Index: branches/5.3.x/core/units/helpers/image_helper.php =================================================================== diff -u -N -r15902 -r15975 --- branches/5.3.x/core/units/helpers/image_helper.php (.../image_helper.php) (revision 15902) +++ branches/5.3.x/core/units/helpers/image_helper.php (.../image_helper.php) (revision 15975) @@ -1,6 +1,6 @@ change resulting image name ! @@ -224,6 +229,9 @@ return @$write_function($dst_image_rs, $params['dst_image']); } + // 4. apply filter + $this->applyFilter($dst_image_rs, $params); + return @$write_function($dst_image_rs, $params['dst_image'], $write_function == 'imagepng' ? 0 : 100); } } @@ -417,6 +425,36 @@ } /** + * Applies filter to an image. + * + * @param resource $src_image_rs Source image. + * @param array $params Parameters. + * + * @return boolean + * @access protected + * @throws InvalidArgumentException When unknown filter type given. + * @link http://php.net/manual/en/function.imagefilter.php + */ + protected function applyFilter(&$src_image_rs, array $params) + { + if ( !array_key_exists('filter_type', $params) ) { + return true; + } + + $filter_type = strtoupper($params['filter_type']); + $filter_params = (array)$params['filter_params']; + + if ( !defined('IMG_FILTER_' . $filter_type) ) { + throw new InvalidArgumentException(sprintf('Unknown filter type "%s"', $filter_type)); + } + + array_unshift($filter_params, constant('IMG_FILTER_' . $filter_type)); + array_unshift($filter_params, $src_image_rs); + + return call_user_func_array('imagefilter', $filter_params); + } + + /** * Returns destination image size without actual resizing (useful for HTML tag) * * @param string $src_image full path to source image (already existing)