http://www.perlmonks.org?node_id=1098232

pete_l has asked for the wisdom of the Perl Monks concerning the following question:

There is a small piece of code that does what I expect it to:
#!/usr/bin/perl use Image::Magick; $ipimage = Image::Magick->new(size=>'640x480'); $ipimage->Read("logo:"); $blob1=$ipimage->ImageToBlob(); $opimage = Image::Magick->new(size=>'640x480'); $opimage->BlobToImage($blob1); $opimage->Write("t1.jpg");
It writes a JPEG of the ImageMagick logo. Here is a second piece of code. The only difference is that I have specified an RGB format for the image:
#!/usr/bin/perl use Image::Magick; $ipimage = Image::Magick->new(size=>'640x480'); $ipimage->Set(magick=>'RGB'); $ipimage->Read("logo:"); $blob1=$ipimage->ImageToBlob(); $opimage = Image::Magick->new(size=>'640x480'); $opimage->Set(magick=>'RGB'); $opimage->BlobToImage($blob1); $opimage->Write("t2.jpg");
In this case, the output is still a 640x480 JPEG image. However, the icon is a quarter the size, it's repeated in the top left and right quadrants (the lower half of the image being black) and the image colours are wrong.

I have looked for any worked examples of BlobToImage and come up with nothing. What documentation I have found seems to be abstract API definitions, but without enough information to say for sure if I'm calling it correctly. I'd really appreciate someone explaining to me why I get these different outputs, and how to call BlobToImage for an RGB image (since I need to manipulate the individual colour pixels and GetPixel/SetPixel is far too slow) to create the sort of output that the first code example gives.

With thanks