jasonraimondi / url-to-png

Selfhosted. URL to PNG utility featuring parallel rendering using Playwright for screenshots and with storage caching via Local, S3, or CouchDB
https://jasonraimondi.github.io/url-to-png/
MIT License
156 stars 28 forks source link

add `deviceScaleFactor` support #12

Closed AnnatarHe closed 3 years ago

AnnatarHe commented 3 years ago

puppeteer support deviceScaleFactor for high resolution screenshot. can we support that parameter?

I notice that maybe we can change this line: https://github.com/jasonraimondi/url-to-png/blob/master/src/services/image-render.service.ts#L62

jasonraimondi commented 3 years ago

@AnnatarHe I just added a branch called device-scale-factor that supports this field, but in my testing, I did not see any output difference of screenshots. Do you mind testing and seeing if this does what you are expecting?

http://localhost:3000/?url=https://jasonraimondi.com // defaults to 1
http://localhost:3000/?url=https://jasonraimondi.com&deviceScaleFactor=2
http://localhost:3000/?url=https://jasonraimondi.com&deviceScaleFactor=3

All of the above seemed to me to be relatively the same output screenshot.

AnnatarHe commented 3 years ago

I clone the repo and switch to branch device-scale-factor

and tried to download

http://localhost:3000/?url=https%3A%2F%2Fjasonraimondi.com&isMobile=true&isFullPage=true&viewPortWidth=375&width=375&deviceScaleFactor=1

by change width and deviceScaleFactor with width=375, width=1125 and deviceScaleFactor=1, deviceScaleFactor=3

and Airdrop to iPhone 12 try to scale image

In my eyes I think width=1125 and deviceScaleFactor=3 has the best quality

jasonraimondi commented 3 years ago

Oh awesome thank you for the great update! I'll go ahead and merge this into master and get a tag out for v1.2.0

jasonraimondi commented 3 years ago

merged #13