Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by tonyc (Pilgrim)
on Oct 21, 2009 at 00:44 UTC ( [id://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);

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://802348]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-03-28 15:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found