Add image as alpha?

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
nonfatmatt
Posts: 1
Joined: 2015-04-21T19:40:23-07:00
Authentication code: 6789

Add image as alpha?

Post by nonfatmatt »

I'm working on a game development project and the engine I'm using needs a gloss map (which is a black and while image) added as an alpha layer to the normal map (which is an RGB image with no alpha). In Gimp I've been trying to copy my black and white gloss map into the alpha channel of the normal map to no avail (for some reason the channel selection is off). I've been through ImageMagick manual but can't seem to find how to do this or where to start. Basically I would have two filenames, like so:

texture1_normal
texture1_gloss

And I need to output one image called texture1_normal that has texture1_gloss as its alpha channel. Both images are the same size. Is there a way to do this with ImageMagick?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Add image as alpha?

Post by fmw42 »

What version of Imagemagick and what platform? Please always provide that as syntax may be different.

Code: Select all

convert texture1_normal texture1_gloss -compose copy_opacity -composite texture1_normal
But this will overwrite texture1_normal. You may want to change the output name to something different from the input for safety.

see http://www.imagemagick.org/Usage/compose/#copyopacity
Post Reply