pngminus: Change license to MIT, etc.

Change the license to MIT.
Move the license text from the source files to a LICENSE file.
Move the change log from the source files to a CHANGES file.
Delete the Turbo C makefile and simplify the Linux makefile heavily.
Create explicitly named static and shared executables in the makefile.
Refresh the README file a bit from the twenty year old one.

Signed-off-by: Willem van Schaik <willem@schaik.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
This commit is contained in:
Willem van Schaik 2019-01-23 06:05:54 -08:00 committed by Cosmin Truta
parent 3342fafa60
commit 62a56d4fcc
10 changed files with 124 additions and 193 deletions

View File

@ -0,0 +1,13 @@
pnm2png / png2pnm --- conversion from PBM/PGM/PPM-file to PNG-file
copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
version 1.0 - 1999.10.15 - First version.
1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
1.2 - 2017.04.22 - Add buffer-size check
1.3 - 2017.08.24 - Fix potential overflow in buffer-size check
(Glenn Randers-Pehrson)
1.4 - 2017.08.28 - Add PNGMINUS_UNUSED (Christian Hesse)
1.5 - 2018.08.05 - Fix buffer overflow in tokenizer (Cosmin Truta)
1.6 - 2018.08.05 - Improve portability and fix style (Cosmin Truta)
1.7 - 2019.01.22 - Change license to MIT (Willem van Schaik)

View File

@ -0,0 +1,22 @@
pnm2png / png2pnm --- conversion from PBM/PGM/PPM-file to PNG-file
copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The software is provided "as is", without warranty of any kind, express or
implied, including but not limited to the warranties of merchantability,
fitness for a particular purpose and noninfringement. In no event shall the
authors or copyight holders be liable for any claim, damages or other
liability, whether in an action of contract, tort or otherwise, arising from,
out of or in connection with the software or the use or other dealings in the
software.

57
contrib/pngminus/Makefile Normal file
View File

@ -0,0 +1,57 @@
# Makefile for PngMinus (png2pnm and pnm2png)
# Linux / Unix
#CC = cc
CC = gcc
LD = $(CC)
RM = rm -f
PNGINC = -I../..
PNGLIB_SHARED = -L../.. -lpng
PNGLIB_STATIC = ../../libpng.a
ZINC = -I../../../zlib
ZLIB_SHARED = -L../../../zlib -lz
ZLIB_STATIC = ../../../zlib/libz.a
CPPFLAGS = $(PNGINC) $(ZINC)
CFLAGS =
LDFLAGS =
LIBS_SHARED = $(PNGLIB_SHARED) $(ZLIB_SHARED)
LIBS_STATIC = $(PNGLIB_STATIC) $(ZLIB_STATIC)
EXEEXT =
#EXEEXT = .exe
# dependencies
all: png2pnm$(EXEEXT) pnm2png$(EXEEXT) png2pnm-static$(EXEEXT) pnm2png-static$(EXEEXT)
png2pnm.o: png2pnm.c
$(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm.c
pnm2png.o: pnm2png.c
$(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png.c
png2pnm$(EXEEXT): png2pnm.o
$(LD) $(LDFLAGS) -o png2pnm$(EXEEXT) png2pnm.o $(LIBS_SHARED) -lm
pnm2png$(EXEEXT): pnm2png.o
$(LD) $(LDFLAGS) -o pnm2png$(EXEEXT) pnm2png.o $(LIBS_SHARED) -lm
png2pnm-static$(EXEEXT): png2pnm.o
$(LD) $(LDFLAGS) -o png2pnm-static$(EXEEXT) png2pnm.o $(LIBS_STATIC) -lm
pnm2png-static$(EXEEXT): pnm2png.o
$(LD) $(LDFLAGS) -o pnm2png-static$(EXEEXT) pnm2png.o $(LIBS_STATIC) -lm
clean:
$(RM) png2pnm.o
$(RM) pnm2png.o
$(RM) png2pnm$(EXEEXT)
$(RM) pnm2png$(EXEEXT)
$(RM) png2pnm-static$(EXEEXT)
$(RM) pnm2png-static$(EXEEXT)
# End of makefile for png2pnm / pnm2png

View File

@ -1,26 +1,16 @@
PngMinus PngMinus
-------- --------
(copyright Willem van Schaik, 1999) (copyright Willem van Schaik, 1999-2019)
License
-------
Permission to use, copy, modify, and distribute this software and
its documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear in
supporting documentation. This software is provided "as is" without
express or implied warranty.
Some history Some history
------------ ------------
Soon after the creation of PNG in 1995, the need was felt for a set of Soon after the creation of PNG in 1995, the need was felt for a set of
pnmtopng / pngtopnm utilities. Independently Alexander Lehmann and I pnmtopng / pngtopnm utilities. Independently Alexander Lehmann and I
(Willem van Schaik) started such a project. Luckily we discovered this (Willem van Schaik) started such a project. Luckily we discovered this
and merged the two together into pnmtopng.tar.gz, which is available and merged the two, which later became part of NetPBM, available from
from a/o ftp://ftp.simplesystems.org/pub/libpng/png/. SourceForge.
These two utilities have many, many options and make use of most of the These two utilities have many, many options and make use of most of the
features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes
@ -35,8 +25,8 @@ makes the whole setup a bit bulky. But that's unavoidable given the many
features of pnmtopng. features of pnmtopng.
What now What now (1999)
-------- ---------------
At this moment libpng is in a very stable state and can do much of the At this moment libpng is in a very stable state and can do much of the
work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new
interface of libpng. Hence, it is time for a rewrite from the ground up interface of libpng. Hence, it is time for a rewrite from the ground up
@ -49,8 +39,8 @@ a small prototype that contains only the basic functionality. It doesn't
have any of the options to read or write special chunks and it will do have any of the options to read or write special chunks and it will do
no gamma correction. But this makes it also a simple program that is no gamma correction. But this makes it also a simple program that is
quite easy to understand and can serve well as a template for other quite easy to understand and can serve well as a template for other
software developments. (By now there are of course a couple of programs, software developments. By now there are of course a couple of programs,
like Greg Roelofs' rpng/wpng, that can be used just as good.) like Greg Roelofs' rpng/wpng, that can be used just as good.
Can and can not Can and can not
@ -60,7 +50,8 @@ PngMinus. Because I started this development in good-old Turbo-C, I
avoided the use the netpbm library, which requires DOS extenders. Again, avoided the use the netpbm library, which requires DOS extenders. Again,
another reason to call it PngMinus (minus netpbm :-). So, part of the another reason to call it PngMinus (minus netpbm :-). So, part of the
program are some elementary routines to read / write pgm- and ppm-files. program are some elementary routines to read / write pgm- and ppm-files.
It does not read b&w pbm-files. It does not handle B&W pbm-files, but instead you could do pgm with bit-
depth 1.
The downside of this approach is that you can not use them on images The downside of this approach is that you can not use them on images
that require blocks of memory bigger than 64k (the DOS version). For that require blocks of memory bigger than 64k (the DOS version). For
@ -96,58 +87,34 @@ To list the options type "png2pnm -h" or "pnm2png -h".
Just like Scandinavian furniture Just like Scandinavian furniture
-------------------------------- --------------------------------
You have to put it together yourself. I did test the software under You have to put it together yourself. I developed the software on MS-DOS
MS-DOS with Turbo-C 3.0 and under RedHat Linux 4.2 with gcc. In both with Turbo-C 3.0 and RedHat Linux 4.2 with gcc. In both cases I used
cases I used libpng-1.0.4 and zlib-1.1.3. Later versions should be OK, libpng-1.0.4 and zlib-1.1.3. By now (2019) it is twenty years later and
however some older libpng versions have a bug in pngmem.c when using more current versions are OK.
Turbo-C 3.0 (see below).
You can build it using one of the two makefiles (make -f makefile.###) The makefile assumes that the libpng libraries can be found in ../.. and
or use the batch/script files pngminus.bat / pngminus.sh. This assumes libz in ../../../zlib. But you can change this to for example ../libpng
that you have built the libraries in ../libpng and ../zlib. Using Linux, and ../zlib. The makefile creates two versions of each program, one with
make sure that you have built libpng with makefile.std and not static library support and the other using shared libraries.
makefile.linux (also called .lnx in earlier versions of libpng). The
latter creates a .so shared-library, while the PngMinus makefile assumes
a normal .a static library.
If you create a ../pngsuite directory and then store the basn####.png If you create a ../pngsuite directory and then store the basn####.png
files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can
test in one go the proper functioning of PngMinus, see png2pnm.bat and test the proper functioning of PngMinus by running pngminus.sh.
pnm2png.bat (or the .sh versions).
Warranty Warranty
------- -------
Please, remember that this was just a small experiment to learn a few Please, remember that this was just a small experiment to learn a few
things. It will have many unforeseen features <vbg>. Who said bugs? Use things. It will have many unforeseen features <vbg> ... who said bugs? Use
it when you are in need for something simple or when you want to start it when you are in need for something simple or when you want a starting
developing your own stuff. point for developing your own stuff.
The Turbo bug
-------------
** pngmem.old
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
hptr += 16L;
** pngmem.c
hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
hptr = hptr + 16L;
**
** pngmem.old
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
hptr += (png_uint_32)65536L;
** pngmem.c
png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
hptr = hptr + 65536L;
**
The end The end
------- -------
Willem van Schaik Willem van Schaik
mailto:willem at schaik.com mailto:willem at schaik dot com
http://www.schaik.com/png/ http://www.schaik.com/png/
-------
Oct 1999 Oct 1999, Jan 2019

View File

@ -1,66 +0,0 @@
# Makefile for PngMinus (png2pnm and pnm2png)
# Linux / Unix
#CC=cc
CC=gcc
LD=$(CC)
RM=rm -f
#PNGPATH = /usr/local
#PNGINC = -I$(PNGPATH)/include/libpng16
#PNGLIB = -L$(PNGPATH)/lib -lpng16
#PNGLIBS = $(PNGPATH)/lib/libpng16.a
PNGINC = -I../..
PNGLIB = -L../.. -lpng
PNGLIBS = ../../libpng.a
#ZPATH = /usr/local
#ZINC = -I$(ZPATH)/include
#ZLIB = -L$(ZPATH)/lib -lz
#ZLIBS = $(ZPATH)/lib/libz.a
ZINC = -I../../../zlib
ZLIB = -L../../../zlib -lz
ZLIBS = ../../../zlib/libz.a
CPPFLAGS=$(PNGINC) $(ZINC)
CFLAGS=
LDLIBS=$(PNGLIB) $(ZLIB)
LDLIBSS=$(PNGLIBS) $(ZLIBS)
C=.c
O=.o
L=.a
E=
# dependencies
#all: png2pnm$(E) pnm2png$(E)
all: png2pnm$(E) pnm2png$(E) png2pnm-static$(E) pnm2png-static$(E)
png2pnm$(O): png2pnm$(C)
$(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm$(C)
png2pnm$(E): png2pnm$(O)
$(LD) $(LDFLAGS) -o png2pnm$(E) png2pnm$(O) $(LDLIBS) -lm
png2pnm-static$(E): png2pnm$(O)
$(LD) $(LDFLAGS) -o png2pnm-static$(E) png2pnm$(O) $(LDLIBSS) -lm
pnm2png$(O): pnm2png$(C)
$(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png$(C)
pnm2png$(E): pnm2png$(O)
$(LD) $(LDFLAGS) -o pnm2png$(E) pnm2png$(O) $(LDLIBS) -lm
pnm2png-static$(E): pnm2png$(O)
$(LD) $(LDFLAGS) -o pnm2png-static$(E) pnm2png$(O) $(LDLIBSS) -lm
clean:
$(RM) png2pnm$(O)
$(RM) pnm2png$(O)
$(RM) png2pnm$(E)
$(RM) pnm2png$(E)
$(RM) png2pnm-static$(E)
$(RM) pnm2png-static$(E)
# End of makefile for png2pnm / pnm2png

View File

@ -1,38 +0,0 @@
# Makefile for PngMinus (png2pnm and pnm2png)
# TurboC++ 3.0
CC=tcc -Ic:\tc3\inc
LD=tcc -Lc:\tc3\lib
LB=tlib
RM=del
CP=copy
MODEL=l
CPPFLAGS=-I..\libpng -I..\zlib
CFLAGS=-O -m$(MODEL)
LDFLAGS=-m$(MODEL) -L..\libpng -L..\zlib
C=.c
O=.obj
L=.lib
E=.exe
# dependencies
all: png2pnm$(E) pnm2png$(E)
png2pnm$(O): png2pnm$(C)
$(CC) -c $(CPPFLAGS) $(CFLAGS) png2pnm$(C)
png2pnm$(E): png2pnm$(O)
$(LD) $(LDFLAGS) png2pnm$(O) libpng$(L) zlib$(L)
pnm2png$(O): pnm2png$(C)
$(CC) -c $(CPPFLAGS) $(CFLAGS) pnm2png$(C)
pnm2png$(E): pnm2png$(O)
$(LD) $(LDFLAGS) pnm2png$(O) libpng$(L) zlib$(L)
clean:
$(RM) *$(O)
$(RM) *$(E)
# End of makefile for png2pnm / pnm2png

View File

@ -1,20 +1,9 @@
/* /*
* png2pnm.c --- conversion from PNG-file to PGM/PPM-file * png2pnm.c --- conversion from PNG-file to PGM/PPM-file
* copyright (C) 1999,2017,2018 by Willem van Schaik <willem at schaik.com> * copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
* *
* version 1.0 - 1999.10.15 - First version. * This software is released under the MIT license. For conditions of
* 1.1 - 2017.04.22 - Add buffer-size check (Glenn Randers-Pehrson) * distribution and use, see the LICENSE file part of this package.
* 1.2 - 2017.08.24 - Fix potential overflow in buffer-size check
* (Glenn Randers-Pehrson)
* 1.3 - 2017.08.28 - Add PNGMINUS_UNUSED (Christian Hesse)
* 1.4 - 2018.08.05 - Improve portability and fix style (Cosmin Truta)
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear in
* supporting documentation. This software is provided "as is" without
* express or implied warranty.
*/ */
#include <stdio.h> #include <stdio.h>

View File

@ -1,4 +1,4 @@
make -f makefile.tc3 make
call png2pnm.bat call png2pnm.bat
call pnm2png.bat call pnm2png.bat

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
make -f makefile.std make
sh png2pnm.sh sh png2pnm.sh
sh pnm2png.sh sh pnm2png.sh

View File

@ -1,22 +1,9 @@
/* /*
* pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file * pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file
* copyright (C) 1999,2015,2017,2018 by Willem van Schaik <willem at schaik.com> * copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
* *
* version 1.0 - 1999.10.15 - First version. * This software is released under the MIT license. For conditions of
* 1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson) * distribution and use, see the LICENSE file part of this package.
* 1.2 - 2017.04.22 - Add buffer-size check
* 1.3 - 2017.08.24 - Fix potential overflow in buffer-size check
* (Glenn Randers-Pehrson)
* 1.4 - 2017.08.28 - Add PNGMINUS_UNUSED (Christian Hesse)
* 1.5 - 2018.08.05 - Fix buffer overflow in tokenizer (Cosmin Truta)
* 1.6 - 2018.08.05 - Improve portability and fix style (Cosmin Truta)
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright notice appear in all copies and
* that both that copyright notice and this permission notice appear in
* supporting documentation. This software is provided "as is" without
* express or implied warranty.
*/ */
#include <stdio.h> #include <stdio.h>