1 | PngMinus
|
---|
2 | --------
|
---|
3 | (copyright Willem van Schaik, 1999-2019)
|
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 | Some history
|
---|
8 | ------------
|
---|
9 | Soon after the creation of PNG in 1995, the need was felt for a set of
|
---|
10 | pnmtopng / pngtopnm utilities. Independently Alexander Lehmann and I
|
---|
11 | (Willem van Schaik) started such a project. Luckily we discovered this
|
---|
12 | and merged the two, which later became part of NetPBM, available from
|
---|
13 | SourceForge.
|
---|
14 |
|
---|
15 | These two utilities have many, many options and make use of most of the
|
---|
16 | features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes
|
---|
17 | the utilities quite complex and by now not anymore very maintainable.
|
---|
18 | When we wrote these programs, libpng was still in an early stage.
|
---|
19 | Therefore, lots of the functionality that we put in our software can now
|
---|
20 | be done using transform-functions in libpng.
|
---|
21 |
|
---|
22 | Finally, to compile these programs, you need to have installed and
|
---|
23 | compiled three libraries: libpng, zlib and netpbm. Especially the latter
|
---|
24 | makes the whole setup a bit bulky. But that's unavoidable given the many
|
---|
25 | features of pnmtopng.
|
---|
26 |
|
---|
27 |
|
---|
28 | What now (1999)
|
---|
29 | ---------------
|
---|
30 | At this moment libpng is in a very stable state and can do much of the
|
---|
31 | work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new
|
---|
32 | interface of libpng. Hence, it is time for a rewrite from the ground up
|
---|
33 | of pnmtopng and pngtopnm. This will happen in the near future (stay
|
---|
34 | tuned). The new package will get a different name to distinguish it from
|
---|
35 | the old one: PngPlus.
|
---|
36 |
|
---|
37 | To experiment a bit with the new interface of libpng, I started off with
|
---|
38 | a small prototype that contains only the basic functionality. It doesn't
|
---|
39 | have any of the options to read or write special chunks and it will do
|
---|
40 | no gamma correction. But this makes it also a simple program that is
|
---|
41 | quite easy to understand and can serve well as a template for other
|
---|
42 | software developments. By now there are of course a couple of programs,
|
---|
43 | like Greg Roelofs' rpng/wpng, that can be used just as good.
|
---|
44 |
|
---|
45 |
|
---|
46 | Can and can not
|
---|
47 | ---------------
|
---|
48 | As this is the small brother of the future PngPlus, I called this fellow
|
---|
49 | PngMinus. Because I started this development in good-old Turbo-C, I
|
---|
50 | avoided the use the netpbm library, which requires DOS extenders. Again,
|
---|
51 | another reason to call it PngMinus (minus netpbm :-). So, part of the
|
---|
52 | program are some elementary routines to read / write pgm- and ppm-files.
|
---|
53 | It does not handle B&W pbm-files, but instead you could do pgm with bit-
|
---|
54 | depth 1.
|
---|
55 |
|
---|
56 | The downside of this approach is that you can not use them on images
|
---|
57 | that require blocks of memory bigger than 64k (the DOS version). For
|
---|
58 | larger images you will get an out-of-memory error.
|
---|
59 |
|
---|
60 | As said before, PngMinus doesn't correct for gamma. When reading
|
---|
61 | png-files you can do this just as well by piping the output of png2pnm
|
---|
62 | to pnmgamma, one of the standard PbmPlus tools. This same scenario will
|
---|
63 | most probably also be followed in the full-blown future PngPlus, with
|
---|
64 | the addition of course of the possibility to create gamma-chunks when
|
---|
65 | writing png-files.
|
---|
66 |
|
---|
67 | On the other hand it supports alpha-channels. When reading a png-image
|
---|
68 | you can write the alpha-channel into a pgm-file. And when creating an
|
---|
69 | RGB+A png-image, you just combine a ppm-file with a corresponding
|
---|
70 | pgm-file containing the alpha-channel. When reading, transparency chunks
|
---|
71 | are converted into an alpha-channel and from there on treated the same
|
---|
72 | way.
|
---|
73 |
|
---|
74 | Finally you can opt for writing ascii or binary pgm- and ppm-files. When
|
---|
75 | the bit-depth is 16, the format will always be ascii.
|
---|
76 |
|
---|
77 |
|
---|
78 | Using it
|
---|
79 | --------
|
---|
80 | To distinguish them from pnmtopng and PngPlus, the utilities are named
|
---|
81 | png2pnm and pnm2png (2 instead of to). The input- and output-files can
|
---|
82 | be given as parameters or through redirection. Therefore the programs
|
---|
83 | can be part of a pipe.
|
---|
84 |
|
---|
85 | To list the options type "png2pnm -h" or "pnm2png -h".
|
---|
86 |
|
---|
87 |
|
---|
88 | Just like Scandinavian furniture
|
---|
89 | --------------------------------
|
---|
90 | You have to put it together yourself. I developed the software on MS-DOS
|
---|
91 | with Turbo-C 3.0 and RedHat Linux 4.2 with gcc. In both cases I used
|
---|
92 | libpng-1.0.4 and zlib-1.1.3. By now (2019) it is twenty years later and
|
---|
93 | more current versions are OK.
|
---|
94 |
|
---|
95 | The makefile assumes that the libpng libraries can be found in ../.. and
|
---|
96 | libz in ../../../zlib. But you can change this to for example ../libpng
|
---|
97 | and ../zlib. The makefile creates two versions of each program, one with
|
---|
98 | static library support and the other using shared libraries.
|
---|
99 |
|
---|
100 | If you create a ../pngsuite directory and then store the basn####.png
|
---|
101 | files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can
|
---|
102 | test the proper functioning of PngMinus by running pngminus.sh.
|
---|
103 |
|
---|
104 |
|
---|
105 | Warranty
|
---|
106 | -------
|
---|
107 | Please, remember that this was just a small experiment to learn a few
|
---|
108 | things. It will have many unforeseen features <vbg> ... who said bugs? Use
|
---|
109 | it when you are in need for something simple or when you want a starting
|
---|
110 | point for developing your own stuff.
|
---|
111 |
|
---|
112 |
|
---|
113 | The end
|
---|
114 | -------
|
---|
115 | Willem van Schaik
|
---|
116 | mailto:willem at schaik dot com
|
---|
117 | http://www.schaik.com/png/
|
---|
118 |
|
---|
119 | Oct 1999, Jan 2019
|
---|
120 |
|
---|