开发者

Darken part of an image using GD

开发者 https://www.devze.com 2023-04-04 09:36 出处:网络
I\'ve got a jpg image and I want to return the same image, with a \"highlight\" effect. Basically, I want to pass the script the xy coords, and redraw the image darkened, with an ellipse that remains

I've got a jpg image and I want to return the same image, with a "highlight" effect.

Basically, I want to pass the script the xy coords, and redraw the image darkened, with an ellipse that remains in the original colouring.

Initially I did this by creating a second image, same dimensions, and drawing a white elipse, then merging them together at 40% or so. The effect works, but the "highlighted" area is obviously a bit washed out.

Anyone know how I can basically delete that ellipse so i开发者_如何学JAVAt is purely transparent and then merge it on top of the original for a clear highlight?


You can use a png for the second image with the elipse being completely transparent while the area that you want darkened has an alpha of 20% (or whatever works best). When you merge the images, you can use imagecopy instead of imagecopymerge as the alpha (transparent) value is included in the second image already.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号