Browse Source

Добавление метода Upload.brightnessContrast(). Добавление метода Upload.getFilePath().

master
Alexander Demidov 11 years ago
parent
commit
5ffdaa44b1
  1. 19
      Upload.class.php

19
Upload.class.php

@ -12,11 +12,15 @@ abstract class Upload
return $greagwar_image; 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 $class string|Image
* @param $file array (ex. ['tmp_name' => '...', 'name' => '...', 'type' => '...']) * @param $file array (ex. ['tmp_name' => '...', 'name' => '...', 'type' => '...'])
* @param $force_create_variants bool * @param $force_create_variants bool
* @param int $quality
* @return Image * @return Image
* @throws ErrorException * @throws ErrorException
* TODO: Рефакторинг: убрать параметр $force_create_variants * TODO: Рефакторинг: убрать параметр $force_create_variants
@ -56,7 +60,7 @@ abstract class Upload
{ {
$image_variant = new ImageVariant(); $image_variant = new ImageVariant();
if (is_null($greagwar_image)) { 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); $size_parts = explode('x', $size);
self::saveImage($image_variant, $greagwar_image, $size_parts[0] ? : null, $size_parts[1] ? : null); 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->width = $greagwar_image->width();
$image->height = $greagwar_image->height(); $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);
}
}
}
} }
Loading…
Cancel
Save