From 9dc36d13c3bdb0496e65e6d20dec9028430398cb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 3 May 2021 19:25:16 +0200 Subject: [PATCH] Enhance error management --- htdocs/core/lib/images.lib.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index a1a6e97c8d2..0a0ebe3ce02 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -203,6 +203,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } } + // Test function to read source image exists $imgfonction = ''; switch ($infoImg[2]) { case 1: // IMG_GIF @@ -228,6 +229,34 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, } } + // Test function to write target image exists + if ($filetowrite) { + $imgfonction = ''; + switch ($newExt) { + case 'gif': // IMG_GIF + $imgfonction = 'imagecreatefromgif'; + break; + case 'jpg': // IMG_JPG + $imgfonction = 'imagecreatefromjpeg'; + break; + case 'png': // IMG_PNG + $imgfonction = 'imagecreatefrompng'; + break; + case 'bmp': // IMG_WBMP + $imgfonction = 'imagecreatefromwbmp'; + break; + case 'webp': // IMG_WEBP + $imgfonction = 'imagecreatefromwebp'; + break; + } + if ($imgfonction) { + if (!function_exists($imgfonction)) { + // Fonctions de conversion non presente dans ce PHP + return 'Write of image not possible. This PHP does not support GD functions '.$imgfonction; + } + } + } + // Read source image file switch ($infoImg[2]) { case 1: // Gif