mirror of
https://framagit.org/fiat-tux/hat-softwares/lutim.git
synced 2026-03-28 17:42:54 +01:00
Fix #90 — catch Image::Magick problems
This commit is contained in:
@@ -401,25 +401,25 @@ sub add {
|
||||
my ($width, $height);
|
||||
if ($im_loaded && $mediatype ne 'image/svg+xml' && $mediatype !~ m#image/(x-)?xcf# && $mediatype ne 'image/webp') { # ImageMagick don't work in Debian with svg (for now?)
|
||||
my $im = Image::Magick->new;
|
||||
$im->BlobToImage($upload->slurp);
|
||||
if($im->BlobToImage($upload->slurp)) {
|
||||
# Automatic rotation from EXIF tag
|
||||
$im->AutoOrient();
|
||||
|
||||
# Automatic rotation from EXIF tag
|
||||
$im->AutoOrient();
|
||||
# Update the uploaded file with it's auto-rotated clone
|
||||
my $asset = Mojo::Asset::Memory->new->add_chunk($im->ImageToBlob());
|
||||
$upload->asset($asset);
|
||||
|
||||
# Update the uploaded file with it's auto-rotated clone
|
||||
my $asset = Mojo::Asset::Memory->new->add_chunk($im->ImageToBlob());
|
||||
$upload->asset($asset);
|
||||
# Create the thumbnail
|
||||
$width = $im->Get('width');
|
||||
$height = $im->Get('height');
|
||||
$im->Resize(geometry=>'x85');
|
||||
|
||||
# Create the thumbnail
|
||||
$width = $im->Get('width');
|
||||
$height = $im->Get('height');
|
||||
$im->Resize(geometry=>'x85');
|
||||
|
||||
$thumb = 'data:'.$mediatype.';base64,';
|
||||
if ($mediatype eq 'image/gif') {
|
||||
$thumb .= b64_encode $im->[0]->ImageToBlob();
|
||||
} else {
|
||||
$thumb .= b64_encode $im->ImageToBlob();
|
||||
$thumb = 'data:'.$mediatype.';base64,';
|
||||
if ($mediatype eq 'image/gif') {
|
||||
$thumb .= b64_encode $im->[0]->ImageToBlob();
|
||||
} else {
|
||||
$thumb .= b64_encode $im->ImageToBlob();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user