Revision 64c12df6
Von Werner Hahn vor mehr als 6 Jahren hinzugefügt
SL/Controller/Helper/ThumbnailCreator.pm | ||
---|---|---|
24 | 24 |
); |
25 | 25 |
|
26 | 26 |
sub file_create_thumbnail { |
27 |
my ($self) = @_;
|
|
28 |
croak "No picture set yet" if !$self->file_content;
|
|
29 |
|
|
30 |
my $image = GD::Image->new($self->file_content);
|
|
27 |
my ($thumb) = @_;
|
|
28 |
croak "No picture set yet" if !$thumb->{content};
|
|
29 |
$main::lxdebug->dump(0, 'WH: CTHUMB ', $thumb); |
|
30 |
my $image = GD::Image->new($thumb->{content});
|
|
31 | 31 |
my ($width, $height) = $image->getBounds; |
32 | 32 |
my $max_dim = 64; |
33 | 33 |
my $curr_max = max $width, $height, 1; |
... | ... | |
38 | 38 |
|
39 | 39 |
$thumbnail->copyResized($image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); |
40 | 40 |
|
41 |
$self->thumbnail_img_content($thumbnail->png); |
|
42 |
$self->thumbnail_img_content_type('image/png'); |
|
43 |
$self->thumbnail_img_width($new_width); |
|
44 |
$self->thumbnail_img_height($new_height); |
|
45 |
return 1; |
|
41 |
$thumb->{thumbnail_img_content} = $thumbnail->png; |
|
42 |
$thumb->{thumbnail_img_content_type} = "image/png"; |
|
43 |
$thumb->{thumbnail_img_width} = $new_width; |
|
44 |
$thumb->{thumbnail_img_height} = $new_height; |
|
45 |
#$self->thumbnail_img_content($thumbnail->png); |
|
46 |
#$self->thumbnail_img_content_type('image/png'); |
|
47 |
#$self->thumbnail_img_width($new_width); |
|
48 |
#$self->thumbnail_img_height($new_height); |
|
49 |
return $thumb; |
|
46 | 50 |
|
47 | 51 |
} |
48 | 52 |
|
... | ... | |
66 | 70 |
} |
67 | 71 |
|
68 | 72 |
sub file_probe_type { |
69 |
my ($self) = @_; |
|
70 |
|
|
71 |
return (t8("No file uploaded yet")) if !$self->file_content; |
|
72 |
my $mime_type = File::MimeInfo::Magic::magic($self->file_content); |
|
73 |
|
|
74 |
my $info = Image::Info::image_info(\$self->{file_content}); |
|
73 |
my ($content) = @_; |
|
74 |
#$main::lxdebug->dump(0, 'WH: FPT Content', $content); |
|
75 |
return (t8("No file uploaded yet")) if !$content; |
|
76 |
#my $mime_type = File::MimeInfo::Magic::magic($content); |
|
77 |
#$main::lxdebug->dump(0, 'WH: MIME ', $mime_type); |
|
78 |
my $info = Image::Info::image_info(\$content); |
|
79 |
#$main::lxdebug->dump(0, 'WH: INFO', $info); |
|
75 | 80 |
if (!$info || $info->{error} || !$info->{file_media_type} || !$supported_mime_types{ $info->{file_media_type} }) { |
76 | 81 |
$::lxdebug->warn("Image::Info error: " . $info->{error}) if $info && $info->{error}; |
77 | 82 |
return (t8('Unsupported image type (supported types: #1)', join(' ', sort keys %supported_mime_types))); |
78 | 83 |
} |
79 | 84 |
|
80 |
$self->file_content_type($info->{file_media_type}); |
|
81 |
$self->files_img_width($info->{width}); |
|
82 |
$self->files_img_height($info->{height}); |
|
83 |
$self->files_mtime(DateTime->now_local); |
|
85 |
my $thumbnail; |
|
86 |
$thumbnail->{file_content_type} = $info->{file_media_type}; |
|
87 |
$thumbnail->{file_image_width} = $info->{width}; |
|
88 |
$thumbnail->{file_image_height} = $info->{height}; |
|
89 |
$thumbnail->{content} = $content; |
|
90 |
#$self->file_content_type($info->{file_media_type}); |
|
91 |
#$self->files_img_width($info->{width}); |
|
92 |
#$self->files_img_height($info->{height}); |
|
93 |
#$self->files_mtime(DateTime->now_local); |
|
84 | 94 |
|
85 |
$self->file_create_thumbnail;
|
|
95 |
$thumbnail = &file_create_thumbnail($thumbnail);
|
|
86 | 96 |
|
87 |
return ();
|
|
97 |
return $thumbnail;
|
|
88 | 98 |
} |
89 | 99 |
|
90 | 100 |
sub file_update_type_and_dimensions { |
Auch abrufbar als: Unified diff
Shopmodul: Bilder hochladen