2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								<?php
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-16 11:54:23 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								/**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * Class Upload
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 * TODO: При загрузке изображений - использовать экземпляр класса. Убрать статику
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								 */
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								abstract class Upload
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								{
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-09 14:04:26 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    public static $dir_image_cache = 'media/cache/images';
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-10 16:46:29 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-16 11:54:23 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    public static function &getGreagwarImage($file_path)
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-27 10:30:13 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        require_once PATH . '/lib/GreagwarImage/GreagwarImage.php';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        $greagwar_image = new GreagwarImage($file_path);
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-17 12:01:59 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        $greagwar_image->setCacheDir(Config::get('PATH_WEB_ROOT') . DIRECTORY_SEPARATOR . self::$dir_image_cache);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-27 10:30:13 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return $greagwar_image;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-17 12:01:59 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-20 17:29:57 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    public static function getFilePath($image)
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-07 11:10:34 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return Config::get('PATH_WEB_ROOT') . DIRECTORY_SEPARATOR . $image->path . DIRECTORY_SEPARATOR . $image->filename;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    /**
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-19 12:11:40 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     * @param $class string|Image
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-29 18:33:05 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     * @param $file array (ex. ['tmp_name' => '...', 'name' => '...', 'error' => '...'])
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-27 10:30:13 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     * @param $force_create_variants bool
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     * @return Image
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-29 15:01:54 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     * @throws ErrorException
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-29 18:33:05 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     * TODO: Рефакторинг: убрать параметр $force_create_variants?
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     */
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-04 16:47:07 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    public static function image($class, $file, $force_create_variants = true)
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-29 15:01:54 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        /**
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         * @var $image Image
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								         */
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-19 12:11:40 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if (is_null($class) || $class == '') {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            throw new ErrorException('Class not defined.');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if (!is_object($class) && !class_exists($class)) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            throw new ErrorException('Class "' . $class . '" not exists.');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-29 15:01:54 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        Image::checkSubClass($class);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-29 18:33:05 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if (isset($file['error']) && $file['error'] != 0) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            return false;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-19 12:11:40 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        $image = is_object($class) ? $class : new $class;
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        $image->original_filename = $file['name'];
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-27 10:30:13 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        $greagwar_image = self::getGreagwarImage($file['tmp_name']);
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-04 16:47:07 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self::saveImage($image, $greagwar_image, $class::getMaxWidth(), $class::getMaxHeight());
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-16 11:54:23 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        unset($greagwar_image);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-27 10:30:13 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if ($force_create_variants) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-29 15:01:54 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            $sizes = $image->getSizes();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            foreach ($sizes as $size) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-04 16:47:07 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                self::imageVariant($image, $size);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-27 10:30:13 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            }
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return $image;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    /**
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-04 16:47:07 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     * @param $image Image
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     * @param $size string @ex '1200x960'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     * @param $greagwar_image GreagwarImage
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     */
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    public static function imageVariant($image, $size, $greagwar_image = null)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        $image_variant = new ImageVariant();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if (is_null($greagwar_image)) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-07 11:10:34 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            $greagwar_image = self::getGreagwarImage(self::getFilePath($image));
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-04 16:47:07 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        $size_parts = explode('x', $size);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        self::saveImage($image_variant, $greagwar_image, $size_parts[0] ? : null, $size_parts[1] ? : null);
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-16 11:54:23 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        unset($greagwar_image);
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-04 16:47:07 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        $image->variants[$size] = $image_variant;
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-20 17:29:57 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if (Config::get('PYTHON_PIL_RESIZE')) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            $script_file_path = Config::get('PYTHON_PIL_RESIZE')->script_file_path;
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-02 16:37:32 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            $pil_options = isset(Config::get('PYTHON_PIL_RESIZE')->pil_options) ? ' ' . implode(' ', Config::get('PYTHON_PIL_RESIZE')->pil_options) : '';
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-20 17:29:57 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            ob_start();
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-02 16:37:32 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            exec($script_file_path
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                . (($size_parts[0])?' --width=' . $size_parts[0]:'')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                . (($size_parts[1])?' --height=' . $size_parts[1]:'')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                . $pil_options
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                . ' ' . self::getFilePath($image)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                . ' ' . self::getFilePath($image_variant));
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-20 17:29:57 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            ob_clean();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-26 23:06:16 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if ($image->getWatermark($size) && Config::get('PYTHON_PIL_PASTE')) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            $script_file_path = Config::get('PYTHON_PIL_PASTE')->script_file_path;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            $pil_options = (isset(Config::get('PYTHON_PIL_PASTE')->pil_options) && Config::get('PYTHON_PIL_PASTE')->pil_options) ? ' ' . implode(' ', Config::get('PYTHON_PIL_PASTE')->pil_options) : '';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ob_start();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            exec($script_file_path
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                . $pil_options
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                . ' ' . self::getFilePath($image_variant)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                . ' ' . Config::get('PATH_WEB_ROOT') . '/' . $image->getWatermark($size));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ob_clean();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-04 16:47:07 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    /**
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-10 16:46:29 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     * @param $image ImageVariant|Image
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     * @param $greagwar_image GreagwarImage
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     * @param null $width
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     * @param null $height
							 | 
						
					
						
							
								
									
										
										
										
											2013-08-19 12:11:40 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								     * TODO: Сделать возможность передавать параметры для метода _resize()
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								     */
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-16 11:54:23 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    public static function saveImage($image, $greagwar_image , $width = null, $height = null)
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    {
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-16 11:54:23 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        $greagwar_image_clone = clone($greagwar_image);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        unset($greagwar_image);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if ($width || $height) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-23 14:07:03 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if (!(ImageVariant::getIsClass($image)) && Image::getIsSubClass($image)) {
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-16 11:54:23 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                $greagwar_image_clone->resize($width, $height, 0xffffff, $force = false, $rescale = false, $crop = true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-23 14:07:03 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            } else {
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-16 11:54:23 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                $greagwar_image_clone->resize($width, $height, 0xffffff, $force = false, $rescale = false, $crop = false);
							 | 
						
					
						
							
								
									
										
										
										
											2013-09-23 14:07:03 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            }
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-16 11:54:23 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        $image->type = $greagwar_image_clone->guessType();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        $file_path = $greagwar_image_clone->cacheFile($image->type, $quality = 100, true);
							 | 
						
					
						
							
								
									
										
										
										
											2013-11-22 14:58:03 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        chmod($file_path, 0664);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-27 10:30:13 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        $image->size = filesize($file_path);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        $path_parts = pathinfo($file_path);
							 | 
						
					
						
							
								
									
										
										
										
											2013-06-17 12:01:59 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        $image->path = preg_replace('#^' . Config::get('PATH_WEB_ROOT') . '/#', '', $path_parts['dirname']);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        $image->filename = $path_parts['basename'];
							 | 
						
					
						
							
								
									
										
										
										
											2013-12-16 11:54:23 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        $image->width = $greagwar_image_clone->width();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        $image->height = $greagwar_image_clone->height();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        unset($greagwar_image_clone);
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2013-10-07 11:10:34 +04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    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);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2013-05-24 13:27:47 +04:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |