diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index 0f0ff2cf7be..bb874b7b6ec 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -1,7 +1,7 @@ * Copyright (C) 2005-2007 Regis Houssin - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -315,6 +315,10 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, break; } + if ($img === null) { + return "Error: Could not create Image from '$filetoread'"; + } + // Create empty image for target if ($newExt == 'gif') { // Compatibility image GIF @@ -615,6 +619,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', // Variable initialization according to image extension $img = null; + $extImg = null; switch ($infoImg[2]) { case IMAGETYPE_GIF: // 1 $img = imagecreatefromgif($filetoread); @@ -805,7 +810,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small', imagejpeg($imgThumb, $imgThumbName, $newquality); // @phan-suppress-current-line PhanTypeMismatchArgumentNullableInternal,PhanPossiblyUndeclaredVariable break; case IMAGETYPE_PNG: // 3 - imagepng($imgThumb, $imgThumbName, $newquality); // @phan-suppress-current-line PhanPossiblyUndeclaredVariable + imagepng($imgThumb, $imgThumbName, !is_numeric($newquality) ? -1 : (int) $newquality); // @phan-suppress-current-line PhanPossiblyUndeclaredVariable break; case IMAGETYPE_BMP: // 6 // Not supported by PHP GD