Watermark: http://www.traileraddict.com/fm/watermark.png
That white-barred watermark should be transparent, but it is not. If I do PNG-8 I get the best transparency it can make, but with PNG-24 with alpha (so should be PNG-32), it should be working fine also.
I cannot figure out why it is fighting me. All feedback appreciated. GD Version bundled (2.0.34 compatible) with png version 1.5.14
That’s because you are writing it as a jpeg which to my knowledge doesn’t support transparency. You should use imagepng (and change your content type to image/png)
Thanks. I made the adjustments and that does not work; the adjustments remain and you can see new header. I want the final product to be a jpeg, but when I merge the PNG with transparency layer over the sourced JPEG when creating a new image, it’s a watermark, that’s when the alpha transparency fails, long before the final jpeg output.
I could have the watermark.png be PNG-8 and it works fine, save for the face that PNG-8 is a bit rough around the edges.
It’s almost like my PNG-32 isn’t really a PNG-32 or the alpha layer isn’t readying right.
<?php
$watermark = imagecreatefrompng('watermark.png');
// no idea what the following two lines are trying to do... :/
#imagealphablending($watermark, false);
#imagesavealpha($watermark,true);
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
// these get overwritten by the imagecreatefromjpeg, thus therefore useless
#$image = imagecreatetruecolor($watermark_width, $watermark_height);
#imagealphablending($image, false);
#imagesavealpha($image,true);
$image = imagecreatefromjpeg('big_hero_six.jpg');
$size = getimagesize('big_hero_six.jpg');
$dest_x = $size[0] - $watermark_width - 5;
$dest_y = $size[1] - $watermark_height - 5;
// since you are using 100% alpha, why bother with that parameter?
imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height);
header('content-type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
imagedestroy($watermark);