You are here

function imagemagick_advanced_imagemagick_arguments_alter in ImageMagick 7

Implements hook_imagemagick_arguments_alter().

File

imagemagick_advanced/imagemagick_advanced.module, line 60
Provides advanced ImageMagick effects and options.

Code

function imagemagick_advanced_imagemagick_arguments_alter(&$args, $context) {

  // Change image density.
  if ($density = (int) variable_get('imagemagick_advanced_density', 0)) {
    $args['density'] = "-density {$density} -units PixelsPerInch";
  }

  // Apply color profile.
  if ($profile = variable_get('imagemagick_advanced_profile', '')) {
    if (file_exists($profile)) {
      $args['profile'] = '-profile ' . escapeshellarg($profile);
    }
  }
  elseif ($colorspace = variable_get('imagemagick_advanced_colorspace', 0)) {

    // Do not hi-jack desaturate effect.
    if (array_search('-colorspace GRAY', $args) === FALSE) {
      $args['colorspace'] = '-colorspace ' . escapeshellarg($colorspace);
    }
  }
}