maaaaz / webscreenshot

A simple script to screenshot a list of websites
GNU Lesser General Public License v3.0
654 stars 162 forks source link

Add clipping rect when rasterizing to limit image dimensions at sane values #25

Closed manuelbua closed 4 years ago

manuelbua commented 5 years ago

Under some circumstances, the output image can be resized indefinitely by the rasterizer while processing the webpage. For example, the Yahoo homepage can result in an image of size 1200x5000+, some other pages can result in images of size 1200x31000 and a 15.4Mb jpg!

The proposed change is to allow for a maximum of 2x multiplier on the specified/default viewport size: that is, the final image will never be bigger than 1200x1600 with the default configuration.

maaaaz commented 4 years ago

Again thanks for your contribution @manuelbua but I don't know if it is a desirable limitation.

I understand that this can't bloat a screenshot size but this tool was built to be able to capture as much information as possible on a page, so arbitrarily limiting the height is not something I want to put in place, or maybe with a specific option --limit-size in a future release.

And as this feature comes from a file size problem, the recently added format and quality options might answer that need.

Cheers.

manuelbua commented 4 years ago

Yeah made this into an option a while ago and i've now sent a PR to illustrate the general idea.