You are here

function imageapi_image_overlay in ImageCache Actions 6

Same name and namespace in other branches
  1. 5.3 imagecache_canvasactions.module \imageapi_image_overlay()
  2. 5.2 imagecache_canvasactions.module \imageapi_image_overlay()

Place one image over another

Parameters

$image: Base imageapi object.

$overlay: May be a filename or an imageAPI object

$x: Position of the overlay

$y: Position of the overlay

$alpha: Transparency of the overlay from 0-100. 0 is totally transparent. 100 (default) is totally opaque.

$reverse: BOOL flag to indicate the 'overlay' actually goes under the image. As the imageapi callbacks modify the $image object by reference, this is needed to replace the old image resource with the new one.

Return value

bool success

5 calls to imageapi_image_overlay()
canvasactions_canvas2file_image in ./canvasactions.inc
Place the source image on the current background
canvasactions_file2canvas_image in ./canvasactions.inc
Place the source image on the current background
canvasactions_source2canvas_image in ./canvasactions.inc
Place the source image on the current background
imageapi_gd_image_definecanvas in ./canvasactions.inc
Draw a color (or transparency) behind an image
textactions_rendertext_image in ./textrender.inc
Place the text defined in the action onto the current background

File

./imagecache_canvasactions.module, line 120
A collection of canvas (layer) type manipulations for imagecache - including "Watermark"

Code

function imageapi_image_overlay(&$image, &$layer, $x, $y, $alpha = 100, $reverse = FALSE) {
  if (is_string($layer)) {
    if (!file_exists($layer)) {
      trigger_error("Image file does not exist. Attempted to overlay {$layer}", E_USER_ERROR);
      return FALSE;
    }
    $layer = imageapi_image_open($layer);
  }

  // else $layer had better be an image handle
  $x = imagecache_actions_keyword_filter($x, $image->info['width'], $layer->info['width']);
  $y = imagecache_actions_keyword_filter($y, $image->info['height'], $layer->info['height']);
  return imageapi_toolkit_invoke('overlay', $image, array(
    &$layer,
    $x,
    $y,
    $alpha,
    $reverse,
  ));
}