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