);
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);
}
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} }) {
$thumbnail->{file_image_height} = $info->{height};
$thumbnail->{content} = $content;
- $thumbnail = &file_create_thumbnail($thumbnail);
+ $thumbnail = &file_create_thumbnail($thumbnail, %params);
return $thumbnail;
}
}
1;
+
__END__
=pod
=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 E<lt>wh@futureworldsearch.netE<gt>
-
-=cut
-
-
-=head1 INTERFACE
-
-
-=head1 DEPENDENCIES
-
-
-=head1 SEE ALSO
-
-
+Werner Hahn E<lt>wh@futureworldsearch.netE<gt>