Thread

Posted on Fri Dec 7 00:39:32 2007 by brianski
miscellaneous questions from a newcomer
Hiya. I'm giving up on GD, and a coworker pointed me at Imager - looks great! A few questions:

Am I missing something, or is there no way to tweak the compression level of images generated in PNG format?

Are GIF images created with LZW compression by default? I have libungif installed on my system, and I see that Makefile.PL looks for libgif as well, but I can't install libgif because everything and the kitchen sink that is multimedia related on ubuntu gutsy seems to rely on libungif, w/o support for libgif. Can anyone enlighten me?

It strikes me that it would be handy to have a generic quality level between, say, 0 (low) and 100 (high) that would apply the appropriate format-specific compression ratio, so 90 would map to 90 for jpegquality, 1 for PNG's zlib compression, some best-guess for tiff images, etc. Is there anything that does this already?

The ability to drop down to C for operations that need to be fast is absolutely brilliant. I'm wondering, however, if there is any way to access imager as a stand alone C library, without any perl context?

Thanks a lot!
Direct Responses: 6636 | Write a response
Posted on Fri Dec 7 05:01:22 2007 by tonyc in response to 6631
Re: miscellaneous questions from a newcomer

PNG Compression level - Currently there's no control over the ZIP compression level of PNG images. I'm planning on some re-work of the PNG file format handler similar to the TIFF changes that I've been working on, that should include some control over the compression level.

GIF LZW - GIF compression is controlled completely by libungif/giflib. Unfortunately Debian/Ubuntu are still shipping libungif as the main dependency for any libraries that require the giflib ABI, and the way they have the conflicts setup is badly broken. The only real choice is to install giflib from source, but it's annoying when we use a packaging system to avoid that sort of messing around.

A common compression control - Currently there's no common compression level option you can use, though it's a good idea. It will take some thought however. The jpegquality parameter is a quality output control which happens to help file sizes when it's small, a user specifying 100% compression level is going to expect small files from PNG which exactly match the original, they might get suprised by how ugly their max compression JPEG is.

Imager as C library - Most of the imager source files are independent of perl, so you should be able to package them up into a library, the main exception being dynaload.c. I don't ship any Makefiles/configures to do that however.

Direct Responses: 6638 | Write a response
Posted on Fri Dec 7 12:33:00 2007 by brianski in response to 6636
Re: miscellaneous questions from a newcomer

Excellent, thanks for your answers!

As for the common compression control, hmmm. You're right, it does get messy since Imager has both lossy and lossless backends. I guess what I really need (read: want) is a way to set defaults for my prefered compression levels at Imager->new() timem so I don't have to specify the compression level I want whenever I call write(). So I would say my $img = Imager->new(default_jpeg_compression => 33, default_png_compression => 9, default_tiff_compression => ...); Later calls to write with explicit arguments would of course could override these defaults, however. Whatcha think?

I wonder how much work it would be to create a stand-alone implementation of LZW to fall back on for gif compression. giflib and libgd (at least) both have working implementations which might be snarfed if the license is compatible (this is thinking out loud more than a request)

Cheers,
Brian

Write a response