tungs / timesnap

Node.js program that takes screenshots at smooth intervals of web pages with JavaScript animations
BSD 3-Clause "New" or "Revised" License
234 stars 57 forks source link

fix: fix overriding device scale factor #40

Closed hatemhosny closed 3 years ago

hatemhosny commented 4 years ago

Setting viewport was overriding puppeteer launchOptions that set device scale factor https://github.com/tungs/timesnap/blob/master/index.js#L161

this does not allow improving image quality by setting --launch-arguments="--device-scale-factor=2", or alternatively --launch-arguments="--force-device-scale-factor=2", as mentioned in #30

This fixes it by extracting these options and adding them to config.viewport

You may consider also doing that for the rest of the properties https://pptr.dev/#?product=Puppeteer&version=v5.0.0&show=api-pagesetviewportviewport

I believe this is an important setting for image quality, so you may also consider making it a cli arg

tungs commented 3 years ago

This change was integrated into v0.2.0, as well as allowing for additional viewport options to be defined in the CLI via the key=value, format e.g. --viewport="800,600,deviceScaleFactor=2". From my limited tests, it seems --launch-arguments="--device-scale-factor=2" or --launch-arguments="--force-device-scale-factor=2" does not seem to do anything more than change the deviceScaleFactor of the viewport, so it's probably a better practice to set the scale factor via the viewport option.