I'm trying to copy a semi-transparent portion of an image over itself using imagecopymerge. If I create a second image with imagecreatetruecolor, copy the image to that image with imagecopy, then copy it back to the original image with imagecopymerge and the PCT argument, I get a semi-transparent copy like I expect.
However, if I skip creating that second image and simply specify the same resource for the $src and $dest arguments, that last PCT argument in imagecopymerge seems to be completely ignored.
Fails, ignoring PCT argument.
$img = imagecreatefromjpeg('image.jpg');
imagecopymerge($img, $img, $dest_x, $dest_y, $src_x, $src_y, $width, $height, $PCT);
- $img = imagecreatefromjpeg('image.jpg');
- imagecopymerge($img, $img, $dest_x, $dest_y, $src_x, $src_y, $width, $height, $PCT);
Works.
$dest = imagecreatefromjpeg($filename);
$dest2 = imagecreatetruecolor(imagesx($dest), imagesy($dest));
imagecopy($dest2, $dest, 0, 0, 0, 0, imagesx($dest), imagesy($dest));
imagecopymerge($dest, $dest2, $dest_x, $dest_y, $src_x, $src_y, $width, $height, $PCT);
- $dest = imagecreatefromjpeg($filename);
- $dest2 = imagecreatetruecolor(imagesx($dest), imagesy($dest));
- imagecopy($dest2, $dest, 0, 0, 0, 0, imagesx($dest), imagesy($dest));
- imagecopymerge($dest, $dest2, $dest_x, $dest_y, $src_x, $src_y, $width, $height, $PCT);
Anyone seen this before ?
Am I doing something wrong ?
Is it possible to do this without using two image resources ?
Strong with this one, the sudo is.