Revision ca96627e
Von Bernd Bleßmann vor fast 4 Jahren hinzugefügt
SL/Controller/Helper/ThumbnailCreator.pm | ||
---|---|---|
23 | 23 |
); |
24 | 24 |
|
25 | 25 |
sub file_create_thumbnail { |
26 |
my ($thumb) = @_; |
|
26 |
my ($thumb, %params) = @_; |
|
27 |
|
|
27 | 28 |
croak "No picture set yet" if !$thumb->{content}; |
29 |
|
|
28 | 30 |
my $image = GD::Image->new($thumb->{content}); |
29 | 31 |
my ($width, $height) = $image->getBounds; |
30 |
my $max_dim = 64; |
|
32 |
my $max_dim = $params{size} // 64;
|
|
31 | 33 |
my $curr_max = max $width, $height, 1; |
32 | 34 |
my $factor = $curr_max <= $max_dim ? 1 : $curr_max / $max_dim; |
33 | 35 |
my $new_width = int($width / $factor + 0.5); |
... | ... | |
64 | 66 |
} |
65 | 67 |
|
66 | 68 |
sub file_probe_type { |
67 |
my ($content) = @_; |
|
69 |
my ($content, %params) = @_;
|
|
68 | 70 |
return (t8("No file uploaded yet")) if !$content; |
69 | 71 |
my $info = Image::Info::image_info(\$content); |
70 | 72 |
if (!$info || $info->{error} || !$info->{file_media_type} || !$supported_mime_types{ $info->{file_media_type} }) { |
... | ... | |
78 | 80 |
$thumbnail->{file_image_height} = $info->{height}; |
79 | 81 |
$thumbnail->{content} = $content; |
80 | 82 |
|
81 |
$thumbnail = &file_create_thumbnail($thumbnail); |
|
83 |
$thumbnail = &file_create_thumbnail($thumbnail, %params);
|
|
82 | 84 |
|
83 | 85 |
return $thumbnail; |
84 | 86 |
} |
Auch abrufbar als: Unified diff
S:C:H:ThumbnailCreator: Thumbnail-Größe übergeben können