如何在PHP中着色透明的PNG文件? [英] How can I tint transparent PNG files in PHP?
问题描述
我有一个透明的PNG图像.透明区域需要保持完全透明,而其他区域则需要使用特定的色调进行着色.
I have a transparent PNG image. The transparent areas need to remain completely transparent, but the other areas need tinting with a particular hue.
使用GD最好的方法是什么?
What's the best way to do this using GD?
干杯,
詹姆斯
Cheers,
James
推荐答案
上述解决方案不适用于我.
The above solution didn't work for me.
您在此处用红色填充Alpha区域;我认为这不是目标.目的是为图像的其余部分着色,并保持Alpha不变. (此外,错误使用了imagecolorallocate函数,您应该使用imagecolorallocatealpha.)
You are filling alpha region here with red; that I believe is not the objective. Objective is to tint the rest of the image and leave the alpha unchanged. (Also, wrong use of function imagecolorallocate, you should use imagecolorallocatealpha.)
我设法使用imagefilter并进行了如下着色:
I managed to use imagefilter and colorize as follows:
图像过滤器($ image,IMG_FILTER_COLORIZE,0、255、0 ,30);
imagefilter($image, IMG_FILTER_COLORIZE, 0, 255, 0, 30);
应用着色.
这篇关于如何在PHP中着色透明的PNG文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!