Code: Select all
my $image = Image::Magick->new;
# $imagebuffer is the BLOB of the image
if( 1 != $image->BlobToImage( $imagebuffer ) ) {
undef $imagebuffer;
$log->logcroak("2:ImageMagick:BlobToImage() failed: $!");
}
# convert non jpeg images to jpeg
unless ($imgmagick eq "JPEG") {
if ($imgmagick eq "PNG" || $imgmagick eq "GIF") {
# Going for lossless conversion
$image->Set(quality=>100,compression=>'none',magick=>'jpeg');
$image->Strip();
}
}
$jpegRawImageBuffer = $image->ImageToBlob();
return $jpegRawImageBuffer;
If someone has working code, I'd appreciate a posting - thanks!