mozilla-services / screenshots

Firefox Screenshots: the best way to take screenshots on the web.
https://screenshots.firefox.com
Mozilla Public License 2.0
620 stars 128 forks source link

PNG images are not optimized #5436

Open atoponce opened 3 years ago

atoponce commented 3 years ago

Saving screenshots are not optimized. On average, screenshots could be about 30%-40% smaller on download. For example, if I take a screenshot of the first published comic of SMBC, and download, the file size is 58162 bytes:

$ ls -l /tmp/smbc.png 
-rw-r--r-- 1 aaron aaron 58162 Aug 27 21:35 /tmp/smbc.png

Optimizing the image reduces it by 40.99%:

$ optipng /tmp/smbc.png
** Processing: /tmp/smbc.png
468x612 pixels, 4x8 bits/pixel, RGB+alpha
Reducing image to 8 bits/pixel, 64 colors in palette
Input IDAT size = 58021 bytes
Input file size = 58162 bytes

Trying:
  zc = 9  zm = 8  zs = 0  f = 0     IDAT size = 34063

Selecting parameters:
  zc = 9  zm = 8  zs = 0  f = 0     IDAT size = 34063

Output IDAT size = 34063 bytes (23958 bytes decrease)
Output file size = 34324 bytes (23838 bytes = 40.99% decrease)

The new file size (as reported by optipng(1)) is now 34324 bytes:

$ ls -l /tmp/smbc.png  
-rw-rw-r-- 1 aaron aaron 34324 Aug 27 21:36 /tmp/smbc.png