Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Imager - Problem with Filehandle (Catalyst, DBIx::Class::InflateColumn::FS)

by tonyc (Pilgrim)
on Oct 21, 2009 at 00:44 UTC ( #802348=note: print w/ replies, xml ) Need Help??


in reply to Imager - Problem with Filehandle (Catalyst, DBIx::Class::InflateColumn::FS)

For medium_pfad and thumb_pfad you appear to be supplying Imager objects to something expecting file handles. That can't work.

For the original file, when you read the file via a fh into an Imager image, Imager will read to the end of the image, so unless you seek back to the beginning, only the remnant of the file will be copied (usually nothing) to the file referenced by original.

Fixing this for original is simple enough, just seek back to the beginning of the file.

For medium_pfad and thumb_pfad you could write the images to scalars ($im->write(data => \$data, ...)) and open those using open my $fh, \$data to provide a file handle to D::C::IC:FS)

# something like this my $medium_data; # write to an in-memory file requires a file format $medium->write(type => "png", data => \$data) or die; open my $medium_fh, "<", \$data or die; $self->form->item->medium_pfad($medium_fh);


Comment on Re: Imager - Problem with Filehandle (Catalyst, DBIx::Class::InflateColumn::FS)
Select or Download Code
Re^2: Imager - Problem with Filehandle (Catalyst, DBIx::Class::InflateColumn::FS)
by scrivener (Initiate) on Oct 21, 2009 at 01:58 UTC

    Thank you very much for your help.
    I was able to fix the problem as far as the original file is concerned.
    Neverthless, this doesn't work for me:

    my $data; $thumb->write( type => 'png', data => \$data ) or die; open my $thumb_fh, "<", \$data or die; $self->form->item->thumb_pfad($thumb_fh);

    The resulting file is still corrupted

      Finally I got this to work using IO::String:

      my $data; $thumb->write( type => 'png', data => \$data ) or die; my $thumb_fh = IO::String->new( \$data ) or die; $self->form->item->thumb_pfad($thumb_fh);

      Thanks again for your help


      KvW

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://802348]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (17)
As of 2014-09-23 17:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (232 votes), past polls