I want to use imagecache Actions module to create image overlays. The user should upload one image and I want to scale and crop it and then overlay a transparent PNG over it.
I have installed drupal 6 and ImageCache and ImageCache Actions modules. ImageCache Actions defines the imageapi_image_overlay
function.
I have created a ImageCache Preset with the name 590x160_Newsletter
to scale and crop the image.
Image Tool is GD
Heres what I want to do: User uploads an image. This Image is scaled and cropped with the ImageCache preset. Then I want to overlay it with an image (PNG with transparency). I cannot choose this to be in the preset, because it depends on some other settings in the node, which overlay image I want to use.
The scale and crop does work good, but the $image2
after calling imageapi_image_overlay
is still the same (same path, same image) though it says 'success'. But it should be altered like the API reference says
Here is a test code
/* PHP */
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
print "<body style=\"background: lightgreen\">";
$path = "path/to/source/image.jpg";
$opath = "path/to/overlay/image.png";
print '<xmp>';
$image = imageapi_image_open($path);
print '$image: ' . print_r($image,1) . "
";
$image2 =imageapi_image_open(imagecache_create_path('590x160_Newsletter', $path));
print '$image2: ' . print_r($image2,1) . "
";
$overlay = imageapi_image_open($opath);
print imageapi_image_overlay($image2, $overlay, 0, 0, 100, TRUE) ? "success
" : "failure
";
print '$image2 after: ' . print_r($image2,1) . "
";
print '$overlay: ' . print_r($overlay,1) . "
";
print '</xmp>';
print "<img src=\"$image->source\" />";
print "<img src=\"$image2->source\" />";
print "<img src=\"$overlay->source\" />";