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: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to