derpibooru / philomena

Next-generation imageboard
https://derpibooru.org/
GNU Affero General Public License v3.0
218 stars 58 forks source link

Use Oxipng instead of Optipng #279

Open Rainboom-Dash opened 1 year ago

Rainboom-Dash commented 1 year ago

Main reason: lower file sizes while not being longer to compress than default optipng compression

Based on my testing, oxipng usually beats optipng... it can lose in some cases by a few percent (simplistic rasterized images of a vector is an example where it can lose) but overall seems to beat it by a few percent while not taking longer

Even with -o2 and -t1, it seems to overall be more efficient than optipng while also being much faster while keeping it single-threaded

I just did a small test (26 images to be exact) of some recent images under "dashabetes" tag and made sure they were all compressed with default optipng (a lot weren't as I know the compression level was temporarily decreased recently and then turned back up) default optipng: 44.2MiB 8.0 release oxipng -o2: 41MiB 5 images were more efficient with optipng than oxipng but they didn't contribute much difference to the file size most of the time optipng wins, the image was simplistic anyway so the file size was not big

Rainboom-Dash commented 12 months ago

Apparently, Derpibooru still uses -o1 for optipng! I was wrong there It works well for the most part.. but there are instances like the last image in this test where it chooses a poor filter (optipng -o1 versus default [-o2] oxipng) https://cdn.discordapp.com/attachments/730093648548462642/1166281607557169183/SPOILER_comparison.png oxipng does a quick evaluation of 4 filters by default which I believe reduces the chance of this happening

Also, optipng apparently compresses every image twice... for no reason... it makes sense for it to do this with more than 1 trial to cut down on memory.. but with only 1 trial tested, it doesn't really make sense.. so this is PART of the reason why it is so slow compared to oxipng But it's also because oxipng is using libdeflate which is not only capable of much lower file sizes... but also much, much faster

Oxipng does use more memory, so that is something to consider