Automattic / mShots

Website Thumbnail/Snapshot Service
GNU General Public License v2.0
100 stars 21 forks source link

Add format param to allow saving PNGs #74

Closed alshakero closed 2 years ago

alshakero commented 2 years ago

This addsquality param to allow creating higher quality images. The simpler and safer solution would be to change the default quality to 100 instead of 90.

This adds a format param to allow choosing between jpeg and png. It defaults to jpeg. I tried JPEG quality 100, and it's still subpar. And sadly, webp is not supported by neither PHP nor Puppeteer.

The quality of images is key to user conversion in Link in Bio flow. To see how pixelated current screenshots are, please visit https://wordpress.com/setup/patterns?flow=link-in-bio.

Testing instructions

  1. Clone this repo.
  2. Make sure you have Docker installed.
  3. Run npm start.
  4. Visit http://localhost:8000/mshots/v1/page.com and verify that you'll get a JPEG (by checking DevTools > Network tab).
  5. Visit http://localhost:8000/mshots/v1/page.com?format=jpeg and verify that you'll get a JPEG.
  6. Visit http://localhost:8000/mshots/v1/page.com?format=png and verify that you'll get a PNG.
  7. Visit http://localhost:8000/mshots/v1/page.com?format=xml and verify that you'll get a JPEG.
escapemanuele commented 2 years ago

I tried and it always returned 404 to me, but it is probably something wrong in my installation/testing. Will try again later 👍

alshakero commented 2 years ago

Thanks for the feedback @aidvu and @xknown! I addressed it all here: https://github.com/Automattic/mShots/pull/75.