in reply to Setting png compression level in Imager

I poked around a bit. I expect it is possible but I didn't see where/how. It looks like Imager harnesses pnglib which primarily does compression via zlib. I went through the pnglib docs quite a lot and it all seemed a mismatch for things I would call intuitive Perl; like setting the compression level or quality in the write call as you were trying. I also tried your code and quite a few other variations as guesses from the libpng doc and had no luck. I was also a little irritated and surprised by the arbitrary argument acceptance. :| If you figure it out or get an answer, please submit a doc patch. This would be really good to have documented.

You could maybe switch to jpg(?) in the short term. If you're not doing things that are either text oriented or clean deco-ish, jpg is a much better match for file size optimization than png.

Replies are listed 'Best First'.
Re^2: Setting png compression level in Imager
by Anonymous Monk on May 13, 2018 at 05:53 UTC

    Thanks. The program is designed to convert thousands of tiff files to png after performing several operations on them, and the compression needs to be lossless, so no jpegs.

    I did finally find a set of default arg values in the Imager source code, and one of them is compress => 1, but changing it makes no difference in file size. I saved a few images with GIMP using different settings, and judging by file size Imager uses png compression level 6. Also, from the same tests it looks like going to maximum compression from 6 will not give more than 4% improvement. Since I'm already getting better than 3:1 reduction in file size by converting to png's I'll just be happy with that.