December 25th, 2012, 07:19 AM
Imagecreatefrompng - no inherit transparency
Problem: A PNG's transparency is not carried over to the resource when using imagecreatefrompng(). I've tried several suggested methods and different variations of alpha settings over the last couple hours, but so far nothing has worked.
I'm currently using the following function to create watermarked png images:
Note: The bottom area of the newly merged image containing the watermark is completely transparent.
$img = imagecreatefrompng($newname);
list($width, $height) = getimagesize($newname);
$watermark = imagecreatefrompng("classes/watermark.png");
//set new image height (image height + watermark height)
$newHeight = $height + 40;
$newImage = imagecreatetruecolor($width, $newHeight);
//calculate watermark cords
$y = $newHeight-40;
$x = ($width - 200)/2;
//makes $newImage background transparent
$transparent = imagecolorallocatealpha($newImage, 0, 0, 0, 127);
imagefill($newImage, 0, 0, $transparent);
//choose RGB color
//$white = imagecolorallocate($newImage,233,234,235);
imagecopymerge($newImage, $img, 0, 0, 0, 0, $width, $height, 100);
imagecopymerge($newImage, $watermark, $x, $y, 0, 0, 200, 40, 100);
December 25th, 2012, 08:06 PM
The manual comments address this:
Originally Posted by Manual Comments
HEY! YOU! Read the New User Guide and Forum Rules
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002
Think we're being rude? Maybe you asked a bad question
or you're a Help Vampire.
Trying to argue intelligently? Please read this.
December 25th, 2012, 08:16 PM
Unfortunately I've tried this already with no luck. I tried it again as you have suggested for the hell of it, but it's still producing the same result.
Originally Posted by ManiacDan
December 30th, 2012, 12:23 PM
I still haven't been able to solve this problem if anyone has any suggestions it would be greatly appreciated.