[英]Cropping transparency in an image
I have a PNG image, which has a transparent background. 我有一个具有透明背景的PNG图像。
I'm using PHP GD to display these images, from a server. 我正在使用PHP GD从服务器显示这些图像。 Is it possible in GD to also trim this transparent background, while maintaining the remainder of the image to be transparent and if so, how would I do it?
GD中是否也可以修剪此透明背景,同时保持图像的其余部分透明,如果可以,我该怎么做?
eg. 例如。 original image: http://puu.sh/8pNdx/ab2ff1e64f.png
原始图片: http : //puu.sh/8pNdx/ab2ff1e64f.png
and the expected result after processing would be: http://puu.sh/8pNg7/7b7ec85459.png 处理后的预期结果将是: http : //puu.sh/8pNg7/7b7ec85459.png
If it is really important to remove transparent pixels than you will have to write a small custom algorithm. 如果删除透明像素真的很重要,则必须编写一个小的自定义算法。
Try searching for some efficient algorithm for: 尝试搜索一些有效的算法来:
separating objects from an image
从图像中分离对象
I hope it will help. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.