Fixed Make error in thumbnail generation

This commit is contained in:
Michał 2022-09-12 14:30:57 +00:00
parent 92a1c3500e
commit b5375414bc
2 changed files with 4 additions and 6 deletions

View file

@ -12,12 +12,12 @@ class Make {
*/
function thumbnail($image_path, $thumbnail_path, $resolution) {
try {
$thumbnail = new Imagick($image_path);
$thumbnail = new \Imagick($image_path);
$thumbnail->resizeImage($resolution,null,null,1,null);
$thumbnail->writeImage($thumbnail_path);
return "success";
} catch (Exception $e) {
} catch (\Exception $e) {
return $e;
}
}

View file

@ -38,8 +38,7 @@ if (isset($_POST['submit'])) {
// Attempt making a thumbnail
list($width, $height) = getimagesize($image_path);
if ($width > 300) {
$make_stuff->thumbnail($image_path, $thumb_dir.$image_newname, 300);
if ($make_thumbnail != "success") {
if ($make_stuff->thumbnail($image_path, $thumb_dir.$image_newname, 300) != "success") {
?>
<script>
sniffleAdd('Gwha!', 'We hit a small roadbump during making of the thumbail. We will continue anyway! \n Full Error: <?php echo $make_thumbnail; ?>', 'var(--black)', 'assets/icons/bug.svg');
@ -48,8 +47,7 @@ if (isset($_POST['submit'])) {
}
}
if ($width > 1100) {
$make_stuff->thumbnail($image_path, $preview_dir.$image_newname, 900);
if ($make_preview != "success") {
if ($make_stuff->thumbnail($image_path, $preview_dir.$image_newname, 900) != "success") {
?>
<script>
sniffleAdd('Gwha!', 'We hit a small roadbump during making of the preview. We will continue anyway! \n Full Error: <?php echo $make_preview; ?>', 'var(--black)', 'assets/icons/bug.svg');