...

View Full Version : Resolved Transparent watermark



Ludatha
10-31-2009, 11:30 PM
http://ludatha.com/test/watermark/

This script displays a watermark in the center of any given image, the problem is, it doesn't seem to keep the transparency from the previous image.

The image I want to use as a watermark is
http://ludatha.com/themes/ludatha/images/logo.png
http://ludatha.com/themes/ludatha/images/logo.png

Does anyone know how to keep the transparency?

This is the code


function watermark(){
header('content-type: image/jpeg');

$watermark = imagecreatefrompng('http://ludatha.com/themes/ludatha/images/logo.png');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
$image = imagecreatetruecolor($watermark_width, $watermark_height);
$image = imagecreatefromjpeg('http://fc05.deviantart.com/fs49/i/2009/218/6/7/Emma_1_by_ludatha.jpg');
$size = getimagesize('http://fc05.deviantart.com/fs49/i/2009/218/6/7/Emma_1_by_ludatha.jpg');
$dest_x = ($size[0] /2) - ($watermark_width / 2);
$dest_y = ($size[1] /2) - ($watermark_height / 2);
imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);
}

mlseim
11-01-2009, 12:40 AM
Without knowing much about your PNG image, 24 bit, 8 bit, transparency?
... try changing the 100 to 20 ... see below ...

imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 20);

Ludatha
11-01-2009, 12:46 AM
Without knowing much about your PNG image, 24 bit, 8 bit, transparency?
... try changing the 100 to 20 ... see below ...

imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 20);

http://ludatha.com/test/watermark/
I did that, but the background still isn't transparent...

I think it's 24bit

EDIT: I found this, http://drupal.org/node/80369
PROBLEM SOLVED :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum