[handle_pixel] don't fail silently when imagemagick fails - see #1006

This commit is contained in:
Shish 2024-01-09 17:59:41 +00:00
parent d986d0d378
commit c16aeca4d8

View file

@ -47,19 +47,8 @@ class PixelFileHandler extends DataHandlerExtension
try {
create_image_thumb($image);
return true;
} catch (InsufficientMemoryException $e) {
log_warning("handle_pixel", "Insufficient memory while creating thumbnail: ".$e->getMessage());
$tsize = get_thumbnail_max_size_scaled();
$thumb = imagecreatetruecolor($tsize[0], min($tsize[1], 64));
$white = imagecolorallocate($thumb, 255, 255, 255);
$black = imagecolorallocate($thumb, 0, 0, 0);
imagefill($thumb, 0, 0, $white);
imagestring($thumb, 5, 10, 24, "Image Too Large :(", $black);
// FIXME: write the image to disk??
return true;
} catch (\Exception $e) {
log_error("handle_pixel", "Error while creating thumbnail: ".$e->getMessage());
return false;
throw new UploadException("Error while creating thumbnail: ".$e->getMessage());
}
}