开发者

replacing an image with a single color while preserving transparency with imagmagick

开发者 https://www.devze.com 2023-02-20 16:12 出处:网络
I have a simple operation I need to do in a web application - take an image, check each pixel, and replace it with a certain color while preserving transparency (if i开发者_高级运维t\'s transparent it

I have a simple operation I need to do in a web application - take an image, check each pixel, and replace it with a certain color while preserving transparency (if i开发者_高级运维t's transparent it doesn't change). Doing this through PHP is extremely slow due to the size of the image; is there an imagemagick command that will have the same result? The input image is a 32-bit png created by imagemagick by disassembling the layers of a PSD file.


It turned out to be simple (throwing in a resize to minimize the work):

convert $source {$resize} -alpha set -channel RGB -fill '#{$color}' +opaque none $output
0

精彩评论

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

关注公众号