Giter Club home page Giter Club logo

Comments (1)

peteragarclover avatar peteragarclover commented on June 11, 2024 1

I ran into this issue as well. I would like to migrate to Storycap from Loki as it seems to be significantly faster, but the large screenshots make comparing changes difficult.

I'm aware of the clip option, which looks helpful, but it requires hard coded x/y/width/height.

In Loki, they have a chromeSelector option which they use to automatically determine the clip dimensions:

https://github.com/oblador/loki/blob/02c143c91b450273a8a5468b86d4a8fbd7827bc6/packages/target-chrome-core/src/create-chrome-target.js#L262-L276

In Loki you can provide chromeSelector: "body > *" which will only capture the component root elements (e.g. React root element plus any React Portals). This means the screenshot is still wide, but only as tall as the rendered component, not the entire body element.

Perhaps a similar feature could be added to Storycap? Perhaps an option, like clipSelector?

Storycap already queries the page using the Puppeteer Page API where it specifies the clip option for the screenshot call. This could be a convenient place to automatically calculate the value for clip based on a clipSelector.

// Get PNG image buffer
const rawBuffer = await this.page.screenshot({
fullPage: emittedScreenshotOptions.fullPage,
omitBackground: emittedScreenshotOptions.omitBackground,
captureBeyondViewport: emittedScreenshotOptions.captureBeyondViewport,
clip: emittedScreenshotOptions.clip ?? undefined,

In addition to #506, mentioned above, I found a suggestion in #186 to use Jimp to post-process the images, however, using Jimp significantly increases the total build time. If the original screenshot only captured the rendered div/s, that would be really helpful.

from storycap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.