You are here

function imageapi_gd_image_overlaytext_alpha in ImageCache Actions 6

Same name and namespace in other branches
  1. 5.3 textactions.inc \imageapi_gd_image_overlaytext_alpha()
  2. 5.2 textactions.inc \imageapi_gd_image_overlaytext_alpha()

Place text on an image.

File

./textactions.inc, line 379
Helper functions for imagecache_textactions

Code

function imageapi_gd_image_overlaytext_alpha(&$image, $text, $size = 12, $x = 0, $y = 0, $RGB, $fontfile = 'MgOpenModernaBold', $angle = 0) {
  $color = imagecolorallocatealpha($image->resource, $RGB['red'], $RGB['green'], $RGB['blue'], $RGB['alpha']);

  // Merging images where one or the other is partially transparent needs to be supported or we get black blocks.
  //  EG text over PNG
  // This flag will be lost again in jpegs, but that's after we've merged, so it's OK.
  imagesavealpha($image->resource, TRUE);
  imagealphablending($image->resource, TRUE);
  $bounds = imagettftext($image->resource, $size, $angle, $x, $y, $color, $fontfile, $text);
  if (empty($bounds)) {
    return FALSE;
  }
  return TRUE;
}