Having issues with transparency and Mogrify

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
aaron
Posts: 8
Joined: 2013-07-01T18:08:35-07:00
Authentication code: 6789

Having issues with transparency and Mogrify

Post by aaron »

Hi guys,

I have DDS files with transparency that I need to convert to PNG. I've tried every combination of -alpha, -transparent, -background, etc. but I can't seem to get it right.

Here is the DDS converted to PNG in GIMP
Image

The closest I have come is this, using the command:

Code: Select all

mogrify -alpha set -format PNG24 [filename].dds 
Image

As you can see, the black shirt turns transparent and there are some remaining black pixels around the head that should be transparent.

Or this, using:

Code: Select all

mogrify -alpha set -format PNG32 [filename].dds
Image

This one retains the black shirt, but it looks like crap :|.

Any help? Thanks so much!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Having issues with transparency and Mogrify

Post by fmw42 »

Post a link to your dds file. It is possible that IM only handles binary transparency with DDS.

Try

mogrify -format png [filename].dds

The following works fine for me with a 32-bit tiff file with 8-bit alpha converting to 32-bit png. I have no DDS files and IM only reads them.

# create 8bit transparency
convert logo: -transparent white -channel alpha -blur 0x2 +channel logo.tif
# mogrify
mogrify -format png logo.tif


Also try on one file

convert filename.dds filename.png
or
convert filename.dds PNG32:filename.png

and see if that works OK

I do not think mogrify allows -format PNG32. At least it did not work on my system correctly. It added suffix PNG32 and not just png.
aaron
Posts: 8
Joined: 2013-07-01T18:08:35-07:00
Authentication code: 6789

Re: Having issues with transparency and Mogrify

Post by aaron »

Thanks for the reply!

I tried your suggestion, it gave the same result as my last image. I'm not sure I can share the DDS file, my company is VERY protective of our files.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Having issues with transparency and Mogrify

Post by fmw42 »

aaron wrote:Thanks for the reply!

I tried your suggestion, it gave the same result as my last image. I'm not sure I can share the DDS file, my company is VERY protective of our files.

What about the one you used above? If not that, just create something that you can share that has transparency.
Post Reply