Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Close GH-2: Rebuilding OptiPNG on Unix systems.

  • Loading branch information...
commit 9b553029bdb67815547808e9cc90d1b076c208ee 1 parent fe315b5
@badunk badunk authored sindresorhus committed
Showing with 77,115 additions and 2 deletions.
  1. +3 −0  .gitignore
  2. +13 −2 lib/optipng-bin.js
  3. +25 −0 optipng/AUTHORS.txt
  4. +23 −0 optipng/LICENSE.txt
  5. +32 −0 optipng/Makefile
  6. +32 −0 optipng/Makefile.in
  7. +49 −0 optipng/README.txt
  8. +24 −0 optipng/build/bcc32.mk
  9. +24 −0 optipng/build/visualc.mk
  10. +329 −0 optipng/configure
  11. +367 −0 optipng/doc/history.txt
  12. +666 −0 optipng/doc/optipng.man.html
  13. BIN  optipng/doc/optipng.man.pdf
  14. +298 −0 optipng/doc/optipng.man.txt
  15. +634 −0 optipng/doc/png_optimization.html
  16. +47 −0 optipng/doc/todo.txt
  17. +32 −0 optipng/src/Makefile
  18. +32 −0 optipng/src/Makefile.in
  19. +195 −0 optipng/src/cexcept/README
  20. +12 −0 optipng/src/cexcept/README.optipng.txt
  21. +61 −0 optipng/src/cexcept/cexcept-2-0-1-optipng.diff
  22. +252 −0 optipng/src/cexcept/cexcept.h
  23. +66 −0 optipng/src/cexcept/example1.c
  24. +139 −0 optipng/src/cexcept/example2.c
  25. +183 −0 optipng/src/cexcept/rationale
  26. +282 −0 optipng/src/gifread/Doxyfile
  27. +51 −0 optipng/src/gifread/Makefile
  28. +51 −0 optipng/src/gifread/Makefile.in
  29. +4 −0 optipng/src/gifread/README.optipng.txt
  30. +53 −0 optipng/src/gifread/build/bcc32.mk
  31. +57 −0 optipng/src/gifread/build/clang.mk
  32. +57 −0 optipng/src/gifread/build/gcc.mk
  33. +57 −0 optipng/src/gifread/build/unix.mk
  34. +51 −0 optipng/src/gifread/build/visualc.mk
  35. +723 −0 optipng/src/gifread/gifread.c
  36. +195 −0 optipng/src/gifread/gifread.h
  37. BIN  optipng/src/gifread/img/compass.gif
  38. +1 −0  optipng/src/gifread/img/index.txt
  39. +112 −0 optipng/src/gifread/test/gifdump.c
  40. +36 −0 optipng/src/libpng/ANNOUNCE
  41. +2,882 −0 optipng/src/libpng/CHANGES
  42. +397 −0 optipng/src/libpng/CMakeLists.txt
  43. +144 −0 optipng/src/libpng/INSTALL
  44. +111 −0 optipng/src/libpng/LICENSE
  45. +139 −0 optipng/src/libpng/Makefile.am
  46. +1,262 −0 optipng/src/libpng/Makefile.in
  47. +254 −0 optipng/src/libpng/README
  48. +10 −0 optipng/src/libpng/README.optipng.txt
  49. +31 −0 optipng/src/libpng/TODO
  50. +9,036 −0 optipng/src/libpng/aclocal.m4
  51. +34 −0 optipng/src/libpng/autogen.sh
  52. +1,501 −0 optipng/src/libpng/config.guess
  53. +86 −0 optipng/src/libpng/config.h.in
  54. +1,705 −0 optipng/src/libpng/config.sub
  55. +14,000 −0 optipng/src/libpng/configure
  56. +157 −0 optipng/src/libpng/configure.ac
  57. +340 −0 optipng/src/libpng/contrib/gregbook/COPYING
  58. +50 −0 optipng/src/libpng/contrib/gregbook/LICENSE
  59. +130 −0 optipng/src/libpng/contrib/gregbook/Makefile.mingw32
  60. +104 −0 optipng/src/libpng/contrib/gregbook/Makefile.sgi
  61. +132 −0 optipng/src/libpng/contrib/gregbook/Makefile.unx
  62. +113 −0 optipng/src/libpng/contrib/gregbook/Makefile.w32
  63. +186 −0 optipng/src/libpng/contrib/gregbook/README
  64. +132 −0 optipng/src/libpng/contrib/gregbook/makevms.com
  65. +304 −0 optipng/src/libpng/contrib/gregbook/readpng.c
  66. +88 −0 optipng/src/libpng/contrib/gregbook/readpng.h
  67. +484 −0 optipng/src/libpng/contrib/gregbook/readpng2.c
  68. +116 −0 optipng/src/libpng/contrib/gregbook/readpng2.h
  69. +179 −0 optipng/src/libpng/contrib/gregbook/readppm.c
  70. +728 −0 optipng/src/libpng/contrib/gregbook/rpng-win.c
  71. +904 −0 optipng/src/libpng/contrib/gregbook/rpng-x.c
  72. +1,253 −0 optipng/src/libpng/contrib/gregbook/rpng2-win.c
  73. +2,109 −0 optipng/src/libpng/contrib/gregbook/rpng2-x.c
  74. BIN  optipng/src/libpng/contrib/gregbook/toucan.png
  75. +853 −0 optipng/src/libpng/contrib/gregbook/wpng.c
  76. +392 −0 optipng/src/libpng/contrib/gregbook/writepng.c
  77. +133 −0 optipng/src/libpng/contrib/gregbook/writepng.h
  78. +9 −0 optipng/src/libpng/contrib/pngminim/decoder/README
  79. +10 −0 optipng/src/libpng/contrib/pngminim/decoder/gather.sh
  80. +43 −0 optipng/src/libpng/contrib/pngminim/decoder/makefile
  81. +75 −0 optipng/src/libpng/contrib/pngminim/decoder/pngusr.h
  82. +9 −0 optipng/src/libpng/contrib/pngminim/encoder/README
  83. +11 −0 optipng/src/libpng/contrib/pngminim/encoder/gather.sh
  84. +41 −0 optipng/src/libpng/contrib/pngminim/encoder/makefile
  85. +75 −0 optipng/src/libpng/contrib/pngminim/encoder/pngusr.h
  86. +14 −0 optipng/src/libpng/contrib/pngminim/preader/README
  87. +11 −0 optipng/src/libpng/contrib/pngminim/preader/gather.sh
  88. +59 −0 optipng/src/libpng/contrib/pngminim/preader/makefile
  89. +68 −0 optipng/src/libpng/contrib/pngminim/preader/pngusr.h
  90. +153 −0 optipng/src/libpng/contrib/pngminus/README
  91. +65 −0 optipng/src/libpng/contrib/pngminus/makefile.std
  92. +38 −0 optipng/src/libpng/contrib/pngminus/makefile.tc3
  93. +92 −0 optipng/src/libpng/contrib/pngminus/makevms.com
  94. +41 −0 optipng/src/libpng/contrib/pngminus/png2pnm.bat
  95. +430 −0 optipng/src/libpng/contrib/pngminus/png2pnm.c
  96. +42 −0 optipng/src/libpng/contrib/pngminus/png2pnm.sh
  97. +4 −0 optipng/src/libpng/contrib/pngminus/pngminus.bat
  98. +5 −0 optipng/src/libpng/contrib/pngminus/pngminus.sh
  99. +41 −0 optipng/src/libpng/contrib/pngminus/pnm2png.bat
  100. +533 −0 optipng/src/libpng/contrib/pngminus/pnm2png.c
  101. +42 −0 optipng/src/libpng/contrib/pngminus/pnm2png.sh
  102. +105 −0 optipng/src/libpng/contrib/pngsuite/README
  103. BIN  optipng/src/libpng/contrib/pngsuite/basn0g01.png
  104. BIN  optipng/src/libpng/contrib/pngsuite/basn0g02.png
  105. BIN  optipng/src/libpng/contrib/pngsuite/basn0g04.png
  106. BIN  optipng/src/libpng/contrib/pngsuite/basn0g08.png
  107. BIN  optipng/src/libpng/contrib/pngsuite/basn0g16.png
  108. BIN  optipng/src/libpng/contrib/pngsuite/basn2c08.png
  109. BIN  optipng/src/libpng/contrib/pngsuite/basn2c16.png
  110. BIN  optipng/src/libpng/contrib/pngsuite/basn3p01.png
  111. BIN  optipng/src/libpng/contrib/pngsuite/basn3p02.png
  112. BIN  optipng/src/libpng/contrib/pngsuite/basn3p04.png
  113. BIN  optipng/src/libpng/contrib/pngsuite/basn3p08.png
  114. BIN  optipng/src/libpng/contrib/pngsuite/basn4a08.png
  115. BIN  optipng/src/libpng/contrib/pngsuite/basn4a16.png
  116. BIN  optipng/src/libpng/contrib/pngsuite/basn6a08.png
  117. BIN  optipng/src/libpng/contrib/pngsuite/basn6a16.png
  118. BIN  optipng/src/libpng/contrib/pngsuite/ftbbn0g01.png
  119. BIN  optipng/src/libpng/contrib/pngsuite/ftbbn0g02.png
  120. BIN  optipng/src/libpng/contrib/pngsuite/ftbbn0g04.png
  121. BIN  optipng/src/libpng/contrib/pngsuite/ftbbn2c16.png
  122. BIN  optipng/src/libpng/contrib/pngsuite/ftbbn3p08.png
  123. BIN  optipng/src/libpng/contrib/pngsuite/ftbgn2c16.png
  124. BIN  optipng/src/libpng/contrib/pngsuite/ftbgn3p08.png
  125. BIN  optipng/src/libpng/contrib/pngsuite/ftbrn2c08.png
  126. BIN  optipng/src/libpng/contrib/pngsuite/ftbwn0g16.png
  127. BIN  optipng/src/libpng/contrib/pngsuite/ftbwn3p08.png
  128. BIN  optipng/src/libpng/contrib/pngsuite/ftbyn3p08.png
  129. BIN  optipng/src/libpng/contrib/pngsuite/ftp0n0g08.png
  130. BIN  optipng/src/libpng/contrib/pngsuite/ftp0n2c08.png
  131. BIN  optipng/src/libpng/contrib/pngsuite/ftp0n3p08.png
  132. BIN  optipng/src/libpng/contrib/pngsuite/ftp1n3p08.png
  133. +442 −0 optipng/src/libpng/contrib/visupng/PngFile.c
  134. +30 −0 optipng/src/libpng/contrib/visupng/PngFile.h
  135. +61 −0 optipng/src/libpng/contrib/visupng/README.txt
  136. +964 −0 optipng/src/libpng/contrib/visupng/VisualPng.c
  137. +147 −0 optipng/src/libpng/contrib/visupng/VisualPng.dsp
  138. +29 −0 optipng/src/libpng/contrib/visupng/VisualPng.dsw
  139. BIN  optipng/src/libpng/contrib/visupng/VisualPng.ico
  140. BIN  optipng/src/libpng/contrib/visupng/VisualPng.png
  141. +152 −0 optipng/src/libpng/contrib/visupng/VisualPng.rc
  142. +248 −0 optipng/src/libpng/contrib/visupng/cexcept.h
  143. +23 −0 optipng/src/libpng/contrib/visupng/resource.h
  144. +630 −0 optipng/src/libpng/depcomp
  145. +838 −0 optipng/src/libpng/example.c
  146. +520 −0 optipng/src/libpng/install-sh
  147. +3,367 −0 optipng/src/libpng/libpng-1.4.12.txt
  148. +127 −0 optipng/src/libpng/libpng-config.in
  149. +4,605 −0 optipng/src/libpng/libpng.3
  150. +11 −0 optipng/src/libpng/libpng.pc.in
  151. +802 −0 optipng/src/libpng/libpngpf.3
  152. +8,745 −0 optipng/src/libpng/ltmain.sh
  153. +376 −0 optipng/src/libpng/missing
  154. +74 −0 optipng/src/libpng/png.5
  155. +914 −0 optipng/src/libpng/png.c
  156. +2,737 −0 optipng/src/libpng/png.h
  157. BIN  optipng/src/libpng/pngbar.jpg
  158. BIN  optipng/src/libpng/pngbar.png
  159. +1,556 −0 optipng/src/libpng/pngconf.h
  160. +412 −0 optipng/src/libpng/pngerror.c
  161. +931 −0 optipng/src/libpng/pngget.c
  162. +611 −0 optipng/src/libpng/pngmem.c
  163. BIN  optipng/src/libpng/pngnow.png
Sorry, we could not display the entire diff because too many files (581) changed.
View
3  .gitignore
@@ -0,0 +1,3 @@
+node_modules
+optipng/
+
View
15 lib/optipng-bin.js
@@ -1,9 +1,20 @@
var path = require('path');
+var execSync = require('exec-sync');
if (process.platform === 'darwin') {
- exports.path = path.join(__dirname, '../vendor/osx', 'optipng');
+ var version = execSync('sw_vers -productVersion');
+
+ if (/10.8/.test(version)) {
+ exports.path = path.join(__dirname, '../vendor/osx/10.8', 'optipng');
+ } else if (/10.7/.test(version)) {
+ exports.path = path.join(__dirname, '../vendor/osx/10.7', 'optipng');
+ }
} else if (process.platform === 'linux') {
- exports.path = path.join(__dirname, '../vendor/linux', 'optipng');
+ if (process.arch === 'x64') {
+ exports.path = path.join(__dirname, '../vendor/linux/x64', 'optipng');
+ } else {
+ exports.path = path.join(__dirname, '../vendor/linux/x86', 'optipng');
+ }
} else if (process.platform === 'win32') {
exports.path = path.join(__dirname, '../vendor/win32', 'optipng.exe');
} else {
View
25 optipng/AUTHORS.txt
@@ -0,0 +1,25 @@
+# OptiPNG version 0.7.4
+# Copyright (C) 2001-2012 Cosmin Truta and the Contributing Authors.
+# See the accompanying LICENSE file for details.
+#
+# A Contributing Author is a person or company who contributed code that
+# is now part of OptiPNG.
+#
+# For the purpose of copyright and licensing, this is the official list
+# of Contributing Authors, in alphabetic order.
+
+Adam Ciarcinski
+Brian McQuade
+Elias Pipping
+Fabien Barbier
+Maciej Pilichowski
+Matthew Fearnley
+Nelson A. de Oliveira
+Niels de Koning
+Petr Gajdos
+Piotr Bandurski
+Ramona C. Truta
+Sebastian Pipping
+Stefan Br�ns
+Till Maas
+Ville Skytt�
View
23 optipng/LICENSE.txt
@@ -0,0 +1,23 @@
+
+Copyright (C) 2001-2012 Cosmin Truta and the Contributing Authors.
+For the purpose of copyright and licensing, the list of Contributing
+Authors is available in the accompanying AUTHORS file.
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the author(s) be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and must not
+ be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source distribution.
+
View
32 optipng/Makefile
@@ -0,0 +1,32 @@
+all:
+ cd src/optipng && \
+ $(MAKE) && \
+ cd ../..
+
+test:
+ cd src/optipng && \
+ $(MAKE) test && \
+ cd ../..
+
+check: test
+
+install:
+ cd src/optipng && \
+ $(MAKE) install && \
+ cd ../..
+
+uninstall:
+ cd src/optipng && \
+ $(MAKE) uninstall && \
+ cd ../..
+
+clean:
+ cd src/optipng && \
+ $(MAKE) clean && \
+ cd ../..
+
+distclean:
+ cd src/optipng && \
+ $(MAKE) distclean && \
+ cd ../..
+ -rm -f src/Makefile Makefile
View
32 optipng/Makefile.in
@@ -0,0 +1,32 @@
+all:
+ cd src/optipng && \
+ $(MAKE) && \
+ cd ../..
+
+test:
+ cd src/optipng && \
+ $(MAKE) test && \
+ cd ../..
+
+check: test
+
+install:
+ cd src/optipng && \
+ $(MAKE) install && \
+ cd ../..
+
+uninstall:
+ cd src/optipng && \
+ $(MAKE) uninstall && \
+ cd ../..
+
+clean:
+ cd src/optipng && \
+ $(MAKE) clean && \
+ cd ../..
+
+distclean:
+ cd src/optipng && \
+ $(MAKE) distclean && \
+ cd ../..
+ -rm -f src/Makefile Makefile
View
49 optipng/README.txt
@@ -0,0 +1,49 @@
+
+OptiPNG 0.7.4: Advanced PNG optimizer.
+Copyright (C) 2001-2012 Cosmin Truta.
+======================================
+
+License
+-------
+ Open-Source (the zlib license)
+ See the accompanying LICENSE.txt
+
+Resources
+---------
+ Home page:
+ http://optipng.sourceforge.net/
+ Download:
+ http://sourceforge.net/project/showfiles.php?group_id=151404
+ Announcements:
+ https://sourceforge.net/news/?group_id=151404
+ Support:
+ http://sourceforge.net/tracker/?group_id=151404
+ ctruta (at) gmail (dot) com
+
+Build instructions
+------------------
+ On Unix, or under a Bourne-compatible shell, run ./configure and make:
+ cd optipng-0.7.4/
+ ./configure
+ make
+ make test
+
+ Alternatively, use a pre-configured makefile that matches your compiler;
+ e.g.:
+ cd optipng-0.7.4/
+ nmake -f build/visualc.mk
+ nmake -f build/visualc.mk test
+
+Installation instructions
+-------------------------
+ Build the program according to the instructions above.
+
+ On Unix:
+ - Make the "install" target:
+ sudo make install
+ - To uninstall, make the "uninstall" target:
+ sudo make uninstall
+
+ On Windows:
+ - Copy optipng.exe to a directory found in PATH.
+
View
24 optipng/build/bcc32.mk
@@ -0,0 +1,24 @@
+# Makefile for Borland C++
+# Usage: make -f build\bcc32.mk
+
+all:
+ cd src\optipng
+ $(MAKE) -f build\bcc32.mk
+ cd ..\..
+
+test:
+ cd src\optipng
+ $(MAKE) -f build\bcc32.mk test
+ cd ..\..
+
+check: test
+
+clean:
+ cd src\optipng
+ $(MAKE) -f build\bcc32.mk clean
+ cd ..\..
+
+distclean:
+ cd src\optipng
+ $(MAKE) -f build\bcc32.mk distclean
+ cd ..\..
View
24 optipng/build/visualc.mk
@@ -0,0 +1,24 @@
+# Makefile for Microsoft Visual C++
+# Usage: nmake -f build\visualc.mk
+
+all:
+ cd src\optipng
+ $(MAKE) -f build\visualc.mk
+ cd ..\..
+
+test:
+ cd src\optipng
+ $(MAKE) -f build\visualc.mk test
+ cd ..\..
+
+check: test
+
+clean:
+ cd src\optipng
+ $(MAKE) -f build\visualc.mk clean
+ cd ..\..
+
+distclean:
+ cd src\optipng
+ $(MAKE) -f build\visualc.mk distclean
+ cd ..\..
View
329 optipng/configure
@@ -0,0 +1,329 @@
+#!/bin/sh
+
+trap "rm -f conftest* core a.out; exit 1" 1 2 3 15
+
+prefix="${prefix-/usr/local}"
+exec_prefix="${exec_prefix-\$(prefix)}"
+bindir="${bindir-\$(exec_prefix)/bin}"
+mandir="${mandir-\$(prefix)/man}"
+man1dir="${man1dir-\$(mandir)/man1}"
+
+cc="${CC-gcc}"
+#cc="${CC-clang}"
+#cc="${CC-c99}"
+cflags="$CFLAGS"
+
+enable_debug=0
+
+with_system_libpng=0
+with_system_zlib=0
+
+with_preconfigured_libpng=1
+with_preconfigured_zlib=0
+
+for arg in "$@"
+do
+ case "$arg" in
+ -- )
+ option="$arg"
+ ;;
+ --* )
+ option=`expr "X$arg" : 'X-\(.*\)'`
+ ;;
+ * )
+ option="$arg"
+ ;;
+ esac
+ case "$arg" in
+ *=* )
+ optarg=`expr "X$arg" : 'X[^=]*=\(.*\)'`
+ ;;
+ * )
+ optarg=""
+ ;;
+ esac
+ case "$option" in
+ -help | -hel | -he | -h )
+ echo "Usage:"
+ echo " $0 [options]"
+ echo "Options:"
+ echo " -h, -help Show this help"
+ echo "Installation directories:"
+ echo " -prefix=PREFIX Install architecture-independent files in PREFIX"
+ echo " [default: $prefix]"
+ echo " -exec-prefix=EPREFIX Install architecture-dependent files in EPREFIX"
+ echo " [default: PREFIX]"
+ echo " -bindir=DIR Install executable in DIR [default: EPREFIX/bin]"
+ echo " -mandir=DIR Install manual in DIR [default: PREFIX/man]"
+ echo "Optional features:"
+ echo " -enable-debug Enable debug build flags and run-time checks"
+ echo "Optional packages:"
+ echo " -with-system-libpng Use the system-supplied libpng"
+ echo " [default: false]"
+ echo " -with-system-zlib Use the system-supplied zlib"
+ echo " [default: with-system-libpng]"
+ echo "Environment variables:"
+ echo " CC C compiler command"
+ echo " LD Linker command"
+ echo " CFLAGS C compiler flags (e.g. -O3)"
+ echo " CPPFLAGS C preprocessor flags (e.g. -I DIR)"
+ echo " LDFLAGS Linker flags (e.g. -L DIR)"
+ echo " LIBS Additional libraries (e.g. -lfoo)"
+ exit 0
+ ;;
+ -prefix | -prefi | -pref | -pre | -pr | -p )
+ prefix="$2"
+ shift
+ ;;
+ -prefix=* | -prefi=* | -pref=* | -pre=* | -pr=* | -p=* )
+ prefix="$optarg"
+ ;;
+ -exec-prefix | -exec_prefix | -exec-prefi | -exec_prefi \
+ | -exec-pref | -exec_pref | -exec-pre | -exec_pre \
+ | -exec-pr | -exec_pr | -exec-p | -exec_p | exec- | -exec_ \
+ | -exec | -exe | -ex | -e )
+ exec_prefix="$2"
+ shift
+ ;;
+ -exec-prefix=* | -exec_prefix=* | -exec-prefi=* | -exec_prefi=* \
+ | -exec-pref=* | -exec_pref=* | -exec-pre=* | -exec_pre=* \
+ | -exec-pr=* | -exec_pr=* | -exec-p=* | -exec_p=* | exec-=* | -exec_=* \
+ | -exec=* | -exe=* | -ex=* | -e=* )
+ exec_prefix="$optarg"
+ ;;
+ -bindir | -bindi | -bind | -bin | -bi | -b )
+ bindir="$2"
+ shift
+ ;;
+ -bindir=* | -bindi=* | -bind=* | -bin=* | -bi=* | -b=* )
+ bindir="$optarg"
+ ;;
+ -mandir | -mandi | -mand | -man | -ma | -m )
+ mandir="$2"
+ shift
+ ;;
+ -mandir=* | -mandi=* | -mand=* | -man=* | -ma=* | -m=* )
+ mandir="$optarg"
+ ;;
+ -enable-debug )
+ enable_debug=1
+ ;;
+ -disable-debug )
+ enable_debug=0
+ ;;
+ -with-system-libpng )
+ with_system_libpng=1
+ # Must use the system-supplied zlib with the system-supplied libpng.
+ with_system_zlib=1
+ ;;
+ -without-system-libpng )
+ with_system_libpng=0
+ ;;
+ -with-system-zlib )
+ with_system_zlib=1
+ ;;
+ -without-system-zlib )
+ with_system_zlib=0
+ # Can't use the system-supplied libpng without the system-supplied zlib.
+ with_system_libpng=0
+ ;;
+ * )
+ echo "error: unknown option: $arg"
+ echo "Type \"$0 -help\" for help"
+ exit 64 # EX_USAGE
+ ;;
+ esac
+done
+
+if test "$with_system_libpng" -ne 0
+then
+ sed_config_libpng="
+ s:@USE_SYSTEM_LIBPNG_TRUE@::g
+ s:@USE_SYSTEM_LIBPNG_FALSE@:#:g
+ "
+else
+ sed_config_libpng="
+ s:@USE_SYSTEM_LIBPNG_FALSE@::g
+ s:@USE_SYSTEM_LIBPNG_TRUE@:#:g
+ "
+fi
+
+if test "$with_system_zlib" -ne 0
+then
+ sed_config_zlib="
+ s:@USE_SYSTEM_ZLIB_TRUE@::g
+ s:@USE_SYSTEM_ZLIB_FALSE@:#:g
+ "
+else
+ sed_config_zlib="
+ s:@USE_SYSTEM_ZLIB_FALSE@::g
+ s:@USE_SYSTEM_ZLIB_TRUE@:#:g
+ "
+ case `uname -s` in
+ mingw* | MINGW* | windows* | WINDOWS* )
+ with_preconfigured_zlib=1
+ sed_config_zlib="
+ $sed_config_zlib
+ s:@ZLIB_MK@:win32/Makefile.gcc:g
+ /MAKE.*ZLIB_MK/ s:distclean:clean:
+ "
+ ;;
+ esac
+fi
+
+test=conftest$$
+cat > $test.c <<EOM
+int hello() { return 42; }
+EOM
+
+gccish=0
+case "$cc" in
+*gcc* | *clang* )
+ echo "Checking for $cc..."
+ if ($cc -c $cflags $test.c) 2>/dev/null
+ then
+ gccish=1
+ fi
+ ;;
+esac
+
+rm -f $test.c $test.o
+
+if test $gccish -ne 0
+then
+ CC="${CC-$cc}"
+ CFLAGS="${CFLAGS--O2 -Wall -Wextra}"
+else
+ CC="${CC-cc}"
+ CFLAGS="${CFLAGS--O}"
+fi
+
+if test $enable_debug -ne 0
+then
+ CPPFLAGS="$CPPFLAGS -DDEBUG -D_DEBUG"
+ CFLAGS="$CFLAGS -g"
+ LDFLAGS="$LDFLAGS -g"
+fi
+
+if test $with_system_libpng -eq 0
+then
+ if test "$with_preconfigured_libpng" -ne 0
+ then
+ echo "Using pre-configured libpng..."
+ if test $gccish -ne 0
+ then
+ sed_config_libpng="
+ $sed_config_libpng
+ s:@LIBPNG_MK@:scripts/makefile.gcc:g
+ "
+ else
+ sed_config_libpng="
+ $sed_config_libpng
+ s:@LIBPNG_MK@:scripts/makefile.std:g
+ "
+ fi
+ else
+ echo "Configuring libpng..."
+ (cd src/libpng && ./configure)
+ if test $? -ne 0
+ then
+ echo "error: could not configure: libpng"
+ exit 1
+ fi
+ fi
+else
+ echo "Checking for system libpng..."
+ test=conftest$$
+cat > $test.c <<EOM
+#include <png.h>
+#if PNG_LIBPNG_VER < 10209
+#error This program requires libpng version 1.2.9 or higher
+#endif
+int dummy;
+EOM
+ ($CC -c $CPPFLAGS $CFLAGS $test.c) 2>/dev/null
+ status=$?
+ rm -f $test.c $test.o
+ if test $status -ne 0
+ then
+ echo "error: missing libpng or incorrect libpng version"
+ echo "note: libpng version 1.2.9 or higher is required"
+ exit 1
+ fi
+fi
+
+if test $with_system_zlib -eq 0
+then
+ if test "$with_preconfigured_zlib" -ne 0
+ then
+ echo "Using pre-configured zlib..."
+ else
+ echo "Configuring zlib..."
+ (cd src/zlib && ./configure --static)
+ if test $? -ne 0
+ then
+ echo "error: could not configure: zlib"
+ exit 1
+ fi
+ fi
+else
+ echo "Checking for system zlib..."
+ test=conftest$$
+cat > $test.c <<EOM
+#include <zlib.h>
+#if ZLIB_VERNUM < 0x1210
+#error This program requires zlib version 1.2.1 or higher.
+#endif
+int dummy;
+EOM
+ ($CC -c $CPPFLAGS $CFLAGS $test.c) 2>/dev/null
+ status=$?
+ rm -f $test.c $test.o
+ if test $status -ne 0
+ then
+ echo "error: missing zlib or incorrect zlib version"
+ echo "note: zlib version 1.2.1 or higher is required"
+ exit 1
+ fi
+fi
+
+sed_config="
+ $sed_config_libpng
+ $sed_config_zlib
+ s#@prefix@#$prefix#g
+ s#@exec_prefix@#$exec_prefix#g
+ s#@bindir@#$bindir#g
+ s#@mandir@#$mandir#g
+ s#@man1dir@#$man1dir#g
+ s#@CC@#${CC-cc}#g
+ s#@CFLAGS@#${CFLAGS--O}#g
+ s#@CPP@#${CPP-\$(CC) -E}#g
+ s#@CPPFLAGS@#${CPPFLAGS-}#g
+ s#@LD@#${LD-\$(CC)}#g
+ s#@LDFLAGS@#${LDFLAGS--s}#g
+ s#@AR@#${AR-ar}#g
+ s#@ARFLAGS@#${ARFLAGS-cru}#g
+ s#@RANLIB@#${RANLIB-ranlib}#g
+ s#@LIBS@#${LIBS-}#g
+ s#@LIBM@#${LIBM--lm}#g
+ s#@LIBZ@#${LIBZ--lz}#g
+ s#@LIBPNG@#${LIBPNG--lpng}#g
+ s#@DIFF@#${DIFF-diff -b -u}#g
+ s#@RM_F@#${RM_F-rm -f}#g
+ s#@[A-Z]*_MK@#Makefile#g
+ s# *\$##
+"
+
+for makefile in \
+ ./Makefile \
+ src/Makefile \
+ src/gifread/Makefile \
+ src/minitiff/Makefile \
+ src/opngreduc/Makefile \
+ src/optipng/Makefile \
+ src/optipng/man/Makefile \
+ src/pngxtern/Makefile \
+ src/pnmio/Makefile
+do
+ sed "$sed_config" $makefile.in > $makefile
+done
View
367 optipng/doc/history.txt
@@ -0,0 +1,367 @@
+
+OptiPNG - Revision history
+==========================
+
+Legend
+------
+++ Added or improved performance-related feature
+ (might improve compression ratio or processing speed).
+ + Added or improved feature.
+ - Removed feature.
+ ! Fixed bug.
+!! Fixed critical bug
+ (crash, data/metadata loss or security hazard).
+ * Other modification (e.g. architectural improvement).
+
+Version 0.7.4 21-oct-2012
+-------------
+!! Fixed the previous fix, which failed to fix the option -fix.
+ (Thanks to Gynvael Coldwind and Mateusz Jurczyk for the report.)
+
+Version 0.7.3 16-sep-2012
+-------------
+!! Fixed a use-after-free vulnerability in the palette reduction code.
+ This vulnerability was accidentally introduced in version 0.7.
+
+Version 0.7.2 24-aug-2012
+-------------
+ * Upgraded libpng to version 1.4.12.
+ * Upgraded zlib to version 1.2.7-optipng.
+ ! Fixed the display of huge (4GB+) file/IDAT sizes on 32-bit platforms.
+ ! Issued a proper error message if the output IDAT can't fit in 2GB.
+ Acknowledged this limitation in the user manual.
+ (Thanks to John Sauter for the report.)
+ ! Fixed the output file cleanup that should occur after a write error.
+ * Added the option -debug and various undocumented debug features.
+ * Moved the PNG reduction module (opngreduc) to a separate sub-project.
+
+Version 0.7.1 19-mar-2012
+-------------
+!! Fixed a regression in the reduction of palette-encoded grayscale
+ images. This regression was introduced in version 0.7.
+ (Thanks to Adam Ciarcinski for the fix.)
+
+Version 0.7 29-feb-2012
+-----------
+ * Upgraded libpng to version 1.4.9.
+ * Upgraded zlib to version 1.2.6-optipng.
+!! Resolved a rarely-occurring out-of-bounds memory access error in
+ Z_RLE, by upgrading zlib. (Thanks to Christopher Wichura for the
+ report, and thanks to Mark Adler for fixing zlib.)
+ + Added the popularly-requested option -strip.
+ The only suboption currently supported is "-strip all".
+ + Added the option -clobber.
+ (Thanks in part to Maciej Pilichowski for the contribution.)
+ + Added the option -backup, as an alias of -keep.
+ + Added the option -silent, as an alias of -quiet.
+ - Deprecated the option -log.
+ * Changed the activity display output from STDOUT to STDERR.
+ + Allowed the option -preserve to save high-resolution timestamps
+ on Unix, if the POSIX-1.2008 API is available. This feature was
+ previously available on Windows only.
+ ! Fixed a minor precision error in the display of file size percents.
+ ! Fixed a memory leak that occurred when reading broken GIF images.
+ ! Fixed various build issues.
+ (Thanks to Sebastian Pipping and Ville Skytta for the fixes.)
+ * Resolved all remaining compatibility issues with libpng-1.5.
+ (Thanks in part to Adam Ciarcinski for the contribution.)
+ * Added build support for clang.
+ * Reorganized the source directory structure.
+
+Version 0.6.5 24-jan-2011
+-------------
+ * Upgraded libpng to version 1.4.5-optipng.
+ * Upgraded zlib to version 1.2.5-optipng.
+!! Fixed the I/O states (in libpng 1.4.5);
+ they caused incorrect file reads in some rare cases.
+ (Thanks to [M*A*S*H] and Dmitry Marakasov for the report.)
+!! Fixed processing of PNG files with chunks of size 0.
+ (Thanks to Matthew Fearnley for the report.)
+ ! Fixed a display error in the TIFF import.
+ (Thanks to Piotr Bandurski for the fix.)
+ + Improved checking of the arguments of -f, -zc, -zm and -zs.
+ - Removed quirks from the rangeset option argument syntax.
+ ! Fixed a build issue under the system-supplied libpng-1.4.
+ (Thanks to Petr Gajdos for the fix.)
+ * Resolved forward-compatibility issues regarding libpng-1.5;
+ however, the system-supplied libpng-1.5 is not yet supported.
+ * Added various enhancements to the configure+make build system.
+ (Thanks in part to Elias Pipping and Dmitri Zubko.)
+
+Version 0.6.4 14-mar-2010
+-------------
+ * Upgraded libpng to version 1.4.1-optipng.
+ * Upgraded zlib to version 1.2.4-optipng.
+ + Added the option -nx.
+ * Clarified the behavior of -nz and the relation between -nz and -o0.
+ + Added a filesystem check (resolving normalized paths, symlinks, etc.)
+ to better detect when the output overwrites the input.
+ + Enabled automatic wildcard expansion (i.e. globbing) on Win64.
+ ! Fixed a Unicode build issue on Windows.
+ (Thanks to Fabien Barbier for the fix.)
+
+Version 0.6.3 18-may-2009
+-------------
+ * Upgraded libpng to version 1.2.36-optipng.
+!! Fixed a use-after-free error in the GIF reader.
+ (Thanks to Roy Tam for the report, and to Bryan McQuade for the fix.)
+ ! Flushed the output log to display the current trial in real time.
+ This only worked on Windows in the previous version.
+ (Thanks to Vincent Lefevre for the fix.)
+ ! Fixed an error in reporting unrecognized file formats.
+ (Thanks to [LaughingMan] for the report.)
+ - Removed the requirement to "fix" TIFF files that contain unrecognized
+ metadata. (Thanks to Piotr Bandurski for the suggestion.)
+ * Simplified the option abbreviation rules. Option names can now be
+ abbreviated to their shortest unique prefix, as in X11 applications.
+
+Version 0.6.2 9-nov-2008
+-------------
+ * Upgraded libpng to version 1.2.33-optipng.
+++ Put back a speed optimization, accidentally removed in version 0.6,
+ allowing singleton trials (-o1) to be bypassed in certain conditions.
+!! Fixed an array overflow in the BMP reader.
+!! Fixed the loss of private chunks under the -snip option.
+ + Produced a more concise on-screen output in the non-verbose mode.
+ (Thanks to Vincent Lefevre for the contribution.)
+ * Added a programming interface to the optimization engine, in order
+ to facilitate the development of PNG-optimizing GUI apps and plugins.
+
+Version 0.6.1 20-jul-2008
+-------------
+ * Upgraded cexcept to version 2.0.1.
+ + Added a configure script, to be used instead of unix-secure.mak.
+ ! Fixed a build issue that occurred when using libpng from the system.
+ (Thanks to Nelson A. de Oliveira for the report.)
+ ! Fixed processing when image reduction yields an output larger than
+ the original. (Thanks to Michael Krishtopa for the report.)
+ ! Fixed behavior of -preserve.
+ (Thanks to Bill Koch for the report.)
+ - Removed displaying of partial progress when abandoning IDATs under
+ the -v option. The percentages displayed were not very accurate.
+
+Version 0.6 15-jun-2008
+-----------
+ * Upgraded libpng to version 1.2.29-optipng.
+++ Implemented grayscale(alpha)-to-palette reductions.
+++ Improved conversion of bKGD info during RGB-to-palette reductions.
+ (Thanks to Matthew Fearnley for the contribution.)
+!! Fixed conversion of bKGD and tRNS during 16-to-8-bit reductions.
+ (Thanks to Matthew Fearnley for the report.)
+ + Added support for compressed BMP (incl. PNG-compressed BMP, you bet!)
+ + Improved the speed of reading raw PNM files.
+ + Recognized PNG digital signatures (dSIG) and disabled optimization
+ in their presence, to preserve their integrity.
+ + Allowed the user to enforce the optimization of dSIG'ed files.
+ + Recognized APNG animation files and disabled reductions to preserve
+ their integrity.
+ + Added the -snip option, to allow the user to "snip" one image out of
+ a multi-image file, such as animated GIF, multi-page TIFF, or APNG.
+ (Thanks to [LaughingMan] for the suggestion.)
+ + Improved recovery of PNG files with incomplete IDAT.
+!! Fixed a crash triggered by the use of -log on some platforms.
+ (Thanks to Stefan Bruns for the fix.)
+ ! Fixed behavior of -out and -dir when the input is already optimized.
+ (Thanks to Christian Davideck for the report.)
+ * Provided more detailed image information at the start of processing.
+ * Provided a more detailed summary at the end of processing, under the
+ presence of the -v option and/or the occurrence of exceptional events.
+
+Version 0.5.5 28-jan-2007
+-------------
+ * Upgraded libpng to version 1.2.15-optipng.
+++ Used a previously-missed RGB-to-palette reduction opportunity
+ for images containing 256 distinct colors.
+ (Thanks to Joachim Kluge for the report.)
+!! Fixed conversion of bKGD info during RGB-to-palette reductions.
+ (Thanks to Matthew Fearnley for the report.)
+ ! Fixed pre-computation of iterations.
+ (Thanks to Matthew Fearnley for the report.)
+ ! Eliminated a false alarm when processing RGB images with tRNS
+ in Unix-secure mode. (Thanks to Till Maas for the report, and
+ thanks to Nelson A. de Oliveira for the fix.)
+ ! Fixed behavior of -out and -dir when changing interlacing.
+ (Thanks to Martin Packman for the report.)
+ ! Fixed the behavior of "-dir [DRIVE]:" on Windows.
+
+Version 0.5.4 11-aug-2006
+-------------
+ + Added user options -out and -dir, to specify the name of
+ the output file or directory.
+ (Thanks to Alexander Lucas for the suggestion.)
+ * Added support for builds based on the system-supplied libpng.
+ (Thanks to Nelson A. de Oliveira for the valuable help.)
+
+Version 0.5.3 23-jul-2006
+-------------
+ * Upgraded libpng to version 1.2.12-optipng.
+ + Implemented basic support for TIFF (grayscale, RGB and RGBA,
+ uncompressed).
+++ Avoided the redundant trial when the search space is singular
+ (e.g. when running "optipng -o1 example.tif").
+ + Prevented accidental file corruption when using option "-log".
+ ! Fixed (again) a small typo in the online help.
+
+Version 0.5.2 7-may-2006
+-------------
+ + Improved handling of inexact PNM-to-PNG conversions.
+ ! Fixed a typo that was breaking the build on some Unix platforms.
+ (Thanks to Aaron Reitz for the report.)
+
+Version 0.5.1 30-apr-2006
+-------------
+++ Implemented bit depth reduction for palette images.
+ * Upgraded libpng to version 1.2.10-optipng.
+ + Improved the BMP support.
+ + Added a Unix man page.
+ (Thanks to Nelson A. de Oliveira for the contribution.)
+ + Allowed abbreviation of command-line options.
+ + Changed user option -log to accept a file name as an argument.
+ * Changed user option -no to -simulate.
+ ! Fixed an error in handling .bak files on Unix.
+ (Thanks to Adam Szojda and Nelson A. de Oliveira for the report.)
+ ! Fixed a small typo in the help screen.
+ (Thanks to A. Costa and Nelson A. de Oliveira for the report.)
+
+Version 0.5 14-jan-2006
+-----------
+++ Added pngxtern, a libpng add-on for external image format
+ support: BMP (uncompressed), GIF, PNM.
+ (This was incorporated from OptiPNG-Plus.)
+++ Implemented RGB(A)-to-palette reductions.
+ * Upgraded zlib to version 1.2.3-optipng.
+ * Upgraded libpng to version 1.2.8-optipng.
+ + If trials are ended prematurely, detailed progression is only
+ reported under the user option -v.
+ - Removed reporting of some IDAT sizes that exceeded the optimum.
+ (This was NOT a bug, but a "feature" that confused some users.)
+ ! Fixed an RGB-to-gray reduction problem that occurred under some
+ specific background colors.
+ * Added support for builds based on the system-supplied zlib.
+ (Thanks to Nelson A. de Oliveira for the suggestion.)
+ * Modified LICENSE. It is now a verbatim spell of the zlib license.
+
+Version 0.4.8 10-may-2005
+-------------
+ * Upgraded libpng to version 1.0.18-optipng.
+!! Fixed a palette-to-gray reduction problem that occurred when an
+ RGB triple had both an alpha below max, and an alpha equal to max.
+ (Thanks to Nicolas Le Gland for the report.)
+ + Packed the Windows executable using UPX.
+ (Thanks to [Warriant] for the suggestion.)
+
+Version 0.4.7 30-oct-2004
+-------------
+!! Fixed a palette-to-gray reduction problem that occurred when
+ having more than one alpha value per RGB triple.
+ (Thanks to Larry Hastings for the report.)
+ ! Fixed the progress display, when processing very large images.
+ + Displayed the image info at the beginning of processing.
+++ Reduced the IDAT buffer size, allowing abandoned trials to
+ terminate earlier in some circumstances.
+ + Implemented error recovery, when PLTE is too small, and/or
+ tRNS is too large.
+
+Version 0.4.6 25-oct-2004
+-------------
+ * Upgraded zlib to version 1.2.2-optipng.
+ * Upgraded libpng to version 1.0.17-optipng.
+ This provides safe handling of some ill-formed PNG images.
+ + Rewrote makefiles.
+ + Added project workspace to build under Visual C++ 6.0,
+ integrated with memory leak detection.
+++ Implemented a premature termination of trials, in the moment
+ when IDAT grows beyond the smallest size previously achieved.
+ (Thanks to Larry Hastings for the idea.)
+ + Changed the order of trials, to perform the trials that are
+ more likely to yield a smaller IDAT, at the beginning.
+ + Added user option -full to avoid the premature termination of
+ trials; useful for debugging.
+
+Version 0.4.5 31-may-2004
+-------------
+ * Upgraded zlib to version 1.2.1.f-cos2.
+ * Upgraded libpng to version 1.0.15-cos2.
+ * Changed user option -nx to -nz.
+ + Added user option to preserve file attributes (file mode,
+ time stamp, etc.) when applicable.
+ (Thanks to Nehal Mistry for the suggestion.)
+ ! Fixed an incorrect initialization of zlib window bits.
+ ! Displayed an error message when the search space was invalid.
+!! Fixed a palette reduction problem for bit depths below 8.
+ ! Eliminated memory leaks.
+ (Thanks to Niels de Koning for the help.)
+
+Version 0.4.4 20-nov-2003
+-------------
+ * Upgraded zlib to version 1.2.1
+++ Added support for the Z_RLE strategy.
+
+Version 0.4.3 12-aug-2003
+-------------
+ ! Fixed a reduction problem that caused an assertion failure.
+ (Thanks to Dimitri Papadopoulos for the report.)
+
+Version 0.4.2 30-jun-2003
+-------------
+++ Enhanced the support for palette size reductions:
+ trailing sterile palette entries are removed even when
+ the bit depth is below 8.
+ ! Enforced recompression when the new IDAT has the same size,
+ but other chunks have been reduced.
+ + Displayed the IDAT size difference as a percentage.
+ (Thanks to Nehal Mistry for the suggestion.)
+
+Version 0.4.1 19-may-2003
+-------------
+ ! Fixed the removal of trailing sterile palette entries.
+
+Version 0.4 12-may-2003
+-----------
+++ Added support for palette-to-gray reductions.
+++ Added partial support for palette size reductions.
+ ! Fixed the reporting of invalid command-line options.
+ ! Eliminated a spurious warning when the zlib window size
+ is set to 256.
+
+Version 0.3.2 11-mar-2003
+-------------
+ + Added support for updating sBIT during reductions.
+ ! Fixed the reduction of the alpha channel.
+
+Version 0.3.1 25-feb-2003
+-------------
+ ! Fixed the encoding of interlaced images when they become
+ larger than the input.
+ (Thanks to James H. Cloos, Jr. for the report.)
+ + Added the HISTORY document (this file).
+
+Version 0.3 24-feb-2003
+-----------
+This is the first public release of OptiPNG.
+++ Added support for iterating through zlib memory levels.
+++ Added support for collapsing IDAT, avoiding calls to
+ png_set_compression_buffer_size().
+ This reduces the memory requirements.
+++ Added support for lossless reduction of the image type:
+ RGB[A] -> G[A], RGBA -> RGB, GA -> G
+ + Added many user options.
+ + Added documentation.
+
+Version 0.2 27-dec-2001
+-----------
+ + Added support for optimization level presets.
+ + Added user option for changing the interlacing.
+
+Version 0.1 17-dec-2001
+-----------
+ + Added support for chunk I/O status annotation.
+ This improves the speed of OptiPNG significantly.
+ * Structured exception handling is provided by cexcept.
+
+Version 0.0.1 10-dec-2001
+-------------
+This is the very first version of OptiPNG.
+It compresses IDAT repeatedly, iterating through zlib compression
+and strategy levels, and PNG filters.
+
View
666 optipng/doc/optipng.man.html
@@ -0,0 +1,666 @@
+<!-- Creator : groff version 1.21 -->
+<!-- CreationDate: Sun Oct 21 21:41:00 2012 -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+<meta name="generator" content="groff -Thtml, see www.gnu.org">
+<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
+<meta name="Content-Style" content="text/css">
+<style type="text/css">
+ p { margin-top: 0; margin-bottom: 0; vertical-align: top }
+ pre { margin-top: 0; margin-bottom: 0; vertical-align: top }
+ table { margin-top: 0; margin-bottom: 0; vertical-align: top }
+ h1 { text-align: center }
+</style>
+<title>OPTIPNG</title>
+
+</head>
+<body>
+
+<h1 align="center">OPTIPNG</h1>
+
+<hr>
+
+
+<h2>NAME
+<a name="NAME"></a>
+</h2>
+
+
+<p style="margin-left:11%; margin-top: 1em"><b>OptiPNG</b>
+&minus; Optimize Portable Network Graphics files</p>
+
+<h2>SYNOPSIS
+<a name="SYNOPSIS"></a>
+</h2>
+
+
+<p style="margin-left:11%; margin-top: 1em"><b>optipng</b>
+[<b>&minus;?</b> | <b>&minus;h</b> | <b>&minus;help</b>]
+<b><br>
+optipng</b> [<i>options...</i>] <i>files...</i></p>
+
+<h2>DESCRIPTION
+<a name="DESCRIPTION"></a>
+</h2>
+
+
+<p style="margin-left:11%; margin-top: 1em">The
+<b>OptiPNG</b> program shall attempt to <i>optimize</i> PNG
+files, i.e. reduce their size to a minimum, without losing
+semantic information. In addition, this program shall
+perform a suite of auxiliary functions like integrity
+checks, metadata recovery and pixmap-to-PNG conversion.</p>
+
+<p style="margin-left:11%; margin-top: 1em">The
+optimization attempts are not guaranteed to succeed. Valid
+PNG files that cannot be optimized by this program are
+normally left intact; their size will not grow. The user may
+request to override this default behavior.</p>
+
+<h2>FILES
+<a name="FILES"></a>
+</h2>
+
+
+<p style="margin-left:11%; margin-top: 1em">The input files
+are raster image files encoded either in PNG format (the
+native format), or in an external format. The currently
+supported external formats are GIF, BMP, PNM and TIFF.</p>
+
+<p style="margin-left:11%; margin-top: 1em"><b>OptiPNG</b>
+processes each image file given in the command line as
+follows:</p>
+
+<p style="margin-left:11%; margin-top: 1em">&minus; If the
+image is in PNG format:</p>
+
+<p style="margin-left:22%; margin-top: 1em">Attempts to
+optimize the given file in-place. If optimization is
+successful, or if the option <b>&minus;force</b> is enabled,
+replaces the original file with its optimized version. The
+original file is backed up if the option <b>&minus;keep</b>
+is enabled.</p>
+
+<p style="margin-left:11%; margin-top: 1em">&minus; If the
+image is in an external format:</p>
+
+<p style="margin-left:22%; margin-top: 1em">Creates an
+optimized PNG version of the given file. The output file
+name is composed from the original file name and the
+<tt>.png</tt> extension.</p>
+
+<p style="margin-left:11%; margin-top: 1em">Existing files
+are <i>not</i> overwritten, unless the option
+<b>&minus;clobber</b> is enabled.</p>
+
+<h2>OPTIONS
+<a name="OPTIONS"></a>
+</h2>
+
+
+<p style="margin-left:11%; margin-top: 1em"><b>General
+options <br>
+&minus;?</b>, <b>&minus;h</b>, <b>&minus;help</b></p>
+
+<p style="margin-left:22%;">Show a complete summary of
+options.</p>
+
+<p style="margin-left:11%;"><b>&minus;backup</b>,
+<b>&minus;keep</b></p>
+
+<p style="margin-left:22%;">Keep a backup of the modified
+files.</p>
+
+<p style="margin-left:11%;"><b>&minus;clobber</b></p>
+
+<p style="margin-left:22%;">Overwrite the existing output
+and backup files. <br>
+Under this option, if the option <b>&minus;backup</b> is not
+enabled, the old backups of the overwritten files are
+deleted.</p>
+
+<p style="margin-left:11%;"><b>&minus;dir</b>
+<i>directory</i></p>
+
+<p style="margin-left:22%;">Write the output files to
+<i>directory</i>.</p>
+
+<table width="100%" border="0" rules="none" frame="void"
+ cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="6%">
+
+
+<p><b>&minus;fix</b></p></td>
+<td width="5%"></td>
+<td width="78%">
+
+
+<p>Enable error recovery. This option has no effect on
+valid input files.</p></td></tr>
+</table>
+
+<p style="margin-left:22%;">The program will spend a
+reasonable amount of effort to recover as much data as
+possible, without increasing the output file size, but the
+success cannot be generally guaranteed. The program may even
+increase the file size, e.g., by reconstructing missing
+critical data. Under this option, integrity shall take
+precedence over file size. <br>
+When this option is not used, the invalid input files are
+left unprocessed.</p>
+
+<table width="100%" border="0" rules="none" frame="void"
+ cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="9%">
+
+
+<p style="margin-top: 1em"><b>&minus;force</b></p></td>
+<td width="2%"></td>
+<td width="56%">
+
+
+<p style="margin-top: 1em">Enforce writing of a new output
+file.</p> </td>
+<td width="22%">
+</td></tr>
+</table>
+
+<p style="margin-left:22%;">This option overrides the
+program&rsquo;s decision not to write such file, e.g. when
+the PNG input is digitally signed (using dSIG), or when the
+PNG output becomes larger than the PNG input.</p>
+
+<p style="margin-left:11%;"><b>&minus;log</b>
+<i>file</i></p>
+
+<p style="margin-left:22%;">Log messages to <i>file</i>.
+For safety reasons, <i>file</i> must have the extension
+<tt>.log</tt>. <br>
+This option is deprecated and will be removed eventually.
+Use shell redirection.</p>
+
+<p style="margin-left:11%;"><b>&minus;out</b>
+<i>file</i></p>
+
+<p style="margin-left:22%;">Write output file to
+<i>file</i>. The command line must contain exactly one input
+file.</p>
+
+<p style="margin-left:11%;"><b>&minus;preserve</b></p>
+
+<p style="margin-left:22%;">Preserve file attributes (time
+stamps, file access rights, etc.) where applicable.</p>
+
+<p style="margin-left:11%;"><b>&minus;quiet</b>,
+<b>&minus;silent</b></p>
+
+<p style="margin-left:22%;">Run in quiet mode. <br>
+The messages are still written to the log file if the option
+<b>&minus;log</b> is enabled.</p>
+
+<p style="margin-left:11%;"><b>&minus;simulate</b></p>
+
+<p style="margin-left:22%;">Run in simulation mode: perform
+the trials, but do not create output files.</p>
+
+<table width="100%" border="0" rules="none" frame="void"
+ cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="3%">
+
+
+<p><b>&minus;v</b></p></td>
+<td width="8%"></td>
+<td width="63%">
+
+
+<p>Enable the options <b>&minus;verbose</b> and
+<b>&minus;version</b>.</p> </td>
+<td width="15%">
+</td></tr>
+</table>
+
+<p style="margin-left:11%;"><b>&minus;verbose</b></p>
+
+<p style="margin-left:22%;">Run in verbose mode.</p>
+
+<p style="margin-left:11%;"><b>&minus;version</b></p>
+
+<p style="margin-left:22%;">Show copyright, version and
+build info.</p>
+
+<table width="100%" border="0" rules="none" frame="void"
+ cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="3%">
+
+
+<p><b>&minus;&minus;</b></p></td>
+<td width="8%"></td>
+<td width="41%">
+
+
+<p>Stop option switch parsing.</p></td>
+<td width="37%">
+</td></tr>
+</table>
+
+<p style="margin-left:11%; margin-top: 1em"><b>PNG encoding
+and optimization options <br>
+&minus;o</b> <i>level</i></p>
+
+<p style="margin-left:22%;">Select the optimization level.
+<br>
+The optimization level 0 enables a set of optimization
+operations that require minimal effort. There will be no
+changes to image attributes like bit depth or color type,
+and no recompression of existing IDAT datastreams. <br>
+The optimization level 1 enables a single IDAT compression
+trial. The trial chosen is what <b>OptiPNG</b> <i>thinks</i>
+it&rsquo;s probably the most effective. <br>
+The optimization levels 2 and higher enable multiple IDAT
+compression trials; the higher the level, the more trials.
+<br>
+The behavior and the default value of this option may change
+across different program versions. Use the option
+<b>&minus;h</b> to see the details pertaining to your
+specific version.</p>
+
+<p style="margin-left:11%;"><b>&minus;f</b>
+<i>filters</i></p>
+
+<p style="margin-left:22%;">Select the PNG delta filters.
+<br>
+The <i>filters</i> argument is specified as a rangeset (e.g.
+<b>&minus;f0&minus;5</b>), and the default <i>filters</i>
+value depends on the optimization level set by the option
+<b>&minus;o</b>. <br>
+The filter values 0, 1, 2, 3 and 4 indicate static
+filtering, and correspond to the standard PNG filter codes
+(<i>None</i>, <i>Left</i>, <i>Up</i>, <i>Average</i> and
+<i>Paeth</i>, respectively). The filter value 5 indicates
+adaptive filtering, whose effect is defined by the
+<b>libpng</b>(3) library used by <b>OptiPNG</b>.</p>
+
+<table width="100%" border="0" rules="none" frame="void"
+ cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="7%">
+
+
+<p><b>&minus;full</b></p></td>
+<td width="4%"></td>
+<td width="78%">
+
+
+<p>Produce a full report on IDAT. This option might slow
+down the trials.</p></td></tr>
+</table>
+
+<p style="margin-left:11%;"><b>&minus;i</b> <i>type</i></p>
+
+<p style="margin-left:22%;">Select the interlace type
+(0&minus;1). <br>
+If the interlace type 0 is selected, the output image shall
+be non-interlaced (i.e. progressive-scanned). If the
+interlace type 1 is selected, the output image shall be
+interlaced using the <i>Adam7</i> method. <br>
+By default, the output shall have the same interlace type as
+the input.</p>
+
+<table width="100%" border="0" rules="none" frame="void"
+ cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="4%">
+
+
+<p><b>&minus;nb</b></p></td>
+<td width="7%"></td>
+<td width="78%">
+
+
+<p>Do not apply bit depth reduction.</p></td></tr>
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="4%">
+
+
+<p><b>&minus;nc</b></p></td>
+<td width="7%"></td>
+<td width="78%">
+
+
+<p>Do not apply color type reduction.</p></td></tr>
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="4%">
+
+
+<p><b>&minus;np</b></p></td>
+<td width="7%"></td>
+<td width="78%">
+
+
+<p>Do not apply palette reduction.</p></td></tr>
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="4%">
+
+
+<p><b>&minus;nx</b></p></td>
+<td width="7%"></td>
+<td width="78%">
+
+
+<p>Do not apply any lossless image reduction: enable the
+options <b>&minus;nb</b>, <b>&minus;nc</b> and
+<b>&minus;np</b>.</p> </td></tr>
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="4%">
+
+
+<p><b>&minus;nz</b></p></td>
+<td width="7%"></td>
+<td width="78%">
+
+
+<p>Do not recode IDAT datastreams.</p></td></tr>
+</table>
+
+<p style="margin-left:22%;">The IDAT optimization
+operations that do not require recoding (e.g. IDAT chunk
+concatenation) are still performed. <br>
+This option has effect on PNG input files only.</p>
+
+<p style="margin-left:11%;"><b>&minus;zc</b>
+<i>levels</i></p>
+
+<p style="margin-left:22%;">Select the zlib compression
+levels used in IDAT compression. <br>
+The <i>levels</i> argument is specified as a rangeset (e.g.
+<b>&minus;zc6&minus;9</b>), and the default <i>levels</i>
+value depends on the optimization level set by the option
+<b>&minus;o</b>. <br>
+The effect of this option is defined by the <b>zlib</b>(3)
+library used by <b>OptiPNG</b>.</p>
+
+<p style="margin-left:11%;"><b>&minus;zm</b>
+<i>levels</i></p>
+
+<p style="margin-left:22%;">Select the zlib memory levels
+used in IDAT compression. <br>
+The <i>levels</i> argument is specified as a rangeset (e.g.
+<b>&minus;zm8&minus;9</b>), and the default <i>levels</i>
+value depends on the optimization level set by the option
+<b>&minus;o</b>. <br>
+The effect of this option is defined by the <b>zlib</b>(3)
+library used by <b>OptiPNG</b>.</p>
+
+<p style="margin-left:11%;"><b>&minus;zs</b>
+<i>strategies</i></p>
+
+<p style="margin-left:22%;">Select the zlib compression
+strategies used in IDAT compression. <br>
+The <i>strategies</i> argument is specified as a rangeset
+(e.g. <b>&minus;zs0&minus;3</b>), and the default
+<i>strategies</i> value depends on the optimization level
+set by the option <b>&minus;o</b>. <br>
+The effect of this option is defined by the <b>zlib</b>(3)
+library used by <b>OptiPNG</b>.</p>
+
+<p style="margin-left:11%;"><b>&minus;zw</b>
+<i>size</i></p>
+
+<p style="margin-left:22%;">Select the zlib window size
+(32k,16k,8k,4k,2k,1k,512,256) used in IDAT compression. <br>
+The <i>size</i> argument can be specified either in bytes
+(e.g. 16384) or kilobytes (e.g. 16k). The default
+<i>size</i> value is set to the lowest window size that
+yields an IDAT output as big as if yielded by the value
+32768. <br>
+The effect of this option is defined by the <b>zlib</b>(3)
+library used by <b>OptiPNG</b>.</p>
+
+<p style="margin-left:11%; margin-top: 1em"><b>Editing
+options</b></p>
+
+<table width="100%" border="0" rules="none" frame="void"
+ cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="7%">
+
+
+<p><b>&minus;snip</b></p></td>
+<td width="4%"></td>
+<td width="78%">
+
+
+<p>Cut one image out of multi-image, animation or video
+files.</p> </td></tr>
+</table>
+
+<p style="margin-left:22%;">Depending on the input format,
+this may be either the first or the most relevant (e.g. the
+largest) image.</p>
+
+<p style="margin-left:11%;"><b>&minus;strip</b>
+<i>objects</i></p>
+
+<p style="margin-left:22%;">Strip metadata objects from a
+PNG file. <br>
+PNG metadata is the information stored in any ancillary
+chunk except tRNS. (tRNS represents the alpha channel,
+which, even if ignored in rendering, is still a proper image
+channel in the RGBA color space.) <br>
+The only option currently supported is <b>&minus;strip
+all</b>.</p>
+
+<p style="margin-left:11%; margin-top: 1em"><b>Notes</b>
+<br>
+Options may come in any order (except for
+<b>&minus;&minus;</b>), before, after, or alternating with
+file names. Option names are case-insensitive and may be
+abbreviated to their shortest unique prefix.</p>
+
+<p style="margin-left:11%; margin-top: 1em">Some options
+may have arguments that follow the option name, separated by
+whitespace or the equal sign (&rsquo;<b>=</b>&rsquo;). If
+the option argument is a number or a rangeset, the separator
+may be omitted. For example:</p>
+
+
+<p style="margin-left:22%; margin-top: 1em"><b>&minus;out</b>
+<tt>newfile.png &nbsp;</tt>&lt;=&gt;
+&nbsp;<b>&minus;out=</b><tt>newfile.png</tt> <b><br>
+&minus;o3 &nbsp;</b>&lt;=&gt; &nbsp;<b>&minus;o 3
+&nbsp;</b>&lt;=&gt; &nbsp;<b>&minus;o=3 <br>
+&minus;f0,3&minus;5 &nbsp;</b>&lt;=&gt; &nbsp;<b>&minus;f
+0,3&minus;5 &nbsp;</b>&lt;=&gt;
+&nbsp;<b>&minus;f=0,3&minus;5</b></p>
+
+<p style="margin-left:11%; margin-top: 1em">Rangeset
+arguments are cumulative; e.g.</p>
+
+<p style="margin-left:22%; margin-top: 1em"><b>&minus;f0
+&minus;f3&minus;5 &nbsp;</b>&lt;=&gt;
+&nbsp;<b>&minus;f0,3&minus;5 <br>
+&minus;zs0 &minus;zs1 &minus;zs2&minus;3 &nbsp;</b>&lt;=&gt;
+&nbsp;<b>&minus;zs0,1,2,3 &nbsp;</b>&lt;=&gt;
+&nbsp;<b>&minus;zs0&minus;3</b></p>
+
+<h2>EXTENDED DESCRIPTION
+<a name="EXTENDED DESCRIPTION"></a>
+</h2>
+
+
+<p style="margin-left:11%; margin-top: 1em">The PNG
+optimization algorithm consists of the following steps:</p>
+
+<table width="100%" border="0" rules="none" frame="void"
+ cellspacing="0" cellpadding="0">
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="3%">
+
+
+<p>1.</p></td>
+<td width="3%"></td>
+<td width="83%">
+
+
+<p>Reduce the bit depth, the color type and the color
+palette of the image. This step may reduce the size of the
+uncompressed image, which, indirectly, may reduce the size
+of the compressed image (i.e. the size of the output PNG
+file).</p> </td></tr>
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="3%">
+
+
+<p>2.</p></td>
+<td width="3%"></td>
+<td width="83%">
+
+
+<p>Run a suite of compression methods and strategies and
+select the compression parameters that yield the smallest
+output file.</p></td></tr>
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="3%">
+
+
+<p>3.</p></td>
+<td width="3%"></td>
+<td width="83%">
+
+
+<p>Store all IDAT contents into a single chunk, eliminating
+the overhead incurred by repeated IDAT headers and CRCs.</p></td></tr>
+<tr valign="top" align="left">
+<td width="11%"></td>
+<td width="3%">
+
+
+<p>4.</p></td>
+<td width="3%"></td>
+<td width="83%">
+
+
+<p>Set the zlib window size inside IDAT to a mininum that
+does not affect the compression ratio, reducing the memory
+requirements of PNG decoders.</p></td></tr>
+</table>
+
+<p style="margin-left:11%; margin-top: 1em">Not all of the
+above steps need to be executed. The behavior depends on the
+actual input files and user options.</p>
+
+<p style="margin-left:11%; margin-top: 1em">Step 1 may be
+customized via the no-reduce options <b>&minus;nb</b>,
+<b>&minus;nc</b>, <b>&minus;np</b> and <b>&minus;nx</b>.
+Step 2 may be customized via the <b>&minus;o</b> option, and
+may be fine-tuned via the options <b>&minus;zc</b>,
+<b>&minus;zm</b>, <b>&minus;zs</b> and <b>&minus;zw</b>.
+Step 3 is always executed. Step 4 is executed only if a new
+IDAT is being created, and may be fine-tuned via the option
+<b>&minus;zw</b>.</p>
+
+<p style="margin-left:11%; margin-top: 1em">Extremely
+exhaustive searches are not generally expected to yield
+significant improvements in compression ratio, and are
+recommended to advanced users only.</p>
+
+<h2>EXAMPLES
+<a name="EXAMPLES"></a>
+</h2>
+
+
+<p style="margin-left:11%; margin-top: 1em"><tt>optipng
+file.png &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt># default speed
+<tt><br>
+optipng -o5 file.png &nbsp;</tt># slow <tt><br>
+optipng -o7 file.png &nbsp;</tt># very slow</p>
+
+<h2>BUGS
+<a name="BUGS"></a>
+</h2>
+
+
+<p style="margin-left:11%; margin-top: 1em">Lossless image
+reductions are not completely implemented. (This does
+<i>not</i> affect the integrity of the output files.) Here
+are the missing pieces:</p>
+
+<p style="margin-left:22%; margin-top: 1em">&minus; The
+color palette reductions are implemented only partially.
+<br>
+&minus; The bit depth reductions below 8, for grayscale
+images, are not implemented yet.</p>
+
+<p style="margin-left:11%; margin-top: 1em">Encoding of
+images whose total IDAT size exceeds 2GB is not
+supported.</p>
+
+<p style="margin-left:11%; margin-top: 1em">TIFF support is
+limited to uncompressed, PNG-compatible (grayscale, RGB and
+RGBA) images.</p>
+
+<p style="margin-left:11%; margin-top: 1em">Metadata is not
+imported from the external image formats.</p>
+
+<p style="margin-left:11%; margin-top: 1em">There is no
+support for pipes or streams.</p>
+
+<h2>SEE ALSO
+<a name="SEE ALSO"></a>
+</h2>
+
+
+<p style="margin-left:11%; margin-top: 1em"><b>png</b>(5),
+<b>libpng</b>(3), <b>zlib</b>(3), <b>pngcrush</b>(1),
+<b>pngrewrite</b>(1).</p>
+
+<h2>STANDARDS
+<a name="STANDARDS"></a>
+</h2>
+
+
+<p style="margin-left:11%; margin-top: 1em">The files
+produced by <b>OptiPNG</b> are compliant with
+<b>PNG&minus;2003</b>: <br>
+Glenn Randers-Pehrson et al. <i>Portable Network Graphics
+(PNG) Specification, Second Edition</i>. <br>
+W3C Recommendation 10 November 2003; ISO/IEC IS 15948:2003
+(E). <tt><br>
+http://www.w3.org/TR/PNG/</tt></p>
+
+<h2>AUTHOR
+<a name="AUTHOR"></a>
+</h2>
+
+
+
+<p style="margin-left:11%; margin-top: 1em"><tt><b>OptiPNG</b></tt>
+is written and maintained by Cosmin Truta.</p>
+
+<p style="margin-left:11%; margin-top: 1em">This manual
+page was originally written by Nelson A. de Oliveira for the
+Debian Project. It was later updated by Cosmin Truta, and is
+now part of the <b>OptiPNG</b> distribution.</p>
+<hr>
+</body>
+</html>
View
BIN  optipng/doc/optipng.man.pdf
Binary file not shown
View
298 optipng/doc/optipng.man.txt
@@ -0,0 +1,298 @@
+OPTIPNG(1) OPTIPNG(1)
+
+NAME
+ OptiPNG - Optimize Portable Network Graphics files
+
+SYNOPSIS
+ optipng [-? | -h | -help]
+ optipng [options...] files...
+
+DESCRIPTION
+ The OptiPNG program shall attempt to optimize PNG files, i.e. reduce
+ their size to a minimum, without losing semantic information. In addi-
+ tion, this program shall perform a suite of auxiliary functions like
+ integrity checks, metadata recovery and pixmap-to-PNG conversion.
+
+ The optimization attempts are not guaranteed to succeed. Valid PNG
+ files that cannot be optimized by this program are normally left
+ intact; their size will not grow. The user may request to override this
+ default behavior.
+
+FILES
+ The input files are raster image files encoded either in PNG format
+ (the native format), or in an external format. The currently supported
+ external formats are GIF, BMP, PNM and TIFF.
+
+ OptiPNG processes each image file given in the command line as follows:
+
+ - If the image is in PNG format:
+
+ Attempts to optimize the given file in-place. If optimization is
+ successful, or if the option -force is enabled, replaces the
+ original file with its optimized version. The original file is
+ backed up if the option -keep is enabled.
+
+ - If the image is in an external format:
+
+ Creates an optimized PNG version of the given file. The output
+ file name is composed from the original file name and the .png
+ extension.
+
+ Existing files are not overwritten, unless the option -clobber is
+ enabled.
+
+OPTIONS
+ General options
+ -?, -h, -help
+ Show a complete summary of options.
+
+ -backup, -keep
+ Keep a backup of the modified files.
+
+ -clobber
+ Overwrite the existing output and backup files.
+ Under this option, if the option -backup is not enabled, the old
+ backups of the overwritten files are deleted.
+
+ -dir directory
+ Write the output files to directory.
+
+ -fix Enable error recovery. This option has no effect on valid input
+ files.
+ The program will spend a reasonable amount of effort to recover
+ as much data as possible, without increasing the output file
+ size, but the success cannot be generally guaranteed. The pro-
+ gram may even increase the file size, e.g., by reconstructing
+ missing critical data. Under this option, integrity shall take
+ precedence over file size.
+ When this option is not used, the invalid input files are left
+ unprocessed.
+
+ -force Enforce writing of a new output file.
+ This option overrides the program's decision not to write such
+ file, e.g. when the PNG input is digitally signed (using dSIG),
+ or when the PNG output becomes larger than the PNG input.
+
+ -log file
+ Log messages to file. For safety reasons, file must have the
+ extension .log.
+ This option is deprecated and will be removed eventually. Use
+ shell redirection.
+
+ -out file
+ Write output file to file. The command line must contain
+ exactly one input file.
+
+ -preserve
+ Preserve file attributes (time stamps, file access rights, etc.)
+ where applicable.
+
+ -quiet, -silent
+ Run in quiet mode.
+ The messages are still written to the log file if the option
+ -log is enabled.
+
+ -simulate
+ Run in simulation mode: perform the trials, but do not create
+ output files.
+
+ -v Enable the options -verbose and -version.
+
+ -verbose
+ Run in verbose mode.
+
+ -version
+ Show copyright, version and build info.
+
+ -- Stop option switch parsing.
+
+ PNG encoding and optimization options
+ -o level
+ Select the optimization level.
+ The optimization level 0 enables a set of optimization opera-
+ tions that require minimal effort. There will be no changes to
+ image attributes like bit depth or color type, and no recompres-
+ sion of existing IDAT datastreams.
+ The optimization level 1 enables a single IDAT compression
+ trial. The trial chosen is what OptiPNG thinks it's probably the
+ most effective.
+ The optimization levels 2 and higher enable multiple IDAT com-
+ pression trials; the higher the level, the more trials.
+ The behavior and the default value of this option may change
+ across different program versions. Use the option -h to see the
+ details pertaining to your specific version.
+
+ -f filters
+ Select the PNG delta filters.
+ The filters argument is specified as a rangeset (e.g. -f0-5),
+ and the default filters value depends on the optimization level
+ set by the option -o.
+ The filter values 0, 1, 2, 3 and 4 indicate static filtering,
+ and correspond to the standard PNG filter codes (None, Left, Up,
+ Average and Paeth, respectively). The filter value 5 indicates
+ adaptive filtering, whose effect is defined by the libpng(3)
+ library used by OptiPNG.
+
+ -full Produce a full report on IDAT. This option might slow down the
+ trials.
+
+ -i type
+ Select the interlace type (0-1).
+ If the interlace type 0 is selected, the output image shall be
+ non-interlaced (i.e. progressive-scanned). If the interlace type
+ 1 is selected, the output image shall be interlaced using the
+ Adam7 method.
+ By default, the output shall have the same interlace type as the
+ input.
+
+ -nb Do not apply bit depth reduction.
+
+ -nc Do not apply color type reduction.
+
+ -np Do not apply palette reduction.
+
+ -nx Do not apply any lossless image reduction: enable the options
+ -nb, -nc and -np.
+
+ -nz Do not recode IDAT datastreams.
+ The IDAT optimization operations that do not require recoding
+ (e.g. IDAT chunk concatenation) are still performed.
+ This option has effect on PNG input files only.
+
+ -zc levels
+ Select the zlib compression levels used in IDAT compression.
+ The levels argument is specified as a rangeset (e.g. -zc6-9),
+ and the default levels value depends on the optimization level
+ set by the option -o.
+ The effect of this option is defined by the zlib(3) library used
+ by OptiPNG.
+
+ -zm levels
+ Select the zlib memory levels used in IDAT compression.
+ The levels argument is specified as a rangeset (e.g. -zm8-9),
+ and the default levels value depends on the optimization level
+ set by the option -o.
+ The effect of this option is defined by the zlib(3) library used
+ by OptiPNG.
+
+ -zs strategies
+ Select the zlib compression strategies used in IDAT compression.
+ The strategies argument is specified as a rangeset (e.g.
+ -zs0-3), and the default strategies value depends on the opti-
+ mization level set by the option -o.
+ The effect of this option is defined by the zlib(3) library used
+ by OptiPNG.
+
+ -zw size
+ Select the zlib window size (32k,16k,8k,4k,2k,1k,512,256) used
+ in IDAT compression.
+ The size argument can be specified either in bytes (e.g. 16384)
+ or kilobytes (e.g. 16k). The default size value is set to the
+ lowest window size that yields an IDAT output as big as if
+ yielded by the value 32768.
+ The effect of this option is defined by the zlib(3) library used
+ by OptiPNG.
+
+ Editing options
+ -snip Cut one image out of multi-image, animation or video files.
+ Depending on the input format, this may be either the first or
+ the most relevant (e.g. the largest) image.
+
+ -strip objects
+ Strip metadata objects from a PNG file.
+ PNG metadata is the information stored in any ancillary chunk
+ except tRNS. (tRNS represents the alpha channel, which, even if
+ ignored in rendering, is still a proper image channel in the
+ RGBA color space.)
+ The only option currently supported is -strip all.
+
+ Notes
+ Options may come in any order (except for --), before, after, or alter-
+ nating with file names. Option names are case-insensitive and may be
+ abbreviated to their shortest unique prefix.
+
+ Some options may have arguments that follow the option name, separated
+ by whitespace or the equal sign ('='). If the option argument is a num-
+ ber or a rangeset, the separator may be omitted. For example:
+
+ -out newfile.png <=> -out=newfile.png
+ -o3 <=> -o 3 <=> -o=3
+ -f0,3-5 <=> -f 0,3-5 <=> -f=0,3-5
+
+ Rangeset arguments are cumulative; e.g.
+
+ -f0 -f3-5 <=> -f0,3-5
+ -zs0 -zs1 -zs2-3 <=> -zs0,1,2,3 <=> -zs0-3
+
+EXTENDED DESCRIPTION
+ The PNG optimization algorithm consists of the following steps:
+
+ 1. Reduce the bit depth, the color type and the color palette of the
+ image. This step may reduce the size of the uncompressed image,
+ which, indirectly, may reduce the size of the compressed image
+ (i.e. the size of the output PNG file).
+
+ 2. Run a suite of compression methods and strategies and select the
+ compression parameters that yield the smallest output file.
+
+ 3. Store all IDAT contents into a single chunk, eliminating the over-
+ head incurred by repeated IDAT headers and CRCs.
+
+ 4. Set the zlib window size inside IDAT to a mininum that does not
+ affect the compression ratio, reducing the memory requirements of
+ PNG decoders.
+
+ Not all of the above steps need to be executed. The behavior depends on
+ the actual input files and user options.
+
+ Step 1 may be customized via the no-reduce options -nb, -nc, -np and
+ -nx. Step 2 may be customized via the -o option, and may be fine-tuned
+ via the options -zc, -zm, -zs and -zw. Step 3 is always executed. Step
+ 4 is executed only if a new IDAT is being created, and may be fine-
+ tuned via the option -zw.
+
+ Extremely exhaustive searches are not generally expected to yield sig-
+ nificant improvements in compression ratio, and are recommended to
+ advanced users only.
+
+EXAMPLES
+ optipng file.png # default speed
+ optipng -o5 file.png # slow
+ optipng -o7 file.png # very slow
+
+BUGS
+ Lossless image reductions are not completely implemented. (This does
+ not affect the integrity of the output files.) Here are the missing
+ pieces:
+
+ - The color palette reductions are implemented only partially.
+ - The bit depth reductions below 8, for grayscale images, are
+ not implemented yet.
+
+ Encoding of images whose total IDAT size exceeds 2GB is not supported.
+
+ TIFF support is limited to uncompressed, PNG-compatible (grayscale, RGB
+ and RGBA) images.
+
+ Metadata is not imported from the external image formats.
+
+ There is no support for pipes or streams.
+
+SEE ALSO
+ png(5), libpng(3), zlib(3), pngcrush(1), pngrewrite(1).
+
+STANDARDS
+ The files produced by OptiPNG are compliant with PNG-2003:
+ Glenn Randers-Pehrson et al. Portable Network Graphics (PNG) Specifi-
+ cation, Second Edition.
+ W3C Recommendation 10 November 2003; ISO/IEC IS 15948:2003 (E).
+ http://www.w3.org/TR/PNG/
+
+AUTHOR
+ OptiPNG is written and maintained by Cosmin Truta.
+
+ This manual page was originally written by Nelson A. de Oliveira for
+ the Debian Project. It was later updated by Cosmin Truta, and is now
+ part of the OptiPNG distribution.
+
+OptiPNG version 0.7.4 2012-Oct-21 OPTIPNG(1)
View
634 optipng/doc/png_optimization.html
@@ -0,0 +1,634 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta name="Author" content="Cosmin Truţa">
+ <title>A guide to PNG optimization</title>
+</head>
+<body>
+
+<h2>A guide to PNG optimization</h2>
+
+<h3>1. Background</h3>
+
+<h4>1.1 The PNG file format</h4>
+
+<p>
+The <a href="http://www.libpng.org/pub/png/">Portable Network Graphics</a>
+(<b><i>PNG</i></b>) is a format for storing compressed raster graphics. The
+compression engine is based on the <b><i>Deflate</i></b> method
+[<a href="http://www.ietf.org/rfc/rfc1951">RFC1951</a>],
+designed by
+<a href="http://www.pkware.com/">PKWare</a>
+and originally used in <b>PKZIP</b>.
+</p>
+
+<p>
+The PNG format is defined by the
+<a href="http://www.libpng.org/pub/png/spec/">PNG Specification</a>.
+This specification was developed by an ad-hoc group named the
+<a href="http://www.libpng.org/pub/png/">PNG Development Group</a>, and it is
+both an International Standard (published under the formal name
+ISO/IEC&nbsp;15948) and a W3C Recommendation.
+</p>
+
+<p>
+PNG was initially intended as a superior, patent-free replacement of GIF. The
+final outcome is a modern, extensible, reliable image format, capable to handle
+an impressive number of image types (from 1-bit black-and-white images up to
+48-bit RGB images with a full 16-bit alpha channel), and geared by a
+significantly stronger lossless compression engine (typically 5-25% better than
+GIF).
+</p>
+
+<p>
+Unlike other lossless compression schemes, PNG compression does not depend
+solely on the statistics of the input, but it may vary within wide limits,
+depending on the compressor's implementation. A good PNG encoder must be
+able to take informed decisions about the factors that affect the size of the
+output. The purpose of this article is to provide information about these
+factors, and to give advice on implementing efficient PNG encoders.
+</p>
+
+
+<h4>1.2 The PNG compression</h4>
+
+<p>
+The PNG compression works in a pipeline manner.
+</p>
+
+<p>
+In the first stage, the image pixels are passed through a lossless arithmetic
+transformation named <b><i>delta filtering</i></b>, or simply
+<b><i>filtering</i></b>, and sent further as a (filtered) byte sequence.
+Filtering does not compress or otherwise reduce the size of the data, but it
+makes the data more compressible.
+</p>
+
+<p>
+In the second stage, the filtered byte sequence is passed through the
+Ziv-Lempel algorithm (LZ77), producing LZ77 codes that are further compressed
+by the Huffman algorithm in the third and final stage. The combination of the
+last two stages is referred to as the <b><i>Deflate compression</i></b>, a
+widely-used, patent-free algorithm for universal, lossless data compression.
+The maximum size of the LZ77 sliding window in Deflate is 32768 bytes, and the
+LZ77 matches can be between 3 and 258 bytes long.
+</p>
+
+<p>
+A complete description of the PNG compression is beyond the scope of this
+guide. The PNG Specification describes the format completely, and provides
+a complete list of references to the underlying technologies.
+</p>
+
+
+<h3>2. Factors that affect the PNG file size</h3>
+
+<div>
+Like any other compression scheme, PNG compression depends on the statistics
+of the input data. In addition, it depends on the following PNG-specific
+parameters:
+</div>
+<ol>
+<li>
+ The PNG image type
+</li>
+<li>
+ The PNG delta filters
+</li>
+<li>
+ The strategy of searching LZ77 matches
+</li>
+<li>
+ The size of the Huffman buffers inside the Deflate encoder
+</li>
+</ol>
+
+<p>
+Depending on how these parameters are chosen by the implementation, PNG
+compression may vary within wide limits. The process of selecting the best
+configuration is computationally infeasible, but heuristics to select a
+satisfactory configuration are available. The problem of improving these
+heuristics constitutes an interesting subject for research.
+</p>
+
+
+<h4>2.1 The PNG image type</h4>
+
+<p>
+The type of a PNG image is defined in the <b><code>IHDR</code></b> image
+header. The image has a certain bit depth, up to 16 bits per sample, and a
+certain color type, from Grayscale to RGB+Alpha. If two PNG files of different
+types represent exactly the same image, each file can be regarded as a lossless
+transformation of the other. A lossless transformation can reduce the
+<i>uncompressed</i> stream, and such a transformation is named <b><i>image
+reduction</i></b>. In most cases, image reductions are capable of reducing the
+<i>compressed</i> stream (which is, in fact, our interest), as an indirect
+effect of reducing the size of the compressor's input.
+</p>
+
+<div>
+The possible image reductions are:
+</div>
+<ul>
+<li>
+ <i>Bit depth reduction</i>
+ <br>
+ The bit depth can be reduced to a minimum value that is acceptable for all
+ samples. For example, if all sample values in a 16-bit image have the form
+ (256+1)*<i>n</i>, (e.g. #0000, #2323, #FFFF), then the bit depth can be
+ reduced to 8, and the new sample values will become <i>n</i>, (e.g. #00, #23,
+ #FF).
+</li>
+<li>
+ <i>Color type reduction</i>
+ <br>
+ - If an RGB image has 256 distinct colors or less, it can be reencoded as a
+ Palette image.
+ <br>
+ - If an RGB or Palette image has only gray pixels, it can be reencoded as
+ Grayscale.
+ <br>
+ A color type reduction can also enable a bit depth reduction.
+</li>
+<li>
+ <i>Color palette reduction</i>
+ <br>
+ If the color palette contains redundant entries (i.e. duplicate entries that
+ indicate the same RGB value) or sterile entries (i.e. entries that do not
+ have a correspondent in the raw pixel data), these entries can be removed.
+ <br>
+ A color palette reduction can also enable a bit depth reduction.
+</li>
+<li>
+ <i>Alpha channel reduction</i>
+ <br>
+ If all pixels in a Grayscale+Alpha or an RGB+Alpha image are fully opaque
+ (i.e. all alpha components are equal to 2^<sup>bitdepth</sup>-1), or if the
+ transparency information can be stored entirely in a (much cheaper)
+ <b><code>tRNS</code></b> chunk, the alpha channel can be stripped.
+</li>
+</ul>
+
+<p>
+There are, however, a few cases when some image type reductions do not
+necessarily lead to the reduction of the compressed stream. The
+<a href="http://www.cs.toronto.edu/~cosmin/pngtech/">PNG-Tech</a> site contains
+experimental analyses of these possibilities; for example, see the article
+<a href="8bpp.html">8 bits per pixel in paletted images</a>.
+</p>
+
+<p>
+Interlacing, useful for a faster, progressive rendering, is another component
+of the PNG image type that affects compression. In an interlaced stream, the
+samples corresponding to neighboring pixels are stored far away, hence the data
+in it is less correlated and less compressible. Unlike JPEG, where interlacing
+may improve the compression slightly, the PNG interlacing degrades the
+compression significantly.
+</p>
+
+
+<h4>2.2 The PNG delta filters</h4>
+
+<p>
+The role of filtering can be illustrated in the following example. Assume the
+sequence 2, 3, 4, 5, 6, 7, 8, 9. Although it has much redundancy, the sequence
+is not compressible by a Ziv-Lempel compressor, nor by a Huffman compressor.
+However, if one makes a simple and reversible transformation, replacing each
+value with the numerical difference between it and the value to its left, the
+sequence becomes 2, 1, 1, 1, 1, 1, 1, 1, which is highly compressible.
+</p>
+
+<p>
+The PNG format employs five types of filters: <b><i>None</i></b>,
+<b><i>Left</i></b>, <b><i>Up</i></b>, <b><i>Average</i></b>, and
+<b><i>Paeth</i></b>. The first filter leaves the original data intact, and the
+other four are subtracting from each pixel a value that involves the
+neighbor pixels from the left, up, and/or the upper left.
+</p>
+
+<p>
+A certain filter is assigned to each row, and is applied to all pixels from
+that row. Therefore, an image can be delta-filtered in a huge number of
+possible configurations (5 ^ <sup><i>height</i></sup>), and each configuration
+leads to a different compressed output. Two different filter configurations may
+make a difference in the compressed file size by a couple of factors, so a
+careful choice of filters is of paramount importance.
+</p>
+
+<p>
+It is possible to apply a single filter to all rows, or to apply different
+filters to different rows. In the former case, the filtering process is
+<b><i>fixed</i></b>; in the latter, it is <b><i>adaptive</i></b>.
+</p>
+
+<div>
+While an exhaustive search is unfeasible, the PNG Specification suggests a
+heuristic filtering strategy:
+</div>
+<ul>
+<li>
+ If the image type is Palette, or the bit depth is smaller than 8, then
+ do not filter the image (i.e. use fixed filtering, with the filter
+ <i>None</i>).
+</li>
+<li>
+ (The other case) If the image type is Grayscale or RGB (with or without
+ Alpha), and the bit depth is not smaller than 8, then use adaptive filtering
+ as follows: <i>independently for each row</i>, apply all five filters and
+ select the filter that produces the smallest sum of absolute values per row.
+</li>
+</ul>
+
+<p>
+Cases where the above heuristics are less than optimal are shown on the
+<a href="http://www.cs.toronto.edu/~cosmin/pngtech/">PNG-Tech</a>
+site; for example, see
+<a href="better-filtering.html">Brute-force vs. heuristic filtering</a>.
+</p>
+
+
+<h4>2.3 The strategy of searching LZ77 matches</h4>
+
+<p>
+The Ziv-Lempel algorithm works under the assumption that contiguous sequences
+appear repeatedly in the input stream. If the sequence to be encoded matches
+one or more sequences already present in the sliding history window, the
+encoder sends a LZ77 pair (<i>distance</i>, <i>length</i>) that points to the
+<i>closest</i> match. In most LZ77 incarnations, including Deflate, smaller
+distance codes are encoded more concisely.
+</p>
+
+<p>
+In Deflate, in particular, the regular (non-matched) symbols, and the match
+lengths, are sent to the same Huffman coder, while the match distances are sent
+to a separate Huffman coder. If the LZ77 matches fall between the accepted
+boundaries (i.e. they are not shorter than 3 and not longer than 258), a greedy
+strategy will accept them as a replacement for the symbols to which they
+correspond.