Jump to content
You must now use your email address to sign in [click for more info] ×

zopfliPNG


aitte

Recommended Posts

Would you be able to include the world's best PNG compressor in the export features? It usually produces files 60-80% of the Affinity PNG size and is available as a C library. The compression is the best in the world, and the only feature they lack is extra-advanced palette optimization (it does optimize, but could be even smarter, it is on their todo list), but even without that they're still smaller than all other PNG compressors.

License is apache 2.0 = free for commercial use if you attribute them in the about-box.

Project was made by Google employees.

If you include it then please preserve control over the various tuning/algorithm parameters (you'll see what I mean if you try their command line version), because that is how to achieve the best compression.

Link to comment
Share on other sites

  • 2 weeks later...

To show the results for some graphics, here are some compression numbers. The "Input size" is the size that was created by Affinity Designer, and the "Result size" is the zopflipng result.

 

+ $ ./zopflipng --filters=01234me -m ~/Downloads/backgrounds.png ~/Downloads/backgroundzop.png 

Optimizing /Users/Aitte/Downloads/backgrounds.png
Filter strategy zero: 152892 bytes
Filter strategy one: 109296 bytes
Filter strategy two: 115480 bytes
Filter strategy three: 113140 bytes
Filter strategy four: 107029 bytes
Filter strategy minimum sum: 105744 bytes
Filter strategy entropy: 105074 bytes
Result is smaller
Input size: 130432 (127K)
Result size: 105074 (102K). Percentage of original: 80.558%
 
+ $ ./zopflipng --filters=01234me -m ~/Downloads/test.png ~/Downloads/z.png
Optimizing /Users/Aitte/Downloads/test.png
Filter strategy zero: 108460 bytes
Filter strategy one: 97149 bytes
Filter strategy two: 100206 bytes
Filter strategy three: 101311 bytes
Filter strategy four: 98841 bytes
Filter strategy minimum sum: 98427 bytes
Filter strategy entropy: 97128 bytes
Result is smaller
Input size: 124845 (121K)
Result size: 97128 (94K). Percentage of original: 77.799%
 
 
Also, you will notice I ran with all filters (01234me), but they recommend "0me" because usually one of those three is gonna be the winner. So a good default profile is "0me". And the extra "-m" flag I specified just makes it do more iterations to try to make the file even smaller, but usually that's not needed.
Link to comment
Share on other sites

  • 2 weeks later...

Hi Andy! Yep I just verified that the license is Apache 2.0 even for the PNG part:

https://github.com/google/zopfli/blob/master/src/zopflipng/zopflipng_lib.h

 

Good luck and have fun investigating this. It would certainly remove the advantage photoshop has in the "export for web" filesize department.

 

If it makes it into Affinity, I suggest something like an export checkbox saying "Optimize Filesize (Slow)" which runs the "0me" algorithms with the default iteration count (usually, but not always, finds the smallest filesize and does it reasonably fast). And an "advanced" button to enable other algorithms or increase iteration count.

 

And... Since zopfli is somewhat slow, it may be worth showing a progress window which shows the algorithms it's trying and what sizes it finds, while the user waits (i.e exactly what the command line tool above outputs). Maybe as some nice "size" bars to get the user excited about getting efficient files for the web. That feedback also helps a lot; i.e next time you wanna export the same resource you may know that the "e (entropy)" algorithm was the correct one for that particular image, and can uncheck the rest to save time. Maybe the GUI could even help do that automatically.

 

Well, there are lots of considerations so I'll let you have fun exploring the tool and checking it out now :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.