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