From 3de6854186f393d03fd12e56fa484a8eb94b9d88 Mon Sep 17 00:00:00 2001 From: dMetzger Date: Thu, 23 Aug 2012 17:47:03 +0000 Subject: [PATCH] // Fixed upload of the logo in the installer --- install-dev/controllers/http/configure.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/install-dev/controllers/http/configure.php b/install-dev/controllers/http/configure.php index a773016aa..5b21c1024 100644 --- a/install-dev/controllers/http/configure.php +++ b/install-dev/controllers/http/configure.php @@ -125,12 +125,24 @@ class InstallControllerHttpConfigure extends InstallControllerHttp $newwidth = $width * $percent; $newheight = $height * $percent; + if (!is_writable(_PS_ROOT_DIR_.'/img/')) + $error = $this->l('Image folder %s is not writable', _PS_ROOT_DIR_.'/img/'); if (!$error) - if (!is_writable(_PS_ROOT_DIR_.'/img/')) - $error = $this->l('Image folder %s is not writable', _PS_ROOT_DIR_.'/img/'); - else if (!@ImageManager::resize($tmp_name, _PS_IMG_DIR_.'logo.jpg', $newwidth, $newheight)) + { + list($src_width, $src_height, $type) = getimagesize($tmp_name); + $src_image = ImageManager::create($type, $tmp_name); + $dest_image = imagecreatetruecolor($src_width, $src_height); + $white = imagecolorallocate($dest_image, 255, 255, 255); + imagefilledrectangle($dest_image, 0, 0, $src_width, $src_height, $white); + imagecopyresampled($dest_image, $src_image, 0, 0, 0, 0, $src_width, $src_height, $src_width, $src_height); + if (!imagejpeg($dest_image, _PS_ROOT_DIR_.'/img/logo.jpg', 95)) $error = $this->l('An error occurred during logo copy.'); - + else + { + imagedestroy($dest_image); + @chmod($filename, 0664); + } + } } else $error = $this->l('An error occurred during logo upload.');