Convert PNG to TGA with full range transparency

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
BlakeNowah
Posts: 2
Joined: 2019-05-15T06:42:49-07:00
Authentication code: 1152

Convert PNG to TGA with full range transparency

Post by BlakeNowah »

Hi there,

I am attempting to convert a png file that has totally transparent areas and partially transparent areas to a tga format using this:

for %%f in (*.png) do (
convert "%%~f" PNG24:- | convert "%%~nf.tga"
)

However, while the result tga does keep the full transparent areas, the 20% or 40% transparent areas are made of solid color instead of holding the transparency.

I tried using some examples I found on this forum as to include alpha on, but I had no luck in nailing a correct command line.
What am I missing?

Thank you!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert PNG to TGA with full range transparency

Post by snibgo »

BlakeNowah wrote:convert "%%~f" PNG24:- | convert "%%~nf.tga"
Why are you running two convert commands? Why not just one?

The second command has no input from the pipe, so what you have shown won't work. If it did work, you use an intermediate format "PNG24:" which has no alpha channel.

I suggest:

Code: Select all

convert "%%~f" "%%~nf.tga"
snibgo's IM pages: im.snibgo.com
BlakeNowah
Posts: 2
Joined: 2019-05-15T06:42:49-07:00
Authentication code: 1152

Re: Convert PNG to TGA with full range transparency

Post by BlakeNowah »

snibgo wrote: 2019-05-15T07:35:50-07:00 Why are you running two convert commands? Why not just one?
I copy-pasted that from somewhere. I noticed the OR, but I thought it's meant for some fail-safe situation.
My bad, I used it without knowing fully what it does.
snibgo wrote: 2019-05-15T07:35:50-07:00 I suggest:

Code: Select all

convert "%%~f" "%%~nf.tga"
Oh, it was that simple. It worked perfectly, indeed.
Thank you kindly!
Post Reply