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

edited May 2006 in Vanilla 1.0 Help
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.
$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);

Comments

  • i just had this very problem with something i was working on.
    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.
  • Cheers. It works perfectly.

    You wouldn't have been using it on Zenphoto would you? I see you on their forums from time to time.
  • Someone get Zenphoto to switch to Vanilla; their forum software is terrible.
  • Their forum software does suck. I think it is the one developed for Wordpress forums. Not sure though. I really don't think he would switch though. It does seem to running smoothly with that software, and there have been no complaints about it over there.
  • i don't think i've ever been on the zenphoto forums... impostor alert

    no, i was working on a photo captioning thinger for myself.

    glad it worked for you.
  • sorry. that was 3stripe. Getting confused here. FALSE ALARM!
This discussion has been closed.