Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

polettix (7564)

  (email not shown publicly)

Journal of polettix (7564)

Friday July 04, 2008
05:41 PM

Sometimes the solution is under your nose

[ #36853 ]

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 Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • 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 compla

    • 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