You are here

function imageapi_imagemagick_image_definecanvas in ImageCache Actions 6

Same name and namespace in other branches
  1. 6.2 canvasactions/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.

File

./canvasactions.inc, line 299
Helper functions for the text2canvas action for imagecache

Code

function imageapi_imagemagick_image_definecanvas(&$image, $action = array()) {
  $targetsize = $action['targetsize'];
  $RGB = $action['RGB'];

  # TODO needs work.

  #
  $crop = " -background '#{$RGB['HEX']}' -crop   '{$targetsize['width']}x{$targetsize['height']}-{$targetsize['left']}-{$targetsize['top']}!' ";
  $draw = '';
  $draw = " -draw '";
  $draw .= " fill '#{$RGB['HEX']}' polygon 0,0 {$targetsize['width']},0 {$targetsize['width']},{$targetsize['height']} 0,{$targetsize['height']} ";
  $draw .= " ' ";

  #$draw .= " -composite ";
  $draw .= " +repage ";
  $compose = " {$crop} {$draw} ";
  $image->ops[] = $compose;
  return TRUE;
}