Working with alpha turns color pixels black outside of mask

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
KingFish

Working with alpha turns color pixels black outside of mask

Post by KingFish »

Hi.
I have an image with an alpha channel defining the mask.
Using
convert.exe file.psd -alpha on file.tga
will create a tga file that has the correct alpha mask set, but has the color values outside of the mask turned to black.
Is there any way to avoid this?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Working with alpha turns color pixels black outside of mask

Post by anthony »

Depends on how the mask was defined in the PSD file.

PSD files can be a real pain to use as they are not a 'typical' image format, but an image editing format.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
KingFish

Re: Working with alpha turns color pixels black outside of mask

Post by KingFish »

Well, the source data is pretty simple.
If I save the file without alpha (convert file.psd -alpha off file.tga) it correctly shows all color.
If I extract the mask (convert file.psd -alpha extract file_mask.tga) it also is correct (8-bit, black where the color should not be visible and white where it should be).
I'm a bit clueless. Sadly, if this is the default behavior of ImageMagick and there is no way to change it I have to switch to another program.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Working with alpha turns color pixels black outside of mask

Post by anthony »

Are you sure a TGA format can handle a transparency?

Try generating an image with transparency and saving it to TGA and checking the result.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
KingFish

Re: Working with alpha turns color pixels black outside of mask

Post by KingFish »

Hi.
I now checked it with various file formats and all show the same behavior. Meaning in the output file all pixels of the colormap that are outside of the alpha mask are turned to black when using -alpha on.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Working with alpha turns color pixels black outside of mask

Post by anthony »

Can you provide us with a link to such a image (preferably PNG and not PSD), and the command that shows the transparent pixels turning black.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply