[Catalyst] error in reading filehandler when creating thumbnails

Steve steve at matsch.com
Wed Nov 16 16:20:50 GMT 2011


This is not really a Catalyst question.  Having said that, I don't see 
where &read_callback is defined.  It also looks like your 'Args(0)' is 
screwed up - where do you expect to find $path, $fh, and $photos???

On 11/16/2011 10:49 AM, Tanya wrote:
> hello,
>
> =head2 generate_thumbnail
>
> We tried to create an image gallaery for my photos with catalyst. Few
> image files were uploaded and in database columns named 'path' in a
> table named  'photos'.  The schema of the database is named  'photo'.
> After 'stashing' the contents of the table 'photo', when trying to
> process the data from the 'stash'  to create 'thumbnails' using the
> following methods which is failing at the 'read statement.. It says
> "callback parameter missing" Can someone help me solve this please?
> Thankyou.
>
> =cut
>
> sub generate_thumbnail : Chained('get_photos') PathPart('thumbnail') Args(0) {
>          my ( $self, $c, $path, $fh, $photos ) = @_;
>          my $photos = $c->stash->{photos};
>          my $size  = $self->thumbnail_size;
>          my $mimeinfo = File::MimeInfo->new;
>          my $data = open($fh,">  $photos->$path") or die "Error: $!";
>          my $img = Imager->new;
>          my ($max_width, $max_height, $max_bytes) =
>                 Imager->get_file_limits();
>
> #------Giving error at read statement -------  Any suggestions? ----****
>
> #       $img->read(callback =>  \&read_callback) or die;
>           $img->read( $fh =>  $data,  type =>  'jpg') or die $img->errstr;
>
>
>          my $scaled = $img->scale( xheight =>  $size );
>          my $out;
>          $scaled->write(
>              type =>  $mimeinfo->extensions( $photos->mime ),
>              data =>  \$out
>            )
>            or die $scaled->errstr;
>          $c->res->content_type( $photos->mime );
>          $c->res->content_length( $out );
>          $c->res->header( "Content-Disposition" =>  "inline; filename="
>                . $mimeinfo->extensions( $photos->mime ) );
>
>          binmode $out;
>          $c->res->body($out);
>
> }
>
> CHEERS :-) TANYA
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/



More information about the Catalyst mailing list