adding transparency to grayscale images?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: adding transparency to grayscale images?

Post by glennrp »

Code: Select all

convert input.png -negate alpha.png
composite -compose copyopacity alpha.png input.png -depth 8 output.png
This results in an RGBA png file. I can't figure how to force Gray-alpha output,
so I use

Code: Select all

    pngcrush -c 4 output.png gray-alpha.png
afterwards if I need gray-alpha.
Post Reply