Hi All,

I apologise if this is a newbie post; i'm new to transparent graphics
(PNGs in my case).

I have a transparent PNG on disk, which I want PHP to load into memory
and add some text to ("watermarking", I guess). This seems to be what
is achieved @ http://php.ca/manual/en/image.examples.merged-watermark.php

I have taken the following code almost entirely from the manual, but
can not understand what I have done wrong:

<snip>
//Create the image
$img = @imagecreatetruecolor($width, $height)
      or die("Cannot Initialize new GD image stream");

//Make it transparent
imagesavealpha($img, true);
$trans_colour = imagecolorallocatealpha($img, 0, 0, 0, 127);
imagefill($img, 0, 0, $trans_colour);

//Get the text color
$text_color = imagecolorallocate($img, 255, 0, 0);

//Draw the string
imagestring($img, $font_size, 0, 0,  $string, $text_color);

// Load background image, find position, print
$img2 = imagecreatefrompng('xxx.png');
$yoffset = (imagesx($img2)/2) - (imagesx($img)/2);
imagecopymerge($img2, $img, $yoffset, 5, 0, 0, imagesx($img),
imagesy($img), 100);

// Output the merged images
header ("Content-type: image/png");
imagepng($img2);
</snip>

This code prints the background image with transparancy removed with a
light grey, and the text image in red on a black background in the
correct position.
If I change it to imagepng($img), the text image is printed correctly
(transparency and all)

Suggestions appreciated, i'm lost!

Many thanks,

Alex

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to