BlobToImage can not produce image from Oracle DB - help

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
sdj
Posts: 1
Joined: 2011-08-29T11:01:30-07:00
Authentication code: 8675308

BlobToImage can not produce image from Oracle DB - help

Post by sdj »

Hi there,

I am reading Oracle database of BLOB (images..don't know what format those are but trying to read and want to display or store it in a file.

my $test_image;
my $image=Image::Magick->new(magick=>'jpg', size =>'640x480',depth=>72);

$sql = "select my_image from all_images_BLOB where id_pk = 123";
$sth = $dbh->prepare( $sql );
$sth->execute();
$sth->bind_columns(undef,\$test_image);
while($sth->fetch()) {
$image->BlobToImage($test_image);
$image->Write('example_out.jpg');
}


$sth->finish();
$dbh->disconnect();

Somehow, I get a file with 0 bytes.

But when change one line in above code:
$image->Write('example_out.jpg'); to $image->Write('example_out.bmp);

I get Image but its all black.

I really appreciate your help in this,

Thank you in advance,
SDJ
delilama
Posts: 2
Joined: 2011-10-09T11:48:43-07:00
Authentication code: 8675308

Re: BlobToImage can not produce image from Oracle DB - help

Post by delilama »

Just write out the blob. See what it looks like. Maybe your blob is in some different format, and this is why it's failing?
jchimene
Posts: 3
Joined: 2011-10-11T21:37:55-07:00
Authentication code: 8675308

Re: BlobToImage can not produce image from Oracle DB - help

Post by jchimene »

I've been doing this from MySQL, but the principal is the same.

I use $dbh->selectall_arrayref(), but the end result should be the same

Couple questions:
1) Shouldn't you be calling new() for each image?
2) You're not checking the result of the Write. There may be a return result that will provide A Clue
LOGDIE is from Log::Log4perl qw(:easy);
$image->BlobToImage( $result->[$v]{cargo} );
eval {
LOGDIE $! unless $image->Write( $file[0] ) > 0;
};
if ($@)
{
LOGDIE qq/Cannot write image $file[0]: $@\n/;
}
Post Reply