Also see #1022758: Convert format for imagemagick toolkit (with implementation): I added support for the convert format action of imagecache_actions. However that needed a change in imageapi_imagemagick toolkit as well.

Generating a patch for this isolated change is a bit difficult as it would contain many more changes from other patches here, but in short:
file: imageapi_imagemagick.module
function: _imageapi_imagemagick_convert

new code:

function _imageapi_imagemagick_convert($source, $dest, $args) {
  array_unshift($args, '-quality '. escapeshellarg(variable_get('imageapi_imagemagick_quality', 75)));
  // 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.
  $command = escapeshellarg($source) . ' ' . implode(' ', $args);
  // if we want to force the image format, we have to precede the destination file with the requested type and a colon
  // see e.g. www.wizards-toolkit.org/discourse-server/viewtopic.php?f=2&t=11697&start=0%3Cbr%20/%3E
    if (substr($command, -1) !== ':') {
    $command .= ' ';
  }
  $command .= escapeshellarg($dest);

  if (0 != _imageapi_imagemagick_convert_exec($command, $output, $errors)) {
    return FALSE;
  }
  return file_exists($dest);
}

the code for the quality parameter had to be moved to the front (allowing to override it....) as format specifier must be last and mmay not have a space after it.

Comments

sun’s picture