Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Watermarking with png-24 formatted files
As the title says... I would like to apply a watermark to a jpg image. To maximise quality (alpha transparency + anti-aliased fonts) I would really like to use a png-24 formatted file. The thing is, it is not very well supported by PHP and GD, and I get a black background instead of a transparent one.
I am no SUPER whiz at php, and I was wondering if anyone could lend a hand.
This is what I have now.
I am no SUPER whiz at php, and I was wondering if anyone could lend a hand.
This is what I have now.
$watermark = imagecreatefrompng($watermark_image);
//imagetruecolortopalette($watermark, false, 256); // convert
$greyish = imagecolorresolve($watermark, 200, 200, 200); // resolve given palette entry
imagecolortransparent($watermark, $greyish);
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
// Position Overlay in Bottom Right
$dest_x = $neww - $watermark_width;
$dest_y = $newh - $watermark_height;
imagecopymerge($newim, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 20);
imagedestroy($watermark);
0
This discussion has been closed.
Comments
try this:
imagealphablending($watermark, false); imagesavealpha($watermark, true);
and use imagecopy instead of imagecopymerge. i know it sounds weird, but it's what worked for me.
You wouldn't have been using it on Zenphoto would you? I see you on their forums from time to time.
no, i was working on a photo captioning thinger for myself.
glad it worked for you.