Sometimes the solution is under your nose

polettix on 2008-07-04T22:41:34

I think it's hard not to admit that Image::Magick documentation simply sucks. IMHO it's a wonderful module, I simply hate the docs.

One thing that I've been eager to do for a long time has been getting image data in memory instead of writing them to a file. I tried in-memory filehandles, but with no luck. There's always been an interesting ImageToBlob method, but it was a bit short-ranged... at least I believed. Reading the docs, it seemed that it was able to spit data out only in the original format... whatever it means for some dynamically generated image.

Today I had the pleasure to discover that this isn't actually the case. You can use that method to get image data in memory and in any format you want... just pass the magick parameter with the indication of the format:

   my $png_data = $image->ImageToBlob(magick => 'png');


I wish I knew this a long time ago.


The docs are open source too, you know

tirwhan on 2008-07-05T08:34:54

So where's your patch which enables future users to share in your new-found knowledge without having to dig through google and blog-entries? Sometimes one doesn't have the time or energy to "give back", but surely the time spent writing this post would have been better spent creating such a patch?

Sorry, don't mean to be too hard on you, but it always rankles when someone complains about a problem in a piece of OS software which they clearly know how to fix but instead of fixing it they write up their complaint and spew it forth onto the intertubes.

Re:The docs are open source too, you know

polettix on 2008-07-05T15:04:49

Heh, you're 100% right in theory, a little less in practice. The documentation for Image::Magick isn't the usual POD we all love: if you just do perldoc Image::Magick you'll get a couple of screens that redirect you towards the online docs. Figuring out how to "send a patch" for those docs goes well beyond the effort of writing a post here. Call it lazyness :)

There's more, in my opinion. The fact itself of calling such a parameter "magick" is questionable, because it doesn't make it immediately clear what it does. Put it with the fact that it's drowned within a plethora of options, and you easily lose it. This elevates the problem to a higher level than a simple patch: the whole docs should be written in a more "perlish" way, and the doc page linked above could serve as some tutorial.