J
J. Sharp
Hello all,
I'm trying to use ImageMagick to create a thumbnail from an image (JPEG) that I
have as a string returned from an SQL query. Image::Magick->Read() will accept
either a filename or an open file handle, so I'm opening the string as and
passing it a reference (?) to it.
my $immk = Image::Magick->new();
open(FH, "<", \$image);
$immk->Read(file => \*FH);
close(FH);
$immk->Thumbnail(width => THUMBNAIL_WIDTH);
open(FH, ">", \$image);
$immk->Write(file => \*FH, filename => 'image.jpg');
close(FH);
When I'm done, I expect to have the thumbnailed image in $image, but I have
NULL! If I try this with real files, everything works fine:
my $immk = Image::Magick->new();
$immk->Read('/tmp/01.jpg');
$immk->Thumbnail(width => THUMBNAIL_WIDTH);
$immk->Write('/tmp/thumbnailed.jpg');
I really have no clue what I'm doing wrong. Thoughts, anyone?
Thanks.
I'm trying to use ImageMagick to create a thumbnail from an image (JPEG) that I
have as a string returned from an SQL query. Image::Magick->Read() will accept
either a filename or an open file handle, so I'm opening the string as and
passing it a reference (?) to it.
my $immk = Image::Magick->new();
open(FH, "<", \$image);
$immk->Read(file => \*FH);
close(FH);
$immk->Thumbnail(width => THUMBNAIL_WIDTH);
open(FH, ">", \$image);
$immk->Write(file => \*FH, filename => 'image.jpg');
close(FH);
When I'm done, I expect to have the thumbnailed image in $image, but I have
NULL! If I try this with real files, everything works fine:
my $immk = Image::Magick->new();
$immk->Read('/tmp/01.jpg');
$immk->Thumbnail(width => THUMBNAIL_WIDTH);
$immk->Write('/tmp/thumbnailed.jpg');
I really have no clue what I'm doing wrong. Thoughts, anyone?
Thanks.