PHP imagecopymerge ignoring PCT when dest and src are the same ?

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

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.

Code: [ Select ]
$img = imagecreatefromjpeg('image.jpg');
imagecopymerge($img, $img, $dest_x, $dest_y, $src_x, $src_y, $width, $height, $PCT);
  1. $img = imagecreatefromjpeg('image.jpg');
  2. imagecopymerge($img, $img, $dest_x, $dest_y, $src_x, $src_y, $width, $height, $PCT);


Works.

Code: [ Select ]
$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);
  1. $dest = imagecreatefromjpeg($filename);
  2. $dest2 = imagecreatetruecolor(imagesx($dest), imagesy($dest));
  3. imagecopy($dest2, $dest, 0, 0, 0, 0, imagesx($dest), imagesy($dest));
  4. 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 ?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 86 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.