function image_imagemagick_definecanvas in ImageCache Actions 7
Same name and namespace in other branches
- 8 canvasactions/canvasactions.inc \image_imagemagick_definecanvas()
Imagemagick toolkit specific implementation of the define canvas effect.
Parameters
stdClass $image:
array $data: The parameters for this effect. $data['targetsize'] is an array expected to contain a width, height and a left, top.
Return value
bool true on success, false otherwise.
See also
http://www.imagemagick.org/script/command-line-options.php#extent
File
- canvasactions/
canvasactions.inc, line 416
Code
function image_imagemagick_definecanvas(stdClass $image, $data) {
// Reset any gravity settings from earlier effects.
$image->ops[] = '-gravity None';
$backgroundcolor = $data['RGB']['HEX'] != '' ? '#' . ltrim($data['RGB']['HEX'], '#') : 'None';
$image->ops[] = '-background ' . escapeshellarg($backgroundcolor);
$compose_operator = $data['under'] ? 'src-over' : 'dst-over';
$image->ops[] = "-compose {$compose_operator}";
$target_size = $data['targetsize'];
$geometry = sprintf('%dx%d', $target_size['width'], $target_size['height']);
if ($target_size['left'] || $target_size['top']) {
$geometry .= sprintf('%+d%+d', -$target_size['left'], -$target_size['top']);
}
$image->ops[] = '-extent ' . escapeshellarg($geometry);
return TRUE;
}