gif2png - convert GIFs to PNGs
gif2png [-bdfghinprsvwO] [file.[gif]...]
The gif2png program converts files in the obsolescent Graphic Interchange Format (GIF) to Portable Network Graphics (PNG) format, an open W3C standard.
Normally gif2png converts each file named on the command line, leaving the original in place. If a name does not have a .gif extension, the unmodified name will be tried first, followed by the name with .gif appended. For each file named foo.gif, a foo.png will be created.
When a multi-image GIF file named foo.gif is converted, gif2png creates multiple PNG files, each containing one frame; their names will be foo.png, foo.p01, foo.p02 etc.
If no source files are specified and stdin is a terminal, gif2png lists a usage summary and version information, then exits.
If no source files are specified, and stdin is a device or pipe, stdin is converted to noname.png. (The program can't be a normal stdin-to-stdout filter because of the possibility that the input GIF might have multiple images).
However, if filter mode is forced (with -f) stdin will be converted to stdout, with gif2png returning an error code if the GIF is multi-image.
The program will preserve the information contained in a GIF file as closely as possible, including GIF comment and application-data extension blocks. All graphics data (pixels, RGB color tables) will be converted without loss of information. Transparency is also preserved. There is one exception; GIF plain-text extensions are skipped.
The program automatically converts interlaced GIFs to interlaced PNGs. It detects images in which all colors are gray (equal R, G, and B values) and converts such images to PNG grayscale. Other images are converted to use the PNG palette type. Duplicate color entries are silently preserved. Unused color-table entries cause an error message.
The action of the program can be modified with the following command-line switches:
Naively converting all your GIFs at one go with gif2png is not likely to give you the results you want. Animated GIFs cannot be translated to PNG, which is a single-image format.
The web-probe switch is intended to be used with scripts for converting web sites. In versions of this tool up to 2.5.2 it filtered out GIFs with transparency as well as GIFs with animations, but support for PNG transparency has been universal in browsers since about 2006.
STANDARDS AND SPECIFICATIONS¶
Copies of the GIF89 specification are widely available on the Web; search for "GRAPHICS INTERCHANGE FORMAT". The Graphics Interchange Format(c) is the Copyright property of CompuServe Incorporated. GIF(sm) is a Service Mark property of CompuServe Incorporated. The GIF format was formerly covered by a blocking patent on LZW compression, but it expired in June 2003.
The PNG home site at <http://www.libpng.org/pub/png/> has very complete information on the PNG standard, PNG libraries, and PNG tools.
Code by Alexander Lehmann <email@example.com>, 1995. Auto-interlace conversion and tRNS optimization by Greg Roelofs <firstname.lastname@example.org>, 1999. Man page, -O, -w, and production packaging by Eric S. Raymond <email@example.com>, 1999. -m option by Steve Ward, 2012.