Page 1 of 1

Creating Alpha from non Alpha image

Posted: 2009-05-10T04:30:09-07:00
by Jenkins
Howdy all

I registered here because i'm having some rather annoying issues with trying to create an alpha channel from an image without one (WITHOUT touching the colour channel on either images)

The results i'm getting are not what i need, I need

This image
http://i228.photobucket.com/albums/ee24 ... _alpha.jpg

As the ALPHA channel on this image;
http://i228.photobucket.com/albums/ee24 ... normal.png

Forget about the size difference too, the alpha has been scaled down to save bandwidth however the normal map is full size. I just need to Copy the RGB Black and White Mask image into the Alpha Channel of the Normal map... I've tried several combinations of command line options and none of them are what i need, and i DO NOT want the colour channel of the normal map touched at all, when i am able to copy the alpha into the normal map it does not save the alpha channel and deletes any colour information from the input mask alpha...

This is the closest i can get but it Destroys the alpha channel which i dont want to happen;

Code: Select all

composite.exe -compose CopyOpacity alpha.png input.png output.png
Alpha.png = B/W Mask with NO Alpha
Input.png = colour input with NO Alpha
What i need for Output.png = Colour output with Alpha.png as the Alpha Channel of Input.png

Any help is appreciated;

EDIT: I must stress i need the Input.png colour image to stay untouched
This is critical to all images that i want to use this for.

-Jenkins

Re: Creating Alpha from non Alpha image

Posted: 2009-05-10T09:10:01-07:00
by el_supremo
Your command should do exactly what you want. I used the convert program:

Code: Select all

convert input.png -alpha off alpha.jpg -compose copyopacity -composite output.png
and it adds the alpha layer correctly. (For the test, I resized the input.png to be the same size as alpha.jpg)
If you are getting unexpected output, attach an example so we can see what you mean.

Pete

Re: Creating Alpha from non Alpha image

Posted: 2009-05-10T14:34:55-07:00
by fmw42
what IM version and platform are you using? if it is old, you should upgrade. the current version is IM 6.5.2-4

Re: Creating Alpha from non Alpha image

Posted: 2009-05-10T19:18:55-07:00
by Jenkins
el_supremo wrote:Your command should do exactly what you want. I used the convert program:

Code: Select all

convert input.png -alpha off alpha.jpg -compose copyopacity -composite output.png
and it adds the alpha layer correctly. (For the test, I resized the input.png to be the same size as alpha.jpg)
If you are getting unexpected output, attach an example so we can see what you mean.

Pete
Thanks!!!!
fmw42 wrote:what IM version and platform are you using? if it is old, you should upgrade. the current version is IM 6.5.2-4
6.5.1-Q16 :/

Looks like an update is needed then! :D

Thanks again.
-Jenkins

Re: Creating Alpha from non Alpha image

Posted: 2009-05-10T21:40:21-07:00
by anthony
As both images as an alpha channel, you are better of using a Duff-Poster alpha composition function..

For example DstIn to get what parts of the destination are 'In' the shape of the source image. If any parts of the destination image are transparent they will remain transparent! Which is a good thing.

See IM examples, Compose
http://www.imagemagick.org/Usage/compose/#dstin

the CopyOpacity is really only used with greyscale masks and images that have no transparency at all.

See CopyOpacity
http://www.imagemagick.org/Usage/compose/#copyopacity

If you use CopyOpacity, on images with alpha channels, the alpha channel is just copied from one image to the other, which means parts of the destination image that was transparent, may become opaque (or visible!). This is not good, as a transparent area has a undefined color (usually it is just black).

For an example of this see..
Editing a Image Mask
http://www.imagemagick.org/Usage/channels/#erase