COPYRIGHT:

Copyright (C) 1998-2002, 2006-2017 Glenn Randers-Pehrson
                                  (glennrp at users.sf.net)
Portions Copyright (C) 2005 Greg Roelofs

LICENSE:

Permission is hereby irrevocably granted to everyone to use, copy, modify,
and distribute this source code, or portions hereof, or executable programs
compiled from it, for any purpose, without payment of any fee, subject to
the following restrictions:

1. The origin of this source code must not be misrepresented.

2. Altered versions must be plainly marked as such and must not be
   misrepresented as being the original source.

3. This Copyright notice, disclaimers, and license may not be removed
   or altered from any source or altered source distribution.

DISCLAIMERS:

The pngcrush computer program is supplied "AS IS".  The Author disclaims all
warranties, expressed or implied, including, without limitation, the
warranties of merchantability and of fitness for any purpose.  The
Author assumes no liability for direct, indirect, incidental, special,
exemplary, or consequential damages, which may result from the use of
the computer program, even if advised of the possibility of such damage.
There is no warranty against interference with your enjoyment of the
computer program or against infringement.  There is no warranty that my
efforts or the computer program will fulfill any of your particular purposes
or needs.  This computer program is provided with all faults, and the entire
risk of satisfactory quality, performance, accuracy, and effort is with
the user.

EXPORT CONTROL

I am not a lawyer, but I believe that the Export Control Classification
Number (ECCN) for pngcrush is EAR99, which means not subject to export
controls or International Traffic in Arms Regulations (ITAR) because it
and cexcept.c, libpng, and zlib, which may be bundled with pngcrush, are
all open source, publicly available software, that do not contain any
encryption software. See the EAR, paragraphs 734.3(b)(3) and 734.7(b).

TRADEMARK:

The name "pngcrush" has not been registered by the Copyright owner
as a trademark in any jurisdiction.  However, because pngcrush has
been distributed and maintained world-wide, continually since 1998,
the Copyright owner claims "common-law trademark protection" in any
jurisdiction where common-law trademark is recognized.

CEXCEPT COPYRIGHT, DISCLAIMER, and LICENSE:

The cexcept.h header file which is bundled with this software
is conveyed under the license and disclaimer described in lines 10
through 18 of cexcept.h.

LIBPNG COPYRIGHT, DISCLAIMER, and LICENSE:

If libpng is bundled with this software, it is conveyed under the
libpng license (see COPYRIGHT NOTICE, DISCLAIMER, and LICENSE, in png.h).

If intel_init.c and filter_sse2_intrinsics.c are bundled with this
software, they are conveyed under the libpng license (see the
copyright notices within those files and the COPYRIGHT NOTICE, DISCLAIMER,
and LICENSE in png.h).

ZLIB COPYRIGHT, DISCLAIMER, and LICENSE:

If zlib is bundled with this software, it is conveyed under the
zlib license (see the copyright notice, disclaimer, and license
appearing in zlib.h).

ACKNOWLEDGMENTS:

Thanks to Greg Roelofs for various bug fixes, suggestions, and
occasionally creating Linux executables.

Thanks to Stephan Levavej for some helpful suggestions about gcc compiler
options and for a suggestion to increase the Z_MEM_LEVEL from default.

Thanks to others who have made bug reports and suggestions mentioned
in the change log.

CAUTION:

There is another version of pngcrush that has been distributed by
Apple since mid-2008 as a part of the Xcode SDK.   Although it claims
to be pngcrush by Glenn Randers-Pehrson, it has additional options
"-iPhone", "-speed", "-revert-iphone-optimizations", and perhaps others.
It is an "altered version".  I've seen output from a 2006 version that
says on its help screen, "and modified by Apple as indicated in the
sources".

It writes files that have the PNG 8-byte signature but are not valid PNG
files (instead they are "IOS-optimized PNG files"), due to at least

 1. the presence of the CgBI chunk ahead of the IHDR chunk;
 2. nonstandard deflate compression in IDAT, iCCP, and perhaps zTXt chunks
    (I believe this only amounts to the omission of the zlib header from
    the IDAT and perhaps other compressed chunks);
 3. Omission of the CRC bytes from the IDAT chunk and perhaps other chunks;
 4. the use of premultiplied alpha in color_type 6 files; and
 5. the sample order, which is ARGB instead of RGBA in color_type 6 files.

See http://iphonedevwiki.net/index.php/CgBI_file_format for more info.

Although there is no loss in converting a CgBI PNG back to a regular
PNG file, the original PNG file cannot be losslessly recovered from such
files because of the losses that occurred during the conversion to
premultiplied alpha.

Most PNG decoders will recognize the fact that an unknown critical
chunk "CgBI" is present and will immediately reject the file.

It is said that the Xcode version of pngcrush is automatically applied
when PNG files are prepared for downloading to the iPhone unless the
user takes special measures to prevent it.

It is said that the Xcode pngcrush does have a command to undo the
premultiplied alpha.  It's not theoretically possible, however, to recover
the original file without loss.  The underlying color data will either be
reduced in precision, or, in the case of fully-transparent pixels,
completely lost.

I have not seen the source for the Xcode version of pngcrush.  All I
know, for now, is from running "strings -a" on an old copy of the
executable, looking at two Xcode-PNG files, and reading Apple's patent
application <http://www.freepatentsonline.com/y2008/0177769.html>.  Anyone
who does have access to the revised pngcrush code cannot show it to me
anyhow because of their Non-Disclosure Agreement with Apple.

