From 377d78128ff059053ac711ffb5c6a1a9f34de806 Mon Sep 17 00:00:00 2001 From: Alexander Demidov Date: Thu, 26 Dec 2013 23:06:16 +0400 Subject: [PATCH] Correct upload with python pil paste. Add Image::getWatermark() --- Image.class.php | 7 +++++++ Upload.class.php | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/Image.class.php b/Image.class.php index fce7b72..96c4df1 100644 --- a/Image.class.php +++ b/Image.class.php @@ -20,6 +20,8 @@ abstract class Image extends File protected static $sizes = array(); + protected static $watermarks = array(); + public static function getClassName() { return get_called_class(); @@ -50,6 +52,11 @@ abstract class Image extends File return static::$sizes; } + public static function getWatermark($size) + { + return (isset(static::$watermarks[$size])) ? static::$watermarks[$size] : false; + } + public static function getMaxWidth() { return static::$max_width; diff --git a/Upload.class.php b/Upload.class.php index cff16b1..5354fae 100644 --- a/Upload.class.php +++ b/Upload.class.php @@ -79,6 +79,16 @@ abstract class Upload . ' ' . self::getFilePath($image_variant)); ob_clean(); } + 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(); + } } /**