Transparent PNG over JPG in PHP

前端 未结 2 2005
梦谈多话
梦谈多话 2020-12-21 02:21

What seems to be simple, isn\'t :(

I\'m trying to add something like a watermark (transparent png) on an image (jpg). This is the code I\'m using:

$w         


        
相关标签:
2条回答
  • 2020-12-21 02:34

    Your $width and $height should be the dimensions of the watermark, not of the photo. What you're telling it to do is copy the watermark with a much bigger size than it is. When it reads part of an image that doesn't exist (coordinates out of bounds) the result is opaque black, giving the result you see.

    0 讨论(0)
  • 2020-12-21 02:56

    Use imagecopymerge() instead of imagecopy()

    U may also like imagesavealpha()

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题