From 5ffdaa44b12aa036abfda5b785c9bf357e3af933 Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Mon, 7 Oct 2013 11:10:34 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B0=20Upl?= =?UTF-8?q?oad.brightnessContrast().=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4?= =?UTF-8?q?=D0=B0=20Upload.getFilePath().?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Upload.class.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Upload.class.php b/Upload.class.php index 35483e9..a037a93 100644 --- a/Upload.class.php +++ b/Upload.class.php @@ -12,11 +12,15 @@ abstract class Upload return $greagwar_image; } + protected static function getFilePath($image) + { + return Config::get('PATH_WEB_ROOT') . DIRECTORY_SEPARATOR . $image->path . DIRECTORY_SEPARATOR . $image->filename; + } + /** * @param $class string|Image * @param $file array (ex. ['tmp_name' => '...', 'name' => '...', 'type' => '...']) * @param $force_create_variants bool - * @param int $quality * @return Image * @throws ErrorException * TODO: Рефакторинг: убрать параметр $force_create_variants @@ -56,7 +60,7 @@ abstract class Upload { $image_variant = new ImageVariant(); if (is_null($greagwar_image)) { - $greagwar_image = self::getGreagwarImage(Config::get('PATH_WEB_ROOT') . DIRECTORY_SEPARATOR . $image->path . DIRECTORY_SEPARATOR . $image->filename); + $greagwar_image = self::getGreagwarImage(self::getFilePath($image)); } $size_parts = explode('x', $size); self::saveImage($image_variant, $greagwar_image, $size_parts[0] ? : null, $size_parts[1] ? : null); @@ -89,4 +93,15 @@ abstract class Upload $image->width = $greagwar_image->width(); $image->height = $greagwar_image->height(); } + + public static function brightnessContrast($image, $value = '0x7') + { + $file_path = self::getFilePath($image); + $output = shell_exec("convert {$file_path} -brightness-contrast {$value} {$file_path} 2>&1"); + if (isset($output) && $output) { + if (class_exists('ErrorMessage')) { + ErrorMessage::log($output); + } + } + } } \ No newline at end of file