X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FHelper%2FThumbnailCreator.pm;h=cc262d130d1c728521648214decebfc1393fa3af;hb=9dfd320ff258071e3ad78dd6cf2d76e215efd4f7;hp=6f3099871425bf6d9fa5f3de36a9d61569da3d82;hpb=60566f88588ad476cfe20195ef91b4e2ff9586b6;p=kivitendo-erp.git diff --git a/SL/Controller/Helper/ThumbnailCreator.pm b/SL/Controller/Helper/ThumbnailCreator.pm index 6f3099871..cc262d130 100644 --- a/SL/Controller/Helper/ThumbnailCreator.pm +++ b/SL/Controller/Helper/ThumbnailCreator.pm @@ -23,11 +23,13 @@ our %supported_mime_types = ( ); sub file_create_thumbnail { - my ($thumb) = @_; + my ($thumb, %params) = @_; + croak "No picture set yet" if !$thumb->{content}; + my $image = GD::Image->new($thumb->{content}); my ($width, $height) = $image->getBounds; - my $max_dim = 64; + my $max_dim = $params{size} // 64; my $curr_max = max $width, $height, 1; my $factor = $curr_max <= $max_dim ? 1 : $curr_max / $max_dim; my $new_width = int($width / $factor + 0.5); @@ -64,7 +66,7 @@ sub file_probe_image_type { } sub file_probe_type { - my ($content) = @_; + my ($content, %params) = @_; return (t8("No file uploaded yet")) if !$content; my $info = Image::Info::image_info(\$content); if (!$info || $info->{error} || !$info->{file_media_type} || !$supported_mime_types{ $info->{file_media_type} }) { @@ -78,7 +80,7 @@ sub file_probe_type { $thumbnail->{file_image_height} = $info->{height}; $thumbnail->{content} = $content; - $thumbnail = &file_create_thumbnail($thumbnail); + $thumbnail = &file_create_thumbnail($thumbnail, %params); return $thumbnail; } @@ -102,6 +104,7 @@ sub file_update_type_and_dimensions { } 1; + __END__ =pod @@ -110,31 +113,12 @@ __END__ =head1 NAME - SL::DB::Helper::ThumbnailCreator - DatabaseClass Helper for Fileuploads +SL::Controller::Helper::ThumbnailCreator - Helper for Fileuploads =head1 SYNOPSIS - use SL::DB::Helper::ThumbnailCreator; - - # synopsis... - -=head1 DESCRIPTION - - # longer description.. +use SL::Controller::Helper::ThumbnailCreator; =head1 AUTHOR - Werner Hahn Ewh@futureworldsearch.netE - -=cut - - -=head1 INTERFACE - - -=head1 DEPENDENCIES - - -=head1 SEE ALSO - - +Werner Hahn Ewh@futureworldsearch.netE