Page 1 of 1

Convert PNG to TGA with full range transparency

Posted: 2019-05-15T06:48:09-07:00
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!

Re: Convert PNG to TGA with full range transparency

Posted: 2019-05-15T07:35:50-07:00
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"

Re: Convert PNG to TGA with full range transparency

Posted: 2019-05-15T07:47:06-07:00
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!