user83358
user83358

Reputation: 1084

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

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 it'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.

Upvotes: 1

Views: 813

Answers (1)

user83358
user83358

Reputation: 1084

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

Upvotes: 1

Related Questions