diff -up orig/imageapi/imageapi_gd.module patched/imageapi/imageapi_gd.module --- orig/imageapi/imageapi_gd.module 2011-05-16 17:22:12.000000000 +0100 +++ patched/imageapi/imageapi_gd.module 2011-10-05 17:10:23.714542000 +0100 @@ -71,7 +71,7 @@ function imageapi_gd_image_open($image) * @return * TRUE or FALSE, based on success. */ -function imageapi_gd_image_close($image, $destination) { +function imageapi_gd_image_close($image, $destination, $op = NULL) { $extension = str_replace('jpg', 'jpeg', $image->info['extension']); $function = 'image'. $extension; if (!function_exists($function)) { @@ -81,7 +81,16 @@ function imageapi_gd_image_close($image, imageinterlace($image->resource, 1); } if ($extension == 'jpeg') { - return $function($image->resource, $destination, variable_get('imageapi_jpeg_quality', 75)); + if (empty($op)){ + $op = new stdClass(); + } + $op->quality = variable_get('imageapi_jpeg_quality', 75); + + // Allow other modules to alter if the following member variables are present: + if (isset($op->module) && isset($op->name)) { + drupal_alter('imageapi_quality', $op); + } + return $function($image->resource, $destination, $op->quality); } else { // Always save PNG images with full transparency. diff -up orig/imageapi/imageapi_imagemagick.module patched/imageapi/imageapi_imagemagick.module --- orig/imageapi/imageapi_imagemagick.module 2011-05-16 17:22:12.000000000 +0100 +++ patched/imageapi/imageapi_imagemagick.module 2011-10-05 16:40:00.231133000 +0100 @@ -101,8 +101,8 @@ function imageapi_imagemagick_image_open return $image; } -function imageapi_imagemagick_image_close($image, $dst) { - return _imageapi_imagemagick_convert($image->source, $dst, $image->ops); +function imageapi_imagemagick_image_close($image, $dst, $op = NULL) { + return _imageapi_imagemagick_convert($image->source, $dst, $image->ops, $op); } function imageapi_imagemagick_image_crop(&$image, $x, $y, $width, $height) { @@ -144,8 +144,18 @@ function imageapi_imagemagick_image_desa /** * Calls the convert executable with the specified filter. */ -function _imageapi_imagemagick_convert($source, $dest, $args) { - $args['quality'] = '-quality '. escapeshellarg(variable_get('imageapi_imagemagick_quality', 75)); +function _imageapi_imagemagick_convert($source, $dest, $args, $op = NULL) { + if (empty($op)){ + $op = new stdClass(); + } + $op->quality = variable_get('imageapi_imagemagick_quality', 75); + + // Allow other modules to alter if the following member variables are present: + if (isset($op->module) && isset($op->name)) { + drupal_alter('imageapi_quality', $op); + } + $args['quality'] = '-quality '. escapeshellarg($op->quality); + // To make use of ImageMagick 6's parenthetical command grouping we need to make // the $source image the first parameter and $dest the last. // See http://www.imagemagick.org/Usage/basics/#cmdline for more info. diff -up orig/imageapi/imageapi.module patched/imageapi/imageapi.module --- orig/imageapi/imageapi.module 2011-05-16 17:22:12.000000000 +0100 +++ patched/imageapi/imageapi.module 2011-10-05 16:51:36.771515000 +0100 @@ -157,11 +157,12 @@ function imageapi_default_toolkit() { * @return * Mixed values (typically Boolean indicating successful operation). */ -function imageapi_toolkit_invoke($method, &$image, array $params = array()) { +function imageapi_toolkit_invoke($method, &$image, array $params = array(), $op = NULL) { $function = $image->toolkit . '_image_' . $method; if (function_exists($function)) { array_unshift($params, $image); $params[0] = &$image; + $params['op'] = $op; return call_user_func_array($function, $params); } watchdog('imageapi', 'The selected image handling toolkit %toolkit can not correctly process %function.', array('%toolkit' => $image->toolkit, '%function' => $function), WATCHDOG_ERROR); @@ -396,11 +397,11 @@ function imageapi_image_open($file, $too * @return * TRUE or FALSE, based on success. */ -function imageapi_image_close($image, $destination = NULL) { +function imageapi_image_close($image, $destination = NULL, $op = NULL) { if (empty($destination)) { $destination = $image->source; } - if ($return = imageapi_toolkit_invoke('close', $image, array($destination))) { + if ($return = imageapi_toolkit_invoke('close', $image, array($destination), $op)) { // Clear the cached file size and refresh the image information. clearstatcache(); $image->info = image_get_info($destination); Only in patched/imageapi: translations