Page 1 of 1

Unable to convert PNG to transparent GIF

Posted: Wed Apr 07, 2004 2:58 am
by wspollack
I'm unable to create a transparent GIF from a PNG file (and I have successfully made this exact conversion using this same PNG file, interactively using MWSnap, for instance). The syntax I have tried -- and the background color to be made transparent is white -- have included the following:

nconvert -transpcolor 255 255 255 -o c:\test1.gif c:\test1.png

nconvert -transparent 100 -transpcolor 255 255 255 -o c:\test1.gif c:\test1.png

nconvert -transparent 0 -transpcolor 255 255 255 -o c:\test1.gif c:\test1.png

nconvert -transparent 100 -transpcolor FF FF FF -o c:\test1.gif c:\test1.png

nconvert -transparent 100 -transpcolor FFFFFF -o c:\test1.gif c:\test1.png

None of these has made test1.gif transparent, at least as far as I can tell, although all of them have created the test1.gif file without complaint.

Am I doing something wrong?

Regards,

Bill

Re: Unable to create transparent GIF from PNG

Posted: Wed Apr 07, 2004 2:16 pm
by xnview
wspollack wrote:I'm unable to create a transparent GIF from a PNG file ...
-transparent is not for that.

you must use :

nconvert -transparent 100 -o c:\test1.gif -out gif c:\test1.png

100 is the index of the transaprent color in the colormap

Pierre.

I get an error:

Posted: Wed Apr 07, 2004 2:23 pm
by wspollack
If I enter that, here's what happens:

Code: Select all

C:\Program Files\XnView>nconvert -transparent 100 -o c:\test1.gif -out gif c:\te
st1.png
** NCONVERT v4.17 (c) 1991-2004 Pierre-E Gougelet (Feb 17 2004/12:32:24) **
        Version for Windows NT/9x/2000  (All rights reserved)
** This is a freeware software (for non commercial use)

  Error: This picture cannot be written using this format (c:\test1.png)


C:\Program Files\XnView>
test1.png is a valid PNG file, according to all software I've checked.

Any other suggestions?

Thanks for your help,

Bill

Re: I get an error:

Posted: Thu Apr 08, 2004 6:39 am
by xnview
wspollack wrote:...
test1.png is a valid PNG file, according to all software I've checked.

Any other suggestions?
Seems that your picture is not colors picture but RGB picture!
Pierre.

"Properties" of test1.png

Posted: Thu Apr 08, 2004 2:27 pm
by wspollack
Pierre, when I do a Properties on test1.png in Windows Explorer (XP), the Summary tab shows:

Width: 600 pixels
Height: 300 pixels
Horizontal Resolution: 96dpi
Vertical Resolution: 96dpi
Bit Depth: 24
Frame Count: 1

Does this mean it's not a valid PNG file? When I open the file in Ulead Instant Viewer and look at the properites there, the first line says "Data type: RGB True Color (24-bit)." Based on this information, is there some way I can convert this to a GIF, with White as the transparent color?

Thanks,

Bill

Re: "Properties" of test1.png

Posted: Fri Apr 09, 2004 8:43 am
by xnview
wspollack wrote:... the first line says "Data type: RGB True Color (24-bit)." Based on this information, is there some way I can convert this to a GIF, with White as the transparent color?
GIF doesn't accept 24bits file, so you must convert it to 256 colours before!
Pierre.

Re: "Properties" of test1.png

Posted: Wed May 12, 2004 6:29 am
by helmut
xnview wrote:
wspollack wrote:... the first line says "Data type: RGB True Color (24-bit)." Based on this information, is there some way I can convert this to a GIF, with White as the transparent color?
GIF doesn't accept 24bits file, so you must convert it to 256 colours before!
Pierre.
GIF supports only colour maps with up to 256 colours. So you have to reduce the numer of colours of your true colour image (24 bit, 16 Mio. colours) when or before converting to GIF.

Reducing the colours and changing format can be done in one step, this should work:

nconvert -out gif -o output.gif -colors 256 input.png