function _imagemagick_convert in ImageMagick 7
Calls the convert executable with the specified filter.
1 call to _imagemagick_convert()
- image_imagemagick_save in ./
imagemagick.module - Writes an image resource to a destination file.
File
- ./
imagemagick.module, line 369 - Provides ImageMagick integration.
Code
function _imagemagick_convert($source, $destination, $args) {
// Backup original paths for alter hook context.
$source_original = $source;
$destination_original = $destination;
$source = drupal_realpath($source);
$destination = drupal_realpath($destination);
$destination_format = '';
$args['quality'] = '-quality ' . escapeshellarg(variable_get('imagemagick_quality', 75));
// Allow other modules to alter the ImageMagick command line parameters.
$context = array(
'source' => &$source,
'source_original' => $source_original,
'destination' => &$destination,
'destination_original' => $destination_original,
'destination_format' => &$destination_format,
);
drupal_alter('imagemagick_arguments', $args, $context);
// If the format of the derivative image was changed, concatenate the new
// image format and the destination path, delimited by a colon.
// @see http://www.imagemagick.org/script/command-line-processing.php#output
// @see hook_imagemagick_arguments_alter()
if ($destination_format !== '') {
$destination_format .= ':' . $destination;
}
else {
$destination_format = $destination;
}
// GraphicsMagick arguments:
// gm convert [options] input output
// @see http://www.graphicsmagick.org/GraphicsMagick.html
if (variable_get('imagemagick_gm', 0)) {
array_unshift($args, 'convert');
$args[] = escapeshellarg($source);
$args[] = escapeshellarg($destination_format);
}
else {
array_unshift($args, escapeshellarg($source));
$args[] = escapeshellarg($destination_format);
}
$command_args = implode(' ', $args);
if (_imagemagick_convert_exec($command_args, $output, $error) !== TRUE) {
return FALSE;
}
return file_exists($destination);
}