function image_imagemagick_definecanvas in ImageCache Actions 8
Same name and namespace in other branches
- 7 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 414
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}";
$targetsize = $data['targetsize'];
$geometry = sprintf('%dx%d', $targetsize['width'], $targetsize['height']);
if ($targetsize['left'] || $targetsize['top']) {
$geometry .= sprintf('%+d%+d', -$targetsize['left'], -$targetsize['top']);
}
$image->ops[] = '-extent ' . escapeshellarg($geometry);
return TRUE;
}