php – GD图像叠加透明png

前端之家收集整理的这篇文章主要介绍了php – GD图像叠加透明png前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有透明的图像,我想覆盖整个图像,以赋予它更大的效果.在此代码中,它会裁剪现有图像.它合并了两个,但最后的顶部没有显示alpha.我怎样才能解决这个问题?
  1. <?
  2. $dst_x = 0; // X-coordinate of destination point.
  3. $dst_y = 0; // Y --coordinate of destination point.
  4. $src_x = 163; // Crop Start X position in original image
  5. $src_y = 0; // Crop Srart Y position in original image
  6. $dst_w = 469; // Thumb width
  7. $dst_h = 296; // Thumb height
  8. $src_w = 469; // $src_x + $dst_w Crop end X position in original image
  9. $src_h = 296; // $src_y + $dst_h Crop end Y position in original image
  10.  
  11. // Creating an image with true colors having thumb dimensions.( to merge with the original image )
  12. $dst_image = imagecreatetruecolor($dst_w,$dst_h);
  13. // Get original image
  14. $src_image = imagecreatefromjpeg("http://www.ucatholic.com/wp-content/uploads/2012/10/Sallixtus-631x295.jpg");
  15. // Cropping
  16. imagecopyresampled($dst_image,$src_image,$dst_x,$dst_y,$src_x,$src_y,$dst_w,$dst_h,$src_w,$src_h);
  17. // Saving
  18. imagejpeg($dst_image,"images/crop.jpg");
  19.  
  20. $src = imagecreatefrompng('http://www.EdVizenor.com/images/saintCover.png');
  21.  
  22. /// THIS LINE NOT WORKING - - // Copy and merge
  23. imagecopymerge($dst_image,$src,469,296,100);
  24.  
  25. header('Content-Type: image/png');
  26. imagegif($dst_image);
  27. ?>
不要使用imagecopymerge,使用imagecopy,然后它将正常工作,你的水印将显示alpha.
  1. imagecopy($dst_image,296);

猜你在找的PHP相关文章