Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time
tif22pnm: TIFF-to-PNM converter and png22pnm, a PNG-to-PNM converter

This is the README for tif22pnm.c.
by at Sun Apr 14 22:56:35 CEST 2002
Tue Jun 11 18:10:35 CEST 2002
v0.06 at Mon Oct  7 01:35:40 CEST 2002
v0.09 at Fri Jan 17 19:38:29 CET 2003

tif22pnm is a command line utility that converts between TIFF sampled images
and PNM images (both directions), using the libtiff library, but not using
NetPBM. tif22pnm is similar to tifftopnm utility in the NetPBM distribution,
but tif22pnm handles a wider range of TIFF files and it is able to output
the alpha channel as a PBM or PGM file. png22pnm, a converter from PNG to
PNM is also bundled into the distribution.

Caveat: tif22pnm v0.07 contains >1000 lines of untested code. The author
wants to improve the software, and he welcomes bug reports. The author has
tested v0.07 with around 20 very different input files, and it worked. More
thorough testing seems to be necessary.

Unique advantages (over any other TIFF to PNM converter):

-- handles all kinds of compressed TIFF files libtiff can cope with
   (tifftopnm doesn't)
-- handles all kinds of compressed TIFF files GIMP 1.3 can cope with, plus
   more (tifftopnm, GIMP 1.3 doesn't)
-- handles all kinds of color spaces libtiff can cope with
   (tifftopnm doesn't)
-- handles TIFF/JPEG input files correctly (tifftopnm doesn't, GIMP 1.0 
   doesn't, xv doesn't, ImageMagick doesn't, GIMP 1.3 does)
-- automatically writes a smaller file (PBM < PGM < PPM) if image pixels
   make it possible

Compilation under UNIX
	./ compile

Compilation under Win32
To compile tif22pnm.exe and png22pnm.exe, the Win32 equivalents of the UNIX
utilities tif22pnm and png22pnm, you have to install these build
dependencies first:

-- MinGW and MSYS, available from

-- libz (zlib) for MinGW
   libjpeg for MinGW
   libtiff for MinGW
   libpng for MinGW

   Get them from:

   To build a self-contained .exe files, you'll need the appropriate .a


   Most of the libraries create only the .dll files properly, and create the
   .a file that doesn't work without the .dll. To overcome this, watch which
   commands were used during the build to create the dll, and run `ar cr' to
   create the .a file manually. For example, recognise the command

	gcc -shared -o libpng.a -Wl,--out-implib,libpng.a -Wl,--enable-auto-image png.o pngerror.o pngget.o pngmem.o pngpread.o pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o -lz

   and execute this afterwards:

	ar cr libpng.a png.o pngerror.o pngget.o pngmem.o pngpread.o pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o

   If the .a file is smaller than the sum of the .o files, or it contains
   the name of a .dll with a similar name, simply forget about it. Never
   ever run ranlib!

   Copy *.h to the MinGW directory containing _mingw.h. Copy *.a to the
   directory containing libcrtdll.a

To build tif22pnm and png22pnm:

1. Install all the build dependencies.

2. Open the MSYS terminal window from the start menu.

3. Run `explorer .' to figure out what is the current working directory.
   Let's call this directory the MSYS home.

4. Download the tif22pnm sources into the MSYS home:

5. Unpack the sources. Run:

	tar xzvf tif22pnm-latest.tar.gz

6. Run `cd tif22pnm-*.*' to enter the tif22pnm source directory. It should
   contain a newer version of this README and the file tif22pnm.c.

7. Run

	export CC='gcc -static'  # to build standalone .exe files

   Verify that both libtiff and libpng are found. If not, examine config.log,
   and copy the *.a and *.h files from the libraries to a place where gcc
   will find them.

8. Run

	sh ./ compile

9. The files tif22pnm.exe and png22pnm.exe are now created in the current
   directory. Use them. You may copy them to another directory right now:

	cp *22pnm.exe 'C:\Program Files'

10. You should invoke *22pnm.exe from the command line (COMMAND.COM or
    CMD.EXE) with the _appropriate_ arguments, described elsewhere in this
    document. Don't put it into the Start menu, it won't work (a window will
    flash in, showing an error message that you haven't supplied the right

11. The cjpeg.exe and djpeg.exe are useful utilities found in the libjpeg
    distribution (which you've installed anyway, because libtiff needs it).

The author wants tif22pnm to be able to read a vide range of image formats
(not just TIFF and PNM), including corrupted image files. In the future
tif22pnm should support many output formats, but only few compression
methods. If you want tight output and full PostScript and PDF support,
please try sam2p:

As root,

	cp tif22pnm /usr/local/bin

	$ tif22pnm
	This is tif22pnm v0.07: TIFF <-> PNM converter, by
	Usage: ./tif22pnm [options] [--] in.img [out.img]
	Options are:
	-rgb   opaque RGB, alpha associated to black background (default)
	-rgbi  RGB, ignore alpha
	-rgba  RGB with associated alpha (black background)
	-rgbu  RGB with unassociated alpha
	-onlya alpha, ignore RGB

Legal stuff
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



TIFF-to-PNM converter and png22pnm, a PNG-to-PNM converter




No packages published