[eluser]Unknown[/eluser]
I'm overlaying a JPG graphic on top of a square white JPG graphic. I get some speckles of white in the final image. So, I tried adjusting the wm_x_transp and wm_y_transp to see if I got different speckles based on the imagecolorat position. I did. So, I went perusing through the Image_Lib.php library and I found the following relevant code. I must admit that I'm not good with bitwise operands, but the $alpha variable stays at 0, and the "else" portion executes, leaving me with an attempt at transparency on two very un-transparent jpegs.
The user guide says that usually a PNG or GIF would overlay the JPG, but I specifically need a dynamic image overlaying a static one, rather than the alternate. If I hack this code to run just the "imagecopy" function, am I missing anything? Or is there another way?
Code:
// Set RGB values for text and shadow
$rgba = imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp);
$alpha = ($rgba & 0x7F000000) >> 24;
// make a best guess as to whether we're dealing with an image with alpha transparency or no/binary transparency
if ($alpha > 0)
{
// copy the image directly, the image's alpha transparency being the sole determinant of blending
imagecopy($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height);
}
else
{
// set our RGB value from above to be transparent and merge the images with the specified opacity
imagecolortransparent($wm_img, imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp));
imagecopymerge($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height, $this->wm_opacity);
}
Thanks,
Landon