Open tonycoz opened 2 years ago
This would be very nice!
For PNG, there are libraries like libimagequant, zopfli/zopflipng, libimageflow and opnglib (created and used by optipng). OptiPNG also provides interesting documentation on how they optimize PNG images.
Hope this helps!
Imager generally tries to make the output file match the structure of the original image, if the Imager image is direct colour RGB 16-bit/sample, then the image handlers try to produce a 16-bit RGB direct colour file, if the format supports it.
For many uses being able to produce a smaller image is preferred over matching the structure of the image, so we should provide some support for that. Imager itself could include an API for testing whether specific optimizations are possible, based on what the user requests, and what the image file supports. e.g. when writing to PNG it might be good to write a paletted image for an RGB image, while that's pointless to check for with JPEG.
Some possible lossless optimizations:
Some possible lossy optimizations:
Image format specific optimizations are outside the the scope of this, but:
General image format specific optimizations: