From bd986fade3d738b3bb3e3c24d1c59743362ccfe0 Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Wed, 11 Jan 2012 16:30:53 +0100 Subject: [PATCH] check if tech_datas has Width & Height key --- .../binaryAdapter/image/resize/gd.class.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/classes/binaryAdapter/image/resize/gd.class.php b/lib/classes/binaryAdapter/image/resize/gd.class.php index 0cafa4af9c..194d9f6308 100644 --- a/lib/classes/binaryAdapter/image/resize/gd.class.php +++ b/lib/classes/binaryAdapter/image/resize/gd.class.php @@ -93,13 +93,19 @@ class binaryAdapter_image_resize_gd extends binaryAdapter_processorAbstract $size = $this->options['size']; - if (!is_null($size) && !$origine->is_raw_image() - && $tech_datas[system_file::TC_DATAS_WIDTH] < $size && $tech_datas[system_file::TC_DATAS_HEIGHT] < $size) + if ( + !is_null($size) + && isset($tech_datas[system_file::TC_DATAS_WIDTH]) + && isset($tech_datas[system_file::TC_DATAS_HEIGHT]) + && !$origine->is_raw_image() + && $tech_datas[system_file::TC_DATAS_WIDTH] < $size + && $tech_datas[system_file::TC_DATAS_HEIGHT] < $size + ) { $size = max($tech_datas[system_file::TC_DATAS_WIDTH], $tech_datas[system_file::TC_DATAS_HEIGHT]); } - - switch($origine->get_mime()) + + switch ($origine->get_mime()) { case "image/jpeg" : $imag_original = imagecreatefromjpeg($origine->getPathname()); @@ -114,7 +120,7 @@ class binaryAdapter_image_resize_gd extends binaryAdapter_processorAbstract return $this; break; } - + if ($imag_original) { @@ -134,8 +140,7 @@ class binaryAdapter_image_resize_gd extends binaryAdapter_processorAbstract $w_sub = (int) (($w_doc / $h_doc) * ($h_sub = $size)); $img_mini = imagecreatetruecolor($w_sub, $h_sub); - imagecopyresampled($img_mini, $imag_original, 0, 0, 0, 0, - $w_sub, $h_sub, $w_doc, $h_doc); + imagecopyresampled($img_mini, $imag_original, 0, 0, 0, 0, $w_sub, $h_sub, $w_doc, $h_doc); } if ($this->options['autorotate'])