function imageapi_imagemagick_image_definecanvas in ImageCache Actions 6.2
Same name and namespace in other branches
- 6 canvasactions.inc \imageapi_imagemagick_image_definecanvas()
Draw a color (or transparency) behind an image $targetsize is an array expected to contain a width,height and a left,top offset.
Patched with code at issue http://drupal.org/node/844386
File
- canvasactions/
canvasactions.inc, line 395
Code
function imageapi_imagemagick_image_definecanvas(&$image, $action = array()) {
$targetsize = $action['targetsize'];
$backgroundcolor = $action['RGB']['HEX'] != '' ? '#' . $action['RGB']['HEX'] : 'None';
$geometry = "";
if ($targetsize['left'] || $targetsize['top']) {
$offset = ($targetsize['left'] < 0 ? "-" : "+") . (int) $targetsize['left'] . ($targetsize['top'] < 0 ? "-" : "+") . (int) $targetsize['top'];
$geometry = "-geometry {$offset}";
}
$swap = $action['under'] ? '+swap' : '';
$compose = " \\( -size {$targetsize['width']}x{$targetsize['height']} xc:{$backgroundcolor} \\) {$geometry} {$swap} -composite ";
$image->ops[] = $compose;
return TRUE;
}