From 83215978c332ca17ced95fe6369ed46d9122db9c Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Wed, 14 May 2014 14:05:14 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B3=D0=BD=D0=BE=D1=80=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BE=D0=BA=20=D0=BE=D1=82=20unlink=20=D0=B2=20Fil?= =?UTF-8?q?e.=20Upload=20-=20GreagwarImage=20=D1=81=D0=BE=D1=85=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B5=20=D0=B8?= =?UTF-8?q?=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D1=83=D0=B5=D1=82=D1=81?= =?UTF-8?q?=D1=8F,=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=B0=D0=BA=D1=82=D0=B8?= =?UTF-8?q?=D0=B2=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=B1=D0=B8?= =?UTF-8?q?=D0=B1=D0=BB=D0=B8=D0=BE=D1=82=D0=B5=D0=BA=D0=B0=20PythonLibs/I?= =?UTF-8?q?mage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- File.class.php | 6 +++--- Upload.class.php | 23 ++++++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/File.class.php b/File.class.php index d284ff4..44a4104 100644 --- a/File.class.php +++ b/File.class.php @@ -116,14 +116,14 @@ abstract class File * @var $image Image */ if ($this->getIsNoEmpty()) { - unlink($this->getRealPath()); + @unlink($this->getRealPath()); } if (get_parent_class($this) == 'Image') { $image = $this; - foreach ($image->variants as $size) { + foreach ($image->getSizes() as $size) { $image_variant = $image->getVariant($size); if ($image_variant->getIsNoEmpty()) { - unlink($image->getRealPath()); + @unlink($image->getRealPath()); } } } diff --git a/Upload.class.php b/Upload.class.php index 4e4ccfe..2c14dd2 100644 --- a/Upload.class.php +++ b/Upload.class.php @@ -113,15 +113,20 @@ abstract class Upload } else { $greagwar_image = self::getGreagwarImage($tmp_file_path); } - if ($width || $height) { - if (!(ImageVariant::getIsClass($image)) && Image::getIsSubClass($image)) { - $greagwar_image->resize($width, $height, 0xffffff, $force = false, $rescale = false, $crop = true); - } else { - $greagwar_image->resize($width, $height, 0xffffff, $force = false, $rescale = false, $crop = false); - } - } - $image->type = $greagwar_image->guessType(); - $file_path = $greagwar_image->cacheFile($image->type, $quality = 100, true); + $image->type = $greagwar_image->guessType(); + if (!Config::get('PYTHON_PIL_RESIZE')) { + if ($width || $height) { + if (!(ImageVariant::getIsClass($image)) && Image::getIsSubClass($image)) { + $greagwar_image->resize($width, $height, 0xffffff, $force = false, $rescale = false, $crop = true); + } else { + $greagwar_image->resize($width, $height, 0xffffff, $force = false, $rescale = false, $crop = false); + } + } + $file_path = $greagwar_image->cacheFile($image->type, $quality = 100, true); + } else { + $hash = $greagwar_image->getHash($image->type, $quality = 100); + $file_path = $greagwar_image->generateFileFromhash($hash); + } $image->size = filesize($file_path); $path_parts = pathinfo($file_path); $image->path = preg_replace('#^' . Config::get('PATH_WEB_ROOT') . '/#', '', $path_parts['dirname']);