Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > open()ing strings as filehandles

Reply
Thread Tools

open()ing strings as filehandles

 
 
J. Sharp
Guest
Posts: n/a
 
      07-15-2009
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 5.9 How can I make a filehandle local to a subroutine? How do I pass filehandles between subroutines? How do I make an array of filehandles? PerlFAQ Server Perl Misc 0 01-12-2011 11:00 PM
open()ing strings as filehandles J. Sharp Perl Misc 2 07-17-2009 02:00 AM
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM
FileHandles to string Andrew Perl 1 07-10-2004 06:00 PM
newbie - Output to multiple Filehandles Jeremy Phillips Perl 1 05-25-2004 01:38 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57