Skip to content

Instantly share code, notes, and snippets.

@austinhappel
Created March 14, 2013 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save austinhappel/5165120 to your computer and use it in GitHub Desktop.
Save austinhappel/5165120 to your computer and use it in GitHub Desktop.

png optimization and filesize comparison

4 pngs were created, each 1000x1000 pixels in dimension 1 png, 80x80 pixels in dimension. It uses the same image as the one used in png-transparent-tinyimage.png

Images can be found here: https://dl.dropbox.com/u/416403/png-test/png-test.zip

  • png-image.png
    • full size photo
  • png-one-color.png
    • fill of one color
  • png-transparent-tinyimage.png
    • 80x80px photo in center, surrounded by transparency
  • png-transparent.png
    • entirely transparent png
  • 80x80-photo.png
    • 80px x 80px photo, copied image from png-transparent-tiny-image.png

before optimization

   14993 Mar 14 11:24 80x80-photo.png
 1124215 Mar 14 11:08 png-image.png
    5232 Mar 14 11:07 png-one-color.png
   26244 Mar 14 11:08 png-transparent-tinyimage.png
    6196 Mar 14 11:17 png-transparent.png

After optimization ( optipng -o7 *.png)

Note: optipng took ~2 minutes to work on these 4 pngs.

   14345 Mar 14 11:29 80x80-photo.png
 1053914 Mar 14 11:21 png-image.png
    1070 Mar 14 11:21 png-one-color.png
   23619 Mar 14 11:21 png-transparent-tinyimage.png
    1083 Mar 14 11:21 png-transparent.png

conclusion

Although the image was the same, the 1000x1000px png-transparent-tinyimg is ~2x the file size of it's 80x80px counterpart. This means that dimensions, as well as pixel content does matter.

The 1000x1000px png-transparent-tinyimg compressed better: ~9% compared to to the ~4% achieved with the 80x80px counterpart.

For an image almost 12 times larger in pixel dimensions than 80x80-photo, the png-transparent-tinyimage is only 1.6x larger in file size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment