imgmin icon indicating copy to clipboard operation
imgmin copied to clipboard

Checking if lossless png is more efficient

Open fabricasapiens opened this issue 13 years ago • 2 comments

I know this project is to optimize lossy compression, but I guess there are many cases in which lossless compression actually yields better compression rate at superior quality. Examples could be backgrounds with gradients or images with unicolor areas.

Would it be possible to simply generate a PNG for such 'usual suspects' and see if its size is lower than the JPG?

fabricasapiens avatar Jan 17 '12 15:01 fabricasapiens

Yes, probably based on the number of colors in the image.

rflynn avatar Jan 17 '12 15:01 rflynn

On OS X you can compile pngquant with Cocoa reader which gives it JPG support and then run:

pngquant --skip-if-larger input.jpg -o output.png

kornelski avatar May 01 '14 16:05 kornelski