waifu2x icon indicating copy to clipboard operation
waifu2x copied to clipboard

Optimize PNGs before serving them to the user (aka reduce filesize losslessly)

Open NintendoManiac64 opened this issue 5 years ago • 5 comments

While I've absolutely no coding ability whatsoever (my expertise is much more in hardware), I couldn't help but notice that simply running something like "APNG Optimizer" (which works for non-animated PNGs as well) at even the default settings easily cuts down the filesize of a waifu2x'd image by like 10 to 20% while being quite fast to process as well (it also includes a zopfli implementation that gives a bit smaller size but is way slower to process).

As a real-world web app example, ezgif.com's APNG maker seems to implement the same libraries that APNG Optimizer relies on.

For reference, here's a link to the APNG Optimizer program, source, libraries: https://sourceforge.net/projects/apng/files/

NintendoManiac64 avatar Dec 13 '18 02:12 NintendoManiac64

Maybe even better: ZopfliPNG (https://github.com/google/zopfli)

EwoutH avatar Jan 06 '19 20:01 EwoutH

Zopfli is actually included in APNG Optimizer as a non-default compression setting.

However, APNG Optimizer actually can at times result in farther smaller file size than Zopfli alone because it also will reduce the color pallete to the smallest lossless value and will also "clean up" anything left in transparent areas (sometimes they can contain the information for multiple colors even when the according colors are displayed as 100% transparent).

NintendoManiac64 avatar Jan 06 '19 23:01 NintendoManiac64

If it is lossless, I will try it. It also helps to reduce the communication cost of the web server.

nagadomi avatar Jan 07 '19 18:01 nagadomi

If you're interested in reducing file sizes, why not go straight for WebP?

cedws avatar Mar 28 '19 21:03 cedws

@c-edw WebP support only reached decent cross-browser support (~80%) in January 2019 with FF65 and Edge 18. Safari still doesn't support it yet.

wopian avatar Mar 28 '19 22:03 wopian