Unable to convert PNG to transparent GIF

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, xnview

Post Reply
wspollack
Posts: 3
Joined: Wed Apr 07, 2004 2:50 am
Location: Schodack, NY, USA
Contact:

Unable to convert PNG to transparent GIF

Post by wspollack » Wed Apr 07, 2004 2:58 am

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

User avatar
xnview
Author of XnView
Posts: 31887
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Unable to create transparent GIF from PNG

Post by xnview » Wed Apr 07, 2004 2:16 pm

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.

wspollack
Posts: 3
Joined: Wed Apr 07, 2004 2:50 am
Location: Schodack, NY, USA
Contact:

I get an error:

Post by wspollack » Wed Apr 07, 2004 2:23 pm

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

User avatar
xnview
Author of XnView
Posts: 31887
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: I get an error:

Post by xnview » Thu Apr 08, 2004 6:39 am

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.

wspollack
Posts: 3
Joined: Wed Apr 07, 2004 2:50 am
Location: Schodack, NY, USA
Contact:

"Properties" of test1.png

Post by wspollack » Thu Apr 08, 2004 2:27 pm

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

User avatar
xnview
Author of XnView
Posts: 31887
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: "Properties" of test1.png

Post by xnview » Fri Apr 09, 2004 8:43 am

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.

User avatar
helmut
Posts: 8174
Joined: Sun Oct 12, 2003 6:47 pm
Location: Frankfurt, Germany

Re: "Properties" of test1.png

Post by helmut » Wed May 12, 2004 6:29 am

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

Post Reply