From 71e13f626ebe898c59e75c1755a7f3ca7cdbda7e Mon Sep 17 00:00:00 2001 From: "o.pinke" Date: Wed, 11 Oct 2023 17:49:33 +0200 Subject: [PATCH] gdlib fixes --- conlite/includes/functions.api.images.php | 28 ++++++++++------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/conlite/includes/functions.api.images.php b/conlite/includes/functions.api.images.php index 4f7774d..47a9d85 100644 --- a/conlite/includes/functions.api.images.php +++ b/conlite/includes/functions.api.images.php @@ -149,25 +149,23 @@ function capiImgScaleLQ($img, $maxX, $maxY, $crop = false, $expand = false, $cac } } - /* Get out which file we have */ + $imageHandle = null; + switch (strtolower($filetype)) { - case ".gif": $function = "imagecreatefromgif"; + case ".gif": + $imageHandle = imagecreatefromgif($filename); break; - case ".png": $function = "imagecreatefrompng"; + case ".png": + $imageHandle = imagecreatefrompng($filename); break; - case ".jpg": $function = "imagecreatefromjpeg"; - break; - case "jpeg": $function = "imagecreatefromjpeg"; + case ".jpeg": + case "jpg": + $imageHandle = imagecreatefromjpeg($filename); break; default: return false; } - if (function_exists($function)) { - $imageHandle = @$function($filename); - } - - /* If we can't open the image, return false */ - if (!$imageHandle) { + if((gettype($imageHandle) == "object" && get_class($imageHandle) == "GdImage") !== true) { return false; } @@ -696,7 +694,7 @@ function checkImageEditingPosibility() { if (function_exists('gd_info')) { $arrGDInformations = gd_info(); - if (preg_match('#([0-9\.])+#', $arrGDInformations['GD Version'], $strGDVersion)) { + if (preg_match('#([0-9.])+#', $arrGDInformations['GD Version'], $strGDVersion)) { if ($strGDVersion[0] >= '2') { return '2'; } @@ -708,6 +706,4 @@ function checkImageEditingPosibility() { } return '0'; } -} - -?> \ No newline at end of file +} \ No newline at end of file