Imported Upstream version 1.3.31 05/195405/1 upstream/1.3.31
authorhj kim <backto.kim@samsung.com>
Thu, 13 Dec 2018 07:00:00 +0000 (16:00 +0900)
committerhj kim <backto.kim@samsung.com>
Thu, 13 Dec 2018 07:02:34 +0000 (16:02 +0900)
Change-Id: I2c7294cf2abd64840c9513bbaed3c148dc673e1c

471 files changed:
ChangeLog
ChangeLog.2016 [new file with mode: 0644]
ChangeLog.2017 [new file with mode: 0644]
Copyright.txt
Magick++/demo/analyze.cpp
Magick++/demo/button.cpp
Magick++/demo/demo.cpp
Magick++/demo/detrans.cpp
Magick++/demo/flip.cpp
Magick++/demo/gravity.cpp
Magick++/demo/piddle.cpp
Magick++/demo/shapes.cpp
Magick++/demo/zoom.cpp
Magick++/lib/Blob.cpp
Magick++/lib/BlobRef.cpp
Magick++/lib/Color.cpp
Magick++/lib/Drawable.cpp
Magick++/lib/Exception.cpp
Magick++/lib/Geometry.cpp
Magick++/lib/Image.cpp
Magick++/lib/ImageRef.cpp
Magick++/lib/Magick++/CoderInfo.h
Magick++/lib/Magick++/Color.h
Magick++/lib/Magick++/Drawable.h
Magick++/lib/Magick++/Exception.h
Magick++/lib/Magick++/Geometry.h
Magick++/lib/Magick++/Image.h
Magick++/lib/Magick++/ImageRef.h
Magick++/lib/Magick++/Include.h
Magick++/lib/Magick++/Montage.h
Magick++/lib/Magick++/Options.h
Magick++/lib/Magick++/Pixels.h
Magick++/lib/Magick++/STL.h
Magick++/lib/Magick++/Thread.h
Magick++/lib/Magick++/TypeMetric.h
Magick++/lib/Options.cpp
Magick++/lib/Pixels.cpp
Magick++/lib/STL.cpp
Magick++/tests/appendImages.cpp
Magick++/tests/attributes.cpp
Magick++/tests/averageImages.cpp
Magick++/tests/coalesceImages.cpp
Magick++/tests/coderInfo.cpp
Magick++/tests/color.cpp
Magick++/tests/colorHistogram.cpp
Magick++/tests/exceptions.cpp
Magick++/tests/montageImages.cpp
Magick++/tests/morphImages.cpp
Magick++/tests/readWriteBlob.cpp
Magick++/tests/readWriteImages.cpp
Makefile.am
Makefile.in
NEWS.txt
PerlMagick/Magick.pm
PerlMagick/Magick.pm.in
PerlMagick/Magick.xs
PerlMagick/Makefile.PL.in
PerlMagick/Makefile.nt
PerlMagick/t/jpeg/input.jnx [new file with mode: 0644]
PerlMagick/t/jpeg/read.t
PerlMagick/t/reference/jpeg/read_jnx.miff [new file with mode: 0644]
PerlMagick/t/wmf/fulltest.wmf [new file with mode: 0644]
README.txt
TclMagick/ChangeLog
TclMagick/generic/TclMagick.c
TclMagick/generic/TclMagick.h
TclMagick/generic/TclMagickAppInit.c
TclMagick/generic/TkMagick.c
TclMagick/generic/libttkcommon.c
aclocal.m4
coders/Makefile.am
coders/art.c
coders/avs.c
coders/bmp.c
coders/cals.c
coders/cineon.c
coders/cmyk.c
coders/cut.c
coders/dcm.c
coders/dcraw.c
coders/dib.c
coders/dps.c
coders/dpx.c
coders/emf.c
coders/ept.c
coders/fax.c
coders/fits.c
coders/fpx.c
coders/gif.c
coders/gray.c
coders/histogram.c
coders/hrz.c
coders/html.c
coders/icon.c
coders/identity.c
coders/info.c
coders/jbig.c
coders/jnx.c
coders/jp2.c
coders/jpeg.c
coders/locale.c
coders/logo.c
coders/mac.c
coders/map.c
coders/mat.c
coders/matte.c
coders/meta.c
coders/miff.c
coders/mono.c
coders/mpc.c
coders/mpeg.c
coders/msl.c
coders/mtv.c
coders/mvg.c
coders/null.c
coders/otb.c
coders/palm.c
coders/pcd.c
coders/pcl.c
coders/pcx.c
coders/pdb.c
coders/pdf.c
coders/pict.c
coders/pix.c
coders/plasma.c
coders/png.c
coders/pnm.c
coders/ps.c
coders/ps2.c
coders/ps3.c
coders/psd.c
coders/pwp.c
coders/rgb.c
coders/rla.c
coders/rle.c
coders/sct.c
coders/sfw.c
coders/sgi.c
coders/stegano.c
coders/sun.c
coders/svg.c
coders/tga.c
coders/tiff.c
coders/tile.c
coders/tim.c
coders/topol.c
coders/txt.c
coders/uil.c
coders/url.c
coders/uyvy.c
coders/vicar.c
coders/viff.c
coders/wbmp.c
coders/webp.c
coders/wmf.c
coders/wpg.c
coders/xbm.c
coders/xcf.c
coders/xpm.c
coders/xwd.c
coders/yuv.c
common.shi.in
config/compile
config/config.guess
config/config.sub
config/delegates.mgk.in
config/depcomp
config/install-sh
config/missing
config/tap-driver.sh
config/test-driver
configure
configure.ac
filters/analyze.c
locale/C.mgk
m4/pkg.m4 [new file with mode: 0644]
magick/Makefile.am
magick/PreRvIcccm.h
magick/alpha_composite.h
magick/analyze.c
magick/analyze.h
magick/animate.c
magick/animate.h
magick/annotate.c
magick/api.h
magick/attribute.c
magick/attribute.h
magick/average.c
magick/average.h
magick/bit_stream.c
magick/bit_stream.h
magick/blob.c
magick/blob.h
magick/cdl.c
magick/channel.c
magick/channel.h
magick/color.c
magick/color.h
magick/color_lookup.c
magick/color_lookup.h
magick/colormap.c
magick/colormap.h
magick/colorspace.c
magick/colorspace.h
magick/command.c
magick/command.h
magick/common.h
magick/compare.c
magick/compare.h
magick/composite.c
magick/composite.h
magick/compress.c
magick/compress.h
magick/confirm_access.c
magick/confirm_access.h
magick/constitute.c
magick/constitute.h
magick/decorate.c
magick/decorate.h
magick/delegate.c
magick/delegate.h
magick/deprecate.c
magick/deprecate.h
magick/describe.c
magick/describe.h
magick/display.c
magick/display.h
magick/draw.c
magick/draw.h
magick/effect.c
magick/effect.h
magick/enhance.c
magick/enhance.h
magick/enum_strings.c
magick/enum_strings.h
magick/error.c
magick/error.h
magick/export.c
magick/floats.c
magick/floats.h
magick/forward.h
magick/fx.c
magick/fx.h
magick/gem.c
magick/gem.h
magick/gradient.c
magick/gradient.h
magick/hclut.c
magick/hclut.h
magick/image.c
magick/image.h
magick/import.c
magick/list.c
magick/list.h
magick/locale.c
magick/locale_c.h
magick/log.c
magick/log.h
magick/magic.c
magick/magic.h
magick/magick.c
magick/magick.h
magick/magick_config.h.in
magick/magick_endian.c
magick/magick_endian.h
magick/magick_types.h
magick/map.c
magick/map.h
magick/memory.c
magick/memory.h
magick/module.c
magick/module.h
magick/module_aliases.h [new file with mode: 0644]
magick/monitor.c
magick/monitor.h
magick/montage.c
magick/montage.h
magick/nt_base.c
magick/nt_base.h
magick/nt_feature.c
magick/nt_feature.h
magick/omp_data_view.c
magick/omp_data_view.h
magick/operator.c
magick/paint.c
magick/paint.h
magick/pixel_cache.c
magick/pixel_cache.h
magick/pixel_iterator.c
magick/pixel_iterator.h
magick/plasma.h
magick/prefetch.h
magick/profile.c
magick/profile.h
magick/quantize.c
magick/quantize.h
magick/random-private.h
magick/random.c
magick/random.h
magick/registry.h
magick/render.c
magick/render.h
magick/resize.c
magick/resize.h
magick/resource.c
magick/resource.h
magick/segment.c
magick/semaphore.c
magick/semaphore.h
magick/shear.c
magick/shear.h
magick/signature.h
magick/spinlock.h
magick/static.c
magick/static.h
magick/statistics.c
magick/statistics.h
magick/studio.h
magick/symbols.h
magick/tempfile.c
magick/tempfile.h
magick/texture.c
magick/texture.h
magick/timer.h
magick/transform.c
magick/transform.h
magick/tsd.c
magick/tsd.h
magick/type.h
magick/unix_port.c
magick/unix_port.h
magick/utility.c
magick/utility.h
magick/version.h
magick/version.h.in
magick/widget.c
magick/widget.h
magick/xwindow.c
magick/xwindow.h
scripts/gmsymbols.sh [new file with mode: 0755]
scripts/html_fragments.py
tests/rwblob.c
tests/rwblob.tap
tests/rwfile.c
tests/rwfile.tap
utilities/Makefile.am
utilities/gm.1
version.sh
wand/GraphicsMagickWand-config.1
wand/drawing_wand.c
wand/drawing_wand.h
wand/drawtest.c
wand/magick_compat.c
wand/magick_wand.c
wand/magick_wand.h
wand/pixel_wand.h
wand/wand_api.h
wand/wand_symbols.h
wand/wandtest.c
www/ChangeLog-2017.html [new file with mode: 0644]
www/ChangeLog-2017.rst [new file with mode: 0644]
www/Changelog.html
www/Changelog.rst
www/Changes.html
www/Changes.rst
www/Copyright.html
www/FAQ.html
www/FAQ.rst
www/GraphicsMagick.html
www/Hg.html
www/Hg.rst
www/INSTALL-unix.html
www/INSTALL-unix.rst
www/INSTALL-windows.html
www/INSTALL-windows.rst
www/ImageMagickObject.html
www/ImageMagickObject.rst
www/Magick++/Blob.html
www/Magick++/Blob.rst
www/Magick++/COPYING
www/Magick++/CoderInfo.html
www/Magick++/CoderInfo.rst
www/Magick++/Color.html
www/Magick++/Color.rst
www/Magick++/Drawable.html
www/Magick++/Drawable.rst
www/Magick++/Enumerations.html
www/Magick++/Enumerations.rst
www/Magick++/Exception.html
www/Magick++/Exception.rst
www/Magick++/FormatCharacters.html
www/Magick++/FormatCharacters.rst
www/Magick++/Geometry.html
www/Magick++/Geometry.rst
www/Magick++/Image.html
www/Magick++/Image.rst
www/Magick++/ImageDesign.html
www/Magick++/ImageDesign.rst
www/Magick++/Montage.html
www/Magick++/Montage.rst
www/Magick++/PixelPacket.html
www/Magick++/PixelPacket.rst
www/Magick++/Pixels.html
www/Magick++/Pixels.rst
www/Magick++/TypeMetric.html
www/Magick++/TypeMetric.rst
www/Magick++/index.html
www/Magick++/index.rst
www/Makefile.am
www/NEWS.html
www/OpenMP.html
www/OpenMP.rst
www/README.html
www/api/api.html
www/api/api.rst
www/api/attribute.html
www/api/blob.html
www/api/constitute.html
www/api/draw.html
www/api/error.html
www/api/image.html
www/api/list.html
www/api/monitor.html
www/api/render.html
www/api/types.html
www/api/types.rst
www/authors.html
www/authors.rst
www/benchmarks.html
www/benchmarks.rst
www/bugs.html
www/bugs.rst
www/contribute.html
www/contribute.rst
www/download.html
www/download.rst
www/formats.html
www/formats.rst
www/gm.html
www/index.html
www/index.rst
www/links.html
www/links.rst
www/miff.html
www/miff.rst
www/mission.html
www/mission.rst
www/motion-picture.html
www/motion-picture.rst
www/perl.html
www/perl.rst
www/process.html
www/process.rst
www/programming.html
www/programming.rst
www/project.html
www/project.rst
www/quantize.html
www/quantize.rst
www/reference.html
www/reference.rst
www/security.html
www/security.rst
www/thanks.html
www/thanks.rst
www/tools.html
www/tools.rst
www/utilities.html
www/utilities.rst
www/version.html
www/wand/magick_wand.html

index 64271c2..4f746d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
-2017-07-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-11-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * NEWS.txt: Make sure is up to date.
+       * www/index.rst: Update in preparation for 1.3.31 release.
 
-       * www/index.rst: Update for 1.3.26 release.
+       * version.sh: Update library versioning in preparation for
+       1.3.31 release.
 
-       * version.sh: Update library versioning for 1.3.26 release.
+       * NEWS.txt: Update news in preparation for 1.3.31 release.
 
-       * magick/command.c (BatchCommand): Add ferror() checks around
-       batch input loop.
+2018-11-15  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-07-03  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+       * magick/command.c (BenchmarkUsage): Document the benchmark
+       command better.
 
-       * coders/png.c: Reject a PNG file if the file size is too small
-       (less than 61 bytes).  Reject a JNG file if it is too small (less
-       than 147 bytes).
-       * coders/jpeg.c: Reject a JPEG file if the file size is too small
-       (less than 107 bytes).
+2018-11-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-07-02  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+       * magick/resize.c (HorizontalFilter, VerticalFilter): quantum is a
+       pointer so it's value can not be usefully flushed.  Use a local
+       variable and then update quantum pointer when done.
 
-       * coders/dpx.c (ReadDPXImage): Compute required file size and
-       verify that sufficient data exists in file before allocating
-       memory to decode the image data.  Resolves problem with DPX file
-       with valid header (but a huge claimed image width) provided
-       provided via email on Thu, 29 Jun 2017 by LCatro.  This issue has
-       been assigned CVE-2017-10799.
+2018-11-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2016-07-02  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+       * magick/*: Changed row_count tallying to use 'omp atomic' and
+       status update to use 'omp flush' for progress and error
+       indication.  This replaces most use of 'omp critical' for this
+       purpose.  Changed some lumpy algorithms which were using 'static'
+       scheduling to 'guided' scheduling due to observing better results.
+       Also added prolific 'restrict' annotations where they were
+       missing.
 
-       * coders/mat.c Check whether reported object size overflows file size.
+       * www/security.rst: Documented a PGP private key for file signing
+       or private correspondence.
 
-2016-07-01  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+2018-11-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * coders/mat.c Safety check for forged and or corrupted data.
-       This issue has been assigned CVE-2017-10800.
+       * www/authors.rst: Moved "Glenn Randers-Pehrson" and "Gregory J
+       Wolfe" to the "Former Contributor" category.
 
-2017-07-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-11-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * coders/tiff.c ("QuantumTransferMode"): Use a generalized method
-       to enforce that buffer overflow can not happen while importing
-       pixels.  Resolves problem with RGB TIFF claiming only one sample
-       per pixel provided via email on Thu, 29 Jun 2017 by LCatro.  This
-       issue has been assigned CVE-2017-10794.
+       * Added many GCC function annotations in the libraries and coders.
 
-2017-06-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-11-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * magick/command.c: Convert bare 'unsigned int' to MagickPassFail
-       where suitable to make intentions clear.  Convert True/False to
-       MagickTrue/MagickFalse or MagickPass/MagickFail according to
-       purpose.  This is a continuation of a gradual migration and does
-       not represent an API change.
+       * configure.ac: Use printf rather than echo to portably expand tab
+       requests in configuration summary.
 
-2017-06-25  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+2018-11-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * coders/png.c: Avoid NULL dereference when MAGN chunk processing
-       fails (https://sourceforge.net/p/graphicsmagick/bugs/426/). Expand
-       TABs.
+       * configure.ac: Use pkg-config data as the initial choice when
+       configuring for FreeType 2.0 and libxml-2.0.  Only fall back to
+       invoking an external script (and then traditional methods) if
+       pkg-config fails.
 
-2017-06-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+       * coders/msl.c (ProcessMSLScript): Release msl_image if OpenBlob
+       fails.  Similar to ImageMagick CVE-2018-18544.  Problem was
+       reported to us via email from Petr Gajdos on Thu, 1 Nov 2018.
 
-       * NEWS.txt: Update NEWS with changes since the previous release.
+2018-10-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * www/programming.rst: Switch the Lua link to
-       https://github.com/arcapos/luagraphicsmagick, which is a more
-       complete and direct interface from Lua to GraphicsMagick's Wand
-       API.
+       * coders/miff.c (WriteMIFFImage): Only run
+       strlen(attribute->value) once per attribute since the length won't
+       change.  May address oss-fuzz 11158
+       "graphicsmagick/coder_MIFF_fuzzer: Timeout in
+       graphicsmagick_coder_MIFF_fuzzer". (Credit to OSS-Fuzz)
 
-2017-06-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+       * Fix compilation warnings observed with GCC 8.2.0.
 
-       * VisualMagick/installer/gm-foo-dll.iss: Remove PerlMagick from
-       the slim Inno Setup installer builder and remove mention of
-       PerlMagick from the installer documentation.
+2018-10-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * TclMagick/generic/TclMagick.c (magickCmd): Resolve SourceForge
-       patch #51 "TclMagick: memory access error; possible segfault".
-       (newMagickObj): Fix formatting of pointer value so it is 64-bit
-       safe.  Resolves SourceForge patch #50 "TclMagick: 64-bit
-       portability issue".
+       * magick/pixel_iterator.c (PixelIterateMonoModifyImplementation):
+       Use atomic and flush rather than critical construct for a small
+       speedup.
 
-       * coders/pict.c (ReadPICTImage): Avoid possible use of negative
-       value when indexing array, which would cause buffer overflow.
-       Resolves SourceForge issue #427 "One possible buffer overflow
-       vulnerability in
-       GraphicsMagick-1.3.25/coders/pict.c:ReadPICTImage()".
+       * magick/monitor.c (MagickMonitorFormatted): Serialize calls to
+       the progress monitor so that the caller does not need to perform
+       this serialization.
+       (MagickMonitor): Serialize calls to the progress monitor so that
+       the caller does not need to perform this serialization.  This
+       function is now marked as deprecated.
+       (InitializeMagickMonitor): New private function to initialize
+       monitor functionality.
+       (DestroyMagickMonitor): New private function to destroy monitor
+       functionality.
 
-2017-06-22  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+2018-10-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * coders/png.c: Stop memory leak when reading invalid JNG image.
-       Fixes CVE-2017-8350.
+       * coders/gif.c (ReadGIFImage): Improve the efficiency of storing a
+       GIF comment in order to avoid a DOS opportunity.  Fixes oss-fuzz
+       11096 "graphicsmagick/coder_GIF_fuzzer: Timeout in
+       graphicsmagick_coder_GIF_fuzzer". (Credit to OSS-Fuzz)
 
-2017-06-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-10-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * coders/png.c: Fix lcms2.h inclusion logic.
+       * PerlMagick/Makefile.PL.in: Use MAGICK_API_LIBS to obtain the
+       list of libraries to use when linking.
 
-       * wand/magick_wand.c (MagickSetImageOrientation): Eliminate use of
-       snprintf, which is not supported by older Visual Studio.
+       * configure.ac: OpenMP library is normally supplied due to a
+       CFLAGS option so only supply it in cases where the CFLAGS option
+       may be lost or it might not be used.  Otherwise the compiler may
+       apply the library twice when linking.
 
-2017-06-09  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+2018-10-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * coders/png.c: Accept exIf chunks whose data segment
-       erroneously begins with "Exif\0\0".
+       * configure.ac: Remove Ghostscript library support (--with-gslib)
+       from configure script.  The 'HasGS' pre-processor defines which
+       were enabled by this remain in the source code so it is still
+       possible to use this library if absolutely necessary
+       (e.g. CPPFLAGS=-DHasGS LIBS=-lgs).
 
-2017-06-01  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+       * tests/rwfile.tap: Test TIFF format with all supported
+       compression options.
 
-       * coders/png.c: Removed experimental zxIF chunk support.  That
-       proposal is dead.
+       * tests/{rwblob.c, rwfile.c} (main): Use StringToCompressionType()
+       to parse compression option. Also consider requested compression
+       algorithm when deciding if format is lossy.
 
-2017-05-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+       * coders/tiff.c (WriteTIFFImage): WebP compression needs
+       PHOTOMETRIC_RGB. Fix wrong rows-per-strip calculation when using
+       LZMA compression.
 
-       * config/log.mgk: Added documentation suggested by SourceForge
-       issue #419 "Consider a small patch to log.mgk".
+       * tests/rwblob.tap: Added a rwblob test to verify that lower-case
+       magick works.
 
-       * www/Changes.rst: Add missing link to most recent changes.
+       * magick/static.c (OpenModule): Upper case magick string before
+       searching static modules list.  Fixes Debian bug 911386
+       "libgraphicsmagick-q16-3: graphicsmagick 1.3.30 has made formats
+       case-sensitive at the API level".
 
-2017-05-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+       * filters/analyze.c (AnalyzeImage): X and y should be unsigned
+       long to match image rows/columns type.  Calculate total pixels by
+       simple multiplication rather than counting.
 
-       * www/Magick++/Image.rst: Improve documentation for Magick++
-       Image::iccColorProfile() and Image::renderingIntent().
+2018-10-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-05-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+       * coders/tiff.c (WriteTIFFImage): Support WebP compression in
+       TIFF. This requires a libtiff release after 4.0.9.
 
-       * tiff: Update to libtiff 4.0.8.
+       * magick/image.h ("C"): WebPCompression added to CompressionType
+       enumeration.
 
-2017-03-19  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+2018-10-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * coders/png.c: Quieted a new Coverity complaint about a potential
-       text buffer overrun.
+       * configure.ac: Configure for the Zstd library.  Use
+       --without-zstd to disable searching for this library.  Libtiff may
+       require this library to successfully link so static linkage could
+       fail if searching for libzstd is disabled.
 
-2017-03-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+       * magick/image.h ("C"): ZSTDCompression added to CompressionType
+       enumeration.
 
-       * magick/image.c (SetImageInfo): Ignore empty magic prefix
-       specification and do not remove colon character from start of
-       filename.  Resolves SourceForge bug #415 "Inconsistent Behavior w/
-       input_file Parameter".
+       * coders/tiff.c (WriteTIFFImage): Support Zstd compression in
+       TIFF.  This requires a libtiff release after 4.0.9.
 
-2017-03-18  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+2018-10-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * coders/png.c: Added new private orNT PNG chunk, to
-       preserve image->orientation when it is defined and not
-       the default TopLeft.
-       * coders/jpeg.c: Mention image->orientation in the log when
-       writing a JPEG.
+       * magick/command.c (GMCommandSingle): Add 'compare' to the list of
+       command names that gm will support as a command if copied to or
+       linked from that name.  There was already a 'compare' link
+       installed when the '--enable-magick-compat' configure option is
+       used, but it could not possibly function without being blessed by
+       this list.  Related to Debian bug #910652
+       "graphicsmagick-imagemagick-compat: Doesn't ship a compare tool".
 
-2017-03-15  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+2018-09-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * coders/png.c (WriteOnePNGImage): Add version info about
-       gm, libpng, zlib, and lcms to the PNG debug log.
+       * Magick++/lib/Magick++/Drawable.h: Block unused-private-field
+       warnings from Clang due to _dummy members which were intentionally
+       included in some parent class definitions.
 
-2017-03-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+       * magick/widget.c (XEditText): Fix compilation warnings about
+       cases which fall-through.
 
-       * magick/command.c (ImportImageCommand): Fix handling of -frame
-       options. Option handling was incorrect due to option checking the
-       frame option after it had been freed.  Checking the frame dash
-       option before freeing the argument solves the problem.  From patch
-       provided by Victor Ananjevsky as SourceForge patch #49 "-frame
-       doesn't work in gm import".
+       * magick/display.c (MagickXAnnotateEditImage): Fix compilation
+       warnings about cases which fall-through.
 
-       * Magick++/lib/Image.cpp (attribute): Added Image attribute method
-       which accepts a 'char *' argument, and will remove the attribute
-       if the value argument is NULL.  From patch provided by "Gints" as
-       SourceForge patch #46 "C++ api - method to clear/remove
-       attribute".
+       * coders/pict.c (WritePICTImage): Add more checks to memory
+       allocation calculations.
 
-       * VisualMagick/configure/configure.cpp (InitInstance): Applied
-       patch by Paul McConkey to allow the quantum command line argument
-       to set the default value in the wizard drop list.  This allows
-       setting the quantum depth when the /nowizard argument was
-       supplied.  Resolves SourceForge patch #48 "When running from the
-       command line configure.exe does not use the quantum argument".
-       The provided configure.exe still needs to be rebuilt to
-       incorporate this change.
+       * magick/pixel_cache.c (DestroyCacheInfo): Eliminate intentional
+       fall-through logic in switch statement which results in compiler
+       warnings.  Eliminate switch statements entirely and split
+       unrelated logic.
 
-       * magick/command.c (MogrifyImage): The -orient command now also
-       updates the orientation in the EXIF profile, if it exists.
+       * coders/txt.c (ReadTXTImage): Fix comparison between pointer and
+       '\0' rather than NULL as was obviously intended.
 
-       * Magick++/lib/Image.cpp (orientation): Update orientation in EXIF
-       profile, if it exists.
+       * coders/msl.c (MSLStartElement): Add missing 'break' statements
+       after ThrowException() calls.  Otherwise execution falls through
+       into unrelated switch cases and throws a redundant exception.
 
-2017-03-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-09-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * coders/jp2.c: Support PGX JPEG 2000 format for reading and
-       writing (within the bounds of what JasPer supports).
+       * coders/meta.c (parse8BIM): Eliminate repeated use of strlen()
+       which scans the entire remaining string on each cycle.  Fixes
+       oss-fuzz 10667 "graphicsmagick/coder_IPTCTEXT_fuzzer: Timeout in
+       graphicsmagick_coder_IPTCTEXT_fuzzer". (Credit to OSS-Fuzz)
 
-2017-02-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-09-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * coders/tiff.c (QuantumTransferMode): Fix out of bounds read when
-       reading CMYKA TIFF which claims to have only 2 samples per pixel.
-       Problem was reported via email on February 15, 2017 by Valon
-       Chu. This issue was assigned CVE-2017-6335.
+       * magick/utility.c (MagickGetToken): Fix possible read up to four
+       bytes beyond end of stack allocated token buffer.  Fixes oss-fuzz
+       10653 "graphicsmagick/coder_MVG_fuzzer: Stack-buffer-overflow in
+       MagickGetToken". (Credit to OSS-Fuzz)
 
-2017-01-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-09-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * doc/options.imdoc (-geometry): Geometry documentation changes
-       suggested by Jon Wong.
+       * fuzzing/coder_fuzzer.cc (LLVMFuzzerTestOneInput): Limit the
+       maximum number of JPEG progressive scans to 50.
 
-2017-01-26  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+       * coders/jpeg.c (ReadJPEGImage): Apply a default limit of 100
+       progressive scans before the reader quits with an error.  This
+       limit may be adjusted using the -define mechanism like -define
+       JPEG:max-scan-number=500.  Also respond more quickly to files
+       which exceed the maximum image dimensions.  Fixes oss-fuzz 10258
+       "graphicsmagick/coder_JPEG_fuzzer: Timeout in
+       graphicsmagick_coder_JPEG_fuzzer". (Credit to OSS-Fuzz)
 
-       * coders/png.c: Added support for a proposed new PNG chunk
-       (zxIf, read-only) that is currently being discussed on the
-       png-mng-misc at lists.sourceforge.net mailing list.  Enable
-       exIf and zxIf with CPPFLAGS="-DexIf_SUPPORTED -DxzIf_SUPPORTED".
-       If exIf is enabled, only the uncompressed exIF chunk will be
-       written and the hex-encoded zTXt chunk containing the raw Exif
-       profile won't be written.
+2018-09-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-01-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+       * coders/png.c (ReadMNGImage): mng_LOOP chunk must be at least 5
+       bytes long.  Fixes oss-fuzz 10455
+       "graphicsmagick/coder_MNG_fuzzer: Use-of-uninitialized-value in
+       ReadMNGImage". (Credit to OSS-Fuzz)
 
-       * coders/msl.c (MSLStartElement): Change test for NULL image
-       pointer to before it is used rather than after it is used.
-       Problem reported by Petr Gajdos on 2017-01-25.
+2018-09-15  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-01-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+       * magick/render.c (TraceEllipse): Detect arithmetic overflow when
+       computing the number of points to allocate for an ellipse.  Fixes
+       oss-fuzz 10306 "graphicsmagick/coder_MVG_fuzzer:
+       Heap-buffer-overflow in TracePoint". (Credit to OSS-Fuzz)
 
-       * TclMagick/unix/m4/tcl.m4: Update tcl.m4 to TEA 3.10.  File
-       supplied by Massimo Manghi.
+2018-09-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-01-21  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+       * magick/attribute.c (GenerateEXIFAttribute): Eliminate undefined
+       shift.  Also right-sized involved data types.  Fixes oss-fuzz
+       10309 "graphicsmagick/coder_JPG_fuzzer: Undefined-shift in
+       Read32s". (Credit to OSS-Fuzz)
 
-       * coders/png.c: Added support for a proposed new PNG
-       chunk (exIf read-write, eXIf read-only) that is currently
-       being discussed on the png-mng-misc at lists.sourceforge.net
-       mailing list.
+2018-09-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-01-21  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+       * magick/render.c (DrawClipPath): Fix Coverity 319663 "Null
+       pointer dereferences".  Totally insignificant.
 
-       * coders/png.c: Added read_user_chunk_callback() function
-       and used it to implement a private PNG caNv (canvas) chunk
-       for remembering the original dimensions and offsets when an
-       image is cropped.  Previously we used the oFFs chunk for this
-       purpose, but this had potential conflicts with other applications
-       that also use the oFFs chunk.
+       * coders/wpg.c (ReadWPGImage): Mask/fix Coverity 319664 "Error
+       handling issues".
 
-2017-01-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+       * magick/attribute.c (FindEXIFAttribute): Change size types from
+       signed to unsigned and check for unsigned overflow.
+       (GenerateEXIFAttribute): Change size types from signed to unsigned
+       and check for unsigned overflow. Fixes oss-fuzz 10283
+       "graphicsmagick/coder_JPG_fuzzer: Integer-overflow in
+       GenerateEXIFAttribute". (Credit to OSS-Fuzz)
 
-       * TclMagick/Makefile.am (AM_DISTCHECK_CONFIGURE_FLAGS): Applied
-       patch by Massimo Manghi to set AM_DISTCHECK_CONFIGURE_FLAGS so
-       that 'make distcheck' remembers configuration options, and also to
-       uninstall pkgIndex.tcl.
+       * coders/sfw.c (ReadSFWImage): Enforce that file is read using the
+       JPEG reader. (Credit to OSS-Fuzz)
 
-       * magick/image.c (SetImageEx): Use PixelIterateMonoSet() for
-       possibly improved efficiency.
+       * coders/miff.c (ReadMIFFImage): Fix leak of 'values' buffer due
+       to change made yesterday.
 
-       * magick/pixel_iterator.c (PixelIterateMonoSet): New pixel
-       iterator intended for use when initializing image pixels, without
-       regard to existing values.
+       * coders/mpc.c (ReadMPCImage): Fix leak of 'values' buffer due to
+       change made yesterday.  Fixes oss-fuzz 10277
+       "graphicsmagick/coder_MPC_fuzzer: Direct-leak in
+       ReadMPCImage". (Credit to OSS-Fuzz)
 
-2017-01-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-09-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-       * Copyright.txt: Bump copyright years and rotate ChangeLog.
+       * coders/miff.c (ReadMIFFImage): Support legacy keyword
+       'color-profile' for ICC color profile as was used by ImageMagick
+       4.2.9.
+
+       * coders/mpc.c (ReadMPCImage): Require that first keyword/value be
+       id=MagickCache
+
+       * coders/miff.c (ReadMIFFImage): Require that first keyword/value
+       be id=ImageMagick.
+
+2018-09-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dcm.c (DCM_ReadElement): Add more size checks.
+
+       * coders/jnx.c (ExtractTileJPG): Enforce that JPEG tiles are read
+       by the JPEG coder.  Fixes oss-fuzz 10147
+       "graphicsmagick/coder_JNX_fuzzer: Use-of-uninitialized-value in
+       funcDCM_PhotometricInterpretation". (Credit to OSS-Fuzz)
+
+2018-09-10  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/wpg.c Zero fill raster error recovery.
+
+2018-08-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (ConvertPrimitiveToPath): Second attempt to
+       prevent heap write overflow of PathInfo array.  Fixes oss-fuzz
+       10096 "Heap-buffer-overflow in ConvertPrimitiveToPath". (Credit to
+       OSS-Fuzz)
+
+2018-08-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tiff.c ("QuantumTransferMode"): CIE Log images with an
+       alpha channel are not supported.  Fixes oss-fuzz 10013
+       "graphicsmagick/coder_TIFF_fuzzer: Use-of-uninitialized-value in
+       DisassociateAlphaRegion". (Credit to OSS-Fuzz)
+
+       * magick/render.c (DrawImage): SetImageAttribute() appends new
+       text to any existing value, leading to every increasing memory
+       consumption if the existing value is not deleted first by the
+       unwary.  Fixes oss-fuzz 9983 "graphicsmagick/coder_MVG_fuzzer:
+       Timeout in graphicsmagick_coder_MVG_fuzzer" and oss-fuzz 10016
+       "graphicsmagick/coder_MVG_fuzzer: Out-of-memory in
+       graphicsmagick_coder_MVG_fuzzer". (Credit to OSS-Fuzz)
+
+       * magick/utility.c (TranslateTextEx): Fix off-by-one in loop
+       bounds check which allowed a one-byte stack write overflow.  Fixes
+       oss-fuzz 10055 "graphicsmagick/coder_MVG_fuzzer:
+       Stack-buffer-overflow in TranslateTextEx". (Credit to OSS-Fuzz)
+
+       * magick/render.c (DrawImage): Be more precise about error
+       detection and reporting, and return from an error more quickly.
+       Also added MAX_DRAWIMAGE_RECURSION pre-processor definition to
+       allow adjusting the drawing recursion limit.  The drawing
+       recursion limit is still 100, which seems exceptionally generous.
+
+       * magick/constitute.c (WriteImage): Produce a more useful error
+       message if an encoding delegate is not available.
+
+       * magick/nt_base.h (isnan): Try adding a MSVC replacement for
+       missing isnan() function.  Not yet tested.
+
+2018-08-25  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/wpg.c This should fix intentional 64 bit file offset
+       overflow as depictedin OSS-fuzz-9936. Thanks to OSS-Fuzz.
+
+2018-08-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (ConvertPrimitiveToPath): Need to enlarge
+       PathInfo array allocation to avoid possible heap write overflow.
+       Fixes oss-fuzz 9651 "graphicsmagick/coder_MVG_fuzzer:
+       Heap-buffer-overflow in ConvertPrimitiveToPath". (Credit to
+       OSS-Fuzz)
+
+2018-08-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/mpc.c (ReadMPCImage): Insist that the format be
+       identified prior to any comment, and that there is only one
+       comment.
+
+       * coders/miff.c (ReadMIFFImage): Insist that the format be
+       identified prior to any comment, and that there is only one
+       comment.  Fixes oss-fuzz 9979 "graphicsmagick/coder_MIFF_fuzzer:
+       Timeout in graphicsmagick_coder_MIFF_fuzzer".  This is not a
+       serious issue, but the code runs slowly under UBSAN.  (Credit to
+       OSS-Fuzz)
+
+2018-08-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/utility.c (MagickAtoFChk): Add additional validation
+       checks for floating point values.  NAN and +/- INFINITY values
+       also map to 0.0. Fixes oss-fuzz 9630
+       "graphicsmagick/coder_MVG_fuzzer: Integer-overflow in
+       IsNexusInCore" and oss-fuzz 9612 "graphicsmagick/coder_MVG_fuzzer:
+       Integer-overflow in SetCacheNexus". (Credit to OSS-Fuzz)
+
+       * magick/render.c (DrawImage): Add missing error-reporting logic
+       to return immediately upon memory reallocation failure.  Apply
+       memory resource limits to PrimitiveInfo array allocation.  Fixes
+       oss-fuzz 9576 "graphicsmagick/coder_MVG_fuzzer: Null-dereference
+       READ in DrawImage", oss-fuzz 9593
+       "graphicsmagick/coder_MVG_fuzzer: Out-of-memory in
+       graphicsmagick_coder_MVG_fuzzer", oss-fuzz 9648
+       "graphicsmagick/coder_MVG_fuzzer: Unknown signal in
+       DrawImage". (Credit to OSS-Fuzz)
+
+2018-08-16  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coder/mat.c Explicitly reject non-seekable streams.
+
+2018-08-15  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coder/mat.c Correctly check GetBlobSize(image) even for zipstreams.
+
+2018-08-14  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c More aggresive data corruption checking.
+
+2018-08-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/xbm.c (XBMInteger): Limit the number of hex digits parsed
+       to avoid signed integer overflow.  Fixes oss-fuzz 9746
+       "graphicsmagick/coder_XBM_fuzzer: Undefined-shift in
+       XBMInteger". (Credit to OSS-Fuzz)
+
+2018-08-07  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Typecast difference to quantum.
+
+2018-08-05  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/mat.c (InsertComplexFloatRow): Avoid signed
+       overflow. Fixes oss-fuzz 9667 "graphicsmagick/coder_MAT_fuzzer:
+       Integer-overflow in InsertComplexFloatRow". (Credit to OSS-Fuzz)
+
+       * coders/xbm.c (ReadXBMImage): Add validations for row and column
+       dimensions.  Fixes oss-fuzz 9736 "graphicsmagick/coder_XBM_fuzzer:
+       Out-of-memory in graphicsmagick_coder_XBM_fuzzer". (Credit to
+       OSS-Fuzz)
+
+2018-08-04  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/wpg.c Add mechanism to approve embedded subformats in
+       WPG.  This should mute oss-fuzz 9559.  (Credit to OSS-Fuzz)
+
+2018-07-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/mvg.c (ReadMVGImage): Fix memory leak added on
+       2018-07-21.  Fixes oss-fuzz 9548 "graphicsmagick/coder_MVG_fuzzer:
+       Direct-leak in CloneDrawInfo". (Credit to OSS-Fuzz)
+
+2018-07-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/cineon.c (ReadCINEONImage): Fix SourceForge issue 571
+       "Unexpected hang on a crafted Cineon image" by detecting and
+       quitting on EOF appropriately, and verifying that file size is
+       sufficient for claimed pixel dimensions when possible.
+
+       * fuzzing/oss-fuzz-build.sh, fuzzing/dictionaries/MVG.dict: Added
+       MVG fuzzing dictionary by Alex Gaynor.
+
+2018-07-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/pixel_cache.c (SetNexus): For requests one pixel tall,
+       SetNexus() was wrongly using pixels in-core rather than using a
+       staging area for the case where the nexus rows extend beyond the
+       image raster boundary, leading to heap overflow.  This can happen
+       when virtual pixels outside the image bounds are accessed.  Fixes
+       oss-fuzz 9512 "graphicsmagick/graphicsmagick_coder_MVG_fuzzer:
+       Heap-buffer-overflow in AcquireCacheNexus". (Credit to OSS-Fuzz)
+
+       * magick/render.c (ExtractTokensBetweenPushPop):
+       ExtractTokensBetweenPushPop() needs to always return a valid
+       pointer into the primitive string.  Fixes oss-fuzz 9511
+       "graphicsmagick/graphicsmagick_coder_MVG_fuzzer: Null-dereference
+       READ in DrawImage". (Credit to OSS-Fuzz)
+       (DrawPolygonPrimitive): Fix leak of polygon set when object is
+       completely outside image.  Fixes oss-fuzz 9513
+       "graphicsmagick/graphicsmagick_coder_MVG_fuzzer: Direct-leak in
+       AllocateThreadViewDataSet". (Credit to OSS-Fuzz)
+
+2018-07-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/blob.c (FileToBlob): Use confirm access APIs to verify
+       that read access to this path is allowed by policy.  Check that
+       file is a regular file before proceeding to open and read from it.
+
+       * coders/mvg.c (ReadMVGImage): Don't allow MVG files to side-load
+       a file as the drawing primitive using '@' syntax.  Fixes oss-fuzz
+       9494 "graphicsmagick/coder_MVG_fuzzer: Sanitizer CHECK failure in
+       "((0)) != (0)" (0x0, 0x0)". (Credit to OSS-Fuzz)
+
+2018-07-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/mvg.c (ReadMVGImage): Don't assume that in-memory MVG
+       blob is a null-terminated C string. Fixes oss-fuzz 9469
+       "graphicsmagick/coder_MVG_fuzzer: Heap-buffer-overflow in
+       AllocateString". (Credit to OSS-Fuzz)
+
+2018-07-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/miff.c (ReadMIFFImage): Detect EOF when reading using
+       ReadBlobZC() and avoid subsequent heap read overflow.  Fixes
+       oss-fuzz 9357 "graphicsmagick/coder_MIFF_fuzzer:
+       Heap-buffer-overflow in ImportRGBQuantumType". (Credit to
+       OSS-Fuzz)
+
+2018-07-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * fuzzing/oss-fuzz-build.sh (CFLAGS): Try disabling SIMD
+       instructions in libjpeg-turbo build.
+
+2018-07-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (WriteOnePNGImage): Free png_pixels as soon as
+       possible.  This might help with oss-fuzz 9334
+       "graphicsmagick/coder_PNG8_fuzzer: Direct-leak in
+       WriteOnePNGImage", which we have yet to reproduce.  It is not
+       clear if png_pixels is being clobbered by longjmp or if something
+       else is going on.
+
+2018-06-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/jpeg.c (ReadJPEGImage): Provide a memory resource limit
+       (of 1/5th the memory resource limit for Graphicsmagick) to libjpeg
+       to limit how much memory it might consume for itself while reading
+       a file.  Fixes oss-fuzz 9096 "graphicsmagick/coder_JPEG_fuzzer:
+       Timeout in graphicsmagick_coder_JPEG_fuzzer".  (Credit to
+       OSS-Fuzz)
+       (ReadJPEGImage): Make sure that JPEG pixels array is initialized
+       in case libjpeg fails to completely initialize it.  May fix
+       oss-fuzz 9115 "graphicsmagick/coder_JPEG_fuzzer:
+       Use-of-uninitialized-value in ReadJPEGImage".  We are not sure
+       since the problem was not reproduced.  (Credit to OSS-Fuzz)
+
+2018-06-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * version.sh: Update library versioning for 1.3.30 release.
+
+       * NEWS.txt: Update news for 1.3.30 release.
+
+2018-06-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dpx.c (ReadDPXImage): Report exception on EOF file
+       reading DPX pixel data. Fixes oss-fuzz 8104
+       "graphicsmagick/coder_DPX_fuzzer: Use-of-uninitialized-value in
+       WriteDPXImage", oss-fuzz 8297 "graphicsmagick/enhance_fuzzer:
+       Use-of-uninitialized-value in EnhanceImage", and oss-fuzz 8133
+       "graphicsmagick/coder_DPX_fuzzer: Use-of-uninitialized-value in
+       RGBTransformPackets". (Credit to OSS-Fuzz)
+
+2018-06-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/cmyk.c (ReadCMYKImage): Free scanline buffer in error
+       path. Fixes SourceForge issue #567 "small memory leak in rgb.c,
+       gray.c and cmyk.c" reported by Petr Gajdos.
+
+       * coders/gray.c (ReadGRAYImage): Free scanline buffer in error
+       path. Fixes SourceForge issue #567 "small memory leak in rgb.c,
+       gray.c and cmyk.c" reported by Petr Gajdos.
+
+       * coders/rgb.c (ReadRGBImage): Free scanline buffer in error
+       path. Fixes SourceForge issue #567 "small memory leak in rgb.c,
+       gray.c and cmyk.c" reported by Petr Gajdos.
+
+       * coders/jpeg.c (ReadJPEGImage): Avoid memory leak of profile
+       buffer when longjmp-based exception is thrown while reading a
+       profile. Fixes oss-fuzz 8957 "graphicsmagick/enhance_fuzzer:
+       Direct-leak in ReadGenericProfile". (Credit to OSS-Fuzz)
+
+2018-06-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/xcf.c (load_level): Make sure to free 'tile_image' before
+       returning exception.  Fixes oss-fuzz 8935
+       "graphicsmagick/coder_XCF_fuzzer: Indirect-leak in
+       CloneImage". (Credit to OSS-Fuzz)
+
+       * coders/jpeg.c (ReadJPEGImage): Allow three warnings of any given
+       type before promoting the next warning of the same type to a hard
+       error.  The warning limit may be adjusted by the user using
+       -define jpeg:max-warnings=<value>.  Fixes oss-fuzz 8704
+       "graphicsmagick/coder_JPG_fuzzer: Out-of-memory in
+       graphicsmagick_coder_JPG_fuzzer". (Credit to OSS-Fuzz)
+
+       * coders/png.c (ReadPNGImage): Detect EOF when reading
+       magic_number.  Fixes oss-fuzz 8944
+       "graphicsmagick/coder_PNG_fuzzer: Use-of-uninitialized-value in
+       ReadPNGImage".  (Credit to OSS-Fuzz)
+       (ReadPNGImage, ReadJNGImage): Makes sure that return value of
+       ReadBlob() is always checked to detect EOF.
+
+2018-06-16  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tiff.c (ReadTIFFImage): Re-structure exception reporting
+       so that QuantumTransferMode() exceptions thrown for
+       PLANARCONFIG_SEPARATE images are handled immediately.  Fixes
+       oss-fuzz 8896 "graphicsmagick/coder_BIGTIFF_fuzzer:
+       Use-of-uninitialized-value in DisassociateAlphaRegion". (Credit to
+       OSS-Fuzz)
+       (ReadTIFFImage): tsize_t is a signed type so be prepared for
+       unexpected negative values produced by libtiff size functions.
+       Fixes oss-fuzz 8934 "graphicsmagick/coder_TIFF_fuzzer: Sanitizer
+       CHECK failure in "((0)) != (0)" (0x0, 0x0)". (Credit to OSS-Fuzz)
+
+2018-06-16  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/wpg.c Fix oss-fuzz 7735 "graphicsmagick/coder_WPG_fuzzer:
+       Use-of-uninitialized-value in ReadWPGImage".  (Credit to OSS-Fuzz)
+
+2018-06-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadMNGImage): ENDL chunk must be at least one
+       byte in size. Fixes oss-fuzz 8832
+       "graphicsmagick/coder_MNG_fuzzer: Null-dereference READ in
+       ReadMNGImage". (Credit to OSS-Fuzz)
+       (ReadMNGImage): Length of DISC chunk must be evenly divisible by
+       2.  Fixes oss-fuzz 8834 "graphicsmagick/coder_MNG_fuzzer:
+       Heap-buffer-overflow in ReadMNGImage". (Credit to OSS-Fuzz)
+
+2018-06-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/mpc.c (ReadMPCImage): Detect end of file while reading
+       image directory.  Similar to MIFF fixes for ImageMagick
+       CVE-2017-18272.
+       (RegisterMPCImage): Require seekable stream since MPC is strictly
+       a file-based format and so GetBlobSize() is assured to work.
+       Similar to MIFF behavior.  Claimed to be part of the resolution
+       for ImageMagick CVE CVE-2017-11449. Suggested by Petr Gajdos via
+       email on January 3, 2018.
+
+2018-06-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/miff.c (ReadMIFFImage): Detect end of file while reading
+       image directory. Fixes SourceForge issue 565 "ImageMagick
+       CVE-2017-18272 applies to GraphicsMagick".  Thanks to Petr Gajdos
+       for reporting this issue to us.
+
+       * magick/import.c (ImportViewPixelArea): Use appropriate
+       bits_per_sample validations for FloatQuantumSampleType. Fixes
+       oss-fuzz 8780 "graphicsmagick/coder_PTIF_fuzzer:
+       Use-of-uninitialized-value in HorizontalFilter". (Credit to
+       OSS-Fuzz)
+
+2018-06-09  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c More than 4GiB are not supported in MAT!
+
+2018-06-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/mat.c (ReadMATImage): Add casts to avoid arithmetic
+       overflow when computing size and offsets.  Fixes oss-fuzz 8801
+       "graphicsmagick/coder_MAT_fuzzer: Timeout in
+       graphicsmagick_coder_MAT_fuzzer". (Credit to OSS-Fuzz)
+
+       * magick/blob.c (ReadBlobLSBDoubles, ReadBlobMSBDoubles): Only
+       byte-swap doubles or test doubles for NAN if we have read enough
+       bytes for at least one double value.
+       (ReadBlob): Add an assertion to enforce that ReadBlob() will never
+       report reading more bytes than requested due to some
+       implementation issue.
+
+2018-06-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/blob.c (ReadBlob, WriteBlob): gzread(), BZ2_bzread(),
+       gzwrite(), BZ2_bzwrite() return type 'int' rather than 'size_t'
+       like their stdio equivalents.  Use correct signed type to avoid
+       returning a negative value into an unsigned type, forming a huge
+       positive value.  Fixes oss-fuzz 8600
+       "graphicsmagick/coder_MAT_fuzzer: Heap-buffer-overflow in
+       ReadBlobLSBDoubles". (Credit to OSS-Fuzz)
+
+2018-06-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (png_read_raw_profile): Try to shore up parsing of
+       raw profile reading to avoid heap read overruns.  Fixes oss-fuzz
+       8763 "graphicsmagick/coder_PNG32_fuzzer: Heap-buffer-overflow in
+       png_read_raw_profile". (Credit to OSS-Fuzz)
+
+2018-06-07  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Reduce stack usage for 64 bit architecture.
+
+2018-06-06  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/wpg.c Check return values of SeekBlob for more safety.
+
+2018-06-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJNGImage): Use DestroyImageList() rather
+       than DestroyImage() on returned Image from supposed read of JPEG
+       data, in case multiple frames were unexpectedly returned.  Also
+       add "JPEG:" prefix to filename when reading from temporary file to
+       force that it can only be read as a JPEG file, disabling format
+       auto-detection based on file header.  Fixes oss-fuzz 8755
+       "graphicsmagick/coder_JNG_fuzzer: Indirect-leak in
+       AllocateImage". (Credit to OSS-Fuzz)
+
+2018-06-05  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/blob.c (EOFBlob): Implement EOF detection for ZipStream.
+       Does some archaic zlib not provide gzeof()?  Fixes oss-fuzz 8550
+       "graphicsmagick/coder_MAT_fuzzer: Timeout in
+       graphicsmagick_coder_MAT_fuzzer". (Credit to OSS-Fuzz)
+
+2018-06-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOnePNGImage): Skip adding empty raw profile.
+       Fixes oss-fuzz "graphicsmagick/coder_PNG_fuzzer:
+       Heap-buffer-overflow in png_read_raw_profile". (Credit to
+       OSS-Fuzz)
+
+2018-06-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * NEWS.txt: Update NEWS with latest changes.
+
+       * coders/dcm.c (DCM_ReadRGBImage): Force the image to DirectClass
+       to avoid later use of uninitialized indexes.  Fixes oss-fuzz 8602
+       "graphicsmagick/coder_DCM_fuzzer: Use-of-uninitialized-value in
+       DCM_PostRescaleImage". (Credit to OSS-Fuzz)
+       (DCM_ReadPlanarRGBImage): Force the image to DirectClass to avoid
+       later use of uninitialized indexes.
+
+       * coders/png.c (ReadMNGImage): Free chunk memory in error
+       reporting path to avoid leak.  Fixes oss-fuzz 8721
+       "graphicsmagick/coder_MNG_fuzzer: Direct-leak in
+       ReadMNGImage". (Credit to OSS-Fuzz)
+
+2018-06-02  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/constitute.c (ReadImage): Assure that an error exception
+       is thrown if coder returns null without properly reporting an
+       exception.
+
+       * magick/blob.c (BlobToImage): Assure that an error exception is
+       thrown if coder returns null without properly reporting an
+       exception.
+
+       * coders/png.c (ReadMNGImage): Disable mystery "linked list is
+       corrupted" code.  Assure that exceptions are reported to the
+       correct place so they are not lost.  Fixes oss-fuzz 8710
+       "graphicsmagick/coder_MNG_fuzzer: Indirect-leak in
+       AllocateImage". (Credit to OSS-Fuzz)
+
+       * coders/tiff.c (ReadTIFFImage): Initialize allocated scanline,
+       strip, or tile to zero in order to avoid complaint about use of
+       uninitialized data if libtiff fails to write all the bytes.  Fixes
+       oss-fuzz 8551 "graphicsmagick/coder_TIFF_fuzzer:
+       Use-of-uninitialized-value in ImportGrayQuantumType". (Credit to
+       OSS-Fuzz)
+
+       * magick/annotate.c (RenderFreetype): Throw an exception if
+       DrawInfo font is null.  Should fix oss-fuzz 8557
+       "graphicsmagick/coder_PCD_fuzzer: Unknown signal in
+       RenderFreetype" and may fix oss-fuzz 8544
+       "graphicsmagick/coder_PCD_fuzzer: Null-dereference READ in
+       RenderFreetype". (Credit to OSS-Fuzz)
+
+       * coders/jpeg.c (ReadGenericProfile): Add/improve tracing for
+       profile size and when JPEG header is being read.
+
+2018-06-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJNGImage): Report a useful exception for
+       the case when the JNG file fails to provide the necessary image
+       chunks to allocate the color image.  Inspired by oss-fuzz 8666
+       "graphicsmagick/coder_JNG_fuzzer: ASSERT: data != (const char *)
+       NULL" although the reported issue was not reproduced.
+
+2018-05-31  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadMNGImage): Fix off-by-one in length validation
+       for TERM chunk which allowed one byte heap read overflow.  Fixes
+       oss-fuzz 8615 "graphicsmagick/coder_MNG_fuzzer:
+       Heap-buffer-overflow in mng_get_long". (Credit to OSS-Fuzz)
+       (ReadMNGImage): Fix leak of MngInfo in error reporting path.
+       Fixes oss-fuzz 8604 "graphicsmagick/coder_MNG_fuzzer: Direct-leak
+       in ReadMNGImage". (Credit to OSS-Fuzz)
+       (ReadMNGImage): Verify that claimed chunk size does not exceed
+       input size.  Fixes oss-fuzz 8564 "graphicsmagick/coder_MNG_fuzzer:
+       Out-of-memory in graphicsmagick_coder_MNG_fuzzer". (Credit to
+       OSS-Fuzz)
+
+       * coders/tiff.c (ReadTIFFImage): Reject files with excessive
+       samples-per-pixel or extra-samples. Avoids potential issues
+       observed in oss-fuzz 8634 "graphicsmagick/coder_BIGTIFF_fuzzer:
+       Undefined-shift in ImportAlphaQuantumType". (Credit to OSS-Fuzz)
+
+2018-05-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadMNGImage): Assure that object id index is
+       always less than MNG_MAX_OBJECTS to avoid overflow.  Fixes
+       oss-fuzz 8596 "graphicsmagick/coder_MNG_fuzzer:
+       Index-out-of-bounds in ReadMNGImage" and likely other issues yet
+       to be reported. (Credit to OSS-Fuzz)
+
+2018-05-30  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (CompareEdges): Per ticket #562,
+       function CompareEdges() did not conform to the qsort()
+       requirement that if CompareEdges(edge0,edge1) returns
+       -1 (i.e., edge0 "less than" edge1), then
+       CompareEdges(edge1,edge0) should return 1 (edge1
+       "greater than" edge0).  This has been fixed.
+
+2018-05-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJNGImage): Deal with JDAA JNG chunk with
+       length zero.  Fixes oss-fuzz 8562
+       "graphicsmagick/coder_JNG_fuzzer: ASSERT: data != (const char *)
+       NULL". (Credit to OSS-Fuzz)
+
+       * coders/tiff.c (ReadTIFFImage): Check that the bits-per-sample is
+       supported by the implementation before attempting to decode the
+       image. Fixes oss-fuzz 8554 "graphicsmagick/coder_BIGTIFF_fuzzer:
+       Undefined-shift in MagickBitStreamMSBWrite". (Credit to OSS-Fuzz)
+
+       * coders/png.c (ReadMNGImage): Eliminate use of uninitialized
+       header magic data by checking for EOF first.  Fixes oss-fuzz 8597
+       "graphicsmagick/coder_MNG_fuzzer: Use-of-uninitialized-value in
+       ReadMNGImage". (Credit to OSS-Fuzz)
+
+2018-05-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * fuzzing/oss-fuzz-build.sh: More fixes based on what is observed
+       in oss-fuzz build log.
+
+2018-05-24  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/jnx.c The attribute should belong to only one scene and
+       not to whole image list.
+
+2018-05-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * fuzzing/oss-fuzz-build.sh: Changes to add CPPFLAGS to configure
+       executions to hopefully get oss-fuzz build closer to success.
+
+2018-05-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * PerlMagick/t/jpeg/read.t: Add a JNX reader test case.
+
+       * coders/jnx.c (ReadJNXImage): JNX image depth should be 8.
+
+       * fuzzing/oss-fuzz-build.sh: Apply patch from Alex Gaynor to
+       switch libpng to autotools build system, as well as configure
+       GraphicsMagick with '--with-quantum-depth=16'.
+
+2018-05-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tiff.c (ReadTIFFImage): Validate tile memory requests for
+       the TIFFReadRGBATile() case in the same way as the TIFFReadTile()
+       case.  Fixes oss-fuzz 8434 "graphicsmagick/coder_BIGTIFF_fuzzer:
+       Out-of-memory in graphicsmagick_coder_BIGTIFF_fuzzer". (Credit to
+       OSS-Fuzz)
+
+2018-05-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tile.c (ReadTILEImage): Remove any existing size request
+       when while image to tile.  This avoids size being used for both
+       the input image size and the tile image size.  Fixes SourceForge
+       issue #563 "tile:<image> appears to blow image up by 100% before
+       applying tiling".
+
+2018-05-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * fuzzing/oss-fuzz-build.sh: Patch from Paul Kehrer to disable
+       libpng test programs and binaries while building libpng in support
+       of oss-fuzz testing.
+
+       * coders/dcm.c (DCM_ReadGrayscaleImage): If a palette was
+       provided, the image may be in PseudoClass but we need DirectClass
+       for gray image when GRAYSCALE_USES_PALETTE is not defined.  Fixes
+       oss-fuzz 7550 "graphicsmagick/coder_DCM_fuzzer:
+       Use-of-uninitialized-value in SyncImageCallBack". (Credit to
+       OSS-Fuzz)
+       (ReadDCMImage): Restore use of DCM_PostRescaleImage() in order to
+       obtain suitably scaled DICOM again.  Hopefully it is more robust
+       now.
+       (DCM_ReadPaletteImage): Assure that DirectClass pixels are
+       initialized.
+
+2018-05-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tiff.c (ReadTIFFImage): Remove strange addition of
+       image->columns to pixel buffer offsets which now causes a heap
+       overflow since the buffer has been right-sized.  Perhaps the extra
+       offset plus the over-sized allocation was some attempt to avoid
+       buffer over/underflows due to bugs in libtiff. Fixes oss-fuzz 8384
+       "graphicsmagick/coder_BIGTIFF_fuzzer: Heap-buffer-overflow in
+       put1bitbwtile" which is described to be a regression. (Credit to
+       OSS-Fuzz)
+
+       * magick/render.c (DrawImage): Fix wrong range checks which caused
+       spurious "Parsing of SVG images fail with "Non-conforming drawing
+       primitive definition (push)" failure.  Fixes SourceForge issue 561
+       "Parsing of SVG images fail with "Non-conforming drawing primitive
+       definition (push)"" which is due to problems caused by the fix for
+       SourceForge issue 517.
+
+       * coders/tiff.c (WritePTIFImage): Use '-define
+       ptif:minimum-geometry=<geometry>' to specify the smallest
+       subresolution frame which is produced by the PTIF (Pyramid TIFF)
+       writer.
+
+2018-05-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tiff.c (WritePTIFImage): Allow 1x1 input image to be
+       supported.
+
+       * coders/png.c (ReadOneJNGImage): Unconditionally free JDAT chunk
+       memory.  Fixes oss-fuzz 8366 "graphicsmagick/coder_JNG_fuzzer:
+       Direct-leak in ReadOneJNGImage". (Credit to OSS-Fuzz)
+
+       * coders/tiff.c (WritePTIFImage): Fix leak of pyramid Image list
+       if ResizeImage() fails.  Fixes oss-fuzz 8364
+       "graphicsmagick/coder_PTIF_fuzzer: Indirect-leak in
+       CloneImage". (Credit to OSS-Fuzz)
+
+2018-05-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tiff.c (WriteTIFFImage): Add and use
+       ThrowTIFFWriterException() macro to consistently clean-up when
+       throwing writer exception.  May fix oss-fuzz 8321
+       "graphicsmagick/coder_EPT_fuzzer: Direct-leak in
+       TIFFClientOpen". (Credit to OSS-Fuzz)
+       (ReadTIFFImage): Add and use ThrowTIFFReaderException() macro to
+       consistently clean-up when throwing reader exception.
+
+2018-05-16  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/alpha_composite.h (AlphaCompositePixel): The
+       macro definition for MagickAlphaCompositeQuantum in
+       alpha_composite.h computes an expression of the form:
+
+       a * b + c * d * e
+
+       Code in function AlphaCompositePixel() (also in
+       alpha_composite.h) multiplies the result of this macro
+       by variable "delta" as follows:
+
+       delta * a * b + c * d * e
+
+       However, the intended result is actually:
+
+       delta * ( a * b + c * d * e )
+
+       The macro definition has been modified to enclose the
+       entire expression in parentheses.
+
+       The effects of this bug were particularly evident at the
+       boundary between a stroked polygon and a transparent
+       black region. More generally, an incorrect composited
+       pixel value was being computed by AlphaCompositePixel()
+       whenever the output alpha value was not 100% opaque.
+
+2018-05-16  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * tests/rwblob.tap: Add a test for PTIF format.
+
+       * coders/tiff.c (WritePTIFImage): Fix Image blob referencing in
+       order to avoid double-free when writing PTIF to memory BLOB. Fixes
+       oss-fuzz 8280 "graphicsmagick/coder_PTIF_fuzzer: Heap-double-free
+       in Magick::BlobRef::~BlobRef". (Credit to OSS-Fuzz)
+
+2018-05-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tiff.c (WriteTIFFImage): Use libtiff's
+       TIFFDefaultStripSize() function rather than an old porting macro
+       required by some defunct libtiff version.  Expected to fix
+       oss-fuzz 8248 "graphicsmagick/coder_EPT_fuzzer:
+       Floating-point-exception in WriteTIFFImage". (Credit to OSS-Fuzz)
+
+2018-05-13  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Fix potentional leak when compressed object is
+       corrupted. Fixes oss-fuzz 8251 (Credit to OSS-Fuzz)
+
+2018-05-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tiff.c (ReadTIFFImage): Fix leak of Image when
+       TIFFReadRGBAImage() reports failure.  Also harden buffer
+       allocation calculation.  Fixes oss-fuzz 8275
+       "graphicsmagick/coder_BIGTIFF_fuzzer: Indirect-leak in
+       AllocateImage". (Credit to OSS-Fuzz)
+
+       * coders/ept.c (ReadEPTImage): Add validations of 'count' and
+       'filesize' read from EPT file. In response to oss-fuzz 8248
+       "graphicsmagick/coder_EPT_fuzzer: Floating-point-exception in
+       WriteTIFFImage" but we are unable to recreate the oss-fuzz issue
+       since the EPT reader already immediately reports an EOF exception.
+
+2018-05-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * fuzzing/oss-fuzz-build.sh: Apply SourceForge patch #57 "Add
+       fuzzing support for jpeg + freetype delegates" by Alex Gaynor.
+
+       * coders/png.c (read_user_chunk_callback): Fix memory leak and use
+       of uninitialized memory when handling eXIf chunk. Fixes oss-fuzz
+       8247 "graphicsmagick/coder_PNG24_fuzzer: Direct-leak in
+       png_malloc". (Credit to OSS-Fuzz)
+
+2018-05-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * fuzzing/oss-fuzz-build.sh: Apply SourceForge patch #56 "Use a
+       few delegate libraries in fuzzing" by Alex Gaynor.
+
+2018-05-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * tests/rwfile.tap: MIFF zip and bzip compression tests do not
+       fail if zlib and bzlib are not available because the compression
+       request is silently changed to no compression.
 
+2018-05-07  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
 
+       * magick/render.c (DrawImage, InsertAttributeIntoInputStream):
+       For a reference such as 'class="classname"', the "classname"
+       is now allowed to be undefined.
+
+       * coders.svg.c (ProcessStyleClassDefs): Class definitions
+       defined within a <style> block may now be empty.
+
+       * These relaxed conditions are not specifically called out in
+       the SVG spec as being either acceptable or unacceptable, but
+       other SVG renderers (e.g., Chrome) handle them this way. These
+       changes do not resolve, but are related to, ticket #307.
+
+2018-05-05  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * utilities/Makefile.am (utilities/tests/montage.log): Fix
+       dependency rule so that effects.tap is fully executed before
+       execution of montage.tap starts.
+
+2018-05-04  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (DrawImage, TraceXXX): The PrimitiveInfo
+       array used to store points generated by TraceEllipse(), the
+       other TraceXXX() functions, and DrawImage() was not always
+       being expanded when needed, resulting in writes beyond the
+       end of the currently allocated storage. To fix this problem,
+       a new data structure PrimitiveInfoMgr, and an associated
+       function, PrimtiveInfoRealloc(), were written to handle
+       expanding the PrimitiveInfo array as needed. DrawImage() and
+       the TraceXXX() functions were modified to prevent the out of
+       bounds writes to memory. This fixes ticket #516.
+
+2018-05-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJNGImage): Add more JNG chunk
+       validations. Fixes an issue reported by "Trace Probe" via a
+       follow-up post to SourceForge issue 437 "assertion failure in
+       WriteBlob", although the issue described was not reproduced.
+
+       * coders/meta.c (ReadMETAImage): Detect and report 8BIMTEXT and
+       8BIMWTEXT decoding problems.  Fixes oss-fuzz 8125
+       "graphicsmagick/coder_8BIMTEXT_fuzzer: Use-of-uninitialized-value
+       in format8BIM". (Credit to OSS-Fuzz)
+
+2018-05-02  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (TraceStrokePolygon): Excessively
+       large values of stroke-width were cascading through
+       other computations, causing the function to write beyond
+       the end of it's array of points when the stroke-linejoin
+       attribute value was "round". Code was added to reallocate
+       the array of points as needed, and to limit the size of
+       stroke-width (for computational purposes) to no more than
+       approximately twice the diagonal size of the output image.
+       Fixes ticket #515.
+
+       * The same limit on stroke-width was applied to all other
+       instances of the same computation in render.c.
+
+2018-05-01  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * This change set fixes ticket #471.
+
+       * magick/render.c (DrawImage): Polylines with fewer
+       than two points were being flagged as an error. The
+       SVG spec has no such restriction (fixed).
+
+       * coders/svg.c (SVGStartElement) Inner <svg> elements
+       could modify the output image dimensions if a geometry
+       string was supplied. Now the output image dimensions
+       are determined by the outermost <svg> only.
+
+2018-05-01  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (TraceEllipse, TraceRectangle,
+       TraceRoundRectangle): Per the SVG spec, rectangles and
+       round rectangles having a width or height of zero are
+       not rendered. Also per the spec, ellipses having an x
+       or y radius of zero are not rendered.  Fixes ticket #457.
+
+2018-04-30  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.h, (PrimitiveInfo), magick/render.c: Added
+       member "flags" to PrimitiveInfo to support indicating closed
+       shapes (e.g., rectangle, circle, path closed using 'z' or 'Z').
+       Updated code in render.c (functions TraceXXX) to indicate
+       closed shapes.  This replaces the previous policy of detecing
+       closed shapes by comparing the first and last points to see if
+       they are identical (within MagickEpsilon). The old policy
+       prevented open subpaths with the same first and last point from
+       being rendered properly (per the SVG spec) when round or square
+       endcaps were enabled.  Part of the fix for ticket #322.
+
+       * magick/render.c (ConvertPrimitiveToPath): Modified duplicate
+       point elimination code so that the first and last points of
+       a subpath are always preserved.  Consequences: (1) Allows
+       for the correct rendering of the sequence "move x1 y1 line
+       x1 y1" with round or square endcaps.  Part of the fix for
+       ticket #322. (2) Fixes a bug in which eliminating the last
+       point as a duplicate caused a closed shape to no longer be
+       closed. This would manifest itself, for example, as a small
+       "nub" on the boundary of a filled circle.
+
+       * magick/render.c (GetPixelOpacity): Fixed a bug in the
+       code that computed the distance between a point and a
+       segment (polygon edge).  Prior to this fix, for zero length
+       segments this code would generate a divide-by-zero and
+       incorrect output. Part of the fix for ticket #322.
+
+       * magick/render.c (DrawPolygonPrimitive): Polygons/paths with
+       zero or one points are no longer rendered per the SVG spec.
+
+       * magick/render.c (DrawStrokePolygon): Per the SVG spec, a
+       polygon consisting of a single move-to command is not stroked.
+
+       * magick/render.c (TracePath): Per the SVG spec, if the
+       endpoints (x1, y1) and (x2, y2) of an arc subpath are identical,
+       then this is equivalent to omitting the elliptical arc segment
+       entirely.  For rendering purposes the zero length arc is
+       treated like a zero length "line to" command to the current
+       point.
+
+       * magick/render.c (TraceStrokePolygon): Added code to detect
+       zero length open subpaths and return a stroked polygon containing
+       no points when round or square endcaps are not enabled.  This
+       satisfies the SVG spec requirement that zero length subpaths are
+       only stroked if the 'stroke-linecap' property has a value of
+       round or square.
+
+       * magick/render.c (TracePath): Fixed a bug in which if a "move to"
+       command was followed by additional pairs of points, indicating
+       implied "line to" commands, each point was added twice.
+
+2018-04-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pcx.c (ReadPCXImage): Colormap from PCX header is only
+       used if colors <= 16. Determination of DirectClass image was
+       wrong.  Fixes oss-fuzz 8093 "graphicsmagick/coder_PCX_fuzzer:
+       Use-of-uninitialized-value in IsMonochromeImage". (Credit to
+       OSS-Fuzz)
+
+2018-04-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * version.sh: Updates to prepare for the 1.3.29 release.
+
+       * coders/pict.c (DecodeImage): Assure that scanline is initialized
+       to avoid use of uninitialized data.  Fixes oss-fuzz 8063
+       "graphicsmagick/coder_WPG_fuzzer: Use-of-uninitialized-value in
+       ReadPICTImage". (Credit to OSS-Fuzz)
+
+       * coders/dpx.c (ReadDPXImage): Assure that NULL pixels is not
+       used.  Fixes oss-fuzz 8078 "graphicsmagick/coder_DPX_fuzzer:
+       Null-dereference WRITE in ReadDPXImage". (Credit to OSS-Fuzz)
+
+       * NEWS.txt: Update NEWS file with information about changes since
+       last release.
+
+2018-04-28  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dib.c (ReadDIBImage): Disable EOF tests for "ICODIB"
+       subformat due to icon file provided by SourceForge issue #557
+       "ErrorCorruptImage: Magick: Unexpected end-of-file ()" where an
+       EOF error was reported due to no mask data being supplied.
+
+       * coders/png.c (ReadOneJNGImage): The embedded JPEG image is
+       required to have the same dimensions as the JNG image as provided
+       by JHDR.  Fixes SourceForge bug 555 "heap-buffer-overflow in
+       AcquireCacheNexus when processing jng file".  It is likely that
+       this issue is precipitated by using 'montage' which seems to set a
+       default non-zero image size.
+       (ReadMNGImage): By default limit the maximum loops specifiable by
+       the MNG LOOP chunk to 512 loops, but allow this to be modified by
+       '-define mng:maximum-loops=value'.  Also assure that the value is
+       in the range of 0-2147483647 as per the MNG specification.  This
+       is to address the denial of service issue described by
+       CVE-2018-10177.  This problem was reported to us by Petr Gajdos
+       via email on Fri, 20 Apr 2018.
+
+       * coders/dpx.c (ReadDPXImage): Move misplaced channel validation
+       code.  Fixes oss-fuzz 8041 "graphicsmagick/coder_DPX_fuzzer:
+       Use-of-uninitialized-value in WriteDPXImage" and oss-fuzz 8055
+       "graphicsmagick/enhance_fuzzer: Use-of-uninitialized-value in
+       EnhanceImage". (Credit to OSS-Fuzz)
+
+2018-04-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/xpm.c (StringToListMod): Algorithm fixes to fix use of
+       uninitialized data.  Fixes oss-fuzz 8046
+       "graphicsmagick/coder_XPM_fuzzer: Use-of-uninitialized-value in
+       StringToListMod". (Credit to OSS-Fuzz)
+
+2018-04-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/xpm.c (ReadXPMImage): Reduce memory consumption further.
+       Hopefully fixes oss-fuzz 8013 "graphicsmagick/coder_XPM_fuzzer:
+       Out-of-memory in graphicsmagick_coder_XPM_fuzzer". (Credit to
+       OSS-Fuzz)
+
+       * magick/utility.c (StringToList): Only allocate the memory
+       required when converting string to an ASCII list.  May or may not
+       fix oss-fuzz 8013 "graphicsmagick/coder_XPM_fuzzer: Out-of-memory
+       in graphicsmagick_coder_XPM_fuzzer". (Credit to OSS-Fuzz)
+
+2018-04-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/bmp.c (ReadBMPImage): Fix benign use of uninitialized
+       data when testing header magick.  Fixes oss-fuzz 7980
+       "graphicsmagick/coder_BMP_fuzzer: Use-of-uninitialized-value in
+       LocaleNCompare". (Credit to OSS-Fuzz)
+
+       * coders/dpx.c (ReadDPXImage): ColorDifferenceCbCr does require
+       even image width. Fixes oss-fuzz 7966
+       "graphicsmagick/coder_DPX_fuzzer: Unknown signal in
+       TentUpsampleChroma". (Credit to OSS-Fuzz)
+
+2018-04-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dpx.c (ReadDPXImage): ColorDifferenceCbCr element
+       requires two samples/pixel, not one. Fixes oss-fuzz 7951
+       "graphicsmagick/coder_DPX_fuzzer: Heap-buffer-overflow in
+       ReadDPXImage". (Credit to OSS-Fuzz)
+
+2018-04-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pdb.c (ReadPDBImage): Assure that pixels buffer is
+       initialized.  Fixes oss-fuzz 7937
+       "graphicsmagick/coder_PDB_fuzzer: Use-of-uninitialized-value in
+       ReadPDBImage". (Credit to OSS-Fuzz)
+
+       * coders/mvg.c (ReadMVGImage): Assure that MVG viewbox parameters
+       were supplied.  Fixes oss-fuzz 7936
+       "graphicsmagick/coder_MVG_fuzzer: Use-of-uninitialized-value in
+       ReadMVGImage". (Credit to OSS-Fuzz)
+
+       * coders/dpx.c (ReadDPXImage): Element descriptors CbYCrY422 and
+       CbYACrYA4224 require that the image width be evenly divisible by 2
+       so enforce that.  Fixes oss-fuzz 7935
+       "graphicsmagick/coder_DPX_fuzzer: Heap-buffer-overflow in
+       ReadDPXImage". (Credit to OSS-Fuzz)
+
+2018-04-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dpx.c (ReadDPXImage): Reject DPX files which claim to use
+       signed data.  Fixes oss-fuzz 7758
+       "graphicsmagick/coder_DPX_fuzzer: Use-of-uninitialized-value in
+       WriteDPXImage". (Credit to OSS-Fuzz)
+       (ReadDPXImage): Validate that the image elements do update all of
+       the channels, including the alpha channel.  Now report an error if
+       a color channel is missing.  Fixes oss-fuzz 7758
+       "graphicsmagick/coder_DPX_fuzzer: Use-of-uninitialized-value in
+       WriteDPXImage".
+
+       * coders/gif.c (DecodeImage): Finally fix oss-fuzz 7732
+       "graphicsmagick/coder_GIF_fuzzer: Heap-buffer-overflow in
+       DecodeImage" which was not actually fixed with previous
+       changes. (Credit to OSS-Fuzz)
+
+2018-04-21  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/topol.c Emit error when tile storage overflows image data;
+        fixes oss-fuzz 7769 thanks to oss-fuzz.
+
+2018-04-20  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (ConvertPrimitiveToPath):  Fixed a bug
+       in which SVG paths containing multiple open subpaths were
+       not being processed correctly, resulting in incorrect
+       output.  This fixes ticket #94.
+
+2018-04-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/gif.c (DecodeImage): Fix use of uninitialized memory
+       during error condition in decoder. Fixes oss-fuzz 7732
+       "graphicsmagick/coder_GIF_fuzzer: Heap-buffer-overflow in
+       DecodeImage". (Credit to OSS-Fuzz)
+
+       * coders/txt.c (ReadTXTImage): Assure that all image pixels are
+       initialized to black.
+
+       * Magick++/demo/zoom.cpp (main): Add a -read-blob option to read
+       input file into a Blob so that it is read by the Blob reader
+       rather than the file reader.  Default the output Geometry to the
+       input image geometry in case the user does not specify a resize
+       resolution or geometry.
+
+       * Magick++/tests/readWriteBlob.cpp (main): Improve the quality of
+       code which reads a file into memory for Blob testing.
+
+       * magick/blob.c (BlobToImage): Add exception reports for the cases
+       where 'magick' was not set and the file format could not be
+       deduced from its header.  Previously a null Image pointer was
+       being returned without any exception being thrown.
+
+2018-04-15  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dpx.c (ReadDPXImage): Assure that CbCr layer initializes
+       all channels if it is the first element of a planar DPX.  Fixes
+       oss-fuzz 7703 "graphicsmagick/coder_DPX_fuzzer:
+       Use-of-uninitialized-value in WriteDPXImage". (Credit to OSS-Fuzz)
+
+       * coders/pict.c (ReadPICTImage): Don't refer to filename member of
+       ImageInfo which was just destroyed. Much thanks to Alex Gaynor for
+       finding this.  Should fix oss-fuzz 6867
+       "graphicsmagick/coder_PCT_fuzzer: Heap-use-after-free in
+       GetLocaleExceptionMessage". (Credit to OSS-Fuzz).
+
+2018-04-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/sgi.c (ReadSGIImage): Assure that iris pixels are fully
+       initialized.  Fixes oss-fuzz 7543
+       "graphicsmagick/coder_SGI_fuzzer: Use-of-uninitialized-value in
+       SGIEncode". (Credit to OSS-Fuzz).
+
+       * coders/xcf.c (ReadXCFImage): Restore SetImage() which was
+       previously commented out.  This is needed to assure initialized
+       pixels.  Fixes oss-fuzz 7430 "graphicsmagick/coder_XCF_fuzzer:
+       Use-of-uninitialized-value in AlphaCompositePixel". (Credit to
+       OSS-Fuzz).
+
+       * coders/pict.c (ReadPICTImage): Properly initialize "black
+       canvas" that tiles may be composed on.  Fixes oss-fuzz 7574
+       "graphicsmagick/enhance_fuzzer: Use-of-uninitialized-value in
+       EnhanceImage". (Credit to OSS-Fuzz).
+
+       * coders/rle.c (ReadRLEImage): Check for EOF when reading comment.
+       Fixes oss-fuzz 7667 "graphicsmagick/coder_RLE_fuzzer:
+       Use-of-uninitialized-value in ReadRLEImage". (Credit to OSS-Fuzz).
+
+       * coders/pdb.c (WritePDBImage): Avoid use of uninitialized
+       bytes. Fixes oss-fuzz 7638 "graphicsmagick/coder_PDB_fuzzer:
+       Use-of-uninitialized-value in WritePDBImage". (Credit to
+       OSS-Fuzz).
+
+       * coders/rla.c (ReadRLAImage): Add many more validations,
+       including scanline offsets and number of channels.  Fixes oss-fuzz
+       7653 "graphicsmagick/coder_RLA_fuzzer: Timeout in
+       graphicsmagick_coder_RLA_fuzzer". (Credit to OSS-Fuzz).
+
+       * coders/txt.c (ReadTXTImage): Implement missing subrange logic to
+       read only the specified range of frames.  Limits frames read from
+       oss-fuzz test case
+       clusterfuzz-testcase-minimized-coder_TEXT_fuzzer-6061076048248832
+       "graphicsmagick/coder_TEXT_fuzzer: Timeout in
+       graphicsmagick_coder_TEXT_fuzzer". (Credit to OSS-Fuzz).
+
+       * Magick++/lib/Image.cpp (read): Set subrange = 1 since this
+       interface is intended to read just one frame from the input file.
+       Use the STL-based interfaces to read multiple frames.
+
+       * coders/fits.c (ReadFITSImage): Verify FITS header before reading
+       further.  Rejects file from oss-fuzz 7650
+       "graphicsmagick/coder_FITS_fuzzer: Out-of-memory in
+       graphicsmagick_coder_FITS_fuzzer".  (Credit to OSS-Fuzz).
+
+       * PerlMagick/Magick.xs (Get): Fix PerlMagick compilation problem
+       due to rename/repurposing of image->clip_mask.
+
+2018-04-13  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/image.c, magick/image.h:  In order to be able to
+       support SVG masks, and to be able to further extend the
+       Image data structure without changing its size, new data
+       structure ImageExtra (struct _ImageExtra) has been added.
+       Header file image.h contains only a forward declaration;
+       the members of ImageExtra are defined in file image.c.
+       Image member variable Image * clip_mask has been replaced
+       by ImageExtra * extra, and function prototypes that enable
+       access to ImageExtra have been added to image.h.  The
+       clip_mask member variable now resides in ImageExtra.  All
+       references to Image::clip_mask in the GraphicsMagick
+       source code have either been replaced with direct references
+       to ImageExtra::clip_mask (image.c), or have been replaced
+       with calls to access function ImageGetClipMask().
+
+       * magick/render.c, magick/render.h:  In order to be able to
+       support SVG masks, and to be able to further extend the
+       DrawInfo data structure without changing its size, new data
+       structure DrawInfoExtra (struct _DrawInfoExtra) has been added.
+       Header file render.h contains only a forward declaration;
+       the members of DrawInfoExtra are defined in file render.c.
+       DrawInfo member variable char * clip_path has been replaced by
+       DrawInfoExtra * extra, and function prototypes that enable
+       access to DrawInfoExtra have been added to render.h.  The
+       clip_path member variable now resides in ImageExtra.  All
+       references to DrawInfo::clip_path in the GraphicsMagick
+       source code have either been replaced with direct references
+       to DrawInfoExtra::clip_path (render.c), or have been
+       replaced with calls to access function DrawInfoGetClipPath().
+
+       * magick/image.c (new functions CompositePathImage,
+       CompositeMaskImage, GetImageCompositeMask,
+       SetImageCompositeMask):  Defined new data structure ImageExtra,
+       added create/destroy logic, and implemented associated access
+       functions.  Implemented SVG masks.
+
+       * magick/render.c (DrawImage, new function DrawCompositeMask):
+       Defined new data structure DrawInfoExtra, added create/destroy
+       logic, and implemented associated access functions.  Impemented
+       SVG masks.
+
+       * magick/pixel_cache.c (SyncCacheNexus, new function
+       CompositeCacheNexus):  Fixed references to Image::clip_mask.
+       Implemented SVG masks.
+
+       * coders/svg.c (SVGStartElement, SVGEndElement): Implemented
+       SVG masks.
+
+       * locale/c.mgk, magick/gm_messages.mc, magick/local_c.h:
+       Added new error codes to support SVG masks.
+
+       * coders/ps3.c, magick/enhance.c: Fixed references to
+       Image::clip_mask.
+
+       * magick/draw.c, wand/drawing_wand.c: Fixed references to
+       DrawInfo::clip_path.
+
+2018-04-13  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/wpg.c Crash on row overflow fixed oss-fuzz 7639 thanks to oss-fuzz.
+
+2018-04-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dpx.c (ReadDPXImage): Add more header validations.
+       Always assure that scanline is initialized for Luma channel. Fixes
+       oss-fuzz 7544 "graphicsmagick/coder_DPX_fuzzer:
+       Use-of-uninitialized-value in WriteDPXImage". (Credit to OSS-Fuzz)
+
+       * coders/pdb.c (ReadPDBImage): Add more EOF checks to avoid benign
+       use of uninitialized data.  Fixes oss-fuzz 7545
+       "graphicsmagick/coder_PDB_fuzzer: Use-of-uninitialized-value in
+       ReadPDBImage".
+
+       * coders/wpg.c (InsertRow, UnpackWPGRaster): x & y should be
+       'unsigned long' to match type used by pixel cache APIs and image
+       rows/columns.
+
+2018-04-08  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/wpg.c Stop reading when last row is reached.
+       This should stop oss-fuzz 7528 thanks to oss-fuzz.
+
+
+2018-04-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/xcf.c (ReadXCFImage): Fix use of uninitialized data in
+       magick header string for runt file.  Fixes oss-fuzz 7521
+       "graphicsmagick/coder_XCF_fuzzer: Use-of-uninitialized-value in
+       LocaleNCompare". (Credit to OSS-Fuzz).
+
+2018-04-09  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * OVERVIEW: Change set 9aaeeca0224c modified the drawing
+       of clipping paths to conform to the SVG spec.  This change
+       set restores the previous behavior for non-SVG clients of
+       render.c, while still satisfying the SVG spec for SVG clients.
+
+       * magick/render.h (DrawInfo): Added a bit field in member
+       "flags" to indicate that drawing should be SVG compliant.
+
+       * magick/render.c (DrawImage): Now recognizes keyword
+       "svg-compliant", and tags DrawInfo accordingly.  This
+       allows for existing features in render.c to be changed
+       to comply with the SVG spec without impacting the previous
+       behavior expected by non-SVG clients.
+
+       * magick/render.c (DrawImage): Now uses DrawInfo "flags"
+       bit for SVG compliance in conjunction with "flags" bit
+       for "clipping path" to determine when to ignore changes
+       to fill color, stroke color, etc.  This restores the
+       previous behavior for clipping paths for non-SVG clients.
+
+       * coders/svg.c (SVGStartElement): The initial set of
+       MVG commands for rendering an SVG file now includes
+       new keyword "svg-compliant" (to indicate that certain
+       graphical elements should be drawn according to the
+       SVG spec), and includes an intialization of the SVG
+       "fill-rule" to "nonzero" (the SVG default) instead of
+       the internally initialized value of "evenodd".
+
+       * coders/wpg.c: Fixed C99 "//" comments.
+
+2018-04-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pict.c (ReadPICTImage): Copy tile exception info to main
+       image and don't composite tile if it has a problem.  Fixes
+       oss-fuzz 7169 "graphicsmagick/enhance_fuzzer:
+       Use-of-uninitialized-value in EnhanceImage". (Credit to OSS-Fuzz)
+
+       * coders/dib.c (ReadDIBImage): Do not increase decode bits/pixel
+       if compression=2, but use it to increase pixel packet size when
+       estimating bytes per line for decode buffer.  Fixes oss-fuzz issue
+       7324 "graphicsmagick/coder_WPG_fuzzer: Use-of-uninitialized-value
+       in ReadDIBImage". (Credit to OSS-Fuzz)
+
+       * coders/dpx.c (ReadDPXImage): When handling the first element of
+       a planar DPX, assure that the other channels are
+       initialized. Fixes oss-fuzz 7841 "graphicsmagick/coder_DPX_fuzzer:
+       Use-of-uninitialized-value in WriteDPXImage". (Credit to OSS-Fuzz)
+
+       * coders/tim.c (ReadTIMImage): Only 4 and 8 bit TIM requires a
+       colormap. For other depths, force reading as DirectClass even if
+       the TIM file provides a colormap.  Fixes oss-fuzz 7407
+       "graphicsmagick/coder_TIM_fuzzer: Use-of-uninitialized-value in
+       SyncImageCallBack". (Credit to OSS-Fuzz)
+
+2018-04-08  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c The unread data contains crap in memory,
+       erase current image data. This should mute oss-fuzz 6604.
+
+       * coders/wpg.c - condition "if(y<1) continue;" is redundant
+       and could be removed completely.
+       Allow logging in MatlabV4 module.
+
+       * coders/svg.c - Do not use C++ syntax in C code - removed.
+
+2018-04-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/wpg.c (UnpackWPGRaster): Fix uninitialized row 0 when
+       row-based RLE is used.  Fixes oss-fuzz 6603
+       "graphicsmagick/enhance_fuzzer: Use-of-uninitialized-value in
+       BlendCompositePixel". (Credit to OSS-Fuzz)
+
+       * coders/pcd.c: Fix many issues, including oss-fuzz 6016
+       "graphicsmagick/coder_PCD_fuzzer: Heap-double-free in
+       MagickRealloc" and oss-fuzz 6108 "graphicsmagick/coder_PCD_fuzzer:
+       Unknown signal in AllocateThreadViewDataSet". (Credit to OSS-Fuzz)
+
+2018-04-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dcm.c (funcDCM_BitsStored): Limit DICOM significant bits
+       to 16.  Otherwise rescale map code blows up.  Fixes oss-fuzz 7435
+       "graphicsmagick/coder_DCM_fuzzer: Out-of-memory in
+       graphicsmagick_coder_DCM_fuzzer". (Credit to OSS-Fuzz)
+
+       * coders/pix.c (ReadPIXImage): Detect EOF.  Reject RLE lenth of
+       zero.  Fixes oss-fuzz 7440 "graphicsmagick/coder_PIX_fuzzer:
+       Out-of-memory in graphicsmagick_coder_PIX_fuzzer". (Credit to
+       OSS-Fuzz)
+
+2018-04-05  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dpx.c (ReadDPXImage): Insist on having an element
+       descriptor we understand since otherwise we can not decode the
+       image.  Fixes oss-fuzz 7410 "graphicsmagick/coder_DPX_fuzzer:
+       Use-of-uninitialized-value in WriteDPXImage". (Credit to OSS-Fuzz)
+
+       * coders/avs.c, etc... (WriteAVSImage): Cache image list length
+       before writing image sequence so that progress monitor is
+       scalable.  Helps with oss-fuzz 7404
+       "graphicsmagick/coder_AVS_fuzzer: Timeout in
+       graphicsmagick_coder_AVS_fuzzer". (Credit to OSS-Fuzz)
+
+2018-04-05  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * coders/svg.c (SVGStartElement, SVGEndElement),
+       magick/render.c (DrawImage): The current text position
+       is now maintained by DrawImage() instead of by
+       SVGStartElement() and SVGEndElement().  This change was
+       made to support the recently implmemented "use" and
+       "class" elements, which may make changes to the font
+       size that are not visible to the code in svg.c.
+
+       * coders/svg.c (GetStyleTokens, SVGStartElement): The
+       list of SVG attributes is now reordered so that
+       "font-size", "class", and "style" are processed first.
+       This ensures that a change to the font size will be
+       processed before any dimensional attribute whose value
+       may depend on the font size (e.g., a width value
+       specified in "em" units).
+
+       * coders/svg.c (ProcessStyleClassDefs): Fixed two memory
+       leaks associated with making an early return when
+       malformed input is detected.
+
+       * magick/render.c (ExtractTokensBetweenPushPop): Fixed
+       an uninitialized variable condition which can occur when
+       malformed input is detected.
+
+       * magick/render.h (DrawInfo), magick/render.c: DrawInfo
+       member "unused1" has been renamed "flags".  It is now
+       used to tag a DrawInfo as being a clipping path or a
+       compositing mask.
+
+2018-04-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pdb.c (ReadPDBImage): Update DirectClass pixels to avoid
+       use of uninitialized memory for 2 bits/pixel.  Fixes oss-fuzz 7350
+       "graphicsmagick/coder_PDB_fuzzer: Use-of-uninitialized-value in
+       WritePDBImage".  (Credit to OSS-Fuzz)
+
+       * coders/palm.c (ReadPALMImage): Fix use of uninitialized memory.
+       Fixes oss-fuzz 7325 "graphicsmagick/coder_PALM_fuzzer:
+       Use-of-uninitialized-value in TransparentImageCallBack". (Credit
+       to OSS-Fuzz)
+
+       * coders/dcm.c (DCM_ReadNonNativeImages): Break out of reading
+       loop on EOF and properly report exception.  Fixes oss-fuzz 7349
+       "graphicsmagick/coder_DCM_fuzzer: Timeout in
+       graphicsmagick_coder_DCM_fuzzer". (Credit to OSS-Fuzz)
+
+2018-04-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/xcf.c (ReadXCFImage): Require that XCF file offsets be in
+       ascending order to avoid DOS.  Fixes oss-fuzz 7333
+       "graphicsmagick/coder_XCF_fuzzer: Out-of-memory in
+       graphicsmagick_coder_XCF_fuzzer". (Credit to OSS-Fuzz)
+
+       * coders/wpg.c (UnpackWPGRaster): Fix memory leak in error return
+       path. Fixes oss-fuzz 7338 "graphicsmagick/enhance_fuzzer:
+       Direct-leak in UnpackWPGRaster". (Credit to OSS-Fuzz)
+
+2018-04-03  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * coders/svg.c (SVGStartElement): This changeset adds
+       support for SVG geometric transforms specified using the
+       style="transform: ..." syntax.  This syntax is sometimes
+       used when exporting SVG files from Adobe Illustrator.
+
+2018-04-02  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dpx.c (ReadDPXImage): Validate DPX packing method.  Fixes
+       oss-fuzz 7296 "graphicsmagick/coder_DPX_fuzzer:
+       Use-of-uninitialized-value in WriteDPXImage". (Credit to OSS-Fuzz)
+
+2018-04-02  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * coders/svg.c (SVGStartElement, SVGEndElement),
+       magick/render.c (DrawImage): This changeset adds support for
+       "class" styling attributes within a <style> section within
+       the <defs> section, and the ability to reference them from
+       other SVG elements by class="classname".  SVG files exported
+       from Adobe Illustrator make extensive use of "class" definitions.
+
+2018-04-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pict.c (ReadPICTImage): Fix leak of tile image on EOF.
+       This is a recent regression.  Fixes oss-fuzz 7287
+       "graphicsmagick/coder_PCT_fuzzer: Indirect-leak in
+       CloneImage". (Credit to OSS-Fuzz)
+
+       * magick/pixel_cache.c (OpenCache): Use image->scene rather than
+       GetImageIndexInList(image) for scene-id part of cache info file
+       name.
+
+       * coders/txt.c (WriteTXTImage): Optimize the progress indicator
+       since it is very inefficient with a large number of scenes and
+       oss-fuzz 7090 "graphicsmagick/coder_TEXT_fuzzer: Timeout in
+       graphicsmagick_coder_TEXT_fuzzer" consistently shows
+       GetImageListLength() in its stack traces.
+
+       * coders/dcm.c (ReadDCMImage): DICOM reader was no longer
+       immediately quitting with excessive samples per pixel.  This
+       caused spinning for a very long time when reading planar images
+       with large samples per pixel.  This is a regression due to recent
+       changes.  Fixes oss-fuzz 7269 "graphicsmagick/coder_DCM_fuzzer:
+       Timeout in graphicsmagick_coder_DCM_fuzzer". (Credit to OSS-Fuzz)
+
+       * coders/xcf.c (ReadXCFImage): Destroy layer info before returning
+       due to exception.  This is a new regression due to adding more
+       checks. Fixes oss-fuzz 7277 "graphicsmagick/coder_XCF_fuzzer:
+       Direct-leak in ReadXCFImage". (Credit to OSS-Fuzz)
+
+       * coders/pdb.c (ReadPDBImage): Assure that all bytes of scanline
+       are initialized while decoding.  Fixes oss-fuzz 7051
+       "graphicsmagick/coder_PDB_fuzzer: Use-of-uninitialized-value in
+       WritePDBImage". (Credit to OSS-Fuzz)
+
+2018-03-31  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pcx.c (ReadPCXImage): Assure that scanline is
+       initialized.  Fixes oss-fuzz 6612
+       "graphicsmagick/coder_PCX_fuzzer: Use-of-uninitialized-value in
+       WriteRLEPixels". (Credit to OSS-Fuzz)
+
+       * coders/wpg.c (ReadWPGImage): Detect unexpected EOF and avoid use
+       of uninitialized data.  Fixes oss-fuzz 6601
+       "graphicsmagick/enhance_fuzzer: Use-of-uninitialized-value in
+       ImportIndexQuantumType". (Credit to OSS-Fuzz)
+
+       * coders/sgi.c (ReadSGIImage): Assure that RLE decode buffer is
+       initialized.  Fixes oss-fuzz 6599
+       "graphicsmagick/coder_SGI_fuzzer: Use-of-uninitialized-value in
+       SyncImageCallBack" and oss-fuzz 6600
+       "graphicsmagick/coder_SGI_fuzzer: Use-of-uninitialized-value in
+       SGIEncode". (Credit to OSS-Fuzz)
+
+       * coders/viff.c (ReadVIFFImage): Fix blob I/O size validation to
+       avoid use of uninitialized data. Fixes oss-fuzz 6597
+       "graphicsmagick/coder_VIFF_fuzzer: Use-of-uninitialized-value in
+       ThresholdImage". (Credit to OSS-Fuzz)
+       (ReadVIFFImage): Don't execute SetImageType(image,BilevelType) on
+       an image which has no pixels yet in order to avoid use of
+       uninitialized data. Fixes oss-fuzz 6597.  (Credit to OSS-Fuzz)
+
+       * coders/wbmp.c (ReadWBMPImage): Fix blob I/O size validation to
+       avoid use of uninitialized data. Fixes oss-fuzz 7047
+       "graphicsmagick/coder_WBMP_fuzzer: Use-of-uninitialized-value in
+       ReadWBMPImage". (Credit to OSS-Fuzz)
+
+       * coders/wpg.c (ExtractPostscript): Allow non-Postscript content
+       but force reading using the magick we already detected.  Also log
+       the format that we detected.
+
+       * coders/xcf.c (ReadOneLayer): Reject layer size of 0x0.  Fixes
+       oss-fuzz 6636 "graphicsmagick/coder_XCF_fuzzer: Direct-leak in
+       MagickMallocAligned". (Credit to OSS-Fuzz)
+       (ReadXCFImage): Verify that seek offsets are within the bounds of
+       the file data. Fixes oss-fuzz 6682
+       "graphicsmagick/coder_XCF_fuzzer: Out-of-memory in
+       graphicsmagick_coder_XCF_fuzzer". (Credit to OSS-Fuzz)
+
+       * magick/pixel_cache.c (ModifyCache): Destroy CacheInfo if
+       OpenCache() fails so it is not leaked.
+
+       * coders/wpg.c (ExtractPostscript): Enforce that embedded file is
+       a Postscript file.  Fixes oss-fuzz 7235
+       "graphicsmagick/coder_WPG_fuzzer: Indirect-leak in MagickRealloc".
+       This is indicated to be a regression. (Credit to OSS-Fuzz)
+
+2018-03-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pict.c (ReadPICTImage): Check image pixel limits before
+       allocating memory for tile.  Fixes oss-fuzz 7217
+       "graphicsmagick/coder_PICT_fuzzer: Out-of-memory in
+       graphicsmagick_coder_PICT_fuzzer".
+
+2018-03-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pcd.c (ReadPCDImage): Add checks for EOF. Fixes oss-fuzz
+       issue 7180 "graphicsmagick/coder_PCDS_fuzzer: Timeout in
+       graphicsmagick_coder_PCDS_fuzzer".  (Credit to OSS-Fuzz)
+
+2018-03-29  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * coders/svg.c (SVGStartElement, SVGEndElement),
+       magick/render.c (DrawImage): This changeset implements the SVG
+       "use" element.  Graphical elements (e.g., "rect", "text", etc.)
+       can be tagged with an identifier using 'id="identifier"' when
+       defined within the "defs" section.  They can then be referenced
+       elsewhere in the SVG file using:
+
+       <use xlink:href="#identifier" ... />
+
+       When referencing a graphical element by its identifier, the
+       following syntaxes are now treated as being the same:
+
+       href="#identifier"
+       href="url(#identifier)"
+       xlink:href="#identifier"
+       xlink:href="url(#identifier)"
+
+2018-03-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tim.c (ReadTIMImage): Reader was not observing subimage
+       and subrange to quit after the specified frame range.  Inspired by
+       oss-fuzz 7132 "graphicsmagick/coder_TIM_fuzzer: Timeout in
+       graphicsmagick_coder_TIM_fuzzer" (Credit to OSS-Fuzz)
+
+2018-03-27  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * coders/svg.c (SVGStartElement): Enable setting the
+       background color from the SVG file when the client
+       specifies style="background:color" inside the <svg>
+       ... </svg> element.
+
+2018-03-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/mtv.c (ReadMTVImage): Add some elementary tracing to MTV
+       reader.
+
+       * coders/png.c (ReadMNGImage): Fix SourceForge issue 554
+       "Divide-by-zero in ReadMNGImage (coders/png.c)".  (Credit to Trace
+       Probe)
+
+       * coders/bmp.c (ReadBMPImage): Assure that start position always
+       advances to avoid looping BMPs.  Fixes oss-fuzz 7045
+       "graphicsmagick/coder_BMP_fuzzer: Timeout in
+       graphicsmagick_coder_BMP_fuzzer". (Credit to OSS-Fuzz)
+
+       * coders/pict.c (DecodeImage): Verify that sufficient backing data
+       exists before allocating memory to read it.  Fixes oss-fuzz 6629
+       "graphicsmagick/coder_PCT_fuzzer: Out-of-memory in
+       graphicsmagick_coder_PCT_fuzzer".
+       (ReadPICTImage): Destroy tile_image in ThrowPICTReaderException()
+       macro to simplify logic.
+
+2018-03-25  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Check whether datablock is really read.
+       Fixes oss-fuzz 7056 (Credit to OSS-Fuzz)
+
+       * coders/txt.c Duplicate image check for data with fixed geometry
+       previous check is skipped. Fixes oss-fuzz 7090.
+
+2018-03-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dcm.c (ReadDCMImage): Validate that samples per pixel is
+       in valid range.  Fixes oss-fuzz 6260
+       "graphicsmagick/coder_DCM_fuzzer: Out-of-memory in
+       graphicsmagick_coder_DCM_fuzzer". (Credit to OSS-Fuzz)
+
+       * coders/meta.c (format8BIM): Allocate space for null termination
+       and null terminate string.  Fixes oss-fuzz 5985
+       "graphicsmagick/coder_8BIMTEXT_fuzzer: Heap-buffer-overflow in
+       formatIPTCfromBuffer". (Credit to OSS-Fuzz)
+
+       * coders/fits.c (ReadFITSImage): Include number of FITS scenes in
+       file size validations.  Fixes oss-fuzz 6781
+       "graphicsmagick/coder_FITS_fuzzer: Timeout in
+       graphicsmagick_coder_FITS_fuzzer". (Credit to OSS-Fuzz)
+
+2018-03-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/meta.c (format8BIM): Validate size request prior to
+       allocation. Fixes oss-fuzz issue 5974
+       "graphicsmagick/coder_8BIMTEXT_fuzzer: Out-of-memory in
+       graphicsmagick_coder_8BIMTEXT_fuzzer". (Credit to OSS-Fuzz)
+
+2018-03-23  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Fix forged amount of frames 7076. (Credit to OSS-Fuzz)
+
+        * coders/topol.c Check for forged image that overflows file size
+        (fuzz 6836).
+
+2018-03-23  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c, render.h (DrawInfo, CloneDrawInfo,
+       DrawClipPath, DrawImage, GetDrawInfo): According to the SVG
+       spec, a clipping path is defined only by the geometry of its
+       constituent elements, and is not dependent on fill color/opacity,
+       stroke color/opacity, or stroke width.  To ensure conformity
+       with the spec, when a clipping path is created, these SVG
+       elements are set to appropriate values, and any attempt to
+       modify them is ignored.
+
+       Also, whenever a clipping path is drawn, the associated image
+       attributes are now updated from the parent image structure.
+       This ensures that any added or modified attributes are up to
+       date.
+
+2018-03-22  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/topol.c Use rather MagickSwabArrayOfUInt32() to
+        flip all array elements at once.
+
+        * magick/annotate.c Compilation issue - using C++ syntax in C code.
+
+2018-03-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dpx.c (ReadDPXImage): Validate header length and offset
+       properties.  Fixes oss-fuzz "graphicsmagick/coder_DPX_fuzzer:
+       Use-of-uninitialized-value in WriteDPXImage". (Credit to OSS-Fuzz)
+
+2018-03-20  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/annotate.c (RenderType): According to the SVG
+       spec, the 'font-family' element can be a comma-separated
+       list of one or more font family names.  Function RenderType
+       in file annotate.c has been modified to support multiple
+       font family names as follows.  The comma-separated list is
+       processed until the first available font family is found.
+       If no font family is found, or if font substitution occurred,
+       then the entire font family string is tested to see if it
+       exactly matches a font name, or if the font family string
+       with blanks changed to hypens exactly matches a font name.
+       If a font name match is found, the matched font overrides
+       the font substution.  The font name matching functionality
+       is beyond what's in the SVG spec and is provided as a
+       convenience to the user.
+
+2018-03-20  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Fix forged amount of frames 6755. (Credit to OSS-Fuzz)
+
+2018-03-20  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/topol.c Redesign ReadBlobDwordLSB() to be more effective.
+
+2018-03-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/xpm.c (ReadXPMImage): Reject XPM if its condensed version
+       contains non-whitespace control characters.  Fixes oss-fuzz 7027
+       "graphicsmagick/coder_XPM_fuzzer: Timeout in
+       graphicsmagick_coder_XPM_fuzzer". (Credit to OSS-Fuzz)
+
+2018-03-19  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/topol.c Fix tile index overflow fuzz 6634. (Credit to OSS-Fuzz)
+
+2018-03-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dcm.c (DCM_ReadGrayscaleImage): Don't use rescale map if
+       it was not allocated.  This issue was induced in this development
+       cycle due to disabling generating the rescale map.  Fixes oss-fuzz
+       7021 "graphicsmagick/coder_DCM_fuzzer: Null-dereference READ in
+       DCM_ReadGrayscaleImage". (Credit to OSS-Fuzz)
+
+2018-03-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/color_lookup.c (QueryColorDatabase): Defend against
+       partial scanf() expression matching, resulting in use of
+       uninitialized data.  Likely fixes oss-fuzz 6596
+       "graphicsmagick/coder_XPM_fuzzer: Use-of-uninitialized-value in
+       IsMonochromeImage". (Credit to OSS-Fuzz)
+
+       * coders/rle.c (ReadRLEImage): Validate number of colormap bits to
+       avoid undefined shift behavior.  Fixes oss-fuzz 6630
+       "graphicsmagick/enhance_fuzzer: Undefined-shift in
+       ReadRLEImage". (Credit to OSS-Fuzz)
+
+       * coders/dcm.c (DCM_ReadRGBImage): Don't use rescale map if it was
+       not allocated.  This issue was induced in this development cycle
+       due to disabling generating the rescale map.  Fixes oss-fuzz 6995
+       "graphicsmagick/coder_DCM_fuzzer: Null-dereference READ in
+       DCM_ReadRGBImage". (Credit to OSS-Fuzz)
+
+       * coders/dib.c (DecodeImage): Report failure to decode to expected
+       amount of pixel data as an error.  Fixes oss-fuzz 7007
+       "graphicsmagick/enhance_fuzzer: Use-of-uninitialized-value in
+       EnhanceImage". (Credit to OSS-Fuzz)
+
+       * coders/bmp.c (ReadBMPImage): Add file size and offset/seek
+       validations.  Fixes oss-fuzz 6623
+       "graphicsmagick/coder_BMP_fuzzer: Timeout in
+       graphicsmagick_coder_BMP_fuzzer". (Credit to OSS-Fuzz)
+
+2018-03-17  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * dcraw/dcraw.c Updated to version 9.27
+
+2018-03-15  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/gif.c (ReadGIFImage): Fix botched fixes for use of
+       uninitialized data when reading GIF extension blocks.  Hopefully
+       ok now.
+
+2018-03-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/gif.c (ReadGIFImage): Fix use of uninitialized data when
+       reading GIF extension blocks.  Fixes oss-fuzz 6609
+       "graphicsmagick/coder_GIF_fuzzer: Use-of-uninitialized-value in
+       MagickArraySize". This seems to be a totally benign issue. (Credit
+       to OSS-Fuzz)
+
+       * magick/magick.c (MagickSignal): Use an alternate signal stack,
+       if available.  This is required for Go lang C language extensions
+       since Go lang requests an alternate signal sack, and uses small
+       stacks for its threads.  If the library user has not allocated an
+       alternate signal stack, then behavior should be just as before.
+       Issue was originally reported by yzh杨振宏 on March 1, 2018 via
+       the graphicsmagick-help SourceForge mailing list.
+
+2018-02-28  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/pixel_cache.c (AcquireCacheNexus): Add a check that the
+       pixel cache is compatible with the image dimensions.  Fixes
+       oss-fuzz issues 5978 5988 5989 5990 5993 6016, and 6056, which are
+       all related to the PICT writer. (Credit to OSS-Fuzz)
+
+       * magick/draw.c (DrawGetStrokeDashArray): Check for failure to
+       allocate memory.  Patch submited by Petr Gajdos via email on
+       February 28, 2018.
+
+2018-02-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/fits.c (ReadFITSImage): Fix signed integer overflow when
+       computing pixels size.  Fixes oss-fuzz 6586
+       "graphicsmagick/coder_FITS_fuzzer: Integer-overflow in
+       ReadFITSImage". (Credit to OSS-Fuzz)
+
+2018-02-27  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * coders/svg.c (SVGStartElement, SVGEndElement): From the
+       SVG spec:  "The 'foreignObject' element allows for inclusion
+       of a foreign namespace which has its graphical content drawn
+       by a different user agent."  Code has been added to consume
+       and discard the 'foreignObject' element and any settings (e.g.,
+       fill color) internal to it.  Previously, settings internal
+       to the 'foreignObject' element would persist and "leak" into
+       the graphic elements that followed it, resulting in undesired
+       side effects (e.g., fill color other than the expected default).
+
+2018-02-27  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (DrawPolygonPrimitive): Fixed a bug
+       introduced by changeset 39102dd1d456.  For SVG, this
+       changeset applied both the group AND the fill opacity
+       values to fill patterns (similarly for stroke).  For WMF,
+       however, this caused the fill pattern to be rendered as
+       100% transparent.  A closer reading of the SVG spec does
+       NOT show that the fill opacity should be applied to the
+       fill pattern, so as of this latest changeset only the group
+       opacity value is applied to fill and stroke patterns.
+
+2018-02-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/bmp.c (ReadBMPImage): Fix divide by zero regression added
+       by latest fixes.  Fixes oss-fuzz 6583
+       "graphicsmagick/coder_BMP_fuzzer: Divide-by-zero in ReadBMPImage".
+       (Credit to OSS-Fuzz)
+
+2018-02-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pict.c (ReadPICTImage): Validate that PICT rectangles do
+       not have zero dimensions.  Specify expected file type when reading
+       from a temporary file.  Trace PICT rectangle dimensions.  More
+       detection of blob EOF and more error handling.  Fixes oss-fuzz
+       issue 6193 "graphicsmagick/coder_PCT_fuzzer: Unknown signal in
+       AllocateImageColormap" and likely many oss-fuzz ASAN/UBSAN issues
+       reported against "PCT" and "PICT" since this one problem appears
+       to be causing a spew of reports.
+
+       * coders/png.c (ReadMNGImage): Detect and handle failure to
+       allocate global PLTE.  Problem was reported via email from Petr
+       Gajdos on February 26, 2018.
+
+2018-02-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/blob.c (ReadBlobLSBDouble): Make sure imported double is
+       a normal value.
+       (ReadBlobLSBDoubles): Make sure imported doubles are normal
+       values.
+       (ReadBlobLSBFloat): Make sure imported float is a normal value.
+       (ReadBlobLSBFloats): Make sure imported floats are normal values.
+       (ReadBlobMSBFloat): Make sure imported float is a normal value.
+       (ReadBlobMSBFloats): Make sure imported floats are normal values.
+       (ReadBlobMSBDouble): Make sure imported double is a normal value.
+       (ReadBlobMSBDoubles): Make sure imported doubles are normal
+       values.
+
+       * magick/import.c (ImportFloat32Quantum): Make sure imported float
+       is a normal value.
+       (ImportFloat64Quantum): Make sure imported double is a normal
+       value.
+
+       * magick/image.h (RoundDoubleToQuantum): Restore previous behavior
+       (from earlier today).
+       (RoundFloatToQuantum): Restore previous behavior (from earlier
+       today).
+
+       * coders/bmp.c (ReadBMPImage): Fix UBSAN runtime error: left shift
+       of 205 by 24 places cannot be represented in type 'int'.
+
+       * coders/ept.c (ReadEPTImage): Fix dereference of NULL pointer
+       which was detected by UBSAN in the test suite.
+
+       * magick/image.h (RoundDoubleToQuantum): Check double value for
+       NaN and infinity in order to avoid undefined behavior.
+       (RoundFloatToQuantum): Check float value for NaN and infinity in
+       order to avoid undefined behavior.
+
+       * magick/common.h (MAGICK_ISNAN): Add a isnan() wrapper macro.
+       (MAGICK_ISINF): Add a isinf() wrapper macro.
+
+2018-02-25  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Fix oss-fuzz issue 6273 - Heap-use-after-free in
+       GetLocaleExceptionMessage. (Credit to OSS-Fuzz)
+
+2018-02-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dcm.c (DCM_PostRescaleImage): Remove use of
+       DCM_PostRescaleImage() since its implementation is wrong and
+       accesses non-allocated heap memory.  Problem was reported by Petr
+       Gajdos via email on February 8, 2018.
+
+       * coders/jp2.c (ReadJP2Image): Use a ThrowJP2ReaderException macro
+       to automatically clean up when throwing an exception.
+
+       * coders/bmp.c (ReadBMPImage): Report an error if RLE decode does
+       not produce the expected number of bytes.  Fixes oss-fuzz issue
+       6015 "graphicsmagick/coder_BMP_fuzzer: Out-of-memory in
+       graphicsmagick_coder_BMP_fuzzer". (Credit to OSS-Fuzz)
+
+2018-02-23  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (DrawImage): Fixed a bug in which graphical
+       elements defined within <defs> ... </defs> were being rendered,
+       contrary to the SVG spec.
+
+2018-02-23  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (DrawPolygonPrimitive): When filling or
+       stroking a polygon using a pattern, the fill (or stroke)
+       and group/object opacity values were not being applied to
+       the pattern (fixed).
+
+2018-02-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/bmp.c (ReadBMPImage): Fix SeekBlob() return value checks.
+       Add more EOF checks.  Require that a provided ba_offset be a
+       forward seek in order to avoid the possibility of endless looping.
+
+2018-02-23  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Fix oss-fuzz issue 6301. (Credit to OSS-Fuzz)
+
+2018-02-22  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/alpha_composite.c (BlendQuantumOpacity): The
+       pixel compositing equation used when compositing an
+       image into the output was incorrect and has been fixed.
+
+       * magick/render.c (DrawPolygonPrimitive): When
+       compositing polygon edge pixels over a transparent
+       black background, the code would composite as if the
+       background were opaque black, resulting in the edge
+       pixels being too dark (fixed).
+
+2018-02-21  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (DrawImage): Per the SVG spec, opacity,
+       fill-opacity, and stroke-opacity values are now clamped
+       to [0,1].
+
+       Also fixed two bugs introduced by changeset 91de8039f27d
+       (dated 2018-02-12): (1) a group/object opacity value
+       specified using a percentage was not being converted to a
+       value in [0,1]; (2) if fill-opacity or stroke-opacity was
+       1, and the group/object opacity value was set to 1, the
+       resulting fill-opacity or stroke-opacity value would be
+       set to 0 instead of 1.
+       
+2018-02-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/viff.c (ReadVIFFImage): Fix excessive memory usage.
+       Fixes oss-fuzz 6006 "graphicsmagick/coder_XV_fuzzer: Out-of-memory
+       in graphicsmagick_coder_XV_fuzzer". (Credit to OSS-Fuzz)
+
+       * coders/txt.c (ReadInt): Avoid benign signed integer overflow due
+       to accepting an arbitrary number of digits.  Fixes oss-fuzz 6002
+       "graphicsmagick/coder_TEXT_fuzzer: Integer-overflow in
+       ReadInt". (Credit to OSS-Fuzz)
+
+       * coders/viff.c (ReadVIFFImage): Verify that there is sufficient
+       data to back up colormap allocation request.  Fixes oss-fuzz 5986
+       "graphicsmagick/coder_VIFF_fuzzer: Out-of-memory in
+       graphicsmagick_coder_VIFF_fuzzer". (Credit to OSS-Fuzz)
+
+       * magick/memory.c: Define MAGICK_MEMORY_HARD_LIMIT=value to abort
+       when memory request exceeds value.  Useful to find location of
+       excessive memory requests.
+
+2018-02-19  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * coders/svg.c (SVGStartElement): Per the SVG spec, the
+       SVG coder now initializes the MVG coder (which renders
+       SVG graphical elements) with the the SVG defaults for
+       fill color, fill-opacity, stroke color, stroke-opacity,
+       and stroke-width.  This makes the SVG coder independent
+       of the MVG coder intial state.
+
+2018-02-19  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * coders/svg.c (SVGStartElement): Fixed initialization of
+       x and y attributes per the SVG spec:  for graphical elements
+       "image", "pattern", "text", "rect", and "use", if the x or y
+       attribute is not specified, the effect is as if a value of
+       "0" were specified.
+
+2018-02-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/sun.c (ReadSUNImage): Fix edge case which broke file-size
+       validation logic.  Fixes oss-fuzz issue 5981
+       "graphicsmagick/coder_SUN_fuzzer: Out-of-memory in
+       graphicsmagick_coder_SUN_fuzzer". (Credit to OSS-Fuzz)
+
+       * coders/txt.c (ReadTXTImage): Validate that file size is
+       sufficient for claimed image properties.  Fixes oss-fuzz issue
+       5960 "graphicsmagick/coder_TXT_fuzzer: Out-of-memory in
+       graphicsmagick_coder_TXT_fuzzer". (Credit to OSS-Fuzz)
+
+       * coders/tga.c (ReadTGAImage): Only allow 1 and 8 bit
+       colormapped/grey images. Fixes oss-fuzz issue 6314
+       "graphicsmagick/coder_ICB_fuzzer: Undefined-shift in
+       ReadTGAImage". (Credit to OSS-Fuzz)
+
+       * coders/bmp.c (ReadBMPImage): Detect and report when BMP height
+       value is out of range (too negative). Fixes oss-fuzz issue 6394
+       "graphicsmagick/coder_BMP_fuzzer: Integer-overflow in
+       ReadBMPImage". (Credit to OSS-Fuzz)
+
+       * coders/rla.c (ReadRLAImage): Detect when RLE decoding is
+       producing too many samples and report as an error.  Fixes oss-fuzz
+       issue 6312 "graphicsmagick/coder_RLA_fuzzer: Timeout in
+       graphicsmagick_coder_RLA_fuzzer". (Credit to OSS-Fuzz)
+
+       * coders/fits.c (ReadFITSImage): Validate that file size is
+       sufficient for claimed image properties.  Fixes oss-fuzz issue
+       6429 "graphicsmagick/coder_FITS_fuzzer: Timeout in
+       graphicsmagick_coder_FITS_fuzzer". (Credit to OSS-Fuzz)
+
+       * magick/image.c (CloneImage): Check image pixel limits in
+       CloneImage() when it is used to change the image dimensions.  This
+       avoids depending on the using code to detect and report such
+       issues.
+
+       * coders/xcf.c (ReadXCFImage): Check image pixel limits after each
+       CloneImage() to assure that image is within specified resource
+       limits.  Fixes oss-fuzz issue 6399 "graphicsmagick/enhance_fuzzer:
+       Timeout in graphicsmagick_enhance_fuzzer". (Credit to OSS-Fuzz)
+
+2018-02-16  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (TracePath): TracePath() was not
+       correctly processing multiple sets of cubic or quadratic
+       Bezier coordinates when the previous path data command was
+       not a cubic or quadratic Bezier command.  This would result
+       in the first control point being equal to the current path
+       point instead of being computed using the current path
+       point and the second control point of the previous Bezier
+       command.
+
+2018-02-15  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (TracePath): TracePath() was not
+       consuming commas (if present) at the end of a set of
+       points when multiple sets of points were specified for
+       various path commands (e.g., line, Bezier). This
+       resulted in the remaining sets of points being ignored
+       (fixed).
+
+2018-02-15  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (TraceArcPath): No points are generated
+       by TraceArcPath() if the starting and ending arc points
+       are the same.  For this case, the coordinate count was not
+       being set to zero before returning (fixed).
+
+2018-02-15  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (DrawImage): Clipping of polygons in
+       DrawImage() would sometime result in a starting pixel
+       location that was greater than the ending pixel location,
+       causing a subsequent call to GetImagePixelsEx() to fail
+       due a column count <= 0.  Modified the clipping code to
+       eliminate this condition, and also to return early if
+       the polygon lies completely outside the image boundaries.
+       Also fixed variable declarations from a previous commit
+       that were causing problems for the C89 compiler.
+
+2018-02-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/topol.c (ReadTOPOLImage): Detect EOF immediately rather
+       than spinning.  Fixes oss-fuzz issue 6303
+       "graphicsmagick/coder_TOPOL_fuzzer: Timeout in
+       graphicsmagick_coder_TOPOL_fuzzer". (Credit to OSS-Fuzz)
+
+       * coders/dcm.c (DCM_SetupRescaleMap): Avoid excessive left shift.
+       Fixes oss-fuzz issue 6256 "graphicsmagick/coder_DCM_fuzzer:
+       Undefined-shift in DCM_SetupRescaleMap". (Credit to OSS-Fuzz)
+
+2018-02-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/wpg.c (ExtractPostscript): Detect EOF on input while
+       transferring bytes to Postscript file.  Fixes oss-fuzz issue 6087
+       "graphicsmagick/coder_WPG_fuzzer: NULL".  Later identified to be
+       CVE-2017-17682 as previously discovered in ImageMagick.  (Credit to
+       OSS-Fuzz)
+
+       * coders/pdb.c (ReadPDBImage): Quit attempting to read image data
+       immediately at EOF. Fixes oss-fuzz issue 6252
+       "graphicsmagick/coder_PDB_fuzzer: Timeout in
+       graphicsmagick_coder_PDB_fuzzer".  (Credit to OSS-Fuzz)
+
+2018-02-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/topol.c (ReadTOPOLImage): Avoid index out of bounds when
+       input filename does not use a file extension. Fixes oss-fuzz issue
+       6237 "graphicsmagick/coder_TOPOL_fuzzer: Index-out-of-bounds in
+       ReadTOPOLImage".  (Credit to OSS-Fuzz)
+
+2018-02-12  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (DrawImage): Object/group opacity,
+       when set in DrawImage(), would overwrite the fill
+       and stroke opacities. This has been fixed so that
+       the object opacity is now combined with the fill
+       and stroke opacities per the SVG spec.
+
+2018-02-12  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Fix oss-fuzz issue 6021. (Credit to OSS-Fuzz)
+
+2018-02-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dcm.c (ReadDCMImage): Avoid undefined left shift of
+       short.  Fix memory leaks in error reporting paths.  Fixes oss-fuzz
+       issue 6217 "graphicsmagick/coder_DCM_fuzzer: Undefined-shift in
+       ReadDCMImage". (Credit to OSS-Fuzz)
+
+       * coders/dpx.c (ReadDPXImage): Avoid divide by zero exception in
+       the case where reference high equals reference low. Fixes oss-fuzz
+       issue 6215 "graphicsmagick/coder_DPX_fuzzer: Divide-by-zero in
+       ReadDPXImage". (Credit to OSS-Fuzz)
+
+       * coders/topol.c (ReadTOPOLImage): Avoid index out of bounds when
+       input filename does not use a file extension.
+
+       * coders/cut.c (ReadCUTImage): Avoid index out of bounds when
+       input filename does not use a file extension. Fixes oss-fuzz issue
+       6218 "graphicsmagick/coder_CUT_fuzzer: Index-out-of-bounds in
+       ReadCUTImage".  (Credit to OSS-Fuzz)
+
+       * coders/pwp.c (ReadPWPImage): Force temporary file to be read as
+       a SFW file rather than autodetecting the format.  Fixes oss-fuzz
+       issue 6220 "graphicsmagick/coder_PWP_fuzzer: Indirect-leak in
+       AllocateImage".  (Credit to OSS-Fuzz)
+
+2018-02-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pdf.c (WritePDFImage): Assure that xref memory is not
+       leaked if an exception is thrown.  Fixes oss-fuzz issue 5968
+       "graphicsmagick/coder_EPDF_fuzzer: Direct-leak in MagickRealloc".
+       (Credit to OSS-Fuzz)
+
+       * coders/tim.c (ReadTIMImage): Verify that 4/8 bit PSX TIM
+       provides a CLUT and verify indexes.  Fixes oss-fuzz issue 5972
+       "graphicsmagick/coder_TIM_fuzzer: Null-dereference WRITE in
+       ReadTIMImage".  (Credit to OSS-Fuzz)
+
+       * coders/topol.c (ReadTOPOLImage): Add additional header
+       validations.  Fixes oss-fuzz issue 5975
+       "graphicsmagick/coder_TOPOL_fuzzer: Floating-point-exception in
+       ReadTOPOLImage".  (Credit to OSS-Fuzz)
+
+       * coders/bmp.c (ReadBMPImage): Avoid possible division by zero
+       when decoding CIE primary values. (Credit to OSS-Fuzz)
+
+       * magick/export.c (ExportViewPixelArea): Only compute
+       unsigned_maxvalue if sample_bits <= 32.
+
+       * magick/import.c (ImportViewPixelArea): Assure that
+       double_maxvalue minus double_minvalue is not zero, or excessively
+       close to zero to avoid divide by zero exception or impossible
+       scaling factor. (Credit to OSS-Fuzz)
+       (ImportViewPixelArea): Only compute unsigned_maxvalue if
+       sample_bits <= 32.
+
+2018-02-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dib.c (ReadDIBImage): Validate that image width is not
+       too negative such that it's absolute value can not fit in 32-bit
+       unsigned width. Resolves oss-fuzz issue 6179
+       "graphicsmagick/coder_ICO_fuzzer: Integer-overflow in
+       ReadDIBImage". (Credit to OSS-Fuzz)
+
+       * coders/dcm.c (funcDCM_BitsStored): Validate DICOM datum size.
+       Use a different means to determine the maximum value which does
+       not use excessive shifting.  Resolves oss-fuzz issue 6165
+       "graphicsmagick/coder_DCM_fuzzer: Undefined-shift in
+       funcDCM_BitsStored". (Credit to OSS-Fuzz)
+
+2018-02-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dpx.c (ReadWordU32BE): Add casts to avoid default type
+       promotion from unsigned char to 'int' leading to undefined
+       behavior for 24 bit shift. Fixes oss-fuzz issue 6058
+       "graphicsmagick/coder_DPX_fuzzer: Undefined-shift in
+       ReadWordU32BE". (Credit to OSS-Fuzz)
+       (ReadDPXImage): Require that the file has at least one element.
+       Add bountiful casts for values which are left-shifted.  Fixes
+       oss-fuzz issue 5962 "graphicsmagick/coder_DPX_fuzzer:
+       Undefined-shift in ReadDPXImage". (Credit to OSS-Fuzz)
+
+       * coders/dcm.c (DCM_ReadOffsetTable): Add casts Add casts to avoid
+       default type promotion from unsigned char to 'int' leading to
+       undefined behavior for 16 bit shift. Fixes oss-fuzz issue 5980
+       "graphicsmagick/coder_DCM_fuzzer: Undefined-shift in
+       DCM_ReadOffsetTable". (Credit to OSS-Fuzz)
+
+       * magick/module_aliases.h (ModuleAliases): Add missing mapping
+       from "ICODIB" format to "DIB" module.
+
+       * magick/import.c (ImportUInt32Quantum): Add casts to avoid
+       default type promotion from unsigned char to 'int' leading to
+       undefined behavior for 24 bit shift.  Fixes oss-fuzz
+       "graphicsmagick/coder_P7_fuzzer: Undefined-shift in
+       ImportRGBQuantumType". (Credit to OSS-Fuzz)
+
+2018-02-07  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/wpg.c Fix oss-fuzz issue 5964
+       "graphicsmagick/coder_MAT_fuzzer: Heap-use-after-free in
+       GetLocaleExceptionMessage". (Credit to OSS-Fuzz)
+
+2018-02-07     Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/render.c (IsPoint): Fixed a bug in which
+       IsPoint() would reject as a valid coordinate value
+       strings that did not begin with an integer: e.g.,
+       "0.25" would be accepted, but ".25" would not.
+
+2018-02-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/cut.c (ReadCUTImage): Fix DestroyImageInfo() of NULL
+       pointer leading to assertion.  Fixes oss-fuzz issue 6067
+       "graphicsmagick/coder_CUT_fuzzer: Unknown signal in
+       DestroyImageInfo".
+
+       * coders/tga.c (ReadTGAImage): Throw exception rather than
+       assertion for unexpected comment size.  Fixes oss-fuzz issue 5961
+       "graphicsmagick/coder_ICB_fuzzer: ASSERT: (size_t)
+       (tga_info.id_length+1) == commentsize".
+
+2018-02-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pdf.c (WritePDFImage): Free 'xref' allocation before
+       error return.  Fixes oss-fuzz issue 5968
+       "graphicsmagick/coder_EPDF_fuzzer: Direct-leak in MagickRealloc".
+
+2018-02-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pdb.c (ReadPDBImage): Fix heap buffer overflow if blob is
+       already at EOF when comment is read.  Fixes oss-fuzz issue 5997
+       "graphicsmagick/coder_PDB_fuzzer: Heap-buffer-overflow in
+       SetImageAttribute".
+
+       * coders/dpx.c (ReadDPXImage): Fix memory leak of user data if
+       user data is truncated.  Fix consumption of one uninitialized
+       stack bytes.  Fixes oss-fuzz issue 5973:
+       graphicsmagick/enhance_fuzzer: Direct-leak in ReadDPXImage.
+
+       * coders/pnm.c (ReadPNMImage): Detect and avoid division by zero.
+       Fixes Issue 5959 in oss-fuzz: graphicsmagick/coder_P7_fuzzer:
+       Divide-by-zero in ReadPNMImage
+
+       * magick/xwindow.c (MagickXClientMessage): Eliminate valgrind
+       gripe about use of uninitialized stack data by clearing allocation
+       to zero.
+       (MagickXMakeImage): Eliminate valgrind gripe about use of
+       uninitialized heap data by clearing allocation to zero.
+
+       * coders/pwp.c (ReadPWPImage): Remove bogus EOF test on an image
+       with a closed blob.  Fixes Issue 5957 in oss-fuzz:
+       graphicsmagick/coder_PWP_fuzzer: ASSERT: image->blob->type !=
+       UndefinedStream.
+
+       * www/Changes.rst: Fix typo with spelling "ChangeLog-2017.html".
+       Resolves SourceForge issue #544 "dead link 2017 changelog page on
+       GraphicsMagick web site".
+
+2018-02-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/static.c (OpenModule): Assure that status is initialized.
+       Resolves Coverity 261207 "Uninitialized scalar variable".
+
+       * wand/magick_wand.c (MagickHasColormap): New function to test if
+       the image has a colormap.
+       (MagickIsGrayImage): New function to test if the image uses only
+       gray pixels.
+       (MagickIsMonochromeImage): New function to test if the image uses
+       only monochrome pixels.
+       (MagickIsOpaqueImage): New function to test if the image uses only
+       opaque pixels.
+       (MagickIsPaletteImage): New function to test if the image is based
+       on a color palette.  Above functions are written by Troy Patteson
+       and submitted via SourceForge patch #54 "Wand API patches: has
+       colormap, is gray image, is monochrome image, is opaque image, is
+       palette image".
+
+       * fuzzing: Added initial OSS-Fuzz integration by Alex Gaynor.
+       From SourceForge patch #55 "OSS-Fuzz integration"
+
+       * coders/png.c (ReadMNGImage): Fix free using possibly unallocated
+       pointer value.
+
+       * magick/blob.c (SeekBlob): Remove implicit extension of blob
+       allocation size based on seek offset.  Besides making an
+       assumption about how the blob memory was allocated, this
+       reallocation feature provides a memory DOS opportunity.  Resolves
+       issue reported by Alex Gaynor via email entitled "Security issue
+       with memory management in Magick++" to the graphicsmagick-security
+       list on 31 Jan 2018.
+       (SeekBlob):
+
+       * coders/jpeg.c (ReadIPTCProfile): Revert inadvertent wrong return
+       codes added by change on December 9, 2017.  Fixes SourceForge bug
+       542 "Improper call to JPEG library in state 201" since 1.3.28.
+
+2018-02-01  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/annotate.c (RenderFreetype): Fixed the text
+       opacity computation in RenderFreeType(). This bug caused
+       the text fill color to bleed into the character cell when
+       the SVG "fill-opacity" is less than 1.0.
+
+2018-02-01  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * magick/attribute.c (CloneImageAttributes): Fixed a bug
+       in which the source image attributes would always replace
+       the destination image attributes instead of being appended
+       to them, and the destination image attributes would become
+       a memory leak.
+
+2018-01-31  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * coders/svg.c (SVGStartElement): Fixed a bug in which the
+       x,y location values for a <text> or <tspan> were overwritten
+       by the x,y values for the next <tspan> before the previous
+       values were used.  This caused the text associated with the
+       previous <text> or <tspan> to appear at the location
+       specified for the next <tspan>.
+
+2018-01-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/static.c: Use !defined(SupportMagickModules) to enable
+       static module loader.  Fixes SourceForge bug #543 "Multiple
+       definition of "OpenModule" (etc) when cross-compiling shared".
+
+2018-01-29  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * coders/svg.c (SVGStartElement): A terminating '>' in
+       a geometry string is interpreted to mean that the dimensions
+       of an image should only be changed if its width or height
+       exceeds the geometry specification.  For an unapparent and
+       undocumented reason, a terminating '>', if present, was
+       being nulled out, making this feature unusable for SVG files
+       (now fixed).
+
+2018-01-29  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * coders/svg.c (ReadSVGImage): If there is a geometry string
+       in image_info->size (e.g., gm convert -size "50x50%" in.svg
+       out.png), AllocateImage() sets image->columns and image->rows
+       to the width and height values from the size string.  However,
+       this makes no sense if the size string was something like
+       "50x50%" (we'll get columns = rows = 50).  So we set columns
+       and rows to 0 after AllocateImage(), which is the same as if
+       no size string was supplied by the client.  This also results
+       in svg_info.bounds to be set to 0,0 (i.e., unknown), so that
+       svg_info.bounds will later be set using the image size
+       information from either the svg "canvas" width/height or from
+       the viewbox.  Later, variable "page" is set from
+       svg_info->bounds. Then the geometry string in image_info->size
+       gets applied to the (now known) "page" width and height when
+       SvgStartElement() calls GetMagickGeometry(), and the intended
+       result is obtained.
+
+
+2018-01-24  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+       * coders/svg.c (SVGStartElement): When the density (DPI)
+       is specified using the ImageInfo::density member, the derived
+       scale factor is incorrectly applied a second time to the
+       width and height members of variable RectangleInfo page.
+       Fixes SourceForge ticket #451.
+
+2018-01-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/static.c: Use a lazy-loader for static modules with the
+       same external interface as the lazy-loader for dynamic modules.
+
+2018-01-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * NEWS.txt: Prepare for 1.3.28 release.
+
+2018-01-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * NEWS.txt: Update with changes since previous release.
+
+2018-01-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * PerlMagick/Magick.xs: Compiler warnings reduction.
+
+       * magick/pixel_cache.h: Mark GetPixels(), GetIndexes(), and
+       GetOnePixel() as deprecated.  Compilers may produce a warning if
+       these functions are used.
+
+       * magick/pixel_cache.c (InterpolateColor): Return black pixel if
+       InterpolateViewColor() reports failure.
+
+       * coders/png.c (ReadMNGImage): Fix memory leak of chunk and
+       mng_info in error path.
+
+       * coders/gif.c (ReadGIFImage): Fix memory leak of global colormap.
+
+2018-01-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/symbols.h: Fix SourceForge issue #538 "13 symbols in
+       common with ImageMagick despite --enable-symbol-prefix".
+
+       * coders/bmp.c (ReadBMPImage): Fix non-terminal loop due to
+       unexpected bit-field mask value.  Fixes SourceForge issue #541
+       "Infinite Loop in ReadBMPImage (coders/bmp.c)".
+
+       * coders/jpeg.c (JPEGMessageHandler): Revert code added on
+       2017-07-08 to promote certain warnings from libjpeg to errors.
+       Add code to rationalize claimed image dimensions based on file
+       size.  Resolves SourceForge issue #539 "Images with libjpeg
+       warnings result in error".
+
+2018-01-11  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/wpg.c Recursive ReadImage could return multiple scenes
+          fixed.
+
+2018-01-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOnePNGImage): Quit 'passes' loop if we
+       encountered an error
+
+       * magick/pixel_cache.c (SetNexus): Fix heap overwrite in
+       AcquireCacheNexus() due to SetNexus() not using an allocated
+       staging area for the pixels like it should.  This problem impacts
+       all 1.3.X releases.  Resolves SourceForge issues 532
+       "heap-buffer-overflow bug in ReadWPGImage" and #531
+       "heap-buffer-overflow in AcquireCacheNexus".
+
+       * magick/pixel_cache.c (InterpolateViewColor): Now returns
+       MagickPassFail rather than void.  Code using this function is
+       updated to check the return status.
+
+2018-01-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/describe.c (DescribeImage): Discriminate between
+       AcquireImagePixels() returning NULL or finding a transparent
+       pixel.  This avoids use of a null pointer in the case where
+       AcquireImagePixels() returns NULL.
+
+2017-12-31  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/static.c: Change static module initialization to be based
+       on an initialized list rather than a squence of function calls in
+       order to simplify maintenance and possibly address future
+       requirements.
+
+2017-12-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * Copyright.txt: Bump copyright years and rotate ChangeLog.
diff --git a/ChangeLog.2016 b/ChangeLog.2016
new file mode 100644 (file)
index 0000000..8b91536
--- /dev/null
@@ -0,0 +1,911 @@
+2016-12-31  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pnm.c (WritePNMImage): Support writing GRAYSCALE PAM
+       format.  Before this fix, grayscale output was marked as type
+       BLACKANDWHITE.  Problem was reported by Aaron Boxer via email on
+       December 31, 2016.
+
+       * TclMagick/generic/Makefile.am: Applied patch by Massimo Manghi
+       (plus some fixes by me) to add a 'libttkcommon' shared library to
+       contain codde common to the TclMagick/TkMagick loadable modules,
+       and particularly to allow TkMagick to access TclMagick functions
+       without depending on dlopen() with RTLD_GLOBAL behavior.
+
+2016-12-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/compare.c (DifferenceImage): Fix all-black difference
+       image if an input file is colormapped.  Resolves SourceForge issue
+       #404 "Difference file does not work if PNG ".
+
+2016-12-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/txt.c (ReadTXTImage): Fix Coverity issue 55866 "Resource
+       leak".
+
+       * magick/enum_strings.c (StringToCompositeOperator): Fix Coverity
+       issue 139296 "Constant expression result".
+
+       * magick/channel.c (ImportImageChannelsMasked): Fix Coverity issue
+       139297 "Constant expression result".  This was a bug but only in
+       terms of reduced performance, not results.
+
+       * Magick++/lib/Drawable.cpp
+       (PathSmoothCurvetoRel::operator): Fix Coverity issue 139301 "Using
+       invalid iterator".
+       (PathSmoothCurvetoRel::operator): Fix Coverity issue 139302 "Using
+       invalid iterator"
+
+       * magick/attribute.c: From SourceForge patches #47
+       "GraphicsMagick-1.3.25-get-exif-attribute-gps-fix.patch" and
+       "GraphicsMagick-1.3.25-set-exif-orientation-fix.patch" by Troy
+       Patteson with description (related to provided Coverity reports in
+       coverity.txt): Those coverity errors indicate a problem with the
+       earlier patch I sent you to fix getting the EXIF orientation when
+       the GPS IFD occurs before the EXIF IFD. Although the patch fixed
+       that issue it introduced a new issue in that GPS tags could no
+       longer be retrieved. This occurs because the gpsfound flag is set
+       when the GPS IFD is pushed onto the stack but then cleared
+       immediately when breaking out of the loop processing the directory
+       entries for the current IFD. The solution is to push the gpsfound
+       flag onto the stack as well as it needs to be set when the GPS IFD
+       is popped off the stack rather than being set straight away.
+
+       The second coverity error relates to gpsoffset not being set in
+       FindEXIFAttribute(). The code that sets gpsoffset in
+       GenerateEXIFAttribute() was embedded in the code that gets tags
+       values which was removed in FindEXIFAttribute() as only the DE
+       offset is required. I have removed the need for gpsoffset and just
+       computed the GPS IFD offset when pushing it onto the stack in the
+       same way the EXIF IFD offset is computed.
+
+2016-12-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/attribute.c: From SourceForge patches #47
+       "GraphicsMagick-1.3.25-5-set-exif-orientation.patch" by Troy
+       Patteson with description: Rotating an image without resetting the
+       EXIF orientation tag is problematic as follow-on viewers that
+       support the EXIF orientation tag may incorrectly rotate the image
+       a second time. For JPEG images, the current solution is to either
+       strip the image, remove the EXIF profile or modify the EXIF data
+       of the written image with other software. This patch adds the
+       ability to set the orientation tag in the EXIF profile via the
+       SetImageAttribute on attribute EXIF:Orientation provided the EXIF
+       orientation already exists. AutoOrientImage() has been modified to
+       set the EXIF orientation tag on successful rotation of the image.
+
+       The implementation is less than ideal. The EXIF profile must be
+       duplicated because it is returned read-only from the profiles
+       map. Large amounts of the GenerateEXIFAttribute() function has
+       been duplicated in a function called FindEXIFAttribute() which
+       returns the offset in the EXIF profile of a given tag ID. Once
+       found, the orientation tag value is updated accordingly and the
+       new EXIF profile set. Despite the patches shortcomings, I believe
+       it is preferable to leaving the EXIF orientation tag unchanged
+       after auto-orienting the image.
+
+       * wand/magick_wand.c (MagickClearException): From SourceForge
+       patches #47 "GraphicsMagick-1.3.25-1-wand-clear-exception.patch"
+       by Troy Patteson with description: This patch adds the ability to
+       clear the last Wand exception. This is particularly useful to
+       clear any exception on the Wand before calling MagickReadImage()
+       which can return success with a warning exception such as "JPEG
+       data: premature end of data segment".
+       (MagickRemoveImageOption): From SourceForge patches #47
+       "GraphicsMagick-1.3.25-2-wand-remove-image-option.patch" by Troy
+       Patteson with description: There is MagickSetImageOption() to set
+       options like JPEG preserve-settings but no way to remove the
+       option once set. Since the mechanism to remove image options
+       already exists in lower-level API there seems no reason not to
+       expose it in the Wand API.
+       (MagickGetImageOrientation, MagickSetImageOrientation): From
+       SourceForge patches #47
+       "GraphicsMagick-1.3.25-3-wand-get-set-orientation.patch" by Troy
+       Patteson with description: MagickGetImageOrientation returns the
+       internal orientation setting which is useful to know to determine
+       whether an image needs rotation. The function to set the
+       orientation is less useful as it only sets the internal
+       orientation setting which is only used when writing out TIFF
+       files. A future patch addresses this issue.
+       (MagickAutoOrientImage): From SourceForge patches #47
+       "GraphicsMagick-1.3.25-4-wand-auto-orient.patch" by Troy Patteson
+       with description: This patch adds auto-orient image to the Wand
+       API.
+
+2016-12-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * TclMagick/{configure.ac, Makefile.am}: Applied patches by
+       Massimo Manghi to use TEA tcl.m4 version 3.9.
+
+2016-11-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/gif.c (DecodeImage): Applied fixes by Tianyu Lang for
+       "Excessive LZW string data" problem leading to "Corrupt image"
+       report while reading some GIF files.
+
+2016-11-18 Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * doc/options.imdoc, doc/config_files.imdoc, doc/benchmark.imdoc:
+       Fixed some indentation in the documentation.
+
+2016-10-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * acinclude.m4 (LIBS): Fix memory leaks in GM_FUNC_MMAP_FILEIO
+       macro test-case so that it can be used successfully with ASAN
+       compilation options.
+
+       * magick/blob.c: Eliminate unused variable compiler warnings when
+       HAVE_MMAP_FILEIO is not defined.
+
+2016-10-24  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Ability to read multiple images from Matlab V4 format.
+
+2016-10-21 Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       *coders/png.c (ReadOneJNGImage): Enforce spec requirement that the
+       dimensions of the JPEG embedded in a JDAT chunk must match the
+       JHDR dimensions. This issue was assigned CVE-2016-9830 on
+       2016-12-04.  Please note that GraphicsMagick's pixel, width, and
+       height default limits are often greater than the dimension limits
+       of JNG and JPEG so the user should add explicit limits (if needed)
+       to prevent unexpected memory consumption from properly-constructed
+       JNG files with large dimensions.
+
+       *doc/options.imdoc (-strip): Added a caution to not use the -strip
+       option to remove author, copyright, and license information
+       when redistributing an image that requires them to be retained.
+
+       *doc/options.imdoc (-comment and -label): Document the fact that
+       only one comment or label is stored, and how they are stored in
+       PNG files.
+
+2016-10-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/sgi.c (ReadSGIImage): Adjusts some variable types and
+       lessen the amount of casting.
+
+2016-10-09 Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c (ReadJNGImage): Quiet COVERITY issue about
+       a potential memory leak.
+
+2016-10-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/xcf.c (ReadXCFImage): Fix memory leak of layer_info for
+       some recently added error-return paths.
+
+2016-10-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/sgi.c (ReadSGIImage): For RLE SGI image, defer memory
+       allocations for as long as possible and allow the file to prove
+       itself worthy before making the largest allocations.  This helps
+       with rejecting bogus RLE files while avoiding rejecting valid
+       files.
+
+2016-10-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tiff.c (ReadTIFFImage): If TIFF uses Old JPEG
+       compression, then read using full tiles or strips.  Solves
+       "Improper call to JPEG library in state 0. (LibJpeg)." error.
+       Problem was reported via email on October 6, 2016 by John Brown.
+
+2016-10-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/attribute.c (GenerateEXIFAttribute): Fixed SourceForge
+       bug 400 "Exif orientation unknown for some JPEG files".  Patch
+       submitted by Troy Patteson.
+
+2016-10-02  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/wpg.c Add sanity check for palette.  Merge
+       RemoveLastImageFromList+AppendImageToList to ReplaceImageInList.
+       Possible heap overflow of colormap in Q8 build was assigned
+       CVE-2016-7996.  Assertion crash due to blob != NULL was assigned
+       CVE-2016-7997.
+
+2016-10-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/meta.c (parse8BIM): Fix unsigned underflow leading to
+       heap overflow when parsing 8BIM chunk.  Problem was reported by
+       Marco Grassi via email on October 1, 2016.  Problem was already
+       known (but not fixed) based on comments in the code.  This issue
+       has been assigned CVE-2016-7800.
+
+2016-09-28  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/xcf.c: Improve the robustness of the XCF reader by adding
+       more error checking.
+
+2016-09-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/rle.c (RLEConstrainColormapIndex): Was not constraining
+       colormap index like it should be.  This problem was added on
+       2016-09-23.
+
+       * www/thanks.rst: Added Moshe Kaplan to Thanks.
+
+       * www/Hg.rst: Mercurial URL fixes.  Patch from Mark Mitchell.
+
+       * www/programming.rst: Updated programming APIs page.
+
+2016-09-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/pixel_cache.c (OpenCache): Trace ExtendCache() failures.
+
+2016-09-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/sgi.c (ReadSGIImage): Fix unexpectedly large memory
+       allocation with corrupt SGI file provided via email by Agostino
+       Sarubbo on September 15, 2016.
+
+       * coders/rle.c (ReadRLEImage): Only report an invalid colormap
+       index once.  Fixes slowness problem with corrupt file provided via
+       email by Agostino Sarubbo on September 15, 2016.
+
+2016-09-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * www/thanks.rst: Added a 'thanks' page.
+
+2016-09-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * PerlMagick/MANIFEST: Fix content of PerlMagick MANIFEST.
+
+2016-09-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pcx.c (ReadPCXImage): Check that filesize is reasonable
+       given header.  Fixes excessive memory allocation followed by
+       eventual file truncation error for corrupt file.  Problem was
+       reported via email by Agostino Sarubbo on 2016-09-10.
+
+       * coders/sgi.c (ReadSGIImage): Check that filesize is reasonable
+       given header.  Fixes excessive memory allocation followed by
+       eventual file truncation error for corrupt file.  Problem was
+       reported via email by Agostino Sarubbo on 2016-09-09.
+
+       * coders/sct.c (ReadSCTImage): Fix stack-buffer read overflow
+       while reading SCT header.  Problem was reported via email by
+       Agostino Sarubbo on 2016-09-09.
+
+       * coders/svg.c: Fix Coverity issue 135772 "RESOURCE_LEAK" and
+       issue 135829 "Null pointer dereferences".  None of these issues
+       were new, but Coverity noticed them now.  Reflowed source to GNU C
+       style for consistent indentation and so it does not fight with my
+       editor.
+
+2016-09-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/common.h (MAGICK_HAS_ATTRIBUTE): Coverity is allergic to
+       __has_attribute() so don't use it for Coverity builds.
+
+2016-09-05  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * www/index.rst: Update for 1.3.25 release.
+
+       * version.sh: Update library versioning for 1.3.25 release.
+
+       * NEWS.txt: Make sure is up to date.
+
+       * Various fixes for minor issues noticed when compiling under
+       Visual Studio.
+
+2016-08-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/studio.h (MAGICK_CACHE_LINE_SIZE): Apply patch from
+       Gentoo Linux to increase MAGICK_CACHE_LINE_SIZE to 128 when
+       __powerpc__ is defined.
+
+2016-08-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * NEWS.txt: Updated with latest changes.
+
+2016-08-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/rle.c (ReadRLEImage): Reject truncated/absurd Utah RLE
+       files. Problem was reported by Agostino Sarubbo on August 19,
+       2016.  This problem was assigned CVE-2016-7448 after the 1.3.25
+       release.
+
+2016-08-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tiff.c (ReadTIFFImage): Fix heap-based buffer read
+       overflow.  TIFF sized attibutes were not being properly copied to
+       a null-terminated string if the value was not null terminated.
+       Problem was reported by Agostino Sarubbo on August 18, 2016.  This
+       problem was assigned CVE-2016-7449 after the 1.3.25 release.
+
+2016-08-15  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * lcms/src/cmstypes.c (Type_MLU_Read): "Added an extra check to
+       MLU bounds", change based on github mm2/Little-CMS commit
+       5ca71a7bc18b6897ab21d815d15e218e204581e2 and announced to the
+       oss-security list by Ibrahim M. El-Sayed on Mon, 15 Aug 2016.
+
+2016-08-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * webp: Updated bundled libwebp to release 0.5.1.
+
+       * libxml: Updated bundled libxml2 to release 2.9.4.
+
+       * lcms: Updated bundled lcms2 to release 2.8.
+
+       * png: Update bundled libpng to release 1.6.24.
+
+       * coders/jpeg.c (ReadJPEGImage): Log setting resolution and
+       resolution units due to JFIF marker.
+
+       * coders/sgi.c (SGIDecode): Fix integer overflow of size type in
+       Win64 build where sizeof(long) < sizeof(size_t).
+
+2016-08-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders, magick: Compile clean using GCC with -std=c90.
+
+       * magick/describe.c (DescribeImage): The 'identify' and 'info'
+       functionality only shows the pixel read rate if image was not read
+       in 'ping' mode.  Provide seconds timing with 6 digits of precision
+       since that is what is needed.
+
+2016-08-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/describe.c (DescribeImage): Include milliseconds
+       resolution in elapsed time output.
+
+       * magick/timer.c (ElapsedTime): Use clock_gettime() (when
+       available with default linkage) to obtain elapsed time.
+
+2016-08-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/yuv.c (WriteYUVImage): Fix benign clang compiler warning
+       regarding "variable 'x' is incremented both in the loop header and
+       in the loop body".
+
+       * configure.ac: Fixes to use clang's OpenMP runtime library
+       (-lomp) for clang 3.8 and later.  Specifically tested with clang
+       3.8 on Ubuntu 16.04 'xenial'.  Problem was reported by Holger
+       Hoffstätte via private email.
+
+       * NEWS.txt: Bring up to date with latest changes.
+
+2016-07-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (DrawImage): Reject abnormally absurd gradient
+       size requests (many absurd requests are still allowed).  Provide
+       detailed error reports when a gradient is rejected.
+
+       * coders/svg.c: Support units for 'stroke-dashoffset'.
+
+2016-07-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/annotate.c (EscapeParenthesis): In private email on
+       2016-07-07, Gustavo Grieco notified us of a heap overflow in
+       EscapeParenthesis().  I was not able to reproduce the issue but
+       changed the implementation with the suspicion that the
+       implementation has a bug, and due to noticing arbitary limits and
+       inefficiency.  This issue was assigned CVE-2016-7447 after the
+       1.3.25 release.
+
+2016-07-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (DrawImage): Fix absolute and arbitrary gradient
+       dimension sanity checks which caused gradient requests to fail.
+       Resolves SourceForge issue #392 "SVG 'push defs' fails (Debian
+       bugs 829063 and 828120)".
+
+2016-06-16  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * www/security.rst: Add discussion of SVG format and SSRF
+       vulnerability.
+
+2016-06-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/svg.c (ReadSVGImage): Assure that SVGInfo data is freed
+       when XMP parsing is aborted due to an error.
+
+2016-06-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * NEWS.txt: Updated NEWS with changes since last release.
+
+       * www/security.rst: Add a page about GraphicsMagick security.
+
+2016-06-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (DrawPrimitive): Over-aggressive error reporting
+       was causing failures when elements were "drawn" off-image.
+       Resolves SourceForge issue #389 "Non-conforming drawing primitive
+       definition (line)".
+
+2016-05-31  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (DrawImage): Fix problem while reading file
+       "tnamkejarz.svg.2532308010849170049" provided via private email
+       from Gustavo Grieco on May 31, 2016.
+
+       * magick/utility.c (MagickGetToken): Fix problem while reading
+       file "vqxwatmqmi.svg.-3669039972557308254" provided via private
+       email from Gustavo Grieco on May 31, 2016.
+
+2016-05-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * NEWS.txt: Update for 1.3.24 release.
+
+       * www/Changes.rst: Mention 1.3.24 release.
+
+       * www/index.rst: Update for 1.3.24 release.
+
+       * version.sh: Update library ABI information in preparation for
+       1.3.24 release.
+
+       * NEWS.txt: Updated NEWS to reflect fixes and issues.
+
+2016-05-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * NEWS.txt: Updated with latest news.
+
+       * magick/blob.c (OpenBlob): Remove support for reading input from
+       a shell command, or writing output to a shell command, by
+       prefixing the specified filename (containing the command) with a
+       '|'.  This feature provided a remote shell execution opportunity
+       (CVE-2016-5118).
+
+       * coders/mat.c (ReadMATImage): Validate that MAT frames is not
+       zero.
+
+2016-05-28  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (DrawImage): Be less optimistic when estimating
+       the number of points required to represent a path.  This should
+       help address CVE-2016-2317 "Heap buffer overflow".  This resolves
+       SourceForge issue #275 "Applying Clipping Path to high resolution
+       JPG".
+
+2016-05-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (DrawImage): Fix problem while reading file
+       "pxypjhfdxf.svg.7406476585885697806" provided via via private
+       email from Gustavo Grieco on May 24, 2016.
+
+       * coders/svg.c: Fix problem while reading file
+       "pxypjhfdxf.svg.308008972284643989" provided via private email
+       from Gustavo Grieco on May 24, 2016.
+
+2016-05-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/svg.c ("C"): Support font-size "medium".
+
+2016-05-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * NEWS.txt: Updated NEWS.txt to reflect latest changes.
+
+       * magick/render.c (DrawImage): Added DrawImage() recursion
+       detection/prevention.
+
+       * coders/svg.c (ReadSVGImage): Add basic primitive argument
+       validation.
+
+       * magick/render.c (DrawImage): Add basic primitive argument
+       validation.
+
+2016-05-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/url.c (ReadURLImage): Reading "file://" URLs was not
+       working.  Now file URLs are working.
+
+2016-05-21  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Respect JPEG limits (65535x65535) and user width
+       and height limits from "-limit" while reading or writing JNG files.
+
+2016-05-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/url.c: Don't hide HTTP, FTP, and FILE URL support from
+       '-list format' output.  Ignore HTTP, FTP, and FILE as a useful
+       file extension for determing the file format.
+
+2016-05-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (ConvertPathToPolygon): Make sure that first
+       edge is initialized.  Make sure that points is not null.
+
+2016-05-15  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (DrawImage): Fixed segmentation violation while
+       reading file "275077586554139424.lqxdgqxtfs.svg" provided via
+       private email from Gustavo Grieco on May 15, 2016.  This is due to
+       another CVE-2016-2317 related issue.
+
+2016-05-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/svg.c ("C"): Fixed problems while reading files
+       "aaphrbkwwe.svg.-1899680443073025602",
+       "aaphrbkwwe.svg.-5751004588641220738",
+       "aaphrbkwwe.svg.-8875730334406147537", and
+       "aaphrbkwwe.svg.4495884156523242589" provided via private email
+       from Gustavo Grieco on February 8, 2016.
+
+2016-05-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dib.c (ReadDIBImage): Verify that DIB file data is
+       sufficient to meet claims made by file header.  Validate image
+       planes.  Fixes Fixes problem reported by Hanno Böck on May 8th,
+       2016 via private email entitled "malloc issue in ReadDIBImage".
+
+2016-05-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/msl.c (RegisterMSLImage): Ignore the file extension on
+       MSL files.  The only way to read an image from a MSL file (as
+       opposed to explicitly running a MSL script with 'conjure') is by
+       reading using a filename specification like "msl:filename".  This
+       is done for security reasons.
+
+       * magick/render.c (DrawPrimitive): Fix Coverity issue 126378
+       "Resource leak".
+
+       * coders/mat.c (DecompressBlock): Fix Coverity issue 126379
+       "Resource leak".
+
+       * magick/render.c (DrawImage): Fix Coverity issue 126380 "Resource
+       leak".
+
+2016-05-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (DrawPrimitive): Sanity check the image file
+       path or URL before passing it to ReadImage().
+
+       * config/delegates.mgk.in: Pare down delegates.mgk to reduce
+       security exposure due to external programs not under our control.
+
+2016-05-08  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Typo fix - matrix has nothing to do with PostScript.
+
+2016-05-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/mat.c (DecompressBlock): Don't hang on a corrupt deflate
+       stream when reading matlab v6 file.  Fixes problem reported by
+       Hanno Böck on May 8, 2016 via private email entitled "hang of
+       matlab input file".
+
+2016-05-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/image.c (SetImageInfo): Undocumented "TMP" magick prefix
+       no longer removes the argument file after it has been read. This
+       functionality is only used to support the "show" delegate which is
+       used by options in the 'display' program which need to display a
+       generated image in a new instance of 'display'.  The "show"
+       delegate is used by writing a temporary file to be viewed, and
+       which should be removed before the program quits.  Since the "TMP"
+       feature was originally implemented, GraphicsMagick added a
+       temporary file management subsystem which assures that temporary
+       files are removed so this feature is not needed.
+
+       * coders/tiff.c (ReadTIFFImage): Fix heap overflow with file
+       "gkkxrilssm.tiff.-4678010562506843336" provided by Gustavo Grieco
+       on February 8, 2006 via private email.
+
+       * coders/viff.c (ReadVIFFImage): Fix problem with a very large
+       malloc in sample file provided by Hanno Böck on May 7, 2016 with
+       subject "large malloc in ReadVIFFImage".
+
+       * coders/mvg.c (RegisterMVGImage): Do not auto-detect MVG format
+       based on file extension.  MVG files can then only be read by
+       adding a "MVG:" prefix to the file name. There is already no
+       auto-detection of MVG based on content.
+
+2016-05-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/xpm.c (ReadXPMImage): Limit the number of XPM colors and
+       assure array initialization.  Fixes bad behavior with a sample
+       file provided by Hanno Böck on May 6, 2016 with subject "Invalid
+       free in ReadXPMImage".
+
+       * coders/pcx.c (ReadPCXImage): Limit the number of PCX image
+       planes allowed.  Fixes an unreasonable memory allocation in a
+       sample file provided by Hanno Böck on May 5, 2016.
+
+2016-05-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * config/delegates.mgk.in: Gnuplot files are inherently insecure.
+       Remove delegates support for reading them.  Reported by John
+       Lightsey via private email.
+       Added -dSAFER to Ghostscript invokations in delegates.mgk for more
+       secure execution.  Reported by David Chan via SourceForge bug
+       "#386 ghostscript delegates should explicitly use -dSAFER.".
+
+       * magick/constitute.c (ReadImages): Avoid possible infinite
+       ReadImage() recursion.
+
+2016-05-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (DrawPolygonPrimitive): Fix divide by zero
+       exception encountered while reading file "sigfpe.svg" posted by
+       Gustavo Grieco on May 1, 2016 to the oss-security mailing list
+       with subject "CVE request: DoS in multiple versions of
+       GraphicsMagick".
+       (DrawDashPolygon): Fix endless loop problem caused by negative
+       stroke-dasharray arguments.  Resolves problem observed while
+       reading file "circular.svg" posted by Gustavo Grieco on May 1,
+       2016 to the oss-security mailing list with subject "CVE request:
+       DoS in multiple versions of GraphicsMagick".
+
+       * magick/import.c (ImportViewPixelArea): Fix assertion while
+       reading TIFF file gkkxrilssm.tiff.105123337066 provided by Gustavo
+       Grieco.
+
+2016-04-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/locale.c (ReadLOCALEImage): Make sure to close blob
+       before returning.
+
+       * coders/svg.c ("C"): Provide a hack work-around for double-quoted
+       font-family argument.
+
+       * magick/render.c (DrawImage): Make SVG path and other primitive
+       parsing more robust.  Fixes SEGV when reading files provided by
+       CVE-2016-2318 test cases.  Fixes CVE-2016-2318 completely.
+
+2016-04-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (DrawImage): Fix heap buffer overflow when
+       reading aaphrbkwwe.svg.-1114777018469422437 from CVE-2016-2317
+       test cases.  This resolves CVE-2016-2317 completely.
+
+2016-04-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/command.c (MogrifyImageCommand): Added mogrify
+       -preserve-timestamp option to preserve file access and
+       modification timestamps.  Contributed by Niko Rosvall via
+       SourceForge patch #45 "preserve-timestamp option for mogrify
+       command."
+
+2016-04-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/blob.c: Added ReadBlobLSBSignedShort(),
+       ReadBlobMSBSignedShort(),
+       ReadBlobLSBSignedLong(),ReadBlobMSBSignedLong(),
+       WriteBlobLSBSignedShort(), WriteBlobLSBSignedLong(),
+       WriteBlobMSBSignedLong(), WriteBlobMSBSignedShort() for doing I/O
+       on signed integer types without the need for dangerous casts or
+       unexpected values due to signed/unsigned conversion.
+
+2016-04-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * NEWS.txt: Updated with latest changes.
+
+       * magick/constitute.c (ReadImage): Added asserts to check that the
+       I/O blob is not still open in the returned image since this causes
+       problems.
+
+       * magick/blob.c (CloneBlobInfo): Use a cloning approach which does
+       not require manually keeping structure members in sync.
+
+       * coders/msl.c (ProcessMSLScript): Need to close I/O blob before
+       returning.
+
+       * coders/psd.c (ReadPSDImage): Assure that allocated image is not
+       dereferenced before checking if it is NULL.  Check some memory
+       calculations for overflow.
+       (ReadPSDImage): Need to close I/O blob before returning.
+
+       * coders/dib.c (ReadDIBImage): Use DestroyBlob() rather than
+       DestroyBlobInfo().
+
+       * coders/bmp.c (ReadBMPImage): Use DestroyBlob() rather than
+       DestroyBlobInfo().
+
+       * magick/blob.c: Improve blob tracing.
+
+2016-04-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/bmp.c (ReadBMPImage): Fix reading 24-bit Microsoft BMP
+       which claims to have a colormap.
+
+2016-04-13 Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * PerlMagick/t/input_complex_lsb_double_V4.mat Demo Matlab V4
+       complex file.
+       * coders/mat.c Missing break added.
+
+2016-04-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/xpm.c (ReadXPMImage): Fix SourceForge issue #361
+       "out-of-bounds read in coders/xpm.c:150:24"
+
+       * coders/psd.c (ReadPSDImage): Add some defensive code to assure
+       that image layers are not freed twice.
+
+2016-04-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/log.c (InitializeLogInfo): Simplify LogInfo structure and
+       its allocation in order to lessen the amount of fixed overhead.
+
+2016-04-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/jp2.c (WriteJP2Image): Fix SourceForge issue #378 "jp2:
+       impossible to create lossless jpeg-2000".  With this fix,
+       specifying 'define jp2:rate=1.0' or '-quality 100' results in a
+       lossless JP2 file.
+
+2016-04-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/common.h: Update for GCC 5.
+
+       * PerlMagick/MANIFEST: Update PerlMagick manifest.
+
+       * PerlMagick/t/{read.t, write.t}: Add tests for MAT v4.
+
+2016-04-03 Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Matlab V4 attempt to read complex part of data.
+
+2016-04-02  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * PerlMagick/t/features.pl.in: Provide a way that PerlMagick
+       feature tests can test if a feature is supported.  Use it to make
+       the PSD test optional.
+
+       * coders/Makefile.am: Only build PSD module if
+       ENABLE_BROKEN_CODERS is enabled.
+
+       * magick/module.c (UnloadModule): Only invoke the module
+       unregister function if it is defined.  The module register
+       function is not defined if either the register or unregister
+       functions were not found in the module which was loaded.
+
+2016-04-02 Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Matlab V4 files are also rotated.
+        * PerlMagick/t/input_gray_lsb_double_V4.mat   Demo Matlab V4 file.
+
+2016-04-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/magick.c (GetMagickInfo): Only declare that ExceptionInfo
+       argument is not used if modules are not supported.
+
+2016-03-28 Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Attempt to read Matlab V4 files.
+
+2016-03-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/image.c (DestroyImage): Simply return if image is NULL
+       since it is more user-friendly.
+
+       * magick/shear.c (RotateImage): Fix Coverity issue 124519
+       "Logically dead code".
+
+       * magick/effect.c (BlurImage): Fix Coverity issue 124520
+       "Dereference after null check".
+
+       * coders/pdb.c (WritePDBImage): Fix SourceForge bug #360
+       "out-of-bounds read in utilities/gm+0x80fcc71) (PDB reader)".
+
+       * coders/meta.c (convertHTMLcodes): Fix SourceForge bug #373
+       "out-of-bounds read in coders/meta.c:444:50"
+       (ReadMETAImage): Fix SourceForge bug #364 "out-of-bounds write in
+       coders/meta.c:1331:7".
+
+2016-03-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/sgi.c (ReadSGIImage): Fix SourceForge bug #366
+       "out-of-bounds write in coders/sgi.c:528:4" and bug #369
+       "out-of-bounds write in coders/sgi.c:535:4".
+
+       * coders/rle.c (ReadRLEImage): Fix SourceForge bug #371
+       "out-of-bounds read in coders/rle.c:633:39".
+
+2016-03-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dib.c (ReadDIBImage): Fix SourceForge bug #367
+       "out-of-bounds read in coders/dib.c:706:13" and bug #370
+       "out-of-bounds read in coders/dib.c:716:15".
+
+       * coders/pict.c (ReadPICTImage): Fix SourceForge bug #365
+       "out-of-bounds read in magick/image.c:1305:3"
+
+       * magick/utility.c (GetPageGeometry): Fix SourceForge bug #374
+       "out-of-bounds write in magick/utility.c:4355:7"
+
+2016-03-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/miff.c (ReadMIFFImage): Fix SourceForge bug #376 "SIGABRT
+       in magick/colorspace.c:1052".
+
+       * magick/shear.c (RotateImage): Fix SourceForge bug #375 "SIGABRT
+       in magick/image.c:1230".
+
+       * coders/sun.c (DecodeImage): Fix SourceForge bug #368
+       "out-of-bounds read in coders/sun.c:223:17" and bug #363
+       "out-of-bounds read in coders/sun.c:221:16".
+
+2016-03-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/svg.c (GetUserSpaceCoordinateValue): Fix stack buffer
+       overflow when reading file 'aaphrbkwwe.svg.-632425326915265752'
+       from CVE-2016-2317 problem files.  Partial fix for SourceForge bug
+       #358 "CVE-2016-2317 - SVG heap/stack buffer overflows".
+
+       * magick/utility.c (MagickGetToken): New private function to
+       replace GetToken().  The new function accepts a token buffer
+       length argument.  GetToken() is modified to assume a token buffer
+       length 'MaxTextExtent'.  All code using GetToken() is updated to
+       use MagickGetToken().
+
+       * coders/svg.c: Fix heap buffer overflow when reading file
+       "aaphrbkwwe.svg.4495884156523242589" from CVE-2016-2317 problem
+       files.  Partial fix for SourceForge bug #358 "CVE-2016-2317 - SVG
+       heap/stack buffer overflows".
+
+2016-03-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/psd.c (ReadPSDImage): Fix SourceForge bug #341
+       "out-of-bounds read in coders/psd.c:1435".
+       (WriteWhiteBackground): Fix SourceForge bug #350 "SEGV in
+       coders/psd.c:1685".
+       (DecodeImage): Fix SourceForge bug #351 "heap-buffer-overflow in
+       coders/psd.c:142".
+       (ReadPSDImage): Fix SourceForge bug #342 "out-of-bounds write in
+       coders/psd.c:892"
+
+       * coders/xcf.c (load_tile): Fix SourceForge bug #337
+       "heap-buffer-overflow in coders/xcf.c:373".
+
+       * coders/pict.c (WritePICTImage): Fix SourceForge bug #340
+       "out-of-bounds write in coders/pict.c:1929".
+
+       * coders/pdb.c (WritePDBImage): Fix SourceForge bug #348
+       "heap-buffer-overflow in coders/pdb.c:949:26".
+
+       * coders/xpm.c (ReadXPMImage): Fix SourceForge bug #334
+       "heap-buffer-overflow in coders/xpm.c:150".
+
+2016-03-09 Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Fixed huge image limitation.
+
+2016-03-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/sun.c (WriteSUNImage): Fix SourceForge bug #343
+       "out-of-bounds write in coders/sun.c:962".
+
+       * coders/rle.c (ReadRLEImage): Fix SourceForge bug #344
+       "out-of-bounds write in coders/rle.c:524".
+
+       * coders/xpm.c (ReadXPMImage): Fix SourceForge bug #335
+       "out-of-bounds read in coders/xpm.c:154 ".
+
+2016-03-06  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * doc/options.imdoc (-extent): Revised the example to
+       clarify the interaction of -gravity with the "geometry" offsets.
+
+2016-03-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * configure.ac: Add support for --enable-broken-coders which
+       determines if broken or hazardous file format support should be
+       enabled in the build.  Currently Adobe Photoshop (PSD) format is
+       included in this category.
+
+       * Rotate Changelog for new year.  Update documentation copyrights
+       for new year.
+
+2016-03-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * tiff/libtiff/tif_config.h (HAVE_SNPRINTF): Define HAVE_SNPRINTF
+       when using Microsoft Visual C++ 14 (Visual Studio 2015) or later.
+       This is based on advice by Pablo Elpuro.
+
+2016-02-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * Magick++/lib/Image.cpp (xResolution): New method to support
+       setting the horizontal resolution with double precision.
+       (yResolution): New method to support setting the vertical
+       resolution with double precision.
+
+       * www/Hg.rst: Document the ssh public keys for the server hosting
+       the development Mercurial repository.
+
+2016-02-16  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/xpm.c (ReadXPMImage): Fix SourceForge bug #333
+       heap-buffer-overflow in coders/xpm.c:409.
+
diff --git a/ChangeLog.2017 b/ChangeLog.2017
new file mode 100644 (file)
index 0000000..60bd8f1
--- /dev/null
@@ -0,0 +1,1108 @@
+2017-12-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * tests/rwfile.tap: Add tests for MIFF compressed sub-formats.
+
+2017-12-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/blob.c (OpenBlob): Zlib 1.2.8 does not accept an open
+       mode of "w+b" or "wb+".  It seems to be allergic to '+'.  As a
+       result, writing to ".gz" files was not working with Zlib 1.2.8.
+       Note that "w+b" must be used in the normal case since the test
+       suite fails otherwise!
+
+2017-12-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadMNGImage): Fix SourceForge issue #535
+       "heap-buffer-overflow in ReadMNGImage".  Problem was caused by
+       accessing byte before testing that limit has been reached, rather
+       than testing for limit before accessing the byte.  This means that
+       it could only ever read one past the buffer allocation size.
+
+       * coders/webp.c (WriteWEBPImage): Fix SourceForge issue #536
+       "stack-buffer-overflow in WriteWEBPImage".  Due to a change to use
+       WebPMemoryWriter as part of the EXIF and ICC profile support
+       addition (enabled with libwebp 0.5.0), the progress indicator
+       callback is now passed a pointer to a wrong structure.  This is
+       quite unfortunate since the progress indication is useful.  The
+       progress indication is temporarily disabled when the
+       WebPMemoryWriter is in use until a solution is implemented.
+       (ProgressCallback): Re-implement progress callback so that image
+       pointer is stored/retrieved as thread-specific data.
+
+       * coders/png.c (ReadMNGImage): Fix SourceForge issue #537 "null
+       pointer dereference in ReadMNGImage".  DEFI chunk must be at least
+       2 bytes long.
+
+       * coders/tiff.c (ReadNewsProfile): Fix SourceForge issue #533
+       "heap-buffer-overflow on LocaleNCompare".  LocaleNCompare() was
+       being allowed to read heap data beyond the allocated region.
+
+2017-12-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/shear.c (IntegralRotateImage): Assure that reported error
+       in rotate by 270 case does immediately terminate processing.
+       Return a NULL Image pointer if there is a problem rather than a
+       corrupted image.  Fix is related to SourceForge issue #532
+       "heap-buffer-overflow bug in ReadWPGImage".
+
+       * magick/pixel_cache.c (AcquireCacheNexus): Add a check that the
+       pixel cache is compatible with the image dimensions.  Fix is
+       related to SourceForge issue #532 "heap-buffer-overflow bug in
+       ReadWPGImage".
+
+2017-12-16  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJNGImage): Fix SourceForge issue #530
+       "heap-buffer-overflow in ReadOneJNGImage".  In this case there is
+       a read one byte beyond the oFFs chunk allocation size due to an
+       error in specifying an offset into the chunk.
+
+       * coders/palm.c (ReadPALMImage): Fix SourceForge issue #529
+       "global-buffer-overflow in ReadPALMImage".  This issue only
+       occured in builds with QuantumDepth=8 due to the small range of
+       IndexPacket.
+
+2017-12-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * PerlMagick/{Magick.pm, Magick.pm.in, Makefile.PL.in}: Only base
+       PerlMagick version on numeric portion of PACKAGE_VERSION.
+
+2017-12-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * www/index.rst: Update to 1.3.27.
+
+       * www/Changes.rst: Add 1.3.27
+
+       * version.sh: Update library versioning.
+
+       * NEWS.txt: Update NEWS in preparation for releasing 1.3.27.
+
+2017-12-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dcm.c (DCM_ReadElement): Change size checks addressing
+       CVE-2017-12140 to be based on size_t rather than magick_off_t due
+       to apparent instability of the previous check across compilers.
+
+2017-12-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (WriteOnePNGImage): Fix heap read access outside of
+       allocated PixelPacket array while testing pixels for opacity.
+       Resolves SourceForge issue #526 "heap-buffer-overflow in
+       WriteOnePNGImage".
+
+2017-12-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pnm.c (WritePNMImage): Fix SourceForge bug #525
+       "heap-buffer-overflow in MagickBitStreamMSBWrite".
+
+2017-12-05  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dcm.c (DCM_ReadElement): Eliminate huge memory allocation
+       based on bogus length value. Addresses CVE-2017-12140. Problem was
+       reported via email from Petr Gajdos on Tue, 5 Dec 2017.
+
+2017-12-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * Magick++/lib/Image.cpp (colorMap): Try to eliminate Coverity CID
+       172796 "Dereference after null check" which seems to be bogus.
+
+       * coders/png.c (WriteOnePNGImage): Fix Coverity CID 168053
+       "Dereference after null check".  The check for null and the error
+       report which attempted to use the null value was not needed at
+       all.
+
+       * coders/cut.c (GetCutColors): Fix Coverity CID 10181: "Null
+       pointer dereferences". SetImagePixels() may return NULL.
+
+       * coders/rgb.c (ReadRGBImage): Fix SourceForge issue #523
+       "heap-buffer-overflow".  Similar issue to cmyk.c.
+
+       * coders/gray.c (ReadGRAYImage): Fix SourceForge issue #522
+       "heap-buffer-overflow".  Similar issue to cmyk.c.
+
+       * coders/cmyk.c (ReadCMYKImage): Fix SourceForge issue #521
+       "heap-buffer-overflow". The requested tile must be within the
+       bounds of the image.  As it happens, 'montage' passes size and
+       tile information which is useless for reading a raw image so it is
+       not possible to read raw CMYK using 'montage'.
+
+2017-12-02  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pwp.c (ReadPWPImage): Eliminate dereference of null image
+       pointer.  Addresses CVE-2017-11640.  Also address access to
+       uninitialized memory.  Problem was reported via email from Petr
+       Gajdos on Wed, 29 Nov 2017.
+
+2017-11-22  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/wpg.c Additional check for wrong bpp CVE-2017-14342.
+
+
+2017-11-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * Magick++/lib/Image.cpp (autoOrient): Add method to auto-orient
+       an image so it looks right-side up by default.  Based on patch by
+       Przemysław Sobala submitted as SourceForge patch #53 "Add
+       Magick::Image::autoOrient() method to Magick++ library".
+
+       * www/download.rst: Change "Czechoslovakian ftp mirror" to "Czech
+       ftp mirror".  Resolves SourceForge bug #520 "[web] Download sites:
+       non-existent country".
+
+2017-11-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/wpg.c (ReadWPGImage): Fix excessive use of disk resources
+       due to unreasonable record length.  Addresses CVE-2017-14341.
+       Notified of this issue (with suggested patch) via email by Petr
+       Gajdos on Tue, 21 Nov 2017.
+
+2017-11-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * README.txt: Comprehensive white-space clean-up across
+       GraphicsMagick core source files.  Hard TAB character is converted
+       to spaces.  Trailing white-space garbage is stripped.
+
+       * magick/colormap.c (MagickConstrainColormapIndex): Deprecate use
+       of MagickConstrainColormapIndex() and prefer use of
+       VerifyColormapIndex() and VerifyColormapIndexWithColors() due to
+       avoiding dependence on index type, allowing provision of colors
+       other than image->colors, and capturing more useful source file
+       and line information.
+
+       * coders/{rle.c, mat.c, xbm.c, sgi.c, png.c}: Eliminate size_t vs
+       unsigned 32 conversion warnings in WIN64 build.
+
+2017-11-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * tiff: Import libtiff 4.0.9.
+
+2017-11-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/bmp.c (DecodeImage): "Right-size" and "Right-type"
+       DecodeImage() variables and check for EOF at every point of the
+       way.  Pass buffer size as an argument.
+
+       * coders/dib.c (DecodeImage): "Right-size" and "Right-type"
+       DecodeImage() variables and check for EOF at every point of the
+       way.  Pass buffer size as an argument.
+
+       * coders/bmp.c (_BMPInfo): "Right-size" BMPInfo members.  The
+       'long' type is promoted to 64-bit on LP64 systems and the large
+       size is not needed.
+
+2017-11-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/webp.c: Incorporate patch by Jan Spitalnik to add EXIF
+       and ICC metadata support to the WebP coder.  While WebP is still
+       supported back to libwebp 0.1.99, the metadata support requires at
+       least libwebp 0.5.0.  Resolves SourceForge patch #52 "Add EXIF/ICC
+       metadata support to WebP coder".
+
+       * coders/png.c (ReadOneJNGImage): Fix JNG memory leaks when JPEG
+       image fails to be read.
+       (WriteOnePNGImage): Promotion of indexed PNG to RGBA lacked
+       setting of image matte, resulting in undersized buffer allocation
+       and heap overflow.  Fixes SourceForge bug #453 "Heap overflow in
+       source-gra/coders/png.c".
+
+2017-11-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/sfw.c (SFWScan): Fix heap buffer overflow
+       (CVE-2017-13134).  Notified of problem via email (including a
+       patch) from Petr Gajdos on Mon, 6 Nov 2017.
+
+2017-11-05  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/wpg.c Wrong MaxMap check condition - fixed.
+
+2017-11-04  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/wpg.c Check for InsertRow() return value.
+
+2017-11-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/export.c: Add not-null check for indexes pointer where
+       needed.
+
+       * magick/import.c: Add not-null check for indexes pointer with
+       associated exception report where the indexes pointer is needed.
+       (ImportCMYKQuantumType): Was wrongly importing an opacity channel
+       in some cases. Would have crashed if these cases were ever used.
+
+       * coders/wpg.c (ReadWPGImage): Assure that colormapped image is a
+       PseudoClass type with valid colormapped indexes.  Fixes
+       SourceForge bug 519 "Null Pointer Dereference (Write) with
+       malformed WPG Image".
+
+       * coders/sfw.c (ReadSFWImage): Avoid possible heap overflow while
+       copying JFIF magic into buffer. Reject runt files.  Fixes
+       CVE-2017-12983.  Notified of problem via email from Petr Gajdos on
+       Thu, 2 Nov 2017.
+
+2017-10-28  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (DrawImage): Fix SourceForge bug #517 "Push
+       operations in DrawImage can lead to negative strncpy when looking
+       for pop".  Interestingly, valgrind and ASAN only detected a
+       problem with one of the test cases since exercised code which
+       updated an array using the index.  It appears that Linux strncpy()
+       simply ignores the bad request.
+
+2017-10-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJNGImage): Make sure that a reasonable
+       exception is reported to the user when there is a read failure.
+
+2017-10-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJNGImage): Reject JNG files with
+       unreasonable dimensions given the file size.
+
+2017-10-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJNGImage): Fix SourceForge bug #518 "Null
+       pointer in".  Also make sure that errors are reported properly due
+       to problems with transferring JPEG scanlines.
+       (ReadOneJNGImage): Add more checks for null value returned from
+       SetImagePixels().
+
+2017-10-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/describe.c (DescribeImage): Fix possible heap read
+       overflow while accessing heap data, and possible information
+       disclosure while describing the IPTC profile.  Report was provided
+       via email from Maor Shwartz to the graphicsmagick-security mail
+       alias on Thu, 19 Oct 2017.  Independent security researchers,
+       Jeremy Heng (@nn_amon) and Terry Chia (Ayrx), reported this
+       vulnerability to Beyond Security’s SecuriTeam Secure Disclosure
+       program. Please note that this interface is usually (but not
+       exclusively) used from within the command-line utility program, in
+       which case there is not much useful information which might be
+       disclosed.
+       (DescribeImage): Fix possible heap write overflow when describing
+       visual image directory.  Report was provided via email from Maor
+       Shwartz to the graphicsmagick-security mail alias on Thu, 19 Oct
+       2017.  Independent security researchers, Jeremy Heng (@nn_amon)
+       and Terry Chia (Ayrx), reported this vulnerability to Beyond
+       Security’s SecuriTeam Secure Disclosure program. Please note that
+       this interface is usually (but not exclusively) used from within
+       the command-line utility program, in which case the only harm
+       would be a program crash.
+
+       * magick/constitute.c (WriteImage): Assure that the errno present
+       when the blob error status first occured is reported to the user.
+
+       * magick/blob.c (GetBlobStatus): Blob error status is now updated
+       immediately upon the first error reported.
+       (GetBlobFirstErrno): Returns errno value when the first blob error
+       was reported.  This is useful for error reporting.
+
+2017-10-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/constitute.c (WriteImage): Restore use of GetBlobStatus()
+       to test if an I/O error was encountered while writing output file.
+       This assures that I/O failure in writers which do not themselves
+       verify writes is assured to be reported.
+
+2017-10-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/webp.c (WriterCallback): WebP writer now detects partial
+       write to output file.  Patch by Przemysław Sobala from a posting
+       on Mon, 16 Oct 2017 via the graphicsmagick-help mailing list.
+
+2017-10-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/command.c (MontageImageCommand): Fix memory leaks in
+       error return path.  Only people doing leak testing or the few who
+       execute MontageImageCommand() as a function will care about this.
+
+       * magick/studio.h (NumberOfObjectsInArray): The
+       NumberOfObjectsInArray() macro is used to compute the number of
+       whole objects in an array.  Instead it was rounding up, resulting
+       in scrambling the heap beyond the allocation.  Fixes
+       CVE-2017-13737 "There is an invalid free in the MagickFree
+       function in magick/memory.c in GraphicsMagick 1.3.26 that will
+       lead to a remote denial of service attack."
+
+2017-10-09  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOnePNGImage): Suppress "comparison between
+       signed and unsigned integer expressions" warning.
+       * coders/png.c (ReadJNGImage): Fix memory leak in SourceForge
+       Issue #469 "use after free in ReadJNGImage".
+       * coders/png.c (ReadJNGImage): Fix memory leak in SourceForge
+       Issue #470 "Assert failure in writeblob".
+
+2017-10-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * doc/options.imdoc: Fix SourceForge issue #444 "gm mogrify: Wrong
+       documentation for option -output-directory".
+
+2017-10-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/module.c (InitializeModuleSearchPath): Verify that any
+       component paths specified in MAGICK_CODER_MODULE_PATH and
+       MAGICK_FILTER_MODULE_PATH exist before adding them to search paths
+       actually used, and convert to real paths if possible.  This avoids
+       possible use of relative paths to load modules (a possible
+       security issue) and may improve efficiency by removing
+       non-existent paths.
+
+       * coders/yuv.c (ReadYUVImage): Fix leak of scanline upon Image
+       allocation failure.  Patch submitted by Petr Gajdos via email on
+       Fri, 6 Oct 2017.
+
+2017-09-13  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Attempt to fix SourceForge Issue #469 "use after
+       free in ReadJNGImage".  Note that this change was found to replace
+       a use after free with a memory leak so the problem is not solved
+       yet.
+
+2017-10-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dcm.c (DCM_ReadNonNativeImages): Additional fix
+       (improvement) for SourceForge issue #512 "NULL Pointer Dereference
+       in DICOM Decoder".
+
+2017-10-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dcm.c (ReadDCMImage): Fix SourceForge issue #512 "NULL
+       Pointer Dereference in DICOM Decoder".
+
+       * coders/pict.c (ReadPICTImage): Fix SourceForge issue #511
+       "Memory Allocation error due to malformed image file".
+
+       * coders/pnm.c (WritePNMImage): Fix SourceForge issue #503 "memory
+       leak in WritePNMImage".
+
+       * coders/png.c (ReadMNGImage): Fix SourceForge issue #501 "memory
+       leak in ReadMNGImage".
+
+       * magick/segment.c (InitializeIntervalTree): Fix SourceForge issue
+       #507 "null pointer in segment.c" and issue #508 "null pointer in
+       segment.c".
+
+       * coders/topol.c (ReadTOPOLImage): Fix SourceForge issue #510
+       "null pointer and meory leak in topol.c".
+
+       * magick/widget.c (MagickXFileBrowserWidget): Fix SourceForge
+       issue #506 "null pointer in widget.c".
+
+       * coders/tiff.c (WriteTIFFImage): Fix SourceForge issue #509
+       "Memory leak in tiff.c".
+
+       * magick/module.c (FindMagickModule): Fix SourceForge issue #502
+       "null pointer in module.c".
+
+       * coders/avs.c (ReadAVSImage): Fix Coverity CID 184115 "Control
+       flow issues (DEADCODE)".
+
+2017-09-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/avs.c (ReadAVSImage): Fix SourceForge issue #499 "memory
+       leak in avs.c".
+
+       * coders/cmyk.c (ReadCMYKImage): Fix SourceForge issue #498
+       "memory leak in cmyk.c".
+
+       * coders/cut.c (ReadCUTImage): Fix SourceForge issue #497 "memory
+       leak in cut.c".
+
+       * coders/dpx.c (ReadDPXImage): Fix SourceForge issue #496 "memory
+       leak in dpx.c".
+
+       * coders/hdf.c (ReadHDFImage): Fix SourceForge issue #495 "memory
+       leak in hdf.c".
+
+       * coders/pcx.c (ReadPCXImage): Fix SourceForge issue #494 "memory
+       leak in pcx.c".
+
+       * coders/pcd.c (ReadPCDImage): Fix SourceForge issue #493 "memory
+       leak in ReadPCDImage".
+
+       * coders/histogram.c (WriteHISTOGRAMImage): Fix SourceForge issue
+       #492 "memory leak in WriteHISTOGRAMImage".
+
+       * coders/gif.c (WriteGIFImage): Fix SourceForge issue #491 "memory
+       leak in WriteGIFImage".
+
+       * coders/fits.c (WriteFITSImage): Fix SourceForge issue #490
+       "memory leak in WriteFITSImage".
+
+       * coders/palm.c (WritePALMImage): Fix SourceForge issue #489
+       "memory leak in WritePALMImage".
+
+       * coders/rgb.c (ReadRGBImage): Fix SourceForge issue #488 "Memory
+       leak in rgb.c".
+
+       * coders/palm.c (ReadPALMImage): Fix SourceForge issue #487 "NULL
+       pointer dereference in ReadPALMImage".
+
+       * Magick++/lib/Options.cpp (strokeDashArray): Fix SourceForge
+       issue #486 "NULL pointer dereference in
+       Magick::Options::strokeDashArray".
+
+       * magick/nt_feature.c (NTGetTypeList): Fix SourceForge issue #485
+       "NULL pointer dereference in NTGetTypeList".
+
+       * coders/sun.c (ReadSUNImage): Fix SourceForge issue #484 "Memory
+       leak in sun.c".
+
+       * coders/tim.c (ReadTIMImage): Fix SourceForge issue #483 "Memory
+       leak in tim.c".
+
+       * magick/nt_base.c (NTRegistryKeyLookup): Fix SourceForge issue
+       #482 "NULL pointer dereference in NTRegistryKeyLookup".
+
+       * coders/viff.c (ReadVIFFImage): Fix SourceForge issue #481
+       "Memory leak in viff.c".
+
+       * magick/profile.c (SetImageProfile): Fix SourceForge issue #480
+       "assertion failure in MagickMapAllocateMap".
+
+       * coders/yuv.c (ReadYUVImage): Fix SourceForge issue #478 "Memory
+       leak in yuv.c".
+
+       * magick/map.c (MagickMapCloneMap): Fix SourceForge issue #477
+       "assertion failure in MagickMapIterateNext".
+
+       * coders/emf.c (ReadEnhMetaFile): Fix SourceForge issue #475 "NULL
+       pointer dereference in ReadEnhMetaFile".
+
+       * coders/cineon.c (ReadCINEONImage): Fix SourceForge issue #473
+       "NULL pointer dereference in ReadCINEONImage"
+
+       * coders/tiff.c (TIFFIgnoreTags): Fix SourceForge issue #476 "NULL
+       Pointer in tiff.c".
+
+2017-09-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/blob.c (GetConfigureBlob): Fix SourceForge issue #472
+       "NULL Pointer in GetConfigureBlob".
+
+2017-09-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/rle.c (ReadRLEImage): Fix SourceForge issue #458 "Heap
+       out of bounds read in ReadRLEImage()".
+
+2017-09-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/sgi.c (ReadSGIImage): Check for EOF while reading SGI
+       file header.  Issue was brought to our attention by Petr Gajdos
+       via email on Fri, 1 Sep 2017.
+
+2017-09-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tiff.c (ReadTIFFImage): Allow a single scanline, strip,
+       tile, to be 1000X larger than the input file in order to not cause
+       problems for extremely compressible images or tile sizes much
+       larger than the pixel dimensions.
+
+2017-09-16  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/symbols.h, wand/wand_symbols.h: Update C library symbols
+       which should be prefixed with 'Gm'. However, GM will not move
+       Magick++ namespace because of the ImageMagick version.  Resolves
+       SourceForge issue #468 "--enable-symbol-prefix does not prevent
+       clashes with libMagick++ or libMagickWand?"
+
+       * coders/png.c (DestroyJNG): DestroyJNG should be a static
+       function.  Was wrongly exposed as DestroyJNGInfo in 1.3.26.  This
+       is not a public function and was not intended to be part of the
+       ABI.
+
+       * coders/tiff.c (ReadTIFFImage): Limit scanline, strip, and tile
+       memory allocations based on file size multiplied by a maximum
+       compression ratio.  Fixes SourceForge issues #460, #461, #462,
+       #463, #464 "allocation failure in ReadTIFFImage".
+
+       * coders/pnm.c (ReadPNMImage): Require that XV 332 format have 256
+       colors.  Fixes SourceForge issue #465 "NULL Pointer Dereference
+       triggered by malformed file".  In our own testing the test case
+       produced an assertion failure because assertions were enabled.
+
+       * magick/colormap.c (AllocateImageColormap): Use unsigned array
+       index.
+
+2017-09-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/mat.c (ReadMATImage): Fix CVE-2016-10070, which is a heap
+       overflow in the MAT reader due to an under-sized memory
+       allocation.  Based on private email from Petr Gajdos on Mon, 11
+       Sep 2017.
+
+2017-09-13  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Check MemoryResource before allocating
+       ping_pixel array.
+
+2017-09-11  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * magick/shear.c: Possible evil loop might waste CPU for long time
+        without any reason.
+
+2017-09-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/render.c (DrawImage): Fix SourceForge issue #448 "Heap
+       out of bounds read in DrawDashPolygon()".  Problem was reported by
+       Kamil Frankowicz on August 28, 2017.
+
+       * coders/uil.c (WriteUILImage): Fix crash in UIL writer when
+       writing image containing transparency.  Issue was reported by
+       LCatro via email on 18 Jul 2017.
+
+       * coders/wpg.c (InsertRow): Fix crash which occurs if image is not
+       PseudoClass but a PseudoColor scanline is needed.  Resolves
+       SourceForge issue #449 "Null pointer dereference in InsertRow()".
+
+       * coders/rle.c (ReadRLEImage): Impose image dimension limits
+       according to Utah RLE specification. Cap number of planes handled
+       internally at 4.  Remove non-standard multi-frame extension, which
+       did not work anyway.
+
+2017-09-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadJNGImage): Complete fixing CVE-2017-8350 crash
+       while reading a malformed JNG file.
+
+       * coders/{html.c, map.c, plasma.c, png.c, psd.c, rle.c, stegano.c,
+       uil.c}: Downgrade claimed coder stability level for HTML, SHTML,
+       MAP, FRACTAL, PLASMA, JNG, MNG, RLE, STEGANO, and UIL formats.
+
+2017-09-08  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c (ReadJNGImage): More efforts toward fixing
+       CVE-2017-8350 while reading a malformed JNG file.
+
+2017-09-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/error.c (ThrowLoggedException): Capture the first
+       exception at ErrorException level or greater, or only capture
+       exception if it is more severe than an already reported exception.
+       This should help lead to better error reports since the first
+       error is usually the most significant.
+
+       * coders/png.c (ReadJNGImage): Add "improper header" exception
+       reporting.
+
+2017-09-01  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c (ReadJNGImage): Efforts toward fixing CVE-2017-8350
+       while reading a malformed JNG file.
+
+2017-08-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/wpg.c (ReadWPGImage): Patch submitted by Petr Gajdos to
+       check that .Width and .Height are greater than zero before they
+       are assigned to image->columns and image->rows respectively
+       (CVE-2014-9815).
+       (ReadWPGImage): Do more validations on WPG_Palette.StartIndex and
+       WPG_Palette.NumOfEntries.
+
+2017-08-29  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJNGImage): Fix for SourceForge issue #440
+       "use-after-free in CloseBlob (blob.c) (INCOMPLETE FIX FOR
+       CVE-2017-11403)" and SourceForge issue #438 "heap use after free
+       in CloseBlob".
+       * coders/png.c (ReadOneJNGImage): Fix for SourceForge issue #439
+       "assertion failure in magick/pixel_cache.c"
+
+2017-08-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/mpeg.c (WriteMPEGImage): Fix MPEG writer memory leak.
+       Only the first image in the coalesce image list was being freed.
+       Problem was reported by LCatro via email on July 15, 2017.
+
+       * magick/attribute.c (TracePSClippingPath, TraceSVGClippingPath):
+       Fix SourceForge bug #447 "Heap out of bounds read in
+       ReadMSBShort()".
+
+2017-08-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/xbm.c (ReadXBMImage): Fix two denial of service (DOS)
+       issues in ReadXBMImage() which result in the reader not
+       returning. Problem was reported via email on Wed Aug 23 2017 by
+       Xiaohei and Wangchu from Alibaba Security Team.
+
+       * coders/jnx.c (ReadJNXImage): Fix denial of service (DOS) issue
+       in ReadJNXImage() whereby large amounts of CPU and memory
+       resources may be consumed although the file itself does not
+       support the requests.  Problem was reported via email on Wed Aug
+       23 2017 by Xiaohei and Wangchu from Alibaba Security Team.
+
+2017-08-14  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneMNGImage): Deal with invalid (too large)
+       length of MNG chunks (bug #446).
+
+2017-08-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pnm.c (ReadPNMImage): Verify that sufficient file data
+       exists to support what the file header requires before allocating
+       memory for it.  Fixes problem reported by Agostino Sarubbo via
+       email on Wed, 12 Jul 2017 and reported yet again via SourceForge
+       bug #441 "memory allocation failure in MagickRealloc".
+
+2017-08-20  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c: Fix SourceForge bug #433 "memory leak in
+       ReadMATImage".  Credit for discovering and reporting the problem
+       is "ADLab of Venustech".
+
+       * coders/sun.c (ReadSUNImage): Fix failure to allocate memory due
+       to inadequate file data to support claimed image width and height.
+       First notified by email from Agostino Sarubbo on 14 Jul 2017 and
+       then again as SourceForge bug #442 "memory allocation failure in
+       magickmalloc".
+
+2017-08-16  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/svg.c (GetStyleTokens): Fix SourceForge bugs 434 "heap
+       buffer overflow in GetStyleTokens", 435 "null pointer
+       dereference_in_SVGStartElement", and 436 "heap buffer overflow in
+       GetStyleTokens" which all originated from a heap buffer overflow
+       in GetStyleStokens(), or inconsistent initialization.  Now the
+       implementation truncates parsing for poorly-formed input (to avoid
+       buffer overflow) while still correctly parsing well-formed input.
+       The reproducers and problem reports are attributed to "ADLab of
+       Venustech".
+
+2017-08-14  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJNGImage): Fixed double-free after
+       reading a malformed JNG (Issue #438).
+
+2017-08-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pcd.c (ReadPCDImage): Fix memory leak on return path due
+       to corrupted header.  Patch included in email on 14 Aug 2017 by
+       Petr Gajdos (ImageMagick CVE CVE-2017-8351).
+
+2017-08-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/gif.c (ReadGIFImage): Assure that global colormap is
+       initialized.
+
+       * coders/pict.c (ReadPICTImage): Fix memory leaks in error return
+       path.  ImageMagick CVE CVE-2017-8353.  Patch by Petr Gajdos.
+
+2017-08-11  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * tests/rwblob.c and rwfile.c: Write the reason for FAIL in
+       test-suite.log.
+       * magick/image.h: Revised table of image orientations to show
+       Exif ImageOrientation values (which happen to be the same as
+       the enum values 1 to 8).
+       * coders/png.c: ReadJNGIMage(): fix memory leak (Issue 431).
+
+2017-08-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/mtv.c (ReadMTVImage): Fix memory leak in error return
+       path upon unexpected EOF (ImageMagick CVE-2017-9142).  Problem was
+       brought to our attention via email from Petr Gajdos on Wed, 9 Aug
+       2017.  Also changed pixel cache access functions used to assure
+       delivery of exception to the user.
+
+2017-08-05  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * configure.ac (SETJMP_IS_THREAD_SAFE): Decide if setjmp/longjmp
+       are thread safe based on host OS.  Assume that these interfaces
+       are thread safe by default.  Declared not to be thread safe under
+       Solaris.  Declaring these interfaces to be thread safe increases
+       available concurrency for coders which use setjmp/longjmp for
+       error recovery (e.g. PNG and JPEG).
+
+2017-08-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/jpeg.c (RegisterJPEGImage): Add support for the
+       SETJMP_IS_THREAD_SAFE preprocessor definition (already used by
+       coders/png.c) to indicate if setjmp/longjmp are thread safe on
+       this platform and that it is safe for multiple encoders/decoders
+       to be active at one time.
+
+2017-07-31  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/sun.c: Fix heap read overflow while indexing into
+       colormap. Problem was reported via email on 17 Jul 2017 by
+       Agostino Sarubbo.
+
+2017-07-31  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c (ReadMNGImage): Stop a leak when rejecting a
+       MNG image with dimensions that are too large.
+
+2017-07-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/wmf.c (ReadWMFImage): Eliminate use of already freed heap
+       data in error reporting path.  Problem was reported via email by
+       Agostino Sarubbo on Fri, 14 Jul 2017
+
+2017-07-25  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c (ReadMNGImage) Free chunk allocation that remains
+       after attempting to read a truncated file.
+       * coders/png.c: Removed some redundant checks for chunk length
+       before MagickFreeMemory(chunk), which is safe to call with a
+       NULL argument.
+       * coders/png.c: Fixed writer bug due to missing brackets; a Log
+       statement should have been inside the "i" loop but instead was
+       using i++ left over from the loop.  Bug report by L. Catro.
+       * coders/png.c: Reject a MNG with dimensions greater than 65k
+       by 65k.
+       * coders/png.c (WriteOnePNGImage): Return without crashing if
+       WriteOnePNGImage is passed a NULL image. Fixes CVE-2017-11522.
+
+2017-07-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/pcl.c (WritePCLImage): Fix null pointer dereference in
+       PCL writer when writing monochrome images.  Problem was reported
+       by LCatro via email on July 18.
+
+       * magick/pixel_cache.c (PersistCache): Fix memory leak while
+       writing a MPC file.  Problem was reported by LCatro via email on
+       July 18.
+
+       * coders/map.c (WriteMAPImage): Fix null pointer dereference or
+       segmentation violation in the MAP writer if the input image is not
+       already colormapped.  Problem was reported by LCatro via email on
+       July 18.
+
+       * coders/gray.c (WriteGRAYImage): Improve tracing and tidy up.
+
+       * coders/rgb.c (WriteRGBImage): Fix heap overwrite in raw RGB
+       writer (all output subformats) given a multiframe sequence using
+       different widths.  Problem was reported by LCatro via email on
+       July 18.
+
+       * coders/cmyk.c (WriteCMYKImage): Fix heap overwrite in raw CMYK
+       writer (all output subformats) given a multiframe sequence using
+       different widths.  Also fix wrong output of CMYKA (and vice-versa)
+       when CMYK was intended.  Problem was reported by LCatro via email
+       on July 18.
+
+       * coders/palm.c: Disable the PALM writer since the writer is a
+       work in progress and still has implementation problems.  Perhaps
+       no one in the world remains who cares about the undocumented PALM
+       format.  Resolves heap overflow and assertion issues reported by
+       LCatro via emails on July 11th, and 12th, 2017.
+
+       * magick/colormap.c (ReplaceImageColormap): Throw an exception
+       rather than assertion if the input image is not colormapped.
+
+2017-07-13  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Implemented eXIf chunk support.
+
+2017-07-12  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Fix typecast of left shifts (patch by Bob F)
+
+2017-07-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/ps.c (ReadPSImage): Fix reference to constant NULL image
+       argument which is dereferenced to pass an exception to
+       MagickMonitorFormatted().  Problem was reported by Agostino
+       Sarubbo via email on Wed, 12 Jul 2017.
+
+2017-07-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/blob.c: Add casts to fix undefined behavior in left
+       shifts.  Issue was reported by Agostino Sarubbo via email on Mon,
+       10 Jul 2017.
+
+2017-07-10  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJNGImage): Ignore out-of-bounds MOVE
+       and CLIP object_id's.
+       * coders/png.c (ReadMNGImage): Fix apparent off-by-one error
+       in MNG FRAM change_clipping processing.
+       * coders/png.c (ReadMNGImage): Fix out-of-order CloseBlob()
+       and DestroyImageList() that caused a use-after-free crash.
+       Fixes CVE-2017-11403.  This bug was discovered by Agostino Sarubbo.
+
+2017-07-08  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJngImage): Revised double-free fix.
+
+2017-07-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJNGImage): Fix double-frees caused by
+       commit on 2017-07-06.
+
+       * coders/jpeg.c (ReadJPEGImage): Defer creating pixel cache until
+       after successfully reading first scanline.  Classify some serious
+       libjpeg reported "warnings" as errors and quit processing
+       scanlines immediately upon first error so that corrupt JPEG does
+       not consume excessive resources.  Resolves excessive resource
+       consumption issue reported for two JPEG files provided via email
+       by LCatro on Tue, 4 Jul 2017.
+
+2017-07-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c (ReadOneJNGImage): Remove spurious '\n' from log
+       statement.
+
+2017-07-06  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Consolidate JNG cleanup into a new DestroyJNG()
+       function.
+
+2017-07-05  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: prevent a crash due to zero-length color_image
+       while reading a JNG image. (CVE-2017-11102)
+
+2017-07-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * NEWS.txt: Make sure is up to date.
+
+       * www/index.rst: Update for 1.3.26 release.
+
+       * version.sh: Update library versioning for 1.3.26 release.
+
+       * magick/command.c (BatchCommand): Add ferror() checks around
+       batch input loop.
+
+2017-07-03  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Reject a PNG file if the file size is too small
+       (less than 61 bytes).  Reject a JNG file if it is too small (less
+       than 147 bytes).
+       * coders/jpeg.c: Reject a JPEG file if the file size is too small
+       (less than 107 bytes).
+
+2017-07-02  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/dpx.c (ReadDPXImage): Compute required file size and
+       verify that sufficient data exists in file before allocating
+       memory to decode the image data.  Resolves problem with DPX file
+       with valid header (but a huge claimed image width) provided
+       provided via email on Thu, 29 Jun 2017 by LCatro.  This issue has
+       been assigned CVE-2017-10799.
+
+2016-07-02  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Check whether reported object size overflows file size.
+
+2016-07-01  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+       * coders/mat.c Safety check for forged and or corrupted data.
+       This issue has been assigned CVE-2017-10800.
+
+2017-07-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tiff.c ("QuantumTransferMode"): Use a generalized method
+       to enforce that buffer overflow can not happen while importing
+       pixels.  Resolves problem with RGB TIFF claiming only one sample
+       per pixel provided via email on Thu, 29 Jun 2017 by LCatro.  This
+       issue has been assigned CVE-2017-10794.
+
+2017-06-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/command.c: Convert bare 'unsigned int' to MagickPassFail
+       where suitable to make intentions clear.  Convert True/False to
+       MagickTrue/MagickFalse or MagickPass/MagickFail according to
+       purpose.  This is a continuation of a gradual migration and does
+       not represent an API change.
+
+2017-06-25  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Avoid NULL dereference when MAGN chunk processing
+       fails (https://sourceforge.net/p/graphicsmagick/bugs/426/). Expand
+       TABs.
+
+2017-06-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * NEWS.txt: Update NEWS with changes since the previous release.
+
+       * www/programming.rst: Switch the Lua link to
+       https://github.com/arcapos/luagraphicsmagick, which is a more
+       complete and direct interface from Lua to GraphicsMagick's Wand
+       API.
+
+2017-06-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * VisualMagick/installer/gm-foo-dll.iss: Remove PerlMagick from
+       the slim Inno Setup installer builder and remove mention of
+       PerlMagick from the installer documentation.
+
+       * TclMagick/generic/TclMagick.c (magickCmd): Resolve SourceForge
+       patch #51 "TclMagick: memory access error; possible segfault".
+       (newMagickObj): Fix formatting of pointer value so it is 64-bit
+       safe.  Resolves SourceForge patch #50 "TclMagick: 64-bit
+       portability issue".
+
+       * coders/pict.c (ReadPICTImage): Avoid possible use of negative
+       value when indexing array, which would cause buffer overflow.
+       Resolves SourceForge issue #427 "One possible buffer overflow
+       vulnerability in
+       GraphicsMagick-1.3.25/coders/pict.c:ReadPICTImage()".
+
+2017-06-22  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Stop memory leak when reading invalid JNG image.
+       Fixes CVE-2017-8350.
+
+2017-06-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/png.c: Fix lcms2.h inclusion logic.
+
+       * wand/magick_wand.c (MagickSetImageOrientation): Eliminate use of
+       snprintf, which is not supported by older Visual Studio.
+
+2017-06-09  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Accept exIf chunks whose data segment
+       erroneously begins with "Exif\0\0".
+
+2017-06-01  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Removed experimental zxIF chunk support.  That
+       proposal is dead.
+
+2017-05-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * config/log.mgk: Added documentation suggested by SourceForge
+       issue #419 "Consider a small patch to log.mgk".
+
+       * www/Changes.rst: Add missing link to most recent changes.
+
+2017-05-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * www/Magick++/Image.rst: Improve documentation for Magick++
+       Image::iccColorProfile() and Image::renderingIntent().
+
+2017-05-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * tiff: Update to libtiff 4.0.8.
+
+2017-03-19  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Quieted a new Coverity complaint about a potential
+       text buffer overrun.
+
+2017-03-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/image.c (SetImageInfo): Ignore empty magic prefix
+       specification and do not remove colon character from start of
+       filename.  Resolves SourceForge bug #415 "Inconsistent Behavior w/
+       input_file Parameter".
+
+2017-03-18  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Added new private orNT PNG chunk, to
+       preserve image->orientation when it is defined and not
+       the default TopLeft.
+       * coders/jpeg.c: Mention image->orientation in the log when
+       writing a JPEG.
+
+2017-03-15  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c (WriteOnePNGImage): Add version info about
+       gm, libpng, zlib, and lcms to the PNG debug log.
+
+2017-03-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * magick/command.c (ImportImageCommand): Fix handling of -frame
+       options. Option handling was incorrect due to option checking the
+       frame option after it had been freed.  Checking the frame dash
+       option before freeing the argument solves the problem.  From patch
+       provided by Victor Ananjevsky as SourceForge patch #49 "-frame
+       doesn't work in gm import".
+
+       * Magick++/lib/Image.cpp (attribute): Added Image attribute method
+       which accepts a 'char *' argument, and will remove the attribute
+       if the value argument is NULL.  From patch provided by "Gints" as
+       SourceForge patch #46 "C++ api - method to clear/remove
+       attribute".
+
+       * VisualMagick/configure/configure.cpp (InitInstance): Applied
+       patch by Paul McConkey to allow the quantum command line argument
+       to set the default value in the wizard drop list.  This allows
+       setting the quantum depth when the /nowizard argument was
+       supplied.  Resolves SourceForge patch #48 "When running from the
+       command line configure.exe does not use the quantum argument".
+       The provided configure.exe still needs to be rebuilt to
+       incorporate this change.
+
+       * magick/command.c (MogrifyImage): The -orient command now also
+       updates the orientation in the EXIF profile, if it exists.
+
+       * Magick++/lib/Image.cpp (orientation): Update orientation in EXIF
+       profile, if it exists.
+
+2017-03-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/jp2.c: Support PGX JPEG 2000 format for reading and
+       writing (within the bounds of what JasPer supports).
+
+2017-02-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/tiff.c (QuantumTransferMode): Fix out of bounds read when
+       reading CMYKA TIFF which claims to have only 2 samples per pixel.
+       Problem was reported via email on February 15, 2017 by Valon
+       Chu. This issue was assigned CVE-2017-6335.
+
+2017-01-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * doc/options.imdoc (-geometry): Geometry documentation changes
+       suggested by Jon Wong.
+
+2017-01-26  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Added support for a proposed new PNG chunk
+       (zxIf, read-only) that is currently being discussed on the
+       png-mng-misc at lists.sourceforge.net mailing list.  Enable
+       exIf and zxIf with CPPFLAGS="-DexIf_SUPPORTED -DxzIf_SUPPORTED".
+       If exIf is enabled, only the uncompressed exIF chunk will be
+       written and the hex-encoded zTXt chunk containing the raw Exif
+       profile won't be written.
+
+2017-01-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * coders/msl.c (MSLStartElement): Change test for NULL image
+       pointer to before it is used rather than after it is used.
+       Problem reported by Petr Gajdos on 2017-01-25.
+
+2017-01-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * TclMagick/unix/m4/tcl.m4: Update tcl.m4 to TEA 3.10.  File
+       supplied by Massimo Manghi.
+
+2017-01-21  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Added support for a proposed new PNG
+       chunk (exIf read-write, eXIf read-only) that is currently
+       being discussed on the png-mng-misc at lists.sourceforge.net
+       mailing list.
+
+2017-01-21  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+       * coders/png.c: Added read_user_chunk_callback() function
+       and used it to implement a private PNG caNv (canvas) chunk
+       for remembering the original dimensions and offsets when an
+       image is cropped.  Previously we used the oFFs chunk for this
+       purpose, but this had potential conflicts with other applications
+       that also use the oFFs chunk.
+
+2017-01-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * TclMagick/Makefile.am (AM_DISTCHECK_CONFIGURE_FLAGS): Applied
+       patch by Massimo Manghi to set AM_DISTCHECK_CONFIGURE_FLAGS so
+       that 'make distcheck' remembers configuration options, and also to
+       uninstall pkgIndex.tcl.
+
+       * magick/image.c (SetImageEx): Use PixelIterateMonoSet() for
+       possibly improved efficiency.
+
+       * magick/pixel_iterator.c (PixelIterateMonoSet): New pixel
+       iterator intended for use when initializing image pixels, without
+       regard to existing values.
+
+2017-01-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * Copyright.txt: Bump copyright years and rotate ChangeLog.
+
+
index 88dca7f..c565e3e 100644 (file)
@@ -23,7 +23,7 @@ The licenses which components of this software fall under are as follows.
   from ImageMagick Studio's ImageMagick and applied the "MIT" style
   license:
 
-  Copyright (C) 2002 - 2017 GraphicsMagick Group
+  Copyright (C) 2002 - 2018 GraphicsMagick Group
 
   Permission is hereby granted, free of charge, to any person
   obtaining a copy of this software and associated documentation files
@@ -143,12 +143,12 @@ The licenses which components of this software fall under are as follows.
 
   Many of the pattern images in coders/logo.c are derived from XFig,
   which is distributed under the following license:
+
   | FIG : Facility for Interactive Generation of figures
   | Copyright (c) 1985-1988 by Supoj Sutanthavibul
   | Parts Copyright (c) 1989-2000 by Brian V. Smith
   | Parts Copyright (c) 1991 by Paul King
+
   Any party obtaining a copy of these files is granted, free of charge, a
   full and unrestricted irrevocable, world-wide, paid up, royalty-free,
   nonexclusive right and license to deal in this software and
@@ -167,19 +167,19 @@ The licenses which components of this software fall under are as follows.
   this manual page is as follows:
 
   Copyright (c) 1986, University of Utah
-  
+
   This software is copyrighted as noted below.  It may be freely copied,
-  modified, and redistributed, provided that the copyright notice is 
+  modified, and redistributed, provided that the copyright notice is
   preserved on all copies.
-  
+
   There is no warranty or other guarantee of fitness for this software,
   it is provided solely "as is".  Bug reports or fixes may be sent
   to the author, who may or may not act on them as he desires.
-  
+
   You may not include this software in a program or other software product
-  without supplying the source, or without informing the end-user that the 
+  without supplying the source, or without informing the end-user that the
   source is available for no extra charge.
-  
+
   If you modify this software, you should include a notice giving the
   name of the person performing the modification, the date of modification,
   and the reason for such modification.
@@ -192,23 +192,23 @@ The licenses which components of this software fall under are as follows.
   | Copyright (c) 1988-1997 Sam Leffler
   | Copyright (c) 1991-1997 Silicon Graphics, Inc.
 
-  Permission to use, copy, modify, distribute, and sell this software and 
+  Permission to use, copy, modify, distribute, and sell this software and
   its documentation for any purpose is hereby granted without fee, provided
   that (i) the above copyright notices and this permission notice appear in
   all copies of the software and related documentation, and (ii) the names of
   Sam Leffler and Silicon Graphics may not be used in any advertising or
   publicity relating to the software without the specific, prior written
   permission of Sam Leffler and Silicon Graphics.
-   
-  THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
-  EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
-  WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
+
+  THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+  EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+  WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+
   IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
   ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
   OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-  WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
-  LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+  WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+  LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
   OF THIS SOFTWARE.
 
 8)
@@ -217,7 +217,7 @@ The licenses which components of this software fall under are as follows.
   directory, is distributed under the following license:
 
   Copyright 1999 - 2012 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-                                                                          
+
   Permission is hereby granted, free of charge, to any person
   obtaining a copy of this software and associated documentation files
   ("Magick++"), to deal in the Software without restriction, including
@@ -282,4 +282,4 @@ The licenses which components of this software fall under are as follows.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 650ff7d..1754738 100644 (file)
@@ -11,9 +11,9 @@
 #include <iostream>
 #include <iomanip>
 #include <list>
-using namespace std; 
+using namespace std;
 using namespace Magick;
-int main(int argc,char **argv) 
+int main(int argc,char **argv)
 {
   if ( argc < 2 )
     {
@@ -55,13 +55,13 @@ int main(int argc,char **argv)
               pos++;
             }
         }
-        catch( Exception &error_ ) 
-          { 
-            cout << error_.what() << endl; 
+        catch( Exception &error_ )
+          {
+            cout << error_.what() << endl;
           }
         ++arg;
       }
   }
 
-  return 0; 
+  return 0;
 }
index a38222d..b4e1ec9 100644 (file)
@@ -2,7 +2,7 @@
 // Magick++ demo to generate a simple text button
 //
 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2003
-// 
+//
 
 #include <Magick++.h>
 #include <string>
index 6d66401..0a2a733 100644 (file)
@@ -24,13 +24,13 @@ int main( int /*argc*/, char ** argv)
 
   // Initialize Magick
   InitializeMagick(*argv);
-  
+
   try {
-    
+
     string srcdir("");
     if(getenv("SRCDIR") != 0)
       srcdir = getenv("SRCDIR");
-    
+
     // Common font to use.
     string font = "Helvetica";
 
@@ -46,24 +46,24 @@ int main( int /*argc*/, char ** argv)
       model.label( "Magick++" );
       model.borderColor( "black" );
       model.backgroundColor( "black" );
-    
+
       Image smile( srcdir + "smile.miff" );
       smile.label( "Smile" );
       smile.borderColor( "black" );
-    
+
       //
       // Create image stack.
       //
       cout << "Creating thumbnails..." << endl;
-    
+
       // Construct initial list containing seven copies of a null image
       Image null;
       null.size( Geometry(70,70) );
       null.read( "NULL:black" );
       list<Image> images( 7, null );
-    
+
       Image example = model;
-    
+
       // Each of the following follow the pattern
       //  1. obtain reference to (own copy of) image
       //  2. apply label to image
@@ -182,7 +182,7 @@ int main( int /*argc*/, char ** argv)
       example.label( "Equalize" );
       example.equalize( );
       images.push_back( example );
-    
+
       cout << "  explode ..." << endl;
       example = model;
       example.label( "Explode" );
@@ -225,21 +225,21 @@ int main( int /*argc*/, char ** argv)
       example.label( "Gaussian Blur\n(Green Channel)" );
       example.gaussianBlurChannel( GreenChannel, 0.0, 1.5 );
       images.push_back( example );
-    
+
       cout << "  gradient ..." << endl;
       Image gradient;
       gradient.size( "130x194" );
       gradient.read( "gradient:#20a0ff-#ffff00" );
       gradient.label( "Gradient" );
       images.push_back( gradient );
-    
+
       cout << "  grayscale ..." << endl;
       example = model;
       example.label( "Grayscale" );
       example.quantizeColorSpace( GRAYColorspace );
       example.quantize( );
       images.push_back( example );
-    
+
       cout << "  implode ..." << endl;
       example = model;
       example.label( "Implode" );
@@ -284,19 +284,19 @@ int main( int /*argc*/, char ** argv)
       example.label( "Motion Blur" );
       example.motionBlur( 0.0, 7.0,45 );
       images.push_back( example );
-    
+
       cout << "  negate ..." << endl;
       example = model;
       example.label( "Negate" );
       example.negate( );
       images.push_back( example );
-    
+
       cout << "  normalize ..." << endl;
       example = model;
       example.label( "Normalize" );
       example.normalize( );
       images.push_back( example );
-    
+
       cout << "  oil paint ..." << endl;
       example = model;
       example.label( "Oil Paint" );
@@ -332,7 +332,7 @@ int main( int /*argc*/, char ** argv)
       example.label( "Ordered Dither\n(4x4)" );
       example.randomThreshold( Geometry(4,4) );
       images.push_back( example );
-    
+
       cout << "  ordered dither red 4x4..." << endl;
       example = model;
       example.label( "Ordered Dither\n(Red 4x4)" );
@@ -345,7 +345,7 @@ int main( int /*argc*/, char ** argv)
       plasma.read( "plasma:fractal" );
       plasma.label( "Plasma" );
       images.push_back( plasma );
-    
+
       cout << "  quantize ..." << endl;
       example = model;
       example.label( "Quantize" );
@@ -369,31 +369,31 @@ int main( int /*argc*/, char ** argv)
       example.label( "Quantum Operator\nTheshold Region" );
       example.quantumOperator( 30,40,68,112,GrayChannel,ThresholdQuantumOp,0.35*MaxRGB );
       images.push_back( example );
-    
+
       cout << "  raise ..." << endl;
       example = model;
       example.label( "Raise" );
       example.raise( );
       images.push_back( example );
-    
+
       cout << "  reduce noise ..." << endl;
       example = model;
       example.label( "Reduce Noise" );
       example.reduceNoise( 1.0 );
       images.push_back( example );
-    
+
       cout << "  resize ..." << endl;
       example = model;
       example.label( "Resize" );
       example.zoom( "50%" );
       images.push_back( example );
-    
+
       cout << "  roll ..." << endl;
       example = model;
       example.label( "Roll" );
       example.roll( "+20+10" );
       images.push_back( example );
-    
+
       cout << "  rotate ..." << endl;
       example = model;
       example.label( "Rotate" );
@@ -406,50 +406,50 @@ int main( int /*argc*/, char ** argv)
       example.label( "Scale" );
       example.scale( "60%" );
       images.push_back( example );
-    
+
       cout << "  segment ..." << endl;
       example = model;
       example.label( "Segment" );
       example.segment( 0.5, 0.25 );
       images.push_back( example );
-    
+
       cout << "  shade ..." << endl;
       example = model;
       example.label( "Shade" );
       example.shade( 30, 30, false );
       images.push_back( example );
-    
+
       cout << "  sharpen ..." << endl;
       example = model;
       example.label("Sharpen");
       example.sharpen( 0.0, 1.0 );
       images.push_back( example );
-    
+
       cout << "  shave ..." << endl;
       example = model;
       example.label("Shave");
       example.shave( Geometry( 10, 10) );
       images.push_back( example );
-    
+
       cout << "  shear ..." << endl;
       example = model;
       example.label( "Shear" );
       example.shear( 45, 45 );
       example.transparent( "black" );
       images.push_back( example );
-    
+
       cout << "  spread ..." << endl;
       example = model;
       example.label( "Spread" );
       example.spread( 3 );
       images.push_back( example );
-    
+
       cout << "  solarize ..." << endl;
       example = model;
       example.label( "Solarize" );
       example.solarize( );
       images.push_back( example );
-    
+
       cout << "  swirl ..." << endl;
       example = model;
       example.backgroundColor( "#000000FF" );
@@ -468,14 +468,14 @@ int main( int /*argc*/, char ** argv)
       example.label( "Random\nThreshold" );
       example.randomThreshold( Geometry(0.3*MaxRGB,0.85*MaxRGB) );
       images.push_back( example );
-    
+
       cout << "  unsharp mask ..." << endl;
       example = model;
       example.label( "Unsharp Mask" );
       //           radius_, sigma_, amount_, threshold_
       example.unsharpmask( 0.0, 1.0, 1.0, 0.05);
       images.push_back( example );
-    
+
       cout << "  wave ..." << endl;
       example = model;
       example.label( "Wave" );
@@ -483,7 +483,7 @@ int main( int /*argc*/, char ** argv)
       example.backgroundColor( "#000000FF" );
       example.wave( 25, 150 );
       images.push_back( example );
-    
+
       //
       // Create image montage.
       //
index 1a515b1..5b64e5b 100644 (file)
@@ -5,16 +5,16 @@
 // background color, or to create a similar looking effect without
 // transparency.
 //
-// Copyright Bob Friesenhahn, 2000
+// Copyright Bob Friesenhahn, 2000 - 2018
 //
 // Usage: detrans color file...
 //
 
 #include <Magick++.h>
 #include <iostream>
-using namespace std; 
+using namespace std;
 using namespace Magick;
-int main(int argc,char **argv) 
+int main(int argc,char **argv)
 {
   if ( argc < 3 )
     {
@@ -30,7 +30,7 @@ int main(int argc,char **argv)
     try {
       color = Color(argv[1]);
     }
-    catch ( Exception error_ )
+    catch ( Exception &error_ )
       {
         cout << error_.what() << endl;
         cout.flush();
@@ -48,13 +48,13 @@ int main(int argc,char **argv)
           base.matte( false );
           base.write( fname );
         }
-        catch( Exception &error_ ) 
-          { 
-            cout << error_.what() << endl; 
+        catch( Exception &error_ )
+          {
+            cout << error_.what() << endl;
           }
         ++arg;
       }
   }
 
-  return 0; 
+  return 0;
 }
index 61dae19..522f465 100644 (file)
@@ -55,6 +55,6 @@ int main( int /*argc*/, char ** argv)
       cout << "Caught exception: " << error_.what() << endl;
       return 1;
     }
-  
+
   return 0;
 }
index 7b10975..3714812 100644 (file)
@@ -82,6 +82,6 @@ int main( int /*argc*/, char ** argv)
       cout << "Caught exception: " << error_.what() << endl;
       return 1;
     }
-  
+
   return 0;
 }
index 989ea93..d43ca3d 100644 (file)
@@ -179,6 +179,6 @@ int main( int /*argc*/, char ** argv)
       cout << "Caught exception: " << error_.what() << endl;
       return 1;
     }
-  
+
   return 0;
 }
index 0069773..3e815eb 100644 (file)
@@ -120,6 +120,6 @@ int main( int /*argc*/, char ** argv)
       cout << "Caught exception: " << error_.what() << endl;
       return 1;
     }
-  
+
   return 0;
 }
index 32e73cd..0de71dc 100644 (file)
 
 #include <Magick++.h>
 #include <iostream>
+#include <fstream>
 #include <string>
-using namespace std; 
+
+using namespace std;
 using namespace Magick;
 
+//
+// Some compilers (e.g. older Tru64 UNIX) lack ios::binary
+//
+#if defined(MISSING_STD_IOS_BINARY)
+#  define IOS_IN_BINARY ios::in
+#else
+#  define IOS_IN_BINARY ios::in | ios::binary
+#endif
+
 static void Usage ( char **argv )
 {
   cout << "Usage: " << argv[0]
        << " [-density resolution] [-filter algorithm] [-geometry geometry]"
-       << " [-resample resolution] input_file output_file" << endl
+       << " [-resample resolution] [-read-blob] input_file output_file" << endl
        << "   algorithm - bessel blackman box catrom cubic gaussian hamming hanning" << endl
        << "     hermite lanczos mitchell point quadratic sample scale sinc triangle" << endl;
   exit(1);
@@ -31,7 +42,7 @@ static void ParseError (int position, char **argv)
   Usage(argv);
 }
 
-int main(int argc,char **argv) 
+int main(int argc,char **argv)
 {
   // Initialize ImageMagick install location for Windows
   InitializeMagick(*argv);
@@ -52,12 +63,19 @@ int main(int argc,char **argv)
     Geometry resample;
     Magick::FilterTypes filter(LanczosFilter);
     ResizeAlgorithm resize_algorithm=Zoom;
+    bool read_blob = false;
 
     int argv_index=1;
     while ((argv_index < argc - 2) && (*argv[argv_index] == '-'))
       {
         std::string command(argv[argv_index]);
-        if (command.compare("-density") == 0)
+        if (command.compare("-read-blob") == 0)
+          {
+            read_blob = true;
+            argv_index++;
+            continue;
+          }
+        else if (command.compare("-density") == 0)
           {
             argv_index++;
             try {
@@ -151,11 +169,63 @@ int main(int argc,char **argv)
     std::string output_file(argv[argv_index]);
 
     try {
-      Image image(input_file);
+      Image image;
+      if (read_blob)
+        {
+          // Read image data into a blob and use image blob reader.
+          Blob blob;
+          string magick;
+          string real_input_file = input_file;
+          string::size_type idx;
+          if ((idx=input_file.find(":")) != string::npos)
+            {
+              magick=input_file.substr(0,idx);
+              real_input_file=input_file.substr(idx+1);
+            }
+
+          cout << "Magick=\"" << magick << "\", real_input_file=\"" << real_input_file << "\"" << endl;
+
+          ifstream in( real_input_file.c_str(), IOS_IN_BINARY );
+          if( !in )
+          {
+            cout << "Failed to open file " << input_file << " for input!" << endl;
+            exit(1);
+          }
+          in.seekg(0,ios::end);
+          streampos file_size = in.tellg();
+          in.seekg(0,ios::beg);
+          unsigned char* blobData = new unsigned char[file_size];
+          char* c=reinterpret_cast<char *>(blobData);
+          in.read(c,file_size);
+          if (!in.good())
+            {
+              cout << "Failed to read file " << input_file << " for input!" << endl;
+              exit(1);
+            }
+          in.close();
+          cout << "Read " << file_size << " bytes from file \""
+               << input_file.c_str() << "\"..." << endl;
+          blob.updateNoCopy(blobData, file_size, Blob::NewAllocator );
+          //blob.update(blobData, file_size);
+          cout << "Reading file from blob with length " << blob.length() << endl;
+          // Set image file name to whatever was provided (could have
+          // magic prefix)
+          image.fileName(input_file);
+          //image.magick("TXT");
+          image.read(blob);
+          cout << "Reading file from blob" << endl;
+        }
+      else
+        {
+          // Read image directly from file
+          image.read(input_file);
+        }
       if (density.isValid())
         image.density(density);
       density=image.density();
 
+      // If resample was supplied, then rescale geometry and set
+      // resolution to new value.
       if (resample.isValid())
         {
           geometry =
@@ -165,6 +235,11 @@ int main(int argc,char **argv)
                      (image.rows()*((double)resample.height()/density.height())+0.5));
           image.density(resample);
         }
+      // Default to original geometry if it was not specified/changed
+      if (!geometry.isValid())
+        {
+          geometry = Geometry(image.columns(),image.rows());
+        }
       switch (resize_algorithm)
         {
         case Sample:
index 81f9534..0ad6b2d 100644 (file)
@@ -166,4 +166,3 @@ size_t Magick::Blob::length( void ) const
 {
   return _blobRef->_length;
 }
-
index 7eb90d8..0b7478b 100644 (file)
@@ -20,7 +20,7 @@
 
 // Construct with data, making private copy of data
 Magick::BlobRef::BlobRef ( const void* data_,
-                          size_t length_ )
+                           size_t length_ )
   : _data(0),
     _length(length_),
     _allocator(Magick::Blob::NewAllocator),
index 591cbe2..bcabc12 100644 (file)
@@ -20,21 +20,21 @@ using namespace std;
 // Color operator fuctions
 //
 int Magick::operator == ( const Magick::Color& left_,
-                         const Magick::Color& right_ )
+                          const Magick::Color& right_ )
 {
-  return ( ( left_.isValid()      == right_.isValid() ) && 
-          ( left_.redQuantum()   == right_.redQuantum() ) &&
-          ( left_.greenQuantum() == right_.greenQuantum() ) &&
-          ( left_.blueQuantum()  == right_.blueQuantum() )
-         );
+  return ( ( left_.isValid()      == right_.isValid() ) &&
+           ( left_.redQuantum()   == right_.redQuantum() ) &&
+           ( left_.greenQuantum() == right_.greenQuantum() ) &&
+           ( left_.blueQuantum()  == right_.blueQuantum() )
+          );
 }
 int Magick::operator != ( const Magick::Color& left_,
-                         const Magick::Color& right_ )
+                          const Magick::Color& right_ )
 {
   return ( ! (left_ == right_) );
 }
 int Magick::operator >  ( const Magick::Color& left_,
-                         const Magick::Color& right_ )
+                          const Magick::Color& right_ )
 {
   return ( !( left_ < right_ ) && ( left_ != right_ ) );
 }
@@ -42,7 +42,7 @@ int Magick::operator >  ( const Magick::Color& left_,
 // If intensities match, discriminate based on priority green, red,
 // & then blue.
 int Magick::operator <  ( const Magick::Color& left_,
-                         const Magick::Color& right_ )
+                          const Magick::Color& right_ )
 {
   double left_intensity=left_.intensity();
   double right_intensity=right_.intensity();
@@ -56,15 +56,15 @@ int Magick::operator <  ( const Magick::Color& left_,
                   (left_.blueQuantum() < right_.blueQuantum())
                   )
               )
-         );
+          );
 }
 int Magick::operator >= ( const Magick::Color& left_,
-                         const Magick::Color& right_ )
+                          const Magick::Color& right_ )
 {
   return ( ( left_ > right_ ) || ( left_ == right_ ) );
 }
 int Magick::operator <= ( const Magick::Color& left_,
-                         const Magick::Color& right_ )
+                          const Magick::Color& right_ )
 {
   return ( ( left_ < right_ ) || ( left_ == right_ ) );
 }
@@ -153,7 +153,7 @@ Magick::Color::Color ( const char * x11color_ )
 // Construct color via ImageMagick PixelPacket
 Magick::Color::Color ( const PixelPacket &color_ )
   : _pixel(new PixelPacket),
-    _pixelOwn(true),       // We allocated this pixel
+    _pixelOwn(true),        // We allocated this pixel
     _isValid(true),
     _pixelType(RGBPixel)  // RGB pixel by default
 {
@@ -214,9 +214,9 @@ const Magick::Color& Magick::Color::operator = ( const std::string &x11color_ )
       alphaQuantum( target_color.opacity );
 
       if ( target_color.opacity > OpaqueOpacity )
-       _pixelType = RGBAPixel;
+        _pixelType = RGBAPixel;
       else
-       _pixelType = RGBPixel;
+        _pixelType = RGBPixel;
     }
   else
     {
@@ -300,18 +300,18 @@ void Magick::Color::isValid ( bool valid_ )
 //
 
 Magick::ColorHSL::ColorHSL ( double hue_,
-                            double saturation_,
-                            double luminosity_ )
+                             double saturation_,
+                             double luminosity_ )
   : Color ()
 {
   Quantum red, green, blue;
 
   HSLTransform ( hue_,
-                saturation_,
-                luminosity_,
-                &red,
-                &green,
-                &blue );
+                 saturation_,
+                 luminosity_,
+                 &red,
+                 &green,
+                 &blue );
 
   redQuantum   ( red );
   greenQuantum ( green );
@@ -341,22 +341,22 @@ void Magick::ColorHSL::hue ( double hue_ )
 {
   double hue_val, saturation_val, luminosity_val;
   TransformHSL ( redQuantum(),
-                greenQuantum(),
-                blueQuantum(),
-                &hue_val,
-                &saturation_val,
-                &luminosity_val );
+                 greenQuantum(),
+                 blueQuantum(),
+                 &hue_val,
+                 &saturation_val,
+                 &luminosity_val );
 
   hue_val = hue_;
 
   Quantum red, green, blue;
   HSLTransform ( hue_val,
-                saturation_val,
-                luminosity_val,
-                &red,
-                &green,
-                &blue
-                );
+                 saturation_val,
+                 luminosity_val,
+                 &red,
+                 &green,
+                 &blue
+                 );
 
   redQuantum   ( red );
   greenQuantum ( green );
@@ -367,11 +367,11 @@ double Magick::ColorHSL::hue ( void ) const
 {
   double hue_val, saturation_val, luminosity_val;
   TransformHSL ( redQuantum(),
-                greenQuantum(),
-                blueQuantum(),
-                &hue_val,
-                &saturation_val,
-                &luminosity_val );
+                 greenQuantum(),
+                 blueQuantum(),
+                 &hue_val,
+                 &saturation_val,
+                 &luminosity_val );
   return hue_val;
 }
 
@@ -379,22 +379,22 @@ void Magick::ColorHSL::saturation ( double saturation_ )
 {
   double hue_val, saturation_val, luminosity_val;
   TransformHSL ( redQuantum(),
-                greenQuantum(),
-                blueQuantum(),
-                &hue_val,
-                &saturation_val,
-                &luminosity_val );
-  
+                 greenQuantum(),
+                 blueQuantum(),
+                 &hue_val,
+                 &saturation_val,
+                 &luminosity_val );
+
   saturation_val = saturation_;
-  
+
   Quantum red, green, blue;
   HSLTransform ( hue_val,
-                saturation_val,
-                luminosity_val,
-                &red,
-                &green,
-                &blue
-                );
+                 saturation_val,
+                 luminosity_val,
+                 &red,
+                 &green,
+                 &blue
+                 );
 
   redQuantum   ( red );
   greenQuantum ( green );
@@ -405,11 +405,11 @@ double Magick::ColorHSL::saturation ( void ) const
 {
   double hue_val, saturation_val, luminosity_val;
   TransformHSL ( redQuantum(),
-                greenQuantum(),
-                blueQuantum(),
-                &hue_val,
-                &saturation_val,
-                &luminosity_val );
+                 greenQuantum(),
+                 blueQuantum(),
+                 &hue_val,
+                 &saturation_val,
+                 &luminosity_val );
   return saturation_val;
 }
 
@@ -417,23 +417,23 @@ void Magick::ColorHSL::luminosity ( double luminosity_ )
 {
   double hue_val, saturation_val, luminosity_val;
   TransformHSL ( redQuantum(),
-                greenQuantum(),
-                blueQuantum(),
-                &hue_val,
-                &saturation_val,
-                &luminosity_val );
-  
+                 greenQuantum(),
+                 blueQuantum(),
+                 &hue_val,
+                 &saturation_val,
+                 &luminosity_val );
+
   luminosity_val = luminosity_;
-  
+
   Quantum red, green, blue;
   HSLTransform ( hue_val,
-                saturation_val,
-                luminosity_val,
-                &red,
-                &green,
-                &blue
-                );
-  
+                 saturation_val,
+                 luminosity_val,
+                 &red,
+                 &green,
+                 &blue
+                 );
+
   redQuantum   ( red );
   greenQuantum ( green );
   blueQuantum  ( blue );
@@ -443,11 +443,11 @@ double Magick::ColorHSL::luminosity ( void ) const
 {
   double hue_val, saturation_val, luminosity_val;
   TransformHSL ( redQuantum(),
-                greenQuantum(),
-                blueQuantum(),
-                &hue_val,
-                &saturation_val,
-                &luminosity_val );
+                 greenQuantum(),
+                 blueQuantum(),
+                 &hue_val,
+                 &saturation_val,
+                 &luminosity_val );
   return luminosity_val;
 }
 
@@ -463,8 +463,8 @@ Magick::ColorHSL& Magick::ColorHSL::operator = ( const Magick::Color& color_ )
 //
 Magick::ColorGray::ColorGray ( double shade_ )
   : Color ( scaleDoubleToQuantum( shade_ ),
-           scaleDoubleToQuantum( shade_ ),
-           scaleDoubleToQuantum( shade_ ) )
+            scaleDoubleToQuantum( shade_ ),
+            scaleDoubleToQuantum( shade_ ) )
 {
   alphaQuantum ( OpaqueOpacity );
 }
@@ -512,8 +512,8 @@ Magick::ColorGray& Magick::ColorGray::operator = ( const Magick::Color& color_ )
 //
 Magick::ColorMono::ColorMono ( bool mono_  )
   : Color ( ( mono_ ? MaxRGB : 0 ),
-           ( mono_ ? MaxRGB : 0 ),
-           ( mono_ ? MaxRGB : 0 ) )
+            ( mono_ ? MaxRGB : 0 ),
+            ( mono_ ? MaxRGB : 0 ) )
 {
   alphaQuantum ( OpaqueOpacity );
 }
@@ -564,11 +564,11 @@ Magick::ColorMono& Magick::ColorMono::operator = ( const Magick::Color& color_ )
 
 // Construct from red, green, and blue, components
 Magick::ColorRGB::ColorRGB ( double red_,
-                            double green_,
-                            double blue_ )
+                             double green_,
+                             double blue_ )
   : Color ( scaleDoubleToQuantum(red_),
-           scaleDoubleToQuantum(green_),
-           scaleDoubleToQuantum(blue_) )
+            scaleDoubleToQuantum(green_),
+            scaleDoubleToQuantum(blue_) )
 {
   alphaQuantum ( OpaqueOpacity );
 }
@@ -616,11 +616,11 @@ Magick::ColorRGB& Magick::ColorRGB::operator = ( const Magick::Color& color_ )
 
 // Construct from color components
 Magick::ColorYUV::ColorYUV ( double y_,
-                            double u_,
-                            double v_ )
+                             double u_,
+                             double v_ )
   : Color ( scaleDoubleToQuantum(y_ + 1.13980 * v_ ),
-           scaleDoubleToQuantum(y_ - (0.39380 * u_) - (0.58050 * v_) ),
-           scaleDoubleToQuantum(y_ + 2.02790 * u_ ) )
+            scaleDoubleToQuantum(y_ - (0.39380 * u_) - (0.58050 * v_) ),
+            scaleDoubleToQuantum(y_ + 2.02790 * u_ ) )
 {
   alphaQuantum ( OpaqueOpacity );
 }
@@ -653,7 +653,7 @@ void Magick::ColorYUV::u ( double u_ )
 double Magick::ColorYUV::u ( void ) const
 {
   return scaleQuantumToDouble( (-0.14740 * redQuantum()) - (0.28950 *
-                              greenQuantum()) + (0.43690 * blueQuantum()) );
+                               greenQuantum()) + (0.43690 * blueQuantum()) );
 }
 
 void Magick::ColorYUV::v ( double v_ )
@@ -685,7 +685,7 @@ void Magick::ColorYUV::y ( double y_ )
 
 double Magick::ColorYUV::y ( void ) const
 {
-  return scaleQuantumToDouble((0.29900 * redQuantum()) + 
+  return scaleQuantumToDouble((0.29900 * redQuantum()) +
                               (0.58700 * greenQuantum()) +
                               (0.11400 * blueQuantum()));
 }
index c760823..b985520 100644 (file)
@@ -1,6 +1,6 @@
 // This may look like C code, but it is really -*- C++ -*-
 //
-// Copyright Bob Friesenhahn, 1999 - 2016
+// Copyright Bob Friesenhahn, 1999 - 2018
 //
 // Implementation of Drawable (Graphic objects)
 //
@@ -290,7 +290,7 @@ void Magick::DrawableBezier::operator()( MagickLib::DrawContext context_ ) const
       p++;
     }
 
-  DrawBezier( context_, (const unsigned long) num_coords, coordinates );
+  DrawBezier( context_, (unsigned long) num_coords, coordinates );
   delete [] coordinates;
 }
 Magick::DrawableBase* Magick::DrawableBezier::copy() const
@@ -299,7 +299,7 @@ Magick::DrawableBase* Magick::DrawableBezier::copy() const
 }
 
 //
-//Clip Path 
+//Clip Path
 //
 
 // Pop (terminate) Clip path definition
@@ -358,7 +358,7 @@ Magick::DrawableClipPath::~DrawableClipPath( void )
 }
 void Magick::DrawableClipPath::operator()( MagickLib::DrawContext context_ ) const
 {
-       DrawSetClipPath( context_, _id.c_str());
+        DrawSetClipPath( context_, _id.c_str());
 }
 Magick::DrawableBase* Magick::DrawableClipPath::copy() const
 {
@@ -800,7 +800,7 @@ void Magick::DrawablePolygon::operator()
       p++;
     }
 
-  DrawPolygon( context_, (const unsigned long) num_coords, coordinates );
+  DrawPolygon( context_, (unsigned long) num_coords, coordinates );
   delete [] coordinates;
 }
 Magick::DrawableBase* Magick::DrawablePolygon::copy() const
@@ -840,7 +840,7 @@ void Magick::DrawablePolyline::operator()
       p++;
     }
 
-  DrawPolyline( context_, (const unsigned long) num_coords, coordinates );
+  DrawPolyline( context_, (unsigned long) num_coords, coordinates );
   delete [] coordinates;
 }
 Magick::DrawableBase* Magick::DrawablePolyline::copy() const
@@ -1064,7 +1064,7 @@ Magick::DrawableDashArray& Magick::DrawableDashArray::operator=
 void Magick::DrawableDashArray::operator()
   ( MagickLib::DrawContext context_ ) const
 {
-  DrawSetStrokeDashArray( context_, (const unsigned long) _size, _dasharray );
+  DrawSetStrokeDashArray( context_, (unsigned long) _size, _dasharray );
 }
 Magick::DrawableBase* Magick::DrawableDashArray::copy() const
 {
@@ -1777,7 +1777,7 @@ MagickDLLDecl int Magick::operator >
 {
   return ( 0 );
 }
-MagickDLLDecl int Magick::operator < 
+MagickDLLDecl int Magick::operator <
 ( const Magick::PathQuadraticCurvetoArgs& /*left_*/,
   const Magick::PathQuadraticCurvetoArgs& /*right_*/ )
 {
@@ -1832,7 +1832,7 @@ Magick::PathQuadraticCurvetoAbs::PathQuadraticCurvetoAbs
   : _args(1,args_)
 {
 }
-Magick::PathQuadraticCurvetoAbs::PathQuadraticCurvetoAbs 
+Magick::PathQuadraticCurvetoAbs::PathQuadraticCurvetoAbs
 ( const PathQuadraticCurvetoArgsList &args_ )
   : _args(args_)
 {
index b09bdcd..83e3539 100644 (file)
@@ -570,5 +570,4 @@ MagickDLLDecl void Magick::throwException( ExceptionInfo &exception_,
     default :
       throw ErrorUndefined( message );
     }
-
 }
index 9b0d39c..5981640 100644 (file)
@@ -155,61 +155,61 @@ bool Magick::Geometry::fillArea ( void ) const
 
 
 int Magick::operator == ( const Magick::Geometry& left_,
-                         const Magick::Geometry& right_ )
+                          const Magick::Geometry& right_ )
 {
   return (
-         ( left_.isValid()     == right_.isValid() ) &&
-         ( left_.width()       == right_.width() ) &&
-         ( left_.height()      == right_.height() ) &&
-         ( left_.xOff()        == right_.xOff() ) &&
-         ( left_.yOff()        == right_.yOff() ) &&
-         ( left_.xNegative()   == right_.xNegative() ) &&
-         ( left_.yNegative()   == right_.yNegative() ) &&
-         ( left_.percent()     == right_.percent() ) &&
-         ( left_.aspect()      == right_.aspect() ) &&
-         ( left_.greater()     == right_.greater() ) &&
-         ( left_.less()        == right_.less() ) &&
-         ( left_.limitPixels() == right_.limitPixels() ) &&
+          ( left_.isValid()     == right_.isValid() ) &&
+          ( left_.width()       == right_.width() ) &&
+          ( left_.height()      == right_.height() ) &&
+          ( left_.xOff()        == right_.xOff() ) &&
+          ( left_.yOff()        == right_.yOff() ) &&
+          ( left_.xNegative()   == right_.xNegative() ) &&
+          ( left_.yNegative()   == right_.yNegative() ) &&
+          ( left_.percent()     == right_.percent() ) &&
+          ( left_.aspect()      == right_.aspect() ) &&
+          ( left_.greater()     == right_.greater() ) &&
+          ( left_.less()        == right_.less() ) &&
+          ( left_.limitPixels() == right_.limitPixels() ) &&
           ( left_.fillArea()    == right_.fillArea() )
-         );
+          );
 }
 int Magick::operator != ( const Magick::Geometry& left_,
-                         const Magick::Geometry& right_ )
+                          const Magick::Geometry& right_ )
 {
   return ( ! (left_ == right_) );
 }
 int Magick::operator >  ( const Magick::Geometry& left_,
-                         const Magick::Geometry& right_ )
+                          const Magick::Geometry& right_ )
 {
   return ( !( left_ < right_ ) && ( left_ != right_ ) );
 }
 int Magick::operator <  ( const Magick::Geometry& left_,
-                         const Magick::Geometry& right_ )
+                          const Magick::Geometry& right_ )
 {
   return (
-         ( left_.width() * left_.height() )
-         <
-         ( right_.width() * right_.height() )
-         );
+          ( left_.width() * left_.height() )
+          <
+          ( right_.width() * right_.height() )
+          );
 }
 int Magick::operator >= ( const Magick::Geometry& left_,
-                         const Magick::Geometry& right_ )
+                          const Magick::Geometry& right_ )
 {
   return ( ( left_ > right_ ) || ( left_ == right_ ) );
 }
 int Magick::operator <= ( const Magick::Geometry& left_,
-                         const Magick::Geometry& right_ )
+                          const Magick::Geometry& right_ )
 {
   return ( ( left_ < right_ ) || ( left_ == right_ ) );
 }
 
 // Construct using parameterized arguments
 Magick::Geometry::Geometry ( unsigned int width_,
-                            unsigned int height_,
-                            unsigned int xOff_,
-                            unsigned int yOff_,
-                            bool xNegative_,
-                            bool yNegative_ )
+                             unsigned int height_,
+                             unsigned int xOff_,
+                             unsigned int yOff_,
+                             bool xNegative_,
+                             bool yNegative_ )
   : _width( width_ ),
     _height( height_ ),
     _xOff( xOff_ ),
@@ -349,10 +349,10 @@ Magick::Geometry::operator = ( const std::string &geometry_ )
     {
       char *pageptr = GetPageGeometry( geom );
       if ( pageptr != 0 )
-       {
-         strlcpy(geom,pageptr,sizeof(geom));
+        {
+          strlcpy(geom,pageptr,sizeof(geom));
           MagickFreeMemory(pageptr);
-       }
+        }
     }
 
   long x = 0;
index 01b9f79..d56e3e5 100644 (file)
@@ -49,9 +49,9 @@ MagickDLLDecl int Magick::operator == ( const Magick::Image& left_,
 {
   // If image pixels and signature are the same, then the image is identical
   return ( ( left_.rows() == right_.rows() ) &&
-          ( left_.columns() == right_.columns() ) &&
-          ( left_.signature() == right_.signature() )
-          );
+           ( left_.columns() == right_.columns() ) &&
+           ( left_.signature() == right_.signature() )
+           );
 }
 MagickDLLDecl int Magick::operator != ( const Magick::Image& left_,
                                         const Magick::Image& right_ )
@@ -68,8 +68,8 @@ MagickDLLDecl int Magick::operator <  ( const Magick::Image& left_,
 {
   // If image pixels are less, then image is smaller
   return ( ( left_.rows() * left_.columns() ) <
-          ( right_.rows() * right_.columns() )
-          );
+           ( right_.rows() * right_.columns() )
+           );
 }
 MagickDLLDecl int Magick::operator >= ( const Magick::Image& left_,
                                         const Magick::Image& right_ )
@@ -109,7 +109,7 @@ Magick::Image::Image( const std::string &imageSpec_ )
 
 // Construct a blank image canvas of specified size and color
 Magick::Image::Image( const Geometry &size_,
-                     const Color &color_ )
+                      const Color &color_ )
   : _imgRef(new ImageRef)
 {
   // xc: prefix specifies an X11 color string
@@ -159,7 +159,7 @@ Magick::Image::Image ( const Blob &blob_ )
 
 // Construct Image of specified size from in-memory BLOB
 Magick::Image::Image ( const Blob &blob_,
-                      const Geometry &size_ )
+                       const Geometry &size_ )
   : _imgRef(new ImageRef)
 {
   try
@@ -181,8 +181,8 @@ Magick::Image::Image ( const Blob &blob_,
 
 // Construct Image of specified size and depth from in-memory BLOB
 Magick::Image::Image ( const Blob &blob_,
-                      const Geometry &size_,
-                      const unsigned int depth_ )
+                       const Geometry &size_,
+                       const unsigned int depth_ )
   : _imgRef(new ImageRef)
 {
   try
@@ -204,9 +204,9 @@ Magick::Image::Image ( const Blob &blob_,
 
 // Construct Image of specified size, depth, and format from in-memory BLOB
 Magick::Image::Image ( const Blob &blob_,
-                      const Geometry &size_,
-                      const unsigned int depth_,
-                      const std::string &magick_ )
+                       const Geometry &size_,
+                       const unsigned int depth_,
+                       const std::string &magick_ )
   : _imgRef(new ImageRef)
 {
   try
@@ -228,8 +228,8 @@ Magick::Image::Image ( const Blob &blob_,
 
 // Construct Image of specified size, and format from in-memory BLOB
 Magick::Image::Image ( const Blob &blob_,
-                      const Geometry &size_,
-                      const std::string &magick_ )
+                       const Geometry &size_,
+                       const std::string &magick_ )
   : _imgRef(new ImageRef)
 {
   try
@@ -337,8 +337,8 @@ void Magick::Image::addNoise( const NoiseType noiseType_ )
   GetExceptionInfo( &exceptionInfo );
   MagickLib::Image* newImage =
     AddNoiseImage ( image(),
-                   noiseType_,
-                   &exceptionInfo );
+                    noiseType_,
+                    &exceptionInfo );
   replaceImage( newImage );
   throwImageException( exceptionInfo );
 }
@@ -378,23 +378,23 @@ void Magick::Image::affineTransform ( const DrawableAffine &affine_ )
 
 // Annotate using specified text, and placement location
 void Magick::Image::annotate ( const std::string &text_,
-                              const Geometry &location_ )
+                               const Geometry &location_ )
 {
   annotate ( text_, location_,  NorthWestGravity, 0.0 );
 }
 // Annotate using specified text, bounding area, and placement gravity
 void Magick::Image::annotate ( const std::string &text_,
-                              const Geometry &boundingArea_,
-                              const GravityType gravity_ )
+                               const Geometry &boundingArea_,
+                               const GravityType gravity_ )
 {
   annotate ( text_, boundingArea_, gravity_, 0.0 );
 }
 // Annotate with text using specified text, bounding area, placement
 // gravity, and rotation.
 void Magick::Image::annotate ( const std::string &text_,
-                              const Geometry &boundingArea_,
-                              const GravityType gravity_,
-                              const double degrees_ )
+                               const Geometry &boundingArea_,
+                               const GravityType gravity_,
+                               const double degrees_ )
 {
   modifyImage();
 
@@ -459,7 +459,7 @@ void Magick::Image::annotate ( const std::string &text_,
 }
 // Annotate with text (bounding area is entire image) and placement gravity.
 void Magick::Image::annotate ( const std::string &text_,
-                              const GravityType gravity_ )
+                               const GravityType gravity_ )
 {
   modifyImage();
 
@@ -478,6 +478,21 @@ void Magick::Image::annotate ( const std::string &text_,
   throwImageException();
 }
 
+// Orient image to be right-side up based on its current orientation
+// attribute.  This allows the image to be viewed correctly when the
+// orientation attribute is not available, or is not respected.
+void Magick::Image::autoOrient( void )
+{
+  ExceptionInfo exceptionInfo;
+  GetExceptionInfo( &exceptionInfo );
+  MagickLib::Image* newImage =
+    AutoOrientImage ( image(),
+                      orientation(),
+                      &exceptionInfo );
+  replaceImage( newImage );
+  throwImageException( exceptionInfo );
+}
+
 // Blur image
 void Magick::Image::blur( const double radius_, const double sigma_ )
 {
@@ -580,12 +595,12 @@ void Magick::Image::chop( const Geometry &geometry_ )
 void Magick::Image::colorize ( const unsigned int opacityRed_,
                                const unsigned int opacityGreen_,
                                const unsigned int opacityBlue_,
-                              const Color &penColor_ )
+                               const Color &penColor_ )
 {
   if ( !penColor_.isValid() )
   {
     throwExceptionExplicit( OptionError,
-                           "Pen color argument is invalid");
+                            "Pen color argument is invalid");
   }
 
   char opacity[MaxTextExtent];
@@ -595,12 +610,12 @@ void Magick::Image::colorize ( const unsigned int opacityRed_,
   GetExceptionInfo( &exceptionInfo );
   MagickLib::Image* newImage =
   ColorizeImage ( image(), opacity,
-                 penColor_, &exceptionInfo );
+                  penColor_, &exceptionInfo );
   replaceImage( newImage );
   throwImageException( exceptionInfo );
 }
 void Magick::Image::colorize ( const unsigned int opacity_,
-                              const Color &penColor_ )
+                               const Color &penColor_ )
 {
   colorize( opacity_, opacity_, opacity_, penColor_ );
 }
@@ -608,7 +623,7 @@ void Magick::Image::colorize ( const unsigned int opacity_,
 // Apply a color matrix to the image channels.  The user supplied
 // matrix may be of order 1 to 5 (1x1 through 5x5).
 void Magick::Image::colorMatrix (const unsigned int order_,
-                                const double *color_matrix_)
+                                 const double *color_matrix_)
 {
   modifyImage();
   (void) ColorMatrixImage(image(),order_,color_matrix_);
@@ -628,24 +643,24 @@ bool Magick::Image::compare ( const Image &reference_ )
 
 // Composite two images
 void Magick::Image::composite ( const Image &compositeImage_,
-                               const int xOffset_,
-                               const int yOffset_,
-                               const CompositeOperator compose_ )
+                                const int xOffset_,
+                                const int yOffset_,
+                                const CompositeOperator compose_ )
 {
   // Image supplied as compositeImage is composited with current image and
   // results in updating current image.
   modifyImage();
 
   CompositeImage( image(),
-                 compose_,
-                 compositeImage_.constImage(),
-                 xOffset_,
+                  compose_,
+                  compositeImage_.constImage(),
+                  xOffset_,
                   yOffset_ );
   throwImageException();
 }
 void Magick::Image::composite ( const Image &compositeImage_,
-                               const Geometry &offset_,
-                               const CompositeOperator compose_ )
+                                const Geometry &offset_,
+                                const CompositeOperator compose_ )
 {
   modifyImage();
 
@@ -655,18 +670,18 @@ void Magick::Image::composite ( const Image &compositeImage_,
   unsigned long height = rows();
 
   GetMagickGeometry (static_cast<std::string>(offset_).c_str(),
-                     &x, &y,
-                     &width, &height );
+                      &x, &y,
+                      &width, &height );
 
   CompositeImage( image(),
-                 compose_,
-                 compositeImage_.constImage(),
-                 x, y );
+                  compose_,
+                  compositeImage_.constImage(),
+                  x, y );
   throwImageException();
 }
 void Magick::Image::composite ( const Image &compositeImage_,
-                               const GravityType gravity_,
-                               const CompositeOperator compose_ )
+                                const GravityType gravity_,
+                                const CompositeOperator compose_ )
 {
   modifyImage();
 
@@ -677,67 +692,67 @@ void Magick::Image::composite ( const Image &compositeImage_,
     {
     case NorthWestGravity:
       {
-       x = 0;
-       y = 0;
-       break;
+        x = 0;
+        y = 0;
+        break;
       }
     case NorthGravity:
       {
-       x = (columns() - compositeImage_.columns()) >> 1;
-       y = 0;
-       break;
+        x = (columns() - compositeImage_.columns()) >> 1;
+        y = 0;
+        break;
       }
     case NorthEastGravity:
       {
-       x = static_cast<long>(columns() - compositeImage_.columns());
-       y = 0;
-       break;
+        x = static_cast<long>(columns() - compositeImage_.columns());
+        y = 0;
+        break;
       }
     case WestGravity:
       {
-       x = 0;
-       y = (rows() - compositeImage_.rows()) >> 1;
-       break;
+        x = 0;
+        y = (rows() - compositeImage_.rows()) >> 1;
+        break;
       }
     case ForgetGravity:
     case StaticGravity:
     case CenterGravity:
     default:
       {
-       x = (columns() - compositeImage_.columns()) >> 1;
-       y = (rows() - compositeImage_.rows()) >> 1;
-       break;
+        x = (columns() - compositeImage_.columns()) >> 1;
+        y = (rows() - compositeImage_.rows()) >> 1;
+        break;
       }
     case EastGravity:
       {
-       x = static_cast<long>(columns() - compositeImage_.columns());
-       y = (rows() - compositeImage_.rows()) >> 1;
-       break;
+        x = static_cast<long>(columns() - compositeImage_.columns());
+        y = (rows() - compositeImage_.rows()) >> 1;
+        break;
       }
     case SouthWestGravity:
       {
-       x = 0;
-       y = static_cast<long>(rows() - compositeImage_.rows());
-       break;
+        x = 0;
+        y = static_cast<long>(rows() - compositeImage_.rows());
+        break;
       }
     case SouthGravity:
       {
-       x =  (columns() - compositeImage_.columns()) >> 1;
-       y = static_cast<long>(rows() - compositeImage_.rows());
-       break;
+        x =  (columns() - compositeImage_.columns()) >> 1;
+        y = static_cast<long>(rows() - compositeImage_.rows());
+        break;
       }
     case SouthEastGravity:
       {
-       x = static_cast<long>(columns() - compositeImage_.columns());
-       y = static_cast<long>(rows() - compositeImage_.rows());
-       break;
+        x = static_cast<long>(columns() - compositeImage_.columns());
+        y = static_cast<long>(rows() - compositeImage_.rows());
+        break;
       }
     }
 
   CompositeImage( image(),
-                 compose_,
-                 compositeImage_.constImage(),
-                 x, y );
+                  compose_,
+                  compositeImage_.constImage(),
+                  x, y );
   throwImageException();
 }
 
@@ -759,7 +774,7 @@ void Magick::Image::convolve ( const unsigned int order_,
   GetExceptionInfo( &exceptionInfo );
   MagickLib::Image* newImage =
   ConvolveImage ( image(), order_,
-                 kernel_, &exceptionInfo );
+                  kernel_, &exceptionInfo );
   replaceImage( newImage );
   throwImageException( exceptionInfo );
 }
@@ -772,8 +787,8 @@ void Magick::Image::crop ( const Geometry &geometry_ )
   GetExceptionInfo( &exceptionInfo );
   MagickLib::Image* newImage =
     CropImage( image(),
-              &cropInfo,
-              &exceptionInfo);
+               &cropInfo,
+               &exceptionInfo);
   replaceImage( newImage );
   throwImageException( exceptionInfo );
 }
@@ -965,12 +980,12 @@ void Magick::Image::flip ( void )
 // Uses current fuzz setting when determining color match.
 void Magick::Image::floodFillColor( const unsigned int x_,
                                     const unsigned int y_,
-                                   const Magick::Color &fillColor_ )
+                                    const Magick::Color &fillColor_ )
 {
   floodFillTexture( x_, y_, Image( Geometry( 1, 1), fillColor_ ) );
 }
 void Magick::Image::floodFillColor( const Geometry &point_,
-                                   const Magick::Color &fillColor_ )
+                                    const Magick::Color &fillColor_ )
 {
   floodFillTexture( point_, Image( Geometry( 1, 1), fillColor_) );
 }
@@ -980,15 +995,15 @@ void Magick::Image::floodFillColor( const Geometry &point_,
 // Uses current fuzz setting when determining color match.
 void Magick::Image::floodFillColor( const unsigned int x_,
                                     const unsigned int y_,
-                                   const Magick::Color &fillColor_,
-                                   const Magick::Color &borderColor_ )
+                                    const Magick::Color &fillColor_,
+                                    const Magick::Color &borderColor_ )
 {
   floodFillTexture( x_, y_, Image( Geometry( 1, 1), fillColor_),
                     borderColor_ );
 }
 void Magick::Image::floodFillColor( const Geometry &point_,
-                                   const Magick::Color &fillColor_,
-                                   const Magick::Color &borderColor_ )
+                                    const Magick::Color &fillColor_,
+                                    const Magick::Color &borderColor_ )
 {
   floodFillTexture( point_, Image( Geometry( 1, 1), fillColor_),
                     borderColor_ );
@@ -1005,7 +1020,7 @@ void Magick::Image::floodFillOpacity( const unsigned int x_,
   MatteFloodfillImage ( image(),
                         static_cast<PixelPacket>(pixelColor(x_,y_)),
                         opacity_,
-                       static_cast<long>(x_), static_cast<long>(y_),
+                        static_cast<long>(x_), static_cast<long>(y_),
                         method_ );
   throwImageException();
 }
@@ -1015,7 +1030,7 @@ void Magick::Image::floodFillOpacity( const unsigned int x_,
 // Uses current fuzz setting when determining color match.
 void Magick::Image::floodFillTexture( const unsigned int x_,
                                       const unsigned int y_,
-                                     const Magick::Image &texture_ )
+                                      const Magick::Image &texture_ )
 {
   modifyImage();
 
@@ -1038,7 +1053,7 @@ void Magick::Image::floodFillTexture( const unsigned int x_,
   throwImageException();
 }
 void Magick::Image::floodFillTexture( const Magick::Geometry &point_,
-                                     const Magick::Image &texture_ )
+                                      const Magick::Image &texture_ )
 {
   floodFillTexture( point_.xOff(), point_.yOff(), texture_ );
 }
@@ -1048,8 +1063,8 @@ void Magick::Image::floodFillTexture( const Magick::Geometry &point_,
 // Uses current fuzz setting when determining color match.
 void Magick::Image::floodFillTexture( const unsigned int x_,
                                       const unsigned int y_,
-                                     const Magick::Image &texture_,
-                                     const Magick::Color &borderColor_ )
+                                      const Magick::Image &texture_,
+                                      const Magick::Color &borderColor_ )
 {
   modifyImage();
 
@@ -1067,8 +1082,8 @@ void Magick::Image::floodFillTexture( const unsigned int x_,
   throwImageException();
 }
 void  Magick::Image::floodFillTexture( const Magick::Geometry &point_,
-                                      const Magick::Image &texture_,
-                                      const Magick::Color &borderColor_ )
+                                       const Magick::Image &texture_,
+                                       const Magick::Color &borderColor_ )
 {
   floodFillTexture( point_.xOff(), point_.yOff(), texture_, borderColor_ );
 }
@@ -1105,7 +1120,7 @@ void Magick::Image::frame ( const Geometry &geometry_ )
 }
 void Magick::Image::frame ( const unsigned int width_,
                             const unsigned int height_,
-                           const int innerBevel_, const int outerBevel_ )
+                            const int innerBevel_, const int outerBevel_ )
 {
   FrameInfo info;
   info.x           = static_cast<long>(width_);
@@ -1134,11 +1149,11 @@ void Magick::Image::gamma ( const double gamma_ )
 }
 void Magick::Image::gamma ( const double gammaRed_,
                             const double gammaGreen_,
-                           const double gammaBlue_ )
+                            const double gammaBlue_ )
 {
   char gamma[MaxTextExtent + 1];
   FormatString( gamma, "%3.6f/%3.6f/%3.6f/",
-               gammaRed_, gammaGreen_, gammaBlue_);
+                gammaRed_, gammaGreen_, gammaBlue_);
 
   modifyImage();
   GammaImage ( image(), gamma );
@@ -1253,9 +1268,9 @@ void Magick::Image::map ( const Image &mapImage_ , const bool dither_ )
 }
 // Floodfill designated area with replacement opacity value
 void Magick::Image::matteFloodfill ( const Color &target_ ,
-                                    const unsigned int opacity_,
-                                    const int x_, const int y_,
-                                    const Magick::PaintMethod method_ )
+                                     const unsigned int opacity_,
+                                     const int x_, const int y_,
+                                     const Magick::PaintMethod method_ )
 {
   modifyImage();
   MatteFloodfillImage ( image(), static_cast<PixelPacket>(target_),
@@ -1288,12 +1303,12 @@ void Magick::Image::minify ( void )
 
 // Modulate percent hue, saturation, and brightness of an image
 void Magick::Image::modulate ( const double brightness_,
-                              const double saturation_,
-                              const double hue_ )
+                               const double saturation_,
+                               const double hue_ )
 {
   char modulate[MaxTextExtent + 1];
   FormatString( modulate, "%3.6f/%3.6f/%3.6f",
-               brightness_, saturation_, hue_);
+                brightness_, saturation_, hue_);
 
   modifyImage();
   ModulateImage( image(), modulate );
@@ -1361,17 +1376,17 @@ void Magick::Image::opacity ( const unsigned int opacity_ )
 
 // Change the color of an opaque pixel to the pen color.
 void Magick::Image::opaque ( const Color &opaqueColor_,
-                            const Color &penColor_ )
+                             const Color &penColor_ )
 {
   if ( !opaqueColor_.isValid() )
   {
     throwExceptionExplicit( OptionError,
-                           "Opaque color argument is invalid" );
+                            "Opaque color argument is invalid" );
   }
   if ( !penColor_.isValid() )
   {
     throwExceptionExplicit( OptionError,
-                           "Pen color argument is invalid" );
+                            "Pen color argument is invalid" );
   }
 
   modifyImage();
@@ -1448,7 +1463,7 @@ void Magick::Image::quantumOperator ( const ChannelType channel_,
   GetExceptionInfo( &exceptionInfo );
   modifyImage();
   QuantumOperatorImage( image(), channel_, operator_, static_cast<double>(rvalue_),
-                       &exceptionInfo);
+                        &exceptionInfo);
   throwImageException( exceptionInfo );
 }
 void Magick::Image::quantumOperator ( const ChannelType channel_,
@@ -1473,7 +1488,7 @@ void Magick::Image::quantumOperator ( const int x_,const int y_,
   modifyImage();
   QuantumOperatorRegionImage( image(), x_, y_, columns_, rows_, channel_,
                               operator_, static_cast<double>(rvalue_),
-                             &exceptionInfo);
+                              &exceptionInfo);
   throwImageException( exceptionInfo );
 }
 void Magick::Image::quantumOperator ( const int x_,const int y_,
@@ -1494,7 +1509,7 @@ void Magick::Image::quantumOperator ( const int x_,const int y_,
 // Raise image (lighten or darken the edges of an image to give a 3-D
 // raised or lowered effect)
 void Magick::Image::raise ( const Geometry &geometry_ ,
-                           const bool raisedFlag_ )
+                            const bool raisedFlag_ )
 {
   RectangleInfo raiseInfo = geometry_;
   modifyImage();
@@ -1533,6 +1548,8 @@ void Magick::Image::randomThresholdChannel( const Geometry &thresholds_,
 void Magick::Image::read ( const std::string &imageSpec_ )
 {
   options()->fileName( imageSpec_ );
+  // This interface only supports reading one image frame
+  options()->subRange(1);
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
@@ -1557,7 +1574,7 @@ void Magick::Image::read ( const std::string &imageSpec_ )
 
 // Read image of specified size into current object
 void Magick::Image::read ( const Geometry &size_,
-                          const std::string &imageSpec_ )
+                           const std::string &imageSpec_ )
 {
   size( size_ );
   read( imageSpec_ );
@@ -1568,10 +1585,12 @@ void Magick::Image::read ( const Blob &blob_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
+  // This interface only supports reading one image frame
+  options()->subRange(1);
   MagickLib::Image* image =
     BlobToImage( imageInfo(),
-                static_cast<const void *>(blob_.data()),
-                blob_.length(), &exceptionInfo );
+                 static_cast<const void *>(blob_.data()),
+                 blob_.length(), &exceptionInfo );
   replaceImage( image );
   throwImageException( exceptionInfo );
   if ( image )
@@ -1580,7 +1599,7 @@ void Magick::Image::read ( const Blob &blob_ )
 
 // Read image of specified size from in-memory BLOB
 void  Magick::Image::read ( const Blob &blob_,
-                           const Geometry &size_ )
+                            const Geometry &size_ )
 {
   // Set image size
   size( size_ );
@@ -1590,8 +1609,8 @@ void  Magick::Image::read ( const Blob &blob_,
 
 // Read image of specified size and depth from in-memory BLOB
 void Magick::Image::read ( const Blob &blob_,
-                          const Geometry &size_,
-                          const unsigned int depth_ )
+                           const Geometry &size_,
+                           const unsigned int depth_ )
 {
   // Set image size
   size( size_ );
@@ -1603,9 +1622,9 @@ void Magick::Image::read ( const Blob &blob_,
 
 // Read image of specified size, depth, and format from in-memory BLOB
 void Magick::Image::read ( const Blob &blob_,
-                          const Geometry &size_,
-                          const unsigned int depth_,
-                          const std::string &magick_ )
+                           const Geometry &size_,
+                           const unsigned int depth_,
+                           const std::string &magick_ )
 {
   // Set image size
   size( size_ );
@@ -1619,8 +1638,8 @@ void Magick::Image::read ( const Blob &blob_,
 
 // Read image of specified size, and format from in-memory BLOB
 void Magick::Image::read ( const Blob &blob_,
-                          const Geometry &size_,
-                          const std::string &magick_ )
+                           const Geometry &size_,
+                           const std::string &magick_ )
 {
   // Set image size
   size( size_ );
@@ -1756,8 +1775,8 @@ void Magick::Image::sample ( const Geometry &geometry_ )
   unsigned long height = rows();
 
   GetMagickGeometry (static_cast<std::string>(geometry_).c_str(),
-                     &x, &y,
-                     &width, &height );
+                      &x, &y,
+                      &width, &height );
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
@@ -1776,8 +1795,8 @@ void Magick::Image::scale ( const Geometry &geometry_ )
   unsigned long height = rows();
 
   GetMagickGeometry (static_cast<std::string>(geometry_).c_str(),
-                     &x, &y,
-                     &width, &height );
+                      &x, &y,
+                      &width, &height );
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
@@ -1797,8 +1816,8 @@ void Magick::Image::thumbnail ( const Geometry &geometry_ )
   unsigned long height = rows();
 
   GetMagickGeometry (static_cast<std::string>(geometry_).c_str(),
-                     &x, &y,
-                     &width, &height );
+                      &x, &y,
+                      &width, &height );
 
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
@@ -1812,14 +1831,14 @@ void Magick::Image::thumbnail ( const Geometry &geometry_ )
 // histograms of the color components and identifying units that are
 // homogeneous with the fuzzy c-means technique.
 void Magick::Image::segment ( const double clusterThreshold_,
-                             const double smoothingThreshold_ )
+                              const double smoothingThreshold_ )
 {
   modifyImage();
   SegmentImage ( image(),
-                options()->quantizeColorSpace(),
-                options()->verbose(),
-                clusterThreshold_,
-                smoothingThreshold_ );
+                 options()->quantizeColorSpace(),
+                 options()->verbose(),
+                 clusterThreshold_,
+                 smoothingThreshold_ );
   throwImageException();
   SyncImage( image() );
   throwImageException();
@@ -1827,17 +1846,17 @@ void Magick::Image::segment ( const double clusterThreshold_,
 
 // Shade image using distant light source
 void Magick::Image::shade ( const double azimuth_,
-                           const double elevation_,
-                           const bool   colorShading_ )
+                            const double elevation_,
+                            const bool   colorShading_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickLib::Image* newImage =
     ShadeImage( image(),
-               (colorShading_ == true ? 1 : 0),
-               azimuth_,
-               elevation_,
-               &exceptionInfo);
+                (colorShading_ == true ? 1 : 0),
+                azimuth_,
+                elevation_,
+                &exceptionInfo);
   replaceImage( newImage );
   throwImageException( exceptionInfo );
 }
@@ -1878,23 +1897,23 @@ void Magick::Image::shave ( const Geometry &geometry_ )
   GetExceptionInfo( &exceptionInfo );
   MagickLib::Image* newImage =
     ShaveImage( image(),
-              &shaveInfo,
-              &exceptionInfo);
+               &shaveInfo,
+               &exceptionInfo);
   replaceImage( newImage );
   throwImageException( exceptionInfo );
 }
 
 // Shear image
 void Magick::Image::shear ( const double xShearAngle_,
-                           const double yShearAngle_ )
+                            const double yShearAngle_ )
 {
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   MagickLib::Image* newImage =
     ShearImage( image(),
-               xShearAngle_,
-               yShearAngle_,
-               &exceptionInfo );
+                xShearAngle_,
+                yShearAngle_,
+                &exceptionInfo );
   replaceImage( newImage );
   throwImageException( exceptionInfo );
 }
@@ -1915,8 +1934,8 @@ void Magick::Image::spread ( const unsigned int amount_ )
   GetExceptionInfo( &exceptionInfo );
   MagickLib::Image* newImage =
     SpreadImage( image(),
-                amount_,
-                &exceptionInfo );
+                 amount_,
+                 &exceptionInfo );
   replaceImage( newImage );
   throwImageException( exceptionInfo );
 }
@@ -1928,8 +1947,8 @@ void Magick::Image::stegano ( const Image &watermark_ )
   GetExceptionInfo( &exceptionInfo );
   MagickLib::Image* newImage =
     SteganoImage( image(),
-                 watermark_.constImage(),
-                 &exceptionInfo);
+                  watermark_.constImage(),
+                  &exceptionInfo);
   replaceImage( newImage );
   throwImageException( exceptionInfo );
 }
@@ -1941,8 +1960,8 @@ void Magick::Image::stereo ( const Image &rightImage_ )
   GetExceptionInfo( &exceptionInfo );
   MagickLib::Image* newImage =
     StereoImage( image(),
-                rightImage_.constImage(),
-                &exceptionInfo);
+                 rightImage_.constImage(),
+                 &exceptionInfo);
   replaceImage( newImage );
   throwImageException( exceptionInfo );
 }
@@ -1961,7 +1980,7 @@ void Magick::Image::swirl ( const double degrees_ )
   GetExceptionInfo( &exceptionInfo );
   MagickLib::Image* newImage =
     SwirlImage( image(), degrees_,
-               &exceptionInfo);
+                &exceptionInfo);
   replaceImage( newImage );
   throwImageException( exceptionInfo );
 }
@@ -1989,16 +2008,16 @@ void Magick::Image::transform ( const Geometry &imageGeometry_ )
 {
   modifyImage();
   TransformImage ( &(image()), 0,
-                  std::string(imageGeometry_).c_str() );
+                   std::string(imageGeometry_).c_str() );
   throwImageException();
 }
 // Transform image based on image and crop geometries
 void Magick::Image::transform ( const Geometry &imageGeometry_,
-                               const Geometry &cropGeometry_ )
+                                const Geometry &cropGeometry_ )
 {
   modifyImage();
   TransformImage ( &(image()), std::string(cropGeometry_).c_str(),
-                  std::string(imageGeometry_).c_str() );
+                   std::string(imageGeometry_).c_str() );
   throwImageException();
 }
 
@@ -2008,7 +2027,7 @@ void Magick::Image::transparent ( const Color &color_ )
   if ( !color_.isValid() )
   {
     throwExceptionExplicit( OptionError,
-                           "Color argument is invalid" );
+                            "Color argument is invalid" );
   }
 
   std::string color = color_;
@@ -2082,9 +2101,9 @@ void Magick::Image::wave ( const double amplitude_, const double wavelength_ )
   GetExceptionInfo( &exceptionInfo );
   MagickLib::Image* newImage =
     WaveImage( image(),
-              amplitude_,
-              wavelength_,
-              &exceptionInfo);
+               amplitude_,
+               wavelength_,
+               &exceptionInfo);
   replaceImage( newImage );
   throwImageException( exceptionInfo );
 }
@@ -2106,15 +2125,15 @@ void Magick::Image::write ( Blob *blob_ )
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   void* data = ImageToBlob( imageInfo(),
-                           image(),
-                           &length,
-                           &exceptionInfo);
+                            image(),
+                            &length,
+                            &exceptionInfo);
   throwImageException( exceptionInfo );
   blob_->updateNoCopy( data, length, Blob::MallocAllocator );
   throwImageException();
 }
 void Magick::Image::write ( Blob *blob_,
-                           const std::string &magick_ )
+                            const std::string &magick_ )
 {
   modifyImage();
   magick(magick_);
@@ -2122,16 +2141,16 @@ void Magick::Image::write ( Blob *blob_,
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   void* data = ImageToBlob( imageInfo(),
-                           image(),
-                           &length,
-                           &exceptionInfo);
+                            image(),
+                            &length,
+                            &exceptionInfo);
   throwImageException( exceptionInfo );
   blob_->updateNoCopy( data, length, Blob::MallocAllocator );
   throwImageException();
 }
 void Magick::Image::write ( Blob *blob_,
-                           const std::string &magick_,
-                           const unsigned int depth_ )
+                            const std::string &magick_,
+                            const unsigned int depth_ )
 {
   modifyImage();
   magick(magick_);
@@ -2140,9 +2159,9 @@ void Magick::Image::write ( Blob *blob_,
   ExceptionInfo exceptionInfo;
   GetExceptionInfo( &exceptionInfo );
   void* data = ImageToBlob( imageInfo(),
-                           image(),
-                           &length,
-                           &exceptionInfo);
+                            image(),
+                            &length,
+                            &exceptionInfo);
   throwImageException( exceptionInfo );
   blob_->updateNoCopy( data, length, Blob::MallocAllocator );
   throwImageException();
@@ -2467,7 +2486,7 @@ double Magick::Image::colorFuzz ( void ) const
 
 // Set color in colormap at index
 void Magick::Image::colorMap ( const unsigned int index_,
-                              const Color &color_ )
+                               const Color &color_ )
 {
   MagickLib::Image* imageptr = image();
 
@@ -2477,7 +2496,7 @@ void Magick::Image::colorMap ( const unsigned int index_,
 
   if ( !color_.isValid() )
     throwExceptionExplicit( OptionError,
-                           "Color argument is invalid");
+                            "Color argument is invalid");
   modifyImage();
 
   // Ensure that colormap size is large enough
@@ -2494,13 +2513,14 @@ Magick::Color Magick::Image::colorMap ( const unsigned int index_ ) const
 
   if ( !imageptr->colormap )
     throwExceptionExplicit( OptionError,
-                           "Image does not contain a colormap");
+                            "Image does not contain a colormap");
 
   if ( index_ > imageptr->colors-1 )
     throwExceptionExplicit( OptionError,
-                           "Index out of range");
+                            "Index out of range");
 
-  return Magick::Color( (imageptr->colormap)[index_] );
+  return (imageptr->colormap ? Magick::Color( (imageptr->colormap)[index_] )
+          : Magick::Color());
 }
 
 // Colormap size (number of colormap entries)
@@ -2530,14 +2550,17 @@ void Magick::Image::colorMapSize ( const unsigned int entries_ )
 
   if ( !imageptr->colormap )
     throwExceptionExplicit( ResourceLimitError,
-                           "Failed to allocate colormap");
+                            "Failed to allocate colormap");
 
   // Initialize any new new colormap entries as all black
-  Color black(0,0,0);
-  for( unsigned int i=imageptr->colors; i< (entries_-1); i++ )
-    (imageptr->colormap)[i] = black;
+  if (imageptr->colormap)
+    {
+      Color black(0,0,0);
+      for( unsigned int i=imageptr->colors; i< (entries_-1); i++ )
+        (imageptr->colormap)[i] = black;
 
-  imageptr->colors = entries_;
+      imageptr->colors = entries_;
+    }
 }
 unsigned int Magick::Image::colorMapSize ( void )
 {
@@ -2545,7 +2568,7 @@ unsigned int Magick::Image::colorMapSize ( void )
 
   if ( !imageptr->colormap )
     throwExceptionExplicit( OptionError,
-                           "Image does not contain a colormap");
+                            "Image does not contain a colormap");
 
   return imageptr->colors;
 }
@@ -2771,7 +2794,7 @@ std::string Magick::Image::directory ( void ) const
     return std::string( constImage()->directory );
 
   throwExceptionExplicit( CorruptImageWarning,
-                         "Image does not contain a directory");
+                          "Image does not contain a directory");
 
   return std::string();
 }
@@ -2795,7 +2818,7 @@ void Magick::Image::fileName ( const std::string &fileName_ )
   modifyImage();
 
   fileName_.copy( image()->filename,
-                 sizeof(image()->filename) - 1 );
+                  sizeof(image()->filename) - 1 );
   image()->filename[ fileName_.length() ] = 0; // Null terminate
 
   options()->fileName( fileName_ );
@@ -2855,7 +2878,7 @@ Magick::Image  Magick::Image::fillPattern ( void  ) const
       ExceptionInfo exceptionInfo;
       GetExceptionInfo( &exceptionInfo );
       MagickLib::Image* image =
-       CloneImage( tmpTexture,
+        CloneImage( tmpTexture,
                     0, // columns
                     0, // rows
                     1, // orphan
@@ -2925,7 +2948,7 @@ std::string Magick::Image::format ( void ) const
     return std::string(magick_info->description);
 
   throwExceptionExplicit( CorruptImageWarning,
-                         "Unrecognized image magick type" );
+                          "Unrecognized image magick type" );
   return std::string();
 }
 
@@ -2964,7 +2987,7 @@ Magick::Geometry Magick::Image::geometry ( void ) const
   }
 
   throwExceptionExplicit( OptionWarning,
-                         "Image does not contain a geometry");
+                          "Image does not contain a geometry");
 
   return Geometry();
 }
@@ -3067,7 +3090,7 @@ void Magick::Image::magick ( const std::string &magick_ )
   modifyImage();
 
   magick_.copy( image()->magick,
-               sizeof(image()->magick) - 1 );
+                sizeof(image()->magick) - 1 );
   image()->magick[ magick_.length() ] = 0;
 
   options()->magick( magick_ );
@@ -3122,8 +3145,8 @@ void Magick::Image::matteColor ( const Color &matteColor_ )
 Magick::Color Magick::Image::matteColor ( void ) const
 {
   return Color( constImage()->matte_color.red,
-               constImage()->matte_color.green,
-               constImage()->matte_color.blue );
+                constImage()->matte_color.green,
+                constImage()->matte_color.blue );
 }
 
 double Magick::Image::meanErrorPerPixel ( void ) const
@@ -3164,7 +3187,7 @@ Magick::Geometry Magick::Image::montageGeometry ( void ) const
     return Magick::Geometry(constImage()->montage);
 
   throwExceptionExplicit( CorruptImageWarning,
-                         "Image does not contain a montage" );
+                          "Image does not contain a montage" );
 
   return Magick::Geometry();
 }
@@ -3225,7 +3248,7 @@ Magick::Image  Magick::Image::penTexture ( void  ) const
       ExceptionInfo exceptionInfo;
       GetExceptionInfo( &exceptionInfo );
       MagickLib::Image* image =
-       CloneImage( tmpTexture,
+        CloneImage( tmpTexture,
                     0, // columns
                     0, // rows
                     1, // orphan
@@ -3238,7 +3261,7 @@ Magick::Image  Magick::Image::penTexture ( void  ) const
 
 // Set the color of a pixel.
 void Magick::Image::pixelColor ( const unsigned int x_, const unsigned int y_,
-                                const Color &color_ )
+                                 const Color &color_ )
 {
   // Test arguments to ensure they are within the image.
   if ( y_ > rows() || x_ > columns() )
@@ -3261,7 +3284,7 @@ void Magick::Image::pixelColor ( const unsigned int x_, const unsigned int y_,
 }
 // Get the color of a pixel
 Magick::Color Magick::Image::pixelColor ( const unsigned int x_,
-                                         const unsigned int y_ ) const
+                                          const unsigned int y_ ) const
 {
   ClassType storage_class;
   storage_class = classType();
@@ -3294,9 +3317,9 @@ void Magick::Image::page ( const Magick::Geometry &pageSize_ )
 Magick::Geometry Magick::Image::page ( void ) const
 {
   return Geometry( constImage()->page.width,
-                  constImage()->page.height,
-                  AbsoluteValue(constImage()->page.x),
-                  AbsoluteValue(constImage()->page.y),
+                   constImage()->page.height,
+                   AbsoluteValue(constImage()->page.x),
+                   AbsoluteValue(constImage()->page.y),
                    constImage()->page.x < 0 ? true : false,
                    constImage()->page.y < 0 ? true : false);
 }
@@ -3591,7 +3614,7 @@ Magick::Image  Magick::Image::strokePattern ( void  ) const
       ExceptionInfo exceptionInfo;
       GetExceptionInfo( &exceptionInfo );
       MagickLib::Image* image =
-       CloneImage( tmpTexture,
+        CloneImage( tmpTexture,
                     0, // columns
                     0, // rows
                     1, // orphan
@@ -3867,8 +3890,8 @@ Magick::IndexPacket* Magick::Image::getIndexes ( void )
 // by the specified region. Modified pixels may be subsequently
 // transferred back to the image via syncPixels.
 Magick::PixelPacket* Magick::Image::getPixels ( const int x_, const int y_,
-                                               const unsigned int columns_,
-                                               const unsigned int rows_ )
+                                                const unsigned int columns_,
+                                                const unsigned int rows_ )
 {
   modifyImage();
   PixelPacket* result = GetImagePixels( image(),
@@ -3884,8 +3907,8 @@ Magick::PixelPacket* Magick::Image::getPixels ( const int x_, const int y_,
 // by the region rectangle.  This area is subsequently transferred
 // from the pixel cache to the image via syncPixels.
 Magick::PixelPacket* Magick::Image::setPixels ( const int x_, const int y_,
-                                               const unsigned int columns_,
-                                               const unsigned int rows_ )
+                                                const unsigned int columns_,
+                                                const unsigned int rows_ )
 {
   modifyImage();
   PixelPacket* result = SetImagePixels( image(),
@@ -4086,7 +4109,7 @@ long Magick::Image::registerId( void )
       GetExceptionInfo( &exceptionInfo );
       _imgRef->id(SetMagickRegistry(ImageRegistryType, image(),
                                     sizeof(MagickLib::Image),
-                                   &exceptionInfo));
+                                    &exceptionInfo));
       throwImageException( exceptionInfo );
     }
   return _imgRef->id();
index 2dc3440..4a213be 100644 (file)
@@ -27,7 +27,7 @@ Magick::ImageRef::ImageRef ( MagickLib::Image * image_ )
 // Construct with an image and options
 // Inserts Image* in image, but copies Options into image.
 Magick::ImageRef::ImageRef ( MagickLib::Image * image_,
-                            const Options * options_ )
+                             const Options * options_ )
   : _image(image_),
     _options(0),
     _id(-1),
index 5807758..3e69aae 100644 (file)
@@ -20,9 +20,9 @@ namespace Magick
   public:
 
     enum MatchType {
-      AnyMatch,                // match any coder
-      TrueMatch,       // match coder if true
-      FalseMatch       // match coder if false
+      AnyMatch,         // match any coder
+      TrueMatch,        // match coder if true
+      FalseMatch        // match coder if false
     };
 
     // Default constructor
@@ -62,12 +62,12 @@ namespace Magick
 
   private:
 
-    std::string                _name;
-    std::string                _description;
-    bool               _isReadable;
-    bool               _isWritable;
-    bool               _isMultiFrame;
-    
+    std::string         _name;
+    std::string         _description;
+    bool                _isReadable;
+    bool                _isWritable;
+    bool                _isMultiFrame;
+
   };
 } // namespace Magick
 
index c1820b7..fbbede9 100644 (file)
@@ -28,12 +28,12 @@ namespace Magick
   {
   public:
     Color ( Quantum red_,
-           Quantum green_,
-           Quantum blue_ );
+            Quantum green_,
+            Quantum blue_ );
     Color ( Quantum red_,
-           Quantum green_,
-           Quantum blue_,
-           Quantum alpha_ );
+            Quantum green_,
+            Quantum blue_,
+            Quantum alpha_ );
     Color ( const std::string &x11color_ );
     Color ( const char * x11color_ );
     Color ( void );
@@ -60,11 +60,11 @@ namespace Magick
     // (range opaque=0 to transparent=1.0)
     void           alpha ( double alpha_ );
     double         alpha ( void ) const;
-        
+
     // Does object contain valid color?
     void           isValid ( bool valid_ );
     bool           isValid ( void ) const;
-    
+
     // Set color via X11 color specification string
     const Color& operator= ( const std::string &x11color_ );
     const Color& operator= ( const char * x11color_ );
@@ -163,7 +163,7 @@ namespace Magick
     bool                       _isValid;
 
     // Color type supported by _pixel
-    PixelType                  _pixelType;
+    PixelType                   _pixelType;
 
   };
 
@@ -177,13 +177,13 @@ namespace Magick
     ColorHSL ( void );
     ColorHSL ( const Color & color_ );
     /* virtual */  ~ColorHSL ( );
-    
+
     void           hue ( double hue_ );
     double         hue ( void ) const;
-    
+
     void           saturation ( double saturation_ );
     double         saturation ( void ) const;
-    
+
     void           luminosity ( double luminosity_ );
     double         luminosity ( void ) const;
 
@@ -194,7 +194,7 @@ namespace Magick
     // Constructor to construct with PixelPacket*
     ColorHSL ( PixelPacket* rep_, PixelType pixelType_ );
   };
-  
+
   //
   // Grayscale RGB color
   //
@@ -218,7 +218,7 @@ namespace Magick
     // Constructor to construct with PixelPacket*
     ColorGray ( PixelPacket* rep_, PixelType pixelType_ );
   };
-  
+
   //
   // Monochrome color
   //
@@ -231,7 +231,7 @@ namespace Magick
     ColorMono ( void );
     ColorMono ( const Color & color_ );
     /* virtual */ ~ColorMono ();
-    
+
     void           mono ( bool mono_ );
     bool           mono ( void ) const;
 
@@ -242,7 +242,7 @@ namespace Magick
     // Constructor to construct with PixelPacket*
     ColorMono ( PixelPacket* rep_, PixelType pixelType_ );
   };
-  
+
   //
   // RGB color
   //
@@ -254,13 +254,13 @@ namespace Magick
     ColorRGB ( void );
     ColorRGB ( const Color & color_ );
     /* virtual */  ~ColorRGB ( void );
-    
+
     void           red ( double red_ );
     double         red ( void ) const;
-    
+
     void           green ( double green_ );
     double         green ( void ) const;
-    
+
     void           blue ( double blue_ );
     double         blue ( void ) const;
 
@@ -271,7 +271,7 @@ namespace Magick
     // Constructor to construct with PixelPacket*
     ColorRGB ( PixelPacket* rep_, PixelType pixelType_ );
   };
-  
+
   //
   // YUV Colorspace color
   //
@@ -286,13 +286,13 @@ namespace Magick
     ColorYUV ( void );
     ColorYUV ( const Color & color_ );
     /* virtual */ ~ColorYUV ( void );
-    
+
     void           u ( double u_ );
     double         u ( void ) const;
-    
+
     void           v ( double v_ );
     double         v ( void ) const;
-    
+
     void           y ( double y_ );
     double         y ( void ) const;
 
index 9d2e32e..1e8aca5 100644 (file)
 namespace Magick
 {
 
+#if defined(__clang__)
+#pragma clang diagnostic ignored "-Wunknown-warning-option"
+#pragma clang diagnostic ignored "-Wunused-private-field"
+#endif /* if defined(__clang__) */
+
   //
   // Representation of an x,y coordinate
   //
@@ -228,16 +233,16 @@ class MagickDLLDecl VPath
 public:
   // Constructor
   VPath ( void );
-    
+
   // Construct from VPathBase
   VPath ( const VPathBase& original_ );
-    
+
   // Destructor
   virtual ~VPath ( void );
 
   // Copy constructor
   VPath ( const VPath& original_ );
-    
+
   // Assignment operator
   VPath& operator= (const VPath& original_ );
 
@@ -296,7 +301,7 @@ public:
   // Return polymorphic copy of object
   /*virtual*/
   DrawableBase* copy() const;
-    
+
   void sx( const double sx_ )
     {
       _affine.sx = sx_;
@@ -323,7 +328,7 @@ public:
     {
       return _affine.rx;
     }
-  
+
   void ry( const double ry_ )
     {
       _affine.ry = ry_;
@@ -332,7 +337,7 @@ public:
     {
       return _affine.ry;
     }
-  
+
   void tx( const double tx_ )
     {
       _affine.tx = tx_;
@@ -341,7 +346,7 @@ public:
     {
       return _affine.tx;
     }
-  
+
   void ty( const double ty_ )
     {
       _affine.ty = ty_;
@@ -350,7 +355,7 @@ public:
     {
       return _affine.ty;
     }
-  
+
 private:
   MagickLib::AffineMatrix  _affine;
 };
@@ -386,7 +391,7 @@ public:
     {
       return _startX;
     }
-  
+
   void startY( double startY_ )
     {
       _startY = startY_;
@@ -395,7 +400,7 @@ public:
     {
       return _startY;
     }
-  
+
   void endX( double endX_ )
     {
       _endX = endX_;
@@ -413,7 +418,7 @@ public:
     {
       return _endY;
     }
-  
+
   void startDegrees( double startDegrees_ )
     {
       _startDegrees = startDegrees_;
@@ -431,7 +436,7 @@ public:
     {
       return _endDegrees;
     }
-  
+
 private:
   double _startX;
   double _startY;
@@ -459,7 +464,7 @@ public:
 
   // Return polymorphic copy of object
   /*virtual*/ DrawableBase* copy() const;
-  
+
 private:
   CoordinateList _coordinates;
 };
@@ -548,7 +553,7 @@ public:
     }
 
   /*virtual*/ ~DrawableCircle ( void );
-    
+
   // Operator to invoke equivalent draw API call
   /*virtual*/ void operator()( MagickLib::DrawContext context_ ) const;
 
@@ -694,7 +699,7 @@ public:
 
   // Return polymorphic copy of object
   /*virtual*/ DrawableBase* copy() const;
-    
+
   void composition( CompositeOperator composition_ )
     {
       _composition = composition_;
@@ -763,7 +768,7 @@ private:
 class MagickDLLDecl DrawableEllipse : public DrawableBase
 {
 public:
-  DrawableEllipse ( double originX_, double originY_, 
+  DrawableEllipse ( double originX_, double originY_,
                     double radiusX_, double radiusY_,
                     double arcStart_, double arcEnd_ )
     : _originX(originX_),
@@ -838,7 +843,7 @@ public:
 
 private:
   double _originX;
-  double _originY; 
+  double _originY;
   double _radiusX;
   double _radiusY;
   double _arcStart;
@@ -1327,10 +1332,10 @@ public:
 
 private:
   std::string         _id;
-  long         _x;
-  long         _y;
-  long         _width;
-  long         _height;
+  long          _x;
+  long          _y;
+  long          _width;
+  long          _height;
 };
 
 // Rectangle
@@ -1640,7 +1645,7 @@ public:
   DrawableDashArray& operator=(const Magick::DrawableDashArray &original_);
 
 private:
-  size_t       _size;
+  size_t        _size;
   double       *_dasharray;
 };
 
@@ -2208,13 +2213,13 @@ public:
     }
 
 private:
-  double       _radiusX;       // X radius
-  double       _radiusY;       // Y radius
-  double       _xAxisRotation; // Rotation relative to X axis
-  bool        _largeArcFlag;   // Draw longer of the two matching arcs
-  bool        _sweepFlag;      // Draw arc matching clock-wise rotation
-  double       _x;             // End-point X
-  double       _y;             // End-point Y
+  double        _radiusX;       // X radius
+  double        _radiusY;       // Y radius
+  double        _xAxisRotation; // Rotation relative to X axis
+  bool        _largeArcFlag;    // Draw longer of the two matching arcs
+  bool        _sweepFlag;       // Draw arc matching clock-wise rotation
+  double        _x;             // End-point X
+  double        _y;             // End-point Y
 };
 
 // Compare two PathArcArgs objects regardless of LHS/RHS
@@ -2482,7 +2487,7 @@ public:
   /*virtual*/ void operator()( MagickLib::DrawContext context_ ) const;
 
   // Return polymorphic copy of object
-  /*virtual*/ 
+  /*virtual*/
   VPathBase* copy() const;
 
 private:
@@ -2507,7 +2512,7 @@ public:
   /*virtual*/ void operator()( MagickLib::DrawContext context_ ) const;
 
   // Return polymorphic copy of object
-  /*virtual*/ 
+  /*virtual*/
   VPathBase* copy() const;
 
 private:
@@ -2916,6 +2921,11 @@ private:
   CoordinateList _coordinates;
 };
 
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#pragma clang diagnostic pop
+#endif /* if defined(__clang__) */
+
 } // namespace Magick
 
 #endif // Magick_Drawable_header
index 7bdc544..42732e8 100644 (file)
@@ -41,7 +41,7 @@ namespace Magick
     explicit Warning ( const std::string& what_ );
     ~Warning() throw ();
   };
-  
+
   class MagickDLLDecl WarningUndefined : public Warning
   {
   public:
@@ -227,14 +227,14 @@ namespace Magick
     explicit ErrorCorruptImage ( const std::string& what_ );
     ~ErrorCorruptImage() throw ();
   };
-  
+
   class MagickDLLDecl ErrorDelegate : public Error
   {
   public:
     explicit ErrorDelegate ( const std::string& what_ );
     ~ErrorDelegate() throw ();
   };
-  
+
   class MagickDLLDecl ErrorDraw : public Error
   {
   public:
@@ -311,7 +311,7 @@ namespace Magick
     explicit ErrorType ( const std::string& what_ );
     ~ErrorType() throw ();
   };
-  
+
   class MagickDLLDecl ErrorXServer : public Error
   {
   public:
index a46d94d..8b5a53d 100644 (file)
@@ -31,11 +31,11 @@ namespace Magick
   public:
 
     Geometry ( unsigned int width_,
-              unsigned int height_,
-              unsigned int xOff_ = 0,
-              unsigned int yOff_ = 0,
-              bool xNegative_ = false,
-              bool yNegative_ = false );
+               unsigned int height_,
+               unsigned int xOff_ = 0,
+               unsigned int yOff_ = 0,
+               bool xNegative_ = false,
+               bool yNegative_ = false );
     Geometry ( const std::string &geometry_ );
     Geometry ( const char * geometry_ );
     Geometry ( const Geometry &geometry_ );
index cf4e767..c49d309 100644 (file)
@@ -1,6 +1,6 @@
 // This may look like C code, but it is really -*- C++ -*-
 //
-// Copyright Bob Friesenhahn, 1999 - 2015
+// Copyright Bob Friesenhahn, 1999 - 2017
 //
 // Definition of Image, the representation of a single image in Magick++
 //
@@ -77,7 +77,7 @@ namespace Magick
     // in-memory BLOB
     Image ( const Blob &blob_, const Geometry &size,
             const unsigned int depth_,
-           const std::string &magick_ );
+            const std::string &magick_ );
     // Construct Image of specified size, and format from in-memory
     // BLOB
     Image ( const Blob &blob_, const Geometry &size,
@@ -145,22 +145,28 @@ namespace Magick
 
     // Annotate using specified text, and placement location
     void            annotate ( const std::string &text_,
-                              const Geometry &location_ );
+                               const Geometry &location_ );
     // Annotate using specified text, bounding area, and placement
     // gravity
     void            annotate ( const std::string &text_,
-                              const Geometry &boundingArea_,
-                              const GravityType gravity_ );
+                               const Geometry &boundingArea_,
+                               const GravityType gravity_ );
     // Annotate with text using specified text, bounding area,
     // placement gravity, and rotation.
     void            annotate ( const std::string &text_,
-                              const Geometry &boundingArea_,
-                              const GravityType gravity_,
-                              const double degrees_ );
+                               const Geometry &boundingArea_,
+                               const GravityType gravity_,
+                               const double degrees_ );
     // Annotate with text (bounding area is entire image) and placement
     // gravity.
     void            annotate ( const std::string &text_,
-                              const GravityType gravity_ );
+                               const GravityType gravity_ );
+
+    // Orient image to be right-side up based on its current
+    // orientation attribute.  This allows the image to be viewed
+    // correctly when the orientation attribute is not available, or
+    // is not respected.
+    void            autoOrient( void );
 
     // Blur image with specified blur factor
     // The radius_ parameter specifies the radius of the Gaussian, in
@@ -209,15 +215,15 @@ namespace Magick
     void            colorize ( const unsigned int opacityRed_,
                                const unsigned int opacityGreen_,
                                const unsigned int opacityBlue_,
-                              const Color &penColor_ );
+                               const Color &penColor_ );
     // Colorize image with pen color, using specified percent opacity.
     void            colorize ( const unsigned int opacity_,
-                              const Color &penColor_ );
+                               const Color &penColor_ );
 
     // Apply a color matrix to the image channels.  The user supplied
     // matrix may be of order 1 to 5 (1x1 through 5x5).
     void            colorMatrix (const unsigned int order_,
-                                const double *color_matrix_);
+                                 const double *color_matrix_);
 
     // Comment image (add comment string to image)
     void            comment ( const std::string &comment_ );
@@ -230,17 +236,17 @@ namespace Magick
     // Compose an image onto another at specified offset and using
     // specified algorithm
     void            composite ( const Image &compositeImage_,
-                               const int xOffset_,
-                               const int yOffset_,
-                               const CompositeOperator compose_
+                                const int xOffset_,
+                                const int yOffset_,
+                                const CompositeOperator compose_
                                 = InCompositeOp );
     void            composite ( const Image &compositeImage_,
-                               const Geometry &offset_,
-                               const CompositeOperator compose_
+                                const Geometry &offset_,
+                                const CompositeOperator compose_
                                 = InCompositeOp );
     void            composite ( const Image &compositeImage_,
-                               const GravityType gravity_,
-                               const CompositeOperator compose_
+                                const GravityType gravity_,
+                                const CompositeOperator compose_
                                 = InCompositeOp );
 
     // Contrast image (enhance intensity differences in image)
@@ -316,20 +322,20 @@ namespace Magick
     // Uses current fuzz setting when determining color match.
     void            floodFillColor( const unsigned int x_,
                                     const unsigned int y_,
-                                   const Color &fillColor_ );
+                                    const Color &fillColor_ );
     void            floodFillColor( const Geometry &point_,
-                                   const Color &fillColor_ );
+                                    const Color &fillColor_ );
 
     // Flood-fill color across pixels starting at target-pixel and
     // stopping at pixels matching specified border color.
     // Uses current fuzz setting when determining color match.
     void            floodFillColor( const unsigned int x_,
                                     const unsigned int y_,
-                                   const Color &fillColor_,
-                                   const Color &borderColor_ );
+                                    const Color &fillColor_,
+                                    const Color &borderColor_ );
     void            floodFillColor( const Geometry &point_,
-                                   const Color &fillColor_,
-                                   const Color &borderColor_ );
+                                    const Color &fillColor_,
+                                    const Color &borderColor_ );
 
     // Floodfill pixels matching color (within fuzz factor) of target
     // pixel(x,y) with replacement opacity value using method.
@@ -343,20 +349,20 @@ namespace Magick
     // Uses current fuzz setting when determining color match.
     void            floodFillTexture( const unsigned int x_,
                                       const unsigned int y_,
-                                     const Image &texture_ );
+                                      const Image &texture_ );
     void            floodFillTexture( const Geometry &point_,
-                                     const Image &texture_ );
+                                      const Image &texture_ );
 
     // Flood-fill texture across pixels starting at target-pixel and
     // stopping at pixels matching specified border color.
     // Uses current fuzz setting when determining color match.
     void            floodFillTexture( const unsigned int x_,
                                       const unsigned int y_,
-                                     const Image &texture_,
-                                     const Color &borderColor_ );
+                                      const Image &texture_,
+                                      const Color &borderColor_ );
     void            floodFillTexture( const Geometry &point_,
-                                     const Image &texture_,
-                                     const Color &borderColor_ );
+                                      const Image &texture_,
+                                      const Color &borderColor_ );
 
     // Flop image (reflect each scanline in the horizontal direction)
     void            flop ( void );
@@ -365,14 +371,14 @@ namespace Magick
     void            frame ( const Geometry &geometry_ = frameGeometryDefault );
     void            frame ( const unsigned int width_,
                             const unsigned int height_,
-                           const int innerBevel_ = 6,
+                            const int innerBevel_ = 6,
                             const int outerBevel_ = 6 );
 
     // Gamma correct image
     void            gamma ( const double gamma_ );
     void            gamma ( const double gammaRed_,
-                           const double gammaGreen_,
-                           const double gammaBlue_ );
+                            const double gammaGreen_,
+                            const double gammaBlue_ );
 
     // Gaussian blur image
     // The number of neighbor pixels to be included in the convolution
@@ -431,9 +437,9 @@ namespace Magick
 
     // Floodfill designated area with replacement opacity value
     void            matteFloodfill ( const Color &target_ ,
-                                    const unsigned int opacity_,
-                                    const int x_, const int y_,
-                                    const PaintMethod method_ );
+                                     const unsigned int opacity_,
+                                     const int x_, const int y_,
+                                     const PaintMethod method_ );
 
     // Filter image by replacing each pixel component with the median
     // color in a circular neighborhood
@@ -449,8 +455,8 @@ namespace Magick
     // current position corresponding to an argument range of 0 to 2.0
     // (1.0 for no change).
     void            modulate ( const double brightness_,
-                              const double saturation_,
-                              const double hue_ );
+                               const double saturation_,
+                               const double hue_ );
 
     // Motion blur image with specified blur factor
     // The radius_ parameter specifies the radius of the Gaussian, in
@@ -484,7 +490,7 @@ namespace Magick
 
     // Change color of opaque pixel to specified pen color.
     void            opaque ( const Color &opaqueColor_,
-                            const Color &penColor_ );
+                             const Color &penColor_ );
 
     // Ping is similar to read except only enough of the image is read
     // to determine the image columns, rows, and filesize.  Access the
@@ -532,7 +538,7 @@ namespace Magick
     // Raise image (lighten or darken the edges of an image to give a
     // 3-D raised or lowered effect)
     void            raise ( const Geometry &geometry_ = raiseGeometryDefault,
-                           const bool raisedFlag_ = false );
+                            const bool raisedFlag_ = false );
 
     // Random threshold image.
     //
@@ -553,33 +559,33 @@ namespace Magick
 
     // Read single image frame of specified size into current object
     void            read ( const Geometry &size_,
-                          const std::string &imageSpec_ );
+                           const std::string &imageSpec_ );
 
     // Read single image frame from in-memory BLOB
     void            read ( const Blob        &blob_ );
 
     // Read single image frame of specified size from in-memory BLOB
     void            read ( const Blob        &blob_,
-                          const Geometry    &size_ );
+                           const Geometry    &size_ );
 
     // Read single image frame of specified size and depth from
     // in-memory BLOB
     void            read ( const Blob         &blob_,
-                          const Geometry     &size_,
-                          const unsigned int depth_ );
+                           const Geometry     &size_,
+                           const unsigned int depth_ );
 
     // Read single image frame of specified size, depth, and format
     // from in-memory BLOB
     void            read ( const Blob         &blob_,
-                          const Geometry     &size_,
-                          const unsigned int depth_,
-                          const std::string  &magick_ );
+                           const Geometry     &size_,
+                           const unsigned int depth_,
+                           const std::string  &magick_ );
 
     // Read single image frame of specified size, and format from
     // in-memory BLOB
     void            read ( const Blob         &blob_,
-                          const Geometry     &size_,
-                          const std::string  &magick_ );
+                           const Geometry     &size_,
+                           const std::string  &magick_ );
 
     // Read single image frame from an array of raw pixels, with
     // specified storage type (ConstituteImage), e.g.
@@ -615,7 +621,7 @@ namespace Magick
     // number of columnms and rows)
     void            roll ( const Geometry &roll_ );
     void            roll ( const unsigned int columns_,
-                          const unsigned int rows_ );
+                           const unsigned int rows_ );
 
     // Rotate image counter-clockwise by specified number of degrees.
     void            rotate ( const double degrees_ );
@@ -635,12 +641,12 @@ namespace Magick
     // are homogeneous with the fuzzy c-means technique.  Also uses
     // QuantizeColorSpace and Verbose image attributes
     void            segment ( const double clusterThreshold_ = 1.0,
-                             const double smoothingThreshold_ = 1.5 );
+                              const double smoothingThreshold_ = 1.5 );
 
     // Shade image using distant light source
     void            shade ( const double azimuth_ = 30,
-                           const double elevation_ = 30,
-                           const bool   colorShading_ = false );
+                            const double elevation_ = 30,
+                            const bool   colorShading_ = false );
 
     // Sharpen pixels in image
     // The radius_ parameter specifies the radius of the Gaussian, in
@@ -657,7 +663,7 @@ namespace Magick
 
     // Shear image (create parallelogram by sliding image by X or Y axis)
     void            shear ( const double xShearAngle_,
-                           const double yShearAngle_ );
+                            const double yShearAngle_ );
 
     // Solarize image (similar to effect seen when exposing a
     // photographic film to light during the development process)
@@ -691,7 +697,7 @@ namespace Magick
     // Crop geometry is optional
     void            transform ( const Geometry &imageGeometry_ );
     void            transform ( const Geometry &imageGeometry_,
-                               const Geometry &cropGeometry_  );
+                                const Geometry &cropGeometry_  );
 
     // Add matte image to image, setting pixels matching color to
     // transparent
@@ -740,10 +746,10 @@ namespace Magick
     // format and adjoin parameters.
     void            write ( Blob *blob_ );
     void            write ( Blob *blob_,
-                           const std::string &magick_ );
+                            const std::string &magick_ );
     void            write ( Blob *blob_,
-                           const std::string &magick_,
-                           const unsigned int depth_ );
+                            const std::string &magick_,
+                            const unsigned int depth_ );
 
     // Write single image frame to an array of pixels with storage
     // type specified by user (DispatchImage), e.g.
@@ -1073,7 +1079,7 @@ namespace Magick
     // Get/set pixel color at location x & y.
     void            pixelColor ( const unsigned int x_,
                                  const unsigned int y_,
-                                const Color &color_ );
+                                 const Color &color_ );
     Color           pixelColor ( const unsigned int x_,
                                  const unsigned int y_ ) const;
 
@@ -1286,14 +1292,14 @@ namespace Magick
     // transferred back to the image via syncPixels.  This method is
     // valid for DirectClass images.
     PixelPacket* getPixels ( const int x_, const int y_,
-                            const unsigned int columns_,
+                             const unsigned int columns_,
                              const unsigned int rows_ );
 
     // Allocates a pixel cache region to store image pixels as defined
     // by the region rectangle.  This area is subsequently transferred
     // from the pixel cache to the image via syncPixels.
     PixelPacket* setPixels ( const int x_, const int y_,
-                            const unsigned int columns_,
+                             const unsigned int columns_,
                              const unsigned int rows_ );
 
     // Transfers the image cache pixels to the image.
@@ -1303,13 +1309,13 @@ namespace Magick
     // into the image pixel cache of an image.
     // Used to support image decoders.
     void readPixels ( const QuantumType quantum_,
-                     const unsigned char *source_ );
+                      const unsigned char *source_ );
 
     // Transfers one or more pixel components from the image pixel
     // cache to a buffer or file.
     // Used to support image encoders.
     void writePixels ( const QuantumType quantum_,
-                      unsigned char *destination_ );
+                       unsigned char *destination_ );
 
     //////////////////////////////////////////////////////////////////////
     //
index 3b45dc7..0361253 100644 (file)
@@ -22,7 +22,7 @@ namespace Magick
   // Reference counted access to Image *
   //
   class MagickDLLDecl ImageRef {
-    friend class Image; 
+    friend class Image;
   private:
     // Construct with an image pointer and default options
     ImageRef ( MagickLib::Image * image_ );
@@ -36,16 +36,16 @@ namespace Magick
     // Copy constructor and assignment are not supported
     ImageRef(const ImageRef&);
     ImageRef& operator=(const ImageRef&);
-    
+
     void                 image ( MagickLib::Image * image_ );
     MagickLib::Image *&  image ( void );
-    
+
     void                 options ( Options * options_ );
     Options *            options ( void );
 
     void                 id ( const long id_ );
     long                 id ( void ) const;
-    
+
     MagickLib::Image *   _image;    // ImageMagick Image
     Options *            _options;  // User-specified options
     long                 _id;       // Registry ID (-1 if not registered)
index 0b260dd..08ee533 100644 (file)
@@ -1,6 +1,6 @@
 // This may look like C code, but it is really -*- C++ -*-
 //
-// Copyright Bob Friesenhahn, 1999 - 2015
+// Copyright Bob Friesenhahn, 1999 - 2018
 //
 // Inclusion of GraphicsMagick headers (with namespace magic)
 
@@ -224,7 +224,7 @@ namespace Magick
   using MagickLib::UndefinedClass;
   using MagickLib::DirectClass;
   using MagickLib::PseudoClass;
-  
+
   // Channel types
   using MagickLib::ChannelType;
   using MagickLib::UndefinedChannel;
@@ -239,7 +239,7 @@ namespace Magick
   using MagickLib::MatteChannel;
   using MagickLib::AllChannels;
   using MagickLib::GrayChannel;
-  
+
   // Color-space types
   using MagickLib::ColorspaceType;
   using MagickLib::UndefinedColorspace;
@@ -262,7 +262,7 @@ namespace Magick
   using MagickLib::Rec601LumaColorspace;
   using MagickLib::Rec709LumaColorspace;
   using MagickLib::Rec709YCbCrColorspace;
-  
+
   // Composition operations
   using MagickLib::AddCompositeOp;
   using MagickLib::AtopCompositeOp;
@@ -313,7 +313,7 @@ namespace Magick
   using MagickLib::VividLightCompositeOp;
   using MagickLib::PinLightCompositeOp;
   using MagickLib::HardMixCompositeOp;
-  
+
   // Compression algorithms
   using MagickLib::CompressionType;
   using MagickLib::UndefinedCompression;
@@ -330,6 +330,8 @@ namespace Magick
   using MagickLib::JPEG2000Compression;
   using MagickLib::JBIG1Compression;
   using MagickLib::JBIG2Compression;
+  using MagickLib::ZSTDCompression;
+  using MagickLib::WebPCompression;
 
   using MagickLib::DisposeType;
   using MagickLib::UndefinedDispose;
@@ -473,7 +475,7 @@ namespace Magick
   using MagickLib::UndefinedRule;
   using MagickLib::EvenOddRule;
   using MagickLib::NonZeroRule;
-  
+
   // Filter types
   using MagickLib::FilterTypes;
   using MagickLib::UndefinedFilter;
@@ -520,7 +522,7 @@ namespace Magick
   using MagickLib::ColorSeparationType;
   using MagickLib::ColorSeparationMatteType;
   using MagickLib::OptimizeType;
-  
+
   // Interlace types
   using MagickLib::InterlaceType;
   using MagickLib::UndefinedInterlace;
@@ -564,7 +566,7 @@ namespace Magick
   using MagickLib::RightTopOrientation;
   using MagickLib::RightBottomOrientation;
   using MagickLib::LeftBottomOrientation;
-  
+
   // Paint methods
   using MagickLib::PaintMethod;
   using MagickLib::PointMethod;
@@ -671,7 +673,7 @@ namespace Magick
   using MagickLib::PerceptualIntent;
   using MagickLib::AbsoluteIntent;
   using MagickLib::RelativeIntent;
-  
+
   // Resolution units
   using MagickLib::ResolutionType;
   using MagickLib::UndefinedResolution;
index 2d7dc0e..e118cce 100644 (file)
@@ -63,7 +63,7 @@ namespace Magick
     // specification
     void              gravity ( GravityType gravity_ );
     GravityType       gravity ( void ) const;
-    
+
     // Specifies the format used for the image label. Special format
     // characters may be embedded in the format string to include
     // information about the image.
@@ -103,7 +103,7 @@ namespace Magick
     // Specifies the montage title
     void              title ( const std::string &title_ );
     std::string       title ( void ) const;
-    
+
     // Specifies a montage color to set transparent. This option can
     // be set the same as the background color in order for the
     // thumbnails to appear without a background when rendered on an
@@ -118,7 +118,7 @@ namespace Magick
 
     // Update elements in existing MontageInfo structure
     virtual void      updateMontageInfo ( MagickLib::MontageInfo &montageInfo_ ) const;
-        
+
   protected:
 
   private:
@@ -176,15 +176,15 @@ namespace Magick
 
     // Update elements in existing MontageInfo structure
     /* virtual */ void updateMontageInfo ( MagickLib::MontageInfo &montageInfo_ ) const;
-    
+
   protected:
 
   private:
-    
-    Color          _borderColor;       // Frame border color
-    unsigned int   _borderWidth;       // Pixels between thumbnail and surrounding frame
-    Geometry       _frame;             // Frame geometry (width & height frame thickness)
-    Color          _matteColor;                // Frame foreground color
+
+    Color          _borderColor;        // Frame border color
+    unsigned int   _borderWidth;        // Pixels between thumbnail and surrounding frame
+    Geometry       _frame;              // Frame geometry (width & height frame thickness)
+    Color          _matteColor;         // Frame foreground color
   };
 } // namespace Magick
 
index 4592db3..9985dec 100644 (file)
@@ -35,31 +35,31 @@ namespace Magick
     // Remove pixel aliasing
     void            antiAlias( bool flag_ );
     bool            antiAlias( void ) const;
-    
+
     // Join images into a single multi-image file
     void            adjoin ( bool flag_ );
     bool            adjoin ( void ) const;
-    
+
     // Image background color
     void            backgroundColor ( const Color &color_ );
     Color           backgroundColor ( void ) const;
-    
+
     // Name of texture image to tile onto the image background
     void            backgroundTexture ( const std::string &backgroundTexture_ );
     std::string     backgroundTexture ( void ) const;
-    
+
     // Image border color
     void            borderColor ( const Color &color_ );
     Color           borderColor ( void ) const;
-    
+
     // Text bounding-box base color (default none)
     void            boxColor ( const Color &boxColor_ );
     Color           boxColor ( void ) const;
-    
+
     // Colors within this distance are considered equal
     void            colorFuzz ( double fuzz_ );
     double          colorFuzz ( void ) const;
-    
+
     // Compression type ( NoCompression, BZipCompression,
     // FaxCompression, JPEGCompression, LZWCompression,
     // RLECompression, or ZipCompression )
@@ -69,7 +69,7 @@ namespace Magick
     // Enable printing of debug messages from ImageMagick
     void            debug ( bool flag_ );
     bool            debug ( void ) const;
-    
+
     // Vertical and horizontal resolution in pixels of the image
     void            density ( const Geometry &geomery_ );
     Geometry        density ( void ) const;
@@ -106,17 +106,17 @@ namespace Magick
     // Font point size
     void            fontPointsize ( double pointSize_ );
     double          fontPointsize ( void ) const;
-    
+
     std::string     format ( void ) const;
 
     // Image interlace scheme
     void            interlaceType ( InterlaceType interlace_ );
     InterlaceType   interlaceType ( void ) const;
-    
+
    // Image format to write or read
     void            magick ( const std::string &magick_ );
     std::string     magick ( void ) const;
-    
+
     // Transparent color
     void            matteColor ( const Color &matteColor_ );
     Color           matteColor ( void ) const;
@@ -132,19 +132,19 @@ namespace Magick
     // Desired image quality factor
     void            quality ( unsigned int quality_ );
     unsigned int    quality ( void ) const;
-    
+
     // Maximum number of colors to quantize to
     void            quantizeColors ( unsigned int colors_ );
     unsigned int    quantizeColors ( void ) const;
-    
+
     // Colorspace to quantize in.
     void            quantizeColorSpace ( ColorspaceType colorSpace_ );
     ColorspaceType  quantizeColorSpace ( void ) const;
-    
+
     // Dither image during quantization.
     void            quantizeDither ( bool ditherFlag_ );
     bool            quantizeDither ( void ) const;
-    
+
     // Quantization tree-depth
     void            quantizeTreeDepth ( unsigned int treeDepth_ );
     unsigned int    quantizeTreeDepth ( void ) const;
@@ -187,7 +187,7 @@ namespace Magick
     // RoundCap, and SquareCap.
     void            strokeLineCap ( LineCap lineCap_ );
     LineCap         strokeLineCap ( void ) const;
-    
+
     // Specify the shape to be used at the corners of paths (or other
     // vector shapes) when they are stroked. Values of LineJoin are
     // UndefinedJoin, MiterJoin, RoundJoin, and BevelJoin.
@@ -221,7 +221,7 @@ namespace Magick
     // Annotation text encoding (e.g. "UTF-16")
     void            textEncoding ( const std::string &encoding_ );
     std::string     textEncoding ( void ) const;
-    
+
     void            tileName ( const std::string &tileName_ );
     std::string     tileName ( void ) const;
 
@@ -250,14 +250,14 @@ namespace Magick
     // Return verbose information about an image, or an operation
     void            verbose ( bool verboseFlag_ );
     bool            verbose ( void ) const;
-    
+
     void            view ( const std::string &view_ );
     std::string     view ( void ) const;
 
     // X11 display name
     void            x11Display ( const std::string &display_ );
     std::string     x11Display ( void ) const;
-    
+
     //
     // Internal implementation methods.  Please do not use.
     //
@@ -274,7 +274,7 @@ namespace Magick
   protected:
 
   private:
-    
+
     // Assignment not supported
     Options& operator= ( const Options& );
 
index fc5d13a..ba7fe2e 100644 (file)
@@ -23,27 +23,27 @@ namespace Magick
 
     // Destroy pixel view
     ~Pixels( void );
-    
+
     // Transfer pixels from the image to the pixel view as defined by
     // the specified region. Modified pixels may be subsequently
     // transferred back to the image via sync.
     PixelPacket* get ( const int x_, const int y_,
-                      const unsigned int columns_,const  unsigned int rows_ );
+                       const unsigned int columns_,const  unsigned int rows_ );
 
     // Transfer read-only pixels from the image to the pixel view as
     // defined by the specified region.
     const PixelPacket* getConst ( const int x_, const int y_,
                                   const unsigned int columns_,
                                   const unsigned int rows_ );
-    
+
     // Transfers the image view pixels to the image.
     void sync ( void );
-    
+
     // Allocate a pixel view region to store image pixels as defined
     // by the region rectangle.  This area is subsequently transferred
     // from the pixel view to the image via sync.
     PixelPacket* set ( const int x_, const int y_,
-                      const unsigned int columns_, const unsigned int rows_ );
+                       const unsigned int columns_, const unsigned int rows_ );
 
     // Return pixel colormap index array
     IndexPacket* indexes ( void );
@@ -65,17 +65,17 @@ namespace Magick
     // into the image pixel view of an image.  Used to support image
     // decoders.
     void decode ( const QuantumType quantum_,
-                 const unsigned char *source_ )
+                  const unsigned char *source_ )
       {
-       MagickLib::ReadPixelCache( _image.image(), quantum_, source_ );
+        MagickLib::ReadPixelCache( _image.image(), quantum_, source_ );
       }
-    
+
     // Transfer one or more pixel components from the image pixel
     // view to a buffer or file.  Used to support image encoders.
     void encode ( const QuantumType quantum_,
-                 const unsigned char *destination_ )
+                  const unsigned char *destination_ )
       {
-       MagickLib::WritePixelCache( _image.image(), quantum_, destination_ );
+        MagickLib::WritePixelCache( _image.image(), quantum_, destination_ );
       }
 #endif
   private:
index bacf655..7a72efb 100644 (file)
@@ -1,6 +1,6 @@
 // This may look like C code, but it is really -*- C++ -*-
 //
-// Copyright Bob Friesenhahn, 1999 - 2015
+// Copyright Bob Friesenhahn, 1999 - 2018
 //
 // Definition and implementation of template functions for using
 // Magick::Image with STL containers.
@@ -96,8 +96,8 @@ namespace Magick
     // Annotate using specified text, bounding area, and placement
     // gravity
     annotateImage ( const std::string &text_,
-                   const Geometry &geometry_,
-                   const GravityType gravity_ );
+                    const Geometry &geometry_,
+                    const GravityType gravity_ );
 
     // Annotate with text using specified text, bounding area,
     // placement gravity, and rotation.
@@ -109,7 +109,7 @@ namespace Magick
     // Annotate with text (bounding area is entire image) and
     // placement gravity.
     annotateImage ( const std::string &text_,
-                   const GravityType gravity_ );
+                    const GravityType gravity_ );
 
     void operator()( Image &image_ ) const;
 
@@ -193,7 +193,7 @@ namespace Magick
     colorizeImage( const unsigned int opacityRed_,
                    const unsigned int opacityGreen_,
                    const unsigned int opacityBlue_,
-                  const Color &penColor_ );
+                   const Color &penColor_ );
 
     colorizeImage( const unsigned int opacity_,
                    const Color &penColor_ );
@@ -229,7 +229,7 @@ namespace Magick
   {
   public:
     colorMatrixImage( const unsigned int order_,
-                     const double *color_matrix_ );
+                      const double *color_matrix_ );
 
     void operator()( Image &image_ ) const;
 
@@ -268,13 +268,13 @@ namespace Magick
   {
   public:
     compositeImage( const Image &compositeImage_,
-                   int xOffset_,
-                   int yOffset_,
-                   CompositeOperator compose_ = InCompositeOp );
+                    int xOffset_,
+                    int yOffset_,
+                    CompositeOperator compose_ = InCompositeOp );
 
     compositeImage( const Image &compositeImage_,
-                   const Geometry &offset_,
-                   CompositeOperator compose_ = InCompositeOp );
+                    const Geometry &offset_,
+                    CompositeOperator compose_ = InCompositeOp );
 
     void operator()( Image &image_ ) const;
 
@@ -467,22 +467,22 @@ namespace Magick
     // Uses current fuzz setting when determining color match.
     floodFillColorImage( const unsigned int x_,
                          const unsigned int y_,
-                        const Color &fillColor_ );
+                         const Color &fillColor_ );
 
     floodFillColorImage( const Geometry &point_,
-                        const Color &fillColor_ );
+                         const Color &fillColor_ );
 
     // Flood-fill color across pixels starting at target-pixel and
     // stopping at pixels matching specified border color.
     // Uses current fuzz setting when determining color match.
     floodFillColorImage( const unsigned int x_,
                          const unsigned int y_,
-                        const Color &fillColor_,
-                        const Color &borderColor_ );
+                         const Color &fillColor_,
+                         const Color &borderColor_ );
 
     floodFillColorImage( const Geometry &point_,
-                        const Color &fillColor_,
-                        const Color &borderColor_ );
+                         const Color &fillColor_,
+                         const Color &borderColor_ );
 
     void operator()( Image &image_ ) const;
 
@@ -502,22 +502,22 @@ namespace Magick
     // Uses current fuzz setting when determining color match.
     floodFillTextureImage( const unsigned int x_,
                            const unsigned int y_,
-                          const Image &texture_ );
+                           const Image &texture_ );
 
     floodFillTextureImage( const Geometry &point_,
-                          const Image &texture_ );
+                           const Image &texture_ );
 
     // Flood-fill texture across pixels starting at target-pixel and
     // stopping at pixels matching specified border color.
     // Uses current fuzz setting when determining color match.
     floodFillTextureImage( const unsigned int x_,
                            const unsigned int y_,
-                          const Image &texture_,
-                          const Color &borderColor_ );
+                           const Image &texture_,
+                           const Color &borderColor_ );
 
     floodFillTextureImage( const Geometry &point_,
-                          const Image &texture_,
-                          const Color &borderColor_ );
+                           const Image &texture_,
+                           const Color &borderColor_ );
 
     void operator()( Image &image_ ) const;
 
@@ -546,7 +546,7 @@ namespace Magick
     frameImage( const Geometry &geometry_ = frameGeometryDefault );
 
     frameImage( const unsigned int width_, const unsigned int height_,
-               const int innerBevel_ = 6, const int outerBevel_ = 6 );
+                const int innerBevel_ = 6, const int outerBevel_ = 6 );
 
     void operator()( Image &image_ ) const;
 
@@ -564,8 +564,8 @@ namespace Magick
     gammaImage( const double gamma_ );
 
     gammaImage ( const double gammaRed_,
-                const double gammaGreen_,
-                const double gammaBlue_ );
+                 const double gammaGreen_,
+                 const double gammaBlue_ );
 
     void operator()( Image &image_ ) const;
 
@@ -704,9 +704,9 @@ namespace Magick
   {
   public:
     matteFloodfillImage( const Color &target_ ,
-                        const unsigned int matte_,
-                        const int x_, const int y_,
-                        const PaintMethod method_ );
+                         const unsigned int matte_,
+                         const int x_, const int y_,
+                         const PaintMethod method_ );
 
     void operator()( Image &image_ ) const;
 
@@ -752,8 +752,8 @@ namespace Magick
   {
   public:
     modulateImage( const double brightness_,
-                  const double saturation_,
-                  const double hue_ );
+                   const double saturation_,
+                   const double hue_ );
 
     void operator()( Image &image_ ) const;
 
@@ -823,7 +823,7 @@ namespace Magick
   {
   public:
     opaqueImage( const Color &opaqueColor_,
-                const Color &penColor_ );
+                 const Color &penColor_ );
 
     void operator()( Image &image_ ) const;
 
@@ -850,7 +850,7 @@ namespace Magick
   {
   public:
     raiseImage( const Geometry &geometry_ = raiseGeometryDefault,
-               const bool raisedFlag_ = false );
+                const bool raisedFlag_ = false );
 
     void operator()( Image &image_ ) const;
 
@@ -945,7 +945,7 @@ namespace Magick
   {
   public:
     segmentImage( const double clusterThreshold_ = 1.0,
-                 const double smoothingThreshold_ = 1.5 );
+                  const double smoothingThreshold_ = 1.5 );
 
     void operator()( Image &image_ ) const;
 
@@ -959,8 +959,8 @@ namespace Magick
   {
   public:
     shadeImage( const double azimuth_ = 30,
-               const double elevation_ = 30,
-               const bool   colorShading_ = false );
+                const double elevation_ = 30,
+                const bool   colorShading_ = false );
 
     void operator()( Image &image_ ) const;
 
@@ -1001,7 +1001,7 @@ namespace Magick
   {
   public:
     shearImage( const double xShearAngle_,
-               const double yShearAngle_ );
+                const double yShearAngle_ );
 
     void operator()( Image &image_ ) const;
 
@@ -1126,7 +1126,7 @@ namespace Magick
     transformImage( const Geometry &imageGeometry_ );
 
     transformImage( const Geometry &imageGeometry_,
-                   const Geometry &cropGeometry_  );
+                    const Geometry &cropGeometry_  );
 
     void operator()( Image &image_ ) const;
 
@@ -1163,7 +1163,7 @@ namespace Magick
   {
   public:
     waveImage( const double amplitude_ = 25.0,
-              const double wavelength_ = 150.0 );
+               const double wavelength_ = 150.0 );
 
     void operator()( Image &image_ ) const;
 
@@ -1587,7 +1587,7 @@ namespace Magick
   public:
     pixelColorImage( const unsigned int x_,
                      const unsigned int y_,
-                    const Color &color_);
+                     const Color &color_);
 
     void operator()( Image &image_ ) const;
 
@@ -1819,27 +1819,27 @@ namespace Magick
   // method in order to specify the entire container.
   template <class InputIterator>
   void linkImages( InputIterator first_,
-                  InputIterator last_ ) {
+                   InputIterator last_ ) {
 
     MagickLib::Image* previous = 0;
     int scene = 0;
     for ( InputIterator iter = first_; iter != last_; ++iter )
       {
-       // Unless we reduce the reference count to one, the same image
-       // structure may occur more than once in the container, causing
-       // the linked list to fail.
-       iter->modifyImage();
+        // Unless we reduce the reference count to one, the same image
+        // structure may occur more than once in the container, causing
+        // the linked list to fail.
+        iter->modifyImage();
 
-       MagickLib::Image* current = iter->image();
+        MagickLib::Image* current = iter->image();
 
-       current->previous = previous;
-       current->next     = 0;
-       current->scene    = scene++;
+        current->previous = previous;
+        current->next     = 0;
+        current->scene    = scene++;
 
-       if ( previous != 0)
-         previous->next = current;
+        if ( previous != 0)
+          previous->next = current;
 
-       previous = current;
+        previous = current;
       }
   }
 
@@ -1848,12 +1848,12 @@ namespace Magick
   // back to its pristine un-linked state.
   template <class InputIterator>
   void unlinkImages( InputIterator first_,
-                    InputIterator last_ ) {
+                     InputIterator last_ ) {
     for( InputIterator iter = first_; iter != last_; ++iter )
       {
-       MagickLib::Image* image = iter->image();
-       image->previous = 0;
-       image->next = 0;
+        MagickLib::Image* image = iter->image();
+        image->previous = 0;
+        image->next = 0;
       }
   }
 
@@ -1862,24 +1862,24 @@ namespace Magick
   // The options are copied into the object.
   template <class Container>
   void insertImages( Container *sequence_,
-                    MagickLib::Image* images_ ) {
+                     MagickLib::Image* images_ ) {
     MagickLib::Image *image = images_;
     if ( image )
       {
-       do
-         {
-           MagickLib::Image* next_image = image->next;
-           image->next = 0;
+        do
+          {
+            MagickLib::Image* next_image = image->next;
+            image->next = 0;
 
-           if (next_image != 0)
-             next_image->previous=0;
+            if (next_image != 0)
+              next_image->previous=0;
 
-           sequence_->push_back( Magick::Image( image ) );
+            sequence_->push_back( Magick::Image( image ) );
 
-           image=next_image;
-         } while( image );
+            image=next_image;
+          } while( image );
 
-       return;
+        return;
       }
   }
 
@@ -1891,7 +1891,7 @@ namespace Magick
 
   template <class InputIterator>
   void animateImages( InputIterator first_,
-                     InputIterator last_ ) {
+                      InputIterator last_ ) {
     MagickLib::ExceptionInfo exceptionInfo;
     MagickLib::GetExceptionInfo( &exceptionInfo );
     linkImages( first_, last_ );
@@ -1905,15 +1905,15 @@ namespace Magick
   // vertical direction.
   template <class InputIterator>
   void appendImages( Image *appendedImage_,
-                    InputIterator first_,
-                    InputIterator last_,
-                    bool stack_ = false) {
+                     InputIterator first_,
+                     InputIterator last_,
+                     bool stack_ = false) {
     MagickLib::ExceptionInfo exceptionInfo;
     MagickLib::GetExceptionInfo( &exceptionInfo );
     linkImages( first_, last_ );
     MagickLib::Image* image = MagickLib::AppendImages( first_->image(),
-                                                      stack_,
-                                                      &exceptionInfo );
+                                                       stack_,
+                                                       &exceptionInfo );
     unlinkImages( first_, last_ );
     appendedImage_->replaceImage( image );
     throwException( exceptionInfo, appendedImage_->quiet() );
@@ -1923,13 +1923,13 @@ namespace Magick
   // All the input images must be the same size in pixels.
   template <class InputIterator>
   void averageImages( Image *averagedImage_,
-                     InputIterator first_,
-                     InputIterator last_ ) {
+                      InputIterator first_,
+                      InputIterator last_ ) {
     MagickLib::ExceptionInfo exceptionInfo;
     MagickLib::GetExceptionInfo( &exceptionInfo );
     linkImages( first_, last_ );
     MagickLib::Image* image = MagickLib::AverageImages( first_->image(),
-                                                       &exceptionInfo );
+                                                        &exceptionInfo );
     unlinkImages( first_, last_ );
     averagedImage_->replaceImage( image );
     throwException( exceptionInfo, averagedImage_->quiet() );
@@ -2025,7 +2025,7 @@ namespace Magick
           container_->push_back( coderInfo );
         }
         // Intentionally ignore missing module errors
-        catch ( Magick::ErrorModule )
+        catch ( Magick::ErrorModule )
           {
             continue;
           }
@@ -2136,7 +2136,7 @@ namespace Magick
   //
   template <class InputIterator>
   void displayImages( InputIterator first_,
-                     InputIterator last_ ) {
+                      InputIterator last_ ) {
     MagickLib::ExceptionInfo exceptionInfo;
     MagickLib::GetExceptionInfo( &exceptionInfo );
     linkImages( first_, last_ );
@@ -2150,13 +2150,13 @@ namespace Magick
   // This is useful for combining Photoshop layers into a single image.
   template <class InputIterator>
   void flattenImages( Image *flattendImage_,
-                     InputIterator first_,
-                     InputIterator last_ ) {
+                      InputIterator first_,
+                      InputIterator last_ ) {
     MagickLib::ExceptionInfo exceptionInfo;
     MagickLib::GetExceptionInfo( &exceptionInfo );
     linkImages( first_, last_ );
     MagickLib::Image* image = MagickLib::FlattenImages( first_->image(),
-                                                       &exceptionInfo );
+                                                        &exceptionInfo );
     unlinkImages( first_, last_ );
     flattendImage_->replaceImage( image );
     throwException( exceptionInfo, flattendImage_->quiet() );
@@ -2168,48 +2168,48 @@ namespace Magick
   // true in order to evaluate quantization error.
   template <class InputIterator>
   void mapImages( InputIterator first_,
-                 InputIterator last_,
-                 const Image& mapImage_,
-                 bool dither_ = false,
-                 bool measureError_ = false ) {
+                  InputIterator last_,
+                  const Image& mapImage_,
+                  bool dither_ = false,
+                  bool measureError_ = false ) {
 
     MagickLib::ExceptionInfo exceptionInfo;
     MagickLib::GetExceptionInfo( &exceptionInfo );
     linkImages( first_, last_ );
     MagickLib::MapImages( first_->image(),
-                         mapImage_.constImage(),
-                         dither_ );
+                          mapImage_.constImage(),
+                          dither_ );
     MagickLib::GetImageException( first_->image(), &exceptionInfo );
     if ( exceptionInfo.severity != MagickLib::UndefinedException )
       {
-       unlinkImages( first_, last_ );
-       throwException( exceptionInfo, first_->quiet() );
+        unlinkImages( first_, last_ );
+        throwException( exceptionInfo, first_->quiet() );
       }
 
     MagickLib::Image* image = first_->image();
     while( image )
       {
-       // Calculate quantization error
-       if ( measureError_ )
-         {
-           MagickLib::GetImageQuantizeError( image );
-           if ( image->exception.severity > MagickLib::UndefinedException )
-             {
-               unlinkImages( first_, last_ );
-               throwException( exceptionInfo, first_->quiet() );
-             }
-         }
-
-       // Udate DirectClass representation of pixels
-       MagickLib::SyncImage( image );
-       if ( image->exception.severity > MagickLib::UndefinedException )
-         {
-           unlinkImages( first_, last_ );
-           throwException( exceptionInfo, first_->quiet() );
-         }
-
-       // Next image
-       image=image->next;
+        // Calculate quantization error
+        if ( measureError_ )
+          {
+            MagickLib::GetImageQuantizeError( image );
+            if ( image->exception.severity > MagickLib::UndefinedException )
+              {
+                unlinkImages( first_, last_ );
+                throwException( exceptionInfo, first_->quiet() );
+              }
+          }
+
+        // Udate DirectClass representation of pixels
+        MagickLib::SyncImage( image );
+        if ( image->exception.severity > MagickLib::UndefinedException )
+          {
+            unlinkImages( first_, last_ );
+            throwException( exceptionInfo, first_->quiet() );
+          }
+
+        // Next image
+        image=image->next;
       }
 
     unlinkImages( first_, last_ );
@@ -2218,9 +2218,9 @@ namespace Magick
   // Create a composite image by combining several separate images.
   template <class Container, class InputIterator>
   void montageImages( Container *montageImages_,
-                     InputIterator first_,
-                     InputIterator last_,
-                     const Montage &montageOpts_ ) {
+                      InputIterator first_,
+                      InputIterator last_,
+                      const Montage &montageOpts_ ) {
 
     MagickLib::MontageInfo* montageInfo =
       static_cast<MagickLib::MontageInfo*>(MagickLib::MagickMalloc(sizeof(MagickLib::MontageInfo)));
@@ -2242,11 +2242,11 @@ namespace Magick
     MagickLib::ExceptionInfo exceptionInfo;
     MagickLib::GetExceptionInfo( &exceptionInfo );
     MagickLib::Image *images = MagickLib::MontageImages( first_->image(),
-                                                        montageInfo,
-                                                        &exceptionInfo );
+                                                         montageInfo,
+                                                         &exceptionInfo );
     if ( images != 0 )
       {
-       insertImages( montageImages_, images );
+        insertImages( montageImages_, images );
       }
 
     // Clean up any allocated data in montageInfo
@@ -2261,7 +2261,7 @@ namespace Magick
     // Apply transparency to montage images
     if ( montageImages_->size() > 0 && montageOpts_.transparentColor().isValid() )
       {
-       for_each( first_, last_, transparentImage( montageOpts_.transparentColor() ) );
+        for_each( first_, last_, transparentImage( montageOpts_.transparentColor() ) );
       }
 
     // Report any transparentImage() error
@@ -2272,16 +2272,16 @@ namespace Magick
   // Morph a set of images
   template <class InputIterator, class Container >
   void morphImages( Container *morphedImages_,
-                   InputIterator first_,
-                   InputIterator last_,
-                   unsigned int frames_ ) {
+                    InputIterator first_,
+                    InputIterator last_,
+                    unsigned int frames_ ) {
     MagickLib::ExceptionInfo exceptionInfo;
     MagickLib::GetExceptionInfo( &exceptionInfo );
 
     // Build image list
     linkImages( first_, last_ );
     MagickLib::Image* images = MagickLib::MorphImages( first_->image(), frames_,
-                                                      &exceptionInfo);
+                                                       &exceptionInfo);
     // Unlink image list
     unlinkImages( first_, last_ );
 
@@ -2298,13 +2298,13 @@ namespace Magick
   // Inlay a number of images to form a single coherent picture.
   template <class InputIterator>
   void mosaicImages( Image *mosaicImage_,
-                    InputIterator first_,
-                    InputIterator last_ ) {
+                     InputIterator first_,
+                     InputIterator last_ ) {
     MagickLib::ExceptionInfo exceptionInfo;
     MagickLib::GetExceptionInfo( &exceptionInfo );
     linkImages( first_, last_ );
     MagickLib::Image* image = MagickLib::MosaicImages( first_->image(),
-                                                      &exceptionInfo );
+                                                       &exceptionInfo );
     unlinkImages( first_, last_ );
     mosaicImage_->replaceImage( image );
     throwException( exceptionInfo, first_->quiet() );
@@ -2314,34 +2314,34 @@ namespace Magick
   // Set measureError_ to true in order to measure quantization error
   template <class InputIterator>
   void quantizeImages( InputIterator first_,
-                      InputIterator last_,
-                      bool measureError_ = false ) {
+                       InputIterator last_,
+                       bool measureError_ = false ) {
     MagickLib::ExceptionInfo exceptionInfo;
     MagickLib::GetExceptionInfo( &exceptionInfo );
 
     linkImages( first_, last_ );
 
     MagickLib::QuantizeImages( first_->quantizeInfo(),
-                              first_->image() );
+                               first_->image() );
     MagickLib::GetImageException( first_->image(), &exceptionInfo );
     if ( exceptionInfo.severity > MagickLib::UndefinedException )
       {
-       unlinkImages( first_, last_ );
-       throwException( exceptionInfo, first_->quiet() );
+        unlinkImages( first_, last_ );
+        throwException( exceptionInfo, first_->quiet() );
       }
 
     MagickLib::Image* image = first_->image();
     while( image != 0 )
       {
-       // Calculate quantization error
-       if ( measureError_ )
-         MagickLib::GetImageQuantizeError( image );
+        // Calculate quantization error
+        if ( measureError_ )
+          MagickLib::GetImageQuantizeError( image );
 
-       // Update DirectClass representation of pixels
-       MagickLib::SyncImage( image );
+        // Update DirectClass representation of pixels
+        MagickLib::SyncImage( image );
 
-       // Next image
-       image=image->next;
+        // Next image
+        image=image->next;
       }
 
     unlinkImages( first_, last_ );
@@ -2351,7 +2351,7 @@ namespace Magick
   // FIXME: need a way to specify options like size, depth, and density.
   template <class Container>
   void readImages( Container *sequence_,
-                  const std::string &imageSpec_ ) {
+                   const std::string &imageSpec_ ) {
     MagickLib::ImageInfo *imageInfo = MagickLib::CloneImageInfo(0);
     imageSpec_.copy( imageInfo->filename, MaxTextExtent-1 );
     imageInfo->filename[ imageSpec_.length() ] = 0;
@@ -2364,13 +2364,13 @@ namespace Magick
   }
   template <class Container>
   void readImages( Container *sequence_,
-                  const Blob &blob_ ) {
+                   const Blob &blob_ ) {
     MagickLib::ImageInfo *imageInfo = MagickLib::CloneImageInfo(0);
     MagickLib::ExceptionInfo exceptionInfo;
     MagickLib::GetExceptionInfo( &exceptionInfo );
     MagickLib::Image *images = MagickLib::BlobToImage( imageInfo,
-                                                      blob_.data(),
-                                                      blob_.length(), &exceptionInfo );
+                                                       blob_.data(),
+                                                       blob_.length(), &exceptionInfo );
     MagickLib::DestroyImageInfo(imageInfo);
     insertImages( sequence_, images );
     throwException( exceptionInfo );
@@ -2385,9 +2385,9 @@ namespace Magick
   // used.
   template <class InputIterator>
   void writeImages( InputIterator first_,
-                   InputIterator last_,
-                   const std::string &imageSpec_,
-                   bool adjoin_ = true ) {
+                    InputIterator last_,
+                    const std::string &imageSpec_,
+                    bool adjoin_ = true ) {
 
     first_->adjoin( adjoin_ );
 
@@ -2403,8 +2403,8 @@ namespace Magick
 
     if ( errorStat != false )
       {
-       MagickLib::DestroyExceptionInfo( &exceptionInfo );
-       return;
+        MagickLib::DestroyExceptionInfo( &exceptionInfo );
+        return;
       }
 
     throwException( exceptionInfo, first_->quiet() );
@@ -2418,9 +2418,9 @@ namespace Magick
   // used.
   template <class InputIterator>
   void writeImages( InputIterator first_,
-                   InputIterator last_,
-                   Blob *blob_,
-                   bool adjoin_ = true) {
+                    InputIterator last_,
+                    Blob *blob_,
+                    bool adjoin_ = true) {
 
     first_->adjoin( adjoin_ );
 
@@ -2430,9 +2430,9 @@ namespace Magick
     MagickLib::GetExceptionInfo( &exceptionInfo );
     size_t length = 2048; // Efficient size for small images
     void* data = MagickLib::ImageToBlob( first_->imageInfo(),
-                                        first_->image(),
-                                        &length,
-                                        &exceptionInfo);
+                                         first_->image(),
+                                         &length,
+                                         &exceptionInfo);
     blob_->updateNoCopy( data, length, Magick::Blob::MallocAllocator );
 
     unlinkImages( first_, last_ );
index 65af5c6..32e0342 100644 (file)
@@ -6,7 +6,7 @@
 //
 // This class is a Magick++ implementation class and is not intended
 // for use by end-users.
-// 
+//
 #if !defined (Magick_Thread_header)
 #define Magick_Thread_header
 
 #include <windows.h>
 #if defined(_MT)
 struct win32_mutex {
-       HANDLE id;
+        HANDLE id;
 };
 
 // This is a binary semphore -- increase for a counting semaphore
-#define MAXSEMLEN      1
+#define MAXSEMLEN       1
 #endif // defined(_MT)
 #endif // defined(_VISUALC_)
 
@@ -50,7 +50,7 @@ namespace Magick
 
     // Don't support copy constructor
     MutexLock ( const MutexLock& original_ );
-    
+
     // Don't support assignment
     MutexLock& operator = ( const MutexLock& original_ );
 
@@ -75,7 +75,7 @@ namespace Magick
 
     // Don't support copy constructor
     Lock ( const Lock& original_ );
-    
+
     // Don't support assignment
     Lock& operator = ( const Lock& original_ );
 
index 4e5f63e..4889cd7 100644 (file)
@@ -18,7 +18,7 @@ namespace Magick
   {
     friend class Image;
   public:
-    
+
     TypeMetric ( void );
     ~TypeMetric ( void );
 
index bd4dd44..526943a 100644 (file)
@@ -30,7 +30,7 @@ Magick::Options::Options( void )
 {
   // Initialize image info with defaults
   GetImageInfo( _imageInfo );
-  
+
   // Initialize quantization info
   GetQuantizeInfo( _quantizeInfo );
 
@@ -261,11 +261,11 @@ void Magick::Options::fillPattern ( const MagickLib::Image *fillPattern_ )
       ExceptionInfo exceptionInfo;
       GetExceptionInfo( &exceptionInfo );
       _drawInfo->fill_pattern =
-       CloneImage( const_cast<MagickLib::Image*>(fillPattern_),
-                   0,
-                   0,
-                   static_cast<int>(true),
-                   &exceptionInfo );
+        CloneImage( const_cast<MagickLib::Image*>(fillPattern_),
+                    0,
+                    0,
+                    static_cast<int>(true),
+                    &exceptionInfo );
       throwException( exceptionInfo, _quiet );
     }
 }
@@ -301,7 +301,7 @@ std::string Magick::Options::font ( void ) const
 {
   if ( _imageInfo->font )
     return std::string( _imageInfo->font );
-  
+
   return std::string();
 }
 
@@ -323,11 +323,11 @@ std::string Magick::Options::format ( void ) const
   GetExceptionInfo(&exception);
   if ( *_imageInfo->magick != '\0' )
     magick_info = GetMagickInfo( _imageInfo->magick , &exception);
-  
-  if (( magick_info != 0 ) && 
+
+  if (( magick_info != 0 ) &&
       ( *magick_info->description != '\0' ))
     return std::string( magick_info->description );
-  
+
   return std::string();
 }
 
@@ -349,14 +349,14 @@ void Magick::Options::magick ( const std::string &magick_ )
   SetImageInfo( _imageInfo, 1, &exception);
   if ( _imageInfo->magick[0] == '\0' )
     throwExceptionExplicit( OptionWarning,
-                           "Unrecognized image format",
-                           magick_.c_str() );
+                            "Unrecognized image format",
+                            magick_.c_str() );
 }
 std::string Magick::Options::magick ( void ) const
 {
   if ( _imageInfo->magick[0] != '\0' )
     return std::string( _imageInfo->magick );
-  
+
   return std::string();
 }
 
@@ -500,13 +500,18 @@ void Magick::Options::strokeDashArray ( const double* strokeDashArray_ )
 {
   MagickFreeMemory(_drawInfo->dash_pattern);
 
-  if(strokeDashArray_)
+  if (strokeDashArray_)
     {
       // Count elements in dash array
       unsigned int x;
       for (x=0; strokeDashArray_[x]; x++) {};
       // Allocate elements
       _drawInfo->dash_pattern = MagickAllocateMemory(double*,(x+1)*sizeof(double));
+
+      if (!_drawInfo->dash_pattern)
+        throwExceptionExplicit( ResourceLimitError,
+                                "Unable to allocate dash-pattern memory");
+
       // Copy elements
       memcpy(_drawInfo->dash_pattern,strokeDashArray_,
              (x+1)*sizeof(double));
@@ -573,11 +578,11 @@ void Magick::Options::strokePattern ( const MagickLib::Image *strokePattern_ )
       ExceptionInfo exceptionInfo;
       GetExceptionInfo( &exceptionInfo );
       _drawInfo->stroke_pattern =
-       CloneImage( const_cast<MagickLib::Image*>(strokePattern_),
-                   0,
-                   0,
-                   static_cast<int>(true),
-                   &exceptionInfo );
+        CloneImage( const_cast<MagickLib::Image*>(strokePattern_),
+                    0,
+                    0,
+                    static_cast<int>(true),
+                    &exceptionInfo );
       throwException( exceptionInfo, _quiet );
     }
 }
@@ -623,7 +628,7 @@ std::string Magick::Options::textEncoding ( void ) const
 {
   if ( _drawInfo->encoding && *_drawInfo->encoding )
     return std::string( _drawInfo->encoding );
-  
+
   return std::string();
 }
 
index 875afea..3ad33ba 100644 (file)
@@ -46,9 +46,9 @@ Magick::Pixels::~Pixels( void )
 // the specified region. Modified pixels may be subsequently
 // transferred back to the image via sync.
 Magick::PixelPacket* Magick::Pixels::get ( const int x_,
-                                          const int y_,
-                                          const unsigned int columns_,
-                                          const unsigned int rows_ )
+                                           const int y_,
+                                           const unsigned int columns_,
+                                           const unsigned int rows_ )
 {
   _x = x_;
   _y = y_;
@@ -79,7 +79,7 @@ const Magick::PixelPacket* Magick::Pixels::getConst ( const int x_, const int y_
 
   if ( !pixels )
     throwException( _exception, _image.quiet() );
-  
+
   return pixels;
 }
 
@@ -89,14 +89,14 @@ void Magick::Pixels::sync ( void )
   if( !SyncCacheViewPixels( _view, &_exception ) )
     throwException( _exception, _image.quiet() );
 }
-    
+
 // Allocate a pixel view region to store image pixels as defined
 // by the region rectangle.  This area is subsequently transferred
 // from the pixel view to the image via 'sync'.
 Magick::PixelPacket* Magick::Pixels::set ( const int x_,
-                                          const int y_,
-                                          const unsigned int columns_,
-                                          const unsigned int rows_ )
+                                           const int y_,
+                                           const unsigned int columns_,
+                                           const unsigned int rows_ )
 {
   _x = x_;
   _y = y_;
@@ -107,7 +107,7 @@ Magick::PixelPacket* Magick::Pixels::set ( const int x_,
                                             columns_, rows_ , &_exception);
   if ( !pixels )
     throwException( _exception, _image.quiet() );
-  
+
   return pixels;
 }
 
index f4a122d..ac4463b 100644 (file)
@@ -51,8 +51,8 @@ void Magick::affineTransformImage::operator()( Magick::Image &image_ ) const
 Magick::annotateImage::annotateImage ( const std::string &text_,
                                        const Magick::Geometry &geometry_ )
       : _text( text_ ),
-       _geometry( geometry_ ),
-       _gravity( Magick::NorthWestGravity ),
+        _geometry( geometry_ ),
+        _gravity( Magick::NorthWestGravity ),
         _degrees( 0 )
 {
 }
@@ -186,7 +186,7 @@ void Magick::cdlImage::operator()( Image &image_ ) const
 // Apply a color matrix to the image channels.  The user supplied
 // matrix may be of order 1 to 5 (1x1 through 5x5).
 Magick::colorMatrixImage::colorMatrixImage( const unsigned int order_,
-                                           const double *color_matrix_ )
+                                            const double *color_matrix_ )
   : _order( order_ ),
     _color_matrix( color_matrix_ )
 {
@@ -350,7 +350,7 @@ Magick::extentImage::extentImage( const Geometry &geometry_ )
   : _geometry( geometry_ ),
     _backgroundColor( ),
     _gravity( Magick::ForgetGravity )
-    
+
 {
 }
 Magick::extentImage::extentImage( const Geometry &geometry_,
@@ -898,7 +898,7 @@ void Magick::segmentImage::operator()( Magick::Image &image_ ) const
 // Shade image using distant light source
 Magick::shadeImage::shadeImage( const double azimuth_,
                                 const double elevation_,
-                               const bool colorShading_)
+                                const bool colorShading_)
   : _azimuth( azimuth_ ),
     _elevation( elevation_ ),
     _colorShading (colorShading_)
index c8dcb91..b9457e4 100644 (file)
@@ -44,12 +44,12 @@ int main( int /*argc*/, char ** argv)
     if (( appended.signature() != "3a90bb0bb8f69f6788ab99e9e25598a0d6c5cdbbb797f77ad68011e0a8b1689d" ) &&
         ( appended.signature() != "7b8f52c6331487119eeda8063887a85650f76b86a3dce7086bf93d8b49e6ddc3" ))
       {
-       ++failures;
-       cout << "Line: " << __LINE__
-            << "  Horizontal append failed, signature = "
-            << appended.signature() << endl;
-       appended.write("appendImages_horizontal_out.miff");
-       // appended.display();
+        ++failures;
+        cout << "Line: " << __LINE__
+             << "  Horizontal append failed, signature = "
+             << appended.signature() << endl;
+        appended.write("appendImages_horizontal_out.miff");
+        // appended.display();
       }
 
     // Vertical
@@ -57,14 +57,14 @@ int main( int /*argc*/, char ** argv)
     if (( appended.signature() != "d73d25ccd6011936d08b6d0d89183b7a61790544c2195269aff4db2f782ffc08" ) &&
         ( appended.signature() != "d0bbbb124a690fc7a275b19a9116fd7e1079786d97e02da319122617b3416de2" ))
       {
-       ++failures;
-       cout << "Line: " << __LINE__
-            << "  Vertical append failed, signature = "
-            << appended.signature() << endl;
-       appended.write("appendImages_vertical_out.miff");
-       // appended.display();
+        ++failures;
+        cout << "Line: " << __LINE__
+             << "  Vertical append failed, signature = "
+             << appended.signature() << endl;
+        appended.write("appendImages_vertical_out.miff");
+        // appended.display();
       }
-    
+
   }
 
   catch( Exception &error_ )
@@ -83,7 +83,6 @@ int main( int /*argc*/, char ** argv)
       cout << failures << " failures" << endl;
       return 1;
     }
-  
+
   return 0;
 }
-
index a82299b..9c28e8f 100644 (file)
@@ -1,6 +1,6 @@
 // This may look like C code, but it is really -*- C++ -*-
 //
-// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
+// Copyright Bob Friesenhahn, 1999 - 2018
 //
 // Tests for setting/getting Magick::Image attributes
 //
@@ -36,24 +36,24 @@ int main( int /*argc*/, char ** argv)
     // Test default value
     if ( image.antiAlias() != true )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", antiAlias default not true" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", antiAlias default not true" << endl;
       }
 
     // Test setting false
     image.antiAlias( false );
     if ( image.antiAlias() != false )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", antiAlias not false" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", antiAlias not false" << endl;
       }
 
     // Test setting true
     image.antiAlias( true );
     if ( image.antiAlias() != true )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", antiAlias not true" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", antiAlias not true" << endl;
       }
 
     //
@@ -63,8 +63,8 @@ int main( int /*argc*/, char ** argv)
     // Test default value
     if ( image.adjoin() != true )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", adjoin default not 'true' as expected" << endl;
       }
 
@@ -72,16 +72,16 @@ int main( int /*argc*/, char ** argv)
     image.adjoin( false );
     if ( image.adjoin() != false )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", adjoin failed set to 'false'" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", adjoin failed set to 'false'" << endl;
       }
 
     // Test setting true
     image.adjoin( true );
     if ( image.adjoin() != true )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", adjoin failed set to 'true'" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", adjoin failed set to 'true'" << endl;
       }
 
     //
@@ -91,18 +91,18 @@ int main( int /*argc*/, char ** argv)
     // Test default value
     if ( image.animationDelay() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", animationDelay default ("
-            << image.animationDelay()
-            << ") not 0 as expected" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", animationDelay default ("
+             << image.animationDelay()
+             << ") not 0 as expected" << endl;
       }
 
     // Test setting to 0
     image.animationDelay( 0 );
     if ( image.animationDelay() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", failed to set animationDelay to 0" << endl;
       }
 
@@ -110,8 +110,8 @@ int main( int /*argc*/, char ** argv)
     image.animationDelay( 100 );
     if ( image.animationDelay() != 100 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", failed to set animationDelay to 100" << endl;
       }
     image.animationDelay(0);
@@ -123,19 +123,19 @@ int main( int /*argc*/, char ** argv)
     // Test default value
     if ( image.animationIterations() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", animationIterations default ("
-            << image.animationIterations()
-            << ") not 0 as expected" << endl;
+             << image.animationIterations()
+             << ") not 0 as expected" << endl;
       }
 
     // Test setting to 0
     image.animationIterations( 0 );
     if ( image.animationIterations() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", failed to set animationIterations to 0" << endl;
       }
 
@@ -143,8 +143,8 @@ int main( int /*argc*/, char ** argv)
     image.animationIterations( 100 );
     if ( image.animationIterations() != 100 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", failed to set animationIterations to 100" << endl;
       }
     image.animationIterations( 0 );
@@ -156,53 +156,53 @@ int main( int /*argc*/, char ** argv)
     // Test default value.
     if ( image.backgroundColor() != ColorRGB("white") )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", backgroundColor default ("
-            << string(image.backgroundColor())
-            << ") is incorrect" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", backgroundColor default ("
+             << string(image.backgroundColor())
+             << ") is incorrect" << endl;
       }
 
     // Test setting to blue
     image.backgroundColor("blue");
     if ( !image.backgroundColor().isValid() )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", backgroundColor ("
-            << string(image.backgroundColor())
-            << ") failed set to 'blue'" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", backgroundColor ("
+             << string(image.backgroundColor())
+             << ") failed set to 'blue'" << endl;
       }
     else
       if ( string(image.backgroundColor()) != "#0000FF" &&
-          string(image.backgroundColor()) != "#00000000FFFF" &&
-          string(image.backgroundColor()) != "#0000000000000000FFFFFFFF" )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__ << ", backgroundColor ("
-              <<  string(image.backgroundColor()) << ") is incorrect"
-              << endl;
-       }
+           string(image.backgroundColor()) != "#00000000FFFF" &&
+           string(image.backgroundColor()) != "#0000000000000000FFFFFFFF" )
+        {
+          ++failures;
+          cout << "Line: " << __LINE__ << ", backgroundColor ("
+               <<  string(image.backgroundColor()) << ") is incorrect"
+               << endl;
+        }
 
     // Test setting using hex color
     image.backgroundColor("#00AAFF");
     if ( !image.backgroundColor().isValid() )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", backgroundColor ("
-            << string(image.backgroundColor())
-            << ") is incorrectly invalid" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", backgroundColor ("
+             << string(image.backgroundColor())
+             << ") is incorrectly invalid" << endl;
       }
     else
-      if ( string(image.backgroundColor()) != "#00AAFF" && 
-          string(image.backgroundColor()) != "#0000AAAAFFFF" && 
-          string(image.backgroundColor()) != "#00000000AAAAAAAAFFFFFFFF" )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__
-              << ", backgroundColor ("
-              << string(image.backgroundColor())
-              << ") is incorrect"
-              << endl;
-       }
+      if ( string(image.backgroundColor()) != "#00AAFF" &&
+           string(image.backgroundColor()) != "#0000AAAAFFFF" &&
+           string(image.backgroundColor()) != "#00000000AAAAAAAAFFFFFFFF" )
+        {
+          ++failures;
+          cout << "Line: " << __LINE__
+               << ", backgroundColor ("
+               << string(image.backgroundColor())
+               << ") is incorrect"
+               << endl;
+        }
 
     //
     // backgroundTexture
@@ -211,31 +211,31 @@ int main( int /*argc*/, char ** argv)
     // Test default value
     if ( image.backgroundTexture() != "" )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", backgroundTexture default ("
-            << image.backgroundTexture()
-            << ") is incorrect" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", backgroundTexture default ("
+             << image.backgroundTexture()
+             << ") is incorrect" << endl;
       }
 
     // Test setting/getting value
     image.backgroundTexture("afile.jpg");
     if ( image.backgroundTexture() != "afile.jpg" )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", backgroundTexture ("
-            << image.backgroundTexture()
-            << ") is incorrect" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", backgroundTexture ("
+             << image.backgroundTexture()
+             << ") is incorrect" << endl;
       }
 
     // Test setting back to default
     image.backgroundTexture("");
     if ( image.backgroundTexture() != "" )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
-            << ", backgroundTexture ("
-            << image.backgroundTexture()
-            << ") failed to set to \"\"" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << ", backgroundTexture ("
+             << image.backgroundTexture()
+             << ") failed to set to \"\"" << endl;
       }
 
     //
@@ -243,14 +243,14 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.baseColumns() != columns )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
-            << ", baseColumns ("
-            << image.baseColumns()
-            << ") is not equal to "
-            << columns
-            << " as expected"
-            << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << ", baseColumns ("
+             << image.baseColumns()
+             << ") is not equal to "
+             << columns
+             << " as expected"
+             << endl;
       }
 
 
@@ -259,15 +259,15 @@ int main( int /*argc*/, char ** argv)
     //
     // Base filename is color for xc images
     if ( image.baseFilename() != "#FF0000" &&
-        image.baseFilename() != "#FFFF00000000" &&
-        image.baseFilename() != "#FFFFFFFF0000000000000000")
+         image.baseFilename() != "#FFFF00000000" &&
+         image.baseFilename() != "#FFFFFFFF0000000000000000")
       {
-       ++failures;
-       cout << "Line: " << __LINE__
-            << ", baseFilename ("
-            << image.baseFilename()
-            << ") is incorrect"
-            << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << ", baseFilename ("
+             << image.baseFilename()
+             << ") is incorrect"
+             << endl;
       }
 
     //
@@ -275,14 +275,14 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.baseRows() != rows )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
-            << ", baseRows ("
-            << image.baseRows()
-            << ") != rows ("
-            << rows
-            << ")"
-            << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << ", baseRows ("
+             << image.baseRows()
+             << ") != rows ("
+             << rows
+             << ")"
+             << endl;
       }
 
     //
@@ -290,57 +290,57 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.borderColor() != ColorRGB("#dfdfdf") )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
-            << ",  borderColor default ("
-            << string(image.borderColor())
-            << ") is incorrect" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << ",  borderColor default ("
+             << string(image.borderColor())
+             << ") is incorrect" << endl;
       }
 
     image.borderColor("#FF0000");
     if ( image.borderColor() != Color("#FF0000") )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
-            << ", failed to set borderColor ("
-            << string(image.borderColor())
-            << ")" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << ", failed to set borderColor ("
+             << string(image.borderColor())
+             << ")" << endl;
       }
 
     image.borderColor("black");
     if ( image.borderColor() != Color("#000000") )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
-            << ", failed to set borderColor ("
-            << string(image.borderColor())
-            << ")"
-            << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << ", failed to set borderColor ("
+             << string(image.borderColor())
+             << ")"
+             << endl;
       }
-    
+
     //
     // boxColor
     //
     image.boxColor("#FF0000");
     if ( image.boxColor() != Color("#FF0000") )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
-            << ", failed to set boxColor ("
-            << string(image.boxColor())
-            << ")"
-            << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << ", failed to set boxColor ("
+             << string(image.boxColor())
+             << ")"
+             << endl;
       }
 
     image.boxColor("black");
     if ( image.boxColor() != Color("#000000") )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
-            << ", failed to set boxColor ("
-            << string(image.boxColor())
-            << ") to #000000"
-            << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << ", failed to set boxColor ("
+             << string(image.boxColor())
+             << ") to #000000"
+             << endl;
       }
 
     //
@@ -351,22 +351,22 @@ int main( int /*argc*/, char ** argv)
       double x, y;
       image.chromaBluePrimary( &x, &y );
       if ( x != 0 || y != 0 )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__
-              << ",  chromaBluePrimary x/y defaults are non-zero"
-              << endl;
-       }
+        {
+          ++failures;
+          cout << "Line: " << __LINE__
+               << ",  chromaBluePrimary x/y defaults are non-zero"
+               << endl;
+        }
 
       // Test set/get
       image.chromaBluePrimary( 50, 100 );
       image.chromaBluePrimary( &x, &y );
       if ( x != 50 || y != 100 )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__
+        {
+          ++failures;
+          cout << "Line: " << __LINE__
                << ",  chromaBluePrimary x/y failed set/get" << endl;
-       }
+        }
     }
 
     //
@@ -377,21 +377,21 @@ int main( int /*argc*/, char ** argv)
       double x, y;
       image.chromaGreenPrimary( &x, &y );
       if ( x != 0 || y != 0 )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__
+        {
+          ++failures;
+          cout << "Line: " << __LINE__
                << ",  chromaGreenPrimary x/y defaults are non-zero" << endl;
-       }
+        }
 
       // Test set/get
       image.chromaGreenPrimary( 50, 100 );
       image.chromaGreenPrimary( &x, &y );
       if ( x != 50 || y != 100 )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__
+        {
+          ++failures;
+          cout << "Line: " << __LINE__
                << ",  chromaGreenPrimary x/y failed set/get" << endl;
-       }
+        }
     }
 
     //
@@ -402,21 +402,21 @@ int main( int /*argc*/, char ** argv)
       double x, y;
       image.chromaRedPrimary( &x, &y );
       if ( x != 0 || y != 0 )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__
+        {
+          ++failures;
+          cout << "Line: " << __LINE__
                << ",  chromaRedPrimary x/y defaults are non-zero" << endl;
-       }
+        }
 
       // Test set/get
       image.chromaRedPrimary( 50, 100 );
       image.chromaRedPrimary( &x, &y );
       if ( x != 50 || y != 100 )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__
+        {
+          ++failures;
+          cout << "Line: " << __LINE__
                << ",  chromaRedPrimary x/y failed set/get" << endl;
-       }
+        }
     }
 
     //
@@ -427,21 +427,21 @@ int main( int /*argc*/, char ** argv)
       double x, y;
       image.chromaWhitePoint( &x, &y );
       if ( x != 0 || y != 0 )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__
+        {
+          ++failures;
+          cout << "Line: " << __LINE__
                << ",  chromaWhitePoint x/y defaults are non-zero" << endl;
-       }
+        }
 
       // Test set/get
       image.chromaWhitePoint( 50, 100 );
       image.chromaWhitePoint( &x, &y );
       if ( x != 50 || y != 100 )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__
+        {
+          ++failures;
+          cout << "Line: " << __LINE__
                << ",  chromaWhitePoint x/y failed set/get" << endl;
-       }
+        }
     }
 
     //
@@ -449,8 +449,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.classType() != PseudoClass )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", classType is not PseudoClass" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", classType is not PseudoClass" << endl;
       }
 
     //
@@ -460,16 +460,16 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.colorFuzz() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ",  colorFuzz default is non-zero" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ",  colorFuzz default is non-zero" << endl;
       }
 
     // Test set/get
     image.colorFuzz( 2 );
     if ( image.colorFuzz() != 2 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ",  colorFuzz failed to set/get" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ",  colorFuzz failed to set/get" << endl;
       }
     image.colorFuzz( 0 );
 
@@ -479,18 +479,18 @@ int main( int /*argc*/, char ** argv)
     // Test default (first color is image canvas base color)
     if ( image.colorMap(0) != canvasColor )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", colorMap(0) ("
-            << string(image.colorMap(0))
-            << ") is not canvas base color " << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", colorMap(0) ("
+             << string(image.colorMap(0))
+             << ") is not canvas base color " << endl;
       }
 
     // Test setting/getting colorMap
     image.colorMap(0,"#00AAFF");
     if ( image.colorMap(0) != Color("#00AAFF") )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", failed to set/get colorMap(0)" << endl;
       }
     image.colorMap(0,canvasColor);
@@ -500,8 +500,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.columns() != columns )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", columns is not equal to canvas image columns" << endl;
       }
 
@@ -511,8 +511,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.comment().length() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", comment default non-zero length" << endl;
       }
 
@@ -521,18 +521,18 @@ int main( int /*argc*/, char ** argv)
       std::string comment("This is a comment.");
       image.comment( comment );
       if ( image.comment() != comment )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__ << ", comment set/get failed" << endl;
-       }
+        {
+          ++failures;
+          cout << "Line: " << __LINE__ << ", comment set/get failed" << endl;
+        }
     }
 
     // Test resetting comment
     image.comment( string() );
     if ( image.comment().length() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", comment failed to reset" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", comment failed to reset" << endl;
       }
 
     //
@@ -541,8 +541,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.compressType() != UndefinedCompression )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", compressType default is incorrect" << endl;
       }
 
@@ -550,8 +550,8 @@ int main( int /*argc*/, char ** argv)
     image.compressType(RLECompression);
     if ( image.compressType() != RLECompression )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", compressType set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", compressType set/get failed" << endl;
       }
     image.compressType(UndefinedCompression);
 
@@ -561,28 +561,28 @@ int main( int /*argc*/, char ** argv)
     {
       // Test defaults
       if ( image.density() != Geometry(72,72) )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__
+        {
+          ++failures;
+          cout << "Line: " << __LINE__
                << ", density default is not 72x72 as expected" << endl;
-       }
-      
+        }
+
       // Test set/get
       Geometry density(150,75);
       image.density(density);
       if ( image.density() != density )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__ << ", density set/get failed" << endl;
-       }
+        {
+          ++failures;
+          cout << "Line: " << __LINE__ << ", density set/get failed" << endl;
+        }
 
 
       if ( image.xResolution() != 150 ||
-          image.yResolution() != 75 )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__ << ", density set/get failed" << endl;
-       }
+           image.yResolution() != 75 )
+        {
+          ++failures;
+          cout << "Line: " << __LINE__ << ", density set/get failed" << endl;
+        }
 
       image.density("72x72");
 
@@ -642,8 +642,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.depth() != QuantumDepth )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", depth ("
              << image.depth()
              << ") is not equal to " << QuantumDepth << endl;
@@ -659,21 +659,21 @@ int main( int /*argc*/, char ** argv)
            << "that the exception was not caught indicates a test failure.  A properly" << endl
            << "formatted exception message indicates success:" << endl;
       try
-       {
-         //image.directory();
+        {
+          //image.directory();
           Magick::Image bad_image("foo");
-       }
+        }
       catch ( Exception &exception_)
-       {
+        {
           cout << "Caught exception, good!:" << endl
                << "  \"" << exception_.what() << "\"" << endl;
-         caughtException = true;
-       }
+          caughtException = true;
+        }
       if ( caughtException != true )
-       {
-         ++failures;
+        {
+          ++failures;
           cout << "failed to catch exception!" << endl;
-       }
+        }
     }
 
     //
@@ -682,26 +682,26 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.fileName() != string("xc:") + string(canvasColor) )
       {
-       ++failures;
-       cout << "Line: "
-            << __LINE__
-            << ", fileName ("
-            << image.fileName()
-            << ") is not canvas color ("
-            << string(canvasColor)
-            <<") as expected" << endl;
+        ++failures;
+        cout << "Line: "
+             << __LINE__
+             << ", fileName ("
+             << image.fileName()
+             << ") is not canvas color ("
+             << string(canvasColor)
+             <<") as expected" << endl;
       }
 
     // Set/get value
     image.fileName("filename.jpg");
     if ( image.fileName() != "filename.jpg" )
       {
-       ++failures;
-       cout << "Line: "
-            << __LINE__
-            << ", fileName ("
-            << image.fileName()
-            << ") failed to set/get" << endl;
+        ++failures;
+        cout << "Line: "
+             << __LINE__
+             << ", fileName ("
+             << image.fileName()
+             << ") failed to set/get" << endl;
       }
     image.fileName(canvasColor);
 
@@ -711,10 +711,10 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.fileSize() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", fileSize ("
-            << static_cast<long>(image.fileSize())
-            << ") is not zero as expected" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", fileSize ("
+             << static_cast<long>(image.fileSize())
+             << ") is not zero as expected" << endl;
       }
 
     //
@@ -723,8 +723,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.filterType() != UndefinedFilter )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", filterType default ("
              << (int)image.filterType()
              << ") is incorrect" << endl;
@@ -734,8 +734,8 @@ int main( int /*argc*/, char ** argv)
     image.filterType( TriangleFilter );
     if ( image.filterType() != TriangleFilter )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", filterType set/get failed"
+        ++failures;
+        cout << "Line: " << __LINE__ << ", filterType set/get failed"
              << endl;
       }
 
@@ -747,15 +747,15 @@ int main( int /*argc*/, char ** argv)
     image.font("helvetica");
     if ( image.font() != "helvetica" )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", font set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", font set/get failed" << endl;
       }
     // Test set to null font
     image.font( string() );
     if ( image.font().length() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", font failed to unset" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", font failed to unset" << endl;
       }
 
     //
@@ -764,8 +764,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.fontPointsize() != 12 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", fontPointsize ("
              << image.fontPointsize()
              << ") is not default of 12 as expected"
@@ -776,8 +776,8 @@ int main( int /*argc*/, char ** argv)
     image.fontPointsize(10);
     if ( image.fontPointsize() != 10 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", fontPointsize set/get failed" << endl;
       }
     image.fontPointsize(12);
@@ -787,8 +787,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.format() != "Constant image uniform color" )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", format (" << image.format() << ") is not expected value" << endl;
       }
 
@@ -812,8 +812,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.gamma() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", gamma correction is not zero as expected" << endl;
       }
 
@@ -823,19 +823,19 @@ int main( int /*argc*/, char ** argv)
     {
       bool caughtException = false;
       try
-       {
-         image.geometry();
-       }
-      catch ( Exception )
-       {
-         caughtException = true;
-       }
+        {
+          image.geometry();
+        }
+      catch ( Exception )
+        {
+          caughtException = true;
+        }
       if ( caughtException != true )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__
+        {
+          ++failures;
+          cout << "Line: " << __LINE__
                << ", geometry failed to report missing image geometry";
-       }
+        }
     }
 
     //
@@ -844,8 +844,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.gifDisposeMethod() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", gifDisposeMethod default is not zero as expected" << endl;
       }
 
@@ -853,8 +853,8 @@ int main( int /*argc*/, char ** argv)
     image.gifDisposeMethod(4);
     if ( image.gifDisposeMethod() != 4 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", gifDisposeMethod set/get failed" << endl;
       }
     image.gifDisposeMethod(0);
@@ -865,8 +865,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.interlaceType() != UndefinedInterlace )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", interlaceType default is not UndefinedInterlace as expected" << endl;
       }
 
@@ -874,8 +874,8 @@ int main( int /*argc*/, char ** argv)
     image.interlaceType( PlaneInterlace );
     if ( image.interlaceType() != PlaneInterlace )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", interlaceType set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", interlaceType set/get failed" << endl;
       }
     image.interlaceType(NoInterlace);
 
@@ -885,8 +885,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.label().length() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", label default is not empty string as expected" << endl;
       }
 
@@ -894,15 +894,15 @@ int main( int /*argc*/, char ** argv)
     image.label("How now brown cow?");
     if ( image.label() != "How now brown cow?" )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", label set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", label set/get failed" << endl;
       }
     // Test set to default
     image.label( string() );
     if ( image.label().length() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", label failed to unset" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", label failed to unset" << endl;
       }
 
     //
@@ -911,8 +911,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.lineWidth() != 1 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", lineWidth default is not 1 as expected" << endl;
       }
 
@@ -920,8 +920,8 @@ int main( int /*argc*/, char ** argv)
     image.lineWidth(2);
     if ( image.lineWidth() != 2 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", lineWidth set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", lineWidth set/get failed" << endl;
       }
     image.lineWidth(1);
 
@@ -931,8 +931,8 @@ int main( int /*argc*/, char ** argv)
     // Test canvas default
     if ( image.magick() != "XC" )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", magick canvas default is not XC as expected" << endl;
       }
 
@@ -940,8 +940,8 @@ int main( int /*argc*/, char ** argv)
     image.magick("GIF");
     if ( image.magick() != "GIF" )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", magick set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", magick set/get failed" << endl;
       }
 
     image.magick("XC");
@@ -952,8 +952,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.matte() != false )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", matte default is not false as expected" << endl;
       }
 
@@ -961,8 +961,8 @@ int main( int /*argc*/, char ** argv)
     image.matte(true);
     if ( image.matte() != true )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", matte set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", matte set/get failed" << endl;
       }
     image.matte(false);
 
@@ -972,8 +972,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.matteColor() != Color("#BDBDBD") )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", matteColor default is not #BDBDBD as expected" << endl;
       }
 
@@ -981,8 +981,8 @@ int main( int /*argc*/, char ** argv)
     image.matteColor(ColorRGB(0.5,0.5,1));
     if ( image.matteColor() != ColorRGB(0.5,0.5,1) )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", matteColor set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", matteColor set/get failed" << endl;
       }
 
     // Test unset
@@ -995,8 +995,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.meanErrorPerPixel() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", meanErrorPerPixel is not zero as expected" << endl;
       }
 
@@ -1006,19 +1006,19 @@ int main( int /*argc*/, char ** argv)
     {
       bool caughtException = false;
       try
-       {
-         image.montageGeometry();
-       }
-      catch ( Exception )
-       {
-         caughtException = true;
-       }
+        {
+          image.montageGeometry();
+        }
+      catch ( Exception )
+        {
+          caughtException = true;
+        }
       if ( caughtException != true )
-       {
-         ++failures;
-         cout << "Line: " << __LINE__
+        {
+          ++failures;
+          cout << "Line: " << __LINE__
                << ", montageGeometry failed to report missing montage geometry";
-       }
+        }
     }
 
     //
@@ -1027,8 +1027,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.monochrome() != false )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", monochrome is not false as expected" << endl;
       }
 
@@ -1036,8 +1036,8 @@ int main( int /*argc*/, char ** argv)
     image.monochrome(true);
     if ( image.monochrome() != true )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", monochrome get/set failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", monochrome get/set failed" << endl;
       }
     image.monochrome(false);
 
@@ -1046,8 +1046,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.normalizedMaxError() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ",normalizedMaxError is not zero as expected" << endl;
       }
 
@@ -1056,8 +1056,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.normalizedMeanError() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", normalizedMeanError is not zero as expected" << endl;
       }
 
@@ -1068,10 +1068,10 @@ int main( int /*argc*/, char ** argv)
     image.penColor(ColorRGB(0.5,0.5,1));
     if ( image.penColor() != ColorRGB(0.5,0.5,1) )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", penColor ("
-            << string(image.penColor())
-            << ") set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", penColor ("
+             << string(image.penColor())
+             << ") set/get failed" << endl;
       }
 
     //
@@ -1081,10 +1081,10 @@ int main( int /*argc*/, char ** argv)
     image.strokeColor(ColorRGB(0.5,0.5,1));
     if ( image.strokeColor() != ColorRGB(0.5,0.5,1) )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", strokeColor ("
-            << string(image.strokeColor())
-            << ") set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", strokeColor ("
+             << string(image.strokeColor())
+             << ") set/get failed" << endl;
       }
 
 
@@ -1095,10 +1095,10 @@ int main( int /*argc*/, char ** argv)
     image.fillColor(ColorRGB(0.5,0.5,1));
     if ( image.fillColor() != ColorRGB(0.5,0.5,1) )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", fillColor ("
-            << string(image.fillColor())
-            << ") set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", fillColor ("
+             << string(image.fillColor())
+             << ") set/get failed" << endl;
       }
 
     //
@@ -1107,20 +1107,20 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.pixelColor(40,60) != canvasColor )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", pixelColor default ("
-            << string(image.pixelColor(40,60))
-            << ") is not canvas color ("
-            << string(canvasColor)
-            << ") as expected" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", pixelColor default ("
+             << string(image.pixelColor(40,60))
+             << ") is not canvas color ("
+             << string(canvasColor)
+             << ") as expected" << endl;
       }
 
     // Test set/get
     image.pixelColor(40,60, ColorRGB(0.5,1,1));
     if ( image.pixelColor(40,60) != ColorRGB(0.5,1,1) )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", pixelColor set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", pixelColor set/get failed" << endl;
       }
 
     //
@@ -1129,18 +1129,18 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.page() != Geometry(image.columns(),image.rows(),0,0) )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", page default "
-            << "(" << string(image.page()) << ")"
-            << " is not image dimensions as expected" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", page default "
+             << "(" << string(image.page()) << ")"
+             << " is not image dimensions as expected" << endl;
       }
 
     // Test set/get
     image.page("letter+43+43>");
     if ( image.page() != "612x792+43+43" )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", page set/get failed (" << string(image.page()) << ")" << endl;
       }
 
@@ -1150,8 +1150,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.quality() != 75 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", quality default is not 75 as expected" << endl;
       }
 
@@ -1159,8 +1159,8 @@ int main( int /*argc*/, char ** argv)
     image.quality(65);
     if ( image.quality() != 65 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", quality set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", quality set/get failed" << endl;
       }
     image.quality(75);
 
@@ -1170,8 +1170,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.quantizeColors() != 256 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", quantizeColors is not 256 as expected" << endl;
       }
 
@@ -1179,8 +1179,8 @@ int main( int /*argc*/, char ** argv)
     image.quantizeColors(200);
     if ( image.quantizeColors() != 200 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", quantizeColors set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", quantizeColors set/get failed" << endl;
       }
     image.quantizeColors(0);
 
@@ -1190,8 +1190,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.quantizeColorSpace() != RGBColorspace )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", quantizeColorSpace is not RGBColorspace as expected" << endl;
       }
 
@@ -1199,8 +1199,8 @@ int main( int /*argc*/, char ** argv)
     image.quantizeColorSpace(YIQColorspace);
     if ( image.quantizeColorSpace() != YIQColorspace )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", quantizeColorSpace set/get failed" << endl;
       }
     image.quantizeColorSpace(RGBColorspace);
@@ -1211,8 +1211,8 @@ int main( int /*argc*/, char ** argv)
     // Test default
     if ( image.quantizeDither() != true )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", quantizeDither is not true as expected" << endl;
       }
 
@@ -1220,8 +1220,8 @@ int main( int /*argc*/, char ** argv)
     image.quantizeDither(false);
     if ( image.quantizeDither() != false )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", quantizeDither get/set failed" << endl;
       }
     image.quantizeDither(true);
@@ -1231,17 +1231,17 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.quantizeTreeDepth() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", quantizeTreeDepth default is "
-            << image.quantizeTreeDepth()
-            << " rather than zero as expected" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", quantizeTreeDepth default is "
+             << image.quantizeTreeDepth()
+             << " rather than zero as expected" << endl;
       }
 
     image.quantizeTreeDepth(7);
     if ( image.quantizeTreeDepth() != 7 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", quantizeTreeDepth set/get failed" << endl;
       }
     image.quantizeTreeDepth(8);
@@ -1251,8 +1251,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.renderingIntent() != UndefinedIntent )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", renderingIntent default is not UndefinedIntent as expected"
              << endl;
       }
@@ -1260,8 +1260,8 @@ int main( int /*argc*/, char ** argv)
     image.renderingIntent(PerceptualIntent);
     if ( image.renderingIntent() != PerceptualIntent )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", renderingIntent set/get failed" << endl;
       }
     image.renderingIntent(UndefinedIntent);
@@ -1271,8 +1271,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.resolutionUnits() != UndefinedResolution )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", resolutionUnits default is not UndefinedResolution as expected"
              << endl;
       }
@@ -1280,8 +1280,8 @@ int main( int /*argc*/, char ** argv)
     image.resolutionUnits(PixelsPerCentimeterResolution);
     if ( image.resolutionUnits() != PixelsPerCentimeterResolution )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", resolutionUnits set/get failed" << endl;
       }
     image.resolutionUnits(UndefinedResolution);
@@ -1291,8 +1291,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.rows() != rows )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", rows is canvas rows as expected" << endl;
       }
 
@@ -1301,16 +1301,16 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.scene() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", scene default is not zero as expected" << endl;
       }
 
     image.scene(5);
     if ( image.scene() != 5 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", scene set/get failed" << endl;
       }
     image.scene(0);
@@ -1320,14 +1320,14 @@ int main( int /*argc*/, char ** argv)
     //
 
     if ( image.signature() != "3af362f5b4ad66e9c4a684427fad20c12f2fd9c3c1c7128b00a050d7bec72f44" &&
-        image.signature() != "a529e8fe1d83890d893a153777be5f0fd48cf21e0124adee65da248694a204b2" &&
+         image.signature() != "a529e8fe1d83890d893a153777be5f0fd48cf21e0124adee65da248694a204b2" &&
          image.signature() != "573301a0edb9861de8d02b57e445ba5ea689a494d53a6299e8693b7479ba9cb6")
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", signature ("
-            << image.signature()
-            << ") is incorrect" << endl;
-       image.display();
+        ++failures;
+        cout << "Line: " << __LINE__ << ", signature ("
+             << image.signature()
+             << ") is incorrect" << endl;
+        image.display();
       }
 
     //
@@ -1335,20 +1335,20 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.size() != geometry )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", size ("
-            << string(image.size())
-            << ") is not equal to geometry ("
-            << string(geometry)
-            << ")"
-            << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", size ("
+             << string(image.size())
+             << ") is not equal to geometry ("
+             << string(geometry)
+             << ")"
+             << endl;
       }
 
     image.size("800x600");
     if ( image.size() != Geometry("800x600") )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", size set/get failed" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", size set/get failed" << endl;
       }
     image.size( geometry );
 
@@ -1357,16 +1357,16 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.subImage() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", subImage default is not zero as expected" << endl;
       }
 
     image.subImage(5);
     if ( image.subImage() != 5 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", subImage set/get failed" << endl;
       }
     image.subImage(0);
@@ -1374,18 +1374,18 @@ int main( int /*argc*/, char ** argv)
     //
     // subRange
     //
-    if ( image.subRange() != 0 )
+    if ( image.subRange() != 1 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
-             << ", subRange default is not zero as expected" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << ", subRange default is not one as expected" << endl;
       }
 
     image.subRange(5);
     if ( image.subRange() != 5 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", subRange set/get failed" << endl;
       }
     image.subRange(0);
@@ -1395,24 +1395,24 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.tileName().length() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", tileName default is not empty string as expected" << endl;
       }
-    
+
     image.tileName("How now brown cow?");
     if ( image.tileName() != "How now brown cow?" )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", tileName set/get failed" << endl;
       }
 
     image.tileName( string() );
     if ( image.tileName().length() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", tileName failed to unset" << endl;
       }
 
@@ -1421,9 +1421,9 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.totalColors() != 2 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ << ", totalColors is " << image.totalColors()
-            << " rather than 2 as expected" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__ << ", totalColors is " << image.totalColors()
+             << " rather than 2 as expected" << endl;
       }
 
     //
@@ -1432,8 +1432,8 @@ int main( int /*argc*/, char ** argv)
     image.type(PaletteType);
     if ( image.type() != PaletteType )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", type is not PaletteType as expected. Reported type "
              << (int) image.type() << endl;
       }
@@ -1443,8 +1443,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.verbose() != false )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", verbose is not false as expected" << endl;
       }
 
@@ -1453,24 +1453,24 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.view().length() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", view default is not empty string as expected" << endl;
       }
-    
+
     image.view("How now brown cow?");
     if ( image.view() != "How now brown cow?" )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", view set/get failed" << endl;
       }
 
     image.view( string() );
     if ( image.view().length() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", view failed to unset" << endl;
       }
 
@@ -1479,24 +1479,24 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.x11Display().length() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", x11Display default is not empty string as expected" << endl;
       }
-    
+
     image.x11Display(":0.0");
     if ( image.x11Display() != ":0.0" )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", x11Display set/get failed" << endl;
       }
 
     image.x11Display( string() );
     if ( image.x11Display().length() != 0 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", x11Display failed to unset" << endl;
       }
 
@@ -1505,8 +1505,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.xResolution() != 72 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", xResolution default (" << image.xResolution()
              << ") is not zero as expected" << endl;
       }
@@ -1516,8 +1516,8 @@ int main( int /*argc*/, char ** argv)
     //
     if ( image.yResolution() != 72 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__
+        ++failures;
+        cout << "Line: " << __LINE__
              << ", yResolution default (" << image.yResolution()
              << ") is not zero as expected" << endl;
       }
@@ -1532,7 +1532,7 @@ int main( int /*argc*/, char ** argv)
       cout << "Caught exception: " << error_.what() << endl;
       return 1;
     }
-  
+
   if ( failures )
     {
       cout << failures << " failures" << endl;
index 551888c..920591e 100644 (file)
@@ -32,10 +32,10 @@ int main( int /*argc*/, char ** argv)
     //
     // Test averageImages
     //
-    
+
     list<Image> imageList;
     readImages( &imageList, srcdir + "test_image_anim.miff" );
-    
+
     Image averaged;
     averageImages( &averaged, imageList.begin(), imageList.end() );
     // averaged.display();
@@ -43,11 +43,11 @@ int main( int /*argc*/, char ** argv)
          averaged.signature() != "76e3d52bdb28335843afa0f82adcedd1b0794472bb193f311399322863266ed2" &&
          averaged.signature() != "c2a2a727df34c85e3b6528c06cb12967574d6c85e1d0501055506765c578f7cc")
       {
-       cout << "Line: " << __LINE__
-            << "  Averaging image failed, signature = "
-            << averaged.signature() << endl;
-       averaged.display();
-       ++failures;
+        cout << "Line: " << __LINE__
+             << "  Averaging image failed, signature = "
+             << averaged.signature() << endl;
+        averaged.display();
+        ++failures;
       }
   }
 
@@ -67,7 +67,6 @@ int main( int /*argc*/, char ** argv)
       cout << failures << " failures" << endl;
       return 1;
     }
-  
+
   return 0;
 }
-
index 4db76f9..32ae638 100644 (file)
@@ -56,7 +56,6 @@ int main( int /*argc*/, char ** argv)
       cout << failures << " failures" << endl;
       return 1;
     }
-  
+
   return 0;
 }
-
index e5c5df0..c25dd10 100644 (file)
@@ -123,7 +123,7 @@ int main( int /*argc*/, char **argv)
       cout << "Caught exception: " << error_.what() << endl;
       return 1;
     }
-  
+
   if ( failures )
     {
       cout << failures << " failures" << endl;
index 1e9c45b..1f4b9eb 100644 (file)
@@ -30,56 +30,56 @@ int main( int /*argc*/, char **argv)
     {
       struct colorStr
       {
-       const char* color;
-       double red;
-       double green;
-       double blue;
+        const char* color;
+        double red;
+        double green;
+        double blue;
       };
 
       // Convert ratios from rgb.txt via value/255
       struct colorStr colorMap [] =
-      { 
-       { "red", 1,0,0 },
-       { "green", 0,0.5019607843137256,0 },
-       { "blue", 0,0,1 },
-       { "black", 0,0,0 },
-       { "white", 1,1,1 },
-       { "cyan", 0,1,1 },
-       { "magenta", 1,0,1 },
-       { "yellow", 1,1,0 },
-       { NULL, 0,0,0 }
+      {
+        { "red", 1,0,0 },
+        { "green", 0,0.5019607843137256,0 },
+        { "blue", 0,0,1 },
+        { "black", 0,0,0 },
+        { "white", 1,1,1 },
+        { "cyan", 0,1,1 },
+        { "magenta", 1,0,1 },
+        { "yellow", 1,1,0 },
+        { NULL, 0,0,0 }
       };
 
       for ( int i = 0; colorMap[i].color != NULL; i++ )
-       {
-         {
-           Color color( colorMap[i].color );
-           ColorRGB colorMatch( colorMap[i].red,
-                                colorMap[i].green,
-                                colorMap[i].blue );
-           if ( color != colorMatch )
-             {
-               ++failures;
-               cout << "Line: " << __LINE__ << " Color(\""
-                    << colorMap[i].color << "\") is "
-                    << string(color)
-                    << " rather than "
-                    << string(colorMatch)
-                    << endl;
+        {
+          {
+            Color color( colorMap[i].color );
+            ColorRGB colorMatch( colorMap[i].red,
+                                 colorMap[i].green,
+                                 colorMap[i].blue );
+            if ( color != colorMatch )
+              {
+                ++failures;
+                cout << "Line: " << __LINE__ << " Color(\""
+                     << colorMap[i].color << "\") is "
+                     << string(color)
+                     << " rather than "
+                     << string(colorMatch)
+                     << endl;
                 // printf ("Green: %10.16f\n", color.green());
-             }
-         }
-       }      
+              }
+          }
+        }
     }
 
     // Test conversion to/from X11-style color specifications
     {
       const char * colorStrings[] =
       {
-       "#ABC",
-       "#AABBCC",
-       "#AAAABBBBCCCC",
-       NULL
+        "#ABC",
+        "#AABBCC",
+        "#AAAABBBBCCCC",
+        NULL
       };
 
 #if QuantumDepth == 8
@@ -93,18 +93,18 @@ int main( int /*argc*/, char **argv)
 #endif
 
       for ( int i = 0; colorStrings[i] != NULL; ++i )
-       {
-         if ( string(Color(colorStrings[i])) != expectedString )
-           {
-             ++failures;
-             cout << "Line: " << __LINE__
-                  << " Conversion from " << colorStrings[i]
-                  << " is "
-                  << string(Color(colorStrings[i])) << " rather than "
-                  << expectedString
-                  << endl;
-           }
-       }
+        {
+          if ( string(Color(colorStrings[i])) != expectedString )
+            {
+              ++failures;
+              cout << "Line: " << __LINE__
+                   << " Conversion from " << colorStrings[i]
+                   << " is "
+                   << string(Color(colorStrings[i])) << " rather than "
+                   << expectedString
+                   << endl;
+            }
+        }
     }
 
     // Test ColorGray
@@ -144,7 +144,7 @@ int main( int /*argc*/, char **argv)
       cout << "Caught exception: " << error_.what() << endl;
       return 1;
     }
-  
+
   if ( failures )
     {
       cout << failures << " failures" << endl;
index 7e4368b..3076c11 100644 (file)
@@ -95,7 +95,6 @@ int main( int /*argc*/, char ** argv)
       cout << failures << " failures" << endl;
       return 1;
     }
-  
+
   return 0;
 }
-
index 3a4ef3d..9cb81e6 100644 (file)
@@ -17,25 +17,25 @@ int main( int /*argc*/, char ** argv)
 {
   // Initialize GraphicsMagick
   InitializeMagick(*argv);
-      
+
   volatile int failures=0;
 
   cout << "Checking for working exceptions (may crash and burn) ..." << endl;
   cout.flush();
 
-  {      
+  {
     // Basic exception test
     try
       {
         failures++;
-       cout << "Throwing native 'int' exception" << endl;
-       cout.flush();
+        cout << "Throwing native 'int' exception" << endl;
+        cout.flush();
         throw int(100);
       }
     catch ( int /*value_*/ )
       {
-       cout << "Successfully caught native 'int' exception" << endl;
-       cout.flush();
+        cout << "Successfully caught native 'int' exception" << endl;
+        cout.flush();
         failures--;
       }
 
@@ -43,17 +43,17 @@ int main( int /*argc*/, char ** argv)
     try
       {
         failures++;
-       cout << "Throwing 'Magick::WarningResourceLimit' exception" << endl;
-       cout.flush();
+        cout << "Throwing 'Magick::WarningResourceLimit' exception" << endl;
+        cout.flush();
         throw WarningResourceLimit("How now brown cow?");
       }
     catch( Exception & /*error_*/ )
       {
-       cout << "Successfully caught 'Magick::WarningResourceLimit' exception" << endl;
-       cout.flush();
+        cout << "Successfully caught 'Magick::WarningResourceLimit' exception" << endl;
+        cout.flush();
         failures--;
       }
-      
+
     // A more complex test
     try
       {
@@ -66,36 +66,36 @@ int main( int /*argc*/, char ** argv)
           try
             {
               failures++;
-             cout << "Throwing library 'Magick::Exception' exception" << endl;
-             cout.flush();
+              cout << "Throwing library 'Magick::Exception' exception" << endl;
+              cout.flush();
               image.directory();
             }
           catch ( Exception& /*error_*/ )
             {
-             cout << "Successfully caught library 'Magick::Exception' exception" << endl;
-             cout.flush();
+              cout << "Successfully caught library 'Magick::Exception' exception" << endl;
+              cout.flush();
               failures--;
             }
         }
-          
+
       }
     catch( Exception &error_ )
       {
         cout << "Bogus catch: Caught exception: " << error_.what() << endl;
-       cout.flush();
+        cout.flush();
         return 1;
       }
     catch( exception &error_ )
       {
         cout << "Bogus catch: Caught exception: " << error_.what() << endl;
-       cout.flush();
+        cout.flush();
         return 1;
       }
-  
+
     if ( failures )
       {
         cout << failures << " failures" << endl;
-       cout.flush();
+        cout.flush();
         return 1;
       }
     cout << "Exception testing passed!" << endl;
index 8b24d11..dfb1721 100644 (file)
@@ -21,7 +21,7 @@ int main( int /*argc*/, char ** /*argv*/)
   // Initialize ImageMagick install location for Windows
   // InitializeMagick(*argv);
   InitializeMagick("");
-  
+
   int failures=0;
 
   try {
@@ -48,7 +48,7 @@ int main( int /*argc*/, char ** /*argv*/)
       if ( montage[0].montageGeometry() != targetGeometry )
         {
           ++failures;
-          cout << "Line: " << __LINE__ 
+          cout << "Line: " << __LINE__
                << "  Montage geometry ("
                << string(montage[0].montageGeometry())
                << ") is incorrect (expected "
@@ -60,12 +60,12 @@ int main( int /*argc*/, char ** /*argv*/)
 
     if ( montage[0].columns() != 768 || montage[0].rows() != 126 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ 
-            << "  Montage columns/rows ("
-            << montage[0].columns() << "x"
-            << montage[0].rows()
-            << ") incorrect. (expected 768x124)" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << "  Montage columns/rows ("
+             << montage[0].columns() << "x"
+             << montage[0].rows()
+             << ") incorrect. (expected 768x124)" << endl;
       }
 
     // Montage with options set
@@ -85,11 +85,11 @@ int main( int /*argc*/, char ** /*argv*/)
 
     if ( montage.size() != 3 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ 
-            << "  Montage images failed, number of montage frames is "
-            << montage.size()
-            << " rather than 3 as expected." << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << "  Montage images failed, number of montage frames is "
+             << montage.size()
+             << " rather than 3 as expected." << endl;
       }
 
     {
@@ -97,7 +97,7 @@ int main( int /*argc*/, char ** /*argv*/)
       if ( montage[0].montageGeometry() != targetGeometry )
         {
           ++failures;
-          cout << "Line: " << __LINE__ 
+          cout << "Line: " << __LINE__
                << "  Montage geometry ("
                << string(montage[0].montageGeometry())
                << ") is incorrect (expected "
@@ -109,12 +109,12 @@ int main( int /*argc*/, char ** /*argv*/)
 
     if ( montage[0].columns() != 132 || montage[0].rows() != 70 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ 
-            << "  Montage columns/rows ("
-            << montage[0].columns() << "x"
-            << montage[0].rows()
-            << ") incorrect. (expected 132x68)" << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << "  Montage columns/rows ("
+             << montage[0].columns() << "x"
+             << montage[0].rows()
+             << ") incorrect. (expected 132x68)" << endl;
       }
   }
 
@@ -134,7 +134,6 @@ int main( int /*argc*/, char ** /*argv*/)
       cout << failures << " failures" << endl;
       return 1;
     }
-  
+
   return 0;
 }
-
index 00a0c82..9b4394f 100644 (file)
@@ -41,11 +41,11 @@ int main( int /*argc*/, char **argv)
 
     if ( morphed.size() != 21 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ 
-            << "  Morph images failed, number of frames is "
-            << morphed.size()
-            << " rather than 21 as expected." << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << "  Morph images failed, number of frames is "
+             << morphed.size()
+             << " rather than 21 as expected." << endl;
       }
   }
 
@@ -65,7 +65,6 @@ int main( int /*argc*/, char **argv)
       cout << failures << " failures" << endl;
       return 1;
     }
-  
+
   return 0;
 }
-
index 27af159..c64687f 100644 (file)
@@ -67,7 +67,7 @@ int main( int /*argc*/, char ** argv)
         srcdir = getenv("SRCDIR");
 
       string testimage;
-    
+
       //
       // Test reading BLOBs
       //
@@ -86,15 +86,13 @@ int main( int /*argc*/, char ** argv)
             cout << "Failed to open file " << testimage << " for input!" << endl;
             exit(1);
           }
-        unsigned char* blobData = new unsigned char[100000];
+        in.seekg(0,ios::end);
+        streampos file_size = in.tellg();
+        in.seekg(0,ios::beg);
+        unsigned char* blobData = new unsigned char[file_size];
         char* c=reinterpret_cast<char *>(blobData);
-        size_t blobLen=0;
-        while( (blobLen< 100000) && in.get(*c) )
-          {
-            c++;
-            blobLen++;
-          }
-        if ((!in.eof()) || (blobLen == 0))
+        in.read(c,file_size);
+        if (!in.good())
           {
             cout << "Failed to read file " << testimage << " for input!" << endl;
             exit(1);
@@ -102,7 +100,7 @@ int main( int /*argc*/, char ** argv)
         in.close();
 
         // Construct Magick++ Blob
-        Blob blob(static_cast<const void*>(blobData), blobLen);
+        Blob blob(static_cast<const void*>(blobData), file_size);
         delete [] blobData;
 
         // If construction of image fails, an exception should be thrown
@@ -190,7 +188,7 @@ int main( int /*argc*/, char ** argv)
               image.display();
             }
         }
-      
+
       }
       // Test writing BLOBs via STL writeImages
       {
@@ -234,7 +232,7 @@ int main( int /*argc*/, char ** argv)
           }
       }
     }
-  
+
   catch( Exception &error_ )
     {
       cout << "Caught exception: " << error_.what() << endl;
@@ -251,8 +249,6 @@ int main( int /*argc*/, char ** argv)
       cout << failures << " failures" << endl;
       return 1;
     }
-  
+
   return 0;
 }
-
-
index a3af750..581ec1b 100644 (file)
@@ -32,68 +32,68 @@ int main( int /*argc*/, char ** argv)
     //
     // Test readImages and writeImages
     //
-      
+
     list<Image> first;
     readImages( &first, srcdir + "test_image_anim.miff" );
-      
+
     if ( first.size() != 6 )
       {
-       ++failures;
-       cout << "Line: " << __LINE__ 
-            << "  Read images failed, number of frames is "
-            << first.size()
-            << " rather than 6 as expected." << endl;
+        ++failures;
+        cout << "Line: " << __LINE__
+             << "  Read images failed, number of frames is "
+             << first.size()
+             << " rather than 6 as expected." << endl;
       }
-      
+
     writeImages( first.begin(), first.end(), "testmagick_anim_out.miff" );
-      
+
     list<Image> second;
     readImages( &second, "testmagick_anim_out.miff" );
-      
+
     list<Image>::iterator firstIter = first.begin();
     list<Image>::iterator secondIter = second.begin();
     while( firstIter != first.end() && secondIter != second.end() )
       {
-       if ( *firstIter != *secondIter )
-         {
-           ++failures;
-           cout << "Line: " << __LINE__
-                << "  Image scene: " << secondIter->scene()
-                << " is not equal to original" << endl;
-         }
-
-       if ( firstIter->scene() != secondIter->scene() )
-         {
-           ++failures;
-           cout << "Line: " << __LINE__ 
-                << "  Image scene: " << secondIter->scene()
-                << " is not equal to original "
-                << firstIter->scene()
-                << endl;
-         }
-
-       if ( firstIter->rows() != secondIter->rows() )
-         {
-           ++failures;
-           cout << "Line: " << __LINE__ 
-                << "  Image rows " << secondIter->rows()
-                << " are not equal to original "
-                << firstIter->rows()
-                << endl;
-         }
-
-       if ( firstIter->columns() != secondIter->columns() )
-         {
-           ++failures;
-           cout << "Line: " << __LINE__ 
-                << "  Image columns " << secondIter->columns()
-                << " are not equal to original "
-                << firstIter->rows()
-                << endl;
-         }
-
-       firstIter++;
-       secondIter++;
+        if ( *firstIter != *secondIter )
+          {
+            ++failures;
+            cout << "Line: " << __LINE__
+                 << "  Image scene: " << secondIter->scene()
+                 << " is not equal to original" << endl;
+          }
+
+        if ( firstIter->scene() != secondIter->scene() )
+          {
+            ++failures;
+            cout << "Line: " << __LINE__
+                 << "  Image scene: " << secondIter->scene()
+                 << " is not equal to original "
+                 << firstIter->scene()
+                 << endl;
+          }
+
+        if ( firstIter->rows() != secondIter->rows() )
+          {
+            ++failures;
+            cout << "Line: " << __LINE__
+                 << "  Image rows " << secondIter->rows()
+                 << " are not equal to original "
+                 << firstIter->rows()
+                 << endl;
+          }
+
+        if ( firstIter->columns() != secondIter->columns() )
+          {
+            ++failures;
+            cout << "Line: " << __LINE__
+                 << "  Image columns " << secondIter->columns()
+                 << " are not equal to original "
+                 << firstIter->rows()
+                 << endl;
+          }
+
+        firstIter++;
+        secondIter++;
       }
   }
 
@@ -113,7 +113,6 @@ int main( int /*argc*/, char ** argv)
       cout << failures << " failures" << endl;
       return 1;
     }
-  
+
   return 0;
 }
-
index c52c67e..3e75ecf 100644 (file)
@@ -95,6 +95,8 @@ XFAIL_TESTS = \
 # should want to concatenate them.
 CHANGELOGS = \
        ChangeLog \
+       ChangeLog.2017 \
+       ChangeLog.2016 \
        ChangeLog.2015 \
        ChangeLog.2014 \
        ChangeLog.2013 \
@@ -368,6 +370,8 @@ SNAPSHOT_DIRECTORY=/ftp/pub/GraphicsMagick/snapshots
 snapshot: distcheck
        $(MAKE) $(DIST_ARCHIVE_SRPM)
        $(MAKE) $(DIST_WINDOWS_SRC_7ZIP)
+       $(RM) $(SNAPSHOT_DIRECTORY)/$(PACKAGE_NAME)-*.tar.*
+       $(RM) $(SNAPSHOT_DIRECTORY)/$(PACKAGE_NAME)-*-windows.7z
        mv $(DIST_ARCHIVES) $(DIST_WINDOWS_SRC_7ZIP) $(DIST_ARCHIVE_SRPM) $(SNAPSHOT_DIRECTORY)/
        cp $(top_srcdir)/ChangeLog $(SNAPSHOT_DIRECTORY)/ChangeLog.txt
        cp $(top_srcdir)/www/Changelog.html $(SNAPSHOT_DIRECTORY)/ChangeLog.html
@@ -376,6 +380,7 @@ COVERITY_EMAIL=bfriesen@simple.dallas.tx.us
 COVERITY_TARBALL=GraphicsMagick.xz
 COVERITY_VERSION=snapshot-@PACKAGE_CHANGE_DATE@
 COVERITY_DESCRIPTION='Ubuntu Q@QuantumDepth@'
+# New URL is https://brb.synopsys.com/?project=GraphicsMagick
 coverity:
        $(MAKE) clean
        cov-build --dir cov-int $(MAKE)
@@ -399,3 +404,12 @@ coverity:
 #      $(MAKE) CFLAGS="$(CFLAGS) -fprofile-use"
 #
 #CLEANFILES = *.gcda *.gcno
+
+# Generate magick/symbols.h and wand/wand_symbols.h based on archive
+# library symbols
+GMMAGICKSYMBOLS=$(srcdir)/magick/symbols.h
+GMWANDSYMBOLS=$(srcdir)/wand/wand_symbols.h
+
+gmsymbols:
+       $(srcdir)/scripts/gmsymbols.sh magick/.libs/libGraphicsMagick.a MAGICK > $(GMMAGICKSYMBOLS)
+       $(srcdir)/scripts/gmsymbols.sh wand/.libs/libGraphicsMagickWand.a MAGICK_WAND > $(GMWANDSYMBOLS)
index ace40a6..27d92de 100644 (file)
@@ -34,7 +34,7 @@
 #
 #
 
-# Copyright (C) 2004-2016 GraphicsMagick Group
+# Copyright (C) 2004-2018 GraphicsMagick Group
 #
 # This program is covered by multiple licenses, which are described in
 # Copyright.txt. You should have received a copy of Copyright.txt with this
 # Makefile for building Wand API HTML files
 #
 
-# Copyright (C) 2004-2012 GraphicsMagick Group
+# Copyright (C) 2004-2018 GraphicsMagick Group
 #
 # This program is covered by multiple licenses, which are described in
 # Copyright.txt. You should have received a copy of Copyright.txt with this
@@ -225,7 +225,8 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \
        $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
        $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-       $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
+       $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/acinclude.m4 \
+       $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
@@ -436,8 +437,7 @@ coders_emf_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(coders_emf_la_LDFLAGS) $(LDFLAGS) -o $@
 @HasWINGDI32_TRUE@@WITH_MODULES_TRUE@am_coders_emf_la_rpath = -rpath \
 @HasWINGDI32_TRUE@@WITH_MODULES_TRUE@  $(codersdir)
-coders_ept_la_DEPENDENCIES = $(LIBMAGICK) $(am__DEPENDENCIES_1) \
-       $(am__DEPENDENCIES_1)
+coders_ept_la_DEPENDENCIES = $(LIBMAGICK) $(am__DEPENDENCIES_1)
 am_coders_ept_la_OBJECTS = coders/ept.lo
 coders_ept_la_OBJECTS = $(am_coders_ept_la_OBJECTS)
 coders_ept_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -748,8 +748,7 @@ coders_pdb_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
        $(coders_pdb_la_LDFLAGS) $(LDFLAGS) -o $@
 @WITH_MODULES_TRUE@am_coders_pdb_la_rpath = -rpath $(codersdir)
-coders_pdf_la_DEPENDENCIES = $(LIBMAGICK) $(am__DEPENDENCIES_1) \
-       $(am__DEPENDENCIES_1)
+coders_pdf_la_DEPENDENCIES = $(LIBMAGICK) $(am__DEPENDENCIES_1)
 am_coders_pdf_la_OBJECTS = coders/coders_pdf_la-pdf.lo
 coders_pdf_la_OBJECTS = $(am_coders_pdf_la_OBJECTS)
 coders_pdf_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -804,8 +803,7 @@ coders_preview_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
        $(AM_CFLAGS) $(CFLAGS) $(coders_preview_la_LDFLAGS) $(LDFLAGS) \
        -o $@
 @WITH_MODULES_TRUE@am_coders_preview_la_rpath = -rpath $(codersdir)
-coders_ps_la_DEPENDENCIES = $(LIBMAGICK) $(am__DEPENDENCIES_1) \
-       $(am__DEPENDENCIES_1)
+coders_ps_la_DEPENDENCIES = $(LIBMAGICK) $(am__DEPENDENCIES_1)
 am_coders_ps_la_OBJECTS = coders/coders_ps_la-ps.lo
 coders_ps_la_OBJECTS = $(am_coders_ps_la_OBJECTS)
 coders_ps_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
@@ -815,6 +813,7 @@ coders_ps_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 coders_ps2_la_DEPENDENCIES = $(LIBMAGICK) $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1)
 am_coders_ps2_la_OBJECTS = coders/coders_ps2_la-ps2.lo
 coders_ps2_la_OBJECTS = $(am_coders_ps2_la_OBJECTS)
@@ -825,6 +824,7 @@ coders_ps2_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 coders_ps3_la_DEPENDENCIES = $(LIBMAGICK) $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1)
 am_coders_ps3_la_OBJECTS = coders/coders_ps3_la-ps3.lo
 coders_ps3_la_OBJECTS = $(am_coders_ps3_la_OBJECTS)
@@ -923,6 +923,7 @@ coders_tga_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
 coders_tiff_la_DEPENDENCIES = $(LIBMAGICK) $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+       $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
        $(am__DEPENDENCIES_1)
 am_coders_tiff_la_OBJECTS = coders/coders_tiff_la-tiff.lo
 coders_tiff_la_OBJECTS = $(am_coders_tiff_la_OBJECTS)
@@ -2090,6 +2091,8 @@ EXEEXT = @EXEEXT@
 EditorDelegate = @EditorDelegate@
 FGREP = @FGREP@
 FIGDecodeDelegate = @FIGDecodeDelegate@
+FT_CFLAGS = @FT_CFLAGS@
+FT_LIBS = @FT_LIBS@
 GMDelegate = @GMDelegate@
 GREP = @GREP@
 GSCMYKDevice = @GSCMYKDevice@
@@ -2139,7 +2142,6 @@ LIB_DL = @LIB_DL@
 LIB_DPS = @LIB_DPS@
 LIB_FPX = @LIB_FPX@
 LIB_GDI32 = @LIB_GDI32@
-LIB_GS = @LIB_GS@
 LIB_JBIG = @LIB_JBIG@
 LIB_JP2 = @LIB_JP2@
 LIB_JPEG = @LIB_JPEG@
@@ -2161,6 +2163,7 @@ LIB_XEXT = @LIB_XEXT@
 LIB_XML = @LIB_XML@
 LIB_XML_DEPS = @LIB_XML_DEPS@
 LIB_ZLIB = @LIB_ZLIB@
+LIB_ZSTD = @LIB_ZSTD@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LOCALSTATE_DIR = @LOCALSTATE_DIR@
@@ -2180,6 +2183,7 @@ MAGICK_CODER_MODULE_PATH = @MAGICK_CODER_MODULE_PATH@
 MAGICK_CONFIGURE_BUILD_PATH = @MAGICK_CONFIGURE_BUILD_PATH@
 MAGICK_CONFIGURE_SRC_PATH = @MAGICK_CONFIGURE_SRC_PATH@
 MAGICK_DEP_LIBS = @MAGICK_DEP_LIBS@
+MAGICK_EXTRA_DEP_LIBS = @MAGICK_EXTRA_DEP_LIBS@
 MAGICK_FEATURES = @MAGICK_FEATURES@
 MAGICK_FILTER_MODULE_PATH = @MAGICK_FILTER_MODULE_PATH@
 MAGICK_LIBRARY_AGE = @MAGICK_LIBRARY_AGE@
@@ -2245,6 +2249,9 @@ PERL = @PERL@
 PERLMAINCC = @PERLMAINCC@
 PERL_MAKE_OPTIONS = @PERL_MAKE_OPTIONS@
 PERL_SUPPORTS_DESTDIR = @PERL_SUPPORTS_DESTDIR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
 PREFIX_DIR = @PREFIX_DIR@
 PSDelegate = @PSDelegate@
 PTHREAD_CC = @PTHREAD_CC@
@@ -2279,6 +2286,8 @@ UINTPTR_T = @UINTPTR_T@
 VERSION = @VERSION@
 WinPathScript = @WinPathScript@
 XMKMF = @XMKMF@
+XML_CFLAGS = @XML_CFLAGS@
+XML_LIBS = @XML_LIBS@
 X_CFLAGS = @X_CFLAGS@
 X_EXTRA_LIBS = @X_EXTRA_LIBS@
 X_LIBS = @X_LIBS@
@@ -2407,6 +2416,8 @@ TESTS_ENVIRONMENT = \
 # should want to concatenate them.
 CHANGELOGS = \
        ChangeLog \
+       ChangeLog.2017 \
+       ChangeLog.2016 \
        ChangeLog.2015 \
        ChangeLog.2014 \
        ChangeLog.2013 \
@@ -2789,7 +2800,7 @@ coders_dps_la_LIBADD = $(LIBMAGICK) $(LIB_DPS) $(LIB_XEXT) $(LIB_X11)
 coders_dpx_la_SOURCES = coders/dpx.c
 coders_dpx_la_CPPFLAGS = $(MAGICK_CODER_CPPFLAGS)
 coders_dpx_la_LDFLAGS = $(MODULECOMMONFLAGS)
-coders_dpx_la_LIBADD = $(LIBMAGICK) 
+coders_dpx_la_LIBADD = $(LIBMAGICK)
 
 # EMF coder module
 coders_emf_la_SOURCES = coders/emf.c
@@ -2801,7 +2812,7 @@ coders_emf_la_LIBADD = $(LIBMAGICK) $(LIB_GDI32)
 coders_ept_la_SOURCES = coders/ept.c
 coders_epd_la_CPPFLAGS = $(MAGICK_CODER_CPPFLAGS)
 coders_ept_la_LDFLAGS = $(MODULECOMMONFLAGS)
-coders_ept_la_LIBADD = $(LIBMAGICK) $(LIB_GS) $(LIB_MATH)
+coders_ept_la_LIBADD = $(LIBMAGICK) $(LIB_MATH)
 
 # FAX coder module
 coders_fax_la_SOURCES = coders/fax.c
@@ -3041,7 +3052,7 @@ coders_pdb_la_LIBADD = $(LIBMAGICK)
 coders_pdf_la_SOURCES = coders/pdf.c
 coders_pdf_la_CPPFLAGS = $(MAGICK_CODER_CPPFLAGS)
 coders_pdf_la_LDFLAGS = $(MODULECOMMONFLAGS)
-coders_pdf_la_LIBADD = $(LIBMAGICK) $(LIB_ZLIB) $(LIB_GS)
+coders_pdf_la_LIBADD = $(LIBMAGICK) $(LIB_ZLIB)
 
 # PICT coder module
 coders_pict_la_SOURCES = coders/pict.c
@@ -3083,19 +3094,19 @@ coders_preview_la_LIBADD = $(LIBMAGICK)
 coders_ps_la_SOURCES = coders/ps.c
 coders_ps_la_CPPFLAGS = $(MAGICK_CODER_CPPFLAGS)
 coders_ps_la_LDFLAGS = $(MODULECOMMONFLAGS)
-coders_ps_la_LIBADD = $(LIBMAGICK) $(LIB_GS) $(LIB_MATH)
+coders_ps_la_LIBADD = $(LIBMAGICK) $(LIB_MATH)
 
 # PS2 coder module
 coders_ps2_la_SOURCES = coders/ps2.c
 coders_ps2_la_CPPFLAGS = $(MAGICK_CODER_CPPFLAGS)
 coders_ps2_la_LDFLAGS = $(MODULECOMMONFLAGS)
-coders_ps2_la_LIBADD = $(LIBMAGICK) $(LIB_TIFF) $(LIB_JBIG) $(LIB_JPEG) $(LIB_LZMA) $(LIB_ZLIB) $(LIB_MATH)
+coders_ps2_la_LIBADD = $(LIBMAGICK) $(LIB_TIFF) $(LIB_JBIG) $(LIB_JPEG) $(LIB_LZMA) $(LIB_WEBP) $(LIB_ZLIB) $(LIB_ZSTD) $(LIB_MATH)
 
 # PS3 coder module
 coders_ps3_la_SOURCES = coders/ps3.c
 coders_ps3_la_CPPFLAGS = $(MAGICK_CODER_CPPFLAGS)
 coders_ps3_la_LDFLAGS = $(MODULECOMMONFLAGS)
-coders_ps3_la_LIBADD = $(LIBMAGICK) $(LIB_TIFF) $(LIB_JBIG) $(LIB_JPEG) $(LIB_LZMA) $(LIB_ZLIB) $(LIB_MATH)
+coders_ps3_la_LIBADD = $(LIBMAGICK) $(LIB_TIFF) $(LIB_JBIG) $(LIB_JPEG) $(LIB_LZMA) $(LIB_WEBP) $(LIB_ZLIB) $(LIB_ZSTD) $(LIB_MATH)
 
 # PSD coder module
 coders_psd_la_SOURCES = coders/psd.c
@@ -3173,7 +3184,7 @@ coders_tga_la_LIBADD = $(LIBMAGICK)
 coders_tiff_la_SOURCES = coders/tiff.c
 coders_tiff_la_CPPFLAGS = $(MAGICK_CODER_CPPFLAGS)
 coders_tiff_la_LDFLAGS = $(MODULECOMMONFLAGS)
-coders_tiff_la_LIBADD = $(LIBMAGICK) $(LIB_TIFF) $(LIB_JBIG) $(LIB_JPEG) $(LIB_LZMA) $(LIB_ZLIB) $(LIB_MATH)
+coders_tiff_la_LIBADD = $(LIBMAGICK) $(LIB_TIFF) $(LIB_JBIG) $(LIB_JPEG) $(LIB_LZMA) $(LIB_WEBP) $(LIB_ZLIB) $(LIB_ZSTD) $(LIB_MATH)
 
 # TILE coder module
 coders_tile_la_SOURCES = coders/tile.c
@@ -3585,6 +3596,7 @@ MAGICK_NOINST_HDRS = \
        magick/floats.h \
        magick/locale_c.h \
        magick/map.h \
+       magick/module_aliases.h \
        magick/nt_base.h \
        magick/nt_feature.h \
        magick/omp_data_view.h \
@@ -3988,6 +4000,7 @@ RST2HTML_TARGETS = \
        $(WWWDIR)/ChangeLog-2014.html \
        $(WWWDIR)/ChangeLog-2015.html \
        $(WWWDIR)/ChangeLog-2016.html \
+       $(WWWDIR)/ChangeLog-2017.html \
        $(WWWDIR)/Changelog.html \
        $(WWWDIR)/Changes.html \
        $(WWWDIR)/Copyright.html \
@@ -4104,6 +4117,7 @@ WWW_HTML_FILES = \
        $(WWWDIR)/ChangeLog-2014.html \
        $(WWWDIR)/ChangeLog-2015.html \
        $(WWWDIR)/ChangeLog-2016.html \
+       $(WWWDIR)/ChangeLog-2017.html \
        $(WWWDIR)/Changelog.html \
        $(WWWDIR)/Changes.html \
        $(WWWDIR)/Copyright.html \
@@ -4449,6 +4463,22 @@ COVERITY_EMAIL = bfriesen@simple.dallas.tx.us
 COVERITY_TARBALL = GraphicsMagick.xz
 COVERITY_VERSION = snapshot-@PACKAGE_CHANGE_DATE@
 COVERITY_DESCRIPTION = 'Ubuntu Q@QuantumDepth@'
+
+# Rules for a profiled build (according to Paolo Bonzini <bonzini@gnu.org>)
+#.PHONY: profile
+#profile:
+#      $(MAKE) clean
+#      $(MAKE) CFLAGS="$(CFLAGS) -fprofile-generate"
+#      $(MAKE) check
+#      $(MAKE) mostlyclean
+#      $(MAKE) CFLAGS="$(CFLAGS) -fprofile-use"
+#
+#CLEANFILES = *.gcda *.gcno
+
+# Generate magick/symbols.h and wand/wand_symbols.h based on archive
+# library symbols
+GMMAGICKSYMBOLS = $(srcdir)/magick/symbols.h
+GMWANDSYMBOLS = $(srcdir)/wand/wand_symbols.h
 all: $(BUILT_SOURCES)
        $(MAKE) $(AM_MAKEFLAGS) all-am
 
@@ -9842,6 +9872,9 @@ uninstall-data-html:
 @MAINTAINER_MODE_TRUE@$(top_srcdir)/www/Changelog.rst: $(top_srcdir)/ChangeLog
 @MAINTAINER_MODE_TRUE@ $(CHANGELOG2RST) < $^ > $@
 
+@MAINTAINER_MODE_TRUE@$(top_srcdir)/www/ChangeLog-2017.rst: $(top_srcdir)/ChangeLog.2017
+@MAINTAINER_MODE_TRUE@ $(CHANGELOG2RST) < $^ > $@
+
 @MAINTAINER_MODE_TRUE@$(top_srcdir)/www/ChangeLog-2016.rst: $(top_srcdir)/ChangeLog.2016
 @MAINTAINER_MODE_TRUE@ $(CHANGELOG2RST) < $^ > $@
 
@@ -9928,7 +9961,7 @@ uninstall-data-html:
 @HasRST2HTML_TRUE@@MAINTAINER_MODE_TRUE@       --url-prefix=`$(RELPATH) $(top_srcdir)/www $@` $< $@
 
 utilities/tests/montage.log : \
-       utilities/tests/effects.tap
+       utilities/tests/effects.log
 @MAGICK_COMPAT_TRUE@install-exec-local-utilities:
 @MAGICK_COMPAT_TRUE@   $(mkdir_p) $(DESTDIR)$(bindir)
 @MAGICK_COMPAT_TRUE@   cd $(DESTDIR)$(bindir) ; \
@@ -10155,9 +10188,12 @@ $(DIST_WINDOWS_SRC_7ZIP) windows-dist:
 snapshot: distcheck
        $(MAKE) $(DIST_ARCHIVE_SRPM)
        $(MAKE) $(DIST_WINDOWS_SRC_7ZIP)
+       $(RM) $(SNAPSHOT_DIRECTORY)/$(PACKAGE_NAME)-*.tar.*
+       $(RM) $(SNAPSHOT_DIRECTORY)/$(PACKAGE_NAME)-*-windows.7z
        mv $(DIST_ARCHIVES) $(DIST_WINDOWS_SRC_7ZIP) $(DIST_ARCHIVE_SRPM) $(SNAPSHOT_DIRECTORY)/
        cp $(top_srcdir)/ChangeLog $(SNAPSHOT_DIRECTORY)/ChangeLog.txt
        cp $(top_srcdir)/www/Changelog.html $(SNAPSHOT_DIRECTORY)/ChangeLog.html
+# New URL is https://brb.synopsys.com/?project=GraphicsMagick
 coverity:
        $(MAKE) clean
        cov-build --dir cov-int $(MAKE)
@@ -10171,16 +10207,9 @@ coverity:
        https://scan.coverity.com/builds?project=GraphicsMagick
        $(RM) $(COVERITY_TARBALL)
 
-# Rules for a profiled build (according to Paolo Bonzini <bonzini@gnu.org>)
-#.PHONY: profile
-#profile:
-#      $(MAKE) clean
-#      $(MAKE) CFLAGS="$(CFLAGS) -fprofile-generate"
-#      $(MAKE) check
-#      $(MAKE) mostlyclean
-#      $(MAKE) CFLAGS="$(CFLAGS) -fprofile-use"
-#
-#CLEANFILES = *.gcda *.gcno
+gmsymbols:
+       $(srcdir)/scripts/gmsymbols.sh magick/.libs/libGraphicsMagick.a MAGICK > $(GMMAGICKSYMBOLS)
+       $(srcdir)/scripts/gmsymbols.sh wand/.libs/libGraphicsMagickWand.a MAGICK_WAND > $(GMWANDSYMBOLS)
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
index d38a018..8be5dcf 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
 GraphicsMagick News
 ===================
 
-This file was last updated on July 4, 2017
+This file was last updated on November 17, 2018
 
 Please note that this file records news for the associated development
 branch and that each development branch has its own NEWS file. See the
-ChangeLog file for full details.
+ChangeLog file, and/or the Mercurial changesets, for full details.
+
+Due to significant issues being discovered and addressed for almost
+every release, it is recommended to update to the most current
+release and not attempt to patch older releases.
 
 .. contents::
   :local:
 
+1.3.31 (November 17, 2018)
+==========================
+
+Special Issues:
+
+* Firmware and operating system updates to address the Spectre
+  vulnerability (and possibly to some extent the Meltdown
+  vulnerability) have substantially penalized GraphicsMagick's OpenMP
+  performance.  Performance is reduced even with GCC 7 and 8's
+  improved optimizers. There does not appear to be anything we can do
+  about this.
+
+Security Fixes:
+
+* GraphicsMagick is now participating in Google's oss-fuzz project due
+  to the contributions and assistance of Alex Gaynor. Since February 4
+  2018, 292 issues have been opened by oss-fuzz and 279 of those
+  issues have been resolved.  The issues list is available at
+  https://bugs.chromium.org/p/oss-fuzz/issues/list under search term
+  "graphicsmagick".  Issues are available for anyone to view and
+  duplicate if they have been in "Verified" status for 30 days, or if
+  they have been in "New" status for 90 days.  There are too many
+  fixes to list here.  Please consult the GraphicsMagick ChangeLog
+  file, Mercurial repository commit log, and the oss-fuzz issues list
+  for details.
+
+Bug fixes:
+
+* See above note about oss-fuzz fixes.
+
+* CINEON: Fix unexpected hang on a crafted Cineon image.  SourceForge
+  issue 571.
+
+* Drawing recursion is limited to 100 and may be tuned via the
+  MAX_DRAWIMAGE_RECURSION pre-processor definition.
+
+* Fix reading MIFF files using legacy keyword 'color-profile' for ICC
+  color profile as was used by ImageMagick 4.2.9.
+
+* Fix reading/writing files when 'magick' is specified in lower case.
+  This bug was a regression in 1.3.30.
+
+
+New Features:
+
+* TIFF: Support Zstd compression in TIFF.  This requires libtiff
+  4.0.10 or later.
+
+* TIFF: Support WebP compression in TIFF.  This requires libtiff
+  4.0.10 or later.
+
+API Updates:
+
+* MagickMonitor() is marked as deprecated.  Code should not be using
+  this function any more.
+
+Feature improvements:
+
+* The progress monitor callbacks (registered using MagickMonitor() or
+  MagickMonitorFormatted()) are serialized via a common semaphore
+  rather than via critical sections in OpenMP loops.  OpenMP loops are
+  updated to use OpenMP 'atomic' and 'flush' to update shared loop
+  variables rather than using a OpenMP 'critical' construct, reducing
+  contention.  Performance on some targets is observed to have been
+  improved by this change.
+
+Windows Delegate Updates/Additions:
+
+* None
+
+Build Changes:
+
+* There was already a 'compare' command installed with the
+  '--enable-magick-compat' configure option was used but it did not
+  function.  Now it functions.  There was no `compare` command in
+  ImageMagick 5.5.2 and this compare command is only roughly similar
+  to a `compare` command in some subsequent ImageMagick release.
+
+* Removed Remove Ghostscript library support (--with-gslib) from
+  configure script.  The 'HasGS' pre-processor defines which were
+  enabled by this remain in the source code so it is still possible to
+  use this library if absolutely necessary (e.g. CPPFLAGS=-DHasGS
+  LIBS=-lgs).
+
+* No longer explicitly link with the OpenMP library when it will be
+  supplied already due to CFLAGS.
+
+Behavior Changes:
+
+* JPEG: Libjpeg-turbo is allowed 1/5th the memory resource limit
+  provided for Graphicsmagick via the cinfo->mem->max_memory_to_use
+  option, which is part of the IJG JPEG API/ABI, but usually not
+  supported there.  This feature works for libjpeg-turbo 1.5.2 and
+  later.  Limiting the memory usage is useful since libjpeg-turbo may
+  otherwise consume arbitrary amounts of memory even before
+  Graphicsmagick is informed of the image dimensions.
+
+* JPEG: The maximum number of JPEG progressive scans is limited to 50.
+  Otherwise some technically valid files could be read for almost
+  forever.
+
+
+1.3.30 (June 23, 2018)
+=========================
+
+Special Issues:
+
+* None
+
+Security Fixes:
+
+* GraphicsMagick is now participating in Google's oss-fuzz project due
+  to the contributions and assistance of Alex Gaynor. Since February 4
+  2018, 238 issues have been opened by oss-fuzz and 230 of those
+  issues have been resolved.  The issues list is available at
+  https://bugs.chromium.org/p/oss-fuzz/issues/list under search term
+  "graphicsmagick".  Issues are available for anyone to view and
+  duplicate if they have been in "Verified" status for 30 days, or if
+  they have been in "New" status for 90 days.  There are too many
+  fixes to list here.  Please consult the GraphicsMagick ChangeLog
+  file, Mercurial repository commit log, and the oss-fuzz issues list
+  for details.
+
+* SVG/Rendering: Fix heap write overflow of PrimitiveInfo and
+  PointInfo arrays.  This is another manefestation of CVE-2016-2317,
+  which should finally be fixed correctly due to active
+  detection/correction of pending overflow rather than using
+  estimation.
+
+Bug fixes:
+
+* Many oss-fuzz fixes are bug fixes.
+
+* Drawing/Rendering: Many more fixes by Gregory J Wolfe (see the ChangeLog).
+
+* MIFF: Detect end of file while reading image directory.
+
+* SVG: Many more fixes by Gregory J Wolfe (see the ChangeLog).
+
+* The AlphaCompositePixel macro was producing wrong results when the
+  output alpha value was not 100% opaque. This is a regression
+  introduced in 1.3.29.
+
+* TILE: Fix problem with tiling JPEG images because the size request
+  used by the TILE algorithm was also causing re-scaling in the JPEG
+  reader.  The problem is solved by stripping the size request before
+  reading the image.
+
+New Features:
+
+* None
+
+API Updates:
+
+* The size of PrimitiveInfo (believed to be an internal/private
+  structure but in a header which is installed, has been increased to
+  store a 'flags' argument. This is intended to be an internal
+  interface but but may be detected as an ABI change.
+
+Feature improvements:
+
+* None
+
+Windows Delegate Updates/Additions:
+
+* None
+
+Build Changes:
+
+* The oss-fuzz build script (fuzzing/oss-fuzz-build.sh) now includes
+  many delegate libraries such as zlib, libpng, libtiff, libjpeg, and
+  freetype, resulting in more comprehensive testing.  The Q16 build is
+  now being tested rather than the 'configure' default of Q8.
+
+Behavior Changes:
+
+* JPEG: The JPEG reader now allows 3 warnings of any particular type
+  before giving up on reading and throwing an exception.  This choice
+  was made after observing files which produce hundreds of warnings
+  and consume massive amounts of memory before reading the image data
+  has even started.  It is currently unknown how many files which were
+  previously accepted will be rejected by default.  The number of
+  allowed warnings may be adjusted using '-define
+  jpeg:max-warnings=<value>'.  The default limit will be adjusted
+  based on reported user experiences and may be adjusted prior to
+  compilation via the MaxWarningCount definition in coders/jpeg.c.
+
+
+1.3.29 (April 29, 2018)
+=========================
+
+Special Issues:
+
+* None
+
+Security Fixes:
+
+* GraphicsMagick is now participating in Google's oss-fuzz project due
+  to the contributions and assistance of Alex Gaynor. Since February 4
+  2018, 180 issues have been opened by oss-fuzz and 173 of those
+  issues have been resolved.  The issues list is available at
+  https://bugs.chromium.org/p/oss-fuzz/issues/list under search term
+  "graphicsmagick".  Issues are available for anyone to view and
+  duplicate if they have been in "Verified" status for 30 days, or if
+  they have been in "New" status for 90 days.  There are too many
+  fixes to list here.  Please consult the GraphicsMagick ChangeLog
+  file, Mercurial repository commit log, and the oss-fuzz issues list
+  for details.
+
+* JNG: Require that the embedded JPEG image have the same dimensions
+  as the JNG image as provided by JHDR. Avoids a heap write overflow.
+
+* MNG: Arbitrarily limit the number of loops which may be requested by
+  the MNG LOOP chunk to 512 loops, and provide the '-define
+  mng:maximum-loops=value' option in case the user wants to change the
+  limit.  This fixes a denial of service caused by large LOOP
+  specifications.
+
+Bug fixes:
+
+* Many oss-fuzz fixes are bug fixes.
+
+* DICOM: Pre/post rescale functions are temporarily disabled (until
+  the implementation is fixed).
+
+* JPEG: Fix regression in last release in which reading some JPEG
+  files produces the error "Improper call to JPEG library in state
+  201".
+
+* ICON: Some DIB-based Windows ICON files were reported as corrupt to
+  an unexpectedly missing opacity mask image.
+
+* In-memory Blob I/O: Don't implicitly increase the allocation size
+  due to seek offsets.
+
+* MNG: Detect and handle failure to allocate global PLTE. Fix divide
+  by zero.
+
+* DrawGetStrokeDashArray(): Check for failure to allocate memory.
+
+* BlobToImage(): Now produces useful exception reports to cover the
+  cases where 'magick' was not set and the file format could not be
+  deduced from its header.
+
+New Features:
+
+* None
+
+API Updates:
+
+* Wand API: Added MagickIsPaletteImage(), MagickIsOpaqueImage(),
+  MagickIsMonochromeImage(), MagickIsGrayImage(), MagickHasColormap()
+  based on contributions by Troy Patteson.
+
+* New structure ImageExtra added and Image 'clip_mask' member is
+  replaced by 'extra' which points to private ImageExtra allocation.
+  The ImageGetClipMask() function now provides access to the clip mask
+  image.
+
+* New structure DrawInfoExtra and DrawInfo 'clip_path' is replaced by
+  'extra' which points to private DrawInfoExtra allocation.  The
+  DrawInfoGetClipPath() function now provides access to the clip path.
+
+* New core library functions: GetImageCompositeMask(),
+  CompositeMaskImage(), CompositePathImage(), SetImageCompositeMask(),
+  ImageGetClipMask(), ImageGetCompositeMask(), DrawInfoGetClipPath(),
+  DrawInfoGetCompositePath()
+
+* Deprecated core library functions: RegisterStaticModules(),
+  UnregisterStaticModules().
+
+Feature improvements:
+
+* Static modules (in static library or shared library without
+  dynamically loadable modules) are now lazy-loaded using the same
+  external interface as the lazy-loader for dynamic modules.  This
+  results in more similarity between the builds and reduces the fixed
+  initialization overhead by only initializing the modules which are
+  used.
+
+* SVG: The quality of SVG support has been significantly improved due
+  to the efforts of Greg Wolfe.
+
+* FreeType/TTF rendering: Rendering fixes for opacity.
+
+Windows Delegate Updates/Additions:
+
+* None
+
+Build Changes:
+
+* None
+
+Behavior Changes:
+
+* None
+
+
+1.3.28 (January 20, 2018)
+=========================
+
+Special Issues:
+
+* None
+
+Security Fixes:
+
+* BMP: Fix non-terminal loop due to unexpected bit-field mask value
+  (DOS opportunity).
+
+* PALM: Fix heap buffer underflow in builds with QuantumDepth=8.
+
+* SetNexus() Fix heap overwrite under certain conditions due to using
+  a wrong destination buffer.  This issue impacts all 1.3.X releases.
+
+* TIFF: Fix heap buffer read overflow in LocaleNCompare() when parsing
+  NEWS profile.
+
+Bug fixes:
+
+* DescribeImage(): Eliminate possible use of null pointer.
+
+* GIF: Fix memory leak of global colormap in error path.
+
+* GZ: Writing to gzip files with the extension ".gz" was not working
+  with Zlib 1.2.8.
+
+* JNG: Fix buffer read overflow (a tiny fixed overflow of just one byte).
+
+* JPEG: Promoting certain libjpeg warnings to errors caused much more
+  problems than expected.  The promotion of warnings to errors is
+  removed.  Claimed pixel dimensions are validated by file size before
+  allocating memory for the pixels.
+
+* IntegralRotateImage(): Assure that reported error in rotate by 270
+  case does immediately terminate processing.
+
+* MNG: Fix possible null pointer reference related to DEFI chunk
+  parsing.  Fix minor heap read overflow (constrained to just one
+  byte) due to an ordering issue in a limit check.  Fix memory leaks
+  in error path.
+
+* WebP: Fix stack buffer overflow in WriteWEBPImage() which occurs
+  with libwebp 0.5.0 or newer due to a structure type change in the
+  structure passed to the progress monitor callback.
+
+* WPG: Memory leaks fixed.
+
+New Features:
+
+* None
+
+API Updates:
+
+* InterpolateViewColor(): This function now returns MagickPassFail (an
+  unsigned int) rather than void so that errors can be efficiently
+  reported.
+
+* The magick/pixel_cache.h header is updated to add deprecation
+  attributes such that code using GetPixels(), GetIndexes(), and
+  GetOnePixel() will produce deprecation warnings for compilers which
+  support them.  These functions will not be removed in the 1.3.X
+  release series and when they are removed, pre-processor macros will
+  be added so a replacement function is used instead.  There is a
+  long-term objective to eliminate functionally-redundant pixel cache
+  functions to only the ones with the best properties since this
+  reduces maintenance and may reduce the depth of the call stack
+  (improving performance).
+
+Feature improvements:
+
+* None
+
+Windows Delegate Updates/Additions:
+
+* None
+
+Build Changes:
+
+* PerlMagick: Sanitize PACKAGE_VERSION so that Perl is not confused by
+  any trailing alpha character.
+
+* Improved symbol renaming due to adding --enable-symbol-prefix.  Some
+  symbols (for static const strings) were not being included in the
+  renaming.
+
+
+Behavior Changes:
+
+* None
+
+1.3.27 (December 9, 2017)
+=========================
+
+Special Issues:
+
+* None
+
+Security Fixes:
+
+* CMYK: Fix heap overwrites in raw CMYK writer.  Fix heap overwrites
+  in raw CMYK reader (noticed when doing montage).
+
+* GIF: Assure that global colormap is initialized.
+
+* DescribeImage(): Fix possible heap write overflow when describing
+  visual image directory. Fix possible heap read overflow while
+  accessing heap data, and possible information disclosure while
+  describing the IPTC profile.
+
+* DICOM: Fix huge memory allocation based on bogus length value (DOS
+  opportunity).
+
+* DrawDashPolygon(): Fix heap out of bounds read in render code.
+
+* GRAY: Fix heap overwrites in raw GRAY reader (noticed when doing
+  montage).
+
+* JNG: Fix heap overruns.  Fix assertions.
+
+* JNG: Prevent a crash due to zero-length color_image while reading a
+  JNG image. (CVE-2017-11102).  Reject JNG files with unreasonable
+  dimensions given the file size (avoid DOS).
+
+* JNX: Fix DOS due to excessive memory allocations with corrupt file.
+
+* JPEG: Do not allocate backing image pixels until a scanline has been
+  successfully read.  Avoids DOS opportunity with suitably
+  manufactured file.
+
+* MAP: Fix null pointer dereference or segmentation violation.
+
+* MAT: Fix heap write overflow.
+
+* MNG: Reject over-large (65k by 65k) image.  Fix heap overwrites.
+
+* PAM: Fix heap buffer overflow in PAM writer for 1 bit/sample + alpha.
+
+* PICT: Fix excessive memory allocation due to malformed image file.
+
+* PNG: Fix heap buffer overflow in PNG writer when promoting from
+  indexed PNG to RGBA.
+
+* PNM: Fix DOS due to excessive memory allocations with corrupt file.
+
+* RGB: Fix heap overwrite in raw RGB writer. Fix heap overwrites in
+  raw RGB reader (noticed when doing montage).
+
+* RLE: Fix DOS opportunities due to false claims in image header.  Fix
+  heap out of bounds read.
+
+* SFW: Avoid possible heap write overflow.
+
+* SUN: Fix heap read overflow.  Fix DOS due to excessive memory
+  allocations with corrupt file.
+
+* SVG: Fix heap write overflow.
+
+* TIFF: Use heuristics to avoid DOS (excessive memory use) due to
+  false claims by input file.  It is possible that this may reject
+  some valid files.  Fix possible small heap overwrite beyond the
+  allocated scanline buffer due to the NumberOfObjectsInArray() macro
+  rounding up rather than down.
+
+* UIL: Fix heap overwrite in writer.
+
+* WPG: Fix DOS issues (memory, disk space, CPU time) due to
+  insufficient validations.  Fix heap overwrites.
+
+* XBM: Fix DOS issue where code remains stuck in loop and does not
+  return.
+
+* XV 332 (PNM): Fix null pointer dereference due to malformed file.
+
+* TracePSClippingPath()/TraceSVGClippingPath(): Fix heap out of bounds
+  read.
+
+* Validate path entries in the MAGICK_CODER_MODULE_PATH and
+  MAGICK_FILTER_MODULE_PATH environment variables and convert all
+  paths to real paths if possible. This avoids possible use of
+  relative paths to load modules (a possible security issue), or the
+  possibility of adding a directory which was in the path, but
+  missing, and may improve efficiency by removing non-existent paths.
+
+Bug fixes:
+
+* AVS: Memory leaks eliminated.
+
+* CINEON: Fix possible use of NULL pointer.
+
+* CMYK: Memory leaks eliminated.
+
+* CUT: Memory leaks eliminated.  Fix possible use of NULL pointer.
+
+* DCM: Fix possible use of NULL pointer.
+
+* DrawImage(): Avoid "negative" strncpy().  This seems to be benign
+  with glibc but perhaps not with other implementations.
+
+* DPX: Memory leaks eliminated.
+
+* EMF: Fix possible use of NULL pointer.
+
+* FindMagickModule(): Fix possible use of NULL pointer.
+
+* FITS: Fix memory leak.
+
+* GIF: Fix memory leak.
+
+* HDF: Memory leaks eliminated.
+
+* HISTOGRAM: Fix memory leak.
+
+* JNG: Memory leaks eliminated. Memory use after free and double-free
+  issues eliminated.  Error reporting fixes.
+
+* Magick::Options::strokeDashArray(): Fix possible use of NULL pointer.
+
+* MagickXFileBrowserWidget(): Fix possible use of NULL pointer.
+
+* MAT: Memory leaks eliminated.
+
+* MagickMapCloneMap(): Fix possible assertion failure.
+
+* MNG: Memory use after free issues eliminated.  Fix possible use of
+  NULL pointer.  Fix memory leaks.
+
+* MontageImageCommand(): Fix memory leaks.
+
+* MPC: Fix memory leak in writer.
+
+* MPEG: Fix memory leaks in writer.
+
+* MTV: Memory leaks eliminated.
+
+* NTRegistryKeyLookup(): Fix possible use of NULL pointer.
+
+* NTGetTypeList(): Fix possible use of NULL pointer.
+
+* PCD: Memory leaks eliminated.
+
+* PCL: Fix null pointer dereference in PCL writer.
+
+* PCX: Memory leaks eliminated.
+
+* PALM: Fix possible use of NULL pointer. Fix memory leak.
+
+* PICT: Memory leaks eliminated.
+
+* PNG: Fix small (one-off) heap read overflow.
+
+* PNM: Fix memory leaks.
+
+* PS: Fix use of null pointer in error path.
+
+* PWP: Fix possible use of null pointer.
+
+* ReplaceImageColormap(): Throw an exception rather than assertion if
+  the input image is not colormapped.
+
+* RGB: Fix memory leak.
+
+* SegmentImage(): Fix possible use of NULL pointer.
+
+* SetImageProfile(): Fix possible assertion failure.
+
+* SGI: Check for EOF while reading SGI file header.
+
+* SUN: Fix memory leak.
+
+* TIFF: Fix possible use of NULL pointer.  Fix memory leaks in writer.
+
+* TIM: Fix memory leak.
+
+* TOPOL: Fix possible use of NULL pointer.  Fix memory leaks.
+
+* VIFF: Fix memory leak.
+
+* WEBP: Detect partial write to output file.
+
+* WPG: Fix possible use of null pointer. Fix excessive use of disk
+  resources due to insufficient validations.
+
+* WriteImage(): Restore use of GetBlobStatus() to test if an I/O error
+  was encountered while writing output file. This assures that I/O
+  failure in writers which do not themselves verify writes is assured
+  to be reported.
+
+* WMF: Memory use after free issues eliminated.
+
+* YUV: Fix memory leaks.
+
+
+New Features:
+
+* PNG: Implemented eXIf chunk support.
+
+* WEBP: Add support for EXIF and ICC metadata provided that at least
+  libwebp 0.5.0 is used.
+
+* Magick++ Image autoOrient(): New Image method to auto-orient an
+  image so it looks right-side up by default.
+
+Feature improvements:
+
+* None
+
+Windows Delegate Updates/Additions:
+
+* Libtiff is updated to libtiff 4.0.9.
+
+Build Changes:
+
+* JPEG/PNG: The SETJMP_IS_THREAD_SAFE definition is used to determine
+  if setjmp/longjmp are thread safe.  If these interfaces are thread
+  safe, then concurrent reads/writes are possible.  This definition is
+  false for Solaris but true for Linux.  JPEG and PNG will be fully
+  concurrent if this definition is enabled.
+
+Behavior Changes:
+
+* PALM: PALM writer is disabled.
+
+* ThrowLoggedException(): Capture the first exception at
+  ErrorException level or greater, or only capture exception if it is
+  more severe than an already reported exception.
+
+* DestroyJNG(): This internal function is now declared static and is
+  removed from shared library or DLL namespace.
+
 
 1.3.26 (July 4, 2017)
 =====================
@@ -111,9 +745,9 @@ New Features:
 * Magick++: Orientation method now updates orientation in EXIF
   profile, if it exists.
 
-* Magick++: Added Image attribute method which accepts a 'char *'
-  argument, and will remove the attribute if the value argument is
-  NULL.
+* Magick++: Added Image attribute method which accepts a character
+  pointer argument, and will remove the attribute if the value
+  argument is NULL.
 
 * -orient: The -orient command line option now also updates the
   orientation in the EXIF profile, if it exists.
@@ -3511,4 +4145,4 @@ The objectives of GraphicsMagick are to:
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index dc171d7..05e54af 100644 (file)
@@ -40,7 +40,7 @@ require AutoLoader;
     );
 
 # This version identifier must match the package version.
-$VERSION = '1.3.26';
+($VERSION) = '1.3.31' =~ /^([\d.]+)/g;
 
 sub AUTOLOAD {
     # This AUTOLOAD is used to 'autoload' constants from the constant()
@@ -51,14 +51,14 @@ sub AUTOLOAD {
     ($constname = $AUTOLOAD) =~ s/.*:://;
     my $val = constant($constname, @_ ? $_[0] : 0);
     if ($! != 0) {
-       if ($! =~ /Invalid/) {
-           $AutoLoader::AUTOLOAD = $AUTOLOAD;
-           goto &AutoLoader::AUTOLOAD;
-       }
-       else {
-           my($pack,$file,$line) = caller;
-           die "Your vendor has not defined PerlMagick macro $pack\:\:$constname, used at $file line $line.\n";
-       }
+        if ($! =~ /Invalid/) {
+            $AutoLoader::AUTOLOAD = $AUTOLOAD;
+            goto &AutoLoader::AUTOLOAD;
+        }
+        else {
+            my($pack,$file,$line) = caller;
+            die "Your vendor has not defined PerlMagick macro $pack\:\:$constname, used at $file line $line.\n";
+        }
     }
     eval "sub $AUTOLOAD { $val }";
     goto &$AUTOLOAD;
@@ -116,11 +116,11 @@ It was originally developed to be used by CGI scripts for Web pages.
 
 A Web page has been set up for this extension. See:
 
-       http://www.GraphicsMagick.org/www/perl.html
+  http://www.GraphicsMagick.org/www/perl.html
 
 =head1 AUTHOR
 
-Kyle Shorter   magick@wizards.dupont.com
+Kyle Shorter    magick@wizards.dupont.com
 
 =head1 BUGS
 
index b572d6b..92b8e03 100644 (file)
@@ -40,7 +40,7 @@ require AutoLoader;
     );
 
 # This version identifier must match the package version.
-$VERSION = '@PACKAGE_VERSION@';
+($VERSION) = '@PACKAGE_VERSION@' =~ /^([\d.]+)/g;
 
 sub AUTOLOAD {
     # This AUTOLOAD is used to 'autoload' constants from the constant()
@@ -51,14 +51,14 @@ sub AUTOLOAD {
     ($constname = $AUTOLOAD) =~ s/.*:://;
     my $val = constant($constname, @_ ? $_[0] : 0);
     if ($! != 0) {
-       if ($! =~ /Invalid/) {
-           $AutoLoader::AUTOLOAD = $AUTOLOAD;
-           goto &AutoLoader::AUTOLOAD;
-       }
-       else {
-           my($pack,$file,$line) = caller;
-           die "Your vendor has not defined PerlMagick macro $pack\:\:$constname, used at $file line $line.\n";
-       }
+        if ($! =~ /Invalid/) {
+            $AutoLoader::AUTOLOAD = $AUTOLOAD;
+            goto &AutoLoader::AUTOLOAD;
+        }
+        else {
+            my($pack,$file,$line) = caller;
+            die "Your vendor has not defined PerlMagick macro $pack\:\:$constname, used at $file line $line.\n";
+        }
     }
     eval "sub $AUTOLOAD { $val }";
     goto &$AUTOLOAD;
@@ -116,11 +116,11 @@ It was originally developed to be used by CGI scripts for Web pages.
 
 A Web page has been set up for this extension. See:
 
-       http://www.GraphicsMagick.org/www/perl.html
+  http://www.GraphicsMagick.org/www/perl.html
 
 =head1 AUTHOR
 
-Kyle Shorter   magick@wizards.dupont.com
+Kyle Shorter    magick@wizards.dupont.com
 
 =head1 BUGS
 
index 2e366cd..becbd50 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2014 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright (C) 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -86,6 +86,7 @@ extern "C" {
 #define DoubleReference  (char **) 2
 #define EndOf(array)  (&array[NumberOf(array)])
 #define False  0
+#define NullReference  (char **) 0
 #define ImageReference  (char **) 3
 #define IntegerReference  (char **) 1
 #define MaxArguments  28
@@ -208,7 +209,9 @@ static char
   *CompressionTypes[] =
   {
     "Undefined", "None", "BZip", "Fax", "Group4", "JPEG", "LosslessJPEG",
-    "LZW", "RLE", "Zip", "LZMA", "JPEG2000", "JBIG1", "JBIG2", (char *) NULL
+    "LZW", "RLE", "Zip", "LZMA", "JPEG2000", "JBIG1", "JBIG2", "ZSTD",
+    "WebP",
+    (char *) NULL
   },
   *DisposeTypes[] =
   {
@@ -247,7 +250,7 @@ static char
   *LogEventTypes[] =
   {
     "No", "Configure", "Annotate", "Render", "Transform", "Locale",
-    "Coder", "X11", "Cache", "Blob", "Deprecate", "User", "Resource", 
+    "Coder", "X11", "Cache", "Blob", "Deprecate", "User", "Resource",
     "TemporaryFile", "Exception", "All", (char *) NULL
   },
   *MethodTypes[] =
@@ -323,21 +326,21 @@ static struct
     { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
       {"height", IntegerReference}, {"x", IntegerReference},
       {"y", IntegerReference} } },
-    { "Despeckle", },
+    { "Despeckle", { { NULL, NullReference } } },
     { "Edge", { {"radius", DoubleReference} } },
     { "Emboss", { {"geometry", StringReference}, {"radius", DoubleReference},
       {"sigma", DoubleReference} } },
-    { "Enhance", },
-    { "Flip", },
-    { "Flop", },
+    { "Enhance", { { NULL, NullReference } } },
+    { "Flip", { { NULL, NullReference } } },
+    { "Flop", { { NULL, NullReference } } },
     { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
       {"height", IntegerReference}, {"inner", IntegerReference},
       {"outer", IntegerReference}, {"fill", StringReference},
       {"color", StringReference} } },
     { "Implode", { {"amount", DoubleReference} } },
-    { "Magnify", },
+    { "Magnify", { { NULL, NullReference } } },
     { "MedianFilter", { {"radius", DoubleReference} } },
-    { "Minify", },
+    { "Minify", { { NULL, NullReference } } },
     { "OilPaint", { {"radius", DoubleReference} } },
     { "ReduceNoise", { {"radius", DoubleReference} } },
     { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
@@ -398,7 +401,7 @@ static struct
       {"pointsize", DoubleReference}, {"antialias", BooleanTypes},
       {"density", StringReference}, {"linewidth", DoubleReference},
       {"affine", ArrayReference} } },
-    { "Equalize", },
+    { "Equalize", { { NULL, NullReference } } },
     { "Gamma", { {"gamma", StringReference}, {"red", DoubleReference},
       {"green", DoubleReference}, {"blue", DoubleReference} } },
     { "Map", { {"image", ImageReference}, {"dither", BooleanTypes} } },
@@ -409,8 +412,8 @@ static struct
     { "Modulate", { {"factor", StringReference}, {"bright", DoubleReference},
       {"saturation", DoubleReference}, {"hue", DoubleReference} } },
     { "Negate", { {"gray", BooleanTypes} } },
-    { "Normalize", },
-    { "NumberColors", },
+    { "Normalize", { { NULL, NullReference } } },
+    { "NumberColors", { { NULL, NullReference } } },
     { "Opaque", { {"color", StringReference}, {"fill", StringReference},
       {"fuzz", DoubleReference} } },
     { "Quantize", { {"colors", IntegerReference}, {"tree", IntegerReference},
@@ -421,9 +424,9 @@ static struct
     { "Segment", { {"geometry", StringReference}, {"cluster", DoubleReference},
       {"smooth", DoubleReference}, {"colorspace", ColorspaceTypes},
       {"verbose", BooleanTypes} } },
-    { "Signature", },
+    { "Signature", { { NULL, NullReference } } },
     { "Solarize", { {"threshold", DoubleReference} } },
-    { "Sync", },
+    { "Sync", { { NULL, NullReference } } },
     { "Texture", { {"texture", ImageReference} } },
     { "Sans", { {"geometry", StringReference}, {"crop", StringReference},
       {"filter", FilterTypess} } },
@@ -436,10 +439,10 @@ static struct
     { "Wave", { {"geometry", StringReference}, {"amplitude", DoubleReference},
       {"wavelength", DoubleReference} } },
     { "Channel", { {"channel", ChannelTypes} } },
-    { "Condense", },
+    { "Condense", { { NULL, NullReference } } },
     { "Stereo", { {"image", ImageReference} } },
     { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
-    { "Deconstruct", },
+    { "Deconstruct", { { NULL, NullReference } } },
     { "GaussianBlur", { {"geometry", StringReference},
       {"radius", DoubleReference}, {"sigma", DoubleReference} } },
     { "Convolve", { {"coefficients", ArrayReference} } },
@@ -450,12 +453,12 @@ static struct
     { "MotionBlur", { {"geometry", StringReference},
       {"radius", DoubleReference}, {"sigma", DoubleReference},
       {"angle", DoubleReference} } },
-    { "OrderedDither", },
+    { "OrderedDither", { { NULL, NullReference } } },
     { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
       {"height", IntegerReference} } },
     { "Level", { {"level", StringReference}, {"black-point", DoubleReference},
       {"mid-point", DoubleReference}, {"white-point", DoubleReference} } },
-    { "Clip", },
+    { "Clip", { { NULL, NullReference } } },
     { "AffineTransform", { {"affine", ArrayReference},
       {"translate", StringReference}, {"scale", StringReference},
       {"rotate", DoubleReference}, {"skewX", DoubleReference},
@@ -828,7 +831,7 @@ static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,int *current,
       /*
         Blessed scalar, one image.
       */
-      image=(Image *) SvIV(reference);
+      image=(Image *) (magick_uintptr_t)SvIV(reference);
       if (!image)
         return(NULL);
       image->previous=(Image *) NULL;
@@ -848,8 +851,11 @@ static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,int *current,
                     MagickAllocateMemory(SV **,*last*sizeof(*reference_vector));
                 }
             }
-        (*reference_vector)[*current]=reference;
-        (*reference_vector)[++(*current)]=NULL;
+          if (*reference_vector)
+            {
+              (*reference_vector)[*current]=reference;
+              (*reference_vector)[++(*current)]=NULL;
+            }
       }
       return(image);
     }
@@ -907,10 +913,10 @@ static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
     }
   if (SvREFCNT(sv) == 0)
     (void) SvREFCNT_inc(sv);
-  if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
+  if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) (magick_uintptr_t)SvIV(sv)))
     return(clone_info);
   clone_info=ClonePackageInfo(package_info);
-  sv_setiv(sv,(IV) clone_info);
+  sv_setiv(sv,(IV) (magick_uintptr_t)clone_info);
   return(clone_info);
 }
 \f
@@ -1008,7 +1014,7 @@ static void MagickErrorHandler(const ExceptionType severity,const char *reason,
     (reason ? GetLocaleExceptionMessage(severity,reason) : "ERROR"),
     description ? " (" : "",
     description ? GetLocaleExceptionMessage(severity,description) : "",
-               description ? ")" : "",errno ? " [" : "",errno ? strerror(errno) : "",
+                description ? ")" : "",errno ? " [" : "",errno ? strerror(errno) : "",
     errno? "]" : "");
   if ((MY_CXT.error_list == NULL) || (MY_CXT.error_jump == NULL))
     {
@@ -1527,7 +1533,7 @@ static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
               (long) (y % image->rows),1,1);
             if (p == (PixelPacket *) NULL)
               break;
-            indexes=GetIndexes(image);
+            indexes=AccessMutableIndexes(image);
             (void) sscanf(SvPV(sval,na),"%ld",&index);
             if ((index >= 0) && (index < (long) image->colors))
               *indexes=(IndexPacket) index;
@@ -2275,7 +2281,7 @@ Append(ref,...)
     DestroyExceptionInfo(&exception);
     for ( ; image; image=image->next)
     {
-      sv=newSViv((IV) image);
+      sv=newSViv((IV) (magick_uintptr_t)image);
       rv=newRV(sv);
       av_push(av,sv_bless(rv,hv));
       SvREFCNT_dec(sv);
@@ -2377,7 +2383,7 @@ Average(ref)
     av=newAV();
     ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
     SvREFCNT_dec(av);
-    sv=newSViv((IV) image);
+    sv=newSViv((IV) (magick_uintptr_t)image);
     rv=newRV(sv);
     av_push(av,sv_bless(rv,hv));
     SvREFCNT_dec(sv);
@@ -2512,7 +2518,7 @@ BlobToImage(ref,...)
         CatchException(&exception);
       for ( ; image; image=image->next)
       {
-        sv=newSViv((IV) image);
+        sv=newSViv((IV) (magick_uintptr_t)image);
         rv=newRV(sv);
         av_push(av,sv_bless(rv,hv));
         SvREFCNT_dec(sv);
@@ -2621,7 +2627,7 @@ Coalesce(ref)
     DestroyExceptionInfo(&exception);
     for ( ; image; image=image->next)
     {
-      sv=newSViv((IV) image);
+      sv=newSViv((IV) (magick_uintptr_t)image);
       rv=newRV(sv);
       av_push(av,sv_bless(rv,hv));
       SvREFCNT_dec(sv);
@@ -2725,7 +2731,7 @@ Copy(ref)
       clone=CloneImage(image,0,0,True,&exception);
       if (exception.severity != UndefinedException)
         CatchException(&exception);
-      sv=newSViv((IV) clone);
+      sv=newSViv((IV) (magick_uintptr_t)clone);
       rv=newRV(sv);
       av_push(av,sv_bless(rv,hv));
       SvREFCNT_dec(sv);
@@ -2790,7 +2796,7 @@ DESTROY(ref)
         if (sv)
           {
             if ((SvREFCNT(sv) == 1) && SvIOK(sv) &&
-                (info=(struct PackageInfo *) SvIV(sv)))
+                (info=(struct PackageInfo *) (magick_uintptr_t)SvIV(sv)))
               {
                 DestroyPackageInfo(info);
                 sv_setiv(sv,0);
@@ -2806,7 +2812,7 @@ DESTROY(ref)
         /*
           Blessed scalar = (Image *) SvIV(reference)
         */
-        image=(Image *) SvIV(reference);
+        image=(Image *) (magick_uintptr_t)SvIV(reference);
         if (image)
           {
             if (image->previous && image->previous->next == image)
@@ -2985,7 +2991,7 @@ Flatten(ref)
     av=newAV();
     ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
     SvREFCNT_dec(av);
-    sv=newSViv((IV) image);
+    sv=newSViv((IV) (magick_uintptr_t)image);
     rv=newRV(sv);
     av_push(av,sv_bless(rv,hv));
     SvREFCNT_dec(sv);
@@ -3206,9 +3212,9 @@ Get(ref,...)
                   SV
                     *sv;
 
-                  if (image->clip_mask == (Image *) NULL)
+                  if (GetImageClipMask(image,&image->exception) == (Image *) NULL)
                     ClipImage(image);
-                  sv=newSViv((IV) image->clip_mask);
+                  sv=newSViv((IV) (magick_uintptr_t)GetImageClipMask(image,&image->exception));
                   s=sv_bless(newRV(sv),SvSTASH(reference));
                 }
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
@@ -3396,8 +3402,7 @@ Get(ref,...)
               if (image)
                 s=newSVpv(image->filename,0);
               else
-                if (info && info->image_info->filename &&
-                    *info->image_info->filename)
+                if (info && info->image_info->filename[0])
                   s=newSVpv(info->image_info->filename,0);
               PUSHs(s ? sv_2mortal(s) : &sv_undef);
               continue;
@@ -4408,7 +4413,7 @@ Mogrify(ref,...)
         attribute=(char *) SvPV(ST(1),na);
         if (ix)
           {
-            flags=GetImageGeometry(image,attribute,False,&region_info);
+            /*flags=*/GetImageGeometry(image,attribute,False,&region_info);
             attribute=(char *) SvPV(ST(2),na);
             base++;
           }
@@ -4584,7 +4589,7 @@ Mogrify(ref,...)
         case 5:  /* Border */
         {
           if (attribute_flag[0])
-            flags=GetImageGeometry(image,argument_list[0].string_reference,
+            /*flags=*/GetImageGeometry(image,argument_list[0].string_reference,
               False,&geometry);
           if (attribute_flag[1])
             geometry.width=argument_list[1].int_reference;
@@ -4622,7 +4627,7 @@ Mogrify(ref,...)
         case 7:  /* Chop */
         {
           if (attribute_flag[0])
-            flags=GetImageGeometry(image,argument_list[0].string_reference,
+            /*flags=*/GetImageGeometry(image,argument_list[0].string_reference,
               False,&geometry);
           if (attribute_flag[1])
             geometry.width=argument_list[1].int_reference;
@@ -4638,7 +4643,7 @@ Mogrify(ref,...)
         case 8:  /* Crop */
         {
           if (attribute_flag[0])
-            flags=GetImageGeometry(image,argument_list[0].string_reference,
+            /*flags=*/GetImageGeometry(image,argument_list[0].string_reference,
               False,&geometry);
           if (attribute_flag[1])
             geometry.width=argument_list[1].int_reference;
@@ -4704,7 +4709,7 @@ Mogrify(ref,...)
         {
           if (attribute_flag[0])
             {
-              flags=GetImageGeometry(image,argument_list[0].string_reference,
+              /*flags=*/GetImageGeometry(image,argument_list[0].string_reference,
                 False,&geometry);
               frame_info.width=geometry.width;
               frame_info.height=geometry.height;
@@ -4779,7 +4784,7 @@ Mogrify(ref,...)
         case 22:  /* Roll */
         {
           if (attribute_flag[0])
-            flags=GetImageGeometry(image,argument_list[0].string_reference,
+            /*flags=*/GetImageGeometry(image,argument_list[0].string_reference,
               False,&geometry);
           if (attribute_flag[1])
             geometry.x=argument_list[1].int_reference;
@@ -4801,7 +4806,7 @@ Mogrify(ref,...)
         case 24:  /* Sample */
         {
           if (attribute_flag[0])
-            flags=GetImageGeometry(image,argument_list[0].string_reference,
+            /*flags=*/GetImageGeometry(image,argument_list[0].string_reference,
               True,&geometry);
           if (attribute_flag[1])
             geometry.width=argument_list[1].int_reference;
@@ -4813,7 +4818,7 @@ Mogrify(ref,...)
         case 25:  /* Scale */
         {
           if (attribute_flag[0])
-            flags=GetImageGeometry(image,argument_list[0].string_reference,
+            /*flags=*/GetImageGeometry(image,argument_list[0].string_reference,
               True,&geometry);
           if (attribute_flag[1])
             geometry.width=argument_list[1].int_reference;
@@ -4898,7 +4903,7 @@ Mogrify(ref,...)
         case 32:  /* Zoom */
         {
           if (attribute_flag[0])
-            flags=GetImageGeometry(image,argument_list[0].string_reference,
+            /*flags=*/GetImageGeometry(image,argument_list[0].string_reference,
               True,&geometry);
           if (attribute_flag[1])
             geometry.width=argument_list[1].int_reference;
@@ -5079,7 +5084,7 @@ Mogrify(ref,...)
           draw_info=CloneDrawInfo(info ? info->image_info :
             (ImageInfo *) NULL,info ? info->draw_info : (DrawInfo *) NULL);
           if (attribute_flag[0])
-            flags=GetImageGeometry(image,argument_list[0].string_reference,
+            /*flags=*/GetImageGeometry(image,argument_list[0].string_reference,
               False,&geometry);
           if (attribute_flag[1])
             geometry.x=argument_list[1].int_reference;
@@ -5136,7 +5141,7 @@ Mogrify(ref,...)
                 {
                   register PixelPacket
                     *q;
-                  
+
                   if (!composite_image->matte)
                     SetImageOpacity(composite_image,OpaqueOpacity);
                   for (y=0; y < (long) composite_image->rows; y++)
@@ -5193,7 +5198,7 @@ Mogrify(ref,...)
               break;
             }
           if (attribute_flag[2])
-            flags=GetGeometry(argument_list[2].string_reference,&geometry.x,
+            /*flags=*/GetGeometry(argument_list[2].string_reference,&geometry.x,
               &geometry.y,&geometry.width,&geometry.height);
           if (attribute_flag[3])
             geometry.x=argument_list[3].int_reference;
@@ -5216,7 +5221,7 @@ Mogrify(ref,...)
           FormatString(composite_geometry,"%lux%lu%+ld%+ld",
             composite_image->columns,composite_image->rows,geometry.x,
             geometry.y);
-          flags=GetImageGeometry(image,composite_geometry,False,&geometry);
+          /*flags=*/GetImageGeometry(image,composite_geometry,False,&geometry);
           if (!attribute_flag[8])
             CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
           else
@@ -5452,7 +5457,7 @@ Mogrify(ref,...)
             opacity;
 
           if (attribute_flag[0])
-            flags=GetImageGeometry(image,argument_list[0].string_reference,
+            /*flags=*/GetImageGeometry(image,argument_list[0].string_reference,
               False,&geometry);
           if (attribute_flag[1])
             geometry.x=argument_list[1].int_reference;
@@ -5533,19 +5538,20 @@ Mogrify(ref,...)
 
           GetQuantizeInfo(&quantize_info);
           quantize_info.number_colors=
-            attribute_flag[0] ? argument_list[0].int_reference : (info ?
-            info->quantize_info->number_colors : MaxRGB + 1);
+            attribute_flag[0] ? (unsigned long) argument_list[0].int_reference :
+            (info ? info->quantize_info->number_colors :
+             MaxRGB + 1U);
           quantize_info.tree_depth=attribute_flag[1] ?
-            argument_list[1].int_reference :
-            (info ? info->quantize_info->tree_depth : 8);
+            (unsigned int) argument_list[1].int_reference :
+            (info ? info->quantize_info->tree_depth : 8U);
           quantize_info.colorspace=(ColorspaceType)
-            (attribute_flag[2] ? argument_list[2].int_reference :
+            (attribute_flag[2] ? (ColorspaceType) argument_list[2].int_reference :
             (info? info->quantize_info->colorspace : RGBColorspace));
           quantize_info.dither=attribute_flag[3] ?
-            argument_list[3].int_reference :
+            (unsigned int) argument_list[3].int_reference :
             (info ? info->quantize_info->dither : False);
           quantize_info.measure_error=attribute_flag[4] ?
-            argument_list[4].int_reference :
+            (unsigned int) argument_list[4].int_reference :
             (info ? info->quantize_info->measure_error : False);
           if (attribute_flag[5] && argument_list[5].int_reference)
             {
@@ -5563,7 +5569,7 @@ Mogrify(ref,...)
         case 49:  /* Raise */
         {
           if (attribute_flag[0])
-            flags=GetImageGeometry(image,argument_list[0].string_reference,
+            /*flags=*/GetImageGeometry(image,argument_list[0].string_reference,
               False,&geometry);
           if (attribute_flag[1])
             geometry.width=argument_list[1].int_reference;
@@ -5692,7 +5698,7 @@ Mogrify(ref,...)
         {
           if (attribute_flag[0])
             image->fuzz=argument_list[0].double_reference;
-          flags=GetGeometry("0x0",&geometry.x,&geometry.y,
+          /*flags=*/GetGeometry("0x0",&geometry.x,&geometry.y,
             &geometry.width,&geometry.height);
           image=CropImage(image,&geometry,&exception);
           break;
@@ -5860,7 +5866,7 @@ Mogrify(ref,...)
         case 72:  /* Shave */
         {
           if (attribute_flag[0])
-            flags=GetImageGeometry(image,argument_list[0].string_reference,
+            /*flags=*/GetImageGeometry(image,argument_list[0].string_reference,
               False,&geometry);
           if (attribute_flag[1])
             geometry.width=argument_list[1].int_reference;
@@ -6004,8 +6010,8 @@ Mogrify(ref,...)
         }
         case 77:  /* AdaptiveThreshold */
         {
-         double
-           offset;
+          double
+            offset;
 
           unsigned long
             height,
@@ -6037,13 +6043,13 @@ Mogrify(ref,...)
         (void) CatchImageException(next);
       if (region_image != (Image *) NULL)
         {
-          unsigned int
-            status;
+          /*unsigned int
+            status;*/
 
           /*
             Composite region.
           */
-          status=CompositeImage(region_image,CopyCompositeOp,image,
+          /*status=*/CompositeImage(region_image,CopyCompositeOp,image,
             region_info.x,region_info.y);
           (void) CatchImageException(region_image);
           DestroyImage(image);
@@ -6058,7 +6064,7 @@ Mogrify(ref,...)
               next->previous=0;
               DestroyImage(next);
             }
-          sv_setiv(*pv,(IV) image);
+          sv_setiv(*pv,(IV) (magick_uintptr_t)image);
           next=image;
         }
       if (*pv)
@@ -6443,7 +6449,7 @@ Montage(ref,...)
         TransparentImage(next,transparent_color,TransparentOpacity);
     for (  ; image; image=image->next)
     {
-      sv=newSViv((IV) image);
+      sv=newSViv((IV) (magick_uintptr_t)image);
       rv=newRV(sv);
       av_push(av,sv_bless(rv,hv));
       SvREFCNT_dec(sv);
@@ -6580,7 +6586,7 @@ Morph(ref,...)
     DestroyExceptionInfo(&exception);
     for ( ; image; image=image->next)
     {
-      sv=newSViv((IV) image);
+      sv=newSViv((IV) (magick_uintptr_t)image);
       rv=newRV(sv);
       av_push(av,sv_bless(rv,hv));
       SvREFCNT_dec(sv);
@@ -6678,7 +6684,7 @@ Mosaic(ref)
     av=newAV();
     ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
     SvREFCNT_dec(av);
-    sv=newSViv((IV) image);
+    sv=newSViv((IV) (magick_uintptr_t)image);
     rv=newRV(sv);
     av_push(av,sv_bless(rv,hv));
     SvREFCNT_dec(sv);
@@ -6733,8 +6739,10 @@ Ping(ref,...)
     ExceptionInfo
       exception;
 
+    /*
     HV
       *hv;
+      */
 
     Image
       *image,
@@ -6758,9 +6766,7 @@ Ping(ref,...)
       *package_info;
 
     SV
-      *reference,
-      *rv,
-      *sv;
+      *reference;
 
     unsigned int
       status;
@@ -6774,7 +6780,7 @@ Ping(ref,...)
     ac=(items < 2) ? 1 : items-1;
     list=MagickAllocateMemory(char **,(ac+1)*sizeof(*list));
     reference=SvRV(ST(0));
-    hv=SvSTASH(reference);
+    /* hv= SvSTASH(reference); */
     av=(AV *) reference;
     info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL);
     package_info=ClonePackageInfo(info);
@@ -6785,15 +6791,15 @@ Ping(ref,...)
     else
       for (n=0, i=0; i < ac; i++)
       {
-       STRLEN
-         length;
+        STRLEN
+          length;
 
         list[n]=(char *) SvPV(ST(i+1),length);
         if ((items >= 3) && strEQcase(list[n],"blob"))
           {
-           package_info->image_info->blob=(void *) (SvPV(ST(i+2),length));
+            package_info->image_info->blob=(void *) (SvPV(ST(i+2),length));
             package_info->image_info->length=(size_t) length;
-           continue;
+            continue;
           }
         if ((items >= 3) && strEQcase(list[n],"filename"))
           continue;
@@ -6904,7 +6910,7 @@ QueryColor(ref,...)
 
         colorlist=GetColorList("*",&colors);
         EXTEND(sp,colors);
-        for (i=0; i < colors; i++)
+        for (i=0; i < (long) colors; i++)
         {
           PUSHs(sv_2mortal(newSVpv(colorlist[i],0)));
           MagickFreeMemory(colorlist[i]);
@@ -7045,7 +7051,7 @@ QueryFont(ref,...)
 
         typelist=GetTypeList("*",&types);
         EXTEND(sp,types);
-        for (i=0; i < types; i++)
+        for (i=0; i < (long) types; i++)
         {
           PUSHs(sv_2mortal(newSVpv(typelist[i],0)));
           MagickFreeMemory(typelist[i]);
@@ -7605,7 +7611,7 @@ Read(ref,...)
         CatchException(&exception);
       for ( ; image; image=image->next)
       {
-        sv=newSViv((IV) image);
+        sv=newSViv((IV) (magick_uintptr_t)image);
         rv=newRV(sv);
         av_push(av,sv_bless(rv,hv));
         SvREFCNT_dec(sv);
@@ -7664,14 +7670,14 @@ Remote(ref,...)
     SV
       *reference;
 
-    struct PackageInfo
-      *info;
+    /*struct PackageInfo
+     *info;*/
 
     dMY_CXT;
     MY_CXT.error_list=newSVpv("",0);
     reference=SvRV(ST(0));
     av=(AV *) reference;
-    info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL);
+    /*info=*/GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL);
 #if defined(XlibSpecificationRelease)
     {
       Display
@@ -7881,7 +7887,7 @@ Transform(ref,...)
       (void) CatchImageException(clone);
       for ( ; clone; clone=clone->next)
       {
-        sv=newSViv((IV) clone);
+        sv=newSViv((IV) (magick_uintptr_t)clone);
         rv=newRV(sv);
         av_push(av,sv_bless(rv,hv));
         SvREFCNT_dec(sv);
@@ -7985,9 +7991,9 @@ Write(ref,...)
       next->scene=scene++;
     }
     (void) SetImageInfo(package_info->image_info,
-                       (SETMAGICK_WRITE |
-                        (!package_info->image_info->adjoin ? SETMAGICK_RECTIFY: 0U)),
-                       &image->exception);
+                        (SETMAGICK_WRITE |
+                         (!package_info->image_info->adjoin ? SETMAGICK_RECTIFY: 0U)),
+                        &image->exception);
     for (next=image; next; next=next->next)
     {
       (void) WriteImage(package_info->image_info,next);
@@ -8014,4 +8020,3 @@ Write(ref,...)
 # c-basic-offset: 2
 # fill-column: 78
 # End:
-
index 9937e8e..e721d56 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2010 GraphicsMagick Group
+# Copyright (C) 2003-2018 GraphicsMagick Group
 # Copyright (C) 2002 ImageMagick Studio
 # Copyright (C) 1998,1999 E. I. du Pont de Nemours and Company
 #
@@ -21,7 +21,7 @@ my $magick_CC='@CC@';
 my $magick_CPPFLAGS='-I../ -I@top_srcdir@ @CPPFLAGS@';
 my $magick_LDFLAGS='@LDFLAGS@';
 my $magick_BIN_DIR="$ENV{'DESTDIR'}@BIN_DIR@";
-my $magick_DEP_LIBS='@MAGICK_DEP_LIBS@';
+my $magick_API_LIBS='@MAGICK_API_LIBS@';
 my $magick_PERLMAINCC='@PERLMAINCC@';
 my $magick_LIB_DIR="$ENV{'DESTDIR'}@MAGICKLIBDIR@";
 
@@ -39,34 +39,34 @@ foreach $delegate (qw/@DELEGATES@/) {
 WriteMakefile
   (
    # Module description
-   'ABSTRACT'  => 'GraphicsMagick PERL Extension',
+   'ABSTRACT'   => 'GraphicsMagick PERL Extension',
 
    # Perl module name is Graphics::Magick
-   'NAME'      => 'Graphics::Magick',
+   'NAME'       => 'Graphics::Magick',
 
    # Module author
-   'AUTHOR'    => 'GraphicsMagick Group',
+   'AUTHOR'     => 'GraphicsMagick Group',
 
    # Module version
-   'VERSION'   => '@PACKAGE_VERSION@',
+   'VERSION'    => '@PACKAGE_VERSION@' =~ /^([\d\.]+)/g,
 
    # Preprocessor defines
-   'DEFINE'    => $magick_DEFS,     # e.g., '-DHAVE_SOMETHING' 
+   'DEFINE'     => $magick_DEFS,     # e.g., '-DHAVE_SOMETHING'
 
    # Header search specfication and preprocessor flags
-   'INC'       => $magick_CPPFLAGS,
+   'INC'        => $magick_CPPFLAGS,
 
    # C compiler
-   'CC'                => $magick_CC,
+   'CC'         => $magick_CC,
 
    # C pre-processor flags (e.g. -I & -D options)
    # 'CPPFLAGS'    => "$Config{'cppflags'} $magick_CPPFLAGS",
 
    # C compiler flags (e.g. -O -g)
-   'CCFLAGS'     => "$Config{'ccflags'} $magick_CFLAGS",
+   'CCFLAGS'    => "$Config{'ccflags'} $magick_CFLAGS",
 
    # Linker
-   'LD'          => $Config{'ld'} == $Config{'cc'} ? $magick_CC : $Config{'ld'},
+   'LD'         => $Config{'ld'} == $Config{'cc'} ? $magick_CC : $Config{'ld'},
 
    # Linker flags for building an executable
    'LDFLAGS'    =>  "-L$magick_LIB_DIR $Config{'ldflags'}",
@@ -75,25 +75,25 @@ WriteMakefile
    'LDDLFLAGS'  => "-L$magick_LIB_DIR $Config{'lddlflags'}",
 
    # Install PerlMagick binary into GraphicsMagick bin directory
-   'INSTALLBIN'        => $magick_BIN_DIR,
+   'INSTALLBIN' => $magick_BIN_DIR,
 
    # Library specification
-   'LIBS'      => ["-L$magick_LIB_DIR -lGraphicsMagick $magick_LDFLAGS $magick_DEP_LIBS"],
+   'LIBS'       => ["-L$magick_LIB_DIR $magick_LDFLAGS $magick_API_LIBS"],
 
    # Perl binary name (if a Perl binary is built)
-   'MAP_TARGET'        => 'PerlMagick',
+   'MAP_TARGET' => 'PerlMagick',
 
    # Let CFLAGS drive optimization flags by setting OPTIMIZE to empty
-   # 'OPTIMIZE'        => '',
+   # 'OPTIMIZE' => '',
 
    # Use same compiler as GraphicsMagick
-   'PERLMAINCC'        => $magick_PERLMAINCC,
+   'PERLMAINCC' => $magick_PERLMAINCC,
 
    # Set Perl installation prefix to GraphicsMagick installation prefix
-#   'PREFIX'   => '@prefix@',
+#   'PREFIX'    => '@prefix@',
 
    # Include delegate directories in tests
-   test                => { TESTS      =>      $delegate_tests},
+   test         => { TESTS      =>      $delegate_tests},
 
    ($Config{'archname'} =~ /-object$/i ? ('CAPI' => 'TRUE') : ()),
 );
index 8abe3d9..a264a43 100644 (file)
@@ -37,7 +37,7 @@ WriteMakefile(
     'NAME'      => 'Graphics::Magick',
     'VERSION_FROM' => 'Magick.pm', # finds $VERSION
     'LIBS'      => ['-L..\VisualMagick\lib -L..\VisualMagick\bin -lCORE_RL_magick_.lib'],
-    'DEFINE'    => '-D_VISUALC_ -D_WINDOWS',     # e.g., '-DHAVE_SOMETHING' 
+    'DEFINE'    => '-D_VISUALC_ -D_WINDOWS',     # e.g., '-DHAVE_SOMETHING'
     'INC'       => '-I.. -I..\xlib\include',
     'BINARY_LOCATION'  => 'x86/Graphics-Magick.tar.gz',
     'dist' => {ZIP => "zip.exe", ZIPFLAGS=>"-r"},
@@ -46,12 +46,12 @@ WriteMakefile(
 );
 
 #
-# Add a targets for building ActiveState ppm distribution modules 
+# Add a targets for building ActiveState ppm distribution modules
 # Dylan Beattie <dylan@zepler.org>, April 2002
 #
 # Requires tar, gzip, and zip.  This produces PerlMagick.zip
 # Get GNU tar and gzip from http://sourceware.cygnus.com/
-# Get Win32 command line PKZIP from http://www.pkware.com/ 
+# Get Win32 command line PKZIP from http://www.pkware.com/
 # and rename PKZIP.EXE to ZIP.EXE and PKUNZIP.EXE to UNZIP.EXE
 # Make sure tar.exe, gzip.exe and zip.exe are in your system path
 #
@@ -62,8 +62,8 @@ sub MY::postamble
 {
         '
 Graphics-Magick.tar.gz: ppd pure_all #htmlifypods manifypods
-       if exist Graphics-Magick.tar.gz del Graphics-Magick.tar.gz
-       if exist Graphics-Magick.tar del Graphics-Magick.tar
+        if exist Graphics-Magick.tar.gz del Graphics-Magick.tar.gz
+        if exist Graphics-Magick.tar del Graphics-Magick.tar
         $(TAR) $(TARFLAGS) Graphics-Magick.tar blib
         $(COMPRESS) -q Graphics-Magick.tar
 
@@ -116,7 +116,6 @@ sub MY::test
    #  =======   ====================== ======================================
    #   bzlib    BZip compression        BZip library
    #   cgm     CGM format              'ralcgm' program
-   #   hdf     HDF format              HDF library
    #   jbig    JBIG format             JBIG library
    #   jpeg    JPEG format             JPEG library
    #   mpeg    MPEG format             'mpeg2decode' & 'mpeg2encode' programs
diff --git a/PerlMagick/t/jpeg/input.jnx b/PerlMagick/t/jpeg/input.jnx
new file mode 100644 (file)
index 0000000..35141a0
Binary files /dev/null and b/PerlMagick/t/jpeg/input.jnx differ
index 3a21fe3..a5e97c2 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/local/bin/perl
-# Copyright (C) 2003 - 2012 GraphicsMagick Group
+# Copyright (C) 2003 - 2018 GraphicsMagick Group
 # Copyright (C) 2002 ImageMagick Studio
 # Copyright (C) 1991-1999 E. I. du Pont de Nemours and Company
 #
@@ -12,7 +12,7 @@
 #
 # Contributed by Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
 #
-BEGIN { $| = 1; $test=1; print "1..3\n"; }
+BEGIN { $| = 1; $test=1; print "1..4\n"; }
 END {print "not ok $test\n" unless $loaded;}
 use Graphics::Magick;
 $loaded=1;
@@ -23,13 +23,13 @@ chdir 't/jpeg' || die 'Cd failed';
 
 #
 # 1) Test non-interlaced image read
-# 
+#
 print( "Non-interlaced JPEG ...\n" );
 testReadCompare('input.jpg', '../reference/jpeg/read_non_interlaced.miff', q//, 0, 0);
 
 #
 # 2) Test plane-interlaced image read
-# 
+#
 ++$test;
 print( "Plane-interlaced JPEG ...\n" );
 testReadCompare('input_plane.jpg', '../reference/jpeg/read_plane_interlaced.miff', q//, 0, 0);
@@ -40,3 +40,10 @@ testReadCompare('input_plane.jpg', '../reference/jpeg/read_plane_interlaced.miff
 print("Seattle FilmWorks image file ...\n");
 ++$test;
 testReadCompare('input.sfw', '../reference/jpeg/read_sfw.miff', q//, 0.003, 0.1);
+
+#
+# 4) Test JNX file ...\n");
+#
+print("Garmin JNX image file ...\n");
+++$test;
+testReadCompare('input.jnx', '../reference/jpeg/read_jnx.miff', q//, 0.003, 0.1);
diff --git a/PerlMagick/t/reference/jpeg/read_jnx.miff b/PerlMagick/t/reference/jpeg/read_jnx.miff
new file mode 100644 (file)
index 0000000..ebe4d51
--- /dev/null
@@ -0,0 +1,235 @@
+id=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+jnx:northeast=50.289339251019683275,14.41406250671207089950.176898115396916467,14.23828125663021637650.289339251019683275,14.23828125663021637650.176898115396916467,14.41406250671207089950.289339251019683275,14.41406250671207089950.176898115396916467,14.15039063158928911450.289339251019683275,14.15039063158928911450.233151833635361072,14.15039063158928911450.120578096304356563,14.15039063158928911450.289339251019683275,14.23828125663021637650.233151833635361072,14.23828125663021637650.120578096304356563,14.23828125663021637650.176898115396916467,14.23828125663021637650.289339251019683275,14.41406250671207089950.233151833635361072,14.41406250671207089950.120578096304356563,14.41406250671207089950.176898115396916467,14.41406250671207089950.120578096304356563,14.32617188167114363850.289339251019683275,14.32617188167114363850.233151833635361072,14.32617188167114363850.176898115396916467,14.326171881671143638
+jnx:southwest=50.064191776357681363,14.06250000654836185350.064191776357681363,14.06250000654836185350.176898115396916467,14.06250000654836185350.064191776357681363,14.23828125663021637650.176898115396916467,14.23828125663021637650.120578096304356563,14.06250000654836185350.233151833635361072,14.06250000654836185350.176898115396916467,14.06250000654836185350.064191776357681363,14.06250000654836185350.233151833635361072,14.15039063158928911450.176898115396916467,14.15039063158928911450.064191776357681363,14.15039063158928911450.120578096304356563,14.15039063158928911450.233151833635361072,14.32617188167114363850.176898115396916467,14.32617188167114363850.064191776357681363,14.32617188167114363850.120578096304356563,14.32617188167114363850.064191776357681363,14.23828125663021637650.233151833635361072,14.23828125663021637650.176898115396916467,14.23828125663021637650.120578096304356563,14.238281256630216376
+\f
+:\1az\85]r}Uv\81YgqLt~YkuPx\82]u\7f\isPu\7f\}\87ez\84by\83aw\81_isQXb@mxPlwOp{SjtOnxSkuPt~Yv\80]oyVz\84a{\85cpzXgqOisQkuShrPq|Tv\81Ys}Xw\81\mwRpzUmwTq{XkuRt~[w\81_pzXjtRjtRgqOajKt~Yy\83^pzU|\86amwRu\7fZgqNisPlvSlvTjtRhrPkuSluVdmNXaBisNkuP`jEoyTgqLq{XakH^hEkuShrP`jHWa?U^?[dEajKdmNisNfpK_iDeoJblIfpMZdAU_<U_=`jHfpN]fGNW8LU6ZcDirSdnIblGfpM`jGdnK^hEblI`jHNX6[eChqRhqR]fGV_@[dEenONX5Q[8blIYc@fpM_iFs}[x\82`gqOajK]fG_hIclMgpSirUktWIS0`jGT^;S]:JT2IS1pzXw\81_dmN`iJ_hIclOgpSenQ`iL\eHAK(\fCeoLLV4HR0cmKhrP\eF\eFajKfoRenQ_hKZcF]fIbkNNX6Wa?r|Z]gEcmK\81\8biirS_hIgpQbkN`iLclOirUhqV^gLS\AakIQ[9eoMv\80^\7f\89g{\84ektUx\81bnwZirUfoRirUpy^nw\_hMMV;hrP[eCU_=z\84b|\85f^gHirS{\84ehqTt}`y\82emv[^gLZcH]fKajOhrPu\7f]fpNv\7f`oxY[dEr{\qz]nwZs|_nw\]fKQZ?V_D`iNenS\fDt~\z\83dr{\ktUpyZx\81bpy\jsVhqT^gLT]BW`EbkPbkPXaFDN,T^<u~_irSirS|\85fnwZr{^R[>`iLgpUajO]fK`iN_hMX`Hid=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=1  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1aOY7EO-cmKlvT`jH\fDHR06@\1e?I'HR08B eoMlvT\7f\89g\87\91ot~\NX6LV4fpNblJS];ZdBU_=MW5=G%LV4DN,]gEeoM|\86dq{Y[eC9@\1f29\18FM,OV5]dCryXcjIOV5BI(^eDmtSgnMRY8U\;QX7jqPJQ/:A\1fGN,Y`>pwU|\83acjHRY7gnLahFqxVszXx\7f]szXT[9jqOu|ZhoMryWw~\u|ZfmKRY7`gELS1W^<z\81_t{Yw~\u|ZZa?[b@_fDV];`gEjqOryWbiGGN,T[9GN,qxV\99 ~jqOGN,QX6hoMcjHMS1FL*CI'FL*hnLx~\bhFekI\91\97u\8d\93q\92\98vntRY_=gmK\93\99wqwUy\7f[x~Z_eA=C\1fU[7\82\88d\8f\95q¤ª\86\8c\92nu{W\84\8af\89\8fkouQ^d@\98\9ez\82\88dQW3djFW]9;A\1d_eA\87\8di}\83_\80\86b`fBNT0\90\96ry\7f[ioK\80\86bgmIx~Z~\84`\7f\85arxTU[7`fBx~Zv|X\81\87cciECI%x~ZIO+^d@jpLx~Zz\80\{\7fZswRvzUdhCY]8lpK|\80[\8f\93n\97\9bv\80\84_Y]8\`;LP+\90\94o|\80[x|W;?\1aGK&x|W|\80[cgBhlGimHbfAimHosNeiDimHx|W\90\94o\84\88c_c>osNy}X¢¦\81\97\9bvswR\80\84_\86\8aetxSSW2swRmqLimHhlGtxS}\81\osNtxSptO\84\88cnrMVZ5uyT\87\8bf{\7fZw{V\90\94ogkFquP]a<\83\87bx|W~\82]FH#FH#fhCoqLprM\85\87b\81\83^prM\^9fhC\83\85`jlG\99\9bv\80\82]\7f\81\oqLMO*:<\17IK&XZ5fhCz|WxzUwyT_a<}\7fZ\95\97r|~YrtOhjEegB\88\8aeid=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=2  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1a\84\8adpvP^d>ntN\87\8dg\82\88bv|V}\83]z\80Z\86\8cfz\80ZtzT\82\88b{\81[pvP\80\86`z\80Z\8f\95omsM`f@\88\8ehx~XOU/_e?z\80ZflFgmGy\7fYz\80ZqwQsyS}\83]¡§\81z\80ZtzTpvPZ`:hnH|\82\ioItzTV\6bhBx~XqwQtzT}\83]ouOz\80Zu{UqwQx~X}\83]u{UrxR~\84^y\7fYrxRrxRmsMkqK~\84^~\84^_e?_e?ouOu{UsySv|Vu{UqwQrxR\84\8ad\8b\91ktzT_e?ouO}\83]u{UouOioIpvP\84\8adtzTY_9z\80Z\91\97qmsMz\80Zx~X`f@_e?y\7fYv|VtzT\93\99sV\8\8e\94p\85\8bgrxT\8e\94p\85\8bgioK}\83_flH`fBekGw}Y~\84`pvRouQ\82\88d\81\87cx~ZqwSy\7f[x~ZbhDdjF\85\8bgbhDflH\86\8ch\94\9avz\80\hnJ^d@EK'qwS}\83_qwSntP^d@lrNtzV\8b\91m{\81]y\7f[bhDkqMmsOntPMS/DJ&W];ekIlrPgmKFL*hnLz\80^ntRpvT}\83aouStzXlrPntRouS\94\9ax[a?ciGu{YouS<B djHu{YKQ/DJ(agE\b@ciGY_=QW5SY7\87\8dksyWouSx~\|\82`U[9jpNkqOMS1flJz\80^djHflJgmK`fDJP.djHtzXhnL`fDy\7f]pvTntRbhFjpN\93\99w\90\96tbhFV\:_eCntRX^<]cAchHY^>LQ1hmMjoOdiIW\<puUx}]otTOT4PU5UZ:kpPafF`eEQV6SX8UZ:`eELQ1\aAafFbgGinNX]=[`@\80\85ez\7f_\81\86fx}]v{[BG'PU5fkKchH7<\1cchH|\81a]bBfkKDI)RW7\8e\93s\83\88h~\83cuzZtyYid=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=3  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1aq}YitRjuSdoMitRjuSYdDalLitTitTWbD_jLXcEkvX^hMZdIcnLWb@^iG]hF`kIepNcnNt\7f_s~^cnPLW9]hJdoQt\7fa[eJLV;_jHU`>grPitRalJdoMcnNlwW`kK^iK\gIp{]oz\nx]]gL[eJhrPYcA_iGQ[9JT2`iJktUr{\bkNbkNfoRpy\enSYbG\eJmv[]gE_iGkuSakIenO{\84ev\7f`nwXx\81dgpS]fIZcHV_DKT9S\AajOlvTr|Zx\82`pyZx\81bw\80aZcDYbEdmPdmPox]irWdmRMV;QZ?V_D\85\8eou~_]fGR[<_hIMV7<E(jsVbkNmv[\83\8cqu~cox]T\DX`HW_GjqRcjK`gHw~_\93\9a{gmQHN2\8d\93w\9a \86\86\8crv|bW]CafOY^G_dMSXAovWovWt{\lrVhnR\82\88l\90\96zz\80f{\81gsy_fkTY^GW\E^cLafO`eNv|`z\80d~\84hx~btz^z\80dtz`_eKJP6NS<QV?UZC^cLinWlq[joYquZx|auy^rv[tx]jnUUY@IM4JN7QU>Y]F^bKehSjmXhkVbePkoTquZhlQhlQsw^fjQSW>W[BaeNeiRhlUfiTfiTfiTadO[^InrWtx]mqVpt[}\81hrv]eiPos\VZC]aJcfQdgRehSfiTdgR_bMcgLkoVpt[tx_w{bnrYeiRimVRV?[_HcfQdgRdgRbeP^aNX[HSW>Z^EimTkoVbfM`dKbfO]aJ^bKdgRgjUbeP^aL]`M[^KX[HOS:TX?fjQgkRVZA^bImqZeiR\`I^aL\_JVYDVYD_bOilYnq^id=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=4  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1atyYsxXY^>diIsxX\90\95u\80\85e|\81av{[y~^\85\8aj\85\8ajqvVfkKotTv{[z\7f_fkKfkK\82\87g\99\9e~|\81abgGafF\8d\92r\85\8aj{\80`puU^cCNS3QV6afF~\83chmMx}]\8c\91q¡¦\86mrRglLz\7f_`eEglLjoOx}]\81\86flqQ^cCotThmMinNy~^}\82b}\82b]bBkpP\8f\94tqvVqvVdiIlqQ\7f\84dlqQ^cCy~^joOqvVsxX\86\8bkx}]glLdiI\87\8cl\7f\84d~\83cjoOjoOw|\^cCIN.]bB\81\86fotT[`@\80\85e~\83cv{[ejJ\83\88hglLpuUpuUw|\\80\85elqQW\<^cCz\81`elKOV5[bAlsRlsRfmLryXqxWryXnuThoNdkJelKjqPpwVszY{\82ay\80_[bAovUqxWt{ZelKOV5Za@ipOhoN_fEbiHgnMahGgnMbiHw~]w~]lsRkrQ]dCX_>JQ0FM,elKt{Z}\84cryXQX7cjI_iGlvTz\84b\fDLV4dnLgqO]gE\fDXb@Wa?[eCPZ8JT2gqO\84\8elLV4JT2`jH]gES];]gEhrPz\84bS];OY7FP.cmK\fDPZ8mwU`jHPZ8CM+^hFnxVeoMYcAQ[9_iGcmKGQ/<F$R\:R\:YcAoyWV`>JT2OY7eoMblJdnLu\7f]dnLMW5hrPFP.S];S];IS1`jHhrPblJS^<LW5ZeCXcAalJ|\87ev\81_itRbmKJU3doMepNgrPz\85c`kIR];ozX`kIitRcnLZeC_jH[fD^iGy\84bgrP[fDVa?cnLv\81_ozXcnLS^<lwU\82\8dk`kIKV4_jHYdBEP.nyW\80\8bicnLYdBXcAXcAu\80^x\83aid=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=5  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1a]fIU^AAJ-LU8luXdmPV_BktWbkNS\?\80\89l\8d\96yNW:=F)MV94= W`COX;@I,IR5`iLajMfoR\81\8am[dG^gJU^AMV9KT7?H+4= 9B%PV:EK/EK/V\@flPioSkqUrx\jpTZ`DOU9IO3EK/KQ5LR6>D(SY=@F*@F*SY=agKekO^dHOU9_eIZ`DbhLdjN]cGciMciMQW;OU9>D(8>"=C'DJ.NT8RX<KQ5EK/kqU`fJ]cG\82\88lqw[KQ5X^B/5\197=!:@$9?#;A%BH,LR6TZ>ciMkqU`fJciMv|`bhL>D(:@$(,\11<@%=A&<@%MQ6TX=SW<]aF\82\86kgkPosX{\7fdeiNUY>PT9?C(HL1OS86:\1f/3\18UY>gkPaeJimRjnStx]tx]y}bw{`[_DUY>w{`dhMrv[mqV_cHbfKkoTnrWsw\koT}\81fosXw{`w{`nrWtx]Z^Cuy^{\7fdquZeiNhlQnrWsw\}\81fvz_uy^vz_gkPUY>LP5JN3SW<|\7fdruZdgLfiNvy^vy^mpUorW^aF]`EorWOR7?B'JM2=@%LO4orWTW<<?$KN3knSruZilQilQcfKpsX{~c]`EWZ?loT^aFPS8PS858\1d\1c\1f\ 4$'\f>A&IL1PS8adI_bGruZilQfiNfiNknS}\80esv[Y\AUX=MP5KN3IL1;>#9<!JM2|\7fd\83\86kmpUqtYY\A9<!Z]BknS\8a\8ap\8e\8et\8a\8ap\85\85kzz`]]CDD*AA'EE+]]Cuu[\87\87m\84\84j\82\82h\99\99\7f®®\94\91\91w\84\84jnnTggMnnT``FCC)33\19..\14[[A\98\98~\99\99\7f¤¤\8aÀÀ¦©©\8f\9a\9a\80id=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=6  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1av{[y~^\85\8ajhnL]cAdjHRX6\b>kqM|\82^\88\8eh\9c¢|\89\8fi[a;[a;ntN\82\87gnsSv{[\86\8cjv|ZouSy\7f]u{Wz\80\w}Y\86\8cf\95\9buqwQ`f@\88\8eh\98\9ex¡¦\86|\81a\8c\91q\7f\85cMS1QW5ouS~\84`\8e\94p\84\8af\94\9at\8f\95oLR,EK%\85\8be\90\96ppuUJO/\86\8bk\91\97uqwU^dBGM+rxT\86\8chx~Zu{UlrL<B\1c17\11OU/@F ¸½\9d\8b\90p\88\8dmºÀ\9eÅË©{\81_MS1u{W\b>RX4BH"X^8rxRx~XqwQQW1\9b \80©®\8eOT4djH\81\87eW];x~\\82\88d\7f\85a\81\87cpvP|\82\\8f\95o\84\8adv|VdjDw|\¦«\8bnsSZ`>Z`>QW5rxV`fBioKlrNtzT\86\8cf|\82\tzT\88\8eh\86\8cfkpPX]=x}]\7f\85c\81\87e\87\8dktzX\84\8af\91\97spvRtzT\8a\90jouOioI\7f\85_djDnsSuzZkpPrxVntR{\81_\91\97ukqMEK'RX4\81\87au{UpvP~\84^gmGtzT_dD}\82b\80\85eW];u{YV\:tzX\8c\92nX^:QW3lrLdjDkqK\82\88brxR\80\86`SX8Y^>|\81aZ`>djHhnL\8f\95s\98\9ez\8b\91mx~Z\87\8dg\83\89c\87\8dg\89\8fiflFdjDbgG^cCz\7f_~\84bmsQ\97\9d{x~\PV2v|XioK{\81[\86\8cf\8f\95o\8a\90jkqKgmGZ_?qvVz\7f_\8f\95s¡§\85§­\8bSY7IO+u{WjpLouOtzTx~X{\81[z\80Z\87\8dghmM^cCx}]\8e\94r\9e¤\82\87\8dk\7f\85c\97\9dy\9d£\7f\93\99u\86\8cfx~XlrLjpJrxR~\84^\8d\92rnsSv{[\88\8elpvThnL\8e\94r\91\97s\82\88d\7f\85aqwQhnHflFkqKu{Uu{UrwW\92\97w_dDtzXjpN{\81_bhFV\8jpLgmITZ4RX2bhBy\7fY\8b\91k\86\8cfid=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=7  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1a\fD\81\8bimwUx\82_|\86cYc@\fC_iDfpKnxSalDmxPq|TnyQ©´\8cx\83[jtR~\88fs}[lvSkuRq{X\84\8ek\7f\89dfpKV`;p{SmxPw\82Z{\86^\85\90hw\82Z[eCOY7YcAcmJx\82_\8e\98ux\82_V`;MW2BL'`kCfqI{\86^v\81Yq|Ts~VLV4HR0cmKYc@^hEkuRR\9blG=G"R\7Q\4fqI\81\8cdfqIu\80XcnFcmKeoMkuSLV3lvS\87\91nR\9Yc>CM(`jEfqIkvN\7f\8abgrJepHEP(u\7f]kuSYcA;E"|\86cµ¿\9clvS;E ?I$CM(y\84\cnFnyQq|TEP(0;\13lvTblJlvTPZ7OY6\81\8bh\88\92oy\83^IS.7A\1cu\80XfqIhsKmxPHS+7B\1aakIIS1\83\8dk\95\9f|akHkuR\95\9f|\99£~lvQ[e@s~V}\88`w\82ZbmEhsKJU-\8d\97uq{Y\89\93qv\80]KU2pzW\87\91n^hCakFZd?ozRepHAL$ozRx\83[\8d\98pu\7f]}\87egqOHR/ZdAdnK]gD~\88c[e@\83\8dh[f>\g?Yd<bmEepHOZ2IS1lvTYcADN+fpMU_<?I&\89\93nhrMeoJepH\7f\8ab\9a¥}z\85]?J"u\80X;E#NX6cmK]gDU_<HR/JT1y\83^lvQfpKr}UIT,S^6juMLW/\99¤|Q[9MW5cmKYc@DN+NX5Yc@dnI`jEhrMalDCN&.9\116A\19^iAv\81YR\:Xb@Wa?HR/Wa>eoLQ[8OY4AK&%/
+alDjuM^iAalDepHmxP?I'NX6Q[9IS0blInxUWa>\fA/9\14\13\1d\0q|TIT,Va9\96¡yr}UgrJ:D"9C!PZ8NX5KU2akHs}Z\84\8eiNX39C\1ejuMp{S~\89amxPU`8JU-id=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=8  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1a48\15SW4[a=NV1mySFU.+;\141A\1a8H!}\8df\95¤}w\83]{\83^\80\86b\9c }\8b\8flOS0vzWz\80\v~YLV1<H"*9\12?O(Vf?o~Wy\85_gqLy\81\tzVquRY]:WX6\82\86cu{WltOisNx\84^Q`9DS,N]6YhAt\80ZkuPy\81\ouQtxU\84\85cxyW}~\^b?NT0\9a¢}\8c\96q^jDIU/^jDlxR\8e\98s}\85`|\82^osP\84\85c­®\8cµ¶\94\86\87e|}[\81\85b\91\97semH^fAakFYc>bjEt|WlrN\80\84a\7f\80^\8c\8dk\9d\9e|\81\81_efD\86\87e ¤\81Z^;pvR\84\8afZ`<28\14BH$GM)TX5w{XtuS\88\89g\83\83a))\a00\ eQR0efDHI'\8e\92o\9b\9f|PT1RV3gkHUY6deCtuSRS1ssQiiGBC!:;\1967\1578\16xyW\8f\90n\96\97u\84\85c\92\93q\98\99wjkIz{Y\86\87eST2{|ZmnL>?\1d_`>_`>\93\94r¸¹\97\80\81_\8e\8fm\7f\80^}~\xyW|}[\85\86d\8b\8cj\8e\8fmxyWTU3¬°\8d©­\8az~[\84\85c©ª\88\96\97u\9f\9f}eeCTT2zzX\8f\90n}~\pqO|\80]y}Z\`=\99\9f{\84\8afY_;fjG\93\97t£¤\82³´\92ddBKK)opN\81\82`quRmqN\84\8af\92\98t\89\8fkfpKPX3FN)_eAz~[\86\87e§¨\86lmKdeCab@fgE|\80]\92\98t\93\9bv\91\99t\95\9fzNZ4>J$DN)KS.LR.]a>\94\95smnLlmKhiGnrO\8b\91m\9b£~~\88ceqKnzT0?\185D\1dEQ+5?\1a5=\18W]9\8a\8ek_`>\];}\81^\87\8di|\84_u\7fZbnHVe>dsL9I"CR+Vb<AK&=E QW3swTKO,HL)~\82_\83\89ehpKlvQu\81[o~Wr\82[;K$6F\1fET-:F 4<\175;\17Y]:TX5<@\1dimJntPksN\8e\9at\9bª\83|\8ceeuNid=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=9  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1a\80~W\9d\9b\9fyXV0\86\84^¥£}\84\81^\81~[pmJ\80}Z~{ZRO.\7f|[\83\80_qnO\90\8dnmnFvwO\88\88b{{UiiC\8a\8adppL\81\81]\94\94p\95\95qwwU]];\88\88f\8b\8biutU\85\84e\9b¢xkrHv}T\86\8dd`g>szQhnHouO\82\88b\90\96pmsOioKu{WrxTrxV\8d\93q\87\92gMX-doEbmCcnDcnDp{ShsK\87\92jz\85]AK&blG|\86a\81\8bfv\80]q{Xo\7fRm}P\7f\8ecfuJl{PhwLr\81Xr\81Xu\84[|\8bbcrK\81\90is\82[hwPm{Wt\82^iyL~\8ea^mBL[0FU*\k@N]4Wf=~\8ddixO]lE{\8ac\7f\8egy\88ajxTR`<v\83Ww\84XUb7]j?cpEv\83XkwOp|TcoGZf>~\8ad\83\8fiq}WdpJamIVb>y\82WoxM\83\8bb\90\98o\94\9csksJrzSnvOu}V]e>\8d\95p\85\8dh{\83^pxScjHLS1v{R\87\8cc\89\8ef\7f\84\x}UjoGY]8SW2`d?txSx|Yy}Z\83\87d{\7f\vzY\85\89h\85\86^\83\84\\82\82\\80\80ZzzTppJcc?XX4uuQ{{WssQjjHrrP{{Y|{\~}^\95\93l~|U\7f}W\88\86`}{UusMolI_\9{xU\80}Z}zYolKnkJ\86\83b\94\91r\8a\87h\89\87`kiBsqK\81\7fYmkEdb<khEda>khEzwT\88\85dzwVliH\83\80_\94\91r\81~_\7f\81Yce=lnGxzS`b;^`9y{V\85\87b}\7fZ\83\85`\8e\8fm\85\86dwxV\86\87e\8a\8bknoO_f<KR(PW.X_6KR)RY0tzT\8b\91k\8f\95o\80\86`v|Xw}Y}\83_\84\8af{\81_djHjwKboCdqFp}Rx\85Z}\8a_\8a\96n\98¤|y\85]dpHQ]7Xd>dpJ[gAO[7R^:Yi<[k>_nCs\82W\8a\99n\88\97ly\88_u\84[u\84[ixOYhA]lE]lE>M&3A\1dP^:id=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=10  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1aq{X[eBu|ZszXelJt{Y|\82`\8a\90n\92\98v~\84bY]<_cBUY86:\19AB"=>\1ex\82_}\87d\93\9axt{YZa?mtRioM[a?^dBW];[_>imLY]<FJ)TU5WX8\89\93p\7f\89f\88\8fmt{Y[b@]dBdjHouSmsQekI\84\88g\89\8dltxW}\81`\8b\8cl\89\8ajjtQblIjqOhoM[b@W^<ioM\84\8ahy\7f]ekI\7f\83bjnMX\;\89\8dl\9b\9c|\8b\8cl3=\1aXb?hoM]dBX_=`gEioMciGY_=MS1aeD9=\1c&*       lpO\8e\8fo}~^>H%`jGgnLipNipN`gEgmKgmKU[9^dBosRLP/04\13]a@\88\89i\87\88hV`=gqNahFqxVt{YX_=_eCpvT_eCjpNptSimLMQ0JN-noO{|\>H%kuRgnLelJhoMV];QW5CI'`fD^dBSW6jnM\`?9=\1cQR2deE\99£\80¥¯\8c\92\99w\95\9cz}\84bt{YciGPV4djH[a?UY8ptSmqPDH'QR2tuU\9f©\86\93\9dzx\7f]\8a\91ov}[fmKflJqwUagEqwUswV\82\86e\85\89hptScdDST4S]:s}ZqxVovTBI'3:\18;A\1fHN,HN,MS1PT3dhGcgFSW6efFtuUnxU\85\8fl\7f\86d\84\8bicjHSZ8IO-BH&\7f\85cqwUcgFimLUY8>B!VW7hiIoyVblISZ8t{YZa?>E#JP.pvTioMmsQmqPy}\\83\87f\91\95t\98\99ytuU^hEWa>AH&Y`>V];biG~\84b\9b¡\7f\99\9f}\8a\90n\84\88g\90\94s\88\8ck\86\8ai\93\94t{|\fpMjtQ?F$:A\1fRY7\92\99w¢¨\86\84\8ah\8a\90njpNgkJ{\7f^\`?CG&bcCopPR\9x\82_biG>E#\1a!\0AH&y\7f]\92\98vz\80^v|Z\8a\8em¤¨\87\93\97v\8a\8em\95\96vz{[id=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=11  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1apxSLT/DL'\92\9au\8b\92pelJ\84\8bi\cBCJ)mtS~\85d\81\88i\84\8bljqRX_@krSgoJLT/LT/pxS\8a\91o\93\9ax\91\98v~\85dt{Z~\85dt{ZhoPkrShoPmtU\84\8blnvQIQ,PX3NV1ovT\85\8cjZa?ahFhoNjqPkrQnuVv}^\82\89j\8d\94u\96\9d~{\85`CM(IS.EO*NX3Wa>:D!R\9GQ.Wa?r|Z\80\8ah|\85fy\82cw\80amvW ¬\86r~Xs\7fYp|VMY3IU/Wc?Wc?5A\1dR];v\81_\7f\8ahozXgrRitTepP\93\9fw\94 x¡­\85\9eª\84gsM_kEw\83]JV2AM)htP\89\94r\8a\95s|\87et\7f]v\81_|\87eWc;myQ~\8ab\80\8cdgsMiuOz\86`Xd>gsO\8e\9av\9c¨\84\91\9cz\88\93qu\80^epNitR]iAYe=LX0AM%BN&HT.Ua;frLcoI\85\91m\83\8fkt\80\z\85cnyW[fDbmKVc8erGZf>r~V\8c\98pDP(Ye?\85\91kbnH\82\8ehcoKhtP\86\92nt\80\_kGNY7_j@]h>q|R¢­\83±¼\94Q\4DO'pzUlvQ]gBeoJ}\87d\8b\95r\82\8cit~[y\83`IT*\84\8fe\97¢xOZ0BM#`kCv\81Yv\81YeoJ;E jtO\86\90kt~[lvSmwT\8f\99v_g>\8a\92i©±\88bjAT\3\8d\95l\91\99r\8d\95nZb;X`;\8d\95p\9c¤\7frzUZa?ahF~\85cSX/OT+rwOlqI}\82Z\98\9du\a9EI$mqL\9c {©­\8a ¤\81\85\89fosPuyVnrOHM$Z_6mrI]b9sxP¡¦~fkCKO*\8c\90k­±\8c\86\8aegkHimJ{\7f\\90\94qptQFH ^`8tvN\85\87_\8b\8df\8c\8egikD\8f\91j\88\8ae|~Yce@JK)MN,|}[\92\93qmnLUV.uvN}~V\94\95m\99\99s\91\91kwwQ¯¯\89iiEHH$ooKqqO__=\88\88f\87\87e[[9id=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=12  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1a9D"6A\1f9D"$/\r.8\16:D"gnM\7f\86echHKP0\8d\90q\92\95v\9e¡\82§¨\89\90\91ruvWDR/AL*?J(,7\15@K)Q[9jtRlsR}\84cSX8|\81a\89\8cm\86\89j\80\83dijKabC1?\1cFT1_jHMX6OZ8JT2V`>Q[9szY_fE\8a\8fo\9d¢\82z}^ilM\_@x{\FT0<J&FT0M[7p|XjvR\hD?I&HR/X_=\7f\86d\90\97uflJflJ`fD|\82`@N*+9\153A\1dBP,esOamIbnJZfBOY6_iFcmJ`gEOV4qxVjqOfmK5C\1f?M)^lHaoKbpLKY5_kGq}Y_kGo{WakHCM*:D!]gDkuRjtQiwSiwSu\83_o}Y\7f\8diw\85au\83_frNamIo{WmyUT`<FR.;G#Ua=kwSo~Wt\83\r\81ZQ`9]lEnzT\80\8cfq}W\80\8cf{\87a\83\8fi\83\8fi\80\8cfHT.MY3amGNZ4Wc=R^8BN(R^8\80\8cf\87\93meqKcoI\84\90jkwQs\7fYbnHfrLnzTp|VFP+3=\186@\e^hC\8a\94o\94\9ey~\88ceoJeqKdpJR^8kwQ]iCKW1HT.eqKLR,X^8djDw\7fX\91\99r\90\98qv~WckD[f>S^6NY1^iAiuMlxPKW/KW/^b=jnIimHuyT\9b\9fz§­\87\7f\85_U[5MU.IQ*Zb;bmE{\86^\89\94l_jBXc;kkGvvR\85\87b\96\98s\9c\9ey\8b\8dhnrM`d?\b<CI#W]7hpI\7f\87`w\7fXemF\83\8ef\80}Z\9f\9cy¼¹\96¨¨\84||XssO\82\84_\85\87b\84\88cdhCV\6V\6\80\86`\89\91j\84\8ce\86\8e\9dz\92\8ek\92\8fl\86\83`|yV\9f\9f{°°\8c\88\8ae\82\84_|\80[gkF\b<\91\97q£©\83\9c¢|msM°¬\89njGlhE\8a\86c\82\7f\\89\86c\8e\8ejnnJTV1lnIw{V\89\8dh¦¬\86\86\8cf\87\8dgntNid=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=13  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1auwRy{VTV1\91\93n¡¥\82rvS\88\8civzYRW7Y^>\81\86h³º\9bhoPSY=\92\98|¬²\96\83\85`\8b\8dhac>rtO\93\97t\80\84a}\81^\81\85d\82\87g\8a\8footTJQ2<C$pvZhnRDJ.\95\97r±³\8e\94\96quwR\88\8ci\7f\83`fjI}\83ax~\[`@;@ ?F'cjKryZ9?#RX<dfA\85\87b}\81\quR\80\84a}\81^ptSy\7f]ioMglLBI(:A"ZaBv}^\cD~\85f^b?cgD]a>txUw{XswT\87\8dku{YgmKz\81`T[:T[:_fGx\81b{\84er{\\84\88e\7f\83`w{X\81\85b[_<KQ/}\83ay\7f]krPkrQY`?\88\8fnv\80^V`>_iGnwXuyVswTx|[mqPNT2KQ/ioM}\84bw~\\8d\94r{\82amwUPZ8MW5S];nxV{\7f^jnMlrPZ`>ntR\81\87e^eChoMbiG\80\87e{\85bdnKdnKu\7f\U_=w\82`\8a\8forwWrxV\82\88f\98\9e|nuSdkIRY7~\85c\8b\95rnxUGQ.EQ-Xd@coKp|X|\81aejJ~\83cv{[t{Z[bAahF\85\8cjnxUu\7f\lvSNZ6NZ6P\8Zf@\hB\86\8bmSX8kpPelKryXpwVdkJ\8e\98ux\82_`jGgsO[gA\hB<H"IU/MY3w~_ZaBx\7f`~\85fv}\fmL_iG\92\9cys}ZfrNw\83]Q]7Wc=L[4etMIX1\80\87hmtUipQ\81\88iz\81b`jHblJ|\86c^hE\7f\8bg\94 zKW1YhA\86\95l¤³\8a\kB\8d\93wntXJQ2jqRpyZhrPdnLfpM@L(Q]9`lF8G KZ1bqHr\81XJY0[aEY_C]cGnuVZcD[eCV`>q|ZhtPXd>Ua;ZiBixOYh?Xg>crI?E)8>"Y_ClsTenOx\81bMW5`kInzVq}W]iCWf?etKixObqHl{Rid=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=14  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1a;Q+E[5?U/Qe@z\8ei{\8cheuQjxUx\83aozXpzXlsRdiIJO/@E%nsSF\6I_9G]7Qe@ZkGM^:Td@x\86c\80\8bix\83ar|ZahGcjImrRejJotTF\6J`:RfASgBGX4=N*Td@x\86cR];Q[9Q[9<C"FM,tyY{\80`mrRG[6I]8RfATeAK\8N^:XhD\jG\gET^<^hFQX7NU4tyY\82\87g{\80`WkFGX4FW3N_;L\8IY5Q_<Uc@bmKDN,R\:dkJelKrwWy~^\83\88hbsOFW3:K'GW3FV2;I&P^;|\87ealJ3=\e;E#biHt{ZmrR^cClqQXhDVfBEU1<L(@N+=K(Q\:z\85cx\82`YcAYcAqxW\82\89hpwVPU5X]=KY6m{XZhE2@\1d8F#GR0BM+EP.<F$@J(LV4X_>mtSgnMMT3Za@P[9u\80^s~\9D"@K)FQ/PZ8FP.AK)^hFbiHfmL[bAY`?nuTY`?bmKU`>YcAPZ89C!V`>fpNGQ/DN,nxVpwVqxWy\80_`gFZa@szYeoMU_=6@\1eT^<oyW\92\9cz|\86ds}[QX7]dCqxW|\83b}\84c_fEIP/gnM|\83bszYFM,FM,ahGpwV]dCjqPkrQEL+x\7f^\90\97vryXjqP[bAOV5\8b\92qz\81`|\83bX_>7>\1d<C"elKbiH^eDDK*y\80_\87\8emhoNlsRblJPZ8qvV\7f\84d\95\9azuzZqvVjoO}\84cpwV@G&`gFv}\ovUovUisQakIw\81__dD\86\8bk\86\8bkw|\\87\8cluzZX]=V]<KR1ryXlsRipOx\82`pzXv\80^\91\9bybgGqvV}\82b|\81aGL,KP0SX8Y`?W^=T[:FM,\cB`jH`jH{\85ct~\id=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=15  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1a\84\8dr\8a\93x\8c\95zt|d{\83k\92\9a\82w\7fgV^GX`IHP9IQ<[cN^fQS[FV^IfnY[dIYbGXaFFN6QYAiqYS[C9A*PXARZC[cNfnYfnY_gR_gRemXR[@_hMnw\X`HIQ9RZBT\D_gPJR;[cLlt_rzeqydowblt_hp[clQS\AR[@KS;S[C^fNQYAOW@W_HbjSnvarzepxcjr]ckV^fQEN38A&>G,>F.EM5MU=CK3GO8lt]dlUckVjr]iq\[cNRZERZE7@%HQ6gpUaiQQYAPX@ZbJw\7fhmu^^fOZbMemXjr]bjU]ePaiTYbGW`EenSdlThpXqyahpXmu^^fO\dM\dOaiTgoZiq\goZfnYZcH\eJirW_gOYaI^fNU]EYaJV^GaiRdlW[cNX`K]ePYaLMU@qz_\eJR[@V^F[cKdlTdlTYaJfnWZbK\dOgoZiq\ks^iq\^fQ`iNZcH^gL^fNQYAT\DiqYx\80igoXnv_nva_gRX`Khp[jr]U]H09\1e2; MV;hpXgoW_gO_gO_gPZbKemViq\W_JIQ<S[FV^ICK6[dIKT9R[@hpXjrZ`hPZbJT\E^fO\dMgoZlt__gRU]HRZEKS>ajOW`EajOpx`ks[aiQaiQ`hQaiRZbKbjUks^fnY`hS[cNPXCV_DPY>\eJmu]px`mu]dlTV^G]eN^fO\dORZET\Ghp[hp[NVAz\83hktY`iNX`HU]E^fNaiQU]F`hQ`hQ^fQT\GYaLqydv~i^fQ:C(NW<ajOW_GBJ2GO7X`H\dMS[DHP9LT?X`K]ePdlWiq\ckVid=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=16  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1aW[:\94\97x\91\96v\88\8dmRY8OY7pyZ\7f\8ajhvU\kJ\81\92r|\8foZoNRgFRgHc{[glLlqQmrRW\<X_>dnLcnNYdDTbAIX9bsSWjJAT4G\;OdE_tU`eEbgG~\85dDK*:A ;E#CN.T_?O]<Q`An}^m~^[lLReGDW9>Q3\86\8dly\80_u\7f]OY7R\:^gH\gGXcCx\85gq~`u\84eu\84ehwZXgJJZ=HX;t~\pzXNX6]gElwW\82\8dm|\87g_jJt\7faivXerTr\7fcp}aVcGN[?UbF;F$\gEJU3grR\gGfqQp{[epR_jLcnP]gLpz_t~cYcHT^C\fK]kJdrQ\jI]kJ_jJgrRhsUalNr}_}\86k[dIOX=T]BT\Dlt\|\84l}\8bjlzYy\87fN\;R]=WbD^iKlwYbkP\81\8ao`iNJP6PU>[`Iw|e{\80ir\80_kyX]hHNY;cnPfqSCN0AJ/FO4gpUNS<MR;W\EV[D9>'UZCalNq|^]hJWbD\86\8frt}`GP5ox]JS8Y^GOT=KP9LQ:W\E`eOx}gox[QZ=gpSox[_hKpy^y\82gnw\\aJ[`IfkT]bKQV@OT>ejTmr\fjOjnShlQMQ6X^D\7f\85k\7f\85ku{aW\EU]E_gOLT=MU>9A*FN7MU>hkPilQmpU[]EimT\92\96}\89\8dtmr[X]F_gOS[D<D-\fNHR:LV>hrZ\84\82i\\D\80\80h\91\91yxzb\89\8bs\83\87pPU>diRrzb\dMOYAt~f^jRMYCjv`\87\82l\8f\8dv\8c\8as\7f}f\89\89qwyaRT>]aJ^cLdlUS]EYcKamUT`J;I2JXA\97\92|\94\8fy\9c\97\81zxa\\DkkSnpZgkT`eNS[DFP8VbJIU=SaJQ_H]kTid=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=17  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1a\`GgkRTX?Y]D\85\89r\85\89rdhQ`cN\85\88s\8a\8dx^aLsvc¢¥\92\8b\8e{|\7fl\8c\8f|\86\8aq\8b\8fv\83\87nqu\gkRlpY{\7fh\8b\8fx]`K]`Kmp[\94\97\82\91\94\81~\81n\85\88uqta\88\8cq\7f\83h\84\88m\81\85lsw^|\80g\8a\8eu\81\85nhlUhlU\82\85p\9b\9e\89\7f\82mnq\twbUXCotVimRptY\80\84i\8f\93x\93\97|\82\86meiPkoV{\7ff\7f\83l\83\87p\85\89rx|ehkV]`KjoQ\7f\84fx}_ty[\86\8bm\7f\84flpUquZjnSx|c~\82ivzaqu\gkTRV?KO8hmM\86\8bkw|\ejJtyYjoQ]bDuz\y}bgkPy}bhlQ;?&=A(FJ1=A(ekIu{YsyWkpPpuUkpPejJmrTuz\]bDfjOUY>=A&JN3VZ?cgLouSv|Z\87\8dk\82\88fjoOjoOz\7f_{\80`}\82d}\82dlqSW[@sw\mqVGK0imRRX6_eC\86\8cj\8e\94rfkKX]=diI`eE|\81c\83\88j\80\85gquZhlQlpUtx]uy^hnLtzXkqOjoOz\7f_otThmM\81\86hinPsxZrv[hlQkoT{\7fd\7f\83hvz_w|\~\83cdiIX]=uzZ\82\87i|\81c\85\8alz~c}\81fsw\cgLcgNlpWbfMMQ8otVlqSpuWchJ\aC\80\85g\8c\90ufjOw{`pt[gkRcgNfjQgkT^bKSW@\aCRV;]aFdhMbfKvz_z~eX\CosZaeL]aJhlUmqZgkTfiTloZQU:GK0;?$W[B}\81hnrYW[BimVnr[`dM]`KgjUhkV^aL]`KgjUOS:NR9GK2]aHy}dfjSSW@koXZ]HY\GZ]H_bMehUhkXgjWdgTPT;VZArv]uy`[_H\`IhlUX[FadOjmXilWadQfiVrubjmZTWDid=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=18  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1a\81\8akdmNjsTgpQMV7\eFoxY]fGKT5mvWÊÓ¶\93\9c\7fKT7z\83f\89\92ux\81d|\86dx\82`pyZy\82cdmN`iJ|\85fbkLPY:t}^¡ª\8bnwXhqR\93\9c}\87\90sajM}\84c\83\8ai^eD`gFV]<X_>\90\97v\87\8emt{\\9b¢\83\9d¤\85ipQw~_sz[ovWhoPioMy\7f]kqOkqOjpNqwU\94\9ax\96\9b{ÁƦª¯\8fw|\bgG\82\87g`eGdiKafHouOpvP\80\86blrNhnJ~\84`\81\87c\91\97u¼Â \93\99wdiI`eEinNUZ:w|\nsS\89\8efw|T\8f\94lkoJ[_:~\82]y}Z\8b\8fl\89\8dj\87\8bjuyXimLKN/adE\91\94u}\80awyQprJ\95\97o\8a\8cevxQ\8d\8fh\8a\8cg~\80[\8b\8cj\89\8ahhiIbcCTU5\92\93t\98\99znoPWZ/SV+hjBlnF[]5wyR\97\99r\81\83^\80\82]\8d\8ellmMhiIQR2\8d\8eo\86\87h\82\83dpsHbe:_b7HK _a9\8c\8eg\86\88a|~Y\8e\90k|}[{|\XY9cdE\88\89j\82\83d\9d\9d\81\81\84YsvK\88\8b`vyN\8c\8ef\8b\8df\80\82[uwRz{YopPqrRST5ddH\8a\8an\7f\7fc\8e\8er\88\8ebz\80T\8f\95imrI{\80WnsK\85\89d\91\95r\82\86e\86\8ai\89\8cmbeHadI{~cqtY}\7fgbi=x\7fS\87\8edW^4EL#JP*v|V\8e\94pgmK\84\89i\93\98zkoT[_Fpt[z~g\92\96\7f;B\16\86\8dc\96\9dsnuL3:\11DJ$W]9]cAPU5ty[\85\89nimTZ^GeiRnq\\80\83nQZ/\99¢w\94\9dr{\83Z:B\eS[6\cA^eD]dEsy]w}clqZlq[kpZbgS]bNp{P\86\91fq|Ry\84Z^iAblGlvSpzXdmPmv[hpXmu^z\82mx\80kovdgn\hsH\g=Yd:\8d\98p\99£~oyV`jHU^?y\82e{\84iks[jr[mu`cjXbiWcjXid=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=19  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1aYX:mnOklM]^?dgHvyZw|\tyYovUx\82`YcAmxV]hFMX6GU2N\9deFcdEfgHuxY\7f\82cnqR]bBafF\cBw\81_]gE]gENY7XcAWb@KV4]`A|\7f`\8f\92s\8d\90q\84\89ityYhmMhoNZa@ahGWa?pzXoyWoyWu\80^~\89gy~^AF&16\16ipO\8b\92qdkJFM,X_>^eDQX7V]<t{ZmwU[eC]gElvTisQFP.)3\11?I'nxVw\81_`gFNU4MT3KR1_fEcjI_fE`gFahGV]<`kI;F$5@\1e]hFlwUKU3JT2w\81_^eDEL+dkJpuUpuUlqQv{[{\80``nK[iFSa>YgDkvTmxVhsQmwU\88\92pKR1biHmrRejJOR3^aBx{\:J&AQ-GW3K[7ES06D!CN,gqO\85\8fmRY8dkJPU5HM-LO0ehIpsTEV28H$9I%O_;FT1v\84az\85cS^<lvTpwVpwVglL7<\1c>C#{~_svWO_;N^:8H$M]9aoLq\7f\`nKnyW[eCmwU\89\90o\92\99xfmLUZ:nsSX]=UeASc?@P,P^;`nKcqNO]:YdBVa?MW5jtR¡«\89\98¢\80qxW]dCBI(ZhECQ.HV3Q_<LZ7m{X{\86dVa?mxV_jHcnL}\88f\89\94r\80\8bip{YYdBs~\Q\:P[9P[9LW5cnLmxVDO-\jGz\88et\82_HV3ES0ftQm{XbpMv\80^isQcmKkuS\86\91ofqOGR0>I'9G$Tb?]mIK[7Qa=Rb>?O+JZ6]dC\cBlsR}\87e¡«\89\81\8cjlwUguR>L)EU1Td@csOz\8bg`qM1B\1eIZ6]dCEL+]dCY`?Xb@`jH}\88f_mJFT1hxTjzVBS/Qb>ZnI=Q,Pd?id=ImageMagick  version=1.0
+class=DirectClass  matte=False
+columns=16  rows=16  depth=8
+Resolution=72x72  units=pixels-per-inch
+page=16x16+0+0
+scene=20  iterations=0  delay=0
+JPEG-Quality=75
+JPEG-Colorspace=2
+JPEG-Colorspace-Name=RGB
+JPEG-Sampling-factors=2x2,1x1,1x1
+\f
+:\1ajzVaqM=M)XhD\7f\8fkw\87bv\84`s\81]esO\88\94namG9E\1fiuOWa<}\87boyT]mI\87\97sk{WL\8WgCjzUr\80\[iEWeAgsO\81\8dgfrL\hBYc>|\86afpKXhD\7f\8fkw\87cdtP]mIQ_;O]9M[7AO+GS/myUXd>@J%MW2`jE\fARb>ZjFYiEfvRlzVP^:KY5ftPmyU|\88dr~ZkuR{\85b\84\8ek|\86c\86\90mHX4YiEQa<AO+R`<guQo}Y\81\8di_kGlxTNZ6dnKy\83`pzWr|Y`jGWgBhxSaoKBP,Q_;lzVgrPlwUcnLNY7GQ/fpNV`>JT2\7f\86eRY8q\7f[cqMYgCR`<lzVq|ZHS1DO-mxVHR0[eChrP\cDQX9\8c\93tqxYw\85aWeA@N*=K's\7f[\88\93qOZ82=\eV`>CL-foPcjK\80\87hkrSy\80a\7f\85iy\87clzVUa=LX4LX4lwUWb@JT2foPdmN|\83dntXy\7fc\80\86j\87\8dqx~bP\6`lHZfB`lHXd@juSdnL]fGoxYkqUw}alrVou[cgNtx_\87\8brR^8\hBHT0p|X\84\90l\92\9cz\85\8fmajK\86\8dnv|`v|`\82\86m\93\97~`dMLP9W[D`lFy\85_amG\86\90m\80\8agv\80^~\88flsTv|`\84\8an\84\8ap{\7ffrv_59"FI4|\7fj\83\8fi\8f\9buhrM{\85bcmJOY7_fGY`AU[?\bHCG.59"JN747"VYDz|g\95\9fz\87\91lZd?kuR^hET^<^eFahI\bF\83\87nuybPT=DG279${|j¢£\91mwRr|WnxSx\82_V`=PW6dkL\90\97x\90\96z\95\99\80fjS;>):<'@A/\85\86t\8a\8bycmHYc>]gBnxU[eB\cB\cD\83\89m\7f\85i\92\96}~\82kgjU_aLYZH\94\95\83\89\8ax
\ No newline at end of file
diff --git a/PerlMagick/t/wmf/fulltest.wmf b/PerlMagick/t/wmf/fulltest.wmf
new file mode 100644 (file)
index 0000000..42c825a
Binary files /dev/null and b/PerlMagick/t/wmf/fulltest.wmf differ
index ca0d9fb..877e78d 100644 (file)
@@ -113,8 +113,7 @@ building under Microsoft Windows:
 
   to annotate with TrueType and Postscript Type 1 fonts.
 
-* GraphicsMagick requires Ghostscript software (version 9.04
-  recommended) available from
+* GraphicsMagick requires Ghostscript software available from
 
     http://pages.cs.wisc.edu/~ghost/
 
@@ -128,6 +127,16 @@ building under Microsoft Windows:
 
     https://sourceforge.net/projects/gs-fonts/
 
+  Ghostscript (at the time this text is written in October, 2018) has
+  been observed to have severe security issues when reading untrusted
+  Postscript files (does not apply to PDF).  Examples of these severe
+  security issues are being tricked into reading or writing arbitrary
+  files when executing in "-dSAFER" mode, which which is supposed to
+  prevent such access.  Users of Ghostscript who may encounter
+  untrusted Postscript files are recommended to assure that all
+  security patches have been applied and it might be necessary to use
+  the latest upstream release.
+
   Ghostscript is available for use under both free (GPL) and
   commercial licenses.  We are not lawyers so we can not provide
   advice as to when the commercial license from Artifex is required.
@@ -344,9 +353,16 @@ building under Microsoft Windows:
 
   to read or write the PNG or Zip compressed MIFF images.
 
+* GraphicsMagick requires the Zstd library from
+
+     https://facebook.github.io/zstd/
+
+  to read or write Zstd compressed TIFF images.  In the future it is
+  likely that other purposes will be found for Zstd.
+
 
 --------------------------------------------------------------------------
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index d513d73..c06ca51 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+       * generic/TclMagick.c (wandObjCmd): Support Zstd and WebP
+       compressions added by GraphicsMagick 1.3.31.
+
 2017-06-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
        * generic/TclMagick.c (magickCmd): Resolve SourceForge patch #51
index ae1fce3..6a6b5c6 100644 (file)
@@ -164,14 +164,14 @@ static TclMagickObj *newMagickObj(Tcl_Interp  *interp, int type, void *wandPtr,
     mPtr->wandPtr = wandPtr;
     switch(type) {
     case TM_TYPE_WAND:
-       mPtr->magickCmd = Tcl_CreateObjCommand(interp, name, wandObjCmd, (ClientData)mPtr, magickObjDeleteCmd);
-       break;
+        mPtr->magickCmd = Tcl_CreateObjCommand(interp, name, wandObjCmd, (ClientData)mPtr, magickObjDeleteCmd);
+        break;
     case TM_TYPE_DRAWING:
-       mPtr->magickCmd = Tcl_CreateObjCommand(interp, name, drawObjCmd, (ClientData)mPtr, magickObjDeleteCmd);
-       break;
+        mPtr->magickCmd = Tcl_CreateObjCommand(interp, name, drawObjCmd, (ClientData)mPtr, magickObjDeleteCmd);
+        break;
     case TM_TYPE_PIXEL:
-       mPtr->magickCmd = Tcl_CreateObjCommand(interp, name, pixelObjCmd,(ClientData)mPtr, magickObjDeleteCmd);
-       break;
+        mPtr->magickCmd = Tcl_CreateObjCommand(interp, name, pixelObjCmd,(ClientData)mPtr, magickObjDeleteCmd);
+        break;
     }
 
     return mPtr;
@@ -302,107 +302,107 @@ static int magickCmd(
 
     case TM_CREATE:    /* magick create type ?name? */
     {
-       char *name;
-       int   type;
-       TclMagickObj *mPtr;
-
-       if( (objc < 3) || (objc > 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "type ?name?");
-           return TCL_ERROR;
-       }
-       /*
-        * Get type parameter
-        * If no creation ?name? is specified, set name=NULL
-        */
-       if (Tcl_GetIndexFromObj(interp, objv[2], objTypeNames, "type", 0, &type) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       if( objc > 3 ) {
-           name = Tcl_GetString(objv[3]);
-       } else {
-           name = NULL;
-       }
-       mPtr = newMagickObj(interp, type, NULL, name);
-       name = getMagickObjName(mPtr);
-       Tcl_SetResult(interp, name, TCL_VOLATILE);
-
-       break;
+        char *name;
+        int   type;
+        TclMagickObj *mPtr;
+
+        if( (objc < 3) || (objc > 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "type ?name?");
+            return TCL_ERROR;
+        }
+        /*
+         * Get type parameter
+         * If no creation ?name? is specified, set name=NULL
+         */
+        if (Tcl_GetIndexFromObj(interp, objv[2], objTypeNames, "type", 0, &type) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        if( objc > 3 ) {
+            name = Tcl_GetString(objv[3]);
+        } else {
+            name = NULL;
+        }
+        mPtr = newMagickObj(interp, type, NULL, name);
+        name = getMagickObjName(mPtr);
+        Tcl_SetResult(interp, name, TCL_VOLATILE);
+
+        break;
     }
 
     case TM_DELETE:    /* magick delete name name ...*/
     {
-       int      i;
-       char *name;
-       TclMagickObj *mPtr;
+        int      i;
+        char *name;
+        TclMagickObj *mPtr;
 
-       for (i = 2; i < objc; i++) {
-           name = Tcl_GetString(objv[i]);
-           mPtr = findMagickObj(interp, TM_TYPE_ANY, name);
-           if (mPtr == NULL) {
-               return TCL_ERROR;
-           }
-           deleteMagickObj(mPtr);
-       }
-       break;
+        for (i = 2; i < objc; i++) {
+            name = Tcl_GetString(objv[i]);
+            mPtr = findMagickObj(interp, TM_TYPE_ANY, name);
+            if (mPtr == NULL) {
+                return TCL_ERROR;
+            }
+            deleteMagickObj(mPtr);
+        }
+        break;
     }
 
     case TM_NAMES:    /* magick names ?type? */
     {
-       int type = TM_TYPE_ANY;
-       TclMagickObj   *mPtr;
-       Tcl_HashEntry  *hPtr;
-       Tcl_HashSearch search;
-
-       if( objc > 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?type?");
-           return TCL_ERROR;
-       }
-       if( objc > 2 ) {
-           if (Tcl_GetIndexFromObj(interp, objv[2], objTypeNames, "type", 0, &type) != TCL_OK) {
-               return TCL_ERROR;
-           }
-       }
-       hPtr = Tcl_FirstHashEntry(&TM.hashTable, &search);
-       for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
-           mPtr = Tcl_GetHashValue(hPtr);
-           if( (type == TM_TYPE_ANY) || (type == mPtr->type) ) {
-               Tcl_AppendElement(interp, getMagickObjName(mPtr));
-           }
-       }
-       break;
+        int type = TM_TYPE_ANY;
+        TclMagickObj   *mPtr;
+        Tcl_HashEntry  *hPtr;
+        Tcl_HashSearch search;
+
+        if( objc > 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?type?");
+            return TCL_ERROR;
+        }
+        if( objc > 2 ) {
+            if (Tcl_GetIndexFromObj(interp, objv[2], objTypeNames, "type", 0, &type) != TCL_OK) {
+                return TCL_ERROR;
+            }
+        }
+        hPtr = Tcl_FirstHashEntry(&TM.hashTable, &search);
+        for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
+            mPtr = Tcl_GetHashValue(hPtr);
+            if( (type == TM_TYPE_ANY) || (type == mPtr->type) ) {
+                Tcl_AppendElement(interp, getMagickObjName(mPtr));
+            }
+        }
+        break;
     }
 
     case TM_TYPE:    /* magick type name */
     {
-       char *name;
-       TclMagickObj *mPtr;
+        char *name;
+        TclMagickObj *mPtr;
 
-       if( objc != 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "name");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       mPtr = findMagickObj(interp, TM_TYPE_ANY, name);
-       if (mPtr == NULL) {
-           return TCL_ERROR;
-       }
-       Tcl_SetResult(interp, (char *)objTypeNames[mPtr->type], TCL_VOLATILE);
+        if( objc != 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "name");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        mPtr = findMagickObj(interp, TM_TYPE_ANY, name);
+        if (mPtr == NULL) {
+            return TCL_ERROR;
+        }
+        Tcl_SetResult(interp, (char *)objTypeNames[mPtr->type], TCL_VOLATILE);
 
-       break;
+        break;
     }
 
     case TM_TYPES:    /* magick types */
     {
-       int type;
+        int type;
 
-       if( objc != 2) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       for ( type = 0; type < TM_TYPE_ANY; type++ ) {
-           Tcl_AppendElement(interp, objTypeNames[type]);
-       }
-       break;
+        if( objc != 2) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        for ( type = 0; type < TM_TYPE_ANY; type++ ) {
+            Tcl_AppendElement(interp, objTypeNames[type]);
+        }
+        break;
     }
 
     case TM_RESOURCE:      /* resourcelimit resourceType ?limit? */
@@ -410,62 +410,62 @@ static int magickCmd(
         long limit;
         int  resourceIdx;
 
-       if( (objc != 3) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "resourceType ?limit?");
-           return TCL_ERROR;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[2], resourceNames,
-                               "resourceType", 0, &resourceIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       if (objc == 4) {
-           /*
-            * Set channel depth
-            */
-           if( (stat = Tcl_GetLongFromObj(interp, objv[3], &limit)) != TCL_OK ) {
-               return stat;
-           }
-           result = MagickSetResourceLimit(resourceTypes[resourceIdx], (unsigned long) limit);
-           if (!result) {
-               return myMagickError(interp, NULL);
-           }
-       } else {
-           /*
-            * Get channel depth
-            */
-           limit = MagickGetResourceLimit(resourceTypes[resourceIdx]);
-           Tcl_SetObjResult(interp, Tcl_NewLongObj((long)limit));
-       }
-       break;
+        if( (objc != 3) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "resourceType ?limit?");
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[2], resourceNames,
+                                "resourceType", 0, &resourceIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        if (objc == 4) {
+            /*
+             * Set channel depth
+             */
+            if( (stat = Tcl_GetLongFromObj(interp, objv[3], &limit)) != TCL_OK ) {
+                return stat;
+            }
+            result = MagickSetResourceLimit(resourceTypes[resourceIdx], (unsigned long) limit);
+            if (!result) {
+                return myMagickError(interp, NULL);
+            }
+        } else {
+            /*
+             * Get channel depth
+             */
+            limit = MagickGetResourceLimit(resourceTypes[resourceIdx]);
+            Tcl_SetObjResult(interp, Tcl_NewLongObj((long)limit));
+        }
+        break;
     }
 
     case TM_FONTS:    /* fonts pattern */
     {
         unsigned long  i;
-       unsigned long  listLen = 0;
+        unsigned long  listLen = 0;
         Tcl_Obj        *listPtr;
         char           *pattern = "*";
         char          **fonts;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?pattern?");
-           return TCL_ERROR;
-       }
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?pattern?");
+            return TCL_ERROR;
+        }
         if( objc > 2 ) {
             pattern = Tcl_GetString(objv[2]);
         }
 
-       fonts = MagickQueryFonts(pattern, &listLen);
-       if( (fonts != NULL) && (listLen > 0) ) {
+        fonts = MagickQueryFonts(pattern, &listLen);
+        if( (fonts != NULL) && (listLen > 0) ) {
             listPtr = Tcl_NewListObj(0, NULL);
-           for( i=0; i < listLen; i++ ) {
+            for( i=0; i < listLen; i++ ) {
                 Tcl_ListObjAppendElement(interp, listPtr,
-                                        Tcl_NewStringObj(fonts[i], (int)strlen(fonts[i])) );
+                                         Tcl_NewStringObj(fonts[i], (int)strlen(fonts[i])) );
             }
-           Tcl_SetObjResult(interp, listPtr);
+            Tcl_SetObjResult(interp, listPtr);
         }
-       if (fonts != NULL)
-           MagickRelinquishMemory(fonts); /* Free TclMagick resource */
+        if (fonts != NULL)
+            MagickRelinquishMemory(fonts); /* Free TclMagick resource */
 
         break;
     }
@@ -473,101 +473,101 @@ static int magickCmd(
     case TM_FORMATS:    /* formats pattern */
     {
         unsigned long   i;
-       unsigned long   listLen = 0;
+        unsigned long   listLen = 0;
         Tcl_Obj        *listPtr;
         char           *pattern = "*";
         char          **fonts;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?pattern?");
-           return TCL_ERROR;
-       }
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?pattern?");
+            return TCL_ERROR;
+        }
         if( objc > 2 ) {
             pattern = Tcl_GetString(objv[2]);
         }
 
-       fonts = MagickQueryFormats(pattern, &listLen);
-       if( (fonts != NULL) && (listLen > 0) ) {
+        fonts = MagickQueryFormats(pattern, &listLen);
+        if( (fonts != NULL) && (listLen > 0) ) {
             listPtr = Tcl_NewListObj(0, NULL);
-           for( i=0; i < listLen; i++ ) {
+            for( i=0; i < listLen; i++ ) {
                 Tcl_ListObjAppendElement(interp, listPtr,
-                                        Tcl_NewStringObj(fonts[i], (int)strlen(fonts[i])) );
+                                         Tcl_NewStringObj(fonts[i], (int)strlen(fonts[i])) );
             }
-           Tcl_SetObjResult(interp, listPtr);
+            Tcl_SetObjResult(interp, listPtr);
         }
-       if (fonts != NULL)
-           MagickRelinquishMemory(fonts); /* Free TclMagick resource */
+        if (fonts != NULL)
+            MagickRelinquishMemory(fonts); /* Free TclMagick resource */
 
         break;
     }
 
     case TM_VERSION:    /* magick version */
     {
-       if( objc != 2) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       Tcl_SetResult(interp, VERSION, TCL_VOLATILE);
+        if( objc != 2) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        Tcl_SetResult(interp, VERSION, TCL_VOLATILE);
 
-       break;
+        break;
     }
 
     case TM_LIBRARY:    /* magick library ?-option? */
     {
-       static CONST char *options[] = {
-           "-copyright",  "-date",    "-name",       "-quantumdepth", 
-           "-url",        "-version", "-versionstr", "-maxrgb",
-           (char *) NULL
-       };
+        static CONST char *options[] = {
+            "-copyright",  "-date",    "-name",       "-quantumdepth",
+            "-url",        "-version", "-versionstr", "-maxrgb",
+            (char *) NULL
+        };
         char  buf[40];
         const char *str;
         unsigned long depth=0, version=0, maxrgb=0;
 
         if( objc > 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?-option?");
-           return TCL_ERROR;
-       }
-       /*
-        * If called without parameters, return a list of
-        * -option value -option value ...
-        */
-       if( objc == 2 ) {
-           Tcl_Obj *listPtr = Tcl_NewListObj(0, NULL);
+            Tcl_WrongNumArgs(interp, 2, objv, "?-option?");
+            return TCL_ERROR;
+        }
+        /*
+         * If called without parameters, return a list of
+         * -option value -option value ...
+         */
+        if( objc == 2 ) {
+            Tcl_Obj *listPtr = Tcl_NewListObj(0, NULL);
 
             str = MagickGetCopyright();
-           Tcl_ListObjAppendElement(
-               interp, listPtr,
-               Tcl_NewStringObj(options[0], -1));
-           Tcl_ListObjAppendElement(
-               interp, listPtr, Tcl_NewStringObj(str, -1));
+            Tcl_ListObjAppendElement(
+                interp, listPtr,
+                Tcl_NewStringObj(options[0], -1));
+            Tcl_ListObjAppendElement(
+                interp, listPtr, Tcl_NewStringObj(str, -1));
 
             str = MagickGetReleaseDate();
-           Tcl_ListObjAppendElement(
-               interp, listPtr,
-               Tcl_NewStringObj(options[1], -1));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(str, -1));
+            Tcl_ListObjAppendElement(
+                interp, listPtr,
+                Tcl_NewStringObj(options[1], -1));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(str, -1));
 
             str = MagickGetPackageName();
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(options[2], -1));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(str, -1));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(options[2], -1));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(str, -1));
 
             str = MagickGetQuantumDepth(&depth);
             maxrgb = (1 << depth) - 1;
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(options[3], -1));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewLongObj((signed long)depth));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(options[7], -1));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewLongObj((signed long)maxrgb));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(options[3], -1));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewLongObj((signed long)depth));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(options[7], -1));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewLongObj((signed long)maxrgb));
 
             str = MagickGetHomeURL();
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(options[4], -1));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(str, -1));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(options[4], -1));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(str, -1));
 
             str = MagickGetVersion(&version);
             sprintf( buf, "%ld.%ld.%ld", version >> 8, (version >> 4) & 0x0F, version & 0x0F);
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(options[5], -1));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(buf, -1));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(options[6], -1));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(str, -1));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(options[5], -1));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(buf, -1));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(options[6], -1));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewStringObj(str, -1));
 
 
             Tcl_SetObjResult(interp, listPtr);
@@ -575,7 +575,7 @@ static int magickCmd(
             int idx;
 
             if (Tcl_GetIndexFromObj(interp, objv[2], options, "-option", 0, &idx) != TCL_OK) {
-               return TCL_ERROR;
+                return TCL_ERROR;
             }
             switch( idx ) {
             case 0: /* -copyright */
@@ -609,7 +609,7 @@ static int magickCmd(
                 break;
             case 7: /* -maxrgb */
                 MagickGetQuantumDepth(&depth);
-               maxrgb = (1 << depth) - 1;
+                maxrgb = (1 << depth) - 1;
                 Tcl_SetObjResult(interp, Tcl_NewLongObj((signed long)maxrgb));
                 break;
             default:
@@ -618,7 +618,7 @@ static int magickCmd(
 
         }
 
-       break;
+        break;
     }
 
     } /* switch(index) */
@@ -857,7 +857,7 @@ static int wandObjCmd(
         TM_IMAGE_FILENAME,  TM_GET_IMAGE_FILENAME,      TM_SET_IMAGE_FILENAME,
         TM_GAMMA,           TM_GET_GAMMA,               TM_SET_GAMMA,
         TM_GREEN_PRIMARY,   TM_GET_GREEN_PRIMARY,       TM_SET_GREEN_PRIMARY,
-       TM_HEIGHT,          TM_GET_HEIGHT,
+        TM_HEIGHT,          TM_GET_HEIGHT,
         TM_INDEX,           TM_GET_INDEX,               TM_SET_INDEX,
         TM_INTERLACE,       TM_GET_INTERLACE,           TM_SET_INTERLACE,
         TM_ITERATIONS,      TM_GET_ITERATIONS,          TM_SET_ITERATIONS,
@@ -875,12 +875,12 @@ static int wandObjCmd(
         TM_IMAGE_UNITS,     TM_GET_IMAGE_UNITS,         TM_SET_IMAGE_UNITS,
         TM_VIRTUALPIXEL,    TM_GET_VIRTUALPIXEL,        TM_SET_VIRTUALPIXEL,
         TM_WHITE_POINT,     TM_GET_WHITE_POINT,         TM_SET_WHITE_POINT,
-       TM_WIDTH,           TM_GET_WIDTH,
+        TM_WIDTH,           TM_GET_WIDTH,
         TM_NUMBER,          TM_GET_NUMBER_IMAGES,
         TM_SAMPLING_FACTORS,TM_GET_SAMPLING_FACTORS,    TM_SET_SAMPLING_FACTORS,
         TM_SIZE,            TM_GET_SIZE,                TM_SET_SIZE,
-       TM_HASNEXT,         TM_HAS_NEXT_IMAGE,
-       TM_HASPREVIOUS,     TM_HAS_PREVIOUS_IMAGE,
+        TM_HASNEXT,         TM_HAS_NEXT_IMAGE,
+        TM_HASPREVIOUS,     TM_HAS_PREVIOUS_IMAGE,
         TM_IMPLODE,         TM_IMPLODE_IMAGE,
         TM_LABEL,           TM_LABEL_IMAGE,
         TM_LEVEL,           TM_LEVEL_IMAGE,
@@ -1004,7 +1004,7 @@ static int wandObjCmd(
         "divide",    "hardlight",   "exclusion",  "colordodge",
         "colorburn", "softlight",   "linearburn", "lineardodge",
         "linearlight","vividlight", "pinlight",   "hardmix",
-       (char *) NULL
+        (char *) NULL
     };
     static CompositeOperator opTypes[] = {
         UndefinedCompositeOp, OverCompositeOp,        InCompositeOp,         OutCompositeOp,
@@ -1017,7 +1017,7 @@ static int wandObjCmd(
         ColorizeCompositeOp,  LuminizeCompositeOp,    ScreenCompositeOp,     OverlayCompositeOp,
         CopyCyanCompositeOp,  CopyMagentaCompositeOp, CopyYellowCompositeOp, CopyBlackCompositeOp,
         DivideCompositeOp,    HardLightCompositeOp,   ExclusionCompositeOp,  ColorDodgeCompositeOp,
-       ColorBurnCompositeOp, SoftLightCompositeOp,   LinearBurnCompositeOp, LinearDodgeCompositeOp,
+        ColorBurnCompositeOp, SoftLightCompositeOp,   LinearBurnCompositeOp, LinearDodgeCompositeOp,
         LinearLightCompositeOp,VividLightCompositeOp, PinLightCompositeOp,   HardMixCompositeOp
     };
     static CONST char *compressNames[] = {
@@ -1026,9 +1026,13 @@ static int wandObjCmd(
         "jpeg-ls",   "lzw",    "rle",
         "zip"
 #if MagickLibInterfaceNewest > 9
-       /* These enumerations are introduced by GraphicsMagick 1.3.13 */
+        /* These enumerations are introduced by GraphicsMagick 1.3.13 */
         , "lzma",   "jpeg2000", "jbig1",     "jbig2"
 #endif /* MagickLibInterfaceNewest > 9 */
+#if MagickLibInterfaceNewest > 21
+        /* These enumerations are introduced by GraphicsMagick 1.3.31 */
+        , "zstd",   "webp"
+#endif /* MagickLibInterfaceNewest > 21 */
         ,(char *) NULL
     };
     static CompressionType compressTypes[] = {
@@ -1037,10 +1041,15 @@ static int wandObjCmd(
         LosslessJPEGCompression, LZWCompression,    RLECompression,
         ZipCompression
 #if MagickLibInterfaceNewest > 9
-       /* These enumerations are introduced by GraphicsMagick 1.3.13 */
+        /* These enumerations are introduced by GraphicsMagick 1.3.13 */
         ,LZMACompression,         JPEG2000Compression,
-       JBIG1Compression,        JBIG2Compression
+        JBIG1Compression,         JBIG2Compression
 #endif /* MagickLibInterfaceNewest > 9 */
+#if MagickLibInterfaceNewest > 21
+        /* These enumerations are introduced by GraphicsMagick 1.3.31 */
+        ,ZSTDCompression,         WebPCompression
+#endif /* MagickLibInterfaceNewest > 21 */
+
     };
     static CONST char *disposeNames[] = {
         "undefined", "none",    "background",    "previous",
@@ -1141,106 +1150,106 @@ static int wandObjCmd(
     case TM_ADAPTIVE:                   /* adaptive ?width? ?height? ?ofs? */
     case TM_ADAPTIVE_THRESHOLD_IMAGE:   /* AdaptiveThresholdImage ?width? ?height? ?ofs? */
     {
-       unsigned long width=1, height=1;
-       long ofs=0;
-
-       if( (objc > 5) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?width? ?height? ?ofs?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &width)) != TCL_OK) ) {
-           return stat;
-       }
-       height = width; /* default */
-       if( (objc > 3) && ((stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &height)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4], &ofs)) != TCL_OK) ) {
-           return stat;
-       }
-
-       result = MagickAdaptiveThresholdImage(wandPtr, width, height, ofs);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        unsigned long width=1, height=1;
+        long ofs=0;
+
+        if( (objc > 5) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?width? ?height? ?ofs?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &width)) != TCL_OK) ) {
+            return stat;
+        }
+        height = width; /* default */
+        if( (objc > 3) && ((stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &height)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4], &ofs)) != TCL_OK) ) {
+            return stat;
+        }
+
+        result = MagickAdaptiveThresholdImage(wandPtr, width, height, ofs);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_ADD:            /* add name */
     case TM_ADD_IMAGE:      /* AddImage name */
     {
-       MagickWand      *addWand;
-       char            *name;
+        MagickWand      *addWand;
+        char            *name;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "name");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (addWand = findMagickWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       result = MagickAddImage( wandPtr, addWand );
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "name");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (addWand = findMagickWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        result = MagickAddImage( wandPtr, addWand );
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
 
-       break;
+        break;
     }
 
     case TM_ADDNOISE:          /* addnoise ?noiseType? */
     case TM_ADD_NOISE_IMAGE:   /* AddNoiseImage ?noiseType? */
     {
-       static CONST char *noiseNames[] = {
-           "uniform", "gaussian", "multiplicativegaussian", "impulse", "laplacian", "poisson", "random",
-           (char *) NULL
-       };
-       static NoiseType noiseTypes[] = {
-           UniformNoise, GaussianNoise, MultiplicativeGaussianNoise, ImpulseNoise, LaplacianNoise, PoissonNoise, RandomNoise
-       };
-       int noiseIdx=0;
-
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?noiseType=uniform?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && (Tcl_GetIndexFromObj(interp, objv[2], noiseNames, "noiseType", 0, &noiseIdx) != TCL_OK) ) {
-           return TCL_ERROR;
-       }
-       result = MagickAddNoiseImage(wandPtr, noiseTypes[noiseIdx]);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        static CONST char *noiseNames[] = {
+            "uniform", "gaussian", "multiplicativegaussian", "impulse", "laplacian", "poisson", "random",
+            (char *) NULL
+        };
+        static NoiseType noiseTypes[] = {
+            UniformNoise, GaussianNoise, MultiplicativeGaussianNoise, ImpulseNoise, LaplacianNoise, PoissonNoise, RandomNoise
+        };
+        int noiseIdx=0;
+
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?noiseType=uniform?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && (Tcl_GetIndexFromObj(interp, objv[2], noiseNames, "noiseType", 0, &noiseIdx) != TCL_OK) ) {
+            return TCL_ERROR;
+        }
+        result = MagickAddNoiseImage(wandPtr, noiseTypes[noiseIdx]);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_AFFINE_TRANSFORM:       /* affinetransform draw */
     case TM_AFFINE_TRANSFORM_IMAGE: /* AffineTransformImage draw */
     {
-       char    *name;
-       DrawingWand     *drawPtr;
+        char    *name;
+        DrawingWand     *drawPtr;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "draw");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (drawPtr = findDrawingWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "draw");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (drawPtr = findDrawingWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
 
-       result = MagickAffineTransformImage(wandPtr, drawPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        result = MagickAffineTransformImage(wandPtr, drawPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_ANNOTATE:       /* annotate draw ?x y? ?angle? txt */
     case TM_ANNOTATE_IMAGE: /* AnnotateImage draw ?x y? ?angle? txt */
         {
-           char        *name;
-           DrawingWand *drawPtr;
+            char        *name;
+            DrawingWand *drawPtr;
             double      x=0.0, y=0.0, angle=0.0;
             char        *txt="";
 
@@ -1250,22 +1259,22 @@ static int wandObjCmd(
             }
             name = Tcl_GetString(objv[2]);
             if( (drawPtr = findDrawingWand(interp, name)) == NULL ) {
-               return TCL_ERROR;
-           }
-            if( objc >= 6 ) {  /* we have parameters x y */
+                return TCL_ERROR;
+            }
+            if( objc >= 6 ) {   /* we have parameters x y */
                 if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &x)) != TCL_OK ) {
                     return stat;
-               }
+                }
                 if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &y)) != TCL_OK ) {
                     return stat;
-               }
+                }
             }
-            if( objc == 7 ) {  /* we have parameter angle */
+            if( objc == 7 ) {   /* we have parameter angle */
                 if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &angle)) != TCL_OK ) {
                     return stat;
-               }
+                }
             }
-           txt = Tcl_GetString(objv[objc-1]);
+            txt = Tcl_GetString(objv[objc-1]);
 
             result = MagickAnnotateImage(wandPtr, drawPtr, x, y, angle, txt);
             if (!result) {
@@ -1277,948 +1286,948 @@ static int wandObjCmd(
     case TM_APPEND:         /* append ?stack=0? ?newName? */
     case TM_APPEND_IMAGES:  /* AppendImages ?stack=0? ?newName? */
     {
-       int stack=0;
-       MagickWand *newWand;
-       char *name=NULL;
-
-       if( objc > 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?stack=0? ?newName?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetBooleanFromObj(interp, objv[2], &stack)) != TCL_OK) ) {
-           return stat;
-       }
-       if( objc > 3 ) {
-           name = Tcl_GetString(objv[3]);
-       }
-       newWand = MagickAppendImages(wandPtr, stack);
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       name = newWandObj(interp, newWand, name);
-       Tcl_SetResult(interp, name, TCL_VOLATILE);
-
-       break;
+        int stack=0;
+        MagickWand *newWand;
+        char *name=NULL;
+
+        if( objc > 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?stack=0? ?newName?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetBooleanFromObj(interp, objv[2], &stack)) != TCL_OK) ) {
+            return stat;
+        }
+        if( objc > 3 ) {
+            name = Tcl_GetString(objv[3]);
+        }
+        newWand = MagickAppendImages(wandPtr, stack);
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        name = newWandObj(interp, newWand, name);
+        Tcl_SetResult(interp, name, TCL_VOLATILE);
+
+        break;
     }
 
     case TM_AVERAGE:        /* average ?newName? */
     case TM_AVERAGE_IMAGES: /* AverageImages ?newName? */
     {
-       MagickWand *newWand;
-       char *name=NULL;
+        MagickWand *newWand;
+        char *name=NULL;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
-           return TCL_ERROR;
-       }
-       if( objc > 2 ) {
-           name = Tcl_GetString(objv[2]);
-       }
-       newWand = MagickAverageImages(wandPtr);
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       name = newWandObj(interp, newWand, name);
-       Tcl_SetResult(interp, name, TCL_VOLATILE);
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
+            return TCL_ERROR;
+        }
+        if( objc > 2 ) {
+            name = Tcl_GetString(objv[2]);
+        }
+        newWand = MagickAverageImages(wandPtr);
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        name = newWandObj(interp, newWand, name);
+        Tcl_SetResult(interp, name, TCL_VOLATILE);
 
-       break;
+        break;
     }
 
 
     case TM_BLACK_THRESHOLD:        /* blackthreshold thresholdPixel */
     case TM_BLACK_THRESHOLD_IMAGE:  /* BlackThresholdImage thresholdPixel */
     {
-       char        *name;
-       PixelWand   *threshPtr;
+        char        *name;
+        PixelWand   *threshPtr;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "thresholdPixel");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (threshPtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "thresholdPixel");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (threshPtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
 
-       result = MagickBlackThresholdImage(wandPtr, threshPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        result = MagickBlackThresholdImage(wandPtr, threshPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_BLUR:        /* blur ?radius? ?sigma? */
     case TM_BLUR_IMAGE:  /* BlurImage ?radius? ?sigma? */
     {
-       double  radius=0.0, sigma=1.0;
-
-       if( objc > 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0? ?sigma=1.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &sigma)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickBlurImage(wandPtr, radius, sigma);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double  radius=0.0, sigma=1.0;
+
+        if( objc > 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0? ?sigma=1.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &sigma)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickBlurImage(wandPtr, radius, sigma);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_BORDER:        /* border borderPixel ?width? ?height? */
     case TM_BORDER_IMAGE:  /* BorderImage borderPixel ?width? ?height? */
     {
-       unsigned long width=1, height=1;
-       char        *name;
-       PixelWand   *borderPtr;
-
-       if( (objc < 3) || (objc > 5) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "borderPixel ?width=1? ?height=width?");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (borderPtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &width)) != TCL_OK) ) {
-           return stat;
-       }
-       height = width; /* default */
-       if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4], (long int *) &height)) != TCL_OK) ) {
-           return stat;
-       }
-
-       result = MagickBorderImage(wandPtr, borderPtr, width, height);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        unsigned long width=1, height=1;
+        char        *name;
+        PixelWand   *borderPtr;
+
+        if( (objc < 3) || (objc > 5) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "borderPixel ?width=1? ?height=width?");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (borderPtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &width)) != TCL_OK) ) {
+            return stat;
+        }
+        height = width; /* default */
+        if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4], (long int *) &height)) != TCL_OK) ) {
+            return stat;
+        }
+
+        result = MagickBorderImage(wandPtr, borderPtr, width, height);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_CHARCOAL:        /* charcoal ?radius? ?sigma? */
     case TM_CHARCOAL_IMAGE:  /* CharcoalImage ?radius? ?sigma? */
     {
-       double  radius=0.0, sigma=1.0;
-
-       if( objc > 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0? ?sigma=1.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &sigma)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickCharcoalImage(wandPtr, radius, sigma);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double  radius=0.0, sigma=1.0;
+
+        if( objc > 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0? ?sigma=1.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &sigma)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickCharcoalImage(wandPtr, radius, sigma);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_CHOP:        /* chop width height ?x y? */
     case TM_CHOP_IMAGE:  /* ChopImage width height ?x y? */
     {
-       unsigned long width, height;
-       long x=0, y=0;
-
-       if( (objc < 4) || (objc > 6) || (objc == 5) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "width height ?x=0 y=0?");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &width)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &height)) != TCL_OK ) {
-           return stat;
-       }
-       if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4], &x)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 5) && ((stat = Tcl_GetLongFromObj(interp, objv[5], &y)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickChopImage(wandPtr, width, height, x, y);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        unsigned long width, height;
+        long x=0, y=0;
+
+        if( (objc < 4) || (objc > 6) || (objc == 5) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "width height ?x=0 y=0?");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &width)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &height)) != TCL_OK ) {
+            return stat;
+        }
+        if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4], &x)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 5) && ((stat = Tcl_GetLongFromObj(interp, objv[5], &y)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickChopImage(wandPtr, width, height, x, y);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_CLIP:        /* clip */
     case TM_CLIP_IMAGE:  /* ClipImage */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       result = MagickClipImage(wandPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        result = MagickClipImage(wandPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
 
     case TM_CLIP_PATH:          /* clip pathname ?inside=0? */
     case TM_CLIP_PATH_IMAGE:    /* ClipImage pathname ?inside=0? */
     {
-       int inside=0;
-       char *pathname=NULL;
+        int inside=0;
+        char *pathname=NULL;
 
-       if( (objc < 3) || (objc > 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "pathname ?inside=0?");
-           return TCL_ERROR;
-       }
+        if( (objc < 3) || (objc > 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "pathname ?inside=0?");
+            return TCL_ERROR;
+        }
         pathname = Tcl_GetString(objv[2]);
-       if( (objc > 3) && ((stat = Tcl_GetBooleanFromObj(interp, objv[3], &inside)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickClipPathImage(wandPtr, pathname, inside );
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( (objc > 3) && ((stat = Tcl_GetBooleanFromObj(interp, objv[3], &inside)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickClipPathImage(wandPtr, pathname, inside );
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_CLONE:       /* clone ?newName? */
     case TM_CLONE_WAND:  /* CloneWand ?newName? */
     {
-       MagickWand *newWand;
-       char *name=NULL;
+        MagickWand *newWand;
+        char *name=NULL;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
-           return TCL_ERROR;
-       }
-       if( objc > 2 ) {
-           name = Tcl_GetString(objv[2]);
-       }
-       newWand = CloneMagickWand(wandPtr);
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       name = newWandObj(interp, newWand, name);
-       Tcl_SetResult(interp, name, TCL_VOLATILE);
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
+            return TCL_ERROR;
+        }
+        if( objc > 2 ) {
+            name = Tcl_GetString(objv[2]);
+        }
+        newWand = CloneMagickWand(wandPtr);
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        name = newWandObj(interp, newWand, name);
+        Tcl_SetResult(interp, name, TCL_VOLATILE);
 
-       break;
+        break;
     }
 
     case TM_COALESCE:        /* coalesce ?newName? */
     case TM_COALESCE_IMAGES: /* CoalesceImages ?newName? */
     {
-       MagickWand *newWand;
-       char *name=NULL;
+        MagickWand *newWand;
+        char *name=NULL;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
-           return TCL_ERROR;
-       }
-       if( objc > 2 ) {
-           name = Tcl_GetString(objv[2]);
-       }
-       newWand = MagickCoalesceImages(wandPtr);
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       name = newWandObj(interp, newWand, name);
-       Tcl_SetResult(interp, name, TCL_VOLATILE);
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
+            return TCL_ERROR;
+        }
+        if( objc > 2 ) {
+            name = Tcl_GetString(objv[2]);
+        }
+        newWand = MagickCoalesceImages(wandPtr);
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        name = newWandObj(interp, newWand, name);
+        Tcl_SetResult(interp, name, TCL_VOLATILE);
 
-       break;
+        break;
     }
 
     case TM_COLOR_FLOODFILL:        /* colorfloodfill fillPixel ?fuzz? ?borderPix? ?x y? */
     case TM_COLOR_FLOODFILL_IMAGE:  /* ColorFloodfillImage ?fuzz? ?borderPix? ?x y? */
-                                   /* - empty borderPix is allowed */
-    {
-       int     x=0, y=0;
-       double  fuzz=0.0;
-       char    *name;
-       PixelWand *fillPtr, *borderPtr = NULL;
-
-       if( (objc < 3) || (objc > 7) || (objc == 6) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "fillPixel ?fuzz=0.0? ?borderPix=fillPix? ?x=0 y=0?");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (fillPtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &fuzz)) != TCL_OK) ) {
-           return stat;
-       }
-       if( objc > 4 ) {
-           name = Tcl_GetString(objv[4]);
-           if( noWandObj(name) ) {
-               borderPtr = NULL;
-           } else if( (borderPtr = findPixelWand(interp, name)) == NULL ) {
-               return TCL_ERROR;
-           }
-       }
-       if( (objc > 5) && ((stat = Tcl_GetIntFromObj(interp, objv[5], &x)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 6) && ((stat = Tcl_GetIntFromObj(interp, objv[6], &y)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickColorFloodfillImage(wandPtr, fillPtr, fuzz, borderPtr, x, y);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+                                    /* - empty borderPix is allowed */
+    {
+        int     x=0, y=0;
+        double  fuzz=0.0;
+        char    *name;
+        PixelWand *fillPtr, *borderPtr = NULL;
+
+        if( (objc < 3) || (objc > 7) || (objc == 6) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "fillPixel ?fuzz=0.0? ?borderPix=fillPix? ?x=0 y=0?");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (fillPtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &fuzz)) != TCL_OK) ) {
+            return stat;
+        }
+        if( objc > 4 ) {
+            name = Tcl_GetString(objv[4]);
+            if( noWandObj(name) ) {
+                borderPtr = NULL;
+            } else if( (borderPtr = findPixelWand(interp, name)) == NULL ) {
+                return TCL_ERROR;
+            }
+        }
+        if( (objc > 5) && ((stat = Tcl_GetIntFromObj(interp, objv[5], &x)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 6) && ((stat = Tcl_GetIntFromObj(interp, objv[6], &y)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickColorFloodfillImage(wandPtr, fillPtr, fuzz, borderPtr, x, y);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_COLORIZE:       /* colorize fillPixel opacityPixel */
     case TM_COLORIZE_IMAGE: /* ColorizeImage fillPixel opacityPixel */
     {
-       char    *name;
-       PixelWand       *fillPtr, *opacityPtr;
-
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "fillPixel opacityPixel");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (fillPtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[3]);
-       if( (opacityPtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-
-       result = MagickColorizeImage(wandPtr, fillPtr, opacityPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        char    *name;
+        PixelWand       *fillPtr, *opacityPtr;
+
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "fillPixel opacityPixel");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (fillPtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[3]);
+        if( (opacityPtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+
+        result = MagickColorizeImage(wandPtr, fillPtr, opacityPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_COMMENT:        /* comment str */
     case TM_COMMENT_IMAGE:  /* CommentImage str */
     {
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "str");
-           return TCL_ERROR;
-       }
-       result = MagickCommentImage(wandPtr, Tcl_GetString(objv[2]));
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "str");
+            return TCL_ERROR;
+        }
+        result = MagickCommentImage(wandPtr, Tcl_GetString(objv[2]));
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
 
-       break;
+        break;
     }
 
     case TM_COMPARE_CHANNELS:        /* comparechannels refName chan metric */
     case TM_COMPARE_IMAGE_CHANNELS:  /* CompareImageChannels refName chan metric */
     {
-       MagickWand      *refWand, *newWand;
+        MagickWand      *refWand, *newWand;
         int             metricIdx, chanIdx;
-       char            *name;
-       double          value;
-
-       if( objc != 5 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "refName");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (refWand = findMagickWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[3], chanNames,
-                               "channelType", 0, &chanIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[4], metricNames,
-                               "metricType", 0, &metricIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       newWand = MagickCompareImageChannels( wandPtr, refWand, chanTypes[chanIdx],
-                                             metricTypes[metricIdx], &value );
-       if (newWand != NULL) {
-            DestroyMagickWand(newWand);
-       } else {
-           myMagickError(interp, wandPtr);
-           return TCL_ERROR;
-       }
-       Tcl_SetObjResult(interp, Tcl_NewDoubleObj(value));
-
-       break;
-    }
-
-    case TM_COMPARE:         /* compare refName metric */
-    case TM_COMPARE_IMAGES:  /* CompareImages refName metric */
-    {
-       MagickWand      *refWand, *newWand;
-        int             metricIdx;
-       char            *name;
-       double          value;
-
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "refName metric");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (refWand = findMagickWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[3], metricNames,
-                               "metricType", 0, &metricIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       newWand = MagickCompareImages( wandPtr, refWand, metricTypes[metricIdx], &value );
-       if (newWand != NULL) {
-            DestroyMagickWand(newWand);
-       } else {
-           myMagickError(interp, wandPtr);
-           return TCL_ERROR;
-       }
-       Tcl_SetObjResult(interp, Tcl_NewDoubleObj(value));
-
-       break;
-    }
+        char            *name;
+        double          value;
 
-    case TM_COMPOSITE:          /* composite compWand opType ?x y? */
+        if( objc != 5 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "refName");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (refWand = findMagickWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[3], chanNames,
+                                "channelType", 0, &chanIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[4], metricNames,
+                                "metricType", 0, &metricIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        newWand = MagickCompareImageChannels( wandPtr, refWand, chanTypes[chanIdx],
+                                              metricTypes[metricIdx], &value );
+        if (newWand != NULL) {
+            DestroyMagickWand(newWand);
+        } else {
+            myMagickError(interp, wandPtr);
+            return TCL_ERROR;
+        }
+        Tcl_SetObjResult(interp, Tcl_NewDoubleObj(value));
+
+        break;
+    }
+
+    case TM_COMPARE:         /* compare refName metric */
+    case TM_COMPARE_IMAGES:  /* CompareImages refName metric */
+    {
+        MagickWand      *refWand, *newWand;
+        int             metricIdx;
+        char            *name;
+        double          value;
+
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "refName metric");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (refWand = findMagickWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[3], metricNames,
+                                "metricType", 0, &metricIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        newWand = MagickCompareImages( wandPtr, refWand, metricTypes[metricIdx], &value );
+        if (newWand != NULL) {
+            DestroyMagickWand(newWand);
+        } else {
+            myMagickError(interp, wandPtr);
+            return TCL_ERROR;
+        }
+        Tcl_SetObjResult(interp, Tcl_NewDoubleObj(value));
+
+        break;
+    }
+
+    case TM_COMPOSITE:          /* composite compWand opType ?x y? */
     case TM_COMPOSITE_IMAGE:    /* CompositeImage compWand opType ?x y? */
     {
-       int opIdx;
-
-       char        *name;
-       MagickWand  *compPtr;
-       int x=0;
-       int y=0;
-
-       if( (objc < 4) || (objc > 6) || (objc == 5) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "opType compWand ?x=0 y=0?");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (compPtr = findMagickWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[3], opNames, "opType", 0, &opIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       if( (objc > 4) && ((stat = Tcl_GetIntFromObj(interp, objv[4], &x)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 5) && ((stat = Tcl_GetIntFromObj(interp, objv[5], &y)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickCompositeImage(wandPtr, compPtr, opTypes[opIdx], x, y);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-
-       break;
+        int opIdx;
+
+        char        *name;
+        MagickWand  *compPtr;
+        int x=0;
+        int y=0;
+
+        if( (objc < 4) || (objc > 6) || (objc == 5) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "opType compWand ?x=0 y=0?");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (compPtr = findMagickWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[3], opNames, "opType", 0, &opIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        if( (objc > 4) && ((stat = Tcl_GetIntFromObj(interp, objv[4], &x)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 5) && ((stat = Tcl_GetIntFromObj(interp, objv[5], &y)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickCompositeImage(wandPtr, compPtr, opTypes[opIdx], x, y);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+
+        break;
     }
 
     case TM_CONTRAST:        /* contrast ?sharpen? */
     case TM_CONTRAST_IMAGE:  /* ContrastImage ?sharpen? */
     {
-       int sharpen=1;
+        int sharpen=1;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?sharpen=yes?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetBooleanFromObj(interp, objv[2], &sharpen)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickContrastImage(wandPtr, sharpen);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?sharpen=yes?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetBooleanFromObj(interp, objv[2], &sharpen)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickContrastImage(wandPtr, sharpen);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_CONVOLVE:       /* convolve order kernelList */
     case TM_CONVOLVE_IMAGE: /* ConvolveImage order kernelList */
     {
-       int     i, listLen;
-       unsigned long order;
-       double  *kernel;
-       Tcl_Obj **listPtr;
-
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "order kernelList");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &order)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_ListObjGetElements(interp, objv[3], &listLen, &listPtr)) != TCL_OK) {
-           return stat;
-       }
-       if( (unsigned long)listLen != order * order ) {
-           Tcl_AppendResult(
-               interp,
-               "ConvolveImage: Invalid kernelList length, should be = (order x order)", NULL);
-           return TCL_ERROR;
-       }
-       kernel = (double *)ckalloc(listLen * sizeof(double));
-       if( kernel == NULL ) {
-           Tcl_AppendResult(interp, "TclMagick: out of memory", NULL);
-           return TCL_ERROR;
-       }
-       for( i=0; i < listLen; i++ ) {
-           if( (stat = Tcl_GetDoubleFromObj(interp, listPtr[i], &kernel[i])) != TCL_OK) {
-               ckfree((char *)kernel);
-               return stat;
-           }
-       }
-
-       result = MagickConvolveImage(wandPtr, order, kernel);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        int     i, listLen;
+        unsigned long order;
+        double  *kernel;
+        Tcl_Obj **listPtr;
+
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "order kernelList");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &order)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_ListObjGetElements(interp, objv[3], &listLen, &listPtr)) != TCL_OK) {
+            return stat;
+        }
+        if( (unsigned long)listLen != order * order ) {
+            Tcl_AppendResult(
+                interp,
+                "ConvolveImage: Invalid kernelList length, should be = (order x order)", NULL);
+            return TCL_ERROR;
+        }
+        kernel = (double *)ckalloc(listLen * sizeof(double));
+        if( kernel == NULL ) {
+            Tcl_AppendResult(interp, "TclMagick: out of memory", NULL);
+            return TCL_ERROR;
+        }
+        for( i=0; i < listLen; i++ ) {
+            if( (stat = Tcl_GetDoubleFromObj(interp, listPtr[i], &kernel[i])) != TCL_OK) {
+                ckfree((char *)kernel);
+                return stat;
+            }
+        }
+
+        result = MagickConvolveImage(wandPtr, order, kernel);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_CROP:        /* crop width height ?x y? */
     case TM_CROP_IMAGE:  /* CropImage width height ?x y? */
     {
-       unsigned long width, height;
-       long x=0, y=0;
-
-       if( (objc < 4) || (objc > 6) || (objc == 5) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "width height ?x=0 y=0?");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &width)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &height)) != TCL_OK ) {
-           return stat;
-       }
-       if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4], &x)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 5) && ((stat = Tcl_GetLongFromObj(interp, objv[5], &y)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickCropImage(wandPtr, width, height, x, y);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        unsigned long width, height;
+        long x=0, y=0;
+
+        if( (objc < 4) || (objc > 6) || (objc == 5) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "width height ?x=0 y=0?");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &width)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &height)) != TCL_OK ) {
+            return stat;
+        }
+        if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4], &x)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 5) && ((stat = Tcl_GetLongFromObj(interp, objv[5], &y)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickCropImage(wandPtr, width, height, x, y);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_CYCLE_COLORMAP:         /* cyclecolormap ?displace? */
     case TM_CYCLE_COLORMAP_IMAGE:   /* CycleColormapImage ?displace? */
     {
-       int displace=1;
+        int displace=1;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?displace=1?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetIntFromObj(interp, objv[2], &displace)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickCycleColormapImage(wandPtr, displace);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?displace=1?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetIntFromObj(interp, objv[2], &displace)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickCycleColormapImage(wandPtr, displace);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_DECONSTRUCT:        /* deconstruct ?newName? */
     case TM_DECONSTRUCT_IMAGES: /* DeconstructImage ?newName? */
     {
-       MagickWand *newWand;
-       char *name=NULL;
+        MagickWand *newWand;
+        char *name=NULL;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
-           return TCL_ERROR;
-       }
-       if( objc > 2 ) {
-           name = Tcl_GetString(objv[2]);
-       }
-       newWand = MagickDeconstructImages(wandPtr);
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       name = newWandObj(interp, newWand, name);
-       Tcl_SetResult(interp, name, TCL_VOLATILE);
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
+            return TCL_ERROR;
+        }
+        if( objc > 2 ) {
+            name = Tcl_GetString(objv[2]);
+        }
+        newWand = MagickDeconstructImages(wandPtr);
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        name = newWandObj(interp, newWand, name);
+        Tcl_SetResult(interp, name, TCL_VOLATILE);
 
-       break;
+        break;
     }
 
     case TM_DESCRIBE:       /* describe */
     case TM_DESCRIBE_IMAGE: /* DescribeImage */
     {
-       char *txt;
+        char *txt;
 
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       txt = MagickDescribeImage(wandPtr);
-       if(txt != NULL) {
-           Tcl_SetResult(interp, txt, TCL_VOLATILE);
-           MagickRelinquishMemory(txt); /* Free TclMagick resource */
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        txt = MagickDescribeImage(wandPtr);
+        if(txt != NULL) {
+            Tcl_SetResult(interp, txt, TCL_VOLATILE);
+            MagickRelinquishMemory(txt); /* Free TclMagick resource */
+        }
+        break;
     }
 
     case TM_DESPECKLE:          /* despeckle */
     case TM_DESPECKLE_IMAGE:    /* DespeckleImage */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       result = MagickDespeckleImage(wandPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        result = MagickDespeckleImage(wandPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_DRAW:       /* draw draw */
     case TM_DRAW_IMAGE: /* DrawImage draw */
     {
-       char    *name;
-       DrawingWand     *drawPtr;
+        char    *name;
+        DrawingWand     *drawPtr;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "draw");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (drawPtr = findDrawingWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       result = MagickDrawImage(wandPtr, drawPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "draw");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (drawPtr = findDrawingWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        result = MagickDrawImage(wandPtr, drawPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_EDGE:       /* edge ?radius? */
     case TM_EDGE_IMAGE: /* EdgeImage ?radius? */
     {
-       double  radius=0.0;
+        double  radius=0.0;
 
-       if( objc > 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickEdgeImage(wandPtr, radius);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc > 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickEdgeImage(wandPtr, radius);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_EMBOSS:        /* emboss ?radius? ?sigma? */
     case TM_EMBOSS_IMAGE:  /* EmbossImage ?radius? ?sigma? */
     {
-       double  radius=0.0, sigma=1.0;
-
-       if( objc > 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0? ?sigma=1.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &sigma)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickEmbossImage(wandPtr, radius, sigma);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double  radius=0.0, sigma=1.0;
+
+        if( objc > 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0? ?sigma=1.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &sigma)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickEmbossImage(wandPtr, radius, sigma);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_ENHANCE:          /* enhance */
     case TM_ENHANCE_IMAGE:    /* EnhanceImage */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       result = MagickEnhanceImage(wandPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        result = MagickEnhanceImage(wandPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_EQUALIZE:          /* equalize */
     case TM_EQUALIZE_IMAGE:    /* EqualizeImage */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       result = MagickEqualizeImage(wandPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        result = MagickEqualizeImage(wandPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_FLATTEN:          /* flatten ?newName? */
     case TM_FLATTEN_IMAGES:   /* FlattenImages ?newName? */
     {
-       MagickWand *newWand;
-       char *name=NULL;
+        MagickWand *newWand;
+        char *name=NULL;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
-           return TCL_ERROR;
-       }
-       if( objc > 2 ) {
-           name = Tcl_GetString(objv[2]);
-       }
-       newWand = MagickFlattenImages(wandPtr);
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       name = newWandObj(interp, newWand, name);
-       Tcl_SetResult(interp, name, TCL_VOLATILE);
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
+            return TCL_ERROR;
+        }
+        if( objc > 2 ) {
+            name = Tcl_GetString(objv[2]);
+        }
+        newWand = MagickFlattenImages(wandPtr);
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        name = newWandObj(interp, newWand, name);
+        Tcl_SetResult(interp, name, TCL_VOLATILE);
 
-       break;
+        break;
     }
 
     case TM_FLIP:          /* flip */
     case TM_FLIP_IMAGE:    /* FlipImage */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       result = MagickFlipImage(wandPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        result = MagickFlipImage(wandPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
 
     case TM_FLOP:          /* flop */
     case TM_FLOP_IMAGE:    /* FlopImage */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       result = MagickFlopImage(wandPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        result = MagickFlopImage(wandPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_FRAME:          /* frame framePixel ?width? ?height? ?inner? ?outer? */
     case TM_FRAME_IMAGE:    /* FrameImage framePixel ?width? ?height? ?inner? ?outer? */
     {
-       unsigned long width=1, height=1;
-       long inner=0, outer=0;
-       char        *name;
-       PixelWand       *framePtr;
-
-       if( (objc < 3) || (objc > 7) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "framePixel ?width=1? ?height=width? ?inner=0? ?outer=inner?");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (framePtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &width)) != TCL_OK) ) {
-           return stat;
-       }
-       height = width; /* default */
-       if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4],  (long int *) &height)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 5) && ((stat = Tcl_GetLongFromObj(interp, objv[5], &inner)) != TCL_OK) ) {
-           return stat;
-       }
-       outer = inner; /* default */
-       if( (objc > 6) && ((stat = Tcl_GetLongFromObj(interp, objv[6], &outer)) != TCL_OK) ) {
-           return stat;
-       }
-
-       result = MagickFrameImage(wandPtr, framePtr, width, height, inner, outer);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        unsigned long width=1, height=1;
+        long inner=0, outer=0;
+        char        *name;
+        PixelWand       *framePtr;
+
+        if( (objc < 3) || (objc > 7) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "framePixel ?width=1? ?height=width? ?inner=0? ?outer=inner?");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (framePtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &width)) != TCL_OK) ) {
+            return stat;
+        }
+        height = width; /* default */
+        if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4],  (long int *) &height)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 5) && ((stat = Tcl_GetLongFromObj(interp, objv[5], &inner)) != TCL_OK) ) {
+            return stat;
+        }
+        outer = inner; /* default */
+        if( (objc > 6) && ((stat = Tcl_GetLongFromObj(interp, objv[6], &outer)) != TCL_OK) ) {
+            return stat;
+        }
+
+        result = MagickFrameImage(wandPtr, framePtr, width, height, inner, outer);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_FX:         /* fx expr ?newName? */
     case TM_FX_IMAGE:   /* fxImage expr ?newName? */
     {
-        char      *expr;
-       MagickWand *newWand;
-       char       *name=NULL;
+        char       *expr;
+        MagickWand *newWand;
+        char       *name=NULL;
 
-       if( (objc != 3) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "expr ?newName?");
-           return TCL_ERROR;
-       }
-       expr = Tcl_GetString(objv[2]);
+        if( (objc != 3) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "expr ?newName?");
+            return TCL_ERROR;
+        }
+        expr = Tcl_GetString(objv[2]);
 
-       if( objc > 3 ) {
-           name = Tcl_GetString(objv[3]);
-       }
-       newWand = MagickFxImage(wandPtr, expr);
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       name = newWandObj(interp, newWand, name);
-       Tcl_SetResult(interp, name, TCL_VOLATILE);
+        if( objc > 3 ) {
+            name = Tcl_GetString(objv[3]);
+        }
+        newWand = MagickFxImage(wandPtr, expr);
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        name = newWandObj(interp, newWand, name);
+        Tcl_SetResult(interp, name, TCL_VOLATILE);
 
-       break;
+        break;
     }
 
     case TM_FX_CHANNEL:         /* fxchannel channelType expr ?newName? */
     case TM_FX_IMAGE_CHANNEL:   /* fxImageChannel channelType expr ?newName? */
     {
-       int        chanIdx;
+        int        chanIdx;
         char       *expr;
-       MagickWand *newWand;
-       char       *name=NULL;
-
-       if( (objc != 4) && (objc != 5) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "channelType expr ?newName?");
-           return TCL_ERROR;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       expr = Tcl_GetString(objv[3]);
-
-       if( objc > 4 ) {
-           name = Tcl_GetString(objv[4]);
-       }
-       newWand = MagickFxImageChannel(wandPtr, chanTypes[chanIdx], expr);
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       name = newWandObj(interp, newWand, name);
-       Tcl_SetResult(interp, name, TCL_VOLATILE);
-
-       break;
+        MagickWand *newWand;
+        char       *name=NULL;
+
+        if( (objc != 4) && (objc != 5) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "channelType expr ?newName?");
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        expr = Tcl_GetString(objv[3]);
+
+        if( objc > 4 ) {
+            name = Tcl_GetString(objv[4]);
+        }
+        newWand = MagickFxImageChannel(wandPtr, chanTypes[chanIdx], expr);
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        name = newWandObj(interp, newWand, name);
+        Tcl_SetResult(interp, name, TCL_VOLATILE);
+
+        break;
     }
 
     case TM_GAMMAIMAGE:  /* gammaimage level */
     case TM_GAMMA_IMAGE: /* GammaImage level */
     {
-       double gamma;
+        double gamma;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "level");
-           return TCL_ERROR;
-       }
-       if (Tcl_GetDoubleFromObj(interp, objv[2], &gamma) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       result = MagickGammaImage(wandPtr, gamma);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "level");
+            return TCL_ERROR;
+        }
+        if (Tcl_GetDoubleFromObj(interp, objv[2], &gamma) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        result = MagickGammaImage(wandPtr, gamma);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_GAMMACHANNEL:        /* gamma channelType level */
     case TM_GAMMA_IMAGE_CHANNEL: /* GammaImage channelType level */
     {
-       int    chanIdx;
-       double gamma;
-
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "channelType level");
-           return TCL_ERROR;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       if (Tcl_GetDoubleFromObj(interp, objv[3], &gamma) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       result = MagickGammaImageChannel(wandPtr, chanTypes[chanIdx], gamma);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        int    chanIdx;
+        double gamma;
+
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "channelType level");
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        if (Tcl_GetDoubleFromObj(interp, objv[3], &gamma) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        result = MagickGammaImageChannel(wandPtr, chanTypes[chanIdx], gamma);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_FILENAME:        /* filename ?filename? */
     case TM_GET_FILENAME:    /* GetFilename */
     case TM_SET_FILENAME:    /* SetFilename filename */
     {
-       char *filename;
-
-       if( ((enum subIndex)index == TM_FILENAME) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?filename?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_FILENAME) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_FILENAME) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "filename");
-           return TCL_ERROR;
-       }
-       if (objc > 2) { /* Set filename */
-           Tcl_DString extrep;
-
-           filename = Tcl_UtfToExternalDString (NULL, Tcl_GetString(objv[2]), -1, &extrep);
-           MagickSetFilename(wandPtr, filename);
-
-           Tcl_DStringFree (&extrep);
-       } else {    /* Get filename */
-           filename = (char *)MagickGetFilename(wandPtr);
-           if(filename != NULL) {
-               SetResultAsExternalString(interp, filename);
-               MagickRelinquishMemory(filename); /* Free TclMagick resource */
-           }
-       }
-       break;
+        char *filename;
+
+        if( ((enum subIndex)index == TM_FILENAME) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?filename?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_FILENAME) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_FILENAME) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "filename");
+            return TCL_ERROR;
+        }
+        if (objc > 2) { /* Set filename */
+            Tcl_DString extrep;
+
+            filename = Tcl_UtfToExternalDString (NULL, Tcl_GetString(objv[2]), -1, &extrep);
+            MagickSetFilename(wandPtr, filename);
+
+            Tcl_DStringFree (&extrep);
+        } else {    /* Get filename */
+            filename = (char *)MagickGetFilename(wandPtr);
+            if(filename != NULL) {
+                SetResultAsExternalString(interp, filename);
+                MagickRelinquishMemory(filename); /* Free TclMagick resource */
+            }
+        }
+        break;
     }
 
     case TM_BACKGROUND_COLOR:      /* backgroundcolor ?pixel? */
     case TM_GET_BACKGROUND_COLOR:  /* GetBackgroundColor ?pixel? */
     case TM_SET_BACKGROUND_COLOR:  /* SetBackgroundColor pixel */
     {
-       char *name = NULL;
+        char *name = NULL;
         PixelWand *pixPtr = NULL;
 
-       if( ((enum subIndex)index == TM_SET_BACKGROUND_COLOR) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "pixel");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index != TM_SET_BACKGROUND_COLOR) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?pixel?");
-           return TCL_ERROR;
-       }
-       if (objc > 2) { /* Set color / Get color with new name */
-           name = Tcl_GetString(objv[2]);
-           pixPtr = findPixelWand(interp, name);
+        if( ((enum subIndex)index == TM_SET_BACKGROUND_COLOR) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "pixel");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index != TM_SET_BACKGROUND_COLOR) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?pixel?");
+            return TCL_ERROR;
+        }
+        if (objc > 2) { /* Set color / Get color with new name */
+            name = Tcl_GetString(objv[2]);
+            pixPtr = findPixelWand(interp, name);
         }
         /*
          * SET color requires existing pixel object
          */
         if( ((enum subIndex)index == TM_SET_BACKGROUND_COLOR) && (pixPtr == NULL) ) {
-               return TCL_ERROR;
+                return TCL_ERROR;
         }
         /*
          * GET color if GET_COLOR or pixel object doesn't exists
@@ -2232,7 +2241,7 @@ static int wandObjCmd(
             result = MagickGetImageBackgroundColor( wandPtr, pixPtr );
             if (!result) {
                 return myMagickError(interp, wandPtr);
-           }
+            }
             Tcl_SetResult(interp, name, TCL_VOLATILE);
         } else {
             result = MagickSetImageBackgroundColor( wandPtr, pixPtr );
@@ -2240,7 +2249,7 @@ static int wandObjCmd(
                 return myMagickError(interp, wandPtr);
             }
         }
-       break;
+        break;
     }
 
     case TM_BLUE_PRIMARY:      /* blueprimary ?x y? */
@@ -2249,74 +2258,74 @@ static int wandObjCmd(
     {
         double x, y;
 
-       if( ((enum subIndex)index == TM_BLUE_PRIMARY) && (objc != 2) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?x y?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_BLUE_PRIMARY) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_BLUE_PRIMARY) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y");
-           return TCL_ERROR;
-       }
-       if (objc == 4) {
-           /*
-            * Set primary = x y
-            */
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
-               return stat;
-           }
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
-               return stat;
-           }
-           result = MagickSetImageBluePrimary(wandPtr, x, y);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get primary={x y}
-            */
-           Tcl_Obj *listPtr;
-
-           result = MagickGetImageBluePrimary(wandPtr, &x, &y);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-           listPtr = Tcl_NewListObj(0, NULL);
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(x));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(y));
-           Tcl_SetObjResult(interp, listPtr);
-       }
-       break;
+        if( ((enum subIndex)index == TM_BLUE_PRIMARY) && (objc != 2) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?x y?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_BLUE_PRIMARY) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_BLUE_PRIMARY) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y");
+            return TCL_ERROR;
+        }
+        if (objc == 4) {
+            /*
+             * Set primary = x y
+             */
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
+                return stat;
+            }
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
+                return stat;
+            }
+            result = MagickSetImageBluePrimary(wandPtr, x, y);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get primary={x y}
+             */
+            Tcl_Obj *listPtr;
+
+            result = MagickGetImageBluePrimary(wandPtr, &x, &y);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+            listPtr = Tcl_NewListObj(0, NULL);
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(x));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(y));
+            Tcl_SetObjResult(interp, listPtr);
+        }
+        break;
     }
 
     case TM_BORDER_COLOR:      /* bordercolor ?pixel? */
     case TM_GET_BORDER_COLOR:  /* GetBorderColor ?pixel? */
     case TM_SET_BORDER_COLOR:  /* SetBorderColor pixel */
     {
-       char *name = NULL;
+        char *name = NULL;
         PixelWand *pixPtr = NULL;
 
-       if( ((enum subIndex)index == TM_SET_BORDER_COLOR) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "pixel");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index != TM_SET_BORDER_COLOR) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?pixel?");
-           return TCL_ERROR;
-       }
-       if (objc > 2) { /* Set color / Get color with new name */
-           name = Tcl_GetString(objv[2]);
-           pixPtr = findPixelWand(interp, name);
+        if( ((enum subIndex)index == TM_SET_BORDER_COLOR) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "pixel");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index != TM_SET_BORDER_COLOR) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?pixel?");
+            return TCL_ERROR;
+        }
+        if (objc > 2) { /* Set color / Get color with new name */
+            name = Tcl_GetString(objv[2]);
+            pixPtr = findPixelWand(interp, name);
         }
         /*
          * SET color requires existing pixel object
          */
         if( ((enum subIndex)index == TM_SET_BORDER_COLOR) && (pixPtr == NULL) ) {
-               return TCL_ERROR;
+                return TCL_ERROR;
         }
         /*
          * GET color if GET_COLOR or pixel object doesn't exists
@@ -2330,7 +2339,7 @@ static int wandObjCmd(
             result = MagickGetImageBorderColor( wandPtr, pixPtr );
             if (!result) {
                 return myMagickError(interp, wandPtr);
-           }
+            }
             Tcl_SetResult(interp, name, TCL_VOLATILE);
         } else {
             result = MagickSetImageBorderColor( wandPtr, pixPtr );
@@ -2338,50 +2347,50 @@ static int wandObjCmd(
                 return myMagickError(interp, wandPtr);
             }
         }
-       break;
-    }
-
-    case TM_CHANNEL_DEPTH:      /* channeldepth channel ?depth? */
-    case TM_GET_CHANNEL_DEPTH:  /* GetChannelDepth channel */
-    case TM_SET_CHANNEL_DEPTH:  /* SetChannelDepth channel depth */
-    {
-        unsigned long depth;
-        int chanIdx;
-
-       if( ((enum subIndex)index == TM_CHANNEL_DEPTH) && (objc != 3) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "channel ?depth?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_CHANNEL_DEPTH) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "channel");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_CHANNEL_DEPTH) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "channel depth");
-           return TCL_ERROR;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       if (objc == 4) {
-           /*
-            * Set channel depth
-            */
-           if( (stat = Tcl_GetLongFromObj(interp, objv[3],  (long int *) &depth)) != TCL_OK ) {
-               return stat;
-           }
-           result = MagickSetImageChannelDepth(wandPtr, chanTypes[chanIdx], depth);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get channel depth
-            */
-           depth = MagickGetImageChannelDepth(wandPtr, chanTypes[chanIdx]);
-           Tcl_SetObjResult(interp, Tcl_NewLongObj((long)depth));
-       }
-       break;
+        break;
+    }
+
+    case TM_CHANNEL_DEPTH:      /* channeldepth channel ?depth? */
+    case TM_GET_CHANNEL_DEPTH:  /* GetChannelDepth channel */
+    case TM_SET_CHANNEL_DEPTH:  /* SetChannelDepth channel depth */
+    {
+        unsigned long depth;
+        int chanIdx;
+
+        if( ((enum subIndex)index == TM_CHANNEL_DEPTH) && (objc != 3) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "channel ?depth?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_CHANNEL_DEPTH) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "channel");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_CHANNEL_DEPTH) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "channel depth");
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        if (objc == 4) {
+            /*
+             * Set channel depth
+             */
+            if( (stat = Tcl_GetLongFromObj(interp, objv[3],  (long int *) &depth)) != TCL_OK ) {
+                return stat;
+            }
+            result = MagickSetImageChannelDepth(wandPtr, chanTypes[chanIdx], depth);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get channel depth
+             */
+            depth = MagickGetImageChannelDepth(wandPtr, chanTypes[chanIdx]);
+            Tcl_SetObjResult(interp, Tcl_NewLongObj((long)depth));
+        }
+        break;
     }
 
     case TM_CHANNEL_EXTREMA:      /* channelextrema channelType */
@@ -2391,17 +2400,17 @@ static int wandObjCmd(
         int chanIdx;
         Tcl_Obj *listPtr;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "channelType" );
-           return TCL_ERROR;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       result = MagickGetImageChannelExtrema(wandPtr, chanTypes[chanIdx], &min, &max);
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "channelType" );
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        result = MagickGetImageChannelExtrema(wandPtr, chanTypes[chanIdx], &min, &max);
         if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
+            return myMagickError(interp, wandPtr);
+        }
         listPtr = Tcl_NewListObj(0, NULL);
 
         Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewLongObj(min));
@@ -2418,17 +2427,17 @@ static int wandObjCmd(
         int chanIdx;
         Tcl_Obj *listPtr;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "channelType" );
-           return TCL_ERROR;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       result = MagickGetImageChannelMean(wandPtr, chanTypes[chanIdx], &mean, &deviation);
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "channelType" );
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        result = MagickGetImageChannelMean(wandPtr, chanTypes[chanIdx], &mean, &deviation);
         if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
+            return myMagickError(interp, wandPtr);
+        }
         listPtr = Tcl_NewListObj(0, NULL);
 
         Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(mean));
@@ -2442,30 +2451,30 @@ static int wandObjCmd(
     case TM_GET_COLORMAP_COLOR:  /* GetColormapColor index ?pixel? */
     case TM_SET_COLORMAP_COLOR:  /* SetColormapColor index pixel */
     {
-       char *name = NULL;
+        char *name = NULL;
         unsigned long idx;
         PixelWand *pixPtr = NULL;
 
-       if( ((enum subIndex)index == TM_SET_COLORMAP_COLOR) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "index pixel");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index != TM_SET_COLORMAP_COLOR) && ((objc < 3) || (objc > 4)) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "index ?pixel?");
-           return TCL_ERROR;
-       }
-       if (Tcl_GetLongFromObj(interp, objv[2], (long int *) &idx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       if (objc > 3) { /* Set color / Get color with new name */
-           name = Tcl_GetString(objv[3]);
-           pixPtr = findPixelWand(interp, name);
+        if( ((enum subIndex)index == TM_SET_COLORMAP_COLOR) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "index pixel");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index != TM_SET_COLORMAP_COLOR) && ((objc < 3) || (objc > 4)) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "index ?pixel?");
+            return TCL_ERROR;
+        }
+        if (Tcl_GetLongFromObj(interp, objv[2], (long int *) &idx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        if (objc > 3) { /* Set color / Get color with new name */
+            name = Tcl_GetString(objv[3]);
+            pixPtr = findPixelWand(interp, name);
         }
         /*
          * SET color requires existing pixel object
          */
         if( ((enum subIndex)index == TM_SET_COLORMAP_COLOR) && (pixPtr == NULL) ) {
-               return TCL_ERROR;
+                return TCL_ERROR;
         }
         /*
          * GET color if GET_COLOR or pixel object doesn't exists
@@ -2479,7 +2488,7 @@ static int wandObjCmd(
             result = MagickGetImageColormapColor( wandPtr, idx, pixPtr );
             if (!result) {
                 return myMagickError(interp, wandPtr);
-           }
+            }
             Tcl_SetResult(interp, name, TCL_VOLATILE);
         } else {
             result = MagickSetImageColormapColor( wandPtr, idx, pixPtr );
@@ -2487,7 +2496,7 @@ static int wandObjCmd(
                 return myMagickError(interp, wandPtr);
             }
         }
-       break;
+        break;
     }
 
     case TM_COLORS:      /* colors */
@@ -2495,13 +2504,13 @@ static int wandObjCmd(
     {
         long colors;
 
-       if (objc != 2) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       colors = MagickGetImageColors(wandPtr);
-       Tcl_SetObjResult(interp, Tcl_NewLongObj(colors));
-       break;
+        if (objc != 2) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        colors = MagickGetImageColors(wandPtr);
+        Tcl_SetObjResult(interp, Tcl_NewLongObj(colors));
+        break;
     }
 
     case TM_COLORSPACE:      /* colorspace ?colorspaceType? */
@@ -2511,43 +2520,43 @@ static int wandObjCmd(
         int csIdx;
         ColorspaceType cs;
 
-       if( ((enum subIndex)index == TM_COLORSPACE) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?colorspaceType?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_COLORSPACE) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_COLORSPACE) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "colorspaceType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set colorspace
-            */
+        if( ((enum subIndex)index == TM_COLORSPACE) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?colorspaceType?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_COLORSPACE) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_COLORSPACE) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "colorspaceType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set colorspace
+             */
             if (Tcl_GetIndexFromObj(interp, objv[2], csNames, "csType", 0, &csIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageColorspace(wandPtr, csTypes[csIdx]);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get colorspace
-            */
-           cs = MagickGetImageColorspace(wandPtr);
-           for (csIdx = 0; (size_t) csIdx < sizeof(csTypes)/sizeof(csTypes[0]); csIdx++) {
-               if( csTypes[csIdx] == cs ) {
-                   Tcl_SetResult(interp, (char *)csNames[csIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)cs));
-       }
-       break;
+                return TCL_ERROR;
+            }
+            result = MagickSetImageColorspace(wandPtr, csTypes[csIdx]);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get colorspace
+             */
+            cs = MagickGetImageColorspace(wandPtr);
+            for (csIdx = 0; (size_t) csIdx < sizeof(csTypes)/sizeof(csTypes[0]); csIdx++) {
+                if( csTypes[csIdx] == cs ) {
+                    Tcl_SetResult(interp, (char *)csNames[csIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)cs));
+        }
+        break;
     }
 
     case TM_COMPOSE:      /* compose ?opType? */
@@ -2557,43 +2566,43 @@ static int wandObjCmd(
         int opIdx;
         CompositeOperator op;
 
-       if( ((enum subIndex)index == TM_COMPOSE) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?opType?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_COMPOSE) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_COMPOSE) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "opType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set compose operator
-            */
+        if( ((enum subIndex)index == TM_COMPOSE) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?opType?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_COMPOSE) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_COMPOSE) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "opType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set compose operator
+             */
             if (Tcl_GetIndexFromObj(interp, objv[2], opNames, "opType", 0, &opIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageColorspace(wandPtr, opTypes[opIdx]);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get compose operator
-            */
-           op = MagickGetImageColorspace(wandPtr);
-           for (opIdx = 0; (size_t) opIdx < sizeof(opTypes)/sizeof(opTypes[0]); opIdx++) {
-               if( opTypes[opIdx] == op ) {
-                   Tcl_SetResult(interp, (char *)opNames[opIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)op));
-       }
-       break;
+                return TCL_ERROR;
+            }
+            result = MagickSetImageColorspace(wandPtr, opTypes[opIdx]);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get compose operator
+             */
+            op = MagickGetImageColorspace(wandPtr);
+            for (opIdx = 0; (size_t) opIdx < sizeof(opTypes)/sizeof(opTypes[0]); opIdx++) {
+                if( opTypes[opIdx] == op ) {
+                    Tcl_SetResult(interp, (char *)opNames[opIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)op));
+        }
+        break;
     }
 
     case TM_COMPRESSION:      /* compression ?compressionType? */
@@ -2603,43 +2612,43 @@ static int wandObjCmd(
         int csIdx;
         CompressionType cs;
 
-       if( ((enum subIndex)index == TM_COMPRESSION) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?compressionType?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_COMPRESSION) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_COMPRESSION) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "compressionType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set compression
-            */
+        if( ((enum subIndex)index == TM_COMPRESSION) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?compressionType?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_COMPRESSION) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_COMPRESSION) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "compressionType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set compression
+             */
             if (Tcl_GetIndexFromObj(interp, objv[2], compressNames, "compressType", 0, &csIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageCompression(wandPtr, compressTypes[csIdx]);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get compression
-            */
-           cs = MagickGetImageCompression(wandPtr);
-           for (csIdx = 0; (size_t) csIdx < sizeof(compressTypes)/sizeof(compressTypes[0]); csIdx++) {
-               if( compressTypes[csIdx] == cs ) {
-                   Tcl_SetResult(interp, (char *)compressNames[csIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)cs));
-       }
-       break;
+                return TCL_ERROR;
+            }
+            result = MagickSetImageCompression(wandPtr, compressTypes[csIdx]);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get compression
+             */
+            cs = MagickGetImageCompression(wandPtr);
+            for (csIdx = 0; (size_t) csIdx < sizeof(compressTypes)/sizeof(compressTypes[0]); csIdx++) {
+                if( compressTypes[csIdx] == cs ) {
+                    Tcl_SetResult(interp, (char *)compressNames[csIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)cs));
+        }
+        break;
     }
 
     case TM_DELAY:      /* delay ?delay? */
@@ -2648,37 +2657,37 @@ static int wandObjCmd(
     {
         unsigned long delay;
 
-       if( ((enum subIndex)index == TM_DELAY) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?delay?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_DELAY) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_DELAY) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "delay");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set delay
-            */
-               if (Tcl_GetLongFromObj(interp, objv[2], (long int *) &delay) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageDelay(wandPtr, delay);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get delay
-            */
-           delay = MagickGetImageDelay(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewLongObj((long)delay));
-       }
-       break;
+        if( ((enum subIndex)index == TM_DELAY) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?delay?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_DELAY) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_DELAY) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "delay");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set delay
+             */
+                if (Tcl_GetLongFromObj(interp, objv[2], (long int *) &delay) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            result = MagickSetImageDelay(wandPtr, delay);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get delay
+             */
+            delay = MagickGetImageDelay(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewLongObj((long)delay));
+        }
+        break;
     }
 
     case TM_DEPTH:      /* depth ?depth? */
@@ -2687,37 +2696,37 @@ static int wandObjCmd(
     {
         unsigned long depth;
 
-       if( ((enum subIndex)index == TM_DEPTH) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?depth?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_DEPTH) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_DEPTH) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "depth");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set depth
-            */
-           if (Tcl_GetLongFromObj(interp, objv[2], (long int *) &depth) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageDepth(wandPtr, depth);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get depth
-            */
-           depth = MagickGetImageDepth(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewLongObj((long)depth));
-       }
-       break;
+        if( ((enum subIndex)index == TM_DEPTH) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?depth?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_DEPTH) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_DEPTH) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "depth");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set depth
+             */
+            if (Tcl_GetLongFromObj(interp, objv[2], (long int *) &depth) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            result = MagickSetImageDepth(wandPtr, depth);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get depth
+             */
+            depth = MagickGetImageDepth(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewLongObj((long)depth));
+        }
+        break;
     }
 
     case TM_DISPOSE:      /* dispose ?disposeType? */
@@ -2727,43 +2736,43 @@ static int wandObjCmd(
         int disposeIdx;
         DisposeType dispose;
 
-       if( ((enum subIndex)index == TM_DISPOSE) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?disposeType?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_DISPOSE) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_DISPOSE) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "disposeType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set dispose
-            */
+        if( ((enum subIndex)index == TM_DISPOSE) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?disposeType?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_DISPOSE) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_DISPOSE) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "disposeType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set dispose
+             */
             if (Tcl_GetIndexFromObj(interp, objv[2], disposeNames, "disposeType", 0, &disposeIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageDispose(wandPtr, disposeTypes[disposeIdx]);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get dispose
-            */
-           dispose = MagickGetImageDispose(wandPtr);
-           for (disposeIdx = 0; (size_t) disposeIdx < sizeof(disposeTypes)/sizeof(disposeTypes[0]); disposeIdx++) {
-               if( disposeTypes[disposeIdx] == dispose ) {
-                   Tcl_SetResult(interp, (char *)disposeNames[disposeIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)dispose));
-       }
-       break;
+                return TCL_ERROR;
+            }
+            result = MagickSetImageDispose(wandPtr, disposeTypes[disposeIdx]);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get dispose
+             */
+            dispose = MagickGetImageDispose(wandPtr);
+            for (disposeIdx = 0; (size_t) disposeIdx < sizeof(disposeTypes)/sizeof(disposeTypes[0]); disposeIdx++) {
+                if( disposeTypes[disposeIdx] == dispose ) {
+                    Tcl_SetResult(interp, (char *)disposeNames[disposeIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)dispose));
+        }
+        break;
     }
 
     case TM_EXTREMA:      /* extrema */
@@ -2772,14 +2781,14 @@ static int wandObjCmd(
         unsigned long min, max;
         Tcl_Obj *listPtr;
 
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL );
-           return TCL_ERROR;
-       }
-       result = MagickGetImageExtrema(wandPtr, &min, &max);
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL );
+            return TCL_ERROR;
+        }
+        result = MagickGetImageExtrema(wandPtr, &min, &max);
         if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
+            return myMagickError(interp, wandPtr);
+        }
         listPtr = Tcl_NewListObj(0, NULL);
 
         Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewLongObj(min));
@@ -2793,100 +2802,100 @@ static int wandObjCmd(
     case TM_GET_FORMAT: /* GetImageFormat */
     case TM_SET_FORMAT: /* SetImageFormat */
     {
-       char *fmt;
+        char *fmt;
 
         if( ((enum subIndex)index == TM_FORMAT) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?format?");
-           return TCL_ERROR;
-       }
+            Tcl_WrongNumArgs(interp, 2, objv, "?format?");
+            return TCL_ERROR;
+        }
         if( ((enum subIndex)index == TM_GET_FORMAT) && (objc != 2) ) {
           Tcl_WrongNumArgs(interp, 2, objv, NULL);
           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_FORMAT) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "format");
-           return TCL_ERROR;
-       }
+        }
+        if( ((enum subIndex)index == TM_SET_FORMAT) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "format");
+            return TCL_ERROR;
+        }
         if (objc > 2) { /* Set format */
 #if defined(HAVE_MAGICKSETIMAGEFORMAT)
-           Tcl_DString extrep;
+            Tcl_DString extrep;
 
             fmt = Tcl_UtfToExternalDString (NULL, Tcl_GetString(objv[2]), -1, &extrep);
-           MagickSetImageFormat(wandPtr, fmt);
-           Tcl_DStringFree (&extrep);
+            MagickSetImageFormat(wandPtr, fmt);
+            Tcl_DStringFree (&extrep);
 #else
             char msg[1024];
             sprintf(msg, "%.500s: MagickSetImageFormat() is not implemented!", MagickGetPackageName());
             Tcl_AppendResult(interp, msg, NULL);
-           return TCL_ERROR;
+            return TCL_ERROR;
 #endif /* HAVE_MAGICKSETIMAGEFORMAT */
         } else { /* Get format */
           fmt = (char *)MagickGetImageFormat(wandPtr);
           if (fmt != NULL) {
-           Tcl_SetResult(interp, fmt, TCL_VOLATILE);
-           MagickRelinquishMemory(fmt); /* Free TclMagick resource */
+            Tcl_SetResult(interp, fmt, TCL_VOLATILE);
+            MagickRelinquishMemory(fmt); /* Free TclMagick resource */
           }
-       }
-       break;
+        }
+        break;
     }
 
     case TM_GETIMAGE:   /* getimage ?newName? */
     case TM_GET_IMAGE:  /* GetImage ?newName? */
     {
-       MagickWand *newWand;
-       char *name=NULL;
+        MagickWand *newWand;
+        char *name=NULL;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
-           return TCL_ERROR;
-       }
-       if( objc > 2 ) {
-           name = Tcl_GetString(objv[2]);
-       }
-       newWand = MagickGetImage(wandPtr);
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       name = newWandObj(interp, newWand, name);
-       Tcl_SetResult(interp, name, TCL_VOLATILE);
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
+            return TCL_ERROR;
+        }
+        if( objc > 2 ) {
+            name = Tcl_GetString(objv[2]);
+        }
+        newWand = MagickGetImage(wandPtr);
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        name = newWandObj(interp, newWand, name);
+        Tcl_SetResult(interp, name, TCL_VOLATILE);
 
-       break;
+        break;
     }
 
     case TM_IMAGE_FILENAME:        /* imagefilename ?filename? */
     case TM_GET_IMAGE_FILENAME:    /* GetImageFilename */
     case TM_SET_IMAGE_FILENAME:    /* SetImageFilename filename */
     {
-       char *filename;
-
-       if( ((enum subIndex)index == TM_IMAGE_FILENAME) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?filename?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_IMAGE_FILENAME) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_IMAGE_FILENAME) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "filename");
-           return TCL_ERROR;
-       }
-       if (objc > 2) { /* Set filename */
-           Tcl_DString extrep;
-           filename = Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[2]), -1, &extrep);
-           result = MagickSetImageFilename(wandPtr, filename);
-           Tcl_DStringFree(&extrep);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {    /* Get filename */
-           filename = (char *)MagickGetImageFilename(wandPtr);
-           if(filename != NULL) {
-               SetResultAsExternalString(interp, filename);
-               MagickRelinquishMemory(filename); /* Free TclMagick resource */
-           }
-       }
-       break;
+        char *filename;
+
+        if( ((enum subIndex)index == TM_IMAGE_FILENAME) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?filename?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_IMAGE_FILENAME) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_IMAGE_FILENAME) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "filename");
+            return TCL_ERROR;
+        }
+        if (objc > 2) { /* Set filename */
+            Tcl_DString extrep;
+            filename = Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[2]), -1, &extrep);
+            result = MagickSetImageFilename(wandPtr, filename);
+            Tcl_DStringFree(&extrep);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {    /* Get filename */
+            filename = (char *)MagickGetImageFilename(wandPtr);
+            if(filename != NULL) {
+                SetResultAsExternalString(interp, filename);
+                MagickRelinquishMemory(filename); /* Free TclMagick resource */
+            }
+        }
+        break;
     }
 
     case TM_GAMMA:      /* gamma ?gamma? */
@@ -2895,37 +2904,37 @@ static int wandObjCmd(
     {
         double gamma;
 
-       if( ((enum subIndex)index == TM_GAMMA) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?gamma?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_GAMMA) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_GAMMA) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "gamma");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set gamma
-            */
-           if (Tcl_GetDoubleFromObj(interp, objv[2], &gamma) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageGamma(wandPtr, gamma);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get gamma
-            */
-           gamma = MagickGetImageGamma(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(gamma));
-       }
-       break;
+        if( ((enum subIndex)index == TM_GAMMA) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?gamma?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_GAMMA) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_GAMMA) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "gamma");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set gamma
+             */
+            if (Tcl_GetDoubleFromObj(interp, objv[2], &gamma) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            result = MagickSetImageGamma(wandPtr, gamma);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get gamma
+             */
+            gamma = MagickGetImageGamma(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(gamma));
+        }
+        break;
     }
 
     case TM_GREEN_PRIMARY:      /* greenprimary ?x y? */
@@ -2934,102 +2943,102 @@ static int wandObjCmd(
     {
         double x, y;
 
-       if( ((enum subIndex)index == TM_GREEN_PRIMARY) && (objc != 2) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?x y?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_GREEN_PRIMARY) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_GREEN_PRIMARY) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y");
-           return TCL_ERROR;
-       }
-       if (objc == 4) {
-           /*
-            * Set primary = x y
-            */
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
-               return stat;
-           }
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
-               return stat;
-           }
-           result = MagickSetImageGreenPrimary(wandPtr, x, y);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get primary={x y}
-            */
-           Tcl_Obj *listPtr;
-
-           result = MagickGetImageGreenPrimary(wandPtr, &x, &y);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-           listPtr = Tcl_NewListObj(0, NULL);
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(x));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(y));
-           Tcl_SetObjResult(interp, listPtr);
-       }
-       break;
+        if( ((enum subIndex)index == TM_GREEN_PRIMARY) && (objc != 2) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?x y?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_GREEN_PRIMARY) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_GREEN_PRIMARY) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y");
+            return TCL_ERROR;
+        }
+        if (objc == 4) {
+            /*
+             * Set primary = x y
+             */
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
+                return stat;
+            }
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
+                return stat;
+            }
+            result = MagickSetImageGreenPrimary(wandPtr, x, y);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get primary={x y}
+             */
+            Tcl_Obj *listPtr;
+
+            result = MagickGetImageGreenPrimary(wandPtr, &x, &y);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+            listPtr = Tcl_NewListObj(0, NULL);
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(x));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(y));
+            Tcl_SetObjResult(interp, listPtr);
+        }
+        break;
     }
 
     case TM_HEIGHT:     /* height */
     case TM_GET_HEIGHT: /* GetHeight */
     {
-       int value;
+        int value;
 
         if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       value = MagickGetImageHeight(wandPtr);
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        value = MagickGetImageHeight(wandPtr);
         Tcl_SetObjResult(interp, Tcl_NewLongObj(value));
 
-       break;
+        break;
     }
 
     case TM_INDEX:      /* index ?index? */
     case TM_GET_INDEX:  /* GetIndex */
     case TM_SET_INDEX:  /* SetIndex index */
     {
-       long idx;
-
-       if( ((enum subIndex)index == TM_INDEX) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?index?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_INDEX) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_INDEX) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "index");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set index
-            */
-           if (Tcl_GetLongFromObj(interp, objv[2], &idx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageIndex(wandPtr, (long) idx);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get depth
-            */
-           idx = MagickGetImageIndex(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewLongObj((long)idx));
-       }
-       break;
+        long idx;
+
+        if( ((enum subIndex)index == TM_INDEX) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?index?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_INDEX) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_INDEX) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "index");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set index
+             */
+            if (Tcl_GetLongFromObj(interp, objv[2], &idx) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            result = MagickSetImageIndex(wandPtr, (long) idx);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get depth
+             */
+            idx = MagickGetImageIndex(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewLongObj((long)idx));
+        }
+        break;
     }
 
     case TM_INTERLACE:      /* interlace ?interlaceType? */
@@ -3039,46 +3048,46 @@ static int wandObjCmd(
         int interlaceIdx;
         InterlaceType interlace;
 
-       if( ((enum subIndex)index == TM_INTERLACE) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?interlaceType?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_INTERLACE) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_INTERLACE) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "interlaceType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set interlace
-            */
+        if( ((enum subIndex)index == TM_INTERLACE) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?interlaceType?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_INTERLACE) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_INTERLACE) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "interlaceType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set interlace
+             */
             if (Tcl_GetIndexFromObj(interp, objv[2], interlaceNames,
-                                   "interlaceType", 0, &interlaceIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageInterlaceScheme(wandPtr, interlaceTypes[interlaceIdx]);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get interlace
-            */
-           interlace = MagickGetImageInterlaceScheme(wandPtr);
-           for (interlaceIdx = 0;
-                (size_t) interlaceIdx < sizeof(interlaceTypes)/sizeof(interlaceTypes[0]);
-                interlaceIdx++) {
-               if( interlaceTypes[interlaceIdx] == interlace ) {
-                   Tcl_SetResult(interp, (char *)interlaceNames[interlaceIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)interlace));
-       }
-       break;
+                                    "interlaceType", 0, &interlaceIdx) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            result = MagickSetImageInterlaceScheme(wandPtr, interlaceTypes[interlaceIdx]);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get interlace
+             */
+            interlace = MagickGetImageInterlaceScheme(wandPtr);
+            for (interlaceIdx = 0;
+                 (size_t) interlaceIdx < sizeof(interlaceTypes)/sizeof(interlaceTypes[0]);
+                 interlaceIdx++) {
+                if( interlaceTypes[interlaceIdx] == interlace ) {
+                    Tcl_SetResult(interp, (char *)interlaceNames[interlaceIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)interlace));
+        }
+        break;
     }
 
     case TM_ITERATIONS:      /* iterations ?num? */
@@ -3087,63 +3096,63 @@ static int wandObjCmd(
     {
         unsigned long num;
 
-       if( (index == TM_ITERATIONS) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?num?");
-           return TCL_ERROR;
-       }
-       if( (index == TM_GET_ITERATIONS) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( (index == TM_SET_ITERATIONS) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "num");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set iterations
-            */
-           if (Tcl_GetLongFromObj(interp, objv[2], (long int *) &num) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageIterations(wandPtr, num);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get depth
-            */
-           num = MagickGetImageIterations(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewLongObj((long)num));
-       }
-       break;
+        if( (index == TM_ITERATIONS) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?num?");
+            return TCL_ERROR;
+        }
+        if( (index == TM_GET_ITERATIONS) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( (index == TM_SET_ITERATIONS) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "num");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set iterations
+             */
+            if (Tcl_GetLongFromObj(interp, objv[2], (long int *) &num) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            result = MagickSetImageIterations(wandPtr, num);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get depth
+             */
+            num = MagickGetImageIterations(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewLongObj((long)num));
+        }
+        break;
     }
 
     case TM_MATTE_COLOR:      /* mattecolor ?pixel? */
     case TM_GET_MATTE_COLOR:  /* GetMatteColor ?pixel? */
     case TM_SET_MATTE_COLOR:  /* SetMatteColor pixel */
     {
-       char *name = NULL;
+        char *name = NULL;
         PixelWand *pixPtr = NULL;
 
-       if( ((enum subIndex)index == TM_SET_MATTE_COLOR) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "pixel");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index != TM_SET_MATTE_COLOR) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?pixel?");
-           return TCL_ERROR;
-       }
-       if (objc > 2) { /* Set color / Get color with new name */
-           name = Tcl_GetString(objv[2]);
-           pixPtr = findPixelWand(interp, name);
+        if( ((enum subIndex)index == TM_SET_MATTE_COLOR) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "pixel");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index != TM_SET_MATTE_COLOR) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?pixel?");
+            return TCL_ERROR;
+        }
+        if (objc > 2) { /* Set color / Get color with new name */
+            name = Tcl_GetString(objv[2]);
+            pixPtr = findPixelWand(interp, name);
         }
         /*
          * SET color requires existing pixel object
          */
         if( ((enum subIndex)index == TM_SET_MATTE_COLOR) && (pixPtr == NULL) ) {
-               return TCL_ERROR;
+                return TCL_ERROR;
         }
         /*
          * GET color if GET_COLOR or pixel object doesn't exists
@@ -3157,7 +3166,7 @@ static int wandObjCmd(
             result = MagickGetImageMatteColor( wandPtr, pixPtr );
             if (!result) {
                 return myMagickError(interp, wandPtr);
-           }
+            }
             Tcl_SetResult(interp, name, TCL_VOLATILE);
         } else {
             result = MagickSetImageMatteColor( wandPtr, pixPtr );
@@ -3165,134 +3174,134 @@ static int wandObjCmd(
                 return myMagickError(interp, wandPtr);
             }
         }
-       break;
+        break;
     }
 
     case TM_PIXELS:       /* pixels x0 y0 cols rows map storageType ?data? */
     case TM_GET_PIXELS:   /* GetPixels x0 y0 cols rows map storageType */
     case TM_SET_PIXELS:   /* GetPixels x0 y0 cols rows map storageType data */
     {
-       static CONST char *storNames[] = {
-           "char", "short", "integer", "long", "float", "double",
-           (char *) NULL
-       };
-       static StorageType storTypes[] = {
-           CharPixel, ShortPixel, IntegerPixel, LongPixel, FloatPixel, DoublePixel
-       };
-       static size_t storSize[] = {
-           sizeof(char), sizeof(short), sizeof(int), sizeof(long), sizeof(float), sizeof(double)
-       };
-       unsigned long cols, rows, size;
-       long x0, y0;
-       int  storIdx, len;
-       char *map;
-       unsigned char *pixels;
-
-       if( ((enum subIndex)index == TM_PIXELS) && ((objc < 8) || (objc > 9)) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x0 y0 cols rows map storageType ?data?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_PIXELS) && (objc != 8) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x0 y0 cols rows map storageType");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_PIXELS) && (objc != 9) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x0 y0 cols rows map storageType data");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[2], &x0)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[3], &y0)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[4], (long int *) &cols)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[5], (long int *) &rows)) != TCL_OK ) {
-           return stat;
-       }
-       map = Tcl_GetString(objv[6]);
-       if (Tcl_GetIndexFromObj(interp, objv[7], storNames, "storageType", 0, &storIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       size = cols * rows * storSize[storIdx] * strlen(map);
-
-       if( objc == 8 ) {
+        static CONST char *storNames[] = {
+            "char", "short", "integer", "long", "float", "double",
+            (char *) NULL
+        };
+        static StorageType storTypes[] = {
+            CharPixel, ShortPixel, IntegerPixel, LongPixel, FloatPixel, DoublePixel
+        };
+        static size_t storSize[] = {
+            sizeof(char), sizeof(short), sizeof(int), sizeof(long), sizeof(float), sizeof(double)
+        };
+        unsigned long cols, rows, size;
+        long x0, y0;
+        int  storIdx, len;
+        char *map;
+        unsigned char *pixels;
+
+        if( ((enum subIndex)index == TM_PIXELS) && ((objc < 8) || (objc > 9)) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x0 y0 cols rows map storageType ?data?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_PIXELS) && (objc != 8) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x0 y0 cols rows map storageType");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_PIXELS) && (objc != 9) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x0 y0 cols rows map storageType data");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[2], &x0)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[3], &y0)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[4], (long int *) &cols)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[5], (long int *) &rows)) != TCL_OK ) {
+            return stat;
+        }
+        map = Tcl_GetString(objv[6]);
+        if (Tcl_GetIndexFromObj(interp, objv[7], storNames, "storageType", 0, &storIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        size = cols * rows * storSize[storIdx] * strlen(map);
+
+        if( objc == 8 ) {
             /*
              * GetImagePixels: Allocate memory for storage
              */
-               pixels = (unsigned char *) ckalloc(size);
-               if( pixels == NULL ) {
-                       Tcl_AppendResult(interp, "TclMagick: out of memory", NULL);
-                       return TCL_ERROR;
-               }
-
-           result = MagickGetImagePixels(wandPtr, x0, y0, cols, rows, map,
-                                         storTypes[storIdx], pixels);
-           if (!result) {
-                   ckfree((char *) pixels);
-               return myMagickError(interp, wandPtr);
-           }
-
-           /*
-            * Return ByteArray object
-            */
-           Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(pixels, (int)size));
-           ckfree((char *) pixels);
-       } else {
-           pixels = Tcl_GetByteArrayFromObj( objv[8], &len);
-           if( (unsigned long)len < size ) {
-               Tcl_AppendResult(interp, "TclMagick: not enough data bytes", NULL);
-               return TCL_ERROR;
-           }
-           result = MagickSetImagePixels(wandPtr, x0, y0, cols, rows, map,
-                                         storTypes[storIdx], pixels);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       }
-       break;
+                pixels = (unsigned char *) ckalloc(size);
+                if( pixels == NULL ) {
+                        Tcl_AppendResult(interp, "TclMagick: out of memory", NULL);
+                        return TCL_ERROR;
+                }
+
+            result = MagickGetImagePixels(wandPtr, x0, y0, cols, rows, map,
+                                          storTypes[storIdx], pixels);
+            if (!result) {
+                    ckfree((char *) pixels);
+                return myMagickError(interp, wandPtr);
+            }
+
+            /*
+             * Return ByteArray object
+             */
+            Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(pixels, (int)size));
+            ckfree((char *) pixels);
+        } else {
+            pixels = Tcl_GetByteArrayFromObj( objv[8], &len);
+            if( (unsigned long)len < size ) {
+                Tcl_AppendResult(interp, "TclMagick: not enough data bytes", NULL);
+                return TCL_ERROR;
+            }
+            result = MagickSetImagePixels(wandPtr, x0, y0, cols, rows, map,
+                                          storTypes[storIdx], pixels);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        }
+        break;
     }
 
     case TM_PROFILE_IMAGE:  /* ProfileImage name ?profile? */
     {
-       char *name;
-       unsigned char *profile = NULL;
+        char *name;
+        unsigned char *profile = NULL;
         int length = 0;
 
         if( (objc != 3) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "name ?profile?");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
+            Tcl_WrongNumArgs(interp, 2, objv, "name ?profile?");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
 
         if( objc > 3 ) {
-           profile = Tcl_GetByteArrayFromObj(objv[3], &length);
+            profile = Tcl_GetByteArrayFromObj(objv[3], &length);
         }
         result = MagickProfileImage(wandPtr, name, profile, (unsigned long)length);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
         break;
     }
 
     case TM_REMOVE_PROFILE: /* RemoveProfile name */
     {
-       char *name;
-       unsigned char *profile;
+        char *name;
+        unsigned char *profile;
         unsigned long length;
 
         if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "name");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
+            Tcl_WrongNumArgs(interp, 2, objv, "name");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
 
         profile = MagickRemoveImageProfile(wandPtr, (const char*)name, &length);
         if(profile != NULL) {
-           Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(profile, (long)length));
-           MagickRelinquishMemory(profile); /* Free TclMagick resource */
+            Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(profile, (long)length));
+            MagickRelinquishMemory(profile); /* Free TclMagick resource */
         }
         break;
     }
@@ -3301,43 +3310,43 @@ static int wandObjCmd(
     case TM_GET_PROFILE:    /* GetProfile name */
     case TM_SET_PROFILE:    /* SetProfile name profile */
     {
-       char *name;
-       unsigned char *profile;
-
-       if( ((enum subIndex)index == TM_PROFILE) && (objc != 3) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "name ?profile?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_PROFILE) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "name");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_PROFILE) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "name profile");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
+        char *name;
+        unsigned char *profile;
+
+        if( ((enum subIndex)index == TM_PROFILE) && (objc != 3) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "name ?profile?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_PROFILE) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "name");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_PROFILE) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "name profile");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
 
         if( objc == 4 ) {
             int length;
             /*
              * Set/Add image profile
              */
-           profile = Tcl_GetByteArrayFromObj(objv[3], &length);
-           result = MagickSetImageProfile(wandPtr, (const char*)name, profile, (unsigned long)length);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
+            profile = Tcl_GetByteArrayFromObj(objv[3], &length);
+            result = MagickSetImageProfile(wandPtr, (const char*)name, profile, (unsigned long)length);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
         } else {
             unsigned long length;
 
             profile = MagickGetImageProfile(wandPtr, name, &length);
-           if(profile != NULL) {
-               Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(profile, (long)length));
-               MagickRelinquishMemory(profile); /* Free TclMagick resource */
+            if(profile != NULL) {
+                Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(profile, (long)length));
+                MagickRelinquishMemory(profile); /* Free TclMagick resource */
             }
-       }
-       break;
+        }
+        break;
     }
 
     case TM_RED_PRIMARY:      /* redprimary ?x y? */
@@ -3346,48 +3355,48 @@ static int wandObjCmd(
     {
         double x, y;
 
-       if( ((enum subIndex)index == TM_RED_PRIMARY) && (objc != 2) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?x y?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_RED_PRIMARY) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_RED_PRIMARY) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y");
-           return TCL_ERROR;
-       }
-       if (objc == 4) {
-           /*
-            * Set primary = x y
-            */
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
-               return stat;
-           }
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
-               return stat;
-           }
-           result = MagickSetImageRedPrimary(wandPtr, x, y);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get primary={x y}
-            */
-           Tcl_Obj *listPtr;
-
-           result = MagickGetImageRedPrimary(wandPtr, &x, &y);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-           listPtr = Tcl_NewListObj(0, NULL);
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(x));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(y));
-           Tcl_SetObjResult(interp, listPtr);
-       }
-       break;
+        if( ((enum subIndex)index == TM_RED_PRIMARY) && (objc != 2) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?x y?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_RED_PRIMARY) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_RED_PRIMARY) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y");
+            return TCL_ERROR;
+        }
+        if (objc == 4) {
+            /*
+             * Set primary = x y
+             */
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
+                return stat;
+            }
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
+                return stat;
+            }
+            result = MagickSetImageRedPrimary(wandPtr, x, y);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get primary={x y}
+             */
+            Tcl_Obj *listPtr;
+
+            result = MagickGetImageRedPrimary(wandPtr, &x, &y);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+            listPtr = Tcl_NewListObj(0, NULL);
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(x));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(y));
+            Tcl_SetObjResult(interp, listPtr);
+        }
+        break;
     }
 
     case TM_RENDERING:      /* rendering ?renderType? */
@@ -3397,94 +3406,94 @@ static int wandObjCmd(
         int renderIdx;
         RenderingIntent render;
 
-       if( ((enum subIndex)index == TM_RENDERING) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?renderType?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_RENDERING) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_RENDERING) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "renderType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set render
-            */
+        if( ((enum subIndex)index == TM_RENDERING) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?renderType?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_RENDERING) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_RENDERING) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "renderType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set render
+             */
             if (Tcl_GetIndexFromObj(interp, objv[2], renderNames, "renderType", 0, &renderIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageRenderingIntent(wandPtr, renderTypes[renderIdx]);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get render
-            */
-           render = MagickGetImageRenderingIntent(wandPtr);
-           for (renderIdx = 0; (size_t) renderIdx < sizeof(renderTypes)/sizeof(renderTypes[0]); renderIdx++) {
-               if( renderTypes[renderIdx] == render ) {
-                   Tcl_SetResult(interp, (char *)renderNames[renderIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)render));
-       }
-       break;
+                return TCL_ERROR;
+            }
+            result = MagickSetImageRenderingIntent(wandPtr, renderTypes[renderIdx]);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get render
+             */
+            render = MagickGetImageRenderingIntent(wandPtr);
+            for (renderIdx = 0; (size_t) renderIdx < sizeof(renderTypes)/sizeof(renderTypes[0]); renderIdx++) {
+                if( renderTypes[renderIdx] == render ) {
+                    Tcl_SetResult(interp, (char *)renderNames[renderIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)render));
+        }
+        break;
     }
 
     case TM_RESOLUTION:     /* resolution ?x? ?y? */
     case TM_GET_RESOLUTION: /* GetResolution */
     case TM_SET_RESOLUTION: /* SetResolution x ?y? */
     {
-       double  x, y;
-
-       if( ((enum subIndex)index == TM_RESOLUTION) && (objc > 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?x? ?y?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_RESOLUTION) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_RESOLUTION) && (objc != 3) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x ?y?");
-           return TCL_ERROR;
-       }
-       if (objc >= 3) {
-           /*
-            * Set resolution = x y, default: y=x
-            */
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
-               return stat;
-           }
+        double  x, y;
+
+        if( ((enum subIndex)index == TM_RESOLUTION) && (objc > 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?x? ?y?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_RESOLUTION) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_RESOLUTION) && (objc != 3) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x ?y?");
+            return TCL_ERROR;
+        }
+        if (objc >= 3) {
+            /*
+             * Set resolution = x y, default: y=x
+             */
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
+                return stat;
+            }
             y = x;
-           if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK) ) {
-               return stat;
-           }
-           result = MagickSetImageResolution(wandPtr, x, y);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get resolution={x y}
-            */
-           Tcl_Obj *listPtr;
-
-           result = MagickGetImageResolution(wandPtr, &x, &y);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-           listPtr = Tcl_NewListObj(0, NULL);
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(x));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(y));
-           Tcl_SetObjResult(interp, listPtr);
-       }
-       break;
+            if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK) ) {
+                return stat;
+            }
+            result = MagickSetImageResolution(wandPtr, x, y);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get resolution={x y}
+             */
+            Tcl_Obj *listPtr;
+
+            result = MagickGetImageResolution(wandPtr, &x, &y);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+            listPtr = Tcl_NewListObj(0, NULL);
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(x));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(y));
+            Tcl_SetObjResult(interp, listPtr);
+        }
+        break;
     }
 
     case TM_SCENE:      /* scene ?num? */
@@ -3493,72 +3502,72 @@ static int wandObjCmd(
     {
         unsigned long num;
 
-       if( (index == TM_SCENE) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?num?");
-           return TCL_ERROR;
-       }
-       if( (index == TM_GET_SCENE) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( (index == TM_SET_SCENE) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "num");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set scene number
-            */
-               if (Tcl_GetLongFromObj(interp, objv[2], (long int *) &num) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageScene(wandPtr, num);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get scene number
-            */
-           num = MagickGetImageScene(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewLongObj((long)num));
-       }
-       break;
+        if( (index == TM_SCENE) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?num?");
+            return TCL_ERROR;
+        }
+        if( (index == TM_GET_SCENE) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( (index == TM_SET_SCENE) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "num");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set scene number
+             */
+                if (Tcl_GetLongFromObj(interp, objv[2], (long int *) &num) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            result = MagickSetImageScene(wandPtr, num);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get scene number
+             */
+            num = MagickGetImageScene(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewLongObj((long)num));
+        }
+        break;
     }
 
     case TM_SIGNATURE:     /* signature */
     case TM_GET_SIGNATURE: /* GetSignature */
     {
-       char *signature;
+        char *signature;
 
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       signature = (char *)MagickGetImageSignature(wandPtr);
-       if(signature != NULL) {
-           Tcl_SetResult(interp, signature, TCL_VOLATILE);
-           MagickRelinquishMemory(signature); /* Free TclMagick resource */
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        signature = (char *)MagickGetImageSignature(wandPtr);
+        if(signature != NULL) {
+            Tcl_SetResult(interp, signature, TCL_VOLATILE);
+            MagickRelinquishMemory(signature); /* Free TclMagick resource */
+        }
+        break;
     }
 
     case TM_IMAGE_SIZE:      /* imagesize */
     case TM_GET_IMAGE_SIZE:  /* GetImageSize */
     {
-       Tcl_WideInt size;
+        Tcl_WideInt size;
 
         if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
         /*
-        * Get image size={xSize ySize}
-        */
+         * Get image size={xSize ySize}
+         */
         size = MagickGetImageSize(wandPtr);
-       Tcl_SetObjResult(interp, Tcl_NewWideIntObj(size));
+        Tcl_SetObjResult(interp, Tcl_NewWideIntObj(size));
 
-       break;
+        break;
     }
 
     case TM_IMAGE_TYPE:      /* imagetype ?type? */
@@ -3568,44 +3577,44 @@ static int wandObjCmd(
         int typeIdx;
         ImageType type;
 
-       if( ((enum subIndex)index == TM_IMAGE_TYPE) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?type?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_IMAGE_TYPE) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_IMAGE_TYPE) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "type");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set image type
-            */
+        if( ((enum subIndex)index == TM_IMAGE_TYPE) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?type?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_IMAGE_TYPE) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_IMAGE_TYPE) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "type");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set image type
+             */
             if (Tcl_GetIndexFromObj(interp, objv[2], typeNames,
-                                   "typeType", 0, &typeIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageType(wandPtr, typeTypes[typeIdx]);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get image type
-            */
-           type = MagickGetImageType(wandPtr);
-           for (typeIdx = 0; (size_t) typeIdx < sizeof(typeTypes)/sizeof(typeTypes[0]); typeIdx++) {
-               if( typeTypes[typeIdx] == type ) {
-                   Tcl_SetResult(interp, (char *)typeNames[typeIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)type));
-       }
-       break;
+                                    "typeType", 0, &typeIdx) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            result = MagickSetImageType(wandPtr, typeTypes[typeIdx]);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get image type
+             */
+            type = MagickGetImageType(wandPtr);
+            for (typeIdx = 0; (size_t) typeIdx < sizeof(typeTypes)/sizeof(typeTypes[0]); typeIdx++) {
+                if( typeTypes[typeIdx] == type ) {
+                    Tcl_SetResult(interp, (char *)typeNames[typeIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)type));
+        }
+        break;
     }
 
     case TM_IMAGE_UNITS:      /* imageunits ?unitType? */
@@ -3615,43 +3624,43 @@ static int wandObjCmd(
         int unitIdx;
         ResolutionType unit;
 
-       if( ((enum subIndex)index == TM_IMAGE_UNITS) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?unitType?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_IMAGE_UNITS) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_IMAGE_UNITS) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "unitType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set image unit
-            */
+        if( ((enum subIndex)index == TM_IMAGE_UNITS) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?unitType?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_IMAGE_UNITS) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_IMAGE_UNITS) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "unitType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set image unit
+             */
             if (Tcl_GetIndexFromObj(interp, objv[2], unitNames, "unitType", 0, &unitIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageUnits(wandPtr, unitTypes[unitIdx]);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get image type
-            */
-           unit = MagickGetImageUnits(wandPtr);
-           for (unitIdx = 0; (size_t) unitIdx < sizeof(unitTypes)/sizeof(unitTypes[0]); unitIdx++) {
-               if( unitTypes[unitIdx] == unit ) {
-                   Tcl_SetResult(interp, (char *)unitNames[unitIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)unit));
-       }
-       break;
+                return TCL_ERROR;
+            }
+            result = MagickSetImageUnits(wandPtr, unitTypes[unitIdx]);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get image type
+             */
+            unit = MagickGetImageUnits(wandPtr);
+            for (unitIdx = 0; (size_t) unitIdx < sizeof(unitTypes)/sizeof(unitTypes[0]); unitIdx++) {
+                if( unitTypes[unitIdx] == unit ) {
+                    Tcl_SetResult(interp, (char *)unitNames[unitIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)unit));
+        }
+        break;
     }
 
     case TM_VIRTUALPIXEL:      /* virtualpixelmethod ?methodType? */
@@ -3661,43 +3670,43 @@ static int wandObjCmd(
         int methodIdx;
         VirtualPixelMethod method;
 
-       if( ((enum subIndex)index == TM_IMAGE_UNITS) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?methodType?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_VIRTUALPIXEL) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_VIRTUALPIXEL) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "methodType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set image virtual pixel method
-            */
+        if( ((enum subIndex)index == TM_IMAGE_UNITS) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?methodType?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_VIRTUALPIXEL) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_VIRTUALPIXEL) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "methodType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set image virtual pixel method
+             */
             if (Tcl_GetIndexFromObj(interp, objv[2], methodNames, "methodType", 0, &methodIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           result = MagickSetImageVirtualPixelMethod(wandPtr, methodTypes[methodIdx]);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get image virtual pixel method
-            */
-           method = MagickGetImageVirtualPixelMethod(wandPtr);
-           for (methodIdx = 0; (size_t) methodIdx < sizeof(methodTypes)/sizeof(methodTypes[0]); methodIdx++) {
-               if( methodTypes[methodIdx] == method ) {
-                   Tcl_SetResult(interp, (char *)methodNames[methodIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)method));
-       }
-       break;
+                return TCL_ERROR;
+            }
+            result = MagickSetImageVirtualPixelMethod(wandPtr, methodTypes[methodIdx]);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get image virtual pixel method
+             */
+            method = MagickGetImageVirtualPixelMethod(wandPtr);
+            for (methodIdx = 0; (size_t) methodIdx < sizeof(methodTypes)/sizeof(methodTypes[0]); methodIdx++) {
+                if( methodTypes[methodIdx] == method ) {
+                    Tcl_SetResult(interp, (char *)methodNames[methodIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)method));
+        }
+        break;
     }
 
     case TM_WHITE_POINT:      /* whitepoint ?x y? */
@@ -3706,63 +3715,63 @@ static int wandObjCmd(
     {
         double x, y;
 
-       if( ((enum subIndex)index == TM_WHITE_POINT) && (objc != 2) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?x y?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_WHITE_POINT) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_WHITE_POINT) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y");
-           return TCL_ERROR;
-       }
-       if (objc == 4) {
-           /*
-            * Set primary = x y
-            */
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
-               return stat;
-           }
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
-               return stat;
-           }
-           result = MagickSetImageWhitePoint(wandPtr, x, y);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get primary={x y}
-            */
-           Tcl_Obj *listPtr;
-
-           result = MagickGetImageWhitePoint(wandPtr, &x, &y);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-           listPtr = Tcl_NewListObj(0, NULL);
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(x));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(y));
-           Tcl_SetObjResult(interp, listPtr);
-       }
-       break;
+        if( ((enum subIndex)index == TM_WHITE_POINT) && (objc != 2) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?x y?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_WHITE_POINT) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_WHITE_POINT) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y");
+            return TCL_ERROR;
+        }
+        if (objc == 4) {
+            /*
+             * Set primary = x y
+             */
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
+                return stat;
+            }
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
+                return stat;
+            }
+            result = MagickSetImageWhitePoint(wandPtr, x, y);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get primary={x y}
+             */
+            Tcl_Obj *listPtr;
+
+            result = MagickGetImageWhitePoint(wandPtr, &x, &y);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+            listPtr = Tcl_NewListObj(0, NULL);
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(x));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(y));
+            Tcl_SetObjResult(interp, listPtr);
+        }
+        break;
     }
 
     case TM_WIDTH:     /* width */
     case TM_GET_WIDTH: /* GetWidth */
     {
-       int value;
+        int value;
 
         if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       value = MagickGetImageWidth(wandPtr);
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        value = MagickGetImageWidth(wandPtr);
         Tcl_SetObjResult(interp, Tcl_NewLongObj(value));
 
-       break;
+        break;
     }
 
     case TM_NUMBER:             /* number */
@@ -3770,13 +3779,13 @@ static int wandObjCmd(
     {
         long num;
 
-       if (objc != 2) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       num = MagickGetNumberImages(wandPtr);
-       Tcl_SetObjResult(interp, Tcl_NewLongObj(num));
-       break;
+        if (objc != 2) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        num = MagickGetNumberImages(wandPtr);
+        Tcl_SetObjResult(interp, Tcl_NewLongObj(num));
+        break;
     }
 
     case TM_SAMPLING_FACTORS:      /* samplingfactors ?factorList? */
@@ -3785,378 +3794,378 @@ static int wandObjCmd(
     {
         double  *factors;
 
-       if( ((enum subIndex)index == TM_SAMPLING_FACTORS) && (objc != 2) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?factorList?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_SAMPLING_FACTORS) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_SAMPLING_FACTORS) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "factorList");
-           return TCL_ERROR;
-       }
-       if (objc == 3) {
-           /*
-            * Set sampling factors
-            */
+        if( ((enum subIndex)index == TM_SAMPLING_FACTORS) && (objc != 2) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?factorList?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_SAMPLING_FACTORS) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_SAMPLING_FACTORS) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "factorList");
+            return TCL_ERROR;
+        }
+        if (objc == 3) {
+            /*
+             * Set sampling factors
+             */
             Tcl_Obj **listPtr;
             int     i, listLen = 0;
 
-           if( (stat = Tcl_ListObjGetElements(interp, objv[2], &listLen, &listPtr)) != TCL_OK) {
-               return stat;
-           }
-           factors = (double *)ckalloc(listLen * sizeof(double));
+            if( (stat = Tcl_ListObjGetElements(interp, objv[2], &listLen, &listPtr)) != TCL_OK) {
+                return stat;
+            }
+            factors = (double *)ckalloc(listLen * sizeof(double));
             if( factors == NULL ) {
-               Tcl_AppendResult(interp, "TclMagick: out of memory", NULL);
-               return TCL_ERROR;
-           }
-           for( i=0; i < listLen; i++ ) {
-               if( (stat = Tcl_GetDoubleFromObj(interp, listPtr[i], &factors[i])) != TCL_OK) {
-                   ckfree((char *)factors);
-                   return stat;
-               }
-           }
-           result = MagickSetSamplingFactors(wandPtr, (unsigned long)listLen, factors);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-       } else {
-           /*
-            * Get size={xSize ySize}
-            */
+                Tcl_AppendResult(interp, "TclMagick: out of memory", NULL);
+                return TCL_ERROR;
+            }
+            for( i=0; i < listLen; i++ ) {
+                if( (stat = Tcl_GetDoubleFromObj(interp, listPtr[i], &factors[i])) != TCL_OK) {
+                    ckfree((char *)factors);
+                    return stat;
+                }
+            }
+            result = MagickSetSamplingFactors(wandPtr, (unsigned long)listLen, factors);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+        } else {
+            /*
+             * Get size={xSize ySize}
+             */
             Tcl_Obj *listPtr = NULL;
             unsigned long i, uLen;
 
-           factors = MagickGetSamplingFactors(wandPtr, &uLen);
-           if( (factors != NULL) && (uLen > 0) ) {
+            factors = MagickGetSamplingFactors(wandPtr, &uLen);
+            if( (factors != NULL) && (uLen > 0) ) {
                 listPtr = Tcl_NewListObj(0, NULL);
-               for( i=0; i < uLen; i++ ) {
+                for( i=0; i < uLen; i++ ) {
                     Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(factors[i]));
                 }
-               Tcl_SetObjResult(interp, listPtr);
+                Tcl_SetObjResult(interp, listPtr);
             }
-           if (factors != NULL)
-               MagickRelinquishMemory(factors); /* Free TclMagick resource */
-       }
-       break;
+            if (factors != NULL)
+                MagickRelinquishMemory(factors); /* Free TclMagick resource */
+        }
+        break;
     }
 
     case TM_SIZE:      /* size ?x y? */
     case TM_GET_SIZE:  /* size */
     case TM_SET_SIZE:  /* size x y */
     {
-       unsigned long x, y;
-
-       if( ((enum subIndex)index == TM_SIZE) && (objc != 2) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?xSize ySize?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_SIZE) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_SIZE) && (objc != 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "xSize ySize");
-           return TCL_ERROR;
-       }
-       if (objc == 4) {
-           /*
-            * Set size = x y
-            */
-
-               if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &x)) != TCL_OK ) {
-               return stat;
-           }
-           if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &y)) != TCL_OK ) {
-               return stat;
-           }
-           MagickSetSize(wandPtr, x, y);
-       } else {
-           /*
-            * Get size={xSize ySize}
-            */
-           Tcl_Obj *listPtr = Tcl_NewListObj(0, NULL);
-
-           result = MagickGetSize(wandPtr, &x, &y);
-           if (!result) {
-               return myMagickError(interp, wandPtr);
-           }
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewLongObj((long)x));
-           Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewLongObj((long)y));
-           Tcl_SetObjResult(interp, listPtr);
-       }
-       break;
+        unsigned long x, y;
+
+        if( ((enum subIndex)index == TM_SIZE) && (objc != 2) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?xSize ySize?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_SIZE) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_SIZE) && (objc != 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "xSize ySize");
+            return TCL_ERROR;
+        }
+        if (objc == 4) {
+            /*
+             * Set size = x y
+             */
+
+                if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &x)) != TCL_OK ) {
+                return stat;
+            }
+            if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &y)) != TCL_OK ) {
+                return stat;
+            }
+            MagickSetSize(wandPtr, x, y);
+        } else {
+            /*
+             * Get size={xSize ySize}
+             */
+            Tcl_Obj *listPtr = Tcl_NewListObj(0, NULL);
+
+            result = MagickGetSize(wandPtr, &x, &y);
+            if (!result) {
+                return myMagickError(interp, wandPtr);
+            }
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewLongObj((long)x));
+            Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewLongObj((long)y));
+            Tcl_SetObjResult(interp, listPtr);
+        }
+        break;
     }
 
     case TM_HASNEXT:
     case TM_HAS_NEXT_IMAGE:
     {
-       if (objc != 2) {
-           Tcl_WrongNumArgs(interp, 1, objv, "");
-           return TCL_ERROR;
-       }
+        if (objc != 2) {
+            Tcl_WrongNumArgs(interp, 1, objv, "");
+            return TCL_ERROR;
+        }
         result = MagickHasNextImage(wandPtr);
-       Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
-       break;
+        Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
+        break;
     }
 
     case TM_HASPREVIOUS:
     case TM_HAS_PREVIOUS_IMAGE:
     {
-       if (objc != 2) {
-           Tcl_WrongNumArgs(interp, 1, objv, "");
-           return TCL_ERROR;
-       }
+        if (objc != 2) {
+            Tcl_WrongNumArgs(interp, 1, objv, "");
+            return TCL_ERROR;
+        }
         result = MagickHasPreviousImage(wandPtr);
-       Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
-       break;
+        Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
+        break;
     }
 
     case TM_IMPLODE:       /* implode ?amount=0.0? */
     case TM_IMPLODE_IMAGE: /* ImplodeImage ?amount? */
     {
-       double  amount=0.0;
+        double  amount=0.0;
 
-       if( objc > 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?amount=0.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &amount)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickImplodeImage(wandPtr, amount);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc > 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?amount=0.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &amount)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickImplodeImage(wandPtr, amount);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_LABEL:        /* label str */
     case TM_LABEL_IMAGE:  /* LabelImage str */
     {
-       Tcl_DString extrep;
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "str");
-           return TCL_ERROR;
-       }
-       result = MagickLabelImage(wandPtr, 
-           Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[2]), -1, &extrep));
+        Tcl_DString extrep;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "str");
+            return TCL_ERROR;
+        }
+        result = MagickLabelImage(wandPtr,
+            Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[2]), -1, &extrep));
 
-       Tcl_DStringFree(&extrep);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
+        Tcl_DStringFree(&extrep);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
 
-       break;
+        break;
     }
 
     case TM_LEVEL:        /* level ?black=0.0? ?gamma=1.0? ?white=MaxRGB? */
     case TM_LEVEL_IMAGE:  /* LevelImage ?black? ?gamma=1.0? ?white=MaxRGB?  */
     {
-       double  black=0.0, white=MaxRGB, gamma=1.0;
-
-       if( objc > 5 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?black=0.0? ?gamma=1.0? ?white=MaxRGB? ");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &black)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &gamma)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &white)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickLevelImage(wandPtr, black, gamma, white);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double  black=0.0, white=MaxRGB, gamma=1.0;
+
+        if( objc > 5 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?black=0.0? ?gamma=1.0? ?white=MaxRGB? ");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &black)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &gamma)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &white)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickLevelImage(wandPtr, black, gamma, white);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_LEVEL_CHANNEL:        /* levelchannel channelType ?black=0.0? ?gamma=1.0? ?white=MaxRGB? */
     case TM_LEVEL_IMAGE_CHANNEL:  /* LevelImageChannel channelType ?black? ?gamma=1.0? ?white=MaxRGB?  */
     {
-       int     chanIdx;
-       double  black=0.0, white=MaxRGB, gamma=1.0;
-
-       if( objc > 6 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "channelType ?black=0.0? ?gamma=1.0? ?white=MaxRGB? ");
-           return TCL_ERROR;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &black)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &gamma)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 5) && ((stat = Tcl_GetDoubleFromObj(interp, objv[5], &white)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickLevelImageChannel(wandPtr, chanTypes[chanIdx], black, gamma, white);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        int     chanIdx;
+        double  black=0.0, white=MaxRGB, gamma=1.0;
+
+        if( objc > 6 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "channelType ?black=0.0? ?gamma=1.0? ?white=MaxRGB? ");
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &black)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &gamma)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 5) && ((stat = Tcl_GetDoubleFromObj(interp, objv[5], &white)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickLevelImageChannel(wandPtr, chanTypes[chanIdx], black, gamma, white);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_MAGNIFY:        /* magnify */
     case TM_MAGNIFY_IMAGE:  /* MagnifyImage */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       result = MagickMagnifyImage(wandPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        result = MagickMagnifyImage(wandPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
 
-       break;
+        break;
     }
 
     case TM_MAP:        /* map mapName ?dither=false? */
     case TM_MAP_IMAGE:  /* MapImage mapName ?dither? */
     {
-       MagickWand      *mapWand;
-       char            *name;
-       int             dither=0;
-
-       if( objc > 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "mapName ?dither=no?");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (mapWand = findMagickWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetBooleanFromObj(interp, objv[3], &dither)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickMapImage( wandPtr, mapWand, dither );
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-
-       break;
+        MagickWand      *mapWand;
+        char            *name;
+        int             dither=0;
+
+        if( objc > 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "mapName ?dither=no?");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (mapWand = findMagickWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetBooleanFromObj(interp, objv[3], &dither)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickMapImage( wandPtr, mapWand, dither );
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+
+        break;
     }
 
     case TM_MATTE_FLOODFILL:        /* mattefloodfill opacity ?fuzz=0.0? ?borderPix=none? ?x=0 y=0? */
     case TM_MATTE_FLOODFILL_IMAGE:  /* MatteFloodfillImage opacity ?fuzz? ?borderPix? ?x y? */
     {
-       unsigned int    opacity;
-       long x = 0, y = 0;
-       double  fuzz = 0.0;
-       char    *name;
-       PixelWand       *borderPtr=NULL;
-
-       if( (objc < 3) || (objc > 7) || (objc == 6) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "opacity ?fuzz=0.0? ?borderPix=none? ?x=0 y=0?");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetIntFromObj(interp, objv[2], (int *) &opacity)) != TCL_OK ) {
-           return stat;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &fuzz)) != TCL_OK) ) {
-           return stat;
-       }
-       if( objc > 4 ) {
-           name = Tcl_GetString(objv[4]);
-           if( (borderPtr = findPixelWand(interp, name)) == NULL ) {
-               return TCL_ERROR;
-           }
-       }
-       if( (objc > 5) && ((stat = Tcl_GetLongFromObj(interp, objv[5], &x)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 6) && ((stat = Tcl_GetLongFromObj(interp, objv[6], &y)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickMatteFloodfillImage(wandPtr, (Quantum)(opacity), fuzz, borderPtr, x, y);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        unsigned int    opacity;
+        long x = 0, y = 0;
+        double  fuzz = 0.0;
+        char    *name;
+        PixelWand       *borderPtr=NULL;
+
+        if( (objc < 3) || (objc > 7) || (objc == 6) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "opacity ?fuzz=0.0? ?borderPix=none? ?x=0 y=0?");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetIntFromObj(interp, objv[2], (int *) &opacity)) != TCL_OK ) {
+            return stat;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &fuzz)) != TCL_OK) ) {
+            return stat;
+        }
+        if( objc > 4 ) {
+            name = Tcl_GetString(objv[4]);
+            if( (borderPtr = findPixelWand(interp, name)) == NULL ) {
+                return TCL_ERROR;
+            }
+        }
+        if( (objc > 5) && ((stat = Tcl_GetLongFromObj(interp, objv[5], &x)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 6) && ((stat = Tcl_GetLongFromObj(interp, objv[6], &y)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickMatteFloodfillImage(wandPtr, (Quantum)(opacity), fuzz, borderPtr, x, y);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_MEDIANFILTER:       /* medianfilter ?radius? */
     case TM_MEDIANFILTER_IMAGE: /* MedianFilterImage ?radius? */
     {
-       double  radius=0.0;
+        double  radius=0.0;
 
-       if( objc > 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickMedianFilterImage(wandPtr, radius);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc > 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickMedianFilterImage(wandPtr, radius);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_MINIFY:        /* minify */
     case TM_MINIFY_IMAGE:  /* MinifyImage */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       result = MagickMinifyImage(wandPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        result = MagickMinifyImage(wandPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
 
-       break;
+        break;
     }
 
     case TM_MODULATE:       /* modulate ?brightness=0.0? ?saturation=0.0? ?hue=0.0? */
     case TM_MODULATE_IMAGE: /* ModulateImage ?brightness? ?saturation? ?hue? */
     {
-       double  brightness=0.0, saturation=0.0, hue=0.0;
-
-       if( objc > 5) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?brightness=0.0? ?saturation=0.0? ?hue=0.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &brightness)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &saturation)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &hue)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickModulateImage(wandPtr, brightness, saturation, hue);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double  brightness=0.0, saturation=0.0, hue=0.0;
+
+        if( objc > 5) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?brightness=0.0? ?saturation=0.0? ?hue=0.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &brightness)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &saturation)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &hue)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickModulateImage(wandPtr, brightness, saturation, hue);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_MONTAGE:       /* montage draw tileGeom thumbGeom mode frameGeom ?newName? */
     case TM_MONTAGE_IMAGE: /* MontageImage draw tileGeom thumbGeom mode frameGeom ?newName? */
         {
-       static CONST char *modeNames[] = {
-           "frame", "unframe", "concatenate",
-           (char *) NULL
-       };
-       static CompositeOperator modeTypes[] = {
-           FrameMode, UnframeMode, ConcatenateMode
-       };
-        char       *name, *newName=NULL;
+        static CONST char *modeNames[] = {
+            "frame", "unframe", "concatenate",
+            (char *) NULL
+        };
+        static CompositeOperator modeTypes[] = {
+            FrameMode, UnframeMode, ConcatenateMode
+        };
+        char        *name, *newName=NULL;
         DrawingWand *drawPtr;
-       MagickWand  *newWand;
+        MagickWand  *newWand;
         int         modeIdx;
         char        *tileGeom, *thumbGeom, *frameGeom;
 
@@ -4167,23 +4176,23 @@ static int wandObjCmd(
         name = Tcl_GetString(objv[2]);
         if( (drawPtr = findDrawingWand(interp, name)) == NULL ) {
             return TCL_ERROR;
-       }
+        }
         tileGeom  = Tcl_GetString(objv[3]);
         thumbGeom = Tcl_GetString(objv[4]);
-       if (Tcl_GetIndexFromObj(interp, objv[5], modeNames, "mode", 0, &modeIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
+        if (Tcl_GetIndexFromObj(interp, objv[5], modeNames, "mode", 0, &modeIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
         frameGeom = Tcl_GetString(objv[6]);
-       if( objc > 7 ) {
-           newName = Tcl_GetString(objv[7]);
-       }
-       newWand = MagickMontageImage(wandPtr, drawPtr, tileGeom, thumbGeom,
-                                    modeTypes[modeIdx], frameGeom);
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       newName = newWandObj(interp, newWand, newName);
-       Tcl_SetResult(interp, newName, TCL_VOLATILE);
+        if( objc > 7 ) {
+            newName = Tcl_GetString(objv[7]);
+        }
+        newWand = MagickMontageImage(wandPtr, drawPtr, tileGeom, thumbGeom,
+                                     modeTypes[modeIdx], frameGeom);
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        newName = newWandObj(interp, newWand, newName);
+        Tcl_SetResult(interp, newName, TCL_VOLATILE);
 
         break;
     }
@@ -4191,301 +4200,301 @@ static int wandObjCmd(
     case TM_MORPH:         /* morph num ?newName? */
     case TM_MORPH_IMAGES:  /* MorphImages num ?newName? */
     {
-       unsigned long num;
-       MagickWand *newWand;
-       char *name=NULL;
-
-       if( (objc < 3) || (objc > 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "num ?newName?");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &num)) != TCL_OK ) {
-           return stat;
-       }
-       if( objc > 3 ) {
-           name = Tcl_GetString(objv[3]);
-       }
-       newWand = MagickMorphImages(wandPtr, num);
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       name = newWandObj(interp, newWand, name);
-       Tcl_SetResult(interp, name, TCL_VOLATILE);
-
-       break;
+        unsigned long num;
+        MagickWand *newWand;
+        char *name=NULL;
+
+        if( (objc < 3) || (objc > 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "num ?newName?");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &num)) != TCL_OK ) {
+            return stat;
+        }
+        if( objc > 3 ) {
+            name = Tcl_GetString(objv[3]);
+        }
+        newWand = MagickMorphImages(wandPtr, num);
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        name = newWandObj(interp, newWand, name);
+        Tcl_SetResult(interp, name, TCL_VOLATILE);
+
+        break;
     }
 
     case TM_MOSAIC:         /* mosaic ?newName? */
     case TM_MOSAIC_IMAGES:  /* MosaicImages ?newName? */
     {
-       MagickWand *newWand;
-       char *name=NULL;
+        MagickWand *newWand;
+        char *name=NULL;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
-           return TCL_ERROR;
-       }
-       if( objc > 2 ) {
-           name = Tcl_GetString(objv[2]);
-       }
-       newWand = MagickMosaicImages(wandPtr);
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       name = newWandObj(interp, newWand, name);
-       Tcl_SetResult(interp, name, TCL_VOLATILE);
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
+            return TCL_ERROR;
+        }
+        if( objc > 2 ) {
+            name = Tcl_GetString(objv[2]);
+        }
+        newWand = MagickMosaicImages(wandPtr);
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        name = newWandObj(interp, newWand, name);
+        Tcl_SetResult(interp, name, TCL_VOLATILE);
 
-       break;
+        break;
     }
 
     case TM_MOTIONBLUR:       /* motionblur ?radius=0.0? ?sigma=0.0? ?angle=0.0? */
     case TM_MOTIONBLUR_IMAGE: /* MotionBlurImage ?radius? ?sigma? ?angle? */
     {
-       double  radius=0.0, sigma=0.0, angle=0.0;
-
-       if( objc > 5) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0? ?sigma=0.0? ?angle=0.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &sigma)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &angle)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickMotionBlurImage(wandPtr, radius, sigma, angle);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double  radius=0.0, sigma=0.0, angle=0.0;
+
+        if( objc > 5) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0? ?sigma=0.0? ?angle=0.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &sigma)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &angle)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickMotionBlurImage(wandPtr, radius, sigma, angle);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_NEGATE:       /* negate ?gray=false? */
     case TM_NEGATE_IMAGE: /* NegateImage ?gray=false? */
     {
-       int gray=0;
+        int gray=0;
 
-       if (objc > 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?gray=no?");
-           return TCL_ERROR;
-       }
+        if (objc > 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?gray=no?");
+            return TCL_ERROR;
+        }
         if( (objc > 2) && ((stat = Tcl_GetBooleanFromObj(interp, objv[2], &gray)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickNegateImage(wandPtr, gray);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+            return stat;
+        }
+        result = MagickNegateImage(wandPtr, gray);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_NEGATE_CHANNEL:       /* negatechannel channelType ?gray=false? */
     case TM_NEGATE_IMAGE_CHANNEL: /* NegateImageChannel channelType ?gray=false? */
     {
-       int gray=0;
+        int gray=0;
         int chanIdx;
 
-       if( (objc < 3) || (objc > 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "channelType ?gray=no?");
-           return TCL_ERROR;
+        if( (objc < 3) || (objc > 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "channelType ?gray=no?");
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
+            return TCL_ERROR;
         }
-       if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
         if( (objc > 3) && ((stat = Tcl_GetBooleanFromObj(interp, objv[3], &gray)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickNegateImageChannel(wandPtr, chanTypes[chanIdx], gray);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+            return stat;
+        }
+        result = MagickNegateImageChannel(wandPtr, chanTypes[chanIdx], gray);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_NEXT:          /* next ?offset=1? */
     case TM_NEXT_IMAGE:    /* NextImage ?offset=1? */
     {
-       int i, ofs=1;
+        int i, ofs=1;
 
-       if (objc > 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?offset=1?");
-           return TCL_ERROR;
-       } else if (objc == 3) {
-           if( (stat = Tcl_GetIntFromObj(interp, objv[2], &ofs)) != TCL_OK ) {
-               return stat;
-           }
-       }
-       for( i=0; i<ofs; i++) {
-           result = MagickNextImage(wandPtr);
-       }
-       Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
-       break;
+        if (objc > 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?offset=1?");
+            return TCL_ERROR;
+        } else if (objc == 3) {
+            if( (stat = Tcl_GetIntFromObj(interp, objv[2], &ofs)) != TCL_OK ) {
+                return stat;
+            }
+        }
+        for( i=0; i<ofs; i++) {
+            result = MagickNextImage(wandPtr);
+        }
+        Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
+        break;
     }
 
     case TM_NORMALIZE:       /* normalize */
     case TM_NORMALIZE_IMAGE: /* NormalizeImage */
     {
-       if (objc != 2) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       result = MagickNormalizeImage(wandPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if (objc != 2) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        result = MagickNormalizeImage(wandPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_OILPAINT:       /* oilpaint ?radius? */
     case TM_OILPAINT_IMAGE: /* OilPaintImage ?radius? */
     {
-       double  radius=0.0;
+        double  radius=0.0;
 
-       if( objc > 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickOilPaintImage(wandPtr, radius);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc > 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickOilPaintImage(wandPtr, radius);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_OPAQUE:        /* opaque targetPix fillPix ?fuzz=0.0? */
     case TM_OPAQUE_IMAGE:  /* OpaqueImage targetPix fillPix ?fuzz=0.0? */
     {
-       double    fuzz=0.0;
-       char      *name;
-       PixelWand *targetPtr, *fillPtr;
-
-       if( (objc < 4) || (objc > 5) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "targetPix fillPix ?fuzz=0.0?");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (targetPtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[3]);
-       if( (fillPtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &fuzz)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickOpaqueImage(wandPtr, targetPtr, fillPtr, fuzz);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double    fuzz=0.0;
+        char      *name;
+        PixelWand *targetPtr, *fillPtr;
+
+        if( (objc < 4) || (objc > 5) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "targetPix fillPix ?fuzz=0.0?");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (targetPtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[3]);
+        if( (fillPtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &fuzz)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickOpaqueImage(wandPtr, targetPtr, fillPtr, fuzz);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_PING:          /* ping filename */
     case TM_PING_IMAGE:    /* PingImage filename */
     {
-       char *filename;
+        char *filename;
 
-       if (objc != 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "filename");
-           return TCL_ERROR;
-       }
-       filename = Tcl_GetString(objv[2]);
-       result = MagickPingImage(wandPtr, filename);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if (objc != 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "filename");
+            return TCL_ERROR;
+        }
+        filename = Tcl_GetString(objv[2]);
+        result = MagickPingImage(wandPtr, filename);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_PREVIEW:         /* preview previewType ?newName? */
     case TM_PREVIEW_IMAGES:  /* PreviewImages previewType ?newName? */
     {
-       int previewIdx;
-       MagickWand *newWand;
-       char *name=NULL;
+        int previewIdx;
+        MagickWand *newWand;
+        char *name=NULL;
 
-       if( (objc < 3) || (objc > 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "previewType ?newName?");
-           return TCL_ERROR;
-       }
+        if( (objc < 3) || (objc > 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "previewType ?newName?");
+            return TCL_ERROR;
+        }
         if (Tcl_GetIndexFromObj(interp, objv[2], previewNames, "previewType", 0, &previewIdx) != TCL_OK) {
             return TCL_ERROR;
-       }
-       if( objc > 3 ) {
-           name = Tcl_GetString(objv[3]);
-       }
-       newWand = MagickPreviewImages(wandPtr, previewTypes[previewIdx]);
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       name = newWandObj(interp, newWand, name);
-       Tcl_SetResult(interp, name, TCL_VOLATILE);
+        }
+        if( objc > 3 ) {
+            name = Tcl_GetString(objv[3]);
+        }
+        newWand = MagickPreviewImages(wandPtr, previewTypes[previewIdx]);
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        name = newWandObj(interp, newWand, name);
+        Tcl_SetResult(interp, name, TCL_VOLATILE);
 
-       break;
+        break;
     }
 
     case TM_PREVIOUS:          /* previous ?offset=1? */
     case TM_PREVIOUS_IMAGE:    /* PreviousImage ?offset=1? */
     {
-       int i, ofs=1;
+        int i, ofs=1;
 
-       if (objc > 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?offset?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetIntFromObj(interp, objv[2], &ofs)) != TCL_OK) ) {
-           return stat;
-       }
-       for( i=0; i<ofs; i++) {
-           result = MagickPreviousImage(wandPtr);
-       }
-       Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
-       break;
+        if (objc > 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?offset?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetIntFromObj(interp, objv[2], &ofs)) != TCL_OK) ) {
+            return stat;
+        }
+        for( i=0; i<ofs; i++) {
+            result = MagickPreviousImage(wandPtr);
+        }
+        Tcl_SetObjResult(interp, Tcl_NewIntObj(result));
+        break;
     }
 
     case TM_QUANTIZE:        /* quantize numColors ?colorspaceType? ?treedepth? ?dither? ?measureError? */
     case TM_QUANTIZE_IMAGE:  /* QuantizeImage numColors ?colorspaceType? ?treedepth? ?dither? ?measureError? */
     case TM_QUANTIZE_IMAGES: /* QuantizeImage numColors ?colorspaceType? ?treedepth? ?dither? ?measureError? */
     {
-       unsigned long numColors, treeDepth=0;
-       int dither=0, measureError=0;
-       int csIdx=RGBColorspace;
-
-       if( (objc < 3) || (objc > 7) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "numColors ?colorspaceType=RGB? ?treedepth=0? ?dither=no? ?measureError=no?");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &numColors)) != TCL_OK ) {
-           return stat;
-       }
-       if( (objc > 3) && (Tcl_GetIndexFromObj(interp, objv[3], csNames, "colorspaceType", 0, &csIdx) != TCL_OK) ) {
-           return TCL_ERROR;
-       }
-       if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4], (long int *) &treeDepth)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 5) && ((stat = Tcl_GetBooleanFromObj(interp, objv[5], &dither)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 6) && ((stat = Tcl_GetBooleanFromObj(interp, objv[6], &measureError)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (enum subIndex)index == TM_QUANTIZE_IMAGES ) {
-           result = MagickQuantizeImages(wandPtr, numColors, csTypes[csIdx], treeDepth, dither, measureError);
-       } else {
-           result = MagickQuantizeImage(wandPtr, numColors, csTypes[csIdx], treeDepth, dither, measureError);
-       }
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        unsigned long numColors, treeDepth=0;
+        int dither=0, measureError=0;
+        int csIdx=RGBColorspace;
+
+        if( (objc < 3) || (objc > 7) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "numColors ?colorspaceType=RGB? ?treedepth=0? ?dither=no? ?measureError=no?");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &numColors)) != TCL_OK ) {
+            return stat;
+        }
+        if( (objc > 3) && (Tcl_GetIndexFromObj(interp, objv[3], csNames, "colorspaceType", 0, &csIdx) != TCL_OK) ) {
+            return TCL_ERROR;
+        }
+        if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4], (long int *) &treeDepth)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 5) && ((stat = Tcl_GetBooleanFromObj(interp, objv[5], &dither)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 6) && ((stat = Tcl_GetBooleanFromObj(interp, objv[6], &measureError)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (enum subIndex)index == TM_QUANTIZE_IMAGES ) {
+            result = MagickQuantizeImages(wandPtr, numColors, csTypes[csIdx], treeDepth, dither, measureError);
+        } else {
+            result = MagickQuantizeImage(wandPtr, numColors, csTypes[csIdx], treeDepth, dither, measureError);
+        }
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_QUERYFONTMETRICS:     /* queryfontmetrics draw text */
@@ -4495,28 +4504,28 @@ static int wandObjCmd(
         int     i;
         Tcl_Obj *listPtr;
         char    *name, *text;
-       DrawingWand *drawPtr;
-
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "draw text");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (drawPtr = findDrawingWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       text = Tcl_GetString(objv[3]);
-
-       metrics = MagickQueryFontMetrics(wandPtr, drawPtr, text);
-       if( (metrics != NULL) ) {
+        DrawingWand *drawPtr;
+
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "draw text");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (drawPtr = findDrawingWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        text = Tcl_GetString(objv[3]);
+
+        metrics = MagickQueryFontMetrics(wandPtr, drawPtr, text);
+        if( (metrics != NULL) ) {
             listPtr = Tcl_NewListObj(0, NULL);
-           for( i=0; i < 7; i++ ) {
+            for( i=0; i < 7; i++ ) {
                 Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(metrics[i]));
             }
-           Tcl_SetObjResult(interp, listPtr);
+            Tcl_SetObjResult(interp, listPtr);
         }
-       if (metrics != NULL)
-           MagickRelinquishMemory(metrics); /* Free TclMagick resource */
+        if (metrics != NULL)
+            MagickRelinquishMemory(metrics); /* Free TclMagick resource */
 
         break;
     }
@@ -4524,835 +4533,835 @@ static int wandObjCmd(
     case TM_RAISE:        /* raise width height ?x y? ?raise? */
     case TM_RAISE_IMAGE:  /* RaiseImage width height ?x y? ?raise? */
     {
-       unsigned long width, height;
-       long x=0, y=0;
-       int raise=0;
-
-       if( (objc < 4) || (objc > 7) || (objc == 5) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "width height ?x y? ?raise=no?");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &width)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &height)) != TCL_OK ) {
-           return stat;
-       }
-       if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4], &x)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 5) && ((stat = Tcl_GetLongFromObj(interp, objv[5], &y)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 6) && ((stat = Tcl_GetBooleanFromObj(interp, objv[6], &raise)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickRaiseImage(wandPtr, width, height, x, y, raise);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        unsigned long width, height;
+        long x=0, y=0;
+        int raise=0;
+
+        if( (objc < 4) || (objc > 7) || (objc == 5) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "width height ?x y? ?raise=no?");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &width)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &height)) != TCL_OK ) {
+            return stat;
+        }
+        if( (objc > 4) && ((stat = Tcl_GetLongFromObj(interp, objv[4], &x)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 5) && ((stat = Tcl_GetLongFromObj(interp, objv[5], &y)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 6) && ((stat = Tcl_GetBooleanFromObj(interp, objv[6], &raise)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickRaiseImage(wandPtr, width, height, x, y, raise);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_READ:          /* read filename */
     case TM_READ_IMAGE:    /* ReadImage filename */
     {
-       char *filename;
-       Tcl_DString extrep;
+        char *filename;
+        Tcl_DString extrep;
 
-       if (objc != 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "filename");
-           return TCL_ERROR;
-       }
-       filename = Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[2]), -1, &extrep);
-       result = MagickReadImage(wandPtr, filename);
-       Tcl_DStringFree(&extrep);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if (objc != 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "filename");
+            return TCL_ERROR;
+        }
+        filename = Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[2]), -1, &extrep);
+        result = MagickReadImage(wandPtr, filename);
+        Tcl_DStringFree(&extrep);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_READ_BLOB:          /* readblob data */
     case TM_READ_IMAGE_BLOB:    /* ReadImageBlob data */
     {
-       unsigned char *data;
+        unsigned char *data;
         int length;
 
-       if (objc != 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "data");
-           return TCL_ERROR;
-       }
-       data = Tcl_GetByteArrayFromObj(objv[2], &length);
-       result = MagickReadImageBlob(wandPtr, data, (size_t)length);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if (objc != 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "data");
+            return TCL_ERROR;
+        }
+        data = Tcl_GetByteArrayFromObj(objv[2], &length);
+        result = MagickReadImageBlob(wandPtr, data, (size_t)length);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_REDUCENOISE:       /* reducenoise ?radius? */
     case TM_REDUCENOISE_IMAGE: /* ReduceNoiseImage ?radius? */
     {
-       double  radius=0.0;
+        double  radius=0.0;
 
-       if( objc > 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickReduceNoiseImage(wandPtr, radius);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc > 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickReduceNoiseImage(wandPtr, radius);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_REMOVE:        /* remove */
     case TM_REMOVE_IMAGE:  /* RemoveImage */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       result = MagickRemoveImage(wandPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        result = MagickRemoveImage(wandPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_RESETITERATOR:   /* resetiterator */
     case TM_RESET_ITERATOR:  /* ResetIterator */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       MagickResetIterator(wandPtr);
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        MagickResetIterator(wandPtr);
+        break;
     }
 
     case TM_RESAMPLE:        /* resample xRes ?yRes? ?filter? ?blur=1.0? */
     case TM_RESAMPLE_IMAGE:  /* ResampleImage xRes ?yRes? ?filter? ?blur=1.0? */
     {
-       int     filterIdx=0;
-       double  xRes, yRes, blur=1.0;
-
-       if( (objc < 3) || (objc > 6) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "xRes ?yRes=xRes? ?filterType=undefined? ?blur=1.0?");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &xRes)) != TCL_OK ) {
-           return stat;
-       }
-       yRes = xRes; /* default */
-       if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &yRes)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 4) && (Tcl_GetIndexFromObj(interp, objv[4], filterNames, "filterType",
-                                              0, &filterIdx) != TCL_OK) ) {
-           return TCL_ERROR;
-       }
-       if( (objc > 5) && ((stat = Tcl_GetDoubleFromObj(interp, objv[5], &blur)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickResampleImage(wandPtr, xRes, yRes, filterTypes[filterIdx], blur);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        int     filterIdx=0;
+        double  xRes, yRes, blur=1.0;
+
+        if( (objc < 3) || (objc > 6) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "xRes ?yRes=xRes? ?filterType=undefined? ?blur=1.0?");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &xRes)) != TCL_OK ) {
+            return stat;
+        }
+        yRes = xRes; /* default */
+        if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &yRes)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 4) && (Tcl_GetIndexFromObj(interp, objv[4], filterNames, "filterType",
+                                               0, &filterIdx) != TCL_OK) ) {
+            return TCL_ERROR;
+        }
+        if( (objc > 5) && ((stat = Tcl_GetDoubleFromObj(interp, objv[5], &blur)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickResampleImage(wandPtr, xRes, yRes, filterTypes[filterIdx], blur);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_RESIZE:        /* resize x y ?filter? ?blur=1.0? */
     case TM_RESIZE_IMAGE:  /* ResizeImage x y ?filter? ?blur=1.0? */
     {
-       int     filterIdx=0;
-       unsigned long x, y;
-       double  blur=1.0;
-
-       if( (objc < 4) || (objc > 6) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y ?filterType=undefined? ?blur=1.0?");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &x)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &y)) != TCL_OK ) {
-           return stat;
-       }
-       if( (objc > 4) && (Tcl_GetIndexFromObj(interp, objv[4], filterNames, "filterType", 0, &filterIdx) != TCL_OK) ) {
-           return TCL_ERROR;
-       }
-       if( (objc > 5) && ((stat = Tcl_GetDoubleFromObj(interp, objv[5], &blur)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickResizeImage(wandPtr, x, y, filterTypes[filterIdx], blur);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        int     filterIdx=0;
+        unsigned long x, y;
+        double  blur=1.0;
+
+        if( (objc < 4) || (objc > 6) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y ?filterType=undefined? ?blur=1.0?");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &x)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &y)) != TCL_OK ) {
+            return stat;
+        }
+        if( (objc > 4) && (Tcl_GetIndexFromObj(interp, objv[4], filterNames, "filterType", 0, &filterIdx) != TCL_OK) ) {
+            return TCL_ERROR;
+        }
+        if( (objc > 5) && ((stat = Tcl_GetDoubleFromObj(interp, objv[5], &blur)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickResizeImage(wandPtr, x, y, filterTypes[filterIdx], blur);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_ROLL:       /* roll xOfs yOfs */
     case TM_ROLL_IMAGE: /* RollImage xOfs yOfs */
     {
-       int  xOfs, yOfs;
-
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "xOfs yOfs");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetIntFromObj(interp, objv[2], &xOfs)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetIntFromObj(interp, objv[3], &yOfs)) != TCL_OK ) {
-           return stat;
-       }
-       result = MagickRollImage(wandPtr, xOfs, yOfs);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        int  xOfs, yOfs;
+
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "xOfs yOfs");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetIntFromObj(interp, objv[2], &xOfs)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetIntFromObj(interp, objv[3], &yOfs)) != TCL_OK ) {
+            return stat;
+        }
+        result = MagickRollImage(wandPtr, xOfs, yOfs);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_ROTATE:        /* rotate background degrees */
     case TM_ROTATE_IMAGE:  /* RotateImage background degrees */
     {
-       double    degrees;
-       PixelWand *bgPtr;
-       char      *name;
-
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "background degrees");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (bgPtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &degrees)) != TCL_OK ) {
-           return stat;
-       }
-       result = MagickRotateImage(wandPtr, bgPtr, degrees);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double    degrees;
+        PixelWand *bgPtr;
+        char      *name;
+
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "background degrees");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (bgPtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &degrees)) != TCL_OK ) {
+            return stat;
+        }
+        result = MagickRotateImage(wandPtr, bgPtr, degrees);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_SAMPLE:       /* sample x y */
     case TM_SAMPLE_IMAGE: /* SampleImage x y */
     {
-       unsigned long  x, y;
-
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &x)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &y)) != TCL_OK ) {
-           return stat;
-       }
-       result = MagickSampleImage(wandPtr, x, y);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        unsigned long  x, y;
+
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &x)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &y)) != TCL_OK ) {
+            return stat;
+        }
+        result = MagickSampleImage(wandPtr, x, y);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_SCALE:       /* scale x y */
     case TM_SCALE_IMAGE: /* ScaleImage x y */
     {
-       unsigned long  x, y;
-
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &x)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &y)) != TCL_OK ) {
-           return stat;
-       }
-       result = MagickScaleImage(wandPtr, x, y);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        unsigned long  x, y;
+
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &x)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &y)) != TCL_OK ) {
+            return stat;
+        }
+        result = MagickScaleImage(wandPtr, x, y);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_SEPARATE:         /* separate channelType */
     case TM_SEPARATE_CHANNEL: /* SeparateImageChannel channelType */
     {
-       int chanIdx;
+        int chanIdx;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "channelType");
-           return TCL_ERROR;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       result = MagickSeparateImageChannel(wandPtr, chanTypes[chanIdx]);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "channelType");
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        result = MagickSeparateImageChannel(wandPtr, chanTypes[chanIdx]);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_SETIMAGE:  /* setimage name */
     case TM_SET_IMAGE: /* SetImage name */
     {
-       char *name = NULL;
-       MagickWand *setWand;
+        char *name = NULL;
+        MagickWand *setWand;
 
-       if (objc != 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "setwand");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (setWand = findMagickWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       result = MagickSetImage(wandPtr, setWand);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if (objc != 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "setwand");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (setWand = findMagickWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        result = MagickSetImage(wandPtr, setWand);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_SETOPTION:  /* setoption format key value */
     case TM_SET_OPTION: /* SetOption format key value */
     {
-       char *format, *key, *value;
+        char *format, *key, *value;
 
-       if (objc != 5) {
-           Tcl_WrongNumArgs(interp, 2, objv, "format key value");
-           return TCL_ERROR;
-       }
-       format  = Tcl_GetString(objv[2]);
-       key = Tcl_GetString(objv[3]);
-       value = Tcl_GetString(objv[4]);
-       result = MagickSetImageOption(wandPtr, format, key, value);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if (objc != 5) {
+            Tcl_WrongNumArgs(interp, 2, objv, "format key value");
+            return TCL_ERROR;
+        }
+        format  = Tcl_GetString(objv[2]);
+        key = Tcl_GetString(objv[3]);
+        value = Tcl_GetString(objv[4]);
+        result = MagickSetImageOption(wandPtr, format, key, value);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_PASSPHRASE:     /* passphrase phrase */
     case TM_SET_PASSPHRASE: /* SetPassphrase phrase */
     {
-       char *phrase;
+        char *phrase;
 
-       if (objc != 3) {
-           Tcl_WrongNumArgs(interp, 2, objv, "phrase");
-           return TCL_ERROR;
-       }
-       phrase  = Tcl_GetString(objv[2]);
-       result = MagickSetPassphrase(wandPtr, phrase);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if (objc != 3) {
+            Tcl_WrongNumArgs(interp, 2, objv, "phrase");
+            return TCL_ERROR;
+        }
+        phrase  = Tcl_GetString(objv[2]);
+        result = MagickSetPassphrase(wandPtr, phrase);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_SHARPEN:       /* sharpen ?radius? ?sigma? */
     case TM_SHARPEN_IMAGE: /* SharpenImage ?radius? ?sigma? */
     {
-       double  radius=0.0, sigma=1.0;
-
-       if( objc > 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0? ?sigma=1.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &sigma)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickSharpenImage(wandPtr, radius, sigma);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double  radius=0.0, sigma=1.0;
+
+        if( objc > 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0? ?sigma=1.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &sigma)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickSharpenImage(wandPtr, radius, sigma);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_SHAVE:       /* shave x y */
     case TM_SHAVE_IMAGE: /* ShaveImage x y */
     {
-       unsigned long x, y;
-
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &x)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &y)) != TCL_OK ) {
-           return stat;
-       }
-       result = MagickShaveImage(wandPtr, x, y);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        unsigned long x, y;
+
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &x)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &y)) != TCL_OK ) {
+            return stat;
+        }
+        result = MagickShaveImage(wandPtr, x, y);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_SHEAR:        /* shear background xShear ?yShear? */
     case TM_SHEAR_IMAGE:  /* ShearImage background xShear ?yShear? */
     {
-       double    xShear, yShear;
-       PixelWand *bgPtr;
-       char      *name;
-
-       if( (objc < 4) || (objc > 5) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "background xShear ?yShear=xShear?");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (bgPtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &xShear)) != TCL_OK ) {
-           return stat;
-       }
-       yShear = xShear; /* default */
-       if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &yShear)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickShearImage(wandPtr, bgPtr, xShear, yShear);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double    xShear, yShear;
+        PixelWand *bgPtr;
+        char      *name;
+
+        if( (objc < 4) || (objc > 5) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "background xShear ?yShear=xShear?");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (bgPtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &xShear)) != TCL_OK ) {
+            return stat;
+        }
+        yShear = xShear; /* default */
+        if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &yShear)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickShearImage(wandPtr, bgPtr, xShear, yShear);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_SOLARIZE:        /* solarize ?threshold? */
     case TM_SOLARIZE_IMAGE:  /* SolarizeImage ?threshold? */
     {
-       double    threshold=0.0;
+        double    threshold=0.0;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?threshold=0.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &threshold)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickSolarizeImage(wandPtr, threshold);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?threshold=0.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &threshold)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickSolarizeImage(wandPtr, threshold);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_SPREAD:       /* spread ?radius? */
     case TM_SPREAD_IMAGE: /* SpreadImage ?radius? */
     {
-       double  radius=0.0;
+        double  radius=0.0;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickSpreadImage(wandPtr, radius);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickSpreadImage(wandPtr, radius);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_STEGANO:       /* stegano watermark ?offset=0? ?newName? */
     case TM_STEGANO_IMAGE: /* SteganoImage watermark ?offset=0? ?newName? */
     {
-       MagickWand      *watermarkPtr, *newWand;
-       char            *name, *newName=NULL;
-       int             offset=0;
-
-       if( objc > 5 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "watermark ?offset=0?");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (watermarkPtr = findMagickWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetIntFromObj(interp, objv[3], &offset)) != TCL_OK) ) {
-           return stat;
-       }
-       if( objc > 4 ) {
-           newName = Tcl_GetString(objv[4]);
-       }
-       newWand = MagickSteganoImage( wandPtr, watermarkPtr, offset );
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       newName = newWandObj(interp, newWand, newName);
-       Tcl_SetResult(interp, newName, TCL_VOLATILE);
-
-       break;
+        MagickWand      *watermarkPtr, *newWand;
+        char            *name, *newName=NULL;
+        int             offset=0;
+
+        if( objc > 5 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "watermark ?offset=0?");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (watermarkPtr = findMagickWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetIntFromObj(interp, objv[3], &offset)) != TCL_OK) ) {
+            return stat;
+        }
+        if( objc > 4 ) {
+            newName = Tcl_GetString(objv[4]);
+        }
+        newWand = MagickSteganoImage( wandPtr, watermarkPtr, offset );
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        newName = newWandObj(interp, newWand, newName);
+        Tcl_SetResult(interp, newName, TCL_VOLATILE);
+
+        break;
     }
 
     case TM_STEREO:       /* stereo anotherWand ?newName? */
     case TM_STEREO_IMAGE: /* StereoImage anotherwand ?newName? */
     {
-       MagickWand      *anotherPtr, *newWand;
-       char            *name, *newName=NULL;
-
-       if( objc > 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "anotherWand ?newName?");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (anotherPtr = findMagickWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if( objc > 3 ) {
-           newName = Tcl_GetString(objv[3]);
-       }
-       newWand = MagickStereoImage( wandPtr, anotherPtr );
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       newName = newWandObj(interp, newWand, newName);
-       Tcl_SetResult(interp, newName, TCL_VOLATILE);
-
-       break;
+        MagickWand      *anotherPtr, *newWand;
+        char            *name, *newName=NULL;
+
+        if( objc > 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "anotherWand ?newName?");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (anotherPtr = findMagickWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if( objc > 3 ) {
+            newName = Tcl_GetString(objv[3]);
+        }
+        newWand = MagickStereoImage( wandPtr, anotherPtr );
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        newName = newWandObj(interp, newWand, newName);
+        Tcl_SetResult(interp, newName, TCL_VOLATILE);
+
+        break;
     }
 
     case TM_STRIP:       /* strip */
     case TM_STRIP_IMAGE: /* StripImage */
     {
-       if( objc > 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       result = MagickStripImage(wandPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc > 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        result = MagickStripImage(wandPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_SWIRL:       /* swirl ?degrees? */
     case TM_SWIRL_IMAGE: /* SwirlImage ?degrees? */
     {
-       double  degrees=0.0;
+        double  degrees=0.0;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?degrees=0.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &degrees)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickSwirlImage(wandPtr, degrees);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?degrees=0.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &degrees)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickSwirlImage(wandPtr, degrees);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_TEXTURE:       /* texture textWand ?newName? */
     case TM_TEXTURE_IMAGE: /* TextureImage textWand ?newName? */
     {
-       MagickWand      *textPtr, *newWand;
-       char            *name, *newName=NULL;
-
-       if( objc > 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "textWand ?newName?");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (textPtr = findMagickWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if( objc > 3 ) {
-           newName = Tcl_GetString(objv[3]);
-       }
-       newWand = MagickTextureImage( wandPtr, textPtr );
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       newName = newWandObj(interp, newWand, newName);
-       Tcl_SetResult(interp, newName, TCL_VOLATILE);
-
-       break;
+        MagickWand      *textPtr, *newWand;
+        char            *name, *newName=NULL;
+
+        if( objc > 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "textWand ?newName?");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (textPtr = findMagickWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if( objc > 3 ) {
+            newName = Tcl_GetString(objv[3]);
+        }
+        newWand = MagickTextureImage( wandPtr, textPtr );
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        newName = newWandObj(interp, newWand, newName);
+        Tcl_SetResult(interp, newName, TCL_VOLATILE);
+
+        break;
     }
 
     case TM_THRESHOLD:        /* threshold threshold */
     case TM_THRESHOLD_IMAGE:  /* ThresholdImage threshold */
     {
-       double    threshold=0.0;
+        double    threshold=0.0;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "threshold");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &threshold)) != TCL_OK ) {
-           return stat;
-       }
-       result = MagickThresholdImage(wandPtr, threshold);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "threshold");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &threshold)) != TCL_OK ) {
+            return stat;
+        }
+        result = MagickThresholdImage(wandPtr, threshold);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_THRESHOLDCHANNEL:         /* thresholdchannel channelType threshold */
     case TM_THRESHOLD_IMAGE_CHANNEL:  /* ThresholdImageChannel channelType threshold */
     {
         int    chanIdx;
-       double threshold=0.0;
-
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "channelType threshold");
-           return TCL_ERROR;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &threshold)) != TCL_OK ) {
-           return stat;
-       }
-       result = MagickThresholdImageChannel(wandPtr, chanTypes[chanIdx], threshold);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double threshold=0.0;
+
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "channelType threshold");
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[2], chanNames, "channelType", 0, &chanIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &threshold)) != TCL_OK ) {
+            return stat;
+        }
+        result = MagickThresholdImageChannel(wandPtr, chanTypes[chanIdx], threshold);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_TINT:        /* tint tintPixel opacityPixel */
     case TM_TINT_IMAGE:  /* TintImage tintPixel opacityPixel */
     {
-       char      *name;
-       PixelWand *tintPtr, *opacityPtr;
-
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "tintPixel opacityPixel");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (tintPtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[3]);
-       if( (opacityPtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-
-       result = MagickTintImage(wandPtr, tintPtr, opacityPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        char      *name;
+        PixelWand *tintPtr, *opacityPtr;
+
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "tintPixel opacityPixel");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (tintPtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[3]);
+        if( (opacityPtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+
+        result = MagickTintImage(wandPtr, tintPtr, opacityPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_TRANSFORM:       /* transform crop geometry ?newName? */
     case TM_TRANSFORM_IMAGE: /* TransformImage crop geometry ?newName? */
     {
-       MagickWand      *newWand;
-       char            *crop, *geometry, *newName=NULL;
+        MagickWand      *newWand;
+        char            *crop, *geometry, *newName=NULL;
 
-       if( (objc < 4) || (objc > 5) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "crop geometry ?newName?");
-           return TCL_ERROR;
-       }
-       crop = Tcl_GetString(objv[2]);
-       geometry = Tcl_GetString(objv[3]);
-       if( objc > 4 ) {
-           newName = Tcl_GetString(objv[4]);
-       }
-       newWand = MagickTransformImage( wandPtr, crop, geometry );
-       if (newWand == NULL) {
-           return myMagickError(interp, wandPtr);
-       }
-       newName = newWandObj(interp, newWand, newName);
-       Tcl_SetResult(interp, newName, TCL_VOLATILE);
+        if( (objc < 4) || (objc > 5) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "crop geometry ?newName?");
+            return TCL_ERROR;
+        }
+        crop = Tcl_GetString(objv[2]);
+        geometry = Tcl_GetString(objv[3]);
+        if( objc > 4 ) {
+            newName = Tcl_GetString(objv[4]);
+        }
+        newWand = MagickTransformImage( wandPtr, crop, geometry );
+        if (newWand == NULL) {
+            return myMagickError(interp, wandPtr);
+        }
+        newName = newWandObj(interp, newWand, newName);
+        Tcl_SetResult(interp, newName, TCL_VOLATILE);
 
-       break;
+        break;
     }
 
     case TM_TRANSPARENT:        /* transparent targetPix ?opacity? ?fuzz=0.0? */
     case TM_TRANSPARENT_IMAGE:  /* TransparentImage targetPix ?opacity? ?fuzz=0.0? */
     {
-       double    fuzz=0.0;
-       unsigned  opacity=0;
-       char      *name;
-       PixelWand *targetPtr;
-
-       if( (objc < 3) || (objc > 5) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "targetPix ?opacity=0? ?fuzz=0.0?");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (targetPtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetIntFromObj(interp, objv[3], (int *) &opacity)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &fuzz)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickTransparentImage(wandPtr, targetPtr, (const Quantum)opacity, fuzz);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double    fuzz=0.0;
+        unsigned  opacity=0;
+        char      *name;
+        PixelWand *targetPtr;
+
+        if( (objc < 3) || (objc > 5) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "targetPix ?opacity=0? ?fuzz=0.0?");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (targetPtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetIntFromObj(interp, objv[3], (int *) &opacity)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &fuzz)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickTransparentImage(wandPtr, targetPtr, (const Quantum)opacity, fuzz);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_TRIM:        /* trim ?fuzz=0.0? */
     case TM_TRIM_IMAGE:  /* TrimImage ?fuzz=0.0? */
     {
-       double    fuzz=0.0;
+        double    fuzz=0.0;
 
-       if( objc > 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?fuzz=0.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &fuzz)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickTrimImage(wandPtr, fuzz);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        if( objc > 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?fuzz=0.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &fuzz)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickTrimImage(wandPtr, fuzz);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_UNSHARPMASK:        /* unsharpmask ?radius? ?sigma? ?amount? ?threshold? */
     case TM_UNSHARPMASK_IMAGE:  /* UnsharpMaskImage ?radius? ?sigma? ?amount? ?threshold? */
     {
-       double radius=0.0, sigma=1.0, amount=0.0, threshold=0.0;
-
-       if( objc > 6 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0? ?sigma=1.0? ?amount=0.0? ?threshold=0.0?");
-           return TCL_ERROR;
-       }
-       if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &sigma)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &amount)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (objc > 5) && ((stat = Tcl_GetDoubleFromObj(interp, objv[5], &threshold)) != TCL_OK) ) {
-           return stat;
-       }
-       result = MagickUnsharpMaskImage(wandPtr, radius, sigma, amount, threshold);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double radius=0.0, sigma=1.0, amount=0.0, threshold=0.0;
+
+        if( objc > 6 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?radius=0.0? ?sigma=1.0? ?amount=0.0? ?threshold=0.0?");
+            return TCL_ERROR;
+        }
+        if( (objc > 2) && ((stat = Tcl_GetDoubleFromObj(interp, objv[2], &radius)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &sigma)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 4) && ((stat = Tcl_GetDoubleFromObj(interp, objv[4], &amount)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (objc > 5) && ((stat = Tcl_GetDoubleFromObj(interp, objv[5], &threshold)) != TCL_OK) ) {
+            return stat;
+        }
+        result = MagickUnsharpMaskImage(wandPtr, radius, sigma, amount, threshold);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_WAVE:        /* wave amplitude wavelength */
     case TM_WAVE_IMAGE:  /* WaveImage amplitude wavelength */
     {
-       double amplitude, wavelength;
-
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "amplitude wavelength");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &amplitude)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &wavelength)) != TCL_OK ) {
-           return stat;
-       }
-       result = MagickWaveImage(wandPtr, amplitude, wavelength);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        double amplitude, wavelength;
+
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "amplitude wavelength");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &amplitude)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &wavelength)) != TCL_OK ) {
+            return stat;
+        }
+        result = MagickWaveImage(wandPtr, amplitude, wavelength);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_WHITE_THRESHOLD:        /* whitethreshold thresholdPixel */
     case TM_WHITE_THRESHOLD_IMAGE:  /* WhiteThresholdImage thresholdPixel */
     {
-       char    *name;
-       PixelWand       *threshPtr;
+        char    *name;
+        PixelWand       *threshPtr;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "thresholdPixel");
-           return TCL_ERROR;
-       }
-       name = Tcl_GetString(objv[2]);
-       if( (threshPtr = findPixelWand(interp, name)) == NULL ) {
-           return TCL_ERROR;
-       }
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "thresholdPixel");
+            return TCL_ERROR;
+        }
+        name = Tcl_GetString(objv[2]);
+        if( (threshPtr = findPixelWand(interp, name)) == NULL ) {
+            return TCL_ERROR;
+        }
 
-       result = MagickWhiteThresholdImage(wandPtr, threshPtr);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        result = MagickWhiteThresholdImage(wandPtr, threshPtr);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_WRITE:         /* write filename */
     case TM_WRITE_IMAGE:   /* WriteImage filename */
     case TM_WRITE_IMAGES:  /* WriteImages filename ?adjoin? */
     {
-       char *filename;
-       int  adjoin=0;
-       Tcl_DString extrep;
-
-       if( ((enum subIndex)index == TM_WRITE_IMAGES) && ((objc < 3) || (objc > 4)) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "filename ?adjoin=no?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index != TM_WRITE_IMAGES) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "filename");
-           return TCL_ERROR;
-       }
-       filename = Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[2]), -1, &extrep);
-       if( (objc > 3) && ((stat = Tcl_GetBooleanFromObj(interp, objv[3], &adjoin)) != TCL_OK) ) {
-           return stat;
-       }
-       if( (enum subIndex) index == TM_WRITE_IMAGES ) {
-           result = MagickWriteImages(wandPtr, filename, adjoin);
-       } else {
-           result = MagickWriteImage(wandPtr, filename);
-       }
-       Tcl_DStringFree(&extrep);
-       if (!result) {
-           return myMagickError(interp, wandPtr);
-       }
-       break;
+        char *filename;
+        int  adjoin=0;
+        Tcl_DString extrep;
+
+        if( ((enum subIndex)index == TM_WRITE_IMAGES) && ((objc < 3) || (objc > 4)) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "filename ?adjoin=no?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index != TM_WRITE_IMAGES) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "filename");
+            return TCL_ERROR;
+        }
+        filename = Tcl_UtfToExternalDString(NULL, Tcl_GetString(objv[2]), -1, &extrep);
+        if( (objc > 3) && ((stat = Tcl_GetBooleanFromObj(interp, objv[3], &adjoin)) != TCL_OK) ) {
+            return stat;
+        }
+        if( (enum subIndex) index == TM_WRITE_IMAGES ) {
+            result = MagickWriteImages(wandPtr, filename, adjoin);
+        } else {
+            result = MagickWriteImage(wandPtr, filename);
+        }
+        Tcl_DStringFree(&extrep);
+        if (!result) {
+            return myMagickError(interp, wandPtr);
+        }
+        break;
     }
 
     case TM_WRITE_BLOB:         /* writeblob */
     case TM_WRITE_IMAGE_BLOB:   /* WriteImageBlob */
     {
-       unsigned char *data;
+        unsigned char *data;
         size_t  length;
 
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
         data = MagickWriteImageBlob(wandPtr, &length);
         if(data != NULL) {
             Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(data, length));
             MagickRelinquishMemory(data); /* Free TclMagick resource */
-       }
-       break;
+        }
+        break;
     }
 
     /*
@@ -5362,8 +5371,8 @@ static int wandObjCmd(
     case TM_END_OF_TABLE:
     default:
     {
-       Tcl_AppendResult(interp, "TclMagick wandObjCmd: Unmatched subcommand table entry", NULL);
-       return TCL_ERROR;
+        Tcl_AppendResult(interp, "TclMagick wandObjCmd: Unmatched subcommand table entry", NULL);
+        return TCL_ERROR;
     }
 
     } /* switch(index) */
@@ -5448,112 +5457,112 @@ static int pixelObjCmd(
 
     case TM_SET:    /* set ?-quant*um? color val color val ... */
     {
-       int     color;
-
-       if( objc < 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?-quant*? color value color value ...");
-           return TCL_ERROR;
-       }
-       if( strncmp(Tcl_GetString(objv[2]), "-quant", 6) == 0 ) {
-           quantFlag = 1;
-           objv += 3, objc -= 3;
-       } else {
-           quantFlag = 0;
-           objv += 2, objc -= 2;
-       }
-       while( objc > 0 ) {
-           if (Tcl_GetIndexFromObj(interp, objv[0], colors, "color", 0, &color) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           if( objc == 1 ) {
-               Tcl_AppendResult(interp, "Magick: Missing value for color ", objv[0], NULL);
-               return TCL_ERROR;
-           }
-           if( quantFlag ) {
-               if( (stat = Tcl_GetIntFromObj(interp, objv[1], &quantVal)) != TCL_OK ) {
-                   return stat;
-               }
-               switch(color) {
-               case 0:  PixelSetBlackQuantum(wandPtr,    (Quantum)quantVal); break;
-               case 1:  PixelSetBlueQuantum(wandPtr,     (Quantum)quantVal); break;
-               case 2:  PixelSetCyanQuantum(wandPtr,     (Quantum)quantVal); break;
-               case 3:  PixelSetGreenQuantum(wandPtr,    (Quantum)quantVal); break;
-               case 4:  PixelSetMagentaQuantum(wandPtr,  (Quantum)quantVal); break;
-               case 5:  PixelSetOpacityQuantum(wandPtr,  (Quantum)quantVal); break;
-               case 6:  PixelSetRedQuantum(wandPtr,      (Quantum)quantVal); break;
-               case 7:  PixelSetYellowQuantum(wandPtr,   (Quantum)quantVal); break;
-               }
-           } else {
-               if( (stat = Tcl_GetDoubleFromObj(interp, objv[1], &normVal)) != TCL_OK ) {
-                   return stat;
-               }
-               switch(color) {
-               case 0:  PixelSetBlack(wandPtr,    normVal); break;
-               case 1:  PixelSetBlue(wandPtr,     normVal); break;
-               case 2:  PixelSetCyan(wandPtr,     normVal); break;
-               case 3:  PixelSetGreen(wandPtr,    normVal); break;
-               case 4:  PixelSetMagenta(wandPtr,  normVal); break;
-               case 5:  PixelSetOpacity(wandPtr,  normVal); break;
-               case 6:  PixelSetRed(wandPtr,      normVal); break;
-               case 7:  PixelSetYellow(wandPtr,   normVal); break;
-               }
-           }
-           objv += 2, objc -= 2;
-       }
-       break;
+        int     color;
+
+        if( objc < 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?-quant*? color value color value ...");
+            return TCL_ERROR;
+        }
+        if( strncmp(Tcl_GetString(objv[2]), "-quant", 6) == 0 ) {
+            quantFlag = 1;
+            objv += 3, objc -= 3;
+        } else {
+            quantFlag = 0;
+            objv += 2, objc -= 2;
+        }
+        while( objc > 0 ) {
+            if (Tcl_GetIndexFromObj(interp, objv[0], colors, "color", 0, &color) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            if( objc == 1 ) {
+                Tcl_AppendResult(interp, "Magick: Missing value for color ", objv[0], NULL);
+                return TCL_ERROR;
+            }
+            if( quantFlag ) {
+                if( (stat = Tcl_GetIntFromObj(interp, objv[1], &quantVal)) != TCL_OK ) {
+                    return stat;
+                }
+                switch(color) {
+                case 0:  PixelSetBlackQuantum(wandPtr,    (Quantum)quantVal); break;
+                case 1:  PixelSetBlueQuantum(wandPtr,     (Quantum)quantVal); break;
+                case 2:  PixelSetCyanQuantum(wandPtr,     (Quantum)quantVal); break;
+                case 3:  PixelSetGreenQuantum(wandPtr,    (Quantum)quantVal); break;
+                case 4:  PixelSetMagentaQuantum(wandPtr,  (Quantum)quantVal); break;
+                case 5:  PixelSetOpacityQuantum(wandPtr,  (Quantum)quantVal); break;
+                case 6:  PixelSetRedQuantum(wandPtr,      (Quantum)quantVal); break;
+                case 7:  PixelSetYellowQuantum(wandPtr,   (Quantum)quantVal); break;
+                }
+            } else {
+                if( (stat = Tcl_GetDoubleFromObj(interp, objv[1], &normVal)) != TCL_OK ) {
+                    return stat;
+                }
+                switch(color) {
+                case 0:  PixelSetBlack(wandPtr,    normVal); break;
+                case 1:  PixelSetBlue(wandPtr,     normVal); break;
+                case 2:  PixelSetCyan(wandPtr,     normVal); break;
+                case 3:  PixelSetGreen(wandPtr,    normVal); break;
+                case 4:  PixelSetMagenta(wandPtr,  normVal); break;
+                case 5:  PixelSetOpacity(wandPtr,  normVal); break;
+                case 6:  PixelSetRed(wandPtr,      normVal); break;
+                case 7:  PixelSetYellow(wandPtr,   normVal); break;
+                }
+            }
+            objv += 2, objc -= 2;
+        }
+        break;
     }
 
     case TM_GET:    /* get -quantum color color ... */
     {
-       Tcl_Obj *listPtr;
-       int     color;
-
-       if( objc < 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?-quant*? color color ...");
-           return TCL_ERROR;
-       }
-       if( strncmp(Tcl_GetString(objv[2]), "-quant", 6) == 0 ) {
-           quantFlag = 1;
-           objv += 3, objc -= 3;
-       } else {
-           quantFlag = 0;
-           objv += 2, objc -= 2;
-       }
-       listPtr = Tcl_NewListObj(0, NULL);
-       while( objc > 0 ) {
-           if (Tcl_GetIndexFromObj(interp, objv[0], colors, "color", 0, &color) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           if( quantFlag ) {
-               switch(color) {
-               case 0:  quantVal = PixelGetBlackQuantum(wandPtr);    break;
-               case 1:  quantVal = PixelGetBlueQuantum(wandPtr);     break;
-               case 2:  quantVal = PixelGetCyanQuantum(wandPtr);     break;
-               case 3:  quantVal = PixelGetGreenQuantum(wandPtr);    break;
-               case 4:  quantVal = PixelGetMagentaQuantum(wandPtr);  break;
-               case 5:  quantVal = PixelGetOpacityQuantum(wandPtr);  break;
-               case 6:  quantVal = PixelGetRedQuantum(wandPtr);      break;
-               case 7:  quantVal = PixelGetYellowQuantum(wandPtr);   break;
-               }
-               Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewIntObj(quantVal));
-           } else {
-               switch(color) {
-               case 0:  normVal = PixelGetBlack(wandPtr);    break;
-               case 1:  normVal = PixelGetBlue(wandPtr);     break;
-               case 2:  normVal = PixelGetCyan(wandPtr);     break;
-               case 3:  normVal = PixelGetGreen(wandPtr);    break;
-               case 4:  normVal = PixelGetMagenta(wandPtr);  break;
-               case 5:  normVal = PixelGetOpacity(wandPtr);  break;
-               case 6:  normVal = PixelGetRed(wandPtr);      break;
-               case 7:  normVal = PixelGetYellow(wandPtr);   break;
-               }
-               Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(normVal));
-           }
-           objv += 1, objc -= 1;
-       }
-       Tcl_SetObjResult(interp, listPtr);
-
-       break;
+        Tcl_Obj *listPtr;
+        int     color;
+
+        if( objc < 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?-quant*? color color ...");
+            return TCL_ERROR;
+        }
+        if( strncmp(Tcl_GetString(objv[2]), "-quant", 6) == 0 ) {
+            quantFlag = 1;
+            objv += 3, objc -= 3;
+        } else {
+            quantFlag = 0;
+            objv += 2, objc -= 2;
+        }
+        listPtr = Tcl_NewListObj(0, NULL);
+        while( objc > 0 ) {
+            if (Tcl_GetIndexFromObj(interp, objv[0], colors, "color", 0, &color) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            if( quantFlag ) {
+                switch(color) {
+                case 0:  quantVal = PixelGetBlackQuantum(wandPtr);    break;
+                case 1:  quantVal = PixelGetBlueQuantum(wandPtr);     break;
+                case 2:  quantVal = PixelGetCyanQuantum(wandPtr);     break;
+                case 3:  quantVal = PixelGetGreenQuantum(wandPtr);    break;
+                case 4:  quantVal = PixelGetMagentaQuantum(wandPtr);  break;
+                case 5:  quantVal = PixelGetOpacityQuantum(wandPtr);  break;
+                case 6:  quantVal = PixelGetRedQuantum(wandPtr);      break;
+                case 7:  quantVal = PixelGetYellowQuantum(wandPtr);   break;
+                }
+                Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewIntObj(quantVal));
+            } else {
+                switch(color) {
+                case 0:  normVal = PixelGetBlack(wandPtr);    break;
+                case 1:  normVal = PixelGetBlue(wandPtr);     break;
+                case 2:  normVal = PixelGetCyan(wandPtr);     break;
+                case 3:  normVal = PixelGetGreen(wandPtr);    break;
+                case 4:  normVal = PixelGetMagenta(wandPtr);  break;
+                case 5:  normVal = PixelGetOpacity(wandPtr);  break;
+                case 6:  normVal = PixelGetRed(wandPtr);      break;
+                case 7:  normVal = PixelGetYellow(wandPtr);   break;
+                }
+                Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(normVal));
+            }
+            objv += 1, objc -= 1;
+        }
+        Tcl_SetObjResult(interp, listPtr);
+
+        break;
     }
 
     case TM_COLOR:                  /* color ?string? */
@@ -5561,387 +5570,387 @@ static int pixelObjCmd(
     case TM_GET_COLOR:              /* GetColor */
     case TM_GET_COLOR_AS_STRING:    /* GetColorAsString */
     {
-       char *color;
-
-       if( ((enum subIndex)index == TM_COLOR) && (objc != 2) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?string?");
-           return TCL_ERROR;
-       } else if ( ((enum subIndex)index == TM_SET_COLOR) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "string");
-           return TCL_ERROR;
-       } else if ( ((enum subIndex)index == TM_GET_COLOR) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if ( ((enum subIndex)index == TM_GET_COLOR_AS_STRING) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( objc == 3 ) {   /* Set color */
-           color = Tcl_GetString(objv[2]);
-           result = PixelSetColor(wandPtr, color);
-           if( !result ) {
-               Tcl_AppendResult(interp, "Magick: Invalid color ", color, NULL);
-               return TCL_ERROR;
-           }
-       } else {
-           color = PixelGetColorAsString(wandPtr);
-           Tcl_SetResult(interp, color, TCL_VOLATILE);
-           MagickRelinquishMemory(color); /* Free TclMagick resource */
-       }
-
-       break;
+        char *color;
+
+        if( ((enum subIndex)index == TM_COLOR) && (objc != 2) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?string?");
+            return TCL_ERROR;
+        } else if ( ((enum subIndex)index == TM_SET_COLOR) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "string");
+            return TCL_ERROR;
+        } else if ( ((enum subIndex)index == TM_GET_COLOR) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if ( ((enum subIndex)index == TM_GET_COLOR_AS_STRING) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( objc == 3 ) {   /* Set color */
+            color = Tcl_GetString(objv[2]);
+            result = PixelSetColor(wandPtr, color);
+            if( !result ) {
+                Tcl_AppendResult(interp, "Magick: Invalid color ", color, NULL);
+                return TCL_ERROR;
+            }
+        } else {
+            color = PixelGetColorAsString(wandPtr);
+            Tcl_SetResult(interp, color, TCL_VOLATILE);
+            MagickRelinquishMemory(color); /* Free TclMagick resource */
+        }
+
+        break;
     }
 
     case TM_SET_BLACK_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_SET_BLACK:
     {
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "value");
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetBlackQuantum(wandPtr, (Quantum)quantVal);
-       } else {
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetBlack(wandPtr, normVal);
-       }
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "value");
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetBlackQuantum(wandPtr, (Quantum)quantVal);
+        } else {
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetBlack(wandPtr, normVal);
+        }
+        break;
     }
 
     case TM_SET_BLUE_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_SET_BLUE:
     {
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "value");
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetBlueQuantum(wandPtr, (Quantum)quantVal);
-       } else {
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetBlue(wandPtr, normVal);
-       }
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "value");
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetBlueQuantum(wandPtr, (Quantum)quantVal);
+        } else {
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetBlue(wandPtr, normVal);
+        }
+        break;
     }
 
     case TM_SET_CYAN_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_SET_CYAN:
     {
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "value");
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetCyanQuantum(wandPtr, (Quantum)quantVal);
-       } else {
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetCyan(wandPtr, normVal);
-       }
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "value");
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetCyanQuantum(wandPtr, (Quantum)quantVal);
+        } else {
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetCyan(wandPtr, normVal);
+        }
+        break;
     }
 
     case TM_SET_GREEN_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_SET_GREEN:
     {
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "value");
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetGreenQuantum(wandPtr, (Quantum)quantVal);
-       } else {
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetGreen(wandPtr, normVal);
-       }
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "value");
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetGreenQuantum(wandPtr, (Quantum)quantVal);
+        } else {
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetGreen(wandPtr, normVal);
+        }
+        break;
     }
 
     case TM_SET_MAGENTA_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_SET_MAGENTA:
     {
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "value");
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetMagentaQuantum(wandPtr, (Quantum)quantVal);
-       } else {
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetMagenta(wandPtr, normVal);
-       }
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "value");
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetMagentaQuantum(wandPtr, (Quantum)quantVal);
+        } else {
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetMagenta(wandPtr, normVal);
+        }
+        break;
     }
 
     case TM_SET_OPACITY_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_SET_OPACITY:
     {
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "value");
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetOpacityQuantum(wandPtr, (Quantum)quantVal);
-       } else {
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetOpacity(wandPtr, normVal);
-       }
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "value");
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetOpacityQuantum(wandPtr, (Quantum)quantVal);
+        } else {
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetOpacity(wandPtr, normVal);
+        }
+        break;
     }
 
     case TM_SET_RED_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_SET_RED:
     {
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "value");
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetRedQuantum(wandPtr, (Quantum)quantVal);
-       } else {
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetRed(wandPtr, normVal);
-       }
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "value");
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetRedQuantum(wandPtr, (Quantum)quantVal);
+        } else {
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetRed(wandPtr, normVal);
+        }
+        break;
     }
 
     case TM_SET_YELLOW_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_SET_YELLOW:
     {
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "value");
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetYellowQuantum(wandPtr, (Quantum)quantVal);
-       } else {
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
-               return stat;
-           }
-           PixelSetYellow(wandPtr, normVal);
-       }
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "value");
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            if( (stat = Tcl_GetIntFromObj(interp, objv[2], &quantVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetYellowQuantum(wandPtr, (Quantum)quantVal);
+        } else {
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &normVal)) != TCL_OK ) {
+                return stat;
+            }
+            PixelSetYellow(wandPtr, normVal);
+        }
+        break;
     }
 
     case TM_GET_BLACK_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_GET_BLACK:
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           quantVal = PixelGetBlackQuantum(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
-       } else {
-           normVal = PixelGetBlack(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            quantVal = PixelGetBlackQuantum(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
+        } else {
+            normVal = PixelGetBlack(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
+        }
+        break;
     }
 
     case TM_GET_BLUE_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_GET_BLUE:
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           quantVal = PixelGetBlueQuantum(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
-       } else {
-           normVal = PixelGetBlue(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            quantVal = PixelGetBlueQuantum(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
+        } else {
+            normVal = PixelGetBlue(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
+        }
+        break;
     }
 
     case TM_GET_CYAN_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_GET_CYAN:
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           quantVal = PixelGetCyanQuantum(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
-       } else {
-           normVal = PixelGetCyan(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            quantVal = PixelGetCyanQuantum(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
+        } else {
+            normVal = PixelGetCyan(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
+        }
+        break;
     }
 
     case TM_GET_GREEN_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_GET_GREEN:
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           quantVal = PixelGetGreenQuantum(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
-       } else {
-           normVal = PixelGetGreen(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            quantVal = PixelGetGreenQuantum(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
+        } else {
+            normVal = PixelGetGreen(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
+        }
+        break;
     }
 
     case TM_GET_MAGENTA_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_GET_MAGENTA:
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           quantVal = PixelGetMagentaQuantum(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
-       } else {
-           normVal = PixelGetMagenta(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            quantVal = PixelGetMagentaQuantum(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
+        } else {
+            normVal = PixelGetMagenta(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
+        }
+        break;
     }
 
     case TM_GET_OPACITY_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_GET_OPACITY:
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           quantVal = PixelGetOpacityQuantum(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
-       } else {
-           normVal = PixelGetOpacity(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            quantVal = PixelGetOpacityQuantum(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
+        } else {
+            normVal = PixelGetOpacity(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
+        }
+        break;
     }
 
     case TM_GET_RED_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_GET_RED:
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           quantVal = PixelGetRedQuantum(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
-       } else {
-           normVal = PixelGetRed(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            quantVal = PixelGetRedQuantum(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
+        } else {
+            normVal = PixelGetRed(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
+        }
+        break;
     }
 
     case TM_GET_YELLOW_QUANTUM:
     {
-       quantFlag = 1; /* and continue ... */
+        quantFlag = 1; /* and continue ... */
     }
     case TM_GET_YELLOW:
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( quantFlag ) {
-           quantVal = PixelGetYellowQuantum(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
-       } else {
-           normVal = PixelGetYellow(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( quantFlag ) {
+            quantVal = PixelGetYellowQuantum(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewIntObj(quantVal));
+        } else {
+            normVal = PixelGetYellow(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(normVal));
+        }
+        break;
     }
 
     case TM_QUANTUM:                /* quantum ?{r g b o}? */
@@ -5950,51 +5959,51 @@ static int pixelObjCmd(
     {
         PixelPacket color;
 
-       if( ((enum subIndex)index == TM_QUANTUM) && (objc != 2) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?{r g b o}?");
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_GET_QUANTUM) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       if( ((enum subIndex)index == TM_SET_QUANTUM) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "{r g b o}");
-           return TCL_ERROR;
-       }
-       if( objc == 3 ) {
-           /*
-            * Set quantum values
-            */
+        if( ((enum subIndex)index == TM_QUANTUM) && (objc != 2) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?{r g b o}?");
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_GET_QUANTUM) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        if( ((enum subIndex)index == TM_SET_QUANTUM) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "{r g b o}");
+            return TCL_ERROR;
+        }
+        if( objc == 3 ) {
+            /*
+             * Set quantum values
+             */
             Tcl_Obj        **listPtr;
             unsigned long  quant[4];
             int            i, listLen;
 
-           if( (stat = Tcl_ListObjGetElements(interp, objv[2], &listLen, &listPtr)) != TCL_OK ) {
-               return stat;
-           }
+            if( (stat = Tcl_ListObjGetElements(interp, objv[2], &listLen, &listPtr)) != TCL_OK ) {
+                return stat;
+            }
             if( listLen != 4 ) {
-               Tcl_AppendResult(interp, "PixelWand SetQuantum: List of 4 colors {r g b o} required", NULL);
-               return TCL_ERROR;
-            }
-           for( i=0; i < 4; i++ ) {
-                   if( (stat = Tcl_GetLongFromObj(interp, listPtr[i], (long int *) &quant[i])) != TCL_OK) {
-                   return stat;
-               }
-           }
+                Tcl_AppendResult(interp, "PixelWand SetQuantum: List of 4 colors {r g b o} required", NULL);
+                return TCL_ERROR;
+            }
+            for( i=0; i < 4; i++ ) {
+                    if( (stat = Tcl_GetLongFromObj(interp, listPtr[i], (long int *) &quant[i])) != TCL_OK) {
+                    return stat;
+                }
+            }
             color.red     = (Quantum) quant[0];
             color.green   = (Quantum) quant[1];
             color.blue    = (Quantum) quant[2];
             color.opacity = (Quantum) quant[3];
 
-           PixelSetQuantumColor(wandPtr, &color);
-       } else {
-           /*
-            * Get quantum values
-            */
+            PixelSetQuantumColor(wandPtr, &color);
+        } else {
+            /*
+             * Get quantum values
+             */
             Tcl_Obj *listPtr = Tcl_NewListObj(0, NULL);;
 
-           PixelGetQuantumColor(wandPtr, &color);
+            PixelGetQuantumColor(wandPtr, &color);
 
             Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewLongObj(color.red));
             Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewLongObj(color.green));
@@ -6002,8 +6011,8 @@ static int pixelObjCmd(
             Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewLongObj(color.opacity));
 
             Tcl_SetObjResult(interp, listPtr);
-       }
-       break;
+        }
+        break;
     }
     /*
      * All subcommands should be matched
@@ -6012,8 +6021,8 @@ static int pixelObjCmd(
     case TM_END_OF_TABLE:
     default:
     {
-       Tcl_AppendResult(interp, "TclMagick pixelObjCmd: Unmatched subcommand table entry", NULL);
-       return TCL_ERROR;
+        Tcl_AppendResult(interp, "TclMagick pixelObjCmd: Unmatched subcommand table entry", NULL);
+        return TCL_ERROR;
     }
 
     } /* switch(index) */
@@ -6050,7 +6059,7 @@ static int drawObjCmd(
         "ellipse",          "Ellipse",
         "fillcolor",        "GetFillColor",     "SetFillColor",
         "fillopacity",      "GetFillOpacity",   "SetFillOpacity",
-        "fillpatternurl",                      "SetFillPatternURL",
+        "fillpatternurl",                       "SetFillPatternURL",
         "fillrule",         "GetFillRule",      "SetFillRule",
         "font",             "GetFont",          "SetFont",
         "fontfamily",       "GetFontFamily",    "SetFontFamily",
@@ -6085,7 +6094,7 @@ static int drawObjCmd(
         "strokelinejoin",   "GetStrokeLineJoin",    "SetStrokeLineJoin",
         "strokemiterlimit", "GetStrokeMiterLimit",  "SetStrokeMiterLimit",
         "strokeopacity",    "GetStrokeOpacity",     "SetStrokeOpacity",
-        "strokepatternurl",                        "SetStrokePatternURL",
+        "strokepatternurl",                         "SetStrokePatternURL",
         "strokewidth",      "GetStrokeWidth",       "SetStrokeWidth",
         "textantialias",    "GetTextAntialias",     "SetTextAntialias",
         "textdecoration",   "GetTextDecoration",    "SetTextDecoration",
@@ -6166,14 +6175,14 @@ static int drawObjCmd(
         (char *) NULL
     };
     static FillRule fillRules[] = {
-       UndefinedRule, EvenOddRule, NonZeroRule
+        UndefinedRule, EvenOddRule, NonZeroRule
     };
     static CONST char *paintMethodNames[] = {
         "point", "replace", "floodfill", "filltoborder", "reset",
-       (char *) NULL
+        (char *) NULL
     };
     static PaintMethod paintMethods[] = {
-       PointMethod, ReplaceMethod, FloodfillMethod, FillToBorderMethod, ResetMethod
+        PointMethod, ReplaceMethod, FloodfillMethod, FillToBorderMethod, ResetMethod
     };
     int         index, stat;
     TclMagickObj *magickPtr = (TclMagickObj *) clientData;
@@ -6202,84 +6211,84 @@ static int drawObjCmd(
     case TM_AFFINE:     /* affine sx rx ry sy tx ty */
     case TM_AAFFINE:    /* Affine sx rx ry sy tx ty */
     {
-       AffineMatrix A;
-
-       if( objc != 8 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "sx rx ry sy tx ty");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &A.sx)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &A.rx)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &A.ry)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &A.sy)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[6], &A.tx)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[7], &A.ty)) != TCL_OK ) {
-           return stat;
-       }
-       DrawAffine(wandPtr, &A);
-       break;
+        AffineMatrix A;
+
+        if( objc != 8 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "sx rx ry sy tx ty");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &A.sx)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &A.rx)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &A.ry)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &A.sy)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[6], &A.tx)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[7], &A.ty)) != TCL_OK ) {
+            return stat;
+        }
+        DrawAffine(wandPtr, &A);
+        break;
     }
 
     case TM_ANNOTATION:     /* annotation x y text */
     case TM_AANNOTATION:    /* Annotation x y text */
     {
-       double x, y;
-       unsigned char *text;
+        double x, y;
+        unsigned char *text;
 
-       if( objc != 5 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y text");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
-           return stat;
-       }
-       text = (unsigned char *) Tcl_GetString(objv[4]);
-       DrawAnnotation(wandPtr, x, y, text);
-       break;
+        if( objc != 5 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y text");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
+            return stat;
+        }
+        text = (unsigned char *) Tcl_GetString(objv[4]);
+        DrawAnnotation(wandPtr, x, y, text);
+        break;
     }
 
     case TM_ARC:    /* arc sx sy ex ey sd ed */
     case TM_AARC:   /* Arc sx sy ex ey sd ed */
     {
-       double sx, sy, ex, ey, sd, ed;
-
-       if( objc != 8 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "sx sy ex ey sd ed");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &sx)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &sy)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &ex)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &ey)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[6], &sd)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[7], &ed)) != TCL_OK ) {
-           return stat;
-       }
-       DrawArc(wandPtr, sx, sy, ex, ey, sd, ed);
-       break;
+        double sx, sy, ex, ey, sd, ed;
+
+        if( objc != 8 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "sx sy ex ey sd ed");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &sx)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &sy)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &ex)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &ey)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[6], &sd)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[7], &ed)) != TCL_OK ) {
+            return stat;
+        }
+        DrawArc(wandPtr, sx, sy, ex, ey, sd, ed);
+        break;
     }
 
     case TM_BEZIER:     /* bezier   x y x y ... */
@@ -6289,246 +6298,246 @@ static int drawObjCmd(
     case TM_POLYLINE:   /* polyline x y x y ... */
     case TM_PPOLYLINE:  /* Polyline x y x y ... */
     {
-       PointInfo *coordinates;
-       unsigned long i, num;
-
-       if( (objc-2) % 2 != 0 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y x y ...");
-           return TCL_ERROR;
-       }
-       num = (objc-2)/2;   /* number of coordinates */
-       coordinates = (PointInfo *)ckalloc(num*sizeof(coordinates[0]));
-       if( coordinates == NULL ) {
-           Tcl_AppendResult(interp, "TclMagick: out of memory", NULL);
-           return TCL_ERROR;
-       }
+        PointInfo *coordinates;
+        unsigned long i, num;
+
+        if( (objc-2) % 2 != 0 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y x y ...");
+            return TCL_ERROR;
+        }
+        num = (objc-2)/2;   /* number of coordinates */
+        coordinates = (PointInfo *)ckalloc(num*sizeof(coordinates[0]));
+        if( coordinates == NULL ) {
+            Tcl_AppendResult(interp, "TclMagick: out of memory", NULL);
+            return TCL_ERROR;
+        }
         memset( coordinates, 0, num*sizeof(coordinates[0]) );
 
-       objc -= 2, objv += 2;
-       for( i=0; i<num; i++) {
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[0], &coordinates[i].x)) != TCL_OK ) {
-               return stat;
-           }
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[1], &coordinates[i].y)) != TCL_OK ) {
-               return stat;
-           }
-           objc -= 2, objv +=2;
-       }
-       switch ((enum subIndex)index) {
-       case TM_BEZIER:   case TM_BBEZIER:
-           DrawBezier(wandPtr, num, coordinates);
+        objc -= 2, objv += 2;
+        for( i=0; i<num; i++) {
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[0], &coordinates[i].x)) != TCL_OK ) {
+                return stat;
+            }
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[1], &coordinates[i].y)) != TCL_OK ) {
+                return stat;
+            }
+            objc -= 2, objv +=2;
+        }
+        switch ((enum subIndex)index) {
+        case TM_BEZIER:   case TM_BBEZIER:
+            DrawBezier(wandPtr, num, coordinates);
             break;
-       case TM_POLYGON:  case TM_PPOLYGON:
-           DrawPolygon(wandPtr, num, coordinates);
+        case TM_POLYGON:  case TM_PPOLYGON:
+            DrawPolygon(wandPtr, num, coordinates);
             break;
-       case TM_POLYLINE: case TM_PPOLYLINE:
-           DrawPolyline(wandPtr, num, coordinates);
+        case TM_POLYLINE: case TM_PPOLYLINE:
+            DrawPolyline(wandPtr, num, coordinates);
             break;
-       default:
-           break;
-       }
+        default:
+            break;
+        }
 
-       ckfree((char *)coordinates);
-       break;
+        ckfree((char *)coordinates);
+        break;
     }
 
     case TM_CIRCLE:     /* circle ox oy px py */
     case TM_CCIRCLE:    /* Circle ox oy px py */
     {
-       double ox, oy, px, py;
-
-       if( objc != 6 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "ox oy px py");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &ox)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &oy)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &px)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &py)) != TCL_OK ) {
-           return stat;
-       }
-       DrawCircle(wandPtr, ox, oy, px, py);
-       break;
+        double ox, oy, px, py;
+
+        if( objc != 6 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "ox oy px py");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &ox)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &oy)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &px)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &py)) != TCL_OK ) {
+            return stat;
+        }
+        DrawCircle(wandPtr, ox, oy, px, py);
+        break;
     }
 
     case TM_COLOR:  /* color x y paintMethod */
     case TM_CCOLOR: /* Color x y paintMethod */
     {
-       double x, y;
-       int paintIdx;
-
-       if( objc != 5 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y paintMethod");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
-           return stat;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[4], paintMethodNames, "paintMethod", 0, &paintIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       DrawColor(wandPtr, x, y, paintMethods[paintIdx]);
-       break;
+        double x, y;
+        int paintIdx;
+
+        if( objc != 5 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y paintMethod");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
+            return stat;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[4], paintMethodNames, "paintMethod", 0, &paintIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        DrawColor(wandPtr, x, y, paintMethods[paintIdx]);
+        break;
     }
 
     case TM_COMMENT:    /* comment text */
     case TM_CCOMMENT:   /* Comment text */
     {
-       char *text;
+        char *text;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "text");
-           return TCL_ERROR;
-       }
-       text = Tcl_GetString(objv[2]);
-       DrawComment(wandPtr, text);
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "text");
+            return TCL_ERROR;
+        }
+        text = Tcl_GetString(objv[2]);
+        DrawComment(wandPtr, text);
+        break;
     }
 
     case TM_ELLIPSE:    /* ellipse ox oyo rx ry start end */
     case TM_EELLIPSE:   /* Ellipse ox oyo rx ry start end */
     {
-       double ox, oy, rx, ry, start, end;
-
-       if( objc != 8 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "ox oy rx ry start end");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &ox)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &oy)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &rx)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &ry)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[6], &start)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[7], &end)) != TCL_OK ) {
-           return stat;
-       }
-       DrawEllipse(wandPtr, ox, oy, rx, ry, start, end);
-       break;
+        double ox, oy, rx, ry, start, end;
+
+        if( objc != 8 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "ox oy rx ry start end");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &ox)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &oy)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &rx)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &ry)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[6], &start)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[7], &end)) != TCL_OK ) {
+            return stat;
+        }
+        DrawEllipse(wandPtr, ox, oy, rx, ry, start, end);
+        break;
     }
 
     case TM_CLIPPATH:        /* clippath ?name? */
     case TM_GET_CLIPPATH:    /* GetClipPath */
     case TM_SET_CLIPPATH:    /* SetClipPath name */
     {
-       char *name;
-
-       if( ((enum subIndex)index == TM_CLIPPATH) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?name?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_CLIPPATH) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_CLIPPATH) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "name");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set name */
-           name = Tcl_GetString(objv[2]);
-           DrawSetClipPath(wandPtr, name);
-       } else {    /* Get name */
-           name = (char *)DrawGetClipPath(wandPtr);
-           if(name != NULL) {
-               Tcl_SetResult(interp, name, TCL_VOLATILE);
-               MagickRelinquishMemory(name);
-           }
-       }
-       break;
+        char *name;
+
+        if( ((enum subIndex)index == TM_CLIPPATH) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?name?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_CLIPPATH) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_CLIPPATH) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "name");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set name */
+            name = Tcl_GetString(objv[2]);
+            DrawSetClipPath(wandPtr, name);
+        } else {    /* Get name */
+            name = (char *)DrawGetClipPath(wandPtr);
+            if(name != NULL) {
+                Tcl_SetResult(interp, name, TCL_VOLATILE);
+                MagickRelinquishMemory(name);
+            }
+        }
+        break;
     }
 
     case TM_CLIPRULE:        /* cliprule ?rule? */
     case TM_GET_CLIPRULE:    /* GetClipRule */
     case TM_SET_CLIPRULE:    /* SetClipRule rule */
     {
-       int      ruleIdx;
-       FillRule rule;
-
-       if( ((enum subIndex)index == TM_CLIPRULE) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?rule?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_CLIPRULE) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_CLIPRULE) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "rule");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set rule */
-           if (Tcl_GetIndexFromObj(interp, objv[2], fillRuleNames, "fillRule", 0, &ruleIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           DrawSetClipRule(wandPtr, fillRules[ruleIdx]);
-       } else {    /* Get rule */
-           rule = DrawGetClipRule(wandPtr);
-           for (ruleIdx = 0; (size_t) ruleIdx < sizeof(fillRules)/sizeof(fillRules[0]); ruleIdx++) {
-               if( fillRules[ruleIdx] == rule ) {
-                   Tcl_SetResult(interp, (char *)fillRuleNames[ruleIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)rule));
-       }
-       break;
+        int      ruleIdx;
+        FillRule rule;
+
+        if( ((enum subIndex)index == TM_CLIPRULE) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?rule?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_CLIPRULE) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_CLIPRULE) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "rule");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set rule */
+            if (Tcl_GetIndexFromObj(interp, objv[2], fillRuleNames, "fillRule", 0, &ruleIdx) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            DrawSetClipRule(wandPtr, fillRules[ruleIdx]);
+        } else {    /* Get rule */
+            rule = DrawGetClipRule(wandPtr);
+            for (ruleIdx = 0; (size_t) ruleIdx < sizeof(fillRules)/sizeof(fillRules[0]); ruleIdx++) {
+                if( fillRules[ruleIdx] == rule ) {
+                    Tcl_SetResult(interp, (char *)fillRuleNames[ruleIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)rule));
+        }
+        break;
     }
 
     case TM_CLIPUNITS:      /* clipunits ?unit? */
     case TM_GET_CLIPUNITS:  /* GetClipUnits */
     case TM_SET_CLIPUNITS:  /* SetClipunits unit */
     {
-       static CONST char *unitNames[] = {
-           "userspace", "userspaceonuse", "objectboundingbox",
-           (char *) NULL
-       };
-       static ClipPathUnits unitTypes[] = {
-           UserSpace, UserSpaceOnUse, ObjectBoundingBox
-       };
-       int           unitIdx;
-       ClipPathUnits unit;
-
-       if( ((enum subIndex)index == TM_CLIPUNITS) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?unit?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_CLIPUNITS) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_CLIPUNITS) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "unit");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set rule */
-           if (Tcl_GetIndexFromObj(interp, objv[2], unitNames, "unit", 0, &unitIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           DrawSetClipUnits(wandPtr, unitTypes[unitIdx]);
-       } else {    /* Get rule */
-           unit = DrawGetClipUnits(wandPtr);
-           for (unitIdx = 0; (size_t) unitIdx < sizeof(unitTypes)/sizeof(unitTypes[0]); unitIdx++) {
-               if( unitTypes[unitIdx] == unit ) {
-                   Tcl_SetResult(interp, (char *)unitNames[unitIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)unit));
-       }
-       break;
+        static CONST char *unitNames[] = {
+            "userspace", "userspaceonuse", "objectboundingbox",
+            (char *) NULL
+        };
+        static ClipPathUnits unitTypes[] = {
+            UserSpace, UserSpaceOnUse, ObjectBoundingBox
+        };
+        int           unitIdx;
+        ClipPathUnits unit;
+
+        if( ((enum subIndex)index == TM_CLIPUNITS) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?unit?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_CLIPUNITS) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_CLIPUNITS) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "unit");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set rule */
+            if (Tcl_GetIndexFromObj(interp, objv[2], unitNames, "unit", 0, &unitIdx) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            DrawSetClipUnits(wandPtr, unitTypes[unitIdx]);
+        } else {    /* Get rule */
+            unit = DrawGetClipUnits(wandPtr);
+            for (unitIdx = 0; (size_t) unitIdx < sizeof(unitTypes)/sizeof(unitTypes[0]); unitIdx++) {
+                if( unitTypes[unitIdx] == unit ) {
+                    Tcl_SetResult(interp, (char *)unitNames[unitIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)unit));
+        }
+        break;
     }
 
     case TM_FILLCOLOR:              /* fillcolor ?pixel? */
@@ -6542,9 +6551,9 @@ static int drawObjCmd(
             Tcl_WrongNumArgs(interp, 2, objv, "?pixelName?");
             return TCL_ERROR;
         }
-       if (objc > 2) { /* Set color / Get color with new name */
-           name = Tcl_GetString(objv[2]);
-           pixelPtr = findPixelWand(interp, name);
+        if (objc > 2) { /* Set color / Get color with new name */
+            name = Tcl_GetString(objv[2]);
+            pixelPtr = findPixelWand(interp, name);
         }
         /*
          * GET color if pixel object doesn't exists
@@ -6555,36 +6564,36 @@ static int drawObjCmd(
             name = newPixelObj(interp, pixelPtr, name );
 
             switch ((enum subIndex)index) {
-               case TM_FILLCOLOR:
-                       DrawGetFillColor(wandPtr, pixelPtr);
-                       break;
-               case TM_STROKE_COLOR:
-                       DrawGetStrokeColor(wandPtr, pixelPtr);
-                       break;
-               case TM_TEXT_UNDERCOLOR:
-                       DrawGetTextUnderColor(wandPtr, pixelPtr);
-                       break;
-               default:
-                       break;
+                case TM_FILLCOLOR:
+                        DrawGetFillColor(wandPtr, pixelPtr);
+                        break;
+                case TM_STROKE_COLOR:
+                        DrawGetStrokeColor(wandPtr, pixelPtr);
+                        break;
+                case TM_TEXT_UNDERCOLOR:
+                        DrawGetTextUnderColor(wandPtr, pixelPtr);
+                        break;
+                default:
+                        break;
             }
             Tcl_SetResult(interp, name, TCL_VOLATILE);
 
         } else {
             switch ((enum subIndex)index) {
-               case TM_FILLCOLOR:
-                       DrawSetFillColor(wandPtr, pixelPtr);
-                       break;
-               case TM_STROKE_COLOR:
-                       DrawSetStrokeColor(wandPtr, pixelPtr);
-                       break;
-               case TM_TEXT_UNDERCOLOR:
-                       DrawSetTextUnderColor(wandPtr, pixelPtr);
-                       break;
-               default:
-                       break;
+                case TM_FILLCOLOR:
+                        DrawSetFillColor(wandPtr, pixelPtr);
+                        break;
+                case TM_STROKE_COLOR:
+                        DrawSetStrokeColor(wandPtr, pixelPtr);
+                        break;
+                case TM_TEXT_UNDERCOLOR:
+                        DrawSetTextUnderColor(wandPtr, pixelPtr);
+                        break;
+                default:
+                        break;
             }
         }
-       break;
+        break;
     }
 
     case TM_GET_FILLCOLOR:          /* GetFillColor pixel */
@@ -6600,20 +6609,20 @@ static int drawObjCmd(
             }
             name = Tcl_GetString(objv[2]);
             if( (pixelPtr = findPixelWand(interp, name)) == NULL ) {
-               return TCL_ERROR;
-           }
+                return TCL_ERROR;
+            }
             switch ((enum subIndex)index) {
-           case TM_GET_FILLCOLOR:
-               DrawGetFillColor(wandPtr, pixelPtr);
-               break;
-           case TM_GET_STROKE_COLOR:
-               DrawGetStrokeColor(wandPtr, pixelPtr);
-               break;
-           case TM_GET_TEXT_UNDERCOLOR:
-               DrawGetTextUnderColor(wandPtr, pixelPtr);
-               break;
-           default:
-               break;
+            case TM_GET_FILLCOLOR:
+                DrawGetFillColor(wandPtr, pixelPtr);
+                break;
+            case TM_GET_STROKE_COLOR:
+                DrawGetStrokeColor(wandPtr, pixelPtr);
+                break;
+            case TM_GET_TEXT_UNDERCOLOR:
+                DrawGetTextUnderColor(wandPtr, pixelPtr);
+                break;
+            default:
+                break;
             }
             break;
         }
@@ -6631,20 +6640,20 @@ static int drawObjCmd(
             }
             name = Tcl_GetString(objv[2]);
             if( (pixelPtr = findPixelWand(interp, name)) == NULL ) {
-               return TCL_ERROR;
-           }
+                return TCL_ERROR;
+            }
             switch ((enum subIndex)index) {
-           case TM_SET_FILLCOLOR:
-               DrawSetFillColor(wandPtr, pixelPtr);
-               break;
-           case TM_SET_STROKE_COLOR:
-               DrawSetStrokeColor(wandPtr, pixelPtr);
-               break;
-           case TM_SET_TEXT_UNDERCOLOR:
-               DrawSetTextUnderColor(wandPtr, pixelPtr);
-               break;
-           default:
-               break;
+            case TM_SET_FILLCOLOR:
+                DrawSetFillColor(wandPtr, pixelPtr);
+                break;
+            case TM_SET_STROKE_COLOR:
+                DrawSetStrokeColor(wandPtr, pixelPtr);
+                break;
+            case TM_SET_TEXT_UNDERCOLOR:
+                DrawSetTextUnderColor(wandPtr, pixelPtr);
+                break;
+            default:
+                break;
             }
             break;
         }
@@ -6653,959 +6662,959 @@ static int drawObjCmd(
     case TM_GET_FILLOPACITY: /* GetFillOpacity  */
     case TM_SET_FILLOPACITY: /* SetFillOpacity value */
     {
-       double value;
-
-       if( ((enum subIndex)index == TM_FILLOPACITY) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?value?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_FILLOPACITY) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_FILLOPACITY) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "value");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set fill opacity */
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &value)) != TCL_OK ) {
-               return stat;
-           }
-           DrawSetFillOpacity(wandPtr, value);
-       } else {    /* Get fill opacity */
-           value = DrawGetFillOpacity(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(value));
-       }
-       break;
+        double value;
+
+        if( ((enum subIndex)index == TM_FILLOPACITY) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?value?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_FILLOPACITY) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_FILLOPACITY) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "value");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set fill opacity */
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &value)) != TCL_OK ) {
+                return stat;
+            }
+            DrawSetFillOpacity(wandPtr, value);
+        } else {    /* Get fill opacity */
+            value = DrawGetFillOpacity(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(value));
+        }
+        break;
     }
 
     case TM_FILLPATTERNURL:      /* fillpatternurl url */
     case TM_SET_FILLPATTERNURL:  /* SetFillPatternURL url */
     {
-       char *url;
+        char *url;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "url");
-           return TCL_ERROR;
-       }
-       url = Tcl_GetString(objv[2]);
-       DrawSetFillPatternURL(wandPtr, url);
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "url");
+            return TCL_ERROR;
+        }
+        url = Tcl_GetString(objv[2]);
+        DrawSetFillPatternURL(wandPtr, url);
+        break;
     }
 
     case TM_FILLRULE:        /* fillrule ?rule? */
     case TM_GET_FILLRULE:    /* GetFillRule */
     case TM_SET_FILLRULE:    /* SetFillRule rule */
     {
-       int      ruleIdx;
-       FillRule rule;
-
-       if( ((enum subIndex)index == TM_FILLRULE) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?rule?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_FILLRULE) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_FILLRULE) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "rule");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set rule */
-           if (Tcl_GetIndexFromObj(interp, objv[2], fillRuleNames, "fillRule", 0, &ruleIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           DrawSetFillRule(wandPtr, fillRules[ruleIdx]);
-       } else {    /* Get rule */
-           rule = DrawGetFillRule(wandPtr);
-           for (ruleIdx = 0; (size_t) ruleIdx < sizeof(fillRules)/sizeof(fillRules[0]); ruleIdx++) {
-               if( fillRules[ruleIdx] == rule ) {
-                   Tcl_SetResult(interp, (char *)fillRuleNames[ruleIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)rule));
-       }
-       break;
+        int      ruleIdx;
+        FillRule rule;
+
+        if( ((enum subIndex)index == TM_FILLRULE) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?rule?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_FILLRULE) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_FILLRULE) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "rule");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set rule */
+            if (Tcl_GetIndexFromObj(interp, objv[2], fillRuleNames, "fillRule", 0, &ruleIdx) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            DrawSetFillRule(wandPtr, fillRules[ruleIdx]);
+        } else {    /* Get rule */
+            rule = DrawGetFillRule(wandPtr);
+            for (ruleIdx = 0; (size_t) ruleIdx < sizeof(fillRules)/sizeof(fillRules[0]); ruleIdx++) {
+                if( fillRules[ruleIdx] == rule ) {
+                    Tcl_SetResult(interp, (char *)fillRuleNames[ruleIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)rule));
+        }
+        break;
     }
 
     case TM_FONT:        /* font ?fontname? */
     case TM_GET_FONT:    /* GetFont */
     case TM_SET_FONT:    /* SetFont fontname */
     {
-       char *fontname;
-
-       if( ((enum subIndex)index == TM_FONT) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?fontname?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_FONT) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_FONT) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "fontname");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set font */
-           fontname = Tcl_GetString(objv[2]);
-           DrawSetFont(wandPtr, fontname);
-       } else {    /* Get font */
-           fontname = DrawGetFont(wandPtr);
-           if(fontname != NULL) {
-               Tcl_SetResult(interp, fontname, TCL_VOLATILE);
-               MagickRelinquishMemory(fontname); /* Free TclMagick resource */
-           }
-       }
-       break;
+        char *fontname;
+
+        if( ((enum subIndex)index == TM_FONT) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?fontname?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_FONT) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_FONT) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "fontname");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set font */
+            fontname = Tcl_GetString(objv[2]);
+            DrawSetFont(wandPtr, fontname);
+        } else {    /* Get font */
+            fontname = DrawGetFont(wandPtr);
+            if(fontname != NULL) {
+                Tcl_SetResult(interp, fontname, TCL_VOLATILE);
+                MagickRelinquishMemory(fontname); /* Free TclMagick resource */
+            }
+        }
+        break;
     }
 
     case TM_FONTFAMILY:        /* fontfamily ?name? */
     case TM_GET_FONTFAMILY:    /* GetFontFamily */
     case TM_SET_FONTFAMILY:    /* SetFontFamily name */
     {
-       char *name;
-
-       if( ((enum subIndex)index == TM_FONTFAMILY) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?name?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_FONTFAMILY) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_FONTFAMILY) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "name");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set font family */
-           name = Tcl_GetString(objv[2]);
-           DrawSetFontFamily(wandPtr, name);
-       } else {    /* Get font family */
-           name = DrawGetFontFamily(wandPtr);
-           if(name != NULL) {
-               Tcl_SetResult(interp, name, TCL_VOLATILE);
-               MagickRelinquishMemory(name); /* Free TclMagick resource */
-           }
-       }
-       break;
+        char *name;
+
+        if( ((enum subIndex)index == TM_FONTFAMILY) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?name?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_FONTFAMILY) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_FONTFAMILY) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "name");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set font family */
+            name = Tcl_GetString(objv[2]);
+            DrawSetFontFamily(wandPtr, name);
+        } else {    /* Get font family */
+            name = DrawGetFontFamily(wandPtr);
+            if(name != NULL) {
+                Tcl_SetResult(interp, name, TCL_VOLATILE);
+                MagickRelinquishMemory(name); /* Free TclMagick resource */
+            }
+        }
+        break;
     }
 
     case TM_FONTSIZE:        /* fontsize ?value? */
     case TM_GET_FONTSIZE:    /* GetFontSize */
     case TM_SET_FONTSIZE:    /* SetFontSize value */
     {
-       double value;
-
-       if( ((enum subIndex)index == TM_FONTSIZE) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?value?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_FONTSIZE) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_FONTSIZE) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "value");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set font size */
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &value)) != TCL_OK ) {
-               return stat;
-           }
-           DrawSetFontSize(wandPtr, value);
-       } else {    /* Get font size */
-           value = DrawGetFontSize(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(value));
-       }
-       break;
+        double value;
+
+        if( ((enum subIndex)index == TM_FONTSIZE) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?value?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_FONTSIZE) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_FONTSIZE) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "value");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set font size */
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &value)) != TCL_OK ) {
+                return stat;
+            }
+            DrawSetFontSize(wandPtr, value);
+        } else {    /* Get font size */
+            value = DrawGetFontSize(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(value));
+        }
+        break;
     }
 
     case TM_FONTSTRETCH:     /* fontstretch ?stretchType? */
     case TM_GET_FONTSTRETCH: /* GetFontStretch */
     case TM_SET_FONTSTRETCH: /* SetFontStretch stretchType */
     {
-       static CONST char *stretchNames[] = {
-           "normal",        "ultracondensed", "extracondensed", "condensed",
-           "semicondensed", "semiexpanded",   "expanded",       "extraexpanded",
-           "ultraexpanded", "any",
-           (char *) NULL
-       };
-       static StretchType stretchTypes[] = {
-           NormalStretch,        UltraCondensedStretch, ExtraCondensedStretch, CondensedStretch,
-           SemiCondensedStretch, SemiExpandedStretch,   ExpandedStretch,       ExtraExpandedStretch,
-           UltraExpandedStretch, AnyStretch
-
-       };
-       int stretchIdx;
-       StretchType stretch;
-
-       if( ((enum subIndex)index == TM_FONTSTRETCH) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?stretchType?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_FONTSTRETCH) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_FONTSTRETCH) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "stretchType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set font stretch */
-           if (Tcl_GetIndexFromObj(interp, objv[2], stretchNames, "stretchType", 0, &stretchIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           DrawSetFontStretch(wandPtr, stretchTypes[stretchIdx]);
-       } else {    /* Get font stretch */
-           stretch = DrawGetFontStretch(wandPtr);
-           for (stretchIdx = 0; (size_t) stretchIdx < sizeof(stretchTypes)/sizeof(stretchTypes[0]); stretchIdx++) {
-               if( stretchTypes[stretchIdx] == stretch ) {
-                   Tcl_SetResult(interp, (char *)stretchNames[stretchIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)stretch));
-       }
-       break;
+        static CONST char *stretchNames[] = {
+            "normal",        "ultracondensed", "extracondensed", "condensed",
+            "semicondensed", "semiexpanded",   "expanded",       "extraexpanded",
+            "ultraexpanded", "any",
+            (char *) NULL
+        };
+        static StretchType stretchTypes[] = {
+            NormalStretch,        UltraCondensedStretch, ExtraCondensedStretch, CondensedStretch,
+            SemiCondensedStretch, SemiExpandedStretch,   ExpandedStretch,       ExtraExpandedStretch,
+            UltraExpandedStretch, AnyStretch
+
+        };
+        int stretchIdx;
+        StretchType stretch;
+
+        if( ((enum subIndex)index == TM_FONTSTRETCH) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?stretchType?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_FONTSTRETCH) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_FONTSTRETCH) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "stretchType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set font stretch */
+            if (Tcl_GetIndexFromObj(interp, objv[2], stretchNames, "stretchType", 0, &stretchIdx) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            DrawSetFontStretch(wandPtr, stretchTypes[stretchIdx]);
+        } else {    /* Get font stretch */
+            stretch = DrawGetFontStretch(wandPtr);
+            for (stretchIdx = 0; (size_t) stretchIdx < sizeof(stretchTypes)/sizeof(stretchTypes[0]); stretchIdx++) {
+                if( stretchTypes[stretchIdx] == stretch ) {
+                    Tcl_SetResult(interp, (char *)stretchNames[stretchIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)stretch));
+        }
+        break;
     }
 
     case TM_FONTSTYLE:     /* fontstyle ?style? */
     case TM_GET_FONTSTYLE: /* GetFontStyle */
     case TM_SET_FONTSTYLE: /* SetFontStyle style */
     {
-       static CONST char *styleNames[] = {
-           "normal", "italic", "oblique", "any",
-           (char *) NULL
-       };
-       static StyleType styleTypes[] = {
-           NormalStyle, ItalicStyle, ObliqueStyle, AnyStyle
-       };
-       int styleIdx;
-       StyleType style;
-
-       if( ((enum subIndex)index == TM_FONTSTYLE) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?styleType?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_FONTSTYLE) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_FONTSTYLE) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "styleType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set font style */
-           if (Tcl_GetIndexFromObj(interp, objv[2], styleNames, "styleType", 0, &styleIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           DrawSetFontStyle(wandPtr, styleTypes[styleIdx]);
-       } else {    /* Get font style */
-           style = DrawGetFontStyle(wandPtr);
-           for (styleIdx = 0; (size_t) styleIdx < sizeof(styleTypes)/sizeof(styleTypes[0]); styleIdx++) {
-               if( styleTypes[styleIdx] == style ) {
-                   Tcl_SetResult(interp, (char *)styleNames[styleIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)style));
-       }
-       break;
+        static CONST char *styleNames[] = {
+            "normal", "italic", "oblique", "any",
+            (char *) NULL
+        };
+        static StyleType styleTypes[] = {
+            NormalStyle, ItalicStyle, ObliqueStyle, AnyStyle
+        };
+        int styleIdx;
+        StyleType style;
+
+        if( ((enum subIndex)index == TM_FONTSTYLE) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?styleType?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_FONTSTYLE) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_FONTSTYLE) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "styleType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set font style */
+            if (Tcl_GetIndexFromObj(interp, objv[2], styleNames, "styleType", 0, &styleIdx) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            DrawSetFontStyle(wandPtr, styleTypes[styleIdx]);
+        } else {    /* Get font style */
+            style = DrawGetFontStyle(wandPtr);
+            for (styleIdx = 0; (size_t) styleIdx < sizeof(styleTypes)/sizeof(styleTypes[0]); styleIdx++) {
+                if( styleTypes[styleIdx] == style ) {
+                    Tcl_SetResult(interp, (char *)styleNames[styleIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)style));
+        }
+        break;
     }
 
     case TM_FONTWEIGHT:     /* fontweight ?value? */
     case TM_GET_FONTWEIGHT: /* GetFontWeight */
     case TM_SET_FONTWEIGHT: /* SetFontWeight value */
     {
-       unsigned value;
-
-       if( ((enum subIndex)index == TM_FONTSTYLE) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?value?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_FONTSTYLE) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_FONTSTYLE) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "value");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set font weight */
-               if( (stat = Tcl_GetIntFromObj(interp, objv[2], (int *) &value)) != TCL_OK ) {
-               return stat;
-           }
-           DrawSetFontWeight(wandPtr, value);
-       } else {    /* Get font weight */
-           value = DrawGetFontWeight(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)value));
-       }
-       break;
+        unsigned value;
+
+        if( ((enum subIndex)index == TM_FONTSTYLE) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?value?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_FONTSTYLE) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_FONTSTYLE) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "value");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set font weight */
+                if( (stat = Tcl_GetIntFromObj(interp, objv[2], (int *) &value)) != TCL_OK ) {
+                return stat;
+            }
+            DrawSetFontWeight(wandPtr, value);
+        } else {    /* Get font weight */
+            value = DrawGetFontWeight(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)value));
+        }
+        break;
     }
 
     case TM_GRAVITY:     /* gravity ?gravityType? */
     case TM_GET_GRAVITY: /* gravity */
     case TM_SET_GRAVITY: /* gravity gravityType */
     {
-       static CONST char *gravNames[] = {
-           "forget", "northwest", "north",    "northeast", "west",
-           "center", "east",      "southwest","south",     "southeast",
-           "static",
-           (char *) NULL
-       };
-       static GravityType gravTypes[] = {
-           ForgetGravity, NorthWestGravity, NorthGravity,     NorthEastGravity, WestGravity,
-           CenterGravity, EastGravity,      SouthWestGravity, SouthGravity,     SouthEastGravity,
-           StaticGravity
-       };
-       int gravIdx;
-       GravityType grav;
-
-       if( ((enum subIndex)index == TM_GRAVITY) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?gravityType?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_GRAVITY) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_GRAVITY) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "gravityType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set gravity */
-           if (Tcl_GetIndexFromObj(interp, objv[2], gravNames, "gravityType", 0, &gravIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           DrawSetGravity(wandPtr, gravTypes[gravIdx]);
-       } else {    /* Get gravity */
-           grav = DrawGetGravity(wandPtr);
-           for (gravIdx = 0; (size_t) gravIdx < sizeof(gravTypes)/sizeof(gravTypes[0]); gravIdx++) {
-               if( gravTypes[gravIdx] == grav ) {
-                   Tcl_SetResult(interp, (char *)gravNames[gravIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)grav));
-       }
-       break;
+        static CONST char *gravNames[] = {
+            "forget", "northwest", "north",    "northeast", "west",
+            "center", "east",      "southwest","south",     "southeast",
+            "static",
+            (char *) NULL
+        };
+        static GravityType gravTypes[] = {
+            ForgetGravity, NorthWestGravity, NorthGravity,     NorthEastGravity, WestGravity,
+            CenterGravity, EastGravity,      SouthWestGravity, SouthGravity,     SouthEastGravity,
+            StaticGravity
+        };
+        int gravIdx;
+        GravityType grav;
+
+        if( ((enum subIndex)index == TM_GRAVITY) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?gravityType?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_GRAVITY) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_GRAVITY) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "gravityType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set gravity */
+            if (Tcl_GetIndexFromObj(interp, objv[2], gravNames, "gravityType", 0, &gravIdx) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            DrawSetGravity(wandPtr, gravTypes[gravIdx]);
+        } else {    /* Get gravity */
+            grav = DrawGetGravity(wandPtr);
+            for (gravIdx = 0; (size_t) gravIdx < sizeof(gravTypes)/sizeof(gravTypes[0]); gravIdx++) {
+                if( gravTypes[gravIdx] == grav ) {
+                    Tcl_SetResult(interp, (char *)gravNames[gravIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)grav));
+        }
+        break;
     }
 
     case TM_LINE:       /* line sx sy ex ey */
     case TM_LLINE:      /* Line sx sy ex ey */
     {
-       double sx, sy, ex, ey;
-
-       if( objc != 6 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "sx sy ex ey");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &sx)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &sy)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &ex)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &ey)) != TCL_OK ) {
-           return stat;
-       }
-       DrawLine(wandPtr, sx, sy, ex, ey);
-       break;
+        double sx, sy, ex, ey;
+
+        if( objc != 6 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "sx sy ex ey");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &sx)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &sy)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &ex)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &ey)) != TCL_OK ) {
+            return stat;
+        }
+        DrawLine(wandPtr, sx, sy, ex, ey);
+        break;
     }
 
     case TM_MATTE:  /* matte x y paintMethod */
     case TM_MMATTE: /* Matte x y paintMethod */
     {
-       double x, y;
-       int paintIdx=0;
-
-       if( objc != 5 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y paintMethod");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
-           return stat;
-       }
-       if (Tcl_GetIndexFromObj(interp, objv[4], paintMethodNames, "paintMethod", 0, &paintIdx) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       DrawMatte(wandPtr, x, y, paintMethods[paintIdx]);
-       break;
+        double x, y;
+        int paintIdx=0;
+
+        if( objc != 5 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y paintMethod");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
+            return stat;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[4], paintMethodNames, "paintMethod", 0, &paintIdx) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        DrawMatte(wandPtr, x, y, paintMethods[paintIdx]);
+        break;
     }
 
     case TM_POINT:  /* point x y */
     case TM_PPOINT: /* Point x y */
     {
-       double x, y;
+        double x, y;
 
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
-           return stat;
-       }
-       DrawPoint(wandPtr, x, y);
-       break;
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
+            return stat;
+        }
+        DrawPoint(wandPtr, x, y);
+        break;
     }
 
     case TM_RECTANGLE:  /* rectangle x1 y1 x2 y2 */
     case TM_RRECTANGLE: /* Rectangle x1 y1 x2 y2 */
     {
-       double x1, y1, x2, y2;
-
-       if( objc != 6 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x1 y1 x2 y2");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x1)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y1)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &x2)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &y2)) != TCL_OK ) {
-           return stat;
-       }
-       DrawRectangle(wandPtr, x1, y1, x2, y2);
-       break;
+        double x1, y1, x2, y2;
+
+        if( objc != 6 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x1 y1 x2 y2");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x1)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y1)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &x2)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &y2)) != TCL_OK ) {
+            return stat;
+        }
+        DrawRectangle(wandPtr, x1, y1, x2, y2);
+        break;
     }
 
     case TM_RENDER:  /* render */
     case TM_RRENDER: /* Render */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       /*
-         FIXME: DrawRender() is deprecated.  Use MagickDrawImage() instead.
-         Note that TM_DRAW or TM_DRAW_IMAGE already draw on the image. so "render" is not needed.
-       */
-       DrawRender(wandPtr);
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        /*
+          FIXME: DrawRender() is deprecated.  Use MagickDrawImage() instead.
+          Note that TM_DRAW or TM_DRAW_IMAGE already draw on the image. so "render" is not needed.
+        */
+        DrawRender(wandPtr);
+        break;
     }
 
     case TM_ROTATE:     /* rotate degrees */
     case TM_RROTATE:    /* Rotate degrees */
     {
-       double degrees;
+        double degrees;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "degrees");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &degrees)) != TCL_OK ) {
-           return stat;
-       }
-       DrawRotate(wandPtr, degrees);
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "degrees");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &degrees)) != TCL_OK ) {
+            return stat;
+        }
+        DrawRotate(wandPtr, degrees);
+        break;
     }
 
     case TM_ROUND:          /* round x1 y1 x2 y2 rx ry */
     case TM_ROUND_RECTANGLE:/* RoundRectangle x1 y1 x2 y2 rx ry */
     {
-       double x1, y1, x2, y2, rx, ry;
-
-       if( objc != 8 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x1 y1 x2 y2 rx ry");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x1)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y1)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &x2)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &y2)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[6], &rx)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[7], &ry)) != TCL_OK ) {
-           return stat;
-       }
-       DrawRoundRectangle(wandPtr, x1, y1, x2, y2, rx, ry);
-       break;
+        double x1, y1, x2, y2, rx, ry;
+
+        if( objc != 8 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x1 y1 x2 y2 rx ry");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x1)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y1)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &x2)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &y2)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[6], &rx)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[7], &ry)) != TCL_OK ) {
+            return stat;
+        }
+        DrawRoundRectangle(wandPtr, x1, y1, x2, y2, rx, ry);
+        break;
     }
 
     case TM_SCALE:  /* scale x y */
     case TM_SSCALE: /* Scale x y */
     {
-       double x, y;
+        double x, y;
 
-       if( (objc < 3) || (objc > 4) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x ?y?");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
-           return stat;
-       }
-       y = x; /* default */
-       if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK) ) {
-           return stat;
-       }
-       DrawScale(wandPtr, x, y);
-       break;
+        if( (objc < 3) || (objc > 4) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x ?y?");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
+            return stat;
+        }
+        y = x; /* default */
+        if( (objc > 3) && ((stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK) ) {
+            return stat;
+        }
+        DrawScale(wandPtr, x, y);
+        break;
     }
 
     case TM_SKEWX:     /* skewx degrees */
     case TM_SKEW_X:    /* SkewX degrees */
     {
-       double degrees;
+        double degrees;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "degrees");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &degrees)) != TCL_OK ) {
-           return stat;
-       }
-       DrawSkewX(wandPtr, degrees);
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "degrees");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &degrees)) != TCL_OK ) {
+            return stat;
+        }
+        DrawSkewX(wandPtr, degrees);
+        break;
     }
 
     case TM_SKEWY:     /* skewy degrees */
     case TM_SKEW_Y:    /* SkewY degrees */
     {
-       double degrees;
+        double degrees;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "degrees");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &degrees)) != TCL_OK ) {
-           return stat;
-       }
-       DrawSkewY(wandPtr, degrees);
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "degrees");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &degrees)) != TCL_OK ) {
+            return stat;
+        }
+        DrawSkewY(wandPtr, degrees);
+        break;
     }
 
     case TM_STROKE_ANTIALIAS:     /* strokeantialias ?flag? */
     case TM_GET_STROKE_ANTIALIAS: /* GetStrokeAntialias */
     case TM_SET_STROKE_ANTIALIAS: /* SetStrokeAntialias flag */
     {
-       int flag;
-
-       if( ((enum subIndex)index == TM_STROKE_ANTIALIAS) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?flag?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_STROKE_ANTIALIAS) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_STROKE_ANTIALIAS) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "flag");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set antialias flag */
-           if( (stat = Tcl_GetIntFromObj(interp, objv[2], &flag)) != TCL_OK ) {
-               return stat;
-           }
-           DrawSetStrokeAntialias(wandPtr, flag);
-       } else {    /* Get antialias flag */
-           flag = DrawGetStrokeAntialias(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)flag));
-       }
-       break;
+        int flag;
+
+        if( ((enum subIndex)index == TM_STROKE_ANTIALIAS) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?flag?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_STROKE_ANTIALIAS) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_STROKE_ANTIALIAS) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "flag");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set antialias flag */
+            if( (stat = Tcl_GetIntFromObj(interp, objv[2], &flag)) != TCL_OK ) {
+                return stat;
+            }
+            DrawSetStrokeAntialias(wandPtr, flag);
+        } else {    /* Get antialias flag */
+            flag = DrawGetStrokeAntialias(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)flag));
+        }
+        break;
     }
 
     case TM_STROKE_DASHARRAY:     /* strokedasharray {} | val val ... */
     case TM_GET_STROKE_DASHARRAY: /* GetStrokeDashArray */
     case TM_SET_STROKE_DASHARRAY: /* SetStrokeDashArray {} | val val ... */
     {
-       unsigned long i, num;
-       double *arr;
-
-       if( ((enum subIndex)index == TM_GET_STROKE_DASHARRAY) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_STROKE_DASHARRAY) && (objc < 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "{} | val val ...");
-           return TCL_ERROR;
-       }
-       if (objc == 2) { /* Get dash array */
-           Tcl_Obj *listPtr = Tcl_NewListObj(0, NULL);
-
-           arr = DrawGetStrokeDashArray(wandPtr, &num);
-           while ( num > 0 ) {
-               Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(*arr));
-               ++arr;
-           }
-           Tcl_SetObjResult(interp, listPtr);
-       } else {    /* Set dash array */
-           char *str = Tcl_GetString(objv[2]);
-
-           if( strlen(str) == 0 ) { /* SetStrokeDashArray {} : Remove existing dash array */
-               DrawSetStrokeDashArray(wandPtr, 0, NULL);
-           } else {
-               num = objc-2;
-               arr = (double *)ckalloc(num * sizeof(*arr));
-               if( arr == NULL ) {
-                   Tcl_AppendResult(interp, "TclMagick: out of memory", NULL);
-                   return TCL_ERROR;
-               }
-               for( i=0; i<num; i++ ) {
-                   if( (stat = Tcl_GetDoubleFromObj(interp, objv[i+2], &arr[i])) != TCL_OK ) {
-                       return stat;
-                   }
-               }
-               DrawSetStrokeDashArray(wandPtr, num, arr);
-               ckfree((char *)arr);
-           }
-       }
-       break;
+        unsigned long i, num;
+        double *arr;
+
+        if( ((enum subIndex)index == TM_GET_STROKE_DASHARRAY) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_STROKE_DASHARRAY) && (objc < 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "{} | val val ...");
+            return TCL_ERROR;
+        }
+        if (objc == 2) { /* Get dash array */
+            Tcl_Obj *listPtr = Tcl_NewListObj(0, NULL);
+
+            arr = DrawGetStrokeDashArray(wandPtr, &num);
+            while ( num > 0 ) {
+                Tcl_ListObjAppendElement(interp, listPtr, Tcl_NewDoubleObj(*arr));
+                ++arr;
+            }
+            Tcl_SetObjResult(interp, listPtr);
+        } else {    /* Set dash array */
+            char *str = Tcl_GetString(objv[2]);
+
+            if( strlen(str) == 0 ) { /* SetStrokeDashArray {} : Remove existing dash array */
+                DrawSetStrokeDashArray(wandPtr, 0, NULL);
+            } else {
+                num = objc-2;
+                arr = (double *)ckalloc(num * sizeof(*arr));
+                if( arr == NULL ) {
+                    Tcl_AppendResult(interp, "TclMagick: out of memory", NULL);
+                    return TCL_ERROR;
+                }
+                for( i=0; i<num; i++ ) {
+                    if( (stat = Tcl_GetDoubleFromObj(interp, objv[i+2], &arr[i])) != TCL_OK ) {
+                        return stat;
+                    }
+                }
+                DrawSetStrokeDashArray(wandPtr, num, arr);
+                ckfree((char *)arr);
+            }
+        }
+        break;
     }
 
     case TM_STROKE_DASHOFFS:     /* strokedashoffset ?val? */
     case TM_GET_STROKE_DASHOFFS: /* strokedashoffset */
     case TM_SET_STROKE_DASHOFFS: /* strokedashoffset val */
     {
-       double val;
-
-       if( ((enum subIndex)index == TM_STROKE_DASHOFFS) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?val?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_STROKE_DASHOFFS) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_STROKE_DASHOFFS) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "val");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set stroke dash offset */
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &val)) != TCL_OK ) {
-               return stat;
-           }
-           DrawSetStrokeDashOffset(wandPtr, val);
-       } else {    /* Get stroke dash offset */
-           val = DrawGetStrokeDashOffset(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(val));
-       }
-       break;
+        double val;
+
+        if( ((enum subIndex)index == TM_STROKE_DASHOFFS) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?val?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_STROKE_DASHOFFS) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_STROKE_DASHOFFS) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "val");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set stroke dash offset */
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &val)) != TCL_OK ) {
+                return stat;
+            }
+            DrawSetStrokeDashOffset(wandPtr, val);
+        } else {    /* Get stroke dash offset */
+            val = DrawGetStrokeDashOffset(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(val));
+        }
+        break;
     }
 
     case TM_STROKE_LINECAP:     /* strokelinecap ?linecapType? */
     case TM_GET_STROKE_LINECAP: /* GetStrokeLineCap */
     case TM_SET_STROKE_LINECAP: /* SetStrokeLineCap linecapType */
     {
-       static CONST char *capNames[] = {
-           "undefined", "butt", "round", "square",
-           (char *) NULL
-       };
-       static LineCap capTypes[] = {
-           UndefinedCap, ButtCap, RoundCap, SquareCap
-       };
-       int capIdx;
-       LineCap cap;
-
-       if( ((enum subIndex)index == TM_STROKE_LINECAP) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?linecapType?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_STROKE_LINECAP) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_STROKE_LINECAP) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "linecapType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set font style */
-           if (Tcl_GetIndexFromObj(interp, objv[2], capNames, "linecapType", 0, &capIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           DrawSetStrokeLineCap(wandPtr, capTypes[capIdx]);
-       } else {    /* Get font style */
-           cap = DrawGetStrokeLineCap(wandPtr);
-           for (capIdx = 0; (size_t) capIdx < sizeof(capTypes)/sizeof(capTypes[0]); capIdx++) {
-               if( capTypes[capIdx] == cap ) {
-                   Tcl_SetResult(interp, (char *)capNames[capIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)cap));
-       }
-       break;
+        static CONST char *capNames[] = {
+            "undefined", "butt", "round", "square",
+            (char *) NULL
+        };
+        static LineCap capTypes[] = {
+            UndefinedCap, ButtCap, RoundCap, SquareCap
+        };
+        int capIdx;
+        LineCap cap;
+
+        if( ((enum subIndex)index == TM_STROKE_LINECAP) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?linecapType?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_STROKE_LINECAP) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_STROKE_LINECAP) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "linecapType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set font style */
+            if (Tcl_GetIndexFromObj(interp, objv[2], capNames, "linecapType", 0, &capIdx) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            DrawSetStrokeLineCap(wandPtr, capTypes[capIdx]);
+        } else {    /* Get font style */
+            cap = DrawGetStrokeLineCap(wandPtr);
+            for (capIdx = 0; (size_t) capIdx < sizeof(capTypes)/sizeof(capTypes[0]); capIdx++) {
+                if( capTypes[capIdx] == cap ) {
+                    Tcl_SetResult(interp, (char *)capNames[capIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)cap));
+        }
+        break;
     }
 
     case TM_STROKE_LINEJOIN:     /* strokelinejoin ?linejoinType? */
     case TM_GET_STROKE_LINEJOIN: /* GetStrokeLineJoin */
     case TM_SET_STROKE_LINEJOIN: /* SetStrokeLineJoin linejoinType */
     {
-       static CONST char *joinNames[] = {
-           "undefined", "miter", "round", "bevel",
-           (char *) NULL
-       };
-       static LineJoin joinTypes[] = {
-           UndefinedJoin, MiterJoin, RoundJoin, BevelJoin
-
-       };
-       int joinIdx;
-       LineJoin join;
-
-       if( ((enum subIndex)index == TM_STROKE_LINEJOIN) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?linejoinType?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_STROKE_LINEJOIN) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_STROKE_LINEJOIN) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "linejoinType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set font style */
-           if (Tcl_GetIndexFromObj(interp, objv[2], joinNames, "linejoinType", 0, &joinIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           DrawSetStrokeLineCap(wandPtr, joinTypes[joinIdx]);
-       } else {    /* Get font style */
-           join = DrawGetStrokeLineCap(wandPtr);
-           for (joinIdx = 0; (size_t) joinIdx < sizeof(joinTypes)/sizeof(joinTypes[0]); joinIdx++) {
-               if( joinTypes[joinIdx] == join ) {
-                   Tcl_SetResult(interp, (char *)joinNames[joinIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)join));
-       }
-       break;
+        static CONST char *joinNames[] = {
+            "undefined", "miter", "round", "bevel",
+            (char *) NULL
+        };
+        static LineJoin joinTypes[] = {
+            UndefinedJoin, MiterJoin, RoundJoin, BevelJoin
+
+        };
+        int joinIdx;
+        LineJoin join;
+
+        if( ((enum subIndex)index == TM_STROKE_LINEJOIN) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?linejoinType?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_STROKE_LINEJOIN) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_STROKE_LINEJOIN) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "linejoinType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set font style */
+            if (Tcl_GetIndexFromObj(interp, objv[2], joinNames, "linejoinType", 0, &joinIdx) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            DrawSetStrokeLineCap(wandPtr, joinTypes[joinIdx]);
+        } else {    /* Get font style */
+            join = DrawGetStrokeLineCap(wandPtr);
+            for (joinIdx = 0; (size_t) joinIdx < sizeof(joinTypes)/sizeof(joinTypes[0]); joinIdx++) {
+                if( joinTypes[joinIdx] == join ) {
+                    Tcl_SetResult(interp, (char *)joinNames[joinIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)join));
+        }
+        break;
     }
 
     case TM_STROKE_MITERLIM:     /* strokemiterlimit ?val? */
     case TM_GET_STROKE_MITERLIM: /* strokemiterlimit */
     case TM_SET_STROKE_MITERLIM: /* strokemiterlimit val */
     {
-       unsigned val;
-
-       if( ((enum subIndex)index == TM_STROKE_MITERLIM) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?val?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_STROKE_MITERLIM) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_STROKE_MITERLIM) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "val");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set stroke miterlimit */
-               if( (stat = Tcl_GetIntFromObj(interp, objv[2], (int *) &val)) != TCL_OK ) {
-               return stat;
-           }
-           DrawSetStrokeMiterLimit(wandPtr, val);
-       } else {    /* Get stroke miterlimit */
-           val = DrawGetStrokeMiterLimit(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)val));
-       }
-       break;
+        unsigned val;
+
+        if( ((enum subIndex)index == TM_STROKE_MITERLIM) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?val?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_STROKE_MITERLIM) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_STROKE_MITERLIM) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "val");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set stroke miterlimit */
+                if( (stat = Tcl_GetIntFromObj(interp, objv[2], (int *) &val)) != TCL_OK ) {
+                return stat;
+            }
+            DrawSetStrokeMiterLimit(wandPtr, val);
+        } else {    /* Get stroke miterlimit */
+            val = DrawGetStrokeMiterLimit(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)val));
+        }
+        break;
     }
 
     case TM_STROKE_OPACITY:     /* strokeopacity ?val? */
     case TM_GET_STROKE_OPACITY: /* strokeopacity */
     case TM_SET_STROKE_OPACITY: /* strokeopacity val */
     {
-       double val;
-
-       if( ((enum subIndex)index == TM_STROKE_OPACITY) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?val?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_STROKE_OPACITY) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_STROKE_OPACITY) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "val");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set stroke opacity */
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &val)) != TCL_OK ) {
-               return stat;
-           }
-           DrawSetStrokeOpacity(wandPtr, val);
-       } else {    /* Get stroke opacity */
-           val = DrawGetStrokeOpacity(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(val));
-       }
-       break;
+        double val;
+
+        if( ((enum subIndex)index == TM_STROKE_OPACITY) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?val?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_STROKE_OPACITY) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_STROKE_OPACITY) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "val");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set stroke opacity */
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &val)) != TCL_OK ) {
+                return stat;
+            }
+            DrawSetStrokeOpacity(wandPtr, val);
+        } else {    /* Get stroke opacity */
+            val = DrawGetStrokeOpacity(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(val));
+        }
+        break;
     }
 
     case TM_STROKE_PATTERNURL:      /* strokepatternurl url */
     case TM_SET_STROKE_PATTERNURL:  /* SetStrokePatternURL url */
     {
-       char *url;
+        char *url;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "url");
-           return TCL_ERROR;
-       }
-       url = Tcl_GetString(objv[2]);
-       DrawSetStrokePatternURL(wandPtr, url);
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "url");
+            return TCL_ERROR;
+        }
+        url = Tcl_GetString(objv[2]);
+        DrawSetStrokePatternURL(wandPtr, url);
+        break;
     }
 
     case TM_STROKE_WIDTH:     /* strokewidth ?val? */
     case TM_GET_STROKE_WIDTH: /* strokewidth */
     case TM_SET_STROKE_WIDTH: /* strokewidth val */
     {
-       double val;
-
-       if( ((enum subIndex)index == TM_STROKE_WIDTH) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?val?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_STROKE_WIDTH) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_STROKE_WIDTH) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "val");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set stroke width */
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &val)) != TCL_OK ) {
-               return stat;
-           }
-           DrawSetStrokeWidth(wandPtr, val);
-       } else {    /* Get stroke width */
-           val = DrawGetStrokeWidth(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewDoubleObj(val));
-       }
-       break;
+        double val;
+
+        if( ((enum subIndex)index == TM_STROKE_WIDTH) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?val?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_STROKE_WIDTH) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_STROKE_WIDTH) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "val");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set stroke width */
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &val)) != TCL_OK ) {
+                return stat;
+            }
+            DrawSetStrokeWidth(wandPtr, val);
+        } else {    /* Get stroke width */
+            val = DrawGetStrokeWidth(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewDoubleObj(val));
+        }
+        break;
     }
 
     case TM_TEXT_ANTIALIAS:     /* textantialias ?flag? */
     case TM_GET_TEXT_ANTIALIAS: /* GetTextAntialias */
     case TM_SET_TEXT_ANTIALIAS: /* SetTextAntialias flag */
     {
-       int flag;
-
-       if( ((enum subIndex)index == TM_TEXT_ANTIALIAS) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?flag?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_TEXT_ANTIALIAS) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_TEXT_ANTIALIAS) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "flag");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set antialias flag */
-           if( (stat = Tcl_GetIntFromObj(interp, objv[2], &flag)) != TCL_OK ) {
-               return stat;
-           }
-           DrawSetTextAntialias(wandPtr, flag);
-       } else {    /* Get antialias flag */
-           flag = DrawGetTextAntialias(wandPtr);
-           Tcl_SetObjResult(interp, Tcl_NewIntObj(flag));
-       }
-       break;
+        int flag;
+
+        if( ((enum subIndex)index == TM_TEXT_ANTIALIAS) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?flag?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_TEXT_ANTIALIAS) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_TEXT_ANTIALIAS) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "flag");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set antialias flag */
+            if( (stat = Tcl_GetIntFromObj(interp, objv[2], &flag)) != TCL_OK ) {
+                return stat;
+            }
+            DrawSetTextAntialias(wandPtr, flag);
+        } else {    /* Get antialias flag */
+            flag = DrawGetTextAntialias(wandPtr);
+            Tcl_SetObjResult(interp, Tcl_NewIntObj(flag));
+        }
+        break;
     }
 
     case TM_TEXT_DECORATION:     /* textdecoration ?decorationType? */
     case TM_GET_TEXT_DECORATION: /* GetTextDecoration */
     case TM_SET_TEXT_DECORATION: /* SetTextDecoration decorationType */
     {
-       static CONST char *decoNames[] = {
-           "none", "underline", "overline", "linethrough",
-           (char *) NULL
-       };
-       static DecorationType decoTypes[] = {
-           NoDecoration, UnderlineDecoration, OverlineDecoration, LineThroughDecoration
-       };
-       int decoIdx;
-       DecorationType deco;
-
-       if( ((enum subIndex)index == TM_TEXT_DECORATION) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?decorationType?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_TEXT_DECORATION) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_TEXT_DECORATION) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "decorationType");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set antialias flag */
-           if (Tcl_GetIndexFromObj(interp, objv[2], decoNames, "decorationType", 0, &decoIdx) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           DrawSetTextDecoration(wandPtr, decoTypes[decoIdx]);
-       } else {    /* Get antialias flag */
-           deco = DrawGetTextDecoration(wandPtr);
-           for (decoIdx = 0; (size_t) decoIdx < sizeof(decoTypes)/sizeof(decoTypes[0]); decoIdx++) {
-               if( decoTypes[decoIdx] == deco ) {
-                   Tcl_SetResult(interp, (char *)decoNames[decoIdx], TCL_VOLATILE);
-                   return TCL_OK;
-               }
-           }
-           Tcl_SetObjResult(interp, Tcl_NewIntObj((int)deco));
-       }
-       break;
+        static CONST char *decoNames[] = {
+            "none", "underline", "overline", "linethrough",
+            (char *) NULL
+        };
+        static DecorationType decoTypes[] = {
+            NoDecoration, UnderlineDecoration, OverlineDecoration, LineThroughDecoration
+        };
+        int decoIdx;
+        DecorationType deco;
+
+        if( ((enum subIndex)index == TM_TEXT_DECORATION) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?decorationType?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_TEXT_DECORATION) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_TEXT_DECORATION) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "decorationType");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set antialias flag */
+            if (Tcl_GetIndexFromObj(interp, objv[2], decoNames, "decorationType", 0, &decoIdx) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            DrawSetTextDecoration(wandPtr, decoTypes[decoIdx]);
+        } else {    /* Get antialias flag */
+            deco = DrawGetTextDecoration(wandPtr);
+            for (decoIdx = 0; (size_t) decoIdx < sizeof(decoTypes)/sizeof(decoTypes[0]); decoIdx++) {
+                if( decoTypes[decoIdx] == deco ) {
+                    Tcl_SetResult(interp, (char *)decoNames[decoIdx], TCL_VOLATILE);
+                    return TCL_OK;
+                }
+            }
+            Tcl_SetObjResult(interp, Tcl_NewIntObj((int)deco));
+        }
+        break;
     }
 
     case TM_TEXT_ENCODING:      /* textencoding ?string? */
     case TM_GET_TEXT_ENCODING:  /* GetTextEncoding */
     case TM_SET_TEXT_ENCODING:  /* SetTextEncoding string */
     {
-       char *str;
-
-       if( ((enum subIndex)index == TM_TEXT_ENCODING) && (objc > 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "?string?");
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_GET_TEXT_ENCODING) && (objc != 2) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       } else if( ((enum subIndex)index == TM_SET_TEXT_ENCODING) && (objc != 3) ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "string");
-           return TCL_ERROR;
-       }
-       if (objc == 3) { /* Set antialias flag */
-           str = Tcl_GetString(objv[2]);
-           DrawSetTextEncoding(wandPtr, str);
-       } else {    /* Get antialias flag */
-           str = DrawGetTextEncoding(wandPtr);
-           Tcl_SetResult(interp, str, TCL_VOLATILE);
-           MagickRelinquishMemory(str);
-       }
-       break;
+        char *str;
+
+        if( ((enum subIndex)index == TM_TEXT_ENCODING) && (objc > 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "?string?");
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_GET_TEXT_ENCODING) && (objc != 2) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        } else if( ((enum subIndex)index == TM_SET_TEXT_ENCODING) && (objc != 3) ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "string");
+            return TCL_ERROR;
+        }
+        if (objc == 3) { /* Set antialias flag */
+            str = Tcl_GetString(objv[2]);
+            DrawSetTextEncoding(wandPtr, str);
+        } else {    /* Get antialias flag */
+            str = DrawGetTextEncoding(wandPtr);
+            Tcl_SetResult(interp, str, TCL_VOLATILE);
+            MagickRelinquishMemory(str);
+        }
+        break;
     }
 
     case TM_TRANSLATE:  /* translate x y */
     case TM_TTRANSLATE: /* Translate x y */
     {
-       double x, y;
+        double x, y;
 
-       if( objc != 4 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x y");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
-           return stat;
-       }
-       DrawTranslate(wandPtr, x, y);
-       break;
+        if( objc != 4 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x y");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[2], &x)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &y)) != TCL_OK ) {
+            return stat;
+        }
+        DrawTranslate(wandPtr, x, y);
+        break;
     }
 
     case TM_VIEWBOX:        /* viewbox x1 y1 x2 y2 */
     case TM_SET_VIEWBOX:    /* SetViewbox x1 y1 x2 y2 */
     {
-       unsigned long x1, y1, x2, y2;
-
-       if( objc != 6 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "x1 y1 x2 y2");
-           return TCL_ERROR;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &x1)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &y1)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[4], (long int *) &x2)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetLongFromObj(interp, objv[5], (long int *) &y2)) != TCL_OK ) {
-           return stat;
-       }
-       DrawSetViewbox(wandPtr, x1, y1, x2, y2);
-       break;
+        unsigned long x1, y1, x2, y2;
+
+        if( objc != 6 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "x1 y1 x2 y2");
+            return TCL_ERROR;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[2], (long int *) &x1)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[3], (long int *) &y1)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[4], (long int *) &x2)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetLongFromObj(interp, objv[5], (long int *) &y2)) != TCL_OK ) {
+            return stat;
+        }
+        DrawSetViewbox(wandPtr, x1, y1, x2, y2);
+        break;
     }
 
     /****************************************************************
@@ -7613,61 +7622,61 @@ static int drawObjCmd(
      ****************************************************************/
     case TM_PUSH_CLIPPATH: /* PushClipPath id */
     {
-       char *id;
+        char *id;
 
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "id");
-           return TCL_ERROR;
-       }
-       id = Tcl_GetString(objv[2]);
-       DrawPushClipPath(wandPtr, id);
-       break;
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "id");
+            return TCL_ERROR;
+        }
+        id = Tcl_GetString(objv[2]);
+        DrawPushClipPath(wandPtr, id);
+        break;
     }
 
     case TM_PUSH_DEFS: /* PushDefs */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       DrawPushDefs(wandPtr);
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        DrawPushDefs(wandPtr);
+        break;
     }
 
     case TM_PUSH_GRAPHIC_CTX: /* PushGraphicContext */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       DrawPushGraphicContext(wandPtr);
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        DrawPushGraphicContext(wandPtr);
+        break;
     }
 
     case TM_PUSH_PATTERN: /* PushPattern id x y width height */
     {
-       char   *id;
-       double x, y, width, height;
-
-       if( objc != 7 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, "id x y width height");
-           return TCL_ERROR;
-       }
-       id = Tcl_GetString(objv[3]);
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &x)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &y)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &width)) != TCL_OK ) {
-           return stat;
-       }
-       if( (stat = Tcl_GetDoubleFromObj(interp, objv[6], &height)) != TCL_OK ) {
-           return stat;
-       }
-       DrawPushPattern(wandPtr, id, x, y, width, height);
-       break;
+        char   *id;
+        double x, y, width, height;
+
+        if( objc != 7 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, "id x y width height");
+            return TCL_ERROR;
+        }
+        id = Tcl_GetString(objv[3]);
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[3], &x)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &y)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &width)) != TCL_OK ) {
+            return stat;
+        }
+        if( (stat = Tcl_GetDoubleFromObj(interp, objv[6], &height)) != TCL_OK ) {
+            return stat;
+        }
+        DrawPushPattern(wandPtr, id, x, y, width, height);
+        break;
     }
 
     case TM_POP_CLIPPATH:       /* PopClipPath */
@@ -7675,104 +7684,104 @@ static int drawObjCmd(
     case TM_POP_GRAPHIC_CTX:    /* PopGraphicContext */
     case TM_POP_PATTERN:        /* PopPattern */
     {
-       if( objc != 2 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       switch((enum subIndex)index) {
-       case TM_POP_CLIPPATH:       DrawPopClipPath(wandPtr); break;
-       case TM_POP_DEFS:           DrawPopDefs(wandPtr); break;
-       case TM_POP_GRAPHIC_CTX:    DrawPopGraphicContext(wandPtr); break;
-       case TM_POP_PATTERN:        DrawPopPattern(wandPtr); break;
-       default: break;
-       }
-       break;
+        if( objc != 2 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        switch((enum subIndex)index) {
+        case TM_POP_CLIPPATH:       DrawPopClipPath(wandPtr); break;
+        case TM_POP_DEFS:           DrawPopDefs(wandPtr); break;
+        case TM_POP_GRAPHIC_CTX:    DrawPopGraphicContext(wandPtr); break;
+        case TM_POP_PATTERN:        DrawPopPattern(wandPtr); break;
+        default: break;
+        }
+        break;
     }
 
     case TM_PUSH:   /* push what ?args? */
     {
-       int what;
-
-       if (Tcl_GetIndexFromObj(interp, objv[2], pushCmdNames, "what", 0, &what) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       switch((enum pushCmdIndex)what) {
-       case TM_PUSH_CMD_CLIP: /* clippath */
-       {
-           char *id;
-
-           if( objc != 4 ) {
-               Tcl_WrongNumArgs(interp, 2, objv, "id");
-               return TCL_ERROR;
-           }
-           id = Tcl_GetString(objv[3]);
-           DrawPushClipPath(wandPtr, id);
-           break;
-       }
-       case TM_PUSH_CMD_DEFS: /* defs */
-       {
-           if( objc != 3 ) {
-               Tcl_WrongNumArgs(interp, 2, objv, NULL);
-               return TCL_ERROR;
-           }
-           DrawPushDefs(wandPtr);
-       }
-       case TM_PUSH_CMD_GRAPH: /* graphiccontext */
-       {
-           if( objc != 3 ) {
-               Tcl_WrongNumArgs(interp, 2, objv, NULL);
-               return TCL_ERROR;
-           }
-           DrawPushGraphicContext(wandPtr);
-           break;
-       }
-       case TM_PUSH_CMD_PAT: /* pattern */
-       {
-           char   *id;
-           double x, y, width, height;
-
-           if( objc != 8 ) {
-               Tcl_WrongNumArgs(interp, 2, objv, "id x y width height");
-               return TCL_ERROR;
-           }
-           id = Tcl_GetString(objv[3]);
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &x)) != TCL_OK ) {
-               return stat;
-           }
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &y)) != TCL_OK ) {
-               return stat;
-           }
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[6], &width)) != TCL_OK ) {
-               return stat;
-           }
-           if( (stat = Tcl_GetDoubleFromObj(interp, objv[7], &height)) != TCL_OK ) {
-               return stat;
-           }
-           DrawPushPattern(wandPtr, id, x, y, width, height);
-           break;
-       }
-       } /* switch(what) */
-       break;
+        int what;
+
+        if (Tcl_GetIndexFromObj(interp, objv[2], pushCmdNames, "what", 0, &what) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        switch((enum pushCmdIndex)what) {
+        case TM_PUSH_CMD_CLIP: /* clippath */
+        {
+            char *id;
+
+            if( objc != 4 ) {
+                Tcl_WrongNumArgs(interp, 2, objv, "id");
+                return TCL_ERROR;
+            }
+            id = Tcl_GetString(objv[3]);
+            DrawPushClipPath(wandPtr, id);
+            break;
+        }
+        case TM_PUSH_CMD_DEFS: /* defs */
+        {
+            if( objc != 3 ) {
+                Tcl_WrongNumArgs(interp, 2, objv, NULL);
+                return TCL_ERROR;
+            }
+            DrawPushDefs(wandPtr);
+        }
+        case TM_PUSH_CMD_GRAPH: /* graphiccontext */
+        {
+            if( objc != 3 ) {
+                Tcl_WrongNumArgs(interp, 2, objv, NULL);
+                return TCL_ERROR;
+            }
+            DrawPushGraphicContext(wandPtr);
+            break;
+        }
+        case TM_PUSH_CMD_PAT: /* pattern */
+        {
+            char   *id;
+            double x, y, width, height;
+
+            if( objc != 8 ) {
+                Tcl_WrongNumArgs(interp, 2, objv, "id x y width height");
+                return TCL_ERROR;
+            }
+            id = Tcl_GetString(objv[3]);
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[4], &x)) != TCL_OK ) {
+                return stat;
+            }
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[5], &y)) != TCL_OK ) {
+                return stat;
+            }
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[6], &width)) != TCL_OK ) {
+                return stat;
+            }
+            if( (stat = Tcl_GetDoubleFromObj(interp, objv[7], &height)) != TCL_OK ) {
+                return stat;
+            }
+            DrawPushPattern(wandPtr, id, x, y, width, height);
+            break;
+        }
+        } /* switch(what) */
+        break;
     }
 
     case TM_POP:   /* pop what */
     {
-       int what;
+        int what;
 
-       if (Tcl_GetIndexFromObj(interp, objv[2], pushCmdNames, "what", 0, &what) != TCL_OK) {
-           return TCL_ERROR;
-       }
-       if( objc != 3 ) {
-           Tcl_WrongNumArgs(interp, 2, objv, NULL);
-           return TCL_ERROR;
-       }
-       switch((enum pushCmdIndex)what) {
-       case TM_PUSH_CMD_CLIP:  DrawPopClipPath(wandPtr);       break;
-       case TM_PUSH_CMD_DEFS:  DrawPopDefs(wandPtr);           break;
-       case TM_PUSH_CMD_GRAPH: DrawPopGraphicContext(wandPtr); break;
-       case TM_PUSH_CMD_PAT:   DrawPopPattern(wandPtr);        break;
-       } /* switch(what) */
-       break;
+        if (Tcl_GetIndexFromObj(interp, objv[2], pushCmdNames, "what", 0, &what) != TCL_OK) {
+            return TCL_ERROR;
+        }
+        if( objc != 3 ) {
+            Tcl_WrongNumArgs(interp, 2, objv, NULL);
+            return TCL_ERROR;
+        }
+        switch((enum pushCmdIndex)what) {
+        case TM_PUSH_CMD_CLIP:  DrawPopClipPath(wandPtr);       break;
+        case TM_PUSH_CMD_DEFS:  DrawPopDefs(wandPtr);           break;
+        case TM_PUSH_CMD_GRAPH: DrawPopGraphicContext(wandPtr); break;
+        case TM_PUSH_CMD_PAT:   DrawPopPattern(wandPtr);        break;
+        } /* switch(what) */
+        break;
     }
 
     /****************************************************************
@@ -7780,316 +7789,316 @@ static int drawObjCmd(
      ****************************************************************/
     case TM_PATH:   /* path -opt|cmd ?args? -opt|cmd ?args? */
     {
-       static CONST char *pathCmdNames[] = {
-           "#",        "-relative",  "-smooth",
-           "close",    "cubic",      "elliptic",
-           "finish",   "horizontal", "line",
-           "move",     "quadratic",  "start",
-           "vertical",
-           (char *) NULL
-       };
-       enum pathCmdIndex {
-           TM_PATH_COMMENT,      TM_PATH_OPT_RELATIVE,   TM_PATH_OPT_SMOOTH,
-           TM_PATH_CMD_CLOSE,    TM_PATH_CMD_CUBIC,      TM_PATH_CMD_ELLIPTIC,
-           TM_PATH_CMD_FINISH,   TM_PATH_CMD_HORIZONTAL, TM_PATH_CMD_LINE,
-           TM_PATH_CMD_MOVE,     TM_PATH_CMD_QUADRATIC,  TM_PATH_CMD_START,
-           TM_PATH_CMD_VERTICAL,
-       };
-       int cmd, stat;
-       int relFlag=0, smoothFlag=0;
-       int argc;
-       Tcl_Obj **argv;
-
-       /*
-        * Two ways of calling '$draw path' command:
-        * 1. With many arguments:
-        *    $draw path start -relative on \
-        *         move 10 10   \
-        *         line 10 20   \
-        *         line 10 -20  \
-        *         close finish
-        * 2. With a single argument list
-        *    $draw path {
-        *         start -relative on
-        *         move 10 10
-        *         line 10 20
-        *         line 10 -20
-        *         close finish
-        *    }
-        */
-       if( objc == 3 ) {
-           /*
-            * Single argument list
-            */
-           if( (stat = Tcl_ListObjGetElements(interp, objv[2], &argc, &argv) != TCL_OK) ) {
-               return stat;
-           }
-       } else {
-           argc = objc-2;
-           argv = (Tcl_Obj **)(objv+2);
-       }
-       while( argc > 0 ) {
-           if (Tcl_GetIndexFromObj(interp, argv[0], pathCmdNames, "option/command", 0, &cmd) != TCL_OK) {
-               return TCL_ERROR;
-           }
-           switch((enum pathCmdIndex)cmd) {
-
-           case TM_PATH_COMMENT:  /* # comment */
-               argc -= 2, argv += 2;
-               break;
-
-           case TM_PATH_OPT_RELATIVE:  /* -relative boolean */
-               if( argc < 2 ) {
-                   Tcl_WrongNumArgs(interp, 1, argv, "boolean");
-                   return TCL_ERROR;
-               }
-               if( (stat = Tcl_GetBooleanFromObj(interp, argv[1], &relFlag)) != TCL_OK) {
-                   return stat;
-               }
-               argc -= 2, argv += 2;
-               break;
-
-           case TM_PATH_OPT_SMOOTH:    /* -smooth boolean */
-               if( argc < 2 ) {
-                   Tcl_WrongNumArgs(interp, 1, argv, "boolean");
-                   return TCL_ERROR;
-               }
-               if( (stat = Tcl_GetBooleanFromObj(interp, argv[1], &smoothFlag)) != TCL_OK) {
-                   return stat;
-               }
-               argc -= 2, argv += 2;
-               break;
-
-           case TM_PATH_CMD_CLOSE:     /* close */
-               DrawPathClose(wandPtr);
-               argc -= 1, argv += 1;
-               break;
-
-           case TM_PATH_CMD_CUBIC:     /* cubic ?x1 y1? x2 y2 x y */
-           {
-               double x1, y1, x2, y2, x, y;
-
-               if( smoothFlag ) {
-                   /*
-                    * -smooth 1 cubic x2 y2 x y
-                    */
-                   if( argc < 5 ) {
-                       Tcl_WrongNumArgs(interp, 1, argv, "x2 y2 x y");
-                       return TCL_ERROR;
-                   }
-                   if(    ((stat = Tcl_GetDoubleFromObj(interp, argv[1], &x2)) != TCL_OK)
-                          || ((stat = Tcl_GetDoubleFromObj(interp, argv[2], &y2)) != TCL_OK)
-                          || ((stat = Tcl_GetDoubleFromObj(interp, argv[3], &x )) != TCL_OK)
-                          || ((stat = Tcl_GetDoubleFromObj(interp, argv[4], &y )) != TCL_OK) )
-                   {
-                       Tcl_AppendResult(interp, "Smooth cubic bezier curve arguments: x2 y2 x y", NULL);
-                       return stat;
-                   }
-                   relFlag
-                       ? DrawPathCurveToSmoothRelative(wandPtr, x2, y2, x, y)
-                       : DrawPathCurveToSmoothAbsolute(wandPtr, x2, y2, x, y);
-
-                   argc -= 5, argv += 5;
-               } else {
-                   /*
-                    * -smooth 0 cubic x1 y1 x2 y2 x y
-                    */
-                   if( argc < 7 ) {
-                       Tcl_WrongNumArgs(interp, 1, argv, "x1 y1 x2 y2 x y");
-                       return TCL_ERROR;
-                   }
-                   if(    ((stat = Tcl_GetDoubleFromObj(interp, argv[1], &x1)) != TCL_OK)
-                          || ((stat = Tcl_GetDoubleFromObj(interp, argv[2], &y1)) != TCL_OK)
-                          || ((stat = Tcl_GetDoubleFromObj(interp, argv[3], &x2)) != TCL_OK)
-                          || ((stat = Tcl_GetDoubleFromObj(interp, argv[4], &y2)) != TCL_OK)
-                          || ((stat = Tcl_GetDoubleFromObj(interp, argv[5], &x )) != TCL_OK)
-                          || ((stat = Tcl_GetDoubleFromObj(interp, argv[6], &y )) != TCL_OK) )
-                   {
-                       Tcl_AppendResult(interp, "Cubic bezier curve arguments: x1 y1 x2 y2 x y", NULL);
-                       return stat;
-                   }
-                   relFlag
-                       ? DrawPathCurveToRelative(wandPtr, x1, y1, x2, y2, x, y)
-                       : DrawPathCurveToAbsolute(wandPtr, x1, y1, x2, y2, x, y);
-
-                   argc -= 7, argv += 7;
-               }
-               break;
-           }
-
-           case TM_PATH_CMD_ELLIPTIC:  /* elliptic rx ry rotation large sweep x y */
-           {
-               double      rx, ry, rot, x, y;
-               int        large, sweep;
-
-               if( argc < 8 ) {
-                   Tcl_WrongNumArgs(interp, 1, argv, "rx ry rotation large sweep x y");
-                   return TCL_ERROR;
-               }
-               if(    ((stat = Tcl_GetDoubleFromObj(interp,  argv[1], &rx )) != TCL_OK)
-                      || ((stat = Tcl_GetDoubleFromObj(interp,  argv[2], &ry )) != TCL_OK)
-                      || ((stat = Tcl_GetDoubleFromObj(interp,  argv[3], &rot)) != TCL_OK)
-                      || ((stat = Tcl_GetBooleanFromObj(interp, argv[4], &large )) != TCL_OK)
-                      || ((stat = Tcl_GetBooleanFromObj(interp, argv[5], &sweep )) != TCL_OK)
-                      || ((stat = Tcl_GetDoubleFromObj(interp,  argv[6], &x  )) != TCL_OK)
-                      || ((stat = Tcl_GetDoubleFromObj(interp,  argv[7], &y  )) != TCL_OK) )
-               {
-                   Tcl_AppendResult(interp, "Elliptic arc arguments: rx ry rotation large sweep x y", NULL);
-                   return stat;
-               }
-               relFlag
-                   ? DrawPathEllipticArcRelative(wandPtr, rx, ry, rot, large, sweep, x, y)
-                   : DrawPathEllipticArcAbsolute(wandPtr, rx, ry, rot, large, sweep, x, y);
-
-               argc -= 8, argv += 8;
-               break;
-           }
-
-           case TM_PATH_CMD_FINISH:     /* finish */
-               DrawPathFinish(wandPtr);
-               argc -= 1, argv += 1;
-               break;
-
-           case TM_PATH_CMD_HORIZONTAL:  /* horizontal x */
-           {
-               double x;
-
-               if( argc < 2 ) {
-                   Tcl_WrongNumArgs(interp, 1, argv, "x");
-                   return TCL_ERROR;
-               }
-               if( (stat = Tcl_GetDoubleFromObj(interp, argv[1], &x)) != TCL_OK) {
-                   Tcl_AppendResult(interp, "Horizonal line argument: x", NULL);
-                   return stat;
-               }
-               relFlag
-                   ? DrawPathLineToHorizontalRelative(wandPtr, x)
-                   : DrawPathLineToHorizontalAbsolute(wandPtr, x);
-
-               argc -= 2, argv += 2;
-               break;
-           }
-
-           case TM_PATH_CMD_LINE:  /* line x y */
-           {
-               double x, y;
-
-               if( argc < 3 ) {
-                   Tcl_WrongNumArgs(interp, 1, argv, "x y");
-                   return TCL_ERROR;
-               }
-               if(    ((stat = Tcl_GetDoubleFromObj(interp, argv[1], &x )) != TCL_OK)
-                      || ((stat = Tcl_GetDoubleFromObj(interp, argv[2], &y )) != TCL_OK) )
-               {
-                   Tcl_AppendResult(interp, "Line arguments: x y", NULL);
-                   return stat;
-               }
-               relFlag
-                   ? DrawPathLineToRelative(wandPtr, x, y)
-                   : DrawPathLineToAbsolute(wandPtr, x, y);
-
-               argc -= 3, argv += 3;
-               break;
-           }
-
-           case TM_PATH_CMD_MOVE:  /* move {x y} */
-           {
-               double x, y;
-
-               if( argc < 3 ) {
-                   Tcl_WrongNumArgs(interp, 1, argv, "x y");
-                   return TCL_ERROR;
-               }
-               if(    ((stat = Tcl_GetDoubleFromObj(interp, argv[1], &x )) != TCL_OK)
-                      || ((stat = Tcl_GetDoubleFromObj(interp, argv[2], &y )) != TCL_OK) )
-               {
-                   Tcl_AppendResult(interp, "Line arguments: x y", NULL);
-                   return stat;
-               }
-               relFlag
-                   ? DrawPathMoveToRelative(wandPtr, x, y)
-                   : DrawPathMoveToAbsolute(wandPtr, x, y);
-
-               argc -= 3, argv += 3;
-               break;
-           }
-
-           case TM_PATH_CMD_QUADRATIC:     /* quadratic ?x1 y1? x y */
-           {
-               double x1, y1, x, y;
-
-               if( smoothFlag ) {
-                   /*
-                    * -smooth 1 quadratic x y
-                    */
-                   if( argc < 3 ) {
-                       Tcl_WrongNumArgs(interp, 1, argv, "x y");
-                       return TCL_ERROR;
-                   }
-                   if(    ((stat = Tcl_GetDoubleFromObj(interp, argv[1], &x )) != TCL_OK)
-                          || ((stat = Tcl_GetDoubleFromObj(interp, argv[2], &y )) != TCL_OK) )
-                   {
-                       Tcl_AppendResult(interp, "Smooth quadratic bezier curve arguments: x y", NULL);
-                       return stat;
-                   }
-                   relFlag
-                       ? DrawPathCurveToQuadraticBezierSmoothRelative(wandPtr, x, y)
-                       : DrawPathCurveToQuadraticBezierSmoothAbsolute(wandPtr, x, y);
-
-                   argc -= 3, argv += 3;
-               } else {
-                   /*
-                    * -smooth 0 quadratic x1 y1 x y
-                    */
-                   if( argc < 5 ) {
-                       Tcl_WrongNumArgs(interp, 1, argv, "x2 y2 x y");
-                       return TCL_ERROR;
-                   }
-                   if(    ((stat = Tcl_GetDoubleFromObj(interp, argv[1], &x1)) != TCL_OK)
-                          || ((stat = Tcl_GetDoubleFromObj(interp, argv[2], &y1)) != TCL_OK)
-                          || ((stat = Tcl_GetDoubleFromObj(interp, argv[3], &x )) != TCL_OK)
-                          || ((stat = Tcl_GetDoubleFromObj(interp, argv[4], &y )) != TCL_OK) )
-                   {
-                       Tcl_AppendResult(interp, "Quadratic bezier curve arguments: x1 y1 x y", NULL);
-                       return stat;
-                   }
-                   relFlag
-                       ? DrawPathCurveToQuadraticBezierRelative(wandPtr, x1, y1, x, y)
-                       : DrawPathCurveToQuadraticBezierAbsolute(wandPtr, x1, y1, x, y);
-
-                   argc -= 5, argv += 5;
-               }
-               break;
-           }
-
-           case TM_PATH_CMD_START:     /* start */
-               DrawPathStart(wandPtr);
-               argc -= 1, argv += 1;
-               break;
-
-           case TM_PATH_CMD_VERTICAL:  /* vertical {y} */
-           {
-               double y;
-
-               if( argc < 2 ) {
-                   Tcl_WrongNumArgs(interp, 1, argv, "y");
-                   return TCL_ERROR;
-               }
-               if( (stat = Tcl_GetDoubleFromObj(interp, argv[1], &y)) != TCL_OK) {
-                   Tcl_AppendResult(interp, "Horizonal line argument: y", NULL);
-                   return stat;
-               }
-               relFlag
-                   ? DrawPathLineToVerticalRelative(wandPtr, y)
-                   : DrawPathLineToVerticalAbsolute(wandPtr, y);
-
-               argc -= 2, argv += 2;
-               break;
-           }
-
-           } /* switch( path-cmd) */
-       }
-       break; /* path */
+        static CONST char *pathCmdNames[] = {
+            "#",        "-relative",  "-smooth",
+            "close",    "cubic",      "elliptic",
+            "finish",   "horizontal", "line",
+            "move",     "quadratic",  "start",
+            "vertical",
+            (char *) NULL
+        };
+        enum pathCmdIndex {
+            TM_PATH_COMMENT,      TM_PATH_OPT_RELATIVE,   TM_PATH_OPT_SMOOTH,
+            TM_PATH_CMD_CLOSE,    TM_PATH_CMD_CUBIC,      TM_PATH_CMD_ELLIPTIC,
+            TM_PATH_CMD_FINISH,   TM_PATH_CMD_HORIZONTAL, TM_PATH_CMD_LINE,
+            TM_PATH_CMD_MOVE,     TM_PATH_CMD_QUADRATIC,  TM_PATH_CMD_START,
+            TM_PATH_CMD_VERTICAL,
+        };
+        int cmd, stat;
+        int relFlag=0, smoothFlag=0;
+        int argc;
+        Tcl_Obj **argv;
+
+        /*
+         * Two ways of calling '$draw path' command:
+         * 1. With many arguments:
+         *    $draw path start -relative on \
+         *         move 10 10   \
+         *         line 10 20   \
+         *         line 10 -20  \
+         *         close finish
+         * 2. With a single argument list
+         *    $draw path {
+         *         start -relative on
+         *         move 10 10
+         *         line 10 20
+         *         line 10 -20
+         *         close finish
+         *    }
+         */
+        if( objc == 3 ) {
+            /*
+             * Single argument list
+             */
+            if( (stat = Tcl_ListObjGetElements(interp, objv[2], &argc, &argv) != TCL_OK) ) {
+                return stat;
+            }
+        } else {
+            argc = objc-2;
+            argv = (Tcl_Obj **)(objv+2);
+        }
+        while( argc > 0 ) {
+            if (Tcl_GetIndexFromObj(interp, argv[0], pathCmdNames, "option/command", 0, &cmd) != TCL_OK) {
+                return TCL_ERROR;
+            }
+            switch((enum pathCmdIndex)cmd) {
+
+            case TM_PATH_COMMENT:  /* # comment */
+                argc -= 2, argv += 2;
+                break;
+
+            case TM_PATH_OPT_RELATIVE:  /* -relative boolean */
+                if( argc < 2 ) {
+                    Tcl_WrongNumArgs(interp, 1, argv, "boolean");
+                    return TCL_ERROR;
+                }
+                if( (stat = Tcl_GetBooleanFromObj(interp, argv[1], &relFlag)) != TCL_OK) {
+                    return stat;
+                }
+                argc -= 2, argv += 2;
+                break;
+
+            case TM_PATH_OPT_SMOOTH:    /* -smooth boolean */
+                if( argc < 2 ) {
+                    Tcl_WrongNumArgs(interp, 1, argv, "boolean");
+                    return TCL_ERROR;
+                }
+                if( (stat = Tcl_GetBooleanFromObj(interp, argv[1], &smoothFlag)) != TCL_OK) {
+                    return stat;
+                }
+                argc -= 2, argv += 2;
+                break;
+
+            case TM_PATH_CMD_CLOSE:     /* close */
+                DrawPathClose(wandPtr);
+                argc -= 1, argv += 1;
+                break;
+
+            case TM_PATH_CMD_CUBIC:     /* cubic ?x1 y1? x2 y2 x y */
+            {
+                double x1, y1, x2, y2, x, y;
+
+                if( smoothFlag ) {
+                    /*
+                     * -smooth 1 cubic x2 y2 x y
+                     */
+                    if( argc < 5 ) {
+                        Tcl_WrongNumArgs(interp, 1, argv, "x2 y2 x y");
+                        return TCL_ERROR;
+                    }
+                    if(    ((stat = Tcl_GetDoubleFromObj(interp, argv[1], &x2)) != TCL_OK)
+                           || ((stat = Tcl_GetDoubleFromObj(interp, argv[2], &y2)) != TCL_OK)
+                           || ((stat = Tcl_GetDoubleFromObj(interp, argv[3], &x )) != TCL_OK)
+                           || ((stat = Tcl_GetDoubleFromObj(interp, argv[4], &y )) != TCL_OK) )
+                    {
+                        Tcl_AppendResult(interp, "Smooth cubic bezier curve arguments: x2 y2 x y", NULL);
+                        return stat;
+                    }
+                    relFlag
+                        ? DrawPathCurveToSmoothRelative(wandPtr, x2, y2, x, y)
+                        : DrawPathCurveToSmoothAbsolute(wandPtr, x2, y2, x, y);
+
+                    argc -= 5, argv += 5;
+                } else {
+                    /*
+                     * -smooth 0 cubic x1 y1 x2 y2 x y
+                     */
+                    if( argc < 7 ) {
+                        Tcl_WrongNumArgs(interp, 1, argv, "x1 y1 x2 y2 x y");
+                        return TCL_ERROR;
+                    }
+                    if(    ((stat = Tcl_GetDoubleFromObj(interp, argv[1], &x1)) != TCL_OK)
+                           || ((stat = Tcl_GetDoubleFromObj(interp, argv[2], &y1)) != TCL_OK)
+                           || ((stat = Tcl_GetDoubleFromObj(interp, argv[3], &x2)) != TCL_OK)
+                           || ((stat = Tcl_GetDoubleFromObj(interp, argv[4], &y2)) != TCL_OK)
+                           || ((stat = Tcl_GetDoubleFromObj(interp, argv[5], &x )) != TCL_OK)
+                           || ((stat = Tcl_GetDoubleFromObj(interp, argv[6], &y )) != TCL_OK) )
+                    {
+                        Tcl_AppendResult(interp, "Cubic bezier curve arguments: x1 y1 x2 y2 x y", NULL);
+                        return stat;
+                    }
+                    relFlag
+                        ? DrawPathCurveToRelative(wandPtr, x1, y1, x2, y2, x, y)
+                        : DrawPathCurveToAbsolute(wandPtr, x1, y1, x2, y2, x, y);
+
+                    argc -= 7, argv += 7;
+                }
+                break;
+            }
+
+            case TM_PATH_CMD_ELLIPTIC:  /* elliptic rx ry rotation large sweep x y */
+            {
+                double      rx, ry, rot, x, y;
+                int        large, sweep;
+
+                if( argc < 8 ) {
+                    Tcl_WrongNumArgs(interp, 1, argv, "rx ry rotation large sweep x y");
+                    return TCL_ERROR;
+                }
+                if(    ((stat = Tcl_GetDoubleFromObj(interp,  argv[1], &rx )) != TCL_OK)
+                       || ((stat = Tcl_GetDoubleFromObj(interp,  argv[2], &ry )) != TCL_OK)
+                       || ((stat = Tcl_GetDoubleFromObj(interp,  argv[3], &rot)) != TCL_OK)
+                       || ((stat = Tcl_GetBooleanFromObj(interp, argv[4], &large )) != TCL_OK)
+                       || ((stat = Tcl_GetBooleanFromObj(interp, argv[5], &sweep )) != TCL_OK)
+                       || ((stat = Tcl_GetDoubleFromObj(interp,  argv[6], &x  )) != TCL_OK)
+                       || ((stat = Tcl_GetDoubleFromObj(interp,  argv[7], &y  )) != TCL_OK) )
+                {
+                    Tcl_AppendResult(interp, "Elliptic arc arguments: rx ry rotation large sweep x y", NULL);
+                    return stat;
+                }
+                relFlag
+                    ? DrawPathEllipticArcRelative(wandPtr, rx, ry, rot, large, sweep, x, y)
+                    : DrawPathEllipticArcAbsolute(wandPtr, rx, ry, rot, large, sweep, x, y);
+
+                argc -= 8, argv += 8;
+                break;
+            }
+
+            case TM_PATH_CMD_FINISH:     /* finish */
+                DrawPathFinish(wandPtr);
+                argc -= 1, argv += 1;
+                break;
+
+            case TM_PATH_CMD_HORIZONTAL:  /* horizontal x */
+            {
+                double x;
+
+                if( argc < 2 ) {
+                    Tcl_WrongNumArgs(interp, 1, argv, "x");
+                    return TCL_ERROR;
+                }
+                if( (stat = Tcl_GetDoubleFromObj(interp, argv[1], &x)) != TCL_OK) {
+                    Tcl_AppendResult(interp, "Horizonal line argument: x", NULL);
+                    return stat;
+                }
+                relFlag
+                    ? DrawPathLineToHorizontalRelative(wandPtr, x)
+                    : DrawPathLineToHorizontalAbsolute(wandPtr, x);
+
+                argc -= 2, argv += 2;
+                break;
+            }
+
+            case TM_PATH_CMD_LINE:  /* line x y */
+            {
+                double x, y;
+
+                if( argc < 3 ) {
+                    Tcl_WrongNumArgs(interp, 1, argv, "x y");
+                    return TCL_ERROR;
+                }
+                if(    ((stat = Tcl_GetDoubleFromObj(interp, argv[1], &x )) != TCL_OK)
+                       || ((stat = Tcl_GetDoubleFromObj(interp, argv[2], &y )) != TCL_OK) )
+                {
+                    Tcl_AppendResult(interp, "Line arguments: x y", NULL);
+                    return stat;
+                }
+                relFlag
+                    ? DrawPathLineToRelative(wandPtr, x, y)
+                    : DrawPathLineToAbsolute(wandPtr, x, y);
+
+                argc -= 3, argv += 3;
+                break;
+            }
+
+            case TM_PATH_CMD_MOVE:  /* move {x y} */
+            {
+                double x, y;
+
+                if( argc < 3 ) {
+                    Tcl_WrongNumArgs(interp, 1, argv, "x y");
+                    return TCL_ERROR;
+                }
+                if(    ((stat = Tcl_GetDoubleFromObj(interp, argv[1], &x )) != TCL_OK)
+                       || ((stat = Tcl_GetDoubleFromObj(interp, argv[2], &y )) != TCL_OK) )
+                {
+                    Tcl_AppendResult(interp, "Line arguments: x y", NULL);
+                    return stat;
+                }
+                relFlag
+                    ? DrawPathMoveToRelative(wandPtr, x, y)
+                    : DrawPathMoveToAbsolute(wandPtr, x, y);
+
+                argc -= 3, argv += 3;
+                break;
+            }
+
+            case TM_PATH_CMD_QUADRATIC:     /* quadratic ?x1 y1? x y */
+            {
+                double x1, y1, x, y;
+
+                if( smoothFlag ) {
+                    /*
+                     * -smooth 1 quadratic x y
+                     */
+                    if( argc < 3 ) {
+                        Tcl_WrongNumArgs(interp, 1, argv, "x y");
+                        return TCL_ERROR;
+                    }
+                    if(    ((stat = Tcl_GetDoubleFromObj(interp, argv[1], &x )) != TCL_OK)
+                           || ((stat = Tcl_GetDoubleFromObj(interp, argv[2], &y )) != TCL_OK) )
+                    {
+                        Tcl_AppendResult(interp, "Smooth quadratic bezier curve arguments: x y", NULL);
+                        return stat;
+                    }
+                    relFlag
+                        ? DrawPathCurveToQuadraticBezierSmoothRelative(wandPtr, x, y)
+                        : DrawPathCurveToQuadraticBezierSmoothAbsolute(wandPtr, x, y);
+
+                    argc -= 3, argv += 3;
+                } else {
+                    /*
+                     * -smooth 0 quadratic x1 y1 x y
+                     */
+                    if( argc < 5 ) {
+                        Tcl_WrongNumArgs(interp, 1, argv, "x2 y2 x y");
+                        return TCL_ERROR;
+                    }
+                    if(    ((stat = Tcl_GetDoubleFromObj(interp, argv[1], &x1)) != TCL_OK)
+                           || ((stat = Tcl_GetDoubleFromObj(interp, argv[2], &y1)) != TCL_OK)
+                           || ((stat = Tcl_GetDoubleFromObj(interp, argv[3], &x )) != TCL_OK)
+                           || ((stat = Tcl_GetDoubleFromObj(interp, argv[4], &y )) != TCL_OK) )
+                    {
+                        Tcl_AppendResult(interp, "Quadratic bezier curve arguments: x1 y1 x y", NULL);
+                        return stat;
+                    }
+                    relFlag
+                        ? DrawPathCurveToQuadraticBezierRelative(wandPtr, x1, y1, x, y)
+                        : DrawPathCurveToQuadraticBezierAbsolute(wandPtr, x1, y1, x, y);
+
+                    argc -= 5, argv += 5;
+                }
+                break;
+            }
+
+            case TM_PATH_CMD_START:     /* start */
+                DrawPathStart(wandPtr);
+                argc -= 1, argv += 1;
+                break;
+
+            case TM_PATH_CMD_VERTICAL:  /* vertical {y} */
+            {
+                double y;
+
+                if( argc < 2 ) {
+                    Tcl_WrongNumArgs(interp, 1, argv, "y");
+                    return TCL_ERROR;
+                }
+                if( (stat = Tcl_GetDoubleFromObj(interp, argv[1], &y)) != TCL_OK) {
+                    Tcl_AppendResult(interp, "Horizonal line argument: y", NULL);
+                    return stat;
+                }
+                relFlag
+                    ? DrawPathLineToVerticalRelative(wandPtr, y)
+                    : DrawPathLineToVerticalAbsolute(wandPtr, y);
+
+                argc -= 2, argv += 2;
+                break;
+            }
+
+            } /* switch( path-cmd) */
+        }
+        break; /* path */
     }
 
     /*
@@ -8099,8 +8108,8 @@ static int drawObjCmd(
     case TM_END_OF_TABLE:
     default:
     {
-       Tcl_AppendResult(interp, "TclMagick drawObjCmd: Unmatched subcommand table entry", NULL);
-       return TCL_ERROR;
+        Tcl_AppendResult(interp, "TclMagick drawObjCmd: Unmatched subcommand table entry", NULL);
+        return TCL_ERROR;
     }
     } /* switch(index) */
 
@@ -8134,7 +8143,7 @@ EXPORT(int, Tclmagick_Init)(Tcl_Interp *interp)
 {
 #ifdef USE_TCL_STUBS
     if (Tcl_InitStubs(interp, "8", 0) == NULL) {
-       return TCL_ERROR;
+        return TCL_ERROR;
     }
 #endif
     /*
@@ -8142,14 +8151,14 @@ EXPORT(int, Tclmagick_Init)(Tcl_Interp *interp)
      */
     if ( ! TM.initialized ) {
         memset(&TM, 0, sizeof(TM));
-       
+
         /*
          * Create Exit handler, hash table
          */
         Tcl_CreateExitHandler(tmExitHandler,(int *) interp);
         Tcl_InitHashTable(&TM.hashTable, TCL_STRING_KEYS);
         InitializeMagick(Tcl_GetString(Tcl_FSGetCwd(interp)));
-       
+
         TM.initialized = 1;
     }
     /*
index 2abbe96..a01bad5 100644 (file)
@@ -19,12 +19,12 @@ enum objTypes {
 typedef struct {
     int             type;
     void            *wandPtr;  /* MagickWand, DrawingWand or PixelWand
-                               * pointer */
+                                * pointer */
     Tcl_Command     magickCmd; /* Token for magick command, used to
-                               * delete it */
+                                * delete it */
     Tcl_Interp      *interp;   /* Tcl interpreter owing the object */
     Tcl_HashEntry   *hashPtr;  /* Hash entry for this structure, used
-                               * to delete it */
+                                * to delete it */
 } TclMagickObj;
 
 #ifdef __WIN32__
index 8b1e80c..a20a3ac 100644 (file)
@@ -1,8 +1,8 @@
-/* 
+/*
  * tclAppInit.c --
  *
- *     Provides a default version of the main program and Tcl_AppInit
- *     procedure for Tcl applications (without Tk).
+ *      Provides a default version of the main program and Tcl_AppInit
+ *      procedure for Tcl applications (without Tk).
  *
  * Copyright (c) 1993 The Regents of the University of California.
  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 
 #include "tclInt.h"
 
-extern int             Procbodytest_Init _ANSI_ARGS_((Tcl_Interp *interp));
-extern int             Procbodytest_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
-extern int             TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
-extern int             Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
+extern int              Procbodytest_Init _ANSI_ARGS_((Tcl_Interp *interp));
+extern int              Procbodytest_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
+extern int              TclObjTest_Init _ANSI_ARGS_((Tcl_Interp *interp));
+extern int              Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
 #ifdef TCL_THREADS
-extern int             TclThread_Init _ANSI_ARGS_((Tcl_Interp *interp));
+extern int              TclThread_Init _ANSI_ARGS_((Tcl_Interp *interp));
 #endif
 
 #endif /* TCL_TEST */
 
 #ifdef TCL_XT_TEST
-extern void            XtToolkitInitialize _ANSI_ARGS_((void));
-extern int             Tclxttest_Init _ANSI_ARGS_((Tcl_Interp *interp));
+extern void             XtToolkitInitialize _ANSI_ARGS_((void));
+extern int              Tclxttest_Init _ANSI_ARGS_((Tcl_Interp *interp));
 #endif
 \f
 /*
@@ -42,22 +42,22 @@ extern int          Tclxttest_Init _ANSI_ARGS_((Tcl_Interp *interp));
  *
  * main --
  *
- *     This is the main program for the application.
+ *      This is the main program for the application.
  *
  * Results:
- *     None: Tcl_Main never returns here, so this procedure never
- *     returns either.
+ *      None: Tcl_Main never returns here, so this procedure never
+ *      returns either.
  *
  * Side effects:
- *     Whatever the application does.
+ *      Whatever the application does.
  *
  *----------------------------------------------------------------------
  */
 
 int
 main(argc, argv)
-    int argc;                  /* Number of command-line arguments. */
-    char **argv;               /* Values of command-line arguments. */
+    int argc;                   /* Number of command-line arguments. */
+    char **argv;                /* Values of command-line arguments. */
 {
     /*
      * The following #if block allows you to change the AppInit
@@ -67,7 +67,7 @@ main(argc, argv)
      */
 
 #ifndef TCL_LOCAL_APPINIT
-#define TCL_LOCAL_APPINIT Tcl_AppInit    
+#define TCL_LOCAL_APPINIT Tcl_AppInit
 #endif
     extern int TCL_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
 
@@ -91,7 +91,7 @@ main(argc, argv)
 
     Tcl_Main(argc, argv, TCL_LOCAL_APPINIT);
 
-    return 0;                  /* Needed only to prevent compiler warning. */
+    return 0;                   /* Needed only to prevent compiler warning. */
 }
 \f
 /*
@@ -99,49 +99,49 @@ main(argc, argv)
  *
  * TclMagick_AppInit --
  *
- *     This procedure performs application-specific initialization.
- *     Most applications, especially those that incorporate additional
- *     packages, will have their own version of this procedure.
+ *      This procedure performs application-specific initialization.
+ *      Most applications, especially those that incorporate additional
+ *      packages, will have their own version of this procedure.
  *
  * Results:
- *     Returns a standard Tcl completion code, and leaves an error
- *     message in the interp's result if an error occurs.
+ *      Returns a standard Tcl completion code, and leaves an error
+ *      message in the interp's result if an error occurs.
  *
  * Side effects:
- *     Depends on the startup script.
+ *      Depends on the startup script.
  *
  *----------------------------------------------------------------------
  */
 
 int
 TclMagick_AppInit(interp)
-    Tcl_Interp *interp;                /* Interpreter for application. */
+    Tcl_Interp *interp;         /* Interpreter for application. */
 {
     if (Tcl_Init(interp) == TCL_ERROR) {
-       return TCL_ERROR;
+        return TCL_ERROR;
     }
 
 #ifdef TCL_TEST
 #ifdef TCL_XT_TEST
      if (Tclxttest_Init(interp) == TCL_ERROR) {
-        return TCL_ERROR;
+         return TCL_ERROR;
      }
 #endif
     if (Tcltest_Init(interp) == TCL_ERROR) {
-       return TCL_ERROR;
+        return TCL_ERROR;
     }
     Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
             (Tcl_PackageInitProc *) NULL);
     if (TclObjTest_Init(interp) == TCL_ERROR) {
-       return TCL_ERROR;
+        return TCL_ERROR;
     }
 #ifdef TCL_THREADS
     if (TclThread_Init(interp) == TCL_ERROR) {
-       return TCL_ERROR;
+        return TCL_ERROR;
     }
 #endif
     if (Procbodytest_Init(interp) == TCL_ERROR) {
-       return TCL_ERROR;
+        return TCL_ERROR;
     }
     Tcl_StaticPackage(interp, "procbodytest", Procbodytest_Init,
             Procbodytest_SafeInit);
index ac8dcb3..2327735 100644 (file)
  *
  * MagickToPhoto --
  *
- *     Implements "magicktophoto".  Takes the name of a "magick wand"
- *     and a Tk image as arguments.  Both must already exist,
- *     although they don't necessarily have to contain anything.
+ *      Implements "magicktophoto".  Takes the name of a "magick wand"
+ *      and a Tk image as arguments.  Both must already exist,
+ *      although they don't necessarily have to contain anything.
  *
  * Results:
- *     A normal Tcl result.
+ *      A normal Tcl result.
  *
  * Side Effects:
- *     Sets the image photo size.
+ *      Sets the image photo size.
  *
  *-----------------------------------------------------------------------------
  */
@@ -52,15 +52,15 @@ static int MagickToPhoto(
     magickname = Tcl_GetStringFromObj(objv[1], NULL);
     tclmagick = findMagickObj(interp, TM_TYPE_WAND, magickname);
     if (tclmagick == NULL) {
-       return TCL_ERROR;
+        return TCL_ERROR;
     }
     wand = tclmagick->wandPtr;
 
     photoname = Tcl_GetStringFromObj(objv[2], NULL);
     photohandle = Tk_FindPhoto(interp, photoname);
     if (photohandle == NULL) {
-       Tcl_AppendResult(interp, "Not a photo image.", NULL);
-       return TCL_ERROR;
+        Tcl_AppendResult(interp, "Not a photo image.", NULL);
+        return TCL_ERROR;
     }
 
     /* pixelSize corresponds to "RGB" format below. */
@@ -68,8 +68,8 @@ static int MagickToPhoto(
     magickblock.width = MagickGetImageWidth (wand);
     magickblock.height = MagickGetImageHeight (wand);
     magickblock.pixelPtr = (unsigned char *) ckalloc((unsigned)magickblock.height *
-                                                    (unsigned)magickblock.width *
-                                                    magickblock.pixelSize);
+                                                     (unsigned)magickblock.width *
+                                                     magickblock.pixelSize);
     magickblock.pitch = magickblock.width * magickblock.pixelSize;
     magickblock.offset[0] = 0;
     magickblock.offset[1] = 1;
@@ -84,28 +84,28 @@ static int MagickToPhoto(
        required a different map.
     */
     if (strcmp(MagickPackageName, "ImageMagick") == 0) {
-       map = "RGBA";
+        map = "RGBA";
     } else {
-       map = "RGBO";
+        map = "RGBO";
     }
 #endif
 
     if (MagickGetImagePixels (
-           wand, 0, 0, (unsigned)magickblock.width, (unsigned)magickblock.height,
-           map, CharPixel, magickblock.pixelPtr) == False) {
-           return myMagickError(interp, wand);
+            wand, 0, 0, (unsigned)magickblock.width, (unsigned)magickblock.height,
+            map, CharPixel, magickblock.pixelPtr) == False) {
+            return myMagickError(interp, wand);
     }
 
 #if TCL_MAJOR_VERSION <= 8 && TCL_MINOR_VERSION <= 4
     Tk_PhotoPutBlock(photohandle, &magickblock, 0, 0,
-                    magickblock.width, magickblock.height,
-                    TK_PHOTO_COMPOSITE_SET);
+                     magickblock.width, magickblock.height,
+                     TK_PHOTO_COMPOSITE_SET);
 #else
     if (Tk_PhotoPutBlock(interp, photohandle, &magickblock,
-                        0, 0, magickblock.width, magickblock.height,
-                        TK_PHOTO_COMPOSITE_SET) != TCL_OK) {
+                         0, 0, magickblock.width, magickblock.height,
+                         TK_PHOTO_COMPOSITE_SET) != TCL_OK) {
         ckfree((char *) magickblock.pixelPtr);
-       return TCL_ERROR;
+        return TCL_ERROR;
     }
 #endif /* TCL_MAJOR_VERSION <= 8 && TCL_MINOR_VERSION <= 4 */
 
@@ -123,12 +123,12 @@ static int MagickToPhoto(
  *      the magick wand.
  *
  * Results:
- *     Normal Tcl result.
+ *      Normal Tcl result.
  *
  * Side Effects:
  *
- *     Erases the image that was previously in the magick wand, or
- *     creates a new one.
+ *      Erases the image that was previously in the magick wand, or
+ *      creates a new one.
  *
  *-----------------------------------------------------------------------------
  */
@@ -157,52 +157,52 @@ static int PhotoToMagick(
 
     photoname = Tcl_GetStringFromObj(objv[1], NULL);
     photohandle = Tk_FindPhoto(
-       interp, photoname);
+        interp, photoname);
     if (photohandle == NULL) {
-       Tcl_AppendResult(interp, "Not a photo image.", NULL);
-       return TCL_ERROR;
+        Tcl_AppendResult(interp, "Not a photo image.", NULL);
+        return TCL_ERROR;
     }
     Tk_PhotoGetImage(photohandle, &photoblock);
 
     magickname = Tcl_GetStringFromObj(objv[2], NULL);
     tclmagick = findMagickObj(interp, TM_TYPE_WAND, magickname);
     if (tclmagick == NULL) {
-       return TCL_ERROR;
+        return TCL_ERROR;
     }
     wand = tclmagick->wandPtr;
     MagickSetSize (wand, (unsigned)photoblock.width, (unsigned)photoblock.height);
     result = MagickReadImage(wand, "xc:white");
     if (!result) {
-       return myMagickError(interp, wand);
+        return myMagickError(interp, wand);
     }
 
     /* This could be improved some, but I don't know how Tk deals with
        'unusual' pixelSize's. */
     switch (photoblock.pixelSize) {
     case 3:
-       map[photoblock.offset[0]] = 'R';
-       map[photoblock.offset[1]] = 'G';
-       map[photoblock.offset[2]] = 'B';
-       break;
+        map[photoblock.offset[0]] = 'R';
+        map[photoblock.offset[1]] = 'G';
+        map[photoblock.offset[2]] = 'B';
+        break;
     case 4:
-       map[photoblock.offset[0]] = 'R';
-       map[photoblock.offset[1]] = 'G';
-       map[photoblock.offset[2]] = 'B';
-       if (strcmp(MagickPackageName, "ImageMagick") == 0) {
-           map[photoblock.offset[3]] = 'A';
-       } else {
-           map[photoblock.offset[3]] = 'O';
-       }
-       break;
+        map[photoblock.offset[0]] = 'R';
+        map[photoblock.offset[1]] = 'G';
+        map[photoblock.offset[2]] = 'B';
+        if (strcmp(MagickPackageName, "ImageMagick") == 0) {
+            map[photoblock.offset[3]] = 'A';
+        } else {
+            map[photoblock.offset[3]] = 'O';
+        }
+        break;
     default:
-       Tcl_AppendResult(interp, "Unsupported pixelSize in Tk image.", NULL);
-       return TCL_ERROR;
+        Tcl_AppendResult(interp, "Unsupported pixelSize in Tk image.", NULL);
+        return TCL_ERROR;
     };
 
-    if (MagickSetImagePixels (wand, 0, 0, (unsigned)photoblock.width, 
-                             (unsigned)photoblock.height,
-                             map, CharPixel, photoblock.pixelPtr) == False) {
-       return myMagickError(interp, wand);
+    if (MagickSetImagePixels (wand, 0, 0, (unsigned)photoblock.width,
+                              (unsigned)photoblock.height,
+                              map, CharPixel, photoblock.pixelPtr) == False) {
+        return myMagickError(interp, wand);
     }
 
     return TCL_OK;
@@ -213,15 +213,15 @@ static int PhotoToMagick(
  *
  * Tkmagick_Init --
  *
- *     Initialize this module.
+ *      Initialize this module.
  *
  * Results:
- *     Normal Tcl results.
+ *      Normal Tcl results.
  *
  * Side Effects:
  *
- *     Requires TclMagick module, creates magicktophoto and
- *     phototomagick commands.
+ *      Requires TclMagick module, creates magicktophoto and
+ *      phototomagick commands.
  *
  *-----------------------------------------------------------------------------
  */
@@ -230,12 +230,12 @@ EXPORT(int, Tkmagick_Init)(Tcl_Interp *interp)
 {
 #ifdef USE_TCL_STUBS
     if (Tcl_InitStubs(interp, "8", 0) == NULL) {
-       return TCL_ERROR;
+        return TCL_ERROR;
     }
 #endif
 #ifdef USE_TK_STUBS
     if (Tk_InitStubs(interp, "8", 0) == NULL) {
-       return TCL_ERROR;
+        return TCL_ERROR;
     }
 #endif
 
index b0a3475..9281a1f 100644 (file)
@@ -86,4 +86,3 @@ int myMagickError(Tcl_Interp  *interp, MagickWand *wandPtr )
 }
 
 /* vim: set ts=8 sts=8 sw=8 noet: */
-
index 90df929..db5fb74 100644 (file)
@@ -1291,4 +1291,5 @@ m4_include([m4/libtool.m4])
 m4_include([m4/ltoptions.m4])
 m4_include([m4/ltsugar.m4])
 m4_include([m4/ltversion.m4])
+m4_include([m4/pkg.m4])
 m4_include([acinclude.m4])
index 66da577..2672a67 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2004-2016 GraphicsMagick Group
+# Copyright (C) 2004-2018 GraphicsMagick Group
 #
 # This program is covered by multiple licenses, which are described in
 # Copyright.txt. You should have received a copy of Copyright.txt with this
@@ -346,7 +346,7 @@ coders_dps_la_LIBADD       = $(LIBMAGICK) $(LIB_DPS) $(LIB_XEXT) $(LIB_X11)
 coders_dpx_la_SOURCES      = coders/dpx.c
 coders_dpx_la_CPPFLAGS     = $(MAGICK_CODER_CPPFLAGS)
 coders_dpx_la_LDFLAGS      = $(MODULECOMMONFLAGS)
-coders_dpx_la_LIBADD       = $(LIBMAGICK) 
+coders_dpx_la_LIBADD       = $(LIBMAGICK)
 
 # EMF coder module
 coders_emf_la_SOURCES      = coders/emf.c
@@ -358,7 +358,7 @@ coders_emf_la_LIBADD       = $(LIBMAGICK) $(LIB_GDI32)
 coders_ept_la_SOURCES      = coders/ept.c
 coders_epd_la_CPPFLAGS     = $(MAGICK_CODER_CPPFLAGS)
 coders_ept_la_LDFLAGS      = $(MODULECOMMONFLAGS)
-coders_ept_la_LIBADD       = $(LIBMAGICK) $(LIB_GS) $(LIB_MATH)
+coders_ept_la_LIBADD       = $(LIBMAGICK) $(LIB_MATH)
 
 # FAX coder module
 coders_fax_la_SOURCES      = coders/fax.c
@@ -598,7 +598,7 @@ coders_pdb_la_LIBADD       = $(LIBMAGICK)
 coders_pdf_la_SOURCES      = coders/pdf.c
 coders_pdf_la_CPPFLAGS     = $(MAGICK_CODER_CPPFLAGS)
 coders_pdf_la_LDFLAGS      = $(MODULECOMMONFLAGS)
-coders_pdf_la_LIBADD       = $(LIBMAGICK) $(LIB_ZLIB) $(LIB_GS)
+coders_pdf_la_LIBADD       = $(LIBMAGICK) $(LIB_ZLIB)
 
 # PICT coder module
 coders_pict_la_SOURCES     = coders/pict.c
@@ -640,19 +640,19 @@ coders_preview_la_LIBADD   = $(LIBMAGICK)
 coders_ps_la_SOURCES       = coders/ps.c
 coders_ps_la_CPPFLAGS      = $(MAGICK_CODER_CPPFLAGS)
 coders_ps_la_LDFLAGS       = $(MODULECOMMONFLAGS)
-coders_ps_la_LIBADD        = $(LIBMAGICK) $(LIB_GS) $(LIB_MATH)
+coders_ps_la_LIBADD        = $(LIBMAGICK) $(LIB_MATH)
 
 # PS2 coder module
 coders_ps2_la_SOURCES      = coders/ps2.c
 coders_ps2_la_CPPFLAGS     = $(MAGICK_CODER_CPPFLAGS)
 coders_ps2_la_LDFLAGS      = $(MODULECOMMONFLAGS)
-coders_ps2_la_LIBADD       = $(LIBMAGICK) $(LIB_TIFF) $(LIB_JBIG) $(LIB_JPEG) $(LIB_LZMA) $(LIB_ZLIB) $(LIB_MATH)
+coders_ps2_la_LIBADD       = $(LIBMAGICK) $(LIB_TIFF) $(LIB_JBIG) $(LIB_JPEG) $(LIB_LZMA) $(LIB_WEBP) $(LIB_ZLIB) $(LIB_ZSTD) $(LIB_MATH)
 
 # PS3 coder module
 coders_ps3_la_SOURCES      = coders/ps3.c
 coders_ps3_la_CPPFLAGS     = $(MAGICK_CODER_CPPFLAGS)
 coders_ps3_la_LDFLAGS      = $(MODULECOMMONFLAGS)
-coders_ps3_la_LIBADD       = $(LIBMAGICK) $(LIB_TIFF) $(LIB_JBIG) $(LIB_JPEG) $(LIB_LZMA) $(LIB_ZLIB) $(LIB_MATH)
+coders_ps3_la_LIBADD       = $(LIBMAGICK) $(LIB_TIFF) $(LIB_JBIG) $(LIB_JPEG) $(LIB_LZMA) $(LIB_WEBP) $(LIB_ZLIB) $(LIB_ZSTD) $(LIB_MATH)
 
 # PSD coder module
 coders_psd_la_SOURCES      = coders/psd.c
@@ -730,7 +730,7 @@ coders_tga_la_LIBADD       = $(LIBMAGICK)
 coders_tiff_la_SOURCES     = coders/tiff.c
 coders_tiff_la_CPPFLAGS    = $(MAGICK_CODER_CPPFLAGS)
 coders_tiff_la_LDFLAGS     = $(MODULECOMMONFLAGS)
-coders_tiff_la_LIBADD      = $(LIBMAGICK) $(LIB_TIFF) $(LIB_JBIG) $(LIB_JPEG) $(LIB_LZMA) $(LIB_ZLIB) $(LIB_MATH)
+coders_tiff_la_LIBADD      = $(LIBMAGICK) $(LIB_TIFF) $(LIB_JBIG) $(LIB_JPEG) $(LIB_LZMA) $(LIB_WEBP) $(LIB_ZLIB) $(LIB_ZSTD) $(LIB_MATH)
 
 # TILE coder module
 coders_tile_la_SOURCES     = coders/tile.c
index 43d2774..ee745ed 100644 (file)
@@ -116,7 +116,7 @@ static Image *ReadARTImage(const ImageInfo *image_info,ExceptionInfo *exception)
     ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
   image->depth=1;
   image->colors=1l << image->depth;
+
   /* printf("ART header checked OK %d,%d\n",image->colors,image->depth); */
 
   if (!AllocateImageColormap(image,image->colors)) goto NoMemory;
@@ -163,7 +163,7 @@ static Image *ReadARTImage(const ImageInfo *image_info,ExceptionInfo *exception)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  Function WriteARTImage writes an ART image to a file.  
+%  Function WriteARTImage writes an ART image to a file.
 %
 %  The format of the WriteARTImage method is:
 %
@@ -203,7 +203,7 @@ static MagickPassFail WriteARTImage(const ImageInfo *image_info,Image *image)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
 
   DataSize = (long)((image->columns+7) / 8);
-  Padding = (unsigned char)((-(long) DataSize) & 0x01);  
+  Padding = (unsigned char)((-(long) DataSize) & 0x01);
 
   pixels=MagickAllocateMemory(unsigned char *,(size_t) (DataSize));
   if (pixels == (unsigned char *) NULL)
@@ -223,25 +223,25 @@ static MagickPassFail WriteARTImage(const ImageInfo *image_info,Image *image)
   for(y=0; y<(long)image->rows; y++)
   {
     if (AcquireImagePixels(image,0,y,image->columns,1,&image->exception)
-       == (const PixelPacket *) NULL)
+        == (const PixelPacket *) NULL)
       {
-       status=MagickFail;
-       break;
+        status=MagickFail;
+        break;
       }
     if (ExportImagePixelArea(image,GrayQuantum,1,pixels,0,0) != MagickPass)
       {
-       status=MagickFail;
-       break;
+        status=MagickFail;
+        break;
       }
     if (WriteBlob(image,DataSize,pixels) != DataSize)
       {
-       status=MagickFail;
-       break;
+        status=MagickFail;
+        break;
       }
     if (WriteBlob(image,Padding,(char *)&dummy) != Padding)
       {
-       status=MagickFail;
-       break;
+        status=MagickFail;
+        break;
       }
   }
 
@@ -250,7 +250,7 @@ static MagickPassFail WriteARTImage(const ImageInfo *image_info,Image *image)
 
   if (logging)
     (void)LogMagickEvent(CoderEvent,GetMagickModule(),"return ART");
-  
+
   return(status);
 }
 
index 32bf2b2..ba32404 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -83,6 +83,11 @@ static unsigned int
 */
 #define AVS_WIDTH_LIMIT 65536UL  /* Artificially limit width to 64K pixels */
 #define AVS_HEIGHT_LIMIT 65536UL /* Artificially limit height to 64K pixels */
+#define ThrowAVSReaderException(code_,reason_,image_)   \
+  {                                                     \
+    MagickFreeMemory(pixels);                           \
+    ThrowReaderException(code_,reason_,image_);         \
+  }
 static Image *ReadAVSImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
   Image
@@ -101,7 +106,7 @@ static Image *ReadAVSImage(const ImageInfo *image_info,ExceptionInfo *exception)
     *p;
 
   unsigned char
-    *pixels;
+    *pixels = (unsigned char *) NULL;
 
   unsigned int
     status;
@@ -127,7 +132,7 @@ static Image *ReadAVSImage(const ImageInfo *image_info,ExceptionInfo *exception)
   width=ReadBlobMSBLong(image);
   height=ReadBlobMSBLong(image);
   if (EOFBlob(image))
-    ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+    ThrowAVSReaderException(CorruptImageError,UnexpectedEndOfFile,image);
 
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                         "AVS dimensions %ldx%ld",width,height);
@@ -137,7 +142,7 @@ static Image *ReadAVSImage(const ImageInfo *image_info,ExceptionInfo *exception)
     incredibly huge allocations.
   */
   if ((width > AVS_WIDTH_LIMIT) || (height > AVS_HEIGHT_LIMIT))
-    ThrowReaderException(CoderError,ImageColumnOrRowSizeIsNotSupported,image);
+    ThrowAVSReaderException(CoderError,ImageColumnOrRowSizeIsNotSupported,image);
 
   do
   {
@@ -154,19 +159,15 @@ static Image *ReadAVSImage(const ImageInfo *image_info,ExceptionInfo *exception)
       if (image->scene >= (image_info->subimage+image_info->subrange-1))
         break;
     if (CheckImagePixelLimits(image, exception) != MagickPass)
-      ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+      ThrowAVSReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
     pixels=MagickAllocateArray(unsigned char *,image->columns,4);
     if (pixels == (unsigned char *) NULL)
-      ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+      ThrowAVSReaderException(ResourceLimitError,MemoryAllocationFailed,image);
     row_bytes=4*image->columns;
     for (y=0; y < (long) image->rows; y++)
     {
       if (ReadBlob(image,row_bytes,pixels) != row_bytes)
-        {
-          ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
-                         image->filename);
-          status=MagickFail;
-        }
+        ThrowAVSReaderException(CorruptImageError,UnexpectedEndOfFile,image);
       p=pixels;
       q=SetImagePixels(image,0,y,image->columns,1);
       if (q == (PixelPacket *) NULL)
@@ -192,13 +193,11 @@ static Image *ReadAVSImage(const ImageInfo *image_info,ExceptionInfo *exception)
         if (QuantumTick(y,image->rows))
           if (!MagickMonitorFormatted(y,image->rows,exception,
                                       LoadImageText,image->filename,
-                                     image->columns,image->rows))
+                                      image->columns,image->rows))
             {
               status=MagickFail;
               break;
             }
-      if (MagickFail == status)
-        break;
     }
     MagickFreeMemory(pixels);
 
@@ -356,6 +355,9 @@ static unsigned int WriteAVSImage(const ImageInfo *image_info,Image *image)
   unsigned long
     scene;
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -363,6 +365,7 @@ static unsigned int WriteAVSImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -404,14 +407,14 @@ static unsigned int WriteAVSImage(const ImageInfo *image_info,Image *image)
         if (QuantumTick(y,image->rows))
           if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                       SaveImageText,image->filename,
-                                     image->columns,image->rows))
+                                      image->columns,image->rows))
             break;
     }
     MagickFreeMemory(pixels);
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene++,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename);
     if (status == False)
index 2f4f207..5a7bf82 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
 */
 typedef struct _BMPInfo
 {
-  unsigned long
-    file_size,
+  size_t
+    file_size,  /* 0 or size of file in bytes */
+    image_size; /* bytes_per_line*image->rows or uint32_t from file */
+
+  magick_uint32_t
     ba_offset,
-    offset_bits,
-    size;
+    offset_bits,/* Starting position of image data in bytes */
+    size;       /* Header size 12 = v2, 12-64 OS/2 v2, 40 = v3, 108 = v4, 124 = v5 */
 
-  long
-    width,
-    height;
+  magick_int32_t
+    width,      /* BMP width */
+    height;     /* BMP height (negative means bottom-up) */
 
-  unsigned short
+  magick_uint16_t
     planes,
     bits_per_pixel;
 
-  unsigned long
+  magick_uint32_t
     compression,
-    image_size,
     x_pixels,
     y_pixels,
     number_colors,
+    colors_important;
+
+  magick_uint32_t
     red_mask,
     green_mask,
     blue_mask,
-    alpha_mask,
-    colors_important;
+    alpha_mask;
 
-  long
+  magick_int32_t
     colorspace;
 
   PrimaryInfo
@@ -168,19 +172,22 @@ static unsigned int
 %    o pixels:  The address of a byte (8 bits) array of pixel data created by
 %      the decoding process.
 %
+%    o pixels_size: The size of the allocated buffer array.
 %
 */
 static MagickPassFail DecodeImage(Image *image,const unsigned long compression,
-  unsigned char *pixels)
+                                  unsigned char *pixels, const size_t pixels_size)
 {
-  long
-    byte,
-    count,
+  unsigned long
+    x,
     y;
 
-  register long
-    i,
-    x;
+  unsigned int
+    i;
+
+  int
+    byte,
+    count;
 
   register unsigned char
     *q;
@@ -190,133 +197,175 @@ static MagickPassFail DecodeImage(Image *image,const unsigned long compression,
 
   assert(image != (Image *) NULL);
   assert(pixels != (unsigned char *) NULL);
-  (void) LogMagickEvent(CoderEvent,GetMagickModule(),"  Decoding RLE pixels");
-  (void) memset(pixels,0,image->columns*image->rows);
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "  Decoding RLE compressed pixels to"
+                          " %" MAGICK_SIZE_T_F "u bytes",
+                          image->rows*image->columns);
+
+  (void) memset(pixels,0,pixels_size);
   byte=0;
   x=0;
   q=pixels;
-  end=pixels + (size_t) image->columns*image->rows;
-  for (y=0; y < (long) image->rows; )
-  {
-    if (q < pixels || q  >= end)
-      break;
-    count=ReadBlobByte(image);
-    if (count == EOF)
-      return MagickFail;
-    if (count != 0)
-      {
-        count=Min(count, end - q);
-        /*
-          Encoded mode.
-        */
-        byte=ReadBlobByte(image);
-        if (byte == EOF)
-          return MagickFail;
-        if (compression == BI_RLE8)
-          {
-            for ( i=count; i != 0; --i )
+  end=pixels + pixels_size;
+  /*
+    Decompress sufficient data to support the number of pixels (or
+    rows) in the image and then return.
+
+    Do not wait to read the final EOL and EOI markers (if not yet
+    encountered) since we always read this marker just before we
+    return.
+  */
+  for (y=0; y < image->rows; )
+    {
+      if (q < pixels || q >= end)
+        {
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "  Decode buffer full (y=%lu, "
+                                  "pixels_size=%" MAGICK_SIZE_T_F "u, "
+                                  "pixels=%p, q=%p, end=%p)",
+                                  y, (MAGICK_SIZE_T) pixels_size, pixels, q, end);
+          break;
+        }
+      count=ReadBlobByte(image);
+      if (count == EOF)
+        return MagickFail;
+      if (count > 0)
+        {
+          count=Min(count, end - q);
+          /*
+            Encoded mode.
+          */
+          byte=ReadBlobByte(image);
+          if (byte == EOF)
+            return MagickFail;
+          if (compression == BI_RLE8)
+            {
+              for ( i=count; i != 0; --i )
+                {
+                  *q++=(unsigned char) byte;
+                }
+            }
+          else
+            {
+              for ( i=0; i < (unsigned int) count; i++ )
+                {
+                  *q++=(unsigned char)
+                    ((i & 0x01) ? (byte & 0x0f) : ((byte >> 4) & 0x0f));
+                }
+            }
+          x+=count;
+        }
+      else
+        {
+          /*
+            Escape mode.
+          */
+          count=ReadBlobByte(image);
+          if (count == EOF)
+            return MagickFail;
+          if (count == 0x01)
+            {
+              if (image->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "  RLE Escape code encountered");
+              goto rle_decode_done;
+            }
+          switch (count)
+            {
+            case 0x00:
               {
-                *q++=(unsigned char) byte;
+                /*
+                  End of line.
+                */
+                x=0;
+                y++;
+                q=pixels+y*image->columns;
+                break;
               }
-          }
-        else
-          {
-            for ( i=0; i < count; i++ )
+            case 0x02:
               {
-                *q++=(unsigned char)
-                  ((i & 0x01) ? (byte & 0x0f) : ((byte >> 4) & 0x0f));
+                /*
+                  Delta mode.
+                */
+                byte=ReadBlobByte(image);
+                if (byte == EOF)
+                  return MagickFail;
+                x+=byte;
+                byte=ReadBlobByte(image);
+                if (byte == EOF)
+                  return MagickFail;
+                y+=byte;
+                q=pixels+y*image->columns+x;
+                break;
               }
-          }
-        x+=count;
-      }
-    else
-      {
-        /*
-          Escape mode.
-        */
-        count=ReadBlobByte(image);
-        if (count == EOF)
-          return MagickFail;
-        if (count == 0x01)
-          return(MagickPass);
-        switch ((int) count)
-        {
-          case 0x00:
-          {
-            /*
-              End of line.
-            */
-            x=0;
-            y++;
-            q=pixels+y*image->columns;
-            break;
-          }
-          case 0x02:
-          {
-            /*
-              Delta mode.
-            */
-            byte=ReadBlobByte(image);
-            if (byte == EOF)
-              return MagickFail;
-            x+=byte;
-            byte=ReadBlobByte(image);
-            if (byte == EOF)
-              return MagickFail;
-            y+=byte;
-            q=pixels+y*image->columns+x;
-            break;
-          }
-          default:
-          {
-            /*
-              Absolute mode.
-            */
-           count=Min(count, end - q);
-            if (compression == BI_RLE8)
-              for (i=count; i != 0; --i)
-                {
-                  byte=ReadBlobByte(image);
-                  if (byte == EOF)
-                    return MagickFail;
-                  *q++=byte;
-                }
-            else
-              for (i=0; i < count; i++)
+            default:
               {
-                if ((i & 0x01) == 0)
+                /*
+                  Absolute mode.
+                */
+                count=Min(count, end - q);
+                if (count < 0)
+                  return MagickFail;
+                if (compression == BI_RLE8)
+                  for (i=count; i != 0; --i)
+                    {
+                      byte=ReadBlobByte(image);
+                      if (byte == EOF)
+                        return MagickFail;
+                      *q++=byte;
+                    }
+                else
+                  for (i=0; i < (unsigned int) count; i++)
+                    {
+                      if ((i & 0x01) == 0)
+                        {
+                          byte=ReadBlobByte(image);
+                          if (byte == EOF)
+                            return MagickFail;
+                        }
+                      *q++=(unsigned char)
+                        ((i & 0x01) ? (byte & 0x0f) : ((byte >> 4) & 0x0f));
+                    }
+                x+=count;
+                /*
+                  Read pad byte.
+                */
+                if (compression == BI_RLE8)
                   {
-                    byte=ReadBlobByte(image);
-                    if (byte == EOF)
-                      return MagickFail;
+                    if (count & 0x01)
+                      if (ReadBlobByte(image) == EOF)
+                        return MagickFail;
                   }
-                *q++=(unsigned char)
-                  ((i & 0x01) ? (byte & 0x0f) : ((byte >> 4) & 0x0f));
-              }
-            x+=count;
-            /*
-              Read pad byte.
-            */
-            if (compression == BI_RLE8)
-              {
-                if (count & 0x01)
-                  (void) ReadBlobByte(image);
+                else
+                  if (((count & 0x03) == 1) || ((count & 0x03) == 2))
+                    if (ReadBlobByte(image) == EOF)
+                      return MagickFail;
+                break;
               }
-            else
-              if (((count & 0x03) == 1) || ((count & 0x03) == 2))
-                (void) ReadBlobByte(image);
-            break;
-          }
+            }
         }
-      }
-    if (QuantumTick(y,image->rows))
-      if (!MagickMonitorFormatted(y,image->rows,&image->exception,
-                                  LoadImageText,image->filename,
-                                 image->columns,image->rows))
-        break;
-  }
+      if (QuantumTick(y,image->rows))
+        if (!MagickMonitorFormatted(y,image->rows,&image->exception,
+                                    LoadImageText,image->filename,
+                                    image->columns,image->rows))
+          break;
+    }
   (void) ReadBlobByte(image);  /* end of line */
   (void) ReadBlobByte(image);
+ rle_decode_done:
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "  Decoded %" MAGICK_SIZE_T_F "u bytes",
+                          (MAGICK_SIZE_T) (q-pixels));
+  if ((MAGICK_SIZE_T) (q-pixels) < pixels_size)
+    {
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "  RLE decoded output is truncated");
+      return MagickFail;
+    }
   return(MagickPass);
 }
 \f
@@ -403,7 +452,7 @@ static size_t EncodeImage(Image *image,const unsigned long bytes_per_line,
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                   SaveImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   /*
@@ -510,7 +559,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
   long
     y;
 
-  unsigned long
+  magick_uint32_t
     blue,
     green,
     opacity,
@@ -532,8 +581,10 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
     *p;
 
   size_t
+    bytes_per_line,
     count,
-    length;
+    length,
+    pixels_size;
 
   unsigned char
     *bmp_colormap,
@@ -543,11 +594,10 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
   unsigned int
     status;
 
-  unsigned long
-    bytes_per_line;
-
   magick_off_t
-    file_size;
+    file_remaining,
+    file_size,
+    offset;
 
   /*
     Open image file.
@@ -570,6 +620,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
   (void) memset(&bmp_info,0,sizeof(BMPInfo));
   bmp_info.ba_offset=0;
   start_position=0;
+  magick[0]=magick[1]=0;
   count=ReadBlob(image,2,(char *) magick);
   do
   {
@@ -584,9 +635,10 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
     /*
       Verify BMP identifier.
     */
-    if (bmp_info.ba_offset == 0)
-      start_position=TellBlob(image)-2;
+    /* if (bmp_info.ba_offset == 0) */ /* FIXME: Investigate. Start position needs to always advance! */
+    start_position=TellBlob(image)-2;
     bmp_info.ba_offset=0;
+     /* "BA" is OS/2 bitmap array file */
     while (LocaleNCompare((char *) magick,"BA",2) == 0)
     {
       bmp_info.file_size=ReadBlobLSBLong(image);
@@ -595,29 +647,49 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
       if ((count=ReadBlob(image,2,(char *) magick)) != 2)
         break;
     }
-    if (logging)
+    if (logging && count == 2)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"  Magick: %c%c",
         magick[0],magick[1]);
-    if ((count != 2) || ((LocaleNCompare((char *) magick,"BM",2) != 0) &&
-        (LocaleNCompare((char *) magick,"CI",2) != 0)))
+    if ((count != 2) || /* Found "BA" header from above above */
+        ((LocaleNCompare((char *) magick,"BM",2) != 0) && /* "BM" is Windows or OS/2 file. */
+         (LocaleNCompare((char *) magick,"CI",2) != 0)))  /* "CI" is OS/2 Color Icon */
       ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image);
-    bmp_info.file_size=ReadBlobLSBLong(image);
-    (void) ReadBlobLSBLong(image);
-    bmp_info.offset_bits=ReadBlobLSBLong(image);
-    bmp_info.size=ReadBlobLSBLong(image);
+    bmp_info.file_size=ReadBlobLSBLong(image); /* File size in bytes */
+    if (logging)
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "  File size: Claimed=%" MAGICK_SIZE_T_F "u, Actual=%"
+                            MAGICK_OFF_F "d",
+                            (MAGICK_SIZE_T) bmp_info.file_size, file_size);
+    (void) ReadBlobLSBLong(image); /* Reserved */
+    bmp_info.offset_bits=ReadBlobLSBLong(image); /* Bit map offset from start of file */
+    bmp_info.size=ReadBlobLSBLong(image);  /* BMP Header size */
     if (logging)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-        "  BMP size: %lu, File size: %" MAGICK_OFF_F "u",
-        bmp_info.size, GetBlobSize(image));
+                            "  Header size: %u\n"
+                            "    Offset bits: %u\n"
+                            "    Image data offset: %u",
+                            bmp_info.size,
+                            bmp_info.offset_bits,
+                            bmp_info.ba_offset);
+
+    if ((bmp_info.file_size != 0) && ((magick_off_t) bmp_info.file_size > file_size))
+      ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image);
+    if ((bmp_info.size != 12) && (bmp_info.size != 40) && (bmp_info.size != 108)
+        && (bmp_info.size != 124) &&
+        (!(bmp_info.size >= 12 && bmp_info.size <= 64)))
+      ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image);
+    if (bmp_info.offset_bits < bmp_info.size)
+      ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image);
+
     if (bmp_info.size == 12)
       {
         /*
           Windows 2.X or OS/2 BMP image file.
         */
-        bmp_info.width=(magick_int16_t) ReadBlobLSBShort(image);
-        bmp_info.height=(magick_int16_t) ReadBlobLSBShort(image);
-        bmp_info.planes=ReadBlobLSBShort(image);
-        bmp_info.bits_per_pixel=ReadBlobLSBShort(image);
+        bmp_info.width=(magick_int16_t) ReadBlobLSBShort(image); /* Width */
+        bmp_info.height=(magick_int16_t) ReadBlobLSBShort(image); /* Height */
+        bmp_info.planes=ReadBlobLSBShort(image); /* # of color planes */
+        bmp_info.bits_per_pixel=ReadBlobLSBShort(image); /* Bits per pixel */
         bmp_info.x_pixels=0;
         bmp_info.y_pixels=0;
         bmp_info.number_colors=0;
@@ -629,11 +701,11 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
               "  Format: Windows 2.X or OS/2 Bitmap");
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-              "  Geometry: %ldx%ld",bmp_info.width,bmp_info.height);
+              "  Geometry: %dx%d",bmp_info.width,bmp_info.height);
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-              "  Planes: %d",bmp_info.planes);
+              "  Planes: %u",bmp_info.planes);
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-              "  Bits per pixel: %d",bmp_info.bits_per_pixel);
+              "  Bits per pixel: %u",bmp_info.bits_per_pixel);
           }
       }
     else
@@ -653,16 +725,16 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
           origin in the upper-left corner.  The meaning of negative values
           is not defined for width.
         */
-        bmp_info.width=(magick_int32_t) ReadBlobLSBLong(image);
-        bmp_info.height=(magick_int32_t) ReadBlobLSBLong(image);
-        bmp_info.planes=ReadBlobLSBShort(image);
-        bmp_info.bits_per_pixel=ReadBlobLSBShort(image);
-        bmp_info.compression=ReadBlobLSBLong(image);
-        bmp_info.image_size=ReadBlobLSBLong(image);
-        bmp_info.x_pixels=ReadBlobLSBLong(image);
-        bmp_info.y_pixels=ReadBlobLSBLong(image);
-        bmp_info.number_colors=ReadBlobLSBLong(image);
-        bmp_info.colors_important=ReadBlobLSBLong(image);
+        bmp_info.width=(magick_int32_t) ReadBlobLSBLong(image); /* Width */
+        bmp_info.height=(magick_int32_t) ReadBlobLSBLong(image); /* Height */
+        bmp_info.planes=ReadBlobLSBShort(image); /* # of color planes */
+        bmp_info.bits_per_pixel=ReadBlobLSBShort(image); /* Bits per pixel (1/4/8/16/24/32) */
+        bmp_info.compression=ReadBlobLSBLong(image); /* Compression method */
+        bmp_info.image_size=ReadBlobLSBLong(image); /* Bitmap size (bytes) */
+        bmp_info.x_pixels=ReadBlobLSBLong(image); /* Horizontal resolution (pixels/meter) */
+        bmp_info.y_pixels=ReadBlobLSBLong(image); /* Vertical resolution (pixels/meter) */
+        bmp_info.number_colors=ReadBlobLSBLong(image); /* Number of colors */
+        bmp_info.colors_important=ReadBlobLSBLong(image); /* Minimum important colors */
         profile_data=0;
         profile_size=0;
         if (logging)
@@ -670,11 +742,11 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
               "  Format: MS Windows bitmap 3.X");
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-              "  Geometry: %ldx%ld",bmp_info.width,bmp_info.height);
+              "  Geometry: %dx%d",bmp_info.width,bmp_info.height);
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-              "  Planes: %d",bmp_info.planes);
+              "  Planes: %u",bmp_info.planes);
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-              "  Bits per pixel: %d",bmp_info.bits_per_pixel);
+              "  Bits per pixel: %u",bmp_info.bits_per_pixel);
             switch ((int) bmp_info.compression)
             {
               case BI_RGB:
@@ -719,13 +791,13 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
               default:
               {
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                  "  Compression: UNKNOWN (%lu)",bmp_info.compression);
+                  "  Compression: UNKNOWN (%u)",bmp_info.compression);
               }
             }
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-              "  Number of colors: %lu",bmp_info.number_colors);
+              "  Number of colors: %u",bmp_info.number_colors);
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-              "  Important colors: %lu",bmp_info.colors_important);
+              "  Important colors: %u",bmp_info.colors_important);
           }
 
         bmp_info.red_mask=ReadBlobLSBLong(image);
@@ -741,7 +813,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
               Read color management information.
             */
             bmp_info.alpha_mask=ReadBlobLSBLong(image);
-            bmp_info.colorspace=(long) ReadBlobLSBLong(image);
+            bmp_info.colorspace=(magick_int32_t) ReadBlobLSBLong(image);
             /*
               Decode 2^30 fixed point formatted CIE primaries.
             */
@@ -766,6 +838,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
             sum=bmp_info.red_primary.x+bmp_info.red_primary.y+
               bmp_info.red_primary.z;
+            sum=Max(MagickEpsilon,sum);
             bmp_info.red_primary.x/=sum;
             bmp_info.red_primary.y/=sum;
             image->chromaticity.red_primary.x=bmp_info.red_primary.x;
@@ -773,6 +846,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
             sum=bmp_info.green_primary.x+bmp_info.green_primary.y+
               bmp_info.green_primary.z;
+            sum=Max(MagickEpsilon,sum);
             bmp_info.green_primary.x/=sum;
             bmp_info.green_primary.y/=sum;
             image->chromaticity.green_primary.x=bmp_info.green_primary.x;
@@ -780,6 +854,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
             sum=bmp_info.blue_primary.x+bmp_info.blue_primary.y+
               bmp_info.blue_primary.z;
+            sum=Max(MagickEpsilon,sum);
             bmp_info.blue_primary.x/=sum;
             bmp_info.blue_primary.y/=sum;
             image->chromaticity.blue_primary.x=bmp_info.blue_primary.x;
@@ -831,29 +906,34 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
             }
             profile_data=ReadBlobLSBLong(image);
             profile_size=ReadBlobLSBLong(image);
-           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                 "  Profile: size %lu data %lu",
-                                 profile_size,profile_data);
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "  Profile: size %lu data %lu",
+                                  profile_size,profile_data);
             (void) ReadBlobLSBLong(image);  /* Reserved byte */
           }
       }
 
     if (logging)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                            "File size: Claimed=%lu, Actual=%"
+                            "  File size: Claimed=%" MAGICK_SIZE_T_F "u, Actual=%"
                             MAGICK_OFF_F "d",
-                            bmp_info.file_size, file_size);
-    if ((magick_off_t) bmp_info.file_size > file_size)
+                            (MAGICK_SIZE_T) bmp_info.file_size, file_size);
+    /*
+      It seems that some BMPs claim a file size two bytes larger than
+      they actually are so allow some slop before warning about file
+      size.
+    */
+    if ((magick_off_t) bmp_info.file_size > file_size+2)
       {
         ThrowException(exception,CorruptImageWarning,
                        LengthAndFilesizeDoNotMatch,image->filename);
       }
     if (logging && (magick_off_t) bmp_info.file_size < file_size)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                              "Discarding all data beyond bmp_info.file_size");
+                              "  Discarding all data beyond bmp_info.file_size");
     if (bmp_info.width <= 0)
       ThrowBMPReaderException(CorruptImageError,NegativeOrZeroImageSize,image);
-    if (bmp_info.height == 0)
+    if ((bmp_info.height) == 0 || (bmp_info.height < -2147483647))
       ThrowBMPReaderException(CorruptImageError,NegativeOrZeroImageSize,image);
     if ((bmp_info.height < 0) && (bmp_info.compression !=0))
       ThrowBMPReaderException(CorruptImageError,CompressionNotValid,image);
@@ -932,10 +1012,16 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
           packet_size=3;
         else
           packet_size=4;
-        if (SeekBlob(image,start_position+14+bmp_info.size,SEEK_SET) == -1)
-         ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image);
+        offset=start_position+14+bmp_info.size;
+        if (logging)
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Seek offset %" MAGICK_OFF_F "d",
+                                (magick_off_t) offset);
+        if ((offset < start_position) ||
+            (SeekBlob(image,offset,SEEK_SET) != (magick_off_t) offset))
+          ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image);
         if (ReadBlob(image,packet_size*image->colors,(char *) bmp_colormap)
-            != packet_size*image->colors)
+            != (size_t) packet_size*image->colors)
           ThrowBMPReaderException(CorruptImageError,UnexpectedEndOfFile,image);
         p=bmp_colormap;
         for (i=0; i < (long) image->colors; i++)
@@ -961,20 +1047,34 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
     /*
       Read image data.
     */
-    if (SeekBlob(image,start_position+bmp_info.offset_bits,SEEK_SET) == -1)
-      ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image)
+    if (logging)
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "start_position %" MAGICK_OFF_F "d,"
+                            " bmp_info.offset_bits %" MAGICK_OFF_F "d,"
+                            " bmp_info.ba_offset %" MAGICK_OFF_F "d" ,
+                            (magick_off_t) start_position,
+                            (magick_off_t) bmp_info.offset_bits,
+                            (magick_off_t) bmp_info.ba_offset);
+    offset=start_position+bmp_info.offset_bits;
+    if (logging)
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "Seek offset %" MAGICK_OFF_F "d",
+                            (magick_off_t) offset);
+    if ((offset < start_position) ||
+        (SeekBlob(image,offset,SEEK_SET) != (magick_off_t) offset))
+      ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image);
     if (bmp_info.compression == BI_RLE4)
       bmp_info.bits_per_pixel<<=1;
     bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)/32);
     if (logging)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                            "Bytes per line: %" MAGICK_SIZE_T_F "u",
+                            "  Bytes per line: %" MAGICK_SIZE_T_F "u",
                             (MAGICK_SIZE_T) bytes_per_line);
 
-    length=bytes_per_line*image->rows;
+    length=MagickArraySize(bytes_per_line,image->rows);
     if (logging)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                            "Expected total raster length: %" MAGICK_SIZE_T_F "u",
+                            "  Expected total raster length: %" MAGICK_SIZE_T_F "u",
                             (MAGICK_SIZE_T) length);
     if (length/image->rows != bytes_per_line)
       ThrowBMPReaderException(ResourceLimitError,MemoryAllocationFailed,image);
@@ -989,7 +1089,8 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
         /*
           Not compressed.
         */
-        if (length >= (size_t) file_size)
+        file_remaining=file_size-TellBlob(image);
+        if (file_remaining < (magick_off_t) length)
           ThrowBMPReaderException(CorruptImageError,InsufficientImageDataInFile,
                                   image);
       }
@@ -997,14 +1098,15 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
              (bmp_info.compression == BI_RLE8))
       {
         /* RLE Compressed.  Assume a maximum compression ratio. */
-        if ((file_size == 0) || (((double) length/file_size) > 254.0))
+        file_remaining=file_size-TellBlob(image);
+        if ((file_remaining <= 0) || (((double) length/file_remaining) > 254.0))
           ThrowBMPReaderException(CorruptImageError,InsufficientImageDataInFile,
                                   image);
       }
 
-    pixels=MagickAllocateArray(unsigned char *,
-                               Max(bytes_per_line,image->columns+1),
-                               image->rows);
+    pixels_size=MagickArraySize(Max(bytes_per_line,image->columns+1),
+                                image->rows);
+    pixels=MagickAllocateMemory(unsigned char *, pixels_size);
     if (pixels == (unsigned char *) NULL)
       ThrowBMPReaderException(ResourceLimitError,MemoryAllocationFailed,image);
     if ((bmp_info.compression == BI_RGB) ||
@@ -1014,14 +1116,18 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
             "  Reading pixels (%" MAGICK_SIZE_T_F "u bytes)",
                                 (MAGICK_SIZE_T) length);
-        (void) ReadBlob(image,length,(char *) pixels);
+        if (ReadBlob(image,length,(char *) pixels) != (size_t) length)
+          ThrowBMPReaderException(CorruptImageError,UnexpectedEndOfFile,image);
       }
     else
       {
         /*
           Convert run-length encoded raster pixels.
+
+          DecodeImage() normally decompresses to rows*columns bytes of data.
         */
-        status=DecodeImage(image,bmp_info.compression,pixels);
+        status=DecodeImage(image,bmp_info.compression,pixels,
+                           image->rows*image->columns);
         if (status == MagickFail)
           ThrowBMPReaderException(CorruptImageError,UnableToRunlengthDecodeImage,
             image);
@@ -1037,23 +1143,23 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
     */
     if (bmp_info.compression == BI_RGB)
       {
-        bmp_info.alpha_mask=(image->matte ? 0xff000000L : 0);
-        bmp_info.red_mask=0x00ff0000L;
-        bmp_info.green_mask=0x0000ff00L;
-        bmp_info.blue_mask=0x000000ffL;
+        bmp_info.alpha_mask=(image->matte ? 0xff000000U : 0U);
+        bmp_info.red_mask=0x00ff0000U;
+        bmp_info.green_mask=0x0000ff00U;
+        bmp_info.blue_mask=0x000000ffU;
         if (bmp_info.bits_per_pixel == 16)
           {
             /*
               RGB555.
             */
-            bmp_info.red_mask=0x00007c00L;
-            bmp_info.green_mask=0x000003e0L;
-            bmp_info.blue_mask=0x0000001fL;
+            bmp_info.red_mask=0x00007c00U;
+            bmp_info.green_mask=0x000003e0U;
+            bmp_info.blue_mask=0x0000001fU;
           }
       }
     if ((bmp_info.bits_per_pixel == 16) || (bmp_info.bits_per_pixel == 32))
       {
-        register unsigned long
+        register magick_uint32_t
           sample;
 
         /*
@@ -1061,32 +1167,32 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
         */
         (void) memset(&shift,0,sizeof(PixelPacket));
         (void) memset(&quantum_bits,0,sizeof(PixelPacket));
-        if (bmp_info.red_mask != 0)
-          while (((bmp_info.red_mask << shift.red) & 0x80000000UL) == 0)
+        if (bmp_info.red_mask != 0U)
+          while ((shift.red < 32U) && (((bmp_info.red_mask << shift.red) & 0x80000000U) == 0))
             shift.red++;
         if (bmp_info.green_mask != 0)
-          while (((bmp_info.green_mask << shift.green) & 0x80000000UL) == 0)
+          while ((shift.green < 32U) && (((bmp_info.green_mask << shift.green) & 0x80000000U) == 0))
             shift.green++;
         if (bmp_info.blue_mask != 0)
-          while (((bmp_info.blue_mask << shift.blue) & 0x80000000UL) == 0)
+          while ((shift.blue < 32U) && (((bmp_info.blue_mask << shift.blue) & 0x80000000U) == 0))
             shift.blue++;
         if (bmp_info.alpha_mask != 0)
-          while (((bmp_info.alpha_mask << shift.opacity) & 0x80000000UL) == 0)
+          while ((shift.opacity < 32U) && (((bmp_info.alpha_mask << shift.opacity) & 0x80000000U) == 0))
             shift.opacity++;
         sample=shift.red;
-        while (((bmp_info.red_mask << sample) & 0x80000000UL) != 0)
+        while ((sample < 32U) && (((bmp_info.red_mask << sample) & 0x80000000U) != 0))
           sample++;
         quantum_bits.red=(Quantum) (sample-shift.red);
         sample=shift.green;
-        while (((bmp_info.green_mask << sample) & 0x80000000UL) != 0)
+        while ((sample < 32U) && (((bmp_info.green_mask << sample) & 0x80000000U) != 0))
           sample++;
         quantum_bits.green=(Quantum) (sample-shift.green);
         sample=shift.blue;
-        while (((bmp_info.blue_mask << sample) & 0x80000000UL) != 0)
+        while ((sample < 32U) && (((bmp_info.blue_mask << sample) & 0x80000000U) != 0))
           sample++;
         quantum_bits.blue=(Quantum) (sample-shift.blue);
         sample=shift.opacity;
-        while (((bmp_info.alpha_mask << sample) & 0x80000000UL) != 0)
+        while ((sample < 32U) && (((bmp_info.alpha_mask << sample) & 0x80000000U) != 0))
           sample++;
         quantum_bits.opacity=(Quantum) (sample-shift.opacity);
       }
@@ -1114,7 +1220,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 status=MagickMonitorFormatted(image->rows-y-1,image->rows,
                                               exception,LoadImageText,
                                               image->filename,
-                                             image->columns,image->rows);
+                                              image->columns,image->rows);
                 if (status == False)
                   break;
               }
@@ -1143,7 +1249,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 status=MagickMonitorFormatted(image->rows-y-1,image->rows,
                                               exception,LoadImageText,
                                               image->filename,
-                                             image->columns,image->rows);
+                                              image->columns,image->rows);
                 if (status == False)
                   break;
               }
@@ -1175,7 +1281,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 status=MagickMonitorFormatted(image->rows-y-1,image->rows,
                                               exception,LoadImageText,
                                               image->filename,
-                                             image->columns,image->rows);
+                                              image->columns,image->rows);
                 if (status == False)
                   break;
               }
@@ -1184,7 +1290,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
       }
       case 16:
       {
-        unsigned long
+        magick_uint32_t
           pixel;
 
         /*
@@ -1234,7 +1340,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 status=MagickMonitorFormatted(image->rows-y-1,image->rows,
                                               exception,LoadImageText,
                                               image->filename,
-                                             image->columns,image->rows);
+                                              image->columns,image->rows);
                 if (status == False)
                   break;
               }
@@ -1268,7 +1374,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 status=MagickMonitorFormatted(image->rows-y-1,image->rows,
                                               exception,LoadImageText,
                                               image->filename,
-                                             image->columns,image->rows);
+                                              image->columns,image->rows);
                 if (status == False)
                   break;
               }
@@ -1286,7 +1392,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
         bytes_per_line=4*(image->columns);
         for (y=(long) image->rows-1; y >= 0; y--)
         {
-          unsigned long
+          magick_uint32_t
             pixel;
 
           p=pixels+(image->rows-y-1)*bytes_per_line;
@@ -1295,10 +1401,10 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
             break;
           for (x=0; x < (long) image->columns; x++)
           {
-            pixel =(*p++);
-            pixel|=(*p++ << 8);
-            pixel|=(*p++ << 16);
-            pixel|=(unsigned long) (*p++ << 24);
+            pixel =((magick_uint32_t) *p++);
+            pixel|=((magick_uint32_t) *p++ << 8);
+            pixel|=((magick_uint32_t) *p++ << 16);
+            pixel|=((magick_uint32_t) *p++ << 24);
             red=((pixel & bmp_info.red_mask) << shift.red) >> 16;
             if (quantum_bits.red == 8)
               red|=(red >> 8);
@@ -1328,7 +1434,7 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 status=MagickMonitorFormatted(image->rows-y-1,image->rows,
                                               exception,LoadImageText,
                                               image->filename,
-                                             image->columns,image->rows);
+                                              image->columns,image->rows);
                 if (status == False)
                   break;
               }
@@ -1359,8 +1465,8 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
             DestroyImageList(image);
             return((Image *) NULL);
           }
-       DestroyBlob(flipped_image);
-       flipped_image->blob=ReferenceBlob(image->blob);
+        DestroyBlob(flipped_image);
+        flipped_image->blob=ReferenceBlob(image->blob);
         ReplaceImageInList(&image,flipped_image);
       }
     /*
@@ -1370,10 +1476,20 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
       if (image->scene >= (image_info->subimage+image_info->subrange-1))
         break;
     *magick='\0';
-    if (bmp_info.ba_offset != 0)
-      if (SeekBlob(image,bmp_info.ba_offset,SEEK_SET) == -1)
-        ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image)
-    (void) ReadBlob(image,2,(char *) magick);
+    file_remaining=file_size-TellBlob(image);
+    if (file_remaining == 0)
+      break;
+    offset=bmp_info.ba_offset;
+    if (logging)
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "Seek offset %" MAGICK_OFF_F "d",
+                            (magick_off_t) offset);
+    if (offset > 0)
+      if ((offset < TellBlob(image)) ||
+          (SeekBlob(image,offset,SEEK_SET) != (magick_off_t) offset))
+      ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image);
+    if (ReadBlob(image,2,(char *) magick) != (size_t) 2)
+      break;
     if (IsBMP(magick,2))
       {
         /*
@@ -1558,6 +1674,9 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
   size_t
     color_profile_length=0;
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -1565,6 +1684,7 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   logging=LogMagickEvent(CoderEvent,GetMagickModule(),"enter");
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
@@ -1593,7 +1713,7 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
     bmp_info.file_size=14+12;
     if (type > 2)
       bmp_info.file_size+=28;
-    bmp_info.offset_bits=bmp_info.file_size;
+    bmp_info.offset_bits=(magick_uint32_t) bmp_info.file_size;
     bmp_info.compression=BI_RGB;
     if ((image->storage_class != DirectClass) && (image->colors > 256))
       (void) SetImageType(image,TrueColorType);
@@ -1617,12 +1737,12 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
             (void) SetImageType(image,TrueColorType);
           else
             {
-              bmp_info.file_size+=3*(1 << bmp_info.bits_per_pixel);
-              bmp_info.offset_bits+=3*(1 << bmp_info.bits_per_pixel);
+              bmp_info.file_size+=3U*(1U << bmp_info.bits_per_pixel);
+              bmp_info.offset_bits+=3U*(1U << bmp_info.bits_per_pixel);
               if (type > 2)
                 {
-                  bmp_info.file_size+=(1 << bmp_info.bits_per_pixel);
-                  bmp_info.offset_bits+=(1 << bmp_info.bits_per_pixel);
+                  bmp_info.file_size+=(size_t) (1U << bmp_info.bits_per_pixel);
+                  bmp_info.offset_bits+=(1U << bmp_info.bits_per_pixel);
                 }
             }
       }
@@ -1670,22 +1790,22 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
     */
     if (type == 2)
       {
-       bmp_info.width=(magick_int16_t) image->columns;
-       bmp_info.height=(magick_int16_t) image->rows;
+        bmp_info.width=(magick_int16_t) image->columns;
+        bmp_info.height=(magick_int16_t) image->rows;
       }
     else
       {
-       bmp_info.width=(magick_int32_t) image->columns;
-       bmp_info.height=(magick_int32_t) image->rows;
+        bmp_info.width=(magick_int32_t) image->columns;
+        bmp_info.height=(magick_int32_t) image->rows;
       }
     if (((unsigned long) bmp_info.width != image->columns) ||
-       ((unsigned long) bmp_info.height != image->rows))
+        ((unsigned long) bmp_info.height != image->rows))
       {
-       ThrowWriterException(CoderError,ImageColumnOrRowSizeIsNotSupported,image);
+        ThrowWriterException(CoderError,ImageColumnOrRowSizeIsNotSupported,image);
       }
 
     bmp_info.planes=1;
-    bmp_info.image_size=bytes_per_line*image->rows;
+    bmp_info.image_size=MagickArraySize(bytes_per_line,image->rows);
     bmp_info.file_size+=bmp_info.image_size;
     bmp_info.x_pixels=75*39;
     bmp_info.y_pixels=75*39;
@@ -1734,7 +1854,7 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                               SaveImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
             }
           break;
@@ -1765,7 +1885,7 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
            if (QuantumTick(y,image->rows))
              if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                          SaveImageText,image->filename,
-                                        image->columns,image->rows))
+                                         image->columns,image->rows))
                break;
         }
         break;
@@ -1795,7 +1915,7 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                           SaveImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
         break;
@@ -1831,7 +1951,7 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                           SaveImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
         break;
@@ -1886,8 +2006,9 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
           "   BMP bits_per_pixel=%d",bmp_info.bits_per_pixel);
        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-          "   BMP file_size=%lu bytes",bmp_info.file_size);
-        switch ((int) bmp_info.compression)
+                             "   BMP file_size=%" MAGICK_SIZE_T_F "u bytes",
+                             (MAGICK_SIZE_T) bmp_info.file_size);
+        switch (bmp_info.compression)
         {
            case BI_RGB:
            {
@@ -1910,7 +2031,7 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
            default:
            {
              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-               "   Compression=UNKNOWN (%lu)",bmp_info.compression);
+               "   Compression=UNKNOWN (%u)",bmp_info.compression);
              break;
            }
         }
@@ -1919,10 +2040,10 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
             "   Number_colors=unspecified");
         else
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-            "   Number_colors=%lu",bmp_info.number_colors);
+            "   Number_colors=%u",bmp_info.number_colors);
       }
     (void) WriteBlob(image,2,"BM");
-    (void) WriteBlobLSBLong(image,bmp_info.file_size);
+    (void) WriteBlobLSBLong(image,(magick_uint32_t) bmp_info.file_size);
     (void) WriteBlobLSBLong(image,bmp_info.ba_offset);  /* always 0 */
     (void) WriteBlobLSBLong(image,bmp_info.offset_bits);
     if (type == 2)
@@ -1947,7 +2068,7 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
         (void) WriteBlobLSBShort(image,bmp_info.planes);
         (void) WriteBlobLSBShort(image,bmp_info.bits_per_pixel);
         (void) WriteBlobLSBLong(image,bmp_info.compression);
-        (void) WriteBlobLSBLong(image,bmp_info.image_size);
+        (void) WriteBlobLSBLong(image,(magick_uint32_t) bmp_info.image_size);
         (void) WriteBlobLSBLong(image,bmp_info.x_pixels);
         (void) WriteBlobLSBLong(image,bmp_info.y_pixels);
         (void) WriteBlobLSBLong(image,bmp_info.number_colors);
@@ -2074,13 +2195,14 @@ static unsigned int WriteBMPImage(const ImageInfo *image_info,Image *image)
       }
     if (logging)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-        "  Pixels:  %lu bytes",bmp_info.image_size);
+                            "  Pixels:  %" MAGICK_SIZE_T_F "u bytes",
+                            (MAGICK_SIZE_T) bmp_info.image_size);
     (void) WriteBlob(image,bmp_info.image_size,(char *) pixels);
     MagickFreeMemory(pixels);
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene++,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename);
     if (status == False)
index 74df0fa..7749178 100644 (file)
@@ -42,7 +42,7 @@
 #include "magick/monitor.h"
 #include "magick/tempfile.h"
 #include "magick/utility.h"
-/* 
+/*
    Write an unsigned long to file with Intel/LSB ordering
 */
 static void CALS_WriteIntelULong(FILE *file,unsigned long ul)
@@ -135,7 +135,7 @@ static Image *ReadCALSImage(const ImageInfo *image_info,ExceptionInfo *exception
     y;
 
   char
-    record[129];  
+    record[129];
 
   unsigned long
     status,
@@ -179,7 +179,7 @@ static Image *ReadCALSImage(const ImageInfo *image_info,ExceptionInfo *exception
 
   /*
     Scan CAL header, record by record, looking for mandatory fields
-  */ 
+  */
   rtype = 1;
   width = height = 0;
   orient = 1;
@@ -251,7 +251,7 @@ static Image *ReadCALSImage(const ImageInfo *image_info,ExceptionInfo *exception
     ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
 
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                       "Dimensions %lux%lu",width,height);
+                        "Dimensions %lux%lu",width,height);
 
   /* Create TIFF wrapper to handle file data using TIFF library */
   file=AcquireTemporaryFileStream(filename,BinaryFileIOMode);
@@ -341,9 +341,9 @@ static Image *ReadCALSImage(const ImageInfo *image_info,ExceptionInfo *exception
   if (image != (Image *) NULL)
     {
       (void) strlcpy(image->filename,image_info->filename,
-                    sizeof(image->filename));
+                     sizeof(image->filename));
       (void) strlcpy(image->magick_filename,image_info->filename,
-                    sizeof(image->magick_filename));
+                     sizeof(image->magick_filename));
       (void) strlcpy(image->magick,"CALS",sizeof(image->magick));
     }
   return(image);
@@ -484,14 +484,14 @@ static MagickPassFail WriteCALSImage(const ImageInfo *image_info,Image *image)
       ory=0;
       break;
     default:
-      orx=0; 
+      orx=0;
       ory=270;
   }
   FormatString(buffer,"rorient: %03d,%03d",orx,ory);
   WriteCALSRecord(image,buffer);
   /* pixel counts based on columns/rows of input */
   FormatString(buffer,"rpelcnt: %06ld,%06ld",image->columns,image->rows);
-  WriteCALSRecord(image,buffer);  
+  WriteCALSRecord(image,buffer);
   /* density based on input density or default of 200 */
   density=200;
   if (image_info->density != (char *) NULL)
@@ -525,8 +525,8 @@ static MagickPassFail WriteCALSImage(const ImageInfo *image_info,Image *image)
 
     if (MagickFail != status)
       {
-       if (WriteBlob(image,blob_length,blob) != blob_length)
-         status=MagickFail;
+        if (WriteBlob(image,blob_length,blob) != blob_length)
+          status=MagickFail;
       }
     MagickFreeMemory(blob);
   }
index 4bfd21a..9fdd782 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 %
 % This program is covered by multiple licenses, which are described in
 % Copyright.txt. You should have received a copy of Copyright.txt with this
@@ -130,7 +130,7 @@ typedef struct _CineonImageInfo
   U8    sense;                     /* Image sense: 0=positive, 1=negative */
   U32   eol_pad;                   /* End of line padding */
   U32   eoc_pad;                   /* End of channel padding */
-  ASCII reserved2[20];             /* Reserved for future use */  
+  ASCII reserved2[20];             /* Reserved for future use */
 } CineonImageInfo;
 
 typedef struct _CineonImageOriginationInfo
@@ -256,7 +256,7 @@ static unsigned int IsCINEON(const unsigned char *magick,const size_t length)
 \
   if (!IS_UNDEFINED_ASCII(member)) \
     { \
-      (void) strncpy(buffer_,member,Min(sizeof(member),MaxTextExtent)); \
+      (void) memcpy(buffer_,member,Min(sizeof(member),MaxTextExtent)); \
       buffer_[Min(sizeof(member),MaxTextExtent-1)]='\0';             \
       (void) SetImageAttribute(image,name,buffer_); \
       LogSetImageAttribute(name,buffer_); \
@@ -348,7 +348,7 @@ static void SwabCineonImageInfo(CineonImageInfo *image_info)
   MagickSwabFloat(&image_info->blue_primary_chromaticity[0].f);
   MagickSwabFloat(&image_info->blue_primary_chromaticity[1].f);
   MagickSwabUInt32(&image_info->eol_pad);
-  MagickSwabUInt32(&image_info->eoc_pad);  
+  MagickSwabUInt32(&image_info->eoc_pad);
 }
 
 static void SwabCineonImageOriginationInfo(CineonImageOriginationInfo *image_info)
@@ -459,10 +459,10 @@ static Image *ReadCINEONImage(const ImageInfo *image_info,
   Image
     *image;
 
-  long
+  unsigned long
     y;
 
-  register long
+  register unsigned long
     x;
 
   register PixelPacket
@@ -472,14 +472,14 @@ static Image *ReadCINEONImage(const ImageInfo *image_info,
     i;
 
   size_t
-    offset;    
+    offset;
 
   unsigned int
     channel,
     max_bits_per_sample,
     max_lines_per_image,
     max_pixels_per_line,
-    number_of_channels;    
+    number_of_channels;
 
   MagickPassFail
     status;
@@ -492,7 +492,7 @@ static Image *ReadCINEONImage(const ImageInfo *image_info,
 
   unsigned char
     *scandata;
-  
+
   void
     *scanline;
 
@@ -614,7 +614,7 @@ static Image *ReadCINEONImage(const ImageInfo *image_info,
       max_lines_per_image=Max(max_lines_per_image,
                               cin_image_info.channel_info[channel].lines_per_image);
     }
-  
+
   image->depth=max_bits_per_sample;
   image->columns=max_pixels_per_line;
   image->rows=max_lines_per_image;
@@ -705,14 +705,14 @@ static Image *ReadCINEONImage(const ImageInfo *image_info,
     {
       unsigned char
         *user_data;
-      
+
       const size_t
         block_size = 65536UL;
-      
+
       size_t
         read_size,
         user_data_length;
-      
+
       user_data_length=0UL;
       user_data=(unsigned char *) NULL;
       while (user_data_length < cin_file_info.user_defined_length)
@@ -753,6 +753,29 @@ static Image *ReadCINEONImage(const ImageInfo *image_info,
     if (ReadBlobByte(image) == EOF)
       ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
 
+  /*
+    Verify that remaining data is sufficient for claimed dimensions.
+  */
+  if (BlobIsSeekable(image))
+    {
+      magick_off_t file_size;
+      magick_int64_t expected_file_size;
+
+      file_size = GetBlobSize(image);
+
+      expected_file_size=pixels_offset+
+        ((((((magick_int64_t) image->rows*image->columns*number_of_channels+2UL)/3UL)
+           *sizeof(U32)*8UL)+31UL)/32UL)*sizeof(U32);
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Expected file size %" MAGICK_UINT64_F "u bytes"
+                              " (have %" MAGICK_OFF_F "d bytes)",
+                              expected_file_size, file_size);
+
+      if ((file_size > 0) && ((magick_int64_t) file_size < expected_file_size))
+        ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,image);
+    }
+
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                           "Reading Cineon pixels starting at offset %ld",(long) TellBlob(image));
@@ -774,9 +797,11 @@ static Image *ReadCINEONImage(const ImageInfo *image_info,
           scandata_bytes=4;
           scale_to_short=64;
           scandata=MagickAllocateMemory(unsigned char *,scandata_bytes);
+          if (scandata == (unsigned char *) NULL)
+            ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
           scanline=scandata;
           MagickBitStreamInitializeRead(&bit_stream,scanline);
-          for (y=0; y < (long) image->rows; y++)
+          for (y=0; y < image->rows; y++)
             {
               q=SetImagePixels(image,0,y,image->columns,1);
               if (q == (PixelPacket *) NULL)
@@ -786,7 +811,7 @@ static Image *ReadCINEONImage(const ImageInfo *image_info,
               */
               scanline=scandata;
               i=3;
-              for (x=(long) image->columns; x > 0; x--, i++)
+              for (x=0; x < image->columns; x++, i++)
                 {
                   if (i > 2)
                     {
@@ -802,13 +827,15 @@ static Image *ReadCINEONImage(const ImageInfo *image_info,
                   q->opacity=0U;
                   q++;
                 }
+              if (x < image->columns)
+                break;
               if (!SyncImagePixels(image))
                 break;
               if (image->previous == (Image *) NULL)
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,exception,
                                               LoadImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
             }
           MagickFreeMemory(scandata);
@@ -816,10 +843,12 @@ static Image *ReadCINEONImage(const ImageInfo *image_info,
         }
       case 3:
         {
-          scandata_bytes=image->columns*4;
+          scandata_bytes=MagickArraySize(image->columns,4);
           scale_to_short=64;
           scandata=MagickAllocateMemory(unsigned char *,scandata_bytes);
-          for (y=0; y < (long) image->rows; y++)
+          if (scandata == (unsigned char *) NULL)
+            ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+          for (y=0; y < image->rows; y++)
             {
               magick_uint32_t red;
               magick_uint32_t green;
@@ -832,7 +861,7 @@ static Image *ReadCINEONImage(const ImageInfo *image_info,
               if (ReadBlobZC(image,scandata_bytes,&scanline) != scandata_bytes)
                 break;
               MagickBitStreamInitializeRead(&bit_stream,scanline);
-              for (x=0 ; x < (long) image->columns; x++)
+              for (x=0 ; x < image->columns; x++)
                 {
                   /*
                     Packed 10 bit samples with 2 bit pad at end of 32-bit word.
@@ -851,13 +880,15 @@ static Image *ReadCINEONImage(const ImageInfo *image_info,
 /*                          (unsigned int)q->red, (unsigned int)q->green, (unsigned int)q->blue); */
                   q++;
                 }
+              if (x < image->columns)
+                break;
               if (!SyncImagePixels(image))
                 break;
               if (image->previous == (Image *) NULL)
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,exception,
                                               LoadImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
             }
           MagickFreeMemory(scandata);
@@ -867,6 +898,9 @@ static Image *ReadCINEONImage(const ImageInfo *image_info,
         ThrowReaderException(CorruptImageError,ImageTypeNotSupported,image);
       }
   }
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "EOF at offset %" MAGICK_OFF_F "d", TellBlob(image));
   image->depth=Min(image->depth,QuantumDepth);
   image->colorspace=CineonLogRGBColorspace;
 
@@ -1125,7 +1159,7 @@ static unsigned int WriteCINEONImage(const ImageInfo *image_info,Image *image)
 
   register const PixelPacket
     *p;
-  
+
   register long
     x;
 
@@ -1263,7 +1297,7 @@ static unsigned int WriteCINEONImage(const ImageInfo *image_info,Image *image)
   cin_image_info.eol_pad = 0;
   /* End of channel padding */
   cin_image_info.eoc_pad = 0;
-  
+
   /*
     Image origination header.
   */
@@ -1328,7 +1362,7 @@ static unsigned int WriteCINEONImage(const ImageInfo *image_info,Image *image)
   AttributeToString(image_info,image,"DPX:mp.frame.id",cin_mp_info.frame_id);
   /* Slate information */
   AttributeToString(image_info,image,"DPX:mp.slate.info",cin_mp_info.slate_info);
-  
+
   /*
     Open output image file.
   */
@@ -1431,7 +1465,7 @@ static unsigned int WriteCINEONImage(const ImageInfo *image_info,Image *image)
     bits_per_sample = cin_image_info.channel_info[0].bits_per_sample;
     scale_from_short=(65535U / (65535U >> (16-bits_per_sample)));
 
-    scanline_bytes=image->columns*4;
+    scanline_bytes=MagickArraySize(image->columns,4);
     scanline=MagickAllocateMemory(unsigned char *,scanline_bytes);
     if (scanline == (unsigned char *) NULL)
       ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
@@ -1442,9 +1476,9 @@ static unsigned int WriteCINEONImage(const ImageInfo *image_info,Image *image)
         p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
         if (p == (const PixelPacket *) NULL)
           break;
-        
+
         MagickBitStreamInitializeWrite(&bit_stream,scanline);
-        
+
         for (x=0; x < (long) image->columns; x++)
           {
             red   = ScaleQuantumToShort(p->red)/scale_from_short;
@@ -1472,7 +1506,7 @@ static unsigned int WriteCINEONImage(const ImageInfo *image_info,Image *image)
           if (QuantumTick(y,image->rows))
             if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                         SaveImageText,image->filename,
-                                       image->columns,image->rows))
+                                        image->columns,image->rows))
               break;
       }
     MagickFreeMemory(scanline);
index 9edbf33..163d70c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -82,6 +82,11 @@ static unsigned int
 %
 %
 */
+#define ThrowCMYKReaderException(code_,reason_,image_) \
+{ \
+  MagickFreeMemory(scanline);                 \
+  ThrowReaderException(code_,reason_,image_); \
+}
 static Image *ReadCMYKImage(const ImageInfo *image_info,
   ExceptionInfo *exception)
 {
@@ -92,17 +97,18 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
     y;
 
   register long
-    i,
-    x;
+    i;
 
   register PixelPacket
     *q;
 
   size_t
-    count;
+    count,
+    tile_packets,
+    x;
 
   unsigned char
-    *scanline;
+    *scanline = (unsigned char *) NULL;
 
   unsigned int
     status;
@@ -119,8 +125,33 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
   image=AllocateImage(image_info);
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Size %lux%lu", image->columns, image->rows);
   if ((image->columns == 0) || (image->rows == 0))
     ThrowReaderException(OptionError,MustSpecifyImageSize,image);
+
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Tile %lux%lu%+ld%+ld, Offset %lu",
+                          image->tile_info.width,image->tile_info.height,
+                          image->tile_info.x,image->tile_info.y,
+                          image->offset);
+  /*
+    There is the option to either require that the tile be within the
+    image bounds or to return only the portion of the tile which is
+    within the image bounds (returned image is smaller than requested
+    tile size).  For the moment we choose the former.
+  */
+  if ((image->tile_info.width > image->columns) ||
+      (image->tile_info.x < 0) ||
+      (image->tile_info.width+image->tile_info.x > image->columns) ||
+      (image->tile_info.height > image->rows) ||
+      (image->tile_info.y < 0) ||
+      (image->tile_info.height+image->tile_info.y > image->rows)
+      )
+    ThrowReaderException(OptionError,TileNotBoundedByImageDimensions,image);
+
   if (image_info->interlace != PartitionInterlace)
     {
       /*
@@ -128,7 +159,7 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
       */
       status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
       if (status == False)
-        ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+        ThrowCMYKReaderException(FileOpenError,UnableToOpenFile,image);
       for (i=0; i < image->offset; i++)
         {
           if (EOF == ReadBlobByte(image))
@@ -137,22 +168,16 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
         }
     }
 
-  if (image->logging)
-    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                         "Tile %lux%lu%+ld%+ld",
-                         image->tile_info.width,image->tile_info.height,
-                         image->tile_info.x,image->tile_info.y);
-
   /*
     Allocate memory for a scanline.
   */
 
   if (image->depth <= 8)
-    quantum_size=8;
+    quantum_size=8U;
   else if (image->depth <= 16)
-    quantum_size=16;
+    quantum_size=16U;
   else
-    quantum_size=32;
+    quantum_size=32U;
 
   packet_size=(quantum_size*4)/8;
   if (LocaleCompare(image_info->magick,"CMYKA") == 0)
@@ -161,9 +186,17 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
       packet_size=(quantum_size*5)/8;
     }
   scanline=MagickAllocateArray(unsigned char *,
-                              packet_size,image->tile_info.width);
+                               packet_size,image->columns);
   if (scanline == (unsigned char *) NULL)
-    ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+    ThrowCMYKReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+  tile_packets=(size_t) packet_size*image->tile_info.width;
+  x=(size_t) (packet_size*image->tile_info.x);
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "image->tile_info.x=%lu, packet_size=%u, "
+                          "x=%" MAGICK_SIZE_T_F "u",
+                          image->tile_info.x, packet_size,
+                          (MAGICK_SIZE_T) x);
   /*
     Initialize import options.
   */
@@ -173,10 +206,10 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
 
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                         "Depth %u bits, Endian %s, Interlace %s",
-                         quantum_size,
-                         EndianTypeToString(import_options.endian),
-                         InterlaceTypeToString(image_info->interlace));
+                          "Depth %u bits, Endian %s, Interlace %s",
+                          quantum_size,
+                          EndianTypeToString(import_options.endian),
+                          InterlaceTypeToString(image_info->interlace));
   /*
     Support starting at intermediate image frame.
   */
@@ -188,9 +221,9 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
       */
       image->scene++;
       for (y=0; y < (long) image->rows; y++)
-        (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+        if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+          break;
     }
-  x=(long) (packet_size*image->tile_info.x);
   do
   {
     /*
@@ -209,32 +242,35 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
           No interlacing:  CMYKCMYKCMYKCMYKCMYKCMYK...
         */
         for (y=0; y < image->tile_info.y; y++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         for (y=0; y < (long) image->rows; y++)
         {
           if ((y > 0) || (image->previous == (Image *) NULL))
-            (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+            if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+              break;
           q=SetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
           if (!image->matte)
             (void) ImportImagePixelArea(image,CMYKQuantum,quantum_size,scanline+x,
-                                       &import_options,0);
+                                        &import_options,0);
           else
             (void) ImportImagePixelArea(image,CMYKAQuantum,quantum_size,scanline+x,
-                                       &import_options,0);
+                                        &import_options,0);
           if (!SyncImagePixels(image))
             break;
           if (image->previous == (Image *) NULL)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
         count=image->tile_info.height-image->rows-image->tile_info.y;
         for (i=0; i < (long) count; i++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         break;
       }
       case LineInterlace:
@@ -244,31 +280,36 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
         */
         packet_size=(quantum_size)/8;
         for (y=0; y < image->tile_info.y; y++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         for (y=0; y < (long) image->rows; y++)
         {
           if ((y > 0) || (image->previous == (Image *) NULL))
-            (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+            if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+              break;
           q=SetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
           (void) ImportImagePixelArea(image,CyanQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+                                      &import_options,0);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
           (void) ImportImagePixelArea(image,MagentaQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+                                      &import_options,0);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
           (void) ImportImagePixelArea(image,YellowQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+                                      &import_options,0);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
           (void) ImportImagePixelArea(image,BlackQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
+                                      &import_options,0);
           if (image->matte)
             {
-              (void) ReadBlob(image,packet_size*image->tile_info.width,
-                scanline);
+              if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+                break;
               (void) ImportImagePixelArea(image,AlphaQuantum,quantum_size,scanline+x,
-                                         &import_options,0);
+                                          &import_options,0);
             }
           if (!SyncImagePixels(image))
             break;
@@ -276,12 +317,13 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
         count=image->tile_info.height-image->rows-image->tile_info.y;
         for (i=0; i < (long) count; i++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         break;
       }
       case PlaneInterlace:
@@ -298,128 +340,140 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
             AppendImageFormat("C",image->filename);
             status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
             if (status == False)
-              ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+              ThrowCMYKReaderException(FileOpenError,UnableToOpenFile,image);
           }
         packet_size=(quantum_size)/8;
         for (y=0; y < image->tile_info.y; y++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         i=0;
         span=image->rows*(image->matte ? 5 : 4);
         for (y=0; y < (long) image->rows; y++)
         {
           if ((y > 0) || (image->previous == (Image *) NULL))
-            (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+            if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+              break;
           q=SetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
           (void) ImportImagePixelArea(image,CyanQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
+                                      &import_options,0);
           if (!SyncImagePixels(image))
             break;
           if (image->previous == (Image *) NULL)
             if (QuantumTick(i,span))
               if (!MagickMonitorFormatted(i,span,&image->exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
           i++;
         }
         count=image->tile_info.height-image->rows-image->tile_info.y;
         for (i=0; i < (long) count; i++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         if (image_info->interlace == PartitionInterlace)
           {
             CloseBlob(image);
             AppendImageFormat("M",image->filename);
             status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
             if (status == False)
-              ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+              ThrowCMYKReaderException(FileOpenError,UnableToOpenFile,image);
           }
         for (y=0; y < image->tile_info.y; y++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         for (y=0; y < (long) image->rows; y++)
         {
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
           q=GetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
           (void) ImportImagePixelArea(image,MagentaQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
+                                      &import_options,0);
           if (!SyncImagePixels(image))
             break;
           if (image->previous == (Image *) NULL)
             if (QuantumTick(i,span))
               if (!MagickMonitorFormatted(i,span,&image->exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
           i++;
         }
         count=image->tile_info.height-image->rows-image->tile_info.y;
         for (i=0; i < (long) count; i++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         if (image_info->interlace == PartitionInterlace)
           {
             CloseBlob(image);
             AppendImageFormat("Y",image->filename);
             status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
             if (status == False)
-              ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+              ThrowCMYKReaderException(FileOpenError,UnableToOpenFile,image);
           }
         for (y=0; y < image->tile_info.y; y++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         for (y=0; y < (long) image->rows; y++)
         {
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
           q=GetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
           (void) ImportImagePixelArea(image,YellowQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
+                                      &import_options,0);
           if (!SyncImagePixels(image))
             break;
           if (image->previous == (Image *) NULL)
             if (QuantumTick(i,span))
               if (!MagickMonitorFormatted(i,span,&image->exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
           i++;
         }
         count=image->tile_info.height-image->rows-image->tile_info.y;
         for (i=0; i < (long) count; i++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         if (image_info->interlace == PartitionInterlace)
           {
             CloseBlob(image);
             AppendImageFormat("K",image->filename);
             status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
             if (status == False)
-              ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+              ThrowCMYKReaderException(FileOpenError,UnableToOpenFile,image);
           }
         for (y=0; y < image->tile_info.y; y++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         for (y=0; y < (long) image->rows; y++)
         {
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
           q=GetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
           (void) ImportImagePixelArea(image,BlackQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
+                                      &import_options,0);
           if (!SyncImagePixels(image))
             break;
           if (image->previous == (Image *) NULL)
             if (QuantumTick(i,span))
               if (!MagickMonitorFormatted(i,span,&image->exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
           i++;
         }
         count=image->tile_info.height-image->rows-image->tile_info.y;
         for (i=0; i < (long) count; i++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         if (image->matte)
           {
             /*
@@ -431,34 +485,34 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
                 AppendImageFormat("A",image->filename);
                 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
                 if (status == False)
-                  ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+                  ThrowCMYKReaderException(FileOpenError,UnableToOpenFile,image);
               }
             for (y=0; y < image->tile_info.y; y++)
-              (void) ReadBlob(image,packet_size*image->tile_info.width,
-                scanline);
+              if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+                break;
             for (y=0; y < (long) image->rows; y++)
             {
-              (void) ReadBlob(image,packet_size*image->tile_info.width,
-                scanline);
+              if (ReadBlob(image,tile_packets,scanline)  != tile_packets)
+                break;
               q=GetImagePixels(image,0,y,image->columns,1);
               if (q == (PixelPacket *) NULL)
                 break;
               (void) ImportImagePixelArea(image,AlphaQuantum,quantum_size,scanline+x,
-                                         &import_options,0);
+                                          &import_options,0);
               if (!SyncImagePixels(image))
                 break;
               if (image->previous == (Image *) NULL)
                 if (QuantumTick(i,span))
                   if (!MagickMonitorFormatted(i,span,&image->exception,
                                               LoadImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
               i++;
             }
             count=image->tile_info.height-image->rows-image->tile_info.y;
             for (i=0; i < (long) count; i++)
-              (void) ReadBlob(image,packet_size*image->tile_info.width,
-                scanline);
+              if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+                break;
           }
         if (image_info->interlace == PartitionInterlace)
           (void) strlcpy(image->filename,image_info->filename,MaxTextExtent);
@@ -479,8 +533,8 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
         break;
     if (image_info->interlace == PartitionInterlace)
       break;
-    count=ReadBlob(image,packet_size*image->tile_info.width,scanline);
-    if (count != 0)
+    count=ReadBlob(image,tile_packets,scanline);
+    if (count == tile_packets)
       {
         /*
           Allocate next image structure.
@@ -488,8 +542,7 @@ static Image *ReadCMYKImage(const ImageInfo *image_info,
         AllocateNextImage(image_info,image);
         if (image->next == (Image *) NULL)
           {
-            DestroyImageList(image);
-            return((Image *) NULL);
+            ThrowCMYKReaderException(ResourceLimitError,MemoryAllocationFailed,image);
           }
         image=SyncNextImageInList(image);
         status=MagickMonitorFormatted(TellBlob(image),GetBlobSize(image),
@@ -608,16 +661,17 @@ ModuleExport void UnregisterCMYKImage(void)
 */
 static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
 {
-  int
+  long
     y;
 
   register const PixelPacket
     *p;
 
   unsigned char
-    *pixels;
+    *pixels = (unsigned char *) NULL;
 
   unsigned int
+    depth,
     packet_size,
     quantum_size,
     scene,
@@ -629,27 +683,15 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
   ExportPixelAreaInfo
     export_info;
 
-  if (image->depth <= 8)
-    quantum_size=8;
-  else if (image->depth <= 16)
-    quantum_size=16;
-  else
-    quantum_size=32;
-  
+  size_t
+    image_list_length;
 
-  /*
-    Allocate memory for pixels.
-  */
   assert(image_info != (const ImageInfo *) NULL);
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
-  packet_size=(quantum_size*4)/8;
-  if (LocaleCompare(image_info->magick,"CMYKA") == 0)
-    packet_size=(quantum_size*5)/8;
-  pixels=MagickAllocateArray(unsigned char *,packet_size,image->columns);
-  if (pixels == (unsigned char *) NULL)
-    ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+
+  image_list_length=GetImageListLength(image);
   if (image_info->interlace != PartitionInterlace)
     {
       /*
@@ -659,16 +701,39 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
       if (status == False)
         ThrowWriterException(FileOpenError,UnableToOpenFile,image);
     }
+
+  /*
+    Support depth in multiples of 8 bits.
+  */
+  if (image->depth > 16)
+    depth=32;
+  else if (image->depth > 8)
+    depth=16;
+  else
+    depth=8;
+
+  if (depth <= 8)
+    quantum_size=8;
+  else if (depth <= 16)
+    quantum_size=16;
+  else
+    quantum_size=32;
+
+  packet_size=(quantum_size*4)/8;
+  if (LocaleCompare(image_info->magick,"CMYKA") == 0)
+    packet_size=(quantum_size*5)/8;
+
   scene=0;
   do
   {
     /*
-      Convert MIFF to CMYK raster pixels.
+      Allocate memory for pixels.
     */
-    (void) TransformColorspace(image,CMYKColorspace);
-    if (LocaleCompare(image_info->magick,"CMYKA") == 0)
-      if (!image->matte)
-        SetImageOpacity(image,OpaqueOpacity);
+    MagickReallocMemory(unsigned char *,pixels,
+                        MagickArraySize(packet_size,image->columns));
+    if (pixels == (unsigned char *) NULL)
+      ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+
     /*
       Initialize export options.
     */
@@ -677,10 +742,28 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
       export_options.endian=image->endian;
     else if (image_info->endian != UndefinedEndian)
       export_options.endian=image_info->endian;
-    if (image->logging)
-      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "Image depth %u bits, Endian %s",quantum_size,
-                           EndianTypeToString(export_options.endian));
+
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "%lu: "
+                          "Geometry %lux%lu, "
+                          "Depth %u bits, "
+                          "Endian %s, Packet Size %u, "
+                          "Row bytes %" MAGICK_SIZE_T_F "u",
+                          image->scene,
+                          image->columns,image->rows,
+                          quantum_size,
+                          EndianTypeToString(export_options.endian),
+                          packet_size,
+                          (MAGICK_SIZE_T) MagickArraySize(packet_size,image->columns));
+
+    /*
+      Convert MIFF to CMYK raster pixels.
+    */
+    (void) TransformColorspace(image,CMYKColorspace);
+    if (LocaleCompare(image_info->magick,"CMYKA") == 0)
+      if (!image->matte)
+        SetImageOpacity(image,OpaqueOpacity);
+
     switch (image_info->interlace)
     {
       case NoInterlace:
@@ -689,28 +772,22 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
         /*
           No interlacing:  CMYKCMYKCMYKCMYKCMYKCMYK...
         */
+        const QuantumType quantum_type =
+          (LocaleCompare(image_info->magick,"CMYKA") == 0) ? CMYKAQuantum :
+          CMYKQuantum;
         for (y=0; y < (long) image->rows; y++)
         {
           p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-          if (LocaleCompare(image_info->magick,"CMYKA") != 0)
-            {
-              (void) ExportImagePixelArea(image,CMYKQuantum,quantum_size,pixels,
-                                         &export_options,&export_info);
-              (void) WriteBlob(image,export_info.bytes_exported,pixels);
-            }
-          else
-            {
-              (void) ExportImagePixelArea(image,CMYKAQuantum,quantum_size,pixels,
-                                         &export_options,&export_info);
-              (void) WriteBlob(image,export_info.bytes_exported,pixels);
-            }
+          (void) ExportImagePixelArea(image,quantum_type,quantum_size,pixels,
+                                      &export_options,&export_info);
+          (void) WriteBlob(image,export_info.bytes_exported,pixels);
           if (image->previous == (Image *) NULL)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                           SaveImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
         break;
@@ -726,27 +803,27 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
           if (p == (const PixelPacket *) NULL)
             break;
           (void) ExportImagePixelArea(image,CyanQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
           (void) ExportImagePixelArea(image,MagentaQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
           (void) ExportImagePixelArea(image,YellowQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
           (void) ExportImagePixelArea(image,BlackQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
           if (LocaleCompare(image_info->magick,"CMYKA") == 0)
             {
               (void) ExportImagePixelArea(image,AlphaQuantum,quantum_size,pixels,
-                                         &export_options,&export_info);
+                                          &export_options,&export_info);
               (void) WriteBlob(image,export_info.bytes_exported,pixels);
             }
           if (QuantumTick(y,image->rows))
             if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                         SaveImageText,image->filename,
-                                       image->columns,image->rows))
+                                        image->columns,image->rows))
               break;
         }
         break;
@@ -771,7 +848,7 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
           if (p == (const PixelPacket *) NULL)
             break;
           (void) ExportImagePixelArea(image,CyanQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
         }
         if (image_info->interlace == PartitionInterlace)
@@ -785,7 +862,7 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
           }
         if (!MagickMonitorFormatted(100,400,&image->exception,
                                     SaveImageText,image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
         for (y=0; y < (long) image->rows; y++)
         {
@@ -793,7 +870,7 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
           if (p == (const PixelPacket *) NULL)
             break;
           (void) ExportImagePixelArea(image,MagentaQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
         }
         if (image_info->interlace == PartitionInterlace)
@@ -807,7 +884,7 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
           }
         if (!MagickMonitorFormatted(200,400,&image->exception,
                                     SaveImageText,image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
         for (y=0; y < (long) image->rows; y++)
         {
@@ -815,7 +892,7 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
           if (p == (const PixelPacket *) NULL)
             break;
           (void) ExportImagePixelArea(image,YellowQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
         }
         if (image_info->interlace == PartitionInterlace)
@@ -829,7 +906,7 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
           }
         if (!MagickMonitorFormatted(200,400,&image->exception,
                                     SaveImageText,image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
         for (y=0; y < (long) image->rows; y++)
         {
@@ -837,14 +914,14 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
           if (p == (const PixelPacket *) NULL)
             break;
           (void) ExportImagePixelArea(image,BlackQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
         }
         if (LocaleCompare(image_info->magick,"CMYKA") == 0)
           {
             if (!MagickMonitorFormatted(300,400,&image->exception,
                                         SaveImageText,image->filename,
-                                       image->columns,image->rows))
+                                        image->columns,image->rows))
               break;
             if (image_info->interlace == PartitionInterlace)
               {
@@ -862,7 +939,7 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
               if (p == (const PixelPacket *) NULL)
                 break;
               (void) ExportImagePixelArea(image,AlphaQuantum,quantum_size,pixels,
-                                         &export_options,&export_info);
+                                          &export_options,&export_info);
               (void) WriteBlob(image,export_info.bytes_exported,pixels);
             }
           }
@@ -877,7 +954,7 @@ static unsigned int WriteCMYKImage(const ImageInfo *image_info,Image *image)
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene++,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename);
     if (status == False)
index 71fece5..a5821a0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -226,7 +226,7 @@ static void InsertRow(unsigned char *p,long y,Image *image)
 
 static unsigned int GetCutColors(Image *image)
 {
-  int
+  unsigned long
     x,
     y;
 
@@ -238,24 +238,27 @@ static unsigned int GetCutColors(Image *image)
     ScaleCharToQuantum16;
 
   /* Compute the number of colors in Grayed R[i]=G[i]=B[i] image */
-  ScaleCharToQuantum16=ScaleCharToQuantum(16);
-  MaxColor=0;
-  for (y=0; y < (long)image->rows; y++)
+  ScaleCharToQuantum16=ScaleCharToQuantum(16U);
+  MaxColor=0U;
+  for (y=0; y < image->rows; y++)
     {
+
       q=SetImagePixels(image,0,y,image->columns,1);
-      for (x=(long)image->columns; x > 0; x--)
+      if (q == (PixelPacket *) NULL)
+          break;
+      for (x=image->columns; x != 0; x--)
         {
           if (MaxColor < q->red)
             MaxColor=q->red;
           if (MaxColor >= ScaleCharToQuantum16)
-            return(255);
+            return(255U);
           q++;
         }
     }
   if (MaxColor < ScaleCharToQuantum(2))
-    MaxColor=2;
-  else if (MaxColor < ScaleCharToQuantum(16))
-    MaxColor=16;
+    MaxColor=2U;
+  else if (MaxColor < ScaleCharToQuantum(16U))
+    MaxColor=16U;
   return (MaxColor);
 }
 \f
@@ -290,10 +293,18 @@ static unsigned int GetCutColors(Image *image)
 %
 %
 */
+#define ThrowCUTReaderException(code_,reason_,image_) \
+{ \
+  if (palette != (Image *) NULL)              \
+    DestroyImage(palette);                    \
+  if (clone_info != (ImageInfo *) NULL)       \
+    DestroyImageInfo(clone_info);             \
+  ThrowReaderException(code_,reason_,image_); \
+}
 static Image *ReadCUTImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
-  Image *image,*palette;
-  ImageInfo *clone_info;
+  Image *image,*palette = (Image *) NULL;
+  ImageInfo *clone_info = (ImageInfo *) NULL;
   unsigned int status;
   unsigned long EncodedByte;
   unsigned char RunCount,RunValue,RunCountMasked;
@@ -318,15 +329,13 @@ static Image *ReadCUTImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Read CUT image.
   */
-  palette=NULL;
-  clone_info=NULL;
   Header.Width=ReadBlobLSBShort(image);
   Header.Height=ReadBlobLSBShort(image);
   Header.Reserved=ReadBlobLSBShort(image);
 
   if (Header.Width==0 || Header.Height==0 || Header.Reserved!=0 ||
       (Header.Width > INT_MAX) || (Header.Height > INT_MAX) )
-  CUT_KO:  ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+  CUT_KO:  ThrowCUTReaderException(CorruptImageError,ImproperImageHeader,image);
 
   /*---This code checks first line of image---*/
   EncodedByte=ReadBlobLSBShort(image);
@@ -362,12 +371,11 @@ static Image *ReadCUTImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if (image_info->ping) goto Finish;
 
   if (CheckImagePixelLimits(image, exception) != MagickPass)
-    ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+    ThrowCUTReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
 
   /* ----- Do something with palette ----- */
   if ((clone_info=CloneImageInfo(image_info)) == NULL) goto NoPalette;
 
-
   i=(long) strlen(clone_info->filename);
   j=i;
   while (--i>0)
@@ -384,10 +392,13 @@ static Image *ReadCUTImage(const ImageInfo *image_info,ExceptionInfo *exception)
         }
     }
 
-  (void) strcpy(clone_info->filename+i,".PAL");
+  if (i <= 0)
+    goto NoPalette;
+
+  (void) strlcpy(clone_info->filename+i,".PAL",sizeof(clone_info->filename)-i);
   if ((clone_info->file=fopen(clone_info->filename,"rb"))==NULL)
     {
-      (void) strcpy(clone_info->filename+i,".pal");
+      (void) strlcpy(clone_info->filename+i,".pal",sizeof(clone_info->filename)-i);
       if ((clone_info->file=fopen(clone_info->filename,"rb"))==NULL)
         {
           clone_info->filename[i]=0;
@@ -428,7 +439,7 @@ static Image *ReadCUTImage(const ImageInfo *image_info,ExceptionInfo *exception)
       (void) ReadBlob(palette,20,PalHeader.PaletteId);
 
       if (EOFBlob(image))
-        ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+        ThrowCUTReaderException(CorruptImageError,UnexpectedEndOfFile,image);
 
       if (PalHeader.MaxIndex<1) goto ErasePalette;
       image->colors=PalHeader.MaxIndex+1;
@@ -468,7 +479,7 @@ static Image *ReadCUTImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
         }
       if (EOFBlob(image))
-        ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+        ThrowCUTReaderException(CorruptImageError,UnexpectedEndOfFile,image);
     }
 
 
@@ -482,8 +493,11 @@ static Image *ReadCUTImage(const ImageInfo *image_info,ExceptionInfo *exception)
         {
         NoMemory:
           if (clone_info != NULL)
-            DestroyImageInfo(clone_info);
-          ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+            {
+              DestroyImageInfo(clone_info);
+              clone_info=(ImageInfo *) NULL;
+            }
+          ThrowCUTReaderException(ResourceLimitError,MemoryAllocationFailed,image);
         }
 
       for (i=0; i < (long)image->colors; i++)
@@ -564,6 +578,8 @@ static Image *ReadCUTImage(const ImageInfo *image_info,ExceptionInfo *exception)
               for (i=0; i < (long)image->rows; i++)
                 {
                   q=SetImagePixels(image,0,i,image->columns,1);
+                  if (q == (PixelPacket *) NULL)
+                    break;
                   for (j=0; j < (long)image->columns; j++)
                     {
                       if (q->red==ScaleCharToQuantum(1))
@@ -580,10 +596,18 @@ static Image *ReadCUTImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
  Finish:
   if (BImgBuff!=NULL) MagickFreeMemory(BImgBuff);
-  if (palette!=NULL) DestroyImage(palette);
-  if (clone_info!=NULL) DestroyImageInfo(clone_info);
+  if (palette!=NULL)
+    {
+      DestroyImage(palette);
+      palette=(Image *) NULL;
+    }
+  if (clone_info!=NULL)
+    {
+      DestroyImageInfo(clone_info);
+      clone_info=(ImageInfo *) NULL;
+    }
   if (EOFBlob(image))
-    ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+    ThrowCUTReaderException(CorruptImageError,UnexpectedEndOfFile,image);
   CloseBlob(image);
   return(image);
 }
index f77a3fe..a693f0d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2009 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -136,7 +136,7 @@ typedef struct _DicomStream
     msb_state;
 
   Dicom_PI
-    phot_interp;  
+    phot_interp;
 
   double
     window_center,
@@ -183,9 +183,9 @@ typedef struct _DicomStream
     lower_lim;
 
   Quantum
-    *rescale_map;
+    *rescale_map; /* Allocated with dcm->max_value_in+1 entries */
 
-#if defined(USE_GRAYMAP)  
+#if defined(USE_GRAYMAP)
   unsigned short
     *graymap;
 #endif
@@ -2851,6 +2851,7 @@ static MagickPassFail IsDCM(const unsigned char *magick,const size_t length)
 \f
 static MagickPassFail DCM_InitDCM(DicomStream *dcm,int verbose)
 {
+  (void) memset(dcm,0,sizeof(*dcm));
   dcm->columns=0;
   dcm->rows=0;
   dcm->samples_per_pixel=1;
@@ -2891,6 +2892,16 @@ static MagickPassFail DCM_InitDCM(DicomStream *dcm,int verbose)
   return MagickPass;
 }
 \f
+static void DCM_DestroyDCM(DicomStream *dcm)
+{
+  MagickFreeMemory(dcm->offset_arr);
+  MagickFreeMemory(dcm->data);
+#if defined(USE_GRAYMAP)
+  MagickFreeMemory(dcm->graymap);
+#endif
+  MagickFreeMemory(dcm->rescale_map);
+}
+\f
 /*
   Parse functions for DICOM elements
 */
@@ -2972,7 +2983,7 @@ static MagickPassFail funcDCM_TriggerTime(Image *image,DicomStream *dcm,Exceptio
   ARG_NOT_USED(exception);
 
   (void) SetImageAttribute(image,"TriggerTime",(char *) dcm->data);
-  return MagickPass;  
+  return MagickPass;
 }
 
 static MagickPassFail funcDCM_FieldOfView(Image *image,DicomStream *dcm,ExceptionInfo *exception)
@@ -3001,7 +3012,7 @@ static MagickPassFail funcDCM_ImageOrientation(Image *image,DicomStream *dcm,Exc
 {
   ARG_NOT_USED(exception);
   (void) SetImageAttribute(image,"ImageOrientation",(char *) dcm->data);
-  return MagickPass; 
+  return MagickPass;
 }
 
 static MagickPassFail funcDCM_SliceLocation(Image *image,DicomStream *dcm,ExceptionInfo *exception)
@@ -3022,7 +3033,7 @@ static MagickPassFail funcDCM_SamplesPerPixel(Image *image,DicomStream *dcm,Exce
 static MagickPassFail funcDCM_PhotometricInterpretation(Image *image,DicomStream *dcm,ExceptionInfo *exception)
 {
   char photometric[MaxTextExtent];
-  int i;
+  unsigned int i;
 
   ARG_NOT_USED(image);
   ARG_NOT_USED(exception);
@@ -3033,7 +3044,8 @@ static MagickPassFail funcDCM_PhotometricInterpretation(Image *image,DicomStream
       return MagickFail;
     }
 
-  for (i=0; i < (long) Min(dcm->length, MaxTextExtent-1); i++)
+  (void) memset(photometric,0,sizeof(photometric));
+  for (i=0; i < Min(dcm->length, MaxTextExtent-1); i++)
     photometric[i]=dcm->data[i];
   photometric[i]='\0';
 
@@ -3110,9 +3122,18 @@ static MagickPassFail funcDCM_BitsStored(Image *image,DicomStream *dcm,Exception
 
   dcm->significant_bits=dcm->datum;
   dcm->bytes_per_pixel=1;
+  if ((dcm->significant_bits == 0U) || (dcm->significant_bits > 16U))
+    {
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "DICOM significant_bits = %u",
+                              dcm->significant_bits);
+      ThrowException(exception,CorruptImageError,ImproperImageHeader,image->filename);
+      return MagickFail;
+    }
   if (dcm->significant_bits > 8)
     dcm->bytes_per_pixel=2;
-  dcm->max_value_in=(1 << dcm->significant_bits)-1;
+  dcm->max_value_in=MaxValueGivenBits(dcm->significant_bits);
   dcm->max_value_out=dcm->max_value_in;
   image->depth=Min(dcm->significant_bits,QuantumDepth);
   return MagickPass;
@@ -3262,7 +3283,7 @@ static MagickPassFail funcDCM_PaletteDescriptor(Image *image,DicomStream *dcm,Ex
 
 static MagickPassFail funcDCM_LUT(Image *image,DicomStream *dcm,ExceptionInfo *exception)
 {
-#if defined(USE_GRAYMAP)  
+#if defined(USE_GRAYMAP)
   /*
     1200 = grey, LUT data 3006 = LUT data
   */
@@ -3316,6 +3337,10 @@ static MagickPassFail funcDCM_Palette(Image *image,DicomStream *dcm,ExceptionInf
       return MagickFail;
     }
 
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Palette with %" MAGICK_SIZE_T_F "u entries...",
+                          (MAGICK_SIZE_T) dcm->length);
   /*
     Initialize colormap (entries are always 16 bit)
     1201/2/3 = red/green/blue palette
@@ -3345,9 +3370,9 @@ static MagickPassFail funcDCM_Palette(Image *image,DicomStream *dcm,ExceptionInf
   for (i=0; i < (long) image->colors; i++)
     {
       if (dcm->msb_state == DCM_MSB_BIG)
-        index=(*p << 8) | *(p+1);
+        index=((unsigned short) *p << 8) | (unsigned short) *(p+1);
       else
-        index=*p | (*(p+1) << 8);
+        index=(unsigned short) *p | ((unsigned short) *(p+1) << 8);
       if (dcm->element == 0x1201)
         image->colormap[i].red=ScaleShortToQuantum(index);
       else if (dcm->element == 0x1202)
@@ -3367,7 +3392,7 @@ static magick_uint8_t DCM_RLE_ReadByte(Image *image, DicomStream *dcm)
         rep_ct,
         rep_char;
 
-      /* We need to read the next command pair */     
+      /* We need to read the next command pair */
       if (dcm->frag_bytes <= 2)
         dcm->frag_bytes = 0;
       else
@@ -3408,7 +3433,8 @@ static magick_uint8_t DCM_RLE_ReadByte(Image *image, DicomStream *dcm)
 
 static magick_uint16_t DCM_RLE_ReadShort(Image *image, DicomStream *dcm)
 {
-  return (DCM_RLE_ReadByte(image,dcm) << 4) | DCM_RLE_ReadByte(image,dcm);
+  return (((magick_uint16_t) DCM_RLE_ReadByte(image,dcm) << 4) |
+          (magick_uint16_t) DCM_RLE_ReadByte(image,dcm));
 }
 
 static MagickPassFail DCM_ReadElement(Image *image, DicomStream *dcm,ExceptionInfo *exception)
@@ -3545,7 +3571,7 @@ static MagickPassFail DCM_ReadElement(Image *image, DicomStream *dcm,ExceptionIn
   dcm->datum=0;
   if (dcm->quantum == 4)
     {
-      dcm->datum=(long) dcm->funcReadLong(image);
+      dcm->datum=dcm->funcReadLong(image);
       if (EOFBlob(image))
         {
           ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,image->filename);
@@ -3634,7 +3660,7 @@ static MagickPassFail DCM_ReadElement(Image *image, DicomStream *dcm,ExceptionIn
     }
   else if ((dcm->length == 1) && (dcm->quantum == 4))
     {
-      dcm->datum=(long) dcm->funcReadLong(image);
+      dcm->datum=dcm->funcReadLong(image);
       if (EOFBlob(image))
         {
           ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,image->filename);
@@ -3646,6 +3672,11 @@ static MagickPassFail DCM_ReadElement(Image *image, DicomStream *dcm,ExceptionIn
       size_t
         size;
 
+      if (dcm->length > ((size_t) GetBlobSize(image)))
+        {
+          ThrowException(exception,CorruptImageError,InsufficientImageDataInFile,image->filename);
+          return MagickFail;
+        }
       if (dcm->length > ((~0UL)/dcm->quantum))
         {
           ThrowException(exception,CorruptImageError,ImproperImageHeader,image->filename);
@@ -3657,7 +3688,12 @@ static MagickPassFail DCM_ReadElement(Image *image, DicomStream *dcm,ExceptionIn
           ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,image->filename);
           return MagickFail;
         }
-      size=dcm->quantum*dcm->length;
+      size=MagickArraySize(dcm->quantum,dcm->length);
+      if (size == 0)
+        {
+          ThrowException(exception,CorruptImageError,ImproperImageHeader,image->filename);
+          return MagickFail;
+        }
       if (ReadBlob(image,size,(char *) dcm->data) != size)
         {
           ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,image->filename);
@@ -3755,20 +3791,38 @@ static MagickPassFail DCM_SetupRescaleMap(Image *image,DicomStream *dcm,Exceptio
     Xw_min,
     Xw_max;
 
-  unsigned long
+  unsigned int
     i;
 
   if (dcm->rescaling == DCM_RS_NONE)
     return MagickPass;
 
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Set up rescale map for input range of %u"
+                          " (%u entries)...",
+                          dcm->max_value_in+1,MaxMap+1);
+
+  /*
+    The rescale map must be limited to MaxMap+1 entries, which is 256
+    or 65536, depending on QuantumDepth.  Using a QuantumDepth less
+    than 16 for DICOM is a bad idea.
+
+    The dcm->significant_bits value is limited to 16 (larger values
+    are outright rejected) so dcm->max_value_in and dcm->max_value_out
+    are limited to 65535.
+  */
+
   if (dcm->rescale_map == (Quantum *) NULL)
     {
-      dcm->rescale_map=MagickAllocateArray(Quantum *,dcm->max_value_in+1,sizeof(Quantum));
+      size_t num_entries = Max(MaxMap+1,dcm->max_value_in+1);
+      dcm->rescale_map=MagickAllocateArray(Quantum *,num_entries,sizeof(Quantum));
       if (dcm->rescale_map == NULL)
         {
           ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,image->filename);
           return MagickFail;
         }
+      (void) memset(dcm->rescale_map,0,num_entries*sizeof(Quantum));
     }
 
   if (dcm->window_width == 0)
@@ -3798,7 +3852,7 @@ static MagickPassFail DCM_SetupRescaleMap(Image *image,DicomStream *dcm,Exceptio
   Xw_max = win_center - 0.5 + ((win_width-1)/2);
   for (i=0; i < (dcm->max_value_in+1); i++)
     {
-      if ((dcm->pixel_representation == 1) && (i >= (1U << (dcm->significant_bits-1))))
+      if ((dcm->pixel_representation == 1) && (i >= MaxValueGivenBits(dcm->significant_bits)))
         Xr = -((dcm->max_value_in+1-i) * dcm->rescale_slope) + dcm->rescale_intercept;
       else
         Xr = (i * dcm->rescale_slope) + dcm->rescale_intercept;
@@ -3808,10 +3862,11 @@ static MagickPassFail DCM_SetupRescaleMap(Image *image,DicomStream *dcm,Exceptio
         dcm->rescale_map[i]=dcm->max_value_out;
       else
         dcm->rescale_map[i]=(Quantum)(((Xr-Xw_min)/(win_width-1))*dcm->max_value_out+0.5);
-    }  
+    }
   if (dcm->phot_interp == DCM_PI_MONOCHROME1)
-    for (i=0; i < (dcm->max_value_in+1); i++)
+    for (i=0; i <= dcm->max_value_in; i++)
       dcm->rescale_map[i]=dcm->max_value_out-dcm->rescale_map[i];
+
   return MagickPass;
 }
 \f
@@ -3877,6 +3932,15 @@ void DCM_SetRescaling(DicomStream *dcm,int avoid_scaling)
   dcm->rescaling=DCM_RS_PRE;
 }
 \f
+/*
+  FIXME: This code is totally broken since DCM_SetupRescaleMap
+  populates dcm->rescale_map and dcm->rescale_map has
+  dcm->max_value_in+1 entries, which has nothing to do with the number
+  of colormap entries or the range of MaxRGB.
+
+  Disabling this whole function and code invoking it until someone
+  figures it out.
+*/
 static MagickPassFail DCM_PostRescaleImage(Image *image,DicomStream *dcm,unsigned long ScanLimits,ExceptionInfo *exception)
 {
   unsigned long
@@ -3947,7 +4011,8 @@ static MagickPassFail DCM_PostRescaleImage(Image *image,DicomStream *dcm,unsigne
         }
     }
 
-  DCM_SetupRescaleMap(image,dcm,exception);
+  if (DCM_SetupRescaleMap(image,dcm,exception) == MagickFail)
+    return MagickFail;
   for (y=0; y < image->rows; y++)
     {
       q=GetImagePixels(image,0,y,image->columns,1);
@@ -3988,10 +4053,10 @@ static MagickPassFail DCM_PostRescaleImage(Image *image,DicomStream *dcm,unsigne
 \f
 static MagickPassFail DCM_ReadPaletteImage(Image *image,DicomStream *dcm,ExceptionInfo *exception)
 {
-  long
+  unsigned long
     y;
 
-  register long
+  register unsigned long
     x;
 
   register PixelPacket
@@ -4008,13 +4073,17 @@ static MagickPassFail DCM_ReadPaletteImage(Image *image,DicomStream *dcm,Excepti
 
   byte=0;
 
-  for (y=0; y < (long) image->rows; y++)
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Reading Palette image...");
+
+  for (y=0; y < image->rows; y++)
     {
       q=SetImagePixels(image,0,y,image->columns,1);
       if (q == (PixelPacket *) NULL)
         return MagickFail;
       indexes=AccessMutableIndexes(image);
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < image->columns; x++)
         {
           if (dcm->bytes_per_pixel == 1)
             {
@@ -4070,6 +4139,8 @@ static MagickPassFail DCM_ReadPaletteImage(Image *image,DicomStream *dcm,Excepti
               index=(IndexPacket) (index);
               VerifyColormapIndex(image,index);
               indexes[x]=index;
+              *q=image->colormap[index];
+              q++;
             }
 
           if (EOFBlob(image))
@@ -4092,16 +4163,16 @@ static MagickPassFail DCM_ReadPaletteImage(Image *image,DicomStream *dcm,Excepti
 \f
 static MagickPassFail DCM_ReadGrayscaleImage(Image *image,DicomStream *dcm,ExceptionInfo *exception)
 {
-  long
+  unsigned long
     y;
 
-  register long
+  register unsigned long
     x;
 
   register PixelPacket
     *q;
 
-#if defined(GRAYSCALE_USES_PALETTE)
+#if defined(GRAYSCALE_USES_PALETTE) /* not used */
   register IndexPacket
     *indexes;
 #endif
@@ -4112,18 +4183,29 @@ static MagickPassFail DCM_ReadGrayscaleImage(Image *image,DicomStream *dcm,Excep
   unsigned char
     byte;
 
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Reading Grayscale %lux%lu image...",image->columns,image->rows);
+
+#if !defined(GRAYSCALE_USES_PALETTE)
+  /*
+    If a palette was provided, the image may be in PseudoClass
+  */
+  image->storage_class=DirectClass;
+#endif
+
   dcm->lower_lim = dcm->max_value_in;
   dcm->upper_lim = -(dcm->lower_lim);
   byte=0;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < image->rows; y++)
     {
-      q=SetImagePixels(image,0,y,image->columns,1);
+      q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
       if (q == (PixelPacket *) NULL)
         return MagickFail;
-#if defined(GRAYSCALE_USES_PALETTE)
+#if defined(GRAYSCALE_USES_PALETTE) /* not used */
       indexes=AccessMutableIndexes(image);
 #endif
-      for (x=0; x < (long) image->columns; x++)
+      for (x=0; x < image->columns; x++)
         {
           if (dcm->bytes_per_pixel == 1)
             {
@@ -4176,17 +4258,21 @@ static MagickPassFail DCM_ReadGrayscaleImage(Image *image,DicomStream *dcm,Excep
               if ((int) l > dcm->upper_lim)
                 dcm->upper_lim = l;
             }
-#if defined(GRAYSCALE_USES_PALETTE)
+#if defined(GRAYSCALE_USES_PALETTE) /* not used */
           if (dcm->rescaling == DCM_RS_PRE)
             indexes[x]=dcm->rescale_map[index];
           else
             indexes[x]=index;
 #else
-          if (dcm->rescaling == DCM_RS_PRE)
-            index=dcm->rescale_map[index];
+          if ((dcm->rescaling == DCM_RS_PRE) &&
+              (dcm->rescale_map != (Quantum *) NULL))
+            {
+              index=dcm->rescale_map[index];
+            }
           q->red=index;
           q->green=index;
           q->blue=index;
+          q->opacity=OpaqueOpacity;
           q++;
 #endif
           if (EOFBlob(image))
@@ -4195,7 +4281,7 @@ static MagickPassFail DCM_ReadGrayscaleImage(Image *image,DicomStream *dcm,Excep
               return MagickFail;
             }
         }
-      if (!SyncImagePixels(image))
+      if (!SyncImagePixelsEx(image,exception))
         return MagickFail;
       if (image->previous == (Image *) NULL)
         if (QuantumTick(y,image->rows))
@@ -4217,13 +4303,28 @@ static MagickPassFail DCM_ReadPlanarRGBImage(Image *image,DicomStream *dcm,Excep
   register PixelPacket
     *q;
 
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Reading Planar RGB %s compressed image with %u planes...",
+                          (dcm->transfer_syntax == DCM_TS_RLE ? "RLE" : "not"),
+                          dcm->samples_per_pixel);
+  /*
+    Force image to DirectClass since we are only updating DirectClass
+    representation.  The image may be in PseudoClass if we were
+    previously provided with a Palette.
+  */
+  image->storage_class=DirectClass;
+
   for (plane=0; plane < dcm->samples_per_pixel; plane++)
     {
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "  Plane %lu...",plane);
       for (y=0; y < image->rows; y++)
         {
           q=GetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
-            return MagickFail;
+              return MagickFail;
 
           for (x=0; x < image->columns; x++)
             {
@@ -4292,6 +4393,17 @@ static MagickPassFail DCM_ReadRGBImage(Image *image,DicomStream *dcm,ExceptionIn
   green=0;
   blue=0;
 
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Reading RGB image...");
+
+  /*
+    Force image to DirectClass since we are only updating DirectClass
+    representation.  The image may be in PseudoClass if we were
+    previously provided with a Palette.
+  */
+  image->storage_class=DirectClass;
+
   for (y=0; y < image->rows; y++)
     {
       q=GetImagePixels(image,0,y,image->columns,1);
@@ -4334,7 +4446,8 @@ static MagickPassFail DCM_ReadRGBImage(Image *image,DicomStream *dcm,ExceptionIn
           red&=dcm->max_value_in;
           green&=dcm->max_value_in;
           blue&=dcm->max_value_in;
-          if (dcm->rescaling == DCM_RS_PRE)
+          if ((dcm->rescaling == DCM_RS_PRE) &&
+              (dcm->rescale_map != (Quantum *) NULL))
             {
               red=dcm->rescale_map[red];
               green=dcm->rescale_map[green];
@@ -4344,6 +4457,7 @@ static MagickPassFail DCM_ReadRGBImage(Image *image,DicomStream *dcm,ExceptionIn
           q->red=(Quantum) red;
           q->green=(Quantum) green;
           q->blue=(Quantum) blue;
+          q->opacity=OpaqueOpacity;
           q++;
           if (EOFBlob(image))
             {
@@ -4371,7 +4485,8 @@ static MagickPassFail DCM_ReadOffsetTable(Image *image,DicomStream *dcm,Exceptio
     length,
     i;
 
-  tag=(dcm->funcReadShort(image) << 16) | dcm->funcReadShort(image);
+  tag=((magick_uint32_t) dcm->funcReadShort(image) << 16) |
+    (magick_uint32_t) dcm->funcReadShort(image);
   length=dcm->funcReadLong(image);
   if (tag != 0xFFFEE000)
     return MagickFail;
@@ -4386,7 +4501,7 @@ static MagickPassFail DCM_ReadOffsetTable(Image *image,DicomStream *dcm,Exceptio
       return MagickFail;
     }
 
-  dcm->offset_arr=MagickAllocateArray(magick_uint32_t *,dcm->offset_ct,sizeof(magick_uint32_t));  
+  dcm->offset_arr=MagickAllocateArray(magick_uint32_t *,dcm->offset_ct,sizeof(magick_uint32_t));
   if (dcm->offset_arr == (magick_uint32_t *) NULL)
     {
       ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,image->filename);
@@ -4444,6 +4559,14 @@ static MagickPassFail DCM_ReadNonNativeImages(Image **image,const ImageInfo *ima
   if (DCM_ReadOffsetTable(*image,dcm,exception) == MagickFail)
     return MagickFail;
 
+  if (dcm->number_scenes == 0U)
+    {
+      ThrowException(exception,CorruptImageError,
+                     ImageFileHasNoScenes,
+                     image_info->filename);
+      return MagickFail;
+    }
+
   status=MagickPass;
   for (scene=0; scene < dcm->number_scenes; scene++)
     {
@@ -4463,7 +4586,8 @@ static MagickPassFail DCM_ReadNonNativeImages(Image **image,const ImageInfo *ima
           /*
             Read fragment tag
           */
-          tag=(dcm->funcReadShort(*image) << 16) | dcm->funcReadShort(*image);
+          tag=(((magick_uint32_t) dcm->funcReadShort(*image) << 16) |
+               (magick_uint32_t) dcm->funcReadShort(*image));
           length=dcm->funcReadLong(*image);
           if (EOFBlob(*image))
             {
@@ -4548,7 +4672,7 @@ static MagickPassFail DCM_ReadNonNativeImages(Image **image,const ImageInfo *ima
                 dcm->bytes_per_pixel=1;
                 if (dcm->significant_bits > 8)
                   dcm->bytes_per_pixel=2;
-                dcm->max_value_in=(1 << dcm->significant_bits)-1;
+                dcm->max_value_in=MaxValueGivenBits(dcm->significant_bits);
                 dcm->max_value_out=dcm->max_value_in;
                 status=DCM_PostRescaleImage(next_image,dcm,True,exception);
               }
@@ -4561,11 +4685,33 @@ static MagickPassFail DCM_ReadNonNativeImages(Image **image,const ImageInfo *ima
               else
                 AppendImageToList(&image_list,next_image);
             }
+          else if (next_image != (Image *) NULL)
+            {
+              DestroyImage(next_image);
+              next_image=(Image *) NULL;
+            }
         }
       (void) LiberateTemporaryFile(filename);
+
+      if (status == MagickFail)
+        break;
+    }
+  if (EOFBlob(*image))
+    {
+      status = MagickFail;
+      ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,(*image)->filename);
+    }
+
+  if (status == MagickFail)
+    {
+      DestroyImageList(image_list);
+      image_list = (Image *) NULL;
+    }
+  else
+    {
+      DestroyImage(*image);
+      *image=image_list;
     }
-  DestroyImage(*image);
-  *image=image_list;
   return status;
 }
 \f
@@ -4600,6 +4746,11 @@ static MagickPassFail DCM_ReadNonNativeImages(Image **image,const ImageInfo *ima
 %
 %
 */
+#define ThrowDCMReaderException(code_,reason_,image_)   \
+  {                                                     \
+    DCM_DestroyDCM(&dcm);                               \
+    ThrowReaderException(code_,reason_,image_);         \
+}
 static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
   char
@@ -4627,18 +4778,19 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   assert(image_info->signature == MagickSignature);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
+  (void) DCM_InitDCM(&dcm,image_info->verbose);
   image=AllocateImage(image_info);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFail)
-    ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+    ThrowDCMReaderException(FileOpenError,UnableToOpenFile,image);
 
   /*
     Read DCM preamble
   */
   if ((count=ReadBlob(image,128,(char *) magick)) != 128)
-    ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+    ThrowDCMReaderException(CorruptImageError,UnexpectedEndOfFile,image);
   if ((count=ReadBlob(image,4,(char *) magick)) != 4)
-    ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+    ThrowDCMReaderException(CorruptImageError,UnexpectedEndOfFile,image);
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                           "magick: \"%.4s\"",magick);
@@ -4648,7 +4800,6 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Loop to read DCM image header one element at a time
   */
-  (void) DCM_InitDCM(&dcm,image_info->verbose);
   status=DCM_ReadElement(image,&dcm,exception);
   while ((status == MagickPass) && ((dcm.group != 0x7FE0) || (dcm.element != 0x0010)))
     {
@@ -4660,9 +4811,12 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
         status=pfunc(image,&dcm,exception);
       MagickFreeMemory(dcm.data);
       dcm.data = NULL;
+      dcm.length = 0;
       if (status == MagickPass)
         status=DCM_ReadElement(image,&dcm,exception);
     }
+  if (status == MagickFail)
+    goto dcm_read_failure;
 #if defined(IGNORE_WINDOW_FOR_UNSPECIFIED_SCALE_TYPE)
   if (dcm.rescale_type == DCM_RT_UNSPECIFIED)
     {
@@ -4675,32 +4829,42 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Now process the image data
   */
+  if ((dcm.columns == 0) || (dcm.rows == 0))
+    {
+      ThrowException(exception,CorruptImageError,ImproperImageHeader,image->filename);
+      status=MagickFail;
+    }
+  else if ((dcm.samples_per_pixel == 0) || (dcm.samples_per_pixel > 4))
+    {
+      ThrowException(exception,CorruptImageError,ImproperImageHeader,image->filename);
+      status=MagickFail;
+    }
+  else if ((dcm.transfer_syntax != DCM_TS_IMPL_LITTLE) &&
+           (dcm.transfer_syntax != DCM_TS_EXPL_LITTLE) &&
+           (dcm.transfer_syntax != DCM_TS_EXPL_BIG) &&
+           (dcm.transfer_syntax != DCM_TS_RLE))
+    {
+      status=DCM_ReadNonNativeImages(&image,image_info,&dcm,exception);
+      dcm.number_scenes=0;
+    }
+  else if (dcm.rescaling != DCM_RS_POST)
+    {
+      status=DCM_SetupRescaleMap(image,&dcm,exception);
+    }
+
   if (status == MagickFail)
-    ; 
-  else
-    if ((dcm.columns == 0) || (dcm.rows == 0))
-      {
-        ThrowException(exception,CorruptImageError,ImproperImageHeader,image->filename);
-        status=MagickFail;
-      }
-    else if ((dcm.transfer_syntax != DCM_TS_IMPL_LITTLE) &&
-             (dcm.transfer_syntax != DCM_TS_EXPL_LITTLE) &&
-             (dcm.transfer_syntax != DCM_TS_EXPL_BIG) &&
-             (dcm.transfer_syntax != DCM_TS_RLE))
-      {
-        status=DCM_ReadNonNativeImages(&image,image_info,&dcm,exception);
-        dcm.number_scenes=0;
-      }
-    else if (dcm.rescaling != DCM_RS_POST)
-      {
-        status=DCM_SetupRescaleMap(image,&dcm,exception);
-      }
+    goto dcm_read_failure;
 
   if (dcm.transfer_syntax == DCM_TS_RLE)
     status=DCM_ReadOffsetTable(image,&dcm,exception);
 
   /* Loop to process all scenes in image */
-  if (status == MagickFail) dcm.number_scenes = 0;
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "DICOM has %d scenes", dcm.number_scenes);
+  if (status == MagickFail)
+    goto dcm_read_failure;
+
   for (scene=0; scene < (long) dcm.number_scenes; scene++)
     {
       if (dcm.transfer_syntax == DCM_TS_RLE)
@@ -4716,14 +4880,15 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             SeekBlob(image,dcm.frag_bytes,SEEK_CUR);
 
           /*
-           Read fragment tag
+            Read fragment tag
           */
-          tag=(dcm.funcReadShort(image) << 16) | dcm.funcReadShort(image);
+          tag=(((magick_uint32_t) dcm.funcReadShort(image)) << 16) |
+            (magick_uint32_t) dcm.funcReadShort(image);
           length=dcm.funcReadLong(image);
           if ((tag != 0xFFFEE000) || (length <= 64) || EOFBlob(image))
             {
               status=MagickFail;
-              ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+              ThrowDCMReaderException(CorruptImageError,UnexpectedEndOfFile,image);
               break;
             }
 
@@ -4743,7 +4908,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           if (EOFBlob(image))
             {
               status=MagickFail;
-              ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+              ThrowDCMReaderException(CorruptImageError,UnexpectedEndOfFile,image);
               break;
             }
           if (dcm.rle_seg_ct > 1)
@@ -4760,6 +4925,9 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
       image->columns=dcm.columns;
       image->rows=dcm.rows;
       image->interlace=(dcm.interlace==1)?PlaneInterlace:NoInterlace;
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Scene[%d]: %lux%lu", scene, image->columns, image->rows);
 #if defined(GRAYSCALE_USES_PALETTE)
       if ((image->colormap == (PixelPacket *) NULL) && (dcm.samples_per_pixel == 1))
 #else
@@ -4774,7 +4942,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
         break;
 
       if (CheckImagePixelLimits(image, exception) != MagickPass)
-        ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+        ThrowDCMReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
 
       /*
         Process image according to type
@@ -4800,15 +4968,23 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           ((dcm.phot_interp == DCM_PI_MONOCHROME1) ||
            (dcm.phot_interp == DCM_PI_MONOCHROME2)))
         {
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Normalizing image channels...");
           NormalizeImage(image);
         }
       else
-        if (dcm.rescaling == DCM_RS_POST)
-          {
-            status = DCM_PostRescaleImage(image,&dcm,False,exception);
-            if (status != MagickPass)
-              break;
-          }
+        {
+          if (dcm.rescaling == DCM_RS_POST)
+            {
+              if (image->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Rescaling image channels...");
+              status = DCM_PostRescaleImage(image,&dcm,False,exception);
+              if (status != MagickPass)
+                break;
+            }
+        }
 
       /*
         Proceed to next image.
@@ -4839,23 +5015,25 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Free allocated resources
   */
-
-  if (dcm.offset_arr != NULL)
-    MagickFreeMemory(dcm.offset_arr);    
-  if (dcm.data != NULL)
-    MagickFreeMemory(dcm.data);
-#if defined(USE_GRAYMAP)
-  if (dcm.graymap != (unsigned short *) NULL)
-    MagickFreeMemory(dcm.graymap);
-#endif
-  if (dcm.rescale_map != (Quantum *) NULL)
-    MagickFreeMemory(dcm.rescale_map);
+ dcm_read_failure:
+  DCM_DestroyDCM(&dcm);
   if (status == MagickPass)
     {
-      while (image->previous != (Image *) NULL)
-        image=image->previous;
-      CloseBlob(image);
-      return(image);
+      /* It is possible to have success status yet have no image */
+      if (image != (Image *) NULL)
+        {
+          while (image->previous != (Image *) NULL)
+            image=image->previous;
+          CloseBlob(image);
+          return(image);
+        }
+      else
+        {
+          ThrowException(exception,CorruptImageError,
+                         ImageFileDoesNotContainAnyImageData,
+                         image_info->filename);
+          return (Image *) NULL;
+        }
     }
   else
     {
index 30c3dde..20f2a2b 100644 (file)
@@ -148,10 +148,10 @@ ModuleExport void RegisterDCRAWImage(void)
 {
   unsigned int
     i;
-  
+
   MagickInfo
     *entry;
-  
+
   for (i=0; dcraw_formats[i].id != NULL; i++)
     {
       entry=SetMagickInfo(dcraw_formats[i].id);
@@ -186,7 +186,7 @@ ModuleExport void UnregisterDCRAWImage(void)
 {
   unsigned int
     i;
-  
+
   for (i=0; dcraw_formats[i].id != NULL; i++)
     (void) UnregisterMagickInfo(dcraw_formats[i].id);
 }
index 55befac..a84670d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
 #include "magick/utility.h"
 \f
 /*
+  Macro definitions (from Windows wingdi.h).
+*/
+#undef BI_RLE8
+#define BI_RLE8  1
+\f
+/*
   Typedef declarations.
 */
 typedef struct _DIBInfo
@@ -76,7 +82,7 @@ typedef struct _DIBInfo
     blue_mask,
     alpha_mask;
 
-  long
+  magick_int32_t
     colorspace;
 
   PointInfo
@@ -107,7 +113,7 @@ static void LogDIBInfo(const DIBInfo *dib_info)
                         "    Bits Per Pixel:       %u\n"
                         "    Compression:          %u\n"
                         "    Size Of Bitmap:       %u\n"
-                        "    Horzontal Resolution: %u\n"
+                        "    Horizontal Resolution:%u\n"
                         "    Vertical Resolution:  %u\n"
                         "    Colors Used:          %u\n"
                         "    Colors Important:     %u",
@@ -156,19 +162,23 @@ static void LogDIBInfo(const DIBInfo *dib_info)
 %    o pixels:  The address of a byte (8 bits) array of pixel data created by
 %      the decoding process.
 %
+%    o pixels_size: The size of the allocated buffer array.
+%
 %
 */
-static unsigned int DecodeImage(Image *image,const unsigned long compression,
-  unsigned char *pixels)
+static MagickPassFail DecodeImage(Image *image,const unsigned long compression,
+                                  unsigned char *pixels, const size_t pixels_size)
 {
-  long
-    byte,
-    count,
+  unsigned long
+    x,
     y;
 
-  register long
-    i,
-    x;
+  unsigned int
+    i;
+
+  int
+    byte,
+    count;
 
   register unsigned char
     *q;
@@ -178,108 +188,175 @@ static unsigned int DecodeImage(Image *image,const unsigned long compression,
 
   assert(image != (Image *) NULL);
   assert(pixels != (unsigned char *) NULL);
-  (void) memset(pixels,0,image->columns*image->rows);
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "  Decoding RLE compressed pixels to"
+                          " %" MAGICK_SIZE_T_F "u bytes",
+                          image->rows*image->columns);
+
   byte=0;
   x=0;
   q=pixels;
-  end=pixels + (size_t) image->columns*image->rows;
-  for (y=0; y < (long) image->rows; )
-  {
-    if (q < pixels || q  >= end)
-      break;
-    count=ReadBlobByte(image);
-    if (count == EOF)
-      break;
-    if (count != 0)
-      {
-        count=Min(count, end - q);
-        /*
-          Encoded mode.
-        */
-        byte=ReadBlobByte(image);
-        for (i=0; i < count; i++)
+  end=pixels + pixels_size;
+  /*
+    Decompress sufficient data to support the number of pixels (or
+    rows) in the image and then return.
+
+    Do not wait to read the final EOL and EOI markers (if not yet
+    encountered) since we always read this marker just before we
+    return.
+  */
+  for (y=0; y < image->rows; )
+    {
+      if (q < pixels || q >= end)
         {
-          if (compression == 1)
-            *q++=(unsigned char) byte;
-          else
-            *q++=(unsigned char)
-              ((i & 0x01) ? (byte & 0x0f) : ((byte >> 4) & 0x0f));
-          x++;
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "  Decode buffer full (y=%lu, "
+                                  "pixels_size=%" MAGICK_SIZE_T_F "u, "
+                                  "pixels=%p, q=%p, end=%p)",
+                                  y, (MAGICK_SIZE_T) pixels_size, pixels, q, end);
+          break;
         }
-      }
-    else
-      {
-        /*
-          Escape mode.
-        */
-        count=ReadBlobByte(image);
-        if (count == 0x01)
-          return(True);
-        switch ((int) count)
+      count=ReadBlobByte(image);
+      if (count == EOF)
+        return MagickFail;
+      if (count > 0)
         {
-          case 0x00:
-          {
-            /*
-              End of line.
-            */
-            x=0;
-            y++;
-            q=pixels+y*image->columns;
-            break;
-          }
-          case 0x02:
-          {
-            /*
-              Delta mode.
-            */
-            x+=ReadBlobByte(image);
-            y+=ReadBlobByte(image);
-            q=pixels+y*image->columns+x;
-            break;
-          }
-          default:
-          {
-            /*
-              Absolute mode.
-            */
-           count=Min(count, end - q);
-            for (i=0; i < count; i++)
+          count=Min(count, end - q);
+          /*
+            Encoded mode.
+          */
+          byte=ReadBlobByte(image);
+          if (byte == EOF)
+            return MagickFail;
+          if (compression == BI_RLE8)
+            {
+              for ( i=count; i != 0; --i )
+                {
+                  *q++=(unsigned char) byte;
+                }
+            }
+          else
             {
-              if (compression == 1)
-                *q++=ReadBlobByte(image);
-              else
+              for ( i=0; i < (unsigned int) count; i++ )
                 {
-                  if ((i & 0x01) == 0)
-                    byte=ReadBlobByte(image);
                   *q++=(unsigned char)
                     ((i & 0x01) ? (byte & 0x0f) : ((byte >> 4) & 0x0f));
                 }
-              x++;
             }
-            /*
-              Read pad byte.
-            */
-            if (compression == 1)
+          x+=count;
+        }
+      else
+        {
+          /*
+            Escape mode.
+          */
+          count=ReadBlobByte(image);
+          if (count == EOF)
+            return MagickFail;
+          if (count == 0x01)
+            {
+              if (image->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "  RLE Escape code encountered");
+              goto rle_decode_done;
+            }
+          switch (count)
+            {
+            case 0x00:
               {
-                if (count & 0x01)
-                  (void) ReadBlobByte(image);
+                /*
+                  End of line.
+                */
+                x=0;
+                y++;
+                q=pixels+y*image->columns;
+                break;
               }
-            else
-              if (((count & 0x03) == 1) || ((count & 0x03) == 2))
-                (void) ReadBlobByte(image);
-            break;
-          }
+            case 0x02:
+              {
+                /*
+                  Delta mode.
+                */
+                byte=ReadBlobByte(image);
+                if (byte == EOF)
+                  return MagickFail;
+                x+=byte;
+                byte=ReadBlobByte(image);
+                if (byte == EOF)
+                  return MagickFail;
+                y+=byte;
+                q=pixels+y*image->columns+x;
+                break;
+              }
+            default:
+              {
+                /*
+                  Absolute mode.
+                */
+                count=Min(count, end - q);
+                if (count < 0)
+                  return MagickFail;
+                if (compression == BI_RLE8)
+                  for (i=count; i != 0; --i)
+                    {
+                      byte=ReadBlobByte(image);
+                      if (byte == EOF)
+                        return MagickFail;
+                      *q++=byte;
+                    }
+                else
+                  for (i=0; i < (unsigned int) count; i++)
+                    {
+                      if ((i & 0x01) == 0)
+                        {
+                          byte=ReadBlobByte(image);
+                          if (byte == EOF)
+                            return MagickFail;
+                        }
+                      *q++=(unsigned char)
+                        ((i & 0x01) ? (byte & 0x0f) : ((byte >> 4) & 0x0f));
+                    }
+                x+=count;
+                /*
+                  Read pad byte.
+                */
+                if (compression == BI_RLE8)
+                  {
+                    if (count & 0x01)
+                      if (ReadBlobByte(image) == EOF)
+                        return MagickFail;
+                  }
+                else
+                  if (((count & 0x03) == 1) || ((count & 0x03) == 2))
+                    if (ReadBlobByte(image) == EOF)
+                      return MagickFail;
+                break;
+              }
+            }
         }
-      }
-    if (QuantumTick(y,image->rows))
-      if (!MagickMonitorFormatted(y,image->rows,&image->exception,
-                                  LoadImageText,image->filename,
-                                 image->columns,image->rows))
-        break;
-  }
+      if (QuantumTick(y,image->rows))
+        if (!MagickMonitorFormatted(y,image->rows,&image->exception,
+                                    LoadImageText,image->filename,
+                                    image->columns,image->rows))
+          break;
+    }
   (void) ReadBlobByte(image);  /* end of line */
   (void) ReadBlobByte(image);
-  return(True);
+ rle_decode_done:
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "  Decoded %" MAGICK_SIZE_T_F "u bytes",
+                          (MAGICK_SIZE_T) (q-pixels));
+  if ((MAGICK_SIZE_T) (q-pixels) < pixels_size)
+    {
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "  RLE decoded output is truncated");
+      return MagickFail;
+    }
+  return(MagickPass);
 }
 \f
 /*
@@ -365,7 +442,7 @@ static size_t EncodeImage(Image *image,const unsigned long bytes_per_line,
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                   SaveImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   /*
@@ -486,7 +563,9 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
     status;
 
   size_t
-    bytes_per_line;
+    bytes_per_line,
+    packet_size,
+    pixels_size;
 
   magick_off_t
     file_size;
@@ -557,6 +636,8 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
       ThrowReaderException(CorruptImageError,NegativeOrZeroImageSize,image);
   if (dib_info.height == 0)
       ThrowReaderException(CorruptImageError,NegativeOrZeroImageSize,image);
+  if (dib_info.height < -2147483647)
+    ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
   image->matte=dib_info.bits_per_pixel == 32;
   image->columns=AbsoluteValue(dib_info.width);
   image->rows=AbsoluteValue(dib_info.height);
@@ -638,14 +719,15 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Read image data.
   */
+  packet_size=dib_info.bits_per_pixel;
   if (dib_info.compression == 2)
-    dib_info.bits_per_pixel<<=1;
+    packet_size<<=1;
 
   /*
      Below emulates:
-     bytes_per_line=4*((image->columns*dib_info.bits_per_pixel+31)/32);
+     bytes_per_line=4*((image->columns*dib_info.packet_size+31)/32);
   */
-  bytes_per_line=MagickArraySize(image->columns,dib_info.bits_per_pixel);
+  bytes_per_line=MagickArraySize(image->columns,packet_size);
   if (bytes_per_line)
     bytes_per_line += 31;
   bytes_per_line /= 32;
@@ -677,9 +759,8 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
   length=MagickArraySize(bytes_per_line,image->rows);
   if (length == 0)
     ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-  pixels=MagickAllocateArray(unsigned char *,
-                             image->rows,
-                             Max(bytes_per_line,image->columns+1));
+  pixels_size=MagickArraySize(image->rows,Max(bytes_per_line,image->columns+1));
+  pixels=MagickAllocateMemory(unsigned char *,pixels_size);
   if (pixels == (unsigned char *) NULL)
     ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
   if ((dib_info.compression == 0) || (dib_info.compression == 3))
@@ -700,9 +781,12 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
     {
       /*
         Convert run-length encoded raster pixels.
-        DecodeImage expects that pixels array is rows*columns bytes.
+
+        DecodeImage() normally decompresses to rows*columns bytes of data.
       */
-      status=DecodeImage(image,dib_info.compression,pixels);
+      (void) memset(pixels,0,pixels_size);
+      status=DecodeImage(image,dib_info.compression,pixels,
+                         image->rows*image->columns);
       if (status == False)
         {
           MagickFreeMemory(pixels);
@@ -763,7 +847,7 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
               status=MagickMonitorFormatted(image->rows-y-1,image->rows,
                                             exception,LoadImageText,
                                             image->filename,
-                                           image->columns,image->rows);
+                                            image->columns,image->rows);
               if (status == False)
                 break;
             }
@@ -810,7 +894,7 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
               status=MagickMonitorFormatted(image->rows-y-1,image->rows,
                                             exception,LoadImageText,
                                             image->filename,
-                                           image->columns,image->rows);
+                                            image->columns,image->rows);
               if (status == False)
                 break;
             }
@@ -848,7 +932,7 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
               status=MagickMonitorFormatted(image->rows-y-1,image->rows,
                                             exception,LoadImageText,
                                             image->filename,
-                                           image->columns,image->rows);
+                                            image->columns,image->rows);
               if (status == False)
                 break;
             }
@@ -898,7 +982,7 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
               status=MagickMonitorFormatted(image->rows-y-1,image->rows,
                                             exception,LoadImageText,
                                             image->filename,
-                                           image->columns,image->rows);
+                                            image->columns,image->rows);
               if (status == False)
                 break;
             }
@@ -934,7 +1018,7 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
               status=MagickMonitorFormatted(image->rows-y-1,image->rows,
                                             exception,LoadImageText,
                                             image->filename,
-                                           image->columns,image->rows);
+                                            image->columns,image->rows);
               if (status == False)
                 break;
             }
@@ -963,21 +1047,29 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
       image->matte=True;
       for (y=(long) image->rows-1; y >= 0; y--)
         {
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "y=%ld", y);
           q=GetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
           for (x=0; x < ((long) image->columns-7); x+=8)
             {
               byte=0;
-              (void) ReadBlob(image,sizeof(byte),&byte);
+              if (ReadBlob(image,sizeof(byte),&byte) != sizeof(byte))
+                break;
               for (bit=0; bit < 8; bit++)
                 q[x+bit].opacity=(Quantum)
                   (byte & (0x80 >> bit) ? TransparentOpacity : OpaqueOpacity);
             }
+          /* Detect early loop termination above due to EOF */
+          if (x < ((long) image->columns-7))
+            break;
           if ((image->columns % 8) != 0)
             {
               byte=0;
-              (void) ReadBlob(image,sizeof(byte),&byte);
+              if (ReadBlob(image,sizeof(byte),&byte) != sizeof(byte))
+                break;
               for (bit=0; bit < (long) (image->columns % 8); bit++)
                 q[x+bit].opacity=(Quantum)
                   (byte & (0x80 >> bit) ? TransparentOpacity : OpaqueOpacity);
@@ -986,7 +1078,8 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
             for (x=0; x < (long) ((32-(image->columns % 32))/8); x++)
               {
                 byte=0;
-                (void) ReadBlob(image,sizeof(byte),&byte);
+                if (ReadBlob(image,sizeof(byte),&byte) != sizeof(byte))
+                  break;
               }
           if (!SyncImagePixels(image))
             break;
@@ -997,9 +1090,17 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
                                           image->columns,image->rows))
                 break;
         }
+#if 0
+      /*
+        FIXME: SourceForge bug 557 provides an icon for which magick
+        is set to "ICODIB" by the 'icon' coder but there is no data
+        for the ICO mask.  Intentionally ignore EOF at this point
+        until this issue gets figured out.
+       */
       if (EOFBlob(image))
         ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
                        image->filename);
+#endif
     }
   if (dib_info.height < 0)
     {
@@ -1277,7 +1378,7 @@ static unsigned int WriteDIBImage(const ImageInfo *image_info,Image *image)
          if (QuantumTick(y,image->rows))
            if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                        SaveImageText,image->filename,
-                                      image->columns,image->rows))
+                                       image->columns,image->rows))
              break;
       }
       break;
@@ -1306,7 +1407,7 @@ static unsigned int WriteDIBImage(const ImageInfo *image_info,Image *image)
           if (QuantumTick(y,image->rows))
             if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                         SaveImageText,image->filename,
-                                       image->columns,image->rows))
+                                        image->columns,image->rows))
               break;
       }
       break;
@@ -1343,7 +1444,7 @@ static unsigned int WriteDIBImage(const ImageInfo *image_info,Image *image)
           if (QuantumTick(y,image->rows))
             if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                         SaveImageText,image->filename,
-                                       image->columns,image->rows))
+                                        image->columns,image->rows))
                break;
       }
       break;
index 6165f03..fdd2342 100644 (file)
@@ -394,7 +394,7 @@ static Image *ReadDPSImage(const ImageInfo *image_info,
           if (QuantumTick(y,image->rows))
             if (!MagickMonitorFormatted(y,image->rows,exception,
                                         LoadImageText,image->filename,
-                                       image->columns,image->rows))
+                                        image->columns,image->rows))
               break;
         }
       else
@@ -419,7 +419,7 @@ static Image *ReadDPSImage(const ImageInfo *image_info,
           if (QuantumTick(y,image->rows))
             if (!MagickMonitorFormatted(y,image->rows,exception,
                                         LoadImageText,image->filename,
-                                       image->columns,image->rows))
+                                        image->columns,image->rows))
               break;
         }
       break;
@@ -465,7 +465,7 @@ static Image *ReadDPSImage(const ImageInfo *image_info,
         if (QuantumTick(y,image->rows))
           if (!MagickMonitorFormatted(y,image->rows,exception,
                                       LoadImageText,image->filename,
-                                     image->columns,image->rows))
+                                      image->columns,image->rows))
             break;
       }
       break;
index a503a74..37eefb4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2005-2015 GraphicsMagick Group
+% Copyright (C) 2005-2018 GraphicsMagick Group
 %
 % This program is covered by multiple licenses, which are described in
 % Copyright.txt. You should have received a copy of Copyright.txt with this
 %    does pad rows to the next word (16-bit or 32-bit) boundary.  It is not
 %    clear if the End-of-line padding field should reflect padding to a
 %    word boundary.
-%    
+%
 */
 \f
 /*
@@ -191,7 +191,7 @@ typedef enum
   ImageElementBlue=3,
   ImageElementAlpha=4,
   ImageElementLuma=6,
-  ImageElementColorDifferenceCbCr=7,
+  ImageElementColorDifferenceCbCr=7, /* 4:2:2 */
   ImageElementDepth=8,
   ImageElementCompositeVideo=9,
   ImageElementRGB=50,              /* BGR order */
@@ -482,8 +482,8 @@ STATIC unsigned int IsDPX(const unsigned char *magick,const size_t length)
 \
   if (!IS_UNDEFINED_ASCII(member)) \
     { \
-      (void) strncpy(buffer_,member,Min(sizeof(member),MaxTextExtent)); \
-      buffer_[Min(sizeof(member)+1,MaxTextExtent-1)]='\0';             \
+      (void) memcpy(buffer_,member,Min(sizeof(member),MaxTextExtent)); \
+      buffer_[Min(sizeof(member),MaxTextExtent-1)]='\0';             \
       (void) SetImageAttribute(image,name,buffer_); \
       LogSetImageAttribute(name,buffer_); \
     } \
@@ -961,7 +961,7 @@ STATIC void DescribeDPXImageElement(const DPXImageElement *element_info,
   char txt_buffer[MaxTextExtent];
 
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                        "Element %u: data_sign=%s",element, 
+                        "Element %u: data_sign=%s",element,
                         element_info->data_sign == 0 ?
                         "unsigned(0)" : "signed(1)");
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -990,9 +990,9 @@ STATIC void DescribeDPXImageElement(const DPXImageElement *element_info,
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                         "Element %u: packing=%s encoding=%s data_offset=%u eol_pad=%u eoi_pad=%u",
                         element,
-                        (element_info->packing == 0 ? "Packed(0)" :
-                         element_info->packing == 1 ? "PadLSB(1)" :
-                         element_info->packing == 2 ? "PadMSB(2)" :
+                        (element_info->packing == PackingMethodPacked ? "Packed(0)" :
+                         element_info->packing == PackingMethodWordsFillLSB ? "PadLSB(1)" :
+                         element_info->packing == PackingMethodWordsFillMSB ? "PadMSB(2)" :
                          "Unknown"),
                         (element_info->encoding == 0 ? "None(0)" :
                          element_info->encoding == 1 ? "RLE(1)" :
@@ -1015,7 +1015,7 @@ STATIC unsigned int  DPXSamplesPerPixel(const DPXImageElementDescriptor element_
 {
   unsigned int
     samples_per_pixel=0;
-  
+
   switch (element_descriptor)
     {
     case ImageElementUnspecified:
@@ -1024,9 +1024,11 @@ STATIC unsigned int  DPXSamplesPerPixel(const DPXImageElementDescriptor element_
     case ImageElementBlue:
     case ImageElementAlpha:
     case ImageElementLuma:
-    case ImageElementColorDifferenceCbCr:
       samples_per_pixel=1;
       break;
+    case ImageElementColorDifferenceCbCr: /* Cb | Cr 4:2:2 sampling ..., even number of columns required.*/
+      samples_per_pixel=2;
+      break;
     case ImageElementRGB:
       samples_per_pixel=3;
       break;
@@ -1209,7 +1211,7 @@ STATIC inline Quantum ScaleFromVideo(const double sample,
   if (sample > ref_low)
     result = (sample - ref_low)*upscale;
   return RoundDoubleToQuantum(result);
-  
+
 }
 
 /*
@@ -1224,10 +1226,10 @@ STATIC unsigned long ReadWordU32BE (void *state)
 {
   magick_uint32_t value;
   ReadWordU32State *read_state=(ReadWordU32State *) state;
-  value =  *read_state->words++ << 24;
-  value |= *read_state->words++ << 16;
-  value |= *read_state->words++ << 8;
-  value |= *read_state->words++;
+  value =  ((magick_uint32_t) *read_state->words++) << 24;
+  value |= ((magick_uint32_t) *read_state->words++) << 16;
+  value |= ((magick_uint32_t) *read_state->words++) << 8;
+  value |= ((magick_uint32_t) *read_state->words++);
   return value;
 }
 
@@ -1235,10 +1237,10 @@ STATIC unsigned long ReadWordU32LE (void *state)
 {
   magick_uint32_t value;
   ReadWordU32State *read_state=(ReadWordU32State *) state;
-  value = *read_state->words++;
-  value |= *read_state->words++ << 8;
-  value |= *read_state->words++ << 16;
-  value |=  *read_state->words++ << 24;
+  value = ((magick_uint32_t) *read_state->words++);
+  value |= ((magick_uint32_t) *read_state->words++) << 8;
+  value |= ((magick_uint32_t) *read_state->words++) << 16;
+  value |= ((magick_uint32_t) *read_state->words++) << 24;
   return value;
 }
 
@@ -1291,10 +1293,10 @@ STATIC void ReadRowSamples(const unsigned char *scanline,
         {
           register magick_uint32_t
             packed_u32;
-          
+
           register unsigned int
             datum;
-          
+
           unsigned int
             shifts[3] = { 0, 0, 0 };
 
@@ -1385,8 +1387,8 @@ STATIC void ReadRowSamples(const unsigned char *scanline,
                   for (i=samples_per_row; i != 0; i--)
                     {
                       sample=0;
-                      sample |= (*scanline++ << 8);
-                      sample |= (*scanline++);
+                      sample |= (((sample_t) *scanline++) << 8);
+                      sample |= ((sample_t) *scanline++);
                       sample >>= 4;
                       *sp++=sample;
                     }
@@ -1396,8 +1398,8 @@ STATIC void ReadRowSamples(const unsigned char *scanline,
                   for (i=samples_per_row; i != 0; i--)
                     {
                       sample=0;
-                      sample |= (*scanline++);
-                      sample |= (*scanline++ << 8);
+                      sample |= ((sample_t) *scanline++);
+                      sample |= (((sample_t) *scanline++) << 8);
                       sample >>= 4;
                       *sp++=sample;
                     }
@@ -1414,8 +1416,8 @@ STATIC void ReadRowSamples(const unsigned char *scanline,
                   for (i=samples_per_row; i != 0; i--)
                     {
                       sample=0;
-                      sample |= (*scanline++ << 8);
-                      sample |= (*scanline++);
+                      sample |= (((sample_t) *scanline++) << 8);
+                      sample |= ((sample_t) *scanline++);
                       sample &= 0xFFF;
                       *sp++=sample;
                     }
@@ -1425,8 +1427,8 @@ STATIC void ReadRowSamples(const unsigned char *scanline,
                   for (i=samples_per_row; i != 0; i--)
                     {
                       sample=0;
-                      sample |= (*scanline++);
-                      sample |= (*scanline++ << 8);
+                      sample |= ((sample_t) *scanline++);
+                      sample |= (((sample_t) *scanline++) << 8);
                       sample &= 0xFFF;
                       *sp++=sample;
                     }
@@ -1456,8 +1458,8 @@ STATIC void ReadRowSamples(const unsigned char *scanline,
           for (i=samples_per_row; i != 0; i--)
             {
               sample=0;
-              sample |= (*scanline++ << 8);
-              sample |= (*scanline++);
+              sample |= (((sample_t) *scanline++) << 8);
+              sample |= ((sample_t) *scanline++);
               *sp++=sample;
             }
         }
@@ -1466,8 +1468,8 @@ STATIC void ReadRowSamples(const unsigned char *scanline,
           for (i=samples_per_row; i != 0; i--)
             {
               sample=0;
-              sample |= (*scanline++);
-              sample |= (*scanline++ << 8);
+              sample |= ((sample_t) *scanline++);
+              sample |= (((sample_t) *scanline++) << 8);
               *sp++=sample;
             }
         }
@@ -1509,7 +1511,7 @@ STATIC void ReadRowSamples(const unsigned char *scanline,
   {
     ReadWordU32State
       read_state;
-    
+
     WordStreamReadHandle
       read_stream;
 
@@ -1632,6 +1634,7 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
   MagickBool
     is_grayscale=MagickFalse,   /* image is grayscale ? */
     is_monochrome=MagickFalse,  /* image is monochrome ? */
+    matte_init=MagickFalse,     /* Set to True if opacity channel needs init */
     swap_endian=MagickFalse;    /* swap endian order */
 
   DPXImageElementDescriptor
@@ -1686,7 +1689,7 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     original endianness.
   */
   image->endian = endian_type;
-  
+
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                           "%s endian DPX format",
@@ -1768,8 +1771,13 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if (dpx_image_info.elements >
       sizeof(dpx_image_info.element_info)/sizeof(dpx_image_info.element_info[0]))
     ThrowDPXReaderException(CorruptImageError,ImproperImageHeader,image);
+  if (dpx_image_info.elements == 0)
+    ThrowDPXReaderException(CorruptImageError,ImproperImageHeader,image);
   image->columns=dpx_image_info.pixels_per_line & 0xFFFFFFFF;
   image->rows=dpx_image_info.lines_per_image_element & 0xFFFFFFFF;
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Geometry: %lux%lu", image->columns, image->rows);
   U16ToAttribute(image,"DPX:image.orientation",dpx_image_info.orientation);
   image->orientation=DPXOrientationToOrientationType(dpx_image_info.orientation);
 
@@ -1838,7 +1846,7 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
       */
       offset += ReadBlob(image,sizeof(dpx_tv_info),&dpx_tv_info);
       if (offset != (size_t) 2048L)
-        ThrowDPXReaderException(CorruptImageError,UnexpectedEndOfFile,image); 
+        ThrowDPXReaderException(CorruptImageError,UnexpectedEndOfFile,image);
       if (swap_endian)
         SwabDPXTVInfo(&dpx_tv_info);
 
@@ -1870,17 +1878,17 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
           */
           unsigned char
             *user_data;
-          
+
           const size_t
             block_size = 65536UL;
-          
+
           size_t
             read_size,
             user_data_length;
 
           DPXUserDefinedData
             *dpx_user_data;
-          
+
           user_data_length=0UL;
           user_data=(unsigned char *) NULL;
 
@@ -1891,7 +1899,10 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
               if (user_data == (unsigned char *) NULL)
                 ThrowDPXReaderException(ResourceLimitError,MemoryAllocationFailed,image);
               if (ReadBlob(image,read_size,user_data+user_data_length) != read_size)
-                ThrowDPXReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+                {
+                  MagickFreeMemory(user_data);
+                  ThrowDPXReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+                }
               user_data_length += read_size;
               offset += read_size;
             }
@@ -1899,12 +1910,19 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
           dpx_user_data=(DPXUserDefinedData *) user_data;
           StringToAttribute(image,"DPX:user.data.id",dpx_user_data->user_id);
           if (!SetImageProfile(image,"DPXUSERDATA",user_data,user_data_length))
-            ThrowDPXReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+            {
+              MagickFreeMemory(user_data);
+              ThrowDPXReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+            }
           MagickFreeMemory(user_data);
         }
     }
   /*
     Determine the maximum number of bits per sample, samples per element, and colorspace
+
+    If we encounter an element which is not supported (perhaps a
+    vendor extension), then update dpx_image_info.elements to stop
+    reading before that element.
   */
   max_bits_per_sample=0;
   max_samples_per_pixel=0;
@@ -1919,8 +1937,15 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
       colorimetric=ColorimetricUserDefined;
 
     transfer_characteristic=TransferCharacteristicUserDefined;
+    if (image->logging)
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "Number of elements: %u",
+                            dpx_image_info.elements);
+
     for (element=0; element < dpx_image_info.elements; element++)
       {
+        if (image->logging)
+          DescribeDPXImageElement(&dpx_image_info.element_info[element],element+1);
         if (element == 0)
           {
             colorimetric=
@@ -1940,12 +1965,88 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
             (bits_per_sample != 10) &&
             (bits_per_sample != 12) &&
             (bits_per_sample != 16))
-          ThrowDPXReaderException(CorruptImageError,ImproperImageHeader,image);
-        max_bits_per_sample=Max(max_bits_per_sample,bits_per_sample);
-        max_samples_per_pixel=Max(max_samples_per_pixel,
-                                  DPXSamplesPerPixel(element_descriptor));
+          {
+            if (image->logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Unsupported bits per sample %u"
+                                    " (truncating elements)", bits_per_sample);
+            dpx_image_info.elements=element;
+            break;
+          }
+        /*
+          Ignore Northlight Scanner "scratch and dust" channel which claims
+          to be an Alpha channel, but is not.  Things would not be so bad if
+          it was coded according to the DPX standard.  Luckly, it always comes
+          after the color channels.
+        */
+        if ((element_descriptor == ImageElementAlpha) &&
+            (bits_per_sample == 1) &&
+            (LocaleNCompare(dpx_image_info.element_info[element].description,
+                            "NL CLEAN MATTE",sizeof("NL CLEAN MATTE")-1) == 0))
+          {
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Skipping Northlight \"%s\" channel...",
+                                  dpx_image_info.element_info[element].description);
+            dpx_image_info.elements=element;
+            break;
+          }
+        /*
+          Validate packing method
+        */
+        packing_method=(ImageComponentPackingMethod) dpx_image_info.element_info[element].packing;
+        if ((packing_method != PackingMethodPacked) &&
+            (packing_method != PackingMethodWordsFillLSB) &&
+            (packing_method != PackingMethodWordsFillMSB))
+          {
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Unsupported packing method %u"
+                                  " (truncating elements)", packing_method);
+            dpx_image_info.elements=element;
+            break;
+          }
+        /*
+          Data sign, (0 = unsigned; 1 = signed)
+        */
+        if (dpx_image_info.element_info[element].data_sign != 0)
+          {
+            if (image->logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Signed pixel data (in element %u) is not supported"
+                                    " (truncating elements)",
+                                    element);
+            dpx_image_info.elements=element;
+            break;
+          }
         /*
-          Set image colorspace
+          Special image width rules for some element descriptors
+        */
+        switch (element_descriptor)
+          {
+          case ImageElementColorDifferenceCbCr: /* 4:2:2 */
+          case ImageElementCbYCrY422:
+          case ImageElementCbYACrYA4224:
+            if (image->columns % 2)
+              {
+                if (image->logging)
+                  {
+                    char txt_buffer[MaxTextExtent];
+                    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                          "Image width must be evenly divisible"
+                                          " by 2 for \"%s\" element",
+                                          DescribeImageElementDescriptor(txt_buffer,
+                                                                         element_descriptor));
+                  }
+                dpx_image_info.elements=element;
+              }
+            break;
+          default:
+            {
+            }
+          }
+        if (dpx_image_info.elements == element)
+          break;
+        /*
+          Validate and set image colorspace
         */
         switch (element_descriptor)
           {
@@ -1957,7 +2058,8 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
             {
               has_cbcr=MagickTrue;
               colorimetric=(DPXColorimetric) dpx_image_info.element_info[element].colorimetric;
-              transfer_characteristic=(DPXTransferCharacteristic) dpx_image_info.element_info[element].transfer_characteristic;
+              transfer_characteristic=(DPXTransferCharacteristic)
+                dpx_image_info.element_info[element].transfer_characteristic;
               break;
             }
           case ImageElementRed:
@@ -1969,23 +2071,33 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
             {
               has_rgb=MagickTrue;
               colorimetric=(DPXColorimetric) dpx_image_info.element_info[element].colorimetric;
-              transfer_characteristic=(DPXTransferCharacteristic) dpx_image_info.element_info[element].transfer_characteristic;
+              transfer_characteristic=(DPXTransferCharacteristic)
+                dpx_image_info.element_info[element].transfer_characteristic;
               break;
             }
           case ImageElementLuma:
             {
               has_luma=MagickTrue;
               colorimetric=(DPXColorimetric) dpx_image_info.element_info[element].colorimetric;
-              transfer_characteristic=(DPXTransferCharacteristic) dpx_image_info.element_info[element].transfer_characteristic;
+              transfer_characteristic=(DPXTransferCharacteristic)
+                dpx_image_info.element_info[element].transfer_characteristic;
+              break;
+            }
+          case ImageElementAlpha:
+            {
               break;
             }
           default:
             {
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Unhandled element descriptor: %s",
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Unhandled element descriptor (%u): %s"
+                                    " (truncating elements)",
+                                    element_descriptor,
                                     DescribeImageElementDescriptor(txt_buffer,element_descriptor));
+              dpx_image_info.elements=element;
+              break;
             }
           }
-        
         /*
           Check for a matte channel.
         */
@@ -2001,7 +2113,28 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
           default:
             break;
           }
+        max_bits_per_sample=Max(max_bits_per_sample,bits_per_sample);
+        max_samples_per_pixel=Max(max_samples_per_pixel,
+                                  DPXSamplesPerPixel(element_descriptor));
+
+
+      } /* for (element=0; element < dpx_image_info.elements; element++) */
+
+    /*
+      Check if there were any supported elements
+    */
+    if (dpx_image_info.elements == 0)
+      {
+        if (image->logging)
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "No supported image elements were found!");
+        ThrowDPXReaderException(CorruptImageError,ImproperImageHeader,image);
       }
+
+    if (image->logging)
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "Maximum number of bits per sample in any element: %u",
+                            max_bits_per_sample);
     if (has_cbcr)
       {
         image->colorspace=Rec709YCbCrColorspace;
@@ -2048,6 +2181,106 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     ThrowDPXReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
 
   /*
+    Validate that the elements provide all of the channels
+  */
+  {
+    /* Flags to use when updating channel_bits */
+#define RED_CHANNEL     (1U)
+#define GREEN_CHANNEL   (1U << 1U)
+#define BLUE_CHANNEL    (1U << 2U)
+#define OPACITY_CHANNEL (1U << 3U)
+
+    unsigned int
+      channel_bits; /* record of channels which were updated by elements */
+
+    channel_bits=0;
+    for (element=0; element < dpx_image_info.elements; element++)
+      {
+        element_descriptor=(DPXImageElementDescriptor)
+          dpx_image_info.element_info[element].descriptor;
+
+        /*
+          Tally channels which would be updated by this element.
+        */
+        switch (element_descriptor)
+          {
+          case ImageElementRed:
+            channel_bits |= RED_CHANNEL;
+            break;
+          case ImageElementGreen:
+            channel_bits |= GREEN_CHANNEL;
+            break;
+          case ImageElementBlue:
+            channel_bits |= BLUE_CHANNEL;
+            break;
+          case ImageElementAlpha:
+            channel_bits |= OPACITY_CHANNEL;
+            break;
+          case ImageElementUnspecified:
+          case ImageElementLuma:
+            if (IsYCbCrColorspace(image->colorspace))
+              {
+                channel_bits |= RED_CHANNEL;
+              }
+            else
+              {
+                channel_bits |= RED_CHANNEL | GREEN_CHANNEL | BLUE_CHANNEL;
+                if (!image->matte)
+                  channel_bits |= OPACITY_CHANNEL;
+              }
+            break;
+          case ImageElementColorDifferenceCbCr:
+            channel_bits |= GREEN_CHANNEL | BLUE_CHANNEL;
+            break;
+          case ImageElementRGB:
+            channel_bits |= RED_CHANNEL | GREEN_CHANNEL | BLUE_CHANNEL;
+            if (!image->matte)
+              channel_bits |= OPACITY_CHANNEL;
+            break;
+          case ImageElementRGBA:
+            channel_bits |= RED_CHANNEL | GREEN_CHANNEL | BLUE_CHANNEL | OPACITY_CHANNEL;
+            break;
+          case ImageElementABGR:
+            channel_bits |= RED_CHANNEL | GREEN_CHANNEL | BLUE_CHANNEL | OPACITY_CHANNEL;
+            break;
+          case ImageElementCbYCrY422:
+            channel_bits |= RED_CHANNEL | GREEN_CHANNEL | BLUE_CHANNEL;
+            if (!image->matte)
+              channel_bits |= OPACITY_CHANNEL;
+            break;
+          case ImageElementCbYACrYA4224:
+            channel_bits |= RED_CHANNEL | GREEN_CHANNEL | BLUE_CHANNEL | OPACITY_CHANNEL;
+            break;
+          case ImageElementCbYCr444:
+            channel_bits |= RED_CHANNEL | GREEN_CHANNEL | BLUE_CHANNEL;
+            if (!image->matte)
+              channel_bits |= OPACITY_CHANNEL;
+            break;
+          case ImageElementCbYCrA4444:
+            channel_bits |= RED_CHANNEL | GREEN_CHANNEL | BLUE_CHANNEL | OPACITY_CHANNEL;
+            break;
+          default:
+            break;
+          }
+      }
+
+    if (image->logging)
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "Channels updated: %s%s%s%s",
+                            channel_bits & RED_CHANNEL ? "R" : "",
+                            channel_bits & GREEN_CHANNEL ? "G" : "",
+                            channel_bits & BLUE_CHANNEL ? "B" : "",
+                            channel_bits & OPACITY_CHANNEL ? "O" : "");
+
+    if (!(channel_bits & OPACITY_CHANNEL))
+      matte_init = MagickTrue;
+
+    if ((channel_bits & (RED_CHANNEL | GREEN_CHANNEL | BLUE_CHANNEL))
+        != (RED_CHANNEL | GREEN_CHANNEL | BLUE_CHANNEL))
+      ThrowDPXReaderException(CorruptImageError,MissingImageChannel,image);
+  }
+
+  /*
     Validate file size if using a seekable blob
   */
   if (BlobIsSeekable(image))
@@ -2058,11 +2291,33 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
       /*
         Verify that file size claimed by header is matched by file size
       */
-      if ((file_size = GetBlobSize(image)) != 0)
+      file_size = GetBlobSize(image);
+      if (!IS_UNDEFINED_U32(dpx_file_info.file_size) &&
+          (file_size < dpx_file_info.file_size))
+        {
+          ThrowDPXReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+        }
+      if (!IS_UNDEFINED_U32(dpx_file_info.image_data_offset) &&
+          (file_size < dpx_file_info.image_data_offset))
         {
-          if (file_size < dpx_file_info.file_size)
+          ThrowDPXReaderException(CorruptImageError,ImproperImageHeader,image);
+        }
+      if (!IS_UNDEFINED_U32(dpx_file_info.generic_section_length) &&
+          (file_size < dpx_file_info.generic_section_length))
+        {
+          ThrowDPXReaderException(CorruptImageError,ImproperImageHeader,image);
+        }
+      if (!IS_UNDEFINED_U32(dpx_file_info.industry_section_length) &&
+          (file_size < dpx_file_info.industry_section_length))
+        {
+          ThrowDPXReaderException(CorruptImageError,ImproperImageHeader,image);
+        }
+      if (pixels_offset >= 2080UL)
+        {
+          if (!IS_UNDEFINED_U32(dpx_file_info.user_defined_length) &&
+              (file_size < dpx_file_info.user_defined_length))
             {
-              ThrowDPXReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+              ThrowDPXReaderException(CorruptImageError,ImproperImageHeader,image);
             }
         }
 
@@ -2078,16 +2333,43 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
           transfer_characteristic=
             (DPXTransferCharacteristic) dpx_image_info.element_info[element].transfer_characteristic;
           packing_method=(ImageComponentPackingMethod) dpx_image_info.element_info[element].packing;
+          if (!IS_UNDEFINED_U32(dpx_image_info.element_info[element].data_offset) &&
+              !IS_UNDEFINED_U32(dpx_file_info.file_size) &&
+              (dpx_file_info.file_size != 0) &&
+              ((dpx_image_info.element_info[element].data_offset & 0xFFFFFFFF) >=
+               dpx_file_info.file_size))
+            {
+              if (image->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Element offset (%u) is outside the bounds of"
+                                      " file size (%u) indicated by header",
+                                      dpx_image_info.element_info[element].data_offset,
+                                      dpx_file_info.file_size);
+              ThrowDPXReaderException(CorruptImageError,ImproperImageHeader,image);
+            }
+          if (!IS_UNDEFINED_U32(dpx_image_info.element_info[element].data_offset) &&
+              ((dpx_image_info.element_info[element].data_offset & 0xFFFFFFFF) >=
+               file_size))
+            {
+              if (image->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Element offset (%u) is outside the bounds of"
+                                      " actual file size (%" MAGICK_OFF_F "d)",
+                                      dpx_image_info.element_info[element].data_offset,
+                                      file_size);
+              ThrowDPXReaderException(CorruptImageError,ImproperImageHeader,image);
+            }
           samples_per_pixel=DPXSamplesPerPixel(element_descriptor);
           samples_per_row=samples_per_pixel*image->columns;
           element_size=DPXRowOctets(image->rows,samples_per_row,
                                     bits_per_sample,packing_method);
           file_size_estimate += element_size;
         }
-      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                            "File size estimate %" MAGICK_OFF_F
-                            "u bytes (have %" MAGICK_OFF_F "u bytes)",
-                            file_size_estimate, file_size);
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "File size estimate %" MAGICK_OFF_F
+                              "u bytes (have %" MAGICK_OFF_F "u bytes)",
+                              file_size_estimate, file_size);
       if ((file_size_estimate <= 0) || (file_size < file_size_estimate))
         ThrowDPXReaderException(CorruptImageError,InsufficientImageDataInFile,image);
     }
@@ -2102,12 +2384,15 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Allocate sample translation map storage.
   */
+  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                        "Maximum number of bits per sample in any element: %u",
+                        max_bits_per_sample);
   map_Y=MagickAllocateArray(Quantum *,
                             MaxValueGivenBits(max_bits_per_sample)+1,
                             sizeof(Quantum));
   if (map_Y == (Quantum *) NULL)
     ThrowDPXReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-  
+
   map_CbCr=MagickAllocateArray(Quantum *,
                                MaxValueGivenBits(max_bits_per_sample)+1,
                                sizeof(Quantum));
@@ -2150,17 +2435,8 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
       MagickBool
         swap_word_datums = MagickFalse;
 
-      DescribeDPXImageElement(&dpx_image_info.element_info[element],element+1);
-      /*
-        Data sign, (0 = unsigned; 1 = signed)
-      */
-      if (dpx_image_info.element_info[element].data_sign != 0)
-        continue;
-      /*
-        Bits per sample must be must be 1 to 16.
-      */
-      if (dpx_image_info.element_info[element].bits_per_sample > 16)
-        continue;
+      /* if (image->logging) */
+      /*   DescribeDPXImageElement(&dpx_image_info.element_info[element],element+1); */
       /*
         Move to element data
       */
@@ -2168,6 +2444,10 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
           (dpx_image_info.element_info[element].data_offset != 0U))
         {
           pixels_offset=dpx_image_info.element_info[element].data_offset & 0xFFFFFFFF;
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Seek from %" MAGICK_SIZE_T_F "u to %lu...",
+                                  (MAGICK_SIZE_T) offset, pixels_offset);
           if (pixels_offset >= offset)
             {
               /* Data is at, or ahead of current position.  Good! */
@@ -2178,12 +2458,24 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
           else
             {
               /* Data is behind current position.  Bad! */
+              if (image->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Seek backward to %lu...", pixels_offset);
               offset=SeekBlob(image,(magick_off_t) pixels_offset,SEEK_SET);
             }
 
           /* Verify that we reached our offset objective */
           if ( pixels_offset != offset)
-            ThrowDPXReaderException(BlobError,UnableToSeekToOffset,image);
+            {
+              if (image->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Failed to seek to data offset %lu"
+                                      " (have %" MAGICK_SIZE_T_F "u)",
+                                      pixels_offset, (MAGICK_SIZE_T) offset);
+              ThrowDPXReaderException(BlobError,UnableToSeekToOffset,image);
+            }
+          if (EOFBlob(image))
+            ThrowDPXReaderException(CorruptImageError,UnexpectedEndOfFile,image);
         }
       bits_per_sample=dpx_image_info.element_info[element].bits_per_sample;
       element_descriptor=(DPXImageElementDescriptor)
@@ -2235,8 +2527,8 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
           (element_descriptor == ImageElementABGR) ||
           (element_descriptor == ImageElementCbYCrY422) ||
           (element_descriptor == ImageElementCbYACrYA4224) ||
-         (element_descriptor == ImageElementCbYCr444) ||
-         (element_descriptor == ImageElementCbYCrA4444))
+          (element_descriptor == ImageElementCbYCr444) ||
+          (element_descriptor == ImageElementCbYCrA4444))
         {
           if ((bits_per_sample == 10) && (packing_method != PackingMethodPacked))
             swap_word_datums = MagickTrue;
@@ -2252,16 +2544,16 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
       samples_per_pixel=DPXSamplesPerPixel(element_descriptor);
       if (samples_per_pixel != 0)
         {
-         double
+          double
             max_value,
-           reference_low,
-           reference_high,
-           scale_to_quantum;           /* multiplier to scale to Quantum */
+            reference_low,
+            reference_high,
+            scale_to_quantum;           /* multiplier to scale to Quantum */
 
-         max_value = (double) MaxValueGivenBits(bits_per_sample);
-         reference_low = 0.0;
-         reference_high = max_value;
-         scale_to_quantum=MaxRGBDouble/max_value;
+          max_value = (double) MaxValueGivenBits(bits_per_sample);
+          reference_low = 0.0;
+          reference_high = max_value;
+          scale_to_quantum=MaxRGBDouble/max_value;
 
           /*
             Is this a video type space?
@@ -2271,6 +2563,8 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
               (image->colorspace == Rec709LumaColorspace))
             {
               double
+                reference_low_prop,
+                reference_high_prop,
                 ScaleY = 0.0,
                 ScaleCbCr = 0.0;
 
@@ -2281,20 +2575,30 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
               */
               reference_low = ((max_value+1.0) * (64.0/1024.0));
               reference_high = ((max_value+1.0) * (940.0/1024.0));
-              
+
+              reference_low_prop = reference_low;
+              reference_high_prop = reference_high;
+
               if (!IS_UNDEFINED_U32(dpx_image_info.element_info[element].reference_low_data_code))
-                reference_low=dpx_image_info.element_info[element].reference_low_data_code;
+                reference_low_prop=dpx_image_info.element_info[element].reference_low_data_code;
               if ((definition_value=AccessDefinition(image_info,"dpx","reference-low")))
-                reference_low=(double) strtol(definition_value, (char **)NULL, 10);
-              
+                reference_low_prop=(double) strtol(definition_value, (char **)NULL, 10);
+
               if (!IS_UNDEFINED_U32(dpx_image_info.element_info[element].reference_high_data_code))
-                reference_high=dpx_image_info.element_info[element].reference_high_data_code;
+                reference_high_prop=dpx_image_info.element_info[element].reference_high_data_code;
               if ((definition_value=AccessDefinition(image_info,"dpx","reference-high")))
-                reference_high=(double) strtol(definition_value, (char **)NULL, 10);
-              
+                reference_high_prop=(double) strtol(definition_value, (char **)NULL, 10);
+
+              if ((reference_high_prop > reference_low_prop) &&
+                  (reference_high_prop > MagickEpsilon))
+                {
+                  reference_low = reference_low_prop;
+                  reference_high = reference_high_prop;
+                }
+
               ScaleY = ((max_value+1.0)/(reference_high-reference_low));
               ScaleCbCr = ScaleY*((940.0-64.0)/(960.0-64.0));
-             reference_low=reference_low*scale_to_quantum;
+              reference_low=reference_low*scale_to_quantum;
 
               for(i=0; i <= (unsigned long) max_value; i++)
                 {
@@ -2305,7 +2609,7 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
           else
             {
               for(i=0; i <= (unsigned long) max_value; i++)
-               map_Y[i]=scale_to_quantum*i+0.5;
+                map_Y[i]=scale_to_quantum*i+0.5;
             }
 
           /*
@@ -2323,22 +2627,13 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
               */
               element_size=DPXRowOctets(image->rows,samples_per_row,
                                         bits_per_sample,packing_method);
-              
+
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                     "Samples per row %u, octets per row %lu, element size %lu",
                                     samples_per_row, (unsigned long) row_octets,
                                     (unsigned long) element_size);
             }
-          if (((element_descriptor == ImageElementCbYCrY422) ||
-               (element_descriptor == ImageElementCbYACrYA4224) ||
-               (element_descriptor == ImageElementColorDifferenceCbCr)))
-            {
-              /*
-                When subsampling, image width must be evenly divisible by two.
-              */
-              if (image->columns %2)
-                ThrowDPXReaderException(CorruptImageError,SubsamplingRequiresEvenWidth,image);
-            }
+
           /*
             Read element data.
           */
@@ -2356,7 +2651,7 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
               register long
                 x;
-              
+
               register PixelPacket
                 *q;
 
@@ -2368,7 +2663,7 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
               sample_t
                 *samples;                   /* parsed sample array */
-              
+
               unsigned char
                 *scanline;
 
@@ -2391,24 +2686,28 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
               {
                 void
                   *scanline_data;
-                
+
                 scanline_data=scanline;
 #if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
 #  pragma omp critical (GM_ReadDPXImage)
 #endif
                 {
                   if (ReadBlobZC(image,row_octets,&scanline_data) != row_octets)
-                    thread_status=MagickFail;
+                    {
+                      ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
+                                     image->filename);
+                      thread_status=MagickFail;
+                    }
 
                   thread_row_count=row_count;
                   row_count++;
                   if (QuantumTick(thread_row_count,image->rows))
                     if (!MagickMonitorFormatted(thread_row_count,image->rows,exception,
                                                 LoadImageText,image->filename,
-                                               image->columns,image->rows))
+                                                image->columns,image->rows))
                       thread_status=MagickFail;
                 }
-                  
+
                 if (thread_status != MagickFail)
                   ReadRowSamples((const unsigned char*) scanline_data,samples_per_row,bits_per_sample,
                                  packing_method,endian_type,swap_word_datums,samples);
@@ -2425,6 +2724,26 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
               if (pixels == (PixelPacket *) NULL)
                 thread_status=MagickFail;
 
+              /*
+                The matte channel needs explicit
+                initialization if planar image does not
+                provide an alpha channel.
+              */
+              if (thread_status != MagickFail)
+                {
+                  if (element == 0)
+                    {
+                      if (matte_init)
+                        {
+                          q = pixels;
+                          for (x=image->columns; x != 0; x--)
+                            {
+                              SetOpacitySample(q++,OpaqueOpacity);
+                            }
+                        }
+                    }
+                }
+
               if (thread_status == MagickFail)
                 {
 #if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
@@ -2482,6 +2801,8 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       for (x=image->columns; x != 0; x--)
                         {
                           SetGraySample(q,map_Y[*samples_itr++]);
+                          if (!image->matte)
+                            SetOpacitySample(q,OpaqueOpacity);
                           q++;
                         }
                     }
@@ -2494,10 +2815,10 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
                         Quantum
                           Cb,
                           Cr;
-                        
+
                         Cb=map_CbCr[*samples_itr++]; /* Cb */
                         Cr=map_CbCr[*samples_itr++]; /* Cr */
-                    
+
                         SetCbSample(q,Cb);  /* Cb */
                         SetCrSample(q,Cr);  /* Cr */
                         q++;
@@ -2516,7 +2837,8 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       SetRedSample(q,map_Y[*samples_itr++]);
                       SetGreenSample(q,map_Y[*samples_itr++]);
                       SetBlueSample(q,map_Y[*samples_itr++]);
-                      SetOpacitySample(q,OpaqueOpacity);
+                      if (!image->matte)
+                        SetOpacitySample(q,OpaqueOpacity);
                       q++;
                     }
                   break;
@@ -2561,13 +2883,15 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
                         SetYSample(q,Y0);   /* Y0 */
                         SetCbSample(q,Cb);  /* Cb */
                         SetCrSample(q,Cr);  /* Cr */
-                        SetOpacitySample(q,OpaqueOpacity);
+                        if (!image->matte)
+                          SetOpacitySample(q,OpaqueOpacity);
                         q++;
 
                         SetYSample(q,Y1);   /* Y1 */
                         SetCbSample(q,Cb) ; /* Cb (false) */
                         SetCrSample(q,Cr);  /* Cr (false) */
-                        q->opacity=OpaqueOpacity;
+                        if (!image->matte)
+                          q->opacity=OpaqueOpacity;
                         q++;
                       }
                     TentUpsampleChroma(pixels,image->columns);
@@ -2617,7 +2941,8 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
                         SetCbSample(q,map_CbCr[*samples_itr++]); /* Cb */
                         SetYSample(q,map_Y[*samples_itr++]);     /* Y */
                         SetCrSample(q,map_CbCr[*samples_itr++]); /* Cr */
-                        SetOpacitySample(q,OpaqueOpacity);      /* A */
+                        if (!image->matte)
+                          SetOpacitySample(q,OpaqueOpacity);      /* A */
                         q++;
                       }
                     break;
@@ -2644,7 +2969,7 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
               /*
                 FIXME: Add support for optional EOL padding.
-              */              
+              */
               if (thread_status == MagickFail)
 #if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
 #  pragma omp critical (GM_ReadDPXImage)
@@ -2671,10 +2996,13 @@ STATIC Image *ReadDPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
           ThrowDPXReaderException(CoderError,ColorTypeNotSupported,image);
         }
     }
-    
+
+  if (status != MagickPass)
+    ThrowDPXReaderException(CorruptImageError,CorruptImage,image);
+
   if (EOFBlob(image))
-    ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
-                   image->filename);
+    ThrowDPXReaderException(CorruptImageError,UnexpectedEndOfFile,
+                            image);
 
   /*
     Support explicitly overriding the input file's colorspace.  Mostly
@@ -2975,10 +3303,10 @@ STATIC void WriteRowSamples(const sample_t *samples,
         {
           register magick_uint32_t
             packed_u32;
-          
+
           register unsigned int
             datum;
-          
+
           unsigned int
             shifts[3] = { 0, 0, 0 };
 
@@ -3026,9 +3354,9 @@ STATIC void WriteRowSamples(const sample_t *samples,
                 {
                   datum=0;
                   packed_u32=0;
-                  packed_u32 |= (*samples++ << shifts[datum++]);
-                  packed_u32 |= (*samples++ << shifts[datum++]);
-                  packed_u32 |= (*samples++ << shifts[datum]);
+                  packed_u32 |= (((magick_uint32_t) *samples++) << shifts[datum++]);
+                  packed_u32 |= (((magick_uint32_t) *samples++) << shifts[datum++]);
+                  packed_u32 |= (((magick_uint32_t) *samples++) << shifts[datum]);
                   MSBPackedU32WordToOctets(packed_u32,scanline);
                 }
               if ((samples_per_row % 3))
@@ -3036,7 +3364,7 @@ STATIC void WriteRowSamples(const sample_t *samples,
                   datum=0;
                   packed_u32=0;
                   for (i=(samples_per_row % 3); i != 0; --i)
-                    packed_u32 |= (*samples++ << shifts[datum++]);
+                    packed_u32 |= ((magick_uint32_t) *samples++ << shifts[datum++]);
                   MSBPackedU32WordToOctets(packed_u32,scanline);
                 }
             }
@@ -3047,9 +3375,9 @@ STATIC void WriteRowSamples(const sample_t *samples,
                 {
                   datum=0;
                   packed_u32=0;
-                  packed_u32 |= (*samples++ << shifts[datum++]);
-                  packed_u32 |= (*samples++ << shifts[datum++]);
-                  packed_u32 |= (*samples++ << shifts[datum]);
+                  packed_u32 |= (((magick_uint32_t) *samples++) << shifts[datum++]);
+                  packed_u32 |= (((magick_uint32_t) *samples++) << shifts[datum++]);
+                  packed_u32 |= (((magick_uint32_t) *samples++) << shifts[datum]);
                   LSBPackedU32WordToOctets(packed_u32,scanline);
                 }
               if ((samples_per_row % 3))
@@ -3057,7 +3385,7 @@ STATIC void WriteRowSamples(const sample_t *samples,
                   datum=0;
                   packed_u32=0;
                   for (i=(samples_per_row % 3); i != 0; --i)
-                    packed_u32 |= (*samples++ << shifts[datum++]);
+                    packed_u32 |= (((magick_uint32_t) *samples++) << shifts[datum++]);
                   LSBPackedU32WordToOctets(packed_u32,scanline);
                 }
             }
@@ -3190,7 +3518,7 @@ STATIC void WriteRowSamples(const sample_t *samples,
   {
       WriteWordU32State
         write_state;
-      
+
       WordStreamWriteHandle
         write_stream;
 
@@ -3287,7 +3615,7 @@ STATIC void WriteRowSamples(const sample_t *samples,
   if ((definition_value_=AccessDefinition(image_info,"dpx",key+4))) \
     member.f=strtod(definition_value_, (char **) NULL); \
   else if ((attribute_=GetImageAttribute(image,key))) \
-    member.f=strtod(attribute_->value, (char **) NULL);        \
+    member.f=strtod(attribute_->value, (char **) NULL); \
   else \
     SET_UNDEFINED_R32(member); \
 }
@@ -3368,7 +3696,7 @@ STATIC unsigned int WriteDPXImage(const ImageInfo *image_info,Image *image)
 
   register const PixelPacket
     *p;
-  
+
   register unsigned long
     i,
     x;
@@ -3652,7 +3980,7 @@ STATIC unsigned int WriteDPXImage(const ImageInfo *image_info,Image *image)
      primaries (for additive color systems like television) or color
      responses (for printing density). */
   /* Reference low data code.  For printing density the default is 0
-     but for ITU-R 601-5 luma, the default is 16 */ 
+     but for ITU-R 601-5 luma, the default is 16 */
   /* Reference low quantity represented. For printing density the
      default is a density of 0.00. For ITU-R 601-5, the luma default
      is 0 mv */
@@ -3908,7 +4236,7 @@ STATIC unsigned int WriteDPXImage(const ImageInfo *image_info,Image *image)
   if (dpx_file_info.creator[0] == '\0')
 #endif
     (void) strlcpy(dpx_file_info.creator,GetMagickVersion((unsigned long *) NULL),
-                  sizeof(dpx_file_info.creator));
+                   sizeof(dpx_file_info.creator));
   AttributeToString(image_info,image,"DPX:file.project.name",dpx_file_info.project_name);
   AttributeToString(image_info,image,"DPX:file.copyright",dpx_file_info.copyright);
   AttributeToU32(image_info,image,"DPX:file.encryption.key",dpx_file_info.encryption_key);
@@ -4078,7 +4406,7 @@ STATIC unsigned int WriteDPXImage(const ImageInfo *image_info,Image *image)
   while (offset < dpx_image_info.element_info[0].data_offset)
     {
       if (WriteBlobByte(image,0U) != 1)
-       break;
+        break;
       offset += 1;
     }
   /*
@@ -4101,63 +4429,64 @@ STATIC unsigned int WriteDPXImage(const ImageInfo *image_info,Image *image)
 
 
       /*
-       Validate that what we are writing matches the header offsets.
+        Validate that what we are writing matches the header offsets.
       */
       {
-       magick_off_t
-         reported_file_offset;
-         
-       if (((reported_file_offset = TellBlob(image)) != -1) &&
-           ((magick_off_t) dpx_image_info.element_info[element].data_offset !=
-            reported_file_offset))
-         {
-           (void) fprintf(stderr,"### Descriptor %u offset %u, TellBlob says %" MAGICK_OFF_F "d\n",
-                          element+1, dpx_image_info.element_info[element].data_offset,
-                          reported_file_offset);
-         }
+        magick_off_t
+          reported_file_offset;
+
+        if (((reported_file_offset = TellBlob(image)) != -1) &&
+            ((magick_off_t) dpx_image_info.element_info[element].data_offset !=
+             reported_file_offset))
+          {
+            (void) fprintf(stderr,"### Descriptor %u offset %u, TellBlob says %" MAGICK_OFF_F "d\n",
+                           element+1, dpx_image_info.element_info[element].data_offset,
+                           reported_file_offset);
+          }
       }
-      DescribeDPXImageElement(&dpx_image_info.element_info[element],element+1);
+      if (image->logging)
+        DescribeDPXImageElement(&dpx_image_info.element_info[element],element+1);
 
       bits_per_sample=dpx_image_info.element_info[element].bits_per_sample;
       transfer_characteristic=(DPXTransferCharacteristic)
-       dpx_image_info.element_info[element].transfer_characteristic;
+        dpx_image_info.element_info[element].transfer_characteristic;
 
       {
-       double
-         max_value,
-         reference_low,
-         reference_high,
-         scale_from_maxmap;           /* multiplier to scale from MaxMap */
-
-       max_value = (double) MaxValueGivenBits(bits_per_sample);
-       reference_low = 0.0;
-       reference_high = max_value;
-       scale_from_maxmap=max_value/((double) MaxMap);
-
-       if ((transfer_characteristic == TransferCharacteristicITU_R709) ||
-           (transfer_characteristic == TransferCharacteristicITU_R601_625L) ||
-           (transfer_characteristic == TransferCharacteristicITU_R601_525L))
-         {
-           double
-             ScaleY = 0.0,
-             ScaleCbCr = 0.0;
-
-           reference_low = ((MaxRGBDouble+1.0)*(64.0/1024.0));
-           reference_high = ((MaxRGBDouble+1.0)*(940.0/1024.0));
-           ScaleY = (reference_high-reference_low)/(MaxRGBDouble+1.0);
-           ScaleCbCr = ScaleY*((960.0-64.0)/(940.0-64.0));
-
-           for (i=0; i <= MaxMap ; i++)
-             {
-               map_Y[i]=(i*ScaleY+reference_low)*scale_from_maxmap+0.5;
-               map_CbCr[i]=(i*ScaleCbCr+reference_low)*scale_from_maxmap+0.5;
-             }
-         }
-       else
-         {
-           for (i=0; i <= MaxMap ; i++)
-             map_Y[i]=i*scale_from_maxmap+0.5;
-         }
+        double
+          max_value,
+          reference_low,
+          reference_high,
+          scale_from_maxmap;           /* multiplier to scale from MaxMap */
+
+        max_value = (double) MaxValueGivenBits(bits_per_sample);
+        reference_low = 0.0;
+        reference_high = max_value;
+        scale_from_maxmap=max_value/((double) MaxMap);
+
+        if ((transfer_characteristic == TransferCharacteristicITU_R709) ||
+            (transfer_characteristic == TransferCharacteristicITU_R601_625L) ||
+            (transfer_characteristic == TransferCharacteristicITU_R601_525L))
+          {
+            double
+              ScaleY = 0.0,
+              ScaleCbCr = 0.0;
+
+            reference_low = ((MaxRGBDouble+1.0)*(64.0/1024.0));
+            reference_high = ((MaxRGBDouble+1.0)*(940.0/1024.0));
+            ScaleY = (reference_high-reference_low)/(MaxRGBDouble+1.0);
+            ScaleCbCr = ScaleY*((960.0-64.0)/(940.0-64.0));
+
+            for (i=0; i <= MaxMap ; i++)
+              {
+                map_Y[i]=(i*ScaleY+reference_low)*scale_from_maxmap+0.5;
+                map_CbCr[i]=(i*ScaleCbCr+reference_low)*scale_from_maxmap+0.5;
+              }
+          }
+        else
+          {
+            for (i=0; i <= MaxMap ; i++)
+              map_Y[i]=i*scale_from_maxmap+0.5;
+          }
       }
 
       element_descriptor=(DPXImageElementDescriptor)
@@ -4184,8 +4513,8 @@ STATIC unsigned int WriteDPXImage(const ImageInfo *image_info,Image *image)
           (element_descriptor == ImageElementABGR) ||
           (element_descriptor == ImageElementCbYCrY422) ||
           (element_descriptor == ImageElementCbYACrYA4224) ||
-         (element_descriptor == ImageElementCbYCr444) ||
-         (element_descriptor == ImageElementCbYCrA4444))
+          (element_descriptor == ImageElementCbYCr444) ||
+          (element_descriptor == ImageElementCbYCrA4444))
         {
           if ((bits_per_sample == 10) && (packing_method != PackingMethodPacked))
             swap_word_datums = MagickTrue;
@@ -4282,12 +4611,12 @@ STATIC unsigned int WriteDPXImage(const ImageInfo *image_info,Image *image)
                 /* CbCr */
                 const PixelPacket
                   *chroma_pixels;
-                
+
                 chroma_pixels=AcquireImagePixels(chroma_image,0,y,chroma_image->columns,1,
                                                  &image->exception);
                 if (chroma_pixels == (const PixelPacket *) NULL)
                   break;
-                
+
                 for (x=image->columns; x != 0; x -= 2)
                   {
                     *samples_itr++=map_CbCr[ScaleQuantumToMap(GetCbSample(chroma_pixels))]; /* Cb */
@@ -4419,11 +4748,11 @@ STATIC unsigned int WriteDPXImage(const ImageInfo *image_info,Image *image)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                           SaveImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
     }
-  
+
   /*
     Validate that what we are writing matches the header offsets.
   */
@@ -4433,14 +4762,14 @@ STATIC unsigned int WriteDPXImage(const ImageInfo *image_info,Image *image)
 
     reported_file_offset = TellBlob(image);
     if ((reported_file_offset != -1) &&
-       ((magick_off_t) dpx_file_info.file_size != reported_file_offset))
+        ((magick_off_t) dpx_file_info.file_size != reported_file_offset))
       {
-       (void) fprintf(stderr,"### File length %u, TellBlob says %" MAGICK_OFF_F "d\n",
-                      dpx_file_info.file_size,
-                      reported_file_offset);
+        (void) fprintf(stderr,"### File length %u, TellBlob says %" MAGICK_OFF_F "d\n",
+                       dpx_file_info.file_size,
+                       reported_file_offset);
       }
   }
-  
+
   MagickFreeMemory(map_CbCr);
   MagickFreeMemory(map_Y);
   MagickFreeMemory(samples);
index 1ddc5aa..7086373 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -188,6 +188,11 @@ static HENHMETAFILE ReadEnhMetaFile(const char *szFileName,long *width,
     return(NULL);
   dwSize=GetFileSize(hFile,NULL);
   pBits=MagickAllocateMemory(LPBYTE,dwSize);
+  if (pBits == (LPBYTE) NULL)
+    {
+      CloseHandle(hFile);
+      return((HENHMETAFILE) NULL);
+    }
   ReadFile(hFile,pBits,dwSize,&dwSize,NULL);
   CloseHandle(hFile);
   if (((PAPMHEADER) pBits)->dwKey != 0x9ac6cdd7l)
index 54bd376..38c00c9 100644 (file)
@@ -160,7 +160,7 @@ static Image *ReadEPTImage(const ImageInfo *image_info,
   unsigned int
     antialias=4;
 
-  ExtendedSignedIntegralType
+  magick_uint32_t
     filesize;
 
   RectangleInfo
@@ -170,13 +170,13 @@ static Image *ReadEPTImage(const ImageInfo *image_info,
   register char
     *p;
 
-  register long
+  register size_t
     i;
 
   SegmentInfo
     bounds;
 
-  size_t
+  magick_uint32_t
     count;
 
   unsigned long
@@ -228,13 +228,15 @@ static Image *ReadEPTImage(const ImageInfo *image_info,
   (void) ReadBlobLSBLong(image);
   count=ReadBlobLSBLong(image);
   filesize=ReadBlobLSBLong(image);
-  if (image->logging)
-    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                          "File Size: %lu,  Offset: %lu",
-                          (unsigned long) filesize, (unsigned long) count);
   if (EOFBlob(image))
     ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-  for (i=0; i < (long) (count-12); i++)
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "File Size: %u,  Offset: %u",
+                          (unsigned int) filesize, (unsigned int) count);
+  if ((count <= 12) || (filesize == 0))
+    ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+  for (i=0; i < (count-12); i++)
     if (ReadBlobByte(image) == EOF)
       ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
   /*
@@ -255,7 +257,7 @@ static Image *ReadEPTImage(const ImageInfo *image_info,
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                           "Copying Postscript to temporary file \"%s\" ...",
                           postscript_filename);
-  for (i=0; i < (long) filesize; i++)
+  for (i=0; i < filesize; i++)
   {
     if ((c=ReadBlobByte(image)) == EOF)
       break;
@@ -334,7 +336,7 @@ static Image *ReadEPTImage(const ImageInfo *image_info,
     */
     if (image_info->subrange != 0)
       FormatString(options,"-dFirstPage=%lu -dLastPage=%lu",
-                  image_info->subimage+1,image_info->subimage+image_info->subrange);
+                   image_info->subimage+1,image_info->subimage+image_info->subrange);
     /*
       Append bounding box.
     */
@@ -344,15 +346,15 @@ static Image *ReadEPTImage(const ImageInfo *image_info,
       (void) LiberateTemporaryFile((char *) image_info->filename);
     if(!AcquireTemporaryFileName((char *)image_info->filename))
       {
-       (void) LiberateTemporaryFile(postscript_filename);
-       ThrowReaderTemporaryFileException(image_info->filename);
+        (void) LiberateTemporaryFile(postscript_filename);
+        ThrowReaderTemporaryFileException(image_info->filename);
       }
     FormatString(command,delegate_info->commands,antialias,
-                antialias,density,options,image_info->filename,
-                postscript_filename);
+                 antialias,density,options,image_info->filename,
+                 postscript_filename);
   }
-  (void) MagickMonitorFormatted(0,8,&image->exception,RenderPostscriptText,
-                                image->filename);
+  (void) MagickMonitorFormatted(0,8,exception,RenderPostscriptText,
+                                image_info->filename);
   status=InvokePostscriptDelegate(image_info->verbose,command,exception);
   if (!IsAccessibleAndNotEmpty(image_info->filename))
     {
@@ -370,15 +372,15 @@ static Image *ReadEPTImage(const ImageInfo *image_info,
       status=InvokePostscriptDelegate(image_info->verbose,command,exception);
     }
   (void) LiberateTemporaryFile(postscript_filename);
-  (void) MagickMonitorFormatted(7,8,&image->exception,RenderPostscriptText,
-                                image->filename);
+  (void) MagickMonitorFormatted(7,8,exception,RenderPostscriptText,
+                                image_info->filename);
   if (IsAccessibleAndNotEmpty(image_info->filename))
     {
       /*
-       Read Ghostscript output.
+        Read Ghostscript output.
       */
       ImageInfo
-       *clone_info;
+        *clone_info;
 
       clone_info=CloneImageInfo(image_info);
       clone_info->blob=(void *) NULL;
@@ -404,15 +406,15 @@ static Image *ReadEPTImage(const ImageInfo *image_info,
   if (image != (Image *) NULL)
     {
       do
-       {
-         (void) strcpy(image->magick,"PS");
-         (void) strlcpy(image->filename,filename,MaxTextExtent);
-         next_image=SyncNextImageInList(image);
-         if (next_image != (Image *) NULL)
-           image=next_image;
-       } while (next_image != (Image *) NULL);
+        {
+          (void) strcpy(image->magick,"PS");
+          (void) strlcpy(image->filename,filename,MaxTextExtent);
+          next_image=SyncNextImageInList(image);
+          if (next_image != (Image *) NULL)
+            image=next_image;
+        } while (next_image != (Image *) NULL);
       while (image->previous != (Image *) NULL)
-       image=image->previous;
+        image=image->previous;
     }
   return(image);
 }
@@ -450,7 +452,7 @@ ModuleExport void RegisterEPTImage(void)
   entry->encoder=(EncoderHandler) WriteEPTImage;
   entry->magick=(MagickHandler) IsEPT;
   entry->adjoin=False;
-  entry->blob_support=False;
+  entry->blob_support=MagickFalse;
   entry->description="Adobe Encapsulated PostScript with MS-DOS TIFF preview";
   entry->module="EPT";
   entry->coder_class=PrimaryCoderClass;
@@ -461,7 +463,7 @@ ModuleExport void RegisterEPTImage(void)
   entry->encoder=(EncoderHandler) WriteEPTImage;
   entry->magick=(MagickHandler) IsEPT;
   entry->adjoin=False;
-  entry->blob_support=False;
+  entry->blob_support=MagickFalse;
   entry->description="Adobe Level II Encapsulated PostScript with MS-DOS TIFF preview";
   entry->module="EPT";
   entry->coder_class=PrimaryCoderClass;
@@ -472,7 +474,7 @@ ModuleExport void RegisterEPTImage(void)
   entry->encoder=(EncoderHandler) WriteEPTImage;
   entry->magick=(MagickHandler) IsEPT;
   entry->adjoin=False;
-  entry->blob_support=False;
+  entry->blob_support=MagickFalse;
   entry->description="Adobe Level III Encapsulated PostScript with MS-DOS TIFF preview";
   entry->module="EPT";
   entry->coder_class=PrimaryCoderClass;
@@ -585,7 +587,7 @@ static unsigned int WriteEPTImage(const ImageInfo *image_info,Image *image)
       FormatString(image->filename,"%s:%.1024s",subformat,ps_filename);
       if (logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "Writing temporary EPS file \"%s\"",ps_filename);
+                              "Writing temporary EPS file \"%s\"",ps_filename);
       (void) WriteImage(image_info,image);
     }
   /*
@@ -596,12 +598,12 @@ static unsigned int WriteEPTImage(const ImageInfo *image_info,Image *image)
       (void) LiberateTemporaryFile(ps_filename);
       ThrowWriterTemporaryFileException(tiff_filename);
     }
-  
+
   FormatString(image->filename,"tiff:%.1024s",tiff_filename);
   image->compression=RLECompression;
   if (logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                         "Writing temporary TIFF preview file \"%s\"",tiff_filename);
+                          "Writing temporary TIFF preview file \"%s\"",tiff_filename);
   (void) WriteImage(image_info,image);
   /*
     Write EPT image.
@@ -611,94 +613,94 @@ static unsigned int WriteEPTImage(const ImageInfo *image_info,Image *image)
   if (OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception) != MagickFail)
     {
       if ((ps_file=fopen(ps_filename,"rb")) != (FILE *) NULL)
-       {
-         if ((tiff_file=fopen(tiff_filename,"rb")) != (FILE *) NULL)
-           {
-             int
-               c;
-
-             struct stat
-               attributes;
-
-             /*
-               Write EPT image.
-             */
-
-             /* MS-DOS EPS binary file magic signature */
-             (void) WriteBlobLSBLong(image,0xc6d3d0c5ul);
-             /* Byte position in file for start of Postscript language code
-                section */
-             (void) WriteBlobLSBLong(image,30);
-             if (logging)
-               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                     "EPS section offset is %lu bytes",(unsigned long) 30);
-             /* Byte length of PostScript language section. */
-             attributes.st_size=0;
-             (void) fstat(fileno(ps_file),&attributes);
-             if (logging)
-               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                     "EPS section is %lu bytes long",
-                                     (unsigned long)attributes.st_size);
-             (void) WriteBlobLSBLong(image,(unsigned long) attributes.st_size);
-             /* Byte position in file for start of Metafile screen
-                representation (none provided). */
-             (void) WriteBlobLSBLong(image,0);
-             /* Byte length of Metafile section (PSize). (none provided) */
-             (void) WriteBlobLSBLong(image,0);
-             /* Byte position of TIFF representation. */
-             (void) WriteBlobLSBLong(image,(unsigned long) attributes.st_size+30);
-             if (logging)
-               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                     "TIFF section offset is %lu bytes",
-                                     (unsigned long) attributes.st_size+30);
-             /* Byte length of TIFF section. */
-             (void) fstat(fileno(tiff_file),&attributes);
-             if (logging)
-               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                     "TIFF section is %lu bytes long",
-                                     (unsigned long) attributes.st_size);
-             (void) WriteBlobLSBLong(image,(long) attributes.st_size);
-             /* Checksum of header (XOR of bytes 0-27). If Checksum is FFFF
-                then ignore it. This is lazy code. */
-             (void) WriteBlobLSBShort(image,0xffff);
-             /* EPS section */
-             if (logging)
-               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                     "Writing EPS section at offset %ld",
-                                     (long) TellBlob(image));
-             for (c=fgetc(ps_file); c != EOF; c=fgetc(ps_file))
-               (void) WriteBlobByte(image,c);
-             /* TIFF section */
-             if (logging)
-               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                     "Writing TIFF section at offset %ld",
-                                     (long) TellBlob(image));
-             for (c=fgetc(tiff_file); c != EOF; c=fgetc(tiff_file))
-               (void) WriteBlobByte(image,c);
-             (void) fclose(tiff_file);
-             status=MagickPass;
-           }
-         else
-           {
-             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                   "Failed to open \"%s\" for read",
-                                   tiff_filename);
-           }
-         (void) fclose(ps_file);
-       }
+        {
+          if ((tiff_file=fopen(tiff_filename,"rb")) != (FILE *) NULL)
+            {
+              int
+                c;
+
+              struct stat
+                attributes;
+
+              /*
+                Write EPT image.
+              */
+
+              /* MS-DOS EPS binary file magic signature */
+              (void) WriteBlobLSBLong(image,0xc6d3d0c5ul);
+              /* Byte position in file for start of Postscript language code
+                 section */
+              (void) WriteBlobLSBLong(image,30);
+              if (logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "EPS section offset is %lu bytes",(unsigned long) 30);
+              /* Byte length of PostScript language section. */
+              attributes.st_size=0;
+              (void) fstat(fileno(ps_file),&attributes);
+              if (logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "EPS section is %lu bytes long",
+                                      (unsigned long)attributes.st_size);
+              (void) WriteBlobLSBLong(image,(unsigned long) attributes.st_size);
+              /* Byte position in file for start of Metafile screen
+                 representation (none provided). */
+              (void) WriteBlobLSBLong(image,0);
+              /* Byte length of Metafile section (PSize). (none provided) */
+              (void) WriteBlobLSBLong(image,0);
+              /* Byte position of TIFF representation. */
+              (void) WriteBlobLSBLong(image,(unsigned long) attributes.st_size+30);
+              if (logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "TIFF section offset is %lu bytes",
+                                      (unsigned long) attributes.st_size+30);
+              /* Byte length of TIFF section. */
+              (void) fstat(fileno(tiff_file),&attributes);
+              if (logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "TIFF section is %lu bytes long",
+                                      (unsigned long) attributes.st_size);
+              (void) WriteBlobLSBLong(image,(long) attributes.st_size);
+              /* Checksum of header (XOR of bytes 0-27). If Checksum is FFFF
+                 then ignore it. This is lazy code. */
+              (void) WriteBlobLSBShort(image,0xffff);
+              /* EPS section */
+              if (logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Writing EPS section at offset %ld",
+                                      (long) TellBlob(image));
+              for (c=fgetc(ps_file); c != EOF; c=fgetc(ps_file))
+                (void) WriteBlobByte(image,c);
+              /* TIFF section */
+              if (logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Writing TIFF section at offset %ld",
+                                      (long) TellBlob(image));
+              for (c=fgetc(tiff_file); c != EOF; c=fgetc(tiff_file))
+                (void) WriteBlobByte(image,c);
+              (void) fclose(tiff_file);
+              status=MagickPass;
+            }
+          else
+            {
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Failed to open \"%s\" for read",
+                                    tiff_filename);
+            }
+          (void) fclose(ps_file);
+        }
       else
-       {
-         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Failed to open \"%s\" for read",ps_filename);
-       }
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Failed to open \"%s\" for read",ps_filename);
+        }
 
       CloseBlob(image);
     }
   else
     {
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Failed to open \"%s\" for write",
-                           image->filename);
+                                "Failed to open \"%s\" for write",
+                            image->filename);
     }
   if (LocaleCompare(image_info->magick,"EPS") != 0)
     (void) LiberateTemporaryFile(ps_filename);
index 198c709..2c888d2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -292,6 +292,9 @@ static unsigned int WriteFAXImage(const ImageInfo *image_info,Image *image)
   unsigned long
     scene;
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -300,6 +303,7 @@ static unsigned int WriteFAXImage(const ImageInfo *image_info,Image *image)
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+  image_list_length=GetImageListLength(image);
   if (status == False)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
   clone_info=CloneImageInfo(image_info);
@@ -315,7 +319,7 @@ static unsigned int WriteFAXImage(const ImageInfo *image_info,Image *image)
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene++,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename);
     if (status == False)
index 1b77108..8158a86 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -41,6 +41,7 @@
 #include "magick/blob.h"
 #include "magick/colormap.h"
 #include "magick/constitute.h"
+#include "magick/enum_strings.h"
 #include "magick/magick.h"
 #include "magick/monitor.h"
 #include "magick/pixel_cache.h"
@@ -64,13 +65,13 @@ static void FixSignedValues(unsigned char *data, int size, unsigned step, unsign
   if(endian != MSBEndian)
   {
     data += step - 1;  /* LSB has most signifficant byte at the end */
-  }                   /* MSB has most signifficant byte first */
+  }                    /* MSB has most signifficant byte first */
 
   while(size-->0)
   {
-    *data ^= 0x80;     
+    *data ^= 0x80;
     data += step;
-  }     
+  }
 }
 
 /*
@@ -146,12 +147,13 @@ static unsigned int IsFITS(const unsigned char *magick,const size_t length)
 %
 */
 static Image *ReadFITSImage(const ImageInfo *image_info,
-  ExceptionInfo *exception)
+                            ExceptionInfo *exception)
 {
   typedef struct _FITSInfo
   {
     char
       extensions_exist;
+
     int
       simple,
       bits_per_pixel,
@@ -169,18 +171,19 @@ static Image *ReadFITSImage(const ImageInfo *image_info,
 
   char
     keyword[FITS_ROW_SIZE+1],
-    value[FITS_ROW_SIZE+1];  
+    value[FITS_ROW_SIZE+1];
 
   FITSInfo
     fits_info;
 
   Image
-    *image; 
+    *image;
 
   int
-    c;   
+    c;
 
-  int logging;
+  int
+    logging;
 
   long
     packet_size,
@@ -192,17 +195,21 @@ static Image *ReadFITSImage(const ImageInfo *image_info,
     *q;
 
   unsigned char
-    *fits_pixels;    
+    *fits_pixels;
 
   unsigned int
     status,
     value_expected;
 
-  unsigned long
+  magick_uint64_t
     number_pixels;
 
   ImportPixelAreaOptions import_options;
 
+  magick_off_t
+    file_size,
+    remaining;
+
   /*
     Open image file.
   */
@@ -211,13 +218,30 @@ static Image *ReadFITSImage(const ImageInfo *image_info,
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
 
-  logging = LogMagickEvent(CoderEvent,GetMagickModule(),"enter"); 
+  logging = LogMagickEvent(CoderEvent,GetMagickModule(),"enter");
 
   image=AllocateImage(image_info);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == False)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
 
+  file_size=GetBlobSize(image);
+
+  /*
+    Verify file header
+  */
+  if (ReadBlob(image,sizeof(keyword),keyword) != sizeof(keyword))
+    ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+
+  if ((LocaleNCompare(keyword,"IT0",3) != 0) &&
+      (LocaleNCompare(keyword,"SIMPLE",6) != 0))
+    ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+
+  /*
+    Seek back to beginning of file
+  */
+  SeekBlob(image,0,SEEK_SET);
+
   /*
     Initialize common part of image header.
   */
@@ -226,6 +250,7 @@ static Image *ReadFITSImage(const ImageInfo *image_info,
 
   ImportPixelAreaOptionsInit(&import_options);
   import_options.endian = MSBEndian;
+  import_options.sample_type = UnsignedQuantumSampleType;
 
   /*
     Decode image header.
@@ -233,9 +258,10 @@ static Image *ReadFITSImage(const ImageInfo *image_info,
   if ((c=ReadBlobByte(image)) == EOF)
     ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
 
-ReadExtension:
+ ReadExtension:
   if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
-          "Reading FITS HDU at position: %Xh", (unsigned)TellBlob(image) );
+                                    "Reading FITS HDU at position: %Xh",
+                                    (unsigned)TellBlob(image) );
 
   /*
     Initialize image header for all subheaders.
@@ -252,140 +278,141 @@ ReadExtension:
   number_pixels = 0;
 
   for ( ; ; )
-  {
-    if (!isalnum((int) c))
-      c=ReadBlobByte(image);
-    else
-      {
-        register char
-          *p;
-
-        /*
-          Determine a keyword and its value.
-        */
-        p=keyword;
-        do
-        {
-          if ((p-keyword) < (FITS_ROW_SIZE-1))
-            *p++=c;
-          if ((c=ReadBlobByte(image)) == EOF)
-            ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-        } while (isalnum(c) || (c == '_'));
-        *p='\0';
-        if (LocaleCompare(keyword,"END") == 0)
-          break;
-        value_expected=False;
-        while (isspace(c) || (c == '='))
+    {
+      if (!isalnum((int) c))
+        c=ReadBlobByte(image);
+      else
         {
-          if (c == '=')
-            value_expected=True;
-          if ((c=ReadBlobByte(image)) == EOF)
-            ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-        }
-        if (value_expected == False)
-          continue;
-        p=value;
-        if (c == '\'')
-          c=ReadBlobByte(image);
+          register char
+            *p;
 
-        while (isalnum(c) || (c == '-') || (c == '+') || (c == '.'))
-        {
-          if ((p-value) < (FITS_ROW_SIZE-1))
-            *p++=c;
-          if ((c=ReadBlobByte(image)) == EOF)
-            ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-        }
-        *p='\0';
-        /*
-          Assign a value to the specified keyword.
-        */
-        if (LocaleCompare(keyword,"SIMPLE") == 0)
-          fits_info.simple = (*value=='T') || (*value=='t');
-        if (LocaleCompare(keyword,"EXTEND") == 0)
-          fits_info.extensions_exist = (*value== 'T') || (*value=='t');
-        if (LocaleCompare(keyword,"BITPIX") == 0)
-        {
-          fits_info.bits_per_pixel=MagickAtoI(value);
           /*
-            BITPIX valid values:
-              8 -- Character or unsigned binary integer
-             16 -- 16-bit two's complement binary integer
-             32 -- 32-bit two's complement binary integer
-            -32 -- 32-bit floating point, single precision
-            -64 -- 64-bit floating point, double precision
+            Determine a keyword and its value.
           */
-         if(fits_info.bits_per_pixel>0)
-            import_options.sample_type = UnsignedQuantumSampleType;
-         if(fits_info.bits_per_pixel<0)          
-            import_options.sample_type = FloatQuantumSampleType;
-        }
-       if(!LocaleNCompare(keyword,"NAXIS",5))
-        {
-          if (keyword[5] == 0) ax_number=-1;          
-          else
-         {
-            if(isdigit((int) keyword[5]))
-              ax_number = MagickAtoI(keyword+5);
-            else ax_number=-2;                 /*unsupported fits keyword*/
-          }
-         y=0;
-          if(ax_number>=-1)
-           y = MagickAtoI(value);
-          switch(ax_number)
-          {
-            case -1:fits_info.number_axes = y; break;
-            case 1: fits_info.columns = (y<=0) ? 1 : y; break;
-           case 2: fits_info.rows = (y<=0) ? 1 : y; break;
-           case 3: fits_info.number_scenes = (y<=0) ? 1 : y; break;
-          }
-          if(ax_number>0)
-          {
-            if(number_pixels == 0)
-              number_pixels = y;
-            else
-              number_pixels *= (y<=0) ? 1 : y;
-          }
+          p=keyword;
+          do
+            {
+              if ((p-keyword) < (FITS_ROW_SIZE-1))
+                *p++=c;
+              if ((c=ReadBlobByte(image)) == EOF)
+                ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+            } while (isalnum(c) || (c == '_'));
+          *p='\0';
+          if (LocaleCompare(keyword,"END") == 0)
+            break;
+          value_expected=False;
+          while (isspace(c) || (c == '='))
+            {
+              if (c == '=')
+                value_expected=True;
+              if ((c=ReadBlobByte(image)) == EOF)
+                ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+            }
+          if (value_expected == False)
+            continue;
+          p=value;
+          if (c == '\'')
+            c=ReadBlobByte(image);
+
+          while (isalnum(c) || (c == '-') || (c == '+') || (c == '.'))
+            {
+              if ((p-value) < (FITS_ROW_SIZE-1))
+                *p++=c;
+              if ((c=ReadBlobByte(image)) == EOF)
+                ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+            }
+          *p='\0';
+          /*
+            Assign a value to the specified keyword.
+          */
+          if (LocaleCompare(keyword,"SIMPLE") == 0)
+            fits_info.simple = (*value=='T') || (*value=='t');
+          if (LocaleCompare(keyword,"EXTEND") == 0)
+            fits_info.extensions_exist = (*value== 'T') || (*value=='t');
+          if (LocaleCompare(keyword,"BITPIX") == 0)
+            {
+              fits_info.bits_per_pixel=MagickAtoI(value);
+              /*
+                BITPIX valid values:
+                8 -- Character or unsigned binary integer
+                16 -- 16-bit two's complement binary integer
+                32 -- 32-bit two's complement binary integer
+                -32 -- 32-bit floating point, single precision
+                -64 -- 64-bit floating point, double precision
+              */
+              if (fits_info.bits_per_pixel > 0)
+                import_options.sample_type = UnsignedQuantumSampleType;
+              if (fits_info.bits_per_pixel < 0)
+                import_options.sample_type = FloatQuantumSampleType;
+            }
+          if (!LocaleNCompare(keyword,"NAXIS",5))
+            {
+              if (keyword[5] == 0) ax_number=-1;
+              else
+                {
+                  if (isdigit((int) keyword[5]))
+                    ax_number = MagickAtoI(keyword+5);
+                  else ax_number=-2;  /*unsupported fits keyword*/
+                }
+              y=0;
+              if (ax_number >= -1)
+                y = MagickAtoI(value);
+              switch (ax_number)
+                {
+                case -1:fits_info.number_axes = y; break;
+                case 1: fits_info.columns = (y <= 0) ? 1 : y; break;
+                case 2: fits_info.rows = (y <= 0) ? 1 : y; break;
+                case 3: fits_info.number_scenes = (y <=0 ) ? 1 : y; break;
+                }
+              if (ax_number > 0)
+                {
+                  if (number_pixels == 0)
+                    number_pixels = (magick_uint64_t) y;
+                  else
+                    number_pixels *= (y <= 0) ? 1U : (magick_uint64_t) y;
+                }
+            }
+
+          if (LocaleCompare(keyword,"DATAMAX") == 0)
+            fits_info.max_data=MagickAtoF(value);
+          if (LocaleCompare(keyword,"DATAMIN") == 0)
+            fits_info.min_data=MagickAtoF(value);
+          if (LocaleCompare(keyword,"BZERO") == 0)
+            fits_info.zero=MagickAtoF(value);
+          if (LocaleCompare(keyword,"BSCALE") == 0)
+            fits_info.scale=MagickAtoF(value);
+          if (LocaleCompare(keyword,"XENDIAN") == 0)
+            {
+              if (LocaleCompare(keyword,"BIG") == 0)
+                import_options.endian = MSBEndian;
+              else
+                import_options.endian = LSBEndian;
+            }
         }
-
-        if (LocaleCompare(keyword,"DATAMAX") == 0)
-          fits_info.max_data=MagickAtoF(value);
-        if (LocaleCompare(keyword,"DATAMIN") == 0)
-          fits_info.min_data=MagickAtoF(value);
-        if (LocaleCompare(keyword,"BZERO") == 0)
-          fits_info.zero=MagickAtoF(value);
-        if (LocaleCompare(keyword,"BSCALE") == 0)
-          fits_info.scale=MagickAtoF(value);
-        if (LocaleCompare(keyword,"XENDIAN") == 0)
-        {
-         if (LocaleCompare(keyword,"BIG") == 0)
-           import_options.endian = MSBEndian;
-          else
-           import_options.endian = LSBEndian;          
-       }
-      }
-    while ((TellBlob(image) % 80) != 0)
+      while ((TellBlob(image) % 80) != 0)
+        if ((c=ReadBlobByte(image)) == EOF)
+          ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
       if ((c=ReadBlobByte(image)) == EOF)
         ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-    if ((c=ReadBlobByte(image)) == EOF)
-      ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-  }
+    }
 
-  while ((TellBlob(image) % FITS_BLOCK_SIZE) != 0)             /* Read till the rest of a block. */
+  while ((TellBlob(image) % FITS_BLOCK_SIZE) != 0) /* Read till the rest of a block. */
     if ((c=ReadBlobByte(image)) == EOF)
       ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
 
   /*
     Verify that required image information is defined.
-  */  
+  */
   if (logging)
     {
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                            "HDU read finished at %Xh, number of pixel is: %d (%d*%d*%d)",
-                            (unsigned) TellBlob(image),
-                            (unsigned) number_pixels,
-                            (unsigned) fits_info.columns,
-                            (unsigned) fits_info.rows,
-                            (unsigned) fits_info.number_scenes);
+                            "HDU read finished at offset %" MAGICK_OFF_F "Xh, "
+                            "number of pixels is: %" MAGICK_UINT64_F "u (%d*%d*%d)",
+                            TellBlob(image),
+                            number_pixels,
+                            fits_info.columns,
+                            fits_info.rows,
+                            fits_info.number_scenes);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                             "FITS header:\n"
                             "    extensions_exist : 0x%02x\n"
@@ -420,171 +447,247 @@ ReadExtension:
       (fits_info.bits_per_pixel != -64))
     ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
 
-  if ((!fits_info.simple) || (fits_info.number_axes < 1) ||
-      (fits_info.number_axes > 4) || (number_pixels == 0))
-  {
-    if(!fits_info.extensions_exist)    /* when extensions exists, process further */
-      ThrowReaderException(CorruptImageError,ImageTypeNotSupported,image);
-
-    number_pixels = (number_pixels*AbsoluteValue(fits_info.bits_per_pixel)) / 8;
-    number_pixels = ((number_pixels+FITS_BLOCK_SIZE-1) / FITS_BLOCK_SIZE) * FITS_BLOCK_SIZE; /* raw data block size */
-    (void) SeekBlob(image,number_pixels,SEEK_CUR);    
-  }
-  else
-  {
-   number_pixels = fits_info.columns*fits_info.rows; 
-   for (scene=0; scene < (long) fits_info.number_scenes; scene++)
-   {
-      if(image->rows!=0 && image->columns!=0)
-      {
-        /*
-          Allocate next image structure.
-        */
-        AllocateNextImage(image_info,image);
-        if (image->next == (Image *) NULL)
-          {
-            DestroyImageList(image);
-            return((Image *) NULL);
-          }
-        image=SyncNextImageInList(image);
-        if (!MagickMonitorFormatted(TellBlob(image),GetBlobSize(image),exception,
-                                    LoadImagesText,image->filename))
-          break;
-      }
-
-    /*
-      Create linear colormap.
-    */
-    image->columns = fits_info.columns;
-    image->rows = fits_info.rows;
-    if(fits_info.bits_per_pixel>=0)
-      image->depth = Min(QuantumDepth,fits_info.bits_per_pixel);
-    else
-      image->depth = QuantumDepth;             /* double type cell */
-    /* image->storage_class=PseudoClass; */
-    image->storage_class = DirectClass;
-    image->scene=scene;
-    image->is_grayscale = 1;
-
-    if (image->depth<=8 && fits_info.bits_per_pixel==8)
-      if (!AllocateImageColormap(image,1 << image->depth))
-        ThrowReaderException(FileOpenError,UnableToOpenFile,image);
-
-    if (image_info->ping && (image_info->subrange != 0))
-      if (image->scene >= (image_info->subimage+image_info->subrange-1))
-        break;
+  if ((fits_info.columns <= 0) ||
+      (fits_info.rows <= 0) ||
+      (fits_info.number_axes < 0) ||
+      (fits_info.number_scenes < 0))
+    ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
 
-    /*
-      Initialize image structure.
-    */
-    packet_size=AbsoluteValue(fits_info.bits_per_pixel)/8;
-        
-    number_pixels = image->columns*image->rows;
-    if ((number_pixels / image->columns) != image->rows)
-      ThrowReaderException(CoderError,ImageColumnOrRowSizeIsNotSupported,image);
-
-    fits_pixels=MagickAllocateArray(unsigned char *, image->columns, packet_size);
-    if (fits_pixels == (unsigned char *) NULL)
-      ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-
-    /*
-      Recover minimum and maximum from data if not present in HDU
-    */     
-    if ((fits_info.min_data == 0.0) && (fits_info.max_data == 0.0))
-    {  /*  Determine minimum and maximum intensity. */
-      if(fits_info.bits_per_pixel==-32)
-        (void) MagickFindRawImageMinMax(image, import_options.endian, image->columns,
-                                        image->rows, FloatPixel, packet_size*image->columns,
-                                        fits_pixels, &import_options.double_minvalue,
-                                        &import_options.double_maxvalue);
-      if(fits_info.bits_per_pixel==-64)
-        (void) MagickFindRawImageMinMax(image, import_options.endian, image->columns,
-                                        image->rows, DoublePixel, packet_size*image->columns,
-                                        fits_pixels, &import_options.double_minvalue,
-                                        &import_options.double_maxvalue);
-    }
-    else
+  /*
+    Validate that remaining file size is sufficient for claimed
+    image properties
+  */
+  packet_size=AbsoluteValue(fits_info.bits_per_pixel)/8;
+  remaining = file_size-TellBlob(image);
+  if (remaining == 0)
     {
-      import_options.double_maxvalue = fits_info.max_data;
-      import_options.double_minvalue = fits_info.min_data;
+      ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,
+                           image);
     }
+  if (file_size != 0)
+    {
+      double
+        ratio = (((double) number_pixels*packet_size)/remaining);
 
-    /*
-      Convert FITS pixels to pixel packets.
-    */
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "Remaining: %" MAGICK_OFF_F "d, Ratio: %g",
+                            remaining, ratio);
 
-    for (y=(long) image->rows-1; y >= 0; y--)
+      if (ratio > 1.5)
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Unreasonable file size "
+                                "(ratio of pixels to remaining file size %g)",
+                                ratio);
+          ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,
+                               image);
+        }
+    }
+
+  if ((!fits_info.simple) || (fits_info.number_axes < 1) ||
+      (fits_info.number_axes > 4) || (number_pixels == 0))
     {
-      q=SetImagePixels(image,0,y,image->columns,1);
-      if (q == (PixelPacket *) NULL)
-        break;
+      if (!fits_info.extensions_exist)     /* when extensions exists, process further */
+        ThrowReaderException(CorruptImageError,ImageTypeNotSupported,image);
 
-      if(ReadBlob(image, packet_size*image->columns, fits_pixels) != (size_t)packet_size*image->columns)
-      {
-       if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
-           "  fits cannot read scanrow %u from a file.", (unsigned)y );
-       break; /* goto ExitLoop; */
-      }
-
-      switch(fits_info.bits_per_pixel)
-      {
-        case 16: FixSignedValues(fits_pixels, image->columns, 2, import_options.endian);
-                break;
-        case 32: FixSignedValues(fits_pixels, image->columns, 4, import_options.endian);
-                break;
-       case 64: FixSignedValues(fits_pixels, image->columns, 8, import_options.endian);
-                break;
-      }
-
-      if(ImportImagePixelArea(image, GrayQuantum, packet_size*8, fits_pixels, &import_options,0) == MagickFail)
-      {
-        if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
-               "  fits failed to ImportImagePixelArea for a row %u", (unsigned)y);
-       break;
-      }
-
-      if (!SyncImagePixels(image))
-        break;
-      if (QuantumTick(y,image->rows))
-        if (!MagickMonitorFormatted(y,image->rows,exception,
-                                    LoadImageText,image->filename,
-                                   image->columns,image->rows))
-          break;
+      number_pixels = (number_pixels*AbsoluteValue(fits_info.bits_per_pixel)) / 8;
+      number_pixels = ((number_pixels+FITS_BLOCK_SIZE-1) /
+                       FITS_BLOCK_SIZE) * FITS_BLOCK_SIZE; /* raw data block size */
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "Seek CUR: %" MAGICK_OFF_F "u",(magick_off_t) number_pixels);
+      SeekBlob(image,(magick_off_t) number_pixels,SEEK_CUR);
     }
-    MagickFreeMemory(fits_pixels);
-    if (EOFBlob(image))
-      {
-        ThrowException(exception,CorruptImageError,UnexpectedEndOfFile, image->filename);
-        break;
-      }
-
-    /*
-      Proceed to next image.
-    */
-    if (image_info->subrange != 0)
-      if (image->scene >= (image_info->subimage+image_info->subrange-1))
-        break;    
+  else
+    {
+      for (scene=0; scene < (long) fits_info.number_scenes; scene++)
+        {
+          if (image->rows!=0 && image->columns!=0)
+            {
+              /*
+                Allocate next image structure.
+              */
+              AllocateNextImage(image_info,image);
+              if (image->next == (Image *) NULL)
+                {
+                  DestroyImageList(image);
+                  return((Image *) NULL);
+                }
+              image=SyncNextImageInList(image);
+              if (!MagickMonitorFormatted(TellBlob(image),file_size,exception,
+                                          LoadImagesText,image->filename))
+                break;
+            }
+
+          /*
+            Create linear colormap.
+          */
+          image->columns = fits_info.columns;
+          image->rows = fits_info.rows;
+          if (fits_info.bits_per_pixel>=0)
+            image->depth = Min(QuantumDepth,fits_info.bits_per_pixel);
+          else
+            image->depth = QuantumDepth;              /* double type cell */
+          /* image->storage_class=PseudoClass; */
+          image->storage_class = DirectClass;
+          image->scene=scene;
+          image->is_grayscale = 1;
+
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Frame[%lu] geometry %lux%lu, %u bits/pixel, %s",
+                                  scene, image->columns, image->rows,
+                                  fits_info.bits_per_pixel,
+                                  ClassTypeToString(image->storage_class));
+
+          if (image->depth<=8 && fits_info.bits_per_pixel==8)
+            if (!AllocateImageColormap(image,1 << image->depth))
+              ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+
+          if (image_info->ping && (image_info->subrange != 0))
+            if (image->scene >= (image_info->subimage+image_info->subrange-1))
+              break;
+
+          if (CheckImagePixelLimits(image, exception) != MagickPass)
+            ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+
+          /*
+            Initialize image structure.
+          */
+          packet_size=AbsoluteValue(fits_info.bits_per_pixel)/8;
+
+          /*
+            Validate that remaining file size is sufficient for claimed
+            image properties
+          */
+          remaining = file_size-TellBlob(image);
+          if (remaining == 0)
+            {
+              ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,
+                                   image);
+            }
+          if (file_size != 0)
+            {
+              double
+                ratio = (((double) image->columns*image->rows*packet_size)/remaining);
+
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Remaining: %" MAGICK_OFF_F "d, Ratio: %g",
+                                    remaining, ratio);
+
+              if (ratio > 1.5)
+                {
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                        "Unreasonable file size "
+                                        "(ratio of pixels to remaining file size %g)",
+                                        ratio);
+                  ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,
+                                       image);
+                }
+            }
+
+          fits_pixels=MagickAllocateArray(unsigned char *, image->columns, packet_size);
+          if (fits_pixels == (unsigned char *) NULL)
+            ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+
+          /*
+            Recover minimum and maximum from data if not present in HDU
+          */
+          if ((fits_info.min_data == 0.0) && (fits_info.max_data == 0.0))
+            {  /*  Determine minimum and maximum intensity. */
+              if (fits_info.bits_per_pixel==-32)
+                (void) MagickFindRawImageMinMax(image, import_options.endian, image->columns,
+                                                image->rows, FloatPixel, packet_size*image->columns,
+                                                fits_pixels, &import_options.double_minvalue,
+                                                &import_options.double_maxvalue);
+              if (fits_info.bits_per_pixel==-64)
+                (void) MagickFindRawImageMinMax(image, import_options.endian, image->columns,
+                                                image->rows, DoublePixel, packet_size*image->columns,
+                                                fits_pixels, &import_options.double_minvalue,
+                                                &import_options.double_maxvalue);
+            }
+          else
+            {
+              import_options.double_maxvalue = fits_info.max_data;
+              import_options.double_minvalue = fits_info.min_data;
+            }
+
+          /*
+            Convert FITS pixels to pixel packets.
+          */
+
+          for (y=(long) image->rows-1; y >= 0; y--)
+            {
+              q=SetImagePixels(image,0,y,image->columns,1);
+              if (q == (PixelPacket *) NULL)
+                break;
+
+              if (ReadBlob(image, packet_size*image->columns, fits_pixels) != (size_t)packet_size*image->columns)
+                {
+                  if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+                                                    "  fits cannot read scanrow %u from a file.", (unsigned)y );
+                  break; /* goto ExitLoop; */
+                }
+
+              switch(fits_info.bits_per_pixel)
+                {
+                case 16: FixSignedValues(fits_pixels, image->columns, 2, import_options.endian);
+                  break;
+                case 32: FixSignedValues(fits_pixels, image->columns, 4, import_options.endian);
+                  break;
+                case 64: FixSignedValues(fits_pixels, image->columns, 8, import_options.endian);
+                  break;
+                }
+
+              if (ImportImagePixelArea(image, GrayQuantum, packet_size*8, fits_pixels, &import_options,0) == MagickFail)
+                {
+                  if (logging)
+                    (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+                                         "  fits failed to ImportImagePixelArea for a row %u", (unsigned)y);
+                  break;
+                }
+
+              if (!SyncImagePixels(image))
+                break;
+              if (QuantumTick(y,image->rows))
+                if (!MagickMonitorFormatted(y,image->rows,exception,
+                                            LoadImageText,image->filename,
+                                            image->columns,image->rows))
+                  break;
+            }
+          MagickFreeMemory(fits_pixels);
+          if (EOFBlob(image))
+            {
+              ThrowException(exception,CorruptImageError,UnexpectedEndOfFile, image->filename);
+              break;
+            }
+
+          /*
+            Proceed to next image.
+          */
+          if (image_info->subrange != 0)
+            if (image->scene >= (image_info->subimage+image_info->subrange-1))
+              break;
+        }
     }
-  }
 
-  if(fits_info.extensions_exist)
-  {
-    while ((TellBlob(image) % FITS_BLOCK_SIZE) != 0) /* Read till the rest of a block. */
-      if ((c=ReadBlobByte(image)) == EOF)
-        break;
-    if(!EOFBlob(image))
-    {                                          /* Try to read a next extension block header. */
-      if ((c=ReadBlobByte(image)) != EOF)
-       goto ReadExtension;
+  if (fits_info.extensions_exist)
+    {
+      while ((TellBlob(image) % FITS_BLOCK_SIZE) != 0) /* Read till the rest of a block. */
+        if ((c=ReadBlobByte(image)) == EOF)
+          break;
+      if (!EOFBlob(image))
+        {                                           /* Try to read a next extension block header. */
+          if ((c=ReadBlobByte(image)) != EOF)
+            goto ReadExtension;
+        }
     }
-  }
 
   CloseBlob(image);
 
   while (image->previous != (Image *) NULL)
-    image=image->previous;  
+    image=image->previous;
 
-  if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),"return");  
+  if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),"return");
   return(image);
 }
 \f
@@ -655,7 +758,7 @@ ModuleExport void UnregisterFITSImage(void)
 /*
   This functions inserts one row into a HDU. Note that according to
   FITS spec a card image contains 80 bytes of ASCII data.
-  
+
   buffer - 2880 byte logical FITS record.
   data   - string data to append
   offset - offset into FITS record to write the data.
@@ -671,7 +774,7 @@ int InsertRowHDU(char *buffer, const char *data, int offset)
   len = Min(len,80); /* Each card image is 80 bytes max */
 
   if (len > (size_t) (FITS_BLOCK_SIZE-offset))
-       len = FITS_BLOCK_SIZE-offset;
+        len = FITS_BLOCK_SIZE-offset;
 
   (void) strncpy(buffer+offset,data,len);
   return offset +80;
@@ -707,7 +810,7 @@ int InsertRowHDU(char *buffer, const char *data, int offset)
 %
 %
 */
-static unsigned int WriteFITSImage(const ImageInfo *image_info,Image *image)
+static MagickPassFail WriteFITSImage(const ImageInfo *image_info,Image *image)
 {
   char
     buffer[FITS_BLOCK_SIZE],
@@ -717,20 +820,22 @@ static unsigned int WriteFITSImage(const ImageInfo *image_info,Image *image)
     y;
 
   register const PixelPacket
-    *p;  
+    *p;
 
   unsigned char
     *pixels;
 
-  unsigned int    
-    quantum_size,
-    status;
+  unsigned int
+    quantum_size;
 
   unsigned long
     packet_size;
 
   ExportPixelAreaOptions export_options;
 
+  MagickPassFail
+    status;
+
   /*
     Open output image file.
   */
@@ -739,34 +844,42 @@ static unsigned int WriteFITSImage(const ImageInfo *image_info,Image *image)
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
-  if (status == False)
+  if (status == MagickFail)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
-  (void) TransformColorspace(image,RGBColorspace);
+  if (TransformColorspace(image,RGBColorspace) == MagickFail)
+    {
+      CloseBlob(image);
+      return MagickFail;
+    }
 
   ExportPixelAreaOptionsInit(&export_options);
   export_options.endian = MSBEndian;
   export_options.sample_type = UnsignedQuantumSampleType;
 
   if (image->depth <= 8)
-  {
-    quantum_size=8;    
-  }
+    {
+      quantum_size=8;
+    }
   else if (image->depth <= 16)
-  {    
-    quantum_size=16;
-  }
+    {
+      quantum_size=16;
+    }
   else
-  {   
-    quantum_size=32;
-  }
+    {
+      quantum_size=32;
+    }
 
   /*
     Allocate image memory.
-  */  
+  */
   packet_size=quantum_size/8;
   fits_info=MagickAllocateMemory(char *,FITS_BLOCK_SIZE);
-  pixels=MagickAllocateMemory(unsigned char *,packet_size*image->columns);
-  if ((fits_info == (char *) NULL) || (pixels == (unsigned char *) NULL))
+  if (fits_info == (char *) NULL)
+    {
+      ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+    }
+  pixels=MagickAllocateArray(unsigned char *,packet_size,image->columns);
+  if (pixels == (unsigned char *) NULL)
     {
       MagickFreeMemory(fits_info);
       ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
@@ -774,7 +887,7 @@ static unsigned int WriteFITSImage(const ImageInfo *image_info,Image *image)
 
   /*
     Initialize image header.
-  */  
+  */
   memset(fits_info,' ',FITS_BLOCK_SIZE);
   y = 0;
   y = InsertRowHDU(fits_info, "SIMPLE  =                    T", y);
@@ -783,53 +896,57 @@ static unsigned int WriteFITSImage(const ImageInfo *image_info,Image *image)
   y = InsertRowHDU(fits_info, "NAXIS   =                    2", y);
   FormatString(buffer,        "NAXIS1  =           %10lu",image->columns);
   y = InsertRowHDU(fits_info, buffer, y);
-  FormatString(buffer,        "NAXIS2  =           %10lu",image->rows); 
-  y = InsertRowHDU(fits_info, buffer, y);  
+  FormatString(buffer,        "NAXIS2  =           %10lu",image->rows);
+  y = InsertRowHDU(fits_info, buffer, y);
   FormatString(buffer,        "DATAMIN =           %10u",0);
-  y = InsertRowHDU(fits_info, buffer, y);    
+  y = InsertRowHDU(fits_info, buffer, y);
   FormatString(buffer,        "DATAMAX =           %10lu", MaxValueGivenBits(quantum_size));
   y = InsertRowHDU(fits_info, buffer, y);
-  if(quantum_size>8)
-  {
-    FormatString(buffer,      "BZERO   =           %10u", (quantum_size <= 16) ? 32768U : 2147483648U);
-    y = InsertRowHDU(fits_info, buffer, y);
-  }
+  if (quantum_size>8)
+    {
+      FormatString(buffer,      "BZERO   =           %10u", (quantum_size <= 16) ? 32768U : 2147483648U);
+      y = InsertRowHDU(fits_info, buffer, y);
+    }
   /* Magick version data can only be 60 bytes. */
   (void) FormatString(buffer, "HISTORY Created by %.60s.",MagickPackageName " " MagickLibVersionText);
   y = InsertRowHDU(fits_info, buffer, y);
-  y = InsertRowHDU(fits_info, "END", y);        
+  y = InsertRowHDU(fits_info, "END", y);
   (void) WriteBlob(image, FITS_BLOCK_SIZE, (char *)fits_info);
-  
+
   /*
     Convert image to fits scale PseudoColor class.
   */
   for (y=(long) image->rows-1; y >= 0; y--)
-  {
-    p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
-    if (p == (const PixelPacket *) NULL)
-      break;
-    (void) ExportImagePixelArea(image,GrayQuantum,quantum_size,pixels,&export_options,0);
-    if(quantum_size==16) FixSignedValues(pixels, image->columns, 2, export_options.endian);
-    if(quantum_size==32) FixSignedValues(pixels, image->columns, 4, export_options.endian);
-    (void) WriteBlob(image,packet_size*image->columns,pixels);
-    if (QuantumTick(image->rows-y-1,image->rows))
-      {
-        status=MagickMonitorFormatted(image->rows-y-1,image->rows,
-                                      &image->exception,SaveImageText,
-                                      image->filename,
-                                     image->columns,image->rows);
-        if (status == False)
-          break;
-      }
-  }
-  
-       /* Calculate of padding */
+    {
+      p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
+      if (p == (const PixelPacket *) NULL)
+        break;
+      if (ExportImagePixelArea(image,GrayQuantum,quantum_size,pixels,&export_options,0) == MagickFail)
+        break;
+      if (quantum_size == 16)
+        FixSignedValues(pixels, image->columns, 2, export_options.endian);
+      if (quantum_size == 32)
+        FixSignedValues(pixels, image->columns, 4, export_options.endian);
+      if (WriteBlob(image,packet_size*image->columns,pixels) != packet_size*image->columns)
+        break;
+      if (QuantumTick(image->rows-y-1,image->rows))
+        {
+          status=MagickMonitorFormatted(image->rows-y-1,image->rows,
+                                        &image->exception,SaveImageText,
+                                        image->filename,
+                                        image->columns,image->rows);
+          if (status == False)
+            break;
+        }
+    }
+
+  /* Calculate of padding */
   y = FITS_BLOCK_SIZE - (image->columns * image->rows * packet_size) % FITS_BLOCK_SIZE;
-  if(y>0)
-  {
-    memset(fits_info, 0, y);    
-    (void)WriteBlob(image,y,(char *) fits_info);
-  }
+  if (y > 0)
+    {
+      memset(fits_info, 0, y);
+      (void)WriteBlob(image,y,(char *) fits_info);
+    }
   MagickFreeMemory(fits_info);
 
   MagickFreeMemory(pixels);
index aba1856..9ef234f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -393,7 +393,7 @@ static Image *ReadFPXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     q=SetImagePixels(image,0,y,image->columns,1);
     if (q == (PixelPacket *) NULL)
       break;
-    indexes=GetIndexes(image);
+    indexes=AccessMutableIndexes(image);
     if ((y % tile_height) == 0)
       {
         /*
index 596d670..073d3bc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -85,17 +85,15 @@ static unsigned int
 %
 %
 */
-#define MaxStackSize  4096L
-#define NullCode  (-1)
+#define MaxStackSize  4096
+#define NullCode (~0U)
 static MagickPassFail DecodeImage(Image *image,const long opacity)
 {
   int
     bits,
-    code_size,
-    offset,
-    pass;
+    code_size;
 
-  long
+  unsigned int
     available,
     clear,
     code,
@@ -103,12 +101,16 @@ static MagickPassFail DecodeImage(Image *image,const long opacity)
     end_of_information,
     in_code,
     old_code,
-    y;
+    pass;
+
+  unsigned long
+    y,
+    offset;
 
   register IndexPacket
     *indexes;
 
-  register long
+  register unsigned long
     x;
 
   register PixelPacket
@@ -117,13 +119,13 @@ static MagickPassFail DecodeImage(Image *image,const long opacity)
   register unsigned char
     *c;
 
-  register unsigned long
+  register unsigned int
     datum;
 
   size_t
     count;
 
-  short
+  unsigned short
     *prefix;
 
   unsigned char
@@ -141,17 +143,17 @@ static MagickPassFail DecodeImage(Image *image,const long opacity)
   assert(image != (Image *) NULL);
 
   data_size=ReadBlobByte(image);
-  if (data_size > 8U)
+  if (data_size > 8U) /* 256 */
     ThrowBinaryException(CorruptImageError,CorruptImage,image->filename);
   /*
     Allocate decoder tables.
   */
   packet=MagickAllocateMemory(unsigned char *,256);
-  prefix=MagickAllocateArray(short *,MaxStackSize,sizeof(short));
+  prefix=MagickAllocateArray(unsigned short *,MaxStackSize,sizeof(short));
   suffix=MagickAllocateMemory(unsigned char *,MaxStackSize);
   pixel_stack=MagickAllocateMemory(unsigned char *,MaxStackSize+1);
   if ((packet == (unsigned char *) NULL) ||
-      (prefix == (short *) NULL) ||
+      (prefix == (unsigned short *) NULL) ||
       (suffix == (unsigned char *) NULL) ||
       (pixel_stack == (unsigned char *) NULL))
     {
@@ -165,19 +167,23 @@ static MagickPassFail DecodeImage(Image *image,const long opacity)
   /*
     Initialize GIF data stream decoder.
   */
-  clear=1 << data_size;
+  (void) memset(packet,0,256);
+  (void) memset(prefix,0,MaxStackSize*sizeof(short));
+  (void) memset(suffix,0,MaxStackSize);
+  (void) memset(pixel_stack,0,MaxStackSize+1);
+  clear=1U << data_size;
   end_of_information=clear+1;
   available=clear+2;
   old_code=NullCode;
   code_size=data_size+1;
-  code_mask=(1 << code_size)-1;
+  code_mask=(1U << code_size)-1;
   (void) memset(prefix,0,MaxStackSize*sizeof(short));
   (void) memset(suffix,0,MaxStackSize);
   for (code=0; code < clear; code++)
-  {
-    prefix[code]=0;
-    suffix[code]=(unsigned char) code;
-  }
+    {
+      prefix[code]=0;
+      suffix[code]=(unsigned char) code;
+    }
   /*
     Decode GIF pixel stream.
   */
@@ -189,196 +195,218 @@ static MagickPassFail DecodeImage(Image *image,const long opacity)
   offset=0;
   pass=0;
   top_stack=pixel_stack;
-  for (y=0; y < (long) image->rows; y++)
-  {
-    q=SetImagePixels(image,0,offset,image->columns,1);
-    if (q == (PixelPacket *) NULL)
-      {
-        status=MagickFail;
-        break;
-      }
-    indexes=AccessMutableIndexes(image);
-    for (x=0; x < (long) image->columns; )
+  for (y=0; y < image->rows; y++)
     {
-      if (top_stack == pixel_stack)
+      q=SetImagePixels(image,0,offset,image->columns,1);
+      if (q == (PixelPacket *) NULL)
+        {
+          status=MagickFail;
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Breaking");
+          break;
+        }
+      indexes=AccessMutableIndexes(image);
+      for (x=0; x < image->columns; )
         {
-          if (bits < code_size)
+          if (top_stack == pixel_stack)
             {
+              if (bits < code_size)
+                {
+                  /*
+                    Load bytes until there is enough bits for a code.
+                  */
+                  if (count == 0)
+                    {
+                      /*
+                        Read a new data block.
+                      */
+                      count=ReadBlobBlock(image,packet);
+                      if (count == 0)
+                        break;
+                      c=packet;
+                    }
+                  datum+=((unsigned int) *c) << bits;
+                  bits+=8;
+                  c++;
+                  count--;
+                  continue;
+                }
+              /*
+                Get the next code.
+              */
+              code=datum & code_mask;
+              datum>>=code_size;
+              bits-=code_size;
               /*
-                Load bytes until there is enough bits for a code.
+                Interpret the code
               */
-              if (count == 0)
+              if (code == end_of_information)
+                break;
+              if (code == clear)
                 {
                   /*
-                    Read a new data block.
+                    Reset decoder.
                   */
-                  count=ReadBlobBlock(image,packet);
-                  if (count == 0)
-                    break;
-                  c=packet;
+                  code_size=data_size+1;
+                  code_mask=(1U << code_size)-1;
+                  available=clear+2;
+                  old_code=NullCode;
+                  continue;
                 }
-              datum+=(unsigned long) (*c) << bits;
-              bits+=8;
-              c++;
-              count--;
-              continue;
-            }
-          /*
-            Get the next code.
-          */
-          code=(long) (datum & code_mask);
-          datum>>=code_size;
-          bits-=code_size;
-          /*
-            Interpret the code
-          */
-          if (code == end_of_information)
-            break;
-          if (code == clear)
-            {
+              if (old_code == NullCode)
+                {
+                  *top_stack++=suffix[code];
+                  old_code=code;
+                  first=(unsigned char) code;
+                  continue;
+                }
+              in_code=code;
+              if (code >= available)
+                {
+                  *top_stack++=first;
+                  code=old_code;
+                }
+              while (code >= clear)
+                {
+                  if (code >= MaxStackSize)
+                    {
+                      if (image->logging)
+                        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                              "Suffix index (%u) is outside of"
+                                              " bounds (0-%u)", code, MaxStackSize);
+                      status=MagickFail;
+                      break;
+                    }
+                  if ((top_stack-pixel_stack) >= MaxStackSize)
+                    {
+                      if (image->logging)
+                        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                              "Attempted overrun of pixel stack bounds");
+                      status=MagickFail;
+                      break;
+                    }
+                  *top_stack++=suffix[code];
+                  code=prefix[code];
+                }
+              if (status == MagickFail)
+                break;
+              first=suffix[code];
               /*
-                Reset decoder.
+                Add a new string to the string table,
               */
-              code_size=data_size+1;
-              code_mask=(1 << code_size)-1;
-              available=clear+2;
-              old_code=NullCode;
-              continue;
-            }
-          if (old_code == NullCode)
-            {
-              *top_stack++=suffix[code];
-              old_code=code;
-              first=(unsigned char) code;
-              continue;
-            }
-          in_code=code;
-          if (code >= available)
-            {
+              if (available < MaxStackSize)
+                {
+                  prefix[available]=(short) old_code;
+                  suffix[available]=first;
+                  available++;
+                  if (available >= (code_mask + 1) && code_size < 12)
+                    {
+                      code_size++;
+                      code_mask+=available;
+                    }
+                }
               *top_stack++=first;
-              code=old_code;
+              old_code=in_code;
             }
-          /*
-            FIXME: Is the logic for this loop (or the loop which inits
-            suffix and prefix arrays) correct?  Values are
-            intentionally accessed outside of the explictly
-            initialized range of 'clear'.
-          */
-          while (code >= clear)
-          {
-            if ((top_stack-pixel_stack) >= MaxStackSize)
-              {
-                status=MagickFail;
-                break;
-              }
-            *top_stack++=suffix[code];
-            code=prefix[code];
-          }
           if (status == MagickFail)
             break;
-          first=suffix[code];
           /*
-            Add a new string to the string table,
+            Pop a pixel off the pixel stack.
           */
-          if (available < MaxStackSize)
-            {
-              prefix[available]=(short) old_code;
-              suffix[available]=first;
-              available++;
-            if (available >= (code_mask + 1) && code_size < 12)
-              {
-                code_size++;
-                code_mask+=available;
-              }
-            }
-          *top_stack++=first;
-          old_code=in_code;
+          top_stack--;
+          index=(*top_stack);
+          VerifyColormapIndex(image,index);
+          indexes[x]=index;
+          *q=image->colormap[index];
+          q->opacity=(Quantum)
+            (index == opacity ? TransparentOpacity : OpaqueOpacity);
+          x++;
+          q++;
         }
-      /*
-        Pop a pixel off the pixel stack.
-      */
-      top_stack--;
-      index=(*top_stack);
-      VerifyColormapIndex(image,index);
-      indexes[x]=index;
-      *q=image->colormap[index];
-      q->opacity=(Quantum)
-        (index == opacity ? TransparentOpacity : OpaqueOpacity);
-      x++;
-      q++;
-    }
-    if (image->interlace == NoInterlace)
-      offset++;
-    else
-      switch (pass)
-      {
-        case 0:
-        default:
+      if (image->interlace == NoInterlace)
         {
-          offset+=8;
-          if (offset >= (long) image->rows)
+          offset++;
+        }
+      else
+        switch (pass)
+          {
+          case 0:
+          default:
             {
-              pass++;
-              offset=4;
+              offset+=8;
+              if (offset >= image->rows)
+                {
+                  pass++;
+                  offset=4;
+                }
+              break;
             }
-          break;
-        }
-        case 1:
-        {
-          offset+=8;
-          if (offset >= (long) image->rows)
+          case 1:
             {
-              pass++;
-              offset=2;
+              offset+=8;
+              if (offset >= image->rows)
+                {
+                  pass++;
+                  offset=2;
+                }
+              break;
             }
-          break;
-        }
-        case 2:
-        {
-          offset+=4;
-          if (offset >= (long) image->rows)
+          case 2:
             {
-              pass++;
-              offset=1;
+              offset+=4;
+              if (offset >= image->rows)
+                {
+                  pass++;
+                  offset=1;
+                }
+              break;
             }
+          case 3:
+            {
+              offset+=2;
+              break;
+            }
+          }
+      if (!SyncImagePixels(image))
+        {
+          status=MagickFail;
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Failed to sync image pixels");
           break;
         }
-        case 3:
+      if (x < image->columns)
         {
-          offset+=2;
+          status=MagickFail;
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Quitting, LZW decode."
+                                  " Decoded only %lu columns out of %lu.",
+                                  x, image->columns);
           break;
         }
-      }
-    if (!SyncImagePixels(image))
-      {
-        status=MagickFail;
-        break;
-      }
-    if (x < (long) image->columns)
-      {
-        status=MagickFail;
-        break;
-      }
-    if (image->previous == (Image *) NULL)
-      if (QuantumTick(y,image->rows))
-        if (!MagickMonitorFormatted(y,image->rows,&image->exception,
-                                    LoadImageText,image->filename,
-                                   image->columns,image->rows))
-          {
-            status=MagickFail;
-            break;
-          }
-  }
+      if (image->previous == (Image *) NULL)
+        if (QuantumTick(y,image->rows))
+          if (!MagickMonitorFormatted(y,image->rows,&image->exception,
+                                      LoadImageText,image->filename,
+                                      image->columns,image->rows))
+            {
+              status=MagickFail;
+              break;
+            }
+    }
   MagickFreeMemory(pixel_stack);
   MagickFreeMemory(suffix);
   MagickFreeMemory(prefix);
   MagickFreeMemory(packet);
-  if ((status == MagickFail) || (y < (long) image->rows))
+  if ((status == MagickFail) || (y < image->rows))
     {
+      if ((image->logging) && (y < image->rows))
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Decoded only %lu rows out of %lu.",
+                              y, image->rows);
       if (image->exception.severity < ErrorException)
-      {
         ThrowException(&image->exception,CorruptImageError,CorruptImage,image->filename);
-      }
       return MagickFail;
     }
   return(MagickPass);
@@ -415,10 +443,10 @@ static MagickPassFail DecodeImage(Image *image,const long opacity)
 %
 %
 */
-#define MaxCode(number_bits)  ((1 << (number_bits))-1)
+#define MaxCode(number_bits)  ((short) ((1U << (number_bits))-1))
 #define MaxHashTable  5003
 #define MaxGIFBits  12
-#define MaxGIFTable  (1 << MaxGIFBits)
+#define MaxGIFTable  ((short) (1U << MaxGIFBits))
 
 #define GIFOutputCode(code) \
 { \
@@ -426,9 +454,9 @@ static MagickPassFail DecodeImage(Image *image,const long opacity)
     Emit a code. \
   */ \
   if (bits > 0) \
-    datum|=((long) code << bits); \
+    datum|=((unsigned int) code << bits); \
   else \
-    datum=(long) code; \
+    datum=(unsigned int) code; \
   bits+=number_bits; \
   while (bits >= 8) \
   { \
@@ -519,7 +547,7 @@ static MagickPassFail EncodeImage(const ImageInfo *image_info,Image *image,
   */
   number_bits=data_size;
   max_code=MaxCode(number_bits);
-  clear_code=((short) 1 << (data_size-1));
+  clear_code=((short) 1U << (data_size-1));
   end_of_information_code=clear_code+1;
   free_code=clear_code+2;
   byte_count=0;
@@ -549,7 +577,7 @@ static MagickPassFail EncodeImage(const ImageInfo *image_info,Image *image,
       */
       index=indexes[x] & 0xff;
       p++;
-      k=(int) ((int) index << (MaxGIFBits-8))+waiting_code;
+      k=(int) ((unsigned int) index << (MaxGIFBits-8))+waiting_code;
       if (k >= MaxHashTable)
         k-=MaxHashTable;
       next_pixel=False;
@@ -605,7 +633,7 @@ static MagickPassFail EncodeImage(const ImageInfo *image_info,Image *image,
       waiting_code=index;
     }
     if ((image_info->interlace == NoInterlace) ||
-       (image_info->interlace == UndefinedInterlace))
+        (image_info->interlace == UndefinedInterlace))
       offset++;
     else
       switch (pass)
@@ -651,7 +679,7 @@ static MagickPassFail EncodeImage(const ImageInfo *image_info,Image *image,
       if (QuantumTick(y,image->rows))
         if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                     SaveImageText,image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
   }
   /*
@@ -772,7 +800,7 @@ static size_t ReadBlobBlock(Image *image,unsigned char *data)
   if (ReadBlob(image,1,&block_count) == 1)
     {
       if ((count=ReadBlob(image,(size_t) block_count,data)) != (size_t) block_count)
-       count=0;
+        count=0;
     }
   return count;
 }
@@ -841,10 +869,12 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
     header[MaxTextExtent],
     magick[12];
 
+  unsigned int
+    global_colors;
+
   unsigned long
     delay,
     dispose,
-    global_colors,
     image_count,
     iterations;
 
@@ -874,11 +904,18 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
   background=ReadBlobByte(image);
   c=ReadBlobByte(image);  /* reserved */
   global_colors=1 << ((flag & 0x07)+1);
-  global_colormap=MagickAllocateArray(unsigned char *,3,Max(global_colors,256));
+  global_colormap=MagickAllocateArray(unsigned char *,3U,Max(global_colors,256U));
   if (global_colormap == (unsigned char *) NULL)
     ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+  (void) memset(global_colormap,0,3*Max(global_colors,256U));
   if (BitSet(flag,0x80))
-    (void) ReadBlob(image,3*global_colors,(char *) global_colormap);
+    {
+      if (ReadBlob(image,3*global_colors,(char *) global_colormap) != 3U*global_colors)
+        {
+          MagickFreeMemory(global_colormap);
+          ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+        }
+    }
   delay=0;
   dispose=0;
   iterations=1;
@@ -898,10 +935,10 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
         */
         count=ReadBlob(image,1,(char *) &c);
         if (count != 1) {
-         MagickFreeMemory(global_colormap);
-          ThrowReaderException(CorruptImageError,UnableToReadExtensionBlock,    
+          MagickFreeMemory(global_colormap);
+          ThrowReaderException(CorruptImageError,UnableToReadExtensionBlock,
             image);
-       }
+        }
         switch (c)
         {
           case 0xf9:
@@ -909,36 +946,58 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             /*
               Read Graphics Control extension.
             */
-            while (ReadBlobBlock(image,header) != 0);
+            size_t
+              ncount;
+
+            count=0;
+            while ((ncount = ReadBlobBlock(image,header)) != 0)
+              count = ncount;
+            if (count < 4)
+              break;
             dispose=header[0] >> 2;
-            delay=(header[2] << 8) | header[1];
+            delay=((unsigned int) header[2] << 8) | header[1];
             if ((header[0] & 0x01) == 1)
               opacity=(header[3] & 0xff);
             break;
           }
           case 0xfe:
           {
-            char
-              *comments;
-
             /*
               Read Comment extension.
             */
-            comments=AllocateString((char *) NULL);
+            char
+              *comments = (char *) NULL;
+
+            size_t
+              allocation_length=0,
+              offset=0;
+
             for ( ; ; )
-            {
-              count=ReadBlobBlock(image,header);
-              if (count == 0)
-                break;
-              header[count]='\0';
-              (void) ConcatenateString(&comments,(const char *) header);
-            }
+              {
+                count=ReadBlobBlock(image,header);
+                if (count == 0)
+                  break;
+                header[count]='\0';
+                if (count+offset+1 >= allocation_length)
+                  {
+                    allocation_length=allocation_length+count+1;
+                    MagickRoundUpStringLength(allocation_length);
+                    MagickReallocMemory(char *,comments,allocation_length);
+                    if (comments == (char *) NULL)
+                      ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+                    (void) strlcpy(&comments[offset],(char *)header,allocation_length-offset);
+                  }
+              }
+            (void) SetImageAttribute(image,"comment",NULL);
             (void) SetImageAttribute(image,"comment",comments);
             MagickFreeMemory(comments);
             break;
           }
           case 0xff:
           {
+            size_t
+              ncount;
+
             int
               loop;
 
@@ -946,17 +1005,21 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
               Read Netscape Loop extension.
             */
             loop=False;
-            if (ReadBlobBlock(image,header) != 0)
+            count=ReadBlobBlock(image,header);
+            if (count >= 11)
               loop=!LocaleNCompare((char *) header,"NETSCAPE2.0",11);
-            while (ReadBlobBlock(image,header) != 0)
-            if (loop)
+            while ((ncount=ReadBlobBlock(image,header)) != 0)
               {
-                iterations=(header[2] << 8) | header[1];
-                if (image->logging)
-                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                        "Loop extension with iterations %lu",
-                                        iterations);
+                count=ncount;
+                if (loop && (count >= 3))
+                  {
+                    iterations=((unsigned int) header[2] << 8) | header[1];
+                    if (image->logging)
+                      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                            "Loop extension with iterations %lu",
+                                            iterations);
 
+                  }
               }
             break;
           }
@@ -1014,14 +1077,14 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
     dispose=0;
     iterations=1;
     if ((image->columns == 0) || (image->rows == 0)) {
-      MagickFreeMemory(global_colormap);    
+      MagickFreeMemory(global_colormap);
       ThrowReaderException(CorruptImageError,NegativeOrZeroImageSize,image);
     }
     /*
       Inititialize colormap.
     */
     if (!AllocateImageColormap(image,image->colors)) {
-      MagickFreeMemory(global_colormap);    
+      MagickFreeMemory(global_colormap);
       ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
     }
     if (!BitSet(flag,0x80))
@@ -1037,7 +1100,7 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
           image->colormap[i].green=ScaleCharToQuantum(*p++);
           image->colormap[i].blue=ScaleCharToQuantum(*p++);
           if ((long) i == opacity)
-           image->colormap[i].opacity=(Quantum) TransparentOpacity;
+            image->colormap[i].opacity=(Quantum) TransparentOpacity;
         }
         image->background_color=
           image->colormap[Min(background,image->colors-1)];
@@ -1058,11 +1121,11 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                                  image);
           }
         if (ReadBlob(image,3*image->colors,(char *) colormap) != 3*image->colors)
-         {
-           MagickFreeMemory(global_colormap);
-           MagickFreeMemory(colormap);
-           ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,image);
-         }
+          {
+            MagickFreeMemory(global_colormap);
+            MagickFreeMemory(colormap);
+            ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,image);
+          }
         p=colormap;
         for (i=0; i < image->colors; i++)
         {
@@ -1079,7 +1142,10 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
         break;
 
     if (CheckImagePixelLimits(image, exception) != MagickPass)
-      ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+      {
+        MagickFreeMemory(global_colormap);
+        ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+      }
 
     /*
       Decode image.
@@ -1253,6 +1319,9 @@ static MagickPassFail WriteGIFImage(const ImageInfo *image_info,Image *image)
   unsigned long
     scene;
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -1260,6 +1329,7 @@ static MagickPassFail WriteGIFImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == MagickFail)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -1281,13 +1351,17 @@ static MagickPassFail WriteGIFImage(const ImageInfo *image_info,Image *image)
     next_image=next_image->next;
   }
   /*
-    Allocate colormap.
+    Allocate colormaps.
   */
   global_colormap=MagickAllocateMemory(unsigned char *,768);
-  colormap=MagickAllocateMemory(unsigned char *,768);
-  if ((global_colormap == (unsigned char *) NULL) ||
-      (colormap == (unsigned char *) NULL))
+  if (global_colormap == (unsigned char *) NULL)
     ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+  colormap=MagickAllocateMemory(unsigned char *,768);
+  if (colormap == (unsigned char *) NULL)
+    {
+      MagickFreeMemory(global_colormap);
+      ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+    }
   for (i=0; i < 768; i++)
     colormap[i]=0;
   /*
@@ -1311,7 +1385,7 @@ static MagickPassFail WriteGIFImage(const ImageInfo *image_info,Image *image)
     Write images to file.
   */
   interlace=(image_info->interlace == UndefinedInterlace ? NoInterlace :
-            image_info->interlace);
+             image_info->interlace);
   if (image_info->adjoin && (image->next != (Image *) NULL))
     interlace=NoInterlace;
   opacity=(-1);
@@ -1436,7 +1510,7 @@ static MagickPassFail WriteGIFImage(const ImageInfo *image_info,Image *image)
         (void) WriteBlobByte(image,0x21);
         (void) WriteBlobByte(image,0xf9);
         (void) WriteBlobByte(image,0x04);
-        c=(unsigned char) ((int) image->dispose << 2);
+        c=(unsigned char) ((unsigned int) image->dispose << 2);
         if (opacity >= 0)
           c|=0x01;
         (void) WriteBlobByte(image,c);
@@ -1518,7 +1592,7 @@ static MagickPassFail WriteGIFImage(const ImageInfo *image_info,Image *image)
         c|=0x80;
         c|=(bits_per_pixel-1);   /* size of local colormap */
         (void) WriteBlobByte(image,c);
-        (void) WriteBlob(image,3*(1 << bits_per_pixel),(char *) colormap);
+        (void) WriteBlob(image,3U*(1U << bits_per_pixel),(char *) colormap);
       }
     /*
       Write the image data.
@@ -1536,7 +1610,7 @@ static MagickPassFail WriteGIFImage(const ImageInfo *image_info,Image *image)
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene++,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename);
     if (status == MagickFail)
index 98ee2e4..3a4e3e2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -147,19 +147,22 @@ static Image *ReadGRAYImage(const ImageInfo *image_info,
   Image
     *image;
 
+  unsigned long
+    j;
+
   long
-    j,
     y;
 
   register long
-    i,
-    x;
+    i;
 
   register PixelPacket
     *q;
 
   size_t
-    count;
+    count,
+    tile_packets,
+    x;
 
   unsigned char
     *scanline;
@@ -192,6 +195,27 @@ static Image *ReadGRAYImage(const ImageInfo *image_info,
   image=AllocateImage(image_info);
   if ((image->columns == 0) || (image->rows == 0))
     ThrowReaderException(OptionError,MustSpecifyImageSize,image);
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Tile %lux%lu%+ld%+ld, Offset %lu",
+                          image->tile_info.width,image->tile_info.height,
+                          image->tile_info.x,image->tile_info.y,
+                          image->offset);
+  /*
+    There is the option to either require that the tile be within the
+    image bounds or to return only the portion of the tile which is
+    within the image bounds (returned image is smaller than requested
+    tile size).  For the moment we choose the former.
+  */
+  if ((image->tile_info.width > image->columns) ||
+      (image->tile_info.x < 0) ||
+      (image->tile_info.width+image->tile_info.x > image->columns) ||
+      (image->tile_info.height > image->rows) ||
+      (image->tile_info.y < 0) ||
+      (image->tile_info.height+image->tile_info.y > image->rows)
+      )
+    ThrowReaderException(OptionError,TileNotBoundedByImageDimensions,image);
+
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == False)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
@@ -227,6 +251,8 @@ static Image *ReadGRAYImage(const ImageInfo *image_info,
   scanline=MagickAllocateArray(unsigned char *,packet_size,image->tile_info.width);
   if (scanline == (unsigned char *) NULL)
     ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+  tile_packets=(size_t) packet_size*image->tile_info.width;
+  x=(size_t) (packet_size*image->tile_info.x);
   /*
     Initialize import options.
   */
@@ -235,19 +261,12 @@ static Image *ReadGRAYImage(const ImageInfo *image_info,
     import_options.endian=image_info->endian;
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                         "Depth: %u bits, "
-                          "Type: %s, "
-                          "Samples/Pixel: %u, "
-                          "Endian %s, "
-                          "Tile: %lux%lu%+ld%+ld",
-                         quantum_size,
+                          "Depth: %u bits, Type: %s, "
+                          "Samples/Pixel: %u, Endian %s",
+                          quantum_size,
                           QuantumTypeToString(quantum_type),
                           samples_per_pixel,
-                         EndianTypeToString(import_options.endian),
-                          image->tile_info.width,
-                          image->tile_info.height,
-                          image->tile_info.x,
-                          image->tile_info.y);
+                          EndianTypeToString(import_options.endian));
   /*
     Support starting at intermediate image frame.
   */
@@ -259,9 +278,9 @@ static Image *ReadGRAYImage(const ImageInfo *image_info,
       */
       image->scene++;
       for (y=0; y < (long) image->rows; y++)
-        (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+        if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+          break;
     }
-  x=(long) (packet_size*image->tile_info.x);
   do
   {
     /*
@@ -271,7 +290,8 @@ static Image *ReadGRAYImage(const ImageInfo *image_info,
       if (image->scene >= (image_info->subimage+image_info->subrange-1))
         break;
     for (y=0; y < image->tile_info.y; y++)
-      (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+      if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+        break;
     /*
       Support GRAYA with matte channel
     */
@@ -280,27 +300,29 @@ static Image *ReadGRAYImage(const ImageInfo *image_info,
     for (y=0; y < (long) image->rows; y++)
     {
       if ((y > 0) || (image->previous == (Image *) NULL))
-        (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+        if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+          break;
       q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
       if (q == (PixelPacket *) NULL)
         break;
       if (!is_grayscale)
         (void) memset(q,0,sizeof(PixelPacket)*image->columns);
       (void) ImportImagePixelArea(image,quantum_type,quantum_size,scanline+x,
-                                 &import_options,0);
+                                  &import_options,0);
       if (!SyncImagePixelsEx(image,exception))
         break;
       if (image->previous == (Image *) NULL)
         if (QuantumTick(y,image->rows))
           if (!MagickMonitorFormatted(y,image->rows,exception,
                                       LoadImageText,image->filename,
-                                     image->columns,image->rows))
+                                      image->columns,image->rows))
             break;
     }
     image->is_grayscale=is_grayscale;
     count=image->tile_info.height-image->rows-image->tile_info.y;
-    for (j=0; j < (long) count; j++)
-      (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+    for (j=0; j < count; j++)
+      if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+        break;
     if (EOFBlob(image))
       {
         ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
@@ -313,8 +335,8 @@ static Image *ReadGRAYImage(const ImageInfo *image_info,
     if (image_info->subrange != 0)
       if (image->scene >= (image_info->subimage+image_info->subrange-1))
         break;
-    count=ReadBlob(image,packet_size*image->tile_info.width,scanline);
-    if (count != 0)
+    count=ReadBlob(image,tile_packets,scanline);
+    if (count == tile_packets)
       {
         /*
           Allocate next image structure.
@@ -322,8 +344,8 @@ static Image *ReadGRAYImage(const ImageInfo *image_info,
         AllocateNextImage(image_info,image);
         if (image->next == (Image *) NULL)
           {
-            DestroyImageList(image);
-            return((Image *) NULL);
+            MagickFreeMemory(scanline);
+            ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
           }
         image=SyncNextImageInList(image);
         if (!MagickMonitorFormatted(TellBlob(image),GetBlobSize(image),exception,
@@ -526,14 +548,14 @@ ModuleExport void UnregisterGRAYImage(void)
 
 static unsigned int WriteGRAYImage(const ImageInfo *image_info,Image *image)
 {
-  int
+  long
     y;
 
   register const PixelPacket
     *p;
 
   unsigned char
-    *scanline=0;
+    *scanline= (unsigned char *) NULL;
 
   unsigned int
     depth,
@@ -552,6 +574,9 @@ static unsigned int WriteGRAYImage(const ImageInfo *image_info,Image *image)
   QuantumType
     quantum_type;
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -559,12 +584,13 @@ static unsigned int WriteGRAYImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
 
   quantum_type=MagickToQuantumType(image_info->magick,MagickFalse);
-  
+
   /*
     Support depth in multiples of 8 bits.
   */
@@ -574,6 +600,17 @@ static unsigned int WriteGRAYImage(const ImageInfo *image_info,Image *image)
     depth=16;
   else
     depth=8;
+
+  if (depth <= 8)
+    quantum_size=8;
+  else if (depth <= 16)
+    quantum_size=16;
+  else
+    quantum_size=32;
+
+  samples_per_pixel=MagickGetQuantumSamplesPerPixel(quantum_type);
+  packet_size=(quantum_size*samples_per_pixel)/8;
+
   /*
     Convert image to gray scale PseudoColor class.
   */
@@ -581,17 +618,6 @@ static unsigned int WriteGRAYImage(const ImageInfo *image_info,Image *image)
   do
   {
     /*
-      Allocate memory for scanline.
-    */
-    if (depth <= 8)
-      quantum_size=8;
-    else if (depth <= 16)
-      quantum_size=16;
-    else
-      quantum_size=32;
-    samples_per_pixel=MagickGetQuantumSamplesPerPixel(quantum_type);
-    packet_size=(quantum_size*samples_per_pixel)/8;
-    /*
       Allocate scanline
     */
     scanline=MagickAllocateArray(unsigned char *,packet_size,image->columns);
@@ -626,16 +652,20 @@ static unsigned int WriteGRAYImage(const ImageInfo *image_info,Image *image)
       export_options.endian=image->endian;
     else if (image_info->endian != UndefinedEndian)
       export_options.endian=image_info->endian;
-    if (image->logging)
-      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                            "Depth: %u bits, "
-                            "Type: %s, "
-                            "Samples/Pixel: %u, "
-                            "Endian %s",
-                            quantum_size,
-                            QuantumTypeToString(quantum_type),
-                            samples_per_pixel,
-                            EndianTypeToString(export_options.endian));
+
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "%lu: "
+                          "Geometry %lux%lu, "
+                          "Depth: %u bits, "
+                          "Type: %s, "
+                          "Samples/Pixel: %u, "
+                          "Endian %s",
+                          image->scene,
+                          image->columns,image->rows,
+                          quantum_size,
+                          QuantumTypeToString(quantum_type),
+                          samples_per_pixel,
+                          EndianTypeToString(export_options.endian));
     /*
       Convert MIFF to GRAY raster scanline.
     */
@@ -645,20 +675,20 @@ static unsigned int WriteGRAYImage(const ImageInfo *image_info,Image *image)
       if (p == (const PixelPacket *) NULL)
         break;
       (void) ExportImagePixelArea(image,quantum_type,quantum_size,scanline,
-                                 &export_options,&export_info);
+                                  &export_options,&export_info);
       (void) WriteBlob(image,export_info.bytes_exported,scanline);
       if (image->previous == (Image *) NULL)
         if (QuantumTick(y,image->rows))
           if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                       SaveImageText,image->filename,
-                                     image->columns,image->rows))
+                                      image->columns,image->rows))
             break;
     }
     MagickFreeMemory(scanline);
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    if (!MagickMonitorFormatted(scene++,GetImageListLength(image),&image->exception,
+    if (!MagickMonitorFormatted(scene++,image_list_length,&image->exception,
                                 SaveImagesText,image->filename))
       break;
   } while (image_info->adjoin);
index 8cbe2c5..6741b14 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -195,7 +195,7 @@ static unsigned int WriteHISTOGRAMImage(const ImageInfo *image_info,
   unsigned int
     status;
 
-  unsigned long
+  size_t
     length;
 
   /*
@@ -222,12 +222,15 @@ static unsigned int WriteHISTOGRAMImage(const ImageInfo *image_info,
     Allocate histogram count arrays.
   */
   length=Max(ScaleQuantumToChar(MaxRGB)+1,histogram_image->columns);
-  red=MagickAllocateMemory(long *,length*sizeof(long));
-  green=MagickAllocateMemory(long *,length*sizeof(long));
-  blue=MagickAllocateMemory(long *,length*sizeof(long));
+  red=MagickAllocateArray(long *,length,sizeof(long));
+  green=MagickAllocateArray(long *,length,sizeof(long));
+  blue=MagickAllocateArray(long *,length,sizeof(long));
   if ((red == (long *) NULL) || (green == (long *) NULL) ||
       (blue == (long *) NULL))
     {
+      MagickFreeMemory(red);
+      MagickFreeMemory(green);
+      MagickFreeMemory(blue);
       DestroyImage(histogram_image);
       ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image)
     }
@@ -301,7 +304,7 @@ static unsigned int WriteHISTOGRAMImage(const ImageInfo *image_info,
     if (QuantumTick(x,histogram_image->columns))
       if (!MagickMonitorFormatted(x,histogram_image->columns,&image->exception,
                                   SaveImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   /*
index 627d1dd..cf12cc3 100644 (file)
@@ -157,7 +157,7 @@ DONE_READING:
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  Function WriteHRZImage writes an HRZ image to a file.  
+%  Function WriteHRZImage writes an HRZ image to a file.
 %
 %  The format of the WriteHRZImage method is:
 %
@@ -178,7 +178,7 @@ DONE_READING:
 {
     if (logging)
     (void)LogMagickEvent(CoderEvent,GetMagickModule(),"return HRZ");
-  
+
   return(status);
 } */
 
index f52231f..dbeb241 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -124,7 +124,7 @@ ModuleExport void RegisterHTMLImage(void)
   entry->description="Hypertext Markup Language and a client-side image map";
   entry->stealth=MagickTrue;
   entry->module="HTML";
-  entry->coder_class=PrimaryCoderClass;
+  entry->coder_class=StableCoderClass;
   (void) RegisterMagickInfo(entry);
 
   entry=SetMagickInfo("HTML");
@@ -133,7 +133,7 @@ ModuleExport void RegisterHTMLImage(void)
   entry->adjoin=False;
   entry->description="Hypertext Markup Language and a client-side image map";
   entry->module="HTML";
-  entry->coder_class=PrimaryCoderClass;
+  entry->coder_class=StableCoderClass;
   (void) RegisterMagickInfo(entry);
 
   entry=SetMagickInfo("SHTML");
@@ -142,7 +142,7 @@ ModuleExport void RegisterHTMLImage(void)
   entry->adjoin=False;
   entry->description="Hypertext Markup Language and a client-side image map";
   entry->module="HTML";
-  entry->coder_class=PrimaryCoderClass;
+  entry->coder_class=StableCoderClass;
   (void) RegisterMagickInfo(entry);
 }
 \f
index 4e432ed..6892498 100644 (file)
@@ -61,11 +61,11 @@ typedef struct _IconDirEntry
     height,
     colors,
     reserved;
-  
+
   magick_uint16_t
     planes,
     bits_per_pixel;
-  
+
   magick_uint32_t
     size,
     offset;
@@ -80,7 +80,7 @@ typedef struct _IconFile
     reserved,
     resource_type, /* 1 = ICON, 2 = CURSOR */
     count;
-  
+
   IconDirEntry
     directory[MaxIcons];
 } IconFile;
index 8c38d10..5a7d414 100644 (file)
@@ -55,7 +55,7 @@
 */
 
 static Image *ReadIdentityImage(const ImageInfo *image_info,
-                               ExceptionInfo *exception)
+                                ExceptionInfo *exception)
 {
 #define IdentityImageText  "[%s] Generating Hald CLUT identity image..."
 
@@ -89,7 +89,7 @@ static Image *ReadIdentityImage(const ImageInfo *image_info,
     order=MagickAtoL(image_info->filename);
   if (order < 2)
     order=8;
-  
+
   image=AllocateImage(image_info);
   cube_size=order*order;
   image->columns=image->rows=order*order*order;
@@ -122,29 +122,29 @@ static Image *ReadIdentityImage(const ImageInfo *image_info,
 
       if (q != (PixelPacket *) NULL)
         {
-         double
-           value;
-
-         unsigned int
-           red,
-           green,
-           blue;
-
-         blue=y/order;
-         for(green = 0; green < cube_size; green++)
-           {
-             for(red = 0; red < cube_size; red++)
-               {
-                 value=MaxRGBDouble * (double)red / (double)(cube_size - 1);
-                 q->red   = RoundDoubleToQuantum(value);
-                 value     = MaxRGBDouble * (double)green / (double)(cube_size - 1);
-                 q->green = RoundDoubleToQuantum(value);
-                 value    = MaxRGBDouble * (double)blue / (double)(cube_size - 1);
-                 q->blue  = RoundDoubleToQuantum(value);
-                 q->opacity = OpaqueOpacity;
-                 q++;
-               }
-           }
+          double
+            value;
+
+          unsigned int
+            red,
+            green,
+            blue;
+
+          blue=y/order;
+          for(green = 0; green < cube_size; green++)
+            {
+              for(red = 0; red < cube_size; red++)
+                {
+                  value=MaxRGBDouble * (double)red / (double)(cube_size - 1);
+                  q->red   = RoundDoubleToQuantum(value);
+                  value     = MaxRGBDouble * (double)green / (double)(cube_size - 1);
+                  q->green = RoundDoubleToQuantum(value);
+                  value    = MaxRGBDouble * (double)blue / (double)(cube_size - 1);
+                  q->blue  = RoundDoubleToQuantum(value);
+                  q->opacity = OpaqueOpacity;
+                  q++;
+                }
+            }
 
           if (!SyncImagePixelsEx(image,&image->exception))
             thread_status=MagickFail;
index b5ebff9..82b5ac6 100644 (file)
@@ -138,7 +138,7 @@ WriteINFOImage(const ImageInfo *image_info,Image *image)
   format=AccessDefinition(image_info,"info","format");
   if (format != (char *) NULL)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                         "info:format=\"%s\"",format);
+                          "info:format=\"%s\"",format);
 
   /*
     Open blob.
@@ -154,62 +154,62 @@ WriteINFOImage(const ImageInfo *image_info,Image *image)
   if ((file=GetBlobFileHandle(image)) == (FILE *) NULL)
     {
       if(!AcquireTemporaryFileName(temporary_filename))
-       ThrowWriterException(FileOpenError,UnableToCreateTemporaryFile,image);
+        ThrowWriterException(FileOpenError,UnableToCreateTemporaryFile,image);
       if ((file=fopen(temporary_filename,"w")) == (FILE *) NULL)
-       {
-         (void) LiberateTemporaryFile(temporary_filename);
-         ThrowWriterException(FileOpenError,UnableToCreateTemporaryFile,image);
-       }
-      
+        {
+          (void) LiberateTemporaryFile(temporary_filename);
+          ThrowWriterException(FileOpenError,UnableToCreateTemporaryFile,image);
+        }
+
     }
   list_entry=image;
-  
+
   while (list_entry != (Image *) NULL)
     {
       /*
-       Avoid convert style output syntax by restoring original filename.
+        Avoid convert style output syntax by restoring original filename.
       */
       (void) strlcpy(list_entry->filename,list_entry->magick_filename,
-                    sizeof(list_entry->filename));
+                     sizeof(list_entry->filename));
 
       /*
-       Describe image.
+        Describe image.
       */
       if (format != (char *) NULL)
-       {
-         char
-           *text;
-
-         text=TranslateText(image_info,list_entry,format);
-         if (text != (char *) NULL)
-           {
-             (void) fputs(text,file);
-             (void) fputs("\n",file);
-             MagickFreeMemory(text);
-           }
-       }
+        {
+          char
+            *text;
+
+          text=TranslateText(image_info,list_entry,format);
+          if (text != (char *) NULL)
+            {
+              (void) fputs(text,file);
+              (void) fputs("\n",file);
+              MagickFreeMemory(text);
+            }
+        }
       else
-       {
-         if ((status=DescribeImage(list_entry,file,image_info->verbose))
-             == MagickFail)
-           break;
-       }
-      
+        {
+          if ((status=DescribeImage(list_entry,file,image_info->verbose))
+              == MagickFail)
+            break;
+        }
+
       list_entry=GetNextImageInList(list_entry);
     }
 
   if ('\0' != temporary_filename[0])
     {
       /*
-       Close temporary file.
+        Close temporary file.
       */
       (void) fclose(file);
 
       /*
-       Send content of temporary file to blob stream.
+        Send content of temporary file to blob stream.
       */
       if (WriteBlobFile(image,temporary_filename) == MagickFail)
-       status=MagickFail;
+        status=MagickFail;
       (void) LiberateTemporaryFile(temporary_filename);
     }
 
index 2f8da39..e28940c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003, 2007 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -223,7 +223,7 @@ static Image *ReadJBIGImage(const ImageInfo *image_info,
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                   image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   }
@@ -413,6 +413,9 @@ static unsigned int WriteJBIGImage(const ImageInfo *image_info,Image *image)
   unsigned long
     scene;
 
+  size_t
+    image_list_length;
+
   /*
     Open image file.
   */
@@ -420,6 +423,7 @@ static unsigned int WriteJBIGImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -465,7 +469,7 @@ static unsigned int WriteJBIGImage(const ImageInfo *image_info,Image *image)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                           SaveImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
     }
@@ -510,7 +514,7 @@ static unsigned int WriteJBIGImage(const ImageInfo *image_info,Image *image)
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    if (!MagickMonitorFormatted(scene++,GetImageListLength(image),
+    if (!MagickMonitorFormatted(scene++,image_list_length,
                                 &image->exception,SaveImagesText,
                                 image->filename))
       break;
index 2153588..cd453a0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2012-2015 GraphicsMagick Group
+% Copyright (C) 2012-2018 GraphicsMagick Group
 %
 % This program is covered by multiple licenses, which are described in
 % Copyright.txt. You should have received a copy of Copyright.txt with this
@@ -20,7 +20,7 @@
 %                                                                             %
 %                              Software Design                                %
 %                              Jaroslav Fojtik                                %
-%                                  2012 -                                     %
+%                                2012 - 2018                                  %
 %                                                                             %
 %                                                                             %
 %                                                                             %
@@ -100,6 +100,7 @@ ExtractTileJPG(Image * image, const ImageInfo * image_info,
 
   char img_label_str[MaxTextExtent];
 
+
   alloc_size = TileInfo->PicSize + 2;
 
   if (image->logging)
@@ -122,7 +123,15 @@ ExtractTileJPG(Image * image, const ImageInfo * image_info,
               Image
                 *image2;
 
-              if ((image2 = BlobToImage(image_info,blob,alloc_size,exception))
+              ImageInfo
+                *clone_info;
+
+              clone_info=CloneImageInfo(image_info);
+
+              /* BlobToFile("/tmp/jnx-tile.jpg", blob,alloc_size,exception); */
+
+              (void) strlcpy(clone_info->filename,"JPEG:",sizeof(clone_info->filename));
+              if ((image2 = BlobToImage(clone_info,blob,alloc_size,exception))
                   != NULL)
                 {
                   /*
@@ -135,15 +144,26 @@ ExtractTileJPG(Image * image, const ImageInfo * image_info,
                                  sizeof(image2->magick_filename));
                   (void) strlcpy(image2->magick, image->magick,
                                  sizeof(image2->magick));
-                  image2->depth = image->depth;
                   DestroyBlob(image2);
                   image2->blob = ReferenceBlob(image->blob);
 
                   if ((image->rows == 0) || (image->columns == 0))
                     DeleteImageFromList(&image);
 
+                  FormatString(img_label_str, "%.20g;%.20g",
+                               (double) TileInfo->TileBounds.NorthEast.lat*180.0/0x7FFFFFFF,
+                               (double) TileInfo->TileBounds.NorthEast.lon*180.0/0x7FFFFFFF);
+                  SetImageAttribute(image2, "jnx:northeast", img_label_str);
+
+                  FormatString(img_label_str, "%.20g;%.20g",
+                               (double) TileInfo->TileBounds.SouthWest.lat*180.0/0x7FFFFFFF,
+                               (double) TileInfo->TileBounds.SouthWest.lon*180.0/0x7FFFFFFF);
+                  SetImageAttribute(image2, "jnx:southwest", img_label_str);
+
                   AppendImageToList(&image, image2);
                 }
+              DestroyImageInfo(clone_info);
+              clone_info = (ImageInfo *) NULL;
             }
           else
             {
@@ -166,16 +186,6 @@ ExtractTileJPG(Image * image, const ImageInfo * image_info,
       ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,
                      image->filename);
     }
-  
-  FormatString(img_label_str,"%.20g,%.20g", 
-               (double) TileInfo->TileBounds.NorthEast.lat*180.0/0x7FFFFFFF, 
-               (double) TileInfo->TileBounds.NorthEast.lon*180.0/0x7FFFFFFF);
-  SetImageAttribute(image,"jnx:northeast",img_label_str);
-
-  FormatString(img_label_str,"%.20g,%.20g",
-               (double) TileInfo->TileBounds.SouthWest.lat*180.0/0x7FFFFFFF, 
-               (double) TileInfo->TileBounds.SouthWest.lon*180.0/0x7FFFFFFF);
-  SetImageAttribute(image,"jnx:southwest",img_label_str);
 
   return(image);
 }
@@ -242,6 +252,9 @@ ReadJNXImage(const ImageInfo * image_info, ExceptionInfo * exception)
     total_tiles,
     current_tile;
 
+  magick_off_t
+    file_size;
+
   /* Open image file. */
   assert(image_info != (const ImageInfo *) NULL);
   assert(image_info->signature == MagickSignature);
@@ -254,9 +267,8 @@ ReadJNXImage(const ImageInfo * image_info, ExceptionInfo * exception)
   if (status == False)
     ThrowReaderException(FileOpenError, UnableToOpenFile, image);
 
-  memset(JNXLevelInfo, 0, sizeof(JNXLevelInfo));
-
   /* Read JNX image header. */
+  (void) memset(&JNXHeader, 0, sizeof(JNXHeader));
   JNXHeader.Version = ReadBlobLSBLong(image);
   if (JNXHeader.Version > 4)
     ThrowReaderException(CorruptImageError, ImproperImageHeader, image);
@@ -266,8 +278,6 @@ ReadJNXImage(const ImageInfo * image_info, ExceptionInfo * exception)
   JNXHeader.MapBounds.SouthWest.lat = ReadBlobLSBLong(image);
   JNXHeader.MapBounds.SouthWest.lon = ReadBlobLSBLong(image);
   JNXHeader.Levels = ReadBlobLSBLong(image);
-  if (JNXHeader.Levels > 20)
-    ThrowReaderException(CorruptImageError, ImproperImageHeader, image);
   JNXHeader.Expiration = ReadBlobLSBLong(image);
   JNXHeader.ProductID = ReadBlobLSBLong(image);
   JNXHeader.CRC = ReadBlobLSBLong(image);
@@ -279,7 +289,41 @@ ReadJNXImage(const ImageInfo * image_info, ExceptionInfo * exception)
   if (EOFBlob(image))
     ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
 
+  file_size = GetBlobSize(image);
+
+  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                        "JNX Header:\n"
+                        "    Version:    %u\n"
+                        "    DeviceSN:   %u\n"
+                        "    MapBounds:\n"
+                        "      NorthEast: lat = %u, lon = %u\n"
+                        "      SouthWest: lat = %u, lon = %u\n"
+                        "    Levels:     %u\n"
+                        "    Expiration: %u\n"
+                        "    ProductID:  %u\n"
+                        "    CRC:        %u\n"
+                        "    SigVersion: %u\n"
+                        "    SigOffset:  %u\n"
+                        "    ZOrder:     %u",
+                        JNXHeader.Version,
+                        JNXHeader.DeviceSN,
+                        JNXHeader.MapBounds.NorthEast.lat,
+                        JNXHeader.MapBounds.NorthEast.lon,
+                        JNXHeader.MapBounds.SouthWest.lat,
+                        JNXHeader.MapBounds.SouthWest.lon,
+                        JNXHeader.Levels,
+                        JNXHeader.Expiration,
+                        JNXHeader.ProductID,
+                        JNXHeader.CRC,
+                        JNXHeader.SigVersion,
+                        JNXHeader.SigOffset,
+                        JNXHeader.ZOrder);
+
+  if (JNXHeader.Levels > 20)
+    ThrowReaderException(CorruptImageError, ImproperImageHeader, image);
+
   /* Read JNX image level info. */
+  memset(JNXLevelInfo, 0, sizeof(JNXLevelInfo));
   total_tiles = 0;
   current_tile = 0;
   for (i = 0; i < JNXHeader.Levels; i++)
@@ -302,10 +346,22 @@ ReadJNXImage(const ImageInfo * image_info, ExceptionInfo * exception)
         {
           JNXLevelInfo[i].Copyright = NULL;
         }
-    }
 
-  if (EOFBlob(image))
-    ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+      if (EOFBlob(image))
+        ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Level[%u] Info:"
+                              "  TileCount: %4u"
+                              "  TilesOffset: %6u"
+                              "  Scale: %04u",
+                              i,
+                              JNXLevelInfo[i].TileCount,
+                              JNXLevelInfo[i].TilesOffset,
+                              JNXLevelInfo[i].Scale
+                              );
+    }
 
   /* Get the current limit */
   SaveLimit = GetMagickResourceLimit(MapResource);
@@ -316,11 +372,32 @@ ReadJNXImage(const ImageInfo * image_info, ExceptionInfo * exception)
   /* Read JNX image data. */
   for (i = 0; i < JNXHeader.Levels; i++)
     {
+      /*
+        Validate TileCount against remaining file data
+      */
+      const magick_off_t current_offset = TellBlob(image);
+      const size_t pos_list_entry_size =
+        sizeof(magick_uint32_t) + sizeof(magick_uint32_t) + sizeof(magick_uint32_t) +
+        sizeof(magick_uint32_t) + sizeof(magick_uint16_t) + sizeof(magick_uint16_t) +
+        sizeof(magick_uint32_t) + sizeof(magick_uint32_t);
+      const magick_off_t remaining = file_size-current_offset;
+      const size_t needed = MagickArraySize(pos_list_entry_size,JNXLevelInfo[i].TileCount);
+
+      if ((needed == 0U) || (remaining <= 0) || (remaining < (magick_off_t) needed))
+        {
+          (void) SetMagickResourceLimit(MapResource, SaveLimit);
+          ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+        }
+
       PositionList = MagickAllocateArray(TJNXTileInfo *,
                                          JNXLevelInfo[i].TileCount,
                                          sizeof(TJNXTileInfo));
       if (PositionList == NULL)
-        continue;
+        {
+          (void) SetMagickResourceLimit(MapResource, SaveLimit);
+          ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
+                               image);
+        }
 
       (void) SeekBlob(image, JNXLevelInfo[i].TilesOffset, SEEK_SET);
       for (j = 0; j < JNXLevelInfo[i].TileCount; j++)
@@ -333,12 +410,15 @@ ReadJNXImage(const ImageInfo * image_info, ExceptionInfo * exception)
           PositionList[j].PicHeight = ReadBlobLSBShort(image);
           PositionList[j].PicSize = ReadBlobLSBLong(image);
           PositionList[j].PicOffset = ReadBlobLSBLong(image);
-        }
 
-      if (EOFBlob(image))
-        {
-          MagickFreeMemory(PositionList);
-          ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+          if (EOFBlob(image) ||
+              ((magick_off_t) PositionList[j].PicOffset +
+               PositionList[j].PicSize > file_size))
+            {
+              (void) SetMagickResourceLimit(MapResource, SaveLimit);
+              MagickFreeMemory(PositionList);
+              ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+            }
         }
 
       for (j = 0; j < JNXLevelInfo[i].TileCount; j++)
@@ -351,6 +431,9 @@ ReadJNXImage(const ImageInfo * image_info, ExceptionInfo * exception)
           image = ExtractTileJPG(image, image_info, PositionList+j, exception);
           (void) SetMonitorHandler(previous_handler);
 
+          if (exception->severity >= ErrorException)
+            break;
+
           current_tile++;
           if (QuantumTick(current_tile,total_tiles))
             if (!MagickMonitorFormatted(current_tile,total_tiles,exception,
@@ -398,7 +481,7 @@ ReadJNXImage(const ImageInfo * image_info, ExceptionInfo * exception)
     (void) LogMagickEvent(CoderEvent, GetMagickModule(), "return");
   if (image == NULL)
     ThrowReaderException(CorruptImageError, ImageFileDoesNotContainAnyImageData,
-                        image);
+                         image);
 
   return (image);
 }
@@ -414,7 +497,7 @@ ReadJNXImage(const ImageInfo * image_info, ExceptionInfo * exception)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  Function WriteJNXImage writes an JNX image to a file.  
+%  Function WriteJNXImage writes an JNX image to a file.
 %
 %  The format of the WriteJNXImage method is:
 %
index 50edf39..e04cc00 100644 (file)
@@ -322,7 +322,7 @@ static int BlobClose(jas_stream_obj_t *object)
 
 static jas_stream_t *JP2StreamManager(jas_stream_ops_t *stream_ops, Image *image)
 {
-  jas_stream_t 
+  jas_stream_t
     *stream;
 
   StreamManager
@@ -348,6 +348,19 @@ static jas_stream_t *JP2StreamManager(jas_stream_ops_t *stream_ops, Image *image
   return(stream);
 }
 
+#define ThrowJP2ReaderException(code_,reason_,image_) \
+{ \
+  for (component=0; component < (long) number_components; component++) \
+    MagickFreeMemory(channel_lut[component]); \
+  if (pixels) \
+    jas_matrix_destroy(pixels); \
+  if (jp2_stream) \
+    (void) jas_stream_close(jp2_stream); \
+  if (jp2_image) \
+    jas_image_destroy(jp2_image); \
+  ThrowReaderException(code_,reason_,image_); \
+}
+
 static Image *ReadJP2Image(const ImageInfo *image_info,
   ExceptionInfo *exception)
 {
@@ -358,10 +371,10 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
     y;
 
   jas_image_t
-    *jp2_image;
+    *jp2_image = (jas_image_t *) NULL;
 
   jas_matrix_t
-    *pixels;
+    *pixels = (jas_matrix_t *) NULL;
 
   jas_stream_ops_t
     StreamOperators =
@@ -373,7 +386,7 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
     };
 
   jas_stream_t
-    *jp2_stream;
+    *jp2_stream = (jas_stream_t *) NULL;
 
   register long
     x;
@@ -384,7 +397,7 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
   int
     component,
     components[4],
-    number_components;
+    number_components=0;
 
   Quantum
     *channel_lut[4];
@@ -410,6 +423,7 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
   assert(image_info->signature == MagickSignature);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
+  (void) memset(channel_lut,0,sizeof(channel_lut));
   image=AllocateImage(image_info);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == False)
@@ -423,10 +437,7 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
     ThrowReaderException(DelegateError,UnableToManageJP2Stream,image);
   jp2_image=jas_image_decode(jp2_stream,-1,0);
   if (jp2_image == (jas_image_t *) NULL)
-    {
-      (void) jas_stream_close(jp2_stream);
-      ThrowReaderException(DelegateError,UnableToDecodeImageFile,image);
-    }
+    ThrowJP2ReaderException(DelegateError,UnableToDecodeImageFile,image);
 
   /*
     Validate that we can handle the image and obtain component
@@ -437,18 +448,16 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
     case JAS_CLRSPC_FAM_RGB:
       {
         if (((components[0]=
-             jas_image_getcmptbytype(jp2_image,
-                                     JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_R))) < 0) ||
+              jas_image_getcmptbytype(jp2_image,
+                                      JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_R))) < 0) ||
             ((components[1]=
-             jas_image_getcmptbytype(jp2_image,
-                                     JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_G))) < 0) ||
+              jas_image_getcmptbytype(jp2_image,
+                                      JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_G))) < 0) ||
             ((components[2]=
-             jas_image_getcmptbytype(jp2_image,
-                                     JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_B))) < 0))
+              jas_image_getcmptbytype(jp2_image,
+                                      JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_RGB_B))) < 0))
           {
-            (void) jas_stream_close(jp2_stream);
-            jas_image_destroy(jp2_image);
-            ThrowReaderException(CorruptImageError,MissingImageChannel,image);
+            ThrowJP2ReaderException(CorruptImageError,MissingImageChannel,image);
           }
         number_components=3;
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -470,13 +479,9 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
     case JAS_CLRSPC_FAM_GRAY:
       {
         if ((components[0]=
-            jas_image_getcmptbytype(jp2_image,
-                                    JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y))) < 0)
-          {
-            (void) jas_stream_close(jp2_stream);
-            jas_image_destroy(jp2_image);
-            ThrowReaderException(CorruptImageError,MissingImageChannel,image);
-          }
+             jas_image_getcmptbytype(jp2_image,
+                                     JAS_IMAGE_CT_COLOR(JAS_CLRSPC_CHANIND_GRAY_Y))) < 0)
+          ThrowJP2ReaderException(CorruptImageError,MissingImageChannel,image);
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "Image is in GRAY colorspace family");
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -490,11 +495,7 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
         components[1]=jas_image_getcmptbytype(jp2_image,JAS_IMAGE_CT_YCBCR_CB);
         components[2]=jas_image_getcmptbytype(jp2_image,JAS_IMAGE_CT_YCBCR_CR);
         if ((components[0] < 0) || (components[1] < 0) || (components[2] < 0))
-          {
-            (void) jas_stream_close(jp2_stream);
-            jas_image_destroy(jp2_image);
-            ThrowReaderException(CorruptImageError,MissingImageChannel,image);
-          }
+          ThrowJP2ReaderException(CorruptImageError,MissingImageChannel,image);
         number_components=3;
         components[3]=jas_image_getcmptbytype(jp2_image,JAS_IMAGE_CT_OPACITY);
         if (components[3] > 0)
@@ -509,9 +510,7 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
       }
     default:
       {
-        (void) jas_stream_close(jp2_stream);
-        jas_image_destroy(jp2_image);
-        ThrowReaderException(CoderError,ColorspaceModelIsNotSupported,image);
+        ThrowJP2ReaderException(CoderError,ColorspaceModelIsNotSupported,image);
       }
     }
   image->columns=jas_image_width(jp2_image);
@@ -528,26 +527,22 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
          (jas_image_cmpthstep(jp2_image, components[component]) != 1) ||
          (jas_image_cmptvstep(jp2_image, components[component]) != 1) ||
          (jas_image_cmptsgnd(jp2_image, components[component]) != false))
-        {
-          (void) jas_stream_close(jp2_stream);
-          jas_image_destroy(jp2_image);
-          ThrowReaderException(CoderError,IrregularChannelGeometryNotSupported,image);
-        }
+        ThrowJP2ReaderException(CoderError,IrregularChannelGeometryNotSupported,image);
     }
 
   image->matte=number_components > 3;
   for (component=0; component < number_components; component++)
     {
       unsigned int
-       component_depth;
+        component_depth;
 
       component_depth=jas_image_cmptprec(jp2_image,components[component]);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "Component[%d] depth is %u",component,component_depth);
+                            "Component[%d] depth is %u",component,component_depth);
       if (0 == component)
-       image->depth=component_depth;
+        image->depth=component_depth;
       else
-       image->depth=Max(image->depth,component_depth);
+        image->depth=Max(image->depth,component_depth);
     }
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                         "Image depth is %u",image->depth);
@@ -559,21 +554,14 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
     }
 
   if (CheckImagePixelLimits(image, exception) != MagickPass)
-    {
-      (void) jas_stream_close(jp2_stream);
-      jas_image_destroy(jp2_image);
-      ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
-    }
+    ThrowJP2ReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
 
   /*
     Allocate Jasper pixels.
   */
   pixels=jas_matrix_create(1,(unsigned int) image->columns);
   if (pixels == (jas_matrix_t *) NULL)
-    {
-      jas_image_destroy(jp2_image);
-      ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-    }
+    ThrowJP2ReaderException(ResourceLimitError,MemoryAllocationFailed,image);
 
   /*
     Allocate and populate channel LUTs
@@ -581,12 +569,12 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
   for (component=0; component < (long) number_components; component++)
     {
       unsigned long
-       component_depth,
-       i,
-       max_value;
+        component_depth,
+        i,
+        max_value;
 
       double
-       scale_to_quantum;
+        scale_to_quantum;
 
       component_depth=jas_image_cmptprec(jp2_image,components[component]);
       max_value=MaxValueGivenBits(component_depth);
@@ -595,15 +583,9 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
                             "Channel %d scale is %g", component, scale_to_quantum);
       channel_lut[component]=MagickAllocateArray(Quantum *,max_value+1,sizeof(Quantum));
       if (channel_lut[component] == (Quantum *) NULL)
-       {
-         for ( --component; component >= 0; --component)
-           MagickFreeMemory(channel_lut[component]);
-         jas_matrix_destroy(pixels);
-         jas_image_destroy(jp2_image);
-         ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-       }
+        ThrowJP2ReaderException(ResourceLimitError,MemoryAllocationFailed,image);
       for(i=0; i <= max_value; i++)
-       (channel_lut[component])[i]=scale_to_quantum*i+0.5;
+        (channel_lut[component])[i]=scale_to_quantum*i+0.5;
     }
 
   /*
@@ -616,55 +598,55 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
         break;
 
       if (1 == number_components)
-       {
-         /* Grayscale */
-         (void) jas_image_readcmpt(jp2_image,(short) components[0],0,
-                                   (unsigned int) y,
-                                   (unsigned int) image->columns,1,pixels);
-         for (x=0; x < (long) image->columns; x++)
-           {
-             q->red=q->green=q->blue=(channel_lut[0])[jas_matrix_getv(pixels,x)];
-             q->opacity=OpaqueOpacity;
-             q++;
-           }
-       }
+        {
+          /* Grayscale */
+          (void) jas_image_readcmpt(jp2_image,(short) components[0],0,
+                                    (unsigned int) y,
+                                    (unsigned int) image->columns,1,pixels);
+          for (x=0; x < (long) image->columns; x++)
+            {
+              q->red=q->green=q->blue=(channel_lut[0])[jas_matrix_getv(pixels,x)];
+              q->opacity=OpaqueOpacity;
+              q++;
+            }
+        }
       else
-       {
-         /* Red */
-         (void) jas_image_readcmpt(jp2_image,(short) components[0],0,
-                                   (unsigned int) y,
-                                   (unsigned int) image->columns,1,pixels);
-         for (x=0; x < (long) image->columns; x++)
-           q[x].red=(channel_lut[0])[jas_matrix_getv(pixels,x)];
-         
-         /* Green */
-         (void) jas_image_readcmpt(jp2_image,(short) components[1],0,
-                                   (unsigned int) y,
-                                   (unsigned int) image->columns,1,pixels);
-         for (x=0; x < (long) image->columns; x++)
-           q[x].green=(channel_lut[1])[jas_matrix_getv(pixels,x)];
-         
-         /* Blue */
-         (void) jas_image_readcmpt(jp2_image,(short) components[2],0,
-                                   (unsigned int) y,
-                                   (unsigned int) image->columns,1,pixels);
-         for (x=0; x < (long) image->columns; x++)
-           q[x].blue=(channel_lut[2])[jas_matrix_getv(pixels,x)];
-
-           /* Opacity */
-         if (number_components > 3)
-           {
-             (void) jas_image_readcmpt(jp2_image,(short) components[3],0,
-                                       (unsigned int) y,
-                                       (unsigned int) image->columns,1,pixels);
-             for (x=0; x < (long) image->columns; x++)
-               q[x].opacity=MaxRGB-(channel_lut[3])[jas_matrix_getv(pixels,x)];
-           }
-         else
-           {
-             for (x=0; x < (long) image->columns; x++)
-               q[x].opacity=OpaqueOpacity;
-           }
+        {
+          /* Red */
+          (void) jas_image_readcmpt(jp2_image,(short) components[0],0,
+                                    (unsigned int) y,
+                                    (unsigned int) image->columns,1,pixels);
+          for (x=0; x < (long) image->columns; x++)
+            q[x].red=(channel_lut[0])[jas_matrix_getv(pixels,x)];
+
+          /* Green */
+          (void) jas_image_readcmpt(jp2_image,(short) components[1],0,
+                                    (unsigned int) y,
+                                    (unsigned int) image->columns,1,pixels);
+          for (x=0; x < (long) image->columns; x++)
+            q[x].green=(channel_lut[1])[jas_matrix_getv(pixels,x)];
+
+          /* Blue */
+          (void) jas_image_readcmpt(jp2_image,(short) components[2],0,
+                                    (unsigned int) y,
+                                    (unsigned int) image->columns,1,pixels);
+          for (x=0; x < (long) image->columns; x++)
+            q[x].blue=(channel_lut[2])[jas_matrix_getv(pixels,x)];
+
+            /* Opacity */
+          if (number_components > 3)
+            {
+              (void) jas_image_readcmpt(jp2_image,(short) components[3],0,
+                                        (unsigned int) y,
+                                        (unsigned int) image->columns,1,pixels);
+              for (x=0; x < (long) image->columns; x++)
+                q[x].opacity=MaxRGB-(channel_lut[3])[jas_matrix_getv(pixels,x)];
+            }
+          else
+            {
+              for (x=0; x < (long) image->columns; x++)
+                q[x].opacity=OpaqueOpacity;
+            }
         }
       if (!SyncImagePixels(image))
         break;
@@ -672,7 +654,7 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
         if (QuantumTick(y,image->rows))
           if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                       image->filename,
-                                     image->columns,image->rows))
+                                      image->columns,image->rows))
             break;
     }
   if (number_components == 1)
@@ -681,10 +663,10 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
     /*
       Obtain ICC ICM color profile
     */
-    
+
     jas_cmprof_t
       *cm_profile;
-    
+
     /* Obtain a pointer to the existing jas_cmprof_t profile handle. */
     cm_profile=jas_image_cmprof(jp2_image);
     if (cm_profile != (jas_cmprof_t *) NULL)
@@ -707,13 +689,13 @@ static Image *ReadJP2Image(const ImageInfo *image_info,
               {
                 jas_stream_memobj_t
                   *blob;
-                
+
                 blob=(jas_stream_memobj_t *) icc_stream->obj_;
                 if (image->logging)
                   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                         "ICC profile: %lu bytes",(unsigned long) blob->len_);
                 SetImageProfile(image,"ICM",blob->buf_,blob->len_);
-                
+
                 (void) jas_stream_close(icc_stream);
                 jas_iccprof_destroy(icc_profile);
               }
@@ -1031,14 +1013,14 @@ WriteJP2Image(const ImageInfo *image_info,Image *image)
     lut=MagickAllocateArray(unsigned short *,MaxMap+1,sizeof(*lut));
     if (lut == (unsigned short *) NULL)
       {
-       jas_image_destroy(jp2_image);
-       ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+        jas_image_destroy(jp2_image);
+        ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
       }
 
     max_value=MaxValueGivenBits(component_info.prec);
     scale_to_component=max_value/MaxRGBDouble;
     for(i=0; i <= MaxMap; i++)
-       lut[i]=scale_to_component*i+0.5;
+        lut[i]=scale_to_component*i+0.5;
   }
 
   if (number_components == 1)
@@ -1103,39 +1085,39 @@ WriteJP2Image(const ImageInfo *image_info,Image *image)
       break;
     if (number_components == 1)
       {
-       for (x=0; x < (long) image->columns; x++)
-         jas_matrix_setv(jp2_pixels,x,lut[ScaleQuantumToMap(PixelIntensityToQuantum(&p[x]))]);
-       (void) jas_image_writecmpt(jp2_image,0,0,(unsigned int) y,
-                                  (unsigned int) image->columns,1,jp2_pixels);
+        for (x=0; x < (long) image->columns; x++)
+          jas_matrix_setv(jp2_pixels,x,lut[ScaleQuantumToMap(PixelIntensityToQuantum(&p[x]))]);
+        (void) jas_image_writecmpt(jp2_image,0,0,(unsigned int) y,
+                                   (unsigned int) image->columns,1,jp2_pixels);
       }
     else
       {
-       for (x=0; x < (long) image->columns; x++)
-         jas_matrix_setv(jp2_pixels,x,lut[ScaleQuantumToMap(p[x].red)]);
-       (void) jas_image_writecmpt(jp2_image,0,0,(unsigned int) y,
-                                  (unsigned int) image->columns,1,jp2_pixels);
-
-       for (x=0; x < (long) image->columns; x++)
-         jas_matrix_setv(jp2_pixels,x,lut[ScaleQuantumToMap(p[x].green)]);
-       (void) jas_image_writecmpt(jp2_image,1,0,(unsigned int) y,
-                                  (unsigned int) image->columns,1,jp2_pixels);
-
-       for (x=0; x < (long) image->columns; x++)
-         jas_matrix_setv(jp2_pixels,x,lut[ScaleQuantumToMap(p[x].blue)]);
-       (void) jas_image_writecmpt(jp2_image,2,0,(unsigned int) y,
-                                  (unsigned int) image->columns,1,jp2_pixels);
-
-       if (number_components > 3)
-         for (x=0; x < (long) image->columns; x++)
-           jas_matrix_setv(jp2_pixels,x,lut[ScaleQuantumToMap(MaxRGB-p[x].opacity)]);
-       (void) jas_image_writecmpt(jp2_image,3,0,(unsigned int) y,
-                                  (unsigned int) image->columns,1,jp2_pixels);
+        for (x=0; x < (long) image->columns; x++)
+          jas_matrix_setv(jp2_pixels,x,lut[ScaleQuantumToMap(p[x].red)]);
+        (void) jas_image_writecmpt(jp2_image,0,0,(unsigned int) y,
+                                   (unsigned int) image->columns,1,jp2_pixels);
+
+        for (x=0; x < (long) image->columns; x++)
+          jas_matrix_setv(jp2_pixels,x,lut[ScaleQuantumToMap(p[x].green)]);
+        (void) jas_image_writecmpt(jp2_image,1,0,(unsigned int) y,
+                                   (unsigned int) image->columns,1,jp2_pixels);
+
+        for (x=0; x < (long) image->columns; x++)
+          jas_matrix_setv(jp2_pixels,x,lut[ScaleQuantumToMap(p[x].blue)]);
+        (void) jas_image_writecmpt(jp2_image,2,0,(unsigned int) y,
+                                   (unsigned int) image->columns,1,jp2_pixels);
+
+        if (number_components > 3)
+          for (x=0; x < (long) image->columns; x++)
+            jas_matrix_setv(jp2_pixels,x,lut[ScaleQuantumToMap(MaxRGB-p[x].opacity)]);
+        (void) jas_image_writecmpt(jp2_image,3,0,(unsigned int) y,
+                                   (unsigned int) image->columns,1,jp2_pixels);
       }
     if (image->previous == (Image *) NULL)
       if (QuantumTick(y,image->rows))
         if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                     SaveImageText,image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
   }
   (void) strlcpy(magick,image_info->magick,MaxTextExtent);
@@ -1191,7 +1173,7 @@ WriteJP2Image(const ImageInfo *image_info,Image *image)
     {
       double
         rate=INFINITY;
-      
+
       /*
         A rough approximation to JPEG v1 quality using JPEG-2000.
         Default "quality" 75 results in a request for 16:1 compression, which
@@ -1205,13 +1187,13 @@ WriteJP2Image(const ImageInfo *image_info,Image *image)
             current_size,
             target_size,
             d;
-          
+
           d=115-image_info->quality;  /* Best number is 110-115 */
           rate=100.0/(d*d);
           header_size=550.0; /* Base file size. */
           header_size+=(number_components-1)*142; /* Additional components */
           /* FIXME: Need to account for any ICC profiles here */
-          
+
           current_size=(double)((image->rows*image->columns*image->depth)/8)*
             number_components;
           target_size=(current_size*rate)+header_size;
index 3d768f2..dc3eb59 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -123,6 +123,16 @@ static unsigned int IsJPEG(const unsigned char *magick,const size_t length)
 #define XML_MARKER  (JPEG_APP0+1)
 #define MaxBufferExtent  8192
 #define JPEG_MARKER_MAX_SIZE 65533
+#define MaxWarningCount 3
+
+/*
+  Set to 1 to use libjpeg callback for progress indication.  This is
+  not enabled by default since it outputs multiple progress
+  indications, which may be confusing for the user.  However, the
+  libjpeg method provides more detailed progress.
+*/
+#define USE_LIBJPEG_PROGRESS 0 // Use libjpeg callback for progress
+
 static const char *xmp_std_header="http://ns.adobe.com/xap/1.0/";
 
 \f
@@ -136,6 +146,7 @@ typedef struct _DestinationManager
 
   JOCTET
     *buffer;
+
 } DestinationManager;
 
 typedef struct _ErrorManager
@@ -144,11 +155,26 @@ typedef struct _ErrorManager
     *image;
 
   MagickBool
+    ping;
+
+  MagickBool
     completed;
 
   jmp_buf
     error_recovery;
 
+  unsigned int
+    max_warning_count;
+
+  magick_uint16_t
+    warning_counts[JMSG_LASTMSGCODE];
+
+  int
+    max_scan_number;
+
+  unsigned char
+    buffer[65537+200];
+
 } ErrorManager;
 
 typedef struct _SourceManager
@@ -199,12 +225,15 @@ typedef struct _SourceManager
 %
 */
 
+
 /*
-  Format a libjpeg warning or trace event.  Warnings are converted to
-  GraphicsMagick warning exceptions while traces are optionally
-  logged.
+  Format a libjpeg warning or trace event while decoding.  Warnings
+  are converted to GraphicsMagick warning exceptions while traces are
+  optionally logged.
+
+  JPEG message codes range from 0 to JMSG_LASTMSGCODE
 */
-static unsigned int JPEGMessageHandler(j_common_ptr jpeg_info,int msg_level)
+static void JPEGDecodeMessageHandler(j_common_ptr jpeg_info,int msg_level)
 {
   char
     message[JMSG_LENGTH_MAX];
@@ -225,39 +254,108 @@ static unsigned int JPEGMessageHandler(j_common_ptr jpeg_info,int msg_level)
   /* msg_level is -1 for warnings, 0 and up for trace messages. */
   if (msg_level < 0)
     {
+      unsigned int strikes = 0;
       /* A warning */
       (err->format_message)(jpeg_info,message);
 
+      if ((err->msg_code >= 0) &&
+          ((size_t) err->msg_code < ArraySize(error_manager->warning_counts)))
+        {
+          error_manager->warning_counts[err->msg_code]++;
+          strikes=error_manager->warning_counts[err->msg_code];
+        }
+
       if (image->logging)
-       {
-         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "[%s] JPEG Warning: \"%s\" (code=%d, "
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "[%s] JPEG Warning[%u]: \"%s\""
+                                " (code=%d "
                                 "parms=0x%02x,0x%02x,"
-                               "0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)",
-                               image->filename,message,err->msg_code,
-                               err->msg_parm.i[0], err->msg_parm.i[1],
-                               err->msg_parm.i[2], err->msg_parm.i[3],
-                               err->msg_parm.i[4], err->msg_parm.i[5],
-                               err->msg_parm.i[6], err->msg_parm.i[7]);
-       }
+                                "0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)",
+                                image->filename,
+                                strikes,
+                                message,err->msg_code,
+                                err->msg_parm.i[0], err->msg_parm.i[1],
+                                err->msg_parm.i[2], err->msg_parm.i[3],
+                                err->msg_parm.i[4], err->msg_parm.i[5],
+                                err->msg_parm.i[6], err->msg_parm.i[7]);
+        }
+      if (strikes > error_manager->max_warning_count)
+        {
+          ThrowException2(&image->exception,CorruptImageError,(char *) message,
+                          image->filename);
+          longjmp(error_manager->error_recovery,1);
+        }
+
       if ((err->num_warnings == 0) ||
           (err->trace_level >= 3))
-       ThrowBinaryException2(CorruptImageWarning,(char *) message,
-                             image->filename);
+        ThrowException2(&image->exception,CorruptImageWarning,message,
+                        image->filename);
+      /* JWRN_JPEG_EOF - "Premature end of JPEG file" */
       err->num_warnings++;
+      return /* False */;
     }
   else
     {
       /* A trace message */
       if ((image->logging) && (msg_level >= err->trace_level))
-       {
-         (err->format_message)(jpeg_info,message);
-         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "[%s] JPEG Trace: \"%s\"",image->filename,
+        {
+          (err->format_message)(jpeg_info,message);
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "[%s] JPEG Trace: \"%s\"",image->filename,
                                 message);
-       }
+        }
+    }
+  return /* True */;
+}
+
+static void JPEGDecodeProgressMonitor(j_common_ptr cinfo)
+{
+  ErrorManager *error_manager = (ErrorManager *) cinfo->client_data;
+  Image *image = error_manager->image;
+  const int max_scan_number = error_manager->max_scan_number;
+
+#if USE_LIBJPEG_PROGRESS
+  {
+    struct jpeg_progress_mgr *p = cinfo->progress;
+
+#if 0
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Progress: pass_counter=%ld, pass_limit=%ld,"
+                          " completed_passes=%d, total_passes=%d, filename=%s",
+                          p->pass_counter, p->pass_limit,
+                          p->completed_passes, p->total_passes, image->filename);
+#endif
+
+    if (QuantumTick(p->pass_counter,p->pass_limit))
+      if (!MagickMonitorFormatted(p->pass_counter,p->pass_limit,&image->exception,
+                                  "[%s] Loading image: %lux%lu (pass %d of %d)...  ",
+                                  image->filename,
+                                  image->columns,image->rows,
+                                  p->completed_passes+1, p->total_passes))
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Quitting due to progress monitor");
+          longjmp(error_manager->error_recovery,1);
+        }
+  }
+#endif /* USE_LIBJPEG_PROGRESS */
+
+  if (cinfo->is_decompressor)
+    {
+      int scan_no = ((j_decompress_ptr) cinfo)->input_scan_number;
+
+      if (scan_no > max_scan_number)
+        {
+          char message[MaxTextExtent];
+          FormatString(message,"Scan number %d exceeds maximum scans (%d)",
+                       scan_no, max_scan_number);
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),"%s", message);
+          ThrowException2(&image->exception,CorruptImageError,(char *) message,
+                          image->filename);
+          longjmp(error_manager->error_recovery,1);
+        }
     }
-  return(True);
 }
 
 static boolean FillInputBuffer(j_decompress_ptr cinfo)
@@ -282,10 +380,12 @@ static boolean FillInputBuffer(j_decompress_ptr cinfo)
   return(TRUE);
 }
 
-static unsigned int GetCharacter(j_decompress_ptr jpeg_info)
+static int GetCharacter(j_decompress_ptr jpeg_info)
 {
   if (jpeg_info->src->bytes_in_buffer == 0)
-    (void) (*jpeg_info->src->fill_input_buffer)(jpeg_info);
+    if ((!((*jpeg_info->src->fill_input_buffer)(jpeg_info))) ||
+        (jpeg_info->src->bytes_in_buffer == 0))
+      return EOF;
   jpeg_info->src->bytes_in_buffer--;
   return(GETJOCTET(*jpeg_info->src->next_input_byte++));
 }
@@ -328,14 +428,14 @@ static void JPEGErrorHandler(j_common_ptr jpeg_info)
   if (image->logging)
     {
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "[%s] JPEG Error: \"%s\" (code=%d, "
+                            "[%s] JPEG Error: \"%s\" (code=%d, "
                             "parms=0x%02x,0x%02x,"
-                           "0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)",
-                           image->filename,message,err->msg_code,
-                           err->msg_parm.i[0], err->msg_parm.i[1],
-                           err->msg_parm.i[2], err->msg_parm.i[3],
-                           err->msg_parm.i[4], err->msg_parm.i[5],
-                           err->msg_parm.i[6], err->msg_parm.i[7]);
+                            "0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)",
+                            image->filename,message,err->msg_code,
+                            err->msg_parm.i[0], err->msg_parm.i[1],
+                            err->msg_parm.i[2], err->msg_parm.i[3],
+                            err->msg_parm.i[4], err->msg_parm.i[5],
+                            err->msg_parm.i[6], err->msg_parm.i[7]);
     }
   if (error_manager->completed)
     ThrowException2(&image->exception,CoderWarning,(char *) message,
@@ -374,10 +474,7 @@ static boolean ReadComment(j_decompress_ptr jpeg_info)
   if (length <= 2)
     return(True);
   length-=2;
-  comment=MagickAllocateMemory(char *,length+1);
-  if (comment == (char *) NULL)
-    ThrowBinaryException(ResourceLimitError,MemoryAllocationFailed,
-      (char *) NULL);
+  comment=(char *) error_manager->buffer;
   /*
     Read comment.
   */
@@ -389,7 +486,6 @@ static boolean ReadComment(j_decompress_ptr jpeg_info)
     }
   *p='\0';
   (void) SetImageAttribute(image,"comment",comment);
-  MagickFreeMemory(comment);
   return(True);
 }
 
@@ -445,10 +541,7 @@ static boolean ReadGenericProfile(j_decompress_ptr jpeg_info)
   /*
     Copy profile from JPEG to allocated memory.
   */
-  profile=MagickAllocateMemory(unsigned char *,length);
-  if (profile == (unsigned char *) NULL)
-    ThrowBinaryException(ResourceLimitError,MemoryAllocationFailed,
-                         (char *) NULL);
+  profile=error_manager->buffer;
 
   for (i=0 ; i < length ; i++)
     profile[i]=GetCharacter(jpeg_info);
@@ -477,10 +570,12 @@ static boolean ReadGenericProfile(j_decompress_ptr jpeg_info)
   */
   status=AppendImageProfile(image,profile_name,profile+header_length,
                             length-header_length);
-  MagickFreeMemory(profile);
 
-  (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Profile: %s, %lu bytes",
-                        profile_name, (unsigned long) header_length);
+  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                        "Profile: %s, header %" MAGICK_SIZE_T_F "u bytes, "
+                        "data %" MAGICK_SIZE_T_F "u bytes",
+                        profile_name, (MAGICK_SIZE_T) header_length,
+                        (MAGICK_SIZE_T) length-header_length);
 
   return (status);
 }
@@ -537,13 +632,10 @@ static boolean ReadICCProfile(j_decompress_ptr jpeg_info)
   /*
     Read color profile.
   */
-  profile=MagickAllocateMemory(unsigned char *,(size_t) length);
-  if (profile == (unsigned char *) NULL)
-    ThrowBinaryException(ResourceLimitError,MemoryAllocationFailed,
-      (char *) NULL);
+  profile=error_manager->buffer;
 
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                       "ICC profile chunk: %ld bytes",
+                        "ICC profile chunk: %ld bytes",
     length);
 
   for (i=0 ; i < length; i++)
@@ -551,16 +643,11 @@ static boolean ReadICCProfile(j_decompress_ptr jpeg_info)
 
   (void) AppendImageProfile(image,"ICM",profile,length);
 
-  MagickFreeMemory(profile);
-
   return(True);
 }
 
 static boolean ReadIPTCProfile(j_decompress_ptr jpeg_info)
 {
-  char
-    magick[MaxTextExtent];
-
   ErrorManager
     *error_manager;
 
@@ -606,26 +693,31 @@ static boolean ReadIPTCProfile(j_decompress_ptr jpeg_info)
       *(tag+1)=GetCharacter(jpeg_info);
       length-=2;
       if ((*tag == 0x1c) && (*(tag+1) == 0x02))
-       break;
+        break;
     }
   tag_length=2;
 #else
   /*
     Validate that this was written as a Photoshop resource format slug.
   */
-  for (i=0; i < 10; i++)
-    magick[i]=GetCharacter(jpeg_info);
-  magick[10]='\0';
-  length-=10;
-  if (LocaleCompare(magick,"Photoshop ") != 0)
-    {
-      /*
-       Not a ICC profile, return.
-      */
-      for (i=0; i < length; i++)
-       (void) GetCharacter(jpeg_info);
-      return(True);
-    }
+  {
+    char
+      magick[MaxTextExtent];
+
+    for (i=0; i < 10; i++)
+      magick[i]=GetCharacter(jpeg_info);
+    magick[10]='\0';
+    length-=10;
+    if (LocaleCompare(magick,"Photoshop ") != 0)
+      {
+        /*
+          Not a ICC profile, return.
+        */
+        for (i=0; i < length; i++)
+          (void) GetCharacter(jpeg_info);
+        return(True);
+      }
+  }
   /*
     Remove the version number.
   */
@@ -637,15 +729,15 @@ static boolean ReadIPTCProfile(j_decompress_ptr jpeg_info)
   if (length <= 0)
     return(True);
 
-  profile=MagickAllocateMemory(unsigned char *,(size_t) length+tag_length);
-  if (profile == (unsigned char *) NULL)
+  if ((size_t) length+tag_length > sizeof(error_manager->buffer))
     ThrowBinaryException(ResourceLimitError,MemoryAllocationFailed,
       (char *) NULL);
+  profile=error_manager->buffer;
   /*
     Read the payload of this binary data.
   */
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                       "Profile: IPTC, %ld bytes",
+                        "Profile: IPTC, %ld bytes",
     length);
 
   for (i=0; i<length; i++)
@@ -653,7 +745,6 @@ static boolean ReadIPTCProfile(j_decompress_ptr jpeg_info)
 
   (void) AppendImageProfile(image,"IPTC",profile,length);
 
-  MagickFreeMemory(profile);
   return(True);
 }
 
@@ -705,7 +796,7 @@ static void JPEGSourceManager(j_decompress_ptr cinfo,Image *image)
 */
 static int
 EstimateJPEGQuality(const struct jpeg_decompress_struct *jpeg_info,
-                   Image *image)
+                    Image *image)
 {
   int
     save_quality;
@@ -719,147 +810,147 @@ EstimateJPEGQuality(const struct jpeg_decompress_struct *jpeg_info,
     {
       save_quality=100;
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "Quality: 100 (lossless)");
+                            "Quality: 100 (lossless)");
     }
   else
 #endif
 
     {
       int
-       hashval,
-       sum;
+        hashval,
+        sum;
 
       /*
-       Log the JPEG quality that was used for compression.
+        Log the JPEG quality that was used for compression.
       */
       sum=0;
       for (i=0; i < NUM_QUANT_TBLS; i++)
-       {
-         int
-           j;
-
-         if (jpeg_info->quant_tbl_ptrs[i] != NULL)
-           for (j=0; j < DCTSIZE2; j++)
-             {
-               UINT16 *c;
-               c=jpeg_info->quant_tbl_ptrs[i]->quantval;
-               sum+=c[j];
-             }
-       }
+        {
+          int
+            j;
+
+          if (jpeg_info->quant_tbl_ptrs[i] != NULL)
+            for (j=0; j < DCTSIZE2; j++)
+              {
+                UINT16 *c;
+                c=jpeg_info->quant_tbl_ptrs[i]->quantval;
+                sum+=c[j];
+              }
+        }
       if ((jpeg_info->quant_tbl_ptrs[0] != NULL) &&
-         (jpeg_info->quant_tbl_ptrs[1] != NULL))
-       {
-         int
-           hash[] =
-           {
-             1020, 1015,  932,  848,  780,  735,  702,  679,  660,  645,
-             632,  623,  613,  607,  600,  594,  589,  585,  581,  571,
-             555,  542,  529,  514,  494,  474,  457,  439,  424,  410,
-             397,  386,  373,  364,  351,  341,  334,  324,  317,  309,
-             299,  294,  287,  279,  274,  267,  262,  257,  251,  247,
-             243,  237,  232,  227,  222,  217,  213,  207,  202,  198,
-             192,  188,  183,  177,  173,  168,  163,  157,  153,  148,
-             143,  139,  132,  128,  125,  119,  115,  108,  104,   99,
-             94,   90,   84,   79,   74,   70,   64,   59,   55,   49,
-             45,   40,   34,   30,   25,   20,   15,   11,    6,    4,
-             0
-           };
-
-         int
-           sums[] =
-           {
-             32640,32635,32266,31495,30665,29804,29146,28599,28104,27670,
-             27225,26725,26210,25716,25240,24789,24373,23946,23572,22846,
-             21801,20842,19949,19121,18386,17651,16998,16349,15800,15247,
-             14783,14321,13859,13535,13081,12702,12423,12056,11779,11513,
-             11135,10955,10676,10392,10208, 9928, 9747, 9564, 9369, 9193,
-             9017, 8822, 8639, 8458, 8270, 8084, 7896, 7710, 7527, 7347,
-             7156, 6977, 6788, 6607, 6422, 6236, 6054, 5867, 5684, 5495,
-             5305, 5128, 4945, 4751, 4638, 4442, 4248, 4065, 3888, 3698,
-             3509, 3326, 3139, 2957, 2775, 2586, 2405, 2216, 2037, 1846,
-             1666, 1483, 1297, 1109,  927,  735,  554,  375,  201,  128,
-             0
-           };
-
-         hashval=(jpeg_info->quant_tbl_ptrs[0]->quantval[2]+
-                  jpeg_info->quant_tbl_ptrs[0]->quantval[53]+
-                  jpeg_info->quant_tbl_ptrs[1]->quantval[0]+
-                  jpeg_info->quant_tbl_ptrs[1]->quantval[DCTSIZE2-1]);
-         for (i=0; i < 100; i++)
-           {
-             if ((hashval >= hash[i]) || (sum >= sums[i]))
-               {
-                 save_quality=i+1;
-                 if (image->logging)
-                   {
-                     if ((hashval > hash[i]) || (sum > sums[i]))
-                       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                             "Quality: %d (approximate)",
-                                             save_quality);
-                     else
-                       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                             "Quality: %d",save_quality);
-                   }
-                 break;
-               }
-           }
-       }
+          (jpeg_info->quant_tbl_ptrs[1] != NULL))
+        {
+          int
+            hash[] =
+            {
+              1020, 1015,  932,  848,  780,  735,  702,  679,  660,  645,
+              632,  623,  613,  607,  600,  594,  589,  585,  581,  571,
+              555,  542,  529,  514,  494,  474,  457,  439,  424,  410,
+              397,  386,  373,  364,  351,  341,  334,  324,  317,  309,
+              299,  294,  287,  279,  274,  267,  262,  257,  251,  247,
+              243,  237,  232,  227,  222,  217,  213,  207,  202,  198,
+              192,  188,  183,  177,  173,  168,  163,  157,  153,  148,
+              143,  139,  132,  128,  125,  119,  115,  108,  104,   99,
+              94,   90,   84,   79,   74,   70,   64,   59,   55,   49,
+              45,   40,   34,   30,   25,   20,   15,   11,    6,    4,
+              0
+            };
+
+          int
+            sums[] =
+            {
+              32640,32635,32266,31495,30665,29804,29146,28599,28104,27670,
+              27225,26725,26210,25716,25240,24789,24373,23946,23572,22846,
+              21801,20842,19949,19121,18386,17651,16998,16349,15800,15247,
+              14783,14321,13859,13535,13081,12702,12423,12056,11779,11513,
+              11135,10955,10676,10392,10208, 9928, 9747, 9564, 9369, 9193,
+              9017, 8822, 8639, 8458, 8270, 8084, 7896, 7710, 7527, 7347,
+              7156, 6977, 6788, 6607, 6422, 6236, 6054, 5867, 5684, 5495,
+              5305, 5128, 4945, 4751, 4638, 4442, 4248, 4065, 3888, 3698,
+              3509, 3326, 3139, 2957, 2775, 2586, 2405, 2216, 2037, 1846,
+              1666, 1483, 1297, 1109,  927,  735,  554,  375,  201,  128,
+              0
+            };
+
+          hashval=(jpeg_info->quant_tbl_ptrs[0]->quantval[2]+
+                   jpeg_info->quant_tbl_ptrs[0]->quantval[53]+
+                   jpeg_info->quant_tbl_ptrs[1]->quantval[0]+
+                   jpeg_info->quant_tbl_ptrs[1]->quantval[DCTSIZE2-1]);
+          for (i=0; i < 100; i++)
+            {
+              if ((hashval >= hash[i]) || (sum >= sums[i]))
+                {
+                  save_quality=i+1;
+                  if (image->logging)
+                    {
+                      if ((hashval > hash[i]) || (sum > sums[i]))
+                        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                              "Quality: %d (approximate)",
+                                              save_quality);
+                      else
+                        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                              "Quality: %d",save_quality);
+                    }
+                  break;
+                }
+            }
+        }
       else
-       if (jpeg_info->quant_tbl_ptrs[0] != NULL)
-         {
-           int
-             bwhash[] =
-             {
-               510,  505,  422,  380,  355,  338,  326,  318,  311,  305,
-               300,  297,  293,  291,  288,  286,  284,  283,  281,  280,
-               279,  278,  277,  273,  262,  251,  243,  233,  225,  218,
-               211,  205,  198,  193,  186,  181,  177,  172,  168,  164,
-               158,  156,  152,  148,  145,  142,  139,  136,  133,  131,
-               129,  126,  123,  120,  118,  115,  113,  110,  107,  105,
-               102,  100,   97,   94,   92,   89,   87,   83,   81,   79,
-               76,   74,   70,   68,   66,   63,   61,   57,   55,   52,
-               50,   48,   44,   42,   39,   37,   34,   31,   29,   26,
-               24,   21,   18,   16,   13,   11,    8,    6,    3,    2,
-               0
-             };
-
-           int
-             bwsum[] =
-             {
-               16320,16315,15946,15277,14655,14073,13623,13230,12859,12560,
-               12240,11861,11456,11081,10714,10360,10027, 9679, 9368, 9056,
-               8680, 8331, 7995, 7668, 7376, 7084, 6823, 6562, 6345, 6125,
-               5939, 5756, 5571, 5421, 5240, 5086, 4976, 4829, 4719, 4616, 
-               4463, 4393, 4280, 4166, 4092, 3980, 3909, 3835, 3755, 3688,
-               3621, 3541, 3467, 3396, 3323, 3247, 3170, 3096, 3021, 2952,
-               2874, 2804, 2727, 2657, 2583, 2509, 2437, 2362, 2290, 2211,
-               2136, 2068, 1996, 1915, 1858, 1773, 1692, 1620, 1552, 1477,
-               1398, 1326, 1251, 1179, 1109, 1031,  961,  884,  814,  736,
-               667,  592,  518,  441,  369,  292,  221,  151,   86,   64,
-               0
-             };
-
-           hashval=(jpeg_info->quant_tbl_ptrs[0]->quantval[2]+
-                    jpeg_info->quant_tbl_ptrs[0]->quantval[53]);
-           for (i=0; i < 100; i++)
-             {
-               if ((hashval >= bwhash[i]) || (sum >= bwsum[i]))
-                 {
-                   save_quality=i+1;
-                   if (image->logging)
-                     {
-                       if ((hashval > bwhash[i]) || (sum > bwsum[i]))
-                         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                               "Quality: %ld (approximate)",
-                                               i+1);
-                       else
-                         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                               "Quality: %ld",i+1);
-                     }
-                   break;
-                 }
-             }
-         }
+        if (jpeg_info->quant_tbl_ptrs[0] != NULL)
+          {
+            int
+              bwhash[] =
+              {
+                510,  505,  422,  380,  355,  338,  326,  318,  311,  305,
+                300,  297,  293,  291,  288,  286,  284,  283,  281,  280,
+                279,  278,  277,  273,  262,  251,  243,  233,  225,  218,
+                211,  205,  198,  193,  186,  181,  177,  172,  168,  164,
+                158,  156,  152,  148,  145,  142,  139,  136,  133,  131,
+                129,  126,  123,  120,  118,  115,  113,  110,  107,  105,
+                102,  100,   97,   94,   92,   89,   87,   83,   81,   79,
+                76,   74,   70,   68,   66,   63,   61,   57,   55,   52,
+                50,   48,   44,   42,   39,   37,   34,   31,   29,   26,
+                24,   21,   18,   16,   13,   11,    8,    6,    3,    2,
+                0
+              };
+
+            int
+              bwsum[] =
+              {
+                16320,16315,15946,15277,14655,14073,13623,13230,12859,12560,
+                12240,11861,11456,11081,10714,10360,10027, 9679, 9368, 9056,
+                8680, 8331, 7995, 7668, 7376, 7084, 6823, 6562, 6345, 6125,
+                5939, 5756, 5571, 5421, 5240, 5086, 4976, 4829, 4719, 4616,
+                4463, 4393, 4280, 4166, 4092, 3980, 3909, 3835, 3755, 3688,
+                3621, 3541, 3467, 3396, 3323, 3247, 3170, 3096, 3021, 2952,
+                2874, 2804, 2727, 2657, 2583, 2509, 2437, 2362, 2290, 2211,
+                2136, 2068, 1996, 1915, 1858, 1773, 1692, 1620, 1552, 1477,
+                1398, 1326, 1251, 1179, 1109, 1031,  961,  884,  814,  736,
+                667,  592,  518,  441,  369,  292,  221,  151,   86,   64,
+                0
+              };
+
+            hashval=(jpeg_info->quant_tbl_ptrs[0]->quantval[2]+
+                     jpeg_info->quant_tbl_ptrs[0]->quantval[53]);
+            for (i=0; i < 100; i++)
+              {
+                if ((hashval >= bwhash[i]) || (sum >= bwsum[i]))
+                  {
+                    save_quality=i+1;
+                    if (image->logging)
+                      {
+                        if ((hashval > bwhash[i]) || (sum > bwsum[i]))
+                          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                                "Quality: %ld (approximate)",
+                                                i+1);
+                        else
+                          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                                "Quality: %ld",i+1);
+                      }
+                    break;
+                  }
+              }
+          }
     }
 
   return save_quality;
@@ -870,7 +961,7 @@ EstimateJPEGQuality(const struct jpeg_decompress_struct *jpeg_info,
 */
 static void
 FormatJPEGColorSpace(const J_COLOR_SPACE colorspace,
-                    char *colorspace_name)
+                     char *colorspace_name)
 {
   const char
     *s = NULL;
@@ -905,53 +996,53 @@ FormatJPEGColorSpace(const J_COLOR_SPACE colorspace,
 */
 static void
 FormatJPEGSamplingFactors(const struct jpeg_decompress_struct *jpeg_info,
-                         char *sampling_factors)
+                          char *sampling_factors)
 {
   switch (jpeg_info->out_color_space)
     {
     case JCS_CMYK:
       {
-       (void) FormatString(sampling_factors,"%dx%d,%dx%d,%dx%d,%dx%d",
-                           jpeg_info->comp_info[0].h_samp_factor,
-                           jpeg_info->comp_info[0].v_samp_factor,
-                           jpeg_info->comp_info[1].h_samp_factor,
-                           jpeg_info->comp_info[1].v_samp_factor,
-                           jpeg_info->comp_info[2].h_samp_factor,
-                           jpeg_info->comp_info[2].v_samp_factor,
-                           jpeg_info->comp_info[3].h_samp_factor,
-                           jpeg_info->comp_info[3].v_samp_factor);
+        (void) FormatString(sampling_factors,"%dx%d,%dx%d,%dx%d,%dx%d",
+                            jpeg_info->comp_info[0].h_samp_factor,
+                            jpeg_info->comp_info[0].v_samp_factor,
+                            jpeg_info->comp_info[1].h_samp_factor,
+                            jpeg_info->comp_info[1].v_samp_factor,
+                            jpeg_info->comp_info[2].h_samp_factor,
+                            jpeg_info->comp_info[2].v_samp_factor,
+                            jpeg_info->comp_info[3].h_samp_factor,
+                            jpeg_info->comp_info[3].v_samp_factor);
         break;
       }
     case JCS_GRAYSCALE:
       {
-       (void) FormatString(sampling_factors,"%dx%d",
-                           jpeg_info->comp_info[0].h_samp_factor,
-                           jpeg_info->comp_info[0].v_samp_factor);
+        (void) FormatString(sampling_factors,"%dx%d",
+                            jpeg_info->comp_info[0].h_samp_factor,
+                            jpeg_info->comp_info[0].v_samp_factor);
         break;
       }
     case JCS_RGB:
       {
-       (void) FormatString(sampling_factors,"%dx%d,%dx%d,%dx%d",
-                           jpeg_info->comp_info[0].h_samp_factor,
-                           jpeg_info->comp_info[0].v_samp_factor,
-                           jpeg_info->comp_info[1].h_samp_factor,
-                           jpeg_info->comp_info[1].v_samp_factor,
-                           jpeg_info->comp_info[2].h_samp_factor,
-                           jpeg_info->comp_info[2].v_samp_factor);
+        (void) FormatString(sampling_factors,"%dx%d,%dx%d,%dx%d",
+                            jpeg_info->comp_info[0].h_samp_factor,
+                            jpeg_info->comp_info[0].v_samp_factor,
+                            jpeg_info->comp_info[1].h_samp_factor,
+                            jpeg_info->comp_info[1].v_samp_factor,
+                            jpeg_info->comp_info[2].h_samp_factor,
+                            jpeg_info->comp_info[2].v_samp_factor);
         break;
       }
     default:
       {
-       (void) FormatString(sampling_factors,"%dx%d,%dx%d,%dx%d,%dx%d",
-                           jpeg_info->comp_info[0].h_samp_factor,
-                           jpeg_info->comp_info[0].v_samp_factor,
-                           jpeg_info->comp_info[1].h_samp_factor,
-                           jpeg_info->comp_info[1].v_samp_factor,
-                           jpeg_info->comp_info[2].h_samp_factor,
-                           jpeg_info->comp_info[2].v_samp_factor,
-                           jpeg_info->comp_info[3].h_samp_factor,
-                           jpeg_info->comp_info[3].v_samp_factor);
-       break;
+        (void) FormatString(sampling_factors,"%dx%d,%dx%d,%dx%d,%dx%d",
+                            jpeg_info->comp_info[0].h_samp_factor,
+                            jpeg_info->comp_info[0].v_samp_factor,
+                            jpeg_info->comp_info[1].h_samp_factor,
+                            jpeg_info->comp_info[1].v_samp_factor,
+                            jpeg_info->comp_info[2].h_samp_factor,
+                            jpeg_info->comp_info[2].v_samp_factor,
+                            jpeg_info->comp_info[3].h_samp_factor,
+                            jpeg_info->comp_info[3].v_samp_factor);
+        break;
       }
     }
 }
@@ -961,22 +1052,22 @@ IsITUFax(const Image* image)
 {
   size_t
     profile_length;
-  
+
   const unsigned char
     *profile;
-  
+
   MagickBool
     status;
-  
+
   status=MagickFalse;
   if ((profile=GetImageProfile(image,"APP1",&profile_length)) &&
       (profile_length >= 5))
     {
       if (profile[0] == 0x47 &&
-         profile[1] == 0x33 &&
-         profile[2] == 0x46 &&
-         profile[3] == 0x41 &&
-         profile[4] == 0x58)
+          profile[1] == 0x33 &&
+          profile[2] == 0x46 &&
+          profile[3] == 0x41 &&
+          profile[4] == 0x58)
       status=MagickTrue;
     }
 
@@ -984,14 +1075,14 @@ IsITUFax(const Image* image)
 }
 
 static Image *ReadJPEGImage(const ImageInfo *image_info,
-                           ExceptionInfo *exception)
+                            ExceptionInfo *exception)
 {
-  ErrorManager
-    error_manager;
-
   Image
     *image;
 
+  ErrorManager
+    error_manager;
+
   IndexPacket
     index;
 
@@ -1004,15 +1095,21 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
   JSAMPROW
     scanline[1];
 
+  const char
+    *value;
+
   register long
     i;
 
-  struct jpeg_decompress_struct
-    jpeg_info;
-
   struct jpeg_error_mgr
     jpeg_error;
 
+  struct jpeg_progress_mgr
+    jpeg_progress;
+
+  struct jpeg_decompress_struct
+    jpeg_info;
+
   register JSAMPLE
     *p;
 
@@ -1041,13 +1138,24 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
     Initialize structures.
   */
   (void) memset(&error_manager,0,sizeof(error_manager));
+  (void) memset(&jpeg_progress,0,sizeof(jpeg_progress));
   (void) memset(&jpeg_info,0,sizeof(jpeg_info));
   (void) memset(&jpeg_error,0,sizeof(jpeg_error));
   jpeg_info.err=jpeg_std_error(&jpeg_error);
-  jpeg_info.err->emit_message=(void (*)(j_common_ptr,int)) JPEGMessageHandler;
+  jpeg_info.err->emit_message=/*(void (*)(j_common_ptr,int))*/ JPEGDecodeMessageHandler;
   jpeg_info.err->error_exit=(void (*)(j_common_ptr)) JPEGErrorHandler;
   jpeg_pixels=(JSAMPLE *) NULL;
   error_manager.image=image;
+  error_manager.ping=image_info->ping;
+  error_manager.max_scan_number=100;
+  error_manager.max_warning_count=MaxWarningCount;
+
+  /*
+    Allow the user to set how many warnings of any given type are
+    allowed before promotion of the warning to a hard error.
+  */
+  if ((value=AccessDefinition(image_info,"jpeg","max-warnings")))
+    error_manager.max_warning_count=strtol(value,(char **) NULL, 10);
 
   /*
     Set initial longjmp based error handler.
@@ -1065,6 +1173,22 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
   jpeg_info.client_data=(void *) &error_manager;
 
   jpeg_create_decompress(&jpeg_info);
+  /*
+    Specify a memory limit for libjpeg which is 1/5th the absolute
+    limit.  Don't actually consume the resource since we don't know
+    how much libjpeg will actually consume.
+  */
+  jpeg_info.mem->max_memory_to_use=(long) (GetMagickResourceLimit(MemoryResource) -
+                                           GetMagickResource(MemoryResource))/5U;
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Memory capped to %ld bytes", jpeg_info.mem->max_memory_to_use);
+  /*
+    Register our progress monitor
+  */
+  jpeg_progress.progress_monitor=(void (*)(j_common_ptr)) JPEGDecodeProgressMonitor;
+  jpeg_info.progress=&jpeg_progress;
+
   JPEGSourceManager(&jpeg_info,image);
   jpeg_set_marker_processor(&jpeg_info,JPEG_COM,ReadComment);
   jpeg_set_marker_processor(&jpeg_info,ICC_MARKER,ReadICCProfile);
@@ -1072,20 +1196,26 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
   for (i=1; i < 16; i++)
     if ((i != 2) && (i != 13) && (i != 14))
       jpeg_set_marker_processor(&jpeg_info,JPEG_APP0+i,ReadGenericProfile);
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Reading JPEG header...");
   i=jpeg_read_header(&jpeg_info,True);
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Done with reading JPEG header");
   if (IsITUFax(image))
     {
       if (image->logging)
-       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "Image colorspace set to LAB");
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Image colorspace set to LAB");
       image->colorspace=LABColorspace;
       jpeg_info.out_color_space = JCS_YCbCr;
     }
   else if (jpeg_info.out_color_space == JCS_CMYK)
     {
       if (image->logging)
-       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "Image colorspace set to CMYK");
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Image colorspace set to CMYK");
       image->colorspace=CMYKColorspace;
     }
   if (jpeg_info.saw_JFIF_marker)
@@ -1109,6 +1239,7 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
                                   ResolutionTypeToString(image->units));
         }
     }
+
   /*
     If the desired image size is pre-set (e.g. by using -size), then
     let the JPEG library subsample for us.
@@ -1121,9 +1252,9 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
 
 
       if (image->logging)
-       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "Requested Geometry: %lux%lu",
-                             image->columns,image->rows);
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Requested Geometry: %lux%lu",
+                              image->columns,image->rows);
       jpeg_calc_output_dimensions(&jpeg_info);
       image->magick_columns=jpeg_info.output_width;
       image->magick_rows=jpeg_info.output_height;
@@ -1133,11 +1264,11 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
       jpeg_info.scale_denom *=(unsigned int) scale_factor;
       jpeg_calc_output_dimensions(&jpeg_info);
       if (image->logging)
-       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "Scale_factor: %ld (scale_num=%d, "
-                             "scale_denom=%d)",
-                             (long) scale_factor,
-                             jpeg_info.scale_num,jpeg_info.scale_denom);
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Scale_factor: %ld (scale_num=%d, "
+                              "scale_denom=%d)",
+                              (long) scale_factor,
+                              jpeg_info.scale_num,jpeg_info.scale_denom);
     }
 #if 0
   /*
@@ -1155,11 +1286,11 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
       jpeg_info.scale_denom *=(int) image_info->subrange;
       jpeg_calc_output_dimensions(&jpeg_info);
       if (image->logging)
-       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "Requested Scaling Denominator: %d "
-                             "(scale_num=%d, scale_denom=%d)",
-                             (int) image_info->subrange,
-                             jpeg_info.scale_num,jpeg_info.scale_denom);
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Requested Scaling Denominator: %d "
+                              "(scale_num=%d, scale_denom=%d)",
+                              (int) image_info->subrange,
+                              jpeg_info.scale_num,jpeg_info.scale_denom);
 
     }
 #endif
@@ -1171,8 +1302,8 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
     LosslessJPEGCompression : JPEGCompression;
   if (jpeg_info.data_precision > 8)
     MagickError2(OptionError,
-                "12-bit JPEG not supported. Reducing pixel data to 8 bits",
-                (char *) NULL);
+                 "12-bit JPEG not supported. Reducing pixel data to 8 bits",
+                 (char *) NULL);
 #else
   image->interlace=jpeg_info.progressive_mode ? LineInterlace : NoInterlace;
   image->compression=JPEGCompression;
@@ -1181,75 +1312,105 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
   image->compression=JPEGCompression;
   image->interlace=LineInterlace;
 #endif
-  {
-    const char
-      *value;
 
-    /*
-      Allow the user to enable/disable block smoothing.
-    */
-    if ((value=AccessDefinition(image_info,"jpeg","block-smoothing")))
-      {
-       if (LocaleCompare(value,"FALSE") == 0)
-          jpeg_info.do_block_smoothing=False;
-        else
-          jpeg_info.do_block_smoothing=True;
-      }
+  /*
+    Allow the user to enable/disable block smoothing.
+  */
+  if ((value=AccessDefinition(image_info,"jpeg","block-smoothing")))
+    {
+      if (LocaleCompare(value,"FALSE") == 0)
+        jpeg_info.do_block_smoothing=False;
+      else
+        jpeg_info.do_block_smoothing=True;
+    }
 
-    /*
-      Allow the user to select the DCT decoding algorithm.
-    */
-    if ((value=AccessDefinition(image_info,"jpeg","dct-method")))
-      {
-        if (LocaleCompare(value,"ISLOW") == 0)
-          jpeg_info.dct_method=JDCT_ISLOW;
-        else if (LocaleCompare(value,"IFAST") == 0)
-          jpeg_info.dct_method=JDCT_IFAST;
-        else if (LocaleCompare(value,"FLOAT") == 0)
-          jpeg_info.dct_method=JDCT_FLOAT;
-        else if (LocaleCompare(value,"DEFAULT") == 0)
-          jpeg_info.dct_method=JDCT_DEFAULT;
-        else if (LocaleCompare(value,"FASTEST") == 0)
-          jpeg_info.dct_method=JDCT_FASTEST;
-      }
+  /*
+    Allow the user to select the DCT decoding algorithm.
+  */
+  if ((value=AccessDefinition(image_info,"jpeg","dct-method")))
+    {
+      if (LocaleCompare(value,"ISLOW") == 0)
+        jpeg_info.dct_method=JDCT_ISLOW;
+      else if (LocaleCompare(value,"IFAST") == 0)
+        jpeg_info.dct_method=JDCT_IFAST;
+      else if (LocaleCompare(value,"FLOAT") == 0)
+        jpeg_info.dct_method=JDCT_FLOAT;
+      else if (LocaleCompare(value,"DEFAULT") == 0)
+        jpeg_info.dct_method=JDCT_DEFAULT;
+      else if (LocaleCompare(value,"FASTEST") == 0)
+        jpeg_info.dct_method=JDCT_FASTEST;
+    }
 
-    /*
-      Allow the user to enable/disable fancy upsampling.
-    */
-    if ((value=AccessDefinition(image_info,"jpeg","fancy-upsampling")))
-      {
-       if (LocaleCompare(value,"FALSE") == 0)
-          jpeg_info.do_fancy_upsampling=False;
-        else
-          jpeg_info.do_fancy_upsampling=True;
-      }
-  }
-  (void) jpeg_start_decompress(&jpeg_info);
+  /*
+    Allow the user to enable/disable fancy upsampling.
+  */
+  if ((value=AccessDefinition(image_info,"jpeg","fancy-upsampling")))
+    {
+      if (LocaleCompare(value,"FALSE") == 0)
+        jpeg_info.do_fancy_upsampling=False;
+      else
+        jpeg_info.do_fancy_upsampling=True;
+    }
+
+  /*
+    Allow the user to adjust the maximum JPEG scan number
+  */
+  if ((value=AccessDefinition(image_info,"jpeg","max-scan-number")))
+    {
+      error_manager.max_scan_number=strtol(value,(char **) NULL, 10);
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "JPEG max-scan-number set to %d",
+                            error_manager.max_scan_number);
+    }
+
+  jpeg_calc_output_dimensions(&jpeg_info);
   image->columns=jpeg_info.output_width;
   image->rows=jpeg_info.output_height;
+  image->storage_class = jpeg_info.output_components == 1 ? PseudoClass : DirectClass;
+  image->depth=Min(jpeg_info.data_precision,QuantumDepth);
+
   if (image->logging)
     {
       if (image->interlace == LineInterlace)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "Interlace: progressive");
+                              "Interlace: progressive");
       else
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "Interlace: nonprogressive");
+                              "Interlace: nonprogressive");
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Data precision: %d",
-                           (int) jpeg_info.data_precision);
+                            (int) jpeg_info.data_precision);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Components: %d",
-                           (int) jpeg_info.output_components);
+                            (int) jpeg_info.output_components);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Geometry: %dx%d",
-                           (int) jpeg_info.output_width,
-                           (int) jpeg_info.output_height);
+                            (int) jpeg_info.output_width,
+                            (int) jpeg_info.output_height);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"DCT Method: %d",
-                           jpeg_info.dct_method);
+                            jpeg_info.dct_method);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Fancy Upsampling: %s",
-                           (jpeg_info.do_fancy_upsampling ? "true" : "false"));
+                            (jpeg_info.do_fancy_upsampling ? "true" : "false"));
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Block Smoothing: %s",
-                           (jpeg_info.do_block_smoothing ? "true" : "false"));
+                            (jpeg_info.do_block_smoothing ? "true" : "false"));
     }
 
+  if (image_info->ping)
+    {
+      jpeg_destroy_decompress(&jpeg_info);
+      CloseBlob(image);
+      return(image);
+    }
+
+  if (CheckImagePixelLimits(image, exception) != MagickPass)
+    {
+      jpeg_destroy_decompress(&jpeg_info);
+      ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+    }
+
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Starting JPEG decompression...");
+  (void) jpeg_start_decompress(&jpeg_info);
+  image->columns=jpeg_info.output_width;
+  image->rows=jpeg_info.output_height;
   {
     char
       attribute[MaxTextExtent];
@@ -1267,16 +1428,16 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
     (void) SetImageAttribute(image,"JPEG-Colorspace-Name",attribute);
     if (image->logging)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "Colorspace: %s (%d)", attribute,
-                           jpeg_info.out_color_space);
+                            "Colorspace: %s (%d)", attribute,
+                            jpeg_info.out_color_space);
 
     FormatJPEGSamplingFactors(&jpeg_info,attribute);
     (void) SetImageAttribute(image,"JPEG-Sampling-factors",attribute);
     if (image->logging)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "Sampling Factors: %s", attribute);
+                            "Sampling Factors: %s", attribute);
   }
-  
+
   image->depth=Min(jpeg_info.data_precision,QuantumDepth);
   if (jpeg_info.out_color_space == JCS_GRAYSCALE)
     if (!AllocateImageColormap(image,1 << image->depth))
@@ -1284,12 +1445,6 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
         jpeg_destroy_decompress(&jpeg_info);
         ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
       }
-  if (image_info->ping)
-    {
-      jpeg_destroy_decompress(&jpeg_info);
-      CloseBlob(image);
-      return(image);
-    }
   if (CheckImagePixelLimits(image, exception) != MagickPass)
     {
       jpeg_destroy_decompress(&jpeg_info);
@@ -1306,16 +1461,43 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
       jpeg_destroy_decompress(&jpeg_info);
       ThrowReaderException(CoderError,ImageTypeNotSupported,image);
     }
+  /*
+    Verify that file size is reasonable (if we can)
+  */
+  if (BlobIsSeekable(image))
+    {
+      magick_off_t
+        blob_size;
+
+      blob_size = GetBlobSize(image);
+      if ((blob_size == 0) ||
+          (((double) image->columns*image->rows*
+            jpeg_info.output_components/blob_size) > 512.0))
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Unreasonable dimensions: "
+                                "geometry=%lux%lu, components=%d, "
+                                "blob size=%" MAGICK_OFF_F "d bytes",
+                                image->columns, image->rows,
+                                jpeg_info.output_components, blob_size);
+
+          jpeg_destroy_decompress(&jpeg_info);
+          ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,image);
+        }
+    }
 
   jpeg_pixels=MagickAllocateArray(JSAMPLE *,
-                                 jpeg_info.output_components,
-                                 MagickArraySize(image->columns,
+                                  jpeg_info.output_components,
+                                  MagickArraySize(image->columns,
                                                   sizeof(JSAMPLE)));
   if (jpeg_pixels == (JSAMPLE *) NULL)
     {
       jpeg_destroy_decompress(&jpeg_info);
       ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
     }
+  (void) memset(jpeg_pixels,0,MagickArraySize(jpeg_info.output_components,
+                                              MagickArraySize(image->columns,
+                                                              sizeof(JSAMPLE))));
 
   /*
     Extended longjmp-based error handler (with jpeg_pixels)
@@ -1342,105 +1524,111 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
   for (y=0; y < (long) image->rows; y++)
     {
       register IndexPacket
-       *indexes;
+        *indexes;
 
       register long
-       x;
+        x;
 
       register PixelPacket
-       *q;
+        *q;
+
+      /*
+        Read scanlines. Stop at first serious error.
+       */
+      if ((jpeg_read_scanlines(&jpeg_info,scanline,1) != 1) ||
+          (image->exception.severity >= ErrorException))
+        {
+          status=MagickFail;
+          break;
+        }
 
       q=SetImagePixels(image,0,y,image->columns,1);
       if (q == (PixelPacket *) NULL)
-       {
-         status=MagickFail;
-         break;
-       }
+        {
+          status=MagickFail;
+          break;
+        }
       indexes=AccessMutableIndexes(image);
 
-      if (jpeg_read_scanlines(&jpeg_info,scanline,1) != 1)
-       {
-         status=MagickFail;
-         break;
-       }
-
       p=jpeg_pixels;
 
       if (jpeg_info.output_components == 1)
-       {
-         for (x=0; x < (long) image->columns; x++)
-           {
-             index=(IndexPacket) (GETJSAMPLE(*p++));
-             VerifyColormapIndex(image,index);
-             indexes[x]=index;
-             *q++=image->colormap[index];
-           }
-       }
+        {
+          for (x=0; x < (long) image->columns; x++)
+            {
+              index=(IndexPacket) (GETJSAMPLE(*p++));
+              VerifyColormapIndex(image,index);
+              indexes[x]=index;
+              *q++=image->colormap[index];
+            }
+        }
       else if ((jpeg_info.output_components == 3) ||
                (jpeg_info.output_components == 4))
-       {
-         if (jpeg_info.data_precision > 8)
-           {
+        {
+          if (jpeg_info.data_precision > 8)
+            {
               unsigned int
                 scale_short;
 
               scale_short=65535U/MaxValueGivenBits(jpeg_info.data_precision);
-             for (x=0; x < (long) image->columns; x++)
-               {
-                 q->red=ScaleShortToQuantum(scale_short*GETJSAMPLE(*p++));
-                 q->green=ScaleShortToQuantum(scale_short*GETJSAMPLE(*p++));
-                 q->blue=ScaleShortToQuantum(scale_short*GETJSAMPLE(*p++));
-                 if (jpeg_info.output_components > 3)
-                   q->opacity=ScaleShortToQuantum(scale_short*GETJSAMPLE(*p++));
-                 else
-                   q->opacity=OpaqueOpacity;
-                 q++;
-               }
-           }
-         else
-           {
-             for (x=0; x < (long) image->columns; x++)
-               {
-                 q->red=ScaleCharToQuantum(GETJSAMPLE(*p++));
-                 q->green=ScaleCharToQuantum(GETJSAMPLE(*p++));
-                 q->blue=ScaleCharToQuantum(GETJSAMPLE(*p++));
-                 if (jpeg_info.output_components > 3)
-                   q->opacity=ScaleCharToQuantum(GETJSAMPLE(*p++));
-                 else
-                   q->opacity=OpaqueOpacity;
-                 q++;
-               }
-           }
-         if (image->colorspace == CMYKColorspace)
-           {
-             /*
-               CMYK pixels are inverted.
-             */
-             q=AccessMutablePixels(image);
-             for (x=0; x < (long) image->columns; x++)
-               {
-                 q->red=MaxRGB-q->red;
-                 q->green=MaxRGB-q->green;
-                 q->blue=MaxRGB-q->blue;
-                 q->opacity=MaxRGB-q->opacity;
-                 q++;
-               }
-           }
-       }
+              for (x=0; x < (long) image->columns; x++)
+                {
+                  q->red=ScaleShortToQuantum(scale_short*GETJSAMPLE(*p++));
+                  q->green=ScaleShortToQuantum(scale_short*GETJSAMPLE(*p++));
+                  q->blue=ScaleShortToQuantum(scale_short*GETJSAMPLE(*p++));
+                  if (jpeg_info.output_components > 3)
+                    q->opacity=ScaleShortToQuantum(scale_short*GETJSAMPLE(*p++));
+                  else
+                    q->opacity=OpaqueOpacity;
+                  q++;
+                }
+            }
+          else
+            {
+              for (x=0; x < (long) image->columns; x++)
+                {
+                  q->red=ScaleCharToQuantum(GETJSAMPLE(*p++));
+                  q->green=ScaleCharToQuantum(GETJSAMPLE(*p++));
+                  q->blue=ScaleCharToQuantum(GETJSAMPLE(*p++));
+                  if (jpeg_info.output_components > 3)
+                    q->opacity=ScaleCharToQuantum(GETJSAMPLE(*p++));
+                  else
+                    q->opacity=OpaqueOpacity;
+                  q++;
+                }
+            }
+          if (image->colorspace == CMYKColorspace)
+            {
+              /*
+                CMYK pixels are inverted.
+              */
+              q=AccessMutablePixels(image);
+              for (x=0; x < (long) image->columns; x++)
+                {
+                  q->red=MaxRGB-q->red;
+                  q->green=MaxRGB-q->green;
+                  q->blue=MaxRGB-q->blue;
+                  q->opacity=MaxRGB-q->opacity;
+                  q++;
+                }
+            }
+        }
       if (!SyncImagePixels(image))
-       {
-         status=MagickFail;
-         break;
-       }
+        {
+          status=MagickFail;
+          break;
+        }
+#if !USE_LIBJPEG_PROGRESS
       if (QuantumTick(y,image->rows))
-       if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
-                                   image->filename,
-                                   image->columns,image->rows))
-         {
-           status=MagickFail;
-           jpeg_abort_decompress(&jpeg_info);
-           break;
-         }
+        if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
+                                    image->filename,
+                                    image->columns,image->rows))
+          {
+            status=MagickFail;
+            jpeg_abort_decompress(&jpeg_info);
+            break;
+          }
+#endif /* !USE_LIBJPEG_PROGRESS */
     }
   /*
     Free jpeg resources.
@@ -1448,17 +1636,17 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
   if (status == MagickPass)
     {
       /*
-       jpeg_finish_decompress() may throw an exception while it is
-       finishing the remainder of the JPEG file.  At this point we
-       have already decoded the image so we handle exceptions from
-       jpeg_finish_decompress() specially, mapping reported
-       exceptions as warnings rather than errors.  We try using
-       jpeg_finish_decompress() and if it results in a longjmp(),
-       then we skip over it again.
+        jpeg_finish_decompress() may throw an exception while it is
+        finishing the remainder of the JPEG file.  At this point we
+        have already decoded the image so we handle exceptions from
+        jpeg_finish_decompress() specially, mapping reported
+        exceptions as warnings rather than errors.  We try using
+        jpeg_finish_decompress() and if it results in a longjmp(),
+        then we skip over it again.
       */
       error_manager.completed=MagickTrue;
       if (!setjmp(error_manager.error_recovery))
-       (void) jpeg_finish_decompress(&jpeg_info);
+        (void) jpeg_finish_decompress(&jpeg_info);
     }
   jpeg_destroy_decompress(&jpeg_info);
   MagickFreeMemory(jpeg_pixels);
@@ -1474,22 +1662,22 @@ static Image *ReadJPEGImage(const ImageInfo *image_info,
   if (status == MagickPass)
     {
       const ImageAttribute
-       *attribute;
+        *attribute;
 
       attribute = GetImageAttribute(image,"EXIF:Orientation");
       if ((attribute != (const ImageAttribute *) NULL) &&
-         (attribute->value != (char *) NULL))
-       {
-         int
-           orientation;
-
-         orientation=MagickAtoI(attribute->value);
-         if ((orientation > UndefinedOrientation) &&
-             (orientation <= LeftBottomOrientation))
-           image->orientation=(OrientationType) orientation;
-       }
+          (attribute->value != (char *) NULL))
+        {
+          int
+            orientation;
+
+          orientation=MagickAtoI(attribute->value);
+          if ((orientation > UndefinedOrientation) &&
+              (orientation <= LeftBottomOrientation))
+            image->orientation=(OrientationType) orientation;
+        }
     }
-  if (image->logging) 
+  if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),"return");
   GetImageException(image,exception);
   return(image);
@@ -1530,13 +1718,22 @@ ModuleExport void RegisterJPEGImage(void)
   MagickInfo
     *entry;
 
+  MagickBool
+    thread_support;
+
+#if defined(SETJMP_IS_THREAD_SAFE) && (SETJMP_IS_THREAD_SAFE)
+  thread_support=MagickTrue;  /* libjpeg is thread safe */
+#else
+  thread_support=MagickFalse; /* libjpeg is not thread safe */
+#endif
+
   version[0]='\0';
 #if defined(HasJPEG)
   FormatString(version,"IJG JPEG %d",JPEG_LIB_VERSION);
 #endif
 
   entry=SetMagickInfo("JPEG");
-  entry->thread_support=False; /* libjpeg is not thread safe */
+  entry->thread_support=thread_support;
 #if defined(HasJPEG)
   entry->decoder=(DecoderHandler) ReadJPEGImage;
   entry->encoder=(EncoderHandler) WriteJPEGImage;
@@ -1551,7 +1748,7 @@ ModuleExport void RegisterJPEGImage(void)
   (void) RegisterMagickInfo(entry);
 
   entry=SetMagickInfo("JPG");
-  entry->thread_support=False; /* libjpeg is not thread safe */
+  entry->thread_support=thread_support;
 #if defined(HasJPEG)
   entry->decoder=(DecoderHandler) ReadJPEGImage;
   entry->encoder=(EncoderHandler) WriteJPEGImage;
@@ -1677,10 +1874,10 @@ static void WriteAPPNProfile(j_compress_ptr jpeg_info,
 {
   size_t
     j;
-  
+
   int
     marker_id;
-  
+
   marker_id=JPEG_APP0+(int) MagickAtoL(profile_name+3);
   for (j=0; j < profile_length; j+=65533L)
     jpeg_write_marker(jpeg_info,marker_id,
@@ -1761,7 +1958,7 @@ static void WriteIPTCProfile(j_compress_ptr jpeg_info,
   {
     size_t
       length;
-    
+
     unsigned char
       *profile;
 
@@ -1798,12 +1995,12 @@ static void WriteXMPProfile(j_compress_ptr jpeg_info,
   size_t
     count,
     index,
-       header_length,
-       total_length;
+        header_length,
+        total_length;
 
   unsigned int
-       marker_length,
-       remaining;
+        marker_length,
+        remaining;
 
   header_length=strlen(xmp_std_header)+1; /* Include terminating null */
   total_length=header_length+profile_length;
@@ -1849,7 +2046,7 @@ static void WriteProfiles(j_compress_ptr jpeg_info,Image *image)
 
   ImageProfileIterator
     profile_iterator;
-    
+
   size_t
     profile_length=0;
 
@@ -1892,7 +2089,7 @@ static void WriteProfiles(j_compress_ptr jpeg_info,Image *image)
                                   (MAGICK_SIZE_T) profile_length);
           continue;
         }
-      
+
       if (image->logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "Wrote Profile: %s, %"
@@ -1916,6 +2113,124 @@ static void JPEGDestinationManager(j_compress_ptr cinfo,Image * image)
   destination->image=image;
 }
 
+/*
+  Format a libjpeg warning or trace event while encoding.  Warnings
+  are converted to GraphicsMagick warning exceptions while traces are
+  optionally logged.
+
+  JPEG message codes range from 0 to JMSG_LASTMSGCODE
+*/
+static void JPEGEncodeMessageHandler(j_common_ptr jpeg_info,int msg_level)
+{
+  char
+    message[JMSG_LENGTH_MAX];
+
+  struct jpeg_error_mgr
+    *err;
+
+  ErrorManager
+    *error_manager;
+
+  Image
+    *image;
+
+  message[0]='\0';
+  err=jpeg_info->err;
+  error_manager=(ErrorManager *) jpeg_info->client_data;
+  image=error_manager->image;
+  /* msg_level is -1 for warnings, 0 and up for trace messages. */
+  if (msg_level < 0)
+    {
+      unsigned int strikes = 0;
+      /* A warning */
+      (err->format_message)(jpeg_info,message);
+
+      if ((err->msg_code >= 0) &&
+          ((size_t) err->msg_code < ArraySize(error_manager->warning_counts)))
+        {
+          error_manager->warning_counts[err->msg_code]++;
+          strikes=error_manager->warning_counts[err->msg_code];
+        }
+
+      if (image->logging)
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "[%s] JPEG Warning[%u]: \"%s\""
+                                " (code=%d "
+                                "parms=0x%02x,0x%02x,"
+                                "0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)",
+                                image->filename,
+                                strikes,
+                                message,err->msg_code,
+                                err->msg_parm.i[0], err->msg_parm.i[1],
+                                err->msg_parm.i[2], err->msg_parm.i[3],
+                                err->msg_parm.i[4], err->msg_parm.i[5],
+                                err->msg_parm.i[6], err->msg_parm.i[7]);
+        }
+      /*
+      if (strikes > error_manager->max_warning_count)
+        {
+          ThrowException2(&image->exception,CorruptImageError,(char *) message,
+                          image->filename);
+          longjmp(error_manager->error_recovery,1);
+        }
+
+      if ((err->num_warnings == 0) ||
+          (err->trace_level >= 3))
+        ThrowException2(&image->exception,CorruptImageWarning,message,
+                        image->filename);
+      */
+      /* JWRN_JPEG_EOF - "Premature end of JPEG file" */
+      err->num_warnings++;
+      return /* False */;
+    }
+  else
+    {
+      /* A trace message */
+      if ((image->logging) && (msg_level >= err->trace_level))
+        {
+          (err->format_message)(jpeg_info,message);
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "[%s] JPEG Trace: \"%s\"",image->filename,
+                                message);
+        }
+    }
+  return /* True */;
+}
+
+
+static void JPEGEncodeProgressMonitor(j_common_ptr cinfo)
+{
+#if USE_LIBJPEG_PROGRESS
+  struct jpeg_progress_mgr *p = cinfo->progress;
+  ErrorManager *error_manager = (ErrorManager *) cinfo->client_data;
+  Image *image = error_manager->image;
+
+#if 0
+  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                        "Progress: pass_counter=%ld, pass_limit=%ld,"
+                        " completed_passes=%d, total_passes=%d, filename=%s",
+                        p->pass_counter, p->pass_limit,
+                        p->completed_passes, p->total_passes, image->filename);
+#endif
+
+  if (QuantumTick(p->pass_counter,p->pass_limit))
+    if (!MagickMonitorFormatted(p->pass_counter,p->pass_limit,&image->exception,
+                                "[%s] Saving image: %lux%lu (pass %d of %d)...  ",
+                                image->filename,
+                                image->columns,image->rows,
+                                p->completed_passes+1, p->total_passes))
+      {
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Quitting due to progress monitor");
+        longjmp(error_manager->error_recovery,1);
+      }
+#else
+  (void) cinfo;
+#endif /* USE_LIBJPEG_PROGRESS */
+}
+
+
 static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
 {
   Image
@@ -1935,8 +2250,11 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
     scanline[1];
 
   char
-   *sampling_factors,
-   *preserve_settings;
+    *sampling_factors,
+    *preserve_settings;
+
+  const char
+    *value;
 
   long
     y;
@@ -1951,12 +2269,15 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
     i,
     x;
 
-  struct jpeg_compress_struct
-    jpeg_info;
-
   struct jpeg_error_mgr
     jpeg_error;
 
+  struct jpeg_progress_mgr
+    jpeg_progress;
+
+  struct jpeg_compress_struct
+    jpeg_info;
+
   MagickPassFail
     status;
 
@@ -1984,6 +2305,7 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
     ThrowWriterException(FileOpenError,UnableToOpenFile,imagev);
 
   (void) memset(&error_manager,0,sizeof(error_manager));
+  (void) memset(&jpeg_progress,0,sizeof(jpeg_progress));
   (void) memset(&jpeg_info,0,sizeof(jpeg_info));
   (void) memset(&jpeg_error,0,sizeof(jpeg_error));
 
@@ -1992,9 +2314,16 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
   */
   jpeg_info.client_data=(void *) imagev;
   jpeg_info.err=jpeg_std_error(&jpeg_error);
-  jpeg_info.err->emit_message=(void (*)(j_common_ptr,int)) JPEGMessageHandler;
+  jpeg_info.err->emit_message=/*(void (*)(j_common_ptr,int))*/ JPEGEncodeMessageHandler;
   jpeg_info.err->error_exit=(void (*)(j_common_ptr)) JPEGErrorHandler;
   error_manager.image=imagev;
+  error_manager.max_warning_count=MaxWarningCount;
+  /*
+    Allow the user to set how many warnings of any given type are
+    allowed before promotion of the warning to a hard error.
+  */
+  if ((value=AccessDefinition(image_info,"jpeg","max-warnings")))
+    error_manager.max_warning_count=strtol(value,(char **) NULL, 10);
   jpeg_info.client_data=(void *) &error_manager;
   if (setjmp(error_manager.error_recovery))
     {
@@ -2020,11 +2349,11 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
     desired colorspace.
   */
   else if (IsRGBCompatibleColorspace(image->colorspace) &&
-          !IsRGBColorspace(image->colorspace))
+           !IsRGBColorspace(image->colorspace))
     {
       (void) TransformColorspace(image,RGBColorspace);
     }
-  
+
   /*
     Analyze image to be written.
   */
@@ -2044,54 +2373,60 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
   jpeg_info.in_color_space=JCS_RGB;
 
   /*
+    Register our progress monitor
+  */
+  jpeg_progress.progress_monitor=(void (*)(j_common_ptr)) JPEGEncodeProgressMonitor;
+  jpeg_info.progress=&jpeg_progress;
+
+  /*
     Set JPEG colorspace as per user request.
   */
   {
     MagickBool
       colorspace_set=MagickFalse;
-    
+
     if (IsCMYKColorspace(image_info->colorspace))
       {
-       jpeg_info.input_components=4;
-       jpeg_info.in_color_space=JCS_CMYK;
-       colorspace_set=MagickTrue;
+        jpeg_info.input_components=4;
+        jpeg_info.in_color_space=JCS_CMYK;
+        colorspace_set=MagickTrue;
       }
     else if (IsYCbCrColorspace(image_info->colorspace))
       {
-       jpeg_info.input_components=3;
-       jpeg_info.in_color_space=JCS_YCbCr;
-       colorspace_set=MagickTrue;
+        jpeg_info.input_components=3;
+        jpeg_info.in_color_space=JCS_YCbCr;
+        colorspace_set=MagickTrue;
       }
     else if (IsGrayColorspace(image_info->colorspace))
       {
-       jpeg_info.input_components=1;
-       jpeg_info.in_color_space=JCS_GRAYSCALE;
-       colorspace_set=MagickTrue;
+        jpeg_info.input_components=1;
+        jpeg_info.in_color_space=JCS_GRAYSCALE;
+        colorspace_set=MagickTrue;
       }
 
     if (!colorspace_set)
       {
-       if (IsCMYKColorspace(image->colorspace))
-         {
-           jpeg_info.input_components=4;
-           jpeg_info.in_color_space=JCS_CMYK;
-         }
-       else if (IsYCbCrColorspace(image->colorspace))
-         {
-           jpeg_info.input_components=3;
-           jpeg_info.in_color_space=JCS_YCbCr;
-         }
-       else if ((IsGrayColorspace(image->colorspace) ||
-                 (characteristics.grayscale)))
-         {
-           jpeg_info.input_components=1;
-           jpeg_info.in_color_space=JCS_GRAYSCALE;
-         }
-       else
-         {
-           jpeg_info.input_components=3;
-           jpeg_info.in_color_space=JCS_RGB;
-         }
+        if (IsCMYKColorspace(image->colorspace))
+          {
+            jpeg_info.input_components=4;
+            jpeg_info.in_color_space=JCS_CMYK;
+          }
+        else if (IsYCbCrColorspace(image->colorspace))
+          {
+            jpeg_info.input_components=3;
+            jpeg_info.in_color_space=JCS_YCbCr;
+          }
+        else if ((IsGrayColorspace(image->colorspace) ||
+                  (characteristics.grayscale)))
+          {
+            jpeg_info.input_components=1;
+            jpeg_info.in_color_space=JCS_GRAYSCALE;
+          }
+        else
+          {
+            jpeg_info.input_components=3;
+            jpeg_info.in_color_space=JCS_RGB;
+          }
       }
   }
 
@@ -2165,7 +2500,7 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
   {
     int
       sample_size;
-    
+
     sample_size=sizeof(JSAMPLE)*8;
     if (sample_size > 8)
       sample_size=12;
@@ -2236,7 +2571,7 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
 {
   const char
     *value;
-  
+
   huffman_memory=0;
   if ((value=AccessDefinition(image_info,"jpeg","optimize-coding")))
     {
@@ -2273,10 +2608,10 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
    {
      if (image_info->interlace == LineInterlace)
        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                            "Interlace: progressive");
+                             "Interlace: progressive");
      else
        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                            "Interlace: nonprogressive");
+                             "Interlace: nonprogressive");
    }
 #else
   if (image->logging)
@@ -2327,7 +2662,7 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
   if (sampling_factors != (char *) NULL)
     {
       double
-        hs[4]={1.0, 1.0, 1.0, 1.0}, 
+        hs[4]={1.0, 1.0, 1.0, 1.0},
         vs[4]={1.0, 1.0, 1.0, 1.0};
 
       long
@@ -2386,87 +2721,87 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
         "JPEG data precision: %d",(int) jpeg_info.data_precision);
       if (IsCMYKColorspace(image_info->colorspace))
-       {
+        {
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Storage class: DirectClass");
+                                "Storage class: DirectClass");
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Colorspace: CMYK");
-       }
+                                "Colorspace: CMYK");
+        }
       else if (IsYCbCrColorspace(image_info->colorspace))
-       {
-         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Colorspace: YCbCr");
-       }
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Colorspace: YCbCr");
+        }
       if (IsCMYKColorspace(image->colorspace))
-       {
-         /* A CMYK space */
+        {
+          /* A CMYK space */
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Colorspace: CMYK");
+                                "Colorspace: CMYK");
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Sampling factors: %dx%d,%dx%d,%dx%d,%dx%d",
-                               jpeg_info.comp_info[0].h_samp_factor,
-                               jpeg_info.comp_info[0].v_samp_factor,
-                               jpeg_info.comp_info[1].h_samp_factor,
-                               jpeg_info.comp_info[1].v_samp_factor,
-                               jpeg_info.comp_info[2].h_samp_factor,
-                               jpeg_info.comp_info[2].v_samp_factor,
-                               jpeg_info.comp_info[3].h_samp_factor,
-                               jpeg_info.comp_info[3].v_samp_factor);
-       }
+                                "Sampling factors: %dx%d,%dx%d,%dx%d,%dx%d",
+                                jpeg_info.comp_info[0].h_samp_factor,
+                                jpeg_info.comp_info[0].v_samp_factor,
+                                jpeg_info.comp_info[1].h_samp_factor,
+                                jpeg_info.comp_info[1].v_samp_factor,
+                                jpeg_info.comp_info[2].h_samp_factor,
+                                jpeg_info.comp_info[2].v_samp_factor,
+                                jpeg_info.comp_info[3].h_samp_factor,
+                                jpeg_info.comp_info[3].v_samp_factor);
+        }
       else if (IsGrayColorspace(image->colorspace))
-       {
-         /* A gray space */
+        {
+          /* A gray space */
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Colorspace: GRAY");
+                                "Colorspace: GRAY");
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Sampling factors: %dx%d",
+                                "Sampling factors: %dx%d",
                                 jpeg_info.comp_info[0].h_samp_factor,
-                               jpeg_info.comp_info[0].v_samp_factor);
-       }
+                                jpeg_info.comp_info[0].v_samp_factor);
+        }
       else if (IsRGBCompatibleColorspace(image->colorspace))
-       {
-         /* An RGB space */
+        {
+          /* An RGB space */
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               " Image colorspace is RGB");
+                                " Image colorspace is RGB");
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Sampling factors: %dx%d,%dx%d,%dx%d",
-                               jpeg_info.comp_info[0].h_samp_factor,
-                               jpeg_info.comp_info[0].v_samp_factor,
-                               jpeg_info.comp_info[1].h_samp_factor,
-                               jpeg_info.comp_info[1].v_samp_factor,
-                               jpeg_info.comp_info[2].h_samp_factor,
-                               jpeg_info.comp_info[2].v_samp_factor);
-       }
+                                "Sampling factors: %dx%d,%dx%d,%dx%d",
+                                jpeg_info.comp_info[0].h_samp_factor,
+                                jpeg_info.comp_info[0].v_samp_factor,
+                                jpeg_info.comp_info[1].h_samp_factor,
+                                jpeg_info.comp_info[1].v_samp_factor,
+                                jpeg_info.comp_info[2].h_samp_factor,
+                                jpeg_info.comp_info[2].v_samp_factor);
+        }
       else if (IsYCbCrColorspace(image->colorspace))
-       {
-         /* A YCbCr space */
+        {
+          /* A YCbCr space */
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Colorspace: YCbCr");
+                                "Colorspace: YCbCr");
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Sampling factors: %dx%d,%dx%d,%dx%d",
-                               jpeg_info.comp_info[0].h_samp_factor,
-                               jpeg_info.comp_info[0].v_samp_factor,
-                               jpeg_info.comp_info[1].h_samp_factor,
-                               jpeg_info.comp_info[1].v_samp_factor,
-                               jpeg_info.comp_info[2].h_samp_factor,
-                               jpeg_info.comp_info[2].v_samp_factor);
-       }
+                                "Sampling factors: %dx%d,%dx%d,%dx%d",
+                                jpeg_info.comp_info[0].h_samp_factor,
+                                jpeg_info.comp_info[0].v_samp_factor,
+                                jpeg_info.comp_info[1].h_samp_factor,
+                                jpeg_info.comp_info[1].v_samp_factor,
+                                jpeg_info.comp_info[2].h_samp_factor,
+                                jpeg_info.comp_info[2].v_samp_factor);
+        }
       else
-       {
-         /* Some other color space */
+        {
+          /* Some other color space */
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Colorspace: %d",
-                               image->colorspace);
+                                image->colorspace);
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Sampling factors: %dx%d,%dx%d,%dx%d,%dx%d",
-                               jpeg_info.comp_info[0].h_samp_factor,
-                               jpeg_info.comp_info[0].v_samp_factor,
-                               jpeg_info.comp_info[1].h_samp_factor,
-                               jpeg_info.comp_info[1].v_samp_factor,
-                               jpeg_info.comp_info[2].h_samp_factor,
-                               jpeg_info.comp_info[2].v_samp_factor,
-                               jpeg_info.comp_info[3].h_samp_factor,
-                               jpeg_info.comp_info[3].v_samp_factor);
-       }
+                                "Sampling factors: %dx%d,%dx%d,%dx%d,%dx%d",
+                                jpeg_info.comp_info[0].h_samp_factor,
+                                jpeg_info.comp_info[0].v_samp_factor,
+                                jpeg_info.comp_info[1].h_samp_factor,
+                                jpeg_info.comp_info[1].v_samp_factor,
+                                jpeg_info.comp_info[2].h_samp_factor,
+                                jpeg_info.comp_info[2].v_samp_factor,
+                                jpeg_info.comp_info[3].h_samp_factor,
+                                jpeg_info.comp_info[3].v_samp_factor);
+        }
     }
   /*
     Write JPEG profiles.
@@ -2504,10 +2839,10 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
 
       if (jpeg_info.in_color_space == JCS_GRAYSCALE)
         {
-         if (image->logging)
-           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                 "Writing %d bit JCS_GRAYSCALE samples",
-                                 jpeg_info.data_precision);
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Writing %d bit JCS_GRAYSCALE samples",
+                                  jpeg_info.data_precision);
           for (y=0; y < (long) image->rows; y++)
             {
               p=AcquireImagePixels(image,0,y,image->columns,1,
@@ -2534,22 +2869,24 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
                     }
                 }
               (void) jpeg_write_scanlines(&jpeg_info,scanline,1);
+#if !USE_LIBJPEG_PROGRESS
               if (QuantumTick(y,image->rows))
                 if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                             SaveImageText,image->filename,
-                                           image->columns,image->rows))
+                                            image->columns,image->rows))
                   break;
+#endif /* !USE_LIBJPEG_PROGRESS */
             }
         }
       else
         if ((jpeg_info.in_color_space == JCS_RGB) ||
             (jpeg_info.in_color_space == JCS_YCbCr))
           {
-           if (image->logging)
-             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                   "Writing %d bit JCS_RGB or "
+            if (image->logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Writing %d bit JCS_RGB or "
                                     "JCS_YCbCr samples",
-                                   jpeg_info.data_precision);
+                                    jpeg_info.data_precision);
             for (y=0; y < (long) image->rows; y++)
               {
                 p=AcquireImagePixels(image,0,y,image->columns,1,
@@ -2565,19 +2902,21 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
                     p++;
                   }
                 (void) jpeg_write_scanlines(&jpeg_info,scanline,1);
+#if !USE_LIBJPEG_PROGRESS
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                               SaveImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
+#endif /* !USE_LIBJPEG_PROGRESS */
               }
           }
         else
           {
-           if (image->logging)
-             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                   "Writing %d bit JCS_CMYK samples",
-                                   jpeg_info.data_precision);
+            if (image->logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Writing %d bit JCS_CMYK samples",
+                                    jpeg_info.data_precision);
             for (y=0; y < (long) image->rows; y++)
               {
                 p=AcquireImagePixels(image,0,y,image->columns,1,
@@ -2597,21 +2936,23 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
                     p++;
                   }
                 (void) jpeg_write_scanlines(&jpeg_info,scanline,1);
+#if !USE_LIBJPEG_PROGRESS
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                               SaveImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
+#endif /* !USE_LIBJPEG_PROGRESS */
               }
           }
     }
   else
     if (jpeg_info.in_color_space == JCS_GRAYSCALE)
       {
-       if (image->logging)
-         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Writing %d bit JCS_GRAYSCALE samples",
-                               jpeg_info.data_precision);
+        if (image->logging)
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Writing %d bit JCS_GRAYSCALE samples",
+                                jpeg_info.data_precision);
         for (y=0; y < (long) image->rows; y++)
           {
             p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
@@ -2636,21 +2977,23 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
                   }
               }
             (void) jpeg_write_scanlines(&jpeg_info,scanline,1);
+#if !USE_LIBJPEG_PROGRESS
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                           SaveImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
+#endif /* !USE_LIBJPEG_PROGRESS */
           }
       }
     else
       if ((jpeg_info.in_color_space == JCS_RGB) ||
           (jpeg_info.in_color_space == JCS_YCbCr))
         {
-         if (image->logging)
-           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                 "Writing %d bit JCS_RGB or JCS_YCbCr samples",
-                                 jpeg_info.data_precision);
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Writing %d bit JCS_RGB or JCS_YCbCr samples",
+                                  jpeg_info.data_precision);
           for (y=0; y < (long) image->rows; y++)
             {
               p=AcquireImagePixels(image,0,y,image->columns,1,
@@ -2666,19 +3009,21 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
                   p++;
                 }
               (void) jpeg_write_scanlines(&jpeg_info,scanline,1);
+#if !USE_LIBJPEG_PROGRESS
               if (QuantumTick(y,image->rows))
                 if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                             SaveImageText,image->filename,
-                                           image->columns,image->rows))
+                                            image->columns,image->rows))
                   break;
+#endif /* !USE_LIBJPEG_PROGRESS */
             }
         }
       else
         {
-         if (image->logging)
-           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                 "Writing %d bit JCS_CMYK samples",
-                                 jpeg_info.data_precision);
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Writing %d bit JCS_CMYK samples",
+                                  jpeg_info.data_precision);
           for (y=0; y < (long) image->rows; y++)
             {
               p=AcquireImagePixels(image,0,y,image->columns,1,
@@ -2698,11 +3043,13 @@ static MagickPassFail WriteJPEGImage(const ImageInfo *image_info,Image *imagep)
                   p++;
                 }
               (void) jpeg_write_scanlines(&jpeg_info,scanline,1);
+#if !USE_LIBJPEG_PROGRESS
               if (QuantumTick(y,image->rows))
                 if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                             SaveImageText,image->filename,
-                                           image->columns,image->rows))
+                                            image->columns,image->rows))
                   break;
+#endif /* !USE_LIBJPEG_PROGRESS */
             }
         }
   if (image->logging)
index 210d284..420a00b 100644 (file)
@@ -705,7 +705,7 @@ static void output_switches(Image *image,struct locale_str *locstr, int indent,
         if (flag)
           {
             FormatString(message, "\n%*scase '%c':  case '%c':\n",
-                        indent, "", tolower((int) *xl->name), toupper((int) *xl->name));
+                         indent, "", tolower((int) *xl->name), toupper((int) *xl->name));
             (void) WriteBlobString(image,message);
           }
 
@@ -881,7 +881,7 @@ static unsigned int WriteLOCALEImage(const ImageInfo *image_info,Image *image)
       WriteBlobStringWithEOL(image,"#ifndef _LOCAL_C_H");
       WriteBlobStringWithEOL(image,"#define _LOCAL_C_H");
       WriteBlobStringEOL(image);
-      WriteBlobStringWithEOL(image,"extern MagickExport const char *GetLocaleMessageFromID(const int);");
+      WriteBlobStringWithEOL(image,"extern MagickExport const char *GetLocaleMessageFromID(const int) MAGICK_FUNC_CONST;");
       WriteBlobStringEOL(image);
       FormatString(text, "#define MAX_LOCALE_MSGS %d",count);
       WriteBlobStringWithEOL(image,text);
@@ -1114,4 +1114,3 @@ static unsigned int WriteLOCALEImage(const ImageInfo *image_info,Image *image)
   CloseBlob(image);
   return(True);
 }
-
index e24ffc6..251b3c7 100644 (file)
 static const unsigned char
   BricksImage[]=
   {
-    0x50, 0x34, 0x0A, 0x31, 0x36, 0x20, 0x31, 0x36, 0x0A, 0x00, 0x01, 0x00, 
-    0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0xFF, 
-    0xFF, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 
-    0x00, 0x01, 0x00, 0xFF, 0xFF, 
+    0x50, 0x34, 0x0A, 0x31, 0x36, 0x20, 0x31, 0x36, 0x0A, 0x00, 0x01, 0x00,
+    0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0xFF,
+    0xFF, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01,
+    0x00, 0x01, 0x00, 0xFF, 0xFF,
   };
 
 /*
@@ -73,10 +73,10 @@ static const unsigned char
 static const unsigned char
   CirclesImage[]=
   {
-    0x50, 0x34, 0x0A, 0x31, 0x36, 0x20, 0x31, 0x36, 0x0A, 0x07, 0xF0, 0x18, 
-    0x0C, 0x20, 0x02, 0x40, 0x01, 0x40, 0x01, 0x80, 0x00, 0x80, 0x00, 0x80, 
-    0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x40, 0x01, 0x40, 
-    0x01, 0x20, 0x02, 0x18, 0x0C, 
+    0x50, 0x34, 0x0A, 0x31, 0x36, 0x20, 0x31, 0x36, 0x0A, 0x07, 0xF0, 0x18,
+    0x0C, 0x20, 0x02, 0x40, 0x01, 0x40, 0x01, 0x80, 0x00, 0x80, 0x00, 0x80,
+    0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x40, 0x01, 0x40,
+    0x01, 0x20, 0x02, 0x18, 0x0C,
   };
 
 /*
@@ -87,7 +87,7 @@ static const unsigned char
 static const unsigned char
   CrossHatchImage[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x34, 0x0A, 0xFF, 0x11, 0x11, 0x11, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x34, 0x0A, 0xFF, 0x11, 0x11, 0x11,
   };
 
 /*
@@ -98,7 +98,7 @@ static const unsigned char
 static const unsigned char
   CrossHatch30Image[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x34, 0x0A, 0x81, 0x66, 0x18, 0x66, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x34, 0x0A, 0x81, 0x66, 0x18, 0x66,
   };
 
 /*
@@ -109,8 +109,8 @@ static const unsigned char
 static const unsigned char
   CrossHatch45Image[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x88, 0x50, 0x20, 0x50, 0x88, 
-    0x05, 0x02, 0x05, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x88, 0x50, 0x20, 0x50, 0x88,
+    0x05, 0x02, 0x05,
   };
 
 /*
@@ -121,9 +121,9 @@ static const unsigned char
 static const unsigned char
   FishScalesImage[]=
   {
-    0x50, 0x34, 0x0A, 0x31, 0x36, 0x20, 0x38, 0x0A, 0x02, 0x40, 0x0C, 0x30, 
-    0x70, 0x0E, 0x80, 0x01, 0x40, 0x02, 0x30, 0x0C, 0x0E, 0x70, 0x01, 0x80, 
-    
+    0x50, 0x34, 0x0A, 0x31, 0x36, 0x20, 0x38, 0x0A, 0x02, 0x40, 0x0C, 0x30,
+    0x70, 0x0E, 0x80, 0x01, 0x40, 0x02, 0x30, 0x0C, 0x0E, 0x70, 0x01, 0x80,
+
   };
 
 /*
@@ -732,18 +732,18 @@ static const unsigned char
 static const unsigned char
   Gray100Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00,
   };
 
 /*
@@ -754,18 +754,18 @@ static const unsigned char
 static const unsigned char
   Gray95Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 
-    0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 
-    0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 
-    0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x10, 0x10, 0x10, 0x10, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11,
+    0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10,
+    0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11,
+    0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x10, 0x10, 0x10, 0x10,
   };
 
 /*
@@ -776,18 +776,18 @@ static const unsigned char
 static const unsigned char
   Gray90Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x08, 0x08, 0x08, 
-    0x08, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 
-    0x00, 0x80, 0x88, 0x80, 0x88, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 
-    0x22, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 
-    0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 
-    0x80, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 
-    0x00, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 
-    0x22, 0x00, 0x00, 0x00, 0x00, 0x80, 0x88, 0x80, 0x88, 0x00, 0x00, 0x00, 
-    0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 
-    0x08, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 
-    0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 
-    0x22, 0x00, 0x00, 0x00, 0x00, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x08, 0x08, 0x08,
+    0x08, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00,
+    0x00, 0x80, 0x88, 0x80, 0x88, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22,
+    0x22, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00,
+    0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80,
+    0x80, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00,
+    0x00, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22,
+    0x22, 0x00, 0x00, 0x00, 0x00, 0x80, 0x88, 0x80, 0x88, 0x00, 0x00, 0x00,
+    0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08,
+    0x08, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00,
+    0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22,
+    0x22, 0x00, 0x00, 0x00, 0x00,
   };
 
 /*
@@ -798,18 +798,18 @@ static const unsigned char
 static const unsigned char
   Gray85Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x00, 0x00, 0x00, 
-    0x00, 0x88, 0x8A, 0x88, 0x8A, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 
-    0x22, 0x00, 0x00, 0x00, 0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0x00, 0x00, 0x00, 
-    0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x8A, 0x88, 0x8A, 
-    0x88, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 
-    0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 
-    0x22, 0x00, 0x00, 0x00, 0x00, 0x88, 0x8A, 0x88, 0x8A, 0x00, 0x00, 0x00, 
-    0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0xA8, 0xA8, 0xA8, 
-    0xA8, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 
-    0x00, 0x8A, 0x88, 0x8A, 0x88, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 
-    0x22, 0x00, 0x00, 0x00, 0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0x00, 0x00, 0x00, 
-    0x00, 0x22, 0x22, 0x22, 0x22, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x00, 0x00, 0x00,
+    0x00, 0x88, 0x8A, 0x88, 0x8A, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22,
+    0x22, 0x00, 0x00, 0x00, 0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0x00, 0x00, 0x00,
+    0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x8A, 0x88, 0x8A,
+    0x88, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00,
+    0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22,
+    0x22, 0x00, 0x00, 0x00, 0x00, 0x88, 0x8A, 0x88, 0x8A, 0x00, 0x00, 0x00,
+    0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0xA8, 0xA8, 0xA8,
+    0xA8, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22, 0x22, 0x00, 0x00, 0x00,
+    0x00, 0x8A, 0x88, 0x8A, 0x88, 0x00, 0x00, 0x00, 0x00, 0x22, 0x22, 0x22,
+    0x22, 0x00, 0x00, 0x00, 0x00, 0xA8, 0xA8, 0xA8, 0xA8, 0x00, 0x00, 0x00,
+    0x00, 0x22, 0x22, 0x22, 0x22,
   };
 
 /*
@@ -820,18 +820,18 @@ static const unsigned char
 static const unsigned char
   Gray80Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x00, 0x00, 0x00, 
-    0x00, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x51, 0x11, 0x51, 
-    0x11, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 
-    0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 
-    0x55, 0x00, 0x00, 0x00, 0x00, 0x51, 0x51, 0x51, 0x51, 0x00, 0x00, 0x00, 
-    0x00, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 
-    0x11, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 
-    0x00, 0x51, 0x11, 0x51, 0x11, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 
-    0x55, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 
-    0x00, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x51, 0x51, 0x51, 
-    0x51, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 
-    0x00, 0x11, 0x11, 0x11, 0x11, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x00, 0x00, 0x00,
+    0x00, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x51, 0x11, 0x51,
+    0x11, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00,
+    0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55,
+    0x55, 0x00, 0x00, 0x00, 0x00, 0x51, 0x51, 0x51, 0x51, 0x00, 0x00, 0x00,
+    0x00, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11,
+    0x11, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00,
+    0x00, 0x51, 0x11, 0x51, 0x11, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55,
+    0x55, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x00, 0x00, 0x00,
+    0x00, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00, 0x00, 0x51, 0x51, 0x51,
+    0x51, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x55, 0x00, 0x00, 0x00,
+    0x00, 0x11, 0x11, 0x11, 0x11,
   };
 
 /*
@@ -842,18 +842,18 @@ static const unsigned char
 static const unsigned char
   Gray75Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 
-    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 
-    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 
-    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 
-    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 
-    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x00, 0x00, 0x00, 0x00, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00,
+    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00,
+    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00,
+    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00,
+    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00,
+    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x00, 0x00, 0x00, 0x00,
   };
 
 /*
@@ -864,18 +864,18 @@ static const unsigned char
 static const unsigned char
   Gray70Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11, 
-    0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x01, 0x01, 0x01, 0x01, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 
-    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x01, 0x11, 
-    0x01, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 
-    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x01, 0x01, 0x01, 0x01, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11, 
-    0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x11, 0x01, 0x11, 0x01, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11,
+    0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x01, 0x01, 0x01, 0x01, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00,
+    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x01, 0x11,
+    0x01, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00,
+    0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x01, 0x01, 0x01, 0x01, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11,
+    0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x00, 0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x11, 0x01, 0x11, 0x01,
   };
 
 /*
@@ -886,18 +886,18 @@ static const unsigned char
 static const unsigned char
   Gray65Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x44, 0x44, 0x44, 
-    0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x01, 0x01, 0x01, 0x01, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x44, 0x44, 0x44, 0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x10, 0x11, 
-    0x10, 0xAA, 0xAA, 0xAA, 0xAA, 0x44, 0x44, 0x44, 0x44, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x01, 0x01, 0x01, 0x01, 0xAA, 0xAA, 0xAA, 0xAA, 0x44, 0x44, 0x44, 
-    0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x10, 0x10, 0x10, 0x10, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x44, 0x44, 0x44, 0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x01, 0x01, 0x01, 
-    0x01, 0xAA, 0xAA, 0xAA, 0xAA, 0x44, 0x44, 0x44, 0x44, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x11, 0x10, 0x11, 0x10, 0xAA, 0xAA, 0xAA, 0xAA, 0x44, 0x44, 0x44, 
-    0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x01, 0x01, 0x01, 0x01, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x44, 0x44, 0x44, 0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x10, 0x10, 0x10, 
-    0x10, 0xAA, 0xAA, 0xAA, 0xAA, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x44, 0x44, 0x44,
+    0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x01, 0x01, 0x01, 0x01, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x44, 0x44, 0x44, 0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x10, 0x11,
+    0x10, 0xAA, 0xAA, 0xAA, 0xAA, 0x44, 0x44, 0x44, 0x44, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x01, 0x01, 0x01, 0x01, 0xAA, 0xAA, 0xAA, 0xAA, 0x44, 0x44, 0x44,
+    0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x10, 0x10, 0x10, 0x10, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x44, 0x44, 0x44, 0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x01, 0x01, 0x01,
+    0x01, 0xAA, 0xAA, 0xAA, 0xAA, 0x44, 0x44, 0x44, 0x44, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x11, 0x10, 0x11, 0x10, 0xAA, 0xAA, 0xAA, 0xAA, 0x44, 0x44, 0x44,
+    0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x01, 0x01, 0x01, 0x01, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x44, 0x44, 0x44, 0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x10, 0x10, 0x10,
+    0x10, 0xAA, 0xAA, 0xAA, 0xAA,
   };
 
 /*
@@ -908,18 +908,18 @@ static const unsigned char
 static const unsigned char
   Gray60Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x11, 0x11, 0x11, 
-    0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x44, 0x45, 0x44, 0x45, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x54, 0x54, 0x54, 
-    0x54, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x45, 0x44, 0x45, 0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11, 
-    0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x54, 0x54, 0x54, 0x54, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x44, 0x45, 0x44, 
-    0x45, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x54, 0x54, 0x54, 0x54, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11, 
-    0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x45, 0x44, 0x45, 0x44, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x54, 0x54, 0x54, 
-    0x54, 0xAA, 0xAA, 0xAA, 0xAA, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x11, 0x11, 0x11,
+    0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x44, 0x45, 0x44, 0x45, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x54, 0x54, 0x54,
+    0x54, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x45, 0x44, 0x45, 0x44, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11,
+    0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x54, 0x54, 0x54, 0x54, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x44, 0x45, 0x44,
+    0x45, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x54, 0x54, 0x54, 0x54, 0xAA, 0xAA, 0xAA, 0xAA, 0x11, 0x11, 0x11,
+    0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x45, 0x44, 0x45, 0x44, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x11, 0x11, 0x11, 0x11, 0xAA, 0xAA, 0xAA, 0xAA, 0x54, 0x54, 0x54,
+    0x54, 0xAA, 0xAA, 0xAA, 0xAA,
   };
 
 /*
@@ -930,18 +930,18 @@ static const unsigned char
 static const unsigned char
   Gray55Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x55, 0x55, 0x55, 
-    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0x2A, 0x2A, 0x2A, 
-    0x2A, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 
-    0x55, 0x22, 0x22, 0x22, 0x22, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x55, 0x55, 0x55, 0x55, 0x22, 0x2A, 0x22, 0x2A, 0x55, 0x55, 0x55, 
-    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0x22, 0x22, 0x22, 
-    0x22, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 
-    0x55, 0x2A, 0x2A, 0x2A, 0x2A, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x55, 0x55, 0x55, 0x55, 0x22, 0x22, 0x22, 0x22, 0x55, 0x55, 0x55, 
-    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0x22, 0x2A, 0x22, 
-    0x2A, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 
-    0x55, 0x22, 0x22, 0x22, 0x22, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x55, 0x55, 0x55,
+    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0x2A, 0x2A, 0x2A,
+    0x2A, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55,
+    0x55, 0x22, 0x22, 0x22, 0x22, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x55, 0x55, 0x55, 0x55, 0x22, 0x2A, 0x22, 0x2A, 0x55, 0x55, 0x55,
+    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0x22, 0x22, 0x22,
+    0x22, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55,
+    0x55, 0x2A, 0x2A, 0x2A, 0x2A, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x55, 0x55, 0x55, 0x55, 0x22, 0x22, 0x22, 0x22, 0x55, 0x55, 0x55,
+    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0x22, 0x2A, 0x22,
+    0x2A, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55,
+    0x55, 0x22, 0x22, 0x22, 0x22,
   };
 
 /*
@@ -952,18 +952,18 @@ static const unsigned char
 static const unsigned char
   Gray50Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 
-    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 
-    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 
-    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 
-    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 
-    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x55, 0x55, 0x55, 0x55, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55,
+    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55,
+    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55,
+    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55,
+    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55,
+    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x55, 0x55, 0x55, 0x55,
   };
 
 /*
@@ -974,18 +974,18 @@ static const unsigned char
 static const unsigned char
   Gray45Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xBB, 0xBB, 0xBB, 
-    0xBB, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 
-    0x55, 0xAB, 0xAB, 0xAB, 0xAB, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x55, 0x55, 0x55, 0x55, 0xBB, 0xBB, 0xBB, 0xBB, 0x55, 0x55, 0x55, 
-    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xBB, 0xAB, 0xBB, 
-    0xAB, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 
-    0x55, 0xBB, 0xBB, 0xBB, 0xBB, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x55, 0x55, 0x55, 0x55, 0xAB, 0xAB, 0xAB, 0xAB, 0x55, 0x55, 0x55, 
-    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xBB, 0xBB, 0xBB, 
-    0xBB, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 
-    0x55, 0xBB, 0xAB, 0xBB, 0xAB, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x55, 0x55, 0x55, 0x55, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xBB, 0xBB, 0xBB,
+    0xBB, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55,
+    0x55, 0xAB, 0xAB, 0xAB, 0xAB, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x55, 0x55, 0x55, 0x55, 0xBB, 0xBB, 0xBB, 0xBB, 0x55, 0x55, 0x55,
+    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xBB, 0xAB, 0xBB,
+    0xAB, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55,
+    0x55, 0xBB, 0xBB, 0xBB, 0xBB, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x55, 0x55, 0x55, 0x55, 0xAB, 0xAB, 0xAB, 0xAB, 0x55, 0x55, 0x55,
+    0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55, 0xBB, 0xBB, 0xBB,
+    0xBB, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55,
+    0x55, 0xBB, 0xAB, 0xBB, 0xAB, 0x55, 0x55, 0x55, 0x55, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x55, 0x55, 0x55, 0x55,
   };
 
 /*
@@ -996,18 +996,18 @@ static const unsigned char
 static const unsigned char
   Gray40Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xEE, 0xEE, 0xEE, 
-    0xEE, 0x55, 0x55, 0x55, 0x55, 0xAB, 0xAB, 0xAB, 0xAB, 0x55, 0x55, 0x55, 
-    0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55, 0x55, 0xBB, 0xBA, 0xBB, 
-    0xBA, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55, 
-    0x55, 0xAB, 0xAB, 0xAB, 0xAB, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE, 
-    0xEE, 0x55, 0x55, 0x55, 0x55, 0xBA, 0xBB, 0xBA, 0xBB, 0x55, 0x55, 0x55, 
-    0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55, 0x55, 0xAB, 0xAB, 0xAB, 
-    0xAB, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55, 
-    0x55, 0xBB, 0xBA, 0xBB, 0xBA, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE, 
-    0xEE, 0x55, 0x55, 0x55, 0x55, 0xAB, 0xAB, 0xAB, 0xAB, 0x55, 0x55, 0x55, 
-    0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55, 0x55, 0xBA, 0xBB, 0xBA, 
-    0xBB, 0x55, 0x55, 0x55, 0x55, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xEE, 0xEE, 0xEE,
+    0xEE, 0x55, 0x55, 0x55, 0x55, 0xAB, 0xAB, 0xAB, 0xAB, 0x55, 0x55, 0x55,
+    0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55, 0x55, 0xBB, 0xBA, 0xBB,
+    0xBA, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55,
+    0x55, 0xAB, 0xAB, 0xAB, 0xAB, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE,
+    0xEE, 0x55, 0x55, 0x55, 0x55, 0xBA, 0xBB, 0xBA, 0xBB, 0x55, 0x55, 0x55,
+    0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55, 0x55, 0xAB, 0xAB, 0xAB,
+    0xAB, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55,
+    0x55, 0xBB, 0xBA, 0xBB, 0xBA, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE,
+    0xEE, 0x55, 0x55, 0x55, 0x55, 0xAB, 0xAB, 0xAB, 0xAB, 0x55, 0x55, 0x55,
+    0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55, 0x55, 0xBA, 0xBB, 0xBA,
+    0xBB, 0x55, 0x55, 0x55, 0x55,
   };
 
 /*
@@ -1018,18 +1018,18 @@ static const unsigned char
 static const unsigned char
   Gray35Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0xDD, 0xDD, 0xDD, 0xDD, 0xAA, 0xAA, 0xAA, 0xAA, 0x7F, 0x7F, 0x7F, 
-    0x7F, 0xAA, 0xAA, 0xAA, 0xAA, 0xDD, 0xDD, 0xDD, 0xDD, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x77, 0xF7, 0x77, 0xF7, 0xAA, 0xAA, 0xAA, 0xAA, 0xDD, 0xDD, 0xDD, 
-    0xDD, 0xAA, 0xAA, 0xAA, 0xAA, 0x7F, 0x7F, 0x7F, 0x7F, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0xDD, 0xDD, 0xDD, 0xDD, 0xAA, 0xAA, 0xAA, 0xAA, 0xF7, 0xF7, 0xF7, 
-    0xF7, 0xAA, 0xAA, 0xAA, 0xAA, 0xDD, 0xDD, 0xDD, 0xDD, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0x7F, 0x7F, 0x7F, 0x7F, 0xAA, 0xAA, 0xAA, 0xAA, 0xDD, 0xDD, 0xDD, 
-    0xDD, 0xAA, 0xAA, 0xAA, 0xAA, 0x77, 0xF7, 0x77, 0xF7, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0xDD, 0xDD, 0xDD, 0xDD, 0xAA, 0xAA, 0xAA, 0xAA, 0x7F, 0x7F, 0x7F, 
-    0x7F, 0xAA, 0xAA, 0xAA, 0xAA, 0xDD, 0xDD, 0xDD, 0xDD, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0xF7, 0xF7, 0xF7, 0xF7, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xAA, 0xAA, 0xAA,
+    0xAA, 0xDD, 0xDD, 0xDD, 0xDD, 0xAA, 0xAA, 0xAA, 0xAA, 0x7F, 0x7F, 0x7F,
+    0x7F, 0xAA, 0xAA, 0xAA, 0xAA, 0xDD, 0xDD, 0xDD, 0xDD, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x77, 0xF7, 0x77, 0xF7, 0xAA, 0xAA, 0xAA, 0xAA, 0xDD, 0xDD, 0xDD,
+    0xDD, 0xAA, 0xAA, 0xAA, 0xAA, 0x7F, 0x7F, 0x7F, 0x7F, 0xAA, 0xAA, 0xAA,
+    0xAA, 0xDD, 0xDD, 0xDD, 0xDD, 0xAA, 0xAA, 0xAA, 0xAA, 0xF7, 0xF7, 0xF7,
+    0xF7, 0xAA, 0xAA, 0xAA, 0xAA, 0xDD, 0xDD, 0xDD, 0xDD, 0xAA, 0xAA, 0xAA,
+    0xAA, 0x7F, 0x7F, 0x7F, 0x7F, 0xAA, 0xAA, 0xAA, 0xAA, 0xDD, 0xDD, 0xDD,
+    0xDD, 0xAA, 0xAA, 0xAA, 0xAA, 0x77, 0xF7, 0x77, 0xF7, 0xAA, 0xAA, 0xAA,
+    0xAA, 0xDD, 0xDD, 0xDD, 0xDD, 0xAA, 0xAA, 0xAA, 0xAA, 0x7F, 0x7F, 0x7F,
+    0x7F, 0xAA, 0xAA, 0xAA, 0xAA, 0xDD, 0xDD, 0xDD, 0xDD, 0xAA, 0xAA, 0xAA,
+    0xAA, 0xF7, 0xF7, 0xF7, 0xF7,
   };
 
 /*
@@ -1040,18 +1040,18 @@ static const unsigned char
 static const unsigned char
   Gray30Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55, 
-    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xFE, 0xEE, 
-    0xFE, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 
-    0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x55, 0x55, 0x55, 0x55, 0xFE, 0xFE, 0xFE, 0xFE, 0x55, 0x55, 0x55, 
-    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE, 
-    0xEE, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 
-    0x55, 0xEE, 0xFE, 0xEE, 0xFE, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55, 
-    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xFE, 0xFE, 0xFE, 
-    0xFE, 0x55, 0x55, 0x55, 0x55, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55,
+    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xFE, 0xEE,
+    0xFE, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55,
+    0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x55, 0x55, 0x55, 0x55, 0xFE, 0xFE, 0xFE, 0xFE, 0x55, 0x55, 0x55,
+    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE,
+    0xEE, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55,
+    0x55, 0xEE, 0xFE, 0xEE, 0xFE, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x55, 0x55, 0x55, 0x55, 0xEE, 0xEE, 0xEE, 0xEE, 0x55, 0x55, 0x55,
+    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xFE, 0xFE, 0xFE,
+    0xFE, 0x55, 0x55, 0x55, 0x55,
   };
 
 /*
@@ -1062,18 +1062,18 @@ static const unsigned char
 static const unsigned char
   Gray25Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 
-    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 
-    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 
-    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 
-    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 
-    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x55, 0x55, 0x55, 0x55, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55,
+    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55,
+    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55,
+    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55,
+    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55,
+    0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0x55, 0x55, 0x55, 0x55, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x55, 0x55, 0x55, 0x55,
   };
 
 /*
@@ -1084,18 +1084,18 @@ static const unsigned char
 static const unsigned char
   Gray20Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xBB, 0xBB, 0xBB, 0xBB, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xAA, 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xBA, 0xBB, 0xBA, 
-    0xBB, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xBB, 0xBB, 0xBB, 0xBB, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xBA, 0xBA, 0xBA, 0xBA, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xAA, 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xBB, 0xBB, 0xBB, 
-    0xBB, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xBA, 0xBB, 0xBA, 0xBB, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, 0xAA, 
-    0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xBB, 0xBB, 0xBB, 0xBB, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xAA, 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xBA, 0xBA, 0xBA, 
-    0xBA, 0xFF, 0xFF, 0xFF, 0xFF, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xAA, 0xAA, 0xAA,
+    0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xBB, 0xBB, 0xBB, 0xBB, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xAA, 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xBA, 0xBB, 0xBA,
+    0xBB, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xBB, 0xBB, 0xBB, 0xBB, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, 0xAA,
+    0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xBA, 0xBA, 0xBA, 0xBA, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xAA, 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xBB, 0xBB, 0xBB,
+    0xBB, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xBA, 0xBB, 0xBA, 0xBB, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA, 0xAA,
+    0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xBB, 0xBB, 0xBB, 0xBB, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xAA, 0xAA, 0xAA, 0xAA, 0xFF, 0xFF, 0xFF, 0xFF, 0xBA, 0xBA, 0xBA,
+    0xBA, 0xFF, 0xFF, 0xFF, 0xFF,
   };
 
 /*
@@ -1106,18 +1106,18 @@ static const unsigned char
 static const unsigned char
   Gray15Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x77, 0x77, 0x77, 
-    0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0x5D, 0x5D, 0x5D, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xD5, 0xDD, 0xD5, 
-    0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xDD, 0x5D, 0x5D, 0x5D, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 
-    0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0xD5, 0xDD, 0xD5, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0x5D, 0x5D, 
-    0x5D, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xD5, 0xDD, 0xD5, 0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 
-    0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0x5D, 0x5D, 0x5D, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0xD5, 0xDD, 
-    0xD5, 0xFF, 0xFF, 0xFF, 0xFF, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0x77, 0x77, 0x77,
+    0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0x5D, 0x5D, 0x5D, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xD5, 0xDD, 0xD5,
+    0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xDD, 0x5D, 0x5D, 0x5D, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77,
+    0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0xD5, 0xDD, 0xD5, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0x5D, 0x5D,
+    0x5D, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xD5, 0xDD, 0xD5, 0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77,
+    0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0x5D, 0x5D, 0x5D, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0xD5, 0xDD,
+    0xD5, 0xFF, 0xFF, 0xFF, 0xFF,
   };
 
 /*
@@ -1128,18 +1128,18 @@ static const unsigned char
 static const unsigned char
   Gray10Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xDF, 0xDF, 
-    0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFD, 0xDD, 0xFD, 0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 
-    0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xDF, 0xDF, 0xDF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0xFD, 0xFD, 
-    0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xDF, 0xDF, 0xDF, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 
-    0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0xDD, 0xFD, 0xDD, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xDF, 0xDF, 
-    0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFD, 0xFD, 0xFD, 0xFD, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xDF, 0xDF,
+    0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFD, 0xDD, 0xFD, 0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77,
+    0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xDF, 0xDF, 0xDF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0xFD, 0xFD,
+    0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xDF, 0xDF, 0xDF, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77,
+    0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xFD, 0xDD, 0xFD, 0xDD, 0xFF, 0xFF, 0xFF,
+    0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xDF, 0xDF,
+    0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0x77, 0x77, 0x77, 0x77, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFD, 0xFD, 0xFD, 0xFD,
   };
 
 /*
@@ -1150,18 +1150,18 @@ static const unsigned char
 static const unsigned char
   Gray5Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0xDD, 0xDD, 
-    0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xDF, 0xDF, 0xDF, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0xDD, 0xDD, 0xDD, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xDF, 0xDF, 
-    0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xDD, 0xDD, 0xDD, 0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xDF, 0xDF, 0xDF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0xDD, 0xDD, 
-    0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xDF, 0xDF, 0xDF, 0xDF, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0xDD, 0xDD,
+    0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xDF, 0xDF, 0xDF, 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0xDD, 0xDD, 0xDD, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xDF, 0xDF,
+    0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xDD, 0xDD, 0xDD, 0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDF, 0xDF, 0xDF, 0xDF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDD, 0xDD, 0xDD,
+    0xDD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xDF, 0xDF, 0xDF, 0xDF,
   };
 
 /*
@@ -1172,18 +1172,18 @@ static const unsigned char
 static const unsigned char
   Gray0Image[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
-    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 
+    0x50, 0x34, 0x0A, 0x33, 0x32, 0x20, 0x33, 0x32, 0x0A, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+    0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
   };
 
 /*
@@ -1194,13 +1194,13 @@ static const unsigned char
 static const unsigned char
   HexagonsImage[]=
   {
-    0x50, 0x34, 0x0A, 0x33, 0x30, 0x20, 0x31, 0x38, 0x0A, 0x10, 0x01, 0x00, 
-    0x00, 0x10, 0x01, 0x00, 0x00, 0x20, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 
-    0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x80, 0x00, 0x20, 
-    0x00, 0x80, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1F, 0xFC, 0x80, 0x00, 0x20, 
-    0x00, 0x80, 0x00, 0x20, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 
-    0x00, 0x20, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, 0x10, 0x01, 0x00, 
-    0x00, 0x10, 0x01, 0x00, 0x00, 0x0F, 0xFE, 0x00, 0x00, 
+    0x50, 0x34, 0x0A, 0x33, 0x30, 0x20, 0x31, 0x38, 0x0A, 0x10, 0x01, 0x00,
+    0x00, 0x10, 0x01, 0x00, 0x00, 0x20, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80,
+    0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x80, 0x00, 0x20,
+    0x00, 0x80, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1F, 0xFC, 0x80, 0x00, 0x20,
+    0x00, 0x80, 0x00, 0x20, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40,
+    0x00, 0x20, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, 0x10, 0x01, 0x00,
+    0x00, 0x10, 0x01, 0x00, 0x00, 0x0F, 0xFE, 0x00, 0x00,
   };
 
 /*
@@ -1211,7 +1211,7 @@ static const unsigned char
 static const unsigned char
   HorizontalImage[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x34, 0x0A, 0xFF, 0x00, 0x00, 0x00, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x34, 0x0A, 0xFF, 0x00, 0x00, 0x00,
   };
 
 /*
@@ -1222,9 +1222,9 @@ static const unsigned char
 static const unsigned char
   HorizontalSawImage[]=
   {
-    0x50, 0x34, 0x0A, 0x31, 0x36, 0x20, 0x38, 0x0A, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x10, 0x10, 0x28, 0x28, 0x44, 0x44, 0x82, 0x82, 0x01, 0x01, 
-    
+    0x50, 0x34, 0x0A, 0x31, 0x36, 0x20, 0x38, 0x0A, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x10, 0x10, 0x28, 0x28, 0x44, 0x44, 0x82, 0x82, 0x01, 0x01,
+
   };
 
 /*
@@ -1235,8 +1235,8 @@ static const unsigned char
 static const unsigned char
   HS_BDIAGONALImage[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x01, 0x02, 0x04, 0x08, 0x10, 
-    0x20, 0x40, 0x80, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x01, 0x02, 0x04, 0x08, 0x10,
+    0x20, 0x40, 0x80,
   };
 
 /*
@@ -1247,8 +1247,8 @@ static const unsigned char
 static const unsigned char
   HS_CROSSImage[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x10, 0x10, 0x10, 0xFF, 0x10, 
-    0x10, 0x10, 0x10, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x10, 0x10, 0x10, 0xFF, 0x10,
+    0x10, 0x10, 0x10,
   };
 
 /*
@@ -1259,8 +1259,8 @@ static const unsigned char
 static const unsigned char
   HS_DIAGCROSSImage[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x81, 0x42, 0x24, 0x18, 0x18, 
-    0x24, 0x42, 0x81, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x81, 0x42, 0x24, 0x18, 0x18,
+    0x24, 0x42, 0x81,
   };
 
 /*
@@ -1271,8 +1271,8 @@ static const unsigned char
 static const unsigned char
   HS_FDIAGONALImage[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x80, 0x40, 0x20, 0x10, 0x08, 
-    0x04, 0x02, 0x01, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x80, 0x40, 0x20, 0x10, 0x08,
+    0x04, 0x02, 0x01,
   };
 
 /*
@@ -1283,8 +1283,8 @@ static const unsigned char
 static const unsigned char
   HS_HORIZONTALImage[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x00, 0x00, 0x00, 0xFF, 0x00, 
-    0x00, 0x00, 0x00, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x00, 0x00, 0x00, 0xFF, 0x00,
+    0x00, 0x00, 0x00,
   };
 
 /*
@@ -1295,8 +1295,8 @@ static const unsigned char
 static const unsigned char
   HS_VERTICALImage[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x10, 0x10, 0x10, 0x10, 0x10, 
-    0x10, 0x10, 0x10, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x10, 0x10, 0x10, 0x10, 0x10,
+    0x10, 0x10, 0x10,
   };
 
 /*
@@ -1307,7 +1307,7 @@ static const unsigned char
 static const unsigned char
   Left30Image[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x34, 0x0A, 0xC0, 0x30, 0x0C, 0x03, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x34, 0x0A, 0xC0, 0x30, 0x0C, 0x03,
   };
 
 /*
@@ -1318,8 +1318,8 @@ static const unsigned char
 static const unsigned char
   Left45Image[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x80, 0x40, 0x20, 0x10, 0x08, 
-    0x04, 0x02, 0x01, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x80, 0x40, 0x20, 0x10, 0x08,
+    0x04, 0x02, 0x01,
   };
 
 /*
@@ -1330,13 +1330,13 @@ static const unsigned char
 static const unsigned char
   LeftShingleImage[]=
   {
-    0x50, 0x34, 0x0A, 0x32, 0x34, 0x20, 0x32, 0x34, 0x0A, 0x00, 0x00, 0x01, 
-    0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 
-    0x00, 0x00, 0x04, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 
-    0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 
-    0x04, 0x00, 0x00, 0x08, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x00, 
-    0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 
-    0x00, 0x04, 0x00, 0x00, 0x08, 0x00, 0xFF, 0xFF, 0xFF, 
+    0x50, 0x34, 0x0A, 0x32, 0x34, 0x20, 0x32, 0x34, 0x0A, 0x00, 0x00, 0x01,
+    0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04,
+    0x00, 0x00, 0x04, 0x00, 0x00, 0x08, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00,
+    0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00,
+    0x04, 0x00, 0x00, 0x08, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x01, 0x00,
+    0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00,
+    0x00, 0x04, 0x00, 0x00, 0x08, 0x00, 0xFF, 0xFF, 0xFF,
   };
 
 /*
@@ -1347,1846 +1347,1846 @@ static const unsigned char
 static const unsigned char
   LogoImage[]=
   {
-    0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x8E, 0x02, 0xA2, 0x01, 0xF6, 0x00, 
-    0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xB0, 0x4F, 0x00, 0x00, 0x00, 0x66, 0x99, 
-    0x00, 0x70, 0x9F, 0x10, 0xF6, 0xF9, 0xF0, 0x06, 0x09, 0x00, 0x00, 0x0B, 
-    0x04, 0x5F, 0x8F, 0x00, 0x00, 0xA5, 0x4A, 0x33, 0x4C, 0x00, 0x00, 0x58, 
-    0x27, 0x19, 0x26, 0x00, 0x8C, 0xB3, 0x40, 0x4C, 0x72, 0x00, 0x00, 0x84, 
-    0x3B, 0x00, 0x2C, 0x13, 0xD9, 0xE6, 0xC0, 0xB3, 0xCC, 0x80, 0xE3, 0xEC, 
-    0xD0, 0xA0, 0xBF, 0x60, 0xEC, 0xF3, 0xE0, 0xC6, 0xD9, 0xA0, 0x79, 0xA6, 
-    0x20, 0x83, 0xAC, 0x30, 0x59, 0x85, 0x00, 0x26, 0x39, 0x00, 0x0C, 0x13, 
-    0x00, 0x3F, 0x5F, 0x00, 0x00, 0x21, 0x0E, 0x52, 0x7C, 0x00, 0x00, 0x8F, 
-    0x40, 0x13, 0x1C, 0x00, 0xA9, 0xC6, 0x70, 0x00, 0x42, 0x1D, 0x00, 0x6E, 
-    0x31, 0x00, 0x9A, 0x45, 0xD0, 0xDF, 0xB0, 0x2C, 0x42, 0x00, 0x96, 0xB9, 
-    0x50, 0x00, 0x16, 0x09, 0xBC, 0xD3, 0x90, 0x46, 0x69, 0x00, 0x10, 0x10, 
-    0x10, 0x00, 0x37, 0x18, 0x39, 0x56, 0x00, 0x1F, 0x2F, 0x00, 0x00, 0x4D, 
-    0x22, 0x00, 0x79, 0x36, 0xF0, 0xF0, 0xF0, 0x80, 0x80, 0x80, 0x00, 0x63, 
-    0x2C, 0x40, 0x40, 0x40, 0xC0, 0xC0, 0xC0, 0xD0, 0xD0, 0xD0, 0x60, 0x60, 
-    0x60, 0x20, 0x20, 0x20, 0x30, 0x30, 0x30, 0xE0, 0xE0, 0xE0, 0xA0, 0xA0, 
-    0xA0, 0x50, 0x50, 0x50, 0xB0, 0xB0, 0xB0, 0x90, 0x90, 0x90, 0x70, 0x70, 
-    0x70, 0x7F, 0x7F, 0x7F, 0xEF, 0xEF, 0xEF, 0x3F, 0x3F, 0x3F, 0xBF, 0xBF, 
-    0xBF, 0x0F, 0x0F, 0x0F, 0x9F, 0x9F, 0x9F, 0x5F, 0x5F, 0x5F, 0xDF, 0xDF, 
-    0xDF, 0x8F, 0x8F, 0x8F, 0x00, 0x91, 0x42, 0xCF, 0xCF, 0xCF, 0x4F, 0x4F, 
-    0x4F, 0x2F, 0x2F, 0x2F, 0x1F, 0x1F, 0x1F, 0x6F, 0x6F, 0x6F, 0xAF, 0xAF, 
-    0xAF, 0x00, 0x48, 0x21, 0x00, 0x87, 0x3D, 0x00, 0x1B, 0x0C, 0x00, 0x09, 
-    0x04, 0x00, 0x75, 0x35, 0x00, 0x3F, 0x1C, 0x00, 0x51, 0x25, 0x00, 0x7E, 
-    0x39, 0x00, 0x24, 0x10, 0x00, 0x1F, 0x0E, 0x00, 0x2D, 0x14, 0x00, 0x6C, 
-    0x31, 0x00, 0x12, 0x08, 0x00, 0x36, 0x18, 0x00, 0x5A, 0x29, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-    0x00, 0x21, 0xF9, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 
-    0x00, 0x00, 0x8E, 0x02, 0xA2, 0x01, 0x00, 0x07, 0xFE, 0x80, 0x00, 0x82, 
-    0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 
-    0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 
-    0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 
-    0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 
-    0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 
-    0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 
-    0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 
-    0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 
-    0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 
-    0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 
-    0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x00, 0x03, 0x0A, 0x1C, 0x48, 0xB0, 0xA0, 
-    0xC1, 0x83, 0x08, 0x13, 0x2A, 0x5C, 0xC8, 0xB0, 0xA1, 0xC3, 0x87, 0x10, 
-    0x23, 0x4A, 0x9C, 0x48, 0xB1, 0xA2, 0xC5, 0x8B, 0x18, 0x33, 0x6A, 0xDC, 
-    0xC8, 0xB1, 0xA3, 0xC7, 0x8F, 0x20, 0x43, 0x8A, 0x1C, 0x49, 0xB2, 0xA4, 
-    0xC9, 0x93, 0x28, 0x53, 0xAA, 0x5C, 0xC9, 0xB2, 0xA5, 0xCB, 0x97, 0x30, 
-    0x63, 0xCA, 0x9C, 0x49, 0xB3, 0xA6, 0xCD, 0x9B, 0x38, 0x73, 0xEA, 0xDC, 
-    0xC9, 0xB3, 0xA7, 0xCF, 0x9F, 0x40, 0x57, 0x5A, 0x28, 0x10, 0xB4, 0xA8, 
-    0xD1, 0x62, 0x25, 0x06, 0x0C, 0xC0, 0x90, 0x62, 0xC2, 0xD1, 0xA7, 0x50, 
-    0x73, 0x85, 0x50, 0x4A, 0xF5, 0x02, 0x85, 0x12, 0x51, 0xB3, 0x6A, 0x6D, 
-    0x75, 0x81, 0xAA, 0x57, 0xA5, 0x27, 0x2C, 0x54, 0xD8, 0x4A, 0xB6, 0xEC, 
-    0xA7, 0x0A, 0x5F, 0xD3, 0x2A, 0xC5, 0x20, 0xC1, 0xA9, 0xD9, 0xB7, 0xFE, 
-    0x70, 0x25, 0xA5, 0xA0, 0x9A, 0xC1, 0x83, 0x5A, 0xAF, 0x56, 0xB1, 0xC6, 
-    0xDD, 0xCB, 0xD7, 0x50, 0x03, 0xAA, 0x2D, 0x04, 0x6C, 0xD0, 0xA0, 0xE2, 
-    0xAE, 0xD7, 0x13, 0x29, 0xC6, 0xF6, 0x5D, 0x6C, 0xB6, 0x80, 0x57, 0x10, 
-    0x02, 0x22, 0x47, 0x76, 0xC1, 0x21, 0x83, 0xE1, 0xB5, 0x21, 0xDC, 0x32, 
-    0xDE, 0x3C, 0xAB, 0x00, 0xD1, 0x87, 0x16, 0xA8, 0x22, 0x90, 0x4C, 0x3A, 
-    0x32, 0x08, 0x13, 0x76, 0x2F, 0x13, 0xA0, 0xA0, 0x98, 0xB3, 0xEB, 0x54, 
-    0x15, 0x2C, 0x9C, 0x18, 0x60, 0x01, 0x22, 0x05, 0xAA, 0x1C, 0x4A, 0xEB, 
-    0x16, 0x60, 0x80, 0x30, 0x02, 0xC3, 0x11, 0x5E, 0x0B, 0x27, 0x55, 0x21, 
-    0x05, 0x86, 0xC3, 0x10, 0x09, 0x50, 0x75, 0xB1, 0xBB, 0xB9, 0x00, 0x17, 
-    0x2D, 0x2C, 0x7F, 0xD5, 0x3C, 0xBC, 0xBA, 0xA6, 0x09, 0x21, 0xBA, 0xAA, 
-    0x7D, 0x18, 0xC1, 0xAB, 0x01, 0xE7, 0xE0, 0x4F, 0x7B, 0xB5, 0x4E, 0xFE, 
-    0x52, 0x09, 0x0A, 0xDA, 0x0D, 0xEB, 0x65, 0x38, 0x55, 0xA9, 0x03, 0xF0, 
-    0xF0, 0x05, 0x8C, 0x2F, 0x4F, 0xDF, 0x51, 0x01, 0x0B, 0x14, 0x94, 0x5F, 
-    0xA6, 0x4A, 0xC1, 0x61, 0x7A, 0x13, 0xF1, 0x39, 0xB7, 0xC1, 0x7C, 0x8D, 
-    0x9C, 0x10, 0xC2, 0x7A, 0xF5, 0x31, 0x56, 0xDC, 0x6C, 0x97, 0x65, 0xD0, 
-    0x02, 0x08, 0x1A, 0x50, 0x45, 0x40, 0x43, 0x68, 0x51, 0xB5, 0x41, 0x80, 
-    0xCD, 0x31, 0x50, 0x95, 0x23, 0xA1, 0x29, 0x45, 0x40, 0x58, 0x9F, 0x25, 
-    0xB8, 0xD7, 0x5F, 0x86, 0x79, 0x60, 0xC2, 0x85, 0x91, 0x19, 0xE0, 0x55, 
-    0x70, 0xDA, 0x44, 0x10, 0x81, 0x04, 0x30, 0xC6, 0x18, 0xA3, 0x05, 0x2E, 
-    0x86, 0xF8, 0xC9, 0x5C, 0x4A, 0x65, 0x80, 0x61, 0x86, 0x54, 0x35, 0xD0, 
-    0x48, 0x01, 0xE9, 0x79, 0xC5, 0x14, 0x75, 0x22, 0x92, 0x85, 0xE3, 0x57, 
-    0x2A, 0x68, 0xFE, 0xF0, 0x9D, 0x6E, 0x0E, 0x50, 0x15, 0xC2, 0x35, 0xD8, 
-    0x1D, 0xB7, 0xDF, 0x57, 0x0D, 0x50, 0x20, 0x56, 0x27, 0x0C, 0x0E, 0x10, 
-    0xD8, 0x8E, 0xBA, 0x69, 0xA8, 0x94, 0x8F, 0x8C, 0x48, 0xB0, 0xDF, 0x05, 
-    0x07, 0x16, 0x49, 0x56, 0x85, 0x4A, 0x71, 0xE0, 0xC2, 0x92, 0xCD, 0x99, 
-    0xB0, 0xE1, 0x34, 0x05, 0xA4, 0x10, 0xE4, 0x94, 0x77, 0x31, 0x65, 0x63, 
-    0x25, 0x8E, 0x51, 0xC5, 0x00, 0x97, 0xBA, 0xB9, 0xF9, 0x25, 0x23, 0x15, 
-    0xE8, 0x47, 0x67, 0x58, 0xAD, 0x99, 0x79, 0xD4, 0x7F, 0xF1, 0x0D, 0x48, 
-    0x15, 0x91, 0x67, 0x95, 0x20, 0x01, 0x05, 0x0D, 0x48, 0xE9, 0x15, 0x01, 
-    0x55, 0x36, 0xD5, 0x49, 0x09, 0x82, 0xD2, 0x39, 0x25, 0x01, 0x12, 0x60, 
-    0x92, 0x94, 0x52, 0xA3, 0xF1, 0x59, 0x9A, 0x02, 0x4E, 0x32, 0x72, 0x1B, 
-    0x55, 0x20, 0x50, 0xF6, 0xDB, 0x65, 0x6C, 0x31, 0x6A, 0x68, 0x4F, 0xED, 
-    0x0D, 0xE0, 0x41, 0x80, 0xA9, 0x0D, 0x90, 0x02, 0x28, 0x0B, 0x66, 0x4A, 
-    0x27, 0x99, 0x85, 0x52, 0x52, 0x40, 0x96, 0x5F, 0x21, 0xE0, 0x00, 0x07, 
-    0x0A, 0x14, 0x6B, 0x6C, 0xB1, 0x0E, 0x38, 0x50, 0xAB, 0x5A, 0x18, 0xB8, 
-    0xFA, 0xC8, 0xA9, 0x03, 0xE4, 0x26, 0x2A, 0x69, 0xA4, 0x2A, 0xD5, 0xA9, 
-    0x22, 0x13, 0x78, 0xB5, 0xA5, 0x69, 0x0A, 0x2C, 0xAB, 0x56, 0x5E, 0xAF, 
-    0xFE, 0x94, 0xAD, 0x85, 0xF1, 0x55, 0xBB, 0x54, 0x27, 0x71, 0x4A, 0xAA, 
-    0xA9, 0x5A, 0xAC, 0xE1, 0xA9, 0xAE, 0x52, 0x49, 0xA2, 0x18, 0xE0, 0x06, 
-    0xD0, 0x79, 0x3B, 0x00, 0x01, 0xB5, 0x51, 0x22, 0xA8, 0x06, 0xD3, 0x52, 
-    0x4B, 0xD5, 0xB5, 0x89, 0x90, 0x38, 0x00, 0x02, 0x6C, 0x92, 0x36, 0x58, 
-    0x61, 0xFB, 0x21, 0xD6, 0x6B, 0xB8, 0x36, 0xA5, 0xC7, 0x2F, 0x7C, 0x20, 
-    0x78, 0xB5, 0x30, 0x25, 0x15, 0xFE, 0x40, 0xBB, 0xEE, 0x7E, 0x00, 0x43, 
-    0x52, 0xC0, 0xBB, 0x1C, 0xC8, 0x3B, 0xED, 0x06, 0x1C, 0xA4, 0x95, 0x6F, 
-    0x24, 0xE3, 0x2A, 0x55, 0xF0, 0xB4, 0x4D, 0x5A, 0xAB, 0x48, 0x77, 0x54, 
-    0x01, 0x08, 0x1F, 0x65, 0xD2, 0x19, 0x76, 0x2B, 0xC3, 0x38, 0x41, 0xAB, 
-    0x42, 0x7C, 0x2E, 0x78, 0x35, 0xF3, 0x25, 0x62, 0x96, 0x48, 0xAC, 0x0B, 
-    0x0C, 0x78, 0x2C, 0x00, 0x03, 0x2E, 0x74, 0xCB, 0xEC, 0x9D, 0x8C, 0x08, 
-    0x3C, 0x40, 0x06, 0x7B, 0xF6, 0x5B, 0xDA, 0x06, 0x29, 0x2F, 0x2A, 0x49, 
-    0xAC, 0xEF, 0x81, 0xC7, 0x40, 0xD0, 0xE0, 0x45, 0xCD, 0x22, 0x22, 0xE9, 
-    0xE9, 0xB8, 0x23, 0x08, 0x46, 0xAB, 0xE5, 0x2C, 0xCD, 0x30, 0x7D, 0x6A, 
-    0xF2, 0x6E, 0xBD, 0xA9, 0xB0, 0x2A, 0x55, 0x27, 0x5C, 0x32, 0xC1, 0xBB, 
-    0x39, 0xB6, 0xD0, 0x34, 0x86, 0x06, 0x98, 0x10, 0xB3, 0x87, 0x63, 0x1B, 
-    0x72, 0xA4, 0xAC, 0x27, 0x3B, 0x2D, 0x59, 0x0B, 0x78, 0x21, 0xBD, 0x88, 
-    0xA4, 0x2E, 0x3B, 0x97, 0x32, 0x02, 0x0F, 0x33, 0x49, 0xD5, 0xD6, 0x7A, 
-    0x7B, 0xC5, 0x9C, 0xA8, 0x69, 0xAF, 0x7D, 0x01, 0xD9, 0x39, 0xED, 0x6B, 
-    0xB0, 0x09, 0x08, 0xDF, 0x25, 0xB8, 0x23, 0x11, 0xE8, 0x8A, 0xC0, 0x83, 
-    0x7E, 0x2B, 0xB0, 0xF6, 0xBD, 0x79, 0x0F, 0x52, 0x80, 0xA0, 0x1E, 0xF4, 
-    0xED, 0xB7, 0x64, 0xE6, 0x0E, 0xD0, 0xDF, 0x23, 0x68, 0x0E, 0x00, 0x99, 
-    0x73, 0x2A, 0x52, 0xA5, 0x40, 0x73, 0x31, 0x33, 0x4E, 0xC8, 0xE9, 0x54, 
-    0x55, 0xED, 0x74, 0xE6, 0xAF, 0x53, 0x6E, 0x13, 0xB4, 0xB9, 0x81, 0x6D, 
-    0xEF, 0x57, 0x76, 0x52, 0xD2, 0xA1, 0x57, 0x0A, 0xA8, 0x2E, 0x2A, 0x08, 
-    0xCB, 0x12, 0xB0, 0x39, 0x21, 0x3D, 0x2B, 0x35, 0x3B, 0x78, 0x06, 0x30, 
-    0xA0, 0x81, 0x02, 0x57, 0xEF, 0x98, 0xF9, 0x00, 0xFE, 0xA5, 0x13, 0x72, 
-    0xA4, 0xD7, 0xCE, 0x45, 0xB8, 0x5C, 0x73, 0x5E, 0x39, 0x5B, 0xFD, 0x00, 
-    0x73, 0xF7, 0xBB, 0x36, 0x82, 0xC2, 0xCF, 0xB4, 0x3C, 0x02, 0x77, 0xAB, 
-    0x05, 0xA2, 0x25, 0x13, 0x64, 0xEA, 0x81, 0xD0, 0xAB, 0x1B, 0xB0, 0x2C, 
-    0x06, 0x8C, 0x10, 0xD4, 0xED, 0xC2, 0x13, 0x35, 0xD1, 0x74, 0x2C, 0x3E, 
-    0x06, 0x58, 0x5B, 0xDB, 0x1C, 0x91, 0xA5, 0x6D, 0x35, 0x27, 0x64, 0x7A, 
-    0x42, 0x1F, 0x55, 0x10, 0x11, 0x3B, 0x69, 0x39, 0x2D, 0x67, 0x54, 0x99, 
-    0x5E, 0xFC, 0x5A, 0x92, 0x27, 0xD5, 0x5C, 0x85, 0x10, 0x11, 0x08, 0x01, 
-    0x00, 0x23, 0x11, 0x28, 0xAF, 0x58, 0x70, 0x75, 0xBA, 0x59, 0xD6, 0x93, 
-    0x12, 0x61, 0xB6, 0x01, 0x38, 0x6F, 0x32, 0xA3, 0x4B, 0xCB, 0x00, 0xC1, 
-    0x63, 0x3E, 0xA5, 0x4C, 0xEC, 0x10, 0x8E, 0x83, 0xCF, 0xE8, 0xDA, 0x47, 
-    0x1A, 0x02, 0x15, 0x22, 0x4B, 0x08, 0xE0, 0x1F, 0x9F, 0x00, 0x07, 0x96, 
-    0x0D, 0xDE, 0x04, 0x58, 0x78, 0x09, 0x01, 0xE3, 0xCE, 0x23, 0x28, 0xF8, 
-    0x31, 0x42, 0x5D, 0x27, 0x44, 0x61, 0x69, 0xFC, 0xB7, 0xA2, 0x44, 0xC4, 
-    0x2A, 0x8A, 0x53, 0x8C, 0xA1, 0x5A, 0xB0, 0xA8, 0x9B, 0x98, 0xAD, 0x70, 
-    0x11, 0x66, 0x0B, 0x95, 0x73, 0x22, 0xF6, 0x98, 0xDD, 0x90, 0x51, 0x29, 
-    0x87, 0x60, 0x99, 0x52, 0x66, 0xE8, 0xB4, 0x98, 0xED, 0xCC, 0x88, 0xF2, 
-    0x43, 0x5E, 0x5B, 0x4C, 0x27, 0x1B, 0x76, 0x41, 0x62, 0x7D, 0x5C, 0x94, 
-    0xA2, 0x64, 0x36, 0x20, 0xB9, 0x80, 0x51, 0x25, 0x71, 0xBB, 0x21, 0xA2, 
-    0x52, 0x2E, 0x70, 0x02, 0x48, 0xE9, 0x8A, 0x87, 0x7D, 0x7A, 0xD3, 0x22, 
-    0x6C, 0x06, 0x1F, 0x41, 0x2A, 0x85, 0x47, 0x6B, 0x39, 0x84, 0xC0, 0x08, 
-    0xB6, 0x3A, 0x45, 0xD9, 0x10, 0x8E, 0x35, 0xA9, 0x50, 0x03, 0x12, 0xFE, 
-    0x33, 0x88, 0xE2, 0x28, 0x2D, 0x2D, 0x13, 0x72, 0x44, 0xC9, 0xF8, 0xA6, 
-    0x47, 0xF0, 0xF8, 0x49, 0x29, 0x23, 0x2B, 0x84, 0xA0, 0xAE, 0xB7, 0x9B, 
-    0xA8, 0x05, 0x4F, 0x10, 0x29, 0x40, 0x5D, 0xF6, 0xAE, 0x56, 0xB4, 0x62, 
-    0xB5, 0x20, 0x59, 0xCB, 0x0A, 0x9F, 0xC3, 0xE0, 0xE3, 0x2D, 0x48, 0x0E, 
-    0x00, 0x4C, 0x84, 0x58, 0xDE, 0x00, 0x00, 0xD9, 0xAF, 0x53, 0x8E, 0x10, 
-    0x93, 0x34, 0x29, 0x41, 0x88, 0xA2, 0xA4, 0xA9, 0xF0, 0x09, 0x62, 0x92, 
-    0x42, 0x6C, 0xCE, 0x60, 0x14, 0x90, 0x2C, 0x62, 0xB1, 0x12, 0x3E, 0x51, 
-    0x9B, 0x1C, 0x0E, 0xA9, 0x82, 0xCD, 0xC5, 0x19, 0xA2, 0x85, 0x17, 0xFB, 
-    0x22, 0x22, 0x46, 0xF9, 0x42, 0xC1, 0xA4, 0xC5, 0x97, 0xC0, 0x1C, 0x44, 
-    0x7A, 0x66, 0x85, 0xC2, 0xA8, 0x89, 0x13, 0x99, 0x33, 0x29, 0x41, 0x76, 
-    0x2E, 0x83, 0x80, 0x24, 0xD5, 0xEA, 0x9D, 0x88, 0x50, 0xE3, 0x00, 0x0A, 
-    0x07, 0x1F, 0x06, 0x14, 0xD0, 0x2B, 0x0E, 0x40, 0xE4, 0x6E, 0xBC, 0x84, 
-    0xCA, 0x6D, 0x3E, 0x32, 0x6B, 0x3D, 0x5A, 0x18, 0xDC, 0xE8, 0x74, 0x4C, 
-    0x44, 0x54, 0x8F, 0x9D, 0xCE, 0x39, 0x65, 0x8E, 0x9A, 0x63, 0xAE, 0x74, 
-    0x02, 0x60, 0x7D, 0x02, 0xE5, 0x53, 0xED, 0x94, 0xE2, 0x4C, 0x78, 0xDE, 
-    0x23, 0x84, 0xAE, 0x28, 0xA1, 0x61, 0x10, 0xA0, 0x26, 0xC9, 0x9C, 0x52, 
-    0x9B, 0x8B, 0x10, 0x18, 0xF9, 0x1A, 0x39, 0x25, 0x62, 0x5E, 0xEE, 0x9F, 
-    0x28, 0x25, 0x84, 0x57, 0xE0, 0xD3, 0xBA, 0xA5, 0x28, 0xF1, 0x33, 0xEB, 
-    0xBB, 0xD8, 0x0D, 0x05, 0x41, 0x38, 0xF8, 0x7C, 0x6F, 0x00, 0xBE, 0x1B, 
-    0xD5, 0xBF, 0x76, 0x27, 0xA8, 0xA0, 0x8E, 0x2A, 0x03, 0x26, 0x28, 0x67, 
-    0x64, 0x6A, 0x18, 0x4A, 0x8F, 0x02, 0x24, 0x02, 0x24, 0x4A, 0xA5, 0x2A, 
-    0xE6, 0x14, 0xFE, 0xB7, 0x6B, 0x9A, 0x93, 0x2A, 0x3B, 0x15, 0x44, 0xEC, 
-    0x5C, 0xBA, 0x1B, 0x08, 0xB6, 0xB4, 0x34, 0x20, 0x88, 0x0E, 0x70, 0x0C, 
-    0x31, 0x53, 0xEC, 0x69, 0x71, 0x2D, 0x27, 0x00, 0x16, 0x06, 0x1A, 0xC0, 
-    0xD6, 0x10, 0xC4, 0xA8, 0x04, 0x2E, 0x8A, 0x80, 0x06, 0x3B, 0x59, 0x46, 
-    0xDA, 0xA5, 0xC5, 0xA8, 0xAC, 0x1B, 0xEA, 0x20, 0x2C, 0x16, 0xCD, 0x04, 
-    0x82, 0x8A, 0xAB, 0xA4, 0xF1, 0xEA, 0x2B, 0x9D, 0xBA, 0x8F, 0x0A, 0x00, 
-    0x2B, 0xA6, 0xAA, 0x88, 0x15, 0x50, 0x4D, 0x60, 0x55, 0xD2, 0xD4, 0xEA, 
-    0x8D, 0x87, 0x18, 0x5F, 0x80, 0x1C, 0x39, 0x00, 0x32, 0x49, 0xC0, 0x51, 
-    0xEF, 0xDA, 0x80, 0x01, 0x54, 0x95, 0x30, 0xDD, 0x01, 0x60, 0x95, 0x10, 
-    0xAB, 0x1F, 0xB3, 0xAE, 0x32, 0xD7, 0x46, 0x2C, 0x6F, 0xA5, 0xBB, 0xC1, 
-    0x20, 0x40, 0x9B, 0x23, 0x48, 0x80, 0x55, 0xD0, 0x39, 0x5E, 0x1D, 0xC0, 
-    0xE3, 0x9C, 0xF3, 0x3E, 0xC2, 0xF2, 0xA3, 0x62, 0x6A, 0x91, 0x2A, 0x2A, 
-    0xC8, 0x19, 0x1F, 0x41, 0x36, 0xF4, 0x10, 0x92, 0x72, 0x60, 0x73, 0xCE, 
-    0x78, 0x2F, 0xDD, 0xEE, 0x4D, 0xB4, 0x5F, 0x01, 0x17, 0x22, 0x04, 0xC6, 
-    0xCF, 0xF2, 0x1D, 0x8F, 0x59, 0x29, 0x28, 0x6D, 0x22, 0xB2, 0x94, 0x47, 
-    0xC9, 0xC4, 0x76, 0x8D, 0xCD, 0x89, 0xDA, 0xCE, 0x26, 0xE9, 0x3C, 0x4B, 
-    0x1E, 0xD4, 0x39, 0x04, 0x1D, 0x80, 0x74, 0x6D, 0xCB, 0x0E, 0xDC, 0xDE, 
-    0x05, 0xB1, 0xA9, 0xB0, 0x1C, 0xC4, 0x24, 0x96, 0x88, 0x0E, 0xCA, 0x2E, 
-    0x3E, 0x99, 0x23, 0x80, 0xFA, 0xA6, 0x84, 0x81, 0xCC, 0x84, 0x89, 0x2A, 
-    0x10, 0x4D, 0x14, 0xE6, 0x90, 0x9B, 0x16, 0x0A, 0x78, 0xB6, 0x11, 0x39, 
-    0x04, 0x8F, 0x16, 0xD9, 0x48, 0x1A, 0xAD, 0x09, 0x42, 0x9F, 0x04, 0x2E, 
-    0xB0, 0x57, 0x6E, 0x06, 0x1E, 0xFE, 0x41, 0x5A, 0x94, 0xBC, 0xF2, 0x30, 
-    0xEF, 0x65, 0x74, 0x7B, 0x0A, 0x46, 0xC6, 0x27, 0x66, 0x14, 0x3E, 0x30, 
-    0x5D, 0x12, 0xA5, 0x33, 0x45, 0x50, 0xF5, 0x4B, 0x9C, 0x14, 0xA5, 0x57, 
-    0x32, 0x8A, 0x3D, 0x06, 0x28, 0x40, 0x05, 0xFC, 0xFD, 0x52, 0x56, 0xBF, 
-    0x59, 0xD6, 0x31, 0xAA, 0x25, 0xC1, 0x91, 0x31, 0x30, 0x00, 0x24, 0x85, 
-    0x5A, 0xD2, 0x84, 0x77, 0x9F, 0xF0, 0x71, 0x23, 0x84, 0xE9, 0x21, 0x61, 
-    0xAF, 0x20, 0xA0, 0x79, 0x31, 0x43, 0xEF, 0x29, 0x5A, 0x38, 0x59, 0xB6, 
-    0x25, 0xA2, 0x7A, 0x0C, 0x36, 0xA5, 0x22, 0x11, 0xB1, 0xB7, 0xD5, 0x0C, 
-    0x65, 0x12, 0x92, 0xC2, 0x2B, 0x9F, 0xE8, 0x55, 0x19, 0xB5, 0xE0, 0xEB, 
-    0x59, 0x54, 0x49, 0x32, 0x45, 0xD5, 0xD2, 0x5C, 0xC9, 0xE4, 0x0E, 0x00, 
-    0xC2, 0x04, 0xAC, 0x00, 0xEA, 0x17, 0xCD, 0xC8, 0x78, 0x77, 0xC5, 0x3B, 
-    0x36, 0x47, 0x8F, 0x45, 0xD3, 0xBC, 0xA5, 0x7A, 0x25, 0xC3, 0xA5, 0x10, 
-    0xD4, 0x6C, 0x9D, 0xA3, 0x5A, 0xF1, 0x22, 0x22, 0x56, 0x30, 0x2E, 0x4D, 
-    0xE6, 0xF0, 0x59, 0x08, 0xC7, 0x90, 0xC9, 0x89, 0x91, 0x10, 0x66, 0x97, 
-    0xFB, 0x15, 0x56, 0xD1, 0x0E, 0x36, 0x11, 0xBB, 0x04, 0xCF, 0xF1, 0x32, 
-    0x2A, 0x31, 0xDE, 0xB9, 0xA7, 0x7C, 0x5F, 0xC9, 0xEF, 0x6E, 0x4E, 0x9A, 
-    0xE6, 0x77, 0xAC, 0x19, 0x54, 0x6D, 0x26, 0x4D, 0x90, 0x27, 0x51, 0x80, 
-    0x08, 0x58, 0x00, 0x46, 0x70, 0x9D, 0x04, 0x75, 0x03, 0xB4, 0xB6, 0x0C, 
-    0x0B, 0x4C, 0xCC, 0x92, 0x89, 0x1A, 0xA0, 0x0B, 0x81, 0xE6, 0x47, 0xA8, 
-    0x8B, 0xC4, 0xD3, 0xD2, 0x40, 0xFD, 0x0E, 0x6D, 0x88, 0x51, 0x96, 0xF9, 
-    0xAA, 0x1E, 0x8A, 0xE0, 0x6E, 0xC6, 0x83, 0xD1, 0xE6, 0xF8, 0x55, 0x5B, 
-    0x3E, 0x2D, 0x55, 0xA5, 0xD9, 0x61, 0x31, 0x36, 0xFE, 0xAB, 0xAE, 0x86, 
-    0xB4, 0x81, 0x9D, 0x04, 0x16, 0x3A, 0x80, 0xB0, 0x40, 0x62, 0x7E, 0x01, 
-    0x12, 0xEC, 0x72, 0x75, 0x0D, 0x9E, 0xF4, 0xED, 0xD6, 0xC7, 0xA8, 0x9E, 
-    0x56, 0x4D, 0x33, 0x16, 0x59, 0xFC, 0xC2, 0xA7, 0x86, 0x17, 0x10, 0x14, 
-    0xA3, 0xB1, 0x2A, 0x28, 0x2D, 0x0B, 0xF5, 0x2B, 0x8D, 0x95, 0xCC, 0x46, 
-    0x07, 0xF0, 0xDF, 0x61, 0x97, 0xE3, 0x93, 0x3F, 0x2E, 0xE7, 0xA6, 0x01, 
-    0x55, 0xEC, 0xF3, 0xAE, 0xDA, 0x10, 0xEE, 0x85, 0xB5, 0x9B, 0x3D, 0x34, 
-    0x6D, 0xA5, 0xE8, 0x5B, 0x3E, 0x13, 0x4C, 0xC5, 0xDE, 0xA2, 0xA5, 0x54, 
-    0x3E, 0x31, 0x60, 0x74, 0xED, 0xE6, 0xA9, 0xED, 0x82, 0xAD, 0x14, 0xC5, 
-    0xAA, 0x2E, 0xBC, 0x7C, 0x95, 0x66, 0x0C, 0xC5, 0xD8, 0x1C, 0xD5, 0x36, 
-    0xD5, 0xDD, 0xE9, 0xD0, 0xE7, 0xFE, 0xE2, 0x83, 0x6C, 0x38, 0x03, 0xA0, 
-    0x00, 0x8A, 0x1D, 0x94, 0x74, 0x1B, 0x88, 0x40, 0xAF, 0x00, 0x5A, 0x60, 
-    0xFF, 0xF6, 0x61, 0x85, 0x83, 0xC5, 0x81, 0x74, 0x4F, 0x0B, 0x04, 0x7D, 
-    0x44, 0x84, 0x7B, 0x5D, 0x1E, 0x19, 0x93, 0xB7, 0xB8, 0x34, 0x37, 0x5E, 
-    0xF8, 0x03, 0xD3, 0x52, 0xDD, 0xC8, 0x48, 0x1B, 0xE3, 0xEB, 0xE0, 0x6E, 
-    0x80, 0xE6, 0x7D, 0x88, 0x09, 0x7C, 0x18, 0xA8, 0xB8, 0x64, 0x56, 0xF8, 
-    0x24, 0x0B, 0x5F, 0xFE, 0x48, 0x92, 0xDA, 0xCE, 0x51, 0xF9, 0x29, 0x42, 
-    0x5E, 0x55, 0x29, 0x76, 0x1C, 0x11, 0xA7, 0x7D, 0x99, 0x84, 0xDC, 0xEB, 
-    0x4B, 0x1F, 0x3B, 0x2F, 0xE7, 0xB2, 0xD5, 0x21, 0x55, 0x3C, 0x0E, 0xF4, 
-    0x70, 0x20, 0x38, 0x40, 0xE1, 0xA5, 0xB0, 0x30, 0x41, 0xD5, 0xF2, 0x29, 
-    0x6A, 0xC0, 0x5B, 0xF2, 0x5D, 0x44, 0xEC, 0x68, 0xBE, 0xEF, 0xCA, 0x3E, 
-    0xDD, 0xDF, 0xF1, 0xB1, 0xF6, 0x2A, 0x30, 0x75, 0x97, 0x0C, 0xA8, 0xFE, 
-    0xA9, 0xE0, 0x08, 0x8D, 0xE4, 0x21, 0x46, 0x0D, 0x1E, 0xAF, 0x9E, 0x40, 
-    0x9F, 0x15, 0xE7, 0xB2, 0xE1, 0xD4, 0x52, 0x4E, 0xE2, 0x8E, 0xB7, 0xEC, 
-    0xDD, 0x10, 0x7A, 0x7C, 0xB2, 0x69, 0x88, 0xB5, 0x0F, 0x20, 0xD3, 0xCD, 
-    0xD1, 0xC0, 0xE8, 0x08, 0xB0, 0x62, 0x49, 0xE5, 0xD9, 0x60, 0x7A, 0x27, 
-    0xC4, 0xA9, 0x27, 0xEF, 0x4D, 0x56, 0x14, 0x40, 0x02, 0xBA, 0x8A, 0x74, 
-    0x0B, 0xD6, 0x24, 0xAA, 0xF0, 0xBA, 0x4A, 0xCE, 0x39, 0x1E, 0xBB, 0x1A, 
-    0xA5, 0x2C, 0x80, 0x9A, 0x2E, 0x8D, 0xCE, 0x6A, 0x31, 0xB7, 0x6E, 0x1C, 
-    0x0C, 0xF9, 0x75, 0x9C, 0x3D, 0x3E, 0x69, 0x27, 0x04, 0x38, 0x37, 0x9E, 
-    0xA8, 0xFF, 0x69, 0xF0, 0x48, 0x92, 0x6E, 0xCE, 0x3D, 0x0D, 0x81, 0x67, 
-    0xD2, 0x2B, 0x05, 0xB2, 0x89, 0x48, 0x81, 0x8C, 0xA6, 0x2F, 0x23, 0x48, 
-    0xB1, 0x95, 0xAD, 0xE1, 0xBB, 0x0F, 0xB3, 0x01, 0xCA, 0x58, 0x2E, 0x3D, 
-    0x96, 0xC5, 0x54, 0x69, 0xBC, 0xC4, 0x66, 0xBF, 0xE5, 0xAF, 0x90, 0x18, 
-    0xB9, 0x83, 0x76, 0x2C, 0x55, 0xA0, 0xDF, 0xFB, 0x77, 0x8B, 0x06, 0xF0, 
-    0x94, 0xD7, 0x6A, 0xA6, 0x7A, 0xAE, 0x1B, 0x2A, 0x3A, 0x3D, 0x11, 0xB6, 
-    0x8E, 0x0F, 0xA5, 0x0B, 0x51, 0x3D, 0xE1, 0xEE, 0xC6, 0x5C, 0x7C, 0x66, 
-    0x50, 0x17, 0xC3, 0x6E, 0xB0, 0x93, 0x02, 0x9F, 0xA4, 0x16, 0x48, 0x05, 
-    0x78, 0xA7, 0xF4, 0x60, 0xB1, 0xA2, 0x7B, 0xE7, 0x76, 0x2E, 0xCB, 0x43, 
-    0x7B, 0x35, 0x45, 0x7B, 0xB5, 0x77, 0x17, 0xB7, 0xE6, 0x5D, 0x1D, 0xD5, 
-    0x7E, 0xDC, 0xF0, 0x7B, 0xFD, 0xF4, 0x66, 0xCF, 0x64, 0x42, 0x90, 0x73, 
-    0x37, 0xF7, 0x06, 0x00, 0x88, 0x02, 0x1F, 0x67, 0x56, 0x08, 0x11, 0xC8, 
-    0x71, 0x54, 0xF1, 0x5B, 0x14, 0x34, 0x80, 0x58, 0x25, 0x09, 0x15, 0x10, 
-    0x02, 0x0D, 0xFE, 0x70, 0x74, 0xA0, 0x32, 0x67, 0xBE, 0x84, 0x5E, 0x25, 
-    0xE8, 0x1C, 0xB5, 0xD2, 0x29, 0xD5, 0x93, 0x47, 0xD7, 0x95, 0x6E, 0xBF, 
-    0x16, 0x69, 0xF0, 0xB1, 0x7F, 0x1A, 0x98, 0x0E, 0x40, 0x04, 0x7F, 0x1B, 
-    0xA2, 0x4F, 0x0E, 0x18, 0x20, 0x30, 0xB7, 0x75, 0x56, 0xD4, 0x3B, 0x43, 
-    0xB7, 0x7E, 0x85, 0xA0, 0x46, 0x14, 0x27, 0x4D, 0xEC, 0xB5, 0x08, 0xFA, 
-    0x74, 0x31, 0x5A, 0x15, 0x57, 0x8E, 0x12, 0x23, 0x27, 0x70, 0x7D, 0x73, 
-    0xD2, 0x1F, 0xB1, 0x81, 0x1E, 0x77, 0x91, 0x72, 0x01, 0x37, 0x08, 0xF9, 
-    0x67, 0x57, 0x52, 0x53, 0x3D, 0x79, 0x56, 0x40, 0xD5, 0xE5, 0x48, 0xE9, 
-    0xE1, 0x7F, 0x7A, 0x26, 0x6C, 0x45, 0x88, 0x0E, 0xB1, 0xF3, 0x79, 0x36, 
-    0xF6, 0x66, 0x92, 0x37, 0x2D, 0x12, 0x15, 0x80, 0x00, 0xA0, 0x4F, 0x05, 
-    0xE7, 0x5B, 0x64, 0x15, 0x7E, 0x17, 0x26, 0x85, 0x8B, 0x10, 0x2B, 0x1E, 
-    0x70, 0x2C, 0x8A, 0x58, 0x2C, 0x5E, 0x45, 0x00, 0x59, 0xB8, 0x2E, 0x88, 
-    0x35, 0x01, 0xC6, 0xF1, 0x15, 0x35, 0xA6, 0x1B, 0x2A, 0x87, 0x7C, 0xDF, 
-    0xF6, 0x26, 0x6C, 0x98, 0x5D, 0xA2, 0x11, 0x4D, 0xDE, 0x05, 0x2C, 0xB0, 
-    0xB6, 0x6E, 0x23, 0x58, 0x87, 0xE0, 0x00, 0x2D, 0x94, 0xE4, 0x7C, 0xF7, 
-    0xE2, 0x15, 0xD9, 0x86, 0x8A, 0x03, 0xB0, 0x53, 0xEA, 0x15, 0x1E, 0x5E, 
-    0x71, 0x27, 0xE9, 0x61, 0x83, 0x81, 0xB4, 0x64, 0x5C, 0xD3, 0x32, 0x99, 
-    0xF8, 0x27, 0x2E, 0x28, 0x35, 0x86, 0x60, 0x58, 0x23, 0x06, 0x1F, 0x2A, 
-    0x27, 0x30, 0x72, 0x48, 0x1A, 0xC0, 0xF3, 0x81, 0xD8, 0xB5, 0x1B, 0x84, 
-    0x71, 0x8C, 0xBB, 0x11, 0x5F, 0x47, 0x52, 0x85, 0xBA, 0x61, 0x71, 0x93, 
-    0x10, 0x1B, 0x30, 0x92, 0x56, 0x12, 0x90, 0x02, 0x09, 0x47, 0x8A, 0xC5, 
-    0x70, 0x87, 0x68, 0x87, 0x80, 0xFE, 0x28, 0xE4, 0x5D, 0x0F, 0xB6, 0x57, 
-    0x59, 0x16, 0x85, 0x05, 0x45, 0x08, 0x24, 0x67, 0x82, 0x5E, 0xC1, 0x6D, 
-    0x28, 0xE8, 0x15, 0xB7, 0x26, 0x00, 0x5E, 0xF5, 0x24, 0xA9, 0xA7, 0x29, 
-    0xB4, 0x66, 0x8C, 0x97, 0x07, 0x8C, 0x67, 0xF8, 0x71, 0x75, 0x45, 0x5B, 
-    0x54, 0xA1, 0x17, 0x28, 0x87, 0x3D, 0xAC, 0x37, 0x50, 0xE7, 0x48, 0x3C, 
-    0xF0, 0x61, 0x78, 0x90, 0x10, 0x83, 0x34, 0xD8, 0x6C, 0x4F, 0x86, 0x8D, 
-    0xC9, 0x60, 0x8A, 0x48, 0xF8, 0x15, 0x78, 0xB8, 0x23, 0xAD, 0xD3, 0x6E, 
-    0x44, 0x16, 0x1F, 0x02, 0x29, 0x3E, 0xDE, 0xC6, 0x8A, 0xCE, 0xE2, 0x68, 
-    0x40, 0x55, 0x88, 0x4A, 0x81, 0x15, 0x2A, 0xE5, 0x00, 0x2D, 0x60, 0x2C, 
-    0x26, 0x70, 0x35, 0xDD, 0x23, 0x00, 0xC8, 0xE6, 0x2C, 0x59, 0x82, 0x87, 
-    0x04, 0x15, 0x53, 0xD0, 0x06, 0x1E, 0x75, 0x36, 0x08, 0xFB, 0xD8, 0x2F, 
-    0xB5, 0x72, 0x01, 0x18, 0x99, 0x6D, 0x18, 0x66, 0x1F, 0xF5, 0x66, 0x18, 
-    0xAB, 0xD1, 0x6A, 0x08, 0xA9, 0x0B, 0xDA, 0x08, 0x7C, 0x69, 0xB1, 0x8E, 
-    0x74, 0xB3, 0x36, 0xDF, 0x28, 0x08, 0x01, 0xC6, 0x92, 0xB1, 0x48, 0x08, 
-    0x69, 0x08, 0x1E, 0xDE, 0x75, 0x65, 0x53, 0x18, 0x24, 0xFA, 0xE6, 0x78, 
-    0x17, 0x15, 0x8E, 0xF0, 0x11, 0x84, 0x8E, 0x58, 0x79, 0xBF, 0x18, 0x51, 
-    0x3D, 0x42, 0x08, 0x00, 0xD9, 0x60, 0x46, 0xA6, 0x70, 0x78, 0x17, 0x6B, 
-    0x6F, 0xC6, 0x5B, 0x2E, 0x96, 0x41, 0x8D, 0xC0, 0x77, 0x2E, 0xD8, 0x00, 
-    0xD7, 0xB8, 0x93, 0xBB, 0xA0, 0x90, 0x01, 0x52, 0x40, 0xC9, 0xE7, 0x34, 
-    0x0F, 0x89, 0x08, 0x84, 0x27, 0x76, 0x1B, 0x59, 0x08, 0x39, 0x08, 0x1E, 
-    0x35, 0xD5, 0x00, 0x34, 0x12, 0x01, 0x06, 0x88, 0x24, 0xBD, 0xB5, 0x82, 
-    0x1A, 0x46, 0x88, 0x43, 0x28, 0x47, 0xD5, 0xB8, 0xFE, 0x6C, 0x3E, 0xD6, 
-    0x4D, 0x2A, 0x33, 0x08, 0xB0, 0x07, 0x1E, 0x35, 0x49, 0x94, 0xA8, 0x32, 
-    0x2D, 0x06, 0x10, 0x33, 0x00, 0x44, 0x35, 0x34, 0x05, 0x98, 0xF7, 0x95, 
-    0x16, 0x1E, 0xF0, 0x91, 0xC6, 0xE2, 0x00, 0x67, 0xF5, 0x4B, 0x3A, 0xA9, 
-    0x96, 0xB4, 0xD0, 0x93, 0x1D, 0xA8, 0x73, 0x52, 0x14, 0x84, 0x43, 0xB9, 
-    0x92, 0x01, 0x79, 0x7F, 0x83, 0x10, 0x2B, 0x95, 0xD8, 0x55, 0x9A, 0x92, 
-    0x3A, 0x53, 0xB9, 0x36, 0x3B, 0x23, 0x28, 0xE9, 0x37, 0x87, 0x74, 0x42, 
-    0x8B, 0xA0, 0xC7, 0x8B, 0x7F, 0xE8, 0x1D, 0xB0, 0xF8, 0x82, 0x8E, 0xF9, 
-    0x5D, 0x7C, 0x12, 0x97, 0x3D, 0xA5, 0x68, 0x86, 0xA8, 0x08, 0xC5, 0xF6, 
-    0x63, 0xD1, 0xC4, 0x59, 0x69, 0x11, 0x02, 0x8F, 0x07, 0x9A, 0xB1, 0x60, 
-    0x8A, 0x40, 0x29, 0x00, 0x51, 0x23, 0x50, 0xB3, 0xF4, 0x6F, 0x0F, 0x48, 
-    0x80, 0xF8, 0x76, 0x8F, 0x90, 0xC6, 0x6F, 0x48, 0x79, 0x95, 0x7F, 0xB9, 
-    0x1F, 0x0E, 0x50, 0x70, 0xAD, 0x13, 0x22, 0xAC, 0x59, 0x70, 0x06, 0xF0, 
-    0x53, 0x6A, 0x91, 0x6D, 0x5E, 0x15, 0x53, 0x94, 0xA9, 0x64, 0x82, 0xF7, 
-    0x9B, 0x03, 0x00, 0x99, 0x0A, 0x04, 0x00, 0xB1, 0x73, 0x81, 0xA1, 0x87, 
-    0x08, 0xC5, 0xA6, 0x02, 0xE6, 0x69, 0x37, 0x69, 0x71, 0x01, 0xA3, 0xE8, 
-    0x9C, 0xB3, 0xF0, 0x5A, 0x3E, 0x09, 0x9C, 0x91, 0xC1, 0x00, 0x3F, 0xC5, 
-    0x01, 0x80, 0xC7, 0x1B, 0x42, 0xD9, 0x6F, 0x5A, 0x52, 0x72, 0xF9, 0x58, 
-    0x08, 0x02, 0xF3, 0x96, 0x19, 0xC2, 0x5F, 0x19, 0xB0, 0x8A, 0x0A, 0xAA, 
-    0x9A, 0xF4, 0xC9, 0x3C, 0x18, 0x22, 0x6B, 0x77, 0x11, 0x50, 0xE6, 0x58, 
-    0x9C, 0x24, 0x88, 0x8B, 0xC4, 0xD9, 0x70, 0x68, 0x78, 0x73, 0x3B, 0x12, 
-    0x5B, 0x63, 0xC1, 0x74, 0xDB, 0x69, 0x77, 0xC6, 0xF9, 0x15, 0x16, 0xFE, 
-    0x4A, 0x1A, 0x1C, 0xFA, 0x15, 0x27, 0xD0, 0x9C, 0x00, 0xCA, 0x0A, 0x11, 
-    0x47, 0x7A, 0x92, 0x46, 0x59, 0xA2, 0x41, 0x77, 0x79, 0x55, 0x7A, 0x85, 
-    0xA0, 0xA2, 0xE0, 0xB1, 0x67, 0x53, 0xE8, 0x15, 0xB5, 0x39, 0x50, 0xB7, 
-    0x94, 0x2C, 0x0E, 0xA0, 0x00, 0xB8, 0xC9, 0x5A, 0x57, 0x08, 0x8E, 0x8F, 
-    0x89, 0x21, 0xA7, 0xA1, 0x00, 0x1C, 0xA0, 0x02, 0x0A, 0xD0, 0x7D, 0xA8, 
-    0x28, 0x3D, 0x74, 0x45, 0x2E, 0x6A, 0xC8, 0x51, 0x83, 0xA0, 0x46, 0x12, 
-    0xDA, 0x9B, 0x24, 0x0A, 0x00, 0xE5, 0xE8, 0x1C, 0xC5, 0x98, 0x08, 0xC5, 
-    0x66, 0x9D, 0xFF, 0x17, 0x43, 0x04, 0xF0, 0x9F, 0x35, 0x1A, 0x52, 0x20, 
-    0xE8, 0x93, 0x0E, 0x74, 0x5D, 0xC1, 0xC2, 0xA3, 0x17, 0xFA, 0x27, 0xBD, 
-    0xA8, 0x9D, 0x6D, 0x62, 0x8B, 0x00, 0x30, 0x49, 0x74, 0x8A, 0x42, 0x75, 
-    0x76, 0x68, 0x22, 0x35, 0x30, 0x7D, 0xDA, 0x2F, 0xAD, 0x93, 0x31, 0x40, 
-    0x8A, 0x8C, 0x12, 0x02, 0x42, 0x50, 0xC8, 0x27, 0x51, 0x83, 0xA5, 0xF9, 
-    0x46, 0x8F, 0x75, 0xF9, 0x84, 0x5E, 0xE1, 0x01, 0x83, 0x3A, 0x45, 0xE8, 
-    0xC9, 0x9C, 0x6D, 0x8A, 0x0B, 0x37, 0x8A, 0x4D, 0xB3, 0x55, 0x67, 0x5F, 
-    0x12, 0x2C, 0x80, 0x87, 0x6C, 0xFF, 0x35, 0x9C, 0x4A, 0x79, 0x9F, 0x00, 
-    0x30, 0x4A, 0xB0, 0x59, 0x4A, 0x66, 0xB4, 0x36, 0x58, 0xDA, 0x38, 0x3B, 
-    0xAA, 0xAA, 0xA4, 0x21, 0x51, 0xBF, 0x25, 0x8C, 0xA9, 0xA9, 0x14, 0xAF, 
-    0x44, 0x7E, 0x5C, 0x12, 0x5E, 0xD7, 0x12, 0x46, 0x5A, 0x57, 0x8F, 0x58, 
-    0x97, 0x29, 0x08, 0xB0, 0xA4, 0x01, 0xE2, 0x02, 0xF5, 0xD3, 0x2C, 0x99, 
-    0x6A, 0x0B, 0x02, 0x0A, 0x31, 0x6C, 0x72, 0x37, 0x12, 0x40, 0x14, 0x05, 
-    0xA0, 0x34, 0x4B, 0xD8, 0x45, 0x59, 0x69, 0x08, 0x0F, 0x45, 0x2B, 0x74, 
-    0x38, 0x08, 0xFE, 0xEB, 0x43, 0x81, 0x52, 0xD4, 0x84, 0x0F, 0x8A, 0x9F, 
-    0x3E, 0x56, 0xA4, 0x90, 0x19, 0x5B, 0x71, 0x67, 0x3A, 0xDE, 0xD9, 0x1C, 
-    0xB5, 0x85, 0xAD, 0x8B, 0xBA, 0x23, 0x44, 0x67, 0x61, 0xB0, 0xD5, 0x95, 
-    0x8B, 0x60, 0x74, 0x0C, 0xE9, 0x34, 0x06, 0x70, 0x5D, 0x6B, 0x7A, 0xAC, 
-    0xB5, 0xB0, 0xA9, 0x4C, 0xE8, 0x81, 0x84, 0xF0, 0x6A, 0x01, 0x22, 0xAA, 
-    0xB5, 0xA6, 0x8E, 0xFA, 0x67, 0x99, 0x85, 0x00, 0x45, 0x09, 0xCA, 0x27, 
-    0xDC, 0x6A, 0xAB, 0x8A, 0xB0, 0x31, 0x5F, 0xE1, 0x00, 0xC2, 0xCA, 0x27, 
-    0xC4, 0xFA, 0x15, 0x52, 0xC5, 0xAB, 0x56, 0x73, 0x94, 0xE8, 0xAA, 0x8C, 
-    0xFD, 0x6A, 0x72, 0x8A, 0xF9, 0x47, 0xB1, 0x37, 0x8E, 0x8C, 0xA0, 0xB0, 
-    0x26, 0x54, 0xB0, 0xCF, 0x18, 0x43, 0xEC, 0x67, 0xAF, 0xAC, 0x90, 0xAC, 
-    0x01, 0x42, 0x84, 0x9D, 0x54, 0x54, 0x18, 0x12, 0x33, 0xDF, 0x78, 0x97, 
-    0xC3, 0xD5, 0xA4, 0xA6, 0xA3, 0x3F, 0x20, 0x1B, 0x20, 0x79, 0xD9, 0xB1, 
-    0x48, 0xB4, 0x34, 0x72, 0xE3, 0x34, 0x6F, 0x27, 0x32, 0x86, 0xB0, 0x95, 
-    0xCE, 0x21, 0x48, 0x0B, 0x54, 0xB1, 0xF3, 0x18, 0x94, 0xD3, 0x7A, 0xAA, 
-    0xBC, 0x39, 0x96, 0x97, 0x84, 0x65, 0x93, 0x1A, 0x9D, 0xD2, 0xE4, 0x2D, 
-    0xF1, 0x48, 0xB2, 0xAA, 0x80, 0xAF, 0x95, 0x89, 0xB0, 0xAE, 0xFA, 0x95, 
-    0xB9, 0xA8, 0x14, 0x9E, 0xD5, 0x80, 0xE2, 0x68, 0x2B, 0x45, 0x07, 0xAC, 
-    0x68, 0x0A, 0x7C, 0xDE, 0x82, 0x01, 0xE3, 0x95, 0x53, 0x00, 0xD5, 0x02, 
-    0x21, 0x49, 0x73, 0xD9, 0x83, 0x39, 0x5A, 0x54, 0x95, 0x86, 0xF0, 0x8A, 
-    0xB8, 0x03, 0xA2, 0x00, 0x00, 0x2D, 0x0D, 0xE9, 0x2F, 0x3E, 0x8A, 0x88, 
-    0x83, 0xF9, 0x9E, 0x8F, 0xB0, 0x76, 0x08, 0xD0, 0x3E, 0xD5, 0x19, 0x9D, 
-    0xD7, 0xF5, 0xB4, 0x50, 0x7B, 0xFE, 0x0A, 0x26, 0x3B, 0xB5, 0x03, 0x10, 
-    0x80, 0xE9, 0xA1, 0xAD, 0x9A, 0x56, 0xB4, 0x5D, 0x7A, 0xB4, 0x5C, 0x89, 
-    0xB7, 0x48, 0xA9, 0x2B, 0x07, 0xA4, 0xB3, 0xFF, 0xE4, 0x3A, 0x24, 0x73, 
-    0x80, 0x86, 0x81, 0xA4, 0xC9, 0x32, 0x25, 0x33, 0x5A, 0x74, 0x00, 0xA5, 
-    0x24, 0x56, 0xE8, 0x9B, 0x2E, 0xA9, 0xB1, 0xF3, 0xE2, 0x15, 0xAF, 0x44, 
-    0xAA, 0xCA, 0xA7, 0x57, 0x24, 0xA3, 0x2B, 0x00, 0x02, 0x32, 0x94, 0x88, 
-    0x79, 0x99, 0x07, 0xB1, 0x81, 0xFB, 0x0A, 0x52, 0xEB, 0x1C, 0x15, 0x85, 
-    0x75, 0xE5, 0xBA, 0xA2, 0xD8, 0x49, 0x08, 0x6E, 0xFB, 0xB2, 0x64, 0x59, 
-    0x74, 0x70, 0xD3, 0x76, 0x5F, 0xE3, 0x1B, 0x6A, 0x31, 0xB2, 0x8C, 0x10, 
-    0x01, 0x37, 0xBB, 0x8B, 0x3D, 0x92, 0x70, 0x54, 0x27, 0x2B, 0x56, 0x6A, 
-    0x52, 0x02, 0x1B, 0xBA, 0x56, 0x5B, 0xAB, 0x49, 0x9B, 0xA1, 0x4F, 0xEA, 
-    0x6B, 0xA6, 0xFA, 0x08, 0x1E, 0xDB, 0x3B, 0x23, 0xE5, 0xBA, 0xBA, 0x81, 
-    0x6C, 0xE0, 0x13, 0xBB, 0xAD, 0x30, 0xB8, 0xE0, 0x25, 0x75, 0xEA, 0x94, 
-    0xAE, 0x1B, 0xFB, 0x4B, 0x3D, 0x2B, 0x95, 0x74, 0x99, 0x6C, 0x32, 0x77, 
-    0xBC, 0x7E, 0xC7, 0x3D, 0x58, 0x23, 0x18, 0xB4, 0x24, 0xA5, 0x93, 0xEB, 
-    0x15, 0x0D, 0x90, 0x81, 0x32, 0x27, 0x1B, 0xEF, 0xA8, 0x29, 0xAB, 0x91, 
-    0x96, 0xDB, 0x87, 0xB3, 0x8F, 0xE3, 0x4E, 0x7E, 0x01, 0x75, 0xE3, 0x8B, 
-    0xBA, 0x60, 0xB6, 0x61, 0x34, 0xA4, 0xA7, 0x1A, 0x73, 0x93, 0x86, 0x91, 
-    0x01, 0x34, 0x87, 0x6C, 0x43, 0x09, 0xBE, 0xA5, 0xB0, 0x3E, 0xD1, 0x29, 
-    0x8A, 0xB6, 0x4B, 0xC0, 0xAF, 0x3B, 0x76, 0x85, 0x20, 0xB1, 0xD2, 0x1B, 
-    0xB4, 0xBF, 0x8A, 0xBC, 0xE7, 0x45, 0x76, 0x30, 0xE8, 0x28, 0x5F, 0xB8, 
-    0xBF, 0x2B, 0x78, 0x02, 0x12, 0x90, 0x96, 0x9D, 0xFE, 0x94, 0x02, 0xC7, 
-    0xEB, 0x63, 0xDF, 0xE3, 0x59, 0xE2, 0xD6, 0x96, 0x4E, 0x38, 0x08, 0x63, 
-    0xDA, 0x1C, 0x65, 0x9A, 0x4F, 0x12, 0x20, 0x83, 0x0D, 0xE0, 0x56, 0x16, 
-    0x40, 0x24, 0x03, 0xE7, 0x21, 0x91, 0x92, 0x9E, 0x78, 0xA9, 0xAF, 0x12, 
-    0x9C, 0x0A, 0x18, 0x49, 0x7F, 0xA9, 0xE6, 0xAE, 0x86, 0xD0, 0x35, 0x2B, 
-    0x6B, 0x8B, 0xEE, 0xD5, 0xB0, 0x93, 0x41, 0xBE, 0x7D, 0x86, 0x7A, 0x20, 
-    0xEC, 0x21, 0xFE, 0x75, 0x0A, 0x9D, 0x16, 0x57, 0x11, 0xF0, 0x99, 0x32, 
-    0xC7, 0x44, 0x9B, 0x22, 0x80, 0x05, 0x77, 0x75, 0x32, 0x75, 0x3E, 0x02, 
-    0xD6, 0xAD, 0xAC, 0x96, 0x1F, 0x38, 0x79, 0x3F, 0x7F, 0x98, 0x29, 0xCD, 
-    0xAA, 0x55, 0x54, 0x07, 0x6B, 0xB5, 0x12, 0xC1, 0x45, 0x2C, 0x0A, 0x14, 
-    0x7C, 0xB1, 0xA0, 0x9B, 0x8E, 0xA2, 0x7B, 0xB5, 0xEC, 0x4B, 0xC3, 0xB8, 
-    0x41, 0x6A, 0x66, 0x9C, 0xB0, 0x16, 0xF0, 0xBF, 0x75, 0x52, 0x26, 0xCB, 
-    0xC0, 0x4C, 0x77, 0x41, 0x6B, 0x26, 0xFA, 0xB6, 0x83, 0xB4, 0xC1, 0xA2, 
-    0xD1, 0xAB, 0x4A, 0x81, 0x34, 0x64, 0x7B, 0x19, 0x20, 0x52, 0x01, 0xC7, 
-    0x31, 0xAE, 0x84, 0x50, 0x01, 0x4A, 0xD3, 0x9A, 0x05, 0x0A, 0xB3, 0x73, 
-    0xFC, 0xAE, 0x5D, 0x08, 0x6A, 0xF8, 0x2B, 0x08, 0x47, 0x1C, 0x20, 0x41, 
-    0xF8, 0xB4, 0x4C, 0xBC, 0xB5, 0x88, 0x85, 0x9A, 0x41, 0x8A, 0xA1, 0x1D, 
-    0x4B, 0xC2, 0x33, 0x88, 0x17, 0x6C, 0x45, 0x01, 0x97, 0xA5, 0xC2, 0xC7, 
-    0x10, 0x1B, 0x37, 0xAB, 0x5B, 0x5C, 0x47, 0xB8, 0xB9, 0x2B, 0x08, 0xEC, 
-    0xCA, 0xA4, 0x45, 0xB4, 0x3B, 0x82, 0x6C, 0x18, 0x88, 0xD1, 0x2E, 0xDE, 
-    0x5A, 0xBD, 0xBB, 0xA1, 0x63, 0x9D, 0xBC, 0x32, 0x68, 0x7C, 0x17, 0x6A, 
-    0xDC, 0x08, 0x75, 0x2C, 0x91, 0x9C, 0x3C, 0x08, 0x61, 0x66, 0xC7, 0xFE, 
-    0x1C, 0x6B, 0x8F, 0xC6, 0x9C, 0xC1, 0xF7, 0x82, 0x0F, 0xE7, 0xA1, 0x1D, 
-    0x48, 0x43, 0x85, 0xB1, 0xA9, 0xB8, 0x82, 0x90, 0x68, 0xCE, 0x81, 0xCC, 
-    0x82, 0x00, 0xAF, 0x48, 0xA2, 0x00, 0x1A, 0xB0, 0x3D, 0xB7, 0x94, 0x30, 
-    0x07, 0x69, 0x08, 0x92, 0x82, 0x6A, 0xE6, 0xE2, 0xC1, 0xC9, 0x0C, 0x42, 
-    0x96, 0x7B, 0xC8, 0xB4, 0x3C, 0xCA, 0x1C, 0xC6, 0xCA, 0x84, 0x70, 0xCA, 
-    0x1A, 0xC9, 0xA2, 0x83, 0x10, 0x5C, 0xD8, 0xA3, 0x01, 0x05, 0x44, 0xCB, 
-    0xED, 0x30, 0x01, 0x14, 0xA6, 0x4F, 0x24, 0xD5, 0x8F, 0xA5, 0xE1, 0x48, 
-    0xBD, 0x92, 0x94, 0x66, 0xD4, 0xA4, 0xD9, 0x3B, 0x30, 0xDC, 0x2B, 0x19, 
-    0x0C, 0x20, 0x56, 0xC2, 0x7C, 0x25, 0xA2, 0x97, 0xC7, 0xFE, 0xB8, 0xC8, 
-    0xF3, 0xBC, 0x3B, 0x2D, 0xBC, 0x1F, 0x68, 0x79, 0x99, 0x4A, 0xE1, 0xB7, 
-    0xD1, 0x2C, 0x08, 0xD3, 0xAC, 0x82, 0x1A, 0x3C, 0x08, 0x87, 0x6A, 0x66, 
-    0x26, 0x50, 0xBF, 0x7E, 0xA8, 0x0F, 0x8F, 0x08, 0x2F, 0x27, 0xB2, 0x47, 
-    0xA4, 0x4B, 0xAD, 0x15, 0x89, 0x95, 0x78, 0xAB, 0x2E, 0x94, 0x8A, 0x76, 
-    0x1C, 0xD0, 0x99, 0x98, 0xD1, 0xC3, 0xB1, 0x13, 0x8A, 0x52, 0x5C, 0xC4, 
-    0xE6, 0x4C, 0x89, 0x98, 0xEB, 0xD3, 0x27, 0x90, 0x55, 0xF8, 0xFC, 0xA1, 
-    0x54, 0x7B, 0x08, 0xFC, 0x7C, 0xBE, 0x31, 0x55, 0x9F, 0x92, 0x61, 0x3C, 
-    0x97, 0x21, 0x64, 0xFC, 0xF0, 0xC3, 0xAA, 0x07, 0x02, 0x8D, 0x8A, 0x34, 
-    0x9E, 0x87, 0x98, 0x85, 0x2B, 0xB4, 0xA4, 0xC4, 0x25, 0xCA, 0x49, 0x27, 
-    0xCE, 0x68, 0x89, 0xBE, 0xDA, 0xC9, 0xF9, 0x13, 0x2C, 0x0A, 0xC0, 0x3F, 
-    0x07, 0x63, 0x65, 0xC4, 0x1B, 0x95, 0x18, 0xEC, 0x9A, 0x77, 0x1C, 0x4C, 
-    0xAA, 0x48, 0xCD, 0x7B, 0x3C, 0x63, 0x2D, 0x53, 0xD1, 0x29, 0x06, 0x16, 
-    0xED, 0x1C, 0xFE, 0x10, 0x92, 0x18, 0xCC, 0x06, 0xAC, 0x55, 0x78, 0x3A, 
-    0x45, 0x7A, 0x17, 0x3B, 0xA9, 0x3A, 0x2D, 0x63, 0x6D, 0x18, 0x0D, 0x49, 
-    0x5C, 0x1D, 0x7D, 0xAA, 0xBA, 0x32, 0xD1, 0x4F, 0x23, 0x3A, 0x69, 0xB1, 
-    0xB9, 0x87, 0x80, 0x91, 0x88, 0x6B, 0x66, 0x35, 0x7D, 0x8B, 0x13, 0x85, 
-    0xCA, 0x84, 0xB0, 0xBC, 0x56, 0xF6, 0x41, 0x0A, 0x71, 0x1F, 0x27, 0x60, 
-    0xC2, 0x95, 0x85, 0x34, 0x59, 0x97, 0xC0, 0xDC, 0xB9, 0xA7, 0xAF, 0xEA, 
-    0xA7, 0x16, 0x9D, 0x16, 0xA7, 0x58, 0xC0, 0xE8, 0x3B, 0xCF, 0x18, 0xB9, 
-    0x34, 0x83, 0x6A, 0x00, 0x92, 0x8D, 0x17, 0xF3, 0x15, 0xD7, 0xBA, 0x81, 
-    0xA2, 0x17, 0xAC, 0x14, 0x16, 0x2A, 0xC6, 0x46, 0x5B, 0xD5, 0x4A, 0x24, 
-    0x11, 0xF2, 0xF4, 0x61, 0x14, 0x36, 0x97, 0x3B, 0x47, 0xB5, 0xA3, 0x34, 
-    0xB7, 0x53, 0xA6, 0x01, 0xEB, 0x2C, 0xA2, 0x43, 0xFC, 0xCB, 0xC9, 0xAC, 
-    0x34, 0x87, 0xBD, 0x23, 0x1B, 0xF0, 0x53, 0x6C, 0xDB, 0x67, 0x2A, 0x9B, 
-    0xCF, 0x4D, 0xBD, 0xC4, 0x08, 0xDC, 0xCF, 0x31, 0xF5, 0x61, 0xAD, 0x82, 
-    0x11, 0x9E, 0x04, 0xCE, 0x19, 0xAB, 0x14, 0x50, 0x7C, 0xAE, 0xD0, 0xA2, 
-    0xC9, 0x7A, 0xB4, 0x01, 0xDA, 0x23, 0xC3, 0xCF, 0x37, 0xCF, 0xC2, 0x54, 
-    0xDD, 0x7C, 0xA2, 0x79, 0xB0, 0x6B, 0xD3, 0xBA, 0x5D, 0x1A, 0xBC, 0x7D, 
-    0x08, 0x2D, 0x64, 0xA1, 0x12, 0x35, 0x32, 0x8A, 0xB5, 0x49, 0x5C, 0xEC, 
-    0x10, 0xF7, 0x71, 0xC5, 0xE0, 0xA7, 0x14, 0xCD, 0xDB, 0x25, 0x14, 0xBB, 
-    0xBB, 0x53, 0x29, 0x92, 0x4C, 0xBB, 0x23, 0xEB, 0x16, 0xCA, 0xCE, 0x99, 
-    0x1E, 0x41, 0xB4, 0x3A, 0xD0, 0x73, 0xDF, 0x44, 0x65, 0xBE, 0x02, 0x92, 
-    0xD9, 0x77, 0x77, 0x7B, 0x56, 0x03, 0x53, 0x83, 0x80, 0x29, 0xCD, 0x9C, 
-    0x12, 0x54, 0xE7, 0x20, 0xB4, 0xFE, 0x08, 0xB4, 0xE5, 0xCC, 0xB8, 0xFD, 
-    0x34, 0xB9, 0x49, 0xFA, 0xB5, 0xA8, 0x9D, 0xCD, 0xC9, 0x7C, 0xD2, 0xFD, 
-    0xF3, 0x4F, 0xBA, 0xD5, 0x6B, 0xD0, 0x3C, 0xD7, 0x8B, 0xAB, 0xD1, 0x36, 
-    0x56, 0xBF, 0x17, 0x30, 0xE0, 0x22, 0x41, 0x83, 0xF5, 0xE4, 0xB9, 0x63, 
-    0x66, 0x88, 0x47, 0x72, 0xD9, 0x91, 0xA1, 0xA3, 0x69, 0xA1, 0x02, 0x21, 
-    0xE9, 0x34, 0xB5, 0x02, 0xB8, 0x24, 0x9B, 0x25, 0xEC, 0x2D, 0x2A, 0xD7, 
-    0xA5, 0x3B, 0x96, 0x4D, 0xCA, 0x6B, 0xF3, 0xB4, 0x2A, 0xD5, 0x25, 0x3C, 
-    0x2E, 0xC2, 0x29, 0xE1, 0xC5, 0x97, 0x91, 0x88, 0x57, 0xB8, 0x89, 0xE5, 
-    0x32, 0x80, 0x1E, 0x19, 0x92, 0x09, 0xEA, 0x7A, 0x45, 0xEC, 0x19, 0xD6, 
-    0xEC, 0xDB, 0xB0, 0x2A, 0xAE, 0x44, 0x62, 0xE3, 0xBA, 0x7C, 0x43, 0xFA, 
-    0x94, 0x38, 0xFE, 0xF4, 0x2D, 0x5C, 0xDE, 0x12, 0x86, 0x3C, 0x26, 0x42, 
-    0x3B, 0xB7, 0xDE, 0x55, 0x59, 0x41, 0x4C, 0x27, 0x48, 0x1C, 0x63, 0x0A, 
-    0x6C, 0xAF, 0x1B, 0x23, 0xB6, 0x80, 0x08, 0xAB, 0xEC, 0x18, 0x38, 0x19, 
-    0xFE, 0x68, 0x08, 0x74, 0xE5, 0x7E, 0x34, 0x51, 0x75, 0x0E, 0x4A, 0xE8, 
-    0x98, 0x13, 0x0B, 0x72, 0x19, 0x5F, 0x24, 0xE6, 0x85, 0x87, 0xB1, 0x68, 
-    0xC8, 0xC2, 0x23, 0x05, 0x78, 0x75, 0x76, 0xE7, 0x6A, 0x99, 0xD6, 0xCD, 
-    0x86, 0x89, 0x88, 0x2E, 0x9D, 0xF6, 0xCB, 0x7F, 0xB7, 0x5B, 0x7E, 0xD3, 
-    0x3B, 0xA4, 0x74, 0x61, 0x65, 0x6D, 0x6C, 0x14, 0xDB, 0x9C, 0x16, 0x5B, 
-    0x83, 0xE9, 0xF8, 0x98, 0x98, 0x69, 0x24, 0x01, 0x9F, 0x04, 0xAE, 0x29, 
-    0x12, 0x73, 0xB1, 0x6B, 0x96, 0xB9, 0xC6, 0xE8, 0x88, 0x6E, 0x7F, 0xB6, 
-    0xFE, 0x71, 0xDB, 0xFD, 0xCD, 0xDD, 0x0D, 0xA1, 0x38, 0xF9, 0xEA, 0xE3, 
-    0x60, 0x03, 0x32, 0x80, 0x03, 0xBA, 0xB1, 0x02, 0xFE, 0x3C, 0x10, 0x03, 
-    0xD8, 0x30, 0x01, 0x86, 0x09, 0xE3, 0x82, 0x80, 0x64, 0x79, 0xD7, 0xBB, 
-    0x89, 0x10, 0xA8, 0x46, 0x2E, 0x00, 0x8E, 0x44, 0xD0, 0x3B, 0x69, 0x79, 
-    0x1A, 0x8A, 0x36, 0xB5, 0x54, 0x2C, 0x2E, 0x6E, 0x66, 0x08, 0x47, 0x91, 
-    0xF9, 0x4D, 0xB7, 0xAB, 0xAE, 0xA8, 0x92, 0x4E, 0xA3, 0xD5, 0xE0, 0x03, 
-    0xF0, 0xB1, 0x02, 0x3D, 0xA0, 0x0D, 0xB1, 0xF1, 0x46, 0xDE, 0x0C, 0xA9, 
-    0x76, 0xD6, 0x5E, 0xEA, 0x12, 0x9D, 0xE1, 0x25, 0xCF, 0x80, 0xF2, 0x69, 
-    0xD7, 0x77, 0x7D, 0x97, 0x05, 0xEF, 0x64, 0xC3, 0xC0, 0xA4, 0x49, 0x2D, 
-    0x5A, 0x94, 0x01, 0xCC, 0x9D, 0x87, 0x55, 0x61, 0x23, 0x87, 0x6B, 0xE5, 
-    0xFA, 0x0C, 0xBD, 0x1E, 0xA2, 0xEC, 0xE4, 0x70, 0x03, 0xBA, 0xD1, 0x01, 
-    0x10, 0x70, 0x00, 0xA5, 0xB1, 0x03, 0xE0, 0xF0, 0xC4, 0xEB, 0x3B, 0xE9, 
-    0x4E, 0x6A, 0xB1, 0x23, 0x7A, 0x2F, 0xE3, 0x95, 0x2E, 0x9A, 0x0B, 0xEE, 
-    0x34, 0xF3, 0x2B, 0x94, 0x28, 0x43, 0x53, 0x54, 0xBF, 0x74, 0x51, 0xA9, 
-    0x8E, 0x24, 0x4E, 0xC2, 0x64, 0x9D, 0xAD, 0x23, 0xE7, 0x15, 0x6F, 0xF0, 
-    0xD5, 0x80, 0xF1, 0x92, 0x71, 0x00, 0x23, 0x10, 0x00, 0x40, 0x1F, 0x00, 
-    0x24, 0xB0, 0x00, 0x1C, 0x1F, 0x19, 0x1E, 0xFF, 0x0D, 0x59, 0x82, 0xB8, 
-    0xB1, 0x65, 0xF1, 0xA2, 0x0C, 0x2C, 0x5F, 0x7A, 0x9D, 0x6F, 0xDD, 0x49, 
-    0x08, 0x7F, 0x17, 0x21, 0xED, 0x51, 0x11, 0x1D, 0x2D, 0x89, 0xBE, 0x5A, 
-    0x81, 0x45, 0x27, 0x2F, 0x1A, 0x19, 0xB9, 0xB4, 0xCF, 0x1A, 0xEE, 0x6B, 
-    0x0B, 0x2A, 0x97, 0x4C, 0x4F, 0x0E, 0xF2, 0x2E, 0x19, 0x2F, 0x90, 0x00, 
-    0x41, 0xBF, 0xF6, 0x09, 0xD0, 0x01, 0x92, 0x71, 0xF4, 0xDD, 0x20, 0x68, 
-    0xA5, 0x9A, 0x44, 0x72, 0x55, 0x01, 0x21, 0x04, 0xAC, 0xD1, 0xC9, 0xFE, 
-    0x47, 0xE6, 0x8D, 0x6F, 0x9E, 0x4D, 0x27, 0x2F, 0x4D, 0x33, 0xA2, 0x0E, 
-    0xDD, 0x05, 0x14, 0x54, 0x9E, 0xCA, 0x16, 0x64, 0xF8, 0x15, 0xC3, 0xF8, 
-    0xD0, 0x8A, 0x5B, 0xF3, 0x34, 0x5B, 0x45, 0xF2, 0xB0, 0x03, 0x92, 0xD1, 
-    0x01, 0x1F, 0xB0, 0xF6, 0x94, 0x1F, 0x00, 0x6D, 0x2F, 0x19, 0x3E, 0xF0, 
-    0x0D, 0x14, 0xFE, 0xC0, 0xEB, 0x82, 0x00, 0x7D, 0x5A, 0x40, 0x2B, 0xE6, 
-    0xEB, 0x3E, 0x96, 0xA4, 0x21, 0xC9, 0x00, 0x26, 0x40, 0x4D, 0x47, 0x03, 
-    0x47, 0x9D, 0x83, 0x6D, 0xA4, 0x21, 0xEC, 0x41, 0x55, 0x2B, 0xF5, 0xDA, 
-    0xA5, 0xEF, 0x92, 0xF8, 0xBB, 0xE7, 0xF8, 0xE1, 0x1C, 0xF6, 0x68, 0x33, 
-    0xF6, 0xC9, 0x50, 0x03, 0x35, 0x60, 0x03, 0xA4, 0x60, 0x03, 0x2B, 0x10, 
-    0x19, 0x1D, 0xA0, 0xF6, 0x95, 0x4F, 0xF9, 0x97, 0x6F, 0xF4, 0xDE, 0x80, 
-    0xD0, 0x0F, 0xEC, 0xD3, 0x31, 0x8F, 0x21, 0x75, 0x26, 0xF2, 0xA2, 0x7C, 
-    0x93, 0x25, 0xE5, 0x6B, 0x26, 0x10, 0x43, 0x62, 0xBB, 0x41, 0x7A, 0x6B, 
-    0x55, 0x41, 0x48, 0xD3, 0x70, 0xFB, 0x71, 0xC5, 0xF6, 0xA2, 0xA6, 0x49, 
-    0xD7, 0xEB, 0x2E, 0x18, 0x53, 0x7E, 0x0C, 0x35, 0x70, 0x03, 0xC1, 0x1F, 
-    0x19, 0x38, 0xF0, 0x03, 0xBE, 0xFF, 0x09, 0x31, 0x90, 0xFE, 0xC3, 0x5F, 
-    0xFC, 0xC5, 0x9F, 0x00, 0x10, 0x10, 0x19, 0x2B, 0xD0, 0xFE, 0xDC, 0xA0, 
-    0x58, 0x9E, 0xAF, 0x94, 0x72, 0xFA, 0xB1, 0x44, 0xCB, 0xD1, 0x80, 0x00, 
-    0x20, 0x38, 0x28, 0x38, 0x81, 0x31, 0x80, 0x98, 0xC8, 0xB1, 0x21, 0xD0, 
-    0xE8, 0xF8, 0xE8, 0x68, 0xD0, 0x92, 0x88, 0x88, 0x51, 0x40, 0x88, 0x99, 
-    0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, 0x09, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 
-    0x6A, 0x7A, 0x8A, 0xFA, 0x19, 0x42, 0x39, 0xE0, 0xC1, 0x08, 0xD9, 0x08, 
-    0x82, 0x80, 0xFE, 0xE8, 0xC8, 0x90, 0x48, 0xC0, 0x99, 0xC2, 0xEA, 0x02, 
-    0xDB, 0x2B, 0xA0, 0x40, 0x59, 0x41, 0x78, 0x91, 0xE8, 0xE0, 0x2B, 0xB0, 
-    0xC1, 0xC1, 0x8A, 0x78, 0x92, 0xEA, 0xFC, 0x0C, 0x20, 0x73, 0x8C, 0xF3, 
-    0xA3, 0x03, 0x4D, 0x98, 0xD3, 0x28, 0x12, 0xC0, 0xDD, 0xED, 0xFD, 0xCD, 
-    0x9D, 0x70, 0xD0, 0x98, 0x73, 0x6D, 0x7E, 0x1E, 0x7A, 0xC2, 0x6A, 0x72, 
-    0xDC, 0xB8, 0x61, 0xE2, 0x90, 0x81, 0xE8, 0xA1, 0x62, 0xF2, 0xDA, 0xFE, 
-    0xA8, 0x9C, 0x18, 0xC1, 0x59, 0x42, 0xC0, 0xEA, 0x00, 0x04, 0x3E, 0x58, 
-    0x0C, 0x66, 0x25, 0x6A, 0x80, 0x2E, 0xA1, 0xC2, 0x85, 0x0C, 0x1B, 0x3A, 
-    0xF4, 0x54, 0x80, 0x02, 0x40, 0x03, 0xED, 0x5C, 0x20, 0x7A, 0x65, 0xE2, 
-    0x60, 0x27, 0x5D, 0x89, 0x10, 0xDC, 0x6B, 0x67, 0xC0, 0xE0, 0x80, 0x10, 
-    0x84, 0x2C, 0x50, 0xE2, 0x05, 0x29, 0xD9, 0x32, 0x44, 0x14, 0x84, 0x3D, 
-    0x5C, 0xC8, 0x63, 0xA0, 0x80, 0x1B, 0xD6, 0xA0, 0x49, 0x13, 0xD0, 0x21, 
-    0x01, 0xB8, 0x9D, 0xDF, 0x60, 0x38, 0x92, 0xF1, 0x32, 0xA8, 0xA9, 0x02, 
-    0x87, 0x28, 0x39, 0xF8, 0x28, 0x33, 0x69, 0x2D, 0x4A, 0x14, 0x38, 0x99, 
-    0xA4, 0x84, 0x80, 0x9D, 0xD2, 0x47, 0xB2, 0x28, 0x49, 0x10, 0x8A, 0x35, 
-    0xAB, 0xD6, 0xAD, 0xE8, 0x8A, 0x2A, 0x92, 0xA9, 0x61, 0x00, 0x83, 0x46, 
-    0x61, 0x11, 0x21, 0xEC, 0x24, 0x31, 0x91, 0x87, 0xA4, 0xFA, 0x06, 0x5C, 
-    0xC0, 0x44, 0x0C, 0x51, 0x86, 0x47, 0x06, 0x14, 0x88, 0x64, 0xEA, 0x92, 
-    0xEB, 0xB3, 0x9B, 0x28, 0x16, 0x2C, 0x80, 0x80, 0x42, 0x84, 0x08, 0x14, 
-    0xB0, 0x64, 0xC4, 0x70, 0x66, 0xA3, 0xD1, 0x01, 0x9D, 0x3C, 0x1B, 0x73, 
-    0x13, 0xE1, 0xC8, 0x86, 0xDE, 0xC9, 0x83, 0x22, 0x2E, 0x5B, 0x34, 0x75, 
-    0xAA, 0x3C, 0x44, 0x04, 0x2E, 0xFE, 0x69, 0x7A, 0xAA, 0x56, 0x60, 0x66, 
-    0xAA, 0x77, 0x27, 0x50, 0x3E, 0x8D, 0x3A, 0xB5, 0x50, 0x8E, 0x89, 0x44, 
-    0x0F, 0xE4, 0x30, 0x56, 0x80, 0xAD, 0x44, 0x9F, 0x1A, 0x50, 0x52, 0x20, 
-    0x13, 0x04, 0x25, 0xD3, 0x83, 0x40, 0x0F, 0xD0, 0x20, 0xA0, 0xEE, 0xDD, 
-    0x44, 0x2D, 0x55, 0x9F, 0xB2, 0xB1, 0x42, 0x00, 0x0B, 0xC6, 0xDF, 0x48, 
-    0x8C, 0x60, 0xF1, 0x68, 0xC5, 0x0F, 0xC9, 0xA6, 0x62, 0x64, 0x3B, 0xF0, 
-    0xC1, 0xB1, 0xF6, 0x00, 0xD0, 0x05, 0x94, 0x33, 0xBE, 0x55, 0xC2, 0x4A, 
-    0x0E, 0xAE, 0x8F, 0x31, 0x68, 0xE1, 0x01, 0xF8, 0x40, 0x60, 0x89, 0x2C, 
-    0x6C, 0x4A, 0x5B, 0x8C, 0xE2, 0x68, 0x48, 0x16, 0x35, 0x82, 0xBF, 0x8F, 
-    0x3F, 0xBF, 0x28, 0xF8, 0x03, 0x10, 0xC8, 0x1F, 0xF8, 0x8A, 0x01, 0x94, 
-    0xB8, 0xD7, 0x49, 0x01, 0xFF, 0x20, 0xE2, 0x91, 0x4C, 0x22, 0xA5, 0x00, 
-    0x57, 0x22, 0x19, 0xD8, 0xB5, 0x52, 0x71, 0xFA, 0x85, 0x12, 0x03, 0x0E, 
-    0x02, 0xCC, 0xB0, 0x1D, 0x09, 0x0B, 0x8C, 0xE3, 0x08, 0x0E, 0x3B, 0x94, 
-    0xF2, 0x43, 0x23, 0x30, 0x6C, 0xA7, 0x1D, 0x09, 0x8E, 0x7C, 0x38, 0xE1, 
-    0x4B, 0x86, 0xAC, 0x94, 0x41, 0x0B, 0x2E, 0xDC, 0x03, 0x02, 0x03, 0x0A, 
-    0xA8, 0x60, 0xD0, 0x5C, 0x00, 0x52, 0x72, 0x56, 0x26, 0xBE, 0x0D, 0xC0, 
-    0xC1, 0x7C, 0xBE, 0x4C, 0xB2, 0x4F, 0x8A, 0x42, 0x0E, 0x79, 0x9F, 0x3A, 
-    0x6A, 0xFD, 0x97, 0x94, 0x07, 0x89, 0xBC, 0xE5, 0x49, 0x04, 0x94, 0xF4, 
-    0x38, 0x90, 0x0A, 0xC4, 0x61, 0xB2, 0xE3, 0x32, 0x12, 0x12, 0xD9, 0x09, 
-    0x0D, 0x02, 0xBC, 0x40, 0x62, 0x38, 0x2F, 0x40, 0xE2, 0xC3, 0x28, 0x35, 
-    0x34, 0xC2, 0x65, 0x97, 0x8E, 0x41, 0x26, 0xC0, 0x0A, 0x87, 0x61, 0xC9, 
-    0x90, 0x04, 0x07, 0xAE, 0x04, 0x27, 0x22, 0xB8, 0xFE, 0x0D, 0xE4, 0x40, 
-    0x30, 0x9F, 0xB1, 0x02, 0xA5, 0x8F, 0xB0, 0x18, 0xB0, 0xD9, 0x00, 0xCD, 
-    0xB0, 0x09, 0x68, 0xA0, 0x41, 0x11, 0x45, 0x89, 0x0A, 0x99, 0x95, 0x85, 
-    0x08, 0x83, 0x9E, 0xF0, 0x87, 0xA4, 0x2F, 0xEC, 0x0D, 0x90, 0xE3, 0x20, 
-    0x71, 0x59, 0x99, 0x97, 0xA0, 0x98, 0xEC, 0x80, 0x93, 0x99, 0xDD, 0x3C, 
-    0x40, 0x98, 0x23, 0x34, 0x50, 0xE7, 0x49, 0x85, 0x38, 0x31, 0xA7, 0x29, 
-    0x38, 0xE2, 0x34, 0x02, 0x94, 0xA5, 0xE8, 0x14, 0xE0, 0x66, 0x9C, 0x2B, 
-    0xF9, 0x37, 0x10, 0xA2, 0x03, 0x5C, 0x95, 0x49, 0x09, 0xAC, 0xA8, 0xA7, 
-    0x67, 0x2F, 0xB2, 0x7A, 0xA6, 0x6A, 0xAF, 0xBE, 0xA6, 0x62, 0xE0, 0x93, 
-    0x99, 0xF5, 0x49, 0x40, 0xA5, 0x9A, 0x54, 0x40, 0x09, 0xAE, 0xE6, 0xDD, 
-    0xA2, 0x23, 0xA5, 0xBF, 0x62, 0x62, 0xE1, 0x08, 0xA5, 0x76, 0x33, 0x42, 
-    0xA7, 0x69, 0x82, 0xCA, 0x49, 0x4C, 0xD8, 0x4D, 0xDB, 0xD8, 0x07, 0xE3, 
-    0xA8, 0xF9, 0xEC, 0x35, 0x05, 0x58, 0xE0, 0x95, 0xAB, 0x03, 0xB4, 0x30, 
-    0x50, 0x48, 0x89, 0x60, 0xA0, 0xC9, 0x04, 0x6F, 0x9E, 0x9B, 0xEB, 0x31, 
-    0x02, 0xB6, 0x17, 0x6E, 0xBD, 0xF6, 0x76, 0xE2, 0x6E, 0xB2, 0x53, 0xD5, 
-    0x57, 0x09, 0xAF, 0x9B, 0x18, 0xC9, 0xE3, 0x40, 0xB3, 0x21, 0xA2, 0xC9, 
-    0xA4, 0x57, 0xD6, 0x9B, 0x18, 0x0A, 0xDC, 0x7A, 0x03, 0x83, 0xB5, 0x86, 
-    0x71, 0x32, 0xA6, 0x00, 0x0B, 0x68, 0x97, 0x00, 0x0C, 0x0B, 0xBC, 0x30, 
-    0xC3, 0x03, 0x0F, 0x64, 0xD7, 0xD8, 0x02, 0xA8, 0xDE, 0x0B, 0x4D, 0x05, 
-    0x16, 0x50, 0x60, 0x1B, 0x25, 0xE5, 0x22, 0xD5, 0x8B, 0x94, 0x41, 0x66, 
-    0x52, 0x6E, 0x9E, 0xF1, 0xF6, 0x52, 0x27, 0x22, 0xB4, 0x82, 0x4C, 0xF3, 
-    0xBD, 0xB6, 0xEA, 0xAB, 0x94, 0xCA, 0x2C, 0x79, 0x22, 0x1E, 0x22, 0xFE, 
-    0xC6, 0xE0, 0x33, 0xF0, 0x00, 0x77, 0x1E, 0x6C, 0x6F, 0x88, 0xD2, 0x2E, 
-    0xDC, 0x4D, 0x02, 0x1D, 0x38, 0x92, 0xC3, 0x9A, 0x99, 0x64, 0xA3, 0x70, 
-    0x63, 0x0F, 0xA0, 0x09, 0x0B, 0x0A, 0x33, 0x90, 0x9A, 0x74, 0x23, 0xE0, 
-    0xD6, 0x8C, 0x0E, 0x6B, 0x6B, 0x01, 0x4D, 0x09, 0x49, 0x99, 0xAC, 0x52, 
-    0xCC, 0xCB, 0xED, 0x3C, 0xDA, 0xCC, 0x04, 0x62, 0x73, 0xCD, 0xB6, 0xAA, 
-    0xBE, 0x21, 0x50, 0x1E, 0x3E, 0xEA, 0x4E, 0xC9, 0x49, 0xCF, 0x03, 0xFC, 
-    0xDC, 0x4E, 0xD0, 0x9B, 0x18, 0x7B, 0x2F, 0x0E, 0x07, 0x20, 0x0D, 0x0E, 
-    0xD5, 0x37, 0x68, 0x82, 0xA9, 0x00, 0x47, 0x83, 0x33, 0x83, 0xB5, 0xC7, 
-    0xE4, 0xB4, 0x93, 0xC7, 0x02, 0x84, 0xD9, 0xF6, 0x35, 0x64, 0x0F, 0x30, 
-    0x67, 0x3B, 0xC4, 0xFA, 0x2B, 0x88, 0x93, 0x0E, 0x36, 0x9A, 0x9B, 0x09, 
-    0x0A, 0x7C, 0xEE, 0x02, 0xE7, 0x8E, 0x3C, 0xDA, 0x40, 0xBE, 0x4D, 0x45, 
-    0x8E, 0x3A, 0x9B, 0xFC, 0x25, 0x98, 0x94, 0x6E, 0x4C, 0x71, 0x32, 0x39, 
-    0xDE, 0xCB, 0x72, 0x96, 0x3A, 0x21, 0x63, 0x96, 0x09, 0xB8, 0x37, 0x10, 
-    0xFC, 0x84, 0x09, 0x72, 0x02, 0x40, 0xB0, 0x53, 0x02, 0xBB, 0x1F, 0x23, 
-    0xC4, 0x23, 0x8C, 0x7F, 0x93, 0x00, 0x61, 0x38, 0xD4, 0xEE, 0x4C, 0xC9, 
-    0xAD, 0xC4, 0x0D, 0xC9, 0xA3, 0x03, 0x94, 0xA0, 0x49, 0xB9, 0xD0, 0xE3, 
-    0xA3, 0x81, 0x92, 0xAC, 0x20, 0x50, 0x79, 0xF4, 0x4B, 0xBE, 0x79, 0x3A, 
-    0xF3, 0xE2, 0xE3, 0x07, 0x70, 0x2B, 0xA2, 0xFB, 0x22, 0xEB, 0x00, 0x14, 
-    0x60, 0x0E, 0x40, 0xB0, 0x88, 0xA0, 0x8B, 0x0F, 0xE9, 0xE3, 0xDF, 0x60, 
-    0x78, 0xEE, 0xC8, 0x2F, 0xDD, 0x08, 0x8A, 0x00, 0x88, 0x2A, 0xC0, 0x03, 
-    0xE0, 0x7C, 0xA0, 0xB8, 0x46, 0x10, 0xC1, 0x08, 0x48, 0x50, 0x82, 0x20, 
-    0x8E, 0x00, 0xFE, 0x04, 0x22, 0x68, 0x63, 0x27, 0x33, 0x68, 0x44, 0x0F, 
-    0xC6, 0x67, 0x8A, 0x72, 0x51, 0x4E, 0x74, 0x73, 0x83, 0xD4, 0x9D, 0x12, 
-    0xD1, 0x3D, 0x00, 0xC5, 0x0C, 0x4E, 0x1E, 0xE0, 0x9C, 0xF4, 0x58, 0x11, 
-    0x3E, 0x08, 0x8A, 0x90, 0x32, 0x84, 0x2A, 0x9B, 0x52, 0xD2, 0x77, 0x01, 
-    0x7E, 0x0C, 0xA2, 0x02, 0xD6, 0x8B, 0x12, 0xDD, 0x98, 0x97, 0x1C, 0xFF, 
-    0xD9, 0xCF, 0x1B, 0x09, 0x40, 0xD3, 0x0A, 0x6A, 0x92, 0x8D, 0x2D, 0x81, 
-    0x63, 0x04, 0x1C, 0x72, 0x04, 0x11, 0x80, 0x10, 0x04, 0x4D, 0x1C, 0x81, 
-    0x09, 0x8D, 0x98, 0x58, 0x73, 0x1A, 0xC1, 0x83, 0x11, 0x8E, 0x62, 0x72, 
-    0x0E, 0x8A, 0xCD, 0x23, 0xA4, 0xC7, 0x37, 0x00, 0x4C, 0x2A, 0x03, 0xE7, 
-    0xD3, 0xD5, 0x70, 0x56, 0xF2, 0xB5, 0x27, 0xBA, 0x8A, 0x40, 0x4A, 0xEC, 
-    0xA2, 0x56, 0xDC, 0x87, 0x08, 0x97, 0xC5, 0x6A, 0x19, 0x17, 0xA0, 0x80, 
-    0x04, 0xCA, 0x77, 0x37, 0x05, 0xD1, 0x8B, 0x79, 0x3D, 0x68, 0xC4, 0x0C, 
-    0x77, 0xF2, 0x25, 0x01, 0xD0, 0x00, 0x00, 0x11, 0x43, 0x01, 0xD6, 0x3E, 
-    0x00, 0x89, 0x1F, 0x06, 0x91, 0x13, 0x47, 0x50, 0xE0, 0x62, 0xC0, 0x31, 
-    0xBC, 0x9A, 0x78, 0xD1, 0x13, 0x2B, 0x62, 0x85, 0x0A, 0x90, 0xD4, 0xA7, 
-    0x10, 0x0E, 0xE2, 0x66, 0x88, 0x50, 0x16, 0x3E, 0x80, 0x44, 0x09, 0x02, 
-    0x98, 0x51, 0x82, 0x19, 0xDC, 0x20, 0x9C, 0xB8, 0x38, 0xC8, 0x4C, 0x3A, 
-    0x24, 0x5F, 0x89, 0x90, 0x4A, 0x52, 0xD2, 0x07, 0x27, 0xD6, 0xB5, 0x43, 
-    0x56, 0x51, 0x64, 0x5B, 0x4C, 0x3A, 0xF0, 0xC6, 0x9D, 0xA0, 0xE9, 0x06, 
-    0xC9, 0x11, 0xC0, 0x88, 0xBC, 0xE1, 0xAD, 0x47, 0x08, 0xE1, 0x08, 0xA0, 
-    0x50, 0xC2, 0x02, 0xBF, 0x31, 0x82, 0x46, 0x40, 0x4E, 0x93, 0x1B, 0x79, 
-    0x57, 0x7F, 0xA4, 0xC2, 0xAF, 0xFE, 0x01, 0x44, 0x11, 0x60, 0x36, 0x92, 
-    0x49, 0x5B, 0x38, 0x83, 0xC9, 0x08, 0xBC, 0x09, 0x56, 0x8E, 0x18, 0x4E, 
-    0x3D, 0x58, 0x81, 0x49, 0x5E, 0x4A, 0xF3, 0x1C, 0x8C, 0x6C, 0xE4, 0x54, 
-    0x40, 0xA0, 0xBD, 0x50, 0x5E, 0x0F, 0x16, 0x7D, 0x62, 0x97, 0xF8, 0x6E, 
-    0x99, 0xCA, 0x6F, 0xE0, 0xAF, 0x11, 0x2C, 0xF8, 0x46, 0x2C, 0x05, 0x88, 
-    0x84, 0x51, 0x00, 0xA1, 0x11, 0x24, 0x00, 0xC7, 0x38, 0xBE, 0x33, 0xCD, 
-    0xBD, 0xA1, 0xF1, 0x6E, 0x20, 0x80, 0xE4, 0x9F, 0x30, 0x51, 0x00, 0x4A, 
-    0x78, 0x12, 0x1F, 0xC7, 0xF4, 0x13, 0xFB, 0x34, 0x67, 0x4D, 0x77, 0xE0, 
-    0xA9, 0x11, 0xFD, 0x8C, 0x66, 0x3C, 0x0F, 0x8A, 0x8A, 0xB7, 0x6D, 0xF3, 
-    0x18, 0x1A, 0xE8, 0xD3, 0x93, 0xAA, 0xF8, 0x88, 0x8C, 0xAC, 0xB1, 0x76, 
-    0x11, 0x3B, 0x5C, 0x38, 0x93, 0xC6, 0xA1, 0x3F, 0x26, 0xCD, 0x5A, 0x44, 
-    0x30, 0x20, 0x29, 0x9A, 0xA0, 0xC3, 0x6F, 0xA0, 0x09, 0x5B, 0x08, 0x25, 
-    0x84, 0x3F, 0x96, 0x21, 0x12, 0x83, 0x02, 0xA0, 0x9A, 0x10, 0x75, 0x44, 
-    0x3F, 0x15, 0xA5, 0x09, 0x80, 0xC1, 0x4F, 0x00, 0x12, 0x0D, 0x63, 0x3E, 
-    0x22, 0xC9, 0x9B, 0x92, 0xEA, 0xB4, 0x14, 0xAB, 0x43, 0xD9, 0x40, 0x40, 
-    0xE0, 0xB9, 0xCF, 0x69, 0xA0, 0xA5, 0x8E, 0xA8, 0x0A, 0x22, 0x98, 0xC4, 
-    0xBC, 0xC2, 0x71, 0xEC, 0xA2, 0xDE, 0x70, 0x9C, 0x45, 0x03, 0x40, 0xB5, 
-    0x26, 0x78, 0x94, 0x14, 0x43, 0x10, 0xC0, 0xDF, 0x70, 0xD9, 0x88, 0x1F, 
-    0xEC, 0x34, 0x13, 0x05, 0x60, 0x22, 0x2B, 0xA2, 0x18, 0x3B, 0x99, 0x7C, 
-    0x50, 0xA5, 0x83, 0xB0, 0x1B, 0xDE, 0x74, 0x26, 0x46, 0x01, 0x1C, 0x93, 
-    0x00, 0x39, 0xDD, 0xAA, 0x5B, 0x17, 0x45, 0x89, 0x0E, 0x9A, 0x2D, 0x5D, 
-    0x0E, 0xA5, 0x9E, 0xF8, 0x6E, 0xC2, 0x54, 0x70, 0xFE, 0x7C, 0x09, 0x78, 
-    0xDE, 0xC8, 0x65, 0x23, 0x98, 0xB0, 0x47, 0x53, 0x14, 0xEF, 0xA9, 0x0F, 
-    0x68, 0xC4, 0xF2, 0xDE, 0x4A, 0x88, 0x08, 0x48, 0x70, 0x00, 0xB8, 0xD0, 
-    0x84, 0xF3, 0x32, 0xD8, 0x0B, 0xD7, 0x4D, 0x74, 0x13, 0x66, 0x6D, 0x26, 
-    0x22, 0xF6, 0x79, 0xD3, 0x5B, 0xB4, 0x15, 0xB1, 0x9C, 0xAD, 0x4C, 0xB9, 
-    0x64, 0x37, 0x57, 0x58, 0x60, 0x93, 0x12, 0xF7, 0x64, 0x5E, 0x4C, 0xF8, 
-    0x9A, 0xD7, 0x6E, 0xA0, 0x40, 0xA3, 0xDC, 0x38, 0x27, 0x60, 0x53, 0x61, 
-    0x4B, 0x54, 0x7E, 0x23, 0x32, 0x9D, 0x2D, 0xEB, 0xBB, 0x22, 0x45, 0x08, 
-    0x4A, 0x38, 0xF1, 0x18, 0x96, 0x24, 0x2B, 0x21, 0xE0, 0x03, 0x3F, 0xD7, 
-    0x39, 0x92, 0x2E, 0xD9, 0x64, 0xEC, 0x66, 0x6B, 0x9B, 0xBA, 0x02, 0x44, 
-    0x60, 0xB9, 0xCB, 0x3D, 0x45, 0x01, 0x26, 0x15, 0xB0, 0xD0, 0x12, 0xE4, 
-    0x2E, 0x96, 0x80, 0xA0, 0x96, 0x70, 0xA7, 0x9D, 0x11, 0xBC, 0x60, 0xA9, 
-    0x66, 0x7A, 0xC0, 0xB6, 0xBC, 0x81, 0xBF, 0x26, 0x04, 0x16, 0x15, 0x44, 
-    0x94, 0x61, 0x37, 0xD0, 0xA4, 0x55, 0xE4, 0x02, 0xA0, 0x02, 0xCE, 0x0B, 
-    0x81, 0x41, 0xF3, 0x99, 0x08, 0x9F, 0x3E, 0x22, 0x68, 0x6B, 0xEB, 0xC4, 
-    0x9B, 0xA4, 0x92, 0x91, 0xE1, 0x42, 0xC2, 0x00, 0xC5, 0xBD, 0x00, 0xFB, 
-    0xD4, 0x4B, 0x33, 0xB5, 0x41, 0x77, 0x5D, 0x21, 0xB0, 0xAB, 0x28, 0x38, 
-    0x79, 0x59, 0xE9, 0x3A, 0x42, 0x25, 0x38, 0x15, 0x61, 0x11, 0xB7, 0xC3, 
-    0x29, 0x47, 0x74, 0x60, 0x04, 0x58, 0x3B, 0xD3, 0x53, 0xE3, 0xD8, 0x51, 
-    0x68, 0x20, 0xE1, 0x77, 0xE6, 0x34, 0x2C, 0x80, 0x05, 0x71, 0xD2, 0x44, 
-    0x61, 0x02, 0xA0, 0x03, 0x78, 0xCD, 0x92, 0xFE, 0x8B, 0x09, 0xD6, 0x0C, 
-    0xE0, 0x15, 0x2A, 0xD0, 0xEF, 0x9E, 0x8A, 0x5B, 0xDD, 0x0F, 0x07, 0xFE, 
-    0xD8, 0x79, 0xAE, 0xBA, 0x40, 0x08, 0x4A, 0xA9, 0x09, 0x12, 0xFF, 0x66, 
-    0x2A, 0x9E, 0x73, 0xC1, 0x6E, 0xE7, 0xDB, 0x4F, 0xB7, 0x1C, 0xB7, 0x76, 
-    0x8D, 0x30, 0x2F, 0x4F, 0xE2, 0x08, 0x89, 0xEF, 0x6E, 0xE7, 0xA9, 0x3E, 
-    0x11, 0x40, 0x86, 0xA1, 0x71, 0x84, 0x22, 0x7F, 0x83, 0x43, 0x0F, 0xFC, 
-    0x30, 0x40, 0xD9, 0x9A, 0x58, 0x4A, 0x0C, 0x64, 0x41, 0x9F, 0xA8, 0xC0, 
-    0x9B, 0xF0, 0x26, 0xDF, 0x5E, 0x6C, 0x80, 0x15, 0xDE, 0x94, 0xB1, 0xBD, 
-    0xBC, 0x6A, 0x2E, 0x96, 0xE0, 0x98, 0x4A, 0xAC, 0x58, 0xE8, 0x8B, 0x1D, 
-    0xE4, 0x00, 0x15, 0x28, 0xC0, 0x01, 0x96, 0xC4, 0x11, 0x8A, 0x53, 0x27, 
-    0xE5, 0xC6, 0x50, 0x0D, 0x16, 0x07, 0x30, 0x32, 0x4F, 0x1E, 0xD0, 0x4E, 
-    0x8C, 0x36, 0xA2, 0x08, 0xE7, 0x20, 0xE2, 0x36, 0xBC, 0xB1, 0xCA, 0x0F, 
-    0x23, 0x78, 0x00, 0x31, 0x06, 0x00, 0x89, 0x07, 0xB2, 0x1B, 0x88, 0x94, 
-    0xEB, 0xC7, 0x32, 0xE1, 0x6F, 0x24, 0x7D, 0x6B, 0xE6, 0x40, 0x95, 0x90, 
-    0x15, 0x1E, 0xA0, 0x73, 0x3C, 0xE0, 0x44, 0x80, 0x99, 0x79, 0x82, 0x89, 
-    0x70, 0x53, 0xCA, 0x06, 0xAE, 0x18, 0x27, 0x51, 0x3B, 0xB8, 0x7F, 0x1D, 
-    0x73, 0xC4, 0x12, 0x9E, 0x30, 0x84, 0x21, 0x14, 0x4F, 0x31, 0xDC, 0x25, 
-    0x11, 0x9A, 0xD2, 0x79, 0x8E, 0x75, 0x46, 0x8D, 0x5A, 0x5A, 0x03, 0xF0, 
-    0xA2, 0x11, 0xB1, 0xB6, 0x47, 0xE3, 0x83, 0x12, 0x9F, 0xE0, 0x8F, 0xA1, 
-    0x32, 0xB3, 0x81, 0xE2, 0x62, 0x39, 0x15, 0x25, 0xC0, 0x74, 0xA6, 0x85, 
-    0x32, 0x81, 0x01, 0x67, 0x60, 0xA8, 0xFB, 0xD5, 0x80, 0xCE, 0x4C, 0x36, 
-    0xE4, 0x4C, 0xF0, 0x47, 0xAE, 0xAD, 0x43, 0x35, 0x08, 0xD7, 0x4C, 0x64, 
-    0x56, 0xEF, 0x04, 0x8F, 0x8D, 0x00, 0x02, 0x26, 0x64, 0xAD, 0x98, 0x0A, 
-    0x4B, 0xAD, 0xFE, 0x11, 0x42, 0x48, 0x48, 0x11, 0x1A, 0xC1, 0x5D, 0x13, 
-    0x39, 0x10, 0xB9, 0x5E, 0x86, 0x93, 0x81, 0x29, 0xE1, 0x66, 0x01, 0x44, 
-    0x7A, 0x13, 0x96, 0xE9, 0x08, 0x51, 0x21, 0x61, 0x54, 0xCE, 0x64, 0x3B, 
-    0x14, 0xEC, 0x65, 0xEC, 0x9D, 0x9F, 0xFD, 0x12, 0x30, 0xF6, 0xC7, 0xC5, 
-    0x91, 0x80, 0x10, 0x2B, 0x60, 0xCA, 0x89, 0x4D, 0xB7, 0x62, 0x2A, 0xA0, 
-    0x24, 0x30, 0xB8, 0x99, 0x97, 0x67, 0x70, 0xE0, 0x8F, 0xD0, 0x9A, 0x30, 
-    0x02, 0x39, 0xCD, 0xD4, 0xA9, 0xA9, 0x9A, 0xA3, 0xAA, 0xAE, 0x14, 0x67, 
-    0x23, 0x06, 0x57, 0xDB, 0x72, 0x29, 0xDB, 0x33, 0x93, 0x62, 0x78, 0x23, 
-    0x12, 0xB9, 0xB7, 0x72, 0x95, 0xFA, 0x9A, 0x77, 0x59, 0xF6, 0x29, 0x5A, 
-    0xC5, 0x0C, 0x84, 0x73, 0x45, 0xE2, 0xAE, 0x48, 0x8A, 0x70, 0x58, 0xD1, 
-    0x00, 0x70, 0x3F, 0x57, 0x58, 0x27, 0x64, 0xC5, 0x09, 0x22, 0x70, 0xF0, 
-    0x55, 0xFB, 0x99, 0x1B, 0x8E, 0xE3, 0xF8, 0x26, 0x96, 0x20, 0x22, 0x12, 
-    0xF9, 0xD5, 0x08, 0x0B, 0x79, 0x70, 0x5F, 0x1D, 0xE1, 0xB4, 0xB7, 0xDA, 
-    0xCD, 0x7C, 0xD2, 0x3B, 0x0B, 0xC0, 0x8E, 0x7D, 0x0C, 0x48, 0x0E, 0xC0, 
-    0xA0, 0x16, 0xF0, 0xA5, 0xCB, 0x23, 0x7B, 0x97, 0x0B, 0x0C, 0xFC, 0x13, 
-    0x8A, 0x5D, 0x86, 0x0A, 0x75, 0x8E, 0x15, 0x95, 0xFF, 0xFB, 0x11, 0x1B, 
-    0xA8, 0x33, 0x01, 0x20, 0xDE, 0xAE, 0x77, 0x41, 0xB6, 0x1D, 0x6B, 0x4D, 
-    0xBA, 0xD2, 0xC1, 0x41, 0x82, 0x71, 0x2C, 0xC1, 0x13, 0x41, 0x50, 0xE0, 
-    0xAE, 0x1D, 0xB3, 0x3B, 0x22, 0xD0, 0x52, 0x21, 0x20, 0x3D, 0xB4, 0x37, 
-    0x4E, 0xC4, 0x59, 0x64, 0x6D, 0xAE, 0x11, 0x96, 0xBC, 0x8A, 0x6F, 0xC2, 
-    0x8C, 0x0C, 0x10, 0x22, 0x7D, 0x02, 0x16, 0x18, 0x30, 0x02, 0x50, 0xA2, 
-    0x14, 0x17, 0x50, 0xD7, 0xEF, 0xFE, 0xFC, 0x46, 0xF3, 0x51, 0x49, 0x0F, 
-    0xF7, 0x6B, 0x6C, 0x7B, 0xEE, 0xB0, 0xA8, 0xE9, 0x41, 0x0E, 0xAE, 0xE3, 
-    0xB3, 0x43, 0xE2, 0xDA, 0x8D, 0xD6, 0x64, 0xC6, 0xBB, 0xE1, 0x31, 0x22, 
-    0x8C, 0x77, 0x13, 0x1B, 0xAE, 0x9F, 0x63, 0xC8, 0x6D, 0xEE, 0x85, 0x14, 
-    0x0F, 0xB5, 0xDD, 0x70, 0x04, 0x0F, 0x62, 0x50, 0x83, 0xB7, 0xF2, 0xC7, 
-    0x89, 0x15, 0x1C, 0xC0, 0x04, 0xC0, 0x08, 0x76, 0x47, 0xA5, 0x19, 0x41, 
-    0xF9, 0x86, 0x45, 0xFA, 0x6A, 0x3F, 0x8A, 0x10, 0xC3, 0x49, 0xD5, 0xA9, 
-    0x5F, 0x88, 0x6F, 0xB8, 0xED, 0xA3, 0xD1, 0x46, 0xD2, 0xC0, 0x17, 0x6C, 
-    0x8D, 0x52, 0x2C, 0x9D, 0x88, 0xD2, 0x66, 0xB2, 0x11, 0x18, 0x9A, 0xB2, 
-    0x00, 0xA8, 0x0E, 0x8A, 0xE2, 0x1D, 0x5E, 0x95, 0x4E, 0xDE, 0x7D, 0xAE, 
-    0xAD, 0x0A, 0x8E, 0xEE, 0x74, 0x88, 0x06, 0x34, 0x29, 0xA9, 0xE4, 0xDF, 
-    0x47, 0x1F, 0x94, 0xE0, 0x5F, 0xFC, 0x01, 0x7A, 0xBE, 0x10, 0x64, 0xCB, 
-    0xE0, 0x00, 0xAC, 0x47, 0x16, 0x64, 0x86, 0x7A, 0x98, 0x50, 0x70, 0x00, 
-    0x01, 0x02, 0x96, 0xB4, 0x76, 0xDD, 0xF7, 0x0C, 0x13, 0x00, 0x15, 0x98, 
-    0xA7, 0x14, 0x1F, 0xE4, 0x4F, 0xB0, 0x03, 0x15, 0xD5, 0x17, 0x09, 0x77, 
-    0xA1, 0x48, 0x5E, 0x64, 0x75, 0xBC, 0x26, 0x00, 0x4F, 0x10, 0x0A, 0x51, 
-    0xE6, 0x7B, 0xC1, 0x33, 0x0E, 0xC1, 0xB7, 0x10, 0xEF, 0x26, 0x00, 0x3B, 
-    0xE4, 0x0B, 0x2B, 0xC0, 0x03, 0x55, 0x36, 0x4D, 0x2A, 0xC6, 0x39, 0x62, 
-    0xD7, 0x12, 0xCB, 0x94, 0x6F, 0x1A, 0xE8, 0x20, 0xB2, 0x67, 0x7D, 0x46, 
-    0xD7, 0x80, 0x84, 0x80, 0x73, 0x1D, 0x21, 0x15, 0xA7, 0x66, 0x1F, 0x14, 
-    0x98, 0x10, 0x43, 0x97, 0x08, 0x94, 0xA6, 0x27, 0xE2, 0x77, 0x0B, 0xE4, 
-    0x87, 0x09, 0xAB, 0xA7, 0x14, 0x01, 0x37, 0x00, 0xFE, 0x78, 0xD7, 0x45, 
-    0xD9, 0x40, 0x7C, 0x01, 0x90, 0x78, 0xA3, 0x40, 0x44, 0xB2, 0xC5, 0x40, 
-    0xF5, 0xD7, 0x10, 0x24, 0xE7, 0x67, 0x09, 0x80, 0x0F, 0x34, 0xD0, 0x03, 
-    0x59, 0x37, 0x48, 0xCE, 0x93, 0x56, 0xC1, 0x51, 0x5C, 0x25, 0xB0, 0x75, 
-    0x33, 0x77, 0x0C, 0x1B, 0x80, 0x1E, 0x1D, 0xD1, 0x62, 0xF3, 0xF1, 0x41, 
-    0x21, 0x08, 0x0A, 0x6D, 0x67, 0x48, 0x48, 0x22, 0x3D, 0x56, 0x88, 0x84, 
-    0xCF, 0xC0, 0x1F, 0x98, 0xF5, 0x32, 0x92, 0x60, 0x25, 0x28, 0xA6, 0x72, 
-    0xFB, 0x02, 0x4D, 0x9A, 0xA4, 0x25, 0xC4, 0x27, 0x6F, 0x83, 0x27, 0x0A, 
-    0xBD, 0x17, 0x68, 0xE0, 0x40, 0x18, 0x4E, 0xF0, 0x10, 0x8D, 0xF0, 0x54, 
-    0x01, 0x80, 0x3F, 0xDC, 0xD0, 0x30, 0xB0, 0xB0, 0x02, 0xBB, 0x34, 0x48, 
-    0x27, 0xE1, 0x0B, 0x92, 0xC5, 0x58, 0x0F, 0x88, 0x20, 0x4C, 0xA8, 0x60, 
-    0x6A, 0x05, 0x42, 0xA6, 0xF0, 0x7F, 0x4D, 0xD4, 0x0B, 0xD9, 0xD4, 0x19, 
-    0x7F, 0x68, 0x0E, 0xD5, 0x14, 0x7D, 0xD2, 0xC5, 0x00, 0x0E, 0xE5, 0x16, 
-    0x6F, 0x47, 0x08, 0x12, 0xB7, 0x86, 0x0C, 0xD5, 0x60, 0x83, 0xB4, 0x88, 
-    0xDE, 0xD0, 0x40, 0x02, 0xE0, 0x74, 0xA0, 0x10, 0x04, 0x23, 0xC8, 0x30, 
-    0x8D, 0x30, 0x04, 0x95, 0x28, 0x31, 0xE0, 0xE0, 0x38, 0x49, 0xF3, 0x17, 
-    0xE3, 0xA4, 0x4B, 0x99, 0x64, 0x81, 0x89, 0x50, 0x45, 0xAE, 0x67, 0x09, 
-    0x94, 0xA4, 0x80, 0xA3, 0xD1, 0x4F, 0x78, 0xE8, 0x09, 0x25, 0x20, 0x0C, 
-    0xE5, 0xC3, 0x01, 0xE7, 0x13, 0x34, 0xEA, 0x07, 0x8B, 0xCE, 0xF5, 0x26, 
-    0x54, 0x74, 0x8A, 0x91, 0x20, 0x76, 0xC0, 0xC6, 0x3E, 0x8B, 0xB6, 0x77, 
-    0xC7, 0xB0, 0x56, 0x17, 0x87, 0x3A, 0xBF, 0x78, 0x5E, 0x8D, 0x60, 0x7F, 
-    0x9E, 0xE0, 0x71, 0xF3, 0xC7, 0x0D, 0xD0, 0xD1, 0x04, 0x2F, 0x61, 0xFE, 
-    0x8C, 0xDC, 0x20, 0x6F, 0x4B, 0xF7, 0x00, 0xC3, 0xD3, 0x08, 0x9F, 0xE2, 
-    0x45, 0xC2, 0x76, 0x0C, 0xD7, 0x26, 0x01, 0x12, 0xD7, 0x1F, 0x2D, 0x10, 
-    0x66, 0x06, 0xC0, 0x00, 0x2F, 0xA2, 0x8D, 0xAC, 0xC0, 0x7D, 0x9E, 0x50, 
-    0x70, 0x08, 0x51, 0x6F, 0xF3, 0xD0, 0x0E, 0x62, 0x87, 0x8B, 0xE5, 0x68, 
-    0x0A, 0xE5, 0x63, 0x8A, 0x06, 0x00, 0x0F, 0xAD, 0xC0, 0x01, 0x05, 0x98, 
-    0x19, 0x05, 0xC1, 0x0A, 0x6A, 0x97, 0x09, 0xD3, 0x98, 0x08, 0x3E, 0xE8, 
-    0x08, 0xB4, 0x17, 0x84, 0x35, 0x43, 0x8F, 0xDC, 0xB0, 0x3B, 0xFD, 0x48, 
-    0x0A, 0x4F, 0x10, 0x75, 0xDE, 0x20, 0x6F, 0xF0, 0xE7, 0x10, 0xFF, 0xC8, 
-    0x0D, 0x4B, 0xB3, 0x74, 0xDC, 0x30, 0x35, 0x1D, 0x92, 0x7C, 0x4A, 0x04, 
-    0x50, 0x59, 0xE4, 0x0B, 0xCD, 0xF7, 0x7C, 0x8B, 0x35, 0x00, 0x19, 0xE0, 
-    0x00, 0x9F, 0x33, 0x23, 0x9F, 0x66, 0x53, 0x53, 0x61, 0x00, 0x75, 0xE6, 
-    0x6C, 0x99, 0x30, 0x84, 0xD4, 0xA3, 0x62, 0x82, 0xF8, 0x81, 0x27, 0xE6, 
-    0x91, 0xA7, 0x50, 0x4D, 0x33, 0x05, 0x70, 0xB6, 0xD8, 0x94, 0xA6, 0x98, 
-    0x2E, 0xD7, 0x26, 0x33, 0xCD, 0xA2, 0x5B, 0xE7, 0x57, 0x5C, 0xB8, 0x65, 
-    0x5D, 0x6E, 0xD4, 0x0D, 0xBB, 0xD3, 0x6E, 0xA4, 0x50, 0x8C, 0xCB, 0xE8, 
-    0x0D, 0x71, 0x64, 0x82, 0xCA, 0x68, 0x44, 0x22, 0x25, 0x6E, 0x3C, 0x41, 
-    0x02, 0xC3, 0x33, 0x47, 0x46, 0xE9, 0x20, 0x03, 0xD1, 0x27, 0xFE, 0x25, 
-    0x08, 0xA6, 0x17, 0x27, 0xEF, 0x28, 0x2F, 0xC5, 0x35, 0x76, 0xA3, 0xA0, 
-    0x87, 0xB7, 0x70, 0x09, 0x5E, 0x21, 0x4A, 0xB0, 0x10, 0x4C, 0x15, 0xF9, 
-    0x95, 0x10, 0x31, 0x45, 0xA2, 0x43, 0x85, 0x78, 0x92, 0x8D, 0x8E, 0x20, 
-    0x7A, 0x64, 0xD6, 0x91, 0x6F, 0xE8, 0x81, 0x8D, 0xD0, 0x7C, 0xDC, 0x58, 
-    0x3B, 0x5A, 0xFE, 0xF2, 0x82, 0x71, 0x29, 0x00, 0x2C, 0xC8, 0x85, 0x99, 
-    0xE2, 0x0D, 0xE3, 0xA0, 0x7B, 0xFE, 0x68, 0x97, 0xDF, 0xE0, 0x31, 0x41, 
-    0x49, 0x43, 0xF8, 0x43, 0x83, 0x10, 0x84, 0x90, 0xBE, 0x10, 0x4C, 0xB8, 
-    0x38, 0x01, 0x34, 0x16, 0x27, 0x2E, 0x19, 0x09, 0x8C, 0x79, 0x95, 0x95, 
-    0x81, 0x98, 0x24, 0xC1, 0x92, 0x03, 0x30, 0x8B, 0xB3, 0xB7, 0x6F, 0x97, 
-    0x19, 0x0A, 0x5B, 0xC7, 0x84, 0xE8, 0x17, 0x27, 0xA3, 0xD9, 0x0B, 0x06, 
-    0x80, 0x96, 0xEA, 0x53, 0x29, 0xFC, 0x81, 0x8E, 0xDD, 0x46, 0x09, 0x7E, 
-    0x78, 0x9A, 0x70, 0x49, 0x93, 0xC2, 0x68, 0x0A, 0xEB, 0x24, 0x00, 0x4B, 
-    0x35, 0x75, 0x41, 0xE1, 0x93, 0x01, 0x50, 0x9B, 0x19, 0x32, 0x0E, 0x87, 
-    0x35, 0x42, 0x6B, 0x79, 0x0C, 0x8F, 0x52, 0x66, 0x84, 0x30, 0x01, 0x14, 
-    0xE0, 0x4B, 0x38, 0xC3, 0x96, 0x91, 0xD4, 0x91, 0x9D, 0xA0, 0x7D, 0x2B, 
-    0xC1, 0x0F, 0x4C, 0x64, 0x92, 0x74, 0x27, 0x12, 0x6E, 0xE9, 0x9C, 0xFC, 
-    0xF6, 0x26, 0xBB, 0x28, 0x76, 0x27, 0x50, 0x01, 0x25, 0x40, 0x63, 0x2F, 
-    0x63, 0x02, 0x57, 0x74, 0x02, 0x16, 0xE0, 0x12, 0x72, 0x17, 0x7A, 0x89, 
-    0x28, 0x42, 0x21, 0x92, 0x9A, 0xE1, 0x99, 0x8C, 0xA5, 0x60, 0x4B, 0xB3, 
-    0xB9, 0x71, 0xE8, 0x59, 0x72, 0xE0, 0xE0, 0x13, 0xB6, 0xF9, 0x0D, 0xC1, 
-    0x98, 0x2A, 0x22, 0xE4, 0x15, 0x62, 0x09, 0x0B, 0x68, 0x83, 0x2F, 0x2A, 
-    0x16, 0x50, 0x53, 0xE8, 0x50, 0x36, 0x67, 0x91, 0xC0, 0x79, 0x37, 0x28, 
-    0x59, 0x09, 0xED, 0x93, 0x99, 0xF1, 0xD9, 0x9D, 0x05, 0xFA, 0x09, 0x76, 
-    0x33, 0x99, 0x0B, 0x86, 0x23, 0x8B, 0xA4, 0x16, 0x66, 0x53, 0x77, 0x70, 
-    0x52, 0x46, 0x43, 0x18, 0x5D, 0x9F, 0xD4, 0x8B, 0xE3, 0xD3, 0x46, 0x19, 
-    0xAA, 0x85, 0x02, 0xB0, 0xA1, 0xFE, 0xA5, 0xA0, 0x40, 0xE5, 0x14, 0x00, 
-    0x64, 0x28, 0x00, 0x4C, 0x20, 0x14, 0xB7, 0xB7, 0x29, 0x7D, 0xA9, 0x1D, 
-    0xC3, 0xA3, 0x3F, 0xE3, 0x33, 0x39, 0xCC, 0xD4, 0x0B, 0x8F, 0x82, 0x54, 
-    0x9A, 0x20, 0x71, 0x9F, 0x97, 0x19, 0x54, 0x28, 0xA3, 0xBD, 0xB4, 0x3D, 
-    0xF8, 0x65, 0x15, 0x2B, 0x45, 0x09, 0x2A, 0x4A, 0x9A, 0xEB, 0xF8, 0x8A, 
-    0x3C, 0x6A, 0xA0, 0x18, 0x64, 0x80, 0x90, 0x39, 0x08, 0x93, 0xE3, 0x32, 
-    0x1A, 0xA0, 0x98, 0x03, 0xE1, 0x02, 0x64, 0x19, 0x49, 0x71, 0x3A, 0x15, 
-    0x62, 0x57, 0x2C, 0x10, 0x14, 0x31, 0xBA, 0x03, 0xA5, 0xA7, 0x00, 0x75, 
-    0x7C, 0x55, 0x58, 0xE2, 0xF9, 0x12, 0x75, 0xA9, 0x6E, 0x85, 0x45, 0xA2, 
-    0xF7, 0x73, 0x2D, 0x22, 0x94, 0x9C, 0x5C, 0xD9, 0x08, 0x41, 0x03, 0x85, 
-    0x83, 0x10, 0x6D, 0x1D, 0x98, 0xA6, 0x35, 0x37, 0x81, 0x85, 0xB0, 0x58, 
-    0x87, 0xF4, 0x08, 0x1B, 0x74, 0xA8, 0xE5, 0x13, 0x37, 0x81, 0xBA, 0x0C, 
-    0x0B, 0x69, 0xA7, 0x9B, 0x00, 0x1A, 0x62, 0x4A, 0x77, 0x03, 0x42, 0x08, 
-    0x5E, 0xA1, 0x2C, 0xCA, 0xE0, 0x01, 0xD4, 0xD9, 0x7A, 0x82, 0x7A, 0x02, 
-    0xC9, 0xB9, 0x63, 0x4A, 0x1A, 0xA4, 0x10, 0x94, 0x1C, 0x8A, 0x1A, 0xA5, 
-    0xA4, 0xF0, 0x6E, 0x7C, 0xD5, 0x64, 0xF7, 0xA8, 0x10, 0x24, 0xD7, 0x18, 
-    0x5C, 0xAA, 0x1D, 0xE4, 0xB6, 0x35, 0xE3, 0xE3, 0x3C, 0xB2, 0x0A, 0x09, 
-    0xC4, 0x72, 0x5C, 0xFD, 0x09, 0x87, 0xDC, 0xB9, 0x2E, 0x17, 0xD7, 0x55, 
-    0xCB, 0x90, 0x01, 0x94, 0x26, 0x8A, 0x18, 0xF9, 0x26, 0x59, 0xB4, 0x01, 
-    0xD7, 0x59, 0x3A, 0xAF, 0xCA, 0x09, 0x5E, 0xB1, 0x8B, 0x35, 0x55, 0xA6, 
-    0xF0, 0x75, 0x11, 0x8F, 0x90, 0x4D, 0x7F, 0xFA, 0x53, 0x7D, 0x07, 0x00, 
-    0x3B, 0x62, 0x96, 0x11, 0x95, 0x92, 0xA3, 0x5A, 0xFE, 0x33, 0x31, 0x11, 
-    0x89, 0xBB, 0x53, 0xAC, 0xA3, 0x60, 0x4B, 0x51, 0xE3, 0x31, 0x8E, 0xF8, 
-    0x12, 0x1B, 0xE6, 0x85, 0x1A, 0x77, 0x89, 0x8E, 0xE1, 0x38, 0x4D, 0xA3, 
-    0x9B, 0x84, 0x8A, 0x3E, 0xFA, 0x69, 0x9C, 0xDB, 0xA3, 0xAB, 0x02, 0x70, 
-    0x7D, 0x7E, 0x57, 0x02, 0x03, 0x36, 0x41, 0xD2, 0x97, 0x08, 0x5A, 0xA9, 
-    0x4F, 0x34, 0x35, 0x1C, 0x77, 0x87, 0xAE, 0x9C, 0x90, 0x9C, 0xF2, 0xA5, 
-    0x33, 0xF5, 0x05, 0x1A, 0xC5, 0x14, 0x1C, 0x9C, 0x86, 0x81, 0xED, 0x70, 
-    0x6D, 0x06, 0x26, 0x9A, 0xFC, 0xC4, 0x80, 0x23, 0x24, 0x0D, 0xB8, 0xE3, 
-    0xAF, 0xA8, 0xD0, 0x08, 0x3A, 0xF1, 0x25, 0xC3, 0xE8, 0x0C, 0x41, 0xE0, 
-    0x04, 0x42, 0xE0, 0xB3, 0x79, 0x49, 0x08, 0x4E, 0xC0, 0x61, 0x3C, 0x01, 
-    0x01, 0x7B, 0x49, 0x22, 0xC9, 0x83, 0x44, 0x22, 0x44, 0x63, 0x0B, 0x55, 
-    0x67, 0x27, 0x20, 0x01, 0xF6, 0xA9, 0xB2, 0x87, 0x12, 0xB3, 0x9D, 0x50, 
-    0x01, 0xF3, 0x14, 0x10, 0x20, 0x71, 0x39, 0x00, 0x20, 0x99, 0x8C, 0xE9, 
-    0x27, 0xF2, 0xC8, 0xA3, 0x76, 0x83, 0x94, 0x90, 0xB0, 0x41, 0xB8, 0x28, 
-    0x53, 0xF3, 0x85, 0x52, 0x01, 0x2A, 0x13, 0xC1, 0xA4, 0x48, 0xDA, 0x79, 
-    0x3E, 0x55, 0x09, 0x42, 0x31, 0x79, 0x2F, 0x98, 0xE2, 0x85, 0x35, 0x7B, 
-    0x0A, 0x0A, 0x34, 0x22, 0xE3, 0xA0, 0xAC, 0x82, 0x05, 0x09, 0x3C, 0x29, 
-    0x08, 0xC5, 0xE3, 0x78, 0x80, 0x64, 0xB4, 0x24, 0xF2, 0xA8, 0x02, 0x70, 
-    0xA2, 0xCC, 0x93, 0x9C, 0xDB, 0xF9, 0x66, 0xE6, 0x92, 0x80, 0x52, 0x6B, 
-    0x32, 0x49, 0x97, 0x02, 0xBE, 0x14, 0x15, 0x32, 0x41, 0x5F, 0x00, 0xE0, 
-    0xAB, 0x02, 0xD8, 0xA9, 0x21, 0x8B, 0x09, 0xCE, 0xA3, 0xA9, 0x02, 0xB0, 
-    0x41, 0x06, 0xE6, 0xAE, 0x03, 0x50, 0x80, 0xEB, 0xD8, 0x92, 0x99, 0xFE, 
-    0x51, 0x41, 0x86, 0x99, 0xB9, 0x71, 0xC5, 0x39, 0xC9, 0xC6, 0x0A, 0xF5, 
-    0x25, 0x42, 0x3A, 0x00, 0x6F, 0x1A, 0x8A, 0x0A, 0xC5, 0x33, 0x31, 0x57, 
-    0x6A, 0x0E, 0x1E, 0x07, 0x0B, 0x8B, 0x27, 0x08, 0x0A, 0x14, 0xB8, 0xDE, 
-    0xF0, 0x00, 0x09, 0xAB, 0x1D, 0x71, 0x14, 0xAD, 0xCC, 0xC3, 0x44, 0xBB, 
-    0xC8, 0x86, 0xAE, 0x22, 0xAF, 0xBA, 0x92, 0x8A, 0xF8, 0x52, 0xAA, 0xAC, 
-    0x77, 0x6D, 0xFF, 0xB9, 0x12, 0x21, 0x00, 0xB7, 0xCE, 0x49, 0x09, 0x61, 
-    0x06, 0x49, 0x39, 0x12, 0xAB, 0x90, 0xE0, 0x8A, 0xB7, 0x32, 0x15, 0xCD, 
-    0x6B, 0xA6, 0x2D, 0x03, 0x70, 0xC3, 0x51, 0x9C, 0xA8, 0x13, 0x13, 0xED, 
-    0x47, 0xB7, 0xA6, 0xD0, 0xA8, 0x78, 0x44, 0x89, 0xD0, 0x40, 0x72, 0xB0, 
-    0xE0, 0x74, 0x75, 0xF9, 0x4A, 0xA9, 0x84, 0xB4, 0x84, 0x0B, 0x41, 0x12, 
-    0xE7, 0x72, 0x0E, 0x57, 0x28, 0x2B, 0x0B, 0x0B, 0xDB, 0x58, 0x20, 0x68, 
-    0xF6, 0xAD, 0xA4, 0x2B, 0x12, 0xEC, 0xA2, 0x84, 0x95, 0xA0, 0xAF, 0x21, 
-    0xFB, 0x7F, 0x08, 0x50, 0x11, 0x94, 0x60, 0x57, 0x29, 0x4A, 0x17, 0xC1, 
-    0xE0, 0x55, 0xA3, 0xE9, 0x7A, 0xAC, 0x4B, 0x08, 0x19, 0x09, 0x80, 0x64, 
-    0x51, 0x73, 0xFB, 0x39, 0x42, 0x3E, 0x10, 0x52, 0xE5, 0x4B, 0x78, 0x50, 
-    0x17, 0x9B, 0x00, 0xB0, 0x4E, 0x07, 0x00, 0x1D, 0x40, 0xEB, 0x0C, 0x20, 
-    0xD5, 0x0B, 0x3C, 0x49, 0x72, 0x91, 0x98, 0x4A, 0xD0, 0x8A, 0x86, 0xA9, 
-    0xE3, 0xAB, 0xF7, 0x6A, 0x00, 0x1A, 0xD0, 0x02, 0x0E, 0xD0, 0x02, 0xF6, 
-    0x30, 0x1F, 0xFA, 0xDB, 0x0F, 0x18, 0xAB, 0x00, 0x9D, 0x49, 0x53, 0x6F, 
-    0x7A, 0x33, 0x20, 0x8B, 0xB9, 0x79, 0x68, 0x42, 0xC7, 0x40, 0x2C, 0x15, 
-    0xB0, 0x8A, 0xE5, 0x81, 0x28, 0x4C, 0xE2, 0x1B, 0xA0, 0xE5, 0x0B, 0x46, 
-    0x78, 0x7A, 0xFE, 0xF8, 0xF2, 0x2E, 0xC0, 0xE1, 0x7A, 0xC6, 0xC5, 0x4B, 
-    0x31, 0x60, 0x55, 0x3A, 0xA1, 0xC1, 0x9C, 0x10, 0x04, 0xB3, 0x26, 0x00, 
-    0xE9, 0x4B, 0x9E, 0xF6, 0x08, 0x0D, 0x2E, 0xD8, 0x0B, 0x73, 0x09, 0x00, 
-    0x1B, 0x76, 0x55, 0x4C, 0xE5, 0x57, 0x49, 0x04, 0x41, 0x0A, 0x95, 0x8E, 
-    0x2E, 0x95, 0xBC, 0xC7, 0x62, 0xB5, 0x13, 0x2B, 0xB6, 0xB7, 0xF0, 0x8D, 
-    0x0A, 0xFA, 0xC3, 0xA1, 0x00, 0x50, 0x4A, 0x0C, 0x09, 0xB2, 0x82, 0x01, 
-    0x93, 0x83, 0xB2, 0x02, 0x50, 0xB2, 0x83, 0xA0, 0x62, 0xB1, 0xD1, 0x02, 
-    0x98, 0x01, 0x0B, 0x12, 0xF8, 0x09, 0x3B, 0x52, 0x67, 0xD8, 0xE7, 0x8B, 
-    0x38, 0x01, 0x01, 0xE3, 0xF0, 0xAF, 0x4F, 0xF7, 0x08, 0x36, 0xD9, 0xC5, 
-    0x58, 0x0A, 0x0D, 0x50, 0xE7, 0x0B, 0x62, 0x2C, 0xB4, 0x54, 0x9A, 0x57, 
-    0x71, 0xF4, 0xA5, 0xCC, 0xD3, 0x53, 0xE9, 0x68, 0x00, 0x05, 0x95, 0x0B, 
-    0x90, 0xBB, 0xB9, 0x95, 0xB6, 0x8E, 0x04, 0x5A, 0xC7, 0x9D, 0x70, 0xC7, 
-    0x20, 0x51, 0x5C, 0x12, 0x30, 0x29, 0x98, 0x45, 0x09, 0xB8, 0xA8, 0x86, 
-    0x8D, 0x50, 0x1F, 0x84, 0xDC, 0x08, 0xAE, 0x67, 0x99, 0x99, 0xE0, 0xA2, 
-    0xA4, 0x15, 0xBD, 0x91, 0xC3, 0x17, 0x4B, 0xA3, 0xB3, 0x42, 0x04, 0x0B, 
-    0xC9, 0xD8, 0xC5, 0xE9, 0xFB, 0x0C, 0x24, 0x1C, 0xC6, 0x83, 0x50, 0x3C, 
-    0xED, 0x97, 0x5A, 0xBB, 0x13, 0xBC, 0xCC, 0x43, 0x63, 0xE0, 0x37, 0x57, 
-    0xD2, 0x89, 0x08, 0x64, 0x55, 0x48, 0x85, 0xA2, 0xC3, 0x9E, 0x49, 0x96, 
-    0x10, 0x9C, 0xCA, 0xF8, 0xD2, 0x11, 0x8B, 0xC9, 0x14, 0x2C, 0xF5, 0x08, 
-    0xFC, 0xD2, 0x58, 0x42, 0x2A, 0x17, 0x02, 0xA5, 0x08, 0x02, 0xC1, 0xC4, 
-    0x8C, 0x36, 0x0A, 0xFC, 0xF1, 0x42, 0xD3, 0x74, 0x13, 0x2F, 0xF0, 0x25, 
-    0xAC, 0xC9, 0x7B, 0xB0, 0x60, 0xFE, 0x6E, 0x5D, 0x2C, 0xC2, 0xA8, 0xD0, 
-    0xA1, 0x97, 0x3C, 0x08, 0x0A, 0x54, 0x6B, 0x17, 0xE5, 0x57, 0x81, 0x39, 
-    0x3E, 0x3C, 0x97, 0xCD, 0xD5, 0x49, 0x9C, 0x66, 0xCA, 0xBF, 0xF7, 0x0A, 
-    0x20, 0xD7, 0x89, 0x01, 0x03, 0xDC, 0xCD, 0x83, 0x40, 0x09, 0xE7, 0x73, 
-    0x4C, 0x08, 0x01, 0x1F, 0xB3, 0x08, 0x49, 0x8A, 0xF4, 0xB9, 0x8E, 0x60, 
-    0x8B, 0x19, 0xE0, 0x50, 0x0E, 0x2D, 0x08, 0xC0, 0x19, 0xBE, 0x22, 0x74, 
-    0x13, 0x1F, 0x90, 0x4B, 0xF4, 0xAC, 0x09, 0x5D, 0xEC, 0x08, 0xF7, 0xEC, 
-    0x08, 0xD7, 0xB0, 0xBE, 0xBD, 0x10, 0x7C, 0xC5, 0x58, 0xC6, 0xA9, 0x15, 
-    0x00, 0x9D, 0x92, 0x9B, 0xCC, 0x13, 0xC0, 0xCF, 0x63, 0x36, 0xD4, 0x4C, 
-    0x00, 0x2A, 0x75, 0xB1, 0xCB, 0x90, 0xC3, 0xB9, 0xF2, 0xA0, 0xAC, 0xE0, 
-    0xC3, 0x0F, 0x3D, 0x0A, 0xB6, 0xDA, 0x0B, 0xC7, 0x64, 0x09, 0x9F, 0x6B, 
-    0x92, 0xD9, 0x64, 0x50, 0x5A, 0x46, 0x50, 0xAE, 0x92, 0xCB, 0x11, 0x57, 
-    0x14, 0x04, 0x70, 0xB9, 0xBC, 0xA4, 0x25, 0x7F, 0x83, 0xBE, 0x9F, 0x80, 
-    0xD2, 0x83, 0xE6, 0xC1, 0xEC, 0x76, 0x0D, 0x38, 0x79, 0x0C, 0x1C, 0x57, 
-    0x55, 0x9A, 0x1C, 0x00, 0x1F, 0x80, 0x3F, 0xBB, 0x8B, 0x34, 0x7E, 0x85, 
-    0x72, 0x10, 0xB4, 0x68, 0xD9, 0x3A, 0x1F, 0x3A, 0x7D, 0x5C, 0x55, 0x8B, 
-    0x80, 0x70, 0x4C, 0x15, 0x5C, 0x4B, 0xC7, 0x44, 0x4D, 0x0A, 0x61, 0x95, 
-    0xC7, 0x91, 0x74, 0x09, 0xAC, 0xD1, 0xC7, 0xFA, 0x96, 0x08, 0x7C, 0xE3, 
-    0xD4, 0x3B, 0x0C, 0x27, 0xF3, 0x39, 0x0A, 0x5E, 0xB6, 0xA6, 0xD3, 0x54, 
-    0x38, 0x46, 0x44, 0xBB, 0x9E, 0xB0, 0xD5, 0xF0, 0x47, 0x9E, 0x62, 0xEC, 
-    0x0C, 0xB6, 0xEB, 0x0B, 0x8B, 0xB7, 0x61, 0xED, 0x27, 0x3C, 0x8E, 0x80, 
-    0x02, 0x95, 0x3A, 0x2D, 0xCA, 0xA3, 0x44, 0x6D, 0xFE, 0x2D, 0x9C, 0xA2, 
-    0x25, 0xAA, 0xBA, 0x4C, 0xCA, 0xB9, 0x42, 0x88, 0x29, 0x59, 0xD5, 0x78, 
-    0xDD, 0x24, 0xF0, 0xB9, 0x80, 0x9A, 0x25, 0x08, 0x93, 0xA2, 0xA2, 0x92, 
-    0x55, 0xCE, 0x2B, 0x34, 0xD8, 0x41, 0x13, 0x49, 0x5E, 0xDB, 0x2E, 0xBD, 
-    0x5C, 0x3B, 0x3A, 0x70, 0x1D, 0x8C, 0xB1, 0x3B, 0x79, 0x2B, 0x08, 0x5B, 
-    0x1D, 0x7C, 0xE4, 0x69, 0xCC, 0xCE, 0xA0, 0xC5, 0xB0, 0xC0, 0x93, 0x50, 
-    0xD7, 0x4E, 0xE7, 0x24, 0x31, 0xEA, 0x06, 0x38, 0x8F, 0x2A, 0x48, 0x6C, 
-    0x2D, 0x41, 0xE1, 0x38, 0x1A, 0x1F, 0xB4, 0xA6, 0xD7, 0x9C, 0x08, 0x2A, 
-    0x80, 0xBF, 0xE6, 0xB1, 0xCD, 0xBA, 0x8D, 0xD7, 0x93, 0x92, 0x45, 0x54, 
-    0xA8, 0x42, 0x23, 0x0B, 0x09, 0x03, 0xE3, 0x96, 0xA0, 0x11, 0xDE, 0xCC, 
-    0x12, 0x01, 0x29, 0x20, 0x01, 0x21, 0x5D, 0x5B, 0x3A, 0xD0, 0x4A, 0xB8, 
-    0xE3, 0x31, 0xF9, 0x9C, 0x09, 0x2D, 0xBD, 0x9A, 0xC1, 0x5D, 0x6E, 0xD7, 
-    0x70, 0xDC, 0x90, 0xB0, 0xA1, 0x28, 0x78, 0x31, 0x9A, 0xCD, 0xD9, 0x48, 
-    0xB3, 0x3B, 0x9E, 0x38, 0xBF, 0x12, 0x94, 0x01, 0x68, 0xCB, 0x9B, 0xB6, 
-    0x28, 0xA3, 0xDD, 0xCA, 0x0A, 0x07, 0x6E, 0xDA, 0x0C, 0xED, 0xD1, 0xAA, 
-    0xAD, 0x96, 0x72, 0x22, 0x00, 0x54, 0xC8, 0x45, 0x7A, 0x6D, 0xB6, 0x47, 
-    0x95, 0x09, 0xB0, 0xFD, 0x08, 0xC4, 0xE6, 0x91, 0xA8, 0xC9, 0x5A, 0x3E, 
-    0x51, 0xDC, 0x9A, 0xB0, 0xCF, 0xC8, 0x88, 0xDF, 0xF7, 0x0D, 0x0D, 0xFB, 
-    0xED, 0x08, 0x36, 0x09, 0x00, 0x94, 0xED, 0x08, 0x0B, 0xE0, 0xDC, 0x33, 
-    0x94, 0x4B, 0xEE, 0x39, 0x42, 0xFD, 0x66, 0x14, 0x2E, 0xDC, 0x50, 0xCB, 
-    0x50, 0x7B, 0x3D, 0xCD, 0x0A, 0x2D, 0x50, 0xD0, 0x1E, 0x2B, 0xD4, 0xDE, 
-    0x29, 0xE1, 0xA3, 0x40, 0x63, 0xD9, 0xF3, 0xA6, 0x92, 0x32, 0xBA, 0xFE, 
-    0xB0, 0xB0, 0xA3, 0x65, 0x85, 0x6F, 0x1D, 0x4E, 0x1B, 0xE5, 0xD8, 0xA4, 
-    0x21, 0x0A, 0x90, 0x8D, 0xDD, 0x09, 0x0A, 0xB4, 0xD2, 0x82, 0x60, 0xC9, 
-    0x26, 0x7D, 0x0A, 0x2A, 0xCE, 0xD5, 0x00, 0x80, 0x82, 0x8E, 0x00, 0x01, 
-    0x28, 0x9C, 0x57, 0x56, 0x5A, 0xD3, 0x22, 0xB4, 0xCB, 0x4D, 0xE9, 0x22, 
-    0xA2, 0xB1, 0x01, 0x32, 0x72, 0x9D, 0xC0, 0x16, 0xC1, 0xF3, 0x94, 0xAB, 
-    0xB9, 0x12, 0x81, 0xCB, 0x70, 0xD7, 0x43, 0x9E, 0x0A, 0x12, 0xDC, 0xC6, 
-    0xEB, 0x15, 0xD1, 0x29, 0x63, 0x15, 0x7D, 0x6D, 0x14, 0x90, 0xE0, 0xE1, 
-    0x7F, 0xC8, 0x3F, 0x7F, 0xCB, 0x0D, 0xE3, 0x80, 0xBB, 0x9B, 0x00, 0xC6, 
-    0x3C, 0x49, 0x44, 0x28, 0xFE, 0x0C, 0x96, 0x0C, 0x0B, 0x41, 0xA4, 0x04, 
-    0xC8, 0x8C, 0x02, 0xEF, 0x2B, 0xD3, 0xFB, 0x28, 0x47, 0xD2, 0xC8, 0x94, 
-    0xD3, 0x77, 0x8B, 0x84, 0xF0, 0xB8, 0x6D, 0x6A, 0xDA, 0x1A, 0x78, 0x01, 
-    0xA9, 0x6D, 0xE7, 0xA4, 0x50, 0x25, 0x16, 0x54, 0x12, 0x43, 0xDA, 0x0B, 
-    0xB6, 0x8D, 0x52, 0x1F, 0x31, 0x30, 0x65, 0x4A, 0x81, 0x39, 0x74, 0x3C, 
-    0x8A, 0x8A, 0x6B, 0x9D, 0xB0, 0x61, 0x8A, 0x27, 0x08, 0xFB, 0xAC, 0xE5, 
-    0xA6, 0xD0, 0x7B, 0x90, 0xD0, 0x6E, 0x4A, 0x60, 0xE5, 0xCD, 0x5D, 0xE9, 
-    0x58, 0x25, 0x00, 0xD1, 0xDD, 0x45, 0x9D, 0xAE, 0xE9, 0x47, 0x85, 0x49, 
-    0xD8, 0x8D, 0x08, 0xDA, 0x9D, 0x2B, 0xB5, 0xB8, 0x0C, 0xD0, 0x3B, 0xEA, 
-    0x07, 0x36, 0x6A, 0x53, 0xBB, 0xA7, 0x78, 0xAA, 0xB1, 0x70, 0xE2, 0x48, 
-    0x88, 0x82, 0xCA, 0x08, 0x87, 0xC1, 0x56, 0x25, 0xE6, 0x4C, 0x47, 0xE5, 
-    0x9D, 0xA0, 0x04, 0x7B, 0xB4, 0xEB, 0x8C, 0xBE, 0xB3, 0xBF, 0xEE, 0x08, 
-    0x46, 0x30, 0x04, 0x56, 0xAE, 0x64, 0xC1, 0x2E, 0x68, 0x6B, 0x3D, 0x48, 
-    0x05, 0x90, 0xFE, 0x02, 0x18, 0xBB, 0x12, 0x11, 0x9A, 0x09, 0xBE, 0xE4, 
-    0xE0, 0x7A, 0x62, 0x9D, 0x3A, 0x1E, 0xE1, 0x43, 0x5E, 0x00, 0xEA, 0xE0, 
-    0x6C, 0xF0, 0x51, 0xA7, 0x84, 0xE0, 0x3C, 0x08, 0x7E, 0xCB, 0xD8, 0x9E, 
-    0xBF, 0x89, 0x10, 0xD5, 0x66, 0x16, 0xE5, 0xFF, 0x2C, 0x94, 0x8D, 0x70, 
-    0xE8, 0x9B, 0x30, 0x04, 0x40, 0xA0, 0xE2, 0xB9, 0xAE, 0xEB, 0xED, 0xD0, 
-    0xEE, 0xEE, 0xDE, 0x0D, 0x4D, 0x46, 0xEC, 0x83, 0x34, 0x01, 0x12, 0xD0, 
-    0x00, 0xBE, 0xD4, 0x00, 0x14, 0x60, 0x01, 0x28, 0x96, 0xC4, 0x3F, 0x1E, 
-    0xD4, 0x91, 0x24, 0xE4, 0xD1, 0xBE, 0x92, 0x5E, 0xC1, 0xCD, 0xBF, 0x25, 
-    0xC5, 0x99, 0xE0, 0x3C, 0x0A, 0x9D, 0x0C, 0x9B, 0x81, 0x00, 0xB6, 0xFC, 
-    0x08, 0x22, 0x21, 0xEA, 0x32, 0xE6, 0x3B, 0x29, 0x68, 0x2A, 0xF9, 0xBD, 
-    0x09, 0x41, 0x80, 0xD2, 0x81, 0x31, 0x03, 0x68, 0x62, 0xF1, 0xE6, 0x6B, 
-    0xE5, 0x42, 0x80, 0xCC, 0x19, 0xAF, 0xF1, 0xDD, 0xD0, 0x40, 0x02, 0x6D, 
-    0x66, 0x34, 0xB6, 0xDD, 0xA2, 0x55, 0x67, 0x5D, 0xCB, 0xF2, 0xA1, 0xF0, 
-    0x6B, 0xA6, 0x79, 0x98, 0x16, 0x0C, 0x00, 0x7B, 0xFE, 0x32, 0x88, 0x32, 
-    0xDB, 0x70, 0xC7, 0x3F, 0x68, 0xED, 0x0D, 0x84, 0x41, 0x04, 0x9B, 0xE0, 
-    0xE2, 0x2C, 0xF0, 0xBE, 0x8E, 0x43, 0xB0, 0xD7, 0x70, 0x04, 0xB1, 0xB6, 
-    0xEB, 0x4C, 0xDF, 0xF4, 0xE1, 0xF0, 0x31, 0x99, 0x26, 0xC1, 0x78, 0x2C, 
-    0x37, 0xA0, 0xBE, 0xF3, 0x57, 0xEF, 0xA9, 0xF7, 0xA9, 0x3E, 0xA7, 0xF0, 
-    0x26, 0x3F, 0xEE, 0x08, 0x1B, 0xA4, 0xF5, 0x32, 0x16, 0x13, 0x02, 0x40, 
-    0xE8, 0x3B, 0xD1, 0x1D, 0x3A, 0x5B, 0x04, 0xB3, 0xD6, 0x17, 0x62, 0xDE, 
-    0x64, 0x94, 0x9C, 0x10, 0x8B, 0x2E, 0xF7, 0x73, 0xCF, 0x0D, 0x71, 0x44, 
-    0x52, 0x00, 0xB6, 0x75, 0xA1, 0xFE, 0xED, 0xEC, 0xAB, 0xEB, 0xDD, 0x78, 
-    0x7D, 0xD3, 0xD4, 0x2E, 0x0A, 0x33, 0xFF, 0x32, 0x41, 0xC3, 0xF5, 0x0C, 
-    0xDF, 0x08, 0xB1, 0xDE, 0x18, 0xC1, 0x38, 0x97, 0x47, 0xE0, 0x04, 0x56, 
-    0x0E, 0x01, 0x94, 0x3E, 0x5B, 0x8D, 0xA0, 0x10, 0xBB, 0xEE, 0xBB, 0x96, 
-    0xCF, 0x0D, 0x84, 0xB1, 0x02, 0x99, 0xAF, 0x5E, 0x92, 0xF9, 0x6F, 0xFB, 
-    0x4E, 0x66, 0xFD, 0x1E, 0xED, 0xE5, 0xE3, 0x01, 0x29, 0xDF, 0x2F, 0xA4, 
-    0x00, 0x30, 0xA5, 0x9C, 0x14, 0x1B, 0x64, 0xD8, 0x08, 0x17, 0x03, 0xC9, 
-    0xC1, 0x5A, 0x8E, 0x31, 0xB8, 0x14, 0xEF, 0x08, 0x22, 0xE0, 0xF0, 0x88, 
-    0x66, 0xE2, 0xE7, 0x50, 0x78, 0xE0, 0x84, 0xFB, 0x3B, 0xF1, 0xA8, 0xBB, 
-    0x9F, 0x69, 0x24, 0x46, 0xBC, 0x8E, 0x60, 0xFC, 0x9C, 0xB1, 0xF2, 0x23, 
-    0x66, 0x01, 0x12, 0x10, 0x02, 0x0D, 0xC0, 0xFE, 0x66, 0x64, 0x01, 0xA7, 
-    0xFF, 0xAA, 0x24, 0x26, 0x57, 0x54, 0xA8, 0xC8, 0x1B, 0x31, 0x98, 0xB9, 
-    0x22, 0x2B, 0x7B, 0xAF, 0x5E, 0xDA, 0x72, 0xFD, 0x3F, 0xFF, 0x08, 0x07, 
-    0x00, 0x08, 0x0B, 0x09, 0x01, 0x84, 0x85, 0x86, 0x85, 0x30, 0x02, 0x02, 
-    0x40, 0x00, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x00, 0x42, 0x8A, 0x07, 
-    0x83, 0x87, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x99, 0x22, 0x8A, 0x2B, 0x3B, 
-    0x93, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xA9, 0x21, 0x03, 
-    0xAF, 0x03, 0x0C, 0x8A, 0xB3, 0xB4, 0x20, 0x0E, 0xB0, 0xB0, 0x27, 0x15, 
-    0xA7, 0x11, 0x21, 0x18, 0xB8, 0xC0, 0xB8, 0x27, 0x16, 0x05, 0xAC, 0xC6, 
-    0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0x91, 0xBF, 0xAF, 0x08, 0x06, 0xB3, 0x20, 
-    0x08, 0xB8, 0x04, 0x13, 0xAA, 0x15, 0xB8, 0x1A, 0xB4, 0xDC, 0xDD, 0xDD, 
-    0x06, 0xD4, 0xAF, 0x0D, 0xCC, 0xE4, 0xE5, 0xE6, 0xFE, 0xE6, 0x3B, 0x8A, 
-    0x23, 0x9E, 0x86, 0x1D, 0xB4, 0x22, 0x24, 0xEC, 0x85, 0x0F, 0x8A, 0x4C, 
-    0xE7, 0x41, 0xB3, 0x0B, 0xF2, 0xFB, 0xFC, 0x9E, 0x09, 0x2C, 0xB3, 0x7E, 
-    0x9C, 0x1B, 0x48, 0xB0, 0xA0, 0xA3, 0x02, 0x04, 0x60, 0x65, 0xF0, 0x66, 
-    0x40, 0x41, 0xB0, 0x0B, 0x25, 0x4C, 0x4D, 0xA0, 0x90, 0x30, 0x98, 0x45, 
-    0x60, 0x14, 0x22, 0x18, 0xDC, 0xC8, 0xB1, 0x23, 0xA9, 0x09, 0xB8, 0x5C, 
-    0x70, 0x03, 0xE1, 0xA1, 0xDA, 0xB5, 0x54, 0x0D, 0x60, 0x41, 0xF3, 0xC6, 
-    0x92, 0xDB, 0x2D, 0x58, 0x27, 0x3D, 0xCA, 0x9C, 0xA9, 0xCA, 0x86, 0x22, 
-    0x7D, 0xF2, 0x3E, 0x00, 0x14, 0x00, 0x61, 0x04, 0x26, 0x7E, 0x09, 0x0E, 
-    0x28, 0x0A, 0x62, 0xAE, 0xC8, 0xAC, 0x78, 0xFD, 0x92, 0x2A, 0x9D, 0xE7, 
-    0x4E, 0xC0, 0x0D, 0x9A, 0x50, 0xA3, 0x02, 0x28, 0x81, 0x4B, 0x01, 0x37, 
-    0x06, 0x19, 0x82, 0x85, 0x28, 0x36, 0xA9, 0x40, 0x8A, 0x0B, 0x17, 0xC3, 
-    0x5A, 0x6C, 0x10, 0x53, 0xAA, 0xD9, 0xB3, 0xA4, 0x5C, 0xBD, 0x5A, 0xF8, 
-    0xAD, 0x24, 0x2C, 0x02, 0x1A, 0x51, 0x45, 0xC0, 0xE5, 0xA1, 0xA5, 0x5D, 
-    0x0E, 0xB8, 0x42, 0xA0, 0xDD, 0x2B, 0x33, 0xC6, 0x0A, 0x01, 0x28, 0xF6, 
-    0x7D, 0xB0, 0xB4, 0x6E, 0x69, 0x80, 0xC1, 0x02, 0x8A, 0x94, 0x0B, 0xD2, 
-    0xE4, 0xA6, 0xE1, 0xC7, 0xFD, 0x12, 0x34, 0x7D, 0xCA, 0xB7, 0x32, 0xB9, 
-    0x94, 0xB0, 0x36, 0x28, 0x32, 0xA0, 0x22, 0x18, 0x86, 0xB8, 0x92, 0x0A, 
-    0x48, 0xA8, 0x78, 0xD1, 0x41, 0x0B, 0x05, 0x0A, 0x5C, 0xA0, 0x6E, 0xF1, 
-    0xD2, 0xE2, 0x56, 0xCB, 0xB0, 0xA1, 0x62, 0x1E, 0x60, 0x82, 0xA5, 0x01, 
-    0xB7, 0xB0, 0x2C, 0xB4, 0xC2, 0xC5, 0x21, 0x9A, 0x5D, 0x6E, 0x1A, 0x70, 
-    0x61, 0xE0, 0x1A, 0xBB, 0xF8, 0x32, 0x1E, 0x8A, 0x1E, 0xB0, 0x23, 0xFE, 
-    0x01, 0x4A, 0xC0, 0x8B, 0x9F, 0x86, 0x21, 0x08, 0x68, 0x52, 0xCE, 0x88, 
-    0xA2, 0xC0, 0x90, 0xB3, 0xCB, 0x93, 0xAC, 0x48, 0x86, 0xF1, 0xEF, 0xA8, 
-    0x2A, 0x90, 0x76, 0x20, 0xC0, 0x44, 0xB8, 0xB7, 0x12, 0x48, 0x89, 0x26, 
-    0x0D, 0xCC, 0x81, 0x09, 0x10, 0xBF, 0x5D, 0x70, 0x38, 0x0F, 0x0B, 0x43, 
-    0x59, 0xF0, 0xF8, 0x97, 0x91, 0x96, 0x65, 0xBB, 0x33, 0x2E, 0xDD, 0xA7, 
-    0x14, 0xE0, 0xCC, 0x2B, 0x1E, 0x68, 0xF6, 0x9B, 0x22, 0x0E, 0xBD, 0x75, 
-    0x5F, 0x7E, 0x0C, 0x4E, 0xD2, 0x83, 0x22, 0x2C, 0x78, 0xF2, 0x40, 0x73, 
-    0x07, 0x20, 0x95, 0xDD, 0x08, 0x8A, 0x20, 0xB1, 0x4C, 0x10, 0x4B, 0xCC, 
-    0x32, 0x83, 0x76, 0x20, 0x7A, 0xF2, 0x81, 0x50, 0x02, 0xD8, 0xD0, 0xE0, 
-    0x89, 0x00, 0x48, 0x80, 0x4B, 0x56, 0xC0, 0x34, 0xB0, 0xCB, 0x24, 0x25, 
-    0xB0, 0x07, 0x8B, 0x07, 0x26, 0xF8, 0x76, 0xE0, 0x66, 0x1A, 0xB0, 0xA8, 
-    0x20, 0x8A, 0x3C, 0xA6, 0x82, 0xCB, 0x6F, 0x1B, 0x00, 0x83, 0x41, 0x2A, 
-    0x13, 0xB0, 0x87, 0x40, 0x6D, 0x76, 0x6D, 0xE0, 0x1F, 0x2C, 0x11, 0xF5, 
-    0xE8, 0xA4, 0x5F, 0x02, 0x5C, 0xC2, 0xC9, 0x03, 0x3B, 0x75, 0xF0, 0x80, 
-    0x85, 0xDA, 0xB9, 0x43, 0x04, 0x51, 0xC8, 0x28, 0xD1, 0xD8, 0x2C, 0xD0, 
-    0x85, 0x28, 0xA6, 0x21, 0xF4, 0x08, 0x80, 0x43, 0x0C, 0x4E, 0xE2, 0x37, 
-    0x20, 0x30, 0x04, 0x34, 0x19, 0xDA, 0x09, 0x16, 0x71, 0x00, 0xDF, 0x8D, 
-    0x2C, 0x29, 0x40, 0x9F, 0x35, 0x69, 0xE6, 0x09, 0x09, 0x2E, 0x73, 0xB2, 
-    0x84, 0xDB, 0x00, 0xC3, 0xA9, 0x52, 0x24, 0x30, 0x19, 0x68, 0x60, 0xE3, 
-    0x2C, 0x1B, 0xD8, 0x09, 0x0C, 0x80, 0x7A, 0x9E, 0x88, 0x9C, 0x00, 0x30, 
-    0x6C, 0xF2, 0x40, 0x53, 0x02, 0x88, 0x10, 0xA6, 0x76, 0x24, 0x28, 0x62, 
-    0x04, 0x32, 0xFE, 0x40, 0x70, 0x83, 0xDD, 0x98, 0xA0, 0x1A, 0xF2, 0x82, 
-    0x22, 0x3C, 0x34, 0x5A, 0xDC, 0x5C, 0x5A, 0x11, 0x17, 0xC9, 0x04, 0x60, 
-    0x01, 0xC3, 0x81, 0x81, 0x74, 0xB6, 0xB4, 0xC1, 0x9F, 0x78, 0x9A, 0x9A, 
-    0xE6, 0x6C, 0xDB, 0xD4, 0x29, 0x9C, 0xAA, 0xA8, 0x08, 0x68, 0x91, 0x69, 
-    0xA8, 0xA9, 0xF0, 0xE7, 0x2B, 0x04, 0x30, 0x6A, 0x2B, 0x7E, 0x0F, 0x0A, 
-    0x10, 0xA1, 0x26, 0x0B, 0xCC, 0x72, 0xC0, 0x87, 0xA1, 0x06, 0x00, 0x83, 
-    0x50, 0x4E, 0xB0, 0x72, 0x44, 0x25, 0x80, 0x91, 0x08, 0x41, 0xB4, 0xDC, 
-    0x26, 0x80, 0x82, 0x22, 0x02, 0x1D, 0x5B, 0x99, 0x5A, 0xAF, 0x7C, 0x56, 
-    0xCA, 0xA0, 0xB8, 0xA8, 0x00, 0x6B, 0xAC, 0xBF, 0xE1, 0x05, 0xCB, 0x05, 
-    0xBC, 0x8A, 0x9B, 0x1F, 0x05, 0x0A, 0xB5, 0x74, 0x5E, 0xA0, 0xC7, 0xA8, 
-    0x28, 0xD6, 0x43, 0x0B, 0xCA, 0x0B, 0x1B, 0x94, 0x52, 0x1E, 0x42, 0x82, 
-    0x74, 0x8A, 0x40, 0x80, 0x65, 0xA8, 0x18, 0x0A, 0xB0, 0x29, 0x2A, 0x41, 
-    0x74, 0x0A, 0x61, 0x02, 0x65, 0x6E, 0xCB, 0x6D, 0xB4, 0x09, 0x0B, 0xD0, 
-    0x83, 0xBF, 0x68, 0x21, 0x34, 0x00, 0x01, 0xE9, 0x9D, 0x6B, 0xA4, 0x48, 
-    0xEC, 0xC6, 0xEA, 0xEE, 0x2B, 0x27, 0x60, 0x9C, 0x5F, 0x01, 0x15, 0xA0, 
-    0xFA, 0x0A, 0x92, 0x57, 0xE1, 0xD2, 0xAF, 0xA0, 0xB3, 0x89, 0xC5, 0x71, 
-    0xBC, 0x26, 0x57, 0x46, 0x83, 0x22, 0x91, 0x1E, 0xB2, 0x00, 0x89, 0x28, 
-    0x14, 0x36, 0x31, 0x21, 0xCD, 0x2A, 0x6C, 0xCA, 0x11, 0x40, 0x10, 0x61, 
-    0x09, 0x4E, 0x11, 0xFF, 0x1C, 0xED, 0xB7, 0x4E, 0xD5, 0x6C, 0x56, 0x09, 
-    0x2E, 0x9A, 0xA2, 0xF1, 0x8C, 0x87, 0x86, 0x7C, 0xE3, 0x9F, 0xA0, 0x39, 
-    0x0D, 0x1B, 0xBD, 0x27, 0x90, 0x86, 0xC0, 0xBA, 0x8A, 0x04, 0x57, 0x2E, 
-    0x39, 0x13, 0xB5, 0xEA, 0x59, 0xFE, 0x0A, 0x34, 0x6B, 0x8D, 0xD6, 0x0D, 
-    0x8E, 0x91, 0xC9, 0xF4, 0x01, 0x3E, 0x2B, 0x1D, 0x00, 0x09, 0x24, 0x36, 
-    0x51, 0x04, 0x97, 0x8E, 0x04, 0xF1, 0x44, 0x87, 0x47, 0xFF, 0x94, 0xB4, 
-    0xDC, 0x63, 0x96, 0x29, 0x00, 0x9A, 0x6A, 0x17, 0xB7, 0x66, 0x6F, 0x56, 
-    0x87, 0x0C, 0xCE, 0xBB, 0x85, 0x5B, 0x36, 0x35, 0x30, 0x1E, 0x54, 0x9D, 
-    0xE0, 0x00, 0xE3, 0x98, 0x93, 0xB2, 0x04, 0x98, 0xA7, 0x10, 0x41, 0xDA, 
-    0x8D, 0x9B, 0x95, 0x8E, 0xB2, 0x3A, 0xCF, 0xC2, 0xC2, 0xA5, 0x4A, 0x27, 
-    0x40, 0xF0, 0x6F, 0x07, 0x08, 0x92, 0x89, 0x74, 0x12, 0x03, 0x2E, 0x26, 
-    0xC1, 0xDE, 0x75, 0x5E, 0x99, 0xBE, 0x04, 0x26, 0x9E, 0xB8, 0x0B, 0xB8, 
-    0x74, 0x2C, 0xBB, 0x59, 0x16, 0x84, 0xA5, 0x42, 0xCB, 0xC4, 0xEE, 0xDE, 
-    0x79, 0xB2, 0x01, 0x07, 0x60, 0xBA, 0x25, 0xD0, 0xBA, 0x2E, 0xF0, 0x02, 
-    0x4C, 0xD3, 0xD2, 0x01, 0x04, 0x0B, 0xF8, 0xB4, 0xC9, 0x0C, 0x8A, 0x90, 
-    0xAE, 0xFC, 0x52, 0x65, 0xE2, 0x20, 0x3C, 0x5A, 0x20, 0x51, 0x6D, 0x7B, 
-    0xE2, 0xAD, 0x11, 0xC0, 0xF9, 0xF6, 0x06, 0xAD, 0x19, 0x0C, 0x07, 0xB4, 
-    0x04, 0x09, 0x8B, 0xEE, 0xE4, 0x63, 0x6C, 0xC3, 0x5F, 0x90, 0x16, 0x32, 
-    0x83, 0xB6, 0x07, 0x5F, 0x6F, 0xC8, 0x07, 0x0B, 0x2C, 0x00, 0xC3, 0x07, 
-    0x82, 0xA9, 0x63, 0x3F, 0x88, 0x4D, 0xB9, 0x58, 0xFB, 0x64, 0xC3, 0xA7, 
-    0xEF, 0x25, 0x0E, 0x04, 0xB8, 0x48, 0xC1, 0x00, 0x65, 0xD2, 0xBD, 0xB0, 
-    0x90, 0x87, 0x16, 0x4B, 0x1A, 0x80, 0xB1, 0x16, 0x68, 0xAA, 0x18, 0xE0, 
-    0xC0, 0x7F, 0x01, 0x98, 0x14, 0xF2, 0xFE, 0x07, 0x2A, 0x12, 0xB1, 0x20, 
-    0x67, 0x1C, 0x5C, 0x4A, 0xC2, 0x4A, 0x45, 0x41, 0x8F, 0xA8, 0x6C, 0x00, 
-    0x56, 0x31, 0x60, 0xE2, 0x46, 0x76, 0x81, 0x12, 0xFE, 0x72, 0x84, 0x5E, 
-    0x6B, 0xD9, 0x40, 0x0B, 0xE8, 0x03, 0x36, 0x04, 0x26, 0xD0, 0x85, 0xA6, 
-    0xCA, 0x01, 0x06, 0x2B, 0xD6, 0x81, 0xFA, 0x85, 0x10, 0x32, 0x23, 0x9A, 
-    0x05, 0x0A, 0x16, 0xC0, 0xBF, 0x1F, 0xF6, 0x43, 0x28, 0x39, 0xC0, 0x21, 
-    0x47, 0x66, 0xC3, 0x16, 0xAB, 0x81, 0xC0, 0x04, 0xC2, 0xA2, 0x0B, 0x07, 
-    0x40, 0x96, 0x24, 0x5C, 0xB8, 0x49, 0x89, 0xE5, 0x78, 0x1C, 0xCB, 0x34, 
-    0x70, 0x8B, 0x14, 0x02, 0xA7, 0x45, 0x2F, 0xC2, 0x22, 0x8A, 0xD8, 0x26, 
-    0x00, 0x68, 0x8D, 0xAA, 0x6D, 0x46, 0x14, 0x53, 0xC5, 0x68, 0x01, 0x81, 
-    0x36, 0xB6, 0x31, 0x7F, 0x33, 0x78, 0xC0, 0x03, 0x8A, 0x08, 0xB8, 0x04, 
-    0xCC, 0xE0, 0x05, 0x42, 0x19, 0x22, 0x1D, 0xCF, 0xA8, 0x03, 0x31, 0x0E, 
-    0xA4, 0x81, 0x03, 0xC8, 0x55, 0xAC, 0x64, 0xA8, 0xA3, 0x8B, 0x64, 0x80, 
-    0x8A, 0x2C, 0x69, 0x4D, 0xC9, 0xFC, 0x48, 0x8E, 0xDE, 0xC1, 0xA2, 0x6A, 
-    0x60, 0xA3, 0xC5, 0xC8, 0x88, 0xA5, 0x40, 0x46, 0xE6, 0x87, 0x8C, 0x22, 
-    0x30, 0x5E, 0x95, 0xE8, 0x98, 0x46, 0x31, 0x4D, 0xEB, 0x7B, 0x10, 0x10, 
-    0xC1, 0x0C, 0xAC, 0xF7, 0x98, 0x11, 0x90, 0x88, 0x16, 0x07, 0x28, 0x62, 
-    0xA6, 0x04, 0x10, 0x2E, 0x4B, 0x32, 0x83, 0x5C, 0x4D, 0xBC, 0x11, 0x03, 
-    0x5A, 0xB3, 0xAF, 0x57, 0xA0, 0xAF, 0x25, 0x62, 0x7B, 0x45, 0x18, 0x5D, 
-    0x79, 0x8C, 0x01, 0xDD, 0x32, 0x56, 0x26, 0x78, 0xC8, 0x04, 0x79, 0xC9, 
-    0x17, 0x32, 0x76, 0x20, 0x83, 0xDF, 0x7A, 0x56, 0x27, 0xB9, 0xF5, 0x81, 
-    0xD3, 0x7D, 0x4F, 0x04, 0x20, 0x04, 0xD1, 0xB7, 0x5E, 0xA0, 0x93, 0x59, 
-    0x1C, 0x93, 0x10, 0x00, 0xD1, 0x1E, 0x31, 0x95, 0x61, 0x36, 0x96, 0xFD, 
-    0x66, 0x96, 0xB5, 0x8C, 0x93, 0x5D, 0xCE, 0x53, 0xC9, 0x6D, 0xAE, 0xFE, 
-    0x22, 0x1B, 0xB0, 0xE0, 0x0F, 0xBB, 0xB0, 0x22, 0x4C, 0x73, 0xEE, 0xE5, 
-    0x07, 0x96, 0xB0, 0xA3, 0x22, 0x3A, 0x40, 0xCA, 0x65, 0x82, 0xE8, 0x1F, 
-    0x2A, 0x04, 0x4C, 0xF2, 0xB2, 0xF3, 0x01, 0x10, 0x36, 0x6F, 0x1E, 0x8A, 
-    0x30, 0x91, 0x3B, 0x59, 0x81, 0xCE, 0x57, 0x44, 0xD2, 0x1B, 0x2D, 0xB8, 
-    0x08, 0x06, 0x42, 0x50, 0x82, 0x93, 0x4C, 0xC0, 0x02, 0x31, 0xA3, 0x4D, 
-    0x4B, 0x12, 0x3A, 0xB6, 0x81, 0xEE, 0x66, 0x2D, 0xB6, 0x33, 0x00, 0x45, 
-    0x81, 0x71, 0x01, 0xB4, 0x59, 0x94, 0x26, 0x9F, 0x83, 0x54, 0x73, 0x2C, 
-    0x65, 0x4F, 0xC0, 0xC9, 0xF1, 0xA4, 0x28, 0x7D, 0xC0, 0x08, 0xF2, 0xC7, 
-    0xD2, 0xFC, 0x35, 0xCF, 0x9A, 0xCA, 0x19, 0x53, 0x10, 0x05, 0x60, 0x88, 
-    0x6F, 0x51, 0xE6, 0xA3, 0xA8, 0x70, 0xE4, 0x00, 0xEA, 0xF2, 0x9B, 0xDB, 
-    0x3C, 0x44, 0x02, 0xBB, 0x84, 0x44, 0x8C, 0x54, 0x52, 0x35, 0x69, 0xE0, 
-    0x62, 0x7C, 0x38, 0x05, 0x00, 0x69, 0xBC, 0x98, 0x38, 0x70, 0x06, 0x83, 
-    0x00, 0x14, 0x78, 0x59, 0x52, 0xC9, 0x61, 0x93, 0xEB, 0x10, 0xEC, 0x05, 
-    0x25, 0xCD, 0x6A, 0x21, 0x10, 0x23, 0x00, 0x12, 0xEC, 0x2C, 0x1F, 0xA0, 
-    0x6A, 0x8E, 0x21, 0xA8, 0xB7, 0x82, 0xA9, 0x9E, 0x82, 0x76, 0xBF, 0xB4, 
-    0xCD, 0xB0, 0x2E, 0x30, 0x4C, 0x49, 0x9C, 0x90, 0xA9, 0xDC, 0x38, 0xCF, 
-    0x15, 0xCD, 0xEA, 0x08, 0x9D, 0x0E, 0xE0, 0xA0, 0x21, 0x73, 0xAA, 0x67, 
-    0x88, 0x41, 0xD7, 0x72, 0xE8, 0x00, 0x7E, 0xB4, 0x88, 0x9B, 0x56, 0x97, 
-    0xE9, 0xAD, 0xEB, 0x10, 0xE2, 0x03, 0xCD, 0xBB, 0x66, 0x88, 0x82, 0x66, 
-    0x88, 0xA0, 0x08, 0x60, 0x14, 0x7D, 0x95, 0x04, 0x0C, 0x51, 0xD8, 0xAE, 
-    0x6A, 0x94, 0x13, 0x15, 0x93, 0x8D, 0x25, 0x37, 0x46, 0xA6, 0x97, 0xC8, 
-    0x3A, 0x62, 0xFE, 0x36, 0xBF, 0xCB, 0xA7, 0x22, 0xF4, 0xCA, 0xA6, 0xA8, 
-    0x7A, 0x16, 0x19, 0x31, 0xD0, 0x21, 0x2A, 0x39, 0x39, 0xD8, 0x65, 0xEE, 
-    0xA4, 0x8C, 0x85, 0x38, 0x9E, 0x22, 0x32, 0x09, 0xA2, 0x20, 0x1E, 0xE0, 
-    0x10, 0xA0, 0xD0, 0xE6, 0x69, 0x3F, 0x0B, 0x0B, 0x41, 0x7A, 0x03, 0x77, 
-    0x3B, 0x3A, 0x27, 0x2E, 0xF0, 0x1A, 0x4C, 0x71, 0xEC, 0xB6, 0xA0, 0x03, 
-    0x40, 0xA4, 0x68, 0x37, 0x30, 0x9F, 0x8B, 0x74, 0x14, 0xA9, 0xBB, 0x75, 
-    0x44, 0x6A, 0xB9, 0xF1, 0x9C, 0xD6, 0x66, 0x35, 0x68, 0x02, 0x50, 0x6C, 
-    0x21, 0xB0, 0xBB, 0x4F, 0xA5, 0x40, 0x0C, 0xBB, 0x38, 0x29, 0xC4, 0x2A, 
-    0x21, 0x1B, 0xDD, 0xD9, 0xA8, 0xD3, 0x1B, 0x3A, 0xAA, 0x15, 0x2B, 0xCC, 
-    0x76, 0xDE, 0x5A, 0xE0, 0x62, 0xB7, 0xB0, 0x14, 0x2D, 0x43, 0x4C, 0x50, 
-    0x48, 0x8C, 0x64, 0x2D, 0xBA, 0x91, 0x98, 0xAE, 0x35, 0x59, 0x6B, 0xDD, 
-    0x34, 0x0A, 0x0E, 0x02, 0xA4, 0xDB, 0x49, 0xF1, 0x94, 0xD2, 0x9C, 0x79, 
-    0x5E, 0x0A, 0x20, 0x2B, 0x20, 0xDC, 0x6E, 0x67, 0xA3, 0x5C, 0xF7, 0x32, 
-    0x09, 0x19, 0xB3, 0xF1, 0x26, 0x37, 0x70, 0x11, 0x54, 0xB3, 0xB2, 0x27, 
-    0x03, 0x35, 0x92, 0x6F, 0x37, 0x18, 0x30, 0x49, 0x8E, 0x7A, 0x14, 0xBF, 
-    0x8F, 0xD0, 0xEF, 0xC3, 0xFA, 0x5B, 0x52, 0xC7, 0x3A, 0x87, 0x13, 0x26, 
-    0xC6, 0xAA, 0x61, 0x3E, 0xD0, 0x14, 0xD5, 0x65, 0xA2, 0x4C, 0x24, 0xDC, 
-    0x2D, 0x9C, 0x5E, 0x01, 0x57, 0x5A, 0x4C, 0xAE, 0x85, 0x10, 0xEE, 0x6D, 
-    0x4B, 0x74, 0x74, 0xDF, 0xA9, 0xDA, 0x35, 0x5D, 0x0D, 0x96, 0xAF, 0x01, 
-    0x4C, 0x30, 0x2C, 0x5C, 0x64, 0x04, 0xC4, 0x8D, 0x20, 0xA3, 0x22, 0x54, 
-    0x4C, 0x62, 0x7B, 0x4A, 0x07, 0x6E, 0xFE, 0x68, 0x4A, 0x77, 0x23, 0xC3, 
-    0x02, 0x1F, 0x16, 0x82, 0x60, 0xFE, 0x37, 0x7D, 0x9F, 0x00, 0x68, 0x20, 
-    0x50, 0x9C, 0xD2, 0xAE, 0xC6, 0xB3, 0x58, 0x12, 0xFB, 0x56, 0xF1, 0xB8, 
-    0xF6, 0xD2, 0xA2, 0x35, 0x3D, 0x4E, 0x6A, 0x05, 0x28, 0x62, 0x48, 0x05, 
-    0xE0, 0x35, 0x9F, 0x20, 0x68, 0xAE, 0x45, 0x2E, 0x90, 0x66, 0xBA, 0x2A, 
-    0xF9, 0x00, 0xD1, 0x6C, 0x32, 0x0C, 0x00, 0xF2, 0x82, 0x3C, 0x03, 0x6E, 
-    0x54, 0x28, 0xE0, 0xAF, 0x26, 0x4C, 0x1C, 0x53, 0x8A, 0xCD, 0x62, 0x14, 
-    0x3A, 0x50, 0x2D, 0xB8, 0x14, 0x3C, 0xD0, 0x14, 0xC0, 0xE2, 0x81, 0xDE, 
-    0x40, 0x33, 0x32, 0x68, 0x37, 0x80, 0xA2, 0xCE, 0x42, 0xD2, 0xA7, 0x2D, 
-    0x80, 0x05, 0xCC, 0x07, 0x64, 0x0D, 0x73, 0xC3, 0x00, 0x1A, 0x28, 0xB2, 
-    0x04, 0xA3, 0xAB, 0xE4, 0xD1, 0x35, 0x79, 0xAC, 0xD4, 0xAD, 0x27, 0xA8, 
-    0x12, 0x91, 0x4A, 0x7E, 0x04, 0x91, 0xC9, 0xD1, 0x3A, 0x1D, 0x0F, 0x6E, 
-    0x26, 0x00, 0x2C, 0x60, 0x41, 0x11, 0x34, 0xC0, 0xA9, 0xCA, 0x10, 0xD0, 
-    0x92, 0xD6, 0xB4, 0xF5, 0x14, 0x76, 0x4D, 0x6B, 0x37, 0x30, 0x1D, 0xDD, 
-    0x89, 0xC8, 0x48, 0x21, 0x6E, 0xF6, 0x74, 0x2D, 0xE4, 0xBC, 0x31, 0x52, 
-    0x83, 0xF5, 0xD4, 0x86, 0x38, 0xE5, 0x7E, 0x01, 0x47, 0x37, 0x01, 0x14, 
-    0x5A, 0x30, 0x07, 0xB8, 0xED, 0xC4, 0xAA, 0xCD, 0x8D, 0x28, 0x44, 0xA1, 
-    0x0A, 0x8A, 0x10, 0xE0, 0x40, 0x0B, 0x30, 0x5C, 0x96, 0x8C, 0x8C, 0x02, 
-    0xAC, 0x28, 0x00, 0xB9, 0x0C, 0x6A, 0x17, 0x62, 0x83, 0x18, 0xA2, 0xBE, 
-    0x0B, 0xB2, 0x68, 0x75, 0xD4, 0x59, 0xCF, 0x2A, 0x59, 0xB0, 0xA7, 0x4E, 
-    0x44, 0xA5, 0x66, 0x50, 0x60, 0x01, 0xE0, 0x1B, 0x54, 0xDC, 0x69, 0x5D, 
-    0x3F, 0x48, 0xB0, 0xAC, 0x89, 0xAD, 0x51, 0x11, 0x49, 0x48, 0xC2, 0x15, 
-    0xA6, 0x20, 0x80, 0x15, 0xF4, 0xD1, 0xA2, 0x03, 0xFE, 0xF2, 0x2D, 0x2D, 
-    0x72, 0x29, 0x3E, 0x6C, 0x98, 0xED, 0x15, 0x12, 0xEF, 0x06, 0x8F, 0x91, 
-    0xFC, 0x88, 0x0A, 0x84, 0xE0, 0xD8, 0x6B, 0x49, 0xB6, 0x86, 0x81, 0xAB, 
-    0xCB, 0xD3, 0xFA, 0xC0, 0x12, 0x82, 0x6E, 0xF2, 0x19, 0x7F, 0x72, 0x46, 
-    0x81, 0x47, 0xAB, 0x39, 0x29, 0x5F, 0x26, 0x76, 0x11, 0x9E, 0x70, 0x28, 
-    0x04, 0xF4, 0xA3, 0xE4, 0x0A, 0xED, 0x37, 0xF2, 0xB2, 0x8A, 0x98, 0x09, 
-    0x7B, 0xE7, 0xB0, 0x80, 0xEE, 0x69, 0xE1, 0x7D, 0x11, 0x15, 0xC8, 0xDB, 
-    0x6A, 0x4B, 0xAA, 0x5C, 0x64, 0x3F, 0xD7, 0x43, 0x68, 0x67, 0xE2, 0x5B, 
-    0xB4, 0xBD, 0x32, 0x4F, 0x7E, 0x36, 0x2A, 0x28, 0x93, 0xB8, 0xDF, 0x56, 
-    0xA8, 0x79, 0x77, 0x3E, 0x4A, 0x15, 0x58, 0xB4, 0x64, 0x92, 0xBF, 0x76, 
-    0x2B, 0x2E, 0x5A, 0xF0, 0x9B, 0x5C, 0xE2, 0x98, 0xE3, 0x92, 0xF0, 0x38, 
-    0xC8, 0x07, 0x90, 0x01, 0x91, 0xDB, 0x4E, 0x7D, 0xAF, 0x08, 0xBB, 0x45, 
-    0x99, 0xAE, 0x6A, 0xEB, 0x0E, 0xA6, 0x42, 0xF7, 0x13, 0x4A, 0x78, 0x11, 
-    0x96, 0x1C, 0x68, 0x9F, 0x51, 0x11, 0x54, 0x48, 0x82, 0xCD, 0x05, 0x10, 
-    0xBB, 0x71, 0x87, 0x84, 0x25, 0x1B, 0xA0, 0xCF, 0x09, 0xA4, 0x0A, 0x89, 
-    0xC9, 0xDE, 0xD5, 0x2E, 0x4B, 0x42, 0x37, 0xDA, 0x4B, 0x41, 0x74, 0x8B, 
-    0x18, 0xDD, 0x76, 0xC5, 0x6D, 0xF6, 0xD2, 0xE3, 0xE9, 0xF4, 0x4C, 0x8C, 
-    0x2A, 0xEA, 0xC6, 0x6B, 0x8A, 0x95, 0xB5, 0x83, 0x98, 0xBD, 0x37, 0xD9, 
-    0x94, 0x8A, 0x90, 0x42, 0x12, 0xC0, 0x4D, 0x78, 0x9C, 0xCE, 0x78, 0x00, 
-    0x3A, 0xEF, 0x46, 0x2E, 0xDF, 0xD5, 0x80, 0xDA, 0x37, 0xE0, 0x02, 0x15, 
-    0x06, 0x80, 0x78, 0x60, 0x11, 0x7B, 0x6E, 0xC0, 0x7D, 0xD4, 0x93, 0x37, 
-    0x85, 0xDA, 0xDB, 0xFC, 0x66, 0x96, 0xD0, 0x7B, 0xF3, 0x51, 0x8A, 0xFE, 
-    0xF9, 0xA9, 0xBF, 0x15, 0xCD, 0x91, 0x32, 0x53, 0x28, 0xF4, 0xEC, 0xFC, 
-    0x61, 0xA4, 0xAD, 0x88, 0x1A, 0xE0, 0xD4, 0xAE, 0x96, 0x0E, 0xDB, 0xBE, 
-    0x7E, 0x4D, 0x69, 0x33, 0x23, 0xE8, 0x2D, 0x42, 0x0F, 0x3E, 0x00, 0x2A, 
-    0x1F, 0x8C, 0xCB, 0xCB, 0xD2, 0x65, 0x7D, 0xAD, 0xC1, 0x5F, 0xF0, 0x2C, 
-    0xFD, 0x4C, 0xF4, 0x9D, 0x10, 0x09, 0x43, 0x41, 0xDD, 0x97, 0xC2, 0x9D, 
-    0xE8, 0xB7, 0x7F, 0xE6, 0x5B, 0x9E, 0x2A, 0x69, 0x24, 0xCC, 0x0D, 0x17, 
-    0xD0, 0x07, 0x23, 0x5D, 0x61, 0x36, 0x3C, 0xE5, 0x7B, 0x3C, 0x27, 0x7E, 
-    0xD8, 0xF0, 0x71, 0x17, 0x81, 0x00, 0x2D, 0x50, 0x7C, 0x02, 0x30, 0x32, 
-    0x43, 0x42, 0x57, 0x35, 0x80, 0x72, 0xED, 0x97, 0x09, 0x2C, 0xC0, 0x64, 
-    0x0F, 0x40, 0x22, 0x7E, 0x76, 0x4F, 0xEE, 0x60, 0x7F, 0xED, 0x67, 0x62, 
-    0xE1, 0x36, 0x55, 0x99, 0xD5, 0x53, 0x44, 0x36, 0x67, 0xA4, 0x60, 0x57, 
-    0x19, 0x17, 0x3E, 0xB9, 0x67, 0x80, 0xA6, 0x40, 0x7E, 0xED, 0x91, 0x71, 
-    0x9B, 0xF1, 0x1F, 0x74, 0xA5, 0x5F, 0xD7, 0x36, 0x81, 0xCC, 0x02, 0x21, 
-    0xD1, 0xC2, 0x1D, 0xAD, 0x46, 0x83, 0x01, 0x80, 0x5D, 0x65, 0x35, 0x55, 
-    0x80, 0xE4, 0x82, 0xDF, 0xC0, 0x00, 0x0C, 0x30, 0x39, 0x03, 0x90, 0x82, 
-    0x00, 0x30, 0x1B, 0x2B, 0x31, 0x0B, 0x44, 0x38, 0x66, 0x2A, 0x78, 0x80, 
-    0x6B, 0xA7, 0x80, 0x60, 0x93, 0x79, 0x15, 0x67, 0x56, 0x64, 0xF4, 0x6F, 
-    0x9B, 0x00, 0x31, 0x33, 0xB0, 0x00, 0x71, 0x24, 0x47, 0xAD, 0xD5, 0x2C, 
-    0x23, 0x30, 0x7A, 0x90, 0x01, 0x0A, 0x39, 0xA8, 0x83, 0xAB, 0xD4, 0x34, 
-    0x66, 0xC5, 0x44, 0x21, 0xA3, 0x23, 0x61, 0xF7, 0x56, 0xB3, 0x30, 0x7B, 
-    0xF0, 0xD2, 0x84, 0xCA, 0x60, 0x01, 0xAF, 0x17, 0x0C, 0x0E, 0x20, 0x48, 
-    0x3A, 0x22, 0xFE, 0x79, 0x53, 0x75, 0x72, 0x95, 0xC2, 0x0F, 0xD4, 0xE3, 
-    0x0D, 0x53, 0xA6, 0x83, 0xFB, 0x20, 0x86, 0xCA, 0xE7, 0x74, 0x24, 0x92, 
-    0x6B, 0x66, 0x75, 0x42, 0xFC, 0x77, 0x17, 0xB0, 0x80, 0x87, 0x92, 0x55, 
-    0x6E, 0xD3, 0x80, 0x0B, 0x75, 0xB6, 0x4D, 0x11, 0x60, 0x01, 0x12, 0x50, 
-    0x7B, 0xBF, 0x20, 0x13, 0x15, 0x20, 0x01, 0x17, 0x87, 0x0B, 0x0A, 0x38, 
-    0x7B, 0x8C, 0x47, 0x4C, 0xEA, 0x37, 0x75, 0xFC, 0xF0, 0x52, 0xDC, 0x00, 
-    0x60, 0x80, 0xD8, 0x0F, 0x67, 0x94, 0x81, 0x13, 0x58, 0x60, 0xD6, 0x77, 
-    0x86, 0x2A, 0xC1, 0x80, 0x13, 0x57, 0x1F, 0xA5, 0xB0, 0x7B, 0xAF, 0xA0, 
-    0x02, 0x1A, 0x40, 0x1F, 0x97, 0x65, 0x4E, 0x13, 0x50, 0x89, 0x17, 0x21, 
-    0x76, 0x17, 0xD0, 0x00, 0x21, 0xA0, 0x39, 0xE1, 0x67, 0x0A, 0x25, 0x30, 
-    0x87, 0x0A, 0x65, 0x56, 0x00, 0x33, 0x7F, 0xF0, 0x37, 0x4F, 0x64, 0x42, 
-    0x30, 0x28, 0xA0, 0x8A, 0xA7, 0x78, 0x08, 0x09, 0x03, 0x7A, 0xA7, 0x58, 
-    0x86, 0x85, 0x97, 0x54, 0x27, 0x04, 0x69, 0x07, 0xF2, 0x7B, 0xE3, 0x43, 
-    0x69, 0x00, 0xE8, 0x4E, 0x5E, 0xB1, 0x89, 0xC1, 0x20, 0x09, 0xDE, 0x08, 
-    0x0B, 0x0D, 0x40, 0x01, 0x12, 0x10, 0x01, 0x9F, 0x38, 0x8B, 0x9A, 0x18, 
-    0x16, 0x72, 0x47, 0x4C, 0x7A, 0x08, 0x8D, 0x35, 0x28, 0x8A, 0xA2, 0x22, 
-    0x81, 0xD1, 0xC8, 0x09, 0xD3, 0x78, 0x8F, 0x86, 0xD0, 0x1C, 0xAD, 0x34, 
-    0x55, 0xEB, 0x06, 0x66, 0xC6, 0xF7, 0x60, 0xEA, 0x01, 0x72, 0x8C, 0xC8, 
-    0x4B, 0xEB, 0x11, 0x4E, 0xF1, 0xE2, 0x78, 0x62, 0x81, 0x01, 0x27, 0x20, 
-    0x01, 0x25, 0x10, 0x89, 0xA4, 0x50, 0x8C, 0x4F, 0x35, 0x8C, 0x7E, 0x84, 
-    0x1C, 0x2E, 0xC7, 0x0E, 0x41, 0x73, 0x91, 0x01, 0xF0, 0x2D, 0x28, 0x50, 
-    0x70, 0xFA, 0x68, 0x08, 0xFA, 0xFE, 0x46, 0x8D, 0xF7, 0x58, 0x26, 0x86, 
-    0x68, 0x56, 0x05, 0x70, 0x71, 0x40, 0xD8, 0x0D, 0x9C, 0xB5, 0x82, 0xC1, 
-    0x50, 0x90, 0xAE, 0x54, 0x02, 0xE2, 0xB8, 0x16, 0x1C, 0xA0, 0x00, 0xB8, 
-    0xD1, 0x63, 0x11, 0x15, 0x4E, 0xAF, 0xF0, 0x8B, 0x12, 0x20, 0x8C, 0xE1, 
-    0xD1, 0x8E, 0xAF, 0xE0, 0x92, 0x16, 0xF5, 0x17, 0x33, 0x88, 0x91, 0xB3, 
-    0x00, 0x6B, 0x84, 0x30, 0x2D, 0x01, 0x30, 0x60, 0x1F, 0x19, 0x44, 0x1C, 
-    0xF8, 0x91, 0x01, 0x10, 0x0A, 0x91, 0x05, 0x48, 0x94, 0x75, 0x20, 0x99, 
-    0xF7, 0x80, 0xA5, 0xB0, 0x26, 0xB9, 0x68, 0x49, 0x05, 0xA0, 0x90, 0xB5, 
-    0xA8, 0x01, 0xB0, 0xE2, 0x6E, 0x8D, 0x50, 0x15, 0xAC, 0xF1, 0x7F, 0x38, 
-    0x49, 0x00, 0xE7, 0x98, 0x8E, 0x46, 0x38, 0x15, 0x70, 0xB2, 0x8E, 0xAE, 
-    0x94, 0x0E, 0xDA, 0xB5, 0x0F, 0x82, 0x23, 0x00, 0x2E, 0x76, 0x08, 0x30, 
-    0x00, 0x86, 0x34, 0xC8, 0x94, 0xCA, 0xD8, 0x7E, 0xCD, 0xD1, 0x65, 0x66, 
-    0xF5, 0x63, 0x2A, 0x90, 0x7D, 0x46, 0x15, 0x74, 0xA6, 0x80, 0x2A, 0x6D, 
-    0x62, 0x4E, 0xBE, 0xC2, 0x89, 0x0A, 0x50, 0x54, 0x60, 0x49, 0x6E, 0xCF, 
-    0x40, 0x0B, 0x06, 0xC0, 0x00, 0x1A, 0xA0, 0x00, 0x0E, 0x50, 0x5F, 0x38, 
-    0x09, 0x91, 0xBA, 0x47, 0x57, 0xC8, 0xF1, 0x87, 0xEC, 0xE0, 0x4C, 0x07, 
-    0xA0, 0x91, 0x4E, 0x79, 0x58, 0x42, 0xE1, 0x99, 0xFA, 0x58, 0x26, 0xD7, 
-    0xD8, 0x97, 0xC0, 0x80, 0x00, 0x29, 0xA9, 0x08, 0x72, 0x75, 0x0A, 0x27, 
-    0xD0, 0x00, 0x14, 0x39, 0x40, 0x87, 0x09, 0x0B, 0x89, 0x99, 0x48, 0xB0, 
-    0x70, 0x5F, 0x2A, 0xA3, 0x8D, 0xDE, 0xC0, 0x00, 0xAA, 0x11, 0x45, 0xB5, 
-    0x64, 0x95, 0x48, 0xF6, 0x17, 0x76, 0xB9, 0x09, 0x5C, 0x35, 0x0B, 0x9F, 
-    0xA9, 0x09, 0x78, 0x59, 0x9C, 0x87, 0xF0, 0x2D, 0xFE, 0xBA, 0xD5, 0x57, 
-    0x3F, 0xB6, 0x53, 0x29, 0xB9, 0x24, 0xF5, 0xA6, 0x1E, 0x34, 0x91, 0x96, 
-    0x27, 0xB3, 0x26, 0x19, 0xD0, 0x27, 0xDE, 0x30, 0x39, 0xF7, 0xE5, 0x68, 
-    0xAF, 0x40, 0x76, 0xEC, 0xB2, 0x01, 0x43, 0xC8, 0x01, 0x0E, 0x40, 0x96, 
-    0xC0, 0x07, 0x62, 0x55, 0x05, 0x19, 0x72, 0xB4, 0x67, 0xA2, 0xA9, 0x8F, 
-    0x4C, 0x19, 0x9C, 0xD1, 0x98, 0x30, 0x3E, 0x70, 0x5A, 0x11, 0x70, 0x6C, 
-    0x08, 0xC0, 0x01, 0x5E, 0xC9, 0x0D, 0x55, 0xC9, 0x3D, 0x11, 0x20, 0x01, 
-    0x21, 0x70, 0x7B, 0x94, 0xA3, 0x27, 0x73, 0x18, 0x39, 0xBF, 0x31, 0x39, 
-    0x13, 0x44, 0x2E, 0x00, 0x19, 0x2B, 0x8F, 0x69, 0x02, 0xAD, 0x71, 0x76, 
-    0xF8, 0xC5, 0x36, 0xEB, 0x89, 0x9C, 0x86, 0xF1, 0x49, 0x4D, 0xD9, 0x5A, 
-    0x22, 0xD0, 0x01, 0x0B, 0xE0, 0x9E, 0x57, 0x28, 0x14, 0x09, 0x96, 0x69, 
-    0xC6, 0x08, 0x39, 0x0E, 0xF0, 0xA1, 0x7F, 0x32, 0x13, 0x13, 0xB0, 0x9F, 
-    0xFD, 0x19, 0x93, 0x9A, 0xE7, 0x24, 0xDC, 0x49, 0x20, 0x80, 0xA9, 0x84, 
-    0xEB, 0x03, 0x09, 0xE6, 0x25, 0x5F, 0xBF, 0xF7, 0x8E, 0x53, 0x75, 0x33, 
-    0x0F, 0x0A, 0xA1, 0x49, 0xD1, 0x87, 0x13, 0x3A, 0x58, 0xCD, 0xA3, 0x94, 
-    0xFD, 0xD0, 0x1C, 0x31, 0xE6, 0x59, 0x11, 0x60, 0xA2, 0x61, 0x61, 0x99, 
-    0xC7, 0x30, 0xA2, 0xFC, 0xE9, 0x9F, 0x38, 0x39, 0x00, 0x69, 0x42, 0x8B, 
-    0x3B, 0xB5, 0xA2, 0x2C, 0xFA, 0x0A, 0x63, 0x66, 0x36, 0xB0, 0x28, 0x32, 
-    0x8C, 0x03, 0x62, 0x34, 0x6A, 0xA3, 0x21, 0xD2, 0x1C, 0xA6, 0x46, 0x62, 
-    0xFA, 0xE6, 0x2C, 0x43, 0xB9, 0x0F, 0xDC, 0x26, 0x6E, 0xF2, 0xD9, 0xA1, 
-    0x61, 0xC1, 0x84, 0xAC, 0x60, 0xA4, 0x25, 0x9A, 0xA4, 0x17, 0x41, 0xA4, 
-    0xC5, 0x31, 0x59, 0x5F, 0x43, 0x27, 0x93, 0x33, 0x66, 0x3F, 0xA2, 0xFE, 
-    0x61, 0x31, 0x0A, 0x62, 0x05, 0x03, 0xA1, 0x24, 0xC0, 0x85, 0x8F, 0x81, 
-    0x83, 0xF2, 0x68, 0x4F, 0xDC, 0x51, 0x29, 0xF8, 0xC4, 0xA3, 0xFB, 0xD0, 
-    0x87, 0x1B, 0x8A, 0x5F, 0x9A, 0x46, 0x01, 0x9C, 0x86, 0x0B, 0x17, 0x10, 
-    0x9D, 0xA7, 0x80, 0xA6, 0x48, 0xAA, 0xA6, 0xED, 0xA1, 0x02, 0x0A, 0xA0, 
-    0x23, 0x73, 0xC5, 0x20, 0xC8, 0x95, 0x88, 0x2C, 0x91, 0x79, 0xEC, 0x73, 
-    0x9B, 0xCA, 0x36, 0x32, 0x4A, 0xB7, 0x5B, 0x7F, 0x51, 0xA3, 0x13, 0xD8, 
-    0xA5, 0x56, 0xB2, 0x14, 0xC7, 0xC9, 0x87, 0x6E, 0x34, 0x4A, 0xCA, 0x83, 
-    0xA3, 0x84, 0x50, 0x58, 0x46, 0xD9, 0x0F, 0x04, 0xF3, 0xA3, 0x48, 0x36, 
-    0xA2, 0x11, 0x50, 0xAB, 0xB5, 0xBA, 0x8E, 0x8E, 0x2A, 0xA4, 0x38, 0xE9, 
-    0x00, 0x92, 0xAA, 0x01, 0x0C, 0x70, 0x28, 0x23, 0x63, 0xA6, 0xF8, 0x11, 
-    0x5F, 0xB1, 0xC2, 0x00, 0x2D, 0x5A, 0x57, 0xB0, 0xF0, 0x73, 0x2A, 0xF4, 
-    0x7B, 0x6C, 0x69, 0x51, 0xB4, 0x96, 0x97, 0x4E, 0xE7, 0x4C, 0x6F, 0x29, 
-    0x0F, 0xA8, 0x97, 0xA3, 0x9D, 0xD0, 0xA5, 0xD7, 0x61, 0x7A, 0x13, 0x13, 
-    0x34, 0x3E, 0x93, 0x30, 0x7B, 0xCA, 0x34, 0x62, 0x0A, 0x87, 0x8E, 0x10, 
-    0x01, 0x25, 0x70, 0xA4, 0xBA, 0x1A, 0x4E, 0xBC, 0xAA, 0x00, 0xBE, 0xEA, 
-    0xA4, 0x93, 0x03, 0x94, 0xF8, 0x41, 0x1A, 0xA9, 0xB9, 0x61, 0xE6, 0xF8, 
-    0x08, 0x5F, 0xA6, 0x6C, 0x02, 0xD0, 0x1A, 0xEE, 0x6A, 0x56, 0xB4, 0x66, 
-    0x85, 0x64, 0xD8, 0x0D, 0x83, 0x18, 0x3A, 0xD9, 0x05, 0xAD, 0x01, 0x40, 
-    0x29, 0xB4, 0xF0, 0xAA, 0xD1, 0xB2, 0x13, 0xD0, 0xF1, 0x02, 0xFC, 0x9A, 
-    0x13, 0xA1, 0xC0, 0x68, 0xC1, 0x47, 0xAE, 0x12, 0x40, 0x01, 0x0D, 0xB0, 
-    0x76, 0x49, 0x9A, 0xAE, 0xEB, 0x6A, 0x35, 0x24, 0xF7, 0xA9, 0x0C, 0xD2, 
-    0x75, 0x03, 0xFE, 0xC0, 0x6B, 0xEB, 0x34, 0xAF, 0xBC, 0xF5, 0x0A, 0x47, 
-    0xF7, 0x3D, 0x24, 0x37, 0x85, 0xA7, 0xF5, 0x28, 0xA2, 0xDA, 0x79, 0xCD, 
-    0x82, 0x02, 0x2F, 0x40, 0x30, 0x5F, 0x3A, 0x68, 0x5A, 0x2A, 0xB0, 0x18, 
-    0x32, 0x05, 0x57, 0x20, 0x05, 0xDC, 0x20, 0x92, 0xA1, 0x22, 0x7A, 0xA0, 
-    0x12, 0x34, 0x49, 0x54, 0x0E, 0x11, 0x68, 0x26, 0x34, 0x40, 0x03, 0x37, 
-    0xF0, 0x70, 0xE4, 0x03, 0xB1, 0x12, 0x4B, 0xB1, 0xBB, 0xDA, 0xAB, 0xBF, 
-    0x2A, 0x5A, 0xC6, 0x1A, 0x3C, 0x28, 0x32, 0x59, 0xDE, 0x59, 0xAC, 0x20, 
-    0xDB, 0x08, 0x03, 0x82, 0x9D, 0x1A, 0xA6, 0x86, 0xD1, 0xF5, 0xB3, 0x02, 
-    0xF0, 0xAF, 0x2A, 0x1B, 0x3F, 0x41, 0xE3, 0x9E, 0x24, 0xD0, 0x14, 0x38, 
-    0xCB, 0x0E, 0x00, 0xA1, 0x05, 0x5A, 0x47, 0x0B, 0x5C, 0x0B, 0x19, 0x7D, 
-    0x48, 0x52, 0x63, 0x32, 0x19, 0xE5, 0xF0, 0x28, 0xB4, 0xD0, 0x8A, 0x85, 
-    0x63, 0xB4, 0x13, 0x0B, 0xA9, 0x74, 0xA8, 0xB4, 0x4E, 0x6A, 0x40, 0xEF, 
-    0x85, 0x22, 0xA4, 0x61, 0xB5, 0x07, 0xD2, 0xB4, 0xFF, 0xE9, 0x08, 0x73, 
-    0x6A, 0xAF, 0x93, 0xB3, 0x48, 0xBB, 0x75, 0x41, 0x7B, 0xF8, 0x91, 0xCD, 
-    0x12, 0x21, 0x8C, 0xC5, 0x0E, 0xF3, 0xA3, 0x08, 0x9A, 0xB9, 0x99, 0x02, 
-    0x00, 0x05, 0x09, 0x97, 0x04, 0x54, 0xC0, 0x05, 0xCF, 0xF6, 0x33, 0x55, 
-    0x02, 0x03, 0x02, 0xDB, 0x09, 0x26, 0x76, 0x53, 0xCA, 0xF0, 0x17, 0x2C, 
-    0x20, 0x47, 0x00, 0x51, 0x9A, 0x26, 0x83, 0xB4, 0xB5, 0x84, 0x00, 0x0E, 
-    0x30, 0x93, 0x17, 0x6B, 0xAF, 0xF6, 0x52, 0x9B, 0x27, 0xD2, 0x40, 0x1E, 
-    0x4B, 0x27, 0x1C, 0x76, 0x1E, 0x4A, 0xD7, 0x40, 0x03, 0x98, 0x9B, 0x0A, 
-    0xC0, 0x00, 0x53, 0x4A, 0x80, 0x82, 0xB9, 0x5B, 0xF0, 0xA4, 0x08, 0x18, 
-    0x7A, 0x6A, 0xF4, 0xB0, 0x2D, 0xFE, 0xCD, 0x32, 0xB6, 0xE2, 0x75, 0x3A, 
-    0x0B, 0xEB, 0x09, 0xD2, 0xB1, 0x05, 0x95, 0x1B, 0x05, 0x56, 0x90, 0xB9, 
-    0x13, 0x23, 0x5B, 0x27, 0x26, 0x26, 0x82, 0xD3, 0x8F, 0xC7, 0x10, 0x03, 
-    0x6D, 0xD3, 0x2C, 0xD8, 0x6B, 0x32, 0xE7, 0xCA, 0x89, 0xAB, 0x9B, 0x1A, 
-    0xDE, 0xE7, 0xBA, 0xED, 0x26, 0x90, 0x0C, 0x82, 0x56, 0x74, 0x62, 0x0B, 
-    0x9E, 0xE1, 0x08, 0x1C, 0x8B, 0x9B, 0x2E, 0x41, 0x17, 0x92, 0xEA, 0x02, 
-    0xE3, 0xCB, 0x0D, 0xB8, 0x21, 0xA3, 0x16, 0x55, 0x55, 0xA0, 0xA3, 0x8F, 
-    0xFF, 0x70, 0x4C, 0xCD, 0xF2, 0xB2, 0x84, 0xF0, 0xB8, 0x51, 0xD2, 0xA7, 
-    0xCC, 0x2B, 0x00, 0x51, 0x60, 0xB9, 0x5D, 0xC0, 0x70, 0x1E, 0xE2, 0x3A, 
-    0x0F, 0xF0, 0x2D, 0xD3, 0x9A, 0x1D, 0x67, 0x54, 0x92, 0xC8, 0xA0, 0x87, 
-    0x31, 0xD5, 0x2C, 0x10, 0x5C, 0x33, 0x37, 0xF9, 0x0C, 0xE1, 0x2B, 0xBF, 
-    0xE4, 0xAB, 0x42, 0xC1, 0x7A, 0x22, 0xAF, 0x17, 0xAF, 0x8A, 0x90, 0x79, 
-    0xE3, 0xD8, 0x08, 0xF5, 0xBA, 0x63, 0x61, 0x31, 0xBF, 0x4F, 0x3A, 0x00, 
-    0xF9, 0x3A, 0xA3, 0xB3, 0xB0, 0xBC, 0x9D, 0x97, 0x00, 0x83, 0xF0, 0x00, 
-    0x06, 0x4B, 0x08, 0x03, 0x33, 0x0B, 0x06, 0xC3, 0x4F, 0x59, 0xE0, 0x05, 
-    0x36, 0xCB, 0x0D, 0xD6, 0x7A, 0x85, 0x2C, 0xD0, 0x13, 0x8F, 0xD1, 0x67, 
-    0x00, 0x47, 0x22, 0x7C, 0x49, 0x0A, 0x31, 0x50, 0x03, 0x3E, 0x20, 0x03, 
-    0x4A, 0xAC, 0xC4, 0x4A, 0x86, 0x14, 0xD9, 0x54, 0x38, 0xE4, 0xE2, 0x00, 
-    0xE2, 0xBB, 0xC1, 0xCA, 0xD6, 0xAE, 0x27, 0x42, 0x1A, 0xB0, 0xB8, 0x51, 
-    0x6F, 0x01, 0x8C, 0xBA, 0x33, 0x59, 0xA9, 0x29, 0x16, 0xBD, 0x97, 0x9B, 
-    0xB2, 0x18, 0x5D, 0x5A, 0xA6, 0x08, 0x69, 0xEB, 0x74, 0xA4, 0xF4, 0x49, 
-    0x4B, 0xB6, 0x58, 0xDD, 0x90, 0x3A, 0xD0, 0x7A, 0xFE, 0x3A, 0x28, 0xE0, 
-    0xBF, 0xFF, 0x13, 0x34, 0xCB, 0x19, 0x62, 0x3B, 0x70, 0x03, 0x34, 0x00, 
-    0x58, 0x2D, 0x71, 0x58, 0xB4, 0xB0, 0x02, 0x3C, 0xE0, 0x03, 0x44, 0x2B, 
-    0x2F, 0xB4, 0x13, 0xC6, 0x54, 0x2C, 0x5A, 0x19, 0xDB, 0x20, 0x05, 0x35, 
-    0xBB, 0x2D, 0x41, 0x72, 0xE2, 0x90, 0x66, 0x2F, 0xCA, 0x12, 0x36, 0x14, 
-    0x16, 0xB0, 0xB8, 0xB7, 0xD1, 0x95, 0x2C, 0x51, 0x32, 0xBC, 0x80, 0xF8, 
-    0x77, 0xFE, 0x26, 0x26, 0x83, 0xB1, 0x13, 0x2F, 0xF0, 0x00, 0x9D, 0xFB, 
-    0x5A, 0x23, 0xD6, 0x49, 0x26, 0x26, 0xB7, 0x47, 0x2C, 0x03, 0x70, 0x7B, 
-    0x23, 0x12, 0x13, 0x97, 0xB4, 0xF0, 0x03, 0x0E, 0x6B, 0x2A, 0x9C, 0x5A, 
-    0xC8, 0xCA, 0x06, 0xB8, 0x04, 0xD0, 0x20, 0xED, 0xDB, 0x53, 0xE7, 0x51, 
-    0x98, 0x93, 0x30, 0xB8, 0xBF, 0x95, 0x0B, 0x00, 0x40, 0xAE, 0x66, 0x13, 
-    0xB5, 0xBD, 0x06, 0xBB, 0x0D, 0x3A, 0x6D, 0x36, 0xCA, 0x62, 0x42, 0x24, 
-    0xC7, 0xA6, 0x1A, 0x00, 0x5F, 0xB8, 0xA7, 0x5F, 0xE5, 0xA5, 0xD1, 0xF2, 
-    0x01, 0x7A, 0x2A, 0x0F, 0x41, 0xA3, 0xC4, 0x79, 0x6C, 0x3B, 0x51, 0x47, 
-    0xB0, 0x7D, 0x1C, 0xAE, 0x8D, 0x02, 0x48, 0xB2, 0x6C, 0xAF, 0x94, 0x8C, 
-    0x1F, 0x25, 0xDC, 0x12, 0x44, 0x28, 0x55, 0x89, 0x6C, 0x17, 0x71, 0x8A, 
-    0xAC, 0x8D, 0x59, 0x59, 0x71, 0x87, 0x64, 0xA1, 0x18, 0x25, 0x2E, 0x4C, 
-    0x83, 0x33, 0x57, 0x5D, 0xD6, 0x95, 0x00, 0xCF, 0x0C, 0x21, 0xCA, 0x9C, 
-    0x14, 0x15, 0xA3, 0xAD, 0x57, 0x68, 0x40, 0x9D, 0xA9, 0xB0, 0x58, 0x22, 
-    0xCD, 0x28, 0x05, 0x03, 0x04, 0xD3, 0xBD, 0x7A, 0x82, 0x0B, 0x79, 0xFB, 
-    0xCD, 0x37, 0x02, 0x9E, 0x22, 0xCC, 0xA6, 0x68, 0xF1, 0xC1, 0xBF, 0x71, 
-    0x1E, 0xC2, 0xDA, 0x08, 0xB1, 0xCC, 0x12, 0x4B, 0x62, 0x2C, 0xA4, 0xFE, 
-    0x31, 0xB2, 0x02, 0x90, 0xCE, 0x48, 0x26, 0x62, 0x3D, 0xE3, 0x94, 0x1A, 
-    0x74, 0x1D, 0xF9, 0xBC, 0x4C, 0xCC, 0xC1, 0x0D, 0xF1, 0xBC, 0x0F, 0xD4, 
-    0x25, 0x0F, 0x65, 0xD8, 0x12, 0x1D, 0xC0, 0x02, 0x2C, 0x35, 0x02, 0x23, 
-    0xAD, 0x09, 0xFA, 0x06, 0xBA, 0x8D, 0xC2, 0x5E, 0x0A, 0x1D, 0x32, 0x0C, 
-    0x2D, 0x99, 0xA2, 0x36, 0x00, 0x95, 0x5A, 0x1C, 0x8F, 0xCC, 0x12, 0xB4, 
-    0x3C, 0x3E, 0x29, 0x2A, 0xCC, 0xC3, 0x46, 0xCC, 0x8D, 0x00, 0xB5, 0xBF, 
-    0xA1, 0xA9, 0x93, 0x27, 0x03, 0xB4, 0xF0, 0xD1, 0xA7, 0xF8, 0x00, 0xA7, 
-    0x93, 0x3A, 0xED, 0x47, 0x70, 0xCE, 0x12, 0xB9, 0xFD, 0x70, 0x77, 0xD8, 
-    0x35, 0x7A, 0xCC, 0x01, 0x01, 0xA4, 0x18, 0x25, 0xD0, 0x03, 0xD3, 0x3B, 
-    0x4B, 0x2A, 0xC7, 0x82, 0x2B, 0x37, 0x2D, 0x2B, 0x0C, 0x60, 0x02, 0x3A, 
-    0x9D, 0xA4, 0x13, 0x6D, 0x19, 0xBC, 0x9C, 0x9D, 0x8B, 0x68, 0x0A, 0xE4, 
-    0x82, 0xA9, 0x8A, 0x10, 0xCE, 0x53, 0x31, 0x23, 0xDF, 0xF4, 0xD6, 0x93, 
-    0xA7, 0x03, 0x3F, 0x00, 0x58, 0x07, 0xF0, 0x02, 0x98, 0x6C, 0x4F, 0x25, 
-    0x0D, 0x21, 0x7F, 0x9D, 0x55, 0x50, 0x6D, 0x4D, 0xDA, 0x41, 0x0F, 0x22, 
-    0xC0, 0x55, 0x2F, 0xDB, 0x87, 0xB3, 0x20, 0x02, 0x5A, 0x38, 0xD8, 0x49, 
-    0x81, 0x4F, 0x02, 0x10, 0x9F, 0xA6, 0x62, 0xA0, 0x65, 0x2D, 0x00, 0x39, 
-    0xED, 0x00, 0x3B, 0x8D, 0x93, 0x2B, 0x5C, 0x19, 0x2A, 0xF1, 0x1B, 0xAD, 
-    0xD1, 0xD3, 0x8F, 0xF0, 0xD3, 0xDD, 0x00, 0x77, 0x0C, 0x1A, 0x96, 0x5E, 
-    0x67, 0x17, 0x80, 0xAB, 0xB1, 0x1C, 0xA7, 0x03, 0xA9, 0x9C, 0x5D, 0x33, 
-    0x00, 0xD9, 0xFF, 0x13, 0xD8, 0x90, 0xDB, 0xB9, 0x83, 0x15, 0xD2, 0xC8, 
-    0xDB, 0x3F, 0xFA, 0x70, 0x14, 0x99, 0x20, 0x5B, 0xD0, 0x04, 0xCA, 0xF6, 
-    0x03, 0x0A, 0xFE, 0x0E, 0x67, 0x2A, 0x83, 0x4C, 0xC5, 0x99, 0xBD, 0xD9, 
-    0x38, 0x89, 0x01, 0x0D, 0xB0, 0x93, 0x11, 0x40, 0x9D, 0x7C, 0x51, 0xD1, 
-    0xB4, 0xF9, 0x0A, 0x9F, 0x48, 0x1A, 0x1E, 0x30, 0x93, 0xBC, 0x0B, 0x3C, 
-    0x81, 0xFB, 0x08, 0x03, 0x82, 0xC2, 0xAB, 0xDD, 0x84, 0x35, 0x80, 0xB8, 
-    0xB4, 0xF0, 0x41, 0xFD, 0xB5, 0x67, 0xCE, 0x13, 0xD3, 0x4E, 0xF7, 0xB8, 
-    0x10, 0x20, 0xC0, 0x9D, 0x10, 0x53, 0xCC, 0x48, 0x97, 0x42, 0xC1, 0x7E, 
-    0x21, 0xE4, 0x58, 0x39, 0xF0, 0xCA, 0x3C, 0x02, 0xDD, 0x2A, 0x04, 0x02, 
-    0x43, 0x98, 0xD6, 0x76, 0x2B, 0x1C, 0xCB, 0xAD, 0x39, 0xCE, 0x6D, 0x1C, 
-    0xF6, 0xDD, 0x0D, 0x74, 0x2D, 0x09, 0x62, 0xE1, 0x01, 0xF1, 0xBB, 0x92, 
-    0x2E, 0x9A, 0x4E, 0xAA, 0x3D, 0xB5, 0x2A, 0xE8, 0x03, 0xC1, 0x8B, 0x4A, 
-    0xD0, 0xE4, 0xA7, 0x30, 0x20, 0x02, 0xD2, 0xB6, 0x00, 0xE6, 0x2D, 0x7D, 
-    0x09, 0xD0, 0x1C, 0x81, 0x96, 0x1D, 0x68, 0x64, 0x3C, 0x67, 0xD4, 0xC3, 
-    0xCA, 0x73, 0x46, 0xE4, 0x95, 0x26, 0xDE, 0x2C, 0x5A, 0x1D, 0x06, 0xA9, 
-    0xCA, 0xCD, 0xDC, 0xFF, 0xDD, 0x20, 0x2A, 0xA3, 0xAC, 0xB4, 0x30, 0xE0, 
-    0x90, 0x70, 0x42, 0x38, 0x99, 0x95, 0xE4, 0xC2, 0xDD, 0x0C, 0xDE, 0x84, 
-    0x96, 0xCC, 0x0D, 0x07, 0x10, 0xE1, 0x1C, 0xE4, 0x55, 0xDA, 0x0C, 0x01, 
-    0x17, 0xAE, 0x83, 0x21, 0xDD, 0x01, 0x56, 0xED, 0x09, 0xC2, 0xBB, 0x55, 
-    0xEE, 0xA0, 0x4C, 0x9D, 0x44, 0x9A, 0xA6, 0x82, 0xD0, 0x30, 0x4A, 0x4B, 
-    0x61, 0x91, 0xE2, 0xFE, 0xAD, 0x35, 0x2A, 0x73, 0xA0, 0x8A, 0xD0, 0x1A, 
-    0x8C, 0xB7, 0x66, 0x75, 0x5B, 0x99, 0x91, 0x50, 0xE3, 0x76, 0x41, 0x72, 
-    0x6B, 0x8D, 0x76, 0x0F, 0xCE, 0x12, 0x3B, 0xAE, 0xDE, 0xB5, 0xB5, 0x00, 
-    0x3F, 0x6E, 0xE1, 0x58, 0xAA, 0xFE, 0x09, 0xA8, 0x97, 0x5D, 0x41, 0x4E, 
-    0x08, 0x2F, 0x60, 0x7A, 0xCA, 0x62, 0xDB, 0xDC, 0x22, 0x14, 0x75, 0xEC, 
-    0x24, 0x36, 0x5D, 0x0B, 0x43, 0xC8, 0x1A, 0x19, 0xE0, 0x00, 0xBD, 0x2B, 
-    0x00, 0x0C, 0x20, 0x6A, 0x74, 0xB6, 0xE2, 0xE2, 0x92, 0xA2, 0x56, 0x7E, 
-    0xAF, 0xB9, 0x91, 0x0A, 0x05, 0x10, 0x01, 0x29, 0x50, 0x89, 0x42, 0x1A, 
-    0x2F, 0xA4, 0xDD, 0x0D, 0x1C, 0xDD, 0x84, 0x3A, 0x20, 0x03, 0xF0, 0xE3, 
-    0xD8, 0xF9, 0xE3, 0x4C, 0x42, 0xE4, 0xD2, 0x27, 0x25, 0xDB, 0x92, 0x42, 
-    0xE1, 0xCE, 0xA3, 0xE6, 0x6B, 0xEE, 0xB9, 0x7F, 0xC7, 0xB6, 0x91, 0x71, 
-    0x08, 0xC0, 0x5D, 0x52, 0x3B, 0x51, 0xC4, 0x3D, 0x32, 0x1B, 0xAB, 0x31, 
-    0x99, 0x09, 0x28, 0xD7, 0xDE, 0x90, 0x23, 0xED, 0xB4, 0x3B, 0x86, 0x3E, 
-    0xA0, 0xBE, 0x8C, 0x0C, 0x10, 0x7B, 0x02, 0x03, 0x22, 0x09, 0xDB, 0x8D, 
-    0xCE, 0xC7, 0x6A, 0x80, 0x35, 0x40, 0x6B, 0x6E, 0x2E, 0x30, 0xA0, 0x6E, 
-    0x17, 0xFF, 0xCC, 0x52, 0xA9, 0xBE, 0xDE, 0x2B, 0xC5, 0x52, 0x5C, 0x5D, 
-    0x8A, 0xAA, 0x3A, 0xEA, 0x39, 0x41, 0x30, 0x6E, 0xFC, 0x99, 0x41, 0x23, 
-    0xB7, 0x69, 0xB2, 0x6E, 0xBB, 0xFA, 0xE7, 0x0D, 0x41, 0x96, 0x0D, 0xE0, 
-    0xD0, 0xB6, 0x52, 0xE5, 0xBF, 0x11, 0xC9, 0x45, 0x58, 0x0E, 0x15, 0xD0, 
-    0x2F, 0x6D, 0xAD, 0x92, 0xE6, 0x3B, 0x79, 0xC3, 0x4E, 0x0B, 0xFC, 0x8C, 
-    0xE4, 0xB6, 0x03, 0x01, 0x71, 0xCE, 0x02, 0xDA, 0xCC, 0x12, 0x28, 0x20, 
-    0x02, 0xD2, 0x83, 0x9C, 0x80, 0x71, 0xC6, 0xD2, 0x48, 0x22, 0x52, 0xAD, 
-    0xB8, 0xD5, 0xD7, 0x28, 0xE5, 0x18, 0x4E, 0x47, 0xC2, 0x2E, 0x06, 0x70, 
-    0xE2, 0x03, 0xA0, 0x0B, 0x8D, 0xA3, 0x32, 0x84, 0xCC, 0x0D, 0x3A, 0xC2, 
-    0xDA, 0xE7, 0xC0, 0xB1, 0xB9, 0x1B, 0x69, 0x46, 0xFE, 0xCD, 0x71, 0x31, 
-    0x70, 0x67, 0xD4, 0xC4, 0x0E, 0xD4, 0x2B, 0x97, 0x0F, 0x90, 0x85, 0x2D, 
-    0xFB, 0xEC, 0x21, 0xD3, 0x99, 0xF2, 0x1E, 0x47, 0xA3, 0xDE, 0x87, 0x82, 
-    0xBA, 0x1D, 0x7F, 0x17, 0xC7, 0xFA, 0x78, 0xED, 0x8D, 0x22, 0xE3, 0x2D, 
-    0xD2, 0x90, 0x16, 0xA0, 0xED, 0x03, 0xE0, 0xE7, 0xDF, 0x09, 0xE5, 0xAF, 
-    0xF0, 0x1A, 0x54, 0xFE, 0x68, 0x07, 0x32, 0x7B, 0x8C, 0x7A, 0x0E, 0x48, 
-    0x3D, 0x4E, 0xBF, 0xDB, 0xD1, 0x96, 0x9E, 0xAD, 0x79, 0xF9, 0xA7, 0x80, 
-    0x61, 0x3D, 0xD2, 0x0C, 0x03, 0x2D, 0xD5, 0x52, 0x30, 0xFD, 0xE6, 0xFA, 
-    0xB8, 0x5A, 0x8F, 0xD1, 0x4C, 0xCE, 0xC2, 0x02, 0x30, 0xCD, 0xEF, 0x59, 
-    0x45, 0x30, 0xAC, 0xCE, 0x23, 0x0D, 0xD4, 0x00, 0x30, 0xBF, 0x39, 0x91, 
-    0x10, 0xA4, 0xA7, 0x29, 0xEB, 0xB9, 0x59, 0x64, 0x1C, 0xA3, 0x35, 0x05, 
-    0xA5, 0x59, 0xD1, 0x0D, 0xA5, 0x05, 0x81, 0x5C, 0x28, 0x6C, 0x00, 0x30, 
-    0x7E, 0x5A, 0x7F, 0x75, 0x1D, 0x66, 0x2E, 0x30, 0xA7, 0xE4, 0x91, 0xD2, 
-    0x0E, 0x40, 0xDC, 0xF0, 0xEE, 0xFB, 0xD0, 0xE6, 0xB4, 0x40, 0x83, 0x09, 
-    0xA0, 0x08, 0x77, 0xEE, 0x24, 0x5E, 0xDF, 0x2B, 0x32, 0x4F, 0xF3, 0xEC, 
-    0x42, 0xEB, 0x1C, 0x65, 0xBF, 0x69, 0xE2, 0xE4, 0x40, 0xA2, 0x78, 0xAF, 
-    0x79, 0x0A, 0x68, 0xB8, 0xE0, 0xC6, 0x85, 0x64, 0x7B, 0x3D, 0x5B, 0x74, 
-    0x9E, 0x41, 0x81, 0x75, 0xF7, 0x63, 0x42, 0xD0, 0x6C, 0x74, 0xF9, 0x09, 
-    0xA0, 0xC9, 0x29, 0xAB, 0x55, 0xF0, 0x49, 0x3E, 0x5C, 0x99, 0x01, 0x7F, 
-    0xBE, 0x19, 0x8A, 0xD2, 0x22, 0xE0, 0x8E, 0x22, 0x91, 0x0E, 0xC9, 0x77, 
-    0x22, 0x01, 0x8F, 0x3F, 0x09, 0x8E, 0x17, 0xAF, 0x93, 0xD3, 0xF3, 0x9E, 
-    0xF5, 0xB3, 0x1D, 0x60, 0xF5, 0x9A, 0xA0, 0xC9, 0x27, 0xAD, 0xF9, 0xFE, 
-    0x83, 0xDA, 0xD4, 0xBA, 0x0F, 0x92, 0x2D, 0x4C, 0x83, 0x4D, 0x11, 0xC8, 
-    0x8D, 0x33, 0x01, 0x9C, 0xA6, 0x2E, 0x19, 0x85, 0xF0, 0xCD, 0x8A, 0x22, 
-    0xE4, 0x42, 0xD4, 0x2D, 0xF1, 0x88, 0xD5, 0x60, 0x5A, 0xC9, 0xB0, 0x95, 
-    0xB8, 0xE0, 0xBE, 0xDD, 0x70, 0xD1, 0x1D, 0x7D, 0xA7, 0xDA, 0x81, 0xAD, 
-    0xF1, 0xE3, 0xFB, 0x21, 0xB2, 0x46, 0x63, 0xA8, 0x14, 0x04, 0xD3, 0xC0, 
-    0xA7, 0x16, 0x34, 0x06, 0xED, 0x34, 0xEA, 0x16, 0x0C, 0x87, 0x94, 0x4F, 
-    0x1B, 0x00, 0xE5, 0xAB, 0x6F, 0xCB, 0xF5, 0x42, 0x27, 0xB3, 0x32, 0x67, 
-    0x0C, 0xF5, 0x9A, 0x16, 0x70, 0x71, 0x49, 0x08, 0xF4, 0xD2, 0xCD, 0x71, 
-    0xB4, 0x96, 0xB6, 0x80, 0xF0, 0x10, 0x30, 0x48, 0x18, 0x40, 0xC2, 0x22, 
-    0x90, 0xA8, 0x78, 0xF0, 0x51, 0xE8, 0xF8, 0x08, 0x19, 0x29, 0x39, 0x49, 
-    0x59, 0x69, 0x79, 0x89, 0xF9, 0x71, 0xA0, 0x88, 0x92, 0x80, 0x59, 0x38, 
-    0x92, 0x78, 0xE0, 0xF9, 0x59, 0x6A, 0x7A, 0xF9, 0x91, 0xB8, 0x12, 0x03, 
-    0xD0, 0xEA, 0xFA, 0x0A, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, 0x1B, 
-    0x5B, 0x72, 0x31, 0xC0, 0xDB, 0xDB, 0x62, 0xA0, 0x18, 0x2C, 0x3C, 0x4C, 
-    0x9C, 0xC8, 0xE0, 0xD1, 0x2B, 0x81, 0xBB, 0xCC, 0xDC, 0xEC, 0x0C, 0x40, 
-    0xD0, 0xCB, 0x50, 0x5C, 0x6C, 0x82, 0xD0, 0x8B, 0xCD, 0x7B, 0x71, 0x22, 
-    0x61, 0x11, 0x51, 0x20, 0x5B, 0x51, 0x12, 0xB2, 0x8B, 0x8D, 0x00, 0x42, 
-    0xAD, 0x08, 0xD2, 0x7B, 0xF1, 0xEC, 0xFE, 0x0E, 0x1F, 0x2F, 0xEF, 0xBA, 
-    0x23, 0x4A, 0x4A, 0xC9, 0x72, 0x1F, 0x90, 0xF0, 0x42, 0x7D, 0x30, 0x72, 
-    0x2A, 0xA0, 0xC0, 0x81, 0x04, 0x25, 0x69, 0x52, 0xD4, 0x81, 0x50, 0x02, 
-    0x11, 0x24, 0x2A, 0x25, 0xD8, 0x24, 0x60, 0x41, 0xC1, 0x89, 0xA6, 0x3A, 
-    0x24, 0xF2, 0xFE, 0x31, 0x2F, 0xA3, 0xC6, 0x59, 0x15, 0x4E, 0x64, 0x1B, 
-    0xE0, 0x01, 0x5D, 0xBA, 0x91, 0xC5, 0x14, 0xF4, 0x0A, 0xB1, 0x31, 0x25, 
-    0x3C, 0x0A, 0xBD, 0x1C, 0x90, 0x14, 0x66, 0x40, 0x41, 0x86, 0x8F, 0x34, 
-    0x79, 0x11, 0x68, 0xD0, 0xA0, 0x26, 0xAF, 0x0C, 0x22, 0x47, 0xB6, 0xE8, 
-    0x45, 0x41, 0xA5, 0xD0, 0xA1, 0x44, 0x61, 0xDD, 0x10, 0xD5, 0x88, 0x12, 
-    0x84, 0x17, 0x84, 0x66, 0x40, 0x4C, 0x84, 0x63, 0xC5, 0x30, 0x80, 0x14, 
-    0xAB, 0x5A, 0xBD, 0x4A, 0x28, 0x94, 0x22, 0x11, 0x83, 0x16, 0x08, 0x80, 
-    0x51, 0x49, 0x44, 0xA2, 0x4E, 0x58, 0xCB, 0x3A, 0xF2, 0x2A, 0x80, 0x46, 
-    0xD1, 0xB5, 0xCD, 0x52, 0x44, 0x33, 0x67, 0xE2, 0xA5, 0x5C, 0x61, 0x1A, 
-    0x7A, 0x35, 0x60, 0x8B, 0x17, 0x56, 0x04, 0x6C, 0xD3, 0xE6, 0x2A, 0x72, 
-    0xA1, 0xE2, 0x9A, 0xCE, 0xC1, 0xD8, 0x7E, 0xC9, 0x9D, 0xC9, 0xAB, 0x44, 
-    0xDE, 0xC5, 0x8C, 0x71, 0xC5, 0x90, 0x21, 0x0A, 0xEC, 0x24, 0x08, 0x02, 
-    0x48, 0x3C, 0x40, 0x11, 0x2C, 0x87, 0x8E, 0x56, 0x3E, 0xA4, 0x06, 0x93, 
-    0x38, 0x30, 0x01, 0xE5, 0x44, 0x22, 0xF4, 0x99, 0x3D, 0x8D, 0xE9, 0xC1, 
-    0xD3, 0x19, 0x01, 0x2C, 0x52, 0x95, 0xF4, 0x40, 0x91, 0x20, 0xD4, 0x65, 
-    0xB5, 0xAE, 0xD8, 0xDC, 0xB8, 0xF1, 0x04, 0x0C, 0x1F, 0x55, 0x6C, 0xF0, 
-    0x0B, 0x9C, 0x01, 0xBB, 0xDC, 0x78, 0x73, 0xF2, 0x72, 0x09, 0x3C, 0x18, 
-    0x03, 0x05, 0x0E, 0x08, 0xD7, 0xE4, 0xF0, 0x5B, 0xAE, 0x70, 0x9B, 0xC4, 
-    0xAB, 0x5B, 0x07, 0x60, 0x03, 0x47, 0xA2, 0x17, 0x0D, 0x23, 0x51, 0x7E, 
-    0x9A, 0xE8, 0x06, 0x2B, 0x57, 0x3A, 0x68, 0x08, 0xEB, 0x90, 0xD4, 0x54, 
-    0x02, 0x8B, 0xC1, 0x3A, 0x98, 0xA6, 0x0D, 0x3F, 0x52, 0xEC, 0xAD, 0x89, 
-    0xD2, 0x43, 0x4A, 0x80, 0x59, 0xFE, 0x00, 0xEB, 0xF8, 0x56, 0x0F, 0x0A, 
-    0xE8, 0x71, 0x1D, 0x5B, 0x05, 0x84, 0xF0, 0x51, 0x06, 0x2E, 0x24, 0x27, 
-    0x40, 0x4C, 0xC0, 0x90, 0x64, 0x00, 0x36, 0x01, 0x0E, 0xB5, 0x57, 0x2F, 
-    0x07, 0x22, 0x28, 0x0C, 0x08, 0x2E, 0x28, 0xC0, 0x81, 0x03, 0xC8, 0x14, 
-    0xE8, 0x40, 0x0B, 0x2E, 0x2C, 0x38, 0x97, 0x0A, 0x40, 0x3D, 0x48, 0x22, 
-    0x5E, 0x31, 0x68, 0x27, 0x80, 0x7B, 0x91, 0xF4, 0xA3, 0x08, 0x0D, 0xB8, 
-    0xC9, 0x72, 0x94, 0x30, 0xA0, 0x95, 0x22, 0xD6, 0x30, 0x07, 0x48, 0x56, 
-    0xD5, 0x21, 0x10, 0xEC, 0x08, 0x01, 0x0B, 0xB3, 0xF1, 0x07, 0x89, 0x56, 
-    0x8B, 0x50, 0x82, 0x16, 0x04, 0x40, 0x56, 0xF5, 0x50, 0x22, 0x3C, 0x94, 
-    0x38, 0x94, 0x2E, 0x1F, 0x19, 0x96, 0x1C, 0x03, 0xD7, 0x20, 0x30, 0xE1, 
-    0x48, 0xD8, 0x4C, 0xC0, 0xE4, 0x46, 0xC6, 0x0D, 0x80, 0x00, 0x88, 0x14, 
-    0x7E, 0x29, 0xD7, 0x06, 0xD8, 0x44, 0x90, 0x65, 0x99, 0x2A, 0xD9, 0xE0, 
-    0x19, 0x04, 0x0B, 0xD8, 0xD7, 0x95, 0x22, 0x3B, 0xDC, 0x62, 0x9E, 0x30, 
-    0x10, 0xBC, 0x37, 0x49, 0x2A, 0x02, 0xB0, 0x40, 0xC2, 0x07, 0x2C, 0x46, 
-    0x64, 0xD5, 0x65, 0xC4, 0xBC, 0x76, 0x64, 0x21, 0x35, 0x26, 0x62, 0xA4, 
-    0x24, 0x24, 0x88, 0xD2, 0x5D, 0xA0, 0xA1, 0xB1, 0x87, 0xC3, 0x78, 0x66, 
-    0xCA, 0xD3, 0xD1, 0x47, 0x21, 0x51, 0xF8, 0x13, 0x36, 0x2A, 0x78, 0x49, 
-    0x4C, 0x73, 0xBC, 0x90, 0xF9, 0x68, 0x3C, 0x13, 0x58, 0x0A, 0x66, 0xA8, 
-    0x2F, 0x71, 0xD0, 0x0B, 0x06, 0x9D, 0x9E, 0x2A, 0x4F, 0x0F, 0xC1, 0x14, 
-    0x5A, 0xC8, 0xA1, 0x89, 0x38, 0x4A, 0x4B, 0x0C, 0x39, 0x0C, 0x83, 0x02, 
-    0x9B, 0x93, 0xD4, 0xF8, 0xA3, 0x45, 0x07, 0x58, 0x95, 0x64, 0x8A, 0x22, 
-    0x3C, 0x30, 0x83, 0x6C, 0x8A, 0x3A, 0xC2, 0x1E, 0xFE, 0x9F, 0x92, 0x20, 
-    0xF2, 0xD5, 0xB0, 0x03, 0x7D, 0x90, 0xDF, 0x0A, 0x36, 0xA0, 0x0A, 0x8F, 
-    0x5B, 0xD9, 0x20, 0x10, 0x17, 0x82, 0x20, 0x6C, 0x98, 0x4D, 0x06, 0x7D, 
-    0x15, 0x23, 0x22, 0x2F, 0xCA, 0x40, 0xEB, 0x8E, 0x04, 0x85, 0x89, 0x4A, 
-    0x2E, 0x31, 0xD3, 0xF1, 0x62, 0x01, 0xB8, 0xEA, 0x36, 0x83, 0x62, 0x22, 
-    0x3F, 0x12, 0x52, 0x63, 0x0D, 0x8E, 0xCD, 0x2A, 0xCC, 0x3F, 0x97, 0x40, 
-    0xC4, 0xD5, 0x20, 0x94, 0x31, 0x55, 0xD5, 0x7C, 0x07, 0x24, 0xAA, 0x15, 
-    0x0B, 0xCA, 0x12, 0x32, 0x9F, 0x00, 0xEF, 0x3A, 0x32, 0xDF, 0x7E, 0x03, 
-    0xAB, 0xC7, 0x9E, 0xB3, 0xEB, 0x3A, 0x13, 0xA1, 0xA5, 0xD1, 0x25, 0x67, 
-    0xCD, 0x60, 0x50, 0x0E, 0x63, 0x12, 0x2F, 0x28, 0x3D, 0xDC, 0x0C, 0x6F, 
-    0xBD, 0x68, 0x50, 0x6E, 0xC8, 0x09, 0x62, 0x6B, 0x2A, 0xC7, 0x26, 0xCF, 
-    0x12, 0xA7, 0x3D, 0x8E, 0xB8, 0xBA, 0xA4, 0x63, 0x3B, 0xA4, 0xAC, 0x48, 
-    0x3E, 0x95, 0x70, 0x92, 0x15, 0x0A, 0x07, 0x13, 0x34, 0x9F, 0x69, 0x16, 
-    0xA1, 0x50, 0xD5, 0x0C, 0x6B, 0x9A, 0x42, 0xE8, 0x64, 0x77, 0x2E, 0x1C, 
-    0xD0, 0x68, 0x0E, 0x9F, 0x8C, 0xCB, 0xA7, 0xBD, 0x18, 0x48, 0xA1, 0x01, 
-    0x9A, 0xF6, 0x42, 0x40, 0x08, 0x6F, 0x2D, 0xBD, 0x6D, 0x30, 0x75, 0xF1, 
-    0x72, 0x17, 0xD2, 0xB7, 0x54, 0x30, 0xF5, 0x00, 0x20, 0x8B, 0x2C, 0x6A, 
-    0xA5, 0x9B, 0x6A, 0x4D, 0x36, 0x00, 0x89, 0x74, 0x80, 0xAC, 0x8A, 0x82, 
-    0x0A, 0x90, 0x83, 0x33, 0x31, 0x06, 0x73, 0x23, 0x25, 0xF9, 0x09, 0xF0, 
-    0x1A, 0x9D, 0xCB, 0x26, 0xA2, 0xF0, 0x3E, 0x98, 0xED, 0x5A, 0xD0, 0x7A, 
-    0xA2, 0x00, 0xEA, 0x10, 0xDE, 0x92, 0x04, 0x5B, 0x19, 0xD1, 0xA6, 0xD4, 
-    0x78, 0x74, 0xD9, 0xB5, 0x60, 0x83, 0xE9, 0x5C, 0x2E, 0x08, 0x56, 0xFE, 
-    0x6A, 0x05, 0x00, 0x14, 0xE0, 0x51, 0x36, 0x17, 0x1B, 0x33, 0x9C, 0xE2, 
-    0xB4, 0x28, 0xDD, 0x8B, 0x02, 0x60, 0x83, 0x79, 0x35, 0x2F, 0x41, 0x69, 
-    0x7E, 0xB2, 0x28, 0x83, 0x0A, 0xDC, 0x6A, 0x22, 0xCF, 0x36, 0xF3, 0x76, 
-    0x30, 0xA5, 0x0D, 0xBE, 0x88, 0xAD, 0x55, 0x21, 0x9B, 0x9E, 0x9D, 0xA8, 
-    0x13, 0x54, 0x6C, 0x22, 0x80, 0x4F, 0x02, 0x43, 0x7D, 0x91, 0x24, 0x99, 
-    0x2F, 0x6A, 0x30, 0x1C, 0x90, 0xF7, 0x40, 0x68, 0xE1, 0xB0, 0x3A, 0xE9, 
-    0xB3, 0x94, 0x33, 0x40, 0xD5, 0x72, 0x19, 0x20, 0x76, 0x32, 0xB0, 0x94, 
-    0xD0, 0xF5, 0x00, 0xDA, 0x06, 0xD3, 0x60, 0x2F, 0xCA, 0xCF, 0x62, 0x41, 
-    0x36, 0x97, 0x7E, 0x9E, 0x5C, 0xE8, 0x03, 0x5C, 0x00, 0xCE, 0xF6, 0x0F, 
-    0xD3, 0x2B, 0x4C, 0xF0, 0xFA, 0x0A, 0xF0, 0xC3, 0x33, 0x90, 0x0D, 0xD3, 
-    0x41, 0xA2, 0x8E, 0xF8, 0xAD, 0xC8, 0x02, 0x76, 0x13, 0x84, 0xD6, 0x3F, 
-    0x49, 0x89, 0x85, 0xA3, 0x40, 0xF3, 0xB1, 0xB0, 0x80, 0x4D, 0xF0, 0xEC, 
-    0x12, 0x88, 0x18, 0x20, 0x24, 0x68, 0x47, 0x1B, 0x3B, 0xDD, 0xCC, 0x14, 
-    0x23, 0xC8, 0x0F, 0x0D, 0x60, 0x65, 0xBE, 0x57, 0x6C, 0xE9, 0x6B, 0x73, 
-    0x01, 0x01, 0x62, 0xD8, 0xC1, 0x29, 0x58, 0x50, 0xEE, 0x49, 0x20, 0xBA, 
-    0x52, 0x04, 0x61, 0xD1, 0x3D, 0x6C, 0x5C, 0x0F, 0x7C, 0x72, 0x11, 0xDF, 
-    0x00, 0xB0, 0xF4, 0x41, 0x75, 0xA1, 0x89, 0x18, 0xEA, 0xEB, 0x1D, 0x0E, 
-    0xDC, 0x61, 0x03, 0xF4, 0x2D, 0x62, 0x81, 0x5D, 0x79, 0x8A, 0xCD, 0xB0, 
-    0x02, 0x83, 0xD1, 0x20, 0xA5, 0x2A, 0x62, 0x41, 0x9D, 0xDF, 0xF8, 0x55, 
-    0x09, 0x8B, 0x14, 0x8F, 0x10, 0xBD, 0x4B, 0x11, 0x7C, 0xB4, 0x42, 0x43, 
-    0x54, 0xCC, 0xAD, 0x7D, 0x29, 0x8C, 0x05, 0x81, 0x78, 0xE1, 0xB9, 0xB9, 
-    0x64, 0x0C, 0xFE, 0x1B, 0x14, 0x28, 0xDF, 0x2C, 0xA8, 0x97, 0xAD, 0xBE, 
-    0x3C, 0x2D, 0x83, 0x4D, 0x9C, 0x40, 0xF5, 0x2E, 0x47, 0x42, 0x62, 0x98, 
-    0x20, 0x1B, 0xE9, 0x6A, 0xA2, 0xBA, 0x62, 0x50, 0x83, 0x34, 0xD6, 0xE0, 
-    0x7D, 0xC6, 0x1A, 0xC4, 0x26, 0xE4, 0xE5, 0x8E, 0xCE, 0x4C, 0xC5, 0x50, 
-    0x2F, 0xC0, 0x97, 0x59, 0x48, 0x90, 0xC3, 0x4D, 0xF0, 0x6D, 0x22, 0x94, 
-    0x99, 0x51, 0x92, 0xE4, 0x17, 0x09, 0xC2, 0xC9, 0xAE, 0x57, 0xFD, 0x33, 
-    0xCB, 0x7C, 0x00, 0xF9, 0x09, 0xFF, 0x08, 0xE0, 0x4D, 0x66, 0x84, 0x85, 
-    0xB8, 0x78, 0xA1, 0x82, 0x30, 0x3D, 0xCD, 0x26, 0x8A, 0xB9, 0xC5, 0x06, 
-    0x2D, 0x67, 0x80, 0x6E, 0x0D, 0xE0, 0x5B, 0x8D, 0xDC, 0xCD, 0xB4, 0xA2, 
-    0x18, 0x46, 0x98, 0x68, 0x12, 0x5D, 0x8D, 0x44, 0x5A, 0x3D, 0x7C, 0x37, 
-    0x08, 0xB1, 0xDC, 0x00, 0x1E, 0x31, 0x68, 0x5D, 0x22, 0x66, 0x04, 0x09, 
-    0x12, 0x2C, 0x00, 0x02, 0x88, 0xBC, 0x4A, 0x0E, 0x59, 0x55, 0x10, 0x44, 
-    0xC0, 0x92, 0x32, 0x43, 0x5C, 0x99, 0x00, 0x23, 0x81, 0x16, 0x20, 0xA2, 
-    0x26, 0x36, 0x09, 0x09, 0x88, 0x90, 0x56, 0x00, 0xC7, 0x52, 0xBA, 0x22, 
-    0x62, 0xC8, 0x19, 0x89, 0x06, 0x20, 0x87, 0x35, 0xC9, 0x31, 0x03, 0x8B, 
-    0x22, 0xD4, 0xE4, 0xC6, 0x4A, 0x39, 0xA0, 0x02, 0x29, 0xA0, 0x71, 0x9F, 
-    0xAB, 0x18, 0x36, 0xCA, 0xA8, 0x4C, 0x93, 0xF1, 0xE0, 0x6C, 0xA4, 0x70, 
-    0x61, 0xAA, 0x3C, 0xB3, 0x95, 0xFB, 0x19, 0x2E, 0x20, 0xC3, 0xB3, 0x0F, 
-    0x65, 0x70, 0x09, 0x89, 0x1A, 0x15, 0x72, 0x10, 0xAE, 0x82, 0xE7, 0x69, 
-    0xC4, 0x62, 0xCF, 0x4B, 0x1C, 0x33, 0x79, 0xE1, 0x04, 0x00, 0xE7, 0x06, 
-    0x30, 0x92, 0x4C, 0x7E, 0x24, 0x05, 0xEE, 0x28, 0xC0, 0x96, 0x3E, 0x92, 
-    0xB5, 0x70, 0x46, 0x80, 0x79, 0xFE, 0xBD, 0x40, 0x00, 0x07, 0x7A, 0x02, 
-    0x36, 0x0D, 0x5C, 0x90, 0x92, 0xFD, 0x3C, 0x99, 0x0E, 0x3C, 0x73, 0xBB, 
-    0x44, 0xBC, 0xE8, 0x1D, 0xAD, 0x3C, 0x4F, 0x2D, 0xD7, 0x49, 0x91, 0x22, 
-    0xE6, 0x53, 0x21, 0x9B, 0x28, 0xE6, 0x23, 0xC4, 0xF2, 0xAF, 0xF8, 0x10, 
-    0x6E, 0xA4, 0x94, 0xD8, 0x67, 0x45, 0x5F, 0xC1, 0x38, 0x6A, 0x30, 0x60, 
-    0xA2, 0x03, 0xC0, 0x00, 0x0A, 0xDF, 0x21, 0xAD, 0x8F, 0xB4, 0xA3, 0xA2, 
-    0x05, 0x90, 0x40, 0xF5, 0x76, 0xD2, 0x02, 0xE7, 0x7D, 0x69, 0x03, 0x32, 
-    0xF9, 0x08, 0x06, 0xA4, 0xF9, 0x52, 0x8E, 0xB1, 0x51, 0x32, 0x88, 0x68, 
-    0x99, 0x3C, 0x74, 0xE0, 0x4A, 0xFB, 0x81, 0x14, 0x49, 0x0F, 0x28, 0xA2, 
-    0x00, 0x84, 0xF9, 0x08, 0xAD, 0xF4, 0xD2, 0x4E, 0xB0, 0xBC, 0xE7, 0x56, 
-    0x18, 0xA8, 0x88, 0xC4, 0x25, 0x95, 0x79, 0x42, 0x4D, 0x44, 0xF4, 0x34, 
-    0x66, 0x45, 0x78, 0x54, 0xE0, 0xA0, 0xDA, 0x4B, 0x6A, 0x4F, 0x7F, 0xDA, 
-    0x12, 0x05, 0x30, 0x80, 0x9B, 0x23, 0x61, 0x40, 0x0B, 0xB0, 0x85, 0x0D, 
-    0x02, 0x70, 0x32, 0xA9, 0x1C, 0x8B, 0x81, 0x22, 0xF8, 0x45, 0x38, 0x08, 
-    0xC2, 0x03, 0xAA, 0xE8, 0x14, 0x00, 0x04, 0x92, 0x38, 0x55, 0x4C, 0x0C, 
-    0x2A, 0x11, 0x1F, 0x1D, 0x04, 0xB2, 0x6A, 0x89, 0x52, 0x75, 0x16, 0xA4, 
-    0xAA, 0x3A, 0x14, 0x80, 0xEC, 0x26, 0x21, 0x24, 0xCD, 0xF0, 0xD5, 0x15, 
-    0x13, 0x1C, 0xC6, 0xB5, 0xB2, 0x41, 0x00, 0x2E, 0xCE, 0x23, 0xA7, 0xBD, 
-    0xB8, 0xE9, 0x4B, 0x7B, 0xCA, 0x50, 0x9A, 0x20, 0xC0, 0x01, 0x1C, 0x50, 
-    0x80, 0x06, 0x18, 0x00, 0xDB, 0xD8, 0xC2, 0xD6, 0x04, 0x0A, 0x50, 0x01, 
-    0x5E, 0x3F, 0x42, 0x01, 0xA4, 0x6E, 0x96, 0x63, 0xE3, 0x34, 0xA2, 0x21, 
-    0x12, 0x91, 0xCC, 0x8C, 0x3C, 0xA6, 0xB0, 0x28, 0xFE, 0x98, 0x41, 0x63, 
-    0x13, 0x3B, 0x33, 0xC3, 0x1A, 0x77, 0x12, 0x09, 0x38, 0xDB, 0x7D, 0x5E, 
-    0x69, 0x48, 0x11, 0xCC, 0xED, 0xAB, 0x9F, 0xC8, 0xAC, 0x60, 0x5F, 0xFA, 
-    0xC4, 0x01, 0x80, 0x32, 0x11, 0xDE, 0xEC, 0xC5, 0x09, 0xD2, 0xAA, 0x91, 
-    0xB5, 0x8E, 0x69, 0xB7, 0xAD, 0x28, 0x01, 0x4B, 0x9C, 0x83, 0x5E, 0x9A, 
-    0x10, 0x20, 0xB7, 0xE4, 0x45, 0xDA, 0x0A, 0x0B, 0x17, 0x00, 0xCC, 0xC8, 
-    0x40, 0x28, 0xC3, 0x4D, 0xDF, 0x71, 0x91, 0xBB, 0xA2, 0xDD, 0x41, 0x02, 
-    0x2D, 0xBD, 0x0C, 0x96, 0x01, 0xFB, 0x93, 0x3B, 0x61, 0x20, 0x36, 0xAB, 
-    0x8A, 0xC8, 0xC1, 0x75, 0x5F, 0xFA, 0xC8, 0x01, 0x44, 0x32, 0x11, 0x4E, 
-    0x03, 0x2D, 0x41, 0x8B, 0x92, 0xD3, 0xBD, 0x92, 0xD7, 0xBC, 0xA9, 0x4D, 
-    0x6F, 0x4D, 0x4E, 0x60, 0x01, 0xF0, 0xB6, 0x57, 0xA9, 0xBA, 0x1B, 0x44, 
-    0x3F, 0x9C, 0xAA, 0x92, 0xFA, 0xBA, 0x6E, 0x9E, 0xF8, 0x25, 0x48, 0x92, 
-    0x46, 0x01, 0x09, 0xCC, 0x0C, 0xD8, 0x14, 0x24, 0xA8, 0x63, 0x30, 0x68, 
-    0xD0, 0xAE, 0xDB, 0x59, 0xA2, 0x60, 0x06, 0xDE, 0x30, 0x00, 0x98, 0x99, 
-    0x88, 0xC7, 0x65, 0xE3, 0xA8, 0x78, 0x11, 0xEF, 0x35, 0x6D, 0x0C, 0x80, 
-    0x0A, 0x58, 0x20, 0x04, 0x6C, 0x4D, 0x2F, 0x06, 0x42, 0x50, 0x02, 0x0D, 
-    0x03, 0xF9, 0x61, 0xEF, 0xDB, 0x4F, 0xEF, 0x56, 0xB0, 0x96, 0x18, 0xF8, 
-    0xA0, 0x5D, 0xA2, 0x90, 0x6A, 0x89, 0x0B, 0x42, 0xB8, 0xAE, 0x0E, 0x22, 
-    0x14, 0x2C, 0x65, 0xF1, 0x08, 0x2A, 0x9B, 0x03, 0x19, 0xB0, 0x22, 0x18, 
-    0x2B, 0x26, 0x84, 0x7F, 0x6A, 0x6C, 0xE3, 0x7F, 0x42, 0xEF, 0x23, 0x12, 
-    0x66, 0x4B, 0x0A, 0x4E, 0xB0, 0xE4, 0x70, 0x44, 0xC0, 0x02, 0x12, 0x90, 
-    0x00, 0x4E, 0xEE, 0x7C, 0xE7, 0x3A, 0x97, 0x40, 0xB4, 0x71, 0x3E, 0xFE, 
-    0x95, 0x1A, 0xFF, 0x2C, 0x03, 0x19, 0xF0, 0x00, 0x45, 0x0A, 0x49, 0xC4, 
-    0x03, 0xD9, 0xA2, 0x83, 0x97, 0xC1, 0x6D, 0x01, 0xF7, 0xBD, 0x32, 0x25, 
-    0x74, 0x45, 0x27, 0x15, 0x13, 0x84, 0x04, 0x23, 0x78, 0xC1, 0x74, 0xD3, 
-    0x22, 0xE6, 0x56, 0xD4, 0x40, 0x11, 0x5D, 0x76, 0x84, 0x7F, 0x6E, 0x13, 
-    0x67, 0x6C, 0xDC, 0xF6, 0x02, 0x7C, 0xEE, 0xB3, 0xA9, 0x4F, 0x4D, 0x8B, 
-    0x1A, 0xF8, 0x40, 0x06, 0x37, 0xA0, 0x81, 0x0C, 0xD3, 0x21, 0xE3, 0xD1, 
-    0xA0, 0x19, 0xD1, 0x3F, 0x28, 0x6C, 0x07, 0x96, 0xEB, 0xE8, 0x4F, 0xB8, 
-    0x4A, 0x7D, 0x84, 0xF0, 0xCA, 0x7F, 0x75, 0x3D, 0x02, 0xE9, 0x0E, 0x83, 
-    0x06, 0x32, 0x08, 0x2E, 0x00, 0x52, 0x76, 0xD9, 0x47, 0x28, 0x92, 0x9F, 
-    0x36, 0xAE, 0xB0, 0xE8, 0x94, 0x8C, 0xEA, 0x68, 0xF7, 0xD9, 0x06, 0x3E, 
-    0xB8, 0xC1, 0xAB, 0xFD, 0x02, 0x4B, 0xC2, 0xB1, 0xED, 0xC0, 0xF4, 0xDD, 
-    0xC1, 0x0F, 0xA8, 0xDC, 0x81, 0x11, 0x48, 0x36, 0xD7, 0x83, 0x10, 0xE4, 
-    0x23, 0x92, 0x84, 0xD5, 0x4A, 0xB4, 0x38, 0xC0, 0x6C, 0xFB, 0x41, 0x0F, 
-    0xAE, 0xBB, 0x69, 0xD2, 0xA0, 0xE2, 0x29, 0x8C, 0x8C, 0x73, 0x91, 0x09, 
-    0x50, 0x49, 0x69, 0xEB, 0x3B, 0xCE, 0x36, 0x90, 0x01, 0xCC, 0x48, 0x82, 
-    0xB6, 0x05, 0x08, 0x7C, 0x01, 0x22, 0x18, 0x0D, 0x2C, 0x5D, 0xA5, 0x8A, 
-    0x7A, 0x2F, 0xA6, 0x07, 0xBD, 0x15, 0x85, 0x9A, 0xC4, 0x4D, 0xEE, 0x48, 
-    0xEC, 0x0C, 0x12, 0xFD, 0x48, 0xA9, 0x25, 0x3E, 0x30, 0x83, 0x00, 0xE3, 
-    0xE0, 0x06, 0x3B, 0xD8, 0xA8, 0x2C, 0x1A, 0x3E, 0xEE, 0x00, 0x28, 0x52, 
-    0xE1, 0x4B, 0xCE, 0x6E, 0x34, 0xF7, 0x8D, 0xF2, 0x0D, 0xF7, 0xE0, 0x06, 
-    0x85, 0xF5, 0x87, 0x9A, 0x60, 0x90, 0x6C, 0x91, 0x9B, 0x06, 0x2D, 0x2D, 
-    0x32, 0x76, 0xFE, 0x5E, 0x6A, 0xE0, 0x6A, 0x2A, 0x43, 0x40, 0x04, 0x3F, 
-    0x8B, 0x78, 0x00, 0xE6, 0xA3, 0xE5, 0x24, 0xF5, 0xB2, 0x10, 0xC0, 0x62, 
-    0x01, 0x78, 0xD2, 0xE2, 0x03, 0x66, 0xD3, 0xC2, 0x06, 0x31, 0xBB, 0x38, 
-    0xBD, 0x51, 0x9D, 0xE0, 0x01, 0x3C, 0x38, 0xE5, 0x54, 0x7F, 0xA9, 0x0E, 
-    0x64, 0xD0, 0x72, 0xF8, 0xBD, 0x60, 0x06, 0x0F, 0x08, 0xB9, 0x24, 0xE8, 
-    0x17, 0x8C, 0x1B, 0x78, 0x7C, 0x31, 0xFF, 0x0E, 0x06, 0x0A, 0x5E, 0xB0, 
-    0x80, 0x11, 0x3C, 0xA0, 0xD1, 0xC3, 0xFA, 0xCE, 0x7B, 0xB4, 0x42, 0xA7, 
-    0x07, 0xCC, 0x72, 0x18, 0x2B, 0xB8, 0x41, 0xB1, 0x9D, 0x91, 0x32, 0xFD, 
-    0x7A, 0xFA, 0x29, 0xF3, 0x45, 0x75, 0x84, 0x6C, 0x5A, 0xF5, 0xC0, 0x87, 
-    0xB3, 0x06, 0xAE, 0xAC, 0x17, 0x0B, 0x20, 0x6E, 0x95, 0xC5, 0xAA, 0x22, 
-    0xD3, 0x8B, 0x11, 0xB1, 0x5C, 0x0E, 0xD0, 0xA3, 0x81, 0x4B, 0x7E, 0xF2, 
-    0x69, 0x5F, 0xBB, 0xF0, 0xA0, 0xFB, 0x08, 0x8B, 0xC8, 0x38, 0x00, 0x30, 
-    0x30, 0xFA, 0xB0, 0x49, 0xDE, 0x0C, 0x1F, 0x04, 0x43, 0xB2, 0xBD, 0x62, 
-    0x9B, 0xCD, 0x97, 0xBC, 0x97, 0x10, 0x40, 0x5B, 0xF0, 0xAC, 0xD7, 0x5C, 
-    0x0F, 0xCA, 0xCE, 0x69, 0x5C, 0x9B, 0x45, 0xF1, 0x8B, 0xE7, 0xF6, 0x46, 
-    0x4E, 0x74, 0x1E, 0x00, 0x4E, 0xDE, 0xD2, 0xA1, 0x82, 0xBC, 0xEE, 0x1F, 
-    0x00, 0x7C, 0x9F, 0xF1, 0x68, 0xF8, 0x3B, 0x02, 0xA0, 0xDA, 0x81, 0xFF, 
-    0x00, 0x36, 0x91, 0x40, 0x80, 0xEF, 0x99, 0x0F, 0x0A, 0x76, 0x74, 0x69, 
-    0x43, 0xD3, 0xC0, 0x07, 0x63, 0x6F, 0xC6, 0x29, 0xE5, 0xCD, 0x5C, 0x76, 
-    0x0B, 0x23, 0x07, 0x34, 0xB0, 0x7B, 0xA0, 0xBF, 0x0F, 0xFE, 0xF0, 0xCB, 
-    0xA0, 0x07, 0x35, 0xB0, 0xBD, 0xD6, 0xF2, 0xDD, 0xFA, 0xF4, 0x6B, 0xEE, 
-    0x31, 0x54, 0x3E, 0x9B, 0xC0, 0xFE, 0x11, 0x0F, 0x9F, 0x07, 0x54, 0x36, 
-    0xAC, 0x62, 0x2F, 0x8A, 0x0E, 0xD0, 0x77, 0x58, 0x4A, 0x60, 0xBC, 0xE0, 
-    0xD1, 0x0F, 0x25, 0xFC, 0x20, 0x90, 0x3B, 0x0B, 0x44, 0x7B, 0x05, 0x46, 
-    0x6C, 0xD5, 0xF7, 0x0C, 0x17, 0xC5, 0x09, 0x92, 0x35, 0x80, 0x22, 0x43, 
-    0x03, 0xEE, 0xA6, 0x7E, 0x0F, 0x08, 0x81, 0x19, 0x81, 0x75, 0x1E, 0xB5, 
-    0x30, 0x2D, 0x76, 0x74, 0x4A, 0x72, 0x7A, 0xF2, 0x10, 0x03, 0x9E, 0x11, 
-    0x3F, 0x44, 0x54, 0x7C, 0xF7, 0xF5, 0x01, 0x30, 0x40, 0x70, 0x10, 0x70, 
-    0x81, 0xFE, 0x17, 0x0C, 0xE9, 0xB6, 0x0F, 0xDB, 0xC7, 0x03, 0x3B, 0x50, 
-    0x03, 0x06, 0x08, 0x0F, 0x0D, 0x27, 0x00, 0xBC, 0xF6, 0x08, 0x05, 0x93, 
-    0x0E, 0x28, 0xC0, 0x73, 0x2F, 0x40, 0x82, 0x14, 0x52, 0x77, 0x3E, 0x50, 
-    0x7E, 0x11, 0xE8, 0x83, 0x3F, 0x48, 0x0B, 0xF7, 0x17, 0x0C, 0x32, 0x33, 
-    0x55, 0x1F, 0x10, 0x40, 0xC3, 0x80, 0x03, 0x3B, 0x60, 0x7E, 0xCD, 0xD0, 
-    0x5B, 0x29, 0x35, 0x03, 0x2C, 0x50, 0x59, 0x28, 0x58, 0x0A, 0x09, 0x10, 
-    0x7C, 0xDA, 0x57, 0x2E, 0x5A, 0x16, 0x00, 0x42, 0xC2, 0x03, 0x2E, 0x38, 
-    0x0F, 0xAA, 0x42, 0x66, 0x94, 0xA0, 0x78, 0x10, 0x70, 0x7C, 0x65, 0xA6, 
-    0x6C, 0xC8, 0xE7, 0x62, 0xC5, 0xC0, 0x03, 0x00, 0x02, 0x84, 0x6B, 0xE8, 
-    0x83, 0xEF, 0x25, 0x00, 0x71, 0x53, 0x62, 0x09, 0x50, 0x69, 0x47, 0xB7, 
-    0x02, 0x18, 0xD1, 0x85, 0x7F, 0xB5, 0x00, 0xC8, 0xC2, 0x09, 0x56, 0xD6, 
-    0x2F, 0x73, 0x83, 0x03, 0xE2, 0x07, 0x88, 0x81, 0x28, 0x68, 0xA2, 0x70, 
-    0x6B, 0x90, 0x40, 0x19, 0x38, 0xC0, 0x85, 0xF3, 0x80, 0x7B, 0x08, 0x41, 
-    0x09, 0x08, 0x07, 0x40, 0x31, 0x17, 0x10, 0xC8, 0x37, 0x03, 0xC3, 0xE7, 
-    0x87, 0x2B, 0xB8, 0x84, 0x6C, 0x88, 0x89, 0x7D, 0xFE, 0xD6, 0x03, 0xE8, 
-    0x44, 0x4B, 0x11, 0x47, 0x02, 0xEC, 0xC6, 0x03, 0x97, 0xB8, 0x74, 0x59, 
-    0x67, 0x58, 0x22, 0x00, 0x03, 0x07, 0xA3, 0x1A, 0x7A, 0x37, 0x85, 0xC5, 
-    0xA2, 0x74, 0xCC, 0x10, 0x23, 0x60, 0xF1, 0x1E, 0xAE, 0x02, 0x7A, 0x2A, 
-    0xF1, 0x03, 0x72, 0x42, 0x09, 0x2C, 0xA2, 0x8A, 0xA7, 0x81, 0x71, 0xD3, 
-    0x65, 0x89, 0x99, 0xE8, 0x8B, 0xD1, 0x76, 0x7D, 0xFA, 0x91, 0x23, 0x62, 
-    0x81, 0x02, 0x24, 0x36, 0x11, 0x95, 0x26, 0x0C, 0xC8, 0xC4, 0x51, 0xED, 
-    0x67, 0x58, 0x0B, 0x44, 0x02, 0x4E, 0x41, 0x28, 0x10, 0x60, 0x8C, 0x98, 
-    0x40, 0x3F, 0x6A, 0xE1, 0x0E, 0x3A, 0x80, 0x79, 0x90, 0x10, 0x58, 0x6B, 
-    0x11, 0x6F, 0xAB, 0xC2, 0x5C, 0x07, 0x70, 0x43, 0x03, 0xF3, 0x65, 0xC2, 
-    0xC0, 0x78, 0xBF, 0x68, 0x8E, 0x1B, 0xC6, 0x74, 0x67, 0x03, 0x89, 0x9F, 
-    0x70, 0x84, 0x29, 0x42, 0x86, 0x01, 0x41, 0x02, 0xF3, 0xC7, 0x44, 0xCD, 
-    0x20, 0x2B, 0xC2, 0x80, 0x27, 0x81, 0x44, 0x0C, 0xD3, 0x48, 0x8D, 0xEC, 
-    0x91, 0x81, 0xB6, 0x30, 0x4E, 0x64, 0x11, 0x09, 0x98, 0x61, 0x8D, 0x44, 
-    0xB1, 0x81, 0xC3, 0xD0, 0x65, 0x33, 0xF0, 0x3A, 0x9F, 0x90, 0x00, 0xBF, 
-    0xC7, 0x76, 0x96, 0x60, 0x81, 0x8A, 0x80, 0x03, 0x76, 0x78, 0x8E, 0x13, 
-    0x99, 0x54, 0x8B, 0x88, 0x85, 0xA7, 0xF0, 0x8C, 0x73, 0xB3, 0x79, 0xA7, 
-    0x91, 0x43, 0x99, 0xD1, 0x8A, 0xB2, 0x90, 0x68, 0xED, 0x02, 0x01, 0xC9, 
-    0xF6, 0x01, 0xF3, 0x07, 0x40, 0xFA, 0xA8, 0x90, 0x9B, 0xF0, 0x42, 0xCE, 
-    0x50, 0x8B, 0xC9, 0x82, 0x8F, 0x02, 0xD0, 0x77, 0x43, 0xB1, 0x89, 0xA2, 
-    0x80, 0x76, 0x28, 0x19, 0x00, 0x32, 0xE8, 0x90, 0xE7, 0x21, 0x7B, 0xA1, 
-    0xA1, 0x87, 0x02, 0xF0, 0x91, 0x14, 0x09, 0x94, 0x1F, 0xD4, 0x92, 0xFE, 
-    0x6A, 0x42, 0x79, 0x93, 0xB7, 0x62, 0x7A, 0xB2, 0x08, 0x6A, 0xD2, 0x90, 
-    0x14, 0x21, 0x24, 0x02, 0xB0, 0x02, 0xB3, 0x08, 0x0B, 0x33, 0x19, 0x11, 
-    0x03, 0x36, 0x3C, 0xC2, 0x30, 0x74, 0x03, 0x41, 0x38, 0x12, 0x89, 0x0B, 
-    0xA2, 0x67, 0x58, 0x93, 0x00, 0x11, 0xFD, 0x28, 0x0F, 0x2D, 0x79, 0x55, 
-    0x5E, 0x97, 0x00, 0x5E, 0x77, 0x52, 0xC4, 0x70, 0x78, 0x66, 0x29, 0x09, 
-    0x34, 0x07, 0x96, 0x41, 0xE9, 0x96, 0x9A, 0x03, 0x7B, 0xC5, 0x70, 0x91, 
-    0x04, 0x63, 0x3A, 0xEB, 0xA8, 0x8B, 0xD3, 0x05, 0x95, 0x00, 0x10, 0x03, 
-    0x62, 0x89, 0x93, 0x8E, 0xB0, 0x27, 0xA2, 0xF0, 0x8E, 0xA5, 0x80, 0x19, 
-    0xAB, 0xE0, 0x18, 0x6F, 0xD3, 0x58, 0xCD, 0x25, 0x00, 0x8D, 0x22, 0x14, 
-    0xE5, 0x31, 0x16, 0x76, 0x49, 0x11, 0x0F, 0x50, 0x70, 0xF3, 0x17, 0x83, 
-    0x36, 0x79, 0x8B, 0xC0, 0xF5, 0x96, 0x97, 0x29, 0x94, 0x72, 0xC1, 0x10, 
-    0x93, 0xA0, 0x1A, 0x29, 0xA2, 0x96, 0xA7, 0x31, 0x02, 0x4F, 0xD1, 0x8A, 
-    0x3B, 0xE0, 0x19, 0x07, 0xB0, 0x62, 0x61, 0xF8, 0x99, 0xD5, 0x95, 0x08, 
-    0x31, 0x39, 0x0B, 0x52, 0xD6, 0x2E, 0xB9, 0x58, 0x44, 0x3F, 0xA0, 0x03, 
-    0x35, 0xF0, 0x93, 0xCF, 0x50, 0x8F, 0x9E, 0xA9, 0x2C, 0x54, 0x08, 0x2C, 
-    0x3A, 0x74, 0x00, 0x22, 0xE0, 0x98, 0x8E, 0x30, 0x02, 0xFC, 0x88, 0x99, 
-    0xC3, 0xA9, 0x3C, 0x42, 0x98, 0x0E, 0x9B, 0x69, 0x28, 0xC8, 0x92, 0x90, 
-    0xEB, 0x74, 0x08, 0x50, 0x01, 0x41, 0xD7, 0xC7, 0x08, 0x8D, 0x18, 0x60, 
-    0x52, 0x88, 0x24, 0x10, 0x61, 0x80, 0x84, 0x97, 0x3E, 0x60, 0x48, 0x0C, 
-    0x39, 0x60, 0x77, 0x3D, 0xF8, 0x0E, 0xBD, 0x35, 0x27, 0x45, 0xF8, 0x02, 
-    0xEC, 0x71, 0x76, 0x6C, 0xF7, 0x00, 0x3D, 0x29, 0x1E, 0xC4, 0xA9, 0x9E, 
-    0x8A, 0x13, 0xFE, 0x03, 0x3D, 0xC0, 0x8C, 0x89, 0xB0, 0x91, 0x67, 0xA1, 
-    0x47, 0xB9, 0x38, 0x30, 0x07, 0x31, 0x8F, 0xAD, 0x80, 0x22, 0x70, 0x78, 
-    0x6E, 0x30, 0x30, 0x9E, 0xF5, 0x42, 0x99, 0x58, 0x16, 0x1E, 0xAE, 0x50, 
-    0x03, 0xDE, 0x46, 0x03, 0x59, 0xD7, 0x69, 0x01, 0xF0, 0x12, 0x38, 0xC0, 
-    0x03, 0xD4, 0x87, 0x77, 0xB8, 0x89, 0x5F, 0x0F, 0x50, 0x2C, 0x1D, 0xC0, 
-    0x73, 0x6A, 0xA7, 0x0F, 0x18, 0xD7, 0x93, 0xEC, 0xB3, 0x9E, 0x19, 0xCA, 
-    0x9E, 0x6A, 0x74, 0x14, 0xED, 0xF2, 0x51, 0x0B, 0xA9, 0x8E, 0x8A, 0x62, 
-    0x19, 0xC8, 0x47, 0xA2, 0x92, 0x88, 0x08, 0x2B, 0xB0, 0x82, 0xAF, 0xD0, 
-    0x8D, 0x67, 0x77, 0x8A, 0xC0, 0x37, 0x02, 0x50, 0x28, 0x99, 0x67, 0xB3, 
-    0x94, 0x02, 0x61, 0x84, 0x56, 0x48, 0x0C, 0x07, 0x30, 0x97, 0x85, 0x00, 
-    0x1C, 0x69, 0xC8, 0x0C, 0xE6, 0x41, 0x9D, 0xEB, 0x84, 0x94, 0xFF, 0x97, 
-    0x83, 0x2F, 0x26, 0x03, 0xB5, 0xA9, 0xA1, 0x47, 0xFA, 0x30, 0xEF, 0xF6, 
-    0x3E, 0x38, 0x09, 0xA1, 0xD8, 0x17, 0x7F, 0x0B, 0x80, 0x83, 0x36, 0x1A, 
-    0x0C, 0x75, 0xA7, 0x86, 0xB0, 0xD0, 0x8D, 0x24, 0xB1, 0x02, 0xE8, 0xB3, 
-    0x9C, 0x9E, 0x26, 0x77, 0x91, 0x49, 0x7C, 0x3B, 0x27, 0x70, 0x3B, 0xD9, 
-    0x2A, 0x04, 0x27, 0xA5, 0xAB, 0xB2, 0x14, 0xFF, 0x89, 0xA0, 0x57, 0x05, 
-    0x48, 0x45, 0x77, 0x81, 0x38, 0xF0, 0x03, 0x3C, 0x68, 0x0B, 0xE6, 0xF1, 
-    0x6B, 0x25, 0x46, 0x02, 0x0B, 0x08, 0x15, 0x1C, 0x27, 0x8A, 0x48, 0xAA, 
-    0xA7, 0xEA, 0x22, 0x15, 0x28, 0x56, 0x08, 0x7B, 0x72, 0x95, 0x14, 0x91, 
-    0x00, 0x4F, 0x38, 0x17, 0x1B, 0x97, 0x74, 0xB6, 0x50, 0x78, 0xC2, 0xB0, 
-    0xA0, 0xCF, 0xF2, 0x3E, 0xAF, 0x11, 0x82, 0x50, 0x0A, 0x01, 0xFD, 0x47, 
-    0x12, 0x36, 0x28, 0x79, 0x76, 0xFE, 0xAA, 0x47, 0x2F, 0xD0, 0xA2, 0x5D, 
-    0x77, 0x0A, 0x2F, 0x00, 0x89, 0x1F, 0x20, 0x77, 0x6D, 0x2A, 0x03, 0x06, 
-    0x18, 0x23, 0x33, 0x3A, 0x30, 0xF1, 0xA8, 0xA8, 0x0C, 0xBA, 0xA7, 0xA9, 
-    0xAA, 0x3C, 0xBD, 0x05, 0x4B, 0x35, 0x12, 0x8E, 0xD1, 0x25, 0x17, 0x0D, 
-    0xF8, 0x6E, 0x43, 0x11, 0x97, 0xD4, 0x90, 0x03, 0x3C, 0xC0, 0x6A, 0xB5, 
-    0x4A, 0x0D, 0xCF, 0x37, 0x86, 0x55, 0x45, 0x9F, 0x65, 0x91, 0x00, 0xB3, 
-    0x14, 0x7D, 0x3C, 0x0A, 0x0B, 0x05, 0x19, 0x9F, 0x81, 0x02, 0x7F, 0x9C, 
-    0x39, 0x37, 0x79, 0xA9, 0xAA, 0xCD, 0xCA, 0x61, 0x02, 0x30, 0x40, 0xFC, 
-    0x40, 0x28, 0xA9, 0x79, 0x09, 0x0F, 0xD0, 0x9F, 0xE9, 0xA0, 0xA0, 0x70, 
-    0xCA, 0x16, 0xBA, 0xAA, 0x08, 0x69, 0xD8, 0x8A, 0x36, 0xD0, 0x03, 0x82, 
-    0x76, 0x6D, 0x55, 0x46, 0x6E, 0x9D, 0x97, 0x8C, 0xE9, 0xD9, 0x0A, 0xEF, 
-    0xF3, 0xA3, 0x82, 0x2A, 0x09, 0x45, 0xE4, 0x23, 0x96, 0x80, 0x38, 0x46, 
-    0xEA, 0xAC, 0xF3, 0x7A, 0x2A, 0xD7, 0x37, 0x02, 0xCC, 0x22, 0x38, 0xEA, 
-    0xD6, 0x73, 0x72, 0xE8, 0x10, 0xDA, 0xB7, 0x02, 0x0D, 0x58, 0x6C, 0xF2, 
-    0x7A, 0x26, 0xEF, 0x99, 0x08, 0x39, 0x80, 0xAA, 0xB8, 0x10, 0x43, 0xC2, 
-    0xB0, 0xAE, 0x13, 0xC1, 0x02, 0x68, 0x3A, 0x09, 0xB2, 0x34, 0x5D, 0x2B, 
-    0x89, 0x9F, 0xF0, 0x59, 0x16, 0x87, 0x00, 0x73, 0xF6, 0x02, 0x09, 0x34, 
-    0x38, 0x92, 0x61, 0xA1, 0x0A, 0x02, 0x4B, 0xAF, 0x1F, 0x5B, 0x22, 0xDD, 
-    0xF8, 0x14, 0x39, 0xBA, 0x0F, 0xE3, 0x68, 0x30, 0xA9, 0xF4, 0xA3, 0xC1, 
-    0x7A, 0x74, 0x6E, 0xDA, 0x96, 0x79, 0x21, 0x65, 0x3C, 0x40, 0x03, 0x31, 
-    0x3B, 0x7D, 0x2D, 0xF8, 0x0C, 0xC1, 0x68, 0x8A, 0xF0, 0x91, 0x24, 0x3E, 
-    0x42, 0xAD, 0x8F, 0x50, 0x95, 0x17, 0xE1, 0x0A, 0xFE, 0xEF, 0x75, 0x8F, 
-    0x56, 0x51, 0x24, 0x63, 0x41, 0x62, 0x97, 0x46, 0xB2, 0x01, 0x40, 0x38, 
-    0x84, 0x09, 0xB2, 0x4B, 0xEB, 0x67, 0xC3, 0xD0, 0x97, 0x83, 0x00, 0x99, 
-    0x02, 0x34, 0x03, 0x8D, 0x00, 0xA2, 0xC9, 0x16, 0x9A, 0x99, 0x71, 0xB0, 
-    0xE6, 0xF3, 0x5E, 0x1B, 0xCB, 0x1F, 0xFE, 0x01, 0x79, 0x0B, 0x30, 0x03, 
-    0x3B, 0x3B, 0x08, 0x25, 0xA9, 0x0A, 0x8E, 0x62, 0x9C, 0x86, 0xB5, 0x00, 
-    0x81, 0x39, 0x09, 0x7F, 0x49, 0x5D, 0x44, 0xF7, 0x00, 0x2F, 0x8A, 0x10, 
-    0x90, 0x88, 0x16, 0xB3, 0xC6, 0xB4, 0x75, 0x5B, 0x22, 0x6C, 0x94, 0xAF, 
-    0x8F, 0x00, 0xB1, 0xA6, 0x73, 0x0F, 0xDF, 0xF1, 0x3B, 0x7A, 0x58, 0x77, 
-    0x1E, 0xAB, 0x35, 0x71, 0x72, 0xB4, 0x58, 0x81, 0xAF, 0x70, 0xB3, 0x75, 
-    0x62, 0x8B, 0x2C, 0xF7, 0x09, 0x00, 0x13, 0xB8, 0x15, 0x6A, 0x1B, 0x4B, 
-    0x6F, 0xFB, 0x14, 0x16, 0xC1, 0xB5, 0x7A, 0xDB, 0x8E, 0x2F, 0xA0, 0x4E, 
-    0xA3, 0xC1, 0x9A, 0x76, 0xCB, 0xB9, 0xD6, 0xF1, 0x03, 0x5A, 0x7A, 0x6E, 
-    0x26, 0x7B, 0x36, 0xFD, 0x43, 0x38, 0x38, 0xF9, 0x01, 0x0D, 0x53, 0x8E, 
-    0x4D, 0xC4, 0x95, 0xC7, 0x4A, 0x10, 0xBF, 0x0A, 0xA2, 0xC5, 0x20, 0x02, 
-    0x81, 0x1A, 0x09, 0x35, 0x32, 0x90, 0x3F, 0x7B, 0x6D, 0xDC, 0x51, 0x10, 
-    0xFE, 0x91, 0x87, 0xDB, 0x61, 0x37, 0x83, 0xAA, 0x47, 0x7C, 0xE8, 0x4B, 
-    0xFF, 0xD1, 0xB9, 0xC3, 0x7B, 0x1D, 0x7E, 0xF5, 0x86, 0x8E, 0x00, 0x03, 
-    0x03, 0xB8, 0x00, 0x30, 0x90, 0x28, 0xC8, 0x32, 0x4F, 0x3D, 0x9B, 0xBA, 
-    0x66, 0xE4, 0x19, 0xA4, 0x6A, 0x09, 0xC1, 0xB2, 0xA5, 0x92, 0x20, 0xBA, 
-    0x06, 0xD9, 0x58, 0x9E, 0x1A, 0x7C, 0x7A, 0xB8, 0x4A, 0xB2, 0x10, 0x03, 
-    0xDE, 0x26, 0x27, 0x14, 0x2A, 0x10, 0xA2, 0x01, 0x3F, 0xF7, 0x73, 0xFE, 
-    0xB5, 0x6F, 0x38, 0x74, 0x94, 0xD1, 0xB2, 0xC4, 0xEB, 0xBE, 0x2A, 0xC1, 
-    0x95, 0x2A, 0xD2, 0x62, 0x92, 0x9A, 0x94, 0x00, 0x28, 0x0A, 0xF3, 0x43, 
-    0xBB, 0x89, 0x68, 0x3E, 0x8A, 0x50, 0x16, 0x68, 0xD1, 0x81, 0x0E, 0xC9, 
-    0x7B, 0xC4, 0xD0, 0x01, 0x5D, 0x05, 0x99, 0xC5, 0xE0, 0x22, 0xB6, 0x30, 
-    0x9B, 0xAD, 0x66, 0x76, 0x61, 0x2B, 0x10, 0xE9, 0x3B, 0x43, 0xB0, 0xD1, 
-    0x1E, 0x37, 0xC3, 0xBE, 0xEF, 0x4B, 0xC1, 0x8B, 0xC1, 0x09, 0xDA, 0x17, 
-    0x66, 0x3E, 0xE0, 0x6A, 0xC5, 0xB0, 0x79, 0x35, 0xC2, 0xAC, 0x29, 0xA4, 
-    0x08, 0xBF, 0x7A, 0x0A, 0xF9, 0x41, 0x3C, 0xBA, 0x26, 0x7C, 0x43, 0x4A, 
-    0x1A, 0xA7, 0xD8, 0x91, 0x99, 0x21, 0xB3, 0x1F, 0x2C, 0x0B, 0x2B, 0x37, 
-    0x84, 0x23, 0x40, 0xBD, 0xFB, 0xC0, 0xB6, 0x6D, 0xA4, 0x10, 0x2B, 0x6C, 
-    0x76, 0x2F, 0xA0, 0xA9, 0x5A, 0xD1, 0xBE, 0x15, 0xEC, 0xC3, 0xF0, 0x40, 
-    0x8A, 0x6C, 0x13, 0xB3, 0x1B, 0x85, 0x73, 0x73, 0x44, 0x08, 0xFD, 0x20, 
-    0x56, 0xFD, 0xD4, 0x84, 0x0B, 0x6B, 0x0A, 0x30, 0x50, 0x2C, 0x9D, 0x78, 
-    0x0A, 0xD9, 0x2B, 0x0C, 0x3F, 0x30, 0x7E, 0xC2, 0xD5, 0x03, 0xB5, 0x86, 
-    0x10, 0x3D, 0xF7, 0x09, 0x7E, 0xD2, 0x1E, 0xDD, 0xB1, 0x10, 0x25, 0x58, 
-    0x2F, 0x2A, 0x99, 0xA7, 0x3F, 0x4C, 0xC6, 0xCC, 0xB0, 0x46, 0x3C, 0x98, 
-    0x46, 0xFA, 0xEB, 0x86, 0x02, 0x40, 0x0A, 0xE6, 0x9B, 0x03, 0x82, 0x6B, 
-    0x3E, 0x7B, 0x39, 0x17, 0x1D, 0xF0, 0x70, 0xEF, 0x68, 0xAE, 0x6F, 0x28, 
-    0xC2, 0x91, 0x50, 0xA7, 0xE0, 0xA1, 0xB4, 0x42, 0xB1, 0x03, 0x37, 0xD0, 
-    0x2E, 0xC5, 0xA5, 0x96, 0xAF, 0xBB, 0x08, 0x60, 0x71, 0xA1, 0x34, 0xB0, 
-    0x46, 0xE3, 0xBA, 0x48, 0x65, 0xCC, 0xC8, 0x0F, 0x72, 0x9B, 0x85, 0xD2, 
-    0x99, 0x74, 0xFE, 0xCB, 0x57, 0x89, 0xFA, 0x12, 0x1D, 0xA0, 0xC3, 0x0E, 
-    0x59, 0x23, 0x44, 0x78, 0x0A, 0x2A, 0xDB, 0xB1, 0x6C, 0x61, 0x03, 0x2C, 
-    0x47, 0x93, 0x33, 0xEA, 0xC0, 0xC4, 0x80, 0x03, 0x55, 0x0A, 0x00, 0x3A, 
-    0xF0, 0xB9, 0xAA, 0x50, 0x7F, 0x8D, 0xCC, 0xCA, 0xD6, 0xE1, 0x19, 0xAC, 
-    0x41, 0x38, 0xDF, 0xBB, 0x61, 0x94, 0x3C, 0x17, 0x87, 0xE7, 0x10, 0x62, 
-    0x81, 0x1E, 0xA1, 0x71, 0x84, 0x7F, 0x68, 0x22, 0x8E, 0x1B, 0x83, 0xBF, 
-    0x79, 0xBA, 0xC4, 0xB0, 0xA0, 0x63, 0xDC, 0xCA, 0xC5, 0x6C, 0xC1, 0xF5, 
-    0x81, 0x2C, 0x20, 0xB6, 0x61, 0x62, 0x39, 0x0C, 0xDC, 0x27, 0xB3, 0x05, 
-    0x5A, 0x0C, 0x28, 0xF0, 0xAB, 0x87, 0x80, 0xB1, 0xE5, 0x8B, 0x2C, 0x9B, 
-    0x5B, 0x14, 0x9F, 0x9C, 0x4E, 0x98, 0xC0, 0xB6, 0x6D, 0x63, 0xCC, 0xDF, 
-    0x5C, 0x26, 0x8B, 0x50, 0xB0, 0xC4, 0x5C, 0x4A, 0xB3, 0xF9, 0x67, 0x60, 
-    0x69, 0x03, 0x03, 0xCA, 0x6A, 0xED, 0x82, 0xA3, 0x92, 0x15, 0x2C, 0x9A, 
-    0x8C, 0x91, 0xEC, 0xE1, 0xC2, 0x1B, 0x71, 0x75, 0x7D, 0x2A, 0xBB, 0x44, 
-    0x37, 0x5D, 0xA6, 0x0C, 0xCE, 0xFB, 0x6C, 0x1D, 0xAD, 0x03, 0x6A, 0x40, 
-    0x68, 0x03, 0xDF, 0x16, 0xA2, 0x9C, 0x79, 0x00, 0xA6, 0xB9, 0x28, 0x4E, 
-    0x09, 0xC7, 0x8A, 0x38, 0x81, 0x1D, 0xF0, 0x8E, 0xED, 0x28, 0xBC, 0xFC, 
-    0x0C, 0xD1, 0xD5, 0xC1, 0x7E, 0xB2, 0xE9, 0x8B, 0x3B, 0x40, 0x2F, 0x24, 
-    0x7B, 0x10, 0x79, 0x23, 0x7F, 0xCB, 0x1B, 0x72, 0x07, 0x51, 0xBB, 0x8B, 
-    0xC1, 0x98, 0x31, 0x48, 0x96, 0x0D, 0x93, 0xD0, 0x11, 0x6D, 0xD2, 0x20, 
-    0x1B, 0x23, 0xFF, 0x1B, 0x09, 0x07, 0xA1, 0x3E, 0x66, 0xC7, 0x02, 0x5C, 
-    0x87, 0x59, 0x1A, 0x55, 0x1D, 0x72, 0xA4, 0x9F, 0x94, 0x40, 0x3F, 0xFF, 
-    0x7C, 0xD2, 0x39, 0x4D, 0xC1, 0xFE, 0xA7, 0x54, 0xD3, 0x7A, 0x6B, 0x11, 
-    0xC1, 0xD3, 0x94, 0xAB, 0x82, 0xA9, 0x88, 0xE4, 0xB3, 0xD5, 0x11, 0xD2, 
-    0x4C, 0xBC, 0x0F, 0xEC, 0xA1, 0xCC, 0x3A, 0xCD, 0xD4, 0x9C, 0x9B, 0xB0, 
-    0x36, 0x7C, 0x6E, 0x88, 0x90, 0x2F, 0x41, 0x7D, 0xA3, 0x00, 0x34, 0x1B, 
-    0xAB, 0x19, 0x20, 0xEF, 0x13, 0x9E, 0xFD, 0x5A, 0xD4, 0x4D, 0xED, 0xD5, 
-    0x76, 0x5B, 0x90, 0x77, 0x72, 0x3F, 0x7E, 0xC3, 0x15, 0x4F, 0x81, 0x03, 
-    0xCF, 0x1C, 0x97, 0xC2, 0x19, 0x20, 0x2B, 0x94, 0xCB, 0x5C, 0x2D, 0x00, 
-    0xFA, 0xFB, 0xD5, 0x71, 0x8D, 0xA4, 0xEF, 0xD5, 0xD6, 0xB1, 0x54, 0x52, 
-    0x05, 0xAB, 0xCF, 0x00, 0x20, 0x95, 0xC4, 0x50, 0xD2, 0xF4, 0x35, 0x2B, 
-    0xD5, 0xCC, 0x5C, 0x02, 0x29, 0xD7, 0x83, 0xFD, 0xB1, 0x4F, 0xAD, 0x36, 
-    0x41, 0xD2, 0xAD, 0xB6, 0x97, 0xC8, 0x8A, 0x70, 0x03, 0x79, 0x6D, 0x1D, 
-    0x1D, 0x15, 0x83, 0x0E, 0x39, 0xC1, 0x84, 0x4D, 0xD9, 0xAA, 0x0A, 0xD9, 
-    0x5D, 0x66, 0x11, 0x7D, 0x4C, 0x36, 0x4B, 0x6A, 0x09, 0x5E, 0x81, 0xCD, 
-    0x95, 0x0D, 0xDA, 0x19, 0xCA, 0x95, 0x4F, 0x3B, 0x1F, 0xDE, 0xAC, 0x38, 
-    0xA4, 0x09, 0xAD, 0xF4, 0x89, 0x08, 0xF3, 0x1C, 0xDA, 0xAD, 0x0D, 0x94, 
-    0xA7, 0xA4, 0x8A, 0xA3, 0xD1, 0xC3, 0xD0, 0x92, 0x1D, 0x34, 0x69, 0x2B, 
-    0xE6, 0xEB, 0x93, 0xAE, 0xAD, 0xDB, 0xA2, 0x9D, 0x08, 0xC6, 0xE8, 0x2A, 
-    0x12, 0xCB, 0x9E, 0xCC, 0x0C, 0x79, 0xC3, 0x07, 0x11, 0xB2, 0xBC, 0xDB, 
-    0xC7, 0x8D, 0x99, 0x31, 0x32, 0x74, 0x35, 0x62, 0x3E, 0x45, 0x5C, 0x0C, 
-    0x4F, 0x89, 0xDC, 0xD1, 0x3D, 0x9C, 0x31, 0x02, 0xCF, 0x50, 0x6B, 0x99, 
-    0x71, 0xBC, 0x03, 0xE2, 0x37, 0xAB, 0xD2, 0xCD, 0xDD, 0x6F, 0x19, 0x23, 
-    0xD1, 0xE9, 0x08, 0x98, 0xC1, 0xB8, 0xDD, 0x4D, 0xEE, 0xDE, 0xE5, 0xED, 
-    0x0A, 0x5C, 0x69, 0x58, 0xF6, 0x81, 0xC4, 0xE4, 0x6C, 0xDE, 0xED, 0x4D, 
-    0xD8, 0x35, 0x50, 0x9A, 0x3B, 0xC7, 0x9F, 0x8A, 0x30, 0xDB, 0xEE, 0x6D, 
-    0xDF, 0x84, 0x2D, 0xC7, 0xA4, 0x7C, 0xDF, 0xFB, 0xDD, 0xDD, 0x36, 0x50, 
-    0x76, 0x4B, 0xCD, 0xDF, 0x01, 0xEE, 0xDA, 0x16, 0x0D, 0x91, 0x7D, 0x2D, 
-    0xE0, 0x07, 0x9E, 0xD3, 0x3A, 0xB0, 0x6A, 0xEC, 0x8D, 0xE0, 0x0D, 0xEE, 
-    0xE0, 0x0F, 0x0E, 0xE1, 0x11, 0x2E, 0xE1, 0x13, 0x4E, 0xE1, 0x15, 0x6E, 
-    0xE1, 0x17, 0x8E, 0xE1, 0x19, 0xAE, 0xE1, 0x1B, 0xCE, 0xE1, 0x1D, 0xEE, 
-    0xE1, 0x1F, 0x0E, 0xE2, 0x21, 0x2E, 0xE2, 0x23, 0x4E, 0xE2, 0x25, 0x6E, 
-    0xE2, 0x27, 0x8E, 0xE2, 0x29, 0xAE, 0xE2, 0x2B, 0xCE, 0xE2, 0x2D, 0xEE, 
-    0xE2, 0x2F, 0x0E, 0xE3, 0x31, 0x2E, 0xE3, 0x33, 0x4E, 0xE3, 0x35, 0x6E, 
-    0xE3, 0x37, 0x8E, 0xE3, 0x39, 0xAE, 0xE3, 0x3B, 0xCE, 0xE3, 0x3D, 0xEE, 
-    0xE3, 0x3F, 0x0E, 0xE4, 0x41, 0x2E, 0xE4, 0x43, 0x4E, 0xE4, 0x45, 0x6E, 
-    0xE4, 0x47, 0x8E, 0xE4, 0x49, 0xAE, 0xE4, 0x4B, 0xCE, 0xE4, 0x4D, 0xEE, 
-    0xE4, 0x4F, 0x0E, 0xE5, 0x51, 0x2E, 0xE5, 0x53, 0x4E, 0xE5, 0x55, 0x6E, 
-    0xE5, 0x57, 0x8E, 0xE5, 0x59, 0xAE, 0xE5, 0x5B, 0xCE, 0xE5, 0x5D, 0xEE, 
-    0xE5, 0x5F, 0x0E, 0xE6, 0x61, 0x2E, 0xE6, 0x63, 0x4E, 0xE6, 0x65, 0x6E, 
-    0xE6, 0x67, 0x8E, 0xE6, 0x69, 0xAE, 0xE6, 0x6B, 0xCE, 0xE6, 0x6D, 0xEE, 
-    0xE6, 0x6F, 0x0E, 0xE7, 0x71, 0x2E, 0xE7, 0x73, 0x4E, 0xE7, 0x75, 0x6E, 
-    0xE7, 0x77, 0x8E, 0xE7, 0x79, 0xAE, 0xE7, 0x7B, 0xCE, 0xE7, 0x7D, 0xEE, 
-    0xE7, 0x7F, 0x0E, 0xE8, 0x26, 0x13, 0x08, 0x00, 0x3B, 
+    0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x8E, 0x02, 0xA2, 0x01, 0xF6, 0x00,
+    0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xB0, 0x4F, 0x00, 0x00, 0x00, 0x66, 0x99,
+    0x00, 0x70, 0x9F, 0x10, 0xF6, 0xF9, 0xF0, 0x06, 0x09, 0x00, 0x00, 0x0B,
+    0x04, 0x5F, 0x8F, 0x00, 0x00, 0xA5, 0x4A, 0x33, 0x4C, 0x00, 0x00, 0x58,
+    0x27, 0x19, 0x26, 0x00, 0x8C, 0xB3, 0x40, 0x4C, 0x72, 0x00, 0x00, 0x84,
+    0x3B, 0x00, 0x2C, 0x13, 0xD9, 0xE6, 0xC0, 0xB3, 0xCC, 0x80, 0xE3, 0xEC,
+    0xD0, 0xA0, 0xBF, 0x60, 0xEC, 0xF3, 0xE0, 0xC6, 0xD9, 0xA0, 0x79, 0xA6,
+    0x20, 0x83, 0xAC, 0x30, 0x59, 0x85, 0x00, 0x26, 0x39, 0x00, 0x0C, 0x13,
+    0x00, 0x3F, 0x5F, 0x00, 0x00, 0x21, 0x0E, 0x52, 0x7C, 0x00, 0x00, 0x8F,
+    0x40, 0x13, 0x1C, 0x00, 0xA9, 0xC6, 0x70, 0x00, 0x42, 0x1D, 0x00, 0x6E,
+    0x31, 0x00, 0x9A, 0x45, 0xD0, 0xDF, 0xB0, 0x2C, 0x42, 0x00, 0x96, 0xB9,
+    0x50, 0x00, 0x16, 0x09, 0xBC, 0xD3, 0x90, 0x46, 0x69, 0x00, 0x10, 0x10,
+    0x10, 0x00, 0x37, 0x18, 0x39, 0x56, 0x00, 0x1F, 0x2F, 0x00, 0x00, 0x4D,
+    0x22, 0x00, 0x79, 0x36, 0xF0, 0xF0, 0xF0, 0x80, 0x80, 0x80, 0x00, 0x63,
+    0x2C, 0x40, 0x40, 0x40, 0xC0, 0xC0, 0xC0, 0xD0, 0xD0, 0xD0, 0x60, 0x60,
+    0x60, 0x20, 0x20, 0x20, 0x30, 0x30, 0x30, 0xE0, 0xE0, 0xE0, 0xA0, 0xA0,
+    0xA0, 0x50, 0x50, 0x50, 0xB0, 0xB0, 0xB0, 0x90, 0x90, 0x90, 0x70, 0x70,
+    0x70, 0x7F, 0x7F, 0x7F, 0xEF, 0xEF, 0xEF, 0x3F, 0x3F, 0x3F, 0xBF, 0xBF,
+    0xBF, 0x0F, 0x0F, 0x0F, 0x9F, 0x9F, 0x9F, 0x5F, 0x5F, 0x5F, 0xDF, 0xDF,
+    0xDF, 0x8F, 0x8F, 0x8F, 0x00, 0x91, 0x42, 0xCF, 0xCF, 0xCF, 0x4F, 0x4F,
+    0x4F, 0x2F, 0x2F, 0x2F, 0x1F, 0x1F, 0x1F, 0x6F, 0x6F, 0x6F, 0xAF, 0xAF,
+    0xAF, 0x00, 0x48, 0x21, 0x00, 0x87, 0x3D, 0x00, 0x1B, 0x0C, 0x00, 0x09,
+    0x04, 0x00, 0x75, 0x35, 0x00, 0x3F, 0x1C, 0x00, 0x51, 0x25, 0x00, 0x7E,
+    0x39, 0x00, 0x24, 0x10, 0x00, 0x1F, 0x0E, 0x00, 0x2D, 0x14, 0x00, 0x6C,
+    0x31, 0x00, 0x12, 0x08, 0x00, 0x36, 0x18, 0x00, 0x5A, 0x29, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x21, 0xF9, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00,
+    0x00, 0x00, 0x8E, 0x02, 0xA2, 0x01, 0x00, 0x07, 0xFE, 0x80, 0x00, 0x82,
+    0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E,
+    0x8F, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A,
+    0x9B, 0x9C, 0x9D, 0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6,
+    0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2,
+    0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE,
+    0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA,
+    0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6,
+    0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2,
+    0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE,
+    0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA,
+    0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x00, 0x03, 0x0A, 0x1C, 0x48, 0xB0, 0xA0,
+    0xC1, 0x83, 0x08, 0x13, 0x2A, 0x5C, 0xC8, 0xB0, 0xA1, 0xC3, 0x87, 0x10,
+    0x23, 0x4A, 0x9C, 0x48, 0xB1, 0xA2, 0xC5, 0x8B, 0x18, 0x33, 0x6A, 0xDC,
+    0xC8, 0xB1, 0xA3, 0xC7, 0x8F, 0x20, 0x43, 0x8A, 0x1C, 0x49, 0xB2, 0xA4,
+    0xC9, 0x93, 0x28, 0x53, 0xAA, 0x5C, 0xC9, 0xB2, 0xA5, 0xCB, 0x97, 0x30,
+    0x63, 0xCA, 0x9C, 0x49, 0xB3, 0xA6, 0xCD, 0x9B, 0x38, 0x73, 0xEA, 0xDC,
+    0xC9, 0xB3, 0xA7, 0xCF, 0x9F, 0x40, 0x57, 0x5A, 0x28, 0x10, 0xB4, 0xA8,
+    0xD1, 0x62, 0x25, 0x06, 0x0C, 0xC0, 0x90, 0x62, 0xC2, 0xD1, 0xA7, 0x50,
+    0x73, 0x85, 0x50, 0x4A, 0xF5, 0x02, 0x85, 0x12, 0x51, 0xB3, 0x6A, 0x6D,
+    0x75, 0x81, 0xAA, 0x57, 0xA5, 0x27, 0x2C, 0x54, 0xD8, 0x4A, 0xB6, 0xEC,
+    0xA7, 0x0A, 0x5F, 0xD3, 0x2A, 0xC5, 0x20, 0xC1, 0xA9, 0xD9, 0xB7, 0xFE,
+    0x70, 0x25, 0xA5, 0xA0, 0x9A, 0xC1, 0x83, 0x5A, 0xAF, 0x56, 0xB1, 0xC6,
+    0xDD, 0xCB, 0xD7, 0x50, 0x03, 0xAA, 0x2D, 0x04, 0x6C, 0xD0, 0xA0, 0xE2,
+    0xAE, 0xD7, 0x13, 0x29, 0xC6, 0xF6, 0x5D, 0x6C, 0xB6, 0x80, 0x57, 0x10,
+    0x02, 0x22, 0x47, 0x76, 0xC1, 0x21, 0x83, 0xE1, 0xB5, 0x21, 0xDC, 0x32,
+    0xDE, 0x3C, 0xAB, 0x00, 0xD1, 0x87, 0x16, 0xA8, 0x22, 0x90, 0x4C, 0x3A,
+    0x32, 0x08, 0x13, 0x76, 0x2F, 0x13, 0xA0, 0xA0, 0x98, 0xB3, 0xEB, 0x54,
+    0x15, 0x2C, 0x9C, 0x18, 0x60, 0x01, 0x22, 0x05, 0xAA, 0x1C, 0x4A, 0xEB,
+    0x16, 0x60, 0x80, 0x30, 0x02, 0xC3, 0x11, 0x5E, 0x0B, 0x27, 0x55, 0x21,
+    0x05, 0x86, 0xC3, 0x10, 0x09, 0x50, 0x75, 0xB1, 0xBB, 0xB9, 0x00, 0x17,
+    0x2D, 0x2C, 0x7F, 0xD5, 0x3C, 0xBC, 0xBA, 0xA6, 0x09, 0x21, 0xBA, 0xAA,
+    0x7D, 0x18, 0xC1, 0xAB, 0x01, 0xE7, 0xE0, 0x4F, 0x7B, 0xB5, 0x4E, 0xFE,
+    0x52, 0x09, 0x0A, 0xDA, 0x0D, 0xEB, 0x65, 0x38, 0x55, 0xA9, 0x03, 0xF0,
+    0xF0, 0x05, 0x8C, 0x2F, 0x4F, 0xDF, 0x51, 0x01, 0x0B, 0x14, 0x94, 0x5F,
+    0xA6, 0x4A, 0xC1, 0x61, 0x7A, 0x13, 0xF1, 0x39, 0xB7, 0xC1, 0x7C, 0x8D,
+    0x9C, 0x10, 0xC2, 0x7A, 0xF5, 0x31, 0x56, 0xDC, 0x6C, 0x97, 0x65, 0xD0,
+    0x02, 0x08, 0x1A, 0x50, 0x45, 0x40, 0x43, 0x68, 0x51, 0xB5, 0x41, 0x80,
+    0xCD, 0x31, 0x50, 0x95, 0x23, 0xA1, 0x29, 0x45, 0x40, 0x58, 0x9F, 0x25,
+    0xB8, 0xD7, 0x5F, 0x86, 0x79, 0x60, 0xC2, 0x85, 0x91, 0x19, 0xE0, 0x55,
+    0x70, 0xDA, 0x44, 0x10, 0x81, 0x04, 0x30, 0xC6, 0x18, 0xA3, 0x05, 0x2E,
+    0x86, 0xF8, 0xC9, 0x5C, 0x4A, 0x65, 0x80, 0x61, 0x86, 0x54, 0x35, 0xD0,
+    0x48, 0x01, 0xE9, 0x79, 0xC5, 0x14, 0x75, 0x22, 0x92, 0x85, 0xE3, 0x57,
+    0x2A, 0x68, 0xFE, 0xF0, 0x9D, 0x6E, 0x0E, 0x50, 0x15, 0xC2, 0x35, 0xD8,
+    0x1D, 0xB7, 0xDF, 0x57, 0x0D, 0x50, 0x20, 0x56, 0x27, 0x0C, 0x0E, 0x10,
+    0xD8, 0x8E, 0xBA, 0x69, 0xA8, 0x94, 0x8F, 0x8C, 0x48, 0xB0, 0xDF, 0x05,
+    0x07, 0x16, 0x49, 0x56, 0x85, 0x4A, 0x71, 0xE0, 0xC2, 0x92, 0xCD, 0x99,
+    0xB0, 0xE1, 0x34, 0x05, 0xA4, 0x10, 0xE4, 0x94, 0x77, 0x31, 0x65, 0x63,
+    0x25, 0x8E, 0x51, 0xC5, 0x00, 0x97, 0xBA, 0xB9, 0xF9, 0x25, 0x23, 0x15,
+    0xE8, 0x47, 0x67, 0x58, 0xAD, 0x99, 0x79, 0xD4, 0x7F, 0xF1, 0x0D, 0x48,
+    0x15, 0x91, 0x67, 0x95, 0x20, 0x01, 0x05, 0x0D, 0x48, 0xE9, 0x15, 0x01,
+    0x55, 0x36, 0xD5, 0x49, 0x09, 0x82, 0xD2, 0x39, 0x25, 0x01, 0x12, 0x60,
+    0x92, 0x94, 0x52, 0xA3, 0xF1, 0x59, 0x9A, 0x02, 0x4E, 0x32, 0x72, 0x1B,
+    0x55, 0x20, 0x50, 0xF6, 0xDB, 0x65, 0x6C, 0x31, 0x6A, 0x68, 0x4F, 0xED,
+    0x0D, 0xE0, 0x41, 0x80, 0xA9, 0x0D, 0x90, 0x02, 0x28, 0x0B, 0x66, 0x4A,
+    0x27, 0x99, 0x85, 0x52, 0x52, 0x40, 0x96, 0x5F, 0x21, 0xE0, 0x00, 0x07,
+    0x0A, 0x14, 0x6B, 0x6C, 0xB1, 0x0E, 0x38, 0x50, 0xAB, 0x5A, 0x18, 0xB8,
+    0xFA, 0xC8, 0xA9, 0x03, 0xE4, 0x26, 0x2A, 0x69, 0xA4, 0x2A, 0xD5, 0xA9,
+    0x22, 0x13, 0x78, 0xB5, 0xA5, 0x69, 0x0A, 0x2C, 0xAB, 0x56, 0x5E, 0xAF,
+    0xFE, 0x94, 0xAD, 0x85, 0xF1, 0x55, 0xBB, 0x54, 0x27, 0x71, 0x4A, 0xAA,
+    0xA9, 0x5A, 0xAC, 0xE1, 0xA9, 0xAE, 0x52, 0x49, 0xA2, 0x18, 0xE0, 0x06,
+    0xD0, 0x79, 0x3B, 0x00, 0x01, 0xB5, 0x51, 0x22, 0xA8, 0x06, 0xD3, 0x52,
+    0x4B, 0xD5, 0xB5, 0x89, 0x90, 0x38, 0x00, 0x02, 0x6C, 0x92, 0x36, 0x58,
+    0x61, 0xFB, 0x21, 0xD6, 0x6B, 0xB8, 0x36, 0xA5, 0xC7, 0x2F, 0x7C, 0x20,
+    0x78, 0xB5, 0x30, 0x25, 0x15, 0xFE, 0x40, 0xBB, 0xEE, 0x7E, 0x00, 0x43,
+    0x52, 0xC0, 0xBB, 0x1C, 0xC8, 0x3B, 0xED, 0x06, 0x1C, 0xA4, 0x95, 0x6F,
+    0x24, 0xE3, 0x2A, 0x55, 0xF0, 0xB4, 0x4D, 0x5A, 0xAB, 0x48, 0x77, 0x54,
+    0x01, 0x08, 0x1F, 0x65, 0xD2, 0x19, 0x76, 0x2B, 0xC3, 0x38, 0x41, 0xAB,
+    0x42, 0x7C, 0x2E, 0x78, 0x35, 0xF3, 0x25, 0x62, 0x96, 0x48, 0xAC, 0x0B,
+    0x0C, 0x78, 0x2C, 0x00, 0x03, 0x2E, 0x74, 0xCB, 0xEC, 0x9D, 0x8C, 0x08,
+    0x3C, 0x40, 0x06, 0x7B, 0xF6, 0x5B, 0xDA, 0x06, 0x29, 0x2F, 0x2A, 0x49,
+    0xAC, 0xEF, 0x81, 0xC7, 0x40, 0xD0, 0xE0, 0x45, 0xCD, 0x22, 0x22, 0xE9,
+    0xE9, 0xB8, 0x23, 0x08, 0x46, 0xAB, 0xE5, 0x2C, 0xCD, 0x30, 0x7D, 0x6A,
+    0xF2, 0x6E, 0xBD, 0xA9, 0xB0, 0x2A, 0x55, 0x27, 0x5C, 0x32, 0xC1, 0xBB,
+    0x39, 0xB6, 0xD0, 0x34, 0x86, 0x06, 0x98, 0x10, 0xB3, 0x87, 0x63, 0x1B,
+    0x72, 0xA4, 0xAC, 0x27, 0x3B, 0x2D, 0x59, 0x0B, 0x78, 0x21, 0xBD, 0x88,
+    0xA4, 0x2E, 0x3B, 0x97, 0x32, 0x02, 0x0F, 0x33, 0x49, 0xD5, 0xD6, 0x7A,
+    0x7B, 0xC5, 0x9C, 0xA8, 0x69, 0xAF, 0x7D, 0x01, 0xD9, 0x39, 0xED, 0x6B,
+    0xB0, 0x09, 0x08, 0xDF, 0x25, 0xB8, 0x23, 0x11, 0xE8, 0x8A, 0xC0, 0x83,
+    0x7E, 0x2B, 0xB0, 0xF6, 0xBD, 0x79, 0x0F, 0x52, 0x80, 0xA0, 0x1E, 0xF4,
+    0xED, 0xB7, 0x64, 0xE6, 0x0E, 0xD0, 0xDF, 0x23, 0x68, 0x0E, 0x00, 0x99,
+    0x73, 0x2A, 0x52, 0xA5, 0x40, 0x73, 0x31, 0x33, 0x4E, 0xC8, 0xE9, 0x54,
+    0x55, 0xED, 0x74, 0xE6, 0xAF, 0x53, 0x6E, 0x13, 0xB4, 0xB9, 0x81, 0x6D,
+    0xEF, 0x57, 0x76, 0x52, 0xD2, 0xA1, 0x57, 0x0A, 0xA8, 0x2E, 0x2A, 0x08,
+    0xCB, 0x12, 0xB0, 0x39, 0x21, 0x3D, 0x2B, 0x35, 0x3B, 0x78, 0x06, 0x30,
+    0xA0, 0x81, 0x02, 0x57, 0xEF, 0x98, 0xF9, 0x00, 0xFE, 0xA5, 0x13, 0x72,
+    0xA4, 0xD7, 0xCE, 0x45, 0xB8, 0x5C, 0x73, 0x5E, 0x39, 0x5B, 0xFD, 0x00,
+    0x73, 0xF7, 0xBB, 0x36, 0x82, 0xC2, 0xCF, 0xB4, 0x3C, 0x02, 0x77, 0xAB,
+    0x05, 0xA2, 0x25, 0x13, 0x64, 0xEA, 0x81, 0xD0, 0xAB, 0x1B, 0xB0, 0x2C,
+    0x06, 0x8C, 0x10, 0xD4, 0xED, 0xC2, 0x13, 0x35, 0xD1, 0x74, 0x2C, 0x3E,
+    0x06, 0x58, 0x5B, 0xDB, 0x1C, 0x91, 0xA5, 0x6D, 0x35, 0x27, 0x64, 0x7A,
+    0x42, 0x1F, 0x55, 0x10, 0x11, 0x3B, 0x69, 0x39, 0x2D, 0x67, 0x54, 0x99,
+    0x5E, 0xFC, 0x5A, 0x92, 0x27, 0xD5, 0x5C, 0x85, 0x10, 0x11, 0x08, 0x01,
+    0x00, 0x23, 0x11, 0x28, 0xAF, 0x58, 0x70, 0x75, 0xBA, 0x59, 0xD6, 0x93,
+    0x12, 0x61, 0xB6, 0x01, 0x38, 0x6F, 0x32, 0xA3, 0x4B, 0xCB, 0x00, 0xC1,
+    0x63, 0x3E, 0xA5, 0x4C, 0xEC, 0x10, 0x8E, 0x83, 0xCF, 0xE8, 0xDA, 0x47,
+    0x1A, 0x02, 0x15, 0x22, 0x4B, 0x08, 0xE0, 0x1F, 0x9F, 0x00, 0x07, 0x96,
+    0x0D, 0xDE, 0x04, 0x58, 0x78, 0x09, 0x01, 0xE3, 0xCE, 0x23, 0x28, 0xF8,
+    0x31, 0x42, 0x5D, 0x27, 0x44, 0x61, 0x69, 0xFC, 0xB7, 0xA2, 0x44, 0xC4,
+    0x2A, 0x8A, 0x53, 0x8C, 0xA1, 0x5A, 0xB0, 0xA8, 0x9B, 0x98, 0xAD, 0x70,
+    0x11, 0x66, 0x0B, 0x95, 0x73, 0x22, 0xF6, 0x98, 0xDD, 0x90, 0x51, 0x29,
+    0x87, 0x60, 0x99, 0x52, 0x66, 0xE8, 0xB4, 0x98, 0xED, 0xCC, 0x88, 0xF2,
+    0x43, 0x5E, 0x5B, 0x4C, 0x27, 0x1B, 0x76, 0x41, 0x62, 0x7D, 0x5C, 0x94,
+    0xA2, 0x64, 0x36, 0x20, 0xB9, 0x80, 0x51, 0x25, 0x71, 0xBB, 0x21, 0xA2,
+    0x52, 0x2E, 0x70, 0x02, 0x48, 0xE9, 0x8A, 0x87, 0x7D, 0x7A, 0xD3, 0x22,
+    0x6C, 0x06, 0x1F, 0x41, 0x2A, 0x85, 0x47, 0x6B, 0x39, 0x84, 0xC0, 0x08,
+    0xB6, 0x3A, 0x45, 0xD9, 0x10, 0x8E, 0x35, 0xA9, 0x50, 0x03, 0x12, 0xFE,
+    0x33, 0x88, 0xE2, 0x28, 0x2D, 0x2D, 0x13, 0x72, 0x44, 0xC9, 0xF8, 0xA6,
+    0x47, 0xF0, 0xF8, 0x49, 0x29, 0x23, 0x2B, 0x84, 0xA0, 0xAE, 0xB7, 0x9B,
+    0xA8, 0x05, 0x4F, 0x10, 0x29, 0x40, 0x5D, 0xF6, 0xAE, 0x56, 0xB4, 0x62,
+    0xB5, 0x20, 0x59, 0xCB, 0x0A, 0x9F, 0xC3, 0xE0, 0xE3, 0x2D, 0x48, 0x0E,
+    0x00, 0x4C, 0x84, 0x58, 0xDE, 0x00, 0x00, 0xD9, 0xAF, 0x53, 0x8E, 0x10,
+    0x93, 0x34, 0x29, 0x41, 0x88, 0xA2, 0xA4, 0xA9, 0xF0, 0x09, 0x62, 0x92,
+    0x42, 0x6C, 0xCE, 0x60, 0x14, 0x90, 0x2C, 0x62, 0xB1, 0x12, 0x3E, 0x51,
+    0x9B, 0x1C, 0x0E, 0xA9, 0x82, 0xCD, 0xC5, 0x19, 0xA2, 0x85, 0x17, 0xFB,
+    0x22, 0x22, 0x46, 0xF9, 0x42, 0xC1, 0xA4, 0xC5, 0x97, 0xC0, 0x1C, 0x44,
+    0x7A, 0x66, 0x85, 0xC2, 0xA8, 0x89, 0x13, 0x99, 0x33, 0x29, 0x41, 0x76,
+    0x2E, 0x83, 0x80, 0x24, 0xD5, 0xEA, 0x9D, 0x88, 0x50, 0xE3, 0x00, 0x0A,
+    0x07, 0x1F, 0x06, 0x14, 0xD0, 0x2B, 0x0E, 0x40, 0xE4, 0x6E, 0xBC, 0x84,
+    0xCA, 0x6D, 0x3E, 0x32, 0x6B, 0x3D, 0x5A, 0x18, 0xDC, 0xE8, 0x74, 0x4C,
+    0x44, 0x54, 0x8F, 0x9D, 0xCE, 0x39, 0x65, 0x8E, 0x9A, 0x63, 0xAE, 0x74,
+    0x02, 0x60, 0x7D, 0x02, 0xE5, 0x53, 0xED, 0x94, 0xE2, 0x4C, 0x78, 0xDE,
+    0x23, 0x84, 0xAE, 0x28, 0xA1, 0x61, 0x10, 0xA0, 0x26, 0xC9, 0x9C, 0x52,
+    0x9B, 0x8B, 0x10, 0x18, 0xF9, 0x1A, 0x39, 0x25, 0x62, 0x5E, 0xEE, 0x9F,
+    0x28, 0x25, 0x84, 0x57, 0xE0, 0xD3, 0xBA, 0xA5, 0x28, 0xF1, 0x33, 0xEB,
+    0xBB, 0xD8, 0x0D, 0x05, 0x41, 0x38, 0xF8, 0x7C, 0x6F, 0x00, 0xBE, 0x1B,
+    0xD5, 0xBF, 0x76, 0x27, 0xA8, 0xA0, 0x8E, 0x2A, 0x03, 0x26, 0x28, 0x67,
+    0x64, 0x6A, 0x18, 0x4A, 0x8F, 0x02, 0x24, 0x02, 0x24, 0x4A, 0xA5, 0x2A,
+    0xE6, 0x14, 0xFE, 0xB7, 0x6B, 0x9A, 0x93, 0x2A, 0x3B, 0x15, 0x44, 0xEC,
+    0x5C, 0xBA, 0x1B, 0x08, 0xB6, 0xB4, 0x34, 0x20, 0x88, 0x0E, 0x70, 0x0C,
+    0x31, 0x53, 0xEC, 0x69, 0x71, 0x2D, 0x27, 0x00, 0x16, 0x06, 0x1A, 0xC0,
+    0xD6, 0x10, 0xC4, 0xA8, 0x04, 0x2E, 0x8A, 0x80, 0x06, 0x3B, 0x59, 0x46,
+    0xDA, 0xA5, 0xC5, 0xA8, 0xAC, 0x1B, 0xEA, 0x20, 0x2C, 0x16, 0xCD, 0x04,
+    0x82, 0x8A, 0xAB, 0xA4, 0xF1, 0xEA, 0x2B, 0x9D, 0xBA, 0x8F, 0x0A, 0x00,
+    0x2B, 0xA6, 0xAA, 0x88, 0x15, 0x50, 0x4D, 0x60, 0x55, 0xD2, 0xD4, 0xEA,
+    0x8D, 0x87, 0x18, 0x5F, 0x80, 0x1C, 0x39, 0x00, 0x32, 0x49, 0xC0, 0x51,
+    0xEF, 0xDA, 0x80, 0x01, 0x54, 0x95, 0x30, 0xDD, 0x01, 0x60, 0x95, 0x10,
+    0xAB, 0x1F, 0xB3, 0xAE, 0x32, 0xD7, 0x46, 0x2C, 0x6F, 0xA5, 0xBB, 0xC1,
+    0x20, 0x40, 0x9B, 0x23, 0x48, 0x80, 0x55, 0xD0, 0x39, 0x5E, 0x1D, 0xC0,
+    0xE3, 0x9C, 0xF3, 0x3E, 0xC2, 0xF2, 0xA3, 0x62, 0x6A, 0x91, 0x2A, 0x2A,
+    0xC8, 0x19, 0x1F, 0x41, 0x36, 0xF4, 0x10, 0x92, 0x72, 0x60, 0x73, 0xCE,
+    0x78, 0x2F, 0xDD, 0xEE, 0x4D, 0xB4, 0x5F, 0x01, 0x17, 0x22, 0x04, 0xC6,
+    0xCF, 0xF2, 0x1D, 0x8F, 0x59, 0x29, 0x28, 0x6D, 0x22, 0xB2, 0x94, 0x47,
+    0xC9, 0xC4, 0x76, 0x8D, 0xCD, 0x89, 0xDA, 0xCE, 0x26, 0xE9, 0x3C, 0x4B,
+    0x1E, 0xD4, 0x39, 0x04, 0x1D, 0x80, 0x74, 0x6D, 0xCB, 0x0E, 0xDC, 0xDE,
+    0x05, 0xB1, 0xA9, 0xB0, 0x1C, 0xC4, 0x24, 0x96, 0x88, 0x0E, 0xCA, 0x2E,
+    0x3E, 0x99, 0x23, 0x80, 0xFA, 0xA6, 0x84, 0x81, 0xCC, 0x84, 0x89, 0x2A,
+    0x10, 0x4D, 0x14, 0xE6, 0x90, 0x9B, 0x16, 0x0A, 0x78, 0xB6, 0x11, 0x39,
+    0x04, 0x8F, 0x16, 0xD9, 0x48, 0x1A, 0xAD, 0x09, 0x42, 0x9F, 0x04, 0x2E,
+    0xB0, 0x57, 0x6E, 0x06, 0x1E, 0xFE, 0x41, 0x5A, 0x94, 0xBC, 0xF2, 0x30,
+    0xEF, 0x65, 0x74, 0x7B, 0x0A, 0x46, 0xC6, 0x27, 0x66, 0x14, 0x3E, 0x30,
+    0x5D, 0x12, 0xA5, 0x33, 0x45, 0x50, 0xF5, 0x4B, 0x9C, 0x14, 0xA5, 0x57,
+    0x32, 0x8A, 0x3D, 0x06, 0x28, 0x40, 0x05, 0xFC, 0xFD, 0x52, 0x56, 0xBF,
+    0x59, 0xD6, 0x31, 0xAA, 0x25, 0xC1, 0x91, 0x31, 0x30, 0x00, 0x24, 0x85,
+    0x5A, 0xD2, 0x84, 0x77, 0x9F, 0xF0, 0x71, 0x23, 0x84, 0xE9, 0x21, 0x61,
+    0xAF, 0x20, 0xA0, 0x79, 0x31, 0x43, 0xEF, 0x29, 0x5A, 0x38, 0x59, 0xB6,
+    0x25, 0xA2, 0x7A, 0x0C, 0x36, 0xA5, 0x22, 0x11, 0xB1, 0xB7, 0xD5, 0x0C,
+    0x65, 0x12, 0x92, 0xC2, 0x2B, 0x9F, 0xE8, 0x55, 0x19, 0xB5, 0xE0, 0xEB,
+    0x59, 0x54, 0x49, 0x32, 0x45, 0xD5, 0xD2, 0x5C, 0xC9, 0xE4, 0x0E, 0x00,
+    0xC2, 0x04, 0xAC, 0x00, 0xEA, 0x17, 0xCD, 0xC8, 0x78, 0x77, 0xC5, 0x3B,
+    0x36, 0x47, 0x8F, 0x45, 0xD3, 0xBC, 0xA5, 0x7A, 0x25, 0xC3, 0xA5, 0x10,
+    0xD4, 0x6C, 0x9D, 0xA3, 0x5A, 0xF1, 0x22, 0x22, 0x56, 0x30, 0x2E, 0x4D,
+    0xE6, 0xF0, 0x59, 0x08, 0xC7, 0x90, 0xC9, 0x89, 0x91, 0x10, 0x66, 0x97,
+    0xFB, 0x15, 0x56, 0xD1, 0x0E, 0x36, 0x11, 0xBB, 0x04, 0xCF, 0xF1, 0x32,
+    0x2A, 0x31, 0xDE, 0xB9, 0xA7, 0x7C, 0x5F, 0xC9, 0xEF, 0x6E, 0x4E, 0x9A,
+    0xE6, 0x77, 0xAC, 0x19, 0x54, 0x6D, 0x26, 0x4D, 0x90, 0x27, 0x51, 0x80,
+    0x08, 0x58, 0x00, 0x46, 0x70, 0x9D, 0x04, 0x75, 0x03, 0xB4, 0xB6, 0x0C,
+    0x0B, 0x4C, 0xCC, 0x92, 0x89, 0x1A, 0xA0, 0x0B, 0x81, 0xE6, 0x47, 0xA8,
+    0x8B, 0xC4, 0xD3, 0xD2, 0x40, 0xFD, 0x0E, 0x6D, 0x88, 0x51, 0x96, 0xF9,
+    0xAA, 0x1E, 0x8A, 0xE0, 0x6E, 0xC6, 0x83, 0xD1, 0xE6, 0xF8, 0x55, 0x5B,
+    0x3E, 0x2D, 0x55, 0xA5, 0xD9, 0x61, 0x31, 0x36, 0xFE, 0xAB, 0xAE, 0x86,
+    0xB4, 0x81, 0x9D, 0x04, 0x16, 0x3A, 0x80, 0xB0, 0x40, 0x62, 0x7E, 0x01,
+    0x12, 0xEC, 0x72, 0x75, 0x0D, 0x9E, 0xF4, 0xED, 0xD6, 0xC7, 0xA8, 0x9E,
+    0x56, 0x4D, 0x33, 0x16, 0x59, 0xFC, 0xC2, 0xA7, 0x86, 0x17, 0x10, 0x14,
+    0xA3, 0xB1, 0x2A, 0x28, 0x2D, 0x0B, 0xF5, 0x2B, 0x8D, 0x95, 0xCC, 0x46,
+    0x07, 0xF0, 0xDF, 0x61, 0x97, 0xE3, 0x93, 0x3F, 0x2E, 0xE7, 0xA6, 0x01,
+    0x55, 0xEC, 0xF3, 0xAE, 0xDA, 0x10, 0xEE, 0x85, 0xB5, 0x9B, 0x3D, 0x34,
+    0x6D, 0xA5, 0xE8, 0x5B, 0x3E, 0x13, 0x4C, 0xC5, 0xDE, 0xA2, 0xA5, 0x54,
+    0x3E, 0x31, 0x60, 0x74, 0xED, 0xE6, 0xA9, 0xED, 0x82, 0xAD, 0x14, 0xC5,
+    0xAA, 0x2E, 0xBC, 0x7C, 0x95, 0x66, 0x0C, 0xC5, 0xD8, 0x1C, 0xD5, 0x36,
+    0xD5, 0xDD, 0xE9, 0xD0, 0xE7, 0xFE, 0xE2, 0x83, 0x6C, 0x38, 0x03, 0xA0,
+    0x00, 0x8A, 0x1D, 0x94, 0x74, 0x1B, 0x88, 0x40, 0xAF, 0x00, 0x5A, 0x60,
+    0xFF, 0xF6, 0x61, 0x85, 0x83, 0xC5, 0x81, 0x74, 0x4F, 0x0B, 0x04, 0x7D,
+    0x44, 0x84, 0x7B, 0x5D, 0x1E, 0x19, 0x93, 0xB7, 0xB8, 0x34, 0x37, 0x5E,
+    0xF8, 0x03, 0xD3, 0x52, 0xDD, 0xC8, 0x48, 0x1B, 0xE3, 0xEB, 0xE0, 0x6E,
+    0x80, 0xE6, 0x7D, 0x88, 0x09, 0x7C, 0x18, 0xA8, 0xB8, 0x64, 0x56, 0xF8,
+    0x24, 0x0B, 0x5F, 0xFE, 0x48, 0x92, 0xDA, 0xCE, 0x51, 0xF9, 0x29, 0x42,
+    0x5E, 0x55, 0x29, 0x76, 0x1C, 0x11, 0xA7, 0x7D, 0x99, 0x84, 0xDC, 0xEB,
+    0x4B, 0x1F, 0x3B, 0x2F, 0xE7, 0xB2, 0xD5, 0x21, 0x55, 0x3C, 0x0E, 0xF4,
+    0x70, 0x20, 0x38, 0x40, 0xE1, 0xA5, 0xB0, 0x30, 0x41, 0xD5, 0xF2, 0x29,
+    0x6A, 0xC0, 0x5B, 0xF2, 0x5D, 0x44, 0xEC, 0x68, 0xBE, 0xEF, 0xCA, 0x3E,
+    0xDD, 0xDF, 0xF1, 0xB1, 0xF6, 0x2A, 0x30, 0x75, 0x97, 0x0C, 0xA8, 0xFE,
+    0xA9, 0xE0, 0x08, 0x8D, 0xE4, 0x21, 0x46, 0x0D, 0x1E, 0xAF, 0x9E, 0x40,
+    0x9F, 0x15, 0xE7, 0xB2, 0xE1, 0xD4, 0x52, 0x4E, 0xE2, 0x8E, 0xB7, 0xEC,
+    0xDD, 0x10, 0x7A, 0x7C, 0xB2, 0x69, 0x88, 0xB5, 0x0F, 0x20, 0xD3, 0xCD,
+    0xD1, 0xC0, 0xE8, 0x08, 0xB0, 0x62, 0x49, 0xE5, 0xD9, 0x60, 0x7A, 0x27,
+    0xC4, 0xA9, 0x27, 0xEF, 0x4D, 0x56, 0x14, 0x40, 0x02, 0xBA, 0x8A, 0x74,
+    0x0B, 0xD6, 0x24, 0xAA, 0xF0, 0xBA, 0x4A, 0xCE, 0x39, 0x1E, 0xBB, 0x1A,
+    0xA5, 0x2C, 0x80, 0x9A, 0x2E, 0x8D, 0xCE, 0x6A, 0x31, 0xB7, 0x6E, 0x1C,
+    0x0C, 0xF9, 0x75, 0x9C, 0x3D, 0x3E, 0x69, 0x27, 0x04, 0x38, 0x37, 0x9E,
+    0xA8, 0xFF, 0x69, 0xF0, 0x48, 0x92, 0x6E, 0xCE, 0x3D, 0x0D, 0x81, 0x67,
+    0xD2, 0x2B, 0x05, 0xB2, 0x89, 0x48, 0x81, 0x8C, 0xA6, 0x2F, 0x23, 0x48,
+    0xB1, 0x95, 0xAD, 0xE1, 0xBB, 0x0F, 0xB3, 0x01, 0xCA, 0x58, 0x2E, 0x3D,
+    0x96, 0xC5, 0x54, 0x69, 0xBC, 0xC4, 0x66, 0xBF, 0xE5, 0xAF, 0x90, 0x18,
+    0xB9, 0x83, 0x76, 0x2C, 0x55, 0xA0, 0xDF, 0xFB, 0x77, 0x8B, 0x06, 0xF0,
+    0x94, 0xD7, 0x6A, 0xA6, 0x7A, 0xAE, 0x1B, 0x2A, 0x3A, 0x3D, 0x11, 0xB6,
+    0x8E, 0x0F, 0xA5, 0x0B, 0x51, 0x3D, 0xE1, 0xEE, 0xC6, 0x5C, 0x7C, 0x66,
+    0x50, 0x17, 0xC3, 0x6E, 0xB0, 0x93, 0x02, 0x9F, 0xA4, 0x16, 0x48, 0x05,
+    0x78, 0xA7, 0xF4, 0x60, 0xB1, 0xA2, 0x7B, 0xE7, 0x76, 0x2E, 0xCB, 0x43,
+    0x7B, 0x35, 0x45, 0x7B, 0xB5, 0x77, 0x17, 0xB7, 0xE6, 0x5D, 0x1D, 0xD5,
+    0x7E, 0xDC, 0xF0, 0x7B, 0xFD, 0xF4, 0x66, 0xCF, 0x64, 0x42, 0x90, 0x73,
+    0x37, 0xF7, 0x06, 0x00, 0x88, 0x02, 0x1F, 0x67, 0x56, 0x08, 0x11, 0xC8,
+    0x71, 0x54, 0xF1, 0x5B, 0x14, 0x34, 0x80, 0x58, 0x25, 0x09, 0x15, 0x10,
+    0x02, 0x0D, 0xFE, 0x70, 0x74, 0xA0, 0x32, 0x67, 0xBE, 0x84, 0x5E, 0x25,
+    0xE8, 0x1C, 0xB5, 0xD2, 0x29, 0xD5, 0x93, 0x47, 0xD7, 0x95, 0x6E, 0xBF,
+    0x16, 0x69, 0xF0, 0xB1, 0x7F, 0x1A, 0x98, 0x0E, 0x40, 0x04, 0x7F, 0x1B,
+    0xA2, 0x4F, 0x0E, 0x18, 0x20, 0x30, 0xB7, 0x75, 0x56, 0xD4, 0x3B, 0x43,
+    0xB7, 0x7E, 0x85, 0xA0, 0x46, 0x14, 0x27, 0x4D, 0xEC, 0xB5, 0x08, 0xFA,
+    0x74, 0x31, 0x5A, 0x15, 0x57, 0x8E, 0x12, 0x23, 0x27, 0x70, 0x7D, 0x73,
+    0xD2, 0x1F, 0xB1, 0x81, 0x1E, 0x77, 0x91, 0x72, 0x01, 0x37, 0x08, 0xF9,
+    0x67, 0x57, 0x52, 0x53, 0x3D, 0x79, 0x56, 0x40, 0xD5, 0xE5, 0x48, 0xE9,
+    0xE1, 0x7F, 0x7A, 0x26, 0x6C, 0x45, 0x88, 0x0E, 0xB1, 0xF3, 0x79, 0x36,
+    0xF6, 0x66, 0x92, 0x37, 0x2D, 0x12, 0x15, 0x80, 0x00, 0xA0, 0x4F, 0x05,
+    0xE7, 0x5B, 0x64, 0x15, 0x7E, 0x17, 0x26, 0x85, 0x8B, 0x10, 0x2B, 0x1E,
+    0x70, 0x2C, 0x8A, 0x58, 0x2C, 0x5E, 0x45, 0x00, 0x59, 0xB8, 0x2E, 0x88,
+    0x35, 0x01, 0xC6, 0xF1, 0x15, 0x35, 0xA6, 0x1B, 0x2A, 0x87, 0x7C, 0xDF,
+    0xF6, 0x26, 0x6C, 0x98, 0x5D, 0xA2, 0x11, 0x4D, 0xDE, 0x05, 0x2C, 0xB0,
+    0xB6, 0x6E, 0x23, 0x58, 0x87, 0xE0, 0x00, 0x2D, 0x94, 0xE4, 0x7C, 0xF7,
+    0xE2, 0x15, 0xD9, 0x86, 0x8A, 0x03, 0xB0, 0x53, 0xEA, 0x15, 0x1E, 0x5E,
+    0x71, 0x27, 0xE9, 0x61, 0x83, 0x81, 0xB4, 0x64, 0x5C, 0xD3, 0x32, 0x99,
+    0xF8, 0x27, 0x2E, 0x28, 0x35, 0x86, 0x60, 0x58, 0x23, 0x06, 0x1F, 0x2A,
+    0x27, 0x30, 0x72, 0x48, 0x1A, 0xC0, 0xF3, 0x81, 0xD8, 0xB5, 0x1B, 0x84,
+    0x71, 0x8C, 0xBB, 0x11, 0x5F, 0x47, 0x52, 0x85, 0xBA, 0x61, 0x71, 0x93,
+    0x10, 0x1B, 0x30, 0x92, 0x56, 0x12, 0x90, 0x02, 0x09, 0x47, 0x8A, 0xC5,
+    0x70, 0x87, 0x68, 0x87, 0x80, 0xFE, 0x28, 0xE4, 0x5D, 0x0F, 0xB6, 0x57,
+    0x59, 0x16, 0x85, 0x05, 0x45, 0x08, 0x24, 0x67, 0x82, 0x5E, 0xC1, 0x6D,
+    0x28, 0xE8, 0x15, 0xB7, 0x26, 0x00, 0x5E, 0xF5, 0x24, 0xA9, 0xA7, 0x29,
+    0xB4, 0x66, 0x8C, 0x97, 0x07, 0x8C, 0x67, 0xF8, 0x71, 0x75, 0x45, 0x5B,
+    0x54, 0xA1, 0x17, 0x28, 0x87, 0x3D, 0xAC, 0x37, 0x50, 0xE7, 0x48, 0x3C,
+    0xF0, 0x61, 0x78, 0x90, 0x10, 0x83, 0x34, 0xD8, 0x6C, 0x4F, 0x86, 0x8D,
+    0xC9, 0x60, 0x8A, 0x48, 0xF8, 0x15, 0x78, 0xB8, 0x23, 0xAD, 0xD3, 0x6E,
+    0x44, 0x16, 0x1F, 0x02, 0x29, 0x3E, 0xDE, 0xC6, 0x8A, 0xCE, 0xE2, 0x68,
+    0x40, 0x55, 0x88, 0x4A, 0x81, 0x15, 0x2A, 0xE5, 0x00, 0x2D, 0x60, 0x2C,
+    0x26, 0x70, 0x35, 0xDD, 0x23, 0x00, 0xC8, 0xE6, 0x2C, 0x59, 0x82, 0x87,
+    0x04, 0x15, 0x53, 0xD0, 0x06, 0x1E, 0x75, 0x36, 0x08, 0xFB, 0xD8, 0x2F,
+    0xB5, 0x72, 0x01, 0x18, 0x99, 0x6D, 0x18, 0x66, 0x1F, 0xF5, 0x66, 0x18,
+    0xAB, 0xD1, 0x6A, 0x08, 0xA9, 0x0B, 0xDA, 0x08, 0x7C, 0x69, 0xB1, 0x8E,
+    0x74, 0xB3, 0x36, 0xDF, 0x28, 0x08, 0x01, 0xC6, 0x92, 0xB1, 0x48, 0x08,
+    0x69, 0x08, 0x1E, 0xDE, 0x75, 0x65, 0x53, 0x18, 0x24, 0xFA, 0xE6, 0x78,
+    0x17, 0x15, 0x8E, 0xF0, 0x11, 0x84, 0x8E, 0x58, 0x79, 0xBF, 0x18, 0x51,
+    0x3D, 0x42, 0x08, 0x00, 0xD9, 0x60, 0x46, 0xA6, 0x70, 0x78, 0x17, 0x6B,
+    0x6F, 0xC6, 0x5B, 0x2E, 0x96, 0x41, 0x8D, 0xC0, 0x77, 0x2E, 0xD8, 0x00,
+    0xD7, 0xB8, 0x93, 0xBB, 0xA0, 0x90, 0x01, 0x52, 0x40, 0xC9, 0xE7, 0x34,
+    0x0F, 0x89, 0x08, 0x84, 0x27, 0x76, 0x1B, 0x59, 0x08, 0x39, 0x08, 0x1E,
+    0x35, 0xD5, 0x00, 0x34, 0x12, 0x01, 0x06, 0x88, 0x24, 0xBD, 0xB5, 0x82,
+    0x1A, 0x46, 0x88, 0x43, 0x28, 0x47, 0xD5, 0xB8, 0xFE, 0x6C, 0x3E, 0xD6,
+    0x4D, 0x2A, 0x33, 0x08, 0xB0, 0x07, 0x1E, 0x35, 0x49, 0x94, 0xA8, 0x32,
+    0x2D, 0x06, 0x10, 0x33, 0x00, 0x44, 0x35, 0x34, 0x05, 0x98, 0xF7, 0x95,
+    0x16, 0x1E, 0xF0, 0x91, 0xC6, 0xE2, 0x00, 0x67, 0xF5, 0x4B, 0x3A, 0xA9,
+    0x96, 0xB4, 0xD0, 0x93, 0x1D, 0xA8, 0x73, 0x52, 0x14, 0x84, 0x43, 0xB9,
+    0x92, 0x01, 0x79, 0x7F, 0x83, 0x10, 0x2B, 0x95, 0xD8, 0x55, 0x9A, 0x92,
+    0x3A, 0x53, 0xB9, 0x36, 0x3B, 0x23, 0x28, 0xE9, 0x37, 0x87, 0x74, 0x42,
+    0x8B, 0xA0, 0xC7, 0x8B, 0x7F, 0xE8, 0x1D, 0xB0, 0xF8, 0x82, 0x8E, 0xF9,
+    0x5D, 0x7C, 0x12, 0x97, 0x3D, 0xA5, 0x68, 0x86, 0xA8, 0x08, 0xC5, 0xF6,
+    0x63, 0xD1, 0xC4, 0x59, 0x69, 0x11, 0x02, 0x8F, 0x07, 0x9A, 0xB1, 0x60,
+    0x8A, 0x40, 0x29, 0x00, 0x51, 0x23, 0x50, 0xB3, 0xF4, 0x6F, 0x0F, 0x48,
+    0x80, 0xF8, 0x76, 0x8F, 0x90, 0xC6, 0x6F, 0x48, 0x79, 0x95, 0x7F, 0xB9,
+    0x1F, 0x0E, 0x50, 0x70, 0xAD, 0x13, 0x22, 0xAC, 0x59, 0x70, 0x06, 0xF0,
+    0x53, 0x6A, 0x91, 0x6D, 0x5E, 0x15, 0x53, 0x94, 0xA9, 0x64, 0x82, 0xF7,
+    0x9B, 0x03, 0x00, 0x99, 0x0A, 0x04, 0x00, 0xB1, 0x73, 0x81, 0xA1, 0x87,
+    0x08, 0xC5, 0xA6, 0x02, 0xE6, 0x69, 0x37, 0x69, 0x71, 0x01, 0xA3, 0xE8,
+    0x9C, 0xB3, 0xF0, 0x5A, 0x3E, 0x09, 0x9C, 0x91, 0xC1, 0x00, 0x3F, 0xC5,
+    0x01, 0x80, 0xC7, 0x1B, 0x42, 0xD9, 0x6F, 0x5A, 0x52, 0x72, 0xF9, 0x58,
+    0x08, 0x02, 0xF3, 0x96, 0x19, 0xC2, 0x5F, 0x19, 0xB0, 0x8A, 0x0A, 0xAA,
+    0x9A, 0xF4, 0xC9, 0x3C, 0x18, 0x22, 0x6B, 0x77, 0x11, 0x50, 0xE6, 0x58,
+    0x9C, 0x24, 0x88, 0x8B, 0xC4, 0xD9, 0x70, 0x68, 0x78, 0x73, 0x3B, 0x12,
+    0x5B, 0x63, 0xC1, 0x74, 0xDB, 0x69, 0x77, 0xC6, 0xF9, 0x15, 0x16, 0xFE,
+    0x4A, 0x1A, 0x1C, 0xFA, 0x15, 0x27, 0xD0, 0x9C, 0x00, 0xCA, 0x0A, 0x11,
+    0x47, 0x7A, 0x92, 0x46, 0x59, 0xA2, 0x41, 0x77, 0x79, 0x55, 0x7A, 0x85,
+    0xA0, 0xA2, 0xE0, 0xB1, 0x67, 0x53, 0xE8, 0x15, 0xB5, 0x39, 0x50, 0xB7,
+    0x94, 0x2C, 0x0E, 0xA0, 0x00, 0xB8, 0xC9, 0x5A, 0x57, 0x08, 0x8E, 0x8F,
+    0x89, 0x21, 0xA7, 0xA1, 0x00, 0x1C, 0xA0, 0x02, 0x0A, 0xD0, 0x7D, 0xA8,
+    0x28, 0x3D, 0x74, 0x45, 0x2E, 0x6A, 0xC8, 0x51, 0x83, 0xA0, 0x46, 0x12,
+    0xDA, 0x9B, 0x24, 0x0A, 0x00, 0xE5, 0xE8, 0x1C, 0xC5, 0x98, 0x08, 0xC5,
+    0x66, 0x9D, 0xFF, 0x17, 0x43, 0x04, 0xF0, 0x9F, 0x35, 0x1A, 0x52, 0x20,
+    0xE8, 0x93, 0x0E, 0x74, 0x5D, 0xC1, 0xC2, 0xA3, 0x17, 0xFA, 0x27, 0xBD,
+    0xA8, 0x9D, 0x6D, 0x62, 0x8B, 0x00, 0x30, 0x49, 0x74, 0x8A, 0x42, 0x75,
+    0x76, 0x68, 0x22, 0x35, 0x30, 0x7D, 0xDA, 0x2F, 0xAD, 0x93, 0x31, 0x40,
+    0x8A, 0x8C, 0x12, 0x02, 0x42, 0x50, 0xC8, 0x27, 0x51, 0x83, 0xA5, 0xF9,
+    0x46, 0x8F, 0x75, 0xF9, 0x84, 0x5E, 0xE1, 0x01, 0x83, 0x3A, 0x45, 0xE8,
+    0xC9, 0x9C, 0x6D, 0x8A, 0x0B, 0x37, 0x8A, 0x4D, 0xB3, 0x55, 0x67, 0x5F,
+    0x12, 0x2C, 0x80, 0x87, 0x6C, 0xFF, 0x35, 0x9C, 0x4A, 0x79, 0x9F, 0x00,
+    0x30, 0x4A, 0xB0, 0x59, 0x4A, 0x66, 0xB4, 0x36, 0x58, 0xDA, 0x38, 0x3B,
+    0xAA, 0xAA, 0xA4, 0x21, 0x51, 0xBF, 0x25, 0x8C, 0xA9, 0xA9, 0x14, 0xAF,
+    0x44, 0x7E, 0x5C, 0x12, 0x5E, 0xD7, 0x12, 0x46, 0x5A, 0x57, 0x8F, 0x58,
+    0x97, 0x29, 0x08, 0xB0, 0xA4, 0x01, 0xE2, 0x02, 0xF5, 0xD3, 0x2C, 0x99,
+    0x6A, 0x0B, 0x02, 0x0A, 0x31, 0x6C, 0x72, 0x37, 0x12, 0x40, 0x14, 0x05,
+    0xA0, 0x34, 0x4B, 0xD8, 0x45, 0x59, 0x69, 0x08, 0x0F, 0x45, 0x2B, 0x74,
+    0x38, 0x08, 0xFE, 0xEB, 0x43, 0x81, 0x52, 0xD4, 0x84, 0x0F, 0x8A, 0x9F,
+    0x3E, 0x56, 0xA4, 0x90, 0x19, 0x5B, 0x71, 0x67, 0x3A, 0xDE, 0xD9, 0x1C,
+    0xB5, 0x85, 0xAD, 0x8B, 0xBA, 0x23, 0x44, 0x67, 0x61, 0xB0, 0xD5, 0x95,
+    0x8B, 0x60, 0x74, 0x0C, 0xE9, 0x34, 0x06, 0x70, 0x5D, 0x6B, 0x7A, 0xAC,
+    0xB5, 0xB0, 0xA9, 0x4C, 0xE8, 0x81, 0x84, 0xF0, 0x6A, 0x01, 0x22, 0xAA,
+    0xB5, 0xA6, 0x8E, 0xFA, 0x67, 0x99, 0x85, 0x00, 0x45, 0x09, 0xCA, 0x27,
+    0xDC, 0x6A, 0xAB, 0x8A, 0xB0, 0x31, 0x5F, 0xE1, 0x00, 0xC2, 0xCA, 0x27,
+    0xC4, 0xFA, 0x15, 0x52, 0xC5, 0xAB, 0x56, 0x73, 0x94, 0xE8, 0xAA, 0x8C,
+    0xFD, 0x6A, 0x72, 0x8A, 0xF9, 0x47, 0xB1, 0x37, 0x8E, 0x8C, 0xA0, 0xB0,
+    0x26, 0x54, 0xB0, 0xCF, 0x18, 0x43, 0xEC, 0x67, 0xAF, 0xAC, 0x90, 0xAC,
+    0x01, 0x42, 0x84, 0x9D, 0x54, 0x54, 0x18, 0x12, 0x33, 0xDF, 0x78, 0x97,
+    0xC3, 0xD5, 0xA4, 0xA6, 0xA3, 0x3F, 0x20, 0x1B, 0x20, 0x79, 0xD9, 0xB1,
+    0x48, 0xB4, 0x34, 0x72, 0xE3, 0x34, 0x6F, 0x27, 0x32, 0x86, 0xB0, 0x95,
+    0xCE, 0x21, 0x48, 0x0B, 0x54, 0xB1, 0xF3, 0x18, 0x94, 0xD3, 0x7A, 0xAA,
+    0xBC, 0x39, 0x96, 0x97, 0x84, 0x65, 0x93, 0x1A, 0x9D, 0xD2, 0xE4, 0x2D,
+    0xF1, 0x48, 0xB2, 0xAA, 0x80, 0xAF, 0x95, 0x89, 0xB0, 0xAE, 0xFA, 0x95,
+    0xB9, 0xA8, 0x14, 0x9E, 0xD5, 0x80, 0xE2, 0x68, 0x2B, 0x45, 0x07, 0xAC,
+    0x68, 0x0A, 0x7C, 0xDE, 0x82, 0x01, 0xE3, 0x95, 0x53, 0x00, 0xD5, 0x02,
+    0x21, 0x49, 0x73, 0xD9, 0x83, 0x39, 0x5A, 0x54, 0x95, 0x86, 0xF0, 0x8A,
+    0xB8, 0x03, 0xA2, 0x00, 0x00, 0x2D, 0x0D, 0xE9, 0x2F, 0x3E, 0x8A, 0x88,
+    0x83, 0xF9, 0x9E, 0x8F, 0xB0, 0x76, 0x08, 0xD0, 0x3E, 0xD5, 0x19, 0x9D,
+    0xD7, 0xF5, 0xB4, 0x50, 0x7B, 0xFE, 0x0A, 0x26, 0x3B, 0xB5, 0x03, 0x10,
+    0x80, 0xE9, 0xA1, 0xAD, 0x9A, 0x56, 0xB4, 0x5D, 0x7A, 0xB4, 0x5C, 0x89,
+    0xB7, 0x48, 0xA9, 0x2B, 0x07, 0xA4, 0xB3, 0xFF, 0xE4, 0x3A, 0x24, 0x73,
+    0x80, 0x86, 0x81, 0xA4, 0xC9, 0x32, 0x25, 0x33, 0x5A, 0x74, 0x00, 0xA5,
+    0x24, 0x56, 0xE8, 0x9B, 0x2E, 0xA9, 0xB1, 0xF3, 0xE2, 0x15, 0xAF, 0x44,
+    0xAA, 0xCA, 0xA7, 0x57, 0x24, 0xA3, 0x2B, 0x00, 0x02, 0x32, 0x94, 0x88,
+    0x79, 0x99, 0x07, 0xB1, 0x81, 0xFB, 0x0A, 0x52, 0xEB, 0x1C, 0x15, 0x85,
+    0x75, 0xE5, 0xBA, 0xA2, 0xD8, 0x49, 0x08, 0x6E, 0xFB, 0xB2, 0x64, 0x59,
+    0x74, 0x70, 0xD3, 0x76, 0x5F, 0xE3, 0x1B, 0x6A, 0x31, 0xB2, 0x8C, 0x10,
+    0x01, 0x37, 0xBB, 0x8B, 0x3D, 0x92, 0x70, 0x54, 0x27, 0x2B, 0x56, 0x6A,
+    0x52, 0x02, 0x1B, 0xBA, 0x56, 0x5B, 0xAB, 0x49, 0x9B, 0xA1, 0x4F, 0xEA,
+    0x6B, 0xA6, 0xFA, 0x08, 0x1E, 0xDB, 0x3B, 0x23, 0xE5, 0xBA, 0xBA, 0x81,
+    0x6C, 0xE0, 0x13, 0xBB, 0xAD, 0x30, 0xB8, 0xE0, 0x25, 0x75, 0xEA, 0x94,
+    0xAE, 0x1B, 0xFB, 0x4B, 0x3D, 0x2B, 0x95, 0x74, 0x99, 0x6C, 0x32, 0x77,
+    0xBC, 0x7E, 0xC7, 0x3D, 0x58, 0x23, 0x18, 0xB4, 0x24, 0xA5, 0x93, 0xEB,
+    0x15, 0x0D, 0x90, 0x81, 0x32, 0x27, 0x1B, 0xEF, 0xA8, 0x29, 0xAB, 0x91,
+    0x96, 0xDB, 0x87, 0xB3, 0x8F, 0xE3, 0x4E, 0x7E, 0x01, 0x75, 0xE3, 0x8B,
+    0xBA, 0x60, 0xB6, 0x61, 0x34, 0xA4, 0xA7, 0x1A, 0x73, 0x93, 0x86, 0x91,
+    0x01, 0x34, 0x87, 0x6C, 0x43, 0x09, 0xBE, 0xA5, 0xB0, 0x3E, 0xD1, 0x29,
+    0x8A, 0xB6, 0x4B, 0xC0, 0xAF, 0x3B, 0x76, 0x85, 0x20, 0xB1, 0xD2, 0x1B,
+    0xB4, 0xBF, 0x8A, 0xBC, 0xE7, 0x45, 0x76, 0x30, 0xE8, 0x28, 0x5F, 0xB8,
+    0xBF, 0x2B, 0x78, 0x02, 0x12, 0x90, 0x96, 0x9D, 0xFE, 0x94, 0x02, 0xC7,
+    0xEB, 0x63, 0xDF, 0xE3, 0x59, 0xE2, 0xD6, 0x96, 0x4E, 0x38, 0x08, 0x63,
+    0xDA, 0x1C, 0x65, 0x9A, 0x4F, 0x12, 0x20, 0x83, 0x0D, 0xE0, 0x56, 0x16,
+    0x40, 0x24, 0x03, 0xE7, 0x21, 0x91, 0x92, 0x9E, 0x78, 0xA9, 0xAF, 0x12,
+    0x9C, 0x0A, 0x18, 0x49, 0x7F, 0xA9, 0xE6, 0xAE, 0x86, 0xD0, 0x35, 0x2B,
+    0x6B, 0x8B, 0xEE, 0xD5, 0xB0, 0x93, 0x41, 0xBE, 0x7D, 0x86, 0x7A, 0x20,
+    0xEC, 0x21, 0xFE, 0x75, 0x0A, 0x9D, 0x16, 0x57, 0x11, 0xF0, 0x99, 0x32,
+    0xC7, 0x44, 0x9B, 0x22, 0x80, 0x05, 0x77, 0x75, 0x32, 0x75, 0x3E, 0x02,
+    0xD6, 0xAD, 0xAC, 0x96, 0x1F, 0x38, 0x79, 0x3F, 0x7F, 0x98, 0x29, 0xCD,
+    0xAA, 0x55, 0x54, 0x07, 0x6B, 0xB5, 0x12, 0xC1, 0x45, 0x2C, 0x0A, 0x14,
+    0x7C, 0xB1, 0xA0, 0x9B, 0x8E, 0xA2, 0x7B, 0xB5, 0xEC, 0x4B, 0xC3, 0xB8,
+    0x41, 0x6A, 0x66, 0x9C, 0xB0, 0x16, 0xF0, 0xBF, 0x75, 0x52, 0x26, 0xCB,
+    0xC0, 0x4C, 0x77, 0x41, 0x6B, 0x26, 0xFA, 0xB6, 0x83, 0xB4, 0xC1, 0xA2,
+    0xD1, 0xAB, 0x4A, 0x81, 0x34, 0x64, 0x7B, 0x19, 0x20, 0x52, 0x01, 0xC7,
+    0x31, 0xAE, 0x84, 0x50, 0x01, 0x4A, 0xD3, 0x9A, 0x05, 0x0A, 0xB3, 0x73,
+    0xFC, 0xAE, 0x5D, 0x08, 0x6A, 0xF8, 0x2B, 0x08, 0x47, 0x1C, 0x20, 0x41,
+    0xF8, 0xB4, 0x4C, 0xBC, 0xB5, 0x88, 0x85, 0x9A, 0x41, 0x8A, 0xA1, 0x1D,
+    0x4B, 0xC2, 0x33, 0x88, 0x17, 0x6C, 0x45, 0x01, 0x97, 0xA5, 0xC2, 0xC7,
+    0x10, 0x1B, 0x37, 0xAB, 0x5B, 0x5C, 0x47, 0xB8, 0xB9, 0x2B, 0x08, 0xEC,
+    0xCA, 0xA4, 0x45, 0xB4, 0x3B, 0x82, 0x6C, 0x18, 0x88, 0xD1, 0x2E, 0xDE,
+    0x5A, 0xBD, 0xBB, 0xA1, 0x63, 0x9D, 0xBC, 0x32, 0x68, 0x7C, 0x17, 0x6A,
+    0xDC, 0x08, 0x75, 0x2C, 0x91, 0x9C, 0x3C, 0x08, 0x61, 0x66, 0xC7, 0xFE,
+    0x1C, 0x6B, 0x8F, 0xC6, 0x9C, 0xC1, 0xF7, 0x82, 0x0F, 0xE7, 0xA1, 0x1D,
+    0x48, 0x43, 0x85, 0xB1, 0xA9, 0xB8, 0x82, 0x90, 0x68, 0xCE, 0x81, 0xCC,
+    0x82, 0x00, 0xAF, 0x48, 0xA2, 0x00, 0x1A, 0xB0, 0x3D, 0xB7, 0x94, 0x30,
+    0x07, 0x69, 0x08, 0x92, 0x82, 0x6A, 0xE6, 0xE2, 0xC1, 0xC9, 0x0C, 0x42,
+    0x96, 0x7B, 0xC8, 0xB4, 0x3C, 0xCA, 0x1C, 0xC6, 0xCA, 0x84, 0x70, 0xCA,
+    0x1A, 0xC9, 0xA2, 0x83, 0x10, 0x5C, 0xD8, 0xA3, 0x01, 0x05, 0x44, 0xCB,
+    0xED, 0x30, 0x01, 0x14, 0xA6, 0x4F, 0x24, 0xD5, 0x8F, 0xA5, 0xE1, 0x48,
+    0xBD, 0x92, 0x94, 0x66, 0xD4, 0xA4, 0xD9, 0x3B, 0x30, 0xDC, 0x2B, 0x19,
+    0x0C, 0x20, 0x56, 0xC2, 0x7C, 0x25, 0xA2, 0x97, 0xC7, 0xFE, 0xB8, 0xC8,
+    0xF3, 0xBC, 0x3B, 0x2D, 0xBC, 0x1F, 0x68, 0x79, 0x99, 0x4A, 0xE1, 0xB7,
+    0xD1, 0x2C, 0x08, 0xD3, 0xAC, 0x82, 0x1A, 0x3C, 0x08, 0x87, 0x6A, 0x66,
+    0x26, 0x50, 0xBF, 0x7E, 0xA8, 0x0F, 0x8F, 0x08, 0x2F, 0x27, 0xB2, 0x47,
+    0xA4, 0x4B, 0xAD, 0x15, 0x89, 0x95, 0x78, 0xAB, 0x2E, 0x94, 0x8A, 0x76,
+    0x1C, 0xD0, 0x99, 0x98, 0xD1, 0xC3, 0xB1, 0x13, 0x8A, 0x52, 0x5C, 0xC4,
+    0xE6, 0x4C, 0x89, 0x98, 0xEB, 0xD3, 0x27, 0x90, 0x55, 0xF8, 0xFC, 0xA1,
+    0x54, 0x7B, 0x08, 0xFC, 0x7C, 0xBE, 0x31, 0x55, 0x9F, 0x92, 0x61, 0x3C,
+    0x97, 0x21, 0x64, 0xFC, 0xF0, 0xC3, 0xAA, 0x07, 0x02, 0x8D, 0x8A, 0x34,
+    0x9E, 0x87, 0x98, 0x85, 0x2B, 0xB4, 0xA4, 0xC4, 0x25, 0xCA, 0x49, 0x27,
+    0xCE, 0x68, 0x89, 0xBE, 0xDA, 0xC9, 0xF9, 0x13, 0x2C, 0x0A, 0xC0, 0x3F,
+    0x07, 0x63, 0x65, 0xC4, 0x1B, 0x95, 0x18, 0xEC, 0x9A, 0x77, 0x1C, 0x4C,
+    0xAA, 0x48, 0xCD, 0x7B, 0x3C, 0x63, 0x2D, 0x53, 0xD1, 0x29, 0x06, 0x16,
+    0xED, 0x1C, 0xFE, 0x10, 0x92, 0x18, 0xCC, 0x06, 0xAC, 0x55, 0x78, 0x3A,
+    0x45, 0x7A, 0x17, 0x3B, 0xA9, 0x3A, 0x2D, 0x63, 0x6D, 0x18, 0x0D, 0x49,
+    0x5C, 0x1D, 0x7D, 0xAA, 0xBA, 0x32, 0xD1, 0x4F, 0x23, 0x3A, 0x69, 0xB1,
+    0xB9, 0x87, 0x80, 0x91, 0x88, 0x6B, 0x66, 0x35, 0x7D, 0x8B, 0x13, 0x85,
+    0xCA, 0x84, 0xB0, 0xBC, 0x56, 0xF6, 0x41, 0x0A, 0x71, 0x1F, 0x27, 0x60,
+    0xC2, 0x95, 0x85, 0x34, 0x59, 0x97, 0xC0, 0xDC, 0xB9, 0xA7, 0xAF, 0xEA,
+    0xA7, 0x16, 0x9D, 0x16, 0xA7, 0x58, 0xC0, 0xE8, 0x3B, 0xCF, 0x18, 0xB9,
+    0x34, 0x83, 0x6A, 0x00, 0x92, 0x8D, 0x17, 0xF3, 0x15, 0xD7, 0xBA, 0x81,
+    0xA2, 0x17, 0xAC, 0x14, 0x16, 0x2A, 0xC6, 0x46, 0x5B, 0xD5, 0x4A, 0x24,
+    0x11, 0xF2, 0xF4, 0x61, 0x14, 0x36, 0x97, 0x3B, 0x47, 0xB5, 0xA3, 0x34,
+    0xB7, 0x53, 0xA6, 0x01, 0xEB, 0x2C, 0xA2, 0x43, 0xFC, 0xCB, 0xC9, 0xAC,
+    0x34, 0x87, 0xBD, 0x23, 0x1B, 0xF0, 0x53, 0x6C, 0xDB, 0x67, 0x2A, 0x9B,
+    0xCF, 0x4D, 0xBD, 0xC4, 0x08, 0xDC, 0xCF, 0x31, 0xF5, 0x61, 0xAD, 0x82,
+    0x11, 0x9E, 0x04, 0xCE, 0x19, 0xAB, 0x14, 0x50, 0x7C, 0xAE, 0xD0, 0xA2,
+    0xC9, 0x7A, 0xB4, 0x01, 0xDA, 0x23, 0xC3, 0xCF, 0x37, 0xCF, 0xC2, 0x54,
+    0xDD, 0x7C, 0xA2, 0x79, 0xB0, 0x6B, 0xD3, 0xBA, 0x5D, 0x1A, 0xBC, 0x7D,
+    0x08, 0x2D, 0x64, 0xA1, 0x12, 0x35, 0x32, 0x8A, 0xB5, 0x49, 0x5C, 0xEC,
+    0x10, 0xF7, 0x71, 0xC5, 0xE0, 0xA7, 0x14, 0xCD, 0xDB, 0x25, 0x14, 0xBB,
+    0xBB, 0x53, 0x29, 0x92, 0x4C, 0xBB, 0x23, 0xEB, 0x16, 0xCA, 0xCE, 0x99,
+    0x1E, 0x41, 0xB4, 0x3A, 0xD0, 0x73, 0xDF, 0x44, 0x65, 0xBE, 0x02, 0x92,
+    0xD9, 0x77, 0x77, 0x7B, 0x56, 0x03, 0x53, 0x83, 0x80, 0x29, 0xCD, 0x9C,
+    0x12, 0x54, 0xE7, 0x20, 0xB4, 0xFE, 0x08, 0xB4, 0xE5, 0xCC, 0xB8, 0xFD,
+    0x34, 0xB9, 0x49, 0xFA, 0xB5, 0xA8, 0x9D, 0xCD, 0xC9, 0x7C, 0xD2, 0xFD,
+    0xF3, 0x4F, 0xBA, 0xD5, 0x6B, 0xD0, 0x3C, 0xD7, 0x8B, 0xAB, 0xD1, 0x36,
+    0x56, 0xBF, 0x17, 0x30, 0xE0, 0x22, 0x41, 0x83, 0xF5, 0xE4, 0xB9, 0x63,
+    0x66, 0x88, 0x47, 0x72, 0xD9, 0x91, 0xA1, 0xA3, 0x69, 0xA1, 0x02, 0x21,
+    0xE9, 0x34, 0xB5, 0x02, 0xB8, 0x24, 0x9B, 0x25, 0xEC, 0x2D, 0x2A, 0xD7,
+    0xA5, 0x3B, 0x96, 0x4D, 0xCA, 0x6B, 0xF3, 0xB4, 0x2A, 0xD5, 0x25, 0x3C,
+    0x2E, 0xC2, 0x29, 0xE1, 0xC5, 0x97, 0x91, 0x88, 0x57, 0xB8, 0x89, 0xE5,
+    0x32, 0x80, 0x1E, 0x19, 0x92, 0x09, 0xEA, 0x7A, 0x45, 0xEC, 0x19, 0xD6,
+    0xEC, 0xDB, 0xB0, 0x2A, 0xAE, 0x44, 0x62, 0xE3, 0xBA, 0x7C, 0x43, 0xFA,
+    0x94, 0x38, 0xFE, 0xF4, 0x2D, 0x5C, 0xDE, 0x12, 0x86, 0x3C, 0x26, 0x42,
+    0x3B, 0xB7, 0xDE, 0x55, 0x59, 0x41, 0x4C, 0x27, 0x48, 0x1C, 0x63, 0x0A,
+    0x6C, 0xAF, 0x1B, 0x23, 0xB6, 0x80, 0x08, 0xAB, 0xEC, 0x18, 0x38, 0x19,
+    0xFE, 0x68, 0x08, 0x74, 0xE5, 0x7E, 0x34, 0x51, 0x75, 0x0E, 0x4A, 0xE8,
+    0x98, 0x13, 0x0B, 0x72, 0x19, 0x5F, 0x24, 0xE6, 0x85, 0x87, 0xB1, 0x68,
+    0xC8, 0xC2, 0x23, 0x05, 0x78, 0x75, 0x76, 0xE7, 0x6A, 0x99, 0xD6, 0xCD,
+    0x86, 0x89, 0x88, 0x2E, 0x9D, 0xF6, 0xCB, 0x7F, 0xB7, 0x5B, 0x7E, 0xD3,
+    0x3B, 0xA4, 0x74, 0x61, 0x65, 0x6D, 0x6C, 0x14, 0xDB, 0x9C, 0x16, 0x5B,
+    0x83, 0xE9, 0xF8, 0x98, 0x98, 0x69, 0x24, 0x01, 0x9F, 0x04, 0xAE, 0x29,
+    0x12, 0x73, 0xB1, 0x6B, 0x96, 0xB9, 0xC6, 0xE8, 0x88, 0x6E, 0x7F, 0xB6,
+    0xFE, 0x71, 0xDB, 0xFD, 0xCD, 0xDD, 0x0D, 0xA1, 0x38, 0xF9, 0xEA, 0xE3,
+    0x60, 0x03, 0x32, 0x80, 0x03, 0xBA, 0xB1, 0x02, 0xFE, 0x3C, 0x10, 0x03,
+    0xD8, 0x30, 0x01, 0x86, 0x09, 0xE3, 0x82, 0x80, 0x64, 0x79, 0xD7, 0xBB,
+    0x89, 0x10, 0xA8, 0x46, 0x2E, 0x00, 0x8E, 0x44, 0xD0, 0x3B, 0x69, 0x79,
+    0x1A, 0x8A, 0x36, 0xB5, 0x54, 0x2C, 0x2E, 0x6E, 0x66, 0x08, 0x47, 0x91,
+    0xF9, 0x4D, 0xB7, 0xAB, 0xAE, 0xA8, 0x92, 0x4E, 0xA3, 0xD5, 0xE0, 0x03,
+    0xF0, 0xB1, 0x02, 0x3D, 0xA0, 0x0D, 0xB1, 0xF1, 0x46, 0xDE, 0x0C, 0xA9,
+    0x76, 0xD6, 0x5E, 0xEA, 0x12, 0x9D, 0xE1, 0x25, 0xCF, 0x80, 0xF2, 0x69,
+    0xD7, 0x77, 0x7D, 0x97, 0x05, 0xEF, 0x64, 0xC3, 0xC0, 0xA4, 0x49, 0x2D,
+    0x5A, 0x94, 0x01, 0xCC, 0x9D, 0x87, 0x55, 0x61, 0x23, 0x87, 0x6B, 0xE5,
+    0xFA, 0x0C, 0xBD, 0x1E, 0xA2, 0xEC, 0xE4, 0x70, 0x03, 0xBA, 0xD1, 0x01,
+    0x10, 0x70, 0x00, 0xA5, 0xB1, 0x03, 0xE0, 0xF0, 0xC4, 0xEB, 0x3B, 0xE9,
+    0x4E, 0x6A, 0xB1, 0x23, 0x7A, 0x2F, 0xE3, 0x95, 0x2E, 0x9A, 0x0B, 0xEE,
+    0x34, 0xF3, 0x2B, 0x94, 0x28, 0x43, 0x53, 0x54, 0xBF, 0x74, 0x51, 0xA9,
+    0x8E, 0x24, 0x4E, 0xC2, 0x64, 0x9D, 0xAD, 0x23, 0xE7, 0x15, 0x6F, 0xF0,
+    0xD5, 0x80, 0xF1, 0x92, 0x71, 0x00, 0x23, 0x10, 0x00, 0x40, 0x1F, 0x00,
+    0x24, 0xB0, 0x00, 0x1C, 0x1F, 0x19, 0x1E, 0xFF, 0x0D, 0x59, 0x82, 0xB8,
+    0xB1, 0x65, 0xF1, 0xA2, 0x0C, 0x2C, 0x5F, 0x7A, 0x9D, 0x6F, 0xDD, 0x49,
+    0x08, 0x7F, 0x17, 0x21, 0xED, 0x51, 0x11, 0x1D, 0x2D, 0x89, 0xBE, 0x5A,
+    0x81, 0x45, 0x27, 0x2F, 0x1A, 0x19, 0xB9, 0xB4, 0xCF, 0x1A, 0xEE, 0x6B,
+    0x0B, 0x2A, 0x97, 0x4C, 0x4F, 0x0E, 0xF2, 0x2E, 0x19, 0x2F, 0x90, 0x00,
+    0x41, 0xBF, 0xF6, 0x09, 0xD0, 0x01, 0x92, 0x71, 0xF4, 0xDD, 0x20, 0x68,
+    0xA5, 0x9A, 0x44, 0x72, 0x55, 0x01, 0x21, 0x04, 0xAC, 0xD1, 0xC9, 0xFE,
+    0x47, 0xE6, 0x8D, 0x6F, 0x9E, 0x4D, 0x27, 0x2F, 0x4D, 0x33, 0xA2, 0x0E,
+    0xDD, 0x05, 0x14, 0x54, 0x9E, 0xCA, 0x16, 0x64, 0xF8, 0x15, 0xC3, 0xF8,
+    0xD0, 0x8A, 0x5B, 0xF3, 0x34, 0x5B, 0x45, 0xF2, 0xB0, 0x03, 0x92, 0xD1,
+    0x01, 0x1F, 0xB0, 0xF6, 0x94, 0x1F, 0x00, 0x6D, 0x2F, 0x19, 0x3E, 0xF0,
+    0x0D, 0x14, 0xFE, 0xC0, 0xEB, 0x82, 0x00, 0x7D, 0x5A, 0x40, 0x2B, 0xE6,
+    0xEB, 0x3E, 0x96, 0xA4, 0x21, 0xC9, 0x00, 0x26, 0x40, 0x4D, 0x47, 0x03,
+    0x47, 0x9D, 0x83, 0x6D, 0xA4, 0x21, 0xEC, 0x41, 0x55, 0x2B, 0xF5, 0xDA,
+    0xA5, 0xEF, 0x92, 0xF8, 0xBB, 0xE7, 0xF8, 0xE1, 0x1C, 0xF6, 0x68, 0x33,
+    0xF6, 0xC9, 0x50, 0x03, 0x35, 0x60, 0x03, 0xA4, 0x60, 0x03, 0x2B, 0x10,
+    0x19, 0x1D, 0xA0, 0xF6, 0x95, 0x4F, 0xF9, 0x97, 0x6F, 0xF4, 0xDE, 0x80,
+    0xD0, 0x0F, 0xEC, 0xD3, 0x31, 0x8F, 0x21, 0x75, 0x26, 0xF2, 0xA2, 0x7C,
+    0x93, 0x25, 0xE5, 0x6B, 0x26, 0x10, 0x43, 0x62, 0xBB, 0x41, 0x7A, 0x6B,
+    0x55, 0x41, 0x48, 0xD3, 0x70, 0xFB, 0x71, 0xC5, 0xF6, 0xA2, 0xA6, 0x49,
+    0xD7, 0xEB, 0x2E, 0x18, 0x53, 0x7E, 0x0C, 0x35, 0x70, 0x03, 0xC1, 0x1F,
+    0x19, 0x38, 0xF0, 0x03, 0xBE, 0xFF, 0x09, 0x31, 0x90, 0xFE, 0xC3, 0x5F,
+    0xFC, 0xC5, 0x9F, 0x00, 0x10, 0x10, 0x19, 0x2B, 0xD0, 0xFE, 0xDC, 0xA0,
+    0x58, 0x9E, 0xAF, 0x94, 0x72, 0xFA, 0xB1, 0x44, 0xCB, 0xD1, 0x80, 0x00,
+    0x20, 0x38, 0x28, 0x38, 0x81, 0x31, 0x80, 0x98, 0xC8, 0xB1, 0x21, 0xD0,
+    0xE8, 0xF8, 0xE8, 0x68, 0xD0, 0x92, 0x88, 0x88, 0x51, 0x40, 0x88, 0x99,
+    0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, 0x09, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A,
+    0x6A, 0x7A, 0x8A, 0xFA, 0x19, 0x42, 0x39, 0xE0, 0xC1, 0x08, 0xD9, 0x08,
+    0x82, 0x80, 0xFE, 0xE8, 0xC8, 0x90, 0x48, 0xC0, 0x99, 0xC2, 0xEA, 0x02,
+    0xDB, 0x2B, 0xA0, 0x40, 0x59, 0x41, 0x78, 0x91, 0xE8, 0xE0, 0x2B, 0xB0,
+    0xC1, 0xC1, 0x8A, 0x78, 0x92, 0xEA, 0xFC, 0x0C, 0x20, 0x73, 0x8C, 0xF3,
+    0xA3, 0x03, 0x4D, 0x98, 0xD3, 0x28, 0x12, 0xC0, 0xDD, 0xED, 0xFD, 0xCD,
+    0x9D, 0x70, 0xD0, 0x98, 0x73, 0x6D, 0x7E, 0x1E, 0x7A, 0xC2, 0x6A, 0x72,
+    0xDC, 0xB8, 0x61, 0xE2, 0x90, 0x81, 0xE8, 0xA1, 0x62, 0xF2, 0xDA, 0xFE,
+    0xA8, 0x9C, 0x18, 0xC1, 0x59, 0x42, 0xC0, 0xEA, 0x00, 0x04, 0x3E, 0x58,
+    0x0C, 0x66, 0x25, 0x6A, 0x80, 0x2E, 0xA1, 0xC2, 0x85, 0x0C, 0x1B, 0x3A,
+    0xF4, 0x54, 0x80, 0x02, 0x40, 0x03, 0xED, 0x5C, 0x20, 0x7A, 0x65, 0xE2,
+    0x60, 0x27, 0x5D, 0x89, 0x10, 0xDC, 0x6B, 0x67, 0xC0, 0xE0, 0x80, 0x10,
+    0x84, 0x2C, 0x50, 0xE2, 0x05, 0x29, 0xD9, 0x32, 0x44, 0x14, 0x84, 0x3D,
+    0x5C, 0xC8, 0x63, 0xA0, 0x80, 0x1B, 0xD6, 0xA0, 0x49, 0x13, 0xD0, 0x21,
+    0x01, 0xB8, 0x9D, 0xDF, 0x60, 0x38, 0x92, 0xF1, 0x32, 0xA8, 0xA9, 0x02,
+    0x87, 0x28, 0x39, 0xF8, 0x28, 0x33, 0x69, 0x2D, 0x4A, 0x14, 0x38, 0x99,
+    0xA4, 0x84, 0x80, 0x9D, 0xD2, 0x47, 0xB2, 0x28, 0x49, 0x10, 0x8A, 0x35,
+    0xAB, 0xD6, 0xAD, 0xE8, 0x8A, 0x2A, 0x92, 0xA9, 0x61, 0x00, 0x83, 0x46,
+    0x61, 0x11, 0x21, 0xEC, 0x24, 0x31, 0x91, 0x87, 0xA4, 0xFA, 0x06, 0x5C,
+    0xC0, 0x44, 0x0C, 0x51, 0x86, 0x47, 0x06, 0x14, 0x88, 0x64, 0xEA, 0x92,
+    0xEB, 0xB3, 0x9B, 0x28, 0x16, 0x2C, 0x80, 0x80, 0x42, 0x84, 0x08, 0x14,
+    0xB0, 0x64, 0xC4, 0x70, 0x66, 0xA3, 0xD1, 0x01, 0x9D, 0x3C, 0x1B, 0x73,
+    0x13, 0xE1, 0xC8, 0x86, 0xDE, 0xC9, 0x83, 0x22, 0x2E, 0x5B, 0x34, 0x75,
+    0xAA, 0x3C, 0x44, 0x04, 0x2E, 0xFE, 0x69, 0x7A, 0xAA, 0x56, 0x60, 0x66,
+    0xAA, 0x77, 0x27, 0x50, 0x3E, 0x8D, 0x3A, 0xB5, 0x50, 0x8E, 0x89, 0x44,
+    0x0F, 0xE4, 0x30, 0x56, 0x80, 0xAD, 0x44, 0x9F, 0x1A, 0x50, 0x52, 0x20,
+    0x13, 0x04, 0x25, 0xD3, 0x83, 0x40, 0x0F, 0xD0, 0x20, 0xA0, 0xEE, 0xDD,
+    0x44, 0x2D, 0x55, 0x9F, 0xB2, 0xB1, 0x42, 0x00, 0x0B, 0xC6, 0xDF, 0x48,
+    0x8C, 0x60, 0xF1, 0x68, 0xC5, 0x0F, 0xC9, 0xA6, 0x62, 0x64, 0x3B, 0xF0,
+    0xC1, 0xB1, 0xF6, 0x00, 0xD0, 0x05, 0x94, 0x33, 0xBE, 0x55, 0xC2, 0x4A,
+    0x0E, 0xAE, 0x8F, 0x31, 0x68, 0xE1, 0x01, 0xF8, 0x40, 0x60, 0x89, 0x2C,
+    0x6C, 0x4A, 0x5B, 0x8C, 0xE2, 0x68, 0x48, 0x16, 0x35, 0x82, 0xBF, 0x8F,
+    0x3F, 0xBF, 0x28, 0xF8, 0x03, 0x10, 0xC8, 0x1F, 0xF8, 0x8A, 0x01, 0x94,
+    0xB8, 0xD7, 0x49, 0x01, 0xFF, 0x20, 0xE2, 0x91, 0x4C, 0x22, 0xA5, 0x00,
+    0x57, 0x22, 0x19, 0xD8, 0xB5, 0x52, 0x71, 0xFA, 0x85, 0x12, 0x03, 0x0E,
+    0x02, 0xCC, 0xB0, 0x1D, 0x09, 0x0B, 0x8C, 0xE3, 0x08, 0x0E, 0x3B, 0x94,
+    0xF2, 0x43, 0x23, 0x30, 0x6C, 0xA7, 0x1D, 0x09, 0x8E, 0x7C, 0x38, 0xE1,
+    0x4B, 0x86, 0xAC, 0x94, 0x41, 0x0B, 0x2E, 0xDC, 0x03, 0x02, 0x03, 0x0A,
+    0xA8, 0x60, 0xD0, 0x5C, 0x00, 0x52, 0x72, 0x56, 0x26, 0xBE, 0x0D, 0xC0,
+    0xC1, 0x7C, 0xBE, 0x4C, 0xB2, 0x4F, 0x8A, 0x42, 0x0E, 0x79, 0x9F, 0x3A,
+    0x6A, 0xFD, 0x97, 0x94, 0x07, 0x89, 0xBC, 0xE5, 0x49, 0x04, 0x94, 0xF4,
+    0x38, 0x90, 0x0A, 0xC4, 0x61, 0xB2, 0xE3, 0x32, 0x12, 0x12, 0xD9, 0x09,
+    0x0D, 0x02, 0xBC, 0x40, 0x62, 0x38, 0x2F, 0x40, 0xE2, 0xC3, 0x28, 0x35,
+    0x34, 0xC2, 0x65, 0x97, 0x8E, 0x41, 0x26, 0xC0, 0x0A, 0x87, 0x61, 0xC9,
+    0x90, 0x04, 0x07, 0xAE, 0x04, 0x27, 0x22, 0xB8, 0xFE, 0x0D, 0xE4, 0x40,
+    0x30, 0x9F, 0xB1, 0x02, 0xA5, 0x8F, 0xB0, 0x18, 0xB0, 0xD9, 0x00, 0xCD,
+    0xB0, 0x09, 0x68, 0xA0, 0x41, 0x11, 0x45, 0x89, 0x0A, 0x99, 0x95, 0x85,
+    0x08, 0x83, 0x9E, 0xF0, 0x87, 0xA4, 0x2F, 0xEC, 0x0D, 0x90, 0xE3, 0x20,
+    0x71, 0x59, 0x99, 0x97, 0xA0, 0x98, 0xEC, 0x80, 0x93, 0x99, 0xDD, 0x3C,
+    0x40, 0x98, 0x23, 0x34, 0x50, 0xE7, 0x49, 0x85, 0x38, 0x31, 0xA7, 0x29,
+    0x38, 0xE2, 0x34, 0x02, 0x94, 0xA5, 0xE8, 0x14, 0xE0, 0x66, 0x9C, 0x2B,
+    0xF9, 0x37, 0x10, 0xA2, 0x03, 0x5C, 0x95, 0x49, 0x09, 0xAC, 0xA8, 0xA7,
+    0x67, 0x2F, 0xB2, 0x7A, 0xA6, 0x6A, 0xAF, 0xBE, 0xA6, 0x62, 0xE0, 0x93,
+    0x99, 0xF5, 0x49, 0x40, 0xA5, 0x9A, 0x54, 0x40, 0x09, 0xAE, 0xE6, 0xDD,
+    0xA2, 0x23, 0xA5, 0xBF, 0x62, 0x62, 0xE1, 0x08, 0xA5, 0x76, 0x33, 0x42,
+    0xA7, 0x69, 0x82, 0xCA, 0x49, 0x4C, 0xD8, 0x4D, 0xDB, 0xD8, 0x07, 0xE3,
+    0xA8, 0xF9, 0xEC, 0x35, 0x05, 0x58, 0xE0, 0x95, 0xAB, 0x03, 0xB4, 0x30,
+    0x50, 0x48, 0x89, 0x60, 0xA0, 0xC9, 0x04, 0x6F, 0x9E, 0x9B, 0xEB, 0x31,
+    0x02, 0xB6, 0x17, 0x6E, 0xBD, 0xF6, 0x76, 0xE2, 0x6E, 0xB2, 0x53, 0xD5,
+    0x57, 0x09, 0xAF, 0x9B, 0x18, 0xC9, 0xE3, 0x40, 0xB3, 0x21, 0xA2, 0xC9,
+    0xA4, 0x57, 0xD6, 0x9B, 0x18, 0x0A, 0xDC, 0x7A, 0x03, 0x83, 0xB5, 0x86,
+    0x71, 0x32, 0xA6, 0x00, 0x0B, 0x68, 0x97, 0x00, 0x0C, 0x0B, 0xBC, 0x30,
+    0xC3, 0x03, 0x0F, 0x64, 0xD7, 0xD8, 0x02, 0xA8, 0xDE, 0x0B, 0x4D, 0x05,
+    0x16, 0x50, 0x60, 0x1B, 0x25, 0xE5, 0x22, 0xD5, 0x8B, 0x94, 0x41, 0x66,
+    0x52, 0x6E, 0x9E, 0xF1, 0xF6, 0x52, 0x27, 0x22, 0xB4, 0x82, 0x4C, 0xF3,
+    0xBD, 0xB6, 0xEA, 0xAB, 0x94, 0xCA, 0x2C, 0x79, 0x22, 0x1E, 0x22, 0xFE,
+    0xC6, 0xE0, 0x33, 0xF0, 0x00, 0x77, 0x1E, 0x6C, 0x6F, 0x88, 0xD2, 0x2E,
+    0xDC, 0x4D, 0x02, 0x1D, 0x38, 0x92, 0xC3, 0x9A, 0x99, 0x64, 0xA3, 0x70,
+    0x63, 0x0F, 0xA0, 0x09, 0x0B, 0x0A, 0x33, 0x90, 0x9A, 0x74, 0x23, 0xE0,
+    0xD6, 0x8C, 0x0E, 0x6B, 0x6B, 0x01, 0x4D, 0x09, 0x49, 0x99, 0xAC, 0x52,
+    0xCC, 0xCB, 0xED, 0x3C, 0xDA, 0xCC, 0x04, 0x62, 0x73, 0xCD, 0xB6, 0xAA,
+    0xBE, 0x21, 0x50, 0x1E, 0x3E, 0xEA, 0x4E, 0xC9, 0x49, 0xCF, 0x03, 0xFC,
+    0xDC, 0x4E, 0xD0, 0x9B, 0x18, 0x7B, 0x2F, 0x0E, 0x07, 0x20, 0x0D, 0x0E,
+    0xD5, 0x37, 0x68, 0x82, 0xA9, 0x00, 0x47, 0x83, 0x33, 0x83, 0xB5, 0xC7,
+    0xE4, 0xB4, 0x93, 0xC7, 0x02, 0x84, 0xD9, 0xF6, 0x35, 0x64, 0x0F, 0x30,
+    0x67, 0x3B, 0xC4, 0xFA, 0x2B, 0x88, 0x93, 0x0E, 0x36, 0x9A, 0x9B, 0x09,
+    0x0A, 0x7C, 0xEE, 0x02, 0xE7, 0x8E, 0x3C, 0xDA, 0x40, 0xBE, 0x4D, 0x45,
+    0x8E, 0x3A, 0x9B, 0xFC, 0x25, 0x98, 0x94, 0x6E, 0x4C, 0x71, 0x32, 0x39,
+    0xDE, 0xCB, 0x72, 0x96, 0x3A, 0x21, 0x63, 0x96, 0x09, 0xB8, 0x37, 0x10,
+    0xFC, 0x84, 0x09, 0x72, 0x02, 0x40, 0xB0, 0x53, 0x02, 0xBB, 0x1F, 0x23,
+    0xC4, 0x23, 0x8C, 0x7F, 0x93, 0x00, 0x61, 0x38, 0xD4, 0xEE, 0x4C, 0xC9,
+    0xAD, 0xC4, 0x0D, 0xC9, 0xA3, 0x03, 0x94, 0xA0, 0x49, 0xB9, 0xD0, 0xE3,
+    0xA3, 0x81, 0x92, 0xAC, 0x20, 0x50, 0x79, 0xF4, 0x4B, 0xBE, 0x79, 0x3A,
+    0xF3, 0xE2, 0xE3, 0x07, 0x70, 0x2B, 0xA2, 0xFB, 0x22, 0xEB, 0x00, 0x14,
+    0x60, 0x0E, 0x40, 0xB0, 0x88, 0xA0, 0x8B, 0x0F, 0xE9, 0xE3, 0xDF, 0x60,
+    0x78, 0xEE, 0xC8, 0x2F, 0xDD, 0x08, 0x8A, 0x00, 0x88, 0x2A, 0xC0, 0x03,
+    0xE0, 0x7C, 0xA0, 0xB8, 0x46, 0x10, 0xC1, 0x08, 0x48, 0x50, 0x82, 0x20,
+    0x8E, 0x00, 0xFE, 0x04, 0x22, 0x68, 0x63, 0x27, 0x33, 0x68, 0x44, 0x0F,
+    0xC6, 0x67, 0x8A, 0x72, 0x51, 0x4E, 0x74, 0x73, 0x83, 0xD4, 0x9D, 0x12,
+    0xD1, 0x3D, 0x00, 0xC5, 0x0C, 0x4E, 0x1E, 0xE0, 0x9C, 0xF4, 0x58, 0x11,
+    0x3E, 0x08, 0x8A, 0x90, 0x32, 0x84, 0x2A, 0x9B, 0x52, 0xD2, 0x77, 0x01,
+    0x7E, 0x0C, 0xA2, 0x02, 0xD6, 0x8B, 0x12, 0xDD, 0x98, 0x97, 0x1C, 0xFF,
+    0xD9, 0xCF, 0x1B, 0x09, 0x40, 0xD3, 0x0A, 0x6A, 0x92, 0x8D, 0x2D, 0x81,
+    0x63, 0x04, 0x1C, 0x72, 0x04, 0x11, 0x80, 0x10, 0x04, 0x4D, 0x1C, 0x81,
+    0x09, 0x8D, 0x98, 0x58, 0x73, 0x1A, 0xC1, 0x83, 0x11, 0x8E, 0x62, 0x72,
+    0x0E, 0x8A, 0xCD, 0x23, 0xA4, 0xC7, 0x37, 0x00, 0x4C, 0x2A, 0x03, 0xE7,
+    0xD3, 0xD5, 0x70, 0x56, 0xF2, 0xB5, 0x27, 0xBA, 0x8A, 0x40, 0x4A, 0xEC,
+    0xA2, 0x56, 0xDC, 0x87, 0x08, 0x97, 0xC5, 0x6A, 0x19, 0x17, 0xA0, 0x80,
+    0x04, 0xCA, 0x77, 0x37, 0x05, 0xD1, 0x8B, 0x79, 0x3D, 0x68, 0xC4, 0x0C,
+    0x77, 0xF2, 0x25, 0x01, 0xD0, 0x00, 0x00, 0x11, 0x43, 0x01, 0xD6, 0x3E,
+    0x00, 0x89, 0x1F, 0x06, 0x91, 0x13, 0x47, 0x50, 0xE0, 0x62, 0xC0, 0x31,
+    0xBC, 0x9A, 0x78, 0xD1, 0x13, 0x2B, 0x62, 0x85, 0x0A, 0x90, 0xD4, 0xA7,
+    0x10, 0x0E, 0xE2, 0x66, 0x88, 0x50, 0x16, 0x3E, 0x80, 0x44, 0x09, 0x02,
+    0x98, 0x51, 0x82, 0x19, 0xDC, 0x20, 0x9C, 0xB8, 0x38, 0xC8, 0x4C, 0x3A,
+    0x24, 0x5F, 0x89, 0x90, 0x4A, 0x52, 0xD2, 0x07, 0x27, 0xD6, 0xB5, 0x43,
+    0x56, 0x51, 0x64, 0x5B, 0x4C, 0x3A, 0xF0, 0xC6, 0x9D, 0xA0, 0xE9, 0x06,
+    0xC9, 0x11, 0xC0, 0x88, 0xBC, 0xE1, 0xAD, 0x47, 0x08, 0xE1, 0x08, 0xA0,
+    0x50, 0xC2, 0x02, 0xBF, 0x31, 0x82, 0x46, 0x40, 0x4E, 0x93, 0x1B, 0x79,
+    0x57, 0x7F, 0xA4, 0xC2, 0xAF, 0xFE, 0x01, 0x44, 0x11, 0x60, 0x36, 0x92,
+    0x49, 0x5B, 0x38, 0x83, 0xC9, 0x08, 0xBC, 0x09, 0x56, 0x8E, 0x18, 0x4E,
+    0x3D, 0x58, 0x81, 0x49, 0x5E, 0x4A, 0xF3, 0x1C, 0x8C, 0x6C, 0xE4, 0x54,
+    0x40, 0xA0, 0xBD, 0x50, 0x5E, 0x0F, 0x16, 0x7D, 0x62, 0x97, 0xF8, 0x6E,
+    0x99, 0xCA, 0x6F, 0xE0, 0xAF, 0x11, 0x2C, 0xF8, 0x46, 0x2C, 0x05, 0x88,
+    0x84, 0x51, 0x00, 0xA1, 0x11, 0x24, 0x00, 0xC7, 0x38, 0xBE, 0x33, 0xCD,
+    0xBD, 0xA1, 0xF1, 0x6E, 0x20, 0x80, 0xE4, 0x9F, 0x30, 0x51, 0x00, 0x4A,
+    0x78, 0x12, 0x1F, 0xC7, 0xF4, 0x13, 0xFB, 0x34, 0x67, 0x4D, 0x77, 0xE0,
+    0xA9, 0x11, 0xFD, 0x8C, 0x66, 0x3C, 0x0F, 0x8A, 0x8A, 0xB7, 0x6D, 0xF3,
+    0x18, 0x1A, 0xE8, 0xD3, 0x93, 0xAA, 0xF8, 0x88, 0x8C, 0xAC, 0xB1, 0x76,
+    0x11, 0x3B, 0x5C, 0x38, 0x93, 0xC6, 0xA1, 0x3F, 0x26, 0xCD, 0x5A, 0x44,
+    0x30, 0x20, 0x29, 0x9A, 0xA0, 0xC3, 0x6F, 0xA0, 0x09, 0x5B, 0x08, 0x25,
+    0x84, 0x3F, 0x96, 0x21, 0x12, 0x83, 0x02, 0xA0, 0x9A, 0x10, 0x75, 0x44,
+    0x3F, 0x15, 0xA5, 0x09, 0x80, 0xC1, 0x4F, 0x00, 0x12, 0x0D, 0x63, 0x3E,
+    0x22, 0xC9, 0x9B, 0x92, 0xEA, 0xB4, 0x14, 0xAB, 0x43, 0xD9, 0x40, 0x40,
+    0xE0, 0xB9, 0xCF, 0x69, 0xA0, 0xA5, 0x8E, 0xA8, 0x0A, 0x22, 0x98, 0xC4,
+    0xBC, 0xC2, 0x71, 0xEC, 0xA2, 0xDE, 0x70, 0x9C, 0x45, 0x03, 0x40, 0xB5,
+    0x26, 0x78, 0x94, 0x14, 0x43, 0x10, 0xC0, 0xDF, 0x70, 0xD9, 0x88, 0x1F,
+    0xEC, 0x34, 0x13, 0x05, 0x60, 0x22, 0x2B, 0xA2, 0x18, 0x3B, 0x99, 0x7C,
+    0x50, 0xA5, 0x83, 0xB0, 0x1B, 0xDE, 0x74, 0x26, 0x46, 0x01, 0x1C, 0x93,
+    0x00, 0x39, 0xDD, 0xAA, 0x5B, 0x17, 0x45, 0x89, 0x0E, 0x9A, 0x2D, 0x5D,
+    0x0E, 0xA5, 0x9E, 0xF8, 0x6E, 0xC2, 0x54, 0x70, 0xFE, 0x7C, 0x09, 0x78,
+    0xDE, 0xC8, 0x65, 0x23, 0x98, 0xB0, 0x47, 0x53, 0x14, 0xEF, 0xA9, 0x0F,
+    0x68, 0xC4, 0xF2, 0xDE, 0x4A, 0x88, 0x08, 0x48, 0x70, 0x00, 0xB8, 0xD0,
+    0x84, 0xF3, 0x32, 0xD8, 0x0B, 0xD7, 0x4D, 0x74, 0x13, 0x66, 0x6D, 0x26,
+    0x22, 0xF6, 0x79, 0xD3, 0x5B, 0xB4, 0x15, 0xB1, 0x9C, 0xAD, 0x4C, 0xB9,
+    0x64, 0x37, 0x57, 0x58, 0x60, 0x93, 0x12, 0xF7, 0x64, 0x5E, 0x4C, 0xF8,
+    0x9A, 0xD7, 0x6E, 0xA0, 0x40, 0xA3, 0xDC, 0x38, 0x27, 0x60, 0x53, 0x61,
+    0x4B, 0x54, 0x7E, 0x23, 0x32, 0x9D, 0x2D, 0xEB, 0xBB, 0x22, 0x45, 0x08,
+    0x4A, 0x38, 0xF1, 0x18, 0x96, 0x24, 0x2B, 0x21, 0xE0, 0x03, 0x3F, 0xD7,
+    0x39, 0x92, 0x2E, 0xD9, 0x64, 0xEC, 0x66, 0x6B, 0x9B, 0xBA, 0x02, 0x44,
+    0x60, 0xB9, 0xCB, 0x3D, 0x45, 0x01, 0x26, 0x15, 0xB0, 0xD0, 0x12, 0xE4,
+    0x2E, 0x96, 0x80, 0xA0, 0x96, 0x70, 0xA7, 0x9D, 0x11, 0xBC, 0x60, 0xA9,
+    0x66, 0x7A, 0xC0, 0xB6, 0xBC, 0x81, 0xBF, 0x26, 0x04, 0x16, 0x15, 0x44,
+    0x94, 0x61, 0x37, 0xD0, 0xA4, 0x55, 0xE4, 0x02, 0xA0, 0x02, 0xCE, 0x0B,
+    0x81, 0x41, 0xF3, 0x99, 0x08, 0x9F, 0x3E, 0x22, 0x68, 0x6B, 0xEB, 0xC4,
+    0x9B, 0xA4, 0x92, 0x91, 0xE1, 0x42, 0xC2, 0x00, 0xC5, 0xBD, 0x00, 0xFB,
+    0xD4, 0x4B, 0x33, 0xB5, 0x41, 0x77, 0x5D, 0x21, 0xB0, 0xAB, 0x28, 0x38,
+    0x79, 0x59, 0xE9, 0x3A, 0x42, 0x25, 0x38, 0x15, 0x61, 0x11, 0xB7, 0xC3,
+    0x29, 0x47, 0x74, 0x60, 0x04, 0x58, 0x3B, 0xD3, 0x53, 0xE3, 0xD8, 0x51,
+    0x68, 0x20, 0xE1, 0x77, 0xE6, 0x34, 0x2C, 0x80, 0x05, 0x71, 0xD2, 0x44,
+    0x61, 0x02, 0xA0, 0x03, 0x78, 0xCD, 0x92, 0xFE, 0x8B, 0x09, 0xD6, 0x0C,
+    0xE0, 0x15, 0x2A, 0xD0, 0xEF, 0x9E, 0x8A, 0x5B, 0xDD, 0x0F, 0x07, 0xFE,
+    0xD8, 0x79, 0xAE, 0xBA, 0x40, 0x08, 0x4A, 0xA9, 0x09, 0x12, 0xFF, 0x66,
+    0x2A, 0x9E, 0x73, 0xC1, 0x6E, 0xE7, 0xDB, 0x4F, 0xB7, 0x1C, 0xB7, 0x76,
+    0x8D, 0x30, 0x2F, 0x4F, 0xE2, 0x08, 0x89, 0xEF, 0x6E, 0xE7, 0xA9, 0x3E,
+    0x11, 0x40, 0x86, 0xA1, 0x71, 0x84, 0x22, 0x7F, 0x83, 0x43, 0x0F, 0xFC,
+    0x30, 0x40, 0xD9, 0x9A, 0x58, 0x4A, 0x0C, 0x64, 0x41, 0x9F, 0xA8, 0xC0,
+    0x9B, 0xF0, 0x26, 0xDF, 0x5E, 0x6C, 0x80, 0x15, 0xDE, 0x94, 0xB1, 0xBD,
+    0xBC, 0x6A, 0x2E, 0x96, 0xE0, 0x98, 0x4A, 0xAC, 0x58, 0xE8, 0x8B, 0x1D,
+    0xE4, 0x00, 0x15, 0x28, 0xC0, 0x01, 0x96, 0xC4, 0x11, 0x8A, 0x53, 0x27,
+    0xE5, 0xC6, 0x50, 0x0D, 0x16, 0x07, 0x30, 0x32, 0x4F, 0x1E, 0xD0, 0x4E,
+    0x8C, 0x36, 0xA2, 0x08, 0xE7, 0x20, 0xE2, 0x36, 0xBC, 0xB1, 0xCA, 0x0F,
+    0x23, 0x78, 0x00, 0x31, 0x06, 0x00, 0x89, 0x07, 0xB2, 0x1B, 0x88, 0x94,
+    0xEB, 0xC7, 0x32, 0xE1, 0x6F, 0x24, 0x7D, 0x6B, 0xE6, 0x40, 0x95, 0x90,
+    0x15, 0x1E, 0xA0, 0x73, 0x3C, 0xE0, 0x44, 0x80, 0x99, 0x79, 0x82, 0x89,
+    0x70, 0x53, 0xCA, 0x06, 0xAE, 0x18, 0x27, 0x51, 0x3B, 0xB8, 0x7F, 0x1D,
+    0x73, 0xC4, 0x12, 0x9E, 0x30, 0x84, 0x21, 0x14, 0x4F, 0x31, 0xDC, 0x25,
+    0x11, 0x9A, 0xD2, 0x79, 0x8E, 0x75, 0x46, 0x8D, 0x5A, 0x5A, 0x03, 0xF0,
+    0xA2, 0x11, 0xB1, 0xB6, 0x47, 0xE3, 0x83, 0x12, 0x9F, 0xE0, 0x8F, 0xA1,
+    0x32, 0xB3, 0x81, 0xE2, 0x62, 0x39, 0x15, 0x25, 0xC0, 0x74, 0xA6, 0x85,
+    0x32, 0x81, 0x01, 0x67, 0x60, 0xA8, 0xFB, 0xD5, 0x80, 0xCE, 0x4C, 0x36,
+    0xE4, 0x4C, 0xF0, 0x47, 0xAE, 0xAD, 0x43, 0x35, 0x08, 0xD7, 0x4C, 0x64,
+    0x56, 0xEF, 0x04, 0x8F, 0x8D, 0x00, 0x02, 0x26, 0x64, 0xAD, 0x98, 0x0A,
+    0x4B, 0xAD, 0xFE, 0x11, 0x42, 0x48, 0x48, 0x11, 0x1A, 0xC1, 0x5D, 0x13,
+    0x39, 0x10, 0xB9, 0x5E, 0x86, 0x93, 0x81, 0x29, 0xE1, 0x66, 0x01, 0x44,
+    0x7A, 0x13, 0x96, 0xE9, 0x08, 0x51, 0x21, 0x61, 0x54, 0xCE, 0x64, 0x3B,
+    0x14, 0xEC, 0x65, 0xEC, 0x9D, 0x9F, 0xFD, 0x12, 0x30, 0xF6, 0xC7, 0xC5,
+    0x91, 0x80, 0x10, 0x2B, 0x60, 0xCA, 0x89, 0x4D, 0xB7, 0x62, 0x2A, 0xA0,
+    0x24, 0x30, 0xB8, 0x99, 0x97, 0x67, 0x70, 0xE0, 0x8F, 0xD0, 0x9A, 0x30,
+    0x02, 0x39, 0xCD, 0xD4, 0xA9, 0xA9, 0x9A, 0xA3, 0xAA, 0xAE, 0x14, 0x67,
+    0x23, 0x06, 0x57, 0xDB, 0x72, 0x29, 0xDB, 0x33, 0x93, 0x62, 0x78, 0x23,
+    0x12, 0xB9, 0xB7, 0x72, 0x95, 0xFA, 0x9A, 0x77, 0x59, 0xF6, 0x29, 0x5A,
+    0xC5, 0x0C, 0x84, 0x73, 0x45, 0xE2, 0xAE, 0x48, 0x8A, 0x70, 0x58, 0xD1,
+    0x00, 0x70, 0x3F, 0x57, 0x58, 0x27, 0x64, 0xC5, 0x09, 0x22, 0x70, 0xF0,
+    0x55, 0xFB, 0x99, 0x1B, 0x8E, 0xE3, 0xF8, 0x26, 0x96, 0x20, 0x22, 0x12,
+    0xF9, 0xD5, 0x08, 0x0B, 0x79, 0x70, 0x5F, 0x1D, 0xE1, 0xB4, 0xB7, 0xDA,
+    0xCD, 0x7C, 0xD2, 0x3B, 0x0B, 0xC0, 0x8E, 0x7D, 0x0C, 0x48, 0x0E, 0xC0,
+    0xA0, 0x16, 0xF0, 0xA5, 0xCB, 0x23, 0x7B, 0x97, 0x0B, 0x0C, 0xFC, 0x13,
+    0x8A, 0x5D, 0x86, 0x0A, 0x75, 0x8E, 0x15, 0x95, 0xFF, 0xFB, 0x11, 0x1B,
+    0xA8, 0x33, 0x01, 0x20, 0xDE, 0xAE, 0x77, 0x41, 0xB6, 0x1D, 0x6B, 0x4D,
+    0xBA, 0xD2, 0xC1, 0x41, 0x82, 0x71, 0x2C, 0xC1, 0x13, 0x41, 0x50, 0xE0,
+    0xAE, 0x1D, 0xB3, 0x3B, 0x22, 0xD0, 0x52, 0x21, 0x20, 0x3D, 0xB4, 0x37,
+    0x4E, 0xC4, 0x59, 0x64, 0x6D, 0xAE, 0x11, 0x96, 0xBC, 0x8A, 0x6F, 0xC2,
+    0x8C, 0x0C, 0x10, 0x22, 0x7D, 0x02, 0x16, 0x18, 0x30, 0x02, 0x50, 0xA2,
+    0x14, 0x17, 0x50, 0xD7, 0xEF, 0xFE, 0xFC, 0x46, 0xF3, 0x51, 0x49, 0x0F,
+    0xF7, 0x6B, 0x6C, 0x7B, 0xEE, 0xB0, 0xA8, 0xE9, 0x41, 0x0E, 0xAE, 0xE3,
+    0xB3, 0x43, 0xE2, 0xDA, 0x8D, 0xD6, 0x64, 0xC6, 0xBB, 0xE1, 0x31, 0x22,
+    0x8C, 0x77, 0x13, 0x1B, 0xAE, 0x9F, 0x63, 0xC8, 0x6D, 0xEE, 0x85, 0x14,
+    0x0F, 0xB5, 0xDD, 0x70, 0x04, 0x0F, 0x62, 0x50, 0x83, 0xB7, 0xF2, 0xC7,
+    0x89, 0x15, 0x1C, 0xC0, 0x04, 0xC0, 0x08, 0x76, 0x47, 0xA5, 0x19, 0x41,
+    0xF9, 0x86, 0x45, 0xFA, 0x6A, 0x3F, 0x8A, 0x10, 0xC3, 0x49, 0xD5, 0xA9,
+    0x5F, 0x88, 0x6F, 0xB8, 0xED, 0xA3, 0xD1, 0x46, 0xD2, 0xC0, 0x17, 0x6C,
+    0x8D, 0x52, 0x2C, 0x9D, 0x88, 0xD2, 0x66, 0xB2, 0x11, 0x18, 0x9A, 0xB2,
+    0x00, 0xA8, 0x0E, 0x8A, 0xE2, 0x1D, 0x5E, 0x95, 0x4E, 0xDE, 0x7D, 0xAE,
+    0xAD, 0x0A, 0x8E, 0xEE, 0x74, 0x88, 0x06, 0x34, 0x29, 0xA9, 0xE4, 0xDF,
+    0x47, 0x1F, 0x94, 0xE0, 0x5F, 0xFC, 0x01, 0x7A, 0xBE, 0x10, 0x64, 0xCB,
+    0xE0, 0x00, 0xAC, 0x47, 0x16, 0x64, 0x86, 0x7A, 0x98, 0x50, 0x70, 0x00,
+    0x01, 0x02, 0x96, 0xB4, 0x76, 0xDD, 0xF7, 0x0C, 0x13, 0x00, 0x15, 0x98,
+    0xA7, 0x14, 0x1F, 0xE4, 0x4F, 0xB0, 0x03, 0x15, 0xD5, 0x17, 0x09, 0x77,
+    0xA1, 0x48, 0x5E, 0x64, 0x75, 0xBC, 0x26, 0x00, 0x4F, 0x10, 0x0A, 0x51,
+    0xE6, 0x7B, 0xC1, 0x33, 0x0E, 0xC1, 0xB7, 0x10, 0xEF, 0x26, 0x00, 0x3B,
+    0xE4, 0x0B, 0x2B, 0xC0, 0x03, 0x55, 0x36, 0x4D, 0x2A, 0xC6, 0x39, 0x62,
+    0xD7, 0x12, 0xCB, 0x94, 0x6F, 0x1A, 0xE8, 0x20, 0xB2, 0x67, 0x7D, 0x46,
+    0xD7, 0x80, 0x84, 0x80, 0x73, 0x1D, 0x21, 0x15, 0xA7, 0x66, 0x1F, 0x14,
+    0x98, 0x10, 0x43, 0x97, 0x08, 0x94, 0xA6, 0x27, 0xE2, 0x77, 0x0B, 0xE4,
+    0x87, 0x09, 0xAB, 0xA7, 0x14, 0x01, 0x37, 0x00, 0xFE, 0x78, 0xD7, 0x45,
+    0xD9, 0x40, 0x7C, 0x01, 0x90, 0x78, 0xA3, 0x40, 0x44, 0xB2, 0xC5, 0x40,
+    0xF5, 0xD7, 0x10, 0x24, 0xE7, 0x67, 0x09, 0x80, 0x0F, 0x34, 0xD0, 0x03,
+    0x59, 0x37, 0x48, 0xCE, 0x93, 0x56, 0xC1, 0x51, 0x5C, 0x25, 0xB0, 0x75,
+    0x33, 0x77, 0x0C, 0x1B, 0x80, 0x1E, 0x1D, 0xD1, 0x62, 0xF3, 0xF1, 0x41,
+    0x21, 0x08, 0x0A, 0x6D, 0x67, 0x48, 0x48, 0x22, 0x3D, 0x56, 0x88, 0x84,
+    0xCF, 0xC0, 0x1F, 0x98, 0xF5, 0x32, 0x92, 0x60, 0x25, 0x28, 0xA6, 0x72,
+    0xFB, 0x02, 0x4D, 0x9A, 0xA4, 0x25, 0xC4, 0x27, 0x6F, 0x83, 0x27, 0x0A,
+    0xBD, 0x17, 0x68, 0xE0, 0x40, 0x18, 0x4E, 0xF0, 0x10, 0x8D, 0xF0, 0x54,
+    0x01, 0x80, 0x3F, 0xDC, 0xD0, 0x30, 0xB0, 0xB0, 0x02, 0xBB, 0x34, 0x48,
+    0x27, 0xE1, 0x0B, 0x92, 0xC5, 0x58, 0x0F, 0x88, 0x20, 0x4C, 0xA8, 0x60,
+    0x6A, 0x05, 0x42, 0xA6, 0xF0, 0x7F, 0x4D, 0xD4, 0x0B, 0xD9, 0xD4, 0x19,
+    0x7F, 0x68, 0x0E, 0xD5, 0x14, 0x7D, 0xD2, 0xC5, 0x00, 0x0E, 0xE5, 0x16,
+    0x6F, 0x47, 0x08, 0x12, 0xB7, 0x86, 0x0C, 0xD5, 0x60, 0x83, 0xB4, 0x88,
+    0xDE, 0xD0, 0x40, 0x02, 0xE0, 0x74, 0xA0, 0x10, 0x04, 0x23, 0xC8, 0x30,
+    0x8D, 0x30, 0x04, 0x95, 0x28, 0x31, 0xE0, 0xE0, 0x38, 0x49, 0xF3, 0x17,
+    0xE3, 0xA4, 0x4B, 0x99, 0x64, 0x81, 0x89, 0x50, 0x45, 0xAE, 0x67, 0x09,
+    0x94, 0xA4, 0x80, 0xA3, 0xD1, 0x4F, 0x78, 0xE8, 0x09, 0x25, 0x20, 0x0C,
+    0xE5, 0xC3, 0x01, 0xE7, 0x13, 0x34, 0xEA, 0x07, 0x8B, 0xCE, 0xF5, 0x26,
+    0x54, 0x74, 0x8A, 0x91, 0x20, 0x76, 0xC0, 0xC6, 0x3E, 0x8B, 0xB6, 0x77,
+    0xC7, 0xB0, 0x56, 0x17, 0x87, 0x3A, 0xBF, 0x78, 0x5E, 0x8D, 0x60, 0x7F,
+    0x9E, 0xE0, 0x71, 0xF3, 0xC7, 0x0D, 0xD0, 0xD1, 0x04, 0x2F, 0x61, 0xFE,
+    0x8C, 0xDC, 0x20, 0x6F, 0x4B, 0xF7, 0x00, 0xC3, 0xD3, 0x08, 0x9F, 0xE2,
+    0x45, 0xC2, 0x76, 0x0C, 0xD7, 0x26, 0x01, 0x12, 0xD7, 0x1F, 0x2D, 0x10,
+    0x66, 0x06, 0xC0, 0x00, 0x2F, 0xA2, 0x8D, 0xAC, 0xC0, 0x7D, 0x9E, 0x50,
+    0x70, 0x08, 0x51, 0x6F, 0xF3, 0xD0, 0x0E, 0x62, 0x87, 0x8B, 0xE5, 0x68,
+    0x0A, 0xE5, 0x63, 0x8A, 0x06, 0x00, 0x0F, 0xAD, 0xC0, 0x01, 0x05, 0x98,
+    0x19, 0x05, 0xC1, 0x0A, 0x6A, 0x97, 0x09, 0xD3, 0x98, 0x08, 0x3E, 0xE8,
+    0x08, 0xB4, 0x17, 0x84, 0x35, 0x43, 0x8F, 0xDC, 0xB0, 0x3B, 0xFD, 0x48,
+    0x0A, 0x4F, 0x10, 0x75, 0xDE, 0x20, 0x6F, 0xF0, 0xE7, 0x10, 0xFF, 0xC8,
+    0x0D, 0x4B, 0xB3, 0x74, 0xDC, 0x30, 0x35, 0x1D, 0x92, 0x7C, 0x4A, 0x04,
+    0x50, 0x59, 0xE4, 0x0B, 0xCD, 0xF7, 0x7C, 0x8B, 0x35, 0x00, 0x19, 0xE0,
+    0x00, 0x9F, 0x33, 0x23, 0x9F, 0x66, 0x53, 0x53, 0x61, 0x00, 0x75, 0xE6,
+    0x6C, 0x99, 0x30, 0x84, 0xD4, 0xA3, 0x62, 0x82, 0xF8, 0x81, 0x27, 0xE6,
+    0x91, 0xA7, 0x50, 0x4D, 0x33, 0x05, 0x70, 0xB6, 0xD8, 0x94, 0xA6, 0x98,
+    0x2E, 0xD7, 0x26, 0x33, 0xCD, 0xA2, 0x5B, 0xE7, 0x57, 0x5C, 0xB8, 0x65,
+    0x5D, 0x6E, 0xD4, 0x0D, 0xBB, 0xD3, 0x6E, 0xA4, 0x50, 0x8C, 0xCB, 0xE8,
+    0x0D, 0x71, 0x64, 0x82, 0xCA, 0x68, 0x44, 0x22, 0x25, 0x6E, 0x3C, 0x41,
+    0x02, 0xC3, 0x33, 0x47, 0x46, 0xE9, 0x20, 0x03, 0xD1, 0x27, 0xFE, 0x25,
+    0x08, 0xA6, 0x17, 0x27, 0xEF, 0x28, 0x2F, 0xC5, 0x35, 0x76, 0xA3, 0xA0,
+    0x87, 0xB7, 0x70, 0x09, 0x5E, 0x21, 0x4A, 0xB0, 0x10, 0x4C, 0x15, 0xF9,
+    0x95, 0x10, 0x31, 0x45, 0xA2, 0x43, 0x85, 0x78, 0x92, 0x8D, 0x8E, 0x20,
+    0x7A, 0x64, 0xD6, 0x91, 0x6F, 0xE8, 0x81, 0x8D, 0xD0, 0x7C, 0xDC, 0x58,
+    0x3B, 0x5A, 0xFE, 0xF2, 0x82, 0x71, 0x29, 0x00, 0x2C, 0xC8, 0x85, 0x99,
+    0xE2, 0x0D, 0xE3, 0xA0, 0x7B, 0xFE, 0x68, 0x97, 0xDF, 0xE0, 0x31, 0x41,
+    0x49, 0x43, 0xF8, 0x43, 0x83, 0x10, 0x84, 0x90, 0xBE, 0x10, 0x4C, 0xB8,
+    0x38, 0x01, 0x34, 0x16, 0x27, 0x2E, 0x19, 0x09, 0x8C, 0x79, 0x95, 0x95,
+    0x81, 0x98, 0x24, 0xC1, 0x92, 0x03, 0x30, 0x8B, 0xB3, 0xB7, 0x6F, 0x97,
+    0x19, 0x0A, 0x5B, 0xC7, 0x84, 0xE8, 0x17, 0x27, 0xA3, 0xD9, 0x0B, 0x06,
+    0x80, 0x96, 0xEA, 0x53, 0x29, 0xFC, 0x81, 0x8E, 0xDD, 0x46, 0x09, 0x7E,
+    0x78, 0x9A, 0x70, 0x49, 0x93, 0xC2, 0x68, 0x0A, 0xEB, 0x24, 0x00, 0x4B,
+    0x35, 0x75, 0x41, 0xE1, 0x93, 0x01, 0x50, 0x9B, 0x19, 0x32, 0x0E, 0x87,
+    0x35, 0x42, 0x6B, 0x79, 0x0C, 0x8F, 0x52, 0x66, 0x84, 0x30, 0x01, 0x14,
+    0xE0, 0x4B, 0x38, 0xC3, 0x96, 0x91, 0xD4, 0x91, 0x9D, 0xA0, 0x7D, 0x2B,
+    0xC1, 0x0F, 0x4C, 0x64, 0x92, 0x74, 0x27, 0x12, 0x6E, 0xE9, 0x9C, 0xFC,
+    0xF6, 0x26, 0xBB, 0x28, 0x76, 0x27, 0x50, 0x01, 0x25, 0x40, 0x63, 0x2F,
+    0x63, 0x02, 0x57, 0x74, 0x02, 0x16, 0xE0, 0x12, 0x72, 0x17, 0x7A, 0x89,
+    0x28, 0x42, 0x21, 0x92, 0x9A, 0xE1, 0x99, 0x8C, 0xA5, 0x60, 0x4B, 0xB3,
+    0xB9, 0x71, 0xE8, 0x59, 0x72, 0xE0, 0xE0, 0x13, 0xB6, 0xF9, 0x0D, 0xC1,
+    0x98, 0x2A, 0x22, 0xE4, 0x15, 0x62, 0x09, 0x0B, 0x68, 0x83, 0x2F, 0x2A,
+    0x16, 0x50, 0x53, 0xE8, 0x50, 0x36, 0x67, 0x91, 0xC0, 0x79, 0x37, 0x28,
+    0x59, 0x09, 0xED, 0x93, 0x99, 0xF1, 0xD9, 0x9D, 0x05, 0xFA, 0x09, 0x76,
+    0x33, 0x99, 0x0B, 0x86, 0x23, 0x8B, 0xA4, 0x16, 0x66, 0x53, 0x77, 0x70,
+    0x52, 0x46, 0x43, 0x18, 0x5D, 0x9F, 0xD4, 0x8B, 0xE3, 0xD3, 0x46, 0x19,
+    0xAA, 0x85, 0x02, 0xB0, 0xA1, 0xFE, 0xA5, 0xA0, 0x40, 0xE5, 0x14, 0x00,
+    0x64, 0x28, 0x00, 0x4C, 0x20, 0x14, 0xB7, 0xB7, 0x29, 0x7D, 0xA9, 0x1D,
+    0xC3, 0xA3, 0x3F, 0xE3, 0x33, 0x39, 0xCC, 0xD4, 0x0B, 0x8F, 0x82, 0x54,
+    0x9A, 0x20, 0x71, 0x9F, 0x97, 0x19, 0x54, 0x28, 0xA3, 0xBD, 0xB4, 0x3D,
+    0xF8, 0x65, 0x15, 0x2B, 0x45, 0x09, 0x2A, 0x4A, 0x9A, 0xEB, 0xF8, 0x8A,
+    0x3C, 0x6A, 0xA0, 0x18, 0x64, 0x80, 0x90, 0x39, 0x08, 0x93, 0xE3, 0x32,
+    0x1A, 0xA0, 0x98, 0x03, 0xE1, 0x02, 0x64, 0x19, 0x49, 0x71, 0x3A, 0x15,
+    0x62, 0x57, 0x2C, 0x10, 0x14, 0x31, 0xBA, 0x03, 0xA5, 0xA7, 0x00, 0x75,
+    0x7C, 0x55, 0x58, 0xE2, 0xF9, 0x12, 0x75, 0xA9, 0x6E, 0x85, 0x45, 0xA2,
+    0xF7, 0x73, 0x2D, 0x22, 0x94, 0x9C, 0x5C, 0xD9, 0x08, 0x41, 0x03, 0x85,
+    0x83, 0x10, 0x6D, 0x1D, 0x98, 0xA6, 0x35, 0x37, 0x81, 0x85, 0xB0, 0x58,
+    0x87, 0xF4, 0x08, 0x1B, 0x74, 0xA8, 0xE5, 0x13, 0x37, 0x81, 0xBA, 0x0C,
+    0x0B, 0x69, 0xA7, 0x9B, 0x00, 0x1A, 0x62, 0x4A, 0x77, 0x03, 0x42, 0x08,
+    0x5E, 0xA1, 0x2C, 0xCA, 0xE0, 0x01, 0xD4, 0xD9, 0x7A, 0x82, 0x7A, 0x02,
+    0xC9, 0xB9, 0x63, 0x4A, 0x1A, 0xA4, 0x10, 0x94, 0x1C, 0x8A, 0x1A, 0xA5,
+    0xA4, 0xF0, 0x6E, 0x7C, 0xD5, 0x64, 0xF7, 0xA8, 0x10, 0x24, 0xD7, 0x18,
+    0x5C, 0xAA, 0x1D, 0xE4, 0xB6, 0x35, 0xE3, 0xE3, 0x3C, 0xB2, 0x0A, 0x09,
+    0xC4, 0x72, 0x5C, 0xFD, 0x09, 0x87, 0xDC, 0xB9, 0x2E, 0x17, 0xD7, 0x55,
+    0xCB, 0x90, 0x01, 0x94, 0x26, 0x8A, 0x18, 0xF9, 0x26, 0x59, 0xB4, 0x01,
+    0xD7, 0x59, 0x3A, 0xAF, 0xCA, 0x09, 0x5E, 0xB1, 0x8B, 0x35, 0x55, 0xA6,
+    0xF0, 0x75, 0x11, 0x8F, 0x90, 0x4D, 0x7F, 0xFA, 0x53, 0x7D, 0x07, 0x00,
+    0x3B, 0x62, 0x96, 0x11, 0x95, 0x92, 0xA3, 0x5A, 0xFE, 0x33, 0x31, 0x11,
+    0x89, 0xBB, 0x53, 0xAC, 0xA3, 0x60, 0x4B, 0x51, 0xE3, 0x31, 0x8E, 0xF8,
+    0x12, 0x1B, 0xE6, 0x85, 0x1A, 0x77, 0x89, 0x8E, 0xE1, 0x38, 0x4D, 0xA3,
+    0x9B, 0x84, 0x8A, 0x3E, 0xFA, 0x69, 0x9C, 0xDB, 0xA3, 0xAB, 0x02, 0x70,
+    0x7D, 0x7E, 0x57, 0x02, 0x03, 0x36, 0x41, 0xD2, 0x97, 0x08, 0x5A, 0xA9,
+    0x4F, 0x34, 0x35, 0x1C, 0x77, 0x87, 0xAE, 0x9C, 0x90, 0x9C, 0xF2, 0xA5,
+    0x33, 0xF5, 0x05, 0x1A, 0xC5, 0x14, 0x1C, 0x9C, 0x86, 0x81, 0xED, 0x70,
+    0x6D, 0x06, 0x26, 0x9A, 0xFC, 0xC4, 0x80, 0x23, 0x24, 0x0D, 0xB8, 0xE3,
+    0xAF, 0xA8, 0xD0, 0x08, 0x3A, 0xF1, 0x25, 0xC3, 0xE8, 0x0C, 0x41, 0xE0,
+    0x04, 0x42, 0xE0, 0xB3, 0x79, 0x49, 0x08, 0x4E, 0xC0, 0x61, 0x3C, 0x01,
+    0x01, 0x7B, 0x49, 0x22, 0xC9, 0x83, 0x44, 0x22, 0x44, 0x63, 0x0B, 0x55,
+    0x67, 0x27, 0x20, 0x01, 0xF6, 0xA9, 0xB2, 0x87, 0x12, 0xB3, 0x9D, 0x50,
+    0x01, 0xF3, 0x14, 0x10, 0x20, 0x71, 0x39, 0x00, 0x20, 0x99, 0x8C, 0xE9,
+    0x27, 0xF2, 0xC8, 0xA3, 0x76, 0x83, 0x94, 0x90, 0xB0, 0x41, 0xB8, 0x28,
+    0x53, 0xF3, 0x85, 0x52, 0x01, 0x2A, 0x13, 0xC1, 0xA4, 0x48, 0xDA, 0x79,
+    0x3E, 0x55, 0x09, 0x42, 0x31, 0x79, 0x2F, 0x98, 0xE2, 0x85, 0x35, 0x7B,
+    0x0A, 0x0A, 0x34, 0x22, 0xE3, 0xA0, 0xAC, 0x82, 0x05, 0x09, 0x3C, 0x29,
+    0x08, 0xC5, 0xE3, 0x78, 0x80, 0x64, 0xB4, 0x24, 0xF2, 0xA8, 0x02, 0x70,
+    0xA2, 0xCC, 0x93, 0x9C, 0xDB, 0xF9, 0x66, 0xE6, 0x92, 0x80, 0x52, 0x6B,
+    0x32, 0x49, 0x97, 0x02, 0xBE, 0x14, 0x15, 0x32, 0x41, 0x5F, 0x00, 0xE0,
+    0xAB, 0x02, 0xD8, 0xA9, 0x21, 0x8B, 0x09, 0xCE, 0xA3, 0xA9, 0x02, 0xB0,
+    0x41, 0x06, 0xE6, 0xAE, 0x03, 0x50, 0x80, 0xEB, 0xD8, 0x92, 0x99, 0xFE,
+    0x51, 0x41, 0x86, 0x99, 0xB9, 0x71, 0xC5, 0x39, 0xC9, 0xC6, 0x0A, 0xF5,
+    0x25, 0x42, 0x3A, 0x00, 0x6F, 0x1A, 0x8A, 0x0A, 0xC5, 0x33, 0x31, 0x57,
+    0x6A, 0x0E, 0x1E, 0x07, 0x0B, 0x8B, 0x27, 0x08, 0x0A, 0x14, 0xB8, 0xDE,
+    0xF0, 0x00, 0x09, 0xAB, 0x1D, 0x71, 0x14, 0xAD, 0xCC, 0xC3, 0x44, 0xBB,
+    0xC8, 0x86, 0xAE, 0x22, 0xAF, 0xBA, 0x92, 0x8A, 0xF8, 0x52, 0xAA, 0xAC,
+    0x77, 0x6D, 0xFF, 0xB9, 0x12, 0x21, 0x00, 0xB7, 0xCE, 0x49, 0x09, 0x61,
+    0x06, 0x49, 0x39, 0x12, 0xAB, 0x90, 0xE0, 0x8A, 0xB7, 0x32, 0x15, 0xCD,
+    0x6B, 0xA6, 0x2D, 0x03, 0x70, 0xC3, 0x51, 0x9C, 0xA8, 0x13, 0x13, 0xED,
+    0x47, 0xB7, 0xA6, 0xD0, 0xA8, 0x78, 0x44, 0x89, 0xD0, 0x40, 0x72, 0xB0,
+    0xE0, 0x74, 0x75, 0xF9, 0x4A, 0xA9, 0x84, 0xB4, 0x84, 0x0B, 0x41, 0x12,
+    0xE7, 0x72, 0x0E, 0x57, 0x28, 0x2B, 0x0B, 0x0B, 0xDB, 0x58, 0x20, 0x68,
+    0xF6, 0xAD, 0xA4, 0x2B, 0x12, 0xEC, 0xA2, 0x84, 0x95, 0xA0, 0xAF, 0x21,
+    0xFB, 0x7F, 0x08, 0x50, 0x11, 0x94, 0x60, 0x57, 0x29, 0x4A, 0x17, 0xC1,
+    0xE0, 0x55, 0xA3, 0xE9, 0x7A, 0xAC, 0x4B, 0x08, 0x19, 0x09, 0x80, 0x64,
+    0x51, 0x73, 0xFB, 0x39, 0x42, 0x3E, 0x10, 0x52, 0xE5, 0x4B, 0x78, 0x50,
+    0x17, 0x9B, 0x00, 0xB0, 0x4E, 0x07, 0x00, 0x1D, 0x40, 0xEB, 0x0C, 0x20,
+    0xD5, 0x0B, 0x3C, 0x49, 0x72, 0x91, 0x98, 0x4A, 0xD0, 0x8A, 0x86, 0xA9,
+    0xE3, 0xAB, 0xF7, 0x6A, 0x00, 0x1A, 0xD0, 0x02, 0x0E, 0xD0, 0x02, 0xF6,
+    0x30, 0x1F, 0xFA, 0xDB, 0x0F, 0x18, 0xAB, 0x00, 0x9D, 0x49, 0x53, 0x6F,
+    0x7A, 0x33, 0x20, 0x8B, 0xB9, 0x79, 0x68, 0x42, 0xC7, 0x40, 0x2C, 0x15,
+    0xB0, 0x8A, 0xE5, 0x81, 0x28, 0x4C, 0xE2, 0x1B, 0xA0, 0xE5, 0x0B, 0x46,
+    0x78, 0x7A, 0xFE, 0xF8, 0xF2, 0x2E, 0xC0, 0xE1, 0x7A, 0xC6, 0xC5, 0x4B,
+    0x31, 0x60, 0x55, 0x3A, 0xA1, 0xC1, 0x9C, 0x10, 0x04, 0xB3, 0x26, 0x00,
+    0xE9, 0x4B, 0x9E, 0xF6, 0x08, 0x0D, 0x2E, 0xD8, 0x0B, 0x73, 0x09, 0x00,
+    0x1B, 0x76, 0x55, 0x4C, 0xE5, 0x57, 0x49, 0x04, 0x41, 0x0A, 0x95, 0x8E,
+    0x2E, 0x95, 0xBC, 0xC7, 0x62, 0xB5, 0x13, 0x2B, 0xB6, 0xB7, 0xF0, 0x8D,
+    0x0A, 0xFA, 0xC3, 0xA1, 0x00, 0x50, 0x4A, 0x0C, 0x09, 0xB2, 0x82, 0x01,
+    0x93, 0x83, 0xB2, 0x02, 0x50, 0xB2, 0x83, 0xA0, 0x62, 0xB1, 0xD1, 0x02,
+    0x98, 0x01, 0x0B, 0x12, 0xF8, 0x09, 0x3B, 0x52, 0x67, 0xD8, 0xE7, 0x8B,
+    0x38, 0x01, 0x01, 0xE3, 0xF0, 0xAF, 0x4F, 0xF7, 0x08, 0x36, 0xD9, 0xC5,
+    0x58, 0x0A, 0x0D, 0x50, 0xE7, 0x0B, 0x62, 0x2C, 0xB4, 0x54, 0x9A, 0x57,
+    0x71, 0xF4, 0xA5, 0xCC, 0xD3, 0x53, 0xE9, 0x68, 0x00, 0x05, 0x95, 0x0B,
+    0x90, 0xBB, 0xB9, 0x95, 0xB6, 0x8E, 0x04, 0x5A, 0xC7, 0x9D, 0x70, 0xC7,
+    0x20, 0x51, 0x5C, 0x12, 0x30, 0x29, 0x98, 0x45, 0x09, 0xB8, 0xA8, 0x86,
+    0x8D, 0x50, 0x1F, 0x84, 0xDC, 0x08, 0xAE, 0x67, 0x99, 0x99, 0xE0, 0xA2,
+    0xA4, 0x15, 0xBD, 0x91, 0xC3, 0x17, 0x4B, 0xA3, 0xB3, 0x42, 0x04, 0x0B,
+    0xC9, 0xD8, 0xC5, 0xE9, 0xFB, 0x0C, 0x24, 0x1C, 0xC6, 0x83, 0x50, 0x3C,
+    0xED, 0x97, 0x5A, 0xBB, 0x13, 0xBC, 0xCC, 0x43, 0x63, 0xE0, 0x37, 0x57,
+    0xD2, 0x89, 0x08, 0x64, 0x55, 0x48, 0x85, 0xA2, 0xC3, 0x9E, 0x49, 0x96,
+    0x10, 0x9C, 0xCA, 0xF8, 0xD2, 0x11, 0x8B, 0xC9, 0x14, 0x2C, 0xF5, 0x08,
+    0xFC, 0xD2, 0x58, 0x42, 0x2A, 0x17, 0x02, 0xA5, 0x08, 0x02, 0xC1, 0xC4,
+    0x8C, 0x36, 0x0A, 0xFC, 0xF1, 0x42, 0xD3, 0x74, 0x13, 0x2F, 0xF0, 0x25,
+    0xAC, 0xC9, 0x7B, 0xB0, 0x60, 0xFE, 0x6E, 0x5D, 0x2C, 0xC2, 0xA8, 0xD0,
+    0xA1, 0x97, 0x3C, 0x08, 0x0A, 0x54, 0x6B, 0x17, 0xE5, 0x57, 0x81, 0x39,
+    0x3E, 0x3C, 0x97, 0xCD, 0xD5, 0x49, 0x9C, 0x66, 0xCA, 0xBF, 0xF7, 0x0A,
+    0x20, 0xD7, 0x89, 0x01, 0x03, 0xDC, 0xCD, 0x83, 0x40, 0x09, 0xE7, 0x73,
+    0x4C, 0x08, 0x01, 0x1F, 0xB3, 0x08, 0x49, 0x8A, 0xF4, 0xB9, 0x8E, 0x60,
+    0x8B, 0x19, 0xE0, 0x50, 0x0E, 0x2D, 0x08, 0xC0, 0x19, 0xBE, 0x22, 0x74,
+    0x13, 0x1F, 0x90, 0x4B, 0xF4, 0xAC, 0x09, 0x5D, 0xEC, 0x08, 0xF7, 0xEC,
+    0x08, 0xD7, 0xB0, 0xBE, 0xBD, 0x10, 0x7C, 0xC5, 0x58, 0xC6, 0xA9, 0x15,
+    0x00, 0x9D, 0x92, 0x9B, 0xCC, 0x13, 0xC0, 0xCF, 0x63, 0x36, 0xD4, 0x4C,
+    0x00, 0x2A, 0x75, 0xB1, 0xCB, 0x90, 0xC3, 0xB9, 0xF2, 0xA0, 0xAC, 0xE0,
+    0xC3, 0x0F, 0x3D, 0x0A, 0xB6, 0xDA, 0x0B, 0xC7, 0x64, 0x09, 0x9F, 0x6B,
+    0x92, 0xD9, 0x64, 0x50, 0x5A, 0x46, 0x50, 0xAE, 0x92, 0xCB, 0x11, 0x57,
+    0x14, 0x04, 0x70, 0xB9, 0xBC, 0xA4, 0x25, 0x7F, 0x83, 0xBE, 0x9F, 0x80,
+    0xD2, 0x83, 0xE6, 0xC1, 0xEC, 0x76, 0x0D, 0x38, 0x79, 0x0C, 0x1C, 0x57,
+    0x55, 0x9A, 0x1C, 0x00, 0x1F, 0x80, 0x3F, 0xBB, 0x8B, 0x34, 0x7E, 0x85,
+    0x72, 0x10, 0xB4, 0x68, 0xD9, 0x3A, 0x1F, 0x3A, 0x7D, 0x5C, 0x55, 0x8B,
+    0x80, 0x70, 0x4C, 0x15, 0x5C, 0x4B, 0xC7, 0x44, 0x4D, 0x0A, 0x61, 0x95,
+    0xC7, 0x91, 0x74, 0x09, 0xAC, 0xD1, 0xC7, 0xFA, 0x96, 0x08, 0x7C, 0xE3,
+    0xD4, 0x3B, 0x0C, 0x27, 0xF3, 0x39, 0x0A, 0x5E, 0xB6, 0xA6, 0xD3, 0x54,
+    0x38, 0x46, 0x44, 0xBB, 0x9E, 0xB0, 0xD5, 0xF0, 0x47, 0x9E, 0x62, 0xEC,
+    0x0C, 0xB6, 0xEB, 0x0B, 0x8B, 0xB7, 0x61, 0xED, 0x27, 0x3C, 0x8E, 0x80,
+    0x02, 0x95, 0x3A, 0x2D, 0xCA, 0xA3, 0x44, 0x6D, 0xFE, 0x2D, 0x9C, 0xA2,
+    0x25, 0xAA, 0xBA, 0x4C, 0xCA, 0xB9, 0x42, 0x88, 0x29, 0x59, 0xD5, 0x78,
+    0xDD, 0x24, 0xF0, 0xB9, 0x80, 0x9A, 0x25, 0x08, 0x93, 0xA2, 0xA2, 0x92,
+    0x55, 0xCE, 0x2B, 0x34, 0xD8, 0x41, 0x13, 0x49, 0x5E, 0xDB, 0x2E, 0xBD,
+    0x5C, 0x3B, 0x3A, 0x70, 0x1D, 0x8C, 0xB1, 0x3B, 0x79, 0x2B, 0x08, 0x5B,
+    0x1D, 0x7C, 0xE4, 0x69, 0xCC, 0xCE, 0xA0, 0xC5, 0xB0, 0xC0, 0x93, 0x50,
+    0xD7, 0x4E, 0xE7, 0x24, 0x31, 0xEA, 0x06, 0x38, 0x8F, 0x2A, 0x48, 0x6C,
+    0x2D, 0x41, 0xE1, 0x38, 0x1A, 0x1F, 0xB4, 0xA6, 0xD7, 0x9C, 0x08, 0x2A,
+    0x80, 0xBF, 0xE6, 0xB1, 0xCD, 0xBA, 0x8D, 0xD7, 0x93, 0x92, 0x45, 0x54,
+    0xA8, 0x42, 0x23, 0x0B, 0x09, 0x03, 0xE3, 0x96, 0xA0, 0x11, 0xDE, 0xCC,
+    0x12, 0x01, 0x29, 0x20, 0x01, 0x21, 0x5D, 0x5B, 0x3A, 0xD0, 0x4A, 0xB8,
+    0xE3, 0x31, 0xF9, 0x9C, 0x09, 0x2D, 0xBD, 0x9A, 0xC1, 0x5D, 0x6E, 0xD7,
+    0x70, 0xDC, 0x90, 0xB0, 0xA1, 0x28, 0x78, 0x31, 0x9A, 0xCD, 0xD9, 0x48,
+    0xB3, 0x3B, 0x9E, 0x38, 0xBF, 0x12, 0x94, 0x01, 0x68, 0xCB, 0x9B, 0xB6,
+    0x28, 0xA3, 0xDD, 0xCA, 0x0A, 0x07, 0x6E, 0xDA, 0x0C, 0xED, 0xD1, 0xAA,
+    0xAD, 0x96, 0x72, 0x22, 0x00, 0x54, 0xC8, 0x45, 0x7A, 0x6D, 0xB6, 0x47,
+    0x95, 0x09, 0xB0, 0xFD, 0x08, 0xC4, 0xE6, 0x91, 0xA8, 0xC9, 0x5A, 0x3E,
+    0x51, 0xDC, 0x9A, 0xB0, 0xCF, 0xC8, 0x88, 0xDF, 0xF7, 0x0D, 0x0D, 0xFB,
+    0xED, 0x08, 0x36, 0x09, 0x00, 0x94, 0xED, 0x08, 0x0B, 0xE0, 0xDC, 0x33,
+    0x94, 0x4B, 0xEE, 0x39, 0x42, 0xFD, 0x66, 0x14, 0x2E, 0xDC, 0x50, 0xCB,
+    0x50, 0x7B, 0x3D, 0xCD, 0x0A, 0x2D, 0x50, 0xD0, 0x1E, 0x2B, 0xD4, 0xDE,
+    0x29, 0xE1, 0xA3, 0x40, 0x63, 0xD9, 0xF3, 0xA6, 0x92, 0x32, 0xBA, 0xFE,
+    0xB0, 0xB0, 0xA3, 0x65, 0x85, 0x6F, 0x1D, 0x4E, 0x1B, 0xE5, 0xD8, 0xA4,
+    0x21, 0x0A, 0x90, 0x8D, 0xDD, 0x09, 0x0A, 0xB4, 0xD2, 0x82, 0x60, 0xC9,
+    0x26, 0x7D, 0x0A, 0x2A, 0xCE, 0xD5, 0x00, 0x80, 0x82, 0x8E, 0x00, 0x01,
+    0x28, 0x9C, 0x57, 0x56, 0x5A, 0xD3, 0x22, 0xB4, 0xCB, 0x4D, 0xE9, 0x22,
+    0xA2, 0xB1, 0x01, 0x32, 0x72, 0x9D, 0xC0, 0x16, 0xC1, 0xF3, 0x94, 0xAB,
+    0xB9, 0x12, 0x81, 0xCB, 0x70, 0xD7, 0x43, 0x9E, 0x0A, 0x12, 0xDC, 0xC6,
+    0xEB, 0x15, 0xD1, 0x29, 0x63, 0x15, 0x7D, 0x6D, 0x14, 0x90, 0xE0, 0xE1,
+    0x7F, 0xC8, 0x3F, 0x7F, 0xCB, 0x0D, 0xE3, 0x80, 0xBB, 0x9B, 0x00, 0xC6,
+    0x3C, 0x49, 0x44, 0x28, 0xFE, 0x0C, 0x96, 0x0C, 0x0B, 0x41, 0xA4, 0x04,
+    0xC8, 0x8C, 0x02, 0xEF, 0x2B, 0xD3, 0xFB, 0x28, 0x47, 0xD2, 0xC8, 0x94,
+    0xD3, 0x77, 0x8B, 0x84, 0xF0, 0xB8, 0x6D, 0x6A, 0xDA, 0x1A, 0x78, 0x01,
+    0xA9, 0x6D, 0xE7, 0xA4, 0x50, 0x25, 0x16, 0x54, 0x12, 0x43, 0xDA, 0x0B,
+    0xB6, 0x8D, 0x52, 0x1F, 0x31, 0x30, 0x65, 0x4A, 0x81, 0x39, 0x74, 0x3C,
+    0x8A, 0x8A, 0x6B, 0x9D, 0xB0, 0x61, 0x8A, 0x27, 0x08, 0xFB, 0xAC, 0xE5,
+    0xA6, 0xD0, 0x7B, 0x90, 0xD0, 0x6E, 0x4A, 0x60, 0xE5, 0xCD, 0x5D, 0xE9,
+    0x58, 0x25, 0x00, 0xD1, 0xDD, 0x45, 0x9D, 0xAE, 0xE9, 0x47, 0x85, 0x49,
+    0xD8, 0x8D, 0x08, 0xDA, 0x9D, 0x2B, 0xB5, 0xB8, 0x0C, 0xD0, 0x3B, 0xEA,
+    0x07, 0x36, 0x6A, 0x53, 0xBB, 0xA7, 0x78, 0xAA, 0xB1, 0x70, 0xE2, 0x48,
+    0x88, 0x82, 0xCA, 0x08, 0x87, 0xC1, 0x56, 0x25, 0xE6, 0x4C, 0x47, 0xE5,
+    0x9D, 0xA0, 0x04, 0x7B, 0xB4, 0xEB, 0x8C, 0xBE, 0xB3, 0xBF, 0xEE, 0x08,
+    0x46, 0x30, 0x04, 0x56, 0xAE, 0x64, 0xC1, 0x2E, 0x68, 0x6B, 0x3D, 0x48,
+    0x05, 0x90, 0xFE, 0x02, 0x18, 0xBB, 0x12, 0x11, 0x9A, 0x09, 0xBE, 0xE4,
+    0xE0, 0x7A, 0x62, 0x9D, 0x3A, 0x1E, 0xE1, 0x43, 0x5E, 0x00, 0xEA, 0xE0,
+    0x6C, 0xF0, 0x51, 0xA7, 0x84, 0xE0, 0x3C, 0x08, 0x7E, 0xCB, 0xD8, 0x9E,
+    0xBF, 0x89, 0x10, 0xD5, 0x66, 0x16, 0xE5, 0xFF, 0x2C, 0x94, 0x8D, 0x70,
+    0xE8, 0x9B, 0x30, 0x04, 0x40, 0xA0, 0xE2, 0xB9, 0xAE, 0xEB, 0xED, 0xD0,
+    0xEE, 0xEE, 0xDE, 0x0D, 0x4D, 0x46, 0xEC, 0x83, 0x34, 0x01, 0x12, 0xD0,
+    0x00, 0xBE, 0xD4, 0x00, 0x14, 0x60, 0x01, 0x28, 0x96, 0xC4, 0x3F, 0x1E,
+    0xD4, 0x91, 0x24, 0xE4, 0xD1, 0xBE, 0x92, 0x5E, 0xC1, 0xCD, 0xBF, 0x25,
+    0xC5, 0x99, 0xE0, 0x3C, 0x0A, 0x9D, 0x0C, 0x9B, 0x81, 0x00, 0xB6, 0xFC,
+    0x08, 0x22, 0x21, 0xEA, 0x32, 0xE6, 0x3B, 0x29, 0x68, 0x2A, 0xF9, 0xBD,
+    0x09, 0x41, 0x80, 0xD2, 0x81, 0x31, 0x03, 0x68, 0x62, 0xF1, 0xE6, 0x6B,
+    0xE5, 0x42, 0x80, 0xCC, 0x19, 0xAF, 0xF1, 0xDD, 0xD0, 0x40, 0x02, 0x6D,
+    0x66, 0x34, 0xB6, 0xDD, 0xA2, 0x55, 0x67, 0x5D, 0xCB, 0xF2, 0xA1, 0xF0,
+    0x6B, 0xA6, 0x79, 0x98, 0x16, 0x0C, 0x00, 0x7B, 0xFE, 0x32, 0x88, 0x32,
+    0xDB, 0x70, 0xC7, 0x3F, 0x68, 0xED, 0x0D, 0x84, 0x41, 0x04, 0x9B, 0xE0,
+    0xE2, 0x2C, 0xF0, 0xBE, 0x8E, 0x43, 0xB0, 0xD7, 0x70, 0x04, 0xB1, 0xB6,
+    0xEB, 0x4C, 0xDF, 0xF4, 0xE1, 0xF0, 0x31, 0x99, 0x26, 0xC1, 0x78, 0x2C,
+    0x37, 0xA0, 0xBE, 0xF3, 0x57, 0xEF, 0xA9, 0xF7, 0xA9, 0x3E, 0xA7, 0xF0,
+    0x26, 0x3F, 0xEE, 0x08, 0x1B, 0xA4, 0xF5, 0x32, 0x16, 0x13, 0x02, 0x40,
+    0xE8, 0x3B, 0xD1, 0x1D, 0x3A, 0x5B, 0x04, 0xB3, 0xD6, 0x17, 0x62, 0xDE,
+    0x64, 0x94, 0x9C, 0x10, 0x8B, 0x2E, 0xF7, 0x73, 0xCF, 0x0D, 0x71, 0x44,
+    0x52, 0x00, 0xB6, 0x75, 0xA1, 0xFE, 0xED, 0xEC, 0xAB, 0xEB, 0xDD, 0x78,
+    0x7D, 0xD3, 0xD4, 0x2E, 0x0A, 0x33, 0xFF, 0x32, 0x41, 0xC3, 0xF5, 0x0C,
+    0xDF, 0x08, 0xB1, 0xDE, 0x18, 0xC1, 0x38, 0x97, 0x47, 0xE0, 0x04, 0x56,
+    0x0E, 0x01, 0x94, 0x3E, 0x5B, 0x8D, 0xA0, 0x10, 0xBB, 0xEE, 0xBB, 0x96,
+    0xCF, 0x0D, 0x84, 0xB1, 0x02, 0x99, 0xAF, 0x5E, 0x92, 0xF9, 0x6F, 0xFB,
+    0x4E, 0x66, 0xFD, 0x1E, 0xED, 0xE5, 0xE3, 0x01, 0x29, 0xDF, 0x2F, 0xA4,
+    0x00, 0x30, 0xA5, 0x9C, 0x14, 0x1B, 0x64, 0xD8, 0x08, 0x17, 0x03, 0xC9,
+    0xC1, 0x5A, 0x8E, 0x31, 0xB8, 0x14, 0xEF, 0x08, 0x22, 0xE0, 0xF0, 0x88,
+    0x66, 0xE2, 0xE7, 0x50, 0x78, 0xE0, 0x84, 0xFB, 0x3B, 0xF1, 0xA8, 0xBB,
+    0x9F, 0x69, 0x24, 0x46, 0xBC, 0x8E, 0x60, 0xFC, 0x9C, 0xB1, 0xF2, 0x23,
+    0x66, 0x01, 0x12, 0x10, 0x02, 0x0D, 0xC0, 0xFE, 0x66, 0x64, 0x01, 0xA7,
+    0xFF, 0xAA, 0x24, 0x26, 0x57, 0x54, 0xA8, 0xC8, 0x1B, 0x31, 0x98, 0xB9,
+    0x22, 0x2B, 0x7B, 0xAF, 0x5E, 0xDA, 0x72, 0xFD, 0x3F, 0xFF, 0x08, 0x07,
+    0x00, 0x08, 0x0B, 0x09, 0x01, 0x84, 0x85, 0x86, 0x85, 0x30, 0x02, 0x02,
+    0x40, 0x00, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x00, 0x42, 0x8A, 0x07,
+    0x83, 0x87, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x99, 0x22, 0x8A, 0x2B, 0x3B,
+    0x93, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xA9, 0x21, 0x03,
+    0xAF, 0x03, 0x0C, 0x8A, 0xB3, 0xB4, 0x20, 0x0E, 0xB0, 0xB0, 0x27, 0x15,
+    0xA7, 0x11, 0x21, 0x18, 0xB8, 0xC0, 0xB8, 0x27, 0x16, 0x05, 0xAC, 0xC6,
+    0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0x91, 0xBF, 0xAF, 0x08, 0x06, 0xB3, 0x20,
+    0x08, 0xB8, 0x04, 0x13, 0xAA, 0x15, 0xB8, 0x1A, 0xB4, 0xDC, 0xDD, 0xDD,
+    0x06, 0xD4, 0xAF, 0x0D, 0xCC, 0xE4, 0xE5, 0xE6, 0xFE, 0xE6, 0x3B, 0x8A,
+    0x23, 0x9E, 0x86, 0x1D, 0xB4, 0x22, 0x24, 0xEC, 0x85, 0x0F, 0x8A, 0x4C,
+    0xE7, 0x41, 0xB3, 0x0B, 0xF2, 0xFB, 0xFC, 0x9E, 0x09, 0x2C, 0xB3, 0x7E,
+    0x9C, 0x1B, 0x48, 0xB0, 0xA0, 0xA3, 0x02, 0x04, 0x60, 0x65, 0xF0, 0x66,
+    0x40, 0x41, 0xB0, 0x0B, 0x25, 0x4C, 0x4D, 0xA0, 0x90, 0x30, 0x98, 0x45,
+    0x60, 0x14, 0x22, 0x18, 0xDC, 0xC8, 0xB1, 0x23, 0xA9, 0x09, 0xB8, 0x5C,
+    0x70, 0x03, 0xE1, 0xA1, 0xDA, 0xB5, 0x54, 0x0D, 0x60, 0x41, 0xF3, 0xC6,
+    0x92, 0xDB, 0x2D, 0x58, 0x27, 0x3D, 0xCA, 0x9C, 0xA9, 0xCA, 0x86, 0x22,
+    0x7D, 0xF2, 0x3E, 0x00, 0x14, 0x00, 0x61, 0x04, 0x26, 0x7E, 0x09, 0x0E,
+    0x28, 0x0A, 0x62, 0xAE, 0xC8, 0xAC, 0x78, 0xFD, 0x92, 0x2A, 0x9D, 0xE7,
+    0x4E, 0xC0, 0x0D, 0x9A, 0x50, 0xA3, 0x02, 0x28, 0x81, 0x4B, 0x01, 0x37,
+    0x06, 0x19, 0x82, 0x85, 0x28, 0x36, 0xA9, 0x40, 0x8A, 0x0B, 0x17, 0xC3,
+    0x5A, 0x6C, 0x10, 0x53, 0xAA, 0xD9, 0xB3, 0xA4, 0x5C, 0xBD, 0x5A, 0xF8,
+    0xAD, 0x24, 0x2C, 0x02, 0x1A, 0x51, 0x45, 0xC0, 0xE5, 0xA1, 0xA5, 0x5D,
+    0x0E, 0xB8, 0x42, 0xA0, 0xDD, 0x2B, 0x33, 0xC6, 0x0A, 0x01, 0x28, 0xF6,
+    0x7D, 0xB0, 0xB4, 0x6E, 0x69, 0x80, 0xC1, 0x02, 0x8A, 0x94, 0x0B, 0xD2,
+    0xE4, 0xA6, 0xE1, 0xC7, 0xFD, 0x12, 0x34, 0x7D, 0xCA, 0xB7, 0x32, 0xB9,
+    0x94, 0xB0, 0x36, 0x28, 0x32, 0xA0, 0x22, 0x18, 0x86, 0xB8, 0x92, 0x0A,
+    0x48, 0xA8, 0x78, 0xD1, 0x41, 0x0B, 0x05, 0x0A, 0x5C, 0xA0, 0x6E, 0xF1,
+    0xD2, 0xE2, 0x56, 0xCB, 0xB0, 0xA1, 0x62, 0x1E, 0x60, 0x82, 0xA5, 0x01,
+    0xB7, 0xB0, 0x2C, 0xB4, 0xC2, 0xC5, 0x21, 0x9A, 0x5D, 0x6E, 0x1A, 0x70,
+    0x61, 0xE0, 0x1A, 0xBB, 0xF8, 0x32, 0x1E, 0x8A, 0x1E, 0xB0, 0x23, 0xFE,
+    0x01, 0x4A, 0xC0, 0x8B, 0x9F, 0x86, 0x21, 0x08, 0x68, 0x52, 0xCE, 0x88,
+    0xA2, 0xC0, 0x90, 0xB3, 0xCB, 0x93, 0xAC, 0x48, 0x86, 0xF1, 0xEF, 0xA8,
+    0x2A, 0x90, 0x76, 0x20, 0xC0, 0x44, 0xB8, 0xB7, 0x12, 0x48, 0x89, 0x26,
+    0x0D, 0xCC, 0x81, 0x09, 0x10, 0xBF, 0x5D, 0x70, 0x38, 0x0F, 0x0B, 0x43,
+    0x59, 0xF0, 0xF8, 0x97, 0x91, 0x96, 0x65, 0xBB, 0x33, 0x2E, 0xDD, 0xA7,
+    0x14, 0xE0, 0xCC, 0x2B, 0x1E, 0x68, 0xF6, 0x9B, 0x22, 0x0E, 0xBD, 0x75,
+    0x5F, 0x7E, 0x0C, 0x4E, 0xD2, 0x83, 0x22, 0x2C, 0x78, 0xF2, 0x40, 0x73,
+    0x07, 0x20, 0x95, 0xDD, 0x08, 0x8A, 0x20, 0xB1, 0x4C, 0x10, 0x4B, 0xCC,
+    0x32, 0x83, 0x76, 0x20, 0x7A, 0xF2, 0x81, 0x50, 0x02, 0xD8, 0xD0, 0xE0,
+    0x89, 0x00, 0x48, 0x80, 0x4B, 0x56, 0xC0, 0x34, 0xB0, 0xCB, 0x24, 0x25,
+    0xB0, 0x07, 0x8B, 0x07, 0x26, 0xF8, 0x76, 0xE0, 0x66, 0x1A, 0xB0, 0xA8,
+    0x20, 0x8A, 0x3C, 0xA6, 0x82, 0xCB, 0x6F, 0x1B, 0x00, 0x83, 0x41, 0x2A,
+    0x13, 0xB0, 0x87, 0x40, 0x6D, 0x76, 0x6D, 0xE0, 0x1F, 0x2C, 0x11, 0xF5,
+    0xE8, 0xA4, 0x5F, 0x02, 0x5C, 0xC2, 0xC9, 0x03, 0x3B, 0x75, 0xF0, 0x80,
+    0x85, 0xDA, 0xB9, 0x43, 0x04, 0x51, 0xC8, 0x28, 0xD1, 0xD8, 0x2C, 0xD0,
+    0x85, 0x28, 0xA6, 0x21, 0xF4, 0x08, 0x80, 0x43, 0x0C, 0x4E, 0xE2, 0x37,
+    0x20, 0x30, 0x04, 0x34, 0x19, 0xDA, 0x09, 0x16, 0x71, 0x00, 0xDF, 0x8D,
+    0x2C, 0x29, 0x40, 0x9F, 0x35, 0x69, 0xE6, 0x09, 0x09, 0x2E, 0x73, 0xB2,
+    0x84, 0xDB, 0x00, 0xC3, 0xA9, 0x52, 0x24, 0x30, 0x19, 0x68, 0x60, 0xE3,
+    0x2C, 0x1B, 0xD8, 0x09, 0x0C, 0x80, 0x7A, 0x9E, 0x88, 0x9C, 0x00, 0x30,
+    0x6C, 0xF2, 0x40, 0x53, 0x02, 0x88, 0x10, 0xA6, 0x76, 0x24, 0x28, 0x62,
+    0x04, 0x32, 0xFE, 0x40, 0x70, 0x83, 0xDD, 0x98, 0xA0, 0x1A, 0xF2, 0x82,
+    0x22, 0x3C, 0x34, 0x5A, 0xDC, 0x5C, 0x5A, 0x11, 0x17, 0xC9, 0x04, 0x60,
+    0x01, 0xC3, 0x81, 0x81, 0x74, 0xB6, 0xB4, 0xC1, 0x9F, 0x78, 0x9A, 0x9A,
+    0xE6, 0x6C, 0xDB, 0xD4, 0x29, 0x9C, 0xAA, 0xA8, 0x08, 0x68, 0x91, 0x69,
+    0xA8, 0xA9, 0xF0, 0xE7, 0x2B, 0x04, 0x30, 0x6A, 0x2B, 0x7E, 0x0F, 0x0A,
+    0x10, 0xA1, 0x26, 0x0B, 0xCC, 0x72, 0xC0, 0x87, 0xA1, 0x06, 0x00, 0x83,
+    0x50, 0x4E, 0xB0, 0x72, 0x44, 0x25, 0x80, 0x91, 0x08, 0x41, 0xB4, 0xDC,
+    0x26, 0x80, 0x82, 0x22, 0x02, 0x1D, 0x5B, 0x99, 0x5A, 0xAF, 0x7C, 0x56,
+    0xCA, 0xA0, 0xB8, 0xA8, 0x00, 0x6B, 0xAC, 0xBF, 0xE1, 0x05, 0xCB, 0x05,
+    0xBC, 0x8A, 0x9B, 0x1F, 0x05, 0x0A, 0xB5, 0x74, 0x5E, 0xA0, 0xC7, 0xA8,
+    0x28, 0xD6, 0x43, 0x0B, 0xCA, 0x0B, 0x1B, 0x94, 0x52, 0x1E, 0x42, 0x82,
+    0x74, 0x8A, 0x40, 0x80, 0x65, 0xA8, 0x18, 0x0A, 0xB0, 0x29, 0x2A, 0x41,
+    0x74, 0x0A, 0x61, 0x02, 0x65, 0x6E, 0xCB, 0x6D, 0xB4, 0x09, 0x0B, 0xD0,
+    0x83, 0xBF, 0x68, 0x21, 0x34, 0x00, 0x01, 0xE9, 0x9D, 0x6B, 0xA4, 0x48,
+    0xEC, 0xC6, 0xEA, 0xEE, 0x2B, 0x27, 0x60, 0x9C, 0x5F, 0x01, 0x15, 0xA0,
+    0xFA, 0x0A, 0x92, 0x57, 0xE1, 0xD2, 0xAF, 0xA0, 0xB3, 0x89, 0xC5, 0x71,
+    0xBC, 0x26, 0x57, 0x46, 0x83, 0x22, 0x91, 0x1E, 0xB2, 0x00, 0x89, 0x28,
+    0x14, 0x36, 0x31, 0x21, 0xCD, 0x2A, 0x6C, 0xCA, 0x11, 0x40, 0x10, 0x61,
+    0x09, 0x4E, 0x11, 0xFF, 0x1C, 0xED, 0xB7, 0x4E, 0xD5, 0x6C, 0x56, 0x09,
+    0x2E, 0x9A, 0xA2, 0xF1, 0x8C, 0x87, 0x86, 0x7C, 0xE3, 0x9F, 0xA0, 0x39,
+    0x0D, 0x1B, 0xBD, 0x27, 0x90, 0x86, 0xC0, 0xBA, 0x8A, 0x04, 0x57, 0x2E,
+    0x39, 0x13, 0xB5, 0xEA, 0x59, 0xFE, 0x0A, 0x34, 0x6B, 0x8D, 0xD6, 0x0D,
+    0x8E, 0x91, 0xC9, 0xF4, 0x01, 0x3E, 0x2B, 0x1D, 0x00, 0x09, 0x24, 0x36,
+    0x51, 0x04, 0x97, 0x8E, 0x04, 0xF1, 0x44, 0x87, 0x47, 0xFF, 0x94, 0xB4,
+    0xDC, 0x63, 0x96, 0x29, 0x00, 0x9A, 0x6A, 0x17, 0xB7, 0x66, 0x6F, 0x56,
+    0x87, 0x0C, 0xCE, 0xBB, 0x85, 0x5B, 0x36, 0x35, 0x30, 0x1E, 0x54, 0x9D,
+    0xE0, 0x00, 0xE3, 0x98, 0x93, 0xB2, 0x04, 0x98, 0xA7, 0x10, 0x41, 0xDA,
+    0x8D, 0x9B, 0x95, 0x8E, 0xB2, 0x3A, 0xCF, 0xC2, 0xC2, 0xA5, 0x4A, 0x27,
+    0x40, 0xF0, 0x6F, 0x07, 0x08, 0x92, 0x89, 0x74, 0x12, 0x03, 0x2E, 0x26,
+    0xC1, 0xDE, 0x75, 0x5E, 0x99, 0xBE, 0x04, 0x26, 0x9E, 0xB8, 0x0B, 0xB8,
+    0x74, 0x2C, 0xBB, 0x59, 0x16, 0x84, 0xA5, 0x42, 0xCB, 0xC4, 0xEE, 0xDE,
+    0x79, 0xB2, 0x01, 0x07, 0x60, 0xBA, 0x25, 0xD0, 0xBA, 0x2E, 0xF0, 0x02,
+    0x4C, 0xD3, 0xD2, 0x01, 0x04, 0x0B, 0xF8, 0xB4, 0xC9, 0x0C, 0x8A, 0x90,
+    0xAE, 0xFC, 0x52, 0x65, 0xE2, 0x20, 0x3C, 0x5A, 0x20, 0x51, 0x6D, 0x7B,
+    0xE2, 0xAD, 0x11, 0xC0, 0xF9, 0xF6, 0x06, 0xAD, 0x19, 0x0C, 0x07, 0xB4,
+    0x04, 0x09, 0x8B, 0xEE, 0xE4, 0x63, 0x6C, 0xC3, 0x5F, 0x90, 0x16, 0x32,
+    0x83, 0xB6, 0x07, 0x5F, 0x6F, 0xC8, 0x07, 0x0B, 0x2C, 0x00, 0xC3, 0x07,
+    0x82, 0xA9, 0x63, 0x3F, 0x88, 0x4D, 0xB9, 0x58, 0xFB, 0x64, 0xC3, 0xA7,
+    0xEF, 0x25, 0x0E, 0x04, 0xB8, 0x48, 0xC1, 0x00, 0x65, 0xD2, 0xBD, 0xB0,
+    0x90, 0x87, 0x16, 0x4B, 0x1A, 0x80, 0xB1, 0x16, 0x68, 0xAA, 0x18, 0xE0,
+    0xC0, 0x7F, 0x01, 0x98, 0x14, 0xF2, 0xFE, 0x07, 0x2A, 0x12, 0xB1, 0x20,
+    0x67, 0x1C, 0x5C, 0x4A, 0xC2, 0x4A, 0x45, 0x41, 0x8F, 0xA8, 0x6C, 0x00,
+    0x56, 0x31, 0x60, 0xE2, 0x46, 0x76, 0x81, 0x12, 0xFE, 0x72, 0x84, 0x5E,
+    0x6B, 0xD9, 0x40, 0x0B, 0xE8, 0x03, 0x36, 0x04, 0x26, 0xD0, 0x85, 0xA6,
+    0xCA, 0x01, 0x06, 0x2B, 0xD6, 0x81, 0xFA, 0x85, 0x10, 0x32, 0x23, 0x9A,
+    0x05, 0x0A, 0x16, 0xC0, 0xBF, 0x1F, 0xF6, 0x43, 0x28, 0x39, 0xC0, 0x21,
+    0x47, 0x66, 0xC3, 0x16, 0xAB, 0x81, 0xC0, 0x04, 0xC2, 0xA2, 0x0B, 0x07,
+    0x40, 0x96, 0x24, 0x5C, 0xB8, 0x49, 0x89, 0xE5, 0x78, 0x1C, 0xCB, 0x34,
+    0x70, 0x8B, 0x14, 0x02, 0xA7, 0x45, 0x2F, 0xC2, 0x22, 0x8A, 0xD8, 0x26,
+    0x00, 0x68, 0x8D, 0xAA, 0x6D, 0x46, 0x14, 0x53, 0xC5, 0x68, 0x01, 0x81,
+    0x36, 0xB6, 0x31, 0x7F, 0x33, 0x78, 0xC0, 0x03, 0x8A, 0x08, 0xB8, 0x04,
+    0xCC, 0xE0, 0x05, 0x42, 0x19, 0x22, 0x1D, 0xCF, 0xA8, 0x03, 0x31, 0x0E,
+    0xA4, 0x81, 0x03, 0xC8, 0x55, 0xAC, 0x64, 0xA8, 0xA3, 0x8B, 0x64, 0x80,
+    0x8A, 0x2C, 0x69, 0x4D, 0xC9, 0xFC, 0x48, 0x8E, 0xDE, 0xC1, 0xA2, 0x6A,
+    0x60, 0xA3, 0xC5, 0xC8, 0x88, 0xA5, 0x40, 0x46, 0xE6, 0x87, 0x8C, 0x22,
+    0x30, 0x5E, 0x95, 0xE8, 0x98, 0x46, 0x31, 0x4D, 0xEB, 0x7B, 0x10, 0x10,
+    0xC1, 0x0C, 0xAC, 0xF7, 0x98, 0x11, 0x90, 0x88, 0x16, 0x07, 0x28, 0x62,
+    0xA6, 0x04, 0x10, 0x2E, 0x4B, 0x32, 0x83, 0x5C, 0x4D, 0xBC, 0x11, 0x03,
+    0x5A, 0xB3, 0xAF, 0x57, 0xA0, 0xAF, 0x25, 0x62, 0x7B, 0x45, 0x18, 0x5D,
+    0x79, 0x8C, 0x01, 0xDD, 0x32, 0x56, 0x26, 0x78, 0xC8, 0x04, 0x79, 0xC9,
+    0x17, 0x32, 0x76, 0x20, 0x83, 0xDF, 0x7A, 0x56, 0x27, 0xB9, 0xF5, 0x81,
+    0xD3, 0x7D, 0x4F, 0x04, 0x20, 0x04, 0xD1, 0xB7, 0x5E, 0xA0, 0x93, 0x59,
+    0x1C, 0x93, 0x10, 0x00, 0xD1, 0x1E, 0x31, 0x95, 0x61, 0x36, 0x96, 0xFD,
+    0x66, 0x96, 0xB5, 0x8C, 0x93, 0x5D, 0xCE, 0x53, 0xC9, 0x6D, 0xAE, 0xFE,
+    0x22, 0x1B, 0xB0, 0xE0, 0x0F, 0xBB, 0xB0, 0x22, 0x4C, 0x73, 0xEE, 0xE5,
+    0x07, 0x96, 0xB0, 0xA3, 0x22, 0x3A, 0x40, 0xCA, 0x65, 0x82, 0xE8, 0x1F,
+    0x2A, 0x04, 0x4C, 0xF2, 0xB2, 0xF3, 0x01, 0x10, 0x36, 0x6F, 0x1E, 0x8A,
+    0x30, 0x91, 0x3B, 0x59, 0x81, 0xCE, 0x57, 0x44, 0xD2, 0x1B, 0x2D, 0xB8,
+    0x08, 0x06, 0x42, 0x50, 0x82, 0x93, 0x4C, 0xC0, 0x02, 0x31, 0xA3, 0x4D,
+    0x4B, 0x12, 0x3A, 0xB6, 0x81, 0xEE, 0x66, 0x2D, 0xB6, 0x33, 0x00, 0x45,
+    0x81, 0x71, 0x01, 0xB4, 0x59, 0x94, 0x26, 0x9F, 0x83, 0x54, 0x73, 0x2C,
+    0x65, 0x4F, 0xC0, 0xC9, 0xF1, 0xA4, 0x28, 0x7D, 0xC0, 0x08, 0xF2, 0xC7,
+    0xD2, 0xFC, 0x35, 0xCF, 0x9A, 0xCA, 0x19, 0x53, 0x10, 0x05, 0x60, 0x88,
+    0x6F, 0x51, 0xE6, 0xA3, 0xA8, 0x70, 0xE4, 0x00, 0xEA, 0xF2, 0x9B, 0xDB,
+    0x3C, 0x44, 0x02, 0xBB, 0x84, 0x44, 0x8C, 0x54, 0x52, 0x35, 0x69, 0xE0,
+    0x62, 0x7C, 0x38, 0x05, 0x00, 0x69, 0xBC, 0x98, 0x38, 0x70, 0x06, 0x83,
+    0x00, 0x14, 0x78, 0x59, 0x52, 0xC9, 0x61, 0x93, 0xEB, 0x10, 0xEC, 0x05,
+    0x25, 0xCD, 0x6A, 0x21, 0x10, 0x23, 0x00, 0x12, 0xEC, 0x2C, 0x1F, 0xA0,
+    0x6A, 0x8E, 0x21, 0xA8, 0xB7, 0x82, 0xA9, 0x9E, 0x82, 0x76, 0xBF, 0xB4,
+    0xCD, 0xB0, 0x2E, 0x30, 0x4C, 0x49, 0x9C, 0x90, 0xA9, 0xDC, 0x38, 0xCF,
+    0x15, 0xCD, 0xEA, 0x08, 0x9D, 0x0E, 0xE0, 0xA0, 0x21, 0x73, 0xAA, 0x67,
+    0x88, 0x41, 0xD7, 0x72, 0xE8, 0x00, 0x7E, 0xB4, 0x88, 0x9B, 0x56, 0x97,
+    0xE9, 0xAD, 0xEB, 0x10, 0xE2, 0x03, 0xCD, 0xBB, 0x66, 0x88, 0x82, 0x66,
+    0x88, 0xA0, 0x08, 0x60, 0x14, 0x7D, 0x95, 0x04, 0x0C, 0x51, 0xD8, 0xAE,
+    0x6A, 0x94, 0x13, 0x15, 0x93, 0x8D, 0x25, 0x37, 0x46, 0xA6, 0x97, 0xC8,
+    0x3A, 0x62, 0xFE, 0x36, 0xBF, 0xCB, 0xA7, 0x22, 0xF4, 0xCA, 0xA6, 0xA8,
+    0x7A, 0x16, 0x19, 0x31, 0xD0, 0x21, 0x2A, 0x39, 0x39, 0xD8, 0x65, 0xEE,
+    0xA4, 0x8C, 0x85, 0x38, 0x9E, 0x22, 0x32, 0x09, 0xA2, 0x20, 0x1E, 0xE0,
+    0x10, 0xA0, 0xD0, 0xE6, 0x69, 0x3F, 0x0B, 0x0B, 0x41, 0x7A, 0x03, 0x77,
+    0x3B, 0x3A, 0x27, 0x2E, 0xF0, 0x1A, 0x4C, 0x71, 0xEC, 0xB6, 0xA0, 0x03,
+    0x40, 0xA4, 0x68, 0x37, 0x30, 0x9F, 0x8B, 0x74, 0x14, 0xA9, 0xBB, 0x75,
+    0x44, 0x6A, 0xB9, 0xF1, 0x9C, 0xD6, 0x66, 0x35, 0x68, 0x02, 0x50, 0x6C,
+    0x21, 0xB0, 0xBB, 0x4F, 0xA5, 0x40, 0x0C, 0xBB, 0x38, 0x29, 0xC4, 0x2A,
+    0x21, 0x1B, 0xDD, 0xD9, 0xA8, 0xD3, 0x1B, 0x3A, 0xAA, 0x15, 0x2B, 0xCC,
+    0x76, 0xDE, 0x5A, 0xE0, 0x62, 0xB7, 0xB0, 0x14, 0x2D, 0x43, 0x4C, 0x50,
+    0x48, 0x8C, 0x64, 0x2D, 0xBA, 0x91, 0x98, 0xAE, 0x35, 0x59, 0x6B, 0xDD,
+    0x34, 0x0A, 0x0E, 0x02, 0xA4, 0xDB, 0x49, 0xF1, 0x94, 0xD2, 0x9C, 0x79,
+    0x5E, 0x0A, 0x20, 0x2B, 0x20, 0xDC, 0x6E, 0x67, 0xA3, 0x5C, 0xF7, 0x32,
+    0x09, 0x19, 0xB3, 0xF1, 0x26, 0x37, 0x70, 0x11, 0x54, 0xB3, 0xB2, 0x27,
+    0x03, 0x35, 0x92, 0x6F, 0x37, 0x18, 0x30, 0x49, 0x8E, 0x7A, 0x14, 0xBF,
+    0x8F, 0xD0, 0xEF, 0xC3, 0xFA, 0x5B, 0x52, 0xC7, 0x3A, 0x87, 0x13, 0x26,
+    0xC6, 0xAA, 0x61, 0x3E, 0xD0, 0x14, 0xD5, 0x65, 0xA2, 0x4C, 0x24, 0xDC,
+    0x2D, 0x9C, 0x5E, 0x01, 0x57, 0x5A, 0x4C, 0xAE, 0x85, 0x10, 0xEE, 0x6D,
+    0x4B, 0x74, 0x74, 0xDF, 0xA9, 0xDA, 0x35, 0x5D, 0x0D, 0x96, 0xAF, 0x01,
+    0x4C, 0x30, 0x2C, 0x5C, 0x64, 0x04, 0xC4, 0x8D, 0x20, 0xA3, 0x22, 0x54,
+    0x4C, 0x62, 0x7B, 0x4A, 0x07, 0x6E, 0xFE, 0x68, 0x4A, 0x77, 0x23, 0xC3,
+    0x02, 0x1F, 0x16, 0x82, 0x60, 0xFE, 0x37, 0x7D, 0x9F, 0x00, 0x68, 0x20,
+    0x50, 0x9C, 0xD2, 0xAE, 0xC6, 0xB3, 0x58, 0x12, 0xFB, 0x56, 0xF1, 0xB8,
+    0xF6, 0xD2, 0xA2, 0x35, 0x3D, 0x4E, 0x6A, 0x05, 0x28, 0x62, 0x48, 0x05,
+    0xE0, 0x35, 0x9F, 0x20, 0x68, 0xAE, 0x45, 0x2E, 0x90, 0x66, 0xBA, 0x2A,
+    0xF9, 0x00, 0xD1, 0x6C, 0x32, 0x0C, 0x00, 0xF2, 0x82, 0x3C, 0x03, 0x6E,
+    0x54, 0x28, 0xE0, 0xAF, 0x26, 0x4C, 0x1C, 0x53, 0x8A, 0xCD, 0x62, 0x14,
+    0x3A, 0x50, 0x2D, 0xB8, 0x14, 0x3C, 0xD0, 0x14, 0xC0, 0xE2, 0x81, 0xDE,
+    0x40, 0x33, 0x32, 0x68, 0x37, 0x80, 0xA2, 0xCE, 0x42, 0xD2, 0xA7, 0x2D,
+    0x80, 0x05, 0xCC, 0x07, 0x64, 0x0D, 0x73, 0xC3, 0x00, 0x1A, 0x28, 0xB2,
+    0x04, 0xA3, 0xAB, 0xE4, 0xD1, 0x35, 0x79, 0xAC, 0xD4, 0xAD, 0x27, 0xA8,
+    0x12, 0x91, 0x4A, 0x7E, 0x04, 0x91, 0xC9, 0xD1, 0x3A, 0x1D, 0x0F, 0x6E,
+    0x26, 0x00, 0x2C, 0x60, 0x41, 0x11, 0x34, 0xC0, 0xA9, 0xCA, 0x10, 0xD0,
+    0x92, 0xD6, 0xB4, 0xF5, 0x14, 0x76, 0x4D, 0x6B, 0x37, 0x30, 0x1D, 0xDD,
+    0x89, 0xC8, 0x48, 0x21, 0x6E, 0xF6, 0x74, 0x2D, 0xE4, 0xBC, 0x31, 0x52,
+    0x83, 0xF5, 0xD4, 0x86, 0x38, 0xE5, 0x7E, 0x01, 0x47, 0x37, 0x01, 0x14,
+    0x5A, 0x30, 0x07, 0xB8, 0xED, 0xC4, 0xAA, 0xCD, 0x8D, 0x28, 0x44, 0xA1,
+    0x0A, 0x8A, 0x10, 0xE0, 0x40, 0x0B, 0x30, 0x5C, 0x96, 0x8C, 0x8C, 0x02,
+    0xAC, 0x28, 0x00, 0xB9, 0x0C, 0x6A, 0x17, 0x62, 0x83, 0x18, 0xA2, 0xBE,
+    0x0B, 0xB2, 0x68, 0x75, 0xD4, 0x59, 0xCF, 0x2A, 0x59, 0xB0, 0xA7, 0x4E,
+    0x44, 0xA5, 0x66, 0x50, 0x60, 0x01, 0xE0, 0x1B, 0x54, 0xDC, 0x69, 0x5D,
+    0x3F, 0x48, 0xB0, 0xAC, 0x89, 0xAD, 0x51, 0x11, 0x49, 0x48, 0xC2, 0x15,
+    0xA6, 0x20, 0x80, 0x15, 0xF4, 0xD1, 0xA2, 0x03, 0xFE, 0xF2, 0x2D, 0x2D,
+    0x72, 0x29, 0x3E, 0x6C, 0x98, 0xED, 0x15, 0x12, 0xEF, 0x06, 0x8F, 0x91,
+    0xFC, 0x88, 0x0A, 0x84, 0xE0, 0xD8, 0x6B, 0x49, 0xB6, 0x86, 0x81, 0xAB,
+    0xCB, 0xD3, 0xFA, 0xC0, 0x12, 0x82, 0x6E, 0xF2, 0x19, 0x7F, 0x72, 0x46,
+    0x81, 0x47, 0xAB, 0x39, 0x29, 0x5F, 0x26, 0x76, 0x11, 0x9E, 0x70, 0x28,
+    0x04, 0xF4, 0xA3, 0xE4, 0x0A, 0xED, 0x37, 0xF2, 0xB2, 0x8A, 0x98, 0x09,
+    0x7B, 0xE7, 0xB0, 0x80, 0xEE, 0x69, 0xE1, 0x7D, 0x11, 0x15, 0xC8, 0xDB,
+    0x6A, 0x4B, 0xAA, 0x5C, 0x64, 0x3F, 0xD7, 0x43, 0x68, 0x67, 0xE2, 0x5B,
+    0xB4, 0xBD, 0x32, 0x4F, 0x7E, 0x36, 0x2A, 0x28, 0x93, 0xB8, 0xDF, 0x56,
+    0xA8, 0x79, 0x77, 0x3E, 0x4A, 0x15, 0x58, 0xB4, 0x64, 0x92, 0xBF, 0x76,
+    0x2B, 0x2E, 0x5A, 0xF0, 0x9B, 0x5C, 0xE2, 0x98, 0xE3, 0x92, 0xF0, 0x38,
+    0xC8, 0x07, 0x90, 0x01, 0x91, 0xDB, 0x4E, 0x7D, 0xAF, 0x08, 0xBB, 0x45,
+    0x99, 0xAE, 0x6A, 0xEB, 0x0E, 0xA6, 0x42, 0xF7, 0x13, 0x4A, 0x78, 0x11,
+    0x96, 0x1C, 0x68, 0x9F, 0x51, 0x11, 0x54, 0x48, 0x82, 0xCD, 0x05, 0x10,
+    0xBB, 0x71, 0x87, 0x84, 0x25, 0x1B, 0xA0, 0xCF, 0x09, 0xA4, 0x0A, 0x89,
+    0xC9, 0xDE, 0xD5, 0x2E, 0x4B, 0x42, 0x37, 0xDA, 0x4B, 0x41, 0x74, 0x8B,
+    0x18, 0xDD, 0x76, 0xC5, 0x6D, 0xF6, 0xD2, 0xE3, 0xE9, 0xF4, 0x4C, 0x8C,
+    0x2A, 0xEA, 0xC6, 0x6B, 0x8A, 0x95, 0xB5, 0x83, 0x98, 0xBD, 0x37, 0xD9,
+    0x94, 0x8A, 0x90, 0x42, 0x12, 0xC0, 0x4D, 0x78, 0x9C, 0xCE, 0x78, 0x00,
+    0x3A, 0xEF, 0x46, 0x2E, 0xDF, 0xD5, 0x80, 0xDA, 0x37, 0xE0, 0x02, 0x15,
+    0x06, 0x80, 0x78, 0x60, 0x11, 0x7B, 0x6E, 0xC0, 0x7D, 0xD4, 0x93, 0x37,
+    0x85, 0xDA, 0xDB, 0xFC, 0x66, 0x96, 0xD0, 0x7B, 0xF3, 0x51, 0x8A, 0xFE,
+    0xF9, 0xA9, 0xBF, 0x15, 0xCD, 0x91, 0x32, 0x53, 0x28, 0xF4, 0xEC, 0xFC,
+    0x61, 0xA4, 0xAD, 0x88, 0x1A, 0xE0, 0xD4, 0xAE, 0x96, 0x0E, 0xDB, 0xBE,
+    0x7E, 0x4D, 0x69, 0x33, 0x23, 0xE8, 0x2D, 0x42, 0x0F, 0x3E, 0x00, 0x2A,
+    0x1F, 0x8C, 0xCB, 0xCB, 0xD2, 0x65, 0x7D, 0xAD, 0xC1, 0x5F, 0xF0, 0x2C,
+    0xFD, 0x4C, 0xF4, 0x9D, 0x10, 0x09, 0x43, 0x41, 0xDD, 0x97, 0xC2, 0x9D,
+    0xE8, 0xB7, 0x7F, 0xE6, 0x5B, 0x9E, 0x2A, 0x69, 0x24, 0xCC, 0x0D, 0x17,
+    0xD0, 0x07, 0x23, 0x5D, 0x61, 0x36, 0x3C, 0xE5, 0x7B, 0x3C, 0x27, 0x7E,
+    0xD8, 0xF0, 0x71, 0x17, 0x81, 0x00, 0x2D, 0x50, 0x7C, 0x02, 0x30, 0x32,
+    0x43, 0x42, 0x57, 0x35, 0x80, 0x72, 0xED, 0x97, 0x09, 0x2C, 0xC0, 0x64,
+    0x0F, 0x40, 0x22, 0x7E, 0x76, 0x4F, 0xEE, 0x60, 0x7F, 0xED, 0x67, 0x62,
+    0xE1, 0x36, 0x55, 0x99, 0xD5, 0x53, 0x44, 0x36, 0x67, 0xA4, 0x60, 0x57,
+    0x19, 0x17, 0x3E, 0xB9, 0x67, 0x80, 0xA6, 0x40, 0x7E, 0xED, 0x91, 0x71,
+    0x9B, 0xF1, 0x1F, 0x74, 0xA5, 0x5F, 0xD7, 0x36, 0x81, 0xCC, 0x02, 0x21,
+    0xD1, 0xC2, 0x1D, 0xAD, 0x46, 0x83, 0x01, 0x80, 0x5D, 0x65, 0x35, 0x55,
+    0x80, 0xE4, 0x82, 0xDF, 0xC0, 0x00, 0x0C, 0x30, 0x39, 0x03, 0x90, 0x82,
+    0x00, 0x30, 0x1B, 0x2B, 0x31, 0x0B, 0x44, 0x38, 0x66, 0x2A, 0x78, 0x80,
+    0x6B, 0xA7, 0x80, 0x60, 0x93, 0x79, 0x15, 0x67, 0x56, 0x64, 0xF4, 0x6F,
+    0x9B, 0x00, 0x31, 0x33, 0xB0, 0x00, 0x71, 0x24, 0x47, 0xAD, 0xD5, 0x2C,
+    0x23, 0x30, 0x7A, 0x90, 0x01, 0x0A, 0x39, 0xA8, 0x83, 0xAB, 0xD4, 0x34,
+    0x66, 0xC5, 0x44, 0x21, 0xA3, 0x23, 0x61, 0xF7, 0x56, 0xB3, 0x30, 0x7B,
+    0xF0, 0xD2, 0x84, 0xCA, 0x60, 0x01, 0xAF, 0x17, 0x0C, 0x0E, 0x20, 0x48,
+    0x3A, 0x22, 0xFE, 0x79, 0x53, 0x75, 0x72, 0x95, 0xC2, 0x0F, 0xD4, 0xE3,
+    0x0D, 0x53, 0xA6, 0x83, 0xFB, 0x20, 0x86, 0xCA, 0xE7, 0x74, 0x24, 0x92,
+    0x6B, 0x66, 0x75, 0x42, 0xFC, 0x77, 0x17, 0xB0, 0x80, 0x87, 0x92, 0x55,
+    0x6E, 0xD3, 0x80, 0x0B, 0x75, 0xB6, 0x4D, 0x11, 0x60, 0x01, 0x12, 0x50,
+    0x7B, 0xBF, 0x20, 0x13, 0x15, 0x20, 0x01, 0x17, 0x87, 0x0B, 0x0A, 0x38,
+    0x7B, 0x8C, 0x47, 0x4C, 0xEA, 0x37, 0x75, 0xFC, 0xF0, 0x52, 0xDC, 0x00,
+    0x60, 0x80, 0xD8, 0x0F, 0x67, 0x94, 0x81, 0x13, 0x58, 0x60, 0xD6, 0x77,
+    0x86, 0x2A, 0xC1, 0x80, 0x13, 0x57, 0x1F, 0xA5, 0xB0, 0x7B, 0xAF, 0xA0,
+    0x02, 0x1A, 0x40, 0x1F, 0x97, 0x65, 0x4E, 0x13, 0x50, 0x89, 0x17, 0x21,
+    0x76, 0x17, 0xD0, 0x00, 0x21, 0xA0, 0x39, 0xE1, 0x67, 0x0A, 0x25, 0x30,
+    0x87, 0x0A, 0x65, 0x56, 0x00, 0x33, 0x7F, 0xF0, 0x37, 0x4F, 0x64, 0x42,
+    0x30, 0x28, 0xA0, 0x8A, 0xA7, 0x78, 0x08, 0x09, 0x03, 0x7A, 0xA7, 0x58,
+    0x86, 0x85, 0x97, 0x54, 0x27, 0x04, 0x69, 0x07, 0xF2, 0x7B, 0xE3, 0x43,
+    0x69, 0x00, 0xE8, 0x4E, 0x5E, 0xB1, 0x89, 0xC1, 0x20, 0x09, 0xDE, 0x08,
+    0x0B, 0x0D, 0x40, 0x01, 0x12, 0x10, 0x01, 0x9F, 0x38, 0x8B, 0x9A, 0x18,
+    0x16, 0x72, 0x47, 0x4C, 0x7A, 0x08, 0x8D, 0x35, 0x28, 0x8A, 0xA2, 0x22,
+    0x81, 0xD1, 0xC8, 0x09, 0xD3, 0x78, 0x8F, 0x86, 0xD0, 0x1C, 0xAD, 0x34,
+    0x55, 0xEB, 0x06, 0x66, 0xC6, 0xF7, 0x60, 0xEA, 0x01, 0x72, 0x8C, 0xC8,
+    0x4B, 0xEB, 0x11, 0x4E, 0xF1, 0xE2, 0x78, 0x62, 0x81, 0x01, 0x27, 0x20,
+    0x01, 0x25, 0x10, 0x89, 0xA4, 0x50, 0x8C, 0x4F, 0x35, 0x8C, 0x7E, 0x84,
+    0x1C, 0x2E, 0xC7, 0x0E, 0x41, 0x73, 0x91, 0x01, 0xF0, 0x2D, 0x28, 0x50,
+    0x70, 0xFA, 0x68, 0x08, 0xFA, 0xFE, 0x46, 0x8D, 0xF7, 0x58, 0x26, 0x86,
+    0x68, 0x56, 0x05, 0x70, 0x71, 0x40, 0xD8, 0x0D, 0x9C, 0xB5, 0x82, 0xC1,
+    0x50, 0x90, 0xAE, 0x54, 0x02, 0xE2, 0xB8, 0x16, 0x1C, 0xA0, 0x00, 0xB8,
+    0xD1, 0x63, 0x11, 0x15, 0x4E, 0xAF, 0xF0, 0x8B, 0x12, 0x20, 0x8C, 0xE1,
+    0xD1, 0x8E, 0xAF, 0xE0, 0x92, 0x16, 0xF5, 0x17, 0x33, 0x88, 0x91, 0xB3,
+    0x00, 0x6B, 0x84, 0x30, 0x2D, 0x01, 0x30, 0x60, 0x1F, 0x19, 0x44, 0x1C,
+    0xF8, 0x91, 0x01, 0x10, 0x0A, 0x91, 0x05, 0x48, 0x94, 0x75, 0x20, 0x99,
+    0xF7, 0x80, 0xA5, 0xB0, 0x26, 0xB9, 0x68, 0x49, 0x05, 0xA0, 0x90, 0xB5,
+    0xA8, 0x01, 0xB0, 0xE2, 0x6E, 0x8D, 0x50, 0x15, 0xAC, 0xF1, 0x7F, 0x38,
+    0x49, 0x00, 0xE7, 0x98, 0x8E, 0x46, 0x38, 0x15, 0x70, 0xB2, 0x8E, 0xAE,
+    0x94, 0x0E, 0xDA, 0xB5, 0x0F, 0x82, 0x23, 0x00, 0x2E, 0x76, 0x08, 0x30,
+    0x00, 0x86, 0x34, 0xC8, 0x94, 0xCA, 0xD8, 0x7E, 0xCD, 0xD1, 0x65, 0x66,
+    0xF5, 0x63, 0x2A, 0x90, 0x7D, 0x46, 0x15, 0x74, 0xA6, 0x80, 0x2A, 0x6D,
+    0x62, 0x4E, 0xBE, 0xC2, 0x89, 0x0A, 0x50, 0x54, 0x60, 0x49, 0x6E, 0xCF,
+    0x40, 0x0B, 0x06, 0xC0, 0x00, 0x1A, 0xA0, 0x00, 0x0E, 0x50, 0x5F, 0x38,
+    0x09, 0x91, 0xBA, 0x47, 0x57, 0xC8, 0xF1, 0x87, 0xEC, 0xE0, 0x4C, 0x07,
+    0xA0, 0x91, 0x4E, 0x79, 0x58, 0x42, 0xE1, 0x99, 0xFA, 0x58, 0x26, 0xD7,
+    0xD8, 0x97, 0xC0, 0x80, 0x00, 0x29, 0xA9, 0x08, 0x72, 0x75, 0x0A, 0x27,
+    0xD0, 0x00, 0x14, 0x39, 0x40, 0x87, 0x09, 0x0B, 0x89, 0x99, 0x48, 0xB0,
+    0x70, 0x5F, 0x2A, 0xA3, 0x8D, 0xDE, 0xC0, 0x00, 0xAA, 0x11, 0x45, 0xB5,
+    0x64, 0x95, 0x48, 0xF6, 0x17, 0x76, 0xB9, 0x09, 0x5C, 0x35, 0x0B, 0x9F,
+    0xA9, 0x09, 0x78, 0x59, 0x9C, 0x87, 0xF0, 0x2D, 0xFE, 0xBA, 0xD5, 0x57,
+    0x3F, 0xB6, 0x53, 0x29, 0xB9, 0x24, 0xF5, 0xA6, 0x1E, 0x34, 0x91, 0x96,
+    0x27, 0xB3, 0x26, 0x19, 0xD0, 0x27, 0xDE, 0x30, 0x39, 0xF7, 0xE5, 0x68,
+    0xAF, 0x40, 0x76, 0xEC, 0xB2, 0x01, 0x43, 0xC8, 0x01, 0x0E, 0x40, 0x96,
+    0xC0, 0x07, 0x62, 0x55, 0x05, 0x19, 0x72, 0xB4, 0x67, 0xA2, 0xA9, 0x8F,
+    0x4C, 0x19, 0x9C, 0xD1, 0x98, 0x30, 0x3E, 0x70, 0x5A, 0x11, 0x70, 0x6C,
+    0x08, 0xC0, 0x01, 0x5E, 0xC9, 0x0D, 0x55, 0xC9, 0x3D, 0x11, 0x20, 0x01,
+    0x21, 0x70, 0x7B, 0x94, 0xA3, 0x27, 0x73, 0x18, 0x39, 0xBF, 0x31, 0x39,
+    0x13, 0x44, 0x2E, 0x00, 0x19, 0x2B, 0x8F, 0x69, 0x02, 0xAD, 0x71, 0x76,
+    0xF8, 0xC5, 0x36, 0xEB, 0x89, 0x9C, 0x86, 0xF1, 0x49, 0x4D, 0xD9, 0x5A,
+    0x22, 0xD0, 0x01, 0x0B, 0xE0, 0x9E, 0x57, 0x28, 0x14, 0x09, 0x96, 0x69,
+    0xC6, 0x08, 0x39, 0x0E, 0xF0, 0xA1, 0x7F, 0x32, 0x13, 0x13, 0xB0, 0x9F,
+    0xFD, 0x19, 0x93, 0x9A, 0xE7, 0x24, 0xDC, 0x49, 0x20, 0x80, 0xA9, 0x84,
+    0xEB, 0x03, 0x09, 0xE6, 0x25, 0x5F, 0xBF, 0xF7, 0x8E, 0x53, 0x75, 0x33,
+    0x0F, 0x0A, 0xA1, 0x49, 0xD1, 0x87, 0x13, 0x3A, 0x58, 0xCD, 0xA3, 0x94,
+    0xFD, 0xD0, 0x1C, 0x31, 0xE6, 0x59, 0x11, 0x60, 0xA2, 0x61, 0x61, 0x99,
+    0xC7, 0x30, 0xA2, 0xFC, 0xE9, 0x9F, 0x38, 0x39, 0x00, 0x69, 0x42, 0x8B,
+    0x3B, 0xB5, 0xA2, 0x2C, 0xFA, 0x0A, 0x63, 0x66, 0x36, 0xB0, 0x28, 0x32,
+    0x8C, 0x03, 0x62, 0x34, 0x6A, 0xA3, 0x21, 0xD2, 0x1C, 0xA6, 0x46, 0x62,
+    0xFA, 0xE6, 0x2C, 0x43, 0xB9, 0x0F, 0xDC, 0x26, 0x6E, 0xF2, 0xD9, 0xA1,
+    0x61, 0xC1, 0x84, 0xAC, 0x60, 0xA4, 0x25, 0x9A, 0xA4, 0x17, 0x41, 0xA4,
+    0xC5, 0x31, 0x59, 0x5F, 0x43, 0x27, 0x93, 0x33, 0x66, 0x3F, 0xA2, 0xFE,
+    0x61, 0x31, 0x0A, 0x62, 0x05, 0x03, 0xA1, 0x24, 0xC0, 0x85, 0x8F, 0x81,
+    0x83, 0xF2, 0x68, 0x4F, 0xDC, 0x51, 0x29, 0xF8, 0xC4, 0xA3, 0xFB, 0xD0,
+    0x87, 0x1B, 0x8A, 0x5F, 0x9A, 0x46, 0x01, 0x9C, 0x86, 0x0B, 0x17, 0x10,
+    0x9D, 0xA7, 0x80, 0xA6, 0x48, 0xAA, 0xA6, 0xED, 0xA1, 0x02, 0x0A, 0xA0,
+    0x23, 0x73, 0xC5, 0x20, 0xC8, 0x95, 0x88, 0x2C, 0x91, 0x79, 0xEC, 0x73,
+    0x9B, 0xCA, 0x36, 0x32, 0x4A, 0xB7, 0x5B, 0x7F, 0x51, 0xA3, 0x13, 0xD8,
+    0xA5, 0x56, 0xB2, 0x14, 0xC7, 0xC9, 0x87, 0x6E, 0x34, 0x4A, 0xCA, 0x83,
+    0xA3, 0x84, 0x50, 0x58, 0x46, 0xD9, 0x0F, 0x04, 0xF3, 0xA3, 0x48, 0x36,
+    0xA2, 0x11, 0x50, 0xAB, 0xB5, 0xBA, 0x8E, 0x8E, 0x2A, 0xA4, 0x38, 0xE9,
+    0x00, 0x92, 0xAA, 0x01, 0x0C, 0x70, 0x28, 0x23, 0x63, 0xA6, 0xF8, 0x11,
+    0x5F, 0xB1, 0xC2, 0x00, 0x2D, 0x5A, 0x57, 0xB0, 0xF0, 0x73, 0x2A, 0xF4,
+    0x7B, 0x6C, 0x69, 0x51, 0xB4, 0x96, 0x97, 0x4E, 0xE7, 0x4C, 0x6F, 0x29,
+    0x0F, 0xA8, 0x97, 0xA3, 0x9D, 0xD0, 0xA5, 0xD7, 0x61, 0x7A, 0x13, 0x13,
+    0x34, 0x3E, 0x93, 0x30, 0x7B, 0xCA, 0x34, 0x62, 0x0A, 0x87, 0x8E, 0x10,
+    0x01, 0x25, 0x70, 0xA4, 0xBA, 0x1A, 0x4E, 0xBC, 0xAA, 0x00, 0xBE, 0xEA,
+    0xA4, 0x93, 0x03, 0x94, 0xF8, 0x41, 0x1A, 0xA9, 0xB9, 0x61, 0xE6, 0xF8,
+    0x08, 0x5F, 0xA6, 0x6C, 0x02, 0xD0, 0x1A, 0xEE, 0x6A, 0x56, 0xB4, 0x66,
+    0x85, 0x64, 0xD8, 0x0D, 0x83, 0x18, 0x3A, 0xD9, 0x05, 0xAD, 0x01, 0x40,
+    0x29, 0xB4, 0xF0, 0xAA, 0xD1, 0xB2, 0x13, 0xD0, 0xF1, 0x02, 0xFC, 0x9A,
+    0x13, 0xA1, 0xC0, 0x68, 0xC1, 0x47, 0xAE, 0x12, 0x40, 0x01, 0x0D, 0xB0,
+    0x76, 0x49, 0x9A, 0xAE, 0xEB, 0x6A, 0x35, 0x24, 0xF7, 0xA9, 0x0C, 0xD2,
+    0x75, 0x03, 0xFE, 0xC0, 0x6B, 0xEB, 0x34, 0xAF, 0xBC, 0xF5, 0x0A, 0x47,
+    0xF7, 0x3D, 0x24, 0x37, 0x85, 0xA7, 0xF5, 0x28, 0xA2, 0xDA, 0x79, 0xCD,
+    0x82, 0x02, 0x2F, 0x40, 0x30, 0x5F, 0x3A, 0x68, 0x5A, 0x2A, 0xB0, 0x18,
+    0x32, 0x05, 0x57, 0x20, 0x05, 0xDC, 0x20, 0x92, 0xA1, 0x22, 0x7A, 0xA0,
+    0x12, 0x34, 0x49, 0x54, 0x0E, 0x11, 0x68, 0x26, 0x34, 0x40, 0x03, 0x37,
+    0xF0, 0x70, 0xE4, 0x03, 0xB1, 0x12, 0x4B, 0xB1, 0xBB, 0xDA, 0xAB, 0xBF,
+    0x2A, 0x5A, 0xC6, 0x1A, 0x3C, 0x28, 0x32, 0x59, 0xDE, 0x59, 0xAC, 0x20,
+    0xDB, 0x08, 0x03, 0x82, 0x9D, 0x1A, 0xA6, 0x86, 0xD1, 0xF5, 0xB3, 0x02,
+    0xF0, 0xAF, 0x2A, 0x1B, 0x3F, 0x41, 0xE3, 0x9E, 0x24, 0xD0, 0x14, 0x38,
+    0xCB, 0x0E, 0x00, 0xA1, 0x05, 0x5A, 0x47, 0x0B, 0x5C, 0x0B, 0x19, 0x7D,
+    0x48, 0x52, 0x63, 0x32, 0x19, 0xE5, 0xF0, 0x28, 0xB4, 0xD0, 0x8A, 0x85,
+    0x63, 0xB4, 0x13, 0x0B, 0xA9, 0x74, 0xA8, 0xB4, 0x4E, 0x6A, 0x40, 0xEF,
+    0x85, 0x22, 0xA4, 0x61, 0xB5, 0x07, 0xD2, 0xB4, 0xFF, 0xE9, 0x08, 0x73,
+    0x6A, 0xAF, 0x93, 0xB3, 0x48, 0xBB, 0x75, 0x41, 0x7B, 0xF8, 0x91, 0xCD,
+    0x12, 0x21, 0x8C, 0xC5, 0x0E, 0xF3, 0xA3, 0x08, 0x9A, 0xB9, 0x99, 0x02,
+    0x00, 0x05, 0x09, 0x97, 0x04, 0x54, 0xC0, 0x05, 0xCF, 0xF6, 0x33, 0x55,
+    0x02, 0x03, 0x02, 0xDB, 0x09, 0x26, 0x76, 0x53, 0xCA, 0xF0, 0x17, 0x2C,
+    0x20, 0x47, 0x00, 0x51, 0x9A, 0x26, 0x83, 0xB4, 0xB5, 0x84, 0x00, 0x0E,
+    0x30, 0x93, 0x17, 0x6B, 0xAF, 0xF6, 0x52, 0x9B, 0x27, 0xD2, 0x40, 0x1E,
+    0x4B, 0x27, 0x1C, 0x76, 0x1E, 0x4A, 0xD7, 0x40, 0x03, 0x98, 0x9B, 0x0A,
+    0xC0, 0x00, 0x53, 0x4A, 0x80, 0x82, 0xB9, 0x5B, 0xF0, 0xA4, 0x08, 0x18,
+    0x7A, 0x6A, 0xF4, 0xB0, 0x2D, 0xFE, 0xCD, 0x32, 0xB6, 0xE2, 0x75, 0x3A,
+    0x0B, 0xEB, 0x09, 0xD2, 0xB1, 0x05, 0x95, 0x1B, 0x05, 0x56, 0x90, 0xB9,
+    0x13, 0x23, 0x5B, 0x27, 0x26, 0x26, 0x82, 0xD3, 0x8F, 0xC7, 0x10, 0x03,
+    0x6D, 0xD3, 0x2C, 0xD8, 0x6B, 0x32, 0xE7, 0xCA, 0x89, 0xAB, 0x9B, 0x1A,
+    0xDE, 0xE7, 0xBA, 0xED, 0x26, 0x90, 0x0C, 0x82, 0x56, 0x74, 0x62, 0x0B,
+    0x9E, 0xE1, 0x08, 0x1C, 0x8B, 0x9B, 0x2E, 0x41, 0x17, 0x92, 0xEA, 0x02,
+    0xE3, 0xCB, 0x0D, 0xB8, 0x21, 0xA3, 0x16, 0x55, 0x55, 0xA0, 0xA3, 0x8F,
+    0xFF, 0x70, 0x4C, 0xCD, 0xF2, 0xB2, 0x84, 0xF0, 0xB8, 0x51, 0xD2, 0xA7,
+    0xCC, 0x2B, 0x00, 0x51, 0x60, 0xB9, 0x5D, 0xC0, 0x70, 0x1E, 0xE2, 0x3A,
+    0x0F, 0xF0, 0x2D, 0xD3, 0x9A, 0x1D, 0x67, 0x54, 0x92, 0xC8, 0xA0, 0x87,
+    0x31, 0xD5, 0x2C, 0x10, 0x5C, 0x33, 0x37, 0xF9, 0x0C, 0xE1, 0x2B, 0xBF,
+    0xE4, 0xAB, 0x42, 0xC1, 0x7A, 0x22, 0xAF, 0x17, 0xAF, 0x8A, 0x90, 0x79,
+    0xE3, 0xD8, 0x08, 0xF5, 0xBA, 0x63, 0x61, 0x31, 0xBF, 0x4F, 0x3A, 0x00,
+    0xF9, 0x3A, 0xA3, 0xB3, 0xB0, 0xBC, 0x9D, 0x97, 0x00, 0x83, 0xF0, 0x00,
+    0x06, 0x4B, 0x08, 0x03, 0x33, 0x0B, 0x06, 0xC3, 0x4F, 0x59, 0xE0, 0x05,
+    0x36, 0xCB, 0x0D, 0xD6, 0x7A, 0x85, 0x2C, 0xD0, 0x13, 0x8F, 0xD1, 0x67,
+    0x00, 0x47, 0x22, 0x7C, 0x49, 0x0A, 0x31, 0x50, 0x03, 0x3E, 0x20, 0x03,
+    0x4A, 0xAC, 0xC4, 0x4A, 0x86, 0x14, 0xD9, 0x54, 0x38, 0xE4, 0xE2, 0x00,
+    0xE2, 0xBB, 0xC1, 0xCA, 0xD6, 0xAE, 0x27, 0x42, 0x1A, 0xB0, 0xB8, 0x51,
+    0x6F, 0x01, 0x8C, 0xBA, 0x33, 0x59, 0xA9, 0x29, 0x16, 0xBD, 0x97, 0x9B,
+    0xB2, 0x18, 0x5D, 0x5A, 0xA6, 0x08, 0x69, 0xEB, 0x74, 0xA4, 0xF4, 0x49,
+    0x4B, 0xB6, 0x58, 0xDD, 0x90, 0x3A, 0xD0, 0x7A, 0xFE, 0x3A, 0x28, 0xE0,
+    0xBF, 0xFF, 0x13, 0x34, 0xCB, 0x19, 0x62, 0x3B, 0x70, 0x03, 0x34, 0x00,
+    0x58, 0x2D, 0x71, 0x58, 0xB4, 0xB0, 0x02, 0x3C, 0xE0, 0x03, 0x44, 0x2B,
+    0x2F, 0xB4, 0x13, 0xC6, 0x54, 0x2C, 0x5A, 0x19, 0xDB, 0x20, 0x05, 0x35,
+    0xBB, 0x2D, 0x41, 0x72, 0xE2, 0x90, 0x66, 0x2F, 0xCA, 0x12, 0x36, 0x14,
+    0x16, 0xB0, 0xB8, 0xB7, 0xD1, 0x95, 0x2C, 0x51, 0x32, 0xBC, 0x80, 0xF8,
+    0x77, 0xFE, 0x26, 0x26, 0x83, 0xB1, 0x13, 0x2F, 0xF0, 0x00, 0x9D, 0xFB,
+    0x5A, 0x23, 0xD6, 0x49, 0x26, 0x26, 0xB7, 0x47, 0x2C, 0x03, 0x70, 0x7B,
+    0x23, 0x12, 0x13, 0x97, 0xB4, 0xF0, 0x03, 0x0E, 0x6B, 0x2A, 0x9C, 0x5A,
+    0xC8, 0xCA, 0x06, 0xB8, 0x04, 0xD0, 0x20, 0xED, 0xDB, 0x53, 0xE7, 0x51,
+    0x98, 0x93, 0x30, 0xB8, 0xBF, 0x95, 0x0B, 0x00, 0x40, 0xAE, 0x66, 0x13,
+    0xB5, 0xBD, 0x06, 0xBB, 0x0D, 0x3A, 0x6D, 0x36, 0xCA, 0x62, 0x42, 0x24,
+    0xC7, 0xA6, 0x1A, 0x00, 0x5F, 0xB8, 0xA7, 0x5F, 0xE5, 0xA5, 0xD1, 0xF2,
+    0x01, 0x7A, 0x2A, 0x0F, 0x41, 0xA3, 0xC4, 0x79, 0x6C, 0x3B, 0x51, 0x47,
+    0xB0, 0x7D, 0x1C, 0xAE, 0x8D, 0x02, 0x48, 0xB2, 0x6C, 0xAF, 0x94, 0x8C,
+    0x1F, 0x25, 0xDC, 0x12, 0x44, 0x28, 0x55, 0x89, 0x6C, 0x17, 0x71, 0x8A,
+    0xAC, 0x8D, 0x59, 0x59, 0x71, 0x87, 0x64, 0xA1, 0x18, 0x25, 0x2E, 0x4C,
+    0x83, 0x33, 0x57, 0x5D, 0xD6, 0x95, 0x00, 0xCF, 0x0C, 0x21, 0xCA, 0x9C,
+    0x14, 0x15, 0xA3, 0xAD, 0x57, 0x68, 0x40, 0x9D, 0xA9, 0xB0, 0x58, 0x22,
+    0xCD, 0x28, 0x05, 0x03, 0x04, 0xD3, 0xBD, 0x7A, 0x82, 0x0B, 0x79, 0xFB,
+    0xCD, 0x37, 0x02, 0x9E, 0x22, 0xCC, 0xA6, 0x68, 0xF1, 0xC1, 0xBF, 0x71,
+    0x1E, 0xC2, 0xDA, 0x08, 0xB1, 0xCC, 0x12, 0x4B, 0x62, 0x2C, 0xA4, 0xFE,
+    0x31, 0xB2, 0x02, 0x90, 0xCE, 0x48, 0x26, 0x62, 0x3D, 0xE3, 0x94, 0x1A,
+    0x74, 0x1D, 0xF9, 0xBC, 0x4C, 0xCC, 0xC1, 0x0D, 0xF1, 0xBC, 0x0F, 0xD4,
+    0x25, 0x0F, 0x65, 0xD8, 0x12, 0x1D, 0xC0, 0x02, 0x2C, 0x35, 0x02, 0x23,
+    0xAD, 0x09, 0xFA, 0x06, 0xBA, 0x8D, 0xC2, 0x5E, 0x0A, 0x1D, 0x32, 0x0C,
+    0x2D, 0x99, 0xA2, 0x36, 0x00, 0x95, 0x5A, 0x1C, 0x8F, 0xCC, 0x12, 0xB4,
+    0x3C, 0x3E, 0x29, 0x2A, 0xCC, 0xC3, 0x46, 0xCC, 0x8D, 0x00, 0xB5, 0xBF,
+    0xA1, 0xA9, 0x93, 0x27, 0x03, 0xB4, 0xF0, 0xD1, 0xA7, 0xF8, 0x00, 0xA7,
+    0x93, 0x3A, 0xED, 0x47, 0x70, 0xCE, 0x12, 0xB9, 0xFD, 0x70, 0x77, 0xD8,
+    0x35, 0x7A, 0xCC, 0x01, 0x01, 0xA4, 0x18, 0x25, 0xD0, 0x03, 0xD3, 0x3B,
+    0x4B, 0x2A, 0xC7, 0x82, 0x2B, 0x37, 0x2D, 0x2B, 0x0C, 0x60, 0x02, 0x3A,
+    0x9D, 0xA4, 0x13, 0x6D, 0x19, 0xBC, 0x9C, 0x9D, 0x8B, 0x68, 0x0A, 0xE4,
+    0x82, 0xA9, 0x8A, 0x10, 0xCE, 0x53, 0x31, 0x23, 0xDF, 0xF4, 0xD6, 0x93,
+    0xA7, 0x03, 0x3F, 0x00, 0x58, 0x07, 0xF0, 0x02, 0x98, 0x6C, 0x4F, 0x25,
+    0x0D, 0x21, 0x7F, 0x9D, 0x55, 0x50, 0x6D, 0x4D, 0xDA, 0x41, 0x0F, 0x22,
+    0xC0, 0x55, 0x2F, 0xDB, 0x87, 0xB3, 0x20, 0x02, 0x5A, 0x38, 0xD8, 0x49,
+    0x81, 0x4F, 0x02, 0x10, 0x9F, 0xA6, 0x62, 0xA0, 0x65, 0x2D, 0x00, 0x39,
+    0xED, 0x00, 0x3B, 0x8D, 0x93, 0x2B, 0x5C, 0x19, 0x2A, 0xF1, 0x1B, 0xAD,
+    0xD1, 0xD3, 0x8F, 0xF0, 0xD3, 0xDD, 0x00, 0x77, 0x0C, 0x1A, 0x96, 0x5E,
+    0x67, 0x17, 0x80, 0xAB, 0xB1, 0x1C, 0xA7, 0x03, 0xA9, 0x9C, 0x5D, 0x33,
+    0x00, 0xD9, 0xFF, 0x13, 0xD8, 0x90, 0xDB, 0xB9, 0x83, 0x15, 0xD2, 0xC8,
+    0xDB, 0x3F, 0xFA, 0x70, 0x14, 0x99, 0x20, 0x5B, 0xD0, 0x04, 0xCA, 0xF6,
+    0x03, 0x0A, 0xFE, 0x0E, 0x67, 0x2A, 0x83, 0x4C, 0xC5, 0x99, 0xBD, 0xD9,
+    0x38, 0x89, 0x01, 0x0D, 0xB0, 0x93, 0x11, 0x40, 0x9D, 0x7C, 0x51, 0xD1,
+    0xB4, 0xF9, 0x0A, 0x9F, 0x48, 0x1A, 0x1E, 0x30, 0x93, 0xBC, 0x0B, 0x3C,
+    0x81, 0xFB, 0x08, 0x03, 0x82, 0xC2, 0xAB, 0xDD, 0x84, 0x35, 0x80, 0xB8,
+    0xB4, 0xF0, 0x41, 0xFD, 0xB5, 0x67, 0xCE, 0x13, 0xD3, 0x4E, 0xF7, 0xB8,
+    0x10, 0x20, 0xC0, 0x9D, 0x10, 0x53, 0xCC, 0x48, 0x97, 0x42, 0xC1, 0x7E,
+    0x21, 0xE4, 0x58, 0x39, 0xF0, 0xCA, 0x3C, 0x02, 0xDD, 0x2A, 0x04, 0x02,
+    0x43, 0x98, 0xD6, 0x76, 0x2B, 0x1C, 0xCB, 0xAD, 0x39, 0xCE, 0x6D, 0x1C,
+    0xF6, 0xDD, 0x0D, 0x74, 0x2D, 0x09, 0x62, 0xE1, 0x01, 0xF1, 0xBB, 0x92,
+    0x2E, 0x9A, 0x4E, 0xAA, 0x3D, 0xB5, 0x2A, 0xE8, 0x03, 0xC1, 0x8B, 0x4A,
+    0xD0, 0xE4, 0xA7, 0x30, 0x20, 0x02, 0xD2, 0xB6, 0x00, 0xE6, 0x2D, 0x7D,
+    0x09, 0xD0, 0x1C, 0x81, 0x96, 0x1D, 0x68, 0x64, 0x3C, 0x67, 0xD4, 0xC3,
+    0xCA, 0x73, 0x46, 0xE4, 0x95, 0x26, 0xDE, 0x2C, 0x5A, 0x1D, 0x06, 0xA9,
+    0xCA, 0xCD, 0xDC, 0xFF, 0xDD, 0x20, 0x2A, 0xA3, 0xAC, 0xB4, 0x30, 0xE0,
+    0x90, 0x70, 0x42, 0x38, 0x99, 0x95, 0xE4, 0xC2, 0xDD, 0x0C, 0xDE, 0x84,
+    0x96, 0xCC, 0x0D, 0x07, 0x10, 0xE1, 0x1C, 0xE4, 0x55, 0xDA, 0x0C, 0x01,
+    0x17, 0xAE, 0x83, 0x21, 0xDD, 0x01, 0x56, 0xED, 0x09, 0xC2, 0xBB, 0x55,
+    0xEE, 0xA0, 0x4C, 0x9D, 0x44, 0x9A, 0xA6, 0x82, 0xD0, 0x30, 0x4A, 0x4B,
+    0x61, 0x91, 0xE2, 0xFE, 0xAD, 0x35, 0x2A, 0x73, 0xA0, 0x8A, 0xD0, 0x1A,
+    0x8C, 0xB7, 0x66, 0x75, 0x5B, 0x99, 0x91, 0x50, 0xE3, 0x76, 0x41, 0x72,
+    0x6B, 0x8D, 0x76, 0x0F, 0xCE, 0x12, 0x3B, 0xAE, 0xDE, 0xB5, 0xB5, 0x00,
+    0x3F, 0x6E, 0xE1, 0x58, 0xAA, 0xFE, 0x09, 0xA8, 0x97, 0x5D, 0x41, 0x4E,
+    0x08, 0x2F, 0x60, 0x7A, 0xCA, 0x62, 0xDB, 0xDC, 0x22, 0x14, 0x75, 0xEC,
+    0x24, 0x36, 0x5D, 0x0B, 0x43, 0xC8, 0x1A, 0x19, 0xE0, 0x00, 0xBD, 0x2B,
+    0x00, 0x0C, 0x20, 0x6A, 0x74, 0xB6, 0xE2, 0xE2, 0x92, 0xA2, 0x56, 0x7E,
+    0xAF, 0xB9, 0x91, 0x0A, 0x05, 0x10, 0x01, 0x29, 0x50, 0x89, 0x42, 0x1A,
+    0x2F, 0xA4, 0xDD, 0x0D, 0x1C, 0xDD, 0x84, 0x3A, 0x20, 0x03, 0xF0, 0xE3,
+    0xD8, 0xF9, 0xE3, 0x4C, 0x42, 0xE4, 0xD2, 0x27, 0x25, 0xDB, 0x92, 0x42,
+    0xE1, 0xCE, 0xA3, 0xE6, 0x6B, 0xEE, 0xB9, 0x7F, 0xC7, 0xB6, 0x91, 0x71,
+    0x08, 0xC0, 0x5D, 0x52, 0x3B, 0x51, 0xC4, 0x3D, 0x32, 0x1B, 0xAB, 0x31,
+    0x99, 0x09, 0x28, 0xD7, 0xDE, 0x90, 0x23, 0xED, 0xB4, 0x3B, 0x86, 0x3E,
+    0xA0, 0xBE, 0x8C, 0x0C, 0x10, 0x7B, 0x02, 0x03, 0x22, 0x09, 0xDB, 0x8D,
+    0xCE, 0xC7, 0x6A, 0x80, 0x35, 0x40, 0x6B, 0x6E, 0x2E, 0x30, 0xA0, 0x6E,
+    0x17, 0xFF, 0xCC, 0x52, 0xA9, 0xBE, 0xDE, 0x2B, 0xC5, 0x52, 0x5C, 0x5D,
+    0x8A, 0xAA, 0x3A, 0xEA, 0x39, 0x41, 0x30, 0x6E, 0xFC, 0x99, 0x41, 0x23,
+    0xB7, 0x69, 0xB2, 0x6E, 0xBB, 0xFA, 0xE7, 0x0D, 0x41, 0x96, 0x0D, 0xE0,
+    0xD0, 0xB6, 0x52, 0xE5, 0xBF, 0x11, 0xC9, 0x45, 0x58, 0x0E, 0x15, 0xD0,
+    0x2F, 0x6D, 0xAD, 0x92, 0xE6, 0x3B, 0x79, 0xC3, 0x4E, 0x0B, 0xFC, 0x8C,
+    0xE4, 0xB6, 0x03, 0x01, 0x71, 0xCE, 0x02, 0xDA, 0xCC, 0x12, 0x28, 0x20,
+    0x02, 0xD2, 0x83, 0x9C, 0x80, 0x71, 0xC6, 0xD2, 0x48, 0x22, 0x52, 0xAD,
+    0xB8, 0xD5, 0xD7, 0x28, 0xE5, 0x18, 0x4E, 0x47, 0xC2, 0x2E, 0x06, 0x70,
+    0xE2, 0x03, 0xA0, 0x0B, 0x8D, 0xA3, 0x32, 0x84, 0xCC, 0x0D, 0x3A, 0xC2,
+    0xDA, 0xE7, 0xC0, 0xB1, 0xB9, 0x1B, 0x69, 0x46, 0xFE, 0xCD, 0x71, 0x31,
+    0x70, 0x67, 0xD4, 0xC4, 0x0E, 0xD4, 0x2B, 0x97, 0x0F, 0x90, 0x85, 0x2D,
+    0xFB, 0xEC, 0x21, 0xD3, 0x99, 0xF2, 0x1E, 0x47, 0xA3, 0xDE, 0x87, 0x82,
+    0xBA, 0x1D, 0x7F, 0x17, 0xC7, 0xFA, 0x78, 0xED, 0x8D, 0x22, 0xE3, 0x2D,
+    0xD2, 0x90, 0x16, 0xA0, 0xED, 0x03, 0xE0, 0xE7, 0xDF, 0x09, 0xE5, 0xAF,
+    0xF0, 0x1A, 0x54, 0xFE, 0x68, 0x07, 0x32, 0x7B, 0x8C, 0x7A, 0x0E, 0x48,
+    0x3D, 0x4E, 0xBF, 0xDB, 0xD1, 0x96, 0x9E, 0xAD, 0x79, 0xF9, 0xA7, 0x80,
+    0x61, 0x3D, 0xD2, 0x0C, 0x03, 0x2D, 0xD5, 0x52, 0x30, 0xFD, 0xE6, 0xFA,
+    0xB8, 0x5A, 0x8F, 0xD1, 0x4C, 0xCE, 0xC2, 0x02, 0x30, 0xCD, 0xEF, 0x59,
+    0x45, 0x30, 0xAC, 0xCE, 0x23, 0x0D, 0xD4, 0x00, 0x30, 0xBF, 0x39, 0x91,
+    0x10, 0xA4, 0xA7, 0x29, 0xEB, 0xB9, 0x59, 0x64, 0x1C, 0xA3, 0x35, 0x05,
+    0xA5, 0x59, 0xD1, 0x0D, 0xA5, 0x05, 0x81, 0x5C, 0x28, 0x6C, 0x00, 0x30,
+    0x7E, 0x5A, 0x7F, 0x75, 0x1D, 0x66, 0x2E, 0x30, 0xA7, 0xE4, 0x91, 0xD2,
+    0x0E, 0x40, 0xDC, 0xF0, 0xEE, 0xFB, 0xD0, 0xE6, 0xB4, 0x40, 0x83, 0x09,
+    0xA0, 0x08, 0x77, 0xEE, 0x24, 0x5E, 0xDF, 0x2B, 0x32, 0x4F, 0xF3, 0xEC,
+    0x42, 0xEB, 0x1C, 0x65, 0xBF, 0x69, 0xE2, 0xE4, 0x40, 0xA2, 0x78, 0xAF,
+    0x79, 0x0A, 0x68, 0xB8, 0xE0, 0xC6, 0x85, 0x64, 0x7B, 0x3D, 0x5B, 0x74,
+    0x9E, 0x41, 0x81, 0x75, 0xF7, 0x63, 0x42, 0xD0, 0x6C, 0x74, 0xF9, 0x09,
+    0xA0, 0xC9, 0x29, 0xAB, 0x55, 0xF0, 0x49, 0x3E, 0x5C, 0x99, 0x01, 0x7F,
+    0xBE, 0x19, 0x8A, 0xD2, 0x22, 0xE0, 0x8E, 0x22, 0x91, 0x0E, 0xC9, 0x77,
+    0x22, 0x01, 0x8F, 0x3F, 0x09, 0x8E, 0x17, 0xAF, 0x93, 0xD3, 0xF3, 0x9E,
+    0xF5, 0xB3, 0x1D, 0x60, 0xF5, 0x9A, 0xA0, 0xC9, 0x27, 0xAD, 0xF9, 0xFE,
+    0x83, 0xDA, 0xD4, 0xBA, 0x0F, 0x92, 0x2D, 0x4C, 0x83, 0x4D, 0x11, 0xC8,
+    0x8D, 0x33, 0x01, 0x9C, 0xA6, 0x2E, 0x19, 0x85, 0xF0, 0xCD, 0x8A, 0x22,
+    0xE4, 0x42, 0xD4, 0x2D, 0xF1, 0x88, 0xD5, 0x60, 0x5A, 0xC9, 0xB0, 0x95,
+    0xB8, 0xE0, 0xBE, 0xDD, 0x70, 0xD1, 0x1D, 0x7D, 0xA7, 0xDA, 0x81, 0xAD,
+    0xF1, 0xE3, 0xFB, 0x21, 0xB2, 0x46, 0x63, 0xA8, 0x14, 0x04, 0xD3, 0xC0,
+    0xA7, 0x16, 0x34, 0x06, 0xED, 0x34, 0xEA, 0x16, 0x0C, 0x87, 0x94, 0x4F,
+    0x1B, 0x00, 0xE5, 0xAB, 0x6F, 0xCB, 0xF5, 0x42, 0x27, 0xB3, 0x32, 0x67,
+    0x0C, 0xF5, 0x9A, 0x16, 0x70, 0x71, 0x49, 0x08, 0xF4, 0xD2, 0xCD, 0x71,
+    0xB4, 0x96, 0xB6, 0x80, 0xF0, 0x10, 0x30, 0x48, 0x18, 0x40, 0xC2, 0x22,
+    0x90, 0xA8, 0x78, 0xF0, 0x51, 0xE8, 0xF8, 0x08, 0x19, 0x29, 0x39, 0x49,
+    0x59, 0x69, 0x79, 0x89, 0xF9, 0x71, 0xA0, 0x88, 0x92, 0x80, 0x59, 0x38,
+    0x92, 0x78, 0xE0, 0xF9, 0x59, 0x6A, 0x7A, 0xF9, 0x91, 0xB8, 0x12, 0x03,
+    0xD0, 0xEA, 0xFA, 0x0A, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, 0x1B,
+    0x5B, 0x72, 0x31, 0xC0, 0xDB, 0xDB, 0x62, 0xA0, 0x18, 0x2C, 0x3C, 0x4C,
+    0x9C, 0xC8, 0xE0, 0xD1, 0x2B, 0x81, 0xBB, 0xCC, 0xDC, 0xEC, 0x0C, 0x40,
+    0xD0, 0xCB, 0x50, 0x5C, 0x6C, 0x82, 0xD0, 0x8B, 0xCD, 0x7B, 0x71, 0x22,
+    0x61, 0x11, 0x51, 0x20, 0x5B, 0x51, 0x12, 0xB2, 0x8B, 0x8D, 0x00, 0x42,
+    0xAD, 0x08, 0xD2, 0x7B, 0xF1, 0xEC, 0xFE, 0x0E, 0x1F, 0x2F, 0xEF, 0xBA,
+    0x23, 0x4A, 0x4A, 0xC9, 0x72, 0x1F, 0x90, 0xF0, 0x42, 0x7D, 0x30, 0x72,
+    0x2A, 0xA0, 0xC0, 0x81, 0x04, 0x25, 0x69, 0x52, 0xD4, 0x81, 0x50, 0x02,
+    0x11, 0x24, 0x2A, 0x25, 0xD8, 0x24, 0x60, 0x41, 0xC1, 0x89, 0xA6, 0x3A,
+    0x24, 0xF2, 0xFE, 0x31, 0x2F, 0xA3, 0xC6, 0x59, 0x15, 0x4E, 0x64, 0x1B,
+    0xE0, 0x01, 0x5D, 0xBA, 0x91, 0xC5, 0x14, 0xF4, 0x0A, 0xB1, 0x31, 0x25,
+    0x3C, 0x0A, 0xBD, 0x1C, 0x90, 0x14, 0x66, 0x40, 0x41, 0x86, 0x8F, 0x34,
+    0x79, 0x11, 0x68, 0xD0, 0xA0, 0x26, 0xAF, 0x0C, 0x22, 0x47, 0xB6, 0xE8,
+    0x45, 0x41, 0xA5, 0xD0, 0xA1, 0x44, 0x61, 0xDD, 0x10, 0xD5, 0x88, 0x12,
+    0x84, 0x17, 0x84, 0x66, 0x40, 0x4C, 0x84, 0x63, 0xC5, 0x30, 0x80, 0x14,
+    0xAB, 0x5A, 0xBD, 0x4A, 0x28, 0x94, 0x22, 0x11, 0x83, 0x16, 0x08, 0x80,
+    0x51, 0x49, 0x44, 0xA2, 0x4E, 0x58, 0xCB, 0x3A, 0xF2, 0x2A, 0x80, 0x46,
+    0xD1, 0xB5, 0xCD, 0x52, 0x44, 0x33, 0x67, 0xE2, 0xA5, 0x5C, 0x61, 0x1A,
+    0x7A, 0x35, 0x60, 0x8B, 0x17, 0x56, 0x04, 0x6C, 0xD3, 0xE6, 0x2A, 0x72,
+    0xA1, 0xE2, 0x9A, 0xCE, 0xC1, 0xD8, 0x7E, 0xC9, 0x9D, 0xC9, 0xAB, 0x44,
+    0xDE, 0xC5, 0x8C, 0x71, 0xC5, 0x90, 0x21, 0x0A, 0xEC, 0x24, 0x08, 0x02,
+    0x48, 0x3C, 0x40, 0x11, 0x2C, 0x87, 0x8E, 0x56, 0x3E, 0xA4, 0x06, 0x93,
+    0x38, 0x30, 0x01, 0xE5, 0x44, 0x22, 0xF4, 0x99, 0x3D, 0x8D, 0xE9, 0xC1,
+    0xD3, 0x19, 0x01, 0x2C, 0x52, 0x95, 0xF4, 0x40, 0x91, 0x20, 0xD4, 0x65,
+    0xB5, 0xAE, 0xD8, 0xDC, 0xB8, 0xF1, 0x04, 0x0C, 0x1F, 0x55, 0x6C, 0xF0,
+    0x0B, 0x9C, 0x01, 0xBB, 0xDC, 0x78, 0x73, 0xF2, 0x72, 0x09, 0x3C, 0x18,
+    0x03, 0x05, 0x0E, 0x08, 0xD7, 0xE4, 0xF0, 0x5B, 0xAE, 0x70, 0x9B, 0xC4,
+    0xAB, 0x5B, 0x07, 0x60, 0x03, 0x47, 0xA2, 0x17, 0x0D, 0x23, 0x51, 0x7E,
+    0x9A, 0xE8, 0x06, 0x2B, 0x57, 0x3A, 0x68, 0x08, 0xEB, 0x90, 0xD4, 0x54,
+    0x02, 0x8B, 0xC1, 0x3A, 0x98, 0xA6, 0x0D, 0x3F, 0x52, 0xEC, 0xAD, 0x89,
+    0xD2, 0x43, 0x4A, 0x80, 0x59, 0xFE, 0x00, 0xEB, 0xF8, 0x56, 0x0F, 0x0A,
+    0xE8, 0x71, 0x1D, 0x5B, 0x05, 0x84, 0xF0, 0x51, 0x06, 0x2E, 0x24, 0x27,
+    0x40, 0x4C, 0xC0, 0x90, 0x64, 0x00, 0x36, 0x01, 0x0E, 0xB5, 0x57, 0x2F,
+    0x07, 0x22, 0x28, 0x0C, 0x08, 0x2E, 0x28, 0xC0, 0x81, 0x03, 0xC8, 0x14,
+    0xE8, 0x40, 0x0B, 0x2E, 0x2C, 0x38, 0x97, 0x0A, 0x40, 0x3D, 0x48, 0x22,
+    0x5E, 0x31, 0x68, 0x27, 0x80, 0x7B, 0x91, 0xF4, 0xA3, 0x08, 0x0D, 0xB8,
+    0xC9, 0x72, 0x94, 0x30, 0xA0, 0x95, 0x22, 0xD6, 0x30, 0x07, 0x48, 0x56,
+    0xD5, 0x21, 0x10, 0xEC, 0x08, 0x01, 0x0B, 0xB3, 0xF1, 0x07, 0x89, 0x56,
+    0x8B, 0x50, 0x82, 0x16, 0x04, 0x40, 0x56, 0xF5, 0x50, 0x22, 0x3C, 0x94,
+    0x38, 0x94, 0x2E, 0x1F, 0x19, 0x96, 0x1C, 0x03, 0xD7, 0x20, 0x30, 0xE1,
+    0x48, 0xD8, 0x4C, 0xC0, 0xE4, 0x46, 0xC6, 0x0D, 0x80, 0x00, 0x88, 0x14,
+    0x7E, 0x29, 0xD7, 0x06, 0xD8, 0x44, 0x90, 0x65, 0x99, 0x2A, 0xD9, 0xE0,
+    0x19, 0x04, 0x0B, 0xD8, 0xD7, 0x95, 0x22, 0x3B, 0xDC, 0x62, 0x9E, 0x30,
+    0x10, 0xBC, 0x37, 0x49, 0x2A, 0x02, 0xB0, 0x40, 0xC2, 0x07, 0x2C, 0x46,
+    0x64, 0xD5, 0x65, 0xC4, 0xBC, 0x76, 0x64, 0x21, 0x35, 0x26, 0x62, 0xA4,
+    0x24, 0x24, 0x88, 0xD2, 0x5D, 0xA0, 0xA1, 0xB1, 0x87, 0xC3, 0x78, 0x66,
+    0xCA, 0xD3, 0xD1, 0x47, 0x21, 0x51, 0xF8, 0x13, 0x36, 0x2A, 0x78, 0x49,
+    0x4C, 0x73, 0xBC, 0x90, 0xF9, 0x68, 0x3C, 0x13, 0x58, 0x0A, 0x66, 0xA8,
+    0x2F, 0x71, 0xD0, 0x0B, 0x06, 0x9D, 0x9E, 0x2A, 0x4F, 0x0F, 0xC1, 0x14,
+    0x5A, 0xC8, 0xA1, 0x89, 0x38, 0x4A, 0x4B, 0x0C, 0x39, 0x0C, 0x83, 0x02,
+    0x9B, 0x93, 0xD4, 0xF8, 0xA3, 0x45, 0x07, 0x58, 0x95, 0x64, 0x8A, 0x22,
+    0x3C, 0x30, 0x83, 0x6C, 0x8A, 0x3A, 0xC2, 0x1E, 0xFE, 0x9F, 0x92, 0x20,
+    0xF2, 0xD5, 0xB0, 0x03, 0x7D, 0x90, 0xDF, 0x0A, 0x36, 0xA0, 0x0A, 0x8F,
+    0x5B, 0xD9, 0x20, 0x10, 0x17, 0x82, 0x20, 0x6C, 0x98, 0x4D, 0x06, 0x7D,
+    0x15, 0x23, 0x22, 0x2F, 0xCA, 0x40, 0xEB, 0x8E, 0x04, 0x85, 0x89, 0x4A,
+    0x2E, 0x31, 0xD3, 0xF1, 0x62, 0x01, 0xB8, 0xEA, 0x36, 0x83, 0x62, 0x22,
+    0x3F, 0x12, 0x52, 0x63, 0x0D, 0x8E, 0xCD, 0x2A, 0xCC, 0x3F, 0x97, 0x40,
+    0xC4, 0xD5, 0x20, 0x94, 0x31, 0x55, 0xD5, 0x7C, 0x07, 0x24, 0xAA, 0x15,
+    0x0B, 0xCA, 0x12, 0x32, 0x9F, 0x00, 0xEF, 0x3A, 0x32, 0xDF, 0x7E, 0x03,
+    0xAB, 0xC7, 0x9E, 0xB3, 0xEB, 0x3A, 0x13, 0xA1, 0xA5, 0xD1, 0x25, 0x67,
+    0xCD, 0x60, 0x50, 0x0E, 0x63, 0x12, 0x2F, 0x28, 0x3D, 0xDC, 0x0C, 0x6F,
+    0xBD, 0x68, 0x50, 0x6E, 0xC8, 0x09, 0x62, 0x6B, 0x2A, 0xC7, 0x26, 0xCF,
+    0x12, 0xA7, 0x3D, 0x8E, 0xB8, 0xBA, 0xA4, 0x63, 0x3B, 0xA4, 0xAC, 0x48,
+    0x3E, 0x95, 0x70, 0x92, 0x15, 0x0A, 0x07, 0x13, 0x34, 0x9F, 0x69, 0x16,
+    0xA1, 0x50, 0xD5, 0x0C, 0x6B, 0x9A, 0x42, 0xE8, 0x64, 0x77, 0x2E, 0x1C,
+    0xD0, 0x68, 0x0E, 0x9F, 0x8C, 0xCB, 0xA7, 0xBD, 0x18, 0x48, 0xA1, 0x01,
+    0x9A, 0xF6, 0x42, 0x40, 0x08, 0x6F, 0x2D, 0xBD, 0x6D, 0x30, 0x75, 0xF1,
+    0x72, 0x17, 0xD2, 0xB7, 0x54, 0x30, 0xF5, 0x00, 0x20, 0x8B, 0x2C, 0x6A,
+    0xA5, 0x9B, 0x6A, 0x4D, 0x36, 0x00, 0x89, 0x74, 0x80, 0xAC, 0x8A, 0x82,
+    0x0A, 0x90, 0x83, 0x33, 0x31, 0x06, 0x73, 0x23, 0x25, 0xF9, 0x09, 0xF0,
+    0x1A, 0x9D, 0xCB, 0x26, 0xA2, 0xF0, 0x3E, 0x98, 0xED, 0x5A, 0xD0, 0x7A,
+    0xA2, 0x00, 0xEA, 0x10, 0xDE, 0x92, 0x04, 0x5B, 0x19, 0xD1, 0xA6, 0xD4,
+    0x78, 0x74, 0xD9, 0xB5, 0x60, 0x83, 0xE9, 0x5C, 0x2E, 0x08, 0x56, 0xFE,
+    0x6A, 0x05, 0x00, 0x14, 0xE0, 0x51, 0x36, 0x17, 0x1B, 0x33, 0x9C, 0xE2,
+    0xB4, 0x28, 0xDD, 0x8B, 0x02, 0x60, 0x83, 0x79, 0x35, 0x2F, 0x41, 0x69,
+    0x7E, 0xB2, 0x28, 0x83, 0x0A, 0xDC, 0x6A, 0x22, 0xCF, 0x36, 0xF3, 0x76,
+    0x30, 0xA5, 0x0D, 0xBE, 0x88, 0xAD, 0x55, 0x21, 0x9B, 0x9E, 0x9D, 0xA8,
+    0x13, 0x54, 0x6C, 0x22, 0x80, 0x4F, 0x02, 0x43, 0x7D, 0x91, 0x24, 0x99,
+    0x2F, 0x6A, 0x30, 0x1C, 0x90, 0xF7, 0x40, 0x68, 0xE1, 0xB0, 0x3A, 0xE9,
+    0xB3, 0x94, 0x33, 0x40, 0xD5, 0x72, 0x19, 0x20, 0x76, 0x32, 0xB0, 0x94,
+    0xD0, 0xF5, 0x00, 0xDA, 0x06, 0xD3, 0x60, 0x2F, 0xCA, 0xCF, 0x62, 0x41,
+    0x36, 0x97, 0x7E, 0x9E, 0x5C, 0xE8, 0x03, 0x5C, 0x00, 0xCE, 0xF6, 0x0F,
+    0xD3, 0x2B, 0x4C, 0xF0, 0xFA, 0x0A, 0xF0, 0xC3, 0x33, 0x90, 0x0D, 0xD3,
+    0x41, 0xA2, 0x8E, 0xF8, 0xAD, 0xC8, 0x02, 0x76, 0x13, 0x84, 0xD6, 0x3F,
+    0x49, 0x89, 0x85, 0xA3, 0x40, 0xF3, 0xB1, 0xB0, 0x80, 0x4D, 0xF0, 0xEC,
+    0x12, 0x88, 0x18, 0x20, 0x24, 0x68, 0x47, 0x1B, 0x3B, 0xDD, 0xCC, 0x14,
+    0x23, 0xC8, 0x0F, 0x0D, 0x60, 0x65, 0xBE, 0x57, 0x6C, 0xE9, 0x6B, 0x73,
+    0x01, 0x01, 0x62, 0xD8, 0xC1, 0x29, 0x58, 0x50, 0xEE, 0x49, 0x20, 0xBA,
+    0x52, 0x04, 0x61, 0xD1, 0x3D, 0x6C, 0x5C, 0x0F, 0x7C, 0x72, 0x11, 0xDF,
+    0x00, 0xB0, 0xF4, 0x41, 0x75, 0xA1, 0x89, 0x18, 0xEA, 0xEB, 0x1D, 0x0E,
+    0xDC, 0x61, 0x03, 0xF4, 0x2D, 0x62, 0x81, 0x5D, 0x79, 0x8A, 0xCD, 0xB0,
+    0x02, 0x83, 0xD1, 0x20, 0xA5, 0x2A, 0x62, 0x41, 0x9D, 0xDF, 0xF8, 0x55,
+    0x09, 0x8B, 0x14, 0x8F, 0x10, 0xBD, 0x4B, 0x11, 0x7C, 0xB4, 0x42, 0x43,
+    0x54, 0xCC, 0xAD, 0x7D, 0x29, 0x8C, 0x05, 0x81, 0x78, 0xE1, 0xB9, 0xB9,
+    0x64, 0x0C, 0xFE, 0x1B, 0x14, 0x28, 0xDF, 0x2C, 0xA8, 0x97, 0xAD, 0xBE,
+    0x3C, 0x2D, 0x83, 0x4D, 0x9C, 0x40, 0xF5, 0x2E, 0x47, 0x42, 0x62, 0x98,
+    0x20, 0x1B, 0xE9, 0x6A, 0xA2, 0xBA, 0x62, 0x50, 0x83, 0x34, 0xD6, 0xE0,
+    0x7D, 0xC6, 0x1A, 0xC4, 0x26, 0xE4, 0xE5, 0x8E, 0xCE, 0x4C, 0xC5, 0x50,
+    0x2F, 0xC0, 0x97, 0x59, 0x48, 0x90, 0xC3, 0x4D, 0xF0, 0x6D, 0x22, 0x94,
+    0x99, 0x51, 0x92, 0xE4, 0x17, 0x09, 0xC2, 0xC9, 0xAE, 0x57, 0xFD, 0x33,
+    0xCB, 0x7C, 0x00, 0xF9, 0x09, 0xFF, 0x08, 0xE0, 0x4D, 0x66, 0x84, 0x85,
+    0xB8, 0x78, 0xA1, 0x82, 0x30, 0x3D, 0xCD, 0x26, 0x8A, 0xB9, 0xC5, 0x06,
+    0x2D, 0x67, 0x80, 0x6E, 0x0D, 0xE0, 0x5B, 0x8D, 0xDC, 0xCD, 0xB4, 0xA2,
+    0x18, 0x46, 0x98, 0x68, 0x12, 0x5D, 0x8D, 0x44, 0x5A, 0x3D, 0x7C, 0x37,
+    0x08, 0xB1, 0xDC, 0x00, 0x1E, 0x31, 0x68, 0x5D, 0x22, 0x66, 0x04, 0x09,
+    0x12, 0x2C, 0x00, 0x02, 0x88, 0xBC, 0x4A, 0x0E, 0x59, 0x55, 0x10, 0x44,
+    0xC0, 0x92, 0x32, 0x43, 0x5C, 0x99, 0x00, 0x23, 0x81, 0x16, 0x20, 0xA2,
+    0x26, 0x36, 0x09, 0x09, 0x88, 0x90, 0x56, 0x00, 0xC7, 0x52, 0xBA, 0x22,
+    0x62, 0xC8, 0x19, 0x89, 0x06, 0x20, 0x87, 0x35, 0xC9, 0x31, 0x03, 0x8B,
+    0x22, 0xD4, 0xE4, 0xC6, 0x4A, 0x39, 0xA0, 0x02, 0x29, 0xA0, 0x71, 0x9F,
+    0xAB, 0x18, 0x36, 0xCA, 0xA8, 0x4C, 0x93, 0xF1, 0xE0, 0x6C, 0xA4, 0x70,
+    0x61, 0xAA, 0x3C, 0xB3, 0x95, 0xFB, 0x19, 0x2E, 0x20, 0xC3, 0xB3, 0x0F,
+    0x65, 0x70, 0x09, 0x89, 0x1A, 0x15, 0x72, 0x10, 0xAE, 0x82, 0xE7, 0x69,
+    0xC4, 0x62, 0xCF, 0x4B, 0x1C, 0x33, 0x79, 0xE1, 0x04, 0x00, 0xE7, 0x06,
+    0x30, 0x92, 0x4C, 0x7E, 0x24, 0x05, 0xEE, 0x28, 0xC0, 0x96, 0x3E, 0x92,
+    0xB5, 0x70, 0x46, 0x80, 0x79, 0xFE, 0xBD, 0x40, 0x00, 0x07, 0x7A, 0x02,
+    0x36, 0x0D, 0x5C, 0x90, 0x92, 0xFD, 0x3C, 0x99, 0x0E, 0x3C, 0x73, 0xBB,
+    0x44, 0xBC, 0xE8, 0x1D, 0xAD, 0x3C, 0x4F, 0x2D, 0xD7, 0x49, 0x91, 0x22,
+    0xE6, 0x53, 0x21, 0x9B, 0x28, 0xE6, 0x23, 0xC4, 0xF2, 0xAF, 0xF8, 0x10,
+    0x6E, 0xA4, 0x94, 0xD8, 0x67, 0x45, 0x5F, 0xC1, 0x38, 0x6A, 0x30, 0x60,
+    0xA2, 0x03, 0xC0, 0x00, 0x0A, 0xDF, 0x21, 0xAD, 0x8F, 0xB4, 0xA3, 0xA2,
+    0x05, 0x90, 0x40, 0xF5, 0x76, 0xD2, 0x02, 0xE7, 0x7D, 0x69, 0x03, 0x32,
+    0xF9, 0x08, 0x06, 0xA4, 0xF9, 0x52, 0x8E, 0xB1, 0x51, 0x32, 0x88, 0x68,
+    0x99, 0x3C, 0x74, 0xE0, 0x4A, 0xFB, 0x81, 0x14, 0x49, 0x0F, 0x28, 0xA2,
+    0x00, 0x84, 0xF9, 0x08, 0xAD, 0xF4, 0xD2, 0x4E, 0xB0, 0xBC, 0xE7, 0x56,
+    0x18, 0xA8, 0x88, 0xC4, 0x25, 0x95, 0x79, 0x42, 0x4D, 0x44, 0xF4, 0x34,
+    0x66, 0x45, 0x78, 0x54, 0xE0, 0xA0, 0xDA, 0x4B, 0x6A, 0x4F, 0x7F, 0xDA,
+    0x12, 0x05, 0x30, 0x80, 0x9B, 0x23, 0x61, 0x40, 0x0B, 0xB0, 0x85, 0x0D,
+    0x02, 0x70, 0x32, 0xA9, 0x1C, 0x8B, 0x81, 0x22, 0xF8, 0x45, 0x38, 0x08,
+    0xC2, 0x03, 0xAA, 0xE8, 0x14, 0x00, 0x04, 0x92, 0x38, 0x55, 0x4C, 0x0C,
+    0x2A, 0x11, 0x1F, 0x1D, 0x04, 0xB2, 0x6A, 0x89, 0x52, 0x75, 0x16, 0xA4,
+    0xAA, 0x3A, 0x14, 0x80, 0xEC, 0x26, 0x21, 0x24, 0xCD, 0xF0, 0xD5, 0x15,
+    0x13, 0x1C, 0xC6, 0xB5, 0xB2, 0x41, 0x00, 0x2E, 0xCE, 0x23, 0xA7, 0xBD,
+    0xB8, 0xE9, 0x4B, 0x7B, 0xCA, 0x50, 0x9A, 0x20, 0xC0, 0x01, 0x1C, 0x50,
+    0x80, 0x06, 0x18, 0x00, 0xDB, 0xD8, 0xC2, 0xD6, 0x04, 0x0A, 0x50, 0x01,
+    0x5E, 0x3F, 0x42, 0x01, 0xA4, 0x6E, 0x96, 0x63, 0xE3, 0x34, 0xA2, 0x21,
+    0x12, 0x91, 0xCC, 0x8C, 0x3C, 0xA6, 0xB0, 0x28, 0xFE, 0x98, 0x41, 0x63,
+    0x13, 0x3B, 0x33, 0xC3, 0x1A, 0x77, 0x12, 0x09, 0x38, 0xDB, 0x7D, 0x5E,
+    0x69, 0x48, 0x11, 0xCC, 0xED, 0xAB, 0x9F, 0xC8, 0xAC, 0x60, 0x5F, 0xFA,
+    0xC4, 0x01, 0x80, 0x32, 0x11, 0xDE, 0xEC, 0xC5, 0x09, 0xD2, 0xAA, 0x91,
+    0xB5, 0x8E, 0x69, 0xB7, 0xAD, 0x28, 0x01, 0x4B, 0x9C, 0x83, 0x5E, 0x9A,
+    0x10, 0x20, 0xB7, 0xE4, 0x45, 0xDA, 0x0A, 0x0B, 0x17, 0x00, 0xCC, 0xC8,
+    0x40, 0x28, 0xC3, 0x4D, 0xDF, 0x71, 0x91, 0xBB, 0xA2, 0xDD, 0x41, 0x02,
+    0x2D, 0xBD, 0x0C, 0x96, 0x01, 0xFB, 0x93, 0x3B, 0x61, 0x20, 0x36, 0xAB,
+    0x8A, 0xC8, 0xC1, 0x75, 0x5F, 0xFA, 0xC8, 0x01, 0x44, 0x32, 0x11, 0x4E,
+    0x03, 0x2D, 0x41, 0x8B, 0x92, 0xD3, 0xBD, 0x92, 0xD7, 0xBC, 0xA9, 0x4D,
+    0x6F, 0x4D, 0x4E, 0x60, 0x01, 0xF0, 0xB6, 0x57, 0xA9, 0xBA, 0x1B, 0x44,
+    0x3F, 0x9C, 0xAA, 0x92, 0xFA, 0xBA, 0x6E, 0x9E, 0xF8, 0x25, 0x48, 0x92,
+    0x46, 0x01, 0x09, 0xCC, 0x0C, 0xD8, 0x14, 0x24, 0xA8, 0x63, 0x30, 0x68,
+    0xD0, 0xAE, 0xDB, 0x59, 0xA2, 0x60, 0x06, 0xDE, 0x30, 0x00, 0x98, 0x99,
+    0x88, 0xC7, 0x65, 0xE3, 0xA8, 0x78, 0x11, 0xEF, 0x35, 0x6D, 0x0C, 0x80,
+    0x0A, 0x58, 0x20, 0x04, 0x6C, 0x4D, 0x2F, 0x06, 0x42, 0x50, 0x02, 0x0D,
+    0x03, 0xF9, 0x61, 0xEF, 0xDB, 0x4F, 0xEF, 0x56, 0xB0, 0x96, 0x18, 0xF8,
+    0xA0, 0x5D, 0xA2, 0x90, 0x6A, 0x89, 0x0B, 0x42, 0xB8, 0xAE, 0x0E, 0x22,
+    0x14, 0x2C, 0x65, 0xF1, 0x08, 0x2A, 0x9B, 0x03, 0x19, 0xB0, 0x22, 0x18,
+    0x2B, 0x26, 0x84, 0x7F, 0x6A, 0x6C, 0xE3, 0x7F, 0x42, 0xEF, 0x23, 0x12,
+    0x66, 0x4B, 0x0A, 0x4E, 0xB0, 0xE4, 0x70, 0x44, 0xC0, 0x02, 0x12, 0x90,
+    0x00, 0x4E, 0xEE, 0x7C, 0xE7, 0x3A, 0x97, 0x40, 0xB4, 0x71, 0x3E, 0xFE,
+    0x95, 0x1A, 0xFF, 0x2C, 0x03, 0x19, 0xF0, 0x00, 0x45, 0x0A, 0x49, 0xC4,
+    0x03, 0xD9, 0xA2, 0x83, 0x97, 0xC1, 0x6D, 0x01, 0xF7, 0xBD, 0x32, 0x25,
+    0x74, 0x45, 0x27, 0x15, 0x13, 0x84, 0x04, 0x23, 0x78, 0xC1, 0x74, 0xD3,
+    0x22, 0xE6, 0x56, 0xD4, 0x40, 0x11, 0x5D, 0x76, 0x84, 0x7F, 0x6E, 0x13,
+    0x67, 0x6C, 0xDC, 0xF6, 0x02, 0x7C, 0xEE, 0xB3, 0xA9, 0x4F, 0x4D, 0x8B,
+    0x1A, 0xF8, 0x40, 0x06, 0x37, 0xA0, 0x81, 0x0C, 0xD3, 0x21, 0xE3, 0xD1,
+    0xA0, 0x19, 0xD1, 0x3F, 0x28, 0x6C, 0x07, 0x96, 0xEB, 0xE8, 0x4F, 0xB8,
+    0x4A, 0x7D, 0x84, 0xF0, 0xCA, 0x7F, 0x75, 0x3D, 0x02, 0xE9, 0x0E, 0x83,
+    0x06, 0x32, 0x08, 0x2E, 0x00, 0x52, 0x76, 0xD9, 0x47, 0x28, 0x92, 0x9F,
+    0x36, 0xAE, 0xB0, 0xE8, 0x94, 0x8C, 0xEA, 0x68, 0xF7, 0xD9, 0x06, 0x3E,
+    0xB8, 0xC1, 0xAB, 0xFD, 0x02, 0x4B, 0xC2, 0xB1, 0xED, 0xC0, 0xF4, 0xDD,
+    0xC1, 0x0F, 0xA8, 0xDC, 0x81, 0x11, 0x48, 0x36, 0xD7, 0x83, 0x10, 0xE4,
+    0x23, 0x92, 0x84, 0xD5, 0x4A, 0xB4, 0x38, 0xC0, 0x6C, 0xFB, 0x41, 0x0F,
+    0xAE, 0xBB, 0x69, 0xD2, 0xA0, 0xE2, 0x29, 0x8C, 0x8C, 0x73, 0x91, 0x09,
+    0x50, 0x49, 0x69, 0xEB, 0x3B, 0xCE, 0x36, 0x90, 0x01, 0xCC, 0x48, 0x82,
+    0xB6, 0x05, 0x08, 0x7C, 0x01, 0x22, 0x18, 0x0D, 0x2C, 0x5D, 0xA5, 0x8A,
+    0x7A, 0x2F, 0xA6, 0x07, 0xBD, 0x15, 0x85, 0x9A, 0xC4, 0x4D, 0xEE, 0x48,
+    0xEC, 0x0C, 0x12, 0xFD, 0x48, 0xA9, 0x25, 0x3E, 0x30, 0x83, 0x00, 0xE3,
+    0xE0, 0x06, 0x3B, 0xD8, 0xA8, 0x2C, 0x1A, 0x3E, 0xEE, 0x00, 0x28, 0x52,
+    0xE1, 0x4B, 0xCE, 0x6E, 0x34, 0xF7, 0x8D, 0xF2, 0x0D, 0xF7, 0xE0, 0x06,
+    0x85, 0xF5, 0x87, 0x9A, 0x60, 0x90, 0x6C, 0x91, 0x9B, 0x06, 0x2D, 0x2D,
+    0x32, 0x76, 0xFE, 0x5E, 0x6A, 0xE0, 0x6A, 0x2A, 0x43, 0x40, 0x04, 0x3F,
+    0x8B, 0x78, 0x00, 0xE6, 0xA3, 0xE5, 0x24, 0xF5, 0xB2, 0x10, 0xC0, 0x62,
+    0x01, 0x78, 0xD2, 0xE2, 0x03, 0x66, 0xD3, 0xC2, 0x06, 0x31, 0xBB, 0x38,
+    0xBD, 0x51, 0x9D, 0xE0, 0x01, 0x3C, 0x38, 0xE5, 0x54, 0x7F, 0xA9, 0x0E,
+    0x64, 0xD0, 0x72, 0xF8, 0xBD, 0x60, 0x06, 0x0F, 0x08, 0xB9, 0x24, 0xE8,
+    0x17, 0x8C, 0x1B, 0x78, 0x7C, 0x31, 0xFF, 0x0E, 0x06, 0x0A, 0x5E, 0xB0,
+    0x80, 0x11, 0x3C, 0xA0, 0xD1, 0xC3, 0xFA, 0xCE, 0x7B, 0xB4, 0x42, 0xA7,
+    0x07, 0xCC, 0x72, 0x18, 0x2B, 0xB8, 0x41, 0xB1, 0x9D, 0x91, 0x32, 0xFD,
+    0x7A, 0xFA, 0x29, 0xF3, 0x45, 0x75, 0x84, 0x6C, 0x5A, 0xF5, 0xC0, 0x87,
+    0xB3, 0x06, 0xAE, 0xAC, 0x17, 0x0B, 0x20, 0x6E, 0x95, 0xC5, 0xAA, 0x22,
+    0xD3, 0x8B, 0x11, 0xB1, 0x5C, 0x0E, 0xD0, 0xA3, 0x81, 0x4B, 0x7E, 0xF2,
+    0x69, 0x5F, 0xBB, 0xF0, 0xA0, 0xFB, 0x08, 0x8B, 0xC8, 0x38, 0x00, 0x30,
+    0x30, 0xFA, 0xB0, 0x49, 0xDE, 0x0C, 0x1F, 0x04, 0x43, 0xB2, 0xBD, 0x62,
+    0x9B, 0xCD, 0x97, 0xBC, 0x97, 0x10, 0x40, 0x5B, 0xF0, 0xAC, 0xD7, 0x5C,
+    0x0F, 0xCA, 0xCE, 0x69, 0x5C, 0x9B, 0x45, 0xF1, 0x8B, 0xE7, 0xF6, 0x46,
+    0x4E, 0x74, 0x1E, 0x00, 0x4E, 0xDE, 0xD2, 0xA1, 0x82, 0xBC, 0xEE, 0x1F,
+    0x00, 0x7C, 0x9F, 0xF1, 0x68, 0xF8, 0x3B, 0x02, 0xA0, 0xDA, 0x81, 0xFF,
+    0x00, 0x36, 0x91, 0x40, 0x80, 0xEF, 0x99, 0x0F, 0x0A, 0x76, 0x74, 0x69,
+    0x43, 0xD3, 0xC0, 0x07, 0x63, 0x6F, 0xC6, 0x29, 0xE5, 0xCD, 0x5C, 0x76,
+    0x0B, 0x23, 0x07, 0x34, 0xB0, 0x7B, 0xA0, 0xBF, 0x0F, 0xFE, 0xF0, 0xCB,
+    0xA0, 0x07, 0x35, 0xB0, 0xBD, 0xD6, 0xF2, 0xDD, 0xFA, 0xF4, 0x6B, 0xEE,
+    0x31, 0x54, 0x3E, 0x9B, 0xC0, 0xFE, 0x11, 0x0F, 0x9F, 0x07, 0x54, 0x36,
+    0xAC, 0x62, 0x2F, 0x8A, 0x0E, 0xD0, 0x77, 0x58, 0x4A, 0x60, 0xBC, 0xE0,
+    0xD1, 0x0F, 0x25, 0xFC, 0x20, 0x90, 0x3B, 0x0B, 0x44, 0x7B, 0x05, 0x46,
+    0x6C, 0xD5, 0xF7, 0x0C, 0x17, 0xC5, 0x09, 0x92, 0x35, 0x80, 0x22, 0x43,
+    0x03, 0xEE, 0xA6, 0x7E, 0x0F, 0x08, 0x81, 0x19, 0x81, 0x75, 0x1E, 0xB5,
+    0x30, 0x2D, 0x76, 0x74, 0x4A, 0x72, 0x7A, 0xF2, 0x10, 0x03, 0x9E, 0x11,
+    0x3F, 0x44, 0x54, 0x7C, 0xF7, 0xF5, 0x01, 0x30, 0x40, 0x70, 0x10, 0x70,
+    0x81, 0xFE, 0x17, 0x0C, 0xE9, 0xB6, 0x0F, 0xDB, 0xC7, 0x03, 0x3B, 0x50,
+    0x03, 0x06, 0x08, 0x0F, 0x0D, 0x27, 0x00, 0xBC, 0xF6, 0x08, 0x05, 0x93,
+    0x0E, 0x28, 0xC0, 0x73, 0x2F, 0x40, 0x82, 0x14, 0x52, 0x77, 0x3E, 0x50,
+    0x7E, 0x11, 0xE8, 0x83, 0x3F, 0x48, 0x0B, 0xF7, 0x17, 0x0C, 0x32, 0x33,
+    0x55, 0x1F, 0x10, 0x40, 0xC3, 0x80, 0x03, 0x3B, 0x60, 0x7E, 0xCD, 0xD0,
+    0x5B, 0x29, 0x35, 0x03, 0x2C, 0x50, 0x59, 0x28, 0x58, 0x0A, 0x09, 0x10,
+    0x7C, 0xDA, 0x57, 0x2E, 0x5A, 0x16, 0x00, 0x42, 0xC2, 0x03, 0x2E, 0x38,
+    0x0F, 0xAA, 0x42, 0x66, 0x94, 0xA0, 0x78, 0x10, 0x70, 0x7C, 0x65, 0xA6,
+    0x6C, 0xC8, 0xE7, 0x62, 0xC5, 0xC0, 0x03, 0x00, 0x02, 0x84, 0x6B, 0xE8,
+    0x83, 0xEF, 0x25, 0x00, 0x71, 0x53, 0x62, 0x09, 0x50, 0x69, 0x47, 0xB7,
+    0x02, 0x18, 0xD1, 0x85, 0x7F, 0xB5, 0x00, 0xC8, 0xC2, 0x09, 0x56, 0xD6,
+    0x2F, 0x73, 0x83, 0x03, 0xE2, 0x07, 0x88, 0x81, 0x28, 0x68, 0xA2, 0x70,
+    0x6B, 0x90, 0x40, 0x19, 0x38, 0xC0, 0x85, 0xF3, 0x80, 0x7B, 0x08, 0x41,
+    0x09, 0x08, 0x07, 0x40, 0x31, 0x17, 0x10, 0xC8, 0x37, 0x03, 0xC3, 0xE7,
+    0x87, 0x2B, 0xB8, 0x84, 0x6C, 0x88, 0x89, 0x7D, 0xFE, 0xD6, 0x03, 0xE8,
+    0x44, 0x4B, 0x11, 0x47, 0x02, 0xEC, 0xC6, 0x03, 0x97, 0xB8, 0x74, 0x59,
+    0x67, 0x58, 0x22, 0x00, 0x03, 0x07, 0xA3, 0x1A, 0x7A, 0x37, 0x85, 0xC5,
+    0xA2, 0x74, 0xCC, 0x10, 0x23, 0x60, 0xF1, 0x1E, 0xAE, 0x02, 0x7A, 0x2A,
+    0xF1, 0x03, 0x72, 0x42, 0x09, 0x2C, 0xA2, 0x8A, 0xA7, 0x81, 0x71, 0xD3,
+    0x65, 0x89, 0x99, 0xE8, 0x8B, 0xD1, 0x76, 0x7D, 0xFA, 0x91, 0x23, 0x62,
+    0x81, 0x02, 0x24, 0x36, 0x11, 0x95, 0x26, 0x0C, 0xC8, 0xC4, 0x51, 0xED,
+    0x67, 0x58, 0x0B, 0x44, 0x02, 0x4E, 0x41, 0x28, 0x10, 0x60, 0x8C, 0x98,
+    0x40, 0x3F, 0x6A, 0xE1, 0x0E, 0x3A, 0x80, 0x79, 0x90, 0x10, 0x58, 0x6B,
+    0x11, 0x6F, 0xAB, 0xC2, 0x5C, 0x07, 0x70, 0x43, 0x03, 0xF3, 0x65, 0xC2,
+    0xC0, 0x78, 0xBF, 0x68, 0x8E, 0x1B, 0xC6, 0x74, 0x67, 0x03, 0x89, 0x9F,
+    0x70, 0x84, 0x29, 0x42, 0x86, 0x01, 0x41, 0x02, 0xF3, 0xC7, 0x44, 0xCD,
+    0x20, 0x2B, 0xC2, 0x80, 0x27, 0x81, 0x44, 0x0C, 0xD3, 0x48, 0x8D, 0xEC,
+    0x91, 0x81, 0xB6, 0x30, 0x4E, 0x64, 0x11, 0x09, 0x98, 0x61, 0x8D, 0x44,
+    0xB1, 0x81, 0xC3, 0xD0, 0x65, 0x33, 0xF0, 0x3A, 0x9F, 0x90, 0x00, 0xBF,
+    0xC7, 0x76, 0x96, 0x60, 0x81, 0x8A, 0x80, 0x03, 0x76, 0x78, 0x8E, 0x13,
+    0x99, 0x54, 0x8B, 0x88, 0x85, 0xA7, 0xF0, 0x8C, 0x73, 0xB3, 0x79, 0xA7,
+    0x91, 0x43, 0x99, 0xD1, 0x8A, 0xB2, 0x90, 0x68, 0xED, 0x02, 0x01, 0xC9,
+    0xF6, 0x01, 0xF3, 0x07, 0x40, 0xFA, 0xA8, 0x90, 0x9B, 0xF0, 0x42, 0xCE,
+    0x50, 0x8B, 0xC9, 0x82, 0x8F, 0x02, 0xD0, 0x77, 0x43, 0xB1, 0x89, 0xA2,
+    0x80, 0x76, 0x28, 0x19, 0x00, 0x32, 0xE8, 0x90, 0xE7, 0x21, 0x7B, 0xA1,
+    0xA1, 0x87, 0x02, 0xF0, 0x91, 0x14, 0x09, 0x94, 0x1F, 0xD4, 0x92, 0xFE,
+    0x6A, 0x42, 0x79, 0x93, 0xB7, 0x62, 0x7A, 0xB2, 0x08, 0x6A, 0xD2, 0x90,
+    0x14, 0x21, 0x24, 0x02, 0xB0, 0x02, 0xB3, 0x08, 0x0B, 0x33, 0x19, 0x11,
+    0x03, 0x36, 0x3C, 0xC2, 0x30, 0x74, 0x03, 0x41, 0x38, 0x12, 0x89, 0x0B,
+    0xA2, 0x67, 0x58, 0x93, 0x00, 0x11, 0xFD, 0x28, 0x0F, 0x2D, 0x79, 0x55,
+    0x5E, 0x97, 0x00, 0x5E, 0x77, 0x52, 0xC4, 0x70, 0x78, 0x66, 0x29, 0x09,
+    0x34, 0x07, 0x96, 0x41, 0xE9, 0x96, 0x9A, 0x03, 0x7B, 0xC5, 0x70, 0x91,
+    0x04, 0x63, 0x3A, 0xEB, 0xA8, 0x8B, 0xD3, 0x05, 0x95, 0x00, 0x10, 0x03,
+    0x62, 0x89, 0x93, 0x8E, 0xB0, 0x27, 0xA2, 0xF0, 0x8E, 0xA5, 0x80, 0x19,
+    0xAB, 0xE0, 0x18, 0x6F, 0xD3, 0x58, 0xCD, 0x25, 0x00, 0x8D, 0x22, 0x14,
+    0xE5, 0x31, 0x16, 0x76, 0x49, 0x11, 0x0F, 0x50, 0x70, 0xF3, 0x17, 0x83,
+    0x36, 0x79, 0x8B, 0xC0, 0xF5, 0x96, 0x97, 0x29, 0x94, 0x72, 0xC1, 0x10,
+    0x93, 0xA0, 0x1A, 0x29, 0xA2, 0x96, 0xA7, 0x31, 0x02, 0x4F, 0xD1, 0x8A,
+    0x3B, 0xE0, 0x19, 0x07, 0xB0, 0x62, 0x61, 0xF8, 0x99, 0xD5, 0x95, 0x08,
+    0x31, 0x39, 0x0B, 0x52, 0xD6, 0x2E, 0xB9, 0x58, 0x44, 0x3F, 0xA0, 0x03,
+    0x35, 0xF0, 0x93, 0xCF, 0x50, 0x8F, 0x9E, 0xA9, 0x2C, 0x54, 0x08, 0x2C,
+    0x3A, 0x74, 0x00, 0x22, 0xE0, 0x98, 0x8E, 0x30, 0x02, 0xFC, 0x88, 0x99,
+    0xC3, 0xA9, 0x3C, 0x42, 0x98, 0x0E, 0x9B, 0x69, 0x28, 0xC8, 0x92, 0x90,
+    0xEB, 0x74, 0x08, 0x50, 0x01, 0x41, 0xD7, 0xC7, 0x08, 0x8D, 0x18, 0x60,
+    0x52, 0x88, 0x24, 0x10, 0x61, 0x80, 0x84, 0x97, 0x3E, 0x60, 0x48, 0x0C,
+    0x39, 0x60, 0x77, 0x3D, 0xF8, 0x0E, 0xBD, 0x35, 0x27, 0x45, 0xF8, 0x02,
+    0xEC, 0x71, 0x76, 0x6C, 0xF7, 0x00, 0x3D, 0x29, 0x1E, 0xC4, 0xA9, 0x9E,
+    0x8A, 0x13, 0xFE, 0x03, 0x3D, 0xC0, 0x8C, 0x89, 0xB0, 0x91, 0x67, 0xA1,
+    0x47, 0xB9, 0x38, 0x30, 0x07, 0x31, 0x8F, 0xAD, 0x80, 0x22, 0x70, 0x78,
+    0x6E, 0x30, 0x30, 0x9E, 0xF5, 0x42, 0x99, 0x58, 0x16, 0x1E, 0xAE, 0x50,
+    0x03, 0xDE, 0x46, 0x03, 0x59, 0xD7, 0x69, 0x01, 0xF0, 0x12, 0x38, 0xC0,
+    0x03, 0xD4, 0x87, 0x77, 0xB8, 0x89, 0x5F, 0x0F, 0x50, 0x2C, 0x1D, 0xC0,
+    0x73, 0x6A, 0xA7, 0x0F, 0x18, 0xD7, 0x93, 0xEC, 0xB3, 0x9E, 0x19, 0xCA,
+    0x9E, 0x6A, 0x74, 0x14, 0xED, 0xF2, 0x51, 0x0B, 0xA9, 0x8E, 0x8A, 0x62,
+    0x19, 0xC8, 0x47, 0xA2, 0x92, 0x88, 0x08, 0x2B, 0xB0, 0x82, 0xAF, 0xD0,
+    0x8D, 0x67, 0x77, 0x8A, 0xC0, 0x37, 0x02, 0x50, 0x28, 0x99, 0x67, 0xB3,
+    0x94, 0x02, 0x61, 0x84, 0x56, 0x48, 0x0C, 0x07, 0x30, 0x97, 0x85, 0x00,
+    0x1C, 0x69, 0xC8, 0x0C, 0xE6, 0x41, 0x9D, 0xEB, 0x84, 0x94, 0xFF, 0x97,
+    0x83, 0x2F, 0x26, 0x03, 0xB5, 0xA9, 0xA1, 0x47, 0xFA, 0x30, 0xEF, 0xF6,
+    0x3E, 0x38, 0x09, 0xA1, 0xD8, 0x17, 0x7F, 0x0B, 0x80, 0x83, 0x36, 0x1A,
+    0x0C, 0x75, 0xA7, 0x86, 0xB0, 0xD0, 0x8D, 0x24, 0xB1, 0x02, 0xE8, 0xB3,
+    0x9C, 0x9E, 0x26, 0x77, 0x91, 0x49, 0x7C, 0x3B, 0x27, 0x70, 0x3B, 0xD9,
+    0x2A, 0x04, 0x27, 0xA5, 0xAB, 0xB2, 0x14, 0xFF, 0x89, 0xA0, 0x57, 0x05,
+    0x48, 0x45, 0x77, 0x81, 0x38, 0xF0, 0x03, 0x3C, 0x68, 0x0B, 0xE6, 0xF1,
+    0x6B, 0x25, 0x46, 0x02, 0x0B, 0x08, 0x15, 0x1C, 0x27, 0x8A, 0x48, 0xAA,
+    0xA7, 0xEA, 0x22, 0x15, 0x28, 0x56, 0x08, 0x7B, 0x72, 0x95, 0x14, 0x91,
+    0x00, 0x4F, 0x38, 0x17, 0x1B, 0x97, 0x74, 0xB6, 0x50, 0x78, 0xC2, 0xB0,
+    0xA0, 0xCF, 0xF2, 0x3E, 0xAF, 0x11, 0x82, 0x50, 0x0A, 0x01, 0xFD, 0x47,
+    0x12, 0x36, 0x28, 0x79, 0x76, 0xFE, 0xAA, 0x47, 0x2F, 0xD0, 0xA2, 0x5D,
+    0x77, 0x0A, 0x2F, 0x00, 0x89, 0x1F, 0x20, 0x77, 0x6D, 0x2A, 0x03, 0x06,
+    0x18, 0x23, 0x33, 0x3A, 0x30, 0xF1, 0xA8, 0xA8, 0x0C, 0xBA, 0xA7, 0xA9,
+    0xAA, 0x3C, 0xBD, 0x05, 0x4B, 0x35, 0x12, 0x8E, 0xD1, 0x25, 0x17, 0x0D,
+    0xF8, 0x6E, 0x43, 0x11, 0x97, 0xD4, 0x90, 0x03, 0x3C, 0xC0, 0x6A, 0xB5,
+    0x4A, 0x0D, 0xCF, 0x37, 0x86, 0x55, 0x45, 0x9F, 0x65, 0x91, 0x00, 0xB3,
+    0x14, 0x7D, 0x3C, 0x0A, 0x0B, 0x05, 0x19, 0x9F, 0x81, 0x02, 0x7F, 0x9C,
+    0x39, 0x37, 0x79, 0xA9, 0xAA, 0xCD, 0xCA, 0x61, 0x02, 0x30, 0x40, 0xFC,
+    0x40, 0x28, 0xA9, 0x79, 0x09, 0x0F, 0xD0, 0x9F, 0xE9, 0xA0, 0xA0, 0x70,
+    0xCA, 0x16, 0xBA, 0xAA, 0x08, 0x69, 0xD8, 0x8A, 0x36, 0xD0, 0x03, 0x82,
+    0x76, 0x6D, 0x55, 0x46, 0x6E, 0x9D, 0x97, 0x8C, 0xE9, 0xD9, 0x0A, 0xEF,
+    0xF3, 0xA3, 0x82, 0x2A, 0x09, 0x45, 0xE4, 0x23, 0x96, 0x80, 0x38, 0x46,
+    0xEA, 0xAC, 0xF3, 0x7A, 0x2A, 0xD7, 0x37, 0x02, 0xCC, 0x22, 0x38, 0xEA,
+    0xD6, 0x73, 0x72, 0xE8, 0x10, 0xDA, 0xB7, 0x02, 0x0D, 0x58, 0x6C, 0xF2,
+    0x7A, 0x26, 0xEF, 0x99, 0x08, 0x39, 0x80, 0xAA, 0xB8, 0x10, 0x43, 0xC2,
+    0xB0, 0xAE, 0x13, 0xC1, 0x02, 0x68, 0x3A, 0x09, 0xB2, 0x34, 0x5D, 0x2B,
+    0x89, 0x9F, 0xF0, 0x59, 0x16, 0x87, 0x00, 0x73, 0xF6, 0x02, 0x09, 0x34,
+    0x38, 0x92, 0x61, 0xA1, 0x0A, 0x02, 0x4B, 0xAF, 0x1F, 0x5B, 0x22, 0xDD,
+    0xF8, 0x14, 0x39, 0xBA, 0x0F, 0xE3, 0x68, 0x30, 0xA9, 0xF4, 0xA3, 0xC1,
+    0x7A, 0x74, 0x6E, 0xDA, 0x96, 0x79, 0x21, 0x65, 0x3C, 0x40, 0x03, 0x31,
+    0x3B, 0x7D, 0x2D, 0xF8, 0x0C, 0xC1, 0x68, 0x8A, 0xF0, 0x91, 0x24, 0x3E,
+    0x42, 0xAD, 0x8F, 0x50, 0x95, 0x17, 0xE1, 0x0A, 0xFE, 0xEF, 0x75, 0x8F,
+    0x56, 0x51, 0x24, 0x63, 0x41, 0x62, 0x97, 0x46, 0xB2, 0x01, 0x40, 0x38,
+    0x84, 0x09, 0xB2, 0x4B, 0xEB, 0x67, 0xC3, 0xD0, 0x97, 0x83, 0x00, 0x99,
+    0x02, 0x34, 0x03, 0x8D, 0x00, 0xA2, 0xC9, 0x16, 0x9A, 0x99, 0x71, 0xB0,
+    0xE6, 0xF3, 0x5E, 0x1B, 0xCB, 0x1F, 0xFE, 0x01, 0x79, 0x0B, 0x30, 0x03,
+    0x3B, 0x3B, 0x08, 0x25, 0xA9, 0x0A, 0x8E, 0x62, 0x9C, 0x86, 0xB5, 0x00,
+    0x81, 0x39, 0x09, 0x7F, 0x49, 0x5D, 0x44, 0xF7, 0x00, 0x2F, 0x8A, 0x10,
+    0x90, 0x88, 0x16, 0xB3, 0xC6, 0xB4, 0x75, 0x5B, 0x22, 0x6C, 0x94, 0xAF,
+    0x8F, 0x00, 0xB1, 0xA6, 0x73, 0x0F, 0xDF, 0xF1, 0x3B, 0x7A, 0x58, 0x77,
+    0x1E, 0xAB, 0x35, 0x71, 0x72, 0xB4, 0x58, 0x81, 0xAF, 0x70, 0xB3, 0x75,
+    0x62, 0x8B, 0x2C, 0xF7, 0x09, 0x00, 0x13, 0xB8, 0x15, 0x6A, 0x1B, 0x4B,
+    0x6F, 0xFB, 0x14, 0x16, 0xC1, 0xB5, 0x7A, 0xDB, 0x8E, 0x2F, 0xA0, 0x4E,
+    0xA3, 0xC1, 0x9A, 0x76, 0xCB, 0xB9, 0xD6, 0xF1, 0x03, 0x5A, 0x7A, 0x6E,
+    0x26, 0x7B, 0x36, 0xFD, 0x43, 0x38, 0x38, 0xF9, 0x01, 0x0D, 0x53, 0x8E,
+    0x4D, 0xC4, 0x95, 0xC7, 0x4A, 0x10, 0xBF, 0x0A, 0xA2, 0xC5, 0x20, 0x02,
+    0x81, 0x1A, 0x09, 0x35, 0x32, 0x90, 0x3F, 0x7B, 0x6D, 0xDC, 0x51, 0x10,
+    0xFE, 0x91, 0x87, 0xDB, 0x61, 0x37, 0x83, 0xAA, 0x47, 0x7C, 0xE8, 0x4B,
+    0xFF, 0xD1, 0xB9, 0xC3, 0x7B, 0x1D, 0x7E, 0xF5, 0x86, 0x8E, 0x00, 0x03,
+    0x03, 0xB8, 0x00, 0x30, 0x90, 0x28, 0xC8, 0x32, 0x4F, 0x3D, 0x9B, 0xBA,
+    0x66, 0xE4, 0x19, 0xA4, 0x6A, 0x09, 0xC1, 0xB2, 0xA5, 0x92, 0x20, 0xBA,
+    0x06, 0xD9, 0x58, 0x9E, 0x1A, 0x7C, 0x7A, 0xB8, 0x4A, 0xB2, 0x10, 0x03,
+    0xDE, 0x26, 0x27, 0x14, 0x2A, 0x10, 0xA2, 0x01, 0x3F, 0xF7, 0x73, 0xFE,
+    0xB5, 0x6F, 0x38, 0x74, 0x94, 0xD1, 0xB2, 0xC4, 0xEB, 0xBE, 0x2A, 0xC1,
+    0x95, 0x2A, 0xD2, 0x62, 0x92, 0x9A, 0x94, 0x00, 0x28, 0x0A, 0xF3, 0x43,
+    0xBB, 0x89, 0x68, 0x3E, 0x8A, 0x50, 0x16, 0x68, 0xD1, 0x81, 0x0E, 0xC9,
+    0x7B, 0xC4, 0xD0, 0x01, 0x5D, 0x05, 0x99, 0xC5, 0xE0, 0x22, 0xB6, 0x30,
+    0x9B, 0xAD, 0x66, 0x76, 0x61, 0x2B, 0x10, 0xE9, 0x3B, 0x43, 0xB0, 0xD1,
+    0x1E, 0x37, 0xC3, 0xBE, 0xEF, 0x4B, 0xC1, 0x8B, 0xC1, 0x09, 0xDA, 0x17,
+    0x66, 0x3E, 0xE0, 0x6A, 0xC5, 0xB0, 0x79, 0x35, 0xC2, 0xAC, 0x29, 0xA4,
+    0x08, 0xBF, 0x7A, 0x0A, 0xF9, 0x41, 0x3C, 0xBA, 0x26, 0x7C, 0x43, 0x4A,
+    0x1A, 0xA7, 0xD8, 0x91, 0x99, 0x21, 0xB3, 0x1F, 0x2C, 0x0B, 0x2B, 0x37,
+    0x84, 0x23, 0x40, 0xBD, 0xFB, 0xC0, 0xB6, 0x6D, 0xA4, 0x10, 0x2B, 0x6C,
+    0x76, 0x2F, 0xA0, 0xA9, 0x5A, 0xD1, 0xBE, 0x15, 0xEC, 0xC3, 0xF0, 0x40,
+    0x8A, 0x6C, 0x13, 0xB3, 0x1B, 0x85, 0x73, 0x73, 0x44, 0x08, 0xFD, 0x20,
+    0x56, 0xFD, 0xD4, 0x84, 0x0B, 0x6B, 0x0A, 0x30, 0x50, 0x2C, 0x9D, 0x78,
+    0x0A, 0xD9, 0x2B, 0x0C, 0x3F, 0x30, 0x7E, 0xC2, 0xD5, 0x03, 0xB5, 0x86,
+    0x10, 0x3D, 0xF7, 0x09, 0x7E, 0xD2, 0x1E, 0xDD, 0xB1, 0x10, 0x25, 0x58,
+    0x2F, 0x2A, 0x99, 0xA7, 0x3F, 0x4C, 0xC6, 0xCC, 0xB0, 0x46, 0x3C, 0x98,
+    0x46, 0xFA, 0xEB, 0x86, 0x02, 0x40, 0x0A, 0xE6, 0x9B, 0x03, 0x82, 0x6B,
+    0x3E, 0x7B, 0x39, 0x17, 0x1D, 0xF0, 0x70, 0xEF, 0x68, 0xAE, 0x6F, 0x28,
+    0xC2, 0x91, 0x50, 0xA7, 0xE0, 0xA1, 0xB4, 0x42, 0xB1, 0x03, 0x37, 0xD0,
+    0x2E, 0xC5, 0xA5, 0x96, 0xAF, 0xBB, 0x08, 0x60, 0x71, 0xA1, 0x34, 0xB0,
+    0x46, 0xE3, 0xBA, 0x48, 0x65, 0xCC, 0xC8, 0x0F, 0x72, 0x9B, 0x85, 0xD2,
+    0x99, 0x74, 0xFE, 0xCB, 0x57, 0x89, 0xFA, 0x12, 0x1D, 0xA0, 0xC3, 0x0E,
+    0x59, 0x23, 0x44, 0x78, 0x0A, 0x2A, 0xDB, 0xB1, 0x6C, 0x61, 0x03, 0x2C,
+    0x47, 0x93, 0x33, 0xEA, 0xC0, 0xC4, 0x80, 0x03, 0x55, 0x0A, 0x00, 0x3A,
+    0xF0, 0xB9, 0xAA, 0x50, 0x7F, 0x8D, 0xCC, 0xCA, 0xD6, 0xE1, 0x19, 0xAC,
+    0x41, 0x38, 0xDF, 0xBB, 0x61, 0x94, 0x3C, 0x17, 0x87, 0xE7, 0x10, 0x62,
+    0x81, 0x1E, 0xA1, 0x71, 0x84, 0x7F, 0x68, 0x22, 0x8E, 0x1B, 0x83, 0xBF,
+    0x79, 0xBA, 0xC4, 0xB0, 0xA0, 0x63, 0xDC, 0xCA, 0xC5, 0x6C, 0xC1, 0xF5,
+    0x81, 0x2C, 0x20, 0xB6, 0x61, 0x62, 0x39, 0x0C, 0xDC, 0x27, 0xB3, 0x05,
+    0x5A, 0x0C, 0x28, 0xF0, 0xAB, 0x87, 0x80, 0xB1, 0xE5, 0x8B, 0x2C, 0x9B,
+    0x5B, 0x14, 0x9F, 0x9C, 0x4E, 0x98, 0xC0, 0xB6, 0x6D, 0x63, 0xCC, 0xDF,
+    0x5C, 0x26, 0x8B, 0x50, 0xB0, 0xC4, 0x5C, 0x4A, 0xB3, 0xF9, 0x67, 0x60,
+    0x69, 0x03, 0x03, 0xCA, 0x6A, 0xED, 0x82, 0xA3, 0x92, 0x15, 0x2C, 0x9A,
+    0x8C, 0x91, 0xEC, 0xE1, 0xC2, 0x1B, 0x71, 0x75, 0x7D, 0x2A, 0xBB, 0x44,
+    0x37, 0x5D, 0xA6, 0x0C, 0xCE, 0xFB, 0x6C, 0x1D, 0xAD, 0x03, 0x6A, 0x40,
+    0x68, 0x03, 0xDF, 0x16, 0xA2, 0x9C, 0x79, 0x00, 0xA6, 0xB9, 0x28, 0x4E,
+    0x09, 0xC7, 0x8A, 0x38, 0x81, 0x1D, 0xF0, 0x8E, 0xED, 0x28, 0xBC, 0xFC,
+    0x0C, 0xD1, 0xD5, 0xC1, 0x7E, 0xB2, 0xE9, 0x8B, 0x3B, 0x40, 0x2F, 0x24,
+    0x7B, 0x10, 0x79, 0x23, 0x7F, 0xCB, 0x1B, 0x72, 0x07, 0x51, 0xBB, 0x8B,
+    0xC1, 0x98, 0x31, 0x48, 0x96, 0x0D, 0x93, 0xD0, 0x11, 0x6D, 0xD2, 0x20,
+    0x1B, 0x23, 0xFF, 0x1B, 0x09, 0x07, 0xA1, 0x3E, 0x66, 0xC7, 0x02, 0x5C,
+    0x87, 0x59, 0x1A, 0x55, 0x1D, 0x72, 0xA4, 0x9F, 0x94, 0x40, 0x3F, 0xFF,
+    0x7C, 0xD2, 0x39, 0x4D, 0xC1, 0xFE, 0xA7, 0x54, 0xD3, 0x7A, 0x6B, 0x11,
+    0xC1, 0xD3, 0x94, 0xAB, 0x82, 0xA9, 0x88, 0xE4, 0xB3, 0xD5, 0x11, 0xD2,
+    0x4C, 0xBC, 0x0F, 0xEC, 0xA1, 0xCC, 0x3A, 0xCD, 0xD4, 0x9C, 0x9B, 0xB0,
+    0x36, 0x7C, 0x6E, 0x88, 0x90, 0x2F, 0x41, 0x7D, 0xA3, 0x00, 0x34, 0x1B,
+    0xAB, 0x19, 0x20, 0xEF, 0x13, 0x9E, 0xFD, 0x5A, 0xD4, 0x4D, 0xED, 0xD5,
+    0x76, 0x5B, 0x90, 0x77, 0x72, 0x3F, 0x7E, 0xC3, 0x15, 0x4F, 0x81, 0x03,
+    0xCF, 0x1C, 0x97, 0xC2, 0x19, 0x20, 0x2B, 0x94, 0xCB, 0x5C, 0x2D, 0x00,
+    0xFA, 0xFB, 0xD5, 0x71, 0x8D, 0xA4, 0xEF, 0xD5, 0xD6, 0xB1, 0x54, 0x52,
+    0x05, 0xAB, 0xCF, 0x00, 0x20, 0x95, 0xC4, 0x50, 0xD2, 0xF4, 0x35, 0x2B,
+    0xD5, 0xCC, 0x5C, 0x02, 0x29, 0xD7, 0x83, 0xFD, 0xB1, 0x4F, 0xAD, 0x36,
+    0x41, 0xD2, 0xAD, 0xB6, 0x97, 0xC8, 0x8A, 0x70, 0x03, 0x79, 0x6D, 0x1D,
+    0x1D, 0x15, 0x83, 0x0E, 0x39, 0xC1, 0x84, 0x4D, 0xD9, 0xAA, 0x0A, 0xD9,
+    0x5D, 0x66, 0x11, 0x7D, 0x4C, 0x36, 0x4B, 0x6A, 0x09, 0x5E, 0x81, 0xCD,
+    0x95, 0x0D, 0xDA, 0x19, 0xCA, 0x95, 0x4F, 0x3B, 0x1F, 0xDE, 0xAC, 0x38,
+    0xA4, 0x09, 0xAD, 0xF4, 0x89, 0x08, 0xF3, 0x1C, 0xDA, 0xAD, 0x0D, 0x94,
+    0xA7, 0xA4, 0x8A, 0xA3, 0xD1, 0xC3, 0xD0, 0x92, 0x1D, 0x34, 0x69, 0x2B,
+    0xE6, 0xEB, 0x93, 0xAE, 0xAD, 0xDB, 0xA2, 0x9D, 0x08, 0xC6, 0xE8, 0x2A,
+    0x12, 0xCB, 0x9E, 0xCC, 0x0C, 0x79, 0xC3, 0x07, 0x11, 0xB2, 0xBC, 0xDB,
+    0xC7, 0x8D, 0x99, 0x31, 0x32, 0x74, 0x35, 0x62, 0x3E, 0x45, 0x5C, 0x0C,
+    0x4F, 0x89, 0xDC, 0xD1, 0x3D, 0x9C, 0x31, 0x02, 0xCF, 0x50, 0x6B, 0x99,
+    0x71, 0xBC, 0x03, 0xE2, 0x37, 0xAB, 0xD2, 0xCD, 0xDD, 0x6F, 0x19, 0x23,
+    0xD1, 0xE9, 0x08, 0x98, 0xC1, 0xB8, 0xDD, 0x4D, 0xEE, 0xDE, 0xE5, 0xED,
+    0x0A, 0x5C, 0x69, 0x58, 0xF6, 0x81, 0xC4, 0xE4, 0x6C, 0xDE, 0xED, 0x4D,
+    0xD8, 0x35, 0x50, 0x9A, 0x3B, 0xC7, 0x9F, 0x8A, 0x30, 0xDB, 0xEE, 0x6D,
+    0xDF, 0x84, 0x2D, 0xC7, 0xA4, 0x7C, 0xDF, 0xFB, 0xDD, 0xDD, 0x36, 0x50,
+    0x76, 0x4B, 0xCD, 0xDF, 0x01, 0xEE, 0xDA, 0x16, 0x0D, 0x91, 0x7D, 0x2D,
+    0xE0, 0x07, 0x9E, 0xD3, 0x3A, 0xB0, 0x6A, 0xEC, 0x8D, 0xE0, 0x0D, 0xEE,
+    0xE0, 0x0F, 0x0E, 0xE1, 0x11, 0x2E, 0xE1, 0x13, 0x4E, 0xE1, 0x15, 0x6E,
+    0xE1, 0x17, 0x8E, 0xE1, 0x19, 0xAE, 0xE1, 0x1B, 0xCE, 0xE1, 0x1D, 0xEE,
+    0xE1, 0x1F, 0x0E, 0xE2, 0x21, 0x2E, 0xE2, 0x23, 0x4E, 0xE2, 0x25, 0x6E,
+    0xE2, 0x27, 0x8E, 0xE2, 0x29, 0xAE, 0xE2, 0x2B, 0xCE, 0xE2, 0x2D, 0xEE,
+    0xE2, 0x2F, 0x0E, 0xE3, 0x31, 0x2E, 0xE3, 0x33, 0x4E, 0xE3, 0x35, 0x6E,
+    0xE3, 0x37, 0x8E, 0xE3, 0x39, 0xAE, 0xE3, 0x3B, 0xCE, 0xE3, 0x3D, 0xEE,
+    0xE3, 0x3F, 0x0E, 0xE4, 0x41, 0x2E, 0xE4, 0x43, 0x4E, 0xE4, 0x45, 0x6E,
+    0xE4, 0x47, 0x8E, 0xE4, 0x49, 0xAE, 0xE4, 0x4B, 0xCE, 0xE4, 0x4D, 0xEE,
+    0xE4, 0x4F, 0x0E, 0xE5, 0x51, 0x2E, 0xE5, 0x53, 0x4E, 0xE5, 0x55, 0x6E,
+    0xE5, 0x57, 0x8E, 0xE5, 0x59, 0xAE, 0xE5, 0x5B, 0xCE, 0xE5, 0x5D, 0xEE,
+    0xE5, 0x5F, 0x0E, 0xE6, 0x61, 0x2E, 0xE6, 0x63, 0x4E, 0xE6, 0x65, 0x6E,
+    0xE6, 0x67, 0x8E, 0xE6, 0x69, 0xAE, 0xE6, 0x6B, 0xCE, 0xE6, 0x6D, 0xEE,
+    0xE6, 0x6F, 0x0E, 0xE7, 0x71, 0x2E, 0xE7, 0x73, 0x4E, 0xE7, 0x75, 0x6E,
+    0xE7, 0x77, 0x8E, 0xE7, 0x79, 0xAE, 0xE7, 0x7B, 0xCE, 0xE7, 0x7D, 0xEE,
+    0xE7, 0x7F, 0x0E, 0xE8, 0x26, 0x13, 0x08, 0x00, 0x3B,
   };
 
 #define NetscapeImageExtent  9788
@@ -4019,10 +4019,10 @@ static const unsigned char
 static const unsigned char
   OctagonsImage[]=
   {
-    0x50, 0x34, 0x0A, 0x31, 0x36, 0x20, 0x31, 0x36, 0x0A, 0x07, 0xF0, 0x08, 
-    0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x01, 0x80, 0x00, 0x80, 0x00, 0x80, 
-    0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x40, 0x01, 0x20, 
-    0x02, 0x10, 0x04, 0x08, 0x08, 
+    0x50, 0x34, 0x0A, 0x31, 0x36, 0x20, 0x31, 0x36, 0x0A, 0x07, 0xF0, 0x08,
+    0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x01, 0x80, 0x00, 0x80, 0x00, 0x80,
+    0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x40, 0x01, 0x20,
+    0x02, 0x10, 0x04, 0x08, 0x08,
   };
 
 /*
@@ -4033,7 +4033,7 @@ static const unsigned char
 static const unsigned char
   Right30Image[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x34, 0x0A, 0x03, 0x0C, 0x30, 0xC0, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x34, 0x0A, 0x03, 0x0C, 0x30, 0xC0,
   };
 
 /*
@@ -4044,8 +4044,8 @@ static const unsigned char
 static const unsigned char
   Right45Image[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x01, 0x02, 0x04, 0x08, 0x10, 
-    0x20, 0x40, 0x80, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x01, 0x02, 0x04, 0x08, 0x10,
+    0x20, 0x40, 0x80,
   };
 
 /*
@@ -4056,13 +4056,13 @@ static const unsigned char
 static const unsigned char
   RightShingleImage[]=
   {
-    0x50, 0x34, 0x0A, 0x32, 0x34, 0x20, 0x32, 0x34, 0x0A, 0x00, 0x00, 0x08, 
-    0x00, 0x00, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x02, 
-    0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0x00, 0x08, 0x00, 
-    0x00, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x02, 0x00, 
-    0x00, 0x02, 0x00, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0x08, 0x00, 0x00, 
-    0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x02, 0x00, 0x00, 
-    0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 
+    0x50, 0x34, 0x0A, 0x32, 0x34, 0x20, 0x32, 0x34, 0x0A, 0x00, 0x00, 0x08,
+    0x00, 0x00, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x02,
+    0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0x00, 0x08, 0x00,
+    0x00, 0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x02, 0x00,
+    0x00, 0x02, 0x00, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0xFF, 0x08, 0x00, 0x00,
+    0x08, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x02, 0x00, 0x00,
+    0x02, 0x00, 0x00, 0x01, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
   };
 
 /*
@@ -4890,8 +4890,8 @@ static const unsigned char
 static const unsigned char
   SmallFishScalesImage[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x80, 0x80, 0x41, 0x36, 0x08, 
-    0x08, 0x14, 0x63, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x80, 0x80, 0x41, 0x36, 0x08,
+    0x08, 0x14, 0x63,
   };
 
 /*
@@ -4902,15 +4902,15 @@ static const unsigned char
 static const unsigned char
   CheckerboardImage[]=
   {
-    0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x1E, 0x00, 0x1E, 0x00, 0xF0, 0x01, 
-    0x00, 0x66, 0x66, 0x66, 0x99, 0x99, 0x99, 0x21, 0xF9, 0x04, 0x00, 0x00, 
-    0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x1E, 0x00, 
-    0x00, 0x02, 0x42, 0x8C, 0x8F, 0x09, 0xCB, 0xED, 0x09, 0x91, 0x9B, 0x2D, 
-    0x5A, 0x8A, 0x6D, 0xC4, 0x54, 0x43, 0x3E, 0x79, 0x0A, 0x58, 0x89, 0x07, 
-    0x59, 0x9A, 0x01, 0xCA, 0xA8, 0x06, 0xBB, 0xB8, 0x2B, 0x2C, 0xC3, 0x40, 
-    0x4D, 0xBB, 0x36, 0xCE, 0xF2, 0xA8, 0x6F, 0xFB, 0xA9, 0x82, 0xBA, 0xDD, 
-    0xD0, 0x68, 0x22, 0x1E, 0x73, 0x49, 0xA4, 0x48, 0xD9, 0x64, 0x3E, 0x9D, 
-    0x1E, 0xE8, 0x54, 0x5A, 0xA5, 0x6A, 0xAC, 0x9E, 0x02, 0x00, 0x3B, 
+    0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x1E, 0x00, 0x1E, 0x00, 0xF0, 0x01,
+    0x00, 0x66, 0x66, 0x66, 0x99, 0x99, 0x99, 0x21, 0xF9, 0x04, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x1E, 0x00,
+    0x00, 0x02, 0x42, 0x8C, 0x8F, 0x09, 0xCB, 0xED, 0x09, 0x91, 0x9B, 0x2D,
+    0x5A, 0x8A, 0x6D, 0xC4, 0x54, 0x43, 0x3E, 0x79, 0x0A, 0x58, 0x89, 0x07,
+    0x59, 0x9A, 0x01, 0xCA, 0xA8, 0x06, 0xBB, 0xB8, 0x2B, 0x2C, 0xC3, 0x40,
+    0x4D, 0xBB, 0x36, 0xCE, 0xF2, 0xA8, 0x6F, 0xFB, 0xA9, 0x82, 0xBA, 0xDD,
+    0xD0, 0x68, 0x22, 0x1E, 0x73, 0x49, 0xA4, 0x48, 0xD9, 0x64, 0x3E, 0x9D,
+    0x1E, 0xE8, 0x54, 0x5A, 0xA5, 0x6A, 0xAC, 0x9E, 0x02, 0x00, 0x3B,
   };
 
 /*
@@ -4921,8 +4921,8 @@ static const unsigned char
 static const unsigned char
   VerticalImage[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x11, 0x11, 0x11, 0x11, 0x11, 
-    0x11, 0x11, 0x11, 
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x38, 0x0A, 0x11, 0x11, 0x11, 0x11, 0x11,
+    0x11, 0x11, 0x11,
   };
 
 /*
@@ -4933,10 +4933,10 @@ static const unsigned char
 static const unsigned char
   VerticalBricksImage[]=
   {
-    0x50, 0x34, 0x0A, 0x31, 0x36, 0x20, 0x31, 0x36, 0x0A, 0xFF, 0x01, 0x01, 
-    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 
-    0x01, 0x01, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 
-    0x01, 0x01, 0x01, 0x01, 0x01, 
+    0x50, 0x34, 0x0A, 0x31, 0x36, 0x20, 0x31, 0x36, 0x0A, 0xFF, 0x01, 0x01,
+    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+    0x01, 0x01, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+    0x01, 0x01, 0x01, 0x01, 0x01,
   };
 
 /*
@@ -4947,13 +4947,13 @@ static const unsigned char
 static const unsigned char
   VerticalLeftShingleImage[]=
   {
-    0x50, 0x34, 0x0A, 0x32, 0x34, 0x20, 0x32, 0x34, 0x0A, 0x01, 0x01, 0x01, 
-    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81, 
-    0x01, 0x01, 0x61, 0x01, 0x01, 0x19, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01, 
-    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81, 0x01, 
-    0x01, 0x61, 0x01, 0x01, 0x19, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01, 0x01, 
-    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81, 0x01, 0x01, 
-    0x61, 0x01, 0x01, 0x19, 0x01, 0x01, 0x07, 0x01, 0x01, 
+    0x50, 0x34, 0x0A, 0x32, 0x34, 0x20, 0x32, 0x34, 0x0A, 0x01, 0x01, 0x01,
+    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81,
+    0x01, 0x01, 0x61, 0x01, 0x01, 0x19, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01,
+    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81, 0x01,
+    0x01, 0x61, 0x01, 0x01, 0x19, 0x01, 0x01, 0x07, 0x01, 0x01, 0x01, 0x01,
+    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x81, 0x01, 0x01,
+    0x61, 0x01, 0x01, 0x19, 0x01, 0x01, 0x07, 0x01, 0x01,
   };
 
 /*
@@ -4964,13 +4964,13 @@ static const unsigned char
 static const unsigned char
   VerticalRightShingleImage[]=
   {
-    0x50, 0x34, 0x0A, 0x32, 0x34, 0x20, 0x32, 0x34, 0x0A, 0x01, 0x01, 0x01, 
-    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 
-    0x01, 0x0D, 0x01, 0x01, 0x31, 0x01, 0x01, 0xC1, 0x01, 0x01, 0x01, 0x01, 
-    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 
-    0x01, 0x01, 0x0D, 0x01, 0x01, 0x31, 0x01, 0x01, 0xC1, 0x01, 0x01, 0x01, 
-    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 
-    0x0D, 0x01, 0x01, 0x31, 0x01, 0x01, 0xC1, 0x01, 0x01, 
+    0x50, 0x34, 0x0A, 0x32, 0x34, 0x20, 0x32, 0x34, 0x0A, 0x01, 0x01, 0x01,
+    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01,
+    0x01, 0x0D, 0x01, 0x01, 0x31, 0x01, 0x01, 0xC1, 0x01, 0x01, 0x01, 0x01,
+    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03,
+    0x01, 0x01, 0x0D, 0x01, 0x01, 0x31, 0x01, 0x01, 0xC1, 0x01, 0x01, 0x01,
+    0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x03, 0x01, 0x01,
+    0x0D, 0x01, 0x01, 0x31, 0x01, 0x01, 0xC1, 0x01, 0x01,
   };
 
 /*
@@ -4981,17 +4981,17 @@ static const unsigned char
 static const unsigned char
   VerticalSawImage[]=
   {
-    0x50, 0x34, 0x0A, 0x38, 0x20, 0x31, 0x36, 0x0A, 0x40, 0x20, 0x10, 0x08, 
-    0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x08, 0x10, 0x20, 0x40, 0x80,    
+    0x50, 0x34, 0x0A, 0x38, 0x20, 0x31, 0x36, 0x0A, 0x40, 0x20, 0x10, 0x08,
+    0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x08, 0x10, 0x20, 0x40, 0x80,
   };
 
 \f
 typedef struct _EmbeddedImage
 {
   char          name[MaxTextExtent];    /* image name */
-  char          magick[MaxTextExtent]; /* blob format */
-  const void   *blob;                  /* blob data */
-  size_t        extent;                        /* blob size */
+  char          magick[MaxTextExtent];  /* blob format */
+  const void   *blob;                   /* blob data */
+  size_t        extent;                 /* blob size */
 } EmbeddedImage;
 
 static const EmbeddedImage EmbeddedImageList[]=
index ce999e7..e483748 100644 (file)
@@ -13,7 +13,7 @@
 %                            MM MM  A   A  C                                  %
 %                            M M M  AAAAA  C                                  %
 %                            M   M  A   A  C                                  %
-%                            M   M  A   A   CCC                              %                              %
+%                            M   M  A   A   CCC                               %                              %
 %                                                                             %
 %                Read MAC: MacPaint Image Format.                                     %
 %                                                                             %
@@ -77,7 +77,7 @@
 static Image *ReadMACImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
   Image *image;
-  unsigned int y;  
+  unsigned int y;
   unsigned char x8, rep, b;
   long ldblk;
   unsigned char *BImgBuff = NULL;
@@ -85,7 +85,7 @@ static Image *ReadMACImage(const ImageInfo *image_info,ExceptionInfo *exception)
   unsigned int status;
   const PixelPacket *q;
 
-       /* Open image file. */
+        /* Open image file. */
   assert(image_info != (const ImageInfo *) NULL);
   assert(image_info->signature == MagickSignature);
   assert(exception != (ExceptionInfo *) NULL);
@@ -95,15 +95,15 @@ static Image *ReadMACImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if(status == False)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
 
-       /* Read MAC image. */
+        /* Read MAC image. */
   ldblk = ReadBlobLSBShort(image);
   if((ldblk & 0xFF)!=0)
-       ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+        ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
 
-  if(ldblk==0)         /* ???? don't know why */
-       SeekBlob(image,0x200,SEEK_SET);
+  if(ldblk==0)          /* ???? don't know why */
+        SeekBlob(image,0x200,SEEK_SET);
   else
-       SeekBlob(image,0x280,SEEK_SET);
+        SeekBlob(image,0x280,SEEK_SET);
 
   image->columns = 576;
   image->rows = 720;
@@ -121,8 +121,8 @@ static Image *ReadMACImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if(BImgBuff==NULL)
     NoMemory:
       ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-  
-  DataPtr = BImgBuff;  
+
+  DataPtr = BImgBuff;
   x8=0; y=0;
 
   while(y<image->rows)
@@ -141,21 +141,21 @@ static Image *ReadMACImage(const ImageInfo *image_info,ExceptionInfo *exception)
         x8++;
         rep--;
         if(x8>=ldblk)
-       {
-         x8=0;
+        {
+          x8=0;
 
           q = SetImagePixels(image,0,y,image->columns,1);
           if(q == (PixelPacket *)NULL) break;
           (void)ImportImagePixelArea(image,GrayQuantum,1,BImgBuff,NULL,0);
           if(!SyncImagePixels(image)) break;
 
-         DataPtr = BImgBuff;
-         y++;
-         if(y>=image->rows)
-         {
-           break;          
-         }
-       }
+          DataPtr = BImgBuff;
+          y++;
+          if(y>=image->rows)
+          {
+            break;
+          }
+        }
       }
     }
     else
@@ -169,19 +169,19 @@ static Image *ReadMACImage(const ImageInfo *image_info,ExceptionInfo *exception)
         rep--;
         if(x8>=ldblk)
         {
-         x8=0;
+          x8=0;
 
           q = SetImagePixels(image,0,y,image->columns,1);
           if(q == (PixelPacket *)NULL) break;
           (void)ImportImagePixelArea(image,GrayQuantum,1,BImgBuff,NULL,0);
           if (!SyncImagePixels(image)) break;
 
-         DataPtr = BImgBuff;
-         y++;
-         if(y>=image->rows)
-         {
-           break;
-         }
+          DataPtr = BImgBuff;
+          y++;
+          if(y>=image->rows)
+          {
+            break;
+          }
         }
       }
     }
index 619c7e0..597b19b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -18,7 +18,7 @@
 %                            M   M  A   A  P                                  %
 %                                                                             %
 %                                                                             %
-%                 Read/Write Image Colormaps As An Image File                 %
+%                 Read/Write Image Colormaps And Image File                   %
 %                                                                             %
 %                                                                             %
 %                              Software Design                                %
@@ -242,7 +242,7 @@ ModuleExport void RegisterMAPImage(void)
   entry->raw=True;
   entry->description="Colormap intensities and indices";
   entry->module="MAP";
-  entry->coder_class=PrimaryCoderClass;
+  entry->coder_class=UnstableCoderClass;
   entry->extension_treatment=ObeyExtensionTreatment;
   (void) RegisterMagickInfo(entry);
 }
@@ -349,16 +349,17 @@ static unsigned int WriteMAPImage(const ImageInfo *image_info,Image *image)
   /*
     Allocate colormap.
   */
-  if (!IsPaletteImage(image,&image->exception))
-    (void) SetImageType(image,PaletteType);
+  if (SetImageType(image,PaletteType) == MagickFail)
+    ThrowMAPWriterException(ResourceLimitError,MemoryAllocationFailed,image);
   packet_size=image->depth > 8 ? 2 : 1;
-  pixels=MagickAllocateMemory(unsigned char *,image->columns*packet_size);
+  pixels=MagickAllocateArray(unsigned char *,image->columns,packet_size);
   if (pixels == (unsigned char *) NULL)
     ThrowMAPWriterException(ResourceLimitError,MemoryAllocationFailed,image);
   packet_size=image->colors > 256 ? 6 : 3;
-  colormap=MagickAllocateMemory(unsigned char *,packet_size*image->colors);
+  colormap=MagickAllocateArray(unsigned char *,packet_size,image->colors);
   if (colormap == (unsigned char *) NULL)
     ThrowMAPWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+
   /*
     Write colormap to file.
   */
index 65efadc..8c1bb19 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -21,7 +21,7 @@
 %                                                                             %
 %                              Software Design                                %
 %                              Jaroslav Fojtik                                %
-%                                2001 - 2016                                  %
+%                                2001 - 2018                                  %
 %                                                                             %
 %                                                                             %
 %                                                                             %
@@ -64,24 +64,24 @@ MinReal+j*MinComplex = blue  MaxReal+j*MinComplex = black
 typedef struct
 {
   char identific[124];
-  unsigned short Version;
+  magick_uint16_t Version;
   char EndianIndicator[2];
-  unsigned long DataType;
+  magick_uint32_t DataType;
   magick_uint32_t ObjectSize;
-  unsigned long unknown1;
-  unsigned long unknown2;
-
-  unsigned short unknown5;
-  unsigned char StructureFlag;
-  unsigned char StructureClass;
-  unsigned long unknown3;
-  unsigned long unknown4;
-  unsigned long DimFlag;
-
-  unsigned long SizeX;
-  unsigned long SizeY;
-  unsigned short Flag1;
-  unsigned short NameFlag;
+  magick_uint32_t unknown1;
+  magick_uint32_t unknown2;
+
+  magick_uint16_t unknown5;
+  magick_uint8_t StructureFlag;
+  magick_uint8_t StructureClass;
+  magick_uint32_t unknown3;
+  magick_uint32_t unknown4;
+  magick_uint32_t DimFlag;
+
+  magick_uint32_t SizeX;
+  magick_uint32_t SizeY;
+  magick_uint16_t Flag1;
+  magick_uint16_t NameFlag;
 }
 MATHeader;
 
@@ -100,43 +100,43 @@ static const char *OsDesc=
 
 typedef enum
   {
-    miINT8 = 1,                        /* 8 bit signed */
-    miUINT8,                   /* 8 bit unsigned */
-    miINT16,                   /* 16 bit signed */
-    miUINT16,                  /* 16 bit unsigned */
-    miINT32,                   /* 32 bit signed */
-    miUINT32,                  /* 32 bit unsigned */
-    miSINGLE,                  /* IEEE 754 single precision float */
+    miINT8 = 1,                 /* 8 bit signed */
+    miUINT8,                    /* 8 bit unsigned */
+    miINT16,                    /* 16 bit signed */
+    miUINT16,                   /* 16 bit unsigned */
+    miINT32,                    /* 32 bit signed */
+    miUINT32,                   /* 32 bit unsigned */
+    miSINGLE,                   /* IEEE 754 single precision float */
     miRESERVE1,
-    miDOUBLE,                  /* IEEE 754 double precision float */
+    miDOUBLE,                   /* IEEE 754 double precision float */
     miRESERVE2,
     miRESERVE3,
-    miINT64,                   /* 64 bit signed */
-    miUINT64,                  /* 64 bit unsigned */
-    miMATRIX,                  /* MATLAB array */
-    miCOMPRESSED,              /* Compressed Data */
-    miUTF8,                    /* Unicode UTF-8 Encoded Character Data */
-    miUTF16,                   /* Unicode UTF-16 Encoded Character Data */
-    miUTF32                    /* Unicode UTF-32 Encoded Character Data */
+    miINT64,                    /* 64 bit signed */
+    miUINT64,                   /* 64 bit unsigned */
+    miMATRIX,                   /* MATLAB array */
+    miCOMPRESSED,               /* Compressed Data */
+    miUTF8,                     /* Unicode UTF-8 Encoded Character Data */
+    miUTF16,                    /* Unicode UTF-16 Encoded Character Data */
+    miUTF32                     /* Unicode UTF-32 Encoded Character Data */
   } mat5_data_type;
 
 typedef enum
   {
-    mxCELL_CLASS=1,            /* cell array */
-    mxSTRUCT_CLASS,            /* structure */
-    mxOBJECT_CLASS,            /* object */
-    mxCHAR_CLASS,              /* character array */
-    mxSPARSE_CLASS,            /* sparse array */
-    mxDOUBLE_CLASS,            /* double precision array */
-    mxSINGLE_CLASS,            /* single precision floating point */
-    mxINT8_CLASS,              /* 8 bit signed integer */
-    mxUINT8_CLASS,             /* 8 bit unsigned integer */
-    mxINT16_CLASS,             /* 16 bit signed integer */
-    mxUINT16_CLASS,            /* 16 bit unsigned integer */
-    mxINT32_CLASS,             /* 32 bit signed integer */
-    mxUINT32_CLASS,            /* 32 bit unsigned integer */
-    mxINT64_CLASS,             /* 64 bit signed integer */
-    mxUINT64_CLASS,            /* 64 bit unsigned integer */
+    mxCELL_CLASS=1,             /* cell array */
+    mxSTRUCT_CLASS,             /* structure */
+    mxOBJECT_CLASS,             /* object */
+    mxCHAR_CLASS,               /* character array */
+    mxSPARSE_CLASS,             /* sparse array */
+    mxDOUBLE_CLASS,             /* double precision array */
+    mxSINGLE_CLASS,             /* single precision floating point */
+    mxINT8_CLASS,               /* 8 bit signed integer */
+    mxUINT8_CLASS,              /* 8 bit unsigned integer */
+    mxINT16_CLASS,              /* 16 bit signed integer */
+    mxUINT16_CLASS,             /* 16 bit unsigned integer */
+    mxINT32_CLASS,              /* 32 bit signed integer */
+    mxUINT32_CLASS,             /* 32 bit unsigned integer */
+    mxINT64_CLASS,              /* 64 bit signed integer */
+    mxUINT64_CLASS,             /* 64 bit unsigned integer */
     mxFUNCTION_CLASS            /* Function handle */
   } arrayclasstype;
 
@@ -147,16 +147,19 @@ typedef enum
 static const QuantumType z2qtype[4] = {GrayQuantum, BlueQuantum, GreenQuantum, RedQuantum};
 
 
-static void InsertComplexDoubleRow(double *p, int y, Image * image, double MinVal,
+/* Add coloring to gray image. C=R+j*Q. Colors to red when Q>0 and blue for Q<0.
+ Please note that this function expects gray image on input. Additional channel contents
+ checking is wasting of resources only. */
+static void InsertComplexDoubleRow(double *p, int y, Image *image, double MinVal, 
                                   double MaxVal)
 {
   double f;
   int x;
   register PixelPacket *q;
 
-  if (MinVal == 0)
+  if(MinVal >= 0)      /* Grant MinVal to be negative */
     MinVal = -1;
-  if (MaxVal == 0)
+  if(MaxVal <= 0)      /* Grant MaxVal to be positive */
     MaxVal = 1;
 
   q = SetImagePixels(image, 0, y, image->columns, 1);
@@ -166,27 +169,31 @@ static void InsertComplexDoubleRow(double *p, int y, Image * image, double MinVa
   {
     if (*p > 0)
     {
-      f = (*p / MaxVal) * (MaxRGB - q->red);
-      if (f + q->red > MaxRGB)
+      f = (*p / MaxVal) * (Quantum)(MaxRGB - q->red);  /* first multiplier should be in a range <0;1> */
+      /*if(f<0) f=0; */
+      if (f + q->red >= MaxRGB)
         q->red = MaxRGB;
       else
         q->red += (int) f;
-      if ((int) f / 2.0 > q->green)
+      f = q->green - f/2.0;
+      if (f <= 0)
         q->green = q->blue = 0;
       else
-        q->green = q->blue -= (int) (f / 2.0);
+        q->green = q->blue = (int)f;
     }
     if (*p < 0)
     {
-      f = (*p / MaxVal) * (MaxRGB - q->blue);
-      if (f + q->blue > MaxRGB)
+      f = (*p / MinVal) * (Quantum)(MaxRGB - q->blue); /* first multiplier should be in a range <0;1>; *p<0 and MinVal<0. */
+      /*if(f<0) f=0; */
+      if (f + q->blue >= MaxRGB)
         q->blue = MaxRGB;
       else
         q->blue += (int) f;
-      if ((int) f / 2.0 > q->green)
+      f = q->green - f/2.0;
+      if(f <= 0)
         q->green = q->red = 0;
       else
-        q->green = q->red -= (int) (f / 2.0);
+        q->green = q->red = (int)f;
     }
     p++;
     q++;
@@ -200,16 +207,18 @@ static void InsertComplexDoubleRow(double *p, int y, Image * image, double MinVa
 }
 
 
-static void InsertComplexFloatRow(float *p, int y, Image * image, double MinVal,
-                                  double MaxVal)
+/* Add coloring to gray image. C=R+j*Q. Colors to red when Q>0 and blue for Q<0.
+ Please note that this function expects gray image on input. Additional channel contents
+ checking is wasting of resources only. */
+static void InsertComplexFloatRow(float *p, int y, Image *image, double MinVal, double MaxVal)
 {
   double f;
   int x;
   register PixelPacket *q;
 
-  if (MinVal == 0)
+  if(MinVal >= 0)      /* Grant MinVal to be negative */
     MinVal = -1;
-  if (MaxVal == 0)
+  if(MaxVal <= 0)      /* Grant MaxVal to be positive */
     MaxVal = 1;
 
   q = SetImagePixels(image, 0, y, image->columns, 1);
@@ -219,27 +228,32 @@ static void InsertComplexFloatRow(float *p, int y, Image * image, double MinVal,
   {
     if (*p > 0)
     {
-      f = (*p / MaxVal) * (MaxRGB - q->red);
-      if (f + q->red > MaxRGB)
-        q->red = MaxRGB;
+      f = (*p / MaxVal) * (Quantum)(MaxRGB - q->red);
+      /*if(f<0) f=0;   //Only for Assert, should be commented out */
+      if (f + q->red < MaxRGB)
+        q->red += (int)f;
       else
-        q->red += (int) f;
-      if ((int) f / 2.0 > q->green)
-        q->green = q->blue = 0;
+        q->red = MaxRGB;        
+      f /= 2.0;
+      if(f < q->green)
+        q->green = q->blue -= (int)(f);
       else
-        q->green = q->blue -= (int) (f / 2.0);
+        q->green = q->blue = 0;        
     }
     if (*p < 0)
     {
-      f = (*p / MaxVal) * (MaxRGB - q->blue);
-      if (f + q->blue > MaxRGB)
-        q->blue = MaxRGB;
-      else
+      f = (*p / MinVal) * (Quantum)(MaxRGB - q->blue); /* f is positive only <0; inf> */
+      /*if(f<0)        f=0;    //Only for Assert, should be commented out */
+      if (f + q->blue < MaxRGB)
         q->blue += (int) f;
-      if ((int) f / 2.0 > q->green)
-        q->green = q->red = 0;
-      else
-        q->green = q->red -= (int) (f / 2.0);
+      else     /* 'else' branch is executed when NaN occurs. */
+        q->blue = MaxRGB;        
+
+      f /= 2.0;
+      if(f < q->green)
+        q->green = q->red -= (int)(f);
+      else     /* 'else' branch is executed when NaN occurs. */
+        q->green = q->red = 0;        
     }
     p++;
     q++;
@@ -262,8 +276,8 @@ static void FixSignedValues(PixelPacket *q, int y)
   while(y-->0)
   {
      /* Please note that negative values will overflow
-        Q=8; MaxRGB=255: <0;127> + 127+1 = <128; 255> 
-                      <-1;-128> + 127+1 = <0; 127> */
+        Q=8; MaxRGB=255: <0;127> + 127+1 = <128; 255>
+                       <-1;-128> + 127+1 = <0; 127> */
     q->red += MaxRGB/2 + 1;
     q->green += MaxRGB/ + 1;
     q->blue += MaxRGB/ + 1;
@@ -282,7 +296,7 @@ unsigned char val = 0;
   while(ldblk-->0)
   {
     if(*Buff++ != 0)
-      val |= mask;    
+      val |= mask;
 
     mask >>= 1;
     if(mask==0)
@@ -290,17 +304,18 @@ unsigned char val = 0;
       *BuffL++ = val;
       val = 0;
       mask = 128;
-    }   
-      
+    }
+
   }
   *BuffL = val;
 }
 
 #if defined(HasZLIB)
+static voidpf ZLIBAllocFunc(voidpf opaque, uInt items, uInt size) MAGICK_FUNC_MALLOC;
 static voidpf ZLIBAllocFunc(voidpf opaque, uInt items, uInt size)
 {
   ARG_NOT_USED(opaque);
-  return MagickMallocCleared((size_t) items*size);
+  return MagickMallocCleared(MagickArraySize(items,size));
 }
 static void ZLIBFreeFunc(voidpf opaque, voidpf address)
 {
@@ -321,7 +336,7 @@ int zip_status;
 magick_off_t TotalSize = 0;
 
   if(clone_info==NULL) return NULL;
-  if(clone_info->file)         /* Close file opened from previous transaction. */
+  if(clone_info->file)          /* Close file opened from previous transaction. */
   {
     fclose(clone_info->file);
     clone_info->file = NULL;
@@ -331,9 +346,9 @@ magick_off_t TotalSize = 0;
   cache_block = MagickAllocateMemory(unsigned char *,(size_t)((*Size<16384) ? *Size : 16384));
   if(cache_block==NULL) return NULL;
   decompress_block = MagickAllocateMemory(unsigned char *,(size_t)(4096));
-  if(decompress_block==NULL) 
+  if(decompress_block==NULL)
   {
-    MagickFreeMemory(cache_block);    
+    MagickFreeMemory(cache_block);
     return NULL;
   }
 
@@ -368,22 +383,22 @@ magick_off_t TotalSize = 0;
   {
     magick_size = ReadBlob(orig, (*Size<16384)?*Size:16384, cache_block);
     zip_info.next_in = cache_block;
-    zip_info.avail_in = (uInt) magick_size;    
+    zip_info.avail_in = (uInt) magick_size;
 
     while(zip_info.avail_in>0)
     {
-      zip_info.avail_out = 4096;    
+      zip_info.avail_out = 4096;
       zip_info.next_out = decompress_block;
       zip_status = inflate(&zip_info,Z_NO_FLUSH);
       if ((zip_status != Z_OK) && (zip_status != Z_STREAM_END))
         {
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Corrupt inflate stream");
-          ThrowException(exception,CorruptImageError, UnableToUncompressImage, orig->filename);
+          inflateEnd(&zip_info);
           MagickFreeMemory(cache_block);
           MagickFreeMemory(decompress_block);
-          inflateEnd(&zip_info);
           (void)fclose(mat_file);
           LiberateTemporaryFile(clone_info->filename);
+          ThrowException(exception,CorruptImageError, UnableToUncompressImage, orig->filename);
           return NULL;
         }
       fwrite(decompress_block, 4096-zip_info.avail_out, 1, mat_file);
@@ -391,29 +406,31 @@ magick_off_t TotalSize = 0;
 
       if(zip_status == Z_STREAM_END) goto DblBreak;
     }
-
-    *Size -= magick_size;
+        if (*Size >= magick_size)
+                *Size -= (magick_uint32_t) magick_size;
+        else
+                *Size = 0U;
   }
 DblBreak:
-  inflateEnd(&zip_info);                       /* Release all caches used by zip. */
+
+  inflateEnd(&zip_info);                        /* Release all caches used by zip. */
   (void)fclose(mat_file);
   MagickFreeMemory(cache_block);
   MagickFreeMemory(decompress_block);
   *Size = TotalSize;
 
   if((clone_info->file=fopen(clone_info->filename,"rb"))==NULL) goto UnlinkFile;
-  if( (image2 = AllocateImage(clone_info))==NULL ) goto EraseFile;  
+  if((image2 = AllocateImage(clone_info))==NULL) goto EraseFile;
   status = OpenBlob(clone_info,image2,ReadBinaryBlobMode,exception);
   if (status == False)
   {
-    DeleteImageFromList(&image2);    
+    DeleteImageFromList(&image2);
 EraseFile:
     fclose(clone_info->file);
     clone_info->file = NULL;
 UnlinkFile:
     LiberateTemporaryFile(clone_info->filename);
-    return NULL; 
+    return NULL;
   }
 
   return image2;
@@ -429,18 +446,36 @@ UnlinkFile:
 }
 
 
+#define ThrowImg2MATReaderException(code_,reason_,image_) \
+{ \
+   if(image2!=NULL && image2!=image)    /* Does shadow temporary decompressed image exist? */ \
+   { \
+     CloseBlob(image2); \
+     DeleteImageFromList(&image2); \
+  } \
+  if(clone_info) \
+    DestroyImageInfo(clone_info);    \
+  ThrowReaderException(code_,reason_,image_); \
+}
+
+
+
 
 typedef struct {
-       unsigned char Type[4];
-       magick_uint32_t nRows;
-       magick_uint32_t nCols;
-       magick_uint32_t imagf;
-       magick_uint32_t nameLen;
+        unsigned char Type[4];
+        magick_uint32_t nRows;
+        magick_uint32_t nCols;
+        magick_uint32_t imagf;
+        magick_uint32_t nameLen;
 } MAT4_HDR;
 
 
+#define RET_CHECK(image)  return((image->previous==NULL)?NULL:image)
+
+
 /* Load Matlab V4 file. */
-static Image *ReadMATImageV4(const ImageInfo *image_info, Image *image, ImportPixelAreaOptions *import_options, ExceptionInfo *exception)
+static Image *ReadMATImageV4(const ImageInfo *image_info, Image *image, ImportPixelAreaOptions *import_options, 
+                             ExceptionInfo *exception, const int logging)
 {
 MAT4_HDR HDR;
 Image *rotated_image;
@@ -460,91 +495,91 @@ size_t (*ReadBlobXXXFloats)(Image *image, size_t len, float *data);
   {
     ldblk = ReadBlobLSBLong(image);
     if(EOFBlob(image)) break;
-    if(ldblk>9999 || ldblk<0) return 0;
-    HDR.Type[3] = ldblk % 10;  ldblk /= 10;    /* T digit */
-    HDR.Type[2] = ldblk % 10;  ldblk /= 10;    /* P digit */
-    HDR.Type[1] = ldblk % 10;  ldblk /= 10;    /* O digit */
-    HDR.Type[0] = ldblk;                               /* M digit */
+    if(ldblk>9999 || ldblk<0) RET_CHECK(image);
+    HDR.Type[3] = ldblk % 10;   ldblk /= 10;    /* T digit */
+    HDR.Type[2] = ldblk % 10;   ldblk /= 10;    /* P digit */
+    HDR.Type[1] = ldblk % 10;   ldblk /= 10;    /* O digit */
+    HDR.Type[0] = ldblk;                        /* M digit */
 
-    if(HDR.Type[3]!=0) return 0;               /* Data format */
-    if(HDR.Type[2]!=0) return 0;               /* Always 0 */
+    if(HDR.Type[3]!=0) RET_CHECK(image);  /* Data format */
+    if(HDR.Type[2]!=0) RET_CHECK(image);  /* Always 0 */
 
     ImportPixelAreaOptionsInit(import_options);
 
     switch(HDR.Type[0])
     {
-      case 0: ReadBlobXXXLong = ReadBlobLSBLong;            
+      case 0: ReadBlobXXXLong = ReadBlobLSBLong;
               ReadBlobXXXDoubles = ReadBlobLSBDoubles;
               ReadBlobXXXFloats = ReadBlobLSBFloats;
               import_options->endian = LSBEndian;
               break;
-      case 1: ReadBlobXXXLong = ReadBlobMSBLong;            
+      case 1: ReadBlobXXXLong = ReadBlobMSBLong;
               ReadBlobXXXDoubles = ReadBlobMSBDoubles;
               ReadBlobXXXFloats = ReadBlobMSBFloats;
               import_options->endian = MSBEndian;
               break;
-      default: return 0;               /* Unsupported endian */
+      default: RET_CHECK(image);      /* Unsupported endian */
     }
 
-    HDR.nRows = ReadBlobXXXLong(image);  
+    HDR.nRows = ReadBlobXXXLong(image);
     HDR.nCols = ReadBlobXXXLong(image);
 
     HDR.imagf = ReadBlobXXXLong(image);
-    if(HDR.imagf!=0 && HDR.imagf!=1) return NULL;
+    if(HDR.imagf!=0 && HDR.imagf!=1) RET_CHECK(image);
 
     HDR.nameLen = ReadBlobXXXLong(image);
-    if(HDR.nameLen>0xFFFF) return NULL;
-    (void)SeekBlob(image,HDR.nameLen,SEEK_CUR);        /* Skip a matrix name. */
+    if(HDR.nameLen>0xFFFF) RET_CHECK(image);
+    (void)SeekBlob(image,HDR.nameLen,SEEK_CUR); /* Skip a matrix name. */
 
     switch(HDR.Type[1])
     {
-      case 0: sample_size = 64;                                /* double-precision (64-bit) floating point numbers */             
+      case 0: sample_size = 64;                         /* double-precision (64-bit) floating point numbers */
               image->depth = Min(QuantumDepth,32);        /* double type cell */
               import_options->sample_type = FloatQuantumSampleType;
-              if(sizeof(double) != 8) return NULL;     /* incompatible double size */          
+              if(sizeof(double) != 8) RET_CHECK(image);      /* incompatible double size */
               ldblk = (long) (8 * HDR.nRows);
               break;
 
-      case 1: sample_size = 32;                                /* single-precision (32-bit) floating point numbers */            
+      case 1: sample_size = 32;                         /* single-precision (32-bit) floating point numbers */
               image->depth = Min(QuantumDepth,32);        /* double type cell */
               import_options->sample_type = FloatQuantumSampleType;
 #if 0
               if(sizeof(float) != 4)
                 ThrowMATReaderException(CoderError, IncompatibleSizeOfFloat, image);
-#endif        
+#endif
               ldblk = (long) (4 * HDR.nRows);
               break;
 
-      case 2: sample_size = 32;                                /* 32-bit signed integers */            
+      case 2: sample_size = 32;                         /* 32-bit signed integers */
               image->depth = Min(QuantumDepth,32);        /* Dword type cell */
-              ldblk = (long) (4 * HDR.nRows);      
+              ldblk = (long) (4 * HDR.nRows);
               import_options->sample_type = UnsignedQuantumSampleType;
               break;
 
-      case 3:                          /* 16-bit signed integers */
-      case 4:                          /* 16-bit unsigned integers */
+      case 3:                           /* 16-bit signed integers */
+      case 4:                           /* 16-bit unsigned integers */
               sample_size = 16;
               image->depth = Min(QuantumDepth,16);        /* Word type cell */
               ldblk = (long) (2 * HDR.nRows);
-             import_options->sample_type = UnsignedQuantumSampleType;       
+             import_options->sample_type = UnsignedQuantumSampleType;
               break;
 
-      case 5: sample_size = 8;         /* 8-bit unsigned integers */
+      case 5: sample_size = 8;          /* 8-bit unsigned integers */
               image->depth = Min(QuantumDepth,8);         /* Byte type cell */
               import_options->sample_type = UnsignedQuantumSampleType;
               ldblk = (long) HDR.nRows;
               break;
-       
-      default: return NULL;
-    }     
+
+      default: RET_CHECK(image);
+    }
 
     image->columns = HDR.nRows;
     image->rows = HDR.nCols;
     image->colors = 1l << image->depth;
-    if(image->columns == 0 || image->rows == 0) return NULL;
+    if(image->columns == 0 || image->rows == 0) RET_CHECK(image);
     if(CheckImagePixelLimits(image, exception) != MagickPass)
     {
-      return NULL;
+      RET_CHECK(image);
       /* ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image); */
     }
 
@@ -557,89 +592,99 @@ size_t (*ReadBlobXXXFloats)(Image *image, size_t len, float *data);
       if(HDR.imagf==1) ldblk *= 2;
       SeekBlob(image, HDR.nCols*ldblk, SEEK_CUR);
       goto skip_reading_current;
-    }  
+    }
 
-       /* ----- Load raster data ----- */
+        /* ----- Load raster data ----- */
     BImgBuff = MagickAllocateMemory(unsigned char *,(size_t) (ldblk));    /* Ldblk was set in the check phase */
-    if(BImgBuff == NULL) return 0;
-   
-    if(HDR.Type[1]==0)         /* Find Min and Max Values for doubles */
+    if(BImgBuff == NULL) RET_CHECK(image);
+
+    if(HDR.Type[1]==0)          /* Find Min and Max Values for doubles */
     {
       (void)MagickFindRawImageMinMax(image, import_options->endian, HDR.nRows,
                                       HDR.nCols, DoublePixel, ldblk, BImgBuff,
-                                      &import_options->double_minvalue, 
+                                      &import_options->double_minvalue,
                                       &import_options->double_maxvalue);
     }
-    if(HDR.Type[1]==1)         /* Find Min and Max Values for floats */
+    if(HDR.Type[1]==1)          /* Find Min and Max Values for floats */
     {
       (void)MagickFindRawImageMinMax(image, import_options->endian, HDR.nRows,
-                                      HDR.nCols, FloatPixel, ldblk, BImgBuff, 
-                                      &import_options->double_minvalue, 
+                                      HDR.nCols, FloatPixel, ldblk, BImgBuff,
+                                      &import_options->double_minvalue,
                                       &import_options->double_maxvalue);
     }
 
-       /* Main reader loop. */
+        /* Main reader loop. */
     for(i=0; i<(long)HDR.nCols; i++)
     {
       q = SetImagePixels(image, 0, HDR.nCols-i-1, image->columns, 1);
       if(q == (PixelPacket *)NULL)
       {
-        /* if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), */
-        /*        "  MAT set image pixels returns unexpected NULL on a row %u.", (unsigned)(MATLAB_HDR.SizeY-i-1)); */
-        goto skip_reading_current;             /* Skip image rotation, when cannot set image pixels */   
+        if(logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+                    "  MAT set image pixels returns unexpected NULL on a row %u.", (unsigned)i);
+        goto skip_reading_current;              /* Skip image rotation, when cannot set image pixels */
       }
 
       if(ReadBlob(image,ldblk,(char *)BImgBuff) != (size_t)ldblk)
       {
-        /* if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), */
-        /*         "  MAT cannot read scanrow %u from a file.", (unsigned)(MATLAB_HDR.SizeY-i-1)); */
+        if(logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+                   "  MAT cannot read scanrow %u from a file.", (unsigned)(i));
+        DestroyImagePixels(image);             /* The unread data contains crap in memory, erase current image data. */
+        image->columns = image->rows = 0;
         goto ExitLoop;
       }
 
       if(ImportImagePixelArea(image,GrayQuantum,sample_size,BImgBuff,import_options,0) == MagickFail)
-           goto ImportImagePixelAreaFailed;
+            goto ImportImagePixelAreaFailed;
 
-      if(HDR.Type[1]==2 || HDR.Type[1]==3)             
-         FixSignedValues(q,HDR.nRows);
+      if(HDR.Type[1]==2 || HDR.Type[1]==3)
+          FixSignedValues(q,HDR.nRows);
 
       if(!SyncImagePixels(image))
       {
-       /* if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), */
-        /*     "  MAT failed to sync image pixels for a row %u", (unsigned)(MATLAB_HDR.SizeY-i-1)); */
-       goto ExitLoop;
+        if(logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+             "  MAT failed to sync image pixels for a row %u", (unsigned)i);
+        goto ExitLoop;
       }
     }
 
-       /* Read complex part of data. */
+        /* Read complex part of data. */
     if(HDR.imagf==1)
     {
       MinVal_c = MaxVal_c = 0;
-      if(HDR.Type[1]==0)               /* Find Min and Max Values for doubles */
+      if(HDR.Type[1]==0)                /* Find Min and Max Values for doubles */
       {
         (void)MagickFindRawImageMinMax(image, import_options->endian, HDR.nRows,
                                         HDR.nCols, DoublePixel, ldblk, BImgBuff,
                                         &MinVal_c, &MaxVal_c);
         for(i=0; i<(long)HDR.nCols; i++)
         {
-          ReadBlobXXXDoubles(image, ldblk, (double *)BImgBuff);
-          InsertComplexDoubleRow((double *)BImgBuff, i, image, MinVal_c, MaxVal_c);            
+          if(ReadBlobXXXDoubles(image, ldblk, (double *)BImgBuff) != (size_t) ldblk)
+          {
+            if(logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), "Cannot read data.");
+            break;
+          }
+          InsertComplexDoubleRow((double *)BImgBuff, i, image, MinVal_c, MaxVal_c);
         }
       }
 
-      if(HDR.Type[1]==1)               /* Find Min and Max Values for floats */
+      if(HDR.Type[1]==1)                /* Find Min and Max Values for floats */
       {
         (void)MagickFindRawImageMinMax(image, import_options->endian, HDR.nRows,
                                       HDR.nCols, FloatPixel, ldblk, BImgBuff,
                                       &MinVal_c, &MaxVal_c);
         for(i=0; i<(long)HDR.nCols; i++)
         {
-          ReadBlobXXXFloats(image, ldblk, (float *)BImgBuff);
+          if(ReadBlobXXXFloats(image, ldblk, (float *)BImgBuff) != (size_t) ldblk)
+          {
+            if(logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), "Cannot read data.");
+            break;
+          }
           InsertComplexFloatRow((float *)BImgBuff, i, image, MinVal_c, MaxVal_c);
-        }    
+        }
       }
     }
 
-       /*  Rotate image. */
+        /*  Rotate image. */
     rotated_image = RotateImage(image, 90.0, exception);
     if(rotated_image != (Image *) NULL)
     {
@@ -650,16 +695,16 @@ size_t (*ReadBlobXXXFloats)(Image *image, size_t len, float *data);
       blob = rotated_image->blob;
       rotated_image->blob = image->blob;
       rotated_image->colors = image->colors;
-      image->blob = blob;      
+      image->blob = blob;
       AppendImageToList(&image,rotated_image);
       DeleteImageFromList(&image);
       image = rotated_image;
     }
 
 skip_reading_current:
-        /* Allocate next image structure. */    
+        /* Allocate next image structure. */
     AllocateNextImage(image_info,image);
-    if (image->next == (Image *) NULL) break;                
+    if (image->next == (Image *) NULL) break;
     image=SyncNextImageInList(image);
     image->columns = image->rows = 0;
     image->colors=0;
@@ -667,9 +712,8 @@ skip_reading_current:
       /* row scan buffer is no longer needed */
     MagickFreeMemory(BImgBuff);
     BImgBuff = NULL;
-
   }
-    
+
 ImportImagePixelAreaFailed:
 ExitLoop:
 
@@ -717,7 +761,7 @@ static Image *ReadMATImage(const ImageInfo *image_info, ExceptionInfo *exception
   PixelPacket *q;
   unsigned int status;
   MATHeader MATLAB_HDR;
-  unsigned long size;  
+  size_t size;
   magick_uint32_t CellType;
   ImportPixelAreaOptions import_options;
   int i;
@@ -728,10 +772,11 @@ static Image *ReadMATImage(const ImageInfo *image_info, ExceptionInfo *exception
   unsigned Frames;
   int logging;
   int sample_size;
-  magick_off_t filepos=0x80;
+  magick_off_t filepos = 0x80;
+  magick_off_t filesize;
   BlobInfo *blob;
   ImageInfo *clone_info = NULL;
-  
+
   magick_uint32_t (*ReadBlobXXXLong)(Image *image);
   magick_uint16_t (*ReadBlobXXXShort)(Image *image);
   size_t (*ReadBlobXXXDoubles)(Image *image, size_t len, double *data);
@@ -741,7 +786,7 @@ static Image *ReadMATImage(const ImageInfo *image_info, ExceptionInfo *exception
   assert(image_info->signature == MagickSignature);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  logging = LogMagickEvent(CoderEvent,GetMagickModule(),"enter"); 
+  logging = LogMagickEvent(CoderEvent,GetMagickModule(),"enter");
 
   /*
      Open image file.
@@ -750,25 +795,31 @@ static Image *ReadMATImage(const ImageInfo *image_info, ExceptionInfo *exception
 
   status = OpenBlob(image_info, image, ReadBinaryBlobMode, exception);
   if (status == False)
+  {
     ThrowMATReaderException(FileOpenError, UnableToOpenFile, image);
+  }
 
   /*
      Read MATLAB image.
    */
   if(ReadBlob(image,124,&MATLAB_HDR.identific) != 124)
+  {
     ThrowMATReaderException(CorruptImageError,ImproperImageHeader,image);
+  }
 
   if(strncmp(MATLAB_HDR.identific, "MATLAB", 6))
   {
-    image2 = ReadMATImageV4(image_info,image,&import_options,exception);
-    if(image2==NULL) goto MATLAB_KO;
+    image2 = ReadMATImageV4(image_info,image,&import_options,exception,logging);
+    if(image2==NULL) goto MATLAB_KO;    
     image = image2;
-    goto END_OF_READING;    
+    goto END_OF_READING;
   }
 
   MATLAB_HDR.Version = ReadBlobLSBShort(image);
   if(ReadBlob(image,2,&MATLAB_HDR.EndianIndicator) != 2)
+  {
     ThrowMATReaderException(CorruptImageError,ImproperImageHeader,image);
+  }
 
   ImportPixelAreaOptionsInit(&import_options);
 
@@ -781,7 +832,7 @@ static Image *ReadMATImage(const ImageInfo *image_info, ExceptionInfo *exception
     ReadBlobXXXDoubles = ReadBlobLSBDoubles;
     ReadBlobXXXFloats = ReadBlobLSBFloats;
     import_options.endian = LSBEndian;
-  } 
+  }
   else if (!strncmp(MATLAB_HDR.EndianIndicator, "MI", 2))
   {
     ReadBlobXXXLong = ReadBlobMSBLong;
@@ -790,36 +841,50 @@ static Image *ReadMATImage(const ImageInfo *image_info, ExceptionInfo *exception
     ReadBlobXXXFloats = ReadBlobMSBFloats;
     import_options.endian = MSBEndian;
   }
-  else                 /* unsupported endian */
+  else                  /* unsupported endian */
   {
-MATLAB_KO: ThrowMATReaderException(CorruptImageError,ImproperImageHeader,image);  
+MATLAB_KO: ThrowMATReaderException(CorruptImageError,ImproperImageHeader,image);
   }
 
   filepos = TellBlob(image);
-  if(filepos < 0)
-      ThrowMATReaderException(BlobError,UnableToObtainOffset,image);
-  while(!EOFBlob(image)) /* object parser loop */
+
+  filesize = GetBlobSize(image);             /* zero is returned if the size cannot be determined. */
+  if(filesize>0 && BlobIsSeekable(image))
+  { 
+    if(filesize > (magick_off_t)0xFFFFFFFF)
+        filesize = (magick_off_t)0xFFFFFFFF;  /* More than 4GiB are not supported in MAT! */
+  }
+  else
+  {
+    filesize = (magick_off_t)0xFFFFFFFF;
+    if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+          "Blob is not seekable, MAT reader could fail.");
+    ThrowMATReaderException(CorruptImageError,AnErrorHasOccurredReadingFromFile,image);
+  }
+
+  while(filepos<filesize && !EOFBlob(image)) /* object parser loop */
   {
-    Frames = 1;
-    (void) SeekBlob(image,filepos,SEEK_SET);
+    Frames = 1;    
+    if(filepos > filesize || filepos < 0)
+    {
+      ThrowMATReaderException(BlobError,UnableToObtainOffset,image);
+    }
+    if(SeekBlob(image,filepos,SEEK_SET) != filepos) break;
     /* printf("pos=%X\n",TellBlob(image)); */
 
     MATLAB_HDR.DataType = ReadBlobXXXLong(image);
     if(EOFBlob(image)) break;
     MATLAB_HDR.ObjectSize = ReadBlobXXXLong(image);
-    if(EOFBlob(image)) break;    
+    if(EOFBlob(image)) break;
 
-    if(BlobIsSeekable(image))
-    {      
-      if(MATLAB_HDR.ObjectSize+filepos > GetBlobSize(image))   /* Safety check for forged and or corrupted data. */
-      {
-        if(logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
-             "  MAT Object with size %u overflows file with size %u.", (unsigned)MATLAB_HDR.ObjectSize, (unsigned)(GetBlobSize(image)));
-        goto MATLAB_KO;
-      }
+    if(MATLAB_HDR.ObjectSize+filepos >= filesize)   /* Safety check for forged and or corrupted data. */
+    {
+      if(logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+             "  MAT Object with size %u overflows file with size %u.", (unsigned)MATLAB_HDR.ObjectSize, (unsigned)(filesize));
+      goto MATLAB_KO;    
     }
 
-    filepos += MATLAB_HDR.ObjectSize + 4 + 4;  /* Position of a next object, when exists. */
+    filepos += (magick_off_t) MATLAB_HDR.ObjectSize + 4 + 4;   /* Position of a next object, when exists. */
 
     image2 = image;
 #if defined(HasZLIB)
@@ -827,13 +892,13 @@ MATLAB_KO: ThrowMATReaderException(CorruptImageError,ImproperImageHeader,image);
     {
       if(clone_info==NULL)
         if((clone_info=CloneImageInfo(image_info)) == NULL)
-               {
-                 if(logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+                {
+                  if(logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
                                    "CloneImageInfo failed");
-                 continue;
-               }
+                  continue;
+                }
       image2 = DecompressBlock(image,&MATLAB_HDR.ObjectSize,clone_info,exception);
-      if(image2==NULL) 
+      if(image2==NULL)
       {
         if(logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
                                    "Decompression failed");
@@ -841,68 +906,76 @@ MATLAB_KO: ThrowMATReaderException(CorruptImageError,ImproperImageHeader,image);
       }
       MATLAB_HDR.DataType = ReadBlobXXXLong(image2); /* replace compressed object type. */
     }
-#endif    
+#endif
+
+    if(MATLAB_HDR.DataType!=miMATRIX) 
+    {
+#if defined(HasZLIB)
+      if(image2 != image)
+      {
+         DeleteImageFromList(&image2); /* image2 is set to NULL */
+      }
+#endif
+      continue;  /* skip another objects. */
+    }
 
-    if(MATLAB_HDR.DataType!=miMATRIX) continue;  /* skip another objects. */
     MATLAB_HDR.unknown1 = ReadBlobXXXLong(image2);
-    MATLAB_HDR.unknown2 = ReadBlobXXXLong(image2);  
+    MATLAB_HDR.unknown2 = ReadBlobXXXLong(image2);
 
     MATLAB_HDR.unknown5 = ReadBlobXXXLong(image2);
     MATLAB_HDR.StructureClass = MATLAB_HDR.unknown5 & 0xFF;
-    MATLAB_HDR.StructureFlag = (MATLAB_HDR.unknown5>>8) & 0xFF;  
+    MATLAB_HDR.StructureFlag = (MATLAB_HDR.unknown5>>8) & 0xFF;
 
     MATLAB_HDR.unknown3 = ReadBlobXXXLong(image2);
     if(image!=image2)
-      MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2);   /* ??? don't understand why ?? */
+      MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2);    /* ??? don't understand why ?? */
     MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2);
     MATLAB_HDR.DimFlag = ReadBlobXXXLong(image2);
     MATLAB_HDR.SizeX = ReadBlobXXXLong(image2);
-    MATLAB_HDR.SizeY = ReadBlobXXXLong(image2);  
-   
+    MATLAB_HDR.SizeY = ReadBlobXXXLong(image2);
+
 
     switch(MATLAB_HDR.DimFlag)
-    {     
-      case  8: z2=z=1; break;                  /* 2D matrix*/
-      case 12: z2=z = ReadBlobXXXLong(image2); /* 3D matrix RGB*/
-              (void) ReadBlobXXXLong(image2);  /* Unknown6 */
-              if(z!=3) ThrowMATReaderException(CoderError, MultidimensionalMatricesAreNotSupported,
+    {
+      case  8: z2=z=1; break;                   /* 2D matrix*/
+      case 12: z2=z = ReadBlobXXXLong(image2);  /* 3D matrix RGB*/
+               (void) ReadBlobXXXLong(image2);  /* Unknown6 */
+               if(z!=3) ThrowImg2MATReaderException(CoderError, MultidimensionalMatricesAreNotSupported,
                          image);
-              break;
-      case 16: z2=z = ReadBlobXXXLong(image2); /* 4D matrix animation */
-              if(z!=3 && z!=1)
-                ThrowMATReaderException(CoderError, MultidimensionalMatricesAreNotSupported, image);
+               break;
+      case 16: z2=z = ReadBlobXXXLong(image2);  /* 4D matrix animation */
+               if(z!=3 && z!=1)
+                 ThrowImg2MATReaderException(CoderError, MultidimensionalMatricesAreNotSupported, image);
                Frames = ReadBlobXXXLong(image2);
                if (Frames == 0)
-                 ThrowMATReaderException(CorruptImageError,ImproperImageHeader,image2);
-              break;
-      default: ThrowMATReaderException(CoderError, MultidimensionalMatricesAreNotSupported,
-                         image);
-    }  
+                 ThrowImg2MATReaderException(CorruptImageError,ImproperImageHeader,image2);
+               break;
+      default: ThrowImg2MATReaderException(CoderError, MultidimensionalMatricesAreNotSupported, image);
+    }
 
     MATLAB_HDR.Flag1 = ReadBlobXXXShort(image2);
     MATLAB_HDR.NameFlag = ReadBlobXXXShort(image2);
 
     if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
           "MATLAB_HDR.StructureClass %d",MATLAB_HDR.StructureClass);
-    if (MATLAB_HDR.StructureClass != mxCHAR_CLASS && 
-        MATLAB_HDR.StructureClass != mxSINGLE_CLASS &&         /* float + complex float */
-        MATLAB_HDR.StructureClass != mxDOUBLE_CLASS &&         /* double + complex double */
+    if (MATLAB_HDR.StructureClass != mxCHAR_CLASS &&
+        MATLAB_HDR.StructureClass != mxSINGLE_CLASS &&          /* float + complex float */
+        MATLAB_HDR.StructureClass != mxDOUBLE_CLASS &&          /* double + complex double */
         MATLAB_HDR.StructureClass != mxINT8_CLASS &&
-        MATLAB_HDR.StructureClass != mxUINT8_CLASS &&          /* uint8 + uint8 3D */
+        MATLAB_HDR.StructureClass != mxUINT8_CLASS &&           /* uint8 + uint8 3D */
         MATLAB_HDR.StructureClass != mxINT16_CLASS &&
-        MATLAB_HDR.StructureClass != mxUINT16_CLASS &&         /* uint16 + uint16 3D */
+        MATLAB_HDR.StructureClass != mxUINT16_CLASS &&          /* uint16 + uint16 3D */
         MATLAB_HDR.StructureClass != mxINT32_CLASS &&
-        MATLAB_HDR.StructureClass != mxUINT32_CLASS &&         /* uint32 + uint32 3D */
+        MATLAB_HDR.StructureClass != mxUINT32_CLASS &&          /* uint32 + uint32 3D */
         MATLAB_HDR.StructureClass != mxINT64_CLASS &&
-        MATLAB_HDR.StructureClass != mxUINT64_CLASS)           /* uint64 + uint64 3D */
-      ThrowMATReaderException(CoderError,UnsupportedCellTypeInTheMatrix,image);
+        MATLAB_HDR.StructureClass != mxUINT64_CLASS)            /* uint64 + uint64 3D */
+      ThrowImg2MATReaderException(CoderError,UnsupportedCellTypeInTheMatrix,image);
 
     switch (MATLAB_HDR.NameFlag)
     {
       case 0:
-        size = ReadBlobXXXLong(image2);        /* Object name string size */
-        size = 4 * (long) ((size + 3 + 1) / 4);
+        size = ReadBlobXXXLong(image2); /* Object name string size */
+        size = 4 * (((size_t) size + 3 + 1) / 4);
         (void) SeekBlob(image2, size, SEEK_CUR);
         break;
       case 1:
@@ -918,12 +991,13 @@ MATLAB_KO: ThrowMATReaderException(CorruptImageError,ImproperImageHeader,image);
     CellType = ReadBlobXXXLong(image2);    /* Additional object type */
     if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
           "MATLAB_HDR.CellType: %d",CellType);
-  
-    (void) ReadBlob(image2, 4, &size);     /* data size */
+
+    if(4 != ReadBlob(image2,4,&size))     /* data size */
+        goto MATLAB_KO;
 
 NEXT_FRAME:
       /* Image is gray when no complex flag is set and 2D Matrix */
-    image->is_grayscale = (MATLAB_HDR.DimFlag==8) && 
+    image->is_grayscale = (MATLAB_HDR.DimFlag==8) &&
            ((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0);
 
     switch (CellType)
@@ -931,64 +1005,66 @@ NEXT_FRAME:
       case miINT8:
       case miUINT8:
         sample_size = 8;
-        if(MATLAB_HDR.StructureFlag & FLAG_LOGICAL) 
+        if(MATLAB_HDR.StructureFlag & FLAG_LOGICAL)
           image->depth = 1;
         else
           image->depth = Min(QuantumDepth,8);         /* Byte type cell */
         import_options.sample_type = UnsignedQuantumSampleType;
-        ldblk = (long) MATLAB_HDR.SizeX;      
+        ldblk = (long) MATLAB_HDR.SizeX;
         break;
       case miINT16:
       case miUINT16:
         sample_size = 16;
         image->depth = Min(QuantumDepth,16);        /* Word type cell */
         ldblk = (long) (2 * MATLAB_HDR.SizeX);
-        import_options.sample_type = UnsignedQuantumSampleType;       
+        import_options.sample_type = UnsignedQuantumSampleType;
         break;
       case miINT32:
       case miUINT32:
         sample_size = 32;
         image->depth = Min(QuantumDepth,32);        /* Dword type cell */
-        ldblk = (long) (4 * MATLAB_HDR.SizeX);      
-        import_options.sample_type = UnsignedQuantumSampleType;      
+        ldblk = (long) (4 * MATLAB_HDR.SizeX);
+        import_options.sample_type = UnsignedQuantumSampleType;
         break;
       case miINT64:
       case miUINT64:
         sample_size = 64;
         image->depth = Min(QuantumDepth,32);        /* Qword type cell */
-        ldblk = (long) (8 * MATLAB_HDR.SizeX);      
-        import_options.sample_type = UnsignedQuantumSampleType;      
-        break;   
+        ldblk = (long) (8 * MATLAB_HDR.SizeX);
+        import_options.sample_type = UnsignedQuantumSampleType;
+        break;
       case miSINGLE:
         sample_size = 32;
         image->depth = Min(QuantumDepth,32);        /* double type cell */
         import_options.sample_type = FloatQuantumSampleType;
 #if 0
       if (sizeof(float) != 4)
-        ThrowMATReaderException(CoderError, IncompatibleSizeOfFloat, image);
+        ThrowImg2MATReaderException(CoderError, IncompatibleSizeOfFloat, image);
 #endif
         if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX)
-       {                                           /* complex float type cell */
-       }
+        {                                           /* complex float type cell */
+        }
         ldblk = (long) (4 * MATLAB_HDR.SizeX);
         break;
       case miDOUBLE:
-        sample_size = 64; 
+        sample_size = 64;
         image->depth = Min(QuantumDepth,32);        /* double type cell */
         import_options.sample_type = FloatQuantumSampleType;
         if (sizeof(double) != 8)
-          ThrowMATReaderException(CoderError, IncompatibleSizeOfDouble, image);
+        {
+          ThrowImg2MATReaderException(CoderError, IncompatibleSizeOfDouble, image);  /* this causes immediate return. */
+        }
         if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX)
-       {                         /* complex double type cell */        
-       }
+        {                         /* complex double type cell */
+        }
         ldblk = (long) (8 * MATLAB_HDR.SizeX);
         break;
       default:
-        ThrowMATReaderException(CoderError, UnsupportedCellTypeInTheMatrix, image)
+        ThrowImg2MATReaderException(CoderError, UnsupportedCellTypeInTheMatrix, image)
     }
 
     image->columns = MATLAB_HDR.SizeX;
-    image->rows = MATLAB_HDR.SizeY;    
+    image->rows = MATLAB_HDR.SizeY;
     image->colors = 1l << image->depth;
     if(image->columns == 0 || image->rows == 0)
       goto MATLAB_KO;
@@ -997,7 +1073,7 @@ NEXT_FRAME:
 
     if(CheckImagePixelLimits(image, exception) != MagickPass)
     {
-      ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+      ThrowImg2MATReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
     }
 
     /* ----- Create gray palette ----- */
@@ -1006,10 +1082,12 @@ NEXT_FRAME:
     {
       if(image->colors>256) image->colors = 256;
 
-      if (!AllocateImageColormap(image, image->colors))
+      if(AllocateImageColormap(image, image->colors) != MagickPass)
       {
-NoMemory: ThrowMATReaderException(ResourceLimitError, MemoryAllocationFailed,
-                           image)}
+         if(logging)
+           (void)LogMagickEvent(CoderEvent,GetMagickModule(), "Cannot allocate colormap with %d colors.", image->colors);
+NoMemory: ThrowImg2MATReaderException(ResourceLimitError, MemoryAllocationFailed, image)
+      }
     }
 
     /*
@@ -1022,75 +1100,78 @@ NoMemory: ThrowMATReaderException(ResourceLimitError, MemoryAllocationFailed,
       image->columns = image->rows;
       image->rows = temp;
       goto skip_reading_current;
-    }  
+    }
 
   /* ----- Load raster data ----- */
-    BImgBuff = MagickAllocateMemory(unsigned char *,(size_t) (ldblk));    /* Ldblk was set in the check phase */
+    BImgBuff = MagickAllocateArray(unsigned char *,(size_t) (ldblk),sizeof(double));    /* Ldblk was set in the check phase */
     if (BImgBuff == NULL)
       goto NoMemory;
+    (void) memset(BImgBuff,0,ldblk*sizeof(double));
 
     if (CellType==miDOUBLE)        /* Find Min and Max Values for floats */
     {
       (void) MagickFindRawImageMinMax(image2, import_options.endian,MATLAB_HDR.SizeX,
                                       MATLAB_HDR.SizeY,DoublePixel, ldblk, BImgBuff,
-                                      &import_options.double_minvalue, 
+                                      &import_options.double_minvalue,
                                       &import_options.double_maxvalue);
     }
     if (CellType==miSINGLE)        /* Find Min and Max Values for floats */
     {
       (void) MagickFindRawImageMinMax(image2, import_options.endian,MATLAB_HDR.SizeX,
-                                      MATLAB_HDR.SizeY,FloatPixel, ldblk, BImgBuff, 
-                                      &import_options.double_minvalue, 
+                                      MATLAB_HDR.SizeY,FloatPixel, ldblk, BImgBuff,
+                                      &import_options.double_minvalue,
                                       &import_options.double_maxvalue);
     }
 
     /* Main loop for reading all scanlines */
     if(z==1) z=0; /* read grey scanlines */
-               /* else read color scanlines */
+                /* else read color scanlines */
     do
     {
       for(i = 0; i < (long) MATLAB_HDR.SizeY; i++)
       {
         q = SetImagePixels(image,0,MATLAB_HDR.SizeY-i-1,image->columns,1);
         if (q == (PixelPacket *)NULL)
-       {
-         if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+        {
+          if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
               "  MAT set image pixels returns unexpected NULL on a row %u.", (unsigned)(MATLAB_HDR.SizeY-i-1));
-         goto skip_reading_current;            /* Skip image rotation, when cannot set image pixels */   
-       }
+          goto skip_reading_current;            /* Skip image rotation, when cannot set image pixels */
+        }
         if(ReadBlob(image2,ldblk,(char *)BImgBuff) != (size_t) ldblk)
-       {
-         if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+        {
+          if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
              "  MAT cannot read scanrow %u from a file.", (unsigned)(MATLAB_HDR.SizeY-i-1));
-         goto ExitLoop;
-       }
+          goto ExitLoop;       /* It would be great to be abble to read corrupted images. */
+                               /* this goto will abort reading, but there remains not fully read image 
+                                  in the memory. */
+        }
         if((CellType==miINT8 || CellType==miUINT8) && (MATLAB_HDR.StructureFlag & FLAG_LOGICAL))
         {
           FixLogical((unsigned char *)BImgBuff,ldblk);
           if(ImportImagePixelArea(image,z2qtype[z],1,BImgBuff,&import_options,0) == MagickFail)
-         {
+          {
 ImportImagePixelAreaFailed:
-           if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+            if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
               "  MAT failed to ImportImagePixelArea for a row %u", (unsigned)(MATLAB_HDR.SizeY-i-1));
-           break;
-         }
+            break;
+          }
         }
         else
         {
           if(ImportImagePixelArea(image,z2qtype[z],sample_size,BImgBuff,&import_options,0) == MagickFail)
-           goto ImportImagePixelAreaFailed;
+            goto ImportImagePixelAreaFailed;
 
-          if (z<=1 &&                   /* fix only during a last pass z==0 || z==1 */
-               (CellType==miINT8 || CellType==miINT16 || CellType==miINT32 || CellType==miINT64))
-           FixSignedValues(q,MATLAB_HDR.SizeX);
+          if (z<=1 &&                    /* fix only during a last pass z==0 || z==1 */
+                (CellType==miINT8 || CellType==miINT16 || CellType==miINT32 || CellType==miINT64))
+            FixSignedValues(q,MATLAB_HDR.SizeX);
         }
 
         if (!SyncImagePixels(image))
-       {
-         if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+        {
+          if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
             "  MAT failed to sync image pixels for a row %u", (unsigned)(MATLAB_HDR.SizeY-i-1));
-         goto ExitLoop;
-       }
+          goto ExitLoop;
+        }
       }
     } while(z-- >= 2);
 ExitLoop:
@@ -1118,28 +1199,28 @@ ExitLoop:
 
       if (CellType==miDOUBLE)
         for (i = 0; i < (long) MATLAB_HDR.SizeY; i++)
-       {
+        {
           ReadBlobXXXDoubles(image2, ldblk, (double *)BImgBuff);
           InsertComplexDoubleRow((double *)BImgBuff, i, image, MinVal_c, MaxVal_c);
-       }
+        }
 
       if (CellType==miSINGLE)
         for (i = 0; i < (long) MATLAB_HDR.SizeY; i++)
-       {
+        {
           ReadBlobXXXFloats(image2, ldblk, (float *)BImgBuff);
           InsertComplexFloatRow((float *)BImgBuff, i, image, MinVal_c, MaxVal_c);
-       }    
+        }
     }
 
       /* Image is gray when no complex flag is set and 2D Matrix AGAIN!!! */
-    image->is_grayscale = (MATLAB_HDR.DimFlag==8) && 
+    image->is_grayscale = (MATLAB_HDR.DimFlag==8) &&
              ((MATLAB_HDR.StructureFlag & FLAG_COMPLEX) == 0);
     image->is_monochrome = image->depth==1;
     if(image->is_monochrome)
       image->colorspace=GRAYColorspace;
 
-    if(image2==image)          /* image2 is either native image or decompressed block. */
-        image2 = NULL;         /* Remove shadow copy to an image before rotation. */
+    if(image2==image)           /* image2 is either native image or decompressed block. */
+        image2 = NULL;          /* Remove shadow copy to an image before rotation. */
 
       /*  Rotate image. */
     rotated_image = RotateImage(image, 90.0, exception);
@@ -1152,18 +1233,18 @@ ExitLoop:
       blob = rotated_image->blob;
       rotated_image->blob = image->blob;
       rotated_image->colors = image->colors;
-      image->blob = blob;      
+      image->blob = blob;
       AppendImageToList(&image,rotated_image);
-      DeleteImageFromList(&image);      
+      DeleteImageFromList(&image);
     }
 
 skip_reading_current:
 
     if(image2==image) image2 = NULL;
 
-      /* Allocate next image structure. */    
+      /* Allocate next image structure. */
     AllocateNextImage(image_info,image);
-    if (image->next == (Image *) NULL) break;                
+    if (image->next == (Image *) NULL) break;
     image=SyncNextImageInList(image);
     image->columns = image->rows = 0;
     image->colors=0;
@@ -1173,38 +1254,39 @@ skip_reading_current:
     BImgBuff = NULL;
 
     if(--Frames>0)
-    {
+    {      
       z = z2;
       if(image2==NULL) image2 = image;
-      goto NEXT_FRAME;
+      if(!EOFBlob(image) && TellBlob(image)<filepos)
+          goto NEXT_FRAME;
     }
 
     if(image2!=NULL)
-      if(image2!=image)                /* Does shadow temporary decompressed image exist? */
+      if(image2!=image)         /* Does shadow temporary decompressed image exist? */
       {
-/*     CloseBlob(image2); */
+/*      CloseBlob(image2); */
         DeleteImageFromList(&image2);
-       if(clone_info)
-       {
+        if(clone_info)
+        {
           if(clone_info->file)
-         {
+          {
             fclose(clone_info->file);
             clone_info->file = NULL;
             (void) unlink(clone_info->filename);
-         }
-        }    
+          }
+        }
       }
 
   }
 
   MagickFreeMemory(BImgBuff);
 END_OF_READING:
-  CloseBlob(image);
+  CloseBlob(image); 
 
   {
-    Image *p;    
+    Image *p;
     long scene=0;
-    
+
     /*
       Rewind list, removing any empty images while rewinding.
     */
@@ -1221,7 +1303,7 @@ END_OF_READING:
           p=p->previous;
         }
       }
-    
+
     /*
       Fix scene numbers
     */
@@ -1229,7 +1311,7 @@ END_OF_READING:
       p->scene=scene++;
   }
 
-  if(clone_info != NULL)       /* cleanup garbage file from compression */
+  if(clone_info != NULL)        /* cleanup garbage file from compression */
   {
     if(clone_info->file)
     {
@@ -1257,7 +1339,7 @@ END_OF_READING:
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  Function WriteMATLABImage writes an Matlab matrix to a file.  
+%  Function WriteMATLABImage writes an Matlab matrix to a file.
 %
 %  The format of the WriteMATLABImage method is:
 %
@@ -1288,7 +1370,7 @@ static unsigned int WriteMATLABImage(const ImageInfo *image_info,Image *image)
   unsigned char *pixels;
   int is_gray;
   unsigned char ImageName = 'A';
-  
+
   current_time = time((time_t *)NULL);
   t = localtime(&current_time);
 
@@ -1299,10 +1381,10 @@ static unsigned int WriteMATLABImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
-  logging=LogMagickEvent(CoderEvent,GetMagickModule(),"enter MAT");
+  logging = LogMagickEvent(CoderEvent,GetMagickModule(),"enter MAT");
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
-    ThrowWriterException(FileOpenError,UnableToOpenFile,image);  
+    ThrowWriterException(FileOpenError,UnableToOpenFile,image);
 
   /*
     Store MAT header.
@@ -1318,7 +1400,7 @@ static unsigned int WriteMATLABImage(const ImageInfo *image_info,Image *image)
   MATLAB_HDR[0x7C]=0;
   MATLAB_HDR[0x7D]=1;
   MATLAB_HDR[0x7E]='I';
-  MATLAB_HDR[0x7F]='M';  
+  MATLAB_HDR[0x7F]='M';
   (void) WriteBlob(image,sizeof(MATLAB_HDR),MATLAB_HDR);
 
   pixels=(unsigned char *) NULL;
@@ -1326,34 +1408,34 @@ static unsigned int WriteMATLABImage(const ImageInfo *image_info,Image *image)
   {
     pixels=MagickAllocateMemory(unsigned char *,image->rows);
     if (pixels == (unsigned char *) NULL)
-      ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);  
+      ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
 
     is_gray = IsGrayImage(image,&image->exception);
     z = is_gray ? 0 : 3;
 
     DataSize = image->rows /*Y*/ * image->columns /*X*/;
     if(!is_gray) DataSize *= 3 /*Z*/;
-    padding=((unsigned char)(DataSize-1) & 0x7) ^ 0x7;
+    padding = ((unsigned char)(DataSize-1) & 0x7) ^ 0x7;
 
     (void) WriteBlobLSBLong(image, miMATRIX); /* 0x80 */
     (void) WriteBlobLSBLong(image, DataSize + padding + (is_gray?48l:56l)); /* 0x84 */
     (void) WriteBlobLSBLong(image, 0x6); /* 0x88 */
     (void) WriteBlobLSBLong(image, 0x8); /* 0x8C */
-    (void) WriteBlobLSBLong(image, 0x6); /* 0x90 */  
-    (void) WriteBlobLSBLong(image, 0);   
+    (void) WriteBlobLSBLong(image, 0x6); /* 0x90 */
+    (void) WriteBlobLSBLong(image, 0);
     (void) WriteBlobLSBLong(image, 0x5); /* 0x98 */
     (void) WriteBlobLSBLong(image, is_gray?0x8:0xC); /* 0x9C - DimFlag */
-    (void) WriteBlobLSBLong(image, image->rows);    /* x: 0xA0 */  
-    (void) WriteBlobLSBLong(image, image->columns); /* y: 0xA4 */  
+    (void) WriteBlobLSBLong(image, image->rows);    /* x: 0xA0 */
+    (void) WriteBlobLSBLong(image, image->columns); /* y: 0xA4 */
     if(!is_gray)
     {
-      (void) WriteBlobLSBLong(image, 3); /* z: 0xA8 */  
+      (void) WriteBlobLSBLong(image, 3); /* z: 0xA8 */
       (void) WriteBlobLSBLong(image, 0);
     }
-    (void) WriteBlobLSBShort(image, 1);  /* 0xB0 */  
+    (void) WriteBlobLSBShort(image, 1);  /* 0xB0 */
     (void) WriteBlobLSBShort(image, 1);  /* 0xB2 */
     (void) WriteBlobLSBLong(image, ImageName++); /* 0xB4  - here is a small bug only 'A' .. 'Z images could be generated properly */
-    (void) WriteBlobLSBLong(image, 0x2); /* 0xB8 */  
+    (void) WriteBlobLSBLong(image, 0x2); /* 0xB8 */
     (void) WriteBlobLSBLong(image, DataSize); /* 0xBC */
 
     /*
@@ -1373,7 +1455,7 @@ static unsigned int WriteMATLABImage(const ImageInfo *image_info,Image *image)
       do
       {
         for (y=0; y<(long)image->columns; y++)
-       {
+        {
           progress_quantum++;
           (void) AcquireImagePixels(image,y,0,1,image->rows,&image->exception);
           (void) ExportImagePixelArea(image,z2qtype[z],8,pixels,0,0);
@@ -1381,9 +1463,9 @@ static unsigned int WriteMATLABImage(const ImageInfo *image_info,Image *image)
           if (QuantumTick(progress_quantum,progress_span))
             if (!MagickMonitorFormatted(progress_quantum,progress_span,&image->exception,
                                         SaveImageText,image->filename,
-                                       image->columns,image->rows))
+                                        image->columns,image->rows))
               goto BreakAll;
-       }    
+        }
       } while(z-- >= 2);
     }
 BreakAll:
@@ -1392,7 +1474,7 @@ BreakAll:
 
     status=True;
 
-    if(pixels) 
+    if(pixels)
      {MagickFreeMemory(pixels);pixels=NULL;}
     if(image->next==NULL) break;
     image=SyncNextImageInList(image);
@@ -1403,7 +1485,7 @@ BreakAll:
 
   if (logging)
     (void)LogMagickEvent(CoderEvent,GetMagickModule(),"return MAT");
-  
+
   return(status);
 }
 \f
@@ -1442,7 +1524,7 @@ ModuleExport void RegisterMATImage(void)
 #if defined(HasZLIB)
                         "MATLAB Level 4.0-7.0 image formats";
 #else
-                       "MATLAB Level 4.0-6.0 image formats";
+                        "MATLAB Level 4.0-6.0 image formats";
 #endif
   entry->module = "MAT";
   entry->blob_support=False;
index 6872a94..03fe94b 100644 (file)
@@ -191,7 +191,7 @@ static unsigned int WriteMATTEImage(const ImageInfo *image_info,Image *image)
       if (QuantumTick(y,image->rows))
         if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                     SaveImageText,image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
   }
   (void) FormatString(matte_image->filename,"MIFF:%.1024s",image->filename);
index b602181..7aeb994 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -181,10 +181,29 @@ static int stringnicmp(const char *p,const char *q,size_t n)
   return(toupper((int) *p)-toupper((int) *q));
 }
 
-static size_t convertHTMLcodes(char *s, const size_t len)
+/*
+   This routine parses the next HTML ampersand code ("&FOO;") from the
+   provided string and replaces the HTML ampersand code with the
+   equivalent character, moving the remainder of the string forward.
+   The return value is the number of characters consumed (length of
+   code minus one character).
+ */
+static size_t convertHTMLcodes(char *s)
 {
+  size_t len;
+  size_t i;
   int val;
 
+  for (i = 0, len = 0; (i < 7U) && (s[i] != '\0') ; i++)
+    {
+      if (s[i] == ';')
+        {
+          len=i+1;
+          break;
+        }
+    }
+
+
   if ((len == 0) || (s == (char*) NULL) || (*s=='\0'))
     return 0;
 
@@ -197,8 +216,7 @@ static size_t convertHTMLcodes(char *s, const size_t len)
     and that it does not require the terminating ';' to appear in
     order to parse the numeric argument.
   */
-  if ((len > 3) && (s[1] == '#') && (strchr(s,';') != (char *) NULL) &&
-      (sscanf(s,"&#%d;",&val) == 1))
+  if ((len > 3) && (s[1] == '#') && (sscanf(s,"&#%d;",&val) == 1))
     {
       size_t o = 3;
       while (s[o] != ';')
@@ -212,11 +230,11 @@ static size_t convertHTMLcodes(char *s, const size_t len)
       *s = val;
       return o;
     }
-  else
+  else /* Symbolic code, e.g. "&amp;" */
     {
       int
         i,
-        codes = sizeof(html_codes) / sizeof(html_code);
+        codes = ArraySize(html_codes);
 
       for (i=0; i < codes; i++)
       {
@@ -402,7 +420,7 @@ static long parse8BIM(Image *ifile, Image *ofile)
                   char
                     *s = &token[next-1];
 
-                  codes_len = convertHTMLcodes(s, strlen(s));
+                  codes_len = convertHTMLcodes(s);
                   if (codes_len > len)
                     len = 0;
                   else
@@ -695,7 +713,7 @@ static long parse8BIMW(Image *ifile, Image *ofile)
                   char
                     *s = &token[next-1];
 
-                  codes_len = convertHTMLcodes(s, strlen(s));
+                  codes_len = convertHTMLcodes(s);
                   if (codes_len > len)
                     len = 0;
                   else
@@ -1097,7 +1115,7 @@ static Image *ReadMETAImage(const ImageInfo *image_info,
   size_t
     length;
 
-  unsigned int
+  MagickPassFail
     status;
 
   unsigned char
@@ -1112,7 +1130,7 @@ static Image *ReadMETAImage(const ImageInfo *image_info,
   assert(exception->signature == MagickSignature);
   image=AllocateImage(image_info);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
-  if (status == False)
+  if (status == MagickFail)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
   image->columns=1;
   image->rows=1;
@@ -1133,10 +1151,19 @@ static Image *ReadMETAImage(const ImageInfo *image_info,
           ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
             image)
         }
+      (void) memset(blob,0,length);
       AttachBlob(buff->blob,blob,length);
       if (LocaleCompare(image_info->magick,"8BIMTEXT") == 0)
         {
           length=parse8BIM(image, buff);
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "META CODER Parse8BIM returned: %lu",
+                                (unsigned long) length);
+          if (length == 0)
+            {
+              status = MagickFail;
+              goto t8bim_failure;
+            }
           if (length & 1)
             (void) WriteBlobByte(buff,0x0);
         }
@@ -1146,6 +1173,11 @@ static Image *ReadMETAImage(const ImageInfo *image_info,
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                 "META CODER Parse8BIMW returned: %lu",
                                 (unsigned long) length);
+          if (length == 0)
+            {
+              status = MagickFail;
+              goto t8bim_failure;
+            }
           if (length & 1)
             (void) WriteBlobByte(buff,0x0);
         }
@@ -1165,9 +1197,12 @@ static Image *ReadMETAImage(const ImageInfo *image_info,
                             "Store IPTC profile, size %lu bytes",
                             (unsigned long) length);
       (void) SetImageProfile(image,"IPTC",blob,length);
+    t8bim_failure:;
       DetachBlob(buff->blob);
       MagickFreeMemory(blob);
       DestroyImage(buff);
+      if (status == MagickFail)
+        ThrowReaderException(CorruptImageError,CorruptImage,image);
     }
   if (LocaleNCompare(image_info->magick,"APP1",4) == 0)
     {
@@ -1614,7 +1649,7 @@ static size_t GetIPTCStream(const unsigned char *blob, size_t blob_length, size_
   size_t
     tag_length,
     blob_remaining;
-    
+
   p=blob;
   blob_remaining=blob_length;
   if ((*p == 0x1c) && (*(p+1) == 0x02))
@@ -1646,7 +1681,7 @@ static size_t GetIPTCStream(const unsigned char *blob, size_t blob_length, size_
     if (c >= blob_remaining) break;
     p+=c;
     blob_remaining-=c;
-      
+
     /* Read data length */
     if (blob_remaining < 4) break;
     tag_length=(((unsigned long)*p) << 24) | (((unsigned long)*(p+1)) << 16) |
@@ -1669,7 +1704,7 @@ static size_t GetIPTCStream(const unsigned char *blob, size_t blob_length, size_
     p+=tag_length;
     blob_remaining-=tag_length;
   }
-  
+
   /* Find the beginning of the IPTC info */
   p=blob;
   tag_length=0;
@@ -1733,11 +1768,11 @@ iptc_find:
     info_length++;
     if (c & (unsigned char) 0x80)
       {
-       /* long format */
-       tag_length=0;
-       for (i=0; i < 4; i++)
+        /* long format */
+        tag_length=0;
+        for (i=0; i < 4; i++)
         {
-         tag_length <<= 8;
+          tag_length <<= 8;
           tag_length |= (*p++);
           blob_length--;
           if (blob_length == 0)
@@ -1747,7 +1782,7 @@ iptc_find:
       }
     else
       {
-       /* short format */
+        /* short format */
         tag_length=((long) c) << 8;
         c=(*p++);
         blob_length--;
@@ -2140,9 +2175,12 @@ static int format8BIM(Image *ifile, Image *ofile)
     *PString=0,
     *str=0;
 
-  resCount = 0;
+  magick_off_t
+    file_size;
 
-  c =ReadBlobByte(ifile);
+  file_size=GetBlobSize(ifile);
+  resCount = 0;
+  c = ReadBlobByte(ifile);
   while (c != EOF)
     {
       if (c == '8')
@@ -2156,8 +2194,9 @@ static int format8BIM(Image *ifile, Image *ofile)
               c=ReadBlobByte(ifile);
               if (c == EOF)
                 {
-                  Format8BIMLiberate();
-                  return -1;
+                  ThrowException(&ofile->exception,CorruptImageError,UnexpectedEndOfFile,
+                                 ofile->filename);
+                  goto format8BIMError;
                 }
               buffer[i] = (unsigned char) c;
             }
@@ -2175,8 +2214,9 @@ static int format8BIM(Image *ifile, Image *ofile)
       ID = ReadBlobMSBShort(ifile);
       if (ID < 0)
         {
-          Format8BIMLiberate();
-          return -1;
+          ThrowException(&ofile->exception,CorruptImageError,ImproperImageHeader,
+                         ofile->filename);
+          goto format8BIMError;
         }
       {
         unsigned char
@@ -2185,24 +2225,26 @@ static int format8BIM(Image *ifile, Image *ofile)
         c=ReadBlobByte(ifile);
         if (c == EOF)
           {
-            Format8BIMLiberate();
-            return -1;
+            ThrowException(&ofile->exception,CorruptImageError,UnexpectedEndOfFile,
+                           ofile->filename);
+            goto format8BIMError;
           }
         plen = (unsigned char) c;
         PString=MagickAllocateMemory(unsigned char *,(unsigned int) (plen+1));
         if (PString == (unsigned char *) NULL)
           {
-            (void) printf("MemoryAllocationFailed");
-            Format8BIMLiberate();
-            return 0;
+            ThrowException(&ofile->exception,ResourceLimitError,MemoryAllocationFailed,
+                           ofile->filename);
+            goto format8BIMError;
           }
         for (i=0; i<plen; i++)
           {
             c=ReadBlobByte(ifile);
             if (c == EOF)
               {
-                Format8BIMLiberate();
-                return -1;
+                ThrowException(&ofile->exception,CorruptImageError,UnexpectedEndOfFile,
+                               ofile->filename);
+                goto format8BIMError;
               }
             PString[i] = (unsigned char) c;
           }
@@ -2212,35 +2254,41 @@ static int format8BIM(Image *ifile, Image *ofile)
             c=ReadBlobByte(ifile);
             if (c == EOF)
               {
-                Format8BIMLiberate();
-                return -1;
+                ThrowException(&ofile->exception,CorruptImageError,UnexpectedEndOfFile,
+                               ofile->filename);
+                goto format8BIMError;
               }
           }
       }
       Size = ReadBlobMSBLong(ifile);
-      if (Size < 0)
+      if ((Size <= 0) || (Size > (file_size - TellBlob(ifile))))
         {
-          Format8BIMLiberate();
-          return -1;
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Invalid chunk size: %" MAGICK_OFF_F "d", Size);
+          ThrowException(&ofile->exception,CorruptImageError,ImproperImageHeader,
+                         ofile->filename);
+          goto format8BIMError;
         }
       /* make a buffer to hold the data and snag it from the input stream */
-      str=MagickAllocateMemory(unsigned char *,(size_t) Size);
+      str=MagickAllocateMemory(unsigned char *,(size_t) Size+1);
       if (str == (unsigned char *) NULL)
         {
-          (void) printf("MemoryAllocationFailed");
-          Format8BIMLiberate();
-          return 0;
+          ThrowException(&ofile->exception,ResourceLimitError,MemoryAllocationFailed,
+                           ofile->filename);
+          goto format8BIMError;
         }
-      for (i=0; i<Size; i++)
+      for (i=0; i < Size; i++)
         {
           c=ReadBlobByte(ifile);
           if (c == EOF)
             {
-              Format8BIMLiberate();
-              return -1;
+              ThrowException(&ofile->exception,CorruptImageError,UnexpectedEndOfFile,
+                             ofile->filename);
+              goto format8BIMError;
             }
           str[i] = (unsigned char) c;
         }
+      str[i] = '\0';
 
       /* we currently skip thumbnails, since it does not make
        * any sense preserving them in a real world application
@@ -2270,9 +2318,15 @@ static int format8BIM(Image *ifile, Image *ofile)
       c=ReadBlobByte(ifile);
     }
   return resCount;
+
+  /* Error return path */
+ format8BIMError:
+
+  Format8BIMLiberate();
+  return -1;
 }
 
-static unsigned int WriteMETAImage(const ImageInfo *image_info,Image *image)
+static MagickPassFail WriteMETAImage(const ImageInfo *image_info,Image *image)
 {
   const unsigned char
     *profile;
@@ -2280,7 +2334,7 @@ static unsigned int WriteMETAImage(const ImageInfo *image_info,Image *image)
   size_t
     profile_length;
 
-  unsigned int
+  MagickPassFail
     status;
 
   /*
@@ -2298,11 +2352,11 @@ static unsigned int WriteMETAImage(const ImageInfo *image_info,Image *image)
       if((profile=GetImageProfile(image,"8BIM",&profile_length)) == 0)
         ThrowWriterException(CoderError,No8BIMDataIsAvailable,image);
       status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
-      if (status == False)
+      if (status == MagickFail)
         ThrowWriterException(FileOpenError,UnableToOpenFile,image);
       (void) WriteBlob(image,profile_length,(void *) profile);
       CloseBlob(image);
-      return(True);
+      return MagickPass;
     }
   if (LocaleCompare(image_info->magick,"IPTC") == 0)
     {
@@ -2324,7 +2378,7 @@ static unsigned int WriteMETAImage(const ImageInfo *image_info,Image *image)
         }
       (void) WriteBlob(image,length,info);
       CloseBlob(image);
-      return(True);
+      return MagickPass;
     }
   if (LocaleCompare(image_info->magick,"8BIMTEXT") == 0)
     {
@@ -2334,7 +2388,7 @@ static unsigned int WriteMETAImage(const ImageInfo *image_info,Image *image)
       if((profile=GetImageProfile(image,"8BIM",&profile_length)) == 0)
         ThrowWriterException(CoderError,No8BIMDataIsAvailable,image);
       status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
-      if (status == False)
+      if (status == MagickFail)
         ThrowWriterException(FileOpenError,UnableToOpenFile,image);
       buff=AllocateImage((ImageInfo *) NULL);
       if (buff == (Image *) NULL)
@@ -2342,15 +2396,17 @@ static unsigned int WriteMETAImage(const ImageInfo *image_info,Image *image)
           ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
         }
       AttachBlob(buff->blob,profile,profile_length);
-      (void) format8BIM(buff,image);
+      status = MagickPass;
+      if (format8BIM(buff,image) <= 0)
+        status = MagickFail;
       DetachBlob(buff->blob);
       DestroyImage(buff);
       CloseBlob(image);
-      return(True);
+      return status;
     }
   if (LocaleCompare(image_info->magick,"8BIMWTEXT") == 0)
     {
-      return(False);
+      return(MagickFail);
     }
   if (LocaleCompare(image_info->magick,"IPTCTEXT") == 0)
     {
@@ -2371,7 +2427,7 @@ static unsigned int WriteMETAImage(const ImageInfo *image_info,Image *image)
       if (length == 0)
         ThrowWriterException(CoderError,NoIPTCInfoWasFound,image);
       status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
-      if (status == False)
+      if (status == MagickFail)
         ThrowWriterException(FileOpenError,UnableToOpenFile,image);
       buff=AllocateImage((ImageInfo *) NULL);
       if (buff == (Image *) NULL)
@@ -2383,11 +2439,11 @@ static unsigned int WriteMETAImage(const ImageInfo *image_info,Image *image)
       DetachBlob(buff->blob);
       DestroyImage(buff);
       CloseBlob(image);
-      return(True);
+      return MagickPass;
     }
   if (LocaleCompare(image_info->magick,"IPTCWTEXT") == 0)
     {
-      return(False);
+      return(MagickFail);
     }
   if ((LocaleCompare(image_info->magick,"APP1") == 0) ||
       (LocaleCompare(image_info->magick,"EXIF") == 0) ||
@@ -2399,11 +2455,11 @@ static unsigned int WriteMETAImage(const ImageInfo *image_info,Image *image)
       if((profile=GetImageProfile(image,image_info->magick,&profile_length)) == 0)
         ThrowWriterException(CoderError,NoAPP1DataIsAvailable,image);
       status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
-      if (status == False)
+      if (status == MagickFail)
         ThrowWriterException(FileOpenError,UnableToOpenFile,image);
       (void) WriteBlob(image,(int) profile_length, (char *) profile);
       CloseBlob(image);
-      return(True);
+      return MagickPass;
     }
   if ((LocaleCompare(image_info->magick,"ICC") == 0) ||
       (LocaleCompare(image_info->magick,"ICM") == 0))
@@ -2415,11 +2471,11 @@ static unsigned int WriteMETAImage(const ImageInfo *image_info,Image *image)
       if((profile=GetImageProfile(image,"ICM",&profile_length)) == 0)
         ThrowWriterException(CoderError,NoColorProfileAvailable,image);
       status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
-      if (status == False)
+      if (status == MagickFail)
         ThrowWriterException(FileOpenError,UnableToOpenFile,image);
       (void) WriteBlob(image,profile_length,(void *) profile);
       CloseBlob(image);
-      return(True);
+      return MagickPass;
     }
-  return(False);
+  return MagickFail;
 }
index c578cbf..2ab428b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -137,7 +137,7 @@ static unsigned int IsMIFF(const unsigned char *magick,const size_t length)
 */
 
 
-static unsigned int
+static MagickPassFail
 ImportRLEPixels(Image *image,
                 const QuantumType quantum_type,
                 const unsigned int quantum_size,
@@ -683,7 +683,7 @@ ImportRLEPixels(Image *image,
       {
       }
     }
-  return(True);
+  return(MagickPass);
 }
 
 #if 0
@@ -700,10 +700,11 @@ static void BZLIBFreeFunc(void *opaque, void *address)
 #endif
 
 #if defined(HasZLIB)
+static voidpf ZLIBAllocFunc(voidpf opaque, uInt items, uInt size) MAGICK_FUNC_MALLOC;
 static voidpf ZLIBAllocFunc(voidpf opaque, uInt items, uInt size)
 {
   ARG_NOT_USED(opaque);
-  return MagickMallocCleared((size_t) items*size);
+  return MagickMallocCleared(MagickArraySize(items,size));
 }
 static void ZLIBFreeFunc(voidpf opaque, voidpf address)
 {
@@ -714,6 +715,8 @@ static void ZLIBFreeFunc(voidpf opaque, voidpf address)
 
 #define ThrowMIFFReaderException(code_,reason_,image_) \
 do { \
+  MagickFreeMemory(comment); \
+  MagickFreeMemory(values); \
   if (number_of_profiles > 0) \
     { \
       unsigned int _index; \
@@ -777,12 +780,14 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
   void
     *pixels_p;
 
-  unsigned int
+  MagickPassFail
     status;
 
   unsigned int
     colors,
+    comment_count,
     depth,
+    keyword_count,
     packet_size,
     quantum_size;
 
@@ -792,6 +797,10 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
   unsigned int
     number_of_profiles=0;
 
+  char
+    *comment = NULL,
+    *values = NULL;
+
 #if defined(HasZLIB)
   z_stream
     zip_info;
@@ -806,7 +815,7 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
   assert(exception->signature == MagickSignature);
   image=AllocateImage(image_info);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
-  if (status == False)
+  if (status == MagickFail)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
   /*
     Decode image header;  header terminates one character beyond a ':'.
@@ -828,6 +837,8 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
     image->depth=8;
     image->compression=NoCompression;
     image->storage_class=DirectClass;
+    comment_count=0;
+    keyword_count=0;
     while (isgraph(c) && (c != ':'))
     {
       register char
@@ -835,13 +846,30 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
 
       if (c == '{')
         {
-          char
-            *comment;
-
           size_t
             comment_length;
 
           /*
+            Insist that format is identified prior to any comments.
+          */
+          if (id[0] == '\0')
+            {
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Comment precedes format identifier (id=ImageMagick)");
+              ThrowMIFFReaderException(CorruptImageError,ImproperImageHeader,image);
+            }
+
+          /*
+            Insist that only one comment is provided
+          */
+          if (comment_count > 0)
+            {
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Too many comments!");
+              ThrowMIFFReaderException(CorruptImageError,ImproperImageHeader,image);
+            }
+
+          /*
             Read comment-- any text between { }.
           */
           comment_length=MaxTextExtent;
@@ -870,16 +898,15 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
             ThrowMIFFReaderException(ResourceLimitError,MemoryAllocationFailed,
               image);
           *p='\0';
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Comment: \"%s\"", comment);
           (void) SetImageAttribute(image,"comment",comment);
+          comment_count++;
           MagickFreeMemory(comment);
           c=ReadBlobByte(image);
         }
       else
         if (isalnum(c))
           {
-            char
-              *values;
-
             size_t
               values_length;
 
@@ -899,7 +926,18 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
             } while ((c != '=') && (c != EOF));
             *p='\0';
             if (c == EOF)
-              ThrowMIFFReaderException(CorruptImageWarning,ImproperImageHeader,image);
+              ThrowMIFFReaderException(CorruptImageError,ImproperImageHeader,image);
+
+            /*
+              Insist that the first keyword must be 'id' (id=ImageMagick)
+            */
+            if ((keyword_count == 0) && (LocaleCompare(keyword,"id") != 0))
+              {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "First keyword must be 'id' (have '%s')",
+                                      keyword);
+                ThrowMIFFReaderException(CorruptImageError,ImproperImageHeader,image);
+              }
 
             /*
               Get values.
@@ -940,8 +978,18 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
                     break;
               }
             *p='\0';
+            keyword_count++;
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                  "keyword=\"%s\" values=\"%s\"",keyword,values);
+                                  "keyword[%u]=\"%s\" values=\"%s\"",keyword_count,keyword,values);
+            /*
+              Insist that the first keyword value must be 'ImageMagick' (id=ImageMagick)
+            */
+            if ((keyword_count == 1) && (LocaleCompare(values,"ImageMagick") != 0))
+              {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "First keyword/value must be 'id=ImageMagick'");
+                ThrowMIFFReaderException(CorruptImageError,ImproperImageHeader,image);
+              }
             /*
               Assign a value to the specified keyword.
             */
@@ -986,6 +1034,22 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
                         image->storage_class=DirectClass;
                     break;
                   }
+                /* Legacy ImageMagick 4.2.9 used keyword "color-profile" for ICC profile */
+                if (LocaleCompare(keyword,"color-profile") == 0)
+                  {
+                    i=(long) number_of_profiles;
+                    MagickReallocMemory(ProfileInfo *,profiles,(i+1)*sizeof(ProfileInfo));
+                    if (profiles == (ProfileInfo *) NULL)
+                      {
+                        MagickFreeMemory(values);
+                        ThrowMIFFReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+                      }
+                    profiles[i].name=AllocateString("icc");
+                    profiles[i].length=MagickAtoL(values);
+                    profiles[i].info=(unsigned char *) NULL;
+                    number_of_profiles++;
+                    break;
+                  }
                 if (LocaleCompare(keyword,"colors") == 0)
                   {
                     colors=MagickAtoL(values);
@@ -1286,7 +1350,7 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
 
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                           "id=\"%s\" version=%g class=%s colorspace=%s compression=%s matte=%s "
-                         "columns=%lu rows=%lu depth=%u",
+                          "columns=%lu rows=%lu depth=%u",
                           id,version,
                           ClassTypeToString(image->storage_class),
                           ColorspaceTypeToString(image->colorspace),
@@ -1355,10 +1419,12 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
               p=image->directory+strlen(image->directory);
             }
           c=ReadBlobByte(image);
+          if (c == EOF)
+            break;
           *p++=c;
         } while (c != '\0');
       }
+
     /*
       Attached profiles.
     */
@@ -1531,8 +1597,8 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
 #if defined(HasZLIB)
       case ZipCompression:
         {
-         int
-           code=0;
+          int
+            code=0;
 
           for (y=0; y < (long) image->rows; y++)
             {
@@ -1601,14 +1667,15 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
                   code=inflateEnd(&zip_info);
                   status|=code >= 0;
                 }
-              (void) ImportImagePixelArea(image,quantum_type,quantum_size,pixels,0,0);
+              if (!ImportImagePixelArea(image,quantum_type,quantum_size,pixels,0,0))
+                break;
               if (!SyncImagePixels(image))
                 break;
               if (image->previous == (Image *) NULL)
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,exception,
                                               LoadImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
             }
           break;
@@ -1617,8 +1684,8 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
 #if defined(HasBZLIB)
       case BZipCompression:
         {
-         int
-           code=0;
+          int
+            code=0;
 
           for (y=0; y < (long) image->rows; y++)
             {
@@ -1678,14 +1745,15 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
                   code=BZ2_bzDecompressEnd(&bzip_info);
                   status|=code >= 0;
                 }
-              (void) ImportImagePixelArea(image,quantum_type,quantum_size,pixels,0,0);
+              if (!ImportImagePixelArea(image,quantum_type,quantum_size,pixels,0,0))
+                break;
               if (!SyncImagePixels(image))
                 break;
               if (image->previous == (Image *) NULL)
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,exception,
                                               LoadImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
             }
           break;
@@ -1708,14 +1776,15 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
                   length+=*(p-1)+1;
                 }
 
-              (void) ImportRLEPixels(image,quantum_type,quantum_size,pixels);
+              if (!ImportRLEPixels(image,quantum_type,quantum_size,pixels))
+                break;
               if (!SyncImagePixels(image))
                 break;
               if (image->previous == (Image *) NULL)
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,exception,
                                               LoadImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
 
             }
@@ -1729,42 +1798,47 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
               if (q == (PixelPacket *) NULL)
                 break;
               pixels_p=pixels;
-              (void) ReadBlobZC(image,packet_size*image->columns,&pixels_p);
-              (void) ImportImagePixelArea(image,quantum_type,quantum_size,(const unsigned char*) pixels_p,0,0);
+              if (ReadBlobZC(image,packet_size*image->columns,&pixels_p)
+                  != (size_t) packet_size*image->columns)
+                break;
+              if (!ImportImagePixelArea(image,quantum_type,quantum_size,
+                                        (const unsigned char*) pixels_p,0,0))
+                break;
               if (!SyncImagePixels(image))
                 break;
               if (image->previous == (Image *) NULL)
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,exception,
                                               LoadImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
             }
           break;
         }
       } /* End switch (image->compression) */
 
+    MagickFreeMemory(pixels);
+    MagickFreeMemory(compress_pixels);
+
+    if (EOFBlob(image))
+      {
+        ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
+          image->filename);
+        status=MagickFail;
+      }
     /*
       Verify that pixel transfer loops completed
     */
     if (y != (long) image->rows)
-      status=False;
+      status=MagickFail;
 
-    MagickFreeMemory(pixels);
-    MagickFreeMemory(compress_pixels);
-    if (status == False)
+    if (status == MagickFail)
       {
         GetImageException(image,exception);
         CloseBlob(image);
         DestroyImageList(image);
         return((Image *) NULL);
       }
-    if (EOFBlob(image))
-      {
-        ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
-          image->filename);
-        break;
-      }
     /*
       Proceed to next image.
     */
@@ -1790,7 +1864,7 @@ static Image *ReadMIFFImage(const ImageInfo *image_info,
         status=MagickMonitorFormatted(TellBlob(image),GetBlobSize(image),
                                       exception,LoadImagesText,
                                       image->filename);
-        if (status == False)
+        if (status == MagickFail)
           break;
       }
   } while (c != EOF);
@@ -2150,13 +2224,13 @@ static unsigned int WriteMIFFImage(const ImageInfo *image_info,Image *image)
 
   ImageProfileIterator
     profile_iterator;
-  
+
   const char
     *profile_name;
-  
+
   const unsigned char
     *profile_info;
-  
+
   size_t
     profile_length;
 
@@ -2165,6 +2239,9 @@ static unsigned int WriteMIFFImage(const ImageInfo *image_info,Image *image)
     zip_info;
 #endif
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -2172,6 +2249,7 @@ static unsigned int WriteMIFFImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -2427,17 +2505,19 @@ static unsigned int WriteMIFFImage(const ImageInfo *image_info,Image *image)
     attribute=GetImageAttribute(image,(char *) NULL);
     for ( ; attribute != (ImageAttribute *) NULL; attribute=attribute->next)
     {
+      size_t attribute_length;
       if (*attribute->key == '[')
         continue;
       FormatString(buffer,"%.1024s=",attribute->key);
       (void) WriteBlobString(image,buffer);
-      for (i=0; i < (long) strlen(attribute->value); i++)
+      attribute_length=strlen(attribute->value);
+      for (i=0; i < (long) attribute_length; i++)
         if (isspace((int) attribute->value[i]))
           break;
-      if (i < (long) strlen(attribute->value))
+      if (i < (long) attribute_length)
         (void) WriteBlobByte(image,'{');
-      (void) WriteBlob(image,strlen(attribute->value),attribute->value);
-      if (i < (long) strlen(attribute->value))
+      (void) WriteBlob(image,attribute_length,attribute->value);
+      if (i < (long) attribute_length)
         (void) WriteBlobByte(image,'}');
       (void) WriteBlobByte(image,'\n');
     }
@@ -2589,8 +2669,8 @@ static unsigned int WriteMIFFImage(const ImageInfo *image_info,Image *image)
 #if defined(HasZLIB)
         case ZipCompression:
         {
-         int
-           code;
+          int
+            code;
 
           if (y == 0)
             {
@@ -2638,8 +2718,8 @@ static unsigned int WriteMIFFImage(const ImageInfo *image_info,Image *image)
 #if defined(HasBZLIB)
         case BZipCompression:
         {
-         int
-           code;
+          int
+            code;
 
           if (y == 0)
             {
@@ -2726,7 +2806,7 @@ static unsigned int WriteMIFFImage(const ImageInfo *image_info,Image *image)
         if (QuantumTick(y,image->rows))
           if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                       SaveImageText,image->filename,
-                                     image->columns,image->rows))
+                                      image->columns,image->rows))
             break;
     }
     MagickFreeMemory(pixels);
@@ -2734,7 +2814,7 @@ static unsigned int WriteMIFFImage(const ImageInfo *image_info,Image *image)
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene++,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename);
     if (status == False)
index 1f5028c..d659293 100644 (file)
@@ -164,7 +164,7 @@ static Image *ReadMONOImage(const ImageInfo *image_info,
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                   image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   (void) SyncImage(image);
@@ -333,7 +333,7 @@ static unsigned int WriteMONOImage(const ImageInfo *image_info,Image *image)
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                   SaveImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   CloseBlob(image);
index a846198..e80c398 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -128,6 +128,8 @@ static MagickBool IsMPC(const unsigned char *magick,const size_t length)
 
 #define ThrowMPCReaderException(code_,reason_,image_) \
 do { \
+  MagickFreeMemory(comment); \
+  MagickFreeMemory(values); \
   if (number_of_profiles > 0) \
     { \
       unsigned int _index; \
@@ -164,6 +166,8 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception)
     *p;
 
   unsigned int
+    comment_count,
+    keyword_count,
     status;
 
   unsigned long
@@ -175,6 +179,10 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception)
   unsigned int
     number_of_profiles=0;
 
+  char
+    *comment = NULL,
+    *values = NULL;
+
   /*
     Open image file.
   */
@@ -215,6 +223,8 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception)
     image->depth=8;
     image->compression=NoCompression;
     image->storage_class=DirectClass;
+    comment_count=0;
+    keyword_count=0;
     while (isgraph(c) && (c != ':'))
     {
       register char
@@ -222,13 +232,30 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
       if (c == '{')
         {
-          char
-            *comment;
-
           size_t
             comment_length;
 
           /*
+            Insist that format is identified prior to any comments.
+          */
+          if (id[0] == '\0')
+            {
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Comment precedes format identifier (id=MagickCache)");
+              ThrowMPCReaderException(CorruptImageError,ImproperImageHeader,image);
+            }
+
+          /*
+            Insist that only one comment is provided
+          */
+          if (comment_count > 0)
+            {
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Too many comments!");
+              ThrowMPCReaderException(CorruptImageError,ImproperImageHeader,image);
+            }
+
+          /*
             Read comment-- any text between { }.
           */
           comment_length=MaxTextExtent;
@@ -258,15 +285,13 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception)
               image);
           *p='\0';
           (void) SetImageAttribute(image,"comment",comment);
+          comment_count++;
           MagickFreeMemory(comment);
           c=ReadBlobByte(image);
         }
       else
         if (isalnum(c))
           {
-            char
-              *values;
-
             size_t
               values_length;
 
@@ -289,6 +314,17 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception)
               ThrowMPCReaderException(CorruptImageWarning,ImproperImageHeader,image);
 
             /*
+              Insist that the first keyword must be 'id' (id=MagickCache)
+            */
+            if ((keyword_count == 0) && (LocaleCompare(keyword,"id") != 0))
+              {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "First keyword must be 'id' (have '%s')",
+                                      keyword);
+                ThrowMPCReaderException(CorruptImageError,ImproperImageHeader,image);
+              }
+
+            /*
               Get values.
 
               Values not containing spaces are terminated by the first
@@ -327,8 +363,18 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception)
                     break;
               }
             *p='\0';
+            keyword_count++;
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                  "keyword=\"%s\" values=\"%s\"",keyword,values);
+                                  "keyword[%u]=\"%s\" values=\"%s\"",keyword_count,keyword,values);
+            /*
+              Insist that the first keyword value must be 'MagickCache' (id=MagickCache)
+            */
+            if ((keyword_count == 1) && (LocaleCompare(values,"MagickCache") != 0))
+              {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "First keyword/value must be 'id=MagickCache'");
+                ThrowMPCReaderException(CorruptImageError,ImproperImageHeader,image);
+              }
             /*
               Assign a value to the specified keyword.
             */
@@ -476,8 +522,8 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   }
                 if (LocaleCompare(keyword,"grayscale") == 0)
                   {
-                   if (LocaleCompare(values,"True") == 0)
-                     image->is_grayscale=MagickTrue;
+                    if (LocaleCompare(values,"True") == 0)
+                      image->is_grayscale=MagickTrue;
                     break;
                   }
                 if (LocaleCompare(keyword,"green-primary") == 0)
@@ -535,8 +581,8 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   }
                 if (LocaleCompare(keyword,"monochrome") == 0)
                   {
-                   if (LocaleCompare(values,"True") == 0)
-                     image->is_monochrome=MagickTrue;
+                    if (LocaleCompare(values,"True") == 0)
+                      image->is_monochrome=MagickTrue;
                     break;
                   }
                 if (LocaleCompare(keyword,"montage") == 0)
@@ -715,7 +761,7 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                           "id=\"%s\" class=%s compression=%s matte=%s "
-                         "columns=%lu rows=%lu depth=%u",
+                          "columns=%lu rows=%lu depth=%u",
                           id,ClassTypeToString(image->storage_class),
                           CompressionTypeToString(image->compression),
                           MagickBoolToString(image->matte),
@@ -759,6 +805,8 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception)
               p=image->directory+strlen(image->directory);
             }
           c=ReadBlobByte(image);
+          if (c == EOF)
+            break;
           *p++=c;
         } while (c != '\0');
       }
@@ -930,6 +978,7 @@ ModuleExport void RegisterMPCImage(void)
   entry->encoder=(EncoderHandler) WriteMPCImage;
   entry->magick=(MagickHandler) IsMPC;
   entry->description="Magick Persistent Cache image format";
+  entry->seekable_stream=MagickTrue;
   entry->module="MPC";
   entry->coder_class=UnstableCoderClass;
   (void) RegisterMagickInfo(entry);
@@ -1012,16 +1061,19 @@ static MagickPassFail WriteMPCImage(const ImageInfo *image_info,Image *image)
 
   ImageProfileIterator
     profile_iterator;
-  
+
   const char
     *profile_name;
-  
+
   const unsigned char
     *profile_info;
-  
+
   size_t
     profile_length;
 
+  size_t
+    image_list_length;
+
   /*
     Open persistent cache.
   */
@@ -1029,6 +1081,7 @@ static MagickPassFail WriteMPCImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == MagickFail)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -1229,7 +1282,7 @@ static MagickPassFail WriteMPCImage(const ImageInfo *image_info,Image *image)
       }
     /*
       Attached profiles.
-    */    
+    */
     profile_iterator=AllocateImageProfileIterator(image);
     if (profile_iterator)
       {
@@ -1352,7 +1405,7 @@ static MagickPassFail WriteMPCImage(const ImageInfo *image_info,Image *image)
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene++,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename);
     if (status == False)
index 470dad2..adb320d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -498,7 +498,7 @@ static unsigned int WriteMPEGImage(const ImageInfo *image_info,Image *image)
   if (status == False)
     {
       if (coalesce_image != image)
-        DestroyImage(coalesce_image);
+        DestroyImageList(coalesce_image);
       (void) LiberateTemporaryFile(basename);
       if (image_info->quality != DefaultCompressionQuality)
         {
@@ -604,7 +604,7 @@ static unsigned int WriteMPEGImage(const ImageInfo *image_info,Image *image)
   (void) remove(filename);
   (void) LiberateTemporaryFile(basename);
   if (coalesce_image != image)
-    DestroyImage(coalesce_image);
+    DestroyImageList(coalesce_image);
   if (logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),"exit");
   return(status);
index 2c35b7c..d0b3017 100644 (file)
@@ -671,7 +671,7 @@ MSLStartElement(void *context,const xmlChar *name,
             {
               Image
                 *newImage;
-          
+
               newImage=BlurImage(msl_info->image[n],radius,sigma,
                                  &msl_info->image[n]->exception);
               if (newImage == (Image *) NULL)
@@ -796,6 +796,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'C':
     case 'c':
@@ -1331,6 +1332,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'D':
     case 'd':
@@ -1362,6 +1364,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'E':
     case 'e':
@@ -1551,6 +1554,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'F':
     case 'f':
@@ -1669,6 +1673,7 @@ MSLStartElement(void *context,const xmlChar *name,
                             }
                           ThrowException(msl_info->exception,OptionError,
                                          UnrecognizedAttribute,keyword);
+                          break;
                         }
                       case 'G':
                       case 'g':
@@ -1796,6 +1801,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'G':
     case 'g':
@@ -1907,6 +1913,7 @@ MSLStartElement(void *context,const xmlChar *name,
                         }
                       ThrowException(msl_info->exception,OptionError,
                                      UnrecognizedAttribute,keyword);
+                      break;
                     }
                   case 'W':
                   case 'w':
@@ -1923,6 +1930,7 @@ MSLStartElement(void *context,const xmlChar *name,
                         }
                       ThrowException(msl_info->exception,OptionError,
                                      UnrecognizedAttribute,keyword);
+                      break;
                     }
                   default:
                     {
@@ -1943,6 +1951,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'I':
     case 'i':
@@ -2130,6 +2139,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'M':
     case 'm':
@@ -2258,6 +2268,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'N':
     case 'n':
@@ -2281,6 +2292,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'O':
     case 'o':
@@ -2350,6 +2362,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'P':
     case 'p':
@@ -2508,6 +2521,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'R':
     case 'r':
@@ -2931,6 +2945,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'S':
     case 's':
@@ -3873,6 +3888,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'T':
     case 't':
@@ -4117,6 +4133,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     case 'W':
     case 'w':
@@ -4156,6 +4173,7 @@ MSLStartElement(void *context,const xmlChar *name,
                         }
                       ThrowException(msl_info->exception,OptionError,
                                      UnrecognizedAttribute,keyword);
+                      break;
                     }
                   default:
                     {
@@ -4170,6 +4188,7 @@ MSLStartElement(void *context,const xmlChar *name,
           }
         ThrowException(msl_info->exception,OptionError,
                        UnrecognizedElement,(const char *) name);
+        break;
       }
     default:
       {
@@ -4214,7 +4233,7 @@ MSLEndElement(void *context,const xmlChar *name)
                         DestroyImage(msl_info->image[msl_info->n]);
                         msl_info->image[msl_info->n]=(Image *) NULL;
                       }
-                    
+
                     DestroyDrawInfo(msl_info->draw_info[msl_info->n]);
                     msl_info->draw_info[msl_info->n]=(DrawInfo *) NULL;
 
@@ -4344,6 +4363,9 @@ MSLComment(void *context,const xmlChar *value)
 }
 
 static void
+MSLWarning(void *context,const char *format,...) MAGICK_ATTRIBUTE((__format__ (__printf__,2,3)));
+
+static void
 MSLWarning(void *context,const char *format,...)
 {
   char
@@ -4373,6 +4395,9 @@ MSLWarning(void *context,const char *format,...)
 }
 
 static void
+MSLError(void *context,const char *format,...) MAGICK_ATTRIBUTE((__format__ (__printf__,2,3)));
+
+static void
 MSLError(void *context,const char *format,...)
 {
   char
@@ -4524,7 +4549,7 @@ ProcessMSLScript(const ImageInfo *image_info,Image **image,
   MSLInfo
     msl_info;
 
-  unsigned int
+  MagickPassFail
     status;
 
   xmlSAXHandlerPtr
@@ -4538,13 +4563,14 @@ ProcessMSLScript(const ImageInfo *image_info,Image **image,
   assert(image != (Image **) NULL);
   msl_image=AllocateImage(image_info);
   status=OpenBlob(image_info,msl_image,ReadBinaryBlobMode,exception);
-  if (status == False)
+  if (status == MagickFail)
     {
+      DestroyImage(msl_image);
       ThrowException(exception,FileOpenError,UnableToOpenFile,
                      msl_image->filename);
-      return(False);
+      return(MagickFail);
     }
-    
+
   /*
     Parse MSL file.
   */
@@ -4659,7 +4685,7 @@ ProcessMSLScript(const ImageInfo *image_info,Image **image,
 
   CloseBlob(*image);
 
-  return((*image != (Image *) NULL) && 
+  return((*image != (Image *) NULL) &&
          ((*image)->exception.severity == UndefinedException));
 }
 
index 117e640..b1d1a25 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -38,6 +38,7 @@
 #include "magick/studio.h"
 #include "magick/blob.h"
 #include "magick/pixel_cache.h"
+#include "magick/log.h"
 #include "magick/magick.h"
 #include "magick/monitor.h"
 #include "magick/utility.h"
@@ -124,6 +125,7 @@ static Image *ReadMTVImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Read MTV image.
   */
+  buffer[0]='\0';
   (void) ReadBlobString(image,buffer);
   columns=0;
   rows=0;
@@ -134,13 +136,17 @@ static Image *ReadMTVImage(const ImageInfo *image_info,ExceptionInfo *exception)
   {
     size_t
       row_size;
-    
+
     /*
       Initialize image structure.
     */
     image->columns=columns;
     image->rows=rows;
     image->depth=8;
+    if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Image[%lu] Geometry %lux%lu", image->scene,
+                          image->columns, image->rows);
     if (image_info->ping && (image_info->subrange != 0))
       if (image->scene >= (image_info->subimage+image_info->subrange-1))
         break;
@@ -158,9 +164,9 @@ static Image *ReadMTVImage(const ImageInfo *image_info,ExceptionInfo *exception)
     for (y=0; y < (long) image->rows; y++)
     {
       if (ReadBlob(image,row_size,pixels) != row_size)
-        ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+        break;
       p=pixels;
-      q=SetImagePixels(image,0,y,image->columns,1);
+      q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
       if (q == (PixelPacket *) NULL)
         break;
       for (x=0; x < (long) image->columns; x++)
@@ -170,13 +176,13 @@ static Image *ReadMTVImage(const ImageInfo *image_info,ExceptionInfo *exception)
         q->blue=ScaleCharToQuantum(*p++);
         q++;
       }
-      if (!SyncImagePixels(image))
+      if (!SyncImagePixelsEx(image,exception))
         break;
       if (image->previous == (Image *) NULL)
         if (QuantumTick(y,image->rows))
           if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                       image->filename,
-                                     image->columns,image->rows))
+                                      image->columns,image->rows))
             break;
     }
     MagickFreeMemory(pixels);
@@ -193,7 +199,9 @@ static Image *ReadMTVImage(const ImageInfo *image_info,ExceptionInfo *exception)
       if (image->scene >= (image_info->subimage+image_info->subrange-1))
         break;
     *buffer='\0';
-    (void) ReadBlobString(image,buffer);
+    count=0;
+    if (ReadBlobString(image,buffer) == NULL)
+      break;
     count=sscanf(buffer,"%lu %lu\n",&columns,&rows);
     if (count == 2)
       {
@@ -336,6 +344,9 @@ static unsigned int WriteMTVImage(const ImageInfo *image_info,Image *image)
   unsigned long
     scene;
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -343,6 +354,7 @@ static unsigned int WriteMTVImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -380,14 +392,14 @@ static unsigned int WriteMTVImage(const ImageInfo *image_info,Image *image)
         if (QuantumTick(y,image->rows))
           if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                       SaveImageText,image->filename,
-                                     image->columns,image->rows))
+                                      image->columns,image->rows))
             break;
     }
     MagickFreeMemory(pixels);
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene++,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename);
     if (status == False)
index 15c31fc..692e66a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -36,6 +36,7 @@
 #include "magick/studio.h"
 #include "magick/attribute.h"
 #include "magick/blob.h"
+#include "magick/log.h"
 #include "magick/magick.h"
 #include "magick/render.h"
 #include "magick/pixel_cache.h"
@@ -96,10 +97,9 @@ static unsigned int IsMVG(const unsigned char *magick,const size_t length)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  Method ReadMVGImage creates a gradient image and initializes it to
-%  the X server color range as specified by the filename.  It allocates the
-%  memory necessary for the new Image structure and returns a pointer to the
-%  new image.
+%  Method ReadMVGImage renders a MVG vector-graphics file into a raster
+%  image. It allocates the memory necessary for the new Image structure
+%  and returns a pointer to the new image.
 %
 %  The format of the ReadMVGImage method is:
 %
@@ -130,7 +130,10 @@ static Image *ReadMVGImage(const ImageInfo *image_info,ExceptionInfo *exception)
   size_t
     length;
 
-  unsigned int
+  magick_off_t
+    blob_size;
+
+  MagickPassFail
     status;
 
   /*
@@ -141,8 +144,13 @@ static Image *ReadMVGImage(const ImageInfo *image_info,ExceptionInfo *exception)
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
   image=AllocateImage(image_info);
+  /*
+    FIXME: This implementation should be entirely re-written so that
+    it does not require seekable_stream=True and is thus able to read
+    directly from a pipe or compressed stream.
+  */
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
-  if (status == False)
+  if (status == MagickFail)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
   if ((image->columns == 0) || (image->rows == 0))
     {
@@ -158,15 +166,22 @@ static Image *ReadMVGImage(const ImageInfo *image_info,ExceptionInfo *exception)
       /*
         Determine size of image canvas.
       */
+      (void) memset(&bounds,0,sizeof(bounds));
       while (ReadBlobString(image,primitive) != (char *) NULL)
       {
         for (p=primitive; (*p == ' ') || (*p == '\t'); p++);
         if (LocaleNCompare(BoundingBox,p,strlen(BoundingBox)) != 0)
           continue;
-        (void) sscanf(p,"viewbox %lf %lf %lf %lf",&bounds.x1,&bounds.y1,
-          &bounds.x2,&bounds.y2);
-        image->columns=(unsigned long) (bounds.x2-bounds.x1+0.5);
-        image->rows=(unsigned long) (bounds.y2-bounds.y1+0.5);
+        if (sscanf(p,"viewbox %lf %lf %lf %lf",&bounds.x1,&bounds.y1,
+                   &bounds.x2,&bounds.y2) == 4)
+          {
+            image->columns=(unsigned long) (bounds.x2-bounds.x1+0.5);
+            image->rows=(unsigned long) (bounds.y2-bounds.y1+0.5);
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "ViewBox: %g %g %g %g, Geometry: %lux%lu",
+                                  bounds.x1, bounds.y1, bounds.x2, bounds.y2,
+                                  image->columns,image->rows);
+          }
         break;
       }
     }
@@ -182,16 +197,43 @@ static Image *ReadMVGImage(const ImageInfo *image_info,ExceptionInfo *exception)
   (void) SetImage(image,OpaqueOpacity);
   draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
   draw_info->fill=image_info->pen;
+  draw_info->primitive=NULL;
   if (GetBlobStreamData(image))
-    draw_info->primitive=AllocateString((char *) GetBlobStreamData(image));
+    {
+      if ((blob_size = GetBlobSize(image)) > 0)
+        {
+          length=(size_t) blob_size;
+          draw_info->primitive=MagickAllocateMemory(char *,length+1);
+          if (draw_info->primitive != (char *) NULL)
+            {
+              (void) memcpy(draw_info->primitive,GetBlobStreamData(image),length);
+              draw_info->primitive[length]=0;
+            }
+          else
+            {
+              DestroyDrawInfo(draw_info);
+              ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+            }
+        }
+    }
   else
-    draw_info->primitive=(char *) FileToBlob(image->filename,&length,exception);
+    {
+      draw_info->primitive=(char *) FileToBlob(image->filename,&length,exception);
+    }
   if (draw_info->primitive == (char *) NULL)
     {
       DestroyDrawInfo(draw_info);
       CloseBlob(image);
       return (Image *) NULL;
     }
+  /*
+    Don't allow MVG files to side-load a file as the primitive
+  */
+  if (draw_info->primitive[0] == '@')
+    {
+      DestroyDrawInfo(draw_info);
+      ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+    }
   (void) DrawImage(image,draw_info);
   DestroyDrawInfo(draw_info);
   CloseBlob(image);
@@ -273,7 +315,9 @@ ModuleExport void UnregisterMVGImage(void)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  Method WriteMVGImage writes an image to a file in MVG image format.
+%  Method WriteMVGImage writes MVG vector drawing data associated with an
+%  image structure using the attribute key "[MVG]" to a file in MVG
+%  vector-graphics format.
 %
 %  The format of the WriteMVGImage method is:
 %
index ccf0d08..3aa5eab 100644 (file)
@@ -48,7 +48,7 @@
   Forward declarations.
 */
 static unsigned int
-  WriteNULLImage(const ImageInfo *,Image *);
+  WriteNULLImage(const ImageInfo *,Image *) MAGICK_FUNC_PURE;
 \f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 18835fd..1988398 100644 (file)
@@ -178,7 +178,7 @@ static Image *ReadOTBImage(const ImageInfo *image_info,ExceptionInfo *exception)
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                   image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   (void) SyncImage(image);
@@ -365,7 +365,7 @@ static unsigned int WriteOTBImage(const ImageInfo *image_info,Image *image)
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                   SaveImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   CloseBlob(image);
index 62d62ef..eab6078 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
 % Add -rle or -scanline to add compression.  Add -transparent color to make color transparent.
 %
 */
+/*
+  Disable PALM writer by default since it is a work in progress.
+*/
+#if !defined(ENABLE_PALM_WRITER)
+#  define ENABLE_PALM_WRITER 0
+#endif /* if !defined(ENABLE_PALM_WRITER) */
 \f
 /*
   Include declarations.
@@ -388,6 +394,7 @@ PalmPalette8[256][3] =
     { 255, 204, 255 },
     { 255, 255, 255 }
   };
+#if ENABLE_PALM_WRITER
 /*
  The 256 color system palette for Palm Computing Devices.
 */
@@ -651,6 +658,7 @@ static const unsigned char
     {  0,   0,  0},
     {  0,   0,  0}
   };
+#endif /* ENABLE_PALM_WRITER */
 
 typedef struct _PalmHeader
 {
@@ -671,7 +679,7 @@ typedef struct _PalmHeader
   /* Version:
      0: Palm OS 1
      1: Palm OS 3, no transparency, no RLE compression.
-     2: Palm OS 3.5; transparency and RLE compression supported 
+     2: Palm OS 3.5; transparency and RLE compression supported
   */
   magick_uint8_t  version;
   /* Offset (in four byte words) to start of next image frame. */
@@ -710,10 +718,12 @@ typedef struct _PalmHeader
 /*
   Forward declarations.
 */
+#if ENABLE_PALM_WRITER
 static unsigned int
   WritePALMImage(const ImageInfo *,Image *);
+#endif /* #if ENABLE_PALM_WRITER */
 \f
-void LogPALMHeader(const PalmHeader* palm_header)
+static void LogPALMHeader(const PalmHeader* palm_header)
 {
   static const struct
   {
@@ -777,29 +787,29 @@ void LogPALMHeader(const PalmHeader* palm_header)
 \f
 static const unsigned char *
 GetPalmPaletteGivenBits(const unsigned int bits,
-                        size_t *size)
+                       size_t *entries)
 {
   const unsigned char
     *palette = (const unsigned char *) NULL;
 
-  *size=0;
+  *entries=0;
   switch (bits)
     {
     case 1:
       palette=(const unsigned char *) PalmPalette1;
-      *size=sizeof(PalmPalette1);
+      *entries=sizeof(PalmPalette1)/3U;
       break;
     case 2:
       palette=(const unsigned char *) PalmPalette2;
-      *size=sizeof(PalmPalette2);
+      *entries=sizeof(PalmPalette2)/3U;
       break;
     case 4:
       palette=(const unsigned char *) PalmPalette4;
-      *size=sizeof(PalmPalette4);
+      *entries=sizeof(PalmPalette4)/3U;
       break;
     case 8:
       palette=(const unsigned char *) PalmPalette8;
-      *size=sizeof(PalmPalette8);
+      *entries=sizeof(PalmPalette8)/3U;
       break;
     }
   return palette;
@@ -849,7 +859,7 @@ static Image *ReadPALMImage(const ImageInfo *image_info,
   Image
     *image;
 
-  IndexPacket
+  unsigned int
     index;
 
   long
@@ -872,6 +882,9 @@ static Image *ReadPALMImage(const ImageInfo *image_info,
     *one_row,
     *ptr;
 
+  size_t
+    alloc_size;
+
   unsigned int
     status;
 
@@ -983,141 +996,85 @@ static Image *ReadPALMImage(const ImageInfo *image_info,
   /*
     Initialize image colormap.
   */
-  if ((palm_header.bits_per_pixel < 16) &&
-      !AllocateImageColormap(image,1L << palm_header.bits_per_pixel))
-    ThrowPALMReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-
   if ((palm_header.bits_per_pixel == 1) ||
       (palm_header.bits_per_pixel == 2) ||
       (palm_header.bits_per_pixel == 4) ||
-      ((palm_header.bits_per_pixel == 8) &&
-       !(palm_header.flags & PALM_HAS_COLORMAP_FLAG)))
+      (palm_header.bits_per_pixel == 8))
     {
+      size_t
+        palette_entries=0;
+
       const unsigned char
-        *palette;
+        *fixed_palette = NULL;
 
-      size_t
-        size;
+      if (!AllocateImageColormap(image,1UL << palm_header.bits_per_pixel))
+        ThrowPALMReaderException(ResourceLimitError,MemoryAllocationFailed,image);
 
-      palette=GetPalmPaletteGivenBits(palm_header.bits_per_pixel,
-                                      &size);
-      if (palette)
+      if ((palm_header.bits_per_pixel == 8) &&
+          (palm_header.flags & PALM_HAS_COLORMAP_FLAG))
         {
-          if (image->logging)
-            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                  "Default %u bit palette of %"
-                                  MAGICK_SIZE_T_F "u bytes...",
-                                  palm_header.bits_per_pixel,
-                                  (MAGICK_SIZE_T) size);
-          for (index=0; index < image->colors; index++)
+          palette_entries = ReadBlobMSBShort(image);
+
+          if (EOFBlob(image))
+            ThrowPALMReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+          if (palette_entries > image->colors)
+            ThrowPALMReaderException(CorruptImageError,ColormapExceedsColorsLimit,image);
+        }
+
+      if (palette_entries == 0)
+        fixed_palette=GetPalmPaletteGivenBits(palm_header.bits_per_pixel, &palette_entries);
+      if (palette_entries == 0)
+        palette_entries=image->colors;
+
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "%s %u bit palette with %" MAGICK_SIZE_T_F "u colors",
+                              fixed_palette ? "Default" : "Custom",
+                              palm_header.bits_per_pixel,
+                              (MAGICK_SIZE_T) palette_entries);
+
+      if (fixed_palette)
+        {
+          const unsigned char
+            *palette = fixed_palette;
+          for (index=0; index < palette_entries; index++)
             {
               image->colormap[index].red=ScaleCharToQuantum(*palette++);
               image->colormap[index].green=ScaleCharToQuantum(*palette++);
               image->colormap[index].blue=ScaleCharToQuantum(*palette++);
             }
         }
-    }
-
-  else if (palm_header.bits_per_pixel == 8)
-    {
-      i = 0;
-      if (palm_header.flags & PALM_HAS_COLORMAP_FLAG)
+      else if (palm_header.flags & PALM_HAS_COLORMAP_FLAG)
         {
-          unsigned int
-            count;
-
-          count = ReadBlobMSBShort(image);
-
-          if (image->logging)
-            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                  "Custom %u bit palette with %u colors (%"
-                                  MAGICK_SIZE_T_F "u bytes)...",
-                                  palm_header.bits_per_pixel,
-                                  count,
-                                  (MAGICK_SIZE_T) count*3);
-
-          if (count > image->colors)
-            ThrowPALMReaderException(CorruptImageError,ColormapExceedsColorsLimit,image);
-
           /*
             Is palette really written reversed?
           */
-          for (i = 0; i < count; i++)
+          for (i = 0; i < palette_entries; i++)
             {
               /* unsigned int r, g, b; */
               (void) ReadBlobByte(image);
-              index=255 - i;
+              index=(image->colors-1) - i;
               VerifyColormapIndex(image,index);
-#if 0
-              r=ReadBlobByte(image);
-              g=ReadBlobByte(image);
-              b=ReadBlobByte(image);
-              fprintf(stdout,"{ %3u, %3u, %3u },\n", r, g, b);
-#endif
-#if 1
               image->colormap[index].red = ScaleCharToQuantum(ReadBlobByte(image));
               image->colormap[index].green = ScaleCharToQuantum(ReadBlobByte(image));
               image->colormap[index].blue = ScaleCharToQuantum(ReadBlobByte(image));
-#endif
               if (EOFBlob(image))
                 ThrowPALMReaderException(CorruptImageError,UnexpectedEndOfFile,image);
             }
           /*
             Initialize remaining range ???.
           */
-          for (; i < (1U << palm_header.bits_per_pixel); i++)
+          for (; i < image->colors; i++)
             {
-              index=255 - i;
+              index=(image->colors-1) - i;
               image->colormap[index].red = 0;
               image->colormap[index].green = 0;
               image->colormap[index].blue = 0;
             }
         }
-#if 0
-      for (; i < (1U << palm_header.bits_per_pixel); i++)
-        {
-          index=255 - i;
-          VerifyColormapIndex(image,index);
-          image->colormap[index].red = ScaleCharToQuantum(PalmPalette[i][0]);
-          image->colormap[index].green = ScaleCharToQuantum(PalmPalette[i][1]);
-          image->colormap[index].blue = ScaleCharToQuantum(PalmPalette[i][2]);
-        }
-#endif
-#if 0
-      for (i=0; i < (1U << palm_header.bits_per_pixel); i++)
-        {
-          fprintf(stdout,"{ %3u, %3u, %3u },\n",
-                  ScaleQuantumToChar(image->colormap[i].red),
-                  ScaleQuantumToChar(image->colormap[i].green),
-                  ScaleQuantumToChar(image->colormap[i].blue));
-        }
-#endif
     }
 
-image->depth = 8;
-#if 0
-  if (palm_header.bits_per_pixel < 16)
-    {
-      image->storage_class = PseudoClass;
-      image->depth = 8;
-    }
-  else
-    {
-      image->storage_class = DirectClass;
-      image->depth = 8;
-    }
-#endif
-
-#if 0
-  if (image->storage_class == PseudoClass)
-    for (i=0; i < image->colors; i++)
-      fprintf(stderr,"%03u: %3u, %3u, %3u\n",
-              i,
-              ScaleQuantumToChar(image->colormap[i].red),
-              ScaleQuantumToChar(image->colormap[i].green),
-              ScaleQuantumToChar(image->colormap[i].blue));
-#endif
-
+  image->depth = 8;
   image->compression = NoCompression;
   if (palm_header.flags & PALM_IS_COMPRESSED_FLAG)
     {
@@ -1139,11 +1096,19 @@ image->depth = 8;
   if (CheckImagePixelLimits(image, exception) != MagickPass)
     ThrowPALMReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
 
-  one_row = MagickAllocateMemory(unsigned char *,Max(palm_header.bytes_per_row,2*image->columns));
+  alloc_size = Max(palm_header.bytes_per_row,MagickArraySize(2,image->columns));
+  one_row = MagickAllocateMemory(unsigned char *,alloc_size);
   if (one_row == (unsigned char *) NULL)
     ThrowPALMReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+  (void) memset(one_row,0,alloc_size);
   if (palm_header.compression_type == PALM_COMPRESSION_SCANLINE)
-    lastrow = MagickAllocateMemory(unsigned char *,Max(palm_header.bytes_per_row,2*image->columns));
+    {
+      alloc_size = Max(palm_header.bytes_per_row,MagickArraySize(2,image->columns));
+      lastrow = MagickAllocateMemory(unsigned char *,alloc_size);
+      if (lastrow == (unsigned char *) NULL)
+        ThrowPALMReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+      (void) memset(lastrow,0,alloc_size);
+    }
 
   mask = (1l << palm_header.bits_per_pixel) - 1;
 
@@ -1213,7 +1178,7 @@ image->depth = 8;
       indexes=AccessMutableIndexes(image);
       if (palm_header.bits_per_pixel == 16)
         {
-          if (image->columns > 2*palm_header.bytes_per_row)
+          if (image->columns > 2U*palm_header.bytes_per_row)
             ThrowPALMReaderException(CorruptImageError,CorruptImage,image);
           for (x=0; x < (long) image->columns; x++)
             {
@@ -1323,7 +1288,9 @@ ModuleExport void RegisterPALMImage(void)
 
   entry=SetMagickInfo("PALM");
   entry->decoder=ReadPALMImage;
+#if ENABLE_PALM_WRITER
   entry->encoder=WritePALMImage;
+#endif /* #if ENABLE_PALM_WRITER */
   entry->adjoin=False;
   entry->seekable_stream=True;
   entry->description="Palm pixmap";
@@ -1385,7 +1352,7 @@ ModuleExport void UnregisterPALMImage(void)
 %
 %
 */
-#if 1
+#if ENABLE_PALM_WRITER
 static Image *
 CreatePALMMapImage(const unsigned int depth)
 {
@@ -1480,7 +1447,9 @@ OptimizePALMImage(const ImageInfo *image_info,
     {
       for (depth = 1; depth <= 8; depth *= 2)
         {
-          fprintf(stderr,"Depth %u\n",depth);
+          if (image->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Trying depth %u",depth);
           /*
             Get PALM map image for depth.
           */
@@ -1497,13 +1466,13 @@ OptimizePALMImage(const ImageInfo *image_info,
           /*
             Make sure that image is in an RGB type space.
           */
-          if (!TransformColorspace(palm_image,RGBColorspace))
+          if (TransformColorspace(palm_image,RGBColorspace) == MagickFail)
             break;
 
           /*
             Map optimize image to colormap without dithering.
           */
-          if (!MapImage(palm_image, map_image, False))
+          if (MapImage(palm_image, map_image, False) == MagickFail)
             break;
 
           /*
@@ -1543,8 +1512,8 @@ OptimizePALMImage(const ImageInfo *image_info,
           /*
             Replace colormap in optimize image with map image palette.
           */
-          if (!ReplaceImageColormap(palm_image,map_image->colormap,
-                                    map_image->colors))
+          if (ReplaceImageColormap(palm_image,map_image->colormap,
+                                    map_image->colors) == MagickFail)
             break;
 
           DestroyImage(map_image);
@@ -1589,7 +1558,7 @@ OptimizePALMImage(const ImageInfo *image_info,
               /*
                 Make sure that image is in an RGB type space.
               */
-              if (!TransformColorspace(palm_image,RGBColorspace))
+              if (TransformColorspace(palm_image,RGBColorspace) == MagickFail)
                 break;
 
               GetQuantizeInfo(&quantize_info);
@@ -1617,7 +1586,7 @@ OptimizePALMImage(const ImageInfo *image_info,
 
                   DestroyImage(palm_image);
                   palm_image = (Image *) NULL;
+
                   break;
                 }
 
@@ -1672,7 +1641,7 @@ OptimizePALMImage(const ImageInfo *image_info,
 
   return palm_image;
 }
-#endif
+
 static unsigned int WritePALMImage(const ImageInfo *image_info,Image *image)
 {
   int
@@ -1840,10 +1809,17 @@ static unsigned int WritePALMImage(const ImageInfo *image_info,Image *image)
     }
 
   if (palm_image->compression == FaxCompression)
-    lastrow = MagickAllocateMemory(unsigned char *,bytes_per_row);
+    {
+      lastrow = MagickAllocateMemory(unsigned char *,bytes_per_row);
+      if (lastrow == (unsigned char *) NULL)
+        ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+    }
   one_row = MagickAllocateMemory(unsigned char *,bytes_per_row);
   if (one_row == (unsigned char *) NULL)
-    ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+    {
+      MagickFreeMemory(lastrow);
+      ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+    }
 
   ClearPixelPacket(&transpix);
   for (y=0; y < (int) palm_image->rows; y++)
@@ -1882,7 +1858,7 @@ static unsigned int WritePALMImage(const ImageInfo *image_info,Image *image)
             {
               if (bits_per_pixel < 8) /* Make sure we use the entire colorspace for bits_per_pixel */
                 color = (unsigned char) (indexes[x] * ((1 << bits_per_pixel) - 1) /
-                                         (palm_image->colors - 1));
+                                         (palm_image->colors - 1)); /* FIXME: /0 */
               else
                 color = (unsigned char) indexes[x];
               byte |= color << bit;
@@ -1908,7 +1884,7 @@ static unsigned int WritePALMImage(const ImageInfo *image_info,Image *image)
             {
               byte = one_row[x];
               count = 1;
-              while (one_row[++x] == byte && count < 255 && x < (long) bytes_per_row)
+              while (one_row[++x] == byte && count < 255 && x < (long) bytes_per_row) /* FIXME: overrun */
                 count++;
               (void) WriteBlobByte(image, count);
               (void) WriteBlobByte(image, byte);
@@ -1979,3 +1955,4 @@ static unsigned int WritePALMImage(const ImageInfo *image_info,Image *image)
   MagickFreeMemory(lastrow);
   return(True);
 }
+#endif /* if ENABLE_PALM_WRITER */
index 70c0600..d9610b5 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -41,6 +41,7 @@
 #include "magick/pixel_cache.h"
 #include "magick/decorate.h"
 #include "magick/gem.h"
+#include "magick/log.h"
 #include "magick/magick.h"
 #include "magick/monitor.h"
 #include "magick/montage.h"
@@ -185,7 +186,8 @@ static void Upsample(const unsigned long width,const unsigned long height,
   { \
     if (p >= (buffer+0x800)) \
       { \
-        (void) ReadBlob(image,0x800,(char *) buffer); \
+        if (ReadBlob(image,0x800,(char *) buffer) != 0x800) \
+          break;                                            \
         p=buffer; \
       } \
     sum|=((unsigned int) (*p) << (24-bits)); \
@@ -195,7 +197,7 @@ static void Upsample(const unsigned long width,const unsigned long height,
   if (EOFBlob(image)) \
     break; \
 }
-static unsigned int DecodeImage(Image *image,unsigned char *luma,
+static MagickPassFail DecodeImage(Image *image,unsigned char *luma,
   unsigned char *chroma1,unsigned char *chroma2)
 {
   typedef struct PCDTable
@@ -242,13 +244,23 @@ static unsigned int DecodeImage(Image *image,unsigned char *luma,
     row,
     sum;
 
+  unsigned int
+    status = MagickPass;
+
   /*
     Initialize Huffman tables.
   */
   assert(image != (const Image *) NULL);
+  assert(image->signature == MagickSignature);
   assert(luma != (unsigned char *) NULL);
   assert(chroma1 != (unsigned char *) NULL);
   assert(chroma2 != (unsigned char *) NULL);
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Huffman decode image %lux%lu (%u tables)",
+                          image->columns, image->rows,
+                          (image->columns > 1536 ? 3U : 1U));
+  pcd_table[2]=pcd_table[1]=pcd_table[0]=(PCDTable *) NULL;
   buffer=MagickAllocateMemory(unsigned char *,0x800);
   if (buffer == (unsigned char *) NULL)
     ThrowBinaryException(ResourceLimitError,MemoryAllocationFailed,
@@ -260,12 +272,13 @@ static unsigned int DecodeImage(Image *image,unsigned char *luma,
   {
     PCDGetBits(8);
     length=(sum & 0xff)+1;
-    pcd_table[i]=MagickAllocateMemory(PCDTable *,length*sizeof(PCDTable));
+    pcd_table[i]=MagickAllocateArray(PCDTable *,length,sizeof(PCDTable));
     if (pcd_table[i] == (PCDTable *) NULL)
       {
-        MagickFreeMemory(buffer);
-        ThrowBinaryException(ResourceLimitError,MemoryAllocationFailed,
-          (char *) NULL)
+        ThrowException(&image->exception,ResourceLimitError,
+                       MemoryAllocationFailed,image->filename);
+        status=MagickFail;
+        goto decode_image_error;
       }
     r=pcd_table[i];
     for (j=0; j < (long) length; j++)
@@ -274,8 +287,14 @@ static unsigned int DecodeImage(Image *image,unsigned char *luma,
       r->length=(sum & 0xff)+1;
       if (r->length > 16)
         {
-          MagickFreeMemory(buffer);
-          return(False);
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Excessive length %" MAGICK_SIZE_T_F "u!",
+                                  (MAGICK_SIZE_T) length);
+          ThrowException(&image->exception,CorruptImageError,
+                         UnableToUncompressImage,image->filename);
+          status=MagickFail;
+          goto decode_image_error;
         }
       PCDGetBits(16);
       r->sequence=(sum & 0xffff) << 16;
@@ -343,15 +362,23 @@ static unsigned int DecodeImage(Image *image,unsigned char *luma,
           }
           default:
           {
-            ThrowBinaryException(CorruptImageError,CorruptImage,
-              image->filename)
+            if (image->logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Unhandled plane %u!", plane);
+            ThrowException(&image->exception,CorruptImageError,
+                         UnableToUncompressImage,image->filename);
+            status=MagickFail;
+            goto decode_image_error;
           }
         }
         length=pcd_length[plane];
         if (QuantumTick(row,image->rows))
           if (!MagickMonitorFormatted(row,image->rows,&image->exception,
                                       DecodeImageText,image->filename))
-            break;
+            {
+              status=MagickFail;
+              goto decode_image_error;
+            }
         continue;
       }
     /*
@@ -363,7 +390,7 @@ static unsigned int DecodeImage(Image *image,unsigned char *luma,
     if ((row > image->rows) || (r == (PCDTable *) NULL))
       {
         ThrowException(&image->exception,CorruptImageWarning,SkipToSyncByte,
-          image->filename);
+                       image->filename);
         while ((sum & 0x00fff000) != 0x00fff000)
           PCDGetBits(8);
         while (!IsSync)
@@ -381,13 +408,14 @@ static unsigned int DecodeImage(Image *image,unsigned char *luma,
     PCDGetBits(r->length);
     count--;
   }
+ decode_image_error:
   /*
     Free memory.
   */
   for (i=0; i < (image->columns > 1536 ? 3 : 1); i++)
     MagickFreeMemory(pcd_table[i]);
   MagickFreeMemory(buffer);
-  return(True);
+  return(status);
 }
 \f
 /*
@@ -461,7 +489,7 @@ static unsigned int IsPCD(const unsigned char *magick,const size_t length)
 %
 */
 
-static Image *OverviewImage(const ImageInfo *image_info,Image *image,
+static Image *OverviewImage(const ImageInfo *image_info,Image *images,
   ExceptionInfo *exception)
 {
   Image
@@ -477,7 +505,7 @@ static Image *OverviewImage(const ImageInfo *image_info,Image *image,
     Image
       *label_image;
 
-    for( label_image=GetFirstImageInList(image); label_image != 0;
+    for( label_image=GetFirstImageInList(images); label_image != 0;
          label_image=GetNextImageInList(label_image) )
       (void) SetImageAttribute(label_image, "label", DefaultTileLabel);
   }
@@ -487,14 +515,20 @@ static Image *OverviewImage(const ImageInfo *image_info,Image *image,
   */
   montage_info=CloneMontageInfo(image_info,(MontageInfo *) NULL);
   (void) strlcpy(montage_info->filename,image_info->filename,MaxTextExtent);
-  montage_image=MontageImages(image,montage_info,exception);
+  montage_image=MontageImages(images,montage_info,exception);
   DestroyMontageInfo(montage_info);
-  if (montage_image == (Image *) NULL)
-    ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-  DestroyImage(image);
+  DestroyImageList(images);
   return(montage_image);
 }
 
+#define ThrowPCDReaderException(code_,reason_,image_) \
+  {                                                   \
+    MagickFreeMemory(chroma1);                        \
+    MagickFreeMemory(chroma2);                        \
+    MagickFreeMemory(luma);                           \
+    ThrowReaderException(code_,reason_,image_);       \
+  }
+
 static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
   Image
@@ -521,13 +555,14 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
     *yy;
 
   size_t
+    number_pixels,
     count;
 
   unsigned char
-    *chroma1,
-    *chroma2,
-    *header,
-    *luma;
+    *chroma1 = NULL,
+    *chroma2 = NULL,
+    header[3*0x800],
+    *luma = NULL;
 
   unsigned int
     overview,
@@ -537,7 +572,6 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
   unsigned long
     height,
     number_images,
-    number_pixels,
     subimage,
     width;
 
@@ -555,23 +589,21 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Determine if this is a PCD file.
   */
-  header=MagickAllocateMemory(unsigned char *,3*0x800);
-  if (header == (unsigned char *) NULL)
-    ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-  count=ReadBlob(image,3*0x800,(char *) header);
+  if ((count=ReadBlob(image,3*0x800,(char *) header)) != 3*0x800)
+    ThrowPCDReaderException(CorruptImageError,UnexpectedEndOfFile,image);
   overview=LocaleNCompare((char *) header,"PCD_OPA",7) == 0;
-  if ((count == 0) ||
-      ((LocaleNCompare((char *) header+0x800,"PCD",3) != 0) && !overview))
-    ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+  if ((LocaleNCompare((char *) header+0x800,"PCD",3) != 0) && !overview)
+    ThrowPCDReaderException(CorruptImageError,ImproperImageHeader,image);
   rotate=header[0x0e02] & 0x03;
   number_images=((header[10] << 8) | header[11]) & 0xFFFF;
-  MagickFreeMemory(header);
   /*
     Determine resolution by subimage specification.
   */
   number_pixels=image->columns*image->rows;
   if (number_pixels == 0)
-    subimage=3;
+    {
+      subimage=3;
+    }
   else
     {
       width=192;
@@ -606,6 +638,11 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
     image->columns<<=1;
     image->rows<<=1;
   }
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Decode PCD %simage geometry %lux%lu",
+                          (overview ? "(with overview) " : ""),
+                          image->columns,image->rows);
 
   if (CheckImagePixelLimits(image, exception) != MagickPass)
     ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
@@ -613,13 +650,16 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Allocate luma and chroma memory.
   */
-  number_pixels=image->columns*image->rows;
+  number_pixels=MagickArraySize(image->columns,image->rows);
+  if (number_pixels == 0 || number_pixels+1 < number_pixels)
+    ThrowPCDReaderException(ResourceLimitError,MemoryAllocationFailed,image);
   chroma1=MagickAllocateMemory(unsigned char *,number_pixels+1);
   chroma2=MagickAllocateMemory(unsigned char *,number_pixels+1);
   luma=MagickAllocateMemory(unsigned char *,number_pixels+1);
   if ((chroma1 == (unsigned char *) NULL) ||
-      (chroma2 == (unsigned char *) NULL) || (luma == (unsigned char *) NULL))
-    ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+      (chroma2 == (unsigned char *) NULL) ||
+      (luma == (unsigned char *) NULL))
+    ThrowPCDReaderException(ResourceLimitError,MemoryAllocationFailed,image);
   /*
     Advance to image data.
   */
@@ -633,12 +673,10 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
       if (subimage <= 1)
         offset=1;
   for (i=0; i < (long) (offset*0x800); i++)
-    (void) ReadBlobByte(image);
+    if (ReadBlobByte(image) == EOF)
+      ThrowPCDReaderException(CorruptImageError,UnexpectedEndOfFile,image);
   if (overview)
     {
-      Image
-        *overview_image;
-
       MonitorHandler
         handler;
 
@@ -662,15 +700,21 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
         c2=chroma2;
         for (y=0; y < (long) height; y+=2)
         {
-          (void) ReadBlob(image,width,(char *) yy);
+          if (ReadBlob(image,width,(char *) yy) != width)
+            break;
           yy+=image->columns;
-          (void) ReadBlob(image,width,(char *) yy);
+          if (ReadBlob(image,width,(char *) yy) != width)
+            break;
           yy+=image->columns;
-          (void) ReadBlob(image,width >> 1,(char *) c1);
+          if (ReadBlob(image,width >> 1,(char *) c1) != (width >> 1))
+            break;
           c1+=image->columns;
-          (void) ReadBlob(image,width >> 1,(char *) c2);
+          if (ReadBlob(image,width >> 1,(char *) c2) != (width >> 1))
+            break;
           c2+=image->columns;
         }
+        if (EOFBlob(image))
+          ThrowPCDReaderException(CorruptImageError,UnexpectedEndOfFile,image);
         Upsample(image->columns >> 1,image->rows >> 1,image->columns,chroma1);
         Upsample(image->columns >> 1,image->rows >> 1,image->columns,chroma2);
         /*
@@ -698,7 +742,8 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
           image->colorspace=sRGBColorspace;
         else
           image->colorspace=YCCColorspace;
-        (void) TransformColorspace(image,RGBColorspace);
+        if (TransformColorspace(image,RGBColorspace) != MagickPass)
+          break;
         if (j < (long) number_images)
           {
             /*
@@ -706,16 +751,13 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
             */
             AllocateNextImage(image_info,image);
             if (image->next == (Image *) NULL)
-              {
-                DestroyImageList(image);
-                return((Image *) NULL);
-              }
+              ThrowPCDReaderException(ResourceLimitError,MemoryAllocationFailed,image);
             image=SyncNextImageInList(image);
           }
         (void) SetMonitorHandler(handler);
         if (!MagickMonitorFormatted(j-1,number_images,&image->exception,
                                     LoadImageText,image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
       }
       MagickFreeMemory(chroma2);
@@ -723,8 +765,9 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
       MagickFreeMemory(luma);
       while (image->previous != (Image *) NULL)
         image=image->previous;
-      overview_image=OverviewImage(image_info,image,exception);
-      return(overview_image);
+      CloseBlob(image);
+      /* OverviewImage destroys image list before returning */
+      return OverviewImage(image_info,image,exception);
     }
   /*
     Read interleaved image.
@@ -734,15 +777,21 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
   c2=chroma2;
   for (y=0; y < (long) height; y+=2)
   {
-    (void) ReadBlob(image,width,(char *) yy);
+    if (ReadBlob(image,width,(char *) yy) != width)
+      break;
     yy+=image->columns;
-    (void) ReadBlob(image,width,(char *) yy);
+    if (ReadBlob(image,width,(char *) yy) != width)
+      break;
     yy+=image->columns;
-    (void) ReadBlob(image,width >> 1,(char *) c1);
+    if (ReadBlob(image,width >> 1,(char *) c1) != (width >> 1))
+      break;
     c1+=image->columns;
-    (void) ReadBlob(image,width >> 1,(char *) c2);
+    if (ReadBlob(image,width >> 1,(char *) c2)  != (width >> 1))
+      break;
     c2+=image->columns;
   }
+  if (EOFBlob(image))
+    ThrowPCDReaderException(CorruptImageError,UnexpectedEndOfFile,image);
   if (subimage >= 4)
     {
       /*
@@ -779,6 +828,11 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
             }
         }
     }
+  if (EOFBlob(image))
+    ThrowPCDReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+
+  CloseBlob(image);
+
   Upsample(image->columns >> 1,image->rows >> 1,image->columns,chroma1);
   Upsample(image->columns >> 1,image->rows >> 1,image->columns,chroma2);
   /*
@@ -804,7 +858,7 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                   image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   MagickFreeMemory(chroma2);
@@ -816,11 +870,6 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
     image->colorspace=YCCColorspace;
   /* FIXME: YCCColorspace transform is broken! 1.1 is ok! */
   (void) TransformColorspace(image,RGBColorspace);
-  if (EOFBlob(image))
-    ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
-      image->filename);
-  CloseBlob(image);
-
   if ((rotate == 1) || (rotate == 3))
     {
       double
@@ -836,6 +885,8 @@ static Image *ReadPCDImage(const ImageInfo *image_info,ExceptionInfo *exception)
       rotated_image=RotateImage(image,degrees,exception);
       if (rotated_image != (Image *) NULL)
         {
+          DestroyBlob(rotated_image);
+          rotated_image->blob=ReferenceBlob(image->blob);
           DestroyImage(image);
           image=rotated_image;
         }
@@ -1012,18 +1063,32 @@ static unsigned int WritePCDTile(const ImageInfo *image_info,
       */
       border_info.width=(geometry.width-tile_image->columns+1) >> 1;
       border_info.height=(geometry.height-tile_image->rows+1) >> 1;
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Adding %lux%lu border to %lux%lu tile ",
+                              border_info.width, border_info.height,
+                              image->columns, image->rows);
       bordered_image=BorderImage(tile_image,&border_info,&image->exception);
-      if (bordered_image == (Image *) NULL)
-        return(False);
       DestroyImage(tile_image);
+      tile_image=(Image *) NULL;
+      if (bordered_image == (Image *) NULL)
+        return(MagickFail);
       tile_image=bordered_image;
     }
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Transforming tile to %s from %lux%lu",
+                          tile_geometry,
+                          image->columns, image->rows);
   (void) TransformImage(&tile_image,(char *) NULL,tile_geometry);
   (void) TransformColorspace(tile_image,YCCColorspace);
   downsample_image=ResizeImage(tile_image,tile_image->columns/2,
     tile_image->rows/2,TriangleFilter,1.0,&image->exception);
   if (downsample_image == (Image *) NULL)
-    return(False);
+    {
+      DestroyImage(tile_image);
+      return(MagickFail);
+    }
   /*
     Write tile to PCD file.
   */
@@ -1059,17 +1124,17 @@ static unsigned int WritePCDTile(const ImageInfo *image_info,
     if (QuantumTick(y,tile_image->rows))
       if (!MagickMonitorFormatted(y,tile_image->rows,&image->exception,
                                   SaveImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   for (i=0; i < 0x800; i++)
     (void) WriteBlobByte(image,'\0');
   DestroyImage(downsample_image);
   DestroyImage(tile_image);
-  return(True);
+  return(MagickPass);
 }
 
-static unsigned int WritePCDImage(const ImageInfo *image_info,Image *image)
+static MagickPassFail WritePCDImage(const ImageInfo *image_info,Image *image)
 {
   Image
     *pcd_image;
@@ -1097,6 +1162,8 @@ static unsigned int WritePCDImage(const ImageInfo *image_info,Image *image)
       if (rotated_image == (Image *) NULL)
         return(False);
       pcd_image=rotated_image;
+      DestroyBlob(rotated_image);
+      pcd_image->blob=ReferenceBlob(image->blob);
     }
   /*
     Open output image file.
@@ -1143,10 +1210,12 @@ static unsigned int WritePCDImage(const ImageInfo *image_info,Image *image)
   */
   status=WritePCDTile(image_info,pcd_image,(char *) "768x512>",
     (char *) "192x128");
-  status|=WritePCDTile(image_info,pcd_image,(char *) "768x512>",
+  status&=WritePCDTile(image_info,pcd_image,(char *) "768x512>",
     (char *) "384x256");
-  status|=WritePCDTile(image_info,pcd_image,(char *) "768x512>",
+  status&=WritePCDTile(image_info,pcd_image,(char *) "768x512>",
     (char *) "768x512");
+  if (GetBlobStatus(pcd_image) != 0)
+    status=MagickFail;
   CloseBlob(pcd_image);
   if (pcd_image != image)
     DestroyImage(pcd_image);
index 9fdf25f..e6f671e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2010 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -205,6 +205,10 @@ ModuleExport void UnregisterPCLImage(void)
 */
 static PCL_CompressionType PCL_ChooseCompression(unsigned long row_width,
                                                  unsigned char *row,
+                                                 unsigned char *last_row) MAGICK_FUNC_PURE;
+
+static PCL_CompressionType PCL_ChooseCompression(unsigned long row_width,
+                                                 unsigned char *row,
                                                  unsigned char *last_row)
 {
   unsigned long
@@ -275,7 +279,7 @@ static PCL_CompressionType PCL_ChooseCompression(unsigned long row_width,
       */
       RLE_cost += 2*(unrep+((rep+255)/256));
       TiffRLE_cost += unrep + ((unrep+127)/128) + 2*((rep+127)/128);
-    } 
+    }
   /*
     Special case #1 - row is all zero
   */
@@ -339,7 +343,7 @@ static PCL_CompressionType PCL_ChooseCompression(unsigned long row_width,
 
   /* Choose compression to use, starting with most likely */
   least_cost=delta_cost;
-  compression=PCL_DeltaCompression; 
+  compression=PCL_DeltaCompression;
   if (TiffRLE_cost < least_cost)
     {
       least_cost=TiffRLE_cost;
@@ -475,9 +479,9 @@ static unsigned long PCL_DeltaCompress(unsigned long row_width,
             }
           if (rep_this_time == 255)
             *out++ = (unsigned char)0;
-        } 
+        }
       /* Now skip back to beginning of unreplicated data and start outputting it */
-      q -= unrep; 
+      q -= unrep;
       while (1)
         {
           unrep -= unrep_this_time;
@@ -828,6 +832,9 @@ static unsigned int WritePCLImage(const ImageInfo *image_info,Image *image)
     compression,
     last_row_compression;
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -835,6 +842,7 @@ static unsigned int WritePCLImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -942,7 +950,7 @@ static unsigned int WritePCLImage(const ImageInfo *image_info,Image *image)
         Start raster image
       */
       if  ((AccessDefinition(image_info,"pcl","fit-to-page") != NULL) ||
-          (AccessDefinition(image_info,"pcl","fit_to_page") != NULL))
+           (AccessDefinition(image_info,"pcl","fit_to_page") != NULL))
         (void) WriteBlobString(image,"\033*r3A");  /* start raster graphics with scaling */
       else
         (void) WriteBlobString(image,"\033*r1A");  /* start raster graphics */
@@ -1010,7 +1018,16 @@ static unsigned int WritePCLImage(const ImageInfo *image_info,Image *image)
               for (x=0; x < (long) image->columns; x++)
                 {
                   byte<<=1;
-                  if (indexes[x] == blk_ind) byte |= 1;
+                  if (image->storage_class == PseudoClass)
+                    {
+                      if (indexes[x] == blk_ind)
+                        byte |= 1;
+                    }
+                  else
+                    {
+                      if (p[x].red == 0)
+                        byte |= 1;
+                    }
                   bit++;
                   if (bit == 8)
                     {
@@ -1028,10 +1045,20 @@ static unsigned int WritePCLImage(const ImageInfo *image_info,Image *image)
               /*
                 8 bit PseudoClass row
               */
-              indexes=AccessImmutableIndexes(image);
-              for (x=0; x < (long) image->columns; x++)
+              if (image->storage_class == PseudoClass)
                 {
-                  *q++=indexes[x];
+                  indexes=AccessImmutableIndexes(image);
+                  for (x=0; x < (long) image->columns; x++)
+                    {
+                      *q++=indexes[x];
+                    }
+                }
+              else
+                {
+                  for (x=0; x < (long) image->columns; x++)
+                    {
+                      *q++=PixelIntensityRec601(&p[x]);
+                    }
                 }
             }
           else
@@ -1096,7 +1123,7 @@ static unsigned int WritePCLImage(const ImageInfo *image_info,Image *image)
                           (void) WriteBlobString(image,buffer);
                           WriteBlob(image,bytes_to_write,output_row);
                           break;
-                        } 
+                        }
                       case PCL_TiffRLECompression:
                         {
                           if (compression != last_row_compression)
@@ -1108,7 +1135,7 @@ static unsigned int WritePCLImage(const ImageInfo *image_info,Image *image)
                           bytes_to_write=PCL_TiffRLECompress(bytes_per_line,pixels,output_row);
                           FormatString(buffer,"\033*b%luW",bytes_to_write);
                           (void) WriteBlobString(image,buffer);
-                          WriteBlob(image,bytes_to_write,output_row);         
+                          WriteBlob(image,bytes_to_write,output_row);
                           break;
                         }
                       case PCL_RLECompression:
@@ -1122,7 +1149,7 @@ static unsigned int WritePCLImage(const ImageInfo *image_info,Image *image)
                           bytes_to_write=PCL_RLECompress(bytes_per_line,pixels,output_row);
                           FormatString(buffer,"\033*b%luW",bytes_to_write);
                           (void) WriteBlobString(image,buffer);
-                          WriteBlob(image,bytes_to_write,output_row);         
+                          WriteBlob(image,bytes_to_write,output_row);
                           break;
                         }
                       case PCL_RepeatedRowCompression:
@@ -1137,7 +1164,7 @@ static unsigned int WritePCLImage(const ImageInfo *image_info,Image *image)
                           FormatString(buffer,"\033*b0W");  /* no data -> replicate row */
                           (void) WriteBlobString(image,buffer);
                           break;
-                        } 
+                        }
                       case PCL_NoCompression:
                         {
                           if (compression != last_row_compression)
@@ -1186,7 +1213,7 @@ static unsigned int WritePCLImage(const ImageInfo *image_info,Image *image)
         break;
       image=SyncNextImageInList(image);
       if ((status &= MagickMonitorFormatted(scene++,
-                                            GetImageListLength(image),
+                                            image_list_length,
                                             &image->exception,
                                             SaveImagesText,
                                             image->filename)) == MagickFail)
index 4f42dde..ffc1ade 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -249,6 +249,7 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     status;
 
   size_t
+    scanline_size,
     pcx_packets;
 
   magick_off_t
@@ -324,6 +325,7 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
         pcx_info.bottom=ReadBlobLSBShort(image);
         pcx_info.horizontal_resolution=ReadBlobLSBShort(image);
         pcx_info.vertical_resolution=ReadBlobLSBShort(image);
+        (void) memset(pcx_colormap,0,sizeof(pcx_colormap));
         if (ReadBlob(image,3*16,(char *) pcx_colormap) != 3*16)
           break;
         if ((c = ReadBlobByte(image)) == EOF)
@@ -430,25 +432,39 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     if (pcx_info.planes > 6)
       ThrowPCXReaderException(CorruptImageError,UnsupportedNumberOfPlanes,image);
 
-    if ((pcx_info.bits_per_pixel != 8) || (pcx_info.planes == 1))
-      if ((pcx_info.version == 3) || (pcx_info.version == 5) ||
-          ((pcx_info.bits_per_pixel*pcx_info.planes) == 1))
-       {
-          image->colors=1 << (pcx_info.bits_per_pixel*pcx_info.planes);
-         if (image->colors > 256)
-           image->colors = 256;
-       }
-    if (!AllocateImageColormap(image,image->colors))
-      ThrowPCXReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-    if ((pcx_info.bits_per_pixel >= 8) && (pcx_info.planes != 1))
-      image->storage_class=DirectClass;
-    p=pcx_colormap;
-    for (i=0; i < image->colors; i++)
-    {
-      image->colormap[i].red=ScaleCharToQuantum(*p++);
-      image->colormap[i].green=ScaleCharToQuantum(*p++);
-      image->colormap[i].blue=ScaleCharToQuantum(*p++);
-    }
+    if ((pcx_info.bits_per_pixel >= 8) || (pcx_info.planes != 1))
+      {
+        image->storage_class=DirectClass;
+      }
+    else
+      {
+        if ((pcx_info.bits_per_pixel != 8) || (pcx_info.planes == 1))
+          if ((pcx_info.version == 3) || (pcx_info.version == 5) ||
+              ((pcx_info.bits_per_pixel*pcx_info.planes) == 1))
+            {
+              image->colors=1 << (pcx_info.bits_per_pixel*pcx_info.planes);
+              if (image->colors > 256)
+                image->colors = 256;
+            }
+
+      if (!AllocateImageColormap(image,image->colors))
+        ThrowPCXReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+
+      /*
+        256 color images have their color map at the end of the file.
+        Colormap for 1 bit/pixel images is explicitly initialized.
+      */
+      if (image->colors <= 16)
+        {
+          p=pcx_colormap;
+          for (i=0; i < image->colors; i++)
+            {
+              image->colormap[i].red=ScaleCharToQuantum(*p++);
+              image->colormap[i].green=ScaleCharToQuantum(*p++);
+              image->colormap[i].blue=ScaleCharToQuantum(*p++);
+            }
+        }
+      }
 
     for (i=0; i < 54; i++)
       (void) ReadBlobByte(image);
@@ -457,7 +473,7 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
         break;
 
     if (CheckImagePixelLimits(image, exception) != MagickPass)
-      ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+      ThrowPCXReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
 
 
     /*
@@ -466,7 +482,7 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     {
       double
         uncompressed_size;
-      
+
       uncompressed_size=((double) image->rows*pcx_info.bytes_per_line*pcx_info.planes);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                             "Uncompressed size: %.0f", uncompressed_size);
@@ -474,15 +490,15 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
         {
           /* Not compressed */
           if (uncompressed_size > file_size)
-            ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,
-                                   image);
+            ThrowPCXReaderException(CorruptImageError,InsufficientImageDataInFile,
+                                    image);
         }
       else
         {
           /* RLE compressed */
           if (uncompressed_size > file_size*254.0)
-            ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,
-                                 image);
+            ThrowPCXReaderException(CorruptImageError,InsufficientImageDataInFile,
+                                    image);
         }
     }
 
@@ -499,10 +515,13 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     pcx_pixels=MagickAllocateMemory(unsigned char *,pcx_packets);
     if (pcx_pixels == (unsigned char *) NULL)
       ThrowPCXReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-    scanline=MagickAllocateArray(unsigned char *,Max(image->columns,
-      (size_t) pcx_info.bytes_per_line),Max(pcx_info.planes,8));
+    scanline_size=MagickArraySize(Max(image->columns,
+                                      (size_t) pcx_info.bytes_per_line),
+                                  Max(pcx_info.planes,8));
+    scanline=MagickAllocateMemory(unsigned char *,scanline_size);
     if (scanline == (unsigned char *) NULL)
       ThrowPCXReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+    (void) memset(scanline,0,scanline_size);
     if (pcx_info.encoding == 0)
       {
         /*
@@ -738,7 +757,7 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
         if (QuantumTick(y,image->rows))
           if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                       image->filename,
-                                     image->columns,image->rows))
+                                      image->columns,image->rows))
             break;
     }
     if (image->storage_class == PseudoClass)
@@ -1001,6 +1020,9 @@ static unsigned int WritePCXImage(const ImageInfo *image_info,Image *image)
   ImageCharacteristics
     characteristics;
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -1009,6 +1031,7 @@ static unsigned int WritePCXImage(const ImageInfo *image_info,Image *image)
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
 
+  image_list_length=GetImageListLength(image);
   logging=image->logging;
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
@@ -1035,7 +1058,7 @@ static unsigned int WritePCXImage(const ImageInfo *image_info,Image *image)
   {
     if (logging && write_dcx)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "Writing DCX frame %lu...",scene);
+                            "Writing DCX frame %lu...",scene);
     /*
       Ensure that image is in RGB space.
     */
@@ -1044,12 +1067,12 @@ static unsigned int WritePCXImage(const ImageInfo *image_info,Image *image)
       Analyze image to be written.
     */
     if (!GetImageCharacteristics(image,&characteristics,
-                                (OptimizeType == image_info->type),
-                                &image->exception))
+                                 (OptimizeType == image_info->type),
+                                 &image->exception))
       {
         LiberatePCXAllocations();
-       CloseBlob(image);
-       return MagickFail;
+        CloseBlob(image);
+        return MagickFail;
       }
     if (page_table != (ExtendedSignedIntegralType *) NULL)
       page_table[scene]=TellBlob(image);
@@ -1199,7 +1222,7 @@ static unsigned int WritePCXImage(const ImageInfo *image_info,Image *image)
           if (QuantumTick(y,image->rows))
             if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                         SaveImageText,image->filename,
-                                       image->columns,image->rows))
+                                        image->columns,image->rows))
               break;
         }
       }
@@ -1225,7 +1248,7 @@ static unsigned int WritePCXImage(const ImageInfo *image_info,Image *image)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                           SaveImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
       else
@@ -1275,7 +1298,7 @@ static unsigned int WritePCXImage(const ImageInfo *image_info,Image *image)
               if (QuantumTick(y,image->rows))
                 if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                             SaveImageText,image->filename,
-                                           image->columns,image->rows))
+                                            image->columns,image->rows))
                   break;
           }
         }
@@ -1287,7 +1310,7 @@ static unsigned int WritePCXImage(const ImageInfo *image_info,Image *image)
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene++,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename);
     if (status == False)
index 0f34f50..8d4b8da 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -144,33 +144,41 @@ static void LogPDPInfo(const PDBInfo *info)
 
 static void LogPDPImage(const PDBImage *image)
 {
-    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                          "PDP Image:\n"
-                          "    name:       %.32s\n"
-                          "    version:    %d\n"
-                          "    type:       %d\n"
-                          "    reserved_1: %lu\n"
-                          "    note:       %lu\n"
-                          "    x_last:     %u\n"
-                          "    y_last:     %u\n"
-                          "    reserved_2: %lu\n"
-                          "    x_anchor:   %u\n"
-                          "    y_anchor:   %u\n"
-                          "    width:      %u\n"
-                          "    height:     %u",
-                          image->name,
-                          image->version,
-                          image->type,
-                          image->reserved_1,
-                          image->note,
-                          image->x_last,
-                          image->y_last,
-                          image->reserved_2,
-                          image->x_anchor,
-                          image->y_anchor,
-                          image->width,
-                          image->height
-                          );
+  static const char *type_string;
+  switch(image->type)
+    {
+    case 0: type_string = "2 bit gray"; break;
+    case 2: type_string = "4 bit gray"; break;
+    default: type_string = "monochrome"; break;
+    }
+
+  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                        "PDP Image:\n"
+                        "    name:       %.32s\n"
+                        "    version:    %d\n"
+                        "    type:       %d (%s)\n"
+                        "    reserved_1: %lu\n"
+                        "    note:       %lu\n"
+                        "    x_last:     %u\n"
+                        "    y_last:     %u\n"
+                        "    reserved_2: %lu\n"
+                        "    x_anchor:   %u\n"
+                        "    y_anchor:   %u\n"
+                        "    width:      %u\n"
+                        "    height:     %u",
+                        image->name,
+                        image->version,
+                        image->type, type_string,
+                        image->reserved_1,
+                        image->note,
+                        image->x_last,
+                        image->y_last,
+                        image->reserved_2,
+                        image->x_anchor,
+                        image->y_anchor,
+                        image->width,
+                        image->height
+                        );
 }
 \f
 /*
@@ -204,10 +212,11 @@ static void LogPDPImage(const PDBImage *image)
 %
 %
 */
-static unsigned int DecodeImage(Image *image,unsigned char *pixels,
+static MagickPassFail DecodeImage(Image *image,unsigned char *pixels,
   const size_t length)
 {
   int
+    c,
     count,
     pixel;
 
@@ -217,23 +226,44 @@ static unsigned int DecodeImage(Image *image,unsigned char *pixels,
   register unsigned char
     *p;
 
+  MagickPassFail
+    status = MagickPass;
+
   p=pixels;
   while (p < (pixels+length))
   {
-    pixel=ReadBlobByte(image);
+    if ((pixel=ReadBlobByte(image)) == EOF)
+      {
+        status = MagickFail;
+        goto decode_image_quit;
+      }
     if (pixel <= 0x80)
       {
         count=pixel+1;
         for (i=0; i < count; i++)
-          *p++=ReadBlobByte(image);
+          {
+            if ((c = ReadBlobByte(image)) == EOF)
+              {
+                status = MagickFail;
+                goto decode_image_quit;
+              }
+            *p++ = (unsigned char) c;
+          }
         continue;
       }
     count=pixel+1-0x80;
-    pixel=ReadBlobByte(image);
+    if ((pixel=ReadBlobByte(image)) == EOF)
+      {
+        status = MagickFail;
+        goto decode_image_quit;
+      }
+
     for (i=0; i < count; i++)
       *p++=(unsigned char) pixel;
   }
-  return(True);
+ decode_image_quit:;
+
+  return(status);
 }
 \f
 /*
@@ -313,8 +343,10 @@ static unsigned int IsPDB(const unsigned char *magick,const size_t length)
 
 static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
+  int
+    record_type;
+
   char
-    record_type,
     tag[3];
 
   Image
@@ -324,8 +356,7 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
     index;
 
   long
-    offset,
-    y;
+    offset;
 
   PDBImage
     pdb_image;
@@ -336,7 +367,10 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
   register IndexPacket
     *indexes;
 
-  register long
+  unsigned long
+    y;
+
+  register unsigned long
     x;
 
   register PixelPacket
@@ -384,8 +418,9 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
   pdb_info.modify_number=ReadBlobMSBLong(image);
   pdb_info.application_info=ReadBlobMSBLong(image);
   pdb_info.sort_info=ReadBlobMSBLong(image);
-  (void) ReadBlob(image,4,pdb_info.type);
-  (void) ReadBlob(image,4,pdb_info.id);
+  if ((ReadBlob(image,4,pdb_info.type) != 4) ||
+      (ReadBlob(image,4,pdb_info.id) != 4))
+    ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
   pdb_info.seed=ReadBlobMSBLong(image);
   pdb_info.next_record=ReadBlobMSBLong(image);
   pdb_info.number_records=ReadBlobMSBShort(image);
@@ -400,7 +435,8 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
     Read record header.
   */
   offset=(long) ReadBlobMSBLong(image);
-  (void) ReadBlob(image,3,tag);
+  if (ReadBlob(image,3,tag) != 3)
+    ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
   record_type=ReadBlobByte(image);
   if (((record_type != 0x00) && (record_type != 0x01)) ||
       (memcmp(tag,"\x40\x6f\x80",3) != 0))
@@ -465,18 +501,24 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
   pixels=MagickAllocateMemory(unsigned char *,packets + (packets != 0 ? 256 : 0));
   if (pixels == (unsigned char *) NULL)
     ThrowPDBReaderException(ResourceLimitWarning,MemoryAllocationFailed,image);
+  (void) memset(pixels,0,packets+256);
   switch (pdb_image.version)
   {
     case 0:
     {
       image->compression=NoCompression;
-      (void) ReadBlob(image,packets,(char *) pixels);
+      if (ReadBlob(image,packets,(char *) pixels) != packets)
+        {
+          MagickFreeMemory(pixels);
+          ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+        }
       break;
     }
     case 1:
     {
       image->compression=RLECompression;
-      (void) DecodeImage(image,pixels,packets);
+      if (DecodeImage(image,pixels,packets) == MagickFail)
+        ThrowPDBReaderException(CorruptImageError,UnexpectedEndOfFile,image);
       break;
     }
     default:
@@ -495,28 +537,31 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
       /*
         Read 1-bit PDB image.
       */
-      for (y=0; y < (long) image->rows; y++)
+      for (y=0; y < image->rows; y++)
       {
         q=SetImagePixels(image,0,y,image->columns,1);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=AccessMutableIndexes(image);
-        for (x=0; x < ((long) image->columns-7); x+=8)
+        bit=0;
+        for (x=0; x < image->columns; x++)
         {
-          for (bit=0; bit < 8; bit++)
-          {
-            index=(*p & (0x80U >> bit) ? 0x00U : 0x01U);
-            indexes[x+bit]=index;
-            *q++=image->colormap[index];
-          }
-          p++;
+          index=(*p & (0x80U >> bit) ? 0x00U : 0x01U);
+          indexes[x]=index;
+          *q++=image->colormap[index];
+          bit++;
+          if (bit == 8)
+            {
+              p++;
+              bit=0;
+            }
         }
         if (!SyncImagePixels(image))
           break;
         if (QuantumTick(y,image->rows))
           if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                       image->filename,
-                                     image->columns,image->rows))
+                                      image->columns,image->rows))
             break;
       }
       break;
@@ -526,38 +571,35 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
       /*
         Read 2-bit PDB image.
       */
-      for (y=0; y < (long) image->rows; y++)
+      unsigned int
+        shift;
+
+      for (y=0; y < image->rows; y++)
       {
         q=SetImagePixels(image,0,y,image->columns,1);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=AccessMutableIndexes(image);
-        for (x=0; x < (long) image->columns-3; x+=4)
-        {
-          index=(IndexPacket) (3-((*p >> 6) & 0x03));
-          VerifyColormapIndex(image,index);
-          indexes[x]=index;
-          *q++=image->colormap[index];
-          index=(IndexPacket) (3-((*p >> 4) & 0x03));
-          VerifyColormapIndex(image,index);
-          indexes[x+1]=index;
-          *q++=image->colormap[index];
-          index=(IndexPacket) (3-((*p >> 2) & 0x03));
-          VerifyColormapIndex(image,index);
-          indexes[x+2]=index;
-          *q++=image->colormap[index];
-          index=(IndexPacket) (3-((*p) & 0x03));
-          VerifyColormapIndex(image,index);
-          indexes[x+3]=index;
-          *q++=image->colormap[index];
-          p++;
-        }
+        shift = 8;
+        for (x=0; x < image->columns; x++)
+          {
+            shift -= 2;
+            index=(IndexPacket) (3-((*p >> shift) & 0x03));
+            VerifyColormapIndex(image,index);
+            indexes[x]=index;
+            *q++=image->colormap[index];
+            if (shift == 0)
+              {
+                shift = 8;
+                p++;
+              }
+          }
         if (!SyncImagePixels(image))
           break;
         if (QuantumTick(y,image->rows))
           if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                       image->filename,
-                                     image->columns,image->rows))
+                                      image->columns,image->rows))
             break;
       }
       break;
@@ -567,30 +609,35 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
       /*
         Read 4-bit PDB image.
       */
-      for (y=0; y < (long) image->rows; y++)
+      unsigned int
+        shift;
+
+      for (y=0; y < image->rows; y++)
       {
         q=SetImagePixels(image,0,y,image->columns,1);
         if (q == (PixelPacket *) NULL)
           break;
         indexes=AccessMutableIndexes(image);
-        for (x=0; x < (long) image->columns-1; x+=2)
+        shift = 8;
+        for (x=0; x < image->columns; x++)
         {
-          index=(IndexPacket) (15-((*p >> 4) & 0x0f));
+          shift -= 4;
+          index=(IndexPacket) (15-((*p >> shift) & 0x0f));
           VerifyColormapIndex(image,index);
           indexes[x]=index;
           *q++=image->colormap[index];
-          index=(IndexPacket) (15-((*p) & 0x0f));
-          VerifyColormapIndex(image,index);
-          indexes[x+1]=index;
-          *q++=image->colormap[index];
-          p++;
+          if (shift == 0)
+            {
+              shift = 8;
+              p++;
+            }
         }
         if (!SyncImagePixels(image))
           break;
         if (QuantumTick(y,image->rows))
           if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                       image->filename,
-                                     image->columns,image->rows))
+                                      image->columns,image->rows))
             break;
       }
       break;
@@ -615,7 +662,7 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
       register char
         *p;
 
-      unsigned int
+      size_t
         length;
 
       /*
@@ -625,10 +672,11 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
       length=MaxTextExtent;
       comment=MagickAllocateMemory(char *,length+1);
       p=comment;
+      p[0]='\0';
       if (comment != (char *) NULL)
         for ( ; c != EOF; p++)
         {
-          if ((p-comment) >= (int) length)
+          if ((size_t) (p-comment) >= length)
             {
               length<<=1;
               length+=MaxTextExtent;
@@ -769,7 +817,7 @@ static unsigned int WritePDBImage(const ImageInfo *image_info,Image *image)
   int
     bits;
 
-  long
+  unsigned long
     y;
 
   PDBImage
@@ -788,12 +836,12 @@ static unsigned int WritePDBImage(const ImageInfo *image_info,Image *image)
     *scanline = (unsigned char *) NULL;
 
   unsigned int
-    bits_per_pixel,    
+    bits_per_pixel,
     packet_size,
     status;
 
   size_t
-       packets;
+        packets;
 
   unsigned long
     literal,
@@ -889,6 +937,7 @@ static unsigned int WritePDBImage(const ImageInfo *image_info,Image *image)
   buffer=MagickAllocateMemory(unsigned char *,512);
   if (buffer == (unsigned char *) NULL)
     ThrowPDBWriterException(ResourceLimitWarning,MemoryAllocationFailed,image);
+  (void) memset(buffer,0,512);
   packet_size=image->depth > 8 ? 2: 1;
   scanline=MagickAllocateArray(unsigned char *,image->columns,packet_size);
   if (scanline == (unsigned char *) NULL)
@@ -902,7 +951,7 @@ static unsigned int WritePDBImage(const ImageInfo *image_info,Image *image)
   repeat=0;
   q=p;
   buffer[0]=0x00;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < image->rows; y++)
   {
     if (!AcquireImagePixels(image,0,y,image->columns,1,&image->exception))
       break;
@@ -957,7 +1006,7 @@ static unsigned int WritePDBImage(const ImageInfo *image_info,Image *image)
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                   SaveImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   q=EncodeRLE(q,buffer,literal,repeat);
index ef2f75b..a82fb3b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -180,14 +180,14 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
   assert(image_info->signature == MagickSignature);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  
-  if ((value=AccessDefinition(image_info,"pdf","use-cropbox"))) 
+
+  if ((value=AccessDefinition(image_info,"pdf","use-cropbox")))
     {
       if (strcmp(value,"true") == 0)
         use_crop_box = True;
     }
 
-   if ((value=AccessDefinition(image_info,"pdf","stop-on-error"))) 
+   if ((value=AccessDefinition(image_info,"pdf","stop-on-error")))
      {
        if (strcmp(value,"true") == 0)
          pdf_stop_on_error = True;
@@ -265,87 +265,87 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
     (void) memset(&box,0,sizeof(RectangleInfo));
     for (p=command; ; )
       {
-       c=ReadBlobByte(image);
-       if (c == EOF)
-         break;
-       (void) fputc(c,file);
-       *p++=(char) c;
-       if ((c != '\n') && (c != '\r') && ((p-command) < (MaxTextExtent-1)))
-         continue;
-       *p='\0';
-       p=command;
-       /*
-         Continue unless this is a MediaBox statement.
-       */
-       if (LocaleNCompare(command,"/Rotate ",8) == 0)
-         {
-           count=sscanf(command,"/Rotate %d",&rotate);
-           if (count > 0)
-             {
-               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                     "Rotate by %d degrees",rotate);
-             }
-         }
-       q=strstr(command,MediaBox);
-       if (q == (char *) NULL)
-         continue;
-       count=sscanf(q,"/MediaBox [%lf %lf %lf %lf",&bounds.x1,&bounds.y1,
-                    &bounds.x2,&bounds.y2);
-       if (count != 4)
-         count=sscanf(q,"/MediaBox[%lf %lf %lf %lf",&bounds.x1,&bounds.y1,
-                      &bounds.x2,&bounds.y2);
-       if (count == 4)
-         {
-           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                 "Parsed: MediaBox %lf %lf %lf %lf",
-                                 bounds.x1,bounds.y1,
-                                 bounds.x2,bounds.y2);
-         }
-       if (count != 4)
-         continue;
-       if ((bounds.x1 > bounds.x2) || (bounds.y1 > bounds.y2))
-         continue;
-       /*
-         Set Postscript render geometry.
-       */
-       width=(unsigned long) (bounds.x2-bounds.x1+0.5);
-       height=(unsigned long) (bounds.y2-bounds.y1+0.5);
-       if ((width <= box.width) && (height <= box.height))
-         continue;
-       page.width=width;
-       page.height=height;
-       box=page;
+        c=ReadBlobByte(image);
+        if (c == EOF)
+          break;
+        (void) fputc(c,file);
+        *p++=(char) c;
+        if ((c != '\n') && (c != '\r') && ((p-command) < (MaxTextExtent-1)))
+          continue;
+        *p='\0';
+        p=command;
+        /*
+          Continue unless this is a MediaBox statement.
+        */
+        if (LocaleNCompare(command,"/Rotate ",8) == 0)
+          {
+            count=sscanf(command,"/Rotate %d",&rotate);
+            if (count > 0)
+              {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Rotate by %d degrees",rotate);
+              }
+          }
+        q=strstr(command,MediaBox);
+        if (q == (char *) NULL)
+          continue;
+        count=sscanf(q,"/MediaBox [%lf %lf %lf %lf",&bounds.x1,&bounds.y1,
+                     &bounds.x2,&bounds.y2);
+        if (count != 4)
+          count=sscanf(q,"/MediaBox[%lf %lf %lf %lf",&bounds.x1,&bounds.y1,
+                       &bounds.x2,&bounds.y2);
+        if (count == 4)
+          {
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Parsed: MediaBox %lf %lf %lf %lf",
+                                  bounds.x1,bounds.y1,
+                                  bounds.x2,bounds.y2);
+          }
+        if (count != 4)
+          continue;
+        if ((bounds.x1 > bounds.x2) || (bounds.y1 > bounds.y2))
+          continue;
+        /*
+          Set Postscript render geometry.
+        */
+        width=(unsigned long) (bounds.x2-bounds.x1+0.5);
+        height=(unsigned long) (bounds.y2-bounds.y1+0.5);
+        if ((width <= box.width) && (height <= box.height))
+          continue;
+        page.width=width;
+        page.height=height;
+        box=page;
       }
     /*
       If page is rotated right or left, then swap width and height values.
     */
     if ((90 == AbsoluteValue(rotate)) || (270 == AbsoluteValue(rotate)))
       {
-       double
-         value;
+        double
+          value;
 
-       value=page.width;
-       page.width=page.height;
-       page.height=value;
+        value=page.width;
+        page.width=page.height;
+        page.height=value;
       }
     if ((page.width == 0) || (page.height == 0))
       {
-       SetGeometry(image,&page);
-       (void) GetGeometry(PSPageGeometry,&page.x,&page.y,&page.width,
-                          &page.height);
+        SetGeometry(image,&page);
+        (void) GetGeometry(PSPageGeometry,&page.x,&page.y,&page.width,
+                           &page.height);
       }
     if (image_info->page != (char *) NULL)
       (void) GetGeometry(image_info->page,&page.x,&page.y,&page.width,
-                        &page.height);
+                         &page.height);
     geometry[0]='\0';
     FormatString(geometry,"%lux%lu",
-                (unsigned long) ceil(page.width*image->x_resolution/dx_resolution-0.5),
-                (unsigned long) ceil(page.height*image->y_resolution/dy_resolution-0.5));
+                 (unsigned long) ceil(page.width*image->x_resolution/dx_resolution-0.5),
+                 (unsigned long) ceil(page.height*image->y_resolution/dy_resolution-0.5));
     if (ferror(file))
       {
-       (void) fclose(file);
-       ThrowReaderException(CorruptImageError,AnErrorHasOccurredWritingToFile,
-                            image);
+        (void) fclose(file);
+        ThrowReaderException(CorruptImageError,AnErrorHasOccurredWritingToFile,
+                             image);
       }
   }
 
@@ -398,12 +398,12 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
     clone_info=CloneImageInfo(image_info);
     if (!AcquireTemporaryFileName(clone_info->filename))
       {
-       DestroyImageInfo(clone_info);
-       ThrowReaderTemporaryFileException(clone_info->filename);
+        DestroyImageInfo(clone_info);
+        ThrowReaderTemporaryFileException(clone_info->filename);
       }
     FormatString(command,delegate_info->commands,antialias,
-                antialias,density,options,clone_info->filename,
-                postscript_filename);
+                 antialias,density,options,clone_info->filename,
+                 postscript_filename);
   }
   (void) MagickMonitorFormatted(0,8,&image->exception,RenderPostscriptText,
                                 image->filename);
@@ -415,7 +415,7 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if (IsAccessibleAndNotEmpty(clone_info->filename))
     {
       /*
-       Read Ghostscript output.
+        Read Ghostscript output.
       */
       clone_info->blob=(void *) NULL;
       clone_info->length=0;
@@ -431,20 +431,20 @@ static Image *ReadPDFImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if (image == (Image *) NULL)
     {
       if (UndefinedException == exception->severity)
-       ThrowException(exception,DelegateError,PostscriptDelegateFailed,filename);
+        ThrowException(exception,DelegateError,PostscriptDelegateFailed,filename);
     }
   else
     {
       do
-       {
-         (void) strlcpy(image->magick,"PDF",sizeof(image->magick));
-         (void) strlcpy(image->filename,filename,sizeof(image->filename));
-         next_image=SyncNextImageInList(image);
-         if (next_image != (Image *) NULL)
-           image=next_image;
-       } while (next_image != (Image *) NULL);
+        {
+          (void) strlcpy(image->magick,"PDF",sizeof(image->magick));
+          (void) strlcpy(image->filename,filename,sizeof(image->filename));
+          next_image=SyncNextImageInList(image);
+          if (next_image != (Image *) NULL)
+            image=next_image;
+        } while (next_image != (Image *) NULL);
       while (image->previous != (Image *) NULL)
-       image=image->previous;
+        image=image->previous;
       if (image_info->subimage != 0)
         {
           unsigned long
@@ -596,6 +596,18 @@ static char *EscapeParenthesis(const char *text)
   return(buffer);
 }
 
+#define ThrowPDFWriterException(code_,reason_,image_) \
+  {                                                   \
+    MagickFreeMemory(fax_blob);                       \
+    MagickFreeMemory(xref);                           \
+    ThrowWriterException(code_,reason_,image_);       \
+  }
+#define ThrowPDFWriterException2(code_,reason_,image_)  \
+  {                                                     \
+    MagickFreeMemory(fax_blob);                         \
+    MagickFreeMemory(xref);                             \
+    ThrowWriterException2(code_,reason_,image_);        \
+  }
 static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
 {
 #define CFormat  "/Filter [ /%.1024s ]\n"
@@ -673,7 +685,10 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
     text_size;
 
   ExtendedSignedIntegralType
-    *xref;
+    *xref = (ExtendedSignedIntegralType *) NULL;
+
+  size_t
+    image_list_length;
 
   /*
     Open output image file.
@@ -682,9 +697,10 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
-    ThrowWriterException(FileOpenError,UnableToOpenFile,image);
+    ThrowPDFWriterException(FileOpenError,UnableToOpenFile,image);
 
   /*
     Allocate X ref memory.
@@ -692,7 +708,7 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
   xref=MagickAllocateMemory(ExtendedSignedIntegralType *,
                             2048*sizeof(ExtendedSignedIntegralType));
   if (xref == (ExtendedSignedIntegralType *) NULL)
-    ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+    ThrowPDFWriterException(ResourceLimitError,MemoryAllocationFailed,image);
   (void) memset(xref,0,2048*sizeof(ExtendedSignedIntegralType));
   /*
     Write Documentation Information Dictionary
@@ -710,7 +726,7 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
                time_meridian->tm_mon+1,time_meridian->tm_mday,time_meridian->tm_hour,
                time_meridian->tm_min,time_meridian->tm_sec);
   GetPathComponent(image->filename,BasePath,basename);
-  
+
   FormatString(buffer,"/Title (%.1024s)\n",EscapeParenthesis(basename));
   (void) WriteBlobString(image,buffer);
   FormatString(buffer,"/CreationDate (%.1024s)\n",date);
@@ -765,7 +781,7 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
       MagickReallocMemory(ExtendedSignedIntegralType *,xref,
                           (count+2048)*sizeof(ExtendedSignedIntegralType));
       if (xref == (ExtendedSignedIntegralType *) NULL)
-        ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+        ThrowPDFWriterException(ResourceLimitError,MemoryAllocationFailed,image);
     }
   (void) WriteBlobString(image,"]\n");
   FormatString(buffer,"/Count %lu\n",(count-pages_id)/ObjectsPerImage);
@@ -776,76 +792,76 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
   do
     {
       ImageCharacteristics
-       characteristics;
+        characteristics;
 
       CompressionType
-       compression;
+        compression;
 
       /*
-       Analyze image properties.
+        Analyze image properties.
       */
       (void) GetImageCharacteristics(image,&characteristics,
-                                    (OptimizeType == image_info->type),
-                                    &image->exception);
+                                     (OptimizeType == image_info->type),
+                                     &image->exception);
 
       compression=image->compression;
       if (image_info->compression != UndefinedCompression)
-       {
-         /*
-           ImageInfo compression always prevails if it is set.
-         */
-         compression=image_info->compression;
-       }
+        {
+          /*
+            ImageInfo compression always prevails if it is set.
+          */
+          compression=image_info->compression;
+        }
       else
-       {
-         /*
-           Default to Zip compression unless the image was JPEG
-           compressed and is not now monochrome or colormapped.
-         */
-         if ((JPEGCompression != compression) ||
-             (characteristics.monochrome) ||
-             (characteristics.palette))
-           {
+        {
+          /*
+            Default to Zip compression unless the image was JPEG
+            compressed and is not now monochrome or colormapped.
+          */
+          if ((JPEGCompression != compression) ||
+              (characteristics.monochrome) ||
+              (characteristics.palette))
+            {
 #if defined(HasZLIB)
-             compression=ZipCompression;
+              compression=ZipCompression;
 #else
-             compression=LZWCompression;
+              compression=LZWCompression;
 #endif
-           }
-       }
-      
+            }
+        }
+
       switch (compression)
-       {
+        {
 #if !defined(HasJPEG)
-       case JPEGCompression:
-         {
-           /*
-             If JPEG compression is not supported, then use RLE compression
-             and report a warning to user.
-           */
-           compression=RLECompression;
-           ThrowException(&image->exception,MissingDelegateError,JPEGLibraryIsNotAvailable,image->filename);
-           break;
-         }
+        case JPEGCompression:
+          {
+            /*
+              If JPEG compression is not supported, then use RLE compression
+              and report a warning to user.
+            */
+            compression=RLECompression;
+            ThrowException(&image->exception,MissingDelegateError,JPEGLibraryIsNotAvailable,image->filename);
+            break;
+          }
 #endif
 #if !defined(HasZLIB)
-       case ZipCompression:
-         {
-           /*
-             If ZIP compression is not supported, then use RLE compression
-             and report a warning to user.
-           */
-           compression=RLECompression;
-           ThrowException(&image->exception,MissingDelegateError,ZipLibraryIsNotAvailable,image->filename);
-           break;
-         }
+        case ZipCompression:
+          {
+            /*
+              If ZIP compression is not supported, then use RLE compression
+              and report a warning to user.
+            */
+            compression=RLECompression;
+            ThrowException(&image->exception,MissingDelegateError,ZipLibraryIsNotAvailable,image->filename);
+            break;
+          }
 #endif
-       default:
-         break;
-       }
+        default:
+          break;
+        }
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "%s compression.",
-                           CompressionTypeToString(compression));
+                            "%s compression.",
+                            CompressionTypeToString(compression));
 
       /*
         Scale image to size of Portable Document page.
@@ -1063,9 +1079,9 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
             FormatString(buffer,CFormat,"ASCII85Decode");
             break;
           }
-        case JPEGCompression: 
+        case JPEGCompression:
           {
-            FormatString(buffer,CFormat,"DCTDecode"); 
+            FormatString(buffer,CFormat,"DCTDecode");
             if (image->colorspace != CMYKColorspace)
               break;
             (void) WriteBlobString(image,buffer);
@@ -1084,29 +1100,29 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
           }
         case FaxCompression:
           {
-           char
-             CCITTParam[4];
-
-           ExceptionInfo
-             exception;
-
-           /*
-             Try compressing page to Group4 to see if it is
-             supported, otherwise we will fall back to Group3.
-           */
-           (void) strlcpy(CCITTParam,"0",sizeof(CCITTParam));
-           GetExceptionInfo(&exception);
-           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                 "Executing ImageToHuffman2DBlob for CCITT Fax4 ...");
-           fax_blob=ImageToHuffman2DBlob(image,image_info,&fax_blob_length,
-                                         &exception);
-           if (fax_blob != (unsigned char *) NULL)
-             {
-               (void) strlcpy(CCITTParam,"-1",sizeof(CCITTParam));
-               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                     "ImageToHuffman2DBlob reports success!");
-             }
-           DestroyExceptionInfo(&exception);
+            char
+              CCITTParam[4];
+
+            ExceptionInfo
+              exception;
+
+            /*
+              Try compressing page to Group4 to see if it is
+              supported, otherwise we will fall back to Group3.
+            */
+            (void) strlcpy(CCITTParam,"0",sizeof(CCITTParam));
+            GetExceptionInfo(&exception);
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Executing ImageToHuffman2DBlob for CCITT Fax4 ...");
+            fax_blob=ImageToHuffman2DBlob(image,image_info,&fax_blob_length,
+                                          &exception);
+            if (fax_blob != (unsigned char *) NULL)
+              {
+                (void) strlcpy(CCITTParam,"-1",sizeof(CCITTParam));
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "ImageToHuffman2DBlob reports success!");
+              }
+            DestroyExceptionInfo(&exception);
             (void) strlcpy(buffer,"/Filter [ /CCITTFaxDecode ]\n",sizeof(buffer));
             (void) WriteBlobString(image,buffer);
             (void) strlcpy(buffer,"/Interpolate false\n",sizeof(buffer));
@@ -1145,21 +1161,21 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
           ((image_info->type != TrueColorType) &&
            characteristics.grayscale))
         {
-         /*
-           Write grayscale output.
-         */
+          /*
+            Write grayscale output.
+          */
           switch (compression)
             {
             case FaxCompression:
               {
-               /*
-                 Try Group4 first and use Group3 as a fallback.
-               */
-               if (fax_blob != (unsigned char *) NULL)
-                 {
-                   (void) WriteBlob(image,fax_blob_length,fax_blob);
-                   MagickFreeMemory(fax_blob);
-                 }
+                /*
+                  Try Group4 first and use Group3 as a fallback.
+                */
+                if (fax_blob != (unsigned char *) NULL)
+                  {
+                    (void) WriteBlob(image,fax_blob_length,fax_blob);
+                    MagickFreeMemory(fax_blob);
+                  }
                 else
                   {
                     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -1178,9 +1194,9 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
                 /*
                   Write image in JPEG format.
                 */
-               jpeg_blob=ImageToJPEGBlob(image,image_info,&length,&image->exception);
+                jpeg_blob=ImageToJPEGBlob(image,image_info,&length,&image->exception);
                 if (jpeg_blob == (unsigned char *) NULL)
-                  ThrowWriterException2(CoderError,image->exception.reason,image);
+                  ThrowPDFWriterException2(CoderError,image->exception.reason,image);
                 (void) WriteBlob(image,length,jpeg_blob);
                 MagickFreeMemory(jpeg_blob);
                 break;
@@ -1194,8 +1210,8 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
                 length=number_pixels;
                 pixels=MagickAllocateMemory(unsigned char *,length);
                 if (pixels == (unsigned char *) NULL)
-                  ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,
-                                       image);
+                  ThrowPDFWriterException(ResourceLimitError,MemoryAllocationFailed,
+                                          image);
                 /*
                   Dump Runlength encoded pixels.
                 */
@@ -1218,7 +1234,7 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
                                                         &image->exception,
                                                         SaveImageText,
                                                         image->filename,
-                                                       image->columns,image->rows);
+                                                        image->columns,image->rows);
                           if (status == False)
                             break;
                         }
@@ -1236,7 +1252,8 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
                 if (!status)
                   {
                     CloseBlob(image);
-                    return(False);
+                    MagickFreeMemory(xref);
+                    return(MagickFail);
                   }
                 break;
               }
@@ -1265,7 +1282,7 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
                                                         &image->exception,
                                                         SaveImageText,
                                                         image->filename,
-                                                       image->columns,image->rows);
+                                                        image->columns,image->rows);
                           if (status == False)
                             break;
                         }
@@ -1288,9 +1305,9 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
                 /*
                   Write image in JPEG format.
                 */
-               jpeg_blob=ImageToJPEGBlob(image,image_info,&length,&image->exception);
+                jpeg_blob=ImageToJPEGBlob(image,image_info,&length,&image->exception);
                 if (jpeg_blob == (unsigned char *) NULL)
-                  ThrowWriterException2(CoderError,image->exception.reason,image);
+                  ThrowPDFWriterException2(CoderError,image->exception.reason,image);
                 (void) WriteBlob(image,length,jpeg_blob);
                 MagickFreeMemory(jpeg_blob);
                 break;
@@ -1304,8 +1321,8 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
                 length=(image->colorspace == CMYKColorspace ? 4 : 3)*number_pixels;
                 pixels=MagickAllocateMemory(unsigned char *,length);
                 if (pixels == (unsigned char *) NULL)
-                  ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,
-                                       image);
+                  ThrowPDFWriterException(ResourceLimitError,MemoryAllocationFailed,
+                                          image);
                 /*
                   Dump runoffset encoded pixels.
                 */
@@ -1340,7 +1357,7 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
                                                         &image->exception,
                                                         SaveImageText,
                                                         image->filename,
-                                                       image->columns,image->rows);
+                                                        image->columns,image->rows);
                           if (status == False)
                             break;
                         }
@@ -1397,7 +1414,7 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
                                                         &image->exception,
                                                         SaveImageText,
                                                         image->filename,
-                                                       image->columns,image->rows);
+                                                        image->columns,image->rows);
                           if (status == False)
                             break;
                         }
@@ -1422,7 +1439,7 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
                   length=number_pixels;
                   pixels=MagickAllocateMemory(unsigned char *,length);
                   if (pixels == (unsigned char *) NULL)
-                    ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+                    ThrowPDFWriterException(ResourceLimitError,MemoryAllocationFailed,image);
                   /*
                     Dump Runlength encoded pixels.
                   */
@@ -1443,7 +1460,7 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
                                                           &image->exception,
                                                           SaveImageText,
                                                           image->filename,
-                                                         image->columns,image->rows);
+                                                          image->columns,image->rows);
                             if (status == False)
                               break;
                           }
@@ -1487,7 +1504,7 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
                                                           &image->exception,
                                                           SaveImageText,
                                                           image->filename,
-                                                         image->columns,image->rows);
+                                                          image->columns,image->rows);
                             if (status == False)
                               break;
                           }
@@ -1593,7 +1610,7 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
       if (image->next == (Image *) NULL)
         break;
       image=SyncNextImageInList(image);
-      status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+      status=MagickMonitorFormatted(scene++,image_list_length,
                                     &image->exception,SaveImagesText,
                                     image->filename);
       if (status == False)
@@ -1631,7 +1648,7 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
   MagickFreeMemory(xref);
   CloseBlob(image);
   MagickFreeMemory(fax_blob);
-  return(True);
+  return(MagickPass);
 }
 \f
 #if defined(HasZLIB)
@@ -1673,10 +1690,11 @@ static unsigned int WritePDFImage(const ImageInfo *image_info,Image *image)
 %
 %
 */
+static voidpf ZLIBAllocFunc(voidpf opaque, uInt items, uInt size) MAGICK_FUNC_MALLOC;
 static voidpf ZLIBAllocFunc(voidpf opaque, uInt items, uInt size)
 {
   ARG_NOT_USED(opaque);
-  return MagickMallocCleared((size_t) items*size);
+  return MagickMallocCleared(MagickArraySize(items,size));
 }
 static void ZLIBFreeFunc(voidpf opaque, voidpf address)
 {
index cf634d6..12cc805 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -74,6 +74,9 @@
      pixmap.component_count <= 0 || pixmap.component_count > 4 ||      \
      pixmap.component_size <= 0))
 
+/*
+  Read a PICT rectangle
+*/
 #define ReadRectangle(rectangle)                                       \
   {                                                                    \
   rectangle.top=ReadBlobMSBShort(image);                               \
   rectangle.right=ReadBlobMSBShort(image);                             \
   }
 
+/*
+  Return true if PICT rectangle is valid.
+*/
 #define ValidateRectangle(rectangle) \
-  (!(EOFBlob(image) || \
-     (rectangle.top > rectangle.bottom || rectangle.left > rectangle.right)))
+  ((!EOFBlob(image) && \
+    (rectangle.bottom - rectangle.top > 0) && \
+    (rectangle.right - rectangle.left > 0)))
+
+/*
+  Issue a trace message with rectangle dimensions.
+*/
+#define TraceRectangle(image,rectangle)                         \
+  do                                                            \
+    {                                                           \
+      if (image->logging)                                       \
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),     \
+                              "%sRectangle: top %+d, bottom %+d, "        \
+                              "left %+d, right %+d",            \
+                              EOFBlob(image) ? "EOF! " : "",    \
+                              (int) frame.top,                  \
+                              (int) frame.bottom,               \
+                              (int) frame.left,                 \
+                              (int) frame.right);               \
+    } while(0)
+
 
 typedef struct _PICTCode
 {
@@ -408,8 +433,9 @@ static unsigned char *ExpandBuffer(unsigned char *pixels,
 }
 
 static unsigned char *DecodeImage(const ImageInfo *image_info,
-  Image *blob,Image *image,unsigned long bytes_per_line,
-  const unsigned int bits_per_pixel)
+                                  Image *blob,Image *image,
+                                  unsigned long bytes_per_line,
+                                  const unsigned int bits_per_pixel)
 {
   long
     j,
@@ -427,8 +453,8 @@ static unsigned char *DecodeImage(const ImageInfo *image_info,
     row_bytes;
 
   unsigned char
-    *pixels,
-    *scanline;
+    *pixels = NULL,
+    *scanline = NULL;
 
   unsigned long
     bytes_per_pixel,
@@ -437,13 +463,17 @@ static unsigned char *DecodeImage(const ImageInfo *image_info,
     scanline_length,
     width;
 
+  magick_off_t
+    file_size;
+
   ARG_NOT_USED(image_info);
 
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                          "DecodeImage: bytes_per_line=%lu,"
+                          "DecodeImage: %lux%lu, bytes_per_line=%lu,"
                           " bits_per_pixel=%u",
-                          bytes_per_line, bits_per_pixel);
+                          image->columns, image->rows, bytes_per_line,
+                          bits_per_pixel);
 
   /*
     Determine pixel buffer size.
@@ -472,34 +502,82 @@ static unsigned char *DecodeImage(const ImageInfo *image_info,
                           bytes_per_line,
                           (MAGICK_SIZE_T) row_bytes);
   /*
+    Validate allocation requests based on remaining file data
+  */
+  if ((file_size = GetBlobSize(blob)) > 0)
+    {
+      magick_off_t
+        remaining;
+
+      remaining=file_size-TellBlob(blob);
+
+      if (remaining <= 0)
+        {
+          ThrowException(&image->exception,CorruptImageError,InsufficientImageDataInFile,
+                         image->filename);
+          goto decode_error_exit;
+        }
+      else
+        {
+          double
+            ratio;
+
+          ratio = (((double) image->rows*bytes_per_line)/remaining);
+
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Remaining: %" MAGICK_OFF_F "d, Ratio: %g",
+                                remaining, ratio);
+
+          if (ratio > (bytes_per_line < 8 ? 1.0 : 255.0))
+            {
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Unreasonable file size "
+                                    "(ratio of pixels to remaining file size %g)",
+                                    ratio);
+              ThrowException(&image->exception,CorruptImageError,InsufficientImageDataInFile,
+                             image->filename);
+              goto decode_error_exit;
+            }
+        }
+    }
+
+  /*
     Allocate pixel and scanline buffer.
   */
   pixels=MagickAllocateArray(unsigned char *,image->rows,row_bytes);
   if (pixels == (unsigned char *) NULL)
-    return((unsigned char *) NULL);
+    {
+      ThrowException(&image->exception,ResourceLimitError,MemoryAllocationFailed,
+                     image->filename);
+      goto decode_error_exit;
+    }
   allocated_pixels=image->rows*row_bytes;
   (void) memset(pixels,0,allocated_pixels);
   scanline=MagickAllocateMemory(unsigned char *,row_bytes);
   if (scanline == (unsigned char *) NULL)
-    return((unsigned char *) NULL);
+    {
+      ThrowException(&image->exception,ResourceLimitError,MemoryAllocationFailed,
+                     image->filename);
+      goto decode_error_exit;
+    }
   if (bytes_per_line < 8)
     {
       /*
         Pixels are already uncompressed.
       */
       for (y=0; y < (long) image->rows; y++)
-      {
-        q=pixels+y*width;
-        number_pixels=bytes_per_line;
-        if (ReadBlob(blob,number_pixels,(char *) scanline) != number_pixels)
-          {
-            ThrowException(&image->exception,CorruptImageError,UnexpectedEndOfFile,
-                           image->filename);
-            goto decode_error_exit;
-          }
-        p=ExpandBuffer(scanline,&number_pixels,bits_per_pixel);
-        (void) memcpy(q,p,number_pixels);
-      }
+        {
+          q=pixels+y*width;
+          number_pixels=bytes_per_line;
+          if (ReadBlob(blob,number_pixels,(char *) scanline) != number_pixels)
+            {
+              ThrowException(&image->exception,CorruptImageError,UnexpectedEndOfFile,
+                             image->filename);
+              goto decode_error_exit;
+            }
+          p=ExpandBuffer(scanline,&number_pixels,bits_per_pixel);
+          (void) memcpy(q,p,number_pixels);
+        }
       MagickFreeMemory(scanline);
       return(pixels);
     }
@@ -507,66 +585,68 @@ static unsigned char *DecodeImage(const ImageInfo *image_info,
     Uncompress RLE pixels into uncompressed pixel buffer.
   */
   for (y=0; y < (long) image->rows; y++)
-  {
-    q=pixels+y*width;
-    if (bytes_per_line > 200)
-      scanline_length=ReadBlobMSBShort(blob);
-    else
-      scanline_length=ReadBlobByte(blob);
-    if (scanline_length >= row_bytes)
-      {
-        ThrowException(&image->exception,CorruptImageError,UnableToUncompressImage,
-                       "scanline length exceeds row bytes");
-        goto decode_error_exit;
-      }
-    if (ReadBlob(blob,scanline_length,(char *) scanline) != scanline_length)
-      {
-        ThrowException(&image->exception,CorruptImageError,UnexpectedEndOfFile,
-                       image->filename);
-        goto decode_error_exit;
-      }
-    for (j=0; j < (long) scanline_length; )
-      if ((scanline[j] & 0x80) == 0)
+    {
+      q=pixels+y*width;
+      if (bytes_per_line > 200)
+        scanline_length=ReadBlobMSBShort(blob);
+      else
+        scanline_length=ReadBlobByte(blob);
+      if (scanline_length >= row_bytes)
         {
-          length=(scanline[j] & 0xff)+1;
-          number_pixels=length*bytes_per_pixel;
-          p=ExpandBuffer(scanline+j+1,&number_pixels,bits_per_pixel);
-          if (j+number_pixels >= scanline_length)
-            {
-              ThrowException(&image->exception,CorruptImageError,UnableToUncompressImage,
-                             "Decoded RLE pixels exceeds allocation!");
-              goto decode_error_exit;
-            }
-          if ((q+number_pixels > pixels+allocated_pixels))
-            {
-              ThrowException(&image->exception,CorruptImageError,UnableToUncompressImage,
-                             "Decoded RLE pixels exceeds allocation!");
-              goto decode_error_exit;
-            }
-
-          (void) memcpy(q,p,number_pixels); /* ASAN report */
-          q+=number_pixels;
-          j+=length*bytes_per_pixel+1;
+          ThrowException(&image->exception,CorruptImageError,UnableToUncompressImage,
+                         "scanline length exceeds row bytes");
+          goto decode_error_exit;
         }
-      else
+      if (ReadBlob(blob,scanline_length,(char *) scanline) != scanline_length)
         {
-          length=((scanline[j]^0xff) & 0xff)+2;
-          number_pixels=bytes_per_pixel;
-          p=ExpandBuffer(scanline+j+1,&number_pixels,bits_per_pixel);
-          for (i=0; i < (long) length; i++)
+          ThrowException(&image->exception,CorruptImageError,UnexpectedEndOfFile,
+                         image->filename);
+          goto decode_error_exit;
+        }
+      (void) memset(scanline+scanline_length,0,row_bytes-scanline_length); /* Zero */
+      for (j=0; j < (long) scanline_length; )
+        if ((scanline[j] & 0x80) == 0)
           {
-          if ((q+number_pixels > pixels+allocated_pixels))
-            {
-              ThrowException(&image->exception,CorruptImageError,UnableToUncompressImage,
-                             "Decoded RLE pixels exceeds allocation!");
-              goto decode_error_exit;
-            }
-            (void) memcpy(q,p,number_pixels);
+            length=(scanline[j] & 0xff)+1;
+            number_pixels=length*bytes_per_pixel;
+            p=ExpandBuffer(scanline+j+1,&number_pixels,bits_per_pixel);
+            if (j+number_pixels >= scanline_length)
+              {
+                errno=0;
+                ThrowException(&image->exception,CorruptImageError,UnableToUncompressImage,
+                               "Decoded RLE pixels exceeds allocation!");
+                goto decode_error_exit;
+              }
+            if ((q+number_pixels > pixels+allocated_pixels))
+              {
+                ThrowException(&image->exception,CorruptImageError,UnableToUncompressImage,
+                               "Decoded RLE pixels exceeds allocation!");
+                goto decode_error_exit;
+              }
+
+            (void) memcpy(q,p,number_pixels); /* ASAN report */
             q+=number_pixels;
+            j+=length*bytes_per_pixel+1;
           }
-          j+=bytes_per_pixel+1;
-        }
-  }
+        else
+          {
+            length=((scanline[j]^0xff) & 0xff)+2;
+            number_pixels=bytes_per_pixel;
+            p=ExpandBuffer(scanline+j+1,&number_pixels,bits_per_pixel);
+            for (i=0; i < (long) length; i++)
+              {
+                if ((q+number_pixels > pixels+allocated_pixels))
+                  {
+                    ThrowException(&image->exception,CorruptImageError,UnableToUncompressImage,
+                                   "Decoded RLE pixels exceeds allocation!");
+                    goto decode_error_exit;
+                  }
+                (void) memcpy(q,p,number_pixels);
+                q+=number_pixels;
+              }
+            j+=bytes_per_pixel+1;
+          }
+    }
   MagickFreeMemory(scanline);
   return(pixels);
 
@@ -774,6 +854,8 @@ static size_t EncodeImage(Image *image,const unsigned char *scanline,
 { \
   if (clone_info) \
     DestroyImageInfo(clone_info); \
+  if (tile_image) \
+    DestroyImage(tile_image); \
   ThrowReaderException(code_,reason_,image_); \
 }
 
@@ -784,7 +866,8 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
     geometry[MaxTextExtent];
 
   Image
-    *image;
+    *image = (Image *) NULL,
+    *tile_image = (Image *) NULL;
 
   ImageInfo
     *clone_info = (ImageInfo *) NULL;
@@ -851,6 +934,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
     (void) ReadBlobByte(image);  /* skip header */
   (void) ReadBlobMSBShort(image);  /* skip picture size */
   ReadRectangle(frame);
+  TraceRectangle(image,frame);
   if (!ValidateRectangle(frame))
     ThrowPICTReaderException(CorruptImageError,ImproperImageHeader,image);
   while ((c=ReadBlobByte(image)) == 0);
@@ -881,6 +965,11 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
   flags=0;
   image->columns=frame.right-frame.left;
   image->rows=frame.bottom-frame.top;
+  SetRedSample(&image->background_color,0);
+  SetGreenSample(&image->background_color,0);
+  SetBlueSample(&image->background_color,0);
+  SetOpacitySample(&image->background_color,OpaqueOpacity);
+  SetImage(image,OpaqueOpacity);
 
   if (IsEventLogging())
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -927,10 +1016,12 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
             if (length != 0x000a)
               {
                 for (i=0; i < (long) (length-2); i++)
-                  (void) ReadBlobByte(image);
+                  if (ReadBlobByte(image) == EOF)
+                    break;
                 break;
               }
             ReadRectangle(frame);
+            TraceRectangle(image,frame);
             if (!ValidateRectangle(frame))
               ThrowPICTReaderException(CorruptImageError,ImproperImageHeader,image);
             if ((frame.left & 0x8000) || (frame.top & 0x8000))
@@ -970,6 +1061,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
                 image);
             length=ReadBlobMSBShort(image);
             ReadRectangle(frame);
+            TraceRectangle(image,frame);
             if (!ValidateRectangle(frame))
               ThrowPICTReaderException(CorruptImageError,ImproperImageHeader,image);
             ReadPixmap(pixmap);
@@ -994,16 +1086,29 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
             if (length < 8)
               {
                 for (i=0; i < (long) (length*height); i++)
-                  (void) ReadBlobByte(image);
+                  if (ReadBlobByte(image) == EOF)
+                    break;
               }
             else
-              for (j=0; j < (int) height; j++)
-                if (length > 200)
-                  for (j=0; j < ReadBlobMSBShort(image); j++)
-                    (void) ReadBlobByte(image);
-                else
-                  for (j=0; j < ReadBlobByte(image); j++)
-                    (void) ReadBlobByte(image);
+              {
+                for (j=0; j < (int) height; j++)
+                  {
+                    if (EOFBlob(image))
+                      break;
+                    if (length > 200)
+                      {
+                        for (j=0; j < ReadBlobMSBShort(image); j++)
+                          if (ReadBlobByte(image) == EOF)
+                            break;
+                      }
+                    else
+                      {
+                        for (j=0; j < ReadBlobByte(image); j++)
+                          if (ReadBlobByte(image) == EOF)
+                            break;
+                      }
+                  }
+              }
             break;
           }
           case 0x1b:
@@ -1033,7 +1138,8 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
             */
             length=ReadBlobMSBShort(image);
             for (i=0; i < (long) (length-2); i++)
-              (void) ReadBlobByte(image);
+              if (ReadBlobByte(image) == EOF)
+                break;
             break;
           }
           case 0x90:
@@ -1059,9 +1165,6 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
             unsigned char
               *pixels;
 
-            Image
-              *tile_image;
-
             /*
               Pixmap clipped by a rectangle.
             */
@@ -1075,6 +1178,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
                 (void) ReadBlobMSBShort(image);
               }
             ReadRectangle(frame);
+            TraceRectangle(image,frame);
             if (!ValidateRectangle(frame))
               ThrowPICTReaderException(CorruptImageError,ImproperImageHeader,image);
             /*
@@ -1083,7 +1187,10 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
             tile_image=CloneImage(image,frame.right-frame.left,
               frame.bottom-frame.top,True,exception);
             if (tile_image == (Image *) NULL)
-              return((Image *) NULL);
+              {
+                DestroyImage(image);
+                return((Image *) NULL);
+              }
             DestroyBlob(tile_image);
             tile_image->blob=CloneBlobInfo((BlobInfo *) NULL);
             if ((code == 0x9a) || (code == 0x9b) || (bytes_per_line & 0x8000))
@@ -1106,10 +1213,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
                     tile_image->colors=ReadBlobMSBShort(image)+1;
                   }
                 if (!AllocateImageColormap(tile_image,tile_image->colors))
-                  {
-                    DestroyImage(tile_image);
-                    ThrowPICTReaderException(ResourceLimitError,MemoryAllocationFailed,image)
-                  }
+                  ThrowPICTReaderException(ResourceLimitError,MemoryAllocationFailed,image)
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                   "Allocated tile image colormap with %u colors",tile_image->colors);
                 if (bytes_per_line & 0x8000)
@@ -1125,6 +1229,8 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
                         ScaleShortToQuantum(ReadBlobMSBShort(image));
                       tile_image->colormap[j].blue=(Quantum)
                         ScaleShortToQuantum(ReadBlobMSBShort(image));
+                      if (EOFBlob(image))
+                        break;
                     }
                   }
                 else
@@ -1140,10 +1246,14 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
                     }
                   }
               }
+            if (EOFBlob(image))
+              ThrowPICTReaderException(CorruptImageError,UnexpectedEndOfFile,image);
             ReadRectangle(source);
+            TraceRectangle(image,source);
             if (!ValidateRectangle(source))
               ThrowPICTReaderException(CorruptImageError,ImproperImageHeader,image);
             ReadRectangle(destination);
+            TraceRectangle(image,destination);
             if (!ValidateRectangle(destination))
               ThrowPICTReaderException(CorruptImageError,ImproperImageHeader,image);
             (void) ReadBlobMSBShort(image);
@@ -1154,8 +1264,11 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
                 */
                 length=ReadBlobMSBShort(image);
                 for (i=0; i <= (long) (length-2); i++)
-                  (void) ReadBlobByte(image);
+                  if (ReadBlobByte(image) == EOF)
+                    break;
               }
+            if (CheckImagePixelLimits(tile_image, exception) != MagickPass)
+              ThrowPICTReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
             if ((code != 0x9a) && (code != 0x9b) &&
                 (bytes_per_line & 0x8000) == 0)
               pixels=DecodeImage(image_info,image,tile_image,bytes_per_line,1);
@@ -1165,7 +1278,6 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
             if (pixels == (unsigned char *) NULL)
               {
                 CopyException(exception, &tile_image->exception);
-                DestroyImage(tile_image);
                 ThrowPICTReaderException(ResourceLimitError,MemoryAllocationFailed,image)
               }
             /*
@@ -1174,7 +1286,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
             p=pixels;
             for (y=0; y < (long) tile_image->rows; y++)
             {
-              q=SetImagePixels(tile_image,0,y,tile_image->columns,1);
+              q=SetImagePixelsEx(tile_image,0,y,tile_image->columns,1,&image->exception);
               if (q == (PixelPacket *) NULL)
                 break;
               indexes=AccessMutableIndexes(tile_image);
@@ -1221,7 +1333,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
                 p++;
                 q++;
               }
-              if (!SyncImagePixels(tile_image))
+              if (!SyncImagePixelsEx(tile_image,&image->exception))
                 break;
               if ((tile_image->storage_class == DirectClass) &&
                   (pixmap.bits_per_pixel != 16))
@@ -1230,20 +1342,29 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
                 if (QuantumTick(y,tile_image->rows))
                   if (!MagickMonitorFormatted(y,tile_image->rows,&image->exception,
                                               LoadImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
             }
             MagickFreeMemory(pixels);
-            if (jpeg == False)
+            if (tile_image->exception.severity > image->exception.severity)
+              CopyException(&image->exception,&tile_image->exception);
+            if ((tile_image->exception.severity < ErrorException) && (jpeg == False))
               if ((code == 0x9a) || (code == 0x9b) ||
                   (bytes_per_line & 0x8000))
-                (void) CompositeImage(image,CopyCompositeOp,tile_image,
-                                      destination.left,destination.top);
+                {
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                        "Composite tile: %lux%lu%+d%+d",
+                                        tile_image->columns, tile_image->rows,
+                                        destination.left, destination.top);
+                  (void) CompositeImage(image,CopyCompositeOp,tile_image,
+                                        destination.left,destination.top);
+                }
             DestroyImage(tile_image);
+            tile_image=(Image *) NULL;
             if (destination.bottom != (long) image->rows)
               if (!MagickMonitorFormatted(destination.bottom,image->rows,&image->exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
             break;
           }
@@ -1263,7 +1384,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
             if (length == 0)
               break;
             (void) ReadBlobMSBLong(image);
-            length-=4;
+            length-=Min(4,length);
             if (length == 0)
               break;
             info=MagickAllocateMemory(unsigned char *,length);
@@ -1305,7 +1426,8 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
               (void) ReadBlobMSBShort(image);
             else
               for (i=0; i < (long) codes[code].length; i++)
-                (void) ReadBlobByte(image);
+                if (ReadBlobByte(image) == EOF)
+                  break;
           }
         }
       }
@@ -1315,7 +1437,8 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
           Skip header.
         */
         for (i=0; i < 24; i++)
-          (void) ReadBlobByte(image);
+          if (ReadBlobByte(image) == EOF)
+            break;
         continue;
       }
     if (((code >= 0xb0) && (code <= 0xcf)) ||
@@ -1326,8 +1449,8 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
         FILE
           *file;
 
-        Image
-          *tile_image;
+        char
+          tmpfile[MaxTextExtent];
 
         /*
           Embedded JPEG.
@@ -1336,18 +1459,21 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
         clone_info=CloneImageInfo(image_info);
         clone_info->blob=(void *) NULL;
         clone_info->length=0;
-        file=AcquireTemporaryFileStream(clone_info->filename,BinaryFileIOMode);
+        file=AcquireTemporaryFileStream(tmpfile,BinaryFileIOMode);
         if (file == (FILE *) NULL)
           {
             DestroyImageInfo(clone_info);
-            ThrowReaderTemporaryFileException(clone_info->filename);
+            ThrowReaderTemporaryFileException(image_info->filename);
           }
+        (void) strlcpy(clone_info->filename,"JPEG:",sizeof(clone_info->filename));
+        (void) strlcat(clone_info->filename,tmpfile,sizeof(clone_info->filename));
         length=ReadBlobMSBLong(image);
         if (length > 154)
           {
             for (i=0; i < 6; i++)
               (void) ReadBlobMSBLong(image);
             ReadRectangle(frame);
+            TraceRectangle(image,frame);
             if (!ValidateRectangle(frame))
               {
                 (void) fclose(file);
@@ -1377,6 +1503,7 @@ static Image *ReadPICTImage(const ImageInfo *image_info,
           frame.right);
         image->compression=tile_image->compression;
         DestroyImage(tile_image);
+        tile_image=(Image *) NULL;
         continue;
       }
     if ((code == 0xff) || (code == 0xffff))
@@ -1560,7 +1687,7 @@ static unsigned int WritePICTImage(const ImageInfo *image_info,Image *image)
 
   const unsigned char
     *profile_info;
-  
+
   size_t
     profile_length;
 
@@ -1619,7 +1746,7 @@ static unsigned int WritePICTImage(const ImageInfo *image_info,Image *image)
   source_rectangle=size_rectangle;
   destination_rectangle=size_rectangle;
   base_address=0xff;
-  row_bytes=image->columns;
+  row_bytes=(size_t) image->columns;
   bounds.top=0;
   bounds.left=0;
   bounds.bottom=(short) image->rows;
@@ -1647,18 +1774,21 @@ static unsigned int WritePICTImage(const ImageInfo *image_info,Image *image)
       pixmap.bits_per_pixel=32;
       pixmap.pack_type=0x04;
       transfer_mode=0x40;
-      row_bytes=4*image->columns;
+      row_bytes=MagickArraySize(4,(size_t) image->columns);
+      if (row_bytes == 0)
+        ThrowPICTWriterException(ResourceLimitError,MemoryAllocationFailed,image);
     }
   /*
     Allocate memory.
   */
-  bytes_per_line=image->columns;
+  bytes_per_line=(size_t) image->columns;
   if (storage_class == DirectClass)
-    bytes_per_line*=image->matte ? 4 : 3;
+    bytes_per_line = MagickArraySize(bytes_per_line, image->matte ? 4 : 3);
   buffer=MagickAllocateMemory(unsigned char *,PictInfoSize);
   packed_scanline=MagickAllocateMemory(unsigned char *,row_bytes+MaxCount);
   scanline=MagickAllocateMemory(unsigned char *,row_bytes);
-  if ((buffer == (unsigned char *) NULL) ||
+  if ((bytes_per_line == 0) ||
+      (buffer == (unsigned char *) NULL) ||
       (packed_scanline == (unsigned char *) NULL) ||
       (scanline == (unsigned char *) NULL))
     ThrowPICTWriterException(ResourceLimitError,MemoryAllocationFailed,image);
@@ -1892,7 +2022,7 @@ static unsigned int WritePICTImage(const ImageInfo *image_info,Image *image)
       if (QuantumTick(y,image->rows))
         if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                     SaveImageText,image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
     }
   else
@@ -1942,7 +2072,7 @@ static unsigned int WritePICTImage(const ImageInfo *image_info,Image *image)
           if (QuantumTick(y,image->rows))
             if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                         SaveImageText,image->filename,
-                                       image->columns,image->rows))
+                                        image->columns,image->rows))
               break;
         }
       }
index a4b99d2..c65cc15 100644 (file)
@@ -99,13 +99,17 @@ static Image *ReadPIXImage(const ImageInfo *image_info,ExceptionInfo *exception)
   register PixelPacket
     *q;
 
-  unsigned int
+  int
+    length;
+
+  MagickPassFail
     status;
 
+  unsigned int
+    bits_per_pixel;
+
   unsigned long
-    bits_per_pixel,
     height,
-    length,
     width;
 
   /*
@@ -117,7 +121,7 @@ static Image *ReadPIXImage(const ImageInfo *image_info,ExceptionInfo *exception)
   assert(exception->signature == MagickSignature);
   image=AllocateImage(image_info);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
-  if (status == False)
+  if (status == MagickFail)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
   /*
     Read PIX image.
@@ -164,9 +168,12 @@ static Image *ReadPIXImage(const ImageInfo *image_info,ExceptionInfo *exception)
       indexes=AccessMutableIndexes(image);
       for (x=0; x < (long) image->columns; x++)
       {
-        if (length == 0)
+        if (length <= 0)
           {
-            length=ReadBlobByte(image);
+            if ((length=ReadBlobByte(image)) == EOF)
+              break;
+            if (length == 0)
+              ThrowReaderException(CorruptImageError,UnableToRunlengthDecodeImage,image);
             if (bits_per_pixel == 8)
               index=ScaleCharToQuantum(ReadBlobByte(image));
             else
@@ -177,29 +184,30 @@ static Image *ReadPIXImage(const ImageInfo *image_info,ExceptionInfo *exception)
               }
           }
         if (image->storage_class == PseudoClass)
-          indexes[x]=index;
+          {
+            VerifyColormapIndex(image,index);
+            indexes[x]=index;
+          }
         q->blue=blue;
         q->green=green;
         q->red=red;
         length--;
         q++;
       }
+      if (EOFBlob(image))
+        break;
       if (!SyncImagePixels(image))
         break;
       if (image->previous == (Image *) NULL)
         if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                     image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
     }
+    if (EOFBlob(image))
+      ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
     if (image->storage_class == PseudoClass)
       (void) SyncImage(image);
-    if (EOFBlob(image))
-      {
-        ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
-          image->filename);
-        break;
-      }
     /*
       Proceed to next image.
     */
@@ -213,7 +221,7 @@ static Image *ReadPIXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     bits_per_pixel=ReadBlobMSBShort(image);
     status=(!EOFBlob(image)) && (width != 0U) && (height != 0U) &&
       ((bits_per_pixel == 8) || (bits_per_pixel == 24));
-    if (status == True)
+    if (status == MagickPass)
       {
         /*
           Allocate next image structure.
@@ -229,7 +237,7 @@ static Image *ReadPIXImage(const ImageInfo *image_info,ExceptionInfo *exception)
                                     LoadImagesText,image->filename))
           break;
       }
-  } while (status == True);
+  } while (status == MagickPass);
   while (image->previous != (Image *) NULL)
     image=image->previous;
   CloseBlob(image);
index 4d1ba7f..cd3cdc5 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2009 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -212,7 +212,7 @@ ModuleExport void RegisterPLASMAImage(void)
   entry->adjoin=False;
   entry->description="Plasma fractal image";
   entry->module="PLASMA";
-  entry->coder_class=PrimaryCoderClass;
+  entry->coder_class=StableCoderClass;
   entry->extension_treatment=IgnoreExtensionTreatment;
   (void) RegisterMagickInfo(entry);
 
@@ -221,7 +221,7 @@ ModuleExport void RegisterPLASMAImage(void)
   entry->adjoin=False;
   entry->description="Plasma fractal image";
   entry->module="PLASMA";
-  entry->coder_class=PrimaryCoderClass;
+  entry->coder_class=StableCoderClass;
   entry->extension_treatment=IgnoreExtensionTreatment;
   (void) RegisterMagickInfo(entry);
 }
index 37de9fc..ba2ea76 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2017 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
   Optional declarations. Define or undefine them as you like.
 */
 
-/* After eXIf chunk has been approved:
-#define eXIf_SUPPORTED
-*/
-
-/* Experimental; define one or both of these:
-#define exIf_SUPPORTED
-*/
-
 /* #define PNG_DEBUG -- turning this on breaks VisualC compiling */
 
 /*
@@ -215,14 +207,7 @@ static png_byte const mng_TERM[5]={ 84,  69,  82,  77, '\0'};
 static png_byte const mng_bKGD[5]={ 98,  75,  71,  68, '\0'};
 static png_byte const mng_caNv[5]={ 99,  97,  78, 118, '\0'};
 static png_byte const mng_cHRM[5]={ 99,  72,  82,  77, '\0'};
-#ifdef exIf_SUPPORTED
-/* until registration of eXIf */
-static png_byte const mng_exIf[5]={101, 120,  73, 102, '\0'};
-#endif
-#ifdef eXIf_SUPPORTED
-/* after registration of eXIf */
 static png_byte const mng_eXIf[5]={101,  88,  73, 102, '\0'};
-#endif
 static png_byte const mng_gAMA[5]={103,  65,  77,  65, '\0'};
 static png_byte const mng_iCCP[5]={105,  67,  67,  80, '\0'};
 static png_byte const mng_nEED[5]={110,  69,  69,  68, '\0'};
@@ -681,12 +666,12 @@ static void PNGType(png_bytep p,png_byte const * type)
   (void) memcpy(p,type,4*sizeof(png_byte));
 }
 
-static void LogPNGChunk(int logging, png_byte const * type, unsigned long length)
+static void LogPNGChunk(int logging, png_byte const * type, size_t length)
 {
   if (logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-        "  Writing %c%c%c%c chunk, length: %lu",
-        type[0],type[1],type[2],type[3],length);
+        "  Writing %c%c%c%c chunk, length: %" MAGICK_SIZE_T_F "u",
+        type[0],type[1],type[2],type[3],(MAGICK_SIZE_T) length);
 }
 #endif /* PNG_LIBPNG_VER > 10011 */
 
@@ -805,7 +790,7 @@ static void png_get_data(png_structp png_ptr,png_bytep data,png_size_t length)
     {
       png_size_t
         check;
-    
+
       if (length > 0x7fffffff)
         png_warning(png_ptr, "chunk length > 2G");
       check=(png_size_t) ReadBlob(image,(size_t) length,(char *) data);
@@ -813,7 +798,7 @@ static void png_get_data(png_structp png_ptr,png_bytep data,png_size_t length)
         {
           char
             msg[MaxTextExtent];
-        
+
             (void) sprintf(msg,"Expected %lu bytes; found %lu bytes",
                            (unsigned long) length,(unsigned long) check);
           png_warning(png_ptr,msg);
@@ -868,6 +853,8 @@ static void mng_get_data(png_structp png_ptr,png_bytep data,png_size_t length)
             {
               check=(png_size_t) ReadBlob(image,(size_t) length,
                                           (char *) mng_info->read_buffer);
+              if (check != length)
+                png_error(png_ptr,"Read Exception");
               mng_info->read_buffer[4]=0;
               mng_info->bytes_in_read_buffer=4;
               if (!memcmp(mng_info->read_buffer,mng_PLTE,4))
@@ -883,6 +870,8 @@ static void mng_get_data(png_structp png_ptr,png_bytep data,png_size_t length)
             {
               check=(png_size_t) ReadBlob(image,(size_t) length,
                                           (char *) mng_info->read_buffer);
+              if (check != length)
+                png_error(png_ptr,"Read Exception");
               mng_info->read_buffer[4]=0;
               mng_info->bytes_in_read_buffer=4;
               if (!memcmp(mng_info->read_buffer,mng_bKGD,4))
@@ -893,9 +882,13 @@ static void mng_get_data(png_structp png_ptr,png_bytep data,png_size_t length)
                     */
                     check=(png_size_t)
                       ReadBlob(image,5,(char *) mng_info->read_buffer);
+                    if (check != 5)
+                      png_error(png_ptr,"Read Exception");
                     check=(png_size_t) ReadBlob(image,(size_t) length,
                                                 (char *)
                                                 mng_info->read_buffer);
+                    if (check != length)
+                      png_error(png_ptr,"Read Exception");
                     mng_info->saved_bkgd_index=mng_info->read_buffer[0];
                     mng_info->have_saved_bkgd_index=MagickTrue;
                     mng_info->bytes_in_read_buffer=0;
@@ -916,7 +909,7 @@ static void png_put_data(png_structp png_ptr,png_bytep data,png_size_t length)
     {
       png_size_t
         check;
-    
+
       check=(png_size_t) WriteBlob(image,(unsigned long) length,(char *) data);
       if (check != length)
         png_error(png_ptr,"WriteBlob Failed");
@@ -973,7 +966,10 @@ static void MngInfoDiscardObject(MngInfo *mng_info,int i)
           if (mng_info->ob[i]->reference_count == 0)
             {
               if (mng_info->ob[i]->image != (Image *) NULL)
-                DestroyImage(mng_info->ob[i]->image);
+                {
+                  DestroyImage(mng_info->ob[i]->image);
+                  mng_info->ob[i]->image=(Image *) NULL;
+                }
               MagickFreeMemory(mng_info->ob[i]);
             }
         }
@@ -998,9 +994,10 @@ static void MngInfoFreeStruct(MngInfo *mng_info,int *have_mng_structure)
     {
       register long
         i;
-    
+
       for (i=1; i < MNG_MAX_OBJECTS; i++)
         MngInfoDiscardObject(mng_info,i);
+      mng_info->image=(Image *)NULL;
       MagickFreeMemory(mng_info->global_plte);
       MagickFreeMemory(mng_info);
       *have_mng_structure=MagickFalse;
@@ -1024,6 +1021,14 @@ static MngBox mng_minimum_box(MngBox box1,MngBox box2)
   return box;
 }
 
+static long mng_get_long(unsigned char *p)
+{
+  return ((long) (((magick_uint32_t) p[0] << 24) |
+                  ((magick_uint32_t) p[1] << 16) |
+                  ((magick_uint32_t) p[2] <<  8) |
+                  (magick_uint32_t)  p[3]));
+}
+
 static MngBox mng_read_box(MngBox previous_box,char delta_type,
                            unsigned char *p)
 {
@@ -1033,10 +1038,10 @@ static MngBox mng_read_box(MngBox previous_box,char delta_type,
   /*
     Read clipping boundaries from DEFI, CLIP, FRAM, or PAST chunk.
   */
-  box.left=(long) ((p[0]  << 24) | (p[1]  << 16) | (p[2]  << 8) | p[3]);
-  box.right=(long) ((p[4]  << 24) | (p[5]  << 16) | (p[6]  << 8) | p[7]);
-  box.top=(long) ((p[8]  << 24) | (p[9]  << 16) | (p[10] << 8) | p[11]);
-  box.bottom=(long) ((p[12] << 24) | (p[13] << 16) | (p[14] << 8) | p[15]);
+  box.left  = mng_get_long(p);
+  box.right = mng_get_long(&p[4]);
+  box.top   = mng_get_long(&p[8]);
+  box.bottom= mng_get_long(&p[12]);
   if (delta_type != 0)
     {
       box.left+=previous_box.left;
@@ -1055,8 +1060,9 @@ static MngPair mng_read_pair(MngPair previous_pair,int delta_type,
   /*
     Read two longs from CLON, MOVE or PAST chunk
   */
-  pair.a=(long) ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
-  pair.b=(long) ((p[4] << 24) | (p[5] << 16) | (p[6] << 8) | p[7]);
+  pair.a= mng_get_long(p);
+  pair.b= mng_get_long(&p[4]);
+
   if (delta_type != 0)
     {
       pair.a+=previous_pair.a;
@@ -1065,11 +1071,6 @@ static MngPair mng_read_pair(MngPair previous_pair,int delta_type,
   return(pair);
 }
 
-static long mng_get_long(unsigned char *p)
-{
-  return((long) ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]));
-}
-
 static void PNGErrorHandler(png_struct *ping,png_const_charp message) MAGICK_FUNC_NORETURN;
 
 static void PNGErrorHandler(png_struct *ping,png_const_charp message)
@@ -1119,11 +1120,11 @@ static png_voidp png_IM_malloc(png_structp png_ptr,png_size_t size)
 /*
   Free a pointer.  It is removed from the list at the same time.
 */
-static png_free_ptr png_IM_free(png_structp png_ptr,png_voidp ptr)
+static void png_IM_free(png_structp png_ptr,png_voidp ptr)
 {
   (void) png_ptr;
   MagickFreeMemory(ptr);
-  return((png_free_ptr) NULL);
+  return;
 }
 #endif
 
@@ -1133,7 +1134,7 @@ static png_free_ptr png_IM_free(png_structp png_ptr,png_voidp ptr)
 
 static MagickPassFail
 png_read_raw_profile(Image *image, const ImageInfo *image_info,
-                     png_textp text,int ii)
+                     png_textp text,long ii,ExceptionInfo *exception)
 {
   char
     profile_description[MaxTextExtent],
@@ -1151,11 +1152,14 @@ png_read_raw_profile(Image *image, const ImageInfo *image_info,
   register png_charp
     sp;
 
+  png_charp
+    ep;
+
   png_uint_32
     length,
     nibbles;
 
-  unsigned char
+  static const unsigned char
     unhex[103]={0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,
                 0,0,0,0,0,0,0,0,0,1, 2,3,4,5,6,7,8,9,0,0,
@@ -1163,28 +1167,58 @@ png_read_raw_profile(Image *image, const ImageInfo *image_info,
                 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,10,11,12,
                 13,14,15};
 
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "    Read raw profile[%ld]",ii);
+
   sp=text[ii].text+1;
+  ep=text[ii].text+text[ii].text_length;
   /* look for newline */
-  while (*sp != '\n')
+  while ((sp < ep) && (*sp != '\n'))
     sp++;
+  if (sp == ep)
+    {
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "    Failed to find new-line in raw profile");
+      ThrowException(exception,CorruptImageWarning,UnableToParseEmbeddedProfile,image->filename);
+      return MagickFail;
+    }
   /* look for length */
-  while (*sp == '\0' || *sp == ' ' || *sp == '\n')
+  while ((sp < ep) && (*sp == '\0' || *sp == ' ' || *sp == '\n'))
     sp++;
+  if (sp == ep)
+    {
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "    Failed to find raw profile length!");
+      ThrowException(exception,CorruptImageWarning,UnableToParseEmbeddedProfile,image->filename);
+      return MagickFail;
+    }
   length=MagickAtoL(sp);
-  while (*sp != ' ' && *sp != '\n')
+  while ((sp < ep) && (*sp != ' ' && *sp != '\n'))
     sp++;
+  if (sp == ep)
+    {
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "    End of text while looking for start of hex-encoded profile");
+      ThrowException(exception,CorruptImageWarning,UnableToParseEmbeddedProfile,image->filename);
+      return MagickFail;
+    }
   /* allocate space */
-  if (length == 0)
+  if ((length == 0) || (length*2 + sp >= ep))
     {
-      (void) ThrowException2(&image->exception,CoderWarning,
-                             "invalid profile length",(char *) NULL);
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+          "invalid profile length");
+      ThrowException(exception,CorruptImageWarning,UnableToParseEmbeddedProfile,image->filename);
       return (MagickFail);
     }
   info=MagickAllocateMemory(unsigned char *,length);
   if (info == (unsigned char *) NULL)
     {
-      (void) ThrowException2(&image->exception,CoderWarning,
-                             "unable to copy profile",(char *) NULL);
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+          "Unable to copy profile");
       return (MagickFail);
     }
   /* copy profile, skipping white space and column 1 "=" signs */
@@ -1197,8 +1231,8 @@ png_read_raw_profile(Image *image, const ImageInfo *image_info,
           if (*sp == '\0')
             {
               MagickFreeMemory(info);
-              (void) ThrowException2(&image->exception,CoderWarning,
-                                     "ran out of profile data",(char *) NULL);
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                  "ran out of profile data");
               return (MagickFail);
             }
           sp++;
@@ -1234,8 +1268,9 @@ png_read_raw_profile(Image *image, const ImageInfo *image_info,
   if(SetImageProfile(image,profile_name,info,length) == MagickFail)
     {
       MagickFreeMemory(info);
-      (void) ThrowException(&image->exception,ResourceLimitError,
-                            MemoryAllocationFailed,"unable to copy profile");
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+           "unable to copy profile");
+      return MagickFail;
     }
   MagickFreeMemory(info);
   return MagickTrue;
@@ -1263,10 +1298,12 @@ static int read_user_chunk_callback(png_struct *ping, png_unknown_chunkp chunk)
   */
 
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-     "    read_user_chunk: found %c%c%c%c chunk",
-       chunk->name[0],chunk->name[1],chunk->name[2],chunk->name[3]);
+     "    read_user_chunk: found %c%c%c%c chunk with size"
+                        " %" MAGICK_SIZE_T_F "u",
+                        chunk->name[0],chunk->name[1],
+                        chunk->name[2],chunk->name[3],
+                        (MAGICK_SIZE_T) chunk->size);
 
-#if defined(exIf_SUPPORTED)
   if (chunk->name[0]  == 101 &&
       (chunk->name[1] ==  88 || chunk->name[1] == 120 ) &&
       chunk->name[2]  ==  73 &&
@@ -1286,44 +1323,57 @@ static int read_user_chunk_callback(png_struct *ping, png_unknown_chunkp chunk)
       size_t
         i;
 
-(void) LogMagickEvent(CoderEvent,GetMagickModule(),
-        " recognized eXIf|exIf chunk");
-
       image=(Image *) png_get_user_chunk_ptr(ping);
 
-#if PNG_LIBPNG_VER >= 14000
-      profile=(unsigned char *) png_malloc(ping,
-        (png_alloc_size_t) chunk->size+6);
-#else
-      profile=(unsigned char *) png_malloc(ping,
-         (png_size_t) chunk->size+6);
-#endif
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              " recognized eXIf chunk");
+
+      profile=MagickAllocateMemory(unsigned char *,chunk->size+6);
+
+      if (profile == (unsigned char *) NULL)
+        {
+          ThrowException(&image->exception,ResourceLimitError,
+                         MemoryAllocationFailed,image->filename);
+          return -1;
+        }
+
       p=profile;
 
-      if (*p != 'E' || *(p+1) != 'x' || *(p+2) != 'i' ||
-          *(p+3) != 'f' || *(p+4) != '\0' || *(p+5) != '\0')
+      /* Stored profile must start with "Exif\0\0" */
+      *p++ ='E';
+      *p++ ='x';
+      *p++ ='i';
+      *p++ ='f';
+      *p++ ='\0';
+      *p++ ='\0';
+
+      i=0;
+      s=chunk->data;
+
+      if (chunk->size > 6 &&
+          (s[0] == 'E' || s[1] == 'x' || s[2] == 'i' ||
+           s[3] == 'f' || s[4] == '\0' || s[5] == '\0'))
         {
-          /* Initialize profile with "Exif\0\0" if it
-             doesn't already begin with it by accident
+          /*
+            Skip over "Exif\0\0" if already present
           */
-          *p++ ='E';
-          *p++ ='x';
-          *p++ ='i';
-          *p++ ='f';
-          *p++ ='\0';
-          *p++ ='\0';
+          i=6;
+          s += 6;
         }
 
       /* copy chunk->data to profile */
-      s=chunk->data;
-      for (i=0; i<chunk->size; i++)
+      /* It is documented that the first four bytes of eXIf profile
+         should be '73 73 42 0' or '77 77 0 42' */
+      for (; i<chunk->size; i++)
         *p++ = *s++;
 
       (void) SetImageProfile(image,"exif",
-         (const unsigned char *)profile, chunk->size+6);
+         (const unsigned char *)profile, p-profile);
+      MagickFreeMemory(profile)
+
       return(1);
     }
-#endif /* exIf_SUPPORTED */
 
   /* orNT */
   if (chunk->name[0] == 111 &&
@@ -1359,17 +1409,10 @@ static int read_user_chunk_callback(png_struct *ping, png_unknown_chunkp chunk)
 
      image=(Image *) png_get_user_chunk_ptr(ping);
 
-     image->page.width=(size_t) ((chunk->data[0] << 24) |
-        (chunk->data[1] << 16) | (chunk->data[2] << 8) | chunk->data[3]);
-
-     image->page.height=(size_t) ((chunk->data[4] << 24) |
-        (chunk->data[5] << 16) | (chunk->data[6] << 8) | chunk->data[7]);
-
-     image->page.x=(size_t) ((chunk->data[8] << 24) |
-        (chunk->data[9] << 16) | (chunk->data[10] << 8) | chunk->data[11]);
-
-     image->page.y=(size_t) ((chunk->data[12] << 24) |
-        (chunk->data[13] << 16) | (chunk->data[14] << 8) | chunk->data[15]);
+     image->page.width=(size_t) mng_get_long(chunk->data);
+     image->page.height=(size_t) mng_get_long(&chunk->data[4]);
+     image->page.x=(size_t) mng_get_long(&chunk->data[8]);
+     image->page.y=(size_t) mng_get_long(&chunk->data[12]);
 
      return(1);
     }
@@ -1538,6 +1581,8 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
       ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
     }
 
+  png_set_crc_action(ping, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE);
+
   mng_info->png_pixels=(unsigned char *) NULL;
   mng_info->quantum_scanline=(Quantum *) NULL;
 
@@ -1635,11 +1680,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
 # else
   png_set_keep_unknown_chunks(ping, 1, NULL, 0);
 # endif
-  /* Ignore unused chunks and all unknown chunks except for eXIf
-     and caNv */
-#if defined(eXIf_SUPPORTED)
-  png_set_keep_unknown_chunks(ping, 2, (png_bytep) mng_eXIf, 1);
-#endif
+  /* Ignore unused chunks and all unknown chunks except for caNv */
   png_set_keep_unknown_chunks(ping, 2, (png_bytep) mng_caNv, 1);
   png_set_keep_unknown_chunks(ping, 1, unused_chunks,
                               (int)sizeof(unused_chunks)/5);
@@ -1741,7 +1782,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
 
   /* Too big? */
   if (ping_width >
-     (magick_uint64_t) GetMagickResourceLimit(PixelsResource)/ping_height)
+    (magick_uint64_t) GetMagickResourceLimit(PixelsResource)/ping_height)
   {
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
       "Number of pixels exceeds resource limit");
@@ -1987,7 +2028,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
     }
 
 #if defined(PNG_READ_bKGD_SUPPORTED)
-  if (mng_info->have_global_bkgd && 
+  if (mng_info->have_global_bkgd &&
               !(png_get_valid(ping,ping_info, PNG_INFO_bKGD)))
     image->background_color=mng_info->mng_global_bkgd;
   if (png_get_valid(ping, ping_info, PNG_INFO_bKGD))
@@ -2065,7 +2106,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
           "    Reading PNG tRNS chunk.");
 
-      bit_mask = (1 << ping_file_depth) - 1;
+      bit_mask = (1U << ping_file_depth) - 1;
 
       /*
         Image has a transparent background.
@@ -2145,7 +2186,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
       (ping_colortype == PNG_COLOR_TYPE_GRAY))
     {
       image->storage_class=PseudoClass;
-      image->colors=1 << ping_file_depth;
+      image->colors=1U << ping_file_depth;
 #if (QuantumDepth == 8)
       if (image->colors > 256)
         image->colors=256;
@@ -2198,7 +2239,7 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
           unsigned long
             scale;
 
-          scale=(MaxRGB/((1 << ping_file_depth)-1));
+          scale=(MaxRGB/((1U << ping_file_depth)-1));
           if (scale < 1)
             scale=1;
           for (i=0; i < (long) image->colors; i++)
@@ -2243,12 +2284,24 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                           "    Reading PNG IDAT chunk(s)");
   if (num_passes > 1)
-    mng_info->png_pixels=MagickAllocateMemory(unsigned char *,
-                                    ping_rowbytes*image->rows);
+  {
+    if (ping_rowbytes < GetMagickResourceLimit(MemoryResource)/image->rows)
+      mng_info->png_pixels=MagickAllocateMemory(unsigned char *,
+               ping_rowbytes*image->rows);
+    else
+      png_error(ping, "png_pixels array exceeds MemoryResource");
+  }
   else
-    mng_info->png_pixels=MagickAllocateMemory(unsigned char *, ping_rowbytes);
+  {
+    if ((magick_int64_t)ping_rowbytes < GetMagickResourceLimit(MemoryResource))
+      mng_info->png_pixels=MagickAllocateMemory(unsigned char *, ping_rowbytes);
+    else
+      png_error(ping, "png_rowbytes array exceeds MemoryResource");
+  }
   if (mng_info->png_pixels == (unsigned char *) NULL)
+  {
     png_error(ping, "Could not allocate png_pixels array");
+  }
 
   if (logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -2304,7 +2357,8 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
                         *r++=*p++;
                         p++;
                         if ((png_get_valid(ping, ping_info, PNG_INFO_tRNS)) &&
-                            ((unsigned long) ((*(p-2) << 8)|*(p-1))
+                            ((unsigned long) (((magick_uint32_t) *(p-2) << 8)|
+                                              (magick_uint32_t) *(p-1))
                             == transparent_color.opacity))
                           {
                             /* Cheap transparency */
@@ -2325,11 +2379,11 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
                           p++;
                           *r++=*p++;
                           p++;
-                          if (((unsigned long) ((*(p-6) << 8)|*(p-5)) ==
+                          if (((unsigned long) (((magick_uint32_t) *(p-6) << 8)|*(p-5)) ==
                               transparent_color.red) &&
-                              ((unsigned long) ((*(p-4) << 8)|*(p-3)) ==
+                              ((unsigned long) (((magick_uint32_t) *(p-4) << 8)|*(p-3)) ==
                               transparent_color.green) &&
-                              ((unsigned long) ((*(p-2) << 8)|*(p-1)) ==
+                              ((unsigned long) (((magick_uint32_t) *(p-2) << 8)|*(p-1)) ==
                               transparent_color.blue))
                             {
                               /* Cheap transparency */
@@ -2447,141 +2501,147 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
       }
 
   else /* image->storage_class != DirectClass */
-  {
-   image->matte=ping_colortype == PNG_COLOR_TYPE_GRAY_ALPHA;
-   mng_info->quantum_scanline=MagickAllocateMemory(Quantum *,
-      (image->matte ?  2 : 1) * image->columns*sizeof(Quantum));
-   if (mng_info->quantum_scanline == (Quantum *) NULL)
-     png_error(ping, "Could not allocate quantum_scanline");
-   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                         "      Allocated quantum_scanline");
+    {
+      image->matte=ping_colortype == PNG_COLOR_TYPE_GRAY_ALPHA;
+      mng_info->quantum_scanline=
+        MagickAllocateMemory(Quantum *,
+                             (image->matte ?  2 : 1) *
+                             image->columns*sizeof(Quantum));
+      if (mng_info->quantum_scanline == (Quantum *) NULL)
+        png_error(ping, "Could not allocate quantum_scanline");
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "      Allocated quantum_scanline");
 
-    for (pass=0; pass < num_passes; pass++)
-      {
-        register Quantum
-          *r;
+      for (pass=0; pass < num_passes; pass++)
+        {
+          register Quantum
+            *r;
 
-        /*
-          Convert grayscale image to PseudoClass pixel packets.
-        */
-        for (y=0; y < (long) image->rows; y++)
-          {
-            register unsigned char
-              *p;
+          /*
+            Convert grayscale image to PseudoClass pixel packets.
+          */
+          for (y=0; y < (long) image->rows; y++)
+            {
+              register unsigned char
+                *p;
 
-            if (num_passes > 1)
-              row_offset=ping_rowbytes*y;
+              if (num_passes > 1)
+                row_offset=ping_rowbytes*y;
 
-            else
-              row_offset=0;
+              else
+                row_offset=0;
 
-            png_read_row(ping,mng_info->png_pixels+row_offset,NULL);
-            q=SetImagePixels(image,0,y,image->columns,1);
-            if (q == (PixelPacket *) NULL)
-              break;
+              png_read_row(ping,mng_info->png_pixels+row_offset,NULL);
+              q=SetImagePixels(image,0,y,image->columns,1);
+              if (q == (PixelPacket *) NULL)
+                break;
 
-            if (pass < num_passes-1)
-              continue;
+              if (pass < num_passes-1)
+                continue;
 
-            indexes=AccessMutableIndexes(image);
-            p=mng_info->png_pixels+row_offset;
-            r=mng_info->quantum_scanline;
-            switch (ping_bit_depth)
-              {
-              case 8:
+              indexes=AccessMutableIndexes(image);
+              p=mng_info->png_pixels+row_offset;
+              r=mng_info->quantum_scanline;
+              switch (ping_bit_depth)
                 {
-                  if (ping_colortype == 4)
-                    for (x=(long) image->columns; x > 0; x--)
-                      {
-                        *r++=*p++;
-                        /* In image.h, OpaqueOpacity is 0
-                         * TransparentOpacity is MaxRGB
-                         * In a PNG datastream, Opaque is MaxRGB
-                         * and Transparent is 0.
-                         */
-                        q->opacity=ScaleCharToQuantum(255-(*p++));
-                        q++;
-                      }
-                  else
-                    for (x=(long) image->columns; x > 0; x--)
-                      *r++=*p++;
-                  break;
-                }
-              case 16:
-                {
-                  for (x=(long) image->columns; x > 0; x--)
-                    {
-#if (QuantumDepth == 16)
-                      if (image->colors > 256)
-                        *r=((*p++) << 8);
-                      else
-                        *r=0;
-                      *r|=(*p++);
-                      r++;
-                      if (ping_colortype == 4)
+                case 8:
+                  {
+                    if (ping_colortype == 4)
+                      for (x=(long) image->columns; x > 0; x--)
                         {
-                          q->opacity=((*p++) << 8);
-                          q->opacity|=(*p++);
-                          q->opacity=(Quantum) (MaxRGB-q->opacity);
+                          *r++=*p++;
+                          /* In image.h, OpaqueOpacity is 0
+                           * TransparentOpacity is MaxRGB
+                           * In a PNG datastream, Opaque is MaxRGB
+                           * and Transparent is 0.
+                           */
+                          q->opacity=ScaleCharToQuantum(255-(*p++));
                           q++;
                         }
+                    else
+                      for (x=(long) image->columns; x > 0; x--)
+                        *r++=*p++;
+                    break;
+                  }
+                case 16:
+                  {
+                    for (x=(long) image->columns; x > 0; x--)
+                      {
+#if (QuantumDepth == 16)
+                        if (image->colors > 256)
+                          *r=(((magick_uint32_t) *p++) << 8);
+                        else
+                          *r=0;
+                        *r|=(*p++);
+                        r++;
+                        if (ping_colortype == 4)
+                          {
+                            q->opacity=(((magick_uint32_t) *p++) << 8);
+                            q->opacity|=((magick_uint32_t) *p++);
+                            q->opacity=(Quantum) (MaxRGB-q->opacity);
+                            q++;
+                          }
 #else
 #if (QuantumDepth == 32)
-                      if (image->colors > 256)
-                        *r=((*p++) << 8);
-                      else
-                        *r=0;
-                      *r|=(*p++);
-                      r++;
-                      if (ping_colortype == 4)
-                        {
-                          q->opacity=((*p++) << 8);
-                          q->opacity|=(*p++);
-                          q->opacity*=65537L;
-                          q->opacity=(Quantum) (MaxRGB-q->opacity);
-                          q++;
-                        }
+                        if (image->colors > 256)
+                          *r=(((magick_uint32_t) *p++) << 8);
+                        else
+                          *r=0;
+                        *r|=(*p++);
+                        r++;
+                        if (ping_colortype == 4)
+                          {
+                            q->opacity=(((magick_uint32_t) *p++) << 8);
+                            q->opacity|=((magick_uint32_t) *p++);
+                            q->opacity*=65537U;
+                            q->opacity=(Quantum) (MaxRGB-q->opacity);
+                            q++;
+                          }
 #else /* QuantumDepth == 8 */
-                      *r++=(*p++);
-                      p++; /* strip low byte */
-                      if (ping_colortype == 4)
-                        {
-                          q->opacity=(Quantum) (MaxRGB-(*p++));
-                          p++;
-                          q++;
-                        }
+                        *r++=(*p++);
+                        p++; /* strip low byte */
+                        if (ping_colortype == 4)
+                          {
+                            q->opacity=(Quantum) (MaxRGB-(*p++));
+                            p++;
+                            q++;
+                          }
 #endif
 #endif
-                    }
+                      }
+                    break;
+                  }
+                default:
                   break;
                 }
-              default:
-                break;
-              }
-            /*
-              Transfer image scanline.
-            */
-            r=mng_info->quantum_scanline;
+              /*
+                Transfer image scanline.
+              */
+              r=mng_info->quantum_scanline;
 
-            for (x=0; x < (long) image->columns; x++)
-              indexes[x]=(*r++);
+              for (x=0; x < (long) image->columns; x++)
+                indexes[x]=(*r++);
 
-            if (!SyncImagePixels(image))
-              break;
+              if (!SyncImagePixels(image))
+                break;
             }
 
-        if (image->previous == (Image *) NULL)
-          if (QuantumTick(pass, num_passes))
-            if (!MagickMonitorFormatted(pass,num_passes,exception,LoadImageTag,
-                                        image->filename,
-                                            image->columns,image->rows))
+          /* Quit 'passes' loop if we encountered an error */
+          if (y < (long) image->rows)
+            break;
+
+          if (image->previous == (Image *) NULL)
+            if (QuantumTick(pass, num_passes))
+              if (!MagickMonitorFormatted(pass,num_passes,exception,LoadImageTag,
+                                          image->filename,
+                                          image->columns,image->rows))
               break;
       }
 
       MagickFreeMemory(mng_info->quantum_scanline);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-          "      Free'ed quantum_scanline after last pass");
-  }
+                            "      Free'ed quantum_scanline after last pass");
+    }
 
   if (image->storage_class == PseudoClass)
     (void) SyncImage(image);
@@ -2615,7 +2675,6 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
       image->matte=MagickTrue;
       for (y=0; y < (long) image->rows; y++)
         {
-          image->storage_class=storage_class;
           q=SetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
@@ -2676,46 +2735,61 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
     image->depth=8;
 #endif
   if (png_get_text(ping,ping_info,&text,&num_text) != 0)
-    for (i=0; i < (long) num_text; i++)
-      {
-        /* Check for a profile */
+    {
+      if (logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "    Text chunks: %u", num_text);
+      for (i=0; i < (long) num_text; i++)
+        {
+          /* Check for a profile */
 
-        if (logging)
-          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                "    Reading PNG text chunk");
-        if (strlen(text[i].key) > 16 &&
-            !memcmp(text[i].key, "Raw profile type ",17))
-          {
-            if (png_read_raw_profile(image,image_info,text,(int) i) ==
-              MagickFail)
-            break;
-          }
-        else
-          {
-            char
-              *value;
+          if (logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "    Reading PNG text chunk[%ld] key=\"%.16s\","
+                                  " length=%" MAGICK_SSIZE_T_F "u",i,text[i].key,
+                                  (MAGICK_SSIZE_T) text[i].text_length);
+          if (strlen(text[i].key) > 16 &&
+              !memcmp(text[i].key, "Raw profile type ",17))
+            {
+              if (text[i].text_length == 0)
+                {
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                        "    Skipping empty raw profile...");
+                }
+              else
+                {
+                  if (png_read_raw_profile(image,image_info,text,i,exception) ==
+                      MagickFail)
+                    break;
+                }
+            }
+          else
+            {
+              char
+                *value;
 
-            length=(unsigned long) text[i].text_length;
-            value=MagickAllocateMemory(char *,length+1);
-            if (value == (char *) NULL)
-              {
-                png_warning(ping, "Could not allocate memory for text chunk");
-                break;
-              }
-            *value='\0';
-            (void) strlcat(value,text[i].text,length+1);
-            (void) SetImageAttribute(image,text[i].key,value);
-            if (logging)
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                    "      Keyword: %s",text[i].key);
-            MagickFreeMemory(value);
-          }
-      }
+              length=(unsigned long) text[i].text_length;
+              value=MagickAllocateMemory(char *,length+1);
+              if (value == (char *) NULL)
+                {
+                  png_warning(ping, "Could not allocate memory for text chunk");
+                  break;
+                }
+              *value='\0';
+              (void) strlcat(value,text[i].text,length+1);
+              (void) SetImageAttribute(image,text[i].key,value);
+              if (logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "      Keyword: %s",text[i].key);
+              MagickFreeMemory(value);
+            }
+        }
+    }
 #ifdef MNG_OBJECT_BUFFERS
   /*
     Store the object if necessary.
   */
-  if (object_id && !mng_info->frozen[object_id])
+  if (object_id && object_id < MNG_MAX_OBJECTS && !mng_info->frozen[object_id])
     {
       if (mng_info->ob[object_id] == (MngBuffer *) NULL)
         {
@@ -2752,7 +2826,10 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
             filter_method;
 
           if (mng_info->ob[object_id]->image != (Image *) NULL)
-            DestroyImage(mng_info->ob[object_id]->image);
+            {
+              DestroyImage(mng_info->ob[object_id]->image);
+              mng_info->ob[object_id]->image=(Image *) NULL;
+            }
           mng_info->ob[object_id]->image=CloneImage(image,0,0,MagickTrue,
                                                     &image->exception);
           if (mng_info->ob[object_id]->image != (Image *) NULL)
@@ -2849,8 +2926,8 @@ static Image *ReadPNGImage(const ImageInfo *image_info,
   /*
     Verify PNG signature.
   */
-  (void) ReadBlob(image,8,magic_number);
-  if (memcmp(magic_number,"\211PNG\r\n\032\n",8) != 0)
+  if ((ReadBlob(image,8,magic_number) != 8) ||
+      (memcmp(magic_number,"\211PNG\r\n\032\n",8) != 0))
   {
     ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
   }
@@ -2895,6 +2972,7 @@ static Image *ReadPNGImage(const ImageInfo *image_info,
       if (image->exception.severity > exception->severity)
         CopyException(exception,&image->exception);
       DestroyImageList(image);
+      image=(Image *) NULL;
       if (logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "exit ReadPNGImage() with error.");
@@ -2924,18 +3002,32 @@ static Image *ReadPNGImage(const ImageInfo *image_info,
 
 #if defined(JNG_SUPPORTED)
 
-
-void
-DestroyJNGInfo(ImageInfo *color_image_info, ImageInfo *alpha_image_info)
+static void
+DestroyJNG(unsigned char *chunk,Image **color_image,
+   ImageInfo **color_image_info,
+   Image **alpha_image,ImageInfo **alpha_image_info)
 {
-          if (color_image_info != (ImageInfo *)NULL)
-            {
-              DestroyImageInfo(color_image_info);
-            }
-          if (alpha_image_info != (ImageInfo *)NULL)
-            {
-              DestroyImageInfo(alpha_image_info);
-            }
+  MagickFreeMemory(chunk);
+  if (*color_image_info)
+  {
+    DestroyImageInfo(*color_image_info);
+    *color_image_info = (ImageInfo *)NULL;
+  }
+  if (*alpha_image_info)
+  {
+    DestroyImageInfo(*alpha_image_info);
+    *alpha_image_info = (ImageInfo *)NULL;
+  }
+  if (*color_image)
+  {
+    DestroyImage(*color_image);
+    *color_image = (Image *)NULL;
+  }
+  if (*alpha_image)
+  {
+    DestroyImage(*alpha_image);
+    *alpha_image = (Image *)NULL;
+  }
 }
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -3026,9 +3118,12 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
     reading_idat,
     status;
 
-  unsigned long
+  size_t
     length;
 
+  magick_off_t
+    blob_size;
+
   jng_alpha_compression_method=0;
   jng_alpha_sample_depth=8;
   jng_color_type=0;
@@ -3043,6 +3138,7 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
                          "  enter ReadOneJNGImage()");
 
   image=mng_info->image;
+  blob_size=GetBlobSize(image);
   if (AccessMutablePixels(image) != (PixelPacket *) NULL)
     {
       /*
@@ -3064,7 +3160,7 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
 
   read_JSEP=MagickFalse;
   reading_idat=MagickFalse;
-  
+
   width_resource = GetMagickResourceLimit(WidthResource);
   height_resource = GetMagickResourceLimit(HeightResource);
 
@@ -3074,7 +3170,7 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
         type[MaxTextExtent];
 
       unsigned char
-        *chunk;
+        *chunk = (unsigned char *) NULL;
 
       unsigned int
         count;
@@ -3083,47 +3179,87 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
         Read a new JNG chunk.
       */
 
-      if (QuantumTick(TellBlob(image),2*GetBlobSize(image)))
-        if (!MagickMonitorFormatted(TellBlob(image),2*GetBlobSize(image),
+      if (QuantumTick(TellBlob(image),2*blob_size))
+        if (!MagickMonitorFormatted(TellBlob(image),2*blob_size,
                                     exception,LoadImagesTag,image->filename))
           break;
 
       type[0]='\0';
       (void) strcat(type,"errr");
-      length=ReadBlobMSBLong(image);
+      length=(size_t) ReadBlobMSBLong(image);
       count=(unsigned int) ReadBlob(image,4,type);
-
+      if (count != 4)
+        {
+          DestroyJNG(NULL,&color_image,&color_image_info,
+            &alpha_image,&alpha_image_info);
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "chunk count is zero");
+          ThrowException(exception,CorruptImageError,
+                         UnexpectedEndOfFile,image->filename);
+          return ((Image*)NULL);
+        }
       if (logging)
         {
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                " Reading JNG chunk type %c%c%c%c, length: %lu",
-                                type[0],type[1],type[2],type[3],length);
-      
+                                " Reading JNG chunk type %c%c%c%c, "
+                                "length: %" MAGICK_SIZE_T_F "u",
+                                type[0],type[1],type[2],type[3],
+                                (MAGICK_SIZE_T) length);
+
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                "   count=%u\n",count);
+                                "   count=%u",count);
         }
 
-      if (length > PNG_MAX_UINT || count == 0)
+      if (length > PNG_MAX_UINT)
         {
-          DestroyJNGInfo(color_image_info,alpha_image_info);
-          ThrowReaderException(CorruptImageError,CorruptImage,image);
+          DestroyJNG(NULL,&color_image,&color_image_info,
+            &alpha_image,&alpha_image_info);
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "chunk length (%" MAGICK_SIZE_T_F "u) > PNG_MAX_UINT",
+                                (MAGICK_SIZE_T) length);
+          ThrowException(exception,CorruptImageError,
+                         ImproperImageHeader,image->filename);
+          return ((Image*)NULL);
+        }
+      if (length > (size_t) blob_size)
+        {
+          DestroyJNG(NULL,&color_image,&color_image_info,
+            &alpha_image,&alpha_image_info);
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "chunk length (%" MAGICK_SIZE_T_F "u)"
+                                  " is greater than input size"
+                                  " (%" MAGICK_OFF_F "d)",
+                                  (MAGICK_SIZE_T) length,
+                                  blob_size);
+          ThrowException(exception,CorruptImageError,
+                         ImproperImageHeader,image->filename);
+          return ((Image*)NULL);
         }
 
-      chunk=(unsigned char *) NULL;
       p=NULL;
       if (length)
         {
           chunk=MagickAllocateMemory(unsigned char *,length);
           if (chunk == (unsigned char *) NULL)
             {
-              DestroyJNGInfo(color_image_info,alpha_image_info);
-              ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-                                   image);
+              DestroyJNG(chunk,&color_image,&color_image_info,
+                &alpha_image,&alpha_image_info);
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                  "    Could not allocate chunk memory");
+              ThrowException(exception,ResourceLimitError,
+                             MemoryAllocationFailed,image->filename);
+              return ((Image*)NULL);
             }
-          if (ReadBlob(image,length,chunk) < length)
+          if (ReadBlob(image,length,chunk) != length)
             {
-              DestroyJNGInfo(color_image_info,alpha_image_info);
-              ThrowReaderException(CorruptImageError,CorruptImage,image);
+              DestroyJNG(chunk,&color_image,&color_image_info,
+                &alpha_image,&alpha_image_info);
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                  "    chunk reading was incomplete");
+              ThrowException(exception,CorruptImageError,
+                             InsufficientImageDataInFile,image->filename);
+              return ((Image*)NULL);
             }
           p=chunk;
         }
@@ -3131,63 +3267,54 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
 
       if (!memcmp(type,mng_JHDR,4))
         {
-          if (length != 16)
-            {
-              DestroyJNGInfo(color_image_info,alpha_image_info);
-              MagickFreeMemory(chunk);
-              (void) ThrowException2(&image->exception,CoderWarning,
-                             "Invalid JHDR chunk length",(char *) NULL);
-              return (MagickFail);
-            }
-
-          jng_width=(unsigned long) ((p[0] << 24) | (p[1] << 16) |
-                                     (p[2] << 8) | p[3]);
-          jng_height=(unsigned long) ((p[4] << 24) | (p[5] << 16) |
-                                      (p[6] << 8) | p[7]);
-          jng_color_type=p[8];
-          jng_image_sample_depth=p[9];
-          jng_image_compression_method=p[10];
-          jng_image_interlace_method=p[11];
-          jng_alpha_sample_depth=p[12];
-          jng_alpha_compression_method=p[13];
-          jng_alpha_filter_method=p[14];
-          jng_alpha_interlace_method=p[15];
-          if (logging)
+          if (length == 16)
             {
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                    "    jng_width:      %16lu",
-                                    jng_width);
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                    "    jng_height:     %16lu",
-                                    jng_height);
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                    "    jng_color_type: %16d",
-                                    jng_color_type);
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                    "    jng_image_sample_depth:      %3d",
-                                    jng_image_sample_depth);
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                    "    jng_image_compression_method:%3d",
-                                    jng_image_compression_method);
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                    "    jng_image_interlace_method:  %3d",
-                                    jng_image_interlace_method);
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                    "    jng_alpha_sample_depth:      %3d",
-                                jng_alpha_sample_depth);
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                    "    jng_alpha_compression_method:%3d",
-                                    jng_alpha_compression_method);
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                    "    jng_alpha_filter_method:     %3d",
-                                    jng_alpha_filter_method);
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                    "    jng_alpha_interlace_method:  %3d",
-                                    jng_alpha_interlace_method);
+              jng_width=(unsigned long) mng_get_long(p);
+              jng_height=(unsigned long) mng_get_long(&p[4]);
+              jng_color_type=p[8];
+              jng_image_sample_depth=p[9];
+              jng_image_compression_method=p[10];
+              jng_image_interlace_method=p[11];
+              jng_alpha_sample_depth=p[12];
+              jng_alpha_compression_method=p[13];
+              jng_alpha_filter_method=p[14];
+              jng_alpha_interlace_method=p[15];
+              if (logging)
+                {
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "    jng_width:      %16lu",
+                      jng_width);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "    jng_height:     %16lu",
+                      jng_height);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "    jng_color_type: %16d",
+                      jng_color_type);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "    jng_image_sample_depth:      %3d",
+                      jng_image_sample_depth);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "    jng_image_compression_method:%3d",
+                      jng_image_compression_method);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "    jng_image_interlace_method:  %3d",
+                      jng_image_interlace_method);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "    jng_alpha_sample_depth:      %3d",
+                      jng_alpha_sample_depth);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "    jng_alpha_compression_method:%3d",
+                      jng_alpha_compression_method);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "    jng_alpha_filter_method:     %3d",
+                      jng_alpha_filter_method);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "    jng_alpha_interlace_method:  %3d",
+                      jng_alpha_interlace_method);
+                }
             }
 
-          if (length)
-            MagickFreeMemory(chunk);
+          MagickFreeMemory(chunk);
 
           if (jng_width > 65535 || jng_height > 65535 ||
                (long) jng_width > GetMagickResourceLimit(WidthResource) ||
@@ -3196,9 +3323,28 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                  "    JNG width or height too large: (%lu x %lu)",
                   jng_width, jng_height);
-              MagickFreeMemory(chunk);
-              DestroyJNGInfo(color_image_info,alpha_image_info);
-              ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+              ThrowException(exception,CorruptImageError,
+                             ImproperImageHeader,image->filename);
+              DestroyJNG(chunk,&color_image,&color_image_info,
+                &alpha_image,&alpha_image_info);
+              return ((Image *)NULL);
+            }
+
+          /* Rationalize dimensions with blob size if it is available */
+          if ((blob_size == 0) ||
+              ((((double) jng_width*jng_height)/blob_size) > 512.0))
+            {
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "    Unreasonable dimensions: "
+                                    "geometry = %lux%lu, "
+                                    "blob size = %" MAGICK_OFF_F "d",
+                                    jng_width, jng_height, blob_size);
+
+              ThrowException(exception,CorruptImageError,
+                             InsufficientImageDataInFile,image->filename);
+              DestroyJNG(chunk,&color_image,&color_image_info,
+                         &alpha_image,&alpha_image_info);
+              return ((Image *)NULL);
             }
 
           /* Temporarily set width and height resources to match JHDR */
@@ -3208,11 +3354,9 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
           continue;
         }
 
-
-      if (!reading_idat && !read_JSEP && (!memcmp(type,mng_JDAT,4) ||
-                                          !memcmp(type,mng_JdAA,4) ||
-                                          !memcmp(type,mng_IDAT,4) ||
-                                          !memcmp(type,mng_JDAA,4)))
+      if ((reading_idat == MagickFalse) && (read_JSEP == MagickFalse) &&
+         ((memcmp(type,mng_JDAT,4) == 0) || (memcmp(type,mng_JdAA,4) == 0) ||
+         (memcmp(type,mng_IDAT,4) == 0) || (memcmp(type,mng_JDAA,4) == 0)))
         {
           /*
             o create color_image
@@ -3224,17 +3368,25 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
           color_image_info=MagickAllocateMemory(ImageInfo *,sizeof(ImageInfo));
           if (color_image_info == (ImageInfo *) NULL)
             {
-              DestroyJNGInfo(color_image_info,alpha_image_info);
-              ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-                                   image);
+              DestroyJNG(chunk,&color_image,&color_image_info,
+                &alpha_image,&alpha_image_info);
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                  "    could not allocate color_image_info");
+              ThrowException(exception,ResourceLimitError,
+                             MemoryAllocationFailed,image->filename);
+              return ((Image *)NULL);
             }
           GetImageInfo(color_image_info);
           color_image=AllocateImage(color_image_info);
           if (color_image == (Image *) NULL)
             {
-              DestroyJNGInfo(color_image_info,alpha_image_info);
-              ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-                                   image);
+              DestroyJNG(chunk,&color_image,&color_image_info,
+                &alpha_image,&alpha_image_info);
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                  "    could not allocate color_image");
+              ThrowException(exception,ResourceLimitError,
+                             MemoryAllocationFailed,image->filename);
+              return ((Image *)NULL);
             }
           if (logging)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -3244,8 +3396,12 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
                           exception);
           if (status == MagickFalse)
             {
-              DestroyJNGInfo(color_image_info,alpha_image_info);
-              ThrowReaderException(CoderError,UnableToOpenBlob,color_image);
+              CopyException(exception,&color_image->exception);
+              DestroyJNG(chunk,&color_image,&color_image_info,
+                &alpha_image,&alpha_image_info);
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                  "    could not open color_image blob");
+              return ((Image *)NULL);
             }
 
           if (!image_info->ping && jng_color_type >= 12)
@@ -3254,18 +3410,25 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
                                                     sizeof(ImageInfo));
               if (alpha_image_info == (ImageInfo *) NULL)
                 {
-                  DestroyJNGInfo(color_image_info,alpha_image_info);
-                  ThrowReaderException(ResourceLimitError,
-                                       MemoryAllocationFailed, image);
+                  DestroyJNG(chunk,&color_image,&color_image_info,
+                    &alpha_image,&alpha_image_info);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "    could not allocate alpha_image_info");
+                  ThrowException(exception,ResourceLimitError,
+                                 MemoryAllocationFailed,image->filename);
+                  return ((Image *)NULL);
                 }
               GetImageInfo(alpha_image_info);
               alpha_image=AllocateImage(alpha_image_info);
               if (alpha_image == (Image *) NULL)
                 {
-                  DestroyJNGInfo(color_image_info,alpha_image_info);
-                  ThrowReaderException(ResourceLimitError,
-                                       MemoryAllocationFailed,
-                                       alpha_image);
+                  DestroyJNG(chunk,&color_image,&color_image_info,
+                    &alpha_image,&alpha_image_info);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "    could not allocate alpha_image");
+                  ThrowException(exception,ResourceLimitError,
+                                 MemoryAllocationFailed,image->filename);
+                  return ((Image *)NULL);
                 }
               if (logging)
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -3275,9 +3438,11 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
                               exception);
               if (status == MagickFalse)
                 {
-                  DestroyJNGInfo(color_image_info,alpha_image_info);
-                  DestroyImage(alpha_image);
-                  ThrowReaderException(CoderError,UnableToOpenBlob,image);
+                  DestroyJNG(chunk,&color_image,&color_image_info,
+                    &alpha_image,&alpha_image_info);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "    could not open alpha_image blob");
+                  return ((Image *)NULL);
                 }
               if (jng_alpha_compression_method == 0)
                 {
@@ -3312,14 +3477,27 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
             Copy chunk to color_image->blob
           */
 
-          if (logging)
-            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                  "    Copying JDAT chunk data"
-                                  " to color_blob.");
-          if (color_image != (Image *)NULL)
-            (void) WriteBlob(color_image,length,(char *) chunk);
-          if (length)
-            MagickFreeMemory(chunk);
+
+          if (length && color_image != (Image *)NULL)
+            {
+              if (logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "    Copying %" MAGICK_SIZE_T_F
+                                      "u bytes of JDAT chunk data"
+                                      " to color_blob.",
+                                      (MAGICK_SIZE_T) length);
+              (void) WriteBlob(color_image,length,(char *) chunk);
+            }
+          else
+            {
+              if (logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "    Skipping copy of %" MAGICK_SIZE_T_F
+                                      "u bytes of JDAT chunk data"
+                                      " to color_blob (color_image=%p).",
+                                      (MAGICK_SIZE_T) length, color_image);
+            }
+          MagickFreeMemory(chunk);
           continue;
         }
 
@@ -3335,20 +3513,28 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
           if (alpha_image != NULL && image_info->ping == MagickFalse)
             {
               if (logging)
+              {
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                      "    Copying IDAT chunk data"
-                                      " to alpha_blob.");
-
+                    "    Copying IDAT chunk data"
+                    " to alpha_blob.");
+              }
+              if (length == 0)
+              {
+                if (logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                    "    IDAT chunk has length 0");
+                MagickFreeMemory(chunk);
+                continue;
+              }
               (void) WriteBlobMSBULong(alpha_image,(unsigned long) length);
               PNGType(data,mng_IDAT);
               LogPNGChunk(logging,mng_IDAT,length);
               (void) WriteBlob(alpha_image,4,(char *) data);
               (void) WriteBlob(alpha_image,length,(char *) chunk);
               (void) WriteBlobMSBULong(alpha_image,
-                                       crc32(crc32(0,data,4),chunk,length));
+                                       crc32(crc32(0,data,4),chunk,(uInt) length));
             }
-          if (length)
-            MagickFreeMemory(chunk);
+          MagickFreeMemory(chunk);
           continue;
         }
 
@@ -3358,7 +3544,7 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
             Copy chunk data to alpha_image->blob
           */
 
-          if (alpha_image != NULL && image_info->ping == MagickFalse)
+          if (alpha_image != NULL && image_info->ping == MagickFalse && length != 0)
             {
               if (logging)
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -3367,16 +3553,14 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
 
               (void) WriteBlob(alpha_image,length,(char *) chunk);
             }
-          if (length)
-            MagickFreeMemory(chunk);
+          MagickFreeMemory(chunk);
           continue;
         }
 
       if (!memcmp(type,mng_JSEP,4))
         {
           read_JSEP=MagickTrue;
-          if (length)
-            MagickFreeMemory(chunk);
+          MagickFreeMemory(chunk);
           continue;
         }
 
@@ -3448,14 +3632,13 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
             {
               image->page.x=mng_get_long(p);
               image->page.y=mng_get_long(&p[4]);
-              if ((int) p[9] != 0)
+              if ((int) p[8] != 0)
                 {
                   image->page.x/=10000;
                   image->page.y/=10000;
                 }
             }
-          if (length)
-            MagickFreeMemory(chunk);
+          MagickFreeMemory(chunk);
           continue;
         }
 
@@ -3480,14 +3663,12 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
       if (!memcmp(type,mng_iCCP,4))
         {
           /* To do. */
-          if (length)
-            MagickFreeMemory(chunk);
+          MagickFreeMemory(chunk);
           continue;
         }
 #endif
 
-      if (length)
-        MagickFreeMemory(chunk);
+      MagickFreeMemory(chunk);
 
       if (memcmp(type,mng_IEND,4))
         continue;
@@ -3495,7 +3676,7 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
     }
 
 
-  /* IEND found */
+  /* IEND found or loop ended */
 
   /*
     Finish up reading image data:
@@ -3518,14 +3699,36 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
     o destroy the secondary image.
   */
 
-  if (color_image != (Image *)NULL)
+  if (color_image_info == (ImageInfo *) NULL || color_image == (Image *) NULL)
+    {
+
+      if (logging)
+        {
+          if (color_image_info == (ImageInfo *) NULL)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Color image info is NULL!");
+          if (color_image == (Image *) NULL)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Color image is NULL!");
+        }
+      if (color_image == (Image *) NULL)
+        {
+          ThrowException(exception,CorruptImageError,
+                         ImageFileDoesNotContainAnyImageData,image->filename);
+        }
+      DestroyImage(color_image);
+      color_image=(Image *) NULL;
+      return (Image *) NULL;
+    }
+
+  else
     {
       CloseBlob(color_image);
       if (logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                              "    Reading jng_image from color_blob.");
+            "    Reading jng_image from color_blob.");
 
-      FormatString(color_image_info->filename,"%.1024s",color_image->filename);
+      FormatString(color_image_info->filename,"JPEG:%.1024s",color_image->filename);
 
       color_image_info->ping=MagickFalse;   /* To do: avoid this */
       jng_image=ReadImage(color_image_info,exception);
@@ -3541,26 +3744,73 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
             Don't throw exception here since ReadImage() will already
             have thrown it.
           */
-          DestroyImage(image);
+          DestroyJNG(/*chunk*/ NULL,&color_image,&color_image_info,
+                     &alpha_image,&alpha_image_info);
           return (Image *) NULL;
         }
 
       if (logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                              "    Copying jng_image pixels to main image.");
+                              "jng_height=%lu, jng_width=%lu",
+                              jng_height, jng_width);
       image->rows=jng_height;
       image->columns=jng_width;
-      length=image->columns*sizeof(PixelPacket);
+      length=MagickArraySize(image->columns,sizeof(PixelPacket));
+      if (jng_height == 0 || jng_width == 0 || length == 0)
+        {
+          if (logging)
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+              "  jng_width=%lu jng_height=%lu",
+              (unsigned long)jng_width,(unsigned long)jng_height);
+          DestroyJNG(NULL,&color_image,&color_image_info,
+            &alpha_image,&alpha_image_info);
+          DestroyImageList(jng_image);
+          ThrowException(exception,CorruptImageError,
+                         ImproperImageHeader,image->filename);
+          return ((Image *)NULL);
+        }
+      if ((image->columns != jng_image->columns) ||
+          (image->rows != jng_image->rows))
+        {
+          if (logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "image dimensions %lux%lu do not"
+                                  " match JPEG dimensions %lux%lu",
+                                  image->columns,image->rows,
+                                  jng_image->columns,jng_image->rows);
+          DestroyJNG(NULL,&color_image,&color_image_info,
+                     &alpha_image,&alpha_image_info);
+          DestroyImage(jng_image);
+          ThrowException(exception,CorruptImageError,
+                         ImproperImageHeader,image->filename);
+          return ((Image *)NULL);
+        }
+      if (logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "copying jng_image pixels to main image");
       for (y=0; y < (long) image->rows; y++)
         {
-          s=AcquireImagePixels(jng_image,0,y,image->columns,1,&image->exception);
-          q=SetImagePixels(image,0,y,image->columns,1);
+          s=AcquireImagePixels(jng_image,0,y,image->columns,1,
+             exception);
+          q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
+          if ((s == (const PixelPacket *) NULL) ||
+              (q == (PixelPacket *) NULL))
+            break;
           (void) memcpy(q,s,length);
           if (!SyncImagePixels(image))
             break;
         }
       DestroyImage(jng_image);
       jng_image = (Image *)NULL;
+      if ((unsigned long) y != image->rows)
+        {
+          if (logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Failed to transfer JPEG scanlines");
+          DestroyJNG(NULL,&color_image,&color_image_info,
+                     &alpha_image,&alpha_image_info);
+          return ((Image *)NULL);
+        }
       if (alpha_image != (Image *)NULL && !image_info->ping)
         {
           if (jng_color_type >= 12)
@@ -3578,43 +3828,73 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
               CloseBlob(alpha_image);
               if (logging)
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                      "    Reading opacity from alpha_blob.");
+                     "    Reading opacity from alpha_blob.");
 
               FormatString(alpha_image_info->filename,"%.1024s",
                            alpha_image->filename);
 
               jng_image=ReadImage(alpha_image_info,exception);
 
-              for (y=0; y < (long) image->rows; y++)
+              if (jng_image == (Image *)NULL)
                 {
-                  s=AcquireImagePixels(jng_image,0,y,image->columns,1,
-                                       &image->exception);
-                  if (image->matte)
-                    {
-                      q=SetImagePixels(image,0,y,image->columns,1);
-                      for (x=(long) image->columns; x > 0; x--,q++,s++)
-                        q->opacity=(Quantum) MaxRGB-s->red;
-                    }
-                  else
-                    {
-                      q=SetImagePixels(image,0,y,image->columns,1);
-                      for (x=(long) image->columns; x > 0; x--,q++,s++)
-                        {
-                          q->opacity=(Quantum) MaxRGB-s->red;
-                          if (q->opacity != OpaqueOpacity)
-                            image->matte=MagickTrue;
-                        }
-                    }
-                  if (!SyncImagePixels(image))
-                    break;
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                       "    jng_image is NULL.");
+                  DestroyJNG(NULL,&color_image,&color_image_info,
+                    &alpha_image,&alpha_image_info);
                 }
-              (void) LiberateUniqueFileResource(alpha_image->filename);
-              DestroyImage(alpha_image);
-              alpha_image = (Image *)NULL;
-              DestroyImageInfo(alpha_image_info);
-              alpha_image_info = (ImageInfo *)NULL;
-              DestroyImage(jng_image);
-              jng_image = (Image *)NULL;
+             else
+                {
+
+                 if (logging)
+                   {
+                     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "    Read jng_image.");
+                     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "      jng_image->width=%lu, jng_image->height=%lu",
+                          (unsigned long)jng_width,(unsigned long)jng_height);
+                     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "      image->rows=%lu, image->columns=%lu",
+                         (unsigned long)image->rows,
+                         (unsigned long)image->columns);
+                   }
+
+                 for (y=0; y < (long) image->rows; y++)
+                   {
+                     s=AcquireImagePixels(jng_image,0,y,image->columns,1,
+                                          &image->exception);
+                     if (s == (PixelPacket *) NULL)
+                       break;
+                     if (image->matte)
+                       {
+                         q=SetImagePixels(image,0,y,image->columns,1);
+                         if (q == (PixelPacket *) NULL)
+                           break;
+                         for (x=(long) image->columns; x > 0; x--,q++,s++)
+                           q->opacity=(Quantum) MaxRGB-s->red;
+                       }
+                     else
+                       {
+                         q=SetImagePixels(image,0,y,image->columns,1);
+                         if (q == (PixelPacket *) NULL)
+                           break;
+                         for (x=(long) image->columns; x > 0; x--,q++,s++)
+                           {
+                             q->opacity=(Quantum) MaxRGB-s->red;
+                             if (q->opacity != OpaqueOpacity)
+                               image->matte=MagickTrue;
+                           }
+                       }
+                     if (!SyncImagePixels(image))
+                       break;
+                   }
+                 (void) LiberateUniqueFileResource(alpha_image->filename);
+                 DestroyJNG(NULL,&color_image,&color_image_info,
+                   &alpha_image,&alpha_image_info);
+                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                     " Destroy the JNG image");
+                 DestroyImage(jng_image);
+                 jng_image = (Image *)NULL;
+               }
             }
         }
 
@@ -3635,13 +3915,8 @@ static Image *ReadOneJNGImage(MngInfo *mng_info,
 
   /* Clean up in case we didn't earlier */
 
-  DestroyJNGInfo(color_image_info,alpha_image_info);
-
-  if (alpha_image != (Image *)NULL)
-    {
-      (void) LiberateUniqueFileResource(alpha_image->filename);
-      DestroyImage(alpha_image);
-    }
+  DestroyJNG(NULL,&color_image,&color_image_info,
+    &alpha_image,&alpha_image_info);
 
   if (logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -3719,18 +3994,43 @@ static Image *ReadJNGImage(const ImageInfo *image_info,
   mng_info=(MngInfo *) NULL;
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
-    ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+  {
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Unable to open file");
+    ThrowException(exception,FileOpenError,UnableToOpenFile,image->filename);
+    DestroyImageList(image);
+    image=(Image *) NULL;
+    return ((Image *)NULL);
+  }
   if (LocaleCompare(image_info->magick,"JNG") != 0)
-    ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+  {
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Improper Image Header");
+    ThrowException(exception,CorruptImageError,ImproperImageHeader,image->filename);
+    DestroyImageList(image);
+    image=(Image *) NULL;
+    return((Image *)NULL);
+  }
   /*
     Verify JNG signature.
   */
   if ((ReadBlob(image,8,magic_number) != 8) ||
       (memcmp(magic_number,"\213JNG\r\n\032\n",8) != 0))
-    ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+  {
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Improper Image Header");
+    ThrowException(exception,CorruptImageError,ImproperImageHeader,image->filename);
+    DestroyImageList(image);
+    image=(Image *) NULL;
+    return((Image *)NULL);
+  }
 
   if (BlobIsSeekable(image) && GetBlobSize(image) < 147)
-    ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,image);
+  {
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+        "Insufficient Image Data");
+    ThrowException(exception,CorruptImageError,InsufficientImageDataInFile,image->filename);
+    DestroyImageList(image);
+    image=(Image *) NULL;
+    return((Image *)NULL);
+  }
 
   /*
     Allocate a MngInfo structure.
@@ -3738,7 +4038,14 @@ static Image *ReadJNGImage(const ImageInfo *image_info,
   have_mng_structure=MagickFalse;
   mng_info=MagickAllocateMemory(MngInfo *,sizeof(MngInfo));
   if (mng_info == (MngInfo *) NULL)
-    ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+  {
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+        "Memory Allocation Failed");
+    ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,image->filename);
+    DestroyImageList(image);
+    image=(Image *) NULL;
+    return((Image *)NULL);
+  }
   /*
     Initialize members of the MngInfo structure.
   */
@@ -3747,23 +4054,28 @@ static Image *ReadJNGImage(const ImageInfo *image_info,
 
   mng_info->image=image;
   image=ReadOneJNGImage(mng_info,image_info,exception);
-  MngInfoFreeStruct(mng_info,&have_mng_structure);
-  if (image == (Image *) NULL)
+  if (image == (Image *) NULL || image->columns == 0 || image->rows == 0)
     {
       if (logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                              "exit ReadJNGImage() with error");
-      return((Image *) NULL);
+            "exit ReadJNGImage() with error");
+      if (image != (Image *) NULL)
+        {
+          DestroyImageList(image);
+          image=(Image *) NULL;
+        }
+      if (mng_info->image != (Image *) NULL)
+        {
+          DestroyImageList(mng_info->image);
+          mng_info->image=(Image *) NULL;
+        }
+      MngInfoFreeStruct(mng_info,&have_mng_structure);
+      return((Image *)NULL);
     }
+
   CloseBlob(image);
-  if (image->columns == 0 || image->rows == 0)
-    {
-      DestroyImageList(image);
-      if (logging)
-        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                              "exit ReadJNGImage() with error");
-      return((Image *) NULL);
-    }
+  MngInfoFreeStruct(mng_info,&have_mng_structure);
+
   if (logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),"exit ReadJNGImage()");
   return (image);
@@ -3852,6 +4164,10 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
     simplicity=0,
     subframe_height=0,
     subframe_width=0;
+
+  magick_off_t
+    blob_size;
+
   previous_fb.top=0;
   previous_fb.bottom=0;
   previous_fb.left=0;
@@ -3874,6 +4190,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+  blob_size=GetBlobSize(image);
   first_mng_object=MagickFalse;
   skipping_loop=(-1);
   have_mng_structure=MagickFalse;
@@ -3898,8 +4215,8 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
       /*
         Verify MNG signature.
       */
-      (void) ReadBlob(image,8,magic_number);
-      if (memcmp(magic_number,"\212MNG\r\n\032\n",8) != 0)
+      if ((ReadBlob(image,8,magic_number) != 8) ||
+          (memcmp(magic_number,"\212MNG\r\n\032\n",8) != 0))
         {
           MngInfoFreeStruct(mng_info,&have_mng_structure);
           ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
@@ -3942,19 +4259,19 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
       if (LocaleCompare(image_info->magick,"MNG") == 0)
         {
           register unsigned char
-            *p;
+            *p = 0;
 
           unsigned char
-            *chunk;
+            *chunk = (unsigned char *) NULL;
 
           /*
             Read a new chunk.
           */
           type[0]='\0';
           (void) strcat(type,"errr");
-          length=ReadBlobMSBLong(image);
+          length=(size_t) ReadBlobMSBLong(image);
           count=ReadBlob(image,4,type);
-          if (count < 4)
+          if (count != 4)
             {
               if (logging)
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -3972,17 +4289,31 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
                                   type[0],type[1],type[2],type[3],length);
 
           if (length > PNG_MAX_UINT)
-            status=MagickFalse;
-          p=NULL;
-          chunk=(unsigned char *) NULL;
+            {
+              MngInfoFreeStruct(mng_info,&have_mng_structure);
+              ThrowReaderException(CorruptImageError,CorruptImage,image);
+            }
+          if (length > (size_t) blob_size)
+            {
+              if (image->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "chunk length (%" MAGICK_SIZE_T_F "u)"
+                                      " is greater than input size"
+                                      " (%" MAGICK_OFF_F "d)",
+                                      (MAGICK_SIZE_T) length,
+                                      blob_size);
+              MngInfoFreeStruct(mng_info,&have_mng_structure);
+              ThrowReaderException(CorruptImageError,CorruptImage,image);
+            }
           if (length)
             {
               chunk=MagickAllocateMemory(unsigned char *,length);
               if (chunk == (unsigned char *) NULL)
                 ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
                                      image);
-              if (ReadBlob(image,length,chunk) < length)
+              if (ReadBlob(image,length,chunk) != length)
                 {
+                  MagickFreeMemory(chunk);
                   MngInfoFreeStruct(mng_info,&have_mng_structure);
                   ThrowReaderException(CorruptImageError,CorruptImage,image);
                 }
@@ -3995,7 +4326,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
             {
               skip_to_iend=MagickTrue;
               if (!mng_info->jhdr_warning)
-                (void) ThrowException(&image->exception,CoderError,
+                (void) ThrowException(exception,CoderError,
                                       JNGCompressionNotSupported,
                                       image->filename);
               mng_info->jhdr_warning++;
@@ -4005,18 +4336,20 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
             {
               skip_to_iend=MagickTrue;
               if (!mng_info->dhdr_warning)
-                (void) ThrowException(&image->exception,CoderError,
+                (void) ThrowException(exception,CoderError,
                                       DeltaPNGNotSupported,image->filename);
               mng_info->dhdr_warning++;
             }
           if (!memcmp(type,mng_MEND,4))
-            break;
+            {
+              MagickFreeMemory(chunk);
+              break;
+            }
           if (skip_to_iend)
             {
               if (!memcmp(type,mng_IEND,4))
                 skip_to_iend=MagickFalse;
-              if (length)
-                MagickFreeMemory(chunk);
+              MagickFreeMemory(chunk);
               if (logging)
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                       "  Skip to IEND.");
@@ -4026,18 +4359,16 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
             {
               if (length < 16)
                 {
+                  MagickFreeMemory(chunk);
+                  MngInfoFreeStruct(mng_info,&have_mng_structure);
                   ThrowReaderException(CorruptImageError,CorruptImage,image);
                 }
 #if defined(GMPNG_SETJMP_NOT_THREAD_SAFE)
               /* To quiet a Coverity complaint */
               LockSemaphoreInfo(png_semaphore);
 #endif
-              mng_info->mng_width=(unsigned long) ((p[0] << 24) |
-                                                   (p[1] << 16) |
-                                                   (p[2] << 8) | p[3]);
-              mng_info->mng_height=(unsigned long) ((p[4] << 24) |
-                                                    (p[5] << 16) |
-                                                    (p[6] << 8) | p[7]);
+              mng_info->mng_width=(unsigned long) mng_get_long(p);
+              mng_info->mng_height=(unsigned long) mng_get_long(&p[4]);
               if (logging)
                 {
                   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -4058,6 +4389,8 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
                   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                       "   MNG width or height too large: %lu, %lu",
                       mng_info->mng_width,mng_info->mng_height);
+                  MagickFreeMemory(chunk);
+                  MngInfoFreeStruct(mng_info,&have_mng_structure);
                   ThrowReaderException(CorruptImageError,ImproperImageHeader,
                       image);
                 }
@@ -4101,11 +4434,18 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
                   mng_info->image=image;
                 }
 
-              if ((mng_info->mng_width > 65535L) || (mng_info->mng_height
-                                                     > 65535L))
-                (void) ThrowException(&image->exception,ImageError,
-                                      WidthOrHeightExceedsLimit,
-                                      image->filename);
+              if ((mng_info->mng_width > 65535L) ||
+                  (mng_info->mng_height > 65535L))
+                {
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                      "  MNG width or height is too large: %lu, %lu",
+                      mng_info->mng_width,mng_info->mng_height);
+                  MagickFreeMemory(chunk);
+                  MngInfoFreeStruct(mng_info,&have_mng_structure);
+                  ThrowReaderException(CorruptImageError,
+                     ImproperImageHeader,image);
+                }
+
               FormatString(page_geometry,"%lux%lu+0+0",mng_info->mng_width,
                            mng_info->mng_height);
               mng_info->frame.left=0;
@@ -4133,7 +4473,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
 
               if (length)
                 repeat=p[0];
-              if (repeat == 3 && length > 8)
+              if (repeat == 3 && length > 9)
                 {
                   final_delay=(png_uint_32) mng_get_long(&p[2]);
                   mng_iterations=(png_uint_32) mng_get_long(&p[6]);
@@ -4158,34 +4498,49 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
           if (!memcmp(type,mng_DEFI,4))
             {
               if (mng_type == 3)
-                (void) ThrowException2(&image->exception,CoderError,
-                                       "DEFI chunk found in MNG-VLC"
-                                       " datastream",
-                                       (char *) NULL);
-              object_id=(p[0] << 8) | p[1];
+                {
+                  if (logging)
+                    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                          "DEFI chunk found in MNG-VLC"
+                                          " datastream");
+                  MagickFreeMemory(chunk);
+                  continue;
+                }
+              if (length < 2)
+                {
+                  if (logging)
+                    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                          "  DEFI chunk must be at least"
+                                          " 2 bytes long");
+                  MagickFreeMemory(chunk);
+                  MngInfoFreeStruct(mng_info,&have_mng_structure);
+                  ThrowReaderException(CorruptImageError,CorruptImage,image);
+                }
+              object_id=((magick_uint32_t) p[0] << 8) | (magick_uint32_t) p[1];
               if (mng_type == 2 && object_id != 0)
-                (void) ThrowException2(&image->exception,CoderError,
+                (void) ThrowException2(exception,CoderError,
                                        "Nonzero object_id in MNG-LC"
                                        " datastream",
                                        (char *) NULL);
-              if (object_id > MNG_MAX_OBJECTS)
+              if (object_id >= MNG_MAX_OBJECTS)
                 {
                   /*
                     Instead of issuing a warning we should allocate a larger
                     MngInfo structure and continue.
                   */
-                  (void) ThrowException2(&image->exception,CoderError,
-                                         "object id too large",(char *) NULL);
-                  object_id=MNG_MAX_OBJECTS;
+                  if (logging)
+                    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                          "object id (%u) too large", object_id);
+                  object_id=MNG_MAX_OBJECTS-1;
                 }
               if (mng_info->exists[object_id])
                 if (mng_info->frozen[object_id])
                   {
+                    if (logging)
+                      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                            "DEFI cannot redefine a frozen"
+                                           " MNG object");
                     MagickFreeMemory(chunk);
-                    (void) ThrowException2(&image->exception,CoderError,
-                                           "DEFI cannot redefine a frozen"
-                                           " MNG object",
-                                           (char *) NULL);
                     continue;
                   }
               mng_info->exists[object_id]=MagickTrue;
@@ -4196,12 +4551,8 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
               */
               if (length > 11)
                 {
-                  mng_info->x_off[object_id]=(long) ((p[4] << 24) |
-                                                     (p[5] << 16) |
-                                                     (p[6] << 8) | p[7]);
-                  mng_info->y_off[object_id]=(long) ((p[8] << 24) |
-                                                     (p[9] << 16) |
-                                                     (p[10] << 8) | p[11]);
+                  mng_info->x_off[object_id]= mng_get_long(&p[4]);
+                  mng_info->y_off[object_id]= mng_get_long(&p[8]);
                   if (logging)
                     {
                       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -4227,11 +4578,14 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
               if (length > 5)
                 {
                   mng_info->mng_global_bkgd.red
-                    =ScaleShortToQuantum(((p[0] << 8) | p[1]));
+                    =ScaleShortToQuantum((((magick_uint32_t) p[0] << 8) |
+                                          (magick_uint32_t) p[1]));
                   mng_info->mng_global_bkgd.green
-                    =ScaleShortToQuantum(((p[2] << 8) | p[3]));
+                    =ScaleShortToQuantum((((magick_uint32_t) p[2] << 8) |
+                                          (magick_uint32_t) p[3]));
                   mng_info->mng_global_bkgd.blue
-                    =ScaleShortToQuantum(((p[4] << 8) | p[5]));
+                    =ScaleShortToQuantum((((magick_uint32_t) p[4] << 8) |
+                                          (magick_uint32_t) p[5]));
                   mng_info->have_global_bkgd=MagickTrue;
                 }
               MagickFreeMemory(chunk);
@@ -4247,16 +4601,20 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
               if (mandatory_back && length > 5)
                 {
                   mng_background_color.red=
-                    ScaleShortToQuantum(((p[0] << 8) | p[1]));
+                    ScaleShortToQuantum((((magick_uint32_t) p[0] << 8) |
+                                         (magick_uint32_t) p[1]));
                   mng_background_color.green=
-                    ScaleShortToQuantum(((p[2] << 8) | p[3]));
+                    ScaleShortToQuantum((((magick_uint32_t) p[2] << 8) |
+                                         (magick_uint32_t) p[3]));
                   mng_background_color.blue=
-                    ScaleShortToQuantum(((p[4] << 8) | p[5]));
+                    ScaleShortToQuantum((((magick_uint32_t) p[4] << 8) |
+                                         (magick_uint32_t) p[5]));
                   mng_background_color.opacity=OpaqueOpacity;
                 }
 #ifdef MNG_OBJECT_BUFFERS
               if (length > 8)
-                mng_background_object=(p[7] << 8) | p[8];
+                mng_background_object=((magick_uint32_t) p[7] << 8) |
+                  (magick_uint32_t) p[8];
 #endif
 #endif
               MagickFreeMemory(chunk);
@@ -4272,6 +4630,14 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
                   if (mng_info->global_plte == (png_colorp) NULL)
                     mng_info->global_plte=
                       MagickAllocateMemory(png_colorp,256*sizeof(png_color));
+                  if (mng_info->global_plte == (png_colorp) NULL)
+                    {
+                      mng_info->global_plte_length=0;
+                      MagickFreeMemory(chunk);
+                      MngInfoFreeStruct(mng_info,&have_mng_structure);
+                      ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                           image);
+                    }
                   for (i=0; i < (long) (length/3); i++)
                     {
                       mng_info->global_plte[i].red=p[3*i];
@@ -4380,14 +4746,13 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
               /*
                 Read global iCCP.
               */
-              if (length)
-                MagickFreeMemory(chunk);
+              MagickFreeMemory(chunk);
               continue;
             }
           if (!memcmp(type,mng_FRAM,4))
             {
               if (mng_type == 3)
-                (void) ThrowException2(&image->exception,CoderError,
+                (void) ThrowException2(exception,CoderError,
                                        "FRAM chunk found in MNG-VLC"
                                        " datastream",
                                        (char *) NULL);
@@ -4410,7 +4775,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
                     Note the delay and frame clipping boundaries.
                   */
                   p++; /* framing mode */
-                  while (*p && ((p-chunk) < (long) length))
+                  while (((p-chunk) < (long) length) && *p)
                     p++;  /* frame name */
                   p++;  /* frame name terminator */
                   if ((p-chunk) < (long) (length-4))
@@ -4424,10 +4789,13 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
                       change_timeout=(*p++);
                       change_clipping=(*p++);
                       p++; /* change_sync */
-                      if (change_delay && (p-chunk) < (ssize_t) (length-4))
+                      if (change_delay && ((p-chunk) < (ssize_t) (length-4)))
                         {
-                          frame_delay=(100*(mng_get_long(p))/
-                                       mng_info->ticks_per_second);
+                          if (mng_info->ticks_per_second == 0)
+                            frame_delay=0;
+                          else
+                            frame_delay=(100*(mng_get_long(p))/
+                                         mng_info->ticks_per_second);
                           if (change_delay == 2)
                             default_frame_delay=frame_delay;
                           p+=4;
@@ -4438,8 +4806,11 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
                         }
                       if (change_timeout && (p-chunk) < (ssize_t) (length-4))
                         {
-                          frame_timeout=
-                            (100*(mng_get_long(p))/mng_info->ticks_per_second);
+                          if (mng_info->ticks_per_second == 0)
+                            frame_timeout=0;
+                          else
+                            frame_timeout=
+                              (100*(mng_get_long(p))/mng_info->ticks_per_second);
                           if (change_timeout == 2)
                             default_frame_timeout=frame_timeout;
                           p+=4;
@@ -4448,10 +4819,10 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
                                                   "    Framing_timeout=%ld",
                                                   frame_timeout);
                         }
-                      if (change_clipping && (p-chunk) < (ssize_t) (length-17))
+                      if (change_clipping && (p-chunk) < (ssize_t) (length-16))
                         {
                           fb=mng_read_box(previous_fb,p[0],&p[1]);
-                          p+=17;
+                          p+=16;
                           previous_fb=fb;
                           if (logging)
                             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -4545,12 +4916,14 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
               */
               if (length > 3)
                 {
-                  first_object=(p[0] << 8) | p[1];
-                  last_object=(p[2] << 8) | p[3];
+                  first_object=((magick_uint32_t) p[0] << 8) | (magick_uint32_t) p[1];
+                  last_object=((magick_uint32_t) p[2] << 8) | (magick_uint32_t) p[3];
                   p+=4;
 
                   for (i=(int) first_object; i <= (int) last_object; i++)
                     {
+                      if (i >= MNG_MAX_OBJECTS)
+                        continue;
                       if (mng_info->exists[i] && !mng_info->frozen[i])
                         {
                           MngBox
@@ -4577,8 +4950,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
                       mng_info->ob[i]->frozen=MagickTrue;
 #endif
                   }
-              if (length)
-                MagickFreeMemory(chunk);
+              MagickFreeMemory(chunk);
               continue;
             }
 
@@ -4587,7 +4959,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
               /*
                 Read DISC or SEEK.
               */
-              if ((length == 0) || !memcmp(type,mng_SEEK,4))
+              if ((length == 0) || (length % 2) || !memcmp(type,mng_SEEK,4))
                 {
                   for (i=1; i < MNG_MAX_OBJECTS; i++)
                     MngInfoDiscardObject(mng_info,i);
@@ -4599,12 +4971,11 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
 
                   for (j=0; j < (long) length; j+=2)
                     {
-                      i=p[j] << 8 | p[j+1];
+                      i=(magick_uint32_t) p[j] << 8 | (magick_uint32_t) p[j+1];
                       MngInfoDiscardObject(mng_info,i);
                     }
                 }
-              if (length)
-                MagickFreeMemory(chunk);
+              MagickFreeMemory(chunk);
               continue;
             }
           if (!memcmp(type,mng_MOVE,4))
@@ -4619,12 +4990,14 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
 
               if (length > 3)
                 {
-                  first_object=(p[0] << 8) | p[1];
-                  last_object=(p[2] << 8) | p[3];
+                  first_object=((magick_uint32_t) p[0] << 8) | (magick_uint32_t) p[1];
+                  last_object=((magick_uint32_t) p[2] << 8) | (magick_uint32_t) p[3];
                   p+=4;
 
                   for (i=(long) first_object; i <= (long) last_object; i++)
                     {
+                      if (i >= MNG_MAX_OBJECTS)
+                        continue;
                       if (mng_info->exists[i] && !mng_info->frozen[i] &&
                           (p-chunk) < (ssize_t) (length-8))
                         {
@@ -4650,29 +5023,62 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
             {
               long loop_iters=1;
 
-              if (length > 0) /* To do: check spec, if empty LOOP is allowed */
+              if (length >= 5) /* To do: check spec, if empty LOOP is allowed */
                 {
-                  loop_level=chunk[0];
+                  loop_level=chunk[0]; /* 1 byte */
                   loops_active++;
                   mng_info->loop_active[loop_level]=1;  /* mark loop active */
                   /*
                     Record starting point.
                   */
-                  loop_iters=mng_get_long(&chunk[1]);
-                  if (loop_iters == 0)
+                  loop_iters=mng_get_long(&chunk[1]); /* 4 bytes */
+                  if (loop_iters <= 0)
                     skipping_loop=loop_level;
                   else
                     {
+                      long
+                        loop_iters_max = 512;
+
+                      const char
+                        *definition_value;
+
+                      if ((definition_value=AccessDefinition(image_info,"mng","maximum-loops")))
+                        loop_iters_max=atol(definition_value);
+                      if (loop_iters > loop_iters_max)
+                        loop_iters=loop_iters_max;
+
+                      /*
+                        The LOOP chunk allows an iteration count in the range 0..2^31-1
+                      */
+                      if (loop_iters >= 2147483647L)
+                        loop_iters=2147483647L;
+                      else if (loop_iters < 0)
+                        loop_iters=1;
+
                       mng_info->loop_jump[loop_level]=TellBlob(image);
                       mng_info->loop_count[loop_level]=loop_iters;
                     }
                   mng_info->loop_iteration[loop_level]=0;
                 }
+              else
+                {
+                  if (logging)
+                    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                          "Ignoring short LOOP chunk (%lu bytes)", length);
+                }
               MagickFreeMemory(chunk);
               continue;
             }
           if (!memcmp(type,mng_ENDL,4))
             {
+              if (length < 1)
+                {
+                  if (logging)
+                    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                          "Ignoring empty ENDL chunk");
+                  MagickFreeMemory(chunk);
+                  continue;
+                }
               loop_level=chunk[0];
               if (skipping_loop > 0)
                 {
@@ -4719,7 +5125,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
           if (!memcmp(type,mng_CLON,4))
             {
               if (!mng_info->clon_warning)
-                (void) ThrowException2(&image->exception,CoderError,
+                (void) ThrowException2(exception,CoderError,
                                        "CLON is not implemented yet",
                                        image->filename);
               mng_info->clon_warning++;
@@ -4739,18 +5145,18 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
                 magn_methy;
 
               if (length > 1)
-                magn_first=(p[0] << 8) | p[1];
+                magn_first=((magick_uint32_t) p[0] << 8) | (magick_uint32_t) p[1];
               else
                 magn_first=0;
               if (length > 3)
-                magn_last=(p[2] << 8) | p[3];
+                magn_last=((magick_uint32_t) p[2] << 8) | (magick_uint32_t) p[3];
               else
                 magn_last=magn_first;
 #ifndef MNG_OBJECT_BUFFERS
               if (magn_first || magn_last)
                 if (!mng_info->magn_warning)
                   {
-                    (void) ThrowException2(&image->exception,CoderError,
+                    (void) ThrowException2(exception,CoderError,
                                            "MAGN is not implemented yet"
                                            " for nonzero objects",
                                            image->filename);
@@ -4763,42 +5169,42 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
                 magn_methx=0;
 
               if (length > 6)
-                magn_mx=(p[5] << 8) | p[6];
+                magn_mx=((magick_uint32_t) p[5] << 8) | (magick_uint32_t) p[6];
               else
                 magn_mx=1;
               if (magn_mx == 0)
                 magn_mx=1;
 
               if (length > 8)
-                magn_my=(p[7] << 8) | p[8];
+                magn_my=((magick_uint32_t) p[7] << 8) | (magick_uint32_t) p[8];
               else
                 magn_my=magn_mx;
               if (magn_my == 0)
                 magn_my=1;
 
               if (length > 10)
-                magn_ml=(p[9] << 8) | p[10];
+                magn_ml=((magick_uint32_t) p[9] << 8) | (magick_uint32_t) p[10];
               else
                 magn_ml=magn_mx;
               if (magn_ml == 0)
                 magn_ml=1;
 
               if (length > 12)
-                magn_mr=(p[11] << 8) | p[12];
+                magn_mr=((magick_uint32_t) p[11] << 8) | (magick_uint32_t) p[12];
               else
                 magn_mr=magn_mx;
               if (magn_mr == 0)
                 magn_mr=1;
 
               if (length > 14)
-                magn_mt=(p[13] << 8) | p[14];
+                magn_mt=((magick_uint32_t) p[13] << 8) | (magick_uint32_t) p[14];
               else
                 magn_mt=magn_my;
               if (magn_mt == 0)
                 magn_mt=1;
 
               if (length > 16)
-                magn_mb=(p[15] << 8) | p[16];
+                magn_mb=((magick_uint32_t) p[15] << 8) | (magick_uint32_t) p[16];
               else
                 magn_mb=magn_my;
               if (magn_mb == 0)
@@ -4812,7 +5218,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
               if (magn_methx > 5 || magn_methy > 5)
                 if (!mng_info->magn_warning)
                   {
-                    (void) ThrowException2(&image->exception,CoderError,
+                    (void) ThrowException2(exception,CoderError,
                                            "Unknown MAGN method in"
                                            " MNG datastream",
                                            image->filename);
@@ -4838,7 +5244,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
           if (!memcmp(type,mng_PAST,4))
             {
               if (!mng_info->past_warning)
-                (void) ThrowException2(&image->exception,CoderError,
+                (void) ThrowException2(exception,CoderError,
                                        "PAST is not implemented yet",
                                        image->filename);
               mng_info->past_warning++;
@@ -4846,7 +5252,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
           if (!memcmp(type,mng_SHOW,4))
             {
               if (!mng_info->show_warning)
-                (void) ThrowException2(&image->exception,CoderError,
+                (void) ThrowException2(exception,CoderError,
                                        "SHOW is not implemented yet",
                                        image->filename);
               mng_info->show_warning++;
@@ -4880,7 +5286,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
           if (!memcmp(type,mng_pHYg,4))
             {
               if (!mng_info->phyg_warning)
-                (void) ThrowException2(&image->exception,CoderError,
+                (void) ThrowException2(exception,CoderError,
                                        "pHYg is not implemented.",
                                        image->filename);
               mng_info->phyg_warning++;
@@ -4889,33 +5295,34 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
             {
               skip_to_iend=MagickTrue;
               if (!mng_info->basi_warning)
-                (void) ThrowException2(&image->exception,CoderError,
+                (void) ThrowException2(exception,CoderError,
                                        "BASI is not implemented yet",
                                        image->filename);
               mng_info->basi_warning++;
 #ifdef MNG_BASI_SUPPORTED
-              basi_width=(unsigned long) ((p[0] << 24) | (p[1] << 16) |
-                                          (p[2] << 8) | p[3]);
-              basi_height=(unsigned long) ((p[4] << 24) | (p[5] << 16) |
-                                           (p[6] << 8) | p[7]);
+              basi_width=(unsigned long) mng_get_long(p);
+                                          ((magick_uint32_t) p[1] << 16) |
+                                          ((magick_uint32_t) p[2] << 8) |
+                                          (magick_uint32_t) p[3]);
+              basi_height=(unsigned long) mng_get_long(&p[4]);
               basi_color_type=p[8];
               basi_compression_method=p[9];
               basi_filter_type=p[10];
               basi_interlace_method=p[11];
               if (length > 11)
-                basi_red=(p[12] << 8) & p[13];
+                basi_red=((magick_uint32_t) p[12] << 8) & (magick_uint32_t) p[13];
               else
                 basi_red=0;
               if (length > 13)
-                basi_green=(p[14] << 8) & p[15];
+                basi_green=((magick_uint32_t) p[14] << 8) & (magick_uint32_t) p[15];
               else
                 basi_green=0;
               if (length > 15)
-                basi_blue=(p[16] << 8) & p[17];
+                basi_blue=((magick_uint32_t) p[16] << 8) & (magick_uint32_t) p[17];
               else
                 basi_blue=0;
               if (length > 17)
-                basi_alpha=(p[18] << 8) & p[19];
+                basi_alpha=((magick_uint32_t) p[18] << 8) & (magick_uint32_t) p[19];
               else
                 {
                   if (basi_sample_depth == 16)
@@ -4938,8 +5345,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
               )
             {
               /* Not an IHDR or JHDR chunk */
-              if (length)
-                MagickFreeMemory(chunk);
+              MagickFreeMemory(chunk);
               continue;
             }
           /* Process IHDR */
@@ -4960,7 +5366,11 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
             }
 #ifdef MNG_INSERT_LAYERS
           if (length < 8)
-            ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+            {
+              MagickFreeMemory(chunk);
+              MngInfoFreeStruct(mng_info,&have_mng_structure);
+              ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+            }
           image_width=mng_get_long(p);
           image_height=mng_get_long(&p[4]);
 #endif
@@ -5140,8 +5550,8 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
 
       if (image == (Image *) NULL)
         {
-          DestroyImageList(previous);
           CloseBlob(previous);
+          DestroyImageList(previous);
           MngInfoFreeStruct(mng_info,&have_mng_structure);
           return((Image *) NULL);
         }
@@ -5313,12 +5723,14 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
                                           large_image->rows);
                   m=mng_info->magn_mt;
                   yy=0;
-                  row_length=(size_t) (image->columns*sizeof(PixelPacket));
+                  row_length=MagickArraySize(image->columns,sizeof(PixelPacket));
                   next=MagickAllocateMemory(PixelPacket *,row_length);
                   prev=MagickAllocateMemory(PixelPacket *,row_length);
                   if ((prev == (PixelPacket *) NULL) ||
                       (next == (PixelPacket *) NULL))
                     {
+                      MagickFreeMemory(next);
+                      MagickFreeMemory(prev);
                       DestroyImageList(image);
                       MngInfoFreeStruct(mng_info,&have_mng_structure);
                       ThrowReaderException(ResourceLimitError,
@@ -5355,8 +5767,10 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
                           assert(yy < (long) large_image->rows);
                           p=prev;
                           n=next;
-                          q=SetImagePixels(large_image,0,yy,
-                                           large_image->columns,1);
+                          q=SetImagePixelsEx(large_image,0,yy,
+                                             large_image->columns,1,exception);
+                          if (q == (const PixelPacket *) NULL)
+                            break;
                           q+=(large_image->columns-image->columns);
                           for (x=(long) image->columns; x > 0; x--)
                             {
@@ -5712,25 +6126,28 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
   while (image->previous != (Image *) NULL)
     {
       image_count++;
+#if 0
+      /* This code triggers and fails to reliease memory in oss-fuzz 8710 */
       if (image_count > 10*mng_info->image_found)
         {
           if (logging)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "  No beginning");
           MngInfoFreeStruct(mng_info,&have_mng_structure);
-          (void) ThrowException2(&image->exception,(ExceptionType) CoderError,
+          (void) ThrowException2(exception,(ExceptionType) CoderError,
                                  "Linked list is corrupted,"
                                  " beginning of list not found",
                                  image_info->filename);
           return((Image *) NULL);
         }
+#endif
       image=image->previous;
       if (image->next == (Image *) NULL)
         {
           if (logging)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "  Corrupt list");
-          (void) ThrowException2(&image->exception,(ExceptionType) CoderError,
+          (void) ThrowException2(exception,(ExceptionType) CoderError,
                                  "Linked list is corrupted;"
                                  " next_image is NULL",
                                  image_info->filename);
@@ -5742,7 +6159,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
       if (logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "  First image null");
-      (void) ThrowException2(&image->exception,(ExceptionType) CoderError,
+      (void) ThrowException2(exception,(ExceptionType) CoderError,
                              "image->next for first image is NULL but"
                              " shouldn't be.",
                              image_info->filename);
@@ -5752,7 +6169,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
       if (logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "  No visible images found.");
-      (void) ThrowException2(&image->exception,(ExceptionType) CoderError,
+      (void) ThrowException2(exception,(ExceptionType) CoderError,
                              "No visible images in file",image_info->filename);
       if (image != (Image *) NULL)
         DestroyImageList(image);
@@ -5815,7 +6232,7 @@ static Image *ReadMNGImage(const ImageInfo *image_info,
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "  Coalesce Images");
       scene=image->scene;
-      next_image=CoalesceImages(image,&image->exception);
+      next_image=CoalesceImages(image,exception);
       if (next_image == (Image *) NULL)
         MagickFatalError2(image->exception.severity,image->exception.reason,
                           image->exception.description);
@@ -5982,7 +6399,7 @@ ModuleExport void RegisterPNGImage(void)
       if (*version != '\0')
         entry->version=version;
       entry->module="PNG";
-      entry->coder_class=PrimaryCoderClass;
+      entry->coder_class=StableCoderClass;
       entry->note=MNGNote;
       (void) RegisterMagickInfo(entry);
 
@@ -6106,6 +6523,7 @@ ModuleExport void RegisterPNGImage(void)
 #endif
 #endif
       entry->magick=(MagickHandler) IsJNG;
+      entry->seekable_stream=MagickTrue;  /* To do: eliminate this. */
       entry->adjoin=MagickFalse;
       entry->thread_support=MagickTrue;
       entry->description="JPEG Network Graphics";
@@ -6113,7 +6531,7 @@ ModuleExport void RegisterPNGImage(void)
       if (*version != '\0')
         entry->version=version;
       entry->module="PNG";
-      entry->coder_class=PrimaryCoderClass;
+      entry->coder_class=StableCoderClass;
       (void) RegisterMagickInfo(entry);
 
 #if defined(GMPNG_SETJMP_NOT_THREAD_SAFE)
@@ -6409,6 +6827,9 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
   logging=LogMagickEvent(CoderEvent,GetMagickModule(),
                          "  enter WriteOnePNGImage()");
 
+  if (imagev == (Image *) NULL)
+    return(MagickFalse);
+
   /* Define these outside of the following "if logging()" block so they will
    * show in debuggers.
    */
@@ -6847,6 +7268,9 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
               unsigned int
                 mask;
 
+              MagickBool
+                opaque = MagickTrue;
+
               mask=0xffff;
               if (ping_bit_depth == 8)
                 mask=0x00ff;
@@ -6869,14 +7293,16 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
                   for (x=(long) image->columns; x > 0; x--)
                     {
                       if (p->opacity != OpaqueOpacity)
-                        break;
+                        {
+                          opaque=MagickFalse;
+                          break;
+                        }
                       p++;
                     }
-                  if (p->opacity != OpaqueOpacity)
+                  if (!opaque)
                     break;
                 }
-              if ((p != (const PixelPacket *) NULL) &&
-                  (p->opacity != OpaqueOpacity))
+              if ((!opaque) && (p != (const PixelPacket *) NULL))
                 {
                   ping_trans_color.red=ScaleQuantumToShort(p->red)&mask;
                   ping_trans_color.green=ScaleQuantumToShort(p->green)
@@ -6935,7 +7361,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
                     }
                   if (x != 0)
                     break;
-                } 
+                }
               if (x != 0)
                 {
                   ping_valid_trns = 0;
@@ -6977,7 +7403,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
           if (image_depth > QuantumDepth)
             image_depth=QuantumDepth;
           if (image_colors == 0 || image_colors-1 > MaxRGB)
-            image_colors=1 << image_depth;
+            image_colors=1U << image_depth;
           if (image_depth > 8)
             ping_bit_depth=16;
           else
@@ -6985,7 +7411,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
               if (ping_colortype == PNG_COLOR_TYPE_PALETTE)
                 {
                   ping_bit_depth=1;
-                  while ((int) (1 << ping_bit_depth) <
+                  while ((int) (1U << ping_bit_depth) <
                                 (long) image_colors)
                     ping_bit_depth <<= 1;
                 }
@@ -7035,7 +7461,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
                     MagickFreeMemory(palette);
                   }
                 ping_bit_depth=1;
-                while ((1UL << ping_bit_depth) < number_colors)
+                while ((1U << ping_bit_depth) < number_colors)
                   ping_bit_depth <<= 1;
                 ping_num_trans=0;
                 if (matte)
@@ -7102,6 +7528,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
                          ping_valid_trns = 0;
                          png_set_invalid(ping, ping_info, PNG_INFO_PLTE);
                          mng_info->IsPalette=MagickFalse;
+                         image_matte=MagickTrue;
                          (void) SyncImage(image);
                          if (logging)
                            (void) LogMagickEvent(CoderEvent,
@@ -7138,12 +7565,14 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
                           png_error(ping, "Could not allocate trans_alpha");
 
                         for (i=0; i<(int) number_colors; i++)
-                          if (trans_alpha[i] == 256)
-                             ping_trans_alpha[i]=255;
-                          else
-                             ping_trans_alpha[i]=(png_byte) trans_alpha[i];
-                         (void) LogMagickEvent(CoderEvent, GetMagickModule(),
-                            "    Alpha[%d]=%d",(int) i, (int) trans_alpha[i]);
+                          {
+                            if (trans_alpha[i] == 256)
+                               ping_trans_alpha[i]=255;
+                            else
+                               ping_trans_alpha[i]=(png_byte) trans_alpha[i];
+                           (void) LogMagickEvent(CoderEvent, GetMagickModule(),
+                              "    Alpha[%d]=%d",(int) i, (int) trans_alpha[i]);
+                          }
                       }
                   }
 
@@ -7180,7 +7609,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
           png_uint_16
             maxval;
 
-          maxval=(1 << ping_bit_depth)-1;
+          maxval=(1U << ping_bit_depth)-1;
 
           ping_trans_color.gray=(png_uint_16)(maxval*
                                 ping_trans_color.gray/
@@ -7316,7 +7745,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
           png_color_16
             background;
 
-          maxval=(1 << ping_bit_depth)-1;
+          maxval=(1U << ping_bit_depth)-1;
 
 
           background.gray=(png_uint_16)
@@ -7335,7 +7764,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
               int
                 maxval;
 
-              maxval=(1 << image_depth)-1;
+              maxval=(1U << image_depth)-1;
               background.red=(png_uint_16)
                 (maxval*image->background_color.red/MaxRGB);
               background.green=(png_uint_16)
@@ -7483,11 +7912,9 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
                                       profile_info,
                                       (png_uint_32) profile_length);
               }
-#ifdef exIf_SUPPORTED
             else if (LocaleCompare(profile_name,"exif") == 0)
-              /* Do not write exif; we'll write it later as exIf */ 
+              /* Do not write exif; we'll write it later as eXIf */
               ;
-#endif
             else
               {
                 if (logging)
@@ -7524,7 +7951,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
         (void) png_set_sRGB(ping,ping_info,PerceptualIntent);
       png_set_gAMA(ping,ping_info,0.45455);
     }
-  if ((!mng_info->write_mng) || 
+  if ((!mng_info->write_mng) ||
        !png_get_valid(ping, ping_info, PNG_INFO_sRGB))
 #endif
     {
@@ -7610,6 +8037,17 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
   /*
     Allocate memory.
   */
+  if (logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "  mng_info: columns=%lu, image_depth=%u, "
+                          "write_png8=%u, write_png24=%u, write_png32=%u "
+                          "write_png48=%u, write_png64=%u, IsPalette=%u, "
+                          "image_matte=%u",
+                          image->columns, image_depth, mng_info->write_png8,
+                          mng_info->write_png24, mng_info->write_png32,
+                          mng_info->write_png48, mng_info->write_png64,
+                          mng_info->IsPalette, image_matte
+                          );
   rowbytes=image->columns;
   if (image_depth <= 8)
     {
@@ -7868,6 +8306,8 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
             }
       }
 
+  MagickFreeMemory(png_pixels);
+
   if (logging)
     {
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -7899,10 +8339,10 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
         text;
 
       if (*attribute->key == '[')
-        continue; 
+        continue;
       if (LocaleCompare(attribute->key,"png:IHDR.color-type-orig") == 0 ||
           LocaleCompare(attribute->key,"png:IHDR.bit-depth-orig") == 0)
-        continue; 
+        continue;
 #if PNG_LIBPNG_VER >= 14000
             text=(png_textp) png_malloc(ping,
                  (png_alloc_size_t) sizeof(png_text));
@@ -7926,9 +8366,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
       png_free(ping,text);
     }
 
-#if defined(exIf_SUPPORTED) || \
-    defined(eXIf_SUPPORTED)
-  /* write exIf profile */
+  /* write eXIf profile */
   {
     ImageProfileIterator
       *profile_iterator;
@@ -7964,11 +8402,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
 
                 length=(png_uint_32) profile_length;
 
-#ifdef eXIf_SUPPORTED /* eXIf chunk is registered */
                 PNGType(chunk,mng_eXIf);
-#else /* eXIf chunk not yet registered; write exIf instead */
-                PNGType(chunk,mng_exIf);
-#endif
 
                 if (length < 7)
                   break;  /* othewise crashes */
@@ -7988,7 +8422,6 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
         DeallocateImageProfileIterator(profile_iterator);
       }
     }
-#endif /* exIf_SUPPORTED) */
 
   if (logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -8048,8 +8481,6 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
   */
   png_destroy_write_struct(&ping,&ping_info);
 
-  MagickFreeMemory(png_pixels);
-
 #if defined(GMPNG_SETJMP_NOT_THREAD_SAFE)
   UnlockSemaphoreInfo(png_semaphore);
 #endif
@@ -8113,7 +8544,7 @@ static MagickPassFail WriteOnePNGImage(MngInfo *mng_info,
 %    o PNG32: An 8-bit per sample RGBA PNG is written.  Partial
 %             transparency is permitted, i.e., the alpha sample for
 %             each pixel can have any value from 0 to 255. The alpha
-%             channel is present even if the image is fully opaque. 
+%             channel is present even if the image is fully opaque.
 %
 %    o PNG48:   A 16-bit per sample RGB PNG datastream is written.  The tRNS
 %               chunk can be present to convey binary transparency by naming
@@ -8649,10 +9080,7 @@ static MagickPassFail WriteOneJNGImage(MngInfo *mng_info,
           p=(unsigned char *) (blob+8);
           for (i=8; i<(long) length; i+=len+12)
             {
-              len=((*(p    ) & 0xff) << 24) +
-                  ((*(p + 1) & 0xff) << 16) +
-                  ((*(p + 2) & 0xff) <<  8) +
-                  ((*(p + 3) & 0xff)      ) ;
+              len=mng_get_long(p);
               p+=4;
               if (*(p)==73 && *(p+1)==68 && *(p+2)==65 && *(p+3)==84)
                 {
index 347901d..136d51b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2013 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -210,19 +210,19 @@ static unsigned int PNMInteger(Image *image,const unsigned int base)
   return(value);
 }
 
-#define ValidateScalingIndex(image, index, max)                                \
-  do                                                                   \
-    {                                                                  \
-      if (index > max)                                                 \
-       ThrowReaderException(CorruptImageError,CorruptImage, image);    \
+#define ValidateScalingIndex(image, index, max)                         \
+  do                                                                    \
+    {                                                                   \
+      if (index > max)                                                  \
+        ThrowReaderException(CorruptImageError,CorruptImage, image);    \
     } while (0)
 
-#define ValidateScalingPixel(image, pixel, max)                \
-  do                                                   \
-    {                                                  \
-      ValidateScalingIndex(image, pixel.red, max);     \
-      ValidateScalingIndex(image, pixel.green, max);   \
-      ValidateScalingIndex(image, pixel.blue, max);    \
+#define ValidateScalingPixel(image, pixel, max)         \
+  do                                                    \
+    {                                                   \
+      ValidateScalingIndex(image, pixel.red, max);      \
+      ValidateScalingIndex(image, pixel.green, max);    \
+      ValidateScalingIndex(image, pixel.blue, max);     \
     } while (0)
 
 typedef enum
@@ -309,224 +309,224 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
         ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
 
       if (c != 'P')
-       {
-         (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Read %c rather than expected 'P'!",c);
-         ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
-       }
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Read %c rather than expected 'P'!",c);
+          ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+        }
 
       c=ReadBlobByte(image);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"PNM Format Id: P%c",
                             c);
 
       switch (c)
-       {
-       case '1': format=PBM_ASCII_Format; break;
-       case '2': format=PGM_ASCII_Format; break;
-       case '3': format=PPM_ASCII_Format; break;
-       case '4': format=PBM_RAW_Format; break;
-       case '5': format=PGM_RAW_Format; break;
-       case '6': format=PPM_RAW_Format; break;
-       case '7':
-         {
-           if ((ReadBlobByte(image) == ' ') && 
-               (PNMInteger(image,10) == 332))
-             format=XV_332_Format;
-           else
-             format=PAM_Format;
-           break;
-         }
-       default:
-         {
-           format=Undefined_PNM_Format;
-         }
-       }
+        {
+        case '1': format=PBM_ASCII_Format; break;
+        case '2': format=PGM_ASCII_Format; break;
+        case '3': format=PPM_ASCII_Format; break;
+        case '4': format=PBM_RAW_Format; break;
+        case '5': format=PGM_RAW_Format; break;
+        case '6': format=PPM_RAW_Format; break;
+        case '7':
+          {
+            if ((ReadBlobByte(image) == ' ') &&
+                (PNMInteger(image,10) == 332))
+              format=XV_332_Format;
+            else
+              format=PAM_Format;
+            break;
+          }
+        default:
+          {
+            format=Undefined_PNM_Format;
+          }
+        }
 
       if (PAM_Format == format)
-       {
-         /*
-           PAM header format
-
-           P7
-           WIDTH 227
-           HEIGHT 149
-           DEPTH 3
-           MAXVAL 255
-           TUPLTYPE RGB
-           ENDHDR
-         */
-
-         char
-           keyword[MaxTextExtent];
-
-         register char
-           *p;
-
-         int
-           c;
-
-         while (1)
-           {
-             p=keyword;
-             c=ReadBlobByte(image);
-             do
-               {
-                 if (isalnum(c) || ('#' == c))
-                   if ((p-keyword) < (MaxTextExtent-1))
-                     *p++=c;
-                 c=ReadBlobByte(image);
-               } while (isalnum(c) || ('#' == c));
-             *p='\0';
-
-             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                   "Keyword \"%s\"",keyword);
-             if ((EOF == c) || (LocaleCompare(keyword,"ENDHDR") == 0))
-               {
-                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                       "Exiting header!");
-                 break;
-               }
-             else if (LocaleCompare(keyword,"HEIGHT") == 0)
-               {
-                 image->rows=PNMInteger(image,10);
-               }
-             else if (LocaleCompare(keyword,"WIDTH") == 0)
-               {
-                 image->columns=PNMInteger(image,10);
-               }
-             else if (LocaleCompare(keyword,"DEPTH") == 0)
-               {
-                 samples_per_pixel=PNMInteger(image,10);
-               }
-             else if (LocaleCompare(keyword,"MAXVAL") == 0)
-               {
-                 max_value=PNMInteger(image,10);
-               }
-             else if (LocaleCompare(keyword,"TUPLTYPE") == 0)
-               {
-                 /* Skip white space */
-                 do
-                   {
-                     c=ReadBlobByte(image);
-                   } while (isspace(c) && (EOF != c));
-                 if (EOF == c)
-                   break;
-                 /* Tupletype argument */
-                 p=keyword;
-                 do
-                   {
-                     if ((p-keyword) < (MaxTextExtent-1))
-                       *p++=c;
-                     c=ReadBlobByte(image);
-                   } while (('\n' != c) && (EOF != c));
-                 *p='\0';
-                 if (EOF == c)
-                   break;
-                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                       "TUPLTYPE \"%s\"",keyword);
-                 if (LocaleNCompare(keyword,"BLACKANDWHITE",13) == 0)
-                   {
-                     image->colorspace=GRAYColorspace;
-                     image->is_monochrome=MagickTrue;
-                   }
-                 else if (LocaleNCompare(keyword,"CMYK",4) == 0)
-                   {
-                     image->colorspace=CMYKColorspace;
-                   }
-                 else if (LocaleNCompare(keyword,"GRAYSCALE",9) == 0)
-                   {
-                     image->colorspace=GRAYColorspace;
-                   }
-                 else if (LocaleNCompare(keyword,"RGB",3) == 0)
-                   {
-                   }
-
-                 /*
-                   Check for alpha flag.
-                 */
-                 count=strlen(keyword);
-                 if ((count > 6) && (LocaleNCompare(keyword+count-6,"_ALPHA",6) == 0))
-                   {
-                     image->matte=MagickTrue;
-                   }
-               }
-             else if (LocaleNCompare(keyword,"#",1) == 0)
-               {
-                 /* Skip white space */
-                 do
-                   {
-                     c=ReadBlobByte(image);
-                   } while (isspace(c) && (EOF != c));
-                 if (EOF == c)
-                   break;
-
-                 /* Comment */
-                 p=keyword;
-                 do
-                   {
-                     if ((p-keyword) < (MaxTextExtent-1))
-                       *p++=c;
-                     c=ReadBlobByte(image);
-                   } while (('\n' != c) && (EOF != c));
-                 *p='\0';
-                 (void) SetImageAttribute(image,"comment",keyword);
-                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                       "Comment: \"%s\"",keyword);
-               }
-             else
-               {
-                 /* Unknown! */
-                 do
-                   {
-                     c=ReadBlobByte(image);
-                   } while (('\n' != c) && (EOF != c));
-                 break;
-               }
-           }
-       }
+        {
+          /*
+            PAM header format
+
+            P7
+            WIDTH 227
+            HEIGHT 149
+            DEPTH 3
+            MAXVAL 255
+            TUPLTYPE RGB
+            ENDHDR
+          */
+
+          char
+            keyword[MaxTextExtent];
+
+          register char
+            *p;
+
+          int
+            c;
+
+          while (1)
+            {
+              p=keyword;
+              c=ReadBlobByte(image);
+              do
+                {
+                  if (isalnum(c) || ('#' == c))
+                    if ((p-keyword) < (MaxTextExtent-1))
+                      *p++=c;
+                  c=ReadBlobByte(image);
+                } while (isalnum(c) || ('#' == c));
+              *p='\0';
+
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Keyword \"%s\"",keyword);
+              if ((EOF == c) || (LocaleCompare(keyword,"ENDHDR") == 0))
+                {
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                        "Exiting header!");
+                  break;
+                }
+              else if (LocaleCompare(keyword,"HEIGHT") == 0)
+                {
+                  image->rows=PNMInteger(image,10);
+                }
+              else if (LocaleCompare(keyword,"WIDTH") == 0)
+                {
+                  image->columns=PNMInteger(image,10);
+                }
+              else if (LocaleCompare(keyword,"DEPTH") == 0)
+                {
+                  samples_per_pixel=PNMInteger(image,10);
+                }
+              else if (LocaleCompare(keyword,"MAXVAL") == 0)
+                {
+                  max_value=PNMInteger(image,10);
+                }
+              else if (LocaleCompare(keyword,"TUPLTYPE") == 0)
+                {
+                  /* Skip white space */
+                  do
+                    {
+                      c=ReadBlobByte(image);
+                    } while (isspace(c) && (EOF != c));
+                  if (EOF == c)
+                    break;
+                  /* Tupletype argument */
+                  p=keyword;
+                  do
+                    {
+                      if ((p-keyword) < (MaxTextExtent-1))
+                        *p++=c;
+                      c=ReadBlobByte(image);
+                    } while (('\n' != c) && (EOF != c));
+                  *p='\0';
+                  if (EOF == c)
+                    break;
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                        "TUPLTYPE \"%s\"",keyword);
+                  if (LocaleNCompare(keyword,"BLACKANDWHITE",13) == 0)
+                    {
+                      image->colorspace=GRAYColorspace;
+                      image->is_monochrome=MagickTrue;
+                    }
+                  else if (LocaleNCompare(keyword,"CMYK",4) == 0)
+                    {
+                      image->colorspace=CMYKColorspace;
+                    }
+                  else if (LocaleNCompare(keyword,"GRAYSCALE",9) == 0)
+                    {
+                      image->colorspace=GRAYColorspace;
+                    }
+                  else if (LocaleNCompare(keyword,"RGB",3) == 0)
+                    {
+                    }
+
+                  /*
+                    Check for alpha flag.
+                  */
+                  count=strlen(keyword);
+                  if ((count > 6) && (LocaleNCompare(keyword+count-6,"_ALPHA",6) == 0))
+                    {
+                      image->matte=MagickTrue;
+                    }
+                }
+              else if (LocaleNCompare(keyword,"#",1) == 0)
+                {
+                  /* Skip white space */
+                  do
+                    {
+                      c=ReadBlobByte(image);
+                    } while (isspace(c) && (EOF != c));
+                  if (EOF == c)
+                    break;
+
+                  /* Comment */
+                  p=keyword;
+                  do
+                    {
+                      if ((p-keyword) < (MaxTextExtent-1))
+                        *p++=c;
+                      c=ReadBlobByte(image);
+                    } while (('\n' != c) && (EOF != c));
+                  *p='\0';
+                  (void) SetImageAttribute(image,"comment",keyword);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                        "Comment: \"%s\"",keyword);
+                }
+              else
+                {
+                  /* Unknown! */
+                  do
+                    {
+                      c=ReadBlobByte(image);
+                    } while (('\n' != c) && (EOF != c));
+                  break;
+                }
+            }
+        }
       else
-       {
-         /*
-           PNM header type format
-
-           P1
-           # feep.pbm
-           24 7
-
-           P3
-           # feep.ppm
-           4 4
-           15
-         */
-         image->columns=PNMInteger(image,10);
-         image->rows=PNMInteger(image,10);
-
-         if ((format == PBM_ASCII_Format) || (format == PBM_RAW_Format))
-           max_value=1;  /* bitmap */
-         else
-           max_value=PNMInteger(image,10);
-
-         switch (format)
-           {
-           case PBM_ASCII_Format:
-           case PBM_RAW_Format:
-           case PGM_ASCII_Format:
-           case PGM_RAW_Format:
-           case XV_332_Format:
-             {
-               samples_per_pixel=1;
-               break;
-             }
-           case PPM_ASCII_Format:
-           case PPM_RAW_Format:
-             {
-               samples_per_pixel=3;
-               break;
-             }
-           default:
-             {
-             }
-           }
-       }
+        {
+          /*
+            PNM header type format
+
+            P1
+            # feep.pbm
+            24 7
+
+            P3
+            # feep.ppm
+            4 4
+            15
+          */
+          image->columns=PNMInteger(image,10);
+          image->rows=PNMInteger(image,10);
+
+          if ((format == PBM_ASCII_Format) || (format == PBM_RAW_Format))
+            max_value=1;  /* bitmap */
+          else
+            max_value=PNMInteger(image,10);
+
+          switch (format)
+            {
+            case PBM_ASCII_Format:
+            case PBM_RAW_Format:
+            case PGM_ASCII_Format:
+            case PGM_RAW_Format:
+            case XV_332_Format:
+              {
+                samples_per_pixel=1;
+                break;
+              }
+            case PPM_ASCII_Format:
+            case PPM_RAW_Format:
+              {
+                samples_per_pixel=3;
+                break;
+              }
+            default:
+              {
+              }
+            }
+        }
 
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Dimensions: %lux%lu",
                             image->columns,image->rows);
@@ -534,32 +534,35 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
         ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
 
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Max Value: %u",
-                           max_value);
+                            max_value);
       if ((max_value == 0) || (max_value > 4294967295U))
         ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
 
+      if ((format == XV_332_Format) && (max_value != 255))
+        ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+
       bits_per_sample=0;
       if (max_value <= 1)
-       bits_per_sample=1;
+        bits_per_sample=1;
       else if (max_value <= 255U)
-       bits_per_sample=8;
+        bits_per_sample=8;
       else if (max_value <= 65535U)
-       bits_per_sample=16;
+        bits_per_sample=16;
       else if (max_value <= 4294967295U)
-       bits_per_sample=32;
+        bits_per_sample=32;
 
       image->depth=Min(bits_per_sample,QuantumDepth);
 
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Image Depth: %u",
                             image->depth);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Samples Per Pixel: %u",
-                           samples_per_pixel);
+                            samples_per_pixel);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Bits Per Sample: %u",
-                           bits_per_sample);
+                            bits_per_sample);
 
       if (EOFBlob(image))
-       ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
-                      image->filename);
+        ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
+                       image->filename);
 
       if ((1 == samples_per_pixel) && (max_value < MaxColormapSize))
         {
@@ -569,7 +572,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Colors: %u",
                                 image->colors);
         }
-      number_pixels=image->columns*image->rows;
+      number_pixels=MagickArraySize(image->columns,image->rows);
       if (number_pixels == 0)
         ThrowReaderException(CorruptImageError,NegativeOrZeroImageSize,image);
       if (image->storage_class == PseudoClass)
@@ -577,6 +580,9 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           /*
             Create colormap.
           */
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Allocating colormap with %u colors",
+                                image->colors);
           if (!AllocateImageColormap(image,image->colors))
             ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
                                  image);
@@ -619,7 +625,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             */
             register unsigned long
               x;
-            
+
             register PixelPacket
               *q;
 
@@ -644,7 +650,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   if (QuantumTick(y,image->rows))
                     if (!MagickMonitorFormatted(y,image->rows,exception,
                                                 LoadImageText,image->filename,
-                                               image->columns,image->rows))
+                                                image->columns,image->rows))
                       break;
                 if (EOFBlob(image))
                   break;
@@ -663,7 +669,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             */
             register unsigned long
               x;
-            
+
             register PixelPacket
               *q;
 
@@ -681,43 +687,43 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 q=SetImagePixels(image,0,y,image->columns,1);
                 if (q == (PixelPacket *) NULL)
                   break;
-               if (image->storage_class == PseudoClass)
-                 {
-                   /*
-                     PseudoClass
-                   */
-                   indexes=AccessMutableIndexes(image);
-                   for (x=0; x < image->columns; x++)
-                     {
-                       intensity=PNMInteger(image,10);
-                       ValidateScalingIndex(image, intensity, max_value);
-                       if (EOFBlob(image))
-                         break;
-                       index=intensity;
-                       VerifyColormapIndex(image,index);
-                       indexes[x]=index;
-                       *q=image->colormap[index];
-                       is_monochrome &= IsMonochrome(*q);
-                       q++;
-                     }
-                 }
-               else
-                 {
-                   /*
-                     DirectClass
-                   */
-                   for (x=0; x < image->columns; x++)
-                     {
-                       intensity=PNMInteger(image,10);
-                       ValidateScalingIndex(image, intensity, max_value);
-                       if (EOFBlob(image))
-                         break;
+                if (image->storage_class == PseudoClass)
+                  {
+                    /*
+                      PseudoClass
+                    */
+                    indexes=AccessMutableIndexes(image);
+                    for (x=0; x < image->columns; x++)
+                      {
+                        intensity=PNMInteger(image,10);
+                        ValidateScalingIndex(image, intensity, max_value);
+                        if (EOFBlob(image))
+                          break;
+                        index=intensity;
+                        VerifyColormapIndex(image,index);
+                        indexes[x]=index;
+                        *q=image->colormap[index];
+                        is_monochrome &= IsMonochrome(*q);
+                        q++;
+                      }
+                  }
+                else
+                  {
+                    /*
+                      DirectClass
+                    */
+                    for (x=0; x < image->columns; x++)
+                      {
+                        intensity=PNMInteger(image,10);
+                        ValidateScalingIndex(image, intensity, max_value);
+                        if (EOFBlob(image))
+                          break;
                         intensity=ScaleAnyToQuantum(intensity, max_value);
-                       q->red=q->green=q->blue=intensity;
-                       is_monochrome &= IsMonochrome(*q);
-                       q++;
-                     }
-                 }
+                        q->red=q->green=q->blue=intensity;
+                        is_monochrome &= IsMonochrome(*q);
+                        q++;
+                      }
+                  }
                 if (EOFBlob(image))
                   break;
                 if (!SyncImagePixels(image))
@@ -726,7 +732,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   if (QuantumTick(y,image->rows))
                     if (!MagickMonitorFormatted(y,image->rows,exception,
                                                 LoadImageText,image->filename,
-                                               image->columns,image->rows))
+                                                image->columns,image->rows))
                       break;
               }
             image->is_monochrome=is_monochrome;
@@ -743,7 +749,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             */
             register unsigned long
               x;
-            
+
             register PixelPacket
               *q;
 
@@ -784,7 +790,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   if (QuantumTick(y,image->rows))
                     if (!MagickMonitorFormatted(y,image->rows,exception,
                                                 LoadImageText,image->filename,
-                                               image->columns,image->rows))
+                                                image->columns,image->rows))
                       break;
               }
             image->is_monochrome=is_monochrome;
@@ -797,30 +803,31 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
         case PBM_RAW_Format:
         case PGM_RAW_Format:
         case PPM_RAW_Format:
-       case PAM_Format:
+        case PAM_Format:
         case XV_332_Format:
-         {
+          {
             /*
               Convert PBM/PGM/PPM/PAM/XV raw raster image to pixel packets.
             */
-           ImportPixelAreaOptions
+            ImportPixelAreaOptions
               import_options;
 
-           QuantumType
-             quantum_type;
+            QuantumType
+              quantum_type;
 
             size_t
               bytes_per_row;
-        
+
             MagickBool
-             check_pixels,
+              check_pixels,
               is_grayscale,
               is_monochrome,
               use_scaling;
-        
+
             unsigned long
+              max_value_given_bits,
               row_count=0;
-        
+
             ThreadViewDataSet
               *scanline_set;
 
@@ -835,87 +842,150 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               pnm_read_threads = PNMReadThreads;
 #endif
 
-           (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Reading PAM");
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Reading PAM");
+
+            ImportPixelAreaOptionsInit(&import_options);
 
-           ImportPixelAreaOptionsInit(&import_options);
-           check_pixels=MagickTrue;
+            check_pixels=MagickTrue;
             is_grayscale=MagickTrue;
             is_monochrome=MagickTrue;
 
-           /*
-             Deduce correct import parameters.
-           */
-           quantum_type=UndefinedQuantum;
-           import_options.grayscale_miniswhite=MagickFalse;
-            sample_max=RoundDoubleToQuantum((MaxRGBDouble*max_value)/
-                                            MaxValueGivenBits(bits_per_sample));
+            /*
+              Deduce correct import parameters.
+            */
+            quantum_type=UndefinedQuantum;
+            import_options.grayscale_miniswhite=MagickFalse;
+            max_value_given_bits=MaxValueGivenBits(bits_per_sample);
+            if (max_value_given_bits == 0UL)
+              {
+                ThrowException(exception,CorruptImageError,ImproperImageHeader,
+                               image->filename);
+                break;
+              }
+            sample_max=RoundDoubleToQuantum((MaxRGBDouble*max_value)/max_value_given_bits);
+            if (sample_max == 0U)
+              {
+                ThrowException(exception,CorruptImageError,ImproperImageHeader,
+                               image->filename);
+                break;
+              }
             sample_scale=MaxRGBDouble/sample_max;
             use_scaling=(MaxRGB != sample_max);
-           bytes_per_row=0;
-           if (1 == samples_per_pixel)
-             {
-               if (1 == bits_per_sample)
-                 {
-                   /* PBM */
-                   bytes_per_row=((image->columns+7) >> 3);
-                   import_options.grayscale_miniswhite=MagickTrue;
-                   quantum_type=GrayQuantum;
-                 }
-               else
-                 {
-                   /* PGM & XV_332 */
-                   bytes_per_row=((bits_per_sample+7)/8)*image->columns;
-                   if (XV_332_Format == format)
-                     {
-                       quantum_type=IndexQuantum;
-                     }
-                   else
-                     {
-                       quantum_type=GrayQuantum;
-                     }
-                 }
-             }
-           else
-             {
-               bytes_per_row=(((bits_per_sample+7)/8)*samples_per_pixel)*image->columns;
-               if (3 == samples_per_pixel)
-                 {
-                   /* PPM */
-                   quantum_type=RGBQuantum;
-                 }
-               else if (4 == samples_per_pixel)
-                 {
-                   if (CMYKColorspace == image->colorspace)
-                     quantum_type=CMYKQuantum;
-                   else
-                     quantum_type=RGBAQuantum;
-                 }
-               else if (5 == samples_per_pixel)
-                 {
-                   if (CMYKColorspace == image->colorspace)
-                     quantum_type=CMYKAQuantum;
-                 }
-             }
-
-           if (1 == samples_per_pixel)
-             {
-               check_pixels=MagickFalse;
-             }
-           if (GrayQuantum)
-             {
-               if (1 == bits_per_sample)
-                 {
-                   is_grayscale=MagickTrue;
-                   is_monochrome=MagickTrue;
-                 }
-               else
-                 {
-                   is_grayscale=MagickTrue;
-                   is_monochrome=MagickFalse;
-                 }
-             }
-        
+            bytes_per_row=0;
+
+            if (1 == samples_per_pixel)
+              {
+                if (1 == bits_per_sample)
+                  {
+                    /* PBM */
+                    import_options.grayscale_miniswhite=MagickTrue;
+                    quantum_type=GrayQuantum;
+                  }
+                else
+                  {
+                    /* PGM & XV_332 */
+                    if ((XV_332_Format == format) && (image->storage_class == PseudoClass))
+                      {
+                        quantum_type=IndexQuantum;
+                      }
+                    else
+                      {
+                        quantum_type=GrayQuantum;
+                      }
+                  }
+              }
+            else if (2 == samples_per_pixel && image->matte)
+              {
+                quantum_type=GrayAlphaQuantum;
+              }
+            else if (3 == samples_per_pixel)
+              {
+                /* PPM */
+                quantum_type=RGBQuantum;
+              }
+            else if (4 == samples_per_pixel)
+              {
+                if (CMYKColorspace == image->colorspace)
+                  quantum_type=CMYKQuantum;
+                else
+                  quantum_type=RGBAQuantum;
+              }
+            else if (5 == samples_per_pixel)
+              {
+                if (CMYKColorspace == image->colorspace)
+                  quantum_type=CMYKAQuantum;
+              }
+
+            if (image->logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Import Quantum Type: %s",
+                                    QuantumTypeToString(quantum_type));
+
+            samples_per_pixel=MagickGetQuantumSamplesPerPixel(quantum_type);
+            if (image->logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Samples/Pixel: %u", samples_per_pixel);
+
+            if (1 == bits_per_sample)
+              {
+                /* bytes_per_row=(((size_t) image->columns*samples_per_pixel+7) >> 3); */
+                bytes_per_row=MagickArraySize(image->columns,samples_per_pixel);
+                if (bytes_per_row)
+                  bytes_per_row += 7;
+                if (bytes_per_row)
+                  bytes_per_row >>= 3;
+              }
+            else
+              {
+                bytes_per_row=MagickArraySize(((bits_per_sample+7)/8)*
+                                              samples_per_pixel,image->columns);
+              }
+
+            if (image->logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Bytes/Row: %" MAGICK_SIZE_T_F "u",
+                                    (MAGICK_SIZE_T) bytes_per_row);
+
+            if (1 == samples_per_pixel)
+              {
+                check_pixels=MagickFalse;
+              }
+            if (GrayQuantum)
+              {
+                if (1 == bits_per_sample)
+                  {
+                    is_grayscale=MagickTrue;
+                    is_monochrome=MagickTrue;
+                  }
+                else
+                  {
+                    is_grayscale=MagickTrue;
+                    is_monochrome=MagickFalse;
+                  }
+              }
+
+            /* Validate file size before allocating memory */
+            if (BlobIsSeekable(image))
+              {
+                const magick_off_t file_size = GetBlobSize(image);
+                const magick_off_t current_offset = TellBlob(image);
+                if ((file_size > 0) &&
+                    (current_offset > 0) &&
+                    (file_size > current_offset))
+                  {
+                    const magick_off_t remaining = file_size-current_offset;
+                    const magick_off_t needed = (magick_off_t) image->rows *
+                      (magick_off_t) bytes_per_row;
+                    if ((remaining < (magick_off_t) bytes_per_row) ||
+                        (remaining < needed))
+                      {
+                        ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
+                                       image->filename);
+                        break;
+                      }
+                  }
+              }
+
             scanline_set=AllocateThreadViewDataArray(image,exception,bytes_per_row,1);
             if (scanline_set == (ThreadViewDataSet *) NULL)
               ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
@@ -939,16 +1009,16 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
                 MagickBool
                   thread_status;
-            
+
                 MagickBool
                   thread_is_grayscale,
                   thread_is_monochrome;
-            
+
                 unsigned long
                   thread_row_count;
 
-               ImportPixelAreaInfo
-                 import_info;
+                ImportPixelAreaInfo
+                  import_info;
 
 #if PNMReadUseOpenMP
 #  pragma omp critical (GM_ReadPNMImage)
@@ -956,28 +1026,28 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 thread_status=status;
                 if (thread_status == MagickFail)
                   continue;
-            
+
                 pixels=AccessThreadViewData(scanline_set);
-            
+
 #if PNMReadUseOpenMP
 #  pragma omp critical (GM_ReadPNMImage)
 #endif
                 {
-                 thread_is_grayscale=is_grayscale;
-                 thread_is_monochrome=is_monochrome;
+                  thread_is_grayscale=is_grayscale;
+                  thread_is_monochrome=is_monochrome;
 
                   if (ReadBlobZC(image,bytes_per_row,&pixels) != bytes_per_row)
                     thread_status=MagickFail;
-              
+
                   thread_row_count=row_count;
                   row_count++;
-              
+
                   if (image->previous == (Image *) NULL)
                     if (QuantumTick(thread_row_count,image->rows))
                       if (!MagickMonitorFormatted(thread_row_count,image->rows,
                                                   exception,LoadImageText,
                                                   image->filename,
-                                                 image->columns,image->rows))
+                                                  image->columns,image->rows))
                         thread_status=MagickFail;
                 }
 
@@ -988,7 +1058,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
                 if (thread_status != MagickFail)
                   if (!ImportImagePixelArea(image,quantum_type,bits_per_sample,pixels,
-                                           &import_options,&import_info))
+                                            &import_options,&import_info))
                     thread_status=MagickFail;
                 /*
                   Scale sub-ranged pixels up to full range if necessary
@@ -1021,15 +1091,15 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   memory.
                 */
                 if (thread_status != MagickFail)
-                 if (check_pixels)
-                   if (thread_is_grayscale || thread_is_monochrome)
-                     for (x=0; x < image->columns; x++)
-                       {
-                         thread_is_grayscale = thread_is_grayscale && IsGray(q[x]);
-                         thread_is_monochrome = thread_is_monochrome && IsMonochrome(q[x]);
-                         if (!thread_is_grayscale && !thread_is_monochrome)
-                           break;
-                       }
+                  if (check_pixels)
+                    if (thread_is_grayscale || thread_is_monochrome)
+                      for (x=0; x < image->columns; x++)
+                        {
+                          thread_is_grayscale = thread_is_grayscale && IsGray(q[x]);
+                          thread_is_monochrome = thread_is_monochrome && IsMonochrome(q[x]);
+                          if (!thread_is_grayscale && !thread_is_monochrome)
+                            break;
+                        }
 
                 if (thread_status != MagickFail)
                   if (!SyncImagePixels(image))
@@ -1055,8 +1125,8 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             if (EOFBlob(image))
               ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
                              image->filename);
-           break;
-         }
+            break;
+          }
         default:
           ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
         }
@@ -1309,6 +1379,9 @@ static unsigned int WritePNMImage(const ImageInfo *image_info,Image *image)
     scene,
     status;
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -1316,6 +1389,7 @@ static unsigned int WritePNMImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == MagickFail)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -1325,731 +1399,774 @@ static unsigned int WritePNMImage(const ImageInfo *image_info,Image *image)
       depth=(image->depth <= 8 ? 8 : image->depth <= 16 ? 16 : 32);
 
       /*
-       Write PNM file header.
+        Write PNM file header.
       */
       format=Undefined_PNM_Format;
       if (LocaleCompare(image_info->magick,"P7") == 0)
-       {
-         format=XV_332_Format;
-       }
+        {
+          format=XV_332_Format;
+        }
       else if (LocaleCompare(image_info->magick,"PPM") == 0)
-       {
-         format=PPM_RAW_Format;
-       }
+        {
+          format=PPM_RAW_Format;
+        }
       else if (LocaleCompare(image_info->magick,"PGM") == 0)
-       {
-         format=PGM_RAW_Format;
-       }
+        {
+          format=PGM_RAW_Format;
+        }
       else if (LocaleCompare(image_info->magick,"PBM") == 0)
-       {
-         format=PBM_RAW_Format;
-       }
+        {
+          format=PBM_RAW_Format;
+        }
       else if (LocaleCompare(image_info->magick,"PAM") == 0)
-       {
-         format=PAM_Format;
-       }
+        {
+          format=PAM_Format;
+        }
       else /* PNM auto format */
-       {
-         ImageCharacteristics
-           characteristics;
-
-         /*
-           Make sure that image is in an RGB type space.
-         */
-         (void) TransformColorspace(image,RGBColorspace);
-           
-         /*
-           Analyze image to be written.
-         */
-         if (!GetImageCharacteristics(image,&characteristics,
-                                      (OptimizeType == image_info->type),
-                                      &image->exception))
-           {
-             CloseBlob(image);
-             return MagickFail;
-           }
-
-         if ((characteristics.monochrome) &&
-             (image_info->type != GrayscaleType) &&
-             (image_info->type != GrayscaleMatteType) &&
-             (image_info->type != TrueColorType) &&
-             (image_info->type != TrueColorMatteType))
-           {
-             /* PBM */
-             format=PBM_RAW_Format;
-           }
-         else if ((characteristics.grayscale) &&
-                  (image_info->type != TrueColorType) &&
-                  (image_info->type != TrueColorMatteType))
-           {
-             /* PGM */
-             format=PGM_RAW_Format;
-           }
-         else
-           {
-             /* PPM */
-             format=PPM_RAW_Format;
-           }
-       }
+        {
+          ImageCharacteristics
+            characteristics;
+
+          /*
+            Make sure that image is in an RGB type space.
+          */
+          (void) TransformColorspace(image,RGBColorspace);
+
+          /*
+            Analyze image to be written.
+          */
+          if (!GetImageCharacteristics(image,&characteristics,
+                                       (OptimizeType == image_info->type),
+                                       &image->exception))
+            {
+              CloseBlob(image);
+              return MagickFail;
+            }
+
+          if ((characteristics.monochrome) &&
+              (image_info->type != GrayscaleType) &&
+              (image_info->type != GrayscaleMatteType) &&
+              (image_info->type != TrueColorType) &&
+              (image_info->type != TrueColorMatteType))
+            {
+              /* PBM */
+              format=PBM_RAW_Format;
+            }
+          else if ((characteristics.grayscale) &&
+                   (image_info->type != TrueColorType) &&
+                   (image_info->type != TrueColorMatteType))
+            {
+              /* PGM */
+              format=PGM_RAW_Format;
+            }
+          else
+            {
+              /* PPM */
+              format=PPM_RAW_Format;
+            }
+        }
 
       /*
-       Check if ASCII subformat is requested.
+        Check if ASCII subformat is requested.
       */
       if ((PBM_RAW_Format == format) || (PGM_RAW_Format == format) | (PPM_RAW_Format == format))
-       {
-         MagickBool
-           ascii = MagickFalse;
-
-         /*
-           If quality is set to zero or "pnm:ascii" is defined, then
-           select an ASCII subformat.
-         */
-         if (image_info->quality == 0)
-           ascii=MagickTrue;
-         else if ((AccessDefinition(image_info,"pnm","ascii")))
-           ascii=MagickTrue;
-
-         if (ascii)
-           {
-             if (PBM_RAW_Format == format)
-               format=PBM_ASCII_Format;
-             else if (PGM_RAW_Format == format)
-               format=PGM_ASCII_Format;
-             else if (PPM_RAW_Format == format)
-               format=PPM_ASCII_Format;
-           }
-       }
+        {
+          MagickBool
+            ascii = MagickFalse;
+
+          /*
+            If quality is set to zero or "pnm:ascii" is defined, then
+            select an ASCII subformat.
+          */
+          if (image_info->quality == 0)
+            ascii=MagickTrue;
+          else if ((AccessDefinition(image_info,"pnm","ascii")))
+            ascii=MagickTrue;
+
+          if (ascii)
+            {
+              if (PBM_RAW_Format == format)
+                format=PBM_ASCII_Format;
+              else if (PGM_RAW_Format == format)
+                format=PGM_ASCII_Format;
+              else if (PPM_RAW_Format == format)
+                format=PPM_ASCII_Format;
+            }
+        }
 
       {
-       const char *header = "";
-       switch (format)
-         {
-         case Undefined_PNM_Format: break;
-         case PBM_ASCII_Format: header="P1"; break;
-         case PGM_ASCII_Format: header="P2"; break;
-         case PPM_ASCII_Format: header="P3"; break;
-         case PBM_RAW_Format:   header="P4"; break;
-         case PGM_RAW_Format:   header="P5"; break;
-         case PPM_RAW_Format:   header="P6"; break;
-         case PAM_Format:       header="P7"; break;
-         case XV_332_Format:    header="P7 332"; break;
-         }
-       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Format Id: %s",
-                             header);
-       (void) WriteBlobString(image,header);
-       (void) WriteBlobByte(image,'\n');
+        const char *header = "";
+        switch (format)
+          {
+          case Undefined_PNM_Format: break;
+          case PBM_ASCII_Format: header="P1"; break;
+          case PGM_ASCII_Format: header="P2"; break;
+          case PPM_ASCII_Format: header="P3"; break;
+          case PBM_RAW_Format:   header="P4"; break;
+          case PGM_RAW_Format:   header="P5"; break;
+          case PPM_RAW_Format:   header="P6"; break;
+          case PAM_Format:       header="P7"; break;
+          case XV_332_Format:    header="P7 332"; break;
+          }
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Format Id: %s",
+                              header);
+        (void) WriteBlobString(image,header);
+        (void) WriteBlobByte(image,'\n');
       }
 
       attribute=GetImageAttribute(image,"comment");
       if (attribute != (const ImageAttribute *) NULL)
-       {
-         register char
-           *av;
-
-         /*
-           Write comments to file.
-         */
-         (void) WriteBlobByte(image,'#');
-         for (av=attribute->value; *av != '\0'; av++)
-           {
-             (void) WriteBlobByte(image,*av);
-             if ((*av == '\n') && (*(av+1) != '\0'))
-               (void) WriteBlobByte(image,'#');
-           }
-         (void) WriteBlobByte(image,'\n');
-       }
+        {
+          register char
+            *av;
+
+          /*
+            Write comments to file.
+          */
+          (void) WriteBlobByte(image,'#');
+          for (av=attribute->value; *av != '\0'; av++)
+            {
+              (void) WriteBlobByte(image,*av);
+              if ((*av == '\n') && (*(av+1) != '\0'))
+                (void) WriteBlobByte(image,'#');
+            }
+          (void) WriteBlobByte(image,'\n');
+        }
       if ((PAM_Format != format) && (XV_332_Format != format))
-       {
-         FormatString(buffer,"%lu %lu\n",image->columns,image->rows);
-         (void) WriteBlobString(image,buffer);
-       }
+        {
+          FormatString(buffer,"%lu %lu\n",image->columns,image->rows);
+          (void) WriteBlobString(image,buffer);
+        }
       /*
-       Write PNM raster pixels.
+        Write PNM raster pixels.
       */
       switch (format)
-       {
-       case PBM_ASCII_Format:
-         {
-           unsigned int
-             polarity;
-
-           size_t
-             j;
-
-           /*
-             Convert image to a PBM ASCII image.
-           */
-           (void) SetImageType(image,BilevelType);
-           polarity=PixelIntensityToQuantum(&image->colormap[0]) < (MaxRGB/2);
-           if (image->colors == 2)
-             polarity=PixelIntensityToQuantum(&image->colormap[0]) <
-               PixelIntensityToQuantum(&image->colormap[1]);
-           i=0;
-           j=0;
-           for (y=0; y < image->rows; y++)
-             {
-               p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
-               if (p == (const PixelPacket *) NULL)
-                 {
-                   status=MagickFail;
-                   break;
-                 }
-               indexes=AccessImmutableIndexes(image);
-               for (x=0; x < image->columns; x++)
-                 {
-                   buffer[j++] = (indexes[x] == polarity ? '0' : '1');
-                   buffer[j++] = ' ';
-                   i++;
-                   if (i == 36)
-                     {
-                       buffer[j++] = '\n';
-                       i=0;
-                     }
-                   if (j+4 > sizeof(buffer))
-                     {
-                       status=(WriteBlob(image,j,buffer) == j);
-                       j=0;
-                       if (MagickFail == status)
-                         break;
-                     }
-                 }
-               if (image->previous == (Image *) NULL)
-                 if (QuantumTick(y,image->rows))
-                   if (!MagickMonitorFormatted(y,image->rows,&image->exception,
-                                               SaveImageText,image->filename,
-                                               image->columns,image->rows))
-                     {
-                       status=MagickFail;
-                       break;
-                     }
-               if (MagickFail == status)
-                 break;
-             }
-           if (MagickFail != status)
-             {
-               if (i != 0)
-                 buffer[j++] = '\n';
-               if (j > 0)
-                 status=(WriteBlob(image,j,buffer) == j);
-             }
-           break;
-         }
-       case PGM_ASCII_Format:
-         {
-           /*
-             Convert image to a PGM ASCII image.
-           */
-           size_t
-             j;
-
-           unsigned int
-             value;
-
-           /*
-             Make sure that image is in an RGB type space.
-           */
-           (void) TransformColorspace(image,RGBColorspace);
-
-           i=0;
-           j=0;
+        {
+        case PBM_ASCII_Format:
+          {
+            unsigned int
+              polarity;
+
+            size_t
+              j;
+
+            /*
+              Convert image to a PBM ASCII image.
+            */
+            (void) SetImageType(image,BilevelType);
+            polarity=PixelIntensityToQuantum(&image->colormap[0]) < (MaxRGB/2);
+            if (image->colors == 2)
+              polarity=PixelIntensityToQuantum(&image->colormap[0]) <
+                PixelIntensityToQuantum(&image->colormap[1]);
+            i=0;
+            j=0;
+            for (y=0; y < image->rows; y++)
+              {
+                p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
+                if (p == (const PixelPacket *) NULL)
+                  {
+                    status=MagickFail;
+                    break;
+                  }
+                indexes=AccessImmutableIndexes(image);
+                for (x=0; x < image->columns; x++)
+                  {
+                    buffer[j++] = (indexes[x] == polarity ? '0' : '1');
+                    buffer[j++] = ' ';
+                    i++;
+                    if (i == 36)
+                      {
+                        buffer[j++] = '\n';
+                        i=0;
+                      }
+                    if (j+4 > sizeof(buffer))
+                      {
+                        status=(WriteBlob(image,j,buffer) == j);
+                        j=0;
+                        if (MagickFail == status)
+                          break;
+                      }
+                  }
+                if (image->previous == (Image *) NULL)
+                  if (QuantumTick(y,image->rows))
+                    if (!MagickMonitorFormatted(y,image->rows,&image->exception,
+                                                SaveImageText,image->filename,
+                                                image->columns,image->rows))
+                      {
+                        status=MagickFail;
+                        break;
+                      }
+                if (MagickFail == status)
+                  break;
+              }
+            if (MagickFail != status)
+              {
+                if (i != 0)
+                  buffer[j++] = '\n';
+                if (j > 0)
+                  status=(WriteBlob(image,j,buffer) == j);
+              }
+            break;
+          }
+        case PGM_ASCII_Format:
+          {
+            /*
+              Convert image to a PGM ASCII image.
+            */
+            size_t
+              j;
+
+            unsigned int
+              value;
+
+            /*
+              Make sure that image is in an RGB type space.
+            */
+            (void) TransformColorspace(image,RGBColorspace);
+
+            i=0;
+            j=0;
 
             value=(depth <=8 ? 255U : depth <= 16 ? 65535U : 4294967295U);
 
-           j += sprintf(&buffer[j],"%u\n",value);
-           for (y=0; y < image->rows; y++)
-             {
-               p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
-               if (p == (const PixelPacket *) NULL)
-                 {
-                   status=MagickFail;
-                   break;
-                 }
-               for (x=0; x < image->columns; x++)
-                 {
-                   if (image->is_grayscale)
-                     index=p->red;
-                   else
-                     index=PixelIntensityToQuantum(p);
-                   if (depth <= 8)
-                     {
-                       /* Use LUT for speed */
-                       value=ScaleQuantumToChar(index);
-                       AppendUnsignedCharValueToString(j,buffer,value);
+            j += sprintf(&buffer[j],"%u\n",value);
+            for (y=0; y < image->rows; y++)
+              {
+                p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
+                if (p == (const PixelPacket *) NULL)
+                  {
+                    status=MagickFail;
+                    break;
+                  }
+                for (x=0; x < image->columns; x++)
+                  {
+                    if (image->is_grayscale)
+                      index=p->red;
+                    else
+                      index=PixelIntensityToQuantum(p);
+                    if (depth <= 8)
+                      {
+                        /* Use LUT for speed */
+                        value=ScaleQuantumToChar(index);
+                        AppendUnsignedCharValueToString(j,buffer,value);
                         buffer[j++] = ' ';
-                     }
+                      }
                     else if (depth <= 16)
-                     {
-                       value=ScaleQuantumToShort(index);
-                       j += sprintf(&buffer[j]," %u",value);
-                     }
+                      {
+                        value=ScaleQuantumToShort(index);
+                        j += sprintf(&buffer[j]," %u",value);
+                      }
                     else
                       {
-                       value=ScaleQuantumToLong(index);
-                       j += sprintf(&buffer[j]," %u",value);
+                        value=ScaleQuantumToLong(index);
+                        j += sprintf(&buffer[j]," %u",value);
+                      }
+
+                    i++;
+                    if (i == 12)
+                      {
+                        buffer[j++] = '\n';
+                        i=0;
+                      }
+                    if (j+8 > sizeof(buffer))
+                      {
+                        status=(WriteBlob(image,j,buffer) == j);
+                        j=0;
+                        if (MagickFail == status)
+                          break;
+                      }
+                    p++;
+                  }
+                if (image->previous == (Image *) NULL)
+                  if (QuantumTick(y,image->rows))
+                    if (!MagickMonitorFormatted(y,image->rows,&image->exception,
+                                                SaveImageText,image->filename,
+                                                image->columns,image->rows))
+                      {
+                        status=MagickFail;
+                        break;
                       }
+                if (MagickFail == status)
+                  break;
+              }
+            if (MagickFail != status)
+              {
+                if (i != 0)
+                  buffer[j++] = '\n';
+                if (j > 0)
+                  status=(WriteBlob(image,j,buffer) == j);
+              }
+            break;
+          }
+        case PPM_ASCII_Format:
+          {
+            /*
+              Convert image to a PPM ASCII image.
+            */
+            size_t
+              j;
+
+            unsigned int
+              value;
 
-                   i++;
-                   if (i == 12)
-                     {
-                       buffer[j++] = '\n';
-                       i=0;
-                     }
-                   if (j+8 > sizeof(buffer))
-                     {
-                       status=(WriteBlob(image,j,buffer) == j);
-                       j=0;
-                       if (MagickFail == status)
-                         break;
-                     }
-                   p++;
-                 }
-               if (image->previous == (Image *) NULL)
-                 if (QuantumTick(y,image->rows))
-                   if (!MagickMonitorFormatted(y,image->rows,&image->exception,
-                                               SaveImageText,image->filename,
-                                               image->columns,image->rows))
-                     {
-                       status=MagickFail;
-                       break;
-                     }
-               if (MagickFail == status)
-                 break;
-             }
-           if (MagickFail != status)
-             {
-               if (i != 0)
-                 buffer[j++] = '\n';
-               if (j > 0)
-                 status=(WriteBlob(image,j,buffer) == j);
-             }
-           break;
-         }
-       case PPM_ASCII_Format:
-         {
-           /*
-             Convert image to a PPM ASCII image.
-           */
-           size_t
-             j;
-
-           unsigned int
-             value;
-
-           /*
-             Make sure that image is in an RGB type space.
-           */
-           (void) TransformColorspace(image,RGBColorspace);
-
-           i=0;
-           j=0;
+            /*
+              Make sure that image is in an RGB type space.
+            */
+            (void) TransformColorspace(image,RGBColorspace);
+
+            i=0;
+            j=0;
 
             value=(depth <=8 ? 255U : (depth <= 16 ? 65535U : 4294967295U));
 
-           j += sprintf(&buffer[j],"%u\n",value);
-           for (y=0; y < image->rows; y++)
-             {
-               p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
-               if (p == (const PixelPacket *) NULL)
-                 {
-                   status=MagickFail;
-                   break;
-                 }
-               for (x=0; x < image->columns; x++)
-                 {
-                   if (depth <= 8)
-                     {
-                       /* Use LUT for speed */
-                       value=ScaleQuantumToChar(p->red);
-                       AppendUnsignedCharValueToString(j,buffer,value);
-                       buffer[j++] = ' ';
-                       value=ScaleQuantumToChar(p->green);
-                       AppendUnsignedCharValueToString(j,buffer,value);
-                       buffer[j++] = ' ';
-                       value=ScaleQuantumToChar(p->blue);
-                       AppendUnsignedCharValueToString(j,buffer,value);
-                       buffer[j++] = ' ';
-                     }
+            j += sprintf(&buffer[j],"%u\n",value);
+            for (y=0; y < image->rows; y++)
+              {
+                p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
+                if (p == (const PixelPacket *) NULL)
+                  {
+                    status=MagickFail;
+                    break;
+                  }
+                for (x=0; x < image->columns; x++)
+                  {
+                    if (depth <= 8)
+                      {
+                        /* Use LUT for speed */
+                        value=ScaleQuantumToChar(p->red);
+                        AppendUnsignedCharValueToString(j,buffer,value);
+                        buffer[j++] = ' ';
+                        value=ScaleQuantumToChar(p->green);
+                        AppendUnsignedCharValueToString(j,buffer,value);
+                        buffer[j++] = ' ';
+                        value=ScaleQuantumToChar(p->blue);
+                        AppendUnsignedCharValueToString(j,buffer,value);
+                        buffer[j++] = ' ';
+                      }
                     else if (depth <= 16)
                       {
-                       j += sprintf(&buffer[j],"%u %u %u ",
+                        j += sprintf(&buffer[j],"%u %u %u ",
                                      ScaleQuantumToShort(p->red),
-                                    ScaleQuantumToShort(p->green),
+                                     ScaleQuantumToShort(p->green),
                                      ScaleQuantumToShort(p->blue));
                       }
-                   else
-                     {
-                       j += sprintf(&buffer[j],"%u %u %u ",
+                    else
+                      {
+                        j += sprintf(&buffer[j],"%u %u %u ",
                                      (unsigned int) ScaleQuantumToLong(p->red),
-                                    (unsigned int) ScaleQuantumToLong(p->green),
+                                     (unsigned int) ScaleQuantumToLong(p->green),
                                      (unsigned int) ScaleQuantumToLong(p->blue));
-                     }
-                   i++;
-                   if (i == 4)
-                     {
-                       buffer[j++] = '\n';
-                       i=0;
-                     }
-                   if (j+(8*3) > sizeof(buffer))
-                     {
-                       status=(WriteBlob(image,j,buffer) == j);
-                       j=0;
-                       if (MagickFail == status)
-                         break;
-                     }
-                   p++;
-                 }
-               if (image->previous == (Image *) NULL)
-                 if (QuantumTick(y,image->rows))
-                   if (!MagickMonitorFormatted(y,image->rows,&image->exception,
-                                               SaveImageText,image->filename,
-                                               image->columns,image->rows))
-                     {
-                       status=MagickFail;
-                       break;
-                     }
-               if (MagickFail == status)
-                 break;
-             }
-           if (MagickFail != status)
-             {
-               if (i != 0)
-                 buffer[j++] = '\n';
-               if (j > 0)
-                 status=(WriteBlob(image,j,buffer) == j);
-             }
-           break;
-         }
-       case PBM_RAW_Format:
-       case PGM_RAW_Format:
-       case PPM_RAW_Format:
-       case PAM_Format:
-         {
-           ExportPixelAreaOptions
+                      }
+                    i++;
+                    if (i == 4)
+                      {
+                        buffer[j++] = '\n';
+                        i=0;
+                      }
+                    if (j+(8*3) > sizeof(buffer))
+                      {
+                        status=(WriteBlob(image,j,buffer) == j);
+                        j=0;
+                        if (MagickFail == status)
+                          break;
+                      }
+                    p++;
+                  }
+                if (image->previous == (Image *) NULL)
+                  if (QuantumTick(y,image->rows))
+                    if (!MagickMonitorFormatted(y,image->rows,&image->exception,
+                                                SaveImageText,image->filename,
+                                                image->columns,image->rows))
+                      {
+                        status=MagickFail;
+                        break;
+                      }
+                if (MagickFail == status)
+                  break;
+              }
+            if (MagickFail != status)
+              {
+                if (i != 0)
+                  buffer[j++] = '\n';
+                if (j > 0)
+                  status=(WriteBlob(image,j,buffer) == j);
+              }
+            break;
+          }
+        case PBM_RAW_Format:
+        case PGM_RAW_Format:
+        case PPM_RAW_Format:
+        case PAM_Format:
+          {
+            ExportPixelAreaOptions
               export_options;
 
             size_t
               bytes_per_row;
 
-           QuantumType
-             quantum_type;
-           
-           unsigned int
-             bits_per_sample,
-             samples_per_pixel;
+            QuantumType
+              quantum_type;
 
-           MagickBool
-             grayscale_miniswhite=MagickFalse;
+            unsigned int
+              bits_per_sample,
+              samples_per_pixel;
+
+            MagickBool
+              grayscale_miniswhite=MagickFalse;
 
-           unsigned char
-             *pixels;
+            unsigned char
+              *pixels;
 
-           /*
-             Deduce correct export parameters.
-           */
+            /*
+              Deduce correct export parameters.
+            */
             bits_per_sample=(depth <=8 ? 8 : (depth <= 16 ? 16 : 32));
-           quantum_type=RGBQuantum;
-           if (PBM_RAW_Format == format)
-             {
-               bits_per_sample=1;
-               grayscale_miniswhite=MagickTrue;
-               quantum_type=GrayQuantum;
-             }
-           else if (PGM_RAW_Format == format)
-             {
-               quantum_type=GrayQuantum;
-             }
-           else if (PPM_RAW_Format == format)
-             {
-               quantum_type=RGBQuantum;
-             }
-           else if (PAM_Format == format)
-             {
-               ImageCharacteristics
-                 characteristics;
-
-               /*
-                 Make sure image is of desired type.
-               */
-               if (UndefinedType != image_info->type)
-                 SetImageType(image,image_info->type);
-
-               /*
-                 Analyze the image to get its characteristics.
-               */
-               if (!GetImageCharacteristics(image,&characteristics,
-                                            (OptimizeType == image_info->type),
-                                            &image->exception))
-                 {
-                   CloseBlob(image);
-                   return MagickFail;
-                 }
-
-               /*
-                 Choose best encoding based on image characteristics.
-               */
-               if (characteristics.cmyk)
-                 {
-                   if (image->matte)
-                     quantum_type=CMYKAQuantum;
-                   else
-                     quantum_type=CMYKQuantum;
-                 }
-               else if (characteristics.monochrome)
-                 {
-                   bits_per_sample=1;
-                   grayscale_miniswhite=MagickTrue;
-
-                   if (image->matte)
-                     quantum_type=GrayAlphaQuantum;
-                   else
-                     quantum_type=GrayQuantum;
-                 }
-               else if (characteristics.grayscale)
-                 {
-                   if (image->matte)
-                     quantum_type=GrayAlphaQuantum;
-                   else
-                     quantum_type=GrayQuantum;
-                 }
-               else
-                 {
-                   if (image->matte)
-                     quantum_type=RGBAQuantum;
-                   else
-                     quantum_type=RGBQuantum;
-                 }
-             }
-
-           samples_per_pixel=MagickGetQuantumSamplesPerPixel(quantum_type);
-
-           if (1 == bits_per_sample)
-             bytes_per_row=((image->columns+7) >> 3);
-           else
-             bytes_per_row=(((bits_per_sample+7)/8)*samples_per_pixel)*image->columns;
-
-           ExportPixelAreaOptionsInit(&export_options);
-           export_options.grayscale_miniswhite=grayscale_miniswhite;
-
-           /*
-             Allocate memory for pixels.
-           */
-           pixels=MagickAllocateMemory(unsigned char *,bytes_per_row);
-           if (pixels == (unsigned char *) NULL)
-             ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,
-                                  image);
-
-           /*
-             Output header details
-           */
-           if (PAM_Format == format)
-             {
-               /*
-                 PAM header
-               */
-               const char *tuple_type=NULL;
-
-               if (GrayQuantum == quantum_type)
+            quantum_type=RGBQuantum;
+            if (PBM_RAW_Format == format)
+              {
+                bits_per_sample=1;
+                grayscale_miniswhite=MagickTrue;
+                quantum_type=GrayQuantum;
+              }
+            else if (PGM_RAW_Format == format)
+              {
+                quantum_type=GrayQuantum;
+              }
+            else if (PPM_RAW_Format == format)
+              {
+                quantum_type=RGBQuantum;
+              }
+            else if (PAM_Format == format)
+              {
+                ImageCharacteristics
+                  characteristics;
+
+                /*
+                  Make sure image is of desired type.
+                */
+                if (UndefinedType != image_info->type)
+                  SetImageType(image,image_info->type);
+
+                /*
+                  Analyze the image to get its characteristics.
+                */
+                if (!GetImageCharacteristics(image,&characteristics,
+                                             (OptimizeType == image_info->type),
+                                             &image->exception))
+                  {
+                    CloseBlob(image);
+                    return MagickFail;
+                  }
+
+                /*
+                  Choose best encoding based on image characteristics.
+                */
+                if (characteristics.cmyk)
+                  {
+                    if (image->matte)
+                      quantum_type=CMYKAQuantum;
+                    else
+                      quantum_type=CMYKQuantum;
+                  }
+                else if (characteristics.monochrome)
+                  {
+                    bits_per_sample=1;
+                    grayscale_miniswhite=MagickTrue;
+
+                    if (image->matte)
+                      quantum_type=GrayAlphaQuantum;
+                    else
+                      quantum_type=GrayQuantum;
+                  }
+                else if (characteristics.grayscale)
+                  {
+                    if (image->matte)
+                      quantum_type=GrayAlphaQuantum;
+                    else
+                      quantum_type=GrayQuantum;
+                  }
+                else
+                  {
+                    if (image->matte)
+                      quantum_type=RGBAQuantum;
+                    else
+                      quantum_type=RGBQuantum;
+                  }
+              }
+            if (image->logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Export Quantum Type: %s",
+                                    QuantumTypeToString(quantum_type));
+
+            samples_per_pixel=MagickGetQuantumSamplesPerPixel(quantum_type);
+            if (image->logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Samples/Pixel: %u", samples_per_pixel);
+
+            if (1 == bits_per_sample)
+              {
+                /* bytes_per_row=(((size_t) image->columns*samples_per_pixel+7) >> 3); */
+                bytes_per_row=MagickArraySize(image->columns,samples_per_pixel);
+                if (bytes_per_row)
+                  bytes_per_row += 7;
+                if (bytes_per_row)
+                  bytes_per_row >>= 3;
+              }
+            else
+              {
+                bytes_per_row=MagickArraySize(((bits_per_sample+7)/8)*
+                                              samples_per_pixel,image->columns);
+              }
+
+            if (image->logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Bytes/Row: %" MAGICK_SIZE_T_F "u",
+                                    (MAGICK_SIZE_T) bytes_per_row);
+
+            ExportPixelAreaOptionsInit(&export_options);
+            export_options.grayscale_miniswhite=grayscale_miniswhite;
+
+            /*
+              Allocate memory for pixels.
+            */
+            pixels=MagickAllocateMemory(unsigned char *,bytes_per_row);
+            if (pixels == (unsigned char *) NULL)
+              ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,
+                                   image);
+
+            /*
+              Output header details
+            */
+            if (PAM_Format == format)
+              {
+                /*
+                  PAM header
+                */
+                const char *tuple_type=NULL;
+
+                if (GrayQuantum == quantum_type)
                   {
                     if (1 == bits_per_sample)
                       tuple_type="BLACKANDWHITE";
                     else
                       tuple_type="GRAYSCALE";
                   }
-               else if (GrayAlphaQuantum == quantum_type)
+                else if (GrayAlphaQuantum == quantum_type)
                   {
                     if (1 == bits_per_sample)
                       tuple_type="BLACKANDWHITE_ALPHA";
                     else
                       tuple_type="GRAYSCALE_ALPHA";
                   }
-               else if (RGBQuantum == quantum_type)
-                 tuple_type="RGB";
-               else if (RGBAQuantum == quantum_type)
-                 tuple_type="RGB_ALPHA";
-               else if (CMYKQuantum == quantum_type)
-                 tuple_type="CMYK";
-               else if (CMYKAQuantum == quantum_type)
-                 tuple_type="CMYK_ALPHA";
-
-               FormatString(buffer,"WIDTH %lu\nHEIGHT %lu\nDEPTH %u\nMAXVAL %lu\nTUPLTYPE %s\n",
-                            image->columns,image->rows,samples_per_pixel,
-                            MaxValueGivenBits(bits_per_sample),tuple_type);
-               WriteBlobString(image,buffer);
-
-               (void) WriteBlobString(image,"ENDHDR\n");
-             }
-           else if ((PGM_RAW_Format == format) || (PPM_RAW_Format == format))
-             {
-               /*
-                 PGM, PPM header
-               */
-               FormatString(buffer,"%lu\n",MaxValueGivenBits(bits_per_sample));
-               WriteBlobString(image,buffer);
-             }
-
-           /*
-             Output pixels
-           */
-           for (y=0; y < image->rows; y++)
-             {
-               p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
-               if (p == (const PixelPacket *) NULL)
-                 break;
-               if (ExportImagePixelArea(image,quantum_type,bits_per_sample,pixels,&export_options,0) == MagickFail)
-                 break;
-               if (WriteBlob(image,bytes_per_row,(char *) pixels) != bytes_per_row)
-                 break;
-               if (image->previous == (Image *) NULL)
-                 if (QuantumTick(y,image->rows))
-                   if (!MagickMonitorFormatted(y,image->rows,&image->exception,
-                                               SaveImageText,image->filename,
-                                               image->columns,image->rows))
-                     break;
-             }
-           MagickFreeMemory(pixels);
-
-           break;
-         }
-       case XV_332_Format:
-         {
-           static const short int
-             dither_red[2][16]=
-             {
-               {-16,  4, -1, 11,-14,  6, -3,  9,-15,  5, -2, 10,-13,  7, -4,  8},
-               { 15, -5,  0,-12, 13, -7,  2,-10, 14, -6,  1,-11, 12, -8,  3, -9}
-             },
-             dither_green[2][16]=
-               {
-                 { 11,-15,  7, -3,  8,-14,  4, -2, 10,-16,  6, -4,  9,-13,  5, -1},
-                 {-12, 14, -8,  2, -9, 13, -5,  1,-11, 15, -7,  3,-10, 12, -6,  0}
-               },
-               dither_blue[2][16]=
-                 {
-                   { -3,  9,-13,  7, -1, 11,-15,  5, -4,  8,-14,  6, -2, 10,-16,  4},
-                   {  2,-10, 12, -8,  0,-12, 14, -6,  3, -9, 13, -7,  1,-11, 15, -5}
-                 };
-
-               long
-                 value;
-
-               Quantum
-                 pixel;
-
-               unsigned short
-                 *blue_map[2][16],
-                 *green_map[2][16],
-                 *red_map[2][16];
-
-               unsigned int
-                 j;
-
-               /*
-                 Allocate and initialize dither maps.
-               */
-               for (i=0; i < 2; i++)
-                 for (j=0; j < 16; j++)
-                   {
-                     red_map[i][j]=MagickAllocateMemory(unsigned short *,
-                                                        256*sizeof(unsigned short));
-                     green_map[i][j]=MagickAllocateMemory(unsigned short *,
-                                                          256*sizeof(unsigned short));
-                     blue_map[i][j]=MagickAllocateMemory(unsigned short *,
-                                                         256*sizeof(unsigned short));
-                     if ((red_map[i][j] == (unsigned short *) NULL) ||
-                         (green_map[i][j] == (unsigned short *) NULL) ||
-                         (blue_map[i][j] == (unsigned short *) NULL))
-                       ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,
-                                            image);
-                   }
-               /*
-                 Initialize dither tables.
-               */
-               for (i=0; i < 2; i++)
-                 for (j=0; j < 16; j++)
-                   for (x=0; x < 256; x++)
-                     {
-                       value=x-16;
-                       if (x < 48)
-                         value=x/2+8;
-                       value+=dither_red[i][j];
-                       red_map[i][j][x]=(unsigned short)
-                         ((value < 0) ? 0 : (value > 255) ? 255 : value);
-                       value=x-16;
-                       if (x < 48)
-                         value=x/2+8;
-                       value+=dither_green[i][j];
-                       green_map[i][j][x]=(unsigned short)
-                         ((value < 0) ? 0 : (value > 255) ? 255 : value);
-                       value=x-32;
-                       if (x < 112)
-                         value=x/2+24;
-                       value+=2*dither_blue[i][j];
-                       blue_map[i][j][x]=(unsigned short)
-                         ((value < 0) ? 0 : (value > 255) ? 255 : value);
-                     }
-               /*
-                 Write pixels.
-               */
-               (void) WriteBlobString(image,"#END_OF_COMMENTS\n");
-               FormatString(buffer,"%lu %lu 255\n",image->columns,image->rows);
-               (void) WriteBlobString(image,buffer);
-               i=0;
-               j=0;
-               for (y=0; y < image->rows; y++)
-                 {
-                   p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
-                   if (p == (const PixelPacket *) NULL)
-                     break;
-                   for (x=0; x < image->columns; x++)
-                     {
-                       if (!image_info->dither)
-                         pixel=(Quantum) ((ScaleQuantumToChar(p->red) & 0xe0) |
-                                          ((ScaleQuantumToChar(p->green) & 0xe0) >> 3) |
-                                          ((ScaleQuantumToChar(p->blue) & 0xc0) >> 6));
-                       else
-                         pixel=(Quantum)
-                           ((red_map[i][j][ScaleQuantumToChar(p->red)] & 0xe0) |
-                            ((green_map[i][j][ScaleQuantumToChar(p->green)] & 0xe0) >> 3) |
-                            ((blue_map[i][j][ScaleQuantumToChar(p->blue)] & 0xc0) >> 6));
-                       (void) WriteBlobByte(image,pixel);
-                       p++;
-                       j++;
-                       if (j == 16)
-                         j=0;
-                     }
-                   i++;
-                   if (i == 2)
-                     i=0;
-                   if (QuantumTick(y,image->rows))
-                     if (!MagickMonitorFormatted(y,image->rows,&image->exception,
-                                                 SaveImageText,image->filename,
-                                                 image->columns,image->rows))
-                       break;
-                 }
-               /*
-                 Free allocated memory.
-               */
-               for (i=0; i < 2; i++)
-                 for (j=0; j < 16; j++)
-                   {
-                     MagickFreeMemory(green_map[i][j]);
-                     MagickFreeMemory(blue_map[i][j]);
-                     MagickFreeMemory(red_map[i][j]);
-                   }
-               break;
-         }
-       case Undefined_PNM_Format:
-         break;
-       }
+                else if (RGBQuantum == quantum_type)
+                  tuple_type="RGB";
+                else if (RGBAQuantum == quantum_type)
+                  tuple_type="RGB_ALPHA";
+                else if (CMYKQuantum == quantum_type)
+                  tuple_type="CMYK";
+                else if (CMYKAQuantum == quantum_type)
+                  tuple_type="CMYK_ALPHA";
+
+                FormatString(buffer,"WIDTH %lu\nHEIGHT %lu\nDEPTH %u"
+                             "\nMAXVAL %lu\nTUPLTYPE %s\n",
+                             image->columns,image->rows,samples_per_pixel,
+                             MaxValueGivenBits(bits_per_sample),tuple_type);
+                if (image->logging)
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                        "PAM Header: WIDTH %lu, HEIGHT %lu, "
+                                        "DEPTH %u, MAXVAL %lu, TUPLTYPE %s",
+                                        image->columns,
+                                        image->rows,samples_per_pixel,
+                                        MaxValueGivenBits(bits_per_sample),
+                                        tuple_type);
+                WriteBlobString(image,buffer);
+
+                (void) WriteBlobString(image,"ENDHDR\n");
+              }
+            else if ((PGM_RAW_Format == format) || (PPM_RAW_Format == format))
+              {
+                /*
+                  PGM, PPM header
+                */
+                FormatString(buffer,"%lu\n",MaxValueGivenBits(bits_per_sample));
+                WriteBlobString(image,buffer);
+              }
+
+            /*
+              Output pixels
+            */
+            for (y=0; y < image->rows; y++)
+              {
+                p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
+                if (p == (const PixelPacket *) NULL)
+                  break;
+                if (ExportImagePixelArea(image,quantum_type,bits_per_sample,pixels,&export_options,0) == MagickFail)
+                  break;
+                if (WriteBlob(image,bytes_per_row,(char *) pixels) != bytes_per_row)
+                  break;
+                if (image->previous == (Image *) NULL)
+                  if (QuantumTick(y,image->rows))
+                    if (!MagickMonitorFormatted(y,image->rows,&image->exception,
+                                                SaveImageText,image->filename,
+                                                image->columns,image->rows))
+                      break;
+              }
+            MagickFreeMemory(pixels);
+
+            break;
+          }
+        case XV_332_Format:
+          {
+            static const short int
+              dither_red[2][16]=
+              {
+                {-16,  4, -1, 11,-14,  6, -3,  9,-15,  5, -2, 10,-13,  7, -4,  8},
+                { 15, -5,  0,-12, 13, -7,  2,-10, 14, -6,  1,-11, 12, -8,  3, -9}
+              },
+              dither_green[2][16]=
+                {
+                  { 11,-15,  7, -3,  8,-14,  4, -2, 10,-16,  6, -4,  9,-13,  5, -1},
+                  {-12, 14, -8,  2, -9, 13, -5,  1,-11, 15, -7,  3,-10, 12, -6,  0}
+                },
+                dither_blue[2][16]=
+                  {
+                    { -3,  9,-13,  7, -1, 11,-15,  5, -4,  8,-14,  6, -2, 10,-16,  4},
+                    {  2,-10, 12, -8,  0,-12, 14, -6,  3, -9, 13, -7,  1,-11, 15, -5}
+                  };
+
+                long
+                  value;
+
+                Quantum
+                  pixel;
+
+                unsigned short
+                  *blue_map[2][16],
+                  *green_map[2][16],
+                  *red_map[2][16];
+
+                unsigned int
+                  j;
+
+                /*
+                  Allocate and initialize dither maps.
+                */
+                memset(blue_map,0,sizeof(blue_map));
+                memset(green_map,0,sizeof(green_map));
+                memset(red_map,0,sizeof(red_map));
+                for (i=0; i < 2; i++)
+                  for (j=0; j < 16; j++)
+                    {
+                      red_map[i][j]=MagickAllocateMemory(unsigned short *,
+                                                         256*sizeof(unsigned short));
+                      green_map[i][j]=MagickAllocateMemory(unsigned short *,
+                                                           256*sizeof(unsigned short));
+                      blue_map[i][j]=MagickAllocateMemory(unsigned short *,
+                                                          256*sizeof(unsigned short));
+                      if ((red_map[i][j] == (unsigned short *) NULL) ||
+                          (green_map[i][j] == (unsigned short *) NULL) ||
+                          (blue_map[i][j] == (unsigned short *) NULL))
+                        {
+                          for (i=0; i < 2; i++)
+                            for (j=0; j < 16; j++)
+                              {
+                                MagickFreeMemory(green_map[i][j]);
+                                MagickFreeMemory(blue_map[i][j]);
+                                MagickFreeMemory(red_map[i][j]);
+                              }
+                          ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,
+                                               image);
+                        }
+                    }
+                /*
+                  Initialize dither tables.
+                */
+                for (i=0; i < 2; i++)
+                  for (j=0; j < 16; j++)
+                    for (x=0; x < 256; x++)
+                      {
+                        value=x-16;
+                        if (x < 48)
+                          value=x/2+8;
+                        value+=dither_red[i][j];
+                        red_map[i][j][x]=(unsigned short)
+                          ((value < 0) ? 0 : (value > 255) ? 255 : value);
+                        value=x-16;
+                        if (x < 48)
+                          value=x/2+8;
+                        value+=dither_green[i][j];
+                        green_map[i][j][x]=(unsigned short)
+                          ((value < 0) ? 0 : (value > 255) ? 255 : value);
+                        value=x-32;
+                        if (x < 112)
+                          value=x/2+24;
+                        value+=2*dither_blue[i][j];
+                        blue_map[i][j][x]=(unsigned short)
+                          ((value < 0) ? 0 : (value > 255) ? 255 : value);
+                      }
+                /*
+                  Write pixels.
+                */
+                (void) WriteBlobString(image,"#END_OF_COMMENTS\n");
+                FormatString(buffer,"%lu %lu 255\n",image->columns,image->rows);
+                (void) WriteBlobString(image,buffer);
+                i=0;
+                j=0;
+                for (y=0; y < image->rows; y++)
+                  {
+                    p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
+                    if (p == (const PixelPacket *) NULL)
+                      break;
+                    for (x=0; x < image->columns; x++)
+                      {
+                        if (!image_info->dither)
+                          pixel=(Quantum) ((ScaleQuantumToChar(p->red) & 0xe0) |
+                                           ((ScaleQuantumToChar(p->green) & 0xe0) >> 3) |
+                                           ((ScaleQuantumToChar(p->blue) & 0xc0) >> 6));
+                        else
+                          pixel=(Quantum)
+                            ((red_map[i][j][ScaleQuantumToChar(p->red)] & 0xe0) |
+                             ((green_map[i][j][ScaleQuantumToChar(p->green)] & 0xe0) >> 3) |
+                             ((blue_map[i][j][ScaleQuantumToChar(p->blue)] & 0xc0) >> 6));
+                        (void) WriteBlobByte(image,pixel);
+                        p++;
+                        j++;
+                        if (j == 16)
+                          j=0;
+                      }
+                    i++;
+                    if (i == 2)
+                      i=0;
+                    if (QuantumTick(y,image->rows))
+                      if (!MagickMonitorFormatted(y,image->rows,&image->exception,
+                                                  SaveImageText,image->filename,
+                                                  image->columns,image->rows))
+                        break;
+                  }
+                /*
+                  Free allocated memory.
+                */
+                for (i=0; i < 2; i++)
+                  for (j=0; j < 16; j++)
+                    {
+                      MagickFreeMemory(green_map[i][j]);
+                      MagickFreeMemory(blue_map[i][j]);
+                      MagickFreeMemory(red_map[i][j]);
+                    }
+                break;
+          }
+        case Undefined_PNM_Format:
+          break;
+        }
       if (image->next == (Image *) NULL)
-       break;
+        break;
       image=SyncNextImageInList(image);
       if (status != MagickFail)
-        status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+        status=MagickMonitorFormatted(scene++,image_list_length,
                                       &image->exception,SaveImagesText,
                                       image->filename);
       if (status == MagickFail)
-       break;
+        break;
     } while (image_info->adjoin);
   if (image_info->adjoin)
     while (image->previous != (Image *) NULL)
index dfd6ab9..e77ee32 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -314,14 +314,14 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
     char
       options[MaxTextExtent],
       arg[MaxTextExtent];
-    
+
     options[0]='\0';
     /*
       Append subrange.
     */
     if (image_info->subrange != 0)
       FormatString(options,"-dFirstPage=%lu -dLastPage=%lu",
-                  image_info->subimage+1,image_info->subimage+image_info->subrange);
+                   image_info->subimage+1,image_info->subimage+image_info->subrange);
     /*
       Append bounding box.
     */
@@ -335,14 +335,14 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
       (void) LiberateTemporaryFile((char *) image_info->filename);
     if(!AcquireTemporaryFileName((char *) image_info->filename))
       {
-       (void) LiberateTemporaryFile(postscript_filename);
-       ThrowReaderTemporaryFileException(image_info->filename);
+        (void) LiberateTemporaryFile(postscript_filename);
+        ThrowReaderTemporaryFileException(image_info->filename);
       }
     FormatString(command,delegate_info->commands,antialias,
-                antialias,density,options,image_info->filename,
-                postscript_filename);
+                 antialias,density,options,image_info->filename,
+                 postscript_filename);
   }
-  (void) MagickMonitorFormatted(0,8,&image->exception,RenderPostscriptText,
+  (void) MagickMonitorFormatted(0,8,exception,RenderPostscriptText,
                                 image_info->filename);
   status=InvokePostscriptDelegate(image_info->verbose,command,exception);
   if (!IsAccessibleAndNotEmpty(image_info->filename))
@@ -361,15 +361,15 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
       status=InvokePostscriptDelegate(image_info->verbose,command,exception);
     }
   (void) LiberateTemporaryFile(postscript_filename);
-  (void) MagickMonitorFormatted(7,8,&image->exception,RenderPostscriptText,
+  (void) MagickMonitorFormatted(7,8,exception,RenderPostscriptText,
                                 image_info->filename);
   if (IsAccessibleAndNotEmpty(image_info->filename))
     {
       /*
-       Read Ghostscript output.
+        Read Ghostscript output.
       */
       ImageInfo
-       *clone_info;
+        *clone_info;
 
       clone_info=CloneImageInfo(image_info);
       clone_info->blob=(void *) NULL;
@@ -395,25 +395,25 @@ static Image *ReadPSImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if (image == (Image *) NULL)
     {
       if (UndefinedException == exception->severity)
-       ThrowException(exception,DelegateError,PostscriptDelegateFailed,filename);
+        ThrowException(exception,DelegateError,PostscriptDelegateFailed,filename);
     }
   else
     {
       do
-       {
-         (void) strlcpy(image->magick,"PS",sizeof(image->magick));
-         (void) strlcpy(image->filename,filename,sizeof(image->filename));
-         next_image=SyncNextImageInList(image);
-         if (next_image != (Image *) NULL)
-           image=next_image;
-       } while (next_image != (Image *) NULL);
+        {
+          (void) strlcpy(image->magick,"PS",sizeof(image->magick));
+          (void) strlcpy(image->filename,filename,sizeof(image->filename));
+          next_image=SyncNextImageInList(image);
+          if (next_image != (Image *) NULL)
+            image=next_image;
+        } while (next_image != (Image *) NULL);
       while (image->previous != (Image *) NULL)
-       image=image->previous;
+        image=image->previous;
       if (image_info->subimage != 0)
         {
           unsigned long
             scene = image_info->subimage;
-          
+
           for (next_image=image;
                next_image != (Image *) NULL;
                next_image=next_image->next)
@@ -946,6 +946,8 @@ static unsigned int WritePSImage(const ImageInfo *image_info,Image *image)
     scene,
     text_size;
 
+  size_t
+    image_list_length;
 
   /*
     Open output image file.
@@ -954,6 +956,7 @@ static unsigned int WritePSImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -1086,7 +1089,7 @@ static unsigned int WritePSImage(const ImageInfo *image_info,Image *image)
             (void) WriteBlobString(image,"%%Orientation: Portrait\n");
             (void) WriteBlobString(image,"%%PageOrder: Ascend\n");
             FormatString(buffer,"%%%%Pages: %lu\n", image_info->adjoin ?
-              (unsigned long) GetImageListLength(image) : 1L);
+              (unsigned long) image_list_length : 1L);
             (void) WriteBlobString(image,buffer);
           }
         (void) WriteBlobString(image,"%%EndComments\n");
@@ -1302,9 +1305,9 @@ static unsigned int WritePSImage(const ImageInfo *image_info,Image *image)
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                               SaveImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
-            } 
+            }
             if (bp != buffer)
               {
                 *bp++='\n';
@@ -1372,7 +1375,7 @@ static unsigned int WritePSImage(const ImageInfo *image_info,Image *image)
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                               SaveImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
             }
             if (bp != buffer)
@@ -1439,7 +1442,7 @@ static unsigned int WritePSImage(const ImageInfo *image_info,Image *image)
                   if (QuantumTick(y,image->rows))
                     if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                                 SaveImageText,image->filename,
-                                               image->columns,image->rows))
+                                                image->columns,image->rows))
                       break;
               }
               if (bp != buffer)
@@ -1486,7 +1489,7 @@ static unsigned int WritePSImage(const ImageInfo *image_info,Image *image)
                   if (QuantumTick(y,image->rows))
                     if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                                 SaveImageText,image->filename,
-                                               image->columns,image->rows))
+                                                image->columns,image->rows))
                       break;
               }
               if (bp != buffer)
@@ -1572,7 +1575,7 @@ static unsigned int WritePSImage(const ImageInfo *image_info,Image *image)
                   if (QuantumTick(y,image->rows))
                     if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                                 SaveImageText,image->filename,
-                                               image->columns,image->rows))
+                                                image->columns,image->rows))
                       break;
               }
               if (bp != buffer)
@@ -1614,7 +1617,7 @@ static unsigned int WritePSImage(const ImageInfo *image_info,Image *image)
                   if (QuantumTick(y,image->rows))
                     if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                                 SaveImageText,image->filename,
-                                               image->columns,image->rows))
+                                                image->columns,image->rows))
                       break;
               }
               if (bp != buffer)
@@ -1633,7 +1636,7 @@ static unsigned int WritePSImage(const ImageInfo *image_info,Image *image)
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    if (!MagickMonitorFormatted(scene++,GetImageListLength(image),&image->exception,
+    if (!MagickMonitorFormatted(scene++,image_list_length,&image->exception,
                                 SaveImagesText,image->filename))
       break;
   } while (image_info->adjoin);
index dcdb8e6..3c9bd9f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -542,6 +542,9 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image)
   void
     *blob;
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -549,6 +552,7 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -704,7 +708,7 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image)
               (void) strcpy(buffer,"%%Pages: 1\n");
             else
               FormatString(buffer,"%%%%Pages: %lu\n",(unsigned long)
-                GetImageListLength(image));
+                image_list_length);
             (void) WriteBlobString(image,buffer);
           }
         (void) WriteBlobString(image,"%%EndComments\n");
@@ -832,10 +836,10 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image)
             /*
               Write image in JPEG format.
             */
-           blob=ImageToJPEGBlob(image,image_info,&length,&image->exception);
-           if (blob == (char *) NULL)
-             ThrowWriterException2(CoderError,image->exception.reason,image);
-           (void) WriteBlob(image,length,blob);
+            blob=ImageToJPEGBlob(image,image_info,&length,&image->exception);
+            if (blob == (char *) NULL)
+              ThrowWriterException2(CoderError,image->exception.reason,image);
+            (void) WriteBlob(image,length,blob);
             MagickFreeMemory(blob);
             break;
           }
@@ -875,7 +879,7 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image)
                                                   &image->exception,
                                                   SaveImageText,
                                                   image->filename,
-                                                 image->columns,image->rows);
+                                                  image->columns,image->rows);
                     if (status == False)
                       break;
                   }
@@ -917,7 +921,7 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image)
                                                   &image->exception,
                                                   SaveImageText,
                                                   image->filename,
-                                                 image->columns,image->rows);
+                                                  image->columns,image->rows);
                     if (status == False)
                       break;
                   }
@@ -940,14 +944,14 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image)
           {
             case JPEGCompression:
             {
-             /*
-               Write image in JPEG format.
-             */
-             blob=ImageToJPEGBlob(image,image_info,&length,&image->exception);
-             if (blob == (char *) NULL)
-               ThrowWriterException2(CoderError,image->exception.reason,image);
-             (void) WriteBlob(image,length,blob);
-             MagickFreeMemory(blob);
+              /*
+                Write image in JPEG format.
+              */
+              blob=ImageToJPEGBlob(image,image_info,&length,&image->exception);
+              if (blob == (char *) NULL)
+                ThrowWriterException2(CoderError,image->exception.reason,image);
+              (void) WriteBlob(image,length,blob);
+              MagickFreeMemory(blob);
               break;
             }
             case RLECompression:
@@ -1005,7 +1009,7 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image)
                                                     &image->exception,
                                                     SaveImageText,
                                                     image->filename,
-                                                   image->columns,image->rows);
+                                                    image->columns,image->rows);
                       if (status == False)
                         break;
                     }
@@ -1065,7 +1069,7 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image)
                                                     &image->exception,
                                                     SaveImageText,
                                                     image->filename,
-                                                   image->columns,image->rows);
+                                                    image->columns,image->rows);
                       if (status == False)
                         break;
                     }
@@ -1130,7 +1134,7 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image)
                                                     &image->exception,
                                                     SaveImageText,
                                                     image->filename,
-                                                   image->columns,image->rows);
+                                                    image->columns,image->rows);
                       if (status == False)
                         break;
                     }
@@ -1169,7 +1173,7 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image)
                                                     &image->exception,
                                                     SaveImageText,
                                                     image->filename,
-                                                   image->columns,image->rows);
+                                                    image->columns,image->rows);
                       if (status == False)
                         break;
                     }
@@ -1201,7 +1205,7 @@ static unsigned int WritePS2Image(const ImageInfo *image_info,Image *image)
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene++,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename);
     if (status == False)
index 706b591..2fab60f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -164,7 +164,7 @@ static unsigned int SerializeHuffman2DImage(const ImageInfo *image_info,
   huffman_image=CloneImage(image,0,0,True,&image->exception);
   if (huffman_image == (Image *) NULL)
     return(False);
-  /* 
+  /*
     TODO: If (image, then) huffman_image->compression is JPEG, huffman_image
     is changed to DirectClass in WriteTIFFImage and the huffman_image ends up
     broken. Change WriteTIFFIMage to not alter bilevel image to directclass
@@ -333,19 +333,19 @@ static MagickPassFail JPEGEncodeImage(const ImageInfo *image_info,
 
   MagickPassFail
     status=MagickFail;
-  
+
   blob=ImageToJPEGBlob(image,image_info,&length,&image->exception);
   if (blob != (unsigned char *) NULL)
     {
       register const unsigned char
-       *p;
+        *p;
 
       register size_t
-       i;
+        i;
 
         Ascii85Initialize(image);
       for (p=(const unsigned char*) blob,i=0; i < length; i++)
-       Ascii85Encode(image,(unsigned long) p[i]);
+        Ascii85Encode(image,(unsigned long) p[i]);
       Ascii85Flush(image);
       MagickFreeMemory(blob);
       status=MagickPass;
@@ -468,7 +468,7 @@ static unsigned int SerializePseudoClassImage(const ImageInfo *image_info,
         {
           status=MagickMonitorFormatted(y,image->rows,&image->exception,
                                         SaveImageText,image->filename,
-                                       image->columns,image->rows);
+                                        image->columns,image->rows);
           if (status == False)
             break;
         }
@@ -561,7 +561,7 @@ static unsigned int SerializeMultiChannelImage(const ImageInfo *image_info,
         {
           status=MagickMonitorFormatted(y,image->rows,&image->exception,
                                         SaveImageText,image->filename,
-                                       image->columns,image->rows);
+                                        image->columns,image->rows);
           if (status == False)
             break;
         }
@@ -678,7 +678,7 @@ static unsigned int SerializeSingleChannelImage(const ImageInfo *image_info,
           status=MagickMonitorFormatted(y,image->rows,
                                         &image->exception,SaveImageText,
                                         image->filename,
-                                       image->columns,image->rows);
+                                        image->columns,image->rows);
           if (status == False)
             break;
         }
@@ -1244,6 +1244,12 @@ static unsigned int WritePS3Image(const ImageInfo *image_info,Image *image)
     scene,
     text_size;
 
+  size_t
+    image_list_length;
+
+  Image
+    *clip_mask;
+
   /*
     Open output image file.
   */
@@ -1251,6 +1257,7 @@ static unsigned int WritePS3Image(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -1280,6 +1287,7 @@ static unsigned int WritePS3Image(const ImageInfo *image_info,Image *image)
   }
   page=0;
   scene=0;
+  clip_mask = *ImageGetClipMask(image);
   do
   {
     page++;
@@ -1448,7 +1456,7 @@ static unsigned int WritePS3Image(const ImageInfo *image_info,Image *image)
               (void) strlcpy(buffer,"%%Pages: 1\n",sizeof(buffer));
             else
               FormatString(buffer,"%%%%Pages: %lu\n",(unsigned long)
-                GetImageListLength(image));
+                           image_list_length);
             (void) WriteBlobString(image,buffer);
           }
         (void) WriteBlobString(image,"%%EndComments\n");
@@ -1526,13 +1534,13 @@ static unsigned int WritePS3Image(const ImageInfo *image_info,Image *image)
       (void) WriteBlobString(image,"%%PageResources: font Helvetica\n");
 
     /* PS clipping path from Photoshop clipping path */
-    if ((image->clip_mask != (Image *) NULL) && 
-      (LocaleNCompare("8BIM:",image->clip_mask->magick_filename,5) == 0))
+    if ((clip_mask != (Image *) NULL) &&
+      (LocaleNCompare("8BIM:",clip_mask->magick_filename,5) == 0))
       {
         const ImageAttribute
           *attribute;
 
-        attribute=GetImageAttribute(image,image->clip_mask->magick_filename);
+        attribute=GetImageAttribute(image,clip_mask->magick_filename);
         if (attribute == (const ImageAttribute *) NULL)
           return(False);
         (void) WriteBlobString(image,attribute->value);
@@ -1598,12 +1606,12 @@ static unsigned int WritePS3Image(const ImageInfo *image_info,Image *image)
       }
 
     /* Photoshop clipping path active? */
-    if ((image->clip_mask != (Image *) NULL) &&
-        (LocaleNCompare("8BIM:",image->clip_mask->magick_filename,5) == 0))
+    if ((clip_mask != (Image *) NULL) &&
+        (LocaleNCompare("8BIM:",clip_mask->magick_filename,5) == 0))
       (void) WriteBlobString(image,"true\n");
     else
       (void) WriteBlobString(image,"false\n");
-  
+
     /* Compression seems to take precedence over anyting */
     if (compression == FaxCompression)
       (void) SetImageType(image, BilevelType);
@@ -1674,27 +1682,27 @@ static unsigned int WritePS3Image(const ImageInfo *image_info,Image *image)
           (void) WriteBlobString(image,PS3_JPEGCompression"\n");
           break;
       }
-      
+
       /* Number of colors -- 0 for single component non-color mapped data */
       (void) WriteBlobString(image,"0\n");
 
       /* 1 bit or 8 bit components? */
-      FormatString(buffer,"%d\n", 
+      FormatString(buffer,"%d\n",
         IsMonochromeImage(image,&image->exception) ? 1 : 8);
       (void) WriteBlobString(image,buffer);
 
       /* Image data. Always ASCII85 encoded. */
       if (compression == JPEGCompression)
         {
-         status=JPEGEncodeImage(image_info,image);
+          status=JPEGEncodeImage(image_info,image);
         }
       else
         if (compression == FaxCompression)
           {
-           if (LocaleCompare(CCITTParam,"0") == 0)
-             status=HuffmanEncodeImage(image_info,image);
-           else
-             status=Huffman2DEncodeImage(image_info,image);
+            if (LocaleCompare(CCITTParam,"0") == 0)
+              status=HuffmanEncodeImage(image_info,image);
+            else
+              status=Huffman2DEncodeImage(image_info,image);
           }
         else
           {
@@ -1803,7 +1811,7 @@ static unsigned int WritePS3Image(const ImageInfo *image_info,Image *image)
         {
           /*
             Color mapped images.
-            
+
             Image class.
           */
           (void) WriteBlobString(image,PS3_PseudoClass"\n");
@@ -1828,7 +1836,7 @@ static unsigned int WritePS3Image(const ImageInfo *image_info,Image *image)
               (void) WriteBlobString(image,PS3_ZipCompression"\n");
               break;
           }
-          
+
           /* Number of colors in color map */
           FormatString(buffer,"%u\n",image->colors);
           (void) WriteBlobString(image,buffer);
@@ -1905,7 +1913,7 @@ static unsigned int WritePS3Image(const ImageInfo *image_info,Image *image)
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    status=MagickMonitorFormatted(scene,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename);
     if (status == False)
@@ -1975,10 +1983,11 @@ static unsigned int WritePS3Image(const ImageInfo *image_info,Image *image)
 %
 */
 
+static voidpf ZLIBAllocFunc(voidpf opaque, uInt items, uInt size) MAGICK_FUNC_MALLOC;
 static voidpf ZLIBAllocFunc(voidpf opaque, uInt items, uInt size)
 {
   ARG_NOT_USED(opaque);
-  return MagickMallocCleared((size_t) items*size);
+  return MagickMallocCleared(MagickArraySize(items,size));
 }
 static void ZLIBFreeFunc(voidpf opaque, voidpf address)
 {
@@ -2054,4 +2063,3 @@ static unsigned int ZLIBEncode2Image(Image *image,const size_t length,
   return(False);
 }
 #endif
-
index 023c6d2..cfbf263 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -672,14 +672,14 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception)
                                 "  ImageColorMap allocated");
         }
     }
-  
+
   if (logging)
     {
-      (void) LogMagickEvent(CoderEvent,GetMagickModule(), 
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                             image->matte ?
                             "  image has matte" : "  image has no matte");
     }
-  
+
   /*
     Read PSD raster colormap only present for indexed and duotone images.
   */
@@ -795,7 +795,7 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if (image_info->ping)
     {
       CloseBlob(image);
-      
+
       if (logging)
         {
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -882,9 +882,9 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   if (logging)
                     {
                       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                            "    offset(%ld,%ld), size(%ld,%ld), channels=%d", 
+                                            "    offset(%ld,%ld), size(%ld,%ld), channels=%d",
                                             layer_info[i].page.x,
-                                            layer_info[i].page.y, 
+                                            layer_info[i].page.y,
                                             layer_info[i].page.height,
                                             layer_info[i].page.width,
                                             layer_info[i].channels);
@@ -903,8 +903,8 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       if (logging)
                         {
                           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                                "    channel[%ld]: type=%d, size=%ld", 
-                                                j, layer_info[i].channel_info[j].type, 
+                                                "    channel[%ld]: type=%d, size=%ld",
+                                                j, layer_info[i].channel_info[j].type,
                                                 (long) layer_info[i].channel_info[j].size);
                         }
                     }
@@ -927,7 +927,7 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   if (logging)
                     {
                       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                            "    blend=%.4s, opacity=%d, clipping=%s, flags=%d, visible=%s", 
+                                            "    blend=%.4s, opacity=%d, clipping=%s, flags=%d, visible=%s",
                                             layer_info[i].blendkey, layer_info[i].opacity,
                                             layer_info[i].clipping ? "true" : "false",
                                             layer_info[i].flags,
@@ -1025,7 +1025,7 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       /* padBytes = ((length + 1 + 3) & ~3) - (length + 1); */
                       /* for (j=0; j < padBytes; j++) */
                       /*   ReadBlobByte(image); */
-              
+
 #if 0  /* still in development */
                       /*
                         Adjustment layers and other stuff...
@@ -1352,7 +1352,7 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   layer_info[0].image->previous=image;
 #else
                   DestroyImage(image);
-                  returnImage = layer_info[0].image;  
+                  returnImage = layer_info[0].image;
 #endif
                   MagickFreeMemory(layer_info);
 
@@ -1508,7 +1508,7 @@ static Image *ReadPSDImage(const ImageInfo *image_info,ExceptionInfo *exception)
             break;
         }
     }
-  
+
   CloseBlob(image);
 
   if(logging)
@@ -1875,12 +1875,12 @@ static unsigned int WritePSDImage(const ImageInfo *image_info,Image *image)
   {
     const unsigned char
       *iptc_profile;
-    
+
     size_t
       iptc_profile_length;
-    
+
     iptc_profile=GetImageProfile(image,"IPTC",&iptc_profile_length);
-    
+
     if ( iptc_profile != 0 )
       {
         (void) WriteBlobMSBLong( image, (const magick_uint32_t) iptc_profile_length );
@@ -1935,7 +1935,7 @@ static unsigned int WritePSDImage(const ImageInfo *image_info,Image *image)
       if ( invert_layer_count )
         layer_count *= -1;  /* if we have a matte, then use negative count! */
       (void) WriteBlobMSBShort(image, layer_count);
-  
+
       layer_count = 1;
       tmp_image = base_image;
       while ( tmp_image != NULL ) {
@@ -1985,7 +1985,7 @@ static unsigned int WritePSDImage(const ImageInfo *image_info,Image *image)
               (void) WriteBlobMSBShort(image, 3);
               (void) WriteBlobMSBLong(image, channel_size);
             }
+
         (void) WriteBlob(image, 4, "8BIM");
         (void) WriteBlob(image, 4, CompositeOperatorToPSDBlendMode(tmp_image->compose));
         (void) WriteBlobByte(image, 255);    /* BOGUS: layer opacity */
@@ -2004,7 +2004,7 @@ static unsigned int WritePSDImage(const ImageInfo *image_info,Image *image)
             sprintf((char *) &(layer_name[1]), "%4s", theAttr->value );
             (void) WriteBlobByte(image, 3);
             (void) WriteBlob(image, 3, &layer_name[1]);
-          */ 
+          */
         } else {
           /*
             In Photoshop 5.5 the maximum number of layers was 100 but
index 71fbdf2..c6331a2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -162,13 +162,14 @@ static Image *ReadPWPImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if (status == False)
     ThrowReaderException(FileOpenError,UnableToOpenFile,pwp_image);
   count=ReadBlob(pwp_image,5,(char *) magick);
-  if ((count == 0) || (LocaleNCompare((char *) magick,"SFW95",5) != 0))
+  if ((count != 5) || (LocaleNCompare((char *) magick,"SFW95",5) != 0))
     ThrowReaderException(CorruptImageError,ImproperImageHeader,pwp_image);
   clone_info=CloneImageInfo(image_info);
   clone_info->blob=(void *) NULL;
   clone_info->length=0;
   for ( ; ; )
   {
+    (void) memset(magick,0,sizeof(magick));
     for (c=ReadBlobByte(pwp_image); c != EOF; c=ReadBlobByte(pwp_image))
     {
       for (i=0; i < 17; i++)
@@ -178,24 +179,32 @@ static Image *ReadPWPImage(const ImageInfo *image_info,ExceptionInfo *exception)
         break;
     }
     if (c == EOF)
-      break;
+      {
+        ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
+                       clone_info->filename);
+        break;
+      }
     if (LocaleNCompare((char *) (magick+12),"SFW94A",6) != 0)
       {
-        ThrowReaderException(CorruptImageError,ImproperImageHeader,pwp_image);
+        ThrowException(exception,CorruptImageError,ImproperImageHeader,
+                       clone_info->filename);
+        break;
       }
     /*
       Dump SFW image to a temporary file.
     */
-    file=AcquireTemporaryFileStream(clone_info->filename,BinaryFileIOMode);
-    if (file == (FILE *) NULL)
-      {
-        char
-          filename[MaxTextExtent];
-
-        (void) strcpy(filename,clone_info->filename);
-        DestroyImageInfo(clone_info);
-        ThrowReaderTemporaryFileException(filename);
-      }
+    {
+      char tmpfile[MaxTextExtent];
+      file=AcquireTemporaryFileStream(tmpfile,BinaryFileIOMode);
+      if (file == (FILE *) NULL)
+        {
+          ThrowException(exception,FileOpenError,UnableToCreateTemporaryFile,
+                         clone_info->filename);
+          break;
+        }
+      (void) strlcpy(clone_info->filename,"SFW:",sizeof(clone_info->filename));
+      (void) strlcat(clone_info->filename,tmpfile,sizeof(clone_info->filename));
+    }
     (void) fwrite("SFW94A",1,6,file);
     filesize=(65535L*magick[2]+256L*magick[1]+magick[0]) & 0xFFFFFFFF;
     for (i=0; i < filesize; i++)
@@ -206,7 +215,11 @@ static Image *ReadPWPImage(const ImageInfo *image_info,ExceptionInfo *exception)
     }
     (void) fclose(file);
     if (c == EOF)
-      break;
+      {
+        ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
+                       clone_info->filename);
+        break;
+      }
     handler=SetMonitorHandler((MonitorHandler) NULL);
     next_image=ReadImage(clone_info,exception);
     (void) LiberateTemporaryFile(clone_info->filename);
@@ -237,10 +250,6 @@ static Image *ReadPWPImage(const ImageInfo *image_info,ExceptionInfo *exception)
   DestroyImageInfo(clone_info);
   CloseBlob(pwp_image);
   DestroyImage(pwp_image);
-  if (EOFBlob(image))
-    ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
-      image->filename);
-  CloseBlob(image);
   return(image);
 }
 \f
index 5757a8a..ba1c486 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
 static unsigned int
   WriteRGBImage(const ImageInfo *,Image *);
 \f
+#define ThrowRGBReaderException(code_,reason_,image_) \
+{ \
+  MagickFreeMemory(scanline);                 \
+  ThrowReaderException(code_,reason_,image_); \
+}
+\f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
@@ -90,17 +96,18 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
     y;
 
   register long
-    i,
-    x;
+    i;
 
   register PixelPacket
     *q;
 
   size_t
-    count;
+    count,
+    tile_packets,
+    x;
 
   unsigned char
-    *scanline;
+    *scanline = (unsigned char *) NULL;
 
   unsigned int
     status;
@@ -118,7 +125,28 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
   assert(exception->signature == MagickSignature);
   image=AllocateImage(image_info);
   if ((image->columns == 0) || (image->rows == 0))
-    ThrowReaderException(OptionError,MustSpecifyImageSize,image);
+    ThrowRGBReaderException(OptionError,MustSpecifyImageSize,image);
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Tile %lux%lu%+ld%+ld, Offset %lu",
+                          image->tile_info.width,image->tile_info.height,
+                          image->tile_info.x,image->tile_info.y,
+                          image->offset);
+  /*
+    There is the option to either require that the tile be within the
+    image bounds or to return only the portion of the tile which is
+    within the image bounds (returned image is smaller than requested
+    tile size).  For the moment we choose the former.
+  */
+  if ((image->tile_info.width > image->columns) ||
+      (image->tile_info.x < 0) ||
+      (image->tile_info.width+image->tile_info.x > image->columns) ||
+      (image->tile_info.height > image->rows) ||
+      (image->tile_info.y < 0) ||
+      (image->tile_info.height+image->tile_info.y > image->rows)
+      )
+    ThrowReaderException(OptionError,TileNotBoundedByImageDimensions,image);
+
   if (image_info->interlace != PartitionInterlace)
     {
       /*
@@ -126,7 +154,7 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
       */
       status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
       if (status == False)
-        ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+        ThrowRGBReaderException(FileOpenError,UnableToOpenFile,image);
       for (i=0; i < image->offset; i++)
         {
           if (EOF == ReadBlobByte(image))
@@ -137,9 +165,9 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                         "Tile %lux%lu%+ld%+ld",
-                         image->tile_info.width,image->tile_info.height,
-                         image->tile_info.x,image->tile_info.y);
+                          "Tile %lux%lu%+ld%+ld",
+                          image->tile_info.width,image->tile_info.height,
+                          image->tile_info.x,image->tile_info.y);
 
   /*
     Allocate memory for a scanline.
@@ -159,9 +187,11 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
     }
 
   scanline=MagickAllocateArray(unsigned char *,
-                              packet_size,image->tile_info.width);
+                               packet_size,image->tile_info.width);
   if (scanline == (unsigned char *) NULL)
-    ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+    ThrowRGBReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+  tile_packets=(size_t) packet_size*image->tile_info.width;
+  x=(size_t) (packet_size*image->tile_info.x);
   /*
     Initialize import options.
   */
@@ -171,10 +201,10 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                         "Depth %u bits, Endian %s, Interlace %s",
-                         quantum_size,
-                         EndianTypeToString(import_options.endian),
-                         InterlaceTypeToString(image_info->interlace));
+                          "Depth %u bits, Endian %s, Interlace %s",
+                          quantum_size,
+                          EndianTypeToString(import_options.endian),
+                          InterlaceTypeToString(image_info->interlace));
   /*
     Support starting at intermediate image frame.
   */
@@ -186,9 +216,9 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
       */
       image->scene++;
       for (y=0; y < (long) image->rows; y++)
-        (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+        if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+          break;
     }
-  x=(long) (packet_size*image->tile_info.x);
   do
   {
     /*
@@ -202,36 +232,39 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
       case NoInterlace:
       default:
       {
-       QuantumType
-         quantum_type;
+        QuantumType
+          quantum_type;
 
         /*
           No interlacing:  RGBRGBRGBRGBRGBRGB...
         */
-       quantum_type=(image->matte ? RGBAQuantum : RGBQuantum);
+        quantum_type=(image->matte ? RGBAQuantum : RGBQuantum);
         for (y=0; y < image->tile_info.y; y++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         for (y=0; y < (long) image->rows; y++)
         {
           if ((y > 0) || (image->previous == (Image *) NULL))
-            (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+            if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+              break;
           q=SetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
-         (void) ImportImagePixelArea(image,quantum_type,quantum_size,scanline+x,
-                                     &import_options,0);
+          (void) ImportImagePixelArea(image,quantum_type,quantum_size,scanline+x,
+                                      &import_options,0);
           if (!SyncImagePixels(image))
             break;
           if (image->previous == (Image *) NULL)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
         count=image->tile_info.height-image->rows-image->tile_info.y;
         for (i=0; i < (long) count; i++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         break;
       }
       case LineInterlace:
@@ -241,28 +274,32 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
         */
         packet_size=(quantum_size)/8;
         for (y=0; y < image->tile_info.y; y++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         for (y=0; y < (long) image->rows; y++)
         {
           if ((y > 0) || (image->previous == (Image *) NULL))
-            (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+            if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+              break;
           q=SetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
           (void) ImportImagePixelArea(image,RedQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+                                      &import_options,0);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
           (void) ImportImagePixelArea(image,GreenQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+                                      &import_options,0);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
           (void) ImportImagePixelArea(image,BlueQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
+                                      &import_options,0);
           if (image->matte)
             {
-              (void) ReadBlob(image,packet_size*image->tile_info.width,
-                scanline);
+              if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+                break;
               (void) ImportImagePixelArea(image,AlphaQuantum,quantum_size,scanline+x,
-                                         &import_options,0);
+                                          &import_options,0);
             }
           if (!SyncImagePixels(image))
             break;
@@ -270,12 +307,13 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
         count=image->tile_info.height-image->rows-image->tile_info.y;
         for (i=0; i < (long) count; i++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         break;
       }
       case PlaneInterlace:
@@ -292,97 +330,106 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
             AppendImageFormat("R",image->filename);
             status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
             if (status == False)
-              ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+              ThrowRGBReaderException(FileOpenError,UnableToOpenFile,image);
           }
         packet_size=(quantum_size)/8;
         for (y=0; y < image->tile_info.y; y++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         i=0;
         span=image->rows*(image->matte ? 4 : 3);
         for (y=0; y < (long) image->rows; y++)
         {
           if ((y > 0) || (image->previous == (Image *) NULL))
-            (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+            if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+              break;
           q=SetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
           (void) ImportImagePixelArea(image,RedQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
+                                      &import_options,0);
           if (!SyncImagePixels(image))
             break;
           if (image->previous == (Image *) NULL)
             if (QuantumTick(i,span))
               if (!MagickMonitorFormatted(i,span,&image->exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
           i++;
         }
         count=image->tile_info.height-image->rows-image->tile_info.y;
         for (i=0; i < (long) count; i++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         if (image_info->interlace == PartitionInterlace)
           {
             CloseBlob(image);
             AppendImageFormat("G",image->filename);
             status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
             if (status == False)
-              ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+              ThrowRGBReaderException(FileOpenError,UnableToOpenFile,image);
           }
         for (y=0; y < image->tile_info.y; y++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         for (y=0; y < (long) image->rows; y++)
         {
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
           q=GetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
           (void) ImportImagePixelArea(image,GreenQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
+                                      &import_options,0);
           if (!SyncImagePixels(image))
             break;
           if (image->previous == (Image *) NULL)
             if (QuantumTick(i,span))
               if (!MagickMonitorFormatted(i,span,&image->exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
           i++;
         }
         count=image->tile_info.height-image->rows-image->tile_info.y;
         for (i=0; i < (long) count; i++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         if (image_info->interlace == PartitionInterlace)
           {
             CloseBlob(image);
             AppendImageFormat("B",image->filename);
             status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
             if (status == False)
-              ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+              ThrowRGBReaderException(FileOpenError,UnableToOpenFile,image);
           }
         for (y=0; y < image->tile_info.y; y++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         for (y=0; y < (long) image->rows; y++)
         {
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
           q=GetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
           (void) ImportImagePixelArea(image,BlueQuantum,quantum_size,scanline+x,
-                                     &import_options,0);
+                                      &import_options,0);
           if (!SyncImagePixels(image))
             break;
           if (image->previous == (Image *) NULL)
             if (QuantumTick(i,span))
               if (!MagickMonitorFormatted(i,span,&image->exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
           i++;
         }
         count=image->tile_info.height-image->rows-image->tile_info.y;
         for (i=0; i < (long) count; i++)
-          (void) ReadBlob(image,packet_size*image->tile_info.width,scanline);
+          if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+            break;
         if (image->matte)
           {
             /*
@@ -394,34 +441,34 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 AppendImageFormat("A",image->filename);
                 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
                 if (status == False)
-                  ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+                  ThrowRGBReaderException(FileOpenError,UnableToOpenFile,image);
               }
             for (y=0; y < image->tile_info.y; y++)
-              (void) ReadBlob(image,packet_size*image->tile_info.width,
-                scanline);
+              if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+                break;
             for (y=0; y < (long) image->rows; y++)
             {
-              (void) ReadBlob(image,packet_size*image->tile_info.width,
-                scanline);
+              if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+                break;
               q=GetImagePixels(image,0,y,image->columns,1);
               if (q == (PixelPacket *) NULL)
                 break;
               (void) ImportImagePixelArea(image,AlphaQuantum,quantum_size,scanline+x,
-                                         &import_options,0);
+                                          &import_options,0);
               if (!SyncImagePixels(image))
                 break;
               if (image->previous == (Image *) NULL)
                 if (QuantumTick(i,span))
                   if (!MagickMonitorFormatted(i,span,&image->exception,
                                               LoadImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
               i++;
             }
             count=image->tile_info.height-image->rows-image->tile_info.y;
             for (i=0; i < (long) count; i++)
-              (void) ReadBlob(image,packet_size*image->tile_info.width,
-                scanline);
+              if (ReadBlob(image,tile_packets,scanline) != tile_packets)
+                break;
           }
         if (image_info->interlace == PartitionInterlace)
           (void) strlcpy(image->filename,image_info->filename,MaxTextExtent);
@@ -442,8 +489,8 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
         break;
     if (image_info->interlace == PartitionInterlace)
       break;
-    count=ReadBlob(image,packet_size*image->tile_info.width,scanline);
-    if (count != 0)
+    count=ReadBlob(image,tile_packets,scanline);
+    if (count == tile_packets)
       {
         /*
           Allocate next image structure.
@@ -451,8 +498,7 @@ static Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
         AllocateNextImage(image_info,image);
         if (image->next == (Image *) NULL)
           {
-            DestroyImageList(image);
-            return((Image *) NULL);
+            ThrowRGBReaderException(ResourceLimitError,MemoryAllocationFailed,image);
           }
         image=SyncNextImageInList(image);
         if (!MagickMonitorFormatted(TellBlob(image),GetBlobSize(image),
@@ -570,19 +616,20 @@ ModuleExport void UnregisterRGBImage(void)
 */
 static unsigned int WriteRGBImage(const ImageInfo *image_info,Image *image)
 {
-  int
+  long
     y;
 
   register const PixelPacket
     *p;
 
   unsigned char
-    *pixels;
+    *pixels = (unsigned char *) NULL;
 
   unsigned int
     status;
 
   unsigned int
+    depth,
     packet_size,
     quantum_size,
     scene;
@@ -593,27 +640,15 @@ static unsigned int WriteRGBImage(const ImageInfo *image_info,Image *image)
   ExportPixelAreaInfo
     export_info;
 
-  /*
-    Allocate memory for pixels.
-  */
+  size_t
+    image_list_length;
+
   assert(image_info != (const ImageInfo *) NULL);
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
 
-  if (image->depth <= 8)
-    quantum_size=8;
-  else if (image->depth <= 16)
-    quantum_size=16;
-  else
-    quantum_size=32;
-
-  packet_size=(quantum_size*3)/8;
-  if (LocaleCompare(image_info->magick,"RGBA") == 0)
-    packet_size=(quantum_size*4)/8;
-  pixels=MagickAllocateArray(unsigned char *,packet_size,image->columns);
-  if (pixels == (unsigned char *) NULL)
-    ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+  image_list_length=GetImageListLength(image);
   if (image_info->interlace != PartitionInterlace)
     {
       /*
@@ -623,57 +658,97 @@ static unsigned int WriteRGBImage(const ImageInfo *image_info,Image *image)
       if (status == False)
         ThrowWriterException(FileOpenError,UnableToOpenFile,image);
     }
-  scene=0;
+
   /*
-    Initialize export options.
+    Support depth in multiples of 8 bits.
   */
-  ExportPixelAreaOptionsInit(&export_options);
-  if (image->endian != UndefinedEndian)
-    export_options.endian=image->endian;
-  else if (image_info->endian != UndefinedEndian)
-    export_options.endian=image_info->endian;
-  if (image->logging)
-    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                         "Depth %u bits, Endian %s, Interlace %s",
-                         quantum_size,
-                         EndianTypeToString(export_options.endian),
-                         InterlaceTypeToString(image_info->interlace));
+  if (image->depth > 16)
+    depth=32;
+  else if (image->depth > 8)
+    depth=16;
+  else
+    depth=8;
+
+  if (depth <= 8)
+    quantum_size=8;
+  else if (depth <= 16)
+    quantum_size=16;
+  else
+    quantum_size=32;
+
+  packet_size=(quantum_size*3)/8;
+  if (LocaleCompare(image_info->magick,"RGBA") == 0)
+    packet_size=(quantum_size*4)/8;
+
+  scene=0;
   do
   {
     /*
+      Allocate memory for pixels.
+    */
+    MagickReallocMemory(unsigned char *,pixels,
+                        MagickArraySize(packet_size,image->columns));
+    if (pixels == (unsigned char *) NULL)
+      ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+
+    /*
+      Initialize export options.
+    */
+    ExportPixelAreaOptionsInit(&export_options);
+    if (image->endian != UndefinedEndian)
+      export_options.endian=image->endian;
+    else if (image_info->endian != UndefinedEndian)
+      export_options.endian=image_info->endian;
+
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "%lu: "
+                          "Geometry %lux%lu, "
+                          "Depth %u bits, "
+                          "Endian %s, "
+                          "Packet Size %u, "
+                          "Row bytes %" MAGICK_SIZE_T_F "u",
+                          image->scene,
+                          image->columns,image->rows,
+                          quantum_size,
+                          EndianTypeToString(export_options.endian),
+                          packet_size,
+                          (MAGICK_SIZE_T) MagickArraySize(packet_size,image->columns));
+
+    /*
       Convert MIFF to RGB raster pixels.
     */
     (void) TransformColorspace(image,RGBColorspace);
     if (LocaleCompare(image_info->magick,"RGBA") == 0)
       if (!image->matte)
         SetImageOpacity(image,OpaqueOpacity);
+
     switch (image_info->interlace)
     {
       case NoInterlace:
       default:
       {
-       QuantumType
-         quantum_type;
+        QuantumType
+          quantum_type;
 
         /*
           No interlacing:  RGBRGBRGBRGBRGBRGB...
         */
-       quantum_type=RGBQuantum;
-       if (LocaleCompare(image_info->magick,"RGBA") == 0)
-         quantum_type=RGBAQuantum;
+        quantum_type=RGBQuantum;
+        if (LocaleCompare(image_info->magick,"RGBA") == 0)
+          quantum_type=RGBAQuantum;
         for (y=0; y < (long) image->rows; y++)
         {
           p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
-         (void) ExportImagePixelArea(image,quantum_type,quantum_size,pixels,
-                                     &export_options,&export_info);
-         (void) WriteBlob(image,export_info.bytes_exported,pixels);
+          (void) ExportImagePixelArea(image,quantum_type,quantum_size,pixels,
+                                      &export_options,&export_info);
+          (void) WriteBlob(image,export_info.bytes_exported,pixels);
           if (image->previous == (Image *) NULL)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                           SaveImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
         break;
@@ -689,24 +764,24 @@ static unsigned int WriteRGBImage(const ImageInfo *image_info,Image *image)
           if (p == (const PixelPacket *) NULL)
             break;
           (void) ExportImagePixelArea(image,RedQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
           (void) ExportImagePixelArea(image,GreenQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
           (void) ExportImagePixelArea(image,BlueQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
           if (LocaleCompare(image_info->magick,"RGBA") == 0)
             {
               (void) ExportImagePixelArea(image,AlphaQuantum,quantum_size,pixels,
-                                         &export_options,&export_info);
+                                          &export_options,&export_info);
               (void) WriteBlob(image,export_info.bytes_exported,pixels);
             }
           if (QuantumTick(y,image->rows))
             if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                         SaveImageText,image->filename,
-                                       image->columns,image->rows))
+                                        image->columns,image->rows))
               break;
         }
         break;
@@ -730,7 +805,7 @@ static unsigned int WriteRGBImage(const ImageInfo *image_info,Image *image)
           if (p == (const PixelPacket *) NULL)
             break;
           (void) ExportImagePixelArea(image,RedQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
         }
         if (image_info->interlace == PartitionInterlace)
@@ -743,7 +818,7 @@ static unsigned int WriteRGBImage(const ImageInfo *image_info,Image *image)
           }
         if (!MagickMonitorFormatted(100,400,&image->exception,SaveImageText,
                                     image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
         for (y=0; y < (long) image->rows; y++)
         {
@@ -751,7 +826,7 @@ static unsigned int WriteRGBImage(const ImageInfo *image_info,Image *image)
           if (p == (const PixelPacket *) NULL)
             break;
           (void) ExportImagePixelArea(image,GreenQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
         }
         if (image_info->interlace == PartitionInterlace)
@@ -764,7 +839,7 @@ static unsigned int WriteRGBImage(const ImageInfo *image_info,Image *image)
           }
         if (!MagickMonitorFormatted(200,400,&image->exception,SaveImageText,
                                     image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
         for (y=0; y < (long) image->rows; y++)
         {
@@ -772,14 +847,14 @@ static unsigned int WriteRGBImage(const ImageInfo *image_info,Image *image)
           if (p == (const PixelPacket *) NULL)
             break;
           (void) ExportImagePixelArea(image,BlueQuantum,quantum_size,pixels,
-                                     &export_options,&export_info);
+                                      &export_options,&export_info);
           (void) WriteBlob(image,export_info.bytes_exported,pixels);
         }
         if (LocaleCompare(image_info->magick,"RGBA") == 0)
           {
             if (!MagickMonitorFormatted(300,400,&image->exception,
                                         SaveImageText,image->filename,
-                                       image->columns,image->rows))
+                                        image->columns,image->rows))
               break;
             if (image_info->interlace == PartitionInterlace)
               {
@@ -797,7 +872,7 @@ static unsigned int WriteRGBImage(const ImageInfo *image_info,Image *image)
               if (p == (const PixelPacket *) NULL)
                 break;
               (void) ExportImagePixelArea(image,AlphaQuantum,quantum_size,pixels,
-                                         &export_options,&export_info);
+                                          &export_options,&export_info);
               (void) WriteBlob(image,export_info.bytes_exported,pixels);
             }
           }
@@ -812,7 +887,7 @@ static unsigned int WriteRGBImage(const ImageInfo *image_info,Image *image)
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    if (!MagickMonitorFormatted(scene++,GetImageListLength(image),
+    if (!MagickMonitorFormatted(scene++,image_list_length,
                                 &image->exception,SaveImagesText,
                                 image->filename))
       break;
index fc9f5e3..615f01d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -191,13 +191,13 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
     number_channels,
     runlength;
 
-  long
+  unsigned long
     y;
 
   magick_uint32_t
     *scanlines=0;
 
-  register long
+  register unsigned long
     i,
     x;
 
@@ -222,6 +222,10 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
   MagickPassFail
     status;
 
+  magick_off_t
+    current_offset,
+    file_size;
+
   /*
     Open image file.
   */
@@ -233,6 +237,7 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFail)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+  file_size=GetBlobSize(image);
   is_rla3=MagickFalse;
   memset(&rla_info,0,sizeof(rla_info));
   memset(&rla3_extra_info,0,sizeof(rla3_extra_info));
@@ -344,7 +349,7 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
     {
       const char
         *storage_type = "Unknown";
-      
+
       switch (rla_info.storage_type)
         {
         case 0:
@@ -416,7 +421,7 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
                                 "Time           : %.12s", rla3_extra_info.time);
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                 "Filter         : %.32s", rla3_extra_info.filter);
-          
+
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                 "BitsPerChannel : %u", rla3_extra_info.bits_per_channel);
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -459,7 +464,24 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
   if (LocaleNCompare(rla_info.chan,"rgb",3) != 0)
     ThrowRLAReaderException(CoderError,ColorTypeNotSupported,image);
-                          
+
+  if (rla_info.number_channels > 3)
+    {
+      if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Unsupported number of color channels: %u",
+                                  rla_info.number_channels);
+      ThrowRLAReaderException(CorruptImageError,UnsupportedNumberOfPlanes,image);
+    }
+  if (rla_info.number_matte_channels > 1)
+    {
+      if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Unsupported number of matte channels: %u",
+                                  rla_info.number_matte_channels);
+      ThrowRLAReaderException(CorruptImageError,UnsupportedNumberOfPlanes,image);
+    }
+
   /*
     Initialize image structure.
   */
@@ -489,7 +511,8 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Read offsets to each scanline data.
   */
-  for (i=0; i < (long) image->rows; i++)
+  current_offset=TellBlob(image);
+  for (i=0; i < image->rows; i++)
     {
       scanlines[i]=(magick_uint32_t) ReadBlobMSBLong(image);
 #if 0
@@ -497,6 +520,29 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "scanline[%ld] = %lu",i,(unsigned long) scanlines[i]);
 #endif
+      if ((magick_off_t) scanlines[i] > file_size)
+        {
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "scanline[%ld] offset %lu is beyond end of file",
+                                  i,(unsigned long) scanlines[i]);
+          ThrowRLAReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+        }
+      if ((magick_off_t) scanlines[i] < current_offset)
+        {
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "scanline[%ld] offset %lu is too small!",
+                                  i,(unsigned long) scanlines[i]);
+          ThrowRLAReaderException(CorruptImageError,ImproperImageHeader,image);
+        }
+      if ((i != 0) && (scanlines[i-1] == scanlines[i]))
+        {
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "scanline[%ld] offset %lu is a duplicate!",
+                                  i,(unsigned long) scanlines[i]);
+        }
     }
   if (EOFBlob(image))
     ThrowRLAReaderException(CorruptImageError,UnexpectedEndOfFile,image);
@@ -504,7 +550,7 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
     Read image data.
   */
   x=0;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < image->rows; y++)
   {
     if (SeekBlob(image,scanlines[image->rows-y-1],SEEK_SET) == -1)
       {
@@ -535,6 +581,8 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
           {
             while (runlength < 0)
             {
+              if (x > image->rows*image->columns*number_channels)
+                  ThrowRLAReaderException(CorruptImageError,UnableToRunlengthDecodeImage,image);
               q=GetImagePixels(image,(long) (x % image->columns),
                                (long) (y % image->columns),1,1);
               if (q == (PixelPacket *) NULL)
@@ -595,6 +643,8 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
         runlength++;
         do
         {
+          if (x > image->rows*image->columns*number_channels)
+            ThrowRLAReaderException(CorruptImageError,UnableToRunlengthDecodeImage,image);
           q=GetImagePixels(image,(long) (x % image->columns),
             (long) (y % image->columns),1,1);
           if (q == (PixelPacket *) NULL)
@@ -649,7 +699,7 @@ static Image *ReadRLAImage(const ImageInfo *image_info,ExceptionInfo *exception)
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                   image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         {
           status=MagickFail;
           break;
index cf2b34e..fe4310b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
 #include "magick/monitor.h"
 #include "magick/pixel_cache.h"
 #include "magick/utility.h"
-\f
-static unsigned int
-RLEConstrainColormapIndex(Image *image, unsigned int index,
-                          unsigned int colormap_entries)
-{
-  if (index >= colormap_entries)
-    {
-      if (image->exception.severity < CorruptImageError)
-        {
-          char
-            colormapIndexBuffer[MaxTextExtent];
-
-          FormatString(colormapIndexBuffer,"index %u >= %u, %.1024s",
-                       (unsigned int) index, colormap_entries, image->filename);
-          errno=0;
-          ThrowException(&image->exception,CorruptImageError,
-                         InvalidColormapIndex,colormapIndexBuffer);
-        }
-      index=0U;
-    }
 
-  return index;
-}
-#define RLEVerifyColormapIndex(image,index,colormap_entries)    \
-{ \
-  if (index >= colormap_entries) \
-    index=RLEConstrainColormapIndex(image,index,colormap_entries);      \
-}
 typedef struct _RLE_Header
 {
   magick_uint8_t   Magic[2];    /* Magic number */
@@ -87,6 +60,31 @@ typedef struct _RLE_Header
 
 } RLE_HEADER;
 
+/* If this flag is set, the image rectangle should first be cleared to
+the background color (q.v.) before reading the scanline data. */
+#define ClearFirstFlag    0x01
+
+/* If this flag is set, no background color is supplied, and the
+ClearFirst flag should be ignored. */
+#define NoBackgroundFlag  0x02
+
+/* This flag indicates the presence of an "alpha" channel. The alpha
+channel is used by image compositing software to correctly blend
+anti-aliased edges. It is stored as channel -1 (255). */
+#define AlphaFlag         0x04
+
+/* If this flag is set, comments are present in the variable part of
+the header, immediately following the color map. */
+#define CommentsFlag      0x08
+
+/* RLE operators */
+#define SkipLinesOp  0x01
+#define SetColorOp  0x02
+#define SkipPixelsOp  0x03
+#define ByteDataOp  0x05
+#define RunDataOp  0x06
+#define EOFOp  0x07
+
 static void LogRLEHeader(const RLE_HEADER* rle_header)
 {
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -199,13 +197,6 @@ do { \
 } while (0);
 static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
-#define SkipLinesOp  0x01
-#define SetColorOp  0x02
-#define SkipPixelsOp  0x03
-#define ByteDataOp  0x05
-#define RunDataOp  0x06
-#define EOFOp  0x07
-
   RLE_HEADER
     rle_header;
 
@@ -218,7 +209,7 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
     pixel,
     status;
 
-  unsigned int
+  size_t
     colormap_entries;
 
   unsigned int
@@ -244,11 +235,11 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
   size_t
     count,
+    map_length,
+    number_pixels,
+    offset,
     rle_bytes;
 
-  unsigned int
-    map_length;
-
   unsigned char
     background_color[256],
     *colormap = (unsigned char *) NULL,
@@ -257,7 +248,6 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
   unsigned int
     number_colormaps,
-    number_pixels,
     number_planes;
 
   magick_off_t
@@ -282,163 +272,202 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if ((count != 2) || (memcmp(&rle_header.Magic,"\122\314",2) != 0))
     ThrowRLEReaderException(CorruptImageError,ImproperImageHeader,image);
   file_size=GetBlobSize(image);
-  do
-  {
-    /*
-      Read image header.
-    */
-    rle_header.Xpos=ReadBlobLSBShort(image);
-    rle_header.Ypos=ReadBlobLSBShort(image);
-    rle_header.XSize=ReadBlobLSBShort(image);
-    rle_header.YSize=ReadBlobLSBShort(image);
-    rle_header.Flags=ReadBlobByte(image);
-    rle_header.Ncolors=ReadBlobByte(image);
-    rle_header.Pixelbits=ReadBlobByte(image);
-    rle_header.Ncmap=ReadBlobByte(image);
-    rle_header.Cmaplen=ReadBlobByte(image);
-    if (EOFBlob(image))
-      ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+  /*
+    Read image header.
+  */
+  rle_header.Xpos=ReadBlobLSBShort(image);
+  rle_header.Ypos=ReadBlobLSBShort(image);
+  rle_header.XSize=ReadBlobLSBShort(image);
+  rle_header.YSize=ReadBlobLSBShort(image);
+  rle_header.Flags=ReadBlobByte(image);
+  rle_header.Ncolors=ReadBlobByte(image);
+  rle_header.Pixelbits=ReadBlobByte(image);
+  rle_header.Ncmap=ReadBlobByte(image);
+  rle_header.Cmaplen=ReadBlobByte(image);
+  if (EOFBlob(image))
+    ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+
+  LogRLEHeader(&rle_header);
+
+  if ((rle_header.Ncolors == 0) ||
+      (rle_header.Ncolors == 2) ||
+      ((rle_header.Flags & AlphaFlag) &&
+       ((rle_header.Ncolors > 254) || (rle_header.Ncolors < 3))) ||
+      (rle_header.Pixelbits != 8))
+    ThrowRLEReaderException(CoderError,DataEncodingSchemeIsNotSupported,image);
+
+  /* X/Y size may not be zero and may not exceed 32768 */
+  if ((rle_header.XSize == 0) || (rle_header.XSize >= 32768) ||
+      (rle_header.YSize == 0) || (rle_header.YSize >= 32768))
+    ThrowRLEReaderException(CorruptImageError,ImproperImageHeader,image);
 
-    LogRLEHeader(&rle_header);
-
-    if ((rle_header.Ncolors == 0) ||
-        (rle_header.Ncolors == 2) ||
-        ((rle_header.Flags & 0x04) && (rle_header.Ncolors > 254)) ||
-        (rle_header.Pixelbits != 8))
-      ThrowRLEReaderException(CoderError,DataEncodingSchemeIsNotSupported,image);
-
-    if ((rle_header.XSize == 0) || (rle_header.YSize == 0))
-      ThrowRLEReaderException(CorruptImageError,ImproperImageHeader,image);
-
-    image->columns=rle_header.XSize;
-    image->rows=rle_header.YSize;
-    image->matte=rle_header.Flags & 0x04;
-    number_planes=rle_header.Ncolors;
-    number_colormaps=rle_header.Ncmap;
-    map_length=(1U << rle_header.Cmaplen);
-
-    (void) memset(background_color,0,sizeof(background_color));
-    if (rle_header.Flags & 0x02)
-      {
-        /*
-          No background color-- initialize to black.
-        */
-        for (i=0; i < number_planes; i++)
-          background_color[i]=0;
-        (void) ReadBlobByte(image);
-      }
-    else
-      {
-        /*
-          Initialize background color.
-        */
-        p=background_color;
-        for (i=0; i < number_planes; i++)
-          *p++=ReadBlobByte(image);
-      }
-    if ((number_planes & 0x01) == 0)
+  if (rle_header.Cmaplen > 8)
+    ThrowRLEReaderException(CorruptImageError,ImproperImageHeader,image);
+
+  image->columns=rle_header.XSize;
+  image->rows=rle_header.YSize;
+  image->matte=rle_header.Flags & AlphaFlag;
+  number_planes=rle_header.Ncolors;
+  number_colormaps=rle_header.Ncmap;
+  map_length=(size_t) (1UL << rle_header.Cmaplen);
+
+  (void) memset(background_color,0,sizeof(background_color));
+  if (rle_header.Flags & NoBackgroundFlag)
+    {
+      /*
+        No background color-- initialize to black.
+      */
+      for (i=0; i < number_planes; i++)
+        background_color[i]=0;
       (void) ReadBlobByte(image);
+    }
+  else
+    {
+      /*
+        Initialize background color.
+      */
+      p=background_color;
+      for (i=0; i < number_planes; i++)
+        *p++=ReadBlobByte(image);
+    }
+  if ((number_planes & 0x01) == 0)
+    (void) ReadBlobByte(image);
 
-    if (EOFBlob(image))
-      ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+  if (EOFBlob(image))
+    ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
 
-    if (image->matte)
-      number_planes++;
-
-    /*
-      Rationalize pixels with file size
-    */
-    if ((file_size == 0) ||
-        ((((double) image->columns*image->rows*number_planes*
-           rle_header.Pixelbits/8)/file_size) > 254.0))
-      ThrowRLEReaderException(CorruptImageError,InsufficientImageDataInFile,
-                              image);
-
-    if ((double) number_colormaps*map_length > file_size)
-      ThrowRLEReaderException(CorruptImageError,InsufficientImageDataInFile,
-                              image);
-
-    colormap=(unsigned char *) NULL;
-    colormap_entries=0;
-    if (number_colormaps != 0)
-      {
-        /*
-          Read image colormaps.  Color map values are stored as 16 bit
-          quantities, left justified in the word.
-        */
-        colormap=MagickAllocateArray(unsigned char *,number_colormaps,
-                                     map_length);
-        if (colormap == (unsigned char *) NULL)
-          ThrowRLEReaderException(ResourceLimitError,MemoryAllocationFailed,
-            image);
-        p=colormap; /* unsigned char * */
-        for (i=0; i < number_colormaps; i++)
-          for (x=0; x < map_length; x++)
-            {
-              if (EOFBlob(image))
-                ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,
-                                        image);
-              *p++=(ReadBlobLSBShort(image) >> 8);
-            }
-        colormap_entries=number_colormaps*map_length;
-      }
-    if (rle_header.Flags & 0x08)
-      {
-        char
-          *comment;
-
-        unsigned int
-          length;
-
-        /*
-          Read image comment.
-        */
-        length=ReadBlobLSBShort(image);
-        comment=MagickAllocateMemory(char *,length);
-        if (comment == (char *) NULL)
+  if (image->matte)
+    number_planes++;
+
+  /*
+    Rationalize pixels with file size
+  */
+  if ((file_size == 0) ||
+      ((((double) image->columns*image->rows*number_planes*
+         rle_header.Pixelbits/8)/file_size) > 254.0))
+    ThrowRLEReaderException(CorruptImageError,InsufficientImageDataInFile,
+                            image);
+
+  if ((double) number_colormaps*map_length > file_size)
+    ThrowRLEReaderException(CorruptImageError,InsufficientImageDataInFile,
+                            image);
+
+  /*
+    Cap the number of planes at 4 since we don't support more than that.
+  */
+  if (number_planes > 4)
+    number_planes=4;
+
+  colormap_entries=0;
+  if (number_colormaps != 0)
+    {
+      /*
+        Read image colormaps.  Color map values are stored as 16 bit
+        quantities, left justified in the word.
+      */
+      colormap=MagickAllocateArray(unsigned char *,number_colormaps,
+                                   map_length);
+      if (colormap == (unsigned char *) NULL)
+        ThrowRLEReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                image);
+      p=colormap; /* unsigned char * */
+      for (i=0; i < number_colormaps; i++)
+        for (x=0; x < map_length; x++)
+          {
+            if (EOFBlob(image))
+              ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,
+                                      image);
+            *p++=(ReadBlobLSBShort(image) >> 8);
+          }
+      colormap_entries=MagickArraySize(number_colormaps,map_length);
+    }
+  if (rle_header.Flags & CommentsFlag)
+    {
+      char
+        *comment;
+
+      unsigned int
+        length;
+
+      /*
+        Read image comment.
+
+        The comment block contains any number of null-terminated
+        text strings. These strings will conventionally be of the
+        form "name=value", allowing for easy retrieval of specific
+        information. However, there is no restriction that a given
+        name appear only once, and a comment may contain an
+        arbitrary string.
+      */
+      length=ReadBlobLSBShort(image);
+      comment=MagickAllocateMemory(char *,length+1);
+      if (comment == (char *) NULL)
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Failed to allocate %u bytes for comment",
+                                length+1);
           ThrowRLEReaderException(ResourceLimitError,MemoryAllocationFailed,
-            image);
-        (void) ReadBlob(image,length-1,comment);
-        comment[length-1]='\0';
-        (void) SetImageAttribute(image,"comment",comment);
-        MagickFreeMemory(comment);
-        if ((length & 0x01) == 0)
-          (void) ReadBlobByte(image);
-      }
-
-    if (EOFBlob(image))
-      ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+                                  image);
+        }
+      if (ReadBlob(image,length,comment) != length)
+        {
+          MagickFreeMemory(comment);
+          ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+        }
+      comment[length]='\0';
+      /*
+        Delimit multiple comments with '\n' so they fit in one string.
+      */
+      if (length)
+        for (i=0; i < length-1; i++)
+          {
+            if (comment[i]=='\0')
+              comment[i]='\n';
+          }
+      (void) SetImageAttribute(image,"comment",comment);
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "Comment: '%s'", comment);
+      MagickFreeMemory(comment);
+      if ((length & 0x01) == 0)
+        (void) ReadBlobByte(image);
+    }
 
-    if (image_info->ping && (image_info->subrange != 0))
-      if (image->scene >= (image_info->subimage+image_info->subrange-1))
-        break;
-
-    if (CheckImagePixelLimits(image, exception) != MagickPass)
-      ThrowRLEReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
-
-    /*
-      Allocate RLE pixels.
-    */
-    number_pixels=image->columns*image->rows;
-    if ((image->columns != 0) &&
-        (image->rows != number_pixels/image->columns))
-      number_pixels=0;
-    rle_pixels=MagickAllocateArray(unsigned char *,number_pixels,
-                                   Max(number_planes,4));
-    if (rle_pixels == (unsigned char *) NULL)
-      ThrowRLEReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-    rle_bytes=MagickArraySize(number_pixels,Max(number_planes,4));
-    (void) memset(rle_pixels,0,rle_bytes);
-    if ((rle_header.Flags & 0x01) && !(rle_header.Flags & 0x02))
-      {
-        int
-          j;
-
-        /*
-          Set background color.
-        */
-        p=rle_pixels;
-        for (i=0; i < number_pixels; i++)
+  if (EOFBlob(image))
+    ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+
+  if (image_info->ping)
+    {
+      MagickFreeMemory(colormap);
+      CloseBlob(image);
+      return(image);
+    }
+
+  if (CheckImagePixelLimits(image, exception) != MagickPass)
+    ThrowRLEReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+
+  /*
+    Allocate RLE pixels.
+  */
+  number_pixels=MagickArraySize(image->columns,image->rows);
+  rle_bytes=MagickArraySize(number_pixels,number_planes);
+  if ((number_pixels == 0) || (rle_bytes == 0))
+    ThrowRLEReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+  rle_pixels=MagickAllocateArray(unsigned char *,number_pixels,
+                                 number_planes);
+  if (rle_pixels == (unsigned char *) NULL)
+    ThrowRLEReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+  (void) memset(rle_pixels,0,rle_bytes);
+  if ((rle_header.Flags & ClearFirstFlag) &&
+      !(rle_header.Flags & NoBackgroundFlag))
+    {
+      int
+        j;
+
+      /*
+        Set background color.
+      */
+      p=rle_pixels;
+      for (i=0; i < number_pixels; i++)
         {
           if (!image->matte)
             for (j=0; j < (int) number_planes; j++)
@@ -450,201 +479,202 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
               *p++=0;  /* initialize matte channel */
             }
         }
-      }
-    /*
-      Read runlength-encoded image.
-    */
-    plane=0;
-    x=0;
-    y=0;
-    opcode=ReadBlobByte(image);
-    if (opcode == EOF)
-      ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-    do
+    }
+  /*
+    Read runlength-encoded image.
+  */
+  plane=0;
+  x=0;
+  y=0;
+  opcode=ReadBlobByte(image);
+  if (opcode == EOF)
+    ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+  do
     {
       switch (opcode & 0x3f)
-      {
-        case SkipLinesOp:
         {
-          operand=ReadBlobByte(image);
-          if (operand == EOF)
-            ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-          if (opcode & 0x40)
-            {
-              operand=ReadBlobLSBShort(image);
-              if (EOFBlob(image))
-                ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-            }
-          x=0;
-          y+=operand;
-          break;
-        }
+        case SkipLinesOp:
+          {
+            operand=ReadBlobByte(image);
+            if (operand == EOF)
+              ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+            if (opcode & 0x40)
+              {
+                operand=ReadBlobLSBShort(image);
+                if (EOFBlob(image))
+                  ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+              }
+            x=0;
+            y+=operand;
+            break;
+          }
         case SetColorOp:
-        {
-          operand=ReadBlobByte(image);
-          if (operand == EOF)
-            ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-          plane=(unsigned char) operand;
-          if (plane == 255)
-            plane=(unsigned char) (number_planes-1);
-          x=0;
-          break;
-        }
+          {
+            operand=ReadBlobByte(image);
+            if (operand == EOF)
+              ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+            plane=(unsigned char) operand;
+            if (plane == 255)
+              plane=(unsigned char) (number_planes-1);
+            x=0;
+            break;
+          }
         case SkipPixelsOp:
-        {
-          operand=ReadBlobByte(image);
-          if (operand == EOF)
-            ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-          if (opcode & 0x40)
-            {
-              operand=ReadBlobLSBShort(image);
-              if (EOFBlob(image))
-                ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-            }
-          x+=operand;
-          break;
-        }
+          {
+            operand=ReadBlobByte(image);
+            if (operand == EOF)
+              ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+            if (opcode & 0x40)
+              {
+                operand=ReadBlobLSBShort(image);
+                if (EOFBlob(image))
+                  ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+              }
+            x+=operand;
+            break;
+          }
         case ByteDataOp:
-        {
-          operand=ReadBlobByte(image);
-          if (operand == EOF)
-            ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-          if (opcode & 0x40)
-            {
-              operand=ReadBlobLSBShort(image);
-              if (EOFBlob(image))
-                ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-            }
-          p=rle_pixels+((image->rows-y-1)*image->columns*number_planes)+
-            x*number_planes+plane;
-          operand++;
-          for (i=0; i < (unsigned int) operand; i++)
           {
-            pixel=ReadBlobByte(image);
-            if (pixel == EOF)
+            operand=ReadBlobByte(image);
+            if (operand == EOF)
               ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-            if ((p >= rle_pixels) && (p < rle_pixels+rle_bytes))
-              *p=(unsigned char) pixel;
-            else
-              ThrowRLEReaderException(CorruptImageError,UnableToRunlengthDecodeImage,image);
-            p+=number_planes;
+            if (opcode & 0x40)
+              {
+                operand=ReadBlobLSBShort(image);
+                if (EOFBlob(image))
+                  ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+              }
+            offset=((image->rows-y-1)*image->columns*number_planes)+x*number_planes+plane;
+            operand++;
+            p=rle_pixels+offset;
+            for (i=0; i < (unsigned int) operand; i++)
+              {
+                pixel=ReadBlobByte(image);
+                if (pixel == EOF)
+                  ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+                if ((p >= rle_pixels) && (p < rle_pixels+rle_bytes))
+                  *p=(unsigned char) pixel;
+                else
+                  ThrowRLEReaderException(CorruptImageError,UnableToRunlengthDecodeImage,image);
+                p+=number_planes;
+              }
+            if (operand & 0x01)
+              (void) ReadBlobByte(image);
+            x+=operand;
+            break;
           }
-          if (operand & 0x01)
-            (void) ReadBlobByte(image);
-          x+=operand;
-          break;
-        }
         case RunDataOp:
-        {
-          operand=ReadBlobByte(image);
-          if (operand == EOF)
-            ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-          if (opcode & 0x40)
-            {
-              operand=ReadBlobLSBShort(image);
-              if (EOFBlob(image))
-                ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-            }
-          pixel=ReadBlobByte(image);
-          if (pixel == EOF)
-            ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-          (void) ReadBlobByte(image);
-          operand++;
-          p=rle_pixels+((image->rows-y-1)*image->columns*number_planes)+
-            x*number_planes+plane;
-          for (i=0; i < (unsigned int) operand; i++)
           {
-            if ((p >= rle_pixels) && (p < rle_pixels+rle_bytes))
-              *p=pixel;
-            else
-              ThrowRLEReaderException(CorruptImageError,UnableToRunlengthDecodeImage,image);
-            p+=number_planes;
+            operand=ReadBlobByte(image);
+            if (operand == EOF)
+              ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+            if (opcode & 0x40)
+              {
+                operand=ReadBlobLSBShort(image);
+                if (EOFBlob(image))
+                  ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+              }
+            pixel=ReadBlobByte(image);
+            if (pixel == EOF)
+              ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+            (void) ReadBlobByte(image);
+            operand++;
+            offset=((image->rows-y-1)*image->columns*number_planes)+x*number_planes+plane;
+            p=rle_pixels+offset;
+            for (i=0; i < (unsigned int) operand; i++)
+              {
+                if ((p >= rle_pixels) && (p < rle_pixels+rle_bytes))
+                  *p=pixel;
+                else
+                  ThrowRLEReaderException(CorruptImageError,UnableToRunlengthDecodeImage,image);
+                p+=number_planes;
+              }
+            x+=operand;
+            break;
           }
-          x+=operand;
-          break;
-        }
         default:
           break;
-      }
+        }
       opcode=ReadBlobByte(image);
       if (opcode == EOF)
         ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
     } while (((opcode & 0x3f) != EOFOp) && (opcode != EOF));
-    if (number_colormaps != 0)
-      {
-        unsigned int
-          mask;
-
-        /*
-          Apply colormap affineation to image.
-        */
-        mask=(map_length-1);
-        p=rle_pixels;
-        if (number_colormaps == 1)
-          for (i=0; i < number_pixels; i++)
+  if (number_colormaps != 0)
+    {
+      unsigned int
+        mask;
+
+      /*
+        Apply colormap affineation to image.
+      */
+      mask=(unsigned int) (map_length-1);
+      p=rle_pixels;
+      if (number_colormaps == 1)
+        for (i=0; i < number_pixels; i++)
           {
             index=*p & mask;
-            RLEVerifyColormapIndex(image,index,colormap_entries);
+            VerifyColormapIndexWithColors(image,index,colormap_entries);
             *p=colormap[index];
             p++;
           }
-        else
-          if ((number_planes >= 3) && (number_colormaps >= 3))
-            for (i=0; i < number_pixels; i++)
-              for (x=0; x < number_planes; x++)
+      else
+        if ((number_planes >= 3) && (number_colormaps >= 3))
+          for (i=0; i < number_pixels; i++)
+            for (x=0; x < number_planes; x++)
               {
-                index=x*map_length+(*p & mask);
-                RLEVerifyColormapIndex(image,index,colormap_entries);
+                index=x*(unsigned int) map_length+(*p & mask);
+                VerifyColormapIndexWithColors(image,index,colormap_entries);
                 *p=colormap[index];
                 p++;
               }
-      }
-    /*
-      Initialize image structure.
-    */
-    if (number_planes >= 3)
-      {
-        /*
-          Convert raster image to DirectClass pixel packets.
-        */
-        p=rle_pixels;
-        for (y=0; y < image->rows; y++)
+    }
+  /*
+    Initialize image structure.
+  */
+  if (number_planes >= 3)
+    {
+      /*
+        Convert raster image to DirectClass pixel packets.
+      */
+      p=rle_pixels;
+      for (y=0; y < image->rows; y++)
         {
           q=SetImagePixels(image,0,y,image->columns,1);
           if (q == (PixelPacket *) NULL)
             break;
           for (x=0; x < image->columns; x++)
-          {
-            q->red=ScaleCharToQuantum(*p++);
-            q->green=ScaleCharToQuantum(*p++);
-            q->blue=ScaleCharToQuantum(*p++);
-            if (image->matte)
-              q->opacity=(Quantum) (MaxRGB-ScaleCharToQuantum(*p++));
-            q++;
-          }
+            {
+              q->red=ScaleCharToQuantum(*p++);
+              q->green=ScaleCharToQuantum(*p++);
+              q->blue=ScaleCharToQuantum(*p++);
+              if (image->matte)
+                q->opacity=(Quantum) (MaxRGB-ScaleCharToQuantum(*p++));
+              q++;
+            }
           if (!SyncImagePixels(image))
             break;
           if (image->previous == (Image *) NULL)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+            image->columns,image->rows))
                 break;
         }
-      }
-    else
-      {
-        /*
-          Create colormap.
-        */
-        if (number_colormaps == 0)
-          map_length=256;
-        if (!AllocateImageColormap(image,map_length))
-          ThrowRLEReaderException(ResourceLimitError,MemoryAllocationFailed,
-            image);
-        p=colormap;
-        if (number_colormaps == 1)
-          for (i=0; i < image->colors; i++)
+    }
+  else
+    {
+      /*
+        Create colormap.
+      */
+      if (number_colormaps == 0)
+        map_length=256;
+      if (((unsigned long) map_length != map_length) ||
+          (!AllocateImageColormap(image,(unsigned long) map_length)))
+        ThrowRLEReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                image);
+      p=colormap;
+      if (number_colormaps == 1)
+        for (i=0; i < image->colors; i++)
           {
             /*
               Pseudocolor.
@@ -653,9 +683,9 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
             image->colormap[i].green=ScaleCharToQuantum(i);
             image->colormap[i].blue=ScaleCharToQuantum(i);
           }
-        else
-          if (number_colormaps > 1)
-            for (i=0; i < image->colors; i++)
+      else
+        if (number_colormaps > 1)
+          for (i=0; i < image->colors; i++)
             {
               image->colormap[i].red=ScaleCharToQuantum(*p);
               image->colormap[i].green=ScaleCharToQuantum(*(p+map_length));
@@ -665,13 +695,13 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 image->colormap[i].blue=0U;
               p++;
             }
-        p=rle_pixels;
-        if (!image->matte)
-          {
-            /*
-              Convert raster image to PseudoClass pixel packets.
-            */
-            for (y=0; y < image->rows; y++)
+      p=rle_pixels;
+      if (!image->matte)
+        {
+          /*
+            Convert raster image to PseudoClass pixel packets.
+          */
+          for (y=0; y < image->rows; y++)
             {
               q=SetImagePixels(image,0,y,image->columns,1);
               if (q == (PixelPacket *) NULL)
@@ -685,35 +715,35 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,exception,
                                               LoadImageText,image->filename,
-                                             image->columns,image->rows))
+                image->columns,image->rows))
                     break;
             }
-            (void) SyncImage(image);
-          }
-        else
-          {
-            /*
-              Image has a matte channel-- promote to DirectClass.
-            */
-            for (y=0; y < image->rows; y++)
+          (void) SyncImage(image);
+        }
+      else
+        {
+          /*
+            Image has a matte channel-- promote to DirectClass.
+          */
+          for (y=0; y < image->rows; y++)
             {
               q=SetImagePixels(image,0,y,image->columns,1);
               if (q == (PixelPacket *) NULL)
                 break;
               for (x=0; x < image->columns; x++)
-              {
-                index=*p++;
-                VerifyColormapIndex(image,index);
-                q->red=image->colormap[index].red;
-                index=*p++;
-                VerifyColormapIndex(image,index);
-                q->green=image->colormap[index].green;
-                index=*p++;
-                VerifyColormapIndex(image,index);
-                q->blue=image->colormap[index].blue;
-                q->opacity=(Quantum) (MaxRGB-ScaleCharToQuantum(*p++));
-                q++;
-              }
+                {
+                  index=*p++;
+                  VerifyColormapIndex(image,index);
+                  q->red=image->colormap[index].red;
+                  index=*p++;
+                  VerifyColormapIndex(image,index);
+                  q->green=image->colormap[index].green;
+                  index=*p++;
+                  VerifyColormapIndex(image,index);
+                  q->blue=image->colormap[index].blue;
+                  q->opacity=(Quantum) (MaxRGB-ScaleCharToQuantum(*p++));
+                  q++;
+                }
               if (!SyncImagePixels(image))
                 break;
               if (image->previous == (Image *) NULL)
@@ -721,52 +751,21 @@ static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   if (!MagickMonitorFormatted(y,image->rows,exception,
                                               LoadImageText,
                                               image->filename,
-                                             image->columns,image->rows))
+                image->columns,image->rows))
                     break;
             }
-            MagickFreeMemory(image->colormap);
-            image->colormap=(PixelPacket *) NULL;
-            image->storage_class=DirectClass;
-            image->colors=0;
-          }
-      }
-    if (number_colormaps != 0)
-      MagickFreeMemory(colormap);
-    MagickFreeMemory(rle_pixels);
-    if (EOFBlob(image))
-      {
-        ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
-          image->filename);
-        break;
-      }
-    /*
-      Proceed to next image.
-    */
-    if (image_info->subrange != 0)
-      if (image->scene >= (image_info->subimage+image_info->subrange-1))
-        break;
-    (void) ReadBlobByte(image);
-    count=ReadBlob(image,2,(char *) &rle_header.Magic);
-    if ((count == 2) && (memcmp(&rle_header.Magic,"\122\314",2) == 0))
-      {
-        /*
-          Allocate next image structure.
-        */
-        AllocateNextImage(image_info,image);
-        if (image->next == (Image *) NULL)
-          {
-            DestroyImageList(image);
-            return((Image *) NULL);
-          }
-        image=SyncNextImageInList(image);
-        if (!MagickMonitorFormatted(TellBlob(image),GetBlobSize(image),
-                                    exception,LoadImagesText,
-                                    image->filename))
-          break;
-      }
-  } while ((count == 2) && (memcmp(&rle_header.Magic,"\122\314",2) == 0));
-  while (image->previous != (Image *) NULL)
-    image=image->previous;
+          MagickFreeMemory(image->colormap);
+          image->colormap=(PixelPacket *) NULL;
+          image->storage_class=DirectClass;
+          image->colors=0;
+        }
+    }
+  MagickFreeMemory(colormap);
+  MagickFreeMemory(rle_pixels);
+  if (EOFBlob(image))
+    {
+      ThrowRLEReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+    }
   CloseBlob(image);
   return(image);
 }
@@ -805,6 +804,7 @@ ModuleExport void RegisterRLEImage(void)
   entry->adjoin=False;
   entry->description="Utah Run length encoded image";
   entry->module="RLE";
+  entry->coder_class=UnstableCoderClass;
   (void) RegisterMagickInfo(entry);
 }
 \f
index 4de52d7..95db45e 100644 (file)
@@ -274,7 +274,7 @@ static Image *ReadSCTImage(const ImageInfo *image_info,ExceptionInfo *exception)
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                   image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
     if (EOFBlob(image))
       break;
index 0880755..9ece042 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -115,23 +115,21 @@ static unsigned int IsSFW(const unsigned char *magick,const size_t length)
 */
 
 static unsigned char *SFWScan(const unsigned char *p,const unsigned char *q,
-                             const unsigned char *target,const size_t length)
+                              const unsigned char *target,const size_t length)
 {
   register size_t
     i;
 
-  if (p+length < q)
+  while ((p+length) < q)
     {
-      while( p < q )
-       {
-         for (i=0; i < length; i++)
-           if (p[i] != target[i])
-             break;
-         if (i == length)
-           return((unsigned char *) p);
-         p++;
-       }
+      for (i=0; i < length; i++)
+        if (p[i] != target[i])
+          break;
+      if (i == length)
+        return((unsigned char *) p);
+      p++;
     }
+
   return((unsigned char *) NULL);
 }
 
@@ -212,7 +210,8 @@ static Image *ReadSFWImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
   char
     original_filename[MaxTextExtent],
-    original_magick[MaxTextExtent];
+    original_magick[MaxTextExtent],
+    temporary_filename[MaxTextExtent];
 
   size_t
     count;
@@ -251,7 +250,7 @@ static Image *ReadSFWImage(const ImageInfo *image_info,ExceptionInfo *exception)
     if ((magick_off_t) buffer_size != blob_size)
       buffer_size=0;
   }
-  if (buffer_size < 7)
+  if (buffer_size < 141)
     {
       ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
     }
@@ -269,8 +268,9 @@ static Image *ReadSFWImage(const ImageInfo *image_info,ExceptionInfo *exception)
     Find the start of the JFIF data
   */
   header=SFWScan(buffer,buffer_end,
-                (unsigned char *)"\377\310\377\320",4);
-  if (header == (unsigned char *) NULL)
+                 (unsigned char *)"\377\310\377\320",4);
+  if ((header == (unsigned char *) NULL) ||
+      (header+6+134 > buffer_end)) /* 134 ~ Minimum JFIF size */
     {
       MagickFreeMemory(buffer);
       ThrowReaderException(CorruptImageError,ImproperImageHeader,image)
@@ -290,8 +290,8 @@ static Image *ReadSFWImage(const ImageInfo *image_info,ExceptionInfo *exception)
   {
     if (offset+4 > buffer_end)
       {
-       MagickFreeMemory(buffer);
-       ThrowReaderException(CorruptImageError,ImproperImageHeader,image)
+        MagickFreeMemory(buffer);
+        ThrowReaderException(CorruptImageError,ImproperImageHeader,image)
       }
     TranslateSFWMarker(offset);
     if (offset[1] == 0xda)
@@ -313,16 +313,12 @@ static Image *ReadSFWImage(const ImageInfo *image_info,ExceptionInfo *exception)
   clone_info=CloneImageInfo(image_info);
   clone_info->blob=(void *) NULL;
   clone_info->length=0;
-  file=AcquireTemporaryFileStream(clone_info->filename,BinaryFileIOMode);
+  file=AcquireTemporaryFileStream(temporary_filename,BinaryFileIOMode);
   if (file == (FILE *) NULL)
     {
-      char
-        filename[MaxTextExtent];
-
-      (void) strcpy(filename,clone_info->filename);
       MagickFreeMemory(buffer);
       DestroyImageInfo(clone_info);
-      ThrowReaderTemporaryFileException(filename)
+      ThrowReaderTemporaryFileException(image_info->filename)
     }
   (void) fwrite(header,(size_t) (offset-header+1),1,file);
   (void) fwrite(HuffmanTable,1,sizeof(HuffmanTable)/sizeof(*HuffmanTable),file);
@@ -332,7 +328,7 @@ static Image *ReadSFWImage(const ImageInfo *image_info,ExceptionInfo *exception)
   MagickFreeMemory(buffer);
   if (status)
     {
-      (void) LiberateTemporaryFile(clone_info->filename);
+      (void) LiberateTemporaryFile(temporary_filename);
       DestroyImageInfo(clone_info);
       ThrowReaderException(FileOpenError,UnableToWriteFile,image)
     }
@@ -343,8 +339,10 @@ static Image *ReadSFWImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Read JPEG image.
   */
+  (void) strlcpy(clone_info->filename,"JPEG:",sizeof(clone_info->filename));
+  (void) strlcat(clone_info->filename,temporary_filename,sizeof(clone_info->filename));
   image=ReadImage(clone_info,exception);
-  (void) LiberateTemporaryFile(clone_info->filename);
+  (void) LiberateTemporaryFile(temporary_filename);
   DestroyImageInfo(clone_info);
   if (image == (Image *) NULL)
     return(image);
@@ -402,6 +400,7 @@ ModuleExport void RegisterSFWImage(void)
   entry->adjoin=False;
   entry->description="Seattle Film Works";
   entry->module="SFW";
+  entry->seekable_stream=True;
   entry->coder_class=UnstableCoderClass;
   (void) RegisterMagickInfo(entry);
 }
index b724bbe..2f01fc7 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -162,8 +162,8 @@ static unsigned int IsSGI(const unsigned char *magick,const size_t length)
 */
 
 static int SGIDecode(const size_t bytes_per_pixel,
-                    unsigned char *max_packets,unsigned char *pixels,
-                    size_t npackets,size_t npixels)
+                     unsigned char *max_packets,unsigned char *pixels,
+                     size_t npackets,size_t npixels)
 {
   size_t
     count;
@@ -180,72 +180,72 @@ static int SGIDecode(const size_t bytes_per_pixel,
   if (bytes_per_pixel == 2)
     {
       for ( ; ; )
-       {
-         if (npackets-- == 0)
-           return -1;
-         pixel=(*p++) << 8U;
-         pixel|=(*p++);
-         count=(pixel & 0x7fU);
-         if (count == 0)
-           break;
-         if (count > npixels)
-           return -1;
-         npixels -= count;
-         if (pixel & 0x80U)
-           for ( ; count != 0U; count--)
-             {
-               if (npackets-- == 0)
-                 return -1;
-               *q=(*p++);
-               *(q+1)=(*p++);
-               q+=8U;
-             }
-         else
-           {
-             if (npackets-- == 0)
-               return -1;
-             pixel=(*p++) << 8U;
-             pixel|=(*p++);
-             for ( ; count != 0; count--)
-               {
-                 *q=(unsigned char) (pixel >> 8U);
-                 *(q+1)=(unsigned char) pixel;
-                 q+=8U;
-               }
-           }
-       }
+        {
+          if (npackets-- == 0)
+            return -1;
+          pixel=(*p++) << 8U;
+          pixel|=(*p++);
+          count=(pixel & 0x7fU);
+          if (count == 0)
+            break;
+          if (count > npixels)
+            return -1;
+          npixels -= count;
+          if (pixel & 0x80U)
+            for ( ; count != 0U; count--)
+              {
+                if (npackets-- == 0)
+                  return -1;
+                *q=(*p++);
+                *(q+1)=(*p++);
+                q+=8U;
+              }
+          else
+            {
+              if (npackets-- == 0)
+                return -1;
+              pixel=(*p++) << 8U;
+              pixel|=(*p++);
+              for ( ; count != 0; count--)
+                {
+                  *q=(unsigned char) (pixel >> 8U);
+                  *(q+1)=(unsigned char) pixel;
+                  q+=8U;
+                }
+            }
+        }
       return 0;
     }
   for ( ; ; )
     {
       if (npackets-- == 0)
-       return -1;
+        return -1;
       pixel=(*p++);
       count= (pixel & 0x7fU);
       if (count == 0)
-       break;
+        break;
       if (count > npixels)
-       return -1;
+        return -1;
       npixels -= count;
       if (pixel & 0x80)
-       for ( ; count != 0; count--)
-         {
-           if (npackets-- == 0)
-             return -1;
-           *q=(*p++);
-           q+=4;
-         }
+        for ( ; count != 0; count--)
+          {
+            if (npackets-- == 0)
+              return -1;
+            *q=(*p++);
+            q+=4;
+          }
       else
-       {
-         if (npackets-- == 0)
-           return -1;
-         pixel=(*p++);
-         for ( ; count != 0; count--)
-           {
-             *q=(unsigned char) pixel;
-             q+=4;
-           }
-       }
+        {
+          if (npackets-- == 0)
+            return -1;
+          pixel=(*p++);
+          for ( ; count != 0; count--)
+            {
+              *q=(unsigned char) pixel;
+              q+=4;
+            }
+        }
     }
   return 0;
 }
@@ -266,15 +266,17 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception)
     *image;
 
   size_t
-    y,
     z;
 
   register IndexPacket
     *indexes;
 
   register size_t
-    i,
-    x;
+    i;
+
+  unsigned long
+        x,
+    y;
 
   register PixelPacket
     *q;
@@ -314,18 +316,14 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception)
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == False)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
-  /*
-    Read SGI raster header.
-  */
-  iris_info.magic=ReadBlobMSBShort(image);
   file_size=GetBlobSize(image);
   do
     {
       /*
-       Verify SGI identifier.
+        Read SGI raster header.
       */
-      if (iris_info.magic != 0x01DA)
-       ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+      (void) memset(&iris_info, 0, sizeof(iris_info));
+      iris_info.magic=ReadBlobMSBShort(image);
       iris_info.storage=ReadBlobByte(image);
       iris_info.bytes_per_pixel=ReadBlobByte(image) &0xF;
       iris_info.dimension=ReadBlobMSBShort(image) & 0xFFFF;
@@ -336,16 +334,19 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception)
       iris_info.pix_max=ReadBlobMSBLong(image) & 0xFFFFFFFF;
 
       (void) ReadBlob(image,(unsigned int) sizeof(iris_info.dummy1),
-                     iris_info.dummy1);
+                      iris_info.dummy1);
       (void) ReadBlob(image,(unsigned int) sizeof(iris_info.image_name),
-                     iris_info.image_name);
+                      iris_info.image_name);
       iris_info.image_name[sizeof(iris_info.image_name)-1]=0;
       iris_info.color_map=ReadBlobMSBLong(image);
       (void) ReadBlob(image,(unsigned int) sizeof(iris_info.dummy2),
-                     iris_info.dummy2);
+                      iris_info.dummy2);
+
+      if (EOFBlob(image))
+        ThrowReaderException(CorruptImageError,UnableToReadImageHeader,image);
 
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "IRIS Header:\n"
+                            "IRIS Header:\n"
                             "    MAGIC=%u\n"
                             "    STORAGE=%u (%s)\n"
                             "    BPC=%u\n"
@@ -358,73 +359,76 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception)
                             "    IMAGENAME=\"%.79s\"\n"
                             "    COLORMAP=%u",
                             (unsigned int) iris_info.magic,
-                           (unsigned int) iris_info.storage,
+                            (unsigned int) iris_info.storage,
                             (iris_info.storage == 1 ? "RLE" : "VERBATIM"),
-                           (unsigned int) iris_info.bytes_per_pixel,
-                           (unsigned int) iris_info.dimension,
-                           (unsigned int) iris_info.xsize,
-                           (unsigned int) iris_info.ysize,
-                           (unsigned int) iris_info.zsize,
-                           iris_info.pix_min,
-                           iris_info.pix_max,
-                           iris_info.image_name,
-                           iris_info.color_map);
+                            (unsigned int) iris_info.bytes_per_pixel,
+                            (unsigned int) iris_info.dimension,
+                            (unsigned int) iris_info.xsize,
+                            (unsigned int) iris_info.ysize,
+                            (unsigned int) iris_info.zsize,
+                            iris_info.pix_min,
+                            iris_info.pix_max,
+                            iris_info.image_name,
+                            iris_info.color_map);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                             "File size %" MAGICK_OFF_F "d bytes", file_size);
 
       /*
-       Validate image header and set image attributes.
+        Validate image header and set image attributes.
       */
+      if (iris_info.magic != 0x01DA)
+        ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+
       if (iris_info.storage == 0U)
-       {
-         /* Uncompressed */
-         image->compression=NoCompression;
-       }
+        {
+          /* Uncompressed */
+          image->compression=NoCompression;
+        }
       else if (iris_info.storage == 1U)
-       {
-         /* RLE compressed */
-         image->compression=RLECompression;
-       }
+        {
+          /* RLE compressed */
+          image->compression=RLECompression;
+        }
       else
-       {
-         /* Error */
-         ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
-       }
+        {
+          /* Error */
+          ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+        }
 
       if (iris_info.color_map != 0U)
-       {
-         /* We only support images with normal (no) colormap */
-         ThrowReaderException(CorruptImageError,ImageTypeNotSupported,image);
-       }
+        {
+          /* We only support images with normal (no) colormap */
+          ThrowReaderException(CorruptImageError,ImageTypeNotSupported,image);
+        }
 
       if (iris_info.bytes_per_pixel == 1U)
-       {
-         /* 8 bits per sample */
-         image->depth=8;
-       }
+        {
+          /* 8 bits per sample */
+          image->depth=8;
+        }
       else if (iris_info.bytes_per_pixel == 2U)
-       {
-         /* 16 bits per sample */
-         image->depth=Min(16,QuantumDepth);
-       }
+        {
+          /* 16 bits per sample */
+          image->depth=Min(16,QuantumDepth);
+        }
       else
-       {
-         /* Error */
-         ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
-       }
+        {
+          /* Error */
+          ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+        }
 
       /* We only support zsize up to 4. Code further on assumes that. */
       if (iris_info.zsize > 4U)
         ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
 
       if (iris_info.dimension == 1U)
-       {
-         /*
-           Image contains one channel and one scanline, with scanline
-           length specified by xsize.
-         */
-         image->columns=iris_info.xsize;
-         image->rows=1;
+        {
+          /*
+            Image contains one channel and one scanline, with scanline
+            length specified by xsize.
+          */
+          image->columns=iris_info.xsize;
+          image->rows=1;
           if (iris_info.ysize != image->rows)
             {
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -432,86 +436,86 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception)
                                     "for 1 dimensional image", iris_info.ysize);
               iris_info.ysize=image->rows;
             }
-         image->is_grayscale=MagickTrue;
-         if (iris_info.bytes_per_pixel == 1U)
-           {
-             /* Use a grayscale colormap */
-             image->storage_class=PseudoClass;
-             image->colors=256;
-           }
-       }
+          image->is_grayscale=MagickTrue;
+          if (iris_info.bytes_per_pixel == 1U)
+            {
+              /* Use a grayscale colormap */
+              image->storage_class=PseudoClass;
+              image->colors=256;
+            }
+        }
       else if (iris_info.dimension == 2U)
-       {
-         /*
-           One channel with a number of scan lines.  Width and height
-           of image are given by the values of xsize and ysize.
-         */
-         image->columns=iris_info.xsize;
-         image->rows=iris_info.ysize;
-         image->is_grayscale=MagickTrue;
-         if (iris_info.bytes_per_pixel == 1)
-           {
-             /* Use a grayscale colormap */
-             image->storage_class=PseudoClass;
-             image->colors=256;
-           }
-       }
+        {
+          /*
+            One channel with a number of scan lines.  Width and height
+            of image are given by the values of xsize and ysize.
+          */
+          image->columns=iris_info.xsize;
+          image->rows=iris_info.ysize;
+          image->is_grayscale=MagickTrue;
+          if (iris_info.bytes_per_pixel == 1)
+            {
+              /* Use a grayscale colormap */
+              image->storage_class=PseudoClass;
+              image->colors=256;
+            }
+        }
       else if (iris_info.dimension == 3U)
-       {
-         /*
-           A number of channels.  Width and height of image are given
-           by the values of xsize and ysize. The number of channels is
-           specified by zsize.
-
-           B/W images have a zsize of 1.  RGB images have a zsize of 3.
-           RGB images with an alpha channel have a zsize of 4. Images
-           may have more than four channels but the meaning of
-           additional channels is implementation dependent.
-         */
-
-         image->columns=iris_info.xsize;
-         image->rows=iris_info.ysize;
-
-         if (iris_info.zsize == 1U)
-           {
-             /* B/W image */
-             image->matte = MagickFalse;
-             image->is_grayscale=MagickTrue;
-             if (iris_info.bytes_per_pixel == 1U)
-               {
-                 /* Use a grayscale colormap */
-                 image->storage_class=PseudoClass;
-                 image->colors=256U;
-               }
-           }
-         else if (iris_info.zsize == 3U)
-           {
-             /* RGB */
-             image->matte=MagickFalse;
-           }
-         else if (iris_info.zsize == 4U)
-           {
-             /* RGBA  */
-             image->matte=MagickTrue;
-           }
-         else
-           {
-             /* Error */
-             ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
-           }
-       }
+        {
+          /*
+            A number of channels.  Width and height of image are given
+            by the values of xsize and ysize. The number of channels is
+            specified by zsize.
+
+            B/W images have a zsize of 1.  RGB images have a zsize of 3.
+            RGB images with an alpha channel have a zsize of 4. Images
+            may have more than four channels but the meaning of
+            additional channels is implementation dependent.
+          */
+
+          image->columns=iris_info.xsize;
+          image->rows=iris_info.ysize;
+
+          if (iris_info.zsize == 1U)
+            {
+              /* B/W image */
+              image->matte = MagickFalse;
+              image->is_grayscale=MagickTrue;
+              if (iris_info.bytes_per_pixel == 1U)
+                {
+                  /* Use a grayscale colormap */
+                  image->storage_class=PseudoClass;
+                  image->colors=256U;
+                }
+            }
+          else if (iris_info.zsize == 3U)
+            {
+              /* RGB */
+              image->matte=MagickFalse;
+            }
+          else if (iris_info.zsize == 4U)
+            {
+              /* RGBA  */
+              image->matte=MagickTrue;
+            }
+          else
+            {
+              /* Error */
+              ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+            }
+        }
       else
-       {
-         /* Error */
-         ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
-       }
+        {
+          /* Error */
+          ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+        }
 
       if (iris_info.image_name[0])
-       (void) SetImageAttribute(image,"comment",iris_info.image_name);
+        (void) SetImageAttribute(image,"comment",iris_info.image_name);
 
       if (image_info->ping && (image_info->subrange != 0))
-       if (image->scene >= (image_info->subimage+image_info->subrange-1))
-         break;
+        if (image->scene >= (image_info->subimage+image_info->subrange-1))
+          break;
 
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                             "Image columns=%lu rows=%lu", image->columns, image->rows);
@@ -520,14 +524,17 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception)
         ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
 
       /*
-       Allocate SGI pixels.
+        Allocate SGI pixels.
       */
       bytes_per_pixel=iris_info.bytes_per_pixel;
       if (iris_info.storage != 0x01)
-       {
+        {
           double
               uncompressed_size;
 
+          size_t
+            iris_pixels_size;
+
           /*
             Check that filesize is reasonable given header
           */
@@ -541,63 +548,65 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception)
             ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,
                                  image);
 
-         /*
-           Read standard image format.
-         */
-         scanline=MagickAllocateArray(unsigned char *,
+          /*
+            Read standard image format.
+          */
+          scanline=MagickAllocateArray(unsigned char *,
                                        bytes_per_pixel,iris_info.xsize);
-         if (scanline == (unsigned char *) NULL)
-           ThrowSGIReaderException(ResourceLimitError,MemoryAllocationFailed,
+          if (scanline == (unsigned char *) NULL)
+            ThrowSGIReaderException(ResourceLimitError,MemoryAllocationFailed,
                                     image);
 
-          iris_pixels=MagickAllocateArray(unsigned char *,
-                                          MagickArraySize(4U,bytes_per_pixel),
-                                          MagickArraySize(iris_info.xsize,iris_info.ysize));
+          iris_pixels_size = MagickArraySize(MagickArraySize(4U,bytes_per_pixel),
+                                             MagickArraySize(iris_info.xsize,iris_info.ysize));
+          iris_pixels=MagickAllocateMemory(unsigned char *,iris_pixels_size);
           if (iris_pixels == (unsigned char *) NULL)
             ThrowSGIReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+          (void) memset(iris_pixels,0,iris_pixels_size);
 
-         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "   Reading SGI scanlines"); 
-         for (z=0U; z < iris_info.zsize; z++)
-           {
-             p=iris_pixels+bytes_per_pixel*z;
-             for (y=0U; y < iris_info.ysize; y++)
-               {
-                 if (ReadBlob(image,bytes_per_pixel*iris_info.xsize,
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "   Reading SGI scanlines");
+          for (z=0U; z < iris_info.zsize; z++)
+            {
+              p=iris_pixels+bytes_per_pixel*z;
+              for (y=0U; y < iris_info.ysize; y++)
+                {
+                  if (ReadBlob(image,bytes_per_pixel*iris_info.xsize,
                                (char *) scanline) != bytes_per_pixel*iris_info.xsize)
-                   {
-                     ThrowSGIReaderException(CorruptImageError,
+                    {
+                      ThrowSGIReaderException(CorruptImageError,
                                               UnexpectedEndOfFile, image);
-                     break;
-                   }
-                 if (bytes_per_pixel == 2U)
-                   for (x=0; x < iris_info.xsize; x++)
-                     {
-                       *p=scanline[2U*x];
-                       *(p+1U)=scanline[2U*x+1U];
-                       p+=8U;
-                     }
-                 else
-                   for (x=0; x < iris_info.xsize; x++)
-                     {
-                       *p=scanline[x];
-                       p+=4U;
-                     }
-               }
-             if (EOFBlob(image))
-               break;
-           }
-         MagickFreeMemory(scanline);
-       }
+                      break;
+                    }
+                  if (bytes_per_pixel == 2U)
+                    for (x=0; x < iris_info.xsize; x++)
+                      {
+                        *p=scanline[2U*x];
+                        *(p+1U)=scanline[2U*x+1U];
+                        p+=8U;
+                      }
+                  else
+                    for (x=0; x < iris_info.xsize; x++)
+                      {
+                        *p=scanline[x];
+                        p+=4U;
+                      }
+                }
+              if (EOFBlob(image))
+                break;
+            }
+          MagickFreeMemory(scanline);
+        }
       else
-       {
-         unsigned int
-           data_order;
+        {
+          unsigned int
+            data_order;
 
-         magick_off_t
-           offset;
+          magick_off_t
+            offset;
 
           size_t
+            iris_pixels_size,
             max_packets_alloc_size,
             rle_alloc_size,
             rle_dimensions;
@@ -612,13 +621,13 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception)
             ThrowSGIReaderException(ResourceLimitError,MemoryAllocationFailed,
                                     image);
 
-         /*
-           Read runlength-encoded image format.
-         */
+          /*
+            Read runlength-encoded image format.
+          */
           if (TellBlob(image)+rle_alloc_size > (size_t) file_size)
             ThrowSGIReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-         offsets=MagickAllocateMemory(magick_uint32_t *,rle_alloc_size);
-         if (offsets == (magick_uint32_t *) NULL)
+          offsets=MagickAllocateMemory(magick_uint32_t *,rle_alloc_size);
+          if (offsets == (magick_uint32_t *) NULL)
             ThrowSGIReaderException(ResourceLimitError,MemoryAllocationFailed,
                                     image);
           if (ReadBlob(image,rle_alloc_size,offsets) != rle_alloc_size)
@@ -626,8 +635,8 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
           if (TellBlob(image)+rle_alloc_size > (size_t) file_size)
             ThrowSGIReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-         runlength=MagickAllocateMemory(magick_uint32_t *,rle_alloc_size);
-         if (runlength == (magick_uint32_t *) NULL)
+          runlength=MagickAllocateMemory(magick_uint32_t *,rle_alloc_size);
+          if (runlength == (magick_uint32_t *) NULL)
             ThrowSGIReaderException(ResourceLimitError,MemoryAllocationFailed,
                                     image);
           if (ReadBlob(image,rle_alloc_size,runlength) != rle_alloc_size)
@@ -647,250 +656,265 @@ static Image *ReadSGIImage(const ImageInfo *image_info,ExceptionInfo *exception)
           for (i=0U; i < rle_dimensions; i++)
             {
               if (runlength[i] > ((size_t) 4U*iris_info.xsize+10U))
-               ThrowSGIReaderException(CorruptImageError,UnableToRunlengthDecodeImage,image);
+                ThrowSGIReaderException(CorruptImageError,UnableToRunlengthDecodeImage,image);
             }
 
           max_packets_alloc_size=MagickArraySize(iris_info.xsize+10U,4U);
-         max_packets=MagickAllocateMemory(unsigned char *,max_packets_alloc_size);
-         if (max_packets == (unsigned char *) NULL)
+          max_packets=MagickAllocateMemory(unsigned char *,max_packets_alloc_size);
+          if (max_packets == (unsigned char *) NULL)
             ThrowSGIReaderException(ResourceLimitError,MemoryAllocationFailed,
                                     image);
 
-          iris_pixels=MagickAllocateArray(unsigned char *,
-                                          MagickArraySize(4U,bytes_per_pixel),
-                                          MagickArraySize(iris_info.xsize,iris_info.ysize));
+          iris_pixels_size=MagickArraySize(MagickArraySize(4U,bytes_per_pixel),
+                                           MagickArraySize(iris_info.xsize,iris_info.ysize));
+          iris_pixels=MagickAllocateMemory(unsigned char *,iris_pixels_size);
           if (iris_pixels == (unsigned char *) NULL)
             ThrowSGIReaderException(ResourceLimitError,MemoryAllocationFailed,image);
 
-         /*
-           Check data order.
-         */
-         offset=0;
-         data_order=0U;
-         for (y=0; ((y < iris_info.ysize) && !data_order); y++)
-           for (z=0U; ((z < iris_info.zsize) && !data_order); z++)
-             {
+          (void) memset(iris_pixels,0,iris_pixels_size);
+
+          /*
+            Check data order.
+          */
+          offset=0;
+          data_order=0U;
+          for (y=0; ((y < iris_info.ysize) && !data_order); y++)
+            for (z=0U; ((z < iris_info.zsize) && !data_order); z++)
+              {
                 const size_t run_index = (size_t) y+z*iris_info.ysize;
                 if (run_index >= rle_alloc_size)
                   ThrowSGIReaderException(CorruptImageError,
                                           UnableToRunlengthDecodeImage,image);
-               if (offsets[run_index] < offset)
-                 data_order=1;
-               offset=(magick_off_t) offsets[run_index];
-             }
-         offset=TellBlob(image);
-         if (data_order == 1)
-           {
-             for (z=0U; z < iris_info.zsize; z++)
-               {
-                 p=iris_pixels;
-                 for (y=0U; y < iris_info.ysize; y++)
-                   {
+                if (offsets[run_index] < offset)
+                  data_order=1;
+                offset=(magick_off_t) offsets[run_index];
+              }
+          offset=TellBlob(image);
+          if (data_order == 1)
+            {
+              for (z=0U; z < iris_info.zsize; z++)
+                {
+                  p=iris_pixels;
+                  for (y=0U; y < iris_info.ysize; y++)
+                    {
                       const size_t run_index = (size_t) y+z*iris_info.ysize;
                       size_t length;
                       if (run_index >= rle_alloc_size)
                         ThrowSGIReaderException(CorruptImageError,
                                                 UnableToRunlengthDecodeImage,image);
-                     if (offset != (magick_off_t) offsets[run_index])
-                       {
-                         offset=(magick_off_t) offsets[run_index];
-                         if (SeekBlob(image,offset,SEEK_SET) != offset)
+                      if (offset != (magick_off_t) offsets[run_index])
+                        {
+                          offset=(magick_off_t) offsets[run_index];
+                          if (SeekBlob(image,offset,SEEK_SET) != offset)
                             ThrowSGIReaderException(CorruptImageError,
                                                     UnableToRunlengthDecodeImage, image);
-                       }
+                        }
                       length=runlength[run_index];
                       if (length > max_packets_alloc_size)
                         ThrowSGIReaderException(CorruptImageError,
                                                 UnableToRunlengthDecodeImage,image);
-                     if (ReadBlob(image,length,(char *) max_packets) != length)
+                      if (ReadBlob(image,length,(char *) max_packets) != length)
                         ThrowSGIReaderException(CorruptImageError,
                                                 UnexpectedEndOfFile, image);
-                     offset+=(magick_off_t) length;
-                     if (SGIDecode(bytes_per_pixel,max_packets,p+bytes_per_pixel*z,
-                                   length/bytes_per_pixel,
-                                   iris_info.xsize) == -1)
-                       ThrowSGIReaderException(CorruptImageError,
+                      offset+=(magick_off_t) length;
+                      if (SGIDecode(bytes_per_pixel,max_packets,p+bytes_per_pixel*z,
+                                    length/bytes_per_pixel,
+                                    iris_info.xsize) == -1)
+                        ThrowSGIReaderException(CorruptImageError,
                                                 UnableToRunlengthDecodeImage,image);
-                     p+=((size_t) iris_info.xsize*4U*bytes_per_pixel);
-                   }
-               }
-           }
-         else
-           {
-             p=iris_pixels;
-             for (y=0; y < iris_info.ysize; y++)
-               {
-                 for (z=0; z < iris_info.zsize; z++)
-                   {
+                      p+=((size_t) iris_info.xsize*4U*bytes_per_pixel);
+                    }
+                }
+            }
+          else
+            {
+              p=iris_pixels;
+              for (y=0; y < iris_info.ysize; y++)
+                {
+                  for (z=0; z < iris_info.zsize; z++)
+                    {
                       const size_t run_index = (size_t) y+z*iris_info.ysize;
                       size_t length;
                       if (run_index >= rle_alloc_size)
                         ThrowSGIReaderException(CorruptImageError,
                                                 UnableToRunlengthDecodeImage,image);
-                     if (offset != (magick_off_t) offsets[run_index])
-                       {
-                         offset=(magick_off_t) offsets[run_index];
-                         if (SeekBlob(image,offset,SEEK_SET) != offset)
+                      if (offset != (magick_off_t) offsets[run_index])
+                        {
+                          offset=(magick_off_t) offsets[run_index];
+                          if (SeekBlob(image,offset,SEEK_SET) != offset)
                             ThrowSGIReaderException(CorruptImageError,
                                                     UnableToRunlengthDecodeImage, image);
-                       }
+                        }
                       length=runlength[run_index];
                       if (length > max_packets_alloc_size)
                         ThrowSGIReaderException(CorruptImageError,
                                                 UnableToRunlengthDecodeImage,image);
-                     if (ReadBlob(image,length, (char *) max_packets) != length)
+                      if (ReadBlob(image,length, (char *) max_packets) != length)
                         ThrowSGIReaderException(CorruptImageError,
                                                 UnexpectedEndOfFile, image);
-                     offset+=length;
-                     if (SGIDecode(bytes_per_pixel,max_packets,p+bytes_per_pixel*z,
-                                   length/bytes_per_pixel,
-                                   iris_info.xsize) == -1)
-                       ThrowSGIReaderException(CorruptImageError,
-                                                UnableToRunlengthDecodeImage,image); 
-                   }
-                 p+=((size_t) iris_info.xsize*4U*bytes_per_pixel);
-                 if (EOFBlob(image))
-                   break;
-               }
-           }
-         MagickFreeMemory(runlength);
-         MagickFreeMemory(max_packets);
-         MagickFreeMemory(offsets);
-       }
+                      offset+=length;
+                      if (SGIDecode(bytes_per_pixel,max_packets,p+bytes_per_pixel*z,
+                                    length/bytes_per_pixel,
+                                    iris_info.xsize) == -1)
+                        ThrowSGIReaderException(CorruptImageError,
+                                                UnableToRunlengthDecodeImage,image);
+                    }
+                  p+=((size_t) iris_info.xsize*4U*bytes_per_pixel);
+                  if (EOFBlob(image))
+                    break;
+                }
+            }
+          MagickFreeMemory(runlength);
+          MagickFreeMemory(max_packets);
+          MagickFreeMemory(offsets);
+        }
 
       /*
-       Convert SGI raster image to pixel packets.
+        Convert SGI raster image to pixel packets.
       */
       if (image->storage_class == DirectClass)
-       {
-         /*
-           Convert SGI image to DirectClass pixel packets.
-         */
-         if (bytes_per_pixel == 2U)
-           {
-             for (y=0; y < image->rows; y++)
-               {
-                 p=iris_pixels+(image->rows-y-1)*8*image->columns;
-                 q=SetImagePixels(image,0,y,image->columns,1);
-                 if (q == (PixelPacket *) NULL)
-                   break;
-                 for (x=0U; x < image->columns; x++)
-                   {
-                     q->red=ScaleShortToQuantum((*(p+0) << 8U) | (*(p+1)));
-                     q->green=ScaleShortToQuantum((*(p+2) << 8U) | (*(p+3)));
-                     q->blue=ScaleShortToQuantum((*(p+4) << 8U) | (*(p+5)));
-                     if (image->matte)
-                       q->opacity=(Quantum)
-                         (MaxRGB-ScaleShortToQuantum((*(p+6) << 8) | (*(p+7))));
-                     else
-                       q->opacity=OpaqueOpacity;
-                     p+=8U;
-                     q++;
-                   }
-                 if (!SyncImagePixels(image))
-                   break;
-                 if (QuantumTick(y,image->rows))
-                   if (!MagickMonitorFormatted(y,image->rows,exception,
-                                               LoadImageText,image->filename,
-                                               image->columns,image->rows))
-                     break;
-               }
-           }
-         else
-           for (y=0; y < image->rows; y++)
-             {
-               p=iris_pixels+(image->rows-y-1)*4*image->columns;
-               q=SetImagePixels(image,0,y,image->columns,1);
-               if (q == (PixelPacket *) NULL)
-                 break;
-               for (x=0; x < image->columns; x++)
-                 {
-                   q->red=ScaleCharToQuantum(*p);
-                   q->green=ScaleCharToQuantum(*(p+1));
-                   q->blue=ScaleCharToQuantum(*(p+2));
-                   if (image->matte)
-                     q->opacity=(Quantum) (MaxRGB-ScaleCharToQuantum(*(p+3)));
-                   else
-                     q->opacity=OpaqueOpacity;
-                   p+=4;
-                   q++;
-                 }
-               if (!SyncImagePixels(image))
-                 break;
-               if (QuantumTick(y,image->rows))
-                 if (!MagickMonitorFormatted(y,image->rows,exception,
-                                             LoadImageText,image->filename,
-                                             image->columns,image->rows))
-                   break;
-             }
-       }
+        {
+          /*
+            Convert SGI image to DirectClass pixel packets.
+          */
+          if (bytes_per_pixel == 2U)
+            {
+              for (y=0; y < image->rows; y++)
+                {
+                  p=iris_pixels+(image->rows-y-1)*8*image->columns;
+                  q=SetImagePixels(image,0,y,image->columns,1);
+                  if (q == (PixelPacket *) NULL)
+                    break;
+                  for (x=0U; x < image->columns; x++)
+                    {
+                      q->red=ScaleShortToQuantum((*(p+0) << 8U) | (*(p+1)));
+                      q->green=ScaleShortToQuantum((*(p+2) << 8U) | (*(p+3)));
+                      q->blue=ScaleShortToQuantum((*(p+4) << 8U) | (*(p+5)));
+                      if (image->matte)
+                        q->opacity=(Quantum)
+                          (MaxRGB-ScaleShortToQuantum((*(p+6) << 8) | (*(p+7))));
+                      else
+                        q->opacity=OpaqueOpacity;
+                      p+=8U;
+                      q++;
+                    }
+                  if (!SyncImagePixels(image))
+                    break;
+                  if (QuantumTick(y,image->rows))
+                    if (!MagickMonitorFormatted(y,image->rows,exception,
+                                                LoadImageText,image->filename,
+                                                image->columns,image->rows))
+                      break;
+                }
+            }
+          else
+            for (y=0; y < image->rows; y++)
+              {
+                p=iris_pixels+(image->rows-y-1)*4*image->columns;
+                q=SetImagePixels(image,0,y,image->columns,1);
+                if (q == (PixelPacket *) NULL)
+                  break;
+                for (x=0; x < image->columns; x++)
+                  {
+                    q->red=ScaleCharToQuantum(*p);
+                    q->green=ScaleCharToQuantum(*(p+1));
+                    q->blue=ScaleCharToQuantum(*(p+2));
+                    if (image->matte)
+                      q->opacity=(Quantum) (MaxRGB-ScaleCharToQuantum(*(p+3)));
+                    else
+                      q->opacity=OpaqueOpacity;
+                    p+=4;
+                    q++;
+                  }
+                if (!SyncImagePixels(image))
+                  break;
+                if (QuantumTick(y,image->rows))
+                  if (!MagickMonitorFormatted(y,image->rows,exception,
+                                              LoadImageText,image->filename,
+                                              image->columns,image->rows))
+                    break;
+              }
+        }
       else
-       {
-         /*
-           Create grayscale map.
-         */
-         if (!AllocateImageColormap(image,image->colors))
-           ThrowSGIReaderException(ResourceLimitError,MemoryAllocationFailed,
+        {
+          /*
+            Create grayscale map.
+          */
+          if (!AllocateImageColormap(image,image->colors))
+            ThrowSGIReaderException(ResourceLimitError,MemoryAllocationFailed,
                                     image);
-         /*
-           Convert SGI image to PseudoClass pixel packets.
-         */
-         if (bytes_per_pixel == 2)
-           {
-             for (y=0; y < image->rows; y++)
-               {
-                 p=iris_pixels+(image->rows-y-1)*8*image->columns;
-                 q=SetImagePixels(image,0,y,image->columns,1);
-                 if (q == (PixelPacket *) NULL)
-                   break;
-                 indexes=AccessMutableIndexes(image);
-                 for (x=0; x < image->columns; x++)
-                   {
-                     indexes[x]=(*p << 8);
-                     indexes[x]|=(*(p+1));
-                     p+=8;
-                     q++;
-                   }
-                 if (!SyncImagePixels(image))
-                   break;
-                 if (QuantumTick(y,image->rows))
-                   if (!MagickMonitorFormatted(y,image->rows,exception,
-                                               LoadImageText,image->filename,
-                                               image->columns,image->rows))
-                     break;
-               }
-           }
-         else
-           for (y=0; y < image->rows; y++)
-             {
-               p=iris_pixels+(image->rows-y-1)*4U*image->columns;
-               q=SetImagePixels(image,0,y,image->columns,1);
-               if (q == (PixelPacket *) NULL)
-                 break;
-               indexes=AccessMutableIndexes(image);
-               for (x=0; x < image->columns; x++)
-                 {
-                   indexes[x]=(*p);
-                   p+=4;
-                   q++;
-                 }
-               if (!SyncImagePixels(image))
-                 break;
-               if (QuantumTick(y,image->rows))
-                 if (!MagickMonitorFormatted(y,image->rows,exception,
-                                             LoadImageText,image->filename,
-                                             image->columns,image->rows))
-                   break;
-             }
-         (void) SyncImage(image);
-       }
+          /*
+            Convert SGI image to PseudoClass pixel packets.
+          */
+          if (bytes_per_pixel == 2)
+            {
+              for (y=0; y < image->rows; y++)
+                {
+                  p=iris_pixels+(image->rows-y-1)*8*image->columns;
+                  q=SetImagePixels(image,0,y,image->columns,1);
+                  if (q == (PixelPacket *) NULL)
+                    break;
+                  indexes=AccessMutableIndexes(image);
+                  for (x=0; x < image->columns; x++)
+                    {
+                      indexes[x]=(*p << 8);
+                      indexes[x]|=(*(p+1));
+                      p+=8;
+                      q++;
+                    }
+                  if (!SyncImagePixels(image))
+                    break;
+                  if (QuantumTick(y,image->rows))
+                    if (!MagickMonitorFormatted(y,image->rows,exception,
+                                                LoadImageText,image->filename,
+                                                image->columns,image->rows))
+                      break;
+                }
+            }
+          else
+            {
+              for (y=0; y < image->rows; y++)
+                {
+                  p=iris_pixels+(image->rows-y-1)*4U*image->columns;
+                  q=SetImagePixels(image,0,y,image->columns,1);
+                  if (q == (PixelPacket *) NULL)
+                    break;
+                  indexes=AccessMutableIndexes(image);
+                  for (x=0; x < image->columns; x++)
+                    {
+                      indexes[x]=(*p);
+                      p+=4;
+                      q++;
+                    }
+                  if (!SyncImagePixels(image))
+                    break;
+                  if (QuantumTick(y,image->rows))
+                    if (!MagickMonitorFormatted(y,image->rows,exception,
+                                                LoadImageText,image->filename,
+                                                image->columns,image->rows))
+                      break;
+                }
+            }
+          if (y < image->rows)
+            {
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Only transferred %lu rows out of %lu",
+                                    y, image->rows);
+              MagickFreeMemory(iris_pixels);
+              /*
+                Not sure what a proper error report is here
+               */
+              ThrowSGIReaderException(CorruptImageError,UnableToReadImageData,image);
+            }
+          (void) SyncImage(image);
+        }
       MagickFreeMemory(iris_pixels);
       if (EOFBlob(image))
-       {
-         ThrowSGIReaderException(CorruptImageError,UnexpectedEndOfFile,
+        {
+          ThrowSGIReaderException(CorruptImageError,UnexpectedEndOfFile,
                                   image);
-         break;
-       }
+          break;
+        }
     } while (0);
   CloseBlob(image);
   return(image);
@@ -990,7 +1014,7 @@ ModuleExport void UnregisterSGIImage(void)
 */
 
 static size_t SGIEncode(unsigned char *pixels,size_t count,
-                       unsigned char *packets)
+                        unsigned char *packets)
 {
   short
     runlength;
@@ -1011,32 +1035,32 @@ static size_t SGIEncode(unsigned char *pixels,size_t count,
       mark=p;
       p+=8;
       while ((p < limit) && ((*(p-8) != *(p-4)) || (*(p-4) != *p)))
-       p+=4;
+        p+=4;
       p-=8;
       count=((p-mark) >> 2);
       while (count)
-       {
-         runlength=(short) (count > 126 ? 126 : count);
-         count-=runlength;
-         *q++=0x80 | runlength;
-         for ( ; runlength > 0; runlength--)
-           {
-             *q++=(*mark);
-             mark+=4;
-           }
-       }
+        {
+          runlength=(short) (count > 126 ? 126 : count);
+          count-=runlength;
+          *q++=0x80 | runlength;
+          for ( ; runlength > 0; runlength--)
+            {
+              *q++=(*mark);
+              mark+=4;
+            }
+        }
       mark=p;
       p+=4;
       while ((p < limit) && (*p == *mark))
-       p+=4;
+        p+=4;
       count=((p-mark) >> 2);
       while (count)
-       {
-         runlength=(short) (count > 126 ? 126 : count);
-         count-=runlength;
-         *q++=(unsigned char) runlength;
-         *q++=(*mark);
-       }
+        {
+          runlength=(short) (count > 126 ? 126 : count);
+          count-=runlength;
+          *q++=(unsigned char) runlength;
+          *q++=(*mark);
+        }
     }
   *q++=0;
   return(q-packets);
@@ -1101,60 +1125,60 @@ static unsigned int WriteSGIImage(const ImageInfo *image_info,Image *image)
   do
     {
       ImageCharacteristics
-       characteristics;
+        characteristics;
 
       /*
-       Ensure that image is in an RGB space.
+        Ensure that image is in an RGB space.
       */
       (void) TransformColorspace(image,RGBColorspace);
       /*
-       Analyze image to be written.
+        Analyze image to be written.
       */
       (void) GetImageCharacteristics(image,&characteristics,
-                                    (OptimizeType == image_info->type),
-                                    &image->exception);
+                                     (OptimizeType == image_info->type),
+                                     &image->exception);
       /*
-       Initialize SGI raster file header.
+        Initialize SGI raster file header.
       */
       iris_info.magic=0x01DA;
       if (image_info->compression == NoCompression)
-       iris_info.storage=0x00;
+        iris_info.storage=0x00;
       else
-       iris_info.storage=0x01;
+        iris_info.storage=0x01;
       iris_info.bytes_per_pixel=1;  /* one byte per pixel */
       iris_info.dimension=3;
       iris_info.xsize=(unsigned short) image->columns;
       iris_info.ysize=(unsigned short) image->rows;
       if (image->matte != MagickFalse)
-       iris_info.zsize=4;
+        iris_info.zsize=4;
       else
-       {
-         if ((image_info->type != TrueColorType) &&
-             (characteristics.grayscale))
-           {
-             iris_info.dimension=2;
-             iris_info.zsize=1;
-           }
-         else
-           iris_info.zsize=3;
-       }
+        {
+          if ((image_info->type != TrueColorType) &&
+              (characteristics.grayscale))
+            {
+              iris_info.dimension=2;
+              iris_info.zsize=1;
+            }
+          else
+            iris_info.zsize=3;
+        }
       iris_info.pix_min=0;
       iris_info.pix_max=ScaleQuantumToChar(MaxRGB);
 
       (void) memset(iris_info.dummy1,0,sizeof(iris_info.dummy1));
       {
-       const ImageAttribute
-         *attribute;
+        const ImageAttribute
+          *attribute;
 
-       (void) memset(iris_info.image_name,0,sizeof(iris_info.image_name));
-       if ((attribute=GetImageAttribute(image,"comment")))
-         (void) strlcpy(iris_info.image_name,attribute->value,sizeof(iris_info.image_name));
+        (void) memset(iris_info.image_name,0,sizeof(iris_info.image_name));
+        if ((attribute=GetImageAttribute(image,"comment")))
+          (void) strlcpy(iris_info.image_name,attribute->value,sizeof(iris_info.image_name));
       }
       iris_info.color_map=0;
       (void) memset(iris_info.dummy2,0,sizeof(iris_info.dummy2));
 
       /*
-       Write SGI header.
+        Write SGI header.
       */
       (void) WriteBlobMSBShort(image,iris_info.magic);
       (void) WriteBlobByte(image,iris_info.storage);
@@ -1166,121 +1190,121 @@ static unsigned int WriteSGIImage(const ImageInfo *image_info,Image *image)
       (void) WriteBlobMSBLong(image,iris_info.pix_min);
       (void) WriteBlobMSBLong(image,iris_info.pix_max);
       (void) WriteBlob(image,sizeof(iris_info.dummy1),
-                      (char *) iris_info.dummy1);
+                       (char *) iris_info.dummy1);
       (void) WriteBlob(image,sizeof(iris_info.image_name),
-                      (char *) iris_info.image_name);
+                       (char *) iris_info.image_name);
       (void) WriteBlobMSBLong(image,iris_info.color_map);
       (void) WriteBlob(image,sizeof(iris_info.dummy2),
-                      (char *) iris_info.dummy2);
+                       (char *) iris_info.dummy2);
       /*
-       Allocate SGI pixels.
+        Allocate SGI pixels.
       */
       number_pixels=image->columns*image->rows;
       iris_pixels=MagickAllocateMemory(unsigned char *,4*number_pixels);
       if (iris_pixels == (unsigned char *) NULL)
-       ThrowSGIWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+        ThrowSGIWriterException(ResourceLimitError,MemoryAllocationFailed,image);
       /*
-       Convert image pixels to uncompressed SGI pixels.
+        Convert image pixels to uncompressed SGI pixels.
       */
       for (y=0; y < (long) image->rows; y++)
-       {
-         p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
-         if (p == (const PixelPacket *) NULL)
-           break;
-         q=iris_pixels+((iris_info.ysize-1)-y)*(iris_info.xsize*4);
-         for (x=0; x < (long) image->columns; x++)
-           {
-             *q++=ScaleQuantumToChar(p->red);
-             *q++=ScaleQuantumToChar(p->green);
-             *q++=ScaleQuantumToChar(p->blue);
-             *q++=ScaleQuantumToChar(MaxRGB-p->opacity);
-             p++;
-           }
-         if (QuantumTick(y,image->rows))
-           if (!MagickMonitorFormatted(y,image->rows,&image->exception,
-                                       SaveImageText,image->filename,
-                                       image->columns,image->rows))
-             break;
-       }
+        {
+          p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
+          if (p == (const PixelPacket *) NULL)
+            break;
+          q=iris_pixels+((iris_info.ysize-1)-y)*(iris_info.xsize*4);
+          for (x=0; x < (long) image->columns; x++)
+            {
+              *q++=ScaleQuantumToChar(p->red);
+              *q++=ScaleQuantumToChar(p->green);
+              *q++=ScaleQuantumToChar(p->blue);
+              *q++=ScaleQuantumToChar(MaxRGB-p->opacity);
+              p++;
+            }
+          if (QuantumTick(y,image->rows))
+            if (!MagickMonitorFormatted(y,image->rows,&image->exception,
+                                        SaveImageText,image->filename,
+                                        image->columns,image->rows))
+              break;
+        }
       if (image_info->compression == NoCompression)
-       {
-         /*
-           Write uncompressed SGI pixels.
-         */
-         scanline=MagickAllocateMemory(unsigned char *,iris_info.xsize);
-         if (scanline == (unsigned char *) NULL)
-           ThrowSGIWriterException(ResourceLimitError,MemoryAllocationFailed,
+        {
+          /*
+            Write uncompressed SGI pixels.
+          */
+          scanline=MagickAllocateMemory(unsigned char *,iris_info.xsize);
+          if (scanline == (unsigned char *) NULL)
+            ThrowSGIWriterException(ResourceLimitError,MemoryAllocationFailed,
                                     image);
-         for (z=0; z < (int) iris_info.zsize; z++)
-           {
-             q=iris_pixels+z;
-             for (y=0; y < (long) iris_info.ysize; y++)
-               {
-                 for (x=0; x < (long) iris_info.xsize; x++)
-                   {
-                     scanline[x]=(*q);
-                     q+=4;
-                   }
-                 (void) WriteBlob(image,iris_info.xsize,(char *) scanline);
-               }
-           }
-         MagickFreeMemory(scanline);
-       }
+          for (z=0; z < (int) iris_info.zsize; z++)
+            {
+              q=iris_pixels+z;
+              for (y=0; y < (long) iris_info.ysize; y++)
+                {
+                  for (x=0; x < (long) iris_info.xsize; x++)
+                    {
+                      scanline[x]=(*q);
+                      q+=4;
+                    }
+                  (void) WriteBlob(image,iris_info.xsize,(char *) scanline);
+                }
+            }
+          MagickFreeMemory(scanline);
+        }
       else
-       {
-         unsigned long
-           length,
-           number_packets,
-           offset;
-
-         /*
-           Convert SGI uncompressed pixels.
-         */
-         offsets=MagickAllocateArray(unsigned long *,iris_info.ysize,
+        {
+          unsigned long
+            length,
+            number_packets,
+            offset;
+
+          /*
+            Convert SGI uncompressed pixels.
+          */
+          offsets=MagickAllocateArray(unsigned long *,iris_info.ysize,
                                       MagickArraySize(iris_info.zsize,
                                                       sizeof(unsigned long)));
-         packets=MagickAllocateArray(unsigned char *,
+          packets=MagickAllocateArray(unsigned char *,
                                       4*(2*(size_t) iris_info.xsize+10),
                                       image->rows);
-         runlength=MagickAllocateArray(unsigned long *,iris_info.ysize,
+          runlength=MagickAllocateArray(unsigned long *,iris_info.ysize,
                                         MagickArraySize(iris_info.zsize,
                                                         sizeof(unsigned long)));
-         if ((offsets == (unsigned long *) NULL) ||
-             (packets == (unsigned char *) NULL) ||
-             (runlength == (unsigned long *) NULL))
+          if ((offsets == (unsigned long *) NULL) ||
+              (packets == (unsigned char *) NULL) ||
+              (runlength == (unsigned long *) NULL))
             ThrowSGIWriterException(ResourceLimitError,MemoryAllocationFailed,
                                     image);
-         offset=512+4*2*((size_t) iris_info.ysize*iris_info.zsize);
-         number_packets=0;
-         q=iris_pixels;
-         for (y=0; y < (long) iris_info.ysize; y++)
-           {
-             for (z=0; z < (int) iris_info.zsize; z++)
-               {
-                 length=(unsigned long)
-                   SGIEncode(q+z,(int) iris_info.xsize,packets+number_packets);
-                 number_packets+=length;
-                 offsets[y+z*iris_info.ysize]=offset;
-                 runlength[y+z*iris_info.ysize]=length;
-                 offset+=length;
-               }
-             q+=(iris_info.xsize*4);
-           }
-         /*
-           Write out line start and length tables and runlength-encoded pixels.
-         */
-         for (i=0; i < (int) (iris_info.ysize*iris_info.zsize); i++)
-           (void) WriteBlobMSBLong(image,offsets[i]);
-         for (i=0; i < (int) (iris_info.ysize*iris_info.zsize); i++)
-           (void) WriteBlobMSBLong(image,runlength[i]);
-         (void) WriteBlob(image,number_packets,(char *) packets);
-         /*
-           Free memory.
-         */
-         MagickFreeMemory(runlength);
-         MagickFreeMemory(packets);
-         MagickFreeMemory(offsets);
-       }
+          offset=512+4*2*((size_t) iris_info.ysize*iris_info.zsize);
+          number_packets=0;
+          q=iris_pixels;
+          for (y=0; y < (long) iris_info.ysize; y++)
+            {
+              for (z=0; z < (int) iris_info.zsize; z++)
+                {
+                  length=(unsigned long)
+                    SGIEncode(q+z,(int) iris_info.xsize,packets+number_packets);
+                  number_packets+=length;
+                  offsets[y+z*iris_info.ysize]=offset;
+                  runlength[y+z*iris_info.ysize]=length;
+                  offset+=length;
+                }
+              q+=(iris_info.xsize*4);
+            }
+          /*
+            Write out line start and length tables and runlength-encoded pixels.
+          */
+          for (i=0; i < (int) (iris_info.ysize*iris_info.zsize); i++)
+            (void) WriteBlobMSBLong(image,offsets[i]);
+          for (i=0; i < (int) (iris_info.ysize*iris_info.zsize); i++)
+            (void) WriteBlobMSBLong(image,runlength[i]);
+          (void) WriteBlob(image,number_packets,(char *) packets);
+          /*
+            Free memory.
+          */
+          MagickFreeMemory(runlength);
+          MagickFreeMemory(packets);
+          MagickFreeMemory(offsets);
+        }
       MagickFreeMemory(iris_pixels);
     } while (0);
   CloseBlob(image);
index ba849eb..321bc5a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -228,7 +228,7 @@ ModuleExport void RegisterSTEGANOImage(void)
   entry->decoder=(DecoderHandler) ReadSTEGANOImage;
   entry->description="Steganographic image";
   entry->module="STEGANO";
-  entry->coder_class=PrimaryCoderClass;
+  entry->coder_class=StableCoderClass;
   entry->extension_treatment=IgnoreExtensionTreatment;
   (void) RegisterMagickInfo(entry);
 }
index f35abb2..6a5f968 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -490,7 +490,7 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
       }
       default:
         ThrowReaderException(CoderError,ColormapTypeNotSupported,image)
-    } 
+    }
     image->matte=(sun_info.depth == 32);
     image->columns=sun_info.width;
     image->rows=sun_info.height;
@@ -498,6 +498,12 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
     if (sun_info.depth < 8)
       image->depth=sun_info.depth;
 
+    if (image_info->ping)
+      {
+        CloseBlob(image);
+        return(image);
+      }
+
     /*
       Compute bytes per line and bytes per image for an unencoded
       image.
@@ -522,15 +528,38 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
       if (bytes_per_image > sun_info.length)
         ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
 
-    if (image_info->ping)
-      {
-        CloseBlob(image);
-        return(image);
-      }
     if (sun_info.type == RT_ENCODED)
       sun_data_length=(size_t) sun_info.length;
     else
       sun_data_length=bytes_per_image;
+
+    /*
+      Verify that data length claimed by header is supported by file size
+    */
+    if (sun_info.type == RT_ENCODED)
+      {
+        if (sun_data_length < bytes_per_image/255U)
+          {
+            ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+          }
+      }
+    if (BlobIsSeekable(image))
+      {
+        const magick_off_t file_size = GetBlobSize(image);
+        const magick_off_t current_offset = TellBlob(image);
+        if ((file_size > 0) &&
+            (current_offset > 0) &&
+            (file_size >= current_offset))
+        {
+          const magick_off_t remaining = file_size-current_offset;
+
+          if ((remaining == 0) || (remaining < (magick_off_t) sun_data_length))
+            {
+              ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+            }
+        }
+      }
+
     sun_data=MagickAllocateMemory(unsigned char *,sun_data_length);
     if (sun_data == (unsigned char *) NULL)
       ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
@@ -548,8 +577,11 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
         */
         sun_pixels=MagickAllocateMemory(unsigned char *,bytes_per_image);
         if (sun_pixels == (unsigned char *) NULL)
-          ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-            image);
+          {
+            MagickFreeMemory(sun_data);
+            ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                 image);
+          }
         status &= DecodeImage(sun_data,sun_data_length,sun_pixels,bytes_per_image);
         MagickFreeMemory(sun_data);
         if (status != MagickPass)
@@ -577,6 +609,7 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
           for (bit=7; bit >= 0; bit--)
             {
               index=((*p) & (0x01 << bit) ? 0x01 : 0x00);
+              VerifyColormapIndex(image,index);
               indexes[x+7-bit]=index;
               q[x+7-bit]=image->colormap[index];
             }
@@ -587,6 +620,7 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
             for (bit=7; bit >= (long) (8-(image->columns % 8)); bit--)
               {
                 index=((*p) & (0x01 << bit) ? 0x01 : 0x00);
+                VerifyColormapIndex(image,index);
                 indexes[x+7-bit]=index;
                 q[x+7-bit]=image->colormap[index];
               }
@@ -600,7 +634,7 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
           if (QuantumTick(y,image->rows))
             if (!MagickMonitorFormatted(y,image->rows,exception,
                                         LoadImageText,image->filename,
-                                       image->columns,image->rows))
+                                        image->columns,image->rows))
               break;
       }
     else
@@ -630,10 +664,10 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
               if (QuantumTick(y,image->rows))
                 if (!MagickMonitorFormatted(y,image->rows,exception,
                                             LoadImageText,image->filename,
-                                           image->columns,image->rows))
+                                            image->columns,image->rows))
                   break;
           }
-       }
+        }
       else
         {
           /*
@@ -676,10 +710,10 @@ static Image *ReadSUNImage(const ImageInfo *image_info,ExceptionInfo *exception)
               if (QuantumTick(y,image->rows))
                 if (!MagickMonitorFormatted(y,image->rows,exception,
                                             LoadImageText,image->filename,
-                                           image->columns,image->rows))
+                                            image->columns,image->rows))
                   break;
           }
-       }
+        }
     MagickFreeMemory(sun_pixels);
     if (EOFBlob(image))
       {
@@ -843,6 +877,9 @@ static unsigned int WriteSUNImage(const ImageInfo *image_info,Image *image)
     number_pixels,
     scene;
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -850,6 +887,7 @@ static unsigned int WriteSUNImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -980,7 +1018,7 @@ static unsigned int WriteSUNImage(const ImageInfo *image_info,Image *image)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                           SaveImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
         MagickFreeMemory(pixels);
@@ -1032,7 +1070,7 @@ static unsigned int WriteSUNImage(const ImageInfo *image_info,Image *image)
               if (QuantumTick(y,image->rows))
                 if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                             SaveImageText,image->filename,
-                                           image->columns,image->rows))
+                                            image->columns,image->rows))
                   break;
           }
         }
@@ -1067,14 +1105,14 @@ static unsigned int WriteSUNImage(const ImageInfo *image_info,Image *image)
               if (QuantumTick(y,image->rows))
                 if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                             SaveImageText,image->filename,
-                                           image->columns,image->rows))
+                                            image->columns,image->rows))
                   break;
           }
         }
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    if (!MagickMonitorFormatted(scene++,GetImageListLength(image),
+    if (!MagickMonitorFormatted(scene++,image_list_length,
                                 &image->exception,SaveImagesText,
                                 image->filename))
       break;
index ac83c7d..dde29bd 100644 (file)
@@ -155,6 +155,15 @@ typedef struct _SVGInfo
     *vertices,
     *url;
 
+  /*
+    Even though it's unlikely to happen, keep track of nested <defs> and
+    elements tagged with an id.
+  */
+  int
+    defsPushCount,      /* for tracking nested <defs> */
+    idLevelInsideDefs,  /* when an "id" is seen, remember svg->n (SVG element level) */
+    svgPushCount;       /* for tracking nested <svg> elements */
+
 #if defined(HasXML)
   xmlParserCtxtPtr
     parser;
@@ -267,51 +276,113 @@ static char **GetStyleTokens(void *context,const char *text,size_t *number_token
   char
     **tokens;
 
-  register const char
+  const char
     *p,
     *q;
 
-  register size_t
-    i;
+  size_t
+    alloc_tokens,
+    i,
+    iListFront;
 
   SVGInfo
     *svg_info;
 
+  MagickBool
+    IsFontSize = MagickFalse;
+
   svg_info=(SVGInfo *) context;
   *number_tokens=0;
+  alloc_tokens=0;
   if (text == (const char *) NULL)
     return((char **) NULL);
   /*
     Determine the number of arguments.
+
+    style="fill: red; stroke: blue; stroke-width: 3"
   */
   for (p=text; *p != '\0'; p++)
     if (*p == ':')
-      (*number_tokens)+=2;
-  tokens=MagickAllocateMemory(char **,(*number_tokens+2)*sizeof(*tokens));
+      alloc_tokens+=2;
+  if (alloc_tokens == 0)
+    return((char **) NULL);
+  tokens=MagickAllocateMemory(char **,(alloc_tokens+2)*sizeof(*tokens));
   if (tokens == (char **) NULL)
     {
       ThrowException3(svg_info->exception,ResourceLimitError,
                       MemoryAllocationFailed,UnableToConvertStringToTokens);
       return((char **) NULL);
     }
+  (void) memset(tokens,0,(alloc_tokens+2)*sizeof(*tokens));
   /*
     Convert string to an ASCII list.
   */
   i=0;
   p=text;
+  iListFront = 0;
   for (q=p; *q != '\0'; q++)
     {
+      /*
+        ':' terminates the style element (e.g., fill:)
+        ';' terminates the style element value (e.g., red)
+      */
       if ((*q != ':') && (*q != ';') && (*q != '\0'))
         continue;
       tokens[i]=AllocateString(p);
+      if (tokens[i] == NULL)
+        {
+          ThrowException3(svg_info->exception,ResourceLimitError,
+                          MemoryAllocationFailed,UnableToConvertStringToTokens);
+          break;
+        }
       (void) strlcpy(tokens[i],p,q-p+1);
-      Strip(tokens[i++]);
+      Strip(tokens[i]);
+      /*
+        Check for "font-size", which we will move to the first position in
+        the list.  This will ensure that any following numerical conversions
+        that depend on the font size will use the new value.
+      */
+      if  ( (i & 1) == 0 )  /*element name*/
+        IsFontSize = (LocaleCompare("font-size",tokens[i]) == 0) ? MagickTrue : MagickFalse;
+      else if  ( IsFontSize )
+        {/*found font-size/value pair*/
+          if  ( (i-1) == iListFront )
+            iListFront += 2;  /* already at front of list */
+          else
+            {
+              /* move "font-size" and value to top of list */
+              char * pToken = tokens[iListFront];
+              tokens[iListFront] = tokens[i-1];
+              tokens[i-1] = pToken;
+              iListFront++;
+              pToken = tokens[iListFront];
+              tokens[iListFront] = tokens[i];
+              tokens[i] = pToken;
+              iListFront++;
+            }
+        }/*found font-size/value pair*/
+      i++;
+      if (i >= alloc_tokens)
+        break;
       p=q+1;
     }
-  tokens[i]=AllocateString(p);
-  (void) strlcpy(tokens[i],p,q-p+1);
-  Strip(tokens[i++]);
+  if (i < alloc_tokens)
+    {
+      tokens[i]=AllocateString(p);
+      if (tokens[i] == NULL)
+        {
+          ThrowException3(svg_info->exception,ResourceLimitError,
+                          MemoryAllocationFailed,UnableToConvertStringToTokens);
+        }
+      else
+        {
+          (void) strlcpy(tokens[i],p,q-p+1);
+          Strip(tokens[i]);
+          i++;
+        }
+    }
   tokens[i]=(char *) NULL;
+  *number_tokens=i;
   return(tokens);
 }
 
@@ -793,6 +864,198 @@ SVGEndDocument(void *context)
     }
 }
 
+
+/*
+  Code from SVGStartElement() that processed transform="..." has been refactored
+  into new function SVGProcessTransformString().
+*/
+static void
+SVGProcessTransformString  (
+        void *context,
+        char const *TransformString
+        )
+{/*SVGProcessTransformString*/
+
+  char
+    **tokens;
+
+  AffineMatrix
+    affine,
+    current,
+    transform;
+
+  char
+    *p = NULL,
+    token[MaxTextExtent];
+
+  SVGInfo
+    *svg_info=(SVGInfo *) context;
+
+  size_t
+    j,
+    number_tokens = 0;
+
+  IdentityAffine(&transform);
+  (void) LogMagickEvent(CoderEvent,GetMagickModule(),"  ");
+  tokens=GetTransformTokens(context,TransformString,&number_tokens);
+  if ((tokens != (char **) NULL) && (number_tokens > 0))
+    {/*if ((tokens != (char **) NULL) && (number_tokens > 0))*/
+
+                const char
+        *keyword = NULL,
+        *value = NULL;
+
+      for (j=0; j < (number_tokens-1); j+=2)
+        {/*j token loop*/
+
+          keyword=(char *) tokens[j];   /* matrix, rotate, etc. */
+          value=(char *) tokens[j+1];   /* associated numerical values */
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "    %.1024s: %.1024s",keyword,value);
+          current=transform;
+          IdentityAffine(&affine);
+          switch (*keyword)
+            {/*keyword switch*/
+
+            case 'M':
+            case 'm':
+              {/*Mm*/
+                if (LocaleCompare(keyword,"matrix") == 0)
+                  {
+                    p=(char *) value;
+                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                    affine.sx=MagickAtoF(token);
+                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                    if (*token == ',')
+                      (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                    affine.rx=MagickAtoF(token);
+                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                    if (*token == ',')
+                      (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                    affine.ry=MagickAtoF(token);
+                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                    if (*token == ',')
+                      (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                    affine.sy=MagickAtoF(token);
+                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                    if (*token == ',')
+                      (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                    affine.tx=MagickAtoF(token);
+                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                    if (*token == ',')
+                      (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                    affine.ty=MagickAtoF(token);
+                    break;
+                  }
+                break;
+              }/*Mm*/
+
+            case 'R':
+            case 'r':
+              {/*Rr*/
+                if (LocaleCompare(keyword,"rotate") == 0)
+                  {
+                    double
+                      angle;
+
+                    angle=GetUserSpaceCoordinateValue(svg_info,0,value,MagickFalse);
+                    affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
+                    affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
+                    affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
+                    affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
+                    break;
+                  }
+                break;
+              }/*Rr*/
+
+            case 'S':
+            case 's':
+              {/*Ss*/
+                if (LocaleCompare(keyword,"scale") == 0)
+                  {
+                    for (p=(char *) value; *p != '\0'; p++)
+                      if (isspace((int) (*p)) || (*p == ','))
+                        break;
+                    affine.sx=GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse);
+                    affine.sy=affine.sx;
+                    if (*p != '\0')
+                      affine.sy=
+                        GetUserSpaceCoordinateValue(svg_info,-1,p+1,MagickFalse);
+                    svg_info->scale[svg_info->n]=ExpandAffine(&affine);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"skewX") == 0)
+                  {
+                    affine.sx=svg_info->affine.sx;
+                    affine.ry=tan(DegreesToRadians(fmod(
+                      GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse),
+                      360.0)));
+                    affine.sy=svg_info->affine.sy;
+                    break;
+                  }
+                if (LocaleCompare(keyword,"skewY") == 0)
+                  {
+                    affine.sx=svg_info->affine.sx;
+                    affine.rx=tan(DegreesToRadians(fmod(
+                      GetUserSpaceCoordinateValue(svg_info,-1,value,MagickFalse),
+                      360.0)));
+                    affine.sy=svg_info->affine.sy;
+                    break;
+                  }
+                break;
+              }/*Ss*/
+
+            case 'T':
+            case 't':
+              {/*Tt*/
+                if (LocaleCompare(keyword,"translate") == 0)
+                  {
+                    for (p=(char *) value; *p != '\0'; p++)
+                      if (isspace((int) (*p)) || (*p == ','))
+                        break;
+                    affine.tx=GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse);
+                    affine.ty=affine.tx;
+                    if (*p != '\0')
+                      affine.ty=
+                        GetUserSpaceCoordinateValue(svg_info,-1,p+1,MagickFalse);
+                    break;
+                  }
+                break;
+              }/*Tt*/
+
+            default:
+              break;
+
+            }/*keyword switch*/
+
+          transform.sx=current.sx*affine.sx+current.ry*affine.rx;
+          transform.rx=current.rx*affine.sx+current.sy*affine.rx;
+          transform.ry=current.sx*affine.ry+current.ry*affine.sy;
+          transform.sy=current.rx*affine.ry+current.sy*affine.sy;
+          transform.tx=current.sx*affine.tx+current.ry*affine.ty+
+            current.tx;
+          transform.ty=current.rx*affine.tx+current.sy*affine.ty+
+            current.ty;
+
+        }/*j token loop*/
+
+      MVGPrintf(svg_info->file,"affine %g %g %g %g %g %g\n",
+                transform.sx,transform.rx,transform.ry,transform.sy,
+                transform.tx,transform.ty);
+
+    }/*if ((tokens != (char **) NULL) && (number_tokens > 0))*/
+
+  /* clean up memory used for tokens */
+  if (tokens != (char **) NULL)
+    {
+      for (j=0; tokens[j] != (char *) NULL; j++)
+        MagickFreeMemory(tokens[j]);
+      MagickFreeMemory(tokens);
+    }
+
+}/*SVGProcessTransformString*/
+
+
 static void
 SVGStartElement(void *context,const xmlChar *name,
                 const xmlChar **attributes)
@@ -818,6 +1081,13 @@ SVGStartElement(void *context,const xmlChar *name,
     i,
     j;
 
+  char
+    svg_element_background_color[MaxTextExtent];  /* to support style="background:color" */
+
+  MagickBool
+    IsTSpan = MagickFalse,
+    IsTextOrTSpan = MagickFalse;
+
   /*
     Called when an opening tag has been processed.
   */
@@ -838,6 +1108,75 @@ SVGStartElement(void *context,const xmlChar *name,
   color=AllocateString("none");
   units=AllocateString("userSpaceOnUse");
   value=(const char *) NULL;
+  svg_element_background_color[0]='\0';
+  IsTextOrTSpan = IsTSpan = LocaleCompare((char *) name,"tspan") == 0;  /* need to know this early */
+  /*
+    According to the SVG spec, for the following SVG elements, if the x or y
+    attribute is not specified, the effect is as if a value of "0" were specified.
+  */
+  if (
+         (LocaleCompare((char *) name,"image") == 0)
+      || (LocaleCompare((char *) name,"pattern") == 0)
+      || (LocaleCompare((char *) name,"rect") == 0)
+      || (LocaleCompare((char *) name,"text") == 0)
+      || (LocaleCompare((char *) name,"use") == 0)
+      )
+    {
+      svg_info->bounds.x = svg_info->bounds.y = 0;
+    }
+  /*
+    NOTE: SVG spec makes similar statements for cx,cy of circle and ellipse, and
+    x1,y1,x2,y2 of line, but these are zeroed out initially, AND at the end of
+    SVGEndElement() after they have been used.
+  */
+
+  /*
+    When "font-size" is (or is contained in) one of the attributes for this SVG
+    element, we want it to be processed first so that any numerical conversions
+    that depend on the font size will use the new value.  So we will first scan
+    the attribute list and move any "font-size", "class" (which may contain a
+    "font-size"), or "style" (which may contain a "font-size") attributes to the
+    front of the attribute list.
+
+    For now we will ignore the possibility that "font-size" may be specified
+    more than once among "font-size", "class", and "style".  However, the
+    relative order among these three will be preserved.
+  */
+  if (attributes != (const xmlChar **) NULL)
+  {/*have some attributes*/
+
+    size_t iListFront = 0;
+    for  ( i = 0; (attributes[i] != (const xmlChar *) NULL); i += 2 )
+      {/*attribute[i]*/
+
+        keyword = (const char *) attributes[i];
+        if  (  (LocaleCompare(keyword,"font-size") == 0)
+            || (LocaleCompare(keyword,"class") == 0)
+            || (LocaleCompare(keyword,"style") == 0)
+         )
+         {/*(possible) font-size*/
+
+            if  ( i == iListFront )
+              iListFront += 2;  /* already at front of list */
+            else
+              {
+                /* move to front of list */
+                const xmlChar * pAttr = attributes[iListFront];
+                attributes[iListFront] = attributes[i];
+                attributes[i] = pAttr;
+                iListFront++;
+                pAttr = attributes[iListFront];
+                attributes[iListFront] = attributes[i+1];
+                attributes[i+1] = pAttr;
+                iListFront++;
+              }
+
+         }/*(possible) font-size*/
+
+      }/*attribute[i]*/
+
+  }/*have some attributes*/
+
   if (attributes != (const xmlChar **) NULL)
     for (i=0; (svg_info->exception->severity < ErrorException) &&
            (attributes[i] != (const xmlChar *) NULL); i+=2)
@@ -897,6 +1236,13 @@ SVGStartElement(void *context,const xmlChar *name,
               if (LocaleCompare(keyword,"id") == 0)
                 {
                   (void) strlcpy(id,value,MaxTextExtent);
+                  /* track elements inside <defs> that have an "id" */
+                  if  ( (svg_info->defsPushCount > 0)
+                    && (svg_info->idLevelInsideDefs == 0)   /* do not allow nested "id" elements for now */
+                    && (LocaleCompare((const char *)name,"clipPath") != 0)  /* handled separately */
+                    && (LocaleCompare((const char *)name,"mask") != 0)      /* handled separately */
+                    )
+                      svg_info->idLevelInsideDefs = svg_info->n;
                   break;
                 }
               break;
@@ -928,7 +1274,11 @@ SVGStartElement(void *context,const xmlChar *name,
             {
               if (LocaleCompare(keyword,"x") == 0)
                 {
-                  svg_info->bounds.x=GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse);
+                  /* if processing a tspan, preserve the current bounds.x, which belongs to the
+                     previously processed text or tspan; the bounds.x for the current tspan will
+                     be set later */
+                  if (!IsTSpan)
+                    svg_info->bounds.x=GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse);
                   break;
                 }
               if (LocaleCompare(keyword,"x1") == 0)
@@ -950,7 +1300,11 @@ SVGStartElement(void *context,const xmlChar *name,
             {
               if (LocaleCompare(keyword,"y") == 0)
                 {
-                  svg_info->bounds.y=GetUserSpaceCoordinateValue(svg_info,-1,value,MagickFalse);
+                  /* if processing a tspan, preserve the current bounds.y, which belongs to the
+                     previously processed text or tspan; the bounds.y for the current tspan will
+                     be set later */
+                  if (!IsTSpan)
+                    svg_info->bounds.y=GetUserSpaceCoordinateValue(svg_info,-1,value,MagickFalse);
                   break;
                 }
               if (LocaleCompare(keyword,"y1") == 0)
@@ -988,6 +1342,8 @@ SVGStartElement(void *context,const xmlChar *name,
       {
         if (LocaleCompare((char *) name,"circle") == 0)
           {
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "push id" if warranted */
+              MVGPrintf(svg_info->file,"push id '%s'\n",id);
             MVGPrintf(svg_info->file,"push graphic-context\n");
             break;
           }
@@ -1003,6 +1359,7 @@ SVGStartElement(void *context,const xmlChar *name,
       {
         if (LocaleCompare((char *) name,"defs") == 0)
           {
+            svg_info->defsPushCount++;
             MVGPrintf(svg_info->file,"push defs\n");
             break;
           }
@@ -1013,6 +1370,24 @@ SVGStartElement(void *context,const xmlChar *name,
       {
         if (LocaleCompare((char *) name,"ellipse") == 0)
           {
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "push id" if warranted */
+              MVGPrintf(svg_info->file,"push id '%s'\n",id);
+            MVGPrintf(svg_info->file,"push graphic-context\n");
+            break;
+          }
+        break;
+      }
+    case 'F':
+    case 'f':
+      {
+        /*
+          For now we are ignoring "foreignObject".  However, we do a push/pop
+          graphic-context so that any settings (e.g., fill) are consumed and
+          discarded.  Otherwise they might persist and "leak" into the graphic
+          elements that follow.
+        */
+        if (LocaleCompare((char *) name,"foreignObject") == 0)
+          {
             MVGPrintf(svg_info->file,"push graphic-context\n");
             break;
           }
@@ -1023,6 +1398,8 @@ SVGStartElement(void *context,const xmlChar *name,
       {
         if (LocaleCompare((char *) name,"g") == 0)
           {
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "push id" if warranted */
+              MVGPrintf(svg_info->file,"push id '%s'\n",id);
             MVGPrintf(svg_info->file,"push graphic-context\n");
             break;
           }
@@ -1043,6 +1420,8 @@ SVGStartElement(void *context,const xmlChar *name,
       {
         if (LocaleCompare((char *) name,"line") == 0)
           {
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "push id" if warranted */
+              MVGPrintf(svg_info->file,"push id '%s'\n",id);
             MVGPrintf(svg_info->file,"push graphic-context\n");
             break;
           }
@@ -1055,11 +1434,23 @@ SVGStartElement(void *context,const xmlChar *name,
           }
         break;
       }
+    case 'M':
+    case 'm':
+      {
+        if (LocaleCompare((char *) name,"mask") == 0)   /* added mask */
+        {
+          MVGPrintf(svg_info->file,"push mask '%s'\n",id);
+          break;
+        }
+      break;
+      }
     case 'P':
     case 'p':
       {
         if (LocaleCompare((char *) name,"path") == 0)
           {
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "push id" if warranted */
+              MVGPrintf(svg_info->file,"push id '%s'\n",id);
             MVGPrintf(svg_info->file,"push graphic-context\n");
             break;
           }
@@ -1072,11 +1463,15 @@ SVGStartElement(void *context,const xmlChar *name,
           }
         if (LocaleCompare((char *) name,"polygon") == 0)
           {
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "push id" if warranted */
+              MVGPrintf(svg_info->file,"push id '%s'\n",id);
             MVGPrintf(svg_info->file,"push graphic-context\n");
             break;
           }
         if (LocaleCompare((char *) name,"polyline") == 0)
           {
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "push id" if warranted */
+              MVGPrintf(svg_info->file,"push id '%s'\n",id);
             MVGPrintf(svg_info->file,"push graphic-context\n");
             break;
           }
@@ -1102,6 +1497,8 @@ SVGStartElement(void *context,const xmlChar *name,
           }
         if (LocaleCompare((char *) name,"rect") == 0)
           {
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "push id" if warranted */
+              MVGPrintf(svg_info->file,"push id '%s'\n",id);
             MVGPrintf(svg_info->file,"push graphic-context\n");
             break;
           }
@@ -1110,9 +1507,37 @@ SVGStartElement(void *context,const xmlChar *name,
     case 'S':
     case 's':
       {
+        /* element "style" inside <defs> */
+        if (LocaleCompare((char *) name,"style") == 0)
+          {
+            /*
+              This is here more or less as a documentation aid.  The real work is done when
+              we encounter </style>.
+            */
+            break;
+          }
         if (LocaleCompare((char *) name,"svg") == 0)
           {
+            svg_info->svgPushCount++;
             MVGPrintf(svg_info->file,"push graphic-context\n");
+            /*
+              Per the SVG spec, initialize the MVG coder with the following
+              SVG defaults:
+                - svg-compliant: "1" (note: internal to GM, not an SVG element)
+                - fill color: "black"
+                - fill-opacity value: "1"
+                - stroke color: "none"
+                - stroke-width value: "1"
+                - stroke-opacity value: "1"
+                - fill-rule value: "nonzero"
+            */
+            MVGPrintf(svg_info->file,"svg-compliant 1\n");
+            MVGPrintf(svg_info->file,"fill 'black'\n");
+            MVGPrintf(svg_info->file,"fill-opacity 1\n");
+            MVGPrintf(svg_info->file,"stroke 'none'\n");
+            MVGPrintf(svg_info->file,"stroke-width 1\n");
+            MVGPrintf(svg_info->file,"stroke-opacity 1\n");
+            MVGPrintf(svg_info->file,"fill-rule 'nonzero'\n");
             break;
           }
         break;
@@ -1122,34 +1547,33 @@ SVGStartElement(void *context,const xmlChar *name,
       {
         if (LocaleCompare((char *) name,"text") == 0)
           {
+            IsTextOrTSpan = MagickTrue;
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "push id" if warranted */
+              MVGPrintf(svg_info->file,"push id '%s'\n",id);
             MVGPrintf(svg_info->file,"push graphic-context\n");
+            /* update text current position */
+            MVGPrintf(svg_info->file,"textx %g\n",svg_info->bounds.x);
+            MVGPrintf(svg_info->file,"texty %g\n",svg_info->bounds.y);
             break;
           }
         if (LocaleCompare((char *) name,"tspan") == 0)
           {
+            IsTextOrTSpan = MagickTrue;
             Strip(svg_info->text);
             if (*svg_info->text != '\0')
               {
-                DrawInfo
-                  *draw_info;
-                
-                TypeMetric
-                  metrics;
-                
                 char
                   *text;
 
                 text=EscapeString(svg_info->text,'\'');
-                MVGPrintf(svg_info->file,"text %g,%g '%s'\n",svg_info->bounds.x,
-                          svg_info->bounds.y,text);
+                MVGPrintf(svg_info->file,"textc '%s'\n",text);
                 MagickFreeMemory(text);
-                draw_info=CloneDrawInfo(svg_info->image_info,(DrawInfo *) NULL);
-                draw_info->pointsize=svg_info->pointsize;
-                draw_info->text=AllocateString(svg_info->text);
-                (void) ConcatenateString(&draw_info->text," ");
-                (void) GetTypeMetrics(svg_info->image,draw_info,&metrics);
-                svg_info->bounds.x+=metrics.width;
-                DestroyDrawInfo(draw_info);
+                /*
+                  The code that used to be here to compute the next text position has been eliminated.
+                  The reason is that at this point in the code we may not know the font or font size
+                  (they may be hidden in a "class" definition), so we can't really do that computation.
+                  This functionality is now handled by DrawImage() in render.c.
+                */
                 *svg_info->text='\0';
               }
             MVGPrintf(svg_info->file,"push graphic-context\n");
@@ -1157,6 +1581,17 @@ SVGStartElement(void *context,const xmlChar *name,
           }
         break;
       }
+    case 'U':
+    case 'u':
+      {
+        if (LocaleCompare((char *) name,"use") == 0)
+          {
+            /* "use" behaves like "g" */
+            MVGPrintf(svg_info->file,"push graphic-context\n");
+            break;
+          }
+        break;
+       }
     default:
       break;
     }
@@ -1184,6 +1619,20 @@ SVGStartElement(void *context,const xmlChar *name,
           case 'C':
           case 'c':
             {
+              if (LocaleCompare(keyword,"class") == 0)
+                {/*"class=classname"*/
+                  char * pClassNames = (char * ) value;
+                  do
+                    {
+                      (void) MagickGetToken(pClassNames,&pClassNames,token,MaxTextExtent);
+                      if  ( *token == ',' )
+                        (void) MagickGetToken(pClassNames,&pClassNames,token,MaxTextExtent);
+                      if  ( *token != '\0' )
+                        MVGPrintf(svg_info->file,"class '%s'\n",token);
+                  }
+                  while  ( *token != '\0' );
+                  break;
+                }/*"class=classname"*/
               if (LocaleCompare(keyword,"clip-path") == 0)
                 {
                   MVGPrintf(svg_info->file,"clip-path '%s'\n",value);
@@ -1229,14 +1678,34 @@ SVGStartElement(void *context,const xmlChar *name,
                 }
               if (LocaleCompare(keyword,"dx") == 0)
                 {
-                  svg_info->bounds.x+=
-                    GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse);
+                  double dx=GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse);
+                  svg_info->bounds.x+=dx;   /* preserve previous behavior */
+                  /* update text current position for text or tspan */
+                  if  ( IsTextOrTSpan )
+                    {
+                      char * pUnit;
+                      (void) MagickGetToken(value,&pUnit,token,MaxTextExtent);
+                      if  ( *pUnit && ((LocaleNCompare(pUnit,"em",2) == 0) || (LocaleNCompare(pUnit,"ex",2) == 0)) )
+                        MVGPrintf(svg_info->file,"textdx %s\n",value);  /* postpone interpretation of "em" or "ex" until we know point size */
+                      else
+                        MVGPrintf(svg_info->file,"textdx %g\n",dx);
+                    }
                   break;
                 }
               if (LocaleCompare(keyword,"dy") == 0)
                 {
-                  svg_info->bounds.y+=
-                    GetUserSpaceCoordinateValue(svg_info,-1,value,MagickFalse);
+                  double dy=GetUserSpaceCoordinateValue(svg_info,-1,value,MagickFalse);
+                  svg_info->bounds.y+=dy;   /* preserve previous behavior */
+                  /* update text current position for text or tspan */
+                  if  ( IsTextOrTSpan )
+                    {
+                      char * pUnit;
+                      (void) MagickGetToken(value,&pUnit,token,MaxTextExtent);
+                      if  ( *pUnit && ((LocaleNCompare(pUnit,"em",2) == 0) || (LocaleNCompare(pUnit,"ex",2) == 0)) )
+                        MVGPrintf(svg_info->file,"textdy %s\n",value);  /* postpone interpretation of "em" or "ex" until we know point size */
+                      else
+                        MVGPrintf(svg_info->file,"textdy %g\n",dy);
+                    }
                   break;
                 }
               break;
@@ -1325,7 +1794,7 @@ SVGStartElement(void *context,const xmlChar *name,
                     affine,
                     current,
                     transform;
-                  
+
                   IdentityAffine(&transform);
                   (void) LogMagickEvent(CoderEvent,GetMagickModule(),"  ");
                   tokens=GetTransformTokens(context,value,&number_tokens);
@@ -1382,7 +1851,7 @@ SVGStartElement(void *context,const xmlChar *name,
                                   {
                                     double
                                       angle;
-                                    
+
                                     angle=GetUserSpaceCoordinateValue(svg_info,0,value,MagickFalse);
                                     affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
                                     affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
@@ -1488,7 +1957,19 @@ SVGStartElement(void *context,const xmlChar *name,
                 }
               if (LocaleCompare(keyword,"href") == 0)
                 {
-                  (void) CloneString(&svg_info->url,value);
+                  /* process "#identifier" as if it were "url(#identifier)" */
+                  if  ( value[0] == '#' )
+                    {
+                      /* reallocate the needed memory once */
+                      size_t NewSize = strlen(value) + 6;   /* 6 == url()<null> */
+                      MagickReallocMemory(char *,svg_info->url,NewSize);
+                      memcpy(svg_info->url,"url(",4);
+                      strcpy(svg_info->url+4,value);
+                      svg_info->url[NewSize-2] = ')';
+                      svg_info->url[NewSize-1] = '\0';
+                    }
+                  else
+                    (void) CloneString(&svg_info->url,value);
                   break;
                 }
               break;
@@ -1502,6 +1983,11 @@ SVGStartElement(void *context,const xmlChar *name,
                     GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse);
                   break;
                 }
+              if (LocaleCompare(keyword,"mask") == 0)   /* added mask */
+                {
+                  MVGPrintf(svg_info->file,"mask '%s'\n",value);
+                  break;
+                }
               if (LocaleCompare(keyword,"minor") == 0)
                 {
                   svg_info->element.minor=
@@ -1555,13 +2041,29 @@ SVGStartElement(void *context,const xmlChar *name,
                 {
                   double
                     angle;
-                  
+
                   angle=GetUserSpaceCoordinateValue(svg_info,0,value,MagickFalse);
-                  MVGPrintf(svg_info->file,"translate %g,%g\n",svg_info->bounds.x,
-                            svg_info->bounds.y);
-                  svg_info->bounds.x=0;
-                  svg_info->bounds.y=0;
-                  MVGPrintf(svg_info->file,"rotate %g\n",angle);
+                  /*
+                    When the current text position was managed in this code, and a "rotate" was encountered
+                    (indicating that the text character was to be rotated), the code would emit to the MVG file:
+
+                      translate x y (where x, y indicate the current text position)
+                      rotate angle (where angle indicates the rotation angle)
+
+                    Now that the current text position is being managed by DrawImage() in render.c, this code
+                    cannot issue the "translate" because it can't know the current text position.  To handle
+                    this, "textr" (text rotation) has been implemented in DrawImage() to perform the appropriate
+                    translation/rotation sequence.
+                  */
+                  if ( IsTextOrTSpan )
+                    MVGPrintf(svg_info->file,"textr %g\n",angle);  /* pre-translation will be handled in DrawImage() */
+                  else
+                  {
+                    MVGPrintf(svg_info->file,"translate %g,%g\n",svg_info->bounds.x,svg_info->bounds.y);
+                    svg_info->bounds.x=0;
+                    svg_info->bounds.y=0;
+                    MVGPrintf(svg_info->file,"rotate %g\n",angle);
+                  }
                   break;
                 }
               if (LocaleCompare(keyword,"rx") == 0)
@@ -1634,7 +2136,7 @@ SVGStartElement(void *context,const xmlChar *name,
               if (LocaleCompare(keyword,"stroke-miterlimit") == 0)
                 {
                   double stroke_miterlimit;
-                  if ((MagickAtoFChk(value,&stroke_miterlimit) != MagickPass) || 
+                  if ((MagickAtoFChk(value,&stroke_miterlimit) != MagickPass) ||
                       stroke_miterlimit < 1.0)
                     {
                       errno=0;
@@ -1674,6 +2176,18 @@ SVGStartElement(void *context,const xmlChar *name,
                                                 "    %.1024s: %.1024s",keyword,value);
                           switch (*keyword)
                             {
+                            case 'B':
+                            case 'b':
+                              {
+                                if (LocaleCompare(keyword,"background") == 0)
+                                {
+                                  /* only do this if background was specified inside <svg ... */
+                                  if  ( LocaleCompare((const char *)name,"svg") == 0 )
+                                    strlcpy(svg_element_background_color,value,MaxTextExtent);
+                                  break;
+                                }
+                                break;
+                              }
                             case 'C':
                             case 'c':
                               {
@@ -1880,6 +2394,12 @@ SVGStartElement(void *context,const xmlChar *name,
                                               LocaleCompare(value,"true") == 0);
                                     break;
                                   }
+                                if (LocaleCompare(keyword,"transform") == 0)
+                                  {
+                                    /* implement style="transform: translate(..." */
+                                    SVGProcessTransformString(context,value);
+                                    break;
+                                  }
                                 break;
                               }
                             default:
@@ -1928,184 +2448,42 @@ SVGStartElement(void *context,const xmlChar *name,
                 }
               if (LocaleCompare(keyword,"transform") == 0)
                 {
-                  char
-                    **tokens;
-
-                  AffineMatrix
-                    affine,
-                    current,
-                    transform;
-                  
-                  IdentityAffine(&transform);
-                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),"  ");
-                  tokens=GetTransformTokens(context,value,&number_tokens);
-                  if ((tokens != (char **) NULL) && (number_tokens > 0))
-                    {
-                      for (j=0; j < (number_tokens-1); j+=2)
-                        {
-                          keyword=(char *) tokens[j];
-                          value=(char *) tokens[j+1];
-                          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                                "    %.1024s: %.1024s",keyword,value);
-                          current=transform;
-                          IdentityAffine(&affine);
-                          switch (*keyword)
-                            {
-                            case 'M':
-                            case 'm':
-                              {
-                                if (LocaleCompare(keyword,"matrix") == 0)
-                                  {
-                                    p=(char *) value;
-                                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                                    affine.sx=MagickAtoF(value);
-                                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                                    if (*token == ',')
-                                      (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                                    affine.rx=MagickAtoF(token);
-                                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                                    if (*token == ',')
-                                      (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                                    affine.ry=MagickAtoF(token);
-                                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                                    if (*token == ',')
-                                      (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                                    affine.sy=MagickAtoF(token);
-                                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                                    if (*token == ',')
-                                      (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                                    affine.tx=MagickAtoF(token);
-                                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                                    if (*token == ',')
-                                      (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                                    affine.ty=MagickAtoF(token);
-                                    break;
-                                  }
-                                break;
-                              }
-                            case 'R':
-                            case 'r':
-                              {
-                                if (LocaleCompare(keyword,"rotate") == 0)
-                                  {
-                                    double
-                                      angle;
-                                    
-                                    angle=GetUserSpaceCoordinateValue(svg_info,0,value,MagickFalse);
-                                    affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
-                                    affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
-                                    affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
-                                    affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
-                                    break;
-                                  }
-                                break;
-                              }
-                            case 'S':
-                            case 's':
-                              {
-                                if (LocaleCompare(keyword,"scale") == 0)
-                                  {
-                                    for (p=(char *) value; *p != '\0'; p++)
-                                      if (isspace((int) (*p)) || (*p == ','))
-                                        break;
-                                    affine.sx=GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse);
-                                    affine.sy=affine.sx;
-                                    if (*p != '\0')
-                                      affine.sy=
-                                        GetUserSpaceCoordinateValue(svg_info,-1,p+1,MagickFalse);
-                                    svg_info->scale[svg_info->n]=ExpandAffine(&affine);
-                                    break;
-                                  }
-                                if (LocaleCompare(keyword,"skewX") == 0)
-                                  {
-                                    affine.sx=svg_info->affine.sx;
-                                    affine.ry=tan(DegreesToRadians(fmod(
-                                                                        GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse),
-                                                                        360.0)));
-                                    affine.sy=svg_info->affine.sy;
-                                    break;
-                                  }
-                                if (LocaleCompare(keyword,"skewY") == 0)
-                                  {
-                                    affine.sx=svg_info->affine.sx;
-                                    affine.rx=tan(DegreesToRadians(fmod(
-                                                                        GetUserSpaceCoordinateValue(svg_info,-1,value,MagickFalse),
-                                                                        360.0)));
-                                    affine.sy=svg_info->affine.sy;
-                                    break;
-                                  }
-                                break;
-                              }
-                            case 'T':
-                            case 't':
-                              {
-                                if (LocaleCompare(keyword,"translate") == 0)
-                                  {
-                                    for (p=(char *) value; *p != '\0'; p++)
-                                      if (isspace((int) (*p)) || (*p == ','))
-                                        break;
-                                    affine.tx=GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse);
-                                    affine.ty=affine.tx;
-                                    if (*p != '\0')
-                                      affine.ty=
-                                        GetUserSpaceCoordinateValue(svg_info,-1,p+1,MagickFalse);
-                                    break;
-                                  }
-                                break;
-                              }
-                            default:
-                              break;
-                            }
-                          transform.sx=current.sx*affine.sx+current.ry*affine.rx;
-                          transform.rx=current.rx*affine.sx+current.sy*affine.rx;
-                          transform.ry=current.sx*affine.ry+current.ry*affine.sy;
-                          transform.sy=current.rx*affine.ry+current.sy*affine.sy;
-                          transform.tx=current.sx*affine.tx+current.ry*affine.ty+
-                            current.tx;
-                          transform.ty=current.rx*affine.tx+current.sy*affine.ty+
-                            current.ty;
-                        }
-                      MVGPrintf(svg_info->file,"affine %g %g %g %g %g %g\n",
-                                transform.sx,transform.rx,transform.ry,transform.sy,
-                                transform.tx,transform.ty);
-                    } /* if ((tokens != (char **) NULL) && (number_tokens > 0)) */
-                  if (tokens != (char **) NULL)
-                    {
-                      for (j=0; tokens[j] != (char *) NULL; j++)
-                        MagickFreeMemory(tokens[j]);
-                      MagickFreeMemory(tokens);
-                    }
-                  break;
-                }
-              break;
-            }
-          case 'V':
-          case 'v':
-            {
-              if (LocaleCompare(keyword,"verts") == 0)
-                {
-                  (void) CloneString(&svg_info->vertices,value);
-                  break;
-                }
-              if (LocaleCompare(keyword,"viewBox") == 0)
-                {
-                  p=(char *) value;
-                  (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                  svg_info->view_box.x=MagickAtoF(token);
-                  (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                  if (*token == ',')
-                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                  svg_info->view_box.y=MagickAtoF(token);
-                  (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                  if (*token == ',')
-                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                  svg_info->view_box.width=MagickAtoF(token);
-                  (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                  if (*token == ',')
-                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
-                  svg_info->view_box.height=MagickAtoF(token);
-                  if (svg_info->view_box.width < 0.0 ||
-                      svg_info->view_box.height < 0.0)
+                  /*
+                    The code that was here has been refactored into
+                    function SVGProcessTransformString()
+                  */
+                  SVGProcessTransformString(context,value);
+                  break;
+                }
+              break;
+            }
+          case 'V':
+          case 'v':
+            {
+              if (LocaleCompare(keyword,"verts") == 0)
+                {
+                  (void) CloneString(&svg_info->vertices,value);
+                  break;
+                }
+              if (LocaleCompare(keyword,"viewBox") == 0)
+                {
+                  p=(char *) value;
+                  (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                  svg_info->view_box.x=MagickAtoF(token);
+                  (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                  if (*token == ',')
+                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                  svg_info->view_box.y=MagickAtoF(token);
+                  (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                  if (*token == ',')
+                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                  svg_info->view_box.width=MagickAtoF(token);
+                  (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                  if (*token == ',')
+                    (void) MagickGetToken(p,&p,token,MaxTextExtent);
+                  svg_info->view_box.height=MagickAtoF(token);
+                  if (svg_info->view_box.width < 0.0 ||
+                      svg_info->view_box.height < 0.0)
                     {
                       ThrowException(svg_info->exception,CorruptImageError,
                                      NegativeOrZeroImageSize,
@@ -2137,11 +2515,26 @@ SVGStartElement(void *context,const xmlChar *name,
               if (LocaleCompare(keyword,"x") == 0)
                 {
                   svg_info->bounds.x=GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse);
+                  /* update text current position for tspan (already did this if text) */
+                  if  ( IsTSpan )
+                    MVGPrintf(svg_info->file,"textx %g\n",svg_info->bounds.x);
                   break;
                 }
               if (LocaleCompare(keyword,"xlink:href") == 0)
                 {
-                  (void) CloneString(&svg_info->url,value);
+                  /* process "#identifier" as if it were "url(#identifier)" */
+                  if  ( value[0] == '#' )
+                    {
+                      /* reallocate the needed memory once */
+                      size_t NewSize = strlen(value) + 6;   /* 6 == url()<null> */
+                      MagickReallocMemory(char *,svg_info->url,NewSize);
+                      memcpy(svg_info->url,"url(",4);
+                      strcpy(svg_info->url+4,value);
+                      svg_info->url[NewSize-2] = ')';
+                      svg_info->url[NewSize-1] = '\0';
+                    }
+                  else
+                    (void) CloneString(&svg_info->url,value);
                   break;
                 }
               if (LocaleCompare(keyword,"x1") == 0)
@@ -2164,6 +2557,9 @@ SVGStartElement(void *context,const xmlChar *name,
               if (LocaleCompare(keyword,"y") == 0)
                 {
                   svg_info->bounds.y=GetUserSpaceCoordinateValue(svg_info,-1,value,MagickFalse);
+                  /* update text current position for tspan (already did this if text) */
+                  if  ( IsTSpan )
+                    MVGPrintf(svg_info->file,"texty %g\n",svg_info->bounds.y);
                   break;
                 }
               if (LocaleCompare(keyword,"y1") == 0)
@@ -2197,7 +2593,7 @@ SVGStartElement(void *context,const xmlChar *name,
           double
             sx,
             sy;
-          
+
           if ((svg_info->view_box.width == 0.0) ||
               (svg_info->view_box.height == 0.0))
             svg_info->view_box=svg_info->bounds;
@@ -2211,10 +2607,10 @@ SVGStartElement(void *context,const xmlChar *name,
           {
             char
               tuple[MaxTextExtent];
-            
+
             GetColorTuple(&svg_info->image_info->background_color,8,True,True,
                           tuple);
-            
+
             MVGPrintf(svg_info->file,"push graphic-context\n");
             MVGPrintf(svg_info->file,"fill %s\n", tuple);
             MVGPrintf(svg_info->file,"rectangle 0,0 %g,%g\n",
@@ -2236,16 +2632,15 @@ SVGStartElement(void *context,const xmlChar *name,
       if (attributes != (const xmlChar **) NULL)
         {
           char
-            *geometry,
-            *p;
-          
+            *geometry;
+
           RectangleInfo
             page;
-          
+
           double
             sx,
             sy;
-          
+
           if (svg_info->bounds.width < 0.0 || svg_info->bounds.height < 0.0)
             {
               ThrowException(svg_info->exception,CorruptImageError,
@@ -2278,38 +2673,465 @@ SVGStartElement(void *context,const xmlChar *name,
               geometry=GetPageGeometry(svg_info->size);
           if (geometry != (char *) NULL)
             {
-              p=strchr(geometry,'>');
-              if (p != (char *) NULL)
-                *p='\0';
+              /*
+                A terminating '>' in a geometry string is interpreted to mean that
+                the dimensions of an image should only be changed if its width or
+                height exceeds the geometry specification.  For an unapparent and
+                undocumented reason, a terminating '>', if present, was being nulled
+                out, making this feature unusable for SVG files (now fixed).
+              */
               (void) GetMagickGeometry(geometry,&page.x,&page.y,
                                        &page.width,&page.height);
               MagickFreeMemory(geometry);
             }
-          if (svg_info->affine.sx != 1.0)
-            page.width=(unsigned long)
-              ceil(ExpandAffine(&svg_info->affine)*page.width-0.5);
-          if (svg_info->affine.sy != 0.0)
-            page.height=(unsigned long)
-              ceil(ExpandAffine(&svg_info->affine)*page.height-0.5);
+          /* NOTE: the scale factor returned by ExpandAffine() has already been applied
+             to page.width and page.height
+          */
           (void) MVGPrintf(svg_info->file,"viewbox 0 0 %g %g\n",
                            svg_info->view_box.width,svg_info->view_box.height);
           sx=(double) page.width/svg_info->view_box.width;
           sy=(double) page.height/svg_info->view_box.height;
           MVGPrintf(svg_info->file,"affine %g 0 0 %g %g %g\n",sx,sy,
                     -sx*svg_info->view_box.x,-sy*svg_info->view_box.y);
-          svg_info->width=page.width;
-          svg_info->height=page.height;
+          /* only set the output width and height if this is the outermost <svg> */
+          if  ( svg_info->svgPushCount == 1 )
+            {/*outermost <svg>*/
+              svg_info->width=page.width;
+              svg_info->height=page.height;
+              /* check if background color was specified using <svg ... style="background:color" */
+              if  ( svg_element_background_color[0] != '\0' )
+                {
+                  MVGPrintf(svg_info->file,"push graphic-context\n");
+                  MVGPrintf(svg_info->file,"fill %s\n",svg_element_background_color);
+                  MVGPrintf(svg_info->file,"rectangle 0,0 %g,%g\n",svg_info->view_box.width,svg_info->view_box.height);
+                  MVGPrintf(svg_info->file,"pop graphic-context\n");
+                }
+            }/*outermost <svg>*/
         }
     }
 #endif
   /* Error dispatch point */
  svg_start_element_error:;
-  
+
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),"  )");
   MagickFreeMemory(units);
   MagickFreeMemory(color);
 }
 
+/* Process the "class" definitions inside <style> ... </style> */
+static
+void    ProcessStyleClassDefs (
+  SVGInfo * svg_info
+  )
+{/*ProcessStyleClassDefs*/
+
+  /*
+    Style defs look like:
+
+      .class1,.class2,.class3{kwd:val;kwd:val;}
+
+    Class name (e.g., ".class1"} can show up multiple times
+  */
+
+  /* keyword/value pair for an element */
+  typedef struct ElementValue
+    {/*ElementValue*/
+        struct ElementValue     * pNext;  /* next in list */
+        char *                pKeyword;
+        char *                pValue;
+    }/*ElementValue*/
+  ElementValue;
+
+  /* the keyword/value pair list associated with a class */
+  typedef struct ClassDef
+    {/*ClassDef*/
+      struct ClassDef * pNext;            /* next in list */
+      struct ClassDef * pActiveNext;      /* next in active list */
+      char *            pName;            /* class name */
+      ElementValue      ElementValueHead; /* list head for style element/value pairs */
+      ElementValue *    pElementValueLast;
+    }/*ClassDef*/
+  ClassDef;
+
+  ClassDef ClassDefHead;  /* list head for classes */
+  ClassDef * pClassDefLast = &ClassDefHead; /* tail ptr for class def list */
+  ClassDef ClassDefActiveHead;  /* list head for "active" class defs */
+  ClassDef * pClassDefActiveLast = &ClassDefActiveHead; /* tail ptr for "active" class def list */
+  ClassDef * pClassDef;
+  char * pCopyOfText;
+  char * pString;
+  char * cp,*cp2;
+  int c;
+
+  memset(&ClassDefHead,0,sizeof(ClassDefHead));
+  memset(&ClassDefActiveHead,0,sizeof(ClassDefActiveHead));
+
+  /* a macro to allocate an zero out a new struct instance,
+      and add it to the end of a linked list */
+  #define       ADD_NEW_STRUCT(pNew,pLast,TheTypeDef) \
+  pNew = MagickAllocateMemory(TheTypeDef *,sizeof(TheTypeDef)); \
+  memset(pNew,0,sizeof(TheTypeDef)); \
+  pLast = pLast->pNext = pNew
+
+  /* we will get a modifiable value of the string, and delimit
+      substrings by storing null characters */
+  pCopyOfText = AcquireString(svg_info->text);
+  for  ( pString = pCopyOfText; *pString; )
+    {/*pString loop*/
+      char * pClassNameList;
+      char * pStyleElementList;
+
+      while  ( (c = *pString) && isspace(c) )  pString++;   /* skip white space */
+      if  ( !*pString )  break;   /* found end of string; done */
+      pClassNameList = pString;
+
+      /* find the end of the comma-separated list of class names */
+      while  ( (c = *pString) && (c != '{') )  pString++;
+      if  ( !*pString )
+        {
+          /* malformed input: class name list not followed by '{' */
+          MagickFreeMemory(pCopyOfText);
+          return;
+        }
+      *pString++ = '\0';
+      pStyleElementList = pString;
+
+      /* extract the class names */
+      ClassDefActiveHead.pActiveNext = 0;
+      pClassDefActiveLast = &ClassDefActiveHead;  /* initially, no active class defs */
+      for  ( cp = pClassNameList; *cp; )
+        {/*extract class name loop*/
+
+          while  ( (c = *cp) && (isspace(c) || (c ==',')) )  cp++;  /* skip white space/commas */
+          if  ( *cp == '.' )  cp++;     /* .classname, skip leading period */
+          if  ( *cp )
+          {/*found class name*/
+
+              char * pClassName = cp;
+              while  ( (c = *cp) && !(isspace(c) || (c == ',')) )  cp++;  /* find white space/comma/null */
+              if  ( *cp )
+                *cp++ = '\0';   /* terminate identifier string and increment */
+              /* add uniquely to list */
+              for  (  pClassDef = ClassDefHead.pNext;
+                      pClassDef && (strcmp(pClassName,pClassDef->pName) != 0);
+                      pClassDef = pClassDef->pNext );
+              if  ( pClassDef == 0 )
+                {/*new class name*/
+                  ADD_NEW_STRUCT(pClassDef,pClassDefLast,ClassDef);
+                  pClassDef->pElementValueLast = &pClassDef->ElementValueHead;
+                  pClassDef->pName = pClassName;
+                }/*new class name*/
+              pClassDefActiveLast = pClassDefActiveLast->pActiveNext = pClassDef;   /* add to active list */
+
+              }/*found class name*/
+
+        }/*extract class name loop*/
+
+      /* find the end of the style elements */
+      while  ( (c = *pString) && (c != '}') )  pString++;
+      if  ( !*pString )
+        {
+          /* malformed input: style elements not terminated by '{' */
+          MagickFreeMemory(pCopyOfText);
+          return;
+        }
+      *pString++ = '\0';  /* advance past '}' for next loop pass */
+
+      /* get the style elements */
+      for  ( cp = pStyleElementList; *cp; )
+        {/*extract style elements loop*/
+
+          /* looking for <space><classname><space>: */
+          while  ( (c = *cp) && isspace(c) )  cp++;   /* skip white space */
+          if  ( *cp )
+            {/*found style element*/
+
+              char * pStyleElement = cp;
+              while  ( (c = *cp) && (c != ':') )  cp++;   /* find colon/null */
+              for  ( cp2 = cp-1; isspace(*cp2); *cp2-- = '\0');   /* trim white space */
+              if  ( *cp )
+                *cp++ = '\0';   /* terminate style element string and increment */
+
+              /* looking for <space><style-value>; */
+              while  ( (c = *cp) && isspace(c) )  cp++;   /* skip white space */
+              if  ( *cp )
+                {/*found style element value*/
+
+                  char * pStyleValue = cp;
+                  while  ( (c = *cp) && (c != ';') )  cp++;   /* find semi-colon/null */
+                  for  ( cp2 = cp-1; isspace(*cp2); *cp2-- = '\0');   /* trim white space */
+                  if  ( *cp )
+                    *cp++ = '\0';   /* terminate style value string and increment */
+
+                  /* add style element/value pair to each active class def */
+                  for  ( pClassDef = ClassDefActiveHead.pActiveNext; pClassDef; pClassDef = pClassDef->pActiveNext )
+                    {
+                      ElementValue * pEV;
+                      ADD_NEW_STRUCT(pEV,pClassDef->pElementValueLast,ElementValue);
+                      pEV->pKeyword = pStyleElement;
+                      pEV->pValue = pStyleValue;
+                    }
+
+                }/*found style element value*/
+
+            }/*found style element*/
+
+        }/*extract style elements loop*/
+
+    }/*pString loop*/
+
+  /* emit class definitions */
+  for  ( pClassDef = ClassDefHead.pNext; pClassDef; pClassDef = pClassDef->pNext )
+    {/*pClassDef loop*/
+
+      ElementValue * pEV;
+      MVGPrintf(svg_info->file,"push class '%s'\n",pClassDef->pName);
+      /* NOTE: we allow class definitions that are empty */
+      for  ( pEV = pClassDef->ElementValueHead.pNext; pEV; pEV = pEV->pNext )
+        {/*pEV loop*/
+
+          char * keyword = pEV->pKeyword;
+          char * value = pEV->pValue;
+          /* switch below was copied/pasted from elsewhere and modified */
+          switch (*keyword)
+            {/*keyword*/
+
+            case 'C':
+            case 'c':
+              {/*Cc*/
+                if (LocaleCompare(keyword,"clip-path") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"clip-path '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"clip-rule") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"clip-rule '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"clipPathUnits") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"clip-units '%s'\n",value);
+                    break;
+                  }
+                break;
+              }/*Cc*/
+
+            case 'F':
+            case 'f':
+               {/*Ff*/
+                if  ( (LocaleCompare(keyword,"fill") == 0) || (LocaleCompare(keyword,"fillcolor") == 0) )
+                  {
+                    MVGPrintf(svg_info->file,"fill '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"fill-rule") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"fill-rule '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"fill-opacity") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"fill-opacity '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"font-family") == 0)
+                  {
+                    /*
+                      Deal with Adobe Illustrator 10.0 which double-quotes
+                      font-family.  Maybe we need a generalized solution for
+                      this.
+                    */
+                    size_t n;
+                    if  ( (value[0] == '\'') && (value[(n = (strlen(value)-1))] == '\'') )
+                      {
+                        size_t i;
+                        FILE * fp = svg_info->file;
+                        MVGPrintf(fp,"font-family '");
+                        for(i = 1; i < n; i++)
+                          fputc(value[i],fp);
+                        MVGPrintf(fp,"'\n");
+                      }
+                    else
+                      MVGPrintf(svg_info->file,"font-family '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"font-stretch") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"font-stretch '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"font-style") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"font-style '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"font-size") == 0)
+                  {
+                    if (LocaleCompare(value,"medium") == 0)
+                      svg_info->pointsize = 12;
+                    else
+                      svg_info->pointsize = GetUserSpaceCoordinateValue(svg_info,0,value,MagickTrue);
+                    MVGPrintf(svg_info->file,"font-size %g\n",svg_info->pointsize);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"font-weight") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"font-weight '%s'\n",value);
+                    break;
+                  }
+                break;
+              }/*Ff*/
+
+            case 'O':
+            case 'o':
+              {/*Oo*/
+                if (LocaleCompare(keyword,"offset") == 0)
+                  {
+                   MVGPrintf(svg_info->file,"offset %g\n",GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse));
+                   break;
+                  }
+                if (LocaleCompare(keyword,"opacity") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"opacity '%s'\n",value);
+                    break;
+                  }
+                break;
+              }/*Oo*/
+
+            case 'S':
+            case 's':
+              {/*Ss*/
+                if (LocaleCompare(keyword,"stop-color") == 0)
+                  {
+                    (void) CloneString(&svg_info->stop_color,value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"stroke") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"stroke '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"stroke-antialiasing") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"stroke-antialias %d\n",LocaleCompare(value,"true") == 0);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"stroke-dasharray") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"stroke-dasharray %s\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"stroke-dashoffset") == 0)
+                  {
+                    double dashoffset=GetUserSpaceCoordinateValue(svg_info,1,value,MagickFalse);
+                    MVGPrintf(svg_info->file,"stroke-dashoffset %g\n",dashoffset);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"stroke-linecap") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"stroke-linecap '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"stroke-linejoin") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"stroke-linejoin '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"stroke-miterlimit") == 0)
+                  {
+                    double stroke_miterlimit;
+                    if ((MagickAtoFChk(value,&stroke_miterlimit) != MagickPass) || stroke_miterlimit < 1.0)
+                      {
+                        errno=0;
+                        ThrowException(svg_info->exception,DrawError,InvalidPrimitiveArgument,value);
+                        break;
+                      }
+                    MVGPrintf(svg_info->file,"stroke-miterlimit '%ld'\n",(long) stroke_miterlimit);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"stroke-opacity") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"stroke-opacity '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"stroke-width") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"stroke-width %g\n",GetUserSpaceCoordinateValue(svg_info,1,value,MagickTrue));
+                    break;
+                  }
+                break;
+              }/*Ss*/
+
+            case 'T':
+            case 't':
+              {/*Tt*/
+                if (LocaleCompare(keyword,"text-align") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"text-align '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"text-anchor") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"text-anchor '%s'\n",value);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"text-decoration") == 0)
+                  {
+                    if (LocaleCompare(value,"underline") == 0)
+                      MVGPrintf(svg_info->file,"decorate underline\n");
+                    if (LocaleCompare(value,"line-through") == 0)
+                      MVGPrintf(svg_info->file,"decorate line-through\n");
+                    if (LocaleCompare(value,"overline") == 0)
+                      MVGPrintf(svg_info->file,"decorate overline\n");
+                    break;
+                  }
+                if (LocaleCompare(keyword,"text-antialiasing") == 0)
+                  {
+                    MVGPrintf(svg_info->file,"text-antialias %d\n",LocaleCompare(value,"true") == 0);
+                    break;
+                  }
+                if (LocaleCompare(keyword,"transform") == 0)
+                  {/*style="transform: ...*/
+                    SVGProcessTransformString((void *)svg_info,value);
+                    break;
+                  }/*style="transform: ...*/
+                break;
+              }/*Tt*/
+
+            default:
+            break;
+
+            }/*keyword*/
+
+        }/*pEV loop*/
+
+      MVGPrintf(svg_info->file,"pop class\n");
+
+    }/*pClassDef loop*/
+
+  /* clean up */
+  {
+    ClassDef * pClassDef;
+    for(pClassDef = ClassDefHead.pNext; pClassDef; )
+      {
+        ElementValue *pEV;
+        ClassDef * pClassDefTemp = pClassDef;
+        for(pEV = pClassDef->ElementValueHead.pNext; pEV; )
+          {
+            ElementValue * pEVTemp = pEV;
+            pEV = pEV->pNext;
+            MagickFreeMemory(pEVTemp);
+          }
+        pClassDef = pClassDef->pNext;
+        MagickFreeMemory(pClassDefTemp);
+      }
+  }
+  MagickFreeMemory(pCopyOfText);
+
+#undef  ADD_NEW_STRUCT
+}/*ProcessStyleClassDefs*/
+
 static void
 SVGEndElement(void *context,const xmlChar *name)
 {
@@ -2341,6 +3163,11 @@ SVGEndElement(void *context,const xmlChar *name)
                       svg_info->element.cy,svg_info->element.cx,svg_info->element.cy+
                       svg_info->element.minor);
             MVGPrintf(svg_info->file,"pop graphic-context\n");
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "pop id" if warranted */
+              {
+                svg_info->idLevelInsideDefs = 0;
+                MVGPrintf(svg_info->file,"pop id\n");
+              }
             break;
           }
         if (LocaleCompare((char *) name,"clipPath") == 0)
@@ -2355,6 +3182,7 @@ SVGEndElement(void *context,const xmlChar *name)
       {
         if (LocaleCompare((char *) name,"defs") == 0)
           {
+            svg_info->defsPushCount--;
             MVGPrintf(svg_info->file,"pop defs\n");
             break;
           }
@@ -2362,7 +3190,7 @@ SVGEndElement(void *context,const xmlChar *name)
           {
             register char
               *p;
-            
+
             Strip(svg_info->text);
             if (*svg_info->text == '\0')
               break;
@@ -2386,13 +3214,34 @@ SVGEndElement(void *context,const xmlChar *name)
           {
             double
               angle;
-            
+
             angle=svg_info->element.angle;
             MVGPrintf(svg_info->file,"ellipse %g,%g %g,%g 0,360\n",
                       svg_info->element.cx,svg_info->element.cy,
                       angle == 0.0 ? svg_info->element.major : svg_info->element.minor,
                       angle == 0.0 ? svg_info->element.minor : svg_info->element.major);
             MVGPrintf(svg_info->file,"pop graphic-context\n");
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "pop id" if warranted */
+              {
+                svg_info->idLevelInsideDefs = 0;
+                MVGPrintf(svg_info->file,"pop id\n");
+              }
+            break;
+          }
+        break;
+      }
+    case 'F':
+    case 'f':
+      {
+        /*
+          For now we are ignoring "foreignObject".  However, we do a push/pop
+          graphic-context so that any settings (e.g., fill) are consumed and
+          discarded.  Otherwise they might persist and "leak" into the graphic
+          elements that follow.
+        */
+        if (LocaleCompare((char *) name,"foreignObject") == 0)
+          {
+            MVGPrintf(svg_info->file,"pop graphic-context\n");
             break;
           }
         break;
@@ -2403,6 +3252,11 @@ SVGEndElement(void *context,const xmlChar *name)
         if (LocaleCompare((char *) name,"g") == 0)
           {
             MVGPrintf(svg_info->file,"pop graphic-context\n");
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "pop id" if warranted */
+              {
+                svg_info->idLevelInsideDefs = 0;
+                MVGPrintf(svg_info->file,"pop id\n");
+              }
             break;
           }
         break;
@@ -2428,6 +3282,11 @@ SVGEndElement(void *context,const xmlChar *name)
             MVGPrintf(svg_info->file,"line %g,%g %g,%g\n",svg_info->segment.x1,
                       svg_info->segment.y1,svg_info->segment.x2,svg_info->segment.y2);
             MVGPrintf(svg_info->file,"pop graphic-context\n");
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "pop id" if warranted */
+              {
+                svg_info->idLevelInsideDefs = 0;
+                MVGPrintf(svg_info->file,"pop id\n");
+              }
             break;
           }
         if (LocaleCompare((char *) name,"linearGradient") == 0)
@@ -2437,6 +3296,16 @@ SVGEndElement(void *context,const xmlChar *name)
           }
         break;
       }
+    case 'M':
+    case 'm':
+      {
+        if (LocaleCompare((char *) name,"mask") == 0)   /* added mask */
+          {
+            MVGPrintf(svg_info->file,"pop mask\n");
+            break;
+          }
+        break;
+      }
     case 'P':
     case 'p':
       {
@@ -2449,18 +3318,33 @@ SVGEndElement(void *context,const xmlChar *name)
           {
             MVGPrintf(svg_info->file,"path '%s'\n",svg_info->vertices);
             MVGPrintf(svg_info->file,"pop graphic-context\n");
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "pop id" if warranted */
+              {
+                svg_info->idLevelInsideDefs = 0;
+                MVGPrintf(svg_info->file,"pop id\n");
+              }
             break;
           }
         if (LocaleCompare((char *) name,"polygon") == 0)
           {
             MVGPrintf(svg_info->file,"polygon %s\n",svg_info->vertices);
             MVGPrintf(svg_info->file,"pop graphic-context\n");
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "pop id" if warranted */
+              {
+                svg_info->idLevelInsideDefs = 0;
+                MVGPrintf(svg_info->file,"pop id\n");
+              }
             break;
           }
         if (LocaleCompare((char *) name,"polyline") == 0)
           {
             MVGPrintf(svg_info->file,"polyline %s\n",svg_info->vertices);
             MVGPrintf(svg_info->file,"pop graphic-context\n");
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "pop id" if warranted */
+              {
+                svg_info->idLevelInsideDefs = 0;
+                MVGPrintf(svg_info->file,"pop id\n");
+              }
             break;
           }
         break;
@@ -2482,6 +3366,11 @@ SVGEndElement(void *context,const xmlChar *name)
                           svg_info->bounds.x+svg_info->bounds.width,
                           svg_info->bounds.y+svg_info->bounds.height);
                 MVGPrintf(svg_info->file,"pop graphic-context\n");
+              if  ( svg_info->idLevelInsideDefs == svg_info->n )        /* emit a "pop id" if warranted */
+                {
+                  svg_info->idLevelInsideDefs = 0;
+                  MVGPrintf(svg_info->file,"pop id\n");
+                }
                 break;
               }
             if (svg_info->radius.x == 0.0)
@@ -2495,6 +3384,11 @@ SVGEndElement(void *context,const xmlChar *name)
             svg_info->radius.x=0.0;
             svg_info->radius.y=0.0;
             MVGPrintf(svg_info->file,"pop graphic-context\n");
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "pop id" if warranted */
+              {
+                svg_info->idLevelInsideDefs = 0;
+                MVGPrintf(svg_info->file,"pop id\n");
+              }
             break;
           }
         break;
@@ -2508,8 +3402,16 @@ SVGEndElement(void *context,const xmlChar *name)
                       svg_info->offset);
             break;
           }
+        /* element "style" inside <defs> */
+        if (LocaleCompare((char *) name,"style") == 0)
+          {
+            /* the style definitions are in svg_info->text */
+            ProcessStyleClassDefs(svg_info);
+            break;
+          }
         if (LocaleCompare((char *) name,"svg") == 0)
           {
+            svg_info->svgPushCount--;
             MVGPrintf(svg_info->file,"pop graphic-context\n");
             break;
           }
@@ -2527,12 +3429,16 @@ SVGEndElement(void *context,const xmlChar *name)
                   *text;
 
                 text=EscapeString(svg_info->text,'\'');
-                MVGPrintf(svg_info->file,"text %g,%g '%s'\n",svg_info->bounds.x,
-                          svg_info->bounds.y,text);
+                MVGPrintf(svg_info->file,"textc '%s'\n",text);  /* write text at current position */
                 MagickFreeMemory(text);
                 *svg_info->text='\0';
               }
             MVGPrintf(svg_info->file,"pop graphic-context\n");
+            if  ( svg_info->idLevelInsideDefs == svg_info->n )  /* emit a "pop id" if warranted */
+              {
+                svg_info->idLevelInsideDefs = 0;
+                MVGPrintf(svg_info->file,"pop id\n");
+              }
             break;
           }
         if (LocaleCompare((char *) name,"tspan") == 0)
@@ -2540,26 +3446,18 @@ SVGEndElement(void *context,const xmlChar *name)
             Strip(svg_info->text);
             if (*svg_info->text != '\0')
               {
-                DrawInfo
-                  *draw_info;
-
-                TypeMetric
-                  metrics;
-
                 char
                   *text;
 
                 text=EscapeString(svg_info->text,'\'');
-                MVGPrintf(svg_info->file,"text %g,%g '%s'\n",svg_info->bounds.x,
-                          svg_info->bounds.y,text);
+                MVGPrintf(svg_info->file,"textc '%s'\n",text);  /* write text at current position */
                 MagickFreeMemory(text);
-                draw_info=CloneDrawInfo(svg_info->image_info,(DrawInfo *) NULL);
-                draw_info->pointsize=svg_info->pointsize;
-                draw_info->text=AllocateString(svg_info->text);
-                (void) ConcatenateString(&draw_info->text," ");
-                (void) GetTypeMetrics(svg_info->image,draw_info,&metrics);
-                svg_info->bounds.x+=metrics.width;
-                DestroyDrawInfo(draw_info);
+                /*
+                  The code that used to be here to compute the next text position has been eliminated.
+                  The reason is that at this point in the code we may not know the font or font size
+                  (they may be hidden in a "class" definition), so we can't really do that computation.
+                  This functionality is now handled by DrawImage() in render.c.
+                */
                 *svg_info->text='\0';
               }
             MVGPrintf(svg_info->file,"pop graphic-context\n");
@@ -2576,6 +3474,34 @@ SVGEndElement(void *context,const xmlChar *name)
           }
         break;
       }
+    case 'U':
+    case 'u':
+      {
+        if (LocaleCompare((char *) name,"use") == 0)
+          {
+            /*
+              If the "use" had a "transform" attribute it has already been output to the MVG file.
+
+              According to the SVG spec for "use":
+
+              In the generated content, the 'use' will be replaced by 'g', where all attributes
+              from the 'use' element except for 'x', 'y', 'width', 'height' and 'xlink:href' are
+              transferred to the generated 'g' element. An additional transformation translate(x,y)
+              is appended to the end (i.e., right-side) of the 'transform' attribute on the generated
+              'g', where x and y represent the values of the 'x' and 'y' attributes on the 'use'
+              element. The referenced object and its contents are deep-cloned into the generated tree.
+            */
+            if  ( (svg_info->bounds.x != 0.0) || (svg_info->bounds.y != 0.0) )
+              MVGPrintf(svg_info->file,"translate %g,%g\n",svg_info->bounds.x,svg_info->bounds.y);
+
+            /* NOTE: not implementing "width" and "height" for now */
+
+            MVGPrintf(svg_info->file,"use '%s'\n",svg_info->url);
+            MVGPrintf(svg_info->file,"pop graphic-context\n");
+            break;
+          }
+        break;
+      }
     default:
       break;
     }
@@ -2693,6 +3619,9 @@ SVGComment(void *context,const xmlChar *value)
 }
 
 static void
+SVGWarning(void *context,const char *format,...) MAGICK_ATTRIBUTE((__format__ (__printf__,2,3)));
+
+static void
 SVGWarning(void *context,const char *format,...)
 {
   char
@@ -2722,6 +3651,9 @@ SVGWarning(void *context,const char *format,...)
 }
 
 static void
+SVGError(void *context,const char *format,...) MAGICK_ATTRIBUTE((__format__ (__printf__,2,3)));
+
+static void
 SVGError(void *context,const char *format,...)
 {
   char
@@ -2881,6 +3813,24 @@ ReadSVGImage(const ImageInfo *image_info,ExceptionInfo *exception)
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
   image=AllocateImage(image_info);
+  /*
+    If there is a geometry string in image_info->size (e.g., gm convert
+    -size "50x50%" in.svg out.png), AllocateImage() sets image->columns
+    and image->rows to the width and height values from the size string.
+    However, this makes no sense if the size string was something like
+    "50x50%" (we'll get columns = rows = 50).  So we set columns and
+    rows to 0 here, which is the same as if no size string was supplied
+    by the client.  This also results in svg_info.bounds to be set to
+    0,0 below (i.e., unknown), so that svg_info.bounds will be set using
+    the image size information from either the svg "canvas" width/height
+    or from the viewbox.  Later, variable "page" is set from
+    svg_info->bounds. Then the geometry string in image_info->size gets
+    applied to the (now known) "page" width and height when
+    SvgStartElement() calls GetMagickGeometry(), and the intended result
+    is obtained.
+  */
+  image->columns = 0;
+  image->rows = 0;
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == False)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
@@ -2916,6 +3866,9 @@ ReadSVGImage(const ImageInfo *image_info,ExceptionInfo *exception)
   svg_info.scale[0]=ExpandAffine(&svg_info.affine);
   svg_info.bounds.width=image->columns;
   svg_info.bounds.height=image->rows;
+  svg_info.defsPushCount = 0;
+  svg_info.idLevelInsideDefs = 0;
+  svg_info.svgPushCount = 0;
   if (image_info->size != (char *) NULL)
     (void) CloneString(&svg_info.size,image_info->size);
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),"begin SAX");
index 73062b2..8f839b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -240,7 +240,7 @@ static Image *ReadTGAImage(const ImageInfo *image_info,ExceptionInfo *exception)
         ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                             "ImageType=%s CMapType=%u CMapStart=%u CMapLength=%u CMapDepth=%u\n"
-                           "  XOffset=%u YOffset=%u Width=%u Height=%u PixelDepth=%u Attributes=0x%.2x",
+                            "  XOffset=%u YOffset=%u Width=%u Height=%u PixelDepth=%u Attributes=0x%.2x",
                             ((tga_info.image_type == TGAColormap) ? "Colormapped" :
                              (tga_info.image_type == TGARGB) ? "TrueColor" :
                              (tga_info.image_type == TGAMonochrome) ? "Monochrome" :
@@ -296,8 +296,15 @@ static Image *ReadTGAImage(const ImageInfo *image_info,ExceptionInfo *exception)
           (tga_info.image_type == TGARLEColormap) ||
           (tga_info.image_type == TGARLEMonochrome))
         {
-          (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Setting PseudoClass");
-          image->storage_class=PseudoClass;
+          if ((tga_info.bits_per_pixel == 1) || (tga_info.bits_per_pixel == 8))
+            {
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Setting PseudoClass");
+              image->storage_class=PseudoClass;
+            }
+          else
+            {
+              ThrowReaderException(CoderError,DataStorageTypeIsNotSupported,image);
+            }
         }
 
       if ((tga_info.image_type == TGARLEColormap) ||
@@ -335,13 +342,14 @@ static Image *ReadTGAImage(const ImageInfo *image_info,ExceptionInfo *exception)
                             ((image->storage_class == DirectClass) ? "DirectClass" : "PseduoClass"),
                             MagickBoolToString(image->matte), image->depth,
                             MagickBoolToString(is_grayscale));
-    
+
       if (tga_info.id_length != 0)
         {
           /*
             TGA image comment.
           */
-          assert((size_t) (tga_info.id_length+1) == commentsize);
+          if ((size_t) (tga_info.id_length+1) != commentsize)
+            ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
           if (ReadBlob(image,tga_info.id_length,commentbuffer) != tga_info.id_length)
             ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
           commentbuffer[tga_info.id_length]='\0';
@@ -379,10 +387,10 @@ static Image *ReadTGAImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       packet;
 
                     if (ReadBlob(image, 2, readbuffer) != 2)
-                     ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-                   readbufferpos = 0;
-                   packet = ReadBlobByteFromBuffer(readbuffer, &readbufferpos);
-                   packet |= (((unsigned int) ReadBlobByteFromBuffer(readbuffer, &readbufferpos)) << 8);
+                      ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+                    readbufferpos = 0;
+                    packet = ReadBlobByteFromBuffer(readbuffer, &readbufferpos);
+                    packet |= (((unsigned int) ReadBlobByteFromBuffer(readbuffer, &readbufferpos)) << 8);
 
                     pixel.red=(packet >> 10) & 0x1f;
                     pixel.red=ScaleCharToQuantum(ScaleColor5to8(pixel.red));
@@ -399,11 +407,11 @@ static Image *ReadTGAImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       8 bits each of blue, green and red.
                     */
                     if (ReadBlob(image, 3, readbuffer) != 3)
-                     ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-                   readbufferpos = 0;
-                   pixel.blue=ScaleCharToQuantum(ReadBlobByteFromBuffer(readbuffer, &readbufferpos));
-                   pixel.green=ScaleCharToQuantum(ReadBlobByteFromBuffer(readbuffer, &readbufferpos));
-                   pixel.red=ScaleCharToQuantum(ReadBlobByteFromBuffer(readbuffer, &readbufferpos));
+                      ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+                    readbufferpos = 0;
+                    pixel.blue=ScaleCharToQuantum(ReadBlobByteFromBuffer(readbuffer, &readbufferpos));
+                    pixel.green=ScaleCharToQuantum(ReadBlobByteFromBuffer(readbuffer, &readbufferpos));
+                    pixel.red=ScaleCharToQuantum(ReadBlobByteFromBuffer(readbuffer, &readbufferpos));
                     break;
                   }
                 }
@@ -494,13 +502,13 @@ static Image *ReadTGAImage(const ImageInfo *image_info,ExceptionInfo *exception)
                         packet;
 
                       if (ReadBlob(image, 2, readbuffer) != 2)
-                       {
-                         status=MagickFail;
-                         break;
-                       }
-                     readbufferpos = 0;
-                     packet = ReadBlobByteFromBuffer(readbuffer, &readbufferpos);
-                     packet |= (((unsigned int) ReadBlobByteFromBuffer(readbuffer, &readbufferpos)) << 8);
+                        {
+                          status=MagickFail;
+                          break;
+                        }
+                      readbufferpos = 0;
+                      packet = ReadBlobByteFromBuffer(readbuffer, &readbufferpos);
+                      packet |= (((unsigned int) ReadBlobByteFromBuffer(readbuffer, &readbufferpos)) << 8);
 
                       pixel.red=(packet >> 10) & 0x1f;
                       pixel.red=ScaleCharToQuantum(ScaleColor5to8(pixel.red));
@@ -515,7 +523,7 @@ static Image *ReadTGAImage(const ImageInfo *image_info,ExceptionInfo *exception)
                           else
                             pixel.opacity=TransparentOpacity;
                         }
-                
+
                       if (image->storage_class == PseudoClass)
                         {
                           index=(IndexPacket) (packet & 0x7fff);
@@ -528,10 +536,10 @@ static Image *ReadTGAImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       8 bits each of blue green and red.
                     */
                     if (ReadBlob(image, 3, readbuffer) != 3)
-                     {
-                       status=MagickFail;
-                       break;
-                     }
+                      {
+                        status=MagickFail;
+                        break;
+                      }
                     readbufferpos = 0;
                     pixel.blue=ScaleCharToQuantum(ReadBlobByteFromBuffer(readbuffer, &readbufferpos));
                     pixel.green=ScaleCharToQuantum(ReadBlobByteFromBuffer(readbuffer, &readbufferpos));
@@ -543,10 +551,10 @@ static Image *ReadTGAImage(const ImageInfo *image_info,ExceptionInfo *exception)
                         8 bits each of blue green and red.
                       */
                       if (ReadBlob(image, 4, readbuffer) != 4)
-                       {
-                         status=MagickFail;
-                         break;
-                       }
+                        {
+                          status=MagickFail;
+                          break;
+                        }
                       readbufferpos = 0;
                       pixel.blue=ScaleCharToQuantum(ReadBlobByteFromBuffer(readbuffer, &readbufferpos));
                       pixel.green=ScaleCharToQuantum(ReadBlobByteFromBuffer(readbuffer, &readbufferpos));
@@ -588,7 +596,7 @@ static Image *ReadTGAImage(const ImageInfo *image_info,ExceptionInfo *exception)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
       if (EOFBlob(image))
@@ -606,18 +614,18 @@ static Image *ReadTGAImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
       status=MagickFalse;
       if (ReadBlob(image, 3, readbuffer) == 3)
-       {
-         readbufferpos = 0;
-         tga_info.id_length=(unsigned char)ReadBlobByteFromBuffer(readbuffer, &readbufferpos);
-         tga_info.colormap_type=(unsigned char)ReadBlobByteFromBuffer(readbuffer, &readbufferpos);
-         tga_info.image_type=(unsigned char)ReadBlobByteFromBuffer(readbuffer, &readbufferpos);
-         status=((tga_info.image_type == TGAColormap) ||
-                 (tga_info.image_type == TGARGB) ||
-                 (tga_info.image_type == TGAMonochrome) ||
-                 (tga_info.image_type == TGARLEColormap) ||
-                 (tga_info.image_type == TGARLERGB) ||
-                 (tga_info.image_type == TGARLEMonochrome));
-       }
+        {
+          readbufferpos = 0;
+          tga_info.id_length=(unsigned char)ReadBlobByteFromBuffer(readbuffer, &readbufferpos);
+          tga_info.colormap_type=(unsigned char)ReadBlobByteFromBuffer(readbuffer, &readbufferpos);
+          tga_info.image_type=(unsigned char)ReadBlobByteFromBuffer(readbuffer, &readbufferpos);
+          status=((tga_info.image_type == TGAColormap) ||
+                  (tga_info.image_type == TGARGB) ||
+                  (tga_info.image_type == TGAMonochrome) ||
+                  (tga_info.image_type == TGARLEColormap) ||
+                  (tga_info.image_type == TGARLERGB) ||
+                  (tga_info.image_type == TGARLEMonochrome));
+        }
       if (!EOFBlob(image) && (status == MagickTrue))
         {
           /*
@@ -827,6 +835,9 @@ static unsigned int WriteTGAImage(const ImageInfo *image_info,Image *image)
   unsigned long
     scene;
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -834,6 +845,7 @@ static unsigned int WriteTGAImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == MagickFalse)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -841,7 +853,7 @@ static unsigned int WriteTGAImage(const ImageInfo *image_info,Image *image)
   do
     {
       ImageCharacteristics
-        characteristics;        
+        characteristics;
 
       write_grayscale=MagickFalse;
 
@@ -895,10 +907,10 @@ static unsigned int WriteTGAImage(const ImageInfo *image_info,Image *image)
       targa_info.id_length=0;
       attribute=GetImageAttribute(image,"comment");
       if (attribute != (const ImageAttribute *) NULL)
-           {
-                 unsigned char id_length =(unsigned char) strlen(attribute->value);
+            {
+                  unsigned char id_length =(unsigned char) strlen(attribute->value);
           targa_info.id_length=Min(id_length,255);
-           }
+            }
       targa_info.colormap_type=0;
       targa_info.colormap_index=0;
       targa_info.colormap_length=0;
@@ -917,11 +929,11 @@ static unsigned int WriteTGAImage(const ImageInfo *image_info,Image *image)
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                 "Writing Grayscale raster ...");
           targa_info.image_type=TargaMonochrome;
-         targa_info.bits_per_pixel=8;
-         targa_info.colormap_type=0;
+          targa_info.bits_per_pixel=8;
+          targa_info.colormap_type=0;
           targa_info.colormap_index=0;
           targa_info.colormap_length=0;
-          targa_info.colormap_size=0;  
+          targa_info.colormap_size=0;
         }
       else if (image->storage_class == DirectClass)
         {
@@ -1050,14 +1062,14 @@ static unsigned int WriteTGAImage(const ImageInfo *image_info,Image *image)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                           SaveImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
       MagickFreeMemory(targa_pixels);
       if (image->next == (Image *) NULL)
         break;
       image=SyncNextImageInList(image);
-      if (!MagickMonitorFormatted(scene++,GetImageListLength(image),
+      if (!MagickMonitorFormatted(scene++,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename))
         break;
index affab1d..7bfeb5d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -65,6 +65,9 @@
 #  if !defined(COMPRESSION_ADOBE_DEFLATE)
 #     define COMPRESSION_ADOBE_DEFLATE  8
 #  endif  /* !defined(COMPRESSION_ADOBE_DEFLATE) */
+#  if defined(COMPRESSION_ZSTD) && defined(HasZSTD)
+#    include "zstd.h"
+#  endif /* if defined(COMPRESSION_ZSTD) && defined(HasZSTD) */
 
 /*
   JPEG headers are needed in order to obtain BITS_IN_JSAMPLE
@@ -276,8 +279,8 @@ TIFFIgnoreTags(TIFF *tiff)
     *p,
     *tags;
 
-  const ImageInfo
-    *image_info;
+  Magick_TIFF_ClientData
+    *client_data;
 
   register ssize_t
     i;
@@ -291,8 +294,10 @@ TIFFIgnoreTags(TIFF *tiff)
   if (TIFFGetReadProc(tiff) != TIFFReadBlob)
     return;
 
-  image_info=((Magick_TIFF_ClientData *)TIFFClientdata(tiff))->image_info;
-  tags=AccessDefinition(image_info,"tiff","ignore-tags");
+  client_data=((Magick_TIFF_ClientData *) TIFFClientdata(tiff));
+  if (client_data == (Magick_TIFF_ClientData *) NULL)
+    return;
+  tags=AccessDefinition(client_data->image_info,"tiff","ignore-tags");
   if (tags == (const char *) NULL)
     return;
   count=0;
@@ -303,9 +308,7 @@ TIFFIgnoreTags(TIFF *tiff)
         p++;
 
       {
-        /* Avoid warning about unused strtol return value on Linux */
-        long ignored = strtol(p,&q,10);
-        (void) ignored;
+        (void) strtol(p,&q,10);
       }
       if (p == q)
         return;
@@ -321,6 +324,12 @@ TIFFIgnoreTags(TIFF *tiff)
   i=0;
   p=tags;
   ignore=MagickAllocateArray(TIFFFieldInfo*,count,sizeof(*ignore));
+  if (ignore == (TIFFFieldInfo*) NULL)
+    {
+      ThrowException(&client_data->image->exception,ResourceLimitError,
+                     MemoryAllocationFailed,client_data->image->filename);
+      return;
+    }
   /* This also sets field_bit to 0 (FIELD_IGNORE) */
   (void) memset(ignore,0,count*sizeof(*ignore));
   while (*p != '\0')
@@ -359,7 +368,7 @@ ExtensionTagsDefaultDirectory(TIFF *tif)
    * the default directory method, we call it now to
    * allow it to set up the rest of its own methods.
    */
-  if (_ParentExtender) 
+  if (_ParentExtender)
     (*_ParentExtender)(tif);
   TIFFIgnoreTags(tif);
 }
@@ -373,7 +382,7 @@ void ExtensionTagsInitialize(void)
 {
   static int
     first_time=1;
-       
+
   if (! first_time) return; /* Been there. Done that. */
   first_time = 0;
 
@@ -389,7 +398,7 @@ void ExtensionTagsInitialize(void)
 */
 static MagickBool
 CompressionSupported(const CompressionType compression,
-                    char *compression_name)
+                     char *compression_name)
 {
   uint16
     compress_tag;
@@ -436,24 +445,24 @@ CompressionSupported(const CompressionType compression,
       {
         strlcpy(compression_name,"Group4 FAX",MaxTextExtent);
 #if defined(COMPRESSION_CCITTFAX4)
-        compress_tag=COMPRESSION_CCITTFAX4; 
+        compress_tag=COMPRESSION_CCITTFAX4;
         status=MagickTrue;
 #endif
         break;
       }
     case JBIG1Compression:
       {
-       strlcpy(compression_name,"JBIG",MaxTextExtent);
+        strlcpy(compression_name,"JBIG",MaxTextExtent);
 #if defined(COMPRESSION_JBIG)
         compress_tag=COMPRESSION_JBIG;
         status=MagickTrue;
 #endif
-       break;
+        break;
       }
     case JBIG2Compression:
       {
-       strlcpy(compression_name,"JBIG2",MaxTextExtent);
-       break;
+        strlcpy(compression_name,"JBIG2",MaxTextExtent);
+        break;
       }
     case JPEGCompression:
       {
@@ -501,6 +510,15 @@ CompressionSupported(const CompressionType compression,
 #endif
         break;
       }
+    case WebPCompression:
+      {
+        strlcpy(compression_name,"WebP",MaxTextExtent);
+#if defined(COMPRESSION_WEBP)
+        compress_tag=COMPRESSION_WEBP;
+        status=MagickTrue;
+#endif
+        break;
+      }
     case ZipCompression:
       {
         strlcpy(compression_name,"Adobe Deflate",MaxTextExtent);
@@ -510,6 +528,15 @@ CompressionSupported(const CompressionType compression,
 #endif
         break;
       }
+    case ZSTDCompression:
+      {
+        strlcpy(compression_name,"Zstandard",MaxTextExtent);
+#if defined(COMPRESSION_ZSTD)
+        compress_tag=COMPRESSION_ZSTD;
+        status=MagickTrue;
+#endif
+        break;
+      }
     }
 
   if (MagickTrue == status)
@@ -522,12 +549,12 @@ CompressionSupported(const CompressionType compression,
             working. Otherwise 0 will be returned.
           */
           if (!TIFFIsCODECConfigured(compress_tag))
-           status = MagickFalse;
-         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "TIFFIsCODECConfigured says support for %s "
-                               "compression %s configured.",
-                               compression_name,
-                               (status == MagickTrue ? "is" : "is not"));
+            status = MagickFalse;
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "TIFFIsCODECConfigured says support for %s "
+                                "compression %s configured.",
+                                compression_name,
+                                (status == MagickTrue ? "is" : "is not"));
         }
 #else
       switch (compress_tag)
@@ -627,6 +654,21 @@ CompressionTagToString(unsigned int compress_tag)
       result="ThunderScan RLE";
       break;
 #endif
+#if defined(COMPRESSION_LZMA)
+    case COMPRESSION_LZMA:
+      result="LZMA";
+      break;
+#endif
+#if defined(COMPRESSION_ZSTD)
+    case COMPRESSION_ZSTD:
+      result="Zstandard";
+      break;
+#endif
+#if defined(COMPRESSION_WEBP)
+    case COMPRESSION_WEBP:
+      result="WebP";
+      break;
+#endif
   }
   return result;
 }
@@ -636,7 +678,7 @@ PhotometricTagToString(unsigned int photometric)
 {
   const char
     *result = "Unknown";
-  
+
   switch (photometric)
     {
     case  PHOTOMETRIC_CIELAB:
@@ -676,53 +718,122 @@ PhotometricTagToString(unsigned int photometric)
   return result;
 }
 
+/*
+  Locate and store Photoshop or IPTC profiles.
+
+  Arguments:
+
+  text - Pointer to octet buffer
+  length - Number of bytes or 32-bit words in buffer
+  image  - Image to store into
+  type   - TIFF tag (TIFFTAG_PHOTOSHOP or TIFFTAG_RICHTIFFIPTC)
+
+  If the tag is TIFFTAG_RICHTIFFIPTC then it appears that the length
+  represents the number of 32-bit words.  If the tag is
+  TIFFTAG_PHOTOSHOP then the length is in bytes, but the underlying
+  data is stored in units of 16-bit words.
+ */
+#define NEWSP_REMAINING(base_p,current_p,length) ((ssize_t) length-(current_p-base_p))
 static unsigned int
-ReadNewsProfile(char *text,long int length,Image *image,int type)
+ReadNewsProfile(const unsigned char *text,const size_t length,Image *image,const int type)
 {
-  register unsigned char
+  register const unsigned char
     *p;
 
-  if (length <= 0)
-    return(False);
+#if defined(GET_ONLY_IPTC_DATA)
+  static const char tag_header [] = "8BIM44";
+#else
+  static const char tag_header [] = "8BIM";
+#endif
+
+  MagickBool found_header=MagickFalse;
+
+  if ((length == 0) || ((ssize_t) length < 0))
+    return MagickFail;
+
   p=(unsigned char *) text;
   if (type == TIFFTAG_RICHTIFFIPTC)
     {
       /*
-        Handle IPTC tag.
+        Handle IPTC tag (length is number of 32-bit words).
       */
-      length*=4;
-      return SetImageProfile(image,"IPTC",p,(size_t) length);
+      return SetImageProfile(image,"IPTC",p,(size_t) length*4U);
     }
   /*
-    Handle PHOTOSHOP tag.
+    Handle PHOTOSHOP tag (length is in bytes, but data is organized as
+    array of 16-bit values.
   */
-  while (length > 0)
-  {
-#if defined(GET_ONLY_IPTC_DATA)
-    if (LocaleNCompare((char *) p,"8BIM44",6) == 0)
-#else
-    if (LocaleNCompare((char *) p,"8BIM",4) == 0)
-#endif
-      break;
-    length-=2;
-    p+=2;
-  }
-  if (length <= 0)
-    return(False);
+  while (NEWSP_REMAINING(text,p,length) > (ssize_t) sizeof(tag_header))
+    {
+      if (LocaleNCompare((char *) p,tag_header,sizeof(tag_header)-1) == 0)
+        {
+          found_header=MagickTrue;
+          break;
+        }
+      p+=2;
+    }
+  if (!found_header)
+    {
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "Failed to find %s header, ignoring profile.",
+                            tag_header);
+      return MagickFail;
+    }
 #if defined(GET_ONLY_IPTC_DATA)
   /*
     Eat OSType, IPTC ID code, and Pascal string length bytes.
   */
-  p+=6;
-  length=(*p++);
-  if (length)
-    p+=length;
-  if ((length & 0x01) == 0)
-    p++;  /* align to an even byte boundary */
-  length=(p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
-  p+=4;
+  do
+    {
+      magick_uint32_t
+        hdr_length;
+
+      p+=sizeof(tag_header)-1;
+      if (NEWSP_REMAINING(text,p,length) < 8)
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Truncated profile: %" MAGICK_SIZE_T_F
+                                "u bytes, %" MAGICK_SSIZE_T_F "u remaining"
+                                ", ignoring profile.",
+                                (MAGICK_SIZE_T) length,
+                                (MAGICK_SSIZE_T) NEWSP_REMAINING(text,p,length));
+          break;
+        }
+      hdr_length=(*p++);
+      p+=hdr_length;
+      if (NEWSP_REMAINING(text,p,length) < 8)
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Truncated profile: %" MAGICK_SIZE_T_F
+                                "u bytes, %" MAGICK_SSIZE_T_F "u remaining"
+                                ", ignoring profile.",
+                                (MAGICK_SIZE_T) length,
+                                (MAGICK_SSIZE_T) NEWSP_REMAINING(text,p,length));
+          break;
+        }
+      if ((hdr_length & 0x01) == 0)
+        p++;  /* align to an even byte boundary */
+      hdr_length=(p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
+      p+=4;
+      if (((ssize_t) hdr_length <= 0) ||
+          ((ssize_t) hdr_length > NEWSP_REMAINING(text,p,length)))
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Truncated profile: %" MAGICK_SIZE_T_F
+                                "u bytes, %" MAGICK_SSIZE_T_F "u "
+                                "remaining (need %u more bytes)"
+                                ", ignoring profile.",
+                                (MAGICK_SIZE_T) length,
+                                (MAGICK_SSIZE_T) NEWSP_REMAINING(text,p,length),
+                                hdr_length);
+          return MagickFail;
+        }
+      return SetImageProfile(image,"8BIM",p,hdr_length);
+    } while (0);
+  return MagickFail;
+#else
+  return SetImageProfile(image,"8BIM",p,(size_t) NEWSP_REMAINING(text,p,length));
 #endif
-  return SetImageProfile(image,"8BIM",p,(size_t) length);
 }
 
 /*
@@ -775,7 +886,10 @@ TIFFCloseBlob(thandle_t image_handle)
 }
 
 /* Report errors. */
-static unsigned int
+static void
+TIFFErrors(const char *module,const char *format,
+           va_list warning) MAGICK_ATTRIBUTE((__format__ (__printf__,2,0)));
+static void
 TIFFErrors(const char *module,const char *format,
   va_list warning)
 {
@@ -791,7 +905,6 @@ TIFFErrors(const char *module,const char *format,
   (void) strlcat(message,".",MaxTextExtent);
   tiff_exception=(ExceptionInfo *) MagickTsdGetSpecific(tsd_key);
   ThrowException2(tiff_exception,CoderError,message,module);
-  return(True);
 }
 
 /* Memory map entire input file in read-only mode. */
@@ -810,8 +923,8 @@ TIFFMapBlob(thandle_t image_handle,tdata_t *base,toff_t *size)
 #if LOG_TIFF_BLOB_IO
       if (image->logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "TIFF mapped blob: base=0x%p size=%" MAGICK_OFF_F
-                             "d",*base, (magick_off_t) *size);
+                              "TIFF mapped blob: base=0x%p size=%" MAGICK_OFF_F
+                              "d",*base, (magick_off_t) *size);
 #endif
       return 1;
     }
@@ -835,8 +948,8 @@ TIFFReadBlob(thandle_t image_handle,tdata_t data,tsize_t size)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                           "TIFF read blob: data=0x%p size=%"
                           MAGICK_SIZE_T_F "u, returns %"
-                         MAGICK_SIZE_T_F "u",
-                         data, (MAGICK_SIZE_T) size,
+                          MAGICK_SIZE_T_F "u",
+                          data, (MAGICK_SIZE_T) size,
                           (MAGICK_SIZE_T) result);
 #endif /* LOG_TIFF_BLOB_IO */
 
@@ -858,13 +971,13 @@ TIFFSeekBlob(thandle_t image_handle,toff_t offset,int whence)
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                           "TIFF seek blob: offset=%" MAGICK_OFF_F
-                         "u whence=%d (%s), returns %" MAGICK_OFF_F "d",
+                          "u whence=%d (%s), returns %" MAGICK_OFF_F "d",
                           (magick_off_t) offset,
-                         whence,
+                          whence,
                           (whence == SEEK_SET ? "SET" :
                            (whence == SEEK_CUR ? "CUR" :
                             (whence == SEEK_END ? "END" : "unknown"))),
-                         (magick_off_t) result);
+                          (magick_off_t) result);
 #endif  /* LOG_TIFF_BLOB_IO */
   return result;
 }
@@ -884,8 +997,8 @@ TIFFGetBlobSize(thandle_t image_handle)
 #if LOG_TIFF_BLOB_IO
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                         "TIFF get blob size returns %" MAGICK_OFF_F "d",
-                         (magick_off_t) result);
+                          "TIFF get blob size returns %" MAGICK_OFF_F "d",
+                          (magick_off_t) result);
 #endif /* LOG_TIFF_BLOB_IO */
 
   return result;
@@ -903,8 +1016,8 @@ TIFFUnmapBlob(thandle_t image,
 
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                         "TIFF unmap blob: base=0x%p size=%" MAGICK_OFF_F "d",
-                         base,(magick_off_t) size);
+                          "TIFF unmap blob: base=0x%p size=%" MAGICK_OFF_F "d",
+                          base,(magick_off_t) size);
 #else
   ARG_NOT_USED(image);
   ARG_NOT_USED(base);
@@ -913,7 +1026,9 @@ TIFFUnmapBlob(thandle_t image,
 }
 
 /* Report warnings as a coder log message. */
-static unsigned int
+static void
+TIFFWarningsLogOnly(const char *module,const char *format,va_list warning) MAGICK_ATTRIBUTE((__format__ (__printf__,2,0)));
+static void
 TIFFWarningsLogOnly(const char *module,const char *format,va_list warning)
 {
 /*   ExceptionInfo */
@@ -931,11 +1046,12 @@ TIFFWarningsLogOnly(const char *module,const char *format,va_list warning)
 /*   ThrowException2(tiff_exception,CoderWarning,message,module); */
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                         "TIFF Warning: %s",message);
-  return(True);
 }
 
 /* Report warnings as exception in thread-specific ExceptionInfo */
-static unsigned int
+static void
+TIFFWarningsThrowException(const char *module,const char *format,va_list warning) MAGICK_ATTRIBUTE((__format__ (__printf__,2,0)));
+static void
 TIFFWarningsThrowException(const char *module,const char *format,va_list warning)
 {
   ExceptionInfo
@@ -953,7 +1069,6 @@ TIFFWarningsThrowException(const char *module,const char *format,va_list warning
   ThrowException2(tiff_exception,CoderWarning,message,module);
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                         "TIFF Warning: %s",message);
-  return(True);
 }
 
 /* Write data at current offset */
@@ -971,10 +1086,10 @@ TIFFWriteBlob(thandle_t image_handle,tdata_t data,tsize_t size)
 #if LOG_TIFF_BLOB_IO
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                         "TIFF write blob: data=0x%p size=%" MAGICK_SIZE_T_F
-                         "u, returns %" MAGICK_SIZE_T_F "u",
-                         data, (MAGICK_SIZE_T) size,
-                         (MAGICK_SIZE_T) result);
+                          "TIFF write blob: data=0x%p size=%" MAGICK_SIZE_T_F
+                          "u, returns %" MAGICK_SIZE_T_F "u",
+                          data, (MAGICK_SIZE_T) size,
+                          (MAGICK_SIZE_T) result);
 #endif  /* LOG_TIFF_BLOB_IO */
 
   return result;
@@ -986,30 +1101,30 @@ TIFFWriteBlob(thandle_t image_handle,tdata_t data,tsize_t size)
 #if !defined(WORDS_BIGENDIAN)
 static void
 SwabDataToBigEndian(const uint16 bits_per_sample, tdata_t data,
-                   const tsize_t size)
+                    const tsize_t size)
 {
   if (bits_per_sample == 64U)
     {
       TIFFSwabArrayOfDouble((double*) data,
-                           NumberOfObjectsInArray(size,sizeof(double)));
+                            NumberOfObjectsInArray(size,sizeof(double)));
     }
   else if (bits_per_sample == 32U)
     {
       TIFFSwabArrayOfLong((uint32*) data,
-                         NumberOfObjectsInArray(size,sizeof(uint32)));
+                          NumberOfObjectsInArray(size,sizeof(uint32)));
     }
 #if defined(HAVE_TIFFSWABARRAYOFTRIPLES)
   /* New libtiff function to swap 24 bit values.  Grumble ... */
   else if (bits_per_sample == 24U)
     {
       TIFFSwabArrayOfTriples(data,
-                            NumberOfObjectsInArray(size,3));
+                             NumberOfObjectsInArray(size,3));
     }
 #endif
   else if (bits_per_sample == 16U)
     {
       TIFFSwabArrayOfShort((uint16*) data,
-                          NumberOfObjectsInArray(size,sizeof(uint16)));
+                           NumberOfObjectsInArray(size,sizeof(uint16)));
     }
 }
 #endif
@@ -1020,30 +1135,30 @@ SwabDataToBigEndian(const uint16 bits_per_sample, tdata_t data,
 #if !defined(WORDS_BIGENDIAN)
 static void
 SwabDataToNativeEndian(const uint16 bits_per_sample, tdata_t data,
-                      const tsize_t size)
+                       const tsize_t size)
 {
   if (bits_per_sample == 64)
     {
       TIFFSwabArrayOfDouble((double*) data,
-                           NumberOfObjectsInArray(size,sizeof(double)));
+                            NumberOfObjectsInArray(size,sizeof(double)));
     }
   else if (bits_per_sample == 32)
     {
       TIFFSwabArrayOfLong((uint32*) data,
-                         NumberOfObjectsInArray(size,sizeof(uint32)));
+                          NumberOfObjectsInArray(size,sizeof(uint32)));
     }
 #if defined(HAVE_TIFFSWABARRAYOFTRIPLES)
   /* New libtiff function to swap 24 bit values.  Grumble ... */
   else if (bits_per_sample == 24U)
     {
       TIFFSwabArrayOfTriples(data,
-                            NumberOfObjectsInArray(size,3));
+                             NumberOfObjectsInArray(size,3));
     }
 #endif
   else if (bits_per_sample == 16)
     {
       TIFFSwabArrayOfShort((uint16*) data,
-                          NumberOfObjectsInArray(size,sizeof(uint16)));
+                           NumberOfObjectsInArray(size,sizeof(uint16)));
     }
 }
 #endif
@@ -1085,7 +1200,7 @@ InitializeImageColormap(Image *image, TIFF *tiff)
       else
         image->colors=MaxColormapSize;
     }
-  
+
   if (image->colors > 0)
     {
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
@@ -1117,12 +1232,12 @@ InitializeImageColormap(Image *image, TIFF *tiff)
           {
             long
               range;
-        
+
             uint16
               *blue_colormap,
               *green_colormap,
               *red_colormap;
-        
+
             (void) TIFFGetField(tiff,TIFFTAG_COLORMAP,&red_colormap,
                                 &green_colormap,&blue_colormap);
             range=256L;  /* might be old style 8-bit colormap */
@@ -1278,22 +1393,28 @@ QuantumTransferMode(const Image *image,
           }
         case PHOTOMETRIC_LOGL:
           {
-            *quantum_type=CIEYQuantum;
-            *quantum_samples=1;
-            break;
-          }
-        case PHOTOMETRIC_LOGLUV:
-          {
-            if (samples_per_pixel == 1)
+            if (!image->matte)
               {
-                /* FIXME: this might not work. */
                 *quantum_type=CIEYQuantum;
                 *quantum_samples=1;
               }
-            else
+            break;
+          }
+        case PHOTOMETRIC_LOGLUV:
+          {
+            if (!image->matte)
               {
-                *quantum_type=CIEXYZQuantum;
-                *quantum_samples=3;
+                if (samples_per_pixel == 1)
+                  {
+                    /* FIXME: this might not work. */
+                    *quantum_type=CIEYQuantum;
+                    *quantum_samples=1;
+                  }
+                else
+                  {
+                    *quantum_type=CIEXYZQuantum;
+                    *quantum_samples=3;
+                  }
               }
             break;
           }
@@ -1439,7 +1560,10 @@ QuantumTransferMode(const Image *image,
           }
         }
     }
-  /* fprintf(stderr,"Quantum Type: %d Quantum Samples: %d\n",(int) *quantum_type,*quantum_samples); */
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Quantum Type: %s, Quantum Samples: %d",
+                          QuantumTypeToString(*quantum_type),*quantum_samples);
   /* FIXME: We do need to support YCbCr! */
 
   if (*quantum_samples != 0)
@@ -1461,6 +1585,10 @@ QuantumTransferMode(const Image *image,
         }
     }
 
+  if ((image->logging) && (*quantum_samples == 0))
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Reporting failure");
+
   return (*quantum_samples != 0 ? MagickPass : MagickFail);
 }
 
@@ -1472,12 +1600,13 @@ QuantumTransferMode(const Image *image,
 */
 static void
 CompactSamples( const unsigned long total_pixels,
-               const unsigned int bits_per_sample,
-               const unsigned int samples_per_pixel,
-               const unsigned int quantum_samples,
-               unsigned char *samples)
+                const unsigned int bits_per_sample,
+                const unsigned int samples_per_pixel,
+                const unsigned int quantum_samples,
+                unsigned char *samples)
 {
-  if (samples_per_pixel > quantum_samples)
+  if ((samples_per_pixel > quantum_samples) &&
+      (bits_per_sample > 0) && bits_per_sample <= 32)
     {
       /*
         Compact scanline to only contain raster data.
@@ -1604,7 +1733,7 @@ DisassociateAlphaRegion(Image *image)
       _attribute[Min(sizeof(_attribute)-1,count)]='\0';                \
       (void) SetImageAttribute(image,key,_attribute);                 \
     } while(0);
-    
+
 
 typedef enum
 {
@@ -1616,6 +1745,13 @@ typedef enum
   RGBAPuntMethod             /* RGBA whole-image method (last resort) */
 } TIFFMethod;
 
+#define ThrowTIFFReaderException(code_,reason_,image_) \
+{ \
+  if (tiff != (TIFF *) NULL)                  \
+    TIFFClose(tiff);                          \
+  ThrowReaderException(code_,reason_,image_); \
+}
+
 static Image *
 ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
@@ -1646,7 +1782,11 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
     i;
 
   TIFF
-    *tiff;
+    *tiff = (TIFF *) NULL;
+
+  magick_off_t
+    file_size,
+    max_compress_ratio=1000; /* Maximum compression ratio */
 
   uint16
     compress_tag,
@@ -1703,6 +1843,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFail)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
+  file_size = GetBlobSize(image);
   (void) MagickTsdSetSpecific(tsd_key,(void *) exception);
   (void) TIFFSetErrorHandler((TIFFErrorHandler) TIFFErrors);
   (void) TIFFSetWarningHandler((TIFFErrorHandler) (CheckThrowWarnings(image_info) ?
@@ -1711,8 +1852,8 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
   client_data.image=image;
   client_data.image_info=image_info;
   tiff=TIFFClientOpen(image->filename,"rb",(thandle_t) &client_data,TIFFReadBlob,
-                     TIFFWriteBlob,TIFFSeekBlob,TIFFCloseBlob,
-                     TIFFGetBlobSize,TIFFMapBlob,TIFFUnmapBlob);
+                      TIFFWriteBlob,TIFFSeekBlob,TIFFCloseBlob,
+                      TIFFGetBlobSize,TIFFMapBlob,TIFFUnmapBlob);
   if (tiff == (TIFF *) NULL)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
 
@@ -1726,9 +1867,8 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
         status=TIFFReadDirectory(tiff);
         if (status == False)
           {
-            TIFFClose(tiff);
-            ThrowReaderException(CorruptImageError,UnableToReadSubImageData,
-                                 image);
+            ThrowTIFFReaderException(CorruptImageError,UnableToReadSubImageData,
+                                     image);
           }
       }
   do
@@ -1757,15 +1897,14 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
       status &= (TIFFGetFieldDefaulted(tiff,TIFFTAG_FILLORDER,&fill_order) == 1);
       if (status == 0)
         {
-          TIFFClose(tiff);
           /*
             Promote TIFF warnings to errors for these critical tags.
           */
           if ((exception->severity > WarningException) &&
               (exception->severity < ErrorException))
             exception->severity += (ErrorException - WarningException);
-          ThrowReaderException(CorruptImageError,ImproperImageHeader,
-                               image);
+          ThrowTIFFReaderException(CorruptImageError,ImproperImageHeader,
+                                   image);
         }
       if (TIFFGetField(tiff,TIFFTAG_ORIENTATION,&orientation) == 1)
         image->orientation=(OrientationType) orientation;
@@ -1798,7 +1937,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             {
               double
                 value;
-              
+
               if (TIFFGetField(tiff,TIFFTAG_SMINSAMPLEVALUE,&value) == 1)
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                       "Special min sample value: %g", value);
@@ -1827,14 +1966,13 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
 #if 1
           image->colorspace=LABColorspace;
 #else
-          TIFFClose(tiff);
-          ThrowReaderException(CoderError,UnableToReadCIELABImages,image);
+          ThrowTIFFReaderException(CoderError,UnableToReadCIELABImages,image);
 #endif
         }
       if (photometric == PHOTOMETRIC_SEPARATED)
         image->colorspace=CMYKColorspace;
       if (planar_config == PLANARCONFIG_SEPARATE)
-       image->interlace=PlaneInterlace;
+        image->interlace=PlaneInterlace;
       (void) TIFFGetFieldDefaulted(tiff,TIFFTAG_RESOLUTIONUNIT,&units);
       x_resolution=image->x_resolution;
       y_resolution=image->y_resolution;
@@ -1892,7 +2030,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "Photoshop embedded profile with length %lu bytes",
                                   (unsigned long) length);
-            (void) ReadNewsProfile(text,(long) length,image,TIFFTAG_PHOTOSHOP);
+            (void) ReadNewsProfile((unsigned char *) text,(long) length,image,TIFFTAG_PHOTOSHOP);
           }
 #elif defined(TIFFTAG_RICHTIFFIPTC)
         /* IPTC TAG from RichTIFF specifications */
@@ -1902,7 +2040,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
               TIFFSwabArrayOfLong((uint32 *) text,length);
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "IPTC Newsphoto embedded profile with length %u bytes",length);
-            ReadNewsProfile(text,length,image,TIFFTAG_RICHTIFFIPTC);
+            ReadNewsProfile((unsigned char *) text,length,image,TIFFTAG_RICHTIFFIPTC);
           }
 #endif
         /*
@@ -1920,22 +2058,54 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
 #endif
       }
       /*
-        Allocate memory for the image and pixel buffer.
+        Map from TIFF compression tags to GraphicsMagick equivalents
+        as well as estimate a maximum compression ratio (for
+        validating scanline/strip/tile allocation requests).
       */
       switch (compress_tag)
         {
-        case COMPRESSION_NONE: image->compression=NoCompression; break;
-        case COMPRESSION_CCITTFAX3: image->compression=FaxCompression; break;
-        case COMPRESSION_CCITTFAX4: image->compression=Group4Compression; break;
-        case COMPRESSION_JPEG: image->compression=JPEGCompression; break;
-        case COMPRESSION_OJPEG: image->compression=JPEGCompression; break;
-        case COMPRESSION_LZW: image->compression=LZWCompression; break;
+        case COMPRESSION_NONE:
+          image->compression=NoCompression;
+          break;
+        case COMPRESSION_CCITTFAX3:
+          image->compression=FaxCompression;
+          break;
+        case COMPRESSION_CCITTFAX4:
+          image->compression=Group4Compression;
+          break;
+        case COMPRESSION_JPEG:
+          image->compression=JPEGCompression;
+          break;
+        case COMPRESSION_OJPEG:
+          image->compression=JPEGCompression;
+          break;
+        case COMPRESSION_LZW:
+          image->compression=LZWCompression;
+          break;
 #if defined(COMPRESSION_LZMA)
-       case COMPRESSION_LZMA: image->compression=LZMACompression; break;
+        case COMPRESSION_LZMA:
+          image->compression=LZMACompression;
+          break;
 #endif /* defined(COMPRESSION_LZMA) */
-        case COMPRESSION_DEFLATE: image->compression=ZipCompression; break;
-        case COMPRESSION_ADOBE_DEFLATE: image->compression=ZipCompression; break;
-        default: image->compression=RLECompression; break;
+        case COMPRESSION_DEFLATE:
+          image->compression=ZipCompression;
+          break;
+        case COMPRESSION_ADOBE_DEFLATE:
+          image->compression=ZipCompression;
+          break;
+#if defined(COMPRESSION_ZSTD)
+        case COMPRESSION_ZSTD:
+          image->compression=ZSTDCompression;
+          break;
+#endif /* defined(COMPRESSION_ZSTD) */
+#if defined(COMPRESSION_WEBP)
+        case COMPRESSION_WEBP:
+          image->compression=WebPCompression;
+          break;
+#endif /* if defined(COMPRESSION_WEBP) */
+        default:
+          image->compression=NoCompression;
+          break;
         }
       image->columns=width;
       image->rows=height;
@@ -1963,14 +2133,15 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
               else if (sample_info[0] == EXTRASAMPLE_ASSOCALPHA)
                 alpha_type=AssociatedAlpha;
             }
-          for (sample_index=0 ; sample_index < extra_samples; sample_index++)
-            {
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                    "Extra sample %u contains %s alpha",sample_index+1,
-                                    ((sample_info[sample_index] == EXTRASAMPLE_ASSOCALPHA) ? "ASSOCIATED" :
-                                     (sample_info[sample_index] == EXTRASAMPLE_UNASSALPHA) ? "UNASSOCIATED" :
-                                     "UNSPECIFIED"));
-            }
+          if (image->logging)
+            for (sample_index=0 ; sample_index < extra_samples; sample_index++)
+              {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Extra sample %u contains %s alpha",sample_index+1,
+                                      ((sample_info[sample_index] == EXTRASAMPLE_ASSOCALPHA) ? "ASSOCIATED" :
+                                       (sample_info[sample_index] == EXTRASAMPLE_UNASSALPHA) ? "UNASSOCIATED" :
+                                       "UNSPECIFIED"));
+              }
         }
       /*
         Handle RGBA images which are improperly marked.
@@ -2031,11 +2202,11 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
       if (units == RESUNIT_CENTIMETER)
         image->units=PixelsPerCentimeterResolution;
       {
-       uint16
-         pagenumber;
+        uint16
+          pagenumber;
 
-       pagenumber=(unsigned short) image->scene;
-       if (TIFFGetFieldDefaulted(tiff,TIFFTAG_PAGENUMBER,&pagenumber,&pages) == 1)
+        pagenumber=(unsigned short) image->scene;
+        if (TIFFGetFieldDefaulted(tiff,TIFFTAG_PAGENUMBER,&pagenumber,&pages) == 1)
           image->scene=pagenumber;
       }
 
@@ -2074,10 +2245,10 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
       */
       if (TIFFGetField(tiff,TIFFTAG_OPIIMAGEID,&count,&text) == 1)
         CopySizedFieldToAttribute("imageid",count,text);
-      
+
       if (TIFFGetField(tiff,33423,&count,&text) == 1)
         CopySizedFieldToAttribute("kodak-33423",count,text);
-      
+
       if (TIFFGetField(tiff,36867,&count,&text) == 1)
         CopySizedFieldToAttribute("kodak-36867",count,text);
 
@@ -2087,8 +2258,8 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
            ((image_info->type == PaletteType) ||
             (image_info->type == PaletteMatteType)) &&
             (MaxColormapSize > MaxValueGivenBits(bits_per_sample))
-          )
-         )
+           )
+          )
         {
           /*
             Palette image
@@ -2099,8 +2270,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             }
           else
             {
-              TIFFClose(tiff);
-              ThrowReaderException(CoderError,ColormapTooLarge,image);
+              ThrowTIFFReaderException(CoderError,ColormapTooLarge,image);
             }
         }
 
@@ -2119,8 +2289,28 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
       if (CheckImagePixelLimits(image, exception) != MagickPass)
         {
-          TIFFClose(tiff);
-          ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+          ThrowTIFFReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+        }
+
+      /*
+        Check if the bits-per-sample value is supported by the
+        implementation before proceeding.
+
+        Currently we support a range of 1-32, and 64 bits if the
+        samples are float.
+      */
+      if (!((sample_format == SAMPLEFORMAT_IEEEFP && bits_per_sample == 64) ||
+            ((bits_per_sample > 0) && (bits_per_sample <= 32))))
+        {
+          ThrowTIFFReaderException(CoderError,UnsupportedBitsPerSample,image);
+        }
+
+      /*
+        Check for excessive samples per pixel or excessive extra samples.
+      */
+      if ((samples_per_pixel > 8U) || (extra_samples > 8U))
+        {
+          ThrowTIFFReaderException(CoderError,UnsupportedSamplesPerPixel,image);
         }
 
       /*
@@ -2135,7 +2325,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
         if ((samples_per_pixel > 1) &&
             (compress_tag == COMPRESSION_JPEG) &&
-           (photometric == PHOTOMETRIC_YCBCR))
+            (photometric == PHOTOMETRIC_YCBCR))
           {
             /* Following hack avoids the error message "Application
                transferred too many scanlines. (JPEGLib)." caused by
@@ -2145,7 +2335,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                     "Resetting photometric from %s to %s for JPEG RGB",
                                     PhotometricTagToString(photometric),
-                                   PhotometricTagToString(PHOTOMETRIC_RGB));
+                                    PhotometricTagToString(PHOTOMETRIC_RGB));
             (void) TIFFSetField( tiff, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB );
             photometric=PHOTOMETRIC_RGB;
           }
@@ -2190,8 +2380,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             /*
               QuantumTransferMode reported an error
              */
-            TIFFClose(tiff);
-            ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+            ThrowTIFFReaderException(CorruptImageError,ImproperImageHeader,image);
           }
       }
 
@@ -2251,10 +2440,26 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                                     "Using scanline %s read method with %u bits per sample",
                                     PhotometricTagToString(photometric),bits_per_sample);
             /*
+              Prepare for separate/contiguous retrieval.
+            */
+            max_sample=1;
+            if (planar_config == PLANARCONFIG_SEPARATE)
+              {
+                if (QuantumTransferMode(image,photometric,compress_tag,
+                                        sample_format,samples_per_pixel,
+                                        PLANARCONFIG_CONTIG,0,
+                                        &quantum_type,&quantum_samples,
+                                        exception)
+                    != MagickPass)
+                  ThrowTIFFReaderException(CorruptImageError,
+                                           ImproperImageHeader,image);
+                max_sample=quantum_samples;
+              }
+            /*
               Allocate memory for one scanline.
             */
             scanline_size=TIFFScanlineSize(tiff);
-            if (0 == scanline_size)
+            if (scanline_size <= 0)
               {
                 status=MagickFail;
                 break;
@@ -2266,44 +2471,43 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
             if (logging)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                    "Allocating scanline buffer of %lu bytes",
-                                    (unsigned long) scanline_size);
+                                    "Request to allocate scanline buffer of %"
+                                    MAGICK_SIZE_T_F "u bytes",
+                                    (MAGICK_SIZE_T) scanline_size);
+
+            /*
+              Rationalize memory request based on file size
+            */
+            if (scanline_size > file_size*max_compress_ratio)
+              {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Unreasonable allocation size "
+                                      "(ratio of alloc to file size %g)",
+                                      (double) scanline_size/file_size);
+                ThrowTIFFReaderException(CorruptImageError,InsufficientImageDataInFile,
+                                         image);
+              }
 
             scanline=MagickAllocateMemory(unsigned char *,(size_t) scanline_size);
             if (scanline == (unsigned char *) NULL)
               {
-                TIFFClose(tiff);
-                ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-                                     image);
+                ThrowTIFFReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                         image);
               }
-            /*
-              Prepare for separate/contiguous retrieval.
-            */
-            max_sample=1;
-            if (planar_config == PLANARCONFIG_SEPARATE)
+            memset(scanline,0,(size_t) scanline_size);
+            for (sample=0; sample < max_sample; sample++)
               {
-                if (QuantumTransferMode(image,photometric,compress_tag,
-                                        sample_format,samples_per_pixel,
-                                        PLANARCONFIG_CONTIG,0,
-                                        &quantum_type,&quantum_samples,
-                                        exception)
-                    == MagickPass)
-                  max_sample=quantum_samples;
-              }
-           for (sample=0; sample < max_sample; sample++)
-             {
-               for (y=0; y < image->rows; y++)
-                 {
-                   if (sample == 0)
-                     q=SetImagePixels(image,0,y,image->columns,1);
-                   else
-                     q=GetImagePixels(image,0,y,image->columns,1);
-                   if (q == (PixelPacket *) NULL)
-                     {
-                       CopyException(exception,&image->exception);
-                       status=MagickFail;
-                       break;
-                     }
+                for (y=0; y < image->rows; y++)
+                  {
+                    if (sample == 0)
+                      q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
+                    else
+                      q=GetImagePixelsEx(image,0,y,image->columns,1,exception);
+                    if (q == (PixelPacket *) NULL)
+                      {
+                        status=MagickFail;
+                        break;
+                      }
                     /*
                       Obtain a scanline
                     */
@@ -2327,7 +2531,6 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                                             exception)
                         == MagickFail)
                       {
-                        CopyException(exception,&image->exception);
                         status=MagickFail;
                         break;
                       }
@@ -2348,29 +2551,28 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                         status=MagickFail;
                         break;
                       }
-                   /*
-                     Disassociate alpha from pixels if necessary.
-                   */
-                   if ((image->matte) && (alpha_type == AssociatedAlpha) &&
-                       (sample == (max_sample-1)))
-                     DisassociateAlphaRegion(image);
-                   /*
-                     Save our updates.
-                   */
-                   if (!SyncImagePixels(image))
-                     {
-                       CopyException(exception,&image->exception);
-                       status=MagickFail;
-                       break;
-                     }
-                   if (image->previous == (Image *) NULL)
-                     if (QuantumTick(y+sample*image->rows,image->rows*max_sample))
-                       if (!MagickMonitorFormatted(y+sample*image->rows,
-                                                   image->rows*max_sample,exception,
-                                                   LoadImageText,image->filename,
-                                                   image->columns,image->rows))
-                         break;
-                 }
+                    /*
+                      Disassociate alpha from pixels if necessary.
+                    */
+                    if ((image->matte) && (alpha_type == AssociatedAlpha) &&
+                        (sample == (max_sample-1)))
+                      DisassociateAlphaRegion(image);
+                    /*
+                      Save our updates.
+                    */
+                    if (!SyncImagePixelsEx(image,exception))
+                      {
+                        status=MagickFail;
+                        break;
+                      }
+                    if (image->previous == (Image *) NULL)
+                      if (QuantumTick(y+sample*image->rows,image->rows*max_sample))
+                        if (!MagickMonitorFormatted(y+sample*image->rows,
+                                                    image->rows*max_sample,exception,
+                                                    LoadImageText,image->filename,
+                                                    image->columns,image->rows))
+                          break;
+                  }
               }
             MagickFreeMemory(scanline);
             break;
@@ -2404,18 +2606,43 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             QuantumType
               quantum_type;
 
+            ImportPixelAreaInfo
+              import_info;
+
             if (logging)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                     "Using stripped read method with %u bits per sample",
                                     bits_per_sample);
+            /*
+              Prepare for separate/contiguous retrieval.
+            */
+            max_sample=1;
+            if (planar_config == PLANARCONFIG_SEPARATE)
+              {
+                if (QuantumTransferMode(image,photometric,compress_tag,
+                                        sample_format,
+                                        samples_per_pixel,PLANARCONFIG_CONTIG,
+                                        0,&quantum_type,&quantum_samples,
+                                        exception)
+                    != MagickPass)
+                  ThrowTIFFReaderException(CorruptImageError,
+                                           ImproperImageHeader,image);
+                max_sample=quantum_samples;
+              }
+
             /* pixels_per_strip=rows_per_strip*image->columns; */
             p=0;
             strip_size=0;
             strip_id=0;
-            /*
+             /*
               Allocate memory for one strip.
             */
             strip_size_max=TIFFStripSize(tiff);
+            if (strip_size_max <= 0)
+              {
+                status=MagickFail;
+                break;
+              }
             /*
               Scale up to size of 32-bit word.
             */
@@ -2424,33 +2651,32 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                     "Maximum strip size %" MAGICK_SIZE_T_F "u",
                                     (MAGICK_SSIZE_T) strip_size_max);
-            if (0 == strip_size_max)
+            if (strip_size_max <= 0)
               {
                 status=MagickFail;
                 break;
               }
 
-            strip=MagickAllocateMemory(unsigned char *,(size_t) strip_size_max);
-            if (strip == (unsigned char *) NULL)
-              {
-                TIFFClose(tiff);
-                ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-                                     image);
-              }
             /*
-              Prepare for separate/contiguous retrieval.
+              Rationalize memory request based on file size
             */
-            max_sample=1;
-            if (planar_config == PLANARCONFIG_SEPARATE)
+            if (strip_size_max > file_size*max_compress_ratio)
               {
-                if (QuantumTransferMode(image,photometric,compress_tag,
-                                        sample_format,
-                                        samples_per_pixel,PLANARCONFIG_CONTIG,
-                                        0,&quantum_type,&quantum_samples,
-                                        exception)
-                    == MagickPass)
-                  max_sample=quantum_samples;
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Unreasonable allocation size "
+                                      "(ratio of alloc to file size %g)",
+                                      (double) strip_size_max/file_size);
+                ThrowTIFFReaderException(CorruptImageError,InsufficientImageDataInFile,
+                                         image);
               }
+
+           strip=MagickAllocateMemory(unsigned char *,(size_t) strip_size_max);
+            if (strip == (unsigned char *) NULL)
+              {
+                ThrowTIFFReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                         image);
+              }
+            memset(strip,0,(size_t) strip_size_max);
             /*
               Compute per-row stride.
             */
@@ -2471,7 +2697,6 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                                         exception)
                     == MagickFail)
                   {
-                    CopyException(exception,&image->exception);
                     status=MagickFail;
                     break;
                   }
@@ -2481,12 +2706,11 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       Access Magick pixels.
                     */
                     if (sample == 0)
-                      q=SetImagePixels(image,0,y,image->columns,1);
+                      q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
                     else
-                      q=GetImagePixels(image,0,y,image->columns,1);
+                      q=GetImagePixelsEx(image,0,y,image->columns,1,exception);
                     if (q == (PixelPacket *) NULL)
                       {
-                        CopyException(exception,&image->exception);
                         status=MagickFail;
                         break;
                       }
@@ -2522,7 +2746,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       Import strip row into image.
                     */
                     if (ImportImagePixelArea(image,quantum_type,bits_per_sample,p,
-                                             &import_options,0) == MagickFail)
+                                             &import_options,&import_info) == MagickFail)
                       {
                         CopyException(exception,&image->exception);
                         status=MagickFail;
@@ -2537,9 +2761,8 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                     /*
                       Save our updates.
                     */
-                    if (!SyncImagePixels(image))
+                    if (!SyncImagePixelsEx(image,exception))
                       {
-                        CopyException(exception,&image->exception);
                         status=MagickFail;
                         break;
                       }
@@ -2553,7 +2776,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       if (QuantumTick(y+image->rows*sample,image->rows*max_sample))
                         if (!MagickMonitorFormatted(y+image->rows*sample,image->rows*max_sample,exception,
                                                     LoadImageText,image->filename,
-                                                   image->columns,image->rows))
+                                                    image->columns,image->rows))
                           {
                             status=MagickFail;
                             break;
@@ -2590,198 +2813,218 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             QuantumType
               quantum_type;
 
-            unsigned long
+            size_t
               tile_total_pixels;
-        
+
             if (logging)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                     "Using tiled %s read method with %u bits per sample",
                                     PhotometricTagToString(photometric), bits_per_sample);
             /*
+              Prepare for separate/contiguous retrieval.
+            */
+            max_sample=1;
+            if (planar_config == PLANARCONFIG_SEPARATE)
+              {
+                if (QuantumTransferMode(image,photometric,compress_tag,
+                                        sample_format,samples_per_pixel,
+                                        PLANARCONFIG_CONTIG,0,&quantum_type,
+                                        &quantum_samples,
+                                        exception)
+                    != MagickPass)
+                  ThrowTIFFReaderException(CorruptImageError,
+                                           ImproperImageHeader,image);
+                max_sample=quantum_samples;
+              }
+            /*
               Obtain tile geometry
             */
             if(!(TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&tile_columns) == 1) ||
                !(TIFFGetField(tiff,TIFFTAG_TILELENGTH,&tile_rows) == 1))
               {
-                TIFFClose(tiff);
-                ThrowReaderException(CoderError,ImageIsNotTiled,image);
+                ThrowTIFFReaderException(CoderError,ImageIsNotTiled,image);
               }
             /*
               Obtain the maximum number of bytes required to contain a tile.
             */
             tile_size_max=TIFFTileSize(tiff);
+            if (tile_size_max <= 0)
+              {
+                ThrowTIFFReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                         image);
+              }
             /*
               Scale up to size of 32-bit word.
             */
             tile_size_max=RoundUpToAlignment(tile_size_max,sizeof(magick_int32_t));
             if (0 == tile_size_max)
               {
-                status=MagickFail;
-                break;
+                ThrowTIFFReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                         image);
               }
             /*
               Compute the total number of pixels in one tile
             */
-            tile_total_pixels=tile_columns*tile_rows;
+            tile_total_pixels=MagickArraySize(tile_columns,tile_rows);
             if (logging)
               {
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                      "TIFF tile geometry %ux%u, %lu pixels",
+                                      "TIFF tile geometry %ux%u, "
+                                      "%" MAGICK_SIZE_T_F "u pixels"
+                                      " (%" MAGICK_SIZE_T_F  "u bytes max)",
                                       (unsigned int)tile_columns,
                                       (unsigned int)tile_rows,
-                                      tile_total_pixels);
+                                      (MAGICK_SIZE_T) tile_total_pixels,
+                                      (MAGICK_SIZE_T) tile_size_max);
               }
+
             /*
-              Allocate tile buffer
+              Rationalize memory request based on file size
             */
-            tile=MagickAllocateMemory(unsigned char *, (size_t) tile_size_max);
-            if (tile == (unsigned char *) NULL)
+            if (tile_size_max > file_size*max_compress_ratio)
               {
-                TIFFClose(tiff);
-                ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-                                     image);
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Unreasonable tile allocation size "
+                                      "(ratio of alloc to file size %g)",
+                                      (double) tile_size_max/file_size);
+                ThrowTIFFReaderException(CorruptImageError,InsufficientImageDataInFile,
+                                         image);
               }
+
             /*
-              Prepare for separate/contiguous retrieval.
+              Allocate tile buffer
             */
-            max_sample=1;
-            if (planar_config == PLANARCONFIG_SEPARATE)
+            tile=MagickAllocateMemory(unsigned char *, (size_t) tile_size_max);
+            if (tile == (unsigned char *) NULL)
               {
-                if (QuantumTransferMode(image,photometric,compress_tag,
-                                        sample_format,samples_per_pixel,
-                                        PLANARCONFIG_CONTIG,0,&quantum_type,
-                                        &quantum_samples,
-                                        exception)
-                    == MagickPass)
-                  max_sample=quantum_samples;
+                ThrowTIFFReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                         image);
               }
+            memset(tile,0,(size_t) tile_size_max);
             /*
               Compute per-row stride.
             */
             stride=TIFFTileRowSize(tiff);
 
-           /*
-             Process each plane.
-           */
-           for (sample=0; sample < max_sample; sample++)
-             {
-               /*
-                 Determine quantum parse method.
-               */
-               if (QuantumTransferMode(image,photometric,compress_tag,
+            /*
+              Process each plane.
+            */
+            for (sample=0; sample < max_sample; sample++)
+              {
+                /*
+                  Determine quantum parse method.
+                */
+                if (QuantumTransferMode(image,photometric,compress_tag,
                                         sample_format,samples_per_pixel,
                                         planar_config,sample,&quantum_type,
                                         &quantum_samples,exception)
-                   == MagickFail)
-                 {
-                   CopyException(exception,&image->exception);
-                   status=MagickFail;
-                   break;
-                 }
-               for (y=0; y < image->rows; y+=tile_rows)
-                 {
-                   for (x=0; x < image->columns; x+=tile_columns)
-                     {
-                       long
-                         tile_set_columns,
-                         tile_set_rows;
-                       
-                       unsigned char
-                         *p;
-                       
-                       register long
-                         yy;
-                       
-                       /*
-                         Compute image region corresponding to tile.
-                       */
-                       if (x+tile_columns > image->columns)
-                         tile_set_columns=(tile_columns-(x+tile_columns-image->columns));
-                       else
-                         tile_set_columns=tile_columns;
-                       if (y+tile_rows > image->rows)
-                         tile_set_rows=(tile_rows-(y+tile_rows-image->rows));
-                       else
-                         tile_set_rows=tile_rows;
-                       
-                       /*
-                         Read a tile.
-                       */
-                       if ((tile_size=TIFFReadTile(tiff,tile,x,y,0,sample)) == -1)
-                         {
-                           status=MagickFail;
-                           break;
-                         }
+                    == MagickFail)
+                  {
+                    status=MagickFail;
+                    break;
+                  }
+                for (y=0; y < image->rows; y+=tile_rows)
+                  {
+                    for (x=0; x < image->columns; x+=tile_columns)
+                      {
+                        long
+                          tile_set_columns,
+                          tile_set_rows;
+
+                        unsigned char
+                          *p;
+
+                        register long
+                          yy;
+
+                        /*
+                          Compute image region corresponding to tile.
+                        */
+                        if (x+tile_columns > image->columns)
+                          tile_set_columns=(tile_columns-(x+tile_columns-image->columns));
+                        else
+                          tile_set_columns=tile_columns;
+                        if (y+tile_rows > image->rows)
+                          tile_set_rows=(tile_rows-(y+tile_rows-image->rows));
+                        else
+                          tile_set_rows=tile_rows;
+
+                        /*
+                          Read a tile.
+                        */
+                        if ((tile_size=TIFFReadTile(tiff,tile,x,y,0,sample)) == -1)
+                          {
+                            status=MagickFail;
+                            break;
+                          }
 #if !defined(WORDS_BIGENDIAN)
-                       if (24 == bits_per_sample)
-                         SwabDataToBigEndian(bits_per_sample,tile,tile_size);
+                        if (24 == bits_per_sample)
+                          SwabDataToBigEndian(bits_per_sample,tile,tile_size);
 #endif
-                       p=tile;
-                       for (yy=y; yy < (long) y+tile_set_rows; yy++)
-                         {
-                           /*
-                             Obtain pixel region corresponding to tile row.
-                           */
-                           if (sample == 0)
-                             q=SetImagePixels(image,x,yy,tile_set_columns,1);
-                           else
-                             q=GetImagePixels(image,x,yy,tile_set_columns,1);
-                           if (q == (PixelPacket *) NULL)
-                             {
-                               CopyException(exception,&image->exception);
-                               status=MagickFail;
-                               break;
-                             }
-                           /*
-                             Compact tile row to only contain raster data.
-                           */
-                           if ((samples_per_pixel > quantum_samples) &&
-                               (planar_config == PLANARCONFIG_CONTIG))
-                             CompactSamples(tile_set_columns, bits_per_sample,
-                                            samples_per_pixel, quantum_samples, p);
-                           /*
-                             Import tile row
-                           */
-                           if (ImportImagePixelArea(image,quantum_type,
-                                                    bits_per_sample,p,
-                                                    &import_options,0)
-                               == MagickFail)
-                             {
-                               CopyException(exception,&image->exception);
-                               status=MagickFail;
-                               break;
-                             }
-                           /*
-                             Disassociate alpha from pixels if necessary.
-                           */
-                           if ((image->matte) && (alpha_type == AssociatedAlpha)
-                               && (sample == (max_sample-1)))
-                             DisassociateAlphaRegion(image);
-                           /*
-                             Save our updates.
-                           */
-                           if (!SyncImagePixels(image))
-                             {
-                               CopyException(exception,&image->exception);
-                               status=MagickFail;
-                               break;
-                             }
-                           p += stride;
-                         }
-                       if (status == MagickFail)
-                         break;
+                        p=tile;
+                        for (yy=y; yy < (long) y+tile_set_rows; yy++)
+                          {
+                            /*
+                              Obtain pixel region corresponding to tile row.
+                            */
+                            if (sample == 0)
+                              q=SetImagePixelsEx(image,x,yy,tile_set_columns,1,exception);
+                            else
+                              q=GetImagePixelsEx(image,x,yy,tile_set_columns,1,exception);
+                            if (q == (PixelPacket *) NULL)
+                              {
+                                status=MagickFail;
+                                break;
+                              }
+                            /*
+                              Compact tile row to only contain raster data.
+                            */
+                            if ((samples_per_pixel > quantum_samples) &&
+                                (planar_config == PLANARCONFIG_CONTIG))
+                              CompactSamples(tile_set_columns, bits_per_sample,
+                                             samples_per_pixel, quantum_samples, p);
+                            /*
+                              Import tile row
+                            */
+                            if (ImportImagePixelArea(image,quantum_type,
+                                                     bits_per_sample,p,
+                                                     &import_options,0)
+                                == MagickFail)
+                              {
+                                CopyException(exception,&image->exception);
+                                status=MagickFail;
+                                break;
+                              }
+                            /*
+                              Disassociate alpha from pixels if necessary.
+                            */
+                            if ((image->matte) && (alpha_type == AssociatedAlpha)
+                                && (sample == (max_sample-1)))
+                              DisassociateAlphaRegion(image);
+                            /*
+                              Save our updates.
+                            */
+                            if (!SyncImagePixelsEx(image,exception))
+                              {
+                                status=MagickFail;
+                                break;
+                              }
+                            p += stride;
+                          }
+                        if (status == MagickFail)
+                          break;
                       }
                     if (status == MagickFail)
                       break;
-                   
+
                     if (image->previous == (Image *) NULL)
                       if (QuantumTick((y+sample*image->rows)/tile_rows,
-                                     (image->rows*max_sample)/tile_rows))
+                                      (image->rows*max_sample)/tile_rows))
                         if (!MagickMonitorFormatted((y+sample*image->rows)/tile_rows,
-                                                   (image->rows*max_sample)/tile_rows,
-                                                   exception,
+                                                    (image->rows*max_sample)/tile_rows,
+                                                    exception,
                                                     LoadImageText,image->filename,
-                                                   image->columns,image->rows))
+                                                    image->columns,image->rows))
                           {
                             status=MagickFail;
                             break;
@@ -2815,17 +3058,29 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             number_pixels=MagickArraySize(image->columns,rows_per_strip);
             if (0 == number_pixels)
               {
-                TIFFClose(tiff);
-                ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-                                     image);
+                ThrowTIFFReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                         image);
+              }
+            /*
+              Rationalize memory request based on file size
+            */
+            if ((magick_off_t) (number_pixels*sizeof(uint32)) >
+                file_size*max_compress_ratio)
+              {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Unreasonable allocation size "
+                                      "(ratio of alloc to file size %g)",
+                                      (double) (number_pixels*sizeof(uint32))/file_size);
+                ThrowTIFFReaderException(CorruptImageError,InsufficientImageDataInFile,
+                                         image);
               }
             strip_pixels=MagickAllocateArray(uint32 *,number_pixels,sizeof(uint32));
             if (strip_pixels == (uint32 *) NULL)
               {
-                TIFFClose(tiff);
-                ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-                                     image);
+                ThrowTIFFReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                         image);
               }
+            memset(strip_pixels,0,(size_t) number_pixels*sizeof(uint32));
             if (logging)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                     "Allocated %" MAGICK_SIZE_T_F "u bytes for RGBA strip",
@@ -2837,10 +3092,9 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             p=0;
             for (y=0; y < image->rows; y++)
               {
-                q=SetImagePixels(image,0,y,image->columns,1);
+                q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
                 if (q == (PixelPacket *) NULL)
                   {
-                    CopyException(exception,&image->exception);
                     status=MagickFail;
                     break;
                   }
@@ -2869,10 +3123,9 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   Disassociate alpha from pixels if necessary.
                 */
                 if ((image->matte) && (alpha_type == AssociatedAlpha))
-                  DisassociateAlphaRegion(image);                
-                if (!SyncImagePixels(image))
+                  DisassociateAlphaRegion(image);
+                if (!SyncImagePixelsEx(image,exception))
                   {
-                    CopyException(exception,&image->exception);
                     status=MagickFail;
                     break;
                   }
@@ -2880,7 +3133,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   if (QuantumTick(y,image->rows))
                     if (!MagickMonitorFormatted(y,image->rows,exception,
                                                 LoadImageText,image->filename,
-                                               image->columns,image->rows))
+                                                image->columns,image->rows))
                       {
                         status=MagickFail;
                         break;
@@ -2896,15 +3149,18 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             */
             register uint32
               *p;
-        
+
             uint32
               *tile_pixels,
               tile_columns,
               tile_rows;
-        
+
+            tsize_t
+              tile_size_max;
+
             size_t
               tile_total_pixels;
-        
+
             if (logging)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                     "Using RGB tiled read method with %u bits per sample",
@@ -2915,8 +3171,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             if (!(TIFFGetField(tiff,TIFFTAG_TILEWIDTH,&tile_columns) == 1) ||
                 !(TIFFGetField(tiff,TIFFTAG_TILELENGTH,&tile_rows) == 1))
               {
-                TIFFClose(tiff);
-                ThrowReaderException(CoderError,ImageIsNotTiled,image);
+                ThrowTIFFReaderException(CoderError,ImageIsNotTiled,image);
               }
             tile_total_pixels=MagickArraySize(tile_columns,tile_rows);
             if (logging)
@@ -2929,15 +3184,35 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                                       (MAGICK_SIZE_T) tile_total_pixels);
               }
             /*
+              Obtain the maximum number of bytes required to contain a tile.
+            */
+            tile_size_max=TIFFTileSize(tiff);
+            if (tile_size_max <= 0)
+              {
+                ThrowTIFFReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                         image);
+              }
+            /*
+              Rationalize memory request based on file size
+            */
+            if (tile_size_max > file_size*max_compress_ratio)
+              {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Unreasonable tile allocation size "
+                                      "(ratio of alloc to file size %g)",
+                                      (double) tile_size_max/file_size);
+                ThrowTIFFReaderException(CorruptImageError,InsufficientImageDataInFile,
+                                         image);
+              }
+            /*
               Allocate tile buffer
             */
             tile_pixels=MagickAllocateArray(uint32*,MagickArraySize(tile_columns,tile_rows),
                                                                     sizeof (uint32));
             if (tile_pixels == (uint32 *) NULL)
               {
-                TIFFClose(tiff);
-                ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-                                     image);
+                ThrowTIFFReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                         image);
               }
             for (y=0; y < image->rows; y+=tile_rows)
               {
@@ -2959,10 +3234,9 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 /*
                   Obtain a row of pixels
                 */
-                strip=SetImagePixels(image,0,y,image->columns,tile_rows_remaining);
+                strip=SetImagePixelsEx(image,0,y,image->columns,tile_rows_remaining,exception);
                 if (strip == (PixelPacket *) NULL)
                   {
-                    CopyException(exception,&image->exception);
                     status=MagickFail;
                     break;
                   }
@@ -3027,10 +3301,9 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   Disassociate alpha from pixels if necessary.
                 */
                 if ((image->matte) && (alpha_type == AssociatedAlpha))
-                  DisassociateAlphaRegion(image);                
-                if (!SyncImagePixels(image))
+                  DisassociateAlphaRegion(image);
+                if (!SyncImagePixelsEx(image,exception))
                   {
-                    CopyException(exception,&image->exception);
                     status=MagickFail;
                     break;
                   }
@@ -3038,7 +3311,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   if (QuantumTick(y,image->rows))
                     if (!MagickMonitorFormatted(y,image->rows,exception,
                                                 LoadImageText,image->filename,
-                                               image->columns,image->rows))
+                                                image->columns,image->rows))
                       {
                         status=MagickFail;
                         break;
@@ -3066,41 +3339,60 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             /*
               Convert TIFF image to DirectClass MIFF image.
             */
-            number_pixels=(size_t) image->columns*image->rows;
-            if ((image->columns == 0) ||
-                (number_pixels/image->columns != image->rows))
+            number_pixels=MagickArraySize(image->columns,image->rows);
+            if (number_pixels == 0)
               {
-                TIFFClose(tiff);
-                ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-                                     image);
+                ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,
+                               image->filename);
+                status=MagickFail;
+                break;
               }
-            pixels=MagickAllocateArray(uint32 *,
-                                       number_pixels+6*image->columns,
-                                       sizeof(uint32));
+
+            /*
+              TIFFReadRGBAImage reads a strip- or tile-based image
+              into memory, storing the result in the user supplied
+              raster.  The raster is assumed to be an array of width
+              times height 32-bit entries, where width must be less
+              than or equal to the width of the image (height may be
+              any non-zero size). If the raster dimensions are smaller
+              than the image, the image data is cropped to the raster
+              bounds.  If the raster height is greater than that of
+              the image, then the image data are placed in the lower
+              part of the raster.  (Note that the raster is assumed to
+              be organized such that the pixel at location (x,y) is
+              raster[y*width+x]; with the raster origin in the
+              lower-left hand corner.)
+
+              Please note that this allocation used to be
+              (number_pixels+6*image->columns)*sizeof(uint32) for
+              unknown reasons.
+            */
+            pixels=MagickAllocateArray(uint32 *,number_pixels,sizeof(uint32));
             if (pixels == (uint32 *) NULL)
               {
-                TIFFClose(tiff);
-                ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-                                     image);
+                ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,
+                               image->filename);
+                status=MagickFail;
+                break;
+
               }
             if (!TIFFReadRGBAImage(tiff,(uint32) image->columns,
                                    (uint32) image->rows,
-                                   pixels+image->columns,0))
+                                   pixels,0))
               {
                 MagickFreeMemory(pixels);
-                TIFFClose(tiff);
-                return ((Image *) NULL);
+                status=MagickFail;
+                break;
               }
             /*
               Convert image to DirectClass pixel packets.
             */
-            p=pixels+number_pixels+image->columns-1;
+            p=pixels+number_pixels-1;
             for (y=0; y < image->rows; y++)
               {
-                q=SetImagePixels(image,0,y,image->columns,1);
+                q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
                 if (q == (PixelPacket *) NULL)
                   {
-                    CopyException(exception,&image->exception);
                     status=MagickFail;
                     break;
                   }
@@ -3129,9 +3421,8 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 */
                 if ((image->matte) && (alpha_type == AssociatedAlpha))
                   DisassociateAlphaRegion(image);
-                if (!SyncImagePixels(image))
+                if (!SyncImagePixelsEx(image,exception))
                   {
-                    CopyException(exception,&image->exception);
                     status=MagickFail;
                     break;
                   }
@@ -3139,7 +3430,7 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   if (QuantumTick(y,image->rows))
                     if (!MagickMonitorFormatted(y,image->rows,exception,
                                                 LoadImageText,image->filename,
-                                               image->columns,image->rows))
+                                                image->columns,image->rows))
                       {
                         status=MagickFail;
                         break;
@@ -3185,10 +3476,10 @@ ReadTIFFImage(const ImageInfo *image_info,ExceptionInfo *exception)
               status=MagickMonitorFormatted(image->scene-1,image->scene,
                                             &image->exception,
                                             LoadImageText,image->filename,
-                                           image->columns,image->rows);
+                                            image->columns,image->rows);
             }
         }
-      
+
       if (status == MagickFail)
         break;
 
@@ -3518,7 +3809,7 @@ WriteGROUP4RAWImage(const ImageInfo *image_info,Image *image)
       TIFFClose(tiff);
       (void) LiberateTemporaryFile(temporary_filename);
       ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,
-                          image);
+                           image);
     }
   /*
     Open blob for output
@@ -3536,13 +3827,13 @@ WriteGROUP4RAWImage(const ImageInfo *image_info,Image *image)
     Compress runlength encoded to 2D Huffman pixels.
   */
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                       "Output 2D Huffman pixels.");
+                        "Output 2D Huffman pixels.");
   for (i=0; i < TIFFNumberOfStrips(tiff); i++)
   {
     count=TIFFReadRawStrip(tiff,(uint32) i,strip,strip_size);
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                         "Writing strip %u (%lu bytes) to blob ...",
-                         i,(unsigned long) count);
+                          "Writing strip %u (%lu bytes) to blob ...",
+                          i,(unsigned long) count);
     if ((toff_t) WriteBlob(image,count,strip) != count)
       status=MagickFail;
   }
@@ -3568,7 +3859,7 @@ WriteGROUP4RAWImage(const ImageInfo *image_info,Image *image)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  WritePTIFImage() writes an image in the pyrimid-encoded Tagged image file
+%  WritePTIFImage() writes an image in the pyramid-encoded Tagged image file
 %  format.
 %
 %  The format of the WritePTIFImage method is:
@@ -3602,6 +3893,12 @@ WritePTIFImage(const ImageInfo *image_info,Image *image)
   unsigned int
     status;
 
+  const char
+    *def;
+
+  RectangleInfo
+    min_geometry;
+
   /*
     Create pyramid-encoded TIFF image.
   */
@@ -3609,28 +3906,53 @@ WritePTIFImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  if (!(((def=AccessDefinition(image_info,"ptif","minimum-geometry")) != NULL) &&
+        (GetGeometry(def,&min_geometry.x,&min_geometry.y,&min_geometry.width,
+                     &min_geometry.height) & (WidthValue|HeightValue))))
+    {
+      /*
+        Minimum default subresolution frame is 32x32
+      */
+      min_geometry.height=32;
+      min_geometry.width=32;
+    }
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "PTIF minimum pyramid dimensions: %lux%lu",
+                          min_geometry.width, min_geometry.height);
   filter=TriangleFilter;
   if (image->is_monochrome)
     filter=PointFilter;
   pyramid_image=CloneImage(image,0,0,True,&image->exception);
   if (pyramid_image == (Image *) NULL)
     ThrowWriterException2(FileOpenError,image->exception.reason,image);
+  DestroyBlob(pyramid_image);
+  pyramid_image->blob=ReferenceBlob(image->blob);
   (void) SetImageAttribute(pyramid_image,"subfiletype","NONE");
-  do
+  while(1)
     {
+      if ((pyramid_image->columns/2 < min_geometry.width) ||
+          (pyramid_image->rows/2 < min_geometry.height))
+        break;
+
       pyramid_image->next=ResizeImage(image,pyramid_image->columns/2,
                                       pyramid_image->rows/2,filter,
                                       1.0,&image->exception);
       if (pyramid_image->next == (Image *) NULL)
-        ThrowWriterException2(FileOpenError,image->exception.reason,image);
+        {
+          DestroyImageList(pyramid_image);
+          ThrowWriterException2(FileOpenError,image->exception.reason,image);
+        }
+      DestroyBlob(pyramid_image->next);
+        pyramid_image->next->blob=ReferenceBlob(image->blob);
       if ((!image->is_monochrome) && (image->storage_class == PseudoClass))
         (void) MapImage(pyramid_image->next,image,False);
-      pyramid_image->next->x_resolution=pyramid_image->x_resolution/2;
-      pyramid_image->next->y_resolution=pyramid_image->y_resolution/2;
+      pyramid_image->next->x_resolution=pyramid_image->x_resolution/2.0;
+      pyramid_image->next->y_resolution=pyramid_image->y_resolution/2.0;
       (void) SetImageAttribute(pyramid_image->next,"subfiletype","REDUCEDIMAGE");
       pyramid_image->next->previous=pyramid_image;
       pyramid_image=pyramid_image->next;
-    } while ((pyramid_image->columns > 64) && (pyramid_image->rows > 64));
+    };
   while (pyramid_image->previous != (Image *) NULL)
     pyramid_image=pyramid_image->previous;
   /*
@@ -3683,9 +4005,9 @@ WritePTIFImage(const ImageInfo *image_info,Image *image)
 
 static void
 WriteNewsProfile(TIFF *tiff,
-                int profile_tag,
-                const unsigned char *profile_data,
-                const size_t profile_length)
+                 int profile_tag,
+                 const unsigned char *profile_data,
+                 const size_t profile_length)
 {
   unsigned char
     *profile=0;
@@ -3756,9 +4078,13 @@ WriteNewsProfile(TIFF *tiff,
   MagickFreeMemory(profile);
 }
 
-#if !defined(TIFFDefaultStripSize)
-#define TIFFDefaultStripSize(tiff,request)  ((8*1024)/TIFFScanlineSize(tiff))
-#endif
+#define ThrowTIFFWriterException(code_,reason_,image_) \
+{ \
+  if (tiff != (TIFF *) NULL)                  \
+    TIFFClose(tiff);                          \
+  ThrowWriterException(code_,reason_,image_); \
+}
+
 static MagickPassFail
 WriteTIFFImage(const ImageInfo *image_info,Image *image)
 {
@@ -3777,7 +4103,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
     i;
 
   TIFF
-    *tiff;
+    *tiff = (TIFF *) NULL;
 
   uint16
     bits_per_sample,
@@ -3823,6 +4149,9 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
     depth,
     scene;
 
+  size_t
+    image_list_length;
+
   /*
     Open TIFF file.
   */
@@ -3830,6 +4159,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   logging=IsEventLogging();
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == MagickFail)
@@ -3897,7 +4227,8 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
                       TIFFUnmapBlob);
   if (tiff == (TIFF *) NULL)
     {
-      /* CloseBlob(image); */
+      if (GetBlobIsOpen(image))
+        CloseBlob(image);
       return(MagickFail);
     }
   scene=0;
@@ -3950,7 +4281,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             if (logging)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                     "%s compression not supported.  "
-                                   "Compression request removed",
+                                    "Compression request removed",
                                     compression_name);
           }
       }
@@ -3984,7 +4315,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
         case JBIG1Compression:
           {
             compress_tag=COMPRESSION_JBIG;
-           fill_order=FILLORDER_LSB2MSB;
+            fill_order=FILLORDER_LSB2MSB;
             break;
           }
 #endif /* defined(COMPRESSION_JBIG) */
@@ -4015,6 +4346,20 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             compress_tag=COMPRESSION_ADOBE_DEFLATE;
             break;
           }
+#if defined(COMPRESSION_ZSTD)
+        case ZSTDCompression:
+          {
+            compress_tag=COMPRESSION_ZSTD;
+            break;
+          }
+#endif /* defined(COMPRESSION_ZSTD) */
+#if defined(COMPRESSION_WEBP)
+        case WebPCompression:
+          {
+            compress_tag=COMPRESSION_WEBP;
+            break;
+          }
+#endif /* defined(COMPRESSION_WEBP) */
         default:
           {
             compress_tag=COMPRESSION_NONE;
@@ -4045,7 +4390,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
 
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                             "Image characteristics: cmyk=%c, gray=%c, mono=%c,"
-                           " opaque=%c, palette=%c",
+                            " opaque=%c, palette=%c",
                             (characteristics.cmyk ? 'y' : 'n'),
                             (characteristics.grayscale ? 'y' : 'n'),
                             (characteristics.monochrome ? 'y' : 'n'),
@@ -4070,7 +4415,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
                   {
                     const char *
                       compress_type;
-                    
+
                     compress_type=CompressionTagToString(compress_tag);
                     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                           "Disabled image matte channel since "
@@ -4130,13 +4475,13 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
         MINISWHITE.  CMYK takes precedence over JPEG compression.
       */
       if ((compress_tag == COMPRESSION_JPEG) &&
-         (photometric == PHOTOMETRIC_PALETTE))
+          (photometric == PHOTOMETRIC_PALETTE))
         {
           photometric=PHOTOMETRIC_RGB;
           if (logging)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "Using RGB photometric due to request for"
-                                 " JPEG compression.");
+                                  " JPEG compression.");
         }
       else if (compress_tag == COMPRESSION_CCITTFAX3)
         {
@@ -4144,7 +4489,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
           if (logging)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "Using MINISWHITE photometric due to request"
-                                 " for Group3 FAX compression.");
+                                  " for Group3 FAX compression.");
         }
       else if (compress_tag == COMPRESSION_CCITTFAX4)
         {
@@ -4152,7 +4497,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
           if (logging)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "Using MINISWHITE photometric due to request"
-                                 " for Group4 FAX compression.");
+                                  " for Group4 FAX compression.");
         }
 #if defined(COMPRESSION_JBIG)
       else if (compress_tag == COMPRESSION_JBIG)
@@ -4161,9 +4506,19 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
           if (logging)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "Using MINISWHITE photometric due to request"
-                                 " for JBIG compression.");
+                                  " for JBIG compression.");
         }
 #endif /* defined(COMPRESSION_JBIG) */
+#if defined(COMPRESSION_WEBP)
+      else if (compress_tag == COMPRESSION_WEBP)
+        {
+          photometric=PHOTOMETRIC_RGB;
+          if (logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Using RGB photometric due to request for"
+                                  " WebP compression.");
+        }
+#endif /* defined(COMPRESSION_WEBP) */
 
       /*
         Allow user to override the photometric.
@@ -4237,15 +4592,15 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
       */
       if ((compress_tag == COMPRESSION_JPEG) &&
           ((photometric != PHOTOMETRIC_MINISWHITE) &&
-          (photometric != PHOTOMETRIC_MINISBLACK) &&
-          (photometric != PHOTOMETRIC_RGB) &&
+           (photometric != PHOTOMETRIC_MINISBLACK) &&
+           (photometric != PHOTOMETRIC_RGB) &&
            (photometric != PHOTOMETRIC_YCBCR)))
         {
           compress_tag=COMPRESSION_NONE;
           if (logging)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "Ignoring request for JPEG compression due "
-                                 "to incompatible photometric.");
+                                  "to incompatible photometric.");
         }
       else if ((compress_tag == COMPRESSION_CCITTFAX3) &&
                (photometric != PHOTOMETRIC_MINISWHITE))
@@ -4255,7 +4610,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
           if (logging)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "Ignoring request for Group3 FAX compression"
-                                 " due to incompatible photometric.");
+                                  " due to incompatible photometric.");
         }
       else if ((compress_tag == COMPRESSION_CCITTFAX4) &&
                (photometric != PHOTOMETRIC_MINISWHITE))
@@ -4265,7 +4620,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
           if (logging)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "Ignoring request for Group4 FAX compression"
-                                 " due to incompatible photometric.");
+                                  " due to incompatible photometric.");
         }
 #if defined(COMPRESSION_JBIG)
       else if ((compress_tag == COMPRESSION_JBIG) &&
@@ -4276,7 +4631,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
           if (logging)
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "Ignoring request for JBIG compression"
-                                 " due to incompatible photometric.");
+                                  " due to incompatible photometric.");
         }
 #endif /* defined(COMPRESSION_JBIG) */
 
@@ -4355,7 +4710,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             libtiff or libtiff can be extended?
 
             FIXME
-          */          
+          */
 #if defined(BITS_IN_JSAMPLE)
           depth=BITS_IN_JSAMPLE;
           bits_per_sample=BITS_IN_JSAMPLE;
@@ -4415,7 +4770,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
                 break;
               }
             }
-            
+
           (void) TIFFSetField(tiff,TIFFTAG_EXTRASAMPLES,extra_samples,
                               &sample_info);
         }
@@ -4479,12 +4834,12 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
                 /* Clamp maximum unsigned bits per sample to 32 bits */
                 if ((bits_per_sample < 1) ||
                     ((bits_per_sample > 32) && (bits_per_sample != 64)))
-                 bits_per_sample=old_value;
+                  bits_per_sample=old_value;
               }
             if ((logging) && (old_value != bits_per_sample))
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                     "User override (bits-per-sample): %u bits "
-                                   "per sample (was %u)",
+                                    "per sample (was %u)",
                                     (unsigned int) bits_per_sample, old_value);
           }
 
@@ -4499,7 +4854,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             if (logging)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                     "User override (samples-per-pixel): %u "
-                                   "samples per pixel (was %u)",
+                                    "samples per pixel (was %u)",
                                     (unsigned int) samples_per_pixel, old_value);
           }
       }
@@ -4509,35 +4864,35 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
       */
       planar_config=PLANARCONFIG_CONTIG;
       if (samples_per_pixel > 1)
-       {
-         switch (image->interlace)
-           {
-           case UndefinedInterlace:
-             break;
-           case NoInterlace:
-           case LineInterlace:
-           case PartitionInterlace:
-             planar_config=PLANARCONFIG_CONTIG;
-             break;
-           case PlaneInterlace:
-             planar_config=PLANARCONFIG_SEPARATE;
-             break;
-           }
-
-         switch (image_info->interlace)
-           {
-           case UndefinedInterlace:
-             break;
-           case NoInterlace:
-           case LineInterlace:
-           case PartitionInterlace:
-             planar_config=PLANARCONFIG_CONTIG;
-             break;
-           case PlaneInterlace:
-             planar_config=PLANARCONFIG_SEPARATE;
-             break;
-           }
-       }
+        {
+          switch (image->interlace)
+            {
+            case UndefinedInterlace:
+              break;
+            case NoInterlace:
+            case LineInterlace:
+            case PartitionInterlace:
+              planar_config=PLANARCONFIG_CONTIG;
+              break;
+            case PlaneInterlace:
+              planar_config=PLANARCONFIG_SEPARATE;
+              break;
+            }
+
+          switch (image_info->interlace)
+            {
+            case UndefinedInterlace:
+              break;
+            case NoInterlace:
+            case LineInterlace:
+            case PartitionInterlace:
+              planar_config=PLANARCONFIG_CONTIG;
+              break;
+            case PlaneInterlace:
+              planar_config=PLANARCONFIG_SEPARATE;
+              break;
+            }
+        }
 
       /*
         YCbCr encoding compresses much better than RGB.  Use YCbCr
@@ -4557,7 +4912,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
       if (logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "Using %s photometric, %u samples per pixel, "
-                             "%u bits per sample, format %s",
+                              "%u bits per sample, format %s",
                               PhotometricTagToString(photometric),
                               (unsigned int) samples_per_pixel,
                               (unsigned int) bits_per_sample,
@@ -4584,10 +4939,10 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
       (void) TIFFSetField(tiff,TIFFTAG_SAMPLEFORMAT,sample_format);
       (void) TIFFSetField(tiff,TIFFTAG_PLANARCONFIG,planar_config);
       if (logging)
-       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "%s image planes",
-                             (planar_config == PLANARCONFIG_SEPARATE ?
-                              "Separate" : "Contiguous"));
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "%s image planes",
+                              (planar_config == PLANARCONFIG_SEPARATE ?
+                               "Separate" : "Contiguous"));
       (void) TIFFSetField(tiff,TIFFTAG_COMPRESSION,compress_tag);
 
       /*
@@ -4620,16 +4975,26 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             /*
               RowsPerStrip must be multiple of 16 for JPEG.
 
-             RowsPerStrip is required to be a multiple of 8 times the
-             largest vertical sampling factor.  If YCbCr subsampling
-             is 2,2 then RowsPerStrip must be a multiple of 16.
+              RowsPerStrip is required to be a multiple of 8 times the
+              largest vertical sampling factor.  If YCbCr subsampling
+              is 2,2 then RowsPerStrip must be a multiple of 16.
             */
-           rows_per_strip=(((rows_per_strip < 16 ? 16 : rows_per_strip)+1)/16)*16;
+            rows_per_strip=(((rows_per_strip < 16 ? 16 : rows_per_strip)+1)/16)*16;
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "JPEG Quality: %u", (unsigned) image_info->quality);
             (void) TIFFSetField(tiff,TIFFTAG_JPEGQUALITY,image_info->quality);
             if (IsRGBColorspace(image->colorspace))
-              (void) TIFFSetField(tiff,TIFFTAG_JPEGCOLORMODE,JPEGCOLORMODE_RGB);
+              {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "TIFFTAG_JPEGCOLORMODE: JPEGCOLORMODE_RGB");
+                (void) TIFFSetField(tiff,TIFFTAG_JPEGCOLORMODE,JPEGCOLORMODE_RGB);
+              }
             if (bits_per_sample == 12)
-              (void) TIFFSetField(tiff,TIFFTAG_JPEGTABLESMODE,JPEGTABLESMODE_QUANT);
+              {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "TIFFTAG_JPEGTABLESMODE: JPEGTABLESMODE_QUANT");
+                (void) TIFFSetField(tiff,TIFFTAG_JPEGTABLESMODE,JPEGTABLESMODE_QUANT);
+              }
             break;
           }
         case COMPRESSION_ADOBE_DEFLATE:
@@ -4652,7 +5017,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             if (((photometric == PHOTOMETRIC_RGB) ||
                  (photometric == PHOTOMETRIC_MINISBLACK)) &&
                 ((bits_per_sample == 8) || (bits_per_sample == 16)))
-             predictor=PREDICTOR_HORIZONTAL;
+              predictor=PREDICTOR_HORIZONTAL;
             {
               /*
                 Zip quality has a useful range of 1-9.
@@ -4662,6 +5027,9 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
                 zip_quality=1;
               if (zip_quality > 9)
                 zip_quality=9;
+
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "TIFFTAG_ZIPQUALITY: %u", zip_quality);
               (void) TIFFSetField(tiff,TIFFTAG_ZIPQUALITY,zip_quality);
             }
             break;
@@ -4675,25 +5043,25 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
               Group3Options = 4,5. LONG. Data may be one- or
               two-dimensional, but EOLs must be
               byte-aligned. Uncompressed data is not allowed.
-              
+
               bit 0 = 0 for 1-Dimensional, 1 for 2-Dimensional
-              
+
               bit 1 = must be 0 (uncompressed data not allowed)
 
               bit 2 = 1 for byte-aligned EOLs
 
             */
-           uint32
-             group_three_options = 4;
-
-           const char *
-             value;
-       
-           if ((value=AccessDefinition(image_info,"tiff","group-three-options")))
-             {
-               group_three_options=(uint32) strtol(value,(char **)NULL, 10);
-             }
-           (void) TIFFSetField(tiff,TIFFTAG_GROUP3OPTIONS,group_three_options);
+            uint32
+              group_three_options = 4;
+
+            const char *
+              value;
+
+            if ((value=AccessDefinition(image_info,"tiff","group-three-options")))
+              {
+                group_three_options=(uint32) strtol(value,(char **)NULL, 10);
+              }
+            (void) TIFFSetField(tiff,TIFFTAG_GROUP3OPTIONS,group_three_options);
 
             /*
               It is recommended (but not required) to output FAX as
@@ -4724,67 +5092,70 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
 #if defined(COMPRESSION_LZMA)
         case COMPRESSION_LZMA:
           {
-           unsigned int
-             lzma_preset;
-
-           const char *
-             lzma_preset_str;
-
-           /*
-             Lzma preset has a useful range of 1-9.
-
-             We default to 1 since testing does not show much benefit
-             from use of larger values.  However, we allow the
-             power-user who wants to experiment to change the preset
-             value via syntax like '-define tiff:lzmapreset=7'.  This
-             ability is intentionally not documented other than here.
-           */
-
-           lzma_preset=1;
-           if ((lzma_preset_str=AccessDefinition(image_info,"tiff","lzmapreset")))
-             lzma_preset=(unsigned short) MagickAtoI(lzma_preset_str);
-
-           if (lzma_preset < 1)
-             lzma_preset=1;
-           if (lzma_preset > 9)
-             lzma_preset=9;
-           (void) TIFFSetField(tiff,TIFFTAG_LZMAPRESET,lzma_preset);
-           if (logging)
-             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                   "LZMA PRESET set to %u", lzma_preset);
-
-           {
-             /*
-               Provide a default rows-per-strip which is suitably
-               tailored for the compression level.
-             */
-             
-             /*
-               Strip memory target for various compression preset levels.
-               Values are arbitrary.  LZMA is a memory and CPU pig.
-             */
-             static const unsigned int
-               lzma_memory_mb[] =
-               {       /* Level  Compress  Decompress */
-                 1U,  /*   1       2 MB      1 MB    */
-                 4U,  /*   2      12 MB      2 MB    */
-                 4U,  /*   3      12 MB      1 MB    */
-                 4U,  /*   4      16 MB      2 MB    */
-                 6U,  /*   5      26 MB      3 MB    */
-                 10U, /*   6      45 MB      5 MB    */
-                 18U, /*   7      83 MB      9 MB    */
-                 34U, /*   8     159 MB     17 MB    */
-                 66U  /*   9     311 MB     33 MB    */
-               };
-             
-             rows_per_strip = (uint32) (((lzma_memory_mb[lzma_preset-1]*1024U*1024U))/
-                                         ((((unsigned long) bits_per_sample*samples_per_pixel)/
-                                           8U)*image->rows));
-             if (rows_per_strip < 1)
-               rows_per_strip=1U;
-             if (rows_per_strip > image->rows)
-               rows_per_strip=image->rows;
-           }
+            unsigned int
+              lzma_preset;
+
+            const char *
+              lzma_preset_str;
+
+            /*
+              Lzma preset has a useful range of 1-9.
+
+              We default to 1 since testing does not show much benefit
+              from use of larger values.  However, we allow the
+              power-user who wants to experiment to change the preset
+              value via syntax like '-define tiff:lzmapreset=7'.  This
+              ability is intentionally not documented other than here.
+            */
+
+            lzma_preset=1;
+            if ((lzma_preset_str=AccessDefinition(image_info,"tiff","lzmapreset")))
+              lzma_preset=(unsigned short) MagickAtoI(lzma_preset_str);
+
+            if (lzma_preset < 1)
+              lzma_preset=1;
+            if (lzma_preset > 9)
+              lzma_preset=9;
+            (void) TIFFSetField(tiff,TIFFTAG_LZMAPRESET,lzma_preset);
+            if (logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "LZMA PRESET set to %u", lzma_preset);
+
+            {
+              /*
+                Provide a default rows-per-strip which is suitably
+                tailored for the compression level.
+              */
+
+              /*
+                Strip memory target for various compression preset levels.
+                Values are arbitrary.  LZMA is a memory and CPU pig.
+              */
+              static const unsigned int
+                lzma_memory_mb[] =
+                {       /* Level  Compress  Decompress */
+                  1U,  /*   1       2 MB      1 MB    */
+                  4U,  /*   2      12 MB      2 MB    */
+                  4U,  /*   3      12 MB      1 MB    */
+                  4U,  /*   4      16 MB      2 MB    */
+                  6U,  /*   5      26 MB      3 MB    */
+                  10U, /*   6      45 MB      5 MB    */
+                  18U, /*   7      83 MB      9 MB    */
+                  34U, /*   8     159 MB     17 MB    */
+                  66U  /*   9     311 MB     33 MB    */
+                };
+
+              rows_per_strip =
+                (uint32) ceil((((double) lzma_memory_mb[lzma_preset-1]*
+                                1024.0*1024.0*8.0))/
+                              (((double) bits_per_sample*samples_per_pixel
+                                *image->columns)))/8.0;
+
+              if (rows_per_strip < 1)
+                rows_per_strip=1U;
+              if (rows_per_strip > image->rows)
+                rows_per_strip=image->rows;
+            }
 
             /*
               Use horizontal differencing (type 2) for images which are
@@ -4794,13 +5165,13 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             if (((photometric == PHOTOMETRIC_RGB) ||
                  (photometric == PHOTOMETRIC_MINISBLACK)) &&
                 ((bits_per_sample == 8) || (bits_per_sample == 16)))
-             predictor=PREDICTOR_HORIZONTAL;
+              predictor=PREDICTOR_HORIZONTAL;
             break;
           }
 #endif /* COMPRESSION_LZMA */
 #if defined(COMPRESSION_JBIG)
-       case COMPRESSION_JBIG:
-         {
+        case COMPRESSION_JBIG:
+          {
             /*
               It is recommended (but not required) to output FAX as
               one strip. We will limit strip size to 16 megapixels by
@@ -4811,8 +5182,8 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
               rows_per_strip=1;
             if (rows_per_strip > image->rows)
               rows_per_strip=(uint32) image->rows;
-           break;
-         }
+            break;
+          }
 #endif /* COMPRESSION_JBIG */
         case COMPRESSION_LZW:
           {
@@ -4824,9 +5195,104 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             if (((photometric == PHOTOMETRIC_RGB) ||
                  (photometric == PHOTOMETRIC_MINISBLACK)) &&
                 ((bits_per_sample == 8) || (bits_per_sample == 16)))
-             predictor=PREDICTOR_HORIZONTAL;
+              predictor=PREDICTOR_HORIZONTAL;
+            break;
+          }
+#if defined(COMPRESSION_ZSTD)
+        case COMPRESSION_ZSTD:
+          {
+            /*
+              Larger strips compress better with diminishing returns
+              (enlarge if necessary)..
+            */
+            unsigned int
+              proposed_rows_per_strip;
+
+            proposed_rows_per_strip = (uint32) (512*1024) / Max(scanline_size,1);
+            if (proposed_rows_per_strip > rows_per_strip)
+              rows_per_strip=proposed_rows_per_strip;
+            /*
+              Use horizontal differencing (type 2) for images which are
+              likely to be continuous tone.  The TIFF spec says that this
+              usually leads to better compression.
+            */
+            if (((photometric == PHOTOMETRIC_RGB) ||
+                 (photometric == PHOTOMETRIC_MINISBLACK)) &&
+                ((bits_per_sample == 8) || (bits_per_sample == 16)))
+              predictor=PREDICTOR_HORIZONTAL;
+            {
+              /*
+                Zstd level has a useful range of 1-19 (or even 22).
+
+                Libtiff uses a default level of 9.
+
+                Default for ImageInfo 'quality' is 75, which is translated to 9.
+
+                Use -define tiff:zstd-compress-level=<value> to specify a value.
+              */
+              const char *value;
+              int compress_level = (image_info->quality*9)/75;
+#if defined(HasZSTD)
+              int max_compression = ZSTD_maxCLevel();
+#else
+              int max_compression = 19;
+#endif
+              if ((value=AccessDefinition(image_info,"tiff","zstd-compress-level")))
+                compress_level=MagickAtoI(value);
+              if (compress_level < 1)
+                compress_level=1;
+              if (compress_level > max_compression)
+                compress_level=max_compression;
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "TIFFTAG_ZSTD_LEVEL: %u", compress_level);
+              (void) TIFFSetField(tiff,TIFFTAG_ZSTD_LEVEL,compress_level);
+            }
+            break;
+          }
+#endif /* defined(COMPRESSION_ZSTD) */
+#if defined(COMPRESSION_WEBP)
+        case COMPRESSION_WEBP:
+          {
+            /*
+              Larger strips compress better with diminishing returns
+              (enlarge if necessary)..
+            */
+            unsigned int
+              proposed_rows_per_strip;
+
+            proposed_rows_per_strip = (uint32) (1024*1024) / Max(scanline_size,1);
+            if (proposed_rows_per_strip > rows_per_strip)
+              rows_per_strip=proposed_rows_per_strip;
+
+            /* TIFFTAG_WEBP_LEVEL */
+            if (image_info->quality != DefaultCompressionQuality)
+              {
+                int quality = (int) image_info->quality;
+                if (quality < 1)
+                  quality=1;
+                else if (quality > 100)
+                  quality=100;
+
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "TIFFTAG_WEBP_LEVEL: %d", quality);
+                (void) TIFFSetField(tiff,TIFFTAG_WEBP_LEVEL,quality);
+              }
+
+            /* TIFFTAG_WEBP_LOSSLESS */
+            {
+              const char *value;
+              if (((value=AccessDefinition(image_info,"tiff","webp-lossless")) != NULL) ||
+                  ((value=AccessDefinition(image_info,"webp","lossless")) != NULL))
+                {
+                  int lossless=(LocaleCompare(value,"TRUE") == 0 ? 1 : 0);
+                  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "TIFFTAG_WEBP_LOSSLESS: %d", lossless);
+                  (void) TIFFSetField(tiff,TIFFTAG_WEBP_LOSSLESS,lossless);
+                }
+            }
             break;
           }
+#endif /* defined(COMPRESSION_WEBP) */
         default:
           {
             break;
@@ -4834,24 +5300,24 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
         }
 
       /*
-       Allow the user to specify the predictor (at their own peril)
+        Allow the user to specify the predictor (at their own peril)
       */
       {
-       const char *
+        const char *
             value;
-       
-       if ((value=AccessDefinition(image_info,"tiff","predictor")))
-         predictor=(unsigned short) MagickAtoI(value);
+
+        if ((value=AccessDefinition(image_info,"tiff","predictor")))
+          predictor=(unsigned short) MagickAtoI(value);
       }
 
       if (predictor != 0)
-       {
-         if (logging)
-           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                                 "Requesting predictor %u",
-                                 (unsigned int) predictor);
-         (void) TIFFSetField(tiff,TIFFTAG_PREDICTOR,predictor);
-       }
+        {
+          if (logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Requesting predictor %u",
+                                  (unsigned int) predictor);
+          (void) TIFFSetField(tiff,TIFFTAG_PREDICTOR,predictor);
+        }
 
       /*
         Allow the user to override rows-per-strip settings.
@@ -4865,13 +5331,13 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             {
               unsigned int
                 old_value;
-              
+
               old_value=rows_per_strip;
               rows_per_strip=MagickAtoI(value);
               if (logging)
                 (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                       "User override (rows_per_strip): %u rows"
-                                     " per strip (was %u)",
+                                      " per strip (was %u)",
                                       (unsigned int) rows_per_strip, old_value);
             }
           if ((value=AccessDefinition(image_info,"tiff","strip-per-page")))
@@ -4879,27 +5345,27 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
               if (LocaleCompare("TRUE",value) == 0)
                 {
                   rows_per_strip=(uint32) image->rows;
-                  
+
                   if (logging)
                     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                           "User requested a single strip per "
-                                         "page (strip-per-page)");
+                                          "page (strip-per-page)");
                 }
             }
         }
 
       if (COMPRESSION_JPEG == compress_tag)
-       {
-         /*
-           RowsPerStrip must be multiple of 16 for JPEG.
-         */
-         rows_per_strip=(((rows_per_strip < 16 ? 16 : rows_per_strip)+1)/16)*16;
-       }
+        {
+          /*
+            RowsPerStrip must be multiple of 16 for JPEG.
+          */
+          rows_per_strip=(((rows_per_strip < 16 ? 16 : rows_per_strip)+1)/16)*16;
+        }
 
       if (logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "Using %s compression",
-                             CompressionTagToString(compress_tag));
+                              CompressionTagToString(compress_tag));
       if (logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "Image depth %lu bits",depth);
@@ -4981,7 +5447,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
                                 profile_data);
           }
 #endif /* defined(TIFFTAG_XMLPACKET) */
-      
+
 #if defined(TIFFTAG_ICCPROFILE)
         /*
           ICC color profile.
@@ -4995,7 +5461,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
                                 profile_data);
           }
 #endif /* defined(ICC_SUPPORT) */
-      
+
         /*
           IPTC NewsPhoto profile.
         */
@@ -5008,14 +5474,14 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             profile_tag=TIFFTAG_PHOTOSHOP;
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "Photoshop embedded profile with length %lu"
-                                 " bytes",
+                                  " bytes",
                                   (unsigned long) profile_length);
 #else
             /* IPTC TAG from RichTIFF specifications */
             profile_tag=TIFFTAG_RICHTIFFIPTC;
             (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                   "IPTC Newsphoto embedded profile with length"
-                                 " %lu bytes",
+                                  " %lu bytes",
                                   (unsigned long) profile_length);
 
 #endif /* defined(PHOTOSHOP_SUPPORT) */
@@ -5054,7 +5520,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             pages;
 
           page=(uint16) scene;
-          pages=GetImageListLength(image);
+          pages=(uint16) image_list_length;
 
           if (image_info->adjoin && pages > 1)
             {
@@ -5092,7 +5558,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
       attribute=GetImageAttribute(image,"make");
       if (attribute != (const ImageAttribute *) NULL)
         (void) TIFFSetField(tiff,TIFFTAG_MAKE,attribute->value);
+
       attribute=GetImageAttribute(image,"model");
       if (attribute != (const ImageAttribute *) NULL)
         (void) TIFFSetField(tiff,TIFFTAG_MODEL,attribute->value);
@@ -5118,8 +5584,8 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
 
 #if 0
       /*
-       This tag is not supported by libtiff so the tag extension
-       mechanism would need to be used to add support for it.
+        This tag is not supported by libtiff so the tag extension
+        mechanism would need to be used to add support for it.
       */
       attribute=GetImageAttribute(image,"imageid");
       if (attribute != (const ImageAttribute *) NULL)
@@ -5145,8 +5611,13 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
           if ((blue == (unsigned short *) NULL) ||
               (green == (unsigned short *) NULL) ||
               (red == (unsigned short *) NULL))
-            ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,
-                                 image);
+            {
+              MagickFreeMemory(blue);
+              MagickFreeMemory(green);
+              MagickFreeMemory(red);
+              ThrowTIFFWriterException(ResourceLimitError,MemoryAllocationFailed,
+                                       image);
+            }
           (void) memset(red,0,65536L*sizeof(unsigned short));
           (void) memset(green,0,65536L*sizeof(unsigned short));
           (void) memset(blue,0,65536L*sizeof(unsigned short));
@@ -5222,7 +5693,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
 
             QuantumType
               quantum_type;
-            
+
             /*
               Allocate memory for one scanline.
             */
@@ -5231,13 +5702,9 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             if (logging)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                     "Using scanline %s write method with %u "
-                                   "bits per sample (%lu bytes/scanline)",
+                                    "bits per sample (%lu bytes/scanline)",
                                     PhotometricTagToString(photometric),
-                                   bits_per_sample, (unsigned long) scanline_size);
-
-            scanline=MagickAllocateMemory(unsigned char *,(size_t) scanline_size);
-            if (scanline == (unsigned char *) NULL)
-              ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+                                    bits_per_sample, (unsigned long) scanline_size);
             /*
               Prepare for separate/contiguous retrieval.
             */
@@ -5251,6 +5718,10 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
                     == MagickPass)
                   max_sample=quantum_samples;
               }
+
+            scanline=MagickAllocateMemory(unsigned char *,(size_t) scanline_size);
+            if (scanline == (unsigned char *) NULL)
+              ThrowTIFFWriterException(ResourceLimitError,MemoryAllocationFailed,image);
             /*
               For each plane
             */
@@ -5309,15 +5780,15 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
                       }
 
                     if (image->previous == (Image *) NULL)
-                     if (QuantumTick(y+sample*image->rows,image->rows*max_sample))
-                       if (!MagickMonitorFormatted(y+sample*image->rows,
-                                                   image->rows*max_sample,&image->exception,
-                                                   SaveImageText,image->filename,
-                                                   image->columns,image->rows))
-                         {
-                           status=MagickFail;
-                           break;
-                         }
+                      if (QuantumTick(y+sample*image->rows,image->rows*max_sample))
+                        if (!MagickMonitorFormatted(y+sample*image->rows,
+                                                    image->rows*max_sample,&image->exception,
+                                                    SaveImageText,image->filename,
+                                                    image->columns,image->rows))
+                          {
+                            status=MagickFail;
+                            break;
+                          }
 
                   }
                 if (status == MagickFail)
@@ -5353,13 +5824,13 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
 
             unsigned long
               tile_total_pixels;
-        
+
             if (logging)
               (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                                     "Using tiled %s write method with %u bits "
-                                   "per sample",
+                                    "per sample",
                                     PhotometricTagToString(photometric),
-                                   bits_per_sample);
+                                    bits_per_sample);
 
             /*
               Determine tile size
@@ -5370,17 +5841,17 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
 
               tile_columns=0;
               tile_rows=0;
-              
+
               /*
                 Enable tiled output (with default size, or specified separately)
                 -define tiff:tile
-                
+
                 Use an exact tile size in rows & columns
                 -define tiff:tile-geometry=128x128
-                
+
                 Use a specific tile width (pixels)
                 -define tiff:tile-width=128
-                
+
                 Use a specific tile height (pixels)
                 -define tiff:tile-height=128
               */
@@ -5404,7 +5875,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
                 {
                   tile_rows=MagickAtoL(value);
                 }
-              
+
               TIFFDefaultTileSize(tiff,&tile_columns,&tile_rows);
             }
 
@@ -5433,7 +5904,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             */
             tile=MagickAllocateMemory(unsigned char *, (size_t) tile_size_max);
             if (tile == (unsigned char *) NULL)
-              ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);
+              ThrowTIFFWriterException(ResourceLimitError,MemoryAllocationFailed,image);
             /*
               Prepare for separate/contiguous retrieval.
             */
@@ -5452,52 +5923,52 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
             */
             stride=TIFFTileRowSize(tiff);
 
-           /*
-             Process each plane.
-           */
-           for (sample=0; sample < max_sample; sample++)
-             {
-               /*
-                 Determine quantum parse method.
-               */
-               if (QuantumTransferMode(image,photometric,compress_tag,
+            /*
+              Process each plane.
+            */
+            for (sample=0; sample < max_sample; sample++)
+              {
+                /*
+                  Determine quantum parse method.
+                */
+                if (QuantumTransferMode(image,photometric,compress_tag,
                                         sample_format,samples_per_pixel,
                                         planar_config,sample,&quantum_type,
                                         &quantum_samples,&image->exception)
                     == MagickFail)
-                 {
-                   status=MagickFail;
-                   break;
-                 }
-               for (y=0; y < image->rows; y+=tile_rows)
-                 {
-                   for (x=0; x < image->columns; x+=tile_columns)
-                     {
-                       const PixelPacket
-                         *p;
-                       
-                       long
-                         tile_set_columns,
-                         tile_set_rows;
-                       
-                       unsigned char
-                         *q;
-                       
-                       register long
-                         yy;
-                       
-                       /*
-                         Compute image region corresponding to tile.
-                       */
-                       if (x+tile_columns > image->columns)
-                         tile_set_columns=(tile_columns-(x+tile_columns-image->columns));
-                       else
-                         tile_set_columns=tile_columns;
-                       if (y+tile_rows > image->rows)
-                         tile_set_rows=(tile_rows-(y+tile_rows-image->rows));
-                       else
-                         tile_set_rows=tile_rows;
-                       
+                  {
+                    status=MagickFail;
+                    break;
+                  }
+                for (y=0; y < image->rows; y+=tile_rows)
+                  {
+                    for (x=0; x < image->columns; x+=tile_columns)
+                      {
+                        const PixelPacket
+                          *p;
+
+                        long
+                          tile_set_columns,
+                          tile_set_rows;
+
+                        unsigned char
+                          *q;
+
+                        register long
+                          yy;
+
+                        /*
+                          Compute image region corresponding to tile.
+                        */
+                        if (x+tile_columns > image->columns)
+                          tile_set_columns=(tile_columns-(x+tile_columns-image->columns));
+                        else
+                          tile_set_columns=tile_columns;
+                        if (y+tile_rows > image->rows)
+                          tile_set_rows=(tile_rows-(y+tile_rows-image->rows));
+                        else
+                          tile_set_rows=tile_rows;
+
                         q=tile;
                         for (yy=y; yy < (long) y+tile_set_rows; yy++)
                           {
@@ -5508,7 +5979,7 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
                               p=GetImagePixels(image,x,yy,tile_set_columns,1);
                             else
                               p=AcquireImagePixels(image,x,yy,tile_set_columns,
-                                                  1,&image->exception);
+                                                   1,&image->exception);
                             if (p == (const PixelPacket *) NULL)
                               {
                                 status=MagickFail;
@@ -5550,26 +6021,26 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
                           {
                             status=MagickFail;
                           }
-                       if (status == MagickFail)
-                         break;
-                     } /* for x */
-                   /*
-                     Progress indicator.
-                   */
-                   if (image->previous == (Image *) NULL)
-                     if (QuantumTick((y+sample*image->rows)/tile_rows,
-                                     (image->rows*max_sample)/tile_rows))
-                       if (!MagickMonitorFormatted((y+sample*image->rows)/tile_rows,
-                                                   (image->rows*max_sample)/tile_rows,
-                                                   &image->exception,
-                                                   SaveImageText,image->filename,
-                                                   image->columns,image->rows))
-                         status=MagickFail;
-                   
-                   if (status == MagickFail)
-                     break;
-                 } /* for y */
-             } /* for sample */
+                        if (status == MagickFail)
+                          break;
+                      } /* for x */
+                    /*
+                      Progress indicator.
+                    */
+                    if (image->previous == (Image *) NULL)
+                      if (QuantumTick((y+sample*image->rows)/tile_rows,
+                                      (image->rows*max_sample)/tile_rows))
+                        if (!MagickMonitorFormatted((y+sample*image->rows)/tile_rows,
+                                                    (image->rows*max_sample)/tile_rows,
+                                                    &image->exception,
+                                                    SaveImageText,image->filename,
+                                                    image->columns,image->rows))
+                          status=MagickFail;
+
+                    if (status == MagickFail)
+                      break;
+                  } /* for y */
+              } /* for sample */
             MagickFreeMemory(tile);
             break;
           }
@@ -5577,16 +6048,16 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
       if (image_info->verbose > 1)
         TIFFPrintDirectory(tiff,stdout,MagickFalse);
       if(!TIFFWriteDirectory(tiff))
-       {
-         status=MagickFail;
-         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "TIFFWriteDirectory returns failed status!");
-       }
+        {
+          status=MagickFail;
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "TIFFWriteDirectory returns failed status!");
+        }
       if (image->next == (Image *) NULL)
         break;
       image=SyncNextImageInList(image);
       if ((status &= MagickMonitorFormatted(scene++,
-                                            GetImageListLength(image),
+                                            image_list_length,
                                             &image->exception,
                                             SaveImagesText,
                                             image->filename)) == MagickFail)
@@ -5601,10 +6072,10 @@ WriteTIFFImage(const ImageInfo *image_info,Image *image)
       /*
         Handle write failure.
       */
-                           
+
       if (unlink(filename) != -1)
-       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "Removed broken output file \"%s\"",filename);
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Removed broken output file \"%s\"",filename);
       return (MagickFail);
     }
 
index 0553aff..ad127c0 100644 (file)
@@ -86,7 +86,7 @@ static Image *ReadTILEImage(const ImageInfo *image_info,
 
   RectangleInfo
     geometry;
-    
+
 
   /*
     Initialize Image structure.
@@ -100,6 +100,7 @@ static Image *ReadTILEImage(const ImageInfo *image_info,
   clone_info->blob=(void *) NULL;
   clone_info->length=0;
   *clone_info->magick='\0';
+  MagickFreeMemory(clone_info->size);
   tile_image=ReadImage(clone_info,exception);
   DestroyImageInfo(clone_info);
   if (tile_image == (Image *) NULL)
index d48721c..a250f2d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -38,6 +38,8 @@
 #include "magick/studio.h"
 #include "magick/blob.h"
 #include "magick/colormap.h"
+#include "magick/enum_strings.h"
+#include "magick/log.h"
 #include "magick/magick.h"
 #include "magick/monitor.h"
 #include "magick/pixel_cache.h"
@@ -114,13 +116,13 @@ static Image *ReadTIMImage(const ImageInfo *image_info,ExceptionInfo *exception)
     *p;
 
   unsigned char
-    *tim_data,
     *tim_pixels;
 
   unsigned short
     word;
 
   unsigned int
+    index,
     status;
 
   size_t
@@ -148,260 +150,332 @@ static Image *ReadTIMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   */
   tim_info.id=ReadBlobLSBLong(image);
   do
-  {
-    /*
-      Verify TIM identifier.
-    */
-    if (tim_info.id != 0x00000010)
-      ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
-    tim_info.flag=ReadBlobLSBLong(image);
-    has_clut=!!(tim_info.flag & (1 << 3));
-    pixel_mode=tim_info.flag & 0x07;
-    switch ((int) pixel_mode)
     {
-      case 0: bits_per_pixel=4; break;
-      case 1: bits_per_pixel=8; break;
-      case 2: bits_per_pixel=16; break;
-      case 3: bits_per_pixel=24; break;
-      default: bits_per_pixel=4; break;
-    }
-    image->depth=8;
-    if (has_clut)
-      {
-        unsigned char
-          *tim_colormap;
-
-        /*
-          Read TIM raster colormap.
-        */
-        (void)ReadBlobLSBLong(image);
-        (void)ReadBlobLSBShort(image);
-        (void)ReadBlobLSBShort(image);
-        /* width= */ (void)ReadBlobLSBShort(image);
-        /* height= */ (void)ReadBlobLSBShort(image);
-        if (!AllocateImageColormap(image,pixel_mode == 1 ? 256 : 16))
-          ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-            image);
-        tim_colormap=MagickAllocateMemory(unsigned char *,image->colors*2);
-        if (tim_colormap == (unsigned char *) NULL)
-          ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
-            image);
-        (void) ReadBlob(image,2*image->colors,(char *) tim_colormap);
-        p=tim_colormap;
-        for (i=0; i < (long) image->colors; i++)
+      /*
+        Verify TIM identifier.
+      */
+      if (tim_info.id != 0x00000010)
+        ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+      tim_info.flag=ReadBlobLSBLong(image);
+      has_clut=!!(tim_info.flag & (1 << 3));
+      pixel_mode=tim_info.flag & 0x07;
+      switch ((int) pixel_mode)
         {
-          word=(*p++);
-          word|=(unsigned short) (*p++ << 8U);
-          image->colormap[i].blue=ScaleCharToQuantum(ScaleColor5to8((word >> 10U) & 0x1fU));
-          image->colormap[i].green=ScaleCharToQuantum(ScaleColor5to8((word >> 5U) & 0x1fU));
-          image->colormap[i].red=ScaleCharToQuantum(ScaleColor5to8(word & 0x1fU));
+        case 0: bits_per_pixel=4; break;
+        case 1: bits_per_pixel=8; break;
+        case 2: bits_per_pixel=16; break;
+        case 3: bits_per_pixel=24; break;
+        default: bits_per_pixel=4; break;
         }
-        MagickFreeMemory(tim_colormap);
-      }
-
-    /*
-      Read image data.
-    */
-    (void) ReadBlobLSBLong(image);
-    (void) ReadBlobLSBShort(image);
-    (void) ReadBlobLSBShort(image);
-    if (EOFBlob(image))
-      ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
-    width=ReadBlobLSBShort(image);
-    height=ReadBlobLSBShort(image);
-    image_size=MagickArraySize(2,MagickArraySize(width,height));
-    bytes_per_line=MagickArraySize(width,2);
-    width=(unsigned long)(MagickArraySize(width,16))/bits_per_pixel;
-    /*
-      Initialize image structure.
-    */
-    image->columns=width;
-    image->rows=height;
-
-    if (image_info->ping && (image_info->subrange != 0))
-      if (image->scene >= (image_info->subimage+image_info->subrange-1))
-        break;
-
-    if (CheckImagePixelLimits(image, exception) != MagickPass)
-      ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
-
-    tim_data=MagickAllocateMemory(unsigned char *,image_size);
-    if (tim_data == (unsigned char *) NULL)
-      ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-    (void) ReadBlob(image,image_size,(char *) tim_data);
-    tim_pixels=tim_data;
-
-    /*
-      Convert TIM raster image to pixel packets.
-    */
-    switch (bits_per_pixel)
-    {
-      case 4:
-      {
-        /*
-          Convert PseudoColor scanline.
-        */
-        for (y=(long) image->rows-1; y >= 0; y--)
+      image->depth=8;
+      if (has_clut)
         {
-          q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
-          if (q == (PixelPacket *) NULL)
-            break;
-          indexes=AccessMutableIndexes(image);
-          p=tim_pixels+y*bytes_per_line;
-          for (x=0; x < ((long) image->columns-1); x+=2)
-          {
-            indexes[x]=(*p) & 0xf;
-            indexes[x+1]=(*p >> 4) & 0xf;
-            p++;
-          }
-          if ((image->columns % 2) != 0)
+          unsigned char
+            *tim_colormap;
+
+          /*
+            Read TIM raster colormap.
+          */
+          (void)ReadBlobLSBLong(image);
+          (void)ReadBlobLSBShort(image);
+          (void)ReadBlobLSBShort(image);
+          /* width= */ (void)ReadBlobLSBShort(image);
+          /* height= */ (void)ReadBlobLSBShort(image);
+          if (!AllocateImageColormap(image,pixel_mode == 1 ? 256 : 16))
+            ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                 image);
+          tim_colormap=MagickAllocateMemory(unsigned char *,image->colors*2);
+          if (tim_colormap == (unsigned char *) NULL)
+            ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
+                                 image);
+          if (ReadBlob(image,2*image->colors,(char *) tim_colormap) != 2*image->colors)
             {
-              indexes[x]=(*p >> 4) & 0xf;
-              p++;
+              MagickFreeMemory(tim_colormap);
+              ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
             }
-          if (!SyncImagePixelsEx(image,exception))
-            break;
-          if (QuantumTick(y,image->rows))
+          p=tim_colormap;
+          for (i=0; i < (long) image->colors; i++)
             {
-              status=MagickMonitorFormatted(image->rows-y-1,image->rows,
-                                            exception,LoadImageText,
-                                            image->filename,
-                                           image->columns,image->rows);
-              if (status == False)
-                break;
+              word=(*p++);
+              word|=(unsigned short) (*p++ << 8U);
+              image->colormap[i].blue=ScaleCharToQuantum(ScaleColor5to8((word >> 10U) & 0x1fU));
+              image->colormap[i].green=ScaleCharToQuantum(ScaleColor5to8((word >> 5U) & 0x1fU));
+              image->colormap[i].red=ScaleCharToQuantum(ScaleColor5to8(word & 0x1fU));
+              image->colormap[i].opacity=OpaqueOpacity;
             }
+          MagickFreeMemory(tim_colormap);
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "PSX-TIM read CLUT with %u entries",
+                                  image->colors);
         }
-        break;
-      }
-      case 8:
-      {
-        /*
-          Convert PseudoColor scanline.
-        */
-        for (y=(long) image->rows-1; y >= 0; y--)
+      if ((bits_per_pixel == 4) || (bits_per_pixel == 8))
         {
-          q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
-          if (q == (PixelPacket *) NULL)
-            break;
-          indexes=AccessMutableIndexes(image);
-          p=tim_pixels+y*bytes_per_line;
-          for (x=0; x < (long) image->columns; x++)
-            indexes[x]=(*p++);
-          if (!SyncImagePixelsEx(image,exception))
-            break;
-          if (QuantumTick(y,image->rows))
+          if (image->storage_class != PseudoClass)
             {
-              status=MagickMonitorFormatted(image->rows-y-1,image->rows,
-                                            exception,LoadImageText,
-                                            image->filename,
-                                           image->columns,image->rows);
-              if (status == False)
-                break;
+              if (image->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "PSX-TIM %u bits/sample requires a CLUT!",
+                                      bits_per_pixel);
+              errno=0;
+              ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
             }
         }
-        break;
-      }
-      case 16:
-      {
-        /*
-          Convert DirectColor scanline.
-        */
-        for (y=(long) image->rows-1; y >= 0; y--)
+      else
         {
-          p=tim_pixels+y*bytes_per_line;
-          q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
-          if (q == (PixelPacket *) NULL)
-            break;
-          for (x=0; x < (long) image->columns; x++)
-          {
-            word=(*p++);
-            word|=(*p++ << 8);
-            q->blue=ScaleCharToQuantum(ScaleColor5to8((word >> 10) & 0x1f));
-            q->green=ScaleCharToQuantum(ScaleColor5to8((word >> 5) & 0x1f));
-            q->red=ScaleCharToQuantum(ScaleColor5to8(word & 0x1f));
-            q++;
-          }
-          if (!SyncImagePixelsEx(image,exception))
-            break;
-          if (QuantumTick(y,image->rows))
+          if (image->storage_class == PseudoClass)
             {
-              status=MagickMonitorFormatted(image->rows-y-1,image->rows,
-                                            exception,LoadImageText,
-                                            image->filename,
-                                           image->columns,image->rows);
-              if (status == False)
-                break;
+              if (image->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "PSX-TIM %u bits/sample does not use"
+                                      " a CLUT, ignoring it",
+                                      bits_per_pixel);
+              image->storage_class=DirectClass;
             }
         }
-        break;
-      }
-      case 24:
-      {
-        /*
-          Convert DirectColor scanline.
-        */
-        for (y=(long) image->rows-1; y >= 0; y--)
+
+      /*
+        Read image data.
+      */
+      (void) ReadBlobLSBLong(image);
+      (void) ReadBlobLSBShort(image);
+      (void) ReadBlobLSBShort(image);
+      width=ReadBlobLSBShort(image);
+      height=ReadBlobLSBShort(image);
+      if (EOFBlob(image))
+        ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+      image_size=MagickArraySize(2,MagickArraySize(width,height));
+      bytes_per_line=MagickArraySize(width,2);
+      width=(unsigned long)(MagickArraySize(width,16))/bits_per_pixel;
+      /*
+        Initialize image structure.
+      */
+      image->columns=width;
+      image->rows=height;
+
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "TIM[%lu] %lux%lu %d bits/pixel %s",
+                              image->scene,
+                              image->columns, image->rows,
+                              bits_per_pixel,
+                              ClassTypeToString(image->storage_class));
+
+      if (image_info->ping)
+        if ((image_info->subrange == 0) ||
+            ((image_info->subrange != 0) &&
+             (image->scene >= (image_info->subimage+image_info->subrange-1))))
+          break;
+
+      if (CheckImagePixelLimits(image, exception) != MagickPass)
+        ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+
+      tim_pixels=MagickAllocateMemory(unsigned char *,image_size);
+      if (tim_pixels == (unsigned char *) NULL)
+        ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+      if (ReadBlob(image,image_size,(char *) tim_pixels) != image_size)
         {
-          p=tim_pixels+y*bytes_per_line;
-          q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
-          if (q == (PixelPacket *) NULL)
+          MagickFreeMemory(tim_pixels);
+          ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+        }
+
+      /*
+        Convert TIM raster image to pixel packets.
+      */
+      switch (bits_per_pixel)
+        {
+        case 4:
+          {
+            /*
+              Convert PseudoColor scanline.
+            */
+            for (y=(long) image->rows-1; y >= 0; y--)
+              {
+                q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
+                if (q == (PixelPacket *) NULL)
+                  break;
+                indexes=AccessMutableIndexes(image);
+                if (indexes == (IndexPacket *) NULL)
+                  break;
+                p=tim_pixels+y*bytes_per_line;
+                for (x=0; x < ((long) image->columns-1); x+=2)
+                  {
+                    index=(*p) & 0xf;
+                    VerifyColormapIndex(image,index);
+                    indexes[x]=index;
+                    index=(*p >> 4) & 0xf;
+                    VerifyColormapIndex(image,index);
+                    indexes[x+1]=index;
+                    p++;
+                  }
+                if ((image->columns % 2) != 0)
+                  {
+                    index=(*p >> 4) & 0xf;
+                    VerifyColormapIndex(image,index);
+                    indexes[x]=(*p >> 4) & 0xf;
+                    p++;
+                  }
+                if (!SyncImagePixelsEx(image,exception))
+                  break;
+                if (QuantumTick(y,image->rows))
+                  {
+                    status=MagickMonitorFormatted(image->rows-y-1,image->rows,
+                                                  exception,LoadImageText,
+                                                  image->filename,
+                                                  image->columns,image->rows);
+                    if (status == False)
+                      break;
+                  }
+              }
             break;
-          for (x=0; x < (long) image->columns; x++)
+          }
+        case 8:
           {
-            q->red=ScaleCharToQuantum(*p++);
-            q->green=ScaleCharToQuantum(*p++);
-            q->blue=ScaleCharToQuantum(*p++);
-            q++;
+            /*
+              Convert PseudoColor scanline.
+            */
+            for (y=(long) image->rows-1; y >= 0; y--)
+              {
+                q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
+                if (q == (PixelPacket *) NULL)
+                  break;
+                indexes=AccessMutableIndexes(image);
+                if (indexes == (IndexPacket *) NULL)
+                  break;
+                p=tim_pixels+y*bytes_per_line;
+                for (x=0; x < (long) image->columns; x++)
+                  {
+                    index=(*p++);
+                    VerifyColormapIndex(image,index);
+                    indexes[x]=index;
+                  }
+                if (!SyncImagePixelsEx(image,exception))
+                  break;
+                if (QuantumTick(y,image->rows))
+                  {
+                    status=MagickMonitorFormatted(image->rows-y-1,image->rows,
+                                                  exception,LoadImageText,
+                                                  image->filename,
+                                                  image->columns,image->rows);
+                    if (status == False)
+                      break;
+                  }
+              }
+            break;
           }
-          if (!SyncImagePixelsEx(image,exception))
+        case 16:
+          {
+            /*
+              Convert DirectColor scanline.
+            */
+            for (y=(long) image->rows-1; y >= 0; y--)
+              {
+                PixelPacket *t;
+                p=tim_pixels+y*bytes_per_line;
+                q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
+                if (q == (PixelPacket *) NULL)
+                  break;
+                t=q;
+                for (x=0; x < (long) image->columns; x++)
+                  {
+                    word=(*p++);
+                    word|=(*p++ << 8);
+                    q->blue=ScaleCharToQuantum(ScaleColor5to8((word >> 10) & 0x1f));
+                    q->green=ScaleCharToQuantum(ScaleColor5to8((word >> 5) & 0x1f));
+                    q->red=ScaleCharToQuantum(ScaleColor5to8(word & 0x1f));
+                    q->opacity=OpaqueOpacity;
+                    q++;
+                  }
+                memset(t,0,image->columns*sizeof(PixelPacket));
+                if (!SyncImagePixelsEx(image,exception))
+                  break;
+                if (QuantumTick(y,image->rows))
+                  {
+                    status=MagickMonitorFormatted(image->rows-y-1,image->rows,
+                                                  exception,LoadImageText,
+                                                  image->filename,
+                                                  image->columns,image->rows);
+                    if (status == False)
+                      break;
+                  }
+              }
             break;
-          if (QuantumTick(y,image->rows))
-            {
-              status=MagickMonitorFormatted(image->rows-y-1,image->rows,
-                                            exception,LoadImageText,
-                                            image->filename,
-                                           image->columns,image->rows);
-              if (status == False)
-                break;
-            }
-        }
-        break;
-      }
-      default:
-        ThrowReaderException(CorruptImageError,ImproperImageHeader,image)
-    }
-    if (image->storage_class == PseudoClass)
-      (void) SyncImage(image);
-    MagickFreeMemory(tim_pixels);
-    if (EOFBlob(image))
-      {
-        ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
-          image->filename);
-        break;
-      }
-    /*
-      Proceed to next image.
-    */
-    tim_info.id=ReadBlobLSBLong(image);
-    if (tim_info.id == 0x00000010)
-      {
-        /*
-          Allocate next image structure.
-        */
-        AllocateNextImage(image_info,image);
-        if (image->next == (Image *) NULL)
+          }
+        case 24:
+          {
+            /*
+              Convert DirectColor scanline.
+            */
+            for (y=(long) image->rows-1; y >= 0; y--)
+              {
+                p=tim_pixels+y*bytes_per_line;
+                q=SetImagePixelsEx(image,0,y,image->columns,1,exception);
+                if (q == (PixelPacket *) NULL)
+                  break;
+                for (x=0; x < (long) image->columns; x++)
+                  {
+                    q->red=ScaleCharToQuantum(*p++);
+                    q->green=ScaleCharToQuantum(*p++);
+                    q->blue=ScaleCharToQuantum(*p++);
+                    q->opacity=OpaqueOpacity;
+                    q++;
+                  }
+                if (!SyncImagePixelsEx(image,exception))
+                  break;
+                if (QuantumTick(y,image->rows))
+                  {
+                    status=MagickMonitorFormatted(image->rows-y-1,image->rows,
+                                                  exception,LoadImageText,
+                                                  image->filename,
+                                                  image->columns,image->rows);
+                    if (status == False)
+                      break;
+                  }
+              }
+            break;
+          }
+        default:
           {
-            DestroyImageList(image);
-            return((Image *) NULL);
+            MagickFreeMemory(tim_pixels);
+            ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
           }
-        image=SyncNextImageInList(image);
-        status=MagickMonitorFormatted(TellBlob(image),GetBlobSize(image),
-                                      exception,LoadImagesText,
-                                      image->filename);
-        if (status == False)
+        }
+      if (image->storage_class == PseudoClass)
+        (void) SyncImage(image);
+      MagickFreeMemory(tim_pixels);
+      if (EOFBlob(image))
+        {
+          ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
+                         image->filename);
+          break;
+        }
+      /*
+        Proceed to next image.
+      */
+      if (image_info->subrange != 0)
+        if (image->scene >= (image_info->subimage+image_info->subrange-1))
           break;
-      }
-  } while (tim_info.id == 0x00000010);
+
+      tim_info.id=ReadBlobLSBLong(image);
+      if (tim_info.id == 0x00000010)
+        {
+          /*
+            Allocate next image structure.
+          */
+          AllocateNextImage(image_info,image);
+          if (image->next == (Image *) NULL)
+            {
+              DestroyImageList(image);
+              return((Image *) NULL);
+            }
+          image=SyncNextImageInList(image);
+          status=MagickMonitorFormatted(TellBlob(image),GetBlobSize(image),
+                                        exception,LoadImagesText,
+                                        image->filename);
+          if (status == False)
+            break;
+        }
+    } while (tim_info.id == 0x00000010);
   while (image->previous != (Image *) NULL)
     image=image->previous;
   CloseBlob(image);
index efc06fa..a52fa19 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 %
 % This program is covered by multiple licenses, which are described in
 % Copyright.txt. You should have received a copy of Copyright.txt with this
@@ -20,7 +20,7 @@
 %                                                                             %
 %                              Software Design                                %
 %                              Jaroslav Fojtik                                %
-%                                 June 2003                                   %
+%                                2003 - 2018                                  %
 %                                                                             %
 %                                                                             %
 %                                                                             %
@@ -48,34 +48,34 @@ typedef struct
   char Name[20];
   magick_uint16_t Rows;
   magick_uint16_t Cols;
-  magick_uint16_t FileType;    /* 0-binary, 1-8 bitu, 2-8 bits+PAL, 3-4 bits,
-                                  4-4 bits+PAL, 5-24 bits, 6-16 bits, 7-32
-                                  bits */
+  magick_uint16_t FileType;     /* 0-binary, 1-8 bitu, 2-8 bits+PAL, 3-4 bits,
+                                   4-4 bits+PAL, 5-24 bits, 6-16 bits, 7-32
+                                   bits */
   magick_uint32_t Zoom;
   magick_uint16_t Version;
-  magick_uint16_t Komprese;            /* 0 - uncompressed (from release 1) */
+  magick_uint16_t Komprese;             /* 0 - uncompressed (from release 1) */
   magick_uint16_t Stav;
   double xRasMin;
   double yRasMin;
   double xRasMax;
   double yRasMax;
-  double Scale;                        /* from release 2 */
-  magick_uint16_t TileWidth;   /* tile width in pixels */
-  magick_uint16_t TileHeight;  /* tile height in pixels */
-  magick_uint32_t TileOffsets; /* offset to array of longints that contains
-                                  adresses of tiles in the raster (adreses
-                                  are counted from 0) */
+  double Scale;                 /* from release 2 */
+  magick_uint16_t TileWidth;    /* tile width in pixels */
+  magick_uint16_t TileHeight;   /* tile height in pixels */
+  magick_uint32_t TileOffsets;  /* offset to array of longints that contains
+                                   adresses of tiles in the raster (adreses
+                                   are counted from 0) */
   magick_uint32_t TileByteCounts;/* offset to array of words, that contain amount of bytes stored in
-                                  tiles. The tile size might vary depending on
-                                  the value TileCompression */
+                                   tiles. The tile size might vary depending on
+                                   the value TileCompression */
   magick_uint8_t TileCompression;/* 0 - uncompressed, 1 - variant TIFF
-                                  Packbits, 2 - CCITT G3 */
+                                   Packbits, 2 - CCITT G3 */
 
   magick_uint8_t Dummy[423];
 } RasHeader;
 
 /*
-typedef struct                 The palette record inside TopoL
+typedef struct                  The palette record inside TopoL
 {
    BYTE Flag;
    BYTE Red;
@@ -83,7 +83,7 @@ typedef struct                        The palette record inside TopoL
    BYTE Blue;
 } paletteRAS;*/
 \f
-static void InsertRow(int depth, unsigned char *p, long y, Image * image, unsigned Xoffset, unsigned columns, ImportPixelAreaOptions *import_options)
+static int InsertRow(int depth, unsigned char *p, long y, Image * image, unsigned Xoffset, unsigned columns, ImportPixelAreaOptions *import_options)
 {
   int
     bit;
@@ -102,13 +102,12 @@ static void InsertRow(int depth, unsigned char *p, long y, Image * image, unsign
 
   switch (depth)
     {
-    case 1:                    /* Convert bitmap scanline. */
+    case 1:                     /* Convert bitmap scanline. */
       {
-       q = SetImagePixels(image, Xoffset, y, columns, 1);
-       if (q == (PixelPacket *) NULL)
-         break;
-       indexes = AccessMutableIndexes(image);
-       for (x = 0; x < ((long)columns - 7); x += 8)
+        q = SetImagePixels(image, Xoffset, y, columns, 1);
+        if(q == (PixelPacket *) NULL) return -1;
+        indexes = AccessMutableIndexes(image);
+        for (x = 0; x < ((long)columns - 7); x += 8)
           {
             for (bit = 0; bit < 8; bit++)
               {
@@ -118,7 +117,7 @@ static void InsertRow(int depth, unsigned char *p, long y, Image * image, unsign
               }
             p++;
           }
-       if ((columns % 8) != 0)
+        if ((columns % 8) != 0)
           {
             for (bit = 0; bit < (long)(columns % 8); bit++)
               {
@@ -128,20 +127,19 @@ static void InsertRow(int depth, unsigned char *p, long y, Image * image, unsign
               }
             p++;
           }
-       if (!SyncImagePixels(image))
-         break;
-       /* if (image->previous == (Image *) NULL)
-          if (QuantumTick(y,image->rows))
-          ProgressMonitor(LoadImageText,image->rows-y-1,image->rows); */
-       break;
+        if (!SyncImagePixels(image))
+          break;
+        /* if (image->previous == (Image *) NULL)
+           if (QuantumTick(y,image->rows))
+           ProgressMonitor(LoadImageText,image->rows-y-1,image->rows); */
+        break;
       }
-    case 2:                    /* Convert PseudoColor scanline. */
+    case 2:                     /* Convert PseudoColor scanline. */
       {
-       q = SetImagePixels(image, Xoffset, y, columns, 1);
-       if (q == (PixelPacket *) NULL)
-         break;
-       indexes = AccessMutableIndexes(image);
-       for (x = 0; x < ((long)columns - 1); x += 2)
+        q = SetImagePixels(image, Xoffset, y, columns, 1);
+        if(q == (PixelPacket *) NULL) return -1;
+        indexes = AccessMutableIndexes(image);
+        for (x = 0; x < ((long)columns - 1); x += 2)
           {
             index = (IndexPacket) ((*p >> 6) & 0x3);
             VerifyColormapIndex(image, index);
@@ -161,7 +159,7 @@ static void InsertRow(int depth, unsigned char *p, long y, Image * image, unsign
             *q++ = image->colormap[index];
             p++;
           }
-       if ((columns % 4) != 0)
+        if ((columns % 4) != 0)
           {
             index = (IndexPacket) ((*p >> 6) & 0x3);
             VerifyColormapIndex(image, index);
@@ -183,55 +181,53 @@ static void InsertRow(int depth, unsigned char *p, long y, Image * image, unsign
               }
             p++;
           }
-       if (!SyncImagePixels(image))
-         break;
-       /*         if (image->previous == (Image *) NULL)
+        if (!SyncImagePixels(image))
+          break;
+        /*         if (image->previous == (Image *) NULL)
                    if (QuantumTick(y,image->rows))
                    ProgressMonitor(LoadImageText,image->rows-y-1,image->rows); */
-       break;
+        break;
       }
 
-    case 4:                    /* Convert PseudoColor scanline. */
+    case 4:                     /* Convert PseudoColor scanline. */
       {
-       q = SetImagePixels(image, Xoffset, y, columns, 1);
-       if (q == (PixelPacket *) NULL)
-         break;
-       indexes = AccessMutableIndexes(image);
-       for (x = 0; x < ((long)columns - 1); x += 2)
+        q = SetImagePixels(image, Xoffset, y, columns, 1);
+        if(q == (PixelPacket *) NULL) return -1;
+        indexes = AccessMutableIndexes(image);
+        for (x = 0; x < ((long)columns - 1); x += 2)
           {
-            index = (IndexPacket) ((*p >> 4) & 0xF);   /* Lo nibble */
+            index = (IndexPacket) ((*p >> 4) & 0xF);    /* Lo nibble */
             VerifyColormapIndex(image, index);
             indexes[x] = index;
             *q++ = image->colormap[index];
-            index = (IndexPacket) ((*p) & 0xF);                /* Hi nibble */
+            index = (IndexPacket) ((*p) & 0xF);         /* Hi nibble */
             VerifyColormapIndex(image, index);
             indexes[x + 1] = index;
             *q++ = image->colormap[index];
             p++;
           }
-       if((columns % 2) != 0)
+        if((columns % 2) != 0)
           {
-            index = (IndexPacket) ((*p >> 4) & 0xF);   /* padding nibble */
+            index = (IndexPacket) ((*p >> 4) & 0xF);    /* padding nibble */
             VerifyColormapIndex(image, index);
             indexes[x] = index;
             *q++ = image->colormap[index];
             p++;
           }
-       if (!SyncImagePixels(image))
-         break;
-       /*         if (image->previous == (Image *) NULL)
+        if (!SyncImagePixels(image))
+          break;
+        /*         if (image->previous == (Image *) NULL)
                    if (QuantumTick(y,image->rows))
                    ProgressMonitor(LoadImageText,image->rows-y-1,image->rows); */
-       break;
+        break;
       }
-    case 8:                    /* Convert PseudoColor scanline. */
+    case 8:                     /* Convert PseudoColor scanline. */
       {
-       q = SetImagePixels(image, Xoffset, y, columns, 1);
-       if (q == (PixelPacket *) NULL)
-         break;
-       indexes = AccessMutableIndexes(image);
+        q = SetImagePixels(image, Xoffset, y, columns, 1);
+        if(q == (PixelPacket *) NULL) return -1;
+        indexes = AccessMutableIndexes(image);
 
-       for (x = 0; x < (long)columns; x++)
+        for (x = 0; x < (long)columns; x++)
           {
             index = (IndexPacket) (*p);
             VerifyColormapIndex(image, index);
@@ -239,52 +235,51 @@ static void InsertRow(int depth, unsigned char *p, long y, Image * image, unsign
             *q++ = image->colormap[index];
             p++;
           }
-       if (!SyncImagePixels(image))
-         break;
-       /*           if (image->previous == (Image *) NULL)
+        if (!SyncImagePixels(image))
+          break;
+        /*           if (image->previous == (Image *) NULL)
                      if (QuantumTick(y,image->rows))
                      ProgressMonitor(LoadImageText,image->rows-y-1,image->rows); */
       }
       break;
 
-    case 16:           /* Convert 16 bit Gray scanline. */
+    case 16:            /* Convert 16 bit Gray scanline. */
       q = SetImagePixels(image, Xoffset, y, columns, 1);
-      if (q == (PixelPacket *) NULL)
-         break;        
+      if(q == (PixelPacket *) NULL) return -1;
       (void)ImportImagePixelArea(image,GrayQuantum,16,p,import_options,0);
       if(!SyncImagePixels(image)) break;
       break;
 
-    case 24:           /* Convert RGB scanline. */
+    case 24:            /* Convert RGB scanline. */
       q = SetImagePixels(image, Xoffset, y, columns, 1);
-      if (q == (PixelPacket *) NULL)
-         break;        
+      if(q == (PixelPacket *) NULL) return -1;
       (void)ImportImagePixelArea(image,RGBQuantum,8,p,import_options,0);
       if(!SyncImagePixels(image)) break;
       break;
 
-    case 32:           /* Convert 32 bit Gray scanline. */
+    case 32:            /* Convert 32 bit Gray scanline. */
       q = SetImagePixels(image, Xoffset, y, columns, 1);
-      if (q == (PixelPacket *) NULL)
-         break;        
+      if(q == (PixelPacket *) NULL) return -1;
       (void)ImportImagePixelArea(image,GrayQuantum,32,p,import_options,0);
       if(!SyncImagePixels(image)) break;
       break;
-      
+
     }
+
+  return 0;
 }
 
 
 /* This function reads one block of unsigned longS */
-static void ReadBlobDwordLSB(Image *image, size_t len, magick_uint32_t *data)
+static int ReadBlobDwordLSB(Image *image, size_t len, magick_uint32_t *data)
 {
-  while (len >= 4)
-    {
-      *data++ = ReadBlobLSBLong(image);
-      len -= 4;
-    }
-  if (len > 0)
-    (void) SeekBlob(image, len, SEEK_CUR);
+  if(ReadBlob(image, len, data) != len) return -1;
+
+#if defined(WORDS_BIGENDIAN)
+  MagickSwabArrayOfUInt32(data, len/4);
+#endif
+
+  return 0;
 }
 \f
 /*
@@ -319,12 +314,13 @@ static void ReadBlobDwordLSB(Image *image, size_t len, magick_uint32_t *data)
 %
 */
 
-#define ThrowPDBReaderException(code_,reason_,image_) \
+#define ThrowTOPOLReaderException(code_,reason_,image_) \
 { \
   if (clone_info) \
     DestroyImageInfo(clone_info); \
   if (palette) \
     DestroyImage(palette); \
+  MagickFreeMemory(BImgBuff); \
   ThrowReaderException(code_,reason_,image_); \
 }
 
@@ -332,10 +328,10 @@ static Image *ReadTOPOLImage(const ImageInfo * image_info, ExceptionInfo * excep
 {
   Image
     *image,
-    *palette;
+    *palette = (Image *) NULL;
 
   ImageInfo
-    *clone_info;
+    *clone_info = (ImageInfo *) NULL;
 
   RasHeader
     Header;
@@ -343,8 +339,8 @@ static Image *ReadTOPOLImage(const ImageInfo * image_info, ExceptionInfo * excep
   int logging;
 
   int
-    depth,    
-    status;    
+    depth,
+    status;
 
   long
     i,
@@ -368,7 +364,7 @@ static Image *ReadTOPOLImage(const ImageInfo * image_info, ExceptionInfo * excep
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
 
-  logging = LogMagickEvent(CoderEvent,GetMagickModule(),"enter"); 
+  logging = LogMagickEvent(CoderEvent,GetMagickModule(),"enter");
 
   image = AllocateImage(image_info);
   status = OpenBlob(image_info, image, ReadBinaryBlobMode, exception);
@@ -384,11 +380,14 @@ static Image *ReadTOPOLImage(const ImageInfo * image_info, ExceptionInfo * excep
   */
   (void) memset(&Header, 0, sizeof(Header));
   (void) ReadBlob(image, 20, &Header.Name);
+
   Header.Rows = ReadBlobLSBShort(image);
   Header.Cols = ReadBlobLSBShort(image);
   Header.FileType = ReadBlobLSBShort(image);
   Header.Zoom = ReadBlobLSBLong(image);
   Header.Version = ReadBlobLSBShort(image);
+  if (EOFBlob(image))
+    ThrowTOPOLReaderException(CorruptImageError,UnexpectedEndOfFile,image);
   if (Header.Version >= 1)
     {
       Header.Komprese = ReadBlobLSBShort(image);
@@ -397,7 +396,7 @@ static Image *ReadTOPOLImage(const ImageInfo * image_info, ExceptionInfo * excep
       Header.yRasMin = ReadBlobLSBDouble(image);
       Header.xRasMax = ReadBlobLSBDouble(image);
       Header.yRasMax = ReadBlobLSBDouble(image);
-      if (Header.Version >= 2) /* from release 2 */
+      if (Header.Version >= 2)  /* from release 2 */
         {
           Header.Scale = ReadBlobLSBDouble(image);
           Header.TileWidth = ReadBlobLSBShort(image);
@@ -407,19 +406,26 @@ static Image *ReadTOPOLImage(const ImageInfo * image_info, ExceptionInfo * excep
           Header.TileCompression = ReadBlobByte(image);
           /* BYTE Dummy[423]; */
         }
+      if (EOFBlob(image))
+        ThrowTOPOLReaderException(CorruptImageError,UnexpectedEndOfFile,image);
     }
 
   for (i = 0; i < (long) sizeof(Header.Name); i++)
     {
       if (Header.Name[i] < ' ')
-TOPOL_KO:              ThrowPDBReaderException(CorruptImageError,ImproperImageHeader, image);
+TOPOL_KO:              ThrowTOPOLReaderException(CorruptImageError,ImproperImageHeader, image);
     }
   if (Header.Komprese != 0 || (Header.Version >= 2 && Header.TileCompression != 0))
-    ThrowPDBReaderException(CorruptImageError, UnrecognizedImageCompression, image);
-  if (Header.Rows == 0 || Header.Cols == 0)
-    goto TOPOL_KO;
+    ThrowTOPOLReaderException(CorruptImageError, UnrecognizedImageCompression, image);
+  if (((Header.Rows == 0 || Header.Cols == 0)) ||
+      ((Header.Version >= 2) &&
+       (Header.TileWidth == 0 ||
+        Header.TileHeight == 0 ||
+        Header.TileOffsets == 0 ||
+        Header.TileByteCounts == 0)))
+      ThrowTOPOLReaderException(CorruptImageError,ImproperImageHeader, image);
   if (Header.Version > 2)
-    ThrowPDBReaderException(CorruptImageError, InvalidFileFormatVersion, image); /* unknown version */
+    ThrowTOPOLReaderException(CorruptImageError, InvalidFileFormatVersion, image); /* unknown version */
 
   switch(Header.FileType)
     {
@@ -445,11 +451,11 @@ TOPOL_KO:              ThrowPDBReaderException(CorruptImageError,ImproperImageHe
     case 6:
       image->colors = 0;
       depth = 16;
-      break;                   /* ????????? 16 bits */
+      break;                    /* ????????? 16 bits */
     case 7:
       image->colors = 0;
       depth = 32;
-      break;                   /* ????????? 32 bits */
+      break;                    /* ????????? 32 bits */
     default:
       goto TOPOL_KO;
     }
@@ -457,6 +463,11 @@ TOPOL_KO:              ThrowPDBReaderException(CorruptImageError,ImproperImageHe
   image->columns = Header.Cols;
   image->rows = Header.Rows;
 
+  i = GetBlobSize(image);
+  if(i>0)
+    if(((magick_uint64_t)8*Header.Cols*(magick_uint64_t)Header.Rows) / image->depth > (magick_uint64_t)GetBlobSize(image))
+      goto TOPOL_KO;    /* Check for forged image that overflows file size. */
+
   /* If ping is true, then only set image size and colors without reading any image data. */
   if (image_info->ping) goto DONE_READING;
 
@@ -464,19 +475,19 @@ TOPOL_KO:              ThrowPDBReaderException(CorruptImageError,ImproperImageHe
   j = image->colors;
   if(j<=0 || j>256) j=256;
   for(i=0; i<j; i++)
-  {    
+  {
     MEZ[i] = (unsigned char)((i*256)/j);
   }
-    
-  if(Header.FileType>=5) goto NoMEZ;    
-    
+
+  if(Header.FileType>=5) goto NoMEZ;
+
   if ((clone_info=CloneImageInfo(image_info)) == NULL) goto NoMEZ;
-  
+
   i=(long) strlen(clone_info->filename);
   j=i;
   while(--i>0)
     {
-      if(clone_info->filename[i]=='.') 
+      if(clone_info->filename[i]=='.')
       {
         break;
       }
@@ -486,31 +497,34 @@ TOPOL_KO:              ThrowPDBReaderException(CorruptImageError,ImproperImageHe
         break;
       }
     }
-  
-  (void) strcpy(clone_info->filename+i,".MEZ");
+
+  if (i <= 0)
+    goto NoPalette;
+
+  (void) strlcpy(clone_info->filename+i,".MEZ",sizeof(clone_info->filename)-i);
   if((clone_info->file=fopen(clone_info->filename,"rb"))==NULL)
     {
-      (void) strcpy(clone_info->filename+i,".mez");
+      (void) strlcpy(clone_info->filename+i,".mez",sizeof(clone_info->filename)-i);
       if((clone_info->file=fopen(clone_info->filename,"rb"))==NULL)
         {
           DestroyImageInfo(clone_info);
           clone_info=NULL;
-          goto NoMEZ;            
+          goto NoMEZ;
         }
     }
 
   if( (palette=AllocateImage(clone_info))==NULL ) goto NoMEZ;
   status=OpenBlob(clone_info,palette,ReadBinaryBlobMode,exception);
-  if (status == False) goto NoMEZ; 
+  if (status == False) goto NoMEZ;
 
   ldblk=(long) GetBlobSize(palette);
   if ( ldblk > (long) sizeof(MEZ))
     ldblk=sizeof(MEZ);
-  (void) ReadBlob(palette, ldblk, MEZ); 
-            
-NoMEZ:         /*Clean up palette and clone_info*/
+  (void) ReadBlob(palette, ldblk, MEZ);
+
+NoMEZ:          /*Clean up palette and clone_info*/
   if (palette != NULL) {DestroyImage(palette);palette=NULL;}
-  if (clone_info != NULL) 
+  if (clone_info != NULL)
     {
       DestroyImageInfo(clone_info);
       clone_info=NULL;
@@ -519,31 +533,34 @@ NoMEZ:            /*Clean up palette and clone_info*/
   /* ----- Do something with palette ----- */
   if(Header.FileType==5) goto NoPalette;
   if ((clone_info=CloneImageInfo(image_info)) == NULL) goto NoPalette;
+
   i=(long) strlen(clone_info->filename);
   j=i;
   while(--i>0)
     {
-      if(clone_info->filename[i]=='.') 
+      if(clone_info->filename[i]=='.')
         {
           break;
         }
       if(clone_info->filename[i]=='/' || clone_info->filename[i]=='\\' ||
-         clone_info->filename[i]==':' ) 
+         clone_info->filename[i]==':' )
         {
           i=j;
           break;
         }
     }
-  
-  (void) strcpy(clone_info->filename+i,".PAL");
-  if((clone_info->file=fopen(clone_info->filename,"rb"))==NULL)
+
+  if (i <= 0)
+    goto NoPalette;
+
+  (void) strlcpy(clone_info->filename+i,".PAL",sizeof(clone_info->filename)-i);
+  if ((clone_info->file=fopen(clone_info->filename,"rb"))==NULL)
     {
-      (void) strcpy(clone_info->filename+i,".pal");
-      if((clone_info->file=fopen(clone_info->filename,"rb"))==NULL)
+      (void) strlcpy(clone_info->filename+i,".pal",sizeof(clone_info->filename)-i);
+      if ((clone_info->file=fopen(clone_info->filename,"rb"))==NULL)
         {
           clone_info->filename[i]=0;
-          if((clone_info->file=fopen(clone_info->filename,"rb"))==NULL) 
+          if ((clone_info->file=fopen(clone_info->filename,"rb"))==NULL)
             {
               DestroyImageInfo(clone_info);
               clone_info=NULL;
@@ -556,31 +573,31 @@ NoMEZ:            /*Clean up palette and clone_info*/
   status=OpenBlob(clone_info,palette,ReadBinaryBlobMode,exception);
   if (status == False)
     {
-    ErasePalette:     
+    ErasePalette:
       DestroyImage(palette);
       palette=NULL;
       goto NoPalette;
     }
-     
+
+
   if(palette!=NULL)
     {
-      ldblk=ReadBlobByte(palette);             /*size of palette*/
+      ldblk=ReadBlobByte(palette);              /*size of palette*/
       if(ldblk==EOF) goto ErasePalette;
-      image->colors=ldblk+1;    
+      image->colors=ldblk+1;
       if (!AllocateImageColormap(image, image->colors)) goto NoMemory;
-    
+
       for(i=0;i<=ldblk;i++)
-      {     
-        j = ReadBlobByte(palette);     /* Flag */
-        if(j==EOF) break;              /* unexpected end of file */
+      {
+        j = ReadBlobByte(palette);      /* Flag */
+        if(j==EOF) break;               /* unexpected end of file */
         if(j<=ldblk)
         {
-         if(j==MEZ[i])
-           j = i; /* MEZ[i];   ignore MEZ!!! proper palete element after reindexing */ 
+          if(j==MEZ[i])
+            j = i; /* MEZ[i];   ignore MEZ!!! proper palete element after reindexing */
           else
-            j = MEZ[i];                        /* ?? I do not know, big mess ?? */
-         if(j>=(long) image->colors) j=image->colors-1;
+            j = MEZ[i];                 /* ?? I do not know, big mess ?? */
+          if(j>=(long) image->colors) j=image->colors-1;
           image->colormap[j].red = ScaleCharToQuantum(ReadBlobByte(palette));
           image->colormap[j].green = ScaleCharToQuantum(ReadBlobByte(palette));
           image->colormap[j].blue = ScaleCharToQuantum(ReadBlobByte(palette));
@@ -589,7 +606,7 @@ NoMEZ:              /*Clean up palette and clone_info*/
         {
           (void) SeekBlob(palette, 3, SEEK_CUR);
           (void) fprintf(stderr,"TopoL: Wrong index inside palette %d!",(int)j);
-        } 
+        }
       }
     }
 
@@ -601,12 +618,12 @@ NoPalette:
       if (!AllocateImageColormap(image, image->colors))
       {
         NoMemory:
-          ThrowPDBReaderException(ResourceLimitError, MemoryAllocationFailed, image);
+          ThrowTOPOLReaderException(ResourceLimitError, MemoryAllocationFailed, image);
       }
 
       for(i = 0; i < (long) image->colors; i++)
       {
-       j = MEZ[i];
+        j = MEZ[i];
         image->colormap[i].red = ScaleCharToQuantum(j);
         image->colormap[i].green = ScaleCharToQuantum(j);
         image->colormap[i].blue = ScaleCharToQuantum(j);
@@ -614,19 +631,19 @@ NoPalette:
     }
   }
 
-  /* ----- Load TopoL raster ----- */    
+  /* ----- Load TopoL raster ----- */
   switch(Header.Version)
   {
    case 0:
    case 1:
      ldblk = (long) ((depth * image->columns + 7) / 8);
-     BImgBuff = MagickAllocateMemory(unsigned char *,(size_t) ldblk);  /*Ldblk was set in the check phase */
+     BImgBuff = MagickAllocateMemory(unsigned char *,(size_t) ldblk);   /*Ldblk was set in the check phase */
      if (BImgBuff == NULL)
-        ThrowPDBReaderException(ResourceLimitError, MemoryAllocationFailed, image);
+        ThrowTOPOLReaderException(ResourceLimitError, MemoryAllocationFailed, image);
      (void) SeekBlob(image, 512 /*sizeof(Header)*/, SEEK_SET);
      for (i = 0; i < (int) Header.Rows; i++)
      {
-       (void)ReadBlob(image, ldblk, (char *)BImgBuff);       
+       (void)ReadBlob(image, ldblk, (char *)BImgBuff);
        InsertRow(depth, BImgBuff, i, image, 0, image->columns, &import_options);
      }
      break;
@@ -639,44 +656,71 @@ NoPalette:
       unsigned TilesDown   = (Header.Rows+Header.TileHeight-1) / Header.TileHeight;
 
       if(Header.TileCompression!=0)
-               {
-               ThrowPDBReaderException(CorruptImageError, UnrecognizedImageCompression, image);
-               break;
-               }
+                {
+                ThrowTOPOLReaderException(CorruptImageError, UnrecognizedImageCompression, image);
+                break;
+                }
 
        ldblk = (long)((depth * Header.TileWidth + 7) / 8);
-       BImgBuff = MagickAllocateMemory(unsigned char *,(size_t) ldblk);        /*Ldblk was set in the check phase */
+       BImgBuff = MagickAllocateMemory(unsigned char *,(size_t) ldblk); /*Ldblk was set in the check phase */
+       if (BImgBuff == NULL)
+         ThrowTOPOLReaderException(ResourceLimitError, MemoryAllocationFailed, image);
 
        /* dlazdice.create(Header.TileWidth,Header.TileHeight,p.Planes); */
-       Offsets = MagickAllocateMemory(magick_uint32_t *,(size_t)TilesAcross*TilesDown*sizeof(magick_uint32_t));
+       Offsets = MagickAllocateArray(magick_uint32_t *,
+                                     MagickArraySize((size_t)TilesAcross,(size_t)TilesDown),
+                                     sizeof(magick_uint32_t));
        if(Offsets==NULL)
-         ThrowPDBReaderException(ResourceLimitError, MemoryAllocationFailed, image);         
+         ThrowTOPOLReaderException(ResourceLimitError, MemoryAllocationFailed, image);
 
        (void)SeekBlob(image, Header.TileOffsets, SEEK_SET);
-       ReadBlobDwordLSB(image, TilesAcross*TilesDown*4, (magick_uint32_t *)Offsets);
+       if(ReadBlobDwordLSB(image, TilesAcross*TilesDown*4, (magick_uint32_t *)Offsets) < 0)
+       {
+         MagickFreeMemory(Offsets);
+         ThrowTOPOLReaderException(CorruptImageError,InsufficientImageDataInFile, image);
+       }
 
        for(TilY=0;TilY<Header.Rows;TilY+=Header.TileHeight)
-        for(TilX=0;TilX<TilesAcross;TilX++)
-          {
-          ldblk = image->columns - TilX*Header.TileWidth;
-
-          if(ldblk>Header.TileWidth) ldblk = Header.TileWidth;
-          SkipBlk = ((long)depth * (Header.TileWidth-ldblk)+7) / 8;
-          ldblk = ((long)depth * ldblk+7) / 8;
-
-           (void)SeekBlob(image, Offsets[(TilY/Header.TileHeight)*TilesAcross+TilX], SEEK_SET);           
-          j = TilX * (ldblk+SkipBlk);
-          for(i=0;i<Header.TileHeight;i++)
-          {
-             (void)ReadBlob(image, ldblk, (char *)BImgBuff);
+         for(TilX=0;TilX<TilesAcross;TilX++)
+           {
+           ldblk = Offsets[(TilY/Header.TileHeight)*TilesAcross+TilX];
+           if(SeekBlob(image, ldblk, SEEK_SET) != ldblk)
+             {                                                  /* When seek does not reach required place, bail out. */
+               MagickFreeMemory(Offsets);
+               ThrowTOPOLReaderException(CorruptImageError,InsufficientImageDataInFile, image);
+               break;
+             }
+
+           ldblk = image->columns - TilX*Header.TileWidth;
+
+           if(ldblk>Header.TileWidth) ldblk = Header.TileWidth;
+           SkipBlk = ((long)depth * (Header.TileWidth-ldblk)+7) / 8;
+           ldblk = ((long)depth * ldblk+7) / 8;
+
+           j = TilX * (ldblk+SkipBlk);
+           for(i=0;i<Header.TileHeight;i++)
+           {                                    /* It appears that tile padding is legal in Topol format. */
+             if((unsigned long) i+TilY>=image->rows) break;     /* Do not read padding tile data, abort the current tile. */
+
+             if(ReadBlob(image, ldblk, (char *)BImgBuff) != (size_t) ldblk)
+             {
+               MagickFreeMemory(Offsets);
+               ThrowTOPOLReaderException(CorruptImageError,InsufficientImageDataInFile, image);
+               break;
+             }
              if(SkipBlk>0)
                SeekBlob(image, SkipBlk, SEEK_CUR);
-            InsertRow(depth, BImgBuff, i+TilY, image, TilX, 
-                    (image->columns<Header.TileWidth)?image->columns:Header.TileWidth, &import_options);
-          }          
-       }
+             if(InsertRow(depth, BImgBuff, i+TilY, image, TilX,
+                    (image->columns<Header.TileWidth)?image->columns:Header.TileWidth, &import_options))
+             {
+               MagickFreeMemory(Offsets);
+               ThrowTOPOLReaderException(CorruptImageError,TooMuchImageDataInFile, image);
+               break;
+             }
+          }
+        }
 
-       if(Offsets) {MagickFreeMemory(Offsets);Offsets=NULL;}
+       MagickFreeMemory(Offsets);
        break;
       }
     }
@@ -684,14 +728,13 @@ NoPalette:
 
   /* Finish: */
 DONE_READING:
-  if (BImgBuff != NULL)
-    MagickFreeMemory(BImgBuff);
+  MagickFreeMemory(BImgBuff);
   if (palette != NULL)
     DestroyImage(palette);
   if (clone_info != NULL)
     DestroyImageInfo(clone_info);
   /* if (EOFBlob(image))
-     ThrowPDBReaderException(CorruptImageError,UnexpectedEndOfFile,image); */
+     ThrowTOPOLReaderException(CorruptImageError,UnexpectedEndOfFile,image); */
   CloseBlob(image);
 
   if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),"return");
index 75bf7e8..6432325 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -32,7 +32,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 % Patterns accepted:
-%     0,0: 129,129,129,255 
+%     0,0: 129,129,129,255
 %     0,0: 129,129,129
 %     0,0: (129,129,129) #818181
 %     0,0: (3411594072,2774050136,1883729991) #CB58CB58A558A55870477047
@@ -108,6 +108,9 @@ static long ReadInt(Image *image, int *pch)
   long
     n;
 
+  unsigned int
+    digits;
+
   n=0;
   if (pch)
     ch=*pch;
@@ -118,15 +121,17 @@ static long ReadInt(Image *image, int *pch)
     {
       ch = ReadBlobByte(image);
       if (ch == EOF)
-       return (0);
+        return (0);
     }
 
-  while (isdigit(ch))
+  digits=0;
+  while ((digits < 10) && isdigit(ch))
     {
       n=10*n+(ch-'0');
       ch = ReadBlobByte(image);
       if (ch == EOF)
-       return (n);
+        return (n);
+      digits++;
     }
 
   if (pch)
@@ -343,56 +348,60 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
       } while (0);
 
       unsigned
-       x,
-       y;
+        x,
+        y;
 
       unsigned
-       x_min,
-       x_max,
-       y_curr;
+        x_min,
+        x_max,
+        y_curr;
 
       int
-       ch;
+        ch;
 
       unsigned long
-       max,
-       i;
+        max,
+        i;
 
       char
-       NumOfPlanes;
+        NumOfPlanes;
 
       unsigned char
-       *BImgBuff=0;
+        *BImgBuff=0;
 
       magick_uint16_t
-       *WImgBuff;
+        *WImgBuff;
 
       magick_uint32_t
-       *DImgBuff;
+        *DImgBuff;
 
       magick_uint32_t
-       R,
-       G,
-       B,
-       A;
+        R,
+        G,
+        B,
+        A;
 
-      const PixelPacket
-       *q;
+      PixelPacket
+        *q;
 
       ExtendedSignedIntegralType NextImagePos = 0;
 
       ImportPixelAreaOptions
-       import_options;
+        import_options;
 
       if (logging)
-       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "File RAW TXT type: %d", (int) txt_subformat);
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "File RAW TXT type: %d", (int) txt_subformat);
 
       do {
         (void) SeekBlob(image,NextImagePos,SEEK_SET);
 
         if(NextImagePos!=0)
           {
+            if (image_info->subrange != 0)
+              if (image->scene >= (image_info->subimage+image_info->subrange-1))
+                break;
+
             /* Allocate next image structure. */
             AllocateNextImage(image_info,image);
             if(image->next == (Image *)NULL) break;
@@ -415,8 +424,8 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
           case TXT_GM16B_HEX:
           case TXT_GM16B_HEX_Q:
             max=65535;
-            break;     
-          case TXT_GM32B_HEX:  
+            break;
+          case TXT_GM32B_HEX:
           case TXT_GM32B_HEX_Q:
             max=65536;
             break;
@@ -450,7 +459,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
         ch=0;
         if (x == 0 && y == 0)
-          while (!EOFBlob(image))      /* auto detect sizes and num of planes */
+          while (!EOFBlob(image))       /* auto detect sizes and num of planes */
             {
               while (!(ch >= '0' && ch <= '9'))
                 {
@@ -458,7 +467,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   ch = ReadBlobByte(image);
                   if (ch == EOF)
                     goto EndReading;
-                  if (ch == '#') 
+                  if (ch == '#')
                     {
                       readln(image,&ch);
                       continue;
@@ -467,17 +476,17 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       (ch >= 'a' && ch <= 'z') ||
                       (ch >= 'A' && ch <= 'Z'))
                     {
-                    TXT_FAIL:                  /* not a text data */
+                    TXT_FAIL:                   /* not a text data */
                       ThrowNOTXTReaderException(CoderError,ImageTypeNotSupported,image);
                     }
                 }
               /* x,y: (R,G,B) */
-              x_min = ReadInt(image,&ch);              /* x */      
+              x_min = ReadInt(image,&ch);               /* x */
               if (x_min > x)
                 x = x_min;
 
               while (ch != ',')
-                {  
+                {
                   ch = ReadBlobByte(image);
                   if (ch==EOF)
                     break;
@@ -485,11 +494,11 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
                     goto TXT_FAIL;
                 }
               ch=0;
-              i=ReadInt(image,&ch);            /* y */
+              i=ReadInt(image,&ch);             /* y */
 
               /* Check for next image start. */
-              if(x_min==0 && i==0 && x>0 && y>0) 
-               goto EndReading;
+              if(x_min==0 && i==0 && x>0 && y>0)
+                goto EndReading;
 
               if (i > y)
                 y=i;
@@ -512,12 +521,12 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
                       break;
                   }
               ch=0;
-              R = ReadInt(image,&ch);          /* R */
+              R = ReadInt(image,&ch);           /* R */
               if (R > max)
                 max=R;
 
               while (ch != ',')
-                { 
+                {
                   ch = ReadBlobByte(image);
                   if (ch == 10 || ch == 13)
                     goto TXT_FAIL;
@@ -525,7 +534,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
                     break;
                 }
               ch=0;
-              G = ReadInt(image,&ch);          /* G */
+              G = ReadInt(image,&ch);           /* G */
               if (G > max)
                 max=G;
 
@@ -538,7 +547,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
                     break;
                 }
               ch=0;
-              B = ReadInt(image,&ch);          /* B */
+              B = ReadInt(image,&ch);           /* B */
               if (B > max)
                 max=B;
 
@@ -553,7 +562,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
                         break;
                     }
                   ch=0;
-                  A = ReadInt(image,&ch);              /* A */
+                  A = ReadInt(image,&ch);               /* A */
                   if (A > max)
                     max=A;
                 }
@@ -587,26 +596,66 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
         if (logging)
           (void)LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "Image detected [%u * %u]: %d", x, y, NumOfPlanes);
+                               "Image detected[%lu] [%u * %u]: %d", image->scene, x, y, NumOfPlanes);
 
         image->depth = Min(QuantumDepth,NumOfPlanes);
         ImportPixelAreaOptionsInit(&import_options);
         import_options.endian = NativeEndian;
-  
+
+        image->columns = x+1;
+        image->rows = y+1;
+        if (logging)
+          (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+                               "Image Geometry: %lux%lu", image->columns, image->rows);
+
+        if (CheckImagePixelLimits(image, exception) != MagickPass)
+          ThrowNOTXTReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+
+        /*
+          Validate that file size is sufficient for claimed image properties
+        */
+        if (BlobIsSeekable(image))
+          {
+            magick_off_t
+              file_size;
+
+            if ((file_size=GetBlobSize(image)) != 0)
+              {
+                double
+                  ratio;
+
+                double
+                  packet_size=40.0;  /* Max characters in a row */
+
+                double
+                  number_pixels=image->columns*image->rows;
+
+                ratio = (((double) number_pixels*packet_size)/file_size);
+
+                if (ratio > 2.0)
+                  {
+                    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                          "Unreasonable file size "
+                                          "(ratio of pixels to file size %g)",
+                                          ratio);
+                    ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,
+                                         image);
+                  }
+              }
+          }
+
+        /* Assure that all image pixels are initialized to black */
+        SetImage(image,OpaqueOpacity);
+
         BImgBuff = MagickAllocateArray(unsigned char *,
                                        (size_t)(x+1),
                                        ( ((image->matte) ? 4 : 3)
                                          * NumOfPlanes/8));
         WImgBuff = (magick_uint16_t *)BImgBuff;
-        DImgBuff = (magick_uint32_t *)BImgBuff;  
-        if (BImgBuff == NULL) 
+        DImgBuff = (magick_uint32_t *)BImgBuff;
+        if (BImgBuff == NULL)
           ThrowNOTXTReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-  
-        image->columns = x+1;
-        image->rows = y+1;
 
-        if (CheckImagePixelLimits(image, exception) != MagickPass)
-          ThrowNOTXTReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
 
         (void) SeekBlob(image,NextImagePos,SEEK_SET);
         NextImagePos = 0;
@@ -623,23 +672,29 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 if (EOFBlob(image))
                   goto FINISH;
                 ch = ReadBlobByte(image);
-                if (ch == '#') 
+                if (ch == '#')
                   {
                     readln(image,&ch);
                     continue;
                   }
+                if (ch == 0 || ch > 128 ||     /* Duplicate image check for data with fixed geometry previous check is skipped. */
+                      (ch >= 'a' && ch <= 'z') ||
+                      (ch >= 'A' && ch <= 'Z'))
+                {                                 /* not a text data */
+                  ThrowNOTXTReaderException(CoderError,ImageTypeNotSupported,image);
+                }
               }
-    
-            x = ReadInt(image,&ch);            /* x */
+
+            x = ReadInt(image,&ch);             /* x */
 
             while (ch != ',')
               {
-                ch = ReadBlobByte(image);       
+                ch = ReadBlobByte(image);
                 if (ch == EOF)
                   break;
               }
             ch = 0;
-            y = ReadInt(image,&ch);            /* y */
+            y = ReadInt(image,&ch);             /* y */
 
             /* New image detected. */
             if(x==0 && y==0 && y_curr>0 && x_max>0)
@@ -661,7 +716,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   break;
               }
             ch=0;
-            R = ReadInt(image,&ch);            /* R */
+            R = ReadInt(image,&ch);             /* R */
 
             while (ch != ',')
               {
@@ -670,7 +725,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   break;
               }
             ch=0;
-            G = ReadInt(image,&ch);            /* G */
+            G = ReadInt(image,&ch);             /* G */
 
             while (ch != ',')
               {
@@ -679,18 +734,18 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
                   break;
               }
             ch=0;
-            B = ReadInt(image,&ch);            /* B */
+            B = ReadInt(image,&ch);             /* B */
 
             if (image->matte)
               {
                 while (ch != ',')
                   {
-                    ch = ReadBlobByte(image);       
+                    ch = ReadBlobByte(image);
                     if (ch == EOF)
                       break;
                   }
                 ch=0;
-                A = ReadInt(image,&ch);                /* A */
+                A = ReadInt(image,&ch);         /* A */
                 if (A > max)
                   max=A;
               }
@@ -750,7 +805,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
                         DImgBuff[2+4*x] = B;
                         DImgBuff[3+4*x] = 4294967295U-A;
                         break;
-                      }    
+                      }
                   }
                 else
                   {
@@ -771,7 +826,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
                         DImgBuff[1+3*x] = G;
                         DImgBuff[2+3*x] = B;
                         break;
-                      }    
+                      }
                   }
                 if (x_min > x_max)
                   {
@@ -792,10 +847,10 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
       FINISH:
         if (x_min <= x_max)
           {
-            q = SetImagePixels(image,x_min,y_curr,x_max-x_min+1,1);      
+            q = SetImagePixels(image,x_min,y_curr,x_max-x_min+1,1);
             if (q != (PixelPacket *)NULL)
               {
-                if (image->matte)        
+                if (image->matte)
                   (void)ImportImagePixelArea(image, RGBAQuantum, NumOfPlanes,
                                              BImgBuff + 4*x_min*(NumOfPlanes/8),
                                              &import_options, 0);
@@ -814,7 +869,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
           }
         /* Note that DImgBuff and WImgBuff point to BImgBuff */
         MagickFreeMemory(BImgBuff);
-      } while(!EOFBlob(image) && NextImagePos>0);      
+      } while(!EOFBlob(image) && NextImagePos>0);
 
       goto FINISH_TXT;
     }
@@ -844,10 +899,10 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
     DrawInfo
       *draw_info = (DrawInfo *) NULL;
-    
+
     RectangleInfo
       page;
-    
+
     TypeMetric
       metrics;
 
@@ -858,14 +913,14 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
     dy_resolution=72.0;
     if ((image->x_resolution == 0.0) || (image->y_resolution == 0.0))
       {
-       char
-         density[MaxTextExtent];
-
-       (void) strlcpy(density,PSDensityGeometry,sizeof(density));
-       count=GetMagickDimension(density,&image->x_resolution,
-                                &image->y_resolution,NULL,NULL);
-       if (count != 2)
-         image->y_resolution=image->x_resolution;
+        char
+          density[MaxTextExtent];
+
+        (void) strlcpy(density,PSDensityGeometry,sizeof(density));
+        count=GetMagickDimension(density,&image->x_resolution,
+                                 &image->y_resolution,NULL,NULL);
+        if (count != 2)
+          image->y_resolution=image->x_resolution;
       }
     SetGeometry(image,&page);
     page.width=612;
@@ -873,11 +928,11 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
     (void) GetGeometry("612x792+43+43",&page.x,&page.y,&page.width,&page.height);
     if (image_info->page != (char *) NULL)
       (void) GetGeometry(image_info->page,&page.x,&page.y,&page.width,
-                        &page.height);
+                         &page.height);
     if (logging)
       (void)LogMagickEvent(CoderEvent,GetMagickModule(),
-                          "Page Geometry: %lux%lu%+ld%+ld",
-                          page.width,page.height,page.x,page.y);
+                           "Page Geometry: %lux%lu%+ld%+ld",
+                           page.width,page.height,page.x,page.y);
     /*
       Initialize Image structure.
     */
@@ -892,15 +947,15 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
     texture=(Image *) NULL;
     if (image_info->texture != (char *) NULL)
       {
-       ImageInfo
-         *clone_info;
-
-       clone_info=CloneImageInfo(image_info);
-       clone_info->blob=(void *) NULL;
-       clone_info->length=0;
-       (void) strlcpy(clone_info->filename,image_info->texture,MaxTextExtent);
-       texture=ReadImage(clone_info,exception);
-       DestroyImageInfo(clone_info);
+        ImageInfo
+          *clone_info;
+
+        clone_info=CloneImageInfo(image_info);
+        clone_info->blob=(void *) NULL;
+        clone_info->length=0;
+        (void) strlcpy(clone_info->filename,image_info->texture,MaxTextExtent);
+        texture=ReadImage(clone_info,exception);
+        DestroyImageInfo(clone_info);
       }
     /*
       Annotate the text image.
@@ -921,91 +976,91 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
       }
     if (logging)
       (void)LogMagickEvent(CoderEvent,GetMagickModule(),
-                          "Type metrics: ascent=%g descent=%g"
-                          " height=%g max_advance=%g",
-                          metrics.ascent,metrics.descent,
-                          metrics.height,metrics.max_advance);
+                           "Type metrics: ascent=%g descent=%g"
+                           " height=%g max_advance=%g",
+                           metrics.ascent,metrics.descent,
+                           metrics.height,metrics.max_advance);
     pixels_per_line=(long) (metrics.ascent-metrics.descent);
     margins=2*page.y;
     lines_per_page=((image->rows+1)-margins)/pixels_per_line+1;
     if (logging)
       (void)LogMagickEvent(CoderEvent,GetMagickModule(),
-                          "Pixels per line: %ld",
-                          pixels_per_line);
+                           "Pixels per line: %ld",
+                           pixels_per_line);
     if (logging)
       (void)LogMagickEvent(CoderEvent,GetMagickModule(),
-                          "Lines per page: %ld",
-                          lines_per_page);
+                           "Lines per page: %ld",
+                           lines_per_page);
     (void) strlcpy(filename,image_info->filename,MaxTextExtent);
-    if (draw_info->text != '\0')
-      *draw_info->text='\0';  
+    if (draw_info->text != NULL)
+      *draw_info->text='\0';
 
     page_num=1;
     line_num=0;
     while (p != (char *) NULL)
       {
-       /*
-         Annotate image with text.
-
-         Text lines are concatenated so that a full page is
-         rendered at a time via AnnotateImage().
-       */
-       (void) ConcatenateString(&draw_info->text,text);
-       (void) ConcatenateString(&draw_info->text,"\\n");
-       line_num++;
-
-       if (image->previous == (Image *) NULL)
-         if (QuantumTick(line_num,lines_per_page))
-           if (!MagickMonitorFormatted(line_num,lines_per_page,&image->exception,
-                                       LoadImageText,image->filename,
-                                       image->columns,image->rows))
-             break;
-
-       p=ReadBlobString(image,text);
-       if ((line_num < lines_per_page) && (p != (char *) NULL))
-         continue;
-       if (texture != (Image *) NULL)
-         {
-           MonitorHandler
-             handler;
-
-           handler=SetMonitorHandler((MonitorHandler) NULL);
-           (void) TextureImage(image,texture);
-           (void) SetMonitorHandler(handler);
-         }
-       (void) AnnotateImage(image,draw_info);
-       if (p == (char *) NULL)
-         break;
-
-       if (logging)
-         (void)LogMagickEvent(CoderEvent,GetMagickModule(),
-                              "page %ld scene %ld ",page_num, image->scene);
-
-       if ((image_info->subimage != 0) || (image_info->subrange != 0))
-         if (image->scene >= (image_info->subimage+image_info->subrange-1))
-           break;
-
-       /*
-         Page is full-- allocate next image structure.
-       */
-       *draw_info->text='\0';
-       page_num++;
-       line_num=0;
-       AllocateNextImage(image_info,image);
-       if (image->next == (Image *) NULL)
-         {
+        /*
+          Annotate image with text.
+
+          Text lines are concatenated so that a full page is
+          rendered at a time via AnnotateImage().
+        */
+        (void) ConcatenateString(&draw_info->text,text);
+        (void) ConcatenateString(&draw_info->text,"\\n");
+        line_num++;
+
+        if (image->previous == (Image *) NULL)
+          if (QuantumTick(line_num,lines_per_page))
+            if (!MagickMonitorFormatted(line_num,lines_per_page,&image->exception,
+                                        LoadImageText,image->filename,
+                                        image->columns,image->rows))
+              break;
+
+        p=ReadBlobString(image,text);
+        if ((line_num < lines_per_page) && (p != (char *) NULL))
+          continue;
+        if (texture != (Image *) NULL)
+          {
+            MonitorHandler
+              handler;
+
+            handler=SetMonitorHandler((MonitorHandler) NULL);
+            (void) TextureImage(image,texture);
+            (void) SetMonitorHandler(handler);
+          }
+        (void) AnnotateImage(image,draw_info);
+        if (p == (char *) NULL)
+          break;
+
+        if (logging)
+          (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+                               "page %ld scene %ld ",page_num, image->scene);
+
+        if ((image_info->subimage != 0) || (image_info->subrange != 0))
+          if (image->scene >= (image_info->subimage+image_info->subrange-1))
+            break;
+
+        /*
+          Page is full-- allocate next image structure.
+        */
+        *draw_info->text='\0';
+        page_num++;
+        line_num=0;
+        AllocateNextImage(image_info,image);
+        if (image->next == (Image *) NULL)
+          {
             DestroyDrawInfo(draw_info);
-           DestroyImageList(image);
-           return ((Image *) NULL);
-         }
-       image->next->columns=image->columns;
-       image->next->rows=image->rows;
-       image=SyncNextImageInList(image);
-       (void) strlcpy(image->filename,filename,MaxTextExtent);
-       (void) SetImage(image,OpaqueOpacity);
-       if (!MagickMonitorFormatted(TellBlob(image),GetBlobSize(image),exception,
-                                   LoadImagesText,image->filename))
-         break;
+            DestroyImageList(image);
+            return ((Image *) NULL);
+          }
+        image->next->columns=image->columns;
+        image->next->rows=image->rows;
+        image=SyncNextImageInList(image);
+        (void) strlcpy(image->filename,filename,MaxTextExtent);
+        (void) SetImage(image,OpaqueOpacity);
+        if (!MagickMonitorFormatted(TellBlob(image),GetBlobSize(image),exception,
+                                    LoadImagesText,image->filename))
+          break;
       }
 
     if (texture != (Image *) NULL)
@@ -1026,9 +1081,9 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
  FINISH_TXT:
   CloseBlob(image);
   {
-    Image *p;    
+    Image *p;
     long scene=0;
-    
+
     /*
       Rewind list, removing any empty images while rewinding.
     */
@@ -1045,7 +1100,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
           p=p->previous;
         }
       }
-    
+
     /*
       Fix scene numbers
     */
@@ -1053,7 +1108,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
       p->scene=scene++;
   }
 
-  if(logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),"return");  
+  if(logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),"return");
   return (image);
 }
 \f
@@ -1171,6 +1226,9 @@ static unsigned int WriteTXTImage(const ImageInfo *image_info,Image *image)
   register long
     x;
 
+  size_t
+    image_list_length;
+
   unsigned int
     status;
 
@@ -1188,18 +1246,19 @@ static unsigned int WriteTXTImage(const ImageInfo *image_info,Image *image)
   if (status == False)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
   scene=0;
+  image_list_length=GetImageListLength(image);
   do
     {
       unsigned int
-       depth;
-        
+        depth;
+
       (void) TransformColorspace(image,RGBColorspace);
       if (image->depth <= 8)
-       depth=8;
+        depth=8;
       else if (image->depth <= 16)
-       depth=16;
+        depth=16;
       else
-       depth=32;    
+        depth=32;
 
       if ((AccessDefinition(image_info,"txt","with-im-header")))
         {
@@ -1211,39 +1270,40 @@ static unsigned int WriteTXTImage(const ImageInfo *image_info,Image *image)
                        "# ImageMagick pixel enumeration: %.20g,%.20g,%.20g,rgb%c\n",
                        (double) image->columns, (double) image->rows, (double) depth, a);
 
-         (void) WriteBlobString(image,buffer);
+          (void) WriteBlobString(image,buffer);
         }
 
       /*
-       Convert MIFF to TXT raster pixels.
+        Convert MIFF to TXT raster pixels.
       */
       for (y=0; y < (long) image->rows; y++)
-       {
-         p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
-         if (p == (const PixelPacket *) NULL)
-           break;
-         for (x=0; x < (long) image->columns; x++)
-           {
-             FormatString(buffer,"%ld,%ld: ",x,y);
-             (void) WriteBlobString(image,buffer);
-             GetColorTuple(p,depth,image->matte,MagickFalse,tuple);
-             (void) strlcat(tuple," ",sizeof(tuple));
-             (void) WriteBlobString(image,tuple);
-             /* (void) QueryColorname(image,p,SVGCompliance,tuple,&image->exception); */
-             GetColorTuple(p,depth,image->matte,MagickTrue,tuple);
-             (void) WriteBlobString(image,tuple);
-             (void) WriteBlobString(image,"\n");
-             p++;
-           }
-       }
+        {
+          p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
+          if (p == (const PixelPacket *) NULL)
+            break;
+          for (x=0; x < (long) image->columns; x++)
+            {
+              FormatString(buffer,"%ld,%ld: ",x,y);
+              (void) WriteBlobString(image,buffer);
+              GetColorTuple(p,depth,image->matte,MagickFalse,tuple);
+              (void) strlcat(tuple," ",sizeof(tuple));
+              (void) WriteBlobString(image,tuple);
+              /* (void) QueryColorname(image,p,SVGCompliance,tuple,&image->exception); */
+              GetColorTuple(p,depth,image->matte,MagickTrue,tuple);
+              (void) WriteBlobString(image,tuple);
+              (void) WriteBlobString(image,"\n");
+              p++;
+            }
+        }
       if (image->next == (Image *) NULL)
-       break;
+        break;
       image=SyncNextImageInList(image);
-      status=MagickMonitorFormatted(scene++,GetImageListLength(image),
-                                   &image->exception,SaveImagesText,
-                                   image->filename);
+      status=MagickMonitorFormatted(scene,image_list_length,
+                                    &image->exception,SaveImagesText,
+                                    image->filename);
       if (status == False)
-       break;
+        break;
+      scene++;
     } while (image_info->adjoin);
   if (image_info->adjoin)
     while (image->previous != (Image *) NULL)
index 9a58143..e13ab87 100644 (file)
@@ -83,6 +83,7 @@ ModuleExport void RegisterUILImage(void)
   entry->adjoin=False;
   entry->description="X-Motif UIL table";
   entry->module="UIL";
+  entry->coder_class=UnstableCoderClass;
   (void) RegisterMagickInfo(entry);
 }
 \f
@@ -231,6 +232,7 @@ static unsigned int WriteUILImage(const ImageInfo *image_info,Image *image)
       colors=image->colors;
       if (transparent)
         {
+          i=0;
           colors++;
           for (y=0; y < (long) image->rows; y++)
           {
@@ -265,7 +267,7 @@ static unsigned int WriteUILImage(const ImageInfo *image_info,Image *image)
   GetPathComponent(image->filename,BasePath,basename);
   FormatString(buffer,"value\n  %.1024s_ct : color_table(\n",basename);
   (void) WriteBlobString(image,buffer);
-  for (i=0; i < (long) colors; i++)
+  for (i=0; i < (long) image->colors; i++)
   {
     /*
       Define UIL color.
@@ -333,7 +335,7 @@ static unsigned int WriteUILImage(const ImageInfo *image_info,Image *image)
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                   SaveImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   CloseBlob(image);
index 0effa56..5d7562e 100644 (file)
@@ -140,13 +140,13 @@ static Image *ReadURLImage(const ImageInfo *image_info,ExceptionInfo *exception)
   else if (LocaleCompare(image_info->magick,"file") == 0)
     access_mode=URLGetFileConfirmAccessMode;
 
+
   /* Attempt to re-compose original URL */
   (void) strlcpy(filename,image_info->magick,MaxTextExtent);
   LocaleLower(filename);
   (void) strlcat(filename,":",MaxTextExtent);
   (void) strlcat(filename,image_info->filename,MaxTextExtent);
+
   if (MagickConfirmAccess(access_mode,filename,exception)
       == MagickFail)
     return image;
index 4f003bf..c248599 100644 (file)
@@ -166,7 +166,7 @@ static Image *ReadUYVYImage(const ImageInfo *image_info,
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                   image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   image->colorspace=YCbCrColorspace;
@@ -354,7 +354,7 @@ static unsigned int WriteUYVYImage(const ImageInfo *image_info,Image *image)
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                   SaveImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   /*
index 3e2c90d..ff92c6c 100644 (file)
@@ -293,7 +293,7 @@ static Image *ReadVICARImage(const ImageInfo *image_info,
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                   image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   MagickFreeMemory(scanline);
@@ -454,7 +454,7 @@ static unsigned int WriteVICARImage(const ImageInfo *image_info,Image *image)
       if (QuantumTick(y,image->rows))
         if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                     SaveImageText,image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
   }
   MagickFreeMemory(scanline);
index 086414d..a1e3da8 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -330,7 +330,6 @@ static Image *ReadVIFFImage(const ImageInfo *image_info,
 
   size_t
     alloc_size,
-    blob_size,
     max_packets,
     number_pixels;
 
@@ -419,6 +418,8 @@ static Image *ReadVIFFImage(const ImageInfo *image_info,
     image->columns=viff_info.rows;
     image->rows=viff_info.columns;
     image->depth=viff_info.x_pixel_size <= 8 ? 8 : QuantumDepth;
+    if (CheckImagePixelLimits(image, exception) != MagickPass)
+      ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
     /*
       Verify that we can read this VIFF image.
     */
@@ -501,6 +502,9 @@ static Image *ReadVIFFImage(const ImageInfo *image_info,
         viff_colormap_size=MagickArraySize(MagickArraySize(bytes_per_pixel,
                                                            image->colors),
                                            viff_info.map_rows);
+        if (BlobIsSeekable(image) &&
+            (GetBlobSize(image)-TellBlob(image) < (magick_off_t) viff_colormap_size))
+          ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
         viff_colormap=MagickAllocateMemory(unsigned char *,viff_colormap_size);
         if (viff_colormap == (unsigned char *) NULL)
           ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,
@@ -510,7 +514,10 @@ static Image *ReadVIFFImage(const ImageInfo *image_info,
         */
         if (ReadBlob(image,viff_colormap_size,(char *) viff_colormap)
             != viff_colormap_size)
-          ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+          {
+            MagickFreeMemory(viff_colormap);
+            ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+          }
 
         lsb_first=1;
         if (*(char *) &lsb_first &&
@@ -575,8 +582,16 @@ static Image *ReadVIFFImage(const ImageInfo *image_info,
     if (image_info->ping && (image_info->subrange != 0))
       if (image->scene >= (image_info->subimage+image_info->subrange-1))
         break;
-    if (CheckImagePixelLimits(image, exception) != MagickPass)
-      ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+
+    if (viff_info.data_storage_type == VFF_TYP_BIT)
+      {
+        /*
+          Allocate bi-level colormap
+        */
+        if (AllocateImageColormap(image,2) == MagickFail)
+          ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+        image->colorspace=GRAYColorspace;
+      }
     /*
       Allocate VIFF pixels.
     */
@@ -621,8 +636,8 @@ static Image *ReadVIFFImage(const ImageInfo *image_info,
                               (MAGICK_SIZE_T) viff_info.number_data_bands);
       }
     alloc_size=MagickArraySize(bytes_per_pixel,max_packets);
-    blob_size=GetBlobSize(image);
-    if ((blob_size != 0) && (alloc_size > blob_size))
+    if (BlobIsSeekable(image) &&
+        (GetBlobSize(image)-TellBlob(image) < (magick_off_t) alloc_size))
       ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,image);
     viff_pixels=MagickAllocateArray(unsigned char *,
                                     MagickArraySize(bytes_per_pixel,
@@ -630,7 +645,12 @@ static Image *ReadVIFFImage(const ImageInfo *image_info,
                                     sizeof(Quantum));
     if (viff_pixels == (unsigned char *) NULL)
       ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-    (void) ReadBlob(image,bytes_per_pixel*max_packets,(char *) viff_pixels);
+    if (ReadBlob(image,bytes_per_pixel*max_packets,(char *) viff_pixels)
+        != bytes_per_pixel*max_packets)
+      {
+        MagickFreeMemory(viff_pixels);
+        ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+      }
     lsb_first=1;
     if (*(char *) &lsb_first &&
         ((viff_info.machine_dependency != VFF_DEP_DECORDER) &&
@@ -736,7 +756,6 @@ static Image *ReadVIFFImage(const ImageInfo *image_info,
         /*
           Convert bitmap scanline.
         */
-        (void) SetImageType(image,BilevelType);
         polarity=PixelIntensityToQuantum(&image->colormap[0]) < (MaxRGB/2);
         if (image->colors >= 2)
           polarity=PixelIntensityToQuantum(&image->colormap[0]) >
@@ -773,7 +792,7 @@ static Image *ReadVIFFImage(const ImageInfo *image_info,
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
       }
@@ -797,7 +816,7 @@ static Image *ReadVIFFImage(const ImageInfo *image_info,
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,exception,
                                           LoadImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
       else
@@ -839,7 +858,7 @@ static Image *ReadVIFFImage(const ImageInfo *image_info,
               if (QuantumTick(y,image->rows))
                 if (!MagickMonitorFormatted(y,image->rows,exception,
                                             LoadImageText,image->filename,
-                                           image->columns,image->rows))
+                                            image->columns,image->rows))
                   break;
           }
         }
@@ -859,7 +878,7 @@ static Image *ReadVIFFImage(const ImageInfo *image_info,
       if (image->scene >= (image_info->subimage+image_info->subrange-1))
         break;
     count=ReadBlob(image,1,(char *) &viff_info.identifier);
-    if ((count != 0) && (viff_info.identifier == 0xab))
+    if ((count == 1) && (viff_info.identifier == 0xab))
       {
         /*
           Allocate next image structure.
@@ -1031,6 +1050,9 @@ static unsigned int WriteVIFFImage(const ImageInfo *image_info,Image *image)
   ViffInfo
     viff_info;
 
+  size_t
+    image_list_length;
+
   /*
     Open output image file.
   */
@@ -1038,6 +1060,7 @@ static unsigned int WriteVIFFImage(const ImageInfo *image_info,Image *image)
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
   if (status == False)
     ThrowWriterException(FileOpenError,UnableToOpenFile,image);
@@ -1208,7 +1231,7 @@ static unsigned int WriteVIFFImage(const ImageInfo *image_info,Image *image)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                           SaveImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
       }
@@ -1251,7 +1274,7 @@ static unsigned int WriteVIFFImage(const ImageInfo *image_info,Image *image)
               if (QuantumTick(y,image->rows))
                 if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                             SaveImageText,image->filename,
-                                           image->columns,image->rows))
+                                            image->columns,image->rows))
                   break;
           }
         }
@@ -1303,7 +1326,7 @@ static unsigned int WriteVIFFImage(const ImageInfo *image_info,Image *image)
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                               SaveImageText,image->filename,
-                                             image->columns,image->rows))
+                                              image->columns,image->rows))
                     break;
             }
           }
@@ -1326,8 +1349,8 @@ static unsigned int WriteVIFFImage(const ImageInfo *image_info,Image *image)
               if (image->previous == (Image *) NULL)
                 if (QuantumTick(y,image->rows))
                   if (!MagickMonitorFormatted(y,image->rows,&image->exception,
-                                             SaveImageText,image->filename,
-                                             image->columns,image->rows))
+                                              SaveImageText,image->filename,
+                                              image->columns,image->rows))
                     break;
             }
           }
@@ -1336,7 +1359,7 @@ static unsigned int WriteVIFFImage(const ImageInfo *image_info,Image *image)
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene++,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename);
     if (status == False)
index e6d616d..9cd5bff 100644 (file)
@@ -144,16 +144,16 @@ static Image *ReadWBMPImage(const ImageInfo *image_info,
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == False)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
-  if (!ReadBlob(image,2,(char *) &header)) 
+  if (ReadBlob(image,2,(char *) &header) != 2)
     ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
   if (header != 0U)
     ThrowReaderException(CoderError,OnlyLevelZerofilesSupported,image);
   /*
     Initialize image structure.
   */
-  if (WBMPReadInteger(image,&image->columns) == False) 
+  if (WBMPReadInteger(image,&image->columns) == False)
     ThrowReaderException(CorruptImageError,CorruptImage,image);
-  if (WBMPReadInteger(image,&image->rows) == False) 
+  if (WBMPReadInteger(image,&image->rows) == False)
     ThrowReaderException(CorruptImageError,CorruptImage,image);
   if ((image->columns == 0) || (image->rows == 0))
     ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
@@ -199,7 +199,7 @@ static Image *ReadWBMPImage(const ImageInfo *image_info,
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                   image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   (void) SyncImage(image);
@@ -404,7 +404,7 @@ static unsigned int WriteWBMPImage(const ImageInfo *image_info,Image *image)
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                   SaveImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   CloseBlob(image);
index 284a714..7ff34b4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2013 - 2014 GraphicsMagick Group
+% Copyright (C) 2013 - 2017 GraphicsMagick Group
 %
 % This program is covered by multiple licenses, which are described in
 % Copyright.txt. You should have received a copy of Copyright.txt with this
@@ -44,6 +44,8 @@
 #include "magick/magick.h"
 #include "magick/monitor.h"
 #include "magick/pixel_cache.h"
+#include "magick/profile.h"
+#include "magick/tsd.h"
 #include "magick/utility.h"
 
 /*
@@ -64,13 +66,19 @@ static unsigned int WriteWEBPImage(const ImageInfo *,Image *);
   Release versions vs ABI versions (found in src/webp/encode.h)
 
     0.1.3  - 0x0002
-    0.1.99 - 0x0100
+    0.1.99 - 0x0100 <-- earliest version we support
     0.2.0  - 0x0200
     0.2.1  - 0x0200
     0.3.0  - 0x0201
     0.4.0  - 0x0202
     0.4.1  - 0x0202
     0.4.2  - 0x0202
+    0.4.3  - 0x0202
+    0.4.4  - 0x0202
+    0.5.0  - 0x0209
+    0.5.1  - 0x0209
+    0.5.2  - 0x0209
+    0.6.0  - 0x020e
 */
 
 /*
@@ -89,6 +97,20 @@ static unsigned int WriteWEBPImage(const ImageInfo *,Image *);
 #  define SUPPORT_CONFIG_THREAD_LEVEL
 #  define SUPPORT_CONFIG_LOW_MEMORY
 #endif
+#if WEBP_ENCODER_ABI_VERSION >= 0x0202 /* >= 0.4.0 */
+#endif
+#if WEBP_ENCODER_ABI_VERSION >= 0x0209 /* >= 0.5.0 */
+#  define SUPPORT_WEBP_MUX
+#include <webp/mux.h>
+#endif
+#if WEBP_ENCODER_ABI_VERSION >= 0x020e /* >= 0.6.0 */
+#endif
+\f
+/*
+  Global declarations.
+*/
+static MagickTsdKey_t tsd_key = (MagickTsdKey_t) 0;
+
 
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -200,9 +222,9 @@ static Image *ReadWEBPImage(const ImageInfo *image_info,
         case VP8_STATUS_SUSPENDED:
           /*
             Incremental decoder object may be left in SUSPENDED state
-             if the picture is only partially decoded, pending
-             additional input.  We are not doing incremental decoding
-             at this time.
+            if the picture is only partially decoded, pending
+            additional input.  We are not doing incremental decoding
+            at this time.
           */
           break;
         case VP8_STATUS_USER_ABORT:
@@ -242,8 +264,8 @@ static Image *ReadWEBPImage(const ImageInfo *image_info,
                                             &stream_features.height);
   else
     pixels=(unsigned char *) WebPDecodeRGB(stream,length,
-                                            &stream_features.width,
-                                            &stream_features.height);
+                                           &stream_features.width,
+                                           &stream_features.height);
   if (pixels == (unsigned char *) NULL)
     {
       MagickFreeMemory(stream);
@@ -270,9 +292,40 @@ static Image *ReadWEBPImage(const ImageInfo *image_info,
           q++;
         }
 
-      if(!SyncImagePixels(image))
+      if (!SyncImagePixels(image))
         break;
     }
+
+#if defined(SUPPORT_WEBP_MUX)
+  /* Read features out of the WebP container */
+  {
+    uint32_t webp_flags=0;
+    WebPData flag_data;
+    WebPData content={stream,length};
+
+    WebPMux *mux=WebPMuxCreate(&content,0);
+    (void) memset(&flag_data,0,sizeof(flag_data));
+    WebPMuxGetFeatures(mux,&webp_flags);
+
+    if (webp_flags & ICCP_FLAG) {
+      WebPMuxGetChunk(mux,"ICCP",&flag_data);
+      AppendImageProfile(image,"ICC",flag_data.bytes,flag_data.size);
+    }
+
+    if (webp_flags & EXIF_FLAG) {
+      WebPMuxGetChunk(mux,"EXIF",&flag_data);
+      AppendImageProfile(image,"EXIF",flag_data.bytes,flag_data.size);
+    }
+
+    if (webp_flags & XMP_FLAG) {
+      WebPMuxGetChunk(mux,"XMP",&flag_data);
+      AppendImageProfile(image,"XMP",flag_data.bytes,flag_data.size);
+    }
+
+    WebPMuxDelete(mux);
+  }
+#endif /* defined(SUPPORT_WEBP_MUX) */
+
   /*
     Free scale resource.
   */
@@ -329,6 +382,12 @@ ModuleExport void RegisterWEBPImage(void)
   *version='\0';
 
   /*
+    Initialize thread specific data key.
+  */
+  if (tsd_key == (MagickTsdKey_t) 0)
+    (void) MagickTsdKeyCreate(&tsd_key);
+
+  /*
     Obtain the encoder's version number from the library, packed in
     hexadecimal using 8bits for each of major/minor/revision. E.g:
     v2.5.7 is 0x020507.
@@ -381,6 +440,15 @@ ModuleExport void RegisterWEBPImage(void)
 ModuleExport void UnregisterWEBPImage(void)
 {
   (void) UnregisterMagickInfo("WEBP");
+
+  /*
+    Destroy thread specific data key.
+  */
+  if (tsd_key != (MagickTsdKey_t) 0)
+    {
+      (void) MagickTsdKeyDelete(tsd_key);
+      tsd_key = (MagickTsdKey_t) 0;
+    }
 }
 
 #if defined(HasWEBP)
@@ -409,8 +477,10 @@ ModuleExport void UnregisterWEBPImage(void)
 %
 */
 
-/*
-  Called to write data to blob
+#if !defined(SUPPORT_WEBP_MUX)
+ /*
+  Called to write data to blob ("Should return true if writing was
+  successful")
 */
 static int WriterCallback(const unsigned char *stream,size_t length,
                           const WebPPicture *const picture)
@@ -419,11 +489,17 @@ static int WriterCallback(const unsigned char *stream,size_t length,
     *image;
 
   image=(Image *) picture->custom_ptr;
-  return (length != 0 ? (int) WriteBlob(image,length,stream) : 1);
+  assert(image != (Image *) NULL);
+  assert(image->signature == MagickSignature);
+  return (length != 0U ? (WriteBlob(image,length,stream) == length) :
+          MagickTrue);
 }
+#endif /* !defined(SUPPORT_WEBP_MUX) */
 
 /*
-  Called to provide progress indication
+  Called to provide progress indication ("It can return false to
+  request an abort of the encoding process, or true otherwise if
+  everything is OK.")
 */
 #if defined(SUPPORT_PROGRESS)
 static int ProgressCallback(int percent, const WebPPicture* picture)
@@ -431,12 +507,24 @@ static int ProgressCallback(int percent, const WebPPicture* picture)
   Image
     *image;
 
+  /*
+    When the WebPMemoryWriter is used, it commandeers custom_ptr
+    and the ProgressCallback no longer has access to image.
+
+    We use thread specific data instead.
+   */
+  (void) picture;
+  image=(Image *) MagickTsdGetSpecific(tsd_key);
+#if 0
   image=(Image *) picture->custom_ptr;
+#endif
+  assert(image != (Image *) NULL);
+  assert(image->signature == MagickSignature);
   return MagickMonitorFormatted(percent, 101, &image->exception,
                                 SaveImageText, image->filename,
                                 image->columns, image->rows);
 }
-#endif
+#endif /* defined(SUPPORT_PROGRESS) */
 
 static unsigned int WriteWEBPImage(const ImageInfo *image_info,Image *image)
 {
@@ -473,6 +561,11 @@ static unsigned int WriteWEBPImage(const ImageInfo *image_info,Image *image)
   WebPPicture
     picture;
 
+#if defined(SUPPORT_WEBP_MUX)
+  WebPMemoryWriter
+    writer;
+#endif /* defined(SUPPORT_WEBP_MUX) */
+
   WebPAuxStats
     statistics;
 
@@ -501,8 +594,16 @@ static unsigned int WriteWEBPImage(const ImageInfo *image_info,Image *image)
   (void) TransformColorspace(image,RGBColorspace);
   image->storage_class=DirectClass;
 
+  (void) MagickTsdSetSpecific(tsd_key,(void *) image);
+
+#if !defined(SUPPORT_WEBP_MUX)
   picture.writer=WriterCallback;
   picture.custom_ptr=(void *) image;
+#else
+  WebPMemoryWriterInit(&writer);
+  picture.writer=WebPMemoryWrite;
+  picture.custom_ptr=&writer;
+#endif
 #if defined(SUPPORT_PROGRESS)
   picture.progress_hook=ProgressCallback;
 #endif
@@ -589,7 +690,7 @@ static unsigned int WriteWEBPImage(const ImageInfo *image_info,Image *image)
       for (y = 0; y < image->rows; y++)
         {
           magick_uint32_t *s = picture.argb + y * picture.argb_stride;
-         p=GetImagePixelsEx(image,0,y,image->columns,1,&image->exception);
+          p=GetImagePixelsEx(image,0,y,image->columns,1,&image->exception);
           if (p == (const PixelPacket *) NULL)
             break;
           for (x = 0; x < image->columns; x++)
@@ -707,7 +808,98 @@ static unsigned int WriteWEBPImage(const ImageInfo *image_info,Image *image)
         } /* if (! webp_status) */
     } /* if (webp_status) */
 
+#if defined(SUPPORT_WEBP_MUX)
+  /* Write profiles */
+  if (image->profiles)
+    {
+      size_t idx;
+
+      /* Mapping of GraphicsMagick->libwebp feature/profile names */
+      char data_features[][3][6]={{"ICC", "ICCP"},{"EXIF", "EXIF"},{"XMP", "XMP"}};
+
+      /* Prepare the WebP muxer */
+      WebPMuxError mux_error;
+      WebPMux *mux=WebPMuxNew();
+      WebPData encoded_image={writer.mem,writer.size};
+
+      WebPMuxSetImage(mux,&encoded_image,1);
+
+      /* Iterate over all available features and try to push them into the WebP container */
+      for (idx=0;idx<sizeof(data_features)/sizeof(data_features[0]);idx++)
+        {
+          /* Get feature data */
+          WebPData chunk;
+
+          (void) memset(&chunk,0,sizeof(chunk));
+          chunk.bytes=GetImageProfile(image,data_features[idx][0],&chunk.size);
+
+          if (!chunk.bytes)
+            continue;
+
+          /* Write feature data */
+          mux_error=WebPMuxSetChunk(mux,data_features[idx][1],&chunk,0);
+
+          switch(mux_error) {
+          case WEBP_MUX_OK:
+            break;
+            ;;
+          case WEBP_MUX_BAD_DATA:
+          case WEBP_MUX_NOT_ENOUGH_DATA:
+          case WEBP_MUX_NOT_FOUND:
+            ThrowWriterException(CoderError,WebPInvalidParameter,image);
+            break;
+            ;;
+          case WEBP_MUX_INVALID_ARGUMENT:
+            ThrowWriterException(CoderError,WebPEncodingFailedNULLParameter,image);
+            break;
+            ;;
+          case WEBP_MUX_MEMORY_ERROR:
+            ThrowWriterException(CoderError,WebPEncodingFailedOutOfMemory,image);
+            break;
+            ;;
+          }
+        }
+
+      /* Create the new container */
+      {
+        WebPData picture_profiles={writer.mem, writer.size};
+        mux_error=WebPMuxAssemble(mux,&picture_profiles);
+
+        switch (mux_error) {
+        case WEBP_MUX_OK:
+          break;
+          ;;
+        case WEBP_MUX_BAD_DATA:
+        case WEBP_MUX_NOT_ENOUGH_DATA:
+        case WEBP_MUX_NOT_FOUND:
+          ThrowWriterException(CoderError,WebPInvalidParameter,image);
+        case WEBP_MUX_INVALID_ARGUMENT:
+          ThrowWriterException(CoderError,WebPEncodingFailedNULLParameter,image);
+          break;
+          ;;
+        case WEBP_MUX_MEMORY_ERROR:
+          ThrowWriterException(CoderError,WebPEncodingFailedOutOfMemory,image);
+          break;
+          ;;
+        }
+
+        /* Replace the original data with the container data */
+        WebPMemoryWriterClear(&writer);
+        writer.size=picture_profiles.size;
+        writer.mem=(unsigned char *)picture_profiles.bytes;
+
+        /* Cleanup the muxer */
+        WebPMuxDelete(mux);
+      }
+    } /* if (webp_status) */
+
+  /* Write out the data to the blob and cleanup*/
+  WriteBlob(image, writer.size, writer.mem);
+#endif /* defined(SUPPORT_WEBP_MUX) */
   WebPPictureFree(&picture);
+#if defined(SUPPORT_WEBP_MUX)
+  WebPMemoryWriterClear(&writer);
+#endif
   CloseBlob(image);
 
   return (webp_status ? MagickPass : MagickFail);
index f10132f..9a709a7 100644 (file)
@@ -292,7 +292,7 @@ static void draw_color_fill_rgb( wmfAPI* API, const wmfRGB* rgb )
   fill_color.opacity = OpaqueOpacity;
 
   DrawSetFillColor(WmfDrawContext,&fill_color);
-  
+
 }
 
 /* Set stroke color */
@@ -300,12 +300,12 @@ static void draw_color_stroke_rgb( wmfAPI* API, const wmfRGB* rgb )
 {
   PixelPacket
     stroke_color;
-  
+
   stroke_color.red     = ScaleCharToQuantum(rgb->r);
   stroke_color.green   = ScaleCharToQuantum(rgb->g);
   stroke_color.blue    = ScaleCharToQuantum(rgb->b);
   stroke_color.opacity = OpaqueOpacity;
-  
+
   DrawSetStrokeColor(WmfDrawContext,&stroke_color);
 }
 
@@ -333,7 +333,7 @@ static void ipa_rop_draw(wmfAPI * API, wmfROP_Draw_t * rop_draw)
 {
 /*   wmfBrush */
 /*     *brush = WMF_DC_BRUSH(rop_draw->dc); */
-  
+
 /*   wmfBMP */
 /*     *brush_bmp = WMF_BRUSH_BITMAP(brush); */
 
@@ -348,12 +348,12 @@ static void ipa_rop_draw(wmfAPI * API, wmfROP_Draw_t * rop_draw)
   /*
   struct _wmfROP_Draw_t
   {       wmfDC* dc;
-    
+
     wmfD_Coord TL;
     wmfD_Coord BR;
-    
+
     U32 ROP;
-    
+
     double pixel_width;
     double pixel_height;
   };
@@ -540,7 +540,7 @@ static void ipa_bmp_read(wmfAPI * API, wmfBMP_Read_t * bmp_read) {
     {
       char
         size[MaxTextExtent];
-      
+
       FormatString(size,"%ux%u",bmp_read->width,bmp_read->height);
       (void) CloneString(&image_info->size,size);
     }
@@ -667,7 +667,7 @@ static void ipa_device_begin(wmfAPI * API)
 
       ImageInfo
         *image_info;
-      
+
       ExceptionInfo
         exception;
 
@@ -1226,7 +1226,7 @@ static void ipa_functions(wmfAPI *API)
 
 static void ipa_draw_text(wmfAPI * API, wmfDrawText_t * draw_text)
 {
-  double    
+  double
     angle = 0,      /* text rotation angle */
     pointsize = 0;  /* pointsize to output font with desired height */
 
@@ -1320,7 +1320,7 @@ static void ipa_draw_text(wmfAPI * API, wmfDrawText_t * draw_text)
     {
       Image
         *image = ddata->image;
-      
+
       DrawInfo
         *draw_info;
 
@@ -1336,7 +1336,7 @@ static void ipa_draw_text(wmfAPI * API, wmfDrawText_t * draw_text)
             {
               double
                 text_width = metrics.width * (ddata->scale_y / ddata->scale_x);
-              
+
 #if defined(HasWMFlite)
               point.x -= text_width / 2;
 #else
@@ -1564,7 +1564,7 @@ static void util_set_brush(wmfAPI * API, wmfDC * dc, const BrushApply brush_appl
         DrawPushDefs(WmfDrawContext);
         draw_pattern_push(API, ddata->pattern_id, 8, 8);
         DrawPushGraphicContext(WmfDrawContext);
-        
+
         if (WMF_DC_OPAQUE(dc))
           {
             if( brush_apply == BrushApplyStroke )
@@ -1577,12 +1577,12 @@ static void util_set_brush(wmfAPI * API, wmfDC * dc, const BrushApply brush_appl
 
         DrawSetStrokeAntialias(WmfDrawContext, False);
         DrawSetStrokeWidth(WmfDrawContext, 1);
-        
+
         draw_color_stroke_rgb(API,WMF_BRUSH_COLOR(brush));
-        
+
         switch ((unsigned int) WMF_BRUSH_HATCH(brush))
           {
-            
+
           case HS_HORIZONTAL:  /* ----- */
             {
               DrawLine(WmfDrawContext, 0, 3, 7,3);
@@ -1657,7 +1657,7 @@ static void util_set_brush(wmfAPI * API, wmfDC * dc, const BrushApply brush_appl
 
         if (brush_bmp && brush_bmp->data != 0)
           {
-            CompositeOperator            
+            CompositeOperator
               mode;
 
             const Image
@@ -1972,7 +1972,7 @@ static double util_pointsize( wmfAPI* API, wmfFont* font, char* str, double font
           draw_info->pointsize = pointsize;
           if (GetTypeMetrics(image, draw_info, &metrics) != False)
             pointsize *= (font_height / metrics.height);
-          
+
         }
 
 
@@ -2130,7 +2130,7 @@ static const wmfFontMap WMFFontMap[] = {
 
 /* Mapping between base name and Ghostscript family name */
 static const wmfMapping SubFontMap[] = {
-  { "Arial",      "Helvetica", (FT_Encoding) 0 },
+  { "Arial",      "Helvetica",  (FT_Encoding) 0 },
   { "Courier",    "Courier",    (FT_Encoding) 0 },
   { "Fixed",      "Courier",    (FT_Encoding) 0 },
   { "Helvetica",  "Helvetica",  (FT_Encoding) 0 },
@@ -2209,7 +2209,7 @@ static void lite_font_map( wmfAPI* API, wmfFont* font)
                 weight;
 
               /* printf("Considering font %s\n", type_info->description); */
-              
+
               if( WMF_FONT_ITALIC(font) && !(strstr(type_info->description,"Italic") ||
                                              strstr(type_info->description,"Oblique")) )
                 continue;
@@ -2296,7 +2296,7 @@ static void lite_font_map( wmfAPI* API, wmfFont* font)
   printf("WMF_FONT_PSNAME         = \"%s\"\n", WMF_FONT_PSNAME(font));
   fflush(stdout);
 #endif
-  
+
 }
 
 /* Initialize API font structures */
@@ -2402,7 +2402,7 @@ static Image *ReadWMFImage(const ImageInfo * image_info, ExceptionInfo * excepti
         }
       ThrowReaderException(FileOpenError,UnableToOpenFile,image);
     }
-  
+
   /*
    * Create WMF API
    *
@@ -2571,7 +2571,7 @@ static Image *ReadWMFImage(const ImageInfo * image_info, ExceptionInfo * excepti
     {
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"  Placeable metafile:          %s",
                      (API)->File->placeable ? "Yes" : "No");
-      
+
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"  Size in metafile units:      %.4gx%.4g",
                      wmf_width, wmf_height);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"  Metafile units/inch:         %.4g",
@@ -2601,7 +2601,7 @@ static Image *ReadWMFImage(const ImageInfo * image_info, ExceptionInfo * excepti
       wmfPen   default_pen;
       wmfBrush default_brush;
       wmfFont  default_font;
-      
+
       wmfDC* dc; /* current dc */
     };
 
@@ -2694,7 +2694,7 @@ static Image *ReadWMFImage(const ImageInfo * image_info, ExceptionInfo * excepti
       if (logging)
         {
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                               "  Playing WMF failed with wmf_error_code %d", wmf_error_code);
+                                "  Playing WMF failed with wmf_error_code %d", wmf_error_code);
           (void) LogMagickEvent(CoderEvent,GetMagickModule(),"leave ReadWMFImage()");
         }
       ipa_device_close(API);
@@ -2719,8 +2719,8 @@ static Image *ReadWMFImage(const ImageInfo * image_info, ExceptionInfo * excepti
   if(image->exception.severity != UndefinedException)
     ThrowException2(exception,
                    CoderWarning,
-                   ddata->image->exception.reason,
-                   ddata->image->exception.description);
+                   image->exception.reason,
+                   image->exception.description);
 
   if(logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),"leave ReadWMFImage()");
@@ -2761,7 +2761,7 @@ ModuleExport void RegisterWMFImage(void)
     *entry;
 
   static const char
-    *WMFNote = 
+    *WMFNote =
     {
       "Use density to adjust scale (default 72DPI). Use background or\n"
       "texture to apply a background color or texture under the image."
index b4b83ca..ef67f09 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -21,7 +21,7 @@
 %                                                                             %
 %                              Software Design                                %
 %                              Jaroslav Fojtik                                %
-%                              June 2000 - 2016                               %
+%                              June 2000 - 2018                               %
 %                         Rework for GraphicsMagick                           %
 %                              Bob Friesenhahn                                %
 %                               Feb-May 2003                                  %
@@ -39,6 +39,7 @@
 #include "magick/blob.h"
 #include "magick/colormap.h"
 #include "magick/constitute.h"
+#include "magick/log.h"
 #include "magick/magic.h"
 #include "magick/magick.h"
 #include "magick/pixel_cache.h"
@@ -57,137 +58,144 @@ typedef struct
 
 /* Default palette for WPG level 1 */
 const RGB_Record WPG1_Palette[256]={
-{  0,  0,  0},         {  0,  0,168},
-{  0,168,  0},         {  0,168,168},
-{168,  0,  0},         {168,  0,168},
-{168, 84,  0},         {168,168,168},
-{ 84, 84, 84},         { 84, 84,252},
-{ 84,252, 84},         { 84,252,252},
-{252, 84, 84},         {252, 84,252},
-{252,252, 84},         {252,252,252},  /*16*/
-{  0,  0,  0},         { 20, 20, 20},
-{ 32, 32, 32},         { 44, 44, 44},
-{ 56, 56, 56},         { 68, 68, 68},
-{ 80, 80, 80},         { 96, 96, 96},
-{112,112,112},         {128,128,128},
-{144,144,144},         {160,160,160},
-{180,180,180},         {200,200,200},
-{224,224,224},         {252,252,252},  /*32*/
-{  0,  0,252},         { 64,  0,252},
-{124,  0,252},         {188,  0,252},
-{252,  0,252},         {252,  0,188},
-{252,  0,124},         {252,  0, 64},
-{252,  0,  0},         {252, 64,  0},
-{252,124,  0},         {252,188,  0},
-{252,252,  0},         {188,252,  0},
-{124,252,  0},         { 64,252,  0},  /*48*/
-{  0,252,  0},         {  0,252, 64},
-{  0,252,124},         {  0,252,188},
-{  0,252,252},         {  0,188,252},
-{  0,124,252},         {  0, 64,252},
-{124,124,252},         {156,124,252},
-{188,124,252},         {220,124,252},
-{252,124,252},         {252,124,220},
-{252,124,188},         {252,124,156},  /*64*/
-{252,124,124},         {252,156,124},
-{252,188,124},         {252,220,124},
-{252,252,124},         {220,252,124},
-{188,252,124},         {156,252,124},
-{124,252,124},         {124,252,156},
-{124,252,188},         {124,252,220},
-{124,252,252},         {124,220,252},
-{124,188,252},         {124,156,252},  /*80*/
-{180,180,252},         {196,180,252},
-{216,180,252},         {232,180,252},
-{252,180,252},         {252,180,232},
-{252,180,216},         {252,180,196},
-{252,180,180},         {252,196,180},
-{252,216,180},         {252,232,180},
-{252,252,180},         {232,252,180},
-{216,252,180},         {196,252,180},  /*96*/
-{180,220,180},         {180,252,196},
-{180,252,216},         {180,252,232},
-{180,252,252},         {180,232,252},
-{180,216,252},         {180,196,252},
-{0,0,112},             {28,0,112},
-{56,0,112},            {84,0,112},
-{112,0,112},           {112,0,84},
-{112,0,56},            {112,0,28},     /*112*/
-{112,0,0},             {112,28,0},
-{112,56,0},            {112,84,0},
-{112,112,0},           {84,112,0},
-{56,112,0},            {28,112,0},
-{0,112,0},             {0,112,28},
-{0,112,56},            {0,112,84},
-{0,112,112},           {0,84,112},
-{0,56,112},            {0,28,112},     /*128*/
-{56,56,112},           {68,56,112},
-{84,56,112},           {96,56,112},
-{112,56,112},          {112,56,96},
-{112,56,84},           {112,56,68},
-{112,56,56},           {112,68,56},
-{112,84,56},           {112,96,56},
-{112,112,56},          {96,112,56},
-{84,112,56},           {68,112,56},    /*144*/
-{56,112,56},           {56,112,69},
-{56,112,84},           {56,112,96},
-{56,112,112},          {56,96,112},
-{56,84,112},           {56,68,112},
-{80,80,112},           {88,80,112},
-{96,80,112},           {104,80,112},
-{112,80,112},          {112,80,104},
-{112,80,96},           {112,80,88},    /*160*/
-{112,80,80},           {112,88,80},
-{112,96,80},           {112,104,80},
-{112,112,80},          {104,112,80},
-{96,112,80},           {88,112,80},
-{80,112,80},           {80,112,88},
-{80,112,96},           {80,112,104},
-{80,112,112},          {80,114,112},
-{80,96,112},           {80,88,112},    /*176*/
-{0,0,64},              {16,0,64},
-{32,0,64},             {48,0,64},
-{64,0,64},             {64,0,48},
-{64,0,32},             {64,0,16},
-{64,0,0},              {64,16,0},
-{64,32,0},             {64,48,0},
-{64,64,0},             {48,64,0},
-{32,64,0},             {16,64,0},      /*192*/
-{0,64,0},              {0,64,16},
-{0,64,32},             {0,64,48},
-{0,64,64},             {0,48,64},
-{0,32,64},             {0,16,64},
-{32,32,64},            {40,32,64},
-{48,32,64},            {56,32,64},
-{64,32,64},            {64,32,56},
-{64,32,48},            {64,32,40},     /*208*/
-{64,32,32},            {64,40,32},
-{64,48,32},            {64,56,32},
-{64,64,32},            {56,64,32},
-{48,64,32},            {40,64,32},
-{32,64,32},            {32,64,40},
-{32,64,48},            {32,64,56},
-{32,64,64},            {32,56,64},
-{32,48,64},            {32,40,64},     /*224*/
-{44,44,64},            {48,44,64},
-{52,44,64},            {60,44,64},
-{64,44,64},            {64,44,60},
-{64,44,52},            {64,44,48},
-{64,44,44},            {64,48,44},
-{64,52,44},            {64,60,44},
-{64,64,44},            {60,64,44},
-{52,64,44},            {48,64,44},     /*240*/
-{44,64,44},            {44,64,48},
-{44,64,52},            {44,64,60},
-{44,64,64},            {44,60,64},
-{44,55,64},            {44,48,64},
-{0,0,0},               {0,0,0},
-{0,0,0},               {0,0,0},
-{0,0,0},               {0,0,0},
-{0,0,0},               {0,0,0}         /*256*/
+{  0,  0,  0},          {  0,  0,168},
+{  0,168,  0},          {  0,168,168},
+{168,  0,  0},          {168,  0,168},
+{168, 84,  0},          {168,168,168},
+{ 84, 84, 84},          { 84, 84,252},
+{ 84,252, 84},          { 84,252,252},
+{252, 84, 84},          {252, 84,252},
+{252,252, 84},          {252,252,252},  /*16*/
+{  0,  0,  0},          { 20, 20, 20},
+{ 32, 32, 32},          { 44, 44, 44},
+{ 56, 56, 56},          { 68, 68, 68},
+{ 80, 80, 80},          { 96, 96, 96},
+{112,112,112},          {128,128,128},
+{144,144,144},          {160,160,160},
+{180,180,180},          {200,200,200},
+{224,224,224},          {252,252,252},  /*32*/
+{  0,  0,252},          { 64,  0,252},
+{124,  0,252},          {188,  0,252},
+{252,  0,252},          {252,  0,188},
+{252,  0,124},          {252,  0, 64},
+{252,  0,  0},          {252, 64,  0},
+{252,124,  0},          {252,188,  0},
+{252,252,  0},          {188,252,  0},
+{124,252,  0},          { 64,252,  0},  /*48*/
+{  0,252,  0},          {  0,252, 64},
+{  0,252,124},          {  0,252,188},
+{  0,252,252},          {  0,188,252},
+{  0,124,252},          {  0, 64,252},
+{124,124,252},          {156,124,252},
+{188,124,252},          {220,124,252},
+{252,124,252},          {252,124,220},
+{252,124,188},          {252,124,156},  /*64*/
+{252,124,124},          {252,156,124},
+{252,188,124},          {252,220,124},
+{252,252,124},          {220,252,124},
+{188,252,124},          {156,252,124},
+{124,252,124},          {124,252,156},
+{124,252,188},          {124,252,220},
+{124,252,252},          {124,220,252},
+{124,188,252},          {124,156,252},  /*80*/
+{180,180,252},          {196,180,252},
+{216,180,252},          {232,180,252},
+{252,180,252},          {252,180,232},
+{252,180,216},          {252,180,196},
+{252,180,180},          {252,196,180},
+{252,216,180},          {252,232,180},
+{252,252,180},          {232,252,180},
+{216,252,180},          {196,252,180},  /*96*/
+{180,220,180},          {180,252,196},
+{180,252,216},          {180,252,232},
+{180,252,252},          {180,232,252},
+{180,216,252},          {180,196,252},
+{0,0,112},              {28,0,112},
+{56,0,112},             {84,0,112},
+{112,0,112},            {112,0,84},
+{112,0,56},             {112,0,28},     /*112*/
+{112,0,0},              {112,28,0},
+{112,56,0},             {112,84,0},
+{112,112,0},            {84,112,0},
+{56,112,0},             {28,112,0},
+{0,112,0},              {0,112,28},
+{0,112,56},             {0,112,84},
+{0,112,112},            {0,84,112},
+{0,56,112},             {0,28,112},     /*128*/
+{56,56,112},            {68,56,112},
+{84,56,112},            {96,56,112},
+{112,56,112},           {112,56,96},
+{112,56,84},            {112,56,68},
+{112,56,56},            {112,68,56},
+{112,84,56},            {112,96,56},
+{112,112,56},           {96,112,56},
+{84,112,56},            {68,112,56},    /*144*/
+{56,112,56},            {56,112,69},
+{56,112,84},            {56,112,96},
+{56,112,112},           {56,96,112},
+{56,84,112},            {56,68,112},
+{80,80,112},            {88,80,112},
+{96,80,112},            {104,80,112},
+{112,80,112},           {112,80,104},
+{112,80,96},            {112,80,88},    /*160*/
+{112,80,80},            {112,88,80},
+{112,96,80},            {112,104,80},
+{112,112,80},           {104,112,80},
+{96,112,80},            {88,112,80},
+{80,112,80},            {80,112,88},
+{80,112,96},            {80,112,104},
+{80,112,112},           {80,114,112},
+{80,96,112},            {80,88,112},    /*176*/
+{0,0,64},               {16,0,64},
+{32,0,64},              {48,0,64},
+{64,0,64},              {64,0,48},
+{64,0,32},              {64,0,16},
+{64,0,0},               {64,16,0},
+{64,32,0},              {64,48,0},
+{64,64,0},              {48,64,0},
+{32,64,0},              {16,64,0},      /*192*/
+{0,64,0},               {0,64,16},
+{0,64,32},              {0,64,48},
+{0,64,64},              {0,48,64},
+{0,32,64},              {0,16,64},
+{32,32,64},             {40,32,64},
+{48,32,64},             {56,32,64},
+{64,32,64},             {64,32,56},
+{64,32,48},             {64,32,40},     /*208*/
+{64,32,32},             {64,40,32},
+{64,48,32},             {64,56,32},
+{64,64,32},             {56,64,32},
+{48,64,32},             {40,64,32},
+{32,64,32},             {32,64,40},
+{32,64,48},             {32,64,56},
+{32,64,64},             {32,56,64},
+{32,48,64},             {32,40,64},     /*224*/
+{44,44,64},             {48,44,64},
+{52,44,64},             {60,44,64},
+{64,44,64},             {64,44,60},
+{64,44,52},             {64,44,48},
+{64,44,44},             {64,48,44},
+{64,52,44},             {64,60,44},
+{64,64,44},             {60,64,44},
+{52,64,44},             {48,64,44},     /*240*/
+{44,64,44},             {44,64,48},
+{44,64,52},             {44,64,60},
+{44,64,64},             {44,60,64},
+{44,55,64},             {44,48,64},
+{0,0,0},                {0,0,0},
+{0,0,0},                {0,0,0},
+{0,0,0},                {0,0,0},
+{0,0,0},                {0,0,0}         /*256*/
 };
 
 
+static int ApproveFormatForWPG(const char *Format)
+{
+  if(!strcmp(Format,"PFB")) return 0;
+  return 1;
+}
+
+
 
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -228,33 +236,32 @@ static unsigned int IsWPG(const unsigned char *magick,const size_t length)
 }
 \f
 
-static void Rd_WP_DWORD(Image *image,unsigned long *d)
+static int Rd_WP_DWORD(Image *image, unsigned long *d)
 {
-  unsigned char
-    b;
+  unsigned char b;
 
-  b=ReadBlobByte(image);
-  *d=b;
+  b = ReadBlobByte(image);
+  *d = b;
   if (b < 0xFFU)
-    return;
-  b=ReadBlobByte(image);
-  *d=(unsigned long) b;
-  b=ReadBlobByte(image);
+    return 1;
+  b = ReadBlobByte(image);
+  *d = (unsigned long) b;
+  b = ReadBlobByte(image);
   *d+=(unsigned long) b*256l;
   if (*d < 0x8000)
-    return;
+    return 3;
   *d=(*d & 0x7FFF) << 16;
+  b = ReadBlobByte(image);
+  *d += (unsigned long) b;
   b=ReadBlobByte(image);
-  *d+=(unsigned long) b;
-  b=ReadBlobByte(image);
-  *d+=(unsigned long) b*256l;
-  return;
+  *d += (unsigned long) b*256l;
+  return 5;
 }
 
 
-static MagickPassFail InsertRow(unsigned char *p,long y, Image *image, int bpp)
+static MagickPassFail InsertRow(unsigned char *p,unsigned long y, Image *image, int bpp)
 {
-  long
+  unsigned long
     x;
   register PixelPacket
     *q;
@@ -262,15 +269,19 @@ static MagickPassFail InsertRow(unsigned char *p,long y, Image *image, int bpp)
   IndexPacket index;
   IndexPacket *indexes;
 
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Insert row %ld of %lu...", y, image->rows);
 
   q = SetImagePixels(image,0,y,image->columns,1);
-  if(q == (PixelPacket *) NULL) return MagickFail;
+  if(q == (PixelPacket *) NULL)
+    return MagickFail;
 
   switch (bpp)
     {
     case 1:  /* Convert bitmap scanline. WP seems to ignore palette even if it is present. */
         RetVal = ImportImagePixelArea(image,GrayQuantum,bpp,p,NULL,0);
-        break; 
+        break;
 
     case 4:  /* Convert PseudoColor scanline. */
     case 8:  /* Convert PseudoColor scanline. */
@@ -280,8 +291,16 @@ static MagickPassFail InsertRow(unsigned char *p,long y, Image *image, int bpp)
     case 2:  /* Convert PseudoColor scanline. */
       {
         indexes=AccessMutableIndexes(image);
+        if ((image->storage_class != PseudoClass) ||
+            (indexes == (IndexPacket *) NULL))
+          {
+            if (image->logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Image has no colormap, skipping...");
+          return MagickFail;
+          }
         x = 0;
-        while(x < (long)image->columns-3)
+        while(x+3 < image->columns)
           {
             index = (IndexPacket)((*p >> 6) & 0x3);
             VerifyColormapIndex(image,index);
@@ -300,20 +319,20 @@ static MagickPassFail InsertRow(unsigned char *p,long y, Image *image, int bpp)
             indexes[x++]=index;
             *q++ = image->colormap[index];
             p++;
-                 }
-        if(x < (long) image->columns)
+          }
+        if(x < image->columns)
           {
             index = (IndexPacket) ((*p >> 6) & 0x3);
             VerifyColormapIndex(image,index);
             indexes[x++] = index;
             *q++=image->colormap[index];
-            if(x < (long) image->columns)
+            if(x < image->columns)
               {
                 index = (IndexPacket) ((*p >> 4) & 0x3);
                 VerifyColormapIndex(image,index);
                 indexes[x++] = index;
                 *q++=image->colormap[index];
-                if(x < (long) image->columns)
+                if(x < image->columns)
                   {
                     index = (IndexPacket)((*p >> 2) & 0x3);
                     VerifyColormapIndex(image,index);
@@ -322,29 +341,36 @@ static MagickPassFail InsertRow(unsigned char *p,long y, Image *image, int bpp)
                   }
               }
             /* p++; */
-          }       
+          }
         RetVal = MagickPass;
         break;
       }
-          
-    case 24:     /*  Convert DirectColor scanline.  */      
+
+    case 24:     /*  Convert DirectColor scanline.  */
       RetVal = ImportImagePixelArea(image,RGBQuantum,8,p,NULL,0);
       break;
 
     default:
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Unsupported bits per pixel %u",bpp);
+
       return MagickFail;  /* emit some error here */
     }
 
 
   if(RetVal==MagickFail)
-    (void) LogMagickEvent(CoderEvent,GetMagickModule(),"ImportImagePixelArea failed for row: %ld, bpp: %d", y, bpp); 
+  {
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),"ImportImagePixelArea failed for row: %lu, bpp: %d", y, bpp);
+    return MagickFail;
+  }
 
-  if (!SyncImagePixels(image))
+  if(!SyncImagePixels(image))
   {
-    (void) LogMagickEvent(CoderEvent,GetMagickModule(),"SyncImagePixels failed for row: %ld, bpp: %d", y, bpp); 
-    RetVal = MagickFail;
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),"SyncImagePixels failed for row: %ld, bpp: %d", y, bpp);
+    return MagickFail;
   }
-          
+
 return RetVal;
 }
 
@@ -356,19 +382,42 @@ return RetVal;
   x++; \
   if((long) x>=ldblk) \
   { \
-    (void)InsertRow(BImgBuff,(long) y,image,bpp); \
+    if(InsertRow(BImgBuff,y,image,bpp)==MagickFail) RetVal=-6; \
     x=0; \
     y++; \
+    if(y>=image->rows) break; \
     } \
 }
 
-/* WPG1 raster reader. */
+
+/** Call this function to ensure that all data matrix is filled with something. This function
+ * is used only to error recovery. */
+static void ZeroFillMissingData(unsigned char *BImgBuff,unsigned long x, unsigned long y, Image *image,
+                                int bpp, long ldblk)
+{
+  while(y < image->rows)
+  {
+    if((long) x<ldblk) memset(BImgBuff+x, 0, ldblk-(long)x);
+    if (InsertRow(BImgBuff,y,image,bpp) == MagickFail)
+      break;
+    x = 0;
+    y++;
+  }
+}
+
+
+/* WPG1 raster reader.
+ * @return      0 - OK; -2 - alocation failure; -3 unaligned column; -4 - image row overflowl
+                -5 - blob read error; -6 - row insert problem  */
 static int UnpackWPGRaster(Image *image,int bpp)
 {
-  int
+  unsigned long
     x,
-    y,
+    y;
+
+  int
     i;
+  int RetVal = 0;
 
   unsigned char
     bbuf,
@@ -381,7 +430,7 @@ static int UnpackWPGRaster(Image *image,int bpp)
   x=0;
   y=0;
 
-  ldblk=(long) ((bpp*image->columns+7)/8);
+  ldblk = (long)((bpp*image->columns+7)/8);
   (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                         "Raster allocation size: %ld byte%s",
                         ldblk, (ldblk > 1 ? "s" : ""));
@@ -389,11 +438,12 @@ static int UnpackWPGRaster(Image *image,int bpp)
   if(BImgBuff==NULL) return(-2);
   (void) memset(BImgBuff,0,(size_t) ldblk);
 
-  while(y<(long) image->rows)
+  while(y<image->rows)
     {
       i = ReadBlobByte(image);
-         if(i==EOF)
-           {
+      if(i==EOF)
+        {
+          ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
           MagickFreeMemory(BImgBuff);
           return(-5);
         }
@@ -422,29 +472,47 @@ static int UnpackWPGRaster(Image *image,int bpp)
               }
           }
         else {  /* repeat previous line runcount* */
-          RunCount=ReadBlobByte(image);
-          if(x) {    /* attempt to duplicate row from x position: */
-            /* I do not know what to do here */
+          i = ReadBlobByte(image);
+          if(i==EOF)
+          {
+            ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
+            MagickFreeMemory(BImgBuff);
+            return -7;
+          }
+          RunCount = i;
+          if(x!=0) {    /* attempt to duplicate row from x position: */
+                        /* I do not know what to do here */
+            if (InsertRow(BImgBuff,y,image,bpp) == MagickPass)   /* May be line flush can fix a situation. */
+              {
+                x=0;
+                y++;
+                ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
+              }
             MagickFreeMemory(BImgBuff);
             return(-3);
           }
-          for(i=0;i < (int) RunCount;i++)
-            {
-              x=0;
-              y++;    /* Here I need to duplicate previous row RUNCOUNT* */
-              if(y<2) continue;
-              if(y>(long) image->rows)
+          for(i=0; i<(int)RunCount; i++)
+            {           /* Here I need to duplicate previous row RUNCOUNT* */
+                        /* when x=0; y points to a new empty line. For y=0 zero line will be populated. */
+              if(y>=image->rows)
                 {
+                  ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
                   MagickFreeMemory(BImgBuff);
                   return(-4);
                 }
-              (void) InsertRow(BImgBuff,y-1,image,bpp);
+              if(InsertRow(BImgBuff,y,image,bpp)==MagickFail)
+                {
+                  ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
+                  MagickFreeMemory(BImgBuff);
+                  return(-6);
+                }
+              y++;
             }
         }
       }
     }
   MagickFreeMemory(BImgBuff);
-  return(0);
+  return(RetVal);
 }
 
 
@@ -458,7 +526,7 @@ static int UnpackWPGRaster(Image *image,int bpp)
   x++; \
   if((long) x >= ldblk) \
   { \
-    (void)InsertRow(BImgBuff,(long) y,image,bpp); \
+    if(InsertRow(BImgBuff,(long) y,image,bpp)==MagickFail) RetVal=-6; \
     x=0; \
     y++; \
     XorMe = 0; \
@@ -483,7 +551,7 @@ static int UnpackWPG2Raster(Image *image, int bpp)
 
   unsigned char
     bbuf,
-    *BImgBuff = (unsigned char *) NULL,          /* Buffer for a current line. */
+    *BImgBuff = (unsigned char *) NULL,   /* Buffer for a current line. */
     *UpImgBuff = (unsigned char *) NULL,  /* Buffer for previous line. */
     *tmpImgBuff = (unsigned char *) NULL,
     RunCount,
@@ -501,6 +569,7 @@ static int UnpackWPG2Raster(Image *image, int bpp)
 
   int XorMe = 0;
   int c;
+  int RetVal = 0;
 
   x=0;
   y=0;
@@ -542,9 +611,9 @@ static int UnpackWPG2Raster(Image *image, int bpp)
             }
           break;
         case 0x7E:
-          if(y==0)                        /* XOR */
-           (void)fprintf(stderr,"\nWPG token XOR on the first line is not supported, please report!");
-         XorMe=!XorMe; /* or XorMe=1 ?? */
+          if(y==0)                         /* XOR */
+            (void)fprintf(stderr,"\nWPG token XOR on the first line is not supported, please report!");
+          XorMe=!XorMe; /* or XorMe=1 ?? */
           break;
         case 0x7F:
           if ((c = ReadBlobByte(image)) == EOF) /* BLK */
@@ -564,8 +633,8 @@ static int UnpackWPG2Raster(Image *image, int bpp)
               FreeUnpackWPG2RasterAllocs(BImgBuff,UpImgBuff);
               return(-4);
             }
-         RunCount=c;
-         for(i=0; i<= RunCount;i++)
+          RunCount=c;
+          for(i=0; i<= RunCount;i++)
             for(bbuf=0; bbuf < SampleSize; bbuf++)
               InsertByte6(SampleBuffer[bbuf]);
           break;
@@ -587,15 +656,18 @@ static int UnpackWPG2Raster(Image *image, int bpp)
           {
             /* duplicate the previous row RunCount x */
             for(i=0;i<=RunCount;i++)
-              {      
-                (void) InsertRow(UpImgBuff,(long) (image->rows >= y ? y : image->rows-1),
-                                 image,bpp);
+              {
+                if(InsertRow(UpImgBuff,(long)((image->rows>y) ? y : image->rows-1),image,bpp) == MagickFail)
+                  {
+                    FreeUnpackWPG2RasterAllocs(BImgBuff,UpImgBuff);
+                    return(-4);
+                  }
                 y++;
-              }    
+              }
           }
           break;
         case 0xFF:
-          if ((c = ReadBlobByte(image)) == EOF)         /* WHT */
+          if ((c = ReadBlobByte(image)) == EOF)  /* WHT */
             {
               FreeUnpackWPG2RasterAllocs(BImgBuff,UpImgBuff);
               return(-4);
@@ -609,15 +681,15 @@ static int UnpackWPG2Raster(Image *image, int bpp)
         default:
           RunCount=bbuf & 0x7F;
 
-          if(bbuf & 0x80)               /* REP */
-            {  
+          if(bbuf & 0x80)                /* REP */
+            {
               for(i=0; i < SampleSize; i++)
                 SampleBuffer[i]=ReadBlobByte(image);
               for(i=0;i<=RunCount;i++)
                 for(bbuf=0;bbuf<SampleSize;bbuf++)
                   InsertByte6(SampleBuffer[bbuf]);
             }
-          else {                       /* NRP */
+          else {                        /* NRP */
             for(i=0; i< SampleSize*(RunCount+1);i++)
               {
                 bbuf=ReadBlobByte(image);
@@ -632,7 +704,7 @@ static int UnpackWPG2Raster(Image *image, int bpp)
         }
     }
   FreeUnpackWPG2RasterAllocs(BImgBuff,UpImgBuff);
-  return(0);
+  return(RetVal);
 }
 
 
@@ -651,50 +723,50 @@ unsigned Flags;
  (*CTM)[2][2]=1;
 
  Flags=ReadBlobLSBShort(image);
- if(Flags & LCK) /*x=*/ (void) ReadBlobLSBLong(image); /*Edit lock*/
+ if(Flags & LCK) /*x=*/ (void) ReadBlobLSBLong(image);  /*Edit lock*/
  if(Flags & OID)
-       {
-       if(Precision==0)
-         {/*x=*/ (void) ReadBlobLSBShort(image);}      /*ObjectID*/
-       else
-         {/*x=*/ (void) ReadBlobLSBLong(image);}       /*ObjectID (Double precision)*/
-       }
+        {
+        if(Precision==0)
+          {/*x=*/ (void) ReadBlobLSBShort(image);}      /*ObjectID*/
+        else
+          {/*x=*/ (void) ReadBlobLSBLong(image);}       /*ObjectID (Double precision)*/
+        }
  if(Flags & ROT)
-       {
-        x=ReadBlobLSBLong(image);      /*Rot Angle*/
-       if(Angle) *Angle=x/65536.0;
-       }
+        {
+        x=ReadBlobLSBLong(image);       /*Rot Angle*/
+        if(Angle) *Angle=x/65536.0;
+        }
  if(Flags & (ROT|SCL))
-       {
-       x=ReadBlobLSBLong(image);       /*Sx*cos()*/
-       (*CTM)[0][0] = (float)x/0x10000;
-       x=ReadBlobLSBLong(image);       /*Sy*cos()*/
-       (*CTM)[1][1] = (float)x/0x10000;
-       }
+        {
+        x=ReadBlobLSBLong(image);       /*Sx*cos()*/
+        (*CTM)[0][0] = (float)x/0x10000;
+        x=ReadBlobLSBLong(image);       /*Sy*cos()*/
+        (*CTM)[1][1] = (float)x/0x10000;
+        }
  if(Flags & (ROT|SKW))
-       {
-       x=ReadBlobLSBLong(image);       /*Kx*sin()*/
-       (*CTM)[1][0] = (float)x/0x10000;
-       x=ReadBlobLSBLong(image);       /*Ky*sin()*/
-       (*CTM)[0][1] = (float)x/0x10000;
-       }
+        {
+        x=ReadBlobLSBLong(image);       /*Kx*sin()*/
+        (*CTM)[1][0] = (float)x/0x10000;
+        x=ReadBlobLSBLong(image);       /*Ky*sin()*/
+        (*CTM)[0][1] = (float)x/0x10000;
+        }
  if(Flags & TRN)
-       {
-       x=ReadBlobLSBLong(image); DenX=ReadBlobLSBShort(image);  /*Tx*/
+        {
+        x=ReadBlobLSBLong(image); DenX=ReadBlobLSBShort(image);  /*Tx*/
         if(x>=0) (*CTM)[0][2] = (float)x+(float)DenX/0x10000;
             else (*CTM)[0][2] = (float)x-(float)DenX/0x10000;
-       x=ReadBlobLSBLong(image); DenX=ReadBlobLSBShort(image);  /*Ty*/
-       (*CTM)[1][2]=(float)x + ((x>=0)?1:-1)*(float)DenX/0x10000;
+        x=ReadBlobLSBLong(image); DenX=ReadBlobLSBShort(image);  /*Ty*/
+        (*CTM)[1][2]=(float)x + ((x>=0)?1:-1)*(float)DenX/0x10000;
         if(x>=0) (*CTM)[1][2] = (float)x+(float)DenX/0x10000;
             else (*CTM)[1][2] = (float)x-(float)DenX/0x10000;
-       }
+        }
  if(Flags & TPR)
-       {
-       x=ReadBlobLSBShort(image); DenX=ReadBlobLSBShort(image);  /*Px*/
-       (*CTM)[2][0] = x + (float)DenX/0x10000;;
-       x=ReadBlobLSBShort(image);  DenX=ReadBlobLSBShort(image); /*Py*/
-       (*CTM)[2][1] = x + (float)DenX/0x10000;
-       }
+        {
+        x=ReadBlobLSBShort(image); DenX=ReadBlobLSBShort(image);  /*Px*/
+        (*CTM)[2][0] = x + (float)DenX/0x10000;;
+        x=ReadBlobLSBShort(image);  DenX=ReadBlobLSBShort(image); /*Py*/
+        (*CTM)[2][1] = x + (float)DenX/0x10000;
+        }
  return(Flags);
 }
 
@@ -713,13 +785,13 @@ static Image *ExtractPostscript(Image *image,const ImageInfo *image_info,
 
   Image
     *image2;
-    
+
   unsigned char
     magick[2*MaxTextExtent];
 
   size_t
     magick_size;
-    
+
 
   if ((clone_info=CloneImageInfo(image_info)) == NULL)
     return(image);
@@ -727,7 +799,7 @@ static Image *ExtractPostscript(Image *image,const ImageInfo *image_info,
   clone_info->length=0;
 
   /* Obtain temporary file */
-  ps_file=AcquireTemporaryFileStream(postscript_file,BinaryFileIOMode);
+  ps_file = AcquireTemporaryFileStream(postscript_file,BinaryFileIOMode);
   if (!ps_file)
     {
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"Gannot create file stream for PS image");
@@ -735,46 +807,106 @@ static Image *ExtractPostscript(Image *image,const ImageInfo *image_info,
     }
 
   /* Copy postscript to temporary file */
-  (void) SeekBlob(image,PS_Offset,SEEK_SET);
-  magick_size=ReadBlob(image, sizeof(magick), magick);
-  
-  (void) SeekBlob(image,PS_Offset,SEEK_SET);
+  if(SeekBlob(image,PS_Offset,SEEK_SET) != PS_Offset) goto BAD_SEEK;
+  magick_size = ReadBlob(image, sizeof(magick), magick);
+
+  if(SeekBlob(image,PS_Offset,SEEK_SET) != PS_Offset)
+  {
+BAD_SEEK:
+    (void) fclose(ps_file);
+    ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,image->filename);
+    goto FINISH_UNL;
+  }
+
   while(PS_Size-- > 0)
     {
-      (void) fputc(ReadBlobByte(image),ps_file);
+      int c;
+      if ((c = ReadBlobByte(image)) == EOF)
+        {
+          (void) fclose(ps_file);
+          ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,image->filename);
+          goto FINISH_UNL;
+        }
+      (void) fputc(c,ps_file);
     }
   (void) fclose(ps_file);
-  
+
   /* Detect file format - Check magic.mgk configuration file. */
   if (GetMagickFileFormat(magick,magick_size,clone_info->magick,
-                           MaxTextExtent,exception) == MagickFail)
+          MaxTextExtent,exception) == MagickFail)
+    {
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "Failed to identify embedded file type!");
+      ThrowException(exception,CorruptImageError,UnableToReadImageHeader,image->filename);
+      goto FINISH_UNL;
+    }
+
+  if(!ApproveFormatForWPG(clone_info->magick))
+  {
+    (void) LogMagickEvent(CoderEvent, GetMagickModule(),
+                        "Format \"%s\" cannot be embedded inside WPG.", clone_info->magick);
+    ThrowException(exception,CorruptImageError,UnableToReadImageHeader,image->filename);
     goto FINISH_UNL;
-  
-  /* Read nested image */
-  /*FormatString(clone_info->filename,"%s:%.1024s",magic_info->name,postscript_file);*/
-  FormatString(clone_info->filename,"%.1024s",postscript_file);
-  image2=ReadImage(clone_info,exception);
+  }
+
+  (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                        "Reading embedded \"%s\" content...", clone_info->magick);
+
+  /* Read nested image, forcing read as Postscript format */
+  FormatString(clone_info->filename,"%s:%.1024s",clone_info->magick,postscript_file);
+  image2 = ReadImage(clone_info,exception);
 
   if (!image2)
     goto FINISH_UNL;
+  if(exception->severity>=ErrorException) /* When exception is raised, destroy image2 read. */
+  {
+    CloseBlob(image2);
+    DestroyImageList(image2);
+    goto FINISH_UNL;
+  }
 
   /*
     Replace current image with new image while copying base image
     attributes.
   */
-  (void) strlcpy(image2->filename,image->filename,MaxTextExtent);
-  (void) strlcpy(image2->magick_filename,image->magick_filename,MaxTextExtent);
-  (void) strlcpy(image2->magick,image->magick,MaxTextExtent);
-  image2->depth=image->depth;
-  DestroyBlob(image2);
-  image2->blob=ReferenceBlob(image->blob);
-
-  if ((image->rows == 0) || (image->columns == 0))
+  {
+    Image *p;
+    p = image2;
+    do
+    {
+      (void) strlcpy(p->filename,image->filename,MaxTextExtent);
+      (void) strlcpy(p->magick_filename,image->magick_filename,MaxTextExtent);
+      (void) strlcpy(p->magick,image->magick,MaxTextExtent);
+      /*image2->depth=image->depth;*/   /* !!!! The image2 depth should not be modified here. Image2 is completely different. */
+      DestroyBlob(p);
+
+      if(p->rows==0 || p->columns==0)
+      {
+        DeleteImageFromList(&p);
+        if(p==NULL)
+        {
+          image2 = NULL;
+          goto FINISH_UNL;      /* Nothing to add, skip. */
+        }
+      }
+      else
+      {
+        p->blob = ReferenceBlob(image->blob);
+        p = p->next;
+      }
+    } while(p!=NULL);
+  }
+
+  if((image->rows==0 || image->columns==0) && (image->previous!=NULL || image->next!=NULL))
+  {
     DeleteImageFromList(&image);
+  }
 
-  AppendImageToList(&image,image2);
+  AppendImageToList(&image,image2);     /* This should append list 'image2' to the list 'image', image2 accepts NULL. */
+  while(image->next != NULL)
+    image = image->next;                /* Rewind the cursor to the end. */
 
- FINISH_UNL:    
+ FINISH_UNL:
   (void) LiberateTemporaryFile(postscript_file);
  FINISH:
   DestroyImageInfo(clone_info);
@@ -819,7 +951,7 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
   typedef struct
   {
     unsigned long FileId;
-    ExtendedSignedIntegralType DataOffset;
+    ExtendedSignedIntegralType DataOffset;  /* magick_uint32_t */
     unsigned int ProductType;
     unsigned int FileType;
     unsigned char MajorVersion;
@@ -844,8 +976,8 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
 
   typedef struct
   {
-    unsigned   HorizontalUnits;
-    unsigned   VerticalUnits;
+    unsigned    HorizontalUnits;
+    unsigned    VerticalUnits;
     unsigned char PosSizePrecision;
   } WPG2Start;
 
@@ -936,6 +1068,7 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
   unsigned char
     *BImgBuff;
   BlobInfo *TmpBlob;
+  magick_off_t FilePos, filesize;
 
   tCTM CTM;         /*current transform matrix*/
 
@@ -947,7 +1080,7 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
 
-  logging = LogMagickEvent(CoderEvent,GetMagickModule(),"enter"); 
+  logging = LogMagickEvent(CoderEvent,GetMagickModule(),"enter");
 
   image=AllocateImage(image_info);
   image->depth=8;
@@ -978,34 +1111,60 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
   if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
           "File type: %d", Header.FileType);
 
+        /* Determine file size. */
+  filesize = GetBlobSize(image);              /* zero is returned if the size cannot be determined. */
+  if(filesize>0 && BlobIsSeekable(image))
+  {
+    if(filesize > (magick_off_t)0xFFFFFFFF)
+        filesize = (magick_off_t)0xFFFFFFFF;  /* More than 4GiB are not supported in MAT! */
+  }
+  else
+  {
+    filesize = (magick_off_t)0xFFFFFFFF;
+    if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+          "Blob is not seekable, WPG reader could fail.");
+    ThrowReaderException(CorruptImageError,AnErrorHasOccurredReadingFromFile,image);
+  }
+
   switch(Header.FileType)
     {
     case 1:     /* WPG level 1 */
       BitmapHeader2.RotAngle = 0;
-
+      FilePos = Header.DataOffset;
       while(!EOFBlob(image)) /* object parser loop */
         {
-          (void) SeekBlob(image,Header.DataOffset,SEEK_SET);
-          if(EOFBlob(image))
+          if(SeekBlob(image,FilePos,SEEK_SET) != FilePos)
             break;
 
-          Rec.RecType=(i=ReadBlobByte(image));
-          if(i==EOF)
-            break;
-          Rd_WP_DWORD(image,&Rec.RecordLength);
-          if(EOFBlob(image))
-            break;
+          Rec.RecType = (i=ReadBlobByte(image));
+          if(i==EOF) break;
+          FilePos += 1;
 
-          Header.DataOffset=TellBlob(image)+Rec.RecordLength;
+          FilePos += Rd_WP_DWORD(image,&Rec.RecordLength);
+          if((magick_off_t)Rec.RecordLength > filesize)
+            ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+          if(EOFBlob(image)) break;
+
+          FilePos += (magick_off_t)Rec.RecordLength;
+          if(FilePos>filesize || FilePos<Header.DataOffset)
+          {
+            if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+                "Invalid record length: %X", (unsigned)Rec.RecType);
+            break;
+          }
+          Header.DataOffset = FilePos;
 
           if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
             "Parsing object: %X", Rec.RecType);
+          //printf("\nParsing object: %u:%X", (unsigned)FilePos, Rec.RecType);
 
           switch(Rec.RecType)
             {
             case 0x0B: /* bitmap type 1 */
               BitmapHeader1.Width=ReadBlobLSBShort(image);
               BitmapHeader1.Heigth=ReadBlobLSBShort(image);
+              if ((BitmapHeader1.Width == 0) || (BitmapHeader1.Heigth == 0))
+                ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
               BitmapHeader1.Depth=ReadBlobLSBShort(image);
               BitmapHeader1.HorzRes=ReadBlobLSBShort(image);
               BitmapHeader1.VertRes=ReadBlobLSBShort(image);
@@ -1033,21 +1192,19 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
               for (i=WPG_Palette.StartIndex;
                    i < (int)WPG_Palette.NumOfEntries; i++)
                 {
-                  image->colormap[i].red=
-                    ScaleCharToQuantum(ReadBlobByte(image));
-                  image->colormap[i].green=
-                    ScaleCharToQuantum(ReadBlobByte(image));
-                  image->colormap[i].blue=
-                    ScaleCharToQuantum(ReadBlobByte(image));
+                  image->colormap[i].red=ScaleCharToQuantum(ReadBlobByte(image));
+                  image->colormap[i].green=ScaleCharToQuantum(ReadBlobByte(image));
+                  image->colormap[i].blue=ScaleCharToQuantum(ReadBlobByte(image));
+                  image->colormap[i].opacity = OpaqueOpacity;
                 }
               break;
-     
+
             case 0x11:  /* Start PS l1 */
               if(Rec.RecordLength > 8)
                 image=ExtractPostscript(image,image_info,
                                         TellBlob(image)+8,   /* skip PS header in the wpg */
                                         (long) Rec.RecordLength-8,exception);
-              break;     
+              break;
 
             case 0x14:  /* bitmap type 2 */
               BitmapHeader2.RotAngle=ReadBlobLSBShort(image);
@@ -1057,6 +1214,8 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
               BitmapHeader2.UpRightY=ReadBlobLSBShort(image);
               BitmapHeader2.Width=ReadBlobLSBShort(image);
               BitmapHeader2.Heigth=ReadBlobLSBShort(image);
+              if ((BitmapHeader2.Width == 0) || (BitmapHeader2.Heigth == 0))
+                ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
               BitmapHeader2.Depth=ReadBlobLSBShort(image);
               BitmapHeader2.HorzRes=ReadBlobLSBShort(image);
               BitmapHeader2.VertRes=ReadBlobLSBShort(image);
@@ -1077,8 +1236,11 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
               image->rows=BitmapHeader2.Heigth;
               bpp=BitmapHeader2.Depth;
 
-            UnpackRaster:          
-              if ((image->colors == 0) && (bpp != 24))
+            UnpackRaster:
+              if(bpp>24)
+                {ThrowReaderException(CoderError,ColorTypeNotSupported,image)}
+
+              if ((image->storage_class != PseudoClass) && (bpp != 24))
                 {
                   image->colors=1 << bpp;
                   if (!AllocateImageColormap(image,image->colors))
@@ -1090,10 +1252,11 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
                   image->storage_class = PseudoClass;
                   /* printf("Load default colormap \n"); */
                   for (i=0; (i < (int) image->colors) && (i < 256); i++)
-                    {               
+                    {
                       image->colormap[i].red=ScaleCharToQuantum(WPG1_Palette[i].Red);
                       image->colormap[i].green=ScaleCharToQuantum(WPG1_Palette[i].Green);
                       image->colormap[i].blue=ScaleCharToQuantum(WPG1_Palette[i].Blue);
+                      image->colormap[i].opacity = OpaqueOpacity;
                     }
                 }
               else
@@ -1103,31 +1266,36 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
                       MagickReallocMemory(PixelPacket *,image->colormap,
                                           (size_t) (1U<<bpp)*sizeof(PixelPacket));
                 }
-          
-              if (bpp == 1)
+
+              if(bpp == 1)
                 {
-                  if(image->colormap[0].red==0 &&
-                     image->colormap[0].green==0 &&
-                     image->colormap[0].blue==0 &&
-                     image->colormap[1].red==0 &&
-                     image->colormap[1].green==0 &&
-                     image->colormap[1].blue==0)
+                  if(image->colors<=0)
+                                  {
+                                image->colormap[0].red =
+                        image->colormap[0].green =
+                        image->colormap[0].blue = 0;
+                      image->colormap[0].opacity = OpaqueOpacity;
+                                  }
+                  if(image->colors<=1 ||        /* Realloc has been enforced and value [1] remains uninitialised, or .. */
+                                           (image->colormap[0].red==0 && image->colormap[0].green==0 && image->colormap[0].blue==0 &&
+                        image->colormap[1].red==0 && image->colormap[1].green==0 && image->colormap[1].blue==0))
                     {  /* fix crippled monochrome palette */
                       image->colormap[1].red =
                         image->colormap[1].green =
                         image->colormap[1].blue = MaxRGB;
+                      image->colormap[1].opacity = OpaqueOpacity;
                     }
-                }      
+                }
 
               if(!image_info->ping)
-                if(UnpackWPGRaster(image,bpp) < 0)                
-                {              /* The raster cannot be unpacked */
+                if(UnpackWPGRaster(image,bpp) < 0)
+                {               /* The raster cannot be unpacked */
                 DecompressionFailed:
                   ThrowReaderException(CoderError,UnableToDecompressImage,image)
                 }
 
               if(Rec.RecType==0x14 && BitmapHeader2.RotAngle!=0 && !image_info->ping)
-                {  
+                {
                   /* flop command */
                   if(BitmapHeader2.RotAngle & 0x8000)
                     {
@@ -1152,8 +1320,8 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
                           ReplaceImageInList(&image,rotated_image);
                         }
                     }
-               
-                 /* rotate command */
+
+                  /* rotate command */
                   if(BitmapHeader2.RotAngle & 0x0FFF)
                     {
                       rotated_image = RotateImage(image,
@@ -1166,7 +1334,7 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
                           image->blob = TmpBlob;
                           ReplaceImageInList(&image,rotated_image);
                         }
-                    }                
+                    }
                 }
 
               /* Allocate next image structure. */
@@ -1194,7 +1362,8 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
       StartWPG.PosSizePrecision = 0;
       while(!EOFBlob(image)) /* object parser loop */
         {
-          (void) SeekBlob(image,Header.DataOffset,SEEK_SET);
+          if(SeekBlob(image,Header.DataOffset,SEEK_SET) != Header.DataOffset)
+            break;
           if(EOFBlob(image))
             break;
 
@@ -1216,7 +1385,7 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
 
           switch(Rec2.RecType)
             {
-           case 1:
+            case 1:
               StartWPG.HorizontalUnits=ReadBlobLSBShort(image);
               StartWPG.VerticalUnits=ReadBlobLSBShort(image);
               StartWPG.PosSizePrecision=ReadBlobByte(image);
@@ -1225,10 +1394,18 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
               WPG_Palette.StartIndex=ReadBlobLSBShort(image);
               WPG_Palette.NumOfEntries=ReadBlobLSBShort(image);
 
-                       /* Sanity check for amount of palette entries. */
-              if( (WPG_Palette.NumOfEntries-WPG_Palette.StartIndex) > (Rec2.RecordLength-2-2) / 3)
-                 ThrowReaderException(CorruptImageError,InvalidColormapIndex,image);                 
+              /* Sanity check for amount of palette entries. */
+              if (WPG_Palette.NumOfEntries == 0)
+                ThrowReaderException(CorruptImageError,UnrecognizedNumberOfColors,image);
+
+              if (WPG_Palette.NumOfEntries > MaxMap+1)
+                ThrowReaderException(CorruptImageError,ColormapExceedsColorsLimit,image);
+
+              if ( (WPG_Palette.StartIndex > WPG_Palette.NumOfEntries) ||
+                   (((WPG_Palette.NumOfEntries-WPG_Palette.StartIndex) >
+                     ((Rec2.RecordLength-2-2) / 3))) )
+                 ThrowReaderException(CorruptImageError,InvalidColormapIndex,image);
+
               image->colors=WPG_Palette.NumOfEntries;
               if (!AllocateImageColormap(image,image->colors))
                 ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
@@ -1239,12 +1416,15 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
                   image->colormap[i].red=ScaleCharToQuantum(ReadBlobByte(image));
                   image->colormap[i].green=ScaleCharToQuantum(ReadBlobByte(image));
                   image->colormap[i].blue=ScaleCharToQuantum(ReadBlobByte(image));
+                  image->colormap[i].opacity = OpaqueOpacity;
                   (void) ReadBlobByte(image);   /*Opacity??*/
                 }
               break;
             case 0x0E:
               Bitmap2Header1.Width=ReadBlobLSBShort(image);
               Bitmap2Header1.Heigth=ReadBlobLSBShort(image);
+              if ((Bitmap2Header1.Width == 0) || (Bitmap2Header1.Heigth == 0))
+                ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
               Bitmap2Header1.Depth=ReadBlobByte(image);
               Bitmap2Header1.Compression=ReadBlobByte(image);
 
@@ -1252,7 +1432,7 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
                 continue; /*Unknown compression method */
               switch(Bitmap2Header1.Depth)
                 {
-                case 1: bpp=1; 
+                case 1: bpp=1;
                   break;
                 case 2: bpp=2;
                   break;
@@ -1266,7 +1446,7 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
                   continue;  /*Ignore raster with unknown depth*/
                 }
               image->columns=Bitmap2Header1.Width;
-              image->rows=Bitmap2Header1.Heigth;  
+              image->rows=Bitmap2Header1.Heigth;
 
               if ((image->colors == 0) && (bpp != 24))
                 {
@@ -1295,12 +1475,20 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
 
                     for(i=0; i< (long) image->rows; i++)
                       {
-                        (void) ReadBlob(image,ldblk,(char *) BImgBuff);
-                        (void) InsertRow(BImgBuff,i,image,bpp);
+                        if (ReadBlob(image,ldblk,(char *) BImgBuff) != (size_t) ldblk)
+                          {
+                            MagickFreeMemory(BImgBuff);
+                            ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,image->filename);
+                            goto DecompressionFailed;
+                          }
+                        if(InsertRow(BImgBuff,i,image,bpp) == MagickFail)
+                        {
+                          if(BImgBuff) MagickFreeMemory(BImgBuff);
+                          goto DecompressionFailed;
+                        }
                       }
 
-                    if(BImgBuff)
-                      MagickFreeMemory(BImgBuff);
+                    if(BImgBuff) MagickFreeMemory(BImgBuff);
                     break;
                   }
                 case 1:    /*RLE for WPG2 */
@@ -1308,13 +1496,13 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
                     if( UnpackWPG2Raster(image,bpp) < 0)
                       goto DecompressionFailed;
                     break;
-                  }   
+                  }
                 }
 
 
               if(CTM[0][0]<0 && !image_info->ping)
-               {               /*?? RotAngle=360-RotAngle;*/
-                 rotated_image = FlopImage(image, exception);
+                {               /*?? RotAngle=360-RotAngle;*/
+                  rotated_image = FlopImage(image, exception);
                   if (rotated_image != (Image *) NULL)
                     {
                       TmpBlob = rotated_image->blob;
@@ -1322,15 +1510,15 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
                       image->blob = TmpBlob;
                       ReplaceImageInList(&image,rotated_image);
                     }
-                  /* Try to change CTM according to Flip - I am not sure, must be checked.               
+                  /* Try to change CTM according to Flip - I am not sure, must be checked.
                      Tx(0,0)=-1;      Tx(1,0)=0;   Tx(2,0)=0;
                      Tx(0,1)= 0;      Tx(1,1)=1;   Tx(2,1)=0;
                      Tx(0,2)=(WPG._2Rect.X_ur+WPG._2Rect.X_ll);
-                     Tx(1,2)=0;   Tx(2,2)=1; */                  
+                     Tx(1,2)=0;   Tx(2,2)=1; */
                 }
               if(CTM[1][1]<0 && !image_info->ping)
-               {               /*?? RotAngle=360-RotAngle;*/
-                 rotated_image = FlipImage(image, exception);
+                {               /*?? RotAngle=360-RotAngle;*/
+                  rotated_image = FlipImage(image, exception);
                   if (rotated_image != (Image *) NULL)
                     {
                       TmpBlob = rotated_image->blob;
@@ -1343,9 +1531,9 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
                      Tx(0,0)= 1;   Tx(1,0)= 0;   Tx(2,0)=0;
                      Tx(0,1)= 0;   Tx(1,1)=-1;   Tx(2,1)=0;
                      Tx(0,2)= 0;   Tx(1,2)=(WPG._2Rect.Y_ur+WPG._2Rect.Y_ll);
-                     Tx(2,2)=1; */               
-               }               
-               
+                     Tx(2,2)=1; */
+                }
+
 
               /* Allocate next image structure. */
               AllocateNextImage(image_info,image);
@@ -1358,14 +1546,14 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
               break;
 
             case 0x12:  /* Postscript WPG2*/
-             i=ReadBlobLSBShort(image);
+              i=ReadBlobLSBShort(image);
               if(Rec2.RecordLength > (unsigned int) i)
                 image=ExtractPostscript(image,image_info,
-                                        TellBlob(image)+i,             /*skip PS header in the wpg2*/
+                                        TellBlob(image)+i,              /*skip PS header in the wpg2*/
                                         (long) (Rec2.RecordLength-i-2),exception);
               break;
 
-           case 0x1B:          /*bitmap rectangle*/
+            case 0x1B:          /*bitmap rectangle*/
               (void) LoadWPG2Flags(image,StartWPG.PosSizePrecision,NULL,&CTM); /* WPG2Flags */
               break;
             }
@@ -1385,10 +1573,10 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
   {
     Image
       *p;
-    
+
     long
       scene=0;
-    
+
     /*
       Rewind list, removing any empty images while rewinding.
     */
@@ -1405,7 +1593,7 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
           p=p->previous;
         }
       }
-    
+
     /*
       Fix scene numbers
     */
@@ -1413,10 +1601,10 @@ static Image *ReadWPGImage(const ImageInfo *image_info,
       p->scene=scene++;
   }
 
-  if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),"return");  
+  if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),"return");
   if(image==NULL)
     ThrowReaderException(CorruptImageError,ImageFileDoesNotContainAnyImageData,image);
-  return(image);   
+  return(image);
 }
 \f
 /*
index b33e05e..b5cdf0b 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 -2012 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -119,16 +119,23 @@ static unsigned int IsXBM(const unsigned char *magick,const size_t length)
 %
 */
 
-static int XBMInteger(Image *image,short int *hex_digits)
+static int XBMInteger(Image *image,const unsigned int max_digits, short int *hex_digits)
 {
+  unsigned int
+    digits;
+
   int
     c,
-    flag,
     value;
 
+  /*
+    Read hex value in form 0xhh or 0xhhhh from text which may look
+    like ", 0x7f".  FIXME: This implementation is non-validating.
+  */
+
   value=0;
-  flag=0;
-  for ( ; )
+  digits=0U;
+  for ( digits=0U; digits <= max_digits+1; )
   {
     c=ReadBlobByte(image);
     if (c == EOF)
@@ -140,12 +147,15 @@ static int XBMInteger(Image *image,short int *hex_digits)
     if (isxdigit(c))
       {
         value=(value << 4)+hex_digits[c];
-        flag++;
+        digits++;
         continue;
       }
-    if ((hex_digits[c]) < 0 && flag)
+    if ((hex_digits[c]) < 0 && digits)
       break;
   }
+  /* The '0' in '0x' is currently counted as a digit */
+  if (digits > max_digits+1)
+    value=(-1);
   return(value);
 }
 
@@ -158,18 +168,20 @@ static Image *ReadXBMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   Image
     *image;
 
-  int
-    bit;
-
-  long
-    y;
-
   register IndexPacket
     *indexes;
 
-  register long
-    i,
-    x;
+  register size_t
+    bytes_per_line,
+    i;
+
+  unsigned long
+    x,
+    y;
+
+  long
+    columns_signed,
+    rows_signed;
 
   register PixelPacket
     *q;
@@ -177,22 +189,24 @@ static Image *ReadXBMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   register unsigned char
     *p;
 
-  short int
-    hex_digits[256];
-
   unsigned char
     *data;
 
   unsigned int
-    status;
-
-  unsigned long
+    bit,
     byte,
-    bytes_per_line,
     padding,
-    value,
     version;
 
+  int
+    value;
+
+  short int
+    hex_digits[256];
+
+  MagickPassFail
+    status;
+
   /*
     Open image file.
   */
@@ -207,16 +221,26 @@ static Image *ReadXBMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Read X bitmap header.
   */
+  (void) memset(buffer,0,sizeof(buffer));
+  name[0]='\0';
+  columns_signed=0;
+  rows_signed=0;
   while (ReadBlobString(image,buffer) != (char *) NULL)
-    if (sscanf(buffer,"#define %s %lu",name,&image->columns) == 2)
+    if (sscanf(buffer,"#define %s %ld",name,&columns_signed) == 2)
       if ((strlen(name) >= 6) &&
           (LocaleCompare(name+strlen(name)-6,"_width") == 0))
           break;
   while (ReadBlobString(image,buffer) != (char *) NULL)
-    if (sscanf(buffer,"#define %s %lu",name,&image->rows) == 2)
+    if (sscanf(buffer,"#define %s %ld",name,&rows_signed) == 2)
       if ((strlen(name) >= 7) &&
           (LocaleCompare(name+strlen(name)-7,"_height") == 0))
           break;
+  if (EOFBlob(image))
+      ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+  if ((columns_signed <= 0) || (rows_signed <= 0))
+    ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+  image->columns=(unsigned long) columns_signed;
+  image->rows=(unsigned long) rows_signed;
   image->depth=8;
   image->storage_class=PseudoClass;
   image->colors=2;
@@ -244,8 +268,9 @@ static Image *ReadXBMImage(const ImageInfo *image_info,ExceptionInfo *exception)
     if (LocaleCompare("bits[]",(char *) p) == 0)
       break;
   }
-  if ((image->columns == 0) || (image->rows == 0) || EOFBlob(image))
-    ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+  if (EOFBlob(image))
+    ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+
   /*
     Initialize image structure.
   */
@@ -265,6 +290,8 @@ static Image *ReadXBMImage(const ImageInfo *image_info,ExceptionInfo *exception)
       CloseBlob(image);
       return(image);
     }
+  if (CheckImagePixelLimits(image, exception) != MagickPass)
+      ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
   /*
     Allocate temporary storage for X bitmap image
   */
@@ -278,6 +305,8 @@ static Image *ReadXBMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   /*
     Initialize hex values.
   */
+  for (i = 0; i < sizeof(hex_digits)/sizeof(hex_digits[0]); i++)
+    hex_digits[i]=(-1);
   hex_digits['0']=0;
   hex_digits['1']=1;
   hex_digits['2']=2;
@@ -311,47 +340,57 @@ static Image *ReadXBMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   */
   p=data;
   if (version == 10)
-    for (i=0; i < (long) (bytes_per_line*image->rows); (i+=2))
+    for (i=0; i < (bytes_per_line*image->rows); (i+=2))
     {
-      value=XBMInteger(image,hex_digits);
+      value=XBMInteger(image,4,hex_digits);
+      if (value < 0)
+        {
+          MagickFreeMemory(data);
+          ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+        }
       *p++=(unsigned char) value;
       if (!padding || ((i+2) % bytes_per_line))
         *p++=(unsigned char) (value >> 8);
     }
   else
-    for (i=0; i < (long) (bytes_per_line*image->rows); i++)
+    for (i=0; i < (bytes_per_line*image->rows); i++)
     {
-      value=XBMInteger(image,hex_digits);
+      value=XBMInteger(image,2,hex_digits);
+      if (value < 0)
+        {
+          MagickFreeMemory(data);
+          ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+        }
       *p++=(unsigned char) value;
     }
   /*
     Convert X bitmap image to pixel packets.
   */
   p=data;
-  for (y=0; y < (long) image->rows; y++)
+  for (y=0; y < image->rows; y++)
   {
     q=SetImagePixels(image,0,y,image->columns,1);
     if (q == (PixelPacket *) NULL)
       break;
     indexes=AccessMutableIndexes(image);
-    bit=0;
-    byte=0;
-    for (x=0; x < (long) image->columns; x++)
+    bit=0U;
+    byte=0U;
+    for (x=0; x < image->columns; x++)
     {
-      if (bit == 0)
+      if (bit == 0U)
         byte=(*p++);
       indexes[x]=byte & 0x01 ? 0x01 : 0x00;
       bit++;
-      byte>>=1;
-      if (bit == 8)
-        bit=0;
+      byte>>=1U;
+      if (bit == 8U)
+        bit=0U;
     }
     if (!SyncImagePixels(image))
       break;
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,exception,
                                   LoadImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
          break;
   }
   MagickFreeMemory(data);
@@ -570,7 +609,7 @@ static unsigned int WriteXBMImage(const ImageInfo *image_info,Image *image)
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                   SaveImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   (void) strcpy(buffer,"};\n");
index a4bd5b5..71260bf 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -102,7 +102,7 @@ typedef struct {
     compression;
 
   /* not really part of the doc, but makes it easy to pass around! */
-  ExceptionInfo 
+  ExceptionInfo
     *exception;
 
   /* File size */
@@ -307,7 +307,7 @@ static char *ReadBlobStringWithLongSize(Image *image,char *string,size_t max)
 }
 
 \f
-static MagickPassFail load_tile (Image* image, Image* tile_image, XCFDocInfo* inDocInfo, 
+static MagickPassFail load_tile (Image* image, Image* tile_image, XCFDocInfo* inDocInfo,
                                  XCFLayerInfo*  inLayerInfo, size_t data_length)
 {
   size_t
@@ -365,9 +365,7 @@ static MagickPassFail load_tile (Image* image, Image* tile_image, XCFDocInfo* in
   if (nmemb_read_successfully != data_length)
     {
       MagickFreeMemory(xcfodata);
-      ThrowException(&image->exception,CorruptImageError,UnexpectedEndOfFile,
-                     NULL);
-      return MagickFail;
+      ThrowBinaryException(CorruptImageError,UnexpectedEndOfFile,image->filename);
     }
 
   q=SetImagePixels(tile_image,0,0,tile_image->columns,tile_image->rows);
@@ -398,7 +396,7 @@ static MagickPassFail load_tile (Image* image, Image* tile_image, XCFDocInfo* in
               q->green    = ScaleCharToQuantum(xcfdata->green);
               q->blue     = ScaleCharToQuantum(xcfdata->blue);
               q->opacity  = (Quantum) (xcfdata->opacity==0U ? TransparentOpacity :
-                                       ScaleCharToQuantum(255U-inLayerInfo->opacity)); 
+                                       ScaleCharToQuantum(255U-inLayerInfo->opacity));
               xcfdata++;
               q++;
             }
@@ -411,7 +409,7 @@ static MagickPassFail load_tile (Image* image, Image* tile_image, XCFDocInfo* in
 
 static MagickPassFail load_tile_rle (Image* image,
                                      Image* tile_image,
-                                     XCFDocInfo* inDocInfo, 
+                                     XCFDocInfo* inDocInfo,
                                      XCFLayerInfo*  inLayerInfo,
                                      size_t data_length)
 {
@@ -458,13 +456,11 @@ static MagickPassFail load_tile_rle (Image* image,
                               (unsigned long) nmemb_read_successfully,
                               (unsigned long) data_length);
       MagickFreeMemory(xcfodata);
-      ThrowException(&image->exception,CorruptImageError,UnexpectedEndOfFile,
-                     NULL);
-      return MagickFail;
+      ThrowBinaryException(CorruptImageError,UnexpectedEndOfFile,image->filename);
     }
 
   xcfdatalimit = &xcfodata[nmemb_read_successfully - 1];
-  
+
   for (i = 0; i < bpp; i++)
     {
       q=SetImagePixels(tile_image,0,0,tile_image->columns,tile_image->rows);
@@ -482,9 +478,9 @@ static MagickPassFail load_tile_rle (Image* image,
             {
               goto bogus_rle;
             }
-    
+
           val = *xcfdata++;
-    
+
           length = val;
 
           if (length >= 128)
@@ -497,24 +493,24 @@ static MagickPassFail load_tile_rle (Image* image,
                     {
                       goto bogus_rle;
                     }
-    
+
                   length = ((*xcfdata << 8) + xcfdata[1]) & 0xFFFF;
                   xcfdata += 2;
                 }
-    
+
               count += length;
               size -= length;
-    
+
               if (size < 0)
                 {
                   goto bogus_rle;
                 }
-    
+
               if (&xcfdata[length-1] > xcfdatalimit)
                 {
                   goto bogus_rle;
                 }
-    
+
               while (length-- > 0)
                 {
                   data = *xcfdata++;
@@ -522,7 +518,7 @@ static MagickPassFail load_tile_rle (Image* image,
                     {
                     case 0:
                       {
-                        q->red          = ScaleCharToQuantum(data);  
+                        q->red          = ScaleCharToQuantum(data);
                         if ( inDocInfo->image_type == GIMP_GRAY )
                           {
                             q->green    = ScaleCharToQuantum(data);
@@ -550,7 +546,7 @@ static MagickPassFail load_tile_rle (Image* image,
                     case 3:
                       {
                         q->opacity = (Quantum) (data==0 ? TransparentOpacity :
-                                                ScaleCharToQuantum(255-inLayerInfo->opacity));  
+                                                ScaleCharToQuantum(255-inLayerInfo->opacity));
                         break;
                       }
                     }
@@ -566,26 +562,26 @@ static MagickPassFail load_tile_rle (Image* image,
                     {
                       goto bogus_rle;
                     }
-    
+
                   length = ((*xcfdata << 8) + xcfdata[1]) & 0xFFFF;
                   xcfdata += 2;
                 }
-    
+
               count += length;
               size -= length;
 
               if (size < 0)
                 {
-                 goto bogus_rle;
+                  goto bogus_rle;
                 }
-    
+
               if (xcfdata > xcfdatalimit)
                 {
                   goto bogus_rle;
                 }
-    
+
               val = *xcfdata++;
-    
+
               for (j = 0; j < length; j++)
                 {
                   data = val;
@@ -593,7 +589,7 @@ static MagickPassFail load_tile_rle (Image* image,
                     {
                     case 0:
                       {
-                        q->red = ScaleCharToQuantum(data);  
+                        q->red = ScaleCharToQuantum(data);
                         if ( inDocInfo->image_type == GIMP_GRAY )
                           {
                             q->green = ScaleCharToQuantum(data);
@@ -621,7 +617,7 @@ static MagickPassFail load_tile_rle (Image* image,
                     case 3:
                       {
                         q->opacity = (Quantum) (data==0 ? TransparentOpacity :
-                                                ScaleCharToQuantum(255-inLayerInfo->opacity));  
+                                                ScaleCharToQuantum(255-inLayerInfo->opacity));
                         break;
                       }
                     }
@@ -630,7 +626,7 @@ static MagickPassFail load_tile_rle (Image* image,
             }
         }
       if (SyncImagePixelsEx(tile_image,&tile_image->exception) == MagickFail)
-       break;
+        break;
     }
   MagickFreeMemory(xcfodata);
   return MagickPass;
@@ -682,9 +678,9 @@ static MagickPassFail load_level (Image* image,
   MagickPassFail
     status = MagickPass;
 
-  ExceptionInfo 
+  ExceptionInfo
     *exception = inDocInfo->exception;
-  
+
   /* start reading the data */
   width = ReadBlobMSBLong(image); /* width */
   height = ReadBlobMSBLong(image); /* height */
@@ -694,6 +690,10 @@ static MagickPassFail load_level (Image* image,
    *  and we can simply return.
    */
   offset = ReadBlobMSBLong(image);
+
+  if (EOFBlob(image))
+    ThrowBinaryException(CorruptImageError,UnexpectedEndOfFile,image->filename);
+
   if (offset == 0)
     return MagickPass;
 
@@ -749,6 +749,8 @@ static MagickPassFail load_level (Image* image,
         amount of data needed for this tile
       */
       offset2 = ReadBlobMSBLong(image);
+      if (EOFBlob(image))
+        ThrowBinaryException(CorruptImageError,UnexpectedEndOfFile,image->filename);
       if (offset2 >= inDocInfo->file_size)
         {
           if (image->logging)
@@ -757,12 +759,22 @@ static MagickPassFail load_level (Image* image,
                                   (long) offset2, (unsigned long) inDocInfo->file_size);
           ThrowBinaryException(CorruptImageError,CorruptImage,image->filename);
         }
-      
+
+      /* verify that seek position is in file */
+      if ((magick_off_t) offset >= GetBlobSize(image))
+        {
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Tile offset %" MAGICK_OFF_F "d is outside file bounds",
+                                  (magick_off_t) offset);
+          ThrowBinaryException(CorruptImageError,InsufficientImageDataInFile,image->filename);
+        }
+
       /* seek to the tile offset */
       if (SeekBlob(image, offset, SEEK_SET) != offset)
         ThrowBinaryException(CorruptImageError,InsufficientImageDataInFile,image->filename);
 
-      /* allocate the image for the tile 
+      /* allocate the image for the tile
          NOTE: the last tile in a row or column may not be a full tile!
       */
       tile_image_width=(size_t) (destLeft == (int) ntile_cols-1 ?
@@ -774,6 +786,9 @@ static MagickPassFail load_level (Image* image,
       tile_image=CloneImage(inLayerInfo->image, tile_image_width,
                             tile_image_height,True,exception);
 
+      if (tile_image == (Image *) NULL)
+        return MagickFail;
+
       /*
         Compute the tile data size.
       */
@@ -825,7 +840,10 @@ static MagickPassFail load_level (Image* image,
                                       "Final tile data size: %lu",
                                       (unsigned long) tile_data_size);
               if (offset2 <= offset)
-                ThrowBinaryException(CorruptImageError,UnexpectedEndOfFile,image->filename);
+                {
+                  DestroyImage(tile_image);
+                  ThrowBinaryException(CorruptImageError,UnexpectedEndOfFile,image->filename);
+                }
             }
         }
 
@@ -841,9 +859,11 @@ static MagickPassFail load_level (Image* image,
                                tile_data_size);
           break;
         case COMPRESS_ZLIB:
+          DestroyImage(tile_image);
           ThrowBinaryException(CoderError,ZipCompressionNotSupported,
                                image->filename);
         case COMPRESS_FRACTAL:
+          DestroyImage(tile_image);
           ThrowBinaryException(CoderError,FractalCompressionNotSupported,
                                image->filename);
         }
@@ -916,9 +936,9 @@ static MagickPassFail load_level (Image* image,
           destTop++;
         }
 
-      if (MagickPass != status) 
+      if (MagickPass != status)
         return status;
-      
+
       /* restore the saved position so we'll be ready to
        *  read the next offset.
        */
@@ -926,11 +946,13 @@ static MagickPassFail load_level (Image* image,
 
       /* read in the offset of the next tile */
       offset = ReadBlobMSBLong(image);
+      if (EOFBlob(image))
+        ThrowBinaryException(CorruptImageError,UnexpectedEndOfFile,image->filename);
       if (offset != 0)
         if (!MagickMonitorFormatted(offset,inDocInfo->file_size,
                                     &image->exception,LoadImageText,
                                     image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
     }
 
@@ -943,7 +965,7 @@ static MagickPassFail load_level (Image* image,
       (void) MagickMonitorFormatted(inDocInfo->file_size,
                                     inDocInfo->file_size+1,&image->exception,
                                     LoadImageText,image->filename,
-                                   image->columns,image->rows);
+                                    image->columns,image->rows);
     }
 
   return MagickPass;
@@ -973,22 +995,36 @@ static MagickPassFail load_hierarchy (Image *image, XCFDocInfo* inDocInfo, XCFLa
    */
   offset = ReadBlobMSBLong(image);  /* top level */
 
+  if (EOFBlob(image))
+    ThrowBinaryException(CorruptImageError,UnexpectedEndOfFile,image->filename);
+
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                          "load_hierarchy: dimensions %lux%lu, bpp=%lu, offset=%lu",
+                          "load_hierarchy: dimensions %lux%lu, bpp=%lu,"
+                          " offset=%" MAGICK_OFF_F "d",
                           width,height,(unsigned long) inDocInfo->bpp,
-                          (unsigned long) offset);
+                          (magick_off_t) offset);
+
+  /* verify that seek position is in file */
+  if ((magick_off_t) offset >= GetBlobSize(image))
+    {
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Heirarchy offset %" MAGICK_OFF_F "d is outside file bounds",
+                              (magick_off_t) offset);
+      ThrowBinaryException(CorruptImageError,InsufficientImageDataInFile,image->filename);
+    }
 
   /* discard offsets for layers below first, if any.
    */
-  do 
+  do
     {
       junk = ReadBlobMSBLong(image);
     }
   while ((junk != 0) && (!EOFBlob(image)));
 
   if (EOFBlob(image))
-    return MagickFail;
+    ThrowBinaryException(CorruptImageError,UnexpectedEndOfFile,image->filename);
 
   /* save the current position as it is where the
    *  next level offset is stored.
@@ -996,15 +1032,25 @@ static MagickPassFail load_hierarchy (Image *image, XCFDocInfo* inDocInfo, XCFLa
   saved_pos = TellBlob(image);
   if (saved_pos < 0)
     ThrowBinaryException(BlobError,UnableToObtainOffset,image->filename);
-  
+
+  /* verify that seek position is in file */
+  if ((magick_off_t) offset >= GetBlobSize(image))
+    {
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Level offset %" MAGICK_OFF_F "d is outside file bounds",
+                              (magick_off_t) offset);
+      ThrowBinaryException(CorruptImageError,InsufficientImageDataInFile,image->filename);
+    }
+
   /* seek to the level offset */
   if (SeekBlob(image, offset, SEEK_SET) != offset)
     ThrowBinaryException(CorruptImageError,InsufficientImageDataInFile,image->filename);
-  
+
   /* read in the level */
   if (load_level (image, inDocInfo, inLayer) == MagickFail)
     return MagickFail;
-      
+
   /* restore the saved position so we'll be ready to
    *  read the next offset.
    */
@@ -1025,12 +1071,16 @@ static MagickPassFail ReadOneLayer( Image* image, XCFDocInfo* inDocInfo, XCFLaye
     foundPropEnd = 0;
 
   unsigned long
-    hierarchy_offset, 
+    hierarchy_offset,
     layer_mask_offset;
 
+  magick_off_t start_offset;
+
+  start_offset = TellBlob(image);
+
   /* clear the block! */
   (void) memset( outLayer, 0, sizeof( XCFLayerInfo ) );
-  
+
   /* read in the layer width, height, type and name */
   outLayer->width = ReadBlobMSBLong(image);
   outLayer->height = ReadBlobMSBLong(image);
@@ -1038,6 +1088,9 @@ static MagickPassFail ReadOneLayer( Image* image, XCFDocInfo* inDocInfo, XCFLaye
   (void) ReadBlobStringWithLongSize(image, outLayer->name,
                                     sizeof(outLayer->name));
 
+  if (EOFBlob(image))
+    ThrowBinaryException(CorruptImageError,UnexpectedEndOfFile,image->filename);
+
   if (image->logging)
     (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                           "Loading layer \"%s\", dimensions %lux%lu, type %lu",
@@ -1046,8 +1099,8 @@ static MagickPassFail ReadOneLayer( Image* image, XCFDocInfo* inDocInfo, XCFLaye
                           (unsigned long) outLayer->height,
                           (unsigned long) outLayer->type);
 
-  if (EOFBlob(image))
-    ThrowBinaryException(CorruptImageError,InsufficientImageDataInFile,image->filename);
+  if ((outLayer->width == 0) || (outLayer->height == 0))
+    ThrowBinaryException(CorruptImageError,ImproperImageHeader,image->filename);
 
   /* allocate the image for this layer */
   outLayer->image=CloneImage(image,outLayer->width, outLayer->height,True,
@@ -1055,9 +1108,6 @@ static MagickPassFail ReadOneLayer( Image* image, XCFDocInfo* inDocInfo, XCFLaye
   if (outLayer->image == (Image *) NULL)
     return MagickFail;
 
-  if (CheckImagePixelLimits(outLayer->image, &image->exception) != MagickPass)
-    ThrowBinaryException(ResourceLimitError,ImagePixelLimitExceeded,image->filename);
-
   /* read the layer properties! */
   foundPropEnd = 0;
   while ( !foundPropEnd && !EOFBlob(image) )
@@ -1148,6 +1198,8 @@ static MagickPassFail ReadOneLayer( Image* image, XCFDocInfo* inDocInfo, XCFLaye
           break;
         }
     }
+  if (EOFBlob(image))
+    ThrowBinaryException(CorruptImageError,UnexpectedEndOfFile,image->filename);
 
   if (!foundPropEnd)
     return MagickFail;
@@ -1161,22 +1213,69 @@ static MagickPassFail ReadOneLayer( Image* image, XCFDocInfo* inDocInfo, XCFLaye
   if ( outLayer->visible == False )
     {
       /* BOGUS: should really be separate member var! */
-      outLayer->image->compose = NoCompositeOp;  
+      outLayer->image->compose = NoCompositeOp;
     }
 
   /* read the hierarchy and layer mask offsets */
   hierarchy_offset = ReadBlobMSBLong(image);
   layer_mask_offset = ReadBlobMSBLong(image);
 
+  /* verify that seek position is in file */
+  if ((magick_off_t) hierarchy_offset >= GetBlobSize(image))
+    {
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Hierarchy offset %" MAGICK_OFF_F "d is outside file bounds",
+                              (magick_off_t) hierarchy_offset);
+      ThrowBinaryException(CorruptImageError,InsufficientImageDataInFile,image->filename);
+    }
+  /*
+    Verify that seek position is not too small.
+    Seek position provides ample opportunity for abuse.
+  */
+  if ((magick_off_t) hierarchy_offset <= start_offset)
+    {
+      if (image->logging)
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Hierarchy offset %" MAGICK_OFF_F "d is unreasonable",
+                              (magick_off_t) hierarchy_offset);
+      ThrowBinaryException(CorruptImageError,ImproperImageHeader,image->filename);
+    }
+
   /* read in the hierarchy */
   if (SeekBlob(image, hierarchy_offset, SEEK_SET) != (magick_off_t) hierarchy_offset)
     ThrowBinaryException(CorruptImageError,InsufficientImageDataInFile,image->filename);
+  if (image->logging)
+    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                          "Hierarchy offset %" MAGICK_OFF_F "d",
+                          (magick_off_t) hierarchy_offset);
   if (load_hierarchy (image, inDocInfo, outLayer) == MagickFail)
     return MagickFail;
 
   /* read in the layer mask */
   if (layer_mask_offset != 0)
     {
+      /* verify that seek position is in file */
+      if ((magick_off_t) layer_mask_offset >= GetBlobSize(image))
+        {
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Layer mask offset %" MAGICK_OFF_F "d is outside file bounds",
+                                  (magick_off_t) layer_mask_offset);
+          ThrowBinaryException(CorruptImageError,InsufficientImageDataInFile,image->filename);
+        }
+      /*
+        Verify that seek position is not too small.
+        Seek position provides ample opportunity for abuse.
+      */
+      if ((magick_off_t) layer_mask_offset <= start_offset)
+        {
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Layer mask offset %" MAGICK_OFF_F "d is unreasonable",
+                                  (magick_off_t) hierarchy_offset);
+          ThrowBinaryException(CorruptImageError,ImproperImageHeader,image->filename);
+        }
       if (SeekBlob(image, layer_mask_offset, SEEK_SET) != (magick_off_t) layer_mask_offset)
         ThrowBinaryException(CorruptImageError,InsufficientImageDataInFile,image->filename);
 
@@ -1296,7 +1395,7 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
   if (status == MagickFail)
     ThrowReaderException(FileOpenError,UnableToOpenFile,image);
   count=ReadBlob(image,14,(char *) magick);
-  if ((count == 0) ||
+  if ((count != 14) ||
       (LocaleNCompare((char *) magick,"gimp xcf",8) != 0))
     ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
   /* clear the docinfo stuff */
@@ -1324,7 +1423,7 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
   if ((image->columns == 0) || (image->rows == 0))
     ThrowReaderException(CorruptImageError,NegativeOrZeroImageSize,image);
-  
+
   /* setup some things about the image...*/
   image->compression=NoCompression;
   image->depth = 8;
@@ -1344,11 +1443,23 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
     {
       ThrowReaderException(CorruptImageError,ImageTypeNotSupported,image);
     }
+
+  if (CheckImagePixelLimits(image, exception) != MagickPass)
+    ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+
   /*
-    SetImage can be very expensive and it is not clear that this one is
-    actually needed so comment it out for now.
+    SetImage can be very expensive but we do it here because it is
+    expected that the canvas is initialized to opaque-black and
+    operations may be done using uninitialized pixels if we don't
+    initialize here.
   */
-  /* (void) SetImage(image,OpaqueOpacity); */  /* until we know otherwise...*/
+  SetRedSample(&image->background_color,0);
+  SetGreenSample(&image->background_color,0);
+  SetBlueSample(&image->background_color,0);
+  SetOpacitySample(&image->background_color,OpaqueOpacity);
+  if (SetImage(image,OpaqueOpacity) != MagickPass)
+    ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image); /* ??? */
+
   image->matte=True;  /* XCF always has a matte! */
 
   /* read properties */
@@ -1369,31 +1480,31 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             if (ReadBlobByte(image) == EOF)
               ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
           /*
-            if (info->file_version == 0) 
+            if (info->file_version == 0)
             {
             gint i;
 
             g_message (_("XCF warning: version 0 of XCF file format\n"
             "did not save indexed colormaps correctly.\n"
             "Substituting grayscale map."));
-            info->cp += 
+            info->cp +=
             xcf_read_int32 (info->fp, (guint32*) &gimage->num_cols, 1);
             gimage->cmap = g_new (guchar, gimage->num_cols*3);
             xcf_seek_pos (info, info->cp + gimage->num_cols);
-            for (i = 0; i<gimage->num_cols; i++) 
+            for (i = 0; i<gimage->num_cols; i++)
             {
             gimage->cmap[i*3+0] = i;
             gimage->cmap[i*3+1] = i;
             gimage->cmap[i*3+2] = i;
             }
             }
-            else 
+            else
             {
-            info->cp += 
+            info->cp +=
             xcf_read_int32 (info->fp, (guint32*) &gimage->num_cols, 1);
             gimage->cmap = g_new (guchar, gimage->num_cols*3);
-            info->cp += 
-            xcf_read_int8 (info->fp, 
+            info->cp +=
+            xcf_read_int8 (info->fp,
             (guint8*) gimage->cmap, gimage->num_cols*3);
             }
           */
@@ -1441,7 +1552,7 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
               }
             */
 
-      
+
             /* BOGUS: we don't write these yet because we aren't
                reading them properly yet :( */
             /* image->x_resolution = xres; */
@@ -1551,7 +1662,7 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
         *layer_info;
 
       unsigned long
-       number_layers = 0,
+        number_layers = 0,
         num_layers = 0;
 
       long
@@ -1563,24 +1674,63 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
       MagickBool
         foundAllLayers = MagickFalse;
 
+      magick_off_t
+        oldPos;
+
+      magick_uint32_t
+        previous_offset;
+
+      if (CheckImagePixelLimits(image, exception) != MagickPass)
+        ThrowReaderException(ResourceLimitError,ImagePixelLimitExceeded,image);
+
       /* BIG HACK
          because XCF doesn't include the layer count, and we
          want to know it in advance in order to allocate memory,
          we have to scan the layer offset list, and then reposition
          the read pointer
       */
-      magick_off_t oldPos = TellBlob(image);
+      oldPos = TellBlob(image);
       if (oldPos < 0)
         ThrowReaderException(BlobError,UnableToObtainOffset,image);
+
+      previous_offset = 0;
       do
         {
-          long
-            offset = (long) ReadBlobMSBLong(image);
+          magick_uint32_t
+            offset = ReadBlobMSBLong(image);
+
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Layer Offset[%lu] = %" MAGICK_UINT32_F "u",
+                                  number_layers, offset);
+
+          if (offset >= doc_info.file_size)
+            {
+              if (image->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Layer Offset %" MAGICK_UINT32_F "u"
+                                      " is outside of file bounds",
+                                      offset);
+              ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+            }
+          /*
+            Are layer offsets assured to be ascending?
+          */
+          if ((offset != 0) && (offset <= previous_offset))
+            {
+              if (image->logging)
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                      "Layer Offset %" MAGICK_UINT32_F "u"
+                                      " is not ascending",
+                                      offset);
+              ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
+            }
 
           if ( offset == 0 )
             foundAllLayers = MagickTrue;
           else
             number_layers++;
+          previous_offset=offset;
         } while ( !foundAllLayers );
 
       if (SeekBlob(image, oldPos, SEEK_SET) != oldPos) /* restore the position! */
@@ -1595,8 +1745,8 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
       if (image->logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "XCF number_layers=%lu first_layer=%ld last_layer=%ld",
-                             number_layers, first_layer, last_layer);
+                              "XCF number_layers=%lu first_layer=%ld last_layer=%ld",
+                              number_layers, first_layer, last_layer);
 
       /* XCF has layers backwards, so this gets a bit complicated */
       T = last_layer;
@@ -1606,8 +1756,8 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
 
       if (image->logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "XCF reading layers %ld to %ld inclusive", first_layer,
-                             last_layer);
+                              "XCF reading layers %ld to %ld inclusive", first_layer,
+                              last_layer);
 
       /* allocate our array of layer info blocks */
       layer_info=MagickAllocateArray(XCFLayerInfo *,
@@ -1646,24 +1796,35 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
             }
 
           if ( first_layer <= current_layer && current_layer <= last_layer )
-           {
-             /* seek to the layer offset */
-             if (SeekBlob(image, offset, SEEK_SET) != offset)
+            {
+              /* verify that seek position is in file */
+              if ((magick_off_t) offset >= GetBlobSize(image))
+                {
+                  if (image->logging)
+                    (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                          "Layer offset %" MAGICK_OFF_F "d is outside file bounds",
+                                          (magick_off_t) offset);
+                  DestroyLayerInfo(number_layers,layer_info);
+                  ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,image);
+                }
+
+              /* seek to the layer offset */
+              if (SeekBlob(image, offset, SEEK_SET) != offset)
                 {
                   /* FIXME: CID 64064: leaks layer_info */
                   DestroyLayerInfo(number_layers,layer_info);
                   ThrowReaderException(CorruptImageError,InsufficientImageDataInFile,image);
                 }
 
-             /* read in the layer */
-             layer_ok = ReadOneLayer( image, &doc_info, &layer_info[current_layer-first_layer] );
-             if (!layer_ok)
-               {
+              /* read in the layer */
+              layer_ok = ReadOneLayer( image, &doc_info, &layer_info[current_layer-first_layer] );
+              if (!layer_ok)
+                {
 #if 0
-                 int
-                   j;
+                  int
+                    j;
 
-                 for (j=0; j <= (current_layer-first_layer); j++)
+                  for (j=0; j <= (current_layer-first_layer); j++)
                     {
                       if (layer_info[j].image)
                         {
@@ -1671,86 +1832,111 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
                           layer_info[j].image = (Image *) NULL;
                         }
                     }
-                 MagickFreeMemory(layer_info);
+                  MagickFreeMemory(layer_info);
 #endif
                   DestroyLayerInfo(number_layers,layer_info);
-                 CopyException(exception,&image->exception);
-                 CloseBlob(image);
-                 DestroyImageList(image);
-                 return (Image *) NULL;
-               }
-             /* restore the saved position so we'll be ready to
-              *  read the next offset.
-              */
-             if (SeekBlob(image, saved_pos, SEEK_SET) != saved_pos)
+                  CopyException(exception,&image->exception);
+                  CloseBlob(image);
+                  DestroyImageList(image);
+                  return (Image *) NULL;
+                }
+              /* restore the saved position so we'll be ready to
+               *  read the next offset.
+               */
+              if (SeekBlob(image, saved_pos, SEEK_SET) != saved_pos)
                 {
                   /* FIXME: CID 64064: leaks layer_info */
                   DestroyLayerInfo(number_layers,layer_info);
                   ThrowReaderException(BlobError,UnableToSeekToOffset,image);
                 }
-           }
+            }
 
           current_layer++;
         }
 
       if ( number_layers == 1 )
-       {
-         /* composite the layer data onto the main image & then dispose the layer */
-         (void) CompositeImage(image, OverCompositeOp, layer_info[0].image,
-                               layer_info[0].offset_x, layer_info[0].offset_y );
-         DestroyImage( layer_info[0].image );
+        {
+          /* composite the layer data onto the main image & then dispose the layer */
+          if (image->logging)
+            (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                  "Composite Layer[0]: %lux%lu%+d%+d",
+                                    layer_info[0].image->columns,
+                                    layer_info[0].image->rows,
+                                    layer_info[0].offset_x,
+                                    layer_info[0].offset_y);
+          (void) CompositeImage(image, OverCompositeOp, layer_info[0].image,
+                                layer_info[0].offset_x, layer_info[0].offset_y );
+          DestroyImage( layer_info[0].image );
           layer_info[0].image = (Image *) NULL;
-       }
+        }
       else
-       {
+        {
 #if 0
-         {
-           /* NOTE: XCF layers are REVERSED from composite order! */
-           long
-             j;
-
-           for (j=number_layers-1; j>=0; j--) {
-             /* BOGUS: need to consider layer blending modes!! */
-             if ( layer_info[j].visible ) { /* only visible ones, please! */
-               CompositeImage(image, OverCompositeOp, layer_info[j].image,
-                              layer_info[j].offset_x, layer_info[j].offset_y );
-               DestroyImage( layer_info[j].image );
-                layer_info[j].image = (Image *) NULL;
-             }
-           }
-         }
+          {
+            /* NOTE: XCF layers are REVERSED from composite order! */
+            long
+              j;
+
+            for (j=number_layers-1; j>=0; j--)
+              {
+                /* BOGUS: need to consider layer blending modes!! */
+                if ( layer_info[j].visible )  /* only visible ones, please! */
+                  {
+                    if (image->logging)
+                      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                            "Composite Layer[%lu]: %lux%lu%+d%+d",
+                                            j,
+                                            layer_info[j].image->columns,
+                                            layer_info[j].image->rows,
+                                            layer_info[j].offset_x,
+                                            layer_info[j].offset_y);
+                    CompositeImage(image, OverCompositeOp, layer_info[j].image,
+                                   layer_info[j].offset_x, layer_info[j].offset_y );
+                    DestroyImage( layer_info[j].image );
+                    layer_info[j].image = (Image *) NULL;
+                  }
+              }
+          }
 #else
-         {
-           /* NOTE: XCF layers are REVERSED from composite order! */
-           long
-             j;
-
-           /* first we copy the last layer on top of the main image */
-           (void) CompositeImage(image, CopyCompositeOp, layer_info[number_layers-1].image,
-                                 layer_info[number_layers-1].offset_x,
-                                 layer_info[number_layers-1].offset_y );
-           DestroyImage( layer_info[number_layers-1].image );
+          {
+            /* NOTE: XCF layers are REVERSED from composite order! */
+            long
+              j;
+
+            /* first we copy the last layer on top of the main image */
+            if (image->logging)
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "Composite Layer[%lu]: %lux%lu%+d%+d",
+                                    number_layers-1,
+                                    layer_info[number_layers-1].image->columns,
+                                    layer_info[number_layers-1].image->rows,
+                                    layer_info[number_layers-1].offset_x,
+                                    layer_info[number_layers-1].offset_y);
+            (void) CompositeImage(image, CopyCompositeOp, layer_info[number_layers-1].image,
+                                  layer_info[number_layers-1].offset_x,
+                                  layer_info[number_layers-1].offset_y );
+            DestroyImage( layer_info[number_layers-1].image );
             layer_info[number_layers-1].image = (Image *) NULL;
 
-           /* now reverse the order of the layers as they are put
-              into subimages
-           */
-           image->next=layer_info[number_layers-2].image;
-           layer_info[number_layers-2].image->previous=image;
-           for (j=(long) number_layers-2; j >= 0; j--)
-             {
-               if (j > 0)
-                 layer_info[j].image->next=layer_info[j-1].image;
-               if (j < ((long) number_layers-1))
-                 layer_info[j].image->previous=layer_info[j+1].image;
-               layer_info[j].image->page.x = layer_info[j].offset_x;
-               layer_info[j].image->page.y = layer_info[j].offset_y;
-               layer_info[j].image->page.width = layer_info[j].width;
-               layer_info[j].image->page.height = layer_info[j].height;
-             }
-         }
+            /* now reverse the order of the layers as they are put
+               into subimages
+            */
+            image->next=layer_info[number_layers-2].image;
+            layer_info[number_layers-2].image->previous=image;
+            for (j=(long) number_layers-2; j >= 0; j--)
+              {
+                if (j > 0)
+                  layer_info[j].image->next=layer_info[j-1].image;
+                if (j < ((long) number_layers-1))
+                  layer_info[j].image->previous=layer_info[j+1].image;
+                layer_info[j].image->page.x = layer_info[j].offset_x;
+                layer_info[j].image->page.y = layer_info[j].offset_y;
+                layer_info[j].image->page.width = layer_info[j].width;
+                layer_info[j].image->page.height = layer_info[j].height;
+              }
+          }
 #endif
-       }
+        }
 
       MagickFreeMemory(layer_info);
 
index 418daa1..b2c6b46 100644 (file)
@@ -127,6 +127,60 @@ static unsigned int IsXPM(const unsigned char *magick,const size_t length)
 %
 */
 
+static char **StringToListMod(char *text)
+{
+  char
+    **textlist;
+
+  register char
+    *p;
+
+  register size_t
+    i;
+
+  size_t
+    lines;
+
+  if (text == (char *) NULL)
+    return((char **) NULL);
+
+  /*
+    Convert string to an ASCII list, modifying the input string.
+  */
+  lines=1;
+  for (p=text; *p != '\0'; p++)
+    if (*p == '\n')
+      lines++;
+  textlist=MagickAllocateMemory(char **,(lines+1)*sizeof(char *));
+  if (textlist == (char **) NULL)
+    MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
+                      UnableToConvertText);
+  i=0;
+  textlist[i]=text;
+  for (p=text; *p != '\0'; p++)
+    {
+      if (*p == '\r')
+        {
+          *p='\0';
+          continue;
+        }
+      if (*p == '\n')
+        {
+          *p='\0';
+          if (*(p+1) != '\0')
+            {
+              i++;
+              textlist[i]=p+1;
+            }
+        }
+    }
+  i++;
+  textlist[i]=(char *) NULL;
+  return(textlist);
+}
+
+static char *ParseColor(char *data) MAGICK_FUNC_PURE;
+
 static char *ParseColor(char *data)
 {
 #define NumberTargets  6
@@ -172,9 +226,6 @@ do { \
     for (i=0; i < (long) image->colors; i++) \
       MagickFreeMemory(keys[i]); \
   MagickFreeMemory(keys); \
-  if (textlist) \
-    for (i=0; textlist[i] != (char *) NULL; i++) \
-      MagickFreeMemory(textlist[i]); \
   MagickFreeMemory(textlist); \
   MagickFreeMemory(xpm_buffer); \
   ThrowReaderException(code_,reason_,image_); \
@@ -315,21 +366,37 @@ static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception)
         ThrowXPMReaderException(CorruptImageError,CorruptImage,image);
       }
   }
-  textlist=StringToList(xpm_buffer);
-  MagickFreeMemory(xpm_buffer);
+  /*
+    Scan for non-white space binary control codes and reject file if
+    they are present.
+  */
+  for (p=xpm_buffer; *p != '\0'; p++)
+    if (((unsigned char) *p < 32) && !isspace((int)(unsigned char) (*p)))
+      break;
+  if (*p != '\0')
+    {
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Binary control codes error");
+        ThrowXPMReaderException(CorruptImageError,CorruptImage,image);
+    }
+  textlist=StringToListMod(xpm_buffer);
   if (textlist == (char **) NULL)
     ThrowXPMReaderException(ResourceLimitError,MemoryAllocationFailed,image);
 #if 0
   if (image->logging)
     {
+      for (i=0; textlist[i] != (char *) NULL; i++)
+        { };
+      (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                            "TextList has %lu entries", i);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                             "TextList");
       for (i=0; textlist[i] != (char *) NULL; i++)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                              "    %lu: %s", i, textlist[i]);
+                              "    %lu: \"%s\"", i, textlist[i]);
     }
 #endif
-  
+
   /*
     Initialize image structure.
   */
@@ -455,9 +522,8 @@ static Image *ReadXPMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   for (i=0; i < (long) image->colors; i++)
     MagickFreeMemory(keys[i]);
   MagickFreeMemory(keys);
-  for (i=0; textlist[i] != (char *) NULL; i++)
-    MagickFreeMemory(textlist[i]);
   MagickFreeMemory(textlist);
+  MagickFreeMemory(xpm_buffer);
   CloseBlob(image);
   return(image);
 }
@@ -829,7 +895,7 @@ static unsigned int WritePICONImage(const ImageInfo *image_info,Image *image)
     if (QuantumTick(y,picon->rows))
       if (!MagickMonitorFormatted(y,picon->rows,&image->exception,
                                   SaveImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   DestroyImage(picon);
@@ -1059,7 +1125,7 @@ static unsigned int WriteXPMImage(const ImageInfo *image_info,Image *image)
     if (QuantumTick(y,image->rows))
       if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                   SaveImageText,image->filename,
-                                 image->columns,image->rows))
+                                  image->columns,image->rows))
         break;
   }
   (void) WriteBlobString(image,"};\n");
index 5490efa..b24e2a0 100644 (file)
@@ -889,7 +889,7 @@ static unsigned int WriteXWDImage(const ImageInfo *image_info,Image *image)
       {
         for (x=(long) image->columns; x > 0; x--)
           {
-            
+
             *q++=ScaleQuantumToChar(p->red);
             *q++=ScaleQuantumToChar(p->green);
             *q++=ScaleQuantumToChar(p->blue);
@@ -903,7 +903,7 @@ static unsigned int WriteXWDImage(const ImageInfo *image_info,Image *image)
       if (QuantumTick(y,image->rows))
         if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                     SaveImageText,image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           break;
   }
   MagickFreeMemory(pixels);
index d0aa863..9c5ac55 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -84,6 +84,8 @@ static unsigned int
 #define ThrowYUVReaderException(code_,reason_,image_) \
 { \
   MagickFreeMemory(scanline);                 \
+  DestroyImage(chroma_image);                 \
+  DestroyImage(resize_image);                 \
   ThrowReaderException(code_,reason_,image_); \
 }
 
@@ -274,7 +276,7 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
       if (image->previous == (Image *) NULL)
         if (!MagickMonitorFormatted(y,image->rows,exception,LoadImageText,
                                     image->filename,
-                                   image->columns,image->rows))
+                                    image->columns,image->rows))
           {
             status=MagickFail;
             break;
@@ -355,6 +357,7 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
     resize_image=ResizeImage(chroma_image,image->columns,image->rows,
       TriangleFilter,1.0,exception);
     DestroyImage(chroma_image);
+    chroma_image=(Image *) NULL;
     if (resize_image == (Image *) NULL)
       ThrowYUVReaderException(ResourceLimitError,MemoryAllocationFailed,image);
     for (y=0; y < (long) image->rows; y++)
@@ -381,6 +384,7 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
         }
     }
     DestroyImage(resize_image);
+    resize_image=(Image *) NULL;
     if (status == MagickFail)
       break;
     image->colorspace=YCbCrColorspace;
@@ -412,6 +416,7 @@ static Image *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
         if (image->next == (Image *) NULL)
           {
             DestroyImageList(image);
+            MagickFreeMemory(scanline);
             return((Image *) NULL);
           }
         image=SyncNextImageInList(image);
@@ -550,10 +555,14 @@ static unsigned int WriteYUVImage(const ImageInfo *image_info,Image *image)
     height,
     width;
 
+  size_t
+    image_list_length;
+
   assert(image_info != (const ImageInfo *) NULL);
   assert(image_info->signature == MagickSignature);
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  image_list_length=GetImageListLength(image);
   interlace=image_info->interlace;
   horizontal_factor=2;
   vertical_factor=2;
@@ -648,7 +657,7 @@ static unsigned int WriteYUVImage(const ImageInfo *image_info,Image *image)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                           SaveImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
         DestroyImage(yuv_image);
@@ -673,7 +682,7 @@ static unsigned int WriteYUVImage(const ImageInfo *image_info,Image *image)
             if (QuantumTick(y,image->rows))
               if (!MagickMonitorFormatted(y,image->rows,&image->exception,
                                           SaveImageText,image->filename,
-                                         image->columns,image->rows))
+                                          image->columns,image->rows))
                 break;
         }
         DestroyImage(yuv_image);
@@ -732,7 +741,7 @@ static unsigned int WriteYUVImage(const ImageInfo *image_info,Image *image)
     if (image->next == (Image *) NULL)
       break;
     image=SyncNextImageInList(image);
-    status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene++,image_list_length,
                                   &image->exception,SaveImagesText,
                                   image->filename);
     if (status == False)
index 5d1dd21..eb3b108 100644 (file)
@@ -1,5 +1,5 @@
 # -*- shell-script -*-
-# Copyright (C) 2012 GraphicsMagick Group
+# Copyright (C) 2012-2017 GraphicsMagick Group
 # Definitions of optional features and configuration values for this build.
 # Intended for use by test scripts.
 MAGICK_FEATURES='@MAGICK_FEATURES@'
@@ -13,6 +13,7 @@ LD_LIBRARY_PATH="@abs_top_builddir@/magick/.libs:${LD_LIBRARY_PATH}"
 MAGICK_CODER_MODULE_PATH='@abs_top_builddir@/coders'
 MAGICK_CONFIGURE_PATH='@abs_top_builddir@/config:@abs_top_srcdir@/config'
 MAGICK_FILTER_MODULE_PATH='@abs_top_builddir@/filters'
+MAGICK_CODER_STABILITY='BROKEN'
 
 PATH="@abs_top_builddir@/utilities:${PATH}"
 set +a
index a85b723..99e5052 100755 (executable)
@@ -1,9 +1,9 @@
 #! /bin/sh
 # Wrapper for compilers which do not understand '-c -o'.
 
-scriptversion=2012-10-14.11; # UTC
+scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2018 Free Software Foundation, Inc.
 # Written by Tom Tromey <tromey@cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ scriptversion=2012-10-14.11; # UTC
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -255,7 +255,8 @@ EOF
     echo "compile $scriptversion"
     exit $?
     ;;
-  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
+  icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
     func_cl_wrapper "$@"      # Doesn't return...
     ;;
 esac
@@ -339,9 +340,9 @@ exit $ret
 # Local Variables:
 # mode: shell-script
 # sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:
index 6c32c86..256083a 100755 (executable)
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2014 Free Software Foundation, Inc.
+#   Copyright 1992-2018 Free Software Foundation, Inc.
 
-timestamp='2014-11-04'
+timestamp='2018-03-08'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@ timestamp='2014-11-04'
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -27,7 +27,7 @@ timestamp='2014-11-04'
 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
 #
 # You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 #
 # Please send patches to <config-patches@gnu.org>.
 
@@ -39,7 +39,7 @@ Usage: $0 [OPTION]
 
 Output the configuration name of the system \`$me' is run on.
 
-Operation modes:
+Options:
   -h, --help         print this help, then exit
   -t, --time-stamp   print date of last modification, then exit
   -v, --version      print version number, then exit
@@ -50,7 +50,7 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2014 Free Software Foundation, Inc.
+Copyright 1992-2018 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -107,9 +107,9 @@ trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
 dummy=$tmp/dummy ;
 tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
 case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,)    echo "int x;" > $dummy.c ;
+ ,,)    echo "int x;" > "$dummy.c" ;
        for c in cc gcc c89 c99 ; do
-         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+         if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
             CC_FOR_BUILD="$c"; break ;
          fi ;
        done ;
@@ -132,14 +132,14 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
 UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
-case "${UNAME_SYSTEM}" in
+case "$UNAME_SYSTEM" in
 Linux|GNU|GNU/*)
        # If the system lacks a compiler, then just pick glibc.
        # We could probably try harder.
        LIBC=gnu
 
-       eval $set_cc_for_build
-       cat <<-EOF > $dummy.c
+       eval "$set_cc_for_build"
+       cat <<-EOF > "$dummy.c"
        #include <features.h>
        #if defined(__UCLIBC__)
        LIBC=uclibc
@@ -149,13 +149,20 @@ Linux|GNU|GNU/*)
        LIBC=gnu
        #endif
        EOF
-       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
+       eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
+
+       # If ldd exists, use it to detect musl libc.
+       if command -v ldd >/dev/null && \
+               ldd --version 2>&1 | grep -q ^musl
+       then
+           LIBC=musl
+       fi
        ;;
 esac
 
 # Note: order is significant - the case branches are not exclusive.
 
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
     *:NetBSD:*:*)
        # NetBSD (nbsd) targets should (where applicable) match one or
        # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
@@ -168,21 +175,31 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        # Note: NetBSD doesn't particularly care about the vendor
        # portion of the name.  We always set it to "unknown".
        sysctl="sysctl -n hw.machine_arch"
-       UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
-           /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
-       case "${UNAME_MACHINE_ARCH}" in
+       UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
+           "/sbin/$sysctl" 2>/dev/null || \
+           "/usr/sbin/$sysctl" 2>/dev/null || \
+           echo unknown)`
+       case "$UNAME_MACHINE_ARCH" in
            armeb) machine=armeb-unknown ;;
            arm*) machine=arm-unknown ;;
            sh3el) machine=shl-unknown ;;
            sh3eb) machine=sh-unknown ;;
            sh5el) machine=sh5le-unknown ;;
-           *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+           earmv*)
+               arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
+               endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
+               machine="${arch}${endian}"-unknown
+               ;;
+           *) machine="$UNAME_MACHINE_ARCH"-unknown ;;
        esac
        # The Operating System including object format, if it has switched
-       # to ELF recently, or will in the future.
-       case "${UNAME_MACHINE_ARCH}" in
+       # to ELF recently (or will in the future) and ABI.
+       case "$UNAME_MACHINE_ARCH" in
+           earm*)
+               os=netbsdelf
+               ;;
            arm*|i386|m68k|ns32k|sh3*|sparc|vax)
-               eval $set_cc_for_build
+               eval "$set_cc_for_build"
                if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
                        | grep -q __ELF__
                then
@@ -197,44 +214,67 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
                os=netbsd
                ;;
        esac
+       # Determine ABI tags.
+       case "$UNAME_MACHINE_ARCH" in
+           earm*)
+               expr='s/^earmv[0-9]/-eabi/;s/eb$//'
+               abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
+               ;;
+       esac
        # The OS release
        # Debian GNU/NetBSD machines have a different userland, and
        # thus, need a distinct triplet. However, they do not need
        # kernel version information, so it can be replaced with a
        # suitable tag, in the style of linux-gnu.
-       case "${UNAME_VERSION}" in
+       case "$UNAME_VERSION" in
            Debian*)
                release='-gnu'
                ;;
            *)
-               release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+               release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
                ;;
        esac
        # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
        # contains redundant information, the shorter form:
        # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
-       echo "${machine}-${os}${release}"
+       echo "$machine-${os}${release}${abi}"
        exit ;;
     *:Bitrig:*:*)
        UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
-       echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
+       echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE"
        exit ;;
     *:OpenBSD:*:*)
        UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
-       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+       echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE"
+       exit ;;
+    *:LibertyBSD:*:*)
+       UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
+       echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE"
+       exit ;;
+    *:MidnightBSD:*:*)
+       echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE"
        exit ;;
     *:ekkoBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE"
        exit ;;
     *:SolidBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE"
        exit ;;
     macppc:MirBSD:*:*)
-       echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+       echo powerpc-unknown-mirbsd"$UNAME_RELEASE"
        exit ;;
     *:MirBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE"
        exit ;;
+    *:Sortix:*:*)
+       echo "$UNAME_MACHINE"-unknown-sortix
+       exit ;;
+    *:Redox:*:*)
+       echo "$UNAME_MACHINE"-unknown-redox
+       exit ;;
+    mips:OSF1:*.*)
+        echo mips-dec-osf1
+        exit ;;
     alpha:OSF1:*:*)
        case $UNAME_RELEASE in
        *4.0)
@@ -251,63 +291,54 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
        case "$ALPHA_CPU_TYPE" in
            "EV4 (21064)")
-               UNAME_MACHINE="alpha" ;;
+               UNAME_MACHINE=alpha ;;
            "EV4.5 (21064)")
-               UNAME_MACHINE="alpha" ;;
+               UNAME_MACHINE=alpha ;;
            "LCA4 (21066/21068)")
-               UNAME_MACHINE="alpha" ;;
+               UNAME_MACHINE=alpha ;;
            "EV5 (21164)")
-               UNAME_MACHINE="alphaev5" ;;
+               UNAME_MACHINE=alphaev5 ;;
            "EV5.6 (21164A)")
-               UNAME_MACHINE="alphaev56" ;;
+               UNAME_MACHINE=alphaev56 ;;
            "EV5.6 (21164PC)")
-               UNAME_MACHINE="alphapca56" ;;
+               UNAME_MACHINE=alphapca56 ;;
            "EV5.7 (21164PC)")
-               UNAME_MACHINE="alphapca57" ;;
+               UNAME_MACHINE=alphapca57 ;;
            "EV6 (21264)")
-               UNAME_MACHINE="alphaev6" ;;
+               UNAME_MACHINE=alphaev6 ;;
            "EV6.7 (21264A)")
-               UNAME_MACHINE="alphaev67" ;;
+               UNAME_MACHINE=alphaev67 ;;
            "EV6.8CB (21264C)")
-               UNAME_MACHINE="alphaev68" ;;
+               UNAME_MACHINE=alphaev68 ;;
            "EV6.8AL (21264B)")
-               UNAME_MACHINE="alphaev68" ;;
+               UNAME_MACHINE=alphaev68 ;;
            "EV6.8CX (21264D)")
-               UNAME_MACHINE="alphaev68" ;;
+               UNAME_MACHINE=alphaev68 ;;
            "EV6.9A (21264/EV69A)")
-               UNAME_MACHINE="alphaev69" ;;
+               UNAME_MACHINE=alphaev69 ;;
            "EV7 (21364)")
-               UNAME_MACHINE="alphaev7" ;;
+               UNAME_MACHINE=alphaev7 ;;
            "EV7.9 (21364A)")
-               UNAME_MACHINE="alphaev79" ;;
+               UNAME_MACHINE=alphaev79 ;;
        esac
        # A Pn.n version is a patched version.
        # A Vn.n version is a released version.
        # A Tn.n version is a released field test version.
        # A Xn.n version is an unreleased experimental baselevel.
        # 1.2 uses "1.2" for uname -r.
-       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`"
        # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
        exitcode=$?
        trap '' 0
        exit $exitcode ;;
-    Alpha\ *:Windows_NT*:*)
-       # How do we know it's Interix rather than the generic POSIX subsystem?
-       # Should we change UNAME_MACHINE based on the output of uname instead
-       # of the specific Alpha model?
-       echo alpha-pc-interix
-       exit ;;
-    21064:Windows_NT:50:3)
-       echo alpha-dec-winnt3.5
-       exit ;;
     Amiga*:UNIX_System_V:4.0:*)
        echo m68k-unknown-sysv4
        exit ;;
     *:[Aa]miga[Oo][Ss]:*:*)
-       echo ${UNAME_MACHINE}-unknown-amigaos
+       echo "$UNAME_MACHINE"-unknown-amigaos
        exit ;;
     *:[Mm]orph[Oo][Ss]:*:*)
-       echo ${UNAME_MACHINE}-unknown-morphos
+       echo "$UNAME_MACHINE"-unknown-morphos
        exit ;;
     *:OS/390:*:*)
        echo i370-ibm-openedition
@@ -319,7 +350,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        echo powerpc-ibm-os400
        exit ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
-       echo arm-acorn-riscix${UNAME_RELEASE}
+       echo arm-acorn-riscix"$UNAME_RELEASE"
        exit ;;
     arm*:riscos:*:*|arm*:RISCOS:*:*)
        echo arm-unknown-riscos
@@ -346,38 +377,38 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
            sparc) echo sparc-icl-nx7; exit ;;
        esac ;;
     s390x:SunOS:*:*)
-       echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
        exit ;;
     sun4H:SunOS:5.*:*)
-       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
        exit ;;
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
-       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
        exit ;;
     i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
-       echo i386-pc-auroraux${UNAME_RELEASE}
+       echo i386-pc-auroraux"$UNAME_RELEASE"
        exit ;;
     i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
-       eval $set_cc_for_build
-       SUN_ARCH="i386"
+       eval "$set_cc_for_build"
+       SUN_ARCH=i386
        # If there is a compiler, see if it is configured for 64-bit objects.
        # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
        # This test works for both compilers.
-       if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+       if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
            if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
-               (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+               (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
                grep IS_64BIT_ARCH >/dev/null
            then
-               SUN_ARCH="x86_64"
+               SUN_ARCH=x86_64
            fi
        fi
-       echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
        exit ;;
     sun4*:SunOS:6*:*)
        # According to config.sub, this is the proper way to canonicalize
        # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
        # it's likely to be more like Solaris than SunOS4.
-       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
        exit ;;
     sun4*:SunOS:*:*)
        case "`/usr/bin/arch -k`" in
@@ -386,25 +417,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
                ;;
        esac
        # Japanese Language versions have a version number like `4.1.3-JL'.
-       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`"
        exit ;;
     sun3*:SunOS:*:*)
-       echo m68k-sun-sunos${UNAME_RELEASE}
+       echo m68k-sun-sunos"$UNAME_RELEASE"
        exit ;;
     sun*:*:4.2BSD:*)
        UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
-       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+       test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
        case "`/bin/arch`" in
            sun3)
-               echo m68k-sun-sunos${UNAME_RELEASE}
+               echo m68k-sun-sunos"$UNAME_RELEASE"
                ;;
            sun4)
-               echo sparc-sun-sunos${UNAME_RELEASE}
+               echo sparc-sun-sunos"$UNAME_RELEASE"
                ;;
        esac
        exit ;;
     aushp:SunOS:*:*)
-       echo sparc-auspex-sunos${UNAME_RELEASE}
+       echo sparc-auspex-sunos"$UNAME_RELEASE"
        exit ;;
     # The situation for MiNT is a little confusing.  The machine name
     # can be virtually everything (everything which is not
@@ -415,44 +446,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     # MiNT.  But MiNT is downward compatible to TOS, so this should
     # be no problem.
     atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-       echo m68k-atari-mint${UNAME_RELEASE}
+       echo m68k-atari-mint"$UNAME_RELEASE"
        exit ;;
     atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
-       echo m68k-atari-mint${UNAME_RELEASE}
+       echo m68k-atari-mint"$UNAME_RELEASE"
        exit ;;
     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-       echo m68k-atari-mint${UNAME_RELEASE}
+       echo m68k-atari-mint"$UNAME_RELEASE"
        exit ;;
     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-       echo m68k-milan-mint${UNAME_RELEASE}
+       echo m68k-milan-mint"$UNAME_RELEASE"
        exit ;;
     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-       echo m68k-hades-mint${UNAME_RELEASE}
+       echo m68k-hades-mint"$UNAME_RELEASE"
        exit ;;
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-       echo m68k-unknown-mint${UNAME_RELEASE}
+       echo m68k-unknown-mint"$UNAME_RELEASE"
        exit ;;
     m68k:machten:*:*)
-       echo m68k-apple-machten${UNAME_RELEASE}
+       echo m68k-apple-machten"$UNAME_RELEASE"
        exit ;;
     powerpc:machten:*:*)
-       echo powerpc-apple-machten${UNAME_RELEASE}
+       echo powerpc-apple-machten"$UNAME_RELEASE"
        exit ;;
     RISC*:Mach:*:*)
        echo mips-dec-mach_bsd4.3
        exit ;;
     RISC*:ULTRIX:*:*)
-       echo mips-dec-ultrix${UNAME_RELEASE}
+       echo mips-dec-ultrix"$UNAME_RELEASE"
        exit ;;
     VAX*:ULTRIX*:*:*)
-       echo vax-dec-ultrix${UNAME_RELEASE}
+       echo vax-dec-ultrix"$UNAME_RELEASE"
        exit ;;
     2020:CLIX:*:* | 2430:CLIX:*:*)
-       echo clipper-intergraph-clix${UNAME_RELEASE}
+       echo clipper-intergraph-clix"$UNAME_RELEASE"
        exit ;;
     mips:*:*:UMIPS | mips:*:*:RISCos)
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
+       eval "$set_cc_for_build"
+       sed 's/^        //' << EOF > "$dummy.c"
 #ifdef __cplusplus
 #include <stdio.h>  /* for printf() prototype */
        int main (int argc, char *argv[]) {
@@ -461,23 +492,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 #endif
        #if defined (host_mips) && defined (MIPSEB)
        #if defined (SYSTYPE_SYSV)
-         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+         printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
        #endif
        #if defined (SYSTYPE_SVR4)
-         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+         printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
        #endif
        #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
-         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+         printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
        #endif
        #endif
          exit (-1);
        }
 EOF
-       $CC_FOR_BUILD -o $dummy $dummy.c &&
-         dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
-         SYSTEM_NAME=`$dummy $dummyarg` &&
+       $CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
+         dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+         SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
            { echo "$SYSTEM_NAME"; exit; }
-       echo mips-mips-riscos${UNAME_RELEASE}
+       echo mips-mips-riscos"$UNAME_RELEASE"
        exit ;;
     Motorola:PowerMAX_OS:*:*)
        echo powerpc-motorola-powermax
@@ -503,17 +534,17 @@ EOF
     AViiON:dgux:*:*)
        # DG/UX returns AViiON for all architectures
        UNAME_PROCESSOR=`/usr/bin/uname -p`
-       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+       if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ]
        then
-           if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
-              [ ${TARGET_BINARY_INTERFACE}x = x ]
+           if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \
+              [ "$TARGET_BINARY_INTERFACE"x = x ]
            then
-               echo m88k-dg-dgux${UNAME_RELEASE}
+               echo m88k-dg-dgux"$UNAME_RELEASE"
            else
-               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+               echo m88k-dg-dguxbcs"$UNAME_RELEASE"
            fi
        else
-           echo i586-dg-dgux${UNAME_RELEASE}
+           echo i586-dg-dgux"$UNAME_RELEASE"
        fi
        exit ;;
     M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
@@ -530,7 +561,7 @@ EOF
        echo m68k-tektronix-bsd
        exit ;;
     *:IRIX*:*:*)
-       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`"
        exit ;;
     ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
        echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
@@ -542,14 +573,14 @@ EOF
        if [ -x /usr/bin/oslevel ] ; then
                IBM_REV=`/usr/bin/oslevel`
        else
-               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+               IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
        fi
-       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+       echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV"
        exit ;;
     *:AIX:2:3)
        if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
-               eval $set_cc_for_build
-               sed 's/^                //' << EOF >$dummy.c
+               eval "$set_cc_for_build"
+               sed 's/^                //' << EOF > "$dummy.c"
                #include <sys/systemcfg.h>
 
                main()
@@ -560,7 +591,7 @@ EOF
                        exit(0);
                        }
 EOF
-               if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+               if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
                then
                        echo "$SYSTEM_NAME"
                else
@@ -574,7 +605,7 @@ EOF
        exit ;;
     *:AIX:*:[4567])
        IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
-       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+       if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
                IBM_ARCH=rs6000
        else
                IBM_ARCH=powerpc
@@ -583,18 +614,18 @@ EOF
                IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
                           awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
        else
-               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+               IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
        fi
-       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       echo "$IBM_ARCH"-ibm-aix"$IBM_REV"
        exit ;;
     *:AIX:*:*)
        echo rs6000-ibm-aix
        exit ;;
-    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+    ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
        echo romp-ibm-bsd4.4
        exit ;;
     ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
-       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+       echo romp-ibm-bsd"$UNAME_RELEASE"   # 4.3 with uname added to
        exit ;;                             # report: romp-ibm BSD 4.3
     *:BOSX:*:*)
        echo rs6000-bull-bosx
@@ -609,28 +640,28 @@ EOF
        echo m68k-hp-bsd4.4
        exit ;;
     9000/[34678]??:HP-UX:*:*)
-       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-       case "${UNAME_MACHINE}" in
-           9000/31? )            HP_ARCH=m68000 ;;
-           9000/[34]?? )         HP_ARCH=m68k ;;
+       HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
+       case "$UNAME_MACHINE" in
+           9000/31?)            HP_ARCH=m68000 ;;
+           9000/[34]??)         HP_ARCH=m68k ;;
            9000/[678][0-9][0-9])
                if [ -x /usr/bin/getconf ]; then
                    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
-                   case "${sc_cpu_version}" in
-                     523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-                     528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                   case "$sc_cpu_version" in
+                     523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
+                     528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
                      532)                      # CPU_PA_RISC2_0
-                       case "${sc_kernel_bits}" in
-                         32) HP_ARCH="hppa2.0n" ;;
-                         64) HP_ARCH="hppa2.0w" ;;
-                         '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                       case "$sc_kernel_bits" in
+                         32) HP_ARCH=hppa2.0n ;;
+                         64) HP_ARCH=hppa2.0w ;;
+                         '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
                        esac ;;
                    esac
                fi
-               if [ "${HP_ARCH}" = "" ]; then
-                   eval $set_cc_for_build
-                   sed 's/^            //' << EOF >$dummy.c
+               if [ "$HP_ARCH" = "" ]; then
+                   eval "$set_cc_for_build"
+                   sed 's/^            //' << EOF > "$dummy.c"
 
                #define _HPUX_SOURCE
                #include <stdlib.h>
@@ -663,13 +694,13 @@ EOF
                    exit (0);
                }
 EOF
-                   (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+                   (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
                    test -z "$HP_ARCH" && HP_ARCH=hppa
                fi ;;
        esac
-       if [ ${HP_ARCH} = "hppa2.0w" ]
+       if [ "$HP_ARCH" = hppa2.0w ]
        then
-           eval $set_cc_for_build
+           eval "$set_cc_for_build"
 
            # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
            # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
@@ -680,23 +711,23 @@ EOF
            # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
            # => hppa64-hp-hpux11.23
 
-           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+           if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
                grep -q __LP64__
            then
-               HP_ARCH="hppa2.0w"
+               HP_ARCH=hppa2.0w
            else
-               HP_ARCH="hppa64"
+               HP_ARCH=hppa64
            fi
        fi
-       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       echo "$HP_ARCH"-hp-hpux"$HPUX_REV"
        exit ;;
     ia64:HP-UX:*:*)
-       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-       echo ia64-hp-hpux${HPUX_REV}
+       HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
+       echo ia64-hp-hpux"$HPUX_REV"
        exit ;;
     3050*:HI-UX:*:*)
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
+       eval "$set_cc_for_build"
+       sed 's/^        //' << EOF > "$dummy.c"
        #include <unistd.h>
        int
        main ()
@@ -721,11 +752,11 @@ EOF
          exit (0);
        }
 EOF
-       $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+       $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
                { echo "$SYSTEM_NAME"; exit; }
        echo unknown-hitachi-hiuxwe2
        exit ;;
-    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
        echo hppa1.1-hp-bsd
        exit ;;
     9000/8??:4.3bsd:*:*)
@@ -734,7 +765,7 @@ EOF
     *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
        echo hppa1.0-hp-mpeix
        exit ;;
-    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
        echo hppa1.1-hp-osf
        exit ;;
     hp8??:OSF1:*:*)
@@ -742,9 +773,9 @@ EOF
        exit ;;
     i*86:OSF1:*:*)
        if [ -x /usr/sbin/sysversion ] ; then
-           echo ${UNAME_MACHINE}-unknown-osf1mk
+           echo "$UNAME_MACHINE"-unknown-osf1mk
        else
-           echo ${UNAME_MACHINE}-unknown-osf1
+           echo "$UNAME_MACHINE"-unknown-osf1
        fi
        exit ;;
     parisc*:Lites*:*:*)
@@ -769,127 +800,109 @@ EOF
        echo c4-convex-bsd
        exit ;;
     CRAY*Y-MP:*:*:*)
-       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
        exit ;;
     CRAY*[A-Z]90:*:*:*)
-       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+       echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
        | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
              -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
              -e 's/\.[^.]*$/.X/'
        exit ;;
     CRAY*TS:*:*:*)
-       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
        exit ;;
     CRAY*T3E:*:*:*)
-       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
        exit ;;
     CRAY*SV1:*:*:*)
-       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
        exit ;;
     *:UNICOS/mp:*:*)
-       echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
        exit ;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
-       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-       FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-       FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+       FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+       FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
+       FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
        exit ;;
     5000:UNIX_System_V:4.*:*)
-       FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-       FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+       FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
+       FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
        exit ;;
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
-       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE"
        exit ;;
     sparc*:BSD/OS:*:*)
-       echo sparc-unknown-bsdi${UNAME_RELEASE}
+       echo sparc-unknown-bsdi"$UNAME_RELEASE"
        exit ;;
     *:BSD/OS:*:*)
-       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE"
        exit ;;
     *:FreeBSD:*:*)
        UNAME_PROCESSOR=`/usr/bin/uname -p`
-       case ${UNAME_PROCESSOR} in
+       case "$UNAME_PROCESSOR" in
            amd64)
-               echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
-           *)
-               echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+               UNAME_PROCESSOR=x86_64 ;;
+           i386)
+               UNAME_PROCESSOR=i586 ;;
        esac
+       echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
        exit ;;
     i*:CYGWIN*:*)
-       echo ${UNAME_MACHINE}-pc-cygwin
+       echo "$UNAME_MACHINE"-pc-cygwin
        exit ;;
     *:MINGW64*:*)
-       echo ${UNAME_MACHINE}-pc-mingw64
+       echo "$UNAME_MACHINE"-pc-mingw64
        exit ;;
     *:MINGW*:*)
-       echo ${UNAME_MACHINE}-pc-mingw32
+       echo "$UNAME_MACHINE"-pc-mingw32
        exit ;;
     *:MSYS*:*)
-       echo ${UNAME_MACHINE}-pc-msys
-       exit ;;
-    i*:windows32*:*)
-       # uname -m includes "-pc" on this system.
-       echo ${UNAME_MACHINE}-mingw32
+       echo "$UNAME_MACHINE"-pc-msys
        exit ;;
     i*:PW*:*)
-       echo ${UNAME_MACHINE}-pc-pw32
+       echo "$UNAME_MACHINE"-pc-pw32
        exit ;;
     *:Interix*:*)
-       case ${UNAME_MACHINE} in
+       case "$UNAME_MACHINE" in
            x86)
-               echo i586-pc-interix${UNAME_RELEASE}
+               echo i586-pc-interix"$UNAME_RELEASE"
                exit ;;
            authenticamd | genuineintel | EM64T)
-               echo x86_64-unknown-interix${UNAME_RELEASE}
+               echo x86_64-unknown-interix"$UNAME_RELEASE"
                exit ;;
            IA64)
-               echo ia64-unknown-interix${UNAME_RELEASE}
+               echo ia64-unknown-interix"$UNAME_RELEASE"
                exit ;;
        esac ;;
-    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
-       echo i${UNAME_MACHINE}-pc-mks
-       exit ;;
-    8664:Windows_NT:*)
-       echo x86_64-pc-mks
-       exit ;;
-    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
-       # How do we know it's Interix rather than the generic POSIX subsystem?
-       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
-       # UNAME_MACHINE based on the output of uname instead of i386?
-       echo i586-pc-interix
-       exit ;;
     i*:UWIN*:*)
-       echo ${UNAME_MACHINE}-pc-uwin
+       echo "$UNAME_MACHINE"-pc-uwin
        exit ;;
     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
        echo x86_64-unknown-cygwin
        exit ;;
-    p*:CYGWIN*:*)
-       echo powerpcle-unknown-cygwin
-       exit ;;
     prep*:SunOS:5.*:*)
-       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
        exit ;;
     *:GNU:*:*)
        # the GNU system
-       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`"
        exit ;;
     *:GNU/*:*:*)
        # other systems with GNU libc and userland
-       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
+       echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC"
        exit ;;
     i*86:Minix:*:*)
-       echo ${UNAME_MACHINE}-pc-minix
+       echo "$UNAME_MACHINE"-pc-minix
        exit ;;
     aarch64:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     aarch64_be:Linux:*:*)
        UNAME_MACHINE=aarch64_be
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     alpha:Linux:*:*)
        case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
@@ -902,58 +915,64 @@ EOF
          EV68*) UNAME_MACHINE=alphaev68 ;;
        esac
        objdump --private-headers /bin/sh | grep -q ld.so.1
-       if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     arc:Linux:*:* | arceb:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     arm*:Linux:*:*)
-       eval $set_cc_for_build
+       eval "$set_cc_for_build"
        if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
            | grep -q __ARM_EABI__
        then
-           echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+           echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        else
            if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
                | grep -q __ARM_PCS_VFP
            then
-               echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
+               echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi
            else
-               echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
+               echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf
            fi
        fi
        exit ;;
     avr32*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     cris:Linux:*:*)
-       echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+       echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
        exit ;;
     crisv32:Linux:*:*)
-       echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+       echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
+       exit ;;
+    e2k:Linux:*:*)
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     frv:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     hexagon:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     i*86:Linux:*:*)
-       echo ${UNAME_MACHINE}-pc-linux-${LIBC}
+       echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
        exit ;;
     ia64:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+       exit ;;
+    k1om:Linux:*:*)
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     m32r*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     m68*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     mips:Linux:*:* | mips64:Linux:*:*)
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
+       eval "$set_cc_for_build"
+       sed 's/^        //' << EOF > "$dummy.c"
        #undef CPU
        #undef ${UNAME_MACHINE}
        #undef ${UNAME_MACHINE}el
@@ -967,64 +986,70 @@ EOF
        #endif
        #endif
 EOF
-       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
-       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
+       eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`"
+       test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; }
        ;;
+    mips64el:Linux:*:*)
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+       exit ;;
     openrisc*:Linux:*:*)
-       echo or1k-unknown-linux-${LIBC}
+       echo or1k-unknown-linux-"$LIBC"
        exit ;;
     or32:Linux:*:* | or1k*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     padre:Linux:*:*)
-       echo sparc-unknown-linux-${LIBC}
+       echo sparc-unknown-linux-"$LIBC"
        exit ;;
     parisc64:Linux:*:* | hppa64:Linux:*:*)
-       echo hppa64-unknown-linux-${LIBC}
+       echo hppa64-unknown-linux-"$LIBC"
        exit ;;
     parisc:Linux:*:* | hppa:Linux:*:*)
        # Look for CPU level
        case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
-         PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
-         PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
-         *)    echo hppa-unknown-linux-${LIBC} ;;
+         PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;;
+         PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;;
+         *)    echo hppa-unknown-linux-"$LIBC" ;;
        esac
        exit ;;
     ppc64:Linux:*:*)
-       echo powerpc64-unknown-linux-${LIBC}
+       echo powerpc64-unknown-linux-"$LIBC"
        exit ;;
     ppc:Linux:*:*)
-       echo powerpc-unknown-linux-${LIBC}
+       echo powerpc-unknown-linux-"$LIBC"
        exit ;;
     ppc64le:Linux:*:*)
-       echo powerpc64le-unknown-linux-${LIBC}
+       echo powerpc64le-unknown-linux-"$LIBC"
        exit ;;
     ppcle:Linux:*:*)
-       echo powerpcle-unknown-linux-${LIBC}
+       echo powerpcle-unknown-linux-"$LIBC"
+       exit ;;
+    riscv32:Linux:*:* | riscv64:Linux:*:*)
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
-       echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
+       echo "$UNAME_MACHINE"-ibm-linux-"$LIBC"
        exit ;;
     sh64*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     sh*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     sparc:Linux:*:* | sparc64:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     tile*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     vax:Linux:*:*)
-       echo ${UNAME_MACHINE}-dec-linux-${LIBC}
+       echo "$UNAME_MACHINE"-dec-linux-"$LIBC"
        exit ;;
     x86_64:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
        exit ;;
     xtensa*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     i*86:DYNIX/ptx:4*:*)
        # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -1038,34 +1063,34 @@ EOF
        # I am not positive that other SVR4 systems won't match this,
        # I just have to hope.  -- rms.
        # Use sysv4.2uw... so that sysv4* matches it.
-       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+       echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION"
        exit ;;
     i*86:OS/2:*:*)
        # If we were able to find `uname', then EMX Unix compatibility
        # is probably installed.
-       echo ${UNAME_MACHINE}-pc-os2-emx
+       echo "$UNAME_MACHINE"-pc-os2-emx
        exit ;;
     i*86:XTS-300:*:STOP)
-       echo ${UNAME_MACHINE}-unknown-stop
+       echo "$UNAME_MACHINE"-unknown-stop
        exit ;;
     i*86:atheos:*:*)
-       echo ${UNAME_MACHINE}-unknown-atheos
+       echo "$UNAME_MACHINE"-unknown-atheos
        exit ;;
     i*86:syllable:*:*)
-       echo ${UNAME_MACHINE}-pc-syllable
+       echo "$UNAME_MACHINE"-pc-syllable
        exit ;;
     i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
-       echo i386-unknown-lynxos${UNAME_RELEASE}
+       echo i386-unknown-lynxos"$UNAME_RELEASE"
        exit ;;
     i*86:*DOS:*:*)
-       echo ${UNAME_MACHINE}-pc-msdosdjgpp
+       echo "$UNAME_MACHINE"-pc-msdosdjgpp
        exit ;;
-    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
-       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+    i*86:*:4.*:*)
+       UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
        if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
-               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+               echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL"
        else
-               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+               echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL"
        fi
        exit ;;
     i*86:*:5:[678]*)
@@ -1075,12 +1100,12 @@ EOF
            *Pentium)        UNAME_MACHINE=i586 ;;
            *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
        esac
-       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+       echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}"
        exit ;;
     i*86:*:3.2:*)
        if test -f /usr/options/cb.name; then
                UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
-               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+               echo "$UNAME_MACHINE"-pc-isc"$UNAME_REL"
        elif /bin/uname -X 2>/dev/null >/dev/null ; then
                UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
                (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
@@ -1090,9 +1115,9 @@ EOF
                        && UNAME_MACHINE=i686
                (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
                        && UNAME_MACHINE=i686
-               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+               echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL"
        else
-               echo ${UNAME_MACHINE}-pc-sysv32
+               echo "$UNAME_MACHINE"-pc-sysv32
        fi
        exit ;;
     pc:*:*:*)
@@ -1100,7 +1125,7 @@ EOF
        # uname -m prints for DJGPP always 'pc', but it prints nothing about
        # the processor, so we play safe by assuming i586.
        # Note: whatever this is, it MUST be the same as what config.sub
-       # prints for the "djgpp" host, or else GDB configury will decide that
+       # prints for the "djgpp" host, or else GDB configure will decide that
        # this is a cross-build.
        echo i586-pc-msdosdjgpp
        exit ;;
@@ -1112,9 +1137,9 @@ EOF
        exit ;;
     i860:*:4.*:*) # i860-SVR4
        if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
-         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+         echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4
        else # Add other i860-SVR4 vendors below as they are discovered.
-         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+         echo i860-unknown-sysv"$UNAME_RELEASE"  # Unknown i860-SVR4
        fi
        exit ;;
     mini*:CTIX:SYS*5:*)
@@ -1134,9 +1159,9 @@ EOF
        test -r /etc/.relid \
        && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-         && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+         && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
        /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-         && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+         && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
          && { echo i486-ncr-sysv4; exit; } ;;
@@ -1145,28 +1170,28 @@ EOF
        test -r /etc/.relid \
            && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-           && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+           && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
        /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-           && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+           && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
        /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
-           && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+           && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
     m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
-       echo m68k-unknown-lynxos${UNAME_RELEASE}
+       echo m68k-unknown-lynxos"$UNAME_RELEASE"
        exit ;;
     mc68030:UNIX_System_V:4.*:*)
        echo m68k-atari-sysv4
        exit ;;
     TSUNAMI:LynxOS:2.*:*)
-       echo sparc-unknown-lynxos${UNAME_RELEASE}
+       echo sparc-unknown-lynxos"$UNAME_RELEASE"
        exit ;;
     rs6000:LynxOS:2.*:*)
-       echo rs6000-unknown-lynxos${UNAME_RELEASE}
+       echo rs6000-unknown-lynxos"$UNAME_RELEASE"
        exit ;;
     PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
-       echo powerpc-unknown-lynxos${UNAME_RELEASE}
+       echo powerpc-unknown-lynxos"$UNAME_RELEASE"
        exit ;;
     SM[BE]S:UNIX_SV:*:*)
-       echo mips-dde-sysv${UNAME_RELEASE}
+       echo mips-dde-sysv"$UNAME_RELEASE"
        exit ;;
     RM*:ReliantUNIX-*:*:*)
        echo mips-sni-sysv4
@@ -1177,7 +1202,7 @@ EOF
     *:SINIX-*:*:*)
        if uname -p 2>/dev/null >/dev/null ; then
                UNAME_MACHINE=`(uname -p) 2>/dev/null`
-               echo ${UNAME_MACHINE}-sni-sysv4
+               echo "$UNAME_MACHINE"-sni-sysv4
        else
                echo ns32k-sni-sysv
        fi
@@ -1197,23 +1222,23 @@ EOF
        exit ;;
     i*86:VOS:*:*)
        # From Paul.Green@stratus.com.
-       echo ${UNAME_MACHINE}-stratus-vos
+       echo "$UNAME_MACHINE"-stratus-vos
        exit ;;
     *:VOS:*:*)
        # From Paul.Green@stratus.com.
        echo hppa1.1-stratus-vos
        exit ;;
     mc68*:A/UX:*:*)
-       echo m68k-apple-aux${UNAME_RELEASE}
+       echo m68k-apple-aux"$UNAME_RELEASE"
        exit ;;
     news*:NEWS-OS:6*:*)
        echo mips-sony-newsos6
        exit ;;
     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
        if [ -d /usr/nec ]; then
-               echo mips-nec-sysv${UNAME_RELEASE}
+               echo mips-nec-sysv"$UNAME_RELEASE"
        else
-               echo mips-unknown-sysv${UNAME_RELEASE}
+               echo mips-unknown-sysv"$UNAME_RELEASE"
        fi
        exit ;;
     BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
@@ -1232,46 +1257,56 @@ EOF
        echo x86_64-unknown-haiku
        exit ;;
     SX-4:SUPER-UX:*:*)
-       echo sx4-nec-superux${UNAME_RELEASE}
+       echo sx4-nec-superux"$UNAME_RELEASE"
        exit ;;
     SX-5:SUPER-UX:*:*)
-       echo sx5-nec-superux${UNAME_RELEASE}
+       echo sx5-nec-superux"$UNAME_RELEASE"
        exit ;;
     SX-6:SUPER-UX:*:*)
-       echo sx6-nec-superux${UNAME_RELEASE}
+       echo sx6-nec-superux"$UNAME_RELEASE"
        exit ;;
     SX-7:SUPER-UX:*:*)
-       echo sx7-nec-superux${UNAME_RELEASE}
+       echo sx7-nec-superux"$UNAME_RELEASE"
        exit ;;
     SX-8:SUPER-UX:*:*)
-       echo sx8-nec-superux${UNAME_RELEASE}
+       echo sx8-nec-superux"$UNAME_RELEASE"
        exit ;;
     SX-8R:SUPER-UX:*:*)
-       echo sx8r-nec-superux${UNAME_RELEASE}
+       echo sx8r-nec-superux"$UNAME_RELEASE"
+       exit ;;
+    SX-ACE:SUPER-UX:*:*)
+       echo sxace-nec-superux"$UNAME_RELEASE"
        exit ;;
     Power*:Rhapsody:*:*)
-       echo powerpc-apple-rhapsody${UNAME_RELEASE}
+       echo powerpc-apple-rhapsody"$UNAME_RELEASE"
        exit ;;
     *:Rhapsody:*:*)
-       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
        exit ;;
     *:Darwin:*:*)
        UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
-       eval $set_cc_for_build
+       eval "$set_cc_for_build"
        if test "$UNAME_PROCESSOR" = unknown ; then
            UNAME_PROCESSOR=powerpc
        fi
-       if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
-           if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+       if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then
+           if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
                if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
-                   (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
-                   grep IS_64BIT_ARCH >/dev/null
+                      (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+                      grep IS_64BIT_ARCH >/dev/null
                then
                    case $UNAME_PROCESSOR in
                        i386) UNAME_PROCESSOR=x86_64 ;;
                        powerpc) UNAME_PROCESSOR=powerpc64 ;;
                    esac
                fi
+               # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
+               if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
+                      (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+                      grep IS_PPC >/dev/null
+               then
+                   UNAME_PROCESSOR=powerpc
+               fi
            fi
        elif test "$UNAME_PROCESSOR" = i386 ; then
            # Avoid executing cc on OS X 10.9, as it ships with a stub
@@ -1282,27 +1317,33 @@ EOF
            # that Apple uses in portable devices.
            UNAME_PROCESSOR=x86_64
        fi
-       echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+       echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE"
        exit ;;
     *:procnto*:*:* | *:QNX:[0123456789]*:*)
        UNAME_PROCESSOR=`uname -p`
-       if test "$UNAME_PROCESSOR" = "x86"; then
+       if test "$UNAME_PROCESSOR" = x86; then
                UNAME_PROCESSOR=i386
                UNAME_MACHINE=pc
        fi
-       echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+       echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE"
        exit ;;
     *:QNX:*:4*)
        echo i386-pc-qnx
        exit ;;
-    NEO-?:NONSTOP_KERNEL:*:*)
-       echo neo-tandem-nsk${UNAME_RELEASE}
+    NEO-*:NONSTOP_KERNEL:*:*)
+       echo neo-tandem-nsk"$UNAME_RELEASE"
        exit ;;
     NSE-*:NONSTOP_KERNEL:*:*)
-       echo nse-tandem-nsk${UNAME_RELEASE}
+       echo nse-tandem-nsk"$UNAME_RELEASE"
+       exit ;;
+    NSR-*:NONSTOP_KERNEL:*:*)
+       echo nsr-tandem-nsk"$UNAME_RELEASE"
        exit ;;
-    NSR-?:NONSTOP_KERNEL:*:*)
-       echo nsr-tandem-nsk${UNAME_RELEASE}
+    NSV-*:NONSTOP_KERNEL:*:*)
+       echo nsv-tandem-nsk"$UNAME_RELEASE"
+       exit ;;
+    NSX-*:NONSTOP_KERNEL:*:*)
+       echo nsx-tandem-nsk"$UNAME_RELEASE"
        exit ;;
     *:NonStop-UX:*:*)
        echo mips-compaq-nonstopux
@@ -1311,18 +1352,18 @@ EOF
        echo bs2000-siemens-sysv
        exit ;;
     DS/*:UNIX_System_V:*:*)
-       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE"
        exit ;;
     *:Plan9:*:*)
        # "uname -m" is not consistent, so use $cputype instead. 386
        # is converted to i386 for consistency with other x86
        # operating systems.
-       if test "$cputype" = "386"; then
+       if test "$cputype" = 386; then
            UNAME_MACHINE=i386
        else
            UNAME_MACHINE="$cputype"
        fi
-       echo ${UNAME_MACHINE}-unknown-plan9
+       echo "$UNAME_MACHINE"-unknown-plan9
        exit ;;
     *:TOPS-10:*:*)
        echo pdp10-unknown-tops10
@@ -1343,14 +1384,14 @@ EOF
        echo pdp10-unknown-its
        exit ;;
     SEI:*:*:SEIUX)
-       echo mips-sei-seiux${UNAME_RELEASE}
+       echo mips-sei-seiux"$UNAME_RELEASE"
        exit ;;
     *:DragonFly:*:*)
-       echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
        exit ;;
     *:*VMS:*:*)
        UNAME_MACHINE=`(uname -p) 2>/dev/null`
-       case "${UNAME_MACHINE}" in
+       case "$UNAME_MACHINE" in
            A*) echo alpha-dec-vms ; exit ;;
            I*) echo ia64-dec-vms ; exit ;;
            V*) echo vax-dec-vms ; exit ;;
@@ -1359,34 +1400,48 @@ EOF
        echo i386-pc-xenix
        exit ;;
     i*86:skyos:*:*)
-       echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+       echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`"
        exit ;;
     i*86:rdos:*:*)
-       echo ${UNAME_MACHINE}-pc-rdos
+       echo "$UNAME_MACHINE"-pc-rdos
        exit ;;
     i*86:AROS:*:*)
-       echo ${UNAME_MACHINE}-pc-aros
+       echo "$UNAME_MACHINE"-pc-aros
        exit ;;
     x86_64:VMkernel:*:*)
-       echo ${UNAME_MACHINE}-unknown-esx
+       echo "$UNAME_MACHINE"-unknown-esx
+       exit ;;
+    amd64:Isilon\ OneFS:*:*)
+       echo x86_64-unknown-onefs
        exit ;;
 esac
 
+echo "$0: unable to guess system type" >&2
+
+case "$UNAME_MACHINE:$UNAME_SYSTEM" in
+    mips:Linux | mips64:Linux)
+       # If we got here on MIPS GNU/Linux, output extra information.
+       cat >&2 <<EOF
+
+NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
+the system type. Please install a C compiler and try again.
+EOF
+       ;;
+esac
+
 cat >&2 <<EOF
-$0: unable to guess system type
 
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
+This script (version $timestamp), has failed to recognize the
+operating system you are using. If your script is old, overwrite *all*
+copies of config.guess and config.sub with the latest versions from:
 
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+  https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 and
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+  https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
+If $0 has already been updated, send the following data and any
+information you think might be pertinent to config-patches@gnu.org to
+provide the necessary information to handle your system.
 
 config.guess timestamp = $timestamp
 
@@ -1405,16 +1460,16 @@ hostinfo               = `(hostinfo) 2>/dev/null`
 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
 
-UNAME_MACHINE = ${UNAME_MACHINE}
-UNAME_RELEASE = ${UNAME_RELEASE}
-UNAME_SYSTEM  = ${UNAME_SYSTEM}
-UNAME_VERSION = ${UNAME_VERSION}
+UNAME_MACHINE = "$UNAME_MACHINE"
+UNAME_RELEASE = "$UNAME_RELEASE"
+UNAME_SYSTEM  = "$UNAME_SYSTEM"
+UNAME_VERSION = "$UNAME_VERSION"
 EOF
 
 exit 1
 
 # Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "timestamp='"
 # time-stamp-format: "%:y-%02m-%02d"
 # time-stamp-end: "'"
index 7ffe373..9ccf09a 100755 (executable)
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1992-2014 Free Software Foundation, Inc.
+#   Copyright 1992-2018 Free Software Foundation, Inc.
 
-timestamp='2014-12-03'
+timestamp='2018-03-08'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@ timestamp='2014-12-03'
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -33,7 +33,7 @@ timestamp='2014-12-03'
 # Otherwise, we print the canonical config type on stdout and succeed.
 
 # You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
 # This file is supposed to be the same for all GNU packages
 # and recognize all the CPU types, system types and aliases
@@ -53,12 +53,11 @@ timestamp='2014-12-03'
 me=`echo "$0" | sed -e 's,.*/,,'`
 
 usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
-       $0 [OPTION] ALIAS
+Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
 
 Canonicalize a configuration name.
 
-Operation modes:
+Options:
   -h, --help         print this help, then exit
   -t, --time-stamp   print date of last modification, then exit
   -v, --version      print version number, then exit
@@ -68,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright 1992-2014 Free Software Foundation, Inc.
+Copyright 1992-2018 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -95,7 +94,7 @@ while test $# -gt 0 ; do
 
     *local*)
        # First pass through any local machine types.
-       echo $1
+       echo "$1"
        exit ;;
 
     * )
@@ -113,24 +112,24 @@ esac
 
 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
 # Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
   linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
-  knetbsd*-gnu* | netbsd*-gnu* | \
-  kopensolaris*-gnu* | \
+  knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
+  kopensolaris*-gnu* | cloudabi*-eabi* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
-    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
   android-linux)
     os=-linux-android
-    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+    basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
     ;;
   *)
-    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
-    if [ $basic_machine != $1 ]
-    then os=`echo $1 | sed 's/.*-/-/'`
+    basic_machine=`echo "$1" | sed 's/-[^-]*$//'`
+    if [ "$basic_machine" != "$1" ]
+    then os=`echo "$1" | sed 's/.*-/-/'`
     else os=; fi
     ;;
 esac
@@ -179,44 +178,44 @@ case $os in
                ;;
        -sco6)
                os=-sco5v6
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
                ;;
        -sco5)
                os=-sco3.2v5
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
                ;;
        -sco4)
                os=-sco3.2v4
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
                ;;
        -sco3.2.[4-9]*)
                os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
                ;;
        -sco3.2v[4-9]*)
                # Don't forget version if it is 3.2v4 or newer.
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
                ;;
        -sco5v6*)
                # Don't forget version if it is 3.2v4 or newer.
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
                ;;
        -sco*)
                os=-sco3.2v2
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
                ;;
        -udk*)
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
                ;;
        -isc)
                os=-isc2.2
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
                ;;
        -clix*)
                basic_machine=clipper-intergraph
                ;;
        -isc*)
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
                ;;
        -lynx*178)
                os=-lynxos178
@@ -228,10 +227,7 @@ case $os in
                os=-lynxos
                ;;
        -ptx*)
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
-               ;;
-       -windowsnt*)
-               os=`echo $os | sed -e 's/windowsnt/winnt/'`
+               basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'`
                ;;
        -psos*)
                os=-psos
@@ -255,15 +251,16 @@ case $basic_machine in
        | arc | arceb \
        | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
        | avr | avr32 \
+       | ba \
        | be32 | be64 \
        | bfin \
        | c4x | c8051 | clipper \
        | d10v | d30v | dlx | dsp16xx \
-       | epiphany \
-       | fido | fr30 | frv \
+       | e2k | epiphany \
+       | fido | fr30 | frv | ft32 \
        | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
        | hexagon \
-       | i370 | i860 | i960 | ia64 \
+       | i370 | i860 | i960 | ia16 | ia64 \
        | ip2k | iq2000 \
        | k1om \
        | le32 | le64 \
@@ -299,13 +296,14 @@ case $basic_machine in
        | nios | nios2 | nios2eb | nios2el \
        | ns16k | ns32k \
        | open8 | or1k | or1knd | or32 \
-       | pdp10 | pdp11 | pj | pjl \
+       | pdp10 | pj | pjl \
        | powerpc | powerpc64 | powerpc64le | powerpcle \
+       | pru \
        | pyramid \
        | riscv32 | riscv64 \
        | rl78 | rx \
        | score \
-       | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+       | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
        | sh64 | sh64le \
        | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
        | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
@@ -314,7 +312,7 @@ case $basic_machine in
        | ubicom32 \
        | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
        | visium \
-       | we32k \
+       | wasm32 \
        | x86 | xc16x | xstormy16 | xtensa \
        | z8k | z80)
                basic_machine=$basic_machine-unknown
@@ -335,7 +333,7 @@ case $basic_machine in
                basic_machine=$basic_machine-unknown
                os=-none
                ;;
-       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65)
                ;;
        ms1)
                basic_machine=mt-unknown
@@ -364,7 +362,7 @@ case $basic_machine in
          ;;
        # Object if more than one company name word.
        *-*-*)
-               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
                exit 1
                ;;
        # Recognize the basic CPU types with company name.
@@ -376,17 +374,18 @@ case $basic_machine in
        | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
        | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
        | avr-* | avr32-* \
+       | ba-* \
        | be32-* | be64-* \
        | bfin-* | bs2000-* \
        | c[123]* | c30-* | [cjt]90-* | c4x-* \
        | c8051-* | clipper-* | craynv-* | cydra-* \
        | d10v-* | d30v-* | dlx-* \
-       | elxsi-* \
+       | e2k-* | elxsi-* \
        | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
        | h8300-* | h8500-* \
        | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
        | hexagon-* \
-       | i*86-* | i860-* | i960-* | ia64-* \
+       | i*86-* | i860-* | i960-* | ia16-* | ia64-* \
        | ip2k-* | iq2000-* \
        | k1om-* \
        | le32-* | le64-* \
@@ -427,13 +426,15 @@ case $basic_machine in
        | orion-* \
        | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
        | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+       | pru-* \
        | pyramid-* \
+       | riscv32-* | riscv64-* \
        | rl78-* | romp-* | rs6000-* | rx-* \
        | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
        | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
        | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
        | sparclite-* \
-       | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+       | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
        | tahoe-* \
        | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
        | tile*-* \
@@ -442,6 +443,7 @@ case $basic_machine in
        | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
        | vax-* \
        | visium-* \
+       | wasm32-* \
        | we32k-* \
        | x86-* | x86_64-* | xc16x-* | xps100-* \
        | xstormy16-* | xtensa*-* \
@@ -455,7 +457,7 @@ case $basic_machine in
        # Recognize the various machine names and aliases which stand
        # for a CPU type and a company and sometimes even an OS.
        386bsd)
-               basic_machine=i386-unknown
+               basic_machine=i386-pc
                os=-bsd
                ;;
        3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
@@ -489,7 +491,7 @@ case $basic_machine in
                basic_machine=x86_64-pc
                ;;
        amd64-*)
-               basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        amdahl)
                basic_machine=580-amdahl
@@ -518,6 +520,9 @@ case $basic_machine in
                basic_machine=i386-pc
                os=-aros
                ;;
+       asmjs)
+               basic_machine=asmjs-unknown
+               ;;
        aux)
                basic_machine=m68k-apple
                os=-aux
@@ -531,7 +536,7 @@ case $basic_machine in
                os=-linux
                ;;
        blackfin-*)
-               basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                os=-linux
                ;;
        bluegene*)
@@ -539,13 +544,13 @@ case $basic_machine in
                os=-cnk
                ;;
        c54x-*)
-               basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        c55x-*)
-               basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        c6x-*)
-               basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        c90)
                basic_machine=c90-cray
@@ -634,10 +639,18 @@ case $basic_machine in
                basic_machine=rs6000-bull
                os=-bosx
                ;;
-       dpx2* | dpx2*-bull)
+       dpx2*)
                basic_machine=m68k-bull
                os=-sysv3
                ;;
+       e500v[12])
+               basic_machine=powerpc-unknown
+               os=$os"spe"
+               ;;
+       e500v[12]-*)
+               basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+               os=$os"spe"
+               ;;
        ebmon29k)
                basic_machine=a29k-amd
                os=-ebmon
@@ -727,9 +740,6 @@ case $basic_machine in
        hp9k8[0-9][0-9] | hp8[0-9][0-9])
                basic_machine=hppa1.0-hp
                ;;
-       hppa-next)
-               os=-nextstep3
-               ;;
        hppaosf)
                basic_machine=hppa1.1-hp
                os=-osf
@@ -742,26 +752,26 @@ case $basic_machine in
                basic_machine=i370-ibm
                ;;
        i*86v32)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
                os=-sysv32
                ;;
        i*86v4*)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
                os=-sysv4
                ;;
        i*86v)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
                os=-sysv
                ;;
        i*86sol2)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
                os=-solaris2
                ;;
        i386mach)
                basic_machine=i386-mach
                os=-mach
                ;;
-       i386-vsta | vsta)
+       vsta)
                basic_machine=i386-unknown
                os=-vsta
                ;;
@@ -780,19 +790,16 @@ case $basic_machine in
                os=-sysv
                ;;
        leon-*|leon[3-9]-*)
-               basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
+               basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'`
                ;;
        m68knommu)
                basic_machine=m68k-unknown
                os=-linux
                ;;
        m68knommu-*)
-               basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                os=-linux
                ;;
-       m88k-omron*)
-               basic_machine=m88k-omron
-               ;;
        magnum | m3230)
                basic_machine=mips-mips
                os=-sysv
@@ -824,10 +831,10 @@ case $basic_machine in
                os=-mint
                ;;
        mips3*-*)
-               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+               basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`
                ;;
        mips3*)
-               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+               basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown
                ;;
        monitor)
                basic_machine=m68k-rom68k
@@ -846,7 +853,7 @@ case $basic_machine in
                os=-msdos
                ;;
        ms1-*)
-               basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+               basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'`
                ;;
        msys)
                basic_machine=i686-pc
@@ -888,7 +895,7 @@ case $basic_machine in
                basic_machine=v70-nec
                os=-sysv
                ;;
-       next | m*-next )
+       next | m*-next)
                basic_machine=m68k-next
                case $os in
                    -nextstep* )
@@ -933,6 +940,12 @@ case $basic_machine in
        nsr-tandem)
                basic_machine=nsr-tandem
                ;;
+       nsv-tandem)
+               basic_machine=nsv-tandem
+               ;;
+       nsx-tandem)
+               basic_machine=nsx-tandem
+               ;;
        op50n-* | op60c-*)
                basic_machine=hppa1.1-oki
                os=-proelf
@@ -965,7 +978,7 @@ case $basic_machine in
                os=-linux
                ;;
        parisc-*)
-               basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                os=-linux
                ;;
        pbd)
@@ -981,7 +994,7 @@ case $basic_machine in
                basic_machine=i386-pc
                ;;
        pc98-*)
-               basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        pentium | p5 | k5 | k6 | nexgen | viac3)
                basic_machine=i586-pc
@@ -996,16 +1009,16 @@ case $basic_machine in
                basic_machine=i786-pc
                ;;
        pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
-               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        pentiumpro-* | p6-* | 6x86-* | athlon-*)
-               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
-               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        pentium4-*)
-               basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        pn)
                basic_machine=pn-gould
@@ -1015,23 +1028,23 @@ case $basic_machine in
        ppc | ppcbe)    basic_machine=powerpc-unknown
                ;;
        ppc-* | ppcbe-*)
-               basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
-       ppcle | powerpclittle | ppc-le | powerpc-little)
+       ppcle | powerpclittle)
                basic_machine=powerpcle-unknown
                ;;
        ppcle-* | powerpclittle-*)
-               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        ppc64)  basic_machine=powerpc64-unknown
                ;;
-       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+       ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
-       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+       ppc64le | powerpc64little)
                basic_machine=powerpc64le-unknown
                ;;
        ppc64le-* | powerpc64little-*)
-               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        ps2)
                basic_machine=i386-ibm
@@ -1085,17 +1098,10 @@ case $basic_machine in
        sequent)
                basic_machine=i386-sequent
                ;;
-       sh)
-               basic_machine=sh-hitachi
-               os=-hms
-               ;;
        sh5el)
                basic_machine=sh5le-unknown
                ;;
-       sh64)
-               basic_machine=sh64-unknown
-               ;;
-       sparclite-wrs | simso-wrs)
+       simso-wrs)
                basic_machine=sparclite-wrs
                os=-vxworks
                ;;
@@ -1114,7 +1120,7 @@ case $basic_machine in
                os=-sysv4
                ;;
        strongarm-* | thumb-*)
-               basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        sun2)
                basic_machine=m68000-sun
@@ -1236,6 +1242,9 @@ case $basic_machine in
                basic_machine=hppa1.1-winbond
                os=-proelf
                ;;
+       x64)
+               basic_machine=x86_64-pc
+               ;;
        xbox)
                basic_machine=i686-pc
                os=-mingw32
@@ -1244,20 +1253,12 @@ case $basic_machine in
                basic_machine=xps100-honeywell
                ;;
        xscale-* | xscalee[bl]-*)
-               basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+               basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'`
                ;;
        ymp)
                basic_machine=ymp-cray
                os=-unicos
                ;;
-       z8k-*-coff)
-               basic_machine=z8k-unknown
-               os=-sim
-               ;;
-       z80-*-coff)
-               basic_machine=z80-unknown
-               os=-sim
-               ;;
        none)
                basic_machine=none-none
                os=-none
@@ -1286,10 +1287,6 @@ case $basic_machine in
        vax)
                basic_machine=vax-dec
                ;;
-       pdp10)
-               # there are many clones, so DEC is not a safe bet
-               basic_machine=pdp10-unknown
-               ;;
        pdp11)
                basic_machine=pdp11-dec
                ;;
@@ -1299,9 +1296,6 @@ case $basic_machine in
        sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
                basic_machine=sh-unknown
                ;;
-       sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
-               basic_machine=sparc-sun
-               ;;
        cydra)
                basic_machine=cydra-cydrome
                ;;
@@ -1321,7 +1315,7 @@ case $basic_machine in
                # Make sure to match an already-canonicalized machine name.
                ;;
        *)
-               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
                exit 1
                ;;
 esac
@@ -1329,10 +1323,10 @@ esac
 # Here we canonicalize certain aliases for manufacturers.
 case $basic_machine in
        *-digital*)
-               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+               basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'`
                ;;
        *-commodore*)
-               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+               basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'`
                ;;
        *)
                ;;
@@ -1343,8 +1337,8 @@ esac
 if [ x"$os" != x"" ]
 then
 case $os in
-       # First match some system type aliases
-       # that might get confused with valid system types.
+       # First match some system type aliases that might get confused
+       # with valid system types.
        # -solaris* is a basic system type, with this one exception.
        -auroraux)
                os=-auroraux
@@ -1355,45 +1349,48 @@ case $os in
        -solaris)
                os=-solaris2
                ;;
-       -svr4*)
-               os=-sysv4
-               ;;
        -unixware*)
                os=-sysv4.2uw
                ;;
        -gnu/linux*)
                os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
                ;;
-       # First accept the basic system types.
+       # es1800 is here to avoid being matched by es* (a different OS)
+       -es1800*)
+               os=-ose
+               ;;
+       # Now accept the basic system types.
        # The portable systems comes first.
-       # Each alternative MUST END IN A *, to match a version number.
+       # Each alternative MUST end in a * to match a version number.
        # -sysv* is not here because it comes later, after sysvr4.
        -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
              | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
              | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
              | -sym* | -kopensolaris* | -plan9* \
              | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-             | -aos* | -aros* \
+             | -aos* | -aros* | -cloudabi* | -sortix* \
              | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
              | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
-             | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
-             | -bitrig* | -openbsd* | -solidbsd* \
+             | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \
+             | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \
              | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
              | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
              | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
-             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-             | -chorusos* | -chorusrdb* | -cegcc* \
+             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* | -hcos* \
+             | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \
              | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-             | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+             | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
              | -linux-newlib* | -linux-musl* | -linux-uclibc* \
              | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
-             | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+             | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \
              | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
              | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
              | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
-             | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+             | -morphos* | -superux* | -rtmk* | -windiss* \
              | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-             | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
+             | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
+             | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \
+             | -midnightbsd*)
        # Remember, each alternative MUST END IN *, to match a version number.
                ;;
        -qnx*)
@@ -1410,12 +1407,12 @@ case $os in
        -nto*)
                os=`echo $os | sed -e 's|nto|nto-qnx|'`
                ;;
-       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
-             | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+       -sim | -xray | -os68k* | -v88r* \
+             | -windows* | -osx | -abug | -netware* | -os9* \
              | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
                ;;
        -mac*)
-               os=`echo $os | sed -e 's|mac|macos|'`
+               os=`echo "$os" | sed -e 's|mac|macos|'`
                ;;
        -linux-dietlibc)
                os=-linux-dietlibc
@@ -1424,10 +1421,10 @@ case $os in
                os=`echo $os | sed -e 's|linux|linux-gnu|'`
                ;;
        -sunos5*)
-               os=`echo $os | sed -e 's|sunos5|solaris2|'`
+               os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
                ;;
        -sunos6*)
-               os=`echo $os | sed -e 's|sunos6|solaris3|'`
+               os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
                ;;
        -opened*)
                os=-openedition
@@ -1438,12 +1435,6 @@ case $os in
        -wince*)
                os=-wince
                ;;
-       -osfrose*)
-               os=-osfrose
-               ;;
-       -osf*)
-               os=-osf
-               ;;
        -utek*)
                os=-bsd
                ;;
@@ -1468,7 +1459,7 @@ case $os in
        -nova*)
                os=-rtmk-nova
                ;;
-       -ns2 )
+       -ns2)
                os=-nextstep2
                ;;
        -nsk*)
@@ -1490,7 +1481,7 @@ case $os in
        -oss*)
                os=-sysv3
                ;;
-       -svr4)
+       -svr4*)
                os=-sysv4
                ;;
        -svr3)
@@ -1505,32 +1496,38 @@ case $os in
        -ose*)
                os=-ose
                ;;
-       -es1800*)
-               os=-ose
-               ;;
-       -xenix)
-               os=-xenix
-               ;;
        -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
                os=-mint
                ;;
-       -aros*)
-               os=-aros
-               ;;
        -zvmoe)
                os=-zvmoe
                ;;
        -dicos*)
                os=-dicos
                ;;
+       -pikeos*)
+               # Until real need of OS specific support for
+               # particular features comes up, bare metal
+               # configurations are quite functional.
+               case $basic_machine in
+                   arm*)
+                       os=-eabi
+                       ;;
+                   *)
+                       os=-elf
+                       ;;
+               esac
+               ;;
        -nacl*)
                ;;
+       -ios)
+               ;;
        -none)
                ;;
        *)
                # Get rid of the `-' at the beginning of $os.
                os=`echo $os | sed 's/[^-]*-//'`
-               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+               echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2
                exit 1
                ;;
 esac
@@ -1620,12 +1617,12 @@ case $basic_machine in
        sparc-* | *-sun)
                os=-sunos4.1.1
                ;;
+       pru-*)
+               os=-elf
+               ;;
        *-be)
                os=-beos
                ;;
-       *-haiku)
-               os=-haiku
-               ;;
        *-ibm)
                os=-aix
                ;;
@@ -1665,7 +1662,7 @@ case $basic_machine in
        m88k-omron*)
                os=-luna
                ;;
-       *-next )
+       *-next)
                os=-nextstep
                ;;
        *-sequent)
@@ -1680,9 +1677,6 @@ case $basic_machine in
        i370-*)
                os=-mvs
                ;;
-       *-next)
-               os=-nextstep3
-               ;;
        *-gould)
                os=-sysv
                ;;
@@ -1792,15 +1786,15 @@ case $basic_machine in
                                vendor=stratus
                                ;;
                esac
-               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+               basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"`
                ;;
 esac
 
-echo $basic_machine$os
+echo "$basic_machine$os"
 exit
 
 # Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "timestamp='"
 # time-stamp-format: "%:y-%02m-%02d"
 # time-stamp-end: "'"
index b8040cd..295cbcb 100644 (file)
   <!-- Read CMYK Postscript, EPS, and PDF  -->
   <delegate decode="gs-cmyk" stealth="True" command='"@PSDelegate@" -q -dBATCH -dSAFER -dMaxBitmap=50000000 -dNOPAUSE -sDEVICE=@GSCMYKDevice@ -dTextAlphaBits=%u -dGraphicsAlphaBits=%u -r%s %s "-sOutputFile=%s" -- "%s" -c quit' />
 
+  <!-- Read monochrome PDF using Poppler's pdftoppm -->
+  <delegate decode="poppler-mono" stealth="True" command='"pdftoppm" "-mono" "-freetype" "yes" "-aa" "yes" "-aaVector" "yes" "-rx" "72" "-ry" "72" "%s" ">" "%s"' />
+
+  <!-- Read grayscale PDF using Poppler's pdftoppm -->
+  <delegate decode="poppler-grey" stealth="True" command='"pdftoppm" "-gray" "-freetype" "yes" "-aa" "yes" "-aaVector" "yes" "-rx" "72" "-ry" "72" "%s" ">" "%s"' />
+
+  <!-- Read color PDF using Poppler's pdftoppm -->
+  <delegate decode="poppler-color" stealth="True" command='"pdftoppm" "-freetype" "yes" "-rx" "-aa" "yes" "-aaVector" "yes" "72" "-ry" "72" "%s" ">" "%s"' />
+
   <delegate decode="hpg" command='"@HPGLDecodeDelegate@" -q -m eps -f `basename "%o"` "%i" && @MVDelegate@ -f `basename "%o"` "%o"' />
   <delegate decode="hpgl" command='"@HPGLDecodeDelegate@" -q -m eps -f `basename "%o"` "%i" && @MVDelegate@ -f `basename "%o"` "%o"' />
   <!-- Read HTML file  -->
index fc98710..65cbf70 100755 (executable)
@@ -1,9 +1,9 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2013-05-30.07; # UTC
+scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2018 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@ scriptversion=2013-05-30.07; # UTC
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -783,9 +783,9 @@ exit 0
 # Local Variables:
 # mode: shell-script
 # sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:
index 0b0fdcb..8175c64 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2013-12-25.23; # UTC
+scriptversion=2018-03-11.20; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -271,15 +271,18 @@ do
     fi
     dst=$dst_arg
 
-    # If destination is a directory, append the input filename; won't work
-    # if double slashes aren't ignored.
+    # If destination is a directory, append the input filename.
     if test -d "$dst"; then
       if test "$is_target_a_directory" = never; then
         echo "$0: $dst_arg: Is a directory" >&2
         exit 1
       fi
       dstdir=$dst
-      dst=$dstdir/`basename "$src"`
+      dstbase=`basename "$src"`
+      case $dst in
+       */) dst=$dst$dstbase;;
+       *)  dst=$dst/$dstbase;;
+      esac
       dstdir_status=0
     else
       dstdir=`dirname "$dst"`
@@ -288,6 +291,11 @@ do
     fi
   fi
 
+  case $dstdir in
+    */) dstdirslash=$dstdir;;
+    *)  dstdirslash=$dstdir/;;
+  esac
+
   obsolete_mkdir_used=false
 
   if test $dstdir_status != 0; then
@@ -324,34 +332,43 @@ do
             # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
             ;;
           *)
+            # Note that $RANDOM variable is not portable (e.g. dash);  Use it
+            # here however when possible just to lower collision chance.
             tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
-            trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
 
+            trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+            # Because "mkdir -p" follows existing symlinks and we likely work
+            # directly in world-writeable /tmp, make sure that the '$tmpdir'
+            # directory is successfully created first before we actually test
+            # 'mkdir -p' feature.
             if (umask $mkdir_umask &&
-                exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+                $mkdirprog $mkdir_mode "$tmpdir" &&
+                exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
             then
               if test -z "$dir_arg" || {
                    # Check for POSIX incompatibilities with -m.
                    # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
                    # other-writable bit of parent directory when it shouldn't.
                    # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
-                   ls_ld_tmpdir=`ls -ld "$tmpdir"`
+                   test_tmpdir="$tmpdir/a"
+                   ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
                    case $ls_ld_tmpdir in
                      d????-?r-*) different_mode=700;;
                      d????-?--*) different_mode=755;;
                      *) false;;
                    esac &&
-                   $mkdirprog -m$different_mode -p -- "$tmpdir" && {
-                     ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+                   $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
+                     ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
                      test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
                    }
                  }
               then posix_mkdir=:
               fi
-              rmdir "$tmpdir/d" "$tmpdir"
+              rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
             else
               # Remove any dirs left behind by ancient mkdir implementations.
-              rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+              rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
             fi
             trap '' 0;;
         esac;;
@@ -427,8 +444,8 @@ do
   else
 
     # Make a couple of temp file names in the proper directory.
-    dsttmp=$dstdir/_inst.$$_
-    rmtmp=$dstdir/_rm.$$_
+    dsttmp=${dstdirslash}_inst.$$_
+    rmtmp=${dstdirslash}_rm.$$_
 
     # Trap to clean up those temp files at exit.
     trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
@@ -493,9 +510,9 @@ do
 done
 
 # Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:
index f62bbae..625aeb1 100755 (executable)
@@ -1,9 +1,9 @@
 #! /bin/sh
 # Common wrapper for a few potentially missing GNU programs.
 
-scriptversion=2013-10-28.13; # UTC
+scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2018 Free Software Foundation, Inc.
 # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ scriptversion=2013-10-28.13; # UTC
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -101,9 +101,9 @@ else
   exit $st
 fi
 
-perl_URL=http://www.perl.org/
-flex_URL=http://flex.sourceforge.net/
-gnu_software_URL=http://www.gnu.org/software
+perl_URL=https://www.perl.org/
+flex_URL=https://github.com/westes/flex
+gnu_software_URL=https://www.gnu.org/software
 
 program_details ()
 {
@@ -207,9 +207,9 @@ give_advice "$1" | sed -e '1s/^/WARNING: /' \
 exit $st
 
 # Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:
index 4254e2b..2516e9c 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2011-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2018 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -132,7 +132,7 @@ fi
     # last `echo $?' statement), and would thus die reporting an internal
     # error.
     # For more information, see the Autoconf manual and the threads:
-    # <http://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
+    # <https://lists.gnu.org/archive/html/bug-autoconf/2011-09/msg00004.html>
     # <http://mail.opensolaris.org/pipermail/ksh93-integration-discuss/2009-February/004121.html>
     trap : 1 3 2 13 15
     if test $merge -gt 0; then
@@ -643,9 +643,9 @@ test $? -eq 0 || fatal "I/O or internal error"
 # Local Variables:
 # mode: shell-script
 # sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:
index 8e575b0..b8521a4 100755 (executable)
@@ -1,9 +1,9 @@
 #! /bin/sh
 # test-driver - basic testsuite driver script.
 
-scriptversion=2013-07-13.22; # UTC
+scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 2011-2014 Free Software Foundation, Inc.
+# Copyright (C) 2011-2018 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@ scriptversion=2013-07-13.22; # UTC
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -140,9 +140,9 @@ echo ":copy-in-global-log: $gcopy" >> $trs_file
 # Local Variables:
 # mode: shell-script
 # sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:
index effa4f1..46b7c6d 100755 (executable)
--- a/configure
+++ b/configure
@@ -638,6 +638,7 @@ MAGICK_API_LDFLAGS
 MAGICK_API_PC_CPPFLAGS
 MAGICK_API_CPPFLAGS
 MAGICK_API_CFLAGS
+MAGICK_EXTRA_DEP_LIBS
 MAGICK_DEP_LIBS
 MAGICK_FEATURES
 DELEGATES
@@ -720,6 +721,8 @@ LIB_XML_DEPS
 LIB_XML
 HasXML_FALSE
 HasXML_TRUE
+XML_LIBS
+XML_CFLAGS
 xml2_config
 LIB_WEBP
 HasWEBP_FALSE
@@ -733,10 +736,12 @@ HasTIFF_TRUE
 LIB_TTF
 HasTTF_FALSE
 HasTTF_TRUE
+FT_LIBS
+FT_CFLAGS
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
 freetype_config
-LIB_GS
-HasGS_FALSE
-HasGS_TRUE
 LIB_JP2
 HasJP2_FALSE
 HasJP2_TRUE
@@ -765,6 +770,9 @@ X_LIBS
 X_PRE_LIBS
 X_CFLAGS
 XMKMF
+LIB_ZSTD
+HasZSTD_FALSE
+HasZSTD_TRUE
 LIB_LZMA
 HasLZMA_FALSE
 HasLZMA_TRUE
@@ -1039,7 +1047,6 @@ with_perl_options
 with_bzlib
 with_dps
 with_fpx
-with_gslib
 with_jbig
 with_webp
 with_jpeg
@@ -1057,6 +1064,7 @@ with_gs_font_dir
 with_windows_font_dir
 with_xml
 with_zlib
+with_zstd
 with_libstdc
 with_x
 '
@@ -1074,7 +1082,14 @@ CXX
 CXXFLAGS
 CCC
 CXXCPP
-XMKMF'
+XMKMF
+PKG_CONFIG
+PKG_CONFIG_PATH
+PKG_CONFIG_LIBDIR
+FT_CFLAGS
+FT_LIBS
+XML_CFLAGS
+XML_LIBS'
 
 
 # Initialize some variables set by options.
@@ -1751,7 +1766,6 @@ Optional Packages:
   --without-bzlib         disable BZLIB support
   --without-dps           disable Display Postscript support
   --with-fpx              enable FlashPIX support
-  --with-gslib            enable Ghostscript library support (not recommended)
   --without-jbig          disable JBIG support
   --without-webp          disable WEBP support
   --without-jpeg          disable JPEG support
@@ -1770,6 +1784,7 @@ Optional Packages:
                           directory containing MS-Windows fonts
   --without-xml           disable XML support
   --without-zlib          disable ZLIB support
+  --without-zstd          disable Zstd support
   --with-libstdc=DIR      use libstdc++ in DIR (for GNU C++)
   --with-x                use the X Window System
   --without-png           disable PNG support
@@ -1789,6 +1804,15 @@ Some influential environment variables:
   CXXFLAGS    C++ compiler flags
   CXXCPP      C++ preprocessor
   XMKMF       Path to xmkmf, Makefile generator for X Window System
+  PKG_CONFIG  path to pkg-config utility
+  PKG_CONFIG_PATH
+              directories to add to pkg-config's search path
+  PKG_CONFIG_LIBDIR
+              path overriding pkg-config's built-in search path
+  FT_CFLAGS   C compiler flags for FT, overriding pkg-config
+  FT_LIBS     linker flags for FT, overriding pkg-config
+  XML_CFLAGS  C compiler flags for XML, overriding pkg-config
+  XML_LIBS    linker flags for XML, overriding pkg-config
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -8011,6 +8035,21 @@ fi
 
 
 #
+# Decide if setjmp/longjmp is thread safe based on host OS
+#
+case "${host_os}" in
+  solaris2* )
+    # Documented not to be MT safe
+
+    ;;
+  *)
+
+$as_echo "#define SETJMP_IS_THREAD_SAFE 1" >>confdefs.h
+
+    ;;
+esac
+
+#
 # Configure libtool
 #
 
@@ -19589,19 +19628,6 @@ if test "$with_fpx" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-fpx=$with_fpx "
 fi
 
-# Enable Ghostscript library support.
-
-# Check whether --with-gslib was given.
-if test "${with_gslib+set}" = set; then :
-  withval=$with_gslib; with_gslib=$withval
-else
-  with_gslib='no'
-fi
-
-if test "$with_gslib" != 'yes' ; then
-    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-gslib=$with_gslib "
-fi
-
 # Disable JBIG.
 
 # Check whether --with-jbig was given.
 
 # # Disable MPEG.
 # AC_ARG_WITH(mpeg2,
-#            AS_HELP_STRING([--without-mpeg2],
+#             AS_HELP_STRING([--without-mpeg2],
 #                            [disable MPEG support]),
-#            [with_mpeg2=$withval],
-#            [with_mpeg2='yes'])
+#             [with_mpeg2=$withval],
+#             [with_mpeg2='yes'])
 
 # Disable PNG.
 
@@ -19841,6 +19867,19 @@ if test "$with_zlib" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-zlib=$with_zlib "
 fi
 
+# Disable Zstd (zstd library)
+
+# Check whether --with-zstd was given.
+if test "${with_zstd+set}" = set; then :
+  withval=$with_zstd; with_zstd=$withval
+else
+  with_zstd='yes'
+fi
+
+if test "$with_zstd" != 'yes' ; then
+    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-zstd=$with_zstd "
+fi
+
 #
 # Specify path to shared libstdc++ if not in normal location
 #
@@ -22977,7 +23016,7 @@ else
   # Look for the header file in a standard set of common directories.
 # Check X11 before X11Rn because it is often a symlink to the current release.
   for ac_dir in               \
-    /lib/usr/lib/X11     \
+    /lib/usr/lib/X11      \
     /usr/X11/lib          \
     /usr/X11R4/lib        \
     /usr/X11R5/lib        \
@@ -23014,7 +23053,7 @@ else
     if test -f "$ac_dir/X11/rgb.txt"
     then
         gm_cv_x_configure="$ac_dir/X11/"
-       break
+        break
     elif test -f "$ac_dir/rgb.txt"
     then
         gm_cv_x_configure="$ac_dir/"
@@ -23829,8 +23868,10 @@ then
 $as_echo_n "checking for ZLIB support ... " >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
 $as_echo "" >&6; }
+
   failed=0
   passed=0
+  # PKG_CHECK_MODULES([ZLIB], [zlib], [], [])
   ac_fn_c_check_header_mongrel "$LINENO" "zconf.h" "ac_cv_header_zconf_h" "$ac_includes_default"
 if test "x$ac_cv_header_zconf_h" = xyes; then :
   passed=`expr $passed + 1`
@@ -24297,6 +24338,7 @@ then
 $as_echo_n "checking for LZMA support ... " >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
 $as_echo "" >&6; }
+  # PKG_CHECK_MODULES([LZMA], [liblzma], [], [])
   failed=0
   passed=0
   ac_fn_c_check_header_mongrel "$LINENO" "lzma.h" "ac_cv_header_lzma_h" "$ac_includes_default"
 
 
 #
+# Check for Zstd
+#
+have_zstd='no'
+LIB_ZSTD=''
+if test "$with_zstd" != 'no'
+then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Zstd support " >&5
+$as_echo_n "checking for Zstd support ... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
+$as_echo "" >&6; }
+  failed=0
+  passed=0
+  # PKG_CHECK_MODULES([ZSTD], [libzstd], [], [])
+  ac_fn_c_check_header_mongrel "$LINENO" "zstd.h" "ac_cv_header_zstd_h" "$ac_includes_default"
+if test "x$ac_cv_header_zstd_h" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZSTD_createDStream in -lzstd" >&5
+$as_echo_n "checking for ZSTD_createDStream in -lzstd... " >&6; }
+if ${ac_cv_lib_zstd_ZSTD_createDStream+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lzstd  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ZSTD_createDStream ();
+int
+main ()
+{
+return ZSTD_createDStream ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_zstd_ZSTD_createDStream=yes
+else
+  ac_cv_lib_zstd_ZSTD_createDStream=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_zstd_ZSTD_createDStream" >&5
+$as_echo "$ac_cv_lib_zstd_ZSTD_createDStream" >&6; }
+if test "x$ac_cv_lib_zstd_ZSTD_createDStream" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Zstd package is complete" >&5
+$as_echo_n "checking if Zstd package is complete... " >&6; }
+  if test $passed -gt 0
+  then
+    if test $failed -gt 0
+    then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+$as_echo "no -- some components failed test" >&6; }
+      have_zstd='no (failed tests)'
+    else
+      LIB_ZSTD='-lzstd'
+      LIBS="$LIB_ZSTD $LIBS"
+
+$as_echo "#define HasZSTD 1" >>confdefs.h
+
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+      have_zstd='yes'
+    fi
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  fi
+fi
+ if test "$have_zstd" = 'yes'; then
+  HasZSTD_TRUE=
+  HasZSTD_FALSE='#'
+else
+  HasZSTD_TRUE='#'
+  HasZSTD_FALSE=
+fi
+
+
+
+#
 # Find the X11 include and library directories.
 #
 LIB_X11=''
@@ -25489,19 +25629,19 @@ $as_echo_n "checking if DPS package is complete... " >&6; }
     then
     if test $failed -gt 0
     then
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
 $as_echo "no -- some components failed test" >&6; }
         have_dps='no (failed tests)'
-       CPPFLAGS="$O_CPPFLAGS"
+        CPPFLAGS="$O_CPPFLAGS"
     else
-       LIB_DPS="-ldpstk -ldps ${LIBDPS_XT}"
-       LIBS="$LIB_DPS $LIBS"
+        LIB_DPS="-ldpstk -ldps ${LIBDPS_XT}"
+        LIBS="$LIB_DPS $LIBS"
 
 $as_echo "#define HasDPS 1" >>confdefs.h
 
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-       have_dps='yes'
+        have_dps='yes'
     fi
     else
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
@@ -25601,16 +25741,16 @@ $as_echo_n "checking if FlashPIX package is complete... " >&6; }
     then
     if test $failed -gt 0
     then
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
 $as_echo "no -- some components failed test" >&6; }
-       have_fpx='no (failed tests)'
+        have_fpx='no (failed tests)'
     else
-       LIB_FPX='-lfpx'
-       # LIBS="$LIB_FPX $LIBS"
+        LIB_FPX='-lfpx'
+        # LIBS="$LIB_FPX $LIBS"
 
 $as_echo "#define HasFPX 1" >>confdefs.h
 
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
         have_fpx='yes'
         PERLMAINCC="$CXX"
@@ -25645,6 +25785,8 @@ $as_echo "" >&6; }
     passed=0
     have_lcms_header='no'
 
+    # PKG_CHECK_MODULES([LCMS2], [lcms2], [], [])
+
     # Check for <lcms2.h>
     ac_fn_c_check_header_mongrel "$LINENO" "lcms2.h" "ac_cv_header_lcms2_h" "$ac_includes_default"
 if test "x$ac_cv_header_lcms2_h" = xyes; then :
@@ -25781,6 +25923,7 @@ else
   with_png='yes'
 fi
 
+      # PKG_CHECK_MODULES([PNG], [libpng], [], [])
 
   if test "$with_png" != 'yes'; then
       DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-png=$with_png "
@@ -25811,9 +25954,9 @@ fi
           pnglib="png1${var}"
         fi
         if test "$have_png" = 'no'
-       then
+        then
 
-         # Test for compatible LIBPNG library
+          # Test for compatible LIBPNG library
           failed=0
           passed=0
           if test "$with_png" = 'yes' -o "$with_png" = "libpng1${var}" ; then
 $as_echo_n "checking if ${pnglib} package is complete... " >&6; }
               if test $passed -gt 0 ; then
                 if test $failed -gt 0 ; then
-               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+                { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
 $as_echo "no -- some components failed test" >&6; }
-               have_png='no (failed tests)'
+                have_png='no (failed tests)'
                 else
-               LIB_PNG="-l${pnglib}"
-               LIBS="$LIB_PNG $LIBS"
+                LIB_PNG="-l${pnglib}"
+                LIBS="$LIB_PNG $LIBS"
 
 $as_echo "#define HasPNG 1" >>confdefs.h
 
-               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+                { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-               have_png='yes'
+                have_png='yes'
                 fi
               fi
             fi
@@ -26176,6 +26319,9 @@ $as_echo_n "checking for JPEG support ... " >&6; }
 $as_echo "" >&6; }
     failed=0
     passed=0
+
+    # PKG_CHECK_MODULES([JPEG], [libturbojpeg, libjpeg], [], [])
+
     ac_fn_c_check_header_mongrel "$LINENO" "jconfig.h" "ac_cv_header_jconfig_h" "$ac_includes_default"
 if test "x$ac_cv_header_jconfig_h" = xyes; then :
   passed=`expr $passed + 1`
@@ -26299,16 +26445,16 @@ $as_echo_n "checking if JPEG package is complete... " >&6; }
     then
     if test $failed -gt 0
     then
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
 $as_echo "no -- some components failed test" >&6; }
         have_jpeg='no (failed tests)'
     else
-       LIB_JPEG='-ljpeg'
-       LIBS="$LIB_JPEG $LIBS"
+        LIB_JPEG='-ljpeg'
+        LIBS="$LIB_JPEG $LIBS"
 
 $as_echo "#define HasJPEG 1" >>confdefs.h
 
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
         have_jpeg='yes'
     fi
@@ -26396,18 +26542,18 @@ $as_echo_n "checking if JPEG version 2 support package is complete... " >&6; }
     then
     if test $failed -gt 0
     then
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
 $as_echo "no -- some components failed test" >&6; }
-       have_jp2='no (failed tests)'
+        have_jp2='no (failed tests)'
     else
-       LIB_JP2='-ljasper'
-       LIBS="$LIB_JP2 $LIBS"
+        LIB_JP2='-ljasper'
+        LIBS="$LIB_JP2 $LIBS"
 
 $as_echo "#define HasJP2 1" >>confdefs.h
 
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-       have_jp2='yes'
+        have_jp2='yes'
     fi
     else
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 
 
 
-#
-# Check for Ghostscript library
-#
-# Test for iapi.h & test for gsapi_new_instance in -lgs
-have_gslib='no'
-LIB_GS=''
-if test "$with_gslib" != 'no'
-then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Ghostscript library support " >&5
-$as_echo_n "checking for Ghostscript library support ... " >&6; }
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
-$as_echo "" >&6; }
-    failed=0
-    passed=0
-    ac_fn_c_check_header_mongrel "$LINENO" "ghostscript/iapi.h" "ac_cv_header_ghostscript_iapi_h" "$ac_includes_default"
-if test "x$ac_cv_header_ghostscript_iapi_h" = xyes; then :
-  passed=`expr $passed + 1`
-else
-  failed=`expr $failed + 1`
-fi
-
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gsapi_new_instance in -lgs" >&5
-$as_echo_n "checking for gsapi_new_instance in -lgs... " >&6; }
-if ${ac_cv_lib_gs_gsapi_new_instance+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lgs  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char gsapi_new_instance ();
-int
-main ()
-{
-return gsapi_new_instance ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_gs_gsapi_new_instance=yes
-else
-  ac_cv_lib_gs_gsapi_new_instance=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gs_gsapi_new_instance" >&5
-$as_echo "$ac_cv_lib_gs_gsapi_new_instance" >&6; }
-if test "x$ac_cv_lib_gs_gsapi_new_instance" = xyes; then :
-  passed=`expr $passed + 1`
-else
-  failed=`expr $failed + 1`
-fi
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Ghostscript library package is complete" >&5
-$as_echo_n "checking if Ghostscript library package is complete... " >&6; }
-    if test $passed -gt 0
-    then
-    if test $failed -gt 0
-    then
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
-$as_echo "no -- some components failed test" >&6; }
-       have_gslib='no (failed tests)'
-    else
-       LIB_GS='-lgs'
-       LIBS="$LIB_GS $LIBS"
-
-$as_echo "#define HasGS 1" >>confdefs.h
-
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-       have_gslib='yes'
-    fi
-    else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-    fi
-fi
- if test "$have_gslib" = 'yes'; then
-  HasGS_TRUE=
-  HasGS_FALSE='#'
-else
-  HasGS_TRUE='#'
-  HasGS_FALSE=
-fi
-
-
-
 # #
 # # Check for MPEG2 library
 # #
 #     then
 #     if test $failed -gt 0
 #     then
-#      AC_MSG_RESULT(no -- some components failed test)
-#      have_mpeg2='no (failed tests)'
+#       AC_MSG_RESULT(no -- some components failed test)
+#       have_mpeg2='no (failed tests)'
 #     else
-#      LIB_MPEG2='-lmpeg2'
-#      LIBS="$LIB_MPEG2 $LIBS"
-#      AC_DEFINE(HasMPEG2,1,Define if you have MPEG2 library)
-#      AC_MSG_RESULT(yes)
-#      have_mpeg2='yes'
+#       LIB_MPEG2='-lmpeg2'
+#       LIBS="$LIB_MPEG2 $LIBS"
+#       AC_DEFINE(HasMPEG2,1,Define if you have MPEG2 library)
+#       AC_MSG_RESULT(yes)
+#       have_mpeg2='yes'
 #     fi
 #     else
 #     AC_MSG_RESULT(no)
@@ -26572,21 +26620,20 @@ $as_echo "" >&6; }
 
     OLD_LDFLAGS="$LDFLAGS"
     OLD_CPPFLAGS="$CPPFLAGS"
+    # https://autotools.io/pkgconfig/pkg_check_modules.html
+    # PKG_CHECK_MODULES(prefix, list-of-modules, action-if-found, action-if-not-found)
+    # % pkg-config --libs freetype2
+    # -lfreetype
+    # % pkg-config --cflags freetype2
+    # -I/usr/include/freetype2 -I/usr/include/libpng12
+    #
+    # % grep FT_ config.status
+    # S["FT_LIBS"]="-R/usr/lib -lfreetype  "
+    # S["FT_CFLAGS"]="-I/usr/include/freetype2
+    freetype_cflags=''
+    freeype_libs=''
     freetype_config=''
-    # Allow the user to specify the location of freetype.
-    if test "$with_ttf" != 'yes'
-    then
-      if test -x "${with_ttf}/bin/freetype-config"
-      then
-        freetype_config="${with_ttf}/bin/freetype-config"
-      elif test -x "${with_ttf}"
-      then
-        freetype_config=${with_ttf}
-      fi
-    fi
-    if test -z "$freetype_config"
-    then
-      # Extract the first word of "freetype-config", so it can be a program name with args.
+    # Extract the first word of "freetype-config", so it can be a program name with args.
 set dummy freetype-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
@@ -26625,10 +26672,205 @@ else
 $as_echo "no" >&6; }
 fi
 
-    fi
-    if test -n "$freetype_config"
-    then
-      freetype_cflags=`${freetype_config} --cflags`
+
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+       if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+       _pkg_min_version=0.9.0
+       { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+       if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       else
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+               PKG_CONFIG=""
+       fi
+fi
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype2" >&5
+$as_echo_n "checking for freetype2... " >&6; }
+
+if test -n "$FT_CFLAGS"; then
+    pkg_cv_FT_CFLAGS="$FT_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"freetype2\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "freetype2") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_FT_CFLAGS=`$PKG_CONFIG --cflags "freetype2" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$FT_LIBS"; then
+    pkg_cv_FT_LIBS="$FT_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"freetype2\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "freetype2") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_FT_LIBS=`$PKG_CONFIG --libs "freetype2" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+               FT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "freetype2" 2>&1`
+        else
+               FT_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "freetype2" 2>&1`
+        fi
+       # Put the nasty error message in config.log where it belongs
+       echo "$FT_PKG_ERRORS" >&5
+
+       if test -n "$freetype_config"
+      then
+        freetype_cflags=`${freetype_config} --cflags`
+        freeype_libs=`${freetype_config}  --libs`
+      fi
+elif test $pkg_failed = untried; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+       if test -n "$freetype_config"
+      then
+        freetype_cflags=`${freetype_config} --cflags`
+        freeype_libs=`${freetype_config}  --libs`
+      fi
+else
+       FT_CFLAGS=$pkg_cv_FT_CFLAGS
+       FT_LIBS=$pkg_cv_FT_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       freetype_cflags=$FT_CFLAGS; freeype_libs=$FT_LIBS
+fi
       # freetype-config --cflags may output values such as
       # -I/usr/local/include/freetype2 -I/usr/local/include
       # Take only the first -I option since non-Freetype include
@@ -26657,7 +26899,6 @@ fi
       # Freetype.  In the future we may need to do something different
       # if the FreeType library was to depend on some weird library
       # that we don't normally test for.
-      freeype_libs=`${freetype_config}  --libs`
       for flag in $freeype_libs
       do
         case $flag in
@@ -26680,7 +26921,6 @@ fi
             ;;
         esac
       done
-    fi
 
     as_ac_Lib=`$as_echo "ac_cv_lib_$LIB_TTF_BASE''_FT_Init_FreeType" | $as_tr_sh`
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FT_Init_FreeType in -l$LIB_TTF_BASE" >&5
@@ -26761,9 +27001,9 @@ fi
     fi
     if test "$have_freetype_h" = 'yes'
     then
-       passed=`expr $passed + 1`
+        passed=`expr $passed + 1`
     else
-       failed=`expr $failed + 1`
+        failed=`expr $failed + 1`
         CPPFLAGS="$OLD_CPPFLAGS"
     fi
 
 $as_echo_n "checking if FreeType package is complete... " >&6; }
     if test $passed -gt 0
     then
-       if test $failed -gt 0
-       then
+        if test $failed -gt 0
+        then
             LIB_TTF=''
-           { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
 $as_echo "no -- some components failed test" >&6; }
-           have_ttf='no (failed tests)'
-       else
-           LIBS="$LIB_TTF $LIBS"
+            have_ttf='no (failed tests)'
+        else
+            LIBS="$LIB_TTF $LIBS"
 
 $as_echo "#define HasTTF 1" >>confdefs.h
 
@@ -26788,12 +27028,12 @@ $as_echo "#define HasTTF 1" >>confdefs.h
 $as_echo "#define HAVE_FT2BUILD_H 1" >>confdefs.h
 
              fi
-           { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-           have_ttf='yes'
-       fi
+            have_ttf='yes'
+        fi
     else
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
     fi
 fi
@@ -26820,6 +27060,7 @@ $as_echo_n "checking for TIFF support ... " >&6; }
 $as_echo "" >&6; }
     failed=0
     passed=0
+    # PKG_CHECK_MODULES([TIFF], [libtiff-4], [], [])
     ac_fn_c_check_header_mongrel "$LINENO" "tiff.h" "ac_cv_header_tiff_h" "$ac_includes_default"
 if test "x$ac_cv_header_tiff_h" = xyes; then :
   passed=`expr $passed + 1`
@@ -27052,19 +27293,19 @@ $as_echo_n "checking if TIFF package is complete... " >&6; }
     then
         if test $failed -gt 0
         then
-           { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
 $as_echo "no -- some components failed test" >&6; }
-           have_tiff='no (failed tests)'
+            have_tiff='no (failed tests)'
         else
-           LIB_TIFF='-ltiff'
-           LIBS="$LIB_TIFF $LIBS"
+            LIB_TIFF='-ltiff'
+            LIBS="$LIB_TIFF $LIBS"
 
 $as_echo "#define HasTIFF 1" >>confdefs.h
 
-           { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-           have_tiff='yes'
-           for ac_header in tiffconf.h
+            have_tiff='yes'
+            for ac_header in tiffconf.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "tiffconf.h" "ac_cv_header_tiffconf_h" "$ac_includes_default"
 if test "x$ac_cv_header_tiffconf_h" = xyes; then :
@@ -27178,16 +27419,16 @@ $as_echo_n "checking if JBIG package is complete... " >&6; }
     then
     if test $failed -gt 0
     then
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
 $as_echo "no -- some components failed test" >&6; }
         have_jbig='no (failed tests)'
     else
-       LIB_JBIG='-ljbig'
-       LIBS="$LIB_JBIG $LIBS"
+        LIB_JBIG='-ljbig'
+        LIBS="$LIB_JBIG $LIBS"
 
 $as_echo "#define HasJBIG 1" >>confdefs.h
 
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
         have_jbig='yes'
     fi
@@ -27219,6 +27460,7 @@ $as_echo_n "checking for WEBP support ... " >&6; }
 $as_echo "" >&6; }
     failed=0
     passed=0
+    # PKG_CHECK_MODULES([WEBP], [libwebp], [], [])
     ac_fn_c_check_header_mongrel "$LINENO" "webp/decode.h" "ac_cv_header_webp_decode_h" "$ac_includes_default"
 if test "x$ac_cv_header_webp_decode_h" = xyes; then :
   passed=`expr $passed + 1`
@@ -27227,6 +27469,14 @@ else
 fi
 
 
+    ac_fn_c_check_header_mongrel "$LINENO" "webp/encode.h" "ac_cv_header_webp_encode_h" "$ac_includes_default"
+if test "x$ac_cv_header_webp_encode_h" = xyes; then :
+  passed=`expr $passed + 1`
+else
+  failed=`expr $failed + 1`
+fi
+
+
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for WebPDecodeRGB in -lwebp" >&5
 $as_echo_n "checking for WebPDecodeRGB in -lwebp... " >&6; }
 if ${ac_cv_lib_webp_WebPDecodeRGB+:} false; then :
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_webp_WebPDecodeRGB" >&5
 $as_echo "$ac_cv_lib_webp_WebPDecodeRGB" >&6; }
 if test "x$ac_cv_lib_webp_WebPDecodeRGB" = xyes; then :
-  passed=`expr $passed + 1`
+  passed=`expr $passed + 1`; LIB_WEBP='-lwebp'
 else
   failed=`expr $failed + 1`
 fi
 
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for WebPMuxSetImage in -lwebpmux" >&5
+$as_echo_n "checking for WebPMuxSetImage in -lwebpmux... " >&6; }
+if ${ac_cv_lib_webpmux_WebPMuxSetImage+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lwebpmux -lwebp $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char WebPMuxSetImage ();
+int
+main ()
+{
+return WebPMuxSetImage ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_webpmux_WebPMuxSetImage=yes
+else
+  ac_cv_lib_webpmux_WebPMuxSetImage=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_webpmux_WebPMuxSetImage" >&5
+$as_echo "$ac_cv_lib_webpmux_WebPMuxSetImage" >&6; }
+if test "x$ac_cv_lib_webpmux_WebPMuxSetImage" = xyes; then :
+  LIB_WEBP="$LIB_WEBP -lwebpmux"
+fi
+
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking if WEBP package is complete" >&5
 $as_echo_n "checking if WEBP package is complete... " >&6; }
     if test $passed -gt 0
     then
-    if test $failed -gt 0
-    then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+        if test $failed -gt 0
+        then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
 $as_echo "no -- some components failed test" >&6; }
-        have_webp='no (failed tests)'
-    else
-  LIB_WEBP='-lwebp'
-  LIBS="$LIB_WEBP $LIBS"
+            have_webp='no (failed tests)'
+        else
+            LIBS="$LIB_WEBP $LIBS"
 
 $as_echo "#define HasWEBP 1" >>confdefs.h
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-        have_webp='yes'
-    fi
+            have_webp='yes'
+        fi
     else
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
@@ -27319,6 +27608,8 @@ $as_echo_n "checking for XML support ... " >&6; }
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
 $as_echo "" >&6; }
     xml2_config=''
+    xml2_cflags=''
+    xml2_libs=''
     # Extract the first word of "xml2-config", so it can be a program name with args.
 set dummy xml2-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -27358,17 +27649,106 @@ else
 $as_echo "no" >&6; }
 fi
 
-    if test -n "$xml2_config"
-    then
-        # Sample output from xml2-config --cflags:
-        # -I/usr/include/libxml2
-        # -I/usr/local/include/libxml2 -I/usr/local/include
-        xml2_cflags=`"$xml2_config" --cflags`
-        for flag in $xml2_cflags
-        do
-            case $flag in
-                -I*)
-                    # Add flag to CPPFLAGS if not already present
+
+pkg_failed=no
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libxml-2.0" >&5
+$as_echo_n "checking for libxml-2.0... " >&6; }
+
+if test -n "$XML_CFLAGS"; then
+    pkg_cv_XML_CFLAGS="$XML_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libxml-2.0\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libxml-2.0") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_XML_CFLAGS=`$PKG_CONFIG --cflags "libxml-2.0" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+if test -n "$XML_LIBS"; then
+    pkg_cv_XML_LIBS="$XML_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+    if test -n "$PKG_CONFIG" && \
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libxml-2.0\""; } >&5
+  ($PKG_CONFIG --exists --print-errors "libxml-2.0") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  pkg_cv_XML_LIBS=`$PKG_CONFIG --libs "libxml-2.0" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes
+else
+  pkg_failed=yes
+fi
+ else
+    pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi
+        if test $_pkg_short_errors_supported = yes; then
+               XML_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libxml-2.0" 2>&1`
+        else
+               XML_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libxml-2.0" 2>&1`
+        fi
+       # Put the nasty error message in config.log where it belongs
+       echo "$XML_PKG_ERRORS" >&5
+
+       if test -n "$xml2_config"
+       then
+          # Sample output from xml2-config --cflags:
+          # -I/usr/include/libxml2
+          # -I/usr/local/include/libxml2 -I/usr/local/include
+          xml2_cflags=`"$xml2_config" --cflags`
+          # Sample output from xml2-config --libs:
+          # -lxml2
+          # -L/usr/lib -R/usr/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl
+          #-L/usr/local/lib -lxml2 -lz -L/usr/local/lib -liconv -lm
+          xml2_libs=`$xml2_config  --libs`
+       fi
+
+elif test $pkg_failed = untried; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+       if test -n "$xml2_config"
+       then
+          # Sample output from xml2-config --cflags:
+          # -I/usr/include/libxml2
+          # -I/usr/local/include/libxml2 -I/usr/local/include
+          xml2_cflags=`"$xml2_config" --cflags`
+          # Sample output from xml2-config --libs:
+          # -lxml2
+          # -L/usr/lib -R/usr/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl
+          #-L/usr/local/lib -lxml2 -lz -L/usr/local/lib -liconv -lm
+          xml2_libs=`$xml2_config  --libs`
+       fi
+
+else
+       XML_CFLAGS=$pkg_cv_XML_CFLAGS
+       XML_LIBS=$pkg_cv_XML_LIBS
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       xml2_cflags=$XML_CFLAGS; xml2_libs=$XML_LIBS
+fi
+      for flag in $xml2_cflags
+      do
+        case $flag in
+             -I*)
+                # Add flag to CPPFLAGS if not already present
                     add=yes;
                     for test_flag in $CPPFLAGS
                     do
                     ;;
                 *)
                     ;;
-            esac
-        done
-        # Sample output from xml2-config --libs:
-        # -lxml2
-        # -L/usr/lib -R/usr/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl
-        #-L/usr/local/lib -lxml2 -lz -L/usr/local/lib -liconv -lm
-        xml2_libs=`$xml2_config  --libs`
-        for flag in $xml2_libs
-        do
+        esac
+      done
+      for flag in $xml2_libs
+      do
             case $flag in
                 -L*)
                     # Add flag to LDFLAGS if not already present
@@ -27416,9 +27791,9 @@ fi
                 *)
                     ;;
             esac
-        done
-        for flag in $xml2_libs
-        do
+      done
+      for flag in $xml2_libs
+      do
             case $flag in
                 -l*)
                     # The first library listed is assumed to be the
@@ -27434,8 +27809,7 @@ fi
                 *)
                     ;;
             esac
-        done
-    fi
+      done
     if test "x$LIB_XML2_BASE" = "x"
     then
         LIB_XML2_BASE=xml2
@@ -27593,13 +27967,13 @@ $as_echo_n "checking if XML package is complete ... " >&6; }
     then
     if test $failed -gt 0
     then
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
 $as_echo "no -- some components failed test" >&6; }
         have_xml='no (failed tests)'
         LDFLAGS="$OLD_LDFLAGS"
         CPPFLAGS="$OLD_CPPFLAGS"
     else
-       LIB_XML="-l$LIB_XML2_BASE"
+        LIB_XML="-l$LIB_XML2_BASE"
         # Add lib to LIBS if not already present
         for test_lib in $LIB_XML $LIB_XML_DEPS
         do
@@ -27620,7 +27994,7 @@ $as_echo "no -- some components failed test" >&6; }
 
 $as_echo "#define HasXML 1" >>confdefs.h
 
-       { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
         have_xml='yes'
     fi
@@ -27723,7 +28097,7 @@ $as_echo "#define HasWMFlite 1" >>confdefs.h
             LIBS="$LIB_WMF $LIBS"
             have_wmf='yes'
         else
-           { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- some components failed test" >&5
 $as_echo "no -- some components failed test" >&6; }
             have_wmf='no (failed tests)'
             have_wmflite='no (failed tests)'
@@ -29369,7 +29743,7 @@ if test "$with_perl" != 'no'
 then
     if test "$with_perl" != 'yes'
     then
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl" >&5
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for perl" >&5
 $as_echo_n "checking for perl... " >&6; }
 if ${ac_cv_path_PERL+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -29378,10 +29752,10 @@ else
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_PERL" >&5
 $as_echo "$ac_cv_path_PERL" >&6; };
-       PERL=$ac_cv_path_PERL
-               have_perl="$ac_cv_path_PERL"
+        PERL=$ac_cv_path_PERL
+                have_perl="$ac_cv_path_PERL"
     else
-       for ac_prog in perl perl5
+        for ac_prog in perl perl5
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -29425,9 +29799,9 @@ fi
 
   test -n "$PERL" && break
 done
-       if test "$ac_cv_path_PERL"
+        if test "$ac_cv_path_PERL"
         then
-         have_perl="$ac_cv_path_PERL"
+          have_perl="$ac_cv_path_PERL"
         fi
     fi
 fi
 
 # The build_modules variable is set to 'yes' if coders and filters are
 # to be built as modules.  This requires libltdl ($LIB_LTDL).
+# Removed $LIB_OMP and $LIB_THREAD
 
 if test "$build_modules" != 'no'
 then
-  MAGICK_DEP_LIBS="$LIBS_USER $LIB_LCMS $LIB_TTF $LIB_GS $LIB_XEXT $LIB_IPC $LIB_X11 $LIB_LZMA $LIB_BZLIB $LIB_ZLIB $LIB_LTDL $LIB_TRIO $LIB_GDI32 $LIB_MATH $LIB_OMP $LIB_UMEM $LIB_THREAD"
+  MAGICK_DEP_LIBS="$LIBS_USER $LIB_LCMS $LIB_TTF $LIB_GS $LIB_XEXT $LIB_IPC $LIB_X11 $LIB_LZMA $LIB_BZLIB $LIB_ZLIB $LIB_LTDL $LIB_TRIO $LIB_GDI32 $LIB_MATH $LIB_UMEM $LIB_THREAD"
 else
-  MAGICK_DEP_LIBS="$LIBS_USER $LIB_JBIG $LIB_WEBP $LIB_LCMS $LIB_TIFF $LIB_TTF $LIB_JP2 $LIB_JPEG $LIB_GS $LIB_PNG $LIB_FPX $LIB_WMF $LIB_DPS $LIB_XEXT $LIB_IPC $LIB_X11 $LIB_LZMA $LIB_BZLIB $LIB_XML $LIB_ZLIB $LIB_TRIO $LIB_GDI32 $LIB_MATH $LIB_OMP $LIB_UMEM $LIB_THREAD"
+  MAGICK_DEP_LIBS="$LIBS_USER $LIB_JBIG $LIB_WEBP $LIB_LCMS $LIB_TIFF $LIB_TTF $LIB_JP2 $LIB_JPEG $LIB_GS $LIB_PNG $LIB_FPX $LIB_WMF $LIB_DPS $LIB_XEXT $LIB_IPC $LIB_X11 $LIB_LZMA $LIB_BZLIB $LIB_XML $LIB_ZLIB $LIB_ZSTD $LIB_TRIO $LIB_GDI32 $LIB_MATH $LIB_UMEM $LIB_THREAD"
 fi
+MAGICK_EXTRA_DEP_LIBS="$LIB_OMP" # Extra libraries typically added due to CFLAGS
+
 
 
 #
@@ -29736,13 +30113,14 @@ CXXFLAGS=`echo $CXXFLAGS | sed -e 's/  */ /g'`
 LDFLAGS=`echo $LDFLAGS | sed -e 's/  */ /g'`
 TESTED_LIBS=`echo $LIBS | sed -e 's/  */ /g'`
 MAGICK_DEP_LIBS=`echo $MAGICK_DEP_LIBS | sed -e 's/  */ /g'`
+MAGICK_EXTRA_DEP_LIBS=`echo $MAGICK_EXTRA_DEP_LIBS | sed -e 's/  */ /g'`
 #LIBS=`echo $LIBS | sed -e 's/  */ /g'`
 
 MAGICK_API_CFLAGS=$CFLAGS
 MAGICK_API_CPPFLAGS=`echo $MAGICK_API_CPPFLAGS | sed -e 's/  */ /g'`
 MAGICK_API_LDFLAGS="-L$LIB_DIR $LDFLAGS"
 MAGICK_API_DEP_LIBS="$MAGICK_DEP_LIBS"
-MAGICK_API_LIBS="-lGraphicsMagick $MAGICK_API_DEP_LIBS"
+MAGICK_API_LIBS="-lGraphicsMagick $MAGICK_API_DEP_LIBS $MAGICK_EXTRA_DEP_LIBS"
 
 MAGICK_API_DEP_LIBS=`echo $MAGICK_API_DEP_LIBS | sed -e 's/  */ /g'`
 MAGICK_API_LIBS=`echo $MAGICK_API_LIBS | sed -e 's/  */ /g'`
@@ -30030,6 +30408,10 @@ if test -z "${HasLZMA_TRUE}" && test -z "${HasLZMA_FALSE}"; then
   as_fn_error $? "conditional \"HasLZMA\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${HasZSTD_TRUE}" && test -z "${HasZSTD_FALSE}"; then
+  as_fn_error $? "conditional \"HasZSTD\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${HasX11_TRUE}" && test -z "${HasX11_FALSE}"; then
   as_fn_error $? "conditional \"HasX11\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -30058,10 +30440,6 @@ if test -z "${HasJP2_TRUE}" && test -z "${HasJP2_FALSE}"; then
   as_fn_error $? "conditional \"HasJP2\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
-if test -z "${HasGS_TRUE}" && test -z "${HasGS_FALSE}"; then
-  as_fn_error $? "conditional \"HasGS\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
 if test -z "${HasTTF_TRUE}" && test -z "${HasTTF_FALSE}"; then
   as_fn_error $? "conditional \"HasTTF\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 
 rm -f magick-version
 
-echo ""
-
-echo "GraphicsMagick is configured as follows. Please verify that this"
-echo "configuration matches your expectations."
-echo ""
-echo "Host system type : $host"
-echo "Build system type : $build"
-echo ""
-echo "Option            Configure option               Configured value"
-echo "-----------------------------------------------------------------"
-echo "Shared libraries  --enable-shared=$enable_shared         $libtool_build_shared_libs"
-echo "Static libraries  --enable-static=$enable_static         $libtool_build_static_libs"
-echo "GNU ld            --with-gnu-ld=$with_gnu_ld             $lt_cv_prog_gnu_ld"
-echo "Quantum depth     --with-quantum-depth=$with_quantum_depth       $with_quantum_depth"
-echo "Modules           --with-modules=$with_modules           $build_modules"
-echo ""
-echo "Delegate Configuration:"
-echo "BZLIB             --with-bzlib=$with_bzlib               $have_bzlib"
-echo "DPS               --with-dps=$with_dps                   $have_dps"
-echo "FlashPIX          --with-fpx=$with_fpx                   $have_fpx"
-echo "FreeType 2.0      --with-ttf=$with_ttf           $have_ttf"
-echo "Ghostscript       None                           $PSDelegate ($GSVersion)"
+printf "\n"
+
+printf "GraphicsMagick is configured as follows. Please verify that this\n"
+printf "configuration matches your expectations.\n"
+printf "\n"
+printf "Host system type : $host\n"
+printf "Build system type : $build\n"
+printf "\n"
+printf "Option            Configure option      \tConfigured value\n"
+printf -- "-----------------------------------------------------------------\n"
+printf "Shared libraries  --enable-shared=$enable_shared\t\t$libtool_build_shared_libs\n"
+printf "Static libraries  --enable-static=$enable_static\t\t$libtool_build_static_libs\n"
+printf "GNU ld            --with-gnu-ld=$with_gnu_ld    \t\t$lt_cv_prog_gnu_ld\n"
+printf "Quantum depth     --with-quantum-depth=$with_quantum_depth\t$with_quantum_depth\n"
+printf "Modules           --with-modules=$with_modules  \t\t$build_modules\n"
+printf "\n"
+printf "Delegate Configuration:\n"
+printf "BZLIB             --with-bzlib=$with_bzlib         \t$have_bzlib\n"
+printf "DPS               --with-dps=$with_dps          \t$have_dps\n"
+printf "FlashPIX          --with-fpx=$with_fpx          \t$have_fpx\n"
+printf "FreeType 2.0      --with-ttf=$with_ttf          \t$have_ttf\n"
+printf "Ghostscript       None                  \t$PSDelegate ($GSVersion)\n"
 result_ghostscript_font_dir='none'
 if test "${ghostscript_font_dir}x" != 'x'
 then
   result_ghostscript_font_dir="$ghostscript_font_dir"
 fi
-echo "Ghostscript fonts --with-gs-font-dir=$with_gs_font_dir    $result_ghostscript_font_dir"
-echo "Ghostscript lib   --with-gslib=$with_gslib               $have_gslib"
-echo "JBIG              --with-jbig=$with_jbig         $have_jbig"
-echo "JPEG v1           --with-jpeg=$with_jpeg         $have_jpeg"
-echo "JPEG-2000         --with-jp2=$with_jp2           $have_jp2"
-echo "LCMS v2           --with-lcms2=$with_lcms2               $have_lcms2"
-# echo "MPEG v2           --with-mpeg2=$with_mpeg2             $have_mpeg2"
-echo "LZMA              --with-lzma=$with_lzma         $have_lzma"
-echo "Magick++          --with-magick-plus-plus=$with_magick_plus_plus         $have_magick_plus_plus"
-echo "PERL              --with-perl=$with_perl                 $have_perl"
+printf "Ghostscript fonts --with-gs-font-dir=$with_gs_font_dir\t$result_ghostscript_font_dir\n"
+printf "JBIG              --with-jbig=$with_jbig        \t$have_jbig\n"
+printf "JPEG v1           --with-jpeg=$with_jpeg        \t$have_jpeg\n"
+printf "JPEG-2000         --with-jp2=$with_jp2          \t$have_jp2\n"
+printf "LCMS v2           --with-lcms2=$with_lcms2        \t$have_lcms2\n"
+# printf "MPEG v2           --with-mpeg2=$with_mpeg2    \t$have_mpeg2\n"
+printf "LZMA              --with-lzma=$with_lzma        \t$have_lzma\n"
+printf "Magick++          --with-magick-plus-plus=$with_magick_plus_plus\t$have_magick_plus_plus\n"
+printf "PERL              --with-perl=$with_perl        \t$have_perl\n"
 if test "${LIB_PNG}x" != 'x'
 then
-echo "PNG               --with-png=$with_png           $have_png ($LIB_PNG)"
+printf "PNG               --with-png=$with_png          \t$have_png ($LIB_PNG)\n"
 else
-echo "PNG               --with-png=$with_png           $have_png"
+printf "PNG               --with-png=$with_png          \t$have_png\n"
 fi
-echo "TIFF              --with-tiff=$with_tiff         $have_tiff"
-echo "TRIO              --with-trio=$with_trio         $have_trio"
-echo "WEBP              --with-webp=$with_webp         $have_webp"
+printf "TIFF              --with-tiff=$with_tiff        \t$have_tiff\n"
+printf "TRIO              --with-trio=$with_trio        \t$have_trio\n"
+printf "WEBP              --with-webp=$with_webp        \t$have_webp\n"
 result_windows_font_dir='none'
 if test "${windows_font_dir}x" != 'x'
 then
   result_windows_font_dir="${windows_font_dir}"
 fi
-echo "Windows fonts     --with-windows-font-dir=$with_windows_font_dir $result_windows_font_dir"
-echo "WMF               --with-wmf=$with_wmf           $have_wmf"
-echo "X11               --with-x=$with_x               $have_x"
-echo "XML               --with-xml=$with_xml           $have_xml"
-echo "ZLIB              --with-zlib=$with_zlib         $have_zlib"
-echo ""
-echo "X11 Configuration:"
+printf "Windows fonts     --with-windows-font-dir=$with_windows_font_dir\t$result_windows_font_dir\n"
+printf "WMF               --with-wmf=$with_wmf          \t$have_wmf\n"
+printf "X11               --with-x=$with_x              \t$have_x\n"
+printf "XML               --with-xml=$with_xml          \t$have_xml\n"
+printf "ZLIB              --with-zlib=$with_zlib        \t$have_zlib\n"
+printf "\n"
+printf "X11 Configuration:\n"
 if test "$have_x" != 'no'
 then
-  echo "  X_CFLAGS     = $X_CFLAGS"
-  echo "  X_PRE_LIBS   = $X_PRE_LIBS"
-  echo "  X_LIBS       = $X_LIBS"
-  echo "  X_EXTRA_LIBS = $X_EXTRA_LIBS"
-else
-  echo ""
-  echo "  Not using X11."
-fi
-echo ""
-echo "Options used to compile and link:"
-echo "  CC       = $CC"
-echo "  CFLAGS   = $CFLAGS"
-echo "  CPPFLAGS = $CPPFLAGS"
-echo "  CXX      = $CXX"
-echo "  CXXFLAGS = $CXXFLAGS"
-echo "  DEFS     = $DEFS"
-echo "  LDFLAGS  = $LDFLAGS"
-echo "  LIBS     = $MAGICK_API_DEP_LIBS"
-echo ""
+  printf "  X_CFLAGS     = $X_CFLAGS\n"
+  printf "  X_PRE_LIBS   = $X_PRE_LIBS\n"
+  printf "  X_LIBS       = $X_LIBS\n"
+  printf "  X_EXTRA_LIBS = $X_EXTRA_LIBS\n"
+else
+  printf "\n"
+  printf "  Not using X11.\n"
+fi
+printf "\n"
+printf "Options used to compile and link:\n"
+printf "  CC       = $CC\n"
+printf "  CFLAGS   = $CFLAGS\n"
+printf "  CPPFLAGS = $CPPFLAGS\n"
+printf "  CXX      = $CXX\n"
+printf "  CXXFLAGS = $CXXFLAGS\n"
+printf "  DEFS     = $DEFS\n"
+printf "  LDFLAGS  = $LDFLAGS\n"
+printf "  LIBS     = $MAGICK_API_DEP_LIBS\n"
+printf "\n"
index 4bb086c..77d042c 100755 (executable)
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2016 GraphicsMagick Group
+# Copyright (C) 2003-2018 GraphicsMagick Group
 # Copyright (C) 2002 ImageMagick Studio
 # Copyright (C) 1998, 1999 E. I. du Pont de Nemours and Company
 #
@@ -10,7 +10,7 @@
 #
 # Written by Bob Friesenhahn <bfriesen@GraphicsMagick.org>
 #
+
 AC_PREREQ(2.69)
 AC_INIT(magick/magick.h)
 
@@ -302,10 +302,10 @@ fi
 #
 # Enable support for POSIX thread APIs
 AC_ARG_WITH(threads,
-             AS_HELP_STRING([--without-threads],
+              AS_HELP_STRING([--without-threads],
                              [disable POSIX threads API support]),
-             [with_threads=$withval],
-             [with_threads='yes'])
+              [with_threads=$withval],
+              [with_threads='yes'])
 
 have_threads=no
 if test "$with_threads" != 'no'
@@ -347,11 +347,11 @@ AC_SUBST(OPENMP_CFLAGS)
 
 # Allow the user to disable use of OpenMP where algorithms sometimes run slower.
 AC_ARG_ENABLE(openmp-slow,
-             AS_HELP_STRING([--enable-openmp-slow],
+              AS_HELP_STRING([--enable-openmp-slow],
                              [enable OpenMP for algorithms which
                              sometimes run slower]),
-             [with_openmp_slow=$enableval],
-             [with_openmp_slow='no'])
+              [with_openmp_slow=$enableval],
+              [with_openmp_slow='no'])
 if test "$with_openmp_slow" = 'no'
 then
   AC_DEFINE(DisableSlowOpenMP,1,[Disable OpenMP for algorithms which sometimes run slower])
@@ -365,7 +365,7 @@ fi
 # remaps standard functions to their 64-bit equivalents.
 #
 # The LFS_CPPFLAGS substition is used to support building PerlMagick.
-# 
+#
 #
 ########
 AC_SYS_LARGEFILE
@@ -393,6 +393,19 @@ fi
 AC_SUBST(LFS_CPPFLAGS)
 
 #
+# Decide if setjmp/longjmp is thread safe based on host OS
+#
+case "${host_os}" in
+  solaris2* )
+    # Documented not to be MT safe
+
+    ;;
+  *)
+    AC_DEFINE(SETJMP_IS_THREAD_SAFE,1,[Setjmp/longjmp are thread safe])
+    ;;
+esac
+
+#
 # Configure libtool
 #
 
@@ -423,11 +436,11 @@ AM_CONDITIONAL(WITH_SHARED_LIBS, test "${libtool_build_shared_libs}" = 'yes')
 #
 build_modules='no'
 AC_ARG_WITH(modules,
-             AS_HELP_STRING([--with-modules],
+              AS_HELP_STRING([--with-modules],
                              [enable building dynamically loadable
                              modules]),
-             [with_modules=$withval],
-             [with_modules='no'])
+              [with_modules=$withval],
+              [with_modules='no'])
 
 # Only allow building loadable modules if we are building shared libraries
 if test "$with_modules" != 'no' ; then
@@ -447,10 +460,10 @@ AM_CONDITIONAL(WITH_MODULES, test "$build_modules" != 'no')
 # Build a version of GraphicsMagick which operates uninstalled.
 # Used to build distributions located via MAGICK_HOME / executable path
 AC_ARG_ENABLE(installed,
-             AS_HELP_STRING([--disable-installed],
+              AS_HELP_STRING([--disable-installed],
                              [disable building an installed GraphicsMagick]),
-             [with_installed=$enableval],
-             [with_installed='yes'])
+              [with_installed=$enableval],
+              [with_installed='yes'])
 if test "$with_installed" = 'yes'
 then
   AC_DEFINE(UseInstalledMagick,1,[GraphicsMagick is formally installed under prefix])
@@ -461,10 +474,10 @@ fi
 # Enable broken/dangerous coders
 # EnableBrokenCoders CPP define and ENABLE_BROKEN_CODERS Automake conditional)
 AC_ARG_ENABLE(broken-coders,
-             AS_HELP_STRING([--enable-broken-coders],
+              AS_HELP_STRING([--enable-broken-coders],
                              [enable broken/dangerous file formats support]),
-             [with_broken_coders=$enableval],
-             [with_broken_coders='no'])
+              [with_broken_coders=$enableval],
+              [with_broken_coders='no'])
 if test "$with_broken_coders" = 'yes'
 then
   AC_DEFINE(EnableBrokenCoders,1,[Enable broken/dangerous file formats support])
@@ -478,24 +491,24 @@ AM_MAINTAINER_MODE
 
 # Enable prof-based profiling support
 AC_ARG_ENABLE(prof,
-             AS_HELP_STRING([--enable-prof],
+              AS_HELP_STRING([--enable-prof],
                              [enable 'prof' profiling support]),
-             [with_prof=$enableval],
-             [with_prof='no'])
+              [with_prof=$enableval],
+              [with_prof='no'])
 
 # Enable gprof-based profiling support
 AC_ARG_ENABLE(gprof,
-             AS_HELP_STRING([--enable-gprof],
+              AS_HELP_STRING([--enable-gprof],
                              [enable 'gprof' profiling support]),
-             [with_gprof=$enableval],
-             [with_gprof='no'])
+              [with_gprof=$enableval],
+              [with_gprof='no'])
 
 # Enable gcov-based profiling support
 AC_ARG_ENABLE(gcov,
-             AS_HELP_STRING([--enable-gcov],
+              AS_HELP_STRING([--enable-gcov],
                              [enable 'gcov' profiling support]),
-             [with_gcov=$enableval],
-             [with_gcov='no'])
+              [with_gcov=$enableval],
+              [with_gcov='no'])
 
 with_profiling='no'
 if test "$with_prof" = 'yes' || test "$with_gprof" = 'yes' || test "$with_gcov" = 'yes'
@@ -510,10 +523,10 @@ fi
 
 # Enable prefixing library symbols with a common string
 AC_ARG_ENABLE(symbol-prefix,
-             AS_HELP_STRING([--enable-symbol-prefix],
+              AS_HELP_STRING([--enable-symbol-prefix],
                              [enable prefixing library symbols with "Gm"]),
-             [with_symbol_prefix=$enableval],
-             [with_symbol_prefix='no'])
+              [with_symbol_prefix=$enableval],
+              [with_symbol_prefix='no'])
 if test "$with_symbol_prefix" != 'no'
 then
   AC_DEFINE(PREFIX_MAGICK_SYMBOLS,1,[Prefix Magick library symbols with a common string.])
@@ -530,10 +543,10 @@ AM_CONDITIONAL(MAGICK_COMPAT, test "$with_magick_compat" != 'no')
 
 # Number of bits in a Quantum
 AC_ARG_WITH(quantum-depth,
-             AS_HELP_STRING([--with-quantum-depth],
+              AS_HELP_STRING([--with-quantum-depth],
                              [number of bits in a pixel quantum (default 8)]),
-             [with_quantum_depth=$withval],
-             [with_quantum_depth=8])
+              [with_quantum_depth=$withval],
+              [with_quantum_depth=8])
 if test "$with_quantum_depth" != '8' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-quantum-depth=$with_quantum_depth "
 fi
@@ -574,17 +587,17 @@ AC_ARG_WITH(frozenpaths,
 
 # Enable build/install of Magick++
 AC_ARG_WITH(magick-plus-plus,
-             AS_HELP_STRING([--without-magick-plus-plus],
+              AS_HELP_STRING([--without-magick-plus-plus],
                              [disable build/install of Magick++]),
-             [with_magick_plus_plus=$withval],
-             [with_magick_plus_plus='yes'])
+              [with_magick_plus_plus=$withval],
+              [with_magick_plus_plus='yes'])
 
 # Enable build/install of PerlMagick.
 AC_ARG_WITH(perl,
-             AS_HELP_STRING([--with-perl@<:@=PERL@:>@],
+              AS_HELP_STRING([--with-perl@<:@=PERL@:>@],
                              [enable build/install of PerlMagick and optionally specify perl to use]),
-             [with_perl=$withval],
-             [with_perl='no'])
+              [with_perl=$withval],
+              [with_perl='no'])
 
 # Options to pass when configuring PerlMagick
 AC_ARG_WITH(perl-options,
@@ -597,50 +610,40 @@ AC_SUBST(PERL_MAKE_OPTIONS)
 
 # Disable BZLIB (bzip2 library)
 AC_ARG_WITH(bzlib,
-             AS_HELP_STRING([--without-bzlib],
+              AS_HELP_STRING([--without-bzlib],
                              [disable BZLIB support]),
-             [with_bzlib=$withval],
-             [with_bzlib='yes'])
+              [with_bzlib=$withval],
+              [with_bzlib='yes'])
 if test "$with_bzlib" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-bzlib=$with_bzlib "
 fi
 
 # Disable Display Postscript.
 AC_ARG_WITH(dps,
-             AS_HELP_STRING([--without-dps],
+              AS_HELP_STRING([--without-dps],
                              [disable Display Postscript support]),
-             [with_dps=$withval],
-             [with_dps='yes'])
+              [with_dps=$withval],
+              [with_dps='yes'])
 if test "$with_dps" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-dps=$with_dps "
 fi
 
 # Enable FlashPIX.
 AC_ARG_WITH(fpx,
-             AS_HELP_STRING([--with-fpx],
+              AS_HELP_STRING([--with-fpx],
                              [enable FlashPIX support]),
-             [with_fpx=$withval],
-             [with_fpx='no'])
+              [with_fpx=$withval],
+              [with_fpx='no'])
 if test "$with_fpx" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-fpx=$with_fpx "
 fi
 
-# Enable Ghostscript library support.
-AC_ARG_WITH(gslib,
-             AS_HELP_STRING([--with-gslib],
-                             [enable Ghostscript library support (not recommended)]),
-             [with_gslib=$withval],
-             [with_gslib='no'])
-if test "$with_gslib" != 'yes' ; then
-    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-gslib=$with_gslib "
-fi
-
 # Disable JBIG.
 AC_ARG_WITH(jbig,
-             AS_HELP_STRING([--without-jbig],
+              AS_HELP_STRING([--without-jbig],
                              [disable JBIG support]),
-             [with_jbig=$withval],
-             [with_jbig='yes'])
+              [with_jbig=$withval],
+              [with_jbig='yes'])
 if test "$with_jbig" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-jbig=$with_jbig "
 fi
@@ -657,87 +660,87 @@ fi
 
 # Disable JPEG.
 AC_ARG_WITH(jpeg,
-             AS_HELP_STRING([--without-jpeg],
+              AS_HELP_STRING([--without-jpeg],
                              [disable JPEG support]),
-             [with_jpeg=$withval],
-             [with_jpeg='yes'])
+              [with_jpeg=$withval],
+              [with_jpeg='yes'])
 if test "$with_jpeg" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-jpeg=$with_jpeg "
 fi
 
 # Disable JPEG Version 2.
 AC_ARG_WITH(jp2,
-             AS_HELP_STRING([--without-jp2],
+              AS_HELP_STRING([--without-jp2],
                              [disable JPEG v2 support]),
-             [with_jp2=$withval],
-             [with_jp2='yes'])
+              [with_jp2=$withval],
+              [with_jp2='yes'])
 if test "$with_jp2" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-jp2=$with_jp2 "
 fi
 
 # Disable LCMS2.
 AC_ARG_WITH(lcms2,
-             AS_HELP_STRING([--without-lcms2],
+              AS_HELP_STRING([--without-lcms2],
                              [disable lcms (v2.X) support]),
-             [with_lcms2=$withval],
-             [with_lcms2='yes'])
+              [with_lcms2=$withval],
+              [with_lcms2='yes'])
 if test "$with_lcms2" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-lcms2=$with_lcms2 "
 fi
 
 # Disable LZMA (lzma library)
 AC_ARG_WITH(lzma,
-             AS_HELP_STRING([--without-lzma],
+              AS_HELP_STRING([--without-lzma],
                              [disable LZMA support]),
-             [with_lzma=$withval],
-             [with_lzma='yes'])
+              [with_lzma=$withval],
+              [with_lzma='yes'])
 if test "$with_lzma" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-lzma=$with_lzma "
 fi
 
 # # Disable MPEG.
 # AC_ARG_WITH(mpeg2,
-#            AS_HELP_STRING([--without-mpeg2],
+#             AS_HELP_STRING([--without-mpeg2],
 #                            [disable MPEG support]),
-#            [with_mpeg2=$withval],
-#            [with_mpeg2='yes'])
+#             [with_mpeg2=$withval],
+#             [with_mpeg2='yes'])
 
 # Disable PNG.
 AC_ARG_WITH(png,
-             AS_HELP_STRING([--without-png],
+              AS_HELP_STRING([--without-png],
                              [disable PNG support]),
-             [with_png=$withval],
-             [with_png='yes'])
+              [with_png=$withval],
+              [with_png='yes'])
 if test "$with_png" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-png=$with_png "
 fi
 
 # Disable TIFF.
 AC_ARG_WITH(tiff,
-             AS_HELP_STRING([--without-tiff],
+              AS_HELP_STRING([--without-tiff],
                              [disable TIFF support]),
-             [with_tiff=$withval],
-             [with_tiff='yes'])
+              [with_tiff=$withval],
+              [with_tiff='yes'])
 if test "$with_tiff" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-tiff=$with_tiff "
 fi
 
 # Disable TRIO.
 AC_ARG_WITH(trio,
-             AS_HELP_STRING([--without-trio],
+              AS_HELP_STRING([--without-trio],
                              [disable TRIO support]),
-             [with_trio=$withval],
-             [with_trio='yes'])
+              [with_trio=$withval],
+              [with_trio='yes'])
 if test "$with_trio" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-trio=$with_trio "
 fi
 
 # Disable TTF.
 AC_ARG_WITH(ttf,
-             AS_HELP_STRING([--without-ttf],
+              AS_HELP_STRING([--without-ttf],
                              [disable TrueType support]),
-             [with_ttf=$withval],
-             [with_ttf='yes'])
+              [with_ttf=$withval],
+              [with_ttf='yes'])
 if test "$with_ttf" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-ttf=$with_ttf "
 fi
@@ -746,20 +749,20 @@ fi
 # Available as a SourceForge project http://sourceforge.net/projects/umem/ or
 # https://labs.omniti.com/trac/portableumem/.
 AC_ARG_WITH(umem,
-             AS_HELP_STRING([--with-umem],
+              AS_HELP_STRING([--with-umem],
                              [enable umem memory allocation library support]),
-             [with_umem=$withval],
-             [with_umem='no'])
+              [with_umem=$withval],
+              [with_umem='no'])
 if test "$with_umem" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-umem=$with_umem "
 fi
 
 # Disable WMF.
 AC_ARG_WITH(wmf,
-             AS_HELP_STRING([--without-wmf],
+              AS_HELP_STRING([--without-wmf],
                              [disable WMF support]),
-             [with_wmf=$withval],
-             [with_wmf='yes'])
+              [with_wmf=$withval],
+              [with_wmf='yes'])
 if test "$with_wmf" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-wmf=$with_wmf "
 fi
@@ -782,30 +785,30 @@ fi
 
 # Set Ghostscript font directory
 AC_ARG_WITH(gs-font-dir,
-             AS_HELP_STRING([--with-gs-font-dir=DIR],
+              AS_HELP_STRING([--with-gs-font-dir=DIR],
                              [directory containing Ghostscript fonts]),
-             [with_gs_font_dir=$withval],
-             [with_gs_font_dir='default'])
+              [with_gs_font_dir=$withval],
+              [with_gs_font_dir='default'])
 if test "$with_gs_font_dir" != 'default' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-gs-font-dir=$with_gs_font_dir "
 fi
 
 # Set Windows font directory
 AC_ARG_WITH(windows-font-dir,
-             AS_HELP_STRING([--with-windows-font-dir=DIR],
+              AS_HELP_STRING([--with-windows-font-dir=DIR],
                              [directory containing MS-Windows fonts]),
-             [with_windows_font_dir=$withval],
-             [with_windows_font_dir=''])
+              [with_windows_font_dir=$withval],
+              [with_windows_font_dir=''])
 if test "$with_windows_font_dir" != '' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-windows-font-dir=$with_windows_font_dir "
 fi
 
 # Disable XML.
 AC_ARG_WITH(xml,
-             AS_HELP_STRING([--without-xml],
+              AS_HELP_STRING([--without-xml],
                              [disable XML support]),
-             [with_xml=$withval],
-             [with_xml='yes'])
+              [with_xml=$withval],
+              [with_xml='yes'])
 if test "$with_xml" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-xml=$with_xml "
 fi
@@ -813,12 +816,22 @@ fi
 AC_ARG_WITH(zlib,
               AS_HELP_STRING([--without-zlib],
                              [disable ZLIB support]),
-             [with_zlib=$withval],
-             [with_zlib='yes'])
+              [with_zlib=$withval],
+              [with_zlib='yes'])
 if test "$with_zlib" != 'yes' ; then
     DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-zlib=$with_zlib "
 fi
 
+# Disable Zstd (zstd library)
+AC_ARG_WITH(zstd,
+              AS_HELP_STRING([--without-zstd],
+                             [disable Zstd support]),
+              [with_zstd=$withval],
+              [with_zstd='yes'])
+if test "$with_zstd" != 'yes' ; then
+    DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-zstd=$with_zstd "
+fi
+
 #
 # Specify path to shared libstdc++ if not in normal location
 #
@@ -842,7 +855,7 @@ AC_PROG_GCC_TRADITIONAL
 ########
 # These options are set for multi-thread DLL module build
 #  libMagick:           _DLL _MAGICKMOD_ _MAGICKLIB_
-#  module:              _DLL 
+#  module:              _DLL
 #  executable/Magick++: _DLL _MAGICKMOD_
 MODULE_EXTRA_CPPFLAGS=''
 LIBRARY_EXTRA_CPPFLAGS=''
@@ -882,7 +895,7 @@ AC_SUBST(LIBRARY_EXTRA_CPPFLAGS)
 AC_HEADER_STDC
 AC_HEADER_DIRENT
 
-# Check additional headers 
+# Check additional headers
 AC_CHECK_HEADERS([machine/param.h mach-o/dyld.h process.h sun_prefetch.h sys/mman.h sys/resource.h sys/times.h sys/types.h])
 AC_CHECK_HEADERS([wincrypt.h],[],[],[#include <windows.h>])
 
@@ -1325,7 +1338,7 @@ AC_CACHE_CHECK(for X11 configure files,gm_cv_x_configure,
 [# Look for the header file in a standard set of common directories.
 # Check X11 before X11Rn because it is often a symlink to the current release.
   for ac_dir in               \
-    /lib/usr/lib/X11     \
+    /lib/usr/lib/X11      \
     /usr/X11/lib          \
     /usr/X11R4/lib        \
     /usr/X11R5/lib        \
@@ -1362,9 +1375,9 @@ AC_CACHE_CHECK(for X11 configure files,gm_cv_x_configure,
     if test -f "$ac_dir/X11/rgb.txt"
     then
         gm_cv_x_configure="$ac_dir/X11/"
-       break
+        break
     elif test -f "$ac_dir/rgb.txt"
-    then 
+    then
         gm_cv_x_configure="$ac_dir/"
         break
     fi
@@ -1566,8 +1579,10 @@ if test "$with_zlib" != 'no' || test "$with_png" != 'no'
 then
   AC_MSG_CHECKING(for ZLIB support )
   AC_MSG_RESULT()
+
   failed=0
   passed=0
+  # PKG_CHECK_MODULES([ZLIB], [zlib], [], [])
   AC_CHECK_HEADER(zconf.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
   AC_CHECK_HEADER(zlib.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
   AC_CHECK_LIB(z,compress,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
@@ -1659,6 +1674,7 @@ if test "$with_lzma" != 'no'
 then
   AC_MSG_CHECKING(for LZMA support )
   AC_MSG_RESULT()
+  # PKG_CHECK_MODULES([LZMA], [liblzma], [], [])
   failed=0
   passed=0
   AC_CHECK_HEADER(lzma.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
@@ -1685,6 +1701,41 @@ AM_CONDITIONAL(HasLZMA, test "$have_lzma" = 'yes')
 AC_SUBST(LIB_LZMA)
 
 #
+# Check for Zstd
+#
+have_zstd='no'
+LIB_ZSTD=''
+if test "$with_zstd" != 'no'
+then
+  AC_MSG_CHECKING(for Zstd support )
+  AC_MSG_RESULT()
+  failed=0
+  passed=0
+  # PKG_CHECK_MODULES([ZSTD], [libzstd], [], [])
+  AC_CHECK_HEADER(zstd.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
+  AC_CHECK_LIB(zstd,ZSTD_createDStream,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
+  AC_MSG_CHECKING(if Zstd package is complete)
+  if test $passed -gt 0
+  then
+    if test $failed -gt 0
+    then
+      AC_MSG_RESULT(no -- some components failed test)
+      have_zstd='no (failed tests)'
+    else
+      LIB_ZSTD='-lzstd'
+      LIBS="$LIB_ZSTD $LIBS"
+      AC_DEFINE(HasZSTD,1,Define if you have zstd compression library)
+      AC_MSG_RESULT(yes)
+      have_zstd='yes'
+    fi
+  else
+    AC_MSG_RESULT(no)
+  fi
+fi
+AM_CONDITIONAL(HasZSTD, test "$have_zstd" = 'yes')
+AC_SUBST(LIB_ZSTD)
+
+#
 # Find the X11 include and library directories.
 #
 LIB_X11=''
@@ -1787,15 +1838,15 @@ then
     then
     if test $failed -gt 0
     then
-       AC_MSG_RESULT([no -- some components failed test])
+        AC_MSG_RESULT([no -- some components failed test])
         have_dps='no (failed tests)'
-       CPPFLAGS="$O_CPPFLAGS"
+        CPPFLAGS="$O_CPPFLAGS"
     else
-       LIB_DPS="-ldpstk -ldps ${LIBDPS_XT}"
-       LIBS="$LIB_DPS $LIBS"
-       AC_DEFINE(HasDPS,1,Define if you have Display Postscript)
-       AC_MSG_RESULT(yes)
-       have_dps='yes'
+        LIB_DPS="-ldpstk -ldps ${LIBDPS_XT}"
+        LIBS="$LIB_DPS $LIBS"
+        AC_DEFINE(HasDPS,1,Define if you have Display Postscript)
+        AC_MSG_RESULT(yes)
+        have_dps='yes'
     fi
     else
     AC_MSG_RESULT(no)
@@ -1825,13 +1876,13 @@ then
     then
     if test $failed -gt 0
     then
-       AC_MSG_RESULT(no -- some components failed test)
-       have_fpx='no (failed tests)'
+        AC_MSG_RESULT(no -- some components failed test)
+        have_fpx='no (failed tests)'
     else
-       LIB_FPX='-lfpx'
-       # LIBS="$LIB_FPX $LIBS"
-       AC_DEFINE(HasFPX,1,Define if you have FlashPIX library)
-       AC_MSG_RESULT(yes)
+        LIB_FPX='-lfpx'
+        # LIBS="$LIB_FPX $LIBS"
+        AC_DEFINE(HasFPX,1,Define if you have FlashPIX library)
+        AC_MSG_RESULT(yes)
         have_fpx='yes'
         PERLMAINCC="$CXX"
     fi
@@ -1855,6 +1906,8 @@ then
     passed=0
     have_lcms_header='no'
 
+    # PKG_CHECK_MODULES([LCMS2], [lcms2], [], [])
+
     # Check for <lcms2.h>
     AC_CHECK_HEADER(lcms2.h,have_lcms_header='yes',,)
     if test "$have_lcms_header" = 'yes'
@@ -1920,12 +1973,13 @@ then
                       [disable PNG support])],
       [with_png=$withval],
       [with_png='yes'])
-  
+      # PKG_CHECK_MODULES([PNG], [libpng], [], [])
+
   if test "$with_png" != 'yes'; then
       DISTCHECK_CONFIG_FLAGS="${DISTCHECK_CONFIG_FLAGS} --with-png=$with_png "
   fi
-  
-  
+
+
   if test "$with_png" != 'no' ; then
     AC_MSG_CHECKING(for PNG support )
     AC_MSG_RESULT()
@@ -1933,7 +1987,7 @@ then
     passed=0
     AC_CHECK_HEADER(png.h,passed=`expr $passed + 1`,
        failed=`expr $failed + 1`,)
-  
+
     if test $passed -gt 0; then
       for var in 7 6 5 4 2 '' ; do
         if test "x${var}" = 'x' ; then
@@ -1942,9 +1996,9 @@ then
           pnglib="png1${var}"
         fi
         if test "$have_png" = 'no'
-       then
-  
-         # Test for compatible LIBPNG library
+        then
+
+          # Test for compatible LIBPNG library
           failed=0
           passed=0
           if test "$with_png" = 'yes' -o "$with_png" = "libpng1${var}" ; then
@@ -1978,7 +2032,7 @@ return 0;
               AC_MSG_RESULT(yes)
             fi
           fi
-  
+
           if test $passed -gt 0 -a $failed -le 0
           then
             if test "1${var}" = '15' ; then
@@ -2005,14 +2059,14 @@ return 0;
               AC_MSG_CHECKING(if ${pnglib} package is complete)
               if test $passed -gt 0 ; then
                 if test $failed -gt 0 ; then
-               AC_MSG_RESULT(no -- some components failed test)
-               have_png='no (failed tests)'
+                AC_MSG_RESULT(no -- some components failed test)
+                have_png='no (failed tests)'
                 else
-               LIB_PNG="-l${pnglib}"
-               LIBS="$LIB_PNG $LIBS"
-               AC_DEFINE(HasPNG,1,Define if you have PNG library)
-               AC_MSG_RESULT(yes)
-               have_png='yes'
+                LIB_PNG="-l${pnglib}"
+                LIBS="$LIB_PNG $LIBS"
+                AC_DEFINE(HasPNG,1,Define if you have PNG library)
+                AC_MSG_RESULT(yes)
+                have_png='yes'
                 fi
               fi
             fi
@@ -2038,6 +2092,9 @@ then
     AC_MSG_RESULT()
     failed=0
     passed=0
+
+    # PKG_CHECK_MODULES([JPEG], [libturbojpeg, libjpeg], [], [])
+
     AC_CHECK_HEADER(jconfig.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
     AC_CHECK_HEADER(jerror.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
     AC_CHECK_HEADER(jmorecfg.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
@@ -2074,13 +2131,13 @@ fi
     then
     if test $failed -gt 0
     then
-       AC_MSG_RESULT(no -- some components failed test)
+        AC_MSG_RESULT(no -- some components failed test)
         have_jpeg='no (failed tests)'
     else
-       LIB_JPEG='-ljpeg'
-       LIBS="$LIB_JPEG $LIBS"
-       AC_DEFINE(HasJPEG,1,Define if you have JPEG library)
-       AC_MSG_RESULT(yes)
+        LIB_JPEG='-ljpeg'
+        LIBS="$LIB_JPEG $LIBS"
+        AC_DEFINE(HasJPEG,1,Define if you have JPEG library)
+        AC_MSG_RESULT(yes)
         have_jpeg='yes'
     fi
     else
@@ -2108,14 +2165,14 @@ then
     then
     if test $failed -gt 0
     then
-       AC_MSG_RESULT(no -- some components failed test)
-       have_jp2='no (failed tests)'
+        AC_MSG_RESULT(no -- some components failed test)
+        have_jp2='no (failed tests)'
     else
-       LIB_JP2='-ljasper'
-       LIBS="$LIB_JP2 $LIBS"
-       AC_DEFINE(HasJP2,1,Define if you have JPEG version 2 "Jasper" library)
-       AC_MSG_RESULT(yes)
-       have_jp2='yes'
+        LIB_JP2='-ljasper'
+        LIBS="$LIB_JP2 $LIBS"
+        AC_DEFINE(HasJP2,1,Define if you have JPEG version 2 "Jasper" library)
+        AC_MSG_RESULT(yes)
+        have_jp2='yes'
     fi
     else
     AC_MSG_RESULT(no)
@@ -2124,41 +2181,6 @@ fi
 AM_CONDITIONAL(HasJP2, test "$have_jp2" = 'yes')
 AC_SUBST(LIB_JP2)
 
-#
-# Check for Ghostscript library
-#
-# Test for iapi.h & test for gsapi_new_instance in -lgs
-have_gslib='no'
-LIB_GS=''
-if test "$with_gslib" != 'no'
-then
-    AC_MSG_CHECKING(for Ghostscript library support )
-    AC_MSG_RESULT()
-    failed=0
-    passed=0
-    AC_CHECK_HEADER(ghostscript/iapi.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
-    AC_CHECK_LIB(gs,gsapi_new_instance,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
-    AC_MSG_CHECKING(if Ghostscript library package is complete)
-    if test $passed -gt 0
-    then
-    if test $failed -gt 0
-    then
-       AC_MSG_RESULT(no -- some components failed test)
-       have_gslib='no (failed tests)'
-    else
-       LIB_GS='-lgs'
-       LIBS="$LIB_GS $LIBS"
-       AC_DEFINE(HasGS,1,Define if you have Ghostscript library)
-       AC_MSG_RESULT(yes)
-       have_gslib='yes'
-    fi
-    else
-    AC_MSG_RESULT(no)
-    fi
-fi
-AM_CONDITIONAL(HasGS, test "$have_gslib" = 'yes')
-AC_SUBST(LIB_GS)
-
 # #
 # # Check for MPEG2 library
 # #
@@ -2177,14 +2199,14 @@ AC_SUBST(LIB_GS)
 #     then
 #     if test $failed -gt 0
 #     then
-#      AC_MSG_RESULT(no -- some components failed test)
-#      have_mpeg2='no (failed tests)'
+#       AC_MSG_RESULT(no -- some components failed test)
+#       have_mpeg2='no (failed tests)'
 #     else
-#      LIB_MPEG2='-lmpeg2'
-#      LIBS="$LIB_MPEG2 $LIBS"
-#      AC_DEFINE(HasMPEG2,1,Define if you have MPEG2 library)
-#      AC_MSG_RESULT(yes)
-#      have_mpeg2='yes'
+#       LIB_MPEG2='-lmpeg2'
+#       LIBS="$LIB_MPEG2 $LIBS"
+#       AC_DEFINE(HasMPEG2,1,Define if you have MPEG2 library)
+#       AC_MSG_RESULT(yes)
+#       have_mpeg2='yes'
 #     fi
 #     else
 #     AC_MSG_RESULT(no)
@@ -2207,25 +2229,27 @@ then
 
     OLD_LDFLAGS="$LDFLAGS"
     OLD_CPPFLAGS="$CPPFLAGS"
+    # https://autotools.io/pkgconfig/pkg_check_modules.html
+    # PKG_CHECK_MODULES(prefix, list-of-modules, action-if-found, action-if-not-found)
+    # % pkg-config --libs freetype2
+    # -lfreetype
+    # % pkg-config --cflags freetype2
+    # -I/usr/include/freetype2 -I/usr/include/libpng12
+    #
+    # % grep FT_ config.status
+    # S["FT_LIBS"]="-R/usr/lib -lfreetype  "
+    # S["FT_CFLAGS"]="-I/usr/include/freetype2
+    freetype_cflags=''
+    freeype_libs=''
     freetype_config=''
-    # Allow the user to specify the location of freetype.
-    if test "$with_ttf" != 'yes'
-    then
-      if test -x "${with_ttf}/bin/freetype-config"
-      then
-        freetype_config="${with_ttf}/bin/freetype-config"
-      elif test -x "${with_ttf}"
+    AC_PATH_PROG(freetype_config,freetype-config,)dnl
+    PKG_CHECK_MODULES([FT], [freetype2],
+      [freetype_cflags=$FT_CFLAGS; freeype_libs=$FT_LIBS],
+      [if test -n "$freetype_config"
       then
-        freetype_config=${with_ttf}
-      fi
-    fi
-    if test -z "$freetype_config"
-    then
-      AC_PATH_PROG(freetype_config,freetype-config,)dnl
-    fi
-    if test -n "$freetype_config"
-    then
-      freetype_cflags=`${freetype_config} --cflags`
+        freetype_cflags=`${freetype_config} --cflags`
+        freeype_libs=`${freetype_config}  --libs`
+      fi])
       # freetype-config --cflags may output values such as
       # -I/usr/local/include/freetype2 -I/usr/local/include
       # Take only the first -I option since non-Freetype include
@@ -2254,7 +2278,6 @@ then
       # Freetype.  In the future we may need to do something different
       # if the FreeType library was to depend on some weird library
       # that we don't normally test for.
-      freeype_libs=`${freetype_config}  --libs`
       for flag in $freeype_libs
       do
         case $flag in
@@ -2277,7 +2300,6 @@ then
             ;;
         esac
       done
-    fi
 
 dnl First see if there is a library
     AC_CHECK_LIB([$LIB_TTF_BASE],[FT_Init_FreeType],[LIB_TTF="-l$LIB_TTF_BASE"],[LIB_TTF=''],[])
@@ -2303,32 +2325,32 @@ dnl Now test for the headers
     fi
     if test "$have_freetype_h" = 'yes'
     then
-       passed=`expr $passed + 1`
+        passed=`expr $passed + 1`
     else
-       failed=`expr $failed + 1`
+        failed=`expr $failed + 1`
         CPPFLAGS="$OLD_CPPFLAGS"
     fi
 
     AC_MSG_CHECKING(if FreeType package is complete)
     if test $passed -gt 0
     then
-       if test $failed -gt 0
-       then
+        if test $failed -gt 0
+        then
             LIB_TTF=''
-           AC_MSG_RESULT(no -- some components failed test)
-           have_ttf='no (failed tests)'
-       else
-           LIBS="$LIB_TTF $LIBS"
-           AC_DEFINE(HasTTF,1,Define if you have FreeType (TrueType font) library)
+            AC_MSG_RESULT(no -- some components failed test)
+            have_ttf='no (failed tests)'
+        else
+            LIBS="$LIB_TTF $LIBS"
+            AC_DEFINE(HasTTF,1,Define if you have FreeType (TrueType font) library)
             if test "$ac_cv_header_ft2build_h" = 'yes'
             then
               AC_DEFINE([HAVE_FT2BUILD_H],[1],[Define to 1 if you have the <ft2build.h> header file.])
              fi
-           AC_MSG_RESULT(yes)
-           have_ttf='yes'
-       fi
+            AC_MSG_RESULT(yes)
+            have_ttf='yes'
+        fi
     else
-       AC_MSG_RESULT(no)
+        AC_MSG_RESULT(no)
     fi
 fi
 AM_CONDITIONAL(HasTTF, test "$have_ttf" = 'yes')
@@ -2345,6 +2367,7 @@ then
     AC_MSG_RESULT()
     failed=0
     passed=0
+    # PKG_CHECK_MODULES([TIFF], [libtiff-4], [], [])
     AC_CHECK_HEADER(tiff.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
     AC_CHECK_HEADER(tiffio.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`)
     AC_CHECK_LIB(tiff,TIFFOpen,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
@@ -2357,15 +2380,15 @@ then
     then
         if test $failed -gt 0
         then
-           AC_MSG_RESULT(no -- some components failed test)
-           have_tiff='no (failed tests)'
+            AC_MSG_RESULT(no -- some components failed test)
+            have_tiff='no (failed tests)'
         else
-           LIB_TIFF='-ltiff'
-           LIBS="$LIB_TIFF $LIBS"
-           AC_DEFINE(HasTIFF,1,Define if you have TIFF library)
-           AC_MSG_RESULT(yes)
-           have_tiff='yes'
-           AC_CHECK_HEADERS(tiffconf.h)
+            LIB_TIFF='-ltiff'
+            LIBS="$LIB_TIFF $LIBS"
+            AC_DEFINE(HasTIFF,1,Define if you have TIFF library)
+            AC_MSG_RESULT(yes)
+            have_tiff='yes'
+            AC_CHECK_HEADERS(tiffconf.h)
             AC_CHECK_FUNCS([TIFFIsCODECConfigured \
                             TIFFMergeFieldInfo \
                             TIFFSetErrorHandlerExt \
@@ -2398,13 +2421,13 @@ then
     then
     if test $failed -gt 0
     then
-       AC_MSG_RESULT(no -- some components failed test)
+        AC_MSG_RESULT(no -- some components failed test)
         have_jbig='no (failed tests)'
     else
-       LIB_JBIG='-ljbig'
-       LIBS="$LIB_JBIG $LIBS"
-       AC_DEFINE(HasJBIG,1,Define if you have JBIG library)
-       AC_MSG_RESULT(yes)
+        LIB_JBIG='-ljbig'
+        LIBS="$LIB_JBIG $LIBS"
+        AC_DEFINE(HasJBIG,1,Define if you have JBIG library)
+        AC_MSG_RESULT(yes)
         have_jbig='yes'
     fi
     else
@@ -2425,22 +2448,24 @@ then
     AC_MSG_RESULT()
     failed=0
     passed=0
-    AC_CHECK_HEADER(webp/decode.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
-    AC_CHECK_LIB(webp,WebPDecodeRGB,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
+    # PKG_CHECK_MODULES([WEBP], [libwebp], [], [])
+    AC_CHECK_HEADER([webp/decode.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],[])
+    AC_CHECK_HEADER([webp/encode.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],[])
+    AC_CHECK_LIB([webp],[WebPDecodeRGB],[passed=`expr $passed + 1`; LIB_WEBP='-lwebp'],[failed=`expr $failed + 1`],[])
+    AC_CHECK_LIB([webpmux],[WebPMuxSetImage],[LIB_WEBP="$LIB_WEBP -lwebpmux"],[],[-lwebp])
     AC_MSG_CHECKING(if WEBP package is complete)
     if test $passed -gt 0
     then
-    if test $failed -gt 0
-    then
-  AC_MSG_RESULT(no -- some components failed test)
-        have_webp='no (failed tests)'
-    else
-  LIB_WEBP='-lwebp'
-  LIBS="$LIB_WEBP $LIBS"
-  AC_DEFINE(HasWEBP,1,Define if you have WEBP library)
-  AC_MSG_RESULT(yes)
-        have_webp='yes'
-    fi
+        if test $failed -gt 0
+        then
+            AC_MSG_RESULT(no -- some components failed test)
+            have_webp='no (failed tests)'
+        else
+            LIBS="$LIB_WEBP $LIBS"
+            AC_DEFINE(HasWEBP,1,Define if you have WEBP library)
+            AC_MSG_RESULT(yes)
+            have_webp='yes'
+        fi
     else
         AC_MSG_RESULT(no)
     fi
@@ -2462,18 +2487,29 @@ then
     AC_MSG_CHECKING([for XML support ])
     AC_MSG_RESULT([])
     xml2_config=''
+    xml2_cflags=''
+    xml2_libs=''
     AC_PATH_PROG([xml2_config],[xml2-config],[])dnl
-    if test -n "$xml2_config"
-    then
-        # Sample output from xml2-config --cflags:
-        # -I/usr/include/libxml2
-        # -I/usr/local/include/libxml2 -I/usr/local/include
-        xml2_cflags=`"$xml2_config" --cflags`
-        for flag in $xml2_cflags
-        do
-            case $flag in
-                -I*)
-                    # Add flag to CPPFLAGS if not already present
+    PKG_CHECK_MODULES([XML], [libxml-2.0],
+      [xml2_cflags=$XML_CFLAGS; xml2_libs=$XML_LIBS],
+      [if test -n "$xml2_config"
+       then
+          # Sample output from xml2-config --cflags:
+          # -I/usr/include/libxml2
+          # -I/usr/local/include/libxml2 -I/usr/local/include
+          xml2_cflags=`"$xml2_config" --cflags`
+          # Sample output from xml2-config --libs:
+          # -lxml2
+          # -L/usr/lib -R/usr/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl
+          #-L/usr/local/lib -lxml2 -lz -L/usr/local/lib -liconv -lm
+          xml2_libs=`$xml2_config  --libs`
+       fi
+      ])
+      for flag in $xml2_cflags
+      do
+        case $flag in
+             -I*)
+                # Add flag to CPPFLAGS if not already present
                     add=yes;
                     for test_flag in $CPPFLAGS
                     do
@@ -2491,15 +2527,10 @@ then
                     ;;
                 *)
                     ;;
-            esac
-        done
-        # Sample output from xml2-config --libs:
-        # -lxml2
-        # -L/usr/lib -R/usr/lib -lxml2 -lz -lpthread -lm -lsocket -lnsl
-        #-L/usr/local/lib -lxml2 -lz -L/usr/local/lib -liconv -lm
-        xml2_libs=`$xml2_config  --libs`
-        for flag in $xml2_libs
-        do
+        esac
+      done
+      for flag in $xml2_libs
+      do
             case $flag in
                 -L*)
                     # Add flag to LDFLAGS if not already present
@@ -2521,9 +2552,9 @@ then
                 *)
                     ;;
             esac
-        done
-        for flag in $xml2_libs
-        do
+      done
+      for flag in $xml2_libs
+      do
             case $flag in
                 -l*)
                     # The first library listed is assumed to be the
@@ -2539,8 +2570,7 @@ then
                 *)
                     ;;
             esac
-        done
-    fi
+      done
     if test "x$LIB_XML2_BASE" = "x"
     then
         LIB_XML2_BASE=xml2
@@ -2561,12 +2591,12 @@ then
     then
     if test $failed -gt 0
     then
-       AC_MSG_RESULT([no -- some components failed test])
+        AC_MSG_RESULT([no -- some components failed test])
         have_xml='no (failed tests)'
         LDFLAGS="$OLD_LDFLAGS"
         CPPFLAGS="$OLD_CPPFLAGS"
     else
-       LIB_XML="-l$LIB_XML2_BASE"
+        LIB_XML="-l$LIB_XML2_BASE"
         # Add lib to LIBS if not already present
         for test_lib in $LIB_XML $LIB_XML_DEPS
         do
@@ -2584,8 +2614,8 @@ then
                 LIBS="$test_lib $LIBS"
             fi
         done
-       AC_DEFINE([HasXML],[1],[Define if you have XML library])
-       AC_MSG_RESULT([yes])
+        AC_DEFINE([HasXML],[1],[Define if you have XML library])
+        AC_MSG_RESULT([yes])
         have_xml='yes'
     fi
     else
@@ -2630,7 +2660,7 @@ then
             LIBS="$LIB_WMF $LIBS"
             have_wmf='yes'
         else
-           AC_MSG_RESULT([no -- some components failed test])
+            AC_MSG_RESULT([no -- some components failed test])
             have_wmf='no (failed tests)'
             have_wmflite='no (failed tests)'
             LIBS="$OLIBS"
@@ -2923,7 +2953,7 @@ else
     #
     # It would be nice to use reg.exe to obtain Ghostscript information
     # but unfortunately MSYS seems to transform registry key paths into
-    # filesystem paths so it does not work.  Maybe there is a way to 
+    # filesystem paths so it does not work.  Maybe there is a way to
     # prevent that translation?
     #
     #   reg query "HKLM\Software\GPL Ghostscript" /s
@@ -3118,7 +3148,7 @@ then
   fi
   AC_MSG_RESULT($GSVersion)
 
-  # GSColorDevice # AS_MESSAGE_LOG_FD 
+  # GSColorDevice # AS_MESSAGE_LOG_FD
   AC_MSG_CHECKING([for gs color device])
   if $PSDelegate -q -dBATCH -sDEVICE=pnmraw -sOutputFile=/dev/null < /dev/null 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
   then
@@ -3246,15 +3276,15 @@ if test "$with_perl" != 'no'
 then
     if test "$with_perl" != 'yes'
     then
-       AC_CACHE_CHECK(for perl,ac_cv_path_PERL,ac_cv_path_PERL="$with_perl");
-       PERL=$ac_cv_path_PERL
-       AC_SUBST(PERL)dnl
-       have_perl="$ac_cv_path_PERL"
+        AC_CACHE_CHECK(for perl,ac_cv_path_PERL,ac_cv_path_PERL="$with_perl");
+        PERL=$ac_cv_path_PERL
+        AC_SUBST(PERL)dnl
+        have_perl="$ac_cv_path_PERL"
     else
-       AC_PATH_PROGS(PERL,perl perl5,)dnl
-       if test "$ac_cv_path_PERL"
+        AC_PATH_PROGS(PERL,perl perl5,)dnl
+        if test "$ac_cv_path_PERL"
         then
-         have_perl="$ac_cv_path_PERL"
+          have_perl="$ac_cv_path_PERL"
         fi
     fi
 fi
@@ -3463,14 +3493,17 @@ fi
 
 # The build_modules variable is set to 'yes' if coders and filters are
 # to be built as modules.  This requires libltdl ($LIB_LTDL).
+# Removed $LIB_OMP and $LIB_THREAD
 
 if test "$build_modules" != 'no'
 then
-  MAGICK_DEP_LIBS="$LIBS_USER $LIB_LCMS $LIB_TTF $LIB_GS $LIB_XEXT $LIB_IPC $LIB_X11 $LIB_LZMA $LIB_BZLIB $LIB_ZLIB $LIB_LTDL $LIB_TRIO $LIB_GDI32 $LIB_MATH $LIB_OMP $LIB_UMEM $LIB_THREAD"
+  MAGICK_DEP_LIBS="$LIBS_USER $LIB_LCMS $LIB_TTF $LIB_GS $LIB_XEXT $LIB_IPC $LIB_X11 $LIB_LZMA $LIB_BZLIB $LIB_ZLIB $LIB_LTDL $LIB_TRIO $LIB_GDI32 $LIB_MATH $LIB_UMEM $LIB_THREAD"
 else
-  MAGICK_DEP_LIBS="$LIBS_USER $LIB_JBIG $LIB_WEBP $LIB_LCMS $LIB_TIFF $LIB_TTF $LIB_JP2 $LIB_JPEG $LIB_GS $LIB_PNG $LIB_FPX $LIB_WMF $LIB_DPS $LIB_XEXT $LIB_IPC $LIB_X11 $LIB_LZMA $LIB_BZLIB $LIB_XML $LIB_ZLIB $LIB_TRIO $LIB_GDI32 $LIB_MATH $LIB_OMP $LIB_UMEM $LIB_THREAD"
+  MAGICK_DEP_LIBS="$LIBS_USER $LIB_JBIG $LIB_WEBP $LIB_LCMS $LIB_TIFF $LIB_TTF $LIB_JP2 $LIB_JPEG $LIB_GS $LIB_PNG $LIB_FPX $LIB_WMF $LIB_DPS $LIB_XEXT $LIB_IPC $LIB_X11 $LIB_LZMA $LIB_BZLIB $LIB_XML $LIB_ZLIB $LIB_ZSTD $LIB_TRIO $LIB_GDI32 $LIB_MATH $LIB_UMEM $LIB_THREAD"
 fi
+MAGICK_EXTRA_DEP_LIBS="$LIB_OMP" # Extra libraries typically added due to CFLAGS
 AC_SUBST(MAGICK_DEP_LIBS)
+AC_SUBST(MAGICK_EXTRA_DEP_LIBS)
 
 #
 # Remove extraneous spaces from output variables (asthetic)
@@ -3487,13 +3520,14 @@ CXXFLAGS=`echo $CXXFLAGS | sed -e 's/  */ /g'`
 LDFLAGS=`echo $LDFLAGS | sed -e 's/  */ /g'`
 TESTED_LIBS=`echo $LIBS | sed -e 's/  */ /g'`
 MAGICK_DEP_LIBS=`echo $MAGICK_DEP_LIBS | sed -e 's/  */ /g'`
+MAGICK_EXTRA_DEP_LIBS=`echo $MAGICK_EXTRA_DEP_LIBS | sed -e 's/  */ /g'`
 #LIBS=`echo $LIBS | sed -e 's/  */ /g'`
 
 MAGICK_API_CFLAGS=$CFLAGS
 MAGICK_API_CPPFLAGS=`echo $MAGICK_API_CPPFLAGS | sed -e 's/  */ /g'`
 MAGICK_API_LDFLAGS="-L$LIB_DIR $LDFLAGS"
 MAGICK_API_DEP_LIBS="$MAGICK_DEP_LIBS"
-MAGICK_API_LIBS="-lGraphicsMagick $MAGICK_API_DEP_LIBS"
+MAGICK_API_LIBS="-lGraphicsMagick $MAGICK_API_DEP_LIBS $MAGICK_EXTRA_DEP_LIBS"
 
 MAGICK_API_DEP_LIBS=`echo $MAGICK_API_DEP_LIBS | sed -e 's/  */ /g'`
 MAGICK_API_LIBS=`echo $MAGICK_API_LIBS | sed -e 's/  */ /g'`
@@ -3533,7 +3567,7 @@ AC_CONFIG_FILES(\
         Makefile \
         PerlMagick/Magick.pm \
         PerlMagick/Makefile.PL \
-       PerlMagick/PerlMagickCheck.sh \
+        PerlMagick/PerlMagickCheck.sh \
         PerlMagick/t/features.pl \
         config/delegates.mgk \
         config/type-ghostscript.mgk \
@@ -3561,82 +3595,81 @@ AC_OUTPUT
 
 rm -f magick-version
 
-echo ""
-
-echo "GraphicsMagick is configured as follows. Please verify that this"
-echo "configuration matches your expectations."
-echo ""
-echo "Host system type : $host"
-echo "Build system type : $build"
-echo ""
-echo "Option            Configure option               Configured value"
-echo "-----------------------------------------------------------------"
-echo "Shared libraries  --enable-shared=$enable_shared         $libtool_build_shared_libs"
-echo "Static libraries  --enable-static=$enable_static         $libtool_build_static_libs"
-echo "GNU ld            --with-gnu-ld=$with_gnu_ld             $lt_cv_prog_gnu_ld"
-echo "Quantum depth     --with-quantum-depth=$with_quantum_depth       $with_quantum_depth"
-echo "Modules           --with-modules=$with_modules           $build_modules"
-echo ""
-echo "Delegate Configuration:"
-echo "BZLIB             --with-bzlib=$with_bzlib               $have_bzlib"
-echo "DPS               --with-dps=$with_dps                   $have_dps"
-echo "FlashPIX          --with-fpx=$with_fpx                   $have_fpx"
-echo "FreeType 2.0      --with-ttf=$with_ttf           $have_ttf"
-echo "Ghostscript       None                           $PSDelegate ($GSVersion)"
+printf "\n"
+
+printf "GraphicsMagick is configured as follows. Please verify that this\n"
+printf "configuration matches your expectations.\n"
+printf "\n"
+printf "Host system type : $host\n"
+printf "Build system type : $build\n"
+printf "\n"
+printf "Option            Configure option      \tConfigured value\n"
+printf -- "-----------------------------------------------------------------\n"
+printf "Shared libraries  --enable-shared=$enable_shared\t\t$libtool_build_shared_libs\n"
+printf "Static libraries  --enable-static=$enable_static\t\t$libtool_build_static_libs\n"
+printf "GNU ld            --with-gnu-ld=$with_gnu_ld    \t\t$lt_cv_prog_gnu_ld\n"
+printf "Quantum depth     --with-quantum-depth=$with_quantum_depth\t$with_quantum_depth\n"
+printf "Modules           --with-modules=$with_modules  \t\t$build_modules\n"
+printf "\n"
+printf "Delegate Configuration:\n"
+printf "BZLIB             --with-bzlib=$with_bzlib         \t$have_bzlib\n"
+printf "DPS               --with-dps=$with_dps          \t$have_dps\n"
+printf "FlashPIX          --with-fpx=$with_fpx          \t$have_fpx\n"
+printf "FreeType 2.0      --with-ttf=$with_ttf          \t$have_ttf\n"
+printf "Ghostscript       None                  \t$PSDelegate ($GSVersion)\n"
 result_ghostscript_font_dir='none'
 if test "${ghostscript_font_dir}x" != 'x'
 then
   result_ghostscript_font_dir="$ghostscript_font_dir"
 fi
-echo "Ghostscript fonts --with-gs-font-dir=$with_gs_font_dir    $result_ghostscript_font_dir"
-echo "Ghostscript lib   --with-gslib=$with_gslib               $have_gslib"
-echo "JBIG              --with-jbig=$with_jbig         $have_jbig"
-echo "JPEG v1           --with-jpeg=$with_jpeg         $have_jpeg"
-echo "JPEG-2000         --with-jp2=$with_jp2           $have_jp2"
-echo "LCMS v2           --with-lcms2=$with_lcms2               $have_lcms2"
-# echo "MPEG v2           --with-mpeg2=$with_mpeg2             $have_mpeg2"
-echo "LZMA              --with-lzma=$with_lzma         $have_lzma"
-echo "Magick++          --with-magick-plus-plus=$with_magick_plus_plus         $have_magick_plus_plus"
-echo "PERL              --with-perl=$with_perl                 $have_perl"
+printf "Ghostscript fonts --with-gs-font-dir=$with_gs_font_dir\t$result_ghostscript_font_dir\n"
+printf "JBIG              --with-jbig=$with_jbig        \t$have_jbig\n"
+printf "JPEG v1           --with-jpeg=$with_jpeg        \t$have_jpeg\n"
+printf "JPEG-2000         --with-jp2=$with_jp2          \t$have_jp2\n"
+printf "LCMS v2           --with-lcms2=$with_lcms2        \t$have_lcms2\n"
+# printf "MPEG v2           --with-mpeg2=$with_mpeg2    \t$have_mpeg2\n"
+printf "LZMA              --with-lzma=$with_lzma        \t$have_lzma\n"
+printf "Magick++          --with-magick-plus-plus=$with_magick_plus_plus\t$have_magick_plus_plus\n"
+printf "PERL              --with-perl=$with_perl        \t$have_perl\n"
 if test "${LIB_PNG}x" != 'x'
 then
-echo "PNG               --with-png=$with_png           $have_png ($LIB_PNG)"
+printf "PNG               --with-png=$with_png          \t$have_png ($LIB_PNG)\n"
 else
-echo "PNG               --with-png=$with_png           $have_png"
+printf "PNG               --with-png=$with_png          \t$have_png\n"
 fi
-echo "TIFF              --with-tiff=$with_tiff         $have_tiff"
-echo "TRIO              --with-trio=$with_trio         $have_trio"
-echo "WEBP              --with-webp=$with_webp         $have_webp"
+printf "TIFF              --with-tiff=$with_tiff        \t$have_tiff\n"
+printf "TRIO              --with-trio=$with_trio        \t$have_trio\n"
+printf "WEBP              --with-webp=$with_webp        \t$have_webp\n"
 result_windows_font_dir='none'
 if test "${windows_font_dir}x" != 'x'
 then
   result_windows_font_dir="${windows_font_dir}"
 fi
-echo "Windows fonts     --with-windows-font-dir=$with_windows_font_dir $result_windows_font_dir"
-echo "WMF               --with-wmf=$with_wmf           $have_wmf"
-echo "X11               --with-x=$with_x               $have_x"
-echo "XML               --with-xml=$with_xml           $have_xml"
-echo "ZLIB              --with-zlib=$with_zlib         $have_zlib"
-echo ""
-echo "X11 Configuration:"
+printf "Windows fonts     --with-windows-font-dir=$with_windows_font_dir\t$result_windows_font_dir\n"
+printf "WMF               --with-wmf=$with_wmf          \t$have_wmf\n"
+printf "X11               --with-x=$with_x              \t$have_x\n"
+printf "XML               --with-xml=$with_xml          \t$have_xml\n"
+printf "ZLIB              --with-zlib=$with_zlib        \t$have_zlib\n"
+printf "\n"
+printf "X11 Configuration:\n"
 if test "$have_x" != 'no'
 then
-  echo "  X_CFLAGS     = $X_CFLAGS"
-  echo "  X_PRE_LIBS   = $X_PRE_LIBS"
-  echo "  X_LIBS       = $X_LIBS"
-  echo "  X_EXTRA_LIBS = $X_EXTRA_LIBS"
+  printf "  X_CFLAGS     = $X_CFLAGS\n"
+  printf "  X_PRE_LIBS   = $X_PRE_LIBS\n"
+  printf "  X_LIBS       = $X_LIBS\n"
+  printf "  X_EXTRA_LIBS = $X_EXTRA_LIBS\n"
 else
-  echo ""
-  echo "  Not using X11."
-fi
-echo ""
-echo "Options used to compile and link:"
-echo "  CC       = $CC"
-echo "  CFLAGS   = $CFLAGS"
-echo "  CPPFLAGS = $CPPFLAGS"
-echo "  CXX      = $CXX"
-echo "  CXXFLAGS = $CXXFLAGS"
-echo "  DEFS     = $DEFS"
-echo "  LDFLAGS  = $LDFLAGS"
-echo "  LIBS     = $MAGICK_API_DEP_LIBS"
-echo ""
+  printf "\n"
+  printf "  Not using X11.\n"
+fi
+printf "\n"
+printf "Options used to compile and link:\n"
+printf "  CC       = $CC\n"
+printf "  CFLAGS   = $CFLAGS\n"
+printf "  CPPFLAGS = $CPPFLAGS\n"
+printf "  CXX      = $CXX\n"
+printf "  CXXFLAGS = $CXXFLAGS\n"
+printf "  DEFS     = $DEFS\n"
+printf "  LDFLAGS  = $LDFLAGS\n"
+printf "  LIBS     = $MAGICK_API_DEP_LIBS\n"
+printf "\n"
index 52b789f..9d51764 100644 (file)
@@ -49,7 +49,7 @@
 %
 %  The format of the AnalyzeImage method is:
 %
-%      unsigned int AnalyzeImage(Image *image)
+%      MagickPassFail AnalyzeImage(Image *image)
 %
 %  A description of each parameter follows:
 %
 %
 */
 #define PRECISION "%.0f"
-ModuleExport unsigned int AnalyzeImage(Image **image,
-  const int argc,char **argv)
+ModuleExport MagickPassFail AnalyzeImage(Image **image,
+                                         const int argc,char **argv)
 {
   double
     bsumX = 0.0,
     bsumX2 = 0.0,
-    brightness_mean = 0.0,
-    brightness_stdev = 0.0,
     ssumX = 0.0,
-    ssumX2 = 0.0,
-    saturation_mean = 0.0,
-    saturation_stdev = 0.0,
-    total_pixels = 0.0;
+    ssumX2 = 0.0;
 
   double
     brightness,
     hue,
     saturation;
 
-  long
+  unsigned long
     y;
 
-  register long
-    x;
+  register unsigned long
+    x = 0;
 
   register PixelPacket
     *p;
@@ -88,58 +83,72 @@ ModuleExport unsigned int AnalyzeImage(Image **image,
   char
     text[MaxTextExtent];
 
+  MagickPassFail
+    status = MagickPass;
+
   ARG_NOT_USED(argc);
   ARG_NOT_USED(argv);
 
   assert(image != (Image **) NULL);
   assert(*image != (Image *) NULL);
-  for (y=0; y < (int) (*image)->rows; y++)
-  {
-    p=GetImagePixels((*image),0,y,(*image)->columns,1);
-    if (p == (PixelPacket *) NULL)
-      break;
-    if (y == 0)
-      {
-        FormatString(text,"#%02x%02x%02x",p->red,p->green,p->blue);
-        (void) SetImageAttribute((*image),"TopLeftColor",text);
-      }
-    if (y == (long) ((*image)->rows-1))
-      {
-        FormatString(text,"#%02x%02x%02x",p->red,p->green,p->blue);
-        (void) SetImageAttribute((*image),"BottomLeftColor",text);
-      }
-    for (x=0; x < (long) (*image)->columns; x++)
+  for (y=0; y < (*image)->rows; y++)
+    {
+      p=GetImagePixels((*image),0,y,(*image)->columns,1);
+      if (p == (PixelPacket *) NULL)
+        break;
+      if (y == 0)
+        {
+          FormatString(text,"#%02x%02x%02x",p->red,p->green,p->blue);
+          (void) SetImageAttribute((*image),"TopLeftColor",text);
+        }
+      if (y == ((*image)->rows-1))
+        {
+          FormatString(text,"#%02x%02x%02x",p->red,p->green,p->blue);
+          (void) SetImageAttribute((*image),"BottomLeftColor",text);
+        }
+      for (x=0; x < (*image)->columns; x++)
+        {
+          TransformHSL(p->red,p->green,p->blue,&hue,&saturation,&brightness);
+          brightness *= MaxRGBDouble;
+          bsumX += brightness;
+          bsumX2 += brightness * brightness;
+          saturation *= MaxRGBDouble;
+          ssumX += saturation;
+          ssumX2 += saturation * saturation;
+          p++;
+        }
+      p--; /* backup one pixel to allow us to sample */
+      if (y == 0)
+        {
+          FormatString(text,"#%02x%02x%02x",p->red,p->green,p->blue);
+          (void) SetImageAttribute((*image),"TopRightColor",text);
+        }
+      if (y == ((*image)->rows-1))
+        {
+          FormatString(text,"#%02x%02x%02x",p->red,p->green,p->blue);
+          (void) SetImageAttribute((*image),"BottomRightColor",text);
+        }
+    }
+  if ((x != (*image)->columns) || (y != (*image)->rows))
     {
-      TransformHSL(p->red,p->green,p->blue,&hue,&saturation,&brightness);
-      brightness *= MaxRGB;
-            bsumX += brightness;
-            bsumX2 += brightness * brightness;
-      saturation *= MaxRGB;
-            ssumX += saturation;
-            ssumX2 += saturation * saturation;
-      total_pixels++;
-      p++;
+      status = MagickFail;
     }
-    p--; /* backup one pixel to allow us to sample */
-    if (y == 0)
-      {
-        FormatString(text,"#%02x%02x%02x",p->red,p->green,p->blue);
-        (void) SetImageAttribute((*image),"TopRightColor",text);
-      }
-    if (y == (long) ((*image)->rows-1))
-      {
-        FormatString(text,"#%02x%02x%02x",p->red,p->green,p->blue);
-        (void) SetImageAttribute((*image),"BottomRightColor",text);
-      }
-  }
-  if (total_pixels > 0.0)
+  else
     {
+      double
+        brightness_mean,
+        brightness_stdev,
+        saturation_mean,
+        saturation_stdev,
+        total_pixels;
+
+      total_pixels = (double) (*image)->columns * (double) (*image)->rows;
       brightness_mean = bsumX/total_pixels;
       FormatString(text,PRECISION,brightness_mean);
       (void) SetImageAttribute((*image),"BrightnessMean",text);
       /*  This formula gives a slightly biased result */
       brightness_stdev =
-          sqrt(bsumX2/total_pixels - (bsumX/total_pixels*bsumX/total_pixels));
+        sqrt(bsumX2/total_pixels - (bsumX/total_pixels*bsumX/total_pixels));
       FormatString(text,PRECISION,brightness_stdev);
       (void) SetImageAttribute((*image),"BrightnessStddev",text);
       /* Now the correction for bias. */
@@ -152,7 +161,7 @@ ModuleExport unsigned int AnalyzeImage(Image **image,
       (void) SetImageAttribute((*image),"SaturationMean",text);
       /* This formula gives a slightly biased result */
       saturation_stdev =
-          sqrt(ssumX2/total_pixels - (ssumX/total_pixels*ssumX/total_pixels));
+        sqrt(ssumX2/total_pixels - (ssumX/total_pixels*ssumX/total_pixels));
       FormatString(text,PRECISION,saturation_stdev);
       (void) SetImageAttribute((*image),"SaturationStddev",text);
       /* Now the correction for bias. */
@@ -160,5 +169,5 @@ ModuleExport unsigned int AnalyzeImage(Image **image,
       /* Now calculate the standard deviation of the mean */
       /*  saturation_stdevmean = sstdev/sqrt((double)total_pixels); */
     }
-  return(True);
+  return status;
 }
index bb129c1..8e29841 100644 (file)
@@ -26,6 +26,9 @@
       <Message name="UnrecognizedImageFormat">
         Unrecognized image format
       </Message>
+      <Message name="UnableToDeduceImageFormat">
+        Unable to deduce image format
+      </Message>
     </Error>
     <FatalError>
       <Message name="Default">
@@ -46,6 +49,9 @@
       <Message name="PixelCacheIsNotOpen">
         Pixel cache is not open
       </Message>
+      <Message name="PixelCacheDimensionsMisMatch">
+        Pixel cache dimensions incompatible with image dimensions
+      </Message>
       <Message name="UnableToAllocateCacheView">
         Unable to allocate cache view
       </Message>
       <Message name="UnsupportedBitsPerSample">
         Unsupported bits per sample
       </Message>
+      <Message name="UnsupportedSamplesPerPixel">
+        Unsupported samples per pixel
+      </Message>
+      <Message name="ArithmeticOverflow">
+        Arithmetic overflow
+      </Message>
+      <Message name="DivisionByZero">
+        Division by zero
+      </Message>
+      <Message name="DecodedImageNotReturned">
+        Coder did not return an image (this is a bug, please report it!)
+      </Message>
     </Error>
     <FatalError>
       <Message name="Default">
         <Message name="UnsupportedNumberOfPlanes">
           Unsupported number of planes
         </Message>
+        <Message name="ImageFileHasNoScenes">
+          Image file has no scenes
+        </Message>
      </Error>
       <FatalError>
         <Message name="UnableToPersistKey">
         <Message name="LengthAndFilesizeDoNotMatch">
           Length and filesize do not match
         </Message>
+        <Message name="UnableToParseEmbeddedProfile">
+          Unable to parse embedded profile
+        </Message>
       </Warning>
     </Image>
   </Corrupt>
       <Message name="ImageDoesNotContainResolution">
         image does not contain resolution
       </Message>
+      <Message name="ImageIsNotColormapped">
+        image is not colormapped
+      </Message>
+      <Message name="CMYKAImageLacksAlphaChannel">
+        CMYKA image lacks an alpha channel (indexes)
+      </Message>
       <Message name="ImageOpacityDiffers">
         image opacity differs
       </Message>
       <Message name="UnableToSetClipMask">
         Unable to set clip mask
       </Message>
+      <Message name="UnableToGetCompositeMask">
+        Unable to get composite mask
+      </Message>
+      <Message name="UnableToSetCompositeMask">
+        Unable to set composite mask
+      </Message>
       <Message name="UnableToShearImage">
         unable to shear image
       </Message>
       <Message name="WidthOrHeightExceedsLimit">
         width or height exceeds limit
       </Message>
+      <Message name="UnableToExportImagePixels">
+        unable to export image pixels
+      </Message>
+      <Message name="UnableToImportImagePixels">
+        unable to import image pixels
+      </Message>
     </Error>
     <FatalError>
       <Message name="UnableToPersistKey">
       <Message name="UsageError">
         Improper arguments supplied, please see manual
       </Message>
+      <Message name="TileNotBoundedByImageDimensions">
+        Tile is not bounded by image dimensions
+      </Message>
     </Error>
     <FatalError>
       <Message name="InvalidInterlaceType">
         <Message name="UnableToAddIPTCProfile">
           unable to add IPTC profile
         </Message>
+        <Message name="UnableToAddOrRemoveProfile">
+          unable to add or remove profile
+        </Message>
         <Message name="UnableToAllocateColormap">
           Unable to allocate colormap
         </Message>
         <Message name="UnableToAllocateQuantizeInfo">
           unable to allocate quantize info
         </Message>
-       <Message name="UnableToAllocateRandomKernel">
+        <Message name="UnableToAllocateRandomKernel">
           unable to allocate random kernel
         </Message>
         <Message name="UnableToAllocateSemaphoreInfo">
         <Message name="UnableToObtainRandomEntropy">
           unable to obtain random bytes from operating system
         </Message>
+        <Message name="UnableToAllocateMagickMap">
+          unable to allocate magick map
+        </Message>
       </FatalError>
       <Warning>
         <Message name="MemoryAllocationFailed">
       <Message name="UnrecognizedFontEncoding">
         Unrecognized font encoding
       </Message>
+      <Message name="FontNotSpecified">
+        Font name not specified
+      </Message>
     </Error>
     <FatalError>
       <Message name="Default">
diff --git a/m4/pkg.m4 b/m4/pkg.m4
new file mode 100644 (file)
index 0000000..13a8890
--- /dev/null
+++ b/m4/pkg.m4
@@ -0,0 +1,275 @@
+# pkg.m4 - Macros to locate and utilise pkg-config.   -*- Autoconf -*-
+# serial 12 (pkg-config-0.29.2)
+
+dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl     [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29.2])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+    [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+       AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+       _pkg_min_version=m4_default([$1], [0.9.0])
+       AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+       if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+               AC_MSG_RESULT([yes])
+       else
+               AC_MSG_RESULT([no])
+               PKG_CONFIG=""
+       fi
+fi[]dnl
+])dnl PKG_PROG_PKG_CONFIG
+
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_default([$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
+
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+                     test "x$?" != "x0" && pkg_failed=yes ],
+                    [pkg_failed=yes])
+ else
+    pkg_failed=untried
+fi[]dnl
+])dnl _PKG_CONFIG
+
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
+
+
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $2])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+        AC_MSG_RESULT([no])
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+               $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+        else
+               $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+        fi
+       # Put the nasty error message in config.log where it belongs
+       echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+       m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+        ])
+elif test $pkg_failed = untried; then
+        AC_MSG_RESULT([no])
+       m4_default([$4], [AC_MSG_FAILURE(
+[The pkg-config script could not be found or is too old.  Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+        ])
+else
+       $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+       $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+       $3
+fi[]dnl
+])dnl PKG_CHECK_MODULES
+
+
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl   [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
+
+
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
+AC_DEFUN([PKG_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([pkgconfigdir],
+    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
+    [with_pkgconfigdir=]pkg_default)
+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_INSTALLDIR
+
+
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
+AC_DEFUN([PKG_NOARCH_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([noarch-pkgconfigdir],
+    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
+    [with_noarch_pkgconfigdir=]pkg_default)
+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+])dnl PKG_NOARCH_INSTALLDIR
+
+
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])dnl PKG_CHECK_VAR
index b531136..5a64f02 100644 (file)
@@ -297,6 +297,7 @@ MAGICK_NOINST_HDRS = \
        magick/floats.h \
        magick/locale_c.h \
        magick/map.h \
+       magick/module_aliases.h \
        magick/nt_base.h \
        magick/nt_feature.h \
        magick/omp_data_view.h \
index 3852fba..d771535 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick X11 compatibility methods.
 */
 #ifndef _MAGICK_PRER5ICCCM_H
index d58f7ef..e4841e4 100644 (file)
@@ -1,13 +1,23 @@
 /*
   Copyright (C) 2003, 2005, 2008, 2013 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Alpha Composite Methods.
 */
+
+/*
+  References on compositing:
+
+    Porter, Thomas; Tom Duff (1984). "Compositing Digital Images". Computer Graphics.
+      18 (3): 253.259. ISBN 0-89791-138-5. doi:10.1145/800031.808606
+
+    SVG specification REC-SVG11-20110816.pdf, "Simple alpha compositing"
+*/
+
 #ifndef _MAGICK_ALPHA_COMPOSITE_H
 #define _MAGICK_ALPHA_COMPOSITE_H
 
@@ -25,11 +35,20 @@ static inline magick_uint32_t BlendQuantumOpacity(magick_uint32_t q,
 
   if (opacity != 0U)
     {
+      /*
+        The 0==transparent/MaxRGB==opaque value for "opacity" is o = (MaxRGB-opacity),
+        and the value for "q" is a = (MaxRGB-q), so the output value is o * a / MaxRGB.
+        This value must be inverted to conform to the  0==opaque/MaxRGB==transparent
+        convention used in this code.  When you work through the algebra you get
+        result = opacity + q - opacity * q / MaxRGB.
+      */
 #if QuantumDepth > 16
-      result = ((magick_uint64_t) opacity*q)/MaxRGB;
+#define _TCAST_  magick_uint64_t
 #else
-      result = ((magick_uint32_t) opacity*q)/MaxRGB;
+#define _TCAST_  magick_uint32_t
 #endif
+      result = opacity + q - ((_TCAST_)opacity * (_TCAST_)q + /*round*/(MaxRGB>>1))/MaxRGB;
+#undef _TCAST_
     }
   return result;
 }
@@ -45,26 +64,26 @@ static inline void BlendCompositePixel(PixelPacket *composite,
 
   if (q->opacity == TransparentOpacity)
     {
-         composite->red=p->red;
-         composite->green=p->green;
-         composite->blue=p->blue;
+          composite->red=p->red;
+          composite->green=p->green;
+          composite->blue=p->blue;
     }
   else if (p->opacity == TransparentOpacity)
     {
-         composite->red=q->red;
-         composite->green=q->green;
-         composite->blue=q->blue;
+          composite->red=q->red;
+          composite->green=q->green;
+          composite->blue=q->blue;
     }
   else
     {
-         color=((double) p->red*(MaxRGBDouble-alpha)+q->red*alpha)/MaxRGBDouble;
-         composite->red=RoundDoubleToQuantum(color);
+          color=((double) p->red*(MaxRGBDouble-alpha)+q->red*alpha)/MaxRGBDouble;
+          composite->red=RoundDoubleToQuantum(color);
 
-         color=((double) p->green*(MaxRGBDouble-alpha)+q->green*alpha)/MaxRGBDouble;
-         composite->green=RoundDoubleToQuantum(color);
+          color=((double) p->green*(MaxRGBDouble-alpha)+q->green*alpha)/MaxRGBDouble;
+          composite->green=RoundDoubleToQuantum(color);
 
-         color=((double) p->blue*(MaxRGBDouble-alpha)+q->blue*alpha)/MaxRGBDouble;
-         composite->blue=RoundDoubleToQuantum(color);
+          color=((double) p->blue*(MaxRGBDouble-alpha)+q->blue*alpha)/MaxRGBDouble;
+          composite->blue=RoundDoubleToQuantum(color);
     }
 
   opacity=((double) p->opacity*(MaxRGBDouble-alpha)+q->opacity*alpha)/MaxRGBDouble;
@@ -72,14 +91,42 @@ static inline void BlendCompositePixel(PixelPacket *composite,
 }
 
 /*
-  Alpha compose pixel 'change' over pixel 'source'.
+  Alpha compose pixel 'change' over pixel 'base'.
 
   The result will be the union of the two image shapes, with
   opaque areas of change-image obscuring base-image in the
   region of overlap.
 */
+
+/*
+  Documentation for macro MagickAlphaCompositeQuantum:
+
+    (1) GM uses the alpha value convention of 0 for opaque and MaxRGB for transparent, which is
+    the opposite of the "standard" usage (see Porter/Duff and SVG references above).
+    (2) Using the standard terminology of fg (foreground) and bg (background), and the standard
+    representation of 0 for transparent and 1 for opaque, let:
+
+      fg_alpha = (1.0 - change_alpha / MaxRGBDouble)
+      bg_alpha = (1.0 - base_alpha / MaxRGBDouble)
+
+    then MagickAlphaCompositeQuantum computes the following result:
+
+      result = fg_alpha * fg + (1 - fg_alpha) * (bg_alpha * bg)
+
+    This is the "standard" compositing equation when the fg and bg colors have not been premultiplied
+    by their alpha values.  For reference, note that when the fg and bg colors HAVE been premultiplied,
+    the compositing equation becomes the simple and elegant:
+
+      result = fg + (1 - fg_alpha) * bg
+
+    and this equation works for both the color components AND the alpha channel.  For the
+    non-premultiplied case, the alpha equation is:
+
+      result_alpha = fg_alpha + (1 - fg_alpha) * bg_alpha
+*/
+
 #define  MagickAlphaCompositeQuantum(change,change_alpha,base,base_alpha) \
-   (1.0-(change_alpha/MaxRGBDouble))*(double) change+(1.0-(base_alpha/MaxRGBDouble))*(double) base*(change_alpha/MaxRGBDouble)
+   ((1.0-(change_alpha/MaxRGBDouble))*(double) change+(1.0-(base_alpha/MaxRGBDouble))*(double) base*(change_alpha/MaxRGBDouble))
 
 static inline void AlphaCompositePixel(PixelPacket *composite, const PixelPacket *change,
                                        const double change_alpha,const PixelPacket *base,
@@ -88,7 +135,7 @@ static inline void AlphaCompositePixel(PixelPacket *composite, const PixelPacket
   if (change_alpha == (double) TransparentOpacity)
     {
       if (composite != base)
-       *composite=*base;
+        *composite=*base;
     }
   else
     {
@@ -96,19 +143,29 @@ static inline void AlphaCompositePixel(PixelPacket *composite, const PixelPacket
         delta,
         value;
 
+      /*
+        "delta" is the 0==transparent/1==opaque opacity value for the composited
+        pixel (I checked the algebra).
+      */
       delta=1.0-(change_alpha/MaxRGBDouble)*(base_alpha/MaxRGBDouble);
-      
-      value=MaxRGBDouble*(1.0-delta);
+
+      value=MaxRGBDouble*(1.0-delta);   /* invert so 0==opaque, MaxRGB==transparent */
       composite->opacity=RoundDoubleToQuantum(value);
-      
+
+      /*
+        The multiplicative inverse of "delta" is used to rescale the red, green, and
+        blue composited pixel values so that they are not premultiplied by the alpha
+        value.  Note the protection against divide-by-zero in case the composited pixel
+        is completely transparent.
+      */
       delta=1.0/(delta <= MagickEpsilon ? 1.0 : delta);
-      
+
       value=delta*MagickAlphaCompositeQuantum(change->red,change_alpha,base->red,base_alpha);
       composite->red=RoundDoubleToQuantum(value);
-      
+
       value=delta*MagickAlphaCompositeQuantum(change->green,change_alpha,base->green,base_alpha);
       composite->green=RoundDoubleToQuantum(value);
-      
+
       value=delta*MagickAlphaCompositeQuantum(change->blue,change_alpha,base->blue,base_alpha);
       composite->blue=RoundDoubleToQuantum(value);
     }
@@ -131,25 +188,25 @@ static inline void AtopCompositePixel(PixelPacket *composite,
   opacity=((double)(MaxRGBDouble-change->opacity)*
            (MaxRGBDouble-base->opacity)+(double) change->opacity*
            (MaxRGBDouble-base->opacity))/MaxRGBDouble;
-  
+
   color=((double) (MaxRGBDouble-change->opacity)*
          (MaxRGBDouble-base->opacity)*change->red/MaxRGBDouble+(double)
          change->opacity*(MaxRGBDouble-base->opacity)*
          base->red/MaxRGBDouble)/opacity;
   composite->red=RoundDoubleToQuantum(color);
-  
+
   color=((double) (MaxRGBDouble-change->opacity)*
          (MaxRGBDouble-base->opacity)*change->green/MaxRGBDouble+(double)
          change->opacity*(MaxRGBDouble-base->opacity)*
          base->green/MaxRGBDouble)/opacity;
   composite->green=RoundDoubleToQuantum(color);
-  
+
   color=((double) (MaxRGBDouble-change->opacity)*
          (MaxRGBDouble-base->opacity)*change->blue/MaxRGBDouble+(double)
          change->opacity*(MaxRGBDouble-base->opacity)*
          base->blue/MaxRGBDouble)/opacity;
   composite->blue=RoundDoubleToQuantum(color);
-  
+
   composite->opacity=MaxRGB-RoundDoubleToQuantum(opacity);
 }
 
index 6c4c489..1d17908 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2009 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2003 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -89,13 +89,13 @@ MagickExport RectangleInfo GetImageBoundingBox(const Image *image,
   (void) AcquireOnePixelByReference(image,&corners[1],(long) image->columns-1,0,exception);
   (void) AcquireOnePixelByReference(image,&corners[2],0,(long) image->rows-1,exception);
 #if defined(HAVE_OPENMP)
-#  pragma omp parallel for schedule(static,4) shared(row_count, status)
+#  pragma omp parallel for schedule(static,4) shared(bounds, row_count, status)
 #endif
   for (y=0; y < (long) image->rows; y++)
     {
       register const PixelPacket
         * restrict p;
-    
+
       register long
         x;
 
@@ -121,13 +121,13 @@ MagickExport RectangleInfo GetImageBoundingBox(const Image *image,
       if (thread_status != MagickFail)
         {
           if ((image->matte) &&
-             (corners[0].opacity != OpaqueOpacity) &&
-             (corners[0].opacity == corners[1].opacity) &&
-             (corners[1].opacity == corners[2].opacity))
-           /*
-             Consider only the opacity channel. Not currently fuzzy
-             so only applied for simple transparency.
-           */
+              (corners[0].opacity != OpaqueOpacity) &&
+              (corners[0].opacity == corners[1].opacity) &&
+              (corners[1].opacity == corners[2].opacity))
+            /*
+              Consider only the opacity channel. Not currently fuzzy
+              so only applied for simple transparency.
+            */
             for (x=0; x < (long) image->columns; x++)
               {
                 if (p->opacity != corners[0].opacity)
@@ -145,31 +145,31 @@ MagickExport RectangleInfo GetImageBoundingBox(const Image *image,
                 p++;
               }
           else if (image->fuzz <= MagickEpsilon)
-           {
-             /*
-               Consider only the RGB channels using absolute comparison
-             */
-             for (x=0; x < (long) image->columns; x++)
-               {
-                 if (!ColorMatch(p,&corners[0]))
-                   if (x < thread_bounds.x)
-                     thread_bounds.x=x;
-                 if (!ColorMatch(p,&corners[1]))
-                   if (x > (long) thread_bounds.width)
-                     thread_bounds.width=x;
-                 if (!ColorMatch(p,&corners[0]))
-                   if (y < thread_bounds.y)
-                     thread_bounds.y=y;
-                 if (!ColorMatch(p,&corners[2]))
-                   if (y > (long) thread_bounds.height)
-                     thread_bounds.height=y;
-                 p++;
-               }
-           }
-         else
-           /*
-             Consider only the RGB channels using fuzzy comparison
-           */
+            {
+              /*
+                Consider only the RGB channels using absolute comparison
+              */
+              for (x=0; x < (long) image->columns; x++)
+                {
+                  if (!ColorMatch(p,&corners[0]))
+                    if (x < thread_bounds.x)
+                      thread_bounds.x=x;
+                  if (!ColorMatch(p,&corners[1]))
+                    if (x > (long) thread_bounds.width)
+                      thread_bounds.width=x;
+                  if (!ColorMatch(p,&corners[0]))
+                    if (y < thread_bounds.y)
+                      thread_bounds.y=y;
+                  if (!ColorMatch(p,&corners[2]))
+                    if (y > (long) thread_bounds.height)
+                      thread_bounds.height=y;
+                  p++;
+                }
+            }
+          else
+            /*
+              Consider only the RGB channels using fuzzy comparison
+            */
             for (x=0; x < (long) image->columns; x++)
               {
                 if (!FuzzyColorMatch(p,&corners[0],image->fuzz))
@@ -189,15 +189,18 @@ MagickExport RectangleInfo GetImageBoundingBox(const Image *image,
         }
 
 #if defined(HAVE_OPENMP)
+#  pragma omp atomic
+#endif
+      row_count++;
+      if (QuantumTick(row_count,image->rows))
+        if (!MagickMonitorFormatted(row_count,image->rows,exception,
+                                    GetImageBoundingBoxText,image->filename))
+          thread_status=MagickFail;
+
+#if defined(HAVE_OPENMP)
 #  pragma omp critical (GM_GetImageBoundingBox)
 #endif
       {
-        row_count++;
-        if (QuantumTick(row_count,image->rows))
-          if (!MagickMonitorFormatted(row_count,image->rows,exception,
-                                      GetImageBoundingBoxText,image->filename))
-            thread_status=MagickFail;
-
         if (thread_bounds.x < bounds.x)
           bounds.x=thread_bounds.x;
         if (thread_bounds.y < bounds.y)
@@ -206,10 +209,15 @@ MagickExport RectangleInfo GetImageBoundingBox(const Image *image,
           bounds.width=thread_bounds.width;
         if (thread_bounds.height > bounds.height)
           bounds.height=thread_bounds.height;
+      }
 
-        if (thread_status == MagickFail)
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
   if ((bounds.width != 0) || (bounds.height != 0))
     {
@@ -273,28 +281,28 @@ static inline unsigned char MinimumDepthForValue(const Quantum quantum)
   register unsigned int
     depth,
     scale;
-  
+
   for (depth=1 ; depth < MaxRGB; depth++)
     {
       scale=MaxRGB / (MaxRGB >> (QuantumDepth-depth));
       if (quantum == scale*(quantum/scale))
         break;
     }
-  
+
   return depth;
 }
 #if MaxMap == MaxRGB
 static magick_uint8_t* AllocateDepthMap(void)
 {
-  magick_uint8_t 
+  magick_uint8_t
     *map;
-  
+
   map = MagickAllocateArray(unsigned char *, MaxMap+1, sizeof(magick_uint8_t));
   if (map != (unsigned char *) NULL)
     {
       unsigned int
         i;
-      
+
       for (i=0; i <= MaxMap; i++)
         map[i] = (magick_uint8_t) MinimumDepthForValue(i);
     }
@@ -306,11 +314,11 @@ static magick_uint8_t* AllocateDepthMap(void)
 static MagickPassFail
 GetImageDepthCallBack(void *mutable_data,          /* User provided mutable data */
                       const void *immutable_data,  /* User provided immutable data */
-                      const Image *image,          /* Input image */
-                      const PixelPacket *pixels,   /* Pixel row */
-                      const IndexPacket *indexes,  /* Pixel indexes */
+                      const Image * restrict image,          /* Input image */
+                      const PixelPacket * restrict pixels,   /* Pixel row */
+                      const IndexPacket * restrict indexes,  /* Pixel indexes */
                       const long npixels,          /* Number of pixels in row */
-                      ExceptionInfo *exception     /* Exception report */
+                      ExceptionInfo * restrict exception     /* Exception report */
                       )
 {
   unsigned int
@@ -429,11 +437,11 @@ MagickExport unsigned long GetImageDepth(const Image *image,
     {
       /*
         DirectClass.
-       
+
         Notice that all pixels in the image must be inspected if the
         image depth is less than QuantumDepth.
       */
-     
+
       (void) PixelIterateMonoRead(GetImageDepthCallBack,
                                   NULL,
                                   GetImageDepthText,
@@ -861,7 +869,7 @@ MagickExport MagickBool IsMonochromeImage(const Image *image,
   if (image->colorspace == CMYKColorspace)
     return(MagickFalse);
   if (image->is_monochrome)
-    return(MagickTrue); 
+    return(MagickTrue);
   is_monochrome=MagickTrue;
   switch (image->storage_class)
   {
index 5530a87..1b22acd 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 - 2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Image Analysis Methods.
 */
 #ifndef _MAGICK_ANALYZE_H
@@ -30,7 +30,7 @@ typedef struct _ImageCharacteristics
 /* Functions which return unsigned int to indicate operation pass/fail */
 extern MagickExport MagickPassFail
   GetImageCharacteristics(const Image *image,ImageCharacteristics *characteristics,
-                         const MagickBool optimize,ExceptionInfo *exception);
+                          const MagickBool optimize,ExceptionInfo *exception);
 
 extern MagickExport unsigned long
   GetImageDepth(const Image *,ExceptionInfo *);
index b290931..bc84486 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -917,10 +917,10 @@ MagickExport void MagickXAnimateBackgroundImage(Display *display,
 */
 MagickExport Image *
 MagickXAnimateImages(Display *display,
-                    MagickXResourceInfo *resource_info,
-                    char *argv[],
-                    const int argc,
-                    Image *images)
+                     MagickXResourceInfo *resource_info,
+                     char *argv[],
+                     const int argc,
+                     Image *images)
 {
 #define MagickMenus  4
 #define MaxWindows  8
@@ -1830,7 +1830,7 @@ MagickXAnimateImages(Display *display,
               {
                 char
                   name[MaxTextExtent];
-                
+
                 FormatString(name,
                              "GraphicsMagick: %.1024s[%lu of %lu]",p,scene,
                              number_scenes);
index df03b6e..8434c81 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Methods to Interactively Animate an Image Sequence.
 */
 #ifndef _MAGICK_ANIMATE_H
index f0fe124..21117fc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -779,6 +779,54 @@ MagickExport MagickPassFail GetTypeMetrics(Image *image,const DrawInfo *draw_inf
   return(status);
 }
 \f
+
+/*
+  Find a single font family name in a comma-separated list; returns a pointer
+  to where next search should start (i.e., to the terminating character), or null
+  if not found.  Trims leading and trailing white space, and surrounding single
+  quotes.
+*/
+static
+char const *FindCommaDelimitedName
+(
+ char const *  pSearchStart, /*start search here*/
+ char const ** ppStart,      /*return pointer to first character in found string*/
+ char const ** ppEnd         /*return pointer to just past last character in found string*/
+ )
+{ /*FindCommaDelimitedName*/
+
+  int c;
+  char const * pStart;
+  char const * pEnd;
+  char const * pNextSearchStart;
+
+  if ( pSearchStart == 0 )
+    return(0);
+
+  for ( pStart = pSearchStart; (c = *pStart) && (isspace(c) || (c == ','));
+        pStart++ );  /*skip leading spaces and commas*/
+  if ( c == '\0' )
+    return(0);  /*didn't find anything!*/
+
+  for ( pEnd = pStart + 1; (c = *pEnd) && (c != ','); pEnd++ ); /*find terminating comma*/
+  pNextSearchStart = pEnd;
+
+  for ( ; isspace(pEnd[-1]); pEnd-- ); /*trim trailing space; we know there is a non-space character there*/
+
+  /* trim off surrounding single quotes */
+  if ((*pStart == '\'') &&  (*pEnd == '\'') && ((pEnd-pStart) >= 3))
+    {
+      pStart++;
+      pEnd--;
+    }
+
+  *ppStart = pStart;
+  *ppEnd = pEnd;
+  return(pNextSearchStart);
+
+} /*FindCommaDelimitedName*/
+
+
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
@@ -814,17 +862,23 @@ MagickExport MagickPassFail GetTypeMetrics(Image *image,const DrawInfo *draw_inf
 %
 */
 static MagickPassFail RenderType(Image *image,const DrawInfo *draw_info,
-  const PointInfo *offset,TypeMetric *metrics)
+                                 const PointInfo *offset,TypeMetric *metrics)
 {
   const TypeInfo
     *type_info;
 
   DrawInfo
-   *clone_info;
+    *clone_info;
 
   MagickPassFail
     status;
 
+  char
+    OneFontFamilyName[2048]; /*special handling only if font name this long or less*/
+
+  char const *
+    pTheFoundFontFamilyName;
+
   type_info=(const TypeInfo *) NULL;
   if (draw_info->font != (char *) NULL)
     {
@@ -837,9 +891,94 @@ static MagickPassFail RenderType(Image *image,const DrawInfo *draw_info,
         if (IsAccessible(draw_info->font))
           return(RenderFreetype(image,draw_info,(char *) NULL,offset,metrics));
     }
+
+  /* draw_info->family may be a comma-separated list of names ... */
+  pTheFoundFontFamilyName = draw_info->family;
   if (type_info == (const TypeInfo *) NULL)
-    type_info=GetTypeInfoByFamily(draw_info->family,draw_info->style,
-      draw_info->stretch,draw_info->weight,&image->exception);
+    { /*type_info not yet found*/
+
+      /* stay consistent with previous behavior unless font family contains comma(s) */
+      if (draw_info->family == 0 || (strchr(draw_info->family,',') == 0))
+        { /*null ptr, or no commas in string; preserve previous behavior*/
+
+          type_info=GetTypeInfoByFamily(draw_info->family,draw_info->style,
+                                        draw_info->stretch,draw_info->weight,
+                                        &image->exception);
+
+        } /*null ptr, or no commas in string; preserve previous behavior*/
+      else
+        { /*process as font family list*/
+
+          char const * pNext = draw_info->family, * pStart = 0, * pEnd = 0;
+          while ((pNext = FindCommaDelimitedName(pNext,&pStart,&pEnd)) != 0)
+            { /*found a name*/
+
+              unsigned int NameLength = pEnd - pStart;
+              if  ( NameLength >= sizeof(OneFontFamilyName) )
+                continue;
+              memcpy(OneFontFamilyName,pStart,NameLength);
+              OneFontFamilyName[NameLength] = '\0';
+              type_info = GetTypeInfoByFamily(OneFontFamilyName,
+                                              draw_info->style,
+                                              draw_info->stretch,
+                                              draw_info->weight,
+                                              &image->exception);
+              /*do not allow font substitution*/
+              if ( type_info && (LocaleCompare(OneFontFamilyName,
+                                               type_info->family) == 0) )
+                {
+                  pTheFoundFontFamilyName = OneFontFamilyName;
+                  break;
+                }
+
+            } /*found a name*/
+
+        } /*process as font family list*/
+
+    } /*type_info not yet found*/
+
+  /*
+    We may have performed font substitution.  If so (i.e., font family
+    name does not match), try again assuming draw_info->family is
+    actually a font name.  If we get a font name match, that will
+    override the font substitution.
+  */
+  if ((type_info == (const TypeInfo *) NULL)
+      || /*found font family, but ...*/
+      (pTheFoundFontFamilyName &&
+       (LocaleCompare(pTheFoundFontFamilyName,type_info->family) != 0)))
+    {/*either not found, or different font family (probably font substitution)*/
+
+      /* try to match a font name */
+      const TypeInfo *type_info2 = 0;
+      if (((type_info2 = GetTypeInfo(pTheFoundFontFamilyName,
+                                     &image->exception))
+           == (const TypeInfo *) NULL)
+          && (pTheFoundFontFamilyName != 0)
+          && strlen(pTheFoundFontFamilyName) < sizeof(OneFontFamilyName))
+        {/*change ' ' to '-' and try again*/
+
+          /*
+            Change blanks to hyphens (i.e. make it look like a font
+            name vs. font family).  Will only do this for font names
+            sizeof(OneFontFamilyName) long or less.
+          */
+          char FontNameWithHyphens[sizeof(OneFontFamilyName)];
+          char *pWithHyphens = FontNameWithHyphens;
+          char c;
+          const char *pFound;
+          for (pFound = pTheFoundFontFamilyName;
+               (*pWithHyphens = (((c = *pFound) != ' ') ? c : '-'));
+               pFound++, pWithHyphens++);
+          type_info2 = GetTypeInfo(FontNameWithHyphens,&image->exception);
+
+        } /*change ' ' to '-' and try again*/
+
+      if  ( type_info2 != (const TypeInfo *) NULL )
+        type_info = type_info2;
+
+    } /*either not found, or different font family (probably font substitution)*/
+
   if (type_info == (const TypeInfo *) NULL)
     return(RenderPostscript(image,draw_info,offset,metrics));
   clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
@@ -1043,6 +1182,9 @@ static MagickPassFail RenderFreetype(Image *image,const DrawInfo *draw_info,
   MagickPassFail
     status=MagickPass;
 
+  if (draw_info->font == (char *) NULL)
+    ThrowBinaryException(TypeError,FontNotSpecified,image->filename);
+
   glyph.image=(FT_Glyph) 0;
   last_glyph.image=(FT_Glyph) 0;
 
@@ -1052,7 +1194,7 @@ static MagickPassFail RenderFreetype(Image *image,const DrawInfo *draw_info,
   ft_status=FT_Init_FreeType(&library);
   if (ft_status)
     ThrowBinaryException(TypeError,UnableToInitializeFreetypeLibrary,
-      draw_info->font);
+                         draw_info->font);
   if (*draw_info->font != '@')
     ft_status=FT_New_Face(library,draw_info->font,0,&face);
   else
@@ -1194,12 +1336,12 @@ static MagickPassFail RenderFreetype(Image *image,const DrawInfo *draw_info,
       (void) FT_Done_Face(face);
       (void) FT_Done_FreeType(library);
       (void) LogMagickEvent(AnnotateEvent,GetMagickModule(),
-                           "Text encoding failed: encoding_type=%ld "
-                           "draw_info->encoding=\"%s\" draw_info->text=\"%s\" length=%ld",
-                           (long) encoding_type,
-                           (draw_info->encoding ? draw_info->encoding : "(null)"),
-                           (draw_info->text ? draw_info->text : "(null)"),
-                           (long) length);
+                            "Text encoding failed: encoding_type=%ld "
+                            "draw_info->encoding=\"%s\" draw_info->text=\"%s\" length=%ld",
+                            (long) encoding_type,
+                            (draw_info->encoding ? draw_info->encoding : "(null)"),
+                            (draw_info->text ? draw_info->text : "(null)"),
+                            (long) length);
       ThrowBinaryException(ResourceLimitError,MemoryAllocationFailed,
         draw_info->font)
     }
@@ -1370,7 +1512,12 @@ static MagickPassFail RenderFreetype(Image *image,const DrawInfo *draw_info,
                     {
                       continue;
                     }
-                  opacity=((MaxRGB-opacity)*(MaxRGB-fill_color.opacity))/MaxRGB;
+                  /*
+                    At this point, opacity is 0==transparent to MaxRGB==opaque, and represents an
+                    anti-aliasing edge blending value.  The computation below integrates in the
+                    fill color opacity, and converts the result to 0=opaque to MaxRGB=transparent.
+                  */
+                  opacity=MaxRGB-(opacity*(MaxRGB-fill_color.opacity)+/*round*/(MaxRGB>>1))/MaxRGB;
                   AlphaCompositePixel(q,&fill_color,opacity,q,
                                       image->matte ? q->opacity : OpaqueOpacity);
                   if (!active)
index 6817c06..8a51223 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 - 2012 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Application Programming Interface declarations.
 
 */
index 9a77c11..010eca2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -61,7 +61,7 @@ static void DestroyImageAttribute(ImageAttribute *attribute);
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  CloneImageAttributes() copies the text attibutes from one image to another.
+%  CloneImageAttributes() copies the text attributes from one image to another.
 %  Any text attributes in the destination image are preserved.
 %  CloneImageAttributes returns MagickPass if all of the attribututes are
 %  successfully cloned or MagickFail if there is a memory allocation error.
@@ -81,7 +81,7 @@ static void DestroyImageAttribute(ImageAttribute *attribute);
 */
 MagickExport MagickPassFail
 CloneImageAttributes(Image* clone_image,
-                    const Image* original_image)
+                     const Image* original_image)
 {
   MagickPassFail
     status;
@@ -98,19 +98,22 @@ CloneImageAttributes(Image* clone_image,
   /*
     Search for tail of list (if any)
   */
-  for(cloned_attributes=clone_image->attributes;
-      cloned_attributes != (ImageAttribute *) NULL;
-      cloned_attributes=cloned_attributes->next);
+  if ((cloned_attributes=clone_image->attributes))
+    {
+      for( ;
+          cloned_attributes->next != (ImageAttribute *) NULL;
+          cloned_attributes=cloned_attributes->next);
+    }
 
   attribute=GetImageAttribute(original_image,(char *) NULL);
   for ( ; attribute != (const ImageAttribute *) NULL;
-       attribute=attribute->next)
+        attribute=attribute->next)
     {
       /*
         Construct AttributeInfo to append.
       */
       cloned_attribute=MagickAllocateMemory(ImageAttribute *,
-                                           sizeof(ImageAttribute));
+                                            sizeof(ImageAttribute));
       if (cloned_attribute == (ImageAttribute *) NULL)
         {
           status = MagickFail;
@@ -119,7 +122,7 @@ CloneImageAttributes(Image* clone_image,
       cloned_attribute->key=AcquireString(attribute->key);
       cloned_attribute->length=attribute->length;
       cloned_attribute->value=
-       MagickAllocateMemory(char *,cloned_attribute->length+1);
+        MagickAllocateMemory(char *,cloned_attribute->length+1);
       cloned_attribute->previous=(ImageAttribute *) NULL;
       cloned_attribute->next=(ImageAttribute *) NULL;
       if ((cloned_attribute->value == (char *) NULL) ||
@@ -331,22 +334,22 @@ GenerateIPTCAttribute(Image *image,const char *key)
   for (i=0; i < (long) profile_length; i++)
     {
       if (profile[i] != 0x1cU)
-       continue;
+        continue;
       if (profile[i+1] != dataset)
-       {
-         /* fprintf(stderr,"Skipping dataset %d\n",profile[i+1]); */
-         continue;
-       }
+        {
+          /* fprintf(stderr,"Skipping dataset %d\n",profile[i+1]); */
+          continue;
+        }
       if (profile[i+2] != record)
-       {
-         /* fprintf(stderr,"Skipping record %d\n",profile[i+2]); */
-         continue;
-       }
+        {
+          /* fprintf(stderr,"Skipping record %d\n",profile[i+2]); */
+          continue;
+        }
       length=profile[i+3] << 8;
       length|=profile[i+4];
       attribute=MagickAllocateMemory(char *,length+1);
       if (attribute == (char *) NULL)
-       continue;
+        continue;
       (void) strlcpy(attribute,(char *) profile+i+5,length+1);
       (void) SetImageAttribute(image,key,(const char *) attribute);
       MagickFreeMemory(attribute);
@@ -368,7 +371,7 @@ ReadByte(unsigned char **p,size_t *length)
   return(c);
 }
 
-static long
+static magick_int32_t
 ReadMSBLong(unsigned char **p,size_t *length)
 {
   int
@@ -401,7 +404,7 @@ ReadMSBLong(unsigned char **p,size_t *length)
   return(value.s);
 }
 
-static int
+static magick_int32_t
 ReadMSBShort(unsigned char **p,size_t *length)
 {
   int
@@ -433,13 +436,28 @@ ReadMSBShort(unsigned char **p,size_t *length)
 }
 
 /*
-  FIXME: length is defined as type size_t, and then code incorrectly
-  assumes that size_t is a signed type
+  Advance 'blob' by 'amount' or the amount remaining in 'length'.
+  Decrement 'length' by 'amount' or to zero.
 */
+static inline size_t AdvanceBlob(const size_t amount, size_t length, unsigned char **blob)
+{
+  if (length > amount)
+    {
+      *blob+=amount;
+      length-=amount;
+    }
+  else
+    {
+      *blob+=length;
+      length=0U;
+    }
+  return length;
+}
+
 static char *
 TracePSClippingPath(unsigned char *blob,size_t length,
-                   unsigned long columns,
-                   unsigned long rows)
+                    const unsigned long columns,
+                    const unsigned long rows)
 {
   char
     *path,
@@ -506,170 +524,166 @@ TracePSClippingPath(unsigned char *blob,size_t length,
     {
       selector=ReadMSBShort(&blob,&length);
       switch (selector)
-       {
-       case 0:
-       case 3:
-         {
-           if (knot_count == 0)
-             {
-               /*
-                 Expected subpath length record
-               */
-               knot_count=ReadMSBShort(&blob,&length);
-               blob+=22;
-               length-=22;
-             }
-           else
-             {
-               blob+=24;
-               length-=24;
-             }   
-           break;
-         }
-       case 1:
-       case 2:
-       case 4:
-       case 5:
-         {
-           if (knot_count == 0)
-             {
-               /*
-                 Unexpected subpath knot
-               */
-               blob+=24;
-               length-=24;
-             }
-           else
-             {
-               /*
-                 Add sub-path knot
-               */
-               for (i=0; i < 3; i++)
-                 {
-                   y=ReadMSBLong(&blob,&length);
-                   x=ReadMSBLong(&blob,&length);
-                   point[i].x=(double) x/4096/4096;
-                   point[i].y=1.0-(double) y/4096/4096;
-                 }
-               if (!in_subpath)
-                 {
-                   FormatString(message,"%.6f %.6f m\n",
-                                point[1].x,point[1].y);
-                   for (i=0; i < 3; i++)
-                     {
-                       first[i]=point[i];
-                       last[i]=point[i];
-                     }
-                 }
-               else
-                 {
-                   /*
-                     Handle special cases when Bezier curves are used
-                     to describe corners and straight lines. This
-                     special handling is desirable to bring down the
-                     size in bytes of the clipping path data.
-                   */
-                   if ((last[1].x == last[2].x) &&
-                       (last[1].y == last[2].y) &&
-                       (point[0].x == point[1].x) &&
-                       (point[0].y == point[1].y))
-                     {
-                       /*
-                         First control point equals first anchor
-                         point and last control point equals last
-                         anchow point. Straigt line between anchor
-                         points.
-                       */
-                       FormatString(message,"%.6f %.6f l\n",
-                                    point[1].x,point[1].y);
-                     }
-                   else if ((last[1].x == last[2].x) &&
-                            (last[1].y == last[2].y))
-                     {
-                       /* First control point equals first anchor point */
-                       FormatString(message,"%.6f %.6f %.6f %.6f v\n",
-                                    point[0].x,point[0].y,
-                                    point[1].x,point[1].y);
-                     }
-                   else if ((point[0].x == point[1].x) &&
-                            (point[0].y == point[1].y))
-                     {
-                       /* Last control point equals last anchow point. */
-                       FormatString(message,"%.6f %.6f %.6f %.6f y\n",
-                                    last[2].x,last[2].y,
-                                    point[1].x,point[1].y);
-                     }
-                   else
-                     {
-                       /* The full monty */
-                       FormatString(message,
-                                    "%.6f %.6f %.6f %.6f %.6f %.6f c\n",
-                                    last[2].x,last[2].y,point[0].x,
-                                    point[0].y,point[1].x,
-                                    point[1].y);
-                     }
-                   for (i=0; i < 3; i++)
-                     last[i]=point[i];
-                 }
-               (void) ConcatenateString(&path,message);
-               in_subpath=True;
-               knot_count--;
-               /*
-                 Close the subpath if there are no more knots.
-               */
-               if (knot_count == 0)
-                 {
-                   /*
-                     Same special handling as above except we compare
-                     to the first point in the path and close the
-                     path.
-                   */
-                   if ((last[1].x == last[2].x) &&
-                       (last[1].y == last[2].y) &&
-                       (first[0].x == first[1].x) &&
-                       (first[0].y == first[1].y))
-                     {
-                       FormatString(message,"%.6f %.6f l z\n",
-                                    first[1].x,first[1].y);
-                     }
-                   else if ((last[1].x == last[2].x) &&
-                            (last[1].y == last[2].y))
-                     {
-                       FormatString(message,"%.6f %.6f %.6f %.6f v z\n",
-                                    first[0].x,first[0].y,
-                                    first[1].x,first[1].y);
-                     }
-                   else if ((first[0].x == first[1].x) &&
-                            (first[0].y == first[1].y))
-                     {
-                       FormatString(message,"%.6f %.6f %.6f %.6f y z\n",
-                                    last[2].x,last[2].y,
-                                    first[1].x,first[1].y);
-                     }
-                   else
-                     {
-                       FormatString(message,
-                                    "%.6f %.6f %.6f %.6f %.6f %.6f c z\n",
-                                    last[2].x,last[2].y,
-                                    first[0].x,first[0].y,
-                                    first[1].x,first[1].y);
-                     }
-                   (void) ConcatenateString(&path,message);
-                   in_subpath=False;
-                 }
-             }
-           break;
-         }
-       case 6:
-       case 7:
-       case 8:
-       default:
-         {
-           blob+=24;
-           length-=24;
-           break;
-         }
-       }
+        {
+        case 0:
+        case 3:
+          {
+            if (knot_count == 0)
+              {
+                /*
+                  Expected subpath length record
+                */
+                knot_count=ReadMSBShort(&blob,&length);
+                length=AdvanceBlob(22U,length,&blob);
+              }
+            else
+              {
+                length=AdvanceBlob(24U,length,&blob);
+              }
+            break;
+          }
+        case 1:
+        case 2:
+        case 4:
+        case 5:
+          {
+            if (knot_count == 0)
+              {
+                /*
+                  Unexpected subpath knot
+                */
+                length=AdvanceBlob(24U,length,&blob);
+              }
+            else
+              {
+                /*
+                  Add sub-path knot
+                */
+                for (i=0; i < 3; i++)
+                  {
+                    y=ReadMSBLong(&blob,&length);
+                    x=ReadMSBLong(&blob,&length);
+                    point[i].x=(double) x/4096/4096;
+                    point[i].y=1.0-(double) y/4096/4096;
+                  }
+                if (!in_subpath)
+                  {
+                    FormatString(message,"%.6f %.6f m\n",
+                                 point[1].x,point[1].y);
+                    for (i=0; i < 3; i++)
+                      {
+                        first[i]=point[i];
+                        last[i]=point[i];
+                      }
+                  }
+                else
+                  {
+                    /*
+                      Handle special cases when Bezier curves are used
+                      to describe corners and straight lines. This
+                      special handling is desirable to bring down the
+                      size in bytes of the clipping path data.
+                    */
+                    if ((last[1].x == last[2].x) &&
+                        (last[1].y == last[2].y) &&
+                        (point[0].x == point[1].x) &&
+                        (point[0].y == point[1].y))
+                      {
+                        /*
+                          First control point equals first anchor
+                          point and last control point equals last
+                          anchow point. Straigt line between anchor
+                          points.
+                        */
+                        FormatString(message,"%.6f %.6f l\n",
+                                     point[1].x,point[1].y);
+                      }
+                    else if ((last[1].x == last[2].x) &&
+                             (last[1].y == last[2].y))
+                      {
+                        /* First control point equals first anchor point */
+                        FormatString(message,"%.6f %.6f %.6f %.6f v\n",
+                                     point[0].x,point[0].y,
+                                     point[1].x,point[1].y);
+                      }
+                    else if ((point[0].x == point[1].x) &&
+                             (point[0].y == point[1].y))
+                      {
+                        /* Last control point equals last anchow point. */
+                        FormatString(message,"%.6f %.6f %.6f %.6f y\n",
+                                     last[2].x,last[2].y,
+                                     point[1].x,point[1].y);
+                      }
+                    else
+                      {
+                        /* The full monty */
+                        FormatString(message,
+                                     "%.6f %.6f %.6f %.6f %.6f %.6f c\n",
+                                     last[2].x,last[2].y,point[0].x,
+                                     point[0].y,point[1].x,
+                                     point[1].y);
+                      }
+                    for (i=0; i < 3; i++)
+                      last[i]=point[i];
+                  }
+                (void) ConcatenateString(&path,message);
+                in_subpath=True;
+                knot_count--;
+                /*
+                  Close the subpath if there are no more knots.
+                */
+                if (knot_count == 0)
+                  {
+                    /*
+                      Same special handling as above except we compare
+                      to the first point in the path and close the
+                      path.
+                    */
+                    if ((last[1].x == last[2].x) &&
+                        (last[1].y == last[2].y) &&
+                        (first[0].x == first[1].x) &&
+                        (first[0].y == first[1].y))
+                      {
+                        FormatString(message,"%.6f %.6f l z\n",
+                                     first[1].x,first[1].y);
+                      }
+                    else if ((last[1].x == last[2].x) &&
+                             (last[1].y == last[2].y))
+                      {
+                        FormatString(message,"%.6f %.6f %.6f %.6f v z\n",
+                                     first[0].x,first[0].y,
+                                     first[1].x,first[1].y);
+                      }
+                    else if ((first[0].x == first[1].x) &&
+                             (first[0].y == first[1].y))
+                      {
+                        FormatString(message,"%.6f %.6f %.6f %.6f y z\n",
+                                     last[2].x,last[2].y,
+                                     first[1].x,first[1].y);
+                      }
+                    else
+                      {
+                        FormatString(message,
+                                     "%.6f %.6f %.6f %.6f %.6f %.6f c z\n",
+                                     last[2].x,last[2].y,
+                                     first[0].x,first[0].y,
+                                     first[1].x,first[1].y);
+                      }
+                    (void) ConcatenateString(&path,message);
+                    in_subpath=False;
+                  }
+              }
+            break;
+          }
+        case 6:
+        case 7:
+        case 8:
+        default:
+          {
+            length=AdvanceBlob(24U,length,&blob);
+            break;
+          }
+        }
     }
   /*
     Returns an empty PS path if the path has no knots.
@@ -682,13 +696,11 @@ TracePSClippingPath(unsigned char *blob,size_t length,
   return(path);
 }
 
-/*
-  FIXME: length is defined as type size_t, and then code incorrectly
-  assumes that size_t is a signed type.
-*/
 static char *
-TraceSVGClippingPath(unsigned char *blob,size_t length,
-                    unsigned long columns,unsigned long rows)
+TraceSVGClippingPath(unsigned char *blob,
+                     size_t length,
+                     const unsigned long columns,
+                     const unsigned long rows)
 {
   char
     *path,
@@ -746,137 +758,133 @@ TraceSVGClippingPath(unsigned char *blob,size_t length,
     {
       selector=ReadMSBShort(&blob,&length);
       switch (selector)
-       {
-       case 0:
-       case 3:
-         {
-           if (knot_count == 0)
-             {
-               /*
-                 Expected subpath length record
-               */
-               knot_count=ReadMSBShort(&blob,&length);
-               blob+=22;
-               length-=22;
-             }
-           else
-             {
-               blob+=24;
-               length-=24;
-             }   
-           break;
-         }
-       case 1:
-       case 2:
-       case 4:
-       case 5:
-         {
-           if (knot_count == 0)
-             {
-               /*
-                 Unexpected subpath knot
-               */
-               blob+=24;
-               length-=24;
-             }
-           else
-             {
-               /*
-                 Add sub-path knot
-               */
-               for (i=0; i < 3; i++)
-                 {
-                   y=ReadMSBLong(&blob,&length);
-                   x=ReadMSBLong(&blob,&length);
-                   point[i].x=(double) x*columns/4096/4096;
-                   point[i].y=(double) y*rows/4096/4096;
-                 }
-               if (!in_subpath)
-                 {
-                   FormatString(message,"M %.6f,%.6f\n",
-                                point[1].x,point[1].y);
-                   for (i=0; i < 3; i++)
-                     {
-                       first[i]=point[i];
-                       last[i]=point[i];
-                     }
-                 }
-               else
-                 {
-                   /*
-                     Handle special case when Bezier curves are used
-                     to describe straight lines.
-                   */
-                   if ((last[1].x == last[2].x) &&
-                       (last[1].y == last[2].y) &&
-                       (point[0].x == point[1].x) &&
-                       (point[0].y == point[1].y))
-                     {
-                       /*
-                         First control point equals first anchor
-                         point and last control point equals last
-                         anchow point. Straigt line between anchor
-                         points.
-                       */
-                       FormatString(message,"L %.6f,%.6f\n",
-                                    point[1].x,point[1].y);
-                     }
-                   else
-                     {
-                       FormatString(message,
-                                    "C %.6f,%.6f %.6f,%.6f %.6f,%.6f\n",
-                                    last[2].x,last[2].y,
-                                    point[0].x,point[0].y,
-                                    point[1].x,point[1].y);
-                     }
-                   for (i=0; i < 3; i++)
-                     last[i]=point[i];
-                 }
-               (void) ConcatenateString(&path,message);
-               in_subpath=True;
-               knot_count--;
-               /*
-                 Close the subpath if there are no more knots.
-               */
-               if (knot_count == 0)
-                 {
-                   /*
-                     Same special handling as above except we compare
-                     to the first point in the path and close the
-                     path.
-                   */
-                   if ((last[1].x == last[2].x) &&
-                       (last[1].y == last[2].y) &&
-                       (first[0].x == first[1].x) &&
-                       (first[0].y == first[1].y))
-                     {
-                       FormatString(message,
-                                    "L %.6f,%.6f Z\n",first[1].x,first[1].y);
-                     }
-                   else
-                     {
-                       FormatString(message,
-                                    "C %.6f,%.6f %.6f,%.6f %.6f,%.6f Z\n",
-                                    last[2].x,last[2].y,
-                                    first[0].x,first[0].y,
-                                    first[1].x,first[1].y);
-                       (void) ConcatenateString(&path,message);
-                     }
-                   in_subpath=False;
-                 }
-             }
-           break;
-         }
-       case 6:
-       case 7:
-       case 8:
-       default:
-         {
-           blob+=24;
-           length-=24;
-           break;
-         }
-       }
+        {
+        case 0:
+        case 3:
+          {
+            if (knot_count == 0)
+              {
+                /*
+                  Expected subpath length record
+                */
+                knot_count=ReadMSBShort(&blob,&length);
+                length=AdvanceBlob(22U,length,&blob);
+              }
+            else
+              {
+                length=AdvanceBlob(24U,length,&blob);
+              }
+            break;
+          }
+        case 1:
+        case 2:
+        case 4:
+        case 5:
+          {
+            if (knot_count == 0)
+              {
+                /*
+                  Unexpected subpath knot
+                */
+                length=AdvanceBlob(24U,length,&blob);
+              }
+            else
+              {
+                /*
+                  Add sub-path knot
+                */
+                for (i=0; i < 3; i++)
+                  {
+                    y=ReadMSBLong(&blob,&length);
+                    x=ReadMSBLong(&blob,&length);
+                    point[i].x=(double) x*columns/4096/4096;
+                    point[i].y=(double) y*rows/4096/4096;
+                  }
+                if (!in_subpath)
+                  {
+                    FormatString(message,"M %.6f,%.6f\n",
+                                 point[1].x,point[1].y);
+                    for (i=0; i < 3; i++)
+                      {
+                        first[i]=point[i];
+                        last[i]=point[i];
+                      }
+                  }
+                else
+                  {
+                    /*
+                      Handle special case when Bezier curves are used
+                      to describe straight lines.
+                    */
+                    if ((last[1].x == last[2].x) &&
+                        (last[1].y == last[2].y) &&
+                        (point[0].x == point[1].x) &&
+                        (point[0].y == point[1].y))
+                      {
+                        /*
+                          First control point equals first anchor
+                          point and last control point equals last
+                          anchow point. Straigt line between anchor
+                          points.
+                        */
+                        FormatString(message,"L %.6f,%.6f\n",
+                                     point[1].x,point[1].y);
+                      }
+                    else
+                      {
+                        FormatString(message,
+                                     "C %.6f,%.6f %.6f,%.6f %.6f,%.6f\n",
+                                     last[2].x,last[2].y,
+                                     point[0].x,point[0].y,
+                                     point[1].x,point[1].y);
+                      }
+                    for (i=0; i < 3; i++)
+                      last[i]=point[i];
+                  }
+                (void) ConcatenateString(&path,message);
+                in_subpath=True;
+                knot_count--;
+                /*
+                  Close the subpath if there are no more knots.
+                */
+                if (knot_count == 0)
+                  {
+                    /*
+                      Same special handling as above except we compare
+                      to the first point in the path and close the
+                      path.
+                    */
+                    if ((last[1].x == last[2].x) &&
+                        (last[1].y == last[2].y) &&
+                        (first[0].x == first[1].x) &&
+                        (first[0].y == first[1].y))
+                      {
+                        FormatString(message,
+                                     "L %.6f,%.6f Z\n",first[1].x,first[1].y);
+                      }
+                    else
+                      {
+                        FormatString(message,
+                                     "C %.6f,%.6f %.6f,%.6f %.6f,%.6f Z\n",
+                                     last[2].x,last[2].y,
+                                     first[0].x,first[0].y,
+                                     first[1].x,first[1].y);
+                        (void) ConcatenateString(&path,message);
+                      }
+                    in_subpath=False;
+                  }
+              }
+            break;
+          }
+        case 6:
+        case 7:
+        case 8:
+        default:
+          {
+            length=AdvanceBlob(24U,length,&blob);
+            break;
+          }
+        }
     }
   /*
     Returns an empty SVG image if the path has no knots.
@@ -958,34 +966,34 @@ Generate8BIMAttribute(Image *image,const char *key)
   while ((length > 0) && (status == False))
     {
       if (ReadByte(&info,&length) != '8')
-       continue;
+        continue;
       if (ReadByte(&info,&length) != 'B')
-       continue;
+        continue;
       if (ReadByte(&info,&length) != 'I')
-       continue;
+        continue;
       if (ReadByte(&info,&length) != 'M')
-       continue;
+        continue;
       id=ReadMSBShort(&info,&length);
       if (id < start)
-       continue;
+        continue;
       if (id > stop)
-       continue;
+        continue;
       if (resource != (char *)NULL)
         MagickFreeMemory(resource);
       count=ReadByte(&info,&length);
       if ((count > 0) && ((size_t) count <= length))
-       {
-         resource=(char *) MagickAllocateMemory(char *,
+        {
+          resource=(char *) MagickAllocateMemory(char *,
                                                  (size_t) count+MaxTextExtent);
-         if (resource != (char *) NULL)
-           {
-             for (i=0; i < count; i++)
-               resource[i]=(char) ReadByte(&info,&length);
-             resource[count]='\0';
-           }
-       }
+          if (resource != (char *) NULL)
+            {
+              for (i=0; i < count; i++)
+                resource[i]=(char) ReadByte(&info,&length);
+              resource[count]='\0';
+            }
+        }
       if (!(count & 0x01))
-       (void) ReadByte(&info,&length);
+        (void) ReadByte(&info,&length);
       count=ReadMSBLong(&info,&length);
       /*
         ReadMSBLong() can return negative values such as -1 or any
@@ -997,59 +1005,59 @@ Generate8BIMAttribute(Image *image,const char *key)
           continue;
         }
       if ((*name != '\0') && (*name != '#'))
-       {
-         if ((resource == (char *) NULL) ||
-             (LocaleCompare(name,resource) != 0))
-           {
-             /*
-               No name match, scroll forward and try next resource.
-             */
-             info+=count;
-             length-=count;
-             continue;
-           }
-       }
+        {
+          if ((resource == (char *) NULL) ||
+              (LocaleCompare(name,resource) != 0))
+            {
+              /*
+                No name match, scroll forward and try next resource.
+              */
+              info+=count;
+              length-=count;
+              continue;
+            }
+        }
       if ((*name == '#') && (sub_number != 1))
-       {
-         /*
-           No numbered match, scroll forward and try next resource.
-         */
-         sub_number--;
-         info+=count;
-         length-=count;
-         continue;
-       }
+        {
+          /*
+            No numbered match, scroll forward and try next resource.
+          */
+          sub_number--;
+          info+=count;
+          length-=count;
+          continue;
+        }
       /*
-       We have the resource of interest.
+        We have the resource of interest.
       */
       attribute=(char *) MagickAllocateMemory(char *,
                                               (size_t) count+MaxTextExtent);
       if (attribute != (char *) NULL)
-       {
-         (void) memcpy(attribute,(char *) info,(size_t) count);
-         attribute[count]='\0';
-         info+=count;
-         length-=count;
-         if ((id <= 1999) || (id >= 2999))
-           {
-             (void) SetImageAttribute(image,key,(const char *) attribute);
-           }
-         else
-           {
-             char
-               *path;
-             if (LocaleCompare("SVG",format) == 0)
-               path=TraceSVGClippingPath((unsigned char *) attribute,count,
-                                         image->columns,image->rows);
-             else
-               path=TracePSClippingPath((unsigned char *) attribute,count,
-                                        image->columns,image->rows);
-             (void) SetImageAttribute(image,key,(const char *) path);
-             MagickFreeMemory(path);
-           }
-         MagickFreeMemory(attribute);
-         status=True;
-       }
+        {
+          (void) memcpy(attribute,(char *) info,(size_t) count);
+          attribute[count]='\0';
+          info+=count;
+          length-=count;
+          if ((id <= 1999) || (id >= 2999))
+            {
+              (void) SetImageAttribute(image,key,(const char *) attribute);
+            }
+          else
+            {
+              char
+                *path;
+              if (LocaleCompare("SVG",format) == 0)
+                path=TraceSVGClippingPath((unsigned char *) attribute,count,
+                                          image->columns,image->rows);
+              else
+                path=TracePSClippingPath((unsigned char *) attribute,count,
+                                         image->columns,image->rows);
+              (void) SetImageAttribute(image,key,(const char *) path);
+              MagickFreeMemory(path);
+            }
+          MagickFreeMemory(attribute);
+          status=True;
+        }
     }
   if (resource != (char *)NULL)
     MagickFreeMemory(resource);
@@ -1359,19 +1367,19 @@ static const TagInfo
 */
 
 static const char *
-EXIFTagToDescription(int t, char *tag_description)
+EXIFTagToDescription(unsigned int t, char *tag_description)
 {
   unsigned int
     i;
 
-  for (i=0; i < sizeof(tag_table)/sizeof(tag_table[0]); i++)
+  for (i=0; i < ArraySize(tag_table); i++)
     {
       if (tag_table[i].tag == t)
-       {
-         (void) strlcpy(tag_description,tag_table[i].description,
-                        MaxTextExtent);
-         return tag_description;
-       }
+        {
+          (void) strlcpy(tag_description,tag_table[i].description,
+                         MaxTextExtent);
+          return tag_description;
+        }
     }
 
   FormatString(tag_description,"0x%04X",t);
@@ -1395,7 +1403,7 @@ EXIFDescriptionToTag(const char *description)
 }
 
 static const char *
-EXIFFormatToDescription(int f)
+EXIFFormatToDescription(unsigned int f)
 {
   const char
     *description;
@@ -1445,7 +1453,7 @@ EXIFFormatToDescription(int f)
   return description;
 }
 
-static int
+static unsigned int
   format_bytes[] =
   {
     0,
@@ -1463,55 +1471,61 @@ static int
     8  /* DOUBLE */
   };
 
-static short
-Read16s(int morder,void *ishort)
+static magick_int16_t
+Read16s(int morder,unsigned char *ishort)
 {
-  short
-    value;
+  union
+  {
+    magick_uint16_t u;
+    magick_int16_t s;
+  } value;
 
   if (morder)
-    value=(((unsigned char *) ishort)[0] << 8) | ((unsigned char *) ishort)[1];
+    value.u=((magick_uint16_t) ishort[0] << 8) | ishort[1];
   else
-    value=(((unsigned char *) ishort)[1] << 8) | ((unsigned char *) ishort)[0];
-  return(value);
+    value.u=((magick_uint16_t) ishort[1] << 8) | ishort[0];
+  return(value.s);
 }
 
-static unsigned short
-Read16u(int morder,void *ishort)
+static magick_uint16_t
+Read16u(int morder,unsigned char *ishort)
 {
-  unsigned short
+  magick_uint16_t
     value;
 
   if (morder)
-    value=(((unsigned char *) ishort)[0] << 8) | ((unsigned char *) ishort)[1];
+    value=((magick_uint16_t) ishort[0] << 8) | ishort[1];
   else
-    value=(((unsigned char *) ishort)[1] << 8) | ((unsigned char *) ishort)[0];
+    value=((magick_uint16_t) ishort[1] << 8) | ishort[0];
   return(value);
 }
 
-static long
-Read32s(int morder,void *ilong)
+static magick_int32_t
+Read32s(int morder,unsigned char *ilong)
 {
-  long
-    value;
+  union
+  {
+    magick_uint32_t u;
+    magick_int32_t s;
+  } value;
 
   if (morder)
-    value=(((char *) ilong)[0] << 24) | (((unsigned char *) ilong)[1] << 16) |
-      (((unsigned char *) ilong)[2] << 8) | (((unsigned char *) ilong)[3]);
+    value.u=((magick_uint32_t) ilong[0] << 24) | (ilong[1] << 16) |
+      (ilong[2] << 8) | (ilong[3]);
   else
-    value=(((char *) ilong)[3] << 24) | (((unsigned char *) ilong)[2] << 16) |
-      (((unsigned char *) ilong)[1] << 8 ) | (((unsigned char *) ilong)[0]);
-  return(value);
+    value.u=((magick_uint32_t) ilong[3] << 24) | (ilong[2] << 16) |
+      (ilong[1] << 8 ) | (ilong[0]);
+  return(value.s);
 }
 
-static unsigned long
-Read32u(int morder, void *ilong)
+static magick_uint32_t
+Read32u(int morder, unsigned char *ilong)
 {
-  return(Read32s(morder,ilong) & 0xffffffffUL);
+  return(Read32s(morder,ilong) & 0xffffffff);
 }
 
 static void
-Write16u(int morder, void *location, unsigned short value)
+Write16u(int morder, void *location, magick_uint16_t value)
 {
   char
     *pval;
@@ -1519,13 +1533,13 @@ Write16u(int morder, void *location, unsigned short value)
   pval = (char *)location;
   if (morder)
     {
-      *pval++ = (char)((value >> 8) & 0xffL);
-      *pval++ = (char)(value & 0xffL);
+      *pval++ = (char)((value >> 8) & 0xff);
+      *pval++ = (char)(value & 0xff);
     }
   else
     {
-      *pval++ = (char)(value & 0xffL);
-      *pval++ = (char)((value >> 8) & 0xffL);
+      *pval++ = (char)(value & 0xff);
+      *pval++ = (char)((value >> 8) & 0xff);
     }
 }
 
@@ -1573,7 +1587,7 @@ GenerateEXIFAttribute(Image *image,const char *specification)
 
   const unsigned char
     *profile_info;
-  
+
   size_t
     profile_length;
 
@@ -1584,19 +1598,19 @@ GenerateEXIFAttribute(Image *image,const char *specification)
   MagickBool
     debug=MagickFalse;
 
-  assert((sizeof(format_bytes)/sizeof(format_bytes[0])-1) == EXIF_NUM_FORMATS);
+  assert((ArraySize(format_bytes)-1) == EXIF_NUM_FORMATS);
 
   {
     const char *
       env_value;
-    
+
     /*
       Allow enabling debug of EXIF tags
     */
     if ((env_value=getenv("MAGICK_DEBUG_EXIF")))
       {
-       if (LocaleCompare(env_value,"TRUE") == 0)
-         debug=MagickTrue;
+        if (LocaleCompare(env_value,"TRUE") == 0)
+          debug=MagickTrue;
       }
   }
   gpsfound=MagickFalse;
@@ -1625,72 +1639,72 @@ GenerateEXIFAttribute(Image *image,const char *specification)
   switch(*key)
     {
       /*
-       Caller has asked for all the tags in the EXIF data.
+        Caller has asked for all the tags in the EXIF data.
       */
     case '*':
       {
-       tag=0;
-       all=1; /* return the data in description=value format */
-       break;
+        tag=0;
+        all=1; /* return the data in description=value format */
+        break;
       }
     case '!':
       {
-       tag=0;
-       all=2; /* return the data in tageid=value format */
-       break;
+        tag=0;
+        all=2; /* return the data in tageid=value format */
+        break;
       }
       /*
-       Check for a hex based tag specification first.
+        Check for a hex based tag specification first.
       */
     case '#':
       {
-       char
-         c;
-
-       size_t
-         n;
-
-       tag=0;
-       key++;
-       n=strlen(key);
-       if (n != 4)
-         goto generate_attribute_failure;
-       else
-         {
-           /*
-             Parse tag specification as a hex number.
-           */
-           n/=4;
-           do
-             {
-               for (i=(long) n-1; i >= 0; i--)
-                 {
-                   c=(*key++);
-                   tag<<=4;
-                   if ((c >= '0') && (c <= '9'))
-                     tag|=c-'0';
-                   else
-                     if ((c >= 'A') && (c <= 'F'))
-                       tag|=c-('A'-10);
-                     else
-                       if ((c >= 'a') && (c <= 'f'))
-                         tag|=c-('a'-10);
-                       else
-                         goto generate_attribute_failure;
-                 }
-             } while (*key != '\0');
-         }
-       break;
+        char
+          c;
+
+        size_t
+          n;
+
+        tag=0;
+        key++;
+        n=strlen(key);
+        if (n != 4)
+          goto generate_attribute_failure;
+        else
+          {
+            /*
+              Parse tag specification as a hex number.
+            */
+            n/=4;
+            do
+              {
+                for (i=(long) n-1; i >= 0; i--)
+                  {
+                    c=(*key++);
+                    tag<<=4;
+                    if ((c >= '0') && (c <= '9'))
+                      tag|=c-'0';
+                    else
+                      if ((c >= 'A') && (c <= 'F'))
+                        tag|=c-('A'-10);
+                      else
+                        if ((c >= 'a') && (c <= 'f'))
+                          tag|=c-('a'-10);
+                        else
+                          goto generate_attribute_failure;
+                  }
+              } while (*key != '\0');
+          }
+        break;
       }
     default:
       {
-       /*
-         Try to match the text with a tag name instead.
-       */
-       tag=EXIFDescriptionToTag(key);
-       if (debug)
-         fprintf(stderr,"Found tag %d for key \"%s\"\n",tag,key);
-       break;
+        /*
+          Try to match the text with a tag name instead.
+        */
+        tag=EXIFDescriptionToTag(key);
+        if (debug)
+          fprintf(stderr,"Found tag %d for key \"%s\"\n",tag,key);
+        break;
       }
     }
   if (tag < 0)
@@ -1700,17 +1714,17 @@ GenerateEXIFAttribute(Image *image,const char *specification)
   while (length != 0)
     {
       if (ReadByte(&info,&length) != 0x45)
-       continue;
+        continue;
       if (ReadByte(&info,&length) != 0x78)
-       continue;
+        continue;
       if (ReadByte(&info,&length) != 0x69)
-       continue;
+        continue;
       if (ReadByte(&info,&length) != 0x66)
-       continue;
+        continue;
       if (ReadByte(&info,&length) != 0x00)
-       continue;
+        continue;
       if (ReadByte(&info,&length) != 0x00)
-       continue;
+        continue;
       break;
     }
   if (length < 16)
@@ -1762,328 +1776,333 @@ GenerateEXIFAttribute(Image *image,const char *specification)
       if (nde > MAX_TAGS_PER_IFD)
         nde=MAX_TAGS_PER_IFD;
       for (; de < nde; de++)
-       {
-         unsigned int
-           n;
+        {
+          size_t
+            n;
 
-         int
-           t,
-           f,
-           c;
+          unsigned int
+            c,
+            f,
+            t;
 
-         unsigned char
-           *pde,
+          unsigned char
+            *pde,
             *pval;
 
-         pde=(unsigned char *) (ifdp+2+(12*de));
+          pde=(unsigned char *) (ifdp+2+(12*de));
           if (pde + 12 > tiffp + length)
             {
               if (debug)
                 fprintf(stderr, "EXIF: Invalid Exif, entry is beyond metadata limit.\n");
               goto generate_attribute_failure;
             }
-         t=Read16u(morder,pde); /* get tag value */
-         f=Read16u(morder,pde+2); /* get the format */
-          if ((f < 0) ||
-              ((size_t) f >= sizeof(format_bytes)/sizeof(format_bytes[0])))
-           break;
-         c=(long) Read32u(morder,pde+4); /* get number of components */
-         n=c*format_bytes[f];
-         if (n <= 4)
-           pval=(unsigned char *) pde+8;
-         else
-           {
-             unsigned long
-               oval;
-
-             /*
-               The directory entry contains an offset.
-             */
-             oval=Read32u(morder,pde+8);
-             if ((oval+n) > length)
-               continue;
-             pval=(unsigned char *)(tiffp+oval);
-           }
-
-         if (debug)
-           {
-             fprintf(stderr,
-                     "EXIF: TagVal=%d  TagDescr=\"%s\" Format=%d  "
-                     "FormatDescr=\"%s\"  Components=%d\n",t,
-                     EXIFTagToDescription(t,tag_description),f,
-                     EXIFFormatToDescription(f),c);
-           }
-
-         if (gpsfound)
-           {
-             if ((t < GPS_TAG_START) || (t > GPS_TAG_STOP))
-               {
-                 if (debug)
-                   fprintf(stderr,
-                           "EXIF: Skipping bogus GPS IFD tag %d ...\n",t);
-                 continue;
-               }
-           }
-         else
-           {
-             if ((t < EXIF_TAG_START) || ( t > EXIF_TAG_STOP))
-               {
-                 if (debug)
-                   fprintf(stderr,
-                           "EXIF: Skipping bogus EXIF IFD tag %d ...\n",t);
-                 continue;
-               }
-           }
-
-         /*
-           Return values for all the tags, or for a specific requested tag.
-
-           Tags from the GPS sub-IFD are in a bit of a chicken and
-           egg situation in that the tag for the GPS sub-IFD will not
-           be seen unless we pass that tag through so it can be
-           processed.  So we pass the GPS_OFFSET tag through, but if
-           it was not requested, then we don't return a string value
-           for it.
-         */
-         if (all || (tag == t) || (GPS_OFFSET == t))
-           {
-             char
-               s[MaxTextExtent];
-
-             switch (f)
-               {
-               case EXIF_FMT_SBYTE:
-                 {
-                   /* 8-bit signed integer */
-                   FormatString(s,"%ld",(long) (*(char *) pval));
-                   value=AllocateString(s);
-                   break;
-                 }
-               case EXIF_FMT_BYTE:
-                 {
-                   /* 8-bit unsigned integer */
-                   value=MagickAllocateMemory(char *,n+1);
-                   if (value != (char *) NULL)
-                     {
-                       unsigned int
-                         a;
-
-                       for (a=0; a < n; a++)
-                         {
-                           value[a]='.';
-                           if (isprint((int) pval[a]))
-                             value[a]=pval[a];
-                         }
-                       value[a]='\0';
-                       break;
-                     }
+          t=Read16u(morder,pde); /* get tag value */
+          f=Read16u(morder,pde+2); /* get the format */
+          if ((size_t) f >= ArraySize(format_bytes))
+            break;
+          c=Read32u(morder,pde+4); /* get number of components */
+          n=MagickArraySize(c,format_bytes[f]);
+          if ((n == 0) && (c != 0) && (format_bytes[f] != 0))
+            {
+              if (debug)
+                fprintf(stderr, "EXIF: Invalid Exif, too many components (%u).\n",c);
+              goto generate_attribute_failure;
+            }
+          if (n <= 4)
+            pval=(unsigned char *) pde+8;
+          else
+            {
+              unsigned long
+                oval;
+
+              /*
+                The directory entry contains an offset.
+              */
+              oval=Read32u(morder,pde+8);
+              if ((oval+n) > length)
+                continue;
+              pval=(unsigned char *)(tiffp+oval);
+            }
+
+          if (debug)
+            {
+              fprintf(stderr,
+                      "EXIF: TagVal=%d  TagDescr=\"%s\" Format=%d  "
+                      "FormatDescr=\"%s\"  Components=%u\n",t,
+                      EXIFTagToDescription(t,tag_description),f,
+                      EXIFFormatToDescription(f),c);
+            }
+
+          if (gpsfound)
+            {
+              if ((t < GPS_TAG_START) || (t > GPS_TAG_STOP))
+                {
+                  if (debug)
+                    fprintf(stderr,
+                            "EXIF: Skipping bogus GPS IFD tag %d ...\n",t);
+                  continue;
+                }
+            }
+          else
+            {
+              if ((t < EXIF_TAG_START) || ( t > EXIF_TAG_STOP))
+                {
+                  if (debug)
+                    fprintf(stderr,
+                            "EXIF: Skipping bogus EXIF IFD tag %d ...\n",t);
+                  continue;
+                }
+            }
+
+          /*
+            Return values for all the tags, or for a specific requested tag.
+
+            Tags from the GPS sub-IFD are in a bit of a chicken and
+            egg situation in that the tag for the GPS sub-IFD will not
+            be seen unless we pass that tag through so it can be
+            processed.  So we pass the GPS_OFFSET tag through, but if
+            it was not requested, then we don't return a string value
+            for it.
+          */
+          if (all || (tag == (int) t) || (GPS_OFFSET == t))
+            {
+              char
+                s[MaxTextExtent];
+
+              switch (f)
+                {
+                case EXIF_FMT_SBYTE:
+                  {
+                    /* 8-bit signed integer */
+                    FormatString(s,"%ld",(long) (*(char *) pval));
+                    value=AllocateString(s);
+                    break;
+                  }
+                case EXIF_FMT_BYTE:
+                  {
+                    /* 8-bit unsigned integer */
+                    value=MagickAllocateMemory(char *,n+1);
+                    if (value != (char *) NULL)
+                      {
+                        unsigned int
+                          a;
+
+                        for (a=0; a < n; a++)
+                          {
+                            value[a]='.';
+                            if (isprint((int) pval[a]))
+                              value[a]=pval[a];
+                          }
+                        value[a]='\0';
+                        break;
+                      }
 #if 0
-                   printf("format %u, length %u\n",f,n);
-                   FormatString(s,"%ld",(long) (*(unsigned char *) pval));
-                   value=AllocateString(s);
+                    printf("format %u, length %u\n",f,n);
+                    FormatString(s,"%ld",(long) (*(unsigned char *) pval));
+                    value=AllocateString(s);
 #endif
-                   break;
-                 }
-               case EXIF_FMT_SSHORT:
-                 {
-                   /* 16-bit signed integer */
-                   FormatString(s,"%hd",Read16u(morder,pval));
-                   value=AllocateString(s);
-                   break;
-                 }
-               case EXIF_FMT_USHORT:
-                 {
-                   /* 16-bit unsigned integer */
-                   FormatString(s,"%hu",Read16s(morder,pval));
-                   value=AllocateString(s);
-                   break;
-                 }
-               case EXIF_FMT_ULONG:
-                 {
-                   offset=Read32u(morder,pval);
-                   /*
-                     Only report value if this tag was requested.
-                   */
-                   if (all || (tag == t))
-                     {
-                       FormatString(s,"%lu",offset);
-                       value=AllocateString(s);
-                     }
-                   if (GPS_OFFSET == t)
-                     gpsoffset=offset;
-                   break;
-                 }
-               case EXIF_FMT_SLONG:
-                 {
-                   FormatString(s,"%ld",Read32s(morder,pval));
-                   value=AllocateString(s);
-                   break;
-                 }
-               case EXIF_FMT_URATIONAL:
-                 {
-                   if (gpsfound &&
-                       (t == GPS_LATITUDE ||
-                        t == GPS_LONGITUDE ||
-                        t == GPS_TIMESTAMP))
-                     {
-                       FormatString(s,"%ld/%ld,%ld/%ld,%ld/%ld"
-                                    ,Read32u(morder,pval),
-                                    Read32u(morder,4+(char *) pval)
-                                    ,Read32u(morder,8+(char *)pval),
-                                    Read32u(morder,12+(char *) pval)
-                                    ,Read32u(morder,16+(char *)pval),
-                                    Read32u(morder,20+(char *) pval)
-                                    );
-                     }
-                   else
-                     {
-                       FormatString(s,"%ld/%ld"
-                                    ,Read32u(morder,pval),
-                                    Read32u(morder,4+(char *) pval)
-                                    );
-                     }
-                   value=AllocateString(s);
-                   break;
-                 }
-               case EXIF_FMT_SRATIONAL:
-                 {
-                   FormatString(s,"%ld/%ld",Read32s(morder,pval),
-                                Read32s(morder,4+(char *) pval));
-                   value=AllocateString(s);
-                   break;
-                 }
-               case EXIF_FMT_SINGLE:
-                 {
-                   FormatString(s,"%f",(double) *(float *) pval);
-                   value=AllocateString(s);
-                   break;
-                 }
-               case EXIF_FMT_DOUBLE:
-                 {
-                   FormatString(s,"%f",*(double *) pval);
-                   value=AllocateString(s);
-                   break;
-                 }
-               default:
-               case EXIF_FMT_UNDEFINED:
-               case EXIF_FMT_STRING:
-                 {
-                   unsigned int
-                     a;
-
-                   size_t
-                     allocation_size;
-
-                   MagickBool
-                     binary=MagickFalse;
-
-                   allocation_size=n+1;
-                   for (a=0; a < n; a++)
-                     if (!(isprint((int) pval[a])))
-                       allocation_size += 3;
-
-                   value=MagickAllocateMemory(char *,allocation_size);
-                   if (value != (char *) NULL)
-                     {
-                       i=0;
-                       for (a=0; a < n; a++)
-                         {
-                           if ((f == EXIF_FMT_STRING) && (pval[a] == '\0'))
-                             break;
-                           if ((isprint((int) pval[a])) ||
-                               ((pval[a] == '\0') &&
-                                (a == (n-1) && (!binary))))
-                             {
-                               value[i++]=pval[a];
-                             }
-                           else
-                             {
-                               i += sprintf(&value[i],"\\%03o",
-                                            (unsigned int) pval[a]);
-                               binary |= MagickTrue;
-                             }
-                         }
-                       value[i]='\0';
-                     }
-                   break;
-                 }
-               }
-             if (value != (char *) NULL)
-               {
-                 const char
-                   *description;
-
-                 if (strlen(final) != 0)
-                   (void) ConcatenateString(&final,EXIF_DELIMITER);
-                 description=(const char *) NULL;
-                 switch (all)
-                   {
-                   case 1:
-                     {
-                       description=EXIFTagToDescription(t,tag_description);
-                       FormatString(s,"%.1024s=",description);
-                       (void) ConcatenateString(&final,s);
-                       break;
-                     }
-                   case 2:
-                     {
-                       FormatString(s,"#%04x=",t);
-                       (void) ConcatenateString(&final,s);
-                       break;
-                     }
-                   }
-                 (void) ConcatenateString(&final,value);
-                 MagickFreeMemory(value);
-               }
-           }
-         if (t == GPS_OFFSET && (gpsoffset != 0))
-           {
-             if ((gpsoffset < length) && (level < (DE_STACK_SIZE-2)))
-               {
-                 /*
-                   Push our current directory state onto the stack.
-                 */
-                 ifdstack[level]=ifdp;
-                 de++; /* bump to the next entry */
-                 destack[level]=de;
-                 gpsfoundstack[level]=gpsfound;
-                 level++;
-                 /*
-                   Push new state onto of stack to cause a jump.
-                 */
-                 ifdstack[level]=tiffp+gpsoffset;
-                 destack[level]=0;
-                 gpsfoundstack[level]=MagickTrue;
-                 level++;
-               }
-             gpsoffset=0;
-             break; /* break out of the for loop */
-           }
-
-         if ((t == TAG_EXIF_OFFSET) || (t == TAG_INTEROP_OFFSET))
-           {
-             offset=Read32u(morder,pval);
-             if ((offset < length) && (level < (DE_STACK_SIZE-2)))
-               {
-                 /*
-                   Push our current directory state onto the stack.
-                 */
-                 ifdstack[level]=ifdp;
-                 de++; /* bump to the next entry */
-                 destack[level]=de;
-                 gpsfoundstack[level]=gpsfound;
-                 level++;
-                 /*
-                   Push new state onto of stack to cause a jump.
-                 */
-                 ifdstack[level]=tiffp+offset;
-                 destack[level]=0;
-                 gpsfoundstack[level]=MagickFalse;
-                 level++;
-               }
-             break; /* break out of the for loop */
-           }
-       }
+                    break;
+                  }
+                case EXIF_FMT_SSHORT:
+                  {
+                    /* 16-bit signed integer */
+                    FormatString(s,"%hd",Read16u(morder,pval));
+                    value=AllocateString(s);
+                    break;
+                  }
+                case EXIF_FMT_USHORT:
+                  {
+                    /* 16-bit unsigned integer */
+                    FormatString(s,"%hu",Read16s(morder,pval));
+                    value=AllocateString(s);
+                    break;
+                  }
+                case EXIF_FMT_ULONG:
+                  {
+                    offset=Read32u(morder,pval);
+                    /*
+                      Only report value if this tag was requested.
+                    */
+                    if (all || (tag == (int) t))
+                      {
+                        FormatString(s,"%lu",offset);
+                        value=AllocateString(s);
+                      }
+                    if (GPS_OFFSET == t)
+                      gpsoffset=offset;
+                    break;
+                  }
+                case EXIF_FMT_SLONG:
+                  {
+                    FormatString(s,"%d",(int) Read32s(morder,pval));
+                    value=AllocateString(s);
+                    break;
+                  }
+                case EXIF_FMT_URATIONAL:
+                  {
+                    if (gpsfound &&
+                        (t == GPS_LATITUDE ||
+                         t == GPS_LONGITUDE ||
+                         t == GPS_TIMESTAMP))
+                      {
+                        FormatString(s,"%u/%u,%u/%u,%u/%u"
+                                     ,(unsigned) Read32u(morder,pval),
+                                     (unsigned) Read32u(morder,4+pval)
+                                     ,(unsigned) Read32u(morder,8+pval),
+                                     (unsigned) Read32u(morder,12+pval)
+                                     ,(unsigned) Read32u(morder,16+pval),
+                                     (unsigned) Read32u(morder,20+pval)
+                                     );
+                      }
+                    else
+                      {
+                        FormatString(s,"%u/%u"
+                                     ,(unsigned) Read32u(morder,pval),
+                                     (unsigned) Read32u(morder,4+pval)
+                                     );
+                      }
+                    value=AllocateString(s);
+                    break;
+                  }
+                case EXIF_FMT_SRATIONAL:
+                  {
+                    FormatString(s,"%d/%d",(int) Read32s(morder,pval),
+                                 (int) Read32s(morder,4+pval));
+                    value=AllocateString(s);
+                    break;
+                  }
+                case EXIF_FMT_SINGLE:
+                  {
+                    FormatString(s,"%f",(double) *(float *) pval);
+                    value=AllocateString(s);
+                    break;
+                  }
+                case EXIF_FMT_DOUBLE:
+                  {
+                    FormatString(s,"%f",*(double *) pval);
+                    value=AllocateString(s);
+                    break;
+                  }
+                default:
+                case EXIF_FMT_UNDEFINED:
+                case EXIF_FMT_STRING:
+                  {
+                    unsigned int
+                      a;
+
+                    size_t
+                      allocation_size;
+
+                    MagickBool
+                      binary=MagickFalse;
+
+                    allocation_size=n+1;
+                    for (a=0; a < n; a++)
+                      if (!(isprint((int) pval[a])))
+                        allocation_size += 3;
+
+                    value=MagickAllocateMemory(char *,allocation_size);
+                    if (value != (char *) NULL)
+                      {
+                        i=0;
+                        for (a=0; a < n; a++)
+                          {
+                            if ((f == EXIF_FMT_STRING) && (pval[a] == '\0'))
+                              break;
+                            if ((isprint((int) pval[a])) ||
+                                ((pval[a] == '\0') &&
+                                 (a == (n-1) && (!binary))))
+                              {
+                                value[i++]=pval[a];
+                              }
+                            else
+                              {
+                                i += sprintf(&value[i],"\\%03o",
+                                             (unsigned int) pval[a]);
+                                binary |= MagickTrue;
+                              }
+                          }
+                        value[i]='\0';
+                      }
+                    break;
+                  }
+                }
+              if (value != (char *) NULL)
+                {
+                  const char
+                    *description;
+
+                  if (strlen(final) != 0)
+                    (void) ConcatenateString(&final,EXIF_DELIMITER);
+                  description=(const char *) NULL;
+                  switch (all)
+                    {
+                    case 1:
+                      {
+                        description=EXIFTagToDescription(t,tag_description);
+                        FormatString(s,"%.1024s=",description);
+                        (void) ConcatenateString(&final,s);
+                        break;
+                      }
+                    case 2:
+                      {
+                        FormatString(s,"#%04x=",t);
+                        (void) ConcatenateString(&final,s);
+                        break;
+                      }
+                    }
+                  (void) ConcatenateString(&final,value);
+                  MagickFreeMemory(value);
+                }
+            }
+          if (t == GPS_OFFSET && (gpsoffset != 0))
+            {
+              if ((gpsoffset < length) && (level < (DE_STACK_SIZE-2)))
+                {
+                  /*
+                    Push our current directory state onto the stack.
+                  */
+                  ifdstack[level]=ifdp;
+                  de++; /* bump to the next entry */
+                  destack[level]=de;
+                  gpsfoundstack[level]=gpsfound;
+                  level++;
+                  /*
+                    Push new state onto of stack to cause a jump.
+                  */
+                  ifdstack[level]=tiffp+gpsoffset;
+                  destack[level]=0;
+                  gpsfoundstack[level]=MagickTrue;
+                  level++;
+                }
+              gpsoffset=0;
+              break; /* break out of the for loop */
+            }
+
+          if ((t == TAG_EXIF_OFFSET) || (t == TAG_INTEROP_OFFSET))
+            {
+              offset=Read32u(morder,pval);
+              if ((offset < length) && (level < (DE_STACK_SIZE-2)))
+                {
+                  /*
+                    Push our current directory state onto the stack.
+                  */
+                  ifdstack[level]=ifdp;
+                  de++; /* bump to the next entry */
+                  destack[level]=de;
+                  gpsfoundstack[level]=gpsfound;
+                  level++;
+                  /*
+                    Push new state onto of stack to cause a jump.
+                  */
+                  ifdstack[level]=tiffp+offset;
+                  destack[level]=0;
+                  gpsfoundstack[level]=MagickFalse;
+                  level++;
+                }
+              break; /* break out of the for loop */
+            }
+        }
     } while (level > 0);
   if (strlen(final) == 0)
     (void) ConcatenateString(&final,"unknown");
@@ -2285,7 +2304,7 @@ GetImageClippingPathAttribute(const Image *image)
 */
 MagickExport const ImageAttribute *
 GetImageInfoAttribute(const ImageInfo *image_info,const Image *image,
-                     const char *key)
+                      const char *key)
 {
   char
     attribute[MaxTextExtent],
@@ -2296,191 +2315,191 @@ GetImageInfoAttribute(const ImageInfo *image_info,const Image *image,
     {
     case 'b':
       {
-       if (LocaleNCompare("base",key,2) == 0)
-         {
-           GetPathComponent(image->magick_filename,BasePath,filename);
-           (void) strlcpy(attribute,filename,MaxTextExtent);
-           break;
-         }
-       break;
+        if (LocaleNCompare("base",key,2) == 0)
+          {
+            GetPathComponent(image->magick_filename,BasePath,filename);
+            (void) strlcpy(attribute,filename,MaxTextExtent);
+            break;
+          }
+        break;
       }
     case 'd':
       {
-       if (LocaleNCompare("depth",key,2) == 0)
-         {
-           FormatString(attribute,"%u",image->depth);
-           break;
-         }
-       if (LocaleNCompare("directory",key,2) == 0)
-         {
-           GetPathComponent(image->magick_filename,HeadPath,filename);
-           (void) strlcpy(attribute,filename,MaxTextExtent);
-           break;
-         }
-       break;
+        if (LocaleNCompare("depth",key,2) == 0)
+          {
+            FormatString(attribute,"%u",image->depth);
+            break;
+          }
+        if (LocaleNCompare("directory",key,2) == 0)
+          {
+            GetPathComponent(image->magick_filename,HeadPath,filename);
+            (void) strlcpy(attribute,filename,MaxTextExtent);
+            break;
+          }
+        break;
       }
     case 'e':
       {
-       if (LocaleNCompare("extension",key,2) == 0)
-         {
-           GetPathComponent(image->magick_filename,ExtensionPath,filename);
-           (void) strlcpy(attribute,filename,MaxTextExtent);
-           break;
-         }
-       break;
+        if (LocaleNCompare("extension",key,2) == 0)
+          {
+            GetPathComponent(image->magick_filename,ExtensionPath,filename);
+            (void) strlcpy(attribute,filename,MaxTextExtent);
+            break;
+          }
+        break;
       }
     case 'g':
       {
-       if (LocaleNCompare("group",key,2) == 0)
-         {
-           FormatString(attribute,"0x%lx",image_info->group);
-           break;
-         }
-       break;
+        if (LocaleNCompare("group",key,2) == 0)
+          {
+            FormatString(attribute,"0x%lx",image_info->group);
+            break;
+          }
+        break;
       }
     case 'h':
       {
-       if (LocaleNCompare("height",key,2) == 0)
-         {
-           FormatString(attribute,"%lu",
-                        image->magick_rows ? image->magick_rows : 256L);
-           break;
-         }
-       break;
+        if (LocaleNCompare("height",key,2) == 0)
+          {
+            FormatString(attribute,"%lu",
+                         image->magick_rows ? image->magick_rows : 256L);
+            break;
+          }
+        break;
       }
     case 'i':
       {
-       if (LocaleNCompare("input",key,2) == 0)
-         {
-           (void) strlcpy(attribute,image->filename,MaxTextExtent);
-           break;
-         }
-       break;
+        if (LocaleNCompare("input",key,2) == 0)
+          {
+            (void) strlcpy(attribute,image->filename,MaxTextExtent);
+            break;
+          }
+        break;
       }
     case 'm':
       {
-       if (LocaleNCompare("magick",key,2) == 0)
-         {
-           (void) strlcpy(attribute,image->magick,MaxTextExtent);
-           break;
-         }
-       break;
+        if (LocaleNCompare("magick",key,2) == 0)
+          {
+            (void) strlcpy(attribute,image->magick,MaxTextExtent);
+            break;
+          }
+        break;
       }
     case 'n':
       {
-       if (LocaleNCompare("name",key,2) == 0)
-         {
-           (void) strlcpy(attribute,filename,MaxTextExtent);
-           break;
-         }
-       break;
+        if (LocaleNCompare("name",key,2) == 0)
+          {
+            (void) strlcpy(attribute,filename,MaxTextExtent);
+            break;
+          }
+        break;
       }
     case 's':
       {
-       if (LocaleNCompare("size",key,2) == 0)
-         {
-           char
-             format[MaxTextExtent];
-
-           FormatSize(GetBlobSize(image),format);
-           FormatString(attribute,"%.1024s",format);
-           break;
-         }
-       if (LocaleNCompare("scene",key,2) == 0)
-         {
-           FormatString(attribute,"%lu",image->scene);
-           if (image_info->subrange != 0)
-             FormatString(attribute,"%lu",image_info->subimage);
-           break;
-         }
-       if (LocaleNCompare("scenes",key,6) == 0)
-         {
-           FormatString(attribute,"%lu",
-                        (unsigned long) GetImageListLength(image));
-           break;
-         }
-       break;
+        if (LocaleNCompare("size",key,2) == 0)
+          {
+            char
+              format[MaxTextExtent];
+
+            FormatSize(GetBlobSize(image),format);
+            FormatString(attribute,"%.1024s",format);
+            break;
+          }
+        if (LocaleNCompare("scene",key,2) == 0)
+          {
+            FormatString(attribute,"%lu",image->scene);
+            if (image_info->subrange != 0)
+              FormatString(attribute,"%lu",image_info->subimage);
+            break;
+          }
+        if (LocaleNCompare("scenes",key,6) == 0)
+          {
+            FormatString(attribute,"%lu",
+                         (unsigned long) GetImageListLength(image));
+            break;
+          }
+        break;
       }
     case 'o':
       {
-       if (LocaleNCompare("output",key,2) == 0)
-         {
-           (void) strlcpy(attribute,image_info->filename,MaxTextExtent);
-           break;
-         }
-       break;
+        if (LocaleNCompare("output",key,2) == 0)
+          {
+            (void) strlcpy(attribute,image_info->filename,MaxTextExtent);
+            break;
+          }
+        break;
       }
     case 'p':
       {
-       if (LocaleNCompare("page",key,2) == 0)
-         {
-           register const Image
-             *p;
-
-           unsigned int
-             page;
-
-           p=image;
-           for (page=1; p->previous != (Image *) NULL; page++)
-             p=p->previous;
-           FormatString(attribute,"%u",page);
-           break;
-         }
-       break;
+        if (LocaleNCompare("page",key,2) == 0)
+          {
+            register const Image
+              *p;
+
+            unsigned int
+              page;
+
+            p=image;
+            for (page=1; p->previous != (Image *) NULL; page++)
+              p=p->previous;
+            FormatString(attribute,"%u",page);
+            break;
+          }
+        break;
       }
     case 'u':
       {
-       if (LocaleNCompare("unique",key,2) == 0)
-         {
-           (void) strlcpy(filename,image_info->unique,MaxTextExtent);
-           if (*filename == '\0')
-             if(!AcquireTemporaryFileName(filename))
-               return((ImageAttribute *) NULL);
-           (void) strlcpy(attribute,filename,MaxTextExtent);
-           break;
-         }
-       break;
+        if (LocaleNCompare("unique",key,2) == 0)
+          {
+            (void) strlcpy(filename,image_info->unique,MaxTextExtent);
+            if (*filename == '\0')
+              if(!AcquireTemporaryFileName(filename))
+                return((ImageAttribute *) NULL);
+            (void) strlcpy(attribute,filename,MaxTextExtent);
+            break;
+          }
+        break;
       }
     case 'w':
       {
-       if (LocaleNCompare("width",key,2) == 0)
-         {
-           FormatString(attribute,"%lu",
-                        image->magick_columns ? image->magick_columns : 256L);
-           break;
-         }
-       break;
+        if (LocaleNCompare("width",key,2) == 0)
+          {
+            FormatString(attribute,"%lu",
+                         image->magick_columns ? image->magick_columns : 256L);
+            break;
+          }
+        break;
       }
     case 'x':
       {
-       if (LocaleNCompare("xresolution",key,2) == 0)
-         {
-           FormatString(attribute,"%g",image->x_resolution);
-           break;
-         }
-       break;
+        if (LocaleNCompare("xresolution",key,2) == 0)
+          {
+            FormatString(attribute,"%g",image->x_resolution);
+            break;
+          }
+        break;
       }
     case 'y':
       {
-       if (LocaleNCompare("yresolution",key,2) == 0)
-         {
-           FormatString(attribute,"%g",image->y_resolution);
-           break;
-         }
-       break;
+        if (LocaleNCompare("yresolution",key,2) == 0)
+          {
+            FormatString(attribute,"%g",image->y_resolution);
+            break;
+          }
+        break;
       }
     case 'z':
       {
-       if (LocaleNCompare("zero",key,2) == 0)
-         {
-           (void) strlcpy(filename,image_info->zero,MaxTextExtent);
-           if (*filename == '\0')
-             if(!AcquireTemporaryFileName(filename))
-               return((ImageAttribute *) NULL);
-           (void) strlcpy(attribute,filename,MaxTextExtent);
-           break;
-         }
-       break;
+        if (LocaleNCompare("zero",key,2) == 0)
+          {
+            (void) strlcpy(filename,image_info->zero,MaxTextExtent);
+            if (*filename == '\0')
+              if(!AcquireTemporaryFileName(filename))
+                return((ImageAttribute *) NULL);
+            (void) strlcpy(attribute,filename,MaxTextExtent);
+            break;
+          }
+        break;
       }
     }
   if (strlen(image->magick_filename) != 0)
@@ -2584,7 +2603,7 @@ FindEXIFAttribute(const unsigned char *profile_info,
 
   attribp = (unsigned char *)NULL;
 
-  assert((sizeof(format_bytes)/sizeof(format_bytes[0])-1) == EXIF_NUM_FORMATS);
+  assert((ArraySize(format_bytes)-1) == EXIF_NUM_FORMATS);
 
   {
     const char *
@@ -2670,13 +2689,13 @@ FindEXIFAttribute(const unsigned char *profile_info,
         nde=MAX_TAGS_PER_IFD;
       for (; de < nde; de++)
         {
-          unsigned int
+          size_t
             n;
 
-          int
-            t,
+          unsigned int
+            c,
             f,
-            c;
+            t;
 
           unsigned char
             *pde,
@@ -2692,11 +2711,16 @@ FindEXIFAttribute(const unsigned char *profile_info,
             }
           t=Read16u(morder,pde); /* get tag value */
           f=Read16u(morder,pde+2); /* get the format */
-          if ((f < 0) ||
-              ((size_t) f >= sizeof(format_bytes)/sizeof(format_bytes[0])))
+          if ((size_t) f >= ArraySize(format_bytes))
             break;
-          c=(long) Read32u(morder,pde+4); /* get number of components */
-          n=c*format_bytes[f];
+          c=Read32u(morder,pde+4); /* get number of components */
+          n=MagickArraySize(c,format_bytes[f]);
+          if ((n == 0) && (c != 0) && (format_bytes[f] != 0))
+            {
+              if (debug)
+                fprintf(stderr, "EXIF: Invalid Exif, too many components (%u).\n",c);
+              goto find_attribute_failure;
+            }
           if (n <= 4)
             pval=(unsigned char *) pde+8;
           else
@@ -2717,7 +2741,7 @@ FindEXIFAttribute(const unsigned char *profile_info,
             {
               fprintf(stderr,
                   "EXIF: TagVal=%d  TagDescr=\"%s\" Format=%d  "
-                  "FormatDescr=\"%s\"  Components=%d\n",t,
+                  "FormatDescr=\"%s\"  Components=%u\n",t,
                   EXIFTagToDescription(t,tag_description),f,
                   EXIFFormatToDescription(f),c);
             }
index 9567648..b0d8393 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Methods to Get/Set/Destroy Image Text Attributes.
 */
 #ifndef _MAGICK_ATTRIBUTE_H
index aba6120..56721f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2008 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2003 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -66,7 +66,7 @@ MagickExport Image *AverageImages(const Image *image,ExceptionInfo *exception)
 
   double
     number_scenes;
-    
+
   unsigned long
     number_pixels;
 
@@ -86,7 +86,7 @@ MagickExport Image *AverageImages(const Image *image,ExceptionInfo *exception)
   {
     const Image
       *next;
-      
+
     for (next=image; next != (Image *) NULL; next=next->next)
       {
         if ((next->columns != image->columns) || (next->rows != image->rows))
@@ -136,9 +136,6 @@ MagickExport Image *AverageImages(const Image *image,ExceptionInfo *exception)
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_AverageImages)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -213,19 +210,22 @@ MagickExport Image *AverageImages(const Image *image,ExceptionInfo *exception)
         }
 
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_AverageImages)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,average_image->rows))
-          if (!MagickMonitorFormatted(row_count,average_image->rows,exception,
-                                      "[%s,...,%s] Average image sequence...",
-                                      image->filename,last_image->filename))
-            thread_status=MagickFail;
-      
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,average_image->rows))
+        if (!MagickMonitorFormatted(row_count,average_image->rows,exception,
+                                    "[%s,...,%s] Average image sequence...",
+                                    image->filename,last_image->filename))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
 
   DestroyThreadViewDataSet(pixels_sums);
@@ -238,4 +238,3 @@ MagickExport Image *AverageImages(const Image *image,ExceptionInfo *exception)
 
   return(average_image);
 }
-
index b0c7ee0..88cc0d9 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 - 2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Image Averaging Methods.
 */
 #ifndef _MAGICK_AVERAGE_H
index 6fd852c..8c321bb 100644 (file)
@@ -1,13 +1,13 @@
 /*
   Copyright (C) 2003 - 2015 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
 
   Interfaces to deal with marshalling quantums to and from a bit-stream.
   Written by Bob Friesenhahn, September 2003
+
 */
 
 #include "magick/studio.h"
@@ -32,7 +32,7 @@ static const unsigned int BitAndMasks[33] =
   Initialize Bit Stream for reading
 */
 MagickExport void MagickBitStreamInitializeRead(BitStreamReadHandle *bit_stream,
-                                               const unsigned char *bytes)
+                                                const unsigned char *bytes)
 {
   bit_stream->bytes          = bytes;
   bit_stream->bits_remaining = 8;
@@ -42,53 +42,53 @@ MagickExport void MagickBitStreamInitializeRead(BitStreamReadHandle *bit_stream,
   Return the requested number of bits from the current position in a
   bit stream. Stream is read in most-significant bit/byte "big endian"
   order.
-  
+
   bit_stream      - already initialized bit stream.
   requested_bits  - number of bits to read
 */
 MagickExport unsigned int MagickBitStreamMSBRead(BitStreamReadHandle *bit_stream,
-                                                const unsigned int requested_bits)
+                                                 const unsigned int requested_bits)
 {
   register unsigned int
     remaining_quantum_bits,
     quantum;
-  
+
   remaining_quantum_bits = requested_bits;
   quantum = 0;
-  
+
   while (remaining_quantum_bits != 0)
     {
       register unsigned int
-       octet_bits;
-      
+        octet_bits;
+
       octet_bits = remaining_quantum_bits;
       if (octet_bits > bit_stream->bits_remaining)
-       octet_bits = bit_stream->bits_remaining;
-      
+        octet_bits = bit_stream->bits_remaining;
+
       remaining_quantum_bits -= octet_bits;
       bit_stream->bits_remaining -= octet_bits;
-      
+
       quantum = (quantum << octet_bits) |
-       ((*bit_stream->bytes >> (bit_stream->bits_remaining))
-        & BitAndMasks[octet_bits]);
-      
+        ((*bit_stream->bytes >> (bit_stream->bits_remaining))
+         & BitAndMasks[octet_bits]);
+
       if (bit_stream->bits_remaining == 0)
-       {
-         bit_stream->bytes++;
-         bit_stream->bits_remaining=8;
-       }
+        {
+          bit_stream->bytes++;
+          bit_stream->bits_remaining=8;
+        }
     }
   return quantum;
 }
 
 /*
   Initialize Bit Stream for writing
-  
+
   bit_stream  - bit stream to initialize.
   bytes       - byte array to write bits to
 */
 MagickExport void MagickBitStreamInitializeWrite(BitStreamWriteHandle *bit_stream,
-                                                unsigned char *bytes)
+                                                 unsigned char *bytes)
 {
   bit_stream->bytes          = bytes;
   bit_stream->bits_remaining = 8;
@@ -98,99 +98,99 @@ MagickExport void MagickBitStreamInitializeWrite(BitStreamWriteHandle *bit_strea
   Write quantum using the specified number of bits at the current
   position in the bit stream. Stream is written in most-significant
   bit/byte "big endian" order.
-  
+
   bit_stream      - already initialized bit stream.
   requested_bits  - number of bits to write to stream.
   quantum         - value to write.
 */
 MagickExport void MagickBitStreamMSBWrite(BitStreamWriteHandle *bit_stream,
-                                         const unsigned int requested_bits,
-                                         const unsigned int quantum)
+                                          const unsigned int requested_bits,
+                                          const unsigned int quantum)
 {
   register unsigned int
     remaining_quantum_bits = requested_bits;
-  
+
   while (remaining_quantum_bits != 0)
     {
       register unsigned int
-       octet_bits;
-      
+        octet_bits;
+
       octet_bits = remaining_quantum_bits;
       if (octet_bits > bit_stream->bits_remaining)
-       octet_bits = bit_stream->bits_remaining;
+        octet_bits = bit_stream->bits_remaining;
 
       remaining_quantum_bits -= octet_bits;
 
       if (bit_stream->bits_remaining == 8)
-       *bit_stream->bytes = 0;
+        *bit_stream->bytes = 0;
 
       bit_stream->bits_remaining -= octet_bits;
 
       *bit_stream->bytes |=
-       (((quantum >> (remaining_quantum_bits)) &
-         BitAndMasks[octet_bits]) << (bit_stream->bits_remaining));
+        (((quantum >> (remaining_quantum_bits)) &
+          BitAndMasks[octet_bits]) << (bit_stream->bits_remaining));
 
       if (bit_stream->bits_remaining == 0)
-       {
-         bit_stream->bytes++;
-         bit_stream->bits_remaining=8;
-       }
+        {
+          bit_stream->bytes++;
+          bit_stream->bits_remaining=8;
+        }
     }
 }
-  
+
 /*
   Initialize Word Stream for reading
-  
+
   word_stream     - stream to initialize.
   read_func       - function to retrieve the next word.
   read_func_state - state to pass to read_func.
 */
 MagickExport void MagickWordStreamInitializeRead(WordStreamReadHandle *word_stream,
-                                                WordStreamReadFunc read_func,
-                                                void *read_func_state)
+                                                 WordStreamReadFunc read_func,
+                                                 void *read_func_state)
 {
   word_stream->word            = 0;
   word_stream->bits_remaining  = 0;
   word_stream->read_func       = read_func;
   word_stream->read_func_state = read_func_state;
 }
-  
+
 /*
   Return the requested number of bits from the current position in a
   32-bit word stream. Stream is read starting with the least significant
   bits of the word.
-  
+
   word_stream     - an initialized word reader stream.
   requested_bits  - number of bits to retrieve from the stream.
 */
 MagickExport unsigned int MagickWordStreamLSBRead(WordStreamReadHandle *word_stream,
-                                                 const unsigned int requested_bits)
+                                                  const unsigned int requested_bits)
 {
   register unsigned int
     remaining_quantum_bits,
     quantum;
-    
+
   remaining_quantum_bits = requested_bits;
   quantum = 0;
-    
+
   while (remaining_quantum_bits != 0)
     {
       register unsigned int
-       word_bits;
-        
+        word_bits;
+
       if (word_stream->bits_remaining == 0)
-       {
-         word_stream->word=word_stream->read_func(word_stream->read_func_state);
-         word_stream->bits_remaining=32;
-       }
-        
+        {
+          word_stream->word=word_stream->read_func(word_stream->read_func_state);
+          word_stream->bits_remaining=32;
+        }
+
       word_bits = remaining_quantum_bits;
       if (word_bits > word_stream->bits_remaining)
-       word_bits = word_stream->bits_remaining;
-        
+        word_bits = word_stream->bits_remaining;
+
       quantum |= (((word_stream->word >> (32-word_stream->bits_remaining))
-                  & BitAndMasks[word_bits]) << (requested_bits-remaining_quantum_bits));
-        
+                   & BitAndMasks[word_bits]) << (requested_bits-remaining_quantum_bits));
+
       remaining_quantum_bits -= word_bits;
       word_stream->bits_remaining -= word_bits;
     }
@@ -199,14 +199,14 @@ MagickExport unsigned int MagickWordStreamLSBRead(WordStreamReadHandle *word_str
 
 /*
   Initialize Word Stream for writing
-  
+
   word_stream      - stream to initialize.
   write_func_state - state to pass to write_func.
   write_func        - function to retrieve the next word.
 */
 MagickExport void MagickWordStreamInitializeWrite(WordStreamWriteHandle *word_stream,
-                                                 WordStreamWriteFunc write_func,
-                                                 void *write_func_state)
+                                                  WordStreamWriteFunc write_func,
+                                                  void *write_func_state)
 {
   word_stream->word             = 0U;
   word_stream->bits_remaining   = 32U;
@@ -218,18 +218,18 @@ MagickExport void MagickWordStreamInitializeWrite(WordStreamWriteHandle *word_st
   Write quantum using the specified number of bits at the current
   position in a 32-bit word stream. Samples are output to words
   starting at the least significant bits of the word.
-  
+
   Note that since a callback function is used to output the words,
   the remaining bits in the last word need to be flushed out by
   invoking MagickWordStreamLSBWriteFlush().
-  
+
   word_stream     - already initialized word stream.
   requested_bits  - number of bits to write to stream.
   quantum         - value to write.
 */
 MagickExport void MagickWordStreamLSBWrite(WordStreamWriteHandle *word_stream,
-                                          const unsigned int requested_bits,
-                                          const unsigned int quantum)
+                                           const unsigned int requested_bits,
+                                           const unsigned int quantum)
 {
   register unsigned int
     remaining_quantum_bits = requested_bits;
@@ -237,26 +237,26 @@ MagickExport void MagickWordStreamLSBWrite(WordStreamWriteHandle *word_stream,
   while (remaining_quantum_bits > 0U)
     {
       register unsigned int
-       word_bits;
+        word_bits;
 
       word_bits = remaining_quantum_bits;
       if (word_bits > word_stream->bits_remaining)
-       word_bits = word_stream->bits_remaining;
+        word_bits = word_stream->bits_remaining;
 
       word_stream->word |=
-       (((quantum >> (requested_bits-remaining_quantum_bits)) &
-         BitAndMasks[word_bits]) << (32-word_stream->bits_remaining));
+        (((quantum >> (requested_bits-remaining_quantum_bits)) &
+          BitAndMasks[word_bits]) << (32-word_stream->bits_remaining));
 
       remaining_quantum_bits -= word_bits;
       word_stream->bits_remaining -= word_bits;
 
       if (word_stream->bits_remaining == 0U)
-       {
-         (void) word_stream->write_func(word_stream->write_func_state,
-                                        word_stream->word);
-         word_stream->word=0U;
-         word_stream->bits_remaining=32U;
-       }
+        {
+          (void) word_stream->write_func(word_stream->write_func_state,
+                                         word_stream->word);
+          word_stream->word=0U;
+          word_stream->bits_remaining=32U;
+        }
     }
 }
 
@@ -265,9 +265,9 @@ MagickExport void MagickWordStreamLSBWrite(WordStreamWriteHandle *word_stream,
   are set to zero.  Should be used to ensure that last word in word
   stream is written to the output.  May also be used to apply
   word-level padding at the end of an image row.
-  
+
   word_stream     - already initialized word stream.
-*/  
+*/
 MagickExport void MagickWordStreamLSBWriteFlush(WordStreamWriteHandle *word_stream)
 {
   if (word_stream->bits_remaining != 32U)
index 74f5bf9..3c9f7a6 100644 (file)
@@ -1,13 +1,13 @@
 /*
   Copyright (C) 2003, 2005, 2009 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
 
   Interfaces to deal with marshalling quantums to and from a bit-stream.
   Written by Bob Friesenhahn, September 2003
+
 */
 #ifndef _MAGICK_BIT_STREAM_H
 #define _MAGICK_BIT_STREAM_H
@@ -40,7 +40,7 @@ extern "C" {
     read_func_state  - state to pass to word reading function.
   */
   typedef unsigned long (*WordStreamReadFunc) (void *read_func_state);
-  
+
   /*
     Word stream word reader "handle"
   */
@@ -75,39 +75,39 @@ extern "C" {
 
   extern MagickExport void
   MagickBitStreamInitializeRead(BitStreamReadHandle *bit_stream,
-                               const unsigned char *bytes);
+                                const unsigned char *bytes);
 
   extern MagickExport unsigned int
   MagickBitStreamMSBRead(BitStreamReadHandle *bit_stream,
-                        const unsigned int requested_bits);
+                         const unsigned int requested_bits);
 
   extern MagickExport void
   MagickBitStreamInitializeWrite(BitStreamWriteHandle *bit_stream,
-                                unsigned char *bytes);
+                                 unsigned char *bytes);
 
   extern MagickExport void
   MagickBitStreamMSBWrite(BitStreamWriteHandle *bit_stream,
-                         const unsigned int requested_bits,
-                         const unsigned int quantum);
+                          const unsigned int requested_bits,
+                          const unsigned int quantum);
 
   extern MagickExport void
   MagickWordStreamInitializeRead(WordStreamReadHandle *word_stream,
-                                WordStreamReadFunc read_func,
-                                void *read_func_state);
+                                 WordStreamReadFunc read_func,
+                                 void *read_func_state);
 
   extern MagickExport unsigned int
   MagickWordStreamLSBRead(WordStreamReadHandle *word_stream,
-                         const unsigned int requested_bits);
+                          const unsigned int requested_bits);
 
   extern MagickExport void
   MagickWordStreamInitializeWrite(WordStreamWriteHandle *word_stream,
-                                 WordStreamWriteFunc write_func,
-                                 void *write_func_state);
+                                  WordStreamWriteFunc write_func,
+                                  void *write_func_state);
 
   extern MagickExport void
   MagickWordStreamLSBWrite(WordStreamWriteHandle *word_stream,
-                          const unsigned int requested_bits,
-                          const unsigned int quantum);
+                           const unsigned int requested_bits,
+                           const unsigned int quantum);
 
   extern MagickExport void
   MagickWordStreamLSBWriteFlush(WordStreamWriteHandle *word_stream);
index 9d1876d..56028ed 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -118,7 +118,8 @@ struct _BlobInfo
     exempt,             /* True if file descriptor should not be closed.*/
     temporary;          /* Associated file is a temporary file */
 
-  unsigned int
+  int
+    first_errno,        /* First reported errno */
     status;             /* Error status. 0 == good */
 
   StreamType
@@ -255,19 +256,23 @@ static const char *BlobStreamTypeToString(StreamType stream_type)
 static inline size_t ReadBlobStream(Image *image,const size_t length,
                                     void **data)
 {
+  BlobInfo
+    * restrict blob;
+
   size_t
     available;
 
-  if (image->blob->offset >= (magick_off_t) image->blob->length)
+  blob=image->blob;
+  if (blob->offset >= (magick_off_t) blob->length)
     {
-      image->blob->eof=MagickTrue;
+      blob->eof=MagickTrue;
       return 0;
     }
-  *data=(void *)(image->blob->data+image->blob->offset);
-  available=Min(length,image->blob->length-image->blob->offset);
-  image->blob->offset+=available;
+  *data=(void *)(blob->data+blob->offset);
+  available=Min(length,blob->length-blob->offset);
+  blob->offset+=available;
   if (available < length)
-    image->blob->eof=True;
+    blob->eof=True;
   return available;
 }
 \f
@@ -302,36 +307,56 @@ static inline size_t ReadBlobStream(Image *image,const size_t length,
 */
 static void *ExtendBlobWriteStream(Image *image,const size_t length)
 {
-  if ((image->blob->offset+length) >= image->blob->extent)
+  BlobInfo
+    * restrict blob;
+
+  blob=image->blob;
+  if ((blob->offset+length) >= blob->extent)
     {
       /* In-memory Blob */
-      image->blob->quantum<<=1;
-      image->blob->extent+=length+image->blob->quantum;
-      MagickReallocMemory(unsigned char *,image->blob->data,image->blob->extent+1);
+      blob->quantum<<=1;
+      blob->extent+=length+blob->quantum;
+#if 0
+      if (image->logging)
+        (void) LogMagickEvent(BlobEvent,GetMagickModule(),
+                              "MagickReallocMemory blob->data=%p,"
+                              " blob->extent=%" MAGICK_SIZE_T_F "u",
+                              blob->data, (MAGICK_SIZE_T) blob->extent);
+#endif
+      MagickReallocMemory(unsigned char *,blob->data,blob->extent+1);
       (void) SyncBlob(image);
-      if (image->blob->data == (unsigned char *) NULL)
+      if (blob->data == (unsigned char *) NULL)
         {
-          DetachBlob(image->blob);
+#if 0
+          if (image->logging)
+            (void) LogMagickEvent(BlobEvent,GetMagickModule(),
+                                  "MagickReallocMemory failed! Detatching Blob...");
+#endif
+          DetachBlob(blob);
           return 0;
         }
     }
-  return image->blob->data+image->blob->offset;
+  return blob->data+blob->offset;
 }
 static inline size_t WriteBlobStream(Image *image,const size_t length,
                                      const void *data)
 {
+  BlobInfo
+    * restrict blob;
+
   void
     *dest;
 
-  dest=image->blob->data+image->blob->offset;
-  if ((image->blob->offset+length) >= image->blob->extent)
+  blob=image->blob;
+  dest=blob->data+blob->offset;
+  if ((blob->offset+length) >= blob->extent)
     if ((dest=ExtendBlobWriteStream(image,length)) == (void *) NULL)
       return 0;
 
   (void) memcpy(dest,data,length);
-  image->blob->offset+=length;
-  if (image->blob->offset > (magick_off_t) image->blob->length)
-    image->blob->length=image->blob->offset;
+  blob->offset+=length;
+  if (blob->offset > (magick_off_t) blob->length)
+    blob->length=blob->offset;
   return length;
 }
 \f
@@ -408,11 +433,14 @@ MagickExport void AttachBlob(BlobInfo *blob_info,const void *blob,
 */
 MagickExport MagickBool BlobIsSeekable(const Image *image)
 {
+  BlobInfo
+    * restrict blob;
+
   assert(image != (const Image *) NULL);
   assert(image->blob != (const BlobInfo *) NULL);
 
-  return ((image->blob->type == FileStream) ||
-          (image->blob->type == BlobStream));
+  blob=image->blob;
+  return ((blob->type == FileStream) || (blob->type == BlobStream));
 }
 \f
 /*
@@ -446,23 +474,35 @@ MagickExport MagickBool BlobIsSeekable(const Image *image)
 */
 MagickExport MagickPassFail BlobReserveSize(Image *image, magick_off_t size)
 {
+  BlobInfo
+    * restrict blob;
+
   MagickPassFail
     status;
 
+  assert(image != (const Image *) NULL);
+  assert(image->blob != (const BlobInfo *) NULL);
+
+  blob=image->blob;
   status=MagickPass;
 
-  if ((FileStream == image->blob->type) ||
-      ((BlobStream == image->blob->type) &&
-       (image->blob->mapped) && (image->blob->handle.std != (FILE *) NULL)))
+  if ((FileStream == blob->type) ||
+      ((BlobStream == blob->type) &&
+       (blob->mapped) && (blob->handle.std != (FILE *) NULL)))
     {
 #if defined(HAVE_POSIX_FALLOCATE)
       /*
         FIXME: Solaris 11.2 documentation says that posix_fallocate()
-        reports EINVAL for anything but UFS */
+        reports EINVAL for anything but UFS.
+
+        FreeBSD 11 (as of changeset r325320) now reports EINVAL when
+        used on a ZFS filesystem and Illumos and ZFS-On-Linux (ZoL)
+        are reported to do the same thing.
+      */
       int
         err_status;
 
-      if ((err_status=posix_fallocate(fileno(image->blob->handle.std),
+      if ((err_status=posix_fallocate(fileno(blob->handle.std),
                                       0UL, size)) != 0)
         {
           /* ThrowException(&image->exception,BlobError,UnableToWriteBlob,strerror(err_status)); */
@@ -471,21 +511,21 @@ MagickExport MagickPassFail BlobReserveSize(Image *image, magick_off_t size)
 #endif /* HAVE_POSIX_FALLOCATE */
     }
 
-  if (BlobStream == image->blob->type)
+  if (BlobStream == blob->type)
   {
     /*
       In-memory blob
     */
-    image->blob->extent=size;
-    MagickReallocMemory(unsigned char *,image->blob->data,image->blob->extent+1);
+    blob->extent=size;
+    MagickReallocMemory(unsigned char *,blob->data,blob->extent+1);
     (void) SyncBlob(image);
-        
-    if (image->blob->data == (unsigned char *) NULL)
+
+    if (blob->data == (unsigned char *) NULL)
       {
         ThrowException(&image->exception,ResourceLimitError,MemoryAllocationFailed,
                        NULL);
 
-        DetachBlob(image->blob);
+        DetachBlob(blob);
         status=MagickFail;
       }
   }
@@ -533,7 +573,7 @@ MagickExport MagickPassFail BlobReserveSize(Image *image, magick_off_t size)
 %
 */
 MagickExport MagickPassFail BlobToFile(const char *filename,const void *blob,
-                                      const size_t length,ExceptionInfo *exception)
+                                       const size_t length,ExceptionInfo *exception)
 {
   ssize_t
     count;
@@ -550,7 +590,7 @@ MagickExport MagickPassFail BlobToFile(const char *filename,const void *blob,
   assert(filename != (const char *) NULL);
   assert(blob != (const void *) NULL);
   (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                       "Copying memory BLOB to file %s",filename);
+                        "Copying memory BLOB to file %s",filename);
   if (MagickConfirmAccess(FileWriteConfirmAccessMode,filename,exception)
       == MagickFail)
     return MagickFail;
@@ -563,7 +603,7 @@ MagickExport MagickPassFail BlobToFile(const char *filename,const void *blob,
   if (status != MagickFail)
     {
       const char
-       *env = NULL;
+        *env = NULL;
 
       size_t
         block_size;
@@ -571,10 +611,10 @@ MagickExport MagickPassFail BlobToFile(const char *filename,const void *blob,
       block_size=MagickGetFileSystemBlockSize();
 
       /*
-       Write data to file.
+        Write data to file.
       */
       for (i=0; i < length; i+=count)
-       {
+        {
           size_t
             remaining;
 
@@ -587,37 +627,37 @@ MagickExport MagickPassFail BlobToFile(const char *filename,const void *blob,
           else
             amount=(MAGICK_POSIX_IO_SIZE_T) remaining;
 
-         count=write(file,(char *) blob+i,amount);
-         if (count <= 0)
-           break;
-       }
+          count=write(file,(char *) blob+i,amount);
+          if (count <= 0)
+            break;
+        }
 
       if (i < length)
-       {
-         if (status != MagickFail)
-           ThrowException(exception,BlobError,UnableToWriteBlob,filename);
-         status=MagickFail;
-       }
+        {
+          if (status != MagickFail)
+            ThrowException(exception,BlobError,UnableToWriteBlob,filename);
+          status=MagickFail;
+        }
 
       /*
-       Explicitly synchronize file to disk if requested.
+        Explicitly synchronize file to disk if requested.
       */
       env = getenv("MAGICK_IO_FSYNC");
       if ((env != (const char *) NULL) && (LocaleCompare(env,"TRUE") == 0))
-       {
-         if (fsync(file) == -1)
-           {
-             if (status != MagickFail)
-               ThrowException(exception,BlobError,UnableToWriteBlob,filename);
-             status=MagickFail;
-           }
-       }
+        {
+          if (fsync(file) == -1)
+            {
+              if (status != MagickFail)
+                ThrowException(exception,BlobError,UnableToWriteBlob,filename);
+              status=MagickFail;
+            }
+        }
       if (close(file) == -1)
-       {
-         if (status != MagickFail)
-           ThrowException(exception,BlobError,UnableToWriteBlob,filename);
-         status=MagickFail;
-       }
+        {
+          if (status != MagickFail)
+            ThrowException(exception,BlobError,UnableToWriteBlob,filename);
+          status=MagickFail;
+        }
     }
   return status;
 }
@@ -655,7 +695,7 @@ MagickExport MagickPassFail BlobToFile(const char *filename,const void *blob,
 %
 */
 MagickExport Image *BlobToImage(const ImageInfo *image_info,const void *blob,
-                               const size_t length,ExceptionInfo *exception)
+                                const size_t length,ExceptionInfo *exception)
 {
   const MagickInfo
     *magick_info;
@@ -671,13 +711,16 @@ MagickExport Image *BlobToImage(const ImageInfo *image_info,const void *blob,
   assert(exception != (ExceptionInfo *) NULL);
 
   image=(Image *) NULL;
-  (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Entering BlobToImage");
+  (void) LogMagickEvent(BlobEvent,GetMagickModule(),
+                        "Entering BlobToImage: blob=%p,"
+                        " length=%" MAGICK_SIZE_T_F "u",
+                        blob, (MAGICK_SIZE_T) length);
   if ((blob == (const void *) NULL) || (length == 0))
     {
       ThrowException(exception,OptionError,NullBlobArgument,
-                    image_info->magick);
+                     image_info->magick);
       (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                           "Leaving BlobToImage");
+                            "Leaving BlobToImage");
       return((Image *) NULL);
     }
   clone_info=CloneImageInfo(image_info);
@@ -689,12 +732,23 @@ MagickExport Image *BlobToImage(const ImageInfo *image_info,const void *blob,
   */
   if (clone_info->magick[0] == '\0')
     (void) SetImageInfo(clone_info,SETMAGICK_READ,exception);
+  (void) LogMagickEvent(BlobEvent,GetMagickModule(),
+                        "Blob magick=\"%s\"", clone_info->magick);
+  if (clone_info->magick[0] == '\0')
+    {
+      ThrowException(exception,BlobError,UnableToDeduceImageFormat,clone_info->filename);
+      DestroyImageInfo(clone_info);
+      (void) LogMagickEvent(BlobEvent,GetMagickModule(),
+                            "Leaving BlobToImage");
+      return((Image *) NULL);
+    }
   magick_info=GetMagickInfo(clone_info->magick,exception);
   if (magick_info == (const MagickInfo *) NULL)
     {
+      ThrowException(exception,BlobError,UnrecognizedImageFormat,clone_info->filename);
       DestroyImageInfo(clone_info);
       (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                           "Leaving BlobToImage");
+                            "Leaving BlobToImage");
       return((Image *) NULL);
     }
   if (magick_info->blob_support)
@@ -703,16 +757,19 @@ MagickExport Image *BlobToImage(const ImageInfo *image_info,const void *blob,
         Native blob support for this image format.
       */
       (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                           "Using native BLOB support");
+                            "Using native BLOB support");
       (void) strlcpy(clone_info->filename,image_info->filename,
-                    MaxTextExtent);
+                     MaxTextExtent);
       (void) strlcpy(clone_info->magick,image_info->magick,MaxTextExtent);
       image=ReadImage(clone_info,exception);
       if (image != (Image *) NULL)
         DetachBlob(image->blob);
       DestroyImageInfo(clone_info);
       (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                           "Leaving BlobToImage");
+                            "Leaving BlobToImage");
+      if ((image == (Image *) NULL) &&
+          (exception->severity < ErrorException))
+        ThrowException(exception,CoderError,DecodedImageNotReturned,"blob");
       return(image);
     }
   /*
@@ -723,49 +780,52 @@ MagickExport Image *BlobToImage(const ImageInfo *image_info,const void *blob,
       temporary_file[MaxTextExtent];
 
       (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                           "Using temporary file");
+                            "Using temporary file");
     clone_info->blob=(void *) NULL;
     clone_info->length=0;
-    
-    if(!AcquireTemporaryFileName(temporary_file))
+
+    if (!AcquireTemporaryFileName(temporary_file))
       {
-       ThrowException(exception,FileOpenError,UnableToCreateTemporaryFile,
-                      clone_info->filename);
+        ThrowException(exception,FileOpenError,UnableToCreateTemporaryFile,
+                       clone_info->filename);
       }
     else
       {
-       if (BlobToFile(temporary_file,blob,length,exception) != MagickFail)
-         {
-           clone_info->filename[0]='\0';
-           if (clone_info->magick[0] != '\0')
-             {
-               (void) strlcpy(clone_info->filename,clone_info->magick,sizeof(clone_info->filename));
-               (void) strlcat(clone_info->filename,":",sizeof(clone_info->filename));
-             }
-           (void) strlcat(clone_info->filename,temporary_file,sizeof(clone_info->filename));
-           image=ReadImage(clone_info,exception);
-           /*
-             Restore original user-provided file name field to images
-             in list so that user does not see a temporary file name.
-           */
-           if (image != (Image *) NULL)
-             {
-               Image
-                 *list_image;
-
-               list_image = GetFirstImageInList(image);
-               while (list_image != (Image *) NULL)
-                 {
-                   (void) strlcpy(list_image->magick_filename,image_info->filename,sizeof(list_image->magick_filename));
-                   (void) strlcpy(list_image->filename,image_info->filename,sizeof(list_image->filename));
-                   list_image = GetNextImageInList(list_image);
-                 }
-             }
-         }
-       (void) LiberateTemporaryFile(temporary_file);
+        if (BlobToFile(temporary_file,blob,length,exception) != MagickFail)
+          {
+            clone_info->filename[0]='\0';
+            if (clone_info->magick[0] != '\0')
+              {
+                (void) strlcpy(clone_info->filename,clone_info->magick,sizeof(clone_info->filename));
+                (void) strlcat(clone_info->filename,":",sizeof(clone_info->filename));
+              }
+            (void) strlcat(clone_info->filename,temporary_file,sizeof(clone_info->filename));
+            image=ReadImage(clone_info,exception);
+            /*
+              Restore original user-provided file name field to images
+              in list so that user does not see a temporary file name.
+            */
+            if (image != (Image *) NULL)
+              {
+                Image
+                  *list_image;
+
+                list_image = GetFirstImageInList(image);
+                while (list_image != (Image *) NULL)
+                  {
+                    (void) strlcpy(list_image->magick_filename,image_info->filename,sizeof(list_image->magick_filename));
+                    (void) strlcpy(list_image->filename,image_info->filename,sizeof(list_image->filename));
+                    list_image = GetNextImageInList(list_image);
+                  }
+              }
+          }
+        (void) LiberateTemporaryFile(temporary_file);
       }
   }
   DestroyImageInfo(clone_info);
+  if ((image == (Image *) NULL) &&
+      (exception->severity < ErrorException))
+    ThrowException(exception,CoderError,DecodedImageNotReturned,"blob");
   (void) LogMagickEvent(BlobEvent,GetMagickModule(), "Leaving BlobToImage");
   return(image);
 }
@@ -832,14 +892,16 @@ MagickExport BlobInfo *CloneBlobInfo(const BlobInfo *blob_info)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  CloseBlob() closes a stream associated with the image.
+%  CloseBlob() closes a stream associated with the image.  The final error
+%  status (based on any prior error occuring while doing I/O, including while
+%  closing the blob) is provided as a MagickPassFail indication.
 %
 %  If the blob 'exempt' member is MagickTrue, then any passed file descriptor
 %  is left open, otherwise it is closed.
 %
 %  The format of the CloseBlob method is:
 %
-%      void CloseBlob(Image *image)
+%      MagickPassFail CloseBlob(Image *image)
 %
 %  A description of each parameter follows:
 %
@@ -847,8 +909,11 @@ MagickExport BlobInfo *CloneBlobInfo(const BlobInfo *blob_info)
 %
 %
 */
-MagickExport void CloseBlob(Image *image)
+MagickExport MagickPassFail CloseBlob(Image *image)
 {
+  BlobInfo
+    * restrict blob;
+
   int
     status;
 
@@ -857,22 +922,22 @@ MagickExport void CloseBlob(Image *image)
   */
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
+  blob=image->blob;
   /*
     If blob was not allocated, is UndefinedStream (closed) then it
     doesn't need to be closed.
   */
-  if ((image->blob == (BlobInfo *) NULL) ||
-      (image->blob->type == UndefinedStream))
-    return;
+  if ((blob == (BlobInfo *) NULL) || (blob->type == UndefinedStream))
+    return MagickPass;
 
   if (image->logging)
     (void) LogMagickEvent(BlobEvent,GetMagickModule(),
                           "Closing %sStream blob: image %p, blob %p, ref %lu",
-                          BlobStreamTypeToString(image->blob->type),
-                          image,image->blob,image->blob->reference_count);
+                          BlobStreamTypeToString(blob->type),
+                          image,blob,blob->reference_count);
 
   status=0;
-  switch (image->blob->type)
+  switch (blob->type)
     {
     case UndefinedStream:
       break;
@@ -880,25 +945,66 @@ MagickExport void CloseBlob(Image *image)
     case StandardStream:
     case PipeStream:
       {
-        if (image->blob->fsync)
+        if (blob->fsync)
           {
-            (void) fflush(image->blob->handle.std);
-            (void) fsync(fileno(image->blob->handle.std));
+            if (fflush(blob->handle.std) != 0)
+              {
+                if (!status)
+                  {
+                    status=1;
+                    if (errno != 0)
+                      blob->first_errno=errno;
+                  }
+              }
+            if (fsync(fileno(blob->handle.std)) != 0)
+              {
+                if (!status)
+                  {
+                    status=1;
+                    if (errno != 0)
+                      blob->first_errno=errno;
+                  }
+              }
           }
-        status=ferror(image->blob->handle.std);
+        if (!(status) && ferror(blob->handle.std))
+          status=1;
         break;
       }
     case ZipStream:
       {
 #if defined(HasZLIB)
-        (void) gzerror(image->blob->handle.gz,&status);
+        if (!(status))
+          {
+            int
+              gzerror_errnum=Z_OK;
+
+            (void) gzerror(blob->handle.gz,&gzerror_errnum);
+            if (gzerror_errnum != Z_OK)
+              {
+                blob->status=1;
+                if ((gzerror_errnum == Z_ERRNO) && (errno != 0))
+                  blob->first_errno=errno;
+              }
+          }
 #endif
         break;
       }
     case BZipStream:
       {
 #if defined(HasBZLIB)
-        (void) BZ2_bzerror(image->blob->handle.bz,&status);
+        if (!(status))
+          {
+            int
+              bzerror_errnum=BZ_OK;
+
+            (void) BZ2_bzerror(blob->handle.bz,&bzerror_errnum);
+            if (bzerror_errnum != BZ_OK)
+              {
+                blob->status=1;
+                if ((bzerror_errnum == BZ_IO_ERROR) && (errno != 0))
+                  blob->first_errno=errno;
+              }
+          }
 #endif
         break;
       }
@@ -907,48 +1013,74 @@ MagickExport void CloseBlob(Image *image)
     }
   errno=0;
   image->taint=MagickFalse;
-  image->blob->size=GetBlobSize(image);
-  image->blob->eof=MagickFalse;
-  image->blob->status=status < 0;
-  image->blob->mode=UndefinedBlobMode;
+  blob->size=GetBlobSize(image);
+  blob->eof=MagickFalse;
+  blob->status=status != 0;
+  blob->mode=UndefinedBlobMode;
 
   /*
     If we are allowed to close the stream and detatch (destroy)
     the blob.
   */
-  if (! image->blob->exempt )
+  if (! blob->exempt )
     {
       /*
         Close the underlying stream.
       */
-      switch (image->blob->type)
+      switch (blob->type)
         {
         case UndefinedStream:
           break;
         case FileStream:
         case StandardStream:
           {
-            status=fclose(image->blob->handle.std);
+            if (fclose(blob->handle.std) != 0)
+              {
+                if (!status)
+                  {
+                    status=1;
+                    if (errno != 0)
+                      blob->first_errno=errno;
+                  }
+              }
             break;
           }
         case PipeStream:
           {
 #if defined(HAVE_PCLOSE)
-            status=pclose(image->blob->handle.std);
+            if (pclose(blob->handle.std) != 0)
+              {
+                if (!status)
+                  {
+                    status=1;
+                    if (errno != 0)
+                      blob->first_errno=errno;
+                  }
+              }
 #endif /* defined(HAVE_PCLOSE) */
             break;
           }
         case ZipStream:
           {
 #if defined(HasZLIB)
-            status=gzclose(image->blob->handle.gz);
+            int
+              gzerror_errnum;
+
+            gzerror_errnum=gzclose(blob->handle.gz);
+            if (gzerror_errnum != Z_OK)
+              {
+                blob->status=1;
+                if ((gzerror_errnum == Z_ERRNO) && (errno != 0))
+                  blob->first_errno=errno;
+              }
 #endif
             break;
           }
         case BZipStream:
           {
 #if defined(HasBZLIB)
-            BZ2_bzclose(image->blob->handle.bz);
+            /* Returns void */
+            BZ2_bzclose(blob->handle.bz);
 #endif
             break;
           }
@@ -960,10 +1092,18 @@ MagickExport void CloseBlob(Image *image)
       /*
         Detatch (destroy) the blob.
       */
-      DetachBlob(image->blob);
+      DetachBlob(blob);
     }
-  image->blob->type=UndefinedStream;
-  image->blob->status=(status != 0);
+  blob->type=UndefinedStream;
+  blob->status=(status != 0);
+  if (image->logging && blob->status)
+    (void) LogMagickEvent(BlobEvent,GetMagickModule(),
+                          "Closed blob: image %p, blob %p with "
+                          "errno %d (\"%s\")",
+                          image,blob,blob->first_errno,
+                          strerror(blob->first_errno));
+  return (blob->status ? MagickFail : MagickPass);
+
 }
 \f
 /*
@@ -993,46 +1133,47 @@ MagickExport void CloseBlob(Image *image)
 */
 MagickExport void DestroyBlob(Image *image)
 {
+  MagickBool
+    destroy;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
-  if (image->blob != (BlobInfo *) NULL)
-    {
-      MagickBool
-        destroy;
 
-      assert(image->blob->signature == MagickSignature);
-      LockSemaphoreInfo(image->blob->semaphore);
+  if (image->blob == (BlobInfo *) NULL)
+    return;
+
+  assert(image->blob->signature == MagickSignature);
+  LockSemaphoreInfo(image->blob->semaphore);
+  if (image->logging)
+    (void) LogMagickEvent(BlobEvent,GetMagickModule(),
+                          "Destroy blob (ref counted): image %p, blob %p,"
+                          " ref %lu, filename \"%s\"",
+                          image,image->blob,image->blob->reference_count,
+                          image->filename);
+  image->blob->reference_count--;
+  assert(image->blob->reference_count >= 0);
+  destroy=(image->blob->reference_count > 0 ? MagickFalse : MagickTrue);
+  UnlockSemaphoreInfo(image->blob->semaphore);
+  if (destroy)
+    {
+      /*
+        Destroy blob object.
+      */
       if (image->logging)
         (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                              "Destroy blob (ref counted): image %p, blob %p,"
+                              "  Destroy blob (real): image %p, blob %p,"
                               " ref %lu, filename \"%s\"",
-                              image,image->blob,image->blob->reference_count,
-                              image->filename);
-      image->blob->reference_count--;
-      assert(image->blob->reference_count >= 0);
-      destroy=(image->blob->reference_count > 0 ? MagickFalse : MagickTrue);
-      UnlockSemaphoreInfo(image->blob->semaphore);
-      if (destroy)
-        {
-          /*
-            Destroy blob object.
-          */
-          if (image->logging)
-            (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                                  "  Destroy blob (real): image %p, blob %p,"
-                                  " ref %lu, filename \"%s\"",
-                                  image,image->blob,
-                                  image->blob->reference_count,image->filename);
-          if (image->blob->type != UndefinedStream)
-            CloseBlob(image);
-          if (image->blob->mapped)
-            (void) UnmapBlob(image->blob->data,image->blob->length);
-         DestroySemaphoreInfo(&image->blob->semaphore);
-          (void) memset((void *) image->blob,0xbf,sizeof(BlobInfo));
-          MagickFreeMemory(image->blob);
-        }
-      image->blob=(BlobInfo *) NULL;
+                              image,image->blob,
+                              image->blob->reference_count,image->filename);
+      if (image->blob->type != UndefinedStream)
+        CloseBlob(image);
+      if (image->blob->mapped)
+        (void) UnmapBlob(image->blob->data,image->blob->length);
+      DestroySemaphoreInfo(&image->blob->semaphore);
+      (void) memset((void *) image->blob,0xbf,sizeof(BlobInfo));
+      MagickFreeMemory(image->blob);
     }
+  image->blob=(BlobInfo *) NULL;
 }
 \f
 /*
@@ -1083,7 +1224,7 @@ MagickExport void DestroyBlobInfo(BlobInfo *blob)
         {
           if (blob->mapped)
             (void) UnmapBlob(blob->data,blob->length);
-         DestroySemaphoreInfo(&blob->semaphore);
+          DestroySemaphoreInfo(&blob->semaphore);
           (void) memset((void *)blob,0xbf,sizeof(BlobInfo));
           MagickFreeMemory(blob);
         }
@@ -1169,11 +1310,15 @@ MagickExport void DetachBlob(BlobInfo *blob_info)
 */
 MagickExport int EOFBlob(const Image *image)
 {
+  BlobInfo
+    * restrict blob;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   assert(image->blob != (BlobInfo *) NULL);
   assert(image->blob->type != UndefinedStream);
-  switch (image->blob->type)
+  blob=image->blob;
+  switch (blob->type)
   {
     case UndefinedStream:
       break;
@@ -1181,12 +1326,14 @@ MagickExport int EOFBlob(const Image *image)
     case StandardStream:
     case PipeStream:
     {
-      image->blob->eof=feof(image->blob->handle.std);
+      blob->eof=feof(blob->handle.std);
       break;
     }
     case ZipStream:
     {
-      image->blob->eof=MagickFalse;
+#if defined(HasZLIB)
+      blob->eof=gzeof(blob->handle.gz);
+#endif /* defined(HasZLIB) */
       break;
     }
     case BZipStream:
@@ -1195,15 +1342,15 @@ MagickExport int EOFBlob(const Image *image)
       int
         status;
 
-      (void) BZ2_bzerror(image->blob->handle.bz,&status);
-      image->blob->eof=status == BZ_UNEXPECTED_EOF;
-#endif
+      (void) BZ2_bzerror(blob->handle.bz,&status);
+      blob->eof=status == BZ_UNEXPECTED_EOF;
+#endif /* defined(HasBZLIB) */
       break;
     }
     case BlobStream:
       break;
   }
-  return(image->blob->eof);
+  return(blob->eof);
 }
 \f
 /*
@@ -1259,6 +1406,26 @@ MagickExport void *FileToBlob(const char *filename,size_t *length,
   assert(exception != (ExceptionInfo *) NULL);
 
   blob=(unsigned char *) NULL;
+
+  /*
+    Verify that read access to this file path is allowed
+  */
+  if (MagickConfirmAccess(FileReadConfirmAccessMode,filename,
+                          exception) == MagickFail)
+    {
+      length=0;
+      return blob;
+    }
+  /*
+    Validate that filename exists, is a normal file, and contains at
+    least one byte of data
+  */
+  if (!IsAccessibleAndNotEmpty(filename))
+    {
+      ThrowException(exception,BlobError,UnableToOpenFile,filename);
+      length=0;
+      return blob;
+    }
   /* Open file */
   if ((file=fopen(filename,"rb")) != (FILE *) NULL)
     {
@@ -1500,9 +1667,9 @@ MagickExport magick_off_t GetBlobSize(const Image *image)
       break;
     case FileStream:
       {
-       offset=(MagickFstat(fileno(image->blob->handle.std),&attributes) < 0 ? 0 :
-               attributes.st_size);
-       break;
+        offset=(MagickFstat(fileno(image->blob->handle.std),&attributes) < 0 ? 0 :
+                attributes.st_size);
+        break;
       }
     case StandardStream:
     case PipeStream:
@@ -1510,14 +1677,14 @@ MagickExport magick_off_t GetBlobSize(const Image *image)
     case ZipStream:
     case BZipStream:
       {
-       offset=(MagickStat(image->filename,&attributes) < 0 ? 0 :
-               attributes.st_size);
-       break;
+        offset=(MagickStat(image->filename,&attributes) < 0 ? 0 :
+                attributes.st_size);
+        break;
       }
     case BlobStream:
       {
-       offset=image->blob->length;
-       break;
+        offset=image->blob->length;
+        break;
       }
     }
   return(offset);
@@ -1534,7 +1701,9 @@ MagickExport magick_off_t GetBlobSize(const Image *image)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  GetBlobStatus() returns the blob error status.
+%  GetBlobStatus() returns the blob error status.  For GraphicsMagick
+%  1.3.26 and earlier, this was only set by CloseBlob() but now it is
+%  set immediately upon error.
 %
 %  The format of the GetBlobStatus method is:
 %
@@ -1558,6 +1727,39 @@ MagickExport int GetBlobStatus(const Image *image)
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   G e t B l o b F i r s t E r r n o                                         %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  GetBlobFirstErrno() returns the errno present (if any) when the blob
+%  first encountered as error, as indicated by GetBlobStatus().  The
+%  the purpose of this function is to help improve the quality of error
+%  reporting.
+%
+%  The format of the GetBlobFirstErrno method is:
+%
+%      int GetBlobFirstErrno(const Image *image)
+%
+%  A description of each parameter follows:
+%
+%    o image: The image.
+%
+%
+*/
+MagickExport int GetBlobFirstErrno(const Image *image)
+{
+  assert(image != (const Image *) NULL);
+  assert(image->signature == MagickSignature);
+  return(image->blob->first_errno);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   G e t B l o b S t r e a m D a t a                                         %
 %                                                                             %
 %                                                                             %
@@ -1714,6 +1916,13 @@ MagickExport void *GetConfigureBlob(const char *filename,char *path,
 
   (void) strlcpy(path,filename,MaxTextExtent);
   path_map=MagickMapAllocateMap(MagickMapCopyString,MagickMapDeallocateString);
+  if (path_map == (MagickMap) NULL)
+    {
+      /* MagickMap is a tiny allocation so failure to allocate it is fatal */
+      ThrowException3(exception,ResourceLimitFatalError,MemoryAllocationFailed,
+      UnableToAllocateMagickMap);
+      return (void *) NULL;
+    }
 
   {
     /*
@@ -1727,19 +1936,19 @@ MagickExport void *GetConfigureBlob(const char *filename,char *path,
         const char
           *end = NULL,
           *start = magick_configure_path;
-        
+
         end=start+strlen(start);
         while ( start < end )
           {
             char
               buffer[MaxTextExtent];
-            
+
             const char
               *separator;
-            
+
             int
               string_length;
-            
+
             separator = strchr(start,DirectoryListSeparator);
             if (separator)
               string_length=separator-start;
@@ -1793,7 +2002,7 @@ MagickExport void *GetConfigureBlob(const char *filename,char *path,
   {
     const char
       *magick_home;
-    
+
     /*
       Search under MAGICK_HOME.
     */
@@ -1873,7 +2082,7 @@ MagickExport void *GetConfigureBlob(const char *filename,char *path,
           (void) ConcatenateString(&search_path,
             (const char *) MagickMapDereferenceIterator(path_map_iterator,0));
         }
-      
+
       (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
          "Searching for file \"%s\" in path \"%s\"",filename,search_path);
 
@@ -1918,12 +2127,12 @@ MagickExport void *GetConfigureBlob(const char *filename,char *path,
         }
 
       if (logging)
-       {
-         (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                               "Tried: %.1024s [%.1024s]",test_path,
-                               strerror(errno));
-         errno=0;
-       }
+        {
+          (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+                                "Tried: %.1024s [%.1024s]",test_path,
+                                strerror(errno));
+          errno=0;
+        }
     }
   MagickMapDeallocateIterator(path_map_iterator);
   MagickMapDeallocateMap(path_map);
@@ -1984,7 +2193,7 @@ MagickExport void *GetConfigureBlob(const char *filename,char *path,
 %
 */
 MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image,
-                              size_t *length,ExceptionInfo *exception)
+                               size_t *length,ExceptionInfo *exception)
 {
   char
     filename[MaxTextExtent],
@@ -2018,11 +2227,11 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image,
   if (magick_info == (const MagickInfo *) NULL)
     {
       ThrowException(exception,MissingDelegateError,
-                    NoDecodeDelegateForThisImageFormat,clone_info->magick);
+                     NoDecodeDelegateForThisImageFormat,clone_info->magick);
       DestroyImageInfo(clone_info);
       if (image->logging)
-       (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                             "Exiting ImageToBlob");
+        (void) LogMagickEvent(BlobEvent,GetMagickModule(),
+                              "Exiting ImageToBlob");
       return((void *) NULL);
     }
   if (magick_info->blob_support)
@@ -2034,7 +2243,7 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image,
       if (clone_info->blob == (void *) NULL)
         {
           ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,
-                        MagickMsg(BlobError,UnableToCreateBlob));
+                         MagickMsg(BlobError,UnableToCreateBlob));
           DestroyImageInfo(clone_info);
           if (image->logging)
             (void) LogMagickEvent(BlobEvent,GetMagickModule(),
@@ -2051,10 +2260,10 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image,
       status=WriteImage(clone_info,image);
       if (status == MagickFalse)
         {
-         /* Only assert our own exception if an exception was not already reported. */
-         if (image->exception.severity == UndefinedException)
-           ThrowException(exception,BlobError,UnableToWriteBlob,
-                          clone_info->magick);
+          /* Only assert our own exception if an exception was not already reported. */
+          if (image->exception.severity == UndefinedException)
+            ThrowException(exception,BlobError,UnableToWriteBlob,
+                           clone_info->magick);
           MagickFreeMemory(image->blob->data);
           DestroyImageInfo(clone_info);
           if (image->logging)
@@ -2063,7 +2272,8 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image,
           return((void *) NULL);
         }
       /* Request to truncate memory allocation down to memory actually used. */
-      MagickReallocMemory(unsigned char *,image->blob->data,image->blob->length+1);
+      if (image->blob->length)
+        MagickReallocMemory(unsigned char *,image->blob->data,image->blob->length+1);
       /* Pass blob data and length to user parameters */
       blob=image->blob->data;
       *length=image->blob->length;
@@ -2082,13 +2292,13 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image,
   if (!AcquireTemporaryFileName(unique))
     {
       ThrowException(exception,FileOpenError,UnableToCreateTemporaryFile,
-                    unique);
+                     unique);
       DestroyImageInfo(clone_info);
       return((void *) NULL);
     }
   if (image->logging)
     (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                         "Allocated temporary file \"%s\"",unique);
+                          "Allocated temporary file \"%s\"",unique);
   FormatString(image->filename,"%.1024s:%.1024s",image->magick,unique);
   status=WriteImage(clone_info,image);
   DestroyImageInfo(clone_info);
@@ -2107,7 +2317,7 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info,Image *image,
   blob=(unsigned char *) FileToBlob(image->filename,length,exception);
   if (image->logging)
     (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                         "Liberating temporary file \"%s\"",image->filename);
+                          "Liberating temporary file \"%s\"",image->filename);
   (void) LiberateTemporaryFile(image->filename);
   (void) strlcpy(image->filename,filename,MaxTextExtent);
   if (blob == (unsigned char *) NULL)
@@ -2306,17 +2516,17 @@ MagickExport void *MapBlob(int file,const MapMode mode,magick_off_t offset,
   if (map == (void *) MAP_FAILED)
     {
       (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                           "Failed to mmap fd %d using %s mode at offset %"
-                           MAGICK_OFF_F "u and length %" MAGICK_OFF_F
-                           "u (%d=\"%s\").",file,MapModeToString(mode),offset,
-                           (magick_off_t) length,errno,strerror(errno));
+                            "Failed to mmap fd %d using %s mode at offset %"
+                            MAGICK_OFF_F "u and length %" MAGICK_OFF_F
+                            "u (%d=\"%s\").",file,MapModeToString(mode),offset,
+                            (magick_off_t) length,errno,strerror(errno));
       return((void *) NULL);
     }
   (void) LogMagickEvent(BlobEvent,GetMagickModule(),
-                       "Mmapped fd %d using %s mode at offset %" MAGICK_OFF_F
-                       "u and length %" MAGICK_OFF_F "u to address %p",
-                       file,MapModeToString(mode),offset,(magick_off_t) length,
-                       map);
+                        "Mmapped fd %d using %s mode at offset %" MAGICK_OFF_F
+                        "u and length %" MAGICK_OFF_F "u to address %p",
+                        file,MapModeToString(mode),offset,(magick_off_t) length,
+                        map);
   return((void *) map);
 #else
   (void) file;
@@ -2587,15 +2797,23 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image,
           if (MagickConfirmAccess((type[0] == 'r' ? FileReadConfirmAccessMode :
                                    FileWriteConfirmAccessMode),filename,
                                   exception) != MagickFail)
-            image->blob->handle.gz=gzopen(filename,type);
+            image->blob->handle.gz=gzopen(filename,*type == 'w' ? "wb" : "rb" );
           if (image->blob->handle.gz != (gzFile) NULL)
             {
               image->blob->type=ZipStream;
               if (image->logging)
                 (void) LogMagickEvent(BlobEvent,GetMagickModule(),
                                       "  opened file %s as ZipStream image"
-                                      " %p, blob %p",
-                                      filename,image,image->blob);
+                                      " %p, blob %p, mode %s",
+                                      filename,image,image->blob,type);
+            }
+          else
+            {
+              if (image->logging)
+                (void) LogMagickEvent(BlobEvent,GetMagickModule(),
+                                      "  failed to open file %s as ZipStream image"
+                                      " %p, blob %p, mode %s",
+                                      filename,image,image->blob,type);
             }
         }
       else
@@ -2762,7 +2980,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image,
             {
               /*
                 Support reading from a file using memory mapping.
-                  
+
                 This code was used for years and definitely speeds
                 re-reading of the same file, but it has been
                 discovered that some operating systems (e.g. FreeBSD
@@ -2775,7 +2993,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image,
                 {
                   const MagickInfo
                     *magick_info;
-                
+
                   MagickStatStruct_t
                     attributes;
 
@@ -2789,10 +3007,10 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image,
                         {
                           size_t
                             length;
-                      
+
                           void
                             *blob;
-                      
+
                           length=(size_t) attributes.st_size;
 
                           if (AcquireMagickResource(MapResource,length))
@@ -2825,6 +3043,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image,
         }
     }
   image->blob->status=MagickFalse;
+  image->blob->first_errno=0;
   if (image->blob->type != UndefinedStream)
     image->blob->size=GetBlobSize(image);
   if (*type == 'r')
@@ -2835,7 +3054,7 @@ MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info,Image *image,
   if (UndefinedStream == image->blob->type)
     {
       if (UndefinedException == exception->severity)
-       ThrowException(exception,FileOpenError,UnableToOpenFile,filename);
+        ThrowException(exception,FileOpenError,UnableToOpenFile,filename);
       return MagickFail;
     }
   return MagickPass;
@@ -2930,6 +3149,9 @@ MagickExport Image *PingBlob(const ImageInfo *image_info,const void *blob,
 */
 MagickExport size_t ReadBlob(Image *image,const size_t length,void *data)
 {
+  BlobInfo
+    * restrict blob;
+
   size_t
     count;
 
@@ -2939,124 +3161,175 @@ MagickExport size_t ReadBlob(Image *image,const size_t length,void *data)
   assert(image->blob->type != UndefinedStream);
   assert(data != (void *) NULL);
 
+  blob=image->blob;
   count=0;
-  switch (image->blob->type)
-  {
+  switch (blob->type)
+    {
     case UndefinedStream:
       break;
     case FileStream:
     case StandardStream:
     case PipeStream:
-    {
-      if (length == 1)
-        {
-          int
-            c;
+      {
+        if (length == 1)
+          {
+            int
+              c;
 
-          if ((c=getc(image->blob->handle.std)) != EOF)
-            {
-              *((unsigned char *)data)=(unsigned char) c;
-              count=1;
-            }
-          else
-            {
-              count=0;
-            }
-        }
-      else
-        {
-          count=fread(data,1,length,image->blob->handle.std);
-        }
-      break;
-    }
+            if ((c=getc(blob->handle.std)) != EOF)
+              {
+                *((unsigned char *)data)=(unsigned char) c;
+                count=1;
+              }
+            else
+              {
+                count=0;
+              }
+          }
+        else
+          {
+            count=fread(data,1,length,blob->handle.std);
+          }
+        if (count != length)
+          {
+            if (!(blob->status) && ferror(blob->handle.std))
+              {
+                blob->status=1;
+                if (errno != 0)
+                  blob->first_errno=errno;
+              }
+          }
+        break;
+      }
     case ZipStream:
-    {
+      {
 #if defined(HasZLIB)
-      size_t
-        i;
+        size_t
+          i;
 
-      for (i=0; i < length; i+=count)
-        {
-          size_t
-            remaining;
+        int
+          gz_count = 0;
 
-          unsigned int
-            amount;
+        for (i=0; i < length; i+=gz_count)
+          {
+            size_t
+              remaining;
 
-          remaining=length - i;
-          if (remaining > image->blob->block_size)
-            amount=(unsigned int) image->blob->block_size;
-          else
-            amount=(unsigned int) remaining;
+            unsigned int
+              amount;
 
-          count=gzread(image->blob->handle.gz,
-                       (void *) ((unsigned char *) data+i),amount);
-          if (count <= 0)
-            break;
-        }
-      count=i;
+            remaining=length - i;
+            if (remaining > blob->block_size)
+              amount=(unsigned int) blob->block_size;
+            else
+              amount=(unsigned int) remaining;
+
+            gz_count=gzread(blob->handle.gz,
+                            (void *) ((unsigned char *) data+i),amount);
+            if (gz_count <= 0)
+              break;
+          }
+        count=i;
+        if (count != length)
+          {
+            if (!(blob->status))
+              {
+                int
+                  gzerror_errnum=Z_OK;
+
+                (void) gzerror(blob->handle.gz,&gzerror_errnum);
+                if (gzerror_errnum != Z_OK)
+                  {
+                    blob->status=1;
+                    if ((gzerror_errnum == Z_ERRNO) && (errno != 0))
+                      blob->first_errno=errno;
+                  }
+              }
+            if (!blob->eof)
+              blob->eof = gzeof(blob->handle.gz);
+          }
 #endif
-      break;
-    }
+        break;
+      }
     case BZipStream:
-    {
+      {
 #if defined(HasBZLIB)
-      size_t
-        i;
+        size_t
+          i;
 
-      for (i=0; i < length; i+=count)
-        {
-          size_t
-            remaining;
+        int
+          bz_count = 0;
 
-          int
-            amount;
+        for (i=0; i < length; i+=bz_count)
+          {
+            size_t
+              remaining;
 
-          remaining=length - i;
-          if (remaining > image->blob->block_size)
-            amount=(int) image->blob->block_size;
-          else
-            amount=(int) remaining;
+            int
+              amount;
 
-          count=BZ2_bzread(image->blob->handle.bz,
-                           (void *) ((unsigned char *) data+i),amount);
-          if (count <= 0)
-            break;
-        }
-      count=i;
+            remaining=length - i;
+            if (remaining > blob->block_size)
+              amount=(int) blob->block_size;
+            else
+              amount=(int) remaining;
+
+            bz_count=BZ2_bzread(blob->handle.bz,
+                                (void *) ((unsigned char *) data+i),amount);
+            if (bz_count <= 0)
+              break;
+          }
+        count=i;
+        if (count != length)
+          {
+            if (!(blob->status))
+              {
+                int
+                  bzerror_errnum=BZ_OK;
+
+                (void) BZ2_bzerror(blob->handle.bz,&bzerror_errnum);
+                if (bzerror_errnum != BZ_OK)
+                  {
+                    blob->status=1;
+                    if ((bzerror_errnum == BZ_IO_ERROR) && (errno != 0))
+                      blob->first_errno=errno;
+                  }
+              }
+          }
 #endif
-      break;
-    }
+        break;
+      }
     case BlobStream:
-    {
-      void
-        *source_void = 0;
+      {
+        void
+          *source_void = 0;
 
-      const unsigned char
-        *source;
+        const unsigned char
+          *source;
 
-      count=ReadBlobStream(image,length,&source_void);
-      source=source_void;
-      if (count <= 10)
-        {
-          register size_t
-            i;
+        count=ReadBlobStream(image,length,&source_void);
+        source=source_void;
+        if (count <= 10)
+          {
+            register size_t
+              i;
 
-          register unsigned char
-            *target=(unsigned char*) data;
+            register unsigned char
+              *target=(unsigned char*) data;
 
-          for(i=count; i > 0; i--)
-            {
-              *target=*source;
-              target++;
-              source++;
-            }
-        }
-      else 
-        (void) memcpy(data,source,count);
-      break;
+            for(i=count; i > 0; i--)
+              {
+                *target=*source;
+                target++;
+                source++;
+              }
+          }
+        else
+          (void) memcpy(data,source,count);
+        break;
+      }
     }
-  }
+  assert(count <= length);
   return(count);
 }
 \f
@@ -3141,39 +3414,59 @@ MagickExport  size_t ReadBlobZC(Image *image,const size_t length,void **data)
 */
 MagickExport int ReadBlobByte(Image *image)
 {
+  BlobInfo
+    * restrict blob;
+
+  int
+    c = EOF;
+
   unsigned char
-    c;
-  
+    octet;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
-  
-  switch (image->blob->type)
+
+  blob=image->blob;
+
+  switch (blob->type)
     {
     case FileStream:
     case StandardStream:
     case PipeStream:
       {
-        return getc(image->blob->handle.std);
+        if ((c=getc(blob->handle.std)) == EOF)
+          {
+            if (!(blob->status) && ferror(blob->handle.std))
+              {
+                blob->status=1;
+                if (errno != 0)
+                  blob->first_errno=errno;
+              }
+          }
+        break;
       }
     case BlobStream:
       {
-        if (image->blob->offset < (magick_off_t) image->blob->length)
+        if (blob->offset < (magick_off_t) blob->length)
+          {
+            octet=*((unsigned char *)blob->data+blob->offset);
+            blob->offset++;
+            c=octet;
+          }
+        else
           {
-            c=*((unsigned char *)image->blob->data+image->blob->offset);
-            image->blob->offset++;
-            return (c);
+            blob->eof=True;
           }
-        image->blob->eof=True;
         break;
       }
     default:
       {
         /* Do things the slow way */
-        if (ReadBlob(image,1,&c) == 1)
-          return (c);
+        if (ReadBlob(image,1,&octet) == 1)
+          c=octet;
       }
     }
-  return(EOF);
+  return c;
 }
 \f
 /*
@@ -3224,6 +3517,9 @@ MagickExport double ReadBlobLSBDouble(Image * image)
   MagickSwabDouble(&dbl_buffer.d);
 #endif
 
+  if (MAGICK_ISNAN(dbl_buffer.d))
+    dbl_buffer.d = 0.0;
+
   return (dbl_buffer.d);
 }
 \f
@@ -3262,6 +3558,7 @@ MagickExport double ReadBlobLSBDouble(Image * image)
 MagickExport size_t ReadBlobLSBDoubles(Image *image, size_t octets, double *data)
 {
   size_t
+    i,
     octets_read;
 
   assert(image != (Image *) NULL);
@@ -3269,11 +3566,17 @@ MagickExport size_t ReadBlobLSBDoubles(Image *image, size_t octets, double *data
   assert(data != (double *) NULL);
 
   octets_read=ReadBlob(image,octets,data);
-#if defined(WORDS_BIGENDIAN)
   if (octets_read >= sizeof(double))
-    MagickSwabArrayOfDouble(data,(octets_read+sizeof(double)-1)/sizeof(double));
+    {
+#if defined(WORDS_BIGENDIAN)
+        MagickSwabArrayOfDouble(data,(octets_read+sizeof(double)-1)/sizeof(double));
 #endif
 
+      for (i=0; i < octets_read/sizeof(double); i++)
+        if (MAGICK_ISNAN(data[i]))
+          data[i] = 0.0;
+    }
+
   return octets_read;
 }
 \f
@@ -3320,10 +3623,10 @@ MagickExport magick_uint32_t ReadBlobLSBLong(Image *image)
   if (ReadBlob(image,4,buffer) != 4)
     return(0U);
 
-  value=buffer[3] << 24;
-  value|=buffer[2] << 16;
-  value|=buffer[1] << 8;
-  value|=buffer[0];
+  value=(magick_uint32_t) buffer[3] << 24;
+  value|=(magick_uint32_t) buffer[2] << 16;
+  value|=(magick_uint32_t) buffer[1] << 8;
+  value|=(magick_uint32_t) buffer[0];
   return(value & 0xffffffff);
 }
 \f
@@ -3370,10 +3673,10 @@ MagickExport magick_int32_t ReadBlobLSBSignedLong(Image *image)
   if (ReadBlob(image,4,buffer) != 4)
     return(0U);
 
-  value.uint32=buffer[3] << 24;
-  value.uint32|=buffer[2] << 16;
-  value.uint32|=buffer[1] << 8;
-  value.uint32|=buffer[0];
+  value.uint32=(magick_uint32_t) buffer[3] << 24;
+  value.uint32|=(magick_uint32_t) buffer[2] << 16;
+  value.uint32|=(magick_uint32_t) buffer[1] << 8;
+  value.uint32|=(magick_uint32_t) buffer[0];
   value.uint32&=0xffffffff;
   return value.int32;
 }
@@ -3473,8 +3776,8 @@ MagickExport magick_uint16_t ReadBlobLSBShort(Image *image)
   if (ReadBlob(image,2,buffer) != 2)
     return(0U);
 
-  value=buffer[1] << 8;
-  value|=buffer[0];
+  value=(magick_uint16_t) buffer[1] << 8;
+  value|=(magick_uint16_t) buffer[0];
   return(value & 0xffff);
 }
 \f
@@ -3521,8 +3824,8 @@ MagickExport magick_int16_t ReadBlobLSBSignedShort(Image *image)
   if (ReadBlob(image,2,buffer) != 2)
     return(0U);
 
-  value.uint16=buffer[1] << 8;
-  value.uint16|=buffer[0];
+  value.uint16=(magick_uint16_t) buffer[1] << 8;
+  value.uint16|=(magick_uint16_t) buffer[0];
   value.uint16&=0xffff;
   return value.int16;
 }
@@ -3575,6 +3878,9 @@ MagickExport float ReadBlobLSBFloat(Image * image)
   MagickSwabFloat(&flt_buffer.f);
 #endif
 
+  if (MAGICK_ISNAN(flt_buffer.f))
+    flt_buffer.f = 0.0;
+
   return (flt_buffer.f);
 }
 \f
@@ -3613,6 +3919,7 @@ MagickExport float ReadBlobLSBFloat(Image * image)
 MagickExport size_t ReadBlobLSBFloats(Image *image, size_t octets, float *data)
 {
   size_t
+    i,
     octets_read;
 
   assert(image != (Image *) NULL);
@@ -3625,6 +3932,10 @@ MagickExport size_t ReadBlobLSBFloats(Image *image, size_t octets, float *data)
     MagickSwabArrayOfFloat(data,(octets_read+sizeof(float)-1)/sizeof(float));
 #endif
 
+  for (i=0; i < octets_read/sizeof(float); i++)
+    if (MAGICK_ISNAN(data[i]))
+      data[i] = 0.0;
+
   return octets_read;
 }
 \f
@@ -3676,6 +3987,9 @@ MagickExport float ReadBlobMSBFloat(Image * image)
   MagickSwabFloat(&flt_buffer.f);
 #endif
 
+  if (MAGICK_ISNAN(flt_buffer.f))
+    flt_buffer.f = 0.0;
+
   return (flt_buffer.f);
 }
 \f
@@ -3714,6 +4028,7 @@ MagickExport float ReadBlobMSBFloat(Image * image)
 MagickExport size_t ReadBlobMSBFloats(Image *image, size_t octets, float *data)
 {
   size_t
+    i,
     octets_read;
 
   assert(image != (Image *) NULL);
@@ -3726,6 +4041,10 @@ MagickExport size_t ReadBlobMSBFloats(Image *image, size_t octets, float *data)
     MagickSwabArrayOfFloat(data,(octets_read+sizeof(float)-1)/sizeof(float));
 #endif
 
+  for (i=0; i < octets_read/sizeof(float); i++)
+    if (MAGICK_ISNAN(data[i]))
+      data[i] = 0.0;
+
   return octets_read;
 }
 \f
@@ -3765,7 +4084,7 @@ MagickExport double ReadBlobMSBDouble(Image * image)
     double d;
     unsigned char chars[8];
   } dbl_buffer;
-  
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   assert(sizeof(dbl_buffer) == sizeof(double));
@@ -3777,6 +4096,9 @@ MagickExport double ReadBlobMSBDouble(Image * image)
   MagickSwabDouble(&dbl_buffer.d);
 #endif
 
+  if (MAGICK_ISNAN(dbl_buffer.d))
+    dbl_buffer.d = 0.0;
+
   return (dbl_buffer.d);
 }
 \f
@@ -3815,6 +4137,7 @@ MagickExport double ReadBlobMSBDouble(Image * image)
 MagickExport size_t ReadBlobMSBDoubles(Image *image, size_t octets, double *data)
 {
   size_t
+    i,
     octets_read;
 
   assert(image != (Image *) NULL);
@@ -3822,11 +4145,17 @@ MagickExport size_t ReadBlobMSBDoubles(Image *image, size_t octets, double *data
   assert(data != (double *) NULL);
 
   octets_read=ReadBlob(image,octets,data);
+  if (octets_read >= sizeof(double))
+    {
 #if !defined(WORDS_BIGENDIAN)
-  if (octets_read > 0)
-    MagickSwabArrayOfDouble(data,(octets_read+sizeof(double)-1)/sizeof(double));
+        MagickSwabArrayOfDouble(data,(octets_read+sizeof(double)-1)/sizeof(double));
 #endif
 
+      for (i=0; i < octets_read/sizeof(double); i++)
+        if (MAGICK_ISNAN(data[i]))
+          data[i] = 0.0;
+    }
+
   return octets_read;
 }
 \f
@@ -3874,9 +4203,9 @@ MagickExport magick_uint32_t ReadBlobMSBLong(Image *image)
   if (ReadBlob(image,4,buffer) != 4)
     return(0U);
 
-  value=buffer[0] << 24;
-  value|=buffer[1] << 16;
-  value|=buffer[2] << 8;
+  value=(magick_uint32_t) buffer[0] << 24;
+  value|=(magick_uint32_t) buffer[1] << 16;
+  value|=(magick_uint32_t) buffer[2] << 8;
   value|=buffer[3];
   return(value & 0xffffffff);
 }
@@ -3925,10 +4254,10 @@ MagickExport magick_int32_t ReadBlobMSBSignedLong(Image *image)
   if (ReadBlob(image,4,buffer) != 4)
     return(0);
 
-  value.uint32=buffer[0] << 24;
-  value.uint32|=buffer[1] << 16;
-  value.uint32|=buffer[2] << 8;
-  value.uint32|=buffer[3];
+  value.uint32=(magick_uint32_t) buffer[0] << 24;
+  value.uint32|=(magick_uint32_t) buffer[1] << 16;
+  value.uint32|=(magick_uint32_t) buffer[2] << 8;
+  value.uint32|=(magick_uint32_t) buffer[3];
   value.uint32&=0xffffffff;
   return value.int32;
 }
@@ -3976,8 +4305,8 @@ MagickExport magick_uint16_t ReadBlobMSBShort(Image *image)
   if (ReadBlob(image,2,buffer) != 2)
     return(0U);
 
-  value=buffer[0] << 8;
-  value|=buffer[1];
+  value=(magick_uint16_t) buffer[0] << 8;
+  value|=(magick_uint16_t) buffer[1];
   return(value & 0xffff);
 }
 \f
@@ -4024,8 +4353,8 @@ MagickExport magick_int16_t ReadBlobMSBSignedShort(Image *image)
   if (ReadBlob(image,2,buffer) != 2)
     return(0U);
 
-  value.uint16=buffer[0] << 8;
-  value.uint16|=buffer[1];
+  value.uint16=(magick_uint16_t) buffer[0] << 8;
+  value.uint16|=(magick_uint16_t) buffer[1];
   value.uint16&=0xffff;
   return value.int16;
 }
@@ -4218,84 +4547,82 @@ MagickExport BlobInfo *ReferenceBlob(BlobInfo *blob)
 %
 */
 MagickExport magick_off_t SeekBlob(Image *image,const magick_off_t offset,
-  const int whence)
+                                   const int whence)
 {
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   assert(image->blob != (BlobInfo *) NULL);
   assert(image->blob->type != UndefinedStream);
+#if 0
+  if (image->logging)
+    (void) LogMagickEvent(BlobEvent,GetMagickModule(),
+                          "Seek %" MAGICK_OFF_F "d, whence = %s",
+                          offset,
+                          (whence == SEEK_SET ? "SEEK_SET" :
+                           (whence == SEEK_CUR ? "SEEK_CUR" :
+                            (whence == SEEK_END ? "SEEK_END" :
+                             "?"))));
+#endif
   switch (image->blob->type)
-  {
+    {
     case UndefinedStream:
       break;
     case FileStream:
-    {
-      if (MagickFseek(image->blob->handle.std,offset,whence) < 0)
-        return(-1);
-      image->blob->offset=TellBlob(image);
-      break;
-    }
+      {
+        if (MagickFseek(image->blob->handle.std,offset,whence) < 0)
+          return(-1);
+        image->blob->offset=TellBlob(image);
+        break;
+      }
     case StandardStream:
     case PipeStream:
       return(-1);
     case ZipStream:
-    {
+      {
 #if defined(HasZLIB)
-      if (gzseek(image->blob->handle.gz,(off_t) offset,whence) < 0)
-        return(-1);
+        if (gzseek(image->blob->handle.gz,(off_t) offset,whence) < 0)
+          return(-1);
 #endif
-      image->blob->offset=TellBlob(image);
-      break;
-    }
+        image->blob->offset=TellBlob(image);
+        break;
+      }
     case BZipStream:
       return(-1);
     case BlobStream:
-    {
-      switch (whence)
       {
-        case SEEK_SET:
-        default:
-        {
-          if (offset < 0)
-            return(-1);
-          image->blob->offset=offset;
-          break;
-        }
-        case SEEK_CUR:
-        {
-          if ((image->blob->offset+offset) < 0)
-            return(-1);
-          image->blob->offset+=offset;
-          break;
-        }
-        case SEEK_END:
-        {
-          if ((magick_off_t)
-              (image->blob->offset+image->blob->length+offset) < 0)
-            return(-1);
-          image->blob->offset=image->blob->length+offset;
-          break;
-        }
-      }
-      if (image->blob->offset <= (magick_off_t) image->blob->length)
-        image->blob->eof=MagickFalse;
-      else
-        if (image->blob->mapped)
-          return(-1);
-        else
+        switch (whence)
           {
-            image->blob->extent=image->blob->offset+image->blob->quantum;
-            MagickReallocMemory(unsigned char *,image->blob->data,image->blob->extent+1);
-            (void) SyncBlob(image);
-            if (image->blob->data == (unsigned char *) NULL)
-              {
-                DetachBlob(image->blob);
+          case SEEK_SET:
+          default:
+            {
+              if (offset < 0)
                 return(-1);
-              }
+              image->blob->offset=offset;
+              break;
+            }
+          case SEEK_CUR:
+            {
+              if ((image->blob->offset+offset) < 0)
+                return(-1);
+              image->blob->offset+=offset;
+              break;
+            }
+          case SEEK_END:
+            {
+              if ((magick_off_t)
+                  (image->blob->offset+image->blob->length+offset) < 0)
+                return(-1);
+              image->blob->offset=image->blob->length+offset;
+              break;
+            }
           }
-      break;
+        if (image->blob->offset <= (magick_off_t) image->blob->length)
+          {
+            image->blob->eof=MagickFalse;
+          }
+        break;
+      }
     }
-  }
   return(image->blob->offset);
 }
 \f
@@ -4345,7 +4672,7 @@ MagickExport void SetBlobClosable(Image *image, MagickBool closeable)
 %
 %  SetBlobTemporary() sets a boolean flag (default False) to specify if
 %  the file associated with the blob is a temporary file and should be
-%  removed when the associated image is destroyed. 
+%  removed when the associated image is destroyed.
 %
 %  The format of the SetBlobTemporary method is:
 %
@@ -4415,7 +4742,7 @@ static int SyncBlob(Image *image)
       the current image (as desired).
     */
     for ( p=GetFirstImageInList(image); p != (Image *) NULL;
-         p=SyncNextImageInList(p));
+          p=SyncNextImageInList(p));
   }
 #endif
 
@@ -4599,6 +4926,9 @@ MagickExport MagickPassFail UnmapBlob(void *map,const size_t length)
 */
 MagickExport size_t WriteBlob(Image *image,const size_t length,const void *data)
 {
+  BlobInfo
+    * restrict blob;
+
   size_t
     count;
 
@@ -4607,92 +4937,134 @@ MagickExport size_t WriteBlob(Image *image,const size_t length,const void *data)
   assert(data != (const char *) NULL);
   assert(image->blob != (BlobInfo *) NULL);
   assert(image->blob->type != UndefinedStream);
+  blob=image->blob;
   count=length;
-  switch (image->blob->type)
-  {
+  switch (blob->type)
+    {
     case UndefinedStream:
       break;
     case FileStream:
     case StandardStream:
     case PipeStream:
-    {
-      if (length == 1)
-        {
-          if((putc((int)*((unsigned char *)data),image->blob->handle.std)) != EOF)
-            count=1;
-          else
-            count=0;
-        }
-      else
-        {
-          count=fwrite((char *) data,1,length,image->blob->handle.std);
-        }
-      break;
-    }
+      {
+        if (length == 1)
+          {
+            if ((putc((int)*((unsigned char *)data),blob->handle.std)) == EOF)
+              count=0;
+          }
+        else
+          {
+            count=fwrite((char *) data,1,length,blob->handle.std);
+          }
+        if (count != length)
+          {
+            if (!(blob->status) && ferror(blob->handle.std))
+              {
+                blob->status=1;
+                if (errno != 0)
+                  blob->first_errno=errno;
+              }
+          }
+        break;
+      }
     case ZipStream:
-    {
+      {
 #if defined(HasZLIB)
-      size_t
-        i;
+        size_t
+          i;
 
-      for (i=0; i < length; i+=count)
-        {
-          size_t
-            remaining;
+        int
+          gz_count = 0;
 
-          unsigned int
-            amount;
+        for (i=0; i < length; i+=gz_count)
+          {
+            size_t
+              remaining;
 
-          remaining=length - i;
-          if (remaining > image->blob->block_size)
-            amount=(unsigned int) image->blob->block_size;
-          else
-            amount=(unsigned int) remaining;
+            unsigned int
+              amount;
 
-          count=gzwrite(image->blob->handle.gz,
-                        (void *) ((unsigned char *) data+i),amount);
-          if (count <= 0)
-            break;
-        }
-      count=i;
+            remaining=length - i;
+            if (remaining > blob->block_size)
+              amount=(unsigned int) blob->block_size;
+            else
+              amount=(unsigned int) remaining;
+
+            gz_count=gzwrite(blob->handle.gz,
+                             (void *) ((unsigned char *) data+i),amount);
+            if (gz_count <= 0)
+              break;
+          }
+        count=i;
+        if ((count != length) && !(blob->status))
+          {
+            int
+              gzerror_errnum=Z_OK;
+
+            (void) gzerror(blob->handle.gz,&gzerror_errnum);
+            if (gzerror_errnum != Z_OK)
+              {
+                blob->status=1;
+                if ((gzerror_errnum == Z_ERRNO) && (errno != 0))
+                  blob->first_errno=errno;
+              }
+          }
 #endif
-      break;
-    }
+        break;
+      }
     case BZipStream:
-    {
+      {
 #if defined(HasBZLIB)
-      size_t
-        i;
+        size_t
+          i;
 
-      for (i=0; i < length; i+=count)
-        {
-          size_t
-            remaining;
+        int
+          bz_count = 0;
 
-          int
-            amount;
+        for (i=0; i < length; i+=bz_count)
+          {
+            size_t
+              remaining;
 
-          remaining=length - i;
-          if (remaining > image->blob->block_size)
-            amount=(int) image->blob->block_size;
-          else
-            amount=(int) remaining;
+            int
+              amount;
 
-          count=BZ2_bzwrite(image->blob->handle.gz,
-                            (void *) ((unsigned char *) data+i),amount);
-          if (count <= 0)
-            break;
-        }
-      count=i;
+            remaining=length - i;
+            if (remaining > blob->block_size)
+              amount=(int) blob->block_size;
+            else
+              amount=(int) remaining;
+
+            bz_count=BZ2_bzwrite(blob->handle.gz,
+                                 (void *) ((unsigned char *) data+i),amount);
+            if (bz_count <= 0)
+              break;
+          }
+        count=i;
+        if ((count != length) && !(blob->status))
+          {
+            int
+              bzerror_errnum=BZ_OK;
+
+            (void) BZ2_bzerror(blob->handle.bz,&bzerror_errnum);
+            if (bzerror_errnum != BZ_OK)
+              {
+                blob->status=1;
+                if ((bzerror_errnum == BZ_IO_ERROR) && (errno != 0))
+                  blob->first_errno=errno;
+              }
+          }
 #endif
-      break;
-    }
+        break;
+      }
     case BlobStream:
-    {
-      count=WriteBlobStream(image,length,data);
-      break;
+      {
+        count=WriteBlobStream(image,length,data);
+        if (count != length)
+          blob->status=1;
+        break;
+      }
     }
-  }
   return(count);
 }
 \f
@@ -4726,30 +5098,46 @@ MagickExport size_t WriteBlob(Image *image,const size_t length,const void *data)
 */
 MagickExport size_t WriteBlobByte(Image *image,const magick_uint8_t value)
 {
+  BlobInfo
+    * restrict blob;
+
+  size_t
+    count=1;
+
   unsigned char
     c;
 
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
 
-  switch (image->blob->type)
+  blob=image->blob;
+
+  switch (blob->type)
     {
     case FileStream:
     case StandardStream:
     case PipeStream:
       {
-        if(putc((int) value,image->blob->handle.std) != EOF)
-          return 1;
-        return 0;
+        if (putc((int) value,blob->handle.std) == EOF)
+          {
+            count=0;
+            if (!(blob->status) && ferror(blob->handle.std))
+              {
+                blob->status=1;
+                if (errno != 0)
+                  blob->first_errno=errno;
+              }
+          }
       }
+      break;
       /* case BlobStream: TBD */
     default:
       {
         c=(unsigned char) value;
-        return(WriteBlob(image,1,&c));
+        count=WriteBlob(image,1,&c);
       }
     }
-
+  return count;
 }
 \f
 /*
@@ -4787,7 +5175,7 @@ MagickExport MagickPassFail WriteBlobFile(Image *image,const char *filename)
     status=MagickFail;
 
   if (MagickConfirmAccess(FileReadConfirmAccessMode,filename,
-                         &image->exception) == MagickFail)
+                          &image->exception) == MagickFail)
     return MagickFail;
   file=open(filename,O_RDONLY | O_BINARY,0777);
   if (file != -1)
index 327d736..10669aa 100644 (file)
@@ -1,12 +1,12 @@
 /*
-  Copyright (C) 2003-2016 GraphicsMagick Group
+  Copyright (C) 2003-2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Image Compression/Decompression Methods.
 */
 #ifndef _MAGICK_BLOB_H
@@ -144,7 +144,7 @@ extern "C" {
   /*
     Close I/O to the file or BLOB.
   */
-  extern MagickExport void CloseBlob(Image *image);
+  extern MagickExport MagickPassFail CloseBlob(Image *image);
 
 
   /*
@@ -189,14 +189,21 @@ extern "C" {
 
   /*
     Test to see if an error has been encountered while doing I/O to the file
-    or BLOB.
+    or BLOB.  Non-zero is returned if an error occured.
+  */
+  extern MagickExport int GetBlobStatus(const Image *image) MAGICK_FUNC_PURE;
+
+  /*
+    Return the first errno present when an error has been encountered while
+    doing I/O to the file or BLOB.  This is only useful if GetBlobStatus() has
+    already reported that an error occured.
   */
-  extern MagickExport int GetBlobStatus(const Image *image);
+  extern MagickExport int GetBlobFirstErrno(const Image *image) MAGICK_FUNC_PURE;
 
   /*
     Test to see if blob is currently open.
   */
-  extern MagickExport MagickBool GetBlobIsOpen(const Image *image);
+  extern MagickExport MagickBool GetBlobIsOpen(const Image *image) MAGICK_FUNC_PURE;
 
   /*
     Obtain the current size of the file or BLOB.  Zero is returned if
@@ -209,14 +216,14 @@ extern "C" {
   /*
     Obtain the underlying stdio FILE* for the file (if any).
   */
-  extern MagickExport FILE *GetBlobFileHandle(const Image *image);
+  extern MagickExport FILE *GetBlobFileHandle(const Image *image) MAGICK_FUNC_PURE;
 
   /*
     Obtain a pointer to the base of where BLOB data is stored.  The data
     is only available if the data is stored on the heap, or is memory
     mapped.  Otherwise NULL is returned.
   */
-  extern MagickExport unsigned char *GetBlobStreamData(const Image *image);
+  extern MagickExport unsigned char *GetBlobStreamData(const Image *image) MAGICK_FUNC_PURE;
 
 
   /*
@@ -436,7 +443,7 @@ extern "C" {
     Blob supports seek operations.  BlobSeek() and BlobTell() may safely be
     used.
   */
-  extern MagickExport MagickBool BlobIsSeekable(const Image *image);
+  extern MagickExport MagickBool BlobIsSeekable(const Image *image) MAGICK_FUNC_PURE;
 
   /*
     Allow file descriptor to be closed (if True).
@@ -454,7 +461,7 @@ extern "C" {
     Returns MagickTrue if the file associated with the blob is a temporary
     file and should be removed when the associated image is destroyed.
   */
-  extern MagickExport MagickBool GetBlobTemporary(const Image *image);
+  extern MagickExport MagickBool GetBlobTemporary(const Image *image) MAGICK_FUNC_PURE;
 
   /*
    *
index 7d19c41..9a77688 100644 (file)
@@ -77,12 +77,12 @@ typedef struct _CdlImageParameters_t
 
   const PixelPacket
     *lut;
-               
+
 } CdlImageParameters_t;
 
 static Quantum
 CdlQuantum(const Quantum quantum, const double slope, const double offset,
-          const double power, const double saturation)
+           const double power, const double saturation)
 {
   double
     v,
@@ -99,46 +99,46 @@ CdlQuantum(const Quantum quantum, const double slope, const double offset,
 
 static MagickPassFail
 CdlImagePixels(void *mutable_data,         /* User provided mutable data */
-              const void *immutable_data, /* User provided immutable data */
-              Image *image,               /* Modify image */
-              PixelPacket *pixels,        /* Pixel row */
-              IndexPacket *indexes,       /* Pixel row indexes */
-              const long npixels,         /* Number of pixels in row */
-              ExceptionInfo *exception)   /* Exception report */
+               const void *immutable_data, /* User provided immutable data */
+               Image * restrict image,               /* Modify image */
+               PixelPacket * restrict pixels,        /* Pixel row */
+               IndexPacket * restrict indexes,       /* Pixel row indexes */
+               const long npixels,         /* Number of pixels in row */
+               ExceptionInfo *exception)   /* Exception report */
 {
   const CdlImageParameters_t
     param = *(const CdlImageParameters_t *) immutable_data;
-       
+
   register long
     i;
-       
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(image);
   ARG_NOT_USED(indexes);
-  ARG_NOT_USED(exception);     
+  ARG_NOT_USED(exception);
 
   if (param.lut != (PixelPacket *) NULL)
     {
       for(i = 0; i < npixels; i++)
-       {
-         pixels[i].red=param.lut[pixels[i].red].red;
-         pixels[i].green=param.lut[pixels[i].green].green;
-         pixels[i].blue=param.lut[pixels[i].blue].blue;
-       }
+        {
+          pixels[i].red=param.lut[pixels[i].red].red;
+          pixels[i].green=param.lut[pixels[i].green].green;
+          pixels[i].blue=param.lut[pixels[i].blue].blue;
+        }
     }
   else
     {
       for(i = 0; i < npixels; i++)
-       {
-         pixels[i].red=CdlQuantum(pixels[i].red,param.redslope,param.redoffset,
-                                  param.redpower,param.saturation);
-         pixels[i].green=CdlQuantum(pixels[i].green,param.greenslope,param.greenoffset,
-                                    param.greenpower,param.saturation);
-         pixels[i].blue=CdlQuantum(pixels[i].blue,param.blueslope,param.blueoffset,
-                                   param.bluepower,param.saturation);
-       }
+        {
+          pixels[i].red=CdlQuantum(pixels[i].red,param.redslope,param.redoffset,
+                                   param.redpower,param.saturation);
+          pixels[i].green=CdlQuantum(pixels[i].green,param.greenslope,param.greenoffset,
+                                     param.greenpower,param.saturation);
+          pixels[i].blue=CdlQuantum(pixels[i].blue,param.blueslope,param.blueoffset,
+                                    param.bluepower,param.saturation);
+        }
     }
-       
+
   return MagickPass;
 }
 
@@ -178,12 +178,12 @@ MagickExport MagickPassFail CdlImage(Image *image,const char *cdl)
   param.lut=(PixelPacket *) NULL;
 
   (void) sscanf(cdl,
-               "%lf%*[,/]%lf%*[,/]%lf%*[:/]%lf%*[,/]%lf%*[,/]%lf%*"
-               "[:/]%lf%*[,/]%lf%*[,/]%lf%*[:/]%lf",
-               &param.redslope,&param.redoffset,&param.redpower,
-               &param.greenslope,&param.greenoffset,&param.greenpower
-               ,&param.blueslope,&param.blueoffset,&param.bluepower,
-               &param.saturation);
+                "%lf%*[,/]%lf%*[,/]%lf%*[:/]%lf%*[,/]%lf%*[,/]%lf%*"
+                "[:/]%lf%*[,/]%lf%*[,/]%lf%*[:/]%lf",
+                &param.redslope,&param.redoffset,&param.redpower,
+                &param.greenslope,&param.greenoffset,&param.greenpower
+                ,&param.blueslope,&param.blueoffset,&param.bluepower,
+                &param.saturation);
 
   param.redslope=AbsoluteValue(param.redslope);
   param.redpower=AbsoluteValue(param.redpower);
@@ -193,11 +193,11 @@ MagickExport MagickPassFail CdlImage(Image *image,const char *cdl)
   param.bluepower=AbsoluteValue(param.bluepower);
 
   FormatString(progress_message,
-              "[%%s] cdl %g/%g/%g/%g/%g/%g/%g/%g/%g/%g image...",
-              param.redslope,param.redoffset,param.redpower,
-              param.greenslope,param.greenoffset,param.greenpower,
-              param.blueslope,param.blueoffset,param.bluepower,
-              param.saturation);
+               "[%%s] cdl %g/%g/%g/%g/%g/%g/%g/%g/%g/%g image...",
+               param.redslope,param.redoffset,param.redpower,
+               param.greenslope,param.greenoffset,param.greenpower,
+               param.blueslope,param.blueoffset,param.bluepower,
+               param.saturation);
 
   if (!IsRGBCompatibleColorspace(image->colorspace))
     TransformColorspace(image,RGBColorspace);
@@ -209,7 +209,7 @@ MagickExport MagickPassFail CdlImage(Image *image,const char *cdl)
     {
       lut=MagickAllocateMemory(PixelPacket *,(MaxMap+1)*sizeof(PixelPacket));
       if (lut != (PixelPacket *) NULL)
-       {
+        {
 #if (MaxMap > 256) && defined(HAVE_OPENMP)
 #  if defined(USE_STATIC_SCHEDULING_ONLY)
 #    pragma omp parallel for schedule(static,4)
@@ -217,36 +217,34 @@ MagickExport MagickPassFail CdlImage(Image *image,const char *cdl)
 #    pragma omp parallel for schedule(guided)
 #  endif
 #endif
-         for (i=0; i <= (long) MaxMap; i++)
-           {
-             lut[i].red=CdlQuantum((Quantum) i,param.redslope,param.redoffset,
-                                      param.redpower,param.saturation);
-             lut[i].green=CdlQuantum((Quantum) i,param.greenslope,param.greenoffset,
-                                        param.greenpower,param.saturation);
-             lut[i].blue=CdlQuantum((Quantum) i,param.blueslope,param.blueoffset,
-                                       param.bluepower,param.saturation);
-           }
-         param.lut=lut;
-       }
+          for (i=0; i <= (long) MaxMap; i++)
+            {
+              lut[i].red=CdlQuantum((Quantum) i,param.redslope,param.redoffset,
+                                       param.redpower,param.saturation);
+              lut[i].green=CdlQuantum((Quantum) i,param.greenslope,param.greenoffset,
+                                         param.greenpower,param.saturation);
+              lut[i].blue=CdlQuantum((Quantum) i,param.blueslope,param.blueoffset,
+                                        param.bluepower,param.saturation);
+            }
+          param.lut=lut;
+        }
     }
 
   if (image->storage_class == PseudoClass)
     {
       (void) CdlImagePixels(NULL,&param,image,image->colormap,
-                           (IndexPacket *) NULL,image->colors,
-                           &image->exception);
+                            (IndexPacket *) NULL,image->colors,
+                            &image->exception);
       status=SyncImage(image);
     }
   else
     {
       status=PixelIterateMonoModify(CdlImagePixels,NULL,progress_message,
-                                   NULL,&param,0,0,image->columns,image->rows,
-                                   image,&image->exception);
+                                    NULL,&param,0,0,image->columns,image->rows,
+                                    image,&image->exception);
     }
 
   MagickFreeMemory(lut);
 
   return(status);
 }
-
-       
index 468cec2..cb2018a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2004 - 2016 GraphicsMagick Group
+% Copyright (C) 2004 - 2018 GraphicsMagick Group
 %
 % This program is covered by multiple licenses, which are described in
 % Copyright.txt. You should have received a copy of Copyright.txt with this
@@ -50,8 +50,8 @@
     correct transform, and the transform is lossy.
   */
 static MagickPassFail ValidateChannelRequest(const ColorspaceType image_colorspace,
-                                            const ChannelType channel,
-                                            ExceptionInfo *exception)
+                                             const ChannelType channel,
+                                             ExceptionInfo *exception)
 {
   MagickPassFail
     status = MagickPass;
@@ -63,13 +63,13 @@ static MagickPassFail ValidateChannelRequest(const ColorspaceType image_colorspa
     case YellowChannel:
     case BlackChannel:
       if (image_colorspace != CMYKColorspace)
-       status = MagickFail;
+        status = MagickFail;
       break;
     case RedChannel:
     case GreenChannel:
     case BlueChannel:
       if (image_colorspace == CMYKColorspace)
-       status = MagickFail;;
+        status = MagickFail;;
       break;
     default:
       {
@@ -117,7 +117,7 @@ static MagickPassFail ValidateChannelRequest(const ColorspaceType image_colorspa
 static MagickPassFail
 ChannelImagePixels(void *mutable_data,            /* User provided mutable data */
                    const void *immutable_data,    /* User provided immutable data */
-                   Image *image,                  /* Modify image */
+                   Image * restrict image,        /* Modify image */
                    PixelPacket * restrict pixels, /* Pixel row */
                    IndexPacket * restrict indexes,/* Pixel row indexes */
                    const long npixels,            /* Number of pixels in row */
@@ -130,7 +130,7 @@ ChannelImagePixels(void *mutable_data,            /* User provided mutable data
     channel = *((const ChannelType *) immutable_data);
 
   register long
-    i;  
+    i;
 
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(exception);
@@ -243,7 +243,7 @@ MagickExport MagickPassFail ChannelImage(Image *image,const ChannelType channel)
   assert(image->signature == MagickSignature);
 
   FormatString(progress_message,"[%%s] Extract %s channel...  ",
-              ChannelTypeToString(channel));
+               ChannelTypeToString(channel));
 
   /*
     Verify that image colorspace is compatible with with requested
@@ -324,12 +324,12 @@ MagickExport MagickPassFail ChannelImage(Image *image,const ChannelType channel)
 static MagickPassFail
 ExportImageChannelPixels(void *mutable_data,                /* User provided mutable data */
                          const void *immutable_data,        /* User provided immutable data */
-                         const Image *source_image,         /* Source image */
-                         const PixelPacket *source_pixels,  /* Pixel row in source image */
-                         const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                         Image *new_image,                  /* New image */
-                         PixelPacket *new_pixels,           /* Pixel row in new image */
-                         IndexPacket *new_indexes,          /* Pixel row indexes in new image */
+                         const Image * restrict source_image,         /* Source image */
+                         const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                         const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                         Image * restrict new_image,                  /* New image */
+                         PixelPacket * restrict new_pixels,           /* Pixel row in new image */
+                         IndexPacket * restrict new_indexes,          /* Pixel row indexes in new image */
                          const long npixels,                /* Number of pixels in row */
                          ExceptionInfo *exception           /* Exception report */
                          )
@@ -369,7 +369,7 @@ ExportImageChannelPixels(void *mutable_data,                /* User provided mut
           {
             register long
               i;
-            
+
             for (i=0; i < npixels; i++)
               {
                 new_pixels[i].red=new_pixels[i].green=
@@ -392,7 +392,7 @@ ExportImageChannelPixels(void *mutable_data,                /* User provided mut
       {
       }
     }
-  
+
   return MagickPass;
 }
 #define ExportImageChannelText "[%s] Exporting channel...  "
@@ -402,7 +402,7 @@ MagickExport Image *ExportImageChannel(const Image *source_image,
 {
   ChannelType
     channel_type = channel;
-  
+
   Image
     *new_image;
 
@@ -433,7 +433,7 @@ MagickExport Image *ExportImageChannel(const Image *source_image,
                              source_image->columns,source_image->rows,
                              source_image,0,0,
                              new_image,0,0,
-                             exception); 
+                             exception);
 
   new_image->is_grayscale=True;
   new_image->is_monochrome=source_image->is_monochrome;
@@ -506,9 +506,9 @@ MagickExport Image *ExportImageChannel(const Image *source_image,
 static MagickPassFail
 GetImageChannelDepthPixels(void *mutable_data,          /* User provided mutable data */
                            const void *immutable_data,  /* User provided immutable data */
-                           const Image *image,          /* Input image */
-                           const PixelPacket *pixels,   /* Pixel row */
-                           const IndexPacket *indexes,  /* Pixel indexes */
+                           const Image * restrict image,          /* Input image */
+                           const PixelPacket * restrict pixels,   /* Pixel row */
+                           const IndexPacket * restrict indexes,  /* Pixel indexes */
                            const long npixels,          /* Number of pixels in row */
                            ExceptionInfo *exception     /* Exception report */
                            )
@@ -669,12 +669,12 @@ GetImageChannelDepth(const Image *image,
 static MagickPassFail
 ImportImageChannelPixels(void *mutable_data,                /* User provided mutable data */
                          const void *immutable_data,        /* User provided immutable data */
-                         const Image *source_image,         /* Source image */
-                         const PixelPacket *source_pixels,  /* Pixel row in source image */
-                         const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                         Image *update_image,               /* Update image */
-                         PixelPacket *update_pixels,        /* Pixel row in update image */
-                         IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                         const Image * restrict source_image,         /* Source image */
+                         const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                         const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                         Image * restrict update_image,               /* Update image */
+                         PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                         IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                          const long npixels,                /* Number of pixels in row */
                          ExceptionInfo *exception           /* Exception report */
                          )
@@ -800,12 +800,12 @@ MagickPassFail ImportImageChannel(const Image *source_image,
 static MagickPassFail
 ImportImageChannelsMaskedPixels(void *mutable_data,                /* User provided mutable data */
                                 const void *immutable_data,        /* User provided immutable data */
-                                const Image *source_image,         /* Source image */
-                                const PixelPacket *source_pixels,  /* Pixel row in source image */
-                                const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                                Image *update_image,               /* Update image */
-                                PixelPacket *update_pixels,        /* Pixel row in update image */
-                                IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                                const Image * restrict source_image,         /* Source image */
+                                const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                                const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                                Image * restrict update_image,               /* Update image */
+                                PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                                IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                                 const long npixels,                /* Number of pixels in row */
                                 ExceptionInfo *exception           /* Exception report */
                                 )
@@ -866,10 +866,10 @@ MagickPassFail ImportImageChannelsMasked(const Image *source_image,
 {
   ChannelType
     channel_type = channels;
-  
+
   MagickPassFail
     status=MagickPass;
-  
+
   assert(update_image != (Image *) NULL);
   assert(update_image->signature == MagickSignature);
   assert(source_image != (Image *) NULL);
index 5dceaee..56e983a 100644 (file)
@@ -1,10 +1,10 @@
 /*
   Copyright (C) 2004 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
 */
 #ifndef _MAGICK_CHANNEL_H
 #define _MAGICK_CHANNEL_H
index 835cf71..1dff591 100644 (file)
@@ -155,16 +155,16 @@ ComputeCubeInfo(const Image *image,ExceptionInfo *exception)
 
   CubeInfo
     *cube_info;
-  
+
   long
     y;
-  
+
   NodeInfo
     *node_info;
-  
+
   register const PixelPacket
     *p;
-  
+
   register long
     i,
     x;
index f25c745..27654c1 100644 (file)
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2003 - 2010 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Color Utility Methods.
 */
 #ifndef _MAGICK_COLOR_H
@@ -61,28 +61,28 @@ extern MagickExport MagickBool
 /*
   Compare two colors
 */
-#define ColorMatch(p,q)                                                \
-  (((p)->red == (q)->red) &&                                   \
-   ((p)->green == (q)->green) &&                               \
+#define ColorMatch(p,q)                                         \
+  (((p)->red == (q)->red) &&                                    \
+   ((p)->green == (q)->green) &&                                \
    ((p)->blue == (q)->blue))
 
-#define NotColorMatch(p,q)                                     \
-  (((p)->red != (q)->red) ||                                   \
-   ((p)->green != (q)->green) ||                               \
+#define NotColorMatch(p,q)                                      \
+  (((p)->red != (q)->red) ||                                    \
+   ((p)->green != (q)->green) ||                                \
    ((p)->blue != (q)->blue))
 
 extern MagickExport unsigned int
-  FuzzyColorMatch(const PixelPacket *p,const PixelPacket *q,const double fuzz);
+  FuzzyColorMatch(const PixelPacket *p,const PixelPacket *q,const double fuzz) MAGICK_FUNC_PURE;
 
 /*
   Compare two pixels (including opacity)
 */
-#define PixelMatch(p,q,matte)                                  \
-  (ColorMatch(p,q) &&                                          \
+#define PixelMatch(p,q,matte)                                   \
+  (ColorMatch(p,q) &&                                           \
    (!matte || ((p)->opacity == (q)->opacity)))
 
-#define NotPixelMatch(p,q,matte)                               \
-  (NotColorMatch(p,q) ||                                       \
+#define NotPixelMatch(p,q,matte)                                \
+  (NotColorMatch(p,q) ||                                        \
    (matte && ((p)->opacity != (q)->opacity)))
 
 
index b0d88a3..d33fbcb 100644 (file)
@@ -672,7 +672,7 @@ DestroyColorInfoEntry(ColorInfo *entry)
       MagickFreeMemory(entry->path);
       MagickFreeMemory(entry->name);
     }
-  MagickFreeMemory(entry);    
+  MagickFreeMemory(entry);
 }
 MagickExport void
 DestroyColorInfo(void)
@@ -759,16 +759,16 @@ GetColorInfo(const char *name,ExceptionInfo *exception)
     {
       /* Check common synonyms */
       const char
-       *pos;
+        *pos;
 
       LocaleUpper(colorname);
       if ((pos = strstr(colorname,"GREY")) != (const char *) NULL)
-       {
-         colorname[pos-colorname+2]='A';
-         for (p=color_list; p != (ColorInfo *) NULL; p=p->next)
-           if (LocaleCompare(colorname,p->name) == 0)
-             break;
-       }
+        {
+          colorname[pos-colorname+2]='A';
+          for (p=color_list; p != (ColorInfo *) NULL; p=p->next)
+            if (LocaleCompare(colorname,p->name) == 0)
+              break;
+        }
     }
   if (p == (ColorInfo *) NULL)
     ThrowException(exception,OptionWarning,UnrecognizedColor,name);
@@ -1046,15 +1046,15 @@ ListColorInfo(FILE *file,ExceptionInfo *exception)
 
     if (p->color.opacity == OpaqueOpacity)
       (void) fprintf(file,"%5d,%5d,%5d       ",
-                    ScaleQuantumToChar(p->color.red),
-                    ScaleQuantumToChar(p->color.green),
-                    ScaleQuantumToChar(p->color.blue));
+                     ScaleQuantumToChar(p->color.red),
+                     ScaleQuantumToChar(p->color.green),
+                     ScaleQuantumToChar(p->color.blue));
     else
       (void) fprintf(file,"%5d,%5d,%5d,%5d ",
-                    ScaleQuantumToChar(p->color.red),
-                    ScaleQuantumToChar(p->color.green),
-                    ScaleQuantumToChar(p->color.blue),
-                    ScaleQuantumToChar(p->color.opacity));
+                     ScaleQuantumToChar(p->color.red),
+                     ScaleQuantumToChar(p->color.green),
+                     ScaleQuantumToChar(p->color.blue),
+                     ScaleQuantumToChar(p->color.opacity));
     if ((unsigned int) p->compliance & (unsigned int) SVGCompliance)
       (void) fprintf(file,"SVG ");
     if ((unsigned int) p->compliance & (unsigned int) X11Compliance)
@@ -1127,7 +1127,7 @@ InitializeColorInfo(void)
 */
 MagickExport unsigned int
 QueryColorDatabase(const char *name,PixelPacket *color,
-                  ExceptionInfo *exception)
+                   ExceptionInfo *exception)
 {
   double
     scale;
@@ -1234,7 +1234,7 @@ QueryColorDatabase(const char *name,PixelPacket *color,
       {
         unsigned int
           divisor=1;
-        
+
         n<<=2;
         for( i=n-1; i; i--)
           {
@@ -1257,31 +1257,47 @@ QueryColorDatabase(const char *name,PixelPacket *color,
   if (LocaleNCompare(name,"rgb(",4) == 0)
     {
       DoublePixelPacket
-       pixel;
+        pixel;
+
+      int
+        count;
 
       scale=strchr(name,'%') == (char *) NULL ? 1.0 :
         ScaleQuantumToChar(MaxRGB)/100.0;
-      (void) sscanf(name,"%*[^(](%lf%*[%,]%lf%*[%,]%lf",
+      pixel.red=pixel.green=pixel.blue=0.0;
+      count=sscanf(name,"%*[^(](%lf%*[%,]%lf%*[%,]%lf",
         &pixel.red,&pixel.green,&pixel.blue);
-      color->red=ScaleCharToQuantum(scale*pixel.red);
-      color->green=ScaleCharToQuantum(scale*pixel.green);
-      color->blue=ScaleCharToQuantum(scale*pixel.blue);
+      if (count > 0)
+        color->red=ScaleCharToQuantum(scale*pixel.red);
+      if (count > 1)
+        color->green=ScaleCharToQuantum(scale*pixel.green);
+      if (count > 2)
+        color->blue=ScaleCharToQuantum(scale*pixel.blue);
       color->opacity=OpaqueOpacity;
       return(True);
     }
   if (LocaleNCompare(name,"rgba(",5) == 0)
     {
       DoublePixelPacket
-       pixel;
+        pixel;
+
+      int
+        count;
 
       scale=strchr(name,'%') == (char *) NULL ? 1.0 :
         ScaleQuantumToChar(MaxRGB)/100.0;
-      (void) sscanf(name,"%*[^(](%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf",
+      pixel.red=pixel.green=pixel.blue=0.0;
+      color->opacity=OpaqueOpacity;
+      count = sscanf(name,"%*[^(](%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf",
         &pixel.red,&pixel.green,&pixel.blue,&pixel.opacity);
-      color->red=ScaleCharToQuantum(scale*pixel.red);
-      color->green=ScaleCharToQuantum(scale*pixel.green);
-      color->blue=ScaleCharToQuantum(scale*pixel.blue);
-      color->opacity=ScaleCharToQuantum(scale*pixel.opacity);
+      if (count > 0)
+        color->red=ScaleCharToQuantum(scale*pixel.red);
+      if (count > 1)
+        color->green=ScaleCharToQuantum(scale*pixel.green);
+      if (count > 2)
+        color->blue=ScaleCharToQuantum(scale*pixel.blue);
+      if (count > 3)
+        color->opacity=ScaleCharToQuantum(scale*pixel.opacity);
       return(True);
     }
   p=GetColorInfo(name,exception);
@@ -1336,8 +1352,8 @@ QueryColorDatabase(const char *name,PixelPacket *color,
 */
 MagickExport unsigned int
 QueryColorname(const Image *image,const PixelPacket *color,
-              const ComplianceType compliance,char *name,
-              ExceptionInfo *exception)
+               const ComplianceType compliance,char *name,
+               ExceptionInfo *exception)
 {
   register const ColorInfo
     *p;
@@ -1402,8 +1418,8 @@ QueryColorname(const Image *image,const PixelPacket *color,
 */
 static MagickPassFail
 ReadColorConfigureFile(const char *basename,
-                      const unsigned int depth,
-                      ExceptionInfo *exception)
+                       const unsigned int depth,
+                       ExceptionInfo *exception)
 {
   size_t
     length;
@@ -1415,40 +1431,40 @@ ReadColorConfigureFile(const char *basename,
   if (depth == 0)
     {
       size_t
-       i;
+        i;
 
       /*
-       Load default set of colors from the static color table.
+        Load default set of colors from the static color table.
       */
       for (i=0 ; i < sizeof(StaticColors)/sizeof(StaticColors[0]); i++)
-       {
-         ColorInfo
-           *color_info;
+        {
+          ColorInfo
+            *color_info;
 
-         color_info=MagickAllocateMemory(ColorInfo *,sizeof(ColorInfo));
-         if (color_info == (ColorInfo *) NULL)
-           MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
-                             UnableToAllocateColorInfo);
-         color_info->path=(char *) BuiltInPath;
-         color_info->name=(char *) StaticColors[i].name;
-         color_info->compliance=(ComplianceType) StaticColors[i].compliance;
-         color_info->color.red=ScaleCharToQuantum(StaticColors[i].red);
-         color_info->color.green=ScaleCharToQuantum(StaticColors[i].green);
-         color_info->color.blue=ScaleCharToQuantum(StaticColors[i].blue);
-         color_info->color.opacity=ScaleCharToQuantum(StaticColors[i].opacity);
-         color_info->stealth=MagickFalse;
-         color_info->signature=MagickSignature;
-         color_info->previous=(ColorInfo *) NULL;
-         color_info->next=(ColorInfo *) NULL;
-         if (color_list == (ColorInfo *) NULL)
-           {
-             color_list=color_info;
-             continue;
-           }
-         color_list->next=color_info;
-         color_info->previous=color_list;
-         color_list=color_list->next;
-       }
+          color_info=MagickAllocateMemory(ColorInfo *,sizeof(ColorInfo));
+          if (color_info == (ColorInfo *) NULL)
+            MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
+                              UnableToAllocateColorInfo);
+          color_info->path=(char *) BuiltInPath;
+          color_info->name=(char *) StaticColors[i].name;
+          color_info->compliance=(ComplianceType) StaticColors[i].compliance;
+          color_info->color.red=ScaleCharToQuantum(StaticColors[i].red);
+          color_info->color.green=ScaleCharToQuantum(StaticColors[i].green);
+          color_info->color.blue=ScaleCharToQuantum(StaticColors[i].blue);
+          color_info->color.opacity=ScaleCharToQuantum(StaticColors[i].opacity);
+          color_info->stealth=MagickFalse;
+          color_info->signature=MagickSignature;
+          color_info->previous=(ColorInfo *) NULL;
+          color_info->next=(ColorInfo *) NULL;
+          if (color_list == (ColorInfo *) NULL)
+            {
+              color_list=color_info;
+              continue;
+            }
+          color_list->next=color_info;
+          color_info->previous=color_list;
+          color_list=color_list->next;
+        }
     }
 
   /*
@@ -1458,12 +1474,12 @@ ReadColorConfigureFile(const char *basename,
   if (depth == 0)
     {
       ExceptionInfo
-       exception_local;
+        exception_local;
 
       GetExceptionInfo(&exception_local);
       xml=(char *) GetConfigureBlob(basename,path,&length,&exception_local);
       if (exception_local.severity != ConfigureError)
-       CopyException(exception,&exception_local);
+        CopyException(exception,&exception_local);
       DestroyExceptionInfo(&exception_local);
     }
   else
@@ -1473,220 +1489,220 @@ ReadColorConfigureFile(const char *basename,
   if (xml != (char *) NULL)
     {
       char
-       keyword[MaxTextExtent],
-       *q,
-       *token;
+        keyword[MaxTextExtent],
+        *q,
+        *token;
 
       size_t
         token_max_length;
 
       MagickBool
-       in_entry;
+        in_entry;
 
       token=AcquireString(xml);
       token_max_length=strlen(token);
       in_entry=MagickFalse;
       for (q=xml; *q != '\0'; )
-       {
-         /*
-           Interpret XML.
-         */
-         MagickGetToken(q,&q,token,token_max_length);
-         if (*token == '\0')
-           break;
-         (void) strlcpy(keyword,token,sizeof(keyword));
-         if (LocaleNCompare(keyword,"<!--",4) == 0)
-           {
-             /*
-               Comment element.
-             */
-             while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
-               MagickGetToken(q,&q,token,token_max_length);
-             continue;
-           }
-         if (LocaleCompare(keyword,"<include") == 0)
-           {
-             /*
-               Include element.
-             */
-             while ((*token != '>') && (*q != '\0'))
-               {
-                 (void) strlcpy(keyword,token,MaxTextExtent);
-                 MagickGetToken(q,&q,token,token_max_length);
-                 if (*token != '=')
-                   continue;
-                 MagickGetToken(q,&q,token,token_max_length);
-                 if (LocaleCompare(keyword,"file") == 0)
-                   {
-                     if (depth > 200)
-                       ThrowException(exception,ConfigureError,
-                                      IncludeElementNestedTooDeeply,path);
-                     else
-                       {
-                         char
-                           filename[MaxTextExtent];
+        {
+          /*
+            Interpret XML.
+          */
+          MagickGetToken(q,&q,token,token_max_length);
+          if (*token == '\0')
+            break;
+          (void) strlcpy(keyword,token,sizeof(keyword));
+          if (LocaleNCompare(keyword,"<!--",4) == 0)
+            {
+              /*
+                Comment element.
+              */
+              while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
+                MagickGetToken(q,&q,token,token_max_length);
+              continue;
+            }
+          if (LocaleCompare(keyword,"<include") == 0)
+            {
+              /*
+                Include element.
+              */
+              while ((*token != '>') && (*q != '\0'))
+                {
+                  (void) strlcpy(keyword,token,MaxTextExtent);
+                  MagickGetToken(q,&q,token,token_max_length);
+                  if (*token != '=')
+                    continue;
+                  MagickGetToken(q,&q,token,token_max_length);
+                  if (LocaleCompare(keyword,"file") == 0)
+                    {
+                      if (depth > 200)
+                        ThrowException(exception,ConfigureError,
+                                       IncludeElementNestedTooDeeply,path);
+                      else
+                        {
+                          char
+                            filename[MaxTextExtent];
 
-                         GetPathComponent(path,HeadPath,filename);
-                         if (*filename != '\0')
-                           (void) strlcat(filename,DirectorySeparator,sizeof(filename));
-                         (void) strlcat(filename,token,sizeof(filename));
-                         (void) ReadColorConfigureFile(filename,depth+1,exception);
-                       }
-                     if (color_list != (ColorInfo *) NULL)
-                       while (color_list->next != (ColorInfo *) NULL)
-                         color_list=color_list->next;
-                   }
-               }
-             continue;
-           }
-         if (LocaleCompare(keyword,"<color") == 0)
-           {
-             ColorInfo
-               *color_info;
+                          GetPathComponent(path,HeadPath,filename);
+                          if (*filename != '\0')
+                            (void) strlcat(filename,DirectorySeparator,sizeof(filename));
+                          (void) strlcat(filename,token,sizeof(filename));
+                          (void) ReadColorConfigureFile(filename,depth+1,exception);
+                        }
+                      if (color_list != (ColorInfo *) NULL)
+                        while (color_list->next != (ColorInfo *) NULL)
+                          color_list=color_list->next;
+                    }
+                }
+              continue;
+            }
+          if (LocaleCompare(keyword,"<color") == 0)
+            {
+              ColorInfo
+                *color_info;
 
-             /*
-               Allocate memory for the color list.
-             */
-             in_entry=MagickTrue;
-             color_info=MagickAllocateMemory(ColorInfo *,sizeof(ColorInfo));
-             if (color_info == (ColorInfo *) NULL)
-               MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
-                                 UnableToAllocateColorInfo);
-             (void) memset(color_info,0,sizeof(ColorInfo));
-             color_info->path=AcquireString(path);
-             color_info->signature=MagickSignature;
-             if (color_list == (ColorInfo *) NULL)
-               {
-                 color_list=color_info;
-                 continue;
-               }
-             color_list->next=color_info;
-             color_info->previous=color_list;
-             color_list=color_list->next;
-             continue;
-           }
-         if (LocaleCompare(keyword,"/>") == 0)
-           {
-             /*
-               Closing a color specification.
-             */
-             if (in_entry)
-               {
-                 /*
-                   Remove any existing entry with same name (last one wins).
-                 */
-                 {
-                   ColorInfo
-                     *color_info;
-             
-                   for (color_info=color_list->previous;
-                        color_info != (ColorInfo *) NULL;
-                        color_info=color_info->previous)
-                     {
-                       if ((LocaleCompare(color_list->name,color_info->name) == 0) &&
-                           (color_list->compliance == color_info->compliance))
-                         {
-                           DestroyColorInfoEntry(color_info);
-                           break;
-                         }
-                     }
-                 }
-                 in_entry=MagickFalse;
-               }
-           }
-         if (color_list == (ColorInfo *) NULL)
-           continue;
-         MagickGetToken(q,(char **) NULL,token,token_max_length);
-         if (*token != '=')
-           continue;
-         MagickGetToken(q,&q,token,token_max_length);
-         MagickGetToken(q,&q,token,token_max_length);
-         switch (*keyword)
-           {
-           case 'B':
-           case 'b':
-             {
-               if (LocaleCompare((char *) keyword,"blue") == 0)
-                 {
-                   color_list->color.blue=ScaleCharToQuantum(MagickAtoL(token));
-                   break;
-                 }
-               break;
-             }
-           case 'C':
-           case 'c':
-             {
-               if (LocaleCompare((char *) keyword,"compliance") == 0)
-                 {
-                   long
-                     compliance;
+              /*
+                Allocate memory for the color list.
+              */
+              in_entry=MagickTrue;
+              color_info=MagickAllocateMemory(ColorInfo *,sizeof(ColorInfo));
+              if (color_info == (ColorInfo *) NULL)
+                MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
+                                  UnableToAllocateColorInfo);
+              (void) memset(color_info,0,sizeof(ColorInfo));
+              color_info->path=AcquireString(path);
+              color_info->signature=MagickSignature;
+              if (color_list == (ColorInfo *) NULL)
+                {
+                  color_list=color_info;
+                  continue;
+                }
+              color_list->next=color_info;
+              color_info->previous=color_list;
+              color_list=color_list->next;
+              continue;
+            }
+          if (LocaleCompare(keyword,"/>") == 0)
+            {
+              /*
+                Closing a color specification.
+              */
+              if (in_entry)
+                {
+                  /*
+                    Remove any existing entry with same name (last one wins).
+                  */
+                  {
+                    ColorInfo
+                      *color_info;
+
+                    for (color_info=color_list->previous;
+                         color_info != (ColorInfo *) NULL;
+                         color_info=color_info->previous)
+                      {
+                        if ((LocaleCompare(color_list->name,color_info->name) == 0) &&
+                            (color_list->compliance == color_info->compliance))
+                          {
+                            DestroyColorInfoEntry(color_info);
+                            break;
+                          }
+                      }
+                  }
+                  in_entry=MagickFalse;
+                }
+            }
+          if (color_list == (ColorInfo *) NULL)
+            continue;
+          MagickGetToken(q,(char **) NULL,token,token_max_length);
+          if (*token != '=')
+            continue;
+          MagickGetToken(q,&q,token,token_max_length);
+          MagickGetToken(q,&q,token,token_max_length);
+          switch (*keyword)
+            {
+            case 'B':
+            case 'b':
+              {
+                if (LocaleCompare((char *) keyword,"blue") == 0)
+                  {
+                    color_list->color.blue=ScaleCharToQuantum(MagickAtoL(token));
+                    break;
+                  }
+                break;
+              }
+            case 'C':
+            case 'c':
+              {
+                if (LocaleCompare((char *) keyword,"compliance") == 0)
+                  {
+                    long
+                      compliance;
 
-                   compliance=color_list->compliance;
-                   if (GlobExpression(token,"*SVG*"))
-                     compliance|=SVGCompliance;
-                   if (GlobExpression(token,"*X11*"))
-                     compliance|=X11Compliance;
-                   if (GlobExpression(token,"*XPM*"))
-                     compliance|=XPMCompliance;
-                   color_list->compliance=(ComplianceType) compliance;
-                   break;
-                 }
-               break;
-             }
-           case 'G':
-           case 'g':
-             {
-               if (LocaleCompare((char *) keyword,"green") == 0)
-                 {
-                   color_list->color.green=ScaleCharToQuantum(MagickAtoL(token));
-                   break;
-                 }
-               break;
-             }
-           case 'N':
-           case 'n':
-             {
-               if (LocaleCompare((char *) keyword,"name") == 0)
-                 {
-                   color_list->name=AcquireString(token);
-                   break;
-                 }
-               break;
-             }
-           case 'O':
-           case 'o':
-             {
-               if (LocaleCompare((char *) keyword,"opacity") == 0)
-                 {
-                   color_list->color.opacity=ScaleCharToQuantum(MagickAtoL(token));
-                   break;
-                 }
-               break;
-             }
-           case 'R':
-           case 'r':
-             {
-               if (LocaleCompare((char *) keyword,"red") == 0)
-                 {
-                   color_list->color.red=ScaleCharToQuantum(MagickAtoL(token));
-                   break;
-                 }
-               break;
-             }
-           case 'S':
-           case 's':
-             {
-               if (LocaleCompare((char *) keyword,"stealth") == 0)
-                 {
-                   color_list->stealth=LocaleCompare(token,"True") == 0;
-                   break;
-                 }
-               break;
-             }
-           default:
-             break;
-           }
-       }
+                    compliance=color_list->compliance;
+                    if (GlobExpression(token,"*SVG*"))
+                      compliance|=SVGCompliance;
+                    if (GlobExpression(token,"*X11*"))
+                      compliance|=X11Compliance;
+                    if (GlobExpression(token,"*XPM*"))
+                      compliance|=XPMCompliance;
+                    color_list->compliance=(ComplianceType) compliance;
+                    break;
+                  }
+                break;
+              }
+            case 'G':
+            case 'g':
+              {
+                if (LocaleCompare((char *) keyword,"green") == 0)
+                  {
+                    color_list->color.green=ScaleCharToQuantum(MagickAtoL(token));
+                    break;
+                  }
+                break;
+              }
+            case 'N':
+            case 'n':
+              {
+                if (LocaleCompare((char *) keyword,"name") == 0)
+                  {
+                    color_list->name=AcquireString(token);
+                    break;
+                  }
+                break;
+              }
+            case 'O':
+            case 'o':
+              {
+                if (LocaleCompare((char *) keyword,"opacity") == 0)
+                  {
+                    color_list->color.opacity=ScaleCharToQuantum(MagickAtoL(token));
+                    break;
+                  }
+                break;
+              }
+            case 'R':
+            case 'r':
+              {
+                if (LocaleCompare((char *) keyword,"red") == 0)
+                  {
+                    color_list->color.red=ScaleCharToQuantum(MagickAtoL(token));
+                    break;
+                  }
+                break;
+              }
+            case 'S':
+            case 's':
+              {
+                if (LocaleCompare((char *) keyword,"stealth") == 0)
+                  {
+                    color_list->stealth=LocaleCompare(token,"True") == 0;
+                    break;
+                  }
+                break;
+              }
+            default:
+              break;
+            }
+        }
       MagickFreeMemory(token);
       MagickFreeMemory(xml);
     }
index 464ebd5..7d6e88f 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 - 2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Color Lookup Methods.
 */
 #ifndef _MAGICK_COLOR_LOOKUP_H
index 8fb7ce9..876676e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2003 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -53,7 +53,7 @@
 MagickExport MagickPassFail AllocateImageColormap(Image *image,
   const unsigned long colors)
 {
-  register long
+  register unsigned int
     i;
 
   size_t
@@ -71,7 +71,7 @@ MagickExport MagickPassFail AllocateImageColormap(Image *image,
     return (MagickFail);
   image->storage_class=PseudoClass;
   image->colors=colors;
-  length=image->colors*sizeof(PixelPacket);
+  length=MagickArraySize((size_t) image->colors,sizeof(PixelPacket));
   if (image->colormap == (PixelPacket *) NULL)
     image->colormap=MagickAllocateMemory(PixelPacket *,length);
   else
@@ -82,7 +82,7 @@ MagickExport MagickPassFail AllocateImageColormap(Image *image,
       image->storage_class=DirectClass;
       return(MagickFail);
     }
-  for (i=0; i < (long) image->colors; i++)
+  for (i=0; i < image->colors; i++)
   {
     quantum=(Quantum) (i*(MaxRGB/Max(colors-1,1)));
     image->colormap[i].red=quantum;
@@ -123,9 +123,9 @@ MagickExport MagickPassFail AllocateImageColormap(Image *image,
 static MagickPassFail
 CycleColormapCallBack(void *mutable_data,         /* User provided mutable data */
                       const void *immutable_data, /* User provided immutable data */
-                      Image *image,               /* Modify image */
-                      PixelPacket *pixels,        /* Pixel row */
-                      IndexPacket *indexes,       /* Pixel row indexes */
+                      Image * restrict image,               /* Modify image */
+                      PixelPacket * restrict pixels,        /* Pixel row */
+                      IndexPacket * restrict indexes,       /* Pixel row indexes */
                       const long npixels,         /* Number of pixels in row */
                       ExceptionInfo *exception)   /* Exception report */
 {
@@ -210,7 +210,7 @@ MagickExport MagickPassFail  CycleColormapImage(Image *image,const int amount)
 %  the VerifyColormapIndex macro.  If the colormap index is outside the
 %  bounds of the image colormap then zero is returned and an
 %  InvalidColormapIndex exception is thrown, otherwise the colormap
-%  index is returned.
+%  index is returned.  The use of this function is DEPRECATED.
 %
 %  The format of the MagickConstrainColormapIndex method is:
 %
@@ -235,7 +235,7 @@ MagickConstrainColormapIndex(Image *image, unsigned int index)
     {
       char
         colormapIndexBuffer[MaxTextExtent];
-      
+
       FormatString(colormapIndexBuffer,"index %u >= %u colors, %.1024s",
                    index, image->colors, image->filename);
       errno=0;
@@ -288,9 +288,9 @@ MagickConstrainColormapIndex(Image *image, unsigned int index)
 static MagickPassFail
 ReplaceImageColormapCallBack(void *mutable_data,         /* User provided mutable data */
                              const void *immutable_data, /* User provided immutable data */
-                             Image *image,               /* Modify image */
-                             PixelPacket *pixels,        /* Pixel row */
-                             IndexPacket *indexes,       /* Pixel row indexes */
+                             Image * restrict image,               /* Modify image */
+                             PixelPacket * restrict pixels,        /* Pixel row */
+                             IndexPacket * restrict indexes,       /* Pixel row indexes */
                              const long npixels,         /* Number of pixels in row */
                              ExceptionInfo *exception)   /* Exception report */
 {
@@ -336,7 +336,18 @@ ReplaceImageColormap(Image *image,
   assert(image != (Image *) NULL);
   assert(colormap != (const PixelPacket *) NULL);
   assert(colors != 0);
-  assert(image->storage_class == PseudoClass);
+
+  /*
+    Input image is required to have a colormap
+  */
+  if ((image->storage_class != PseudoClass) ||
+      (image->colormap == (PixelPacket *) NULL) ||
+      (image->colors == 0U))
+    {
+      ThrowException(&image->exception,ImageError,
+                     ImageIsNotColormapped,image->filename);
+      return MagickFail;
+    }
 
   /*
     Allocate memory for colormap index
@@ -407,7 +418,7 @@ ReplaceImageColormap(Image *image,
 
   image->is_grayscale=IsGrayImage(image,&image->exception);
   image->is_monochrome=IsMonochromeImage(image,&image->exception);
-  
+
   return status;
 }
 \f
@@ -467,9 +478,9 @@ static int InverseIntensityCompare(const void *x,const void *y)
 static MagickPassFail
 SortColormapByIntensityCallBack(void *mutable_data,         /* User provided mutable data */
                                 const void *immutable_data, /* User provided immutable data */
-                                Image *image,               /* Modify image */
-                                PixelPacket *pixels,        /* Pixel row */
-                                IndexPacket *indexes,       /* Pixel row indexes */
+                                Image * restrict image,               /* Modify image */
+                                PixelPacket * restrict pixels,        /* Pixel row */
+                                IndexPacket * restrict indexes,       /* Pixel row indexes */
                                 const long npixels,         /* Number of pixels in row */
                                 ExceptionInfo *exception)   /* Exception report */
 {
@@ -544,4 +555,3 @@ MagickExport MagickPassFail SortColormapByIntensity(Image *image)
   image->is_monochrome=is_monochrome;
   return(status);
 }
-
index 3c289cb..9a0d1a2 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 - 2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Colormap Methods
 */
 #ifndef _MAGICK_COLORMAP_H
@@ -31,14 +31,33 @@ extern MagickExport MagickPassFail
 
 #if defined(MAGICK_IMPLEMENTATION)
 
+#define VerifyColormapIndexWithColors(image,index,colors)     \
+{ \
+  if (index >= colors) \
+    { \
+      if (image->exception.severity < CorruptImageError ) \
+        { \
+          char \
+            colormapIndexBuffer[MaxTextExtent]; \
+          \
+          FormatString(colormapIndexBuffer, \
+                       "index %" MAGICK_SIZE_T_F "u >= %u colors, %.1024s", \
+                       (MAGICK_SIZE_T) index, (unsigned int) colors, image->filename); \
+          errno=0; \
+          ThrowException(&image->exception,CorruptImageError, \
+                         InvalidColormapIndex,colormapIndexBuffer); \
+        } \
+      index = 0U; \
+    } \
+}
+
 #define VerifyColormapIndex(image,index) \
 { \
-  if (index >= image->colors) \
-    index=MagickConstrainColormapIndex(image,index); \
+  VerifyColormapIndexWithColors(image,index,image->colors) \
 }
 
 extern MagickExport unsigned int
-  MagickConstrainColormapIndex(Image *image, unsigned int index);
+  MagickConstrainColormapIndex(Image *image, unsigned int index) MAGICK_FUNC_DEPRECATED;
 
 #endif /* defined(MAGICK_IMPLEMENTATION) */
 
index 00bcc86..230f52c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2008 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2003 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -73,9 +73,9 @@
 static MagickPassFail
 RGBToCMYKTransform(void *mutable_data,          /* User provided mutable data */
                    const void *immutable_data,  /* User provided immutable data */
-                   Image *image,                /* Modify image */
-                   PixelPacket *pixels,         /* Pixel row */
-                   IndexPacket *indexes,        /* Pixel row indexes */
+                   Image * restrict image,                /* Modify image */
+                   PixelPacket * restrict pixels,         /* Pixel row */
+                   IndexPacket * restrict indexes,        /* Pixel row indexes */
                    const long npixels,          /* Number of pixels in row */
                    ExceptionInfo *exception)    /* Exception report */
 {
@@ -83,19 +83,19 @@ RGBToCMYKTransform(void *mutable_data,          /* User provided mutable data */
     Transform RGB to CMYK(A) pixels.
   */
   register long
-    i;  
-  
+    i;
+
   Quantum
     black,
     cyan,
     magenta,
     yellow;
-  
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(immutable_data);
   ARG_NOT_USED(image);
   ARG_NOT_USED(exception);
-  
+
   for (i=0; i < npixels; i++)
     {
       cyan=(Quantum) (MaxRGB-pixels[i].red);
@@ -108,16 +108,16 @@ RGBToCMYKTransform(void *mutable_data,          /* User provided mutable data */
       indexes[i]=pixels[i].opacity;
       pixels[i].opacity=black;
     }
-  
+
   return MagickPass;
 }
 
 static MagickPassFail
 RGBToCineonLogTransform(void *mutable_data,          /* User provided mutable data */
                         const void *immutable_data,  /* User provided immutable data */
-                        Image *image,                /* Modify image */
-                        PixelPacket *pixels,         /* Pixel row */
-                        IndexPacket *indexes,        /* Pixel row indexes */
+                        Image * restrict image,                /* Modify image */
+                        PixelPacket * restrict pixels,         /* Pixel row */
+                        IndexPacket * restrict indexes,        /* Pixel row indexes */
                         const long npixels,          /* Number of pixels in row */
                         ExceptionInfo *exception)    /* Exception report */
 {
@@ -127,31 +127,31 @@ RGBToCineonLogTransform(void *mutable_data,          /* User provided mutable da
   */
   const unsigned int
     *logmap = (const unsigned int *) immutable_data;
-  
+
   register long
-    i;  
+    i;
 
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(image);
   ARG_NOT_USED(indexes);
   ARG_NOT_USED(exception);
-  
+
   for (i=0; i < npixels; i++)
     {
       pixels[i].red   = logmap[ScaleQuantumToMap(pixels[i].red)];
       pixels[i].green = logmap[ScaleQuantumToMap(pixels[i].green)];
       pixels[i].blue  = logmap[ScaleQuantumToMap(pixels[i].blue)];
     }
-  
+
   return MagickPass;
 }
 
 static MagickPassFail
 RGBToHSLTransform(void *mutable_data,          /* User provided mutable data */
                   const void *immutable_data,  /* User provided immutable data */
-                  Image *image,                /* Modify image */
-                  PixelPacket *pixels,         /* Pixel row */
-                  IndexPacket *indexes,        /* Pixel row indexes */
+                  Image * restrict image,                /* Modify image */
+                  PixelPacket * restrict pixels,         /* Pixel row */
+                  IndexPacket * restrict indexes,        /* Pixel row indexes */
                   const long npixels,          /* Number of pixels in row */
                   ExceptionInfo *exception)    /* Exception report */
 {
@@ -162,16 +162,16 @@ RGBToHSLTransform(void *mutable_data,          /* User provided mutable data */
     h,
     s,
     l;
-  
+
   register long
-    i;  
-  
+    i;
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(immutable_data);
   ARG_NOT_USED(image);
   ARG_NOT_USED(indexes);
   ARG_NOT_USED(exception);
-  
+
   for (i=0; i < npixels; i++)
     {
       TransformHSL(pixels[i].red,pixels[i].green,pixels[i].blue,&h,&s,&l);
@@ -189,9 +189,9 @@ RGBToHSLTransform(void *mutable_data,          /* User provided mutable data */
 static MagickPassFail
 RGBToHWBTransform(void *mutable_data,          /* User provided mutable data */
                   const void *immutable_data,  /* User provided immutable data */
-                  Image *image,                /* Modify image */
-                  PixelPacket *pixels,         /* Pixel row */
-                  IndexPacket *indexes,        /* Pixel row indexes */
+                  Image * restrict image,                /* Modify image */
+                  PixelPacket * restrict pixels,         /* Pixel row */
+                  IndexPacket * restrict indexes,        /* Pixel row indexes */
                   const long npixels,          /* Number of pixels in row */
                   ExceptionInfo *exception)    /* Exception report */
 {
@@ -204,7 +204,7 @@ RGBToHWBTransform(void *mutable_data,          /* User provided mutable data */
     b;
 
   register long
-    i;  
+    i;
 
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(immutable_data);
@@ -249,9 +249,9 @@ static const size_t
 static MagickPassFail
 XYZTransformPackets(void *mutable_data,          /* User provided mutable data */
                     const void *immutable_data,  /* User provided immutable data */
-                    Image *image,                /* Modify image */
-                    PixelPacket *pixels,         /* Pixel row */
-                    IndexPacket *indexes,        /* Pixel row indexes */
+                    Image * restrict image,                /* Modify image */
+                    PixelPacket * restrict pixels,         /* Pixel row */
+                    IndexPacket * restrict indexes,        /* Pixel row indexes */
                     const long npixels,          /* Number of pixels in row */
                     ExceptionInfo *exception)    /* Exception report */
 {
@@ -351,7 +351,7 @@ MagickExport MagickPassFail RGBTransformImage(Image *image,
       */
       if (image->storage_class == PseudoClass)
         {
-          
+
           status=SyncImage(image);
           image->storage_class=DirectClass;
         }
@@ -364,7 +364,7 @@ MagickExport MagickPassFail RGBTransformImage(Image *image,
                                       image,
                                       &image->exception);
       (void) LogMagickEvent(TransformEvent,GetMagickModule(),
-                            "Colorspace transform completed"); 
+                            "Colorspace transform completed");
       return(status);
     }
 
@@ -521,7 +521,7 @@ MagickExport MagickPassFail RGBTransformImage(Image *image,
                                         &image->exception);
         }
       (void) LogMagickEvent(TransformEvent,GetMagickModule(),
-                            "Colorspace transform completed"); 
+                            "Colorspace transform completed");
       return(status);
     }
 
@@ -552,7 +552,7 @@ MagickExport MagickPassFail RGBTransformImage(Image *image,
                                         &image->exception);
         }
       (void) LogMagickEvent(TransformEvent,GetMagickModule(),
-                            "Colorspace transform completed"); 
+                            "Colorspace transform completed");
       return(status);
     }
 
@@ -954,11 +954,11 @@ MagickExport MagickPassFail RGBTransformImage(Image *image,
                ((xform.x[i].x)),
                ((xform.x[i].y)),
                ((xform.x[i].z)),
-             
+
                ((xform.y[i].x)),
                ((xform.y[i].y)),
                ((xform.y[i].z)),
-             
+
                ((xform.z[i].x)),
                ((xform.z[i].y)),
                ((xform.z[i].z)));
@@ -1007,7 +1007,7 @@ MagickExport MagickPassFail RGBTransformImage(Image *image,
   image->is_grayscale=IsGrayColorspace(colorspace);
   (void) LogMagickEvent(TransformEvent,GetMagickModule(),
                         "Transform to colorspace %s completed",
-                        ColorspaceTypeToString(colorspace)); 
+                        ColorspaceTypeToString(colorspace));
   return(status);
 }
 \f
@@ -1112,9 +1112,9 @@ MagickExport MagickPassFail TransformColorspace(Image *image,
 static MagickPassFail
 CMYKToRGBTransform(void *mutable_data,          /* User provided mutable data */
                    const void *immutable_data,  /* User provided immutable data */
-                   Image *image,                /* Modify image */
-                   PixelPacket *pixels,         /* Pixel row */
-                   IndexPacket *indexes,        /* Pixel row indexes */
+                   Image * restrict image,                /* Modify image */
+                   PixelPacket * restrict pixels,         /* Pixel row */
+                   IndexPacket * restrict indexes,        /* Pixel row indexes */
                    const long npixels,          /* Number of pixels in row */
                    ExceptionInfo *exception)    /* Exception report */
 {
@@ -1122,7 +1122,7 @@ CMYKToRGBTransform(void *mutable_data,          /* User provided mutable data */
     Transform CMYK(A) pixels to RGB.
   */
   register long
-    i;  
+    i;
 
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(immutable_data);
@@ -1131,18 +1131,18 @@ CMYKToRGBTransform(void *mutable_data,          /* User provided mutable data */
   for (i=0; i < npixels; i++)
     {
       double
-       black_factor;
+        black_factor;
 
       black_factor=MaxRGBDouble-GetBlackSample(&pixels[i]);
       SetRedSample(&pixels[i],
-                  (Quantum) (((MaxRGBDouble-GetCyanSample(&pixels[i]))*
-                              black_factor)/MaxRGBDouble+0.5));
+                   (Quantum) (((MaxRGBDouble-GetCyanSample(&pixels[i]))*
+                               black_factor)/MaxRGBDouble+0.5));
       SetGreenSample(&pixels[i],
-                    (Quantum) (((MaxRGBDouble-GetMagentaSample(&pixels[i]))*
-                                black_factor)/MaxRGBDouble+0.5));
+                     (Quantum) (((MaxRGBDouble-GetMagentaSample(&pixels[i]))*
+                                 black_factor)/MaxRGBDouble+0.5));
       SetBlueSample(&pixels[i],
-                   (Quantum) (((MaxRGBDouble-GetYellowSample(&pixels[i]))*
-                               black_factor)/ MaxRGBDouble+0.5));
+                    (Quantum) (((MaxRGBDouble-GetYellowSample(&pixels[i]))*
+                                black_factor)/ MaxRGBDouble+0.5));
       SetOpacitySample(&pixels[i],(image->matte ? indexes[i] : OpaqueOpacity));
     }
 
@@ -1152,9 +1152,9 @@ CMYKToRGBTransform(void *mutable_data,          /* User provided mutable data */
 static MagickPassFail
 CineonLogToRGBTransform(void *mutable_data,         /* User provided mutable data */
                         const void *immutable_data, /* User provided immutable data */
-                        Image *image,               /* Modify image */
-                        PixelPacket *pixels,        /* Pixel row */
-                        IndexPacket *indexes,       /* Pixel row indexes */
+                        Image * restrict image,               /* Modify image */
+                        PixelPacket * restrict pixels,        /* Pixel row */
+                        IndexPacket * restrict indexes,       /* Pixel row indexes */
                         const long npixels,         /* Number of pixels in row */
                         ExceptionInfo *exception)   /* Exception report */
 {
@@ -1166,7 +1166,7 @@ CineonLogToRGBTransform(void *mutable_data,         /* User provided mutable dat
     *linearmap = (const Quantum *) immutable_data;
 
   register long
-    i;  
+    i;
 
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(image);
@@ -1187,8 +1187,8 @@ static MagickPassFail
 HSLToRGBTransform(void *mutable_data,         /* User provided mutable data */
                   const void *immutable_data, /* User provided immutable data */
                   Image *image,               /* Modify image */
-                  PixelPacket *pixels,        /* Pixel row */
-                  IndexPacket *indexes,       /* Pixel row indexes */
+                  PixelPacket * restrict pixels,        /* Pixel row */
+                  IndexPacket * restrict indexes,       /* Pixel row indexes */
                   const long npixels,         /* Number of pixels in row */
                   ExceptionInfo *exception)   /* Exception report */
 {
@@ -1196,7 +1196,7 @@ HSLToRGBTransform(void *mutable_data,         /* User provided mutable data */
     Transform pixels from HSL space to RGB space.
   */
   register long
-    i;  
+    i;
 
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(immutable_data);
@@ -1216,9 +1216,9 @@ HSLToRGBTransform(void *mutable_data,         /* User provided mutable data */
 static MagickPassFail
 HWBToRGBTransform(void *mutable_data,         /* User provided mutable data */
                   const void *immutable_data, /* User provided immutable data */
-                  Image *image,               /* Modify image */
-                  PixelPacket *pixels,        /* Pixel row */
-                  IndexPacket *indexes,       /* Pixel row indexes */
+                  Image * restrict image,               /* Modify image */
+                  PixelPacket * restrict pixels,        /* Pixel row */
+                  IndexPacket * restrict indexes,       /* Pixel row indexes */
                   const long npixels,         /* Number of pixels in row */
                   ExceptionInfo *exception)   /* Exception report */
 {
@@ -1226,7 +1226,7 @@ HWBToRGBTransform(void *mutable_data,         /* User provided mutable data */
     Transform pixels from HWB space to RGB space.
   */
   register long
-    i;  
+    i;
 
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(immutable_data);
@@ -1263,9 +1263,9 @@ typedef struct _RGBTransformInfo_t
 static MagickPassFail
 RGBTransformPackets(void *mutable_data,         /* User provided mutable data */
                     const void *immutable_data, /* User provided immutable data */
-                    Image *image,               /* Modify image */
-                    PixelPacket *pixels,        /* Pixel row */
-                    IndexPacket *indexes,       /* Pixel row indexes */
+                    Image * restrict image,               /* Modify image */
+                    PixelPacket * restrict pixels,        /* Pixel row */
+                    IndexPacket * restrict indexes,       /* Pixel row indexes */
                     const long npixels,         /* Number of pixels in row */
                     ExceptionInfo *exception)   /* Exception report */
 {
@@ -1298,11 +1298,11 @@ RGBTransformPackets(void *mutable_data,         /* User provided mutable data */
       r_index = ScaleQuantumToMap(pixels[i].red);
       g_index = ScaleQuantumToMap(pixels[i].green);
       b_index = ScaleQuantumToMap(pixels[i].blue);
-  
+
       r = (xform->r[r_index].r + xform->g[g_index].r + xform->b[b_index].r);
       g = (xform->r[r_index].g + xform->g[g_index].g + xform->b[b_index].g);
       b = (xform->r[r_index].b + xform->g[g_index].b + xform->b[b_index].b);
-  
+
       r = r < 0.0f ? 0.0f : r > MaxMapFloat ? MaxMapFloat : (r + 0.5f);
       g = g < 0.0f ? 0.0f : g > MaxMapFloat ? MaxMapFloat : (g + 0.5f);
       b = b < 0.0f ? 0.0f : b > MaxMapFloat ? MaxMapFloat : (b + 0.5f);
@@ -1365,7 +1365,7 @@ MagickExport MagickPassFail TransformRGBImage(Image *image,
       254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 255, 255,
       255, 255, 255, 255, 255
     };
-  
+
   static const unsigned char
     YCCMap[351] =  /* Photo CD information beyond 100% white, Gamma 2.2 */
     {
@@ -1445,7 +1445,7 @@ MagickExport MagickPassFail TransformRGBImage(Image *image,
                                       &image->exception);
       image->colorspace=RGBColorspace;
       (void) LogMagickEvent(TransformEvent,GetMagickModule(),
-                            "Colorspace transform completed"); 
+                            "Colorspace transform completed");
       return(status);
     }
 
@@ -1600,7 +1600,7 @@ MagickExport MagickPassFail TransformRGBImage(Image *image,
         }
       image->colorspace=RGBColorspace;
       (void) LogMagickEvent(TransformEvent,GetMagickModule(),
-                            "Colorspace transform completed"); 
+                            "Colorspace transform completed");
       return(status);
     }
 
@@ -1632,7 +1632,7 @@ MagickExport MagickPassFail TransformRGBImage(Image *image,
         }
       image->colorspace=RGBColorspace;
       (void) LogMagickEvent(TransformEvent,GetMagickModule(),
-                            "Colorspace transform completed"); 
+                            "Colorspace transform completed");
       return(status);
     }
 
@@ -1970,11 +1970,11 @@ MagickExport MagickPassFail TransformRGBImage(Image *image,
                ((xform.r[i].r)),
                ((xform.r[i].g)),
                ((xform.r[i].b)),
-             
+
                ((xform.g[i].r)),
                ((xform.g[i].g)),
                ((xform.g[i].b)),
-             
+
                ((xform.b[i].r)),
                ((xform.b[i].g)),
                ((xform.b[i].b)));
@@ -2011,7 +2011,7 @@ MagickExport MagickPassFail TransformRGBImage(Image *image,
                                       image,
                                       &image->exception);
       }
-    
+
 
     /*
       Free allocated memory.
@@ -2023,6 +2023,6 @@ MagickExport MagickPassFail TransformRGBImage(Image *image,
   image->is_grayscale=is_grayscale;
   image->colorspace=RGBColorspace;
   (void) LogMagickEvent(TransformEvent,GetMagickModule(),
-                        "Colorspace transform completed"); 
+                        "Colorspace transform completed");
   return(status);
 }
index f14d1ec..690aeb7 100644 (file)
@@ -2,12 +2,12 @@
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
-  GraphicsMagick Colorspace Methods. 
+
+  GraphicsMagick Colorspace Methods.
 */
 #ifndef _MAGICK_COLORSPACE_H
 #define _MAGICK_COLORSPACE_H
index ca8b6b2..0470da2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2017 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -299,8 +299,8 @@ static char commandline[MAX_PARAM_CHAR+2];
 %
 */
 static MagickBool CommandAccessMonitor(const ConfirmAccessMode mode,
-                                      const char *path,
-                                      ExceptionInfo *exception)
+                                       const char *path,
+                                       ExceptionInfo *exception)
 {
   const char
     *env;
@@ -313,7 +313,7 @@ static MagickBool CommandAccessMonitor(const ConfirmAccessMode mode,
       (LocaleCompare(env,"TRUE") == 0))
     {
       (void) fprintf(stderr,"  %s %s\n",
-                    ConfirmAccessModeToString(mode),path);
+                     ConfirmAccessModeToString(mode),path);
     }
   return MagickPass;
 }
@@ -351,9 +351,9 @@ static MagickBool CommandAccessMonitor(const ConfirmAccessMode mode,
 %
 */
 static MagickBool CommandProgressMonitor(const char *task,
-                                        const magick_int64_t quantum,
-                                        const magick_uint64_t span,
-                                        ExceptionInfo *exception)
+                                         const magick_int64_t quantum,
+                                         const magick_uint64_t span,
+                                         ExceptionInfo *exception)
 {
   ARG_NOT_USED(exception);
 
@@ -366,14 +366,14 @@ static MagickBool CommandProgressMonitor(const char *task,
       for (p=task; (*p) && (isspace((int) *p)); p++);
       (void) fprintf(stderr,"  %3lu%% %s\r",
                      (unsigned long)
-                    ((double) 100.0*quantum/
-                     (
+                     ((double) 100.0*quantum/
+                      (
 #ifdef _MSC_VER
 # if _MSC_VER <= 1200 /*Older Visual Studio lacks UINT64 to double conversion*/
-                      (magick_int64_t)
+                       (magick_int64_t)
 # endif
 #endif
-                      span-1)),
+                       span-1)),
                      p);
       if ((magick_uint64_t) quantum == (span-1))
         (void) fprintf(stderr,"\n");
@@ -686,9 +686,9 @@ MagickExport MagickPassFail AnimateImageCommand(ImageInfo *image_info,
       else
         option=(char *) "logo:Untitled";
     if ((strlen(option) < 2) ||
-       /* stdin + subexpression */
-       ((option[0] == '-') && (option[1] == '[')) ||
-       ((option[0] != '-') && option[0] != '+'))
+        /* stdin + subexpression */
+        ((option[0] == '-') && (option[1] == '[')) ||
+        ((option[0] != '-') && option[0] != '+'))
       {
         /*
           Option is a file name.
@@ -715,11 +715,11 @@ MagickExport MagickPassFail AnimateImageCommand(ImageInfo *image_info,
           image_info->dither=quantize_info->dither;
           next_image=ReadImage(image_info,exception);
           if (exception->severity > UndefinedException)
-           {
-             CatchException(exception);
-             DestroyExceptionInfo(exception);
-             GetExceptionInfo(exception);
-           }
+            {
+              CatchException(exception);
+              DestroyExceptionInfo(exception);
+              GetExceptionInfo(exception);
+            }
           status&=next_image != (Image *) NULL;
           if (next_image == (Image *) NULL)
             continue;
@@ -1136,15 +1136,15 @@ MagickExport MagickPassFail AnimateImageCommand(ImageInfo *image_info,
         if (LocaleCompare("monitor",option+1) == 0)
           {
             if (*option == '+')
-             {
-               (void) SetMonitorHandler((MonitorHandler) NULL);
-               (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
-             }
+              {
+                (void) SetMonitorHandler((MonitorHandler) NULL);
+                (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
+              }
             else
-             {
-               (void) SetMonitorHandler(CommandProgressMonitor);
-               (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
-             }
+              {
+                (void) SetMonitorHandler(CommandProgressMonitor);
+                (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
+              }
             break;
           }
         if (LocaleCompare("monochrome",option+1) == 0)
@@ -1444,7 +1444,7 @@ MagickExport MagickPassFail AnimateImageCommand(ImageInfo *image_info,
   ARG_NOT_USED(metadata);
   ARG_NOT_USED(exception);
 
-  MagickFatalError(MissingDelegateError,XWindowLibraryIsNotAvailable,
+  MagickError(MissingDelegateError,XWindowLibraryIsNotAvailable,
     (char *) NULL);
   return(MagickFail);
 #endif
@@ -1519,7 +1519,7 @@ static MagickPassFail BatchCommand(int argc, char **argv)
         perror(argv[result]);
         exit(1);
       }
-      
+
   InitializeBatchOptions(!hasInputFile);
   result = ProcessBatchOptions(argc-1, argv+1, &batch_options);
 
@@ -1714,8 +1714,9 @@ static void BenchmarkUsage(void)
   static const char
     *options[]=
     {
-      "-duration duration  duration to run each benchmark (in seconds)",
-      "-iterations loops   number of command iterations",
+      "-concurrent         run multiple commands in parallel",
+      "-duration duration  duration to run benchmark (in seconds)",
+      "-iterations loops   number of command iterations per benchmark",
       "-rawcsv             CSV output (threads,iterations,user_time,elapsed_time)",
       "-stepthreads step   step benchmark with increasing number of threads",
       (char *) NULL
@@ -1729,7 +1730,12 @@ static void BenchmarkUsage(void)
   (void) printf("\nWhere options include one of:\n");
   for (p=options; *p != (char *) NULL; p++)
     (void) printf("  %.1024s\n",*p);
-  (void) printf("Followed by some other GraphicsMagick command\n");
+  (void) printf("Followed by some other arbitrary GraphicsMagick command.\n\n"
+                "The -concurrent option requires use of -iterations or -duration.\n\n"
+                "Example usages:\n"
+                "  gm benchmark -concurrent -duration 10 convert input.miff -minify output.miff\n"
+                "  gm benchmark -iterations 10 convert input.miff -minify output.miff\n"
+                "  gm benchmark -duration 3 -stepthreads 2 convert input.miff -minify null:\n");
 }
 \f
 /*
@@ -1778,7 +1784,7 @@ static MagickPassFail ExecuteSubCommand(const ImageInfo *image_info,
 
   char
     *text = (char *) NULL;;
-  
+
   clone_info=CloneImageInfo(image_info);
   status=MagickCommand(clone_info,argc,argv,metadata,exception);
   if (metadata != (char **) NULL)
@@ -1799,8 +1805,8 @@ static MagickPassFail ExecuteSubCommand(const ImageInfo *image_info,
 }
 MagickExport MagickPassFail
 BenchmarkImageCommand(ImageInfo *image_info,
-                     int argc,char **argv,
-                     char **metadata,ExceptionInfo *exception)
+                      int argc,char **argv,
+                      char **metadata,ExceptionInfo *exception)
 {
   MagickBool
     concurrent;
@@ -1835,10 +1841,10 @@ BenchmarkImageCommand(ImageInfo *image_info,
     {
       BenchmarkUsage();
       if (argc < 2)
-       {
-         ThrowException(exception,OptionError,UsageError,NULL);
-         return MagickFail;
-       }
+        {
+          ThrowException(exception,OptionError,UsageError,NULL);
+          return MagickFail;
+        }
       return MagickPass;
     }
   if (LocaleCompare("-version",argv[1]) == 0)
@@ -1865,41 +1871,41 @@ BenchmarkImageCommand(ImageInfo *image_info,
   while ((argc) && (*argv[0] == '-'))
     {
       if (LocaleCompare("-duration",argv[0]) == 0)
-       {
-         argc--;
-         argv++;
-         if (argc)
-           {
-             duration=MagickAtoF(argv[0]);
-           }
-       }
+        {
+          argc--;
+          argv++;
+          if (argc)
+            {
+              duration=MagickAtoF(argv[0]);
+            }
+        }
       else if (LocaleCompare("-iterations",argv[0]) == 0)
-       {
-         argc--;
-         argv++;
-         if (argc)
-           {
-             max_iterations=MagickAtoL(argv[0]);
-           }
-       }
+        {
+          argc--;
+          argv++;
+          if (argc)
+            {
+              max_iterations=MagickAtoL(argv[0]);
+            }
+        }
       else if (LocaleCompare("-concurrent",argv[0]) == 0)
-       {
-         concurrent=MagickTrue;
-       }
+        {
+          concurrent=MagickTrue;
+        }
       else if (LocaleCompare("-rawcsv",argv[0]) == 0)
-       {
-         raw_csv=MagickTrue;
-       }
+        {
+          raw_csv=MagickTrue;
+        }
       else if (LocaleCompare("-stepthreads",argv[0]) == 0)
-       {
-         thread_bench=MagickTrue;
-         argc--;
-         argv++;
-         if (argc)
-           {
-             thread_step=MagickAtoL(argv[0]);
-           }
-       }
+        {
+          thread_bench=MagickTrue;
+          argc--;
+          argv++;
+          if (argc)
+            {
+              thread_step=MagickAtoL(argv[0]);
+            }
+        }
       argc--;
       argv++;
     }
@@ -1924,214 +1930,222 @@ BenchmarkImageCommand(ImageInfo *image_info,
   do
     {
       char
-       client_name[MaxTextExtent];
+        client_name[MaxTextExtent];
 
       long
-       iteration=0;
-    
+        iteration=0;
+
       TimerInfo
-       timer;
+        timer;
 
       if (thread_bench)
-       (void) SetMagickResourceLimit(ThreadsResource,current_threads);
+        (void) SetMagickResourceLimit(ThreadsResource,current_threads);
 
 
       (void) strlcpy(client_name,GetClientName(),sizeof(client_name));
 
       /*
-       If doing a thread run-up, then warm things up first with one iteration.
+        If doing a thread run-up, then warm things up first with one iteration.
       */
       if (thread_bench)
-       status=ExecuteSubCommand(image_info,argc,argv,metadata,exception);
+        status=ExecuteSubCommand(image_info,argc,argv,metadata,exception);
 
       GetTimerInfo(&timer);
-    
+
       if (concurrent)
-       {
-         MagickBool
-           quit = MagickFalse;
+        {
+          MagickBool
+            quit = MagickFalse;
 
-         long
-           count = 0;
+          long
+            count = 0;
 
 #if defined(HAVE_OPENMP)
-         omp_set_nested(MagickTrue);
+          omp_set_nested(MagickTrue);
 #endif
-         if (duration > 0)
-           {
-             count=0;
+          if (duration > 0)
+            {
+              count=0;
 #if defined(HAVE_OPENMP)
 #  pragma omp parallel for shared(count, status, quit)
 #endif
-             for (iteration=0; iteration < 1000000; iteration++)
-               {
-                 MagickPassFail
-                   thread_status;
+              for (iteration=0; iteration < 1000000; iteration++)
+                {
+                  MagickPassFail
+                    thread_status;
+
+                  MagickBool
+                    thread_quit;
 
-                 MagickBool
-                   thread_quit;
+                  thread_quit=quit;
 
+                  if (thread_quit)
+                    continue;
+
+                  thread_status=ExecuteSubCommand(image_info,argc,argv,metadata,exception);
 #if defined(HAVE_OPENMP)
 #  pragma omp critical (GM_BenchmarkImageCommand)
 #endif
-                 thread_quit=quit;
-               
-                 if (thread_quit)
-                   continue;
-
-                 thread_status=ExecuteSubCommand(image_info,argc,argv,metadata,exception);
+                  {
+                    count++;
+                    if (!thread_status)
+                      {
+                        status=thread_status;
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_BenchmarkImageCommand)
+#  pragma omp flush (status)
+#endif
+                        thread_quit=MagickTrue;
+                      }
+                    if (GetElapsedTime(&timer) > duration)
+                      thread_quit=MagickTrue;
+                    else
+                      (void) ContinueTimer(&timer);
+                    if (thread_quit)
+                      {
+                        quit=thread_quit;
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (quit)
 #endif
-                 {
-                   count++;
-                   if (!thread_status)
-                     {
-                       status=thread_status;
-                       thread_quit=MagickTrue;
-                     }
-                   if (GetElapsedTime(&timer) > duration)
-                     thread_quit=MagickTrue;
-                   else
-                     (void) ContinueTimer(&timer);
-                   if (thread_quit)
-                     quit=thread_quit;
-                 }
-               }
-           }
-         else if (max_iterations > 0)
-           {
+                      }
+                  }
+                }
+            }
+          else if (max_iterations > 0)
+            {
 #if defined(HAVE_OPENMP)
 #  pragma omp parallel for shared(count, status, quit)
 #endif
-             for (iteration=0; iteration < max_iterations; iteration++)
-               {
-                 MagickPassFail
-                   thread_status;
+              for (iteration=0; iteration < max_iterations; iteration++)
+                {
+                  MagickPassFail
+                    thread_status;
 
-                 MagickBool
-                   thread_quit;
+                  MagickBool
+                    thread_quit;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_BenchmarkImageCommand)
-#endif
-                 thread_quit=quit;
+                  thread_quit=quit;
 
-                 if (thread_quit)
-                   continue;
+                  if (thread_quit)
+                    continue;
 
-                 thread_status=ExecuteSubCommand(image_info,argc,argv,metadata,exception);
+                  thread_status=ExecuteSubCommand(image_info,argc,argv,metadata,exception);
 #if defined(HAVE_OPENMP)
 #  pragma omp critical (GM_BenchmarkImageCommand)
 #endif
-                 {
-                   count++;
-                   if (!thread_status)
-                     {
-                       status=thread_status;
-                       thread_quit=MagickTrue;
-                     }
-                   if (thread_quit)
-                     quit=thread_quit;
-                 }
-               }
-           }
-         iteration=count;
-       }
+                  {
+                    count++;
+                    if (!thread_status)
+                      {
+                        status=thread_status;
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+                        thread_quit=MagickTrue;
+                      }
+                    if (thread_quit)
+                      quit=thread_quit;
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (quit)
+#endif
+                  }
+                }
+            }
+          iteration=count;
+        }
       else
-       {
-         if (duration > 0)
-           {
-             /*
-               Loop until duration or max_iterations has been hit.
-             */
-             for (iteration=0; iteration < (LONG_MAX-1); )
-               {
-                 status=ExecuteSubCommand(image_info,argc,argv,metadata,exception);
-                 iteration++;
-                 if (!status)
-                   break;
-                 if (GetElapsedTime(&timer) > duration)
-                   break;
-                 (void) ContinueTimer(&timer);
-               }
-           }
-         else if (max_iterations > 0)
-           {
-             /*
-               Loop until max_iterations has been hit.
-             */
-             for (iteration=0; iteration < max_iterations; )
-               {
-                 status=ExecuteSubCommand(image_info,argc,argv,metadata,exception);
-                 iteration++;
-                 if (!status)
-                   break;
-               }
-           }
-       }
+        {
+          if (duration > 0)
+            {
+              /*
+                Loop until duration or max_iterations has been hit.
+              */
+              for (iteration=0; iteration < (LONG_MAX-1); )
+                {
+                  status=ExecuteSubCommand(image_info,argc,argv,metadata,exception);
+                  iteration++;
+                  if (!status)
+                    break;
+                  if (GetElapsedTime(&timer) > duration)
+                    break;
+                  (void) ContinueTimer(&timer);
+                }
+            }
+          else if (max_iterations > 0)
+            {
+              /*
+                Loop until max_iterations has been hit.
+              */
+              for (iteration=0; iteration < max_iterations; )
+                {
+                  status=ExecuteSubCommand(image_info,argc,argv,metadata,exception);
+                  iteration++;
+                  if (!status)
+                    break;
+                }
+            }
+        }
       {
-       double
-         rate_cpu,
-         rate_total,
-         /* resolution, */
-         user_time;
-
-       double
-         elapsed_time;
-
-       long
-         threads_limit;
-
-       /* resolution=GetTimerResolution(); */
-       user_time=GetUserTime(&timer);
-       elapsed_time=GetElapsedTime(&timer);
-       rate_total=(((double) iteration)/elapsed_time);
-       rate_cpu=(((double) iteration)/user_time);
-       threads_limit=(long) GetMagickResourceLimit(ThreadsResource);
-       if (1 == threads_limit)
-         rate_total_st=rate_total;
-       (void) fflush(stdout);
-       if (raw_csv)
-         {
-           /* RAW CSV value output */
-           (void) fprintf(stderr,"\"%ld\",\"%ld\",\"%.2f\",\"%.3f\"",
-                          threads_limit,iteration,user_time,elapsed_time);
-         }
-       else
-         {
-           /* Formatted and summarized output */
-           (void) fprintf(stderr,
-                          "Results: %ld threads %ld iter %.2fs user %.2fs total %.3f iter/s "
-                          "%.3f iter/cpu",
-                          threads_limit,iteration,user_time,elapsed_time,rate_total,rate_cpu);
-           if (thread_bench)
-             {
-               double
-                 karp_flatt_metric,
-                 speedup;
-
-               /* Speedup ratio */
-               speedup=rate_total/rate_total_st;
-
-               /* Karp-Flatt metric, http://en.wikipedia.org/wiki/Karp%E2%80%93Flatt_metric */
-               karp_flatt_metric=1.0;
-               if (threads_limit > 1)
-                 karp_flatt_metric=((1.0/Min(threads_limit,speedup))-
-                                    (1.0/threads_limit))/(1.0-(1.0/threads_limit));
-               (void) fprintf(stderr," %.2f speedup %.3f karp-flatt",speedup,karp_flatt_metric);
-             }
-         }
-       (void) fprintf(stderr,"\n");
-       (void) fflush(stderr);
+        double
+          rate_cpu,
+          rate_total,
+          /* resolution, */
+          user_time;
+
+        double
+          elapsed_time;
+
+        long
+          threads_limit;
+
+        /* resolution=GetTimerResolution(); */
+        user_time=GetUserTime(&timer);
+        elapsed_time=GetElapsedTime(&timer);
+        rate_total=(((double) iteration)/elapsed_time);
+        rate_cpu=(((double) iteration)/user_time);
+        threads_limit=(long) GetMagickResourceLimit(ThreadsResource);
+        if (1 == threads_limit)
+          rate_total_st=rate_total;
+        (void) fflush(stdout);
+        if (raw_csv)
+          {
+            /* RAW CSV value output */
+            (void) fprintf(stderr,"\"%ld\",\"%ld\",\"%.2f\",\"%.3f\"",
+                           threads_limit,iteration,user_time,elapsed_time);
+          }
+        else
+          {
+            /* Formatted and summarized output */
+            (void) fprintf(stderr,
+                           "Results: %ld threads %ld iter %.2fs user %.2fs total %.3f iter/s "
+                           "%.3f iter/cpu",
+                           threads_limit,iteration,user_time,elapsed_time,rate_total,rate_cpu);
+            if (thread_bench)
+              {
+                double
+                  karp_flatt_metric,
+                  speedup;
+
+                /* Speedup ratio */
+                speedup=rate_total/rate_total_st;
+
+                /* Karp-Flatt metric, http://en.wikipedia.org/wiki/Karp%E2%80%93Flatt_metric */
+                karp_flatt_metric=1.0;
+                if (threads_limit > 1)
+                  karp_flatt_metric=((1.0/Min(threads_limit,speedup))-
+                                     (1.0/threads_limit))/(1.0-(1.0/threads_limit));
+                (void) fprintf(stderr," %.2f speedup %.3f karp-flatt",speedup,karp_flatt_metric);
+              }
+          }
+        (void) fprintf(stderr,"\n");
+        (void) fflush(stderr);
       }
       /*
-       Always measure with one thread, and then step up as if from zero.
+        Always measure with one thread, and then step up as if from zero.
       */
       if ((current_threads == 1) && (thread_step > 1))
-       current_threads = thread_step;
+        current_threads = thread_step;
       else
-       current_threads += thread_step;
+        current_threads += thread_step;
     }
   while ((thread_bench) && (current_threads <= max_threads));
 
@@ -2274,10 +2288,10 @@ CompareImageCommand(ImageInfo *image_info,
     {
       CompareUsage();
       if (argc < 2)
-       {
-         ThrowException(exception,OptionError,UsageError,NULL);
-         return MagickFail;
-       }
+        {
+          ThrowException(exception,OptionError,UsageError,NULL);
+          return MagickFail;
+        }
       return MagickPass;
     }
   if (LocaleCompare("-version",argv[1]) == 0)
@@ -2308,17 +2322,17 @@ CompareImageCommand(ImageInfo *image_info,
   {
     option=argv[i];
     if ((strlen(option) < 2) ||
-       /* stdin + subexpression */
-       ((option[0] == '-') && (option[1] == '[')) ||
-       ((option[0] != '-') && option[0] != '+'))
+        /* stdin + subexpression */
+        ((option[0] == '-') && (option[1] == '[')) ||
+        ((option[0] != '-') && option[0] != '+'))
       {
         /*
           Read input images.
         */
         filename=argv[i];
         (void) strlcpy(image_info->filename,filename,MaxTextExtent);
-       DestroyExceptionInfo(exception);
-       GetExceptionInfo(exception);
+        DestroyExceptionInfo(exception);
+        GetExceptionInfo(exception);
         if (reference_image == (Image *) NULL)
           {
             reference_image=ReadImage(image_info,exception);
@@ -2477,7 +2491,7 @@ CompareImageCommand(ImageInfo *image_info,
         if (LocaleCompare("help",option+1) == 0)
           {
             CompareUsage();
-           break;
+            break;
             /* ThrowCompareException(OptionError,UsageError,NULL); */
           }
         if ((LocaleCompare("highlight-color",option+1) == 0) ||
@@ -2576,19 +2590,19 @@ CompareImageCommand(ImageInfo *image_info,
       case 'm':
       {
         if (LocaleCompare("matte",option+1) == 0)
-         break;
-       if (LocaleCompare("maximum-error",option+1) == 0)
-         {
-           if (*option == '-')
-              {
-               i++;
-               if (i == argc)
-                 ThrowCompareException(OptionError,MissingArgument,
+          break;
+        if (LocaleCompare("maximum-error",option+1) == 0)
+          {
+            if (*option == '-')
+              {
+                i++;
+                if (i == argc)
+                  ThrowCompareException(OptionError,MissingArgument,
                                         option);
-               maximum_error=MagickAtoF(argv[i]);
-             }
-           break;
-         }
+                maximum_error=MagickAtoF(argv[i]);
+              }
+            break;
+          }
         if (LocaleCompare("metric",option+1) == 0)
           {
             if (*option == '-')
@@ -2607,15 +2621,15 @@ CompareImageCommand(ImageInfo *image_info,
         if (LocaleCompare("monitor",option+1) == 0)
           {
             if (*option == '+')
-             {
-               (void) SetMonitorHandler((MonitorHandler) NULL);
-               (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
-             }
+              {
+                (void) SetMonitorHandler((MonitorHandler) NULL);
+                (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
+              }
             else
-             {
-               (void) SetMonitorHandler(CommandProgressMonitor);
-               (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
-             }
+              {
+                (void) SetMonitorHandler(CommandProgressMonitor);
+                (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
+              }
             break;
           }
         ThrowCompareException(OptionError,UnrecognizedOption,option)
@@ -2735,12 +2749,12 @@ CompareImageCommand(ImageInfo *image_info,
           fprintf(stdout," Opacity: %#-6.2f\n",statistics.opacity);
         fprintf(stdout,"   Total: %#-6.2f\n",statistics.combined);
 
-       if ((maximum_error >= 0.0) && (statistics.combined < maximum_error))
-         {
-           status &= MagickFail;
-           FormatString(message,"%g",statistics.combined);
-           ThrowException(exception,ImageError,ImageDifferenceExceedsLimit,message);
-         }
+        if ((maximum_error >= 0.0) && (statistics.combined < maximum_error))
+          {
+            status &= MagickFail;
+            FormatString(message,"%g",statistics.combined);
+            ThrowException(exception,ImageError,ImageDifferenceExceedsLimit,message);
+          }
       }
     else
       {
@@ -2753,12 +2767,12 @@ CompareImageCommand(ImageInfo *image_info,
           fprintf(stdout," Opacity: %#-12.10f % 10.1f\n",statistics.opacity,statistics.opacity*MaxRGBDouble);
         fprintf(stdout,"   Total: %#-12.10f % 10.1f\n",statistics.combined,statistics.combined*MaxRGBDouble);
 
-       if ((maximum_error >= 0.0) && (statistics.combined > maximum_error))
-         {
-           status &= MagickFail;
-           FormatString(message,"%g > %g",statistics.combined, maximum_error);
-           ThrowException(exception,ImageError,ImageDifferenceExceedsLimit,message);
-         }
+        if ((maximum_error >= 0.0) && (statistics.combined > maximum_error))
+          {
+            status &= MagickFail;
+            FormatString(message,"%g > %g",statistics.combined, maximum_error);
+            ThrowException(exception,ImageError,ImageDifferenceExceedsLimit,message);
+          }
       }
   }
 
@@ -2776,10 +2790,10 @@ CompareImageCommand(ImageInfo *image_info,
           (void) strlcpy(difference_image->filename,difference_filename,
                          MaxTextExtent);
           if (WriteImage(image_info,difference_image) == MagickFail)
-           {
-             status &= MagickFail;
-             CopyException(exception,&difference_image->exception);
-           }
+            {
+              status &= MagickFail;
+              CopyException(exception,&difference_image->exception);
+            }
         }
     }
 
@@ -3101,10 +3115,10 @@ MagickExport MagickPassFail CompositeImageCommand(ImageInfo *image_info,
     {
       CompositeUsage();
       if (argc < 2)
-       {
-         ThrowException(exception,OptionError,UsageError,NULL);
-         return MagickFail;
-       }
+        {
+          ThrowException(exception,OptionError,UsageError,NULL);
+          return MagickFail;
+        }
       return MagickPass;
     }
   if (LocaleCompare("-version",argv[1]) == 0)
@@ -3144,9 +3158,9 @@ MagickExport MagickPassFail CompositeImageCommand(ImageInfo *image_info,
   {
     option=argv[i];
     if ((strlen(option) < 2) ||
-       /* stdin + subexpression */
-       ((option[0] == '-') && (option[1] == '[')) ||
-       ((option[0] != '-') && option[0] != '+'))
+        /* stdin + subexpression */
+        ((option[0] == '-') && (option[1] == '[')) ||
+        ((option[0] != '-') && option[0] != '+'))
       {
         /*
           Read input images.
@@ -3561,7 +3575,7 @@ MagickExport MagickPassFail CompositeImageCommand(ImageInfo *image_info,
         if (LocaleCompare("help",option+1) == 0)
           {
             CompositeUsage();
-           break;
+            break;
             /* ThrowCompositeException(OptionError,UsageError,NULL); */
           }
         ThrowCompositeException(OptionError,UnrecognizedOption,option)
@@ -3644,15 +3658,15 @@ MagickExport MagickPassFail CompositeImageCommand(ImageInfo *image_info,
         if (LocaleCompare("monitor",option+1) == 0)
           {
             if (*option == '+')
-             {
-               (void) SetMonitorHandler((MonitorHandler) NULL);
-               (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
-             }
+              {
+                (void) SetMonitorHandler((MonitorHandler) NULL);
+                (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
+              }
             else
-             {
-               (void) SetMonitorHandler(CommandProgressMonitor);
-               (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
-             }
+              {
+                (void) SetMonitorHandler(CommandProgressMonitor);
+                (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
+              }
             break;
           }
         if (LocaleCompare("monochrome",option+1) == 0)
@@ -3760,12 +3774,12 @@ MagickExport MagickPassFail CompositeImageCommand(ImageInfo *image_info,
           break;
         if (LocaleCompare("repage",option+1) == 0)
           {
-           if (*option == '-')
-             {
-               i++;
-               if ((i == argc) || !IsGeometry(argv[i]))
-                 ThrowCompositeException(OptionError,MissingArgument,option);
-             }
+            if (*option == '-')
+              {
+                i++;
+                if ((i == argc) || !IsGeometry(argv[i]))
+                  ThrowCompositeException(OptionError,MissingArgument,option);
+              }
             break;
           }
         if (LocaleCompare("resize",option+1) == 0)
@@ -3865,9 +3879,9 @@ MagickExport MagickPassFail CompositeImageCommand(ImageInfo *image_info,
             break;
           }
         if (LocaleCompare("strip",option+1) == 0)
-         {
-           break;
-         }
+          {
+            break;
+          }
         ThrowCompositeException(OptionError,UnrecognizedOption,option)
       }
       case 't':
@@ -4292,10 +4306,10 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
     {
       ConvertUsage();
       if (argc < 2)
-       {
-         ThrowException(exception,OptionError,UsageError,NULL);
-         return MagickFail;
-       }
+        {
+          ThrowException(exception,OptionError,UsageError,NULL);
+          return MagickFail;
+        }
       return MagickPass;
     }
   if (LocaleCompare("-version",argv[1]) == 0)
@@ -4332,9 +4346,9 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
   {
     option=argv[i];
     if ((strlen(option) < 2) ||
-       /* stdin + subexpression */
-       ((option[0] == '-') && (option[1] == '[')) ||
-       ((option[0] != '-') && option[0] != '+'))
+        /* stdin + subexpression */
+        ((option[0] == '-') && (option[1] == '[')) ||
+        ((option[0] != '-') && option[0] != '+'))
       {
         /*
           Read input image.
@@ -4391,18 +4405,18 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
             break;
           }
         if (LocaleCompare("append",option+1) == 0)
-         {
-           break;
-         }
-       if (LocaleCompare("asc-cdl",option+1) == 0)
           {
-           if (*option == '-')
+            break;
+          }
+        if (LocaleCompare("asc-cdl",option+1) == 0)
+          {
+            if (*option == '-')
               {
-               i++;
-               if ((i == argc) || !sscanf(argv[i],"%lf",&sans))
-                 ThrowConvertException(OptionError,MissingArgument,option);
+                i++;
+                if ((i == argc) || !sscanf(argv[i],"%lf",&sans))
+                  ThrowConvertException(OptionError,MissingArgument,option);
               }
-           break;
+            break;
           }
         if (LocaleCompare("authenticate",option+1) == 0)
           {
@@ -4563,16 +4577,16 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
           }
         if (LocaleCompare("compose",option+1) == 0)
           {
-           if (*option == '-')
+            if (*option == '-')
               {
-               i++;
-               if (i == argc)
-                 ThrowConvertException(OptionError,MissingArgument,option);
-               option=argv[i];
-               if ((StringToCompositeOperator(option)) == UndefinedCompositeOp)
-                 ThrowConvertException(OptionError,UnrecognizedComposeOperator,
-                                       option);
-             }
+                i++;
+                if (i == argc)
+                  ThrowConvertException(OptionError,MissingArgument,option);
+                option=argv[i];
+                if ((StringToCompositeOperator(option)) == UndefinedCompositeOp)
+                  ThrowConvertException(OptionError,UnrecognizedComposeOperator,
+                                        option);
+              }
             break;
           }
         if (LocaleCompare("colors",option+1) == 0)
@@ -4901,10 +4915,10 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
                   ThrowConvertException(OptionError,MissingArgument,
                     option);
                 format=argv[i];
-               /*
-                 Add definition to defines for use by 'info' coder.
-               */
-               (void) AddDefinition(image_info,"info","format",format,exception);
+                /*
+                  Add definition to defines for use by 'info' coder.
+                */
+                (void) AddDefinition(image_info,"info","format",format,exception);
               }
             break;
           }
@@ -4971,7 +4985,7 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
                 if (i == argc)
                   ThrowConvertException(OptionError,MissingArgument,option);
                 option=argv[i];
-               gravity=StringToGravityType(option);
+                gravity=StringToGravityType(option);
                 if (gravity == ForgetGravity)
                   ThrowConvertException(OptionError,UnrecognizedGravityType,
                     option);
@@ -4992,20 +5006,20 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
       }
       case 'h':
       {
-       if (LocaleCompare("hald-clut",option+1) == 0)
+        if (LocaleCompare("hald-clut",option+1) == 0)
           {
-           if (*option == '-')
+            if (*option == '-')
               {
-               i++;
-               if (i == argc)
-                 ThrowConvertException(OptionError,MissingArgument,option);
+                i++;
+                if (i == argc)
+                  ThrowConvertException(OptionError,MissingArgument,option);
               }
-           break;
+            break;
           }
         if (LocaleCompare("help",option+1) == 0)
           {
             ConvertUsage();
-           break;
+            break;
             /* ThrowConvertException(OptionError,UsageError,NULL); */
           }
         ThrowConvertException(OptionError,UnrecognizedOption,option)
@@ -5233,8 +5247,8 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
                     ThrowConvertException(OptionError,UnrecognizedListType,
                       option)
                 }
-               status=MagickPass;
-               goto convert_cleanup_and_return;
+                status=MagickPass;
+                goto convert_cleanup_and_return;
               }
             break;
           }
@@ -5326,15 +5340,15 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
         if (LocaleCompare("monitor",option+1) == 0)
           {
             if (*option == '+')
-             {
-               (void) SetMonitorHandler((MonitorHandler) NULL);
-               (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
-             }
+              {
+                (void) SetMonitorHandler((MonitorHandler) NULL);
+                (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
+              }
             else
-             {
-               (void) SetMonitorHandler(CommandProgressMonitor);
-               (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
-             }
+              {
+                (void) SetMonitorHandler(CommandProgressMonitor);
+                (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
+              }
             break;
           }
         if (LocaleCompare("monochrome",option+1) == 0)
@@ -5378,15 +5392,15 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
               }
             if (*option == '+')
               {
-               NoiseType
-                 noise_type;
+                NoiseType
+                  noise_type;
 
                 i++;
                 if (i == argc)
                   ThrowConvertException(OptionError,MissingArgument,option);
                 option=argv[i];
-               noise_type=StringToNoiseType(option);
-               if (UndefinedNoise == noise_type)
+                noise_type=StringToNoiseType(option);
+                if (UndefinedNoise == noise_type)
                   ThrowConvertException(OptionError,UnrecognizedNoiseType,
                     option);
               }
@@ -5423,7 +5437,7 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
 
                 double
                   rvalue;
-                  
+
                 /* channel */
                 i++;
                 if (i == argc)
@@ -5625,12 +5639,12 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
           break;
         if (LocaleCompare("repage",option+1) == 0)
           {
-           if (*option == '-')
-             {
-               i++;
-               if ((i == argc) || !IsGeometry(argv[i]))
-                 ThrowConvertException(OptionError,MissingArgument,option);
-             }
+            if (*option == '-')
+              {
+                i++;
+                if ((i == argc) || !IsGeometry(argv[i]))
+                  ThrowConvertException(OptionError,MissingArgument,option);
+              }
             break;
           }
         if (LocaleCompare("resample",option+1) == 0)
@@ -5806,9 +5820,9 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
             break;
           }
         if (LocaleCompare("strip",option+1) == 0)
-         {
-           break;
-         }
+          {
+            break;
+          }
         if (LocaleCompare("stroke",option+1) == 0)
           {
             if (*option == '-')
@@ -6054,7 +6068,7 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
       case '?':
         {
           ConvertUsage();
-         break;
+          break;
           /* ThrowConvertException(OptionError,UsageError,NULL); */
         }
       default:
@@ -6091,8 +6105,8 @@ MagickExport MagickPassFail ConvertImageCommand(ImageInfo *image_info,
         *text;
 
       /*
-       Return formatted string with image characteristics if metadata
-       is requested.
+        Return formatted string with image characteristics if metadata
+        is requested.
       */
       text=TranslateText(image_info,image_list,(format != (char *) NULL) ? format : "%w,%h,%m");
       if (text == (char *) NULL)
@@ -6387,10 +6401,10 @@ MagickExport MagickPassFail ConjureImageCommand(ImageInfo *image_info,
     {
       ConjureUsage();
       if (argc < 2)
-       {
-         ThrowException(exception,OptionError,UsageError,NULL);
-         return MagickFail;
-       }
+        {
+          ThrowException(exception,OptionError,UsageError,NULL);
+          return MagickFail;
+        }
       return MagickPass;
     }
   if (LocaleCompare("-version",argv[1]) == 0)
@@ -6479,9 +6493,9 @@ MagickExport MagickPassFail ConjureImageCommand(ImageInfo *image_info,
     image=ReadImage(image_info,exception);
     if (exception->severity > UndefinedException)
       {
-       CatchException(exception);
-       DestroyExceptionInfo(exception);
-       GetExceptionInfo(exception);
+        CatchException(exception);
+        DestroyExceptionInfo(exception);
+        GetExceptionInfo(exception);
       }
     status&=(image != (Image *) NULL);
     if (image != (Image *) NULL)
@@ -6797,9 +6811,9 @@ MagickExport MagickPassFail DisplayImageCommand(ImageInfo *image_info,
       else
         option=(char *) "logo:Untitled";
     if ((strlen(option) < 2) ||
-       /* stdin + subexpression */
-       ((option[0] == '-') && (option[1] == '[')) ||
-       ((option[0] != '-') && option[0] != '+'))
+        /* stdin + subexpression */
+        ((option[0] == '-') && (option[1] == '[')) ||
+        ((option[0] != '-') && option[0] != '+'))
       {
         /*
           Option is a file name.
@@ -6825,20 +6839,20 @@ MagickExport MagickPassFail DisplayImageCommand(ImageInfo *image_info,
           (void) strcpy(image_info->magick,"MIFF");
           image_info->colorspace=quantize_info->colorspace;
           image_info->dither=quantize_info->dither;
-         DestroyExceptionInfo(exception);
-         GetExceptionInfo(exception);
+          DestroyExceptionInfo(exception);
+          GetExceptionInfo(exception);
           image=ReadImage(image_info,exception);
           if (exception->severity > UndefinedException)
-           {
-             CatchException(exception);
-             DestroyExceptionInfo(exception);
-             GetExceptionInfo(exception);
-           }
+            {
+              CatchException(exception);
+              DestroyExceptionInfo(exception);
+              GetExceptionInfo(exception);
+            }
           status&=image != (Image *) NULL;
           if (image == (Image *) NULL)
             continue;
           status&=MogrifyImage(image_info,i-j,argv+j,&image);
-         (void) CatchImageException(image);
+          (void) CatchImageException(image);
           do
           {
             /*
@@ -7218,7 +7232,7 @@ MagickExport MagickPassFail DisplayImageCommand(ImageInfo *image_info,
                 i++;
                 if (i == argc)
                   MagickFatalError(OptionFatalError,MissingArgument,option);
-                
+
                 (void) CloneString(&image_info->server_name,argv[i]);
               }
             break;
@@ -7374,10 +7388,10 @@ MagickExport MagickPassFail DisplayImageCommand(ImageInfo *image_info,
       case 'h':
       {
         if (LocaleCompare("help",option+1) == 0)
-         {
-           DisplayUsage();
-           break;
-         }
+          {
+            DisplayUsage();
+            break;
+          }
         MagickFatalError(OptionFatalError,UnrecognizedOption,option);
         break;
       }
@@ -7519,15 +7533,15 @@ MagickExport MagickPassFail DisplayImageCommand(ImageInfo *image_info,
         if (LocaleCompare("monitor",option+1) == 0)
           {
             if (*option == '+')
-             {
-               (void) SetMonitorHandler((MonitorHandler) NULL);
-               (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
-             }
+              {
+                (void) SetMonitorHandler((MonitorHandler) NULL);
+                (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
+              }
             else
-             {
-               (void) SetMonitorHandler(CommandProgressMonitor);
-               (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
-             }
+              {
+                (void) SetMonitorHandler(CommandProgressMonitor);
+                (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
+              }
             break;
           }
           if (LocaleCompare("monochrome",option+1) == 0)
@@ -7917,12 +7931,12 @@ MagickExport MagickPassFail DisplayImageCommand(ImageInfo *image_info,
                 if (IsAccessible(resource_info.write_filename))
                   {
                     char
-                     *answer,
+                      *answer,
                       answer_buffer[2];
 
-                   answer_buffer[0]='\0';
+                    answer_buffer[0]='\0';
                     (void) fprintf(stderr,"Overwrite %.1024s? ",
-                                  resource_info.write_filename);
+                                   resource_info.write_filename);
                     answer=fgets(answer_buffer,sizeof(answer_buffer),stdin);
                     if ((NULL == answer) || !((answer[0] == 'y') || (answer[0] == 'Y')))
                       Exit(0);
@@ -7949,7 +7963,7 @@ MagickExport MagickPassFail DisplayImageCommand(ImageInfo *image_info,
     {
       MagickXRetainWindowColors(display,XRootWindow(display,XDefaultScreen(display)));
       (void) XSync(display,MagickFalse);
-    } 
+    }
   if (resource_database != (XrmDatabase) NULL)
     {
       /* It seems that recent X11 libraries (as found in FreeBSD 5.4)
@@ -7973,7 +7987,7 @@ MagickExport MagickPassFail DisplayImageCommand(ImageInfo *image_info,
   ARG_NOT_USED(metadata);
   ARG_NOT_USED(exception);
 
-  MagickFatalError(MissingDelegateError,XWindowLibraryIsNotAvailable,
+  MagickError(MissingDelegateError,XWindowLibraryIsNotAvailable,
     (char *) NULL);
   return(MagickFail);
 #endif
@@ -8140,7 +8154,7 @@ static void GMUsage(void)
   PrintUsageHeader();
   (void) printf("Usage: %.1024s command [options ...]\n",GetClientName());
   (void) printf("\nWhere commands include: \n");
-      
+
   for (i=0; commands[i].command != 0; i++)
     {
       if (commands[i].support_mode & run_mode)
@@ -8194,7 +8208,7 @@ static MagickPassFail HelpCommand(ImageInfo *image_info,
     {
       int
         i;
-      
+
       for (i=0; commands[i].command != 0; i++)
         {
           if (!(commands[i].support_mode & run_mode))
@@ -8210,7 +8224,7 @@ static MagickPassFail HelpCommand(ImageInfo *image_info,
             }
         }
     }
-  
+
   GMUsage();
 
   return MagickPass;
@@ -8298,16 +8312,16 @@ MagickExport MagickPassFail IdentifyImageCommand(ImageInfo *image_info,
 
   /*
     Check for sufficient arguments
-  */  
+  */
   if (argc < 2 || ((argc < 3) && (LocaleCompare("-help",argv[1]) == 0 ||
       LocaleCompare("-?",argv[1]) == 0)))
     {
       IdentifyUsage();
       if (argc < 2)
-       {
-         ThrowException(exception,OptionError,UsageError,NULL);
-         return MagickFail;
-       }
+        {
+          ThrowException(exception,OptionError,UsageError,NULL);
+          return MagickFail;
+        }
       return MagickPass;
     }
   if (LocaleCompare("-version",argv[1]) == 0)
@@ -8354,9 +8368,9 @@ MagickExport MagickPassFail IdentifyImageCommand(ImageInfo *image_info,
   {
     option=argv[i];
     if ((strlen(option) < 2) ||
-       /* stdin + subexpression */
-       ((option[0] == '-') && (option[1] == '[')) ||
-       ((option[0] != '-') && option[0] != '+'))
+        /* stdin + subexpression */
+        ((option[0] == '-') && (option[1] == '[')) ||
+        ((option[0] != '-') && option[0] != '+'))
       {
         /*
           Identify image.
@@ -8379,12 +8393,12 @@ MagickExport MagickPassFail IdentifyImageCommand(ImageInfo *image_info,
           image=PingImage(image_info,exception);
         status&=image != (Image *) NULL;
         if (image == (Image *) NULL)
-         {
-           CatchException(exception);
-           DestroyExceptionInfo(exception);
-           GetExceptionInfo(exception);
-           continue;
-         }
+          {
+            CatchException(exception);
+            DestroyExceptionInfo(exception);
+            GetExceptionInfo(exception);
+            continue;
+          }
         for (p=image; p != (Image *) NULL; p=p->next)
         {
           if (p->scene == 0)
@@ -8551,15 +8565,15 @@ MagickExport MagickPassFail IdentifyImageCommand(ImageInfo *image_info,
         if (LocaleCompare("monitor",option+1) == 0)
           {
             if (*option == '+')
-             {
-               (void) SetMonitorHandler((MonitorHandler) NULL);
-               (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
-             }
+              {
+                (void) SetMonitorHandler((MonitorHandler) NULL);
+                (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
+              }
             else
-             {
-               (void) SetMonitorHandler(CommandProgressMonitor);
-               (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
-             }
+              {
+                (void) SetMonitorHandler(CommandProgressMonitor);
+                (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
+              }
             break;
           }
         ThrowIdentifyException(OptionError,UnrecognizedOption,option)
@@ -8775,6 +8789,9 @@ static void LiberateArgumentList(const int argc,char **argv)
   int
     i;
 
+  if (argv == (char **) NULL)
+    return;
+
   for (i=0; i< argc; i++)
     MagickFreeMemory(argv[i]);
   MagickFreeMemory(argv);
@@ -8838,8 +8855,8 @@ MagickExport MagickPassFail MagickCommand(ImageInfo *image_info,
           char
             command_name[MaxTextExtent];
 
-         const char
-           *pos;
+          const char
+            *pos;
 
           /*
             Append subcommand name to existing client name if end of
@@ -8857,10 +8874,10 @@ MagickExport MagickPassFail MagickCommand(ImageInfo *image_info,
                 {
                   char
                     client_name[MaxTextExtent];
-                    
+
                   FormatString(client_name,"%.1024s %s",GetClientName(),
                                commands[i].command);
-                  
+
                   (void) SetClientName(client_name);
                 }
             }
@@ -9073,12 +9090,12 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             draw_info->text_antialias=(*option == '-');
             break;
           }
-       if (LocaleCompare("asc-cdl",option+1) == 0)
+        if (LocaleCompare("asc-cdl",option+1) == 0)
           {
-           ++i;
-           (void) CdlImage(*image,argv[i]);
-           continue;
-         }
+            ++i;
+            (void) CdlImage(*image,argv[i]);
+            continue;
+          }
         if (LocaleCompare("auto-orient",option+1) == 0)
           {
             Image
@@ -9271,38 +9288,38 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
           {
             quantize_info.number_colors=MagickAtoL(argv[++i]);
 
-           if ( IsGrayColorspace(quantize_info.colorspace) )
-             {
-               /*
-                 If color reduction is requested, then quantize to the requested
-                 number of colors in the gray colorspace, otherwise simply
-                 transform the image to the gray colorspace.
-               */
-               if ( quantize_info.number_colors != 0 )
-                 (void) QuantizeImage(&quantize_info,*image);
-               else
-                 (void) TransformColorspace(*image,quantize_info.colorspace);
-             }
-           else
-             {
-               /*
-                 If color reduction is requested, and the image is DirectClass,
-                 or the image is PseudoClass and the number of colors exceeds
-                 the number requested, then quantize the image colors. Otherwise
-                 compress an existing colormap.
-               */
-               if ( quantize_info.number_colors != 0 )
-                 {
-                   if (((*image)->storage_class == DirectClass) ||
-                       ((*image)->colors > quantize_info.number_colors))
-                     (void) QuantizeImage(&quantize_info,*image);
-                   else
-                     CompressImageColormap(*image);
-                 }
-             }
-
-           quantize_info.number_colors=0;
-           
+            if ( IsGrayColorspace(quantize_info.colorspace) )
+              {
+                /*
+                  If color reduction is requested, then quantize to the requested
+                  number of colors in the gray colorspace, otherwise simply
+                  transform the image to the gray colorspace.
+                */
+                if ( quantize_info.number_colors != 0 )
+                  (void) QuantizeImage(&quantize_info,*image);
+                else
+                  (void) TransformColorspace(*image,quantize_info.colorspace);
+              }
+            else
+              {
+                /*
+                  If color reduction is requested, and the image is DirectClass,
+                  or the image is PseudoClass and the number of colors exceeds
+                  the number requested, then quantize the image colors. Otherwise
+                  compress an existing colormap.
+                */
+                if ( quantize_info.number_colors != 0 )
+                  {
+                    if (((*image)->storage_class == DirectClass) ||
+                        ((*image)->colors > quantize_info.number_colors))
+                      (void) QuantizeImage(&quantize_info,*image);
+                    else
+                      CompressImageColormap(*image);
+                  }
+              }
+
+            quantize_info.number_colors=0;
+
             continue;
           }
         if (LocaleCompare("colorspace",option+1) == 0)
@@ -9335,9 +9352,9 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
           }
         if (LocaleCompare("compose",option+1) == 0)
           {
-           (*image)->compose=CopyCompositeOp;
-           if (*option == '-')
-             (*image)->compose=StringToCompositeOperator(argv[++i]);
+            (*image)->compose=CopyCompositeOp;
+            if (*option == '-')
+              (*image)->compose=StringToCompositeOperator(argv[++i]);
             continue;
           }
         if (LocaleCompare("compress",option+1) == 0)
@@ -9372,7 +9389,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
               x;
 
             unsigned int
-             elements,
+              elements,
               order;
 
             /*
@@ -9382,23 +9399,23 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             for (elements=0; *p != '\0'; elements++)
             {
               MagickGetToken(p,&p,token,MaxTextExtent);
-             if (token[0] == '\0')
-               break;
+              if (token[0] == '\0')
+                break;
               if (*token == ',')
                 MagickGetToken(p,&p,token,MaxTextExtent);
-             if (token[0] == '\0')
-               break;
+              if (token[0] == '\0')
+                break;
             }
             order=(unsigned int) sqrt(elements);
-           if ((0 == elements) || (order*order != elements))
-             {
-               char
-                 message[MaxTextExtent];
-
-               FormatString(message,"%u",elements);
-               ThrowException(&(*image)->exception,OptionError,MatrixIsNotSquare,message);
-               continue;
-             }
+            if ((0 == elements) || (order*order != elements))
+              {
+                char
+                  message[MaxTextExtent];
+
+                FormatString(message,"%u",elements);
+                ThrowException(&(*image)->exception,OptionError,MatrixIsNotSquare,message);
+                continue;
+              }
             kernel=MagickAllocateArray(double *,order*order,sizeof(double));
             if (kernel == (double *) NULL)
               MagickFatalError(ResourceLimitFatalError,MemoryAllocationFailed,
@@ -9407,12 +9424,12 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             for (x=0; *p != '\0'; x++)
             {
               MagickGetToken(p,&p,token,MaxTextExtent);
-             if (token[0] == '\0')
-               break;
+              if (token[0] == '\0')
+                break;
               if (token[0] == ',')
                 MagickGetToken(p,&p,token,MaxTextExtent);
-             if (token[0] == '\0')
-               break;
+              if (token[0] == '\0')
+                break;
               kernel[x]=MagickAtoF(token);
             }
             for ( ; x < (long) (order*order); x++)
@@ -9420,7 +9437,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             convolve_image=ConvolveImage(*image,order,kernel,
               &(*image)->exception);
             MagickFreeMemory(kernel);
-           if (convolve_image == (Image *) NULL)
+            if (convolve_image == (Image *) NULL)
               break;
             DestroyImage(*image);
             *image=convolve_image;
@@ -9428,10 +9445,10 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
           }
         if (LocaleCompare("crop",option+1) == 0)
           {
-           /*
-             FIXME: This command can produce multiple images from one
-             image, causing only the first to be fully processed.
-           */
+            /*
+              FIXME: This command can produce multiple images from one
+              image, causing only the first to be fully processed.
+            */
             TransformImage(image,argv[++i],(char *) NULL);
             continue;
           }
@@ -9558,7 +9575,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
           {
             clone_info->dither=(*option == '-');
             quantize_info.dither=clone_info->dither;
-           (*image)->dither=quantize_info.dither;
+            (*image)->dither=quantize_info.dither;
             continue;
           }
         if (LocaleCompare("draw",option+1) == 0)
@@ -9656,7 +9673,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
           }
         if (LocaleCompare("extent",option+1) == 0)
           {
-           Image
+            Image
               *extent_image;
 
             /*
@@ -9675,7 +9692,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             DestroyImage(*image);
             *image=extent_image;
             continue;
-         }
+          }
         break;
       }
       case 'f':
@@ -9837,7 +9854,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
                 continue;
               }
             option=argv[++i];
-           gravity=StringToGravityType(option);
+            gravity=StringToGravityType(option);
             draw_info->gravity=gravity;
             (*image)->gravity=gravity;
             continue;
@@ -9862,23 +9879,23 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
       }
       case 'h':
       {
-       if (LocaleCompare("hald-clut",option+1) == 0)
-          {
-           Image
-             *clut_image;
-                         
-           (void) strlcpy(clone_info->filename,argv[++i],MaxTextExtent);
-           clut_image=ReadImage(clone_info,&(*image)->exception);
-           if (clut_image == (Image *) NULL)
-             continue;
-           
-           (void) HaldClutImage(*image,clut_image);
-
-           (void) DestroyImage(clut_image);
-           clut_image=(Image *) NULL;
-           continue;
-          }
-       break;
+        if (LocaleCompare("hald-clut",option+1) == 0)
+          {
+            Image
+              *clut_image;
+
+            (void) strlcpy(clone_info->filename,argv[++i],MaxTextExtent);
+            clut_image=ReadImage(clone_info,&(*image)->exception);
+            if (clut_image == (Image *) NULL)
+              continue;
+
+            (void) HaldClutImage(*image,clut_image);
+
+            (void) DestroyImage(clut_image);
+            clut_image=(Image *) NULL;
+            continue;
+          }
+        break;
       }
       case 'i':
       {
@@ -10020,17 +10037,17 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             if (*option == '+')
               continue;
             (void) strlcpy(clone_info->filename,argv[++i],MaxTextExtent);
-           {
-             Image
-               *map_image;
-
-             if ((map_image=ReadImage(clone_info,&(*image)->exception)) !=
-                 (Image *) NULL)
-               {
-                 (void) MapImage(*image,map_image,quantize_info.dither);
-                 DestroyImage(map_image);
-               }
-           }
+            {
+              Image
+                *map_image;
+
+              if ((map_image=ReadImage(clone_info,&(*image)->exception)) !=
+                  (Image *) NULL)
+                {
+                  (void) MapImage(*image,map_image,quantize_info.dither);
+                  DestroyImage(map_image);
+                }
+            }
             continue;
           }
         if (LocaleCompare("mask",option+1) == 0)
@@ -10081,10 +10098,10 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             }
             (void) SetImageType(mask,TrueColorMatteType);
             (void) SetImageClipMask(*image,mask);
-           /*
-             SetImageClipMask clones the image.
-            */
-           DestroyImage(mask);
+            /*
+              SetImageClipMask clones the image.
+             */
+            DestroyImage(mask);
           }
         if (LocaleCompare("matte",option+1) == 0)
           {
@@ -10144,7 +10161,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             (LocaleCompare("monochrome",option+1) == 0))
           {
             clone_info->monochrome=MagickTrue;
-           (void) SetImageType(*image,BilevelType);
+            (void) SetImageType(*image,BilevelType);
             continue;
           }
         if (LocaleCompare("motion-blur",option+1) == 0)
@@ -10170,7 +10187,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             DestroyImage(*image);
             *image=blur_image;
             continue;
-          }        
+          }
         break;
       }
       case 'n':
@@ -10230,7 +10247,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
           {
             ChannelType
               channel;
-            
+
             QuantumOperator
               quantum_operator;
 
@@ -10263,8 +10280,8 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
           }
         if (LocaleCompare("orient",option+1) == 0)
           {
-           (*image)->orientation=UndefinedOrientation;
-           if (*option == '-')
+            (*image)->orientation=UndefinedOrientation;
+            if (*option == '-')
               {
                 char orientation[MaxTextExtent];
                 (*image)->orientation=StringToOrientationType(argv[++i]);
@@ -10290,7 +10307,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
               {
                 char
                   *geometry_str;
-                
+
                 geometry_str=GetPageGeometry(argv[++i]);
                 (void) GetGeometry(geometry_str,&(*image)->page.x,&(*image)->page.y,
                                    &(*image)->page.width,&(*image)->page.height);
@@ -10350,7 +10367,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
 
               Image
                 *profile_image;
-              
+
               ProfileInfo
                 profile_info;
 
@@ -10359,13 +10376,13 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
 
               size_t
                 profile_length;
-              
+
               const unsigned char *
                 profile_data;
 
               ImageProfileIterator
                 profile_iterator;
-              
+
               client_data=clone_info->client_data;
 
               /*
@@ -10374,8 +10391,8 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
               */
               profile_info.name="IPTC";
               profile_info.info=
-               (unsigned char *) GetImageProfile(*image,profile_info.name,
-                                                 &profile_info.length);
+                (unsigned char *) GetImageProfile(*image,profile_info.name,
+                                                  &profile_info.length);
               clone_info->client_data=&profile_info; /* used to pass profile to meta.c */
 
               (void) strlcpy(clone_info->filename,argv[++i],MaxTextExtent);
@@ -10394,35 +10411,35 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
               while(NextImageProfile(profile_iterator,&profile_name,&profile_data,
                                      &profile_length) != MagickFail)
                 {
-                 size_t
-                   existing_length;
+                  size_t
+                    existing_length;
 
                   if (((LocaleCompare(profile_name,"ICC") == 0) ||
-                      (LocaleCompare(profile_name,"ICM") == 0)) &&
-                     (GetImageProfile(*image,"ICM",&existing_length)))
-                   {
-                     (void) LogMagickEvent(TransformEvent,GetMagickModule(),
-                                           "Transform using %s profile \"%s\","
-                                           " %lu bytes",
-                                           profile_name,clone_info->filename,
-                                           (unsigned long) profile_length);
-                     (void) ProfileImage(*image,profile_name,
-                                         (unsigned char *) profile_data,
-                                         profile_length,MagickTrue);
-                   }
+                       (LocaleCompare(profile_name,"ICM") == 0)) &&
+                      (GetImageProfile(*image,"ICM",&existing_length)))
+                    {
+                      (void) LogMagickEvent(TransformEvent,GetMagickModule(),
+                                            "Transform using %s profile \"%s\","
+                                            " %lu bytes",
+                                            profile_name,clone_info->filename,
+                                            (unsigned long) profile_length);
+                      (void) ProfileImage(*image,profile_name,
+                                          (unsigned char *) profile_data,
+                                          profile_length,MagickTrue);
+                    }
                   else
-                   {
-                     (void) LogMagickEvent(TransformEvent,GetMagickModule(),
-                                           "Adding %s profile \"%s\","
-                                           " %lu bytes",
-                                           profile_name,clone_info->filename,
-                                           (unsigned long) profile_length);
-                     (void) SetImageProfile(*image,profile_name,profile_data,profile_length);
-                   }
+                    {
+                      (void) LogMagickEvent(TransformEvent,GetMagickModule(),
+                                            "Adding %s profile \"%s\","
+                                            " %lu bytes",
+                                            profile_name,clone_info->filename,
+                                            (unsigned long) profile_length);
+                      (void) SetImageProfile(*image,profile_name,profile_data,profile_length);
+                    }
                 }
               DeallocateImageProfileIterator(profile_iterator);
               DestroyImage(profile_image);
-             profile_image=(Image *) NULL;
+              profile_image=(Image *) NULL;
               clone_info->client_data=client_data;
             }
             continue;
@@ -10475,7 +10492,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
               x;
 
             unsigned int
-             elements,
+              elements,
               order;
 
             /*
@@ -10485,23 +10502,23 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             for (elements=0; *p != '\0'; elements++)
             {
               MagickGetToken(p,&p,token,MaxTextExtent);
-             if (token[0] == '\0')
-               break;
+              if (token[0] == '\0')
+                break;
               if (token[0] == ',')
                 MagickGetToken(p,&p,token,MaxTextExtent);
-             if (token[0] == '\0')
-               break;
+              if (token[0] == '\0')
+                break;
             }
             order=(unsigned int) sqrt(elements);
-           if ((0 == elements) || (order*order != elements))
-             {
-               char
-                 message[MaxTextExtent];
-
-               FormatString(message,"%u",elements);
-               ThrowException(&(*image)->exception,OptionError,MatrixIsNotSquare,message);
-               continue;
-             }
+            if ((0 == elements) || (order*order != elements))
+              {
+                char
+                  message[MaxTextExtent];
+
+                FormatString(message,"%u",elements);
+                ThrowException(&(*image)->exception,OptionError,MatrixIsNotSquare,message);
+                continue;
+              }
             matrix=MagickAllocateArray(double *,order*order,sizeof(double));
             if (matrix == (double *) NULL)
               MagickFatalError(ResourceLimitFatalError,MemoryAllocationFailed,
@@ -10512,13 +10529,13 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
               MagickGetToken(p,&p,token,MaxTextExtent);
               if (token[0] == ',')
                 MagickGetToken(p,&p,token,MaxTextExtent);
-             if (token[0] == '\0')
-               break;
-             matrix[x]=MagickAtoF(token);
+              if (token[0] == '\0')
+                break;
+              matrix[x]=MagickAtoF(token);
             }
             for ( ; x < (long) (order*order); x++)
               matrix[x]=0.0;
-           (void) ColorMatrixImage(*image,order,matrix);
+            (void) ColorMatrixImage(*image,order,matrix);
             MagickFreeMemory(matrix);
             continue;
           }
@@ -10572,39 +10589,39 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             draw_info->render=(*option == '+');
             continue;
           }
-       if (LocaleCompare("repage",option+1) == 0)
+        if (LocaleCompare("repage",option+1) == 0)
           {
-           if (*option == '+')
-             {
-               /* Reset page to defaults */
+            if (*option == '+')
+              {
+                /* Reset page to defaults */
                 (*image)->page.width=0U;
                 (*image)->page.height=0U;
                 (*image)->page.x=0;
                 (*image)->page.y=0;
-             }
-           else
-             {
-               /* Adjust page offsets */
-               (void) ResetImagePage(*image,argv[++i]);
-             }
+              }
+            else
+              {
+                /* Adjust page offsets */
+                (void) ResetImagePage(*image,argv[++i]);
+              }
             continue;
           }
         if (LocaleCompare("resample",option+1) == 0)
           {
             Image
               *resample_image;
-            
+
             char
               resample_density[MaxTextExtent];
-            
+
             double
               x_resolution,
               y_resolution;
-            
+
             unsigned long
               resample_height,
               resample_width;
-            
+
             /*
               Verify that image contains useful resolution information.
             */
@@ -10614,7 +10631,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
                                ImageDoesNotContainResolution,image_info->filename);
                 continue;
               }
-            
+
             /*
               Obtain target resolution.
             */
@@ -10622,14 +10639,14 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
               unsigned long
                 x_integral_resolution=0,
                 y_integral_resolution=0;
-              
+
               long
                 x,
                 y;
-              
+
               int
                 flags;
-              
+
               flags=GetGeometry(argv[++i],&x,&y,&x_integral_resolution,&y_integral_resolution);
               if (!(flags & HeightValue))
                 y_integral_resolution=x_integral_resolution;
@@ -10637,7 +10654,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
               x_resolution=x_integral_resolution;
               y_resolution=y_integral_resolution;
             }
-            
+
             resample_width=(unsigned long)
               ((*image)->columns*(x_resolution/(*image)->x_resolution)+0.5);
             if (resample_width < 1)
@@ -10653,7 +10670,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             (*image)->y_resolution=y_resolution;
             if ((((*image)->columns == resample_width)) && ((*image)->rows == resample_height))
               break;
-            
+
             /*
               Resample image.
             */
@@ -10935,11 +10952,11 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             *image=spread_image;
             continue;
           }
-       if (LocaleCompare("strip",option+1) == 0)
-         {
-           (void) StripImage(*image);
-           continue;
-         }
+        if (LocaleCompare("strip",option+1) == 0)
+          {
+            (void) StripImage(*image);
+            continue;
+          }
         if (LocaleCompare("stroke",option+1) == 0)
           {
             (void) QueryColorDatabase(argv[++i],&draw_info->stroke,
@@ -11024,7 +11041,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
             draw_info->fill_pattern=
               CloneImage(fill_pattern,0,0,MagickTrue,&(*image)->exception);
             DestroyImage(fill_pattern);
-           fill_pattern=(Image *) NULL;
+            fill_pattern=(Image *) NULL;
             continue;
           }
         if (LocaleCompare("transform",option+1) == 0)
@@ -11123,7 +11140,7 @@ MagickExport MagickPassFail MogrifyImage(const ImageInfo *image_info,
                     (*image)->y_resolution /= 2.54;
                   }
               }
-            
+
             (*image)->units=resolution_type;
             continue;
           }
@@ -11379,7 +11396,7 @@ MagickExport MagickPassFail MogrifyImages(const ImageInfo *image_info,
   for (image=*images; image; image=image->next)
     {
       if (image != *images)
-       fprintf(stderr,", ");
+        fprintf(stderr,", ");
       fprintf(stderr,"0x%p->%s", image, image->filename);
     }
   fprintf(stderr,"):");
@@ -11416,17 +11433,17 @@ MagickExport MagickPassFail MogrifyImages(const ImageInfo *image_info,
     {
       status&=MogrifyImage(image_info,argc,argv,&image);
       {
-       Image
-         *p;
-
-       for (p=image; p != (Image *) NULL; p=p->next)
-         {
-           if (scene)
-             p->scene += i;
-           if (image_info->verbose)
-             (void) DescribeImage(p,stderr,MagickFalse);
-           i++;
-         }
+        Image
+          *p;
+
+        for (p=image; p != (Image *) NULL; p=p->next)
+          {
+            if (scene)
+              p->scene += i;
+            if (image_info->verbose)
+              (void) DescribeImage(p,stderr,MagickFalse);
+            i++;
+          }
       }
       AppendImageToList(&mogrify_images,image);
     }
@@ -11513,16 +11530,16 @@ MagickExport MagickPassFail MogrifyImages(const ImageInfo *image_info,
       {
         if (LocaleCompare("flatten",option+1) == 0)
           {
-           Image
-             *flatten_image;
-           
-           flatten_image=FlattenImages(mogrify_images,
-                                       &mogrify_images->exception);
-           if (flatten_image != (Image *) NULL)
-             {
-               DestroyImageList(mogrify_images);
-               mogrify_images=flatten_image;
-             }
+            Image
+              *flatten_image;
+
+            flatten_image=FlattenImages(mogrify_images,
+                                        &mogrify_images->exception);
+            if (flatten_image != (Image *) NULL)
+              {
+                DestroyImageList(mogrify_images);
+                mogrify_images=flatten_image;
+              }
             break;
           }
         break;
@@ -11583,13 +11600,13 @@ MagickExport MagickPassFail MogrifyImages(const ImageInfo *image_info,
             int
               next,
               t_status;
-           
+
             size_t
               length;
-           
+
             TokenInfo
               token_info;
-           
+
             length=strlen(argv[++i]);
             token=MagickAllocateMemory(char *,length+1);
             if (token == (char *) NULL)
@@ -11599,16 +11616,16 @@ MagickExport MagickPassFail MogrifyImages(const ImageInfo *image_info,
                argument like "analyze" but works for "analyze=" */
             arguments=argv[i];
             t_status=Tokenizer(&token_info,0,token,length,arguments,
-                              (char *) "",(char *) "=",(char *) "\"",
-                              0,&breaker,&next,&quote);
+                               (char *) "",(char *) "=",(char *) "\"",
+                               0,&breaker,&next,&quote);
             if (t_status == 0)
               {
                 char
                   *t_argv;
-               
+
                 t_argv=&(arguments[next]);
                 (void) ExecuteModuleProcess(token,&mogrify_images,1,
-                                           &t_argv);
+                                            &t_argv);
               }
             MagickFreeMemory(token);
             continue;
@@ -11714,7 +11731,7 @@ static MagickPassFail* TransmogrifyImage(TransmogrifyOptions *options)
 
       if (status == MagickFail)
         break;
-        
+
       /*
         Transmogrify image as defined by the preceding image
         processing options.
@@ -11748,11 +11765,11 @@ static MagickPassFail* TransmogrifyImage(TransmogrifyOptions *options)
       */
       (void) strlcpy(output_filename,"",MaxTextExtent);
       if (((const char *) NULL != options->output_directory) &&
-         (options->output_directory[0] != '\0'))
+          (options->output_directory[0] != '\0'))
         {
           size_t
             output_directory_length;
-                  
+
           output_directory_length = strlen(options->output_directory);
           if (0 != output_directory_length)
             {
@@ -11781,13 +11798,13 @@ static MagickPassFail* TransmogrifyImage(TransmogrifyOptions *options)
           */
           char
             directory[MaxTextExtent];
-                  
+
           GetPathComponent(output_filename,HeadPath,directory);
           if (IsAccessibleNoLogging(directory) == MagickFalse)
             {
               if (image_info->verbose)
                 fprintf(stdout,"Creating directory \"%s\".\n",directory);
-                      
+
               if (MagickCreateDirectoryPath(directory,&options->exception)
                   == MagickFail)
                 {
@@ -11795,7 +11812,7 @@ static MagickPassFail* TransmogrifyImage(TransmogrifyOptions *options)
                 }
             }
           if (status == MagickFail)
-            break;          
+            break;
         }
       if (LocaleCompare(image_info->filename,"-") != 0)
         {
@@ -11872,47 +11889,47 @@ LoadAndCacheImageFile(char **filename,long *id,ExceptionInfo *exception)
   if (LocaleNCompare(*filename,"MPRI:",5) != 0)
     {
       ImageInfo
-       *image_info;
-      
+        *image_info;
+
       image_info=CloneImageInfo((const ImageInfo *) NULL);
       if (image_info != (ImageInfo *) NULL)
-       {
-         Image
-           *clut_image;
-         
-         (void) strlcpy(image_info->filename,*filename,MaxTextExtent);
-         clut_image=ReadImage(image_info,exception);
-         if (clut_image != (Image *) NULL)
-           {
-             *id=SetMagickRegistry(ImageRegistryType,clut_image,sizeof(Image),exception);
-             if (*id != -1)
-               {
-                 char
-                   mpri[MaxTextExtent];
-                 
-                 FormatString(mpri,"MPRI:%ld",*id);
-                 MagickFreeMemory(*filename);
-                 *filename=AcquireString(mpri);
-                 if (*filename != (char *) NULL)
-                   status=MagickPass;
-               }
-             DestroyImage(clut_image);
-           }
-         DestroyImageInfo(image_info);
-       }
+        {
+          Image
+            *clut_image;
+
+          (void) strlcpy(image_info->filename,*filename,MaxTextExtent);
+          clut_image=ReadImage(image_info,exception);
+          if (clut_image != (Image *) NULL)
+            {
+              *id=SetMagickRegistry(ImageRegistryType,clut_image,sizeof(Image),exception);
+              if (*id != -1)
+                {
+                  char
+                    mpri[MaxTextExtent];
+
+                  FormatString(mpri,"MPRI:%ld",*id);
+                  MagickFreeMemory(*filename);
+                  *filename=AcquireString(mpri);
+                  if (*filename != (char *) NULL)
+                    status=MagickPass;
+                }
+              DestroyImage(clut_image);
+            }
+          DestroyImageInfo(image_info);
+        }
     }
   return status;
 }
 
 #define MaxStaticArrayEntries(a) (sizeof(a)/sizeof(*a))
 
-#define CacheArgumentImage(argp,cache,index,exception) \
-  {                                                                    \
-    if (index < MaxStaticArrayEntries(cache))                          \
-      {                                                                        \
-       if (LoadAndCacheImageFile(argp,&cache[index],exception)) \
-         index++;                                                      \
-      }                                                                        \
+#define CacheArgumentImage(argp,cache,index,exception)  \
+  {                                                                     \
+    if (index < MaxStaticArrayEntries(cache))                           \
+      {                                                                 \
+        if (LoadAndCacheImageFile(argp,&cache[index],exception)) \
+          index++;                                                      \
+      }                                                                 \
 }
 
 
@@ -11935,7 +11952,7 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
     x;
 
   size_t
-    image_cache_entries=0;    
+    image_cache_entries=0;
 
   register long
     i;
@@ -11950,16 +11967,16 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
 
   /*
     Check for sufficient arguments
-  */  
+  */
   if (argc < 2 || ((argc < 3) && (LocaleCompare("-help",argv[1]) == 0 ||
       LocaleCompare("-?",argv[1]) == 0)))
     {
       MogrifyUsage();
       if (argc < 2)
-       {
-         ThrowException(exception,OptionError,UsageError,NULL);
-         return MagickFail;
-       }
+        {
+          ThrowException(exception,OptionError,UsageError,NULL);
+          return MagickFail;
+        }
       return MagickPass;
     }
   if (LocaleCompare("-version",argv[1]) == 0)
@@ -12037,15 +12054,15 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
             image_info->antialias=(*option == '-');
             break;
           }
-       if (LocaleCompare("asc-cdl",option+1) == 0)
+        if (LocaleCompare("asc-cdl",option+1) == 0)
           {
-           if (*option == '-')
+            if (*option == '-')
               {
-               i++;
-               if ((i == argc) || !sscanf(argv[i],"%lf",&sans))
-                 ThrowMogrifyException(OptionError,MissingArgument,option);
+                i++;
+                if ((i == argc) || !sscanf(argv[i],"%lf",&sans))
+                  ThrowMogrifyException(OptionError,MissingArgument,option);
               }
-           break;
+            break;
           }
         if (LocaleCompare("authenticate",option+1) == 0)
           {
@@ -12227,16 +12244,16 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
           }
         if (LocaleCompare("compose",option+1) == 0)
           {
-           if (*option == '-')
+            if (*option == '-')
               {
-               i++;
-               if (i == argc)
-                 ThrowMogrifyException(OptionError,MissingArgument,option);
-               option=argv[i];
-               if ((StringToCompositeOperator(option)) == UndefinedCompositeOp)
-                 ThrowMogrifyException(OptionError,UnrecognizedComposeOperator,
-                                       option);
-             }
+                i++;
+                if (i == argc)
+                  ThrowMogrifyException(OptionError,MissingArgument,option);
+                option=argv[i];
+                if ((StringToCompositeOperator(option)) == UndefinedCompositeOp)
+                  ThrowMogrifyException(OptionError,UnrecognizedComposeOperator,
+                                        option);
+              }
             break;
           }
         if (LocaleCompare("compress",option+1) == 0)
@@ -12610,7 +12627,7 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
                 if (i == argc)
                   ThrowMogrifyException(OptionError,MissingArgument,option);
                 option=argv[i];
-               gravity=StringToGravityType(option);
+                gravity=StringToGravityType(option);
                 if (gravity == ForgetGravity)
                   ThrowMogrifyException(OptionError,UnrecognizedGravityType,
                     option);
@@ -12631,23 +12648,23 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
       }
       case 'h':
       {
-       if (LocaleCompare("hald-clut",option+1) == 0)
+        if (LocaleCompare("hald-clut",option+1) == 0)
           {
-           if (*option == '-')
+            if (*option == '-')
               {
-               i++;
-               if (i == argc)
-                 ThrowMogrifyException(OptionError,MissingArgument,option);
+                i++;
+                if (i == argc)
+                  ThrowMogrifyException(OptionError,MissingArgument,option);
 
-               /*
-                 Cache argument image.
-               */
-               CacheArgumentImage(&argv[i],image_cache,image_cache_entries,
-                                  exception);
+                /*
+                  Cache argument image.
+                */
+                CacheArgumentImage(&argv[i],image_cache,image_cache_entries,
+                                   exception);
               }
-           break;
+            break;
           }
-       if (LocaleCompare("help",option+1) == 0)
+        if (LocaleCompare("help",option+1) == 0)
           break;
         ThrowMogrifyException(OptionError,UnrecognizedOption,option)
       }
@@ -12850,7 +12867,7 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
                       option)
                 }
                 status=MagickPass;
-               goto mogrify_cleanup_and_return;
+                goto mogrify_cleanup_and_return;
               }
             break;
           }
@@ -12892,11 +12909,11 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
                   ThrowMogrifyException(OptionError,MissingArgument,
                     option);
 
-               /*
-                 Cache argument image.
-               */
-               CacheArgumentImage(&argv[i],image_cache,image_cache_entries,
-                                  exception);
+                /*
+                  Cache argument image.
+                */
+                CacheArgumentImage(&argv[i],image_cache,image_cache_entries,
+                                   exception);
               }
             break;
           }
@@ -12909,11 +12926,11 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
                   ThrowMogrifyException(OptionError,MissingArgument,
                     option);
 
-               /*
-                 Cache argument image.
-               */
-               CacheArgumentImage(&argv[i],image_cache,image_cache_entries,
-                                  exception);
+                /*
+                  Cache argument image.
+                */
+                CacheArgumentImage(&argv[i],image_cache,image_cache_entries,
+                                   exception);
               }
             break;
           }
@@ -12957,15 +12974,15 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
         if (LocaleCompare("monitor",option+1) == 0)
           {
             if (*option == '+')
-             {
-               (void) SetMonitorHandler((MonitorHandler) NULL);
-               (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
-             }
+              {
+                (void) SetMonitorHandler((MonitorHandler) NULL);
+                (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
+              }
             else
-             {
-               (void) SetMonitorHandler(CommandProgressMonitor);
-               (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
-             }
+              {
+                (void) SetMonitorHandler(CommandProgressMonitor);
+                (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
+              }
             break;
           }
         if (LocaleCompare("monochrome",option+1) == 0)
@@ -13003,8 +13020,8 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
                 if (i == argc)
                   ThrowMogrifyException(OptionError,MissingArgument,option);
                 option=argv[i];
-               noise_type=StringToNoiseType(option);
-               if (UndefinedNoise == noise_type)
+                noise_type=StringToNoiseType(option);
+                if (UndefinedNoise == noise_type)
                   ThrowMogrifyException(OptionError,UnrecognizedNoiseType,
                     option);
               }
@@ -13092,14 +13109,14 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
           }
         if (LocaleCompare("output-directory",option+1) == 0)
           {
-           output_directory[0]='\0';
+            output_directory[0]='\0';
             if (*option == '-')
               {
                 i++;
                 if (i == argc)
                   ThrowMogrifyException(OptionError,MissingArgument,
                     option);
-               (void) strlcpy(output_directory,argv[i],sizeof(output_directory));
+                (void) strlcpy(output_directory,argv[i],sizeof(output_directory));
               }
             break;
           }
@@ -13231,12 +13248,12 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
           break;
         if (LocaleCompare("repage",option+1) == 0)
           {
-           if (*option == '-')
-             {
-               i++;
-               if ((i == argc) || !IsGeometry(argv[i]))
-                 ThrowMogrifyException(OptionError,MissingArgument,option);
-             }
+            if (*option == '-')
+              {
+                i++;
+                if ((i == argc) || !IsGeometry(argv[i]))
+                  ThrowMogrifyException(OptionError,MissingArgument,option);
+              }
             break;
           }
         if (LocaleCompare("resample",option+1) == 0)
@@ -13431,9 +13448,9 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
             break;
           }
         if (LocaleCompare("strip",option+1) == 0)
-         {
-           break;
-         }
+          {
+            break;
+          }
         if (LocaleCompare("stroke",option+1) == 0)
           {
             if (*option == '-')
@@ -13507,11 +13524,11 @@ MagickExport MagickPassFail MogrifyImageCommand(ImageInfo *image_info,
             if (i == argc)
               ThrowMogrifyException(OptionError,MissingArgument,option);
 
-           /*
-             Cache argument image.
-           */
-           CacheArgumentImage(&argv[i],image_cache,image_cache_entries,
-                              exception);
+            /*
+              Cache argument image.
+            */
+            CacheArgumentImage(&argv[i],image_cache,image_cache_entries,
+                               exception);
             break;
           }
         if (LocaleCompare("transform",option+1) == 0)
@@ -13931,23 +13948,15 @@ static void MogrifyUsage(void)
 */
 #define ThrowMontageException(code,reason,description) \
 { \
-  DestroyImageList(image); \
-  DestroyImageList(image_list); \
-  DestroyImageList(montage_image); \
-  DestroyMontageInfo(montage_info); \
+  status = MagickFail; \
   ThrowException(exception,code,reason,description); \
-  LiberateArgumentList(argc,argv); \
-  return(MagickFail); \
+  goto montage_cleanup_and_return; \
 }
 #define ThrowMontageException3(code,reason,description) \
 { \
-  DestroyImageList(image); \
-  DestroyImageList(image_list); \
-  DestroyImageList(montage_image); \
-  DestroyMontageInfo(montage_info); \
+  status = MagickFail; \
   ThrowException3(exception,code,reason,description); \
-  LiberateArgumentList(argc,argv); \
-  return(MagickFail); \
+  goto montage_cleanup_and_return; \
 }
 MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info,
   int argc,char **argv,char **metadata,ExceptionInfo *exception)
@@ -13961,10 +13970,10 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info,
     sans;
 
   Image
-    *image,
-    *image_list,
-    *montage_image,
-    *next_image;
+    *image = (Image *) NULL,
+    *image_list = (Image *) NULL,
+    *montage_image = (Image *) NULL,
+    *next_image = (Image *) NULL;
 
   long
     first_scene,
@@ -13975,7 +13984,7 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info,
     x;
 
   MontageInfo
-    *montage_info;
+    *montage_info = (MontageInfo *) NULL;
 
   QuantizeInfo
     quantize_info;
@@ -13994,10 +14003,10 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info,
     {
       MontageUsage();
       if (argc < 2)
-       {
-         ThrowException(exception,OptionError,UsageError,NULL);
-         return MagickFail;
-       }
+        {
+          ThrowException(exception,OptionError,UsageError,NULL);
+          return MagickFail;
+        }
       return MagickPass;
     }
 
@@ -14034,9 +14043,9 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info,
   {
     option=argv[i];
     if ((strlen(option) < 2) ||
-       /* stdin + subexpression */
-       ((option[0] == '-') && (option[1] == '[')) ||
-       ((option[0] != '-') && option[0] != '+'))
+        /* stdin + subexpression */
+        ((option[0] == '-') && (option[1] == '[')) ||
+        ((option[0] != '-') && option[0] != '+'))
       {
         k=i;
         for (scene=first_scene; scene <= last_scene ; scene++)
@@ -14670,15 +14679,15 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info,
         if (LocaleCompare("monitor",option+1) == 0)
           {
             if (*option == '+')
-             {
-               (void) SetMonitorHandler((MonitorHandler) NULL);
-               (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
-             }
+              {
+                (void) SetMonitorHandler((MonitorHandler) NULL);
+                (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
+              }
             else
-             {
-               (void) SetMonitorHandler(CommandProgressMonitor);
-               (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
-             }
+              {
+                (void) SetMonitorHandler(CommandProgressMonitor);
+                (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
+              }
             break;
           }
         if (LocaleCompare("monochrome",option+1) == 0)
@@ -14764,12 +14773,12 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info,
           break;
         if (LocaleCompare("repage",option+1) == 0)
           {
-           if (*option == '-')
-             {
-               i++;
-               if ((i == argc) || !IsGeometry(argv[i]))
-                 ThrowMontageException(OptionError,MissingArgument,option);
-             }
+            if (*option == '-')
+              {
+                i++;
+                if ((i == argc) || !IsGeometry(argv[i]))
+                  ThrowMontageException(OptionError,MissingArgument,option);
+              }
             break;
           }
         if (LocaleCompare("resize",option+1) == 0)
@@ -14863,9 +14872,9 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info,
             break;
           }
         if (LocaleCompare("strip",option+1) == 0)
-         {
-           break;
-         }
+          {
+            break;
+          }
         if (LocaleCompare("stroke",option+1) == 0)
           {
             (void) QueryColorDatabase("none",&montage_info->stroke,exception);
@@ -15037,10 +15046,8 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info,
   }
   if ((image == (Image *) NULL) && (image_list == (Image *) NULL))
     {
-      if (exception->severity == UndefinedException)
-        ThrowMontageException(OptionError,RequestDidNotReturnAnImage,
-          (char *) NULL);
-      return(MagickFail);
+      ThrowMontageException(OptionError,RequestDidNotReturnAnImage,
+                            (char *) NULL);
     }
   if (i != (argc-1))
     ThrowMontageException(OptionError,MissingAnImageFilename,(char *) NULL);
@@ -15061,6 +15068,7 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info,
   if (montage_image == (Image *) NULL)
     ThrowMontageException(OptionError,RequestDidNotReturnAnImage,(char *) NULL);
   DestroyImageList(image_list);
+  image_list=(Image *) NULL;
   /*
     Write image.
   */
@@ -15075,7 +15083,7 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info,
         *text;
 
       /*
-       Return metadata to user
+        Return metadata to user
       */
       text=TranslateText(image_info,montage_image,(format != (char *) NULL) ? format : "%w,%h,%m");
       if (text == (char *) NULL)
@@ -15085,6 +15093,9 @@ MagickExport MagickPassFail MontageImageCommand(ImageInfo *image_info,
       (void) ConcatenateString(&(*metadata),"\n");
       MagickFreeMemory(text);
     }
+montage_cleanup_and_return:
+  DestroyImageList(image);
+  DestroyImageList(image_list);
   DestroyImageList(montage_image);
   DestroyMontageInfo(montage_info);
   LiberateArgumentList(argc,argv);
@@ -15784,15 +15795,15 @@ MagickExport MagickPassFail ImportImageCommand(ImageInfo *image_info,
         if (LocaleCompare("monitor",option+1) == 0)
           {
             if (*option == '+')
-             {
-               (void) SetMonitorHandler((MonitorHandler) NULL);
-               (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
-             }
+              {
+                (void) SetMonitorHandler((MonitorHandler) NULL);
+                (void) MagickSetConfirmAccessHandler((ConfirmAccessHandler) NULL);
+              }
             else
-             {
-               (void) SetMonitorHandler(CommandProgressMonitor);
-               (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
-             }
+              {
+                (void) SetMonitorHandler(CommandProgressMonitor);
+                (void) MagickSetConfirmAccessHandler(CommandAccessMonitor);
+              }
             break;
           }
         if (LocaleCompare("monochrome",option+1) == 0)
@@ -16108,7 +16119,7 @@ MagickExport MagickPassFail ImportImageCommand(ImageInfo *image_info,
   ARG_NOT_USED(metadata);
   ARG_NOT_USED(exception);
 
-  MagickFatalError(MissingDelegateError,XWindowLibraryIsNotAvailable,
+  MagickError(MissingDelegateError,XWindowLibraryIsNotAvailable,
     (char *) NULL);
   return(MagickFail);
 #endif
@@ -16748,7 +16759,7 @@ static void TimeUsage(void)
 */
 MagickExport MagickPassFail
 TimeImageCommand(ImageInfo *image_info,
-                int argc,char **argv,char **metadata,ExceptionInfo *exception)
+                 int argc,char **argv,char **metadata,ExceptionInfo *exception)
 {
   double
     elapsed_time,
@@ -16781,10 +16792,10 @@ TimeImageCommand(ImageInfo *image_info,
     {
       TimeUsage();
       if (argc < 2)
-       {
-         ThrowException(exception,OptionError,UsageError,NULL);
-         return MagickFail;
-       }
+        {
+          ThrowException(exception,OptionError,UsageError,NULL);
+          return MagickFail;
+        }
       return MagickPass;
     }
   if (LocaleCompare("-version",argv[1]) == 0)
@@ -16820,18 +16831,18 @@ TimeImageCommand(ImageInfo *image_info,
   for (i=0; i < argc; i++)
     {
       if (i != 0)
-       formatted += fprintf(stderr," ");
+        formatted += fprintf(stderr," ");
       formatted += fprintf(stderr,"%s",argv[i]);
       if (formatted > (screen_width-55))
-       {
-         if ((i+1) < argc)
-           pad="... ";
-         break;
-       }
+        {
+          if ((i+1) < argc)
+            pad="... ";
+          break;
+        }
     }
   (void) fprintf(stderr,
-                "%s%.2fs user %.2fs system %.0f%% cpu %.3f total\n",
-                pad,user_time,0.0,100.0*user_time/elapsed_time,elapsed_time);
+                 "%s%.2fs user %.2fs system %.0f%% cpu %.3f total\n",
+                 pad,user_time,0.0,100.0*user_time/elapsed_time,elapsed_time);
   (void) fflush(stderr);
 
   return status;
@@ -17212,7 +17223,7 @@ static MagickPassFail RegisterCommand(ImageInfo *image_info,
                                       ExceptionInfo *exception)
 {
   char
-    *szRegPath = 
+    *szRegPath =
     "SYSTEM\\CurrentControlSet\\Services\\Eventlog\\Application\\";
 
   char
@@ -17346,6 +17357,7 @@ static MagickPassFail GMCommandSingle(int argc,char **argv)
     static const char *command_names [] =
       {
         "animate",
+        "compare",
         "composite",
         "conjure",
         "convert",
index 58eaca0..cd032b9 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 - 2017 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Image Command Methods.
 */
 #ifndef _MAGICK_COMMAND_H
@@ -43,7 +43,7 @@ extern MagickExport MagickPassFail
   MontageImageCommand(ImageInfo *image_info,int argc,char **argv,
                       char **metadata,ExceptionInfo *exception),
   TimeImageCommand(ImageInfo *image_info,int argc,char **argv,
-                  char **metadata,ExceptionInfo *exception);
+                   char **metadata,ExceptionInfo *exception);
 
 extern MagickExport int
   GMCommand(int argc,char **argv);
index d975a6e..636e02e 100644 (file)
@@ -4,7 +4,7 @@
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Magick API common definitions support.
 */
 #ifndef _MAGICK_COMMON_H
@@ -23,7 +23,7 @@ extern "C" {
 #  define _MAGICKLIB_
 #  undef BuildMagickModules
 #  define SupportMagickModules
-#endif 
+#endif
 
 #if defined(MSWINDOWS) && !defined(__CYGWIN__)
 #  if defined(_MT) && defined(_DLL) && !defined(_MAGICKDLL_) && !defined(_LIB)
@@ -53,12 +53,12 @@ extern "C" {
 #  if defined(_DLL) && !defined(_LIB)
 #    define ModuleExport  __declspec(dllexport)
 #    if defined(_VISUALC_)
-#      pragma message( "Magick module DLL export interface" ) 
+#      pragma message( "Magick module DLL export interface" )
 #    endif
 #  else
 #    define ModuleExport
 #    if defined(_VISUALC_)
-#      pragma message( "Magick module static interface" ) 
+#      pragma message( "Magick module static interface" )
 #    endif
 #  endif
 #  define MagickGlobal __declspec(thread)
@@ -266,6 +266,27 @@ extern "C" {
 #  define MAGICK_OPTIMIZE_FUNC(opt) /*nothing*/
 #endif
 
+  /*
+    The isnan and isinf macros are defined by c99 but might not always be
+    available.  If they (or a substitute) are not available, then define them
+    to a false value.
+  */
+#if defined(isnan)
+#define MAGICK_ISNAN(d) isnan(d)
+#else
+#define MAGICK_ISNAN(d) (0)
+#endif
+#if defined(isinf)
+#define MAGICK_ISINF(d) isinf(d)
+#else
+#define MAGICK_ISINF(d) (0)
+#endif
+#if defined(isnormal)
+#define MAGICK_ISNORMAL(d) isnormal(d)
+#else
+#define MAGICK_ISNORMAL(d) (1)
+#endif
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif
index a818f06..edf3f18 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
 static MagickPassFail
 DifferenceImagePixels(void *mutable_data,                  /* User provided mutable data */
                       const void *immutable_data,          /* User provided immutable data */
-                      const Image *reference_image,        /* Source 1 image */
-                      const PixelPacket *reference_pixels, /* Pixel row in source 1 image */
-                      const IndexPacket *reference_indexes,/* Pixel row indexes in source 1 image */
-                      const Image *compare_image,          /* Source 2 image */
-                      const PixelPacket *compare_pixels,   /* Pixel row in source 2 image */
-                      const IndexPacket *compare_indexes,  /* Pixel row indexes in source 2 image */
-                      Image *result_image,                 /* Update image */
-                      PixelPacket *result_pixels,          /* Pixel row in update image */
-                      IndexPacket *result_indexes,         /* Pixel row indexes in update image */
+                      const Image * restrict reference_image,        /* Source 1 image */
+                      const PixelPacket * restrict reference_pixels, /* Pixel row in source 1 image */
+                      const IndexPacket * restrict reference_indexes,/* Pixel row indexes in source 1 image */
+                      const Image * restrict compare_image,          /* Source 2 image */
+                      const PixelPacket * restrict compare_pixels, /* Pixel row in source 2 image */
+                      const IndexPacket * restrict compare_indexes, /* Pixel row indexes in source 2 image */
+                      Image * restrict result_image,                 /* Update image */
+                      PixelPacket * restrict result_pixels, /* Pixel row in update image */
+                      IndexPacket * restrict result_indexes, /* Pixel row indexes in update image */
                       const long npixels,                  /* Number of pixels in row */
                       ExceptionInfo *exception             /* Exception report */
                    )
@@ -312,12 +312,12 @@ DifferenceImage(const Image *reference_image,const Image *compare_image,
 static MagickPassFail
 ComputeAbsoluteError(void *mutable_data,
                      const void *immutable_data,
-                     const Image *first_image,
-                     const PixelPacket *first_pixels,
-                     const IndexPacket *first_indexes,
-                     const Image *second_image,
-                     const PixelPacket *second_pixels,
-                     const IndexPacket *second_indexes,
+                     const Image * restrict first_image,
+                     const PixelPacket * restrict first_pixels,
+                     const IndexPacket * restrict first_indexes,
+                     const Image * restrict second_image,
+                     const PixelPacket * restrict second_pixels,
+                     const IndexPacket * restrict second_indexes,
                      const long npixels,
                      ExceptionInfo *exception)
 {
@@ -367,12 +367,12 @@ ComputeAbsoluteError(void *mutable_data,
 static MagickPassFail
 ComputePeakAbsoluteError(void *mutable_data,
                          const void *immutable_data,
-                         const Image *first_image,
-                         const PixelPacket *first_pixels,
-                         const IndexPacket *first_indexes,
-                         const Image *second_image,
-                         const PixelPacket *second_pixels,
-                         const IndexPacket *second_indexes,
+                         const Image * restrict first_image,
+                         const PixelPacket * restrict first_pixels,
+                         const IndexPacket * restrict first_indexes,
+                         const Image * restrict second_image,
+                         const PixelPacket * restrict second_pixels,
+                         const IndexPacket * restrict second_indexes,
                          const long npixels,
                          ExceptionInfo *exception)
 {
@@ -438,12 +438,12 @@ ComputePeakAbsoluteError(void *mutable_data,
 static MagickPassFail
 ComputeSquaredError(void *mutable_data,
                     const void *immutable_data,
-                    const Image *first_image,
-                    const PixelPacket *first_pixels,
-                    const IndexPacket *first_indexes,
-                    const Image *second_image,
-                    const PixelPacket *second_pixels,
-                    const IndexPacket *second_indexes,
+                    const Image * restrict first_image,
+                    const PixelPacket * restrict first_pixels,
+                    const IndexPacket * restrict first_indexes,
+                    const Image * restrict second_image,
+                    const PixelPacket * restrict second_pixels,
+                    const IndexPacket * restrict second_indexes,
                     const long npixels,
                     ExceptionInfo *exception)
 {
@@ -546,7 +546,7 @@ GetImageChannelDifference(const Image *reference_image,
 
       char
         description[MaxTextExtent];
-      
+
       FormatString(description,"[%%s]*[%%s] Compute image difference using %s metric...",
                    MetricTypeToString(metric));
 
@@ -820,12 +820,12 @@ typedef struct _ErrorStatistics {
 static MagickPassFail
 ComputePixelError(void *mutable_data,
                   const void *immutable_data,
-                  const Image *first_image,
-                  const PixelPacket *first_pixels,
-                  const IndexPacket *first_indexes,
-                  const Image *second_image,
-                  const PixelPacket *second_pixels,
-                  const IndexPacket *second_indexes,
+                  const Image * restrict first_image,
+                  const PixelPacket * restrict first_pixels,
+                  const IndexPacket * restrict first_indexes,
+                  const Image * restrict second_image,
+                  const PixelPacket * restrict second_pixels,
+                  const IndexPacket * restrict second_indexes,
                   const long npixels,
                   ExceptionInfo *exception)
 {
@@ -937,7 +937,7 @@ IsImagesEqual(Image *image,const Image *reference)
   /*
     Compute final error statistics.
   */
-  
+
   if (image->matte)
     normalize = sqrt(4.0); /* sqrt(1.0*1.0+1.0*1.0+1.0*1.0+1.0*1.0) */
   else
index 31c29b7..014edf5 100644 (file)
@@ -1,10 +1,10 @@
 /*
   Copyright (C) 2008 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Image Comparison Methods.
 */
 #ifndef _MAGICK_COMPARE_H
index a35ccf2..38414de 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2014 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -72,9 +72,9 @@ typedef struct _CompositeOptions_t
 */
 static inline void
 PrepareDestinationPacket(PixelPacket *destination,
-                         const PixelPacket *update_pixels,
-                         const Image *update_image,
-                         const IndexPacket *update_indexes,
+                         const PixelPacket * restrict update_pixels,
+                         const Image * restrict update_image,
+                         const IndexPacket * restrict update_indexes,
                          const long i)
 {
   *destination=update_pixels[i];
@@ -91,9 +91,9 @@ PrepareDestinationPacket(PixelPacket *destination,
 */
 static inline void
 PrepareSourcePacket(PixelPacket *source,
-                    const PixelPacket *source_pixels,
-                    const Image *source_image,
-                    const IndexPacket *source_indexes,
+                    const PixelPacket * restrict source_pixels,
+                    const Image * restrict source_image,
+                    const IndexPacket * restrict source_indexes,
                     const long i)
 {
   *source=source_pixels[i];
@@ -109,10 +109,10 @@ PrepareSourcePacket(PixelPacket *source,
   Apply composition updates to the canvas image.
 */
 static inline void
-ApplyPacketUpdates(PixelPacket *update_pixels,
-                   IndexPacket *update_indexes,
-                   const Image *update_image,
-                   const PixelPacket *composite,
+ApplyPacketUpdates(PixelPacket * restrict update_pixels,
+                   IndexPacket * restrict update_indexes,
+                   const Image * restrict update_image,
+                   const PixelPacket * restrict composite,
                    const long i
                    )
 {
@@ -139,12 +139,12 @@ ApplyPacketUpdates(PixelPacket *update_pixels,
 static MagickPassFail
 OverCompositePixels(void *mutable_data,                /* User provided mutable data */
                     const void *immutable_data,        /* User provided immutable data */
-                    const Image *source_image,         /* Source image */
-                    const PixelPacket *source_pixels,  /* Pixel row in source image */
-                    const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                    Image *update_image,               /* Update image */
-                    PixelPacket *update_pixels,        /* Pixel row in update image */
-                    IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                    const Image * restrict source_image,         /* Source image */
+                    const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                    const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                    Image * restrict update_image,               /* Update image */
+                    PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                    IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                     const long npixels,                /* Number of pixels in row */
                     ExceptionInfo *exception           /* Exception report */
                     )
@@ -182,12 +182,12 @@ OverCompositePixels(void *mutable_data,                /* User provided mutable
 static MagickPassFail
 InCompositePixels(void *mutable_data,                /* User provided mutable data */
                   const void *immutable_data,        /* User provided immutable data */
-                  const Image *source_image,         /* Source image */
-                  const PixelPacket *source_pixels,  /* Pixel row in source image */
-                  const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                  Image *update_image,               /* Update image */
-                  PixelPacket *update_pixels,        /* Pixel row in update image */
-                  IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                  const Image * restrict source_image,         /* Source image */
+                  const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                  const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                  Image * restrict update_image,               /* Update image */
+                  PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                  IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                   const long npixels,                /* Number of pixels in row */
                   ExceptionInfo *exception           /* Exception report */
                   )
@@ -254,12 +254,12 @@ InCompositePixels(void *mutable_data,                /* User provided mutable da
 static MagickPassFail
 OutCompositePixels(void *mutable_data,                /* User provided mutable data */
                    const void *immutable_data,        /* User provided immutable data */
-                   const Image *source_image,         /* Source image */
-                   const PixelPacket *source_pixels,  /* Pixel row in source image */
-                   const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                   Image *update_image,               /* Update image */
-                   PixelPacket *update_pixels,        /* Pixel row in update image */
-                   IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                   const Image * restrict source_image,         /* Source image */
+                   const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                   const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                   Image * restrict update_image,               /* Update image */
+                   PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                   IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                    const long npixels,                /* Number of pixels in row */
                    ExceptionInfo *exception           /* Exception report */
                    )
@@ -324,12 +324,12 @@ OutCompositePixels(void *mutable_data,                /* User provided mutable d
 static MagickPassFail
 AtopCompositePixels(void *mutable_data,                /* User provided mutable data */
                     const void *immutable_data,        /* User provided immutable data */
-                    const Image *source_image,         /* Source image */
-                    const PixelPacket *source_pixels,  /* Pixel row in source image */
-                    const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                    Image *update_image,               /* Update image */
-                    PixelPacket *update_pixels,        /* Pixel row in update image */
-                    IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                    const Image * restrict source_image,         /* Source image */
+                    const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                    const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                    Image * restrict update_image,               /* Update image */
+                    PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                    IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                     const long npixels,                /* Number of pixels in row */
                     ExceptionInfo *exception           /* Exception report */
                     )
@@ -369,12 +369,12 @@ AtopCompositePixels(void *mutable_data,                /* User provided mutable
 static MagickPassFail
 XorCompositePixels(void *mutable_data,                /* User provided mutable data */
                    const void *immutable_data,        /* User provided immutable data */
-                   const Image *source_image,         /* Source image */
-                   const PixelPacket *source_pixels,  /* Pixel row in source image */
-                   const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                   Image *update_image,               /* Update image */
-                   PixelPacket *update_pixels,        /* Pixel row in update image */
-                   IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                   const Image * restrict source_image,         /* Source image */
+                   const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                   const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                   Image * restrict update_image,               /* Update image */
+                   PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                   IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                    const long npixels,                /* Number of pixels in row */
                    ExceptionInfo *exception           /* Exception report */
                    )
@@ -407,23 +407,23 @@ XorCompositePixels(void *mutable_data,                /* User provided mutable d
 
       source_alpha=(double) source.opacity/MaxRGBDouble;
       dest_alpha=(double) destination.opacity/MaxRGBDouble;
-      
+
       gamma=(1.0-source_alpha)+(1.0-dest_alpha)-
         2.0*(1.0-source_alpha)*(1.0-dest_alpha);
-          
+
       composite=MaxRGBDouble*(1.0-gamma);
       destination.opacity=RoundDoubleToQuantum(composite);
-          
+
       gamma=1.0/(gamma <= MagickEpsilon ? 1.0 : gamma);
-          
+
       composite=((1.0-source_alpha)*source.red*dest_alpha+
                  (1.0-dest_alpha)*destination.red*source_alpha)*gamma;
       destination.red=RoundDoubleToQuantum(composite);
-          
+
       composite=((1.0-source_alpha)*source.green*dest_alpha+
                  (1.0-dest_alpha)*destination.green*source_alpha)*gamma;
       destination.green=RoundDoubleToQuantum(composite);
-          
+
       composite=((1.0-source_alpha)*source.blue*dest_alpha+
                  (1.0-dest_alpha)*destination.blue*source_alpha)*gamma;
       destination.blue=RoundDoubleToQuantum(composite);
@@ -438,12 +438,12 @@ XorCompositePixels(void *mutable_data,                /* User provided mutable d
 static MagickPassFail
 PlusCompositePixels(void *mutable_data,                /* User provided mutable data */
                     const void *immutable_data,        /* User provided immutable data */
-                    const Image *source_image,         /* Source image */
-                    const PixelPacket *source_pixels,  /* Pixel row in source image */
-                    const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                    Image *update_image,               /* Update image */
-                    PixelPacket *update_pixels,        /* Pixel row in update image */
-                    IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                    const Image * restrict source_image,         /* Source image */
+                    const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                    const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                    Image * restrict update_image,               /* Update image */
+                    PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                    IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                     const long npixels,                /* Number of pixels in row */
                     ExceptionInfo *exception           /* Exception report */
                     )
@@ -475,15 +475,15 @@ PlusCompositePixels(void *mutable_data,                /* User provided mutable
       value=((double) (MaxRGBDouble-source.opacity)*source.red+(double)
                  (MaxRGBDouble-destination.opacity)*destination.red)/MaxRGBDouble;
       destination.red=RoundDoubleToQuantum(value);
-      
+
       value=((double) (MaxRGBDouble-source.opacity)*source.green+(double)
                    (MaxRGBDouble-destination.opacity)*destination.green)/MaxRGBDouble;
       destination.green=RoundDoubleToQuantum(value);
-      
+
       value=((double) (MaxRGBDouble-source.opacity)*source.blue+(double)
                   (MaxRGBDouble-destination.opacity)*destination.blue)/MaxRGBDouble;
       destination.blue=RoundDoubleToQuantum(value);
-      
+
       value=((double) (MaxRGBDouble-source.opacity)+
                      (double) (MaxRGBDouble-destination.opacity))/MaxRGBDouble;
       destination.opacity=MaxRGB-RoundDoubleToQuantum(value);
@@ -498,12 +498,12 @@ PlusCompositePixels(void *mutable_data,                /* User provided mutable
 static MagickPassFail
 MinusCompositePixels(void *mutable_data,                /* User provided mutable data */
                      const void *immutable_data,        /* User provided immutable data */
-                     const Image *source_image,         /* Source image */
-                     const PixelPacket *source_pixels,  /* Pixel row in source image */
-                     const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                     Image *update_image,               /* Update image */
-                     PixelPacket *update_pixels,        /* Pixel row in update image */
-                     IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                     const Image * restrict source_image,         /* Source image */
+                     const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                     const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                     Image * restrict update_image,               /* Update image */
+                     PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                     IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                      const long npixels,                /* Number of pixels in row */
                      ExceptionInfo *exception           /* Exception report */
                      )
@@ -557,12 +557,12 @@ MinusCompositePixels(void *mutable_data,                /* User provided mutable
 static MagickPassFail
 AddCompositePixels(void *mutable_data,                /* User provided mutable data */
                    const void *immutable_data,        /* User provided immutable data */
-                   const Image *source_image,         /* Source image */
-                   const PixelPacket *source_pixels,  /* Pixel row in source image */
-                   const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                   Image *update_image,               /* Update image */
-                   PixelPacket *update_pixels,        /* Pixel row in update image */
-                   IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                   const Image * restrict source_image,         /* Source image */
+                   const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                   const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                   Image * restrict update_image,               /* Update image */
+                   PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                   IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                    const long npixels,                /* Number of pixels in row */
                    ExceptionInfo *exception           /* Exception report */
                    )
@@ -593,15 +593,15 @@ AddCompositePixels(void *mutable_data,                /* User provided mutable d
       value=(double) source.red+destination.red;
       if (value > MaxRGBDouble) value -= ((double) MaxRGBDouble+1.0);
       destination.red=RoundDoubleToQuantum(value);
-      
+
       value=(double) source.green+destination.green;
       if (value > MaxRGBDouble) value -= ((double) MaxRGBDouble+1.0);
       destination.green=RoundDoubleToQuantum(value);
-      
+
       value=(double) source.blue+destination.blue;
       if (value > MaxRGBDouble) value -= ((double) MaxRGBDouble+1.0);
       destination.blue=RoundDoubleToQuantum(value);
-      
+
       destination.opacity=OpaqueOpacity;
       ApplyPacketUpdates(update_pixels,update_indexes,update_image,&destination,i);
     }
@@ -613,12 +613,12 @@ AddCompositePixels(void *mutable_data,                /* User provided mutable d
 static MagickPassFail
 SubtractCompositePixels(void *mutable_data,                /* User provided mutable data */
                         const void *immutable_data,        /* User provided immutable data */
-                        const Image *source_image,         /* Source image */
-                        const PixelPacket *source_pixels,  /* Pixel row in source image */
-                        const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                        Image *update_image,               /* Update image */
-                        PixelPacket *update_pixels,        /* Pixel row in update image */
-                        IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                        const Image * restrict source_image,         /* Source image */
+                        const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                        const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                        Image * restrict update_image,               /* Update image */
+                        PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                        IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                         const long npixels,                /* Number of pixels in row */
                         ExceptionInfo *exception           /* Exception report */
                         )
@@ -671,12 +671,12 @@ SubtractCompositePixels(void *mutable_data,                /* User provided muta
 static MagickPassFail
 DifferenceCompositePixels(void *mutable_data,                /* User provided mutable data */
                           const void *immutable_data,        /* User provided immutable data */
-                          const Image *source_image,         /* Source image */
-                          const PixelPacket *source_pixels,  /* Pixel row in source image */
-                          const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                          Image *update_image,               /* Update image */
-                          PixelPacket *update_pixels,        /* Pixel row in update image */
-                          IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                          const Image * restrict source_image,         /* Source image */
+                          const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                          const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                          Image * restrict update_image,               /* Update image */
+                          PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                          IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                           const long npixels,                /* Number of pixels in row */
                           ExceptionInfo *exception           /* Exception report */
                           )
@@ -746,12 +746,12 @@ DifferenceCompositePixels(void *mutable_data,                /* User provided mu
 static MagickPassFail
 MultiplyCompositePixels(void *mutable_data,                /* User provided mutable data */
                         const void *immutable_data,        /* User provided immutable data */
-                        const Image *source_image,         /* Source image */
-                        const PixelPacket *source_pixels,  /* Pixel row in source image */
-                        const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                        Image *update_image,               /* Update image */
-                        PixelPacket *update_pixels,        /* Pixel row in update image */
-                        IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                        const Image * restrict source_image,         /* Source image */
+                        const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                        const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                        Image * restrict update_image,               /* Update image */
+                        PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                        IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                         const long npixels,                /* Number of pixels in row */
                         ExceptionInfo *exception           /* Exception report */
                         )
@@ -823,12 +823,12 @@ MultiplyCompositePixels(void *mutable_data,                /* User provided muta
 static MagickPassFail
 BumpmapCompositePixels(void *mutable_data,                /* User provided mutable data */
                        const void *immutable_data,        /* User provided immutable data */
-                       const Image *source_image,         /* Source image */
-                       const PixelPacket *source_pixels,  /* Pixel row in source image */
-                       const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                       Image *update_image,               /* Update image */
-                       PixelPacket *update_pixels,        /* Pixel row in update image */
-                       IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                       const Image * restrict source_image,         /* Source image */
+                       const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                       const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                       Image * restrict update_image,               /* Update image */
+                       PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                       IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                        const long npixels,                /* Number of pixels in row */
                        ExceptionInfo *exception           /* Exception report */
                        )
@@ -881,12 +881,12 @@ BumpmapCompositePixels(void *mutable_data,                /* User provided mutab
 static MagickPassFail
 CopyCompositePixels(void *mutable_data,                /* User provided mutable data */
                     const void *immutable_data,        /* User provided immutable data */
-                    const Image *source_image,         /* Source image */
-                    const PixelPacket *source_pixels,  /* Pixel row in source image */
-                    const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                    Image *update_image,               /* Update image */
-                    PixelPacket *update_pixels,        /* Pixel row in update image */
-                    IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                    const Image * restrict source_image,         /* Source image */
+                    const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                    const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                    Image * restrict update_image,               /* Update image */
+                    PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                    IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                     const long npixels,                /* Number of pixels in row */
                     ExceptionInfo *exception           /* Exception report */
                     )
@@ -917,7 +917,7 @@ CopyCompositePixels(void *mutable_data,                /* User provided mutable
     {
       (void) memcpy(update_pixels,source_pixels,npixels*sizeof(PixelPacket));
     }
-      
+
   return MagickPass;
 }
 
@@ -954,19 +954,19 @@ CopyRedCompositePixels(void *mutable_data,                /* User provided mutab
     {
       update_pixels[i].red = source_pixels[i].red;
     }
-      
+
   return MagickPass;
 }
 
 static MagickPassFail
 CopyGreenCompositePixels(void *mutable_data,                /* User provided mutable data */
                          const void *immutable_data,        /* User provided immutable data */
-                         const Image *source_image,         /* Source image */
-                         const PixelPacket *source_pixels,  /* Pixel row in source image */
-                         const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                         Image *update_image,               /* Update image */
-                         PixelPacket *update_pixels,        /* Pixel row in update image */
-                         IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                         const Image * restrict source_image,         /* Source image */
+                         const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                         const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                         Image * restrict update_image,               /* Update image */
+                         PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                         IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                          const long npixels,                /* Number of pixels in row */
                          ExceptionInfo *exception           /* Exception report */
                          )
@@ -991,7 +991,7 @@ CopyGreenCompositePixels(void *mutable_data,                /* User provided mut
     {
       update_pixels[i].green = source_pixels[i].green;
     }
-      
+
   return MagickPass;
 }
 
@@ -999,12 +999,12 @@ CopyGreenCompositePixels(void *mutable_data,                /* User provided mut
 static MagickPassFail
 CopyBlueCompositePixels(void *mutable_data,                /* User provided mutable data */
                         const void *immutable_data,        /* User provided immutable data */
-                        const Image *source_image,         /* Source image */
-                        const PixelPacket *source_pixels,  /* Pixel row in source image */
-                        const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                        Image *update_image,               /* Update image */
-                        PixelPacket *update_pixels,        /* Pixel row in update image */
-                        IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                        const Image * restrict source_image,         /* Source image */
+                        const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                        const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                        Image * restrict update_image,               /* Update image */
+                        PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                        IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                         const long npixels,                /* Number of pixels in row */
                         ExceptionInfo *exception           /* Exception report */
                         )
@@ -1037,11 +1037,11 @@ static MagickPassFail
 CopyOpacityCompositePixels(void *mutable_data,                /* User provided mutable data */
                            const void *immutable_data,        /* User provided immutable data */
                            const Image *source_image,         /* Source image */
-                           const PixelPacket *source_pixels,  /* Pixel row in source image */
-                           const IndexPacket *source_indexes, /* Pixel row indexes in source image */
+                           const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                           const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
                            Image *update_image,               /* Update image */
-                           PixelPacket *update_pixels,        /* Pixel row in update image */
-                           IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                           PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                           IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                            const long npixels,                /* Number of pixels in row */
                            ExceptionInfo *exception           /* Exception report */
                            )
@@ -1094,19 +1094,19 @@ CopyOpacityCompositePixels(void *mutable_data,                /* User provided m
             }
         }
     }
-      
+
   return MagickPass;
 }
 
 static MagickPassFail
 ClearCompositePixels(void *mutable_data,                /* User provided mutable data */
                      const void *immutable_data,        /* User provided immutable data */
-                     const Image *source_image,         /* Source image */
-                     const PixelPacket *source_pixels,  /* Pixel row in source image */
-                     const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                     Image *update_image,               /* Update image */
-                     PixelPacket *update_pixels,        /* Pixel row in update image */
-                     IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                     const Image * restrict source_image,         /* Source image */
+                     const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                     const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                     Image * restrict update_image,               /* Update image */
+                     PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                     IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                      const long npixels,                /* Number of pixels in row */
                      ExceptionInfo *exception           /* Exception report */
                      )
@@ -1139,7 +1139,7 @@ ClearCompositePixels(void *mutable_data,                /* User provided mutable
           update_pixels[i].opacity = TransparentOpacity;
         }
     }
-      
+
   return MagickPass;
 }
 
@@ -1148,12 +1148,12 @@ ClearCompositePixels(void *mutable_data,                /* User provided mutable
 static MagickPassFail
 DissolveCompositePixels(void *mutable_data,                /* User provided mutable data */
                         const void *immutable_data,        /* User provided immutable data */
-                        const Image *source_image,         /* Source image */
-                        const PixelPacket *source_pixels,  /* Pixel row in source image */
-                        const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                        Image *update_image,               /* Update image */
-                        PixelPacket *update_pixels,        /* Pixel row in update image */
-                        IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                        const Image * restrict source_image,         /* Source image */
+                        const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                        const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                        Image * restrict update_image,               /* Update image */
+                        PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                        IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                         const long npixels,                /* Number of pixels in row */
                         ExceptionInfo *exception           /* Exception report */
                         )
@@ -1195,12 +1195,12 @@ DissolveCompositePixels(void *mutable_data,                /* User provided muta
 static MagickPassFail
 ModulateCompositePixels(void *mutable_data,                /* User provided mutable data */
                         const void *immutable_data,        /* User provided immutable data */
-                        const Image *source_image,         /* Source image */
-                        const PixelPacket *source_pixels,  /* Pixel row in source image */
-                        const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                        Image *update_image,               /* Update image */
-                        PixelPacket *update_pixels,        /* Pixel row in update image */
-                        IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                        const Image * restrict source_image,         /* Source image */
+                        const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                        const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                        Image * restrict update_image,               /* Update image */
+                        PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                        IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                         const long npixels,                /* Number of pixels in row */
                         ExceptionInfo *exception           /* Exception report */
                         )
@@ -1263,12 +1263,12 @@ ModulateCompositePixels(void *mutable_data,                /* User provided muta
 static MagickPassFail
 ThresholdCompositePixels(void *mutable_data,                /* User provided mutable data */
                          const void *immutable_data,        /* User provided immutable data */
-                         const Image *source_image,         /* Source image */
-                         const PixelPacket *source_pixels,  /* Pixel row in source image */
-                         const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                         Image *update_image,               /* Update image */
-                         PixelPacket *update_pixels,        /* Pixel row in update image */
-                         IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                         const Image * restrict source_image,         /* Source image */
+                         const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                         const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                         Image * restrict update_image,               /* Update image */
+                         PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                         IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                          const long npixels,                /* Number of pixels in row */
                          ExceptionInfo *exception           /* Exception report */
                          )
@@ -1336,12 +1336,12 @@ ThresholdCompositePixels(void *mutable_data,                /* User provided mut
 static MagickPassFail
 DarkenCompositePixels(void *mutable_data,                /* User provided mutable data */
                       const void *immutable_data,        /* User provided immutable data */
-                      const Image *source_image,         /* Source image */
-                      const PixelPacket *source_pixels,  /* Pixel row in source image */
-                      const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                      Image *update_image,               /* Update image */
-                      PixelPacket *update_pixels,        /* Pixel row in update image */
-                      IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                      const Image * restrict source_image,         /* Source image */
+                      const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                      const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                      Image * restrict update_image,               /* Update image */
+                      PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                      IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                       const long npixels,                /* Number of pixels in row */
                       ExceptionInfo *exception           /* Exception report */
                       )
@@ -1407,12 +1407,12 @@ DarkenCompositePixels(void *mutable_data,                /* User provided mutabl
 static MagickPassFail
 LightenCompositePixels(void *mutable_data,                /* User provided mutable data */
                        const void *immutable_data,        /* User provided immutable data */
-                       const Image *source_image,         /* Source image */
-                       const PixelPacket *source_pixels,  /* Pixel row in source image */
-                       const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                       Image *update_image,               /* Update image */
-                       PixelPacket *update_pixels,        /* Pixel row in update image */
-                       IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                       const Image * restrict source_image,         /* Source image */
+                       const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                       const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                       Image * restrict update_image,               /* Update image */
+                       PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                       IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                        const long npixels,                /* Number of pixels in row */
                        ExceptionInfo *exception           /* Exception report */
                        )
@@ -1478,12 +1478,12 @@ LightenCompositePixels(void *mutable_data,                /* User provided mutab
 static MagickPassFail
 HueCompositePixels(void *mutable_data,                /* User provided mutable data */
                    const void *immutable_data,        /* User provided immutable data */
-                   const Image *source_image,         /* Source image */
-                   const PixelPacket *source_pixels,  /* Pixel row in source image */
-                   const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                   Image *update_image,               /* Update image */
-                   PixelPacket *update_pixels,        /* Pixel row in update image */
-                   IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                   const Image * restrict source_image,         /* Source image */
+                   const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                   const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                   Image * restrict update_image,               /* Update image */
+                   PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                   IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                    const long npixels,                /* Number of pixels in row */
                    ExceptionInfo *exception           /* Exception report */
                    )
@@ -1538,12 +1538,12 @@ HueCompositePixels(void *mutable_data,                /* User provided mutable d
 static MagickPassFail
 SaturateCompositePixels(void *mutable_data,                /* User provided mutable data */
                         const void *immutable_data,        /* User provided immutable data */
-                        const Image *source_image,         /* Source image */
-                        const PixelPacket *source_pixels,  /* Pixel row in source image */
-                        const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                        Image *update_image,               /* Update image */
-                        PixelPacket *update_pixels,        /* Pixel row in update image */
-                        IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                        const Image * restrict source_image,         /* Source image */
+                        const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                        const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                        Image * restrict update_image,               /* Update image */
+                        PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                        IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                         const long npixels,                /* Number of pixels in row */
                         ExceptionInfo *exception           /* Exception report */
                         )
@@ -1599,12 +1599,12 @@ SaturateCompositePixels(void *mutable_data,                /* User provided muta
 static MagickPassFail
 ColorizeCompositePixels(void *mutable_data,                /* User provided mutable data */
                         const void *immutable_data,        /* User provided immutable data */
-                        const Image *source_image,         /* Source image */
-                        const PixelPacket *source_pixels,  /* Pixel row in source image */
-                        const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                        Image *update_image,               /* Update image */
-                        PixelPacket *update_pixels,        /* Pixel row in update image */
-                        IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                        const Image * restrict source_image,         /* Source image */
+                        const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                        const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                        Image * restrict update_image,               /* Update image */
+                        PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                        IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                         const long npixels,                /* Number of pixels in row */
                         ExceptionInfo *exception           /* Exception report */
                         )
@@ -1660,12 +1660,12 @@ ColorizeCompositePixels(void *mutable_data,                /* User provided muta
 static MagickPassFail
 LuminizeCompositePixels(void *mutable_data,                /* User provided mutable data */
                         const void *immutable_data,        /* User provided immutable data */
-                        const Image *source_image,         /* Source image */
-                        const PixelPacket *source_pixels,  /* Pixel row in source image */
-                        const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                        Image *update_image,               /* Update image */
-                        PixelPacket *update_pixels,        /* Pixel row in update image */
-                        IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                        const Image * restrict source_image,         /* Source image */
+                        const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                        const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                        Image * restrict update_image,               /* Update image */
+                        PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                        IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                         const long npixels,                /* Number of pixels in row */
                         ExceptionInfo *exception           /* Exception report */
                         )
@@ -1721,12 +1721,12 @@ LuminizeCompositePixels(void *mutable_data,                /* User provided muta
 static MagickPassFail
 ScreenCompositePixels(void *mutable_data,                /* User provided mutable data */
                       const void *immutable_data,        /* User provided immutable data */
-                      const Image *source_image,         /* Source image */
-                      const PixelPacket *source_pixels,  /* Pixel row in source image */
-                      const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                      Image *update_image,               /* Update image */
-                      PixelPacket *update_pixels,        /* Pixel row in update image */
-                      IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                      const Image * restrict source_image,         /* Source image */
+                      const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                      const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                      Image * restrict update_image,               /* Update image */
+                      PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                      IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                       const long npixels,                /* Number of pixels in row */
                       ExceptionInfo *exception           /* Exception report */
                       )
@@ -1800,27 +1800,27 @@ ScreenCompositePixels(void *mutable_data,                /* User provided mutabl
 static MagickPassFail
 OverlayCompositePixels(void *mutable_data,               /* User provided mutable data */
                        const void *immutable_data,        /* User provided immutable data */
-                       const Image *source_image,         /* Source image */
-                       const PixelPacket *source_pixels,  /* Pixel row in source image */
-                       const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                       Image *update_image,               /* Update image */
-                       PixelPacket *update_pixels,        /* Pixel row in update image */
-                       IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                       const Image * restrict source_image,         /* Source image */
+                       const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                       const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                       Image * restrict update_image,               /* Update image */
+                       PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                       IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                        const long npixels,                /* Number of pixels in row */
                        ExceptionInfo *exception           /* Exception report */
                        )
 {
   register long
     i;
-    
+
   PixelPacket
     destination,
     source;
-    
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(immutable_data);
   ARG_NOT_USED(exception);
-    
+
   /*
     Multiplies or screens, depending on the destination colour.
     Overlay(a,b) = HardLight(b,a)
@@ -1835,10 +1835,10 @@ OverlayCompositePixels(void *mutable_data,               /* User provided mutabl
 
       double
         value;
-        
+
       PrepareSourcePacket(&source,source_pixels,source_image,source_indexes,i);
       PrepareDestinationPacket(&destination,update_pixels,update_image,update_indexes,i);
-        
+
       source_alpha=(double) source.opacity/MaxRGBDouble;
       dest_alpha=(double) destination.opacity/MaxRGBDouble;
 
@@ -1891,12 +1891,12 @@ OverlayCompositePixels(void *mutable_data,               /* User provided mutabl
 static MagickPassFail
 CopyBlackCompositePixels(void *mutable_data,                /* User provided mutable data */
                          const void *immutable_data,        /* User provided immutable data */
-                         const Image *source_image,         /* Source image */
-                         const PixelPacket *source_pixels,  /* Pixel row in source image */
-                         const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                         Image *update_image,               /* Update image */
-                         PixelPacket *update_pixels,        /* Pixel row in update image */
-                         IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                         const Image * restrict source_image,         /* Source image */
+                         const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                         const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                         Image * restrict update_image,               /* Update image */
+                         PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                         IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                          const long npixels,                /* Number of pixels in row */
                          ExceptionInfo *exception           /* Exception report */
                          )
@@ -1936,12 +1936,12 @@ CopyBlackCompositePixels(void *mutable_data,                /* User provided mut
 static MagickPassFail
 DivideCompositePixels(void *mutable_data,                /* User provided mutable data */
                       const void *immutable_data,        /* User provided immutable data */
-                      const Image *source_image,         /* Source image */
-                      const PixelPacket *source_pixels,  /* Pixel row in source image */
-                      const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                      Image *update_image,               /* Update image */
-                      PixelPacket *update_pixels,        /* Pixel row in update image */
-                      IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                      const Image * restrict source_image,         /* Source image */
+                      const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                      const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                      Image * restrict update_image,               /* Update image */
+                      PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                      IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                       const long npixels,                /* Number of pixels in row */
                       ExceptionInfo *exception           /* Exception report */
                       )
@@ -1958,9 +1958,9 @@ DivideCompositePixels(void *mutable_data,                /* User provided mutabl
   ARG_NOT_USED(exception);
 
   /*
-    The result of change-image / base-image. This is useful for 
+    The result of change-image / base-image. This is useful for
     improving the readability of text on unevenly illuminated photos.
-    (by using a gaussian blurred copy of change-image as base-image) 
+    (by using a gaussian blurred copy of change-image as base-image)
   */
 
   for (i=0; i < npixels; i++)
@@ -1999,27 +1999,27 @@ DivideCompositePixels(void *mutable_data,                /* User provided mutabl
 static MagickPassFail
 HardLightCompositePixels(void *mutable_data,               /* User provided mutable data */
                          const void *immutable_data,        /* User provided immutable data */
-                         const Image *source_image,         /* Source image */
-                         const PixelPacket *source_pixels,  /* Pixel row in source image */
-                         const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                         Image *update_image,               /* Update image */
-                         PixelPacket *update_pixels,        /* Pixel row in update image */
-                         IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                         const Image * restrict source_image,         /* Source image */
+                         const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                         const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                         Image * restrict update_image,               /* Update image */
+                         PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                         IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                          const long npixels,                /* Number of pixels in row */
                          ExceptionInfo *exception           /* Exception report */
                          )
 {
   register long
     i;
-    
+
   PixelPacket
     destination,
     source;
-    
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(immutable_data);
   ARG_NOT_USED(exception);
-    
+
   /*
     The result of base-image gets lighting effects by change-image.
   */
@@ -2033,10 +2033,10 @@ HardLightCompositePixels(void *mutable_data,               /* User provided muta
 
       double
         value;
-        
+
       PrepareSourcePacket(&source,source_pixels,source_image,source_indexes,i);
       PrepareDestinationPacket(&destination,update_pixels,update_image,update_indexes,i);
-        
+
       source_alpha=(double) source.opacity/MaxRGBDouble;
       dest_alpha=(double) destination.opacity/MaxRGBDouble;
 
@@ -2089,12 +2089,12 @@ HardLightCompositePixels(void *mutable_data,               /* User provided muta
 static MagickPassFail
 ExclusionCompositePixels(void *mutable_data,                /* User provided mutable data */
                          const void *immutable_data,        /* User provided immutable data */
-                         const Image *source_image,         /* Source image */
-                         const PixelPacket *source_pixels,  /* Pixel row in source image */
-                         const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                         Image *update_image,               /* Update image */
-                         PixelPacket *update_pixels,        /* Pixel row in update image */
-                         IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                         const Image * restrict source_image,         /* Source image */
+                         const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                         const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                         Image * restrict update_image,               /* Update image */
+                         PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                         IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                          const long npixels,                /* Number of pixels in row */
                          ExceptionInfo *exception           /* Exception report */
                          )
@@ -2168,27 +2168,27 @@ ExclusionCompositePixels(void *mutable_data,                /* User provided mut
 static MagickPassFail
 ColorDodgeCompositePixels(void *mutable_data,               /* User provided mutable data */
                           const void *immutable_data,        /* User provided immutable data */
-                          const Image *source_image,         /* Source image */
-                          const PixelPacket *source_pixels,  /* Pixel row in source image */
-                          const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                          Image *update_image,               /* Update image */
-                          PixelPacket *update_pixels,        /* Pixel row in update image */
-                          IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                          const Image * restrict source_image,         /* Source image */
+                          const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                          const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                          Image * restrict update_image,               /* Update image */
+                          PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                          IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                           const long npixels,                /* Number of pixels in row */
                           ExceptionInfo *exception           /* Exception report */
                           )
 {
   register long
     i;
-    
+
   PixelPacket
     destination,
     source;
-    
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(immutable_data);
   ARG_NOT_USED(exception);
-    
+
   /*
     Brightens the destination color by an amount depending on the source color
   */
@@ -2202,10 +2202,10 @@ ColorDodgeCompositePixels(void *mutable_data,               /* User provided mut
 
       double
         value;
-        
+
       PrepareSourcePacket(&source,source_pixels,source_image,source_indexes,i);
       PrepareDestinationPacket(&destination,update_pixels,update_image,update_indexes,i);
-        
+
       source_alpha=(double) source.opacity/MaxRGBDouble;
       dest_alpha=(double) destination.opacity/MaxRGBDouble;
 
@@ -2219,7 +2219,7 @@ ColorDodgeCompositePixels(void *mutable_data,               /* User provided mut
       gamma=1.0/(fabs(gamma) < MagickEpsilon ? MagickEpsilon : gamma);
 
       if(source.red == MaxRGB)
-       value = MaxRGBDouble;
+        value = MaxRGBDouble;
       else
         value=MagickFmin(MaxRGBDouble,(double)destination.red/(1.0-(double) source.red/MaxRGBDouble));
       composite=(value*(1.0-source_alpha)*(1.0-dest_alpha)+
@@ -2228,7 +2228,7 @@ ColorDodgeCompositePixels(void *mutable_data,               /* User provided mut
       destination.red=RoundDoubleToQuantum(composite);
 
       if(source.green == MaxRGB)
-       value = MaxRGBDouble;
+        value = MaxRGBDouble;
       else
         value=MagickFmin(MaxRGBDouble,(double)destination.green/(1.0-(double) source.green/MaxRGBDouble));
       composite=(value*(1.0-source_alpha)*(1.0-dest_alpha)+
@@ -2237,7 +2237,7 @@ ColorDodgeCompositePixels(void *mutable_data,               /* User provided mut
       destination.green=RoundDoubleToQuantum(composite);
 
       if(source.blue == MaxRGB)
-       value = MaxRGBDouble;
+        value = MaxRGBDouble;
       else
         value=MagickFmin(MaxRGBDouble,(double)destination.blue/(1.0-(double) source.blue/MaxRGBDouble));
       composite=(value*(1.0-source_alpha)*(1.0-dest_alpha)+
@@ -2255,27 +2255,27 @@ ColorDodgeCompositePixels(void *mutable_data,               /* User provided mut
 static MagickPassFail
 ColorBurnCompositePixels(void *mutable_data,               /* User provided mutable data */
                          const void *immutable_data,        /* User provided immutable data */
-                         const Image *source_image,         /* Source image */
-                         const PixelPacket *source_pixels,  /* Pixel row in source image */
-                         const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                         Image *update_image,               /* Update image */
-                         PixelPacket *update_pixels,        /* Pixel row in update image */
-                         IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                         const Image * restrict source_image,         /* Source image */
+                         const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                         const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                         Image * restrict update_image,               /* Update image */
+                         PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                         IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                          const long npixels,                /* Number of pixels in row */
                          ExceptionInfo *exception           /* Exception report */
                          )
 {
   register long
     i;
-    
+
   PixelPacket
     destination,
     source;
-    
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(immutable_data);
   ARG_NOT_USED(exception);
-    
+
   /*
     Darkens the destination color by an amount depending on the source color
   */
@@ -2289,10 +2289,10 @@ ColorBurnCompositePixels(void *mutable_data,               /* User provided muta
 
       double
         value;
-        
+
       PrepareSourcePacket(&source,source_pixels,source_image,source_indexes,i);
       PrepareDestinationPacket(&destination,update_pixels,update_image,update_indexes,i);
-        
+
       source_alpha=(double) source.opacity/MaxRGBDouble;
       dest_alpha=(double) destination.opacity/MaxRGBDouble;
 
@@ -2306,27 +2306,27 @@ ColorBurnCompositePixels(void *mutable_data,               /* User provided muta
       gamma=1.0/(fabs(gamma) < MagickEpsilon ? MagickEpsilon : gamma);
 
       if(source.red == 0)
-       value=0;
+        value=0;
       else
-       value = MaxRGBDouble-MagickFmin(MaxRGBDouble,(MaxRGBDouble-(double)destination.red)/((double) source.red/MaxRGBDouble));
+        value = MaxRGBDouble-MagickFmin(MaxRGBDouble,(MaxRGBDouble-(double)destination.red)/((double) source.red/MaxRGBDouble));
       composite=(value*(1.0-source_alpha)*(1.0-dest_alpha)+
                  source.red*(1.0-source_alpha)*dest_alpha+
                  destination.red*(1.0-dest_alpha)*source_alpha)*gamma;
       destination.red=RoundDoubleToQuantum(composite);
 
       if(source.green == 0)
-       value=0;
+        value=0;
       else
-       value = MaxRGBDouble-MagickFmin(MaxRGBDouble,(MaxRGBDouble-(double)destination.green)/((double) source.green/MaxRGBDouble));
+        value = MaxRGBDouble-MagickFmin(MaxRGBDouble,(MaxRGBDouble-(double)destination.green)/((double) source.green/MaxRGBDouble));
       composite=(value*(1.0-source_alpha)*(1.0-dest_alpha)+
                  source.green*(1.0-source_alpha)*dest_alpha+
                  destination.green*(1.0-dest_alpha)*source_alpha)*gamma;
       destination.green=RoundDoubleToQuantum(composite);
 
       if(source.blue == 0)
-       value=0;
+        value=0;
       else
-       value = MaxRGBDouble-MagickFmin(MaxRGBDouble,(MaxRGBDouble-(double)destination.blue)/((double) source.blue/MaxRGBDouble));
+        value = MaxRGBDouble-MagickFmin(MaxRGBDouble,(MaxRGBDouble-(double)destination.blue)/((double) source.blue/MaxRGBDouble));
       composite=(value*(1.0-source_alpha)*(1.0-dest_alpha)+
                  source.blue*(1.0-source_alpha)*dest_alpha+
                  destination.blue*(1.0-dest_alpha)*source_alpha)*gamma;
@@ -2342,27 +2342,27 @@ ColorBurnCompositePixels(void *mutable_data,               /* User provided muta
 static MagickPassFail
 SoftLightCompositePixels(void *mutable_data,               /* User provided mutable data */
                          const void *immutable_data,        /* User provided immutable data */
-                         const Image *source_image,         /* Source image */
-                         const PixelPacket *source_pixels,  /* Pixel row in source image */
-                         const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                         Image *update_image,               /* Update image */
-                         PixelPacket *update_pixels,        /* Pixel row in update image */
-                         IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                         const Image * restrict source_image,         /* Source image */
+                         const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                         const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                         Image * restrict update_image,               /* Update image */
+                         PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                         IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                          const long npixels,                /* Number of pixels in row */
                          ExceptionInfo *exception           /* Exception report */
                          )
 {
   register long
     i;
-    
+
   PixelPacket
     destination,
     source;
-    
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(immutable_data);
   ARG_NOT_USED(exception);
-    
+
   /*
     Darkens or lightens, depending on the source color
   */
@@ -2377,7 +2377,7 @@ SoftLightCompositePixels(void *mutable_data,               /* User provided muta
 
       double
         value;
-        
+
       PrepareSourcePacket(&source,source_pixels,source_image,source_indexes,i);
       PrepareDestinationPacket(&destination,update_pixels,update_image,update_indexes,i);
 
@@ -2393,15 +2393,15 @@ SoftLightCompositePixels(void *mutable_data,               /* User provided muta
 
       gamma=1.0/(fabs(gamma) < MagickEpsilon ? MagickEpsilon : gamma);
 
-      
+
       if(source.red <= (0.5*MaxRGBDouble))
         value=destination.red*(1.0 - (1.0-(double)destination.red/MaxRGBDouble)*(1.0-2.0*(double)source.red/MaxRGBDouble));
       else
       {
-       if(destination.red <= (0.25*MaxRGBDouble))
-         ramp = ((16.0*((double)destination.red/MaxRGBDouble)-12.0)*((double)destination.red/MaxRGBDouble)+4.0)*(double)destination.red/MaxRGBDouble;
-       else
-         ramp = sqrt((double)destination.red/MaxRGBDouble);
+        if(destination.red <= (0.25*MaxRGBDouble))
+          ramp = ((16.0*((double)destination.red/MaxRGBDouble)-12.0)*((double)destination.red/MaxRGBDouble)+4.0)*(double)destination.red/MaxRGBDouble;
+        else
+          ramp = sqrt((double)destination.red/MaxRGBDouble);
         value=destination.red + ((2.0*source.red)-MaxRGBDouble)*(ramp-(double)destination.red/MaxRGBDouble);
       }
       composite=(value*(1.0-source_alpha)*(1.0-dest_alpha)+
@@ -2413,10 +2413,10 @@ SoftLightCompositePixels(void *mutable_data,               /* User provided muta
         value=destination.green*(1.0 - (1.0-(double)destination.green/MaxRGBDouble)*(1.0-2.0*(double)source.green/MaxRGBDouble));
       else
       {
-       if(destination.green <= (0.25*MaxRGBDouble))
-         ramp = ((16.0*((double)destination.green/MaxRGBDouble)-12.0)*((double)destination.green/MaxRGBDouble)+4.0)*(double)destination.green/MaxRGBDouble;
-       else
-         ramp = sqrt((double)destination.green/MaxRGBDouble);
+        if(destination.green <= (0.25*MaxRGBDouble))
+          ramp = ((16.0*((double)destination.green/MaxRGBDouble)-12.0)*((double)destination.green/MaxRGBDouble)+4.0)*(double)destination.green/MaxRGBDouble;
+        else
+          ramp = sqrt((double)destination.green/MaxRGBDouble);
         value=destination.green + ((2.0*source.green)-MaxRGBDouble)*(ramp-(double)destination.green/MaxRGBDouble);
       }
       composite=(value*(1.0-source_alpha)*(1.0-dest_alpha)+
@@ -2428,10 +2428,10 @@ SoftLightCompositePixels(void *mutable_data,               /* User provided muta
         value=destination.blue*(1.0 - (1.0-(double)destination.blue/MaxRGBDouble)*(1.0-2.0*(double)source.blue/MaxRGBDouble));
       else
       {
-       if(destination.blue <= (0.25*MaxRGBDouble))
-         ramp = ((16.0*((double)destination.blue/MaxRGBDouble)-12.0)*((double)destination.blue/MaxRGBDouble)+4.0)*(double)destination.blue/MaxRGBDouble;
-       else
-         ramp = sqrt((double)destination.blue/MaxRGBDouble);
+        if(destination.blue <= (0.25*MaxRGBDouble))
+          ramp = ((16.0*((double)destination.blue/MaxRGBDouble)-12.0)*((double)destination.blue/MaxRGBDouble)+4.0)*(double)destination.blue/MaxRGBDouble;
+        else
+          ramp = sqrt((double)destination.blue/MaxRGBDouble);
         value=destination.blue + ((2.0*source.blue)-MaxRGBDouble)*(ramp-(double)destination.blue/MaxRGBDouble);
       }
       composite=(value*(1.0-source_alpha)*(1.0-dest_alpha)+
@@ -2449,12 +2449,12 @@ SoftLightCompositePixels(void *mutable_data,               /* User provided muta
 static MagickPassFail
 LinearBurnCompositePixels(void *mutable_data,                /* User provided mutable data */
                           const void *immutable_data,        /* User provided immutable data */
-                          const Image *source_image,         /* Source image */
-                          const PixelPacket *source_pixels,  /* Pixel row in source image */
-                          const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                          Image *update_image,               /* Update image */
-                          PixelPacket *update_pixels,        /* Pixel row in update image */
-                          IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                          const Image * restrict source_image,         /* Source image */
+                          const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                          const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                          Image * restrict update_image,               /* Update image */
+                          PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                          IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                           const long npixels,                /* Number of pixels in row */
                           ExceptionInfo *exception           /* Exception report */
                           )
@@ -2526,12 +2526,12 @@ LinearBurnCompositePixels(void *mutable_data,                /* User provided mu
 static MagickPassFail
 LinearDodgeCompositePixels(void *mutable_data,                /* User provided mutable data */
                            const void *immutable_data,        /* User provided immutable data */
-                           const Image *source_image,         /* Source image */
-                           const PixelPacket *source_pixels,  /* Pixel row in source image */
-                           const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                           Image *update_image,               /* Update image */
-                           PixelPacket *update_pixels,        /* Pixel row in update image */
-                           IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                           const Image * restrict source_image,         /* Source image */
+                           const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                           const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                           Image * restrict update_image,               /* Update image */
+                           PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                           IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                            const long npixels,                /* Number of pixels in row */
                            ExceptionInfo *exception           /* Exception report */
                            )
@@ -2603,12 +2603,12 @@ LinearDodgeCompositePixels(void *mutable_data,                /* User provided m
 static MagickPassFail
 LinearLightCompositePixels(void *mutable_data,                /* User provided mutable data */
                            const void *immutable_data,        /* User provided immutable data */
-                           const Image *source_image,         /* Source image */
-                           const PixelPacket *source_pixels,  /* Pixel row in source image */
-                           const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                           Image *update_image,               /* Update image */
-                           PixelPacket *update_pixels,        /* Pixel row in update image */
-                           IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                           const Image * restrict source_image,         /* Source image */
+                           const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                           const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                           Image * restrict update_image,               /* Update image */
+                           PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                           IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                            const long npixels,                /* Number of pixels in row */
                            ExceptionInfo *exception           /* Exception report */
                            )
@@ -2680,12 +2680,12 @@ LinearLightCompositePixels(void *mutable_data,                /* User provided m
 static MagickPassFail
 VividLightCompositePixels(void *mutable_data,                /* User provided mutable data */
                           const void *immutable_data,        /* User provided immutable data */
-                          const Image *source_image,         /* Source image */
-                          const PixelPacket *source_pixels,  /* Pixel row in source image */
-                          const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                          Image *update_image,               /* Update image */
-                          PixelPacket *update_pixels,        /* Pixel row in update image */
-                          IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                          const Image * restrict source_image,         /* Source image */
+                          const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                          const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                          Image * restrict update_image,               /* Update image */
+                          PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                          IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                           const long npixels,                /* Number of pixels in row */
                           ExceptionInfo *exception           /* Exception report */
                           )
@@ -2730,39 +2730,39 @@ VividLightCompositePixels(void *mutable_data,                /* User provided mu
       gamma=1.0/(fabs(gamma) < MagickEpsilon ? MagickEpsilon : gamma);
 
       if(source.red==MaxRGB)
-       value = MaxRGBDouble;
+        value = MaxRGBDouble;
       else if(source.red==0)
-       value = 0.;
+        value = 0.;
       else if(source.red>=(0.5*MaxRGBDouble))
-       value = MagickFmin(MaxRGBDouble,destination.red/(2.0-(2.0*(double)source.red/MaxRGBDouble)));
+        value = MagickFmin(MaxRGBDouble,destination.red/(2.0-(2.0*(double)source.red/MaxRGBDouble)));
       else
-       value = MagickFmax(0.0,((double)destination.red+2.0*source.red-MaxRGBDouble)/(2.0*(double)source.red/MaxRGBDouble));
+        value = MagickFmax(0.0,((double)destination.red+2.0*source.red-MaxRGBDouble)/(2.0*(double)source.red/MaxRGBDouble));
       composite=((value*(1.0-source_alpha)*(1.0-dest_alpha))+
                  source.red*(1.0-source_alpha)*dest_alpha+
                  destination.red*(1.0-dest_alpha)*source_alpha)*gamma;
       destination.red=RoundDoubleToQuantum(composite);
 
       if(source.green==MaxRGB)
-       value = MaxRGBDouble;
+        value = MaxRGBDouble;
       else if(source.green==0)
-       value = 0.;
+        value = 0.;
       else if(source.green>=(0.5*MaxRGBDouble))
-       value = MagickFmin(MaxRGBDouble,destination.green/(2.0-(2.0*(double)source.green/MaxRGBDouble)));
+        value = MagickFmin(MaxRGBDouble,destination.green/(2.0-(2.0*(double)source.green/MaxRGBDouble)));
       else
-       value = MagickFmax(0.0,((double)destination.green+2.0*source.green-MaxRGBDouble)/(2.0*(double)source.green/MaxRGBDouble));
+        value = MagickFmax(0.0,((double)destination.green+2.0*source.green-MaxRGBDouble)/(2.0*(double)source.green/MaxRGBDouble));
       composite=((value*(1.0-source_alpha)*(1.0-dest_alpha))+
                  source.green*(1.0-source_alpha)*dest_alpha+
                  destination.green*(1.0-dest_alpha)*source_alpha)*gamma;
       destination.green=RoundDoubleToQuantum(composite);
 
       if(source.blue==MaxRGB)
-       value = MaxRGBDouble;
+        value = MaxRGBDouble;
       else if(source.blue==0)
-       value = 0.;
+        value = 0.;
       else if(source.blue>=(0.5*MaxRGBDouble))
-       value = MagickFmin(MaxRGBDouble,destination.blue/(2.0-(2.0*(double)source.blue/MaxRGBDouble)));
+        value = MagickFmin(MaxRGBDouble,destination.blue/(2.0-(2.0*(double)source.blue/MaxRGBDouble)));
       else
-       value = MagickFmax(0.0,((double)destination.blue+2.0*source.blue-MaxRGBDouble)/(2.0*(double)source.blue/MaxRGBDouble));
+        value = MagickFmax(0.0,((double)destination.blue+2.0*source.blue-MaxRGBDouble)/(2.0*(double)source.blue/MaxRGBDouble));
       composite=((value*(1.0-source_alpha)*(1.0-dest_alpha))+
                  source.blue*(1.0-source_alpha)*dest_alpha+
                  destination.blue*(1.0-dest_alpha)*source_alpha)*gamma;
@@ -2778,12 +2778,12 @@ VividLightCompositePixels(void *mutable_data,                /* User provided mu
 static MagickPassFail
 PinLightCompositePixels(void *mutable_data,                /* User provided mutable data */
                         const void *immutable_data,        /* User provided immutable data */
-                        const Image *source_image,         /* Source image */
-                        const PixelPacket *source_pixels,  /* Pixel row in source image */
-                        const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                        Image *update_image,               /* Update image */
-                        PixelPacket *update_pixels,        /* Pixel row in update image */
-                        IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                        const Image * restrict source_image,         /* Source image */
+                        const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                        const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                        Image * restrict update_image,               /* Update image */
+                        PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                        IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                         const long npixels,                /* Number of pixels in row */
                         ExceptionInfo *exception           /* Exception report */
                         )
@@ -2828,27 +2828,27 @@ PinLightCompositePixels(void *mutable_data,                /* User provided muta
       gamma=1.0/(fabs(gamma) < MagickEpsilon ? MagickEpsilon : gamma);
 
       if(source.red>=(0.5*MaxRGBDouble))
-       value = MagickFmax((double)destination.red,2.0*((double)source.red-0.5*MaxRGBDouble));
+        value = MagickFmax((double)destination.red,2.0*((double)source.red-0.5*MaxRGBDouble));
       else
-       value = MagickFmin((double)destination.red,2.0*(double)source.red);
+        value = MagickFmin((double)destination.red,2.0*(double)source.red);
       composite=((value*(1.0-source_alpha)*(1.0-dest_alpha))+
                  source.red*(1.0-source_alpha)*dest_alpha+
                  destination.red*(1.0-dest_alpha)*source_alpha)*gamma;
       destination.red=RoundDoubleToQuantum(composite);
 
       if(source.green>=(0.5*MaxRGBDouble))
-       value = MagickFmax((double)destination.green,2.0*((double)source.green-0.5*MaxRGBDouble));
+        value = MagickFmax((double)destination.green,2.0*((double)source.green-0.5*MaxRGBDouble));
       else
-       value = MagickFmin((double)destination.green,2.0*(double)source.green);
+        value = MagickFmin((double)destination.green,2.0*(double)source.green);
       composite=((value*(1.0-source_alpha)*(1.0-dest_alpha))+
                  source.green*(1.0-source_alpha)*dest_alpha+
                  destination.green*(1.0-dest_alpha)*source_alpha)*gamma;
       destination.green=RoundDoubleToQuantum(composite);
 
       if(source.blue>=(0.5*MaxRGBDouble))
-       value = MagickFmax((double)destination.blue,2.0*((double)source.blue-0.5*MaxRGBDouble));
+        value = MagickFmax((double)destination.blue,2.0*((double)source.blue-0.5*MaxRGBDouble));
       else
-       value = MagickFmin((double)destination.blue,2.0*(double)source.blue);
+        value = MagickFmin((double)destination.blue,2.0*(double)source.blue);
       composite=((value*(1.0-source_alpha)*(1.0-dest_alpha))+
                  source.blue*(1.0-source_alpha)*dest_alpha+
                  destination.blue*(1.0-dest_alpha)*source_alpha)*gamma;
@@ -2864,12 +2864,12 @@ PinLightCompositePixels(void *mutable_data,                /* User provided muta
 static MagickPassFail
 HardMixCompositePixels(void *mutable_data,                /* User provided mutable data */
                        const void *immutable_data,        /* User provided immutable data */
-                       const Image *source_image,         /* Source image */
-                       const PixelPacket *source_pixels,  /* Pixel row in source image */
-                       const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                       Image *update_image,               /* Update image */
-                       PixelPacket *update_pixels,        /* Pixel row in update image */
-                       IndexPacket *update_indexes,       /* Pixel row indexes in update image */
+                       const Image * restrict source_image,         /* Source image */
+                       const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                       const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                       Image * restrict update_image,               /* Update image */
+                       PixelPacket * restrict update_pixels,        /* Pixel row in update image */
+                       IndexPacket * restrict update_indexes,       /* Pixel row indexes in update image */
                        const long npixels,                /* Number of pixels in row */
                        ExceptionInfo *exception           /* Exception report */
                        )
@@ -2916,27 +2916,27 @@ HardMixCompositePixels(void *mutable_data,                /* User provided mutab
       gamma=1.0/(fabs(gamma) < MagickEpsilon ? MagickEpsilon : gamma);
 
       if(source.red + destination.red < MaxRGB)
-       value = 0.0;
+        value = 0.0;
       else
-       value = MaxRGBDouble;
+        value = MaxRGBDouble;
       composite=((value*(1.0-source_alpha)*(1.0-dest_alpha))+
                  source.red*(1.0-source_alpha)*dest_alpha+
                  destination.red*(1.0-dest_alpha)*source_alpha)*gamma;
       destination.red=RoundDoubleToQuantum(composite);
 
       if(source.green + destination.green < MaxRGB)
-       value = 0.0;
+        value = 0.0;
       else
-       value = MaxRGBDouble;
+        value = MaxRGBDouble;
       composite=((value*(1.0-source_alpha)*(1.0-dest_alpha))+
                  source.green*(1.0-source_alpha)*dest_alpha+
                  destination.green*(1.0-dest_alpha)*source_alpha)*gamma;
       destination.green=RoundDoubleToQuantum(composite);
 
       if(source.blue + destination.blue < MaxRGB)
-       value = 0.0;
+        value = 0.0;
       else
-       value = MaxRGBDouble;
+        value = MaxRGBDouble;
       composite=((value*(1.0-source_alpha)*(1.0-dest_alpha))+
                  source.blue*(1.0-source_alpha)*dest_alpha+
                  destination.blue*(1.0-dest_alpha)*source_alpha)*gamma;
@@ -2996,8 +2996,8 @@ HardMixCompositePixels(void *mutable_data,                /* User provided mutab
 */
 static PixelIteratorDualModifyCallback
 GetCompositionPixelIteratorCallback(const CompositeOperator compose,
-                                   const MagickBool canvas_matte,
-                                   const MagickBool change_matte,
+                                    const MagickBool canvas_matte,
+                                    const MagickBool change_matte,
                                     MagickBool *clear)
 {
   PixelIteratorDualModifyCallback
@@ -3015,9 +3015,9 @@ GetCompositionPixelIteratorCallback(const CompositeOperator compose,
       break;
     case OverCompositeOp:
       if (canvas_matte || change_matte)
-       call_back=OverCompositePixels;
+        call_back=OverCompositePixels;
       else
-       call_back=CopyCompositePixels;
+        call_back=CopyCompositePixels;
       break;
     case InCompositeOp:
       call_back=InCompositePixels;
@@ -3027,9 +3027,9 @@ GetCompositionPixelIteratorCallback(const CompositeOperator compose,
       break;
     case AtopCompositeOp:
       if (canvas_matte || change_matte)
-       call_back=AtopCompositePixels;
+        call_back=AtopCompositePixels;
       else
-       call_back=CopyCompositePixels;
+        call_back=CopyCompositePixels;
       break;
     case XorCompositeOp:
       call_back=XorCompositePixels;
@@ -3298,18 +3298,23 @@ CompositeImage(Image *canvas_image,
                 if (update_image->matte)
                   y_displace=(vertical_scale*(p->opacity-
                                               (((double) MaxRGB+1.0)/2)))/(((double) MaxRGB+1.0)/2);
-               InterpolateViewColor(AccessDefaultCacheView(canvas_image),r,
-                                    x_offset+x+x_displace,y_offset+y+y_displace,
-                                    &canvas_image->exception);
+                if (InterpolateViewColor(AccessDefaultCacheView(canvas_image),r,
+                                         x_offset+x+x_displace,y_offset+y+y_displace,
+                                         &canvas_image->exception) == MagickFail)
+                  {
+                    status=MagickFail;
+                    break;
+                  }
                 p++;
                 q++;
                 r++;
               }
-            if (!SyncImagePixels(change_image))
-              {
-                status=MagickFail;
-                break;
-              }
+            if (status != MagickFail)
+              if (!SyncImagePixels(change_image))
+                {
+                  status=MagickFail;
+                  break;
+                }
           }
         break;
       }
@@ -3435,8 +3440,8 @@ CompositeImage(Image *canvas_image,
 
 #if 0
     fprintf(stderr,
-           "Parameters: canvas=%lux%lu | composite=%lux%lu | offset x=%ld y=%ld\n"
-           "Overlap:    canvas x=%ld y=%ld | composite x=%ld y=%ld | size=%ldx%ld\n",
+            "Parameters: canvas=%lux%lu | composite=%lux%lu | offset x=%ld y=%ld\n"
+            "Overlap:    canvas x=%ld y=%ld | composite x=%ld y=%ld | size=%ldx%ld\n",
            canvas_image->columns,canvas_image->rows,
            change_image->columns,change_image->rows,
            x_offset,y_offset,
@@ -3456,22 +3461,22 @@ CompositeImage(Image *canvas_image,
         MagickBool
           clear_pixels = MagickFalse;
 
-       columns = Min(canvas_image->columns - canvas_x,
-                     change_image->columns - composite_x);
-       rows = Min(canvas_image->rows - canvas_y,
-                  change_image->rows - composite_y);
+        columns = Min(canvas_image->columns - canvas_x,
+                      change_image->columns - composite_x);
+        rows = Min(canvas_image->rows - canvas_y,
+                   change_image->rows - composite_y);
 
         call_back=GetCompositionPixelIteratorCallback(compose,
-                                                     canvas_image->matte,
-                                                     change_image->matte,
-                                                     &clear_pixels);
+                                                      canvas_image->matte,
+                                                      change_image->matte,
+                                                      &clear_pixels);
         if (call_back != (PixelIteratorDualModifyCallback) NULL)
           {
             char
               description[MaxTextExtent];
 
-           FormatString(description,"[%%s] Composite %s image pixels ...",
-                        CompositeOperatorToString(compose));
+            FormatString(description,"[%%s] Composite %s image pixels ...",
+                         CompositeOperatorToString(compose));
 
             if (clear_pixels)
               {
@@ -3631,9 +3636,9 @@ CompositeImageRegion(const CompositeOperator compose,
   canvas_image->storage_class=DirectClass;
 
   call_back=GetCompositionPixelIteratorCallback(compose,
-                                               canvas_image->matte,
-                                               update_image->matte,
-                                               &clear_pixels);
+                                                canvas_image->matte,
+                                                update_image->matte,
+                                                &clear_pixels);
   if (call_back != (PixelIteratorDualModifyCallback) NULL)
     {
       const char
@@ -3667,7 +3672,7 @@ CompositeImageRegion(const CompositeOperator compose,
              columns,rows,canvas_x,canvas_y);
 #endif
 
-      if ((status == MagickPass) && 
+      if ((status == MagickPass) &&
           ((unsigned long) canvas_x < canvas_image->columns) &&
           ((unsigned long) canvas_y < canvas_image->rows) &&
           ((unsigned long) update_x < update_image->columns) &&
@@ -3756,12 +3761,12 @@ CompositeImageRegion(const CompositeOperator compose,
 */
 static MagickPassFail
 MagickCompositeImageUnderColorPixels(void *mutable_data,             /* User provided mutable data */
-                                    const void *immutable_data,     /* User provided immutable data */
-                                    Image *image,                   /* Modify image */
-                                    PixelPacket * restrict pixels,  /* Pixel row */
-                                    IndexPacket * restrict indexes, /* Pixel row indexes */
-                                    const long npixels,             /* Number of pixels in row */
-                                    ExceptionInfo *exception)       /* Exception report */
+                                     const void *immutable_data,     /* User provided immutable data */
+                                     Image * restrict image,                   /* Modify image */
+                                     PixelPacket * restrict pixels,  /* Pixel row */
+                                     IndexPacket * restrict indexes, /* Pixel row indexes */
+                                     const long npixels,             /* Number of pixels in row */
+                                     ExceptionInfo *exception)       /* Exception report */
 {
   const PixelPacket
     * restrict background_color = (const PixelPacket *) immutable_data;
@@ -3777,7 +3782,7 @@ MagickCompositeImageUnderColorPixels(void *mutable_data,             /* User pro
   for (i=0; i < npixels; i++)
     {
       AlphaCompositePixel(&pixels[i],&pixels[i],pixels[i].opacity,background_color,
-                         background_color->opacity);
+                          background_color->opacity);
       pixels[i].opacity=OpaqueOpacity;
     }
 
@@ -3786,19 +3791,19 @@ MagickCompositeImageUnderColorPixels(void *mutable_data,             /* User pro
 
 MagickExport MagickPassFail
 MagickCompositeImageUnderColor(Image *image,const PixelPacket *undercolor,
-                              ExceptionInfo *exception)
+                               ExceptionInfo *exception)
 {
   MagickPassFail
     status;
 
   image->storage_class=DirectClass;
   status=PixelIterateMonoModify(MagickCompositeImageUnderColorPixels,
-                               NULL,
-                               "[%s] Applying undercolor...",
-                               NULL,undercolor,
-                               0,0,image->columns,image->rows,
-                               image,
-                               exception);
+                                NULL,
+                                "[%s] Applying undercolor...",
+                                NULL,undercolor,
+                                0,0,image->columns,image->rows,
+                                image,
+                                exception);
   image->matte=MagickFalse;
 
   return status;
index c8a43c1..c01d4b4 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 - 2010 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Image Composite Methods.
 */
 #ifndef _MAGICK_COMPOSITE_H
@@ -44,7 +44,7 @@ extern MagickExport MagickPassFail
                        const long canvas_y,
                        ExceptionInfo *exception),
   MagickCompositeImageUnderColor(Image *image,const PixelPacket *undercolor,
-                                ExceptionInfo *exception);
+                                 ExceptionInfo *exception);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
index c8aa1ab..5563744 100644 (file)
@@ -314,7 +314,7 @@ MagickExport void Ascii85Encode(Image *image,const magick_uint8_t code)
     image->ascii85->buffer[n]=(*p++);
 }
 \f
-MagickExport unsigned int Ascii85WriteByteHook(Image *image, 
+MagickExport unsigned int Ascii85WriteByteHook(Image *image,
   const magick_uint8_t code, void *info)
 {
   ARG_NOT_USED(info);
@@ -623,7 +623,7 @@ MagickExport MagickPassFail HuffmanDecodeImage(Image *image)
         }
     y++;
   }
-  image->rows=Max(y-3,1);
+  image->rows=Max(y-3,1); /* FIXME: Not synced with pixel cache dimensions */
   image->compression=FaxCompression;
   /*
     Free decoder memory.
@@ -927,7 +927,7 @@ MagickExport MagickPassFail HuffmanEncodeImage(const ImageInfo *image_info,
 */
 MagickExport unsigned char *
 ImageToHuffman2DBlob(const Image *image,const ImageInfo *image_info,
-                    size_t *blob_length,ExceptionInfo *exception)
+                     size_t *blob_length,ExceptionInfo *exception)
 {
   unsigned char
     *blob = (unsigned char *) NULL;
@@ -941,16 +941,16 @@ ImageToHuffman2DBlob(const Image *image,const ImageInfo *image_info,
   if (huffman_info != (ImageInfo *) NULL)
     {
       Image
-       *huffman_image;
+        *huffman_image;
 
       huffman_image=CloneImage(image,0,0,MagickTrue,exception);
       if (huffman_image != (Image *) NULL)
-       {
-         (void) strlcpy(huffman_image->magick,"GROUP4RAW",sizeof(huffman_image->magick));
-         (void) strlcpy(huffman_image->filename,"",sizeof(huffman_image->filename));
-         blob=ImageToBlob(huffman_info, huffman_image, blob_length, exception);
-         DestroyImage(huffman_image);
-       }
+        {
+          (void) strlcpy(huffman_image->magick,"GROUP4RAW",sizeof(huffman_image->magick));
+          (void) strlcpy(huffman_image->filename,"",sizeof(huffman_image->filename));
+          blob=ImageToBlob(huffman_info, huffman_image, blob_length, exception);
+          DestroyImage(huffman_image);
+        }
       DestroyImageInfo(huffman_info);
     }
   return blob;
@@ -991,7 +991,7 @@ ImageToHuffman2DBlob(const Image *image,const ImageInfo *image_info,
 */
 MagickExport unsigned char *
 ImageToJPEGBlob(const Image *image,const ImageInfo *image_info,
-               size_t *blob_length,ExceptionInfo *exception)
+                size_t *blob_length,ExceptionInfo *exception)
 {
   unsigned char
     *blob = NULL;
@@ -1004,25 +1004,25 @@ ImageToJPEGBlob(const Image *image,const ImageInfo *image_info,
   if (jpeg_info != (ImageInfo *) NULL)
     {
       Image
-       *jpeg_image;
+        *jpeg_image;
 
       /*
-       Try to preserve any existing JPEG options but if the user
-       applies any override, then existing JPEG options are ignored.
+        Try to preserve any existing JPEG options but if the user
+        applies any override, then existing JPEG options are ignored.
       */
       if ((JPEGCompression == image->compression) &&
-         (DefaultCompressionQuality == image_info->quality) &&
-         ((char *) NULL == jpeg_info->sampling_factor))
-       (void) AddDefinitions(jpeg_info,"jpeg:preserve-settings=TRUE",
-                             exception);
+          (DefaultCompressionQuality == image_info->quality) &&
+          ((char *) NULL == jpeg_info->sampling_factor))
+        (void) AddDefinitions(jpeg_info,"jpeg:preserve-settings=TRUE",
+                              exception);
       jpeg_image=CloneImage(image,0,0,MagickTrue,exception);
       if (jpeg_image != (Image *) NULL)
-       {
-         (void) strlcpy(jpeg_image->magick,"JPEG",sizeof(jpeg_image->magick));
-         (void) strlcpy(jpeg_image->filename,"",sizeof(jpeg_image->filename));
-         blob =(unsigned char *) ImageToBlob(jpeg_info, jpeg_image, blob_length, exception);
-         DestroyImage(jpeg_image);
-       }
+        {
+          (void) strlcpy(jpeg_image->magick,"JPEG",sizeof(jpeg_image->magick));
+          (void) strlcpy(jpeg_image->filename,"",sizeof(jpeg_image->filename));
+          blob =(unsigned char *) ImageToBlob(jpeg_info, jpeg_image, blob_length, exception);
+          DestroyImage(jpeg_image);
+        }
       DestroyImageInfo(jpeg_info);
     }
   return blob;
@@ -1235,7 +1235,7 @@ MagickExport MagickPassFail LZWEncodeImage(Image *image, const size_t length,
 %
 */
 MagickExport MagickPassFail PackbitsEncode2Image(Image *image,
-  const size_t length,magick_uint8_t *pixels,WriteByteHook write_byte, 
+  const size_t length,magick_uint8_t *pixels,WriteByteHook write_byte,
   void *info)
 {
   int
index 2d0046a..97d6ffc 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 - 2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Image Compression/Decompression Methods.
 */
 #ifndef _MAGICK_COMPRESS_H
@@ -41,7 +41,7 @@ typedef unsigned int
 /*
   Commonly used byte writer hooks.
 */
-extern MagickExport unsigned int 
+extern MagickExport unsigned int
   Ascii85WriteByteHook(Image *image, const magick_uint8_t code, void *info),
   BlobWriteByteHook(Image *image, const magick_uint8_t code, void *info);
 
index dbc6db3..dbcee7a 100644 (file)
@@ -58,8 +58,8 @@ static ConfirmAccessHandler
 */
 MagickExport MagickPassFail
 MagickConfirmAccess(const ConfirmAccessMode mode,
-                   const char *path,
-                   ExceptionInfo *exception)
+                    const char *path,
+                    ExceptionInfo *exception)
 {
   MagickPassFail
     status;
index 721f824..eab7878 100644 (file)
@@ -1,10 +1,10 @@
 /*
   Copyright (C) 2009 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Access Confirmation Methods.
 */
 #ifndef _MAGICK_CONFIRM_ACCESS_H
@@ -13,7 +13,7 @@
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
-  
+
   typedef enum
     {
       UndefinedConfirmAccessMode,
@@ -27,13 +27,13 @@ extern "C" {
 
   typedef MagickPassFail
   (*ConfirmAccessHandler)(const ConfirmAccessMode mode,
-                         const char *path,
-                         ExceptionInfo *exception);
+                          const char *path,
+                          ExceptionInfo *exception);
 
   extern MagickExport MagickPassFail
   MagickConfirmAccess(const ConfirmAccessMode mode,
-                     const char *path,
-                     ExceptionInfo *exception);
+                      const char *path,
+                      ExceptionInfo *exception);
 
   extern MagickExport ConfirmAccessHandler
   MagickSetConfirmAccessHandler(ConfirmAccessHandler handler);
index 07b8424..b2db390 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -214,15 +214,15 @@ MagickExport Image *ConstituteImage(const unsigned long width,
         dispatch_type=UndefinedDispatchType;
 
       if (LocaleCompare(map,"BGR") == 0)
-       dispatch_type=BGRDispatchType;
+        dispatch_type=BGRDispatchType;
       else if (LocaleCompare(map,"BGRA") == 0)
-       dispatch_type=BGRADispatchType;
+        dispatch_type=BGRADispatchType;
       else if (LocaleCompare(map,"BGRP") == 0)
-       dispatch_type=BGRPDispatchType;
+        dispatch_type=BGRPDispatchType;
       else if (LocaleCompare(map,"RGB") == 0)
-       dispatch_type=RGBDispatchType;
+        dispatch_type=RGBDispatchType;
       else if (LocaleCompare(map,"RGBA") == 0)
-       dispatch_type=RGBADispatchType;
+        dispatch_type=RGBADispatchType;
       else if (LocaleCompare(map,"I") == 0)
         {
           if (!AllocateImageColormap(image,MaxColormapSize))
@@ -259,7 +259,7 @@ MagickExport Image *ConstituteImage(const unsigned long width,
                   }
                 case BGRADispatchType:
                   {
-                   image->matte=True;
+                    image->matte=True;
                     for (x=(long) image->columns; x != 0; x--)
                       {
                         SetBlueSample(q,ScaleCharToQuantum(*p++));
@@ -297,7 +297,7 @@ MagickExport Image *ConstituteImage(const unsigned long width,
                   }
                 case RGBADispatchType:
                   {
-                   image->matte=True;
+                    image->matte=True;
                     for (x=(long) image->columns; x != 0; x--)
                       {
                         SetRedSample(q,ScaleCharToQuantum(*p++));
@@ -442,9 +442,9 @@ MagickExport Image *ConstituteImage(const unsigned long width,
       indexes=AccessMutableIndexes(image);
       for (x=0; x < (long) image->columns; x++)
         {
-         SetRedSample(q,0);
-         SetGreenSample(q,0);
-         SetBlueSample(q,0);
+          SetRedSample(q,0);
+          SetGreenSample(q,0);
+          SetBlueSample(q,0);
           if (image->colorspace == CMYKColorspace)
             {
               SetBlackSample(q,0);
@@ -460,7 +460,7 @@ MagickExport Image *ConstituteImage(const unsigned long width,
                 Input a quantum
               */
               quantum=0U;
-              
+
               switch (type)
                 {
                 case CharPixel:
@@ -510,7 +510,7 @@ MagickExport Image *ConstituteImage(const unsigned long width,
                     break;
                   }
                 }
-              
+
               /*
                 Transfer quantum to image
               */
@@ -560,7 +560,7 @@ MagickExport Image *ConstituteImage(const unsigned long width,
       if (!SyncImagePixels(image))
         break;
     }
-  
+
   if (image->storage_class == PseudoClass)
     {
       /*
@@ -611,7 +611,7 @@ MagickExport void DestroyConstitute(void)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  DispatchImage() extracts pixel data from an Image into a raw memory array.
-%  The pixel data is written in scanline order top-to-bottom using an 
+%  The pixel data is written in scanline order top-to-bottom using an
 %  arbitrary quantum order specified by 'map', and with quantum size
 %  specified by 'type'.
 %
@@ -716,7 +716,7 @@ MagickExport MagickPassFail DispatchImage(const Image *image,const long x_offset
         {
           register unsigned char
             * restrict q = (unsigned char*) pixels;
-          
+
           for (y=0; y < (long) rows; y++)
             {
               p=AcquireImagePixels(image,x_offset,y_offset+y,columns,1,exception);
@@ -725,7 +725,7 @@ MagickExport MagickPassFail DispatchImage(const Image *image,const long x_offset
                   status=MagickFail;
                   break;
                 }
-              
+
               switch (dispatch_type)
                 {
                 case BGRDispatchType:
@@ -900,7 +900,7 @@ MagickExport MagickPassFail DispatchImage(const Image *image,const long x_offset
           }
         }
     }
-  
+
   for (y=0; y < (long) rows; y++)
     {
       p=AcquireImagePixels(image,x_offset,y_offset+y,columns,1,exception);
@@ -957,7 +957,7 @@ MagickExport MagickPassFail DispatchImage(const Image *image,const long x_offset
                 case OpacityMapQuantum:
                   {
                     if ((image->matte) ||
-                       (image->colorspace == CMYKColorspace))
+                        (image->colorspace == CMYKColorspace))
                       quantum=GetOpacitySample(p);
                     break;
                   }
@@ -1037,7 +1037,7 @@ MagickExport MagickPassFail DispatchImage(const Image *image,const long x_offset
 %  MagickFindRawImageMinMax() obtains the minimum and maximum sample values
 %  for a raw image.  The image blob must already be open with its current
 %  seek offset pointing to the start of the raw data.  The seek offset is
-%  restored when this function returns.  File data is processed on a 
+%  restored when this function returns.  File data is processed on a
 %  scanline basis in order to minimize memory consumption.  The purpose of
 %  this function is to support pre-scanning a raw image to find its maximum
 %  values so that appropriate scaling may be applied when the data is read a
@@ -1085,7 +1085,7 @@ MagickExport MagickPassFail DispatchImage(const Image *image,const long x_offset
           x;                                                            \
                                                                         \
         basic_type                                                      \
-          * restrict scanline;                                         \
+          * restrict scanline;                                          \
                                                                         \
         scanline=(basic_type *) scanline_buffer;                        \
         if ((read_func)(image, scanline_octets, scanline) !=            \
@@ -1136,7 +1136,7 @@ MagickFindRawImageMinMax(Image *image, EndianType endian,
             size_t (*read_func)(Image * image, size_t octets, void *data);
 
             read_func = ReadBlob;
-            
+
             MagickFindMinMax(status,image,read_func,char,scanline_octets,
                              scanline_buffer,min,max)
               break;
@@ -1493,7 +1493,7 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
     ExceptionInfo
       module_exception,
       delegate_exception;
-    
+
     GetExceptionInfo(&module_exception);
     GetExceptionInfo(&delegate_exception);
     magick_info=GetMagickInfo(clone_info->magick,&module_exception);
@@ -1501,7 +1501,7 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
     if ((magick_info == (const MagickInfo *) NULL) ||
         (magick_info->decoder == NULL))
       delegate_info=GetDelegateInfo(clone_info->magick,(char *) NULL,&delegate_exception);
-    
+
     if (((magick_info == (const MagickInfo *) NULL) ||
          (magick_info->decoder == NULL)) &&
         ((delegate_info == (const DelegateInfo *) NULL) ||
@@ -1536,8 +1536,8 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
               }
             else
               {
-              ThrowException(exception,FileOpenError,UnableToOpenFile,
-                             clone_info->filename);
+                ThrowException(exception,FileOpenError,UnableToOpenFile,
+                               clone_info->filename);
               }
           }
         DestroyExceptionInfo(&module_exception);
@@ -1547,7 +1547,7 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
         DestroyImageInfo(clone_info);
         return((Image *) NULL);
       }
-    
+
     DestroyExceptionInfo(&module_exception);
     DestroyExceptionInfo(&delegate_exception);
   }
@@ -1600,29 +1600,36 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
         LockSemaphoreInfo(constitute_semaphore);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
         "Invoking \"%.1024s\" decoder (%.1024s) subimage=%lu subrange=%lu",
-                           magick_info->name,
-                           magick_info->description,
-                           clone_info->subimage,
-                           clone_info->subrange);
+                            magick_info->name,
+                            magick_info->description,
+                            clone_info->subimage,
+                            clone_info->subrange);
       image=(magick_info->decoder)(clone_info,exception);
       if (!magick_info->thread_support)
         UnlockSemaphoreInfo(constitute_semaphore);
 
       if (image != (Image *) NULL)
-        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-          "Returned from \"%.1024s\" decoder: frames=%lu cache=%s monochrome=%s grayscale=%s class=%s colorspace=%s",
-                              magick_info->name,
-                              GetImageListLength(image),
-                             (GetPixelCachePresent(image) ? "present" : "missing"),
-                              MagickBoolToString(image->is_monochrome),
-                              MagickBoolToString(image->is_grayscale),
-                              ClassTypeToString(image->storage_class),
-                              ColorspaceTypeToString(image->colorspace));
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Returned from \"%.1024s\" decoder: frames=%lu cache=%s"
+                                " monochrome=%s grayscale=%s class=%s colorspace=%s",
+                                magick_info->name,
+                                GetImageListLength(image),
+                                (GetPixelCachePresent(image) ? "present" : "missing"),
+                                MagickBoolToString(image->is_monochrome),
+                                MagickBoolToString(image->is_grayscale),
+                                ClassTypeToString(image->storage_class),
+                                ColorspaceTypeToString(image->colorspace));
+        }
       else
-        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-          "Returned from \"%.1024s\" decoder, returned image is NULL!",
-                              magick_info->name);
-      
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Returned from \"%.1024s\" decoder, returned image is NULL!",
+                                magick_info->name);
+          if (exception->severity < ErrorException)
+            ThrowException(exception,CoderError,DecodedImageNotReturned,filename);
+        }
+
       /*
         Enforce that returned images do not have open blobs.
       */
@@ -1709,28 +1716,36 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
         LockSemaphoreInfo(constitute_semaphore);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
         "Invoking \"%.1024s\" decoder (%.1024s) subimage=%lu subrange=%lu",
-                           magick_info->name,
-                           magick_info->description,
-                           clone_info->subimage,
-                           clone_info->subrange);
+                            magick_info->name,
+                            magick_info->description,
+                            clone_info->subimage,
+                            clone_info->subrange);
       image=(magick_info->decoder)(clone_info,exception);
       if (!magick_info->thread_support)
         UnlockSemaphoreInfo(constitute_semaphore);
 
       if (image != (Image *) NULL)
-        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-          "Returned from \"%.1024s\" decoder: frames=%lu cache=%s monochrome=%s grayscale=%s class=%s colorspace=%s",
-                              magick_info->name,
-                              GetImageListLength(image),
-                             (GetPixelCachePresent(image) ? "present" : "missing"),
-                              MagickBoolToString(image->is_monochrome),
-                              MagickBoolToString(image->is_grayscale),
-                              ClassTypeToString(image->storage_class),
-                              ColorspaceTypeToString(image->colorspace));
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Returned from \"%.1024s\" decoder: frames=%lu"
+                                " cache=%s monochrome=%s grayscale=%s class=%s"
+                                " colorspace=%s",
+                                magick_info->name,
+                                GetImageListLength(image),
+                                (GetPixelCachePresent(image) ? "present" : "missing"),
+                                MagickBoolToString(image->is_monochrome),
+                                MagickBoolToString(image->is_grayscale),
+                                ClassTypeToString(image->storage_class),
+                                ColorspaceTypeToString(image->colorspace));
+        }
       else
-        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-          "Returned from \"%.1024s\" decoder: returned image is NULL!",
-                              magick_info->name);
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "Returned from \"%.1024s\" decoder: returned image is NULL!",
+                                magick_info->name);
+          if (exception->severity < ErrorException)
+            ThrowException(exception,CoderError,DecodedImageNotReturned,filename);
+        }
 
       /*
         Enforce that returned images do not have open blobs.
@@ -1860,7 +1875,7 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
     {
       const ImageAttribute
         *attribute;
-      
+
 /*       if ((image_info->attributes) && */
 /*           (attribute=GetImageAttribute(image_info->attributes,"colorspace-override"))) */
       if ((attribute=GetImageAttribute(image,"colorspace-override")))
@@ -2087,13 +2102,14 @@ MagickExport Image *ReadInlineImage(const ImageInfo *image_info,
 %
 %  Use WriteImage() to write an image or an image sequence to a file or
 %  filehandle.  If writing to a file on disk, the name is defined by the
-%  filename member of the image structure.  Write() returns 0 is there is a
-%  memory shortage or if the image cannot be written.  Check the exception
-%  member of image to determine the cause for any failure.
+%  filename member of the image structure.  WriteImage() returns
+%  MagickFailure is there is a memory shortage or if the image cannot be
+%  written.  Check the exception member of image to determine the cause
+%  for any failure.
 %
 %  The format of the WriteImage method is:
 %
-%      unsigned int WriteImage(const ImageInfo *image_info,Image *image)
+%      MagickPassFail WriteImage(const ImageInfo *image_info,Image *image)
 %
 %  A description of each parameter follows:
 %
@@ -2103,7 +2119,8 @@ MagickExport Image *ReadInlineImage(const ImageInfo *image_info,
 %
 %
 */
-MagickExport unsigned int WriteImage(const ImageInfo *image_info,Image *image)
+MagickExport MagickPassFail
+WriteImage(const ImageInfo *image_info,Image *image)
 {
   const DelegateInfo
     *delegate_info;
@@ -2114,7 +2131,7 @@ MagickExport unsigned int WriteImage(const ImageInfo *image_info,Image *image)
   ImageInfo
     *clone_info;
 
-  unsigned int
+  MagickPassFail
     status;
 
   /*
@@ -2148,7 +2165,7 @@ MagickExport unsigned int WriteImage(const ImageInfo *image_info,Image *image)
       (clone_info->page == (char *) NULL) && !IsTaintImage(image))
     {
       delegate_info=GetDelegateInfo(image->magick,clone_info->magick,
-                                   &image->exception);
+                                    &image->exception);
       if ((delegate_info != (const DelegateInfo *) NULL) &&
           (delegate_info->mode == 0) && IsAccessible(image->magick_filename))
         {
@@ -2156,9 +2173,9 @@ MagickExport unsigned int WriteImage(const ImageInfo *image_info,Image *image)
             Let our bi-modal delegate process the image.
           */
           (void) strlcpy(image->filename,image->magick_filename,
-                        MaxTextExtent);
+                         MaxTextExtent);
           status=InvokeDelegate(clone_info,image,image->magick,
-                               clone_info->magick,&image->exception);
+                                clone_info->magick,&image->exception);
           DestroyImageInfo(clone_info);
           return(!status);
         }
@@ -2168,88 +2185,89 @@ MagickExport unsigned int WriteImage(const ImageInfo *image_info,Image *image)
   /*
     Call appropriate image writer based on image type.
   */
-  status=False;
+  status=MagickFail;
   magick_info=GetMagickInfo(clone_info->magick,&image->exception);
   if ((magick_info != (const MagickInfo *) NULL) &&
       (magick_info->encoder != NULL))
     {
       char
-       tempfile[MaxTextExtent];
+        tempfile[MaxTextExtent];
 
       tempfile[0]='\0';
 
       if (magick_info->seekable_stream == MagickTrue)
-       {
-         /*
-           Divert output to temporary file if coder requires a
-           seekable stream and output is not seekable.
-         */
-         if (OpenBlob(clone_info,image,WriteBinaryBlobMode,&image->exception))
-           {
-             if (!BlobIsSeekable(image))
-               {
-                 if(!AcquireTemporaryFileName(tempfile))
-                   {
-                     ThrowException(&image->exception,FileOpenError,
-                                    UnableToCreateTemporaryFile,image->filename);
-                     DestroyImageInfo(clone_info);
-                     return(False);
-                   }
-                 (void) strlcpy(image->filename,tempfile,sizeof(image->filename));
-               }
-             else
-               {
-                 /*
-                   OpenBlob may expand image->filename so we need to restore it.
-                 */
-                 (void) strlcpy(image->filename,clone_info->filename,sizeof(image->filename));
-               }
-             CloseBlob(image);
-           }
-       }
+        {
+          /*
+            Divert output to temporary file if coder requires a
+            seekable stream and output is not seekable.
+          */
+          if (OpenBlob(clone_info,image,WriteBinaryBlobMode,&image->exception))
+            {
+              if (!BlobIsSeekable(image))
+                {
+                  if(!AcquireTemporaryFileName(tempfile))
+                    {
+                      ThrowException(&image->exception,FileOpenError,
+                                     UnableToCreateTemporaryFile,image->filename);
+                      DestroyImageInfo(clone_info);
+                      return(MagickFail);
+                    }
+                  (void) strlcpy(image->filename,tempfile,sizeof(image->filename));
+                }
+              else
+                {
+                  /*
+                    OpenBlob may expand image->filename so we need to restore it.
+                  */
+                  (void) strlcpy(image->filename,clone_info->filename,sizeof(image->filename));
+                }
+              CloseBlob(image);
+            }
+        }
 
       if (!magick_info->thread_support)
         LockSemaphoreInfo(constitute_semaphore);
       if (image->logging)
-       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                             "Invoking \"%.1024s\" encoder (%.1024s): "
-                             "cache=%s "
-                             "adjoin=%s type=%s monochrome=%s grayscale=%s "
-                             "class=%s colorspace=%s",
-                             magick_info->name,
-                             magick_info->description,
-                             (GetPixelCachePresent(image) ? "present" : "missing"),
-                             MagickBoolToString(clone_info->adjoin),
-                             ImageTypeToString(clone_info->type),
-                             MagickBoolToString(image->is_monochrome),
-                             MagickBoolToString(image->is_grayscale),
-                             ClassTypeToString(image->storage_class),
-                             ColorspaceTypeToString(image->colorspace));
+        (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                              "Invoking \"%.1024s\" encoder (%.1024s): "
+                              "cache=%s "
+                              "adjoin=%s type=%s monochrome=%s grayscale=%s "
+                              "class=%s colorspace=%s",
+                              magick_info->name,
+                              magick_info->description,
+                              (GetPixelCachePresent(image) ? "present" : "missing"),
+                              MagickBoolToString(clone_info->adjoin),
+                              ImageTypeToString(clone_info->type),
+                              MagickBoolToString(image->is_monochrome),
+                              MagickBoolToString(image->is_grayscale),
+                              ClassTypeToString(image->storage_class),
+                              ColorspaceTypeToString(image->colorspace));
       status=(magick_info->encoder)(clone_info,image);
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "Returned from \"%.1024s\" encoder",magick_info->name);
+                            "Returned from \"%.1024s\" encoder, %s",magick_info->name,
+                            (status == MagickFail ? "Failed" :"Succeeded"));
       if (!magick_info->thread_support)
         UnlockSemaphoreInfo(constitute_semaphore);
 
       if (tempfile[0] != '\0')
-       {
-         /*
-           Send temporary file to stream.
-         */
-         (void) strlcpy(image->filename,clone_info->filename,MaxTextExtent);     
-         if ((status &= OpenBlob(clone_info,image,WriteBinaryBlobMode,
-                                 &image->exception)))
-           {
-             status &= WriteBlobFile(image,tempfile);
-             CloseBlob(image);
-           }
-         LiberateTemporaryFile(tempfile);
-       }
+        {
+          /*
+            Send temporary file to stream.
+          */
+          (void) strlcpy(image->filename,clone_info->filename,MaxTextExtent);
+          if ((status &= OpenBlob(clone_info,image,WriteBinaryBlobMode,
+                                  &image->exception)))
+            {
+              status &= WriteBlobFile(image,tempfile);
+              CloseBlob(image);
+            }
+          LiberateTemporaryFile(tempfile);
+        }
     }
   else
     {
       delegate_info=GetDelegateInfo((char *) NULL,clone_info->magick,
-                                   &image->exception);
+                                    &image->exception);
       if (delegate_info != (DelegateInfo *) NULL)
         {
           /*
@@ -2258,12 +2276,12 @@ MagickExport unsigned int WriteImage(const ImageInfo *image_info,Image *image)
           if(!AcquireTemporaryFileName(image->filename))
             {
               ThrowException(&image->exception,FileOpenError,
-                            UnableToCreateTemporaryFile,image->filename);
+                             UnableToCreateTemporaryFile,image->filename);
               DestroyImageInfo(clone_info);
-              return(False);
+              return(MagickFail);
             }
           status=InvokeDelegate(clone_info,image,(char *) NULL,
-                               clone_info->magick,&image->exception);
+                                clone_info->magick,&image->exception);
           (void) LiberateTemporaryFile(image->filename);
           DestroyImageInfo(clone_info);
           return(!status);
@@ -2277,9 +2295,9 @@ MagickExport unsigned int WriteImage(const ImageInfo *image_info,Image *image)
         {
           DestroyImageInfo(clone_info);
           ThrowBinaryException(MissingDelegateError,
-                              NoEncodeDelegateForThisImageFormat,
-                              image->filename)
-           }
+                               NoEncodeDelegateForThisImageFormat,
+                               clone_info->magick)
+            }
       if (!magick_info->thread_support)
         LockSemaphoreInfo(constitute_semaphore);
       status=(magick_info->encoder)(clone_info,image);
@@ -2288,6 +2306,17 @@ MagickExport unsigned int WriteImage(const ImageInfo *image_info,Image *image)
     }
   (void) strlcpy(image->magick,clone_info->magick,MaxTextExtent);
   DestroyImageInfo(clone_info);
+  if (GetBlobStatus(image))
+    {
+      int
+        first_errno;
+
+      first_errno=GetBlobFirstErrno(image);
+      if (first_errno != 0)
+        errno=first_errno;
+      ThrowBinaryException(CorruptImageError,AnErrorHasOccurredWritingToFile,
+                           image->filename);
+    }
   return(status);
 }
 \f
@@ -2313,8 +2342,10 @@ MagickExport unsigned int WriteImage(const ImageInfo *image_info,Image *image)
 %
 %  The format of the WriteImages method is:
 %
-%      unsigned int WriteImages(const ImageInfo *image_info,Image *image,
-%                               const char *filename,ExceptionInfo *exception)
+%      MagickPassFail WriteImages(const ImageInfo *image_info,
+%                                 Image *image,
+%                                 const char *filename,
+%                                 ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -2328,8 +2359,9 @@ MagickExport unsigned int WriteImage(const ImageInfo *image_info,Image *image)
 %
 %
 */
-MagickExport MagickPassFail WriteImages(const ImageInfo *image_info,Image *image,
-                                       const char *filename,ExceptionInfo *exception)
+MagickExport MagickPassFail
+WriteImages(const ImageInfo *image_info,Image *image,
+            const char *filename,ExceptionInfo *exception)
 {
   ImageInfo
     *clone_info;
@@ -2363,9 +2395,9 @@ MagickExport MagickPassFail WriteImages(const ImageInfo *image_info,Image *image
                 status &= MagickFail;
         }
       (void) SetImageInfo(clone_info,
-                         (SETMAGICK_WRITE |
-                          (!clone_info->adjoin ? SETMAGICK_RECTIFY : 0U)),
-                         exception);
+                          (SETMAGICK_WRITE |
+                           (!clone_info->adjoin ? SETMAGICK_RECTIFY : 0U)),
+                          exception);
       for (p=image; p != (Image *) NULL; p=p->next)
         {
           status &= WriteImage(clone_info,p);
@@ -2417,7 +2449,7 @@ MagickExport MagickPassFail WriteImages(const ImageInfo *image_info,Image *image
 %
 */
 MagickExport MagickPassFail WriteImagesFile(const ImageInfo *image_info,Image *image,
-                                           FILE * file ,ExceptionInfo *exception)
+                                            FILE * file ,ExceptionInfo *exception)
 {
   ImageInfo
     *clone_info;
@@ -2442,9 +2474,9 @@ MagickExport MagickPassFail WriteImagesFile(const ImageInfo *image_info,Image *i
 
       clone_info->file=file;
       (void) SetImageInfo(clone_info,
-                         (SETMAGICK_WRITE |
-                          (!clone_info->adjoin ? SETMAGICK_RECTIFY : 0U)),
-                         exception);
+                          (SETMAGICK_WRITE |
+                           (!clone_info->adjoin ? SETMAGICK_RECTIFY : 0U)),
+                          exception);
       for (p=image; p != (Image *) NULL; p=p->next)
         {
           status &= WriteImage(clone_info,p);
index cfac9f0..390835b 100644 (file)
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2003 - 2009 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Constitute Methods.
 */
 #ifndef _MAGICK_CONSTITUTE_H
@@ -189,7 +189,7 @@ extern MagickExport MagickPassFail
     double *min, double *max);
 
 extern MagickExport unsigned int
-  MagickGetQuantumSamplesPerPixel(const QuantumType quantum_type);
+  MagickGetQuantumSamplesPerPixel(const QuantumType quantum_type) MAGICK_FUNC_CONST;
 
 #if defined(MAGICK_IMPLEMENTATION)
 
index f3f03e9..9a6d6a9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -152,13 +152,13 @@ MagickExport Image *FrameImage(const Image *image,const FrameInfo *frame_info,
     y;
 
   register const PixelPacket
-    *p;
+    * restrict p;
 
   register long
     x;
 
   register PixelPacket
-    *q;
+    * restrict q;
 
   PixelPacket
     accentuate,
@@ -302,9 +302,6 @@ MagickExport Image *FrameImage(const Image *image,const FrameInfo *frame_info,
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_FrameImage)
-#endif    
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -340,24 +337,27 @@ MagickExport Image *FrameImage(const Image *image,const FrameInfo *frame_info,
           if (!SyncImagePixelsEx(frame_image,exception))
             thread_status=MagickFail;
         }
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_FrameImage)
+#if defined(HAVE_OPENMP)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,image->rows))
-          if (!MagickMonitorFormatted(row_count,image->rows,exception,
-                                      FrameImageText,image->filename,
-                                     frame_info->width,frame_info->height,
-                                     frame_info->x,
-                                     frame_info->y,
-                                     frame_info->inner_bevel,
-                                     frame_info->outer_bevel))
-            thread_status=MagickFail;
-          
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,image->rows))
+        if (!MagickMonitorFormatted(row_count,image->rows,exception,
+                                    FrameImageText,image->filename,
+                                    frame_info->width,frame_info->height,
+                                    frame_info->x,
+                                    frame_info->y,
+                                    frame_info->inner_bevel,
+                                    frame_info->outer_bevel))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
   /*
     Draw bottom of ornamental border.
@@ -365,7 +365,7 @@ MagickExport Image *FrameImage(const Image *image,const FrameInfo *frame_info,
   height=(long) (frame_info->inner_bevel+frame_info->height-frame_info->y-
                  image->rows-bevel_width+frame_info->outer_bevel);
   q=SetImagePixelsEx(frame_image,0,(long) (frame_image->rows-height),
-                        frame_image->columns,height,exception);
+                     frame_image->columns,height,exception);
   if (q == (PixelPacket *) NULL)
     return(frame_image);
   for (y=frame_info->inner_bevel-1; y >= 0; y--)
@@ -471,7 +471,7 @@ RaiseImage(Image *image,const RectangleInfo *raise_info,const int raise_flag)
     is_grayscale;
 
   register PixelPacket
-    *q;
+    * restrict q;
 
   MagickPassFail
     status=MagickPass;
@@ -506,9 +506,6 @@ RaiseImage(Image *image,const RectangleInfo *raise_info,const int raise_flag)
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_RaiseImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -604,19 +601,22 @@ RaiseImage(Image *image,const RectangleInfo *raise_info,const int raise_flag)
           if (!SyncImagePixelsEx(image,&image->exception))
             thread_status=MagickFail;
         }
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_RaiseImage)
+#if defined(HAVE_OPENMP)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,image->rows))
-          if (!MagickMonitorFormatted(row_count,image->rows,&image->exception,
-                                      RaiseImageText,image->filename))
-            thread_status=MagickFail;
-          
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,image->rows))
+        if (!MagickMonitorFormatted(row_count,image->rows,&image->exception,
+                                    RaiseImageText,image->filename))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
 
   image->is_grayscale=is_grayscale;
index f041984..1d1b124 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   ImageMagick Decorate Methods.
 */
 #ifndef _MAGICK_DECORATE_H
index 3ea785c..9c4a60b 100644 (file)
@@ -595,8 +595,8 @@ WindowsShellTextEscape(char *dst, const char *src, const size_t size)
       register const char c = *q;
 #if 0
       /*
-       FIXME: Currently the correct implementation is not known so we
-       don't alter arguments at the moment.
+        FIXME: Currently the correct implementation is not known so we
+        don't alter arguments at the moment.
       */
       if ((c == '\\') ||
           (c == '"') ||
@@ -826,10 +826,10 @@ MagickExport unsigned int InvokeDelegate(ImageInfo *image_info,Image *image,
           int
             arg_count,
             j;
-          
+
           char
             **arg_array;
-          
+
           /*
             Convert command template into an argument array.  Translate
             each argument array element individually in order to
@@ -884,12 +884,12 @@ MagickExport unsigned int InvokeDelegate(ImageInfo *image_info,Image *image,
           */
           command=TranslateTextEx(image_info,image,commands[i],
 #if defined(POSIX)
-                                 UnixShellTextEscape
+                                  UnixShellTextEscape
 #endif /* POSIX */
 #if defined(MSWINDOWS)
-                                 WindowsShellTextEscape
+                                  WindowsShellTextEscape
 #endif /* MSWINDOWS */
-                                 );
+                                  );
           if (command == (char *) NULL)
             break;
           /*
@@ -957,7 +957,7 @@ MagickExport unsigned int InvokeDelegate(ImageInfo *image_info,Image *image,
 */
 MagickExport MagickPassFail
 InvokePostscriptDelegate(const unsigned int verbose,
-                        const char *command,ExceptionInfo *exception)
+                         const char *command,ExceptionInfo *exception)
 {
   register long
     i;
@@ -1002,68 +1002,68 @@ InvokePostscriptDelegate(const unsigned int verbose,
     {
 
       /*
-       Allocate an interpreter.
+        Allocate an interpreter.
       */
       interpreter = (gs_main_instance *) NULL;
       status=(gs_func->new_instance)(&interpreter,(void *) NULL);
       if (status < 0)
-       {
-         ThrowException(exception,DelegateError,
-                        FailedToAllocateGhostscriptInterpreter,command);
-         return(MagickFail);
-       }
+        {
+          ThrowException(exception,DelegateError,
+                         FailedToAllocateGhostscriptInterpreter,command);
+          return(MagickFail);
+        }
       /*
-       Initialize interpreter with argument list.
+        Initialize interpreter with argument list.
       */
       argv=StringToArgv(command,&argc);
       if (argv == (char **) NULL)
-       {
-         ThrowException(exception,DelegateError,FailedToAllocateArgumentList,
-                        command);
-         return(MagickFail);
-       }
+        {
+          ThrowException(exception,DelegateError,FailedToAllocateArgumentList,
+                         command);
+          return(MagickFail);
+        }
 
       if (verbose)
-       {
-         char
-           buffer[MaxTextExtent];
+        {
+          char
+            buffer[MaxTextExtent];
 
 #if defined(MSWINDOWS)
-         (void) NTGhostscriptDLL(buffer,sizeof(buffer));
+          (void) NTGhostscriptDLL(buffer,sizeof(buffer));
 #else
-         (void) strlcpy(buffer,"[ghostscript library]",sizeof(buffer));
+          (void) strlcpy(buffer,"[ghostscript library]",sizeof(buffer));
 #endif
-         (void) fputs(buffer,stderr);
-         for (i=2 ; i < argc ; i++)
-           (void) fprintf(stderr," \"%s\"",argv[i]);
-         (void) fflush(stderr);
-       }
+          (void) fputs(buffer,stderr);
+          for (i=2 ; i < argc ; i++)
+            (void) fprintf(stderr," \"%s\"",argv[i]);
+          (void) fflush(stderr);
+        }
       status=(gs_func->init_with_args)(interpreter,argc-1,argv+1);
       if (status == 0)
-       {
-         status=(gs_func->run_string)
-           (interpreter,"systemdict /start get exec\n",0,&pexit_code);
-         if ((status == 0) || (status <= -100))
-           {
-             char
-               reason[MaxTextExtent];
-
-             FormatString(reason,"Ghostscript returns status %d, exit code %d",
-                          status,pexit_code);
-             (void) LogMagickEvent(CoderEvent,GetMagickModule(),"%s",reason);
-             ThrowException(exception,DelegateError,PostscriptDelegateFailed,command);
-           }
-       }
+        {
+          status=(gs_func->run_string)
+            (interpreter,"systemdict /start get exec\n",0,&pexit_code);
+          if ((status == 0) || (status <= -100))
+            {
+              char
+                reason[MaxTextExtent];
+
+              FormatString(reason,"Ghostscript returns status %d, exit code %d",
+                           status,pexit_code);
+              (void) LogMagickEvent(CoderEvent,GetMagickModule(),"%s",reason);
+              ThrowException(exception,DelegateError,PostscriptDelegateFailed,command);
+            }
+        }
       /*
-       Exit interpreter.
+        Exit interpreter.
       */
       (gs_func->exit)(interpreter);
       /*
-       Deallocate interpreter.
+        Deallocate interpreter.
       */
       (gs_func->delete_instance)(interpreter);
       for (i=0; i < argc; i++)
-       MagickFreeMemory(argv[i]);
+        MagickFreeMemory(argv[i]);
       MagickFreeMemory(argv);
       if ((status == 0) || (status <= -100))
         {
@@ -1085,9 +1085,9 @@ InvokePostscriptDelegate(const unsigned int verbose,
     argv = StringToArgv(command,&argc);
     if (argv == (char **) NULL)
       {
-       ThrowException(exception,DelegateError,
-                      FailedToAllocateArgumentList,
-                      command);
+        ThrowException(exception,DelegateError,
+                       FailedToAllocateArgumentList,
+                       command);
       }
     else
       {
@@ -1109,9 +1109,9 @@ InvokePostscriptDelegate(const unsigned int verbose,
             if (MagickSpawnVP(verbose,argv[1],argv+1) == 0)
               status=MagickPass;
           }
-       for (i=0; i < argc; i++)
-         MagickFreeMemory(argv[i]);
-       MagickFreeMemory(argv);
+        for (i=0; i < argc; i++)
+          MagickFreeMemory(argv[i]);
+        MagickFreeMemory(argv);
       }
   }
 
@@ -1187,7 +1187,7 @@ MagickExport unsigned int ListDelegateInfo(FILE *file,ExceptionInfo *exception)
     if (commands == (char **) NULL)
       continue;
     {
-         size_t
+          size_t
         command_length,
          length=0;
 
@@ -1196,7 +1196,7 @@ MagickExport unsigned int ListDelegateInfo(FILE *file,ExceptionInfo *exception)
         formatted_chars=0,
         screen_width=79,
         strip_length;
-      
+
       char
         *s;
 
@@ -1270,8 +1270,8 @@ MagickExport unsigned int ListDelegateInfo(FILE *file,ExceptionInfo *exception)
 */
 #if defined(MSWINDOWS)
 static void CatDelegatePath(char *path,
-                           const char *binpath,
-                           const char *command)
+                            const char *binpath,
+                            const char *command)
 {
   strcpy(path,binpath);
   strcat(path,command);
@@ -1421,7 +1421,7 @@ static unsigned int ReadConfigureFile(const char *basename,
                       char
                         *key,
                         *key_value;
-                    
+
                       /* Obtain installation path from registry */
                       key="BinPath";
                       key_value=NTRegistryKeyLookup(key);
index de5f9c9..1c36260 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Methods to Read/Write/Invoke Delegates.
 */
 #ifndef _MAGICK_DELEGATE_H
@@ -60,7 +60,7 @@ extern MagickExport DelegateInfo
 
 extern MagickExport MagickPassFail
   InvokePostscriptDelegate(const unsigned int verbose,const char *command,
-                          ExceptionInfo *exception),
+                           ExceptionInfo *exception),
   InvokeDelegate(ImageInfo *image_info,Image *image,const char *decode,
                  const char *encode,ExceptionInfo *exception),
   ListDelegateInfo(FILE *file,ExceptionInfo *exception);
index d4f48ff..a715f67 100644 (file)
 #undef LoadImagesText
 #undef SaveImagesText
 
+#if defined(PREFIX_MAGICK_SYMBOLS)
+
+#define LoadImageText GmLoadImageText
+#define LoadImagesText GmLoadImagesText
+#define SaveImageText GmSaveImageText
+#define SaveImagesText GmSaveImagesText
+
+#endif /* defined(PREFIX_MAGICK_SYMBOLS) */
+
 extern MagickExport const char
   *LoadImageText,
   *LoadImagesText,
@@ -283,7 +292,7 @@ MagickExport unsigned int PopImagePixels(const Image *image,
 {
   unsigned int
     quantum_size;
-  
+
   quantum_size=image->depth;
 
   if (quantum_size <= 8)
@@ -306,7 +315,7 @@ MagickExport unsigned int PopImagePixels(const Image *image,
   if (image->logging)
     (void) LogMagickEvent(DeprecateEvent,GetMagickModule(),
                           "Method has been deprecated");
-  
+
   return ExportImagePixelArea(image,quantum_type,quantum_size,destination,0,0);
 }
 \f
index 136e950..ccba4ab 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003, 2008 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Log methods.
 */
 #ifndef _MAGICK_DEPRECATE_H
index 81c7843..3061f28 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2012 GraphicsMagick Group
+% Copyright (C) 2003 - 2017 GraphicsMagick Group
 % Copyright (C) 2003 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -182,7 +182,7 @@ MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
           (void) fprintf(file," (%s pixels/s)",format);
         }
       (void) fprintf(file,"\n");
-    
+
       return (ferror(file) ? MagickFail : MagickPass);
     }
   /*
@@ -434,10 +434,14 @@ MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
       char
         tuple[MaxTextExtent];
 
+      MagickBool
+        found_transparency;
+
       register const PixelPacket
         *p;
 
       p=(PixelPacket *) NULL;
+      found_transparency = MagickFalse;
       for (y=0; y < image->rows; y++)
         {
           p=AcquireImagePixels(image,0,y,image->columns,1,&image->exception);
@@ -446,13 +450,16 @@ MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
           for (x=0; x < image->columns; x++)
             {
               if (p->opacity == TransparentOpacity)
-                break;
+                {
+                  found_transparency=MagickTrue;
+                  break;
+                }
               p++;
             }
           if (x < image->columns)
             break;
         }
-      if ((x < image->columns) || (y < image->rows))
+      if (found_transparency)
         {
           GetColorTuple(p,image->depth,image->matte,False,tuple);
           (void) fprintf(file,"  Opacity: %.1024s\t",tuple);
@@ -576,8 +583,8 @@ MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
   FormatSize(GetBlobSize(image),format);
   (void) fprintf(file,"  Filesize: %.1024s\n",format);
   fprintf(file,"  Interlace: %s\n",
-         InterlaceTypeToString(image->interlace == UndefinedInterlace ?
-                               NoInterlace : image->interlace));
+          InterlaceTypeToString(image->interlace == UndefinedInterlace ?
+                                NoInterlace : image->interlace));
   (void) fprintf(file,"  Orientation: %s\n",
                  OrientationTypeToString(image->orientation));
   (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
@@ -593,7 +600,7 @@ MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
     (void) fprintf(file,"  Page geometry: %lux%lu%+ld%+ld\n",image->page.width,
                    image->page.height,image->page.x,image->page.y);
   (void) fprintf(file,"  Compose: %s\n",
-                CompositeOperatorToString(image->compose));
+                 CompositeOperatorToString(image->compose));
   (void) fprintf(file,"  Dispose: ");
   switch (image->dispose)
     {
@@ -618,7 +625,7 @@ MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
     if (image->scene != 0)
       (void) fprintf(file,"  Scene: %lu\n",image->scene);
   (void) fprintf(file,"  Compression: %s\n",
-                CompressionTypeToString(image->compression));
+                 CompressionTypeToString(image->compression));
   /*
     Display formatted image attributes. This must happen before we access
     any pseudo attributes like EXIF since doing so causes real attributes
@@ -629,15 +636,15 @@ MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
     for ( ; attribute != (const ImageAttribute *) NULL;
           attribute=attribute->next)
       {
-       if (LocaleNCompare("EXIF",attribute->key,4) != 0)
-         {
-           (void) fprintf(file,"  %c", toupper((int)attribute->key[0]));
-           if (strlen(attribute->key) > 1)
-             (void) fprintf(file,"%.1024s",attribute->key+1);
-           
-           (void) fprintf(file,": ");
-           (void) fprintf(file,"%s\n",attribute->value);
-         }
+        if (LocaleNCompare("EXIF",attribute->key,4) != 0)
+          {
+            (void) fprintf(file,"  %c", toupper((int)attribute->key[0]));
+            if (strlen(attribute->key) > 1)
+              (void) fprintf(file,"%.1024s",attribute->key+1);
+
+            (void) fprintf(file,": ");
+            (void) fprintf(file,"%s\n",attribute->value);
+          }
       }
   }
   if((profile=GetImageProfile(image,"ICM",&profile_length)) != 0)
@@ -657,7 +664,7 @@ MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
       */
       (void) fprintf(file,"  Profile-iptc: %lu bytes\n",(unsigned long)
                      profile_length);
-      for (i=0; i < profile_length; )
+      for (i=0; i+5U < profile_length; )
         {
           if (profile[i] != 0x1c)
             {
@@ -685,7 +692,7 @@ MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
             case 60: tag=(char *) "Created Time"; break;
             case 65: tag=(char *) "Originating Program"; break;
             case 70: tag=(char *) "Program Version"; break;
-            case 75: tag=(char *) "Object Cycle"; break;
+            case 75: tag=(char *) "Object Cyc"; break;
             case 80: tag=(char *) "Byline"; break;
             case 85: tag=(char *) "Byline Title"; break;
             case 90: tag=(char *) "City"; break;
@@ -726,6 +733,7 @@ MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
           (void) fprintf(file,"    %.1024s:\n",tag);
           length=profile[i++] << 8;
           length|=profile[i++];
+          length=Min(length,profile_length-i);
           text=MagickAllocateMemory(char *,length+1);
           if (text != (char *) NULL)
             {
@@ -755,13 +763,13 @@ MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
   {
     const char
       *profile_name;
-    
+
     size_t
       profile_length;
-              
+
     const unsigned char *
       profile_info;
-    
+
     ImageProfileIterator
       profile_iterator;
 
@@ -787,10 +795,10 @@ MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
               {
                 char
                   **values;
-                
+
                 register char
                   *p;
-                
+
                 values=StringToList(attribute->value);
                 if (values != (char **) NULL)
                   {
@@ -850,7 +858,8 @@ MagickExport MagickPassFail DescribeImage(Image *image,FILE *file,
       for (p=image->directory; *p != '\0'; p++)
         {
           q=p;
-          while ((*q != '\n') && (*q != '\0'))
+          while ((*q != '\n') && (*q != '\0') &&
+                 ((size_t) (q-p) < sizeof(image_info->filename)))
             q++;
           (void) strncpy(image_info->filename,p,q-p);
           image_info->filename[q-p]='\0';
index fb45a67..fa129d7 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 - 2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Describe Methods.
 */
 #ifndef _MAGICK_DESCRIBE_H
index f41525f..f7375d5 100644 (file)
@@ -806,6 +806,7 @@ static unsigned int MagickXAnnotateEditImage(Display *display,
             p++;
             if ((x+font_info->max_bounds.width) < (int) windows->image.width)
               break;
+            break; /* Not completely sure about this break (used to fall through) */
           }
           case XK_Return:
           case XK_KP_Enter:
@@ -3413,6 +3414,7 @@ static unsigned int MagickXCropImage(Display *display,MagickXResourceInfo *resou
               state|=UpdateConfigurationState;
               break;
             }
+          break;
         }
         case ButtonRelease:
         {
@@ -5418,12 +5420,12 @@ static Image *MagickXMagickCommand(Display *display,MagickXResourceInfo *resourc
       status=MagickXSaveImage(display,resource_info,windows,*image);
       if (status == MagickFail)
         {
-         char reason[MaxTextExtent];
+          char reason[MaxTextExtent];
 
-         FormatString(reason,"%s \"%s\"",
-                      (*image)->exception.reason ? (*image)->exception.reason : "",
-                      (*image)->exception.description ? (*image)->exception.description : "");
-         MagickXNoticeWidget(display,windows,"Unable to save file:",reason);
+          FormatString(reason,"%s \"%s\"",
+                       (*image)->exception.reason ? (*image)->exception.reason : "",
+                       (*image)->exception.description ? (*image)->exception.description : "");
+          MagickXNoticeWidget(display,windows,"Unable to save file:",reason);
           break;
         }
       break;
@@ -5436,11 +5438,11 @@ static Image *MagickXMagickCommand(Display *display,MagickXResourceInfo *resourc
       status=MagickXPrintImage(display,resource_info,windows,*image);
       if (status == False)
         {
-         char reason[MaxTextExtent];
+          char reason[MaxTextExtent];
 
-         FormatString(reason,"%s \"%s\"",
-                      (*image)->exception.reason ? (*image)->exception.reason : "",
-                      (*image)->exception.description ? (*image)->exception.description : "");
+          FormatString(reason,"%s \"%s\"",
+                       (*image)->exception.reason ? (*image)->exception.reason : "",
+                       (*image)->exception.description ? (*image)->exception.description : "");
           MagickXNoticeWidget(display,windows,"Unable to print image:",reason);
           break;
         }
@@ -6398,7 +6400,7 @@ static Image *MagickXMagickCommand(Display *display,MagickXResourceInfo *resourc
       double
         azimuth,
         elevation;
-      
+
       /*
         Query user for the shade geometry.
       */
@@ -9612,6 +9614,7 @@ static unsigned int MagickXROIImage(Display *display,MagickXResourceInfo *resour
               state|=UpdateConfigurationState;
               break;
             }
+          break;
         }
         case ButtonRelease:
         {
@@ -10968,8 +10971,8 @@ static Image *MagickXTileImage(Display *display,MagickXResourceInfo *resource_in
         {
           MagickXNoticeWidget(display,windows,"Unable to delete image file:",
             filename);
-          break;
         }
+      break;
     }
     case TileUpdateCommand:
     {
@@ -11827,7 +11830,7 @@ MagickExport unsigned int MagickXDisplayBackgroundImage(Display *display,
 
 MagickExport Image *
 MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info,
-                   char *argv[],int argc,Image **image,unsigned long *state)
+                    char *argv[],int argc,Image **image,unsigned long *state)
 {
 
   static const char
@@ -12485,19 +12488,19 @@ MagickXDisplayImage(Display *display,MagickXResourceInfo *resource_info,
       (void ) CloneString(&windows->image.icon_name,"");
       GetPathComponent(display_image->filename,TailPath,filename);
       FormatString(windows->image.name,"%s: %.1024s[%lu]",MagickPackageName,
-                  filename,display_image->scene);
+                   filename,display_image->scene);
       q=display_image;
       while (q->previous != (Image *) NULL)
         q=q->previous;
       for (count=1; q->next != (Image *) NULL; count++)
         q=q->next;
       FormatString(windows->image.name,"%s: %.1024s[%lu of %lu]",
-                  MagickPackageName,filename,display_image->scene+1U,count);
+                   MagickPackageName,filename,display_image->scene+1U,count);
       if ((display_image->previous == (Image *) NULL) &&
           (display_image->next == (Image *) NULL) &&
           (display_image->scene == 0))
         FormatString(windows->image.name,"%s: %.1024s",MagickPackageName,
-                    filename);
+                     filename);
       (void) strlcpy(windows->image.icon_name,filename,MaxTextExtent);
     }
   if (resource_info->immutable)
index 8c897fc..df910e9 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Methods to Interactively Display and Edit an Image.
 */
 #ifndef _MAGICK_DISPLAY_H
index 8496865..6928dd5 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -430,36 +430,36 @@ static int MvgPrintf(DrawContext context, const char *format, ...)
     */
     {
       ssize_t
-       space_available;
-      
+        space_available;
+
       space_available=(ssize_t) context->mvg_alloc - (ssize_t) context->mvg_length - 1;
       formatted_length = -1;
       if (space_available > 0)
-       {
-         va_start(argp, format);
+        {
+          va_start(argp, format);
 #if defined(HAVE_VSNPRINTF)
-         formatted_length =
-           vsnprintf(context->mvg + context->mvg_length,(size_t) space_available, format, argp);
+          formatted_length =
+            vsnprintf(context->mvg + context->mvg_length,(size_t) space_available, format, argp);
 #else
 #  if defined(HAVE_VSPRINTF)
-         formatted_length = vsprintf(context->mvg + context->mvg_length, format, argp);
+          formatted_length = vsprintf(context->mvg + context->mvg_length, format, argp);
 #  else
 #    error Neither vsnprintf or vsprintf is available.
 #  endif
 #endif
-         va_end(argp);
-       }
-      
+          va_end(argp);
+        }
+
       if ((formatted_length < 0) || (formatted_length > space_available))
-       {
-         ThrowException(&context->image->exception,DrawError,UnableToPrint,
-                        format);
-       }
+        {
+          ThrowException(&context->image->exception,DrawError,UnableToPrint,
+                         format);
+        }
       else
-       {
-         context->mvg_length += formatted_length;
-         context->mvg_width += formatted_length;
-       }
+        {
+          context->mvg_length += formatted_length;
+          context->mvg_width += formatted_length;
+        }
     }
     context->mvg[context->mvg_length] = 0;
 
@@ -904,11 +904,13 @@ MagickExport void DrawCircle(DrawContext context, const double ox,
 */
 MagickExport char *DrawGetClipPath(DrawContext context)
 {
+  char * pClipPath;
   assert(context != (DrawContext)NULL);
   assert(context->signature == MagickSignature);
 
-  if (CurrentContext->clip_path != (char *) NULL)
-    return (char *)AllocateString(CurrentContext->clip_path);
+  pClipPath = *DrawInfoGetClipPath(CurrentContext);
+  if (pClipPath != (char *) NULL)
+    return (char *)AllocateString(pClipPath);
   else
     return (char *) NULL;
 }
@@ -941,20 +943,22 @@ MagickExport char *DrawGetClipPath(DrawContext context)
 */
 MagickExport void DrawSetClipPath(DrawContext context, const char *clip_path)
 {
+  char ** ppClipPath,*pClipPath;
   assert(context != (DrawContext)NULL);
   assert(context->signature == MagickSignature);
   assert(clip_path != (const char *) NULL);
 
-  if( CurrentContext->clip_path == NULL || context->filter_off ||
-      LocaleCompare(CurrentContext->clip_path,clip_path) != 0)
+  pClipPath = *(ppClipPath = DrawInfoGetClipPath(CurrentContext));
+  if( pClipPath == NULL || context->filter_off ||
+      LocaleCompare(pClipPath,clip_path) != 0)
     {
-      (void) CloneString(&CurrentContext->clip_path,clip_path);
-      if(CurrentContext->clip_path == (char*)NULL)
+      (void) CloneString(ppClipPath,clip_path);
+      if(*ppClipPath == (char*)NULL)
         ThrowDrawException3(ResourceLimitError,MemoryAllocationFailed,
           UnableToDrawOnImage);
 
 #if DRAW_BINARY_IMPLEMENTATION
-      (void) DrawClipPath(context->image,CurrentContext,CurrentContext->clip_path);
+      (void) DrawClipPath(context->image,CurrentContext,pClipPath);
 #endif
 
       (void) MvgPrintf(context, "clip-path url(#%s)\n", clip_path);
@@ -2380,7 +2384,7 @@ MagickExport void DrawComposite(DrawContext context,
   assert(width != 0);
   assert(height != 0);
   assert(*image->magick != '\0');
-  
+
 /*   LogMagickEvent(CoderEvent,GetMagickModule(),"DrawComposite columns=%ld rows=%ld magick=%s ", */
 /*                  image->columns, image->rows, image->magick ); */
 
@@ -2602,7 +2606,7 @@ MagickExport void DrawPathClose(DrawContext context)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  DrawPathCurveToAbsolute() draws a cubic Bézier curve from the current
+%  DrawPathCurveToAbsolute() draws a cubic Bezier curve from the current
 %  point to (x,y) using (x1,y1) as the control point at the beginning of
 %  the curve and (x2,y2) as the control point at the end of the curve using
 %  absolute coordinates. At the end of the command, the new current point
@@ -2676,7 +2680,7 @@ MagickExport void DrawPathCurveToAbsolute(DrawContext context,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  DrawPathCurveToRelative() draws a cubic Bézier curve from the current
+%  DrawPathCurveToRelative() draws a cubic Bezier curve from the current
 %  point to (x,y) using (x1,y1) as the control point at the beginning of
 %  the curve and (x2,y2) as the control point at the end of the curve using
 %  relative coordinates. At the end of the command, the new current point
@@ -2728,7 +2732,7 @@ MagickExport void DrawPathCurveToRelative(DrawContext context,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  DrawPathCurveToQuadraticBezierAbsolute() draws a quadratic Bézier curve
+%  DrawPathCurveToQuadraticBezierAbsolute() draws a quadratic Bezier curve
 %  from the current point to (x,y) using (x1,y1) as the control point using
 %  absolute coordinates. At the end of the command, the new current point
 %  becomes the final (x,y) coordinate pair used in the polybezier.
@@ -2796,7 +2800,7 @@ MagickExport void DrawPathCurveToQuadraticBezierAbsolute(DrawContext context,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  DrawPathCurveToQuadraticBezierRelative() draws a quadratic Bézier curve
+%  DrawPathCurveToQuadraticBezierRelative() draws a quadratic Bezier curve
 %  from the current point to (x,y) using (x1,y1) as the control point using
 %  relative coordinates. At the end of the command, the new current point
 %  becomes the final (x,y) coordinate pair used in the polybezier.
@@ -2846,7 +2850,7 @@ MagickExport void DrawPathCurveToQuadraticBezierRelative(DrawContext context,
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  DrawPathCurveToQuadraticBezierSmoothAbsolute() draws a quadratic
-%  Bézier curve (using absolute coordinates) from the current point to
+%  Bezier curve (using absolute coordinates) from the current point to
 %  (x,y). The control point is assumed to be the reflection of the
 %  control point on the previous command relative to the current
 %  point. (If there is no previous command or if the previous command was
@@ -2915,7 +2919,7 @@ MagickExport void DrawPathCurveToQuadraticBezierSmoothAbsolute(DrawContext
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  DrawPathCurveToQuadraticBezierSmoothAbsolute() draws a quadratic
-%  Bézier curve (using relative coordinates) from the current point to
+%  Bezier curve (using relative coordinates) from the current point to
 %  (x,y). The control point is assumed to be the reflection of the
 %  control point on the previous command relative to the current
 %  point. (If there is no previous command or if the previous command was
@@ -2963,7 +2967,7 @@ MagickExport void DrawPathCurveToQuadraticBezierSmoothRelative(DrawContext
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  DrawPathCurveToSmoothAbsolute() draws a cubic Bézier curve from the
+%  DrawPathCurveToSmoothAbsolute() draws a cubic Bezier curve from the
 %  current point to (x,y) using absolute coordinates. The first control
 %  point is assumed to be the reflection of the second control point on
 %  the previous command relative to the current point. (If there is no
@@ -3034,7 +3038,7 @@ MagickExport void DrawPathCurveToSmoothAbsolute(DrawContext context,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  DrawPathCurveToSmoothRelative() draws a cubic Bézier curve from the
+%  DrawPathCurveToSmoothRelative() draws a cubic Bezier curve from the
 %  current point to (x,y) using relative coordinates. The first control
 %  point is assumed to be the reflection of the second control point on
 %  the previous command relative to the current point. (If there is no
@@ -3902,9 +3906,10 @@ MagickExport void DrawPopGraphicContext(DrawContext context)
     {
       /* Destroy clip path if not same in preceding context */
 #if DRAW_BINARY_IMPLEMENTATION
-      if (CurrentContext->clip_path != (char *) NULL)
-        if (LocaleCompare(CurrentContext->clip_path,
-                          context->graphic_context[context->index-1]->clip_path) != 0)
+      char * pClipPathCurrent = *DrawInfoGetClipPath(CurrentContext);
+      char * pClipPathPrevious = *DrawInfoGetClipPath(context->graphic_context[context->index-1]);
+      if (pClipPathCurrent != (char *) NULL)
+        if (LocaleCompare(pClipPathCurrent,pClipPathPrevious) != 0)
           (void) SetImageClipMask(context->image,(Image *) NULL);
 #endif
 
@@ -4810,12 +4815,15 @@ MagickExport double *DrawGetStrokeDashArray(DrawContext context,
   if (n != 0)
     {
       dasharray = MagickAllocateArray(double *, n+1, sizeof(double));
-      p = CurrentContext->dash_pattern;
-      q = dasharray;
-      i = n;
-      while( i-- )
-        *q++ = *p++;
-      *q=0.0;
+      if (dasharray != (double*)NULL)
+        {
+          p = CurrentContext->dash_pattern;
+          q = dasharray;
+          i = n;
+          while( i-- )
+            *q++ = *p++;
+          *q=0.0;
+        }
     }
   return dasharray;
 }
@@ -5527,7 +5535,7 @@ MagickExport DecorationType DrawGetTextDecoration(DrawContext context)
 {
   assert(context != (DrawContext)NULL);
   assert(context->signature == MagickSignature);
-  
+
   return CurrentContext->decorate;
 }
 \f
index 76bfdc6..ca0bc99 100644 (file)
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2003 GraphicsMagick Group
+  Copyright (C) 2003-2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   ImageMagick Drawing API.
 
   Usage synopsis:
@@ -34,40 +34,40 @@ extern "C" {
 typedef struct _DrawContext *DrawContext;
 
 extern MagickExport ClipPathUnits
-  DrawGetClipUnits(DrawContext context);
+  DrawGetClipUnits(DrawContext context) MAGICK_FUNC_PURE;
 
 extern MagickExport DrawInfo
   *DrawPeekGraphicContext(const DrawContext context);
 
 extern MagickExport DecorationType
-  DrawGetTextDecoration(DrawContext context);
+  DrawGetTextDecoration(DrawContext context) MAGICK_FUNC_PURE;
 
 extern MagickExport DrawContext
   DrawAllocateContext(const DrawInfo *draw_info, Image *image);
 
 extern MagickExport FillRule
-  DrawGetClipRule(DrawContext context),
-  DrawGetFillRule(DrawContext context);
+  DrawGetClipRule(DrawContext context) MAGICK_FUNC_PURE,
+  DrawGetFillRule(DrawContext context) MAGICK_FUNC_PURE;
 
 extern MagickExport GravityType
-  DrawGetGravity(DrawContext context);
+  DrawGetGravity(DrawContext context) MAGICK_FUNC_PURE;
 
 extern MagickExport LineCap
-  DrawGetStrokeLineCap(DrawContext context);
+  DrawGetStrokeLineCap(DrawContext context) MAGICK_FUNC_PURE;
 
 extern MagickExport LineJoin
-  DrawGetStrokeLineJoin(DrawContext context);
+  DrawGetStrokeLineJoin(DrawContext context) MAGICK_FUNC_PURE;
 
 extern MagickExport PixelPacket
-  DrawGetFillColor(DrawContext context),
-  DrawGetStrokeColor(DrawContext context),
-  DrawGetTextUnderColor(DrawContext context);
+  DrawGetFillColor(DrawContext context) MAGICK_FUNC_PURE,
+  DrawGetStrokeColor(DrawContext context) MAGICK_FUNC_PURE,
+  DrawGetTextUnderColor(DrawContext context) MAGICK_FUNC_PURE;
 
 extern MagickExport StretchType
-  DrawGetFontStretch(DrawContext context);
+  DrawGetFontStretch(DrawContext context) MAGICK_FUNC_PURE;
 
 extern MagickExport StyleType
-  DrawGetFontStyle(DrawContext context);
+  DrawGetFontStyle(DrawContext context) MAGICK_FUNC_PURE;
 
 extern MagickExport char
   *DrawGetClipPath(DrawContext context),
@@ -79,20 +79,20 @@ extern MagickExport int
   DrawRender(const DrawContext context);
 
 extern MagickExport unsigned int
-  DrawGetStrokeAntialias(DrawContext context),
-  DrawGetTextAntialias(DrawContext context);
+  DrawGetStrokeAntialias(DrawContext context) MAGICK_FUNC_PURE,
+  DrawGetTextAntialias(DrawContext context) MAGICK_FUNC_PURE;
 
 extern MagickExport unsigned long
-  DrawGetFontWeight(DrawContext context),
-  DrawGetStrokeMiterLimit(DrawContext context);
+  DrawGetFontWeight(DrawContext context) MAGICK_FUNC_PURE,
+  DrawGetStrokeMiterLimit(DrawContext context) MAGICK_FUNC_PURE;
 
 extern MagickExport double
-  DrawGetFillOpacity(DrawContext context),
-  DrawGetFontSize(DrawContext context),
+  DrawGetFillOpacity(DrawContext context) MAGICK_FUNC_PURE,
+  DrawGetFontSize(DrawContext context) MAGICK_FUNC_PURE,
   *DrawGetStrokeDashArray(DrawContext context, unsigned long *num_elems),
-  DrawGetStrokeDashOffset(DrawContext context),
-  DrawGetStrokeOpacity(DrawContext context),
-  DrawGetStrokeWidth(DrawContext context);
+  DrawGetStrokeDashOffset(DrawContext context) MAGICK_FUNC_PURE,
+  DrawGetStrokeOpacity(DrawContext context) MAGICK_FUNC_PURE,
+  DrawGetStrokeWidth(DrawContext context) MAGICK_FUNC_PURE;
 
 extern MagickExport void
   DrawAffine(DrawContext context, const AffineMatrix *affine),
index 382a38f..a0acce2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
 #define PRE(X,Y) ((Y + height + 2) % (height + 2)) * (image->columns + (width << 1)) + X
 
 MagickExport Image *AdaptiveThresholdImage(const Image * image,
-                                          const unsigned long width,
-                                          const unsigned long height,
-                                          const double offset,
-                                          ExceptionInfo * exception)
+                                           const unsigned long width,
+                                           const unsigned long height,
+                                           const double offset,
+                                           ExceptionInfo * exception)
 {
   const PixelPacket * restrict
     p = (const PixelPacket *) NULL;
@@ -164,7 +164,7 @@ MagickExport Image *AdaptiveThresholdImage(const Image * image,
 
   if ((image->columns < width) || (image->rows < height))
     ThrowImageException3(OptionError, UnableToThresholdImage,
-                        ImageSmallerThanRadius);
+                         ImageSmallerThanRadius);
 
   threshold_image = CloneImage(image, 0, 0, MagickTrue, exception);
   if (threshold_image == (Image *) NULL)
@@ -328,7 +328,7 @@ MagickExport Image *AdaptiveThresholdImage(const Image * image,
               LongPixelPacket
                 long_sum;
 
-              L = x - width/2 - (width & 1);   /* if is odd, subtract 1... */
+              L = x - width/2 - (width & 1);    /* if is odd, subtract 1... */
               R = x + width/2;
               U = y - height - 1;
               B = y - 1;
@@ -531,7 +531,7 @@ AddNoiseImageChannel(const Image *image,const ChannelType channel,
 {
   QuantumOperator
     quantum_operator;
-  
+
   Image
     *noise_image;
 
@@ -639,8 +639,8 @@ MagickExport MagickPassFail BlackThresholdImage(Image *image,const char *thresho
 #define BlurImageColumnsText "[%s] Blur columns: order %lu..."
 #define BlurImageRowsText "[%s] Blur rows: order %lu...  "
 static void
-BlurScanline(const double *kernel,const unsigned long width,
-             const PixelPacket *source,PixelPacket *destination,
+BlurScanline(const double * restrict kernel,const unsigned long width,
+             const PixelPacket * restrict source,PixelPacket * restrict destination,
              const unsigned long columns, const MagickBool matte)
 {
   double
@@ -844,7 +844,7 @@ static MagickPassFail BlurImageScanlines(Image *image,const double *kernel,
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for schedule(static,4) shared(row_count, status)
+#    pragma omp parallel for schedule(guided) shared(row_count, status)
 #  endif
 #endif
       for (y=0; y < (long) image->rows; y++)
@@ -858,13 +858,10 @@ static MagickPassFail BlurImageScanlines(Image *image,const double *kernel,
           MagickBool
             thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_BlurImageScanlines)
-#endif
           thread_status=status;
           if (thread_status == MagickFail)
             continue;
-  
+
           scanline=AccessThreadViewData(data_set);
           q=GetImagePixelsEx(image,0,y,image->columns,1,exception);
           if (q == (PixelPacket *) NULL)
@@ -879,32 +876,35 @@ static MagickPassFail BlurImageScanlines(Image *image,const double *kernel,
               i++;
               for ( ; i < image->columns; i++)
                 {
-                 if (NotPixelMatch(&scanline[i-1],&q[i],matte))
+                  if (NotPixelMatch(&scanline[i-1],&q[i],matte))
                     break;
                   scanline[i]=q[i];
                 }
               if (i != image->columns)
                 {
                   (void) memcpy(&scanline[i],&q[i],
-                               (image->columns-i)*sizeof(PixelPacket));
+                                (image->columns-i)*sizeof(PixelPacket));
                   BlurScanline(kernel,width,scanline,q,image->columns,matte);
                   if (!SyncImagePixelsEx(image,exception))
                     thread_status=MagickFail;
                 }
             }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_BlurImageScanlines)
+#  pragma omp atomic
 #endif
-          {
-            row_count++;
-            if (QuantumTick(row_count,image->rows))
-              if (!MagickMonitorFormatted(row_count,image->rows,exception,
-                                          format,image->filename,width))
-                thread_status=MagickFail;
-          
-            if (thread_status == MagickFail)
+          row_count++;
+          if (QuantumTick(row_count,image->rows))
+            if (!MagickMonitorFormatted(row_count,image->rows,exception,
+                                        format,image->filename,width))
+              thread_status=MagickFail;
+
+          if (thread_status == MagickFail)
+            {
               status=MagickFail;
-          }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+            }
         }
     }
 
@@ -979,8 +979,8 @@ BlurImage(const Image *original_image,const double radius,
 
   if (status != MagickFail)
     status&=BlurImageScanlines(blur_image,kernel,width,BlurImageColumnsText,
-                              exception);
-  
+                               exception);
+
   if (status != MagickFail)
   {
     Image
@@ -999,7 +999,7 @@ BlurImage(const Image *original_image,const double radius,
 
   if (status != MagickFail)
     status&=BlurImageScanlines(blur_image,kernel,width,BlurImageRowsText,
-                              exception);
+                               exception);
 
   MagickFreeMemory(kernel);
 
@@ -1103,9 +1103,9 @@ typedef struct _ChannelThresholdOptions_t
 static MagickPassFail
 ChannelThresholdPixels(void *mutable_data,         /* User provided mutable data */
                        const void *immutable_data, /* User provided immutable data */
-                       Image *image,               /* Modify image */
-                       PixelPacket *pixels,        /* Pixel row */
-                       IndexPacket *indexes,       /* Pixel row indexes */
+                       Image * restrict image,               /* Modify image */
+                       PixelPacket * restrict pixels,        /* Pixel row */
+                       IndexPacket * restrict indexes,       /* Pixel row indexes */
                        const long npixels,         /* Number of pixels in row */
                        ExceptionInfo *exception)   /* Exception report */
 {
@@ -1126,7 +1126,7 @@ ChannelThresholdPixels(void *mutable_data,         /* User provided mutable data
     green_enabled=options->green_enabled,
     blue_enabled=options->blue_enabled,
     opacity_enabled=options->opacity_enabled;
-  
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(image);
   ARG_NOT_USED(indexes);
@@ -1170,7 +1170,7 @@ MagickExport MagickPassFail ChannelThresholdImage(Image *image,
   */
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
-  
+
   if (threshold == (const char *) NULL)
     return(MagickFail);
 
@@ -1193,7 +1193,7 @@ MagickExport MagickPassFail ChannelThresholdImage(Image *image,
                &double_threshold.green,
                &double_threshold.blue,
                &double_threshold.opacity);
-  
+
   if ((count > 3) && (double_threshold.opacity >= 0.0))
     options.opacity_enabled = MagickTrue;
   if ((count > 2) && (double_threshold.blue >= 0.0))
@@ -1202,7 +1202,7 @@ MagickExport MagickPassFail ChannelThresholdImage(Image *image,
     options.green_enabled = MagickTrue;
   if ((count > 0) && (double_threshold.red >= 0.0))
     options.red_enabled = MagickTrue;
-  
+
   if (strchr(threshold,'%') != (char *) NULL)
     {
       if (options.red_enabled)
@@ -1272,8 +1272,8 @@ MagickExport MagickPassFail ChannelThresholdImage(Image *image,
 %
 */
 #define ConvolveImageText "[%s] Convolve: order %u..."
-MagickExport Image *ConvolveImage(const Image *image,const unsigned int order,
-                                  const double *kernel,ExceptionInfo *exception)
+MagickExport Image *ConvolveImage(const Image * restrict image,const unsigned int order,
+                                  const double * restrict kernel,ExceptionInfo *exception)
 {
 #if QuantumDepth < 32
   typedef float float_quantum_t;
@@ -1337,7 +1337,7 @@ MagickExport Image *ConvolveImage(const Image *image,const unsigned int order,
     */
     double
       normalize;
-    
+
     register long
       i;
 
@@ -1361,7 +1361,7 @@ MagickExport Image *ConvolveImage(const Image *image,const unsigned int order,
         normal_kernel[i]=normalize*kernel[i];
       }
   }
-  
+
   if (LogMagickEvent(TransformEvent,GetMagickModule(),
                      "  ConvolveImage with %ldx%ld kernel:",width,width))
     {
@@ -1429,7 +1429,7 @@ MagickExport Image *ConvolveImage(const Image *image,const unsigned int order,
       {
         const PixelPacket
           * restrict p;
-    
+
         PixelPacket
           * restrict q;
 
@@ -1439,21 +1439,18 @@ MagickExport Image *ConvolveImage(const Image *image,const unsigned int order,
         MagickBool
           thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_ConvolveImage)
-#endif
         thread_status=status;
         if (thread_status == MagickFail)
           continue;
 
-       /*
-         Acquire rectangle of columns+width high, and width tall.
-       */
+        /*
+          Acquire rectangle of columns+width high, and width tall.
+        */
         p=AcquireImagePixels(image,-width/2,y-width/2,image->columns+width,width,
                              exception);
-       /*
-         Set one row.
-       */
+        /*
+          Set one row.
+        */
         q=SetImagePixelsEx(convolve_image,0,y,convolve_image->columns,1,exception);
         if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
           thread_status=MagickFail;
@@ -1479,58 +1476,58 @@ MagickExport Image *ConvolveImage(const Image *image,const unsigned int order,
                 r=p;
                 pixel=zero;
                 k=normal_kernel;
-               if (is_grayscale && !matte)
-                 {
-                   /* G */
-                   for (v=0; v < width; v++)
-                     {
-                       for (u=0; u < width; u++)
-                         pixel.red+=k[u]*r[u].red;
-                       k+= width;
-                       r+=image->columns+width;
-                     }
-                   q->red=q->green=q->blue=RoundFloatQuantumToIntQuantum(pixel.red);
-                   q->opacity=OpaqueOpacity;
-                 }
-               else if (!matte)
-                 {
-                   /* RGB */
-                   for (v=0; v < width; v++)
-                     {
-                       for (u=0; u < width; u++)
-                         {
-                           pixel.red+=k[u]*r[u].red;
-                           pixel.green+=k[u]*r[u].green;
-                           pixel.blue+=k[u]*r[u].blue;
-                         }
-                       k+=width;
-                       r+=image->columns+width;
-                     }
-                   q->red=RoundFloatQuantumToIntQuantum(pixel.red);
-                   q->green=RoundFloatQuantumToIntQuantum(pixel.green);
-                   q->blue=RoundFloatQuantumToIntQuantum(pixel.blue);
-                   q->opacity=OpaqueOpacity;
-                 }
-               else
-                 {
-                   /* RGBA */
-                   for (v=0; v < width; v++)
-                     {
-                       for (u=0; u < width; u++)
-                         {
-                           pixel.red+=k[u]*r[u].red;
-                           pixel.green+=k[u]*r[u].green;
-                           pixel.blue+=k[u]*r[u].blue;
-                           pixel.opacity+=k[u]*r[u].opacity;
-                         }
-                       k+=width;
-                       r+=image->columns+width;
-                     }
-                   q->red=RoundFloatQuantumToIntQuantum(pixel.red);
-                   q->green=RoundFloatQuantumToIntQuantum(pixel.green);
-                   q->blue=RoundFloatQuantumToIntQuantum(pixel.blue);
-                   q->opacity=RoundFloatQuantumToIntQuantum(pixel.opacity);
-                 }
+                if (is_grayscale && !matte)
+                  {
+                    /* G */
+                    for (v=0; v < width; v++)
+                      {
+                        for (u=0; u < width; u++)
+                          pixel.red+=k[u]*r[u].red;
+                        k+= width;
+                        r+=image->columns+width;
+                      }
+                    q->red=q->green=q->blue=RoundFloatQuantumToIntQuantum(pixel.red);
+                    q->opacity=OpaqueOpacity;
+                  }
+                else if (!matte)
+                  {
+                    /* RGB */
+                    for (v=0; v < width; v++)
+                      {
+                        for (u=0; u < width; u++)
+                          {
+                            pixel.red+=k[u]*r[u].red;
+                            pixel.green+=k[u]*r[u].green;
+                            pixel.blue+=k[u]*r[u].blue;
+                          }
+                        k+=width;
+                        r+=image->columns+width;
+                      }
+                    q->red=RoundFloatQuantumToIntQuantum(pixel.red);
+                    q->green=RoundFloatQuantumToIntQuantum(pixel.green);
+                    q->blue=RoundFloatQuantumToIntQuantum(pixel.blue);
+                    q->opacity=OpaqueOpacity;
+                  }
+                else
+                  {
+                    /* RGBA */
+                    for (v=0; v < width; v++)
+                      {
+                        for (u=0; u < width; u++)
+                          {
+                            pixel.red+=k[u]*r[u].red;
+                            pixel.green+=k[u]*r[u].green;
+                            pixel.blue+=k[u]*r[u].blue;
+                            pixel.opacity+=k[u]*r[u].opacity;
+                          }
+                        k+=width;
+                        r+=image->columns+width;
+                      }
+                    q->red=RoundFloatQuantumToIntQuantum(pixel.red);
+                    q->green=RoundFloatQuantumToIntQuantum(pixel.green);
+                    q->blue=RoundFloatQuantumToIntQuantum(pixel.blue);
+                    q->opacity=RoundFloatQuantumToIntQuantum(pixel.opacity);
+                  }
                 p++;
                 q++;
               }
@@ -1538,20 +1535,23 @@ MagickExport Image *ConvolveImage(const Image *image,const unsigned int order,
               thread_status=MagickFail;
           }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_ConvolveImage)
+#  pragma omp atomic
 #endif
-        {
-          row_count++;
-          if (QuantumTick(row_count,image->rows))
-            if (!MagickMonitorFormatted(row_count,image->rows,exception,
-                                        ConvolveImageText,
-                                        convolve_image->filename,
-                                       order))
-              thread_status=MagickFail;
-          
-          if (thread_status == MagickFail)
+        row_count++;
+        if (QuantumTick(row_count,image->rows))
+          if (!MagickMonitorFormatted(row_count,image->rows,exception,
+                                      ConvolveImageText,
+                                      convolve_image->filename,
+                                      order))
+            thread_status=MagickFail;
+
+        if (thread_status == MagickFail)
+          {
             status=MagickFail;
-        }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+          }
       }
   }
   MagickFreeAlignedMemory(normal_kernel);
@@ -1611,7 +1611,7 @@ MagickExport Image *DespeckleImage(const Image *image,ExceptionInfo *exception)
     layer,
     min_layer,
     max_layer;
-  
+
   size_t
     length;
 
@@ -1667,7 +1667,7 @@ MagickExport Image *DespeckleImage(const Image *image,ExceptionInfo *exception)
   if (pixels == (Quantum *) NULL)
     {
       ThrowException3(exception,ResourceLimitError,MemoryAllocationFailed,
-                     UnableToDespeckleImage);
+                      UnableToDespeckleImage);
       return ((Image *) NULL);
     }
   buffer=MagickAllocateArray(Quantum *,length,sizeof(*buffer));
@@ -1675,7 +1675,7 @@ MagickExport Image *DespeckleImage(const Image *image,ExceptionInfo *exception)
     {
       MagickFreeMemory(pixels);
       ThrowException3(exception,ResourceLimitError,MemoryAllocationFailed,
-                     UnableToDespeckleImage);
+                      UnableToDespeckleImage);
       return ((Image *) NULL);
     }
 
@@ -1701,131 +1701,131 @@ MagickExport Image *DespeckleImage(const Image *image,ExceptionInfo *exception)
         y;
 
       register const PixelPacket
-        *p;
-  
+        * restrict p;
+
       register long
         i,
         x;
-  
+
       register PixelPacket
-        *q;
+        * restrict q;
 
 
       /*
-       Export image channel
+        Export image channel
       */
       (void) memset(pixels,0,length*sizeof(Quantum));
       j=(long) image->columns+2;
       for (y=0; y < (long) image->rows; y++)
-       {
-         p=AcquireImagePixels(image,0,y,image->columns,1,exception);
-         if (p == (const PixelPacket *) NULL)
-           {
-             status=MagickFail;
-             break;
-           }
-         j++;
-
-         switch (layer)
-           {
-           case 0:
-             for (x=(long) image->columns; x > 0; x--)
-               pixels[j++]=p++->opacity;
-             break;
-           case 1:
-             for (x=(long) image->columns; x > 0; x--)
-               pixels[j++]=p++->red;
-             break;
-           case 2:
-             for (x=(long) image->columns; x > 0; x--)
-               pixels[j++]=p++->green;
-             break;
-           case 3:
-             for (x=(long) image->columns; x > 0; x--)
-               pixels[j++]=p++->blue;
-             break;
-           default:
-             break;
-           }
-
-         j++;
-       }
+        {
+          p=AcquireImagePixels(image,0,y,image->columns,1,exception);
+          if (p == (const PixelPacket *) NULL)
+            {
+              status=MagickFail;
+              break;
+            }
+          j++;
+
+          switch (layer)
+            {
+            case 0:
+              for (x=(long) image->columns; x > 0; x--)
+                pixels[j++]=p++->opacity;
+              break;
+            case 1:
+              for (x=(long) image->columns; x > 0; x--)
+                pixels[j++]=p++->red;
+              break;
+            case 2:
+              for (x=(long) image->columns; x > 0; x--)
+                pixels[j++]=p++->green;
+              break;
+            case 3:
+              for (x=(long) image->columns; x > 0; x--)
+                pixels[j++]=p++->blue;
+              break;
+            default:
+              break;
+            }
+
+          j++;
+        }
       if (status == MagickFail)
-       break;
+        break;
 
       (void) memset(buffer,0,length*sizeof(Quantum));
       for (i=0; i < 4; i++)
-       {
-         progress++;
-         if (!MagickMonitorFormatted(progress,progress_span,exception,
-                                     DespeckleImageText,
-                                     despeckle_image->filename))
-           {
-             status=MagickFail;
-             break;
-           }
-         Hull(X[i],Y[i],image->columns,image->rows,pixels,buffer,1);
-         Hull(-X[i],-Y[i],image->columns,image->rows,pixels,buffer,1);
-         Hull(-X[i],-Y[i],image->columns,image->rows,pixels,buffer,-1);
-         Hull(X[i],Y[i],image->columns,image->rows,pixels,buffer,-1);
-       }
+        {
+          progress++;
+          if (!MagickMonitorFormatted(progress,progress_span,exception,
+                                      DespeckleImageText,
+                                      despeckle_image->filename))
+            {
+              status=MagickFail;
+              break;
+            }
+          Hull(X[i],Y[i],image->columns,image->rows,pixels,buffer,1);
+          Hull(-X[i],-Y[i],image->columns,image->rows,pixels,buffer,1);
+          Hull(-X[i],-Y[i],image->columns,image->rows,pixels,buffer,-1);
+          Hull(X[i],Y[i],image->columns,image->rows,pixels,buffer,-1);
+        }
       if (status == MagickFail)
-       break;
+        break;
 
       /*
-       Import image channel
+        Import image channel
       */
       j=(long) image->columns+2;
       for (y=0; y < (long) image->rows; y++)
-       {
-         q=SetImagePixelsEx(despeckle_image,0,y,despeckle_image->columns,1,exception);
-         if (q == (PixelPacket *) NULL)
-           {
-             status=MagickFail;
-             break;
-           }
-         j++;
-
-         switch (layer)
-           {
-           case 0:
-             for (x=(long) image->columns; x > 0; x--)
-               q++->opacity=pixels[j++];
-             break;
-           case 1:
-             if (characteristics.grayscale)
-               {
-                 for (x=(long) image->columns; x > 0; x--)
-                   {
-                     q->red=q->green=q->blue=pixels[j++];
-                     q++;
-                   }
-               }
-             else
-               {
-                 for (x=(long) image->columns; x > 0; x--)
-                   q++->red=pixels[j++];
-               }
-             break;
-           case 2:
-             for (x=(long) image->columns; x > 0; x--)
-               q++->green=pixels[j++];
-             break;
-           case 3:
-             for (x=(long) image->columns; x > 0; x--)
-               q++->blue=pixels[j++];
-             break;
-           default:
-             break;
-           }
-
-         if (!SyncImagePixelsEx(despeckle_image,exception))
-           {
-             status=MagickFail;
-             break;
-           }
-         j++;
-       }
+        {
+          q=SetImagePixelsEx(despeckle_image,0,y,despeckle_image->columns,1,exception);
+          if (q == (PixelPacket *) NULL)
+            {
+              status=MagickFail;
+              break;
+            }
+          j++;
+
+          switch (layer)
+            {
+            case 0:
+              for (x=(long) image->columns; x > 0; x--)
+                q++->opacity=pixels[j++];
+              break;
+            case 1:
+              if (characteristics.grayscale)
+                {
+                  for (x=(long) image->columns; x > 0; x--)
+                    {
+                      q->red=q->green=q->blue=pixels[j++];
+                      q++;
+                    }
+                }
+              else
+                {
+                  for (x=(long) image->columns; x > 0; x--)
+                    q++->red=pixels[j++];
+                }
+              break;
+            case 2:
+              for (x=(long) image->columns; x > 0; x--)
+                q++->green=pixels[j++];
+              break;
+            case 3:
+              for (x=(long) image->columns; x > 0; x--)
+                q++->blue=pixels[j++];
+              break;
+            default:
+              break;
+            }
+
+          if (!SyncImagePixelsEx(despeckle_image,exception))
+            {
+              status=MagickFail;
+              break;
+            }
+          j++;
+        }
     }
 
   MagickFreeMemory(pixels);
@@ -2089,9 +2089,6 @@ MagickExport Image *EnhanceImage(const Image *image,ExceptionInfo *exception)
         MagickBool
           thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_EnhanceImage)
-#endif
         thread_status=status;
         if (thread_status == MagickFail)
           continue;
@@ -2105,26 +2102,26 @@ MagickExport Image *EnhanceImage(const Image *image,ExceptionInfo *exception)
           thread_status=MagickFail;
         if (thread_status != MagickFail)
           {
-           DoublePixelPacket
-             aggregate;
+            DoublePixelPacket
+              aggregate;
 
-           double
-             pixel_red,
-             pixel_green,
-             pixel_blue,
-             total_weight;
+            double
+              pixel_red,
+              pixel_green,
+              pixel_blue,
+              total_weight;
 
-           register const PixelPacket
-             *r;
+            register const PixelPacket
+              *r;
 
-           double
-             distance,
-             distance_squared,
-             mean;
+            double
+              distance,
+              distance_squared,
+              mean;
 
-           unsigned long
-             i,
-             j;
+            unsigned long
+              i,
+              j;
 
             /*
               Transfer first 2 pixels of the scanline.
@@ -2139,44 +2136,44 @@ MagickExport Image *EnhanceImage(const Image *image,ExceptionInfo *exception)
                 aggregate=zero;
                 total_weight=0.0;
                 r=p+2*image->columns+2;
-               pixel_red=r->red;
-               pixel_green=r->green;
-               pixel_blue=r->blue;
-
-               for (i=0 ; i < 5; i++)
-                 {
-                   r=p+i*image->columns;
-                   for (j = 0; j < 5; j++)
-                     {
-                       const double red = (double) r->red;
-                       const double green = (double) r->green;
-                       const double blue = (double) r->blue;
-                       mean=(red+pixel_red)/2.0;
-                       distance=red-pixel_red;
-                       distance_squared=(2.0*(MaxRGBDouble+1.0)+mean)*distance*
-                         distance/MaxRGBDouble;
-                       mean=(green+pixel_green)/2.0;
-                       distance=green-pixel_green;
-                       distance_squared+=4.0*distance*distance;
-                       mean=(blue+pixel_blue)/2.0;
-                       distance=blue-pixel_blue;
-                       distance_squared+=
-                         (3.0*(MaxRGBDouble+1.0)-1.0-mean)*distance*distance/MaxRGBDouble;
-                       if (distance_squared < ((MaxRGBDouble*MaxRGBDouble/25.0)))
-                         {
-                           const double weight = Weights[i][j];
-                           aggregate.red+=weight*red;
-                           aggregate.green+=weight*green;
-                           aggregate.blue+=weight*blue;
-                           total_weight+=weight;
-                         }
-                       r++;
-                     }
-                 }
+                pixel_red=r->red;
+                pixel_green=r->green;
+                pixel_blue=r->blue;
+
+                for (i=0 ; i < 5; i++)
+                  {
+                    r=p+i*image->columns;
+                    for (j = 0; j < 5; j++)
+                      {
+                        const double red = (double) r->red;
+                        const double green = (double) r->green;
+                        const double blue = (double) r->blue;
+                        mean=(red+pixel_red)/2.0;
+                        distance=red-pixel_red;
+                        distance_squared=(2.0*(MaxRGBDouble+1.0)+mean)*distance*
+                          distance/MaxRGBDouble;
+                        mean=(green+pixel_green)/2.0;
+                        distance=green-pixel_green;
+                        distance_squared+=4.0*distance*distance;
+                        mean=(blue+pixel_blue)/2.0;
+                        distance=blue-pixel_blue;
+                        distance_squared+=
+                          (3.0*(MaxRGBDouble+1.0)-1.0-mean)*distance*distance/MaxRGBDouble;
+                        if (distance_squared < ((MaxRGBDouble*MaxRGBDouble/25.0)))
+                          {
+                            const double weight = Weights[i][j];
+                            aggregate.red+=weight*red;
+                            aggregate.green+=weight*green;
+                            aggregate.blue+=weight*blue;
+                            total_weight+=weight;
+                          }
+                        r++;
+                      }
+                  }
                 q->red=(Quantum) ((aggregate.red+(total_weight/2.0)-1.0)/total_weight);
                 q->green=(Quantum) ((aggregate.green+(total_weight/2.0)-1.0)/total_weight);
                 q->blue=(Quantum) ((aggregate.blue+(total_weight/2.0)-1.0)/total_weight);
-               q->opacity=p->opacity;
+                q->opacity=p->opacity;
                 p++;
                 q++;
               }
@@ -2187,18 +2184,21 @@ MagickExport Image *EnhanceImage(const Image *image,ExceptionInfo *exception)
               thread_status=MagickFail;
           }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_EnhanceImage)
+#  pragma omp atomic
 #endif
-        {
-          row_count++;
-          if (QuantumTick(row_count,image->rows))
-            if (!MagickMonitorFormatted(row_count,image->rows,exception,
-                                        EnhanceImageText,image->filename))
-              thread_status=MagickFail;
-          
-          if (thread_status == MagickFail)
+        row_count++;
+        if (QuantumTick(row_count,image->rows))
+          if (!MagickMonitorFormatted(row_count,image->rows,exception,
+                                      EnhanceImageText,image->filename))
+            thread_status=MagickFail;
+
+        if (thread_status == MagickFail)
+          {
             status=MagickFail;
-        }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+          }
       }
   }
   enhance_image->is_grayscale=image->is_grayscale;
@@ -2570,7 +2570,7 @@ static void DestroyMedianList(void *pixel_list)
     {
       unsigned int
         i;
-      
+
       for (i=0; i < 4U; i++)
         MagickFreeAlignedMemory(skiplist->lists[i].nodes);
     }
@@ -2583,15 +2583,15 @@ static MedianPixelList *AllocateMedianList(const long width)
     *skiplist;
 
   skiplist=MagickAllocateAlignedMemory(MedianPixelList *,
-                                      MAGICK_CACHE_LINE_SIZE,
-                                      sizeof(MedianPixelList));
+                                       MAGICK_CACHE_LINE_SIZE,
+                                       sizeof(MedianPixelList));
   if (skiplist != (MedianPixelList *) NULL)
     {
       unsigned int
         i;
 
       const size_t
-       node_list_size = 65537U*sizeof(MedianListNode);
+        node_list_size = 65537U*sizeof(MedianListNode);
 
       (void) memset(skiplist,0,sizeof(MedianPixelList));
       skiplist->center=width*width/2;
@@ -2599,8 +2599,8 @@ static MedianPixelList *AllocateMedianList(const long width)
       for (i=0; i < 4U; i++)
         {
           skiplist->lists[i].nodes =
-           MagickAllocateAlignedMemory(MedianListNode *,MAGICK_CACHE_LINE_SIZE,
-                                       node_list_size);
+            MagickAllocateAlignedMemory(MedianListNode *,MAGICK_CACHE_LINE_SIZE,
+                                        node_list_size);
           if (skiplist->lists[i].nodes == (MedianListNode *) NULL)
             {
               DestroyMedianList(skiplist);
@@ -2688,7 +2688,7 @@ MagickExport Image *MedianFilterImage(const Image *image,const double radius,
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for schedule(static,4) shared(row_count, status)
+#    pragma omp parallel for schedule(guided) shared(row_count, status)
 #  endif
 #endif
     for (y=0; y < (long) median_image->rows; y++)
@@ -2708,9 +2708,6 @@ MagickExport Image *MedianFilterImage(const Image *image,const double radius,
         MagickBool
           thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_MedianFilterImage)
-#endif
         thread_status=status;
         if (thread_status == MagickFail)
           continue;
@@ -2746,19 +2743,22 @@ MagickExport Image *MedianFilterImage(const Image *image,const double radius,
               thread_status=MagickFail;
           }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_MedianFilterImage)
+#  pragma omp atomic
 #endif
-        {
-          row_count++;
-          if (QuantumTick(row_count,median_image->rows))
-            if (!MagickMonitorFormatted(row_count,median_image->rows,exception,
-                                        MedianFilterImageText,
-                                        median_image->filename))
-              thread_status=MagickFail;
+        row_count++;
+        if (QuantumTick(row_count,median_image->rows))
+          if (!MagickMonitorFormatted(row_count,median_image->rows,exception,
+                                      MedianFilterImageText,
+                                      median_image->filename))
+            thread_status=MagickFail;
 
-          if (thread_status == MagickFail)
+        if (thread_status == MagickFail)
+          {
             status=MagickFail;
-        }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+          }
       }
   }
   DestroyThreadViewDataSet(data_set);
@@ -2824,7 +2824,7 @@ static double *AllocateMotionBlurKernel(const int width,const double sigma)
       double
         alpha,
         normalize;
-      
+
       int
         bias;
 
@@ -2928,7 +2928,7 @@ MagickExport Image *MotionBlurImage(const Image *image,const double radius,
     */
     unsigned long
       row_count=0;
-    
+
     long
       y;
 
@@ -2944,7 +2944,7 @@ MagickExport Image *MotionBlurImage(const Image *image,const double radius,
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for schedule(static,4) shared(row_count, status)
+#    pragma omp parallel for schedule(guided) shared(row_count, status)
 #  endif
 #endif
     for (y=0; y < (long) image->rows; y++)
@@ -2961,9 +2961,6 @@ MagickExport Image *MotionBlurImage(const Image *image,const double radius,
         MagickBool
           thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_MotionBlurImage)
-#endif
         thread_status=status;
         if (thread_status == MagickFail)
           continue;
@@ -3015,18 +3012,21 @@ MagickExport Image *MotionBlurImage(const Image *image,const double radius,
               thread_status=MagickFail;
           }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_MotionBlurImage)
+#  pragma omp atomic
 #endif
-        {
-          row_count++;
-          if (QuantumTick(row_count,image->rows))
-            if (!MagickMonitorFormatted(row_count,image->rows,exception,
-                                        MotionBlurImageText,image->filename))
-              thread_status=MagickFail;
-          
-          if (thread_status == MagickFail)
+        row_count++;
+        if (QuantumTick(row_count,image->rows))
+          if (!MagickMonitorFormatted(row_count,image->rows,exception,
+                                      MotionBlurImageText,image->filename))
+            thread_status=MagickFail;
+
+        if (thread_status == MagickFail)
+          {
             status=MagickFail;
-        }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+          }
       }
   }
   MagickFreeMemory(kernel);
@@ -3086,9 +3086,9 @@ RandomChannelThresholdImage(Image *image,const char *channel,
 
   const double
     o4[16]={ 1.0,  9.0,  3.0, 11.0,
-            13.0,  5.0, 15.0,  7.0,
+             13.0,  5.0, 15.0,  7.0,
              4.0, 12.0,  2.0, 10.0,
-            16.0,  8.0, 14.0,  6.0};
+             16.0,  8.0, 14.0,  6.0};
 
   const double
     o5[25]={ 1.0,  5.0, 16.0, 15.0,  4.0,
@@ -3100,18 +3100,18 @@ RandomChannelThresholdImage(Image *image,const char *channel,
   const double
     o6[36]={ 1.0,   5.0,  14.0,  13.0,  12.0,   4.0,
              6.0,  22.0,  28.0,  27.0,  21.0,  11.0,
-            15.0,  29.0,  35.0,  34.0,  26.0,  20.0,
-            16.0,  30.0,  36.0,  33.0,  25.0,  19.0,
+             15.0,  29.0,  35.0,  34.0,  26.0,  20.0,
+             16.0,  30.0,  36.0,  33.0,  25.0,  19.0,
              7.0,  23.0,  31.0,  32.0,  24.0,  10.0,
              2.0,   8.0,  17.0,  18.0,   9.0,   3.0};
 
   const double
-    o7[49]={ 2.0,   7.0,  17.0,  26.0,  15.0,   6.0,   1.0, 
-             8.0,  16.0,  33.0,  39.0,  32.0,  13.0,   5.0, 
-            18.0,  34.0,  44.0,  48.0,  43.0,  31.0,  14.0, 
-            27.0,  40.0,  45.0,  49.0,  47.0,  38.0,  25.0, 
-            20.0,  35.0,  41.0,  46.0,  42.0,  30.0,  24.0, 
-             9.0,  19.0,  36.0,  37.0,  29.0,  22.0,  12.0, 
+    o7[49]={ 2.0,   7.0,  17.0,  26.0,  15.0,   6.0,   1.0,
+             8.0,  16.0,  33.0,  39.0,  32.0,  13.0,   5.0,
+             18.0,  34.0,  44.0,  48.0,  43.0,  31.0,  14.0,
+             27.0,  40.0,  45.0,  49.0,  47.0,  38.0,  25.0,
+             20.0,  35.0,  41.0,  46.0,  42.0,  30.0,  24.0,
+             9.0,  19.0,  36.0,  37.0,  29.0,  22.0,  12.0,
              3.0,  10.0,  21.0,  28.0,  23.0,  11.0,   4.0};
 
 
@@ -3270,7 +3270,7 @@ RandomChannelThresholdImage(Image *image,const char *channel,
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for schedule(static,4) shared(row_count, status)
+#    pragma omp parallel for schedule(guided) shared(row_count, status)
 #  endif
 #endif
     for (y=0; y < (long) image->rows; y++)
@@ -3291,20 +3291,17 @@ RandomChannelThresholdImage(Image *image,const char *channel,
         register unsigned long
           x;
 
-       MagickRandomKernel
-         *random_kernel;
+        MagickRandomKernel
+          *random_kernel;
 
         MagickBool
           thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_RandomChannelThresholdImage)
-#endif
         thread_status=status;
         if (thread_status == MagickFail)
           continue;
 
-       random_kernel=AcquireMagickRandomKernel();
+        random_kernel=AcquireMagickRandomKernel();
         q=GetImagePixelsEx(image,0,y,image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
           thread_status=MagickFail;
@@ -3321,7 +3318,7 @@ RandomChannelThresholdImage(Image *image,const char *channel,
                     for (x=(long) image->columns; x > 0; x--)
                       {
                         intensity=(is_grayscale ?
-                            q->red : PixelIntensityToQuantum(q));
+                                   q->red : PixelIntensityToQuantum(q));
                         if (intensity < lower_threshold)
                           threshold=lower_threshold;
                         else if (intensity > upper_threshold)
@@ -3343,7 +3340,7 @@ RandomChannelThresholdImage(Image *image,const char *channel,
                     for (x=(long) image->columns; x > 0; x--)
                       {
                         intensity=(is_grayscale ?
-                            q->red : PixelIntensityToQuantum(q));
+                                   q->red : PixelIntensityToQuantum(q));
                         threshold=matrix[(x%order)+order*(y%order)];
                         index=intensity <= threshold ? 0U : 1U;
                         *indexes++=index;
@@ -3457,7 +3454,7 @@ RandomChannelThresholdImage(Image *image,const char *channel,
                     break;
                   }
               }
-            
+
             if ((BlueChannel == channel_type) ||
                 (YellowChannel == channel_type))
               {
@@ -3496,19 +3493,22 @@ RandomChannelThresholdImage(Image *image,const char *channel,
               thread_status=MagickFail;
           }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_RandomChannelThresholdImage)
+#  pragma omp atomic
 #endif
-        {
-          row_count++;
-          if (QuantumTick(row_count,image->rows))
-            if (!MagickMonitorFormatted(row_count,image->rows,exception,
-                                        RandomChannelThresholdImageText,
-                                        image->filename))
-              thread_status=MagickFail;
-          
-          if (thread_status == MagickFail)
+        row_count++;
+        if (QuantumTick(row_count,image->rows))
+          if (!MagickMonitorFormatted(row_count,image->rows,exception,
+                                      RandomChannelThresholdImageText,
+                                      image->filename))
+            thread_status=MagickFail;
+
+        if (thread_status == MagickFail)
+          {
             status=MagickFail;
-        }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+          }
       }
   }
   if ((AllChannels == channel_type) ||
@@ -3677,7 +3677,7 @@ MagickExport Image *ReduceNoiseImage(const Image *image,const double radius,
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for schedule(static,4) shared(row_count, status)
+#    pragma omp parallel for schedule(guided) shared(row_count, status)
 #  endif
 #endif
   for (y=0; y < (long) noise_image->rows; y++)
@@ -3697,13 +3697,10 @@ MagickExport Image *ReduceNoiseImage(const Image *image,const double radius,
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_ReduceNoiseImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
-      
+
       skiplist=AccessThreadViewData(data_set);
       p=AcquireImagePixels(image,-width/2,y-width/2,
                            image->columns+width,width,exception);
@@ -3736,19 +3733,22 @@ MagickExport Image *ReduceNoiseImage(const Image *image,const double radius,
             thread_status=MagickFail;
         }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_ReduceNoiseImage)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,noise_image->rows))
-          if (!MagickMonitorFormatted(row_count,noise_image->rows,exception,
-                                      ReduceNoiseImageText,
-                                      noise_image->filename))
-            thread_status=MagickFail;
+      row_count++;
+      if (QuantumTick(row_count,noise_image->rows))
+        if (!MagickMonitorFormatted(row_count,noise_image->rows,exception,
+                                    ReduceNoiseImageText,
+                                    noise_image->filename))
+          thread_status=MagickFail;
 
-        if (thread_status == MagickFail)
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
   DestroyThreadViewDataSet(data_set);
   noise_image->is_grayscale=image->is_grayscale;
@@ -3830,12 +3830,12 @@ MagickExport Image *ShadeImage(const Image *image,const unsigned int gray,
   {
     unsigned long
       row_count=0;
-    
+
 #if defined(HAVE_OPENMP)
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for schedule(static,4) shared(row_count, status)
+#    pragma omp parallel for schedule(guided) shared(row_count, status)
 #  endif
 #endif
     for (y=0; y < (long) image->rows; y++)
@@ -3844,13 +3844,13 @@ MagickExport Image *ShadeImage(const Image *image,const unsigned int gray,
           normal;
 
         register const PixelPacket
-          *p,
+          * restrict p,
           *s0,
           *s1,
           *s2;
 
         register PixelPacket
-          *q;
+          * restrict q;
 
         register long
           x;
@@ -3858,9 +3858,6 @@ MagickExport Image *ShadeImage(const Image *image,const unsigned int gray,
         MagickBool
           thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_ShadeImage)
-#endif
         thread_status=status;
         if (thread_status == MagickFail)
           continue;
@@ -3931,18 +3928,21 @@ MagickExport Image *ShadeImage(const Image *image,const unsigned int gray,
               thread_status=MagickFail;
           }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_ShadeImage)
+#  pragma omp atomic
 #endif
-        {
-          row_count++;
-          if (QuantumTick(row_count,image->rows))
-            if (!MagickMonitorFormatted(row_count,image->rows,exception,
-                                        ShadeImageText,image->filename))
-              thread_status=MagickFail;
-          
-          if (thread_status == MagickFail)
+        row_count++;
+        if (QuantumTick(row_count,image->rows))
+          if (!MagickMonitorFormatted(row_count,image->rows,exception,
+                                      ShadeImageText,image->filename))
+            thread_status=MagickFail;
+
+        if (thread_status == MagickFail)
+          {
             status=MagickFail;
-        }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+          }
       }
   }
   shade_image->is_grayscale=image->is_grayscale;
@@ -4158,7 +4158,7 @@ MagickExport Image *SpreadImage(const Image *image,const unsigned int radius,
     for (x=0; x < OFFSETS_ENTRIES; x++)
       {
         offsets[x]=(((2*(double) radius+1)*MagickRandomRealInlined(random_kernel))
-                   -((int) radius));
+                    -((int) radius));
       }
   }
 
@@ -4179,7 +4179,7 @@ MagickExport Image *SpreadImage(const Image *image,const unsigned int radius,
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for schedule(static,8) shared(row_count, status)
+#    pragma omp parallel for schedule(guided) shared(row_count, status)
 #  endif
 #endif
     for (y=0; y < (long) image->rows; y++)
@@ -4207,9 +4207,6 @@ MagickExport Image *SpreadImage(const Image *image,const unsigned int radius,
         MagickBool
           thread_status;
 
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_SpreadImage)
-#endif
         thread_status=status;
         if (thread_status == MagickFail)
           continue;
@@ -4222,7 +4219,7 @@ MagickExport Image *SpreadImage(const Image *image,const unsigned int radius,
           y_min=0;
         else
           y_min=y-radius;
-    
+
         if (((unsigned long) y+radius) >= image->rows)
           y_max=image->rows-1;
         else
@@ -4274,19 +4271,22 @@ MagickExport Image *SpreadImage(const Image *image,const unsigned int radius,
             if (!SyncImagePixelsEx(spread_image,exception))
               thread_status=MagickFail;
           }
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_SpreadImage)
+#if defined(HAVE_OPENMP)
+#  pragma omp atomic
 #endif
-        {
-          row_count++;
-          if (QuantumTick(row_count,image->rows))
-            if (!MagickMonitorFormatted(row_count,image->rows,exception,
-                                        EnhanceImageText,image->filename))
-              thread_status=MagickFail;
-          
-          if (thread_status == MagickFail)
+        row_count++;
+        if (QuantumTick(row_count,image->rows))
+          if (!MagickMonitorFormatted(row_count,image->rows,exception,
+                                      EnhanceImageText,image->filename))
+            thread_status=MagickFail;
+
+        if (thread_status == MagickFail)
+          {
             status=MagickFail;
-        }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+          }
       }
   }
   MagickFreeMemory(offsets);
@@ -4376,7 +4376,7 @@ MagickExport MagickPassFail ThresholdImage(Image *image,const double threshold)
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for schedule(static,8) shared(row_count, status)
+#    pragma omp parallel for schedule(guided) shared(row_count, status)
 #  endif
 #endif
     for (y=0; y < (long) image->rows; y++)
@@ -4402,9 +4402,6 @@ MagickExport MagickPassFail ThresholdImage(Image *image,const double threshold)
         MagickBool
           thread_status;
 
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_ThresholdImage)
-#endif
         thread_status=status;
         if (thread_status == MagickFail)
           continue;
@@ -4440,19 +4437,22 @@ MagickExport MagickPassFail ThresholdImage(Image *image,const double threshold)
               if (!SyncImagePixelsEx(image,&image->exception))
                 thread_status=MagickFail;
           }
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_ThresholdImage)
+#if defined(HAVE_OPENMP)
+#  pragma omp atomic
 #endif
-        {
-          row_count++;
-          if (QuantumTick(row_count,image->rows))
-            if (!MagickMonitorFormatted(row_count,image->rows,&image->exception,
-                                        ThresholdImageText,image->filename))
-              thread_status=MagickFail;
-          
-          if (thread_status == MagickFail)
+        row_count++;
+        if (QuantumTick(row_count,image->rows))
+          if (!MagickMonitorFormatted(row_count,image->rows,&image->exception,
+                                      ThresholdImageText,image->filename))
+            thread_status=MagickFail;
+
+        if (thread_status == MagickFail)
+          {
             status=MagickFail;
-        }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+          }
       }
   }
   image->is_monochrome=MagickTrue;
@@ -4554,17 +4554,17 @@ UnsharpMaskPixels(void *mutable_data,                /* User provided mutable da
   for (i=0; i < npixels; i++)
     {
       update_pixels[i].red=UnsharpQuantum(source_pixels[i].red,
-                                         update_pixels[i].red,
-                                         options);
+                                          update_pixels[i].red,
+                                          options);
       update_pixels[i].green=UnsharpQuantum(source_pixels[i].green,
-                                           update_pixels[i].green,
-                                           options);
+                                            update_pixels[i].green,
+                                            options);
       update_pixels[i].blue=UnsharpQuantum(source_pixels[i].blue,
-                                          update_pixels[i].blue,
-                                          options);
+                                           update_pixels[i].blue,
+                                           options);
       update_pixels[i].opacity=UnsharpQuantum(source_pixels[i].opacity,
-                                             update_pixels[i].opacity,
-                                             options);
+                                              update_pixels[i].opacity,
+                                              options);
     }
   return MagickPass;
 }
@@ -4591,12 +4591,12 @@ MagickExport Image *UnsharpMaskImage(const Image *image,const double radius,
   options.amount=amount;
   options.threshold=(MaxRGBFloat*threshold)/2.0;
   FormatString(message,"[%%s] Unsharp mask: amount %g, threshold %g...",
-              amount,threshold);
+               amount,threshold);
   (void) PixelIterateDualModify(UnsharpMaskPixels,NULL,
                                 message,NULL,&options,
                                 image->columns,image->rows,image,0,0,
-                               sharp_image,
-                                0,0,exception);                                
+                                sharp_image,
+                                0,0,exception);
   sharp_image->is_grayscale=image->is_grayscale;
   return(sharp_image);
 }
index b371a34..60633d8 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003-2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Image Effect Methods.
 */
 #ifndef _MAGICK_EFFECT_H
index a26ffe6..e7ef5b2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2010 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -52,9 +52,9 @@
 static MagickPassFail
 BuildChannelHistogramsCB(void *mutable_data,          /* User provided mutable data */
                          const void *immutable_data,  /* User provided immutable data */
-                         const Image *const_image,    /* Input image */
-                         const PixelPacket *pixels,   /* Pixel row */
-                         const IndexPacket *indexes,  /* Pixel indexes */
+                         const Image * restrict const_image,    /* Input image */
+                         const PixelPacket * restrict pixels,   /* Pixel row */
+                         const IndexPacket * restrict indexes,  /* Pixel indexes */
                          const long npixels,          /* Number of pixels in row */
                          ExceptionInfo *exception     /* Exception report */
                          )
@@ -95,7 +95,7 @@ BuildChannelHistograms(const Image *image, ExceptionInfo *exception)
 
   DoublePixelPacket
     *histogram;
-  
+
   histogram=MagickAllocateArray(DoublePixelPacket *,(MaxMap+1),
                                 sizeof(DoublePixelPacket));
   if (histogram == (DoublePixelPacket *) NULL)
@@ -110,7 +110,7 @@ BuildChannelHistograms(const Image *image, ExceptionInfo *exception)
   {
     PixelIteratorOptions
       iterator_options;
-    
+
     InitializePixelIteratorOptions(&iterator_options,exception);
     iterator_options.max_threads=1;
     status=PixelIterateMonoRead(BuildChannelHistogramsCB,
@@ -123,7 +123,7 @@ BuildChannelHistograms(const Image *image, ExceptionInfo *exception)
 
   if (status == MagickFail)
     MagickFreeMemory(histogram);
-  
+
   return histogram;
 }
 \f
@@ -156,9 +156,9 @@ BuildChannelHistograms(const Image *image, ExceptionInfo *exception)
 static MagickPassFail
 ContrastImagePixels(void *mutable_data,         /* User provided mutable data */
                     const void *immutable_data, /* User provided immutable data */
-                    Image *image,               /* Modify image */
-                    PixelPacket *pixels,        /* Pixel row */
-                    IndexPacket *indexes,       /* Pixel row indexes */
+                    Image * restrict image,               /* Modify image */
+                    PixelPacket * restrict pixels,        /* Pixel row */
+                    IndexPacket * restrict indexes,       /* Pixel row indexes */
                     const long npixels,         /* Number of pixels in row */
                     ExceptionInfo *exception)   /* Exception report */
 {
@@ -170,10 +170,10 @@ ContrastImagePixels(void *mutable_data,         /* User provided mutable data */
 
   static const double
     alpha=0.5+MagickEpsilon;
-      
+
   register long
     i;
-  
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(image);
   ARG_NOT_USED(indexes);
@@ -275,9 +275,9 @@ typedef struct _ApplyLevelsOptions_t
 static MagickPassFail
 ApplyLevels(void *mutable_data,          /* User provided mutable data */
             const void *immutable_data,  /* User provided immutable data */
-            Image *image,                /* Modify image */
-            PixelPacket *pixels,         /* Pixel row */
-            IndexPacket *indexes,        /* Pixel row indexes */
+            Image * restrict image,                /* Modify image */
+            PixelPacket * restrict pixels,         /* Pixel row */
+            IndexPacket * restrict indexes,        /* Pixel row indexes */
             const long npixels,          /* Number of pixels in row */
             ExceptionInfo *exception)    /* Exception report */
 {
@@ -298,7 +298,7 @@ ApplyLevels(void *mutable_data,          /* User provided mutable data */
     level_green=options->level_green,
     level_blue=options->level_blue,
     level_opacity=options->level_opacity;
-  
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(image);
   ARG_NOT_USED(indexes);
@@ -369,7 +369,7 @@ MagickExport MagickPassFail EqualizeImage(Image *image)
   /*
     Integrate the histogram to get the equalization map.
   */
-  (void) memset(&intensity,0,sizeof(DoublePixelPacket));  
+  (void) memset(&intensity,0,sizeof(DoublePixelPacket));
   for (i=0; i <= (long) MaxMap; i++)
     {
       intensity.red+=histogram[i].red;
@@ -473,12 +473,12 @@ typedef struct _ApplyLevelsDiscrete_t
 
 static MagickPassFail
 ApplyLevelsDiscrete(void *mutable_data,             /* User provided mutable data */
-                   const void *immutable_data,     /* User provided immutable data */
-                   Image *image,                   /* Modify image */
-                   PixelPacket * restrict pixels,  /* Pixel row */
-                   IndexPacket * restrict indexes, /* Pixel row indexes */
-                   const long npixels,             /* Number of pixels in row */
-                   ExceptionInfo *exception)       /* Exception report */
+                    const void *immutable_data,     /* User provided immutable data */
+                    Image * restrict image,                   /* Modify image */
+                    PixelPacket * restrict pixels,  /* Pixel row */
+                    IndexPacket * restrict indexes, /* Pixel row indexes */
+                    const long npixels,             /* Number of pixels in row */
+                    ExceptionInfo *exception)       /* Exception report */
 {
   /*
     Apply a levels transformation based on a supplied look-up table.
@@ -497,20 +497,20 @@ ApplyLevelsDiscrete(void *mutable_data,             /* User provided mutable dat
   for (i=0; i < npixels; i++)
     {
       if (levels.color)
-       {
-         pixels[i].red=levels.color[ScaleQuantumToMap(pixels[i].red)];
-         pixels[i].green=levels.color[ScaleQuantumToMap(pixels[i].green)];
-         pixels[i].blue=levels.color[ScaleQuantumToMap(pixels[i].blue)];
-       }
+        {
+          pixels[i].red=levels.color[ScaleQuantumToMap(pixels[i].red)];
+          pixels[i].green=levels.color[ScaleQuantumToMap(pixels[i].green)];
+          pixels[i].blue=levels.color[ScaleQuantumToMap(pixels[i].blue)];
+        }
       else
-       {
-         if (levels.red)
-           pixels[i].red=levels.red[ScaleQuantumToMap(pixels[i].red)];
-         if (levels.green)
-           pixels[i].green=levels.green[ScaleQuantumToMap(pixels[i].green)];
-         if (levels.blue)
-           pixels[i].blue=levels.blue[ScaleQuantumToMap(pixels[i].blue)];
-       }
+        {
+          if (levels.red)
+            pixels[i].red=levels.red[ScaleQuantumToMap(pixels[i].red)];
+          if (levels.green)
+            pixels[i].green=levels.green[ScaleQuantumToMap(pixels[i].green)];
+          if (levels.blue)
+            pixels[i].blue=levels.blue[ScaleQuantumToMap(pixels[i].blue)];
+        }
       if (levels.opacity)
         pixels[i].opacity=levels.opacity[ScaleQuantumToMap(pixels[i].opacity)];
     }
@@ -533,12 +533,12 @@ typedef DoublePixelPacket GammaCorrectPixelsOptions_t;
 
 static MagickPassFail
 GammaCorrectPixels(void *mutable_data,             /* User provided mutable data */
-                  const void *immutable_data,     /* User provided immutable data */
-                  Image *image,                   /* Modify image */
-                  PixelPacket * restrict pixels,  /* Pixel row */
-                  IndexPacket * restrict indexes, /* Pixel row indexes */
-                  const long npixels,             /* Number of pixels in row */
-                  ExceptionInfo *exception)       /* Exception report */
+                   const void *immutable_data,     /* User provided immutable data */
+                   Image * restrict image,                   /* Modify image */
+                   PixelPacket * restrict pixels,  /* Pixel row */
+                   IndexPacket * restrict indexes, /* Pixel row indexes */
+                   const long npixels,             /* Number of pixels in row */
+                   ExceptionInfo *exception)       /* Exception report */
 {
   /*
     Apply a gamma transformation based on slow accurate math.
@@ -566,23 +566,23 @@ GammaCorrectPixels(void *mutable_data,             /* User provided mutable data
   for (i=0; i < npixels; i++)
     {
       double
-       value;
+        value;
 
       if (red_flag)
-       {
-         value=MaxRGBDouble*GammaCorrect(pixels[i].red/MaxRGBDouble,options.red);
-         pixels[i].red=RoundDoubleToQuantum(value);
-       }
+        {
+          value=MaxRGBDouble*GammaCorrect(pixels[i].red/MaxRGBDouble,options.red);
+          pixels[i].red=RoundDoubleToQuantum(value);
+        }
       if (green_flag)
-       {
-         value=MaxRGBDouble*GammaCorrect(pixels[i].green/MaxRGBDouble,options.green);
-         pixels[i].green=RoundDoubleToQuantum(value);
-       }
+        {
+          value=MaxRGBDouble*GammaCorrect(pixels[i].green/MaxRGBDouble,options.green);
+          pixels[i].green=RoundDoubleToQuantum(value);
+        }
       if (blue_flag)
-       {
-         value=MaxRGBDouble*GammaCorrect(pixels[i].blue/MaxRGBDouble,options.blue);
-         pixels[i].blue=RoundDoubleToQuantum(value);
-       }
+        {
+          value=MaxRGBDouble*GammaCorrect(pixels[i].blue/MaxRGBDouble,options.blue);
+          pixels[i].blue=RoundDoubleToQuantum(value);
+        }
     }
 
   return MagickPass;
@@ -620,7 +620,7 @@ MagickExport MagickPassFail GammaImage(Image *image,const char *level)
   if (level == (char *) NULL)
     return(MagickFail);
   count=sscanf(level,"%lf%*[,/]%lf%*[,/]%lf",&gamma_red,&gamma_green,
-              &gamma_blue);
+               &gamma_blue);
   if (count == 1)
     {
       gamma_green=gamma_red;
@@ -669,54 +669,54 @@ MagickExport MagickPassFail GammaImage(Image *image,const char *level)
     if (level_blue)
       levels.blue=MagickAllocateArray(Quantum *,(MaxMap+1),sizeof(Quantum));
     if ((level_color && !levels.color) ||
-       (level_red && !levels.red) ||
-       (level_green && !levels.green) ||
-       (level_blue && !levels.blue))
+        (level_red && !levels.red) ||
+        (level_green && !levels.green) ||
+        (level_blue && !levels.blue))
       {
-       MagickFreeMemory(levels.color);
-       MagickFreeMemory(levels.red);
-       MagickFreeMemory(levels.green);
-       MagickFreeMemory(levels.blue);
-       ThrowBinaryException3(ResourceLimitError,MemoryAllocationFailed,
-                             UnableToGammaCorrectImage);
+        MagickFreeMemory(levels.color);
+        MagickFreeMemory(levels.red);
+        MagickFreeMemory(levels.green);
+        MagickFreeMemory(levels.blue);
+        ThrowBinaryException3(ResourceLimitError,MemoryAllocationFailed,
+                              UnableToGammaCorrectImage);
       }
 #if (MaxMap > 256) && defined(HAVE_OPENMP)
 #  pragma omp parallel for
 #endif
     for (i=0; i <= (long) MaxMap; i++)
       {
-       if (levels.color)
-         levels.color[i]=
-           ScaleMapToQuantum(MaxMap*GammaCorrect((double) i/MaxMap,gamma_color));
-       if (levels.red)
-         levels.red[i]=
-           ScaleMapToQuantum(MaxMap*GammaCorrect((double) i/MaxMap,gamma_red));
-       if (levels.green)
-         levels.green[i]=
-           ScaleMapToQuantum(MaxMap*GammaCorrect((double) i/MaxMap,gamma_green));
-       if (levels.blue)
-         levels.blue[i]=
-           ScaleMapToQuantum(MaxMap*GammaCorrect((double) i/MaxMap,gamma_blue));
+        if (levels.color)
+          levels.color[i]=
+            ScaleMapToQuantum(MaxMap*GammaCorrect((double) i/MaxMap,gamma_color));
+        if (levels.red)
+          levels.red[i]=
+            ScaleMapToQuantum(MaxMap*GammaCorrect((double) i/MaxMap,gamma_red));
+        if (levels.green)
+          levels.green[i]=
+            ScaleMapToQuantum(MaxMap*GammaCorrect((double) i/MaxMap,gamma_green));
+        if (levels.blue)
+          levels.blue[i]=
+            ScaleMapToQuantum(MaxMap*GammaCorrect((double) i/MaxMap,gamma_blue));
       }
     /*
       Apply gamma.
     */
     if (image->storage_class == PseudoClass)
       {
-       (void) ApplyLevelsDiscrete(NULL,&levels,image,image->colormap,
-                                  (IndexPacket *) NULL,image->colors,
-                                  &image->exception);
-       status=SyncImage(image);
+        (void) ApplyLevelsDiscrete(NULL,&levels,image,image->colormap,
+                                   (IndexPacket *) NULL,image->colors,
+                                   &image->exception);
+        status=SyncImage(image);
       }
     else
       {
-       status=PixelIterateMonoModify(ApplyLevelsDiscrete,
-                                     NULL,
-                                     "[%s] Applying gamma correction...",
-                                     NULL,&levels,
-                                     0,0,image->columns,image->rows,
-                                     image,
-                                     &image->exception);
+        status=PixelIterateMonoModify(ApplyLevelsDiscrete,
+                                      NULL,
+                                      "[%s] Applying gamma correction...",
+                                      NULL,&levels,
+                                      0,0,image->columns,image->rows,
+                                      image,
+                                      &image->exception);
       }
     MagickFreeMemory(levels.color);
     MagickFreeMemory(levels.red);
@@ -738,23 +738,23 @@ MagickExport MagickPassFail GammaImage(Image *image,const char *level)
     */
     if (image->storage_class == PseudoClass)
       {
-       (void) GammaCorrectPixels(NULL,&levels,image,image->colormap,
-                                  (IndexPacket *) NULL,image->colors,
-                                  &image->exception);
-       status=SyncImage(image);
+        (void) GammaCorrectPixels(NULL,&levels,image,image->colormap,
+                                   (IndexPacket *) NULL,image->colors,
+                                   &image->exception);
+        status=SyncImage(image);
       }
     else
       {
-       status=PixelIterateMonoModify(GammaCorrectPixels,
-                                     NULL,
-                                     "[%s] Applying gamma correction...",
-                                     NULL,&levels,
-                                     0,0,image->columns,image->rows,
-                                     image,
-                                     &image->exception);
+        status=PixelIterateMonoModify(GammaCorrectPixels,
+                                      NULL,
+                                      "[%s] Applying gamma correction...",
+                                      NULL,&levels,
+                                      0,0,image->columns,image->rows,
+                                      image,
+                                      &image->exception);
       }
   }
-  
+
 #endif/* if MaxMap != MaxRGB */
 
   if (image->gamma != 0.0)
@@ -803,7 +803,7 @@ MagickExport MagickPassFail LevelImage(Image *image,const char *levels)
     black_point,
     mid_point,
     white_point;
-  
+
   MagickPassFail
     status=MagickPass;
 
@@ -829,7 +829,7 @@ MagickExport MagickPassFail LevelImage(Image *image,const char *levels)
 
     const char
       *lp;
-    
+
     char
       *cp;
 
@@ -975,7 +975,7 @@ MagickExport MagickPassFail LevelImageChannel(Image *image,
       break;
     default:
       break;
-    }    
+    }
   /*
     Build leveling map.
   */
@@ -1062,9 +1062,9 @@ typedef struct _ModulateImageParameters_t
 static MagickPassFail
 ModulateImagePixels(void *mutable_data,         /* User provided mutable data */
                     const void *immutable_data, /* User provided immutable data */
-                    Image *image,               /* Modify image */
-                    PixelPacket *pixels,        /* Pixel row */
-                    IndexPacket *indexes,       /* Pixel row indexes */
+                    Image * restrict image,               /* Modify image */
+                    PixelPacket * restrict pixels,        /* Pixel row */
+                    IndexPacket * restrict indexes,       /* Pixel row indexes */
                     const long npixels,         /* Number of pixels in row */
                     ExceptionInfo *exception)   /* Exception report */
 {
@@ -1076,7 +1076,7 @@ ModulateImagePixels(void *mutable_data,         /* User provided mutable data */
 
   register long
     i;
-  
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(image);
   ARG_NOT_USED(indexes);
@@ -1097,7 +1097,7 @@ ModulateImagePixels(void *mutable_data,         /* User provided mutable data */
       saturation*=(0.01+MagickEpsilon)*param.percent_saturation;
       if (saturation > 1.0)
         saturation=1.0;
-      
+
       hue += (param.percent_hue/200.0 - 0.5);
       while (hue < 0.0)
         hue += 1.0;
@@ -1193,9 +1193,9 @@ MagickExport MagickPassFail ModulateImage(Image *image,const char *modulate)
 static MagickPassFail
 NegateImagePixels(void *mutable_data,         /* User provided mutable data */
                   const void *immutable_data, /* User provided immutable data */
-                  Image *image,               /* Modify image */
-                  PixelPacket *pixels,        /* Pixel row */
-                  IndexPacket *indexes,       /* Pixel row indexes */
+                  Image * restrict image,               /* Modify image */
+                  PixelPacket * restrict pixels,        /* Pixel row */
+                  IndexPacket * restrict indexes,       /* Pixel row indexes */
                   const long npixels,         /* Number of pixels in row */
                   ExceptionInfo *exception)   /* Exception report */
 {
@@ -1207,7 +1207,7 @@ NegateImagePixels(void *mutable_data,         /* User provided mutable data */
 
   register long
     i;
-  
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(image);
   ARG_NOT_USED(indexes);
@@ -1258,7 +1258,7 @@ MagickExport MagickPassFail NegateImage(Image *image,const unsigned int grayscal
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   is_grayscale=image->is_grayscale;
-  if (image->clip_mask)
+  if (*ImageGetClipMask(image))
     image->storage_class=DirectClass;
 
   if (image->storage_class == PseudoClass)
@@ -1306,50 +1306,50 @@ MagickExport MagickPassFail NegateImage(Image *image,const unsigned int grayscal
 /*
   Find histogram bounds based on a minimum threshold value.
 */
-#define FindHistogramBoundsAlg(Q,threshold,low,high,histogram) \
-  {                                                            \
-    double                                                     \
-      intensity;                                               \
-                                                               \
-    intensity=0.0;                                             \
-    for (low.Q=0.0; low.Q < MaxMapDouble; low.Q += 1.0)                \
-      {                                                                \
-       intensity+=histogram[(long) low.Q].Q;                   \
-       if (intensity > threshold)                              \
-         break;                                                \
-      }                                                                \
-    intensity=0.0;                                             \
-    for (high.Q=MaxMapDouble; high.Q >= 1.0; high.Q -= 1.0)    \
-      {                                                                \
-       intensity+=histogram[(long) high.Q].Q;                  \
-       if (intensity > threshold)                              \
-         break;                                                \
-      }                                                                \
+#define FindHistogramBoundsAlg(Q,threshold,low,high,histogram)  \
+  {                                                             \
+    double                                                      \
+      intensity;                                                \
+                                                                \
+    intensity=0.0;                                              \
+    for (low.Q=0.0; low.Q < MaxMapDouble; low.Q += 1.0)         \
+      {                                                         \
+        intensity+=histogram[(long) low.Q].Q;                   \
+        if (intensity > threshold)                              \
+          break;                                                \
+      }                                                         \
+    intensity=0.0;                                              \
+    for (high.Q=MaxMapDouble; high.Q >= 1.0; high.Q -= 1.0)     \
+      {                                                         \
+        intensity+=histogram[(long) high.Q].Q;                  \
+        if (intensity > threshold)                              \
+          break;                                                \
+      }                                                         \
 }
 /*
   Find histogram bounds, but with additional fallback in case
   contrast is not reasonable.
 */
-#define FindHistogramBounds(Q,threshold,low,high,histogram)    \
-  {                                                            \
-    FindHistogramBoundsAlg(Q,threshold,low,high,histogram);    \
-    if (low.red == high.red)                                   \
-      FindHistogramBoundsAlg(Q,0.0,low,high,histogram);                \
+#define FindHistogramBounds(Q,threshold,low,high,histogram)     \
+  {                                                             \
+    FindHistogramBoundsAlg(Q,threshold,low,high,histogram);     \
+    if (low.red == high.red)                                    \
+      FindHistogramBoundsAlg(Q,0.0,low,high,histogram);         \
 }
 /*
   Compute levels map entry for a quantum.
 */
-#define ComputeHistogramMapQuantum(Q,levels,low,high)                  \
-{                                                                      \
-  if (i < (long) low.Q)                                                        \
-    levels.map[i].Q=0;                                                 \
-  else                                                                 \
-    if (i > (long) high.Q)                                             \
-      levels.map[i].Q=MaxRGB;                                          \
-    else                                                               \
-      if (low.Q != high.Q)                                             \
-       levels.map[i].Q=                                                \
-         ScaleMapToQuantum((MaxMapDouble*(i-low.Q))/(high.Q-low.Q));   \
+#define ComputeHistogramMapQuantum(Q,levels,low,high)                   \
+{                                                                       \
+  if (i < (long) low.Q)                                                 \
+    levels.map[i].Q=0;                                                  \
+  else                                                                  \
+    if (i > (long) high.Q)                                              \
+      levels.map[i].Q=MaxRGB;                                           \
+    else                                                                \
+      if (low.Q != high.Q)                                              \
+        levels.map[i].Q=                                                \
+          ScaleMapToQuantum((MaxMapDouble*(i-low.Q))/(high.Q-low.Q));   \
 }
 MagickExport MagickPassFail NormalizeImage(Image *image)
 {
@@ -1395,12 +1395,12 @@ MagickExport MagickPassFail NormalizeImage(Image *image)
     }
   /*
     Find the histogram boundaries by locating the 0.1 percent levels.
-  */ 
+  */
   threshold_percent=0.1;
   MagickAttributeToDouble(image,"histogram-threshold",threshold_percent);
   threshold=(long) ((double) image->columns*image->rows*0.01*threshold_percent);
   (void) LogMagickEvent(TransformEvent,GetMagickModule(),
-                       "Histogram Threshold = %g%% (%g)", threshold_percent, threshold);
+                        "Histogram Threshold = %g%% (%g)", threshold_percent, threshold);
   FindHistogramBounds(red,threshold,low,high,histogram);
   FindHistogramBounds(green,threshold,low,high,histogram);
   FindHistogramBounds(blue,threshold,low,high,histogram);
@@ -1423,7 +1423,7 @@ MagickExport MagickPassFail NormalizeImage(Image *image)
       ComputeHistogramMapQuantum(blue,levels,low,high);
       levels.map[i].opacity=OpaqueOpacity;
       if (image->matte)
-       ComputeHistogramMapQuantum(opacity,levels,low,high);
+        ComputeHistogramMapQuantum(opacity,levels,low,high);
     }
 
   /*
index b10b32b..95157fc 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   ImageMagick Image Enhancement Methods.
 */
 #ifndef _MAGICK_ENHANCE_H
index 90f117f..19b99e1 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2008 - 2016 GraphicsMagick Group
+% Copyright (C) 2008 - 2018 GraphicsMagick Group
 %
 % This program is covered by multiple licenses, which are described in
 % Copyright.txt. You should have received a copy of Copyright.txt with this
@@ -60,7 +60,7 @@ MagickExport const char *ChannelTypeToString(const ChannelType channel)
     case RedChannel:
       channel_type="red";
       break;
-    case CyanChannel: 
+    case CyanChannel:
       channel_type="cyan";
       break;
     case GreenChannel:
@@ -157,7 +157,7 @@ MagickExport const char *ColorspaceTypeToString(const ColorspaceType colorspace)
 {
   const char
     *colorspace_type = "?";
-  
+
   switch (colorspace)
     {
     case UndefinedColorspace:
@@ -598,6 +598,12 @@ MagickExport const char* CompressionTypeToString(const CompressionType compressi
     case JBIG2Compression:
       compression_string="JBIG2";
       break;
+    case ZSTDCompression:
+      compression_string="ZSTD";
+      break;
+    case WebPCompression:
+      compression_string="WebP";
+      break;
     }
   return compression_string;
 }
@@ -633,15 +639,20 @@ MagickExport CompressionType StringToCompressionType(const char *option)
   else if (LocaleCompare("GZip",option) == 0)
     compression_type=ZipCompression;
   else if ((LocaleCompare("LZMA",option) == 0) ||
-          (LocaleCompare("LZMA2",option) == 0))
+           (LocaleCompare("LZMA2",option) == 0))
     compression_type=LZMACompression;
   else if (LocaleCompare("JPEG2000",option) == 0)
     compression_type=JPEG2000Compression;
   else if ((LocaleCompare("JBIG",option) == 0) ||
-          (LocaleCompare("JBIG1",option) == 0))
+           (LocaleCompare("JBIG1",option) == 0))
     compression_type=JBIG1Compression;
   else if (LocaleCompare("JBIG2",option) == 0)
     compression_type=JBIG2Compression;
+  else if ((LocaleCompare("ZSTD",option) == 0) ||
+           (LocaleCompare("Zstandard",option) == 0))
+    compression_type=ZSTDCompression;
+  else if (LocaleCompare("WebP",option) == 0)
+    compression_type=WebPCompression;
 
   return compression_type;
 }
@@ -1742,7 +1753,7 @@ MagickExport VirtualPixelMethod StringToVirtualPixelMethod(const char *option)
 {
   VirtualPixelMethod
     virtual_pixel_method = UndefinedVirtualPixelMethod;
-  
+
   if (LocaleCompare("Constant",option) == 0)
     virtual_pixel_method=ConstantVirtualPixelMethod;
   else if (LocaleCompare("Edge",option) == 0)
index e66b7fa..3d6d6f4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2008 - 2014 GraphicsMagick Group
+% Copyright (C) 2008 - 2018 GraphicsMagick Group
 %
 % This program is covered by multiple licenses, which are described in
 % Copyright.txt. You should have received a copy of Copyright.txt with this
 extern "C" {
 #endif
 
-  extern MagickExport ChannelType StringToChannelType(const char *option);
-  extern MagickExport ColorspaceType StringToColorspaceType(const char *colorspace_string);
-  extern MagickExport CompositeOperator StringToCompositeOperator(const char *option);
-  extern MagickExport CompressionType StringToCompressionType(const char *option);
-  extern MagickExport EndianType StringToEndianType(const char *option);
-  extern MagickExport FilterTypes StringToFilterTypes(const char *option);
-  extern MagickExport GravityType StringToGravityType(const char *option);
-  extern MagickExport HighlightStyle StringToHighlightStyle(const char *option);
-  extern MagickExport ImageType StringToImageType(const char *option);
-  extern MagickExport InterlaceType StringToInterlaceType(const char *option);
-  extern MagickExport MetricType StringToMetricType(const char *option);
-  extern MagickExport NoiseType StringToNoiseType(const char *option);
-  extern MagickExport OrientationType StringToOrientationType(const char *option);
-  extern MagickExport PreviewType StringToPreviewType(const char *option);
-  extern MagickExport ResolutionType StringToResolutionType(const char *option);
-  extern MagickExport QuantumOperator StringToQuantumOperator(const char *option);
-  extern MagickExport ResourceType StringToResourceType(const char *option);
-  extern MagickExport VirtualPixelMethod StringToVirtualPixelMethod(const char *option); extern MagickExport const char *BlobModeToString(BlobMode blob_mode);
-  extern MagickExport const char *ChannelTypeToString(const ChannelType channel);
-  extern MagickExport const char *ClassTypeToString(const ClassType class_type);
-  extern MagickExport const char *ColorspaceTypeToString(const ColorspaceType colorspace);
-  extern MagickExport const char *CompositeOperatorToString(const CompositeOperator composite_op);
-  extern MagickExport const char *CompressionTypeToString(const CompressionType compression_type);
-  extern MagickExport const char *ConfirmAccessModeToString(const ConfirmAccessMode access_mode);
-  extern MagickExport const char *EndianTypeToString(const EndianType endian_type);
-  extern MagickExport const char *HighlightStyleToString(const HighlightStyle difference_algorithm);
-  extern MagickExport const char *ImageTypeToString(const ImageType image_type);
-  extern MagickExport const char *InterlaceTypeToString(const InterlaceType interlace_type);
-  extern MagickExport const char *MapModeToString(MapMode map_mode);
-  extern MagickExport const char *MetricTypeToString(MetricType metric);
-  extern MagickExport const char *NoiseTypeToString(NoiseType noise_type);
-  extern MagickExport const char *OrientationTypeToString(const OrientationType orientation_type);
-  extern MagickExport const char *QuantumOperatorToString(const QuantumOperator quantum_operator);
-  extern MagickExport const char *QuantumSampleTypeToString(const QuantumSampleType sample_type);
-  extern MagickExport const char *QuantumTypeToString(const QuantumType quantum_type);
-  extern MagickExport const char *ResizeFilterToString(const FilterTypes filter);
-  extern MagickExport const char *ResolutionTypeToString(const ResolutionType resolution_type);
-  extern MagickExport const char *StorageTypeToString(const StorageType storage_type);
-  extern MagickExport const char *StretchTypeToString(StretchType stretch);
-  extern MagickExport const char *StyleTypeToString(StyleType style);
+
+  extern MagickExport ChannelType StringToChannelType(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport ColorspaceType StringToColorspaceType(const char *colorspace_string) MAGICK_FUNC_PURE;
+  extern MagickExport CompositeOperator StringToCompositeOperator(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport CompressionType StringToCompressionType(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport EndianType StringToEndianType(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport FilterTypes StringToFilterTypes(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport GravityType StringToGravityType(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport HighlightStyle StringToHighlightStyle(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport ImageType StringToImageType(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport InterlaceType StringToInterlaceType(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport MetricType StringToMetricType(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport NoiseType StringToNoiseType(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport OrientationType StringToOrientationType(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport PreviewType StringToPreviewType(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport ResolutionType StringToResolutionType(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport QuantumOperator StringToQuantumOperator(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport ResourceType StringToResourceType(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport VirtualPixelMethod StringToVirtualPixelMethod(const char *option) MAGICK_FUNC_PURE;
+  extern MagickExport const char *BlobModeToString(BlobMode blob_mode) MAGICK_FUNC_CONST;
+  extern MagickExport const char *ChannelTypeToString(const ChannelType channel) MAGICK_FUNC_CONST;
+  extern MagickExport const char *ClassTypeToString(const ClassType class_type) MAGICK_FUNC_CONST;
+  extern MagickExport const char *ColorspaceTypeToString(const ColorspaceType colorspace) MAGICK_FUNC_CONST;
+  extern MagickExport const char *CompositeOperatorToString(const CompositeOperator composite_op) MAGICK_FUNC_CONST;
+  extern MagickExport const char *CompressionTypeToString(const CompressionType compression_type) MAGICK_FUNC_CONST;
+  extern MagickExport const char *ConfirmAccessModeToString(const ConfirmAccessMode access_mode) MAGICK_FUNC_CONST;
+  extern MagickExport const char *EndianTypeToString(const EndianType endian_type) MAGICK_FUNC_CONST;
+  extern MagickExport const char *HighlightStyleToString(const HighlightStyle difference_algorithm) MAGICK_FUNC_CONST;
+  extern MagickExport const char *ImageTypeToString(const ImageType image_type) MAGICK_FUNC_CONST;
+  extern MagickExport const char *InterlaceTypeToString(const InterlaceType interlace_type) MAGICK_FUNC_CONST;
+  extern MagickExport const char *MapModeToString(MapMode map_mode) MAGICK_FUNC_CONST;
+  extern MagickExport const char *MetricTypeToString(MetricType metric) MAGICK_FUNC_CONST;
+  extern MagickExport const char *NoiseTypeToString(NoiseType noise_type) MAGICK_FUNC_CONST;
+  extern MagickExport const char *OrientationTypeToString(const OrientationType orientation_type) MAGICK_FUNC_CONST;
+  extern MagickExport const char *QuantumOperatorToString(const QuantumOperator quantum_operator) MAGICK_FUNC_CONST;
+  extern MagickExport const char *QuantumSampleTypeToString(const QuantumSampleType sample_type) MAGICK_FUNC_CONST;
+  extern MagickExport const char *QuantumTypeToString(const QuantumType quantum_type) MAGICK_FUNC_CONST;
+  extern MagickExport const char *ResizeFilterToString(const FilterTypes filter) MAGICK_FUNC_CONST;
+  extern MagickExport const char *ResolutionTypeToString(const ResolutionType resolution_type) MAGICK_FUNC_CONST;
+  extern MagickExport const char *StorageTypeToString(const StorageType storage_type) MAGICK_FUNC_CONST;
+  extern MagickExport const char *StretchTypeToString(StretchType stretch) MAGICK_FUNC_CONST;
+  extern MagickExport const char *StyleTypeToString(StyleType style) MAGICK_FUNC_CONST;
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
index 617e69d..afb308f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -888,6 +888,9 @@ MagickExport void ThrowException(ExceptionInfo *exception,
 %  reason, optional description, source filename, function name, and line
 %  number. If logging is enabled, the exception is also logged.
 %
+%  If the exception already contains an ErrorException (or greater) or the
+%  existing exception is more severe, then it is ignored.
+%
 %  The format of the ThrowLoggedException method is:
 %
 %      void ThrowLoggedException(ExceptionInfo *exception,
@@ -918,7 +921,27 @@ MagickExport void ThrowLoggedException(ExceptionInfo *exception,
   const char *module,const char *function,const unsigned long line)
 {
   assert(exception != (ExceptionInfo *) NULL);
+  assert(function != (const char *) NULL);
   assert(exception->signature == MagickSignature);
+  if ((exception->severity > ErrorException) ||
+       (exception->severity > severity))
+    {
+      if (reason)
+        {
+          if (description)
+            (void) LogMagickEvent(severity,module,function,line,"Ignored: %.1024s (%.1024s)",
+                                  reason,description);
+          else
+            (void) LogMagickEvent(severity,module,function,line,"Ignored: %.1024s",
+                                  reason);
+        }
+      else
+        {
+          (void) LogMagickEvent(severity,module,function,line,
+                                "Ignored: exception contains no reason!");
+        }
+      return;
+    }
   exception->severity=(ExceptionType) severity;
   MagickFreeMemory(exception->reason);
   if (reason)
index c1ecc35..75152d9 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003, 2004 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   ImageMagick Exception Methods.
 */
 #ifndef _MAGICK_ERROR_H
index 5247bc3..4f6ba14 100644 (file)
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2003 - 2015 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
 
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Methods to export image pixels to common representations
 
 */
         *q++=(unsigned char) (value_ >> 24);    \
       }                                         \
   }
-#define ExportFloat16Quantum(endian,q,quantum)     \
-  {                                                \
-    float float_val;                               \
-    unsigned char c[2];                                    \
-                                                   \
-    float_val=(float) (quantum);                   \
+#define ExportFloat16Quantum(endian,q,quantum)      \
+  {                                                 \
+    float float_val;                                \
+    unsigned char c[2];                             \
+                                                    \
+    float_val=(float) (quantum);                    \
     (void) _Gm_convert_fp32_to_fp16(&float_val,     \
-                                   (fp_16bits *)c, \
-                                   RANGE_LIMITED); \
-    if (MyEndianType == endian)                            \
-      {                                                    \
-        *q++=c[0];                                 \
-        *q++=c[1];                                 \
-      }                                                    \
-    else                                           \
-      {                                                    \
-        *q++=c[1];                                 \
-        *q++=c[0];                                 \
-      }                                                    \
+                                    (fp_16bits *)c, \
+                                    RANGE_LIMITED); \
+    if (MyEndianType == endian)                     \
+      {                                             \
+        *q++=c[0];                                  \
+        *q++=c[1];                                  \
+      }                                             \
+    else                                            \
+      {                                             \
+        *q++=c[1];                                  \
+        *q++=c[0];                                  \
+      }                                             \
   }
-#define ExportFloat24Quantum(endian,q,quantum)         \
-  {                                                    \
-    float float_val;                                   \
-    unsigned char c[3];                                        \
-                                                       \
-    float_val=(float) (quantum);                       \
-    (void) _Gm_convert_fp32_to_fp24(&float_val,                \
-                                   (fp_24bits *)c,     \
-                                   RANGE_LIMITED);     \
-    if (MyEndianType == endian)                                \
-      {                                                        \
-        *q++=c[0];                                     \
-        *q++=c[1];                                     \
-        *q++=c[2];                                     \
-      }                                                        \
-    else                                               \
-      {                                                        \
-        *q++=c[2];                                     \
-        *q++=c[1];                                     \
-        *q++=c[0];                                     \
-      }                                                        \
+#define ExportFloat24Quantum(endian,q,quantum)          \
+  {                                                     \
+    float float_val;                                    \
+    unsigned char c[3];                                 \
+                                                        \
+    float_val=(float) (quantum);                        \
+    (void) _Gm_convert_fp32_to_fp24(&float_val,         \
+                                    (fp_24bits *)c,     \
+                                    RANGE_LIMITED);     \
+    if (MyEndianType == endian)                         \
+      {                                                 \
+        *q++=c[0];                                      \
+        *q++=c[1];                                      \
+        *q++=c[2];                                      \
+      }                                                 \
+    else                                                \
+      {                                                 \
+        *q++=c[2];                                      \
+        *q++=c[1];                                      \
+        *q++=c[0];                                      \
+      }                                                 \
   }
 #define ExportFloat32Quantum(endian,q,quantum)  \
   {                                             \
 %  (NativeEndian) endian values.  This function is quite powerful in that
 %  besides common native CPU type sizes, it can support any integer bit
 %  depth from 1 to 32 (e.g. 13), 64-bits as well as 32 and 64-bit float.
-%  
+%
 %
 %  MagickPass is returned if the pixels are successfully transferred,
 %  otherwise MagickFail.
@@ -299,7 +299,7 @@ MagickExport MagickPassFail ExportImagePixelArea(const Image *image,
 %  (NativeEndian) endian values.  This function is quite powerful in that
 %  besides common native CPU type sizes, it can support any integer bit depth
 %  from 1 to 32 (e.g. 13), 64-bits as well as 32 and 64-bit float.
-%  
+%
 %
 %  MagickPass is returned if the pixels are successfully transferred,
 %  otherwise MagickFail.
@@ -340,13 +340,13 @@ MagickExport MagickPassFail ExportImagePixelArea(const Image *image,
 */
 static MagickPassFail
 ExportIndexQuantumType(unsigned char * restrict destination,
-                      const IndexPacket * restrict indexes,
-                      const unsigned long number_pixels,
-                      const unsigned int quantum_size,
-                      const QuantumSampleType sample_type,
-                      const EndianType endian,
-                      const Image *image,
-                      unsigned long *bytes_exported)
+                       const IndexPacket * restrict indexes,
+                       const unsigned long number_pixels,
+                       const unsigned int quantum_size,
+                       const QuantumSampleType sample_type,
+                       const EndianType endian,
+                       const Image *image,
+                       unsigned long *bytes_exported)
 {
   register unsigned long
     x;
@@ -356,122 +356,126 @@ ExportIndexQuantumType(unsigned char * restrict destination,
 
   q=destination;
 
-  assert(indexes != (const IndexPacket *) NULL);
   assert(image->colors <= MaxColormapSize);
 
+  if ((image->storage_class != PseudoClass) ||
+      (image->colors == 0) ||
+      (indexes == (IndexPacket *) NULL))
+    return MagickFail;
+
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 1:
-         {
-           /*
-             Special "fast" support for two-color PsudeoClass.
-           */
-           register unsigned int
-             bit=0,
-             byte=0;
-                  
-           for (x = number_pixels; x != 0; --x)
-             {
-               byte<<=1;
-               byte |= (*indexes++ ? 1U : 0U);
-               bit++;
-               if (bit == 8)
-                 {
-                   *q++=byte;
-                   bit=0;
-                   byte=0;
-                 }
-             }
-           if (bit != 0)
-             {
-               *q++=byte << (8-bit);
-             }
-           break;
-         }
-       case 4:
-         {
-           /*
-             Special "fast" support for four-color PsudeoClass.
-           */
-           register unsigned int
-             state = 0;
-                  
-           for (x = number_pixels ; x != 0 ; --x )
-             {
-               state ^= 1; /* Produces 1 0 1 0 ... */
-               if (state)
-                 {
-                   *q = ((*indexes & 0xf) << 4);
-                 }
-               else
-                 {
-                   *q |= ((*indexes & 0xf));
-                   q++;
-                 }
-               indexes++;
-             }
-           if (1 == state)
-             {
-               q++;
-             }
-           break;
-         }
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt8Quantum(q,*indexes);
-               indexes++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt16Quantum(endian,q,*indexes);
-               indexes++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt32Quantum(endian,q,*indexes);
-               indexes++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt64Quantum(endian,q,*indexes);
-               indexes++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamWriteHandle
-             stream;
-                  
-           MagickBitStreamInitializeWrite(&stream,q);
-           for (x = number_pixels; x != 0; --x)
-             {
-               MagickBitStreamMSBWrite(&stream,quantum_size,*indexes);
-               indexes++;
-             }
-           q=stream.bytes;
-           break;
-         }
-       }
+        {
+        case 1:
+          {
+            /*
+              Special "fast" support for two-color PsudeoClass.
+            */
+            register unsigned int
+              bit=0,
+              byte=0;
+
+            for (x = number_pixels; x != 0; --x)
+              {
+                byte<<=1;
+                byte |= (*indexes++ ? 1U : 0U);
+                bit++;
+                if (bit == 8)
+                  {
+                    *q++=byte;
+                    bit=0;
+                    byte=0;
+                  }
+              }
+            if (bit != 0)
+              {
+                *q++=byte << (8-bit);
+              }
+            break;
+          }
+        case 4:
+          {
+            /*
+              Special "fast" support for four-color PsudeoClass.
+            */
+            register unsigned int
+              state = 0;
+
+            for (x = number_pixels ; x != 0 ; --x )
+              {
+                state ^= 1; /* Produces 1 0 1 0 ... */
+                if (state)
+                  {
+                    *q = ((*indexes & 0xf) << 4);
+                  }
+                else
+                  {
+                    *q |= ((*indexes & 0xf));
+                    q++;
+                  }
+                indexes++;
+              }
+            if (1 == state)
+              {
+                q++;
+              }
+            break;
+          }
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt8Quantum(q,*indexes);
+                indexes++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt16Quantum(endian,q,*indexes);
+                indexes++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt32Quantum(endian,q,*indexes);
+                indexes++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt64Quantum(endian,q,*indexes);
+                indexes++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamWriteHandle
+              stream;
+
+            MagickBitStreamInitializeWrite(&stream,q);
+            for (x = number_pixels; x != 0; --x)
+              {
+                MagickBitStreamMSBWrite(&stream,quantum_size,*indexes);
+                indexes++;
+              }
+            q=stream.bytes;
+            break;
+          }
+        }
     }
 
   /*
@@ -484,15 +488,15 @@ ExportIndexQuantumType(unsigned char * restrict destination,
 
 static MagickPassFail
 ExportIndexAlphaQuantumType(unsigned char * restrict destination,
-                           const PixelPacket * restrict pixels,
-                           const IndexPacket * restrict indexes,
-                           const unsigned long number_pixels,
-                           const unsigned int quantum_size,
-                           const QuantumSampleType sample_type,
-                           const EndianType endian,
-                           const unsigned int unsigned_scale,
-                           const Image *image,
-                           unsigned long *bytes_exported)
+                            const PixelPacket * restrict pixels,
+                            const IndexPacket * restrict indexes,
+                            const unsigned long number_pixels,
+                            const unsigned int quantum_size,
+                            const QuantumSampleType sample_type,
+                            const EndianType endian,
+                            const unsigned int unsigned_scale,
+                            const Image *image,
+                            unsigned long *bytes_exported)
 {
 
   register unsigned char
@@ -508,79 +512,85 @@ ExportIndexAlphaQuantumType(unsigned char * restrict destination,
     unsigned_value;
 
   assert(image->colors <= MaxColormapSize);
+
+  if ((image->storage_class != PseudoClass) ||
+      (image->colors == 0) ||
+      (indexes == (IndexPacket *) NULL))
+    return MagickFail;
+
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt8Quantum(q,*indexes);
-               ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
-               indexes++;
-               p++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt16Quantum(endian,q,*indexes);
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
-               indexes++;
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt32Quantum(endian,q,*indexes);
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-               indexes++;
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt64Quantum(endian,q,*indexes);
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-               indexes++;
-               p++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamWriteHandle
-             stream;
-                  
-           MagickBitStreamInitializeWrite(&stream,q);
-           for (x = number_pixels; x != 0; --x)
-             {
-               MagickBitStreamMSBWrite(&stream,quantum_size,*indexes);
-               unsigned_value=MaxRGB-GetOpacitySample(p);
-               if (QuantumDepth >  quantum_size)
-                 unsigned_value /= unsigned_scale;
-               else if (QuantumDepth <  quantum_size)
-                 unsigned_value *= unsigned_scale;
-               MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
-               indexes++;
-               p++;
-             }
-           q=stream.bytes;
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt8Quantum(q,*indexes);
+                ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
+                indexes++;
+                p++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt16Quantum(endian,q,*indexes);
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
+                indexes++;
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt32Quantum(endian,q,*indexes);
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                indexes++;
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt64Quantum(endian,q,*indexes);
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                indexes++;
+                p++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamWriteHandle
+              stream;
+
+            MagickBitStreamInitializeWrite(&stream,q);
+            for (x = number_pixels; x != 0; --x)
+              {
+                MagickBitStreamMSBWrite(&stream,quantum_size,*indexes);
+                unsigned_value=MaxRGB-GetOpacitySample(p);
+                if (QuantumDepth >  quantum_size)
+                  unsigned_value /= unsigned_scale;
+                else if (QuantumDepth <  quantum_size)
+                  unsigned_value *= unsigned_scale;
+                MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
+                indexes++;
+                p++;
+              }
+            q=stream.bytes;
+            break;
+          }
+        }
     }
 
   /*
@@ -593,19 +603,19 @@ ExportIndexAlphaQuantumType(unsigned char * restrict destination,
 
 static MagickPassFail
 ExportGrayQuantumType(unsigned char * restrict destination,
-                     const PixelPacket * restrict pixels,
-                     const IndexPacket * restrict indexes,
-                     const unsigned long number_pixels,
-                     const unsigned int quantum_size,
-                     const QuantumSampleType sample_type,
-                     const EndianType endian,
-                     const unsigned int unsigned_scale,
-                     const MagickBool grayscale_miniswhite,
-                     const unsigned int sample_bits,
-                     const double double_minvalue,
-                     const double double_scale,
-                     const Image *image,
-                     unsigned long *bytes_exported)
+                      const PixelPacket * restrict pixels,
+                      const IndexPacket * restrict indexes,
+                      const unsigned long number_pixels,
+                      const unsigned int quantum_size,
+                      const QuantumSampleType sample_type,
+                      const EndianType endian,
+                      const unsigned int unsigned_scale,
+                      const MagickBool grayscale_miniswhite,
+                      const unsigned int sample_bits,
+                      const double double_minvalue,
+                      const double double_scale,
+                      const Image *image,
+                      unsigned long *bytes_exported)
 {
 
   register unsigned char
@@ -623,358 +633,359 @@ ExportGrayQuantumType(unsigned char * restrict destination,
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 1:
-         {
-           if (image->storage_class == PseudoClass)
-             {
-               /*
-                 Special "fast" support for two-color PsudeoClass.
-               */
-               register unsigned int
-                 bit=0U,
-                 byte=0U,
-                 polarity;
-
-               polarity=PixelIntensityToQuantum(&image->colormap[0]) < (MaxRGB/2);
-               if (image->colors == 2U)
-                 polarity=PixelIntensityToQuantum(&image->colormap[0]) <
-                   PixelIntensityToQuantum(&image->colormap[1]);
-               if (grayscale_miniswhite)
-                 polarity=!polarity;
-                      
-               for (x = number_pixels; x != 0UL; --x)
-                 {
-                   byte <<= 1U;
-                   if (*indexes++ == polarity)
-                     byte |= 1U;
-                   bit++;
-                   if (bit == 8U)
-                     {
-                       *q++=byte;
-                       bit=0U;
-                       byte=0U;
-                     }
-                 }
-               if (bit != 0U)
-                 {
-                   *q++=byte << (8U-bit);
-                 }
-             }
-           else
-             {
-               /*
-                 Special "fast" support for bi-level gray.
-                 Performs 50% thresholding for best appearance.
-               */
-               register unsigned int
-                 bit=0U,
-                 byte=0U,
-                 black=0U,
-                 white=1U;
-
-               if (grayscale_miniswhite)
-                 {
-                   black=1U;
-                   white=0U;
-                 }
-
-               for (x = number_pixels ; x != 0UL ; --x )
-                 {
-                   if (image->is_grayscale)
-                     unsigned_value=GetGraySample(p);
-                   else
-                     unsigned_value=PixelIntensityToQuantum(p);
-                   byte <<= 1;
-                   byte |= ((unsigned_value > MaxRGB/2U) ? white : black);
-                   bit++;
-                   if (bit == 8U)
-                     {
-                       *q++=byte;
-                       bit=0U;
-                       byte=0U;
-                     }
-                   p++;
-                 }
-               if (bit != 0)
-                 {
-                   *q++=byte << (8-bit);
-                 }
-             }
-           break;
-         }
-       case 8:
-         {
-           if (image->is_grayscale)
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetGraySample(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt8Quantum(q,ScaleQuantumToChar(GetGraySample(p)));
-                       p++;
-                     }
-                 }
-             }
-           else
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-PixelIntensityToQuantum(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt8Quantum(q,ScaleQuantumToChar(PixelIntensityToQuantum(p)));
-                       p++;
-                     }
-                 }
-             }
-           break;
-         }
-       case 16:
-         {
-           if (image->is_grayscale)
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetGraySample(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetGraySample(p)));
-                       p++;
-                     }
-                 }
-             }
-           else
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-PixelIntensityToQuantum(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt16Quantum(endian,q,ScaleQuantumToShort(PixelIntensityToQuantum(p)));
-                       p++;
-                     }
-                 }
-             }
-           break;
-         }
-       case 32:
-         {
-           if (image->is_grayscale)
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetGraySample(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetGraySample(p)));
-                       p++;
-                     }
-                 }
-             }
-           else
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-PixelIntensityToQuantum(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt32Quantum(endian,q,ScaleQuantumToLong(PixelIntensityToQuantum(p)));
-                       p++;
-                     }
-                 }
-             }
-           break;
-         }
-       case 64:
-         {
-           if (image->is_grayscale)
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetGraySample(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetGraySample(p)));
-                       p++;
-                     }
-                 }
-             }
-           else
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-PixelIntensityToQuantum(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt64Quantum(endian,q,ScaleQuantumToLong(PixelIntensityToQuantum(p)));
-                       p++;
-                     }
-                 }
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamWriteHandle
-             stream;
-
-           MagickBitStreamInitializeWrite(&stream,q);
-           if(QuantumDepth == sample_bits)
-             {
-               /* Unity scale */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   if (image->is_grayscale)
-                     unsigned_value=GetGraySample(p);
-                   else
-                     unsigned_value=PixelIntensityToQuantum(p);
-                   if (grayscale_miniswhite)
-                     unsigned_value=MaxRGB-unsigned_value;
-                   MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
-                   p++;
-                 }
-             }
-           else if (QuantumDepth >  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   if (image->is_grayscale)
-                     unsigned_value=GetGraySample(p);
-                   else
-                     unsigned_value=PixelIntensityToQuantum(p);
-                   if (grayscale_miniswhite)
-                     unsigned_value=MaxRGB-unsigned_value;
-                   unsigned_value /= unsigned_scale;
-                   MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
-                   p++;
-                 }
-             }
-           else
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   if (image->is_grayscale)
-                     unsigned_value=GetGraySample(p);
-                   else
-                     unsigned_value=PixelIntensityToQuantum(p);
-                   if (grayscale_miniswhite)
-                     unsigned_value=MaxRGB-unsigned_value;
-                   unsigned_value *= unsigned_scale;
-                   MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
-                   p++;
-                 }
-             }
-           q=stream.bytes;
-           break;
-         }
-       }
+        {
+        case 1:
+          {
+            if ((image->storage_class == PseudoClass) &&
+                (indexes != (IndexPacket *) NULL))
+              {
+                /*
+                  Special "fast" support for two-color PsudeoClass.
+                */
+                register unsigned int
+                  bit=0U,
+                  byte=0U,
+                  polarity;
+
+                polarity=PixelIntensityToQuantum(&image->colormap[0]) < (MaxRGB/2);
+                if (image->colors == 2U)
+                  polarity=PixelIntensityToQuantum(&image->colormap[0]) <
+                    PixelIntensityToQuantum(&image->colormap[1]);
+                if (grayscale_miniswhite)
+                  polarity=!polarity;
+
+                for (x = number_pixels; x != 0UL; --x)
+                  {
+                    byte <<= 1U;
+                    if (*indexes++ == polarity)
+                      byte |= 1U;
+                    bit++;
+                    if (bit == 8U)
+                      {
+                        *q++=byte;
+                        bit=0U;
+                        byte=0U;
+                      }
+                  }
+                if (bit != 0U)
+                  {
+                    *q++=byte << (8U-bit);
+                  }
+              }
+            else
+              {
+                /*
+                  Special "fast" support for bi-level gray.
+                  Performs 50% thresholding for best appearance.
+                */
+                register unsigned int
+                  bit=0U,
+                  byte=0U,
+                  black=0U,
+                  white=1U;
+
+                if (grayscale_miniswhite)
+                  {
+                    black=1U;
+                    white=0U;
+                  }
+
+                for (x = number_pixels ; x != 0UL ; --x )
+                  {
+                    if (image->is_grayscale)
+                      unsigned_value=GetGraySample(p);
+                    else
+                      unsigned_value=PixelIntensityToQuantum(p);
+                    byte <<= 1;
+                    byte |= ((unsigned_value > MaxRGB/2U) ? white : black);
+                    bit++;
+                    if (bit == 8U)
+                      {
+                        *q++=byte;
+                        bit=0U;
+                        byte=0U;
+                      }
+                    p++;
+                  }
+                if (bit != 0)
+                  {
+                    *q++=byte << (8-bit);
+                  }
+              }
+            break;
+          }
+        case 8:
+          {
+            if (image->is_grayscale)
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetGraySample(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt8Quantum(q,ScaleQuantumToChar(GetGraySample(p)));
+                        p++;
+                      }
+                  }
+              }
+            else
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-PixelIntensityToQuantum(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt8Quantum(q,ScaleQuantumToChar(PixelIntensityToQuantum(p)));
+                        p++;
+                      }
+                  }
+              }
+            break;
+          }
+        case 16:
+          {
+            if (image->is_grayscale)
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetGraySample(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetGraySample(p)));
+                        p++;
+                      }
+                  }
+              }
+            else
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-PixelIntensityToQuantum(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt16Quantum(endian,q,ScaleQuantumToShort(PixelIntensityToQuantum(p)));
+                        p++;
+                      }
+                  }
+              }
+            break;
+          }
+        case 32:
+          {
+            if (image->is_grayscale)
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetGraySample(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetGraySample(p)));
+                        p++;
+                      }
+                  }
+              }
+            else
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-PixelIntensityToQuantum(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt32Quantum(endian,q,ScaleQuantumToLong(PixelIntensityToQuantum(p)));
+                        p++;
+                      }
+                  }
+              }
+            break;
+          }
+        case 64:
+          {
+            if (image->is_grayscale)
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetGraySample(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetGraySample(p)));
+                        p++;
+                      }
+                  }
+              }
+            else
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-PixelIntensityToQuantum(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt64Quantum(endian,q,ScaleQuantumToLong(PixelIntensityToQuantum(p)));
+                        p++;
+                      }
+                  }
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamWriteHandle
+              stream;
+
+            MagickBitStreamInitializeWrite(&stream,q);
+            if(QuantumDepth == sample_bits)
+              {
+                /* Unity scale */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    if (image->is_grayscale)
+                      unsigned_value=GetGraySample(p);
+                    else
+                      unsigned_value=PixelIntensityToQuantum(p);
+                    if (grayscale_miniswhite)
+                      unsigned_value=MaxRGB-unsigned_value;
+                    MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
+                    p++;
+                  }
+              }
+            else if (QuantumDepth >  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    if (image->is_grayscale)
+                      unsigned_value=GetGraySample(p);
+                    else
+                      unsigned_value=PixelIntensityToQuantum(p);
+                    if (grayscale_miniswhite)
+                      unsigned_value=MaxRGB-unsigned_value;
+                    unsigned_value /= unsigned_scale;
+                    MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
+                    p++;
+                  }
+              }
+            else
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    if (image->is_grayscale)
+                      unsigned_value=GetGraySample(p);
+                    else
+                      unsigned_value=PixelIntensityToQuantum(p);
+                    if (grayscale_miniswhite)
+                      unsigned_value=MaxRGB-unsigned_value;
+                    unsigned_value *= unsigned_scale;
+                    MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
+                    p++;
+                  }
+              }
+            q=stream.bytes;
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat16Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat24Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat32Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat64Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat16Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat24Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat32Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat64Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   /*
@@ -987,18 +998,18 @@ ExportGrayQuantumType(unsigned char * restrict destination,
 
 static MagickPassFail
 ExportGrayAlphaQuantumType(unsigned char * restrict destination,
-                          const PixelPacket * restrict pixels,
-                          const unsigned long number_pixels,
-                          const unsigned int quantum_size,
-                          const QuantumSampleType sample_type,
-                          const EndianType endian,
-                          const unsigned int unsigned_scale,
-                          const MagickBool grayscale_miniswhite,
-                          const unsigned int sample_bits,
-                          const double double_minvalue,
-                          const double double_scale,
-                          const Image *image,
-                          unsigned long *bytes_exported)
+                           const PixelPacket * restrict pixels,
+                           const unsigned long number_pixels,
+                           const unsigned int quantum_size,
+                           const QuantumSampleType sample_type,
+                           const EndianType endian,
+                           const unsigned int unsigned_scale,
+                           const MagickBool grayscale_miniswhite,
+                           const unsigned int sample_bits,
+                           const double double_minvalue,
+                           const double double_scale,
+                           const Image *image,
+                           unsigned long *bytes_exported)
 {
 
   register unsigned char
@@ -1016,304 +1027,304 @@ ExportGrayAlphaQuantumType(unsigned char * restrict destination,
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           if (image->is_grayscale)
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetRedSample(p)));
-                       ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt8Quantum(q,ScaleQuantumToChar(GetRedSample(p)));
-                       ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-             }
-           else
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-PixelIntensityToQuantum(p)));
-                       ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt8Quantum(q,ScaleQuantumToChar(PixelIntensityToQuantum(p)));
-                       ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-             }
-           break;
-         }
-       case 16:
-         {
-           if (image->is_grayscale)
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetRedSample(p)));
-                       ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetRedSample(p)));
-                       ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-             }
-           else
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-PixelIntensityToQuantum(p)));
-                       ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt16Quantum(endian,q,ScaleQuantumToShort(PixelIntensityToQuantum(p)));
-                       ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-             }
-           break;
-         }
-       case 32:
-         {
-           if (image->is_grayscale)
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetRedSample(p)));
-                       ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
-                       ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-             }
-           else
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-PixelIntensityToQuantum(p)));
-                       ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt32Quantum(endian,q,ScaleQuantumToLong(PixelIntensityToQuantum(p)));
-                       ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-             }
-           break;
-         }
-       case 64:
-         {
-           if (image->is_grayscale)
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetRedSample(p)));
-                       ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
-                       ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-             }
-           else
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-PixelIntensityToQuantum(p)));
-                       ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ExportUInt64Quantum(endian,q,ScaleQuantumToLong(PixelIntensityToQuantum(p)));
-                       ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-                       p++;
-                     }
-                 }
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamWriteHandle
-             stream;
-                  
-           MagickBitStreamInitializeWrite(&stream,q);
-           if( QuantumDepth == sample_bits)
-             {
-               /* Unity scale */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   if (image->is_grayscale)
-                     unsigned_value=GetRedSample(p);
-                   else
-                     unsigned_value=PixelIntensityToQuantum(p);
-                   if (grayscale_miniswhite)
-                     unsigned_value=MaxRGB-unsigned_value;
-                   MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,MaxRGB-GetOpacitySample(p));
-                   p++;
-                 }
-             }
-           else if (QuantumDepth >  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   if (image->is_grayscale)
-                     unsigned_value=GetRedSample(p);
-                   else
-                     unsigned_value=PixelIntensityToQuantum(p);
-                   if (grayscale_miniswhite)
-                     unsigned_value=MaxRGB-unsigned_value;
-                   unsigned_value /= unsigned_scale;
-                   MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           (MaxRGB-GetOpacitySample(p))/unsigned_scale);
-                   p++;
-                 }
-             }
-           else
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   if (image->is_grayscale)
-                     unsigned_value=GetRedSample(p);
-                   else
-                     unsigned_value=PixelIntensityToQuantum(p);
-                   if (grayscale_miniswhite)
-                     unsigned_value=MaxRGB-unsigned_value;
-                   unsigned_value *= unsigned_scale;
-                   MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           (MaxRGB-GetOpacitySample(p))*unsigned_scale);
-                   p++;
-                 }
-             }
-           q=stream.bytes;
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            if (image->is_grayscale)
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetRedSample(p)));
+                        ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt8Quantum(q,ScaleQuantumToChar(GetRedSample(p)));
+                        ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+              }
+            else
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-PixelIntensityToQuantum(p)));
+                        ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt8Quantum(q,ScaleQuantumToChar(PixelIntensityToQuantum(p)));
+                        ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+              }
+            break;
+          }
+        case 16:
+          {
+            if (image->is_grayscale)
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetRedSample(p)));
+                        ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetRedSample(p)));
+                        ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+              }
+            else
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-PixelIntensityToQuantum(p)));
+                        ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt16Quantum(endian,q,ScaleQuantumToShort(PixelIntensityToQuantum(p)));
+                        ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+              }
+            break;
+          }
+        case 32:
+          {
+            if (image->is_grayscale)
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetRedSample(p)));
+                        ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
+                        ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+              }
+            else
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-PixelIntensityToQuantum(p)));
+                        ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt32Quantum(endian,q,ScaleQuantumToLong(PixelIntensityToQuantum(p)));
+                        ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+              }
+            break;
+          }
+        case 64:
+          {
+            if (image->is_grayscale)
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetRedSample(p)));
+                        ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
+                        ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+              }
+            else
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-PixelIntensityToQuantum(p)));
+                        ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ExportUInt64Quantum(endian,q,ScaleQuantumToLong(PixelIntensityToQuantum(p)));
+                        ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                        p++;
+                      }
+                  }
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamWriteHandle
+              stream;
+
+            MagickBitStreamInitializeWrite(&stream,q);
+            if( QuantumDepth == sample_bits)
+              {
+                /* Unity scale */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    if (image->is_grayscale)
+                      unsigned_value=GetRedSample(p);
+                    else
+                      unsigned_value=PixelIntensityToQuantum(p);
+                    if (grayscale_miniswhite)
+                      unsigned_value=MaxRGB-unsigned_value;
+                    MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,MaxRGB-GetOpacitySample(p));
+                    p++;
+                  }
+              }
+            else if (QuantumDepth >  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    if (image->is_grayscale)
+                      unsigned_value=GetRedSample(p);
+                    else
+                      unsigned_value=PixelIntensityToQuantum(p);
+                    if (grayscale_miniswhite)
+                      unsigned_value=MaxRGB-unsigned_value;
+                    unsigned_value /= unsigned_scale;
+                    MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            (MaxRGB-GetOpacitySample(p))/unsigned_scale);
+                    p++;
+                  }
+              }
+            else
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    if (image->is_grayscale)
+                      unsigned_value=GetRedSample(p);
+                    else
+                      unsigned_value=PixelIntensityToQuantum(p);
+                    if (grayscale_miniswhite)
+                      unsigned_value=MaxRGB-unsigned_value;
+                    unsigned_value *= unsigned_scale;
+                    MagickBitStreamMSBWrite(&stream,quantum_size,unsigned_value);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            (MaxRGB-GetOpacitySample(p))*unsigned_scale);
+                    p++;
+                  }
+              }
+            q=stream.bytes;
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat16Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
-               ExportFloat16Quantum(endian,q,(((double) MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue));
-               p++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat24Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
-               ExportFloat24Quantum(endian,q,(((double) MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue));
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat32Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
-               ExportFloat32Quantum(endian,q,(((double) MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue));
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat64Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
-               ExportFloat64Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat16Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
+                ExportFloat16Quantum(endian,q,(((double) MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue));
+                p++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat24Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
+                ExportFloat24Quantum(endian,q,(((double) MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue));
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat32Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
+                ExportFloat32Quantum(endian,q,(((double) MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue));
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat64Quantum(endian,q,PixelIntensity(p)*double_scale+double_minvalue);
+                ExportFloat64Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   /*
@@ -1326,16 +1337,16 @@ ExportGrayAlphaQuantumType(unsigned char * restrict destination,
 
 static MagickPassFail
 ExportRedQuantumType(unsigned char * restrict destination,
-                    const PixelPacket * restrict pixels,
-                    const unsigned long number_pixels,
-                    const unsigned int quantum_size,
-                    const QuantumSampleType sample_type,
-                    const EndianType endian,
-                    const unsigned int unsigned_scale,
-                    const unsigned int sample_bits,
-                    const double double_minvalue,
-                    const double double_scale,
-                    unsigned long *bytes_exported)
+                     const PixelPacket * restrict pixels,
+                     const unsigned long number_pixels,
+                     const unsigned int quantum_size,
+                     const QuantumSampleType sample_type,
+                     const EndianType endian,
+                     const unsigned int unsigned_scale,
+                     const unsigned int sample_bits,
+                     const double double_minvalue,
+                     const double double_scale,
+                     unsigned long *bytes_exported)
 {
 
   register unsigned char
@@ -1350,133 +1361,133 @@ ExportRedQuantumType(unsigned char * restrict destination,
   if (sample_type == UnsignedQuantumSampleType)
     {
       /*
-       Modulo-8 sample sizes
+        Modulo-8 sample sizes
       */
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetRedSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetRedSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
-               p++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamWriteHandle
-             stream;
-                  
-           MagickBitStreamInitializeWrite(&stream,q);
-           if( QuantumDepth == sample_bits)
-             {
-               /* Unity scale */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           GetRedSample(p));
-                   p++;
-                 }
-             }
-           else if (QuantumDepth >  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           GetRedSample(p)/unsigned_scale);
-                   p++;
-                 }
-             }
-           else
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           GetRedSample(p)*unsigned_scale);
-                   p++;
-                 }
-             }
-           q=stream.bytes;
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetRedSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetRedSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
+                p++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamWriteHandle
+              stream;
+
+            MagickBitStreamInitializeWrite(&stream,q);
+            if( QuantumDepth == sample_bits)
+              {
+                /* Unity scale */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            GetRedSample(p));
+                    p++;
+                  }
+              }
+            else if (QuantumDepth >  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            GetRedSample(p)/unsigned_scale);
+                    p++;
+                  }
+              }
+            else
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            GetRedSample(p)*unsigned_scale);
+                    p++;
+                  }
+              }
+            q=stream.bytes;
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat16Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat24Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat32Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat64Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat16Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat24Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat32Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat64Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   /*
@@ -1489,16 +1500,16 @@ ExportRedQuantumType(unsigned char * restrict destination,
 
 static MagickPassFail
 ExportGreenQuantumType(unsigned char * restrict destination,
-                      const PixelPacket * restrict pixels,
-                      const unsigned long number_pixels,
-                      const unsigned int quantum_size,
-                      const QuantumSampleType sample_type,
-                      const EndianType endian,
-                      const unsigned int unsigned_scale,
-                      const unsigned int sample_bits,
-                      const double double_minvalue,
-                      const double double_scale,
-                      unsigned long *bytes_exported)
+                       const PixelPacket * restrict pixels,
+                       const unsigned long number_pixels,
+                       const unsigned int quantum_size,
+                       const QuantumSampleType sample_type,
+                       const EndianType endian,
+                       const unsigned int unsigned_scale,
+                       const unsigned int sample_bits,
+                       const double double_minvalue,
+                       const double double_scale,
+                       unsigned long *bytes_exported)
 {
   register unsigned char
     *q = destination;
@@ -1512,133 +1523,133 @@ ExportGreenQuantumType(unsigned char * restrict destination,
   if (sample_type == UnsignedQuantumSampleType)
     {
       /*
-       Modulo-8 sample sizes
+        Modulo-8 sample sizes
       */
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetGreenSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetGreenSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetGreenSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetGreenSample(p)));
-               p++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamWriteHandle
-             stream;
-                  
-           MagickBitStreamInitializeWrite(&stream,q);
-           if( QuantumDepth == sample_bits)
-             {
-               /* Unity scale */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           GetGreenSample(p));
-                   p++;
-                 }
-             }
-           else if (QuantumDepth >  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           GetGreenSample(p)/unsigned_scale);
-                   p++;
-                 }
-             }
-           else
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           GetGreenSample(p)*unsigned_scale);
-                   p++;
-                 }
-             }
-           q=stream.bytes;
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetGreenSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetGreenSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetGreenSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetGreenSample(p)));
+                p++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamWriteHandle
+              stream;
+
+            MagickBitStreamInitializeWrite(&stream,q);
+            if( QuantumDepth == sample_bits)
+              {
+                /* Unity scale */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            GetGreenSample(p));
+                    p++;
+                  }
+              }
+            else if (QuantumDepth >  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            GetGreenSample(p)/unsigned_scale);
+                    p++;
+                  }
+              }
+            else
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            GetGreenSample(p)*unsigned_scale);
+                    p++;
+                  }
+              }
+            q=stream.bytes;
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat16Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat24Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat32Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat64Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat16Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat24Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat32Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat64Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   /*
@@ -1651,16 +1662,16 @@ ExportGreenQuantumType(unsigned char * restrict destination,
 
 static MagickPassFail
 ExportBlueQuantumType(unsigned char * restrict destination,
-                     const PixelPacket * restrict pixels,
-                     const unsigned long number_pixels,
-                     const unsigned int quantum_size,
-                     const QuantumSampleType sample_type,
-                     const EndianType endian,
-                     const unsigned int unsigned_scale,
-                     const unsigned int sample_bits,
-                     const double double_minvalue,
-                     const double double_scale,
-                     unsigned long *bytes_exported)
+                      const PixelPacket * restrict pixels,
+                      const unsigned long number_pixels,
+                      const unsigned int quantum_size,
+                      const QuantumSampleType sample_type,
+                      const EndianType endian,
+                      const unsigned int unsigned_scale,
+                      const unsigned int sample_bits,
+                      const double double_minvalue,
+                      const double double_scale,
+                      unsigned long *bytes_exported)
 {
   register unsigned char
     *q = destination;
@@ -1674,133 +1685,133 @@ ExportBlueQuantumType(unsigned char * restrict destination,
   if (sample_type == UnsignedQuantumSampleType)
     {
       /*
-       Modulo-8 sample sizes
+        Modulo-8 sample sizes
       */
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetBlueSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetBlueSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetBlueSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetBlueSample(p)));
-               p++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamWriteHandle
-             stream;
-                  
-           MagickBitStreamInitializeWrite(&stream,q);
-           if( QuantumDepth == sample_bits)
-             {
-               /* Unity scale */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           GetBlueSample(p));
-                   p++;
-                 }
-             }
-           else if (QuantumDepth >  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           GetBlueSample(p)/unsigned_scale);
-                   p++;
-                 }
-             }
-           else
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           GetBlueSample(p)*unsigned_scale);
-                   p++;
-                 }
-             }
-           q=stream.bytes;
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetBlueSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetBlueSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetBlueSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetBlueSample(p)));
+                p++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamWriteHandle
+              stream;
+
+            MagickBitStreamInitializeWrite(&stream,q);
+            if( QuantumDepth == sample_bits)
+              {
+                /* Unity scale */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            GetBlueSample(p));
+                    p++;
+                  }
+              }
+            else if (QuantumDepth >  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            GetBlueSample(p)/unsigned_scale);
+                    p++;
+                  }
+              }
+            else
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            GetBlueSample(p)*unsigned_scale);
+                    p++;
+                  }
+              }
+            q=stream.bytes;
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat16Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat24Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat32Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat64Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat16Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat24Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat32Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat64Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   /*
@@ -1813,18 +1824,18 @@ ExportBlueQuantumType(unsigned char * restrict destination,
 
 static MagickPassFail
 ExportAlphaQuantumType(unsigned char * restrict destination,
-                      const PixelPacket * restrict pixels,
-                      const IndexPacket * restrict indexes,
-                      const unsigned long number_pixels,
-                      const unsigned int quantum_size,
-                      const QuantumSampleType sample_type,
-                      const EndianType endian,
-                      const unsigned int unsigned_scale,
-                      const unsigned int sample_bits,
-                      const double double_minvalue,
-                      const double double_scale,
-                      const Image *image,
-                      unsigned long *bytes_exported)
+                       const PixelPacket * restrict pixels,
+                       const IndexPacket * restrict indexes,
+                       const unsigned long number_pixels,
+                       const unsigned int quantum_size,
+                       const QuantumSampleType sample_type,
+                       const EndianType endian,
+                       const unsigned int unsigned_scale,
+                       const unsigned int sample_bits,
+                       const double double_minvalue,
+                       const double double_scale,
+                       const Image *image,
+                       unsigned long *bytes_exported)
 {
   register unsigned char
     *q = destination;
@@ -1837,266 +1848,269 @@ ExportAlphaQuantumType(unsigned char * restrict destination,
 
   if (image->colorspace == CMYKColorspace)
     {
+      if (indexes == (IndexPacket *) NULL)
+        return MagickFail;
+
       if (sample_type == UnsignedQuantumSampleType)
-       {
-         switch (quantum_size)
-           {
-           case 8:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-*indexes));
-                   indexes++;
-                 }
-               break;
-             }
-           case 16:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-*indexes));
-                   indexes++;
-                 }
-               break;
-             }
-           case 32:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-*indexes));
-                   indexes++;
-                 }
-               break;
-             }
-           case 64:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-*indexes));
-                   indexes++;
-                 }
-               break;
-             }
-           default:
-             {
-               /*
-                 Arbitrary sample size
-               */
-               BitStreamWriteHandle
-                 stream;
-                      
-               MagickBitStreamInitializeWrite(&stream,q);
-               if( QuantumDepth == sample_bits)
-                 {
-                   /* Unity scale */
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       MagickBitStreamMSBWrite(&stream,quantum_size,
-                                               MaxRGB-*indexes);
-                       indexes++;
-                     }
-                 }
-               else if (QuantumDepth >  sample_bits)
-                 {
-                   /* Scale down */
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       MagickBitStreamMSBWrite(&stream,quantum_size,
-                                               (MaxRGB-*indexes)/unsigned_scale);
-                       indexes++;
-                     }
-                 }
-               else
-                 {
-                   /* Scale up */
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       MagickBitStreamMSBWrite(&stream,quantum_size,
-                                               (MaxRGB-*indexes)*unsigned_scale);
-                       indexes++;
-                     }
-                 }
-               q=stream.bytes;
-               break;
-             }
-           }
-       }
+        {
+          switch (quantum_size)
+            {
+            case 8:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-*indexes));
+                    indexes++;
+                  }
+                break;
+              }
+            case 16:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-*indexes));
+                    indexes++;
+                  }
+                break;
+              }
+            case 32:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-*indexes));
+                    indexes++;
+                  }
+                break;
+              }
+            case 64:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-*indexes));
+                    indexes++;
+                  }
+                break;
+              }
+            default:
+              {
+                /*
+                  Arbitrary sample size
+                */
+                BitStreamWriteHandle
+                  stream;
+
+                MagickBitStreamInitializeWrite(&stream,q);
+                if( QuantumDepth == sample_bits)
+                  {
+                    /* Unity scale */
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        MagickBitStreamMSBWrite(&stream,quantum_size,
+                                                MaxRGB-*indexes);
+                        indexes++;
+                      }
+                  }
+                else if (QuantumDepth >  sample_bits)
+                  {
+                    /* Scale down */
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        MagickBitStreamMSBWrite(&stream,quantum_size,
+                                                (MaxRGB-*indexes)/unsigned_scale);
+                        indexes++;
+                      }
+                  }
+                else
+                  {
+                    /* Scale up */
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        MagickBitStreamMSBWrite(&stream,quantum_size,
+                                                (MaxRGB-*indexes)*unsigned_scale);
+                        indexes++;
+                      }
+                  }
+                q=stream.bytes;
+                break;
+              }
+            }
+        }
       else if (sample_type == FloatQuantumSampleType)
-       {
-         switch (quantum_size)
-           {
-           case 16:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportFloat16Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
-                   p++;
-                 }
-               break;
-             }
-           case 24:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportFloat24Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
-                   p++;
-                 }
-               break;
-             }
-           case 32:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportFloat32Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
-                   p++;
-                 }
-               break;
-             }
-           case 64:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportFloat64Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
-                   p++;
-                 }
-               break;
-             }
-           default:
-             break;
-           }
-       }
-      
+        {
+          switch (quantum_size)
+            {
+            case 16:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportFloat16Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
+                    p++;
+                  }
+                break;
+              }
+            case 24:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportFloat24Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
+                    p++;
+                  }
+                break;
+              }
+            case 32:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportFloat32Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
+                    p++;
+                  }
+                break;
+              }
+            case 64:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportFloat64Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
+                    p++;
+                  }
+                break;
+              }
+            default:
+              break;
+            }
+        }
+
     }
   else
-    { 
+    {
       if (sample_type == UnsignedQuantumSampleType)
-       {
-         switch (quantum_size)
-           {
-           case 8:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
-                   p++;
-                 }
-               break;
-             }
-           case 16:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
-                   p++;
-                 }
-               break;
-             }
-           case 32:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-                   p++;
-                 }
-               break;
-             }
-           case 64:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-                   p++;
-                 }
-               break;
-             }
-           default:
-             {
-               /*
-                 Arbitrary sample size
-               */
-               BitStreamWriteHandle
-                 stream;
-                  
-               MagickBitStreamInitializeWrite(&stream,q);
-               if( QuantumDepth == sample_bits)
-                 {
-                   /* Unity scale */
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       MagickBitStreamMSBWrite(&stream,quantum_size,
-                                               MaxRGB-GetOpacitySample(p));
-                       p++;
-                     }
-                 }
-               else if (QuantumDepth >  sample_bits)
-                 {
-                   /* Scale down */
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       MagickBitStreamMSBWrite(&stream,quantum_size,
-                                               (MaxRGB-GetOpacitySample(p))/unsigned_scale);
-                       p++;
-                     }
-                 }
-               else
-                 {
-                   /* Scale up */
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       MagickBitStreamMSBWrite(&stream,quantum_size,
-                                               (MaxRGB-GetOpacitySample(p))*unsigned_scale);
-                       p++;
-                     }
-                 }
-               q=stream.bytes;
-               break;
-             }
-           }
-       }
+        {
+          switch (quantum_size)
+            {
+            case 8:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
+                    p++;
+                  }
+                break;
+              }
+            case 16:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
+                    p++;
+                  }
+                break;
+              }
+            case 32:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                    p++;
+                  }
+                break;
+              }
+            case 64:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                    p++;
+                  }
+                break;
+              }
+            default:
+              {
+                /*
+                  Arbitrary sample size
+                */
+                BitStreamWriteHandle
+                  stream;
+
+                MagickBitStreamInitializeWrite(&stream,q);
+                if( QuantumDepth == sample_bits)
+                  {
+                    /* Unity scale */
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        MagickBitStreamMSBWrite(&stream,quantum_size,
+                                                MaxRGB-GetOpacitySample(p));
+                        p++;
+                      }
+                  }
+                else if (QuantumDepth >  sample_bits)
+                  {
+                    /* Scale down */
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        MagickBitStreamMSBWrite(&stream,quantum_size,
+                                                (MaxRGB-GetOpacitySample(p))/unsigned_scale);
+                        p++;
+                      }
+                  }
+                else
+                  {
+                    /* Scale up */
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        MagickBitStreamMSBWrite(&stream,quantum_size,
+                                                (MaxRGB-GetOpacitySample(p))*unsigned_scale);
+                        p++;
+                      }
+                  }
+                q=stream.bytes;
+                break;
+              }
+            }
+        }
       else if (sample_type == FloatQuantumSampleType)
-       {
-         switch (quantum_size)
-           {
-           case 16:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportFloat16Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
-                   p++;
-                 }
-               break;
-             }
-           case 24:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportFloat24Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
-                   p++;
-                 }
-               break;
-             }
-           case 32:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportFloat32Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
-                   p++;
-                 }
-               break;
-             }
-           case 64:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ExportFloat64Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
-                   p++;
-                 }
-               break;
-             }
-           default:
-             break;
-           }
-       }
+        {
+          switch (quantum_size)
+            {
+            case 16:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportFloat16Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
+                    p++;
+                  }
+                break;
+              }
+            case 24:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportFloat24Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
+                    p++;
+                  }
+                break;
+              }
+            case 32:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportFloat32Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
+                    p++;
+                  }
+                break;
+              }
+            case 64:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ExportFloat64Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
+                    p++;
+                  }
+                break;
+              }
+            default:
+              break;
+            }
+        }
     }
 
   /*
@@ -2109,16 +2123,16 @@ ExportAlphaQuantumType(unsigned char * restrict destination,
 
 static MagickPassFail
 ExportBlackQuantumType(unsigned char * restrict destination,
-                      const PixelPacket * restrict pixels,
-                      const unsigned long number_pixels,
-                      const unsigned int quantum_size,
-                      const QuantumSampleType sample_type,
-                      const EndianType endian,
-                      const unsigned int unsigned_scale,
-                      const unsigned int sample_bits,
-                      const double double_minvalue,
-                      const double double_scale,
-                      unsigned long *bytes_exported)
+                       const PixelPacket * restrict pixels,
+                       const unsigned long number_pixels,
+                       const unsigned int quantum_size,
+                       const QuantumSampleType sample_type,
+                       const EndianType endian,
+                       const unsigned int unsigned_scale,
+                       const unsigned int sample_bits,
+                       const double double_minvalue,
+                       const double double_scale,
+                       unsigned long *bytes_exported)
 {
   register unsigned char
     *q = destination;
@@ -2132,130 +2146,130 @@ ExportBlackQuantumType(unsigned char * restrict destination,
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetBlackSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetBlackSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetBlackSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetBlackSample(p)));
-               p++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamWriteHandle
-             stream;
-                  
-           MagickBitStreamInitializeWrite(&stream,q);
-           if( QuantumDepth == sample_bits)
-             {
-               /* Unity scale */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           GetBlackSample(p));
-                   p++;
-                 }
-             }
-           else if (QuantumDepth >  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           GetBlackSample(p)/unsigned_scale);
-                   p++;
-                 }
-             }
-           else
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           GetBlackSample(p)*unsigned_scale);
-                   p++;
-                 }
-             }
-           q=stream.bytes;
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetBlackSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetBlackSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetBlackSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetBlackSample(p)));
+                p++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamWriteHandle
+              stream;
+
+            MagickBitStreamInitializeWrite(&stream,q);
+            if( QuantumDepth == sample_bits)
+              {
+                /* Unity scale */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            GetBlackSample(p));
+                    p++;
+                  }
+              }
+            else if (QuantumDepth >  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            GetBlackSample(p)/unsigned_scale);
+                    p++;
+                  }
+              }
+            else
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            GetBlackSample(p)*unsigned_scale);
+                    p++;
+                  }
+              }
+            q=stream.bytes;
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat16Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat24Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat32Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat64Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat16Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat24Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat32Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat64Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   /*
@@ -2268,16 +2282,16 @@ ExportBlackQuantumType(unsigned char * restrict destination,
 
 static MagickPassFail
 ExportRGBQuantumType(unsigned char * restrict destination,
-                    const PixelPacket * restrict pixels,
-                    const unsigned long number_pixels,
-                    const unsigned int quantum_size,
-                    const QuantumSampleType sample_type,
-                    const EndianType endian,
-                    const unsigned int unsigned_scale,
-                    const unsigned int sample_bits,
-                    const double double_minvalue,
-                    const double double_scale,
-                    unsigned long *bytes_exported)
+                     const PixelPacket * restrict pixels,
+                     const unsigned long number_pixels,
+                     const unsigned int quantum_size,
+                     const QuantumSampleType sample_type,
+                     const EndianType endian,
+                     const unsigned int unsigned_scale,
+                     const unsigned int sample_bits,
+                     const double double_minvalue,
+                     const double double_scale,
+                     unsigned long *bytes_exported)
 {
   register unsigned char
     *q = destination;
@@ -2291,149 +2305,149 @@ ExportRGBQuantumType(unsigned char * restrict destination,
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetRedSample(p)));
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetGreenSample(p)));
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetBlueSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetRedSample(p)));
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetGreenSample(p)));
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetBlueSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetGreenSample(p)));
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetBlueSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetGreenSample(p)));
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetBlueSample(p)));
-               p++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamWriteHandle
-             stream;
-                  
-           MagickBitStreamInitializeWrite(&stream,q);
-           if( QuantumDepth == sample_bits)
-             {
-               /* Unity scale */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetRedSample(p));
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetGreenSample(p));
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetBlueSample(p));
-                   p++;
-                 }
-             }
-           else if (QuantumDepth >  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetRedSample(p)/unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetGreenSample(p)/unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetBlueSample(p)/unsigned_scale);
-                   p++;
-                 }
-             }
-           else
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetRedSample(p)*unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetGreenSample(p)*unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetBlueSample(p)*unsigned_scale);
-                   p++;
-                 }
-             }
-           q=stream.bytes;
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetRedSample(p)));
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetGreenSample(p)));
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetBlueSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetRedSample(p)));
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetGreenSample(p)));
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetBlueSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetGreenSample(p)));
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetBlueSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetGreenSample(p)));
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetBlueSample(p)));
+                p++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamWriteHandle
+              stream;
+
+            MagickBitStreamInitializeWrite(&stream,q);
+            if( QuantumDepth == sample_bits)
+              {
+                /* Unity scale */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetRedSample(p));
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetGreenSample(p));
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetBlueSample(p));
+                    p++;
+                  }
+              }
+            else if (QuantumDepth >  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetRedSample(p)/unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetGreenSample(p)/unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetBlueSample(p)/unsigned_scale);
+                    p++;
+                  }
+              }
+            else
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetRedSample(p)*unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetGreenSample(p)*unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetBlueSample(p)*unsigned_scale);
+                    p++;
+                  }
+              }
+            q=stream.bytes;
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat16Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
-               ExportFloat16Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
-               ExportFloat16Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat24Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
-               ExportFloat24Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
-               ExportFloat24Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat32Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
-               ExportFloat32Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
-               ExportFloat32Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat64Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
-               ExportFloat64Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
-               ExportFloat64Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat16Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
+                ExportFloat16Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
+                ExportFloat16Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat24Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
+                ExportFloat24Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
+                ExportFloat24Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat32Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
+                ExportFloat32Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
+                ExportFloat32Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat64Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
+                ExportFloat64Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
+                ExportFloat64Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   /*
@@ -2446,16 +2460,16 @@ ExportRGBQuantumType(unsigned char * restrict destination,
 
 static MagickPassFail
 ExportRGBAQuantumType(unsigned char * restrict destination,
-                     const PixelPacket * restrict pixels,
-                     const unsigned long number_pixels,
-                     const unsigned int quantum_size,
-                     const QuantumSampleType sample_type,
-                     const EndianType endian,
-                     const unsigned int unsigned_scale,
-                     const unsigned int sample_bits,
-                     const double double_minvalue,
-                     const double double_scale,
-                     unsigned long *bytes_exported)
+                      const PixelPacket * restrict pixels,
+                      const unsigned long number_pixels,
+                      const unsigned int quantum_size,
+                      const QuantumSampleType sample_type,
+                      const EndianType endian,
+                      const unsigned int unsigned_scale,
+                      const unsigned int sample_bits,
+                      const double double_minvalue,
+                      const double double_scale,
+                      unsigned long *bytes_exported)
 {
   register unsigned char
     *q = destination;
@@ -2469,163 +2483,163 @@ ExportRGBAQuantumType(unsigned char * restrict destination,
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetRedSample(p)));
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetGreenSample(p)));
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetBlueSample(p)));
-               ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
-               p++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetRedSample(p)));
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetGreenSample(p)));
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetBlueSample(p)));
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetGreenSample(p)));
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetBlueSample(p)));
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetGreenSample(p)));
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetBlueSample(p)));
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
-               p++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamWriteHandle
-             stream;
-                  
-           MagickBitStreamInitializeWrite(&stream,q);
-           if(QuantumDepth == sample_bits)
-             {
-               /* Unity scale */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetRedSample(p));
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetGreenSample(p));
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetBlueSample(p));
-                   MagickBitStreamMSBWrite(&stream,quantum_size,MaxRGB-GetOpacitySample(p));
-                   p++;
-                 }
-             }
-           else if (QuantumDepth >  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetRedSample(p)/unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetGreenSample(p)/unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetBlueSample(p)/unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           (MaxRGB-GetOpacitySample(p))/unsigned_scale);
-                   p++;
-                 }
-             }
-           else
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetRedSample(p)*unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetGreenSample(p)*unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetBlueSample(p)*unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           (MaxRGB-GetOpacitySample(p))*unsigned_scale);
-                   p++;
-                          
-                 }
-             }
-           q=stream.bytes;
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetRedSample(p)));
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetGreenSample(p)));
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetBlueSample(p)));
+                ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-GetOpacitySample(p)));
+                p++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetRedSample(p)));
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetGreenSample(p)));
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetBlueSample(p)));
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-GetOpacitySample(p)));
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetGreenSample(p)));
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetBlueSample(p)));
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetRedSample(p)));
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetGreenSample(p)));
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetBlueSample(p)));
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-GetOpacitySample(p)));
+                p++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamWriteHandle
+              stream;
+
+            MagickBitStreamInitializeWrite(&stream,q);
+            if(QuantumDepth == sample_bits)
+              {
+                /* Unity scale */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetRedSample(p));
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetGreenSample(p));
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetBlueSample(p));
+                    MagickBitStreamMSBWrite(&stream,quantum_size,MaxRGB-GetOpacitySample(p));
+                    p++;
+                  }
+              }
+            else if (QuantumDepth >  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetRedSample(p)/unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetGreenSample(p)/unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetBlueSample(p)/unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            (MaxRGB-GetOpacitySample(p))/unsigned_scale);
+                    p++;
+                  }
+              }
+            else
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetRedSample(p)*unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetGreenSample(p)*unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetBlueSample(p)*unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            (MaxRGB-GetOpacitySample(p))*unsigned_scale);
+                    p++;
+
+                  }
+              }
+            q=stream.bytes;
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat16Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
-               ExportFloat16Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
-               ExportFloat16Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
-               ExportFloat16Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat24Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
-               ExportFloat24Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
-               ExportFloat24Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
-               ExportFloat24Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat32Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
-               ExportFloat32Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
-               ExportFloat32Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
-               ExportFloat32Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat64Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
-               ExportFloat64Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
-               ExportFloat64Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
-               ExportFloat64Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat16Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
+                ExportFloat16Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
+                ExportFloat16Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
+                ExportFloat16Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat24Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
+                ExportFloat24Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
+                ExportFloat24Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
+                ExportFloat24Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat32Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
+                ExportFloat32Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
+                ExportFloat32Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
+                ExportFloat32Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat64Quantum(endian,q,GetRedSample(p)*double_scale+double_minvalue);
+                ExportFloat64Quantum(endian,q,GetGreenSample(p)*double_scale+double_minvalue);
+                ExportFloat64Quantum(endian,q,GetBlueSample(p)*double_scale+double_minvalue);
+                ExportFloat64Quantum(endian,q,(MaxRGB-GetOpacitySample(p))*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   /*
@@ -2638,16 +2652,16 @@ ExportRGBAQuantumType(unsigned char * restrict destination,
 
 static MagickPassFail
 ExportCMYKQuantumType(unsigned char * restrict destination,
-                     const PixelPacket * restrict pixels,
-                     const unsigned long number_pixels,
-                     const unsigned int quantum_size,
-                     const QuantumSampleType sample_type,
-                     const EndianType endian,
-                     const unsigned int unsigned_scale,
-                     const unsigned int sample_bits,
-                     const double double_minvalue,
-                     const double double_scale,
-                     unsigned long *bytes_exported)
+                      const PixelPacket * restrict pixels,
+                      const unsigned long number_pixels,
+                      const unsigned int quantum_size,
+                      const QuantumSampleType sample_type,
+                      const EndianType endian,
+                      const unsigned int unsigned_scale,
+                      const unsigned int sample_bits,
+                      const double double_minvalue,
+                      const double double_scale,
+                      unsigned long *bytes_exported)
 {
   register unsigned char
     *q = destination;
@@ -2661,160 +2675,160 @@ ExportCMYKQuantumType(unsigned char * restrict destination,
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetCyanSample(p)));
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetMagentaSample(p)));
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetYellowSample(p)));
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetBlackSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetCyanSample(p)));
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetMagentaSample(p)));
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetYellowSample(p)));
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetBlackSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetCyanSample(p)));
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetMagentaSample(p)));
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetYellowSample(p)));
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetBlackSample(p)));
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetCyanSample(p)));
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetMagentaSample(p)));
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetYellowSample(p)));
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetBlackSample(p)));
-               p++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamWriteHandle
-             stream;
-                  
-           MagickBitStreamInitializeWrite(&stream,q);
-           if(QuantumDepth == sample_bits)
-             {
-               /* Unity scale */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetCyanSample(p));
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetMagentaSample(p));
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetYellowSample(p));
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetBlackSample(p));
-                   p++;
-                 }
-             }
-           else if (QuantumDepth >  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetCyanSample(p)/unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetMagentaSample(p)/unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetYellowSample(p)/unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetBlackSample(p)/unsigned_scale);
-                   p++;
-                 }
-             }
-           else
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetCyanSample(p)*unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetMagentaSample(p)*unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetYellowSample(p)*unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetBlackSample(p)*unsigned_scale);
-                   p++;
-                 }
-             }
-           q=stream.bytes;
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetCyanSample(p)));
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetMagentaSample(p)));
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetYellowSample(p)));
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetBlackSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetCyanSample(p)));
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetMagentaSample(p)));
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetYellowSample(p)));
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetBlackSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetCyanSample(p)));
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetMagentaSample(p)));
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetYellowSample(p)));
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetBlackSample(p)));
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetCyanSample(p)));
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetMagentaSample(p)));
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetYellowSample(p)));
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetBlackSample(p)));
+                p++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamWriteHandle
+              stream;
+
+            MagickBitStreamInitializeWrite(&stream,q);
+            if(QuantumDepth == sample_bits)
+              {
+                /* Unity scale */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetCyanSample(p));
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetMagentaSample(p));
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetYellowSample(p));
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetBlackSample(p));
+                    p++;
+                  }
+              }
+            else if (QuantumDepth >  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetCyanSample(p)/unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetMagentaSample(p)/unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetYellowSample(p)/unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetBlackSample(p)/unsigned_scale);
+                    p++;
+                  }
+              }
+            else
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetCyanSample(p)*unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetMagentaSample(p)*unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetYellowSample(p)*unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetBlackSample(p)*unsigned_scale);
+                    p++;
+                  }
+              }
+            q=stream.bytes;
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat16Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
-               ExportFloat16Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
-               ExportFloat16Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
-               ExportFloat16Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat24Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
-               ExportFloat24Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
-               ExportFloat24Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
-               ExportFloat24Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat32Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
-               ExportFloat32Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
-               ExportFloat32Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
-               ExportFloat32Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat64Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
-               ExportFloat64Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
-               ExportFloat64Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
-               ExportFloat64Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat16Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
+                ExportFloat16Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
+                ExportFloat16Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
+                ExportFloat16Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat24Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
+                ExportFloat24Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
+                ExportFloat24Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
+                ExportFloat24Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat32Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
+                ExportFloat32Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
+                ExportFloat32Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
+                ExportFloat32Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat64Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
+                ExportFloat64Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
+                ExportFloat64Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
+                ExportFloat64Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   /*
@@ -2827,17 +2841,17 @@ ExportCMYKQuantumType(unsigned char * restrict destination,
 
 static MagickPassFail
 ExportCMYKAQuantumType(unsigned char * restrict destination,
-                      const PixelPacket * restrict pixels,
-                      const IndexPacket * restrict indexes,
-                      const unsigned long number_pixels,
-                      const unsigned int quantum_size,
-                      const QuantumSampleType sample_type,
-                      const EndianType endian,
-                      const unsigned int unsigned_scale,
-                      const unsigned int sample_bits,
-                      const double double_minvalue,
-                      const double double_scale,
-                      unsigned long *bytes_exported)
+                       const PixelPacket * restrict pixels,
+                       const IndexPacket * restrict indexes,
+                       const unsigned long number_pixels,
+                       const unsigned int quantum_size,
+                       const QuantumSampleType sample_type,
+                       const EndianType endian,
+                       const unsigned int unsigned_scale,
+                       const unsigned int sample_bits,
+                       const double double_minvalue,
+                       const double double_scale,
+                       unsigned long *bytes_exported)
 {
   register unsigned char
     *q = destination;
@@ -2848,183 +2862,186 @@ ExportCMYKAQuantumType(unsigned char * restrict destination,
   register unsigned long
     x;
 
+  if (indexes == (IndexPacket *) NULL)
+    return MagickFail;
+
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetCyanSample(p)));
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetMagentaSample(p)));
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetYellowSample(p)));
-               ExportUInt8Quantum(q,ScaleQuantumToChar(GetBlackSample(p)));
-               ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-*indexes));
-               indexes++;
-               p++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetCyanSample(p)));
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetMagentaSample(p)));
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetYellowSample(p)));
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetBlackSample(p)));
-               ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-*indexes));
-               indexes++;
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetCyanSample(p)));
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetMagentaSample(p)));
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetYellowSample(p)));
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetBlackSample(p)));
-               ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-*indexes));
-               indexes++;
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetCyanSample(p)));
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetMagentaSample(p)));
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetYellowSample(p)));
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetBlackSample(p)));
-               ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-*indexes));
-               indexes++;
-               p++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamWriteHandle
-             stream;
-                  
-           MagickBitStreamInitializeWrite(&stream,q);
-           if( QuantumDepth == sample_bits)
-             {
-               /* Unity scale */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetCyanSample(p));
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetMagentaSample(p));
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetYellowSample(p));
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetBlackSample(p));
-                   MagickBitStreamMSBWrite(&stream,quantum_size,MaxRGB-*indexes);
-                   indexes++;
-                   p++;
-                 }
-             }
-           else if (QuantumDepth >  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetCyanSample(p)/unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetMagentaSample(p)/unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetYellowSample(p)/unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetBlackSample(p)/unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           (MaxRGB-*indexes)/unsigned_scale);
-                   indexes++;
-                   p++;
-                 }
-             }
-           else
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetCyanSample(p)*unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetMagentaSample(p)*unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetYellowSample(p)*unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,GetBlackSample(p)*unsigned_scale);
-                   MagickBitStreamMSBWrite(&stream,quantum_size,
-                                           (MaxRGB-*indexes)*unsigned_scale);
-                   indexes++;
-                   p++;
-                 }
-             }
-           q=stream.bytes;
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetCyanSample(p)));
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetMagentaSample(p)));
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetYellowSample(p)));
+                ExportUInt8Quantum(q,ScaleQuantumToChar(GetBlackSample(p)));
+                ExportUInt8Quantum(q,ScaleQuantumToChar(MaxRGB-*indexes));
+                indexes++;
+                p++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetCyanSample(p)));
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetMagentaSample(p)));
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetYellowSample(p)));
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(GetBlackSample(p)));
+                ExportUInt16Quantum(endian,q,ScaleQuantumToShort(MaxRGB-*indexes));
+                indexes++;
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetCyanSample(p)));
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetMagentaSample(p)));
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetYellowSample(p)));
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(GetBlackSample(p)));
+                ExportUInt32Quantum(endian,q,ScaleQuantumToLong(MaxRGB-*indexes));
+                indexes++;
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetCyanSample(p)));
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetMagentaSample(p)));
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetYellowSample(p)));
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(GetBlackSample(p)));
+                ExportUInt64Quantum(endian,q,ScaleQuantumToLong(MaxRGB-*indexes));
+                indexes++;
+                p++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamWriteHandle
+              stream;
+
+            MagickBitStreamInitializeWrite(&stream,q);
+            if( QuantumDepth == sample_bits)
+              {
+                /* Unity scale */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetCyanSample(p));
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetMagentaSample(p));
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetYellowSample(p));
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetBlackSample(p));
+                    MagickBitStreamMSBWrite(&stream,quantum_size,MaxRGB-*indexes);
+                    indexes++;
+                    p++;
+                  }
+              }
+            else if (QuantumDepth >  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetCyanSample(p)/unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetMagentaSample(p)/unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetYellowSample(p)/unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetBlackSample(p)/unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            (MaxRGB-*indexes)/unsigned_scale);
+                    indexes++;
+                    p++;
+                  }
+              }
+            else
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetCyanSample(p)*unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetMagentaSample(p)*unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetYellowSample(p)*unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,GetBlackSample(p)*unsigned_scale);
+                    MagickBitStreamMSBWrite(&stream,quantum_size,
+                                            (MaxRGB-*indexes)*unsigned_scale);
+                    indexes++;
+                    p++;
+                  }
+              }
+            q=stream.bytes;
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat16Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
-               ExportFloat16Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
-               ExportFloat16Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
-               ExportFloat16Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
-               ExportFloat16Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat24Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
-               ExportFloat24Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
-               ExportFloat24Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
-               ExportFloat24Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
-               ExportFloat24Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat32Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
-               ExportFloat32Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
-               ExportFloat32Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
-               ExportFloat32Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
-               ExportFloat32Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ExportFloat64Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
-               ExportFloat64Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
-               ExportFloat64Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
-               ExportFloat64Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
-               ExportFloat64Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
-               p++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat16Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
+                ExportFloat16Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
+                ExportFloat16Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
+                ExportFloat16Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
+                ExportFloat16Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat24Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
+                ExportFloat24Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
+                ExportFloat24Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
+                ExportFloat24Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
+                ExportFloat24Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat32Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
+                ExportFloat32Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
+                ExportFloat32Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
+                ExportFloat32Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
+                ExportFloat32Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ExportFloat64Quantum(endian,q,GetCyanSample(p)*double_scale+double_minvalue);
+                ExportFloat64Quantum(endian,q,GetMagentaSample(p)*double_scale+double_minvalue);
+                ExportFloat64Quantum(endian,q,GetYellowSample(p)*double_scale+double_minvalue);
+                ExportFloat64Quantum(endian,q,GetBlackSample(p)*double_scale+double_minvalue);
+                ExportFloat64Quantum(endian,q,(MaxRGB-*indexes)*double_scale+double_minvalue);
+                p++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   /*
@@ -3037,11 +3054,11 @@ ExportCMYKAQuantumType(unsigned char * restrict destination,
 
 MagickExport MagickPassFail
 ExportViewPixelArea(const ViewInfo *view,
-                   const QuantumType quantum_type,
-                   const unsigned int quantum_size,
-                   unsigned char *destination,
-                   const ExportPixelAreaOptions *options,
-                   ExportPixelAreaInfo *export_info)
+                    const QuantumType quantum_type,
+                    const unsigned int quantum_size,
+                    unsigned char *destination,
+                    const ExportPixelAreaOptions *options,
+                    ExportPixelAreaInfo *export_info)
 {
   const Image
     *image;
@@ -3141,7 +3158,7 @@ ExportViewPixelArea(const ViewInfo *view,
     {
       /* Maximum value which may be represented by a sample */
       unsigned_maxvalue=MaxValueGivenBits(sample_bits);
-      
+
       if (QuantumDepth == sample_bits)
         {
         }
@@ -3166,110 +3183,110 @@ ExportViewPixelArea(const ViewInfo *view,
     {
     case UndefinedQuantum:
       {
-       status=MagickFail;
-       break;
+        status=MagickFail;
+        break;
       }
     case IndexQuantum:
       {
-       status=ExportIndexQuantumType(destination,indexes,number_pixels,
-                                     quantum_size,sample_type,endian,
-                                     image,&bytes_exported);
+        status=ExportIndexQuantumType(destination,indexes,number_pixels,
+                                      quantum_size,sample_type,endian,
+                                      image,&bytes_exported);
         break;
       }
     case IndexAlphaQuantum:
       {
-       status=ExportIndexAlphaQuantumType(destination,pixels,indexes,number_pixels,
-                                          quantum_size,sample_type,endian,unsigned_scale,
-                                          image,&bytes_exported);
+        status=ExportIndexAlphaQuantumType(destination,pixels,indexes,number_pixels,
+                                           quantum_size,sample_type,endian,unsigned_scale,
+                                           image,&bytes_exported);
         break;
       }
     case GrayQuantum:
       {
-       status=ExportGrayQuantumType(destination,pixels,indexes,number_pixels,quantum_size,
-                                    sample_type,endian,unsigned_scale,grayscale_miniswhite,
-                                    sample_bits,double_minvalue,double_scale,image,
-                                    &bytes_exported);
+        status=ExportGrayQuantumType(destination,pixels,indexes,number_pixels,quantum_size,
+                                     sample_type,endian,unsigned_scale,grayscale_miniswhite,
+                                     sample_bits,double_minvalue,double_scale,image,
+                                     &bytes_exported);
         break;
       }
     case GrayAlphaQuantum:
       {
-       status=ExportGrayAlphaQuantumType(destination,pixels,number_pixels,quantum_size,
-                                         sample_type,endian,unsigned_scale,grayscale_miniswhite,
-                                         sample_bits,double_minvalue,double_scale,
-                                         image,&bytes_exported);
+        status=ExportGrayAlphaQuantumType(destination,pixels,number_pixels,quantum_size,
+                                          sample_type,endian,unsigned_scale,grayscale_miniswhite,
+                                          sample_bits,double_minvalue,double_scale,
+                                          image,&bytes_exported);
         break;
       }
     case RedQuantum:
     case CyanQuantum:
       {
-       status=ExportRedQuantumType(destination,pixels,number_pixels,quantum_size,
-                                   sample_type,endian,unsigned_scale,sample_bits,
-                                   double_minvalue,double_scale,&bytes_exported);
+        status=ExportRedQuantumType(destination,pixels,number_pixels,quantum_size,
+                                    sample_type,endian,unsigned_scale,sample_bits,
+                                    double_minvalue,double_scale,&bytes_exported);
         break;
       }
     case GreenQuantum:
     case MagentaQuantum:
       {
-       status=ExportGreenQuantumType(destination,pixels,number_pixels,quantum_size,
-                                     sample_type,endian,unsigned_scale,sample_bits,
-                                     double_minvalue,double_scale,&bytes_exported);
+        status=ExportGreenQuantumType(destination,pixels,number_pixels,quantum_size,
+                                      sample_type,endian,unsigned_scale,sample_bits,
+                                      double_minvalue,double_scale,&bytes_exported);
         break;
       }
     case BlueQuantum:
     case YellowQuantum:
       {
-       status=ExportBlueQuantumType(destination,pixels,number_pixels,quantum_size,sample_type,
-                                    endian,unsigned_scale,sample_bits,double_minvalue,double_scale,
-                                    &bytes_exported);
+        status=ExportBlueQuantumType(destination,pixels,number_pixels,quantum_size,sample_type,
+                                     endian,unsigned_scale,sample_bits,double_minvalue,double_scale,
+                                     &bytes_exported);
         break;
       }
     case AlphaQuantum:
-       {
-         status=ExportAlphaQuantumType(destination,pixels,indexes,number_pixels,quantum_size,
-                                       sample_type,endian,unsigned_scale,sample_bits,
-                                       double_minvalue,double_scale,image,&bytes_exported);
-         break;
-       }
+        {
+          status=ExportAlphaQuantumType(destination,pixels,indexes,number_pixels,quantum_size,
+                                        sample_type,endian,unsigned_scale,sample_bits,
+                                        double_minvalue,double_scale,image,&bytes_exported);
+          break;
+        }
     case BlackQuantum:
       {
-       status=ExportBlackQuantumType(destination,pixels,number_pixels,quantum_size,sample_type,
-                                     endian,unsigned_scale,sample_bits,double_minvalue,double_scale,
-                                     &bytes_exported);
+        status=ExportBlackQuantumType(destination,pixels,number_pixels,quantum_size,sample_type,
+                                      endian,unsigned_scale,sample_bits,double_minvalue,double_scale,
+                                      &bytes_exported);
         break;
       }
     case RGBQuantum:
       {
-       status=ExportRGBQuantumType(destination,pixels,number_pixels,quantum_size,sample_type,
-                                   endian,unsigned_scale,sample_bits,double_minvalue,double_scale,
-                                   &bytes_exported);
+        status=ExportRGBQuantumType(destination,pixels,number_pixels,quantum_size,sample_type,
+                                    endian,unsigned_scale,sample_bits,double_minvalue,double_scale,
+                                    &bytes_exported);
         break;
       }
     case RGBAQuantum:
       {
-       status=ExportRGBAQuantumType(destination,pixels,number_pixels,quantum_size,sample_type,
-                                    endian,unsigned_scale,sample_bits,double_minvalue,double_scale,
-                                    &bytes_exported);
+        status=ExportRGBAQuantumType(destination,pixels,number_pixels,quantum_size,sample_type,
+                                     endian,unsigned_scale,sample_bits,double_minvalue,double_scale,
+                                     &bytes_exported);
         break;
       }
     case CMYKQuantum:
       {
-       status=ExportCMYKQuantumType(destination,pixels,number_pixels,quantum_size,sample_type,
-                                    endian,unsigned_scale,sample_bits,double_minvalue,double_scale,
-                                    &bytes_exported);
+        status=ExportCMYKQuantumType(destination,pixels,number_pixels,quantum_size,sample_type,
+                                     endian,unsigned_scale,sample_bits,double_minvalue,double_scale,
+                                     &bytes_exported);
         break;
       }
     case CMYKAQuantum:
       {
-       status=ExportCMYKAQuantumType(destination,pixels,indexes,number_pixels,quantum_size,
-                                     sample_type,endian,unsigned_scale,sample_bits,double_minvalue,
-                                     double_scale,&bytes_exported);
+        status=ExportCMYKAQuantumType(destination,pixels,indexes,number_pixels,quantum_size,
+                                      sample_type,endian,unsigned_scale,sample_bits,double_minvalue,
+                                      double_scale,&bytes_exported);
         break;
       }
     case CIEYQuantum:
     case CIEXYZQuantum:
       {
-       status=MagickFail;
-       break;
+        status=MagickFail;
+        break;
       }
     }
 
@@ -3280,7 +3297,7 @@ ExportViewPixelArea(const ViewInfo *view,
     {
       q=(destination+bytes_exported);
       for (x = options->pad_bytes; x != 0; --x)
-       *q++=options->pad_value;
+        *q++=options->pad_value;
       bytes_exported=(q-destination);
     }
 
index 3600266..cc96420 100644 (file)
@@ -1,10 +1,10 @@
 /*
   Copyright (C) 2008 - 2015 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   16/24 bit floating point conversion functions
 
   Written by Richard Nolde, 2008
@@ -29,7 +29,7 @@ int _Gm_convert_fp16_to_fp32 (const fp_16bits *fp16, float *fp32)
   unsigned char  expt; /* exponent bits */
   unsigned char  m2, m1;  /* MSB to LSB of mantissa */
   unsigned char  new_expt;
-  unsigned char  new_m3, new_m2, new_m1; 
+  unsigned char  new_m3, new_m2, new_m1;
   unsigned char *src;
   unsigned char *dst;
 
@@ -37,8 +37,8 @@ int _Gm_convert_fp16_to_fp32 (const fp_16bits *fp16, float *fp32)
   /* Debugging variables */
   int            i, j, bit;
   unsigned int  mant;
-  double         test  = 0.0; 
-  double         test2 = 0.0; 
+  double         test  = 0.0;
+  double         test2 = 0.0;
   double         accum = 0.0;
 
   errno = 0;
@@ -60,24 +60,24 @@ int _Gm_convert_fp16_to_fp32 (const fp_16bits *fp16, float *fp32)
   if ((src[0] | src[1]) != 0U)
     {
 #if !defined(WORDS_BIGENDIAN)
-       {
-         sbit =  *(src + 1) & 0x80;
-         expt = (*(src + 1) & 0x7F) >> 2;
-         m2 =    *(src + 1) & 0x03;
-         m1 = *src;
-       }
+        {
+          sbit =  *(src + 1) & 0x80;
+          expt = (*(src + 1) & 0x7F) >> 2;
+          m2 =    *(src + 1) & 0x03;
+          m1 = *src;
+        }
 #else
-       {
-         sbit =  *src & 0x80;
-         expt = (*src & 0x7F) >> 2;
-         m2 =    *src & 0x03;
-         m1 =  *(src + 1);
-       }
+        {
+          sbit =  *src & 0x80;
+          expt = (*src & 0x7F) >> 2;
+          m2 =    *src & 0x03;
+          m1 =  *(src + 1);
+        }
 #endif /* !defined(WORDS_BIGENDIAN) */
 
       if (expt != 0)
-       new_expt = expt - 15 + 127;
-      new_m3  =  (m2 << 5) | (m1 & 0xF8) >> 3; 
+        new_expt = expt - 15 + 127;
+      new_m3  =  (m2 << 5) | (m1 & 0xF8) >> 3;
       new_m2  =  (m1 & 7) << 5;
       new_m1  = 0;
     }
@@ -97,13 +97,13 @@ int _Gm_convert_fp16_to_fp32 (const fp_16bits *fp16, float *fp32)
     }
 #endif /* !defined(WORDS_BIGENDIAN) */
 
-  /* Underflow and overflow will not be a problem 
+  /* Underflow and overflow will not be a problem
    * since target has more significant bits that
    * the source.
    */
 #ifdef DEBUG32
   /* Debugging code for display only */
-  mant = ((unsigned int)new_m3 << 16) | ((unsigned int)new_m2 << 8) | (unsigned int)new_m1; 
+  mant = ((unsigned int)new_m3 << 16) | ((unsigned int)new_m2 << 8) | (unsigned int)new_m1;
   if (new_expt == 0)
     {
       test = 0.0;
@@ -114,27 +114,27 @@ int _Gm_convert_fp16_to_fp32 (const fp_16bits *fp16, float *fp32)
     {
       accum = 0.0;
       for (i = 22, j = 1; i >= 0; i--, j++)
-       {
-         bit = mant & ((unsigned int)1 << i);
-         if (bit)
-           accum += (1.0 / ((unsigned int)1 << j));
-       }
+        {
+          bit = mant & ((unsigned int)1 << i);
+          if (bit)
+            accum += (1.0 / ((unsigned int)1 << j));
+        }
       accum += 1.0;
       test = pow (2.0, 1.0 * (new_expt - 127));
       switch (errno)
-       {
-       case 0:     break;
-       case EDOM: 
-       case ERANGE: 
-       default: perror ("Invalid value");
-         break;
-       }
+        {
+        case 0:     break;
+        case EDOM:
+        case ERANGE:
+        default: perror ("Invalid value");
+          break;
+        }
       test2 = accum * test;
       if (sbit)
-       test2 *= -1.0;
+        test2 *= -1.0;
     }
   printf ("              Sign bit: %u, Expt biased to %5u,  2^%-5d = %8.1f  *  %10.8f = %18.10f\n\n",
-         sbit > 0 ? 1 : 0, new_expt, new_expt > 0 ? new_expt - 127 : 0, test, accum, test2);
+          sbit > 0 ? 1 : 0, new_expt, new_expt > 0 ? new_expt - 127 : 0, test, accum, test2);
 #endif
   return (0);
 } /* end convertfp16_to_fp32 */
@@ -155,8 +155,8 @@ int _Gm_convert_fp32_to_fp16 (const float *fp32, fp_16bits *fp16, const int mode
 
 #ifdef DEBUG16
   int     j, k;
-  double  test = 0.0; 
-  double  test2 = 0.0; 
+  double  test = 0.0;
+  double  test2 = 0.0;
   double  accum = 0.0;
   double  roundup = 0.0;
 
@@ -185,175 +185,175 @@ int _Gm_convert_fp32_to_fp16 (const float *fp32, fp_16bits *fp16, const int mode
   else
     {
 #if !defined(WORDS_BIGENDIAN)
-       {
-         sbit =   *(src + 3) & 0x80;
-         expt = ((*(src + 3) & 0x7F) << 1) | 
-           ((*(src + 2) & 0x80) >> 7);
-         /* Extract mantissa and left align bits */
-         m3  = (((*(src + 2) & 0x7F)) << 1) |
-           ((*(src + 1) & 0x80) >> 7);
-         m2  = (((*(src + 1) & 0x7F)) << 1)  |
-           ((*src & 0x80) >> 7);
-         m1  =  (*src & 0x7F) << 1;
-       }
+        {
+          sbit =   *(src + 3) & 0x80;
+          expt = ((*(src + 3) & 0x7F) << 1) |
+            ((*(src + 2) & 0x80) >> 7);
+          /* Extract mantissa and left align bits */
+          m3  = (((*(src + 2) & 0x7F)) << 1) |
+            ((*(src + 1) & 0x80) >> 7);
+          m2  = (((*(src + 1) & 0x7F)) << 1)  |
+            ((*src & 0x80) >> 7);
+          m1  =  (*src & 0x7F) << 1;
+        }
 #else
-       {
-         sbit =   *src & 0x80;
-         expt = ((*src & 0x7F) << 1) | 
-           ((*(src + 1) & 0x80) >> 7);
-         /* Extract mantissa and left align bits */
-         m3  = (((*(src + 1) & 0x7F)) << 1) |
-           ((*(src + 2) & 0x80) >> 7);
-         m2  = (((*(src + 2) & 0x7F)) << 1)  |
-           ((*(src + 3) & 0x80) >> 7);
-         m1  =  (*(src + 3) & 0x7F) << 1;
-       }
+        {
+          sbit =   *src & 0x80;
+          expt = ((*src & 0x7F) << 1) |
+            ((*(src + 1) & 0x80) >> 7);
+          /* Extract mantissa and left align bits */
+          m3  = (((*(src + 1) & 0x7F)) << 1) |
+            ((*(src + 2) & 0x80) >> 7);
+          m2  = (((*(src + 2) & 0x7F)) << 1)  |
+            ((*(src + 3) & 0x80) >> 7);
+          m1  =  (*(src + 3) & 0x7F) << 1;
+        }
 #endif /* !defined(WORDS_BIGENDIAN) */
 
-      /* Extract the 16 MSB from the mantissa */  
+      /* Extract the 16 MSB from the mantissa */
       mant = (m3 << 8) | m2;
       if (expt != 0)  /* Normal number */
-       new_expt = expt - 127 + 15;
+        new_expt = expt - 127 + 15;
 
-      /* Even if the new exponent is too small to represent, 
+      /* Even if the new exponent is too small to represent,
        * the mantissa could have signficant digits that can
        * be represented in the new value as a subnormal.
        */
       if (new_expt <= 0) /* Underflow */
-       {
-         rshift = 1 - new_expt;
-         switch (mode)
-           {
-           case STRICT_IEEE: /* NaN has all 1s in exponent plus 2 bits in Mantissa */
-             if (rshift > FP16_MANT_BITS)
-               {
-                 new_expt = 31;
-                 new_mant = 513;
-                 errno = ERANGE;
-                 fflush (stdout);
-                 fprintf (stderr, "Underflow. Result clipped\n");
-                 fflush (stderr);
-                 return (1);  /* The number cannot be represented as fp16 */
-               }
-             break;
-           case RANGE_LIMITED: /* Clamp to smallest subnormal */
-             new_expt = 0;
-             new_mant = mant >> rshift;;
-             mp = (unsigned char *)&new_mant;
+        {
+          rshift = 1 - new_expt;
+          switch (mode)
+            {
+            case STRICT_IEEE: /* NaN has all 1s in exponent plus 2 bits in Mantissa */
+              if (rshift > FP16_MANT_BITS)
+                {
+                  new_expt = 31;
+                  new_mant = 513;
+                  errno = ERANGE;
+                  fflush (stdout);
+                  fprintf (stderr, "Underflow. Result clipped\n");
+                  fflush (stderr);
+                  return (1);  /* The number cannot be represented as fp16 */
+                }
+              break;
+            case RANGE_LIMITED: /* Clamp to smallest subnormal */
+              new_expt = 0;
+              new_mant = mant >> rshift;;
+              mp = (unsigned char *)&new_mant;
 #ifdef DEBUG16
-             if (mant != 0)
-               {
-                 fflush (stdout);
-                 fprintf (stderr, "Underflow. %18.10f Result clippped to subnormal value\n", *fp32);
-                 fflush (stderr);
-               }
+              if (mant != 0)
+                {
+                  fflush (stdout);
+                  fprintf (stderr, "Underflow. %18.10f Result clippped to subnormal value\n", *fp32);
+                  fflush (stderr);
+                }
 #endif
-             break;        
-           case ZERO_LIMITED:  /* Clamp to zero instead of using a subnormal */
-             new_expt = 0;
-             new_mant = 0;
-             mp = (unsigned char *)&new_mant;
+              break;
+            case ZERO_LIMITED:  /* Clamp to zero instead of using a subnormal */
+              new_expt = 0;
+              new_mant = 0;
+              mp = (unsigned char *)&new_mant;
 #ifdef DEBUG16
-             if (mant != 0)
-               {
-                 fflush (stdout);
-                 fprintf (stderr, "Underflow. %18.10f Result clippped to zero\n", *fp32);
-                 fflush (stderr);
-               }
+              if (mant != 0)
+                {
+                  fflush (stdout);
+                  fprintf (stderr, "Underflow. %18.10f Result clippped to zero\n", *fp32);
+                  fflush (stderr);
+                }
 #endif
-             break;        
-           }
-       }
+              break;
+            }
+        }
       else /* Take the MSB from the old mantissa and left justify them */
-       {
-         if (new_expt > 30) /* Overflow */
-           {
-             switch (mode)
-               {
-               case STRICT_IEEE: /* NaN has all 1s in exponent plus 2 bits in Mantissa */
-                 new_expt = 31;
-                 new_mant = 513;
-                 errno = ERANGE;
-                 fflush (stdout);
-                 fprintf (stderr, "Overflow. %18.10f Result clipped\n", *fp32);
-                 fflush (stderr);
-                 return (1);
-               case ZERO_LIMITED:
-               case RANGE_LIMITED:  /* Clamp to maximum allowed value for fp16 */
-                 new_expt = 30;
-                 new_mant = 1023;
-                 mp = (unsigned char *)&new_mant;
+        {
+          if (new_expt > 30) /* Overflow */
+            {
+              switch (mode)
+                {
+                case STRICT_IEEE: /* NaN has all 1s in exponent plus 2 bits in Mantissa */
+                  new_expt = 31;
+                  new_mant = 513;
+                  errno = ERANGE;
+                  fflush (stdout);
+                  fprintf (stderr, "Overflow. %18.10f Result clipped\n", *fp32);
+                  fflush (stderr);
+                  return (1);
+                case ZERO_LIMITED:
+                case RANGE_LIMITED:  /* Clamp to maximum allowed value for fp16 */
+                  new_expt = 30;
+                  new_mant = 1023;
+                  mp = (unsigned char *)&new_mant;
 #ifdef DEBUG16
-                 fflush (stdout);
-                 fprintf (stderr, "Overflow. %18.10f Result clippped\n", *fp32);
-                 fflush (stderr);
+                  fflush (stdout);
+                  fprintf (stderr, "Overflow. %18.10f Result clippped\n", *fp32);
+                  fflush (stderr);
 #endif
-                 break;        
-               }
-           }
-         else /* Normal value within range of target type */
-           {
-             /* Check bits to the right of unit in last signficant place
-              * for destination, eg first digit that cannot be stored.
-              * Rounding of least significant retained bit falls to value
-              * which will produce a zero in the LSB if the bounding values
-              * are equidistant from the unrounded value.
-              */
-             rbits = mant & 0x3F;
-             if (rbits >= 0x20)  /* Greater than or equal to 0.5 times LSB */
-               {
-                 if (rbits > 0x20) /* Rbits is greater than half of LSB */
-                   {
-                     /* Round up to next higher value of LSB */
-                     for (i = 6; i < 16; i++)
-                       {
-                         bit = mant & (1 << i);
-                         if (bit == 0)
-                           {
-                             new_mant = (mant | ((unsigned short)1 << i)) & (0xFFFF << i);
-                             mp  = (unsigned char *)&new_mant;
-                             break;
-                           }
-                       }
-                   }
-                 else    /* Rbits is exactly half of LSB */
-                   {
-                     if ((mant & 0x40)) /* LSB is one so we round up */
-                       {
-                         /* Round up to next higher value of LSB */
-                         for (i = 6; i < 10; i++)
-                           {
-                             bit = mant & (1 << i);
-                             if (bit == 0)
-                               {
-                                 new_mant = (mant | ((unsigned short)1 << i)) & (0xFFFF << i);
-                                 mp  = (unsigned char *)&new_mant;
-                                 break;
-                               }
-                           }
-                       }
-                   }
-               }
-           }
-       }
+                  break;
+                }
+            }
+          else /* Normal value within range of target type */
+            {
+              /* Check bits to the right of unit in last signficant place
+               * for destination, eg first digit that cannot be stored.
+               * Rounding of least significant retained bit falls to value
+               * which will produce a zero in the LSB if the bounding values
+               * are equidistant from the unrounded value.
+               */
+              rbits = mant & 0x3F;
+              if (rbits >= 0x20)  /* Greater than or equal to 0.5 times LSB */
+                {
+                  if (rbits > 0x20) /* Rbits is greater than half of LSB */
+                    {
+                      /* Round up to next higher value of LSB */
+                      for (i = 6; i < 16; i++)
+                        {
+                          bit = mant & (1 << i);
+                          if (bit == 0)
+                            {
+                              new_mant = (mant | ((unsigned short)1 << i)) & (0xFFFF << i);
+                              mp  = (unsigned char *)&new_mant;
+                              break;
+                            }
+                        }
+                    }
+                  else    /* Rbits is exactly half of LSB */
+                    {
+                      if ((mant & 0x40)) /* LSB is one so we round up */
+                        {
+                          /* Round up to next higher value of LSB */
+                          for (i = 6; i < 10; i++)
+                            {
+                              bit = mant & (1 << i);
+                              if (bit == 0)
+                                {
+                                  new_mant = (mant | ((unsigned short)1 << i)) & (0xFFFF << i);
+                                  mp  = (unsigned char *)&new_mant;
+                                  break;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
       /* Extract bits into contiguous positions in bytes */
 #if !defined(WORDS_BIGENDIAN)
-       {
-         m2 =  (*(mp + 1) & 0xC0) >> 6;
-         m1 = ((*(mp + 1) & 0x3F) << 2) |
-           ((*mp & 0xC0) >> 6);
-         *dst = m1;
-         *(dst + 1) = sbit | ((new_expt & 0x1F) << 2) | m2;
-       }
+        {
+          m2 =  (*(mp + 1) & 0xC0) >> 6;
+          m1 = ((*(mp + 1) & 0x3F) << 2) |
+            ((*mp & 0xC0) >> 6);
+          *dst = m1;
+          *(dst + 1) = sbit | ((new_expt & 0x1F) << 2) | m2;
+        }
 #else
-       {
-         m2 = (*mp & 0xC0) >> 6;
-         m1 = ((*mp & 0x3F) << 2) |
-           ((*(mp + 1) & 0xC0) >> 6);
-         *dst = sbit | ((new_expt & 0x1F) << 2) | m2;
-         *(dst + 1) = m1;
-       }
+        {
+          m2 = (*mp & 0xC0) >> 6;
+          m1 = ((*mp & 0x3F) << 2) |
+            ((*(mp + 1) & 0xC0) >> 6);
+          *dst = sbit | ((new_expt & 0x1F) << 2) | m2;
+          *(dst + 1) = m1;
+        }
 #endif /* !defined(WORDS_BIGENDIAN) */
     }
 
@@ -366,64 +366,64 @@ int _Gm_convert_fp32_to_fp16 (const float *fp32, fp_16bits *fp16, const int mode
       bit = mant & (1 << k);
       printf ("%d", bit ? 1 : 0);
       if (j == 9)
-       printf (" ");
+        printf (" ");
       if (bit && (j > 9))
-       roundup += (1.0 / (double)(1 << (j - 9)));
+        roundup += (1.0 / (double)(1 << (j - 9)));
     }
   if (new_mant == 0)
     {
       printf (" Fract: %8.6f  m2m1 ", roundup);
       for (j = 0, k = 1; j < 2; j++, k--)
-       {
-         bit = m2 & (1 << k);
-         printf ("%d", bit ? 1 : 0);
-       }
+        {
+          bit = m2 & (1 << k);
+          printf ("%d", bit ? 1 : 0);
+        }
       for (j = 0, k = 7; j < 8; j++, k--)
-       {
-         bit = m1 & (1 << k);
-         printf ("%d", bit ? 1 : 0);
-       }
+        {
+          bit = m1 & (1 << k);
+          printf ("%d", bit ? 1 : 0);
+        }
     }
   else
     {
       printf (" Fract: %8.6f  Rbits Mant ", roundup);
       for (j = 0, k = 9; j < 10; j++, k--)
-       {
-         bit = new_mant & (1 << k);
-         printf ("%d", bit ? 1 : 0);
-       }
+        {
+          bit = new_mant & (1 << k);
+          printf ("%d", bit ? 1 : 0);
+        }
     }
   printf (" Sbit + Exp ");
 #if !defined(WORDS_BIGENDIAN)
     {
       for (i = 1; i >= 0; i--)
-       {
-         for (j = 0, k = 7; j < 8; j++, k--)
-           {
-             bit = *(dst + i) & (1 << k);
-             printf ("%d", bit ? 1 : 0);
-             if (i == 1 && j == 5)
-               printf ("  Mant: ");
-           }
-       }
+        {
+          for (j = 0, k = 7; j < 8; j++, k--)
+            {
+              bit = *(dst + i) & (1 << k);
+              printf ("%d", bit ? 1 : 0);
+              if (i == 1 && j == 5)
+                printf ("  Mant: ");
+            }
+        }
     }
 #else
     {
       for (i = 0; i < 2; i++)
-       {
-         for (j = 0, k = 7; j < 8; j++, k--)
-           {
-             bit = *(dst + i) & (1 << k);
-             printf ("%d", bit ? 1 : 0);
-             if (i == 0 && j == 5)
-               printf ("  Mant: ");
-           }
-       }
+        {
+          for (j = 0, k = 7; j < 8; j++, k--)
+            {
+              bit = *(dst + i) & (1 << k);
+              printf ("%d", bit ? 1 : 0);
+              if (i == 0 && j == 5)
+                printf ("  Mant: ");
+            }
+        }
     }
 #endif /* !defined(WORDS_BIGENDIAN) */
   printf ("\n");
 
-  mant = ((unsigned short)m2 << 8) | (unsigned short)m1; 
+  mant = ((unsigned short)m2 << 8) | (unsigned short)m1;
   if (*fp32 == 0)
     {
       test = 0.0;
@@ -434,35 +434,35 @@ int _Gm_convert_fp32_to_fp16 (const float *fp32, fp_16bits *fp16, const int mode
     {
       accum = 0.0;
       for (i = 9, j = 1; i >= 0; i--, j++)
-       {
-         bit = mant & ((unsigned int)1 << i);
-         if (bit)
-           accum += (1.0 / ((unsigned int)1 << j));
-       }
+        {
+          bit = mant & ((unsigned int)1 << i);
+          if (bit)
+            accum += (1.0 / ((unsigned int)1 << j));
+        }
       if (new_expt == 0)
-       {
-         accum += 2.0;
-         test = pow (2.0, 1.0 * (-15 - rshift));
-       }
+        {
+          accum += 2.0;
+          test = pow (2.0, 1.0 * (-15 - rshift));
+        }
       else
-       {
-         accum += 1.0;
-         test = pow (2.0, 1.0 * (new_expt - 15));
-       }
+        {
+          accum += 1.0;
+          test = pow (2.0, 1.0 * (new_expt - 15));
+        }
       switch (errno)
-       {
-       case 0:     break;
-       case EDOM: 
-       case ERANGE: 
-       default: perror ("Invalid value");
-         break;
-       }
+        {
+        case 0:     break;
+        case EDOM:
+        case ERANGE:
+        default: perror ("Invalid value");
+          break;
+        }
       test2 = accum * test;
       if (sbit)
-       test2 *= -1.0;
+        test2 *= -1.0;
     }
   printf ("              Sign bit: %u, Expt biased to %5u,  2^%-5d = %8.10f  *  %10.8f = %18.10f\n\n",
-         sbit > 0 ? 1 : 0, new_expt, new_expt > 0 ? new_expt - 15 : 0, test, accum, test2);
+          sbit > 0 ? 1 : 0, new_expt, new_expt > 0 ? new_expt - 15 : 0, test, accum, test2);
 #endif
   return (0);
 } /* end _Gm_convert_fp32_to_fp16 */
@@ -482,8 +482,8 @@ int _Gm_convert_fp24_to_fp32 (const fp_24bits *fp24, float *fp32, const int mode
 
 #ifdef DEBUG32
   int      i, j, k, bit;
-  double   test  = 0.0; 
-  double   test2 = 0.0; 
+  double   test  = 0.0;
+  double   test2 = 0.0;
   double   accum = 0.0;
   errno = 0;
 #endif
@@ -515,29 +515,29 @@ int _Gm_convert_fp24_to_fp32 (const fp_24bits *fp24, float *fp32, const int mode
   else
     {
 #if !defined(WORDS_BIGENDIAN)
-       {
-         sbit = *(src + 2) & 0x80;
-         expt = *(src + 2) & 0x7F;
-         m2  =  *(src + 1);
-         m1  =  *src;
-       }
+        {
+          sbit = *(src + 2) & 0x80;
+          expt = *(src + 2) & 0x7F;
+          m2  =  *(src + 1);
+          m1  =  *src;
+        }
 #else
-       {
-         sbit = *src & 0x80;
-         expt = *src & 0x7F;
-         m2  =  *(src + 1);
-         m1  =  *(src + 2);
-       }
+        {
+          sbit = *src & 0x80;
+          expt = *src & 0x7F;
+          m2  =  *(src + 1);
+          m1  =  *(src + 2);
+        }
 #endif /* !defined(WORDS_BIGENDIAN) */
 
       if (expt != 0)
-       new_expt = expt - 63 + 127;
+        new_expt = expt - 63 + 127;
       /* mant = (m2 << 8) | m1; */
       new_m3  =  (m2 & 0xFE) >> 1;
       new_m2  = ((m2 & 0x01) << 7) | ((m1 & 0xFE) >> 1);
       new_m1  =  (m1 & 0x01) << 7;
     }
-  /* We do not have to worry about underflow or overflow 
+  /* We do not have to worry about underflow or overflow
    * since the target has more significant bits in the
    * exponent and the significand.
    */
@@ -565,7 +565,7 @@ int _Gm_convert_fp24_to_fp32 (const fp_24bits *fp24, float *fp32, const int mode
     {
       bit = mant & (1 << k);
       if ((j % 8) == 0)
-       printf(" ");
+        printf(" ");
       printf ("%d", bit ? 1 : 0);
     }
 
@@ -575,35 +575,35 @@ int _Gm_convert_fp24_to_fp32 (const fp_24bits *fp24, float *fp32, const int mode
       bit = new_mant & (1 << k);
       printf ("%d", bit ? 1 : 0);
       if ((k % 8) == 0)
-       printf(" ");
+        printf(" ");
     }
 
   printf (" Sbit + Exp ");
 #if !defined(WORDS_BIGENDIAN)
     {
       for (i = 3; i >= 0; i--)
-       {
-         for (j = 0, k = 7; j < 8; j++, k--)
-           {
-             bit = *(dst + i) & (1 << k);
-             if (i == 2 && j == 1)
-               printf ("  Mant: ");
-             printf ("%d", bit ? 1 : 0);
-           }
-       }
+        {
+          for (j = 0, k = 7; j < 8; j++, k--)
+            {
+              bit = *(dst + i) & (1 << k);
+              if (i == 2 && j == 1)
+                printf ("  Mant: ");
+              printf ("%d", bit ? 1 : 0);
+            }
+        }
     }
 #else
     {
       for (i = 0; i < 4; i++)
-       {
-         for (j = 0, k = 7; j < 8; j++, k--)
-           {
-             bit = *(dst + i) & (1 << k);
-             if (i == 1 && j == 1)
-               printf ("  Mant: ");
-             printf ("%d", bit ? 1 : 0);
-           }
-       }
+        {
+          for (j = 0, k = 7; j < 8; j++, k--)
+            {
+              bit = *(dst + i) & (1 << k);
+              if (i == 1 && j == 1)
+                printf ("  Mant: ");
+              printf ("%d", bit ? 1 : 0);
+            }
+        }
     }
 #endif /* !defined(WORDS_BIGENDIAN) */
   printf ("\n");
@@ -619,27 +619,27 @@ int _Gm_convert_fp24_to_fp32 (const fp_24bits *fp24, float *fp32, const int mode
     {
       accum = 0.0;
       for (i = 22, j = 1; i >= 0; i--, j++)
-       {
-         bit = new_mant & ((unsigned int)1 << i);
-         if (bit)
-           accum += (1.0 / ((unsigned int)1 << j));
-       }
+        {
+          bit = new_mant & ((unsigned int)1 << i);
+          if (bit)
+            accum += (1.0 / ((unsigned int)1 << j));
+        }
       accum += 1.0;
       test = pow (2.0, 1.0 * (new_expt - 127));
       switch (errno)
-       {
-       case 0:     break;
-       case EDOM: 
-       case ERANGE: 
-       default: perror ("Invalid value");
-         break;
-       }
+        {
+        case 0:     break;
+        case EDOM:
+        case ERANGE:
+        default: perror ("Invalid value");
+          break;
+        }
       test2 = accum * test;
       if (sbit)
-       test2 *= -1.0;
+        test2 *= -1.0;
     }
   printf ("              Sign bit: %u, Expt biased to %5u,  2^%-5d = %8.1f  *  %10.8f = %18.10f\n\n",
-         sbit > 0 ? 1 : 0, new_expt, new_expt > 0 ? new_expt - 127 : 0, test, accum, test2);
+          sbit > 0 ? 1 : 0, new_expt, new_expt > 0 ? new_expt - 127 : 0, test, accum, test2);
 #endif
 
   return (0);
@@ -664,8 +664,8 @@ int _Gm_convert_fp32_to_fp24 (const float *fp32, fp_24bits *fp24, const int mode
 
 #ifdef DEBUG24
   int      j, k;
-  double   test  = 0.0; 
-  double   test2 = 0.0; 
+  double   test  = 0.0;
+  double   test2 = 0.0;
   double   accum = 0.0;
   double   roundup = 0.0;
 #endif
@@ -690,155 +690,155 @@ int _Gm_convert_fp32_to_fp24 (const float *fp32, fp_24bits *fp24, const int mode
   if (*fp32 != 0)
     {
 #if !defined(WORDS_BIGENDIAN)
-       {
-         sbit =   *(src + 3) & 0x80;
-         expt = ((*(src + 3) & 0x7F) << 1) | 
-           ((*(src + 2) & 0x80) >> 7);
-         m3  = (((*(src + 2) & 0x7F)) << 1) |
-           ((*(src + 1) & 0x80) >> 7);
-         m2  = (((*(src + 1) & 0x7F)) << 1)  |
-           ((*src & 0x80) >> 7);
-         m1  =  (*src & 0x7F) << 1;
-       }
+        {
+          sbit =   *(src + 3) & 0x80;
+          expt = ((*(src + 3) & 0x7F) << 1) |
+            ((*(src + 2) & 0x80) >> 7);
+          m3  = (((*(src + 2) & 0x7F)) << 1) |
+            ((*(src + 1) & 0x80) >> 7);
+          m2  = (((*(src + 1) & 0x7F)) << 1)  |
+            ((*src & 0x80) >> 7);
+          m1  =  (*src & 0x7F) << 1;
+        }
 #else
-       {
-         sbit =   *src & 0x80;
-         expt = ((*src & 0x7F) << 1) | 
-           ((*(src + 1) & 0x80) >> 7);
-         m3  = (((*(src + 1) & 0x7F)) << 1) |
-           ((*(src + 2) & 0x80) >> 7);
-         m2  = (((*(src + 2) & 0x7F)) << 1)  |
-           ((*(src + 3) & 0x80) >> 7);
-         m1  =  (*(src + 3) & 0x7F) << 1;
-       }
+        {
+          sbit =   *src & 0x80;
+          expt = ((*src & 0x7F) << 1) |
+            ((*(src + 1) & 0x80) >> 7);
+          m3  = (((*(src + 1) & 0x7F)) << 1) |
+            ((*(src + 2) & 0x80) >> 7);
+          m2  = (((*(src + 2) & 0x7F)) << 1)  |
+            ((*(src + 3) & 0x80) >> 7);
+          m1  =  (*(src + 3) & 0x7F) << 1;
+        }
 #endif /* !defined(WORDS_BIGENDIAN) */
 
-      mant = (m3 << 24) | (m2 << 16) |( m1 << 8); 
+      mant = (m3 << 24) | (m2 << 16) |( m1 << 8);
       if (expt != 0)
-       new_expt = expt - 127 + 63;
+        new_expt = expt - 127 + 63;
 
-      /* Even if the new exponent is too small to represent, 
+      /* Even if the new exponent is too small to represent,
        * the mantissa could have signficant digits that can
        * be represented in the new value as a subnormal.
        */
       if (new_expt <= 0) /* Underflow */
-       {
-         rshift = 0 - new_expt;
-         switch (mode)
-           {
-           case STRICT_IEEE: /* NaN has all 1s in exponent plus 2 bits in Mantissa */
-             if (rshift > FP24_MANT_BITS)
-               {
-                 new_expt = 0x7F;
-                 new_mant = 0x80010000;
-                 errno = ERANGE;
-                 fflush (stdout);
-                 fprintf (stderr, "Underflow. %18.10f Result clipped\n", *fp32);
-                 fflush (stderr);
-                 return (1);  /* The number cannot be represented as fp24 */
-               }
-             break;
-           case RANGE_LIMITED: /* Clamp to smallest subnormal */
-             new_expt = 0;
-             new_mant = mant >> rshift;;
-             mp = (unsigned char *)&new_mant;
+        {
+          rshift = 0 - new_expt;
+          switch (mode)
+            {
+            case STRICT_IEEE: /* NaN has all 1s in exponent plus 2 bits in Mantissa */
+              if (rshift > FP24_MANT_BITS)
+                {
+                  new_expt = 0x7F;
+                  new_mant = 0x80010000;
+                  errno = ERANGE;
+                  fflush (stdout);
+                  fprintf (stderr, "Underflow. %18.10f Result clipped\n", *fp32);
+                  fflush (stderr);
+                  return (1);  /* The number cannot be represented as fp24 */
+                }
+              break;
+            case RANGE_LIMITED: /* Clamp to smallest subnormal */
+              new_expt = 0;
+              new_mant = mant >> rshift;;
+              mp = (unsigned char *)&new_mant;
 #ifdef DEBUG24
-             fflush (stdout);
-             fprintf (stderr, "Underflow. %18.10f Result clippped to subnormal value\n", *fp32);
-             fflush (stderr);
+              fflush (stdout);
+              fprintf (stderr, "Underflow. %18.10f Result clippped to subnormal value\n", *fp32);
+              fflush (stderr);
 #endif
-             break;        
-           case ZERO_LIMITED:  /* Clamp to zero instead of using a subnormal */
-             new_expt = 0;
-             new_mant = 0;
-             mp = (unsigned char *)&new_mant;
+              break;
+            case ZERO_LIMITED:  /* Clamp to zero instead of using a subnormal */
+              new_expt = 0;
+              new_mant = 0;
+              mp = (unsigned char *)&new_mant;
 #ifdef DEBUG24
-             fflush (stdout);
-             fprintf (stderr, "Underflow. %18.10f Result clippped to zero\n", *fp32);
-             fflush (stderr);
+              fflush (stdout);
+              fprintf (stderr, "Underflow. %18.10f Result clippped to zero\n", *fp32);
+              fflush (stderr);
 #endif
-             break;        
-           }
-       }
+              break;
+            }
+        }
       else /* Take the MSB from the old mantissa and left justify them */
-       {
-         if (new_expt > 126) /* Overflow */
-           {
-             switch (mode)
-               {
-               case STRICT_IEEE: /* NaN has all 1s in exponent plus 2 bits in Mantissa */
-                 new_expt = 0x7F;
-                 mant = 0x80010000;
-                 errno = ERANGE;
-                 fflush (stdout);
-                 fprintf (stderr, "Overflow. Result clipped\n");
-                 fflush (stderr);
-                 return (1);
-               case ZERO_LIMITED:
-               case RANGE_LIMITED:  /* Clamp to maximum allowed value for fp24 */
-                 new_expt = 126;
-                 new_mant = 0xFFFF0000;
-                 mp = (unsigned char *)&new_mant;
+        {
+          if (new_expt > 126) /* Overflow */
+            {
+              switch (mode)
+                {
+                case STRICT_IEEE: /* NaN has all 1s in exponent plus 2 bits in Mantissa */
+                  new_expt = 0x7F;
+                  mant = 0x80010000;
+                  errno = ERANGE;
+                  fflush (stdout);
+                  fprintf (stderr, "Overflow. Result clipped\n");
+                  fflush (stderr);
+                  return (1);
+                case ZERO_LIMITED:
+                case RANGE_LIMITED:  /* Clamp to maximum allowed value for fp24 */
+                  new_expt = 126;
+                  new_mant = 0xFFFF0000;
+                  mp = (unsigned char *)&new_mant;
 #ifdef DEBUG24
-                 fflush (stdout);
-                 fprintf (stderr, "Overflow. Result clippped\n");
-                 fflush (stderr);
+                  fflush (stdout);
+                  fprintf (stderr, "Overflow. Result clippped\n");
+                  fflush (stderr);
 #endif
-                 break;        
-               }
-           }
-         else /* Normal value within range of target type */
-           { /* Remove the bits to the left of the binary point 
-              * by shifting the fractional bits into the leftmost position
-              */
-             /* Check bits to the right of Unit in last signficant place.
-              * Rounding of least significant retained bit falls to value
-              * which will produce a zero in the LSB if the bounding values
-              * are equidistant from the unrounded value.
-              */
-
-             rbits = mant & 0x0000FFFF;
-             if (rbits >= 0x8000)  /* Greater than or equal to 0.5 times LSB */
-               {
-                 if (rbits > 0x8000) /* Rbits is greater than half of LSB */
-                   {
-                     /* Round up to next higher value of LSB */
-                     for (i = 16; i < 32; i++)
-                       {
-                         bit = mant & (1 << i);
-                         if (bit == 0)
-                           { 
-                             /* Round up by inserting a 1 at first zero and 
-                              * clearing bits to the right
-                              */
-                             new_mant = (mant | ((unsigned int)1 << i)) &
-                               (0xFFFF << i);
-                             mp  = (unsigned char *)&new_mant;
-                             break;
-                           }
-                       }
-                   }
-                 else    /* Rbits is exactly half of LSB */
-                   {
-                     if ((mant & 0x010000)) /* LSB is one so we round up */
-                       {
-                         /* Round up to next higher value of LSB */
-                         for (i = 16; i < 32; i++)
-                           {
-                             bit = mant & (1 << i);
-                             if (bit == 0)
-                               {
-                                 new_mant = (mant | ((unsigned int)1 << i)) &
-                                   (0xFFFF << i);
-                                 mp  = (unsigned char *)&new_mant;
-                                 break;
-                               }
-                           }
-                       }
-                   }
-               }
-           }
-       }
+                  break;
+                }
+            }
+          else /* Normal value within range of target type */
+            { /* Remove the bits to the left of the binary point
+               * by shifting the fractional bits into the leftmost position
+               */
+              /* Check bits to the right of Unit in last signficant place.
+               * Rounding of least significant retained bit falls to value
+               * which will produce a zero in the LSB if the bounding values
+               * are equidistant from the unrounded value.
+               */
+
+              rbits = mant & 0x0000FFFF;
+              if (rbits >= 0x8000)  /* Greater than or equal to 0.5 times LSB */
+                {
+                  if (rbits > 0x8000) /* Rbits is greater than half of LSB */
+                    {
+                      /* Round up to next higher value of LSB */
+                      for (i = 16; i < 32; i++)
+                        {
+                          bit = mant & (1 << i);
+                          if (bit == 0)
+                            {
+                              /* Round up by inserting a 1 at first zero and
+                               * clearing bits to the right
+                               */
+                              new_mant = (mant | ((unsigned int)1 << i)) &
+                                (0xFFFF << i);
+                              mp  = (unsigned char *)&new_mant;
+                              break;
+                            }
+                        }
+                    }
+                  else    /* Rbits is exactly half of LSB */
+                    {
+                      if ((mant & 0x010000)) /* LSB is one so we round up */
+                        {
+                          /* Round up to next higher value of LSB */
+                          for (i = 16; i < 32; i++)
+                            {
+                              bit = mant & (1 << i);
+                              if (bit == 0)
+                                {
+                                  new_mant = (mant | ((unsigned int)1 << i)) &
+                                    (0xFFFF << i);
+                                  mp  = (unsigned char *)&new_mant;
+                                  break;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
     }
 #if !defined(WORDS_BIGENDIAN)
     {
@@ -865,69 +865,69 @@ int _Gm_convert_fp32_to_fp24 (const float *fp32, fp_24bits *fp24, const int mode
     {
       bit = mant & (1 << k);
       if ((j % 8) == 0)
-       printf(" ");
+        printf(" ");
       printf ("%d", bit ? 1 : 0);
       if (bit && (j > 15))
-       roundup += (1.0 / (double)(1 << (j - 15)));
+        roundup += (1.0 / (double)(1 << (j - 15)));
     }
 
   if (new_mant == 0)
     {
       printf (" Fract: %8.6f  m2m1 ", roundup);
       for (j = 0, k = 7; j < 8; j++, k--)
-       {
-         bit = new_m2 & (1 << k);
-         printf ("%d", bit ? 1 : 0);
-       }
+        {
+          bit = new_m2 & (1 << k);
+          printf ("%d", bit ? 1 : 0);
+        }
       printf(" ");
       for (j = 0, k = 7; j < 8; j++, k--)
-       {
-         bit = new_m1 & (1 << k);
-         printf ("%d", bit ? 1 : 0);
-       }
+        {
+          bit = new_m1 & (1 << k);
+          printf ("%d", bit ? 1 : 0);
+        }
     }
   else
     {
       printf (" Fract: %8.6f  Rbits Mant ", roundup);
       for (j = 0, k = 31; j < 16; j++, k--)
-       {
-         bit = new_mant & (1 << k);
-         if (j == 8)
-           printf(" ");
-         printf ("%d", bit ? 1 : 0);
-       }
+        {
+          bit = new_mant & (1 << k);
+          if (j == 8)
+            printf(" ");
+          printf ("%d", bit ? 1 : 0);
+        }
     }
   printf (" Sbit + Exp ");
 #if !defined(WORDS_BIGENDIAN)
     {
       for (i = 2; i >= 0; i--)
-       {
-         for (j = 0, k = 7; j < 8; j++, k--)
-           {
-             bit = *(dst + i) & (1 << k);
-             if (i == 1 && j == 0)
-               printf ("  Mant: ");
-             printf ("%d", bit ? 1 : 0);
-           }
-       }
+        {
+          for (j = 0, k = 7; j < 8; j++, k--)
+            {
+              bit = *(dst + i) & (1 << k);
+              if (i == 1 && j == 0)
+                printf ("  Mant: ");
+              printf ("%d", bit ? 1 : 0);
+            }
+        }
     }
 #else
     {
       for (i = 0; i < 3; i++)
-       {
-         for (j = 0, k = 7; j < 8; j++, k--)
-           {
-             bit = *(dst + i) & (1 << k);
-             if (i == 1 && j == 0)
-               printf ("  Mant: ");
-             printf ("%d", bit ? 1 : 0);
-           }
-       }
+        {
+          for (j = 0, k = 7; j < 8; j++, k--)
+            {
+              bit = *(dst + i) & (1 << k);
+              if (i == 1 && j == 0)
+                printf ("  Mant: ");
+              printf ("%d", bit ? 1 : 0);
+            }
+        }
     }
 #endif /* !defined(WORDS_BIGENDIAN) */
   printf ("\n");
 
-  mant = ((unsigned int)new_m2 << 8) | (unsigned int)new_m1; 
+  mant = ((unsigned int)new_m2 << 8) | (unsigned int)new_m1;
   if (*fp32 == 0.0)
     {
       test = 0.0;
@@ -938,28 +938,28 @@ int _Gm_convert_fp32_to_fp24 (const float *fp32, fp_24bits *fp24, const int mode
     {
       accum = 0.0;
       for (i = 15, j = 1; i >= 0; i--, j++)
-       {
-         bit = mant & ((unsigned int)1 << i);
-         if (bit)
-           accum += (1.0 / ((unsigned int)1 << j));
-       }
+        {
+          bit = mant & ((unsigned int)1 << i);
+          if (bit)
+            accum += (1.0 / ((unsigned int)1 << j));
+        }
       if (new_expt != 0)
-       accum += 1.0;
+        accum += 1.0;
       test = pow (2.0, 1.0 * (new_expt - 63));
       switch (errno)
-       {
-       case 0:     break;
-       case EDOM: 
-       case ERANGE: 
-       default: perror ("Invalid value");
-         break;
-       }
+        {
+        case 0:     break;
+        case EDOM:
+        case ERANGE:
+        default: perror ("Invalid value");
+          break;
+        }
       test2 = accum * test;
       if (sbit)
-       test2 *= -1.0;
+        test2 *= -1.0;
     }
   printf ("              Sign bit: %u, Expt biased to %5u,  2^%-5d = %8.10f  *  %10.8f = %18.10f\n\n",
-         sbit > 0 ? 1 : 0, new_expt, new_expt > 0 ? new_expt - 63 : 0, test, accum, test2);
+          sbit > 0 ? 1 : 0, new_expt, new_expt > 0 ? new_expt - 63 : 0, test, accum, test2);
 #endif
 
   return (0);
index 0d2d27b..8ebd335 100644 (file)
@@ -1,10 +1,10 @@
 /*
   Copyright (C) 2008 - 2011 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   16/24 bit floating point conversion functions.
 
   Written by Richard Nolde, 2008
index 93a29a0..70a5519 100644 (file)
@@ -1,12 +1,12 @@
 /*
   Copyright (C) 2007 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
 
   Forward declarations for types used in public structures.
+
 */
 #ifndef _MAGICK_FORWARD_H
 #define _MAGICK_FORWARD_H
index 69fb676..59f5941 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2009 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -155,12 +155,12 @@ typedef struct _ColorizeImagePixelsOptions
 static MagickPassFail
 ColorizeImagePixelsCB(void *mutable_data,                /* User provided mutable data */
                       const void *immutable_data,        /* User provided immutable data */
-                      const Image *source_image,         /* Source image */
-                      const PixelPacket *source_pixels,  /* Pixel row in source image */
-                      const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                      Image *new_image,                  /* New image */
-                      PixelPacket *new_pixels,           /* Pixel row in new image */
-                      IndexPacket *new_indexes,          /* Pixel row indexes in new image */
+                      const Image * restrict source_image,         /* Source image */
+                      const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                      const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                      Image * restrict new_image,                  /* New image */
+                      PixelPacket * restrict new_pixels,           /* Pixel row in new image */
+                      IndexPacket * restrict new_indexes,          /* Pixel row indexes in new image */
                       const long npixels,                /* Number of pixels in row */
                       ExceptionInfo *exception           /* Exception report */
                       )
@@ -318,9 +318,9 @@ typedef struct _ColorMatrixImageOptions_t
 static MagickPassFail
 ColorMatrixImagePixels(void *mutable_data,         /* User provided mutable data */
                        const void *immutable_data, /* User provided immutable data */
-                       Image *image,               /* Modify image */
-                       PixelPacket *pixels,        /* Pixel row */
-                       IndexPacket *indexes,       /* Pixel row indexes */
+                       Image * restrict image,     /* Modify image */
+                       PixelPacket * restrict pixels, /* Pixel row */
+                       IndexPacket * restrict indexes, /* Pixel row indexes */
                        const long npixels,         /* Number of pixels in row */
                        ExceptionInfo *exception)   /* Exception report */
 {
@@ -351,55 +351,55 @@ ColorMatrixImagePixels(void *mutable_data,         /* User provided mutable data
   for (i=0; i < npixels; i++)
     {
       unsigned int
-       row;
+        row;
 
       /*
-       Accumulate float input pixel
+        Accumulate float input pixel
       */
       column[0]=(double) pixels[i].red;
       column[1]=(double) pixels[i].green;
       column[2]=(double) pixels[i].blue;
       if (image->matte)
-       column[3]=(MaxRGBDouble-(double) pixels[i].opacity);
+        column[3]=(MaxRGBDouble-(double) pixels[i].opacity);
 
       /*
-       Compute row sums.
+        Compute row sums.
       */
       for (row=0; row < 4; row++)
-       {
-         const double
-           *m;
+        {
+          const double
+            *m;
 
-         if ((m = options->matrix[row]) != (const double *) NULL)
-           sums[row]=m[0]*column[0] + m[1]*column[1] + m[2]*column[2] +
-             m[3]*column[3] + m[4]*column[4];
-       }
+          if ((m = options->matrix[row]) != (const double *) NULL)
+            sums[row]=m[0]*column[0] + m[1]*column[1] + m[2]*column[2] +
+              m[3]*column[3] + m[4]*column[4];
+        }
 
       /*
-       Assign results.
+        Assign results.
       */
       for (row=0; row < 4; row++)
-       {
-         if (options->matrix[row] != (const double *) NULL)
-           {
-             switch (row)
-               {
-               case 0:
-                 pixels[i].red = RoundDoubleToQuantum(sums[row]);
-                 break;
-               case 1:
-                 pixels[i].green = RoundDoubleToQuantum(sums[row]);
-                 break;
-               case 2:
-                 pixels[i].blue = RoundDoubleToQuantum(sums[row]);
-                 break;
-               case 3:
-                 sums[row]=(MaxRGBDouble-sums[row]);
-                 pixels[i].opacity = RoundDoubleToQuantum(sums[row]);
-                 break;
-               }
-           }
-       }
+        {
+          if (options->matrix[row] != (const double *) NULL)
+            {
+              switch (row)
+                {
+                case 0:
+                  pixels[i].red = RoundDoubleToQuantum(sums[row]);
+                  break;
+                case 1:
+                  pixels[i].green = RoundDoubleToQuantum(sums[row]);
+                  break;
+                case 2:
+                  pixels[i].blue = RoundDoubleToQuantum(sums[row]);
+                  break;
+                case 3:
+                  sums[row]=(MaxRGBDouble-sums[row]);
+                  pixels[i].opacity = RoundDoubleToQuantum(sums[row]);
+                  break;
+                }
+            }
+        }
     }
 
   return MagickPass;
@@ -433,7 +433,7 @@ ColorMatrixImage(Image *image,const unsigned int order,const double *color_matri
 
   if ((order < 1) || (order > 5))
     ThrowBinaryException(OptionError,MatrixOrderOutOfRange,
-                        MagickMsg(OptionError,UnableToColorMatrixImage));
+                         MagickMsg(OptionError,UnableToColorMatrixImage));
 
   assert(color_matrix != (const double *) NULL);
 
@@ -453,16 +453,16 @@ ColorMatrixImage(Image *image,const unsigned int order,const double *color_matri
     u = color_matrix;
     for (i=0; i < order; i++)
       {
-       d = &matrix[i*5];
-       for (j=0; j < order; j++)
-         {
-           if (d[j] != *u)
-             {
-               d[j]=*u;
-               options.matrix[i]=&matrix[i*5];
-             }
-           u++;
-         }
+        d = &matrix[i*5];
+        for (j=0; j < order; j++)
+          {
+            if (d[j] != *u)
+              {
+                d[j]=*u;
+                options.matrix[i]=&matrix[i*5];
+              }
+            u++;
+          }
       }
 
     /*
@@ -519,18 +519,18 @@ ColorMatrixImage(Image *image,const unsigned int order,const double *color_matri
     {
       image->storage_class=DirectClass;
       /*
-       We don't currently handle CMYK(A) colorspaces, although
-       manipulation in other alternate colorspaces may be useful.
+        We don't currently handle CMYK(A) colorspaces, although
+        manipulation in other alternate colorspaces may be useful.
       */
       if (image->colorspace == CMYKColorspace)
-       (void) TransformColorspace(image,RGBColorspace);
+        (void) TransformColorspace(image,RGBColorspace);
       status=PixelIterateMonoModify(ColorMatrixImagePixels,
-                                   NULL,
-                                   ColorMatrixImageText,
-                                   NULL,&options,
-                                   0,0,image->columns,image->rows,
-                                   image,
-                                   &image->exception);
+                                    NULL,
+                                    ColorMatrixImageText,
+                                    NULL,&options,
+                                    0,0,image->columns,image->rows,
+                                    image,
+                                    &image->exception);
     }
 
   return status;
@@ -570,7 +570,7 @@ ColorMatrixImage(Image *image,const unsigned int order,const double *color_matri
 %
 %
 */
-MagickExport Image *ImplodeImage(const Image *image,const double amount,
+MagickExport Image *ImplodeImage(const Image * restrict image,const double amount,
                                  ExceptionInfo *exception)
 {
 #define ImplodeImageText "[%s] Implode..."
@@ -583,7 +583,7 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
     y_scale;
 
   Image
-    *implode_image;
+    * restrict implode_image;
 
   long
     y;
@@ -640,7 +640,7 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
           x;
 
         register PixelPacket
-          *q;
+          * restrict q;
 
         double
           distance,
@@ -653,9 +653,6 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
         MagickPassFail
           thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_ImplodeImage)
-#endif
         thread_status=status;
         if (thread_status == MagickFail)
           continue;
@@ -688,29 +685,37 @@ MagickExport Image *ImplodeImage(const Image *image,const double amount,
                     factor=1.0;
                     if (distance > 0.0)
                       factor=pow(sin(MagickPI*sqrt(distance)/radius/2),-amount);
-                    InterpolateViewColor(image_view,q,
-                                         factor*x_distance/x_scale+x_center,
-                                         factor*y_distance/y_scale+y_center,
-                                         exception);
+                    if (InterpolateViewColor(image_view,q,
+                                             factor*x_distance/x_scale+x_center,
+                                             factor*y_distance/y_scale+y_center,
+                                             exception) == MagickFail)
+                      {
+                        thread_status=MagickFail;
+                        break;
+                      }
                   }
                 q++;
               }
-            if (!SyncImagePixelsEx(implode_image,exception))
-              thread_status=MagickFail;
+            if (thread_status != MagickFail)
+              if (!SyncImagePixelsEx(implode_image,exception))
+                thread_status=MagickFail;
           }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_ImplodeImage)
+#  pragma omp atomic
 #endif
-        {
-          row_count++;
-          if (QuantumTick(row_count,image->rows))
-            if (!MagickMonitorFormatted(row_count,image->rows,exception,
-                                        ImplodeImageText,implode_image->filename))
-              thread_status=MagickFail;
+        row_count++;
+        if (QuantumTick(row_count,image->rows))
+          if (!MagickMonitorFormatted(row_count,image->rows,exception,
+                                      ImplodeImageText,implode_image->filename))
+            thread_status=MagickFail;
 
-          if (thread_status == MagickFail)
+        if (thread_status == MagickFail)
+          {
             status=MagickFail;
-        }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+          }
       }
   }
   implode_image->is_grayscale=image->is_grayscale;
@@ -755,12 +760,12 @@ typedef struct _MorphImagePixelsOptions
 static MagickPassFail
 MorphImagePixelsCB(void *mutable_data,                /* User provided mutable data */
                    const void *immutable_data,        /* User provided immutable data */
-                   const Image *source_image,         /* Source image */
-                   const PixelPacket *source_pixels,  /* Pixel row in source image */
-                   const IndexPacket *source_indexes, /* Pixel row indexes in source image */
-                   Image *new_image,                  /* New image */
-                   PixelPacket *new_pixels,           /* Pixel row in new image */
-                   IndexPacket *new_indexes,          /* Pixel row indexes in new image */
+                   const Image * restrict source_image,         /* Source image */
+                   const PixelPacket * restrict source_pixels,  /* Pixel row in source image */
+                   const IndexPacket * restrict source_indexes, /* Pixel row indexes in source image */
+                   Image * restrict new_image,                  /* New image */
+                   PixelPacket * restrict new_pixels,           /* Pixel row in new image */
+                   IndexPacket * restrict new_indexes,          /* Pixel row indexes in new image */
                    const long npixels,                /* Number of pixels in row */
                    ExceptionInfo *exception           /* Exception report */
                    )
@@ -957,7 +962,7 @@ MagickExport Image *OilPaintImage(const Image *image,const double radius,
 
   unsigned long
     row_count=0;
-  
+
   MagickPassFail
     status=MagickPass;
 
@@ -992,12 +997,12 @@ MagickExport Image *OilPaintImage(const Image *image,const double radius,
   for (y=0; y < (long) image->rows; y++)
     {
       const PixelPacket
-        *p,
+        * restrict p,
         *r;
-    
+
       PixelPacket
-        *q;
-    
+        * restrict q;
+
       long
         x;
 
@@ -1007,9 +1012,6 @@ MagickExport Image *OilPaintImage(const Image *image,const double radius,
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_OilPaintImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -1060,7 +1062,7 @@ MagickExport Image *OilPaintImage(const Image *image,const double radius,
                         intensity=ru->red;
                       else
                         intensity=PixelIntensityToQuantum(ru);
-                        
+
                       hp=histogram+ScaleQuantumToChar(intensity);
                       (*hp)++;
                       if (*hp > count)
@@ -1078,18 +1080,21 @@ MagickExport Image *OilPaintImage(const Image *image,const double radius,
             thread_status=MagickFail;
         }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_OilPaintImage)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,image->rows))
-          if (!MagickMonitorFormatted(row_count,image->rows,exception,
+      row_count++;
+      if (QuantumTick(row_count,image->rows))
+        if (!MagickMonitorFormatted(row_count,image->rows,exception,
                                       OilPaintImageText,image->filename))
-            thread_status=MagickFail;
-          
-        if (thread_status == MagickFail)
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
 
   paint_image->is_grayscale=image->is_grayscale;
@@ -1127,9 +1132,9 @@ MagickExport Image *OilPaintImage(const Image *image,const double radius,
 static MagickPassFail
 SolarizeImagePixelsCB(void *mutable_data,         /* User provided mutable data */
                       const void *immutable_data, /* User provided immutable data */
-                      Image *image,               /* Modify image */
-                      PixelPacket *pixels,        /* Pixel row */
-                      IndexPacket *indexes,       /* Pixel row indexes */
+                      Image * restrict image,               /* Modify image */
+                      PixelPacket * restrict pixels,        /* Pixel row */
+                      IndexPacket * restrict indexes,       /* Pixel row indexes */
                       const long npixels,         /* Number of pixels in row */
                       ExceptionInfo *exception)   /* Exception report */
 {
@@ -1138,7 +1143,7 @@ SolarizeImagePixelsCB(void *mutable_data,         /* User provided mutable data
     threshold = *((const double *) immutable_data);
 
   register long
-    i;  
+    i;
 
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(image);
@@ -1240,12 +1245,12 @@ MagickExport MagickPassFail SolarizeImage(Image *image,const double threshold)
 #define SetBit(a,i,set) \
   a=(Quantum) ((set) ? (a) | (1UL << (i)) : (a) & ~(1UL << (i)))
 #define SteganoImageText "[%s] Stegano..."
-MagickExport Image *SteganoImage(const Image *image,const Image *watermark,
+MagickExport Image *SteganoImage(const Image * restrict image,const Image * restrict watermark,
   ExceptionInfo *exception)
 {
 
   Image
-    *stegano_image;
+    * restrict stegano_image;
 
   long
     c,
@@ -1264,7 +1269,7 @@ MagickExport Image *SteganoImage(const Image *image,const Image *watermark,
     is_grayscale;
 
   register PixelPacket
-    *q;
+    * restrict q;
 
   /*
     Initialize steganographic image attributes.
@@ -1372,26 +1377,26 @@ MagickExport Image *SteganoImage(const Image *image,const Image *watermark,
 %
 %
 */
-MagickExport Image *StereoImage(const Image *image,const Image *offset_image,
+MagickExport Image *StereoImage(const Image * restrict image,const Image * restrict offset_image,
   ExceptionInfo *exception)
 {
 #define StereoImageText "[%s] Stereo..."
 
   Image
-    *stereo_image;
+    * restrict stereo_image;
 
   long
     y;
 
   register const PixelPacket
-    *p,
-    *q;
+    * restrict p,
+    * restrict q;
 
   register long
     x;
 
   register PixelPacket
-    *r;
+    * restrict r;
 
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
@@ -1469,7 +1474,7 @@ MagickExport Image *StereoImage(const Image *image,const Image *offset_image,
 %
 %
 */
-MagickExport Image *SwirlImage(const Image *image,double degrees,
+MagickExport Image *SwirlImage(const Image * restrict image,double degrees,
                                ExceptionInfo *exception)
 {
 #define SwirlImageText "[%s] Swirl..."
@@ -1485,7 +1490,7 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
     y;
 
   Image
-    *swirl_image;
+    * restrict swirl_image;
 
   /*
     Initialize swirl image attributes.
@@ -1533,8 +1538,8 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
     for (y=0; y < (long) image->rows; y++)
       {
         register PixelPacket
-          *q;
-    
+          * restrict q;
+
         register long
           x;
 
@@ -1549,9 +1554,6 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
         MagickPassFail
           thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_SwirlImage)
-#endif
         thread_status=status;
         if (thread_status == MagickFail)
           continue;
@@ -1578,36 +1580,44 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
                       cosine,
                       factor,
                       sine;
-            
+
                     /*
                       Swirl the pixel.
                     */
                     factor=1.0-sqrt(distance)/radius;
                     sine=sin(degrees*factor*factor);
                     cosine=cos(degrees*factor*factor);
-                    InterpolateViewColor(image_view,q,
-                                         (cosine*x_distance-sine*y_distance)/x_scale+x_center,
-                                         (sine*x_distance+cosine*y_distance)/y_scale+y_center,
-                                         exception);
+                    if (InterpolateViewColor(image_view,q,
+                                             (cosine*x_distance-sine*y_distance)/x_scale+x_center,
+                                             (sine*x_distance+cosine*y_distance)/y_scale+y_center,
+                                             exception) == MagickFail)
+                      {
+                        thread_status=MagickFail;
+                        break;
+                      }
                   }
                 q++;
               }
-            if (!SyncImagePixelsEx(swirl_image,exception))
-              thread_status=MagickFail;
+            if (thread_status != MagickFail)
+              if (!SyncImagePixelsEx(swirl_image,exception))
+                thread_status=MagickFail;
           }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_SwirlImage)
+#  pragma omp atomic
 #endif
-        {
-          row_count++;
-          if (QuantumTick(row_count,image->rows))
-            if (!MagickMonitorFormatted(row_count,image->rows,exception,
-                                        SwirlImageText,image->filename))
-              thread_status=MagickFail;
+        row_count++;
+        if (QuantumTick(row_count,image->rows))
+          if (!MagickMonitorFormatted(row_count,image->rows,exception,
+                                      SwirlImageText,image->filename))
+            thread_status=MagickFail;
 
-          if (thread_status == MagickFail)
+        if (thread_status == MagickFail)
+          {
             status=MagickFail;
-        }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+          }
       }
   }
   swirl_image->is_grayscale=image->is_grayscale;
@@ -1644,19 +1654,19 @@ MagickExport Image *SwirlImage(const Image *image,double degrees,
 %
 %
 */
-MagickExport Image *WaveImage(const Image *image,const double amplitude,
+MagickExport Image *WaveImage(const Image * restrict image,const double amplitude,
                               const double wave_length,ExceptionInfo *exception)
 {
 #define WaveImageText "[%s] Wave..."
 
   VirtualPixelMethod
     virtual_pixel_method;
-    
+
   double
-    *sine_map;
+    * restrict sine_map;
 
   Image
-    *wave_image;
+    * restrict wave_image;
 
   long
     y;
@@ -1730,7 +1740,7 @@ MagickExport Image *WaveImage(const Image *image,const double amplitude,
     for (y=0; y < (long) wave_image->rows; y++)
       {
         register PixelPacket
-          *q;
+          * restrict q;
 
         register long
           x;
@@ -1741,13 +1751,10 @@ MagickExport Image *WaveImage(const Image *image,const double amplitude,
         MagickPassFail
           thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_WaveImage)
-#endif
         thread_status=status;
         if (thread_status == MagickFail)
           continue;
-        
+
         image_view=AccessDefaultCacheView(image);
         q=SetImagePixelsEx(wave_image,0,y,wave_image->columns,1,exception);
         if (q == (PixelPacket *) NULL)
@@ -1756,26 +1763,34 @@ MagickExport Image *WaveImage(const Image *image,const double amplitude,
           {
             for (x=0; x < (long) wave_image->columns; x++)
               {
-                InterpolateViewColor(image_view,&q[x],(double) x,
-                                     (double) y-sine_map[x],
-                                     exception);
+                if (InterpolateViewColor(image_view,&q[x],(double) x,
+                                         (double) y-sine_map[x],
+                                         exception) == MagickFail)
+                  {
+                    thread_status=MagickFail;
+                    break;
+                  }
               }
-            if (!SyncImagePixelsEx(wave_image,exception))
-              thread_status=MagickFail;
+            if (thread_status != MagickFail)
+              if (!SyncImagePixelsEx(wave_image,exception))
+                thread_status=MagickFail;
           }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_WaveImage)
+#  pragma omp atomic
 #endif
-        {
-          row_count++;
-          if (QuantumTick(row_count,wave_image->rows))
-            if (!MagickMonitorFormatted(row_count,wave_image->rows,exception,
-                                        WaveImageText,image->filename))
-              thread_status=MagickFail;
-          
-          if (thread_status == MagickFail)
+        row_count++;
+        if (QuantumTick(row_count,wave_image->rows))
+          if (!MagickMonitorFormatted(row_count,wave_image->rows,exception,
+                                      WaveImageText,image->filename))
+            thread_status=MagickFail;
+
+        if (thread_status == MagickFail)
+          {
             status=MagickFail;
-        }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+          }
       }
   }
   /*
index 1810c4b..b859f6b 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003-2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Image FX Methods.
 */
 #ifndef _MAGICK_FX_H
index fc5fcc4..dde2ba8 100644 (file)
@@ -175,8 +175,8 @@ MagickExport double ExpandAffine(const AffineMatrix *affine)
 #define TauGaussian    20.0
 
 MagickExport double GenerateDifferentialNoise(const Quantum quantum_pixel,
-                                             const NoiseType noise_type,
-                                             MagickRandomKernel *kernel)
+                                              const NoiseType noise_type,
+                                              MagickRandomKernel *kernel)
 {
   double
     alpha,
@@ -317,7 +317,7 @@ MagickExport Quantum GenerateNoise(const Quantum pixel,
     value;
 
   value=(double) pixel+GenerateDifferentialNoise(pixel,noise_type,
-                                                AcquireMagickRandomKernel());
+                                                 AcquireMagickRandomKernel());
   return (RoundDoubleToQuantum(value));
 }
 \f
@@ -501,7 +501,7 @@ MagickExport void HSLTransform(const double hue,const double saturation,
       vsf=(v-y)*hue_fract;
       x=y+vsf;
       z=v-vsf;
-      
+
       switch (sextant)
         {
         case 0: r=v; g=x; b=y; break;
@@ -642,8 +642,8 @@ MagickExport void HWBTransform(const double hue,const double whiteness,
 */
 
 MagickExport void Hull(const long x_offset,const long y_offset,
-                      const unsigned long columns,const unsigned long rows,Quantum *f,Quantum *g,
-                      const int polarity)
+                       const unsigned long columns,const unsigned long rows,Quantum *f,Quantum *g,
+                       const int polarity)
 {
 #if QuantumDepth > 16
   typedef double SignedQuantum;
@@ -679,37 +679,37 @@ MagickExport void Hull(const long x_offset,const long y_offset,
   for (y=0; y < (long) rows; y++)
     {
       SignedQuantum
-       v;
+        v;
 
       unsigned long
-       x;
+        x;
 
       unsigned int
-       index;
+        index;
 
       index=(2*y+1)+y*columns;
       if (polarity > 0)
-       {
-         for (x=columns ; x != 0; x--)
-           {
-             v=(p[index]);
-             if (r[index] >= (v+ScaleCharToQuantum(2)))
-               v+=ScaleCharToQuantum(1);
-             q[index]=(Quantum) v;
-             index++;
-           }
-       }
+        {
+          for (x=columns ; x != 0; x--)
+            {
+              v=(p[index]);
+              if (r[index] >= (v+ScaleCharToQuantum(2)))
+                v+=ScaleCharToQuantum(1);
+              q[index]=(Quantum) v;
+              index++;
+            }
+        }
       else
-       {
-         for (x=columns ; x != 0; x--)
-           {
-             v=(p[index]);
-             if (r[index] <= (v-(long) ScaleCharToQuantum(2)))
-               v-=(long) ScaleCharToQuantum(1);
-             q[index]=(Quantum) v;
-             index++;
-           }
-       }
+        {
+          for (x=columns ; x != 0; x--)
+            {
+              v=(p[index]);
+              if (r[index] <= (v-(long) ScaleCharToQuantum(2)))
+                v-=(long) ScaleCharToQuantum(1);
+              q[index]=(Quantum) v;
+              index++;
+            }
+        }
     }
   p=f+(columns+2);
   q=g+(columns+2);
@@ -729,37 +729,37 @@ MagickExport void Hull(const long x_offset,const long y_offset,
   for (y=0; y < (long) rows; y++)
     {
       SignedQuantum
-       v;
+        v;
 
       unsigned long
-       x;
+        x;
 
       unsigned int
-       index;
+        index;
 
       index=(2*y+1)+y*columns;
       if (polarity > 0)
-       {
-         for (x=columns ; x != 0; x--)
-           {
-             v=(q[index]);
-             if ((s[index] >= (v+ScaleCharToQuantum(2))) && (r[index] > v))
-               v+=ScaleCharToQuantum(1);
-             p[index]=(Quantum) v;
-             index++;
-           }
-       }
+        {
+          for (x=columns ; x != 0; x--)
+            {
+              v=(q[index]);
+              if ((s[index] >= (v+ScaleCharToQuantum(2))) && (r[index] > v))
+                v+=ScaleCharToQuantum(1);
+              p[index]=(Quantum) v;
+              index++;
+            }
+        }
       else
-       {
-         for (x=columns ; x != 0; x--)
-           {
-             v=(q[index]);
-             if ((s[index] <= (v-(long) ScaleCharToQuantum(2))) && (r[index] < v))
-               v-=(long) ScaleCharToQuantum(1);
-             p[index]=(Quantum) v;
-             index++;
-           }
-       }
+        {
+          for (x=columns ; x != 0; x--)
+            {
+              v=(q[index]);
+              if ((s[index] <= (v-(long) ScaleCharToQuantum(2))) && (r[index] < v))
+                v-=(long) ScaleCharToQuantum(1);
+              p[index]=(Quantum) v;
+              index++;
+            }
+        }
     }
 }
 \f
index b6c5d89..d8736ab 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003-2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Graphic Gems - Graphic Support Methods.
 */
 #ifndef _MAGICK_GEM_H
index 0e47133..0b67fc6 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2014 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2003 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -55,7 +55,7 @@
 */
 
 #define GradientImageText "[%s] Gradient..."
-MagickExport MagickPassFail GradientImage(Image *image,
+MagickExport MagickPassFail GradientImage(Image *restrict image,
                                           const PixelPacket *start_color,
                                           const PixelPacket *stop_color)
 {
@@ -93,13 +93,10 @@ MagickExport MagickPassFail GradientImage(Image *image,
 
       register long
         x;
-      
+
       register PixelPacket
         *q;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_GradientImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -121,18 +118,21 @@ MagickExport MagickPassFail GradientImage(Image *image,
         }
 
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_GradientImage)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,image->rows))
-          if (!MagickMonitorFormatted(row_count,image->rows,&image->exception,
-                                      GradientImageText,image->filename))
-            thread_status=MagickFail;
+      row_count++;
+      if (QuantumTick(row_count,image->rows))
+        if (!MagickMonitorFormatted(row_count,image->rows,&image->exception,
+                                    GradientImageText,image->filename))
+          thread_status=MagickFail;
 
-        if (thread_status == MagickFail)
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
   if (IsGray(*start_color) && IsGray(*stop_color))
     image->is_grayscale=MagickTrue;
index 39181a1..76a91ff 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 - 2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Gradient Image Methods.
 */
 #ifndef _MAGICK_GRADIENT_H
index 7d6eba1..060b137 100644 (file)
 
 typedef struct _HaldClutImageParameters_t
 {
-  unsigned int 
+  unsigned int
     level;
 
-  const PixelPacket 
+  const PixelPacket
     *ppcl;
 
 } HaldClutImageParameters_t;
 
 static MagickPassFail
 HaldClutImagePixels(void *mutable_data,         /* User provided mutable data */
-                   const void *immutable_data, /* User provided immutable data */
-                   Image *image,               /* Modify image */
-                   PixelPacket *pixels,        /* Pixel row */
-                   IndexPacket *indexes,       /* Pixel row indexes */
-                   const long npixels,         /* Number of pixels in row */
-                   ExceptionInfo *exception)   /* Exception report */
+                    const void *immutable_data, /* User provided immutable data */
+                    Image * restrict image,               /* Modify image */
+                    PixelPacket * restrict pixels,        /* Pixel row */
+                    IndexPacket * restrict indexes,       /* Pixel row indexes */
+                    const long npixels,         /* Number of pixels in row */
+                    ExceptionInfo *exception)   /* Exception report */
 {
 
   const HaldClutImageParameters_t *
-    param = (const HaldClutImageParameters_t *) immutable_data;
-       
+     param = (const HaldClutImageParameters_t *) immutable_data;
+
   unsigned int
     level = param->level;
-       
+
   const PixelPacket
-    *clut = param->ppcl;
+    * restrict clut = param->ppcl;
 
   unsigned int
     color;
@@ -118,24 +118,24 @@ HaldClutImagePixels(void *mutable_data,         /* User provided mutable data */
   ARG_NOT_USED(exception);
 
   level *= level;
-       
+
   for(k = 0; k < npixels ; k++)
     {
       /*
-       Calculate the position of each 3D axis pixel level.
+        Calculate the position of each 3D axis pixel level.
       */
       redaxis = (unsigned int) (((double) pixels[k].red/MaxRGBDouble) * (level-1));
       if (redaxis > level - 2)
-       redaxis = level - 2;
+        redaxis = level - 2;
       greenaxis = (unsigned int) (((double) pixels[k].green/MaxRGBDouble) * (level-1));
       if(greenaxis > level - 2)
-       greenaxis = level - 2;
+        greenaxis = level - 2;
       blueaxis = (unsigned int) (((double) pixels[k].blue/MaxRGBDouble) * (level-1));
       if(blueaxis > level - 2)
-       blueaxis = level - 2;
+        blueaxis = level - 2;
 
       /*
-       Convert between the value and the equivalent value position.
+        Convert between the value and the equivalent value position.
       */
       r = ((double) pixels[k].red/MaxRGBDouble) * (level - 1) - redaxis;
       g = ((double) pixels[k].green/MaxRGBDouble) * (level - 1) - greenaxis;
@@ -196,36 +196,36 @@ HaldClutImagePixels(void *mutable_data,         /* User provided mutable data */
       value=(sums[8] * (1 - b) + sums[2] * b);
       pixels[k].blue = RoundDoubleToQuantum(value);
     }
-       
+
   return MagickPass;
 }
 
 
 MagickExport MagickPassFail
 HaldClutImage(Image *image, const Image *clut)
-{      
+{
   unsigned int
     level;
 
   char
     progress_message[MaxTextExtent];
-       
+
   HaldClutImageParameters_t
     param;
-       
+
   MagickPassFail
     status=MagickPass;
-       
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
-    
+
   /*
     Hald CLUT images are square.
   */
   if(clut->rows != clut->columns)
     {
       ThrowBinaryException(OptionError,HaldClutImageDimensionsInvalid,
-                          clut->filename);
+                           clut->filename);
     }
 
   /*
@@ -235,7 +235,7 @@ HaldClutImage(Image *image, const Image *clut)
   if((level * level * level > clut->rows) || (level < 2))
     {
       ThrowBinaryException(OptionError,HaldClutImageDimensionsInvalid,
-                          clut->filename);
+                           clut->filename);
     }
 
   param.level = level;
@@ -247,27 +247,26 @@ HaldClutImage(Image *image, const Image *clut)
   param.ppcl=AcquireImagePixels(clut,0,0,clut->columns,clut->rows,&image->exception);
   if (param.ppcl == (const PixelPacket *) NULL)
     return MagickFail;
-                                                        
+
   FormatString(progress_message,
-              "[%%s] Applying Hald CLUT level %u (%lux%lu) ...",
-              param.level,clut->columns,clut->rows);
+               "[%%s] Applying Hald CLUT level %u (%lux%lu) ...",
+               param.level,clut->columns,clut->rows);
 
   if (!IsRGBCompatibleColorspace(image->colorspace))
     TransformColorspace(image,RGBColorspace);
   if (image->storage_class == PseudoClass)
     {
       (void) HaldClutImagePixels(NULL,&param,image,image->colormap,
-                                (IndexPacket *) NULL,image->colors,
-                                &image->exception);
+                                 (IndexPacket *) NULL,image->colors,
+                                 &image->exception);
       status=SyncImage(image);
     }
   else
     {
       status=PixelIterateMonoModify(HaldClutImagePixels,NULL,progress_message,
-                                   NULL,&param,0,0,image->columns,image->rows,
-                                   image,&image->exception);
+                                    NULL,&param,0,0,image->columns,image->rows,
+                                    image,&image->exception);
     }
-       
+
   return(status);
 }
-       
index d1858d7..6b2cf31 100644 (file)
@@ -1,10 +1,10 @@
 /*
   Copyright (C) 2009 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Hald CLUT implementation
 
 */
index 29593aa..2312cc1 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2003 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -97,6 +97,33 @@ MagickParseSubImageSpecification(const char *subimage_spec,
                                  unsigned long *subrange_ptr,
                                  MagickBool allow_geometry);
 \f
+/*
+  ImageExtra allows for expansion of Image without increasing its
+  size.  The internals are defined only in this source file.  Clients
+  outside of this source file can access the internals via the provided
+  access functions (see below).
+*/
+typedef struct _ImageExtra
+{
+  Image
+    *clip_mask,       /* Private, clipping mask to apply when updating pixels */
+    *composite_mask;  /* Private, compositing mask to apply when updating pixels */
+} ImageExtra;
+
+/* provide public access to the clip_mask member of Image */
+MagickExport Image **
+ImageGetClipMask(const Image * image)
+{
+  return(&image->extra->clip_mask);
+}
+
+/* provide public access to the composite_mask member of Image */
+MagickExport Image **
+ImageGetCompositeMask(const Image * image)
+{
+  return(&image->extra->composite_mask);
+}
+
 /* Round floating value to an integer */
 #define RndToInt(value) ((int)((value)+0.5))
 \f
@@ -181,7 +208,7 @@ MagickExport const char *AccessDefinition(const ImageInfo *image_info,
 */
 MagickExport MagickPassFail
 AddDefinition(ImageInfo *image_info,const char *magick, const char *key,
-             const char *value, ExceptionInfo *exception)
+              const char *value, ExceptionInfo *exception)
 {
   MagickPassFail
     status = MagickFail;
@@ -191,16 +218,16 @@ AddDefinition(ImageInfo *image_info,const char *magick, const char *key,
 
   if (image_info->definitions == 0)
     image_info->definitions=MagickMapAllocateMap(MagickMapCopyString,
-                                                MagickMapDeallocateString);
+                                                 MagickMapDeallocateString);
   if (image_info->definitions != 0)
     {
       /*
-       Format string like "magick:key"
+        Format string like "magick:key"
       */
       FormatString(search_key, "%.60s:%.1024s", magick, key);
-      
+
       /*
-       Add entry to map
+        Add entry to map
       */
       status = MagickMapAddEntry((MagickMap) image_info->definitions,search_key,value,0,exception);
     }
@@ -330,6 +357,9 @@ MagickExport Image *AllocateImage(const ImageInfo *image_info)
   Image
     *allocate_image;
 
+  ImageExtra
+    *ImgExtra;
+
   /*
     Allocate image structure.
   */
@@ -338,6 +368,14 @@ MagickExport Image *AllocateImage(const ImageInfo *image_info)
     MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
       UnableToAllocateImage);
   (void) memset(allocate_image,0,sizeof(Image));
+
+  /* allocate and initialize struct for extra Image members */
+  ImgExtra = MagickAllocateMemory(ImageExtra *,sizeof(ImageExtra));
+  if  ( ImgExtra == (ImageExtra *) NULL )
+    MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,UnableToAllocateImage);
+  memset(ImgExtra,0,sizeof(*ImgExtra));
+  allocate_image->extra = ImgExtra;
+
   /*
     Initialize Image structure.
   */
@@ -382,10 +420,10 @@ MagickExport Image *AllocateImage(const ImageInfo *image_info)
   if (image_info->size != (char *) NULL)
     {
       (void) GetGeometry(image_info->size,
-                        &allocate_image->tile_info.x,
-                        &allocate_image->tile_info.y,
-                        &allocate_image->columns,
-                        &allocate_image->rows);
+                         &allocate_image->tile_info.x,
+                         &allocate_image->tile_info.y,
+                         &allocate_image->columns,
+                         &allocate_image->rows);
       allocate_image->offset=allocate_image->tile_info.x;
       allocate_image->tile_info.width=allocate_image->columns;
       allocate_image->tile_info.height=allocate_image->rows;
@@ -394,14 +432,14 @@ MagickExport Image *AllocateImage(const ImageInfo *image_info)
     if (!IsSubimage(image_info->tile,False))
       {
         (void) GetGeometry(image_info->tile,
-                          &allocate_image->tile_info.x,
-                          &allocate_image->tile_info.y,
-                          &allocate_image->tile_info.width,
-                          &allocate_image->tile_info.height);
-       if (0 == allocate_image->columns)
-         allocate_image->columns=allocate_image->tile_info.width;
-       if (0 == allocate_image->rows)
-         allocate_image->rows=allocate_image->tile_info.height;
+                           &allocate_image->tile_info.x,
+                           &allocate_image->tile_info.y,
+                           &allocate_image->tile_info.width,
+                           &allocate_image->tile_info.height);
+        if (0 == allocate_image->columns)
+          allocate_image->columns=allocate_image->tile_info.width;
+        if (0 == allocate_image->rows)
+          allocate_image->rows=allocate_image->tile_info.height;
       }
   allocate_image->compression=image_info->compression;
   allocate_image->dither=image_info->dither;
@@ -547,7 +585,7 @@ MagickExport MagickPassFail AnimateImages(const ImageInfo *image_info,
   resource.image_info=CloneImageInfo(image_info);
   resource.immutable=True;
   (void) MagickXAnimateImages(display,&resource,(char **) &client_name,
-                             1,image);
+                              1,image);
   (void) XCloseDisplay(display);
   DestroyImageInfo(resource.image_info);
   return(image->exception.severity == UndefinedException);
@@ -660,10 +698,10 @@ MagickExport Image *AppendImages(const Image *image,const unsigned int stack,
       for (next=image; next != (Image *) NULL; next=next->next)
       {
         (void) CompositeImage(append_image,CopyCompositeOp,next,0,y);
-       if (append_image->columns > next->columns)
-         SetImageColorRegion(append_image,next->columns,y,
-                             append_image->columns-next->columns,next->rows,
-                             &append_image->background_color);
+        if (append_image->columns > next->columns)
+          SetImageColorRegion(append_image,next->columns,y,
+                              append_image->columns-next->columns,next->rows,
+                              &append_image->background_color);
         y+=next->rows;
         status=MagickMonitorFormatted(scene,GetImageListLength(image),
                                       exception,AppendImageText,
@@ -683,9 +721,9 @@ MagickExport Image *AppendImages(const Image *image,const unsigned int stack,
     (void) CompositeImage(append_image,CopyCompositeOp,next,x,0);
     if (append_image->rows > next->rows)
       SetImageColorRegion(append_image,x,next->rows,
-                         next->columns,
-                         append_image->rows-next->rows,
-                         &append_image->background_color);
+                          next->columns,
+                          append_image->rows-next->rows,
+                          &append_image->background_color);
     x+=next->columns;
     status=MagickMonitorFormatted(scene++,GetImageListLength(image),
                                   exception,AppendImageText,
@@ -775,9 +813,9 @@ MagickExport MagickPassFail ClipImage(Image *image)
 static MagickPassFail
 ClipPathImageCallBack(void *mutable_data,         /* User provided mutable data */
                       const void *immutable_data, /* User provided immutable data */
-                      Image *image,               /* Modify image */
-                      PixelPacket *pixels,        /* Pixel row */
-                      IndexPacket *indexes,       /* Pixel row indexes */
+                      Image * restrict image,               /* Modify image */
+                      PixelPacket * restrict pixels,        /* Pixel row */
+                      IndexPacket * restrict indexes,       /* Pixel row indexes */
                       const long npixels,         /* Number of pixels in row */
                       ExceptionInfo *exception)   /* Exception report */
 {
@@ -787,7 +825,7 @@ ClipPathImageCallBack(void *mutable_data,         /* User provided mutable data
     renderer.
   */
   const MagickBool
-    inside = *((MagickBool *) immutable_data);
+     inside = *((MagickBool *) immutable_data);
 
   register Quantum
     intensity;
@@ -880,12 +918,152 @@ MagickExport MagickPassFail ClipPathImage(Image *image,const char *pathname,
   DestroyImage(clip_mask);
   return status;
 }
+
+/* code below for CompositePathImage() cloned/modified from ClipPathImage() */
 \f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   C o m p o s i t e P a t h I m a g e                                                 %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  CompositePathImage() sets the image composite mask based any compositing path information
+%  if it exists.
+%
+%  The format of the CompositePathImage method is:
+%
+%      unsigned int CompositePathImage(Image *image,const char *pathname,
+%        const unsigned int inside)
+%
+%  A description of each parameter follows:
+%
+%    o image: The image.
+%
+%    o pathname: name of compositing path resource. If name is preceded by #, use
+%      compositing path numbered by name.
+%
+%    o inside: if non-zero, later operations take effect inside compositing path.
+%      Otherwise later operations take effect outside compositing path.
+%
+%
+*/
+MagickExport MagickPassFail CompositeMaskImage(Image *image)
+{
+  return(CompositePathImage(image,"#1",True));
+}
+
+#define CompositePathImageText "[%s] Creating composite mask..."
+static MagickPassFail
+CompositePathImageCallBack(void *mutable_data,    /* User provided mutable data */
+                      const void *immutable_data, /* User provided immutable data */
+                      Image * restrict image,               /* Modify image */
+                      PixelPacket * restrict pixels,        /* Pixel row */
+                      IndexPacket * restrict indexes,       /* Pixel row indexes */
+                      const long npixels,         /* Number of pixels in row */
+                      ExceptionInfo *exception)   /* Exception report */
+{
+  /*
+    Force all pixel components to be the same (r == g == b)
+  */
+  const MagickBool
+    inside = *((MagickBool *) immutable_data);
+
+  register Quantum
+    intensity;
+
+  register long
+    i;
+
+  ARG_NOT_USED(mutable_data);
+  ARG_NOT_USED(image);
+  ARG_NOT_USED(indexes);
+  ARG_NOT_USED(exception);
+
+  for (i=0; i < npixels; i++)
+    {
+      intensity=PixelIntensityToQuantum(&pixels[i]);
+      if (!inside)
+        intensity=MaxRGB - intensity;   /* invert */
+      pixels[i].red=intensity;
+      pixels[i].green=intensity;
+      pixels[i].blue=intensity;
+      /* leave the opacity unchanged */
+    }
+
+  return MagickPass;
+}
+MagickExport MagickPassFail CompositePathImage(Image *image,const char *pathname,
+  const MagickBool inside)
+{
+
+  char
+    key[MaxTextExtent];
+
+  const ImageAttribute
+    *attribute;
+
+  Image
+    *composite_mask;
+
+  ImageInfo
+    *image_info;
+
+  MagickPassFail
+    status=MagickPass;
+
+  assert(image != (const Image *) NULL);
+  assert(image->signature == MagickSignature);
+  assert(pathname != NULL);
+  FormatString(key,"8BIM:1999,2998:%s",pathname);
+  attribute=GetImageAttribute(image,key);
+  if (attribute == (const ImageAttribute *) NULL)
+    return(MagickFail);
+  image_info=CloneImageInfo((ImageInfo *) NULL);
+  (void) QueryColorDatabase("#ffffffff",&image_info->background_color,
+    &image->exception);
+  composite_mask=BlobToImage(image_info,attribute->value,strlen(attribute->value),
+    &image->exception);
+  DestroyImageInfo(image_info);
+  if (composite_mask == (Image *) NULL)
+    return (MagickFail);
+  if (composite_mask->storage_class == PseudoClass)
+    {
+      if (SyncImage(composite_mask) == MagickFail)
+        return (MagickFail);
+      composite_mask->storage_class=DirectClass;
+    }
+  composite_mask->matte=True;
+  /*
+    Force all pixel components to be the same (r == g == b).
+  */
+  status=PixelIterateMonoModify(CompositePathImageCallBack,NULL,
+                                CompositePathImageText,
+                                NULL,&inside,0,0,composite_mask->columns,composite_mask->rows,
+                                composite_mask,&image->exception);
+  /*
+    Overload magick_filename to keep name of path that created image.
+    This is needed so we can get the path as postscript for PS coders
+    to create a postscript vector based compositing path.
+  */
+  FormatString(composite_mask->magick_filename,"8BIM:1999,2998:%s\nPS",pathname);
+
+  composite_mask->is_grayscale=True;
+  composite_mask->is_monochrome=True;
+  (void) SetImageCompositeMask(image,composite_mask);
+  DestroyImage(composite_mask);
+  return status;
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   C l o n e I m a g e                                                       %
 %                                                                             %
 %                                                                             %
@@ -928,6 +1106,9 @@ MagickExport Image *CloneImage(const Image *image,const unsigned long columns,
   Image
     *clone_image;
 
+  ImageExtra
+    *ImgExtra;
+
   size_t
     length;
 
@@ -938,11 +1119,20 @@ MagickExport Image *CloneImage(const Image *image,const unsigned long columns,
   assert(image->signature == MagickSignature);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
+
   clone_image=MagickAllocateMemory(Image *,sizeof(Image));
   if (clone_image == (Image *) NULL)
     ThrowImageException3(ResourceLimitError,MemoryAllocationFailed,
       UnableToCloneImage);
   (void) memset(clone_image,0,sizeof(Image));
+
+  /* allocate and initialize struct for extra Image members */
+  ImgExtra = MagickAllocateMemory(ImageExtra *,sizeof(ImageExtra));
+  if  ( ImgExtra == (ImageExtra *) NULL )
+    ThrowImageException3(ResourceLimitError,MemoryAllocationFailed,UnableToCloneImage);
+  memset(ImgExtra,0,sizeof(*ImgExtra));
+  clone_image->extra = ImgExtra;
+
   clone_image->storage_class=image->storage_class;
   clone_image->colorspace=image->colorspace;
   clone_image->compression=image->compression;
@@ -1027,7 +1217,8 @@ MagickExport Image *CloneImage(const Image *image,const unsigned long columns,
   clone_image->previous=(Image *) NULL;
   clone_image->list=(Image *) NULL;
   clone_image->next=(Image *) NULL;
-  clone_image->clip_mask=(Image *) NULL;
+  clone_image->extra->clip_mask=(Image *) NULL;
+  clone_image->extra->composite_mask=(Image *) NULL;
   if (orphan)
     clone_image->blob=CloneBlobInfo((BlobInfo *) NULL);
   else
@@ -1051,8 +1242,10 @@ MagickExport Image *CloneImage(const Image *image,const unsigned long columns,
         (void) CloneString(&clone_image->montage,image->montage);
       if (image->directory != (char *) NULL)
         (void) CloneString(&clone_image->directory,image->directory);
-      if (image->clip_mask != (Image *) NULL)
-        clone_image->clip_mask=CloneImage(image->clip_mask,0,0,True,exception);
+      if (image->extra->clip_mask != (Image *) NULL)
+        clone_image->extra->clip_mask=CloneImage(image->extra->clip_mask,0,0,True,exception);
+      if (image->extra->composite_mask != (Image *) NULL)
+        clone_image->extra->composite_mask=CloneImage(image->extra->composite_mask,0,0,True,exception);
       clone_image->ping=image->ping;
       clone_image->cache=ReferenceCache(image->cache);
       clone_image->default_views=AllocateThreadViewSet(clone_image,exception);
@@ -1060,8 +1253,10 @@ MagickExport Image *CloneImage(const Image *image,const unsigned long columns,
            (clone_image->montage == ((char *) NULL))) ||
           ((image->directory != (char *) NULL) &&
            (clone_image->directory == (char *) NULL)) ||
-          ((image->clip_mask != (Image *) NULL) &&
-           (clone_image->clip_mask == (Image *) NULL)) ||
+          ((image->extra->clip_mask != (Image *) NULL) &&
+           (clone_image->extra->clip_mask == (Image *) NULL)) ||
+          ((image->extra->composite_mask != (Image *) NULL) &&
+           (clone_image->extra->composite_mask == (Image *) NULL)) ||
           (clone_image->cache == (_CacheInfoPtr_) NULL) ||
           (clone_image->default_views == (_ThreadViewSetPtr_) NULL))
         {
@@ -1071,6 +1266,12 @@ MagickExport Image *CloneImage(const Image *image,const unsigned long columns,
         }
       return(clone_image);
     }
+  if (CheckImagePixelLimits(clone_image, exception) != MagickPass)
+    {
+      DestroyImage(clone_image);
+      ThrowImageException3(ResourceLimitError,ImagePixelLimitExceeded,
+                           UnableToCloneImage);
+    }
   clone_image->page.width=columns;
   clone_image->page.height=rows;
   if (clone_image->columns > 0)
@@ -1207,7 +1408,8 @@ MagickExport ImageInfo *CloneImageInfo(const ImageInfo *image_info)
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  DestroyImage() dereferences an image, deallocating memory associated with
-%  the image if the reference count becomes zero.
+%  the image if the reference count becomes zero.  There is no effect if the
+%  image pointer is null.
 %
 %  The format of the DestroyImage method is:
 %
@@ -1258,9 +1460,13 @@ MagickExport void DestroyImage(Image *image)
     Destroy image pixel cache.
   */
   DestroyImagePixels(image);
-  if (image->clip_mask != (Image *) NULL)
-    DestroyImage(image->clip_mask);
-  image->clip_mask=(Image *) NULL;
+  if (image->extra->clip_mask != (Image *) NULL)
+    DestroyImage(image->extra->clip_mask);
+  image->extra->clip_mask=(Image *) NULL;
+  if (image->extra->composite_mask != (Image *) NULL)
+    DestroyImage(image->extra->composite_mask);
+  image->extra->composite_mask=(Image *) NULL;
+  MagickFreeMemory(image->extra);
   MagickFreeMemory(image->montage);
   MagickFreeMemory(image->directory);
   MagickFreeMemory(image->colormap);
@@ -1274,6 +1480,7 @@ MagickExport void DestroyImage(Image *image)
   MagickFreeMemory(image->ascii85);
   DestroyBlob(image);
   DestroySemaphoreInfo((SemaphoreInfo **) &image->semaphore);
+  image->signature=0;
   MagickFreeMemory(image);
 }
 \f
@@ -1303,7 +1510,9 @@ MagickExport void DestroyImage(Image *image)
 */
 MagickExport void DestroyImageInfo(ImageInfo *image_info)
 {
-  assert(image_info != (ImageInfo *) NULL);
+  if (image_info == (ImageInfo *) NULL)
+    return;
+
   assert(image_info->signature == MagickSignature);
   MagickFreeMemory(image_info->size);
   MagickFreeMemory(image_info->tile);
@@ -1321,6 +1530,7 @@ MagickExport void DestroyImageInfo(ImageInfo *image_info)
     DestroyCacheInfo(image_info->cache);
   if (image_info->definitions != (MagickMap) NULL)
     MagickMapDeallocateMap((MagickMap) image_info->definitions);
+  image_info->signature=0;
   MagickFreeMemory(image_info);
 }
 \f
@@ -1391,7 +1601,7 @@ MagickExport MagickPassFail DisplayImages(const ImageInfo *image_info,
   {
     state=DefaultState;
     (void) MagickXDisplayImage(display,&resource_info,(char **) &client_name,
-                              1,&next,&state);
+                               1,&next,&state);
     if (state & ExitState)
       break;
   }
@@ -1464,13 +1674,63 @@ MagickExport unsigned int DisplayImages(const ImageInfo *image_info,
 */
 MagickExport Image *GetImageClipMask(const Image *image, ExceptionInfo *exception)
 {
-  if (image->clip_mask)
-    return CloneImage(image->clip_mask,0,0,True,exception);
+  if (image->extra->clip_mask)
+    return CloneImage(image->extra->clip_mask,0,0,True,exception);
 
   ThrowException3(exception,ImageError,UnableToGetClipMask,NoImagesWereFound);
   return ((Image *) NULL);
 }
 \f
+/* code below for GetImageCompositeMask() cloned/modified from GetImageClipMask() */
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   G e t I m a g e C o m p o s i t e M a s k                                           %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  GetImageCompositeMask returns a reference-counted copy of the current image
+%  composite mask. This copy must be deallocated using DestroyImage() once it is
+%  no longer needed.  If the image does not have an associated composite mask,
+%  then NULL is returned.  Use SetImageCompositeMask() to add a composite mask to an
+%  image, or remove a composite mask.
+%
+%  If a component of the composite mask is set to TransparentOpacity (maximum
+%  value) then the corresponding image pixel component will not be updated
+%  when SyncImagePixels() is applied. The composite mask may be used to constrain
+%  the results of an image processing operation to a region of the image.
+%  Regions outside those allowed by the composite mask may be processed, but only
+%  pixel quantums allowed by the composite mask will actually be updated.
+%
+%  The composite mask protects the DirectClass pixels and PseudoClass pixel indexes
+%  from modification. The composite mask does *not* protect the image colormap since
+%  the image colormap is globally shared by all pixels in a PseudoClass image.
+%
+%  The format of the GetImageCompositeMask method is
+%
+%      Image *GetImageCompositeMask(const Image *image, ExceptionInfo *exception)
+%
+%  A descripton of each parameter follows:
+%
+%    o image: The image.
+%
+%    o exception: Reason for failure.
+%
+*/
+MagickExport Image *GetImageCompositeMask(const Image *image, ExceptionInfo *exception)
+{
+  if (image->extra->composite_mask)
+    return CloneImage(image->extra->composite_mask,0,0,True,exception);
+
+  ThrowException3(exception,ImageError,UnableToGetCompositeMask,NoImagesWereFound);
+  return ((Image *) NULL);
+}
+
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
@@ -2010,8 +2270,8 @@ ResetImagePage(Image *image,const char *page)
   else
     {
       /* If values are not absolute, then use offset values, and page
-        width and height based on image width and height plus page
-        offsets */
+         width and height based on image width and height plus page
+         offsets */
       if (flags & XValue)
         {
           image->page.x=page_geometry.x;
@@ -2063,9 +2323,9 @@ ResetImagePage(Image *image,const char *page)
 static MagickPassFail
 SetImageColorCallBack(void *mutable_data,         /* User provided mutable data */
                       const void *immutable_data, /* User provided immutable data */
-                      Image *image,               /* Modify image */
-                      PixelPacket *pixels,        /* Pixel row */
-                      IndexPacket *indexes,       /* Pixel row indexes */
+                      Image * restrict image,               /* Modify image */
+                      PixelPacket * restrict pixels,        /* Pixel row */
+                      IndexPacket * restrict indexes,       /* Pixel row indexes */
                       const long npixels,         /* Number of pixels in row */
                       ExceptionInfo *exception)   /* Exception report */
 {
@@ -2074,7 +2334,7 @@ SetImageColorCallBack(void *mutable_data,         /* User provided mutable data
   */
   const PixelPacket
     background_color = *(const PixelPacket *) immutable_data;
-  
+
   register long
     i;
 
@@ -2193,7 +2453,7 @@ MagickExport MagickPassFail SetImage(Image *image,const Quantum opacity)
 %
 */
 MagickExport MagickPassFail SetImageColor(Image *image,
-                                         const PixelPacket *pixel)
+                                          const PixelPacket *pixel)
 {
   image->is_grayscale=IsGray(*pixel);
   image->is_monochrome=IsMonochrome(*pixel);
@@ -2234,11 +2494,11 @@ MagickExport MagickPassFail SetImageColor(Image *image,
 */
 MagickExport MagickPassFail
 SetImageColorRegion(Image *image,
-                   long x,
-                   long y,
-                   unsigned long width,
-                   unsigned long height,
-                   const PixelPacket *pixel)
+                    long x,
+                    long y,
+                    unsigned long width,
+                    unsigned long height,
+                    const PixelPacket *pixel)
 {
   MagickPassFail
     status;
@@ -2262,10 +2522,10 @@ SetImageColorRegion(Image *image,
   image->storage_class=DirectClass;
 
   status=PixelIterateMonoModify(SetImageColorCallBack,NULL,
-                               SetImageColorText,
-                               NULL,pixel,x,y,
-                               width,height,
-                               image,&image->exception);
+                                SetImageColorText,
+                                NULL,pixel,x,y,
+                                width,height,
+                                image,&image->exception);
 
   image->is_grayscale=is_grayscale;
   image->is_monochrome=is_monochrome;
@@ -2316,17 +2576,75 @@ MagickExport MagickPassFail SetImageClipMask(Image *image,const Image *clip_mask
     if ((clip_mask->columns != image->columns) ||
         (clip_mask->rows != image->rows))
       ThrowBinaryException3(ImageError,UnableToSetClipMask,ImageSizeDiffers);
-  if (image->clip_mask != (Image *) NULL)
-    DestroyImage(image->clip_mask);
-  image->clip_mask=(Image *) NULL;
+  if (image->extra->clip_mask != (Image *) NULL)
+    DestroyImage(image->extra->clip_mask);
+  image->extra->clip_mask=(Image *) NULL;
   if (clip_mask == (Image *) NULL)
     return(MagickPass);
-  image->clip_mask=CloneImage(clip_mask,0,0,True,&image->exception);
-  if (image->clip_mask)
+  image->extra->clip_mask=CloneImage(clip_mask,0,0,True,&image->exception);
+  if (image->extra->clip_mask)
     return (MagickPass);
   return (MagickFail);
 }
+
+/* code below for SetImageCompositeMask() cloned/modified from SetImageClipMask() */
 \f
+\f/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   S e t I m a g e C o m p o s i t e M a s k                                                   %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  SetImageCompositeMask() associates a composite mask with the image.  The mask
+%  must be the same dimensions as the image.
+%
+%  If a component of the composite mask is set to TransparentOpacity (maximum
+%  value) then the corresponding image pixel component will not be updated
+%  when SyncImagePixels() is applied. The composite mask may be used to composite
+%  the results of an image processing operation to a region of the image.
+%  Regions outside those allowed by the composite mask may be processed, but only
+%  pixel quantums covered by the composite mask will actually be updated.
+%
+%  The composite mask protects the DirectClass pixels and PseudoClass pixel indexes
+%  from modification. The composite mask does *not* protect the image colormap since
+%  the image colormap is globally shared by all pixels in a PseudoClass image.
+%
+%  The format of the SetImageCompositeMask method is:
+%
+%      unsigned int SetImageCompositeMask(Image *image,const Image *composite_mask)
+%
+%  A description of each parameter follows:
+%
+%    o image: The image.
+%
+%    o composite_mask: The image composite mask.
+%
+%
+*/
+MagickExport MagickPassFail SetImageCompositeMask(Image *image,const Image *composite_mask)
+{
+  assert(image != (Image *) NULL);
+  assert(image->signature == MagickSignature);
+  if (composite_mask != (const Image *) NULL)
+    if ((composite_mask->columns != image->columns) ||
+        (composite_mask->rows != image->rows))
+      ThrowBinaryException3(ImageError,UnableToSetCompositeMask,ImageSizeDiffers);
+  if (image->extra->composite_mask != (Image *) NULL)
+    DestroyImage(image->extra->composite_mask);
+  image->extra->composite_mask=(Image *) NULL;
+  if (composite_mask == (Image *) NULL)
+    return(MagickPass);
+  image->extra->composite_mask=CloneImage(composite_mask,0,0,True,&image->exception);
+  if (image->extra->composite_mask)
+    return (MagickPass);
+  return (MagickFail);
+}
+
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
@@ -2472,7 +2790,7 @@ MagickParseSubImageSpecification(const char *subimage_spec,
   assert(subrange_ptr != (unsigned long *) NULL);
 
   (void) strlcpy(spec,subimage_spec,sizeof(spec));
-  
+
   do
     {
       const char
@@ -2547,14 +2865,14 @@ MagickParseSubImageSpecification(const char *subimage_spec,
           long
             x,
             y;
-          
+
           unsigned int
             flags;
-          
+
           unsigned long
             height,
             width;
-          
+
           /* Require Width and Height */
           flags=GetGeometry((char *) spec,&x,&y,&width,&height);
           if ((flags & WidthValue) && (flags & HeightValue))
@@ -2601,7 +2919,7 @@ ParseSubImageFileSpecification(char *filename,
       ((spec_start=strrchr(filename,'[')) != (const char *) NULL))
     {
       char
-       spec[MaxTextExtent];
+        spec[MaxTextExtent];
 
       /*
         Example of supported formats (as per documentation):
@@ -2625,18 +2943,18 @@ ParseSubImageFileSpecification(char *filename,
         {
           status=MagickFail;
           ThrowException(exception,OptionError,
-                        InvalidSubimageSpecification,spec);
+                         InvalidSubimageSpecification,spec);
         }
       if (status == MagickPass)
-       {
-         /* Truncate filename */
-         *(spec_start-1)='\0';
+        {
+          /* Truncate filename */
+          *(spec_start-1)='\0';
           (void) CloneString(tile_ptr,spec);
-       }
+        }
 #if 0
       fprintf(stderr,"subimage=%lu subrange=%lu tile=\"%s\"\n",
-             *subimage_ptr,*subrange_ptr,
-             (*tile_ptr ? *tile_ptr : "(null)"));
+              *subimage_ptr,*subrange_ptr,
+              (*tile_ptr ? *tile_ptr : "(null)"));
 #endif
     }
 
@@ -2645,7 +2963,7 @@ ParseSubImageFileSpecification(char *filename,
 
 MagickExport MagickPassFail
 SetImageInfo(ImageInfo *image_info,const unsigned int flags,
-            ExceptionInfo *exception)
+             ExceptionInfo *exception)
 {
   static const char
     *virtual_delegates[] =
@@ -2708,10 +3026,10 @@ SetImageInfo(ImageInfo *image_info,const unsigned int flags,
 
 #if 0
   fprintf(stderr,"SetImageInfo \"%s\" Read=%d Write=%d Rectify=%d\n",
-         image_info->filename,
-         ((lflags & SETMAGICK_READ) > 0),
-         ((lflags & SETMAGICK_WRITE) > 0),
-         ((lflags & SETMAGICK_RECTIFY) > 0));
+          image_info->filename,
+          ((lflags & SETMAGICK_READ) > 0),
+          ((lflags & SETMAGICK_WRITE) > 0),
+          ((lflags & SETMAGICK_RECTIFY) > 0));
 #endif
 
   *magic='\0';
@@ -2719,23 +3037,23 @@ SetImageInfo(ImageInfo *image_info,const unsigned int flags,
   if (lflags & SETMAGICK_READ)
     {
       /*
-       Look for sub-image specification (e.g. img0001.pcd[4]).
+        Look for sub-image specification (e.g. img0001.pcd[4]).
       */
       p=image_info->filename+Max((long) strlen(image_info->filename)-1,0);
       /*
-       Sometimes the provided argument is a real file and we need to
-       account for that.  If it is not a real file and the argument ends
-       with ']' then the trailing part is likely a sub-image or size
-       specification.
+        Sometimes the provided argument is a real file and we need to
+        account for that.  If it is not a real file and the argument ends
+        with ']' then the trailing part is likely a sub-image or size
+        specification.
       */
       if (*p == ']' && !IsAccessibleNoLogging(image_info->filename))
-       {
-         (void) ParseSubImageFileSpecification(image_info->filename,
+        {
+          (void) ParseSubImageFileSpecification(image_info->filename,
                                                 &image_info->tile,
                                                 &image_info->subimage,
                                                 &image_info->subrange,
                                                 exception);
-       }
+        }
     }
 
   /*
@@ -2803,7 +3121,7 @@ SetImageInfo(ImageInfo *image_info,const unsigned int flags,
       while ((*p != '.') && (p > (image_info->filename+1)))
         p--;
       if ((LocaleCompare(p,".gz") == 0) ||
-         (LocaleCompare(p,".Z") == 0) ||
+          (LocaleCompare(p,".Z") == 0) ||
           (LocaleCompare(p,".bz2") == 0))
         do
           {
@@ -2816,10 +3134,10 @@ SetImageInfo(ImageInfo *image_info,const unsigned int flags,
           */
           unsigned int
             i;
-          
+
           MagickBool
             exclude;
-          
+
           (void) strlcpy(magic,p+1,MaxTextExtent);
           for (q=magic; *q != '\0'; q++)
             if (*q == '.')
@@ -2876,56 +3194,56 @@ SetImageInfo(ImageInfo *image_info,const unsigned int flags,
   if (lflags & SETMAGICK_READ)
     {
       /*
-       Determine the file format from the first few bytes of the
-       file.
+        Determine the file format from the first few bytes of the
+        file.
       */
       image=AllocateImage(image_info);
       if (image == (Image *) NULL)
-       return(MagickFail);
+        return(MagickFail);
       (void) strlcpy(image->filename,image_info->filename,MaxTextExtent);
       status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
       if (status == MagickFail)
-       {
-         DestroyImage(image);
-         return(MagickFail);
-       }
+        {
+          DestroyImage(image);
+          return(MagickFail);
+        }
       if (!BlobIsSeekable(image))
-       {
-         /*
-           Copy standard input or pipe to temporary file.
-         */
-         if(!AcquireTemporaryFileName(filename))
-           {
-             CloseBlob(image);
-             DestroyImage(image);
-             return(MagickFail);
-           }
-         (void) ImageToFile(image,filename,exception);
-         CloseBlob(image);
-         (void) strcpy(image->filename,filename);
-         status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
-         if (status == MagickFail)
-           {
-             DestroyImage(image);
-             return(MagickFail);
-           }
-         (void) strcpy(image_info->filename,filename);
-         image_info->temporary=MagickTrue;
-       }
+        {
+          /*
+            Copy standard input or pipe to temporary file.
+          */
+          if(!AcquireTemporaryFileName(filename))
+            {
+              CloseBlob(image);
+              DestroyImage(image);
+              return(MagickFail);
+            }
+          (void) ImageToFile(image,filename,exception);
+          CloseBlob(image);
+          (void) strcpy(image->filename,filename);
+          status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
+          if (status == MagickFail)
+            {
+              DestroyImage(image);
+              return(MagickFail);
+            }
+          (void) strcpy(image_info->filename,filename);
+          image_info->temporary=MagickTrue;
+        }
       magick[0]='\0';
       magick_length = ReadBlob(image,2*MaxTextExtent,magick);
       (void) SeekBlob(image,-(magick_off_t) magick_length,SEEK_CUR);
       CloseBlob(image);
       DestroyImage(image);
       /*
-       Check format using magic.mgk configuration file.  Use of an
-       external config file is absolutely necessary when using loadable
-       modules since otherwise the code necessary to perform the test
-       might not be available yet.
+        Check format using magic.mgk configuration file.  Use of an
+        external config file is absolutely necessary when using loadable
+        modules since otherwise the code necessary to perform the test
+        might not be available yet.
       */
       if (GetMagickFileFormat(magick,magick_length,image_info->magick,
-                             MaxTextExtent,exception))
-       return(MagickPass);
+                              MaxTextExtent,exception))
+        return(MagickPass);
     }
 
   return(MagickPass);
@@ -2963,9 +3281,9 @@ SetImageInfo(ImageInfo *image_info,const unsigned int flags,
 static MagickPassFail
 ModulateImageOpacityCallBack(void *mutable_data,         /* User provided mutable data */
                              const void *immutable_data, /* User provided immutable data */
-                             Image *image,               /* Modify image */
-                             PixelPacket *pixels,        /* Pixel row */
-                             IndexPacket *indexes,       /* Pixel row indexes */
+                             Image * restrict image,               /* Modify image */
+                             PixelPacket * restrict pixels,        /* Pixel row */
+                             IndexPacket * restrict indexes,       /* Pixel row indexes */
                              const long npixels,         /* Number of pixels in row */
                              ExceptionInfo *exception)   /* Exception report */
 {
@@ -2994,9 +3312,9 @@ ModulateImageOpacityCallBack(void *mutable_data,         /* User provided mutabl
 static MagickPassFail
 SetImageOpacityCallBack(void *mutable_data,         /* User provided mutable data */
                         const void *immutable_data, /* User provided immutable data */
-                        Image *image,               /* Modify image */
-                        PixelPacket *pixels,        /* Pixel row */
-                        IndexPacket *indexes,       /* Pixel row indexes */
+                        Image * restrict image,               /* Modify image */
+                        PixelPacket * restrict pixels,        /* Pixel row */
+                        IndexPacket * restrict indexes,       /* Pixel row indexes */
                         const long npixels,         /* Number of pixels in row */
                         ExceptionInfo *exception)   /* Exception report */
 {
@@ -3111,7 +3429,7 @@ MagickExport MagickPassFail SetImageType(Image *image,const ImageType image_type
     {
       MagickBool
         is_monochrome;
-      
+
       if (!IsRGBColorspace(image->colorspace))
         {
           if (logging)
@@ -3405,9 +3723,9 @@ StripImage(Image *image)
 static MagickPassFail
 SyncImageCallBack(void *mutable_data,         /* User provided mutable data */
                   const void *immutable_data, /* User provided immutable data */
-                  Image *image,               /* Modify image */
-                  PixelPacket *pixels,        /* Pixel row */
-                  IndexPacket *indexes,       /* Pixel row indexes */
+                  Image * restrict image,               /* Modify image */
+                  PixelPacket * restrict pixels,        /* Pixel row */
+                  IndexPacket * restrict indexes,       /* Pixel row indexes */
                   const long npixels,         /* Number of pixels in row */
                   ExceptionInfo *exception)   /* Exception report */
 {
index 3672d93..be204ce 100644 (file)
@@ -1,12 +1,12 @@
 /*
-  Copyright (C) 2003 - 2015 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Image Methods.
 */
 #ifndef _MAGICK_IMAGE_H
@@ -33,8 +33,14 @@ extern "C" {
 
 /*
   Maximum unsigned RGB value which fits in the specified bits
+
+  If bits <= 0, then zero is returned.  If bits exceeds bits in unsigned long,
+  then max value of unsigned long is returned.
 */
-#define MaxValueGivenBits(bits) ((unsigned long) (0x01UL << (bits-1)) +((0x01UL << (bits-1))-1))
+#define MaxValueGivenBits(bits) ((unsigned long) \
+                                 (((int) bits <= 0) ? 0 :               \
+                                   ((0x01UL << (Min(sizeof(unsigned long)*8U,(size_t)bits)-1)) + \
+                                    ((0x01UL << (Min(sizeof(unsigned long)*8U,(size_t)bits)-1))-1))))
 
 #if (QuantumDepth == 8)
 #  define MaxColormapSize  256U
@@ -133,7 +139,7 @@ typedef unsigned int Quantum;
   (value > MaxRGBDouble) ? MaxRGB : value + 0.5))
 #define RoundFloatToQuantum(value) ((Quantum) (value < 0.0f ? 0U : \
   (value > MaxRGBFloat) ? MaxRGB : value + 0.5f))
-#define ConstrainToRange(min,max,value) (value < min ? min : \
+#define ConstrainToRange(min,max,value) (value < min ? min :    \
   (value > max) ? max : value)
 #define ConstrainToQuantum(value) ConstrainToRange(0,MaxRGB,value)
 #define ScaleAnyToQuantum(x,max_value) \
@@ -254,7 +260,9 @@ typedef enum
   LZMACompression,              /* Lempel-Ziv-Markov chain algorithm */
   JPEG2000Compression,          /* ISO/IEC std 15444-1 */
   JBIG1Compression,             /* ISO/IEC std 11544 / ITU-T rec T.82 */
-  JBIG2Compression              /* ISO/IEC std 14492 / ITU-T rec T.88 */
+  JBIG2Compression,             /* ISO/IEC std 14492 / ITU-T rec T.88 */
+  ZSTDCompression,              /* Facebook's Zstandard compression */
+  WebPCompression               /* Google's WebP compression */
 } CompressionType;
 
 typedef enum
@@ -393,17 +401,18 @@ typedef enum
 /*
   Image orientation.  Based on TIFF standard values (also EXIF).
 */
-typedef enum               /* Line direction / Frame Direction */
-{                          /* -------------- / --------------- */
-  UndefinedOrientation,    /* Unknown        / Unknown         */
-  TopLeftOrientation,      /* Left to right  / Top to bottom   */
-  TopRightOrientation,     /* Right to left  / Top to bottom   */
-  BottomRightOrientation,  /* Right to left  / Bottom to top   */
-  BottomLeftOrientation,   /* Left to right  / Bottom to top   */
-  LeftTopOrientation,      /* Top to bottom  / Left to right   */
-  RightTopOrientation,     /* Top to bottom  / Right to left   */
-  RightBottomOrientation,  /* Bottom to top  / Right to left   */
-  LeftBottomOrientation    /* Bottom to top  / Left to right   */
+typedef enum               /*    Exif     /  Row 0   / Column 0 */
+                           /* Orientation /  edge    /   edge   */
+{                          /* ----------- / -------- / -------- */
+  UndefinedOrientation,    /*      0      / Unknown  / Unknown  */
+  TopLeftOrientation,      /*      1      / Left     / Top      */
+  TopRightOrientation,     /*      2      / Right    / Top      */
+  BottomRightOrientation,  /*      3      / Right    / Bottom   */
+  BottomLeftOrientation,   /*      4      / Left     / Bottom   */
+  LeftTopOrientation,      /*      5      / Top      / Left     */
+  RightTopOrientation,     /*      6      / Top      / Right    */
+  RightBottomOrientation,  /*      7      / Bottom   / Right    */
+  LeftBottomOrientation    /*      8      / Bottom   / Left     */
 } OrientationType;
 
 typedef enum
@@ -669,6 +678,8 @@ typedef struct _SegmentInfo
     y2;
 } SegmentInfo;
 
+struct _ImageExtra;  /* forward decl.; see member "extra" below */
+
 typedef struct _Image
 {
   ClassType
@@ -682,7 +693,7 @@ typedef struct _Image
 
   MagickBool
     dither,             /* True if image is to be dithered */
-    matte;              /* True if image has an opacity (alpha) channel */ 
+    matte;              /* True if image has an opacity (alpha) channel */
 
   unsigned long
     columns,            /* Number of image columns */
@@ -841,8 +852,16 @@ typedef struct _Image
     is_grayscale,       /* Private, True if image is known to be grayscale */
     taint;              /* Private, True if image has not been modifed */
 
-  struct _Image
-    *clip_mask;         /* Private, Clipping mask to apply when updating pixels */
+  /*
+    Allow for expansion of Image without increasing its size.  The
+    internals are defined only in image.c.  Clients outside of image.c
+    can access the internals via the provided access functions (see below).
+
+    This location in Image used to be occupied by Image *clip_mask. The
+    clip_mask member now lives in _ImageExtra.
+  */
+  struct _ImageExtra
+    *extra;
 
   MagickBool
     ping;               /* Private, if true, pixels are undefined */
@@ -1013,6 +1032,7 @@ extern MagickExport Image
   *CloneImage(const Image *,const unsigned long,const unsigned long,
    const unsigned int,ExceptionInfo *),
   *GetImageClipMask(const Image *,ExceptionInfo *),
+  *GetImageCompositeMask(const Image *,ExceptionInfo *),  /*to support SVG masks*/
   *ReferenceImage(Image *);
 
 extern MagickExport ImageInfo
@@ -1040,6 +1060,8 @@ extern MagickExport MagickPassFail
   AnimateImages(const ImageInfo *image_info,Image *image),
   ClipImage(Image *image),
   ClipPathImage(Image *image,const char *pathname,const MagickBool inside),
+  CompositeMaskImage(Image *image),   /*to support SVG masks*/
+  CompositePathImage(Image *image,const char *pathname,const MagickBool inside),  /*to support SVG masks*/
   DisplayImages(const ImageInfo *image_info,Image *image),
   RemoveDefinitions(const ImageInfo *image_info,const char *options),
   ResetImagePage(Image *image,const char *page),
@@ -1047,8 +1069,9 @@ extern MagickExport MagickPassFail
   SetImageEx(Image *image,const Quantum opacity,ExceptionInfo *exception),
   SetImageColor(Image *image,const PixelPacket *pixel),
   SetImageColorRegion(Image *image,long x,long y,unsigned long width,
-                     unsigned long height,const PixelPacket *pixel),
+                      unsigned long height,const PixelPacket *pixel),
   SetImageClipMask(Image *image,const Image *clip_mask),
+  SetImageCompositeMask(Image *image,const Image *composite_mask),  /*to support SVG masks*/
   SetImageDepth(Image *image,const unsigned long),
   SetImageInfo(ImageInfo *image_info,const unsigned int flags,ExceptionInfo *exception),
   SetImageType(Image *image,const ImageType),
@@ -1064,6 +1087,14 @@ extern MagickExport void
   ModifyImage(Image **,ExceptionInfo *),
   SetImageOpacity(Image *,const unsigned int);
 
+/* provide public access to the clip_mask member of Image */
+extern MagickExport Image
+  **ImageGetClipMask(const Image *) MAGICK_FUNC_PURE;
+
+/* provide public access to the composite_mask member of Image */
+extern MagickExport Image
+  **ImageGetCompositeMask(const Image *) MAGICK_FUNC_PURE;
+
 #if defined(MAGICK_IMPLEMENTATION)
   /*
     SetImageInfo flags specification.
index 1f2f8c4..825115a 100644 (file)
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2003 - 2012 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
 
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Methods to import image pixels from common representations
 
 */
@@ -39,68 +39,68 @@ static const PixelPacket WhitePixel = {MaxRGB, MaxRGB, MaxRGB, OpaqueOpacity};
 #  define MyEndianType LSBEndian
 #endif
 
-#define ImportModulo8Quantum(quantum,quantum_size,p)    \
-  {                                                     \
-    register unsigned int                               \
-      shift;                                            \
-                                                        \
-    quantum=0;                                          \
-    if (LSBEndian != endian)                            \
-      {                                                 \
-        shift=quantum_size;                             \
-        do                                              \
-          {                                             \
-            shift -= 8U;                                \
-            quantum |= (*p++ << shift);                 \
-          } while( shift > 0U);                         \
-      }                                                 \
-    else                                                \
-      {                                                 \
-        shift=0U;                                       \
-        while ( shift < quantum_size )                  \
-          {                                             \
-            quantum |= (*p++ << shift);                 \
-            shift += 8U;                                \
-          }                                             \
-      }                                                 \
+#define ImportModulo8Quantum(quantum,quantum_size,p)            \
+  {                                                             \
+    register unsigned int                                       \
+      shift;                                                    \
+                                                                \
+    quantum=0;                                                  \
+    if (LSBEndian != endian)                                    \
+      {                                                         \
+        shift=quantum_size;                                     \
+        do                                                      \
+          {                                                     \
+            shift -= 8U;                                        \
+            quantum |= (((magick_uint32_t) *p++) << shift);     \
+          } while( shift > 0U);                                 \
+      }                                                         \
+    else                                                        \
+      {                                                         \
+        shift=0U;                                               \
+        while ( shift < quantum_size )                          \
+          {                                                     \
+            quantum |= (((magick_uint32_t) *p++) << shift);     \
+            shift += 8U;                                        \
+          }                                                     \
+      }                                                         \
   }
-#define ImportUInt8Quantum(quantum,p)           \
-  {                                             \
-    quantum=*p++;                               \
+#define ImportUInt8Quantum(quantum,p)                           \
+  {                                                             \
+    quantum=(magick_uint32_t) *p++;                             \
   }
-#define ImportUInt16Quantum(endian,quantum,p)   \
-  {                                             \
-    if (LSBEndian != endian)                    \
-      {                                         \
-        quantum=(*p++ << 8);                    \
-        quantum|=(*p++);                        \
-      }                                         \
-    else                                        \
-      {                                         \
-        quantum=(*p++);                         \
-        quantum|=(*p++ << 8);                   \
-      }                                         \
+#define ImportUInt16Quantum(endian,quantum,p)                   \
+  {                                                             \
+    if (LSBEndian != endian)                                    \
+      {                                                         \
+        quantum=(((magick_uint32_t) *p++) << 8);                \
+        quantum|=((magick_uint32_t) *p++);                      \
+      }                                                         \
+    else                                                        \
+      {                                                         \
+        quantum=((magick_uint32_t) *p++);                       \
+        quantum|=(((magick_uint32_t) *p++) << 8);               \
+      }                                                         \
   }
 /*
   This algorithm has been compared with several others and did best
   overall on SPARC, PowerPC, and Intel Xeon.
 */
-#define ImportUInt32Quantum(endian,quantum,p)   \
-  {                                             \
-    if (LSBEndian != endian)                    \
-      {                                         \
-        quantum=(*p++ << 24);                   \
-        quantum|=(*p++ << 16);                  \
-        quantum|=(*p++ << 8);                   \
-        quantum|=(*p++);                        \
-      }                                         \
-    else                                        \
-      {                                         \
-        quantum=(*p++);                         \
-        quantum|=(*p++ << 8);                   \
-        quantum|=(*p++ << 16);                  \
-        quantum|=(*p++ << 24);                  \
-      }                                         \
+#define ImportUInt32Quantum(endian,quantum,p)                   \
+  {                                                             \
+    if (LSBEndian != endian)                                    \
+      {                                                         \
+        quantum=(((magick_uint32_t) *p++) << 24);               \
+        quantum|=(((magick_uint32_t) *p++) << 16);              \
+        quantum|=(((magick_uint32_t) *p++) << 8);               \
+        quantum|=((magick_uint32_t) *p++);                      \
+      }                                                         \
+    else                                                        \
+      {                                                         \
+        quantum=((magick_uint32_t) *p++);                       \
+        quantum|=(((magick_uint32_t) *p++) << 8);               \
+        quantum|=(((magick_uint32_t) *p++) << 16);              \
+        quantum|=(((magick_uint32_t) *p++) << 24);              \
+      }                                                         \
   }
 /*
   Import a 64-bit unsigned value into a 32-bit quantum type.  This
@@ -108,63 +108,63 @@ static const PixelPacket WhitePixel = {MaxRGB, MaxRGB, MaxRGB, OpaqueOpacity};
   CPUs may perform poorly when using a true 64-bit type.  In this case
   the least significant 32 bits are entirely ignored.
 */
-#define ImportUInt64Quantum(endian,quantum,p)   \
-  {                                             \
-    if (LSBEndian != endian)                    \
-      {                                         \
-        quantum=(*p++ << 24);                   \
-        quantum|=(*p++ << 16);                  \
-        quantum|=(*p++ << 8);                   \
-        quantum|=(*p++);                        \
-        p+=4;                                   \
-      }                                         \
-    else                                        \
-      {                                         \
-        p+=4;                                   \
-        quantum=(*p++);                         \
-        quantum|=(*p++ << 8);                   \
-        quantum|=(*p++ << 16);                  \
-        quantum|=(*p++ << 24);                  \
-      }                                         \
+#define ImportUInt64Quantum(endian,quantum,p)                   \
+  {                                                             \
+    if (LSBEndian != endian)                                    \
+      {                                                         \
+        quantum=(((magick_uint32_t) *p++) << 24);               \
+        quantum|=(((magick_uint32_t) *p++) << 16);              \
+        quantum|=(((magick_uint32_t) *p++) << 8);               \
+        quantum|=((magick_uint32_t) *p++);                      \
+        p+=4;                                                   \
+      }                                                         \
+    else                                                        \
+      {                                                         \
+        p+=4;                                                   \
+        quantum=((magick_uint32_t) *p++);                       \
+        quantum|=(((magick_uint32_t) *p++) << 8);               \
+        quantum|=(((magick_uint32_t) *p++) << 16);              \
+        quantum|=(((magick_uint32_t) *p++) << 24);              \
+      }                                                         \
   }
-#define ImportFloat16Quantum(endian,value,p)                   \
-  {                                                            \
-    float float_value;                                         \
-    unsigned char c[2];                                                \
-    if (MyEndianType == endian)                                        \
-      {                                                                \
-        c[0]=*p++;                                             \
-        c[1]=*p++;                                             \
-      }                                                                \
-    else                                                       \
-      {                                                                \
-        c[1]=*p++;                                             \
-        c[0]=*p++;                                             \
-      }                                                                \
-    (void) _Gm_convert_fp16_to_fp32((const fp_16bits *)c,      \
-                                   &float_value);              \
-    value=float_value;                                         \
+#define ImportFloat16Quantum(endian,value,p)                    \
+  {                                                             \
+    float float_value;                                          \
+    unsigned char c[2];                                         \
+    if (MyEndianType == endian)                                 \
+      {                                                         \
+        c[0]=*p++;                                              \
+        c[1]=*p++;                                              \
+      }                                                         \
+    else                                                        \
+      {                                                         \
+        c[1]=*p++;                                              \
+        c[0]=*p++;                                              \
+      }                                                         \
+    (void) _Gm_convert_fp16_to_fp32((const fp_16bits *)c,       \
+                                    &float_value);              \
+    value=float_value;                                          \
   }
-#define ImportFloat24Quantum(endian,value,p)                   \
-  {                                                            \
-    float float_value;                                         \
-    unsigned char c[3];                                                \
-    if (MyEndianType == endian)                                        \
-      {                                                                \
-        c[0]=*p++;                                             \
-        c[1]=*p++;                                             \
-        c[2]=*p++;                                             \
-      }                                                                \
-    else                                                       \
-      {                                                                \
-        c[2]=*p++;                                             \
-        c[1]=*p++;                                             \
-        c[0]=*p++;                                             \
-      }                                                                \
-    (void) _Gm_convert_fp24_to_fp32((const fp_24bits *)c,      \
-                                   &float_value,               \
-                                   RANGE_LIMITED);             \
-    value=float_value;                                         \
+#define ImportFloat24Quantum(endian,value,p)                    \
+  {                                                             \
+    float float_value;                                          \
+    unsigned char c[3];                                         \
+    if (MyEndianType == endian)                                 \
+      {                                                         \
+        c[0]=*p++;                                              \
+        c[1]=*p++;                                              \
+        c[2]=*p++;                                              \
+      }                                                         \
+    else                                                        \
+      {                                                         \
+        c[2]=*p++;                                              \
+        c[1]=*p++;                                              \
+        c[0]=*p++;                                              \
+      }                                                         \
+    (void) _Gm_convert_fp24_to_fp32((const fp_24bits *)c,       \
+                                    &float_value,               \
+                                    RANGE_LIMITED);             \
+    value=float_value;                                          \
 }
 #define ImportFloat32Quantum(endian,value,p)    \
   {                                             \
@@ -187,6 +187,8 @@ static const PixelPacket WhitePixel = {MaxRGB, MaxRGB, MaxRGB, OpaqueOpacity};
         fu_.c[0]=*p++;                          \
         value=fu_.f;                            \
       }                                         \
+    if (MAGICK_ISNAN(value))                    \
+      value = 0.0;                              \
   }
 #define ImportFloat64Quantum(endian,value,p)    \
   {                                             \
@@ -213,6 +215,8 @@ static const PixelPacket WhitePixel = {MaxRGB, MaxRGB, MaxRGB, OpaqueOpacity};
         du_.c[0]=*p++;                          \
         value=du_.d;                            \
       }                                         \
+    if (MAGICK_ISNAN(value))                \
+      value = 0.0;                              \
   }
 \f
 /*
@@ -337,15 +341,15 @@ MagickExport MagickPassFail ImportImagePixelArea(Image *image,
 */
 static MagickPassFail
 ImportIndexQuantumType(const unsigned char *source,
-                      PixelPacket* restrict q,
-                      IndexPacket * restrict indexes,
-                      const unsigned long number_pixels,
-                      const unsigned int quantum_size,
-                      const QuantumSampleType sample_type,
-                      const unsigned int unsigned_maxvalue,
-                      const EndianType endian,
-                      Image *image,
-                      ImportPixelAreaInfo *import_info)
+                       PixelPacket* restrict q,
+                       IndexPacket * restrict indexes,
+                       const unsigned long number_pixels,
+                       const unsigned int quantum_size,
+                       const QuantumSampleType sample_type,
+                       const unsigned int unsigned_maxvalue,
+                       const EndianType endian,
+                       Image *image,
+                       ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -353,138 +357,142 @@ ImportIndexQuantumType(const unsigned char *source,
   register unsigned long
     x;
 
-  register unsigned int
+  register magick_uint32_t
     index;
 
   assert(image->colors <= MaxColormapSize);
-  assert(image->colors != 0);
-  assert(indexes != (IndexPacket *) NULL);
+
+  if ((image->storage_class != PseudoClass) ||
+      (image->colors == 0) ||
+      (indexes == (IndexPacket *) NULL))
+    ThrowBinaryException3(ImageError,ImageIsNotColormapped,
+                          UnableToImportImagePixels);
 
   p=source;
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 1:
-         {
-           /*
-             Special fast support for two colors.
-           */
-           register unsigned int
-             bit = 8U;
-                  
-           for (x = number_pixels ; x != 0 ; --x )
-             {
-               --bit;
-               index=(*p >> bit) & 0x01;
-               VerifyColormapIndex(image,index);
-               *indexes++=index;
-               *q++=image->colormap[index];
-               if (bit == 0)
-                 {
-                   bit=8;
-                   p++;
-                 }
-             }
-           break;
-         }
-       case 4:
-         {
-           /*
-             Special fast support for 16 colors.
-           */
-           register unsigned int
-             state = 0;
-                  
-           for (x = number_pixels ; x != 0 ; --x )
-             {
-               state ^= 1; /* Produces 1 0 1 0 ... */
-               index=(IndexPacket) ((state ? (*p >> 4) : (*p++)) & 0xf);
-               VerifyColormapIndex(image,index);
-               *indexes++=index;
-               *q++=image->colormap[index];
-             }
-           break;
-         }
-       case 8:
-         {
-           if (unsigned_maxvalue <= (unsigned int) (image->colors-1))
-             {
-               /*
-                 Special case for when it is impossible to
-                 overflow the colormap range.
-               */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportUInt8Quantum(index,p);
-                   *indexes++=index;
-                   *q++=image->colormap[index];
-                 }
-             }
-           else
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportUInt8Quantum(index,p);
-                   VerifyColormapIndex(image,index);
-                   *indexes++=index;
-                   *q++=image->colormap[index];
-                 }
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt16Quantum(endian,index,p);
-               VerifyColormapIndex(image,index);
-               *indexes++=index;
-               *q++=image->colormap[index];
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt32Quantum(endian,index,p);
-               VerifyColormapIndex(image,index);
-               *indexes++=index;
-               *q++=image->colormap[index];
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt64Quantum(endian,index,p);
-               VerifyColormapIndex(image,index);
-               *indexes++=index;
-               *q++=image->colormap[index];
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamReadHandle
-             stream;
-                  
-           MagickBitStreamInitializeRead(&stream,p);
-           for (x = number_pixels; x != 0; --x)
-             {
-               index=MagickBitStreamMSBRead(&stream,quantum_size);
-               VerifyColormapIndex(image,index);
-               *indexes++=index;
-               *q++=image->colormap[index];
-             }
-           break;
-         }
-       }
+        {
+        case 1:
+          {
+            /*
+              Special fast support for two colors.
+            */
+            register unsigned int
+              bit = 8U;
+
+            for (x = number_pixels ; x != 0 ; --x )
+              {
+                --bit;
+                index=(*p >> bit) & 0x01;
+                VerifyColormapIndex(image,index);
+                *indexes++=index;
+                *q++=image->colormap[index];
+                if (bit == 0)
+                  {
+                    bit=8;
+                    p++;
+                  }
+              }
+            break;
+          }
+        case 4:
+          {
+            /*
+              Special fast support for 16 colors.
+            */
+            register unsigned int
+              state = 0;
+
+            for (x = number_pixels ; x != 0 ; --x )
+              {
+                state ^= 1; /* Produces 1 0 1 0 ... */
+                index=(IndexPacket) ((state ? (*p >> 4) : (*p++)) & 0xf);
+                VerifyColormapIndex(image,index);
+                *indexes++=index;
+                *q++=image->colormap[index];
+              }
+            break;
+          }
+        case 8:
+          {
+            if (unsigned_maxvalue <= (unsigned int) (image->colors-1))
+              {
+                /*
+                  Special case for when it is impossible to
+                  overflow the colormap range.
+                */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportUInt8Quantum(index,p);
+                    *indexes++=index;
+                    *q++=image->colormap[index];
+                  }
+              }
+            else
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportUInt8Quantum(index,p);
+                    VerifyColormapIndex(image,index);
+                    *indexes++=index;
+                    *q++=image->colormap[index];
+                  }
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt16Quantum(endian,index,p);
+                VerifyColormapIndex(image,index);
+                *indexes++=index;
+                *q++=image->colormap[index];
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt32Quantum(endian,index,p);
+                VerifyColormapIndex(image,index);
+                *indexes++=index;
+                *q++=image->colormap[index];
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt64Quantum(endian,index,p);
+                VerifyColormapIndex(image,index);
+                *indexes++=index;
+                *q++=image->colormap[index];
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamReadHandle
+              stream;
+
+            MagickBitStreamInitializeRead(&stream,p);
+            for (x = number_pixels; x != 0; --x)
+              {
+                index=MagickBitStreamMSBRead(&stream,quantum_size);
+                VerifyColormapIndex(image,index);
+                *indexes++=index;
+                *q++=image->colormap[index];
+              }
+            break;
+          }
+        }
     }
 
   if (import_info)
@@ -497,15 +505,15 @@ ImportIndexQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportIndexAlphaQuantumType(const unsigned char *source,
-                           PixelPacket* restrict q,
-                           IndexPacket * restrict indexes,
-                           const unsigned long number_pixels,
-                           const unsigned int quantum_size,
-                           const QuantumSampleType sample_type,
-                           const unsigned int unsigned_scale,
-                           const EndianType endian,
-                           Image *image,
-                           ImportPixelAreaInfo *import_info)
+                            PixelPacket* restrict q,
+                            IndexPacket * restrict indexes,
+                            const unsigned long number_pixels,
+                            const unsigned int quantum_size,
+                            const QuantumSampleType sample_type,
+                            const unsigned int unsigned_scale,
+                            const EndianType endian,
+                            Image *image,
+                            ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -513,7 +521,7 @@ ImportIndexAlphaQuantumType(const unsigned char *source,
   register unsigned long
     x;
 
-  register unsigned int
+  register magick_uint32_t
     index,
     unsigned_value;
 
@@ -522,100 +530,106 @@ ImportIndexAlphaQuantumType(const unsigned char *source,
 
   assert(image->colors <= MaxColormapSize);
 
+  if ((image->storage_class != PseudoClass) ||
+      (image->colors == 0) ||
+      (indexes == (IndexPacket *) NULL))
+    ThrowBinaryException3(ImageError,ImageIsNotColormapped,
+                          UnableToImportImagePixels);
+
   sample_bits=quantum_size;
   p=source;
 
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch(quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt8Quantum(index,p);
-               VerifyColormapIndex(image,index);
-               *indexes++=index;
-               *q=image->colormap[index];
-                      
-               ImportUInt8Quantum(unsigned_value,p);
-               SetOpacitySample(q,MaxRGB-ScaleCharToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt16Quantum(endian,index,p);
-               VerifyColormapIndex(image,index);
-               *indexes++=index;
-               *q=image->colormap[index];
-                      
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetOpacitySample(q,MaxRGB-ScaleShortToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt32Quantum(endian,index,p);
-               VerifyColormapIndex(image,index);
-               *indexes++=index;
-               *q=image->colormap[index];
-                      
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt64Quantum(endian,index,p);
-               VerifyColormapIndex(image,index);
-               *indexes++=index;
-               *q=image->colormap[index];
-                      
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamReadHandle
-             stream;
-                  
-           MagickBitStreamInitializeRead(&stream,p);
-           for (x = number_pixels; x != 0; --x)
-             {
-               index=MagickBitStreamMSBRead(&stream,quantum_size);
-               VerifyColormapIndex(image,index);
-               *indexes++=index;
-               *q=image->colormap[index];
-                      
-               unsigned_value=MagickBitStreamMSBRead(&stream,quantum_size);
-               if (QuantumDepth >  sample_bits)
-                 unsigned_value *= unsigned_scale;
-               else if (QuantumDepth <  sample_bits)
-                 unsigned_value /= unsigned_scale;
-               SetOpacitySample(q,MaxRGB-unsigned_value);
-               q++;
-             }
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt8Quantum(index,p);
+                VerifyColormapIndex(image,index);
+                *indexes++=index;
+                *q=image->colormap[index];
+
+                ImportUInt8Quantum(unsigned_value,p);
+                SetOpacitySample(q,MaxRGB-ScaleCharToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt16Quantum(endian,index,p);
+                VerifyColormapIndex(image,index);
+                *indexes++=index;
+                *q=image->colormap[index];
+
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetOpacitySample(q,MaxRGB-ScaleShortToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt32Quantum(endian,index,p);
+                VerifyColormapIndex(image,index);
+                *indexes++=index;
+                *q=image->colormap[index];
+
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt64Quantum(endian,index,p);
+                VerifyColormapIndex(image,index);
+                *indexes++=index;
+                *q=image->colormap[index];
+
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamReadHandle
+              stream;
+
+            MagickBitStreamInitializeRead(&stream,p);
+            for (x = number_pixels; x != 0; --x)
+              {
+                index=MagickBitStreamMSBRead(&stream,quantum_size);
+                VerifyColormapIndex(image,index);
+                *indexes++=index;
+                *q=image->colormap[index];
+
+                unsigned_value=MagickBitStreamMSBRead(&stream,quantum_size);
+                if (QuantumDepth >  sample_bits)
+                  unsigned_value *= unsigned_scale;
+                else if (QuantumDepth <  sample_bits)
+                  unsigned_value /= unsigned_scale;
+                SetOpacitySample(q,MaxRGB-unsigned_value);
+                q++;
+              }
+            break;
+          }
+        }
     }
 
   if (import_info)
@@ -628,19 +642,19 @@ ImportIndexAlphaQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportGrayQuantumType(const unsigned char *source,
-                     PixelPacket* restrict q,
-                     IndexPacket * restrict indexes,
-                     const unsigned long number_pixels,
-                     const unsigned int quantum_size,
-                     const QuantumSampleType sample_type,
-                     const unsigned int unsigned_scale,
-                     const unsigned int unsigned_maxvalue,
-                     const MagickBool grayscale_miniswhite,
-                     const double double_minvalue,
-                     const double double_scale,
-                     const EndianType endian,
-                     Image *image,
-                     ImportPixelAreaInfo *import_info)
+                      PixelPacket* restrict q,
+                      IndexPacket * restrict indexes,
+                      const unsigned long number_pixels,
+                      const unsigned int quantum_size,
+                      const QuantumSampleType sample_type,
+                      const unsigned int unsigned_scale,
+                      const unsigned int unsigned_maxvalue,
+                      const MagickBool grayscale_miniswhite,
+                      const double double_minvalue,
+                      const double double_scale,
+                      const EndianType endian,
+                      Image *image,
+                      ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -651,7 +665,7 @@ ImportGrayQuantumType(const unsigned char *source,
   double
     double_value;
 
-  register unsigned int
+  register magick_uint32_t
     index,
     unsigned_value;
 
@@ -664,344 +678,350 @@ ImportGrayQuantumType(const unsigned char *source,
   if (sample_type == UnsignedQuantumSampleType)
     {
       if (DirectClass == image->storage_class)
-       {
-         /*
-           DirectClass representation.
-         */
-         switch (quantum_size)
-           {
-           case 1:
-             {
-               /*
-                 Special fast support for bi-level gray.
-               */
-               register int
-                 bit = 8;
-                      
-               PixelPacket
-                 min_val,
-                 max_val;
-
-               if (grayscale_miniswhite)
-                 {
-                   min_val=WhitePixel;
-                   max_val=BlackPixel;
-                 }
-               else
-                 {
-                   min_val=BlackPixel;
-                   max_val=WhitePixel;
-                 }
-                      
-               for (x = number_pixels ; x != 0 ; --x )
-                 {
-                   --bit;
-                   *q++=(((*p >> bit) & 0x01) ? max_val : min_val);
-                   if (bit == 0)
-                     {
-                       bit=8;
-                       p++;
-                     }
-                 }
-               if (bit != 8)
-                 p++;
-               break;
-             }
-           case 8:
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       SetGraySample(q,MaxRGB-ScaleCharToQuantum(*p++));
-                       SetOpacitySample(q,OpaqueOpacity);
-                       q++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       SetGraySample(q,ScaleCharToQuantum(*p++));
-                       SetOpacitySample(q,OpaqueOpacity);
-                       q++;
-                     }
-                 }
-               break;
-             }
-           case 16:
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt16Quantum(endian,unsigned_value,p);
-                       SetGraySample(q,MaxRGB-ScaleShortToQuantum(unsigned_value));
-                       SetOpacitySample(q,OpaqueOpacity);
-                       q++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt16Quantum(endian,unsigned_value,p);
-                       SetGraySample(q,ScaleShortToQuantum(unsigned_value));
-                       SetOpacitySample(q,OpaqueOpacity);
-                       q++;
-                     }
-                 }
-               break;
-             }
-           case 32:
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt32Quantum(endian,unsigned_value,p);
-                       SetGraySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
-                       SetOpacitySample(q,OpaqueOpacity);
-                       q++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt32Quantum(endian,unsigned_value,p);
-                       SetGraySample(q,ScaleLongToQuantum(unsigned_value));
-                       SetOpacitySample(q,OpaqueOpacity);
-                       q++;
-                     }
-                 }
-               break;
-             }
-           case 64:
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt64Quantum(endian,unsigned_value,p);
-                       SetGraySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
-                       SetOpacitySample(q,OpaqueOpacity);
-                       q++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt64Quantum(endian,unsigned_value,p);
-                       SetGraySample(q,ScaleLongToQuantum(unsigned_value));
-                       SetOpacitySample(q,OpaqueOpacity);
-                       q++;
-                     }
-                 }
-               break;
-             }
-           default:
-             {
-               BitStreamReadHandle
-                 stream;
-                      
-               MagickBitStreamInitializeRead(&stream,p);
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   unsigned_value=MagickBitStreamMSBRead(&stream,quantum_size);
-                   if (QuantumDepth >  sample_bits)
-                     unsigned_value *= unsigned_scale;
-                   else if (QuantumDepth <  sample_bits)
-                     unsigned_value /= unsigned_scale;
-                   if (grayscale_miniswhite)
-                     unsigned_value = MaxRGB-unsigned_value;
-                   SetGraySample(q,unsigned_value);
-                   SetOpacitySample(q,OpaqueOpacity);
-                   q++;
-                 }
-               break;
-             }
-           }
-       }
+        {
+          /*
+            DirectClass representation.
+          */
+          switch (quantum_size)
+            {
+            case 1:
+              {
+                /*
+                  Special fast support for bi-level gray.
+                */
+                register int
+                  bit = 8;
+
+                PixelPacket
+                  min_val,
+                  max_val;
+
+                if (grayscale_miniswhite)
+                  {
+                    min_val=WhitePixel;
+                    max_val=BlackPixel;
+                  }
+                else
+                  {
+                    min_val=BlackPixel;
+                    max_val=WhitePixel;
+                  }
+
+                for (x = number_pixels ; x != 0 ; --x )
+                  {
+                    --bit;
+                    *q++=(((*p >> bit) & 0x01) ? max_val : min_val);
+                    if (bit == 0)
+                      {
+                        bit=8;
+                        p++;
+                      }
+                  }
+                if (bit != 8)
+                  p++;
+                break;
+              }
+            case 8:
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        SetGraySample(q,MaxRGB-ScaleCharToQuantum(*p++));
+                        SetOpacitySample(q,OpaqueOpacity);
+                        q++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        SetGraySample(q,ScaleCharToQuantum(*p++));
+                        SetOpacitySample(q,OpaqueOpacity);
+                        q++;
+                      }
+                  }
+                break;
+              }
+            case 16:
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt16Quantum(endian,unsigned_value,p);
+                        SetGraySample(q,MaxRGB-ScaleShortToQuantum(unsigned_value));
+                        SetOpacitySample(q,OpaqueOpacity);
+                        q++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt16Quantum(endian,unsigned_value,p);
+                        SetGraySample(q,ScaleShortToQuantum(unsigned_value));
+                        SetOpacitySample(q,OpaqueOpacity);
+                        q++;
+                      }
+                  }
+                break;
+              }
+            case 32:
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt32Quantum(endian,unsigned_value,p);
+                        SetGraySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
+                        SetOpacitySample(q,OpaqueOpacity);
+                        q++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt32Quantum(endian,unsigned_value,p);
+                        SetGraySample(q,ScaleLongToQuantum(unsigned_value));
+                        SetOpacitySample(q,OpaqueOpacity);
+                        q++;
+                      }
+                  }
+                break;
+              }
+            case 64:
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt64Quantum(endian,unsigned_value,p);
+                        SetGraySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
+                        SetOpacitySample(q,OpaqueOpacity);
+                        q++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt64Quantum(endian,unsigned_value,p);
+                        SetGraySample(q,ScaleLongToQuantum(unsigned_value));
+                        SetOpacitySample(q,OpaqueOpacity);
+                        q++;
+                      }
+                  }
+                break;
+              }
+            default:
+              {
+                BitStreamReadHandle
+                  stream;
+
+                MagickBitStreamInitializeRead(&stream,p);
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    unsigned_value=MagickBitStreamMSBRead(&stream,quantum_size);
+                    if (QuantumDepth >  sample_bits)
+                      unsigned_value *= unsigned_scale;
+                    else if (QuantumDepth <  sample_bits)
+                      unsigned_value /= unsigned_scale;
+                    if (grayscale_miniswhite)
+                      unsigned_value = MaxRGB-unsigned_value;
+                    SetGraySample(q,unsigned_value);
+                    SetOpacitySample(q,OpaqueOpacity);
+                    q++;
+                  }
+                break;
+              }
+            }
+        }
       else
-       {
-         /*
-           PseudoClass representation.
-                  
-           Note that this implementation assumes that the
-           colormap is written in ascending levels of intensity
-           as produced by AllocateImageColormap().  Some old
-           code may assume that 'miniswhite' inverts the
-           colormap order as well.
-         */
-         assert(image->colors <= MaxColormapSize);
-                
-         switch (quantum_size)
-           {
-           case 1:
-             {
-               /*
-                 Special fast support for bi-level gray.
-               */
-               register int
-                 bit = 8;
-                      
-               for (x = number_pixels ; x != 0 ; --x )
-                 {
-                   --bit;
-                   index=(*p >> bit) & 0x01;
-                   if (grayscale_miniswhite)
-                     index ^= 0x01;
-                   *indexes++=index;
-                   *q++=image->colormap[index];
-                   if (bit == 0)
-                     {
-                       bit=8;
-                       p++;
-                     }
-                 }
-               if (bit != 8)
-                 p++;
-               break;
-             }
-           case 8:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportUInt8Quantum(index,p);
-                   VerifyColormapIndex(image,index);
-                   if (grayscale_miniswhite)
-                     index=(image->colors-1)-index;
-                   *indexes++=index;
-                   *q++=image->colormap[index];
-                 }
-               break;
-             }
-           case 16:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportUInt16Quantum(endian,index,p);
-                   VerifyColormapIndex(image,index);
-                   if (grayscale_miniswhite)
-                     index=(image->colors-1)-index;
-                   *indexes++=index;
-                   *q++=image->colormap[index];
-                 }
-               break;
-             }
-           case 32:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportUInt32Quantum(endian,index,p);
-                   VerifyColormapIndex(image,index);
-                   if (grayscale_miniswhite)
-                     index=(image->colors-1)-index;
-                   *indexes++=index;
-                   *q++=image->colormap[index];
-                 }
-               break;
-             }
-           case 64:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportUInt64Quantum(endian,index,p);
-                   VerifyColormapIndex(image,index);
-                   if (grayscale_miniswhite)
-                     index=(image->colors-1)-index;
-                   *indexes++=index;
-                   *q++=image->colormap[index];
-                 }
-               break;
-             }
-           default:
-             {
-               /*
-                 Arbitrary sample size
-               */
-               BitStreamReadHandle
-                 stream;
-
-               register unsigned int
-                 indexes_scale = 1U;
-
-               if (unsigned_maxvalue > (image->colors-1))
-                 indexes_scale=(unsigned_maxvalue/(image->colors-1));
-                
-               MagickBitStreamInitializeRead(&stream,p);
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   index=MagickBitStreamMSBRead(&stream,quantum_size);
-                   index /= indexes_scale;
-                   VerifyColormapIndex(image,index);
-                   if (grayscale_miniswhite)
-                     index=(image->colors-1)-index;
-                   *indexes++=index;
-                   *q++=image->colormap[index];
-                 }
-               break;
-             }
-           }
-       }
+        {
+          /*
+            PseudoClass representation.
+
+            Note that this implementation assumes that the
+            colormap is written in ascending levels of intensity
+            as produced by AllocateImageColormap().  Some old
+            code may assume that 'miniswhite' inverts the
+            colormap order as well.
+          */
+          assert(image->colors <= MaxColormapSize);
+
+          if ((image->storage_class != PseudoClass) ||
+              (image->colors == 0) ||
+              (indexes == (IndexPacket *) NULL))
+            ThrowBinaryException3(ImageError,ImageIsNotColormapped,
+                                  UnableToImportImagePixels);
+
+          switch (quantum_size)
+            {
+            case 1:
+              {
+                /*
+                  Special fast support for bi-level gray.
+                */
+                register int
+                  bit = 8;
+
+                for (x = number_pixels ; x != 0 ; --x )
+                  {
+                    --bit;
+                    index=(*p >> bit) & 0x01;
+                    if (grayscale_miniswhite)
+                      index ^= 0x01;
+                    *indexes++=index;
+                    *q++=image->colormap[index];
+                    if (bit == 0)
+                      {
+                        bit=8;
+                        p++;
+                      }
+                  }
+                if (bit != 8)
+                  p++;
+                break;
+              }
+            case 8:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportUInt8Quantum(index,p);
+                    VerifyColormapIndex(image,index);
+                    if (grayscale_miniswhite)
+                      index=(image->colors-1)-index;
+                    *indexes++=index;
+                    *q++=image->colormap[index];
+                  }
+                break;
+              }
+            case 16:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportUInt16Quantum(endian,index,p);
+                    VerifyColormapIndex(image,index);
+                    if (grayscale_miniswhite)
+                      index=(image->colors-1)-index;
+                    *indexes++=index;
+                    *q++=image->colormap[index];
+                  }
+                break;
+              }
+            case 32:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportUInt32Quantum(endian,index,p);
+                    VerifyColormapIndex(image,index);
+                    if (grayscale_miniswhite)
+                      index=(image->colors-1)-index;
+                    *indexes++=index;
+                    *q++=image->colormap[index];
+                  }
+                break;
+              }
+            case 64:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportUInt64Quantum(endian,index,p);
+                    VerifyColormapIndex(image,index);
+                    if (grayscale_miniswhite)
+                      index=(image->colors-1)-index;
+                    *indexes++=index;
+                    *q++=image->colormap[index];
+                  }
+                break;
+              }
+            default:
+              {
+                /*
+                  Arbitrary sample size
+                */
+                BitStreamReadHandle
+                  stream;
+
+                register unsigned int
+                  indexes_scale = 1U;
+
+                if (unsigned_maxvalue > (image->colors-1))
+                  indexes_scale=(unsigned_maxvalue/(image->colors-1));
+
+                MagickBitStreamInitializeRead(&stream,p);
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    index=MagickBitStreamMSBRead(&stream,quantum_size);
+                    index /= indexes_scale;
+                    VerifyColormapIndex(image,index);
+                    if (grayscale_miniswhite)
+                      index=(image->colors-1)-index;
+                    *indexes++=index;
+                    *q++=image->colormap[index];
+                  }
+                break;
+              }
+            }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGraySample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGraySample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGraySample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGraySample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGraySample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGraySample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGraySample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGraySample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   if (import_info)
@@ -1014,19 +1034,19 @@ ImportGrayQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportGrayAlphaQuantumType(const unsigned char *source,
-                          PixelPacket* restrict q,
-                          IndexPacket * restrict indexes,
-                          const unsigned long number_pixels,
-                          const unsigned int quantum_size,
-                          const QuantumSampleType sample_type,
-                          const unsigned int unsigned_scale,
-                          const unsigned int unsigned_maxvalue,
-                          const MagickBool grayscale_miniswhite,
-                          const double double_minvalue,
-                          const double double_scale,
-                          const EndianType endian,
-                          Image *image,
-                          ImportPixelAreaInfo *import_info)
+                           PixelPacket* restrict q,
+                           IndexPacket * restrict indexes,
+                           const unsigned long number_pixels,
+                           const unsigned int quantum_size,
+                           const QuantumSampleType sample_type,
+                           const unsigned int unsigned_scale,
+                           const unsigned int unsigned_maxvalue,
+                           const MagickBool grayscale_miniswhite,
+                           const double double_minvalue,
+                           const double double_scale,
+                           const EndianType endian,
+                           Image *image,
+                           ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -1037,7 +1057,7 @@ ImportGrayAlphaQuantumType(const unsigned char *source,
   double
     double_value;
 
-  register unsigned int
+  register magick_uint32_t
     index,
     unsigned_value;
 
@@ -1050,314 +1070,320 @@ ImportGrayAlphaQuantumType(const unsigned char *source,
   if (sample_type == UnsignedQuantumSampleType)
     {
       if (DirectClass == image->storage_class)
-       {
-         /*
-           DirectClass representation.
-         */
-         switch (quantum_size)
-           {
-           case 8:
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt8Quantum(unsigned_value,p);
-                       SetGraySample(q,MaxRGB-ScaleCharToQuantum(unsigned_value));
-                       ImportUInt8Quantum(unsigned_value,p);
-                       SetOpacitySample(q,MaxRGB-ScaleCharToQuantum(unsigned_value));
-                       q++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt8Quantum(unsigned_value,p);
-                       SetGraySample(q,ScaleCharToQuantum(unsigned_value));
-                       ImportUInt8Quantum(unsigned_value,p);
-                       SetOpacitySample(q,MaxRGB-ScaleCharToQuantum(unsigned_value));
-                       q++;
-                     }
-                 }
-               break;
-             }
-           case 16:
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt16Quantum(endian,unsigned_value,p);
-                       SetGraySample(q,MaxRGB-ScaleShortToQuantum(unsigned_value));
-                       ImportUInt16Quantum(endian,unsigned_value,p);
-                       SetOpacitySample(q,MaxRGB-ScaleShortToQuantum(unsigned_value));
-                       q++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt16Quantum(endian,unsigned_value,p);
-                       SetGraySample(q,ScaleShortToQuantum(unsigned_value));
-                       ImportUInt16Quantum(endian,unsigned_value,p);
-                       SetOpacitySample(q,MaxRGB-ScaleShortToQuantum(unsigned_value));
-                       q++;
-                     }
-                 }
-               break;
-             }
-           case 32:
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt32Quantum(endian,unsigned_value,p);
-                       SetGraySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
-                       ImportUInt32Quantum(endian,unsigned_value,p);
-                       SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
-                       q++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt32Quantum(endian,unsigned_value,p);
-                       SetGraySample(q,ScaleLongToQuantum(unsigned_value));
-                       ImportUInt32Quantum(endian,unsigned_value,p);
-                       SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
-                       q++;
-                     }
-                 }
-               break;
-             }
-           case 64:
-             {
-               if (grayscale_miniswhite)
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt64Quantum(endian,unsigned_value,p);
-                       SetGraySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
-                       ImportUInt64Quantum(endian,unsigned_value,p);
-                       SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
-                       q++;
-                     }
-                 }
-               else
-                 {
-                   for (x = number_pixels; x != 0; --x)
-                     {
-                       ImportUInt64Quantum(endian,unsigned_value,p);
-                       SetGraySample(q,ScaleLongToQuantum(unsigned_value));
-                       ImportUInt64Quantum(endian,unsigned_value,p);
-                       SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
-                       q++;
-                     }
-                 }
-               break;
-             }
-           default:
-             {
-               /*
-                 Arbitrary Depth.
-               */
-               BitStreamReadHandle
-                 stream;
-                      
-               MagickBitStreamInitializeRead(&stream,p);
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   unsigned_value=MagickBitStreamMSBRead(&stream,quantum_size);
-                   if (QuantumDepth >  sample_bits)
-                     unsigned_value *= unsigned_scale;
-                   else if (QuantumDepth <  sample_bits)
-                     unsigned_value /= unsigned_scale;
-                   if (grayscale_miniswhite)
-                     unsigned_value = MaxRGB-unsigned_value;
-                   SetGraySample(q,unsigned_value);
-
-                   unsigned_value=MagickBitStreamMSBRead(&stream,quantum_size);
-                   if (QuantumDepth >  sample_bits)
-                     unsigned_value *= unsigned_scale;
-                   else if (QuantumDepth <  sample_bits)
-                     unsigned_value /= unsigned_scale;
-                   SetOpacitySample(q,MaxRGB-unsigned_value);
-                   q++;
-                 }
-               break;
-             }
-           }
-       }
+        {
+          /*
+            DirectClass representation.
+          */
+          switch (quantum_size)
+            {
+            case 8:
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt8Quantum(unsigned_value,p);
+                        SetGraySample(q,MaxRGB-ScaleCharToQuantum(unsigned_value));
+                        ImportUInt8Quantum(unsigned_value,p);
+                        SetOpacitySample(q,MaxRGB-ScaleCharToQuantum(unsigned_value));
+                        q++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt8Quantum(unsigned_value,p);
+                        SetGraySample(q,ScaleCharToQuantum(unsigned_value));
+                        ImportUInt8Quantum(unsigned_value,p);
+                        SetOpacitySample(q,MaxRGB-ScaleCharToQuantum(unsigned_value));
+                        q++;
+                      }
+                  }
+                break;
+              }
+            case 16:
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt16Quantum(endian,unsigned_value,p);
+                        SetGraySample(q,MaxRGB-ScaleShortToQuantum(unsigned_value));
+                        ImportUInt16Quantum(endian,unsigned_value,p);
+                        SetOpacitySample(q,MaxRGB-ScaleShortToQuantum(unsigned_value));
+                        q++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt16Quantum(endian,unsigned_value,p);
+                        SetGraySample(q,ScaleShortToQuantum(unsigned_value));
+                        ImportUInt16Quantum(endian,unsigned_value,p);
+                        SetOpacitySample(q,MaxRGB-ScaleShortToQuantum(unsigned_value));
+                        q++;
+                      }
+                  }
+                break;
+              }
+            case 32:
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt32Quantum(endian,unsigned_value,p);
+                        SetGraySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
+                        ImportUInt32Quantum(endian,unsigned_value,p);
+                        SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
+                        q++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt32Quantum(endian,unsigned_value,p);
+                        SetGraySample(q,ScaleLongToQuantum(unsigned_value));
+                        ImportUInt32Quantum(endian,unsigned_value,p);
+                        SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
+                        q++;
+                      }
+                  }
+                break;
+              }
+            case 64:
+              {
+                if (grayscale_miniswhite)
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt64Quantum(endian,unsigned_value,p);
+                        SetGraySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
+                        ImportUInt64Quantum(endian,unsigned_value,p);
+                        SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
+                        q++;
+                      }
+                  }
+                else
+                  {
+                    for (x = number_pixels; x != 0; --x)
+                      {
+                        ImportUInt64Quantum(endian,unsigned_value,p);
+                        SetGraySample(q,ScaleLongToQuantum(unsigned_value));
+                        ImportUInt64Quantum(endian,unsigned_value,p);
+                        SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
+                        q++;
+                      }
+                  }
+                break;
+              }
+            default:
+              {
+                /*
+                  Arbitrary Depth.
+                */
+                BitStreamReadHandle
+                  stream;
+
+                MagickBitStreamInitializeRead(&stream,p);
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    unsigned_value=MagickBitStreamMSBRead(&stream,quantum_size);
+                    if (QuantumDepth >  sample_bits)
+                      unsigned_value *= unsigned_scale;
+                    else if (QuantumDepth <  sample_bits)
+                      unsigned_value /= unsigned_scale;
+                    if (grayscale_miniswhite)
+                      unsigned_value = MaxRGB-unsigned_value;
+                    SetGraySample(q,unsigned_value);
+
+                    unsigned_value=MagickBitStreamMSBRead(&stream,quantum_size);
+                    if (QuantumDepth >  sample_bits)
+                      unsigned_value *= unsigned_scale;
+                    else if (QuantumDepth <  sample_bits)
+                      unsigned_value /= unsigned_scale;
+                    SetOpacitySample(q,MaxRGB-unsigned_value);
+                    q++;
+                  }
+                break;
+              }
+            }
+        }
       else
-       {
-         /*
-           PseudoClass representation.
-         */
-         /*
-           Input is organized as a gray level followed by opacity level
-           Colormap array is pre-stuffed with ascending or descending gray
-           levels according to the gray quantum representation.
-         */
-         register unsigned int
-           indexes_scale = 1U;
-
-         assert(image->colors <= MaxColormapSize);
-
-         if (unsigned_maxvalue > (image->colors-1))
-           indexes_scale=(unsigned_maxvalue/(image->colors-1));
-
-         if ( (quantum_size >= 8) && (quantum_size % 8U == 0U) )
-           {
-             /*
-               Modulo-8 sample sizes
-             */
-             if (indexes_scale == 1U)
-               {
-                 for (x = number_pixels; x != 0; --x)
-                   {
-                     ImportModulo8Quantum(index,quantum_size,p);
-                     VerifyColormapIndex(image,index);
-                     if (grayscale_miniswhite)
-                       index=(image->colors-1)-index;
-                     *indexes++=index;
-                     *q=image->colormap[index];
-                    
-                     ImportModulo8Quantum(unsigned_value,quantum_size,p);
-                     if (QuantumDepth >  sample_bits)
-                       unsigned_value *= unsigned_scale;
-                     else if (QuantumDepth <  sample_bits)
-                       unsigned_value /= unsigned_scale;
-                     SetOpacitySample(q,MaxRGB-unsigned_value);
-                     q++;
-                   }
-               }
-             else
-               {
-                 for (x = number_pixels; x != 0; --x)
-                   {
-                     ImportModulo8Quantum(index,quantum_size,p);
-                     index /= indexes_scale;
-                     VerifyColormapIndex(image,index);
-                     if (grayscale_miniswhite)
-                       index=(image->colors-1)-index;
-                     *indexes++=index;
-                     *q=image->colormap[index];
-                    
-                     ImportModulo8Quantum(unsigned_value,quantum_size,p);
-                     if (QuantumDepth >  sample_bits)
-                       unsigned_value *= unsigned_scale;
-                     else if (QuantumDepth <  sample_bits)
-                       unsigned_value /= unsigned_scale;
-                     SetOpacitySample(q,MaxRGB-unsigned_value);
-                     q++;
-                   }
-               }
-           }
-         else
-           {
-             /*
-               Arbitrary sample size
-             */
-             BitStreamReadHandle
-               stream;
-            
-             MagickBitStreamInitializeRead(&stream,p);
-             for (x = number_pixels; x != 0; --x)
-               {
-                 index=MagickBitStreamMSBRead(&stream,quantum_size);
-                 index /= indexes_scale;
-                 VerifyColormapIndex(image,index);
-                 if (grayscale_miniswhite)
-                   index=(image->colors-1)-index;
-                 *indexes++=index;
-                 *q=image->colormap[index];
-
-                 unsigned_value=MagickBitStreamMSBRead(&stream,quantum_size);
-                 if (QuantumDepth >  sample_bits)
-                   unsigned_value *= unsigned_scale;
-                 else if (QuantumDepth <  sample_bits)
-                   unsigned_value /= unsigned_scale;
-                 SetOpacitySample(q,MaxRGB-unsigned_value);
-                 q++;
-               }
-           }
-       }
+        {
+          /*
+            PseudoClass representation.
+          */
+          /*
+            Input is organized as a gray level followed by opacity level
+            Colormap array is pre-stuffed with ascending or descending gray
+            levels according to the gray quantum representation.
+          */
+          register unsigned int
+            indexes_scale = 1U;
+
+          assert(image->colors <= MaxColormapSize);
+
+          if ((image->storage_class != PseudoClass) ||
+              (image->colors == 0) ||
+              (indexes == (IndexPacket *) NULL))
+            ThrowBinaryException3(ImageError,ImageIsNotColormapped,
+                                  UnableToImportImagePixels);
+
+          if (unsigned_maxvalue > (image->colors-1))
+            indexes_scale=(unsigned_maxvalue/(image->colors-1));
+
+          if ( (quantum_size >= 8) && (quantum_size % 8U == 0U) )
+            {
+              /*
+                Modulo-8 sample sizes
+              */
+              if (indexes_scale == 1U)
+                {
+                  for (x = number_pixels; x != 0; --x)
+                    {
+                      ImportModulo8Quantum(index,quantum_size,p);
+                      VerifyColormapIndex(image,index);
+                      if (grayscale_miniswhite)
+                        index=(image->colors-1)-index;
+                      *indexes++=index;
+                      *q=image->colormap[index];
+
+                      ImportModulo8Quantum(unsigned_value,quantum_size,p);
+                      if (QuantumDepth >  sample_bits)
+                        unsigned_value *= unsigned_scale;
+                      else if (QuantumDepth <  sample_bits)
+                        unsigned_value /= unsigned_scale;
+                      SetOpacitySample(q,MaxRGB-unsigned_value);
+                      q++;
+                    }
+                }
+              else
+                {
+                  for (x = number_pixels; x != 0; --x)
+                    {
+                      ImportModulo8Quantum(index,quantum_size,p);
+                      index /= indexes_scale;
+                      VerifyColormapIndex(image,index);
+                      if (grayscale_miniswhite)
+                        index=(image->colors-1)-index;
+                      *indexes++=index;
+                      *q=image->colormap[index];
+
+                      ImportModulo8Quantum(unsigned_value,quantum_size,p);
+                      if (QuantumDepth >  sample_bits)
+                        unsigned_value *= unsigned_scale;
+                      else if (QuantumDepth <  sample_bits)
+                        unsigned_value /= unsigned_scale;
+                      SetOpacitySample(q,MaxRGB-unsigned_value);
+                      q++;
+                    }
+                }
+            }
+          else
+            {
+              /*
+                Arbitrary sample size
+              */
+              BitStreamReadHandle
+                stream;
+
+              MagickBitStreamInitializeRead(&stream,p);
+              for (x = number_pixels; x != 0; --x)
+                {
+                  index=MagickBitStreamMSBRead(&stream,quantum_size);
+                  index /= indexes_scale;
+                  VerifyColormapIndex(image,index);
+                  if (grayscale_miniswhite)
+                    index=(image->colors-1)-index;
+                  *indexes++=index;
+                  *q=image->colormap[index];
+
+                  unsigned_value=MagickBitStreamMSBRead(&stream,quantum_size);
+                  if (QuantumDepth >  sample_bits)
+                    unsigned_value *= unsigned_scale;
+                  else if (QuantumDepth <  sample_bits)
+                    unsigned_value /= unsigned_scale;
+                  SetOpacitySample(q,MaxRGB-unsigned_value);
+                  q++;
+                }
+            }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGraySample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGraySample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGraySample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGraySample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGraySample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGraySample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGraySample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGraySample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   if (import_info)
@@ -1370,15 +1396,15 @@ ImportGrayAlphaQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportRedQuantumType(const unsigned char *source,
-                    PixelPacket* restrict q,
-                    const unsigned long number_pixels,
-                    const unsigned int quantum_size,
-                    const QuantumSampleType sample_type,
-                    const unsigned int unsigned_scale,
-                    const double double_minvalue,
-                    const double double_scale,
-                    const EndianType endian,
-                    ImportPixelAreaInfo *import_info)
+                     PixelPacket* restrict q,
+                     const unsigned long number_pixels,
+                     const unsigned int quantum_size,
+                     const QuantumSampleType sample_type,
+                     const unsigned int unsigned_scale,
+                     const double double_minvalue,
+                     const double double_scale,
+                     const EndianType endian,
+                     ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -1389,7 +1415,7 @@ ImportRedQuantumType(const unsigned char *source,
   double
     double_value;
 
-  register unsigned int
+  register magick_uint32_t
     unsigned_value;
 
   unsigned int
@@ -1401,132 +1427,132 @@ ImportRedQuantumType(const unsigned char *source,
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               SetRedSample(q,ScaleCharToQuantum(*p++));
-               q++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetRedSample(q,ScaleShortToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetRedSample(q,ScaleLongToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetRedSample(q,ScaleLongToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamReadHandle
-             stream;
-                  
-           MagickBitStreamInitializeRead(&stream,p);
-           if (QuantumDepth >=  sample_bits)
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetRedSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   q++;
-                 }
-             }
-           else
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetRedSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   q++;
-                 }
-             }
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                SetRedSample(q,ScaleCharToQuantum(*p++));
+                q++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetRedSample(q,ScaleShortToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetRedSample(q,ScaleLongToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetRedSample(q,ScaleLongToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamReadHandle
+              stream;
+
+            MagickBitStreamInitializeRead(&stream,p);
+            if (QuantumDepth >=  sample_bits)
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetRedSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    q++;
+                  }
+              }
+            else
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetRedSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    q++;
+                  }
+              }
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetRedSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetRedSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetRedSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetRedSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetRedSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetRedSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetRedSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetRedSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   if (import_info)
@@ -1539,15 +1565,15 @@ ImportRedQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportGreenQuantumType(const unsigned char *source,
-                      PixelPacket* restrict q,
-                      const unsigned long number_pixels,
-                      const unsigned int quantum_size,
-                      const QuantumSampleType sample_type,
-                      const unsigned int unsigned_scale,
-                      const double double_minvalue,
-                      const double double_scale,
-                      const EndianType endian,
-                      ImportPixelAreaInfo *import_info)
+                       PixelPacket* restrict q,
+                       const unsigned long number_pixels,
+                       const unsigned int quantum_size,
+                       const QuantumSampleType sample_type,
+                       const unsigned int unsigned_scale,
+                       const double double_minvalue,
+                       const double double_scale,
+                       const EndianType endian,
+                       ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -1558,7 +1584,7 @@ ImportGreenQuantumType(const unsigned char *source,
   double
     double_value;
 
-  register unsigned int
+  register magick_uint32_t
     unsigned_value;
 
   unsigned int
@@ -1570,132 +1596,132 @@ ImportGreenQuantumType(const unsigned char *source,
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               SetGreenSample(q,ScaleCharToQuantum(*p++));
-               q++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetGreenSample(q,ScaleShortToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetGreenSample(q,ScaleLongToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetGreenSample(q,ScaleLongToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamReadHandle
-             stream;
-                  
-           MagickBitStreamInitializeRead(&stream,p);
-           if (QuantumDepth >=  sample_bits)
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetGreenSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   q++;
-                 }
-             }
-           else
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetGreenSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   q++;
-                 }
-             }
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                SetGreenSample(q,ScaleCharToQuantum(*p++));
+                q++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetGreenSample(q,ScaleShortToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetGreenSample(q,ScaleLongToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetGreenSample(q,ScaleLongToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamReadHandle
+              stream;
+
+            MagickBitStreamInitializeRead(&stream,p);
+            if (QuantumDepth >=  sample_bits)
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetGreenSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    q++;
+                  }
+              }
+            else
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetGreenSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    q++;
+                  }
+              }
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGreenSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGreenSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGreenSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGreenSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGreenSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGreenSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGreenSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGreenSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   if (import_info)
@@ -1708,15 +1734,15 @@ ImportGreenQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportBlueQuantumType(const unsigned char *source,
-                     PixelPacket* restrict q,
-                     const unsigned long number_pixels,
-                     const unsigned int quantum_size,
-                     const QuantumSampleType sample_type,
-                     const unsigned int unsigned_scale,
-                     const double double_minvalue,
-                     const double double_scale,
-                     const EndianType endian,
-                     ImportPixelAreaInfo *import_info)
+                      PixelPacket* restrict q,
+                      const unsigned long number_pixels,
+                      const unsigned int quantum_size,
+                      const QuantumSampleType sample_type,
+                      const unsigned int unsigned_scale,
+                      const double double_minvalue,
+                      const double double_scale,
+                      const EndianType endian,
+                      ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -1727,7 +1753,7 @@ ImportBlueQuantumType(const unsigned char *source,
   double
     double_value;
 
-  register unsigned int
+  register magick_uint32_t
     unsigned_value;
 
   unsigned int
@@ -1739,133 +1765,133 @@ ImportBlueQuantumType(const unsigned char *source,
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               SetBlueSample(q,ScaleCharToQuantum(*p++));
-               q++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetBlueSample(q,ScaleShortToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetBlueSample(q,ScaleLongToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetBlueSample(q,ScaleLongToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamReadHandle
-             stream;
-                  
-           MagickBitStreamInitializeRead(&stream,p);
-           if (QuantumDepth >=  sample_bits)
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetBlueSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   q++;
-                 }
-             }
-           else
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetBlueSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   q++;
-                 }
-             }
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                SetBlueSample(q,ScaleCharToQuantum(*p++));
+                q++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetBlueSample(q,ScaleShortToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetBlueSample(q,ScaleLongToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetBlueSample(q,ScaleLongToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamReadHandle
+              stream;
+
+            MagickBitStreamInitializeRead(&stream,p);
+            if (QuantumDepth >=  sample_bits)
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetBlueSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    q++;
+                  }
+              }
+            else
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetBlueSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    q++;
+                  }
+              }
+            break;
+          }
+        }
 
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlueSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlueSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlueSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlueSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlueSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlueSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlueSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlueSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   if (import_info)
@@ -1878,17 +1904,17 @@ ImportBlueQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportAlphaQuantumType(const unsigned char *source,
-                      PixelPacket* restrict q,
-                      IndexPacket * restrict indexes,
-                      const unsigned long number_pixels,
-                      const unsigned int quantum_size,
-                      const QuantumSampleType sample_type,
-                      const unsigned int unsigned_scale,
-                      const double double_minvalue,
-                      const double double_scale,
-                      const EndianType endian,
-                      Image *image,
-                      ImportPixelAreaInfo *import_info)
+                       PixelPacket* restrict q,
+                       IndexPacket * restrict indexes,
+                       const unsigned long number_pixels,
+                       const unsigned int quantum_size,
+                       const QuantumSampleType sample_type,
+                       const unsigned int unsigned_scale,
+                       const double double_minvalue,
+                       const double double_scale,
+                       const EndianType endian,
+                       Image *image,
+                       ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -1899,7 +1925,7 @@ ImportAlphaQuantumType(const unsigned char *source,
   double
     double_value;
 
-  register unsigned int
+  register magick_uint32_t
     unsigned_value;
 
   unsigned int
@@ -1910,247 +1936,251 @@ ImportAlphaQuantumType(const unsigned char *source,
 
   if (image->colorspace == CMYKColorspace)
     {
+      if (indexes == (IndexPacket *) NULL)
+          ThrowBinaryException3(ImageError,CMYKAImageLacksAlphaChannel,
+                                UnableToImportImagePixels);
+
       if (sample_type == UnsignedQuantumSampleType)
-       {
-         if ( (quantum_size >= 8) && (quantum_size % 8U == 0U) )
-           {
-             /*
-               Modulo-8 sample sizes
-             */
-             if( QuantumDepth == sample_bits)
-               {
-                 /* Unity scale */
-                 for (x = number_pixels; x != 0; --x)
-                   {
-                     ImportModulo8Quantum(unsigned_value,quantum_size,p);
-                     *indexes++=(IndexPacket) MaxRGB-unsigned_value;
-                   }
-               }
-             else if (QuantumDepth >  sample_bits)
-               {
-                 /* Scale up */
-                 for (x = number_pixels; x != 0; --x)
-                   {
-                     ImportModulo8Quantum(unsigned_value,quantum_size,p);
-                     *indexes++=(IndexPacket) MaxRGB-unsigned_value*unsigned_scale;
-                   }
-               }
-             else
-               {
-                 /* Scale down */
-                 for (x = number_pixels; x != 0; --x)
-                   {
-                     ImportModulo8Quantum(unsigned_value,quantum_size,p);
-                     *indexes++=(IndexPacket) MaxRGB-unsigned_value/unsigned_scale;
-                   }
-               }
-           }
-         else
-           {
-             /*
-               Arbitrary sample size
-             */
-             BitStreamReadHandle
-               stream;
-                
-             MagickBitStreamInitializeRead(&stream,p);
-             if (QuantumDepth >=  sample_bits)
-               {
-                 /* Scale up */
-                 for (x = number_pixels; x != 0; --x)
-                   {
-                     *indexes++=(IndexPacket) MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale;
-                   }
-               }
-             else
-               {
-                 /* Scale down */
-                 for (x = number_pixels; x != 0; --x)
-                   {
-                     *indexes++=(IndexPacket) MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale;
-                   }
-               }
-           }
-       }
+        {
+          if ( (quantum_size >= 8) && (quantum_size % 8U == 0U) )
+            {
+              /*
+                Modulo-8 sample sizes
+              */
+              if( QuantumDepth == sample_bits)
+                {
+                  /* Unity scale */
+                  for (x = number_pixels; x != 0; --x)
+                    {
+                      ImportModulo8Quantum(unsigned_value,quantum_size,p);
+                      *indexes++=(IndexPacket) MaxRGB-unsigned_value;
+                    }
+                }
+              else if (QuantumDepth >  sample_bits)
+                {
+                  /* Scale up */
+                  for (x = number_pixels; x != 0; --x)
+                    {
+                      ImportModulo8Quantum(unsigned_value,quantum_size,p);
+                      *indexes++=(IndexPacket) MaxRGB-unsigned_value*unsigned_scale;
+                    }
+                }
+              else
+                {
+                  /* Scale down */
+                  for (x = number_pixels; x != 0; --x)
+                    {
+                      ImportModulo8Quantum(unsigned_value,quantum_size,p);
+                      *indexes++=(IndexPacket) MaxRGB-unsigned_value/unsigned_scale;
+                    }
+                }
+            }
+          else
+            {
+              /*
+                Arbitrary sample size
+              */
+              BitStreamReadHandle
+                stream;
+
+              MagickBitStreamInitializeRead(&stream,p);
+              if (QuantumDepth >=  sample_bits)
+                {
+                  /* Scale up */
+                  for (x = number_pixels; x != 0; --x)
+                    {
+                      *indexes++=(IndexPacket) MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale;
+                    }
+                }
+              else
+                {
+                  /* Scale down */
+                  for (x = number_pixels; x != 0; --x)
+                    {
+                      *indexes++=(IndexPacket) MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale;
+                    }
+                }
+            }
+        }
       else if (sample_type == FloatQuantumSampleType)
-       {
-         switch (quantum_size)
-           {
-           case 16:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportFloat16Quantum(endian,double_value,p);
-                   double_value -= double_minvalue;
-                   double_value *= double_scale;
-                   *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
-                 }
-               break;
-             }
-           case 24:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportFloat24Quantum(endian,double_value,p);
-                   double_value -= double_minvalue;
-                   double_value *= double_scale;
-                   *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
-                 }
-               break;
-             }
-           case 32:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportFloat32Quantum(endian,double_value,p);
-                   double_value -= double_minvalue;
-                   double_value *= double_scale;
-                   *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
-                 }
-               break;
-             }
-           case 64:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportFloat64Quantum(endian,double_value,p);
-                   double_value -= double_minvalue;
-                   double_value *= double_scale;
-                   *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
-                 }
-               break;
-             }
-           default:
-             break;
-           }
-       }
+        {
+          switch (quantum_size)
+            {
+            case 16:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportFloat16Quantum(endian,double_value,p);
+                    double_value -= double_minvalue;
+                    double_value *= double_scale;
+                    *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
+                  }
+                break;
+              }
+            case 24:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportFloat24Quantum(endian,double_value,p);
+                    double_value -= double_minvalue;
+                    double_value *= double_scale;
+                    *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
+                  }
+                break;
+              }
+            case 32:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportFloat32Quantum(endian,double_value,p);
+                    double_value -= double_minvalue;
+                    double_value *= double_scale;
+                    *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
+                  }
+                break;
+              }
+            case 64:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportFloat64Quantum(endian,double_value,p);
+                    double_value -= double_minvalue;
+                    double_value *= double_scale;
+                    *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
+                  }
+                break;
+              }
+            default:
+              break;
+            }
+        }
     }
   else
     {
       /* RGB */
       if (sample_type == UnsignedQuantumSampleType)
-       {
-         if ( (quantum_size >= 8) && (quantum_size % 8U == 0U) )
-           {
-             /*
-               Modulo-8 sample sizes
-             */
-             if(QuantumDepth == sample_bits)
-               {
-                 /* Unity scale */
-                 for (x = number_pixels; x != 0; --x)
-                   {
-                     ImportModulo8Quantum(unsigned_value,quantum_size,p);
-                     SetOpacitySample(q,MaxRGB-unsigned_value);
-                     q++;
-                   }
-               }
-             else if (QuantumDepth >  sample_bits)
-               {
-                 /* Scale up */
-                 for (x = number_pixels; x != 0; --x)
-                   {
-                     ImportModulo8Quantum(unsigned_value,quantum_size,p);
-                     SetOpacitySample(q,MaxRGB-unsigned_value*unsigned_scale);
-                     q++;
-                   }
-               }
-             else
-               {
-                 /* Scale down */
-                 for (x = number_pixels; x != 0; --x)
-                   {
-                     ImportModulo8Quantum(unsigned_value,quantum_size,p);
-                     SetOpacitySample(q,MaxRGB-unsigned_value/unsigned_scale);
-                     q++;
-                   }
-               }
-           }
-         else
-           {
-             /*
-               Arbitrary sample size
-             */
-             BitStreamReadHandle
-               stream;
-
-             MagickBitStreamInitializeRead(&stream,p);
-             if (QuantumDepth >=  sample_bits)
-               {
-                 /* Scale up */
-                 for (x = number_pixels; x != 0; --x)
-                   {
-                     SetOpacitySample(q,MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                     q++;
-                   }
-               }
-             else
-               {
-                 /* Scale down */
-                 for (x = number_pixels; x != 0; --x)
-                   {
-                     SetOpacitySample(q,MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                     q++;
-                   }
-               }
-           }
-       }
+        {
+          if ( (quantum_size >= 8) && (quantum_size % 8U == 0U) )
+            {
+              /*
+                Modulo-8 sample sizes
+              */
+              if(QuantumDepth == sample_bits)
+                {
+                  /* Unity scale */
+                  for (x = number_pixels; x != 0; --x)
+                    {
+                      ImportModulo8Quantum(unsigned_value,quantum_size,p);
+                      SetOpacitySample(q,MaxRGB-unsigned_value);
+                      q++;
+                    }
+                }
+              else if (QuantumDepth >  sample_bits)
+                {
+                  /* Scale up */
+                  for (x = number_pixels; x != 0; --x)
+                    {
+                      ImportModulo8Quantum(unsigned_value,quantum_size,p);
+                      SetOpacitySample(q,MaxRGB-unsigned_value*unsigned_scale);
+                      q++;
+                    }
+                }
+              else
+                {
+                  /* Scale down */
+                  for (x = number_pixels; x != 0; --x)
+                    {
+                      ImportModulo8Quantum(unsigned_value,quantum_size,p);
+                      SetOpacitySample(q,MaxRGB-unsigned_value/unsigned_scale);
+                      q++;
+                    }
+                }
+            }
+          else
+            {
+              /*
+                Arbitrary sample size
+              */
+              BitStreamReadHandle
+                stream;
+
+              MagickBitStreamInitializeRead(&stream,p);
+              if (QuantumDepth >=  sample_bits)
+                {
+                  /* Scale up */
+                  for (x = number_pixels; x != 0; --x)
+                    {
+                      SetOpacitySample(q,MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                      q++;
+                    }
+                }
+              else
+                {
+                  /* Scale down */
+                  for (x = number_pixels; x != 0; --x)
+                    {
+                      SetOpacitySample(q,MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                      q++;
+                    }
+                }
+            }
+        }
       else if (sample_type == FloatQuantumSampleType)
-       {
-         switch (quantum_size)
-           {
-           case 16:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportFloat16Quantum(endian,double_value,p);
-                   double_value -= double_minvalue;
-                   double_value *= double_scale;
-                   SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
-                   q++;
-                 }
-               break;
-             }
-           case 24:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportFloat24Quantum(endian,double_value,p);
-                   double_value -= double_minvalue;
-                   double_value *= double_scale;
-                   SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
-                   q++;
-                 }
-               break;
-             }
-           case 32:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportFloat32Quantum(endian,double_value,p);
-                   double_value -= double_minvalue;
-                   double_value *= double_scale;
-                   SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
-                   q++;
-                 }
-               break;
-             }
-           case 64:
-             {
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   ImportFloat64Quantum(endian,double_value,p);
-                   double_value -= double_minvalue;
-                   double_value *= double_scale;
-                   SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
-                   q++;
-                 }
-               break;
-             }
-           default:
-             break;
-           }
-       }
+        {
+          switch (quantum_size)
+            {
+            case 16:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportFloat16Quantum(endian,double_value,p);
+                    double_value -= double_minvalue;
+                    double_value *= double_scale;
+                    SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
+                    q++;
+                  }
+                break;
+              }
+            case 24:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportFloat24Quantum(endian,double_value,p);
+                    double_value -= double_minvalue;
+                    double_value *= double_scale;
+                    SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
+                    q++;
+                  }
+                break;
+              }
+            case 32:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportFloat32Quantum(endian,double_value,p);
+                    double_value -= double_minvalue;
+                    double_value *= double_scale;
+                    SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
+                    q++;
+                  }
+                break;
+              }
+            case 64:
+              {
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    ImportFloat64Quantum(endian,double_value,p);
+                    double_value -= double_minvalue;
+                    double_value *= double_scale;
+                    SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
+                    q++;
+                  }
+                break;
+              }
+            default:
+              break;
+            }
+        }
     }
 
   if (import_info)
@@ -2163,15 +2193,15 @@ ImportAlphaQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportBlackQuantumType(const unsigned char *source,
-                      PixelPacket* restrict q,
-                      const unsigned long number_pixels,
-                      const unsigned int quantum_size,
-                      const QuantumSampleType sample_type,
-                      const unsigned int unsigned_scale,
-                      const double double_minvalue,
-                      const double double_scale,
-                      const EndianType endian,
-                      ImportPixelAreaInfo *import_info)
+                       PixelPacket* restrict q,
+                       const unsigned long number_pixels,
+                       const unsigned int quantum_size,
+                       const QuantumSampleType sample_type,
+                       const unsigned int unsigned_scale,
+                       const double double_minvalue,
+                       const double double_scale,
+                       const EndianType endian,
+                       ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -2182,7 +2212,7 @@ ImportBlackQuantumType(const unsigned char *source,
   double
     double_value;
 
-  register unsigned int
+  register magick_uint32_t
     unsigned_value;
 
   unsigned int
@@ -2194,132 +2224,132 @@ ImportBlackQuantumType(const unsigned char *source,
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               SetBlackSample(q,ScaleCharToQuantum(*p++));
-               q++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetBlackSample(q,ScaleShortToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetBlackSample(q,ScaleLongToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetBlackSample(q,ScaleLongToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamReadHandle
-             stream;
-                  
-           MagickBitStreamInitializeRead(&stream,p);
-           if (QuantumDepth >=  sample_bits)
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetBlackSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   q++;
-                 }
-             }
-           else
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetBlackSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   q++;
-                 }
-             }
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                SetBlackSample(q,ScaleCharToQuantum(*p++));
+                q++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetBlackSample(q,ScaleShortToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetBlackSample(q,ScaleLongToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetBlackSample(q,ScaleLongToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamReadHandle
+              stream;
+
+            MagickBitStreamInitializeRead(&stream,p);
+            if (QuantumDepth >=  sample_bits)
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetBlackSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    q++;
+                  }
+              }
+            else
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetBlackSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    q++;
+                  }
+              }
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlackSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlackSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlackSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlackSample(q,RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlackSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlackSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlackSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlackSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   if (import_info)
@@ -2332,15 +2362,15 @@ ImportBlackQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportRGBQuantumType(const unsigned char *source,
-                    PixelPacket* restrict q,
-                    const unsigned long number_pixels,
-                    const unsigned int quantum_size,
-                    const QuantumSampleType sample_type,
-                    const unsigned int unsigned_scale,
-                    const double double_minvalue,
-                    const double double_scale,
-                    const EndianType endian,
-                    ImportPixelAreaInfo *import_info)
+                     PixelPacket* restrict q,
+                     const unsigned long number_pixels,
+                     const unsigned int quantum_size,
+                     const QuantumSampleType sample_type,
+                     const unsigned int unsigned_scale,
+                     const double double_minvalue,
+                     const double double_scale,
+                     const EndianType endian,
+                     ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -2351,7 +2381,7 @@ ImportRGBQuantumType(const unsigned char *source,
   double
     double_value;
 
-  register unsigned int
+  register magick_uint32_t
     unsigned_value;
 
   unsigned int
@@ -2363,195 +2393,195 @@ ImportRGBQuantumType(const unsigned char *source,
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt8Quantum(unsigned_value,p);
-               SetRedSample(q,ScaleCharToQuantum(unsigned_value));
-               ImportUInt8Quantum(unsigned_value,p);
-               SetGreenSample(q,ScaleCharToQuantum(unsigned_value));
-               ImportUInt8Quantum(unsigned_value,p);
-               SetBlueSample(q,ScaleCharToQuantum(unsigned_value));
-               SetOpacitySample(q,OpaqueOpacity);
-               q++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetRedSample(q,ScaleShortToQuantum(unsigned_value));
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetGreenSample(q,ScaleShortToQuantum(unsigned_value));
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetBlueSample(q,ScaleShortToQuantum(unsigned_value));
-               SetOpacitySample(q,OpaqueOpacity);
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetRedSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetGreenSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetBlueSample(q,ScaleLongToQuantum(unsigned_value));
-               SetOpacitySample(q,OpaqueOpacity);
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetRedSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetGreenSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetBlueSample(q,ScaleLongToQuantum(unsigned_value));
-               SetOpacitySample(q,OpaqueOpacity);
-               q++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamReadHandle
-             stream;
-                  
-           MagickBitStreamInitializeRead(&stream,p);
-           if (QuantumDepth >=  sample_bits)
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetRedSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   SetGreenSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   SetBlueSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   SetOpacitySample(q,OpaqueOpacity);
-                   q++;
-                 }
-             }
-           else if (QuantumDepth <  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetRedSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   SetGreenSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   SetBlueSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   SetOpacitySample(q,OpaqueOpacity);
-                   q++;
-                 }
-             }
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt8Quantum(unsigned_value,p);
+                SetRedSample(q,ScaleCharToQuantum(unsigned_value));
+                ImportUInt8Quantum(unsigned_value,p);
+                SetGreenSample(q,ScaleCharToQuantum(unsigned_value));
+                ImportUInt8Quantum(unsigned_value,p);
+                SetBlueSample(q,ScaleCharToQuantum(unsigned_value));
+                SetOpacitySample(q,OpaqueOpacity);
+                q++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetRedSample(q,ScaleShortToQuantum(unsigned_value));
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetGreenSample(q,ScaleShortToQuantum(unsigned_value));
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetBlueSample(q,ScaleShortToQuantum(unsigned_value));
+                SetOpacitySample(q,OpaqueOpacity);
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetRedSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetGreenSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetBlueSample(q,ScaleLongToQuantum(unsigned_value));
+                SetOpacitySample(q,OpaqueOpacity);
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetRedSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetGreenSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetBlueSample(q,ScaleLongToQuantum(unsigned_value));
+                SetOpacitySample(q,OpaqueOpacity);
+                q++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamReadHandle
+              stream;
+
+            MagickBitStreamInitializeRead(&stream,p);
+            if (QuantumDepth >=  sample_bits)
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetRedSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    SetGreenSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    SetBlueSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    SetOpacitySample(q,OpaqueOpacity);
+                    q++;
+                  }
+              }
+            else if (QuantumDepth <  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetRedSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    SetGreenSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    SetBlueSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    SetOpacitySample(q,OpaqueOpacity);
+                    q++;
+                  }
+              }
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetRedSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGreenSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlueSample(q,RoundDoubleToQuantum(double_value));
-               SetOpacitySample(q,OpaqueOpacity);
-               q++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetRedSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGreenSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlueSample(q,RoundDoubleToQuantum(double_value));
-               SetOpacitySample(q,OpaqueOpacity);
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetRedSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGreenSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlueSample(q,RoundDoubleToQuantum(double_value));
-               SetOpacitySample(q,OpaqueOpacity);
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetRedSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGreenSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlueSample(q,RoundDoubleToQuantum(double_value));
-               SetOpacitySample(q,OpaqueOpacity);
-               q++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetRedSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGreenSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlueSample(q,RoundDoubleToQuantum(double_value));
+                SetOpacitySample(q,OpaqueOpacity);
+                q++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetRedSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGreenSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlueSample(q,RoundDoubleToQuantum(double_value));
+                SetOpacitySample(q,OpaqueOpacity);
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetRedSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGreenSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlueSample(q,RoundDoubleToQuantum(double_value));
+                SetOpacitySample(q,OpaqueOpacity);
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetRedSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGreenSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlueSample(q,RoundDoubleToQuantum(double_value));
+                SetOpacitySample(q,OpaqueOpacity);
+                q++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   if (import_info)
@@ -2564,15 +2594,15 @@ ImportRGBQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportRGBAQuantumType(const unsigned char *source,
-                     PixelPacket* restrict q,
-                     const unsigned long number_pixels,
-                     const unsigned int quantum_size,
-                     const QuantumSampleType sample_type,
-                     const unsigned int unsigned_scale,
-                     const double double_minvalue,
-                     const double double_scale,
-                     const EndianType endian,
-                     ImportPixelAreaInfo *import_info)
+                      PixelPacket* restrict q,
+                      const unsigned long number_pixels,
+                      const unsigned int quantum_size,
+                      const QuantumSampleType sample_type,
+                      const unsigned int unsigned_scale,
+                      const double double_minvalue,
+                      const double double_scale,
+                      const EndianType endian,
+                      ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -2583,7 +2613,7 @@ ImportRGBAQuantumType(const unsigned char *source,
   double
     double_value;
 
-  register unsigned int
+  register magick_uint32_t
     unsigned_value;
 
   unsigned int
@@ -2595,207 +2625,207 @@ ImportRGBAQuantumType(const unsigned char *source,
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               SetRedSample(q,ScaleCharToQuantum(*p++));
-               SetGreenSample(q,ScaleCharToQuantum(*p++));
-               SetBlueSample(q,ScaleCharToQuantum(*p++));
-               SetOpacitySample(q,MaxRGB-ScaleCharToQuantum(*p++));
-               q++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetRedSample(q,ScaleShortToQuantum(unsigned_value));
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetGreenSample(q,ScaleShortToQuantum(unsigned_value));
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetBlueSample(q,ScaleShortToQuantum(unsigned_value));
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetOpacitySample(q,MaxRGB-ScaleShortToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetRedSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetGreenSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetBlueSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetRedSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetGreenSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetBlueSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
-               q++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamReadHandle
-             stream;
-                  
-           MagickBitStreamInitializeRead(&stream,p);
-           if (QuantumDepth >=  sample_bits)
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetRedSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   SetGreenSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   SetBlueSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   SetOpacitySample(q,MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   q++;
-                 }
-             }
-           else if (QuantumDepth <  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetRedSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   SetGreenSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   SetBlueSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   SetOpacitySample(q,MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   q++;
-                 }
-             }
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                SetRedSample(q,ScaleCharToQuantum(*p++));
+                SetGreenSample(q,ScaleCharToQuantum(*p++));
+                SetBlueSample(q,ScaleCharToQuantum(*p++));
+                SetOpacitySample(q,MaxRGB-ScaleCharToQuantum(*p++));
+                q++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetRedSample(q,ScaleShortToQuantum(unsigned_value));
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetGreenSample(q,ScaleShortToQuantum(unsigned_value));
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetBlueSample(q,ScaleShortToQuantum(unsigned_value));
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetOpacitySample(q,MaxRGB-ScaleShortToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetRedSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetGreenSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetBlueSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetRedSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetGreenSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetBlueSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetOpacitySample(q,MaxRGB-ScaleLongToQuantum(unsigned_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamReadHandle
+              stream;
+
+            MagickBitStreamInitializeRead(&stream,p);
+            if (QuantumDepth >=  sample_bits)
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetRedSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    SetGreenSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    SetBlueSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    SetOpacitySample(q,MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    q++;
+                  }
+              }
+            else if (QuantumDepth <  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetRedSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    SetGreenSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    SetBlueSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    SetOpacitySample(q,MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    q++;
+                  }
+              }
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetRedSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGreenSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlueSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetRedSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGreenSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlueSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetRedSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGreenSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlueSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetRedSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetGreenSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlueSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
-               q++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetRedSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGreenSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlueSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetRedSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGreenSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlueSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetRedSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGreenSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlueSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetRedSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetGreenSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlueSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetOpacitySample(q,MaxRGB-RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   if (import_info)
@@ -2808,16 +2838,15 @@ ImportRGBAQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportCMYKQuantumType(const unsigned char *source,
-                     PixelPacket* restrict q,
-                     IndexPacket * restrict indexes,
-                     const unsigned long number_pixels,
-                     const unsigned int quantum_size,
-                     const QuantumSampleType sample_type,
-                     const unsigned int unsigned_scale,
-                     const double double_minvalue,
-                     const double double_scale,
-                     const EndianType endian,
-                     ImportPixelAreaInfo *import_info)
+                      PixelPacket* restrict q,
+                      const unsigned long number_pixels,
+                      const unsigned int quantum_size,
+                      const QuantumSampleType sample_type,
+                      const unsigned int unsigned_scale,
+                      const double double_minvalue,
+                      const double double_scale,
+                      const EndianType endian,
+                      ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -2828,7 +2857,7 @@ ImportCMYKQuantumType(const unsigned char *source,
   double
     double_value;
 
-  register unsigned int
+  register magick_uint32_t
     unsigned_value;
 
   unsigned int
@@ -2840,213 +2869,207 @@ ImportCMYKQuantumType(const unsigned char *source,
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               SetCyanSample(q,ScaleCharToQuantum(*p++));
-               SetMagentaSample(q,ScaleCharToQuantum(*p++));
-               SetYellowSample(q,ScaleCharToQuantum(*p++));
-               SetBlackSample(q,ScaleCharToQuantum(*p++));
-               q++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetCyanSample(q,ScaleShortToQuantum(unsigned_value));
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetMagentaSample(q,ScaleShortToQuantum(unsigned_value));
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetYellowSample(q,ScaleShortToQuantum(unsigned_value));
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetBlackSample(q,unsigned_value);
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetCyanSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetMagentaSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetYellowSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetBlackSample(q,unsigned_value);
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetCyanSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetMagentaSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetYellowSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetBlackSample(q,unsigned_value);
-               q++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamReadHandle
-             stream;
-                  
-           MagickBitStreamInitializeRead(&stream,p);
-           if (QuantumDepth >=  sample_bits)
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetCyanSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   SetMagentaSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   SetYellowSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   SetBlackSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   *indexes++=OpaqueOpacity;
-                   q++;
-                 }
-             }
-           else if (QuantumDepth <  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetCyanSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   SetMagentaSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   SetYellowSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   SetBlackSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   *indexes++=OpaqueOpacity;
-                   q++;
-                 }
-             }
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                SetCyanSample(q,ScaleCharToQuantum(*p++));
+                SetMagentaSample(q,ScaleCharToQuantum(*p++));
+                SetYellowSample(q,ScaleCharToQuantum(*p++));
+                SetBlackSample(q,ScaleCharToQuantum(*p++));
+                q++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetCyanSample(q,ScaleShortToQuantum(unsigned_value));
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetMagentaSample(q,ScaleShortToQuantum(unsigned_value));
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetYellowSample(q,ScaleShortToQuantum(unsigned_value));
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetBlackSample(q,unsigned_value);
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetCyanSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetMagentaSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetYellowSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetBlackSample(q,unsigned_value);
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetCyanSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetMagentaSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetYellowSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetBlackSample(q,unsigned_value);
+                q++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamReadHandle
+              stream;
+
+            MagickBitStreamInitializeRead(&stream,p);
+            if (QuantumDepth >=  sample_bits)
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetCyanSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    SetMagentaSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    SetYellowSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    SetBlackSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    q++;
+                  }
+              }
+            else if (QuantumDepth <  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetCyanSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    SetMagentaSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    SetYellowSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    SetBlackSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    q++;
+                  }
+              }
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetCyanSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetMagentaSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetYellowSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlackSample(q,RoundDoubleToQuantum(double_value));
-               *indexes++=OpaqueOpacity;
-               q++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetCyanSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetMagentaSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetYellowSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlackSample(q,RoundDoubleToQuantum(double_value));
-               *indexes++=OpaqueOpacity;
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetCyanSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetMagentaSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetYellowSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlackSample(q,RoundDoubleToQuantum(double_value));
-               *indexes++=OpaqueOpacity;
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetCyanSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetMagentaSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetYellowSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlackSample(q,RoundDoubleToQuantum(double_value));
-               *indexes++=OpaqueOpacity;
-               q++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetCyanSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetMagentaSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetYellowSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlackSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetCyanSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetMagentaSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetYellowSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlackSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetCyanSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetMagentaSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetYellowSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlackSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetCyanSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetMagentaSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetYellowSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlackSample(q,RoundDoubleToQuantum(double_value));
+                q++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   if (import_info)
@@ -3059,16 +3082,17 @@ ImportCMYKQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportCMYKAQuantumType(const unsigned char *source,
-                      PixelPacket* restrict q,
-                      IndexPacket * restrict indexes,
-                      const unsigned long number_pixels,
-                      const unsigned int quantum_size,
-                      const QuantumSampleType sample_type,
-                      const unsigned int unsigned_scale,
-                      const double double_minvalue,
-                      const double double_scale,
-                      const EndianType endian,
-                      ImportPixelAreaInfo *import_info)
+                       PixelPacket* restrict q,
+                       IndexPacket * restrict indexes,
+                       const unsigned long number_pixels,
+                       const unsigned int quantum_size,
+                       const QuantumSampleType sample_type,
+                       const unsigned int unsigned_scale,
+                       const double double_minvalue,
+                       const double double_scale,
+                       const EndianType endian,
+                       Image *image,
+                       ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -3079,7 +3103,7 @@ ImportCMYKAQuantumType(const unsigned char *source,
   double
     double_value;
 
-  register unsigned int
+  register magick_uint32_t
     unsigned_value;
 
   unsigned int
@@ -3088,235 +3112,239 @@ ImportCMYKAQuantumType(const unsigned char *source,
   sample_bits=quantum_size;
   p=source;
 
+  if (indexes == (IndexPacket *) NULL)
+    ThrowBinaryException3(ImageError,CMYKAImageLacksAlphaChannel,
+                          UnableToImportImagePixels);
+
   if (sample_type == UnsignedQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 8:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               SetCyanSample(q,ScaleCharToQuantum(*p++));
-               SetMagentaSample(q,ScaleCharToQuantum(*p++));
-               SetYellowSample(q,ScaleCharToQuantum(*p++));
-               SetBlackSample(q,ScaleCharToQuantum(*p++));
-               *indexes++=(IndexPacket) MaxRGB-ScaleCharToQuantum(*p++);
-               q++;
-             }
-           break;
-         }
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetCyanSample(q,ScaleShortToQuantum(unsigned_value));
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetMagentaSample(q,ScaleShortToQuantum(unsigned_value));
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetYellowSample(q,ScaleShortToQuantum(unsigned_value));
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               SetBlackSample(q,ScaleShortToQuantum(unsigned_value));
-               ImportUInt16Quantum(endian,unsigned_value,p);
-               *indexes++=(IndexPacket) MaxRGB-ScaleShortToQuantum(unsigned_value);
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetCyanSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetMagentaSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetYellowSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               SetBlackSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt32Quantum(endian,unsigned_value,p);
-               *indexes++=(IndexPacket) MaxRGB-ScaleLongToQuantum(unsigned_value);
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetCyanSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetMagentaSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetYellowSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               SetBlackSample(q,ScaleLongToQuantum(unsigned_value));
-               ImportUInt64Quantum(endian,unsigned_value,p);
-               *indexes++=(IndexPacket) MaxRGB-ScaleLongToQuantum(unsigned_value);
-               q++;
-             }
-           break;
-         }
-       default:
-         {
-           /*
-             Arbitrary sample size
-           */
-           BitStreamReadHandle
-             stream;
-                  
-           MagickBitStreamInitializeRead(&stream,p);
-           if (QuantumDepth >=  sample_bits)
-             {
-               /* Scale up */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetCyanSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   SetMagentaSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   SetYellowSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   SetBlackSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
-                   *indexes++=(IndexPacket) MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale;
-                   q++;
-                 }
-             }
-           else if (QuantumDepth <  sample_bits)
-             {
-               /* Scale down */
-               for (x = number_pixels; x != 0; --x)
-                 {
-                   SetCyanSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   SetMagentaSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   SetYellowSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   SetBlackSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
-                   *indexes++=(IndexPacket) MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale;
-                   q++;
-                 }
-             }
-           break;
-         }
-       }
+        {
+        case 8:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                SetCyanSample(q,ScaleCharToQuantum(*p++));
+                SetMagentaSample(q,ScaleCharToQuantum(*p++));
+                SetYellowSample(q,ScaleCharToQuantum(*p++));
+                SetBlackSample(q,ScaleCharToQuantum(*p++));
+                *indexes++=(IndexPacket) MaxRGB-ScaleCharToQuantum(*p++);
+                q++;
+              }
+            break;
+          }
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetCyanSample(q,ScaleShortToQuantum(unsigned_value));
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetMagentaSample(q,ScaleShortToQuantum(unsigned_value));
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetYellowSample(q,ScaleShortToQuantum(unsigned_value));
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                SetBlackSample(q,ScaleShortToQuantum(unsigned_value));
+                ImportUInt16Quantum(endian,unsigned_value,p);
+                *indexes++=(IndexPacket) MaxRGB-ScaleShortToQuantum(unsigned_value);
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetCyanSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetMagentaSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetYellowSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                SetBlackSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt32Quantum(endian,unsigned_value,p);
+                *indexes++=(IndexPacket) MaxRGB-ScaleLongToQuantum(unsigned_value);
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetCyanSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetMagentaSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetYellowSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                SetBlackSample(q,ScaleLongToQuantum(unsigned_value));
+                ImportUInt64Quantum(endian,unsigned_value,p);
+                *indexes++=(IndexPacket) MaxRGB-ScaleLongToQuantum(unsigned_value);
+                q++;
+              }
+            break;
+          }
+        default:
+          {
+            /*
+              Arbitrary sample size
+            */
+            BitStreamReadHandle
+              stream;
+
+            MagickBitStreamInitializeRead(&stream,p);
+            if (QuantumDepth >=  sample_bits)
+              {
+                /* Scale up */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetCyanSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    SetMagentaSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    SetYellowSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    SetBlackSample(q,MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale);
+                    *indexes++=(IndexPacket) MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)*unsigned_scale;
+                    q++;
+                  }
+              }
+            else if (QuantumDepth <  sample_bits)
+              {
+                /* Scale down */
+                for (x = number_pixels; x != 0; --x)
+                  {
+                    SetCyanSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    SetMagentaSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    SetYellowSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    SetBlackSample(q,MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale);
+                    *indexes++=(IndexPacket) MaxRGB-MagickBitStreamMSBRead(&stream,quantum_size)/unsigned_scale;
+                    q++;
+                  }
+              }
+            break;
+          }
+        }
     }
   else if (sample_type == FloatQuantumSampleType)
     {
       switch (quantum_size)
-       {
-       case 16:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetCyanSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetMagentaSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetYellowSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlackSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat16Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
-               q++;
-             }
-           break;
-         }
-       case 24:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetCyanSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetMagentaSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetYellowSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlackSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat24Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
-               q++;
-             }
-           break;
-         }
-       case 32:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetCyanSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetMagentaSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetYellowSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlackSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat32Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
-               q++;
-             }
-           break;
-         }
-       case 64:
-         {
-           for (x = number_pixels; x != 0; --x)
-             {
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetCyanSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetMagentaSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetYellowSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               SetBlackSample(q,RoundDoubleToQuantum(double_value));
-               ImportFloat64Quantum(endian,double_value,p);
-               double_value -= double_minvalue;
-               double_value *= double_scale;
-               *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
-               q++;
-             }
-           break;
-         }
-       default:
-         break;
-       }
+        {
+        case 16:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetCyanSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetMagentaSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetYellowSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlackSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat16Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
+                q++;
+              }
+            break;
+          }
+        case 24:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetCyanSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetMagentaSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetYellowSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlackSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat24Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
+                q++;
+              }
+            break;
+          }
+        case 32:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetCyanSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetMagentaSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetYellowSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlackSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat32Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
+                q++;
+              }
+            break;
+          }
+        case 64:
+          {
+            for (x = number_pixels; x != 0; --x)
+              {
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetCyanSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetMagentaSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetYellowSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                SetBlackSample(q,RoundDoubleToQuantum(double_value));
+                ImportFloat64Quantum(endian,double_value,p);
+                double_value -= double_minvalue;
+                double_value *= double_scale;
+                *indexes++=(IndexPacket) MaxRGB-RoundDoubleToQuantum(double_value);
+                q++;
+              }
+            break;
+          }
+        default:
+          break;
+        }
     }
 
   if (import_info)
@@ -3329,12 +3357,12 @@ ImportCMYKAQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportCIEXYZQuantumType(const unsigned char *source,
-                       PixelPacket* restrict q,
-                       const unsigned long number_pixels,
-                       const unsigned int quantum_size,
-                       const QuantumSampleType sample_type,
-                       const EndianType endian,
-                       ImportPixelAreaInfo *import_info)
+                        PixelPacket* restrict q,
+                        const unsigned long number_pixels,
+                        const unsigned int quantum_size,
+                        const QuantumSampleType sample_type,
+                        const EndianType endian,
+                        ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -3347,49 +3375,49 @@ ImportCIEXYZQuantumType(const unsigned char *source,
   if (sample_type == FloatQuantumSampleType)
     {
       double
-       red,
-       green,
-       blue,
-       x_sample,
-       y_sample,
-       z_sample;
+        red,
+        green,
+        blue,
+        x_sample,
+        y_sample,
+        z_sample;
 
       for (x = number_pixels; x != 0; --x)
-       {
-         switch (quantum_size)
-           {
-           default:
-           case 32:
-             {
-               ImportFloat32Quantum(endian,x_sample,p);
-               ImportFloat32Quantum(endian,y_sample,p);
-               ImportFloat32Quantum(endian,z_sample,p);
-               break;
-             }
-           case 64:
-             {
-               ImportFloat64Quantum(endian,x_sample,p);
-               ImportFloat64Quantum(endian,y_sample,p);
-               ImportFloat64Quantum(endian,z_sample,p);
-               break;
-             }
-           }
-
-         /* Assume CCIR-709 primaries */
-         red   = 2.690*x_sample  + -1.276*y_sample + -0.414*z_sample;
-         green = -1.022*x_sample +  1.978*y_sample +  0.044*z_sample;
-         blue  = 0.061*x_sample  + -0.224*y_sample +  1.163*z_sample;
-
-         /* assume 2.0 gamma for speed */
-         SetRedSample(q,(Quantum) ((red <= 0.0) ? 0.0 : (red >= 1.0) ? MaxRGB :
-                                   ((MaxRGB * sqrt(red))+0.5)));
-         SetGreenSample(q,(Quantum) ((green <= 0.0) ? 0.0 : (green >= 1.0) ? MaxRGB :
-                                     ((MaxRGB * sqrt(green))+0.5)));
-         SetBlueSample(q,(Quantum) ((blue <= 0.0) ? 0.0 : (blue >= 1.0) ? MaxRGB :
-                                    ((MaxRGB * sqrt(blue))+0.5)));
-         SetOpacitySample(q,OpaqueOpacity);
-         q++;
-       }
+        {
+          switch (quantum_size)
+            {
+            default:
+            case 32:
+              {
+                ImportFloat32Quantum(endian,x_sample,p);
+                ImportFloat32Quantum(endian,y_sample,p);
+                ImportFloat32Quantum(endian,z_sample,p);
+                break;
+              }
+            case 64:
+              {
+                ImportFloat64Quantum(endian,x_sample,p);
+                ImportFloat64Quantum(endian,y_sample,p);
+                ImportFloat64Quantum(endian,z_sample,p);
+                break;
+              }
+            }
+
+          /* Assume CCIR-709 primaries */
+          red   = 2.690*x_sample  + -1.276*y_sample + -0.414*z_sample;
+          green = -1.022*x_sample +  1.978*y_sample +  0.044*z_sample;
+          blue  = 0.061*x_sample  + -0.224*y_sample +  1.163*z_sample;
+
+          /* assume 2.0 gamma for speed */
+          SetRedSample(q,(Quantum) ((red <= 0.0) ? 0.0 : (red >= 1.0) ? MaxRGB :
+                                    ((MaxRGB * sqrt(red))+0.5)));
+          SetGreenSample(q,(Quantum) ((green <= 0.0) ? 0.0 : (green >= 1.0) ? MaxRGB :
+                                      ((MaxRGB * sqrt(green))+0.5)));
+          SetBlueSample(q,(Quantum) ((blue <= 0.0) ? 0.0 : (blue >= 1.0) ? MaxRGB :
+                                     ((MaxRGB * sqrt(blue))+0.5)));
+          SetOpacitySample(q,OpaqueOpacity);
+          q++;
+        }
     }
 
   if (import_info)
@@ -3402,12 +3430,12 @@ ImportCIEXYZQuantumType(const unsigned char *source,
 
 static MagickPassFail
 ImportCIEYQuantumType(const unsigned char *source,
-                     PixelPacket* restrict q,
-                     const unsigned long number_pixels,
-                     const unsigned int quantum_size,
-                     const QuantumSampleType sample_type,
-                     const EndianType endian,
-                     ImportPixelAreaInfo *import_info)
+                      PixelPacket* restrict q,
+                      const unsigned long number_pixels,
+                      const unsigned int quantum_size,
+                      const QuantumSampleType sample_type,
+                      const EndianType endian,
+                      ImportPixelAreaInfo *import_info)
 {
   const unsigned char * restrict
     p;
@@ -3423,27 +3451,27 @@ ImportCIEYQuantumType(const unsigned char *source,
   if (sample_type == FloatQuantumSampleType)
     {
       for (x = number_pixels; x != 0; --x)
-       {
-         switch (quantum_size)
-           {
-           default:
-           case 32:
-             {
-               ImportFloat32Quantum(endian,double_value,p);
-               break;
-             }
-           case 64:
-             {
-               ImportFloat64Quantum(endian,double_value,p);
-               break;
-             }
-           }
-         /* assume 2.0 gamma for speed */
-         SetGraySample(q,(Quantum) ((double_value <= 0.0) ? 0.0 :
-                                    (double_value >= 1.0) ? MaxRGB :
-                                    ((MaxRGB * sqrt(double_value))+0.5)));
-         q++;
-       }
+        {
+          switch (quantum_size)
+            {
+            default:
+            case 32:
+              {
+                ImportFloat32Quantum(endian,double_value,p);
+                break;
+              }
+            case 64:
+              {
+                ImportFloat64Quantum(endian,double_value,p);
+                break;
+              }
+            }
+          /* assume 2.0 gamma for speed */
+          SetGraySample(q,(Quantum) ((double_value <= 0.0) ? 0.0 :
+                                     (double_value >= 1.0) ? MaxRGB :
+                                     ((MaxRGB * sqrt(double_value))+0.5)));
+          q++;
+        }
     }
 
   if (import_info)
@@ -3456,11 +3484,11 @@ ImportCIEYQuantumType(const unsigned char *source,
 
 MagickExport MagickPassFail
 ImportViewPixelArea(ViewInfo *view,
-                   const QuantumType quantum_type,
-                   const unsigned int quantum_size,
-                   const unsigned char *source,
-                   const ImportPixelAreaOptions *options,
-                   ImportPixelAreaInfo *import_info)
+                    const QuantumType quantum_type,
+                    const unsigned int quantum_size,
+                    const unsigned char *source,
+                    const ImportPixelAreaOptions *options,
+                    ImportPixelAreaInfo *import_info)
 {
   Image
     *image;
@@ -3503,17 +3531,6 @@ ImportViewPixelArea(ViewInfo *view,
   assert((options == (const ImportPixelAreaOptions *) NULL) ||
          (options->signature == MagickSignature));
 
-  if ((quantum_size == 0U) ||
-      ((quantum_size > 32U) && (quantum_size != 64U)))
-    {
-      char quantum_size_str[MaxTextExtent];
-      FormatString(quantum_size_str,"%u",quantum_size);
-      status=0;
-      ThrowException(&GetCacheViewImage(view)->exception,CoderError,
-                     UnsupportedBitsPerSample,quantum_size_str);
-      return MagickFail;
-    }
-
   /*
     Transfer any special options.
   */
@@ -3548,20 +3565,49 @@ ImportViewPixelArea(ViewInfo *view,
             break;
           }
         }
-    } 
+    }
 
   if (import_info)
     {
       import_info->bytes_imported=0;
     }
 
+  if (!(((sample_type == FloatQuantumSampleType) &&
+         ((quantum_size == 16) || (quantum_size == 24) ||
+          (quantum_size == 32) || (quantum_size == 64))) ||
+        ((sample_type == UnsignedQuantumSampleType) &&
+         (((quantum_size > 0) && (quantum_size <= 32)) ||
+          (quantum_size == 64)))))
+    {
+      char quantum_size_str[MaxTextExtent];
+      FormatString(quantum_size_str,"%u",quantum_size);
+      status=0;
+      ThrowException(&GetCacheViewImage(view)->exception,CoderError,
+                     UnsupportedBitsPerSample,quantum_size_str);
+      return MagickFail;
+    }
+
+
   /* printf("quantum_type=%d  quantum_size=%u\n",(int) quantum_type, quantum_size); */
 
-  /* Maximum value which may be represented by a sample */
-  unsigned_maxvalue=MaxValueGivenBits(sample_bits);
-  double_scale=(double) MaxRGB/(double_maxvalue-double_minvalue);
+  {
+    const double scale_denominator = double_maxvalue-double_minvalue;
+    if (scale_denominator < MagickEpsilon)
+      {
+        char error_message[MaxTextExtent];
+        FormatString(error_message,"import double max/min value: max=%g, min=%g",
+                     double_maxvalue,double_minvalue);
+        ThrowException(&GetCacheViewImage(view)->exception,CoderError,
+                       DivisionByZero,error_message);
+        return MagickFail;
+      }
+    double_scale=MaxRGBDouble/(scale_denominator);
+  }
   if ((sample_type != FloatQuantumSampleType) && (sample_bits <= 32U))
     {
+      /* Maximum value which may be represented by a sample */
+      unsigned_maxvalue=MaxValueGivenBits(sample_bits);
+
       if (QuantumDepth == sample_bits)
         {
         }
@@ -3585,118 +3631,118 @@ ImportViewPixelArea(ViewInfo *view,
     {
     case UndefinedQuantum:
       {
-       status=MagickFail;
-       break;
+        status=MagickFail;
+        break;
       }
     case IndexQuantum:
       {
-       status=ImportIndexQuantumType(source,q,indexes,number_pixels,quantum_size,
-                                     sample_type,unsigned_maxvalue,endian,image,
-                                     import_info);
+        status=ImportIndexQuantumType(source,q,indexes,number_pixels,quantum_size,
+                                      sample_type,unsigned_maxvalue,endian,image,
+                                      import_info);
         break;
       }
     case IndexAlphaQuantum:
       {
-       status=ImportIndexAlphaQuantumType(source,q,indexes,number_pixels,
-                                          quantum_size,sample_type,unsigned_scale,
-                                          endian,
-                                          image,
-                                          import_info);
+        status=ImportIndexAlphaQuantumType(source,q,indexes,number_pixels,
+                                           quantum_size,sample_type,unsigned_scale,
+                                           endian,
+                                           image,
+                                           import_info);
         break;
       }
     case GrayQuantum:
       {
-       status=ImportGrayQuantumType(source,q,indexes,number_pixels,quantum_size,
-                                    sample_type,unsigned_scale,unsigned_maxvalue,
-                                    grayscale_miniswhite,double_minvalue,
-                                    double_scale,endian,image,import_info);
+        status=ImportGrayQuantumType(source,q,indexes,number_pixels,quantum_size,
+                                     sample_type,unsigned_scale,unsigned_maxvalue,
+                                     grayscale_miniswhite,double_minvalue,
+                                     double_scale,endian,image,import_info);
         break;
       }
     case GrayAlphaQuantum:
       {
-       status=ImportGrayAlphaQuantumType(source,q,indexes,number_pixels,quantum_size,
-                                         sample_type,unsigned_scale,unsigned_maxvalue,
-                                         grayscale_miniswhite,double_minvalue,double_scale,
-                                         endian,image,import_info);
+        status=ImportGrayAlphaQuantumType(source,q,indexes,number_pixels,quantum_size,
+                                          sample_type,unsigned_scale,unsigned_maxvalue,
+                                          grayscale_miniswhite,double_minvalue,double_scale,
+                                          endian,image,import_info);
         break;
       }
     case RedQuantum:
     case CyanQuantum:
       {
-       status=ImportRedQuantumType(source,q,number_pixels,quantum_size,sample_type,
-                                   unsigned_scale,double_minvalue,double_scale,endian,
-                                   import_info);
+        status=ImportRedQuantumType(source,q,number_pixels,quantum_size,sample_type,
+                                    unsigned_scale,double_minvalue,double_scale,endian,
+                                    import_info);
 
         break;
       }
     case GreenQuantum:
     case MagentaQuantum:
       {
-       status=ImportGreenQuantumType(source,q,number_pixels,quantum_size,sample_type,
-                                     unsigned_scale,double_minvalue,double_scale,endian,
-                                     import_info);
+        status=ImportGreenQuantumType(source,q,number_pixels,quantum_size,sample_type,
+                                      unsigned_scale,double_minvalue,double_scale,endian,
+                                      import_info);
         break;
       }
     case BlueQuantum:
     case YellowQuantum:
       {
-       status=ImportBlueQuantumType(source,q,number_pixels,quantum_size,sample_type,
-                                    unsigned_scale,double_minvalue,double_scale,endian,
-                                    import_info);
+        status=ImportBlueQuantumType(source,q,number_pixels,quantum_size,sample_type,
+                                     unsigned_scale,double_minvalue,double_scale,endian,
+                                     import_info);
         break;
       }
     case AlphaQuantum:
       {
-       status=ImportAlphaQuantumType(source,q,indexes,number_pixels,quantum_size,
-                                     sample_type,unsigned_scale,double_minvalue,
-                                     double_scale,endian,image,import_info);
+        status=ImportAlphaQuantumType(source,q,indexes,number_pixels,quantum_size,
+                                      sample_type,unsigned_scale,double_minvalue,
+                                      double_scale,endian,image,import_info);
         break;
       }
     case BlackQuantum:
       {
-       status=ImportBlackQuantumType(source,q,number_pixels,quantum_size,sample_type,
-                                     unsigned_scale,double_minvalue,double_scale,endian,
-                                     import_info);
+        status=ImportBlackQuantumType(source,q,number_pixels,quantum_size,sample_type,
+                                      unsigned_scale,double_minvalue,double_scale,endian,
+                                      import_info);
         break;
       }
     case RGBQuantum:
       {
-       status=ImportRGBQuantumType(source,q,number_pixels,quantum_size,sample_type,
-                                   unsigned_scale,double_minvalue,double_scale,endian,
-                                   import_info);
+        status=ImportRGBQuantumType(source,q,number_pixels,quantum_size,sample_type,
+                                    unsigned_scale,double_minvalue,double_scale,endian,
+                                    import_info);
         break;
       }
     case RGBAQuantum:
       {
-       status=ImportRGBAQuantumType(source,q,number_pixels,quantum_size,sample_type,
-                                    unsigned_scale,double_minvalue,double_scale,endian,
-                                    import_info);
+        status=ImportRGBAQuantumType(source,q,number_pixels,quantum_size,sample_type,
+                                     unsigned_scale,double_minvalue,double_scale,endian,
+                                     import_info);
         break;
       }
     case CMYKQuantum:
       {
-       status=ImportCMYKQuantumType(source,q,indexes,number_pixels,quantum_size,
-                                    sample_type,unsigned_scale,double_minvalue,
-                                    double_scale,endian,import_info);
+        status=ImportCMYKQuantumType(source,q,number_pixels,quantum_size,
+                                     sample_type,unsigned_scale,double_minvalue,
+                                     double_scale,endian,import_info);
         break;
       }
     case CMYKAQuantum:
       {
-       status=ImportCMYKAQuantumType(source,q,indexes,number_pixels,quantum_size,
-                                     sample_type,unsigned_scale,double_minvalue,
-                                     double_scale,endian,import_info);
+        status=ImportCMYKAQuantumType(source,q,indexes,number_pixels,quantum_size,
+                                      sample_type,unsigned_scale,double_minvalue,
+                                      double_scale,endian,image,import_info);
         break;
       }
     case CIEXYZQuantum:
       {
-       status=ImportCIEXYZQuantumType(source,q,number_pixels,quantum_size,sample_type,
-                                      endian,import_info);
+        status=ImportCIEXYZQuantumType(source,q,number_pixels,quantum_size,sample_type,
+                                       endian,import_info);
         break;
       }
     case CIEYQuantum:
       {
-       status=ImportCIEYQuantumType(source,q,number_pixels,quantum_size,sample_type,
-                                    endian,import_info);
+        status=ImportCIEYQuantumType(source,q,number_pixels,quantum_size,sample_type,
+                                     endian,import_info);
         break;
       }
     }
index 8568d01..20eb9d9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002, 2003 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -209,7 +209,8 @@ MagickExport void DeleteImageFromList(Image **images)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  DestroyImageList() destroys an image list.
+%  DestroyImageList() destroys an image list.  There is no effect if the
+%  image pointer is null.
 %
 %  The format of the DestroyImageList method is:
 %
@@ -857,7 +858,7 @@ MagickExport void SpliceImageIntoList(Image **images,const unsigned long length,
 
   register long
     i;
-  
+
   assert(images != (Image **) NULL);
   assert(splice != (Image *) NULL);
   assert(splice->signature == MagickSignature);
index e611f53..e9fdbd8 100644 (file)
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2003 GraphicsMagick Group
+  Copyright (C) 2003-2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   ImageMagick Image List Methods.
 */
 #ifndef _MAGICK_LIST_H
@@ -17,23 +17,23 @@ extern "C" {
 
 extern MagickExport Image
   *CloneImageList(const Image *,ExceptionInfo *),
-  *GetFirstImageInList(const Image *),
-  *GetImageFromList(const Image *,const long),
-  *GetLastImageInList(const Image *),
-  *GetNextImageInList(const Image *),
-  *GetPreviousImageInList(const Image *),
+  *GetFirstImageInList(const Image *) MAGICK_FUNC_PURE,
+  *GetImageFromList(const Image *,const long) MAGICK_FUNC_PURE,
+  *GetLastImageInList(const Image *) MAGICK_FUNC_PURE,
+  *GetNextImageInList(const Image *) MAGICK_FUNC_PURE,
+  *GetPreviousImageInList(const Image *) MAGICK_FUNC_PURE,
   **ImageListToArray(const Image *,ExceptionInfo *),
-  *NewImageList(void),
+  *NewImageList(void) MAGICK_FUNC_CONST,
   *RemoveLastImageFromList(Image **),
   *RemoveFirstImageFromList(Image **),
   *SplitImageList(Image *),
   *SyncNextImageInList(const Image *);
 
 extern MagickExport long
-  GetImageIndexInList(const Image *);
+  GetImageIndexInList(const Image *) MAGICK_FUNC_PURE;
 
 extern MagickExport unsigned long
-  GetImageListLength(const Image *);
+  GetImageListLength(const Image *) MAGICK_FUNC_PURE;
 
 extern MagickExport void
   AppendImageToList(Image **,Image *),
index 3d6b2a1..a7204a3 100644 (file)
@@ -1,39 +1,39 @@
-/* 
-% Copyright (C) 2003, 2004 GraphicsMagick Group 
-% 
-% This program is covered by multiple licenses, which are described in 
-% Copyright.txt. You should have received a copy of Copyright.txt with this 
-% package; otherwise see http://www.graphicsmagick.org/www/Copyright.html. 
-% 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
-%                                                                             % 
-%                                                                             % 
-%                                                                             % 
-%                  L       OOO    CCCC   AAA   L      EEEEE                   % 
-%                  L      O   O  C      A   A  L      E                       % 
-%                  L      O   O  C      AAAAA  L      EEE                     % 
-%                  L      O   O  C      A   A  L      E                       % 
-%                  LLLLL   OOO    CCCC  A   A  LLLLL  EEEEE                   % 
-%                                                                             % 
-%                                                                             % 
-%                   GraphicsMagick Locale Message Methods                     % 
-%                                                                             % 
-%                                                                             % 
-%                              Software Design                                % 
-%                            William T. Radcliffe                             % 
-%                                 July 2003                                   % 
-%                                                                             % 
-%                                                                             % 
-%                                                                             % 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
-% 
-*/ 
+/*
+% Copyright (C) 2003, 2004 GraphicsMagick Group
+%
+% This program is covered by multiple licenses, which are described in
+% Copyright.txt. You should have received a copy of Copyright.txt with this
+% package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%                  L       OOO    CCCC   AAA   L      EEEEE                   %
+%                  L      O   O  C      A   A  L      E                       %
+%                  L      O   O  C      AAAAA  L      EEE                     %
+%                  L      O   O  C      A   A  L      E                       %
+%                  LLLLL   OOO    CCCC  A   A  LLLLL  EEEEE                   %
+%                                                                             %
+%                                                                             %
+%                   GraphicsMagick Locale Message Methods                     %
+%                                                                             %
+%                                                                             %
+%                              Software Design                                %
+%                            William T. Radcliffe                             %
+%                                 July 2003                                   %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+*/
 \f 
-/* 
-  Include declarations. 
-*/ 
+/*
+  Include declarations.
+*/
 #include "studio.h"
-#include "utility.h" 
+#include "utility.h"
 #define _INCLUDE_CATEGORYMAP_TABLE_
 #define _INCLUDE_SEVERITYMAP_TABLE_
 #define _INCLUDE_TAGMAP_TABLE_
@@ -238,29 +238,29 @@ GetLocaleMessageFromTag(const char *tag)
   return tag;
 }
 
-/* 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
-%                                                                             % 
-%                                                                             % 
-%                                                                             % 
-%   G e t L o c a l e M e s s a g e                                           % 
-%                                                                             % 
-%                                                                             % 
-%                                                                             % 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
-% 
-%  GetLocaleMessage() returns a message in the current locale that matches the 
-%  supplied tag. 
-% 
-%  The format of the GetLocaleMessage method is: 
-% 
-%      const char *GetLocaleMessage(const char *tag) 
-% 
-%  A description of each parameter follows: 
-% 
-%    o tag: Return a message that matches this tag in the current locale. 
-% 
-% 
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   G e t L o c a l e M e s s a g e                                           %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  GetLocaleMessage() returns a message in the current locale that matches the
+%  supplied tag.
+%
+%  The format of the GetLocaleMessage method is:
+%
+%      const char *GetLocaleMessage(const char *tag)
+%
+%  A description of each parameter follows:
+%
+%    o tag: Return a message that matches this tag in the current locale.
+%
+%
 */
 MagickExport const char *
 GetLocaleMessage(const char *tag)
index b3d422b..5436c0b 100644 (file)
 #ifndef _LOCAL_C_H
 #define _LOCAL_C_H
 
-extern MagickExport const char *GetLocaleMessageFromID(const int);
+extern MagickExport const char *GetLocaleMessageFromID(const int) MAGICK_FUNC_CONST;
 
-#define MAX_LOCALE_MSGS 557
+#define MAX_LOCALE_MSGS 575
 
 #define MGK_BlobErrorUnableToCreateBlob 1
-#define MGK_BlobErrorUnableToObtainOffset 2
-#define MGK_BlobErrorUnableToOpenFile 3
-#define MGK_BlobErrorUnableToReadFile 4
-#define MGK_BlobErrorUnableToReadToOffset 5
-#define MGK_BlobErrorUnableToSeekToOffset 6
-#define MGK_BlobErrorUnableToWriteBlob 7
-#define MGK_BlobErrorUnrecognizedImageFormat 8
-#define MGK_BlobFatalErrorDefault 9
-#define MGK_BlobWarningDefault 10
-#define MGK_CacheErrorInconsistentPersistentCacheDepth 11
-#define MGK_CacheErrorPixelCacheIsNotOpen 12
-#define MGK_CacheErrorUnableToAllocateCacheView 13
-#define MGK_CacheErrorUnableToCloneCache 14
-#define MGK_CacheErrorUnableToExtendCache 15
-#define MGK_CacheErrorUnableToGetCacheNexus 16
-#define MGK_CacheErrorUnableToGetPixelsFromCache 17
-#define MGK_CacheErrorUnableToOpenCache 18
-#define MGK_CacheErrorUnableToPeristPixelCache 19
-#define MGK_CacheErrorUnableToReadPixelCache 20
-#define MGK_CacheErrorUnableToSyncCache 21
-#define MGK_CacheFatalErrorDiskAllocationFailed 22
-#define MGK_CacheFatalErrorUnableToExtendPixelCache 23
-#define MGK_CacheWarningDefault 24
-#define MGK_CoderErrorColormapTooLarge 25
-#define MGK_CoderErrorColormapTypeNotSupported 26
-#define MGK_CoderErrorColorspaceModelIsNotSupported 27
-#define MGK_CoderErrorColorTypeNotSupported 28
-#define MGK_CoderErrorCompressionNotValid 29
-#define MGK_CoderErrorDataEncodingSchemeIsNotSupported 30
-#define MGK_CoderErrorDataStorageTypeIsNotSupported 31
-#define MGK_CoderErrorDeltaPNGNotSupported 32
-#define MGK_CoderErrorEncryptedWPGImageFileNotSupported 33
-#define MGK_CoderErrorFractalCompressionNotSupported 34
-#define MGK_CoderErrorImageColumnOrRowSizeIsNotSupported 35
-#define MGK_CoderErrorImageDoesNotHaveAMatteChannel 36
-#define MGK_CoderErrorImageIsNotTiled 37
-#define MGK_CoderErrorImageTypeNotSupported 38
-#define MGK_CoderErrorIncompatibleSizeOfDouble 39
-#define MGK_CoderErrorIrregularChannelGeometryNotSupported 40
-#define MGK_CoderErrorJNGCompressionNotSupported 41
-#define MGK_CoderErrorJPEGCompressionNotSupported 42
-#define MGK_CoderErrorJPEGEmbeddingFailed 43
-#define MGK_CoderErrorLocationTypeIsNotSupported 44
-#define MGK_CoderErrorMapStorageTypeIsNotSupported 45
-#define MGK_CoderErrorMSBByteOrderNotSupported 46
-#define MGK_CoderErrorMultidimensionalMatricesAreNotSupported 47
-#define MGK_CoderErrorMultipleRecordListNotSupported 48
-#define MGK_CoderErrorNo8BIMDataIsAvailable 49
-#define MGK_CoderErrorNoAPP1DataIsAvailable 50
-#define MGK_CoderErrorNoBitmapOnClipboard 51
-#define MGK_CoderErrorNoColorProfileAvailable 52
-#define MGK_CoderErrorNoDataReturned 53
-#define MGK_CoderErrorNoImageVectorGraphics 54
-#define MGK_CoderErrorNoIPTCInfoWasFound 55
-#define MGK_CoderErrorNoIPTCProfileAvailable 56
-#define MGK_CoderErrorNumberOfImagesIsNotSupported 57
-#define MGK_CoderErrorOnlyContinuousTonePictureSupported 58
-#define MGK_CoderErrorOnlyLevelZerofilesSupported 59
-#define MGK_CoderErrorPNGCompressionNotSupported 60
-#define MGK_CoderErrorPNGLibraryTooOld 61
-#define MGK_CoderErrorRLECompressionNotSupported 62
-#define MGK_CoderErrorSubsamplingRequiresEvenWidth 63
-#define MGK_CoderErrorUnableToCopyProfile 64
-#define MGK_CoderErrorUnableToCreateADC 65
-#define MGK_CoderErrorUnableToCreateBitmap 66
-#define MGK_CoderErrorUnableToDecompressImage 67
-#define MGK_CoderErrorUnableToInitializeFPXLibrary 68
-#define MGK_CoderErrorUnableToOpenBlob 69
-#define MGK_CoderErrorUnableToReadAspectRatio 70
-#define MGK_CoderErrorUnableToReadCIELABImages 71
-#define MGK_CoderErrorUnableToReadSummaryInfo 72
-#define MGK_CoderErrorUnableToSetAffineMatrix 73
-#define MGK_CoderErrorUnableToSetAspectRatio 74
-#define MGK_CoderErrorUnableToSetColorTwist 75
-#define MGK_CoderErrorUnableToSetContrast 76
-#define MGK_CoderErrorUnableToSetFilteringValue 77
-#define MGK_CoderErrorUnableToSetImageComments 78
-#define MGK_CoderErrorUnableToSetImageTitle 79
-#define MGK_CoderErrorUnableToSetJPEGLevel 80
-#define MGK_CoderErrorUnableToSetRegionOfInterest 81
-#define MGK_CoderErrorUnableToSetSummaryInfo 82
-#define MGK_CoderErrorUnableToTranslateText 83
-#define MGK_CoderErrorUnableToWriteMPEGParameters 84
-#define MGK_CoderErrorUnableToWriteTemporaryFile 85
-#define MGK_CoderErrorUnableToZipCompressImage 86
-#define MGK_CoderErrorUnsupportedBitsPerSample 87
-#define MGK_CoderErrorUnsupportedCellTypeInTheMatrix 88
-#define MGK_CoderErrorWebPDecodingFailedUserAbort 89
-#define MGK_CoderErrorWebPEncodingFailed 90
-#define MGK_CoderErrorWebPEncodingFailedBadDimension 91
-#define MGK_CoderErrorWebPEncodingFailedBadWrite 92
-#define MGK_CoderErrorWebPEncodingFailedBitstreamOutOfMemory 93
-#define MGK_CoderErrorWebPEncodingFailedFileTooBig 94
-#define MGK_CoderErrorWebPEncodingFailedInvalidConfiguration 95
-#define MGK_CoderErrorWebPEncodingFailedNULLParameter 96
-#define MGK_CoderErrorWebPEncodingFailedOutOfMemory 97
-#define MGK_CoderErrorWebPEncodingFailedPartition0Overflow 98
-#define MGK_CoderErrorWebPEncodingFailedPartitionOverflow 99
-#define MGK_CoderErrorWebPEncodingFailedUserAbort 100
-#define MGK_CoderErrorWebPInvalidConfiguration 101
-#define MGK_CoderErrorWebPInvalidParameter 102
-#define MGK_CoderErrorZipCompressionNotSupported 103
-#define MGK_CoderFatalErrorDefault 104
-#define MGK_CoderWarningLosslessToLossyJPEGConversion 105
-#define MGK_ConfigureErrorIncludeElementNestedTooDeeply 106
-#define MGK_ConfigureErrorRegistryKeyLookupFailed 107
-#define MGK_ConfigureErrorStringTokenLengthExceeded 108
-#define MGK_ConfigureErrorUnableToAccessConfigureFile 109
-#define MGK_ConfigureErrorUnableToAccessFontFile 110
-#define MGK_ConfigureErrorUnableToAccessLogFile 111
-#define MGK_ConfigureErrorUnableToAccessModuleFile 112
-#define MGK_ConfigureFatalErrorDefault 113
-#define MGK_ConfigureFatalErrorUnableToChangeToWorkingDirectory 114
-#define MGK_ConfigureFatalErrorUnableToGetCurrentDirectory 115
-#define MGK_ConfigureFatalErrorUnableToRestoreCurrentDirectory 116
-#define MGK_ConfigureWarningDefault 117
-#define MGK_CorruptImageErrorAnErrorHasOccurredReadingFromFile 118
-#define MGK_CorruptImageErrorAnErrorHasOccurredWritingToFile 119
-#define MGK_CorruptImageErrorColormapExceedsColorsLimit 120
-#define MGK_CorruptImageErrorCompressionNotValid 121
-#define MGK_CorruptImageErrorCorruptImage 122
-#define MGK_CorruptImageErrorImageFileDoesNotContainAnyImageData 123
-#define MGK_CorruptImageErrorImageTypeNotSupported 124
-#define MGK_CorruptImageErrorImproperImageHeader 125
-#define MGK_CorruptImageErrorInsufficientImageDataInFile 126
-#define MGK_CorruptImageErrorInvalidColormapIndex 127
-#define MGK_CorruptImageErrorInvalidFileFormatVersion 128
-#define MGK_CorruptImageErrorLengthAndFilesizeDoNotMatch 129
-#define MGK_CorruptImageErrorMissingImageChannel 130
-#define MGK_CorruptImageErrorNegativeOrZeroImageSize 131
-#define MGK_CorruptImageErrorNonOS2HeaderSizeError 132
-#define MGK_CorruptImageErrorNotEnoughTiles 133
-#define MGK_CorruptImageErrorStaticPlanesValueNotEqualToOne 134
-#define MGK_CorruptImageErrorSubsamplingRequiresEvenWidth 135
-#define MGK_CorruptImageErrorTooMuchImageDataInFile 136
-#define MGK_CorruptImageErrorUnableToReadColormapFromDumpFile 137
-#define MGK_CorruptImageErrorUnableToReadColorProfile 138
-#define MGK_CorruptImageErrorUnableToReadExtensionBlock 139
-#define MGK_CorruptImageErrorUnableToReadGenericProfile 140
-#define MGK_CorruptImageErrorUnableToReadImageData 141
-#define MGK_CorruptImageErrorUnableToReadImageHeader 142
-#define MGK_CorruptImageErrorUnableToReadIPTCProfile 143
-#define MGK_CorruptImageErrorUnableToReadPixmapFromDumpFile 144
-#define MGK_CorruptImageErrorUnableToReadSubImageData 145
-#define MGK_CorruptImageErrorUnableToReadVIDImage 146
-#define MGK_CorruptImageErrorUnableToReadWindowNameFromDumpFile 147
-#define MGK_CorruptImageErrorUnableToRunlengthDecodeImage 148
-#define MGK_CorruptImageErrorUnableToUncompressImage 149
-#define MGK_CorruptImageErrorUnexpectedEndOfFile 150
-#define MGK_CorruptImageErrorUnexpectedSamplingFactor 151
-#define MGK_CorruptImageErrorUnknownPatternType 152
-#define MGK_CorruptImageErrorUnrecognizedBitsPerPixel 153
-#define MGK_CorruptImageErrorUnrecognizedImageCompression 154
-#define MGK_CorruptImageErrorUnrecognizedNumberOfColors 155
-#define MGK_CorruptImageErrorUnrecognizedXWDHeader 156
-#define MGK_CorruptImageErrorUnsupportedBitsPerSample 157
-#define MGK_CorruptImageErrorUnsupportedNumberOfPlanes 158
-#define MGK_CorruptImageFatalErrorUnableToPersistKey 159
-#define MGK_CorruptImageWarningCompressionNotValid 160
-#define MGK_CorruptImageWarningCorruptImage 161
-#define MGK_CorruptImageWarningImproperImageHeader 162
-#define MGK_CorruptImageWarningInvalidColormapIndex 163
-#define MGK_CorruptImageWarningLengthAndFilesizeDoNotMatch 164
-#define MGK_CorruptImageWarningNegativeOrZeroImageSize 165
-#define MGK_CorruptImageWarningNonOS2HeaderSizeError 166
-#define MGK_CorruptImageWarningSkipToSyncByte 167
-#define MGK_CorruptImageWarningStaticPlanesValueNotEqualToOne 168
-#define MGK_CorruptImageWarningUnrecognizedBitsPerPixel 169
-#define MGK_CorruptImageWarningUnrecognizedImageCompression 170
-#define MGK_DelegateErrorDelegateFailed 171
-#define MGK_DelegateErrorFailedToAllocateArgumentList 172
-#define MGK_DelegateErrorFailedToAllocateGhostscriptInterpreter 173
-#define MGK_DelegateErrorFailedToComputeOutputSize 174
-#define MGK_DelegateErrorFailedToFindGhostscript 175
-#define MGK_DelegateErrorFailedToRenderFile 176
-#define MGK_DelegateErrorFailedToScanFile 177
-#define MGK_DelegateErrorNoTagFound 178
-#define MGK_DelegateErrorPostscriptDelegateFailed 179
-#define MGK_DelegateErrorUnableToCreateImage 180
-#define MGK_DelegateErrorUnableToCreateImageComponent 181
-#define MGK_DelegateErrorUnableToDecodeImageFile 182
-#define MGK_DelegateErrorUnableToEncodeImageFile 183
-#define MGK_DelegateErrorUnableToInitializeFPXLibrary 184
-#define MGK_DelegateErrorUnableToInitializeWMFLibrary 185
-#define MGK_DelegateErrorUnableToManageJP2Stream 186
-#define MGK_DelegateErrorUnableToWriteSVGFormat 187
-#define MGK_DelegateErrorWebPABIMismatch 188
-#define MGK_DelegateFatalErrorDefault 189
-#define MGK_DelegateWarningDefault 190
-#define MGK_DrawErrorAlreadyPushingPatternDefinition 191
-#define MGK_DrawErrorDrawingRecursionDetected 192
-#define MGK_DrawErrorFloatValueConversionError 193
-#define MGK_DrawErrorIntegerValueConversionError 194
-#define MGK_DrawErrorInvalidPrimitiveArgument 195
-#define MGK_DrawErrorNonconformingDrawingPrimitiveDefinition 196
-#define MGK_DrawErrorPrimitiveArithmeticOverflow 197
-#define MGK_DrawErrorTooManyCoordinates 198
-#define MGK_DrawErrorUnableToPrint 199
-#define MGK_DrawErrorUnbalancedGraphicContextPushPop 200
-#define MGK_DrawErrorUnreasonableGradientSize 201
-#define MGK_DrawErrorVectorPathTruncated 202
-#define MGK_DrawFatalErrorDefault 203
-#define MGK_DrawWarningNotARelativeURL 204
-#define MGK_DrawWarningNotCurrentlyPushingPatternDefinition 205
-#define MGK_DrawWarningURLNotFound 206
-#define MGK_FileOpenErrorUnableToCreateTemporaryFile 207
-#define MGK_FileOpenErrorUnableToOpenFile 208
-#define MGK_FileOpenErrorUnableToWriteFile 209
-#define MGK_FileOpenFatalErrorDefault 210
-#define MGK_FileOpenWarningDefault 211
-#define MGK_ImageErrorAngleIsDiscontinuous 212
-#define MGK_ImageErrorColorspaceColorProfileMismatch 213
-#define MGK_ImageErrorImageColorspaceDiffers 214
-#define MGK_ImageErrorImageColorspaceMismatch 215
-#define MGK_ImageErrorImageDifferenceExceedsLimit 216
-#define MGK_ImageErrorImageDoesNotContainResolution 217
-#define MGK_ImageErrorImageOpacityDiffers 218
-#define MGK_ImageErrorImageSequenceIsRequired 219
-#define MGK_ImageErrorImageSizeDiffers 220
-#define MGK_ImageErrorInvalidColormapIndex 221
-#define MGK_ImageErrorLeftAndRightImageSizesDiffer 222
-#define MGK_ImageErrorNoImagesWereFound 223
-#define MGK_ImageErrorNoImagesWereLoaded 224
-#define MGK_ImageErrorNoLocaleImageAttribute 225
-#define MGK_ImageErrorTooManyClusters 226
-#define MGK_ImageErrorUnableToAppendImage 227
-#define MGK_ImageErrorUnableToAssignProfile 228
-#define MGK_ImageErrorUnableToAverageImage 229
-#define MGK_ImageErrorUnableToCoalesceImage 230
-#define MGK_ImageErrorUnableToCompareImages 231
-#define MGK_ImageErrorUnableToCreateImageMosaic 232
-#define MGK_ImageErrorUnableToCreateStereoImage 233
-#define MGK_ImageErrorUnableToDeconstructImageSequence 234
-#define MGK_ImageErrorUnableToFlattenImage 235
-#define MGK_ImageErrorUnableToGetClipMask 236
-#define MGK_ImageErrorUnableToHandleImageChannel 237
-#define MGK_ImageErrorUnableToResizeImage 238
-#define MGK_ImageErrorUnableToSegmentImage 239
-#define MGK_ImageErrorUnableToSetClipMask 240
-#define MGK_ImageErrorUnableToShearImage 241
-#define MGK_ImageErrorWidthOrHeightExceedsLimit 242
-#define MGK_ImageFatalErrorUnableToPersistKey 243
-#define MGK_ImageWarningDefault 244
-#define MGK_MissingDelegateErrorDPSLibraryIsNotAvailable 245
-#define MGK_MissingDelegateErrorFPXLibraryIsNotAvailable 246
-#define MGK_MissingDelegateErrorFreeTypeLibraryIsNotAvailable 247
-#define MGK_MissingDelegateErrorJPEGLibraryIsNotAvailable 248
-#define MGK_MissingDelegateErrorLCMSLibraryIsNotAvailable 249
-#define MGK_MissingDelegateErrorLZWEncodingNotEnabled 250
-#define MGK_MissingDelegateErrorNoDecodeDelegateForThisImageFormat 251
-#define MGK_MissingDelegateErrorNoEncodeDelegateForThisImageFormat 252
-#define MGK_MissingDelegateErrorTIFFLibraryIsNotAvailable 253
-#define MGK_MissingDelegateErrorXMLLibraryIsNotAvailable 254
-#define MGK_MissingDelegateErrorXWindowLibraryIsNotAvailable 255
-#define MGK_MissingDelegateErrorZipLibraryIsNotAvailable 256
-#define MGK_MissingDelegateFatalErrorDefault 257
-#define MGK_MissingDelegateWarningDefault 258
-#define MGK_ModuleErrorFailedToCloseModule 259
-#define MGK_ModuleErrorFailedToFindSymbol 260
-#define MGK_ModuleErrorUnableToLoadModule 261
-#define MGK_ModuleErrorUnableToRegisterImageFormat 262
-#define MGK_ModuleErrorUnrecognizedModule 263
-#define MGK_ModuleFatalErrorUnableToInitializeModuleLoader 264
-#define MGK_ModuleWarningDefault 265
-#define MGK_MonitorErrorDefault 266
-#define MGK_MonitorFatalErrorDefault 267
-#define MGK_MonitorFatalErrorUserRequestedTerminationBySignal 268
-#define MGK_MonitorWarningDefault 269
-#define MGK_OptionErrorBevelWidthIsNegative 270
-#define MGK_OptionErrorColorSeparatedImageRequired 271
-#define MGK_OptionErrorFrameIsLessThanImageSize 272
-#define MGK_OptionErrorGeometryDimensionsAreZero 273
-#define MGK_OptionErrorGeometryDoesNotContainImage 274
-#define MGK_OptionErrorHaldClutImageDimensionsInvalid 275
-#define MGK_OptionErrorImagesAreNotTheSameSize 276
-#define MGK_OptionErrorImageSizeMustExceedBevelWidth 277
-#define MGK_OptionErrorImageSmallerThanKernelWidth 278
-#define MGK_OptionErrorImageSmallerThanRadius 279
-#define MGK_OptionErrorImageWidthsOrHeightsDiffer 280
-#define MGK_OptionErrorInputImagesAlreadySpecified 281
-#define MGK_OptionErrorInvalidSubimageSpecification 282
-#define MGK_OptionErrorKernelRadiusIsTooSmall 283
-#define MGK_OptionErrorKernelWidthMustBeAnOddNumber 284
-#define MGK_OptionErrorMatrixIsNotSquare 285
-#define MGK_OptionErrorMatrixOrderOutOfRange 286
-#define MGK_OptionErrorMissingAnImageFilename 287
-#define MGK_OptionErrorMissingArgument 288
-#define MGK_OptionErrorMustSpecifyAnImageName 289
-#define MGK_OptionErrorMustSpecifyImageSize 290
-#define MGK_OptionErrorNoBlobDefined 291
-#define MGK_OptionErrorNoImagesDefined 292
-#define MGK_OptionErrorNonzeroWidthAndHeightRequired 293
-#define MGK_OptionErrorNoProfileNameWasGiven 294
-#define MGK_OptionErrorNullBlobArgument 295
-#define MGK_OptionErrorReferenceImageRequired 296
-#define MGK_OptionErrorReferenceIsNotMyType 297
-#define MGK_OptionErrorRegionAreaExceedsLimit 298
-#define MGK_OptionErrorRequestDidNotReturnAnImage 299
-#define MGK_OptionErrorSteganoImageRequired 300
-#define MGK_OptionErrorStereoImageRequired 301
-#define MGK_OptionErrorSubimageSpecificationReturnsNoImages 302
-#define MGK_OptionErrorUnableToAddOrRemoveProfile 303
-#define MGK_OptionErrorUnableToAverageImageSequence 304
-#define MGK_OptionErrorUnableToBlurImage 305
-#define MGK_OptionErrorUnableToChopImage 306
-#define MGK_OptionErrorUnableToColorMatrixImage 307
-#define MGK_OptionErrorUnableToConstituteImage 308
-#define MGK_OptionErrorUnableToConvolveImage 309
-#define MGK_OptionErrorUnableToEdgeImage 310
-#define MGK_OptionErrorUnableToEqualizeImage 311
-#define MGK_OptionErrorUnableToFilterImage 312
-#define MGK_OptionErrorUnableToFormatImageMetadata 313
-#define MGK_OptionErrorUnableToFrameImage 314
-#define MGK_OptionErrorUnableToOilPaintImage 315
-#define MGK_OptionErrorUnableToPaintImage 316
-#define MGK_OptionErrorUnableToRaiseImage 317
-#define MGK_OptionErrorUnableToSharpenImage 318
-#define MGK_OptionErrorUnableToThresholdImage 319
-#define MGK_OptionErrorUnableToWaveImage 320
-#define MGK_OptionErrorUnrecognizedAttribute 321
-#define MGK_OptionErrorUnrecognizedChannelType 322
-#define MGK_OptionErrorUnrecognizedColor 323
-#define MGK_OptionErrorUnrecognizedColormapType 324
-#define MGK_OptionErrorUnrecognizedColorspace 325
-#define MGK_OptionErrorUnrecognizedCommand 326
-#define MGK_OptionErrorUnrecognizedComposeOperator 327
-#define MGK_OptionErrorUnrecognizedDisposeMethod 328
-#define MGK_OptionErrorUnrecognizedElement 329
-#define MGK_OptionErrorUnrecognizedEndianType 330
-#define MGK_OptionErrorUnrecognizedGravityType 331
-#define MGK_OptionErrorUnrecognizedHighlightStyle 332
-#define MGK_OptionErrorUnrecognizedImageCompression 333
-#define MGK_OptionErrorUnrecognizedImageFilter 334
-#define MGK_OptionErrorUnrecognizedImageFormat 335
-#define MGK_OptionErrorUnrecognizedImageMode 336
-#define MGK_OptionErrorUnrecognizedImageType 337
-#define MGK_OptionErrorUnrecognizedIntentType 338
-#define MGK_OptionErrorUnrecognizedInterlaceType 339
-#define MGK_OptionErrorUnrecognizedListType 340
-#define MGK_OptionErrorUnrecognizedMetric 341
-#define MGK_OptionErrorUnrecognizedModeType 342
-#define MGK_OptionErrorUnrecognizedNoiseType 343
-#define MGK_OptionErrorUnrecognizedOperator 344
-#define MGK_OptionErrorUnrecognizedOption 345
-#define MGK_OptionErrorUnrecognizedPerlMagickMethod 346
-#define MGK_OptionErrorUnrecognizedPixelMap 347
-#define MGK_OptionErrorUnrecognizedPreviewType 348
-#define MGK_OptionErrorUnrecognizedResourceType 349
-#define MGK_OptionErrorUnrecognizedType 350
-#define MGK_OptionErrorUnrecognizedUnitsType 351
-#define MGK_OptionErrorUnrecognizedVirtualPixelMethod 352
-#define MGK_OptionErrorUnsupportedSamplingFactor 353
-#define MGK_OptionErrorUsageError 354
-#define MGK_OptionFatalErrorInvalidColorspaceType 355
-#define MGK_OptionFatalErrorInvalidEndianType 356
-#define MGK_OptionFatalErrorInvalidImageType 357
-#define MGK_OptionFatalErrorInvalidInterlaceType 358
-#define MGK_OptionFatalErrorMissingAnImageFilename 359
-#define MGK_OptionFatalErrorMissingArgument 360
-#define MGK_OptionFatalErrorNoImagesWereLoaded 361
-#define MGK_OptionFatalErrorOptionLengthExceedsLimit 362
-#define MGK_OptionFatalErrorRequestDidNotReturnAnImage 363
-#define MGK_OptionFatalErrorUnableToOpenXServer 364
-#define MGK_OptionFatalErrorUnableToPersistKey 365
-#define MGK_OptionFatalErrorUnrecognizedColormapType 366
-#define MGK_OptionFatalErrorUnrecognizedColorspaceType 367
-#define MGK_OptionFatalErrorUnrecognizedDisposeMethod 368
-#define MGK_OptionFatalErrorUnrecognizedEndianType 369
-#define MGK_OptionFatalErrorUnrecognizedFilterType 370
-#define MGK_OptionFatalErrorUnrecognizedImageCompressionType 371
-#define MGK_OptionFatalErrorUnrecognizedImageType 372
-#define MGK_OptionFatalErrorUnrecognizedInterlaceType 373
-#define MGK_OptionFatalErrorUnrecognizedOption 374
-#define MGK_OptionFatalErrorUnrecognizedResourceType 375
-#define MGK_OptionFatalErrorUnrecognizedVirtualPixelMethod 376
-#define MGK_OptionWarningUnrecognizedColor 377
-#define MGK_RegistryErrorImageExpected 378
-#define MGK_RegistryErrorImageInfoExpected 379
-#define MGK_RegistryErrorStructureSizeMismatch 380
-#define MGK_RegistryErrorUnableToGetRegistryID 381
-#define MGK_RegistryErrorUnableToLocateImage 382
-#define MGK_RegistryErrorUnableToSetRegistry 383
-#define MGK_RegistryFatalErrorDefault 384
-#define MGK_RegistryWarningDefault 385
-#define MGK_ResourceLimitErrorCacheResourcesExhausted 386
-#define MGK_ResourceLimitErrorImagePixelHeightLimitExceeded 387
-#define MGK_ResourceLimitErrorImagePixelLimitExceeded 388
-#define MGK_ResourceLimitErrorImagePixelWidthLimitExceeded 389
-#define MGK_ResourceLimitErrorMemoryAllocationFailed 390
-#define MGK_ResourceLimitErrorNoPixelsDefinedInCache 391
-#define MGK_ResourceLimitErrorPixelCacheAllocationFailed 392
-#define MGK_ResourceLimitErrorUnableToAddColorProfile 393
-#define MGK_ResourceLimitErrorUnableToAddGenericProfile 394
-#define MGK_ResourceLimitErrorUnableToAddIPTCProfile 395
-#define MGK_ResourceLimitErrorUnableToAllocateCoefficients 396
-#define MGK_ResourceLimitErrorUnableToAllocateColormap 397
-#define MGK_ResourceLimitErrorUnableToAllocateICCProfile 398
-#define MGK_ResourceLimitErrorUnableToAllocateImage 399
-#define MGK_ResourceLimitErrorUnableToAllocateString 400
-#define MGK_ResourceLimitErrorUnableToAnnotateImage 401
-#define MGK_ResourceLimitErrorUnableToAverageImageSequence 402
-#define MGK_ResourceLimitErrorUnableToCloneDrawingWand 403
-#define MGK_ResourceLimitErrorUnableToCloneImage 404
-#define MGK_ResourceLimitErrorUnableToComputeImageSignature 405
-#define MGK_ResourceLimitErrorUnableToConstituteImage 406
-#define MGK_ResourceLimitErrorUnableToConvertFont 407
-#define MGK_ResourceLimitErrorUnableToConvertStringToTokens 408
-#define MGK_ResourceLimitErrorUnableToCreateColormap 409
-#define MGK_ResourceLimitErrorUnableToCreateColorTransform 410
-#define MGK_ResourceLimitErrorUnableToCreateCommandWidget 411
-#define MGK_ResourceLimitErrorUnableToCreateImageGroup 412
-#define MGK_ResourceLimitErrorUnableToCreateImageMontage 413
-#define MGK_ResourceLimitErrorUnableToCreateXWindow 414
-#define MGK_ResourceLimitErrorUnableToCropImage 415
-#define MGK_ResourceLimitErrorUnableToDespeckleImage 416
-#define MGK_ResourceLimitErrorUnableToDetermineImageClass 417
-#define MGK_ResourceLimitErrorUnableToDetermineTheNumberOfImageColors 418
-#define MGK_ResourceLimitErrorUnableToDitherImage 419
-#define MGK_ResourceLimitErrorUnableToDrawOnImage 420
-#define MGK_ResourceLimitErrorUnableToEdgeImage 421
-#define MGK_ResourceLimitErrorUnableToEmbossImage 422
-#define MGK_ResourceLimitErrorUnableToEnhanceImage 423
-#define MGK_ResourceLimitErrorUnableToFloodfillImage 424
-#define MGK_ResourceLimitErrorUnableToGammaCorrectImage 425
-#define MGK_ResourceLimitErrorUnableToGetBestIconSize 426
-#define MGK_ResourceLimitErrorUnableToGetFromRegistry 427
-#define MGK_ResourceLimitErrorUnableToGetPackageInfo 428
-#define MGK_ResourceLimitErrorUnableToLevelImage 429
-#define MGK_ResourceLimitErrorUnableToMagnifyImage 430
-#define MGK_ResourceLimitErrorUnableToManageColor 431
-#define MGK_ResourceLimitErrorUnableToMapImage 432
-#define MGK_ResourceLimitErrorUnableToMapImageSequence 433
-#define MGK_ResourceLimitErrorUnableToMedianFilterImage 434
-#define MGK_ResourceLimitErrorUnableToMotionBlurImage 435
-#define MGK_ResourceLimitErrorUnableToNoiseFilterImage 436
-#define MGK_ResourceLimitErrorUnableToNormalizeImage 437
-#define MGK_ResourceLimitErrorUnableToOpenColorProfile 438
-#define MGK_ResourceLimitErrorUnableToQuantizeImage 439
-#define MGK_ResourceLimitErrorUnableToQuantizeImageSequence 440
-#define MGK_ResourceLimitErrorUnableToReadTextChunk 441
-#define MGK_ResourceLimitErrorUnableToReadXImage 442
-#define MGK_ResourceLimitErrorUnableToReadXServerColormap 443
-#define MGK_ResourceLimitErrorUnableToResizeImage 444
-#define MGK_ResourceLimitErrorUnableToRotateImage 445
-#define MGK_ResourceLimitErrorUnableToSampleImage 446
-#define MGK_ResourceLimitErrorUnableToScaleImage 447
-#define MGK_ResourceLimitErrorUnableToSelectImage 448
-#define MGK_ResourceLimitErrorUnableToSharpenImage 449
-#define MGK_ResourceLimitErrorUnableToShaveImage 450
-#define MGK_ResourceLimitErrorUnableToShearImage 451
-#define MGK_ResourceLimitErrorUnableToSortImageColormap 452
-#define MGK_ResourceLimitErrorUnableToThresholdImage 453
-#define MGK_ResourceLimitErrorUnableToTransformColorspace 454
-#define MGK_ResourceLimitFatalErrorMemoryAllocationFailed 455
-#define MGK_ResourceLimitFatalErrorSemaporeOperationFailed 456
-#define MGK_ResourceLimitFatalErrorUnableToAllocateAscii85Info 457
-#define MGK_ResourceLimitFatalErrorUnableToAllocateCacheInfo 458
-#define MGK_ResourceLimitFatalErrorUnableToAllocateCacheView 459
-#define MGK_ResourceLimitFatalErrorUnableToAllocateColorInfo 460
-#define MGK_ResourceLimitFatalErrorUnableToAllocateDashPattern 461
-#define MGK_ResourceLimitFatalErrorUnableToAllocateDelegateInfo 462
-#define MGK_ResourceLimitFatalErrorUnableToAllocateDerivatives 463
-#define MGK_ResourceLimitFatalErrorUnableToAllocateDrawContext 464
-#define MGK_ResourceLimitFatalErrorUnableToAllocateDrawInfo 465
-#define MGK_ResourceLimitFatalErrorUnableToAllocateDrawingWand 466
-#define MGK_ResourceLimitFatalErrorUnableToAllocateGammaMap 467
-#define MGK_ResourceLimitFatalErrorUnableToAllocateImage 468
-#define MGK_ResourceLimitFatalErrorUnableToAllocateImagePixels 469
-#define MGK_ResourceLimitFatalErrorUnableToAllocateLogInfo 470
-#define MGK_ResourceLimitFatalErrorUnableToAllocateMagicInfo 471
-#define MGK_ResourceLimitFatalErrorUnableToAllocateMagickInfo 472
-#define MGK_ResourceLimitFatalErrorUnableToAllocateModuleInfo 473
-#define MGK_ResourceLimitFatalErrorUnableToAllocateMontageInfo 474
-#define MGK_ResourceLimitFatalErrorUnableToAllocateQuantizeInfo 475
-#define MGK_ResourceLimitFatalErrorUnableToAllocateRandomKernel 476
-#define MGK_ResourceLimitFatalErrorUnableToAllocateRegistryInfo 477
-#define MGK_ResourceLimitFatalErrorUnableToAllocateSemaphoreInfo 478
-#define MGK_ResourceLimitFatalErrorUnableToAllocateString 479
-#define MGK_ResourceLimitFatalErrorUnableToAllocateTypeInfo 480
-#define MGK_ResourceLimitFatalErrorUnableToAllocateWand 481
-#define MGK_ResourceLimitFatalErrorUnableToAnimateImageSequence 482
-#define MGK_ResourceLimitFatalErrorUnableToCloneBlobInfo 483
-#define MGK_ResourceLimitFatalErrorUnableToCloneCacheInfo 484
-#define MGK_ResourceLimitFatalErrorUnableToCloneImage 485
-#define MGK_ResourceLimitFatalErrorUnableToCloneImageInfo 486
-#define MGK_ResourceLimitFatalErrorUnableToConcatenateString 487
-#define MGK_ResourceLimitFatalErrorUnableToConvertText 488
-#define MGK_ResourceLimitFatalErrorUnableToCreateColormap 489
-#define MGK_ResourceLimitFatalErrorUnableToDestroySemaphore 490
-#define MGK_ResourceLimitFatalErrorUnableToDisplayImage 491
-#define MGK_ResourceLimitFatalErrorUnableToEscapeString 492
-#define MGK_ResourceLimitFatalErrorUnableToInitializeSemaphore 493
-#define MGK_ResourceLimitFatalErrorUnableToInterpretMSLImage 494
-#define MGK_ResourceLimitFatalErrorUnableToLockSemaphore 495
-#define MGK_ResourceLimitFatalErrorUnableToObtainRandomEntropy 496
-#define MGK_ResourceLimitFatalErrorUnableToUnlockSemaphore 497
-#define MGK_ResourceLimitWarningMemoryAllocationFailed 498
-#define MGK_StreamErrorImageDoesNotContainTheStreamGeometry 499
-#define MGK_StreamErrorNoStreamHandlerIsDefined 500
-#define MGK_StreamErrorPixelCacheIsNotOpen 501
-#define MGK_StreamErrorUnableToAcquirePixelStream 502
-#define MGK_StreamErrorUnableToSetPixelStream 503
-#define MGK_StreamErrorUnableToSyncPixelStream 504
-#define MGK_StreamFatalErrorDefault 505
-#define MGK_StreamWarningDefault 506
-#define MGK_TypeErrorFontSubstitutionRequired 507
-#define MGK_TypeErrorUnableToGetTypeMetrics 508
-#define MGK_TypeErrorUnableToInitializeFreetypeLibrary 509
-#define MGK_TypeErrorUnableToReadFont 510
-#define MGK_TypeErrorUnrecognizedFontEncoding 511
-#define MGK_TypeFatalErrorDefault 512
-#define MGK_TypeWarningDefault 513
-#define MGK_WandErrorInvalidColormapIndex 514
-#define MGK_WandErrorWandAPINotImplemented 515
-#define MGK_WandErrorWandContainsNoImageIndexs 516
-#define MGK_WandErrorWandContainsNoImages 517
-#define MGK_XServerErrorColorIsNotKnownToServer 518
-#define MGK_XServerErrorNoWindowWithSpecifiedIDExists 519
-#define MGK_XServerErrorStandardColormapIsNotInitialized 520
-#define MGK_XServerErrorUnableToConnectToRemoteDisplay 521
-#define MGK_XServerErrorUnableToCreateBitmap 522
-#define MGK_XServerErrorUnableToCreateColormap 523
-#define MGK_XServerErrorUnableToCreatePixmap 524
-#define MGK_XServerErrorUnableToCreateProperty 525
-#define MGK_XServerErrorUnableToCreateStandardColormap 526
-#define MGK_XServerErrorUnableToDisplayImageInfo 527
-#define MGK_XServerErrorUnableToGetProperty 528
-#define MGK_XServerErrorUnableToGetStandardColormap 529
-#define MGK_XServerErrorUnableToGetVisual 530
-#define MGK_XServerErrorUnableToGrabMouse 531
-#define MGK_XServerErrorUnableToLoadFont 532
-#define MGK_XServerErrorUnableToMatchVisualToStandardColormap 533
-#define MGK_XServerErrorUnableToOpenXServer 534
-#define MGK_XServerErrorUnableToReadXAttributes 535
-#define MGK_XServerErrorUnableToReadXWindowImage 536
-#define MGK_XServerErrorUnrecognizedColormapType 537
-#define MGK_XServerErrorUnrecognizedGravityType 538
-#define MGK_XServerErrorUnrecognizedVisualSpecifier 539
-#define MGK_XServerFatalErrorUnableToAllocateXHints 540
-#define MGK_XServerFatalErrorUnableToCreateCursor 541
-#define MGK_XServerFatalErrorUnableToCreateGraphicContext 542
-#define MGK_XServerFatalErrorUnableToCreateStandardColormap 543
-#define MGK_XServerFatalErrorUnableToCreateTextProperty 544
-#define MGK_XServerFatalErrorUnableToCreateXImage 545
-#define MGK_XServerFatalErrorUnableToCreateXPixmap 546
-#define MGK_XServerFatalErrorUnableToCreateXWindow 547
-#define MGK_XServerFatalErrorUnableToDisplayImage 548
-#define MGK_XServerFatalErrorUnableToDitherImage 549
-#define MGK_XServerFatalErrorUnableToGetPixelInfo 550
-#define MGK_XServerFatalErrorUnableToGetVisual 551
-#define MGK_XServerFatalErrorUnableToLoadFont 552
-#define MGK_XServerFatalErrorUnableToMakeXWindow 553
-#define MGK_XServerFatalErrorUnableToOpenXServer 554
-#define MGK_XServerFatalErrorUnableToViewFonts 555
-#define MGK_XServerWarningUnableToGetVisual 556
-#define MGK_XServerWarningUsingDefaultVisual 557
+#define MGK_BlobErrorUnableToDeduceImageFormat 2
+#define MGK_BlobErrorUnableToObtainOffset 3
+#define MGK_BlobErrorUnableToOpenFile 4
+#define MGK_BlobErrorUnableToReadFile 5
+#define MGK_BlobErrorUnableToReadToOffset 6
+#define MGK_BlobErrorUnableToSeekToOffset 7
+#define MGK_BlobErrorUnableToWriteBlob 8
+#define MGK_BlobErrorUnrecognizedImageFormat 9
+#define MGK_BlobFatalErrorDefault 10
+#define MGK_BlobWarningDefault 11
+#define MGK_CacheErrorInconsistentPersistentCacheDepth 12
+#define MGK_CacheErrorPixelCacheDimensionsMisMatch 13
+#define MGK_CacheErrorPixelCacheIsNotOpen 14
+#define MGK_CacheErrorUnableToAllocateCacheView 15
+#define MGK_CacheErrorUnableToCloneCache 16
+#define MGK_CacheErrorUnableToExtendCache 17
+#define MGK_CacheErrorUnableToGetCacheNexus 18
+#define MGK_CacheErrorUnableToGetPixelsFromCache 19
+#define MGK_CacheErrorUnableToOpenCache 20
+#define MGK_CacheErrorUnableToPeristPixelCache 21
+#define MGK_CacheErrorUnableToReadPixelCache 22
+#define MGK_CacheErrorUnableToSyncCache 23
+#define MGK_CacheFatalErrorDiskAllocationFailed 24
+#define MGK_CacheFatalErrorUnableToExtendPixelCache 25
+#define MGK_CacheWarningDefault 26
+#define MGK_CoderErrorArithmeticOverflow 27
+#define MGK_CoderErrorColormapTooLarge 28
+#define MGK_CoderErrorColormapTypeNotSupported 29
+#define MGK_CoderErrorColorspaceModelIsNotSupported 30
+#define MGK_CoderErrorColorTypeNotSupported 31
+#define MGK_CoderErrorCompressionNotValid 32
+#define MGK_CoderErrorDataEncodingSchemeIsNotSupported 33
+#define MGK_CoderErrorDataStorageTypeIsNotSupported 34
+#define MGK_CoderErrorDecodedImageNotReturned 35
+#define MGK_CoderErrorDeltaPNGNotSupported 36
+#define MGK_CoderErrorDivisionByZero 37
+#define MGK_CoderErrorEncryptedWPGImageFileNotSupported 38
+#define MGK_CoderErrorFractalCompressionNotSupported 39
+#define MGK_CoderErrorImageColumnOrRowSizeIsNotSupported 40
+#define MGK_CoderErrorImageDoesNotHaveAMatteChannel 41
+#define MGK_CoderErrorImageIsNotTiled 42
+#define MGK_CoderErrorImageTypeNotSupported 43
+#define MGK_CoderErrorIncompatibleSizeOfDouble 44
+#define MGK_CoderErrorIrregularChannelGeometryNotSupported 45
+#define MGK_CoderErrorJNGCompressionNotSupported 46
+#define MGK_CoderErrorJPEGCompressionNotSupported 47
+#define MGK_CoderErrorJPEGEmbeddingFailed 48
+#define MGK_CoderErrorLocationTypeIsNotSupported 49
+#define MGK_CoderErrorMapStorageTypeIsNotSupported 50
+#define MGK_CoderErrorMSBByteOrderNotSupported 51
+#define MGK_CoderErrorMultidimensionalMatricesAreNotSupported 52
+#define MGK_CoderErrorMultipleRecordListNotSupported 53
+#define MGK_CoderErrorNo8BIMDataIsAvailable 54
+#define MGK_CoderErrorNoAPP1DataIsAvailable 55
+#define MGK_CoderErrorNoBitmapOnClipboard 56
+#define MGK_CoderErrorNoColorProfileAvailable 57
+#define MGK_CoderErrorNoDataReturned 58
+#define MGK_CoderErrorNoImageVectorGraphics 59
+#define MGK_CoderErrorNoIPTCInfoWasFound 60
+#define MGK_CoderErrorNoIPTCProfileAvailable 61
+#define MGK_CoderErrorNumberOfImagesIsNotSupported 62
+#define MGK_CoderErrorOnlyContinuousTonePictureSupported 63
+#define MGK_CoderErrorOnlyLevelZerofilesSupported 64
+#define MGK_CoderErrorPNGCompressionNotSupported 65
+#define MGK_CoderErrorPNGLibraryTooOld 66
+#define MGK_CoderErrorRLECompressionNotSupported 67
+#define MGK_CoderErrorSubsamplingRequiresEvenWidth 68
+#define MGK_CoderErrorUnableToCopyProfile 69
+#define MGK_CoderErrorUnableToCreateADC 70
+#define MGK_CoderErrorUnableToCreateBitmap 71
+#define MGK_CoderErrorUnableToDecompressImage 72
+#define MGK_CoderErrorUnableToInitializeFPXLibrary 73
+#define MGK_CoderErrorUnableToOpenBlob 74
+#define MGK_CoderErrorUnableToReadAspectRatio 75
+#define MGK_CoderErrorUnableToReadCIELABImages 76
+#define MGK_CoderErrorUnableToReadSummaryInfo 77
+#define MGK_CoderErrorUnableToSetAffineMatrix 78
+#define MGK_CoderErrorUnableToSetAspectRatio 79
+#define MGK_CoderErrorUnableToSetColorTwist 80
+#define MGK_CoderErrorUnableToSetContrast 81
+#define MGK_CoderErrorUnableToSetFilteringValue 82
+#define MGK_CoderErrorUnableToSetImageComments 83
+#define MGK_CoderErrorUnableToSetImageTitle 84
+#define MGK_CoderErrorUnableToSetJPEGLevel 85
+#define MGK_CoderErrorUnableToSetRegionOfInterest 86
+#define MGK_CoderErrorUnableToSetSummaryInfo 87
+#define MGK_CoderErrorUnableToTranslateText 88
+#define MGK_CoderErrorUnableToWriteMPEGParameters 89
+#define MGK_CoderErrorUnableToWriteTemporaryFile 90
+#define MGK_CoderErrorUnableToZipCompressImage 91
+#define MGK_CoderErrorUnsupportedBitsPerSample 92
+#define MGK_CoderErrorUnsupportedCellTypeInTheMatrix 93
+#define MGK_CoderErrorUnsupportedSamplesPerPixel 94
+#define MGK_CoderErrorWebPDecodingFailedUserAbort 95
+#define MGK_CoderErrorWebPEncodingFailed 96
+#define MGK_CoderErrorWebPEncodingFailedBadDimension 97
+#define MGK_CoderErrorWebPEncodingFailedBadWrite 98
+#define MGK_CoderErrorWebPEncodingFailedBitstreamOutOfMemory 99
+#define MGK_CoderErrorWebPEncodingFailedFileTooBig 100
+#define MGK_CoderErrorWebPEncodingFailedInvalidConfiguration 101
+#define MGK_CoderErrorWebPEncodingFailedNULLParameter 102
+#define MGK_CoderErrorWebPEncodingFailedOutOfMemory 103
+#define MGK_CoderErrorWebPEncodingFailedPartition0Overflow 104
+#define MGK_CoderErrorWebPEncodingFailedPartitionOverflow 105
+#define MGK_CoderErrorWebPEncodingFailedUserAbort 106
+#define MGK_CoderErrorWebPInvalidConfiguration 107
+#define MGK_CoderErrorWebPInvalidParameter 108
+#define MGK_CoderErrorZipCompressionNotSupported 109
+#define MGK_CoderFatalErrorDefault 110
+#define MGK_CoderWarningLosslessToLossyJPEGConversion 111
+#define MGK_ConfigureErrorIncludeElementNestedTooDeeply 112
+#define MGK_ConfigureErrorRegistryKeyLookupFailed 113
+#define MGK_ConfigureErrorStringTokenLengthExceeded 114
+#define MGK_ConfigureErrorUnableToAccessConfigureFile 115
+#define MGK_ConfigureErrorUnableToAccessFontFile 116
+#define MGK_ConfigureErrorUnableToAccessLogFile 117
+#define MGK_ConfigureErrorUnableToAccessModuleFile 118
+#define MGK_ConfigureFatalErrorDefault 119
+#define MGK_ConfigureFatalErrorUnableToChangeToWorkingDirectory 120
+#define MGK_ConfigureFatalErrorUnableToGetCurrentDirectory 121
+#define MGK_ConfigureFatalErrorUnableToRestoreCurrentDirectory 122
+#define MGK_ConfigureWarningDefault 123
+#define MGK_CorruptImageErrorAnErrorHasOccurredReadingFromFile 124
+#define MGK_CorruptImageErrorAnErrorHasOccurredWritingToFile 125
+#define MGK_CorruptImageErrorColormapExceedsColorsLimit 126
+#define MGK_CorruptImageErrorCompressionNotValid 127
+#define MGK_CorruptImageErrorCorruptImage 128
+#define MGK_CorruptImageErrorImageFileDoesNotContainAnyImageData 129
+#define MGK_CorruptImageErrorImageFileHasNoScenes 130
+#define MGK_CorruptImageErrorImageTypeNotSupported 131
+#define MGK_CorruptImageErrorImproperImageHeader 132
+#define MGK_CorruptImageErrorInsufficientImageDataInFile 133
+#define MGK_CorruptImageErrorInvalidColormapIndex 134
+#define MGK_CorruptImageErrorInvalidFileFormatVersion 135
+#define MGK_CorruptImageErrorLengthAndFilesizeDoNotMatch 136
+#define MGK_CorruptImageErrorMissingImageChannel 137
+#define MGK_CorruptImageErrorNegativeOrZeroImageSize 138
+#define MGK_CorruptImageErrorNonOS2HeaderSizeError 139
+#define MGK_CorruptImageErrorNotEnoughTiles 140
+#define MGK_CorruptImageErrorStaticPlanesValueNotEqualToOne 141
+#define MGK_CorruptImageErrorSubsamplingRequiresEvenWidth 142
+#define MGK_CorruptImageErrorTooMuchImageDataInFile 143
+#define MGK_CorruptImageErrorUnableToReadColormapFromDumpFile 144
+#define MGK_CorruptImageErrorUnableToReadColorProfile 145
+#define MGK_CorruptImageErrorUnableToReadExtensionBlock 146
+#define MGK_CorruptImageErrorUnableToReadGenericProfile 147
+#define MGK_CorruptImageErrorUnableToReadImageData 148
+#define MGK_CorruptImageErrorUnableToReadImageHeader 149
+#define MGK_CorruptImageErrorUnableToReadIPTCProfile 150
+#define MGK_CorruptImageErrorUnableToReadPixmapFromDumpFile 151
+#define MGK_CorruptImageErrorUnableToReadSubImageData 152
+#define MGK_CorruptImageErrorUnableToReadVIDImage 153
+#define MGK_CorruptImageErrorUnableToReadWindowNameFromDumpFile 154
+#define MGK_CorruptImageErrorUnableToRunlengthDecodeImage 155
+#define MGK_CorruptImageErrorUnableToUncompressImage 156
+#define MGK_CorruptImageErrorUnexpectedEndOfFile 157
+#define MGK_CorruptImageErrorUnexpectedSamplingFactor 158
+#define MGK_CorruptImageErrorUnknownPatternType 159
+#define MGK_CorruptImageErrorUnrecognizedBitsPerPixel 160
+#define MGK_CorruptImageErrorUnrecognizedImageCompression 161
+#define MGK_CorruptImageErrorUnrecognizedNumberOfColors 162
+#define MGK_CorruptImageErrorUnrecognizedXWDHeader 163
+#define MGK_CorruptImageErrorUnsupportedBitsPerSample 164
+#define MGK_CorruptImageErrorUnsupportedNumberOfPlanes 165
+#define MGK_CorruptImageFatalErrorUnableToPersistKey 166
+#define MGK_CorruptImageWarningCompressionNotValid 167
+#define MGK_CorruptImageWarningCorruptImage 168
+#define MGK_CorruptImageWarningImproperImageHeader 169
+#define MGK_CorruptImageWarningInvalidColormapIndex 170
+#define MGK_CorruptImageWarningLengthAndFilesizeDoNotMatch 171
+#define MGK_CorruptImageWarningNegativeOrZeroImageSize 172
+#define MGK_CorruptImageWarningNonOS2HeaderSizeError 173
+#define MGK_CorruptImageWarningSkipToSyncByte 174
+#define MGK_CorruptImageWarningStaticPlanesValueNotEqualToOne 175
+#define MGK_CorruptImageWarningUnableToParseEmbeddedProfile 176
+#define MGK_CorruptImageWarningUnrecognizedBitsPerPixel 177
+#define MGK_CorruptImageWarningUnrecognizedImageCompression 178
+#define MGK_DelegateErrorDelegateFailed 179
+#define MGK_DelegateErrorFailedToAllocateArgumentList 180
+#define MGK_DelegateErrorFailedToAllocateGhostscriptInterpreter 181
+#define MGK_DelegateErrorFailedToComputeOutputSize 182
+#define MGK_DelegateErrorFailedToFindGhostscript 183
+#define MGK_DelegateErrorFailedToRenderFile 184
+#define MGK_DelegateErrorFailedToScanFile 185
+#define MGK_DelegateErrorNoTagFound 186
+#define MGK_DelegateErrorPostscriptDelegateFailed 187
+#define MGK_DelegateErrorUnableToCreateImage 188
+#define MGK_DelegateErrorUnableToCreateImageComponent 189
+#define MGK_DelegateErrorUnableToDecodeImageFile 190
+#define MGK_DelegateErrorUnableToEncodeImageFile 191
+#define MGK_DelegateErrorUnableToInitializeFPXLibrary 192
+#define MGK_DelegateErrorUnableToInitializeWMFLibrary 193
+#define MGK_DelegateErrorUnableToManageJP2Stream 194
+#define MGK_DelegateErrorUnableToWriteSVGFormat 195
+#define MGK_DelegateErrorWebPABIMismatch 196
+#define MGK_DelegateFatalErrorDefault 197
+#define MGK_DelegateWarningDefault 198
+#define MGK_DrawErrorAlreadyPushingPatternDefinition 199
+#define MGK_DrawErrorDrawingRecursionDetected 200
+#define MGK_DrawErrorFloatValueConversionError 201
+#define MGK_DrawErrorIntegerValueConversionError 202
+#define MGK_DrawErrorInvalidPrimitiveArgument 203
+#define MGK_DrawErrorNonconformingDrawingPrimitiveDefinition 204
+#define MGK_DrawErrorPrimitiveArithmeticOverflow 205
+#define MGK_DrawErrorTooManyCoordinates 206
+#define MGK_DrawErrorUnableToPrint 207
+#define MGK_DrawErrorUnbalancedGraphicContextPushPop 208
+#define MGK_DrawErrorUnreasonableGradientSize 209
+#define MGK_DrawErrorVectorPathTruncated 210
+#define MGK_DrawFatalErrorDefault 211
+#define MGK_DrawWarningNotARelativeURL 212
+#define MGK_DrawWarningNotCurrentlyPushingPatternDefinition 213
+#define MGK_DrawWarningURLNotFound 214
+#define MGK_FileOpenErrorUnableToCreateTemporaryFile 215
+#define MGK_FileOpenErrorUnableToOpenFile 216
+#define MGK_FileOpenErrorUnableToWriteFile 217
+#define MGK_FileOpenFatalErrorDefault 218
+#define MGK_FileOpenWarningDefault 219
+#define MGK_ImageErrorAngleIsDiscontinuous 220
+#define MGK_ImageErrorCMYKAImageLacksAlphaChannel 221
+#define MGK_ImageErrorColorspaceColorProfileMismatch 222
+#define MGK_ImageErrorImageColorspaceDiffers 223
+#define MGK_ImageErrorImageColorspaceMismatch 224
+#define MGK_ImageErrorImageDifferenceExceedsLimit 225
+#define MGK_ImageErrorImageDoesNotContainResolution 226
+#define MGK_ImageErrorImageIsNotColormapped 227
+#define MGK_ImageErrorImageOpacityDiffers 228
+#define MGK_ImageErrorImageSequenceIsRequired 229
+#define MGK_ImageErrorImageSizeDiffers 230
+#define MGK_ImageErrorInvalidColormapIndex 231
+#define MGK_ImageErrorLeftAndRightImageSizesDiffer 232
+#define MGK_ImageErrorNoImagesWereFound 233
+#define MGK_ImageErrorNoImagesWereLoaded 234
+#define MGK_ImageErrorNoLocaleImageAttribute 235
+#define MGK_ImageErrorTooManyClusters 236
+#define MGK_ImageErrorUnableToAppendImage 237
+#define MGK_ImageErrorUnableToAssignProfile 238
+#define MGK_ImageErrorUnableToAverageImage 239
+#define MGK_ImageErrorUnableToCoalesceImage 240
+#define MGK_ImageErrorUnableToCompareImages 241
+#define MGK_ImageErrorUnableToCreateImageMosaic 242
+#define MGK_ImageErrorUnableToCreateStereoImage 243
+#define MGK_ImageErrorUnableToDeconstructImageSequence 244
+#define MGK_ImageErrorUnableToExportImagePixels 245
+#define MGK_ImageErrorUnableToFlattenImage 246
+#define MGK_ImageErrorUnableToGetClipMask 247
+#define MGK_ImageErrorUnableToGetCompositeMask 248
+#define MGK_ImageErrorUnableToHandleImageChannel 249
+#define MGK_ImageErrorUnableToImportImagePixels 250
+#define MGK_ImageErrorUnableToResizeImage 251
+#define MGK_ImageErrorUnableToSegmentImage 252
+#define MGK_ImageErrorUnableToSetClipMask 253
+#define MGK_ImageErrorUnableToSetCompositeMask 254
+#define MGK_ImageErrorUnableToShearImage 255
+#define MGK_ImageErrorWidthOrHeightExceedsLimit 256
+#define MGK_ImageFatalErrorUnableToPersistKey 257
+#define MGK_ImageWarningDefault 258
+#define MGK_MissingDelegateErrorDPSLibraryIsNotAvailable 259
+#define MGK_MissingDelegateErrorFPXLibraryIsNotAvailable 260
+#define MGK_MissingDelegateErrorFreeTypeLibraryIsNotAvailable 261
+#define MGK_MissingDelegateErrorJPEGLibraryIsNotAvailable 262
+#define MGK_MissingDelegateErrorLCMSLibraryIsNotAvailable 263
+#define MGK_MissingDelegateErrorLZWEncodingNotEnabled 264
+#define MGK_MissingDelegateErrorNoDecodeDelegateForThisImageFormat 265
+#define MGK_MissingDelegateErrorNoEncodeDelegateForThisImageFormat 266
+#define MGK_MissingDelegateErrorTIFFLibraryIsNotAvailable 267
+#define MGK_MissingDelegateErrorXMLLibraryIsNotAvailable 268
+#define MGK_MissingDelegateErrorXWindowLibraryIsNotAvailable 269
+#define MGK_MissingDelegateErrorZipLibraryIsNotAvailable 270
+#define MGK_MissingDelegateFatalErrorDefault 271
+#define MGK_MissingDelegateWarningDefault 272
+#define MGK_ModuleErrorFailedToCloseModule 273
+#define MGK_ModuleErrorFailedToFindSymbol 274
+#define MGK_ModuleErrorUnableToLoadModule 275
+#define MGK_ModuleErrorUnableToRegisterImageFormat 276
+#define MGK_ModuleErrorUnrecognizedModule 277
+#define MGK_ModuleFatalErrorUnableToInitializeModuleLoader 278
+#define MGK_ModuleWarningDefault 279
+#define MGK_MonitorErrorDefault 280
+#define MGK_MonitorFatalErrorDefault 281
+#define MGK_MonitorFatalErrorUserRequestedTerminationBySignal 282
+#define MGK_MonitorWarningDefault 283
+#define MGK_OptionErrorBevelWidthIsNegative 284
+#define MGK_OptionErrorColorSeparatedImageRequired 285
+#define MGK_OptionErrorFrameIsLessThanImageSize 286
+#define MGK_OptionErrorGeometryDimensionsAreZero 287
+#define MGK_OptionErrorGeometryDoesNotContainImage 288
+#define MGK_OptionErrorHaldClutImageDimensionsInvalid 289
+#define MGK_OptionErrorImagesAreNotTheSameSize 290
+#define MGK_OptionErrorImageSizeMustExceedBevelWidth 291
+#define MGK_OptionErrorImageSmallerThanKernelWidth 292
+#define MGK_OptionErrorImageSmallerThanRadius 293
+#define MGK_OptionErrorImageWidthsOrHeightsDiffer 294
+#define MGK_OptionErrorInputImagesAlreadySpecified 295
+#define MGK_OptionErrorInvalidSubimageSpecification 296
+#define MGK_OptionErrorKernelRadiusIsTooSmall 297
+#define MGK_OptionErrorKernelWidthMustBeAnOddNumber 298
+#define MGK_OptionErrorMatrixIsNotSquare 299
+#define MGK_OptionErrorMatrixOrderOutOfRange 300
+#define MGK_OptionErrorMissingAnImageFilename 301
+#define MGK_OptionErrorMissingArgument 302
+#define MGK_OptionErrorMustSpecifyAnImageName 303
+#define MGK_OptionErrorMustSpecifyImageSize 304
+#define MGK_OptionErrorNoBlobDefined 305
+#define MGK_OptionErrorNoImagesDefined 306
+#define MGK_OptionErrorNonzeroWidthAndHeightRequired 307
+#define MGK_OptionErrorNoProfileNameWasGiven 308
+#define MGK_OptionErrorNullBlobArgument 309
+#define MGK_OptionErrorReferenceImageRequired 310
+#define MGK_OptionErrorReferenceIsNotMyType 311
+#define MGK_OptionErrorRegionAreaExceedsLimit 312
+#define MGK_OptionErrorRequestDidNotReturnAnImage 313
+#define MGK_OptionErrorSteganoImageRequired 314
+#define MGK_OptionErrorStereoImageRequired 315
+#define MGK_OptionErrorSubimageSpecificationReturnsNoImages 316
+#define MGK_OptionErrorTileNotBoundedByImageDimensions 317
+#define MGK_OptionErrorUnableToAddOrRemoveProfile 318
+#define MGK_OptionErrorUnableToAverageImageSequence 319
+#define MGK_OptionErrorUnableToBlurImage 320
+#define MGK_OptionErrorUnableToChopImage 321
+#define MGK_OptionErrorUnableToColorMatrixImage 322
+#define MGK_OptionErrorUnableToConstituteImage 323
+#define MGK_OptionErrorUnableToConvolveImage 324
+#define MGK_OptionErrorUnableToEdgeImage 325
+#define MGK_OptionErrorUnableToEqualizeImage 326
+#define MGK_OptionErrorUnableToFilterImage 327
+#define MGK_OptionErrorUnableToFormatImageMetadata 328
+#define MGK_OptionErrorUnableToFrameImage 329
+#define MGK_OptionErrorUnableToOilPaintImage 330
+#define MGK_OptionErrorUnableToPaintImage 331
+#define MGK_OptionErrorUnableToRaiseImage 332
+#define MGK_OptionErrorUnableToSharpenImage 333
+#define MGK_OptionErrorUnableToThresholdImage 334
+#define MGK_OptionErrorUnableToWaveImage 335
+#define MGK_OptionErrorUnrecognizedAttribute 336
+#define MGK_OptionErrorUnrecognizedChannelType 337
+#define MGK_OptionErrorUnrecognizedColor 338
+#define MGK_OptionErrorUnrecognizedColormapType 339
+#define MGK_OptionErrorUnrecognizedColorspace 340
+#define MGK_OptionErrorUnrecognizedCommand 341
+#define MGK_OptionErrorUnrecognizedComposeOperator 342
+#define MGK_OptionErrorUnrecognizedDisposeMethod 343
+#define MGK_OptionErrorUnrecognizedElement 344
+#define MGK_OptionErrorUnrecognizedEndianType 345
+#define MGK_OptionErrorUnrecognizedGravityType 346
+#define MGK_OptionErrorUnrecognizedHighlightStyle 347
+#define MGK_OptionErrorUnrecognizedImageCompression 348
+#define MGK_OptionErrorUnrecognizedImageFilter 349
+#define MGK_OptionErrorUnrecognizedImageFormat 350
+#define MGK_OptionErrorUnrecognizedImageMode 351
+#define MGK_OptionErrorUnrecognizedImageType 352
+#define MGK_OptionErrorUnrecognizedIntentType 353
+#define MGK_OptionErrorUnrecognizedInterlaceType 354
+#define MGK_OptionErrorUnrecognizedListType 355
+#define MGK_OptionErrorUnrecognizedMetric 356
+#define MGK_OptionErrorUnrecognizedModeType 357
+#define MGK_OptionErrorUnrecognizedNoiseType 358
+#define MGK_OptionErrorUnrecognizedOperator 359
+#define MGK_OptionErrorUnrecognizedOption 360
+#define MGK_OptionErrorUnrecognizedPerlMagickMethod 361
+#define MGK_OptionErrorUnrecognizedPixelMap 362
+#define MGK_OptionErrorUnrecognizedPreviewType 363
+#define MGK_OptionErrorUnrecognizedResourceType 364
+#define MGK_OptionErrorUnrecognizedType 365
+#define MGK_OptionErrorUnrecognizedUnitsType 366
+#define MGK_OptionErrorUnrecognizedVirtualPixelMethod 367
+#define MGK_OptionErrorUnsupportedSamplingFactor 368
+#define MGK_OptionErrorUsageError 369
+#define MGK_OptionFatalErrorInvalidColorspaceType 370
+#define MGK_OptionFatalErrorInvalidEndianType 371
+#define MGK_OptionFatalErrorInvalidImageType 372
+#define MGK_OptionFatalErrorInvalidInterlaceType 373
+#define MGK_OptionFatalErrorMissingAnImageFilename 374
+#define MGK_OptionFatalErrorMissingArgument 375
+#define MGK_OptionFatalErrorNoImagesWereLoaded 376
+#define MGK_OptionFatalErrorOptionLengthExceedsLimit 377
+#define MGK_OptionFatalErrorRequestDidNotReturnAnImage 378
+#define MGK_OptionFatalErrorUnableToOpenXServer 379
+#define MGK_OptionFatalErrorUnableToPersistKey 380
+#define MGK_OptionFatalErrorUnrecognizedColormapType 381
+#define MGK_OptionFatalErrorUnrecognizedColorspaceType 382
+#define MGK_OptionFatalErrorUnrecognizedDisposeMethod 383
+#define MGK_OptionFatalErrorUnrecognizedEndianType 384
+#define MGK_OptionFatalErrorUnrecognizedFilterType 385
+#define MGK_OptionFatalErrorUnrecognizedImageCompressionType 386
+#define MGK_OptionFatalErrorUnrecognizedImageType 387
+#define MGK_OptionFatalErrorUnrecognizedInterlaceType 388
+#define MGK_OptionFatalErrorUnrecognizedOption 389
+#define MGK_OptionFatalErrorUnrecognizedResourceType 390
+#define MGK_OptionFatalErrorUnrecognizedVirtualPixelMethod 391
+#define MGK_OptionWarningUnrecognizedColor 392
+#define MGK_RegistryErrorImageExpected 393
+#define MGK_RegistryErrorImageInfoExpected 394
+#define MGK_RegistryErrorStructureSizeMismatch 395
+#define MGK_RegistryErrorUnableToGetRegistryID 396
+#define MGK_RegistryErrorUnableToLocateImage 397
+#define MGK_RegistryErrorUnableToSetRegistry 398
+#define MGK_RegistryFatalErrorDefault 399
+#define MGK_RegistryWarningDefault 400
+#define MGK_ResourceLimitErrorCacheResourcesExhausted 401
+#define MGK_ResourceLimitErrorImagePixelHeightLimitExceeded 402
+#define MGK_ResourceLimitErrorImagePixelLimitExceeded 403
+#define MGK_ResourceLimitErrorImagePixelWidthLimitExceeded 404
+#define MGK_ResourceLimitErrorMemoryAllocationFailed 405
+#define MGK_ResourceLimitErrorNoPixelsDefinedInCache 406
+#define MGK_ResourceLimitErrorPixelCacheAllocationFailed 407
+#define MGK_ResourceLimitErrorUnableToAddColorProfile 408
+#define MGK_ResourceLimitErrorUnableToAddGenericProfile 409
+#define MGK_ResourceLimitErrorUnableToAddIPTCProfile 410
+#define MGK_ResourceLimitErrorUnableToAddOrRemoveProfile 411
+#define MGK_ResourceLimitErrorUnableToAllocateCoefficients 412
+#define MGK_ResourceLimitErrorUnableToAllocateColormap 413
+#define MGK_ResourceLimitErrorUnableToAllocateICCProfile 414
+#define MGK_ResourceLimitErrorUnableToAllocateImage 415
+#define MGK_ResourceLimitErrorUnableToAllocateString 416
+#define MGK_ResourceLimitErrorUnableToAnnotateImage 417
+#define MGK_ResourceLimitErrorUnableToAverageImageSequence 418
+#define MGK_ResourceLimitErrorUnableToCloneDrawingWand 419
+#define MGK_ResourceLimitErrorUnableToCloneImage 420
+#define MGK_ResourceLimitErrorUnableToComputeImageSignature 421
+#define MGK_ResourceLimitErrorUnableToConstituteImage 422
+#define MGK_ResourceLimitErrorUnableToConvertFont 423
+#define MGK_ResourceLimitErrorUnableToConvertStringToTokens 424
+#define MGK_ResourceLimitErrorUnableToCreateColormap 425
+#define MGK_ResourceLimitErrorUnableToCreateColorTransform 426
+#define MGK_ResourceLimitErrorUnableToCreateCommandWidget 427
+#define MGK_ResourceLimitErrorUnableToCreateImageGroup 428
+#define MGK_ResourceLimitErrorUnableToCreateImageMontage 429
+#define MGK_ResourceLimitErrorUnableToCreateXWindow 430
+#define MGK_ResourceLimitErrorUnableToCropImage 431
+#define MGK_ResourceLimitErrorUnableToDespeckleImage 432
+#define MGK_ResourceLimitErrorUnableToDetermineImageClass 433
+#define MGK_ResourceLimitErrorUnableToDetermineTheNumberOfImageColors 434
+#define MGK_ResourceLimitErrorUnableToDitherImage 435
+#define MGK_ResourceLimitErrorUnableToDrawOnImage 436
+#define MGK_ResourceLimitErrorUnableToEdgeImage 437
+#define MGK_ResourceLimitErrorUnableToEmbossImage 438
+#define MGK_ResourceLimitErrorUnableToEnhanceImage 439
+#define MGK_ResourceLimitErrorUnableToFloodfillImage 440
+#define MGK_ResourceLimitErrorUnableToGammaCorrectImage 441
+#define MGK_ResourceLimitErrorUnableToGetBestIconSize 442
+#define MGK_ResourceLimitErrorUnableToGetFromRegistry 443
+#define MGK_ResourceLimitErrorUnableToGetPackageInfo 444
+#define MGK_ResourceLimitErrorUnableToLevelImage 445
+#define MGK_ResourceLimitErrorUnableToMagnifyImage 446
+#define MGK_ResourceLimitErrorUnableToManageColor 447
+#define MGK_ResourceLimitErrorUnableToMapImage 448
+#define MGK_ResourceLimitErrorUnableToMapImageSequence 449
+#define MGK_ResourceLimitErrorUnableToMedianFilterImage 450
+#define MGK_ResourceLimitErrorUnableToMotionBlurImage 451
+#define MGK_ResourceLimitErrorUnableToNoiseFilterImage 452
+#define MGK_ResourceLimitErrorUnableToNormalizeImage 453
+#define MGK_ResourceLimitErrorUnableToOpenColorProfile 454
+#define MGK_ResourceLimitErrorUnableToQuantizeImage 455
+#define MGK_ResourceLimitErrorUnableToQuantizeImageSequence 456
+#define MGK_ResourceLimitErrorUnableToReadTextChunk 457
+#define MGK_ResourceLimitErrorUnableToReadXImage 458
+#define MGK_ResourceLimitErrorUnableToReadXServerColormap 459
+#define MGK_ResourceLimitErrorUnableToResizeImage 460
+#define MGK_ResourceLimitErrorUnableToRotateImage 461
+#define MGK_ResourceLimitErrorUnableToSampleImage 462
+#define MGK_ResourceLimitErrorUnableToScaleImage 463
+#define MGK_ResourceLimitErrorUnableToSelectImage 464
+#define MGK_ResourceLimitErrorUnableToSharpenImage 465
+#define MGK_ResourceLimitErrorUnableToShaveImage 466
+#define MGK_ResourceLimitErrorUnableToShearImage 467
+#define MGK_ResourceLimitErrorUnableToSortImageColormap 468
+#define MGK_ResourceLimitErrorUnableToThresholdImage 469
+#define MGK_ResourceLimitErrorUnableToTransformColorspace 470
+#define MGK_ResourceLimitFatalErrorMemoryAllocationFailed 471
+#define MGK_ResourceLimitFatalErrorSemaporeOperationFailed 472
+#define MGK_ResourceLimitFatalErrorUnableToAllocateAscii85Info 473
+#define MGK_ResourceLimitFatalErrorUnableToAllocateCacheInfo 474
+#define MGK_ResourceLimitFatalErrorUnableToAllocateCacheView 475
+#define MGK_ResourceLimitFatalErrorUnableToAllocateColorInfo 476
+#define MGK_ResourceLimitFatalErrorUnableToAllocateDashPattern 477
+#define MGK_ResourceLimitFatalErrorUnableToAllocateDelegateInfo 478
+#define MGK_ResourceLimitFatalErrorUnableToAllocateDerivatives 479
+#define MGK_ResourceLimitFatalErrorUnableToAllocateDrawContext 480
+#define MGK_ResourceLimitFatalErrorUnableToAllocateDrawInfo 481
+#define MGK_ResourceLimitFatalErrorUnableToAllocateDrawingWand 482
+#define MGK_ResourceLimitFatalErrorUnableToAllocateGammaMap 483
+#define MGK_ResourceLimitFatalErrorUnableToAllocateImage 484
+#define MGK_ResourceLimitFatalErrorUnableToAllocateImagePixels 485
+#define MGK_ResourceLimitFatalErrorUnableToAllocateLogInfo 486
+#define MGK_ResourceLimitFatalErrorUnableToAllocateMagicInfo 487
+#define MGK_ResourceLimitFatalErrorUnableToAllocateMagickInfo 488
+#define MGK_ResourceLimitFatalErrorUnableToAllocateMagickMap 489
+#define MGK_ResourceLimitFatalErrorUnableToAllocateModuleInfo 490
+#define MGK_ResourceLimitFatalErrorUnableToAllocateMontageInfo 491
+#define MGK_ResourceLimitFatalErrorUnableToAllocateQuantizeInfo 492
+#define MGK_ResourceLimitFatalErrorUnableToAllocateRandomKernel 493
+#define MGK_ResourceLimitFatalErrorUnableToAllocateRegistryInfo 494
+#define MGK_ResourceLimitFatalErrorUnableToAllocateSemaphoreInfo 495
+#define MGK_ResourceLimitFatalErrorUnableToAllocateString 496
+#define MGK_ResourceLimitFatalErrorUnableToAllocateTypeInfo 497
+#define MGK_ResourceLimitFatalErrorUnableToAllocateWand 498
+#define MGK_ResourceLimitFatalErrorUnableToAnimateImageSequence 499
+#define MGK_ResourceLimitFatalErrorUnableToCloneBlobInfo 500
+#define MGK_ResourceLimitFatalErrorUnableToCloneCacheInfo 501
+#define MGK_ResourceLimitFatalErrorUnableToCloneImage 502
+#define MGK_ResourceLimitFatalErrorUnableToCloneImageInfo 503
+#define MGK_ResourceLimitFatalErrorUnableToConcatenateString 504
+#define MGK_ResourceLimitFatalErrorUnableToConvertText 505
+#define MGK_ResourceLimitFatalErrorUnableToCreateColormap 506
+#define MGK_ResourceLimitFatalErrorUnableToDestroySemaphore 507
+#define MGK_ResourceLimitFatalErrorUnableToDisplayImage 508
+#define MGK_ResourceLimitFatalErrorUnableToEscapeString 509
+#define MGK_ResourceLimitFatalErrorUnableToInitializeSemaphore 510
+#define MGK_ResourceLimitFatalErrorUnableToInterpretMSLImage 511
+#define MGK_ResourceLimitFatalErrorUnableToLockSemaphore 512
+#define MGK_ResourceLimitFatalErrorUnableToObtainRandomEntropy 513
+#define MGK_ResourceLimitFatalErrorUnableToUnlockSemaphore 514
+#define MGK_ResourceLimitWarningMemoryAllocationFailed 515
+#define MGK_StreamErrorImageDoesNotContainTheStreamGeometry 516
+#define MGK_StreamErrorNoStreamHandlerIsDefined 517
+#define MGK_StreamErrorPixelCacheIsNotOpen 518
+#define MGK_StreamErrorUnableToAcquirePixelStream 519
+#define MGK_StreamErrorUnableToSetPixelStream 520
+#define MGK_StreamErrorUnableToSyncPixelStream 521
+#define MGK_StreamFatalErrorDefault 522
+#define MGK_StreamWarningDefault 523
+#define MGK_TypeErrorFontNotSpecified 524
+#define MGK_TypeErrorFontSubstitutionRequired 525
+#define MGK_TypeErrorUnableToGetTypeMetrics 526
+#define MGK_TypeErrorUnableToInitializeFreetypeLibrary 527
+#define MGK_TypeErrorUnableToReadFont 528
+#define MGK_TypeErrorUnrecognizedFontEncoding 529
+#define MGK_TypeFatalErrorDefault 530
+#define MGK_TypeWarningDefault 531
+#define MGK_WandErrorInvalidColormapIndex 532
+#define MGK_WandErrorWandAPINotImplemented 533
+#define MGK_WandErrorWandContainsNoImageIndexs 534
+#define MGK_WandErrorWandContainsNoImages 535
+#define MGK_XServerErrorColorIsNotKnownToServer 536
+#define MGK_XServerErrorNoWindowWithSpecifiedIDExists 537
+#define MGK_XServerErrorStandardColormapIsNotInitialized 538
+#define MGK_XServerErrorUnableToConnectToRemoteDisplay 539
+#define MGK_XServerErrorUnableToCreateBitmap 540
+#define MGK_XServerErrorUnableToCreateColormap 541
+#define MGK_XServerErrorUnableToCreatePixmap 542
+#define MGK_XServerErrorUnableToCreateProperty 543
+#define MGK_XServerErrorUnableToCreateStandardColormap 544
+#define MGK_XServerErrorUnableToDisplayImageInfo 545
+#define MGK_XServerErrorUnableToGetProperty 546
+#define MGK_XServerErrorUnableToGetStandardColormap 547
+#define MGK_XServerErrorUnableToGetVisual 548
+#define MGK_XServerErrorUnableToGrabMouse 549
+#define MGK_XServerErrorUnableToLoadFont 550
+#define MGK_XServerErrorUnableToMatchVisualToStandardColormap 551
+#define MGK_XServerErrorUnableToOpenXServer 552
+#define MGK_XServerErrorUnableToReadXAttributes 553
+#define MGK_XServerErrorUnableToReadXWindowImage 554
+#define MGK_XServerErrorUnrecognizedColormapType 555
+#define MGK_XServerErrorUnrecognizedGravityType 556
+#define MGK_XServerErrorUnrecognizedVisualSpecifier 557
+#define MGK_XServerFatalErrorUnableToAllocateXHints 558
+#define MGK_XServerFatalErrorUnableToCreateCursor 559
+#define MGK_XServerFatalErrorUnableToCreateGraphicContext 560
+#define MGK_XServerFatalErrorUnableToCreateStandardColormap 561
+#define MGK_XServerFatalErrorUnableToCreateTextProperty 562
+#define MGK_XServerFatalErrorUnableToCreateXImage 563
+#define MGK_XServerFatalErrorUnableToCreateXPixmap 564
+#define MGK_XServerFatalErrorUnableToCreateXWindow 565
+#define MGK_XServerFatalErrorUnableToDisplayImage 566
+#define MGK_XServerFatalErrorUnableToDitherImage 567
+#define MGK_XServerFatalErrorUnableToGetPixelInfo 568
+#define MGK_XServerFatalErrorUnableToGetVisual 569
+#define MGK_XServerFatalErrorUnableToLoadFont 570
+#define MGK_XServerFatalErrorUnableToMakeXWindow 571
+#define MGK_XServerFatalErrorUnableToOpenXServer 572
+#define MGK_XServerFatalErrorUnableToViewFonts 573
+#define MGK_XServerWarningUnableToGetVisual 574
+#define MGK_XServerWarningUsingDefaultVisual 575
 
 #endif
 
@@ -606,61 +624,61 @@ typedef struct _SeverityInfo{
 static const SeverityInfo severity_map[] =
   {
     { "Blob/Error", 0, BlobError },
-    { "Blob/FatalError", 8, BlobFatalError },
-    { "Blob/Warning", 9, BlobWarning },
-    { "Cache/Error", 10, CacheError },
-    { "Cache/FatalError", 21, CacheFatalError },
-    { "Cache/Warning", 23, CacheWarning },
-    { "Coder/Error", 24, CoderError },
-    { "Coder/FatalError", 103, CoderFatalError },
-    { "Coder/Warning", 104, CoderWarning },
-    { "Configure/Error", 105, ConfigureError },
-    { "Configure/FatalError", 112, ConfigureFatalError },
-    { "Configure/Warning", 116, ConfigureWarning },
-    { "Corrupt/Image/Error", 117, CorruptImageError },
-    { "Corrupt/Image/FatalError", 158, CorruptImageFatalError },
-    { "Corrupt/Image/Warning", 159, CorruptImageWarning },
-    { "Delegate/Error", 170, DelegateError },
-    { "Delegate/FatalError", 188, DelegateFatalError },
-    { "Delegate/Warning", 189, DelegateWarning },
-    { "Draw/Error", 190, DrawError },
-    { "Draw/FatalError", 202, DrawFatalError },
-    { "Draw/Warning", 203, DrawWarning },
-    { "File/Open/Error", 206, FileOpenError },
-    { "File/Open/FatalError", 209, FileOpenFatalError },
-    { "File/Open/Warning", 210, FileOpenWarning },
-    { "Image/Error", 211, ImageError },
-    { "Image/FatalError", 242, ImageFatalError },
-    { "Image/Warning", 243, ImageWarning },
-    { "Missing/Delegate/Error", 244, MissingDelegateError },
-    { "Missing/Delegate/FatalError", 256, MissingDelegateFatalError },
-    { "Missing/Delegate/Warning", 257, MissingDelegateWarning },
-    { "Module/Error", 258, ModuleError },
-    { "Module/FatalError", 263, ModuleFatalError },
-    { "Module/Warning", 264, ModuleWarning },
-    { "Monitor/Error", 265, MonitorError },
-    { "Monitor/FatalError", 266, MonitorFatalError },
-    { "Monitor/Warning", 268, MonitorWarning },
-    { "Option/Error", 269, OptionError },
-    { "Option/FatalError", 354, OptionFatalError },
-    { "Option/Warning", 376, OptionWarning },
-    { "Registry/Error", 377, RegistryError },
-    { "Registry/FatalError", 383, RegistryFatalError },
-    { "Registry/Warning", 384, RegistryWarning },
-    { "Resource/Limit/Error", 385, ResourceLimitError },
-    { "Resource/Limit/FatalError", 454, ResourceLimitFatalError },
-    { "Resource/Limit/Warning", 497, ResourceLimitWarning },
-    { "Stream/Error", 498, StreamError },
-    { "Stream/FatalError", 504, StreamFatalError },
-    { "Stream/Warning", 505, StreamWarning },
-    { "Type/Error", 506, TypeError },
-    { "Type/FatalError", 511, TypeFatalError },
-    { "Type/Warning", 512, TypeWarning },
-    { "Wand/Error", 513, WandError },
-    { "XServer/Error", 517, XServerError },
-    { "XServer/FatalError", 539, XServerFatalError },
-    { "XServer/Warning", 555, XServerWarning },
-    { 0, 557, UndefinedException }
+    { "Blob/FatalError", 9, BlobFatalError },
+    { "Blob/Warning", 10, BlobWarning },
+    { "Cache/Error", 11, CacheError },
+    { "Cache/FatalError", 23, CacheFatalError },
+    { "Cache/Warning", 25, CacheWarning },
+    { "Coder/Error", 26, CoderError },
+    { "Coder/FatalError", 109, CoderFatalError },
+    { "Coder/Warning", 110, CoderWarning },
+    { "Configure/Error", 111, ConfigureError },
+    { "Configure/FatalError", 118, ConfigureFatalError },
+    { "Configure/Warning", 122, ConfigureWarning },
+    { "Corrupt/Image/Error", 123, CorruptImageError },
+    { "Corrupt/Image/FatalError", 165, CorruptImageFatalError },
+    { "Corrupt/Image/Warning", 166, CorruptImageWarning },
+    { "Delegate/Error", 178, DelegateError },
+    { "Delegate/FatalError", 196, DelegateFatalError },
+    { "Delegate/Warning", 197, DelegateWarning },
+    { "Draw/Error", 198, DrawError },
+    { "Draw/FatalError", 210, DrawFatalError },
+    { "Draw/Warning", 211, DrawWarning },
+    { "File/Open/Error", 214, FileOpenError },
+    { "File/Open/FatalError", 217, FileOpenFatalError },
+    { "File/Open/Warning", 218, FileOpenWarning },
+    { "Image/Error", 219, ImageError },
+    { "Image/FatalError", 256, ImageFatalError },
+    { "Image/Warning", 257, ImageWarning },
+    { "Missing/Delegate/Error", 258, MissingDelegateError },
+    { "Missing/Delegate/FatalError", 270, MissingDelegateFatalError },
+    { "Missing/Delegate/Warning", 271, MissingDelegateWarning },
+    { "Module/Error", 272, ModuleError },
+    { "Module/FatalError", 277, ModuleFatalError },
+    { "Module/Warning", 278, ModuleWarning },
+    { "Monitor/Error", 279, MonitorError },
+    { "Monitor/FatalError", 280, MonitorFatalError },
+    { "Monitor/Warning", 282, MonitorWarning },
+    { "Option/Error", 283, OptionError },
+    { "Option/FatalError", 369, OptionFatalError },
+    { "Option/Warning", 391, OptionWarning },
+    { "Registry/Error", 392, RegistryError },
+    { "Registry/FatalError", 398, RegistryFatalError },
+    { "Registry/Warning", 399, RegistryWarning },
+    { "Resource/Limit/Error", 400, ResourceLimitError },
+    { "Resource/Limit/FatalError", 470, ResourceLimitFatalError },
+    { "Resource/Limit/Warning", 514, ResourceLimitWarning },
+    { "Stream/Error", 515, StreamError },
+    { "Stream/FatalError", 521, StreamFatalError },
+    { "Stream/Warning", 522, StreamWarning },
+    { "Type/Error", 523, TypeError },
+    { "Type/FatalError", 529, TypeFatalError },
+    { "Type/Warning", 530, TypeWarning },
+    { "Wand/Error", 531, WandError },
+    { "XServer/Error", 535, XServerError },
+    { "XServer/FatalError", 557, XServerFatalError },
+    { "XServer/Warning", 573, XServerWarning },
+    { 0, 575, UndefinedException }
   };
 #endif
 
@@ -674,562 +692,580 @@ typedef struct _MessageInfo
 static const MessageInfo message_map[] =
   {
     { "UnableToCreateBlob", 1 },
-    { "UnableToObtainOffset", 2 },
-    { "UnableToOpenFile", 3 },
-    { "UnableToReadFile", 4 },
-    { "UnableToReadToOffset", 5 },
-    { "UnableToSeekToOffset", 6 },
-    { "UnableToWriteBlob", 7 },
-    { "UnrecognizedImageFormat", 8 },
-    { "Default", 9 },
+    { "UnableToDeduceImageFormat", 2 },
+    { "UnableToObtainOffset", 3 },
+    { "UnableToOpenFile", 4 },
+    { "UnableToReadFile", 5 },
+    { "UnableToReadToOffset", 6 },
+    { "UnableToSeekToOffset", 7 },
+    { "UnableToWriteBlob", 8 },
+    { "UnrecognizedImageFormat", 9 },
     { "Default", 10 },
-    { "InconsistentPersistentCacheDepth", 11 },
-    { "PixelCacheIsNotOpen", 12 },
-    { "UnableToAllocateCacheView", 13 },
-    { "UnableToCloneCache", 14 },
-    { "UnableToExtendCache", 15 },
-    { "UnableToGetCacheNexus", 16 },
-    { "UnableToGetPixelsFromCache", 17 },
-    { "UnableToOpenCache", 18 },
-    { "UnableToPeristPixelCache", 19 },
-    { "UnableToReadPixelCache", 20 },
-    { "UnableToSyncCache", 21 },
-    { "DiskAllocationFailed", 22 },
-    { "UnableToExtendPixelCache", 23 },
-    { "Default", 24 },
-    { "ColormapTooLarge", 25 },
-    { "ColormapTypeNotSupported", 26 },
-    { "ColorspaceModelIsNotSupported", 27 },
-    { "ColorTypeNotSupported", 28 },
-    { "CompressionNotValid", 29 },
-    { "DataEncodingSchemeIsNotSupported", 30 },
-    { "DataStorageTypeIsNotSupported", 31 },
-    { "DeltaPNGNotSupported", 32 },
-    { "EncryptedWPGImageFileNotSupported", 33 },
-    { "FractalCompressionNotSupported", 34 },
-    { "ImageColumnOrRowSizeIsNotSupported", 35 },
-    { "ImageDoesNotHaveAMatteChannel", 36 },
-    { "ImageIsNotTiled", 37 },
-    { "ImageTypeNotSupported", 38 },
-    { "IncompatibleSizeOfDouble", 39 },
-    { "IrregularChannelGeometryNotSupported", 40 },
-    { "JNGCompressionNotSupported", 41 },
-    { "JPEGCompressionNotSupported", 42 },
-    { "JPEGEmbeddingFailed", 43 },
-    { "LocationTypeIsNotSupported", 44 },
-    { "MapStorageTypeIsNotSupported", 45 },
-    { "MSBByteOrderNotSupported", 46 },
-    { "MultidimensionalMatricesAreNotSupported", 47 },
-    { "MultipleRecordListNotSupported", 48 },
-    { "No8BIMDataIsAvailable", 49 },
-    { "NoAPP1DataIsAvailable", 50 },
-    { "NoBitmapOnClipboard", 51 },
-    { "NoColorProfileAvailable", 52 },
-    { "NoDataReturned", 53 },
-    { "NoImageVectorGraphics", 54 },
-    { "NoIPTCInfoWasFound", 55 },
-    { "NoIPTCProfileAvailable", 56 },
-    { "NumberOfImagesIsNotSupported", 57 },
-    { "OnlyContinuousTonePictureSupported", 58 },
-    { "OnlyLevelZerofilesSupported", 59 },
-    { "PNGCompressionNotSupported", 60 },
-    { "PNGLibraryTooOld", 61 },
-    { "RLECompressionNotSupported", 62 },
-    { "SubsamplingRequiresEvenWidth", 63 },
-    { "UnableToCopyProfile", 64 },
-    { "UnableToCreateADC", 65 },
-    { "UnableToCreateBitmap", 66 },
-    { "UnableToDecompressImage", 67 },
-    { "UnableToInitializeFPXLibrary", 68 },
-    { "UnableToOpenBlob", 69 },
-    { "UnableToReadAspectRatio", 70 },
-    { "UnableToReadCIELABImages", 71 },
-    { "UnableToReadSummaryInfo", 72 },
-    { "UnableToSetAffineMatrix", 73 },
-    { "UnableToSetAspectRatio", 74 },
-    { "UnableToSetColorTwist", 75 },
-    { "UnableToSetContrast", 76 },
-    { "UnableToSetFilteringValue", 77 },
-    { "UnableToSetImageComments", 78 },
-    { "UnableToSetImageTitle", 79 },
-    { "UnableToSetJPEGLevel", 80 },
-    { "UnableToSetRegionOfInterest", 81 },
-    { "UnableToSetSummaryInfo", 82 },
-    { "UnableToTranslateText", 83 },
-    { "UnableToWriteMPEGParameters", 84 },
-    { "UnableToWriteTemporaryFile", 85 },
-    { "UnableToZipCompressImage", 86 },
-    { "UnsupportedBitsPerSample", 87 },
-    { "UnsupportedCellTypeInTheMatrix", 88 },
-    { "WebPDecodingFailedUserAbort", 89 },
-    { "WebPEncodingFailed", 90 },
-    { "WebPEncodingFailedBadDimension", 91 },
-    { "WebPEncodingFailedBadWrite", 92 },
-    { "WebPEncodingFailedBitstreamOutOfMemory", 93 },
-    { "WebPEncodingFailedFileTooBig", 94 },
-    { "WebPEncodingFailedInvalidConfiguration", 95 },
-    { "WebPEncodingFailedNULLParameter", 96 },
-    { "WebPEncodingFailedOutOfMemory", 97 },
-    { "WebPEncodingFailedPartition0Overflow", 98 },
-    { "WebPEncodingFailedPartitionOverflow", 99 },
-    { "WebPEncodingFailedUserAbort", 100 },
-    { "WebPInvalidConfiguration", 101 },
-    { "WebPInvalidParameter", 102 },
-    { "ZipCompressionNotSupported", 103 },
-    { "Default", 104 },
-    { "LosslessToLossyJPEGConversion", 105 },
-    { "IncludeElementNestedTooDeeply", 106 },
-    { "RegistryKeyLookupFailed", 107 },
-    { "StringTokenLengthExceeded", 108 },
-    { "UnableToAccessConfigureFile", 109 },
-    { "UnableToAccessFontFile", 110 },
-    { "UnableToAccessLogFile", 111 },
-    { "UnableToAccessModuleFile", 112 },
-    { "Default", 113 },
-    { "UnableToChangeToWorkingDirectory", 114 },
-    { "UnableToGetCurrentDirectory", 115 },
-    { "UnableToRestoreCurrentDirectory", 116 },
-    { "Default", 117 },
-    { "AnErrorHasOccurredReadingFromFile", 118 },
-    { "AnErrorHasOccurredWritingToFile", 119 },
-    { "ColormapExceedsColorsLimit", 120 },
-    { "CompressionNotValid", 121 },
-    { "CorruptImage", 122 },
-    { "ImageFileDoesNotContainAnyImageData", 123 },
-    { "ImageTypeNotSupported", 124 },
-    { "ImproperImageHeader", 125 },
-    { "InsufficientImageDataInFile", 126 },
-    { "InvalidColormapIndex", 127 },
-    { "InvalidFileFormatVersion", 128 },
-    { "LengthAndFilesizeDoNotMatch", 129 },
-    { "MissingImageChannel", 130 },
-    { "NegativeOrZeroImageSize", 131 },
-    { "NonOS2HeaderSizeError", 132 },
-    { "NotEnoughTiles", 133 },
-    { "StaticPlanesValueNotEqualToOne", 134 },
-    { "SubsamplingRequiresEvenWidth", 135 },
-    { "TooMuchImageDataInFile", 136 },
-    { "UnableToReadColormapFromDumpFile", 137 },
-    { "UnableToReadColorProfile", 138 },
-    { "UnableToReadExtensionBlock", 139 },
-    { "UnableToReadGenericProfile", 140 },
-    { "UnableToReadImageData", 141 },
-    { "UnableToReadImageHeader", 142 },
-    { "UnableToReadIPTCProfile", 143 },
-    { "UnableToReadPixmapFromDumpFile", 144 },
-    { "UnableToReadSubImageData", 145 },
-    { "UnableToReadVIDImage", 146 },
-    { "UnableToReadWindowNameFromDumpFile", 147 },
-    { "UnableToRunlengthDecodeImage", 148 },
-    { "UnableToUncompressImage", 149 },
-    { "UnexpectedEndOfFile", 150 },
-    { "UnexpectedSamplingFactor", 151 },
-    { "UnknownPatternType", 152 },
-    { "UnrecognizedBitsPerPixel", 153 },
-    { "UnrecognizedImageCompression", 154 },
-    { "UnrecognizedNumberOfColors", 155 },
-    { "UnrecognizedXWDHeader", 156 },
-    { "UnsupportedBitsPerSample", 157 },
-    { "UnsupportedNumberOfPlanes", 158 },
-    { "UnableToPersistKey", 159 },
-    { "CompressionNotValid", 160 },
-    { "CorruptImage", 161 },
-    { "ImproperImageHeader", 162 },
-    { "InvalidColormapIndex", 163 },
-    { "LengthAndFilesizeDoNotMatch", 164 },
-    { "NegativeOrZeroImageSize", 165 },
-    { "NonOS2HeaderSizeError", 166 },
-    { "SkipToSyncByte", 167 },
-    { "StaticPlanesValueNotEqualToOne", 168 },
-    { "UnrecognizedBitsPerPixel", 169 },
-    { "UnrecognizedImageCompression", 170 },
-    { "DelegateFailed", 171 },
-    { "FailedToAllocateArgumentList", 172 },
-    { "FailedToAllocateGhostscriptInterpreter", 173 },
-    { "FailedToComputeOutputSize", 174 },
-    { "FailedToFindGhostscript", 175 },
-    { "FailedToRenderFile", 176 },
-    { "FailedToScanFile", 177 },
-    { "NoTagFound", 178 },
-    { "PostscriptDelegateFailed", 179 },
-    { "UnableToCreateImage", 180 },
-    { "UnableToCreateImageComponent", 181 },
-    { "UnableToDecodeImageFile", 182 },
-    { "UnableToEncodeImageFile", 183 },
-    { "UnableToInitializeFPXLibrary", 184 },
-    { "UnableToInitializeWMFLibrary", 185 },
-    { "UnableToManageJP2Stream", 186 },
-    { "UnableToWriteSVGFormat", 187 },
-    { "WebPABIMismatch", 188 },
-    { "Default", 189 },
-    { "Default", 190 },
-    { "AlreadyPushingPatternDefinition", 191 },
-    { "DrawingRecursionDetected", 192 },
-    { "FloatValueConversionError", 193 },
-    { "IntegerValueConversionError", 194 },
-    { "InvalidPrimitiveArgument", 195 },
-    { "NonconformingDrawingPrimitiveDefinition", 196 },
-    { "PrimitiveArithmeticOverflow", 197 },
-    { "TooManyCoordinates", 198 },
-    { "UnableToPrint", 199 },
-    { "UnbalancedGraphicContextPushPop", 200 },
-    { "UnreasonableGradientSize", 201 },
-    { "VectorPathTruncated", 202 },
-    { "Default", 203 },
-    { "NotARelativeURL", 204 },
-    { "NotCurrentlyPushingPatternDefinition", 205 },
-    { "URLNotFound", 206 },
-    { "UnableToCreateTemporaryFile", 207 },
-    { "UnableToOpenFile", 208 },
-    { "UnableToWriteFile", 209 },
-    { "Default", 210 },
+    { "Default", 11 },
+    { "InconsistentPersistentCacheDepth", 12 },
+    { "PixelCacheDimensionsMisMatch", 13 },
+    { "PixelCacheIsNotOpen", 14 },
+    { "UnableToAllocateCacheView", 15 },
+    { "UnableToCloneCache", 16 },
+    { "UnableToExtendCache", 17 },
+    { "UnableToGetCacheNexus", 18 },
+    { "UnableToGetPixelsFromCache", 19 },
+    { "UnableToOpenCache", 20 },
+    { "UnableToPeristPixelCache", 21 },
+    { "UnableToReadPixelCache", 22 },
+    { "UnableToSyncCache", 23 },
+    { "DiskAllocationFailed", 24 },
+    { "UnableToExtendPixelCache", 25 },
+    { "Default", 26 },
+    { "ArithmeticOverflow", 27 },
+    { "ColormapTooLarge", 28 },
+    { "ColormapTypeNotSupported", 29 },
+    { "ColorspaceModelIsNotSupported", 30 },
+    { "ColorTypeNotSupported", 31 },
+    { "CompressionNotValid", 32 },
+    { "DataEncodingSchemeIsNotSupported", 33 },
+    { "DataStorageTypeIsNotSupported", 34 },
+    { "DecodedImageNotReturned", 35 },
+    { "DeltaPNGNotSupported", 36 },
+    { "DivisionByZero", 37 },
+    { "EncryptedWPGImageFileNotSupported", 38 },
+    { "FractalCompressionNotSupported", 39 },
+    { "ImageColumnOrRowSizeIsNotSupported", 40 },
+    { "ImageDoesNotHaveAMatteChannel", 41 },
+    { "ImageIsNotTiled", 42 },
+    { "ImageTypeNotSupported", 43 },
+    { "IncompatibleSizeOfDouble", 44 },
+    { "IrregularChannelGeometryNotSupported", 45 },
+    { "JNGCompressionNotSupported", 46 },
+    { "JPEGCompressionNotSupported", 47 },
+    { "JPEGEmbeddingFailed", 48 },
+    { "LocationTypeIsNotSupported", 49 },
+    { "MapStorageTypeIsNotSupported", 50 },
+    { "MSBByteOrderNotSupported", 51 },
+    { "MultidimensionalMatricesAreNotSupported", 52 },
+    { "MultipleRecordListNotSupported", 53 },
+    { "No8BIMDataIsAvailable", 54 },
+    { "NoAPP1DataIsAvailable", 55 },
+    { "NoBitmapOnClipboard", 56 },
+    { "NoColorProfileAvailable", 57 },
+    { "NoDataReturned", 58 },
+    { "NoImageVectorGraphics", 59 },
+    { "NoIPTCInfoWasFound", 60 },
+    { "NoIPTCProfileAvailable", 61 },
+    { "NumberOfImagesIsNotSupported", 62 },
+    { "OnlyContinuousTonePictureSupported", 63 },
+    { "OnlyLevelZerofilesSupported", 64 },
+    { "PNGCompressionNotSupported", 65 },
+    { "PNGLibraryTooOld", 66 },
+    { "RLECompressionNotSupported", 67 },
+    { "SubsamplingRequiresEvenWidth", 68 },
+    { "UnableToCopyProfile", 69 },
+    { "UnableToCreateADC", 70 },
+    { "UnableToCreateBitmap", 71 },
+    { "UnableToDecompressImage", 72 },
+    { "UnableToInitializeFPXLibrary", 73 },
+    { "UnableToOpenBlob", 74 },
+    { "UnableToReadAspectRatio", 75 },
+    { "UnableToReadCIELABImages", 76 },
+    { "UnableToReadSummaryInfo", 77 },
+    { "UnableToSetAffineMatrix", 78 },
+    { "UnableToSetAspectRatio", 79 },
+    { "UnableToSetColorTwist", 80 },
+    { "UnableToSetContrast", 81 },
+    { "UnableToSetFilteringValue", 82 },
+    { "UnableToSetImageComments", 83 },
+    { "UnableToSetImageTitle", 84 },
+    { "UnableToSetJPEGLevel", 85 },
+    { "UnableToSetRegionOfInterest", 86 },
+    { "UnableToSetSummaryInfo", 87 },
+    { "UnableToTranslateText", 88 },
+    { "UnableToWriteMPEGParameters", 89 },
+    { "UnableToWriteTemporaryFile", 90 },
+    { "UnableToZipCompressImage", 91 },
+    { "UnsupportedBitsPerSample", 92 },
+    { "UnsupportedCellTypeInTheMatrix", 93 },
+    { "UnsupportedSamplesPerPixel", 94 },
+    { "WebPDecodingFailedUserAbort", 95 },
+    { "WebPEncodingFailed", 96 },
+    { "WebPEncodingFailedBadDimension", 97 },
+    { "WebPEncodingFailedBadWrite", 98 },
+    { "WebPEncodingFailedBitstreamOutOfMemory", 99 },
+    { "WebPEncodingFailedFileTooBig", 100 },
+    { "WebPEncodingFailedInvalidConfiguration", 101 },
+    { "WebPEncodingFailedNULLParameter", 102 },
+    { "WebPEncodingFailedOutOfMemory", 103 },
+    { "WebPEncodingFailedPartition0Overflow", 104 },
+    { "WebPEncodingFailedPartitionOverflow", 105 },
+    { "WebPEncodingFailedUserAbort", 106 },
+    { "WebPInvalidConfiguration", 107 },
+    { "WebPInvalidParameter", 108 },
+    { "ZipCompressionNotSupported", 109 },
+    { "Default", 110 },
+    { "LosslessToLossyJPEGConversion", 111 },
+    { "IncludeElementNestedTooDeeply", 112 },
+    { "RegistryKeyLookupFailed", 113 },
+    { "StringTokenLengthExceeded", 114 },
+    { "UnableToAccessConfigureFile", 115 },
+    { "UnableToAccessFontFile", 116 },
+    { "UnableToAccessLogFile", 117 },
+    { "UnableToAccessModuleFile", 118 },
+    { "Default", 119 },
+    { "UnableToChangeToWorkingDirectory", 120 },
+    { "UnableToGetCurrentDirectory", 121 },
+    { "UnableToRestoreCurrentDirectory", 122 },
+    { "Default", 123 },
+    { "AnErrorHasOccurredReadingFromFile", 124 },
+    { "AnErrorHasOccurredWritingToFile", 125 },
+    { "ColormapExceedsColorsLimit", 126 },
+    { "CompressionNotValid", 127 },
+    { "CorruptImage", 128 },
+    { "ImageFileDoesNotContainAnyImageData", 129 },
+    { "ImageFileHasNoScenes", 130 },
+    { "ImageTypeNotSupported", 131 },
+    { "ImproperImageHeader", 132 },
+    { "InsufficientImageDataInFile", 133 },
+    { "InvalidColormapIndex", 134 },
+    { "InvalidFileFormatVersion", 135 },
+    { "LengthAndFilesizeDoNotMatch", 136 },
+    { "MissingImageChannel", 137 },
+    { "NegativeOrZeroImageSize", 138 },
+    { "NonOS2HeaderSizeError", 139 },
+    { "NotEnoughTiles", 140 },
+    { "StaticPlanesValueNotEqualToOne", 141 },
+    { "SubsamplingRequiresEvenWidth", 142 },
+    { "TooMuchImageDataInFile", 143 },
+    { "UnableToReadColormapFromDumpFile", 144 },
+    { "UnableToReadColorProfile", 145 },
+    { "UnableToReadExtensionBlock", 146 },
+    { "UnableToReadGenericProfile", 147 },
+    { "UnableToReadImageData", 148 },
+    { "UnableToReadImageHeader", 149 },
+    { "UnableToReadIPTCProfile", 150 },
+    { "UnableToReadPixmapFromDumpFile", 151 },
+    { "UnableToReadSubImageData", 152 },
+    { "UnableToReadVIDImage", 153 },
+    { "UnableToReadWindowNameFromDumpFile", 154 },
+    { "UnableToRunlengthDecodeImage", 155 },
+    { "UnableToUncompressImage", 156 },
+    { "UnexpectedEndOfFile", 157 },
+    { "UnexpectedSamplingFactor", 158 },
+    { "UnknownPatternType", 159 },
+    { "UnrecognizedBitsPerPixel", 160 },
+    { "UnrecognizedImageCompression", 161 },
+    { "UnrecognizedNumberOfColors", 162 },
+    { "UnrecognizedXWDHeader", 163 },
+    { "UnsupportedBitsPerSample", 164 },
+    { "UnsupportedNumberOfPlanes", 165 },
+    { "UnableToPersistKey", 166 },
+    { "CompressionNotValid", 167 },
+    { "CorruptImage", 168 },
+    { "ImproperImageHeader", 169 },
+    { "InvalidColormapIndex", 170 },
+    { "LengthAndFilesizeDoNotMatch", 171 },
+    { "NegativeOrZeroImageSize", 172 },
+    { "NonOS2HeaderSizeError", 173 },
+    { "SkipToSyncByte", 174 },
+    { "StaticPlanesValueNotEqualToOne", 175 },
+    { "UnableToParseEmbeddedProfile", 176 },
+    { "UnrecognizedBitsPerPixel", 177 },
+    { "UnrecognizedImageCompression", 178 },
+    { "DelegateFailed", 179 },
+    { "FailedToAllocateArgumentList", 180 },
+    { "FailedToAllocateGhostscriptInterpreter", 181 },
+    { "FailedToComputeOutputSize", 182 },
+    { "FailedToFindGhostscript", 183 },
+    { "FailedToRenderFile", 184 },
+    { "FailedToScanFile", 185 },
+    { "NoTagFound", 186 },
+    { "PostscriptDelegateFailed", 187 },
+    { "UnableToCreateImage", 188 },
+    { "UnableToCreateImageComponent", 189 },
+    { "UnableToDecodeImageFile", 190 },
+    { "UnableToEncodeImageFile", 191 },
+    { "UnableToInitializeFPXLibrary", 192 },
+    { "UnableToInitializeWMFLibrary", 193 },
+    { "UnableToManageJP2Stream", 194 },
+    { "UnableToWriteSVGFormat", 195 },
+    { "WebPABIMismatch", 196 },
+    { "Default", 197 },
+    { "Default", 198 },
+    { "AlreadyPushingPatternDefinition", 199 },
+    { "DrawingRecursionDetected", 200 },
+    { "FloatValueConversionError", 201 },
+    { "IntegerValueConversionError", 202 },
+    { "InvalidPrimitiveArgument", 203 },
+    { "NonconformingDrawingPrimitiveDefinition", 204 },
+    { "PrimitiveArithmeticOverflow", 205 },
+    { "TooManyCoordinates", 206 },
+    { "UnableToPrint", 207 },
+    { "UnbalancedGraphicContextPushPop", 208 },
+    { "UnreasonableGradientSize", 209 },
+    { "VectorPathTruncated", 210 },
     { "Default", 211 },
-    { "AngleIsDiscontinuous", 212 },
-    { "ColorspaceColorProfileMismatch", 213 },
-    { "ImageColorspaceDiffers", 214 },
-    { "ImageColorspaceMismatch", 215 },
-    { "ImageDifferenceExceedsLimit", 216 },
-    { "ImageDoesNotContainResolution", 217 },
-    { "ImageOpacityDiffers", 218 },
-    { "ImageSequenceIsRequired", 219 },
-    { "ImageSizeDiffers", 220 },
-    { "InvalidColormapIndex", 221 },
-    { "LeftAndRightImageSizesDiffer", 222 },
-    { "NoImagesWereFound", 223 },
-    { "NoImagesWereLoaded", 224 },
-    { "NoLocaleImageAttribute", 225 },
-    { "TooManyClusters", 226 },
-    { "UnableToAppendImage", 227 },
-    { "UnableToAssignProfile", 228 },
-    { "UnableToAverageImage", 229 },
-    { "UnableToCoalesceImage", 230 },
-    { "UnableToCompareImages", 231 },
-    { "UnableToCreateImageMosaic", 232 },
-    { "UnableToCreateStereoImage", 233 },
-    { "UnableToDeconstructImageSequence", 234 },
-    { "UnableToFlattenImage", 235 },
-    { "UnableToGetClipMask", 236 },
-    { "UnableToHandleImageChannel", 237 },
-    { "UnableToResizeImage", 238 },
-    { "UnableToSegmentImage", 239 },
-    { "UnableToSetClipMask", 240 },
-    { "UnableToShearImage", 241 },
-    { "WidthOrHeightExceedsLimit", 242 },
-    { "UnableToPersistKey", 243 },
-    { "Default", 244 },
-    { "DPSLibraryIsNotAvailable", 245 },
-    { "FPXLibraryIsNotAvailable", 246 },
-    { "FreeTypeLibraryIsNotAvailable", 247 },
-    { "JPEGLibraryIsNotAvailable", 248 },
-    { "LCMSLibraryIsNotAvailable", 249 },
-    { "LZWEncodingNotEnabled", 250 },
-    { "NoDecodeDelegateForThisImageFormat", 251 },
-    { "NoEncodeDelegateForThisImageFormat", 252 },
-    { "TIFFLibraryIsNotAvailable", 253 },
-    { "XMLLibraryIsNotAvailable", 254 },
-    { "XWindowLibraryIsNotAvailable", 255 },
-    { "ZipLibraryIsNotAvailable", 256 },
-    { "Default", 257 },
+    { "NotARelativeURL", 212 },
+    { "NotCurrentlyPushingPatternDefinition", 213 },
+    { "URLNotFound", 214 },
+    { "UnableToCreateTemporaryFile", 215 },
+    { "UnableToOpenFile", 216 },
+    { "UnableToWriteFile", 217 },
+    { "Default", 218 },
+    { "Default", 219 },
+    { "AngleIsDiscontinuous", 220 },
+    { "CMYKAImageLacksAlphaChannel", 221 },
+    { "ColorspaceColorProfileMismatch", 222 },
+    { "ImageColorspaceDiffers", 223 },
+    { "ImageColorspaceMismatch", 224 },
+    { "ImageDifferenceExceedsLimit", 225 },
+    { "ImageDoesNotContainResolution", 226 },
+    { "ImageIsNotColormapped", 227 },
+    { "ImageOpacityDiffers", 228 },
+    { "ImageSequenceIsRequired", 229 },
+    { "ImageSizeDiffers", 230 },
+    { "InvalidColormapIndex", 231 },
+    { "LeftAndRightImageSizesDiffer", 232 },
+    { "NoImagesWereFound", 233 },
+    { "NoImagesWereLoaded", 234 },
+    { "NoLocaleImageAttribute", 235 },
+    { "TooManyClusters", 236 },
+    { "UnableToAppendImage", 237 },
+    { "UnableToAssignProfile", 238 },
+    { "UnableToAverageImage", 239 },
+    { "UnableToCoalesceImage", 240 },
+    { "UnableToCompareImages", 241 },
+    { "UnableToCreateImageMosaic", 242 },
+    { "UnableToCreateStereoImage", 243 },
+    { "UnableToDeconstructImageSequence", 244 },
+    { "UnableToExportImagePixels", 245 },
+    { "UnableToFlattenImage", 246 },
+    { "UnableToGetClipMask", 247 },
+    { "UnableToGetCompositeMask", 248 },
+    { "UnableToHandleImageChannel", 249 },
+    { "UnableToImportImagePixels", 250 },
+    { "UnableToResizeImage", 251 },
+    { "UnableToSegmentImage", 252 },
+    { "UnableToSetClipMask", 253 },
+    { "UnableToSetCompositeMask", 254 },
+    { "UnableToShearImage", 255 },
+    { "WidthOrHeightExceedsLimit", 256 },
+    { "UnableToPersistKey", 257 },
     { "Default", 258 },
-    { "FailedToCloseModule", 259 },
-    { "FailedToFindSymbol", 260 },
-    { "UnableToLoadModule", 261 },
-    { "UnableToRegisterImageFormat", 262 },
-    { "UnrecognizedModule", 263 },
-    { "UnableToInitializeModuleLoader", 264 },
-    { "Default", 265 },
-    { "Default", 266 },
-    { "Default", 267 },
-    { "UserRequestedTerminationBySignal", 268 },
-    { "Default", 269 },
-    { "BevelWidthIsNegative", 270 },
-    { "ColorSeparatedImageRequired", 271 },
-    { "FrameIsLessThanImageSize", 272 },
-    { "GeometryDimensionsAreZero", 273 },
-    { "GeometryDoesNotContainImage", 274 },
-    { "HaldClutImageDimensionsInvalid", 275 },
-    { "ImagesAreNotTheSameSize", 276 },
-    { "ImageSizeMustExceedBevelWidth", 277 },
-    { "ImageSmallerThanKernelWidth", 278 },
-    { "ImageSmallerThanRadius", 279 },
-    { "ImageWidthsOrHeightsDiffer", 280 },
-    { "InputImagesAlreadySpecified", 281 },
-    { "InvalidSubimageSpecification", 282 },
-    { "KernelRadiusIsTooSmall", 283 },
-    { "KernelWidthMustBeAnOddNumber", 284 },
-    { "MatrixIsNotSquare", 285 },
-    { "MatrixOrderOutOfRange", 286 },
-    { "MissingAnImageFilename", 287 },
-    { "MissingArgument", 288 },
-    { "MustSpecifyAnImageName", 289 },
-    { "MustSpecifyImageSize", 290 },
-    { "NoBlobDefined", 291 },
-    { "NoImagesDefined", 292 },
-    { "NonzeroWidthAndHeightRequired", 293 },
-    { "NoProfileNameWasGiven", 294 },
-    { "NullBlobArgument", 295 },
-    { "ReferenceImageRequired", 296 },
-    { "ReferenceIsNotMyType", 297 },
-    { "RegionAreaExceedsLimit", 298 },
-    { "RequestDidNotReturnAnImage", 299 },
-    { "SteganoImageRequired", 300 },
-    { "StereoImageRequired", 301 },
-    { "SubimageSpecificationReturnsNoImages", 302 },
-    { "UnableToAddOrRemoveProfile", 303 },
-    { "UnableToAverageImageSequence", 304 },
-    { "UnableToBlurImage", 305 },
-    { "UnableToChopImage", 306 },
-    { "UnableToColorMatrixImage", 307 },
-    { "UnableToConstituteImage", 308 },
-    { "UnableToConvolveImage", 309 },
-    { "UnableToEdgeImage", 310 },
-    { "UnableToEqualizeImage", 311 },
-    { "UnableToFilterImage", 312 },
-    { "UnableToFormatImageMetadata", 313 },
-    { "UnableToFrameImage", 314 },
-    { "UnableToOilPaintImage", 315 },
-    { "UnableToPaintImage", 316 },
-    { "UnableToRaiseImage", 317 },
-    { "UnableToSharpenImage", 318 },
-    { "UnableToThresholdImage", 319 },
-    { "UnableToWaveImage", 320 },
-    { "UnrecognizedAttribute", 321 },
-    { "UnrecognizedChannelType", 322 },
-    { "UnrecognizedColor", 323 },
-    { "UnrecognizedColormapType", 324 },
-    { "UnrecognizedColorspace", 325 },
-    { "UnrecognizedCommand", 326 },
-    { "UnrecognizedComposeOperator", 327 },
-    { "UnrecognizedDisposeMethod", 328 },
-    { "UnrecognizedElement", 329 },
-    { "UnrecognizedEndianType", 330 },
-    { "UnrecognizedGravityType", 331 },
-    { "UnrecognizedHighlightStyle", 332 },
-    { "UnrecognizedImageCompression", 333 },
-    { "UnrecognizedImageFilter", 334 },
-    { "UnrecognizedImageFormat", 335 },
-    { "UnrecognizedImageMode", 336 },
-    { "UnrecognizedImageType", 337 },
-    { "UnrecognizedIntentType", 338 },
-    { "UnrecognizedInterlaceType", 339 },
-    { "UnrecognizedListType", 340 },
-    { "UnrecognizedMetric", 341 },
-    { "UnrecognizedModeType", 342 },
-    { "UnrecognizedNoiseType", 343 },
-    { "UnrecognizedOperator", 344 },
-    { "UnrecognizedOption", 345 },
-    { "UnrecognizedPerlMagickMethod", 346 },
-    { "UnrecognizedPixelMap", 347 },
-    { "UnrecognizedPreviewType", 348 },
-    { "UnrecognizedResourceType", 349 },
-    { "UnrecognizedType", 350 },
-    { "UnrecognizedUnitsType", 351 },
-    { "UnrecognizedVirtualPixelMethod", 352 },
-    { "UnsupportedSamplingFactor", 353 },
-    { "UsageError", 354 },
-    { "InvalidColorspaceType", 355 },
-    { "InvalidEndianType", 356 },
-    { "InvalidImageType", 357 },
-    { "InvalidInterlaceType", 358 },
-    { "MissingAnImageFilename", 359 },
-    { "MissingArgument", 360 },
-    { "NoImagesWereLoaded", 361 },
-    { "OptionLengthExceedsLimit", 362 },
-    { "RequestDidNotReturnAnImage", 363 },
-    { "UnableToOpenXServer", 364 },
-    { "UnableToPersistKey", 365 },
-    { "UnrecognizedColormapType", 366 },
-    { "UnrecognizedColorspaceType", 367 },
-    { "UnrecognizedDisposeMethod", 368 },
-    { "UnrecognizedEndianType", 369 },
-    { "UnrecognizedFilterType", 370 },
-    { "UnrecognizedImageCompressionType", 371 },
-    { "UnrecognizedImageType", 372 },
-    { "UnrecognizedInterlaceType", 373 },
-    { "UnrecognizedOption", 374 },
-    { "UnrecognizedResourceType", 375 },
-    { "UnrecognizedVirtualPixelMethod", 376 },
-    { "UnrecognizedColor", 377 },
-    { "ImageExpected", 378 },
-    { "ImageInfoExpected", 379 },
-    { "StructureSizeMismatch", 380 },
-    { "UnableToGetRegistryID", 381 },
-    { "UnableToLocateImage", 382 },
-    { "UnableToSetRegistry", 383 },
-    { "Default", 384 },
-    { "Default", 385 },
-    { "CacheResourcesExhausted", 386 },
-    { "ImagePixelHeightLimitExceeded", 387 },
-    { "ImagePixelLimitExceeded", 388 },
-    { "ImagePixelWidthLimitExceeded", 389 },
-    { "MemoryAllocationFailed", 390 },
-    { "NoPixelsDefinedInCache", 391 },
-    { "PixelCacheAllocationFailed", 392 },
-    { "UnableToAddColorProfile", 393 },
-    { "UnableToAddGenericProfile", 394 },
-    { "UnableToAddIPTCProfile", 395 },
-    { "UnableToAllocateCoefficients", 396 },
-    { "UnableToAllocateColormap", 397 },
-    { "UnableToAllocateICCProfile", 398 },
-    { "UnableToAllocateImage", 399 },
-    { "UnableToAllocateString", 400 },
-    { "UnableToAnnotateImage", 401 },
-    { "UnableToAverageImageSequence", 402 },
-    { "UnableToCloneDrawingWand", 403 },
-    { "UnableToCloneImage", 404 },
-    { "UnableToComputeImageSignature", 405 },
-    { "UnableToConstituteImage", 406 },
-    { "UnableToConvertFont", 407 },
-    { "UnableToConvertStringToTokens", 408 },
-    { "UnableToCreateColormap", 409 },
-    { "UnableToCreateColorTransform", 410 },
-    { "UnableToCreateCommandWidget", 411 },
-    { "UnableToCreateImageGroup", 412 },
-    { "UnableToCreateImageMontage", 413 },
-    { "UnableToCreateXWindow", 414 },
-    { "UnableToCropImage", 415 },
-    { "UnableToDespeckleImage", 416 },
-    { "UnableToDetermineImageClass", 417 },
-    { "UnableToDetermineTheNumberOfImageColors", 418 },
-    { "UnableToDitherImage", 419 },
-    { "UnableToDrawOnImage", 420 },
-    { "UnableToEdgeImage", 421 },
-    { "UnableToEmbossImage", 422 },
-    { "UnableToEnhanceImage", 423 },
-    { "UnableToFloodfillImage", 424 },
-    { "UnableToGammaCorrectImage", 425 },
-    { "UnableToGetBestIconSize", 426 },
-    { "UnableToGetFromRegistry", 427 },
-    { "UnableToGetPackageInfo", 428 },
-    { "UnableToLevelImage", 429 },
-    { "UnableToMagnifyImage", 430 },
-    { "UnableToManageColor", 431 },
-    { "UnableToMapImage", 432 },
-    { "UnableToMapImageSequence", 433 },
-    { "UnableToMedianFilterImage", 434 },
-    { "UnableToMotionBlurImage", 435 },
-    { "UnableToNoiseFilterImage", 436 },
-    { "UnableToNormalizeImage", 437 },
-    { "UnableToOpenColorProfile", 438 },
-    { "UnableToQuantizeImage", 439 },
-    { "UnableToQuantizeImageSequence", 440 },
-    { "UnableToReadTextChunk", 441 },
-    { "UnableToReadXImage", 442 },
-    { "UnableToReadXServerColormap", 443 },
-    { "UnableToResizeImage", 444 },
-    { "UnableToRotateImage", 445 },
-    { "UnableToSampleImage", 446 },
-    { "UnableToScaleImage", 447 },
-    { "UnableToSelectImage", 448 },
-    { "UnableToSharpenImage", 449 },
-    { "UnableToShaveImage", 450 },
-    { "UnableToShearImage", 451 },
-    { "UnableToSortImageColormap", 452 },
-    { "UnableToThresholdImage", 453 },
-    { "UnableToTransformColorspace", 454 },
-    { "MemoryAllocationFailed", 455 },
-    { "SemaporeOperationFailed", 456 },
-    { "UnableToAllocateAscii85Info", 457 },
-    { "UnableToAllocateCacheInfo", 458 },
-    { "UnableToAllocateCacheView", 459 },
-    { "UnableToAllocateColorInfo", 460 },
-    { "UnableToAllocateDashPattern", 461 },
-    { "UnableToAllocateDelegateInfo", 462 },
-    { "UnableToAllocateDerivatives", 463 },
-    { "UnableToAllocateDrawContext", 464 },
-    { "UnableToAllocateDrawInfo", 465 },
-    { "UnableToAllocateDrawingWand", 466 },
-    { "UnableToAllocateGammaMap", 467 },
-    { "UnableToAllocateImage", 468 },
-    { "UnableToAllocateImagePixels", 469 },
-    { "UnableToAllocateLogInfo", 470 },
-    { "UnableToAllocateMagicInfo", 471 },
-    { "UnableToAllocateMagickInfo", 472 },
-    { "UnableToAllocateModuleInfo", 473 },
-    { "UnableToAllocateMontageInfo", 474 },
-    { "UnableToAllocateQuantizeInfo", 475 },
-    { "UnableToAllocateRandomKernel", 476 },
-    { "UnableToAllocateRegistryInfo", 477 },
-    { "UnableToAllocateSemaphoreInfo", 478 },
-    { "UnableToAllocateString", 479 },
-    { "UnableToAllocateTypeInfo", 480 },
-    { "UnableToAllocateWand", 481 },
-    { "UnableToAnimateImageSequence", 482 },
-    { "UnableToCloneBlobInfo", 483 },
-    { "UnableToCloneCacheInfo", 484 },
-    { "UnableToCloneImage", 485 },
-    { "UnableToCloneImageInfo", 486 },
-    { "UnableToConcatenateString", 487 },
-    { "UnableToConvertText", 488 },
-    { "UnableToCreateColormap", 489 },
-    { "UnableToDestroySemaphore", 490 },
-    { "UnableToDisplayImage", 491 },
-    { "UnableToEscapeString", 492 },
-    { "UnableToInitializeSemaphore", 493 },
-    { "UnableToInterpretMSLImage", 494 },
-    { "UnableToLockSemaphore", 495 },
-    { "UnableToObtainRandomEntropy", 496 },
-    { "UnableToUnlockSemaphore", 497 },
-    { "MemoryAllocationFailed", 498 },
-    { "ImageDoesNotContainTheStreamGeometry", 499 },
-    { "NoStreamHandlerIsDefined", 500 },
-    { "PixelCacheIsNotOpen", 501 },
-    { "UnableToAcquirePixelStream", 502 },
-    { "UnableToSetPixelStream", 503 },
-    { "UnableToSyncPixelStream", 504 },
-    { "Default", 505 },
-    { "Default", 506 },
-    { "FontSubstitutionRequired", 507 },
-    { "UnableToGetTypeMetrics", 508 },
-    { "UnableToInitializeFreetypeLibrary", 509 },
-    { "UnableToReadFont", 510 },
-    { "UnrecognizedFontEncoding", 511 },
-    { "Default", 512 },
-    { "Default", 513 },
-    { "InvalidColormapIndex", 514 },
-    { "WandAPINotImplemented", 515 },
-    { "WandContainsNoImageIndexs", 516 },
-    { "WandContainsNoImages", 517 },
-    { "ColorIsNotKnownToServer", 518 },
-    { "NoWindowWithSpecifiedIDExists", 519 },
-    { "StandardColormapIsNotInitialized", 520 },
-    { "UnableToConnectToRemoteDisplay", 521 },
-    { "UnableToCreateBitmap", 522 },
-    { "UnableToCreateColormap", 523 },
-    { "UnableToCreatePixmap", 524 },
-    { "UnableToCreateProperty", 525 },
-    { "UnableToCreateStandardColormap", 526 },
-    { "UnableToDisplayImageInfo", 527 },
-    { "UnableToGetProperty", 528 },
-    { "UnableToGetStandardColormap", 529 },
-    { "UnableToGetVisual", 530 },
-    { "UnableToGrabMouse", 531 },
-    { "UnableToLoadFont", 532 },
-    { "UnableToMatchVisualToStandardColormap", 533 },
-    { "UnableToOpenXServer", 534 },
-    { "UnableToReadXAttributes", 535 },
-    { "UnableToReadXWindowImage", 536 },
-    { "UnrecognizedColormapType", 537 },
-    { "UnrecognizedGravityType", 538 },
-    { "UnrecognizedVisualSpecifier", 539 },
-    { "UnableToAllocateXHints", 540 },
-    { "UnableToCreateCursor", 541 },
-    { "UnableToCreateGraphicContext", 542 },
-    { "UnableToCreateStandardColormap", 543 },
-    { "UnableToCreateTextProperty", 544 },
-    { "UnableToCreateXImage", 545 },
-    { "UnableToCreateXPixmap", 546 },
-    { "UnableToCreateXWindow", 547 },
-    { "UnableToDisplayImage", 548 },
-    { "UnableToDitherImage", 549 },
-    { "UnableToGetPixelInfo", 550 },
-    { "UnableToGetVisual", 551 },
-    { "UnableToLoadFont", 552 },
-    { "UnableToMakeXWindow", 553 },
-    { "UnableToOpenXServer", 554 },
-    { "UnableToViewFonts", 555 },
-    { "UnableToGetVisual", 556 },
-    { "UsingDefaultVisual", 557 },
+    { "DPSLibraryIsNotAvailable", 259 },
+    { "FPXLibraryIsNotAvailable", 260 },
+    { "FreeTypeLibraryIsNotAvailable", 261 },
+    { "JPEGLibraryIsNotAvailable", 262 },
+    { "LCMSLibraryIsNotAvailable", 263 },
+    { "LZWEncodingNotEnabled", 264 },
+    { "NoDecodeDelegateForThisImageFormat", 265 },
+    { "NoEncodeDelegateForThisImageFormat", 266 },
+    { "TIFFLibraryIsNotAvailable", 267 },
+    { "XMLLibraryIsNotAvailable", 268 },
+    { "XWindowLibraryIsNotAvailable", 269 },
+    { "ZipLibraryIsNotAvailable", 270 },
+    { "Default", 271 },
+    { "Default", 272 },
+    { "FailedToCloseModule", 273 },
+    { "FailedToFindSymbol", 274 },
+    { "UnableToLoadModule", 275 },
+    { "UnableToRegisterImageFormat", 276 },
+    { "UnrecognizedModule", 277 },
+    { "UnableToInitializeModuleLoader", 278 },
+    { "Default", 279 },
+    { "Default", 280 },
+    { "Default", 281 },
+    { "UserRequestedTerminationBySignal", 282 },
+    { "Default", 283 },
+    { "BevelWidthIsNegative", 284 },
+    { "ColorSeparatedImageRequired", 285 },
+    { "FrameIsLessThanImageSize", 286 },
+    { "GeometryDimensionsAreZero", 287 },
+    { "GeometryDoesNotContainImage", 288 },
+    { "HaldClutImageDimensionsInvalid", 289 },
+    { "ImagesAreNotTheSameSize", 290 },
+    { "ImageSizeMustExceedBevelWidth", 291 },
+    { "ImageSmallerThanKernelWidth", 292 },
+    { "ImageSmallerThanRadius", 293 },
+    { "ImageWidthsOrHeightsDiffer", 294 },
+    { "InputImagesAlreadySpecified", 295 },
+    { "InvalidSubimageSpecification", 296 },
+    { "KernelRadiusIsTooSmall", 297 },
+    { "KernelWidthMustBeAnOddNumber", 298 },
+    { "MatrixIsNotSquare", 299 },
+    { "MatrixOrderOutOfRange", 300 },
+    { "MissingAnImageFilename", 301 },
+    { "MissingArgument", 302 },
+    { "MustSpecifyAnImageName", 303 },
+    { "MustSpecifyImageSize", 304 },
+    { "NoBlobDefined", 305 },
+    { "NoImagesDefined", 306 },
+    { "NonzeroWidthAndHeightRequired", 307 },
+    { "NoProfileNameWasGiven", 308 },
+    { "NullBlobArgument", 309 },
+    { "ReferenceImageRequired", 310 },
+    { "ReferenceIsNotMyType", 311 },
+    { "RegionAreaExceedsLimit", 312 },
+    { "RequestDidNotReturnAnImage", 313 },
+    { "SteganoImageRequired", 314 },
+    { "StereoImageRequired", 315 },
+    { "SubimageSpecificationReturnsNoImages", 316 },
+    { "TileNotBoundedByImageDimensions", 317 },
+    { "UnableToAddOrRemoveProfile", 318 },
+    { "UnableToAverageImageSequence", 319 },
+    { "UnableToBlurImage", 320 },
+    { "UnableToChopImage", 321 },
+    { "UnableToColorMatrixImage", 322 },
+    { "UnableToConstituteImage", 323 },
+    { "UnableToConvolveImage", 324 },
+    { "UnableToEdgeImage", 325 },
+    { "UnableToEqualizeImage", 326 },
+    { "UnableToFilterImage", 327 },
+    { "UnableToFormatImageMetadata", 328 },
+    { "UnableToFrameImage", 329 },
+    { "UnableToOilPaintImage", 330 },
+    { "UnableToPaintImage", 331 },
+    { "UnableToRaiseImage", 332 },
+    { "UnableToSharpenImage", 333 },
+    { "UnableToThresholdImage", 334 },
+    { "UnableToWaveImage", 335 },
+    { "UnrecognizedAttribute", 336 },
+    { "UnrecognizedChannelType", 337 },
+    { "UnrecognizedColor", 338 },
+    { "UnrecognizedColormapType", 339 },
+    { "UnrecognizedColorspace", 340 },
+    { "UnrecognizedCommand", 341 },
+    { "UnrecognizedComposeOperator", 342 },
+    { "UnrecognizedDisposeMethod", 343 },
+    { "UnrecognizedElement", 344 },
+    { "UnrecognizedEndianType", 345 },
+    { "UnrecognizedGravityType", 346 },
+    { "UnrecognizedHighlightStyle", 347 },
+    { "UnrecognizedImageCompression", 348 },
+    { "UnrecognizedImageFilter", 349 },
+    { "UnrecognizedImageFormat", 350 },
+    { "UnrecognizedImageMode", 351 },
+    { "UnrecognizedImageType", 352 },
+    { "UnrecognizedIntentType", 353 },
+    { "UnrecognizedInterlaceType", 354 },
+    { "UnrecognizedListType", 355 },
+    { "UnrecognizedMetric", 356 },
+    { "UnrecognizedModeType", 357 },
+    { "UnrecognizedNoiseType", 358 },
+    { "UnrecognizedOperator", 359 },
+    { "UnrecognizedOption", 360 },
+    { "UnrecognizedPerlMagickMethod", 361 },
+    { "UnrecognizedPixelMap", 362 },
+    { "UnrecognizedPreviewType", 363 },
+    { "UnrecognizedResourceType", 364 },
+    { "UnrecognizedType", 365 },
+    { "UnrecognizedUnitsType", 366 },
+    { "UnrecognizedVirtualPixelMethod", 367 },
+    { "UnsupportedSamplingFactor", 368 },
+    { "UsageError", 369 },
+    { "InvalidColorspaceType", 370 },
+    { "InvalidEndianType", 371 },
+    { "InvalidImageType", 372 },
+    { "InvalidInterlaceType", 373 },
+    { "MissingAnImageFilename", 374 },
+    { "MissingArgument", 375 },
+    { "NoImagesWereLoaded", 376 },
+    { "OptionLengthExceedsLimit", 377 },
+    { "RequestDidNotReturnAnImage", 378 },
+    { "UnableToOpenXServer", 379 },
+    { "UnableToPersistKey", 380 },
+    { "UnrecognizedColormapType", 381 },
+    { "UnrecognizedColorspaceType", 382 },
+    { "UnrecognizedDisposeMethod", 383 },
+    { "UnrecognizedEndianType", 384 },
+    { "UnrecognizedFilterType", 385 },
+    { "UnrecognizedImageCompressionType", 386 },
+    { "UnrecognizedImageType", 387 },
+    { "UnrecognizedInterlaceType", 388 },
+    { "UnrecognizedOption", 389 },
+    { "UnrecognizedResourceType", 390 },
+    { "UnrecognizedVirtualPixelMethod", 391 },
+    { "UnrecognizedColor", 392 },
+    { "ImageExpected", 393 },
+    { "ImageInfoExpected", 394 },
+    { "StructureSizeMismatch", 395 },
+    { "UnableToGetRegistryID", 396 },
+    { "UnableToLocateImage", 397 },
+    { "UnableToSetRegistry", 398 },
+    { "Default", 399 },
+    { "Default", 400 },
+    { "CacheResourcesExhausted", 401 },
+    { "ImagePixelHeightLimitExceeded", 402 },
+    { "ImagePixelLimitExceeded", 403 },
+    { "ImagePixelWidthLimitExceeded", 404 },
+    { "MemoryAllocationFailed", 405 },
+    { "NoPixelsDefinedInCache", 406 },
+    { "PixelCacheAllocationFailed", 407 },
+    { "UnableToAddColorProfile", 408 },
+    { "UnableToAddGenericProfile", 409 },
+    { "UnableToAddIPTCProfile", 410 },
+    { "UnableToAddOrRemoveProfile", 411 },
+    { "UnableToAllocateCoefficients", 412 },
+    { "UnableToAllocateColormap", 413 },
+    { "UnableToAllocateICCProfile", 414 },
+    { "UnableToAllocateImage", 415 },
+    { "UnableToAllocateString", 416 },
+    { "UnableToAnnotateImage", 417 },
+    { "UnableToAverageImageSequence", 418 },
+    { "UnableToCloneDrawingWand", 419 },
+    { "UnableToCloneImage", 420 },
+    { "UnableToComputeImageSignature", 421 },
+    { "UnableToConstituteImage", 422 },
+    { "UnableToConvertFont", 423 },
+    { "UnableToConvertStringToTokens", 424 },
+    { "UnableToCreateColormap", 425 },
+    { "UnableToCreateColorTransform", 426 },
+    { "UnableToCreateCommandWidget", 427 },
+    { "UnableToCreateImageGroup", 428 },
+    { "UnableToCreateImageMontage", 429 },
+    { "UnableToCreateXWindow", 430 },
+    { "UnableToCropImage", 431 },
+    { "UnableToDespeckleImage", 432 },
+    { "UnableToDetermineImageClass", 433 },
+    { "UnableToDetermineTheNumberOfImageColors", 434 },
+    { "UnableToDitherImage", 435 },
+    { "UnableToDrawOnImage", 436 },
+    { "UnableToEdgeImage", 437 },
+    { "UnableToEmbossImage", 438 },
+    { "UnableToEnhanceImage", 439 },
+    { "UnableToFloodfillImage", 440 },
+    { "UnableToGammaCorrectImage", 441 },
+    { "UnableToGetBestIconSize", 442 },
+    { "UnableToGetFromRegistry", 443 },
+    { "UnableToGetPackageInfo", 444 },
+    { "UnableToLevelImage", 445 },
+    { "UnableToMagnifyImage", 446 },
+    { "UnableToManageColor", 447 },
+    { "UnableToMapImage", 448 },
+    { "UnableToMapImageSequence", 449 },
+    { "UnableToMedianFilterImage", 450 },
+    { "UnableToMotionBlurImage", 451 },
+    { "UnableToNoiseFilterImage", 452 },
+    { "UnableToNormalizeImage", 453 },
+    { "UnableToOpenColorProfile", 454 },
+    { "UnableToQuantizeImage", 455 },
+    { "UnableToQuantizeImageSequence", 456 },
+    { "UnableToReadTextChunk", 457 },
+    { "UnableToReadXImage", 458 },
+    { "UnableToReadXServerColormap", 459 },
+    { "UnableToResizeImage", 460 },
+    { "UnableToRotateImage", 461 },
+    { "UnableToSampleImage", 462 },
+    { "UnableToScaleImage", 463 },
+    { "UnableToSelectImage", 464 },
+    { "UnableToSharpenImage", 465 },
+    { "UnableToShaveImage", 466 },
+    { "UnableToShearImage", 467 },
+    { "UnableToSortImageColormap", 468 },
+    { "UnableToThresholdImage", 469 },
+    { "UnableToTransformColorspace", 470 },
+    { "MemoryAllocationFailed", 471 },
+    { "SemaporeOperationFailed", 472 },
+    { "UnableToAllocateAscii85Info", 473 },
+    { "UnableToAllocateCacheInfo", 474 },
+    { "UnableToAllocateCacheView", 475 },
+    { "UnableToAllocateColorInfo", 476 },
+    { "UnableToAllocateDashPattern", 477 },
+    { "UnableToAllocateDelegateInfo", 478 },
+    { "UnableToAllocateDerivatives", 479 },
+    { "UnableToAllocateDrawContext", 480 },
+    { "UnableToAllocateDrawInfo", 481 },
+    { "UnableToAllocateDrawingWand", 482 },
+    { "UnableToAllocateGammaMap", 483 },
+    { "UnableToAllocateImage", 484 },
+    { "UnableToAllocateImagePixels", 485 },
+    { "UnableToAllocateLogInfo", 486 },
+    { "UnableToAllocateMagicInfo", 487 },
+    { "UnableToAllocateMagickInfo", 488 },
+    { "UnableToAllocateMagickMap", 489 },
+    { "UnableToAllocateModuleInfo", 490 },
+    { "UnableToAllocateMontageInfo", 491 },
+    { "UnableToAllocateQuantizeInfo", 492 },
+    { "UnableToAllocateRandomKernel", 493 },
+    { "UnableToAllocateRegistryInfo", 494 },
+    { "UnableToAllocateSemaphoreInfo", 495 },
+    { "UnableToAllocateString", 496 },
+    { "UnableToAllocateTypeInfo", 497 },
+    { "UnableToAllocateWand", 498 },
+    { "UnableToAnimateImageSequence", 499 },
+    { "UnableToCloneBlobInfo", 500 },
+    { "UnableToCloneCacheInfo", 501 },
+    { "UnableToCloneImage", 502 },
+    { "UnableToCloneImageInfo", 503 },
+    { "UnableToConcatenateString", 504 },
+    { "UnableToConvertText", 505 },
+    { "UnableToCreateColormap", 506 },
+    { "UnableToDestroySemaphore", 507 },
+    { "UnableToDisplayImage", 508 },
+    { "UnableToEscapeString", 509 },
+    { "UnableToInitializeSemaphore", 510 },
+    { "UnableToInterpretMSLImage", 511 },
+    { "UnableToLockSemaphore", 512 },
+    { "UnableToObtainRandomEntropy", 513 },
+    { "UnableToUnlockSemaphore", 514 },
+    { "MemoryAllocationFailed", 515 },
+    { "ImageDoesNotContainTheStreamGeometry", 516 },
+    { "NoStreamHandlerIsDefined", 517 },
+    { "PixelCacheIsNotOpen", 518 },
+    { "UnableToAcquirePixelStream", 519 },
+    { "UnableToSetPixelStream", 520 },
+    { "UnableToSyncPixelStream", 521 },
+    { "Default", 522 },
+    { "Default", 523 },
+    { "FontNotSpecified", 524 },
+    { "FontSubstitutionRequired", 525 },
+    { "UnableToGetTypeMetrics", 526 },
+    { "UnableToInitializeFreetypeLibrary", 527 },
+    { "UnableToReadFont", 528 },
+    { "UnrecognizedFontEncoding", 529 },
+    { "Default", 530 },
+    { "Default", 531 },
+    { "InvalidColormapIndex", 532 },
+    { "WandAPINotImplemented", 533 },
+    { "WandContainsNoImageIndexs", 534 },
+    { "WandContainsNoImages", 535 },
+    { "ColorIsNotKnownToServer", 536 },
+    { "NoWindowWithSpecifiedIDExists", 537 },
+    { "StandardColormapIsNotInitialized", 538 },
+    { "UnableToConnectToRemoteDisplay", 539 },
+    { "UnableToCreateBitmap", 540 },
+    { "UnableToCreateColormap", 541 },
+    { "UnableToCreatePixmap", 542 },
+    { "UnableToCreateProperty", 543 },
+    { "UnableToCreateStandardColormap", 544 },
+    { "UnableToDisplayImageInfo", 545 },
+    { "UnableToGetProperty", 546 },
+    { "UnableToGetStandardColormap", 547 },
+    { "UnableToGetVisual", 548 },
+    { "UnableToGrabMouse", 549 },
+    { "UnableToLoadFont", 550 },
+    { "UnableToMatchVisualToStandardColormap", 551 },
+    { "UnableToOpenXServer", 552 },
+    { "UnableToReadXAttributes", 553 },
+    { "UnableToReadXWindowImage", 554 },
+    { "UnrecognizedColormapType", 555 },
+    { "UnrecognizedGravityType", 556 },
+    { "UnrecognizedVisualSpecifier", 557 },
+    { "UnableToAllocateXHints", 558 },
+    { "UnableToCreateCursor", 559 },
+    { "UnableToCreateGraphicContext", 560 },
+    { "UnableToCreateStandardColormap", 561 },
+    { "UnableToCreateTextProperty", 562 },
+    { "UnableToCreateXImage", 563 },
+    { "UnableToCreateXPixmap", 564 },
+    { "UnableToCreateXWindow", 565 },
+    { "UnableToDisplayImage", 566 },
+    { "UnableToDitherImage", 567 },
+    { "UnableToGetPixelInfo", 568 },
+    { "UnableToGetVisual", 569 },
+    { "UnableToLoadFont", 570 },
+    { "UnableToMakeXWindow", 571 },
+    { "UnableToOpenXServer", 572 },
+    { "UnableToViewFonts", 573 },
+    { "UnableToGetVisual", 574 },
+    { "UsingDefaultVisual", 575 },
     { 0, 0 }
   };
 #endif
@@ -1239,6 +1275,7 @@ static const char *message_dat[] =
   {
     "%1",
     "Unable to create blob",
+    "Unable to deduce image format",
     "Unable to obtain current offset",
     "Unable to open file",
     "Unable to read file",
@@ -1249,6 +1286,7 @@ static const char *message_dat[] =
     "default error",
     "default warning",
     "Inconsistent persistent cache depth",
+    "Pixel cache dimensions incompatible with image dimensions",
     "Pixel cache is not open",
     "Unable to allocate cache view",
     "Unable to clone cache",
@@ -1262,6 +1300,7 @@ static const char *message_dat[] =
     "disk allocation failed",
     "Unable to extend pixel cache",
     "default warning",
+    "Arithmetic overflow",
     "Colormap size exceeds limit",
     "Colormap type not supported",
     "Colorspace model is not supported",
@@ -1269,7 +1308,9 @@ static const char *message_dat[] =
     "Compression not valid",
     "Data encoding scheme is not supported",
     "Data storage type is not supported",
+    "Coder did not return an image (this is a bug, please report it!)",
     "Delta-PNG is not supported",
+    "Division by zero",
     "Encrypted WPG image file not supported",
     "Fractal compression not supported",
     "Image column or row size is not supported",
@@ -1326,6 +1367,7 @@ static const char *message_dat[] =
     "Unable to zip-compress image",
     "Unsupported bits per sample",
     "Unsupported cell type in the matrix",
+    "Unsupported samples per pixel",
     "WebP decoding failed: user abort",
     "WebP encoding failed: unknown reason",
     "WebP encoding failed: bad dimension",
@@ -1361,6 +1403,7 @@ static const char *message_dat[] =
     "Compression not valid",
     "Corrupt image",
     "Image file or blob does not contain any image data",
+    "Image file has no scenes",
     "Image type not supported",
     "Improper image header",
     "Insufficient image data in file",
@@ -1406,6 +1449,7 @@ static const char *message_dat[] =
     "Non OS2 header size error",
     "Corrupt PCD image, skipping to sync byte",
     "Static planes value not equal to one",
+    "Unable to parse embedded profile",
     "Unrecognized bits per pixel",
     "Unrecognized image compression",
     "Delegate failed",
@@ -1450,11 +1494,13 @@ static const char *message_dat[] =
     "default error",
     "default warning",
     "angle is discontinuous",
+    "CMYKA image lacks an alpha channel (indexes)",
     "Colorspace color profile mismatch",
     "image colorspace differs",
     "image colorspace mismatch",
     "image difference exceeds limit (%s)",
     "image does not contain resolution",
+    "image is not colormapped",
     "image opacity differs",
     "Image sequence is required",
     "image size differs",
@@ -1472,12 +1518,16 @@ static const char *message_dat[] =
     "unable to create image mosaic",
     "unable to create stereo image",
     "unable to deconstruct image sequence",
+    "unable to export image pixels",
     "unable to flatten image",
     "Unable to get clip mask",
+    "Unable to get composite mask",
     "unable to handle image channel",
+    "unable to import image pixels",
     "unable to resize image",
     "unable to segment image",
     "Unable to set clip mask",
+    "Unable to set composite mask",
     "unable to shear image",
     "width or height exceeds limit",
     "Unable to persist key",
@@ -1540,6 +1590,7 @@ static const char *message_dat[] =
     "Stegano image required",
     "Stereo image required",
     "Subimage specification returns no images",
+    "Tile is not bounded by image dimensions",
     "Unable to add or remove profile",
     "unable to average image sequence",
     "unable to blur image",
@@ -1633,6 +1684,7 @@ static const char *message_dat[] =
     "unable to add ICC Color profile",
     "unable to add generic profile",
     "unable to add IPTC profile",
+    "unable to add or remove profile",
     "unable to allocate coefficients",
     "Unable to allocate colormap",
     "unable to allocate ICC profile",
@@ -1710,6 +1762,7 @@ static const char *message_dat[] =
     "unable to allocate log info",
     "unable to allocate magic info",
     "unable to allocate magick info",
+    "unable to allocate magick map",
     "unable to allocate module info",
     "unable to allocate montage info",
     "unable to allocate quantize info",
@@ -1744,6 +1797,7 @@ static const char *message_dat[] =
     "Unable to sync pixel stream",
     "default error",
     "default warning",
+    "Font name not specified",
     "Font substitution required",
     "Unable to get type metrics",
     "Unable to initialize freetype library",
index c50d924..f65962f 100644 (file)
@@ -53,7 +53,7 @@
   Typedef declarations.
 */
 typedef enum
-{ 
+{
   DisabledOutput = 0x0000,
   UndefinedOutput = 0x0000,
   StdoutOutput = 0x0001,
@@ -183,6 +183,9 @@ static SemaphoreInfo
 */
 static MagickPassFail
   ReadLogConfigureFile(const char *,const unsigned int,ExceptionInfo *);
+
+static LogEventType
+ParseEvents(const char *event_string) MAGICK_FUNC_PURE;
 \f
 /*
   Parse an event specification string and return the equivalent bits.
@@ -499,10 +502,10 @@ MagickExport  unsigned int LogMagickEventList(const ExceptionType type,
     {
       unsigned int
         i;
-      
+
       unsigned int
         enabled;
-      
+
       /* first translate the base type of the event to a mask */
       enabled=False;
       for (i=0; eventmask_map[i].name != 0; i++)
index 0a01cf6..357f7ac 100644 (file)
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2003 - 2014 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Log methods.
 */
 #ifndef _MAGICK_LOG_H
@@ -45,7 +45,7 @@ extern "C" {
 
 /* NOTE: any changes to this effect PerlMagick */
 typedef enum
-{ 
+{
   UndefinedEventMask     = 0x00000000,
   NoEventsMask           = 0x00000000,
   ConfigureEventMask     = 0x00000001,
@@ -78,13 +78,13 @@ typedef void
   Method declarations.
 */
 extern MagickExport MagickBool
-  IsEventLogging(void),
+  IsEventLogging(void) MAGICK_FUNC_PURE,
   LogMagickEvent(const ExceptionType type,
     const char *module,const char *function,const unsigned long line,
     const char *format,...) MAGICK_ATTRIBUTE((__format__ (__printf__,5,6))),
   LogMagickEventList(const ExceptionType type,
     const char *module,const char *function,const unsigned long line,
-    const char *format,va_list operands);
+    const char *format,va_list operands) MAGICK_ATTRIBUTE((__format__ (__printf__,5,0)));
 
 extern MagickExport unsigned long
   SetLogEventMask(const char *events);
index e439a41..bc36ff3 100644 (file)
@@ -204,7 +204,7 @@ DestroyMagicInfo(void)
 %  MagickPass is returned if the format was successfully identified.  The
 %  value MagickFail is returned if the format was not identified or an
 %  exception occured.
-%  
+%
 %
 %  The format of the GetMagickFileFormat method is:
 %
@@ -244,25 +244,25 @@ GetMagickFileFormat(const unsigned char *header, const size_t header_length,
   ARG_NOT_USED(exception);
 
   if (!((header == (const unsigned char *) NULL) || (header_length == 0) ||
-       (format_length < 2)))
+        (format_length < 2)))
     {
       /*
-       Search for requested magic.
+        Search for requested magic.
       */
       for (i=0; i < sizeof(StaticMagic)/sizeof(StaticMagic[0]); i++)
-       {
-         if (StaticMagic[i].offset+StaticMagic[i].length <= header_length)
-           {
-             if ((header[StaticMagic[i].offset] == StaticMagic[i].magic[0]) &&
-                 (memcmp(header+StaticMagic[i].offset,StaticMagic[i].magic,
-                         StaticMagic[i].length) == 0))
-               {
-                 if (strlcpy(format,StaticMagic[i].name,format_length) < format_length)
-                   status=MagickPass;
-                 break;
-               }
-           }
-       }
+        {
+          if (StaticMagic[i].offset+StaticMagic[i].length <= header_length)
+            {
+              if ((header[StaticMagic[i].offset] == StaticMagic[i].magic[0]) &&
+                  (memcmp(header+StaticMagic[i].offset,StaticMagic[i].magic,
+                          StaticMagic[i].length) == 0))
+                {
+                  if (strlcpy(format,StaticMagic[i].name,format_length) < format_length)
+                    status=MagickPass;
+                  break;
+                }
+            }
+        }
     }
   return status;
 }
@@ -332,48 +332,48 @@ ListMagicInfo(FILE *file,ExceptionInfo *exception)
 
   (void) fprintf(file,"Name      Offset Target\n");
   (void) fprintf(file,"-------------------------------------------------"
-                "------------------------------\n");
+                 "------------------------------\n");
   for (i=0; i < sizeof(StaticMagic)/sizeof(StaticMagic[0]); i++)
     {
       register const unsigned char
-       *c;
+        *c;
 
       (void) fprintf(file,"%.1024s",StaticMagic[i].name);
       for (j= (unsigned int) strlen(StaticMagic[i].name); j <= 9; j++)
-       (void) fprintf(file," ");
+        (void) fprintf(file," ");
       (void) fprintf(file,"%6u ",StaticMagic[i].offset);
 
       (void) fprintf(file,"\"");
       c=StaticMagic[i].magic;
       for (j=0; j < StaticMagic[i].length; j++)
-       {
-/*         else if ('\b' == c[j]) */
-/*           (void) fprintf(file,"\\b"); */
-/*         else if ('\f' == c[j]) */
-/*           (void) fprintf(file,"\\f"); */
-         if ('\n' == c[j])
-           (void) fprintf(file,"\\n");
-         else if ('\r' == c[j])
-           (void) fprintf(file,"\\r");
-         else if ('\t' == c[j])
-             (void) fprintf(file,"\\t");
-/*         else if ('\v' == c[j]) */
-/*           (void) fprintf(file,"\\v"); */
-/*         else if ('\a' == c[j]) */
-/*           (void) fprintf(file,"\\a"); */
-         else if ('\\' == c[j])
-           (void) fprintf(file,"\\");
-         else if ('\?' == c[j])
-           (void) fprintf(file,"\\?");
-         else if ('"' == c[j])
-           (void) fprintf(file,"\\\"");
-         else if (isprint((int) c[j]))
-           (void) fprintf(file,"%c",(int) c[j]);
-         else
-           {
-             (void) fprintf(file,"\\%03o",c[j]);
-           }
-       }
+        {
+/*          else if ('\b' == c[j]) */
+/*            (void) fprintf(file,"\\b"); */
+/*          else if ('\f' == c[j]) */
+/*            (void) fprintf(file,"\\f"); */
+          if ('\n' == c[j])
+            (void) fprintf(file,"\\n");
+          else if ('\r' == c[j])
+            (void) fprintf(file,"\\r");
+          else if ('\t' == c[j])
+              (void) fprintf(file,"\\t");
+/*          else if ('\v' == c[j]) */
+/*            (void) fprintf(file,"\\v"); */
+/*          else if ('\a' == c[j]) */
+/*            (void) fprintf(file,"\\a"); */
+          else if ('\\' == c[j])
+            (void) fprintf(file,"\\");
+          else if ('\?' == c[j])
+            (void) fprintf(file,"\\?");
+          else if ('"' == c[j])
+            (void) fprintf(file,"\\\"");
+          else if (isprint((int) c[j]))
+            (void) fprintf(file,"%c",(int) c[j]);
+          else
+            {
+              (void) fprintf(file,"\\%03o",c[j]);
+            }
+        }
       (void) fprintf(file,"\"\n");
     }
   (void) fflush(file);
index 5bb5711..9fcec14 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 - 2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Magic methods.
 */
 #ifndef _MAGICK_MAGIC_H
index 0d2d7c0..3bada89 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -80,10 +80,8 @@ static void
 static SemaphoreInfo
   *magick_semaphore = (SemaphoreInfo *) NULL;
 
-#if defined(SupportMagickModules)
 static SemaphoreInfo
   *module_semaphore = (SemaphoreInfo *) NULL;
-#endif /* #if defined(SupportMagickModules) */
 
 static MagickInfo
   *magick_list = (MagickInfo *) NULL;
@@ -168,9 +166,10 @@ DestroyMagick(void)
     }
 
   (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                       "Destroy Magick");
+                        "Destroy Magick");
 
   MagickDestroyCommandInfo();   /* Command parser */
+  DestroyMagickMonitor();       /* Progress monitor */
 #if defined(HasX11)
   MagickXDestroyX11Resources();
 #endif
@@ -267,22 +266,14 @@ DestroyMagickInfoList(void)
   register MagickInfo
     *p;
 
-#if defined(SupportMagickModules)
   DestroyMagickModules();
-#endif /* defined(SupportMagickModules) */
-
-#if !defined(BuildMagickModules)
-  UnregisterStaticModules();
-#endif /* !defined(BuildMagickModules) */
 
   /*
     At this point, the list should be empty, but check for remaining
     entries anyway.
   */
-#if defined(BuildMagickModules)
   if (magick_list != (MagickInfo *) NULL)
     (void) printf("Warning: module registrations are still present!\n");
-#endif /* defined(BuildMagickModules) */
   for (p=magick_list; p != (MagickInfo *) NULL; )
   {
     magick_info=p;
@@ -297,9 +288,7 @@ DestroyMagickInfoList(void)
   magick_list=(MagickInfo *) NULL;
   DestroySemaphoreInfo(&magick_semaphore);
 
-#if defined(SupportMagickModules)
   DestroySemaphoreInfo(&module_semaphore);
-#endif /* #if defined(SupportMagickModules) */
 }
 \f
 /*
@@ -394,7 +383,7 @@ GetMagickInfoEntryLocked(const char *name)
       for (p=magick_list; p != (MagickInfo *) NULL; p=p->next)
         if (LocaleCompare(p->name,name) == 0)
           break;
-      
+
       if (p != (MagickInfo *) NULL)
         if (p != magick_list)
           {
@@ -422,35 +411,31 @@ GetMagickInfo(const char *name,ExceptionInfo *exception)
   const MagickInfo
     *magick_info=(const MagickInfo *) NULL;
 
-#if defined(SupportMagickModules)
   if ((name != (const char *) NULL) &&
       (name[0] != '\0'))
     {
       LockSemaphoreInfo(module_semaphore);
       if (name[0] == '*')
-       {
-         /*
-           If all modules are requested, then use OpenModules to load all
-           modules.
-         */
-         (void) OpenModules(exception);
-       }
+        {
+          /*
+            If all modules are requested, then use OpenModules to load all
+            modules.
+          */
+          (void) OpenModules(exception);
+        }
       else
-       {
-         magick_info=GetMagickInfoEntryLocked(name);
-         if (magick_info == (const MagickInfo *) NULL)
-           {
-             /*
-               Try to load a supporting module.
-             */
-             (void) OpenModule(name,exception);
-           }
-       }
+        {
+          magick_info=GetMagickInfoEntryLocked(name);
+          if (magick_info == (const MagickInfo *) NULL)
+            {
+              /*
+                Try to load a supporting module.
+              */
+              (void) OpenModule(name,exception);
+            }
+        }
       UnlockSemaphoreInfo(module_semaphore);
     }
-#else
-  ARG_NOT_USED(exception);
-#endif /* #if defined(SupportMagickModules) */
 
   /*
     Return whatever we've got
@@ -635,6 +620,9 @@ MagickSignal(int signo, Sigfunc *func)
 #  if defined(SA_INTERRUPT)  /* SunOS */
   act.sa_flags |= SA_INTERRUPT;
 #  endif
+#  if defined(SA_ONSTACK)  /* Use alternate signal stack if available */
+  act.sa_flags |= SA_ONSTACK;
+#  endif
   if (sigaction(signo, &act, &oact) < 0)
     return (SIG_ERR);
   return (oact.sa_handler);
@@ -835,16 +823,16 @@ MagickPanicSignalHandler(int signo)
       MagickSignalHandlerMessage(signo,"abort");
 
       /*
-       Call abort so that we quit with core dump.
+        Call abort so that we quit with core dump.
       */
       abort();
     }
 }
 
 static MagickBool QuitProgressMonitor(const char *task,
-                                     const magick_int64_t quantum,
-                                     const magick_uint64_t span,
-                                     ExceptionInfo *exception)
+                                      const magick_int64_t quantum,
+                                      const magick_uint64_t span,
+                                      ExceptionInfo *exception)
 {
   ARG_NOT_USED(task);
   ARG_NOT_USED(quantum);
@@ -870,13 +858,13 @@ MagickSignalHandler(int signo)
   if (1 == quit_signal_handler_call_count)
     {
       if (MagickInitialized == InitInitialized)
-       {
+        {
 
-         /*
-           Set progress monitor handler to one which always returns
-           MagickFail.
-         */
-         (void) SetMonitorHandler(QuitProgressMonitor);
+          /*
+            Set progress monitor handler to one which always returns
+            MagickFail.
+          */
+          (void) SetMonitorHandler(QuitProgressMonitor);
 
           /*
             Release persistent resources
@@ -888,11 +876,11 @@ MagickSignalHandler(int signo)
           */
           if (signo != SIGINT)
             MagickSignalHandlerMessage(signo,"quitting");
-       }
+        }
 
       /*
-       Invoke _exit(signo) (or equivalent) which avoids invoking
-       registered atexit() functions.
+        Invoke _exit(signo) (or equivalent) which avoids invoking
+        registered atexit() functions.
       */
       SignalHandlerExit(signo);
     }
@@ -900,7 +888,7 @@ MagickSignalHandler(int signo)
 
 /*
    The goal of this routine is to determine whether the passed
-   string is a valid and complete path to a file within the 
+   string is a valid and complete path to a file within the
    filesystem
  */
 #if !defined(UseInstalledMagick)
@@ -916,7 +904,7 @@ IsValidFilesystemPath(const char *path)
       if ((*path == *DirectorySeparator))
         return IsAccessibleNoLogging(path);
 #elif defined(MSWINDOWS)
-      /* For Windows we check to see if the path passed seems to be a 
+      /* For Windows we check to see if the path passed seems to be a
          pathof any kind (contains delimiters) or seem to be either UNC
          path or one with a drive letter spec in it: \\Server\share, C:\
       */
@@ -1094,13 +1082,13 @@ InitializeMagick(const char *path)
       SPINLOCK_RELEASE;
       return;
     }
-  
+
 #if defined(MSWINDOWS)
 # if defined(_DEBUG) && !defined(__BORLANDC__)
   {
     int
       debug;
-    
+
     debug=_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
     debug|=_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_DELAY_FREE_MEM_DF |
       _CRTDBG_LEAK_CHECK_DF;
@@ -1120,7 +1108,7 @@ InitializeMagick(const char *path)
   InitializeMagickRandomGenerator();
 
   (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                       "Initialize Magick");
+                        "Initialize Magick");
 
   /*
     Set the filesystem block size.
@@ -1133,7 +1121,7 @@ InitializeMagick(const char *path)
       {
         long
           block_size_long;
-    
+
         block_size_long = MagickAtoL(p);
         if ((block_size_long > 0L) && (block_size_long <= 2097152L))
           block_size=(size_t) block_size_long;
@@ -1142,7 +1130,7 @@ InitializeMagick(const char *path)
                                 "Ignoring unreasonable MAGICK_IOBUF_SIZE of "
                                 "%ld bbytes", block_size_long);
       }
-    
+
     MagickSetFileSystemBlockSize(block_size);
   }
 
@@ -1169,13 +1157,13 @@ InitializeMagick(const char *path)
   if ((p=getenv("MAGICK_CODER_STABILITY")) != (const char *) NULL)
     {
       if (LocaleCompare(p,"BROKEN") == 0)
-       MinimumCoderClass=BrokenCoderClass;
+        MinimumCoderClass=BrokenCoderClass;
       else if (LocaleCompare(p,"UNSTABLE") == 0)
-       MinimumCoderClass=UnstableCoderClass;
+        MinimumCoderClass=UnstableCoderClass;
       else if (LocaleCompare(p,"STABLE") == 0)
-       MinimumCoderClass=StableCoderClass;
+        MinimumCoderClass=StableCoderClass;
       else if (LocaleCompare(p,"PRIMARY") == 0)
-       MinimumCoderClass=PrimaryCoderClass;
+        MinimumCoderClass=PrimaryCoderClass;
     }
 
 #if defined(MSWINDOWS)
@@ -1191,12 +1179,13 @@ InitializeMagick(const char *path)
   InitializeTypeInfo();             /* Font information */
   InitializeDelegateInfo();         /* External delegate information */
   InitializeColorInfo();            /* Color database */
+  InitializeMagickMonitor();        /* Progress monitor */
   MagickInitializeCommandInfo();    /* Command parser */
 
   /* Let's log the three important setting as we exit this routine */
   (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                       "Path: \"%s\" Name: \"%s\" Filename: \"%s\"",
-                       GetClientPath(),GetClientName(),GetClientFilename());
+                        "Path: \"%s\" Name: \"%s\" Filename: \"%s\"",
+                        GetClientPath(),GetClientName(),GetClientFilename());
 
   /* Now initialized */
   MagickInitialized=InitInitialized;
@@ -1230,18 +1219,10 @@ InitializeMagickInfoList(void)
   assert(magick_semaphore == (SemaphoreInfo *) NULL);
   magick_semaphore=AllocateSemaphoreInfo();
 
-#if defined(SupportMagickModules)
   assert(module_semaphore == (SemaphoreInfo *) NULL);
   module_semaphore=AllocateSemaphoreInfo();
-#endif /* #if defined(SupportMagickModules) */
-
-#if !defined(BuildMagickModules)
-  RegisterStaticModules();          /* Register all static modules */
-#endif /* !defined(BuildMagickModules) */
 
-#if defined(SupportMagickModules)
   InitializeMagickModules();        /* Module loader */
-#endif /* defined(SupportMagickModules) */
 
   return MagickPass;
 }
@@ -1424,8 +1405,8 @@ ListModuleMap(FILE *file,ExceptionInfo *exception)
          {
            (void) fprintf(file, "  <module magick=\"%s\" name=\"%s\" />\n",
                           magick_array[i]->name,
-                         (magick_array[i]->module == NULL ? "(null)" :
-                          magick_array[i]->module));
+                          (magick_array[i]->module == NULL ? "(null)" :
+                           magick_array[i]->module));
          }
      }
    (void) fprintf(file, "</modulemap>\n");
index 08f51ef..33bdee7 100644 (file)
@@ -1,12 +1,12 @@
 /*
-  Copyright (C) 2003 - 2014 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Application Programming Interface declarations.
 */
 #ifndef _MAGICK_MAGICK_H
@@ -83,7 +83,7 @@ typedef struct _MagickInfo
                          *   that it can retrieve a bit of the file header in order to
                          *   support the file header magic logic.
                          */
-    blob_support,      /* coder uses BLOB APIs (default True) */
+    blob_support,       /* coder uses BLOB APIs (default True) */
     thread_support;     /* coder is thread safe (default True) */
 
   CoderClass
@@ -107,7 +107,7 @@ extern MagickExport const char
   *GetImageMagick(const unsigned char *magick,const size_t length);
 
 extern MagickExport MagickBool
-  IsMagickConflict(const char *magick);
+  IsMagickConflict(const char *magick) MAGICK_FUNC_PURE;
 
 extern MagickExport MagickPassFail
   ListModuleMap(FILE *file,ExceptionInfo *exception),
@@ -135,7 +135,7 @@ extern MagickExport MagickInfo
     Get blocksize to use when accessing the filesystem.
   */
   extern size_t
-  MagickGetFileSystemBlockSize(void);
+  MagickGetFileSystemBlockSize(void) MAGICK_FUNC_PURE;
 
   /*
     Set blocksize to use when accessing the filesystem.
index b5df198..4d2bd5d 100644 (file)
 /* Define if you have FlashPIX library */
 #undef HasFPX
 
-/* Define if you have Ghostscript library */
-#undef HasGS
-
 /* Define if you have JBIG library */
 #undef HasJBIG
 
 /* Define if you have zlib compression library */
 #undef HasZLIB
 
+/* Define if you have zstd compression library */
+#undef HasZSTD
+
 /* Define to the sub-directory where libtool stores uninstalled libraries. */
 #undef LT_OBJDIR
 
 /* Define as the return type of signal handlers (`int' or `void'). */
 #undef RETSIGTYPE
 
+/* Setjmp/longjmp are thread safe */
+#undef SETJMP_IS_THREAD_SAFE
+
 /* The size of `off_t', as computed by sizeof. */
 #undef SIZEOF_OFF_T
 
index 508c28f..150620a 100644 (file)
@@ -2,23 +2,23 @@
  * Copyright (c) 1988-1997 Sam Leffler
  * Copyright (c) 1991-1997 Silicon Graphics, Inc.
  *
- * Permission to use, copy, modify, distribute, and sell this software and 
+ * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation for any purpose is hereby granted without fee, provided
  * that (i) the above copyright notices and this permission notice appear in
  * all copies of the software and related documentation, and (ii) the names of
  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  * publicity relating to the software without the specific, prior written
  * permission of Sam Leffler and Silicon Graphics.
- * 
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
- * 
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  * OF THIS SOFTWARE.
  */
 
@@ -150,38 +150,38 @@ static const unsigned char MagickBitRevTable[256] = {
     0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
 };
 static const unsigned char MagickNoBitRevTable[256] = {
-    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 
-    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 
-    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 
-    0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 
-    0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 
-    0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 
-    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 
-    0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 
-    0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 
-    0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 
-    0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 
-    0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 
-    0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 
-    0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 
-    0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 
-    0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 
-    0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 
-    0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 
-    0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 
-    0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 
-    0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 
-    0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 
-    0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 
-    0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 
-    0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 
-    0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 
-    0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 
-    0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 
-    0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 
-    0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 
-    0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 
-    0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 
+    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+    0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+    0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+    0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+    0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+    0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+    0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+    0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+    0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+    0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+    0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+    0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+    0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+    0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+    0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+    0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+    0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+    0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+    0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+    0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+    0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+    0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+    0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+    0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+    0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+    0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+    0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+    0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+    0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
 };
 
 MagickExport const unsigned char*
index fb0a6e0..c1449f5 100644 (file)
@@ -1,6 +1,6 @@
 /*
   Copyright (C) 2005 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
@@ -19,7 +19,7 @@ extern MagickExport void
   MagickSwabUInt32(magick_uint32_t *lp);
 
 extern MagickExport const unsigned char
-  *MagickGetBitRevTable(int);
+  *MagickGetBitRevTable(int) MAGICK_FUNC_CONST;
 
 /*
  * Local Variables:
index cab7550..bb41f81 100644 (file)
@@ -103,13 +103,13 @@ extern "C" {
   typedef unsigned int magick_uint32_t;
 #  define MAGICK_UINT32_F ""
 
-  typedef signed long  magick_int64_t;
-#  define MAGICK_INT64_F "l"
-  typedef unsigned long magick_uint64_t;
-#  define MAGICK_UINT64_F "l"
+  typedef signed long long  magick_int64_t;
+#  define MAGICK_INT64_F "ll"
+  typedef unsigned long long magick_uint64_t;
+#  define MAGICK_UINT64_F "ll"
 
-  typedef unsigned long magick_uintmax_t;
-#  define MAGICK_UINTMAX_F "l"
+  typedef unsigned long long magick_uintmax_t;
+#  define MAGICK_UINTMAX_F "ll"
 
   typedef unsigned long magick_uintptr_t;
 #  define MAGICK_UINTPTR_F "l"
index 633642b..2626675 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 %
 % This program is covered by multiple licenses, which are described in
 % Copyright.txt. You should have received a copy of Copyright.txt with this
@@ -382,7 +382,7 @@ MagickMapAddEntry(MagickMap map,const char *key, const void *object,
               p->previous=0;
               p->next=0;
               spliced_in=MagickTrue;
-              
+
               /*
                 Remove old object
               */
@@ -507,7 +507,20 @@ MagickMapCloneMap(MagickMap map,ExceptionInfo *exception)
   /* LockSemaphoreInfo(map->semaphore); */
 
   map_clone=MagickMapAllocateMap(map->clone_function,map->deallocate_function);
+  if (map_clone == (MagickMap) NULL)
+    {
+      ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,
+                     "MagickMapAllocateMap");
+      return (MagickMap) NULL;
+    }
   iterator=MagickMapAllocateIterator(map);
+  if (iterator == (MagickMapIterator) NULL)
+    {
+      MagickMapDeallocateMap(map_clone);
+      ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,
+                     "MagickMapAllocateIterator");
+      return (MagickMap) NULL;
+    }
   while(MagickMapIterateNext(iterator,&key))
   {
     const void *object=MagickMapDereferenceIterator(iterator,&size);
@@ -669,7 +682,7 @@ MagickMapDeallocateMap(MagickMap map)
         current=p;
         p=p->next;
         MagickMapDestroyObject(current);
-      }        
+      }
   }
 
   (void) UnlockSemaphoreInfo(map->semaphore);
@@ -893,7 +906,7 @@ MagickMapIterateNext(MagickMapIterator iterator,const char **key)
     *key=iterator->member->key;
 
   UnlockSemaphoreInfo(iterator->map->semaphore);
-  
+
   return (iterator->member != 0);
 }
 \f
@@ -1025,7 +1038,7 @@ MagickMapRemoveEntry(MagickMap map,const char *key)
                 {
                   if (p->previous)
                     p->previous->next=p->next;
-                  
+
                   if (p->next)
                     p->next->previous=p->previous;
                 }
index 92b0ae5..6beb7f4 100644 (file)
@@ -1,10 +1,10 @@
 /*
   Copyright (C) 2003 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
 */
 #ifndef _MAGICK_MAP_H
 #define _MAGICK_MAP_H
index 757b852..5101317 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
 #include "magick/studio.h"
 #include "magick/utility.h"
 
+#if defined(MAGICK_MEMORY_HARD_LIMIT)
+#define MEMORY_LIMIT_CHECK(func,size)                                   \
+  do                                                                    \
+    {                                                                   \
+      if (0) fprintf(stderr,"%s: %zu\n", func, size);                   \
+      if (size > (size_t)MAGICK_MEMORY_HARD_LIMIT)                      \
+        {                                                               \
+          fprintf(stderr,"%s: Excessive allocation request %zu\n", func, size); \
+          abort();                                                      \
+        }                                                               \
+  } while(0)
+#else
+#define MEMORY_LIMIT_CHECK(func,size)
+#endif /* MAGICK_MEMORY_HARD_LIMIT */
+
 /*
   Static variables.
 */
@@ -153,6 +168,8 @@ MagickExport void * MagickMalloc(const size_t size)
   if (size == 0)
     return ((void *) NULL);
 
+  MEMORY_LIMIT_CHECK(GetCurrentFunction(),size);
+
   return (MallocFunc)(size);
 }
 \f
@@ -176,7 +193,7 @@ MagickExport void * MagickMalloc(const size_t size)
 %
 %  The requested alignment should be a power of 2 at least as large as
 %  sizeof a void pointer.
-% 
+%
 %  NULL is returned if insufficient memory is available, the requested
 %  size is zero, or integer overflow was detected.
 %
@@ -208,6 +225,8 @@ MagickExport void * MagickMallocAligned(const size_t alignment,const size_t size
   void
     *alligned_p = 0;
 
+  MEMORY_LIMIT_CHECK(GetCurrentFunction(),size);
+
   alligned_size=RoundUpToAlignment(size,alignment);
 
   if ((size == 0) || (alignment < sizeof(void *)) || (alligned_size < size))
@@ -229,12 +248,12 @@ MagickExport void * MagickMallocAligned(const size_t alignment,const size_t size
     alloc_size=(size+alignment-1)+sizeof(void *);
     if (alloc_size > size)
       {
-       if ((alloc_p = (MagickMalloc(alloc_size))) != NULL)
-         {
-           alligned_p=(void*) RoundUpToAlignment((magick_uintptr_t)alloc_p+
-                                                 sizeof(void *),alignment);
-           *((void **)alligned_p-1)=alloc_p;
-         }
+        if ((alloc_p = (MagickMalloc(alloc_size))) != NULL)
+          {
+            alligned_p=(void*) RoundUpToAlignment((magick_uintptr_t)alloc_p+
+                                                  sizeof(void *),alignment);
+            *((void **)alligned_p-1)=alloc_p;
+          }
       }
   }
 #endif
@@ -384,7 +403,7 @@ MagickExport void * MagickMallocCleared(const size_t size)
       p=MagickMalloc(size);
 
       if (p != (void *) NULL)
-       (void) memset(p,0,size);
+        (void) memset(p,0,size);
     }
 
   return p;
@@ -467,6 +486,8 @@ MagickExport void *MagickRealloc(void *memory,const size_t size)
   void
     *new_memory = (void *) NULL;
 
+  MEMORY_LIMIT_CHECK(GetCurrentFunction(),size);
+
   if ((void *) NULL == memory)
     new_memory = (MallocFunc)(size);
   else
index 3a5eda0..43e0ce1 100644 (file)
@@ -1,10 +1,10 @@
 /*
-  Copyright (C) 2003-2013 GraphicsMagick Group
+  Copyright (C) 2003-2018 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Memory Allocation Methods.
 */
 #ifndef _MAGICK_MEMORY_H
@@ -14,9 +14,9 @@
 extern "C" {
 #endif
 
-typedef void *(*MagickMallocFunc)(size_t size) MAGICK_FUNC_ALLOC_SIZE_1ARG(1);
+typedef void *(*MagickMallocFunc)(size_t size);
 typedef void (*MagickFreeFunc)(void *ptr);
-typedef void *(*MagickReallocFunc)(void *ptr, size_t size) MAGICK_FUNC_ALLOC_SIZE_1ARG(2);
+typedef void *(*MagickReallocFunc)(void *ptr, size_t size);
 
 extern MagickExport void
    MagickAllocFunctions(MagickFreeFunc free_func,MagickMallocFunc malloc_func,
@@ -36,7 +36,7 @@ extern MagickExport void
   *MagickMallocArray(const size_t count,const size_t size) MAGICK_FUNC_MALLOC MAGICK_FUNC_ALLOC_SIZE_2ARG(1,2);
 
 extern MagickExport size_t
-  MagickArraySize(const size_t count,const size_t size);
+  MagickArraySize(const size_t count,const size_t size) MAGICK_FUNC_CONST;
 
 /*
   Allocate memory
@@ -76,26 +76,26 @@ extern MagickExport size_t
 /*
   Allocate memory aligned to a specified alignment boundary
 */
-#define MagickAllocateAlignedMemory(type,alignment,size)               \
-  ((((size) != ((size_t) (size))) || (size == 0)) ? ((type) 0) :       \
+#define MagickAllocateAlignedMemory(type,alignment,size)                \
+  ((((size) != ((size_t) (size))) || (size == 0)) ? ((type) 0) :        \
    ((type) MAGICK_ASSUME_ALIGNED(MagickMallocAligned((size_t) alignment, (size_t) (size)),alignment)))
 
 /*
   Allocate array aligned to a specified alignment boundary
 */
-#define MagickAllocateAlignedArray(type,alignment,count,size)          \
-  ((((size) != ((size_t) (size))) || (size == 0)) ? ((type) 0) :       \
+#define MagickAllocateAlignedArray(type,alignment,count,size)           \
+  ((((size) != ((size_t) (size))) || (size == 0)) ? ((type) 0) :        \
    ((type) MAGICK_ASSUME_ALIGNED(MagickMallocAlignedArray((size_t) alignment, (size_t) (count), (size_t) (size)),alignment)))
 
 /*
   Free aligned memory (from MagickAllocateAlignedMemory()) and set pointer to
   NULL
 */
-#define MagickFreeAlignedMemory(memory)                \
-{                                              \
-  void *_magick_mp=memory;                     \
-  MagickFreeAligned(_magick_mp);               \
-  memory=0;                                    \
+#define MagickFreeAlignedMemory(memory)         \
+{                                               \
+  void *_magick_mp=memory;                      \
+  MagickFreeAligned(_magick_mp);                \
+  memory=0;                                     \
 }
 
 #endif /* defined(MAGICK_IMPLEMENTATION) */
index 012e3c5..a0d93b8 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -81,130 +81,7 @@ typedef enum
 static const char
   *BuiltInPath="[Built In]";
 
-static const struct
-{
-  char
-    *magick,
-    *name;
-}
-ModuleAliases[] =
-{
-#define MODULEALIAS(magick,name) {magick,name}
-  MODULEALIAS("3FR","DCRAW"),
-  MODULEALIAS("8BIM","META"),
-  MODULEALIAS("8BIMTEXT","META"),
-  MODULEALIAS("8BIMWTEXT","META"),
-  MODULEALIAS("APP1","META"),
-  MODULEALIAS("APP1JPEG","META"),
-  MODULEALIAS("ARW","DCRAW"),
-  MODULEALIAS("B","GRAY"),
-  MODULEALIAS("BIE","JBIG"),
-  MODULEALIAS("BIGTIFF","TIFF"),
-  MODULEALIAS("BMP2","BMP"),
-  MODULEALIAS("BMP3","BMP"),
-  MODULEALIAS("C","GRAY"),
-  MODULEALIAS("CAL","CALS"),
-  MODULEALIAS("CIN","CINEON"),
-  MODULEALIAS("CMYKA","CMYK"),
-  MODULEALIAS("CR2","DCRAW"),
-  MODULEALIAS("CRW","DCRAW"),
-  MODULEALIAS("CUR","ICON"),
-  MODULEALIAS("DCR","DCRAW"),
-  MODULEALIAS("DCX","PCX"),
-  MODULEALIAS("DNG","DCRAW"),
-  MODULEALIAS("EPDF","PDF"),
-  MODULEALIAS("EPI","PS"),
-  MODULEALIAS("EPS","PS"),
-  MODULEALIAS("EPS2","PS2"),
-  MODULEALIAS("EPS3","PS3"),
-  MODULEALIAS("EPSF","PS"),
-  MODULEALIAS("EPSI","PS"),
-  MODULEALIAS("EPT2","EPT"),
-  MODULEALIAS("EPT3","EPT"),
-  MODULEALIAS("ERF","DCRAW"),
-  MODULEALIAS("EXIF","META"),
-  MODULEALIAS("FILE","URL"),
-  MODULEALIAS("FRACTAL","PLASMA"),
-  MODULEALIAS("FTP","URL"),
-  MODULEALIAS("G","GRAY"),
-  MODULEALIAS("G3","FAX"),
-  MODULEALIAS("GIF87","GIF"),
-  MODULEALIAS("GRANITE","LOGO"),
-  MODULEALIAS("GRAYA","GRAY"),
-  MODULEALIAS("GROUP4RAW","TIFF"),
-  MODULEALIAS("H","LOGO"),
-  MODULEALIAS("HTM","HTML"),
-  MODULEALIAS("HTTP","URL"),
-  MODULEALIAS("ICB","TGA"),
-  MODULEALIAS("ICC","META"),
-  MODULEALIAS("ICM","META"),
-  MODULEALIAS("ICO","ICON"),
-  MODULEALIAS("IMAGE","LOGO"),
-  MODULEALIAS("IPTC","META"),
-  MODULEALIAS("IPTCTEXT","META"),
-  MODULEALIAS("IPTCWTEXT","META"),
-  MODULEALIAS("J2C","JP2"),
-  MODULEALIAS("JBG","JBIG"),
-  MODULEALIAS("JNG","PNG"),
-  MODULEALIAS("JPC","JP2"),
-  MODULEALIAS("JPG","JPEG"),
-  MODULEALIAS("K","GRAY"),
-  MODULEALIAS("K25","DCRAW"),
-  MODULEALIAS("KDC","DCRAW"),
-  MODULEALIAS("LOCALEC","LOCALE"),
-  MODULEALIAS("LOCALEH","LOCALE"),
-  MODULEALIAS("LOCALEMC","LOCALE"),
-  MODULEALIAS("M","GRAY"),
-  MODULEALIAS("M2V","MPEG"),
-  MODULEALIAS("MEF","DCRAW"),
-  MODULEALIAS("MNG","PNG"),
-  MODULEALIAS("MPG","MPEG"),
-  MODULEALIAS("MRW","DCRAW"),
-  MODULEALIAS("NEF","DCRAW"),
-  MODULEALIAS("NETSCAPE","LOGO"),
-  MODULEALIAS("O","GRAY"),
-  MODULEALIAS("ORF","DCRAW"),
-  MODULEALIAS("P7","PNM"),
-  MODULEALIAS("PAL","UYVY"),
-  MODULEALIAS("PAM","PNM"),
-  MODULEALIAS("PATTERN","LOGO"),
-  MODULEALIAS("PBM","PNM"),
-  MODULEALIAS("PCDS","PCD"),
-  MODULEALIAS("PCT","PICT"),
-  MODULEALIAS("PEF","DCRAW"),
-  MODULEALIAS("PFA","TTF"),
-  MODULEALIAS("PFB","TTF"),
-  MODULEALIAS("PGM","PNM"),
-  MODULEALIAS("PGX","JP2"),
-  MODULEALIAS("PICON","XPM"),
-  MODULEALIAS("PM","XPM"),
-  MODULEALIAS("PNG24","PNG"),
-  MODULEALIAS("PNG32","PNG"),
-  MODULEALIAS("PNG8","PNG"),
-  MODULEALIAS("PPM","PNM"),
-  MODULEALIAS("PTIF","TIFF"),
-  MODULEALIAS("R","GRAY"),
-  MODULEALIAS("RAF","DCRAW"),
-  MODULEALIAS("RAS","SUN"),
-  MODULEALIAS("RGBA","RGB"),
-  MODULEALIAS("ROSE","LOGO"),
-  MODULEALIAS("SHTML","HTML"),
-  MODULEALIAS("SR2","DCRAW"),
-  MODULEALIAS("SRF","DCRAW"),
-  MODULEALIAS("SVGZ","SVG"),
-  MODULEALIAS("TEXT","TXT"),
-  MODULEALIAS("TIF","TIFF"),
-  MODULEALIAS("VDA","TGA"),
-  MODULEALIAS("VST","TGA"),
-  MODULEALIAS("X3F","DCRAW"),
-  MODULEALIAS("XMP","META"),
-  MODULEALIAS("XTRNARRAY","XTRN"),
-  MODULEALIAS("XTRNBLOB","XTRN"),
-  MODULEALIAS("XTRNFILE","XTRN"),
-  MODULEALIAS("XTRNIMAGE","XTRN"),
-  MODULEALIAS("XV","VIFF"),
-  MODULEALIAS("Y","GRAY")
-};
+#include "magick/module_aliases.h"
 
 /*
   Coder module list
@@ -308,15 +185,15 @@ static unsigned int
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  DestroyMagickResources() destroys the resource environment.
+%  DestroyMagickModules() destroys the modules environment.
 %
-%  The format of the DestroyMagickResources() method is:
+%  The format of the DestroyMagickModules() method is:
 %
-%      DestroyMagickResources(void)
+%      DestroyMagickModules(void)
 %
 %
 */
-MagickExport void
+void
 DestroyMagickModules(void)
 {
   DestroyModuleInfo();
@@ -368,10 +245,10 @@ DestroyModuleInfoEntry(ModuleInfo *entry)
       MagickFreeMemory(entry->magick);
       MagickFreeMemory(entry->name);
     }
-  MagickFreeMemory(entry);    
+  MagickFreeMemory(entry);
 }
 
-MagickExport void
+void
 DestroyModuleInfo(void)
 {
   CoderInfo
@@ -463,9 +340,9 @@ DestroyModuleInfo(void)
 %      arguments.
 %
 */
-MagickExport MagickPassFail
+MagickPassFail
 ExecuteModuleProcess(const char *tag,Image **image,
-                    const int argc,char **argv)
+                     const int argc,char **argv)
 {
   ModuleHandle
     handle;
@@ -503,7 +380,7 @@ ExecuteModuleProcess(const char *tag,Image **image,
       {
         char
           message[MaxTextExtent];
-        
+
         FormatString(message,"\"%.256s: %.256s\"",module_path,lt_dlerror());
         ThrowException(&(*image)->exception,ModuleError,UnableToLoadModule,
           message);
@@ -646,7 +523,7 @@ GetCoderInfo(const char *tag, ExceptionInfo *exception)
 
 static MagickPassFail
 FindMagickModule(const char *filename,MagickModuleType module_type,
-                char *path,ExceptionInfo *exception)
+                 char *path,ExceptionInfo *exception)
 {
   MagickMap
     path_map = (MagickMap) NULL;
@@ -664,7 +541,7 @@ FindMagickModule(const char *filename,MagickModuleType module_type,
   assert(path != (char *) NULL);
   assert(exception != (ExceptionInfo *) NULL);
   (void) strlcpy(path,filename,MaxTextExtent);
-  
+
   if (InitializeModuleSearchPath(module_type,exception) == MagickFail)
     return (status);
 
@@ -688,15 +565,22 @@ FindMagickModule(const char *filename,MagickModuleType module_type,
         break;
       }
     }
-  
+
   path_map_iterator=MagickMapAllocateIterator(path_map);
-  
+  if (path_map_iterator == (MagickMapIterator) NULL)
+    {
+      path[0]='\0';
+      ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,
+                     "MagickMapAllocateIterator");
+      return MagickFail;
+    }
+
   if (IsEventLogging())
     {
       char
         list_seperator[2],
         *search_path=0;
-      
+
       list_seperator[0]=DirectoryListSeparator;
       list_seperator[1]='\0';
       while(MagickMapIterateNext(path_map_iterator,&key))
@@ -706,21 +590,21 @@ FindMagickModule(const char *filename,MagickModuleType module_type,
           (void) ConcatenateString(&search_path,
                                    MagickMapDereferenceIterator(path_map_iterator,0));
         }
-      
+
       (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
                             "Searching for module file \"%s\" in path \"%s\"",
-                           filename,search_path);
-      
+                            filename,search_path);
+
       MagickFreeMemory(search_path);
       MagickMapIterateToFront(path_map_iterator);
     }
-  
+
   while(MagickMapIterateNext(path_map_iterator,&key))
     {
       FormatString(path,"%.1024s%.256s",
                    (const char *)MagickMapDereferenceIterator(path_map_iterator,0),
                    filename);
-      
+
       if (IsAccessible(path))
         {
           status=MagickPass;
@@ -763,9 +647,9 @@ FindMagickModule(const char *filename,MagickModuleType module_type,
 */
 static MagickPassFail
 GetModuleListForDirectory(const char *path,           /* Directory to scan. */
-                         char **list,                /* List to extend. */
-                         unsigned long *max_entries, /* Allocated list entries. */
-                         ExceptionInfo *exception )  /* Any exception. */
+                          char **list,                /* List to extend. */
+                          unsigned long *max_entries, /* Allocated list entries. */
+                          ExceptionInfo *exception )  /* Any exception. */
 {
   char
     module_tag[MaxTextExtent];
@@ -867,9 +751,6 @@ GetModuleList(ExceptionInfo *exception)
   unsigned long
     max_entries;
 
-  if (InitializeModuleSearchPath(MagickCoderModule,exception) == MagickFail)
-    return ((char **) NULL);
-
   max_entries=MAX_MODULES;
   modules=MagickAllocateMemory(char **,(max_entries+1)*sizeof(char *));
   if (modules == (char **) NULL)
@@ -912,7 +793,7 @@ GetModuleList(ExceptionInfo *exception)
 %
 %
 */
-MagickExport void
+void
 InitializeMagickModules(void)
 {
   ExceptionInfo
@@ -968,7 +849,7 @@ InitializeMagickModules(void)
 */
 static void
 AddModulePath(MagickMap path_map, unsigned int *path_index,
-             const char *path,ExceptionInfo *exception)
+              const char *path,ExceptionInfo *exception)
 {
   char
     key[MaxTextExtent];
@@ -1004,7 +885,7 @@ ChopPathComponents(char *path,const unsigned long components)
 
 MagickPassFail
 InitializeModuleSearchPath(MagickModuleType module_type,
-                          ExceptionInfo *exception)
+                           ExceptionInfo *exception)
 {
   MagickMap
     path_map = (MagickMap) NULL;
@@ -1066,19 +947,22 @@ InitializeModuleSearchPath(MagickModuleType module_type,
       const char
         *end = NULL,
         *start = module_path;
-      
+
       end=start+strlen(start);
       while ( start < end )
         {
           char
             buffer[MaxTextExtent];
-          
+
           const char
             *seperator;
-          
+
           int
             length;
-          
+
+          MagickBool
+            skip=MagickFalse;
+
           seperator = strchr(start,DirectoryListSeparator);
           if (seperator)
             length=seperator-start;
@@ -1088,9 +972,52 @@ InitializeModuleSearchPath(MagickModuleType module_type,
             length = MaxTextExtent-1;
           (void) strncpy(buffer,start,length);
           buffer[length]='\0';
-          if (buffer[length-1] != DirectorySeparator[0])
-            (void) strcat(buffer,DirectorySeparator);
-          AddModulePath(path_map,&path_index,buffer,exception);
+#if HAVE_REALPATH
+          {
+            char
+              real_path[PATH_MAX+1];
+
+            if (realpath(buffer,real_path) != NULL)
+              {
+                length=strlcpy(buffer,real_path,sizeof(buffer));
+                if ((size_t) length >= sizeof(buffer))
+                  {
+                    /* Buffer overflow */
+                    (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+                                          "Module path: Buffer overflow of "
+                                          "component \"%s\"",
+                                          real_path);
+                    length=0;
+                    skip=MagickTrue;
+                  }
+              }
+            else
+              {
+                /* Path does not exist */
+                (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+                                      "Module path: Skipping invalid path "
+                                      "component \"%s\" (%s)",
+                                      buffer,strerror(errno));
+                skip=MagickTrue;
+              }
+          }
+#else /* !HAVE_REALPATH */
+          if (IsAccessibleNoLogging(buffer) != MagickTrue)
+            {
+              /* Path does not exist */
+              (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+                                    "Module path: Skipping invalid path "
+                                    "component \"%s\" (%s)",
+                                    buffer,strerror(errno));
+              skip=MagickTrue;
+            }
+#endif
+          if (skip == MagickFalse)
+            {
+              if (buffer[length-1] != DirectorySeparator[0])
+                (void) strcat(buffer,DirectorySeparator);
+              AddModulePath(path_map,&path_index,buffer,exception);
+            }
           start += length+1;
         }
     }
@@ -1269,7 +1196,7 @@ InitializeModuleSearchPath(MagickModuleType module_type,
 %
 %
 */
-MagickExport const ModuleInfo *
+const ModuleInfo *
 GetModuleInfo(const char *name,ExceptionInfo *exception)
 {
   const ModuleInfo
@@ -1284,30 +1211,30 @@ GetModuleInfo(const char *name,ExceptionInfo *exception)
   else
     {
       register ModuleInfo
-       *p;
+        *p;
 
       for (p=module_list; p != (ModuleInfo *) NULL; p=p->next)
-       if (LocaleCompare(p->name,name) == 0)
-         break;
+        if (LocaleCompare(p->name,name) == 0)
+          break;
 
       if (p != (ModuleInfo *) NULL)
-       {
-         module_info=p;
-         if (p != module_list)
-           {
-             /*
-               Self-adjusting list.
-             */
-             if (p->previous != (ModuleInfo *) NULL)
-               p->previous->next=p->next;
-             if (p->next != (ModuleInfo *) NULL)
-               p->next->previous=p->previous;
-             p->previous=(ModuleInfo *) NULL;
-             p->next=module_list;
-             module_list->previous=p;
-             module_list=p;
-           }
-       }
+        {
+          module_info=p;
+          if (p != module_list)
+            {
+              /*
+                Self-adjusting list.
+              */
+              if (p->previous != (ModuleInfo *) NULL)
+                p->previous->next=p->next;
+              if (p->next != (ModuleInfo *) NULL)
+                p->next->previous=p->previous;
+              p->previous=(ModuleInfo *) NULL;
+              p->next=module_list;
+              module_list->previous=p;
+              module_list=p;
+            }
+        }
     }
   return (module_info);
 }
@@ -1404,7 +1331,7 @@ ListModuleInfo(FILE *file,ExceptionInfo *exception)
 %
 %
 */
-MagickExport MagickPassFail
+MagickPassFail
 OpenModule(const char *module,ExceptionInfo *exception)
 {
   {
@@ -1565,7 +1492,7 @@ OpenModule(const char *module,ExceptionInfo *exception)
 %    o exception: Return any errors or warnings in this structure.
 %
 */
-MagickExport MagickPassFail
+MagickPassFail
 OpenModules(ExceptionInfo *exception)
 {
   (void) GetMagickInfo((char *) NULL,exception);
@@ -1638,8 +1565,8 @@ OpenModules(ExceptionInfo *exception)
 */
 static MagickPassFail
 ReadModuleConfigureFile(const char *basename,
-                       const unsigned int depth,
-                       ExceptionInfo *exception)
+                        const unsigned int depth,
+                        ExceptionInfo *exception)
 {
   size_t
     length;
@@ -1651,36 +1578,36 @@ ReadModuleConfigureFile(const char *basename,
   if (depth == 0)
     {
       size_t
-       i;
+        i;
 
       /*
-       Load default set of module aliases from the static aliases table.
+        Load default set of module aliases from the static aliases table.
       */
       for (i=0 ; i < sizeof(ModuleAliases)/sizeof(ModuleAliases[0]); i++)
-       {
-         ModuleInfo
-           *module_info;
-
-         module_info=MagickAllocateMemory(ModuleInfo *,sizeof(ModuleInfo));
-         if (module_info == (ModuleInfo *) NULL)
-           MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
-                             UnableToAllocateModuleInfo);
-         module_info->path=(char *) BuiltInPath;
-         module_info->magick=(char *) ModuleAliases[i].magick;
-         module_info->name=(char *) ModuleAliases[i].name;
-         module_info->stealth=MagickFalse;
-         module_info->signature=MagickSignature;
-         module_info->previous=(ModuleInfo *) NULL;
-         module_info->next=(ModuleInfo *) NULL;
-         if (module_list == (ModuleInfo *) NULL)
-           {
-             module_list=module_info;
-             continue;
-           }
-         module_list->next=module_info;
-         module_info->previous=module_list;
-         module_list=module_list->next;
-       }
+        {
+          ModuleInfo
+            *module_info;
+
+          module_info=MagickAllocateMemory(ModuleInfo *,sizeof(ModuleInfo));
+          if (module_info == (ModuleInfo *) NULL)
+            MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
+                              UnableToAllocateModuleInfo);
+          module_info->path=(char *) BuiltInPath;
+          module_info->magick=(char *) ModuleAliases[i].magick;
+          module_info->name=(char *) ModuleAliases[i].name;
+          module_info->stealth=MagickFalse;
+          module_info->signature=MagickSignature;
+          module_info->previous=(ModuleInfo *) NULL;
+          module_info->next=(ModuleInfo *) NULL;
+          if (module_list == (ModuleInfo *) NULL)
+            {
+              module_list=module_info;
+              continue;
+            }
+          module_list->next=module_info;
+          module_info->previous=module_list;
+          module_list=module_list->next;
+        }
     }
 
   /*
@@ -1690,12 +1617,12 @@ ReadModuleConfigureFile(const char *basename,
   if (depth == 0)
     {
       ExceptionInfo
-       exception_local;
+        exception_local;
 
       GetExceptionInfo(&exception_local);
       xml=(char *) GetConfigureBlob(basename,path,&length,&exception_local);
       if (exception_local.severity != ConfigureError)
-       CopyException(exception,&exception_local);
+        CopyException(exception,&exception_local);
       DestroyExceptionInfo(&exception_local);
     }
   else
@@ -1705,12 +1632,12 @@ ReadModuleConfigureFile(const char *basename,
   if (xml != (char *) NULL)
     {
       char
-       keyword[MaxTextExtent],
-       *q,
-       *token;
+        keyword[MaxTextExtent],
+        *q,
+        *token;
 
       MagickBool
-       in_entry;
+        in_entry;
 
       size_t
         token_max_length;
@@ -1719,155 +1646,155 @@ ReadModuleConfigureFile(const char *basename,
       token_max_length=strlen(token);
       in_entry=MagickFalse;
       for (q=xml; *q != '\0'; )
-       {
-         /*
-           Interpret XML.
-         */
-         MagickGetToken(q,&q,token,token_max_length);
-         if (*token == '\0')
-           break;
-         (void) strlcpy(keyword,token,sizeof(keyword));
-         if (LocaleNCompare(keyword,"<!--",4) == 0)
-           {
-             /*
-               Comment element.
-             */
-             while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
-               MagickGetToken(q,&q,token,token_max_length);
-             continue;
-           }
-         if (LocaleCompare(keyword,"<include") == 0)
-           {
-             /*
-               Include element.
-             */
-             while ((*token != '>') && (*q != '\0'))
-               {
-                 (void) strlcpy(keyword,token,MaxTextExtent);
-                 MagickGetToken(q,&q,token,token_max_length);
-                 if (*token != '=')
-                   continue;
-                 MagickGetToken(q,&q,token,token_max_length);
-                 if (LocaleCompare(keyword,"file") == 0)
-                   {
-                     if (depth > 200)
-                       ThrowException(exception,ConfigureError,
-                                      IncludeElementNestedTooDeeply,path);
-                     else
-                       {
-                         char
-                           filename[MaxTextExtent];
-
-                         GetPathComponent(path,HeadPath,filename);
-                         if (*filename != '\0')
-                           (void) strlcat(filename,DirectorySeparator,sizeof(filename));
-                         (void) strlcat(filename,token,sizeof(filename));
-                         (void) ReadModuleConfigureFile(filename,depth+1,exception);
-                       }
-                     if (module_list != (ModuleInfo *) NULL)
-                       while (module_list->next != (ModuleInfo *) NULL)
-                         module_list=module_list->next;
-                   }
-               }
-             continue;
-           }
-         if (LocaleCompare(keyword,"<module") == 0)
-           {
-             ModuleInfo
-               *module_info;
-
-             /*
-               Allocate memory for the module list.
-             */
-             in_entry=MagickTrue;
-             module_info=MagickAllocateMemory(ModuleInfo *,sizeof(ModuleInfo));
-             if (module_info == (ModuleInfo *) NULL)
-               MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
-                                 UnableToAllocateModuleInfo);
-             (void) memset(module_info,0,sizeof(ModuleInfo));
-             module_info->path=AcquireString(path);
-             module_info->signature=MagickSignature;
-             if (module_list == (ModuleInfo *) NULL)
-               {
-                 module_list=module_info;
-                 continue;
-               }
-             module_list->next=module_info;
-             module_info->previous=module_list;
-             module_list=module_list->next;
-             continue;
-           }
-         if (LocaleCompare(keyword,"/>") == 0)
-           {
-             /*
-               Closing a module alias specification.
-             */
-             if (in_entry)
-               {
-                 /*
-                   Remove any existing entry with same name (last one wins).
-                 */
-                 {
-                   ModuleInfo
-                     *module_info;
-             
-                   for (module_info=module_list->previous;
-                        module_info != (ModuleInfo *) NULL;
-                        module_info=module_info->previous)
-                     {
-                       if (LocaleCompare(module_list->magick,module_info->magick) == 0)
-                         {
-                           DestroyModuleInfoEntry(module_info);
-                           break;
-                         }
-                     }
-                 }
-                 in_entry=MagickFalse;
-               }
-           }
-         if (module_list == (ModuleInfo *) NULL)
-           continue;
-         MagickGetToken(q,(char **) NULL,token,token_max_length);
-         if (*token != '=')
-           continue;
-         MagickGetToken(q,&q,token,token_max_length);
-         MagickGetToken(q,&q,token,token_max_length);
-         switch (*keyword)
-           {
-           case 'M':
-           case 'm':
-             {
-               if (LocaleCompare((char *) keyword,"magick") == 0)
-                 {
-                   module_list->magick=AcquireString(token);
-                   break;
-                 }
-               break;
-             }
-           case 'N':
-           case 'n':
-             {
-               if (LocaleCompare((char *) keyword,"name") == 0)
-                 {
-                   module_list->name=AcquireString(token);
-                   break;
-                 }
-               break;
-             }
-           case 'S':
-           case 's':
-             {
-               if (LocaleCompare((char *) keyword,"stealth") == 0)
-                 {
-                   module_list->stealth=LocaleCompare(token,"True") == 0;
-                   break;
-                 }
-               break;
-             }
-           default:
-             break;
-           }
-       }
+        {
+          /*
+            Interpret XML.
+          */
+          MagickGetToken(q,&q,token,token_max_length);
+          if (*token == '\0')
+            break;
+          (void) strlcpy(keyword,token,sizeof(keyword));
+          if (LocaleNCompare(keyword,"<!--",4) == 0)
+            {
+              /*
+                Comment element.
+              */
+              while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
+                MagickGetToken(q,&q,token,token_max_length);
+              continue;
+            }
+          if (LocaleCompare(keyword,"<include") == 0)
+            {
+              /*
+                Include element.
+              */
+              while ((*token != '>') && (*q != '\0'))
+                {
+                  (void) strlcpy(keyword,token,MaxTextExtent);
+                  MagickGetToken(q,&q,token,token_max_length);
+                  if (*token != '=')
+                    continue;
+                  MagickGetToken(q,&q,token,token_max_length);
+                  if (LocaleCompare(keyword,"file") == 0)
+                    {
+                      if (depth > 200)
+                        ThrowException(exception,ConfigureError,
+                                       IncludeElementNestedTooDeeply,path);
+                      else
+                        {
+                          char
+                            filename[MaxTextExtent];
+
+                          GetPathComponent(path,HeadPath,filename);
+                          if (*filename != '\0')
+                            (void) strlcat(filename,DirectorySeparator,sizeof(filename));
+                          (void) strlcat(filename,token,sizeof(filename));
+                          (void) ReadModuleConfigureFile(filename,depth+1,exception);
+                        }
+                      if (module_list != (ModuleInfo *) NULL)
+                        while (module_list->next != (ModuleInfo *) NULL)
+                          module_list=module_list->next;
+                    }
+                }
+              continue;
+            }
+          if (LocaleCompare(keyword,"<module") == 0)
+            {
+              ModuleInfo
+                *module_info;
+
+              /*
+                Allocate memory for the module list.
+              */
+              in_entry=MagickTrue;
+              module_info=MagickAllocateMemory(ModuleInfo *,sizeof(ModuleInfo));
+              if (module_info == (ModuleInfo *) NULL)
+                MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
+                                  UnableToAllocateModuleInfo);
+              (void) memset(module_info,0,sizeof(ModuleInfo));
+              module_info->path=AcquireString(path);
+              module_info->signature=MagickSignature;
+              if (module_list == (ModuleInfo *) NULL)
+                {
+                  module_list=module_info;
+                  continue;
+                }
+              module_list->next=module_info;
+              module_info->previous=module_list;
+              module_list=module_list->next;
+              continue;
+            }
+          if (LocaleCompare(keyword,"/>") == 0)
+            {
+              /*
+                Closing a module alias specification.
+              */
+              if (in_entry)
+                {
+                  /*
+                    Remove any existing entry with same name (last one wins).
+                  */
+                  {
+                    ModuleInfo
+                      *module_info;
+
+                    for (module_info=module_list->previous;
+                         module_info != (ModuleInfo *) NULL;
+                         module_info=module_info->previous)
+                      {
+                        if (LocaleCompare(module_list->magick,module_info->magick) == 0)
+                          {
+                            DestroyModuleInfoEntry(module_info);
+                            break;
+                          }
+                      }
+                  }
+                  in_entry=MagickFalse;
+                }
+            }
+          if (module_list == (ModuleInfo *) NULL)
+            continue;
+          MagickGetToken(q,(char **) NULL,token,token_max_length);
+          if (*token != '=')
+            continue;
+          MagickGetToken(q,&q,token,token_max_length);
+          MagickGetToken(q,&q,token,token_max_length);
+          switch (*keyword)
+            {
+            case 'M':
+            case 'm':
+              {
+                if (LocaleCompare((char *) keyword,"magick") == 0)
+                  {
+                    module_list->magick=AcquireString(token);
+                    break;
+                  }
+                break;
+              }
+            case 'N':
+            case 'n':
+              {
+                if (LocaleCompare((char *) keyword,"name") == 0)
+                  {
+                    module_list->name=AcquireString(token);
+                    break;
+                  }
+                break;
+              }
+            case 'S':
+            case 's':
+              {
+                if (LocaleCompare((char *) keyword,"stealth") == 0)
+                  {
+                    module_list->stealth=LocaleCompare(token,"True") == 0;
+                    break;
+                  }
+                break;
+              }
+            default:
+              break;
+            }
+        }
       MagickFreeMemory(token);
       MagickFreeMemory(xml);
     }
index e0f5d76..ea423f4 100644 (file)
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2003 - 2009 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Modules Methods.
 */
 #ifndef _MAGICK_MODULE_H
@@ -22,6 +22,11 @@ extern "C" {
 extern MagickExport MagickPassFail
   ListModuleInfo(FILE *file,ExceptionInfo *exception);
 
+extern MagickExport MagickPassFail
+  ExecuteModuleProcess(const char *tag,Image **image,
+                       const int argc,char **argv);
+
+
 #if defined(MAGICK_IMPLEMENTATION)
 
 /*
@@ -33,12 +38,12 @@ extern MagickExport MagickPassFail
 typedef struct _ModuleInfo
 {
   char
-    *path,             /* Path to modules.mgk which created alias */
-    *magick,           /* Format name */
-    *name;             /* Name of module supporting format. */
+    *path,              /* Path to modules.mgk which created alias */
+    *magick,            /* Format name */
+    *name;              /* Name of module supporting format. */
 
   unsigned int
-    stealth;           /* If true, hide when printing module list */
+    stealth;            /* If true, hide when printing module list */
 
   unsigned long
     signature;
@@ -48,23 +53,21 @@ typedef struct _ModuleInfo
     *next;
 } ModuleInfo;
 
-extern MagickExport const ModuleInfo
+extern const ModuleInfo
   *GetModuleInfo(const char *,ExceptionInfo *);
 
-extern MagickExport MagickPassFail
-  ExecuteModuleProcess(const char *tag,Image **image,
-                      const int argc,char **argv),
+extern MagickPassFail
   ExecuteStaticModuleProcess(const char *,Image **,const int,char **),
   ListModuleInfo(FILE *file,ExceptionInfo *exception),
   OpenModule(const char *module,ExceptionInfo *exception),
   OpenModules(ExceptionInfo *exception);
 
-extern MagickExport void
+extern void
   DestroyModuleInfo(void),
   DestroyMagickModules(void),
   InitializeMagickModules(void),
-  RegisterStaticModules(void),
-  UnregisterStaticModules(void);
+  RegisterStaticModules(void) MAGICK_FUNC_DEPRECATED,
+  UnregisterStaticModules(void) MAGICK_FUNC_DEPRECATED;
 
 #endif /* defined(MAGICK_IMPLEMENTATION) */
 
diff --git a/magick/module_aliases.h b/magick/module_aliases.h
new file mode 100644 (file)
index 0000000..0ab5061
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
+
+  This program is covered by multiple licenses, which are described in
+  Copyright.txt. You should have received a copy of Copyright.txt with this
+  package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
+  GraphicsMagick Module Aliases
+
+  This file should only be included into module.c and static.c.
+*/
+#ifndef _MAGICK_MODULE_ALIASES_H
+#define _MAGICK_MODULE_ALIASES_H
+
+typedef struct ModuleAlias
+{
+  char
+    *magick,
+    *name;
+  const unsigned int
+     magick_len;
+} ModuleAlias;
+
+/*
+  This list must be ordered by 'magick' in an ascending order matching
+  strcmp().
+*/
+static ModuleAlias
+ModuleAliases[] =
+  {
+#define MODULEALIAS(magick,name) {magick,name,sizeof(magick)-1}
+    MODULEALIAS("3FR","DCRAW"),
+    MODULEALIAS("8BIM","META"),
+    MODULEALIAS("8BIMTEXT","META"),
+    MODULEALIAS("8BIMWTEXT","META"),
+    MODULEALIAS("APP1","META"),
+    MODULEALIAS("APP1JPEG","META"),
+    MODULEALIAS("ARW","DCRAW"),
+    MODULEALIAS("B","GRAY"),
+    MODULEALIAS("BIE","JBIG"),
+    MODULEALIAS("BIGTIFF","TIFF"),
+    MODULEALIAS("BMP2","BMP"),
+    MODULEALIAS("BMP3","BMP"),
+    MODULEALIAS("C","GRAY"),
+    MODULEALIAS("CAL","CALS"),
+    MODULEALIAS("CIN","CINEON"),
+    MODULEALIAS("CMYKA","CMYK"),
+    MODULEALIAS("CR2","DCRAW"),
+    MODULEALIAS("CRW","DCRAW"),
+    MODULEALIAS("CUR","ICON"),
+    MODULEALIAS("DCR","DCRAW"),
+    MODULEALIAS("DCX","PCX"),
+    MODULEALIAS("DNG","DCRAW"),
+    MODULEALIAS("EPDF","PDF"),
+    MODULEALIAS("EPI","PS"),
+    MODULEALIAS("EPS","PS"),
+    MODULEALIAS("EPS2","PS2"),
+    MODULEALIAS("EPS3","PS3"),
+    MODULEALIAS("EPSF","PS"),
+    MODULEALIAS("EPSI","PS"),
+    MODULEALIAS("EPT2","EPT"),
+    MODULEALIAS("EPT3","EPT"),
+    MODULEALIAS("ERF","DCRAW"),
+    MODULEALIAS("EXIF","META"),
+    MODULEALIAS("FILE","URL"),
+    MODULEALIAS("FRACTAL","PLASMA"),
+    MODULEALIAS("FTP","URL"),
+    MODULEALIAS("G","GRAY"),
+    MODULEALIAS("G3","FAX"),
+    MODULEALIAS("GIF87","GIF"),
+    MODULEALIAS("GRANITE","LOGO"),
+    MODULEALIAS("GRAYA","GRAY"),
+    MODULEALIAS("GROUP4RAW","TIFF"),
+    MODULEALIAS("H","LOGO"),
+    MODULEALIAS("HTM","HTML"),
+    MODULEALIAS("HTTP","URL"),
+    MODULEALIAS("ICB","TGA"),
+    MODULEALIAS("ICC","META"),
+    MODULEALIAS("ICM","META"),
+    MODULEALIAS("ICO","ICON"),
+    MODULEALIAS("ICODIB", "DIB"),
+    MODULEALIAS("IMAGE","LOGO"),
+    MODULEALIAS("IPTC","META"),
+    MODULEALIAS("IPTCTEXT","META"),
+    MODULEALIAS("IPTCWTEXT","META"),
+    MODULEALIAS("J2C","JP2"),
+    MODULEALIAS("JBG","JBIG"),
+    MODULEALIAS("JNG","PNG"),
+    MODULEALIAS("JPC","JP2"),
+    MODULEALIAS("JPG","JPEG"),
+    MODULEALIAS("K","GRAY"),
+    MODULEALIAS("K25","DCRAW"),
+    MODULEALIAS("KDC","DCRAW"),
+    MODULEALIAS("LOCALEC","LOCALE"),
+    MODULEALIAS("LOCALEH","LOCALE"),
+    MODULEALIAS("LOCALEMC","LOCALE"),
+    MODULEALIAS("M","GRAY"),
+    MODULEALIAS("M2V","MPEG"),
+    MODULEALIAS("MEF","DCRAW"),
+    MODULEALIAS("MNG","PNG"),
+    MODULEALIAS("MPG","MPEG"),
+    MODULEALIAS("MRW","DCRAW"),
+    MODULEALIAS("NEF","DCRAW"),
+    MODULEALIAS("NETSCAPE","LOGO"),
+    MODULEALIAS("O","GRAY"),
+    MODULEALIAS("ORF","DCRAW"),
+    MODULEALIAS("P7","PNM"),
+    MODULEALIAS("PAL","UYVY"),
+    MODULEALIAS("PAM","PNM"),
+    MODULEALIAS("PATTERN","LOGO"),
+    MODULEALIAS("PBM","PNM"),
+    MODULEALIAS("PCDS","PCD"),
+    MODULEALIAS("PCT","PICT"),
+    MODULEALIAS("PEF","DCRAW"),
+    MODULEALIAS("PFA","TTF"),
+    MODULEALIAS("PFB","TTF"),
+    MODULEALIAS("PGM","PNM"),
+    MODULEALIAS("PGX","JP2"),
+    MODULEALIAS("PICON","XPM"),
+    MODULEALIAS("PM","XPM"),
+    MODULEALIAS("PNG24","PNG"),
+    MODULEALIAS("PNG32","PNG"),
+    MODULEALIAS("PNG8","PNG"),
+    MODULEALIAS("PPM","PNM"),
+    MODULEALIAS("PTIF","TIFF"),
+    MODULEALIAS("R","GRAY"),
+    MODULEALIAS("RAF","DCRAW"),
+    MODULEALIAS("RAS","SUN"),
+    MODULEALIAS("RGBA","RGB"),
+    MODULEALIAS("ROSE","LOGO"),
+    MODULEALIAS("SHTML","HTML"),
+    MODULEALIAS("SR2","DCRAW"),
+    MODULEALIAS("SRF","DCRAW"),
+    MODULEALIAS("SVGZ","SVG"),
+    MODULEALIAS("TEXT","TXT"),
+    MODULEALIAS("TIF","TIFF"),
+    MODULEALIAS("VDA","TGA"),
+    MODULEALIAS("VST","TGA"),
+    MODULEALIAS("X3F","DCRAW"),
+    MODULEALIAS("XMP","META"),
+    MODULEALIAS("XTRNARRAY","XTRN"),
+    MODULEALIAS("XTRNBLOB","XTRN"),
+    MODULEALIAS("XTRNFILE","XTRN"),
+    MODULEALIAS("XTRNIMAGE","XTRN"),
+    MODULEALIAS("XV","VIFF"),
+    MODULEALIAS("Y","GRAY")
+  };
+
+#endif /* _MAGICK_MODULE_ALIASES_H */
index be8da4a..8d29112 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -38,6 +38,7 @@
 */
 #include "magick/studio.h"
 #include "magick/monitor.h"
+#include "magick/semaphore.h"
 #include "magick/utility.h"
 \f
 /*
 */
 static MonitorHandler
   monitor_handler = (MonitorHandler) NULL;
+
+static SemaphoreInfo
+  *monitor_semaphore = 0;
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   D e s t r o y M a g i c k M o n i t o r                                   %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  DestroyMagickMonitor() destroys the monitor environment.
+%
+%  The format of the DestroyMagickMonitor() method is:
+%
+%      DestroyMagickMonitor(void)
+%
+%
+*/
+void
+DestroyMagickMonitor(void)
+{
+  DestroySemaphoreInfo(&monitor_semaphore);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   I n i t i a l i z e M a g i c k M o n i t o r                             %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  InitializeMagickMonitor() initializes the module loader.
+%
+%  The format of the InitializeMagickMonitor() method is:
+%
+%      MagickPassFail InitializeMagickMonitor(void)
+%
+%
+*/
+MagickPassFail
+InitializeMagickMonitor(void)
+{
+  assert(monitor_semaphore == (SemaphoreInfo *) NULL);
+  monitor_semaphore=AllocateSemaphoreInfo();
+  return MagickPass;
+}
 \f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -62,6 +118,8 @@ static MonitorHandler
 %  on success otherwise False if an error is encountered, e.g. if there was a
 %  user interrupt.
 %
+%  This function is deprecated.  Please use MagickMonitorFormatted() instead.
+%
 %  The format of the MagickMonitor method is:
 %
 %      MagickPassFail MagickMonitor(const char *text,
@@ -87,13 +145,16 @@ MagickMonitor(const char *text,
               ExceptionInfo *exception)
 {
   MagickPassFail
-    status;
+    status = MagickPass;
 
   assert(text != (const char *) NULL);
   ProcessPendingEvents(text);
-  status=MagickPass;
   if (monitor_handler != (MonitorHandler) NULL)
-    status=(*monitor_handler)(text,quantum,span,exception);
+    {
+      LockSemaphoreInfo(monitor_semaphore);
+      status=(*monitor_handler)(text,quantum,span,exception);
+      UnlockSemaphoreInfo(monitor_semaphore);
+    }
   return(status);
 }
 \f
@@ -111,8 +172,16 @@ MagickMonitor(const char *text,
 %  MagickMonitorFormatted() calls the monitor handler method with a
 %  printf type format specification and variable argument list.  Also
 %  passed are quantum and span values which provide a measure of
-%  completion.  The method returns True on success otherwise False if
-%  an error is encountered, e.g. if there was a user interrupt.
+%  completion.  The method returns MagickPass on success otherwise
+%  MagickFail if an error is encountered, e.g. if there was a user
+%  interrupt.  If MagickFail is returned, the calling code is expected
+%  to terminate whatever is being monitored as soon as possible.
+%
+%  Most callers of this function will use the QuantumTick() macro to
+%  decide when it should be called.  The QuantumTick() macro is designed
+%  to deliver no more than 100 events in a span (representing 1-100%)
+%  and to distribute events as evenly as possible over the span so that
+%  events are reported for every 1% of progress when possible.
 %
 %  The format of the MagickMonitorFormatted method is:
 %
@@ -140,10 +209,8 @@ MagickMonitorFormatted(const magick_int64_t quantum,
                        const char *format,...)
 {
   MagickPassFail
-    status;
-
+    status = MagickPass;
 
-  status=MagickPass;
   if (monitor_handler != (MonitorHandler) NULL)
     {
       va_list
@@ -155,7 +222,28 @@ MagickMonitorFormatted(const magick_int64_t quantum,
       va_start(operands,format);
       FormatStringList(text,format,operands);
       va_end(operands);
-      status=MagickMonitor(text,quantum,span,exception);
+      /*
+        Serialize calls to the handler so that it will
+        never be invoked by more than one thread at a time.
+
+        When OpenMP is used, many different threads may invoke the
+        handler, but the implementation of the handler might not be
+        prepared for that.
+
+        It is theoretically possible for events to be delivered out of
+        order if the handler takes so much time to complete that
+        another thread is already delivering an event.  If the OS does
+        not provide any lock ordering sematics (first come, first
+        served) then behavior is indeterminate.  FIXME: if the
+        progress monitor is called by a thread while the lock is still
+        held, maybe just cache the latest progress and deliver it once
+        the monitor hander returns so the most recent progress is
+        delivered. The current semaphore design does not provide "try
+        lock" behavior.
+      */
+      LockSemaphoreInfo(monitor_semaphore);
+      status=(*monitor_handler)(text,quantum,span,exception);
+      UnlockSemaphoreInfo(monitor_semaphore);
     }
   return status;
 }
index 5315428..0ba069d 100644 (file)
@@ -1,12 +1,12 @@
 /*
-  Copyright (C) 2003 - 2012 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Progress Monitor Methods.
 */
 #ifndef _MAGICK_MONITOR_H
@@ -32,7 +32,7 @@ extern "C" {
   extern MagickExport MagickPassFail
   MagickMonitor(const char *text,
                 const magick_int64_t quantum,const magick_uint64_t span,
-                ExceptionInfo *exception);
+                ExceptionInfo *exception) MAGICK_FUNC_DEPRECATED;
 
   extern MagickExport MagickPassFail
   MagickMonitorFormatted(const magick_int64_t quantum,
@@ -40,6 +40,16 @@ extern "C" {
                          ExceptionInfo *exception,
                          const char *format,...) MAGICK_ATTRIBUTE((__format__ (__printf__,4,5)));
 
+#if defined(MAGICK_IMPLEMENTATION)
+
+  extern void
+  DestroyMagickMonitor(void);
+
+  extern MagickPassFail
+    InitializeMagickMonitor(void);
+
+#endif /* defined(MAGICK_IMPLEMENTATION) */
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif
index 7807064..dc9baa9 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -141,8 +141,12 @@ MagickExport MontageInfo *CloneMontageInfo(const ImageInfo *image_info,
 */
 MagickExport void DestroyMontageInfo(MontageInfo *montage_info)
 {
-  assert(montage_info != (MontageInfo *) NULL);
+
+  if (montage_info == (MontageInfo *) NULL)
+    return;
+
   assert(montage_info->signature == MagickSignature);
+
   if (montage_info->geometry != (char *) NULL)
     MagickFreeMemory(montage_info->geometry);
   if (montage_info->tile != (char *) NULL)
@@ -155,6 +159,7 @@ MagickExport void DestroyMontageInfo(MontageInfo *montage_info)
     MagickFreeMemory(montage_info->texture);
   if (montage_info->font != (char *) NULL)
     MagickFreeMemory(montage_info->font);
+  montage_info->signature=0;
   MagickFreeMemory(montage_info);
 }
 \f
@@ -382,8 +387,8 @@ MagickExport Image *MontageImages(const Image *images,
         --i;
 
       for (tile=0; (long) tile <= i; tile++)
-       if (image_list[tile])
-         DestroyImage(image_list[tile]);
+        if (image_list[tile])
+          DestroyImage(image_list[tile]);
       MagickFreeMemory(master_list);
       return((Image *) NULL);
     }
index a9ebe7c..b333397 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   ImageMagick Image Montage Methods.
 */
 #ifndef _MAGICK_MONTAGE_H
index fe78297..4d19439 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -125,7 +125,7 @@ MagickExport int NTclosedir(DIR *entry)
 %  A description of each parameter follows:
 %
 %    o hinstDLL: handle to the DLL module
-%   
+%
 %    o fdwReason: reason for calling function.
 %
 %          May have values:
@@ -158,9 +158,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
         char
           dll_path[DLL_PATH_MAX],
           current_path[ENV_VAR_MAX];
-        
+
         long count;
-        
+
         count = GetModuleFileName(hinstDLL,dll_path,DLL_PATH_MAX);
         if (count) {
           for ( ; count>0 ; --count)
@@ -440,7 +440,7 @@ MagickUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *info)
     ULONG_PTR                ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
     } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
 
-    https://msdn.microsoft.com/en-us/library/windows/desktop/ms679284%28v=vs.85%29.aspx 
+    https://msdn.microsoft.com/en-us/library/windows/desktop/ms679284%28v=vs.85%29.aspx
     We don't care about PCONTEXT because it is processor-specific and includes low level
     details such as register contents.
 
@@ -1155,7 +1155,7 @@ char *NTGetLastError(void)
  */
 static int
 NTGetRegistryValue(HKEY hkeyroot, const char *key, const char *name,
-                  char *ptr, int *plen)
+                   char *ptr, int *plen)
 {
   HKEY
     hkey;
@@ -1177,22 +1177,22 @@ NTGetRegistryValue(HKEY hkeyroot, const char *key, const char *name,
       keytype = REG_SZ;
       cbData = *plen;
       if (bptr == (BYTE *) NULL)
-       bptr = &b;  /* Registry API won't return ERROR_MORE_DATA */
+        bptr = &b;  /* Registry API won't return ERROR_MORE_DATA */
       /* if ptr is NULL */
       rc = RegQueryValueExA(hkey, (char *)name, 0, &keytype, bptr, &cbData);
       RegCloseKey(hkey);
       if (rc == ERROR_SUCCESS)
-       {
-         *plen = cbData;
-         return 0;  /* found environment variable and copied it */
-       }
+        {
+          *plen = cbData;
+          return 0;  /* found environment variable and copied it */
+        }
       else
-       if (rc == ERROR_MORE_DATA)
-         {
-           /* buffer wasn't large enough */
-           *plen = cbData;
-           return -1;
-         }
+        if (rc == ERROR_MORE_DATA)
+          {
+            /* buffer wasn't large enough */
+            *plen = cbData;
+            return -1;
+          }
     }
   return 1;  /* not found */
 }
@@ -1203,8 +1203,8 @@ NTGetRegistryValue(HKEY hkeyroot, const char *key, const char *name,
 */
 static MagickPassFail
 NTGhostscriptFind(const char **gs_productfamily,
-                 int *gs_major_version,
-                 int *gs_minor_version)
+                  int *gs_major_version,
+                  int *gs_minor_version)
 {
   /*
     These are the Ghostscript product versions we will search for.
@@ -1214,7 +1214,7 @@ NTGhostscriptFind(const char **gs_productfamily,
       "GPL Ghostscript",
       "GNU Ghostscript",
       "AFPL Ghostscript",
-      "Aladdin Ghostscript" 
+      "Aladdin Ghostscript"
     };
 
   unsigned int
@@ -1227,7 +1227,7 @@ NTGhostscriptFind(const char **gs_productfamily,
   *gs_productfamily=NULL;
 
   (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                       "Searching for Ghostscript...");
+                        "Searching for Ghostscript...");
 
   /* Minimum version of Ghostscript is 5.50 */
   *gs_major_version=5;
@@ -1236,126 +1236,126 @@ NTGhostscriptFind(const char **gs_productfamily,
        ++product_index)
     {
       HKEY
-       hkey,
-       hkeyroot;
+        hkey,
+        hkeyroot;
 
       LONG
-       winstatus;
+        winstatus;
 
       REGSAM
-       open_key_mode;
+        open_key_mode;
 
       char
-       key[MaxTextExtent],
-       last_error_msg[MaxTextExtent];
+        key[MaxTextExtent],
+        last_error_msg[MaxTextExtent];
 
       (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                           "  Searching for %s...",
-                           products[product_index]);
+                            "  Searching for %s...",
+                            products[product_index]);
       FormatString(key,"SOFTWARE\\%s",products[product_index]);
       hkeyroot = HKEY_LOCAL_MACHINE;
       /*
-       long WINAPI RegOpenKeyEx(const HKEY hKey, const LPCTSTR
-       lpSubKey, const DWORD ulOptions, const REGSAM samDesired,
-       PHKEY phkResult)
+        long WINAPI RegOpenKeyEx(const HKEY hKey, const LPCTSTR
+        lpSubKey, const DWORD ulOptions, const REGSAM samDesired,
+        PHKEY phkResult)
       */
       open_key_mode=KEY_READ;
       if ((winstatus=RegOpenKeyExA(hkeyroot, key, 0, open_key_mode, &hkey))
-         == ERROR_SUCCESS)
-       {
-         DWORD
-           cbData;
-
-         int
-           n;
-
-         (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                               "    RegOpenKeyExA() opened "
-                               "\"HKEY_LOCAL_MACHINE\\%s\"",
-                               key);
-         /* Now enumerate the keys */
-         cbData = sizeof(key) / sizeof(char);
-         n=0;
-         /*
-           LONG WINAPI RegEnumKeyEx(HKEY hKey, DWORD dwIndex, LPTSTR
-           lpName, LPDWORD lpcName, LPDWORD lpReserved, LPTSTR
-           lpClass, LPDWORD lpcClass, PFILETIME lpftLastWriteTime)
-
-           Enumerates the subkeys of the specified open registry key. 
-
-           RegEnumKeyA is is provided only for compatibility with
-           16-bit versions of Windows.
-         */
-         while ((winstatus=RegEnumKeyA(hkey, n, key, cbData)) == ERROR_SUCCESS)
-           {
-             int
-               major_version,
-               minor_version;
-
-             (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                                   "      RegEnumKeyA enumerated \"%s\"",key);
-             n++;
-             major_version=0;
-             minor_version=0;
-             if (sscanf(key,"%d.%d",&major_version,&minor_version) != 2)
-               continue;
-
-             (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                                   "      Found Ghostscript (%s) version %d.%02d",
-                                   products[product_index],
-                                   major_version,
-                                   minor_version);
-
-             if ((major_version > *gs_major_version) ||
-                 ((major_version == *gs_major_version) &&
-                  (minor_version > *gs_minor_version)))
-               {
-                 *gs_productfamily=products[product_index];
-                 *gs_major_version=major_version;
-                 *gs_minor_version=minor_version;
-                 status=MagickPass;
-               }
-           }
-         if (winstatus != ERROR_NO_MORE_ITEMS)
-           {
-             (void) NTstrerror_r(winstatus,last_error_msg,sizeof(last_error_msg));
-             (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                                   "      RegEnumKeyA (%s)",
-                                   last_error_msg);
-           }
-         /*
-           LONG WINAPI RegCloseKey(HKEY hKey)
-           
-           Close the registry key.
-         */
-         winstatus=RegCloseKey(hkey);
-       }
+          == ERROR_SUCCESS)
+        {
+          DWORD
+            cbData;
+
+          int
+            n;
+
+          (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+                                "    RegOpenKeyExA() opened "
+                                "\"HKEY_LOCAL_MACHINE\\%s\"",
+                                key);
+          /* Now enumerate the keys */
+          cbData = sizeof(key) / sizeof(char);
+          n=0;
+          /*
+            LONG WINAPI RegEnumKeyEx(HKEY hKey, DWORD dwIndex, LPTSTR
+            lpName, LPDWORD lpcName, LPDWORD lpReserved, LPTSTR
+            lpClass, LPDWORD lpcClass, PFILETIME lpftLastWriteTime)
+
+            Enumerates the subkeys of the specified open registry key.
+
+            RegEnumKeyA is is provided only for compatibility with
+            16-bit versions of Windows.
+          */
+          while ((winstatus=RegEnumKeyA(hkey, n, key, cbData)) == ERROR_SUCCESS)
+            {
+              int
+                major_version,
+                minor_version;
+
+              (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+                                    "      RegEnumKeyA enumerated \"%s\"",key);
+              n++;
+              major_version=0;
+              minor_version=0;
+              if (sscanf(key,"%d.%d",&major_version,&minor_version) != 2)
+                continue;
+
+              (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+                                    "      Found Ghostscript (%s) version %d.%02d",
+                                    products[product_index],
+                                    major_version,
+                                    minor_version);
+
+              if ((major_version > *gs_major_version) ||
+                  ((major_version == *gs_major_version) &&
+                   (minor_version > *gs_minor_version)))
+                {
+                  *gs_productfamily=products[product_index];
+                  *gs_major_version=major_version;
+                  *gs_minor_version=minor_version;
+                  status=MagickPass;
+                }
+            }
+          if (winstatus != ERROR_NO_MORE_ITEMS)
+            {
+              (void) NTstrerror_r(winstatus,last_error_msg,sizeof(last_error_msg));
+              (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+                                    "      RegEnumKeyA (%s)",
+                                    last_error_msg);
+            }
+          /*
+            LONG WINAPI RegCloseKey(HKEY hKey)
+
+            Close the registry key.
+          */
+          winstatus=RegCloseKey(hkey);
+        }
       else
-       {
-         /*
-           If the function fails, the return value is a nonzero error
-           code defined in Winerror.h. You can use the FormatMessage
-           function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a
-           generic description of the error.
-          */
-         (void) NTstrerror_r(winstatus,last_error_msg,sizeof(last_error_msg));
-         (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                               "    RegOpenKeyExA() failed to open "
-                               "\"HKEY_LOCAL_MACHINE\\%s\" (%s)",
-                               key,last_error_msg);
-       }
+        {
+          /*
+            If the function fails, the return value is a nonzero error
+            code defined in Winerror.h. You can use the FormatMessage
+            function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a
+            generic description of the error.
+           */
+          (void) NTstrerror_r(winstatus,last_error_msg,sizeof(last_error_msg));
+          (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+                                "    RegOpenKeyExA() failed to open "
+                                "\"HKEY_LOCAL_MACHINE\\%s\" (%s)",
+                                key,last_error_msg);
+        }
     }
   if (status != MagickFail)
     {
       (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                           "Selected Ghostscript (%s) version %d.%02d",
-                           *gs_productfamily,*gs_major_version,
-                           *gs_minor_version);
+                            "Selected Ghostscript (%s) version %d.%02d",
+                            *gs_productfamily,*gs_major_version,
+                            *gs_minor_version);
     }
   else
     {
       (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                           "Failed to find Ghostscript!");
+                            "Failed to find Ghostscript!");
       *gs_major_version=0;
       *gs_minor_version=0;
     }
@@ -1393,7 +1393,7 @@ NTGhostscriptGetString(const char *name, char *ptr, const size_t len)
 
   int
     length;
-  
+
   char
     key[MaxTextExtent];
 
@@ -1401,30 +1401,30 @@ NTGhostscriptGetString(const char *name, char *ptr, const size_t len)
 
   if (NULL == gs_productfamily)
     (void) NTGhostscriptFind(&gs_productfamily,&gs_major_version,
-                            &gs_minor_version);
+                             &gs_minor_version);
 
   if (NULL == gs_productfamily)
     return MagickFail;
 
   FormatString(key,"SOFTWARE\\%s\\%d.%02d",gs_productfamily,
-              gs_major_version, gs_minor_version);
-  
+               gs_major_version, gs_minor_version);
+
   for (i=0; i < sizeof(hkeys)/sizeof(hkeys[0]); ++i)
     {
       length = (int) len;
       if (NTGetRegistryValue(hkeys[i].hkey, key, name, ptr, &length) == 0)
-       {
-         (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                               "Registry: \"%s\\%s\\%s\"=\"%s\"",
-                               hkeys[i].name,key,name,ptr);
-         return MagickPass;
-       }
+        {
+          (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+                                "Registry: \"%s\\%s\\%s\"=\"%s\"",
+                                hkeys[i].name,key,name,ptr);
+          return MagickPass;
+        }
       else
-       {
-         (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
-                               "Failed lookup: \"%s\\%s\\%s\"",
-                               hkeys[i].name,key,name);
-       }
+        {
+          (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+                                "Failed lookup: \"%s\\%s\\%s\"",
+                                hkeys[i].name,key,name);
+        }
     }
 
   return MagickFail;
@@ -1570,14 +1570,14 @@ MagickExport int NTGhostscriptEXE(char *path, int path_length)
       (void) strlcpy(cache,gsexe,sizeof(cache));
 
       if (NTGhostscriptDLL(cache,sizeof(cache)))
-       {
-         p = strrchr(cache, '\\');
-         if (p) {
-           p++;
-           *p = 0;
+        {
+          p = strrchr(cache, '\\');
+          if (p) {
+            p++;
+            *p = 0;
             (void) strlcat(cache,gsexe,sizeof(cache));
-         }
-       }
+          }
+        }
       result=cache;
     }
 
@@ -1643,20 +1643,20 @@ MagickExport int NTGhostscriptFonts(char *path, int path_length)
     const char
       *end = NULL,
       *start = gs_lib_path;
-        
+
     end=start+strlen(start);
     while ( start < end )
       {
         char
           font_dir[MaxTextExtent],
           font_dir_file[MaxTextExtent];
-            
+
         const char
           *separator;
-            
+
         int
           length;
-            
+
         separator = strchr(start,DirectoryListSeparator);
         if (separator)
           length=separator-start;
@@ -1883,7 +1883,7 @@ MagickExport unsigned char *NTRegistryKeyLookup(const char *subkey)
 
       LONG
         res;
-      
+
       FormatString(package_key,"SOFTWARE\\%s\\%s\\Q:%d", MagickPackageName,
                    MagickLibVersionText,QuantumDepth);
 
@@ -1903,29 +1903,32 @@ MagickExport unsigned char *NTRegistryKeyLookup(const char *subkey)
   {
     unsigned char
       *dest;
-    
+
     DWORD
       size,
       type;
 
     LONG
       res;
-    
+
     size = 32;
     dest = MagickAllocateMemory(unsigned char *,size);
-    
-    res = RegQueryValueExA (reg_key, subkey, 0, &type, dest, &size);
-    if (res == ERROR_MORE_DATA && type == REG_SZ)
+
+    if (dest != (unsigned char *) NULL)
       {
-        MagickReallocMemory(unsigned char *,dest,size);
         res = RegQueryValueExA (reg_key, subkey, 0, &type, dest, &size);
+        if (res == ERROR_MORE_DATA && type == REG_SZ)
+          {
+            MagickReallocMemory(unsigned char *,dest,size);
+            res = RegQueryValueExA (reg_key, subkey, 0, &type, dest, &size);
+          }
+
+        if (type != REG_SZ || res != ERROR_SUCCESS)
+          {
+            MagickFreeMemory(dest);
+          }
       }
-    
-    if (type != REG_SZ || res != ERROR_SUCCESS)
-      {
-        MagickFreeMemory(dest);
-      }
-    
+
     return dest;
   }
 }
@@ -2074,20 +2077,20 @@ NTstrerror_r(LONG errnum, char *strerrbuf, size_t  buflen)
   if (buflen > 0)
     strerrbuf[0]='\0';
   if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
-                   FORMAT_MESSAGE_FROM_SYSTEM,NULL,errnum,
-                   MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
-                   (LPTSTR) &buffer,0,NULL))
+                    FORMAT_MESSAGE_FROM_SYSTEM,NULL,errnum,
+                    MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
+                    (LPTSTR) &buffer,0,NULL))
     {
       if (strlcpy(strerrbuf,buffer,buflen) < buflen)
-       {
-         size_t
-           index;
-
-         for (index=0; strerrbuf[index] != 0; index++)
-           if (strerrbuf[index] == '\015')
-             strerrbuf[index]='\0';
-         status=MagickPass;
-       }
+        {
+          size_t
+            index;
+
+          for (index=0; strerrbuf[index] != 0; index++)
+            if (strerrbuf[index] == '\015')
+              strerrbuf[index]='\0';
+          status=MagickPass;
+        }
       LocalFree(buffer);
     }
   return status;
@@ -2355,11 +2358,11 @@ MagickExport int NTftruncate(int filedes, off_t length)
     The CreateFileMapping() function may also be used to extend a
     file's length. The filler byte values are not defined in the
     documentation.
-  */ 
+  */
   status=chsize(filedes,length);
 
   /*
-    It is not documented if _chsize preserves the seek 
+    It is not documented if _chsize preserves the seek
     position, so restore the seek position like ftruncate
     does
   */
index 077db06..53d4b20 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 - 2016 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Windows NT Utility Methods for GraphicsMagick.
 */
 #ifndef _MAGICK_NTBASE_H
@@ -121,7 +121,7 @@ extern "C" {
 #endif
 
 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
-#define vsnprintf _vsnprintf 
+#define vsnprintf _vsnprintf
 #endif
 
 #if defined(_MT) && defined(MSWINDOWS)
@@ -245,6 +245,27 @@ extern "C" {
 #endif
 
 /*
+  The isnan() function was implemented starting in Visual Studio 2003
+  The function prototype for isnan() and _isnanf() comes from <math.h>
+  and the prototype for _isnan() comes from <float.h>.  The _isnanf()
+  function is only available in _WIN64 builds.
+
+  Some useful documentation was found at
+  https://msdn.microsoft.com/en-us/library/tzthab44.aspx.
+*/
+#if (defined(_MSC_VER) && _MSC_VER < 1700 && !defined(isnan))
+#  if defined(_WIN64)
+#    define isnan(f) _isnanf(f)
+#  else
+#    include <float.h> /* Needed for _isnan */
+#    if !defined(isnan)
+#      define isnan(f) _isnan(f)
+#    endif
+#  endif
+#endif
+
+
+/*
   Typedef declarations.
 */
 typedef UINT (CALLBACK *LPFNDLLFUNC1)(DWORD,UINT);
@@ -430,7 +451,7 @@ extern MagickExport const char
 #define lt_dlsetsearchpath(path) NTdlsetsearchpath(path)
 #define lt_dlsym(handle,name) NTdlsym(handle,name)
 #endif /* !defined(HasLTDL) */
-  
+
 extern MagickExport unsigned char
   *NTResourceToBlob(const char *);
 
index 30d698e..2fda4a0 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -154,7 +154,7 @@ MagickExport void *CropImageToHBITMAP(Image *image,
   bitmap_bitsH = (HANDLE) GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE,
                page.width*page.height*bitmap.bmBitsPixel);
   if (bitmap_bitsH == NULL)
-    return( NULL ); 
+    return( NULL );
 
   bitmap_bits = (RGBQUAD *) GlobalLock((HGLOBAL) bitmap_bitsH);
 
@@ -199,7 +199,7 @@ MagickExport void *CropImageToHBITMAP(Image *image,
 #endif
     if (QuantumTick(y,page.height))
       if (!MagickMonitorFormatted(y,page.height-1,exception,CropImageText,
-                                 image->filename))
+                                  image->filename))
         break;
   }
   if (y < (long) page.height)
@@ -557,29 +557,33 @@ MagickExport TypeInfo* NTGetTypeList( void )
     int
       array_index = 0;
 
-    type_array = MagickAllocateMemory(TypeInfo**,sizeof(TypeInfo*)*list_entries);
+    type_array = MagickAllocateMemory(TypeInfo**,MagickArraySize(sizeof(TypeInfo*),
+                                                                 list_entries));
 
-    while (type_list->previous != (TypeInfo *) NULL)
-      type_list=type_list->previous;
-
-    for (array_index=0; array_index< list_entries; array_index++)
+    if (type_array != (TypeInfo**) NULL)
       {
-        type_array[array_index] = type_list;
-        type_list=type_list->next;
-      }
+        while (type_list->previous != (TypeInfo *) NULL)
+          type_list=type_list->previous;
 
-    qsort((void *) type_array, list_entries, sizeof(TypeInfo *),TypeInfoCompare);
+        for (array_index=0; array_index< list_entries; array_index++)
+          {
+            type_array[array_index] = type_list;
+            type_list=type_list->next;
+          }
 
-    type_list=type_array[0];
-    type_list->previous=(TypeInfo *) NULL;
-    for(array_index=1; array_index < list_entries; array_index++)
-      {
-        type_array[array_index-1]->next = type_array[array_index];
-        type_array[array_index]->previous = type_array[array_index-1];
-        type_array[array_index]->next=(TypeInfo *) NULL;
-      }
+        qsort((void *) type_array, list_entries, sizeof(TypeInfo *),TypeInfoCompare);
+
+        type_list=type_array[0];
+        type_list->previous=(TypeInfo *) NULL;
+        for(array_index=1; array_index < list_entries; array_index++)
+          {
+            type_array[array_index-1]->next = type_array[array_index];
+            type_array[array_index]->previous = type_array[array_index-1];
+            type_array[array_index]->next=(TypeInfo *) NULL;
+          }
 
-    MagickFreeMemory(type_array);
+        MagickFreeMemory(type_array);
+      }
   }
 
   return (TypeInfo *) type_list;
@@ -610,7 +614,7 @@ MagickExport TypeInfo* NTGetTypeList( void )
 */
 MagickExport void *ImageToHBITMAP(Image* image)
 {
-  unsigned long 
+  unsigned long
     nPixels,
     row;
 
@@ -647,8 +651,8 @@ MagickExport void *ImageToHBITMAP(Image* image)
   bitmap_bitsH = (HANDLE) GlobalAlloc (GMEM_MOVEABLE | GMEM_DDESHARE, memSize);
 
   if (bitmap_bitsH == NULL)
-    return( NULL ); 
-  
+    return( NULL );
+
   bitmap_bits = (RGBQUAD *) GlobalLock((HGLOBAL) bitmap_bitsH);
   pDestPixel = bitmap_bits;
 
index 9a8a758..9c246da 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Windows NT Utility Methods for ImageMagick.
 */
 #ifndef _MAGICK_NTFEATURE_H
index d033d60..79b812d 100644 (file)
@@ -51,7 +51,7 @@ DestroyThreadViewDataSet(ThreadViewDataSet *data_set)
 {
   unsigned int
     i;
-  
+
   if (data_set != (ThreadViewDataSet *) NULL)
     {
       if (data_set->view_data != (void *) NULL)
@@ -81,10 +81,10 @@ AllocateThreadViewDataSet(const MagickFreeFunc destructor,
 {
   ThreadViewDataSet
     *data_set;
-  
+
   MagickPassFail
     status=MagickPass;
-  
+
   data_set=MagickAllocateMemory(ThreadViewDataSet *,sizeof(ThreadViewDataSet));
   if (data_set == (ThreadViewDataSet *) NULL)
     MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
@@ -101,7 +101,7 @@ AllocateThreadViewDataSet(const MagickFreeFunc destructor,
 
   if (data_set->view_data != (void *) NULL)
     (void) memset(data_set->view_data,0,data_set->nviews*sizeof(void *));
-  
+
   if (status == MagickFail)
     {
       DestroyThreadViewDataSet(data_set);
@@ -126,10 +126,10 @@ AllocateThreadViewDataArray(const Image *image,
   */
   ThreadViewDataSet
     *data_set;
-  
+
   MagickPassFail
     alloc_status=MagickFail;
-          
+
   data_set=AllocateThreadViewDataSet(MagickFree,image,exception);
   if (data_set != (ThreadViewDataSet *) NULL)
     {
@@ -138,15 +138,15 @@ AllocateThreadViewDataArray(const Image *image,
 
       unsigned int
         i;
-              
+
       alloc_status=MagickPass;
       allocated_views=GetThreadViewDataSetAllocatedViews(data_set);
-              
+
       for (i=0; i < allocated_views; i++)
         {
           unsigned char
             *data;
-                  
+
           data=MagickAllocateArray(unsigned char *,count,size);
           if (data == (unsigned char *) NULL)
             {
index 9c78ffb..8ede301 100644 (file)
@@ -1,10 +1,10 @@
 /*
-  Copyright (C) 2008 GraphicsMagick Group
+  Copyright (C) 2008-2018 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick OpenMP Thread-Specific Data Methods.
 */
 #ifndef _MAGICK_OMP_DATA_VIEW
@@ -29,14 +29,14 @@ extern "C" {
 
     MagickFreeFunc
     destructor;
-    
+
     unsigned int
     nviews;
   } ThreadViewDataSet;
 
   extern MagickExport void
   DestroyThreadViewDataSet(ThreadViewDataSet *data_set);
-  
+
   extern MagickExport ThreadViewDataSet
   *AllocateThreadViewDataSet(const MagickFreeFunc destructor,
                              const Image *image,
@@ -48,14 +48,14 @@ extern "C" {
                               size_t count,size_t size);
 
   extern MagickExport unsigned int
-  GetThreadViewDataSetAllocatedViews(ThreadViewDataSet *data_set);
+  GetThreadViewDataSetAllocatedViews(ThreadViewDataSet *data_set) MAGICK_FUNC_PURE;
 
   extern MagickExport void
   *AccessThreadViewData(ThreadViewDataSet *data_set);
 
   extern MagickExport void
   *AccessThreadViewDataById(ThreadViewDataSet *data_set,
-                            unsigned int index);
+                            unsigned int index) MAGICK_FUNC_PURE;
 
   extern MagickExport void
   AssignThreadViewData(ThreadViewDataSet *data_set, unsigned int index,
index 7cec131..eabb8e4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2004 - 2014 GraphicsMagick Group
+% Copyright (C) 2004 - 2018 GraphicsMagick Group
 %
 % This program is covered by multiple licenses, which are described in
 % Copyright.txt. You should have received a copy of Copyright.txt with this
@@ -175,7 +175,7 @@ QuantumOperatorImageMultivalue(Image *image,
                &options.values.green,
                &options.values.blue,
                &options.values.opacity);
-  
+
   if ((count > 3) && (options.values.opacity >= 0.0))
     options.opacity_enabled = MagickTrue;
   if ((count > 2) && (options.values.blue >= 0.0))
@@ -327,9 +327,9 @@ QuantumOperatorImageMultivalue(Image *image,
 static MagickPassFail
 QuantumAddCB(void *mutable_data,
              const void *immutable_data,
-             Image *image,
-             PixelPacket *pixels,
-             IndexPacket *indexes,
+             Image * restrict image,
+             PixelPacket * restrict pixels,
+             IndexPacket * restrict indexes,
              const long npixels,
              ExceptionInfo *exception)
 {
@@ -381,7 +381,7 @@ QuantumAddCB(void *mutable_data,
         {
           Quantum
             intensity;
-          
+
           intensity = PixelIntensity(&pixels[i]);
           ApplyArithmeticOperator(intensity,+,context->double_value);
           pixels[i].red = pixels[i].green = pixels[i].blue = intensity;
@@ -394,9 +394,9 @@ QuantumAddCB(void *mutable_data,
 static MagickPassFail
 QuantumAndCB(void *mutable_data,
              const void *immutable_data,
-             Image *image,
-             PixelPacket *pixels,
-             IndexPacket *indexes,
+             Image * restrict image,
+             PixelPacket * restrict pixels,
+             IndexPacket * restrict indexes,
              const long npixels,
              ExceptionInfo *exception)
 {
@@ -461,9 +461,9 @@ QuantumAndCB(void *mutable_data,
 static MagickPassFail
 QuantumAssignCB(void *mutable_data,
                 const void *immutable_data,
-                Image *image,
-                PixelPacket *pixels,
-                IndexPacket *indexes,
+                Image * restrict image,
+                PixelPacket * restrict pixels,
+                IndexPacket * restrict indexes,
                 const long npixels,
                 ExceptionInfo *exception)
 {
@@ -534,9 +534,9 @@ QuantumAssignCB(void *mutable_data,
 static MagickPassFail
 QuantumDepthCB(void *mutable_data,
                const void *immutable_data,
-               Image *image,
-               PixelPacket *pixels,
-               IndexPacket *indexes,
+               Image * restrict image,
+               PixelPacket * restrict pixels,
+               IndexPacket * restrict indexes,
                const long npixels,
                ExceptionInfo *exception)
 {
@@ -583,7 +583,7 @@ QuantumDepthCB(void *mutable_data,
           mutable_context->channel_lut=MagickAllocateArray(Quantum *, MaxMap+1,sizeof(Quantum));
           if (mutable_context->channel_lut == (Quantum *) NULL)
             status=MagickFail;
-          
+
           if (mutable_context->channel_lut != (Quantum *) NULL)
             {
               for (i=0; i <= (long) MaxMap; i++)
@@ -643,7 +643,7 @@ QuantumDepthCB(void *mutable_data,
             {
               Quantum
                 intensity;
-                
+
               intensity = PixelIntensity(&pixels[i]);
               intensity=CrushChannelDepth(intensity);
               pixels[i].red = pixels[i].green = pixels[i].blue = intensity;
@@ -651,29 +651,29 @@ QuantumDepthCB(void *mutable_data,
           break;
         }
     }
-  
+
   return MagickPass;
 }
 static MagickPassFail
 QuantumDivideCB(void *mutable_data,
                 const void *immutable_data,
-                Image *image,
-                PixelPacket *pixels,
-                IndexPacket *indexes,
+                Image * restrict image,
+                PixelPacket * restrict pixels,
+                IndexPacket * restrict indexes,
                 const long npixels,
                 ExceptionInfo *exception)
 {
   const QuantumImmutableContext
     *context=(const QuantumImmutableContext *) immutable_data;
-  
+
   register long
     i;
-  
+
   ARG_NOT_USED(mutable_data);
   ARG_NOT_USED(image);
   ARG_NOT_USED(indexes);
   ARG_NOT_USED(exception);
-  
+
   switch (context->channel)
     {
     case RedChannel:
@@ -729,9 +729,9 @@ QuantumDivideCB(void *mutable_data,
 static MagickPassFail
 QuantumGammaCB(void *mutable_data,
                const void *immutable_data,
-               Image *image,
-               PixelPacket *pixels,
-               IndexPacket *indexes,
+               Image * restrict image,
+               PixelPacket * restrict pixels,
+               IndexPacket * restrict indexes,
                const long npixels,
                ExceptionInfo *exception)
 {
@@ -740,13 +740,13 @@ QuantumGammaCB(void *mutable_data,
 
   const QuantumImmutableContext
     *immutable_context=(const QuantumImmutableContext *) immutable_data;
-  
+
   register long
     i;
 
   MagickPassFail
     status=MagickPass;
-  
+
   ARG_NOT_USED(image);
   ARG_NOT_USED(indexes);
   ARG_NOT_USED(exception);
@@ -763,7 +763,7 @@ QuantumGammaCB(void *mutable_data,
       mutable_context->channel_lut=MagickAllocateArray(Quantum *, MaxMap+1,sizeof(Quantum));
       if (mutable_context->channel_lut == (Quantum *) NULL)
         status=MagickFail;
-      
+
       if (mutable_context->channel_lut != (Quantum *) NULL)
         {
           for (i=0; i <= (long) MaxMap; i++)
@@ -828,9 +828,9 @@ QuantumGammaCB(void *mutable_data,
 static MagickPassFail
 QuantumNegateCB(void *mutable_data,
                 const void *immutable_data,
-                Image *image,
-                PixelPacket *pixels,
-                IndexPacket *indexes,
+                Image * restrict image,
+                PixelPacket * restrict pixels,
+                IndexPacket * restrict indexes,
                 const long npixels,
                 ExceptionInfo *exception)
 {
@@ -844,7 +844,7 @@ QuantumNegateCB(void *mutable_data,
   ARG_NOT_USED(image);
   ARG_NOT_USED(indexes);
   ARG_NOT_USED(exception);
-  
+
   switch (context->channel)
     {
     case RedChannel:
@@ -903,9 +903,9 @@ QuantumNegateCB(void *mutable_data,
 static MagickPassFail
 QuantumLogCB(void *mutable_data,
              const void *immutable_data,
-             Image *image,
-             PixelPacket *pixels,
-             IndexPacket *indexes,
+             Image * restrict image,
+             PixelPacket * restrict pixels,
+             IndexPacket * restrict indexes,
              const long npixels,
              ExceptionInfo *exception)
 {
@@ -914,13 +914,13 @@ QuantumLogCB(void *mutable_data,
 
   const QuantumImmutableContext
     *immutable_context=(const QuantumImmutableContext *) immutable_data;
-  
+
   register long
     i;
 
   MagickPassFail
     status=MagickPass;
-  
+
   ARG_NOT_USED(image);
   ARG_NOT_USED(indexes);
   ARG_NOT_USED(exception);
@@ -937,7 +937,7 @@ QuantumLogCB(void *mutable_data,
       mutable_context->channel_lut=MagickAllocateArray(Quantum *, MaxMap+1,sizeof(Quantum));
       if (mutable_context->channel_lut == (Quantum *) NULL)
         status=MagickFail;
-      
+
       if (mutable_context->channel_lut != (Quantum *) NULL)
         {
           for (i=0; i <= (long) MaxMap; i++)
@@ -1008,9 +1008,9 @@ QuantumLogCB(void *mutable_data,
 static MagickPassFail
 QuantumLShiftCB(void *mutable_data,
                 const void *immutable_data,
-                Image *image,
-                PixelPacket *pixels,
-                IndexPacket *indexes,
+                Image * restrict image,
+                PixelPacket * restrict pixels,
+                IndexPacket * restrict indexes,
                 const long npixels,
                 ExceptionInfo *exception)
 {
@@ -1075,9 +1075,9 @@ QuantumLShiftCB(void *mutable_data,
 static MagickPassFail
 QuantumMaxCB(void *mutable_data,
              const void *immutable_data,
-             Image *image,
-             PixelPacket *pixels,
-             IndexPacket *indexes,
+             Image * restrict image,
+             PixelPacket * restrict pixels,
+             IndexPacket * restrict indexes,
              const long npixels,
              ExceptionInfo *exception)
 {
@@ -1150,9 +1150,9 @@ QuantumMaxCB(void *mutable_data,
 static MagickPassFail
 QuantumMinCB(void *mutable_data,
              const void *immutable_data,
-             Image *image,
-             PixelPacket *pixels,
-             IndexPacket *indexes,
+             Image * restrict image,
+             PixelPacket * restrict pixels,
+             IndexPacket * restrict indexes,
              const long npixels,
              ExceptionInfo *exception)
 {
@@ -1225,9 +1225,9 @@ QuantumMinCB(void *mutable_data,
 static MagickPassFail
 QuantumMultiplyCB(void *mutable_data,
                   const void *immutable_data,
-                  Image *image,
-                  PixelPacket *pixels,
-                  IndexPacket *indexes,
+                  Image * restrict image,
+                  PixelPacket * restrict pixels,
+                  IndexPacket * restrict indexes,
                   const long npixels,
                   ExceptionInfo *exception)
 {
@@ -1305,9 +1305,9 @@ GenerateQuantumNoise(const Quantum quantum,const NoiseType noise_type,
 static MagickPassFail
 QuantumNoiseCB(void *mutable_data,
                const void *immutable_data,
-               Image *image,
-               PixelPacket *pixels,
-               IndexPacket *indexes,
+               Image * restrict image,
+               PixelPacket * restrict pixels,
+               IndexPacket * restrict indexes,
                const long npixels,
                ExceptionInfo *exception,
                const NoiseType noise_type
@@ -1383,9 +1383,9 @@ QuantumNoiseCB(void *mutable_data,
 static MagickPassFail
 QuantumNoiseGaussianCB(void *mutable_data,
                        const void *immutable_data,
-                       Image *image,
-                       PixelPacket *pixels,
-                       IndexPacket *indexes,
+                       Image * restrict image,
+                       PixelPacket * restrict pixels,
+                       IndexPacket * restrict indexes,
                        const long npixels,
                        ExceptionInfo *exception)
 {
@@ -1395,9 +1395,9 @@ QuantumNoiseGaussianCB(void *mutable_data,
 static MagickPassFail
 QuantumNoiseImpulseCB(void *mutable_data,
                       const void *immutable_data,
-                      Image *image,
-                      PixelPacket *pixels,
-                      IndexPacket *indexes,
+                      Image * restrict image,
+                      PixelPacket * restrict pixels,
+                      IndexPacket * restrict indexes,
                       const long npixels,
                       ExceptionInfo *exception)
 {
@@ -1407,9 +1407,9 @@ QuantumNoiseImpulseCB(void *mutable_data,
 static MagickPassFail
 QuantumNoiseLaplacianCB(void *mutable_data,
                         const void *immutable_data,
-                        Image *image,
-                        PixelPacket *pixels,
-                        IndexPacket *indexes,
+                        Image * restrict image,
+                        PixelPacket * restrict pixels,
+                        IndexPacket * restrict indexes,
                         const long npixels,
                         ExceptionInfo *exception)
 {
@@ -1419,9 +1419,9 @@ QuantumNoiseLaplacianCB(void *mutable_data,
 static MagickPassFail
 QuantumNoiseMultiplicativeCB(void *mutable_data,
                              const void *immutable_data,
-                             Image *image,
-                             PixelPacket *pixels,
-                             IndexPacket *indexes,
+                             Image * restrict image,
+                             PixelPacket * restrict pixels,
+                             IndexPacket * restrict indexes,
                              const long npixels,
                              ExceptionInfo *exception)
 {
@@ -1432,9 +1432,9 @@ QuantumNoiseMultiplicativeCB(void *mutable_data,
 static MagickPassFail
 QuantumNoisePoissonCB(void *mutable_data,
                       const void *immutable_data,
-                      Image *image,
-                      PixelPacket *pixels,
-                      IndexPacket *indexes,
+                      Image * restrict image,
+                      PixelPacket * restrict pixels,
+                      IndexPacket * restrict indexes,
                       const long npixels,
                       ExceptionInfo *exception)
 {
@@ -1445,10 +1445,10 @@ QuantumNoisePoissonCB(void *mutable_data,
 
 static MagickPassFail
 QuantumNoiseRandomCB(void *mutable_data,
-                    const void *immutable_data,
-                      Image *image,
-                      PixelPacket *pixels,
-                      IndexPacket *indexes,
+                     const void *immutable_data,
+                      Image * restrict image,
+                      PixelPacket * restrict pixels,
+                      IndexPacket * restrict indexes,
                       const long npixels,
                       ExceptionInfo *exception)
 {
@@ -1459,9 +1459,9 @@ QuantumNoiseRandomCB(void *mutable_data,
 static MagickPassFail
 QuantumNoiseUniformCB(void *mutable_data,
                       const void *immutable_data,
-                      Image *image,
-                      PixelPacket *pixels,
-                      IndexPacket *indexes,
+                      Image * restrict image,
+                      PixelPacket * restrict pixels,
+                      IndexPacket * restrict indexes,
                       const long npixels,
                       ExceptionInfo *exception)
 {
@@ -1471,9 +1471,9 @@ QuantumNoiseUniformCB(void *mutable_data,
 static MagickPassFail
 QuantumOrCB(void *mutable_data,
             const void *immutable_data,
-            Image *image,
-            PixelPacket *pixels,
-            IndexPacket *indexes,
+            Image * restrict image,
+            PixelPacket * restrict pixels,
+            IndexPacket * restrict indexes,
             const long npixels,
             ExceptionInfo *exception)
 {
@@ -1543,9 +1543,9 @@ QuantumOrCB(void *mutable_data,
 static MagickPassFail
 QuantumPowCB(void *mutable_data,
              const void *immutable_data,
-             Image *image,
-             PixelPacket *pixels,
-             IndexPacket *indexes,
+             Image * restrict image,
+             PixelPacket * restrict pixels,
+             IndexPacket * restrict indexes,
              const long npixels,
              ExceptionInfo *exception)
 {
@@ -1554,13 +1554,13 @@ QuantumPowCB(void *mutable_data,
 
   const QuantumImmutableContext
     *immutable_context=(const QuantumImmutableContext *) immutable_data;
-  
+
   register long
     i;
 
   MagickPassFail
     status=MagickPass;
-  
+
   ARG_NOT_USED(image);
   ARG_NOT_USED(indexes);
   ARG_NOT_USED(exception);
@@ -1577,7 +1577,7 @@ QuantumPowCB(void *mutable_data,
       mutable_context->channel_lut=MagickAllocateArray(Quantum *, MaxMap+1,sizeof(Quantum));
       if (mutable_context->channel_lut == (Quantum *) NULL)
         status=MagickFail;
-      
+
       if (mutable_context->channel_lut != (Quantum *) NULL)
         {
           for (i=0; i <= (long) MaxMap; i++)
@@ -1642,9 +1642,9 @@ QuantumPowCB(void *mutable_data,
 static MagickPassFail
 QuantumRShiftCB(void *mutable_data,
                 const void *immutable_data,
-                Image *image,
-                PixelPacket *pixels,
-                IndexPacket *indexes,
+                Image * restrict image,
+                PixelPacket * restrict pixels,
+                IndexPacket * restrict indexes,
                 const long npixels,
                 ExceptionInfo *exception)
 {
@@ -1709,9 +1709,9 @@ QuantumRShiftCB(void *mutable_data,
 static MagickPassFail
 QuantumSubtractCB(void *mutable_data,
                   const void *immutable_data,
-                  Image *image,
-                  PixelPacket *pixels,
-                  IndexPacket *indexes,
+                  Image * restrict image,
+                  PixelPacket * restrict pixels,
+                  IndexPacket * restrict indexes,
                   const long npixels,
                   ExceptionInfo *exception)
 {
@@ -1790,9 +1790,9 @@ static inline Quantum ApplyThresholdOperator(const Quantum quantum,
 static MagickPassFail
 QuantumThresholdCB(void *mutable_data,
                    const void *immutable_data,
-                   Image *image,
-                   PixelPacket *pixels,
-                   IndexPacket *indexes,
+                   Image * restrict image,
+                   PixelPacket * restrict pixels,
+                   IndexPacket * restrict indexes,
                    const long npixels,
                    ExceptionInfo *exception)
 {
@@ -1839,7 +1839,7 @@ QuantumThresholdCB(void *mutable_data,
             intensity;
 
           intensity = PixelIntensity(&pixels[i]);
-          pixels[i].red = pixels[i].green = pixels[i].blue = 
+          pixels[i].red = pixels[i].green = pixels[i].blue =
             ApplyThresholdOperator(intensity,context->quantum_value);
         }
       break;
@@ -1863,9 +1863,9 @@ static inline Quantum ApplyThresholdBlackOperator(const Quantum quantum,
 static MagickPassFail
 QuantumThresholdBlackCB(void *mutable_data,
                         const void *immutable_data,
-                        Image *image,
-                        PixelPacket *pixels,
-                        IndexPacket *indexes,
+                        Image * restrict image,
+                        PixelPacket * restrict pixels,
+                        IndexPacket * restrict indexes,
                         const long npixels,
                         ExceptionInfo *exception)
 {
@@ -1955,9 +1955,9 @@ static inline Quantum ApplyThresholdWhiteOperator(const Quantum quantum,
 static MagickPassFail
 QuantumThresholdWhiteCB(void *mutable_data,
                         const void *immutable_data,
-                        Image *image,
-                        PixelPacket *pixels,
-                        IndexPacket *indexes,
+                        Image * restrict image,
+                        PixelPacket * restrict pixels,
+                        IndexPacket * restrict indexes,
                         const long npixels,
                         ExceptionInfo *exception)
 {
@@ -2048,9 +2048,9 @@ static inline Quantum ApplyThresholdBlackNegateOperator(const Quantum intensity,
 static MagickPassFail
 QuantumThresholdBlackNegateCB(void *mutable_data,
                               const void *immutable_data,
-                              Image *image,
-                              PixelPacket *pixels,
-                              IndexPacket *indexes,
+                              Image * restrict image,
+                              PixelPacket * restrict pixels,
+                              IndexPacket * restrict indexes,
                               const long npixels,
                               ExceptionInfo *exception)
 {
@@ -2142,9 +2142,9 @@ static inline Quantum ApplyThresholdWhiteNegateOperator(const Quantum intensity,
 static MagickPassFail
 QuantumThresholdWhiteNegateCB(void *mutable_data,
                               const void *immutable_data,
-                              Image *image,
-                              PixelPacket *pixels,
-                              IndexPacket *indexes,
+                              Image * restrict image,
+                              PixelPacket * restrict pixels,
+                              IndexPacket * restrict indexes,
                               const long npixels,
                               ExceptionInfo *exception)
 {
@@ -2222,9 +2222,9 @@ QuantumThresholdWhiteNegateCB(void *mutable_data,
 static MagickPassFail
 QuantumXorCB(void *mutable_data,
              const void *immutable_data,
-             Image *image,
-             PixelPacket *pixels,
-             IndexPacket *indexes,
+             Image * restrict image,
+             PixelPacket * restrict pixels,
+             IndexPacket * restrict indexes,
              const long npixels,
              ExceptionInfo *exception)
 {
index 8f37362..ea4c8b3 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -614,9 +614,9 @@ typedef struct _OpaqueImageOptions_t
 static MagickPassFail
 OpaqueImageCallBack(void *mutable_data,         /* User provided mutable data */
                       const void *immutable_data, /* User provided immutable data */
-                      Image *image,               /* Modify image */
-                      PixelPacket *pixels,        /* Pixel row */
-                      IndexPacket *indexes,       /* Pixel row indexes */
+                      Image * restrict image,               /* Modify image */
+                      PixelPacket * restrict pixels,        /* Pixel row */
+                      IndexPacket * restrict indexes,       /* Pixel row indexes */
                       const long npixels,         /* Number of pixels in row */
                       ExceptionInfo *exception)   /* Exception report */
 {
@@ -731,9 +731,9 @@ typedef struct _TransparentImageOptions_t
 static MagickPassFail
 TransparentImageCallBack(void *mutable_data,         /* User provided mutable data */
                          const void *immutable_data, /* User provided immutable data */
-                         Image *image,               /* Modify image */
-                         PixelPacket *pixels,        /* Pixel row */
-                         IndexPacket *indexes,       /* Pixel row indexes */
+                         Image * restrict image,               /* Modify image */
+                         PixelPacket * restrict pixels,        /* Pixel row */
+                         IndexPacket * restrict indexes,       /* Pixel row indexes */
                          const long npixels,         /* Number of pixels in row */
                          ExceptionInfo *exception)   /* Exception report */
 {
index 0e83104..a683b07 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   ImageMagick Image Paint Methods.
 */
 #ifndef _MAGICK_PAINT_H
index 3e753fd..ac9123f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -34,6 +34,7 @@
 #include "magick/studio.h"
 #include "magick/blob.h"
 #include "magick/constitute.h"
+#include "magick/enum_strings.h"
 #include "magick/list.h"
 #include "magick/log.h"
 #include "magick/magick.h"
@@ -57,7 +58,7 @@
 #elif defined (MSWINDOWS)
 #  define S_MODE     (_S_IREAD | _S_IWRITE)
 #else
-# define S_MODE      0644 
+# define S_MODE      0644
 #endif
 
 /*
@@ -99,9 +100,9 @@ extern "C" {
   */
   MagickExport const PixelPacket
   *AcquireImagePixelsDirect(const Image *image,
-                           const pixel_off_t offset,
-                           const unsigned long length,
-                           ExceptionInfo *exception);
+                            const pixel_off_t offset,
+                            const unsigned long length,
+                            ExceptionInfo *exception);
 
   /*
     Read/write access to a linear pixel region (existing data read and
@@ -109,18 +110,18 @@ extern "C" {
   */
   extern MagickExport PixelPacket
   *GetImagePixelsDirect(Image *image,
-                       const pixel_off_t offset,
-                       const unsigned long length,
-                       ExceptionInfo *exception);
+                        const pixel_off_t offset,
+                        const unsigned long length,
+                        ExceptionInfo *exception);
 
   /*
     Write access to a linear pixel region (existing data ignored).
   */
   extern MagickExport PixelPacket
   *SetImagePixelsDirect(Image *image,
-                       const pixel_off_t offset,
-                       const unsigned long length,
-                       ExceptionInfo *exception);
+                        const pixel_off_t offset,
+                        const unsigned long length,
+                        ExceptionInfo *exception);
 
 
 /*
@@ -148,7 +149,7 @@ typedef struct _CacheInfo
 
   /* Offset to pixels in cache file */
   magick_off_t offset;
-  
+
   /* Length of pixels region */
   magick_off_t length;
 
@@ -205,7 +206,7 @@ typedef struct _CacheInfo
 typedef struct _NexusInfo
 {
   /* Points to staging or cache_info->pixels+offset */
-  PixelPacket *pixels; 
+  PixelPacket *pixels;
 
   /* Points into staging or cache_info->indexes+offset */
   IndexPacket *indexes;
@@ -219,7 +220,7 @@ typedef struct _NexusInfo
   /* Selected region (width, height, x, y) */
   RectangleInfo region;
 
-  /* Nexus pixels are non-strided and in core */
+  /* Nexus pixels are non-strided and in core (sync not needed) */
   MagickBool in_core;
 
 #if 0
@@ -259,10 +260,10 @@ typedef struct _View
   A vector of thread views.
 */
 typedef struct _ThreadViewSet
-{ 
+{
   ViewInfo
   *views;
-  
+
   unsigned int
   nviews;
 } ThreadViewSet;
@@ -337,14 +338,14 @@ FilePositionRead(int file, void *buffer, size_t length,magick_off_t offset)
   for (total_count=0; total_count < length; total_count+=count)
     {
       char
-       *io_buff_address;
+        *io_buff_address;
 
       size_t
-       requested_io_size;
+        requested_io_size;
 
 #if HAVE_PREAD
       off_t
-       io_file_offset;
+        io_file_offset;
 #endif
 
       requested_io_size=length-total_count;
@@ -393,14 +394,14 @@ FilePositionWrite(int file, const void *buffer,size_t length,magick_off_t offset
   for (total_count=0; total_count < length; total_count+=count)
     {
       char
-       *io_buff_address;
+        *io_buff_address;
 
       size_t
-       requested_io_size;
+        requested_io_size;
 
 #if HAVE_PWRITE
       off_t
-       io_file_offset;
+        io_file_offset;
 #endif
 
       io_buff_address=(char *) buffer+total_count;
@@ -428,7 +429,7 @@ DestroyThreadViewSet(ThreadViewSet *view_set)
 {
   unsigned int
     i;
-  
+
   if (view_set != (ThreadViewSet *) NULL)
     {
       if (view_set->views != (ViewInfo *) NULL)
@@ -452,21 +453,21 @@ AllocateThreadViewSet(Image *image,ExceptionInfo *exception)
 {
   ThreadViewSet
     *view_set;
-  
+
   unsigned int
     i;
-  
+
   MagickPassFail
     status=MagickPass;
-  
+
   view_set=MagickAllocateAlignedMemory(ThreadViewSet *,MAGICK_CACHE_LINE_SIZE,
-                                      sizeof(ThreadViewSet));
+                                       sizeof(ThreadViewSet));
   if (view_set == (ThreadViewSet *) NULL)
     MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
                       UnableToAllocateCacheView);
   view_set->nviews=omp_get_max_threads();
   view_set->views=MagickAllocateAlignedMemory(ViewInfo *,MAGICK_CACHE_LINE_SIZE,
-                                             view_set->nviews*sizeof(ViewInfo *));
+                                              view_set->nviews*sizeof(ViewInfo *));
   if (view_set->views == (ViewInfo *) NULL)
     {
       ThrowException(exception,CacheError,UnableToAllocateCacheView,
@@ -752,7 +753,7 @@ AccessMutablePixels(Image *image)
 %    o x,y,columns,rows:  These values define the perimeter of a region of
 %      pixels.
 %
-%    o nexus: specifies which cache nexus to acquire.
+%    o nexus_info: specifies which cache nexus to acquire.
 %
 %    o exception: Return any errors or warnings in this structure.
 %
@@ -825,10 +826,28 @@ AcquireCacheNexus(const Image *image,const long x,const long y,
                      image->filename);
       return((const PixelPacket *) NULL);
     }
+#if 0
+  fprintf(stderr,"AcquireCacheNexus(): image->columns=%lu, image->rows=%lu, "
+          "x=%ld, y=%ld, columns=%lu, rows=%lu\n",
+          image->columns,image->rows,x,y,columns,rows);
+#endif
+  if ((image->columns != cache_info->columns) ||
+      (image->rows > cache_info->rows))
+    {
+      (void) LogMagickEvent(CacheEvent,GetMagickModule(),
+                            "Image dimensions: %lux%lu, "
+                            "Cache dimensions: %lux%lu",
+                            image->columns, image->rows,
+                            cache_info->columns, cache_info->rows);
+      ThrowException(exception,CacheError,PixelCacheDimensionsMisMatch,
+                     image->filename);
+      return((const PixelPacket *) NULL);
+    }
   region.x=x;
   region.y=y;
   region.width=columns;
   region.height=rows;
+  /* Define the region of the cache for the cache nexus */
   pixels=SetNexus(image,&region,nexus_info,exception);
   if (pixels == (PixelPacket *) NULL)
     return((const PixelPacket *) NULL);
@@ -989,7 +1008,7 @@ AcquireCacheViewPixels(const ViewInfo *view,
 {
   const View
     * restrict view_info = (const View *) view;
-  
+
   assert(view_info != (const View *) NULL);
   assert(view_info->signature == MagickSignature);
   return AcquireCacheNexus(view_info->image,x,y,columns,rows,
@@ -1148,9 +1167,10 @@ AcquireOneCacheViewPixelInlined(const View *view_info,
     {
       magick_off_t
         offset;
-      
+
       offset=y*(magick_off_t) cache_info->columns+x;
-      if ((cache_info->indexes_valid) && (PseudoClass == image->storage_class))
+      if ((cache_info->indexes_valid) &&
+          (PseudoClass == cache_info->storage_class))
         *pixel=image->colormap[cache_info->indexes[offset]];
       else
         *pixel=cache_info->pixels[offset];
@@ -1427,6 +1447,9 @@ ClipCacheNexus(Image *image,const NexusInfo *nexus_info)
     *image_nexus,
     *mask_nexus;
 
+  Image
+    *clip_mask;
+
   /*
     Apply clip mask.
   */
@@ -1444,7 +1467,8 @@ ClipCacheNexus(Image *image,const NexusInfo *nexus_info)
                   nexus_info->region.width,nexus_info->region.height,
                   image_nexus,&image->exception);
   q=nexus_info->pixels;
-  r=AcquireCacheNexus(image->clip_mask,nexus_info->region.x,nexus_info->region.y,
+  clip_mask = *ImageGetClipMask(image);
+  r=AcquireCacheNexus(clip_mask,nexus_info->region.x,nexus_info->region.y,
                       nexus_info->region.width,nexus_info->region.height,mask_nexus,
                       &image->exception);
   if ((p != (PixelPacket *) NULL) && (r != (const PixelPacket *) NULL))
@@ -1469,6 +1493,162 @@ ClipCacheNexus(Image *image,const NexusInfo *nexus_info)
   DestroyCacheNexus(mask_nexus);
   return((p != (PixelPacket *) NULL) && (q != (PixelPacket *) NULL));
 }
+
+/* code for CompositeCacheNexus() below was cloned/copied from ClipCacheNexus() */
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   C o m p o s i t e C a c h e N e x u s                                               %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  CompositeCacheNexus() composites the image pixels of the in-memory or disk cache as
+%  defined by the image composite mask.  The method returns MagickPass if the
+%  pixel region is composited, otherwise MagickFail.
+%
+%  The format of the CompositeCacheNexus() method is:
+%
+%      MagickPassFail CompositeCacheNexus(Image *image,const NexusInfo *nexus_info)
+%
+%  A description of each parameter follows:
+%
+%    o status: CompositeCacheNexus() returns MagickPass if the image pixels are
+%      composited, otherwise MagickFail.
+%
+%    o image: The image.
+%
+%    o nexus_info: specifies which cache nexus to composite.
+%
+%
+*/
+static MagickPassFail
+CompositeCacheNexus(Image *image,const NexusInfo *nexus_info)
+{
+  long
+    y;
+
+  register const PixelPacket
+    *r; /* the mask */
+
+  register long
+    x;
+
+  register PixelPacket
+    *p,        /* the background pixels */
+    *q; /* the foreground pixels, also output */
+
+  NexusInfo
+    *image_nexus,
+    *mask_nexus;
+
+  Image
+    *composite_mask;
+
+  /*
+    Apply composite mask.
+  */
+  assert(image != (Image *) NULL);
+  assert(image->signature == MagickSignature);
+  image_nexus=AllocateCacheNexus();
+  mask_nexus=AllocateCacheNexus();
+  if ((image_nexus == (NexusInfo *) NULL) || (mask_nexus == (NexusInfo *) NULL))
+    {
+      DestroyCacheNexus(image_nexus);
+      DestroyCacheNexus(mask_nexus);
+      ThrowBinaryException(CacheError,UnableToGetCacheNexus,image->filename);
+    }
+  /* get background pixels */
+  p=GetCacheNexus(image,nexus_info->region.x,nexus_info->region.y,
+                  nexus_info->region.width,nexus_info->region.height,
+                  image_nexus,&image->exception);
+  /* get foreground pixels */
+  q=nexus_info->pixels;
+  /* get composite mask */
+  composite_mask = *ImageGetCompositeMask(image);
+  r=AcquireCacheNexus(composite_mask,nexus_info->region.x,nexus_info->region.y,
+                      nexus_info->region.width,nexus_info->region.height,mask_nexus,
+                      &image->exception);
+  if ((p != (PixelPacket *) NULL) && (r != (const PixelPacket *) NULL))
+    for (y=0; y < (long) nexus_info->region.height; y++)
+      {
+        for (x=0; x < (long) nexus_info->region.width; x++)
+          {
+            /*
+              The mask has already been converted to a luminance value, so using just the
+              red component should do.  Also, the "fill-opacity" was integrated into the
+              RGB components when the mask was rendered, so we do not do it again here.
+            */
+            unsigned int alpha = r->red;
+            /*
+              If the alpha value == MaxRGB (opaque), we do nothing, since the foreground
+              value is already in the output "q".  Otherwise, ...
+            */
+            if  ( alpha == 0 )
+              {/*mask fully transparent, store background*/
+                q->red = p->red;
+                q->green = p->green;
+                q->blue = p->blue;
+                q->opacity = p->opacity;
+              }/*mask fully transparent, store background*/
+            else if  ( alpha < MaxRGB )
+              {/*alpha not completely opaque, composite*/
+                /*
+                  Notes:
+                    - q is the fg, p is the bg
+                    - The fg and bg pixel values are NOT premultiplied by their
+                      alpha values.  However, in this case it doesn't matter because
+                      the mask alpha value is used to simply mix the two pixel values
+                      together according to:
+
+                        output = alpha * fg + (1 - alpha) * bg
+                               = alpha * (fg - bg) + bg
+
+                    - The fg and bg alpha values are stored as 0 == opaque, MaxRGB ==
+                      transparent (opposite the conventional usage), but if you work
+                      through the algebra it turns out the same equation works here too.
+                */
+                double AlphaNorm = alpha / MaxRGBDouble;
+                double aOut = MaxRGBDouble - (AlphaNorm * (q->opacity - p->opacity) + p->opacity);
+                double rOut,gOut,bOut;
+                if  ( aOut <= 0.0 )
+                  rOut = gOut = bOut = aOut = 0.0;
+                else if  ( aOut >= MaxRGBDouble )
+                  {
+                    rOut = AlphaNorm * (q->red - p->red) + p->red;
+                    gOut = AlphaNorm * (q->green - p->green) + p->green;
+                    bOut = AlphaNorm * (q->blue - p->blue) + p->blue;
+                    aOut = MaxRGBDouble;
+                  }
+                else
+                  {
+                    /* ReScale makes RGB be not alpha pre-multipled */
+                    double ReScale = MaxRGBDouble / aOut;
+                    rOut = ReScale * (AlphaNorm * (q->red - p->red) + p->red);
+                    gOut = ReScale * (AlphaNorm * (q->green - p->green) + p->green);
+                    bOut = ReScale * (AlphaNorm * (q->blue - p->blue) + p->blue);
+                    if  ( rOut > MaxRGBDouble )  rOut = MaxRGBDouble;
+                    if  ( gOut > MaxRGBDouble )  gOut = MaxRGBDouble;
+                    if  ( bOut > MaxRGBDouble )  bOut = MaxRGBDouble;
+                  }
+                q->red = RoundDoubleToQuantum(rOut);
+                q->green = RoundDoubleToQuantum(gOut);
+                q->blue = RoundDoubleToQuantum(bOut);
+                q->opacity = MaxRGB - (Quantum) RoundDoubleToQuantum(aOut);
+              }/*alpha not completely opaque, composite*/
+            p++;
+            q++;
+            r++;
+          }
+      }
+  DestroyCacheNexus(image_nexus);
+  DestroyCacheNexus(mask_nexus);
+  return((p != (PixelPacket *) NULL) && (q != (PixelPacket *) NULL));
+}
 \f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1528,7 +1708,10 @@ ClonePixelCache(Image *image,Image *clone_image,ExceptionInfo *exception)
   if (cache_info->length != clone_info->length)
     {
       Image
-        *clip_mask;
+        *clip_mask,
+        *composite_mask,
+        **ppclone_clip_mask,
+        **ppclone_composite_mask;
 
       ViewInfo
         *clone_view,
@@ -1553,8 +1736,12 @@ ClonePixelCache(Image *image,Image *clone_image,ExceptionInfo *exception)
         Unoptimized pixel cache clone.
       */
       (void) LogMagickEvent(CacheEvent,GetMagickModule(),"unoptimized clone");
-      clip_mask=clone_image->clip_mask;
-      clone_image->clip_mask=(Image *) NULL;
+      ppclone_clip_mask = ImageGetClipMask(clone_image);
+      clip_mask=*ppclone_clip_mask;
+      *ppclone_clip_mask=(Image *) NULL;
+      ppclone_composite_mask = ImageGetCompositeMask(clone_image);
+      composite_mask=*ppclone_composite_mask;
+      *ppclone_composite_mask=(Image *) NULL;
       length=Min(image->columns,clone_image->columns);
       y=0;
       image_view=OpenCacheView(image);
@@ -1565,10 +1752,10 @@ ClonePixelCache(Image *image,Image *clone_image,ExceptionInfo *exception)
           for (y=0; y < (long) image->rows; y++)
             {
               p=AcquireCacheViewPixels(image_view,0,y,image->columns,1,
-                                      exception);
+                                       exception);
               q=SetCacheViewPixels(clone_view,0,y,image->columns,1,exception);
               if ((p == (const PixelPacket *) NULL) ||
-                 (q == (PixelPacket *) NULL))
+                  (q == (PixelPacket *) NULL))
                 break;
               (void) memcpy(q,p,length*sizeof(PixelPacket));
               indexes=AcquireCacheViewIndexes(image_view);
@@ -1576,12 +1763,13 @@ ClonePixelCache(Image *image,Image *clone_image,ExceptionInfo *exception)
               if ((indexes != (const IndexPacket *) NULL) &&
                   (clone_indexes != (IndexPacket *) NULL))
                 (void) memcpy(clone_indexes,indexes,
-                             length*sizeof(IndexPacket));
+                              length*sizeof(IndexPacket));
               if (!SyncCacheViewPixels(clone_view,exception))
                 break;
             }
         }
-      clone_image->clip_mask=clip_mask;
+      *ImageGetClipMask(clone_image)=clip_mask;
+      *ImageGetCompositeMask(clone_image)=composite_mask;
       CloseCacheView(image_view);
       CloseCacheView(clone_view);
       return(y == (long) image->rows);
@@ -1592,7 +1780,7 @@ ClonePixelCache(Image *image,Image *clone_image,ExceptionInfo *exception)
   if ((cache_info->type != DiskCache) && (clone_info->type != DiskCache))
     {
       (void) LogMagickEvent(CacheEvent,GetMagickModule(),
-                           "memory => memory clone");
+                            "memory => memory clone");
       (void) memcpy(clone_info->pixels,cache_info->pixels,
                     (size_t) cache_info->length);
       return(MagickPass);
@@ -1605,7 +1793,7 @@ ClonePixelCache(Image *image,Image *clone_image,ExceptionInfo *exception)
     {
       if (cache_info->file == -1)
         {
-         /* FIXME: open */
+          /* FIXME: open */
           cache_file=open(cache_info->cache_filename,O_RDONLY | O_BINARY);
           if (cache_file == -1)
             {
@@ -1619,7 +1807,7 @@ ClonePixelCache(Image *image,Image *clone_image,ExceptionInfo *exception)
       if (clone_info->type != DiskCache)
         {
           (void) LogMagickEvent(CacheEvent,GetMagickModule(),
-                               "disk => memory clone");
+                                "disk => memory clone");
           for (offset=0; offset < cache_info->length; offset+=count)
             {
               size_t
@@ -1656,7 +1844,7 @@ ClonePixelCache(Image *image,Image *clone_image,ExceptionInfo *exception)
     {
       if (clone_info->file == -1)
         {
-         /* FIXME: open */
+          /* FIXME: open */
           clone_file=open(clone_info->cache_filename,O_WRONLY | O_BINARY |
                           O_EXCL,S_MODE);
           if (clone_file == -1)
@@ -1676,7 +1864,7 @@ ClonePixelCache(Image *image,Image *clone_image,ExceptionInfo *exception)
       if (cache_info->type != DiskCache)
         {
           (void) LogMagickEvent(CacheEvent,GetMagickModule(),
-                               "memory => disk clone");
+                                "memory => disk clone");
           for (offset=0L; offset < clone_info->length; offset+=count)
             {
               size_t
@@ -1795,7 +1983,7 @@ CloseCacheView(ViewInfo *view)
     {
       View
         *view_info = (View *) view;
-      
+
       assert(view_info->signature == MagickSignature);
       assert(view_info->nexus_info->signature == MagickSignature);
       DestroyCacheNexus(view_info->nexus_info);
@@ -1844,40 +2032,40 @@ DestroyCacheInfo(Cache cache_info)
       return;
     }
   UnlockSemaphoreInfo(cache_info->reference_semaphore);
-  switch (cache_info->type)
+
+  /*
+    Release Cache Pixel Resources
+  */
+  if (MemoryCache == cache_info->type)
     {
-    default:
-      {
-        if (cache_info->pixels == (PixelPacket *) NULL)
-          break;
-      }
-    case MemoryCache:
-      {
-        MagickFreeMemory(cache_info->pixels);
-        LiberateMagickResource(MemoryResource,cache_info->length);
-        break;
-      }
-    case MapCache:
-      {
-        (void) UnmapBlob(cache_info->pixels,(size_t) cache_info->length);
-        LiberateMagickResource(MapResource,cache_info->length);
-      }
-    case DiskCache:
-      {
-        if (cache_info->file != -1)
-          {
-            (void) close(cache_info->file);
-            LiberateMagickResource(FileResource,1);
-          }
-        cache_info->file=(-1);
-        (void) LiberateTemporaryFile(cache_info->cache_filename);
-        (void) LogMagickEvent(CacheEvent,GetMagickModule(),
-                              "remove %.1024s (%.1024s)",cache_info->filename,
-                              cache_info->cache_filename);
-        LiberateMagickResource(DiskResource,cache_info->length);
-        break;
-      }
+      MagickFreeMemory(cache_info->pixels);
+      LiberateMagickResource(MemoryResource,cache_info->length);
     }
+  else if (MapCache == cache_info->type)
+    {
+      (void) UnmapBlob(cache_info->pixels,(size_t) cache_info->length);
+      cache_info->pixels = NULL;
+      LiberateMagickResource(MapResource,cache_info->length);
+    }
+
+  /*
+    Release Cache File Resources
+  */
+  if ((MapCache == cache_info->type) || (DiskCache == cache_info->type))
+    {
+      if (cache_info->file != -1)
+        {
+          (void) close(cache_info->file);
+          LiberateMagickResource(FileResource,1);
+          cache_info->file=(-1);
+        }
+      (void) LiberateTemporaryFile(cache_info->cache_filename);
+      (void) LogMagickEvent(CacheEvent,GetMagickModule(),
+                            "remove %.1024s (%.1024s)",cache_info->filename,
+                            cache_info->cache_filename);
+      LiberateMagickResource(DiskResource,cache_info->length);
+    }
+
   DestroySemaphoreInfo(&cache_info->file_semaphore);
   DestroySemaphoreInfo(&cache_info->reference_semaphore);
   (void) LogMagickEvent(CacheEvent,GetMagickModule(),"destroy cache %.1024s",
@@ -1897,7 +2085,7 @@ DestroyCacheInfo(Cache cache_info)
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  DestroyCacheNexus() destroys a cache nexus which was allocated via 
+%  DestroyCacheNexus() destroys a cache nexus which was allocated via
 %  AllocateCacheNexus().
 %
 %  The format of the DestroyCacheNexus() method is:
@@ -1984,8 +2172,8 @@ GetCacheInfo(Cache *cache)
 
   assert(cache != (Cache*) NULL);
   cache_info=MagickAllocateAlignedMemory(CacheInfo *,
-                                        MAGICK_CACHE_LINE_SIZE,
-                                        sizeof(CacheInfo));
+                                         MAGICK_CACHE_LINE_SIZE,
+                                         sizeof(CacheInfo));
   if (cache_info == (CacheInfo *) NULL)
     MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
                       UnableToAllocateCacheInfo);
@@ -2505,7 +2693,7 @@ AllocateCacheNexus(void)
     *nexus_info;
 
   nexus_info=MagickAllocateAlignedMemory(NexusInfo *,MAGICK_CACHE_LINE_SIZE,
-                                        sizeof(NexusInfo));
+                                         sizeof(NexusInfo));
   if (nexus_info != ((NexusInfo *) NULL))
     {
       (void) memset(nexus_info,0,sizeof(NexusInfo));
@@ -2662,14 +2850,14 @@ GetPixelCacheInCore(const Image *image)
   if (image->cache != (Cache) NULL)
     {
       CacheInfo
-       *cache_info;
+        *cache_info;
 
       cache_info=(CacheInfo *) image->cache;
       assert(cache_info->signature == MagickSignature);
 
       if ((image->cache->type == MemoryCache) ||
-         ((image->cache->type == MapCache) && (image->cache->read_only)))
-       status=MagickTrue;
+          ((image->cache->type == MapCache) && (image->cache->read_only)))
+        status=MagickTrue;
     }
 
   return status;
@@ -2748,7 +2936,7 @@ GetPixelCachePresent(const Image *image)
 %
 %
 */
-MagickExport void
+MagickExport MagickPassFail
 InterpolateViewColor(const ViewInfo *view,
                      PixelPacket *color,
                      const double x_offset,
@@ -2777,7 +2965,7 @@ InterpolateViewColor(const ViewInfo *view,
 
   p=AcquireCacheViewPixels(view,(long) x_offset,(long) y_offset,2,2,exception);
   if (p == (const PixelPacket *) NULL)
-    return;
+    return MagickFail;
 
   matte = image->matte && IsRGBColorspace(image->colorspace);
 
@@ -2819,6 +3007,8 @@ InterpolateViewColor(const ViewInfo *view,
           (one_minus_beta*(one_minus_alpha*p[0].opacity+alpha*p[1].opacity)+
            beta*(one_minus_alpha*p[2].opacity+alpha*p[3].opacity)+0.5);
     }
+
+  return MagickPass;
 }
 MagickExport PixelPacket InterpolateColor(const Image *image,
   const double x_offset,const double y_offset,ExceptionInfo *exception)
@@ -2828,8 +3018,9 @@ MagickExport PixelPacket InterpolateColor(const Image *image,
 
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
-  InterpolateViewColor(AccessDefaultCacheView(image),&color,
-                       x_offset,y_offset,exception);
+  if (InterpolateViewColor(AccessDefaultCacheView(image),&color,
+                           x_offset,y_offset,exception) == MagickFail)
+    color.red=color.green=color.blue=color.opacity=0U;
   return color;
 }
 \f
@@ -2893,15 +3084,17 @@ ModifyCache(Image *image, ExceptionInfo *exception)
           Image
             clone_image;
 
+          (void) LogMagickEvent(CacheEvent,GetMagickModule(),
+                                "modify+clone %.1024s",cache_info->filename);
           /* fprintf(stderr,"ModifyCache: Thread %d enters (cache_info = %p)\n",
              omp_get_thread_num(),image->cache); */
           clone_image=(*image);
-         /*
-           Semaphore and reference count need to be initialized for the temporary
-           Image copy since otherwise there may be deadlock in ClonePixelCache.
-         */
-         clone_image.semaphore=AllocateSemaphoreInfo();
-         clone_image.reference_count=1;
+          /*
+            Semaphore and reference count need to be initialized for the temporary
+            Image copy since otherwise there may be deadlock in ClonePixelCache.
+          */
+          clone_image.semaphore=AllocateSemaphoreInfo();
+          clone_image.reference_count=1;
 
           GetCacheInfo(&clone_image.cache);
           status=OpenCache(&clone_image,IOMode,exception);
@@ -2911,12 +3104,14 @@ ModifyCache(Image *image, ExceptionInfo *exception)
                 Clone the pixel cache.
               */
               status=ClonePixelCache(image,&clone_image,exception);
+              if (status == MagickFail)
+                DestroyCacheInfo(clone_image.cache);
             }
-         DestroySemaphoreInfo(&clone_image.semaphore);
+          DestroySemaphoreInfo(&clone_image.semaphore);
 
           if (status != MagickFail)
             {
-             destroy_cache=MagickTrue;
+              destroy_cache=MagickTrue;
               image->cache=clone_image.cache;
             }
           if (status == MagickFail)
@@ -2936,19 +3131,19 @@ ModifyCache(Image *image, ExceptionInfo *exception)
 
     if (status != MagickFail)
       {
-       /*
-         Indicate that image will be (possibly) modified, and unset
-         grayscale/monocrome flags.
-       */
-       image->taint=MagickTrue;
-       image->is_grayscale=MagickFalse;
-       image->is_monochrome=MagickFalse;
-
-       /*
-         Make sure that pixel cache reflects key image parameters
-         such as storage class and colorspace.  Re-open cache if
-         necessary.
-       */
+        /*
+          Indicate that image will be (possibly) modified, and unset
+          grayscale/monocrome flags.
+        */
+        image->taint=MagickTrue;
+        image->is_grayscale=MagickFalse;
+        image->is_monochrome=MagickFalse;
+
+        /*
+          Make sure that pixel cache reflects key image parameters
+          such as storage class and colorspace.  Re-open cache if
+          necessary.
+        */
         cache_info=(CacheInfo *) image->cache;
         status=(((image->storage_class == cache_info->storage_class) &&
                  (image->colorspace == cache_info->colorspace)) ||
@@ -3056,7 +3251,7 @@ OpenCache(Image *image,const MapMode mode,ExceptionInfo *exception)
   cache_info=(CacheInfo *) image->cache;
   assert(cache_info->signature == MagickSignature);
   FormatString(cache_info->filename,"%.1024s[%ld]",image->filename,
-               GetImageIndexInList(image));
+               image->scene /*GetImageIndexInList(image)*/);
   cache_info->rows=image->rows;
   cache_info->columns=image->columns;
   number_pixels=(magick_uint64_t) cache_info->columns*cache_info->rows;
@@ -3170,9 +3365,13 @@ OpenCache(Image *image,const MapMode mode,ExceptionInfo *exception)
           if (cache_info->indexes_valid)
             cache_info->indexes=(IndexPacket *) (pixels+number_pixels);
           FormatSize(cache_info->length,format);
-          (void) LogMagickEvent(CacheEvent,GetMagickModule(),
-                                "open %.1024s (%.1024s)",cache_info->filename,
-                                format);
+          if (image->logging)
+            (void) LogMagickEvent(CacheEvent,GetMagickModule(),
+                                  "open %.1024s (%.1024s) storage_class=%s,"
+                                  " colorspace=%s",cache_info->filename,
+                                  format,
+                                  ClassTypeToString(cache_info->storage_class),
+                                  ColorspaceTypeToString(cache_info->colorspace));
           return(MagickPass);
         }
     }
@@ -3197,13 +3396,13 @@ OpenCache(Image *image,const MapMode mode,ExceptionInfo *exception)
     {
     case ReadMode:
       {
-       /* FIXME: open */
+        /* FIXME: open */
         file=open(cache_info->cache_filename,O_RDONLY | O_BINARY | _O_SEQUENTIAL);
         break;
       }
     case WriteMode:
       {
-       /* FIXME: open */
+        /* FIXME: open */
         file=open(cache_info->cache_filename,O_WRONLY | O_CREAT | O_BINARY |
                   O_EXCL | _O_SEQUENTIAL,S_MODE);
         if (file == -1)
@@ -3213,7 +3412,7 @@ OpenCache(Image *image,const MapMode mode,ExceptionInfo *exception)
     case IOMode:
     default:
       {
-       /* FIXME: open */
+        /* FIXME: open */
         file=open(cache_info->cache_filename,O_RDWR | O_CREAT | O_BINARY |
                   O_EXCL | _O_SEQUENTIAL, S_MODE);
         if (file == -1)
@@ -3282,12 +3481,16 @@ OpenCache(Image *image,const MapMode mode,ExceptionInfo *exception)
   /*   (void) signal(SIGBUS,CacheSignalHandler); */
 #endif
   FormatSize(cache_info->length,format);
-  (void) LogMagickEvent(CacheEvent,GetMagickModule(),
-                        "open %.1024s (%.1024s[%d], %.1024s, %.1024s)",
-                        cache_info->filename,cache_info->cache_filename,
-                        cache_info->file,
-                        cache_info->type == MapCache ? "memory-mapped" : "disk",
-                        format);
+  if (image->logging)
+    (void) LogMagickEvent(CacheEvent,GetMagickModule(),
+                          "open %.1024s (%.1024s[%d], %.1024s, %.1024s)"
+                          " storage_class=%s, colorspace=%s",
+                          cache_info->filename,cache_info->cache_filename,
+                          cache_info->file,
+                          cache_info->type == MapCache ? "memory-mapped" : "disk",
+                          format,
+                          ClassTypeToString(cache_info->storage_class),
+                          ColorspaceTypeToString(cache_info->colorspace));
   return(MagickPass);
 }
 \f
@@ -3324,7 +3527,7 @@ OpenCacheView(Image *image)
   assert(image->signature == MagickSignature);
 
   view=MagickAllocateAlignedMemory(View *,MAGICK_CACHE_LINE_SIZE,
-                                  sizeof(View));
+                                   sizeof(View));
   if (view == (View *) NULL)
     MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
                       UnableToAllocateCacheView);
@@ -3458,7 +3661,10 @@ PersistCache(Image *image,const char *filename,
   cache_info->type=DiskCache;
   cache_info->offset=(*offset);
   if (!OpenCache(clone_image,IOMode,exception))
-    return(MagickFail);
+    {
+      DestroyImage(clone_image);
+      return(MagickFail);
+    }
   y=0;
   {
     ViewInfo
@@ -3495,11 +3701,13 @@ PersistCache(Image *image,const char *filename,
     CloseCacheView(image_view);
     CloseCacheView(clone_view);
   }
-  cache_info=(CacheInfo*) ReferenceCache(cache_info);
-  DestroyImage(clone_image);
   if (y < (long) image->rows)
-    return(MagickFail);
+    {
+      DestroyImage(clone_image);
+      return(MagickFail);
+    }
   *offset+=cache_info->length+pagesize-(cache_info->length % pagesize);
+  DestroyImage(clone_image);
   (void) LogMagickEvent(CacheEvent,GetMagickModule(),"Clone persistent cache");
   return(MagickPass);
 }
@@ -3597,7 +3805,7 @@ ReadCacheIndexes(const Cache cache,const NexusInfo *nexus_info,
             {
               register long
                 x;
-              
+
               for (x=0; x < (long) nexus_info->region.width; x++)
                 *indexes++=cache_indexes[x];
               cache_indexes+=cache_info->columns;
@@ -3720,7 +3928,7 @@ ReadCachePixels(const Cache cache,const NexusInfo *nexus_info,
   length=nexus_info->region.width*sizeof(PixelPacket);
   if (length/sizeof(PixelPacket) != nexus_info->region.width)
     return MagickFail;
-  rows=nexus_info->region.height;  
+  rows=nexus_info->region.height;
   number_pixels=(magick_uint64_t) length*rows;
   if ((length ==0) || (number_pixels/length != rows))
     return MagickFail;
@@ -3896,7 +4104,7 @@ SetCacheNexus(Image *image,const long x,const long y,
       */
       assert(image->cache != (Cache) NULL);
       cache_info=(CacheInfo *) image->cache;
-      offset=y*(magick_off_t) cache_info->columns+x;
+      offset=y*(magick_off_t) cache_info->columns+x; /* FIXME: oss-fuzz 9612 signed integer overflow */
       if (offset >= 0)
         {
           magick_uint64_t
@@ -4169,7 +4377,7 @@ SetImageVirtualPixelMethod(const Image *image,
 %
 */
 static PixelPacket *
-SetNexus(const Image *image,const RectangleInfo *region,
+SetNexus(const Image *image,const RectangleInfo * restrict region,
          NexusInfo *nexus_info,ExceptionInfo *exception)
 {
   const CacheInfo
@@ -4186,38 +4394,53 @@ SetNexus(const Image *image,const RectangleInfo *region,
   assert(image != (const Image *) NULL);
   cache_info=(const CacheInfo *) image->cache;
   assert(cache_info->signature == MagickSignature);
-  nexus_info->region=*region;
-  if ((cache_info->type != PingCache) && (cache_info->type != DiskCache) &&
-      (image->clip_mask == (const Image *) NULL))
+#if 0
+  fprintf(stderr,"SetNexus(): cache_info: %lux%lu,"
+          " region: %lux%lu%+ld%+ld, cache_info->type: %u\n",
+          cache_info->columns, cache_info->rows,
+          region->width, region->height, region->x,region->y,
+          cache_info->type);
+#endif
+  if ((cache_info->type != PingCache) &&
+      (cache_info->type != DiskCache) &&
+      (/* Region must entirely be in bounds of image raster */
+       (region->x >= 0) &&
+       (region->y >= 0) &&
+       ((region->y+region->height) <= cache_info->rows)) &&
+      ((/* All/part of one row */
+        (region->height == 1) &&
+        ((region->x+region->width) <= cache_info->columns)
+        )
+       ||
+       (/* One or more full rows */
+        (region->x == 0) &&
+        (region->width == cache_info->columns)
+        )) &&
+      (*ImageGetClipMask(image) == (const Image *) NULL) &&
+      (*ImageGetCompositeMask(image) == (const Image *) NULL))
     {
-      magick_off_t
-       offset;
-
-      offset=nexus_info->region.y*(magick_off_t) cache_info->columns+nexus_info->region.x;
-      length=(nexus_info->region.height-1)*cache_info->columns+nexus_info->region.width-1;
-      number_pixels=(magick_uint64_t) cache_info->columns*cache_info->rows;
-      if ((offset >= 0) && (((magick_uint64_t) offset+length) < number_pixels))
-        if ((((nexus_info->region.x+nexus_info->region.width) <= cache_info->columns) &&
-             (nexus_info->region.height == 1)) ||
-            ((nexus_info->region.x == 0) &&
-             ((nexus_info->region.width % cache_info->columns) == 0)))
-          {
-            /*
-              Pixels are accessed directly from memory.
-            */
-            nexus_info->pixels=cache_info->pixels+offset;
-            nexus_info->indexes=(IndexPacket *) NULL;
-            if (cache_info->indexes_valid)
-              nexus_info->indexes=cache_info->indexes+offset;
-            nexus_info->in_core=IsNexusInCore(cache_info,nexus_info);
-            return(nexus_info->pixels);
-          }
+      /*
+        Pixels are accessed directly from memory.
+      */
+      size_t
+        offset;
+
+      offset=((size_t) region->y)*cache_info->columns+((size_t) region->x);
+
+      nexus_info->pixels=cache_info->pixels+offset;
+      nexus_info->indexes=(IndexPacket *) NULL;
+      if (cache_info->indexes_valid)
+        nexus_info->indexes=cache_info->indexes+offset;
+      nexus_info->in_core=MagickTrue;
+      nexus_info->region=*region;
+      /* fprintf(stderr,"Pixels in core (%p)\n",nexus_info->pixels); */
+      return(nexus_info->pixels);
     }
   /*
     Pixels are stored in a staging area until they are synced to the cache.
   */
-  number_pixels=(magick_uint64_t)
-    Max(nexus_info->region.width*nexus_info->region.height,cache_info->columns);
+  number_pixels=
+    (magick_uint64_t) Max(region->width*region->height,cache_info->columns);
   packet_size=sizeof(PixelPacket);
   if (cache_info->indexes_valid)
     packet_size+=sizeof(IndexPacket);
@@ -4229,13 +4452,13 @@ SetNexus(const Image *image,const RectangleInfo *region,
       nexus_info->staging_length=0;
       MagickFreeAlignedMemory(nexus_info->staging);
       nexus_info->staging=MagickAllocateAlignedMemory(PixelPacket *,
-                                                     MAGICK_CACHE_LINE_SIZE,
-                                                     length);
+                                                      MAGICK_CACHE_LINE_SIZE,
+                                                      length);
       if (nexus_info->staging != (PixelPacket *) NULL)
-       {
-         nexus_info->staging_length=length;
-         (void) memset((void *) nexus_info->staging,0,nexus_info->staging_length);
-       }
+        {
+          nexus_info->staging_length=length;
+          (void) memset((void *) nexus_info->staging,0,nexus_info->staging_length);
+        }
     }
   nexus_info->pixels=nexus_info->staging;
   nexus_info->indexes=(IndexPacket *) NULL;
@@ -4245,20 +4468,30 @@ SetNexus(const Image *image,const RectangleInfo *region,
   if (nexus_info->pixels == (PixelPacket *) NULL)
     {
       (void) LogMagickEvent(CacheEvent,GetMagickModule(),
-                           "Failed to allocate %" MAGICK_SIZE_T_F
+                            "Failed to allocate %" MAGICK_SIZE_T_F
                             "u bytes for nexus staging "
-                           "(number pixels=%" MAGICK_OFF_F "u, region width=%lu, "
-                           "region height=%lu, cache columns=%lu)!",
-                           (MAGICK_SIZE_T) length,
-                           number_pixels,
-                           nexus_info->region.width,
-                           nexus_info->region.height,
-                           cache_info->columns);
+                            "(number pixels=%" MAGICK_OFF_F "u, region width=%lu, "
+                            "region height=%lu, cache columns=%lu)!",
+                            (MAGICK_SIZE_T) length,
+                            number_pixels,
+                            region->width,
+                            region->height,
+                            cache_info->columns);
       ThrowException(exception,ResourceLimitError,MemoryAllocationFailed,
-                    image->filename);
+                     image->filename);
+      nexus_info->region.width=0;
+      nexus_info->region.height=0;
+      nexus_info->region.x=0;
+      nexus_info->region.y=0;
+      nexus_info->in_core=MagickFalse;
+    }
+  else
+    {
+      nexus_info->region=*region;
+      nexus_info->in_core=IsNexusInCore(cache_info,nexus_info);
     }
-  nexus_info->in_core=IsNexusInCore(cache_info,nexus_info);
 
+  /* fprintf(stderr,"Pixels in staging (%p)\n",nexus_info->pixels); */
   return(nexus_info->pixels);
 }
 \f
@@ -4322,20 +4555,29 @@ SyncCacheNexus(Image *image,const NexusInfo *nexus_info,
     }
   else
     {
-      if (image->clip_mask != (Image *) NULL)
-       if (!ClipCacheNexus(image,nexus_info))
-         status=MagickFail;
+      if (*ImageGetClipMask(image) != (Image *) NULL)
+        if (!ClipCacheNexus(image,nexus_info))
+          status=MagickFail;
+    /* added mask */
+    if  ( status != MagickFail )
+      {
+        if (*ImageGetCompositeMask(image) != (Image *) NULL)
+          {
+            if (!CompositeCacheNexus(image,nexus_info))
+              status=MagickFail;
+          }
+      }
 
       if (status != MagickFail)
-       if ((status=WriteCachePixels(cache_info,nexus_info)) == MagickFail)
-         ThrowException(exception,CacheError,UnableToSyncCache,
-                        image->filename);
+        if ((status=WriteCachePixels(cache_info,nexus_info)) == MagickFail)
+          ThrowException(exception,CacheError,UnableToSyncCache,
+                         image->filename);
 
       if (status != MagickFail)
-       if (cache_info->indexes_valid)
-         if ((status=WriteCacheIndexes(cache_info,nexus_info)) == MagickFail)
-           ThrowException(exception,CacheError,UnableToSyncCache,
-                          image->filename);
+        if (cache_info->indexes_valid)
+          if ((status=WriteCacheIndexes(cache_info,nexus_info)) == MagickFail)
+            ThrowException(exception,CacheError,UnableToSyncCache,
+                           image->filename);
     }
 
   return(status);
@@ -4520,7 +4762,7 @@ WriteCacheIndexes(Cache cache,const NexusInfo *nexus_info)
     return(MagickPass);
   offset=nexus_info->region.y*(magick_off_t) cache_info->columns+nexus_info->region.x;
   length=nexus_info->region.width*sizeof(IndexPacket);
-  rows=nexus_info->region.height;  
+  rows=nexus_info->region.height;
   number_pixels=(magick_uint64_t) length*rows;
   y=0;
   indexes=nexus_info->indexes;
@@ -4530,14 +4772,14 @@ WriteCacheIndexes(Cache cache,const NexusInfo *nexus_info)
         *cache_indexes;
 
       /*
-       Coalesce rows into larger write request if possible.
+        Coalesce rows into larger write request if possible.
       */
       if ((cache_info->columns == nexus_info->region.width) &&
-         (number_pixels == (size_t) number_pixels))
-       {
-         length=number_pixels;
-         rows=1;
-       }
+          (number_pixels == (size_t) number_pixels))
+        {
+          length=number_pixels;
+          rows=1;
+        }
 
       /*
         Write indexes to memory.
@@ -4574,38 +4816,38 @@ WriteCacheIndexes(Cache cache,const NexusInfo *nexus_info)
     file=cache_info->file;
     if (cache_info->file == -1)
       {
-       /* FIXME: open */
+        /* FIXME: open */
         file=open(cache_info->cache_filename,O_WRONLY | O_BINARY | O_EXCL,S_MODE);
         if (file == -1)
           file=open(cache_info->cache_filename,O_WRONLY | O_BINARY,S_MODE);
       }
     if (file != -1)
       {
-       magick_off_t
-         row_offset;
-       
-       ssize_t
-         bytes_written;
+        magick_off_t
+          row_offset;
+
+        ssize_t
+          bytes_written;
 
         number_pixels=(magick_uint64_t) cache_info->columns*cache_info->rows;
-       row_offset=cache_info->offset+number_pixels*sizeof(PixelPacket)+offset
-         *sizeof(IndexPacket);
+        row_offset=cache_info->offset+number_pixels*sizeof(PixelPacket)+offset
+          *sizeof(IndexPacket);
         for (y=0; y < (long) rows; y++)
           {
             if ((bytes_written=FilePositionWrite(file,indexes,length,row_offset))
-               < (long) length)
-             {
-               (void) LogMagickEvent(CacheEvent,GetMagickModule(),
-                                     "Failed to write row %ld at file offset %" MAGICK_OFF_F
-                                     "d.  Wrote %" MAGICK_SSIZE_T_F "d rather than %"
+                < (long) length)
+              {
+                (void) LogMagickEvent(CacheEvent,GetMagickModule(),
+                                      "Failed to write row %ld at file offset %" MAGICK_OFF_F
+                                      "d.  Wrote %" MAGICK_SSIZE_T_F "d rather than %"
                                       MAGICK_SIZE_T_F "u bytes (%s).",
-                                     y,
-                                     row_offset,
-                                     (MAGICK_SSIZE_T) bytes_written,
-                                     (MAGICK_SIZE_T) length,
-                                     strerror(errno));
-               break;
-             }
+                                      y,
+                                      row_offset,
+                                      (MAGICK_SSIZE_T) bytes_written,
+                                      (MAGICK_SIZE_T) length,
+                                      strerror(errno));
+                break;
+              }
             indexes+=nexus_info->region.width;
             offset+=cache_info->columns;
           }
@@ -4686,7 +4928,7 @@ WriteCachePixels(Cache cache,const NexusInfo *nexus_info)
     return(MagickPass);
   offset=nexus_info->region.y*(magick_off_t) cache_info->columns+nexus_info->region.x;
   length=nexus_info->region.width*sizeof(PixelPacket);
-  rows=nexus_info->region.height;  
+  rows=nexus_info->region.height;
   number_pixels=(magick_uint64_t) length*rows;
   y=0;
   pixels=nexus_info->pixels;
@@ -4696,14 +4938,14 @@ WriteCachePixels(Cache cache,const NexusInfo *nexus_info)
         *cache_pixels;
 
       /*
-       Coalesce rows into larger write request if possible.
+        Coalesce rows into larger write request if possible.
       */
       if ((cache_info->columns == nexus_info->region.width) &&
-         (number_pixels == (size_t) number_pixels))
-       {
-         length=number_pixels;
-         rows=1;
-       }
+          (number_pixels == (size_t) number_pixels))
+        {
+          length=number_pixels;
+          rows=1;
+        }
 
       /*
         Write pixels to memory.
@@ -4748,28 +4990,28 @@ WriteCachePixels(Cache cache,const NexusInfo *nexus_info)
       {
         for (y=0; y < (long) rows; y++)
           {
-           magick_off_t
-             row_offset;
+            magick_off_t
+              row_offset;
 
-           ssize_t
-             bytes_written;
+            ssize_t
+              bytes_written;
 
-           row_offset=cache_info->offset+offset*sizeof(PixelPacket);
+            row_offset=cache_info->offset+offset*sizeof(PixelPacket);
             if ((bytes_written=FilePositionWrite(file,pixels,length,row_offset))
-               < (ssize_t) length)
-             {
-               (void) LogMagickEvent(CacheEvent,GetMagickModule(),
-                                     "Failed to write row %ld at file offset %"
+                < (ssize_t) length)
+              {
+                (void) LogMagickEvent(CacheEvent,GetMagickModule(),
+                                      "Failed to write row %ld at file offset %"
                                       MAGICK_OFF_F "d.  Wrote %"
                                       MAGICK_SSIZE_T_F "d rather than %"
                                       MAGICK_SIZE_T_F "u bytes (%s).",
-                                     y,
-                                     row_offset,
-                                     (MAGICK_SSIZE_T) bytes_written,
-                                     (MAGICK_SIZE_T) length,
-                                     strerror(errno));
-               break;
-             }
+                                      y,
+                                      row_offset,
+                                      (MAGICK_SSIZE_T) bytes_written,
+                                      (MAGICK_SIZE_T) length,
+                                      strerror(errno));
+                break;
+              }
             pixels+=nexus_info->region.width;
             offset+=cache_info->columns;
           }
index 959006a..f62359f 100644 (file)
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2003 - 2015 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Pixel Cache Methods.
 */
 #ifndef _MAGICK_CACHE_H
@@ -84,14 +84,15 @@ extern "C" {
     the image.
   */
   extern MagickExport VirtualPixelMethod
-  GetImageVirtualPixelMethod(const Image *image);
+  GetImageVirtualPixelMethod(const Image *image) MAGICK_FUNC_PURE;
 
   /*
     GetPixels() and AccessMutablePixels() return the pixels associated
     with the last call to SetImagePixels() or GetImagePixels().
   */
   extern MagickExport PixelPacket
-  *GetPixels(const Image *image);
+  *GetPixels(const Image *image)
+    MAGICK_FUNC_DEPRECATED; /* Prefer AccessMutablePixels instead */
   extern MagickExport PixelPacket
   *AccessMutablePixels(Image *image);
 
@@ -101,7 +102,8 @@ extern "C" {
     GetImagePixels().
   */
   extern MagickExport IndexPacket
-  *GetIndexes(const Image *image);
+  *GetIndexes(const Image *image)
+    MAGICK_FUNC_DEPRECATED; /* Prefer AccessMutableIndexes() instead */
   extern MagickExport IndexPacket
   *AccessMutableIndexes(Image *image);
 
@@ -113,7 +115,8 @@ extern "C" {
     is not reliably influenced by this function.
   */
   extern MagickExport PixelPacket
-  GetOnePixel(Image *image,const long x,const long y);
+  GetOnePixel(Image *image,const long x,const long y)
+    MAGICK_FUNC_DEPRECATED; /* Prefer AcquireOnePixel() instead */
 
   /*
     GetPixelCacheArea() returns the area (width * height in pixels)
@@ -176,14 +179,14 @@ extern "C" {
     (i.e. AcquireCacheViewPixels() or GetCacheViewPixels()).
   */
   extern MagickExport PixelPacket
-  *AccessCacheViewPixels(const ViewInfo *view);
+  *AccessCacheViewPixels(const ViewInfo *view) MAGICK_FUNC_PURE;
 
   /*
     AcquireCacheViewIndexes() returns read-only indexes associated
     with a cache view.
   */
   extern MagickExport const IndexPacket
-  *AcquireCacheViewIndexes(const ViewInfo *view);
+  *AcquireCacheViewIndexes(const ViewInfo *view) MAGICK_FUNC_PURE;
 
   /*
     AcquireCacheViewPixels() obtains a pixel region from a cache view
@@ -210,19 +213,19 @@ extern "C" {
     currently consumed by the pixel cache view.
   */
   extern MagickExport magick_off_t
-  GetCacheViewArea(const ViewInfo *view);
+  GetCacheViewArea(const ViewInfo *view) MAGICK_FUNC_PURE;
 
   /*
     GetCacheViewImage() obtains the image used to allocate the cache view.
   */
   extern Image *
-  GetCacheViewImage(const ViewInfo *view);
+  GetCacheViewImage(const ViewInfo *view) MAGICK_FUNC_PURE;
 
   /*
     GetCacheViewIndexes() returns the indexes associated with a cache view.
   */
   extern MagickExport IndexPacket
-  *GetCacheViewIndexes(const ViewInfo *view);
+  *GetCacheViewIndexes(const ViewInfo *view) MAGICK_FUNC_PURE;
 
   /*
     GetCacheViewPixels() obtains a pixel region from a cache view for
@@ -237,7 +240,7 @@ extern "C" {
     Obtain the offset and size of the selected region.
   */
   extern MagickExport RectangleInfo
-  GetCacheViewRegion(const ViewInfo *view);
+  GetCacheViewRegion(const ViewInfo *view) MAGICK_FUNC_PURE;
 
 
   /*
@@ -321,14 +324,14 @@ extern "C" {
     allocated memory and therefore supports efficient random access.
   */
   extern MagickBool
-  GetPixelCacheInCore(const Image *image);
+  GetPixelCacheInCore(const Image *image) MAGICK_FUNC_PURE;
 
   /*
     GetPixelCachePresent() tests to see the pixel cache is present
     and contains pixels.
   */
   extern MagickExport MagickBool
-  GetPixelCachePresent(const Image *image);
+  GetPixelCachePresent(const Image *image) MAGICK_FUNC_PURE;
 
   /*
     Obtain an interpolated pixel value via bi-linear interpolation.
@@ -338,7 +341,7 @@ extern "C" {
       const double y_offset,ExceptionInfo *exception)
       MAGICK_FUNC_DEPRECATED;
 
-  extern MagickExport void
+  extern MagickExport MagickPassFail
     InterpolateViewColor(const ViewInfo *view,PixelPacket *color,
        const double x_offset,const double y_offset,
        ExceptionInfo *exception);
index e11e612..4cf272b 100644 (file)
@@ -1,10 +1,10 @@
 /*
-  Copyright (C) 2004-2016 GraphicsMagick Group
+  Copyright (C) 2004-2018 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Interfaces to support simple iterative pixel read/update access
   within an image or between two images. These interfaces exist in
   order to eliminate large amounts of redundant code and to allow
@@ -38,7 +38,7 @@
 #if defined(HAVE_OPENMP)
 static int
 GetRegionThreads(const PixelIteratorOptions *options,
-                const MagickBool in_core,
+                 const MagickBool in_core,
                  const unsigned long columns,
                  const unsigned long rows)
 {
@@ -202,7 +202,7 @@ PixelIterateMonoRead(PixelIteratorMonoReadCallback call_back,
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(static,1) shared(row_count, status)
+#    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(guided) shared(row_count, status)
 #  endif
 #endif
   for (row=y; row < (long) (y+rows); row++)
@@ -216,12 +216,9 @@ PixelIterateMonoRead(PixelIteratorMonoReadCallback call_back,
       const IndexPacket
         * restrict indexes;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_PixelIterateMonoRead)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
-       continue;
+        continue;
 
       pixels=AcquireImagePixels(image,x, row, columns, 1, exception);
       if (!pixels)
@@ -232,18 +229,21 @@ PixelIterateMonoRead(PixelIteratorMonoReadCallback call_back,
         thread_status=(call_back)(mutable_data,immutable_data,image,pixels,indexes,columns,exception);
 
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_PixelIterateMonoRead)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,rows))
-          if (!MagickMonitorFormatted(row_count,rows,exception,
-                                      description,image->filename))
-            thread_status=MagickFail;
-
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,rows))
+        if (!MagickMonitorFormatted(row_count,rows,exception,
+                                    description,image->filename))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
 
   return (status);
@@ -345,25 +345,18 @@ PixelIterateMonoModifyImplementation(PixelIteratorMonoModifyCallback call_back,
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(static,1) shared(row_count, status)
+#    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(guided) shared(row_count, status)
 #  endif
 #endif
   for (row=y; row < (long) (y+rows); row++)
     {
-      MagickBool
-        thread_status;
-
       PixelPacket
         * restrict pixels;
 
       IndexPacket
         * restrict indexes;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_PixelIterateMonoModify)
-#endif
-      thread_status=status;
-      if (thread_status == MagickFail)
+      if (status == MagickFail)
         continue;
 
       if (set)
@@ -371,29 +364,31 @@ PixelIterateMonoModifyImplementation(PixelIteratorMonoModifyCallback call_back,
       else
         pixels=GetImagePixelsEx(image, x, row, columns, 1, exception);
       if (!pixels)
-        thread_status=MagickFail;
+        goto mono_modify_fail;
       indexes=AccessMutableIndexes(image);
-      
-      if (thread_status != MagickFail)
-        thread_status=(call_back)(mutable_data,immutable_data,image,pixels,indexes,columns,exception);
-
-      if (thread_status != MagickFail)
-        if (!SyncImagePixelsEx(image,exception))
-          thread_status=MagickFail;
 
+      if (!((call_back)(mutable_data,immutable_data,image,pixels,indexes,columns,exception)))
+        goto mono_modify_fail;
+      if (!SyncImagePixelsEx(image,exception))
+        goto mono_modify_fail;
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_PixelIterateMonoModify)
+#  pragma omp atomic
+#endif
+      row_count++;
+      if (QuantumTick(row_count,rows))
+        if (!MagickMonitorFormatted(row_count,rows,exception,
+                                    description,image->filename))
+          goto mono_modify_fail;
+
+      /* Continue loop processing */
+      continue;
+
+      /* There was a problem */
+    mono_modify_fail:;
+      status=MagickFail;
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,rows))
-          if (!MagickMonitorFormatted(row_count,rows,exception,
-                                      description,image->filename))
-            thread_status=MagickFail;
-
-        if (thread_status == MagickFail)
-          status=MagickFail;
-      }
     }
 
   return (status);
@@ -603,9 +598,9 @@ PixelIterateDualRead(PixelIteratorDualReadCallback call_back,
 
 #if defined(HAVE_OPENMP)
   int num_threads=GetRegionThreads(options,
-                                  (GetPixelCacheInCore(first_image) &&
-                                   GetPixelCacheInCore(second_image)),
-                                  columns,rows);
+                                   (GetPixelCacheInCore(first_image) &&
+                                    GetPixelCacheInCore(second_image)),
+                                   columns,rows);
 #else
   (void) options;
 #endif /* defined(HAVE_OPENMP) */
@@ -614,7 +609,7 @@ PixelIterateDualRead(PixelIteratorDualReadCallback call_back,
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(static,1) shared(row_count, status)
+#    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(guided) shared(row_count, status)
 #  endif
 #endif
   for (row=0; row < (long) rows; row++)
@@ -634,9 +629,6 @@ PixelIterateDualRead(PixelIteratorDualReadCallback call_back,
         * restrict first_indexes,
         * restrict second_indexes;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_PixelIterateDualRead)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -663,19 +655,22 @@ PixelIterateDualRead(PixelIteratorDualReadCallback call_back,
                                   columns, exception);
 
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_PixelIterateDualRead)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,rows))
-          if (!MagickMonitorFormatted(row_count,rows,exception,
-                                      description,first_image->filename,
-                                      second_image->filename))
-            thread_status=MagickFail;
-
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,rows))
+        if (!MagickMonitorFormatted(row_count,rows,exception,
+                                    description,first_image->filename,
+                                    second_image->filename))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
 
   return (status);
@@ -775,9 +770,9 @@ PixelIterateDualImplementation(PixelIteratorDualModifyCallback call_back,
 
 #if defined(HAVE_OPENMP)
   int num_threads=GetRegionThreads(options,
-                                  (GetPixelCacheInCore(source_image) &&
-                                   GetPixelCacheInCore(update_image)),
-                                  columns,rows);
+                                   (GetPixelCacheInCore(source_image) &&
+                                    GetPixelCacheInCore(update_image)),
+                                   columns,rows);
 #else
   (void) options;
 #endif /* defined(HAVE_OPENMP) */
@@ -789,7 +784,7 @@ PixelIterateDualImplementation(PixelIteratorDualModifyCallback call_back,
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(static,1) shared(row_count, status)
+#    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(guided) shared(row_count, status)
 #  endif
 #endif
   for (row=0; row < (long) rows; row++)
@@ -813,9 +808,6 @@ PixelIterateDualImplementation(PixelIteratorDualModifyCallback call_back,
         source_row,
         update_row;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_PixelIterateDualImplementation)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -828,7 +820,7 @@ PixelIterateDualImplementation(PixelIteratorDualModifyCallback call_back,
       if (!source_pixels)
         thread_status=MagickFail;
       source_indexes=AccessImmutableIndexes(source_image);
-      
+
       if (set)
         update_pixels=SetImagePixelsEx(update_image, update_x, update_row,
                                        columns, 1, exception);
@@ -844,25 +836,28 @@ PixelIterateDualImplementation(PixelIteratorDualModifyCallback call_back,
                                   source_image,source_pixels,source_indexes,
                                   update_image,update_pixels,update_indexes,
                                   columns,exception);
-      
+
       if (thread_status != MagickFail)
         if (!SyncImagePixelsEx(update_image,exception))
           thread_status=MagickFail;
 
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_PixelIterateDualImplementation)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,rows))
-          if (!MagickMonitorFormatted(row_count,rows,exception,
-                                      description,source_image->filename,
-                                      update_image->filename))
-            thread_status=MagickFail;
-
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,rows))
+        if (!MagickMonitorFormatted(row_count,rows,exception,
+                                    description,source_image->filename,
+                                    update_image->filename))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
 
   return (status);
@@ -1082,10 +1077,10 @@ PixelIterateTripleImplementation(PixelIteratorTripleModifyCallback call_back,
 
 #if defined(HAVE_OPENMP)
   int num_threads=GetRegionThreads(options,
-                                  (GetPixelCacheInCore(source1_image) &&
-                                   GetPixelCacheInCore(source2_image) &&
-                                   GetPixelCacheInCore(update_image)),
-                                  columns,rows);
+                                   (GetPixelCacheInCore(source1_image) &&
+                                    GetPixelCacheInCore(source2_image) &&
+                                    GetPixelCacheInCore(update_image)),
+                                   columns,rows);
 #else
   (void) options;
 #endif /* defined(HAVE_OPENMP) */
@@ -1097,7 +1092,7 @@ PixelIterateTripleImplementation(PixelIteratorTripleModifyCallback call_back,
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(static,1) shared(row_count, status)
+#    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(guided) shared(row_count, status)
 #endif
 #endif
   for (row=0; row < (long) rows; row++)
@@ -1123,9 +1118,6 @@ PixelIterateTripleImplementation(PixelIteratorTripleModifyCallback call_back,
         source_row,
         update_row;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_PixelIterateTripleImplementation)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -1169,30 +1161,33 @@ PixelIterateTripleImplementation(PixelIteratorTripleModifyCallback call_back,
 
       if (thread_status != MagickFail)
         thread_status=(call_back)(mutable_data,immutable_data,
-                                 source1_image,source1_pixels,source1_indexes,
-                                 source2_image,source2_pixels,source2_indexes,
-                                 update_image,update_pixels,update_indexes,
-                                 columns,exception);
+                                  source1_image,source1_pixels,source1_indexes,
+                                  source2_image,source2_pixels,source2_indexes,
+                                  update_image,update_pixels,update_indexes,
+                                  columns,exception);
 
       if (thread_status != MagickFail)
-       if (!SyncImagePixelsEx(update_image,exception))
-         thread_status=MagickFail;
+        if (!SyncImagePixelsEx(update_image,exception))
+          thread_status=MagickFail;
 
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_PixelIterateTripleImplementation)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,rows))
-          if (!MagickMonitorFormatted(row_count,rows,exception,description,
-                                      source1_image->filename,
-                                      source2_image->filename,
-                                      update_image->filename))
-            thread_status=MagickFail;
-
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,rows))
+        if (!MagickMonitorFormatted(row_count,rows,exception,description,
+                                    source1_image->filename,
+                                    source2_image->filename,
+                                    update_image->filename))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
 
   return (status);
index 749f286..91a5545 100644 (file)
@@ -1,6 +1,6 @@
 /*
   Copyright (C) 2004-2016 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
@@ -19,7 +19,7 @@
   be safely used by other applications/libraries.
 
   Written by Bob Friesenhahn, March 2004, Updated for regions 2008.
+
 */
 #ifndef _PIXEL_ROW_ITERATOR_H
 #define _PIXEL_ROW_ITERATOR_H
index 9ce1470..3bad6b7 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 - 2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Plasma Methods.
 */
 #ifndef _MAGICK_PLASMA_H
@@ -23,7 +23,7 @@ extern "C" {
 \f
 extern MagickExport MagickPassFail
 PlasmaImage(Image *image,const SegmentInfo *segment,
-           unsigned long attenuate,unsigned long depth);
+            unsigned long attenuate,unsigned long depth);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
index 845441b..ae99abf 100644 (file)
@@ -1,6 +1,6 @@
 /*
   Copyright (C) 2010 - 2011 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
index cfda041..27596fc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -77,7 +77,7 @@
 %  referencing.  However, it is safe to delete a profile that the iterator
 %  is not currently referencing. Inserting additional profiles does not
 %  invalidate the current iterator.
-%  
+%
 %
 %  The format of the AllocateImageProfileIterator method is:
 %
@@ -137,9 +137,9 @@ AllocateImageProfileIterator(const Image *image)
 */
 MagickExport MagickPassFail
 AppendImageProfile(Image *image,
-                  const char *name,
-                  const unsigned char *profile_chunk,
-                  const size_t chunk_length)
+                   const char *name,
+                   const unsigned char *profile_chunk,
+                   const size_t chunk_length)
 {
   const unsigned char
     *existing_profile;
@@ -164,17 +164,17 @@ AppendImageProfile(Image *image,
   else
     {
       unsigned char
-       *profile;
+        *profile;
 
       size_t
-       profile_length;
+        profile_length;
 
       profile_length=existing_length+chunk_length;
-      if ((profile_length < existing_length) || 
-         ((profile=MagickAllocateMemory(unsigned char *,(size_t) profile_length)) ==
-          (unsigned char *) NULL))
-       ThrowBinaryException(ResourceLimitError,MemoryAllocationFailed,
-                            (char *) NULL);
+      if ((profile_length < existing_length) ||
+          ((profile=MagickAllocateMemory(unsigned char *,(size_t) profile_length)) ==
+           (unsigned char *) NULL))
+        ThrowBinaryException(ResourceLimitError,MemoryAllocationFailed,
+                             (char *) NULL);
       (void) memcpy(profile,existing_profile,existing_length);
       (void) memcpy(profile+existing_length,profile_chunk,chunk_length);
       status=SetImageProfile(image,name,profile,profile_length);
@@ -401,7 +401,7 @@ NextImageProfile(ImageProfileIterator profile_iterator,
 %  If there is no ICM profile currently associated with the image, then
 %  the profile is simply associated with the image and the image pixels
 %  are not altered.
-%  
+%
 %  If there is already a ICM profile associated with the image, then
 %  the colorspace transform described by the existing and new profiles
 %  is applied to the image pixels, and the new profile is associated
@@ -473,21 +473,21 @@ lcmsReplacementErrorHandler(cmsContext ContextID, cmsUInt32Number ErrorCode, con
   }
 
   (void) LogMagickEvent(type,GetMagickModule(),"lcms: #%u, %s",
-                       ErrorCode,(ErrorText != (char *) NULL) ? ErrorText : "No error text");
+                        ErrorCode,(ErrorText != (char *) NULL) ? ErrorText : "No error text");
 
   if (xform != (TransformInfo *) NULL)
     {
       ThrowException2(&xform->image->exception,type,"UnableToTransformColorspace",
-                    (ErrorText != (char *) NULL) ? ErrorText : "No error text");
+                     (ErrorText != (char *) NULL) ? ErrorText : "No error text");
     }
 }
 
 static MagickPassFail
 ProfileImagePixels(void *mutable_data,         /* User provided mutable data */
                    const void *immutable_data, /* User provided immutable data */
-                   Image *image,               /* Modify image */
-                   PixelPacket *pixels,        /* Pixel row */
-                   IndexPacket *indexes,       /* Pixel row indexes */
+                   Image * restrict image,               /* Modify image */
+                   PixelPacket * restrict pixels,        /* Pixel row */
+                   IndexPacket * restrict indexes,       /* Pixel row indexes */
                    const long npixels,         /* Number of pixels in row */
                    ExceptionInfo *exception)   /* Exception report */
 {
@@ -709,13 +709,13 @@ ProfileImage(Image *image,const char *name,unsigned char *profile,
 
       const char
         *profile_name;
-      
+
       size_t
         profile_length;
-      
+
       const unsigned char *
         profile_info;
-      
+
       ImageProfileIterator
         profile_iterator;
 
@@ -747,7 +747,7 @@ ProfileImage(Image *image,const char *name,unsigned char *profile,
           for (i=1 ; i < argc ; i++)
             {
               if ((*argv[i] == '!') && (LocaleCompare(profile_name,argv[i]+1) == 0))
-                break;                
+                break;
               if (GlobExpression(profile_name,argv[i]))
                 {
                   (void) strlcpy(profile_remove,profile_name,sizeof(profile_remove));
@@ -817,17 +817,17 @@ ProfileImage(Image *image,const char *name,unsigned char *profile,
           /*
             Transform pixel colors as defined by the color profiles.
           */
-         (void) memset(&xform,0,sizeof(xform));
-         xform.signature=MagickSignature;
-         xform.image=image;
+          (void) memset(&xform,0,sizeof(xform));
+          xform.signature=MagickSignature;
+          xform.image=image;
           cmsSetLogErrorHandler(lcmsReplacementErrorHandler);
 
           xform.source_profile=cmsOpenProfileFromMemTHR((cmsContext) &xform,
-                                                       (unsigned char *) existing_profile,
-                                                       (cmsUInt32Number) existing_profile_length);
+                                                        (unsigned char *) existing_profile,
+                                                        (cmsUInt32Number) existing_profile_length);
           xform.target_profile=cmsOpenProfileFromMemTHR((cmsContext) &xform,
-                                                       (unsigned char *) profile,
-                                                       (cmsUInt32Number) length);
+                                                        (unsigned char *) profile,
+                                                        (cmsUInt32Number) length);
           if ((xform.source_profile == (cmsHPROFILE) NULL) ||
               (xform.target_profile == (cmsHPROFILE) NULL))
             ThrowBinaryException3(ResourceLimitError,UnableToManageColor,
@@ -975,7 +975,7 @@ ProfileImage(Image *image,const char *name,unsigned char *profile,
           /* Verify that source colorspace type is supported */
           if (!IsGrayColorspace(xform.source_colorspace) &&
               !IsCMYKColorspace(xform.source_colorspace) &&
-             !IsLABColorspace(xform.source_colorspace) &&
+              !IsLABColorspace(xform.source_colorspace) &&
               !IsYCbCrColorspace(xform.source_colorspace) &&
               !IsRGBColorspace(image->colorspace))
             {
@@ -987,8 +987,8 @@ ProfileImage(Image *image,const char *name,unsigned char *profile,
 
           (void) LogMagickEvent(TransformEvent,GetMagickModule(),
                                 "Source pixel format: COLORSPACE=%s SWAPFIRST=%d "
-                               "FLAVOR=%d PLANAR=%d ENDIAN16=%d DOSWAP=%d "
-                               "EXTRA=%d CHANNELS=%d BYTES=%d",
+                                "FLAVOR=%d PLANAR=%d ENDIAN16=%d DOSWAP=%d "
+                                "EXTRA=%d CHANNELS=%d BYTES=%d",
                                 PixelTypeToString((int) T_COLORSPACE(xform.source_type)),
                                 (int) T_SWAPFIRST(xform.source_type),
                                 (int) T_FLAVOR(xform.source_type),
@@ -1001,8 +1001,8 @@ ProfileImage(Image *image,const char *name,unsigned char *profile,
 
           (void) LogMagickEvent(TransformEvent,GetMagickModule(),
                                 "Target pixel format: COLORSPACE=%s SWAPFIRST=%d "
-                               "FLAVOR=%d PLANAR=%d ENDIAN16=%d DOSWAP=%d "
-                               "EXTRA=%d CHANNELS=%d BYTES=%d",
+                                "FLAVOR=%d PLANAR=%d ENDIAN16=%d DOSWAP=%d "
+                                "EXTRA=%d CHANNELS=%d BYTES=%d",
                                 PixelTypeToString((int) T_COLORSPACE(xform.target_type)),
                                 (int) T_SWAPFIRST(xform.target_type),
                                 (int) T_FLAVOR(xform.target_type),
@@ -1018,17 +1018,17 @@ ProfileImage(Image *image,const char *name,unsigned char *profile,
             case AbsoluteIntent:
               xform.intent=INTENT_ABSOLUTE_COLORIMETRIC;
               break;
-            case PerceptualIntent: 
-              xform.intent=INTENT_PERCEPTUAL; 
+            case PerceptualIntent:
+              xform.intent=INTENT_PERCEPTUAL;
               break;
-            case RelativeIntent: 
+            case RelativeIntent:
               xform.intent=INTENT_RELATIVE_COLORIMETRIC;
               break;
-            case SaturationIntent: 
-              xform.intent=INTENT_SATURATION; 
+            case SaturationIntent:
+              xform.intent=INTENT_SATURATION;
               break;
-            default: 
-              xform.intent=INTENT_PERCEPTUAL; 
+            default:
+              xform.intent=INTENT_PERCEPTUAL;
               break;
             }
 
@@ -1044,44 +1044,44 @@ ProfileImage(Image *image,const char *name,unsigned char *profile,
             ((xform.source_colorspace != GRAYColorspace) ||
              (xform.source_colorspace == xform.target_colorspace));
 
-         /* build pre-computed transforms? */
-         xform.flags=(transform_colormap ? cmsFLAGS_NOOPTIMIZE : 0);
-
-         xform.transform=AllocateThreadViewDataSet(MagickFreeCMSTransform,
-                                                   image,&image->exception);
-         if (xform.transform == (ThreadViewDataSet *) NULL)
-           status=MagickFail;
-         if (status != MagickFail)
-           {
-             cmsHTRANSFORM
-               transform;
-
-             unsigned int
-               index;
-
-             for (index=0 ; index < GetThreadViewDataSetAllocatedViews(xform.transform); index++)
-               {
-                 transform=cmsCreateTransformTHR((cmsContext) &xform,/* transform handle */
-                                              xform.source_profile,  /* input profile */
-                                              xform.source_type,     /* input pixel format */
-                                              xform.target_profile,  /* output profile */
-                                              xform.target_type,     /* output pixel format */
-                                              xform.intent,          /* rendering intent */
-                                              xform.flags            /* pre-computed transforms? */
-                                              );
-                 if (transform == (cmsHTRANSFORM) NULL)
-                   {
-                     status=MagickFail;
-                     break;
-                   }
-                 AssignThreadViewData(xform.transform,index,transform);
-               }
-           }
+          /* build pre-computed transforms? */
+          xform.flags=(transform_colormap ? cmsFLAGS_NOOPTIMIZE : 0);
+
+          xform.transform=AllocateThreadViewDataSet(MagickFreeCMSTransform,
+                                                    image,&image->exception);
+          if (xform.transform == (ThreadViewDataSet *) NULL)
+            status=MagickFail;
+          if (status != MagickFail)
+            {
+              cmsHTRANSFORM
+                transform;
+
+              unsigned int
+                index;
+
+              for (index=0 ; index < GetThreadViewDataSetAllocatedViews(xform.transform); index++)
+                {
+                  transform=cmsCreateTransformTHR((cmsContext) &xform,/* transform handle */
+                                               xform.source_profile,  /* input profile */
+                                               xform.source_type,     /* input pixel format */
+                                               xform.target_profile,  /* output profile */
+                                               xform.target_type,     /* output pixel format */
+                                               xform.intent,          /* rendering intent */
+                                               xform.flags            /* pre-computed transforms? */
+                                               );
+                  if (transform == (cmsHTRANSFORM) NULL)
+                    {
+                      status=MagickFail;
+                      break;
+                    }
+                  AssignThreadViewData(xform.transform,index,transform);
+                }
+            }
           (void) cmsCloseProfile(xform.source_profile);
           (void) cmsCloseProfile(xform.target_profile);
-         if (status == MagickFail)
+          if (status == MagickFail)
             {
-             DestroyThreadViewDataSet(xform.transform);
+              DestroyThreadViewDataSet(xform.transform);
               ThrowBinaryException3(ResourceLimitError,UnableToManageColor,
                                     UnableToCreateColorTransform);
             }
@@ -1132,7 +1132,7 @@ ProfileImage(Image *image,const char *name,unsigned char *profile,
           */
           image->is_grayscale=IsGrayColorspace(xform.target_colorspace);
           image->is_monochrome=False;
-         DestroyThreadViewDataSet(xform.transform);
+          DestroyThreadViewDataSet(xform.transform);
 
           /*
             Throw away the old profile after conversion before we
@@ -1154,7 +1154,7 @@ ProfileImage(Image *image,const char *name,unsigned char *profile,
         We might be trying to assign a CMYK profile to an RGB image,
         for instance.
       */
-      
+
       (void) SetImageProfile(image,"ICM",profile,length);
       if (!clone)
         MagickFreeMemory(profile);
@@ -1251,9 +1251,13 @@ SetImageProfile(Image *image,const char *name, const unsigned char *profile,
         image->profiles=MagickMapAllocateMap(MagickMapCopyBlob,
                                              MagickMapDeallocateBlob);
 
+      if (image->profiles == 0)
+        ThrowBinaryException3(ResourceLimitError,MemoryAllocationFailed,
+                              UnableToAddOrRemoveProfile);
+
       (void) LogMagickEvent(TransformEvent,GetMagickModule(),
                             "Adding %s profile with length %ld bytes",name,
-                           (unsigned long) length);
+                            (unsigned long) length);
       if (profile != 0)
         {
           status &= MagickMapAddEntry(image->profiles,name,profile,length,
index e19bec9..7d62eef 100644 (file)
@@ -1,10 +1,10 @@
 /*
   Copyright (C) 2004 - 2009 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Methods For Manipulating Embedded Image Profiles.
 */
 #ifndef _MAGICK_PROFILE_H
@@ -45,8 +45,8 @@ extern MagickExport MagickPassFail
  */
   extern MagickExport MagickPassFail
   AppendImageProfile(Image *image,const char *name,
-                    const unsigned char *profile_chunk,
-                    const size_t chunk_length);
+                     const unsigned char *profile_chunk,
+                     const size_t chunk_length);
 
 /*
   Generic iterator for traversing profiles.
index 3a3de08..dd5ba71 100644 (file)
@@ -1705,7 +1705,7 @@ MagickExport void GrayscalePseudoClassImage(Image *image,
                 {
                   register int
                     intensity;
-                  
+
                   /*
                     If index is new, create index to colormap
                   */
@@ -1742,7 +1742,7 @@ MagickExport void GrayscalePseudoClassImage(Image *image,
                   *indexes=ScaleQuantumToIndex(q->red);
                   q++;
                   indexes++;
-                } 
+                }
               if (!SyncImagePixels(image))
                 break;
            }
@@ -1770,7 +1770,7 @@ MagickExport void GrayscalePseudoClassImage(Image *image,
               return;
             }
         }
-      
+
       /*
         Assign index values to colormap entries.
       */
@@ -1810,7 +1810,7 @@ MagickExport void GrayscalePseudoClassImage(Image *image,
                 j++;
                 new_colormap[j]=image->colormap[i];
               }
-            
+
             colormap_index[image->colormap[i].opacity]=j;
           }
         image->colors=j+1;
@@ -2599,8 +2599,8 @@ MagickExport MagickPassFail QuantizeImages(const QuantizeInfo *quantize_info,
     image=image->next;
     (void) SetMonitorHandler(handler);
     if ((image != (Image *) NULL) &&
-       (!MagickMonitorFormatted(i,number_images,&image->exception,
-                                ClassifyImageText,image->filename)))
+        (!MagickMonitorFormatted(i,number_images,&image->exception,
+                                 ClassifyImageText,image->filename)))
       break;
   }
   if (status != MagickFail)
@@ -2621,8 +2621,8 @@ MagickExport MagickPassFail QuantizeImages(const QuantizeInfo *quantize_info,
         image=image->next;
         (void) SetMonitorHandler(handler);
         if ((image != (Image *) NULL) &&
-           (!MagickMonitorFormatted(i,number_images,&image->exception,
-                                    AssignImageText,image->filename)))
+            (!MagickMonitorFormatted(i,number_images,&image->exception,
+                                     AssignImageText,image->filename)))
           {
             status=MagickFail;
             break;
@@ -2768,8 +2768,8 @@ static void ReduceImageColors(const char *filename,CubeInfo *cube_info,
     status=MagickMonitorFormatted(span-cube_info->colors,
                                   span-number_colors+1,exception,
                                   ReduceImageText,
-                                 filename,
-                                 number_colors);
+                                  filename,
+                                  number_colors);
     if (status == False)
       break;
   }
index 89a76cf..c124739 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Methods to Reduce the Number of Unique Colors in an Image.
 */
 #ifndef _MAGICK_QUANTIZE_H
index 2ceb899..db60000 100644 (file)
@@ -1,10 +1,10 @@
 /*
   Copyright (C) 2009, 2014 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Random number generator (private not-installed parts).
 
   Currently based on George Marsaglia's multiply-with-carry generator.
index be4af22..819e8f9 100644 (file)
@@ -56,11 +56,11 @@ MagickExport MagickRandomKernel* AcquireMagickRandomKernel()
   if (kernel == (MagickRandomKernel *) NULL)
     {
       kernel=MagickAllocateAlignedMemory(MagickRandomKernel *,
-                                        MAGICK_CACHE_LINE_SIZE,
-                                        sizeof(MagickRandomKernel));
+                                         MAGICK_CACHE_LINE_SIZE,
+                                         sizeof(MagickRandomKernel));
       if (kernel == (MagickRandomKernel *) NULL)
-       MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
-                         UnableToAllocateRandomKernel);
+        MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
+                          UnableToAllocateRandomKernel);
       InitializeMagickRandomKernel(kernel);
       MagickTsdSetSpecific(kernel_key,(const void *) kernel);
     }
@@ -91,7 +91,7 @@ void DestroyMagickRandomGenerator()
   if (initialized)
     {
       MagickRandomKernel
-       *kernel;
+        *kernel;
 
       /* FIXME: This only frees memory associated with one thread */
       kernel=(MagickRandomKernel *) MagickTsdGetSpecific(kernel_key);
@@ -128,9 +128,9 @@ InitializeMagickRandomKernel(MagickRandomKernel *kernel)
 
     if ((file=open("/dev/urandom",O_RDONLY | O_BINARY)) != -1)
       {
-       if (read(file,(void *) kernel,sizeof(*kernel)) == sizeof(*kernel))
+        if (read(file,(void *) kernel,sizeof(*kernel)) == sizeof(*kernel))
           done=MagickTrue;
-       (void) close(file);
+        (void) close(file);
       }
     if (!done)
       MagickFatalError(ResourceLimitFatalError,UnableToObtainRandomEntropy,
@@ -188,7 +188,7 @@ InitializeMagickRandomKernel(MagickRandomKernel *kernel)
       pthread_t thread_id;
       magick_uint32_t intval;
     } pthread_union;
-    
+
     pthread_union.intval=0U;
     pthread_union.thread_id=pthread_self();
     kernel->w ^= pthread_union.intval;
index 6ccb38c..a87e969 100644 (file)
@@ -1,10 +1,10 @@
 /*
   Copyright (C) 2009, 2014 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Random number generator (semi-public interfaces).
 
   Currently based on George Marsaglia's multiply-with-carry generator.
index 4ce9245..c67398c 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003-2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Magick registry methods.
 */
 #ifndef _MAGICK_REGISTRY_H
index 5f3b2d8..d502d58 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -57,6 +57,7 @@
 #include "magick/paint.h"
 #include "magick/pixel_cache.h"
 #include "magick/render.h"
+#include "magick/resource.h"
 #include "magick/transform.h"
 #include "magick/utility.h"
 \f
   Define declarations.
 */
 #define BezierQuantum  200
+
+/* Maximum amount of recursion allowed when executing MVG */
+#if !defined(MAX_DRAWIMAGE_RECURSION)
+#  define MAX_DRAWIMAGE_RECURSION 100
+#endif /* defined(MAX_DRAWIMAGE_RECURSION) */
 \f
 /*
   Typedef declarations.
@@ -87,7 +93,7 @@ typedef struct _EdgeInfo
 
   MagickBool
     ghostline;
-  
+
 } EdgeInfo;
 
 typedef struct _PolygonInfo
@@ -116,39 +122,117 @@ typedef struct _PathInfo
   PathInfoCode
     code;
 } PathInfo;
+
+
+/*
+  A data structure to help manage automatically growing a PrimitiveInfo array.
+  Intended to be used in DrawImage() and the TraceXXX() functions.  See static
+  function PrimitiveInfoRealloc().  Motivated by ticket #516.
+*/
+typedef struct _PrimitiveInfoMgr
+{
+  PrimitiveInfo ** pp_PrimitiveInfo;  /* address of a pointer to the start of the PrimitiveInfo array */
+                                      /* (updated when the array is reallocated) */
+
+  size_t *         p_AllocCount;      /* address of a location containing the number of elements allocated */
+                                      /* (updated when the array is reallocated) */
+
+  size_t           StoreStartingAt;   /* index to the element at which to start storing new elements */
+                                      /* (must be updated before calling PrimitiveInfoRealloc()) */
+
+  ExceptionInfo *  p_Exception;       /* for when reallocation fails */
+} PrimitiveInfoMgr;
+
+
+/*
+  DrawInfoExtra allows for expansion of DrawInfo without increasing its
+  size.  The internals are defined only in this source file.  Clients
+  outside of this source file can access the internals via the provided
+  access functions (see below).
+*/
+typedef struct _DrawInfoExtra
+{
+  char
+    /*
+      clip_path is (typically) the name of the attribute whose value contains
+      the clipping path's graphical elements.
+    */
+    *clip_path,
+    /*
+      composite_path is (typically) the name of the attribute whose value contains
+      the composite path's graphical elements.
+    */
+    *composite_path;
+} DrawInfoExtra;
 \f
+/* provide public access to the clip_path member of DrawInfo */
+MagickExport char **
+DrawInfoGetClipPath(const DrawInfo * draw_info)
+{
+  return(&draw_info->extra->clip_path);
+}
+\f
+/* provide public access to the composite_path member of DrawInfo */
+MagickExport char **
+DrawInfoGetCompositePath(const DrawInfo * draw_info)
+{
+  return(&draw_info->extra->composite_path);
+}
+
 /*
   Forward declarations.
 */
-static PrimitiveInfo
-  *TraceStrokePolygon(const DrawInfo *,const PrimitiveInfo *);
+static PrimitiveInfo  /* added Image* param so DrawInfo::stroke_width can be clamped */
+  *TraceStrokePolygon(const Image *,const DrawInfo *,const PrimitiveInfo *);
 
 static MagickPassFail
-  DrawPrimitive(Image *,const DrawInfo *,const PrimitiveInfo *),
-  DrawStrokePolygon(Image *,const DrawInfo *,const PrimitiveInfo *);
+  DrawBoundingRectangles(Image *image,const DrawInfo *draw_info,
+                         const PolygonInfo *polygon_info) MAGICK_FUNC_WARN_UNUSED_RESULT,
+  DrawPrimitive(Image *,const DrawInfo *,const PrimitiveInfo *) MAGICK_FUNC_WARN_UNUSED_RESULT,
+  DrawStrokePolygon(Image *,const DrawInfo *,const PrimitiveInfo *) MAGICK_FUNC_WARN_UNUSED_RESULT,
+  PrimitiveInfoRealloc(PrimitiveInfoMgr *p_PIMgr,const size_t Needed) MAGICK_FUNC_WARN_UNUSED_RESULT,
+  TraceArc(PrimitiveInfoMgr *,const PointInfo,const PointInfo,const PointInfo) MAGICK_FUNC_WARN_UNUSED_RESULT,
+  TraceArcPath(PrimitiveInfoMgr *,const PointInfo,const PointInfo,const PointInfo,
+               const double,const unsigned int,const unsigned int) MAGICK_FUNC_WARN_UNUSED_RESULT,
+  TraceBezier(PrimitiveInfoMgr *,const unsigned long) MAGICK_FUNC_WARN_UNUSED_RESULT,
+  TraceCircle(PrimitiveInfoMgr *,const PointInfo,const PointInfo) MAGICK_FUNC_WARN_UNUSED_RESULT,
+  TraceEllipse(PrimitiveInfoMgr *,const PointInfo,const PointInfo,const PointInfo) MAGICK_FUNC_WARN_UNUSED_RESULT,
+  TraceLine(PrimitiveInfo *,const PointInfo,const PointInfo) MAGICK_FUNC_WARN_UNUSED_RESULT,
+  TracePoint(PrimitiveInfo *,const PointInfo) MAGICK_FUNC_WARN_UNUSED_RESULT,
+  TraceRectangle(PrimitiveInfo *,const PointInfo,const PointInfo) MAGICK_FUNC_WARN_UNUSED_RESULT,
+  TraceRoundRectangle(PrimitiveInfoMgr *,const PointInfo,const PointInfo,PointInfo) MAGICK_FUNC_WARN_UNUSED_RESULT,
+  TraceSquareLinecap(PrimitiveInfo *,const unsigned long,const double) MAGICK_FUNC_WARN_UNUSED_RESULT;
+
+static MagickBool
+  /*IsDrawInfoClippingPath(const DrawInfo *),*/           /* is DrawInfo a clipping path */
+  IsDrawInfoSVGCompliant(const DrawInfo *),               /* is DrawInfo drawn as SVG compliant */
+  IsDrawInfoSVGCompliantClippingPath(const DrawInfo *);   /* is DrawInfo drawn as SVG compliant clipping path */
+
+static void
+  SetDrawInfoClippingPath(DrawInfo *, MagickBool ClippingPath),   /* tag DrawInfo as clipping path or not */
+  SetDrawInfoSVGCompliant(DrawInfo *, MagickBool SVGCompliant);   /* tag DrawInfo as SVG compliant or not */
 
 static unsigned long
-  TracePath(Image *image, PrimitiveInfo *,const char *);
+  TracePath(Image *image, PrimitiveInfoMgr *,const char *);
 
 static void
 #if 0
   DestroyGradientInfo(GradientInfo *),
 #endif
-  DestroyPolygonInfo(void *polygon_info_void),
-  TraceArc(PrimitiveInfo *,const PointInfo,const PointInfo,const PointInfo),
-  TraceArcPath(PrimitiveInfo *,const PointInfo,const PointInfo,const PointInfo,
-    const double,const unsigned int,const unsigned int),
-  TraceBezier(PrimitiveInfo *,const unsigned long),
-  TraceCircle(PrimitiveInfo *,const PointInfo,const PointInfo),
-  TraceEllipse(PrimitiveInfo *,const PointInfo,const PointInfo,const PointInfo),
-  TraceLine(PrimitiveInfo *,const PointInfo,const PointInfo),
-  TracePoint(PrimitiveInfo *,const PointInfo),
-  TraceRectangle(PrimitiveInfo *,const PointInfo,const PointInfo),
-  TraceRoundRectangle(PrimitiveInfo *,const PointInfo,const PointInfo,
-    PointInfo),
-  TraceSquareLinecap(PrimitiveInfo *,const unsigned long,const double);
+  DestroyPolygonInfo(void *polygon_info_void);
 \f
 /*
+  Ticket #515 showed how an excessively big DrawInfo::stroke_width can cause writes
+  beyond the end of an array of points when computing a stroked polygon.  So we want
+  to clamp it to some reasonable value before using it in computations.  The value
+  sqrt(2)*max(width,height) will always be >= the diagonal size of any image.  The
+  computed upper limit will be twice this value.  Note that 1.415 is just slightly
+  bigger than sqrt(2).
+*/
+
+#define STROKE_WIDTH_LIMIT(image) ((2.0*1.415) * Max((image)->columns,(image)->rows))
+
+/*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
 %                                                                             %
@@ -244,20 +328,23 @@ CloneDrawInfo(const ImageInfo *image_info,const DrawInfo *draw_info)
 
       for (x=0; draw_info->dash_pattern[x] != 0.0; x++);
       clone_info->dash_pattern=
-       MagickAllocateArray(double *,(x+1),sizeof(double));
+        MagickAllocateArray(double *,(x+1),sizeof(double));
       if (clone_info->dash_pattern == (double *) NULL)
         MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
           UnableToAllocateDashPattern);
       (void) memcpy(clone_info->dash_pattern,draw_info->dash_pattern,
         (x+1)*sizeof(double));
     }
-  if (draw_info->clip_path != (char *) NULL)
-    clone_info->clip_path=AllocateString(draw_info->clip_path);
+  if (draw_info->extra->clip_path != (char *) NULL)
+    clone_info->extra->clip_path=AllocateString(draw_info->extra->clip_path);
+  if (draw_info->extra->composite_path != (char *) NULL)
+    clone_info->extra->composite_path=AllocateString(draw_info->extra->composite_path);
   clone_info->bounds=draw_info->bounds;
   clone_info->clip_units=draw_info->clip_units;
   clone_info->render=draw_info->render;
   clone_info->opacity=draw_info->opacity;
   clone_info->element_reference=draw_info->element_reference;
+  clone_info->flags=draw_info->flags;   /* contains SVG compliance bit, etc. */
   return(clone_info);
 }
 \f
@@ -296,30 +383,139 @@ CloneDrawInfo(const ImageInfo *image_info,const DrawInfo *draw_info)
 extern "C" {
 #endif
 
+/*
+  Ticket #562: Inconsistent results from qsort callback.
+
+  NOTE: The right-handed coordinate system is: x right postive, y down positive,
+  z into the plane positive.
+
+  Prior to fixing ticket #562, the compare procedure in CompareEdges() looked at the
+  first segment in each edge (edges can have multiple segments) and compared them as
+  follows:
+
+    (1) Within MagickEpsilon, the edge with the smaller starting y coordinate should come
+        first.  Otherwise:
+    (2) Within MagickEpsilon, the edge with the smaller starting x coordinate should come
+        first.  Otherwise:
+    (3) As indicated by the cross product v0 X v1, the edge that rotates counter-clockwise
+        (as viewed) into the other edge through the smaller angle between them should come
+        first.  I.e., if v0 X v1 is negative, v0 should come first.
+
+  This procedure fails to properly differentiate between parallel and anti-parallel edges
+  whose starting x and y coordinates are within MagickEpsilon of each other (the cross
+  product of such edges is zero).  For these cases, the result for (v0,v1) says v0 comes
+  first, but the result for (v1,v0) says v1 comes first (the problem reported by ticket #562).
+
+  It's unclear to me why the x and y coordinate comparisons should use MagickEpsilon, but to
+  avoid changing existing behavior this part of the code has not been changed.
+
+  The new compare procedure is as follows:
+
+    (1) Within MagickEpsilon, the edge with the smaller starting y coordinate should come
+        first (UNCHANGED).  Otherwise:
+    (2) Within MagickEpsilon, the edge with the smaller starting x coordinate should come
+        first (UNCHANGED).  Otherwise:
+    (3) As indicated by the cross product v0 X v1, the edge that rotates counter-clockwise
+        (as viewed) into the other edge through the smaller angle between them should come
+        first AS LONG AS THE ANGLE BETWEEN THEM IS NON-ZERO.  I.e., if v0 X v1 is STRICTLY
+        NEGATIVE, v0 should come first.  If v0 X v1 IS STRICTLY POSITIVE, v1 should come
+        first.  Otherwise:
+    (4) (If we get here, the edges are either parallel or anti-parallel, but their starting
+        points may or may not be identical.)  The edge with the smaller starting y coordinate
+        should come first (DO NOT use MagickEpsilon).  Otherwise:
+    (5) The edge with the smaller starting x coordinate should come first (DO NOT use
+        MagickEpsilon).  Otherwise:
+    (6) (If we get here, the edges starting points are identical) The edge with the smaller
+        ending y coordinate should come first.  Otherwise:
+    (7) The edge with the smaller ending x coordinate should come first.  Otherwise:
+    (8) The edges are identical with respect to their first segments; return 0 to indicate
+        this.  Note that previously CompareEdges() never returned a 0.
+
+  While it may seem that steps 4 - 8 are a lot of additional code, note that this code will
+  be executed very infrequently, since most cases will be resolved by steps 1 - 3.
+
+  The new code subtracts the two coordinate values and then compares the result to +/- MagickEpsilon.
+  When using finite precision floating point arithmetic, this computation is numerically more
+  accurate that adding +/- MagickEpsilon to one coordinate and then comparing that result to
+  the other coordinate.
+*/
+
 static int
-CompareEdges(const void *x,const void *y)
+CompareEdges(const void *edge0,const void *edge1)
 {
-  register const EdgeInfo
-    *p,
-    *q;
+  register const PointInfo
+    *v0Points,
+    *v1Points;
+
+  double
+    v0CROSSv1,
+    v0x0,
+    v0y0,
+    v1x0,
+    v1y0,
+    DeltaYStart,
+    DeltaXStart,
+    DeltaYEnd,
+    DeltaXEnd,
+    NegMagickEpsilon = -MagickEpsilon;
 
   /*
     Compare two edges.
   */
-  p=(const EdgeInfo *) x;
-  q=(const EdgeInfo *) y;
-  if ((p->points[0].y-MagickEpsilon) > q->points[0].y)
-    return(1);
-  if ((p->points[0].y+MagickEpsilon) < q->points[0].y)
-    return(-1);
-  if ((p->points[0].x-MagickEpsilon) > q->points[0].x)
-    return(1);
-  if ((p->points[0].x+MagickEpsilon) < q->points[0].x)
-    return(-1);
-  if (((p->points[1].x-p->points[0].x)*(q->points[1].y-q->points[0].y)-
-       (p->points[1].y-p->points[0].y)*(q->points[1].x-q->points[0].x)) > 0.0)
-    return(1);
+  v0Points=((const EdgeInfo *) edge0)->points;
+  v1Points=((const EdgeInfo *) edge1)->points;
+
+  /* (1) the edge with the smaller starting y coordinate should come first */
+  DeltaYStart = (v0y0 = v0Points[0].y) - (v1y0 = v1Points[0].y);
+  if  ( DeltaYStart < NegMagickEpsilon )
+    return(-1);  /* v0y0 + epsi < v1y0 */
+  if  ( DeltaYStart > MagickEpsilon )
+    return(1);  /* v0y0 - epsi > v1y0 */
+
+  /* y start coordinates are the same within MagickEpsilon */
+
+  /* (2) the edge with the smaller starting x coordinate should come first */
+  DeltaXStart = (v0x0 = v0Points[0].x) - (v1x0 = v1Points[0].x);
+  if  ( DeltaXStart < NegMagickEpsilon )
+    return(-1);  /* v0x0 + epsi < v1x0 */
+  if  ( DeltaXStart > MagickEpsilon )
+    return(1);  /* v0x0 - epsi > v1x0 */
+
+  /* y and x start coordinates are the same within MagickEpsilon */
+
+  /* compute cross product v0 X v1 */
+  v0CROSSv1 = (v0Points[1].x-v0x0)*(v1Points[1].y-v1y0)-(v0Points[1].y-v0y0)*(v1Points[1].x-v1x0);
+
+  /* (3) the edge that rotates ccwise through the smaller angle between them should come first */
+  if  ( v0CROSSv1 < 0.0 )
   return(-1);
+  if  ( v0CROSSv1 > 0.0 )
+    return(1);
+
+  /* edges are either parallel or anti-parallel; check (4) y and (5) x start coords again w/o MagickEpsilon */
+  if  ( DeltaYStart < 0.0 )
+    return(-1);  /* v0y0 < v1y0 */
+  if  ( DeltaYStart > 0.0 )
+    return(1);  /* v0y0 > v1y0 */
+  if  ( DeltaXStart < 0.0 )
+    return(-1);  /* v0x0 < v1x0 */
+  if  ( DeltaXStart > 0.0 )
+    return(1);  /* v0x0 > v1x0 */
+
+  /* starting points are the same; compare (6) y and (7) x ending points */
+  DeltaYEnd = v0Points[1].y - v1Points[1].y;
+  if  ( DeltaYEnd < 0.0 )
+    return(-1);  /* v0y1 < v1y1 */
+  if  ( DeltaYEnd > 0.0 )
+    return(1);  /* v0y1 > v1y1 */
+  DeltaXEnd = v0Points[1].x - v1Points[1].x;
+  if  ( DeltaXEnd < 0.0 )
+    return(-1);  /* v0x1 < v1x1 */
+  if  ( DeltaXEnd > 0.0 )
+    return(1);  /* v0x1 > v1x1 */
+
+  /* (8) the edges are identical with respect to their first segments */
+  return(0);
 }
 
 #if defined(__cplusplus) || defined(c_plusplus)
@@ -470,7 +666,7 @@ ConvertPathToPolygon(const PathInfo *path_info)
           {
             number_points=16;
             points=
-             MagickAllocateArray(PointInfo *,number_points,sizeof(PointInfo));
+              MagickAllocateArray(PointInfo *,number_points,sizeof(PointInfo));
             if (points == (PointInfo *) NULL)
               {
                 DestroyPolygonInfo(polygon_info);
@@ -523,7 +719,7 @@ ConvertPathToPolygon(const PathInfo *path_info)
         polygon_info->edges[edge].bounds.y2=points[n-1].y;
         number_points=16;
         points=
-         MagickAllocateArray(PointInfo *,number_points,sizeof(PointInfo));
+          MagickAllocateArray(PointInfo *,number_points,sizeof(PointInfo));
         if (points == (PointInfo *) NULL)
           {
             DestroyPolygonInfo(polygon_info);
@@ -657,16 +853,22 @@ ConvertPrimitiveToPath(const DrawInfo *draw_info,
     code;
 
   PointInfo
-    p,
-    q;
+    p,  /* first point in subpath (i.e., just did a "moveto" to this point) */
+    q;  /* previous point in subpath */
 
-  register long
+  register size_t
     i,
     n;
 
-  long
-    coordinates,
-    start;
+  size_t
+    path_info_elem, /* Number of elements in path_info */
+    start;        /* index to start of subpath in path_info */
+
+  ssize_t
+    coordinates;  /* number of points in subpath */
+
+  MagickBool
+    IsClosedSubPath;
 
   ARG_NOT_USED(draw_info);
 
@@ -685,7 +887,8 @@ ConvertPrimitiveToPath(const DrawInfo *draw_info,
       break;
   }
   for (i=0; primitive_info[i].primitive != UndefinedPrimitive; i++);
-  path_info=MagickAllocateArray(PathInfo *,(2*i+3),sizeof(PathInfo));
+  path_info_elem=(2*i+6);
+  path_info=MagickAllocateArray(PathInfo *,path_info_elem,sizeof(PathInfo));
   if (path_info == (PathInfo *) NULL)
     return((PathInfo *) NULL);
   coordinates=0;
@@ -700,31 +903,55 @@ ConvertPrimitiveToPath(const DrawInfo *draw_info,
     code=LineToCode;
     if (coordinates <= 0)
       {
+        /* start of a new subpath */
         coordinates=(long) primitive_info[i].coordinates;
-        p=primitive_info[i].point;
-        start=n;
+        p=primitive_info[i].point;  /* first point in subpath */
+        start=n;  /* index to start of subpath in path_info */
         code=MoveToCode;
+        IsClosedSubPath=PRIMINF_GET_IS_CLOSED_SUBPATH(&primitive_info[i]);
       }
     coordinates--;
     /*
-      Eliminate duplicate points.
+      Do not put the current point into path_info if it is a duplicate of
+      (i.e. "too close" to) the previous point.  However, the current point
+      is always put into path_info when it is the first (code==MoveToCode)
+      or last point in a subpath.  Note that for the first point the "previous
+      point" (q) is not valid (usually a leftover from the previous subpath),
+      so the first point test should be done first.  W.r.t. the last point,
+      sometimes eliminating the last point as a "duplicate" will result in a
+      polygon (path) not being completely closed, causing small "nubs" to
+      protrude from the filled shape at that point.
     */
-    if ((i == 0) || (fabs(q.x-primitive_info[i].point.x) > MagickEpsilon) ||
+    if ((code == MoveToCode) || (coordinates <= 0) ||
+        (fabs(q.x-primitive_info[i].point.x) > MagickEpsilon) ||
         (fabs(q.y-primitive_info[i].point.y) > MagickEpsilon))
       {
+        /* put current point into path_info*/
         path_info[n].code=code;
         path_info[n].point=primitive_info[i].point;
-        q=primitive_info[i].point;
+        q=primitive_info[i].point;  /* will be "previous point" for next iteration */
         n++;
+        if (n == path_info_elem - 1)
+          break;
       }
     if (coordinates > 0)
-      continue;
-    if ((fabs(p.x-primitive_info[i].point.x) <= MagickEpsilon) &&
-        (fabs(p.y-primitive_info[i].point.y) <= MagickEpsilon))
-      continue;
+      continue;   /* go process next point in current subpath */
     /*
-      Mark the p point as open if it does not match the q.
+      The current point is the last point in the subpath.  If it closes
+      the subpath, go on to the next subpath.
     */
+    if  ( IsClosedSubPath )
+      {
+        IsClosedSubPath = MagickFalse;
+        continue;
+      }
+    /*
+      The just completed subpath is not closed.  Mark it as "open" and add two
+      more points (repeat of current point + subpath start point) to "virtually"
+      close it (this is a "ghost line").
+    */
+    if ((start >= path_info_elem - 3) || (n >= path_info_elem - 3))
+      break;
     path_info[start].code=OpenCode;
     path_info[n].code=GhostlineCode;
     path_info[n].point=primitive_info[i].point;
@@ -785,7 +1012,9 @@ DestroyDrawInfo(DrawInfo *draw_info)
   MagickFreeMemory(draw_info->density);
   MagickFreeMemory(draw_info->server_name);
   MagickFreeMemory(draw_info->dash_pattern);
-  MagickFreeMemory(draw_info->clip_path);
+  MagickFreeMemory(draw_info->extra->clip_path);
+  MagickFreeMemory(draw_info->extra->composite_path);
+  MagickFreeMemory(draw_info->extra);
   (void) memset((void *)draw_info,0xbf,sizeof(DrawInfo));
   MagickFreeMemory(draw_info);
 }
@@ -1138,7 +1367,7 @@ DrawAffineImage(Image *image,const Image *composite,
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for schedule(static) shared(row_count, status)
+#    pragma omp parallel for schedule(guided) shared(row_count, status)
 #  endif
 #endif
   for (y=y_min; y <= y_max; y++)
@@ -1159,9 +1388,6 @@ DrawAffineImage(Image *image,const Image *composite,
       register long
         x;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_DrawAffineImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -1194,31 +1420,40 @@ DrawAffineImage(Image *image,const Image *composite,
 
               point.x=x*inverse_affine.sx+y*inverse_affine.ry+inverse_affine.tx;
               point.y=x*inverse_affine.rx+y*inverse_affine.sy+inverse_affine.ty;
-             InterpolateViewColor(AccessDefaultCacheView(composite),&pixel,
-                                  point.x,
-                                  point.y,
-                                  &image->exception);
+              if (InterpolateViewColor(AccessDefaultCacheView(composite),
+                                       &pixel,
+                                       point.x,
+                                       point.y,
+                                       &image->exception) == MagickFail)
+                {
+                  thread_status=MagickFail;
+                  break;
+                }
               if (!composite->matte)
                 pixel.opacity=OpaqueOpacity;
               AlphaCompositePixel(q,&pixel,pixel.opacity,q,q->opacity);
               q++;
             }
-          if (!SyncImagePixelsEx(image,&image->exception))
-            thread_status=MagickFail;
+          if (thread_status != MagickFail)
+            if (!SyncImagePixelsEx(image,&image->exception))
+              thread_status=MagickFail;
         }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_DrawAffineImage)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,y_max-y_min+1))
-          if (!MagickMonitorFormatted(row_count,y_max-y_min+1,&image->exception,
-                                      AffineDrawImageText,image->filename))
-            thread_status=MagickFail;
+      row_count++;
+      if (QuantumTick(row_count,y_max-y_min+1))
+        if (!MagickMonitorFormatted(row_count,y_max-y_min+1,&image->exception,
+                                    AffineDrawImageText,image->filename))
+          thread_status=MagickFail;
 
-        if (thread_status == MagickFail)
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
 
   return (status);
@@ -1253,7 +1488,7 @@ DrawAffineImage(Image *image,const Image *composite,
 %
 %
 */
-static void
+static MagickPassFail
 DrawBoundingRectangles(Image *image,const DrawInfo *draw_info,
                        const PolygonInfo *polygon_info)
 {
@@ -1261,7 +1496,8 @@ DrawBoundingRectangles(Image *image,const DrawInfo *draw_info,
     *clone_info;
 
   double
-    mid;
+    mid,
+    stroke_width_limited;
 
   PointInfo
     end,
@@ -1280,8 +1516,13 @@ DrawBoundingRectangles(Image *image,const DrawInfo *draw_info,
   long
     coordinates;
 
+  MagickPassFail
+    status = MagickPass;
+
+  memset(primitive_info,0,sizeof(primitive_info));
   clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
-  (void) QueryColorDatabase("#000000ff",&clone_info->fill,&image->exception);
+  if ((status=QueryColorDatabase("#000000ff",&clone_info->fill,&image->exception)) == MagickFail)
+    goto draw_bounding_rectangles_end;
   resolution.x=72.0;
   resolution.y=72.0;
   if (clone_info->density != (char *) NULL)
@@ -1293,8 +1534,13 @@ DrawBoundingRectangles(Image *image,const DrawInfo *draw_info,
       if (count != 2)
         resolution.y=resolution.x;
     }
+
+  /* sanity check for excessively big stroke_width (ticket #515) */
+  if  ( (stroke_width_limited = STROKE_WIDTH_LIMIT(image)) > clone_info->stroke_width )
+      stroke_width_limited = clone_info->stroke_width;
+
   mid=(resolution.x/72.0)*ExpandAffine(&clone_info->affine)*
-    clone_info->stroke_width/2.0;
+    stroke_width_limited/2.0;
   bounds.x1=0.0;
   bounds.y1=0.0;
   bounds.x2=0.0;
@@ -1328,35 +1574,51 @@ DrawBoundingRectangles(Image *image,const DrawInfo *draw_info,
       for (i=0; i < polygon_info->number_edges; i++)
       {
         if (polygon_info->edges[i].direction)
-          (void) QueryColorDatabase("red",&clone_info->stroke,
-            &image->exception);
+          {
+          if ((status=QueryColorDatabase("red",&clone_info->stroke,
+                                         &image->exception)) == MagickFail)
+            goto draw_bounding_rectangles_end;
+          }
         else
-          (void) QueryColorDatabase("green",&clone_info->stroke,
-            &image->exception);
+          {
+            if ((status=QueryColorDatabase("green",&clone_info->stroke,
+                                           &image->exception)) == MagickFail)
+              goto draw_bounding_rectangles_end;
+          }
         start.x=polygon_info->edges[i].bounds.x1-mid;
         start.y=polygon_info->edges[i].bounds.y1-mid;
         end.x=polygon_info->edges[i].bounds.x2+mid;
         end.y=polygon_info->edges[i].bounds.y2+mid;
         primitive_info[0].primitive=RectanglePrimitive;
-        TraceRectangle(primitive_info,start,end);
+        if ((status=TraceRectangle(primitive_info,start,end)) == MagickFail)
+          goto draw_bounding_rectangles_end;
         primitive_info[0].method=ReplaceMethod;
         coordinates=(long) primitive_info[0].coordinates;
         primitive_info[coordinates].primitive=UndefinedPrimitive;
-        (void) DrawPrimitive(image,clone_info,primitive_info);
+        if ((status=DrawPrimitive(image,clone_info,primitive_info)) == MagickFail)
+          goto draw_bounding_rectangles_end;
       }
     }
-  (void) QueryColorDatabase("blue",&clone_info->stroke,&image->exception);
+  if ((status=QueryColorDatabase("blue",&clone_info->stroke,&image->exception)) == MagickFail)
+    goto draw_bounding_rectangles_end;
   start.x=bounds.x1-mid;
   start.y=bounds.y1-mid;
   end.x=bounds.x2+mid;
   end.y=bounds.y2+mid;
   primitive_info[0].primitive=RectanglePrimitive;
-  TraceRectangle(primitive_info,start,end);
+  if ((status=TraceRectangle(primitive_info,start,end)) == MagickFail)
+    goto draw_bounding_rectangles_end;
   primitive_info[0].method=ReplaceMethod;
   coordinates=(long) primitive_info[0].coordinates;
   primitive_info[coordinates].primitive=UndefinedPrimitive;
-  (void) DrawPrimitive(image,clone_info,primitive_info);
+  if ((status=DrawPrimitive(image,clone_info,primitive_info)) == MagickFail)
+    goto draw_bounding_rectangles_end;
+
+ draw_bounding_rectangles_end:;
+
   DestroyDrawInfo(clone_info);
+
+  return status;
 }
 \f
 /*
@@ -1397,19 +1659,28 @@ DrawClipPath(Image *image,const DrawInfo *draw_info, const char *name)
     *attribute;
 
   DrawInfo
-    *clone_info;
+    *clone_info = (DrawInfo *) NULL;
 
   MagickPassFail
     status=MagickPass;
 
+  Image
+    *image_clip_mask;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   assert(draw_info != (const DrawInfo *) NULL);
   FormatString(clip_path,"[%.1024s]",name);
   attribute=GetImageAttribute(image,clip_path);
+  /*
+    FIXME: Desired error handling for missing clip-path attribute is
+    not clear (was returning MagickFail).  Maybe the caller does not
+    know.
+  */
   if (attribute == (ImageAttribute *) NULL)
-    return(MagickFail);
-  if (image->clip_mask == (Image *) NULL)
+    return(MagickPass);
+  image_clip_mask = *ImageGetClipMask(image);
+  if (image_clip_mask == (Image *) NULL)
     {
       Image
         *clip_mask;
@@ -1418,25 +1689,184 @@ DrawClipPath(Image *image,const DrawInfo *draw_info, const char *name)
         &image->exception);
       if (clip_mask == (Image *) NULL)
         return(MagickFail);
-      (void) SetImageClipMask(image,clip_mask);
+      status=SetImageClipMask(image,clip_mask);
       DestroyImage(clip_mask);
+      if (status == MagickFail)
+        return(MagickFail);
+      image_clip_mask = *ImageGetClipMask(image);
     }
-  (void) QueryColorDatabase("none",&image->clip_mask->background_color,
-    &image->exception);
-  (void) SetImage(image->clip_mask,TransparentOpacity);
+  else
+    {
+      /*
+        Re-clone the image attributes, since more may have been added since
+        the clip_mask image was created.
+      */
+      DestroyImageAttributes(image_clip_mask);
+      CloneImageAttributes(image_clip_mask,image);
+    }
+  if ((status=QueryColorDatabase("none",&image_clip_mask->background_color,
+                                 &image->exception)) == MagickFail)
+    goto draw_clip_path_end;
+  if ((status=SetImage(image_clip_mask,TransparentOpacity)) == MagickFail)
+    goto draw_clip_path_end;
   (void) LogMagickEvent(RenderEvent,GetMagickModule(),
-    "\nbegin clip-path %.1024s",draw_info->clip_path);
+    "\nbegin clip-path %.1024s",draw_info->extra->clip_path);
   clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
-  (void) CloneString(&clone_info->primitive,attribute->value);
-  (void) QueryColorDatabase("white",&clone_info->fill,&image->exception);
-  MagickFreeMemory(clone_info->clip_path);
-  status&=DrawImage(image->clip_mask,clone_info);
-  status&=NegateImage(image->clip_mask,False);
-  DestroyDrawInfo(clone_info);
+  if ((status=CloneString(&clone_info->primitive,attribute->value)) == MagickFail)
+    goto draw_clip_path_end;
+  if ((status=QueryColorDatabase("white",&clone_info->fill,&image->exception)) == MagickFail)
+    goto draw_clip_path_end;
+
+  /*
+    According to the SVG spec:
+
+    The raw geometry of each child element exclusive of rendering properties such
+    as ‘fill’, ‘stroke’, ‘stroke-width’ within a ‘clipPath’ conceptually defines a
+    1-bit mask (with the possible exception of anti-aliasing along the edge of the
+    geometry) which represents the silhouette of the graphics associated with that
+    element.  Anything outside the outline of the object is masked out.
+
+    To conform with the spec, we make sure that fill color (set above), stroke color,
+    stroke width, and group/global opacity are set to appropriate values.
+  */
+  SetDrawInfoClippingPath(clone_info,MagickTrue);
+  if  ( IsDrawInfoSVGCompliant(clone_info) )
+    {
+      /* changes to fill, etc. will be ignored */
+      if ((status=QueryColorDatabase("none",
+                                     &clone_info->stroke,&image->exception))  /* SVG default */
+          == MagickFail)
+        {
+          goto draw_clip_path_end;
+        }
+      clone_info->stroke_width = 0.0;   /* SVG default */
+      clone_info->opacity = OpaqueOpacity;  /* SVG default */
+    }
+
+  MagickFreeMemory(clone_info->extra->clip_path);
+  if ((status=DrawImage(image_clip_mask,clone_info)) == MagickFail)
+    goto draw_clip_path_end;
+  if ((status=NegateImage(image_clip_mask,False)) == MagickFail)
+    goto draw_clip_path_end;
+
+ draw_clip_path_end:
+
+  if (clone_info != (DrawInfo *) NULL)
+    {
+      MagickFreeMemory(clone_info->extra->clip_path);
+      DestroyDrawInfo(clone_info);
+      clone_info = (DrawInfo *) NULL;
+    }
+
   (void) LogMagickEvent(RenderEvent,GetMagickModule(),"end clip-path");
   return(status);
 }
-\f
+
+/* code below for DrawCompositeMask() cloned/modifed from DrawClipMask() */
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   D r a w C o m p o s i t e M a s k                                                   %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  DrawCompositeMask() draws the composite mask on the image mask.
+%
+%  The format of the DrawCompositeMask method is:
+%
+%      MagickPassFail DrawCompositeMask(Image *image,const DrawInfo *draw_info,
+%        const char *name)
+%
+%  A description of each parameter follows:
+%
+%    o image: The image.
+%
+%    o draw_info: The draw info.
+%
+%    o name: The name of the composite mask.
+%
+%
+*/
+MagickExport MagickPassFail
+DrawCompositeMask(Image *image,const DrawInfo *draw_info, const char *name)
+{
+  char
+    composite_path[MaxTextExtent];
+
+  const ImageAttribute
+    *attribute;
+
+  DrawInfo
+    *clone_info = (DrawInfo *) NULL;
+
+  MagickPassFail
+    status=MagickPass;
+
+  Image
+    *image_composite_mask;
+
+  assert(image != (Image *) NULL);
+  assert(image->signature == MagickSignature);
+  assert(draw_info != (const DrawInfo *) NULL);
+  FormatString(composite_path,"[%.1024s]",name);
+  attribute=GetImageAttribute(image,composite_path);
+  if (attribute == (ImageAttribute *) NULL)
+    return(MagickFail);
+  image_composite_mask = *ImageGetCompositeMask(image);
+  if (image_composite_mask == (Image *) NULL)
+    {
+      Image
+        *composite_mask;
+
+      composite_mask=CloneImage(image,image->columns,image->rows,MagickTrue,
+        &image->exception);
+      if (composite_mask == (Image *) NULL)
+        return(MagickFail);
+      status=SetImageCompositeMask(image,composite_mask);
+      DestroyImage(composite_mask);
+      image_composite_mask = *ImageGetCompositeMask(image);
+      if (status == MagickFail)
+        return(MagickFail);
+    }
+  else
+    {
+      /*
+        Re-clone the image attributes, since more may have been added since
+        the composite_mask image was created.
+      */
+      DestroyImageAttributes(image_composite_mask);
+      CloneImageAttributes(image_composite_mask,image);
+    }
+  if ((status=QueryColorDatabase("none",&image_composite_mask->background_color,
+                                 &image->exception)) == MagickFail)
+    goto draw_composite_mask_end;
+  if ((status=SetImage(image_composite_mask,TransparentOpacity)) == MagickFail)
+    goto draw_composite_mask_end;
+  (void) LogMagickEvent(RenderEvent,GetMagickModule(),
+    "\nbegin mask %.1024s",draw_info->extra->composite_path);
+  clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
+  if ((status=CloneString(&clone_info->primitive,attribute->value)) == MagickFail)
+    goto draw_composite_mask_end;
+  /* these settings are per the SVG spec */
+  if ((status=QueryColorDatabase("black",&clone_info->fill,&image->exception)) == MagickFail)
+    goto draw_composite_mask_end;
+  if ((status=QueryColorDatabase("none",&clone_info->stroke,&image->exception)) == MagickFail)
+    goto draw_composite_mask_end;
+  clone_info->stroke_width = 1.0;
+  clone_info->opacity = OpaqueOpacity;
+  if ((status=DrawImage(image_composite_mask,clone_info)) == MagickFail)
+    goto draw_composite_mask_end;
+ draw_composite_mask_end:;
+  DestroyDrawInfo(clone_info);
+  (void) LogMagickEvent(RenderEvent,GetMagickModule(),"end composite-path");
+  return(status);
+}
+
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
@@ -1509,8 +1939,8 @@ DrawDashPolygon(const DrawInfo *draw_info,const PrimitiveInfo *primitive_info,
   for (i=0; primitive_info[i].primitive != UndefinedPrimitive; i++);
   number_vertices=i;
   dash_polygon=MagickAllocateArray(PrimitiveInfo *,
-                                  (size_t) 2*number_vertices+1,
-                                  sizeof(PrimitiveInfo));
+                                   (size_t) 2*number_vertices+1,
+                                   sizeof(PrimitiveInfo));
   if (dash_polygon == (PrimitiveInfo *) NULL)
     {
       DestroyDrawInfo(clone_info);
@@ -1556,7 +1986,7 @@ DrawDashPolygon(const DrawInfo *draw_info,const PrimitiveInfo *primitive_info,
         if (draw_info->dash_pattern[n] == 0.0)
           n=0;
         length=scale*draw_info->dash_pattern[n];
-      }
+      }  /* oss-fuzz 10614 maximum_length = 2120554, length = 0.5 yeilds 4,241,108 iterations*/
     for (total_length=0.0; (length >= 0.0) && (maximum_length >= (length+total_length)); )
     {
       total_length+=length;
@@ -1571,8 +2001,8 @@ DrawDashPolygon(const DrawInfo *draw_info,const PrimitiveInfo *primitive_info,
         }
       else
         {
-         if (j+1 > number_vertices)
-           break;
+          if (j+1 > number_vertices)
+            break;
           dash_polygon[j]=primitive_info[i-1];
           dash_polygon[j].point.x=primitive_info[i-1].point.x+
             dx*total_length/maximum_length;
@@ -1652,10 +2082,11 @@ IsPoint(const char *point)
   char
     *p;
 
-  long
+  double
     value;
 
-  value=strtol(point,&p,10);
+  /* check for a floating-point (vs. integer) value so .25 will not be rejected */
+  value=strtod(point,&p);
   (void) value;
   return(p != point);
 }
@@ -1680,6 +2111,7 @@ static void DrawImageSetCurrentRecurseLevel(Image *image,const long recurse_leve
     recursion_str[MaxTextExtent];
 
   FormatString(recursion_str,"%ld",recurse_level);
+  /* SetImageAttribute concatenates values! Delete with NULL */
   (void) SetImageAttribute(image,recursion_key,NULL);
   (void) SetImageAttribute(image,recursion_key,recursion_str);
 }
@@ -1692,7 +2124,7 @@ static MagickPassFail DrawImageRecurseIn(Image *image)
   recurse_level++;
   DrawImageSetCurrentRecurseLevel(image,recurse_level);
 
-  if ((recurse_level < 0) || (recurse_level > 100))
+  if ((recurse_level < 0) || (recurse_level > MAX_DRAWIMAGE_RECURSION))
     {
       char
         recursion_str[MaxTextExtent];
@@ -1714,70 +2146,299 @@ static void DrawImageRecurseOut(Image *image)
   DrawImageSetCurrentRecurseLevel(image,recurse_level);
 }
 
-MagickExport MagickPassFail
-DrawImage(Image *image,const DrawInfo *draw_info)
-{
-#define RenderImageText "[%s] Render..."
-
-  AffineMatrix
-    affine,
-    current;
 
+/*
+  Code from DrawImage() that extracted tokens between push/pop clip-path
+  and added them as an attribute has been refactored into new function
+  ExtractTokensBetweenPushPop().  Added to support new elements "use" and
+  "class".
+*/
+static
+char *  ExtractTokensBetweenPushPop (
+  char * q,                 /* address of pointer into primitive string */
+  char * token,             /* big enough buffer for extracted string */
+  size_t token_max_length,
+  char const * pop_string,  /* stop when we see pop pop_string */
+  Image *image,
+  size_t * pExtractedLength /* if not null, length of extracted string returned */
+  )
+{/*ExtractTokensBetweenPushPop*/
+
+  char const * p;
+  char * pAfterPopString = 0;
   char
-    key[2*MaxTextExtent],
-    keyword[MaxTextExtent],
-    geometry[MaxTextExtent],
-    name[MaxTextExtent],
-    pattern[MaxTextExtent],
-    *primitive,
-    *q,
-    *token;
+    name[MaxTextExtent];
+  size_t ExtractedLength = 0;
 
-  double
-    angle,
-    factor,
-    points_length,
-    primitive_extent;
+  /* next token is name associated with push/pop data */
+  MagickGetToken(q,&q,token,token_max_length);
+  FormatString(name,"[%.1024s]",token);
 
-  DrawInfo
-    **graphic_context;
+  /* search for "pop <pop_string>" */
+  for (p=q; *q != '\0'; )
+    {
+      char * qStart = q;
+      MagickGetToken(q,&q,token,token_max_length);
+      if  ( q == qStart )
+        {
+          /* infinite loop detection */
+          pAfterPopString = q;  /* need this to be valid */
+          break;
+        }
+      if (LocaleCompare(token,"pop") == 0)
+        {
+          MagickGetToken(q,&pAfterPopString,token,token_max_length);
+          if (LocaleCompare(token,pop_string) == 0)
+            break;  /* found "pop <pop_string>" */
+        }
+    }
 
-  long
-    j,
-    k,
-    n;
+  /* sanity check on extracted string length */
+  if  ( q > (p+4U) )
+    {
+      ExtractedLength = q - (p+4U);
+      (void) strncpy(token,p,ExtractedLength);
+    }
+  token[ExtractedLength] = '\0';
+  /* SetImageAttribute concatenates values! Delete with NULL */
+  (void) SetImageAttribute(image,name,NULL);
+  (void) SetImageAttribute(image,name,token);
+  if (pAfterPopString != NULL)
+    q = pAfterPopString;  /* skip ID string after "pop" */
+  if  ( pExtractedLength )
+    *pExtractedLength = ExtractedLength;
+  return(q);
 
-  PointInfo
-    point;
+}/*ExtractTokensBetweenPushPop*/
 
-  PixelPacket
-    start_color;
 
-  PrimitiveInfo
-    *primitive_info;
+/*
+  Extract attribute name from input stream, get attribute, and insert it's
+  value into the input stream.  Return updated pointer into input stream.
+  Added to support new elements "use" and "class".
+*/
+static
+char * InsertAttributeIntoInputStream (
+  char * q,                   /* address of pointer into primitive string*/
+  char ** pprimitive,         /* ptr to ptr to primitive string buffer */
+  size_t * pprimitive_extent,
+  char ** ptoken,             /* ptr to ptr to big enough buffer for extracted string */
+  size_t * ptoken_max_length,
+  Image *image,
+  MagickPassFail * pStatus,
+  MagickBool UndefAttrIsError
+  )
+{/*InsertAttributeIntoInputStream*/
+
+  char AttributeName[MaxTextExtent];
+  const ImageAttribute *attribute;
+  size_t AttributeLength;
+  size_t RemainingLength;
+  size_t NeededLength;
+
+  /* get attribute name, then get attribute value */
+  if (MagickGetToken(q,&q,*ptoken,*ptoken_max_length) < 1)
+    {
+      *pStatus = MagickFail;
+      return(q);
+    }
+  FormatString(AttributeName,"[%.1024s]",*ptoken);
+  attribute=GetImageAttribute(image,AttributeName);
+  if (attribute == (ImageAttribute *) NULL)
+    {
+      /* the client specifies whether or not an undefined attributes is an error */
+      if  ( UndefAttrIsError )
+        *pStatus = MagickFail;
+      return(q);
+    }
 
-  PrimitiveType
-    primitive_type;
+  /*
+    Insert attribute->value into input stream by concatenating it with the remainder
+    of the primitive, and updating the required state variables.
+  */
+  AttributeLength = attribute->length;
+  RemainingLength = *pprimitive_extent - (size_t)(q - *pprimitive);
+  NeededLength = AttributeLength + RemainingLength;
 
-  register char
-    *p;
+  if  ( NeededLength <= *pprimitive_extent )
+    {/*combined strings fit in existing primitive buffer*/
 
-  register long
-    i,
-    x;
+      q -= AttributeLength;
+      memcpy(q,attribute->value,AttributeLength);
+
+    }/*combined strings fit in existing primitive buffer*/
+  else
+    {/*combined strings need bigger buffer*/
+
+      char * primitiveNew;
+      *pprimitive_extent = NeededLength;
+      primitiveNew = MagickAllocateMemory(char *,NeededLength+1);
+      if (primitiveNew == (char *) NULL)
+        {
+          *pStatus = MagickFail;
+          return(q);
+        }
+      (void) memcpy(primitiveNew,attribute->value,AttributeLength);
+      (void) memcpy(primitiveNew+AttributeLength,q,RemainingLength);
+      primitiveNew[NeededLength] = '\0';
+
+      MagickFreeMemory(*pprimitive);
+      q = *pprimitive = primitiveNew;
+      MagickFreeMemory(*ptoken);
+      *ptoken = MagickAllocateMemory(char *,NeededLength+1);
+      *ptoken_max_length = NeededLength;
+
+    }/*combined strings need bigger buffer*/
+
+  return(q);
+
+}/*InsertAttributeIntoInputStream*/
+
+
+/*
+  Re-allocate PrimitiveInfo array if needed.  Return MagickFail if
+  allocation has failed.  PrimitiveInfo array pointer is set to NULL
+  if allocation has failed, and any already allocated memory is freed.
+*/
+static MagickPassFail
+PrimitiveInfoRealloc(PrimitiveInfoMgr * p_PIMgr, const size_t Needed)
+{/*PrimitiveInfoRealloc*/
+
+  MagickPassFail status = MagickPass;
+  /* grow the PrimitiveInfo array if Needed elements are not available; return true if reallocated */
+
+  /* ANSI C says that SIZE_MAX gives maximum value of size_t */
+  size_t NeedAllocCount = p_PIMgr->StoreStartingAt + Needed + ((size_t)100);  /* +100 for headroom */
+  if (NeedAllocCount > *p_PIMgr->p_AllocCount)
+    {
+      const size_t have_memory=MagickArraySize(*p_PIMgr->p_AllocCount,sizeof(PrimitiveInfo));
+      const size_t needed_memory=MagickArraySize(NeedAllocCount,sizeof(PrimitiveInfo));
+      const magick_uint64_t added_memory=needed_memory-have_memory;
+
+      /* Need to realloc */
+      if (((*p_PIMgr->p_AllocCount > 0) && (have_memory == 0)) ||
+          ((NeedAllocCount > 0) && (needed_memory == 0)) ||
+          (status=AcquireMagickResource(MemoryResource,added_memory)) == MagickFail)
+        {
+          ThrowException3(p_PIMgr->p_Exception,ResourceLimitError,MemoryAllocationFailed,UnableToDrawOnImage);
+          status = MagickFail;
+        }
+      else
+        {
+          MagickReallocMemory(PrimitiveInfo *,*p_PIMgr->pp_PrimitiveInfo,needed_memory);
+          if (*p_PIMgr->pp_PrimitiveInfo == (PrimitiveInfo *) NULL)
+            {
+              ThrowException3(p_PIMgr->p_Exception,ResourceLimitError,MemoryAllocationFailed,UnableToDrawOnImage);
+              status = MagickFail;
+              /* Record that the memory was unexpectedly released */
+              LiberateMagickResource(MemoryResource,(*p_PIMgr->p_AllocCount)*sizeof(PrimitiveInfo));
+            }
+          else
+            {
+              *p_PIMgr->p_AllocCount = NeedAllocCount;
+            }
+        }
+    }
+
+  return status;
+
+}/*PrimitiveInfoRealloc*/
+
+
+MagickExport MagickPassFail
+DrawImage(Image *image,const DrawInfo *draw_info)
+{
+#define RenderImageText "[%s] Render..."
+
+  AffineMatrix
+    affine,
+    current;
+
+  char
+    key[2*MaxTextExtent],
+    keyword[MaxTextExtent],
+    geometry[MaxTextExtent],
+    name[MaxTextExtent],
+    pattern[MaxTextExtent],
+    *primitive,
+    *q,
+    *token;
+
+  double
+    angle,
+    factor,
+    points_length;  /* primitive_extent is now a size_t */
+
+  DrawInfo
+    **graphic_context;
+
+  long
+    j,
+    k,
+    n;
+
+  PointInfo
+    point;
+
+  PixelPacket
+    start_color;
+
+  PrimitiveInfo
+    *primitive_info = (PrimitiveInfo *) NULL;
+
+  PrimitiveType
+    primitive_type;
+
+  register char
+    *p;
+
+  register long
+    i,
+    x;
 
   SegmentInfo
     bounds;
 
   size_t
     length,
-    token_max_length;
+    token_max_length,
+    primitive_extent;
 
   MagickPassFail
     status;
 
   size_t
-    number_points;
+    number_points=0;
+
+  MagickBool
+    FillOpacityPending,
+    StrokeOpacityPending;
+
+  double
+    FillOpacitySaved,
+    StrokeOpacitySaved;
+
+  MagickBool
+    TextRotationPerformed;  /* see comments below where TextRotationPerformed=MagickFalse */
+
+  /*
+    Use defsPushCount to track when we enter/leave <defs> ... </defs> so we
+    know not to render any graphical elements defined within (per the SVG spec).
+    This is accomplished by turning off the "render" flag in the graphics
+    context if defsPushCount > 0.
+  */
+  int
+    defsPushCount;
+
+  /* These variables are used to track the current text position */
+  double
+    xTextCurrent,
+    yTextCurrent;
+  MagickBool
+    UseCurrentTextPosition;     /* true=>use (possibly modified) current text position */
+
+  PrimitiveInfoMgr
+    PIMgr;
 
   /*
     Ensure the annotation info is valid.
@@ -1804,6 +2465,9 @@ DrawImage(Image *image,const DrawInfo *draw_info)
   if (primitive == (char *) NULL)
     return(MagickFail);
   primitive_extent=strlen(primitive);
+
+  /* SetImageAttribute concatenates values! Delete with NULL */
+  (void) SetImageAttribute(image,"[MVG]",NULL);
   (void) SetImageAttribute(image,"[MVG]",primitive);
   if (getenv("MAGICK_SKIP_RENDERING") != NULL)
     {
@@ -1821,26 +2485,79 @@ DrawImage(Image *image,const DrawInfo *draw_info)
       ThrowBinaryException3(ResourceLimitError,MemoryAllocationFailed,
         UnableToDrawOnImage)
     }
-  number_points=6553;
-  primitive_info=
-    MagickAllocateArray(PrimitiveInfo *,number_points,sizeof(PrimitiveInfo));
-  if (primitive_info == (PrimitiveInfo *) NULL)
+
+  /* Set up to manage growing the PrimitiveInfo array */
+  PIMgr.pp_PrimitiveInfo = &primitive_info;
+  PIMgr.p_AllocCount = &number_points;
+  PIMgr.StoreStartingAt = 0;
+  PIMgr.p_Exception = &image->exception;
+
+  if ((status=PrimitiveInfoRealloc(&PIMgr,6553)) == MagickFail)
     {
       MagickFreeMemory(primitive);
       for ( ; n >= 0; n--)
         DestroyDrawInfo(graphic_context[n]);
       MagickFreeMemory(graphic_context);
-      ThrowBinaryException3(ResourceLimitError,MemoryAllocationFailed,
-        UnableToDrawOnImage)
+      return MagickFail;
     }
+
   graphic_context[n]=CloneDrawInfo((ImageInfo *) NULL,draw_info);
-  token=AllocateString(primitive);
-  token_max_length=strlen(token);
+  /* next two lines: don't need copy of primitive, just a buffer of the same size */
+  token=MagickAllocateMemory(char *,primitive_extent+1);
+  token_max_length=primitive_extent;
   (void) QueryColorDatabase("black",&start_color,&image->exception);
   (void) SetImageType(image,TrueColorType);
   status=MagickPass;
+  defsPushCount = 0;  /* not inside of <defs> ... </defs> */
+  xTextCurrent = yTextCurrent = 0.0;  /* initialize current text position */
+  /*
+    The purpose of these next four variables is to attempt to handle cases like:
+
+    <rect stroke-opacity="0.5" stroke="green" ... />
+
+    I.e., when the stroke-opacity is set before the stroke color is specified (ditto
+    for fill-opacity and fill color).  This creates a problem when the current stroke
+    color is "none" (the typical inherited default).  A value of "none" causes the
+    stroke color to be set to transparent black, wiping out any current stroke-opacity
+    information.  Furthermore, as long as the stroke color is "none", any attempt to
+    set the stroke-opacity will be ignored.  I have not tested this, but I believe the
+    same condition can be arrived at by setting stroke="black" and stroke-opacity="0".
+
+    The real solution to this problem is to store the stroke="none" state without
+    affecting the current stroke-opacity value.  This would require additional data
+    structure members and code modifications, so for now we handle this situation
+    by remembering when there is a pending stroke-opacity request (same for
+    fill-opacity).  When the stroke (fill) color is eventually set, the pending
+    opacity value is also set.
+
+    The "pending" flags are reset to false whenever a graphic-context is pushed or
+    popped, so this fix may only solve a limited set of cases.  However, these cases
+    just happen to be the most common ones.
+  */
+  FillOpacityPending = MagickFalse;
+  StrokeOpacityPending = MagickFalse;
+  FillOpacitySaved = 0.0;
+  StrokeOpacitySaved = 0.0;
+
+  /*
+    When DrawImage() was modified to provide management of the current text position to
+    the client, text rotation also had to be modified.  Previously, the client would
+    perform text rotation (i.e., next character is to be rotated) by supplying the following
+    sequence:
+
+      translate x y (where x, y indicate the current text position)
+      rotate angle (where angle is the rotation angle)
+
+    Later, when the actual 'text x y string' is supplied by the client, x and y must both
+    be zero since the positioning has already been taken care of by the translate/rotate
+    sequence.  The next variable indicates that rotation is being applied so that we can
+    use (0,0) instead of the actual current text position.
+  */
+  TextRotationPerformed = MagickFalse;
+
   for (q=primitive; *q != '\0'; )
   {
+    UseCurrentTextPosition = False;
     /*
       Interpret graphic primitive.
     */
@@ -1942,6 +2659,12 @@ DrawImage(Image *image,const DrawInfo *draw_info)
       case 'c':
       case 'C':
       {
+        if (LocaleCompare("class",keyword) == 0)
+          {/*class*/
+            q = InsertAttributeIntoInputStream(q,&primitive,&primitive_extent,&token,&token_max_length,image,
+              &status,MagickFalse/*UndefAttrIsError*/);
+            break;
+          }/*class*/
         if (LocaleCompare("clip-path",keyword) == 0)
           {
             /*
@@ -1952,9 +2675,10 @@ DrawImage(Image *image,const DrawInfo *draw_info)
                 status=MagickFail;
                 break;
               }
-            (void) CloneString(&graphic_context[n]->clip_path,token);
-            (void) DrawClipPath(image,graphic_context[n],
-              graphic_context[n]->clip_path);
+            (void) CloneString(&graphic_context[n]->extra->clip_path,token);
+            if (DrawClipPath(image,graphic_context[n],
+                             graphic_context[n]->extra->clip_path) == MagickFail)
+              status=MagickFail;
             break;
           }
         if (LocaleCompare("clip-rule",keyword) == 0)
@@ -2066,15 +2790,35 @@ DrawImage(Image *image,const DrawInfo *draw_info)
         if (LocaleCompare("fill",keyword) == 0)
           {
             MagickGetToken(q,&q,token,token_max_length);
+            if  ( IsDrawInfoSVGCompliantClippingPath(graphic_context[n]) )
+              break;    /* if drawing clip path, ignore changes to fill color */
             FormatString(pattern,"[%.1024s]",token);
-            if (GetImageAttribute(image,pattern) == (ImageAttribute *) NULL)
-              (void) QueryColorDatabase(token,&graphic_context[n]->fill,
-                &image->exception);
-            else
+            if (GetImageAttribute(image,pattern) != (ImageAttribute *) NULL)
               (void) DrawPatternPath(image,draw_info,token,
                 &graphic_context[n]->fill_pattern);
-            if (graphic_context[n]->fill.opacity != TransparentOpacity)
-              graphic_context[n]->fill.opacity=graphic_context[n]->opacity;
+            else
+              {/*fill color, not pattern*/
+
+                /* when setting new fill color, try to preserve fill-opacity */
+                Quantum FillOpacityOld = graphic_context[n]->fill.opacity;
+                (void) QueryColorDatabase(token,&graphic_context[n]->fill,&image->exception);
+
+                if (graphic_context[n]->fill.opacity != TransparentOpacity)
+                  {/*new fill color != 'none'*/
+
+                    if  ( FillOpacityOld != TransparentOpacity )
+                      graphic_context[n]->fill.opacity = FillOpacityOld;  /* already has group opacity included */
+                    else  /* combine fill color's opacity with group opacity per SVG spec */
+                      {
+                        Quantum FillOpacity = FillOpacityPending ?
+                          MaxRGB - (Quantum) (MaxRGBDouble * FillOpacitySaved + 0.5) : graphic_context[n]->fill.opacity;
+                        graphic_context[n]->fill.opacity = MaxRGB - (Quantum)((double)(MaxRGB - FillOpacity) * (double)(MaxRGB - graphic_context[n]->opacity) / MaxRGBDouble + 0.5);
+                      }
+                    FillOpacityPending = MagickFalse;
+
+                  }/*new fill color != 'none'*/
+
+              }/*fill color, not pattern*/
             break;
           }
         if (LocaleCompare("fill-rule",keyword) == 0)
@@ -2095,20 +2839,32 @@ DrawImage(Image *image,const DrawInfo *draw_info)
           }
         if (LocaleCompare("fill-opacity",keyword) == 0)
           {
+            double opacity;
             MagickGetToken(q,&q,token,token_max_length);
+            if  ( IsDrawInfoSVGCompliantClippingPath(graphic_context[n]) )
+              break;    /* if drawing clip path, ignore changes to fill opacity */
             factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
+            if ((MagickAtoFChk(token,&opacity) != MagickPass) ||
+                (opacity < 0.0))
+              {
+                status=MagickFail;
+                break;
+              }
+            opacity *= factor;
+            if  ( opacity <= 0.0 )   /* per SVG spec */
+              opacity = 0.0;
+            else if  ( opacity > 1.0 )
+              opacity = 1.0;
+            FillOpacitySaved = opacity;
             if (graphic_context[n]->fill.opacity != TransparentOpacity)
               {
-                double opacity;
-                if ((MagickAtoFChk(token,&opacity) != MagickPass) ||
-                    (opacity < 0.0))
-                  {
-                    status=MagickFail;
-                    break;
-                  }
-                graphic_context[n]->fill.opacity=(Quantum)
-                  ((double) MaxRGB*(1.0-factor*opacity));
+                /* combine new fill-opacity with group opacity per SVG spec */
+                double opacityGroup = MaxRGB - graphic_context[n]->opacity; /* MaxRGB==opaque */
+                graphic_context[n]->fill.opacity = MaxRGB - (Quantum)(opacity * opacityGroup + 0.5);
+                FillOpacityPending = MagickFalse;
               }
+            else
+              FillOpacityPending = MagickTrue;
             break;
           }
         if (LocaleCompare("font",keyword) == 0)
@@ -2214,9 +2970,9 @@ DrawImage(Image *image,const DrawInfo *draw_info)
         if (LocaleCompare("gravity",keyword) == 0)
           {
             MagickGetToken(q,&q,token,token_max_length);
-           graphic_context[n]->gravity=StringToGravityType(token);
-           if (ForgetGravity != graphic_context[n]->gravity)
-             break;
+            graphic_context[n]->gravity=StringToGravityType(token);
+            if (ForgetGravity != graphic_context[n]->gravity)
+              break;
             status=MagickFail;
             break;
           }
@@ -2252,6 +3008,20 @@ DrawImage(Image *image,const DrawInfo *draw_info)
       case 'm':
       case 'M':
       {
+          if (LocaleCompare("mask",keyword) == 0)   /* added mask */
+            {
+              /*
+                Create mask.
+              */
+              if (MagickGetToken(q,&q,token,token_max_length) < 1)
+                {
+                  status=MagickFail;
+                  break;
+                }
+              (void) CloneString(&graphic_context[n]->extra->composite_path,token);
+              (void) DrawCompositeMask(image,graphic_context[n],graphic_context[n]->extra->composite_path);
+              break;
+            }
         if (LocaleCompare("matte",keyword) == 0)
           {
             primitive_type=MattePrimitive;
@@ -2270,18 +3040,55 @@ DrawImage(Image *image,const DrawInfo *draw_info)
           }
         if (LocaleCompare("opacity",keyword) == 0)
           {
-            double opacity;
+            double opacity,opacityGroupOld,opacityGroupNew;
             MagickGetToken(q,&q,token,token_max_length);
+            if  ( IsDrawInfoSVGCompliantClippingPath(graphic_context[n]) )
+              break;    /* if drawing clip path, ignore changes to group/global opacity */
             factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
             if (MagickAtoFChk(token,&opacity) != MagickPass)
               {
                 status=MagickFail;
                 break;
               }
-            graphic_context[n]->opacity=(Quantum) ((double) MaxRGB*(1.0-((1.0-
-              graphic_context[n]->opacity/MaxRGB)*factor*opacity))+0.5);
-            graphic_context[n]->fill.opacity=graphic_context[n]->opacity;
-            graphic_context[n]->stroke.opacity=graphic_context[n]->opacity;
+            opacity *= factor;
+            if  ( opacity <= 0.0 )  /* per SVG spec */
+              opacity = 0.0;
+            else if ( opacity > 1.0 )
+              opacity = 1.0;
+            opacityGroupOld = MaxRGB - graphic_context[n]->opacity; /* MaxRGB==opaque */
+            opacityGroupNew = opacityGroupOld * opacity; /* MaxRGB==opaque */
+            graphic_context[n]->opacity = MaxRGB - (Quantum)(opacityGroupNew + /*round*/0.5);
+            if (graphic_context[n]->fill.opacity != TransparentOpacity)
+            {/*fill color != 'none'*/
+
+              if  ( opacityGroupOld == 0.0 )  /* can't back out old group opacity */
+                graphic_context[n]->fill.opacity = graphic_context[n]->opacity; /* reasonable alternative */
+              else
+              {
+                /* back out old group opacity value, include new group opacity value */
+                double opacityFill = MaxRGB - graphic_context[n]->fill.opacity; /* MaxRGB==opaque */
+                opacityFill = opacityFill * (opacityGroupNew / opacityGroupOld);
+                graphic_context[n]->fill.opacity =
+                  (opacityFill < MaxRGBDouble) ? MaxRGB - (Quantum)(opacityFill + /*round*/0.5) : 0;
+              }
+
+            }/*fill color != 'none'*/
+
+            if (graphic_context[n]->stroke.opacity != TransparentOpacity)
+            {/*stroke color != 'none'*/
+
+              if  ( opacityGroupOld == 0.0 ) /* can't back out old group opacity */
+                graphic_context[n]->stroke.opacity = graphic_context[n]->opacity; /* reasonable alternative */
+              else
+              {
+                /* back out old group opacity value, include new group opacity value */
+                double opacityStroke = MaxRGB - graphic_context[n]->stroke.opacity; /* MaxRGB==opaque */
+                opacityStroke = opacityStroke * (opacityGroupNew / opacityGroupOld);
+                graphic_context[n]->stroke.opacity =
+                  (opacityStroke < MaxRGBDouble) ? MaxRGB - (Quantum)(opacityStroke + /*round*/0.5) : 0;
+              }
+
+            }/*stroke color != 'none'*/
             break;
           }
         status=MagickFail;
@@ -2313,10 +3120,17 @@ DrawImage(Image *image,const DrawInfo *draw_info)
         if (LocaleCompare("pop",keyword) == 0)
           {
             MagickGetToken(q,&q,token,token_max_length);
+            if (LocaleCompare("class",token) == 0)  /* added "pop class" to support "defs" */
+              break;
             if (LocaleCompare("clip-path",token) == 0)
               break;
             if (LocaleCompare("defs",token) == 0)
-              break;
+              {
+                /* do not render graphic elements if inside <defs> ... </defs> */
+                defsPushCount--;
+                graphic_context[n]->render = (defsPushCount > 0) ? 0 : 1;
+                break;
+              }
             if (LocaleCompare("gradient",token) == 0)
               break;
             if (LocaleCompare("graphic-context",token) == 0)
@@ -2327,14 +3141,26 @@ DrawImage(Image *image,const DrawInfo *draw_info)
                     status=MagickFail;
                     break;
                   }
-                if (graphic_context[n]->clip_path != (char *) NULL)
-                  if (LocaleCompare(graphic_context[n]->clip_path,
-                      graphic_context[n-1]->clip_path) != 0)
+                if (graphic_context[n]->extra->clip_path != (char *) NULL)
+                  if (LocaleCompare(graphic_context[n]->extra->clip_path,
+                      graphic_context[n-1]->extra->clip_path) != 0)
                     (void) SetImageClipMask(image,(Image *) NULL);
+                if (graphic_context[n]->extra->composite_path != (char *) NULL)
+                  {
+                    /* clean up composite mask if different from parent */
+                    if (LocaleCompare(graphic_context[n]->extra->composite_path,
+                        graphic_context[n-1]->extra->composite_path) != 0)
+                      (void) SetImageCompositeMask(image,(Image *) NULL);
+                  }
                 DestroyDrawInfo(graphic_context[n]);
                 n--;
+                FillOpacityPending = StrokeOpacityPending = MagickFalse;
                 break;
               }
+            if (LocaleCompare("id",token) == 0)   /* added "pop id" (to support "defs") */
+              break;
+            if (LocaleCompare("mask",token) == 0)   /* added mask */
+              break;
             if (LocaleCompare("pattern",token) == 0)
               break;
             status=MagickFail;
@@ -2343,27 +3169,21 @@ DrawImage(Image *image,const DrawInfo *draw_info)
         if (LocaleCompare("push",keyword) == 0)
           {
             MagickGetToken(q,&q,token,token_max_length);
+            if (LocaleCompare("class",token) == 0)  /* added "push class" to support "defs" */
+              {
+                q = ExtractTokensBetweenPushPop(q,token,token_max_length,"class",image,0);
+                break;
+              }
             if (LocaleCompare("clip-path",token) == 0)
               {
-                char
-                  name[MaxTextExtent];
-
-                MagickGetToken(q,&q,token,token_max_length);
-                FormatString(name,"[%.1024s]",token);
-                for (p=q; *q != '\0'; )
-                {
-                  MagickGetToken(q,&q,token,token_max_length);
-                  if (LocaleCompare(token,"pop") != 0)
-                    continue;
-                  MagickGetToken(q,(char **) NULL,token,token_max_length);
-                  if (LocaleCompare(token,"clip-path") != 0)
-                    continue;
-                  break;
-                }
-                (void) strncpy(token,p,q-p-4);
-                token[q-p-4]='\0';
-                (void) SetImageAttribute(image,name,token);
-                MagickGetToken(q,&q,token,token_max_length);
+                /*
+                  Code that extracted tokens between push/pop clip-path has been refactored
+                  into new function ExtractTokensBetweenPushPop().
+                */
+                size_t ExtractedLength;
+                q = ExtractTokensBetweenPushPop(q,token,token_max_length,"clip-path",image,&ExtractedLength); /* NULLED */
+                if  ( ExtractedLength == 0 )
+                  status=MagickFail;
                 break;
               }
             if (LocaleCompare("gradient",token) == 0)
@@ -2433,6 +3253,11 @@ DrawImage(Image *image,const DrawInfo *draw_info)
                     continue;
                   break;
                 }
+                if ((q == NULL) || (p == NULL) || (q-4 < p))
+                  {
+                    status=MagickFail;
+                    break;
+                  }
                 (void) strncpy(token,p,q-p-4);
                 token[q-p-4]='\0';
                 bounds.x1=graphic_context[n]->affine.sx*segment.x1+
@@ -2499,16 +3324,36 @@ DrawImage(Image *image,const DrawInfo *draw_info)
                     break;
                   }
                 FormatString(key,"[%.1024s]",name);
+                /* SetImageAttribute concatenates values! Delete with NULL */
+                (void) SetImageAttribute(image,key,NULL);
                 (void) SetImageAttribute(image,key,token);
                 FormatString(key,"[%.1024s-geometry]",name);
                 FormatString(geometry,"%gx%g%+g%+g",
                   Max(AbsoluteValue(bounds.x2-bounds.x1+1),1),
                   Max(AbsoluteValue(bounds.y2-bounds.y1+1),1),
                   bounds.x1,bounds.y1);
+                /* SetImageAttribute concatenates values! Delete with NULL */
+                (void) SetImageAttribute(image,key,NULL);
                 (void) SetImageAttribute(image,key,geometry);
                 MagickGetToken(q,&q,token,token_max_length);
                 break;
               }
+            if (LocaleCompare("id",token) == 0)   /* added "push id" (to support "defs") */
+              {
+                if  ( defsPushCount > 0 )
+                  q = ExtractTokensBetweenPushPop(q,token,token_max_length,"id",image,0);
+                else    /* extract <identifier> from "push id <identifier>" */
+                  MagickGetToken(q,&q,token,token_max_length);
+                break;
+              }
+            if (LocaleCompare("mask",token) == 0)   /* added mask */
+              {
+                size_t ExtractedLength;
+                q = ExtractTokensBetweenPushPop(q,token,token_max_length,"mask",image,&ExtractedLength);
+                if  ( ExtractedLength == 0 )
+                  status=MagickFail;
+                break;
+              }
             if (LocaleCompare("pattern",token) == 0)
               {
                 double
@@ -2564,13 +3409,22 @@ DrawImage(Image *image,const DrawInfo *draw_info)
                     continue;
                   break;
                 }
+                if ((q == NULL) || (p == NULL) || (q-4 < p))
+                  {
+                    status=MagickFail;
+                    break;
+                  }
                 (void) strncpy(token,p,q-p-4);
                 token[q-p-4]='\0';
                 FormatString(key,"[%.1024s]",name);
+                /* SetImageAttribute concatenates values! Delete with NULL */
+                (void) SetImageAttribute(image,key,NULL);
                 (void) SetImageAttribute(image,key,token);
                 FormatString(key,"[%.1024s-geometry]",name);
                 FormatString(geometry,"%lux%lu%+ld%+ld",bounds.width,
                   bounds.height,bounds.x,bounds.y);
+                /* SetImageAttribute concatenates values! Delete with NULL */
+                (void) SetImageAttribute(image,key,NULL);
                 (void) SetImageAttribute(image,key,geometry);
                 MagickGetToken(q,&q,token,token_max_length);
                 break;
@@ -2588,10 +3442,16 @@ DrawImage(Image *image,const DrawInfo *draw_info)
                   }
                 graphic_context[n]=
                   CloneDrawInfo((ImageInfo *) NULL,graphic_context[n-1]);
+                FillOpacityPending = StrokeOpacityPending = MagickFalse;
                 break;
               }
             if (LocaleCompare("defs",token) == 0)
-              break;
+              {
+                /* do not render graphic elements if inside <defs> ... </defs> */
+                defsPushCount++;
+                graphic_context[n]->render = (defsPushCount > 0) ? 0 : 1;
+                break;
+              }
             status=MagickFail;
             break;
           }
@@ -2683,15 +3543,34 @@ DrawImage(Image *image,const DrawInfo *draw_info)
         if (LocaleCompare("stroke",keyword) == 0)
           {
             MagickGetToken(q,&q,token,token_max_length);
+            if  ( IsDrawInfoSVGCompliantClippingPath(graphic_context[n]) )
+              break;    /* if drawing clip path, ignore changes to stroke color */
             FormatString(pattern,"[%.1024s]",token);
-            if (GetImageAttribute(image,pattern) == (ImageAttribute *) NULL)
-              (void) QueryColorDatabase(token,&graphic_context[n]->stroke,
-                &image->exception);
-            else
+            if (GetImageAttribute(image,pattern) != (ImageAttribute *) NULL)
               (void) DrawPatternPath(image,draw_info,token,
                 &graphic_context[n]->stroke_pattern);
-            if (graphic_context[n]->stroke.opacity != TransparentOpacity)
-              graphic_context[n]->stroke.opacity=graphic_context[n]->opacity;
+            else
+              {/*stroke color, not pattern*/
+
+                /* when setting new stroke color, try to preserve stroke-opacity */
+                Quantum StrokeOpacityOld = graphic_context[n]->stroke.opacity;
+                (void) QueryColorDatabase(token,&graphic_context[n]->stroke,&image->exception);
+
+                if (graphic_context[n]->stroke.opacity != TransparentOpacity)
+                  {/*stroke color != 'none'*/
+
+                    if  ( StrokeOpacityOld != TransparentOpacity )
+                      graphic_context[n]->stroke.opacity = StrokeOpacityOld;  /* already has group opacity included */
+                    else  /* combine stroke color's opacity with group opacity per SVG spec */
+                    {
+                      Quantum StrokeOpacity = StrokeOpacityPending ? MaxRGB - (Quantum) (MaxRGBDouble * StrokeOpacitySaved + 0.5) : graphic_context[n]->stroke.opacity;
+                      graphic_context[n]->stroke.opacity = MaxRGB - (Quantum)((double)(MaxRGB - StrokeOpacity) * (double)(MaxRGB - graphic_context[n]->opacity) / MaxRGBDouble + 0.5);
+                    }
+                    StrokeOpacityPending = MagickFalse;
+
+                  }/*stroke color != 'none'*/
+
+              }/*stroke color, not pattern*/
             break;
           }
         if (LocaleCompare("stroke-antialias",keyword) == 0)
@@ -2723,7 +3602,7 @@ DrawImage(Image *image,const DrawInfo *draw_info)
                     MagickGetToken(p,&p,token,token_max_length);
                 }
                 graphic_context[n]->dash_pattern=
-                 MagickAllocateArray(double *,(2*x+1),sizeof(double));
+                  MagickAllocateArray(double *,(2*x+2),sizeof(double));
                 if (graphic_context[n]->dash_pattern == (double *) NULL)
                   {
                     status=MagickFail;
@@ -2816,31 +3695,58 @@ DrawImage(Image *image,const DrawInfo *draw_info)
           }
         if (LocaleCompare("stroke-opacity",keyword) == 0)
           {
+            double opacity;
             MagickGetToken(q,&q,token,token_max_length);
+            if  ( IsDrawInfoSVGCompliantClippingPath(graphic_context[n]) )
+              break;    /* if drawing clip path, ignore changes to stroke opacity */
             factor=strchr(token,'%') != (char *) NULL ? 0.01 : 1.0;
+            if ((MagickAtoFChk(token,&opacity) != MagickPass) ||
+                opacity < 0.0)
+              {
+                status=MagickFail;
+                break;
+              }
+            opacity *= factor;
+            if  ( opacity <= 0.0 )  /* per SVG spec */
+              opacity = 0.0;
+            else if  ( opacity > 1.0 )
+              opacity = 1.0;
+            StrokeOpacitySaved = opacity;
             if (graphic_context[n]->stroke.opacity != TransparentOpacity)
               {
-                double opacity;
-                if ((MagickAtoFChk(token,&opacity) != MagickPass) ||
-                    opacity < 0.0)
-                  {
-                    status=MagickFail;
-                    break;
-                  }
-                graphic_context[n]->stroke.opacity=(Quantum)
-                  ((double) MaxRGB*(1.0-factor*opacity));
+                /* combine new stroke-opacity with group opacity per SVG spec */
+                double opacityGroup = MaxRGB - graphic_context[n]->opacity;
+                graphic_context[n]->stroke.opacity = MaxRGB - (Quantum)(opacity * opacityGroup + 0.5);
+                StrokeOpacityPending = MagickFalse;
               }
+            else
+              StrokeOpacityPending = MagickTrue;
             break;
           }
         if (LocaleCompare("stroke-width",keyword) == 0)
           {
             MagickGetToken(q,&q,token,token_max_length);
+            if  ( IsDrawInfoSVGCompliantClippingPath(graphic_context[n]) )
+              break;    /* if drawing clip path, ignore changes to stroke width */
             if ((MagickAtoFChk(token,&graphic_context[n]->stroke_width)
                  == MagickFail) ||
                 (graphic_context[n]->stroke_width < 0.0))
               status=MagickFail;
             break;
           }
+        if (LocaleCompare("svg-compliant",keyword) == 0)
+          {
+            /* mark the DrawInfo as being drawn SVG compliant or not */
+            unsigned int SVGCompliant;
+            MagickGetToken(q,&q,token,token_max_length);
+            if (MagickAtoUIChk(token,&SVGCompliant) != MagickPass)
+              {
+                status=MagickFail;
+              }
+            else
+              SetDrawInfoSVGCompliant(graphic_context[n],SVGCompliant?MagickTrue:MagickFalse);
+            break;
+          }
         status=MagickFail;
         break;
       }
@@ -2850,6 +3756,99 @@ DrawImage(Image *image,const DrawInfo *draw_info)
         if (LocaleCompare("text",keyword) == 0)
           {
             primitive_type=TextPrimitive;
+            UseCurrentTextPosition = MagickFalse;   /* use client-supplied text locations */
+            break;
+          }
+        if (LocaleCompare("textc",keyword) == 0)  /* draw text at current text position */
+          {
+            primitive_type=TextPrimitive;
+            UseCurrentTextPosition = MagickTrue;        /* use internally tracked text location*/
+            break;
+          }
+        if (LocaleCompare("textdx",keyword) == 0)  /* update current x position for text */
+          {/*textdx*/
+            double value;
+            MagickGetToken(q,&q,token,token_max_length);
+            (void) MagickAtoFChk(token,&value);
+            /* value may be specified using "em" or "ex" units */
+            if (LocaleNCompare(q,"em",2) == 0)
+              {
+                value *= graphic_context[n]->pointsize;
+                MagickGetToken(q,&q,token,token_max_length);    /* skip over "em" */
+              }
+            else if (LocaleNCompare(q,"ex",2) == 0)
+              {
+                value *= 0.5 * graphic_context[n]->pointsize;
+                MagickGetToken(q,&q,token,token_max_length);    /* skip over "ex" */
+              }
+            xTextCurrent += value;
+            break;
+          }/*textdx*/
+        if (LocaleCompare("textdy",keyword) == 0)  /* update current y position for text */
+          {/*textdy*/
+            double value;
+            MagickGetToken(q,&q,token,token_max_length);
+            (void) MagickAtoFChk(token,&value);
+            /* value may be specified using "em" or "ex" units */
+            if (LocaleNCompare(q,"em",2) == 0)
+              {
+                value *= graphic_context[n]->pointsize;
+                MagickGetToken(q,&q,token,token_max_length);    /* skip over "em" */
+              }
+            else if (LocaleNCompare(q,"ex",2) == 0)
+              {
+                value *= 0.5 * graphic_context[n]->pointsize;
+                MagickGetToken(q,&q,token,token_max_length);    /* skip over "ex" */
+              }
+            yTextCurrent += value;
+            break;
+          }/*textdy*/
+        /*
+          When the current text position was managed in SVGStartElement() in svg.c, and a "rotate"
+          was encountered (indicating that the text character was to be rotated), the code would
+          emit to the MVG file:
+
+            translate x y (where x, y indicate the current text position)
+            rotate angle (where angle indicates the rotation angle)
+
+          Now that the current text position is being managed by DrawImage() in render.c, the code
+          in SVGStartElement() cannot issue the "translate" because it can't know the current text
+          position.  To handle this, "textr" (text rotation) has been implemented here to perform
+          the appropriate translation/rotation sequence.
+        */
+        if (LocaleCompare("textr",keyword) == 0)  /* text rotation */
+          {/*textr*/
+            TextRotationPerformed = MagickTrue;
+            /* translate x y */
+            affine.tx = xTextCurrent;
+            affine.ty = yTextCurrent;
+            /* rotation angle */
+            MagickGetToken(q,&q,token,token_max_length);
+            if (MagickAtoFChk(token,&angle) != MagickPass)
+              {
+                status=MagickFail;
+                break;
+              }
+            affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
+            affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
+            affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
+            affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
+            break;
+          }/*textr*/
+        if (LocaleCompare("textx",keyword) == 0)  /* set current x position for text */
+          {
+            double value;
+            MagickGetToken(q,&q,token,token_max_length);
+            (void) MagickAtoFChk(token,&value);
+            xTextCurrent = value;
+            break;
+          }
+        if (LocaleCompare("texty",keyword) == 0)  /* set current y position for text */
+          {
+            double value;
+            MagickGetToken(q,&q,token,token_max_length);
+            (void) MagickAtoFChk(token,&value);
+            yTextCurrent = value;
             break;
           }
         if (LocaleCompare("text-align",keyword) == 0)
@@ -2900,6 +3899,18 @@ DrawImage(Image *image,const DrawInfo *draw_info)
         status=MagickFail;
         break;
       }
+      case 'u':
+      case 'U':
+      {
+        if (LocaleCompare("use",keyword) == 0)
+          {
+            q = InsertAttributeIntoInputStream(q,&primitive,&primitive_extent,&token,&token_max_length,image,
+              &status,MagickTrue/*UndefAttrIsError*/);
+            break;
+          }
+        status=MagickFail;
+        break;
+      }
       case 'v':
       case 'V':
       {
@@ -2949,12 +3960,13 @@ DrawImage(Image *image,const DrawInfo *draw_info)
     /*
       Parse the primitive attributes.
     */
-    i=0;
+    PIMgr.StoreStartingAt = i = 0;
     j=0;
     primitive_info[0].point.x=0.0;
     primitive_info[0].point.y=0.0;
     primitive_info[0].coordinates=0;
     primitive_info[0].method=FloodfillMethod;
+    PRIMINF_CLEAR_FLAGS(&primitive_info[0]);
     for (x=0; *q != '\0'; x++)
     {
       /*
@@ -2976,23 +3988,48 @@ DrawImage(Image *image,const DrawInfo *draw_info)
       primitive_info[i].point=point;
       primitive_info[i].coordinates=0;
       primitive_info[i].method=FloodfillMethod;
+      PRIMINF_CLEAR_FLAGS(&primitive_info[i]);
       i++;
+      PIMgr.StoreStartingAt = i;
       if (i < (long) number_points)
         continue;
-      number_points<<=1;
-      MagickReallocMemory(PrimitiveInfo *,primitive_info,
-                          MagickArraySize(number_points,sizeof(PrimitiveInfo)));
-      if (primitive_info == (PrimitiveInfo *) NULL)
-        {
-          ThrowException3(&image->exception,ResourceLimitError,
-            MemoryAllocationFailed,UnableToDrawOnImage);
-          break;
-        }
+      /* Array is full; double the array size */
+      if ((status=PrimitiveInfoRealloc(&PIMgr,number_points)) == MagickFail)
+        break;
     }
+    if (status == MagickFail)
+      break;
+    /*
+      Special handling when using textc with character rotation; see comments
+      above near "textr".
+    */
+    if  ( (primitive_type == TextPrimitive) && UseCurrentTextPosition && (i == 0) )
+      {
+        primitive_info[0].primitive=primitive_type;
+        PRIMINF_CLEAR_FLAGS(&primitive_info[0]);
+        if  ( TextRotationPerformed )
+          {
+            /* text positioning has already been performed by translate/rotate sequence */
+            primitive_info[0].point.x=0;
+            primitive_info[0].point.y=0;
+            TextRotationPerformed = MagickFalse;
+          }
+        else
+          {
+            primitive_info[0].point.x=xTextCurrent;
+            primitive_info[0].point.y=yTextCurrent;
+          }
+        primitive_info[0].coordinates=0;
+        primitive_info[0].method=FloodfillMethod;
+        i++;
+        PIMgr.StoreStartingAt = i;
+        x++;
+      }
     assert(j < (long) number_points);
     primitive_info[j].primitive=primitive_type;
     primitive_info[j].coordinates=x;
     primitive_info[j].method=FloodfillMethod;
+    PRIMINF_CLEAR_FLAGS(&primitive_info[j]);
     primitive_info[j].text=(char *) NULL;
     /*
       Circumscribe primitive within a circle.
@@ -3097,6 +4134,7 @@ DrawImage(Image *image,const DrawInfo *draw_info)
 
     if (((size_t) points_length) < points_length)
       {
+        /* points_length too big to be represented as a size_t */
         status=MagickFail;
         ThrowException(&image->exception,DrawError,
                        PrimitiveArithmeticOverflow,keyword);
@@ -3108,22 +4146,20 @@ DrawImage(Image *image,const DrawInfo *draw_info)
     if ((i+points_length) >= number_points)
       {
         double new_number_points = ceil(number_points+points_length+1);
-        if (((size_t) new_number_points) != new_number_points)
+        size_t new_number_points_size_t = (size_t) new_number_points;
+        if (new_number_points_size_t != new_number_points)
           {
+            /* new_number_points too big to be represented as a size_t */
             status=MagickFail;
             ThrowException3(&image->exception,ResourceLimitError,
                             MemoryAllocationFailed,UnableToDrawOnImage);
             break;
           }
 
-        number_points=new_number_points;
-        MagickReallocMemory(PrimitiveInfo *,primitive_info,
-                            MagickArraySize(number_points,sizeof(PrimitiveInfo)));
-        if (primitive_info == (PrimitiveInfo *) NULL)
+        PIMgr.StoreStartingAt = i;  /* should already be this value; just bein' sure */
+        if (PrimitiveInfoRealloc(&PIMgr,new_number_points_size_t-number_points) == MagickFail)
           {
             status=MagickFail;
-            ThrowException3(&image->exception,ResourceLimitError,
-              MemoryAllocationFailed,UnableToDrawOnImage);
             break;
           }
       }
@@ -3131,6 +4167,18 @@ DrawImage(Image *image,const DrawInfo *draw_info)
     assert(j < (long) number_points);
 
     /*
+      The TraceXXX funtions that generate a dynamic number of points will automatically
+      grow the primitive array as needed.  To make sure that the simpler ones (TracePoint()
+      TraceLine(), TraceRectangle(), etc.) have enough space, we make sure there are at
+      least 100 elements available.
+    */
+    if (PrimitiveInfoRealloc(&PIMgr,100) == MagickFail)
+      {
+        status=MagickFail;
+        break;
+      }
+
+    /*
       Trace points
     */
     switch (primitive_type)
@@ -3143,8 +4191,9 @@ DrawImage(Image *image,const DrawInfo *draw_info)
             status=MagickFail;
             break;
           }
-        TracePoint(primitive_info+j,primitive_info[j].point);
-        i=(long) (j+primitive_info[j].coordinates);
+        if ((status=TracePoint(primitive_info+j,primitive_info[j].point)) == MagickFail)
+          break;
+        PIMgr.StoreStartingAt=i=(long) (j+primitive_info[j].coordinates);
         break;
       }
       case LinePrimitive:
@@ -3154,9 +4203,10 @@ DrawImage(Image *image,const DrawInfo *draw_info)
             status=MagickFail;
             break;
           }
-        TraceLine(primitive_info+j,primitive_info[j].point,
-                  primitive_info[j+1].point);
-        i=(long) (j+primitive_info[j].coordinates);
+        if ((status=TraceLine(primitive_info+j,primitive_info[j].point,
+                              primitive_info[j+1].point)) == MagickFail)
+          break;
+        PIMgr.StoreStartingAt=i=(long) (j+primitive_info[j].coordinates);
         break;
       }
       case RectanglePrimitive:
@@ -3185,10 +4235,11 @@ DrawImage(Image *image,const DrawInfo *draw_info)
             status=MagickFail;
             break;
           }
-        TraceRectangle(/*start*/primitive_info+j,
-                       /*end*/primitive_info[j].point,
-          primitive_info[j+1].point);
-        i=(long) (j+primitive_info[j].coordinates);
+        if ((status=TraceRectangle(primitive_info+j,
+                                   /*start*/primitive_info[j].point,
+                                   /*end*/primitive_info[j+1].point)) == MagickFail)
+          break;
+        PIMgr.StoreStartingAt=i=(long) (j+primitive_info[j].coordinates);
         break;
       }
       case RoundRectanglePrimitive:
@@ -3225,11 +4276,13 @@ DrawImage(Image *image,const DrawInfo *draw_info)
             status=MagickFail;
             break;
           }
-        TraceRoundRectangle(primitive_info+j,
-                            /*start*/primitive_info[j].point,
-                            /*end*/primitive_info[j+1].point,
-                            /*arc*/primitive_info[j+2].point);
-        i=(long) (j+primitive_info[j].coordinates);
+        PIMgr.StoreStartingAt=j;
+        if ((status=TraceRoundRectangle(&PIMgr,
+                                        /*start*/primitive_info[j].point,
+                                        /*end*/primitive_info[j+1].point,
+                                        /*arc*/primitive_info[j+2].point)) == MagickFail)
+          break;
+         PIMgr.StoreStartingAt=i=(long) (j+primitive_info[j].coordinates);
         break;
       }
       case ArcPrimitive:
@@ -3239,9 +4292,11 @@ DrawImage(Image *image,const DrawInfo *draw_info)
             primitive_type=UndefinedPrimitive;
             break;
           }
-        TraceArc(primitive_info+j,primitive_info[j].point,
-          primitive_info[j+1].point,primitive_info[j+2].point);
-        i=(long) (j+primitive_info[j].coordinates);
+        PIMgr.StoreStartingAt=j;
+        if ((status=TraceArc(&PIMgr,primitive_info[j].point,
+                             primitive_info[j+1].point,primitive_info[j+2].point)) == MagickFail)
+          break;
+        PIMgr.StoreStartingAt=i=(long) (j+primitive_info[j].coordinates);
         break;
       }
       case EllipsePrimitive:
@@ -3260,11 +4315,13 @@ DrawImage(Image *image,const DrawInfo *draw_info)
             status=MagickFail;
             break;
           }
-        TraceEllipse(primitive_info+j,
-                     /*start*/primitive_info[j].point, /*centerX,centerY*/
-                     /*stop*/primitive_info[j+1].point, /*radiusX,radiusY*/
-                     /*degrees*/primitive_info[j+2].point); /*arcStart,arcEnd*/
-        i=(long) (j+primitive_info[j].coordinates);
+        PIMgr.StoreStartingAt=j;
+        if ((status=TraceEllipse(&PIMgr,
+                                 /*start*/primitive_info[j].point, /*centerX,centerY*/
+                                 /*stop*/primitive_info[j+1].point, /*radiusX,radiusY*/
+                                 /*degrees*/primitive_info[j+2].point)) == MagickFail) /*arcStart,arcEnd*/
+          break;
+        PIMgr.StoreStartingAt=i=(long) (j+primitive_info[j].coordinates);
         break;
       }
       case CirclePrimitive:
@@ -3274,14 +4331,17 @@ DrawImage(Image *image,const DrawInfo *draw_info)
             status=MagickFail;
             break;
           }
-       TraceCircle(primitive_info+j,primitive_info[j].point,
-          primitive_info[j+1].point);
-        i=(long) (j+primitive_info[j].coordinates);
+        PIMgr.StoreStartingAt=j;
+        if ((status=TraceCircle(&PIMgr,primitive_info[j].point,
+                                primitive_info[j+1].point)) == MagickFail)
+          break;
+        PIMgr.StoreStartingAt=i=(long) (j+primitive_info[j].coordinates);
         break;
       }
       case PolylinePrimitive:
       {
-        if (primitive_info[j].coordinates < 2)
+        /* the SVG spec does not prohibit polylines containing a single point */
+        if (primitive_info[j].coordinates < 1)
           {
             status=MagickFail;
             break;
@@ -3301,6 +4361,7 @@ DrawImage(Image *image,const DrawInfo *draw_info)
         primitive_info[i]=primitive_info[j];
         primitive_info[i].coordinates=0;
         primitive_info[j].coordinates++;
+        PRIMINF_SET_IS_CLOSED_SUBPATH(&primitive_info[j],1);
         i++;
         break;
       }
@@ -3311,13 +4372,16 @@ DrawImage(Image *image,const DrawInfo *draw_info)
             status=MagickFail;
             break;
           }
-        TraceBezier(primitive_info+j,primitive_info[j].coordinates);
-        i=(long) (j+primitive_info[j].coordinates);
+        PIMgr.StoreStartingAt=j;
+        if ((status=TraceBezier(&PIMgr,primitive_info[j].coordinates)) == MagickFail)
+          break;
+        PIMgr.StoreStartingAt=i=(long) (j+primitive_info[j].coordinates);
         break;
       }
       case PathPrimitive:
       {
-        i=(long) (j+TracePath(image,primitive_info+j,token));
+        PIMgr.StoreStartingAt=j;
+        PIMgr.StoreStartingAt=i=(long) (j+TracePath(image,&PIMgr,token));
         break;
       }
       case ColorPrimitive:
@@ -3351,6 +4415,24 @@ DrawImage(Image *image,const DrawInfo *draw_info)
         if (*token != ',')
           MagickGetToken(q,&q,token,token_max_length);
         primitive_info[j].text=AllocateString(token);
+        {/*update current text position for next time*/
+          /*
+            Clone the DrawInfo, add a blank to the end of
+            the text, get the metrics for the concatenated
+            string, and use the width to update the text
+            current x position.
+          */
+          DrawInfo * clone_info;
+          TypeMetric  metrics;
+          clone_info=CloneDrawInfo((ImageInfo *) NULL,graphic_context[n]);
+          MagickFreeMemory(clone_info->density);        /* density values already converted, don't do again! */
+          clone_info->render = 0;
+          clone_info->text=AllocateString(token);
+          (void) ConcatenateString(&clone_info->text," ");
+          (void) GetTypeMetrics(image,clone_info,&metrics);
+          xTextCurrent += metrics.width;
+          DestroyDrawInfo(clone_info);
+        }/*update current text position for next time*/
         break;
       }
       case ImagePrimitive:
@@ -3400,12 +4482,20 @@ DrawImage(Image *image,const DrawInfo *draw_info)
     }
     if (graphic_context[n]->render)
       {
-        if ((n != 0) && (graphic_context[n]->clip_path != (char *) NULL) &&
-            (LocaleCompare(graphic_context[n]->clip_path,
-             graphic_context[n-1]->clip_path) != 0))
+        if ((n != 0) && (graphic_context[n]->extra->clip_path != (char *) NULL) &&
+            (LocaleCompare(graphic_context[n]->extra->clip_path,
+             graphic_context[n-1]->extra->clip_path) != 0))
           if (DrawClipPath(image,graphic_context[n],
-                           graphic_context[n]->clip_path) == MagickFail)
+                           graphic_context[n]->extra->clip_path) == MagickFail)
             status=MagickFail;
+        if ((n != 0) && (graphic_context[n]->extra->composite_path != (char *) NULL) &&
+            (LocaleCompare(graphic_context[n]->extra->composite_path,
+            graphic_context[n-1]->extra->composite_path) != 0))
+          {
+            if (DrawCompositeMask(image,graphic_context[n],
+                graphic_context[n]->extra->composite_path) == MagickFail)
+              status=MagickFail;
+          }
         if (DrawPrimitive(image,graphic_context[n],primitive_info)
             == MagickFail)
           status=MagickFail;
@@ -3426,6 +4516,8 @@ DrawImage(Image *image,const DrawInfo *draw_info)
   */
   DrawImageRecurseOut(image);
   MagickFreeMemory(token);
+  if (primitive_info != (PrimitiveInfo *) NULL)
+    LiberateMagickResource(MemoryResource,(*PIMgr.p_AllocCount)*sizeof(PrimitiveInfo));
   MagickFreeMemory(primitive_info);
   MagickFreeMemory(primitive);
   for ( ; n >= 0; n--)
@@ -3619,29 +4711,39 @@ GetPixelOpacity(PolygonInfo * restrict polygon_info,const double mid,
         }
       /*
         Compute distance between a point and an edge.
+
+        In the comments below, let seg0, seg1 be the end points of the line
+        segment (edge), and let pt be (x,y).  Conceptually, consider the segment
+        to be a vector from seg0 to seg1, and pt to be a vector from seg0 to pt.
+        Let seglen be the length of the segment vector, and ptlen be the length
+        of the pt vector.
+
+        The "if" tests below now test "beta <= 0" instead of "beta < 0", and
+        "beta >= alpha" instead of "beta > alpha".  This captures the case of
+        a zero-length segment and avoids a divide-by-zero when computing 1/alpha.
       */
-      q=p->points+i-1;
-      dx=(q+1)->x-q->x,
-      dy=(q+1)->y-q->y;
-      beta=dx*(x-q->x)+dy*(y-q->y);
-      if (beta < 0.0)
-        {
+      q=p->points+i-1;    /* q is seg0, q+1 is seg1 */
+      dx=(q+1)->x-q->x,   /* seg1.x - seg0.x */
+      dy=(q+1)->y-q->y;   /* seg1.y - seg0.y */
+      beta=dx*(x-q->x)+dy*(y-q->y);   /* dot(segvec,ptvec) = seglen * ptlen * costheta */
+      if (beta <= 0.0)
+        {/*cosine<=0, pt is closest to seg0*/
           dx=x-q->x;
           dy=y-q->y;
           distance=dx*dx+dy*dy;
         }
       else
         {
-          alpha=dx*dx+dy*dy;
-          if (beta > alpha)
-            {
+          alpha=dx*dx+dy*dy;  /*seglen*seglen*/
+          if (beta >= alpha)
+            {/*pt is closest to seg1*/
               dx=x-(q+1)->x;
               dy=y-(q+1)->y;
               distance=dx*dx+dy*dy;
             }
           else
-            {
-              alpha=1.0/alpha;
+            {/*pt is closest to a point between seg0 and seg1*/
+              alpha=1.0/alpha;  /*don't get here if alpha==0*/
               beta=dx*(y-q->y)-dy*(x-q->x);
               distance=alpha*beta*beta;
             }
@@ -3746,16 +4848,17 @@ GetPixelOpacity(PolygonInfo * restrict polygon_info,const double mid,
 
 static MagickPassFail
 DrawPolygonPrimitive(Image *image,const DrawInfo *draw_info,
-                    const PrimitiveInfo *primitive_info)
+                     const PrimitiveInfo *primitive_info)
 {
   double
-    mid;
+    mid,
+    stroke_width_limited;
 
   SegmentInfo
     bounds;
 
   ThreadViewDataSet
-    * restrict polygon_set;
+    * restrict polygon_set = (ThreadViewDataSet *) NULL;
 
   MagickPassFail
     status = MagickPass;
@@ -3768,7 +4871,7 @@ DrawPolygonPrimitive(Image *image,const DrawInfo *draw_info,
   /*
     Nothing to do.
   */
-  if (primitive_info->coordinates == 0)
+  if (primitive_info->coordinates <= 1)   /*single point polygons have zero area; don't draw*/
     return(MagickPass);
 
   {
@@ -3781,20 +4884,19 @@ DrawPolygonPrimitive(Image *image,const DrawInfo *draw_info,
     unsigned int
       index;
 
-    polygon_set=(ThreadViewDataSet *) NULL;
     path_info=(PathInfo *) NULL;
     if ((path_info=ConvertPrimitiveToPath(draw_info,primitive_info))
         != (PathInfo *) NULL)
       {
-       if ((polygon_set=AllocateThreadViewDataSet(DestroyPolygonInfo,image,
+        if ((polygon_set=AllocateThreadViewDataSet(DestroyPolygonInfo,image,
                                                    &image->exception))
             != (ThreadViewDataSet *) NULL)
           {
             /*
               Assign polygon for each worker thread.
             */
-           for (index=0; index < GetThreadViewDataSetAllocatedViews(polygon_set); index++)
-             AssignThreadViewData(polygon_set,index,(void *) ConvertPathToPolygon(path_info));
+            for (index=0; index < GetThreadViewDataSetAllocatedViews(polygon_set); index++)
+              AssignThreadViewData(polygon_set,index,(void *) ConvertPathToPolygon(path_info));
 
             /*
               Verify worker thread allocations.
@@ -3808,7 +4910,7 @@ DrawPolygonPrimitive(Image *image,const DrawInfo *draw_info,
                 }
           }
 
-       MagickFreeMemory(path_info);
+        MagickFreeMemory(path_info);
       }
     if (polygon_set == (ThreadViewDataSet *) NULL)
       return MagickFail;
@@ -3828,35 +4930,71 @@ DrawPolygonPrimitive(Image *image,const DrawInfo *draw_info,
     bounds=polygon_info->edges[0].bounds;
 
     if (0) /* DEBUG ??? */
-      DrawBoundingRectangles(image,draw_info,polygon_info);
-    
+      if ((status=DrawBoundingRectangles(image,draw_info,polygon_info)) == MagickFail)
+        goto draw_polygon_primitive_end;
+
     for (i=1; i < polygon_info->number_edges; i++)
       {
-       register const EdgeInfo
-         *p;
-
-       p=polygon_info->edges+i;
-       if (p->bounds.x1 < bounds.x1)
-         bounds.x1=p->bounds.x1;
-       if (p->bounds.y1 < bounds.y1)
-         bounds.y1=p->bounds.y1;
-       if (p->bounds.x2 > bounds.x2)
-         bounds.x2=p->bounds.x2;
-       if (p->bounds.y2 > bounds.y2)
-         bounds.y2=p->bounds.y2;
+        register const EdgeInfo
+          *p;
+
+        p=polygon_info->edges+i;
+        if (p->bounds.x1 < bounds.x1)
+          bounds.x1=p->bounds.x1;
+        if (p->bounds.y1 < bounds.y1)
+          bounds.y1=p->bounds.y1;
+        if (p->bounds.x2 > bounds.x2)
+          bounds.x2=p->bounds.x2;
+        if (p->bounds.y2 > bounds.y2)
+          bounds.y2=p->bounds.y2;
       }
-    mid=ExpandAffine(&draw_info->affine)*draw_info->stroke_width/2.0;
+    /*
+      Modified clipping below.  Previous code was (similar for y):
+
+        if (x >= columns) x = columns-1;
+
+      Note that if columns == 50 this results in:
+
+        x==49.999 --> x=49.999
+        x==50.000 --> x=49.000
+
+      Pretty sure this was not the intention of the original
+      author.  Also, this can result in x_start > x_end, which
+      can cause the call to GetImagePixelsEx() to blow up due to
+      a column count <= 0 (see code below).
+
+      Changed the code to first check for starting bounds beyond
+      right/bottom of image, and ending bounds beyond left/top
+      of image.  When this is the case, there is nothing to do,
+      since the object lies completely outside the image.  If
+      not, clip based on columns-1 and rows-1 instead of columns
+      and rows.
+    */
+
+    /* sanity check for excessively big stroke_width (ticket #515) */
+    if  ( (stroke_width_limited = STROKE_WIDTH_LIMIT(image)) > draw_info->stroke_width )
+        stroke_width_limited = draw_info->stroke_width;
+
+    mid=ExpandAffine(&draw_info->affine)*stroke_width_limited/2.0;
     bounds.x1-=(mid+1.0);
-    bounds.x1=bounds.x1 < 0.0 ? 0.0 : bounds.x1 >= image->columns ?
-      image->columns-1 : bounds.x1;
     bounds.y1-=(mid+1.0);
-    bounds.y1=bounds.y1 < 0.0 ? 0.0 : bounds.y1 >= image->rows ?
-      image->rows-1 : bounds.y1;
     bounds.x2+=(mid+1.0);
-    bounds.x2=bounds.x2 < 0.0 ? 0.0 : bounds.x2 >= image->columns ?
-      image->columns-1 : bounds.x2;
     bounds.y2+=(mid+1.0);
-    bounds.y2=bounds.y2 < 0.0 ? 0.0 : bounds.y2 >= image->rows ?
+    if ( (bounds.x1 >= image->columns) || (bounds.y1 >= image->rows)
+         || (bounds.x2 <= 0.0) || (bounds.y2 <= 0.0) )
+      {
+        /* object completely outside image */
+        DestroyThreadViewDataSet(polygon_set);
+        polygon_set = (ThreadViewDataSet *) NULL;
+        return(MagickPass);
+      }
+    bounds.x1=bounds.x1 <= 0.0 ? 0.0 : bounds.x1 >= image->columns-1 ?
+      image->columns-1 : bounds.x1;
+    bounds.y1=bounds.y1 <= 0.0 ? 0.0 : bounds.y1 >= image->rows-1 ?
+      image->rows-1 : bounds.y1;
+    bounds.x2=bounds.x2 <= 0.0 ? 0.0 : bounds.x2 >= image->columns-1 ?
+      image->columns-1 : bounds.x2;
+    bounds.y2=bounds.y2 <= 0.0 ? 0.0 : bounds.y2 >= image->rows-1 ?
       image->rows-1 : bounds.y2;
   }
 
@@ -3868,94 +5006,91 @@ DrawPolygonPrimitive(Image *image,const DrawInfo *draw_info,
         Draw point.
       */
       long
-       x_start,
-       x_stop,
-       y_start,
-       y_stop,
-       y;
+        x_start,
+        x_stop,
+        y_start,
+        y_stop,
+        y;
 
       PixelPacket
-       stroke_color;
+        stroke_color;
 
-      stroke_color=draw_info->stroke;      
-      x_start=(long) ceil(bounds.x1-0.5);
-      x_stop=(long) floor(bounds.x2+0.5);
+      stroke_color=draw_info->stroke;
+      x_start=(long) ceil(bounds.x1-0.5);   /* rounds n.5 to n */
+      x_stop=(long) floor(bounds.x2+0.5);   /* rounds n.5 to n+1 */
       y_start=(long) ceil(bounds.y1-0.5);
       y_stop=(long) floor(bounds.y2+0.5);
 #if defined(HAVE_OPENMP)
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for schedule(runtime) shared(status)
 #  else
-#    pragma omp parallel for schedule(static) shared(status)
+#    pragma omp parallel for schedule(guided) shared(status)
 #  endif
 #endif
       for (y=y_start; y <= y_stop; y++)
-       {
-         long
-           x;
+        {
+          long
+            x;
 
-         PixelPacket
-           * restrict q;
+          PixelPacket
+            * restrict q;
 
-         MagickPassFail
-           thread_status;
+          MagickPassFail
+            thread_status;
 
+          thread_status=status;
+          if (thread_status == MagickFail)
+            continue;
+
+          x=x_start;
+          q=GetImagePixelsEx(image,x,y,x_stop-x+1,1,&image->exception);
+          if (q == (PixelPacket *) NULL)
+            thread_status=MagickFail;
+          if (thread_status != MagickFail)
+            {
+              for ( ; x <= x_stop; x++)
+                {
+                  if ((x == (long) ceil(primitive_info->point.x-0.5)) &&
+                      (y == (long) ceil(primitive_info->point.y-0.5)))
+                    *q=stroke_color;
+                  q++;
+                }
+              if (!SyncImagePixelsEx(image,&image->exception))
+                thread_status=MagickFail;
+            }
+          if (thread_status == MagickFail)
+            {
+              status=thread_status;
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_DrawPolygonPrimitive_Status)
-#endif
-         thread_status=status;
-         if (thread_status == MagickFail)
-           continue;
-
-         x=x_start;
-         q=GetImagePixelsEx(image,x,y,x_stop-x+1,1,&image->exception);
-         if (q == (PixelPacket *) NULL)
-           thread_status=MagickFail;
-         if (thread_status != MagickFail)
-           {
-             for ( ; x <= x_stop; x++)
-               {
-                 if ((x == (long) ceil(primitive_info->point.x-0.5)) &&
-                     (y == (long) ceil(primitive_info->point.y-0.5)))
-                   *q=stroke_color;
-                 q++;
-               }
-             if (!SyncImagePixelsEx(image,&image->exception))
-               thread_status=MagickFail;
-           }
-         if (thread_status == MagickFail)
-           {
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_DrawPolygonPrimitive_Status)
+#  pragma omp flush (status)
 #endif
-             status=thread_status;
-           }
-       }
+            }
+        }
     } /* if (primitive_info->coordinates == 1) */
   else
     {
       /*
-       Draw polygon or line.
+        Draw polygon or line.
       */
       long
-       x_start,
-       x_stop,
-       y_start,
-       y_stop,
-       y;
+        x_start,
+        x_stop,
+        y_start,
+        y_stop,
+        y;
 
       const Image
-       *fill_pattern=draw_info->fill_pattern,
-       *stroke_pattern=draw_info->stroke_pattern;
+        *fill_pattern=draw_info->fill_pattern,
+        *stroke_pattern=draw_info->stroke_pattern;
 
       unsigned int
-       fill;
+        fill;
 
       fill=(primitive_info->method == FillToBorderMethod) ||
-       (primitive_info->method == FloodfillMethod);
+        (primitive_info->method == FloodfillMethod);
 
-      x_start=(long) ceil(bounds.x1-0.5);
-      x_stop=(long) floor(bounds.x2+0.5);
+      x_start=(long) ceil(bounds.x1-0.5);   /* rounds n.5 to n */
+      x_stop=(long) floor(bounds.x2+0.5);   /* rounds n.5 to n+1 */
       y_start=(long) ceil(bounds.y1-0.5);
       y_stop=(long) floor(bounds.y2+0.5);
 #if 1
@@ -3968,104 +5103,136 @@ DrawPolygonPrimitive(Image *image,const DrawInfo *draw_info,
 #endif
 #endif
       for (y=y_start; y <= y_stop; y++)
-       {
-         PixelPacket
-           fill_color,
-           stroke_color;
+        {
+          PixelPacket
+            fill_color,
+            stroke_color;
 
-         double
-           fill_opacity,
-           stroke_opacity;
+          double
+            fill_opacity,
+            stroke_opacity;
 
-         long
-           x;
+          long
+            x;
 
-         PolygonInfo
-           * restrict polygon_info;
+          PolygonInfo
+            * restrict polygon_info;
 
-         PixelPacket
-           * restrict q;
+          PixelPacket
+            * restrict q;
 
-         MagickPassFail
-           thread_status;
+          MagickPassFail
+            thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_DrawPolygonPrimitive_Status)
-#endif
-         thread_status=status;
-         if (thread_status == MagickFail)
-           continue;
-
-         polygon_info=(PolygonInfo *) AccessThreadViewData(polygon_set);
-         fill_color=draw_info->fill;
-         stroke_color=draw_info->stroke;
-         x=x_start;
-         q=GetImagePixelsEx(image,x,y,x_stop-x+1,1,&image->exception);
-         if (q == (PixelPacket *) NULL)
-           thread_status=MagickFail;
-
-         if (thread_status != MagickFail)
-           {
-             for ( ; x <= x_stop; x++)
-               {
-                 /*
-                   Fill and/or stroke.
-                 */
-                 fill_opacity=GetPixelOpacity(polygon_info,mid,fill,
-                                              draw_info->fill_rule,
-                                              x,y,&stroke_opacity);
-                 if (!draw_info->stroke_antialias)
-                   {
-                     /* When stroke antialiasing is disabled, only draw for
-                        opacities >= 0.99 in order to ensure that lines are not
-                        drawn wider than requested. */
-                     if (fill_opacity < 0.99)
-                       fill_opacity=0.0;
-                     if (stroke_opacity < 0.99)
-                       stroke_opacity=0.0;
-                   }
-                 if ((fill_pattern != (Image *) NULL) &&
+          thread_status=status;
+          if (thread_status == MagickFail)
+            continue;
+
+          polygon_info=(PolygonInfo *) AccessThreadViewData(polygon_set);
+          fill_color=draw_info->fill;
+          stroke_color=draw_info->stroke;
+          x=x_start;
+          q=GetImagePixelsEx(image,x,y,x_stop-x+1,1,&image->exception);
+          if (q == (PixelPacket *) NULL)
+            thread_status=MagickFail;
+
+          if (thread_status != MagickFail)
+            {
+              for ( ; x <= x_stop; x++)
+                {
+                  /*
+                    Fill and/or stroke.  The fill_opacity returned by GetPixelOpacity()
+                    handles partial pixel coverage at the edge of a polygon, where
+                    0==no coverage and 1==full coverage
+                  */
+                  fill_opacity=GetPixelOpacity(polygon_info,mid,fill,
+                                               draw_info->fill_rule,
+                                               x,y,&stroke_opacity);
+                  if (!draw_info->stroke_antialias)
+                    {
+                      /* When stroke antialiasing is disabled, only draw for
+                         opacities >= 0.99 in order to ensure that lines are not
+                         drawn wider than requested. */
+                      if (fill_opacity < 0.99)
+                        fill_opacity=0.0;
+                      if (stroke_opacity < 0.99)
+                        stroke_opacity=0.0;
+                    }
+                  if ((fill_pattern != (Image *) NULL) &&
                       (fill_pattern->columns != 0) &&
                       (fill_pattern->rows != 0))
-                   (void) AcquireOnePixelByReference
-                     (fill_pattern,&fill_color,
-                      (long) (x-fill_pattern->tile_info.x) % fill_pattern->columns,
-                      (long) (y-fill_pattern->tile_info.y) % fill_pattern->rows,
-                      &image->exception);
-                 fill_opacity=MaxRGBDouble-fill_opacity*
-                   (MaxRGBDouble-(double) fill_color.opacity);
-                 AlphaCompositePixel(q,&fill_color,fill_opacity,q,
-                                     (q->opacity == TransparentOpacity)
-                                     ? OpaqueOpacity : q->opacity);
-                 if ((stroke_pattern != (Image *) NULL) &&
+                    {
+                      (void) AcquireOnePixelByReference
+                        (fill_pattern,&fill_color,
+                        (long) (x-fill_pattern->tile_info.x) % fill_pattern->columns,
+                        (long) (y-fill_pattern->tile_info.y) % fill_pattern->rows,
+                        &image->exception);
+                      /* apply the group opacity value to the pattern pixel */
+                      fill_color.opacity = MaxRGB-((MaxRGB-fill_color.opacity)*(MaxRGB-draw_info->opacity)+(MaxRGB>>1))/MaxRGB;
+                    }
+                  /* combine fill_opacity with the fill color's opacity */
+                  fill_opacity=MaxRGBDouble-fill_opacity*
+                    (MaxRGBDouble-(double) fill_color.opacity);
+                  /*
+                    Notes on call to AlphaCompositePixel():
+
+                      fill_color: the polygon or pattern fill color, not premultiplied
+                        by its opacity value
+                      fill_opacity: product of the fill color opacity and opacity due
+                        to partial pixel coverage (e.g., at the edge of the polygon)
+                      q: (input) the background pixel, (output) the composited pixel;
+                        neither is premultiplied by its opacity value
+                      q->opacity: the background pixel opacity
+
+                    The previous version of this code substituted "OpaqueOpacity"
+                    for q->opacity if q->opacity was transparent.  I think this was
+                    orignally done to avoid a divide-by-zero in AlphaCompositePixel().
+                    However, this substitution results in an incorrect result if the
+                    background pixel is completely transparent.  Since the current
+                    version of AlphaCompositePixel() has code in it to prevent a
+                    divide-by-zero, the code has been fixed to always use q->opacity
+                    as the background pixel opacity.
+                  */
+                  AlphaCompositePixel(q,&fill_color,fill_opacity,q,q->opacity);
+                  if ((stroke_pattern != (Image *) NULL) &&
                       (stroke_pattern->columns != 0) &&
                       (stroke_pattern->rows != 0))
-                   (void) AcquireOnePixelByReference
-                     (stroke_pattern,&stroke_color,
-                      (long) (x-stroke_pattern->tile_info.x) % stroke_pattern->columns,
-                      (long) (y-stroke_pattern->tile_info.y) % stroke_pattern->rows,
-                      &image->exception);
-                 stroke_opacity=MaxRGBDouble-stroke_opacity*
-                   (MaxRGBDouble-(double)stroke_color.opacity);
-                 AlphaCompositePixel(q,&stroke_color,stroke_opacity,q,
-                                     (q->opacity == TransparentOpacity)
-                                     ? OpaqueOpacity : q->opacity);
-                 q++;
-               } /* for ( ; x <= x_stop; x++) */
-             if (!SyncImagePixelsEx(image,&image->exception))
-               thread_status=MagickFail;
-
-             if (thread_status == MagickFail)
-               {
+                    {
+                      (void) AcquireOnePixelByReference
+                        (stroke_pattern,&stroke_color,
+                        (long) (x-stroke_pattern->tile_info.x) % stroke_pattern->columns,
+                        (long) (y-stroke_pattern->tile_info.y) % stroke_pattern->rows,
+                        &image->exception);
+                      /* apply the group opacity value to the pattern pixel */
+                      stroke_color.opacity = MaxRGB-((MaxRGB-stroke_color.opacity)*(MaxRGB-draw_info->opacity)+(MaxRGB>>1))/MaxRGB;
+                    }
+                  stroke_opacity=MaxRGBDouble-stroke_opacity*
+                    (MaxRGBDouble-(double)stroke_color.opacity);
+                  /*
+                    In the call to AlphaCompositePixel() below, q->opacity is now always
+                    used as the background pixel opacity for the same reason as described
+                    in the call to AlphaCompositePixel() above.
+                  */
+                  AlphaCompositePixel(q,&stroke_color,stroke_opacity,q,q->opacity);
+                  q++;
+                } /* for ( ; x <= x_stop; x++) */
+              if (!SyncImagePixelsEx(image,&image->exception))
+                thread_status=MagickFail;
+
+              if (thread_status == MagickFail)
+                {
+                  status=thread_status;
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_DrawPolygonPrimitive_Status)
+#  pragma omp flush (status)
 #endif
-                 status=thread_status;
-               }
-           }
-       }
+                }
+            }
+        }
     }
   (void) LogMagickEvent(RenderEvent,GetMagickModule(),"    end draw-polygon");
+
+ draw_polygon_primitive_end:;
+
   DestroyThreadViewDataSet(polygon_set);
 
   return(status);
@@ -4517,6 +5684,7 @@ DrawPrimitive(Image *image,const DrawInfo *draw_info,
     {
       double
         mid,
+        stroke_width_limited,
         scale;
 
       DrawInfo
@@ -4541,7 +5709,12 @@ DrawPrimitive(Image *image,const DrawInfo *draw_info,
           status&=DrawDashPolygon(draw_info,primitive_info,image);
           break;
         }
-      mid=ExpandAffine(&draw_info->affine)*draw_info->stroke_width/2.0;
+
+      /* sanity check for excessively big stroke_width (ticket #515) */
+      if  ( (stroke_width_limited = STROKE_WIDTH_LIMIT(image)) > draw_info->stroke_width )
+          stroke_width_limited = draw_info->stroke_width;
+
+      mid=ExpandAffine(&draw_info->affine)*stroke_width_limited/2.0;
       if ((mid > 1.0) && (draw_info->stroke.opacity != TransparentOpacity))
         {
           unsigned int
@@ -4550,10 +5723,7 @@ DrawPrimitive(Image *image,const DrawInfo *draw_info,
           /*
             Draw strokes while respecting line cap/join attributes.
           */
-          for (i=0; primitive_info[i].primitive != UndefinedPrimitive; i++);
-          closed_path=
-            (primitive_info[i-1].point.x == primitive_info[0].point.x) &&
-            (primitive_info[i-1].point.y == primitive_info[0].point.y);
+          closed_path=PRIMINF_GET_IS_CLOSED_SUBPATH(&primitive_info[0]);
           i=(long) primitive_info[0].coordinates;
           if ((((draw_info->linecap == RoundCap) || closed_path) &&
                (draw_info->linejoin == RoundJoin)) ||
@@ -4562,11 +5732,13 @@ DrawPrimitive(Image *image,const DrawInfo *draw_info,
               status&=DrawPolygonPrimitive(image,draw_info,primitive_info);
               break;
             }
+          /* first fill the polygon by cloning and turning off stroking ... */
           clone_info=CloneDrawInfo((ImageInfo *) NULL,draw_info);
           clone_info->stroke_width=0.0;
           clone_info->stroke.opacity=TransparentOpacity;
           status&=DrawPolygonPrimitive(image,clone_info,primitive_info);
           DestroyDrawInfo(clone_info);
+          /* ... and then stroke the polygon */
           status&=DrawStrokePolygon(image,draw_info,primitive_info);
           break;
         }
@@ -4670,13 +5842,41 @@ DrawStrokePolygon(Image *image,const DrawInfo *draw_info,
   status=MagickPass;
   for (p=primitive_info; p->primitive != UndefinedPrimitive; p+=p->coordinates)
   {
-    stroke_polygon=TraceStrokePolygon(draw_info,p);
+    /*
+      Per the SVG spec:  A subpath (see Paths) consisting of a
+      single moveto shall not be stroked.
+    */
+    if  ( p->coordinates == 1 )
+      continue;
+    /*
+      *** BUG ALERT! ***
+
+      The sequence below has a bug in it somewhere.  "Thin" polygons that are
+      stroked with a stroke-width whose magnitude is close to the size of the
+      "thinness" of the polygon are rendered incorrectly.  For example, this
+      SVG path renders correctly:
+
+      <path fill="none" stroke="rgb(0,255,0)" stroke-width="3" stroke-linecap="round"
+        stroke-linejoin="miter" d="M 10 10 110 10 110 10.5 z" />
+
+      But this one does not:
+
+      <path fill="none" stroke="rgb(0,255,0)" stroke-width="3" stroke-linecap="round"
+        stroke-linejoin="miter" d="M 10 10 110 10 110 10.4 z" />
+
+      The only difference is the y coordinate of the last path point (10.5 vs. 10.4).
+
+      The "stroke_polygon" produced by TraceStrokePolygon() for the second path is
+      significantly different from that for the first path, so my suspicion is that
+      that's where the bug is.  However, it could also be in DrawPolygonPrimitive().
+    */
+    stroke_polygon=TraceStrokePolygon(image,draw_info,p);
     status&=DrawPolygonPrimitive(image,clone_info,stroke_polygon);
     MagickFreeMemory(stroke_polygon);
     if (status == MagickFail)
       break;
     q=p+p->coordinates-1;
-    closed_path=(q->point.x == p->point.x) && (q->point.y == p->point.y);
+    closed_path=PRIMINF_GET_IS_CLOSED_SUBPATH(p);
     if ((draw_info->linecap == RoundCap) && !closed_path)
       {
         DrawRoundLinecap(image,draw_info,p);
@@ -4720,11 +5920,22 @@ GetDrawInfo(const ImageInfo *image_info,DrawInfo *draw_info)
   ImageInfo
     *clone_info;
 
+  DrawInfoExtra
+    *DIExtra;
+
   /*
     Initialize draw attributes.
   */
   assert(draw_info != (DrawInfo *) NULL);
   (void) memset(draw_info,0,sizeof(DrawInfo));
+
+  /* allocate and initialize struct for extra DrawInfo members */
+  DIExtra = MagickAllocateMemory(DrawInfoExtra *,sizeof(DrawInfoExtra));
+  if  ( DIExtra == (DrawInfoExtra *) NULL )
+    MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,UnableToAllocateDrawInfo);
+  memset(DIExtra,0,sizeof(*DIExtra));
+  draw_info->extra = DIExtra;
+
   clone_info=CloneImageInfo(image_info);
   IdentityAffine(&draw_info->affine);
   draw_info->gravity=NorthWestGravity;
@@ -4751,6 +5962,8 @@ GetDrawInfo(const ImageInfo *image_info,DrawInfo *draw_info)
     draw_info->server_name=AllocateString(clone_info->server_name);
   draw_info->render=True;
   draw_info->signature=MagickSignature;
+  SetDrawInfoSVGCompliant(draw_info,MagickFalse);
+  SetDrawInfoClippingPath(draw_info,MagickFalse);
   DestroyImageInfo(clone_info);
 }
 \f
@@ -4813,8 +6026,8 @@ Permutate(const long n,const long k)
 %
 */
 
-static void
-TraceArc(PrimitiveInfo *primitive_info,const PointInfo start,
+static MagickPassFail
+TraceArc(PrimitiveInfoMgr *p_PIMgr,const PointInfo start,
          const PointInfo end,const PointInfo arc)
 {
   PointInfo
@@ -4825,11 +6038,11 @@ TraceArc(PrimitiveInfo *primitive_info,const PointInfo start,
   center.y=0.5*(end.y+start.y);
   radius.x=fabs(center.x-start.x);
   radius.y=fabs(center.y-start.y);
-  TraceEllipse(primitive_info,center,radius,arc);
+  return TraceEllipse(p_PIMgr,center,radius,arc);
 }
 
-static void
-TraceArcPath(PrimitiveInfo *primitive_info,const PointInfo start,
+static MagickPassFail
+TraceArcPath(PrimitiveInfoMgr *p_PIMgr,const PointInfo start,
              const PointInfo end,const PointInfo arc,const double angle,
              const unsigned int large_arc,const unsigned int sweep)
 {
@@ -4859,14 +6072,32 @@ TraceArcPath(PrimitiveInfo *primitive_info,const PointInfo start,
   unsigned long
     arc_segments;
 
-  if ((start.x == end.x) && (start.y == end.y))
-    return;
+  PrimitiveInfo
+    **pp_PrimitiveInfo,
+    *primitive_info;
+
+  size_t
+    InitialStoreStartingAt;
+
+  pp_PrimitiveInfo = p_PIMgr->pp_PrimitiveInfo;
+  InitialStoreStartingAt = p_PIMgr->StoreStartingAt;
+  primitive_info = *pp_PrimitiveInfo + InitialStoreStartingAt;
+
+  primitive_info->coordinates = 0;      /* in case we return without doing anything */
+  /*
+    Per the SVG spec: If the endpoints (x1, y1) and (x2, y2) are identical, then
+    this is equivalent to omitting the elliptical arc segment entirely.
+  */
+  if  ( (fabs(start.x-end.x) < MagickEpsilon) && (fabs(start.y-end.y) < MagickEpsilon) )
+    {
+      /* substitute a lineto command (so zero length arc looks like a zero length segment) */
+      return (TracePoint(primitive_info,end));
+    }
   radii.x=fabs(arc.x);
   radii.y=fabs(arc.y);
   if ((radii.x == 0.0) || (radii.y == 0.0))
     {
-      TraceLine(primitive_info,start,end);
-      return;
+      return (TraceLine(primitive_info,start,end));
     }
   cosine=cos(DegreesToRadians(fmod(angle,360.0)));
   sine=sin(DegreesToRadians(fmod(angle,360.0)));
@@ -4935,19 +6166,26 @@ TraceArcPath(PrimitiveInfo *primitive_info,const PointInfo start,
     (p+3)->point.y=sine*radii.x*points[2].x+cosine*radii.y*points[2].y;
     if (i == (long) (arc_segments-1))
       (p+3)->point=end;
-    TraceBezier(p,4);
+    if (TraceBezier(p_PIMgr,4) == MagickFail)
+      return MagickFail;
+    p = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;  /* base addr might have changed */
+    p_PIMgr->StoreStartingAt+=p->coordinates;
     p+=p->coordinates;
   }
+  primitive_info = *pp_PrimitiveInfo + InitialStoreStartingAt;
+  p_PIMgr->StoreStartingAt = InitialStoreStartingAt;  /* restore original value */
   primitive_info->coordinates=p-primitive_info;
+  PRIMINF_CLEAR_FLAGS(primitive_info);
   for (i=0; i < (long) primitive_info->coordinates; i++)
   {
     p->primitive=primitive_info->primitive;
     p--;
   }
+  return MagickPass;
 }
 
-static void
-TraceBezier(PrimitiveInfo *primitive_info,
+static MagickPassFail
+TraceBezier(PrimitiveInfoMgr *p_PIMgr,
             const unsigned long number_coordinates)
 {
   double
@@ -4960,6 +6198,10 @@ TraceBezier(PrimitiveInfo *primitive_info,
     point,
     *points;
 
+  PrimitiveInfo
+    *primitive_info,
+    **pp_PrimitiveInfo;
+
   register PrimitiveInfo
     *p;
 
@@ -4967,10 +6209,18 @@ TraceBezier(PrimitiveInfo *primitive_info,
     i,
     j;
 
+  size_t
+    control_points;
+
   unsigned long
-    control_points,
     quantum;
 
+  MagickPassFail
+    status = MagickPass;
+
+  pp_PrimitiveInfo = p_PIMgr->pp_PrimitiveInfo;
+  primitive_info = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;
+
   /*
     Allocate coeficients.
   */
@@ -4988,7 +6238,13 @@ TraceBezier(PrimitiveInfo *primitive_info,
     }
   }
   quantum=Min(quantum/number_coordinates,BezierQuantum);
-  control_points=quantum*number_coordinates;
+  control_points=(size_t) quantum*number_coordinates;
+
+  /* make sure we have enough space */
+  if (PrimitiveInfoRealloc(p_PIMgr,control_points+1) == MagickFail)
+    return MagickFail;
+  primitive_info = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;
+
   coefficients=MagickAllocateArray(double *,number_coordinates,sizeof(double));
   points=MagickAllocateArray(PointInfo *,control_points,sizeof(PointInfo));
   if ((coefficients == (double *) NULL) || (points == (PointInfo *) NULL))
@@ -5023,23 +6279,28 @@ TraceBezier(PrimitiveInfo *primitive_info,
   p=primitive_info;
   for (i=0; i < (long) control_points; i++)
   {
-    TracePoint(p,points[i]);
+    if ((status=TracePoint(p,points[i])) != MagickPass)
+      goto trace_bezier_done;
     p+=p->coordinates;
   }
-  TracePoint(p,end);
+  if ((status=TracePoint(p,end)) == MagickFail)
+    goto trace_bezier_done;
   p+=p->coordinates;
   primitive_info->coordinates=p-primitive_info;
+  PRIMINF_CLEAR_FLAGS(primitive_info);
   for (i=0; i < (long) primitive_info->coordinates; i++)
   {
     p->primitive=primitive_info->primitive;
     p--;
   }
+ trace_bezier_done:;
   MagickFreeMemory(points);
   MagickFreeMemory(coefficients);
+  return status;
 }
 
-static void
-TraceCircle(PrimitiveInfo *primitive_info,const PointInfo start,
+static MagickPassFail
+TraceCircle(PrimitiveInfoMgr *p_PIMgr,const PointInfo start,
             const PointInfo end)
 {
   double
@@ -5058,15 +6319,16 @@ TraceCircle(PrimitiveInfo *primitive_info,const PointInfo start,
   offset.y=radius;
   degrees.x=0.0;
   degrees.y=360.0;
-  TraceEllipse(primitive_info,start,offset,degrees);
+  return TraceEllipse(p_PIMgr,start,offset,degrees);
 }
 
-static void
-TraceEllipse(PrimitiveInfo *primitive_info,const PointInfo start,
+static MagickPassFail
+TraceEllipse(PrimitiveInfoMgr *p_PIMgr,const PointInfo start,
              const PointInfo stop,const PointInfo degrees)
 {
   double
     delta,
+    points_length,
     step,
     y;
 
@@ -5077,57 +6339,102 @@ TraceEllipse(PrimitiveInfo *primitive_info,const PointInfo start,
   register PrimitiveInfo
     *p;
 
-  register long
-    i;
+  PrimitiveInfo
+    *primitive_info,
+    **pp_PrimitiveInfo;
+
+  MagickPassFail
+    status = MagickPass;
 
   /*
     Ellipses are just short segmented polys.
   */
-  if (stop.x == 0.0 || stop.y == 0.0)
-    return;
+  pp_PrimitiveInfo = p_PIMgr->pp_PrimitiveInfo;
+  primitive_info = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;
+  primitive_info->coordinates = 0;  /* in case we return without doing anything */
+  if (stop.x == 0.0 || stop.y == 0.0)  /* actually the x and y radii of the corner ellipse */
+    return MagickPass;
   delta=2.0/Max(stop.x,stop.y);
   step=MagickPI/8.0;
   if (delta < (MagickPI/8.0))
-    step=MagickPI/(4*ceil(MagickPI/delta/2));
+    step=(MagickPI/4.0)/ceil(MagickPI/delta/2.0);
   angle.x=DegreesToRadians(degrees.x);
   y=degrees.y;
   while (y < degrees.x)
     y+=360.0;
   angle.y=DegreesToRadians(y);
+
+  /* FIXME: The number of points could become arbitrarily large.  It
+     would be good to add an algorithm which decreases ellipse drawing
+     quality when necessary in order to limit the number of points
+     required. */
+
+  /* make sure we have enough space */
+  points_length = ceil(1.0 + ceil((angle.y - angle.x) / step));
+  if ((size_t) points_length < points_length)
+    {
+      /* points_length too big to be represented as a size_t */
+      status=MagickFail;
+      ThrowException3(p_PIMgr->p_Exception,ResourceLimitError,
+                     MemoryAllocationFailed,UnableToDrawOnImage);
+      goto trace_ellipse_done;
+    }
+  if ((status=PrimitiveInfoRealloc(p_PIMgr,(size_t) points_length)) == MagickFail)
+    goto trace_ellipse_done;
+  primitive_info = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;
+
   for (p=primitive_info; angle.x < angle.y; angle.x+=step)
   {
     point.x=cos(fmod(angle.x,DegreesToRadians(360.0)))*stop.x+start.x;
     point.y=sin(fmod(angle.x,DegreesToRadians(360.0)))*stop.y+start.y;
-    TracePoint(p,point);
+    if ((status=TracePoint(p,point)) == MagickFail)
+      goto trace_ellipse_done;
     p+=p->coordinates;
   }
   point.x=cos(fmod(angle.y,DegreesToRadians(360.0)))*stop.x+start.x;
   point.y=sin(fmod(angle.y,DegreesToRadians(360.0)))*stop.y+start.y;
-  TracePoint(p,point);
+  if ((status=TracePoint(p,point))  == MagickFail)
+    goto trace_ellipse_done;
   p+=p->coordinates;
   primitive_info->coordinates=p-primitive_info;
-  for (i=0; i < (long) primitive_info->coordinates; i++)
-  {
+  PRIMINF_CLEAR_FLAGS(primitive_info);
+  if  (
+    (fabs(primitive_info[0].point.x-primitive_info[primitive_info->coordinates-1].point.x) < MagickEpsilon)
+    && (fabs(primitive_info[0].point.y-primitive_info[primitive_info->coordinates-1].point.y) < MagickEpsilon)
+    )
+    PRIMINF_SET_IS_CLOSED_SUBPATH(primitive_info,1);
+  /* NOTE: p pointing just past last traced point! */
+  for (p--; p > primitive_info; p--)
     p->primitive=primitive_info->primitive;
-    p--;
-  }
+ trace_ellipse_done:
+  return status;
 }
 
-static void
+static MagickPassFail
 TraceLine(PrimitiveInfo *primitive_info,const PointInfo start,
           const PointInfo end)
 {
-  TracePoint(primitive_info,start);
+  MagickPassFail
+    status = MagickPass;
+
+  if ((status=TracePoint(primitive_info,start)) == MagickFail)
+    goto trace_line_done;
   if ((AbsoluteValue(start.x-end.x) <= MagickEpsilon) &&
       (AbsoluteValue(start.y-end.y) <= MagickEpsilon))
     {
       primitive_info->primitive=PointPrimitive;
       primitive_info->coordinates=1;
-      return;
+      goto trace_line_done;
     }
-  TracePoint(primitive_info+1,end);
+  if ((status=TracePoint(primitive_info+1,end)) == MagickFail)
+    goto trace_line_done;
   (primitive_info+1)->primitive=primitive_info->primitive;
   primitive_info->coordinates=2;
+  PRIMINF_CLEAR_FLAGS(primitive_info);
+
+ trace_line_done:
+
+  return status;
 }
 
 /*
@@ -5173,7 +6480,7 @@ TraceLine(PrimitiveInfo *primitive_info,const PointInfo start,
 
 
 static unsigned long
-TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
+TracePath(Image *image,PrimitiveInfoMgr *p_PIMgr,const char *path)
 {
   char
     token[MaxTextExtent];
@@ -5198,6 +6505,10 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
   PrimitiveType
     primitive_type;
 
+  PrimitiveInfo
+    *primitive_info,
+    **pp_PrimitiveInfo;
+
   register PrimitiveInfo
     *q;
 
@@ -5208,6 +6519,15 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
     number_coordinates,
     z_count;
 
+  size_t
+    SubpathOffset;  /* index to start of current subpath */
+
+  MagickPassFail
+    status = MagickPass;
+
+  pp_PrimitiveInfo = p_PIMgr->pp_PrimitiveInfo;
+  SubpathOffset = p_PIMgr->StoreStartingAt;
+  primitive_info = *pp_PrimitiveInfo + SubpathOffset;
   attribute=0;
   number_coordinates=0;
   z_count=0;
@@ -5274,7 +6594,10 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
           MagickTracePathAtoF(token,&y);
           end.x=attribute == 'A' ? x : point.x+x;
           end.y=attribute == 'A' ? y : point.y+y;
-          TraceArcPath(q,point,end,arc,angle,large_arc,sweep);
+          if ((status=TraceArcPath(p_PIMgr,point,end,arc,angle,large_arc,sweep)) == MagickFail)
+            goto trace_path_done;
+          q = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;  /* base address might have changed */
+          p_PIMgr->StoreStartingAt += q->coordinates;
           q+=q->coordinates;
           point=end;
           while (isspace((int) ((unsigned char) *p)) != 0)
@@ -5312,9 +6635,17 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
           }
           for (i=0; i < 4; i++)
             (q+i)->point=points[i];
-          TraceBezier(q,4);
+          if ((status=TraceBezier(p_PIMgr,4)) == MagickFail)
+            goto trace_path_done;
+          q = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;  /* base address might have changed */
+          p_PIMgr->StoreStartingAt += q->coordinates;
           q+=q->coordinates;
           point=end;
+          /* consume comma if present (as in elliptical arc above) */
+          while (isspace((int) ((unsigned char) *p)) != 0)
+            p++;
+          if (*p == ',')
+            p++;
         } while (IsPoint(p));
         break;
       }
@@ -5328,8 +6659,22 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
             MagickGetTracePathToken(p,&p,token,MaxTextExtent);
           MagickTracePathAtoF(token,&x);
           point.x=attribute == 'H' ? x: point.x+x;
-          TracePoint(q,point);
+          /* make sure we have at least 100 elements available */
+          if ((p_PIMgr->StoreStartingAt + 100) > *p_PIMgr->p_AllocCount)
+            {
+              if (PrimitiveInfoRealloc(p_PIMgr,100) == MagickFail)
+                return 0; /* FIXME: How to return useful error? */
+              q = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;  /* base address might have changed */
+            }
+          if ((status=TracePoint(q,point)) == MagickFail)
+            goto trace_path_done;
+          p_PIMgr->StoreStartingAt += q->coordinates;
           q+=q->coordinates;
+          /* consume comma if present (as in elliptical arc above) */
+          while (isspace((int) ((unsigned char) *p)) != 0)
+            p++;
+          if (*p == ',')
+            p++;
         } while (IsPoint(p));
         break;
       }
@@ -5351,8 +6696,22 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
           MagickTracePathAtoF(token,&y);
           point.x=attribute == 'L' ? x : point.x+x;
           point.y=attribute == 'L' ? y : point.y+y;
-          TracePoint(q,point);
+          /* make sure we have at least 100 elements available */
+          if ((p_PIMgr->StoreStartingAt + 100) > *p_PIMgr->p_AllocCount)
+          {
+            if ((status=PrimitiveInfoRealloc(p_PIMgr,100)) == MagickFail)
+              goto trace_path_done;
+            q = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;  /* base address might have changed */
+          }
+          if ((status=TracePoint(q,point)) == MagickFail)
+            goto trace_path_done;
+          p_PIMgr->StoreStartingAt += q->coordinates;
           q+=q->coordinates;
+          /* consume comma if present (as in elliptical arc above) */
+          while (isspace((int) ((unsigned char) *p)) != 0)
+            p++;
+          if (*p == ',')
+            p++;
         } while (IsPoint(p));
         break;
       }
@@ -5362,11 +6721,13 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
       case 'M':
       case 'm':
       {
-        if (q != primitive_info)
+        if  ( p_PIMgr->StoreStartingAt != SubpathOffset )
           {
+            primitive_info = *pp_PrimitiveInfo + SubpathOffset;
             primitive_info->coordinates=q-primitive_info;
             number_coordinates+=primitive_info->coordinates;
             primitive_info=q;
+            SubpathOffset=p_PIMgr->StoreStartingAt;
           }
         i=0;
         do
@@ -5382,15 +6743,27 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
           point.x=attribute == 'M' ? x : point.x+x;
           point.y=attribute == 'M' ? y : point.y+y;
           if (i == 0)
-            start=point;
+            start=point; /*otherwise it's an implied lineto command for both 'M' and 'm'*/
           i++;
-          TracePoint(q,point);
-          q+=q->coordinates;
-          if ((i != 0) && (attribute == 'M'))
+          /* make sure we have at least 100 elements available */
+          if  ((p_PIMgr->StoreStartingAt + 100) > *p_PIMgr->p_AllocCount)
             {
-              TracePoint(q,point);
-              q+=q->coordinates;
+              if (PrimitiveInfoRealloc(p_PIMgr,100) == MagickFail)
+                return 0; /* FIXME: How to return useful error? */
+              q = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;  /* base address might have changed */
             }
+          if ((status=TracePoint(q,point)) == MagickFail)
+            goto trace_path_done;
+          p_PIMgr->StoreStartingAt += q->coordinates;
+          q+=q->coordinates;
+
+          /* there was code here that added the point again, but only if 'M' (?) ... deleted */
+
+          /* consume comma if present (as in elliptical arc above) */
+          while (isspace((int) ((unsigned char) *p)) != 0)
+            p++;
+          if (*p == ',')
+            p++;
         } while (IsPoint(p));
         break;
       }
@@ -5424,9 +6797,17 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
           }
           for (i=0; i < 3; i++)
             (q+i)->point=points[i];
-          TraceBezier(q,3);
+          if ((status=TraceBezier(p_PIMgr,3)) == MagickFail)
+            goto trace_path_done;
+          q = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;
+          p_PIMgr->StoreStartingAt += q->coordinates;
           q+=q->coordinates;
           point=end;
+          /* consume comma if present (as in elliptical arc above) */
+          while (isspace((int) ((unsigned char) *p)) != 0)
+            p++;
+          if (*p == ',')
+            p++;
         } while (IsPoint(p));
         break;
       }
@@ -5439,6 +6820,11 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
         /*
           Compute bezier points.
         */
+        /*
+          Handle multiple pairs of cubic Bezier points when the previous path data
+          command was not a cubic Bezier (i.e., not 'c' or 's').
+        */
+        int previous_path_data_command = last_attribute;  /* the previous path data command upon entry to this 'case' */
         do
         {
           points[0]=points[3];
@@ -5460,16 +6846,25 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
             end.y=attribute == 'S' ? y : point.y+y;
             points[i]=end;
           }
-          if (strchr("CcSs",last_attribute) == (char *) NULL)
+          if (strchr("CcSs",previous_path_data_command) == (char *) NULL) /* check the ACTUAL previous command */
             {
               points[0]=point;
               points[1]=point;
             }
           for (i=0; i < 4; i++)
             (q+i)->point=points[i];
-          TraceBezier(q,4);
+          if ((TraceBezier(p_PIMgr,4)) == MagickFail)
+            goto trace_path_done;
+          q = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;
+          p_PIMgr->StoreStartingAt += q->coordinates;
           q+=q->coordinates;
           point=end;
+          previous_path_data_command = attribute;   /* current path data command becomes previous for next loop iteration */
+          /* consume comma if present (as in elliptical arc above) */
+          while (isspace((int) ((unsigned char) *p)) != 0)
+            p++;
+          if (*p == ',')
+            p++;
         } while (IsPoint(p));
         break;
       }
@@ -5482,6 +6877,11 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
         /*
           Compute bezier points.
         */
+        /*
+          Handle multiple pairs of quadratic Bezier points when the previous path data
+          command was not a quadratic Bezier (i.e., not 'q' or 't').
+        */
+        int previous_path_data_command = last_attribute;  /* the previous path data command upon entry to this 'case' */
         do
         {
           points[0]=points[2];
@@ -5501,16 +6901,25 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
             end.y=attribute == 'T' ? y : point.y+y;
             points[i]=end;
           }
-          if (strchr("QqTt",last_attribute) == (char *) NULL)
+          if (strchr("QqTt",previous_path_data_command) == (char *) NULL) /* check the ACTUAL previous command */
             {
               points[0]=point;
               points[1]=point;
             }
           for (i=0; i < 3; i++)
             (q+i)->point=points[i];
-          TraceBezier(q,3);
+          if ((status=TraceBezier(p_PIMgr,3)) == MagickFail)
+            goto trace_path_done;
+          q = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;
+          p_PIMgr->StoreStartingAt += q->coordinates;
           q+=q->coordinates;
           point=end;
+          previous_path_data_command = attribute;   /* current path data command becomes previous for next loop iteration */
+          /* consume comma if present (as in elliptical arc above) */
+          while (isspace((int) ((unsigned char) *p)) != 0)
+            p++;
+          if (*p == ',')
+            p++;
         } while (IsPoint(p));
         break;
       }
@@ -5527,8 +6936,22 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
             MagickGetTracePathToken(p,&p,token,MaxTextExtent);
           MagickTracePathAtoF(token,&y);
           point.y=attribute == 'V' ? y : point.y+y;
-          TracePoint(q,point);
+          /* make sure we have at least 100 elements available */
+          if ((p_PIMgr->StoreStartingAt + 100) > *p_PIMgr->p_AllocCount)
+            {
+              if ((status=PrimitiveInfoRealloc(p_PIMgr,100)) == MagickFail)
+                goto trace_path_done;
+              q = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;  /* base address might have changed */
+            }
+          if ((status=TracePoint(q,point)) == MagickFail)
+            goto trace_path_done;
+          p_PIMgr->StoreStartingAt += q->coordinates;
           q+=q->coordinates;
+          /* consume comma if present (as in elliptical arc above) */
+          while (isspace((int) ((unsigned char) *p)) != 0)
+            p++;
+          if (*p == ',')
+            p++;
         } while (IsPoint(p));
         break;
       }
@@ -5539,11 +6962,23 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
       case 'Z':
       {
         point=start;
-        TracePoint(q,point);
+        /* make sure we have at least 100 elements available */
+        if ((p_PIMgr->StoreStartingAt + 100) > *p_PIMgr->p_AllocCount)
+          {
+            if ((status=PrimitiveInfoRealloc(p_PIMgr,100)) == MagickFail)
+              goto trace_path_done;
+            q = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;  /* base address might have changed */
+          }
+        if ((status=TracePoint(q,point)) == MagickFail)
+            goto trace_path_done;
+        p_PIMgr->StoreStartingAt += q->coordinates;
         q+=q->coordinates;
+        primitive_info = *pp_PrimitiveInfo + SubpathOffset;
         primitive_info->coordinates=q-primitive_info;
+        PRIMINF_SET_IS_CLOSED_SUBPATH(primitive_info,1);
         number_coordinates+=primitive_info->coordinates;
         primitive_info=q;
+        SubpathOffset = p_PIMgr->StoreStartingAt;
         z_count++;
         break;
       }
@@ -5556,6 +6991,7 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
     }
   }
 
+  primitive_info = *pp_PrimitiveInfo + SubpathOffset;
   primitive_info->coordinates=q-primitive_info;
   number_coordinates+=primitive_info->coordinates;
   for (i=0; i < (long) number_coordinates; i++)
@@ -5566,17 +7002,25 @@ TracePath(Image *image,PrimitiveInfo *primitive_info,const char *path)
       q->method=FillToBorderMethod;
   }
   q=primitive_info;
+
+ trace_path_done:;
+
+  if (status == MagickFail)
+    number_coordinates = 0;
+
   return(number_coordinates);
 }
 
-static void
+static MagickPassFail
 TracePoint(PrimitiveInfo *primitive_info,const PointInfo point)
 {
   primitive_info->coordinates=1;
+  PRIMINF_CLEAR_FLAGS(primitive_info);
   primitive_info->point=point;
+  return MagickPass;
 }
 
-static void
+static MagickPassFail
 TraceRectangle(PrimitiveInfo *primitive_info,const PointInfo start,
   const PointInfo end)
 {
@@ -5589,31 +7033,54 @@ TraceRectangle(PrimitiveInfo *primitive_info,const PointInfo start,
   register long
     i;
 
+  MagickPassFail
+    status = MagickPass;
+
+  /*
+    Per the SVG spec, if the width and/or height are zero, rendering
+    the element is disabled.
+  */
+  if ((start.x == end.x) || (start.y == end.y))
+  {
+    primitive_info->coordinates = 0;
+    goto trace_rectangle_done;
+  }
   p=primitive_info;
-  TracePoint(p,start);
+  if ((status = TracePoint(p,start)) == MagickFail)
+    goto trace_rectangle_done;
   p+=p->coordinates;
   point.x=start.x;
   point.y=end.y;
-  TracePoint(p,point);
+  if ((status = TracePoint(p,point)) == MagickFail)
+    goto trace_rectangle_done;
   p+=p->coordinates;
-  TracePoint(p,end);
+  if ((status = TracePoint(p,end)) == MagickFail)
+    goto trace_rectangle_done;
   p+=p->coordinates;
   point.x=end.x;
   point.y=start.y;
-  TracePoint(p,point);
+  if ((status = TracePoint(p,point)) == MagickFail)
+    goto trace_rectangle_done;
   p+=p->coordinates;
-  TracePoint(p,start);
+  if ((status = TracePoint(p,start)) == MagickFail)
+    goto trace_rectangle_done;
   p+=p->coordinates;
   primitive_info->coordinates=p-primitive_info;
+  PRIMINF_CLEAR_FLAGS(primitive_info);
+  PRIMINF_SET_IS_CLOSED_SUBPATH(primitive_info,1);
   for (i=0; i < (long) primitive_info->coordinates; i++)
   {
     p->primitive=primitive_info->primitive;
     p--;
   }
+
+ trace_rectangle_done:
+
+  return status;
 }
 
-static void
-TraceRoundRectangle(PrimitiveInfo *primitive_info,
+static MagickPassFail
+TraceRoundRectangle(PrimitiveInfoMgr *p_PIMgr,
                     const PointInfo start,const PointInfo end,PointInfo arc)
 {
   PointInfo
@@ -5624,51 +7091,98 @@ TraceRoundRectangle(PrimitiveInfo *primitive_info,
   register PrimitiveInfo
     *p;
 
-  register long
-    i;
+  size_t
+    InitialStoreStartingAt;
+
+  PrimitiveInfo
+    *primitive_info,
+    **pp_PrimitiveInfo;
+
+  MagickPassFail
+    status = MagickPass;
+
+  pp_PrimitiveInfo = p_PIMgr->pp_PrimitiveInfo;
+  InitialStoreStartingAt = p_PIMgr->StoreStartingAt;
+
+  offset.x=AbsoluteValue(end.x-start.x);  /* rect width */
+  offset.y=AbsoluteValue(end.y-start.y);  /* rect height */
+  /*
+    Per the SVG spec, if the width and/or height are zero, rendering
+    the element is disabled.
+  */
+  if ((offset.x == 0.0) || (offset.y == 0.0))
+  {
+    (*pp_PrimitiveInfo+InitialStoreStartingAt)->coordinates = 0;
+    goto round_rectangle_done;
+  }
 
-  p=primitive_info;
-  offset.x=AbsoluteValue(end.x-start.x);
-  offset.y=AbsoluteValue(end.y-start.y);
   if (arc.x > (0.5*offset.x))
     arc.x=0.5*offset.x;
   if (arc.y > (0.5*offset.y))
     arc.y=0.5*offset.y;
+
   point.x=start.x+offset.x-arc.x;
   point.y=start.y+arc.y;
   degrees.x=270.0;
   degrees.y=360.0;
-  TraceEllipse(p,point,arc,degrees);
-  p+=p->coordinates;
+  if ((status=TraceEllipse(p_PIMgr,point,arc,degrees)) == MagickFail)
+    goto round_rectangle_done;
+  p = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;  /* base addr might have moved */
+  p_PIMgr->StoreStartingAt += p->coordinates;
+
   point.x=start.x+offset.x-arc.x;
   point.y=start.y+offset.y-arc.y;
   degrees.x=0.0;
   degrees.y=90.0;
-  TraceEllipse(p,point,arc,degrees);
-  p+=p->coordinates;
+  if ((status=TraceEllipse(p_PIMgr,point,arc,degrees)) == MagickFail)
+    goto round_rectangle_done;
+  p = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;  /* base addr might have moved */
+  p_PIMgr->StoreStartingAt += p->coordinates;
+
   point.x=start.x+arc.x;
   point.y=start.y+offset.y-arc.y;
   degrees.x=90.0;
   degrees.y=180.0;
-  TraceEllipse(p,point,arc,degrees);
-  p+=p->coordinates;
+  if ((status=TraceEllipse(p_PIMgr,point,arc,degrees)) == MagickFail)
+    goto round_rectangle_done;
+  p = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;  /* base addr might have moved */
+  p_PIMgr->StoreStartingAt += p->coordinates;
+
   point.x=start.x+arc.x;
   point.y=start.y+arc.y;
   degrees.x=180.0;
   degrees.y=270.0;
-  TraceEllipse(p,point,arc,degrees);
-  p+=p->coordinates;
-  TracePoint(p,primitive_info->point);
+  if ((status=TraceEllipse(p_PIMgr,point,arc,degrees)) == MagickFail)
+    goto round_rectangle_done;
+  p = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;  /* base addr might have moved */
+  p_PIMgr->StoreStartingAt += p->coordinates;
+
+  /* need only one element, but make sure there is some headroom */
+  if ((p_PIMgr->StoreStartingAt + 100) > *p_PIMgr->p_AllocCount)
+    {
+      if ((status=PrimitiveInfoRealloc(p_PIMgr,100)) == MagickFail)
+        goto round_rectangle_done;
+    }
+  p = *pp_PrimitiveInfo + p_PIMgr->StoreStartingAt;
+  if ((status=TracePoint(p,(*pp_PrimitiveInfo+InitialStoreStartingAt)->point))  == MagickFail)
+    goto round_rectangle_done;
   p+=p->coordinates;
+  p_PIMgr->StoreStartingAt = InitialStoreStartingAt;  /* restore original value */
+
+  primitive_info = *pp_PrimitiveInfo + InitialStoreStartingAt;
   primitive_info->coordinates=p-primitive_info;
-  for (i=0; i < (long) primitive_info->coordinates; i++)
-  {
+  PRIMINF_CLEAR_FLAGS(primitive_info);
+  PRIMINF_SET_IS_CLOSED_SUBPATH(primitive_info,1);
+  /* NOTE: p pointing just past last traced point! */
+  for (p--; p > primitive_info; p--)
     p->primitive=primitive_info->primitive;
-    p--;
-  }
+
+ round_rectangle_done:;
+
+  return status;
 }
 
-static void
+static MagickPassFail
 TraceSquareLinecap(PrimitiveInfo *primitive_info,
                    const unsigned long number_vertices,const double offset)
 {
@@ -5713,10 +7227,13 @@ TraceSquareLinecap(PrimitiveInfo *primitive_info,
     dx*(distance+offset)/distance;
   primitive_info[number_vertices-1].point.y=primitive_info[j].point.y+
     dy*(distance+offset)/distance;
+
+  return MagickPass;
 }
 
 static PrimitiveInfo *
-TraceStrokePolygon(const DrawInfo *draw_info,
+TraceStrokePolygon(const Image *image,  /* added Image* param so DrawInfo::stroke_width can be clamped */
+                   const DrawInfo *draw_info,
                    const PrimitiveInfo *primitive_info)
 {
   typedef struct _LineSegment
@@ -5740,7 +7257,8 @@ TraceStrokePolygon(const DrawInfo *draw_info,
     delta_theta,
     dot_product,
     mid,
-    miterlimit;
+    miterlimit,
+    stroke_width_limited;
 
   PointInfo
     box_p[5],
@@ -5752,14 +7270,16 @@ TraceStrokePolygon(const DrawInfo *draw_info,
 
   PrimitiveInfo
     *polygon_primitive,
-    *stroke_polygon;
+    *stroke_polygon = (PrimitiveInfo *) NULL;
 
   register long
     i;
 
   unsigned long
     arc_segments,
-    max_strokes,
+    max_strokes_p,
+    max_strokes_q,
+    max_strokes_extra,
     number_vertices;
 
   unsigned long
@@ -5768,34 +7288,31 @@ TraceStrokePolygon(const DrawInfo *draw_info,
     p,
     q;
 
+  MagickPassFail
+    status = MagickPass;
+
   /*
-    Allocate paths.
+    Compute initial sizes for paths based on the number of primitive coordinates.  We
+    will always allocate max_strokes_extra additional points, so that for each loop
+    iteration there will always be enough space, provided we haven't passed
+    max_strokes_{p|q} yet.
   */
   number_vertices=primitive_info->coordinates;
-  max_strokes=2*number_vertices+6*BezierQuantum+360;
-  path_p=MagickAllocateArray(PointInfo *,max_strokes,sizeof(PointInfo));
-  if (path_p == (PointInfo *) NULL)
-    return((PrimitiveInfo *) NULL);
-  path_q=MagickAllocateArray(PointInfo *,max_strokes,sizeof(PointInfo));
-  if (path_q == (PointInfo *) NULL)
-    {
-      MagickFreeMemory(path_p);
-      return((PrimitiveInfo *) NULL);
-    }
+  max_strokes_p=max_strokes_q=2*number_vertices;
+  max_strokes_extra=6*BezierQuantum+360;  /* will always allocate this much extra */
+
+  /* moved path_p and path_q mem alloc to later since we might not need them */
+
   polygon_primitive=
     MagickAllocateArray(PrimitiveInfo *,(number_vertices+2),
-                       sizeof(PrimitiveInfo));
+                        sizeof(PrimitiveInfo));
   if (polygon_primitive == (PrimitiveInfo *) NULL)
     {
-      MagickFreeMemory(path_p);
-      MagickFreeMemory(path_q);
       return((PrimitiveInfo *) NULL);
     }
   (void) memcpy(polygon_primitive,primitive_info,number_vertices*
     sizeof(PrimitiveInfo));
-  closed_path=
-    (primitive_info[number_vertices-1].point.x == primitive_info[0].point.x) &&
-    (primitive_info[number_vertices-1].point.y == primitive_info[0].point.y);
+  closed_path=PRIMINF_GET_IS_CLOSED_SUBPATH(&primitive_info[0]);
   if ((draw_info->linejoin == RoundJoin) ||
       ((draw_info->linejoin == MiterJoin) && closed_path))
     {
@@ -5814,10 +7331,50 @@ TraceStrokePolygon(const DrawInfo *draw_info,
       break;
   }
   if (n == number_vertices)
-    n=number_vertices-1;
+    {
+      /*
+        If we get here the subpath consists entirely of "zero length" (within MagickEpsilon)
+        segments.  According to the SVG spec:  "Any zero length subpath shall not be stroked
+        if the 'stroke-linecap' property has a value of butt but shall be stroked if the
+        'stroke-linecap' property has a value of round or square".  Since 'stroke-linecap'
+        is only used for open paths, this is only significant if the path is not closed.
+      */
+      MagickBool DoStroke;
+      DoStroke = (!closed_path && (draw_info->linecap == RoundCap));
+      if  ( !DoStroke )
+        {/*skip stroking*/
+          /* create polygon with one element and 0 coords; DrawPolygonPrimitive() will ignore it */
+          stroke_polygon = MagickAllocateArray(PrimitiveInfo *,1,sizeof(PrimitiveInfo));
+          stroke_polygon[0] = polygon_primitive[0];
+          stroke_polygon[0].coordinates = 0;
+          MagickFreeMemory(polygon_primitive);
+          return(stroke_polygon);
+        }/*skip stroking*/
+      n=number_vertices-1;
+    }
+
+  /* moved path_p and path_q mem allocs to here */
+
+  /*
+    Allocate paths.
+  */
+  path_p=MagickAllocateArray(PointInfo *,max_strokes_p+max_strokes_extra,sizeof(PointInfo));
+  if (path_p == (PointInfo *) NULL)
+    {
+      MagickFreeMemory(polygon_primitive);
+      return((PrimitiveInfo *) NULL);
+    }
+  path_q=MagickAllocateArray(PointInfo *,max_strokes_q+max_strokes_extra,sizeof(PointInfo));
+  if (path_q == (PointInfo *) NULL)
+    {
+      MagickFreeMemory(path_p);
+      MagickFreeMemory(polygon_primitive);
+      return((PrimitiveInfo *) NULL);
+    }
+
   slope.p=0.0;
   inverse_slope.p=0.0;
-  if (fabs(dx.p) <= MagickEpsilon)
+  if (fabs(dx.p) < MagickEpsilon)
     {
       if (dx.p >= 0.0)
         slope.p=dy.p < 0.0 ? -1.0/MagickEpsilon : 1.0/MagickEpsilon;
@@ -5825,7 +7382,7 @@ TraceStrokePolygon(const DrawInfo *draw_info,
         slope.p=dy.p < 0.0 ? 1.0/MagickEpsilon : -1.0/MagickEpsilon;
     }
   else
-    if (fabs(dy.p) <= MagickEpsilon)
+    if (fabs(dy.p) < MagickEpsilon)
       {
         if (dy.p >= 0.0)
           inverse_slope.p=dx.p < 0.0 ? -1.0/MagickEpsilon : 1.0/MagickEpsilon;
@@ -5837,10 +7394,18 @@ TraceStrokePolygon(const DrawInfo *draw_info,
         slope.p=dy.p/dx.p;
         inverse_slope.p=(-1.0/slope.p);
       }
-  mid=ExpandAffine(&draw_info->affine)*draw_info->stroke_width/2.0;/* FIXME: 'mid' BLOWS UP  */
+
+  /* sanity check for excessively big stroke_width (ticket #515) */
+  if  ( (stroke_width_limited = STROKE_WIDTH_LIMIT(image)) > draw_info->stroke_width )
+      stroke_width_limited = draw_info->stroke_width;
+
+  mid=ExpandAffine(&draw_info->affine)*stroke_width_limited/2.0;
   miterlimit=draw_info->miterlimit*draw_info->miterlimit*mid*mid;
   if ((draw_info->linecap == SquareCap) && !closed_path)
-    TraceSquareLinecap(polygon_primitive,number_vertices,mid);
+    {
+      if ((status=TraceSquareLinecap(polygon_primitive,number_vertices,mid)) == MagickFail)
+        goto trace_stroke_polygon_done;
+    }
   offset.x=sqrt(mid*mid/(inverse_slope.p*inverse_slope.p+1.0));
   offset.y=offset.x*inverse_slope.p;
   if ((dy.p*offset.x-dx.p*offset.y) > 0.0)
@@ -5892,7 +7457,7 @@ TraceStrokePolygon(const DrawInfo *draw_info,
           slope.q=dy.q < 0.0 ? 1.0/MagickEpsilon : -1.0/MagickEpsilon;
       }
     else
-      if (fabs(dy.q) <= MagickEpsilon)
+      if (fabs(dy.q) < MagickEpsilon)
         {
           if (dy.q >= 0.0)
             inverse_slope.q=dx.q < 0.0 ? -1.0/MagickEpsilon : 1.0/MagickEpsilon;
@@ -5943,19 +7508,30 @@ TraceStrokePolygon(const DrawInfo *draw_info,
           box_q[3].y)/(slope.p-slope.q);
         box_q[4].y=slope.p*(box_q[4].x-box_q[0].x)+box_q[0].y;
       }
-    if (q >= (max_strokes-6*BezierQuantum-360))
+    if (p >= max_strokes_p)
+      {/*p pointing into extra; time to realloc*/
+         max_strokes_p+=max_strokes_extra;
+         MagickReallocMemory(PointInfo *,path_p,MagickArraySize(max_strokes_p+max_strokes_extra,sizeof(PointInfo)));
+         if (path_p == (PointInfo *) NULL)
       {
-         max_strokes+=6*BezierQuantum+360;
-         MagickReallocMemory(PointInfo *,path_p,MagickArraySize(max_strokes,sizeof(PointInfo)));
-         MagickReallocMemory(PointInfo *,path_q,MagickArraySize(max_strokes,sizeof(PointInfo)));
-         if ((path_p == (PointInfo *) NULL) || (path_q == (PointInfo *) NULL))
+             MagickFreeMemory(path_p);
+             MagickFreeMemory(path_q);
+             MagickFreeMemory(polygon_primitive);
+             return((PrimitiveInfo *) NULL);
+           }
+      }/*p pointing into extra; time to realloc*/
+    if (q >= max_strokes_q)
+      {/*q pointing into extra; time to realloc*/
+         max_strokes_q+=max_strokes_extra;
+         MagickReallocMemory(PointInfo *,path_q,MagickArraySize(max_strokes_q+max_strokes_extra,sizeof(PointInfo)));
+         if (path_q == (PointInfo *) NULL)
            {
              MagickFreeMemory(path_p);
              MagickFreeMemory(path_q);
              MagickFreeMemory(polygon_primitive);
              return((PrimitiveInfo *) NULL);
            }
-      }
+      }/*q pointing into extra; time to realloc*/
     dot_product=dx.q*dy.p-dx.p*dy.q;
     if (dot_product <= 0.0)
       switch (draw_info->linejoin)
@@ -6010,6 +7586,19 @@ TraceStrokePolygon(const DrawInfo *draw_info,
           if (theta.q < theta.p)
             theta.q+=2.0*MagickPI;
           arc_segments=(long) ceil((theta.q-theta.p)/(2.0*sqrt(1.0/mid)));
+          /* in case arc_segments is big */
+          if  ( (q+arc_segments) >= max_strokes_q )
+            {/*q+arc_segments will point into extra; time to realloc*/
+              max_strokes_q+=arc_segments+max_strokes_extra;
+              MagickReallocMemory(PointInfo *,path_q,MagickArraySize(max_strokes_q+max_strokes_extra,sizeof(PointInfo)));
+              if (path_q == (PointInfo *) NULL)
+                {
+                  MagickFreeMemory(path_p);
+                  MagickFreeMemory(path_q);
+                  MagickFreeMemory(polygon_primitive);
+                  return((PrimitiveInfo *) NULL);
+                }
+            }/*q+arc_segments will point into extra; time to realloc*/
           path_q[q].x=box_q[1].x;
           path_q[q].y=box_q[1].y;
           q++;
@@ -6081,6 +7670,19 @@ TraceStrokePolygon(const DrawInfo *draw_info,
           if (theta.p < theta.q)
             theta.p+=2.0*MagickPI;
           arc_segments=(long) ceil((theta.p-theta.q)/(2.0*sqrt(1.0/mid)));
+          /* in case arc_segments is big */
+          if  ( (p+arc_segments) >= max_strokes_p )
+            {/*p+arc_segments will point into extra; time to realloc*/
+              max_strokes_p+=arc_segments+max_strokes_extra;
+              MagickReallocMemory(PointInfo *,path_p,MagickArraySize(max_strokes_p+max_strokes_extra,sizeof(PointInfo)));
+              if (path_p == (PointInfo *) NULL)
+                {
+                  MagickFreeMemory(path_p);
+                  MagickFreeMemory(path_q);
+                  MagickFreeMemory(polygon_primitive);
+                  return((PrimitiveInfo *) NULL);
+                }
+            }/*p+arc_segments will point into extra; time to realloc*/
           path_p[p++]=box_p[1];
           for (j=1; j < arc_segments; j++)
           {
@@ -6114,7 +7716,7 @@ TraceStrokePolygon(const DrawInfo *draw_info,
   */
   stroke_polygon=
     MagickAllocateArray(PrimitiveInfo *,(p+q+2*closed_path+2),
-                       sizeof(PrimitiveInfo));
+                        sizeof(PrimitiveInfo));
   if (stroke_polygon != (PrimitiveInfo *) NULL)
     {
       for (i=0; i < (long) p; i++)
@@ -6145,8 +7747,48 @@ TraceStrokePolygon(const DrawInfo *draw_info,
       stroke_polygon[i].primitive=UndefinedPrimitive;
       stroke_polygon[0].coordinates=p+q+2*closed_path+1;
     }
+
+ trace_stroke_polygon_done:;
+
   MagickFreeMemory(path_p);
   MagickFreeMemory(path_q);
   MagickFreeMemory(polygon_primitive);
   return(stroke_polygon);
 }
+
+#if 0
+/* is the DrawInfo drawn as SVG compliant */
+static MagickBool
+IsDrawInfoClippingPath(const DrawInfo * draw_info)
+{
+  return(((draw_info->flags&0x2U)==2U)?MagickTrue:MagickFalse);
+}
+#endif
+
+/* is the DrawInfo drawn as SVG compliant */
+static MagickBool
+IsDrawInfoSVGCompliant(const DrawInfo * draw_info)
+{
+  return(((draw_info->flags&0x1U)==1U)?MagickTrue:MagickFalse);
+}
+
+/* is the DrawInfo drawn as an SVG compliant clipping path */
+static MagickBool
+IsDrawInfoSVGCompliantClippingPath(const DrawInfo * draw_info)
+{
+  return(((draw_info->flags&0x3U)==3U)?MagickTrue:MagickFalse);
+}
+
+/* tag the DrawInfo as being a clipping path or not */
+static void
+SetDrawInfoClippingPath(DrawInfo * draw_info, MagickBool ClippingPath)
+{
+  draw_info->flags = (draw_info->flags & (~0x2U)) | (ClippingPath?2U:0U);
+}
+
+/* tag the DrawInfo as being drawn as SVG compliant or not */
+static void
+SetDrawInfoSVGCompliant(DrawInfo * draw_info, MagickBool SVGCompliant)
+{
+  draw_info->flags = (draw_info->flags & (~0x1U)) | (SVGCompliant?1U:0U);
+}
index c131029..8e922f8 100644 (file)
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2003 - 2009 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Drawing methods.
 */
 #ifndef _MAGICK_RENDER_H
@@ -164,6 +164,8 @@ typedef struct _ElementReference
     *next;
 } ElementReference;
 
+struct _DrawInfoExtra;  /* forward decl.; see member "extra" below */
+
 typedef struct _DrawInfo
 {
   char
@@ -252,8 +254,20 @@ typedef struct _DrawInfo
   double
     *dash_pattern; /* Terminated by value 0.0 (i.e. < MagickEpsilon)*/
 
+#if 0
   char
     *clip_path;
+#endif
+  /*
+    Allow for expansion of DrawInfo without increasing its size.  The
+    internals are defined only in render.c.  Clients outside of render.c
+    can access the internals via the provided access functions (see below).
+
+    This location in DrawInfo used to be occupied by char *clip_path. The
+    clip_path member now lives in _DrawInfoExtra.
+  */
+  struct _DrawInfoExtra
+    *extra;
 
   SegmentInfo
     bounds;
@@ -266,7 +280,26 @@ typedef struct _DrawInfo
 
   unsigned int
     render,
-    unused1;  /* Spare. Was long-deprecated 'debug' */
+    /*
+      Bit fields in flags:
+
+        Bit 0: should this DrawInfo should be drawn as:
+          0:  normal (original behavior)
+          1:  SVG compliant
+        Bit 1: is the DrawInfo a clipping path:
+          0:  is not a clipping path
+          1:  is a clipping path
+
+      Access to these bits should be through functions (defined in render.c):
+        IsDrawInfoClippingPath()
+        IsDrawInfoSVGCompliant()
+        IsDrawInfoSVGCompliantClippingPath()
+        SetDrawInfoClippingPath()
+        SetDrawInfoSVGCompliant()
+
+      At the present time the SVG compliance bit only affects how clipping paths are drawn.
+    */
+    flags;  /* previously "unused1" */
 
   ElementReference
     element_reference;
@@ -275,6 +308,8 @@ typedef struct _DrawInfo
     signature;
 } DrawInfo;
 
+#if defined(MAGICK_IMPLEMENTATION)
+
 typedef struct _ElementInfo
 {
   double
@@ -285,6 +320,8 @@ typedef struct _ElementInfo
     angle;
 } ElementInfo;
 
+#endif /* if defined(MAGICK_IMPLEMENTATION) */
+
 typedef struct _PointInfo
 {
   double
@@ -292,6 +329,8 @@ typedef struct _PointInfo
     y;
 } PointInfo;
 
+#if defined(MAGICK_IMPLEMENTATION)
+
 typedef struct _PrimitiveInfo
 {
   PointInfo
@@ -308,8 +347,24 @@ typedef struct _PrimitiveInfo
 
   char
     *text;
+
+  /*
+    "flags" indicates:
+
+       bit 0:  shape/subpath is closed (e.g., rectangle, path with 'z' or 'Z')
+
+    Macro arg "pi" is a PrimitiveInfo *.
+    Macro arg "zero_or_one" should be 0 (turn off) or 1 (turn on).
+  */
+  unsigned long
+    flags;
+#define PRIMINF_CLEAR_FLAGS(pi) ((pi)->flags=0)
+#define PRIMINF_GET_IS_CLOSED_SUBPATH(pi) ((MagickBool)((pi)->flags&1U))
+#define PRIMINF_SET_IS_CLOSED_SUBPATH(pi,zero_or_one) ((pi)->flags=((pi)->flags&(~1U))|(unsigned long)zero_or_one)
 } PrimitiveInfo;
 
+#endif /* if defined(MAGICK_IMPLEMENTATION) */
+
 typedef struct _TypeMetric
 {
   PointInfo
@@ -348,6 +403,14 @@ extern MagickExport void
   DestroyDrawInfo(DrawInfo *),
   GetDrawInfo(const ImageInfo *,DrawInfo *);
 
+/* provide public access to the clip_path member of DrawInfo */
+extern MagickExport char
+  **DrawInfoGetClipPath(const DrawInfo *) MAGICK_FUNC_PURE;
+
+/* provide public access to the composite_path member of DrawInfo */
+extern MagickExport char
+  **DrawInfoGetCompositePath(const DrawInfo *) MAGICK_FUNC_PURE;
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif
index fc7b7e5..56fabf2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
@@ -271,26 +271,26 @@ static double BesselOrderOne(double x)
 %
 %
 */
-MagickExport Image *MagnifyImage(const Image *image,ExceptionInfo *exception)
+MagickExport Image *MagnifyImage(const Image * restrict image,ExceptionInfo *exception)
 {
 #define MagnifyImageText "[%s] Magnify...  "
 
   Image
-    *magnify_image;
+    * restrict magnify_image;
 
   long
     rows,
     y;
 
   PixelPacket
-    *scanline;
+    * restrict scanline;
 
   register long
     x;
 
   register PixelPacket
-    *p,
-    *q,
+    * restrict p,
+    * restrict q,
     *r;
 
   /*
@@ -318,8 +318,8 @@ MagickExport Image *MagnifyImage(const Image *image,ExceptionInfo *exception)
     {
       DestroyImage(magnify_image);
       ThrowImageException3(ResourceLimitError,MemoryAllocationFailed,
-                           UnableToMagnifyImage)
-        }
+                           UnableToMagnifyImage);
+    }
   /*
     Initialize magnify image pixels.
   */
@@ -457,7 +457,7 @@ MagickExport Image *MagnifyImage(const Image *image,ExceptionInfo *exception)
 %
 %
 */
-MagickExport Image *MinifyImage(const Image *image,ExceptionInfo *exception)
+MagickExport Image *MinifyImage(const Image * restrict image,ExceptionInfo *exception)
 {
 #define Minify(weight)                          \
   total.red+=(weight)*(r->red);                 \
@@ -468,11 +468,11 @@ MagickExport Image *MinifyImage(const Image *image,ExceptionInfo *exception)
 #define MinifyImageText "[%s] Minify..."
 
   Image
-    *minify_image;
+    *restrict minify_image;
 
   long
     y;
+
   /*
     Initialize minified image.
   */
@@ -535,9 +535,6 @@ MagickExport Image *MinifyImage(const Image *image,ExceptionInfo *exception)
         MagickBool
           thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_MinifyImage)
-#endif
         thread_status=status;
         if (thread_status == MagickFail)
           continue;
@@ -573,17 +570,20 @@ MagickExport Image *MinifyImage(const Image *image,ExceptionInfo *exception)
               thread_status=MagickFail;
           }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_MinifyImage)
+#  pragma omp atomic
 #endif
+      row_count++;
+      if (QuantumTick(row_count,image->rows))
+        if (!MagickMonitorFormatted(row_count,image->rows,exception,
+                                    MinifyImageText,image->filename))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
         {
-          row_count++;
-          if (QuantumTick(row_count,image->rows))
-            if (!MagickMonitorFormatted(row_count,image->rows,exception,
-                                        MinifyImageText,image->filename))
-              thread_status=MagickFail;
-          
-          if (thread_status == MagickFail)
-            status=MagickFail;
+          status=MagickFail;
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
         }
       }
   }
@@ -808,14 +808,14 @@ static double Triangle(const double x,const double support)
 }
 
 static MagickPassFail
-HorizontalFilter(const Image *source,Image *destination,
-                 const double x_factor,const FilterInfo *filter_info,
+HorizontalFilter(const Image * restrict source,Image * restrict destination,
+                 const double x_factor,const FilterInfo * restrict filter_info,
                  const double blur,ThreadViewDataSet *view_data_set,
-                 const size_t span,unsigned long *quantum,
+                 const size_t span,unsigned long * restrict quantum_p,
                  ExceptionInfo *exception)
 {
 #define ResizeImageText "[%s] Resize..."
-  
+
   double
     scale,
     support;
@@ -826,6 +826,9 @@ HorizontalFilter(const Image *source,Image *destination,
   long
     x;
 
+  unsigned long
+    quantum;
+
   MagickPassFail
     status=MagickPass;
 
@@ -833,6 +836,8 @@ HorizontalFilter(const Image *source,Image *destination,
     (void) LogMagickEvent(TransformEvent,GetMagickModule(),
                           "Enter HorizontalFilter() ...");
 
+  quantum = *quantum_p;
+
   scale=blur*Max(1.0/x_factor,1.0);
   support=scale*filter_info->support;
   destination->storage_class=source->storage_class;
@@ -850,12 +855,12 @@ HorizontalFilter(const Image *source,Image *destination,
   (void) memset(&zero,0,sizeof(DoublePixelPacket));
 #if defined(HAVE_OPENMP)
 #  if defined(TUNE_OPENMP)
-#    pragma omp parallel for schedule(runtime) shared(status)
+#    pragma omp parallel for schedule(runtime) shared(status, quantum)
 #  else
 #    if defined(USE_STATIC_SCHEDULING_ONLY)
-#      pragma omp parallel for schedule(static) shared(status)
+#      pragma omp parallel for schedule(static) shared(status, quantum)
 #    else
-#      pragma omp parallel for schedule(guided) shared(status)
+#      pragma omp parallel for schedule(guided) shared(status, quantum)
 #    endif
 #  endif
 #endif
@@ -866,19 +871,19 @@ HorizontalFilter(const Image *source,Image *destination,
         density;
 
       ContributionInfo
-        *contribution;
+        * restrict contribution;
 
       register const PixelPacket
-        *p;
+        * restrict p;
 
       register PixelPacket
-        *q = (PixelPacket *) NULL;
+        * restrict q = (PixelPacket *) NULL;
 
       const IndexPacket
-        *source_indexes;
+        * restrict source_indexes;
 
       IndexPacket
-        *indexes;
+        * restrict indexes;
 
       long
         n,
@@ -889,9 +894,6 @@ HorizontalFilter(const Image *source,Image *destination,
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_HorizontalFilter)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -926,10 +928,10 @@ HorizontalFilter(const Image *source,Image *destination,
                            contribution[n-1].pixel-contribution[0].pixel+1,
                            source->rows,exception);
       if (p == (const PixelPacket *) NULL)
-       thread_status=MagickFail;
+        thread_status=MagickFail;
 
       if (thread_status != MagickFail)
-       q=SetImagePixelsEx(destination,x,0,1,destination->rows,exception);
+        q=SetImagePixelsEx(destination,x,0,1,destination->rows,exception);
       if (q == (PixelPacket *) NULL)
         thread_status=MagickFail;
 
@@ -954,11 +956,11 @@ HorizontalFilter(const Image *source,Image *destination,
               pixel=zero;
               if ((destination->matte) || (destination->colorspace == CMYKColorspace))
                 {
-                 double
-                   transparency_coeff,
-                   normalize;
+                  double
+                    transparency_coeff,
+                    normalize;
 
-                 normalize=0.0;
+                  normalize=0.0;
                   for (i=0; i < n; i++)
                     {
                       j=y*(contribution[n-1].pixel-contribution[0].pixel+1)+
@@ -972,9 +974,9 @@ HorizontalFilter(const Image *source,Image *destination,
                       normalize += transparency_coeff;
                     }
                   normalize = 1.0 / (AbsoluteValue(normalize) <= MagickEpsilon ? 1.0 : normalize);
-                 pixel.red *= normalize;
-                 pixel.green *= normalize;
-                 pixel.blue *= normalize;
+                  pixel.red *= normalize;
+                  pixel.green *= normalize;
+                  pixel.blue *= normalize;
                   q[y].red=RoundDoubleToQuantum(pixel.red);
                   q[y].green=RoundDoubleToQuantum(pixel.green);
                   q[y].blue=RoundDoubleToQuantum(pixel.blue);
@@ -1010,34 +1012,42 @@ HorizontalFilter(const Image *source,Image *destination,
             thread_status=MagickFail;
         }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_HorizontalFilter)
+#  pragma omp flush (quantum)
 #endif
-      {
-        if (QuantumTick(*quantum,span))
-          if (!MagickMonitorFormatted(*quantum,span,exception,
-                                      ResizeImageText,source->filename))
-            thread_status=MagickFail;
+      if (QuantumTick(quantum,span))
+        if (!MagickMonitorFormatted(quantum,span,exception,
+                                    ResizeImageText,source->filename))
+          thread_status=MagickFail;
 
-        (*quantum)++;
-          
-        if (thread_status == MagickFail)
+#if defined(HAVE_OPENMP)
+#  pragma omp atomic
+#endif
+      quantum++;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
 
   if (IsEventLogging())
     (void) LogMagickEvent(TransformEvent,GetMagickModule(),
                           "%s exit HorizontalFilter()",
-                         (status == MagickFail ? "Error" : "Normal"));
+                          (status == MagickFail ? "Error" : "Normal"));
+
+  *quantum_p = quantum;
 
   return (status);
 }
 
 static MagickPassFail
-VerticalFilter(const Image *source,Image *destination,
-               const double y_factor,const FilterInfo *filter_info,
+VerticalFilter(const Image * restrict source,Image * restrict destination,
+               const double y_factor,const FilterInfo * restrict filter_info,
                const double blur,ThreadViewDataSet *view_data_set,
-               const size_t span,unsigned long *quantum,
+               const size_t span,unsigned long * restrict quantum_p,
                ExceptionInfo *exception)
 {
   double
@@ -1050,6 +1060,9 @@ VerticalFilter(const Image *source,Image *destination,
   long
     y;
 
+  unsigned long
+    quantum;
+
   MagickPassFail
     status=MagickPass;
 
@@ -1057,6 +1070,8 @@ VerticalFilter(const Image *source,Image *destination,
     (void) LogMagickEvent(TransformEvent,GetMagickModule(),
                           "Enter VerticalFilter() ...");
 
+  quantum = *quantum_p;
+
   /*
     Apply filter to resize vertically from source to destination.
   */
@@ -1077,12 +1092,12 @@ VerticalFilter(const Image *source,Image *destination,
   (void) memset(&zero,0,sizeof(DoublePixelPacket));
 #if defined(HAVE_OPENMP)
 #  if defined(TUNE_OPENMP)
-#    pragma omp parallel for schedule(runtime) shared(status)
+#    pragma omp parallel for schedule(runtime) shared(status, quantum)
 #  else
 #    if defined(USE_STATIC_SCHEDULING_ONLY)
-#      pragma omp parallel for schedule(static) shared(status)
+#      pragma omp parallel for schedule(static) shared(status, quantum)
 #    else
-#      pragma omp parallel for schedule(guided) shared(status)
+#      pragma omp parallel for schedule(guided) shared(status, quantum)
 #    endif
 #  endif
 #endif
@@ -1093,19 +1108,19 @@ VerticalFilter(const Image *source,Image *destination,
         density;
 
       ContributionInfo
-        *contribution;
+        * restrict contribution;
 
       register const PixelPacket
-        *p;
-    
+        * restrict p;
+
       register PixelPacket
-        *q = (PixelPacket *) NULL;
+        * restrict q = (PixelPacket *) NULL;
 
       const IndexPacket
-        *source_indexes;
+        * restrict source_indexes;
 
       IndexPacket
-        *indexes;
+        * restrict indexes;
 
       long
         n,
@@ -1116,9 +1131,6 @@ VerticalFilter(const Image *source,Image *destination,
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_VerticalFilter)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -1152,10 +1164,10 @@ VerticalFilter(const Image *source,Image *destination,
                            contribution[n-1].pixel-contribution[0].pixel+1,
                            exception);
       if (p == (const PixelPacket *) NULL)
-       thread_status=MagickFail;
+        thread_status=MagickFail;
 
       if (thread_status != MagickFail)
-       q=SetImagePixelsEx(destination,0,y,destination->columns,1,exception);
+        q=SetImagePixelsEx(destination,0,y,destination->columns,1,exception);
       if (q == (PixelPacket *) NULL)
         thread_status=MagickFail;
 
@@ -1180,11 +1192,11 @@ VerticalFilter(const Image *source,Image *destination,
               pixel=zero;
               if ((source->matte) || (source->colorspace == CMYKColorspace))
                 {
-                 double
-                   transparency_coeff,
-                   normalize;
+                  double
+                    transparency_coeff,
+                    normalize;
 
-                 normalize=0.0;
+                  normalize=0.0;
                   for (i=0; i < n; i++)
                     {
                       j=(long) ((contribution[i].pixel-contribution[0].pixel)*
@@ -1199,9 +1211,9 @@ VerticalFilter(const Image *source,Image *destination,
                     }
 
                   normalize = 1.0 / (AbsoluteValue(normalize) <= MagickEpsilon ? 1.0 : normalize);
-                 pixel.red *= normalize;
-                 pixel.green *= normalize;
-                 pixel.blue *= normalize;
+                  pixel.red *= normalize;
+                  pixel.green *= normalize;
+                  pixel.blue *= normalize;
                   q[x].red=RoundDoubleToQuantum(pixel.red);
                   q[x].green=RoundDoubleToQuantum(pixel.green);
                   q[x].blue=RoundDoubleToQuantum(pixel.blue);
@@ -1237,25 +1249,33 @@ VerticalFilter(const Image *source,Image *destination,
             thread_status=MagickFail;
         }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_VerticalFilter)
+#  pragma omp flush (quantum)
 #endif
-      {
-        if (QuantumTick(*quantum,span))
-          if (!MagickMonitorFormatted(*quantum,span,exception,
-                                      ResizeImageText,source->filename))
-            thread_status=MagickFail;
-        
-        (*quantum)++;
-        
-        if (thread_status == MagickFail)
+      if (QuantumTick(quantum,span))
+        if (!MagickMonitorFormatted(quantum,span,exception,
+                                    ResizeImageText,source->filename))
+          thread_status=MagickFail;
+
+#if defined(HAVE_OPENMP)
+#  pragma omp atomic
+#endif
+      quantum++;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
 
   if (IsEventLogging())
     (void) LogMagickEvent(TransformEvent,GetMagickModule(),
-                         "%s exit VerticalFilter()",
-                         (status == MagickFail ? "Error" : "Normal"));
+                          "%s exit VerticalFilter()",
+                          (status == MagickFail ? "Error" : "Normal"));
+
+  *quantum_p = quantum;
 
   return (status);
 }
@@ -1391,19 +1411,19 @@ MagickExport Image *ResizeImage(const Image *image,const unsigned long columns,
     {
       span=source_image->columns+resize_image->rows;
       status=HorizontalFilter(image,source_image,x_factor,&filters[i],blur,
-                             view_data_set,span,&quantum,exception);
+                              view_data_set,span,&quantum,exception);
       if (status != MagickFail)
-       status=VerticalFilter(source_image,resize_image,y_factor,&filters[i],
-                             blur,view_data_set,span,&quantum,exception);
+        status=VerticalFilter(source_image,resize_image,y_factor,&filters[i],
+                              blur,view_data_set,span,&quantum,exception);
     }
   else
     {
       span=resize_image->columns+source_image->rows;
       status=VerticalFilter(image,source_image,y_factor,&filters[i],blur,
-                           view_data_set,span,&quantum,exception);
+                            view_data_set,span,&quantum,exception);
       if (status != MagickFail)
-       status=HorizontalFilter(source_image,resize_image,x_factor,&filters[i],
-                               blur,view_data_set,span,&quantum,exception);
+        status=HorizontalFilter(source_image,resize_image,x_factor,&filters[i],
+                                blur,view_data_set,span,&quantum,exception);
     }
   /*
     Free allocated memory.
index e00f42c..1d5eb42 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 - 2012 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   ImageMagick Image Resize Methods.
 */
 #ifndef _MAGICK_RESIZE_H
index f5664e9..4f3f30a 100644 (file)
@@ -151,7 +151,7 @@ static ResourceInfo *GetResourceInfo(const ResourceType type)
 
 MagickExport MagickPassFail
 AcquireMagickResource(const ResourceType type,
-                     const magick_uint64_t size)
+                      const magick_uint64_t size)
 {
   magick_uint64_t
     value;
@@ -577,12 +577,12 @@ MagickExport void InitializeMagickResources(void)
 #if defined(HAVE_OPENMP)
     max_threads=omp_get_num_procs();
     (void) LogMagickEvent(ResourceEvent,GetMagickModule(),
-                         "%i CPU cores are available",(int) max_threads);
+                          "%i CPU cores are available",(int) max_threads);
     if ((envp=getenv("OMP_NUM_THREADS")))
       {
-       max_threads=MagickSizeStrToInt64(envp,1024);
-       (void) LogMagickEvent(ResourceEvent,GetMagickModule(),
-                             "OMP_NUM_THREADS requests %i threads",(int) max_threads);
+        max_threads=MagickSizeStrToInt64(envp,1024);
+        (void) LogMagickEvent(ResourceEvent,GetMagickModule(),
+                              "OMP_NUM_THREADS requests %i threads",(int) max_threads);
       }
     if (max_threads < 1)
       max_threads=1;
@@ -595,67 +595,67 @@ MagickExport void InitializeMagickResources(void)
 #  if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
     {
       struct rlimit
-       rlimits;
+        rlimits;
 
       rlim_t
-       margin,
-       target;
+        margin,
+        target;
 
       margin=128;
       target=(rlim_t) max_files+margin;
       if (getrlimit(RLIMIT_NOFILE, &rlimits) != -1)
-       {
-         (void) LogMagickEvent(ResourceEvent,GetMagickModule(),
-                               "System file open limits are %lu soft,"
-                               " %lu hard",
-                               (unsigned long) rlimits.rlim_cur,
-                               (unsigned long) rlimits.rlim_max);
+        {
+          (void) LogMagickEvent(ResourceEvent,GetMagickModule(),
+                                "System file open limits are %lu soft,"
+                                " %lu hard",
+                                (unsigned long) rlimits.rlim_cur,
+                                (unsigned long) rlimits.rlim_max);
 #    if defined(HAVE_SETRLIMIT)
-         if (rlimits.rlim_max < target)
-           rlimits.rlim_cur=rlimits.rlim_max;
-         if (rlimits.rlim_cur < target)
-           {
-             (void) LogMagickEvent(ResourceEvent,GetMagickModule(),
-                                   "Increasing file open soft limit from %lu "
-                                   "to %lu",
-                                   (unsigned long) rlimits.rlim_cur,
-                                   (unsigned long) target);
-             rlimits.rlim_cur=target;
-             (void) setrlimit(RLIMIT_NOFILE, &rlimits);
-           }
-         if (getrlimit(RLIMIT_NOFILE, &rlimits) != -1)
-           {
-             if (rlimits.rlim_cur < target)
-               {
-                 if (rlimits.rlim_cur > margin*2)
-                   max_files=rlimits.rlim_cur-margin;
-                 else
-                   max_files=rlimits.rlim_cur/2;
-               }
-           }
+          if (rlimits.rlim_max < target)
+            rlimits.rlim_cur=rlimits.rlim_max;
+          if (rlimits.rlim_cur < target)
+            {
+              (void) LogMagickEvent(ResourceEvent,GetMagickModule(),
+                                    "Increasing file open soft limit from %lu "
+                                    "to %lu",
+                                    (unsigned long) rlimits.rlim_cur,
+                                    (unsigned long) target);
+              rlimits.rlim_cur=target;
+              (void) setrlimit(RLIMIT_NOFILE, &rlimits);
+            }
+          if (getrlimit(RLIMIT_NOFILE, &rlimits) != -1)
+            {
+              if (rlimits.rlim_cur < target)
+                {
+                  if (rlimits.rlim_cur > margin*2)
+                    max_files=rlimits.rlim_cur-margin;
+                  else
+                    max_files=rlimits.rlim_cur/2;
+                }
+            }
 #    endif
-       }
+        }
     }
 #  elif defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
     {
       long
-       margin,
-       open_max,
-       target;
+        margin,
+        open_max,
+        target;
 
       margin=128;
       target=max_files+margin;
       open_max=sysconf(_SC_OPEN_MAX);
       (void) LogMagickEvent(ResourceEvent,GetMagickModule(),
-                           "System file open limit is %lu",
-                           (unsigned long) open_max);
+                            "System file open limit is %lu",
+                            (unsigned long) open_max);
       if (open_max < target)
-       {
-         if (open_max > margin*2)
-           max_files=open_max-margin;
-         else
-           max_files=open_max/2;
-       }
+        {
+          if (open_max > margin*2)
+            max_files=open_max-margin;
+          else
+            max_files=open_max/2;
+        }
     }
 #  endif
 
@@ -812,7 +812,7 @@ MagickExport MagickPassFail ListMagickResourceInfo(FILE *file,
     index;
 
   ARG_NOT_USED(exception);
-  
+
   LockSemaphoreInfo(resource_semaphore);
   if (file == (const FILE *) NULL)
     file=stdout;
@@ -917,10 +917,10 @@ MagickExport MagickPassFail SetMagickResourceLimit(const ResourceType type,
 
 
           FormatSize((magick_int64_t) limit, f_limit);
-         info->maximum = limit;
+          info->maximum = limit;
 #if defined(HAVE_OPENMP)
-         if (ThreadsResource == type)
-           omp_set_num_threads((int) limit);
+          if (ThreadsResource == type)
+            omp_set_num_threads((int) limit);
 #endif /* HAVE_OPENMP */
           (void) LogMagickEvent(ResourceEvent,GetMagickModule(),
                                 "Set %s resource limit to %s%s",
index ae7b5d1..8bde9d5 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 - 2015 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Resource methods.
 */
 #ifndef _MAGICK_RESOURCE_H
index 7ec5952..6426fae 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -165,6 +165,7 @@ static int
   DefineRegion(const short *,ExtentPacket *);
 
 static void
+  FreeNodes(IntervalTree *node),
   ScaleSpace(const long *,const double,double *),
   ZeroCrossHistogram(double *,const double,short *);
 \f
@@ -251,21 +252,21 @@ typedef struct _Cluster
 {
   struct _Cluster
     *next;
-  
+
   ExtentPacket
     red,
     green,
     blue;
-  
+
   magick_int64_t
     count;
-  
+
   short
     id;
 } Cluster;
 
 static MagickPassFail
-Classify(Image *image,short **extrema,
+Classify(Image * restrict image,short **extrema,
          const double cluster_threshold,
          const double weighting_exponent,
          const unsigned int verbose)
@@ -294,23 +295,23 @@ Classify(Image *image,short **extrema,
     y;
 
   PixelPacket
-    *colormap=0;
+    * restrict colormap=0;
 
   register const PixelPacket
-    *p;
+    * restrict p;
 
   register double
-    *squares;
+    * restrict squares;
 
   register IndexPacket
-    *indexes;
+    * restrict indexes;
 
   register long
     i,
     x;
 
   register PixelPacket
-    *q;
+    * restrict q;
 
   unsigned long
     number_clusters;
@@ -629,11 +630,8 @@ Classify(Image *image,short **extrema,
         thread_status;
 
       int
-       num_threads;
+        num_threads;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_Classify)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -675,13 +673,13 @@ Classify(Image *image,short **extrema,
                     q[x]=image->colormap[indexes[x]];
                     classified=MagickTrue;
 
-                   /*
-                     Re-sort array so that most frequent occurs first.
+                    /*
+                      Re-sort array so that most frequent occurs first.
 
-                     Updating cluster_array causes a multithread race
-                     condition so this chunk is only enabled in the
-                     case of one thread.
-                   */
+                      Updating cluster_array causes a multithread race
+                      condition so this chunk is only enabled in the
+                      case of one thread.
+                    */
                     if ((num_threads == 1) && (count > 0) &&
                         (cluster_array[count]->count > cluster_array[count-1]->count))
                       {
@@ -760,19 +758,22 @@ Classify(Image *image,short **extrema,
             thread_status=MagickFail;
         }
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_Classify)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,image->rows))
-          if (!MagickMonitorFormatted(row_count+image->rows,image->rows << 1,
-                                      &image->exception,
-                                      SegmentImageText,image->filename))
-            thread_status=MagickFail;
+      row_count++;
+      if (QuantumTick(row_count,image->rows))
+        if (!MagickMonitorFormatted(row_count+image->rows,image->rows << 1,
+                                    &image->exception,
+                                    SegmentImageText,image->filename))
+          thread_status=MagickFail;
 
-        if (thread_status == MagickFail)
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
   /*
     Free memory.
@@ -1191,16 +1192,24 @@ InitializeIntervalTree(const ZeroCrossing *zero_crossing,
   */
   list=MagickAllocateMemory(IntervalTree **,TreeLength*sizeof(IntervalTree *));
   if (list == (IntervalTree **) NULL)
-    return((IntervalTree *) NULL);
+    return ((IntervalTree *) NULL);
   /*
     The root is the entire histogram.
   */
   root=MagickAllocateMemory(IntervalTree *,sizeof(IntervalTree));
+  if (root == (IntervalTree *) NULL)
+    {
+      MagickFreeMemory(list);
+      return ((IntervalTree *) NULL);
+    }
   root->child=(IntervalTree *) NULL;
   root->sibling=(IntervalTree *) NULL;
   root->tau=0.0;
   root->left=0;
   root->right=255;
+  root->mean_stability=0.0;
+  root->stability=0.0;
+  (void) memset(list,0,TreeLength*sizeof(IntervalTree *));
   for (i=(-1); i < (long) number_crossings; i++)
     {
       /*
@@ -1232,6 +1241,8 @@ InitializeIntervalTree(const ZeroCrossing *zero_crossing,
                                                          sizeof(IntervalTree));
                       node=node->sibling;
                     }
+                  if (node == (IntervalTree *) NULL)
+                    goto interval_tree_alloc_failure;
                   node->tau=zero_crossing[i+1].tau;
                   node->child=(IntervalTree *) NULL;
                   node->sibling=(IntervalTree *) NULL;
@@ -1243,6 +1254,8 @@ InitializeIntervalTree(const ZeroCrossing *zero_crossing,
           if (left != head->left)
             {
               node->sibling=MagickAllocateMemory(IntervalTree *,sizeof(IntervalTree));
+              if (node->sibling == (IntervalTree *) NULL)
+                goto interval_tree_alloc_failure;
               node=node->sibling;
               node->tau=zero_crossing[i+1].tau;
               node->child=(IntervalTree *) NULL;
@@ -1259,6 +1272,12 @@ InitializeIntervalTree(const ZeroCrossing *zero_crossing,
   MeanStability(root->child);
   MagickFreeMemory(list);
   return(root);
+
+ interval_tree_alloc_failure:
+
+  MagickFreeMemory(list);
+  FreeNodes(root);
+  return ((IntervalTree *) NULL);
 }
 \f
 /*
@@ -1380,7 +1399,10 @@ OptimalTau(const long *histogram,const double max_tau,
   count=(unsigned long) ((max_tau-min_tau)/delta_tau)+2;
   zero_crossing=MagickAllocateMemory(ZeroCrossing *,count*sizeof(ZeroCrossing));
   if (zero_crossing == (ZeroCrossing *) NULL)
-    return(0.0);
+    {
+      MagickFreeMemory(list);
+      return(0.0);
+    }
   for (i=0; i < (long) count; i++)
     zero_crossing[i].tau=(-1);
   /*
@@ -1439,7 +1461,11 @@ OptimalTau(const long *histogram,const double max_tau,
   */
   root=InitializeIntervalTree(zero_crossing,number_crossings);
   if (root == (IntervalTree *) NULL)
-    return(0.0);
+    {
+      MagickFreeMemory(zero_crossing);
+      MagickFreeMemory(list);
+      return(0.0);
+    }
   /*
     Find active nodes:  stability is greater (or equal) to the mean stability of
     its children.
index bccfe6b..c837ede 100644 (file)
 
 #if defined(USE_PTHREAD_LOCKS)
 #  include <pthread.h>
-#  define PTHREAD_MUTEX_DESTROY(semaphore_mutex)                       \
-  {                                                                    \
-    int                                                                        \
-      err_status;                                                      \
-                                                                       \
-    if ((err_status = pthread_mutex_destroy(semaphore_mutex)) != 0)    \
-      {                                                                        \
-        errno=err_status;                                              \
-       MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
-                         UnableToDestroySemaphore);                    \
-      }                                                                        \
+#  define PTHREAD_MUTEX_DESTROY(semaphore_mutex)                        \
+  {                                                                     \
+    int                                                                 \
+      err_status;                                                       \
+                                                                        \
+    if ((err_status = pthread_mutex_destroy(semaphore_mutex)) != 0)     \
+      {                                                                 \
+        errno=err_status;                                               \
+        MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
+                          UnableToDestroySemaphore);                    \
+      }                                                                 \
   }
-#  define PTHREAD_MUTEXATTR_DESTROY(mutexattr)                         \
-  {                                                                    \
-    int                                                                        \
-      err_status;                                                      \
-                                                                       \
-    if ((err_status = pthread_mutexattr_destroy(mutexattr)) != 0)      \
-      {                                                                        \
-        errno=err_status;                                              \
-       MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
-                         UnableToDestroySemaphore);                    \
-      }                                                                        \
+#  define PTHREAD_MUTEXATTR_DESTROY(mutexattr)                          \
+  {                                                                     \
+    int                                                                 \
+      err_status;                                                       \
+                                                                        \
+    if ((err_status = pthread_mutexattr_destroy(mutexattr)) != 0)       \
+      {                                                                 \
+        errno=err_status;                                               \
+        MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
+                          UnableToDestroySemaphore);                    \
+      }                                                                 \
   }
-#  define PTHREAD_MUTEXATTR_INIT(mutexattr)                            \
-  {                                                                    \
-    int                                                                        \
-      err_status;                                                      \
-                                                                       \
-    if ((err_status = pthread_mutexattr_init(mutexattr)) != 0)         \
-      {                                                                        \
-        errno=err_status;                                              \
-       MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
-                         UnableToInitializeSemaphore);                 \
-      }                                                                        \
+#  define PTHREAD_MUTEXATTR_INIT(mutexattr)                             \
+  {                                                                     \
+    int                                                                 \
+      err_status;                                                       \
+                                                                        \
+    if ((err_status = pthread_mutexattr_init(mutexattr)) != 0)          \
+      {                                                                 \
+        errno=err_status;                                               \
+        MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
+                          UnableToInitializeSemaphore);                 \
+      }                                                                 \
   }
-#  define PTHREAD_MUTEXATTR_SETTYPE(mutexattr,mutexattrtype)           \
-  {                                                                    \
-    int                                                                        \
-      err_status;                                                      \
-                                                                       \
+#  define PTHREAD_MUTEXATTR_SETTYPE(mutexattr,mutexattrtype)            \
+  {                                                                     \
+    int                                                                 \
+      err_status;                                                       \
+                                                                        \
     if ((err_status = pthread_mutexattr_settype(mutexattr,mutexattrtype)) != 0) \
-      {                                                                        \
-        errno=err_status;                                              \
-       MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
-                         UnableToInitializeSemaphore);                 \
-      }                                                                        \
+      {                                                                 \
+        errno=err_status;                                               \
+        MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
+                          UnableToInitializeSemaphore);                 \
+      }                                                                 \
   }
-#  define PTHREAD_MUTEX_INIT(semaphore_mutex,mutexattr)                        \
-  {                                                                    \
-    int                                                                        \
-      err_status;                                                      \
-                                                                       \
+#  define PTHREAD_MUTEX_INIT(semaphore_mutex,mutexattr)                 \
+  {                                                                     \
+    int                                                                 \
+      err_status;                                                       \
+                                                                        \
     if ((err_status = pthread_mutex_init(semaphore_mutex,mutexattr)) != 0) \
-      {                                                                        \
-        errno=err_status;                                              \
-       MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
-                         UnableToInitializeSemaphore);                 \
-      }                                                                        \
+      {                                                                 \
+        errno=err_status;                                               \
+        MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
+                          UnableToInitializeSemaphore);                 \
+      }                                                                 \
   }
-#  define PTHREAD_MUTEX_LOCK(semaphore_mutex)                          \
-  {                                                                    \
-    int                                                                        \
-      err_status;                                                      \
-                                                                       \
-    if ((err_status = pthread_mutex_lock(semaphore_mutex)) != 0)       \
-      {                                                                        \
-        errno=err_status;                                              \
-       MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
-                         UnableToLockSemaphore);                       \
-      }                                                                        \
+#  define PTHREAD_MUTEX_LOCK(semaphore_mutex)                           \
+  {                                                                     \
+    int                                                                 \
+      err_status;                                                       \
+                                                                        \
+    if ((err_status = pthread_mutex_lock(semaphore_mutex)) != 0)        \
+      {                                                                 \
+        errno=err_status;                                               \
+        MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
+                          UnableToLockSemaphore);                       \
+      }                                                                 \
   }
-#  define PTHREAD_MUTEX_UNLOCK(semaphore_mutex)                                \
-  {                                                                    \
-    int                                                                        \
-      err_status;                                                      \
-                                                                       \
-    if ((err_status = pthread_mutex_unlock(semaphore_mutex)) != 0)     \
-      {                                                                        \
-        errno=err_status;                                              \
-       MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
-                         UnableToUnlockSemaphore);                     \
-      }                                                                        \
+#  define PTHREAD_MUTEX_UNLOCK(semaphore_mutex)                         \
+  {                                                                     \
+    int                                                                 \
+      err_status;                                                       \
+                                                                        \
+    if ((err_status = pthread_mutex_unlock(semaphore_mutex)) != 0)      \
+      {                                                                 \
+        errno=err_status;                                               \
+        MagickFatalError3(ResourceLimitFatalError,SemaporeOperationFailed, \
+                          UnableToUnlockSemaphore);                     \
+      }                                                                 \
   }
 #endif
 
@@ -153,22 +153,22 @@ struct _SemaphoreInfo
 #endif /* defined(USE_OPENMP_LOCKS) */
 #if defined(USE_PTHREAD_LOCKS)
   pthread_mutex_t
-    mutex;             /* POSIX thread mutex */
+    mutex;              /* POSIX thread mutex */
 #endif /* if defined(USE_PTHREAD_LOCKS) */
 #if defined(USE_WIN32_LOCKS)
   CRITICAL_SECTION
-    mutex;             /* Windows critical section */
+    mutex;              /* Windows critical section */
 #endif /* defined(USE_WIN32_LOCKS) */
 
   unsigned long
-    signature;         /* Used to validate structure */
+    signature;          /* Used to validate structure */
 };
 \f
 /*
   Static declaractions.
 */
 #if defined(USE_OPENMP_LOCKS)
-static omp_lock_t 
+static omp_lock_t
   semaphore_mutex;
 
 static unsigned int
@@ -323,8 +323,8 @@ MagickExport SemaphoreInfo *AllocateSemaphoreInfo(void)
     Allocate semaphore.
   */
   semaphore_info=MagickAllocateAlignedMemory(SemaphoreInfo *,
-                                            MAGICK_CACHE_LINE_SIZE,
-                                            sizeof(SemaphoreInfo));
+                                             MAGICK_CACHE_LINE_SIZE,
+                                             sizeof(SemaphoreInfo));
   if (semaphore_info == (SemaphoreInfo *) NULL)
     MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
       UnableToAllocateSemaphoreInfo);
@@ -337,7 +337,7 @@ MagickExport SemaphoreInfo *AllocateSemaphoreInfo(void)
 #endif /* defined(USE_OPENMP_LOCKS) */
 #if defined(USE_PTHREAD_LOCKS)
   {
-    pthread_mutexattr_t 
+    pthread_mutexattr_t
       mutexattr;
 
     PTHREAD_MUTEXATTR_INIT(&mutexattr);
@@ -359,7 +359,7 @@ MagickExport SemaphoreInfo *AllocateSemaphoreInfo(void)
 #if defined(USE_WIN32_LOCKS)
   InitializeCriticalSection(&semaphore_info->mutex);
 #endif
-  
+
   semaphore_info->signature=MagickSignature;
   return(semaphore_info);
 }
index c413b44..50332f1 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003-2010 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Methods to lock and unlock semaphores.
 */
 #ifndef _MAGICK_SEMAPHORE_H
index 3a228ea..6b6170a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -85,7 +85,7 @@
 */
 MagickExport Image *
 AffineTransformImage(const Image *image,const AffineMatrix *affine,
-                    ExceptionInfo *exception)
+                     ExceptionInfo *exception)
 {
   AffineMatrix
     transform;
@@ -171,7 +171,7 @@ AffineTransformImage(const Image *image,const AffineMatrix *affine,
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  AutoOrientImage() returns an image adjusted so that its orientation is
-%  suitable for viewing (i.e. top-left orientation).  
+%  suitable for viewing (i.e. top-left orientation).
 %
 %  The format of the AutoOrientImage method is:
 %
@@ -319,9 +319,9 @@ AutoOrientImage(const Image *image,
 */
 static MagickPassFail
 CropToFitImage(Image **image,
-              const double x_shear,const double y_shear,
-              const double width,const double height,
-              const unsigned int rotate,ExceptionInfo *exception)
+               const double x_shear,const double y_shear,
+               const double width,const double height,
+               const unsigned int rotate,ExceptionInfo *exception)
 {
   Image
     *crop_image;
@@ -424,7 +424,7 @@ CropToFitImage(Image **image,
 #endif
 static Image *
 IntegralRotateImage(const Image *image,unsigned int rotations,
-                   ExceptionInfo *exception)
+                    ExceptionInfo *exception)
 {
   char
     message[MaxTextExtent];
@@ -456,58 +456,58 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
     unsigned long
       clone_columns=0,
       clone_rows=0;
-    
+
     switch (rotations)
       {
       case 0:
-       clone_columns=0;
-       clone_rows=0;
-       break;
+        clone_columns=0;
+        clone_rows=0;
+        break;
       case 2:
-       clone_columns=image->columns;
-       clone_rows=image->rows;
-       break;
+        clone_columns=image->columns;
+        clone_rows=image->rows;
+        break;
       case 1:
       case 3:
-       clone_columns=image->rows;
-       clone_rows=image->columns;
-       break;
+        clone_columns=image->rows;
+        clone_rows=image->columns;
+        break;
       }
     rotate_image=CloneImage(image,clone_columns,clone_rows,True,exception);
     if (rotate_image == (Image *) NULL)
       return((Image *) NULL);
     if (rotations != 0)
       if (ModifyCache(rotate_image,exception) != MagickPass)
-       {
-         DestroyImage(rotate_image);
-         return (Image *) NULL;
-       }
+        {
+          DestroyImage(rotate_image);
+          return (Image *) NULL;
+        }
   }
 
   tile_height_max=tile_width_max=2048/sizeof(PixelPacket); /* 2k x 2k = 4MB */
   if ((rotations == 1) || (rotations == 3))
     {
       /*
-       Allow override of tile geometry for testing.
+        Allow override of tile geometry for testing.
       */
       const char *
-       value;
+        value;
 
       if (!GetPixelCacheInCore(image) || !GetPixelCacheInCore(rotate_image))
-       tile_height_max=tile_width_max=8192/sizeof(PixelPacket); /* 8k x 8k = 64MB */
+        tile_height_max=tile_width_max=8192/sizeof(PixelPacket); /* 8k x 8k = 64MB */
 
       if ((value=getenv("MAGICK_ROTATE_TILE_GEOMETRY")))
-       {
-         double
-           width,
-           height;
-         
-         if (GetMagickDimension(value,&width,&height,NULL,NULL) == 2)
-           {
-             tile_height_max=(unsigned long) height;
-             tile_width_max=(unsigned long) width;
-           }
-       }
+        {
+          double
+            width,
+            height;
+
+          if (GetMagickDimension(value,&width,&height,NULL,NULL) == 2)
+            {
+              tile_height_max=(unsigned long) height;
+              tile_width_max=(unsigned long) width;
+            }
+        }
     }
 
   /*
@@ -520,10 +520,10 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
         /*
           Rotate 0 degrees (nothing more to do).
         */
-       (void) strlcpy(message,"[%s] Rotate: 0 degrees...",sizeof(message));
-       if (!MagickMonitorFormatted(image->rows-1,image->rows,exception,
-                                   message,image->filename))
-         status=MagickFail;
+        (void) strlcpy(message,"[%s] Rotate: 0 degrees...",sizeof(message));
+        if (!MagickMonitorFormatted(image->rows-1,image->rows,exception,
+                                    message,image->filename))
+          status=MagickFail;
         break;
       }
     case 1:
@@ -549,7 +549,7 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
 
         (void) strlcpy(message,"[%s] Rotate: 90 degrees...",sizeof(message));
         total_tiles=(((image->rows/tile_height_max)+1)*
-                     ((image->columns/tile_width_max)+1));        
+                     ((image->columns/tile_width_max)+1));
         tile=0;
 
 #if defined(IntegralRotateImageUseOpenMP)
@@ -569,11 +569,6 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
             MagickPassFail
               thread_status;
 
-#if defined(IntegralRotateImageUseOpenMP)
-#  if defined(HAVE_OPENMP)
-#    pragma omp critical (GM_IntegralRotateImage)
-#  endif
-#endif
             thread_status=status;
             if (thread_status == MagickFail)
               continue;
@@ -589,7 +584,7 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
                   tile_height;
 
                 const PixelPacket
-                  *tile_pixels;
+                  *tile_pixels=(const PixelPacket *) NULL;
 
                 long
                   y;
@@ -627,13 +622,13 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
                   {
                     register const PixelPacket
                       *p;
-                    
+
                     register PixelPacket
                       *q;
 
                     register const IndexPacket
                       *indexes;
-        
+
                     IndexPacket
                       *rotate_indexes;
 
@@ -651,7 +646,7 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
                       DirectClass pixels
                     */
                     p=tile_pixels+(tile_height-1)*tile_width + y;
-                    for (x=tile_height; x != 0; x--) 
+                    for (x=tile_height; x != 0; x--)
                       {
                         *q = *p;
                         q++;
@@ -668,13 +663,13 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
                           {
                             register IndexPacket
                               *iq;
-                            
+
                             register const IndexPacket
                               *ip;
 
                             iq=rotate_indexes;
                             ip=indexes+(tile_height-1)*tile_width + y;
-                            for (x=tile_height; x != 0; x--) 
+                            for (x=tile_height; x != 0; x--)
                               {
                                 *iq = *ip;
                                 iq++;
@@ -691,19 +686,33 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
 
 #if defined(IntegralRotateImageUseOpenMP)
 #  if defined(HAVE_OPENMP)
-#    pragma omp critical (GM_IntegralRotateImage)
+#    pragma omp atomic
 #  endif
 #endif
-                {
-                  tile++;
-                  if (QuantumTick(tile,total_tiles))
-                    if (!MagickMonitorFormatted(tile,total_tiles,exception,
-                                                message,image->filename))
-                      thread_status=MagickFail;
-                  
-                  if (thread_status == MagickFail)
+                tile++;
+                if (QuantumTick(tile,total_tiles))
+                  if (!MagickMonitorFormatted(tile,total_tiles,exception,
+                                              message,image->filename))
+                    thread_status=MagickFail;
+
+                if (thread_status == MagickFail)
+                  {
                     status=MagickFail;
-                }
+#if defined(IntegralRotateImageUseOpenMP)
+#  if defined(HAVE_OPENMP)
+#    pragma omp flush (status)
+#  endif
+#endif
+                  }
+              }
+            if (thread_status == MagickFail)
+              {
+                status = thread_status;
+#if defined(IntegralRotateImageUseOpenMP)
+#  if defined(HAVE_OPENMP)
+#    pragma omp flush (status)
+#  endif
+#endif
               }
           }
         Swap(page.width,page.height);
@@ -749,7 +758,7 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
 
             register const IndexPacket
               *indexes;
-        
+
             IndexPacket
               *rotate_indexes;
 
@@ -759,11 +768,6 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
             MagickPassFail
               thread_status;
 
-#if defined(IntegralRotateImageUseOpenMP)
-#  if defined(HAVE_OPENMP)
-#    pragma omp critical (GM_IntegralRotateImage)
-#  endif
-#endif
             thread_status=status;
             if (thread_status == MagickFail)
               continue;
@@ -789,19 +793,24 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
               }
 #if defined(IntegralRotateImageUseOpenMP)
 #  if defined(HAVE_OPENMP)
-#    pragma omp critical (GM_IntegralRotateImage)
+#    pragma omp atomic
 #  endif
 #endif
-            {
-              row_count++;
-              if (QuantumTick(row_count,image->rows))
-                if (!MagickMonitorFormatted(row_count,image->rows,exception,
-                                            message,image->filename))
-                  thread_status=MagickFail;
-                  
-              if (thread_status == MagickFail)
+            row_count++;
+            if (QuantumTick(row_count,image->rows))
+              if (!MagickMonitorFormatted(row_count,image->rows,exception,
+                                          message,image->filename))
+                thread_status=MagickFail;
+
+            if (thread_status == MagickFail)
+              {
                 status=MagickFail;
-            }
+#if defined(IntegralRotateImageUseOpenMP)
+#  if defined(HAVE_OPENMP)
+#    pragma omp flush (status)
+#  endif
+#endif
+              }
           }
         page.x=(long) (page.width-rotate_image->columns-page.x);
         page.y=(long) (page.height-rotate_image->rows-page.y);
@@ -850,11 +859,6 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
             MagickPassFail
               thread_status;
 
-#if defined(IntegralRotateImageUseOpenMP)
-#  if defined(HAVE_OPENMP)
-#    pragma omp critical (GM_IntegralRotateImage)
-#  endif
-#endif
             thread_status=status;
             if (thread_status == MagickFail)
               continue;
@@ -866,15 +870,15 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
                   tile_height;
 
                 long
-                  dest_tile_x,
-                  dest_tile_y;
+                  dest_tile_x=0,
+                  dest_tile_y=0;
 
                 long
-                  y;
+                  y=0;
 
                 const PixelPacket
-                  *tile_pixels;
-                    
+                  *tile_pixels = (const PixelPacket *) NULL;
+
                 /*
                   Compute image region corresponding to tile.
                 */
@@ -908,7 +912,7 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
                   {
                     register const PixelPacket
                       *p;
-                    
+
                     register PixelPacket
                       *q;
 
@@ -949,7 +953,7 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
                           {
                             register IndexPacket
                               *iq;
-                            
+
                             register const IndexPacket
                               *ip;
 
@@ -972,22 +976,37 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
 
 #if defined(IntegralRotateImageUseOpenMP)
 #  if defined(HAVE_OPENMP)
-#    pragma omp critical (GM_IntegralRotateImage)
+#    pragma omp atomic
 #  endif
 #endif
-                {
-                  tile++;
-                  if (QuantumTick(tile,total_tiles))
-                    if (!MagickMonitorFormatted(tile,total_tiles,exception,
-                                                message,image->filename))
-                      thread_status=MagickFail;
+                tile++;
+                if (QuantumTick(tile,total_tiles))
+                  if (!MagickMonitorFormatted(tile,total_tiles,exception,
+                                              message,image->filename))
+                    thread_status=MagickFail;
 
-                 if (thread_status == MagickFail)
-                   status=MagickFail;
-                }
+                if (thread_status == MagickFail)
+                  {
+                    status=MagickFail;
+#if defined(IntegralRotateImageUseOpenMP)
+#  if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#  endif
+#endif
+                  }
 
                 if (thread_status == MagickFail)
-                 break;
+                  break;
+              }
+
+            if (thread_status == MagickFail)
+              {
+                status = thread_status;
+#if defined(IntegralRotateImageUseOpenMP)
+#  if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#  endif
+#endif
               }
           }
         Swap(page.width,page.height);
@@ -997,9 +1016,17 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
       }
     }
 
-  rotate_image->page=page;
-  rotate_image->is_grayscale=image->is_grayscale;
-  rotate_image->is_monochrome=image->is_monochrome;
+  if (status == MagickFail)
+    {
+      DestroyImage(rotate_image);
+      rotate_image = (Image *) NULL;
+    }
+  else
+    {
+      rotate_image->page=page;
+      rotate_image->is_grayscale=image->is_grayscale;
+      rotate_image->is_monochrome=image->is_monochrome;
+    }
   return(rotate_image);
 }
 \f
@@ -1041,8 +1068,8 @@ IntegralRotateImage(const Image *image,unsigned int rotations,
 
 static MagickPassFail
 XShearImage(Image *image,const double degrees,
-           const unsigned long width,const unsigned long height,
-           const long x_offset,long y_offset,ExceptionInfo *exception)
+            const unsigned long width,const unsigned long height,
+            const long x_offset,long y_offset,ExceptionInfo *exception)
 {
 #define XShearImageText  "[%s] X Shear: %+g degrees, region %lux%lu%+ld%+ld...  "
 
@@ -1110,9 +1137,6 @@ XShearImage(Image *image,const double degrees,
       MagickPassFail
         thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_XShearImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -1181,20 +1205,23 @@ XShearImage(Image *image,const double degrees,
             thread_status=MagickFail;
 
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_XShearImage)
+#  pragma omp atomic
 #endif
-          {
-            row_count++;
-            if (QuantumTick(row_count,height))
-              if (!MagickMonitorFormatted(row_count,height,exception,
-                                          XShearImageText,image->filename,
-                                         degrees,width,height,
-                                         x_offset,y_offset))
-                thread_status=MagickFail;
-            
-            if (thread_status == MagickFail)
+          row_count++;
+          if (QuantumTick(row_count,height))
+            if (!MagickMonitorFormatted(row_count,height,exception,
+                                        XShearImageText,image->filename,
+                                        degrees,width,height,
+                                        x_offset,y_offset))
+              thread_status=MagickFail;
+
+          if (thread_status == MagickFail)
+            {
               status=MagickFail;
-          }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+            }
 
           continue;
         }
@@ -1268,20 +1295,23 @@ XShearImage(Image *image,const double degrees,
       if (!SyncImagePixelsEx(image,exception))
         thread_status=MagickFail;
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_XShearImage)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,height))
-          if (!MagickMonitorFormatted(row_count,height,exception,
-                                          XShearImageText,image->filename,
-                                         degrees,width,height,
-                                         x_offset,y_offset))
-            thread_status=MagickFail;
-        
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,height))
+        if (!MagickMonitorFormatted(row_count,height,exception,
+                                    XShearImageText,image->filename,
+                                    degrees,width,height,
+                                    x_offset,y_offset))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
   if (is_grayscale && IsGray(image->background_color))
     image->is_grayscale=True;
@@ -1327,8 +1357,8 @@ XShearImage(Image *image,const double degrees,
 */
 static MagickPassFail
 YShearImage(Image *image,const double degrees,
-           const unsigned long width,const unsigned long height,long x_offset,
-           const long y_offset,ExceptionInfo *exception)
+            const unsigned long width,const unsigned long height,long x_offset,
+            const long y_offset,ExceptionInfo *exception)
 {
 #define YShearImageText  "[%s] Y Shear: %+g degrees, region %lux%lu%+ld%+ld...  "
 
@@ -1396,9 +1426,6 @@ YShearImage(Image *image,const double degrees,
       MagickPassFail
         thread_status;
 
-#if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_YShearImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -1467,20 +1494,23 @@ YShearImage(Image *image,const double degrees,
             thread_status=MagickFail;
 
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_YShearImage)
+#  pragma omp atomic
 #endif
-          {
-            row_count++;
-            if (QuantumTick(row_count,width))
-              if (!MagickMonitorFormatted(row_count,width,exception,
-                                          YShearImageText,image->filename,
-                                         degrees,width,height,
-                                         x_offset,y_offset))
-                thread_status=MagickFail;
-            
-            if (thread_status == MagickFail)
+          row_count++;
+          if (QuantumTick(row_count,width))
+            if (!MagickMonitorFormatted(row_count,width,exception,
+                                        YShearImageText,image->filename,
+                                        degrees,width,height,
+                                        x_offset,y_offset))
+              thread_status=MagickFail;
+
+          if (thread_status == MagickFail)
+            {
               status=MagickFail;
-          }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+            }
 
           continue;
         }
@@ -1555,20 +1585,23 @@ YShearImage(Image *image,const double degrees,
         thread_status=MagickFail;
 
 #if defined(HAVE_OPENMP)
-#  pragma omp critical (GM_YShearImage)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,width))
-          if (!MagickMonitorFormatted(row_count,width,exception,
-                                      YShearImageText,image->filename,
-                                     degrees,width,height,
-                                     x_offset,y_offset))
-            thread_status=MagickFail;
-        
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,width))
+        if (!MagickMonitorFormatted(row_count,width,exception,
+                                    YShearImageText,image->filename,
+                                    degrees,width,height,
+                                    x_offset,y_offset))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
   if (is_grayscale && IsGray(image->background_color))
     image->is_grayscale=True;
@@ -1657,9 +1690,9 @@ RotateImage(const Image *image,const double degrees,ExceptionInfo *exception)
   assert(image->signature == MagickSignature);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
-  angle=degrees;
-  while (angle < -45.0)
-    angle+=360.0;
+  angle = degrees - 360.0*(int)(degrees / 360);
+  if(angle < -45.0) angle+=360.0;
+
   for (rotations=0; angle > 45.0; rotations++)
     angle-=90.0;
   rotations%=4;
@@ -1707,19 +1740,19 @@ RotateImage(const Image *image,const double degrees,ExceptionInfo *exception)
   */
   rotate_image->storage_class=DirectClass;
   rotate_image->matte|=rotate_image->background_color.opacity != OpaqueOpacity;
-  
+
   if (XShearImage(rotate_image,shear.x,width,height,
           x_offset,y_offset,exception) != MagickPass)
     goto rotate_image_exception;
 
   if (YShearImage(rotate_image,shear.y,shear1_width,height,
-                 (long) (rotate_image->columns-shear1_width)/2,y_offset,exception)
+                  (long) (rotate_image->columns-shear1_width)/2,y_offset,exception)
       != MagickPass)
     goto rotate_image_exception;
 
   if (XShearImage(rotate_image,shear.x,shear1_width,shear2_height,
-                 (long) (rotate_image->columns-shear1_width)/2,
-                 (long) (rotate_image->rows-shear2_height)/2,exception)
+                  (long) (rotate_image->columns-shear1_width)/2,
+                  (long) (rotate_image->rows-shear2_height)/2,exception)
      != MagickPass)
     goto rotate_image_exception;
 
@@ -1785,7 +1818,7 @@ RotateImage(const Image *image,const double degrees,ExceptionInfo *exception)
 */
 MagickExport Image *
 ShearImage(const Image *image,const double x_shear,
-          const double y_shear,ExceptionInfo *exception)
+           const double y_shear,ExceptionInfo *exception)
 {
   Image
     *integral_image = (Image *) NULL,
@@ -1820,7 +1853,7 @@ ShearImage(const Image *image,const double x_shear,
   shear.x=(-tan(DegreesToRadians(x_shear)/2.0));
   shear.y=sin(DegreesToRadians(y_shear));
   (void) LogMagickEvent(TransformEvent,GetMagickModule(),
-                       "Shear angles x,y: %g,%g degrees", shear.x, shear.y);
+                        "Shear angles x,y: %g,%g degrees", shear.x, shear.y);
   if ((shear.x == 0.0) && (shear.y == 0.0))
     return(integral_image);
 
@@ -1846,19 +1879,19 @@ ShearImage(const Image *image,const double x_shear,
   */
   shear_image->storage_class=DirectClass;
   shear_image->matte|=shear_image->background_color.opacity != OpaqueOpacity;
+
   if (XShearImage(shear_image,shear.x,image->columns,image->rows,x_offset,
-                 (long) (shear_image->rows-image->rows)/2,exception)
+                  (long) (shear_image->rows-image->rows)/2,exception)
       != MagickPass)
     goto shear_image_exception;
-  
+
   if (YShearImage(shear_image,shear.y,y_width,image->rows,
-                 (long) (shear_image->columns-y_width)/2,y_offset,exception)
+                  (long) (shear_image->columns-y_width)/2,y_offset,exception)
       != MagickPass)
     goto shear_image_exception;
-  
+
   if (CropToFitImage(&shear_image,shear.x,shear.y,image->columns,image->rows,
-                    False,exception) != MagickPass)
+                     False,exception) != MagickPass)
     goto shear_image_exception;
 
   shear_image->page.width=0;
index 865b5f8..f08f609 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003-2012 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   ImageMagick Image Shear Methods.
 */
 #ifndef _MAGICK_SHEAR_H
index f466ee2..a9431be 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Digital signature methods.
 */
 #ifndef _MAGICK_SIGNATURE_H
@@ -24,7 +24,7 @@ extern "C" {
   Typedef declarations.
 */
 typedef struct _SignatureInfo
-{   
+{
   unsigned long
     digest[8],
     low_order,
index 3aa7a18..4035c87 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   ImageMagick Spinlock  Methods. These are highly lightweight functions that
   are used to prevent deadlocks on access to global data when the normal
   semaphore system has not yet been initialized. They are intended to only
@@ -58,7 +58,7 @@ static void _spinlock_release (LONG volatile *sl)
 
     To operate on a pointer variable, use the
     InterlockedExchangePointer function.
-    
+
     To operate on a 64-bit variable, use the InterlockedExchange64
     function.
   */
index fd140a9..66c1d76 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2016 GraphicsMagick Group
+% Copyright (C) 2003-2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 %
 % This program is covered by multiple licenses, which are described in
   Include declarations.
 */
 #include "magick/studio.h"
+#include "magick/log.h"
 #include "magick/module.h"
 #include "magick/static.h"
 #include "magick/utility.h"
 \f
+#if !defined(SupportMagickModules)
+
+#include "magick/module_aliases.h"
+
+typedef struct _StaticModule
+{
+  const char* name;
+  void (*register_fn)(void);
+  void (*unregister_fn)(void);
+  MagickBool loaded;
+  const unsigned int name_length;
+
+} StaticModule;
+
+/*
+  This list must be ordered by 'name' in an ascending order based on
+  strcmp().
+*/
+static StaticModule
+StaticModules[] =
+{
+#define STATICM(name,register_fn,unregister_fn) {name,register_fn,unregister_fn,MagickFalse,sizeof(name)-1}
+  STATICM("ART",RegisterARTImage,UnregisterARTImage),
+  STATICM("AVS",RegisterAVSImage,UnregisterAVSImage),
+  STATICM("BMP",RegisterBMPImage,UnregisterBMPImage),
+  STATICM("CALS",RegisterCALSImage,UnregisterCALSImage),
+  STATICM("CAPTION",RegisterCAPTIONImage,UnregisterCAPTIONImage),
+  STATICM("CINEON",RegisterCINEONImage,UnregisterCINEONImage),
+#if defined(HasWINGDI32)
+  STATICM("CLIPBOARD",RegisterCLIPBOARDImage,UnregisterCLIPBOARDImage),
+#endif
+  STATICM("CMYK",RegisterCMYKImage,UnregisterCMYKImage),
+  STATICM("CUT",RegisterCUTImage,UnregisterCUTImage),
+  STATICM("DCM",RegisterDCMImage,UnregisterDCMImage),
+  STATICM("DCRAW",RegisterDCRAWImage,UnregisterDCRAWImage),
+  STATICM("DIB",RegisterDIBImage,UnregisterDIBImage),
+#if defined(HasDPS)
+  STATICM("DPS",RegisterDPSImage,UnregisterDPSImage),
+#endif
+  STATICM("DPX",RegisterDPXImage,UnregisterDPXImage),
+#if defined(HasWINGDI32)
+  STATICM("EMF",RegisterEMFImage,UnregisterEMFImage),
+#endif
+#if defined(HasTIFF)
+  STATICM("EPT",RegisterEPTImage,UnregisterEPTImage),
+#endif
+  STATICM("FAX",RegisterFAXImage,UnregisterFAXImage),
+  STATICM("FITS",RegisterFITSImage,UnregisterFITSImage),
+#if defined(HasFPX)
+  STATICM("FPX",RegisterFPXImage,UnregisterFPXImage),
+#endif
+  STATICM("GIF",RegisterGIFImage,UnregisterGIFImage),
+  STATICM("GRAY",RegisterGRAYImage,UnregisterGRAYImage),
+  STATICM("GRADIENT",RegisterGRADIENTImage,UnregisterGRADIENTImage),
+  STATICM("HISTOGRAM",RegisterHISTOGRAMImage,UnregisterHISTOGRAMImage),
+  STATICM("HRZ",RegisterHRZImage,UnregisterHRZImage),
+  STATICM("HTML",RegisterHTMLImage,UnregisterHTMLImage),
+  STATICM("ICON",RegisterICONImage,UnregisterICONImage),
+  STATICM("IDENTITY",RegisterIDENTITYImage,UnregisterIDENTITYImage),
+  STATICM("INFO",RegisterINFOImage,UnregisterINFOImage),
+#if defined(HasJBIG)
+  STATICM("JBIG",RegisterJBIGImage,UnregisterJBIGImage),
+#endif
+#if defined(HasJPEG)
+  STATICM("JNX",RegisterJNXImage,UnregisterJNXImage),
+#endif
+#if defined(HasJPEG)
+  STATICM("JPEG",RegisterJPEGImage,UnregisterJPEGImage),
+#endif
+#if defined(HasJP2)
+  STATICM("JP2",RegisterJP2Image,UnregisterJP2Image),
+#endif
+  STATICM("LABEL",RegisterLABELImage,UnregisterLABELImage),
+  STATICM("LOCALE",RegisterLOCALEImage,UnregisterLOCALEImage),
+  STATICM("LOGO",RegisterLOGOImage,UnregisterLOGOImage),
+  STATICM("MAC",RegisterMACImage,UnregisterMACImage),
+  STATICM("MAP",RegisterMAPImage,UnregisterMAPImage),
+  STATICM("MAT",RegisterMATImage,UnregisterMATImage),
+  STATICM("MATTE",RegisterMATTEImage,UnregisterMATTEImage),
+  STATICM("META",RegisterMETAImage,UnregisterMETAImage),
+  STATICM("MIFF",RegisterMIFFImage,UnregisterMIFFImage),
+  STATICM("MONO",RegisterMONOImage,UnregisterMONOImage),
+  STATICM("MPC",RegisterMPCImage,UnregisterMPCImage),
+  STATICM("MPEG",RegisterMPEGImage,UnregisterMPEGImage),
+  STATICM("MPR",RegisterMPRImage,UnregisterMPRImage),
+  STATICM("MSL",RegisterMSLImage,UnregisterMSLImage),
+  STATICM("MTV",RegisterMTVImage,UnregisterMTVImage),
+  STATICM("MVG",RegisterMVGImage,UnregisterMVGImage),
+  STATICM("NULL",RegisterNULLImage,UnregisterNULLImage),
+  STATICM("OTB",RegisterOTBImage,UnregisterOTBImage),
+  STATICM("PALM",RegisterPALMImage,UnregisterPALMImage),
+  STATICM("PCD",RegisterPCDImage,UnregisterPCDImage),
+  STATICM("PCL",RegisterPCLImage,UnregisterPCLImage),
+  STATICM("PCX",RegisterPCXImage,UnregisterPCXImage),
+  STATICM("PDB",RegisterPDBImage,UnregisterPDBImage),
+  STATICM("PDF",RegisterPDFImage,UnregisterPDFImage),
+  STATICM("PICT",RegisterPICTImage,UnregisterPICTImage),
+  STATICM("PIX",RegisterPIXImage,UnregisterPIXImage),
+  STATICM("PLASMA",RegisterPLASMAImage,UnregisterPLASMAImage),
+#if defined(HasPNG)
+  STATICM("PNG",RegisterPNGImage,UnregisterPNGImage),
+#endif
+  STATICM("PNM",RegisterPNMImage,UnregisterPNMImage),
+  STATICM("PREVIEW",RegisterPREVIEWImage,UnregisterPREVIEWImage),
+  STATICM("PS",RegisterPSImage,UnregisterPSImage),
+  STATICM("PS2",RegisterPS2Image,UnregisterPS2Image),
+  STATICM("PS3",RegisterPS3Image,UnregisterPS3Image),
+#if defined(EnableBrokenCoders) && EnableBrokenCoders
+  STATICM("PSD",RegisterPSDImage,UnregisterPSDImage),
+#endif /* defined(EnableBrokenCoders) && EnableBrokenCoders */
+  STATICM("PWP",RegisterPWPImage,UnregisterPWPImage),
+  STATICM("RGB",RegisterRGBImage,UnregisterRGBImage),
+  STATICM("RLA",RegisterRLAImage,UnregisterRLAImage),
+  STATICM("RLE",RegisterRLEImage,UnregisterRLEImage),
+  STATICM("SCT",RegisterSCTImage,UnregisterSCTImage),
+  STATICM("SFW",RegisterSFWImage,UnregisterSFWImage),
+  STATICM("SGI",RegisterSGIImage,UnregisterSGIImage),
+  STATICM("STEGANO",RegisterSTEGANOImage,UnregisterSTEGANOImage),
+  STATICM("SUN",RegisterSUNImage,UnregisterSUNImage),
+  STATICM("SVG",RegisterSVGImage,UnregisterSVGImage),
+  STATICM("TGA",RegisterTGAImage,UnregisterTGAImage),
+#if defined(HasTIFF)
+  STATICM("TIFF",RegisterTIFFImage,UnregisterTIFFImage),
+#endif
+  STATICM("TILE",RegisterTILEImage,UnregisterTILEImage),
+  STATICM("TIM",RegisterTIMImage,UnregisterTIMImage),
+  STATICM("TOPOL",RegisterTOPOLImage,UnregisterTOPOLImage),
+  STATICM("TTF",RegisterTTFImage,UnregisterTTFImage),
+  STATICM("TXT",RegisterTXTImage,UnregisterTXTImage),
+  STATICM("UIL",RegisterUILImage,UnregisterUILImage),
+  STATICM("URL",RegisterURLImage,UnregisterURLImage),
+  STATICM("UYVY",RegisterUYVYImage,UnregisterUYVYImage),
+  STATICM("VICAR",RegisterVICARImage,UnregisterVICARImage),
+  STATICM("VID",RegisterVIDImage,UnregisterVIDImage),
+  STATICM("VIFF",RegisterVIFFImage,UnregisterVIFFImage),
+  STATICM("WBMP",RegisterWBMPImage,UnregisterWBMPImage),
+#if defined(HasWEBP)
+  STATICM("WEBP",RegisterWEBPImage,UnregisterWEBPImage),
+#endif
+  STATICM("WMF",RegisterWMFImage,UnregisterWMFImage),
+  STATICM("WPG",RegisterWPGImage,UnregisterWPGImage),
+#if defined(HasX11)
+  STATICM("X",RegisterXImage,UnregisterXImage),
+#endif /* defined(HasX11) */
+  STATICM("XBM",RegisterXBMImage,UnregisterXBMImage),
+  STATICM("XC",RegisterXCImage,UnregisterXCImage),
+  STATICM("XCF",RegisterXCFImage,UnregisterXCFImage),
+  STATICM("XPM",RegisterXPMImage,UnregisterXPMImage),
+#if defined(_VISUALC_)
+  STATICM("XTRN",RegisterXTRNImage,UnregisterXTRNImage),
+#endif /* defined(_VISUALC_) */
+#if defined(HasX11)
+  STATICM("XWD",RegisterXWDImage,UnregisterXWDImage),
+#endif /* defined(HasX11) */
+  STATICM("YUV",RegisterYUVImage,UnregisterYUVImage)
+};
+
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   D e s t r o y M a g i c k M o d u l e s                                   %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  DestroyMagickResources() destroys the resource environment.
+%
+%  The format of the DestroyMagickResources() method is:
+%
+%      DestroyMagickResources(void)
+%
+%
+*/
+void
+DestroyMagickModules(void)
+{
+  unsigned int index;
+
+  for (index=0; index < sizeof(StaticModules)/sizeof(StaticModules[0]);index++)
+    {
+      if (StaticModules[index].loaded == MagickTrue)
+        {
+          (StaticModules[index].unregister_fn)();
+          StaticModules[index].loaded = MagickFalse;
+        }
+    }
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   I n i t i a l i z e M a g i c k M o d u l e s                             %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  InitializeMagickModules() initializes the module loader.
+%
+%  The format of the InitializeMagickModules() method is:
+%
+%      InitializeMagickModules(void)
+%
+%
+*/
+void
+InitializeMagickModules(void)
+{
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   O p e n M o d u l e                                                       %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  OpenModule() loads a module, and invokes its registration method.  It
+%  returns MagickPass on success, and MagickFail if there is an error.
+%
+%  The format of the OpenModule method is:
+%
+%      MagickPassFail OpenModule(const char *module,ExceptionInfo *exception)
+%
+%  A description of each parameter follows:
+%
+%    o status: Method OpenModule returns MagickPass if the specified module is
+%      loaded, otherwise MagickFail.
+%
+%    o module: a character string that indicates the module to load.
+%
+%    o exception: Return any errors or warnings in this structure.
+%
+%
+*/
+MagickPassFail
+OpenModule(const char *module,ExceptionInfo *exception)
+{
+  char
+    module_name[MaxTextExtent];
+
+  size_t
+    name_length;
+
+  unsigned int
+    index;
+
+  MagickPassFail
+    status = MagickFail;
+
+  (void) exception;
+  /*
+    Assign module name from alias.
+  */
+  assert(module != (const char *) NULL);
+  name_length=strlcpy(module_name,module,MaxTextExtent);
+  LocaleUpper(module_name);
+  (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+                        "Magick \"%s\"", module_name);
+  for (index=0; index < ArraySize(ModuleAliases);index++)
+    {
+      if (ModuleAliases[index].magick[0] > module[0])
+        break;
+      if ((ModuleAliases[index].magick[0] == module[0]) &&
+          (ModuleAliases[index].magick_len == name_length) &&
+          (memcmp(ModuleAliases[index].magick,module,name_length) == 0))
+        {
+          name_length=strlcpy(module_name,ModuleAliases[index].name,MaxTextExtent);
+          break;
+        }
+    }
+
+  /*
+    Find module in list and load if not already loaded
+  */
+  for (index=0; index < ArraySize(StaticModules);index++)
+    {
+      if (StaticModules[index].name[0] > module_name[0])
+        break;
+      if ((StaticModules[index].name[0] == module_name[0]) &&
+          (StaticModules[index].name_length == name_length) &&
+          (memcmp(StaticModules[index].name,module_name,name_length) == 0))
+        {
+          if (StaticModules[index].loaded == MagickFalse)
+            {
+              (StaticModules[index].register_fn)();
+              StaticModules[index].loaded = MagickTrue;
+              (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+                                    "Loaded static module \"%s\"", module_name);
+            }
+          status=MagickPass;
+          break;
+        }
+    }
+  if (index == ArraySize(StaticModules))
+    status=MagickFail;
+
+  return status;
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   O p e n M o d u l e s                                                     %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  Method OpenModules loads all available modules.
+%
+%  The format of the OpenModules method is:
+%
+%      MagickPassFail OpenModules(ExceptionInfo *exception)
+%
+%  A description of each parameter follows:
+%
+%    o status: Method OpenModules returns True if the modules are loaded,
+%      otherwise False.
+%
+%    o exception: Return any errors or warnings in this structure.
+%
+*/
+MagickPassFail
+OpenModules(ExceptionInfo *exception)
+{
+  unsigned int index;
+  (void) exception;
+
+  for (index=0; index < ArraySize(StaticModules);index++)
+    {
+      if (StaticModules[index].loaded == MagickFalse)
+        {
+          (StaticModules[index].register_fn)();
+          StaticModules[index].loaded = MagickTrue;
+        }
+    }
+
+  return MagickPass;
+}
+#endif /* !defined(SupportMagickModules) */
+\f
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
 %
 */
 #if defined(SupportMagickModules)
-MagickExport unsigned int ExecuteStaticModuleProcess(const char *tag,
+unsigned int ExecuteStaticModuleProcess(const char *tag,
   Image **image,const int argc,char **argv)
 #else
-MagickExport unsigned int ExecuteModuleProcess(const char *tag,
+unsigned int ExecuteModuleProcess(const char *tag,
   Image **image,const int argc,char **argv)
 #endif /* defined(SupportMagickModules) */
 {
   unsigned int
     status = False;
 
-#if !defined(BuildMagickModules)
+#if !defined(SupportMagickModules)
   unsigned int
     (*method)(Image **,const int,char **) = 0;
 
@@ -105,7 +460,7 @@ MagickExport unsigned int ExecuteModuleProcess(const char *tag,
   ARG_NOT_USED(image);
   ARG_NOT_USED(argc);
   ARG_NOT_USED(argv);
-#endif /* !defined(BuildMagickModules) */
+#endif /* !defined(SupportMagickModules) */
   return(status);
 }
 \f
@@ -120,7 +475,7 @@ MagickExport unsigned int ExecuteModuleProcess(const char *tag,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  
+%
 RegisterStaticModules() statically registers all the available module
 %  handlers.
 %
@@ -130,143 +485,20 @@ RegisterStaticModules() statically registers all the available module
 %
 %
 */
-MagickExport void RegisterStaticModules(void)
+void RegisterStaticModules(void)
 {
-#if !defined(BuildMagickModules)
-  RegisterARTImage();
-  RegisterAVSImage();
-  RegisterBMPImage();
-  RegisterCALSImage();
-  RegisterCAPTIONImage();
-  RegisterCINEONImage();
-#if defined(HasWINGDI32)
-  RegisterCLIPBOARDImage();
-#endif
-  RegisterCMYKImage();
-  RegisterCUTImage();
-  RegisterDCMImage();
-  RegisterDCRAWImage();
-  RegisterDIBImage();
-#if defined(HasDPS)
-  RegisterDPSImage();
-#endif
-  RegisterDPXImage();
-#if defined(HasWINGDI32)
-  RegisterEMFImage();
-#endif
-#if defined(HasTIFF)
-  RegisterEPTImage();
-#endif
-  RegisterFAXImage();
-  RegisterFITSImage();
-#if defined(HasFPX)
-  RegisterFPXImage();
-#endif
-  RegisterGIFImage();
-  RegisterGRAYImage();
-  RegisterGRADIENTImage();
-  RegisterHISTOGRAMImage();
-  RegisterHRZImage();
-  RegisterHTMLImage();
-  RegisterICONImage();
-  RegisterIDENTITYImage();
-  RegisterINFOImage();
-#if defined(HasJBIG)
-  RegisterJBIGImage();
-#endif
-#if defined(HasJPEG)
-  RegisterJNXImage();
-#endif
-#if defined(HasJPEG)
-  RegisterJPEGImage();
-#endif
-#if defined(HasJP2)
-  RegisterJP2Image();
-#endif
-  RegisterLABELImage();
-  RegisterLOCALEImage();
-  RegisterLOGOImage();
-  RegisterMACImage();
-  RegisterMAPImage();
-  RegisterMATImage();
-  RegisterMATTEImage();
-  RegisterMETAImage();
-  RegisterMIFFImage();
-  RegisterMONOImage();
-  RegisterMPCImage();
-  RegisterMPEGImage();
-  RegisterMPRImage();
-  RegisterMSLImage();
-  RegisterMTVImage();
-  RegisterMVGImage();
-  RegisterNULLImage();
-  RegisterOTBImage();
-  RegisterPALMImage();
-  RegisterPCDImage();
-  RegisterPCLImage();
-  RegisterPCXImage();
-  RegisterPDBImage();
-  RegisterPDFImage();
-  RegisterPICTImage();
-  RegisterPIXImage();
-  RegisterPLASMAImage();
-#if defined(HasPNG)
-  RegisterPNGImage();
-#endif
-  RegisterPNMImage();
-  RegisterPREVIEWImage();
-  RegisterPSImage();
-  RegisterPS2Image();
-  RegisterPS3Image();
-#if defined(EnableBrokenCoders) && EnableBrokenCoders
-  RegisterPSDImage();
-#endif /* defined(EnableBrokenCoders) && EnableBrokenCoders */
-  RegisterPWPImage();
-  RegisterRGBImage();
-  RegisterRLAImage();
-  RegisterRLEImage();
-  RegisterSCTImage();
-  RegisterSFWImage();
-  RegisterSGIImage();
-  RegisterSTEGANOImage();
-  RegisterSUNImage();
-  RegisterSVGImage();
-  RegisterTGAImage();
-#if defined(HasTIFF)
-  RegisterTIFFImage();
-#endif
-  RegisterTILEImage();
-  RegisterTIMImage();
-  RegisterTOPOLImage();
-  RegisterTTFImage();
-  RegisterTXTImage();
-  RegisterUILImage();
-  RegisterURLImage();
-  RegisterUYVYImage();
-  RegisterVICARImage();
-  RegisterVIDImage();
-  RegisterVIFFImage();
-  RegisterWBMPImage();
-#if defined(HasWEBP)
-  RegisterWEBPImage();
-#endif
-  RegisterWMFImage();
-  RegisterWPGImage();
-#if defined(HasX11)
-  RegisterXImage();
-#endif /* defined(HasX11) */
-  RegisterXBMImage();
-  RegisterXCImage();
-  RegisterXCFImage();
-  RegisterXPMImage();
-#if defined(_VISUALC_)
-  RegisterXTRNImage();
-#endif /* defined(_VISUALC_) */
-#if defined(HasX11)
-  RegisterXWDImage();
-#endif /* defined(HasX11) */
-  RegisterYUVImage();
-#endif /* !defined(BuildMagickModules) */
+#if !defined(SupportMagickModules)
+  unsigned int index;
+
+  for (index=0; index < ArraySize(StaticModules); index++)
+    {
+      if (StaticModules[index].loaded == MagickFalse)
+        {
+          (StaticModules[index].register_fn)();
+          StaticModules[index].loaded = MagickTrue;
+        }
+    }
+#endif /* !defined(SupportMagickModules) */
 }
 \f
 /*
@@ -289,141 +521,18 @@ MagickExport void RegisterStaticModules(void)
 %
 %
 */
-MagickExport void UnregisterStaticModules(void)
+void UnregisterStaticModules(void)
 {
-#if !defined(BuildMagickModules)
-  UnregisterARTImage();
-  UnregisterAVSImage();
-  UnregisterBMPImage();
-  UnregisterCALSImage();
-  UnregisterCAPTIONImage();
-  UnregisterCINEONImage();
-#if defined(HasWINGDI32)
-  UnregisterCLIPBOARDImage();
-#endif
-  UnregisterCMYKImage();
-  UnregisterCUTImage();
-  UnregisterDCMImage();
-  UnregisterDCRAWImage();
-  UnregisterDIBImage();
-#if defined(HasDPS)
-  UnregisterDPSImage();
-#endif
-  UnregisterDPXImage();
-#if defined(HasWINGDI32)
-  UnregisterEMFImage();
-#endif
-#if defined(HasTIFF)
-  UnregisterEPTImage();
-#endif
-  UnregisterFAXImage();
-  UnregisterFITSImage();
-#if defined(HasFPX)
-  UnregisterFPXImage();
-#endif
-  UnregisterGIFImage();
-  UnregisterGRAYImage();
-  UnregisterGRADIENTImage();
-  UnregisterHISTOGRAMImage();
-  UnregisterHRZImage();
-  UnregisterHTMLImage();
-  UnregisterICONImage();
-  UnregisterIDENTITYImage();
-  UnregisterINFOImage();
-#if defined(HasJBIG)
-  UnregisterJBIGImage();
-#endif
-#if defined(HasJPEG)
-  UnregisterJNXImage();
-#endif
-#if defined(HasJPEG)
-  UnregisterJPEGImage();
-#endif
-#if defined(HasJP2)
-  UnregisterJP2Image();
-#endif
-  UnregisterLABELImage();
-  UnregisterLOCALEImage();
-  UnregisterLOGOImage();
-  UnregisterMACImage();
-  UnregisterMAPImage();
-  UnregisterMATImage();
-  UnregisterMATTEImage();
-  UnregisterMETAImage();
-  UnregisterMIFFImage();
-  UnregisterMONOImage();
-  UnregisterMPCImage();
-  UnregisterMPEGImage();
-  UnregisterMPRImage();
-  UnregisterMSLImage();
-  UnregisterMTVImage();
-  UnregisterMVGImage();
-  UnregisterNULLImage();
-  UnregisterOTBImage();
-  UnregisterPALMImage();
-  UnregisterPCDImage();
-  UnregisterPCLImage();
-  UnregisterPCXImage();
-  UnregisterPDBImage();
-  UnregisterPDFImage();
-  UnregisterPICTImage();
-  UnregisterPIXImage();
-  UnregisterPLASMAImage();
-#if defined(HasPNG)
-  UnregisterPNGImage();
-#endif
-  UnregisterPNMImage();
-  UnregisterPREVIEWImage();
-  UnregisterPSImage();
-  UnregisterPS2Image();
-  UnregisterPS3Image();
-#if defined(EnableBrokenCoders) && EnableBrokenCoders
-  UnregisterPSDImage();
-#endif /* defined(EnableBrokenCoders) && EnableBrokenCoders */
-  UnregisterPWPImage();
-  UnregisterRGBImage();
-  UnregisterRLAImage();
-  UnregisterRLEImage();
-  UnregisterSCTImage();
-  UnregisterSFWImage();
-  UnregisterSGIImage();
-  UnregisterSTEGANOImage();
-  UnregisterSUNImage();
-  UnregisterSVGImage();
-  UnregisterTGAImage();
-#if defined(HasTIFF)
-  UnregisterTIFFImage();
-#endif
-  UnregisterTILEImage();
-  UnregisterTIMImage();
-  UnregisterTOPOLImage();
-  UnregisterTTFImage();
-  UnregisterTXTImage();
-  UnregisterUILImage();
-  UnregisterURLImage();
-  UnregisterUYVYImage();
-  UnregisterVICARImage();
-  UnregisterVIDImage();
-  UnregisterVIFFImage();
-  UnregisterWBMPImage();
-#if defined(HasWEBP)
-  UnregisterWEBPImage();
-#endif
-  UnregisterWMFImage();
-  UnregisterWPGImage();
-#if defined(HasX11)
-  UnregisterXImage();
-#endif /* defined(HasX11) */
-  UnregisterXBMImage();
-  UnregisterXCImage();
-  UnregisterXCFImage();
-  UnregisterXPMImage();
-#if defined(_VISUALC_)
-  UnregisterXTRNImage();
-#endif /* defined(_VISUALC_) */
-#if defined(HasX11)
-  UnregisterXWDImage();
-#endif /* defined(HasX11) */
-  UnregisterYUVImage();
-#endif /* !defined(BuildMagickModules) */
+#if !defined(SupportMagickModules)
+  unsigned int index;
+
+  for (index=0; index < ArraySize(StaticModules);index++)
+    {
+      if (StaticModules[index].loaded == MagickTrue)
+        {
+          (StaticModules[index].unregister_fn)();
+          StaticModules[index].loaded = MagickFalse;
+        }
+    }
+#endif /* !defined(SupportMagickModules) */
 }
index 8de6d06..a01c75d 100644 (file)
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2003-2010 GraphicsMagick Group
+  Copyright (C) 2003-2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   ImageMagick Coder Registration Methods.
 */
 #ifndef _MAGICK_STATIC_H
index a9b3d0c..30c6d2e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2014 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2003 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -58,18 +58,18 @@ typedef struct _StatisticsContext {
 } StatisticsContext;
 static MagickPassFail GetImageStatisticsMean(void *mutable_data,
                                              const void *immutable_data,
-                                             const Image *image,
-                                             const PixelPacket *pixel,
-                                             const IndexPacket *indexes,
+                                             const Image * restrict image,
+                                             const PixelPacket * restrict pixel,
+                                             const IndexPacket * restrict indexes,
                                              const long npixels,
                                              ExceptionInfo *exception)
 {
   ImageStatistics
     lstatistics,
-    *statistics=(ImageStatistics *) mutable_data;
+    * restrict statistics=(ImageStatistics *) mutable_data;
 
   const StatisticsContext
-    *context=(const StatisticsContext *) immutable_data;
+    * restrict context=(const StatisticsContext *) immutable_data;
 
   double
     normalized;
@@ -162,18 +162,18 @@ static MagickPassFail GetImageStatisticsMean(void *mutable_data,
 #define Square(x)  ((x)*(x))
 static MagickPassFail GetImageStatisticsVariance(void *mutable_data,
                                                  const void *immutable_data,
-                                                 const Image *image,
-                                                 const PixelPacket *pixel,
-                                                 const IndexPacket *indexes,
+                                                 const Image * restrict image,
+                                                 const PixelPacket * restrict pixel,
+                                                 const IndexPacket * restrict indexes,
                                                  const long npixels,
                                                  ExceptionInfo *exception)
 {
   ImageStatistics
     lstatistics,
-    *statistics=(ImageStatistics *) mutable_data;
+    * restrict statistics=(ImageStatistics *) mutable_data;
 
   const StatisticsContext
-    *context=(const StatisticsContext *) immutable_data;
+    * restrict context=(const StatisticsContext *) immutable_data;
 
   double
     normalized;
@@ -204,15 +204,15 @@ static MagickPassFail GetImageStatisticsVariance(void *mutable_data,
       normalized=(double) pixel[i].red/MaxRGB;
       lstatistics.red.variance +=
         Square(normalized-lstatistics.red.mean)/context->variance_divisor;
-      
+
       normalized=(double) pixel[i].green/MaxRGB;
       lstatistics.green.variance +=
         Square(normalized-lstatistics.green.mean)/context->variance_divisor;
-      
+
       normalized=(double) pixel[i].blue/MaxRGB;
       lstatistics.blue.variance +=
         Square(normalized-lstatistics.blue.mean)/context->variance_divisor;
-      
+
       if (process_opacity)
         {
           normalized=(double) pixel[i].opacity/MaxRGB;
@@ -239,7 +239,7 @@ MagickExport MagickPassFail GetImageStatistics(const Image *image,
 {
   StatisticsContext
     context;
-  
+
   MagickPassFail
     status=MagickPass;
 
@@ -260,7 +260,7 @@ MagickExport MagickPassFail GetImageStatistics(const Image *image,
   samples=(double) image->rows*image->columns;
   context.samples=samples;
   context.variance_divisor=samples-1;
-  
+
   /*
     Compute Mean, Max, and Min
   */
@@ -292,4 +292,3 @@ MagickExport MagickPassFail GetImageStatistics(const Image *image,
 
   return status;
 }
-
index 7fea1bb..21b3fb7 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 - 2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Image Statistics Methods.
 */
 #ifndef _MAGICK_STATISTICS_H
@@ -46,7 +46,7 @@ typedef struct _ImageStatistics
 
 extern MagickExport MagickPassFail
   GetImageStatistics(const Image *image,ImageStatistics *statistics,
-                    ExceptionInfo *exception);
+                     ExceptionInfo *exception);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
index bf31c2f..ae181c0 100644 (file)
@@ -1,11 +1,11 @@
 /*
-  Copyright (C) 2003 - 2016 GraphicsMagick Group
+  Copyright (C) 2003 - 2017 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Application Programming Interface declarations.
 */
 #ifndef _MAGICK_STUDIO_H
@@ -345,6 +345,7 @@ extern int vsnprintf(char *s, size_t n, const char *format, va_list ap);
   Define declarations.
 */
 #define AbsoluteValue(x)  ((x) < 0 ? -(x) : (x))
+#define ArraySize(a) (sizeof(a)/sizeof(a[0]))
 #define False  0
 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
 #define MagickIncarnate(x)  InitializeMagick(x)
@@ -356,12 +357,12 @@ extern int vsnprintf(char *s, size_t n, const char *format, va_list ap);
 #endif
 #define Max(x,y)  (((x) > (y)) ? (x) : (y))
 #define Min(x,y)  (((x) < (y)) ? (x) : (y))
-#define NumberOfObjectsInArray(octets,size) ((octets+size-1)/size)
+#define NumberOfObjectsInArray(octets,size) (octets/size) /* rounds down */
 #define QuantumTick(i,span) \
   ((((i) % ((Max(101,span)-1)/100)) == 0) || \
     ((magick_int64_t) (i) == ((magick_int64_t) (span)-1)))
 #define RadiansToDegrees(x) (180.0*(x)/MagickPI)
-#define RoundUpToAlignment(offset,alignment)                           \
+#define RoundUpToAlignment(offset,alignment)                            \
   (((offset)+((alignment)-1)) & ~((alignment)-1))
 #define AssertAlignment(offset,alignment) \
   (assert((((size_t) offset) % (size_t) alignment) == (size_t) 0))
index d6f76c2..8868b62 100644 (file)
@@ -1,18 +1,11 @@
 /*
-  Copyright (C) 2003 - 2016 GraphicsMagick Group
+  Copyright (C) 2012-2018 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
 
   Library symbol name-scoping support.
-
-  Obtained via:
-
-  nm -p magick/.libs/libGraphicsMagick.a | grep ' T ' | egrep -vi '(Gm)|(lt_)' | \
-     egrep -v '(MagickError)|(MagickFatalError)|(MagickWarning)|(ThrowException)' | \
-     awk '{ printf("#define %s Gm%s\n", $3, $3); }' | sort
-
 */
 
 #if !defined(_MAGICK_SYMBOLS_H)
 #define CompositeImage GmCompositeImage
 #define CompositeImageCommand GmCompositeImageCommand
 #define CompositeImageRegion GmCompositeImageRegion
+#define CompositeMaskImage GmCompositeMaskImage
 #define CompositeOperatorToString GmCompositeOperatorToString
+#define CompositePathImage GmCompositePathImage
 #define CompressImageColormap GmCompressImageColormap
 #define CompressionTypeToString GmCompressionTypeToString
 #define ConcatenateString GmConcatenateString
 #define CopyException GmCopyException
 #define CropImage GmCropImage
 #define CycleColormapImage GmCycleColormapImage
-#define DCM_SetRescaling GmDCM_SetRescaling
 #define DeallocateImageProfileIterator GmDeallocateImageProfileIterator
 #define DeconstructImages GmDeconstructImages
 #define DefaultTileFrame GmDefaultTileFrame
 #define DestroyLogInfo GmDestroyLogInfo
 #define DestroyMagicInfo GmDestroyMagicInfo
 #define DestroyMagick GmDestroyMagick
+#define DestroyMagickModules GmDestroyMagickModules
+#define DestroyMagickMonitor GmDestroyMagickMonitor
 #define DestroyMagickRandomGenerator GmDestroyMagickRandomGenerator
 #define DestroyMagickRegistry GmDestroyMagickRegistry
 #define DestroyMagickResources GmDestroyMagickResources
 #define DestroyTypeInfo GmDestroyTypeInfo
 #define DetachBlob GmDetachBlob
 #define DifferenceImage GmDifferenceImage
+#define DisassociateBlob GmDisassociateBlob
 #define DispatchImage GmDispatchImage
 #define DisplayImageCommand GmDisplayImageCommand
 #define DisplayImages GmDisplayImages
 #define DrawColor GmDrawColor
 #define DrawComment GmDrawComment
 #define DrawComposite GmDrawComposite
+#define DrawCompositeMask GmDrawCompositeMask
 #define DrawDestroyContext GmDrawDestroyContext
 #define DrawEllipse GmDrawEllipse
 #define DrawGetClipPath GmDrawGetClipPath
 #define DrawGetTextEncoding GmDrawGetTextEncoding
 #define DrawGetTextUnderColor GmDrawGetTextUnderColor
 #define DrawImage GmDrawImage
+#define DrawInfoGetClipPath GmDrawInfoGetClipPath
+#define DrawInfoGetCompositePath GmDrawInfoGetCompositePath
 #define DrawLine GmDrawLine
 #define DrawMatte GmDrawMatte
 #define DrawPathClose GmDrawPathClose
 #define FormatString GmFormatString
 #define FormatStringList GmFormatStringList
 #define FrameImage GmFrameImage
+#define FreeFunc GmFreeFunc
 #define FuzzyColorMatch GmFuzzyColorMatch
 #define GammaImage GmGammaImage
 #define GaussianBlurImage GmGaussianBlurImage
 #define GenerateDifferentialNoise GmGenerateDifferentialNoise
 #define GenerateNoise GmGenerateNoise
 #define GetBlobFileHandle GmGetBlobFileHandle
+#define GetBlobFirstErrno GmGetBlobFirstErrno
 #define GetBlobInfo GmGetBlobInfo
 #define GetBlobIsOpen GmGetBlobIsOpen
 #define GetBlobSize GmGetBlobSize
 #define GetImageCharacteristics GmGetImageCharacteristics
 #define GetImageClipMask GmGetImageClipMask
 #define GetImageClippingPathAttribute GmGetImageClippingPathAttribute
+#define GetImageCompositeMask GmGetImageCompositeMask
 #define GetImageDepth GmGetImageDepth
 #define GetImageDistortion GmGetImageDistortion
 #define GetImageException GmGetImageException
 #define HSLTransform GmHSLTransform
 #define HWBTransform GmHWBTransform
 #define HaldClutImage GmHaldClutImage
+#define HighlightColor GmHighlightColor
 #define HighlightStyleToString GmHighlightStyleToString
 #define HuffmanDecodeImage GmHuffmanDecodeImage
 #define HuffmanEncode2Image GmHuffmanEncode2Image
 #define Hull GmHull
 #define IdentifyImageCommand GmIdentifyImageCommand
 #define IdentityAffine GmIdentityAffine
+#define ImageGetClipMask GmImageGetClipMask
+#define ImageGetCompositeMask GmImageGetCompositeMask
 #define ImageListToArray GmImageListToArray
 #define ImageToBlob GmImageToBlob
 #define ImageToFile GmImageToFile
 #define InitializeDifferenceImageOptions GmInitializeDifferenceImageOptions
 #define InitializeDifferenceStatistics GmInitializeDifferenceStatistics
 #define InitializeLogInfo GmInitializeLogInfo
+#define InitializeLogInfoPost GmInitializeLogInfoPost
 #define InitializeMagicInfo GmInitializeMagicInfo
 #define InitializeMagick GmInitializeMagick
 #define InitializeMagickClientPathAndName GmInitializeMagickClientPathAndName
+#define InitializeMagickModules GmInitializeMagickModules
+#define InitializeMagickMonitor GmInitializeMagickMonitor
 #define InitializeMagickRandomGenerator GmInitializeMagickRandomGenerator
 #define InitializeMagickRandomKernel GmInitializeMagickRandomKernel
 #define InitializeMagickRegistry GmInitializeMagickRegistry
 #define LocaleNCompare GmLocaleNCompare
 #define LocaleUpper GmLocaleUpper
 #define LockSemaphoreInfo GmLockSemaphoreInfo
-#define LogMagickEvent GmLogMagickEvent
-#define LogMagickEventList GmLogMagickEventList
-#define MatteColor GmMatteColor
 #define MSBOrderLong GmMSBOrderLong
 #define MSBOrderShort GmMSBOrderShort
 #define MagickAllocFunctions GmMagickAllocFunctions
 #define MagickArraySize GmMagickArraySize
+#define MagickAtoFChk GmMagickAtoFChk
+#define MagickAtoIChk GmMagickAtoIChk
+#define MagickAtoLChk GmMagickAtoLChk
+#define MagickAtoUIChk GmMagickAtoUIChk
+#define MagickAtoULChk GmMagickAtoULChk
 #define MagickBitStreamInitializeRead GmMagickBitStreamInitializeRead
 #define MagickBitStreamInitializeWrite GmMagickBitStreamInitializeWrite
 #define MagickBitStreamMSBRead GmMagickBitStreamMSBRead
 #define MagickCreateDirectoryPath GmMagickCreateDirectoryPath
 #define MagickDestroyCommandInfo GmMagickDestroyCommandInfo
 #define MagickFindRawImageMinMax GmMagickFindRawImageMinMax
+#define MagickFmax GmMagickFmax
+#define MagickFmin GmMagickFmin
 #define MagickFormatString GmMagickFormatString
 #define MagickFormatStringList GmMagickFormatStringList
 #define MagickFree GmMagickFree
 #define MagickFreeAligned GmMagickFreeAligned
-#define MagickFmin GmMagickFmin
-#define MagickFmax GmMagickFmax
 #define MagickGetBitRevTable GmMagickGetBitRevTable
+#define MagickGetFileAttributes GmMagickGetFileAttributes
 #define MagickGetFileSystemBlockSize GmMagickGetFileSystemBlockSize
 #define MagickGetMMUPageSize GmMagickGetMMUPageSize
 #define MagickGetQuantumSamplesPerPixel GmMagickGetQuantumSamplesPerPixel
+#define MagickGetToken GmMagickGetToken
 #define MagickInitializeCommandInfo GmMagickInitializeCommandInfo
 #define MagickIsTrue GmMagickIsTrue
 #define MagickMalloc GmMagickMalloc
 #define MagickReverseBits GmMagickReverseBits
 #define MagickSceneFileName GmMagickSceneFileName
 #define MagickSetConfirmAccessHandler GmMagickSetConfirmAccessHandler
+#define MagickSetFileAttributes GmMagickSetFileAttributes
 #define MagickSetFileSystemBlockSize GmMagickSetFileSystemBlockSize
 #define MagickSizeStrToInt64 GmMagickSizeStrToInt64
 #define MagickSpawnVP GmMagickSpawnVP
 #define MagickXWindowByName GmMagickXWindowByName
 #define MagickXWindowByProperty GmMagickXWindowByProperty
 #define MagnifyImage GmMagnifyImage
+#define MallocFunc GmMallocFunc
 #define MapBlob GmMapBlob
 #define MapImage GmMapImage
 #define MapImages GmMapImages
 #define MapModeToString GmMapModeToString
+#define MatteColor GmMatteColor
 #define MatteFloodfillImage GmMatteFloodfillImage
 #define MedianFilterImage GmMedianFilterImage
 #define MetricTypeToString GmMetricTypeToString
 #define OpaqueImage GmOpaqueImage
 #define OpenBlob GmOpenBlob
 #define OpenCacheView GmOpenCacheView
+#define OpenModule GmOpenModule
+#define OpenModules GmOpenModules
 #define OrderedDitherImage GmOrderedDitherImage
 #define OrientationTypeToString GmOrientationTypeToString
+#define PSDensityGeometry GmPSDensityGeometry
+#define PSPageGeometry GmPSPageGeometry
 #define PackbitsEncode2Image GmPackbitsEncode2Image
 #define PackbitsEncodeImage GmPackbitsEncodeImage
 #define PanicDestroyMagick GmPanicDestroyMagick
 #define PixelIterateDualNew GmPixelIterateDualNew
 #define PixelIterateDualRead GmPixelIterateDualRead
 #define PixelIterateMonoModify GmPixelIterateMonoModify
-#define PixelIterateMonoSet GmPixelIterateMonoSet
 #define PixelIterateMonoRead GmPixelIterateMonoRead
+#define PixelIterateMonoSet GmPixelIterateMonoSet
 #define PixelIterateTripleModify GmPixelIterateTripleModify
 #define PixelIterateTripleNew GmPixelIterateTripleNew
 #define PlasmaImage GmPlasmaImage
 #define PopImagePixels GmPopImagePixels
 #define PrependImageToList GmPrependImageToList
 #define ProfileImage GmProfileImage
-#define PSDensityGeometry GmPSDensityGeometry
-#define PSPageGeometry GmPSPageGeometry
 #define PurgeTemporaryFiles GmPurgeTemporaryFiles
 #define PurgeTemporaryFilesAsyncSafe GmPurgeTemporaryFilesAsyncSafe
 #define PushImagePixels GmPushImagePixels
 #define ReadBlobLSBShort GmReadBlobLSBShort
 #define ReadBlobLSBShortFromBuffer GmReadBlobLSBShortFromBuffer
 #define ReadBlobLSBShorts GmReadBlobLSBShorts
+#define ReadBlobLSBSignedLong GmReadBlobLSBSignedLong
+#define ReadBlobLSBSignedShort GmReadBlobLSBSignedShort
 #define ReadBlobMSBDouble GmReadBlobMSBDouble
 #define ReadBlobMSBDoubles GmReadBlobMSBDoubles
 #define ReadBlobMSBFloat GmReadBlobMSBFloat
 #define ReadBlobMSBLongs GmReadBlobMSBLongs
 #define ReadBlobMSBShort GmReadBlobMSBShort
 #define ReadBlobMSBShorts GmReadBlobMSBShorts
+#define ReadBlobMSBSignedLong GmReadBlobMSBSignedLong
+#define ReadBlobMSBSignedShort GmReadBlobMSBSignedShort
 #define ReadBlobString GmReadBlobString
 #define ReadBlobZC GmReadBlobZC
 #define ReadImage GmReadImage
 #define ReadInlineImage GmReadInlineImage
+#define ReallocFunc GmReallocFunc
 #define ReduceNoiseImage GmReduceNoiseImage
 #define ReferenceBlob GmReferenceBlob
 #define ReferenceCache GmReferenceCache
 #define ReferenceImage GmReferenceImage
 #define RegisterARTImage GmRegisterARTImage
-#define RegisterAVIImage GmRegisterAVIImage
 #define RegisterAVSImage GmRegisterAVSImage
 #define RegisterBMPImage GmRegisterBMPImage
 #define RegisterCALSImage GmRegisterCALSImage
 #define RegisterVIDImage GmRegisterVIDImage
 #define RegisterVIFFImage GmRegisterVIFFImage
 #define RegisterWBMPImage GmRegisterWBMPImage
+#define RegisterWEBPImage GmRegisterWEBPImage
 #define RegisterWMFImage GmRegisterWMFImage
 #define RegisterWPGImage GmRegisterWPGImage
 #define RegisterXBMImage GmRegisterXBMImage
 #define SampleImage GmSampleImage
 #define ScaleImage GmScaleImage
 #define SeekBlob GmSeekBlob
-#define SegmentImage GmSegmentImage
 #define SetBlobClosable GmSetBlobClosable
 #define SetBlobTemporary GmSetBlobTemporary
 #define SetCacheView GmSetCacheView
 #define SetFatalErrorHandler GmSetFatalErrorHandler
 #define SetGeometry GmSetGeometry
 #define SetImage GmSetImage
-#define SetImageEx GmSetImageEx
 #define SetImageAttribute GmSetImageAttribute
 #define SetImageChannelDepth GmSetImageChannelDepth
 #define SetImageClipMask GmSetImageClipMask
 #define SetImageColor GmSetImageColor
 #define SetImageColorRegion GmSetImageColorRegion
+#define SetImageCompositeMask GmSetImageCompositeMask
 #define SetImageDepth GmSetImageDepth
+#define SetImageEx GmSetImageEx
 #define SetImageInfo GmSetImageInfo
 #define SetImageOpacity GmSetImageOpacity
 #define SetImagePixels GmSetImagePixels
 #define SetImageVirtualPixelMethod GmSetImageVirtualPixelMethod
 #define SetLogEventMask GmSetLogEventMask
 #define SetLogFormat GmSetLogFormat
-#define SetLogMethod GmSetLogMethod
 #define SetMagickInfo GmSetMagickInfo
 #define SetMagickRegistry GmSetMagickRegistry
 #define SetMagickResourceLimit GmSetMagickResourceLimit
 #define StringToList GmStringToList
 #define StringToMetricType GmStringToMetricType
 #define StringToNoiseType GmStringToNoiseType
+#define StringToOrientationType GmStringToOrientationType
 #define StringToPreviewType GmStringToPreviewType
 #define StringToQuantumOperator GmStringToQuantumOperator
 #define StringToResolutionType GmStringToResolutionType
 #define UnlockSemaphoreInfo GmUnlockSemaphoreInfo
 #define UnmapBlob GmUnmapBlob
 #define UnregisterARTImage GmUnregisterARTImage
-#define UnregisterAVIImage GmUnregisterAVIImage
 #define UnregisterAVSImage GmUnregisterAVSImage
 #define UnregisterBMPImage GmUnregisterBMPImage
 #define UnregisterCALSImage GmUnregisterCALSImage
 #define UnregisterVIDImage GmUnregisterVIDImage
 #define UnregisterVIFFImage GmUnregisterVIFFImage
 #define UnregisterWBMPImage GmUnregisterWBMPImage
+#define UnregisterWEBPImage GmUnregisterWEBPImage
 #define UnregisterWMFImage GmUnregisterWMFImage
 #define UnregisterWPGImage GmUnregisterWPGImage
 #define UnregisterXBMImage GmUnregisterXBMImage
 #define WriteBlobFile GmWriteBlobFile
 #define WriteBlobLSBLong GmWriteBlobLSBLong
 #define WriteBlobLSBShort GmWriteBlobLSBShort
+#define WriteBlobLSBSignedLong GmWriteBlobLSBSignedLong
+#define WriteBlobLSBSignedShort GmWriteBlobLSBSignedShort
 #define WriteBlobMSBLong GmWriteBlobMSBLong
 #define WriteBlobMSBShort GmWriteBlobMSBShort
+#define WriteBlobMSBSignedLong GmWriteBlobMSBSignedLong
+#define WriteBlobMSBSignedShort GmWriteBlobMSBSignedShort
 #define WriteBlobString GmWriteBlobString
 #define WriteBlobStringEOL GmWriteBlobStringEOL
 #define WriteBlobStringWithEOL GmWriteBlobStringWithEOL
index 8ffd368..b4ef858 100644 (file)
@@ -136,7 +136,7 @@ static void ComposeTemporaryFileName(char *name)
   for (c=name; *c; c++)
     {
       if (*c == 'X')
-       *c=SafeChars[MagickRandomInteger() % (sizeof(SafeChars)-1)];
+        *c=SafeChars[MagickRandomInteger() % (sizeof(SafeChars)-1)];
     }
 }
 
@@ -312,10 +312,10 @@ MagickExport int AcquireTemporaryFileDescriptor(char *filename)
     {
       char
         tempname[16];
-      
+
       int
         tries=0;
-      
+
       for (tries=0; tries < 256; tries++)
         {
           (void) strlcpy(tempname,"gmXXXXXX",sizeof(tempname));
index 4a8e386..c958cfe 100644 (file)
@@ -1,10 +1,10 @@
 /*
   Copyright (C) 2003, 2004 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Temporary File Management
 */
 
index e5f3298..7f5b56a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2009 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2003 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -67,6 +67,10 @@ MagickExport Image *ConstituteTextureImage(const unsigned long columns,
   MagickPassFail
     status=MagickPass;
 
+#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
+  int num_threads=Min(8,omp_get_max_threads());
+#endif /* defined(HAVE_OPENMP) */
+
   assert(texture_image != (Image *) NULL);
   assert(texture_image->signature == MagickSignature);
 
@@ -75,18 +79,18 @@ MagickExport Image *ConstituteTextureImage(const unsigned long columns,
     return canvas_image;
 #if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
 #  if defined(TUNE_OPENMP)
-#    pragma omp parallel for schedule(runtime) shared(row_count, status)
+#    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for schedule(static,16) shared(row_count, status)
+#    pragma omp parallel for if(num_threads > 1) num_threads(num_threads) schedule(guided) shared(row_count, status)
 #  endif
 #endif
   for (y=0; y < (long) canvas_image->rows; y++)
     {
       const PixelPacket
-        *texture_pixels;
+        * restrict texture_pixels;
 
       PixelPacket
-        *canvas_pixels;
+        *restrict canvas_pixels;
 
       unsigned long
         x;
@@ -94,9 +98,6 @@ MagickExport Image *ConstituteTextureImage(const unsigned long columns,
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_ConstituteTextureImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -116,7 +117,7 @@ MagickExport Image *ConstituteTextureImage(const unsigned long columns,
         {
           const IndexPacket
             *texture_indexes=(const IndexPacket *) NULL;
-          
+
           IndexPacket
             *canvas_indexes=(IndexPacket *) NULL;;
 
@@ -147,20 +148,23 @@ MagickExport Image *ConstituteTextureImage(const unsigned long columns,
           if (!SyncImagePixelsEx(canvas_image,exception))
             thread_status=MagickFail;
         }
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_ConstituteTextureImage)
+#if defined(HAVE_OPENMP)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,canvas_image->rows))
-          if (!MagickMonitorFormatted(row_count,canvas_image->rows,exception,
-                                      ConstituteTextureImageText,
-                                      texture_image->filename))
-            thread_status=MagickFail;
+      row_count++;
+      if (QuantumTick(row_count,canvas_image->rows))
+        if (!MagickMonitorFormatted(row_count,canvas_image->rows,exception,
+                                    ConstituteTextureImageText,
+                                    texture_image->filename))
+          thread_status=MagickFail;
 
-        if (thread_status == MagickFail)
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
 
   if (status == MagickFail)
@@ -207,7 +211,7 @@ MagickExport Image *ConstituteTextureImage(const unsigned long columns,
 */
 
 #define TextureImageText  "[%s] Apply texture..."
-MagickExport MagickPassFail TextureImage(Image *image,const Image *texture)
+MagickExport MagickPassFail TextureImage(Image * restrict image,const Image * restrict texture)
 {
   MagickPassFail
     status=MagickPass;
@@ -237,7 +241,7 @@ MagickExport MagickPassFail TextureImage(Image *image,const Image *texture)
 #  if defined(TUNE_OPENMP)
 #    pragma omp parallel for schedule(runtime) shared(row_count, status)
 #  else
-#    pragma omp parallel for schedule(static,4) shared(row_count, status)
+#    pragma omp parallel for schedule(guided) shared(row_count, status)
 #  endif
 #endif
   for (y=0; y < (long) image->rows; y++)
@@ -252,10 +256,10 @@ MagickExport MagickPassFail TextureImage(Image *image,const Image *texture)
         z;
 
       register const PixelPacket
-        *p;
+        * restrict p;
 
       register PixelPacket
-        *q;
+        * restrict q;
 
       unsigned long
         width;
@@ -263,9 +267,6 @@ MagickExport MagickPassFail TextureImage(Image *image,const Image *texture)
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_TextureImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -322,18 +323,21 @@ MagickExport MagickPassFail TextureImage(Image *image,const Image *texture)
             thread_status=MagickFail;
         }
 #if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_TextureImage)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,image->rows))
-          if (!MagickMonitorFormatted(row_count,image->rows,&image->exception,
-                                      TextureImageText,image->filename))
-            thread_status=MagickFail;
+      row_count++;
+      if (QuantumTick(row_count,image->rows))
+        if (!MagickMonitorFormatted(row_count,image->rows,&image->exception,
+                                    TextureImageText,image->filename))
+          thread_status=MagickFail;
 
-        if (thread_status == MagickFail)
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
 
   if (image->matte)
index 804c517..050a481 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 - 2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Texture Methods.
 */
 #ifndef _MAGICK_TEXTURE_H
@@ -24,7 +24,7 @@ extern "C" {
 \f
 extern MagickExport Image
   *ConstituteTextureImage(const unsigned long columns,const unsigned long rows,
-                         const Image *texture,ExceptionInfo *exception);
+                          const Image *texture,ExceptionInfo *exception);
 
 extern MagickExport MagickPassFail
   TextureImage(Image *,const Image *);
index 3dd42c2..1ed1d20 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   ImageMagick Timer Methods.
 */
 #ifndef _MAGICK_TIMER_H
index 04d1c20..b18d5b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2015 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -148,25 +148,22 @@ MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info,
     {
       register const PixelPacket
         *p;
-    
+
       register const IndexPacket
         *indexes;
-    
+
       register IndexPacket
         *chop_indexes;
-    
+
       register long
         x;
-    
+
       register PixelPacket
         *q;
 
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_ChopImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -196,18 +193,21 @@ MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info,
             thread_status=MagickFail;
         }
 #if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_ChopImage)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,chop_image->rows))
-          if (!MagickMonitorFormatted(row_count,chop_image->rows,exception,
-                                      ChopImageText,image->filename))
-            thread_status=MagickFail;
-          
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,chop_image->rows))
+        if (!MagickMonitorFormatted(row_count,chop_image->rows,exception,
+                                    ChopImageText,image->filename))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
   /*
     Extract chop image.
@@ -223,25 +223,22 @@ MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info,
     {
       register const PixelPacket
         *p;
-    
+
       register const IndexPacket
         *indexes;
-    
+
       register IndexPacket
         *chop_indexes;
-    
+
       register long
         x;
-    
+
       register PixelPacket
         *q;
 
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_ChopImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -271,18 +268,21 @@ MagickExport Image *ChopImage(const Image *image,const RectangleInfo *chop_info,
             thread_status=MagickFail;
         }
 #if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_ChopImage)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,chop_image->rows))
-          if (!MagickMonitorFormatted(row_count,chop_image->rows,exception,
-                                      ChopImageText,image->filename))
-            thread_status=MagickFail;
-          
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,chop_image->rows))
+        if (!MagickMonitorFormatted(row_count,chop_image->rows,exception,
+                                    ChopImageText,image->filename))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
   if (row_count < chop_image->rows)
     {
@@ -333,7 +333,7 @@ MagickExport Image *CoalesceImages(const Image *image,ExceptionInfo *exception)
 
   register long
     i;
-  
+
   MagickBool
     found_transparency=False;
 
@@ -373,8 +373,8 @@ MagickExport Image *CoalesceImages(const Image *image,ExceptionInfo *exception)
       case BackgroundDispose:
       {
         /*
-         Fill image with transparent color, if one exists.
-       */
+          Fill image with transparent color, if one exists.
+        */
         coalesce_image->next=CloneImage(coalesce_image,0,0,True,exception);
         if (coalesce_image->next != (Image *) NULL) {
           for (i = 0; i < (long) coalesce_image->colors; i++) {
@@ -560,9 +560,6 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry,
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_CropImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -585,21 +582,24 @@ MagickExport Image *CropImage(const Image *image,const RectangleInfo *geometry,
             thread_status=MagickFail;
         }
 #if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_CropImage)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,crop_image->rows))
-          if (!MagickMonitorFormatted(row_count,crop_image->rows,exception,
-                                      "[%s] Crop: %lux%lu+%ld+%ld...",
-                                      crop_image->filename,
-                                      crop_image->columns,crop_image->rows,
-                                      page.x,page.y))
-            thread_status=MagickFail;
-          
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,crop_image->rows))
+        if (!MagickMonitorFormatted(row_count,crop_image->rows,exception,
+                                    "[%s] Crop: %lux%lu+%ld+%ld...",
+                                    crop_image->filename,
+                                    crop_image->columns,crop_image->rows,
+                                    page.x,page.y))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
   if (row_count < crop_image->rows)
     {
@@ -838,7 +838,7 @@ MagickExport Image *DeconstructImages(const Image *image,
 %
 */
 MagickExport Image *ExtentImage(const Image *image,const RectangleInfo *geometry,
-                               ExceptionInfo *exception)
+                                ExceptionInfo *exception)
 {
   Image
     *extent_image;
@@ -853,7 +853,7 @@ MagickExport Image *ExtentImage(const Image *image,const RectangleInfo *geometry
     Allocate canvas image
   */
   if ((extent_image=CloneImage(image,geometry->width,geometry->height,
-                              MagickTrue,exception)) == (Image *) NULL)
+                               MagickTrue,exception)) == (Image *) NULL)
     return((Image *) NULL);
 
   /*
@@ -871,7 +871,7 @@ MagickExport Image *ExtentImage(const Image *image,const RectangleInfo *geometry
     operator.
   */
   if ((CompositeImage(extent_image,image->compose,image,geometry->x,
-                     geometry->y)) == MagickFail)
+                      geometry->y)) == MagickFail)
     {
       CopyException(exception,&extent_image->exception);
       DestroyImage(extent_image);
@@ -932,18 +932,18 @@ MagickExport Image *FlattenImages(const Image *image,ExceptionInfo *exception)
   */
   if ((flatten_image != (Image *) NULL) && (flatten_image->matte))
     (void) MagickCompositeImageUnderColor(flatten_image,
-                                         &flatten_image->background_color,
-                                         exception);
+                                          &flatten_image->background_color,
+                                          exception);
 
   if ((flatten_image != (Image *) NULL) &&
       (image->next != (Image *) NULL))
     {
       /*
-       Flatten remaining images onto canvas
+        Flatten remaining images onto canvas
       */
       for (next=image->next; next != (Image *) NULL; next=next->next)
-       (void) CompositeImage(flatten_image,next->compose,next,next->page.x,
-                             next->page.y);
+        (void) CompositeImage(flatten_image,next->compose,next,next->page.x,
+                              next->page.y);
     }
   return(flatten_image);
 }
@@ -1036,9 +1036,6 @@ MagickExport Image *FlipImage(const Image *image,ExceptionInfo *exception)
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_FlipImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -1061,18 +1058,21 @@ MagickExport Image *FlipImage(const Image *image,ExceptionInfo *exception)
             thread_status=MagickFail;
         }
 #if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_FlipImage)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,flip_image->rows))
-          if (!MagickMonitorFormatted(row_count,flip_image->rows,exception,
-                                      FlipImageText,image->filename))
-            thread_status=MagickFail;
-          
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,flip_image->rows))
+        if (!MagickMonitorFormatted(row_count,flip_image->rows,exception,
+                                    FlipImageText,image->filename))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
   if (row_count < flip_image->rows)
     {
@@ -1165,9 +1165,6 @@ MagickExport Image *FlopImage(const Image *image,ExceptionInfo *exception)
       MagickBool
         thread_status;
 
-#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_FlopImage)
-#endif
       thread_status=status;
       if (thread_status == MagickFail)
         continue;
@@ -1195,18 +1192,21 @@ MagickExport Image *FlopImage(const Image *image,ExceptionInfo *exception)
             thread_status=MagickFail;
         }
 #if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
-#  pragma omp critical (GM_FlopImage)
+#  pragma omp atomic
 #endif
-      {
-        row_count++;
-        if (QuantumTick(row_count,flop_image->rows))
-          if (!MagickMonitorFormatted(row_count,flop_image->rows,exception,
-                                      FlopImageText,image->filename))
-            thread_status=MagickFail;
-          
-        if (thread_status == MagickFail)
+      row_count++;
+      if (QuantumTick(row_count,flop_image->rows))
+        if (!MagickMonitorFormatted(row_count,flop_image->rows,exception,
+                                    FlopImageText,image->filename))
+          thread_status=MagickFail;
+
+      if (thread_status == MagickFail)
+        {
           status=MagickFail;
-      }
+#if defined(HAVE_OPENMP) && !defined(DisableSlowOpenMP)
+#  pragma omp flush (status)
+#endif
+        }
     }
   if (row_count < flop_image->rows)
     {
@@ -1330,11 +1330,16 @@ MagickExport Image *MosaicImages(const Image *image,ExceptionInfo *exception)
   MagickPassFail
     status;
 
+  size_t
+    image_list_length;
+
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickSignature);
 
+  image_list_length=GetImageListLength(image);
+
   /*
     Determine mosaic bounding box.
   */
@@ -1374,7 +1379,7 @@ MagickExport Image *MosaicImages(const Image *image,ExceptionInfo *exception)
   {
     (void) CompositeImage(mosaic_image,next->compose,next,next->page.x,
       next->page.y);
-    status=MagickMonitorFormatted(scene++,GetImageListLength(image),
+    status=MagickMonitorFormatted(scene++,image_list_length,
                                   exception,MosaicImageText,image->filename);
     if (status == MagickFail)
       break;
@@ -1530,7 +1535,7 @@ MagickExport Image *ShaveImage(const Image *image,
 %   T r a n s f o r m I m a g e                                               %
 %                                                                             %
 %                                                                             %
-%                                                                             % 
+%                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
 %  TransformImage() is a convenience method that behaves like ResizeImage() or
@@ -1556,7 +1561,7 @@ MagickExport Image *ShaveImage(const Image *image,
 %
 */
 MagickExport void TransformImage(Image **image,const char *crop_geometry,
-                                const char *image_geometry)
+                                 const char *image_geometry)
 {
   Image
     *previous,
@@ -1585,9 +1590,9 @@ MagickExport void TransformImage(Image **image,const char *crop_geometry,
       if ((geometry.width == 0) || (geometry.height == 0) ||
           ((flags & XValue) != 0) || ((flags & YValue) != 0) ||
           (flags & PercentValue))
-       {
-         crop_image=CropImage(transform_image,&geometry,&(*image)->exception);
-       }
+        {
+          crop_image=CropImage(transform_image,&geometry,&(*image)->exception);
+        }
       else
         if ((transform_image->columns > geometry.width) ||
             (transform_image->rows > geometry.height))
@@ -1610,38 +1615,38 @@ MagickExport void TransformImage(Image **image,const char *crop_geometry,
             height=geometry.height;
             next=(Image *) NULL;
             for (y=0; y < (long) transform_image->rows; y+=height)
-             {
-               for (x=0; x < (long) transform_image->columns; x+=width)
-                 {
-                   geometry.width=width;
-                   geometry.height=height;
-                   geometry.x=x;
-                   geometry.y=y;
-                   next=CropImage(transform_image,&geometry,&(*image)->exception);
-                   if (next == (Image *) NULL)
-                     break;
-                   if (crop_image == (Image *) NULL)
-                     crop_image=next;
-                   else
-                     {
-                       next->previous=crop_image;
-                       crop_image->next=next;
-                       crop_image=crop_image->next;
-                     }
-                 }
-               if (next == (Image *) NULL)
-                 break;
-             }
+              {
+                for (x=0; x < (long) transform_image->columns; x+=width)
+                  {
+                    geometry.width=width;
+                    geometry.height=height;
+                    geometry.x=x;
+                    geometry.y=y;
+                    next=CropImage(transform_image,&geometry,&(*image)->exception);
+                    if (next == (Image *) NULL)
+                      break;
+                    if (crop_image == (Image *) NULL)
+                      crop_image=next;
+                    else
+                      {
+                        next->previous=crop_image;
+                        crop_image->next=next;
+                        crop_image=crop_image->next;
+                      }
+                  }
+                if (next == (Image *) NULL)
+                  break;
+              }
           }
       if (crop_image != (Image *) NULL)
         {
-         previous=transform_image->previous;
-         crop_image->next=transform_image->next;
+          previous=transform_image->previous;
+          crop_image->next=transform_image->next;
           DestroyImage(transform_image);
-         transform_image=(Image *) NULL;
+          transform_image=(Image *) NULL;
           while (crop_image->previous != (Image *) NULL)
             crop_image=crop_image->previous;
-         crop_image->previous=previous;
+          crop_image->previous=previous;
           transform_image=crop_image;
         }
       *image=transform_image;
@@ -1654,16 +1659,16 @@ MagickExport void TransformImage(Image **image,const char *crop_geometry,
   */
   SetGeometry(transform_image,&geometry);
   flags=GetMagickGeometry(image_geometry,&geometry.x,&geometry.y,
-                         &geometry.width,&geometry.height);
+                          &geometry.width,&geometry.height);
   if ((transform_image->columns == geometry.width) &&
       (transform_image->rows == geometry.height))
     return;
-  
+
   /*
     Resize image.
   */
   resize_image=ZoomImage(transform_image,geometry.width,geometry.height,
-                        &(*image)->exception);
+                         &(*image)->exception);
   if (resize_image == (Image *) NULL)
     return;
 
index a7f477f..812f01d 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 - 2010 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   ImageMagick Image Transform Methods.
 */
 #ifndef _MAGICK_TRANSFORM_H
index 24ed438..773ac89 100644 (file)
@@ -1,6 +1,6 @@
 /*
   Copyright (C) 2005,2013,2014 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
index 559fccf..e8a08d0 100644 (file)
@@ -1,6 +1,6 @@
 /*
   Copyright (C) 2005,2012 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
index 4cbaa77..b55ee94 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 - 2009 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   Drawing methods.
 */
 #ifndef _MAGICK_TYPE_H
index 68c582b..aa533ee 100644 (file)
@@ -78,10 +78,10 @@ MagickExport long MagickGetMMUPageSize(void)
 #endif /* defined(HAVE_SYSCONF) && defined(_SC_PAGE_SIZE) */
 #if defined(HAVE_GETPAGESIZE)
       if (pagesize <= 0)
-       pagesize=getpagesize();
+        pagesize=getpagesize();
 #endif /* defined(HAVE_GETPAGESIZE) */
       if (pagesize <= 0)
-       pagesize=16384;
+        pagesize=16384;
     }
 
   return pagesize;
index e65ff4e..82842f8 100644 (file)
@@ -1,12 +1,12 @@
 /*
   Copyright (C) 2007-2016 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
 
   Interfaces specific to Unix.
+
 */
 #ifndef _UNIX_PORT_H
 #define _UNIX_PORT_H
index 7f18dff..16992ab 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003 - 2016 GraphicsMagick Group
+% Copyright (C) 2003 - 2018 GraphicsMagick Group
 % Copyright (c) 2000 Markus Friedl.  All rights reserved.
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 #endif
 
 /*
-  Compute a value which is the next kilobyte power of 2 larger than
-  the requested value or MaxTextExtent, whichever is larger.
-
-  The objective is to round up the size quickly (and in repeatable
-  steps) in order to reduce the number of memory copies due to realloc
-  for strings which grow rapidly, while producing a reasonable size
-  for smaller strings.
-*/
-#define MagickRoundUpStringLength(size) \
-{ \
-  size_t \
-    _rounded; \
- \
-  for (_rounded=256U; _rounded < (Max(size,256)); _rounded *= 2); \
-  size=_rounded; \
-}
-
-/*
   Static declarations.
 */
 static const char
@@ -935,104 +917,104 @@ MagickExport MagickPassFail ExpandFilenames(int *argc,char ***argv)
   for (i=0; i < *argc; i++)
     {
       char
-       **filelist,
-       filename[MaxTextExtent],
-       magick[MaxTextExtent],
-       path[MaxTextExtent],
-       subimage[MaxTextExtent];
+        **filelist,
+        filename[MaxTextExtent],
+        magick[MaxTextExtent],
+        path[MaxTextExtent],
+        subimage[MaxTextExtent];
 
       option=(*argv)[i];
       /* Never throw options away, so copy here, then perhaps modify later */
       vector[count++]=AcquireString(option);
 
       /*
-       Don't expand or process any VID: argument since the VID coder
-       does its own expansion
+        Don't expand or process any VID: argument since the VID coder
+        does its own expansion
       */
       if (LocaleNCompare("VID:",option,4) == 0)
-       continue;
+        continue;
 
       /*
-       Don't attempt to expand the argument to these options.
+        Don't attempt to expand the argument to these options.
       */
       if ((LocaleNCompare("+define",option,7) == 0) ||
-         (LocaleNCompare("+profile",option,8) == 0) ||
-         (LocaleNCompare("-comment",option,8) == 0) ||
-         (LocaleNCompare("-convolve",option,9) == 0) ||
-         (LocaleNCompare("-draw",option,5) == 0) ||
-         (LocaleNCompare("-font",option,5) == 0) ||
-         (LocaleNCompare("-format",option,7) == 0) ||
-         (LocaleNCompare("-label",option,6) == 0))
-       {
-         i++;
-         if (i == *argc)
+          (LocaleNCompare("+profile",option,8) == 0) ||
+          (LocaleNCompare("-comment",option,8) == 0) ||
+          (LocaleNCompare("-convolve",option,9) == 0) ||
+          (LocaleNCompare("-draw",option,5) == 0) ||
+          (LocaleNCompare("-font",option,5) == 0) ||
+          (LocaleNCompare("-format",option,7) == 0) ||
+          (LocaleNCompare("-label",option,6) == 0))
+        {
+          i++;
+          if (i == *argc)
             continue;
-         option=(*argv)[i];
-         vector[count++]=AcquireString(option);
-         continue;
-       }
+          option=(*argv)[i];
+          vector[count++]=AcquireString(option);
+          continue;
+        }
 
       /* Pass quotes through to the command-line parser */
       if ((*option == '"') || (*option == '\''))
-       continue;
+        continue;
 
       /*
-       Expand @filename to a list of arguments.
+        Expand @filename to a list of arguments.
       */
       j=0;
       if (option[0] == '@')
-       {
-         FILE
-           *file;
-
-         file=fopen(option+1,"r");
-         if (file != (FILE *) NULL)
-           {
-
-             first=MagickTrue;
-             number_files=0;
-             while (fgets(filename,sizeof(filename),file) != (char *) NULL)
-               {
-                 for (j=0; filename[j] != '\0'; j++)
-                   if (filename[j] == '\n')
-                     filename[j] = '\0';
-             
-                 if (filename[0] != '\0')
-                   {
-                     if ((number_files % prealloc_entries) == 0)
-                       {
-                         MagickReallocMemory(char **,vector,
-                                             (*argc+count+prealloc_entries)*
-                                             sizeof(char *));
-                         if (vector == (char **) NULL)
-                           {
-                             fclose(file);
-                             return(MagickFail);
-                           }
-                       }
-
-                     if (first)
-                       {
-                         /* Deallocate original option assigned above */
-                         --count;
-                         MagickFreeMemory(vector[count]);
-                         first=MagickFalse;
-                       }
-                     number_files++;
-                     vector[count++]=AcquireString(filename);
-                   }
-               }
-
-             fclose(file);
-           }
-       }
-
-      /* 
-        Fast cycle options that are not expandable filename patterns.
-        ListFiles only expands patterns in the filename.  We also check
-        if the full option resolves to a file since ListFiles() obtains
-        a list of all the files in the directory and is thus very slow
-        if there are thousands of files.
+        {
+          FILE
+            *file;
+
+          file=fopen(option+1,"r");
+          if (file != (FILE *) NULL)
+            {
+
+              first=MagickTrue;
+              number_files=0;
+              while (fgets(filename,sizeof(filename),file) != (char *) NULL)
+                {
+                  for (j=0; filename[j] != '\0'; j++)
+                    if (filename[j] == '\n')
+                      filename[j] = '\0';
+
+                  if (filename[0] != '\0')
+                    {
+                      if ((number_files % prealloc_entries) == 0)
+                        {
+                          MagickReallocMemory(char **,vector,
+                                              (*argc+count+prealloc_entries)*
+                                              sizeof(char *));
+                          if (vector == (char **) NULL)
+                            {
+                              fclose(file);
+                              return(MagickFail);
+                            }
+                        }
+
+                      if (first)
+                        {
+                          /* Deallocate original option assigned above */
+                          --count;
+                          MagickFreeMemory(vector[count]);
+                          first=MagickFalse;
+                        }
+                      number_files++;
+                      vector[count++]=AcquireString(filename);
+                    }
+                }
+
+              fclose(file);
+            }
+        }
+
+      /*
+         Fast cycle options that are not expandable filename patterns.
+         ListFiles only expands patterns in the filename.  We also check
+         if the full option resolves to a file since ListFiles() obtains
+         a list of all the files in the directory and is thus very slow
+         if there are thousands of files.
       */
       GetPathComponent(option,TailPath,filename);
       if ((!IsGlob(filename)) || IsAccessibleNoLogging(option))
@@ -1045,110 +1027,110 @@ MagickExport MagickPassFail ExpandFilenames(int *argc,char ***argv)
 
       /* GetPathComponent throws away the colon */
       if (*magick != '\0')
-       (void) strlcat(magick,":",sizeof(magick));
+        (void) strlcat(magick,":",sizeof(magick));
       ExpandFilename(path);
 
       if ('\0' == current_directory[0])
-       if (getcwd(current_directory,MaxTextExtent-1) == NULL)
+        if (getcwd(current_directory,MaxTextExtent-1) == NULL)
           MagickFatalError(ConfigureFatalError,UnableToGetCurrentDirectory,
                            NULL);
 
       /* Get the list of matching file names. */
       filelist=ListFiles(*path=='\0' ? current_directory : path,
-                        filename,&number_files);
+                         filename,&number_files);
 
       if (filelist != (char **) NULL)
-       for (j=0; j < number_files; j++)
-         if (IsDirectory(filelist[j]) <= 0)
-           break;
+        for (j=0; j < number_files; j++)
+          if (IsDirectory(filelist[j]) <= 0)
+            break;
 
       /* ListFiles() may change current directory without restoring. */
       if ((strlen(current_directory) > 0) && (chdir(current_directory) != 0))
         {
           for (j=0; j < number_files; j++)
-           MagickFreeMemory(filelist[j]);
+            MagickFreeMemory(filelist[j]);
           MagickFreeMemory(filelist);
           MagickFatalError(ConfigureFatalError,UnableToRestoreCurrentDirectory,
                            NULL);
         }
 
       if (filelist == 0)
-       continue;
+        continue;
 
       if (j == number_files)
-       {
-         /*
-           Bourne/Bash shells passes through unchanged any glob patterns
-           not matching anything (abc* and there's no file starting with
-           abc). Do the same for behaviour consistent with that.
-         */
-         for (j=0; j < number_files; j++)
-           MagickFreeMemory(filelist[j]);
-         MagickFreeMemory(filelist);
-         continue;
-       }
+        {
+          /*
+            Bourne/Bash shells passes through unchanged any glob patterns
+            not matching anything (abc* and there's no file starting with
+            abc). Do the same for behaviour consistent with that.
+          */
+          for (j=0; j < number_files; j++)
+            MagickFreeMemory(filelist[j]);
+          MagickFreeMemory(filelist);
+          continue;
+        }
 
       /*
-       There's at least one matching filename.
-       Transfer file list to argument vector.
+        There's at least one matching filename.
+        Transfer file list to argument vector.
       */
       MagickReallocMemory(char **,vector,
-                         (*argc+count+number_files+prealloc_entries)*sizeof(char *));
+                          (*argc+count+number_files+prealloc_entries)*sizeof(char *));
       if (vector == (char **) NULL)
-       return(MagickFail);
+        return(MagickFail);
 
       first=MagickTrue;
       for (j=0; j < number_files; j++)
-       {
-         char
-           filename_buffer[MaxTextExtent];
-
-         *filename_buffer='\0';
-         if (strlcat(filename_buffer,path,sizeof(filename_buffer))
-             >= sizeof(filename_buffer))
-           MagickFatalError2(ResourceLimitFatalError,"Path buffer overflow",
-                             filename_buffer);
-         if (*path != '\0')
-           {
-             if (strlcat(filename_buffer,DirectorySeparator,sizeof(filename_buffer))
-                 >= sizeof(filename_buffer))
-               MagickFatalError2(ResourceLimitFatalError,"Path buffer overflow",
-                                 filename_buffer);
-           }
-         if (strlcat(filename_buffer,filelist[j],sizeof(filename_buffer))
-             >= sizeof(filename_buffer))
-           MagickFatalError2(ResourceLimitFatalError,"Path buffer overflow",
-                             filename_buffer);
-         /* If it's a filename (not a directory) ... */
-         if (IsDirectory(filename_buffer) == 0) 
-           {
-             char
-               formatted_buffer[MaxTextExtent];
-
-             *formatted_buffer='\0';
-             if (strlcat(formatted_buffer,magick,sizeof(formatted_buffer))
-                 >= sizeof(formatted_buffer))
-               MagickFatalError2(ResourceLimitFatalError,"Path buffer overflow",
-                                 formatted_buffer);
-             if (strlcat(formatted_buffer,filename_buffer,sizeof(formatted_buffer))
-                 >= sizeof(formatted_buffer))
-               MagickFatalError2(ResourceLimitFatalError,"Path buffer overflow",
-                                 formatted_buffer);
-             if (strlcat(formatted_buffer,subimage,sizeof(formatted_buffer))
-                 >= sizeof(formatted_buffer))
-               MagickFatalError2(ResourceLimitFatalError,"Path buffer overflow",
-                                 formatted_buffer);
-             if (first)
-               {
-                 /* Deallocate original option assigned above */
-                 --count;
-                 MagickFreeMemory(vector[count]);
-                 first=MagickFalse;
-               }
-             vector[count++]=AcquireString(formatted_buffer);
-           }
-         MagickFreeMemory(filelist[j]);
-       }
+        {
+          char
+            filename_buffer[MaxTextExtent];
+
+          *filename_buffer='\0';
+          if (strlcat(filename_buffer,path,sizeof(filename_buffer))
+              >= sizeof(filename_buffer))
+            MagickFatalError2(ResourceLimitFatalError,"Path buffer overflow",
+                              filename_buffer);
+          if (*path != '\0')
+            {
+              if (strlcat(filename_buffer,DirectorySeparator,sizeof(filename_buffer))
+                  >= sizeof(filename_buffer))
+                MagickFatalError2(ResourceLimitFatalError,"Path buffer overflow",
+                                  filename_buffer);
+            }
+          if (strlcat(filename_buffer,filelist[j],sizeof(filename_buffer))
+              >= sizeof(filename_buffer))
+            MagickFatalError2(ResourceLimitFatalError,"Path buffer overflow",
+                              filename_buffer);
+          /* If it's a filename (not a directory) ... */
+          if (IsDirectory(filename_buffer) == 0)
+            {
+              char
+                formatted_buffer[MaxTextExtent];
+
+              *formatted_buffer='\0';
+              if (strlcat(formatted_buffer,magick,sizeof(formatted_buffer))
+                  >= sizeof(formatted_buffer))
+                MagickFatalError2(ResourceLimitFatalError,"Path buffer overflow",
+                                  formatted_buffer);
+              if (strlcat(formatted_buffer,filename_buffer,sizeof(formatted_buffer))
+                  >= sizeof(formatted_buffer))
+                MagickFatalError2(ResourceLimitFatalError,"Path buffer overflow",
+                                  formatted_buffer);
+              if (strlcat(formatted_buffer,subimage,sizeof(formatted_buffer))
+                  >= sizeof(formatted_buffer))
+                MagickFatalError2(ResourceLimitFatalError,"Path buffer overflow",
+                                  formatted_buffer);
+              if (first)
+                {
+                  /* Deallocate original option assigned above */
+                  --count;
+                  MagickFreeMemory(vector[count]);
+                  first=MagickFalse;
+                }
+              vector[count++]=AcquireString(formatted_buffer);
+            }
+          MagickFreeMemory(filelist[j]);
+        }
       MagickFreeMemory(filelist);
     }
   *argc=count;
@@ -1239,7 +1221,7 @@ MagickExport void FormatSize(const magick_int64_t size,char *format)
 %
 %
 */
-MagickExport void FormatStringList(char *string,const char *format, 
+MagickExport void FormatStringList(char *string,const char *format,
                                    va_list operands)
 {
 #if defined(HAVE_VSNPRINTF)
@@ -1334,7 +1316,7 @@ MagickExport MagickPassFail GetExecutionPath(char *path)
     char
       executable_path[PATH_MAX*2],
       real_path[PATH_MAX+1];
-    
+
     bufsize=sizeof(executable_path);
     if (_NSGetExecutablePath(executable_path,&bufsize) == 0)
       if (realpath(executable_path,real_path) != NULL)
@@ -1357,7 +1339,7 @@ MagickExport MagickPassFail GetExecutionPath(char *path)
     long
       pid;
 
-    char 
+    char
       link_path[MaxTextExtent],
       real_path[PATH_MAX+1];
 
@@ -1476,16 +1458,16 @@ MagickExport MagickPassFail GetExecutionPathUsingName(char *path)
         const char
           *end = NULL,
           *start = search_path;
-        
+
         end=start+strlen(start);
         while ( start < end )
           {
             const char
               *separator;
-            
+
             int
               length;
-            
+
             separator = strchr(start,DirectoryListSeparator);
             if (separator)
               length=separator-start;
@@ -1850,9 +1832,9 @@ static int MagickStrToD(const char *start,char **end,double *value)
   int
     i,
     n=0;
-  
+
   p=start;
-  
+
   for (i=0; (*p != 0) && (*p != 'x') && (*p != ',') && (i < MaxTextExtent-2); i++)
     buff[i]=*p++;
   buff[i]=0;
@@ -2450,7 +2432,7 @@ MagickExport void GetPathComponent(const char *path,PathType type,
 
   /* first locate the spot were the filename begins */
   for (p=component+strlen(component); p > component; p--)
-    if (IsBasenameSeparator(*p))
+    if (IsBasenameSeparator(*p)) /* Is directory delimiter like '/' or '\\' */
       break;
 
   switch (type)
@@ -2608,7 +2590,7 @@ MagickExport void GetToken(const char *start,char **end,char *token)
 %  if the specification may be a subimage specification.  If the pattern is
 %  ultimately determined to be a subimage specification, then globbing is
 %  not performed.
-%  
+%
 %
 %  The format of the GlobExpression function is:
 %
@@ -3495,34 +3477,73 @@ MagickExport void LocaleUpper(char *string)
 \f
 MagickExport MagickPassFail MagickAtoFChk(const char *str, double *value)
 {
+  MagickPassFail status = MagickPass;
   char *estr=0;
   *value=strtod(str,&estr);
   if (str == estr)
-    *value=0.0;
-  return (str == estr ? MagickFail : MagickPass);
+    {
+      *value=0.0;
+      status=MagickFail;
+    }
+#if defined(INFINITY)
+  else if ((*value == +INFINITY) || (*value == -INFINITY))
+    {
+      *value=0.0;
+      status=MagickFail;
+      errno=ERANGE;
+    }
+#endif
+  else if (isnan(*value))
+    {
+      *value=0.0;
+      status=MagickFail;
+      errno=ERANGE;
+    }
+  return status;
 }
 \f
 MagickExport MagickPassFail MagickAtoIChk(const char *str, int *value)
 {
+  MagickPassFail status = MagickPass;
   char *estr=0;
   long lvalue;
   lvalue=strtol(str,&estr, 10);
-  if ((str == estr) || ((int) lvalue != lvalue))
-    lvalue=0;
+  if (str == estr)
+    {
+      lvalue=0;
+      status=MagickFail;
+      errno=EINVAL;
+    }
+  else if ((int) lvalue != lvalue)
+    {
+      lvalue=0;
+      status=MagickFail;
+      errno=ERANGE;
+    }
   *value=(int) lvalue;
-  return (str == estr ? MagickFail : MagickPass);
+  return status;
 }
 \f
 MagickExport MagickPassFail MagickAtoUIChk(const char *str, unsigned int *value)
 {
+  MagickPassFail status = MagickPass;
   char *estr=0;
   long lvalue;
   lvalue=strtol(str,&estr, 10);
-  if ((str == estr) || ((long) ((unsigned int) lvalue) != lvalue))
-    lvalue=0U;
+  if (str == estr)
+    {
+      lvalue=0U;
+      status=MagickFail;
+      errno=EINVAL;
+    }
+  else if ((long) ((unsigned int) lvalue) != lvalue)
+    {
+      lvalue=0U;
+      status=MagickFail;
+      errno=ERANGE;
+    }
   *value=(unsigned int) lvalue;
-  return (((str == estr) || ((long) ((unsigned int) lvalue) != lvalue))
-          ? MagickFail : MagickPass);
+  return status;
 }
 \f
 MagickExport MagickPassFail MagickAtoLChk(const char *str, long *value)
@@ -3536,14 +3557,24 @@ MagickExport MagickPassFail MagickAtoLChk(const char *str, long *value)
 \f
 MagickExport MagickPassFail MagickAtoULChk(const char *str, unsigned long *value)
 {
+  MagickPassFail status = MagickPass;
   char *estr=0;
   long lvalue;
   lvalue=strtol(str,&estr, 10);
-  if ((str == estr) || ((long) ((unsigned long) lvalue) != lvalue))
-    lvalue=0L;
+  if (str == estr)
+    {
+      lvalue=0L;
+      status=MagickFail;
+      errno=EINVAL;
+    }
+  else if ((long) ((unsigned long) lvalue) != lvalue)
+    {
+      lvalue=0L;
+      status=MagickFail;
+      errno=ERANGE;
+    }
   *value=(unsigned long) lvalue;
-  return (((str == estr) || ((long) ((unsigned long) lvalue) != lvalue)) ?
-          MagickFail : MagickPass);
+  return status;
 }
 \f
 /*
@@ -3648,7 +3679,7 @@ double MagickFmax(const double x, const double y)
 */
 MagickExport void MagickFormatStringList(char *string,
                                          const size_t length,
-                                         const char *format, 
+                                         const char *format,
                                          va_list operands)
 {
 #if defined(HAVE_VSNPRINTF)
@@ -3827,7 +3858,7 @@ MagickExport size_t MagickGetToken(const char *start,char **end,char *token,
         ((r = strrchr(token,')')) != NULL))
       {
         *r='\0';
-        (void) memmove(token,token+5,r-token+1);
+        (void) memmove(token,token+5,r-token-4);
       }
   }
   if (end != (char **) NULL)
@@ -4029,14 +4060,14 @@ MagickSpawnVP(const unsigned int verbose,const char *file, char *const argv[])
     */
     ExceptionInfo
       exception;
-    
+
     GetExceptionInfo(&exception);
     if (MagickConfirmAccess(FileExecuteConfirmAccessMode,argv[0],&exception)
-       == MagickFail)
+        == MagickFail)
       {
-       errno=EPERM;
-       DestroyExceptionInfo(&exception);
-       return -1;
+        errno=EPERM;
+        DestroyExceptionInfo(&exception);
+        return -1;
       }
   }
 
@@ -4053,47 +4084,47 @@ MagickSpawnVP(const unsigned int verbose,const char *file, char *const argv[])
     child_pid = fork( );
     if ( (pid_t)-1 == child_pid)
       {
-       /* Failed to fork, errno contains reason */
-       status = -1;
-       FormatString(message,"fork failed: %.1024s", strerror(errno));
+        /* Failed to fork, errno contains reason */
+        status = -1;
+        FormatString(message,"fork failed: %.1024s", strerror(errno));
       }
     else if ( 0 == child_pid )
       {
-       /* We are the child process, exec program with arguments. */
-       status = execvp(file, argv);
+        /* We are the child process, exec program with arguments. */
+        status = execvp(file, argv);
 
-       /* If we get here, then execvp must have failed. */
-       (void) fprintf(stderr, "execvp failed, errno = %d (%s)\n",errno,strerror(errno));
+        /* If we get here, then execvp must have failed. */
+        (void) fprintf(stderr, "execvp failed, errno = %d (%s)\n",errno,strerror(errno));
 
-       /* If there is an execvp error, then call _exit() */
-       _exit(1);
+        /* If there is an execvp error, then call _exit() */
+        _exit(1);
       }
     else
       {
-       /* We are the parent process, wait for child. */
-       pid_t waitpid_status;
-       int child_status = 0;
-       waitpid_status = waitpid(child_pid, &child_status, 0);
-       if ( (pid_t)-1 == waitpid_status )
-         {
-           /* Waitpid error */
-           status = -1;
-           FormatString(message, "waitpid failed: %.1024s", strerror(errno));
-         }
-       else if ( waitpid_status == child_pid )
-         {
-           /* Status is available for child process */
-           if ( WIFEXITED( child_status ) )
-             {
-               status =  WEXITSTATUS( child_status );
-             }
-           else if ( WIFSIGNALED( child_status ) )
-             {
-               int sig_num = WTERMSIG( child_status );
-               status = -1;
-               FormatString(message, "child process quit due to signal %d", sig_num);
-             }
-         }
+        /* We are the parent process, wait for child. */
+        pid_t waitpid_status;
+        int child_status = 0;
+        waitpid_status = waitpid(child_pid, &child_status, 0);
+        if ( (pid_t)-1 == waitpid_status )
+          {
+            /* Waitpid error */
+            status = -1;
+            FormatString(message, "waitpid failed: %.1024s", strerror(errno));
+          }
+        else if ( waitpid_status == child_pid )
+          {
+            /* Status is available for child process */
+            if ( WIFEXITED( child_status ) )
+              {
+                status =  WEXITSTATUS( child_status );
+              }
+            else if ( WIFSIGNALED( child_status ) )
+              {
+                int sig_num = WTERMSIG( child_status );
+                status = -1;
+                FormatString(message, "child process quit due to signal %d", sig_num);
+              }
+          }
       }
   }
 #endif
@@ -4105,29 +4136,29 @@ MagickSpawnVP(const unsigned int verbose,const char *file, char *const argv[])
   if (verbose || (status != 0))
     {
       const char
-       *message_p = (const char *) NULL;
+        *message_p = (const char *) NULL;
 
       char
-       *command;
+        *command;
 
       unsigned int
-       i;
+        i;
 
       command = AllocateString((const char*) NULL);
       for (i = 0; argv[i] != (const char*) NULL; i++)
-       {
-         char
-           buffer[MaxTextExtent];
+        {
+          char
+            buffer[MaxTextExtent];
 
-         FormatString(buffer,"\"%.1024s\"", argv[i]);
+          FormatString(buffer,"\"%.1024s\"", argv[i]);
 
-         if (0 != i)
-           (void) ConcatenateString(&command," ");
+          if (0 != i)
+            (void) ConcatenateString(&command," ");
 
-         (void) ConcatenateString(&command,buffer);
-       }
+          (void) ConcatenateString(&command,buffer);
+        }
       if (message[0] != '\0')
-       message_p = message;
+        message_p = message;
       MagickError2(DelegateError,command,message_p);
       MagickFreeMemory(command);
     }
@@ -4483,13 +4514,13 @@ MagickExport size_t MagickStrlCat(char *dst, const char *src, const size_t size)
   if (size >= 1)
     {
       char
-       *p;
+        *p;
 
       for ( p = dst + length ;
-           (*q != 0) && (length < size - 1) ;
-           length++, p++, q++ )
-       *p = *q;
-      
+            (*q != 0) && (length < size - 1) ;
+            length++, p++, q++ )
+        *p = *q;
+
       dst[length]='\0';
     }
 
@@ -4563,13 +4594,13 @@ MagickExport size_t MagickStrlCpy(char *dst, const char *src, const size_t size)
   if (size >= 1)
     {
       char
-       *p;
+        *p;
 
       for ( p=dst ;
-           (*q != 0) && (length < size-1) ;
-           length++, p++, q++ )
-       *p = *q;
-      
+            (*q != 0) && (length < size-1) ;
+            length++, p++, q++ )
+        *p = *q;
+
       dst[length]='\0';
     }
 
@@ -4632,13 +4663,13 @@ MagickExport size_t MagickStrlCpyTrunc(char *dst, const char *src, const size_t
   if (size >= 1)
     {
       char
-       *p;
+        *p;
 
       for ( p=dst, q=src;
-           (*q != 0) && (length < size-1) ;
-           length++, p++, q++ )
-       *p = *q;
-      
+            (*q != 0) && (length < size-1) ;
+            length++, p++, q++ )
+        *p = *q;
+
       dst[length]='\0';
     }
 
@@ -5058,7 +5089,7 @@ MagickExport char **StringToList(const char *text)
   register const char
     *p;
 
-  register long
+  register size_t
     i;
 
   size_t
@@ -5078,26 +5109,21 @@ MagickExport char **StringToList(const char *text)
       for (p=text; *p != '\0'; p++)
         if (*p == '\n')
           lines++;
-      textlist=MagickAllocateMemory(char **,(lines+MaxTextExtent)*sizeof(char *));
+      textlist=MagickAllocateMemory(char **,(lines+1)*sizeof(char *));
       if (textlist == (char **) NULL)
         MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
           UnableToConvertText);
       p=text;
-      for (i=0; i < (long) lines; i++)
+      for (i=0; i < lines; i++)
       {
         for (q=(char *) p; *q != '\0'; q++)
           if ((*q == '\r') || (*q == '\n'))
             break;
-        textlist[i]=MagickAllocateMemory(char *,(size_t) (q-p+MaxTextExtent));
+        textlist[i]=MagickAllocateMemory(char *,(size_t) (q-p+1));
         if (textlist[i] == (char *) NULL)
           MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
             UnableToConvertText);
-       /*
-         Don't use strlcpy here because it spends too much time
-         looking for the trailing null in order to report the
-         characters not copied.
-       */
-       (void) strncpy(textlist[i],p,q-p);
+        (void) memcpy(textlist[i],p,q-p);
         textlist[i][q-p]='\0';
         if (*q == '\r')
           q++;
@@ -5106,30 +5132,35 @@ MagickExport char **StringToList(const char *text)
     }
   else
     {
+      const size_t
+        chars_per_line = 0x14;
+
       char
         hex_string[MaxTextExtent];
 
-      register long
+      register size_t
         j;
 
       /*
         Convert string to a HEX list.
       */
-      lines=(strlen(text)/0x14)+1;
-      textlist=MagickAllocateMemory(char **,(lines+MaxTextExtent)*sizeof(char *));
+      lines=(strlen(text)/chars_per_line)+1;
+      textlist=MagickAllocateMemory(char **,(lines+1)*sizeof(char *));
       if (textlist == (char **) NULL)
         MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
           UnableToConvertText);
       p=text;
-      for (i=0; i < (long) lines; i++)
+      for (i=0; i < lines; i++)
       {
+        /* FIXME: Allocation here is excessively large */
         textlist[i]=MagickAllocateMemory(char *,2*MaxTextExtent);
         if (textlist[i] == (char *) NULL)
           MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
             UnableToConvertText);
-        FormatString(textlist[i],"0x%08lx: ",0x14*i);
+        FormatString(textlist[i],"0x%08" MAGICK_SIZE_T_F "x: ",
+                     (MAGICK_SIZE_T) chars_per_line*i);
         q=textlist[i]+strlen(textlist[i]);
-        for (j=1; j <= (long) Min(strlen(p),0x14); j++)
+        for (j=1; j <= Min(strlen(p),chars_per_line); j++)
         {
           FormatString(hex_string,"%02x",*(p+j));
           (void) strlcpy(q,hex_string,MaxTextExtent);
@@ -5137,7 +5168,7 @@ MagickExport char **StringToList(const char *text)
           if ((j % 0x04) == 0)
             *q++=' ';
         }
-        for (; j <= 0x14; j++)
+        for (; j <= chars_per_line; j++)
         {
           *q++=' ';
           *q++=' ';
@@ -5145,7 +5176,7 @@ MagickExport char **StringToList(const char *text)
             *q++=' ';
         }
         *q++=' ';
-        for (j=1; j <= (long) Min(strlen(p),0x14); j++)
+        for (j=1; j <= Min(strlen(p),chars_per_line); j++)
         {
           if (isprint((int)(unsigned char)(*p)))
             *q++=(*p);
@@ -5262,30 +5293,30 @@ SubstituteString(char **buffer,const char *search,const char *replace)
   for (i=0; p[i] != '\0'; i++)
     {
       if ((p[i] == search[0]) && (strncmp(&p[i],search,search_len) == 0))
-       {
-         if (0 == replace_len)
-           replace_len=strlen(replace);
-         if (replace_len > search_len)
-           {
-             size_t
-               allocation_len;
-
-             allocation_len=strlen(p)+(replace_len-search_len)+1;
-             MagickRoundUpStringLength(allocation_len);
-             MagickReallocMemory(char *,p,allocation_len);
-             *buffer=p;
-             if (p == (char *) NULL)
-               MagickFatalError3(ResourceLimitFatalError,
-                                 MemoryAllocationFailed,
-                                 UnableToAllocateString);
-           }
-         if (search_len != replace_len)
-           (void) MagickCloneMemory(&p[i+replace_len],&p[i+search_len],
-                                    strlen(&p[i+search_len])+1);
-         (void) MagickCloneMemory(&p[i],replace,replace_len);
-         i += replace_len;
-         replaced=MagickTrue;
-       }
+        {
+          if (0 == replace_len)
+            replace_len=strlen(replace);
+          if (replace_len > search_len)
+            {
+              size_t
+                allocation_len;
+
+              allocation_len=strlen(p)+(replace_len-search_len)+1;
+              MagickRoundUpStringLength(allocation_len);
+              MagickReallocMemory(char *,p,allocation_len);
+              *buffer=p;
+              if (p == (char *) NULL)
+                MagickFatalError3(ResourceLimitFatalError,
+                                  MemoryAllocationFailed,
+                                  UnableToAllocateString);
+            }
+          if (search_len != replace_len)
+            (void) MagickCloneMemory(&p[i+replace_len],&p[i+search_len],
+                                     strlen(&p[i+search_len])+1);
+          (void) MagickCloneMemory(&p[i],replace,replace_len);
+          i += replace_len;
+          replaced=MagickTrue;
+        }
     }
   return replaced;
 }
@@ -5349,11 +5380,11 @@ MagickExport int SystemCommand(const unsigned int verbose,const char *command)
     program[0]='\0';
     MagickGetToken(command,&end,program,MaxTextExtent);
     if (MagickConfirmAccess(FileExecuteConfirmAccessMode,program,&exception)
-       == MagickFail)
+        == MagickFail)
       {
-       errno=EPERM;
-       DestroyExceptionInfo(&exception);
-       return -1;
+        errno=EPERM;
+        DestroyExceptionInfo(&exception);
+        return -1;
       }
   }
 
@@ -5550,6 +5581,8 @@ MagickExport int SystemCommand(const unsigned int verbose,const char *command)
 #define IN_QUOTE 2
 #define IN_OZONE 3
 
+static long sindex(char c,char *string) MAGICK_FUNC_PURE;
+
 static long sindex(char c,char *string)
 {
   register char
@@ -6308,7 +6341,7 @@ MagickExport char *TranslateTextEx(const ImageInfo *image_info,
 
         /* Extract attribute key string. */
         p++;
-        for (i=0; (i < MaxTextExtent) && (*p) && (*p != ']'); i++)
+        for (i=0; (i < MaxTextExtent-1) && (*p) && (*p != ']'); i++)
           {
           key[i]=(*p++);
           }
index 1845d81..82b6cd9 100644 (file)
@@ -1,12 +1,12 @@
 /*
-  Copyright (C) 2003 - 2016 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   GraphicsMagick Utility Methods.
 */
 #ifndef _MAGICK_UTILITY_H
@@ -78,9 +78,9 @@ extern MagickExport char
   *TranslateTextEx(const ImageInfo *,Image *,const char *,MagickTextTranslate);
 
 extern MagickExport const char
-  *GetClientFilename(void),
-  *GetClientName(void),
-  *GetClientPath(void),
+  *GetClientFilename(void) MAGICK_FUNC_CONST,
+  *GetClientName(void) MAGICK_FUNC_CONST,
+  *GetClientPath(void) MAGICK_FUNC_CONST,
   *SetClientFilename(const char *),
   *SetClientName(const char *),
   *SetClientPath(const char *);
@@ -90,9 +90,9 @@ extern MagickExport double
 
 extern MagickExport int
   GetGeometry(const char *,long *,long *,unsigned long *,unsigned long *),
-  GlobExpression(const char *,const char *),
-  LocaleNCompare(const char *,const char *,const size_t),
-  LocaleCompare(const char *,const char *),
+  GlobExpression(const char *,const char *) MAGICK_FUNC_PURE,
+  LocaleNCompare(const char *,const char *,const size_t) MAGICK_FUNC_PURE,
+  LocaleCompare(const char *,const char *) MAGICK_FUNC_PURE,
   GetMagickDimension(const char *str,double *width,double *height,double *xoff,double *yoff),
   GetMagickGeometry(const char *geometry,long *x,long *y,unsigned long *width,
     unsigned long *height),
@@ -121,14 +121,14 @@ extern MagickExport MagickBool
   IsAccessibleNoLogging(const char *),
   IsAccessibleAndNotEmpty(const char *),
   IsGeometry(const char *),
-  IsGlob(const char *),
+  IsGlob(const char *) MAGICK_FUNC_PURE,
   IsWriteable(const char *),
   MagickSceneFileName(char *filename,const char* filename_template,
     const char* scene_template,const MagickBool force,unsigned long scene),
   SubstituteString(char **buffer,const char *search,const char *replace);
 
 extern MagickExport unsigned long
-  MultilineCensus(const char *);
+  MultilineCensus(const char *) MAGICK_FUNC_PURE;
 
 extern MagickExport void
   AppendImageFormat(const char *,char *),
@@ -145,9 +145,9 @@ extern MagickExport void
 
 extern MagickExport void
   FormatString(char *string,const char *format,...) MAGICK_ATTRIBUTE((__format__ (__printf__,2,3))),
-  FormatStringList(char *string,const char *format,va_list operands),
+  FormatStringList(char *string,const char *format,va_list operands) MAGICK_ATTRIBUTE((__format__ (__printf__,2,0))),
   MagickFormatString(char *string,const size_t length,const char *format,...) MAGICK_ATTRIBUTE((__format__ (__printf__,3,4))),
-  MagickFormatStringList(char *string,const size_t length,const char *format,va_list operands);
+  MagickFormatStringList(char *string,const size_t length,const char *format,va_list operands) MAGICK_ATTRIBUTE((__format__ (__printf__,3,0)));
 
 extern MagickExport magick_int64_t
   MagickSizeStrToInt64(const char *str,const unsigned int kilo);
@@ -184,6 +184,24 @@ extern MagickExport MagickPassFail MagickAtoUIChk(const char *str, unsigned int
 extern MagickExport MagickPassFail MagickAtoLChk(const char *str, long *value);
 extern MagickExport MagickPassFail MagickAtoULChk(const char *str, unsigned long *value);
 
+/*
+  Compute a value which is the next kilobyte power of 2 larger than
+  the requested value or MaxTextExtent, whichever is larger.
+
+  The objective is to round up the size quickly (and in repeatable
+  steps) in order to reduce the number of memory copies due to realloc
+  for strings which grow rapidly, while producing a reasonable size
+  for smaller strings.
+*/
+#define MagickRoundUpStringLength(size) \
+{ \
+  size_t \
+    _rounded; \
+ \
+  for (_rounded=256U; _rounded < (Max(size,256)); _rounded *= 2); \
+  size=_rounded; \
+}
+
 #endif /* defined(MAGICK_IMPLEMENTATION) */
 
 #if defined(__cplusplus) || defined(c_plusplus)
index f5f1155..c181d3e 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2003 - 2016 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
  
@@ -34,12 +34,12 @@ extern "C" {
   identifying the release.
 */
 #define MagickPackageName "GraphicsMagick"
-#define MagickCopyright  "Copyright (C) 2002-2017 GraphicsMagick Group.\nAdditional copyrights and licenses apply to this software.\nSee http://www.GraphicsMagick.org/www/Copyright.html for details."
-#define MagickLibVersion  0x191600
-#define MagickLibVersionText  "1.3.26"
-#define MagickLibVersionNumber 19,16,0
-#define MagickChangeDate   "20170704"
-#define MagickReleaseDate  "2017-07-04"
+#define MagickCopyright  "Copyright (C) 2002-2018 GraphicsMagick Group.\nAdditional copyrights and licenses apply to this software.\nSee http://www.GraphicsMagick.org/www/Copyright.html for details."
+#define MagickLibVersion  0x221900
+#define MagickLibVersionText  "1.3.31"
+#define MagickLibVersionNumber 22,19,0
+#define MagickChangeDate   "20181117"
+#define MagickReleaseDate  "2018-11-17"
        
 /*
   The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines
@@ -54,7 +54,7 @@ extern "C" {
   MagickLibVersionNumber, but these are broken out and simplified so
   that they can be easily used in C pre-processor logic.
 */
-#define MagickLibInterfaceNewest 19
+#define MagickLibInterfaceNewest 22
 #define MagickLibInterfaceOldest 3
 
 #if (QuantumDepth == 8)
@@ -75,9 +75,9 @@ extern "C" {
   Method declarations.
 */
 extern MagickExport const char
-  *GetMagickCopyright(void),
-  *GetMagickVersion(unsigned long *),
-  *GetMagickWebSite(void);
+  *GetMagickCopyright(void) MAGICK_FUNC_CONST,
+  *GetMagickVersion(unsigned long *) MAGICK_FUNC_CONST,
+  *GetMagickWebSite(void) MAGICK_FUNC_CONST;
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
index ad4ce36..2c5dd82 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2003 - 2016 GraphicsMagick Group
+  Copyright (C) 2003 - 2018 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
  
@@ -34,7 +34,7 @@ extern "C" {
   identifying the release.
 */
 #define MagickPackageName "@PACKAGE_NAME@"
-#define MagickCopyright  "Copyright (C) 2002-2017 GraphicsMagick Group.\nAdditional copyrights and licenses apply to this software.\nSee http://www.GraphicsMagick.org/www/Copyright.html for details."
+#define MagickCopyright  "Copyright (C) 2002-2018 GraphicsMagick Group.\nAdditional copyrights and licenses apply to this software.\nSee http://www.GraphicsMagick.org/www/Copyright.html for details."
 #define MagickLibVersion  @MAGICK_LIB_VERSION@
 #define MagickLibVersionText  "@MAGICK_LIB_VERSION_TEXT@"
 #define MagickLibVersionNumber @MAGICK_LIB_VERSION_NUMBER@
@@ -75,9 +75,9 @@ extern "C" {
   Method declarations.
 */
 extern MagickExport const char
-  *GetMagickCopyright(void),
-  *GetMagickVersion(unsigned long *),
-  *GetMagickWebSite(void);
+  *GetMagickCopyright(void) MAGICK_FUNC_CONST,
+  *GetMagickVersion(unsigned long *) MAGICK_FUNC_CONST,
+  *GetMagickWebSite(void) MAGICK_FUNC_CONST;
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
index 10a3049..0167e61 100644 (file)
@@ -1,5 +1,5 @@
 /*
-% Copyright (C) 2003-2015 GraphicsMagick Group
+% Copyright (C) 2003-2017 GraphicsMagick Group
 % Copyright (C) 2002 ImageMagick Studio
 % Copyright 1991-1999 E. I. du Pont de Nemours and Company
 %
@@ -1029,8 +1029,8 @@ static void XEditText(Display *display,MagickXWidgetInfo *text_info,
           (void) memmove(text_info->cursor,text_info->cursor+1,
                          strlen(text_info->cursor+1)+1);
           text_info->highlight=False;
-          break;
         }
+      break;
     }
     case XK_Left:
     case XK_KP_Left:
@@ -2706,80 +2706,80 @@ MagickExport int MagickXCommandWidget(Display *display,MagickXWindows *windows,
 #define tile_width 112
 #define tile_height 64
 static unsigned char tile_bits[] = {
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 
-  0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 
-  0x00, 0x1E, 0xF8, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0xE0, 0xC0, 0x87, 0x3F, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0xE0, 0x8F, 0x73, 0xDC, 0xFC, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0xC0, 0x71, 0x8E, 0x03, 0xDC, 0x7C, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xC0, 0x71, 0x80, 0x1F, 0xEC, 0x76, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xC3, 0x71, 0x00, 0x7F, 
-  0x6E, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0xC7, 0x73, 
-  0x18, 0x70, 0x6E, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 
-  0x8F, 0x73, 0xDC, 0x71, 0xEE, 0x3B, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0xF8, 0x8F, 0xF3, 0x9F, 0x7F, 0xE7, 0x39, 0x3E, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x78, 0x9C, 0xE7, 0x0F, 0x3F, 0xE7, 0x19, 0x7C, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1C, 0x87, 0x03, 0x00, 0xE6, 0x1C, 
-  0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0x38, 0x07, 0x00, 0x00, 
-  0xE0, 0x9C, 0xC7, 0x01, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE3, 0x38, 0x00, 
-  0x00, 0x00, 0x00, 0xCC, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE7, 
-  0x39, 0x00, 0x00, 0x00, 0x00, 0xC8, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0xF8, 0xCF, 0x01, 0x00, 0x00, 0x07, 0x00, 0xC0, 0x71, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x3C, 0xCE, 0x03, 0x00, 0x81, 0x0D, 0x00, 0x80, 0x7F, 0x7C, 
-  0x00, 0x00, 0x00, 0x00, 0x3C, 0x9E, 0x00, 0x80, 0x87, 0x1E, 0x00, 0x00, 
-  0x3F, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x78, 0x1C, 0x00, 0xC0, 0xDC, 0x1F, 
-  0x00, 0x00, 0x38, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x1E, 0x00, 0x40, 
-  0xF0, 0x38, 0x00, 0x00, 0x10, 0xC7, 0x01, 0x00, 0x00, 0x00, 0xF0, 0x0F, 
-  0x00, 0x40, 0x77, 0x30, 0x00, 0x00, 0x80, 0xC3, 0x03, 0x00, 0x00, 0xC0, 
-  0xE1, 0x01, 0x00, 0xC0, 0x2D, 0x30, 0x00, 0x00, 0xA0, 0xE3, 0x03, 0x00, 
-  0x00, 0xE0, 0xC7, 0x03, 0x00, 0xC0, 0x38, 0xF0, 0x00, 0x00, 0x30, 0xF7, 
-  0xC1, 0x00, 0x00, 0xF0, 0x8F, 0x07, 0x00, 0xC0, 0x18, 0xE0, 0x01, 0x00, 
-  0x70, 0xFE, 0xC0, 0x00, 0x00, 0x38, 0x3F, 0x0F, 0x00, 0x40, 0x10, 0x60, 
-  0x03, 0x00, 0x70, 0x7C, 0xD8, 0x01, 0x00, 0x98, 0x3D, 0x06, 0x00, 0x40, 
-  0x10, 0x74, 0x06, 0x00, 0xE0, 0x3E, 0x1E, 0x00, 0x00, 0xB8, 0x39, 0x02, 
-  0x00, 0xC0, 0x0C, 0x36, 0x04, 0x00, 0xC0, 0x0F, 0x3F, 0x00, 0x00, 0x98, 
-  0x08, 0x00, 0x00, 0xC0, 0x0C, 0x36, 0x0C, 0x00, 0x80, 0xC7, 0x0F, 0x00, 
-  0x00, 0xC0, 0x0D, 0x00, 0x00, 0xE0, 0x08, 0x1E, 0x08, 0x00, 0x00, 0xE0, 
-  0x03, 0x00, 0x00, 0xC2, 0x0F, 0x00, 0x00, 0xA0, 0x0C, 0x0C, 0x18, 0x00, 
-  0x00, 0xE0, 0x01, 0x00, 0x00, 0x87, 0x07, 0x00, 0x00, 0xD0, 0x1B, 0x04, 
-  0x30, 0x00, 0x00, 0x60, 0x78, 0x00, 0x00, 0x07, 0x03, 0x00, 0x00, 0x78, 
-  0x10, 0x06, 0x60, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x03, 0x00, 0x00, 
-  0x00, 0x38, 0xF0, 0x0F, 0x60, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x80, 0x07, 
-  0x00, 0x00, 0x00, 0x0C, 0x00, 0xFC, 0xF1, 0x00, 0x00, 0x00, 0x8F, 0x01, 
-  0x80, 0x1F, 0x00, 0x00, 0x00, 0x06, 0x00, 0xC0, 0xE3, 0x00, 0x00, 0x00, 
-  0x87, 0x03, 0x80, 0xFF, 0x00, 0x00, 0x00, 0x03, 0x70, 0x60, 0xA3, 0x03, 
-  0x00, 0x00, 0x83, 0x03, 0x00, 0xFC, 0x00, 0x00, 0x80, 0x01, 0x70, 0x30, 
-  0x00, 0x07, 0x00, 0x00, 0x87, 0x03, 0x00, 0xE0, 0x00, 0x00, 0xC0, 0x0E, 
-  0x70, 0x18, 0x00, 0x06, 0x00, 0x00, 0x9F, 0x01, 0x10, 0x00, 0x00, 0x00, 
-  0x60, 0x0F, 0x00, 0x0C, 0x00, 0x06, 0x00, 0x00, 0x1E, 0x00, 0x9C, 0x1F, 
-  0x00, 0x00, 0x20, 0x06, 0x00, 0x06, 0x60, 0x06, 0x00, 0x00, 0x1C, 0x00, 
-  0x9E, 0x1F, 0x00, 0x00, 0x20, 0x00, 0x38, 0x33, 0x60, 0x0C, 0x00, 0x00, 
-  0x00, 0x78, 0x9E, 0x3F, 0x00, 0x00, 0x60, 0x00, 0xB8, 0x71, 0x62, 0x08, 
-  0x02, 0x00, 0xF0, 0x7F, 0x8E, 0x39, 0x00, 0x00, 0xC0, 0x00, 0xE0, 0x30, 
-  0x0E, 0xFB, 0x0F, 0x00, 0xFC, 0x7F, 0xC6, 0x39, 0x00, 0x00, 0x80, 0x03, 
-  0x7C, 0x00, 0x1C, 0xFF, 0x18, 0x00, 0xFC, 0x07, 0x06, 0x38, 0x00, 0x00, 
-  0x00, 0xFF, 0x1F, 0x00, 0x72, 0x0E, 0x10, 0x00, 0xE8, 0x01, 0x0E, 0x38, 
-  0x00, 0x00, 0xC0, 0xFC, 0x01, 0x00, 0xC7, 0x00, 0x18, 0x00, 0xC0, 0x07, 
-  0x3E, 0x3C, 0x00, 0x00, 0xC0, 0x3E, 0x06, 0x03, 0xDC, 0x00, 0x18, 0x00, 
-  0xE0, 0x0F, 0xFE, 0x1F, 0x00, 0x00, 0x80, 0x63, 0x07, 0x87, 0x78, 0x00, 
-  0x0C, 0x00, 0xF8, 0x1D, 0xFC, 0x0F, 0x00, 0x00, 0x80, 0xC3, 0x07, 0xC7, 
-  0x69, 0x30, 0x06, 0x00, 0x78, 0x18, 0xF0, 0x07, 0x00, 0x00, 0x00, 0x02, 
-  0x07, 0x80, 0x3D, 0x3C, 0x03, 0x00, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x06, 0x1C, 0x00, 0x94, 0x97, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0xF8, 0x0F, 0xF0, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x1E, 0x38, 0xF0, 0xFF, 0x0F, 0xD8, 0x3F, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0xE0, 0xF8, 0x10, 0x0E, 0x6C, 
-  0xFE, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0xF8, 0xFC, 0xBF, 
-  0x3D, 0x06, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x0E, 
-  0x60, 0xFC, 0xFC, 0x1D, 0x7B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0xFC, 0x01, 0x00, 0x3C, 0xFF, 0x79, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0xC0, 0x00, 0x00, 0xFC, 0x67, 0x80, 0x1D, 0x00, 0x00, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x1A, 0x00, 
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9E, 0x00, 
-  0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-  0x1C, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+  0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00,
+  0x00, 0x1E, 0xF8, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0xE0, 0xC0, 0x87, 0x3F, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0xE0, 0x8F, 0x73, 0xDC, 0xFC, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0xC0, 0x71, 0x8E, 0x03, 0xDC, 0x7C, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xC0, 0x71, 0x80, 0x1F, 0xEC, 0x76,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xC3, 0x71, 0x00, 0x7F,
+  0x6E, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0xC7, 0x73,
+  0x18, 0x70, 0x6E, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,
+  0x8F, 0x73, 0xDC, 0x71, 0xEE, 0x3B, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0xF8, 0x8F, 0xF3, 0x9F, 0x7F, 0xE7, 0x39, 0x3E, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x78, 0x9C, 0xE7, 0x0F, 0x3F, 0xE7, 0x19, 0x7C, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x1C, 0x87, 0x03, 0x00, 0xE6, 0x1C,
+  0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0x38, 0x07, 0x00, 0x00,
+  0xE0, 0x9C, 0xC7, 0x01, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE3, 0x38, 0x00,
+  0x00, 0x00, 0x00, 0xCC, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE7,
+  0x39, 0x00, 0x00, 0x00, 0x00, 0xC8, 0xF1, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0xF8, 0xCF, 0x01, 0x00, 0x00, 0x07, 0x00, 0xC0, 0x71, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x3C, 0xCE, 0x03, 0x00, 0x81, 0x0D, 0x00, 0x80, 0x7F, 0x7C,
+  0x00, 0x00, 0x00, 0x00, 0x3C, 0x9E, 0x00, 0x80, 0x87, 0x1E, 0x00, 0x00,
+  0x3F, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x78, 0x1C, 0x00, 0xC0, 0xDC, 0x1F,
+  0x00, 0x00, 0x38, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x1E, 0x00, 0x40,
+  0xF0, 0x38, 0x00, 0x00, 0x10, 0xC7, 0x01, 0x00, 0x00, 0x00, 0xF0, 0x0F,
+  0x00, 0x40, 0x77, 0x30, 0x00, 0x00, 0x80, 0xC3, 0x03, 0x00, 0x00, 0xC0,
+  0xE1, 0x01, 0x00, 0xC0, 0x2D, 0x30, 0x00, 0x00, 0xA0, 0xE3, 0x03, 0x00,
+  0x00, 0xE0, 0xC7, 0x03, 0x00, 0xC0, 0x38, 0xF0, 0x00, 0x00, 0x30, 0xF7,
+  0xC1, 0x00, 0x00, 0xF0, 0x8F, 0x07, 0x00, 0xC0, 0x18, 0xE0, 0x01, 0x00,
+  0x70, 0xFE, 0xC0, 0x00, 0x00, 0x38, 0x3F, 0x0F, 0x00, 0x40, 0x10, 0x60,
+  0x03, 0x00, 0x70, 0x7C, 0xD8, 0x01, 0x00, 0x98, 0x3D, 0x06, 0x00, 0x40,
+  0x10, 0x74, 0x06, 0x00, 0xE0, 0x3E, 0x1E, 0x00, 0x00, 0xB8, 0x39, 0x02,
+  0x00, 0xC0, 0x0C, 0x36, 0x04, 0x00, 0xC0, 0x0F, 0x3F, 0x00, 0x00, 0x98,
+  0x08, 0x00, 0x00, 0xC0, 0x0C, 0x36, 0x0C, 0x00, 0x80, 0xC7, 0x0F, 0x00,
+  0x00, 0xC0, 0x0D, 0x00, 0x00, 0xE0, 0x08, 0x1E, 0x08, 0x00, 0x00, 0xE0,
+  0x03, 0x00, 0x00, 0xC2, 0x0F, 0x00, 0x00, 0xA0, 0x0C, 0x0C, 0x18, 0x00,
+  0x00, 0xE0, 0x01, 0x00, 0x00, 0x87, 0x07, 0x00, 0x00, 0xD0, 0x1B, 0x04,
+  0x30, 0x00, 0x00, 0x60, 0x78, 0x00, 0x00, 0x07, 0x03, 0x00, 0x00, 0x78,
+  0x10, 0x06, 0x60, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x03, 0x00, 0x00,
+  0x00, 0x38, 0xF0, 0x0F, 0x60, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x80, 0x07,
+  0x00, 0x00, 0x00, 0x0C, 0x00, 0xFC, 0xF1, 0x00, 0x00, 0x00, 0x8F, 0x01,
+  0x80, 0x1F, 0x00, 0x00, 0x00, 0x06, 0x00, 0xC0, 0xE3, 0x00, 0x00, 0x00,
+  0x87, 0x03, 0x80, 0xFF, 0x00, 0x00, 0x00, 0x03, 0x70, 0x60, 0xA3, 0x03,
+  0x00, 0x00, 0x83, 0x03, 0x00, 0xFC, 0x00, 0x00, 0x80, 0x01, 0x70, 0x30,
+  0x00, 0x07, 0x00, 0x00, 0x87, 0x03, 0x00, 0xE0, 0x00, 0x00, 0xC0, 0x0E,
+  0x70, 0x18, 0x00, 0x06, 0x00, 0x00, 0x9F, 0x01, 0x10, 0x00, 0x00, 0x00,
+  0x60, 0x0F, 0x00, 0x0C, 0x00, 0x06, 0x00, 0x00, 0x1E, 0x00, 0x9C, 0x1F,
+  0x00, 0x00, 0x20, 0x06, 0x00, 0x06, 0x60, 0x06, 0x00, 0x00, 0x1C, 0x00,
+  0x9E, 0x1F, 0x00, 0x00, 0x20, 0x00, 0x38, 0x33, 0x60, 0x0C, 0x00, 0x00,
+  0x00, 0x78, 0x9E, 0x3F, 0x00, 0x00, 0x60, 0x00, 0xB8, 0x71, 0x62, 0x08,
+  0x02, 0x00, 0xF0, 0x7F, 0x8E, 0x39, 0x00, 0x00, 0xC0, 0x00, 0xE0, 0x30,
+  0x0E, 0xFB, 0x0F, 0x00, 0xFC, 0x7F, 0xC6, 0x39, 0x00, 0x00, 0x80, 0x03,
+  0x7C, 0x00, 0x1C, 0xFF, 0x18, 0x00, 0xFC, 0x07, 0x06, 0x38, 0x00, 0x00,
+  0x00, 0xFF, 0x1F, 0x00, 0x72, 0x0E, 0x10, 0x00, 0xE8, 0x01, 0x0E, 0x38,
+  0x00, 0x00, 0xC0, 0xFC, 0x01, 0x00, 0xC7, 0x00, 0x18, 0x00, 0xC0, 0x07,
+  0x3E, 0x3C, 0x00, 0x00, 0xC0, 0x3E, 0x06, 0x03, 0xDC, 0x00, 0x18, 0x00,
+  0xE0, 0x0F, 0xFE, 0x1F, 0x00, 0x00, 0x80, 0x63, 0x07, 0x87, 0x78, 0x00,
+  0x0C, 0x00, 0xF8, 0x1D, 0xFC, 0x0F, 0x00, 0x00, 0x80, 0xC3, 0x07, 0xC7,
+  0x69, 0x30, 0x06, 0x00, 0x78, 0x18, 0xF0, 0x07, 0x00, 0x00, 0x00, 0x02,
+  0x07, 0x80, 0x3D, 0x3C, 0x03, 0x00, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x06, 0x1C, 0x00, 0x94, 0x97, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0xF8, 0x0F, 0xF0, 0xFF, 0xFF, 0xD0, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x1E, 0x38, 0xF0, 0xFF, 0x0F, 0xD8, 0x3F, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0xE0, 0xF8, 0x10, 0x0E, 0x6C,
+  0xFE, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0xF8, 0xFC, 0xBF,
+  0x3D, 0x06, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x0E,
+  0x60, 0xFC, 0xFC, 0x1D, 0x7B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0xFC, 0x01, 0x00, 0x3C, 0xFF, 0x79, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0xC0, 0x00, 0x00, 0xFC, 0x67, 0x80, 0x1D, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x1A, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9E, 0x00,
+  0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x1C, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, };
 
   int
@@ -4829,10 +4829,15 @@ MagickExport void MagickXFileBrowserWidget(Display *display,MagickXWindows *wind
                 GetExceptionInfo(&exception);
                 magick_info=GetMagickInfo("*",&exception);
                 DestroyExceptionInfo(&exception);
+                if (magick_info == (const MagickInfo *) NULL)
+                  break;
                 i=0;
                 for (p=magick_info; p != (MagickInfo *) NULL; p=p->next)
                   i++;
-                formats=MagickAllocateMemory(char **,(i+1)*sizeof(char *));
+                formats=MagickAllocateArray(char **,(i+1),sizeof(char *));
+                if (formats == (char **) NULL)
+                  break;
+                (void) memset(formats,0,(i+1)*sizeof(char *));
                 i=0;
                 for (p=magick_info; p != (MagickInfo *) NULL; p=p->next)
                 {
@@ -4840,8 +4845,10 @@ MagickExport void MagickXFileBrowserWidget(Display *display,MagickXWindows *wind
                     continue;
                   if (!p->encoder)
                     continue;
+                   /* AllocateString does a fatal exit on failed alloc */
                   formats[i]=AllocateString(p->name);
-                  LocaleLower((char *) formats[i]);
+                  if (formats[i] != NULL)
+                    LocaleLower((char *) formats[i]);
                   i++;
                 }
                 formats[i]=(char *) NULL;
@@ -5309,6 +5316,8 @@ MagickExport void MagickXFileBrowserWidget(Display *display,MagickXWindows *wind
 extern "C" {
 #endif
 
+static int FontCompare(const void *x,const void *y) MAGICK_FUNC_PURE;
+
 static int FontCompare(const void *x,const void *y)
 {
   register char
index 6b40cbb..c2f2a3d 100644 (file)
@@ -2,11 +2,11 @@
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
   Copyright 1991-1999 E. I. du Pont de Nemours and Company
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   X11 User Interface Methods for ImageMagick.
 */
 #ifndef _MAGICK_WIDGET_H
index bfcb2c9..0d02b7f 100644 (file)
@@ -160,14 +160,14 @@ MagickShmAt(int shmid, void *shmaddr, int shmflg)
 /*
   Shared memory control operations.
 */
-static int 
+static int
 MagickShmCtl(int shmid, int cmd, struct shmid_ds *buf)
 {
   int status;
   if ((status=shmctl(shmid, cmd, buf)) == -1)
     {
       (void) LogMagickEvent(X11Event,GetMagickModule(),"shm control id=%d cmd=%s failed (%s)",
-                            shmid, ((cmd == IPC_STAT) ? "IPC_STAT" : 
+                            shmid, ((cmd == IPC_STAT) ? "IPC_STAT" :
                                     (cmd == IPC_SET) ? "IPC_SET" :
                                     (cmd == IPC_RMID) ? "IPC_RMID" : "Unknown"),
                             strerror(errno));
@@ -175,7 +175,7 @@ MagickShmCtl(int shmid, int cmd, struct shmid_ds *buf)
   else
     {
       (void) LogMagickEvent(X11Event,GetMagickModule(),"shm control id=%d cmd=%s",
-                            shmid, ((cmd == IPC_STAT) ? "IPC_STAT" : 
+                            shmid, ((cmd == IPC_STAT) ? "IPC_STAT" :
                                     (cmd == IPC_SET) ? "IPC_SET" :
                                     (cmd == IPC_RMID) ? "IPC_RMID" : "Unknown"));
     }
@@ -184,7 +184,7 @@ MagickShmCtl(int shmid, int cmd, struct shmid_ds *buf)
 /*
   Detatch from shared memory.
 */
-static int 
+static int
 MagickShmDt(void *shmaddr)
 {
   int result;
@@ -228,14 +228,14 @@ MagickShmDt(void *shmaddr)
 %
 %
 */
-MagickExport void 
+MagickExport void
 MagickXDestroyX11Resources(void)
 {
   MagickXWindows *windows = MagickXSetWindows((MagickXWindows *) ~0);
   if (windows != (MagickXWindows *) NULL)
     {
       MagickXDestroyXWindows(windows);
-      (void) MagickXSetWindows((MagickXWindows *) NULL);  
+      (void) MagickXSetWindows((MagickXWindows *) NULL);
     }
 }
 \f
@@ -261,7 +261,7 @@ MagickXDestroyX11Resources(void)
 %
 %
 */
-MagickExport void 
+MagickExport void
 MagickXDestroyXWindows(MagickXWindows *windows)
 {
   if (windows == (MagickXWindows *) NULL ||
@@ -375,7 +375,7 @@ MagickXDestroyXWindows(MagickXWindows *windows)
 %
 %    o window: Pointer to MagickXWindowInfo structure to destroy.
 */
-MagickExport void 
+MagickExport void
 MagickXDestroyXWindowInfo(Display *display,MagickXWindowInfo *window)
 {
   if (window->mapped != False)
@@ -447,7 +447,7 @@ MagickXDestroyXWindowInfo(Display *display,MagickXWindowInfo *window)
 #if defined(HasSharedMemory)
       XShmSegmentInfo
         *segment_info;
-          
+
       segment_info=(XShmSegmentInfo *) window->segment_info;
       if (segment_info != (XShmSegmentInfo *) NULL)
         {
@@ -492,7 +492,7 @@ MagickXDestroyXWindowInfo(Display *display,MagickXWindowInfo *window)
 %
 %
 */
-MagickExport unsigned int 
+MagickExport unsigned int
 MagickIsTrue(const char *reason)
 {
   if (reason == (char *) NULL)
@@ -545,11 +545,11 @@ MagickIsTrue(const char *reason)
 %
 %
 */
-MagickExport unsigned int 
+MagickExport unsigned int
 MagickXAnnotateImage(Display *display,
-                    const MagickXPixelInfo *pixel,
-                    MagickXAnnotateInfo *annotate_info,
-                    Image *image)
+                     const MagickXPixelInfo *pixel,
+                     MagickXAnnotateInfo *annotate_info,
+                     Image *image)
 {
   GC
     annotate_context;
@@ -640,7 +640,7 @@ MagickXAnnotateImage(Display *display,
   y=0;
   (void) XParseGeometry(annotate_info->geometry,&x,&y,&width,&height);
   (void) AcquireOnePixelByReference(image,&annotate_image->background_color,
-                                   x,y,&image->exception);
+                                    x,y,&image->exception);
   annotate_image->matte=annotate_info->stencil == ForegroundStencil;
   for (y=0; y < (long) annotate_image->rows; y++)
   {
@@ -857,8 +857,8 @@ MagickFontToList(char *font)
 
 MagickExport XFontStruct *
 MagickXBestFont(Display *display,
-               const MagickXResourceInfo *resource_info,
-               const unsigned int text_font)
+                const MagickXResourceInfo *resource_info,
+                const unsigned int text_font)
 {
   static const char
     *Fonts[]=
@@ -1098,9 +1098,9 @@ MagickXBestIconSize(Display *display,MagickXWindowInfo *window,
 %
 %
 */
-MagickExport void 
+MagickExport void
 MagickXBestPixel(Display *display,const Colormap colormap,
-                XColor *colors,unsigned int number_colors,XColor *color)
+                 XColor *colors,unsigned int number_colors,XColor *color)
 {
   double
     min_distance;
@@ -1226,8 +1226,8 @@ MagickXBestPixel(Display *display,const Colormap colormap,
 
 MagickExport XVisualInfo *
 MagickXBestVisualInfo(Display *display,
-                     XStandardColormap *map_info,
-                     MagickXResourceInfo *resource_info)
+                      XStandardColormap *map_info,
+                      MagickXResourceInfo *resource_info)
 {
   char
     *map_type,
@@ -1517,7 +1517,7 @@ MagickXBestVisualInfo(Display *display,
 %
 %
 */
-MagickExport void 
+MagickExport void
 MagickXCheckRefreshWindows(Display *display,MagickXWindows *windows)
 {
   XEvent
@@ -1570,7 +1570,7 @@ MagickXCheckRefreshWindows(Display *display,MagickXWindows *windows)
 %
 %
 */
-MagickExport void 
+MagickExport void
 MagickXClientMessage(Display *display,const Window window,
   const Atom protocol,const Atom reason,const Time timestamp)
 {
@@ -1578,6 +1578,7 @@ MagickXClientMessage(Display *display,const Window window,
     client_event;
 
   assert(display != (Display *) NULL);
+  (void) memset(&client_event,0,sizeof(client_event));
   client_event.type=ClientMessage;
   client_event.window=window;
   client_event.message_type=protocol;
@@ -1690,8 +1691,8 @@ MagickXClientWindow(Display *display,Window target_window)
 */
 MagickExport void
 MagickXConfigureImageColormap(Display *display,
-                             MagickXResourceInfo *resource_info,
-                             MagickXWindows *windows,Image *image)
+                              MagickXResourceInfo *resource_info,
+                              MagickXWindows *windows,Image *image)
 {
   Colormap
     colormap;
@@ -1746,7 +1747,7 @@ MagickXConfigureImageColormap(Display *display,
 */
 MagickExport void
 MagickXConstrainWindowPosition(Display *display,
-                              MagickXWindowInfo *window_info)
+                               MagickXWindowInfo *window_info)
 {
   unsigned int
     limit;
@@ -1970,9 +1971,9 @@ MagickXDestroyWindowColors(Display *display,Window window)
 */
 MagickExport void
 MagickXDisplayImageInfo(Display *display,
-                       const MagickXResourceInfo *resource_info,
-                       MagickXWindows *windows,Image *undo_image,
-                       Image *image)
+                        const MagickXResourceInfo *resource_info,
+                        MagickXWindows *windows,Image *undo_image,
+                        Image *image)
 {
   char
     filename[MaxTextExtent],
@@ -2184,7 +2185,7 @@ static void MagickXDitherImage(Image *image,XImage *ximage)
     {
       red_map[i][j]=MagickAllocateArray(unsigned char *,256,sizeof(unsigned char));
       green_map[i][j]=MagickAllocateArray(unsigned char *,
-                                         256,sizeof(unsigned char));
+                                          256,sizeof(unsigned char));
       blue_map[i][j]=MagickAllocateArray(unsigned char *,256,sizeof(unsigned char));
       if ((red_map[i][j] == (unsigned char *) NULL) ||
           (green_map[i][j] == (unsigned char *) NULL) ||
@@ -2302,7 +2303,7 @@ static void MagickXDitherImage(Image *image,XImage *ximage)
 */
 MagickExport unsigned int
 MagickXDrawImage(Display *display,const MagickXPixelInfo *pixel,
-                MagickXDrawInfo *draw_info,Image *image)
+                 MagickXDrawInfo *draw_info,Image *image)
 {
   GC
     draw_context;
@@ -2726,12 +2727,12 @@ MagickXError(Display *display,XErrorEvent *error)
 */
 MagickExport void
 MagickXFreeResources(Display *display,
-                    XVisualInfo *visual_info,
-                    XStandardColormap *map_info,
-                    MagickXPixelInfo *pixel,
-                    XFontStruct *font_info,
-                    MagickXResourceInfo *resource_info,
-                    MagickXWindowInfo *window_info)
+                     XVisualInfo *visual_info,
+                     XStandardColormap *map_info,
+                     MagickXPixelInfo *pixel,
+                     XFontStruct *font_info,
+                     MagickXResourceInfo *resource_info,
+                     MagickXWindowInfo *window_info)
 {
   assert(display != (Display *) NULL);
   assert(resource_info != (MagickXResourceInfo *) NULL);
@@ -2821,9 +2822,9 @@ MagickXFreeResources(Display *display,
 */
 MagickExport void
 MagickXFreeStandardColormap(Display *display,
-                           const XVisualInfo *visual_info,
-                           XStandardColormap *map_info,
-                           MagickXPixelInfo *pixel)
+                            const XVisualInfo *visual_info,
+                            XStandardColormap *map_info,
+                            MagickXPixelInfo *pixel)
 {
   /*
     Free colormap.
@@ -2928,7 +2929,7 @@ MagickXGetAnnotateInfo(MagickXAnnotateInfo *annotate_info)
 */
 MagickExport void
 MagickXGetMapInfo(const XVisualInfo *visual_info,
-                 const Colormap colormap,XStandardColormap *map_info)
+                  const Colormap colormap,XStandardColormap *map_info)
 {
   /*
     Initialize map info.
@@ -3039,11 +3040,11 @@ MagickXGetImportInfo(MagickXImportInfo *ximage_info)
 */
 MagickExport void
 MagickXGetPixelPacket(Display *display,
-                     const XVisualInfo *visual_info,
-                     const XStandardColormap *map_info,
-                     const MagickXResourceInfo *resource_info,
-                     Image *image,
-                     MagickXPixelInfo *pixel)
+                      const XVisualInfo *visual_info,
+                      const XStandardColormap *map_info,
+                      const MagickXResourceInfo *resource_info,
+                      Image *image,
+                      MagickXPixelInfo *pixel)
 {
   static const char
     *PenColors[MaxNumberPens]=
@@ -3292,8 +3293,8 @@ MagickXGetPixelPacket(Display *display,
 */
 MagickExport char *
 MagickXGetResourceClass(XrmDatabase database,
-                       const char *client_name,const char *keyword,
-                       char *resource_default)
+                        const char *client_name,const char *keyword,
+                        char *resource_default)
 {
   char
     resource_class[MaxTextExtent],
@@ -3384,7 +3385,7 @@ MagickXGetResourceClass(XrmDatabase database,
 */
 MagickExport XrmDatabase
 MagickXGetResourceDatabase(Display *display,
-                          const char *client_name)
+                           const char *client_name)
 {
   char
     filename[MaxTextExtent];
@@ -3487,7 +3488,7 @@ MagickXGetResourceDatabase(Display *display,
 */
 MagickExport void
 MagickXGetResourceInfo(XrmDatabase database,const char *client_name,
-                      MagickXResourceInfo *resource_info)
+                       MagickXResourceInfo *resource_info)
 {
   char
     *resource_value;
@@ -3717,9 +3718,9 @@ MagickXGetResourceInfo(XrmDatabase database,const char *client_name,
 */
 MagickExport char *
 MagickXGetResourceInstance(XrmDatabase database,
-                          const char *client_name,
-                          const char *keyword,
-                          const char *resource_default)
+                           const char *client_name,
+                           const char *keyword,
+                           const char *resource_default)
 {
   char
     *resource_type,
@@ -4029,7 +4030,7 @@ MagickXGetWindowColor(Display *display,MagickXWindows *windows,char *name)
 */
 static Image *
 MagickXGetWindowImage(Display *display,const Window window,
-                     const unsigned int borders,const unsigned int level)
+                      const unsigned int borders,const unsigned int level)
 {
   typedef struct _ColormapInfo
   {
@@ -4156,7 +4157,7 @@ MagickXGetWindowImage(Display *display,const Window window,
       max_windows+=1024;
       if (window_info == (WindowInfo *) NULL)
         window_info=MagickAllocateArray(WindowInfo *,
-                                       max_windows,sizeof(WindowInfo));
+                                        max_windows,sizeof(WindowInfo));
       else
         MagickReallocMemory(WindowInfo *,window_info,max_windows*sizeof(WindowInfo));
     }
@@ -4618,12 +4619,12 @@ MagickXGetWindowImage(Display *display,const Window window,
 */
 MagickExport void
 MagickXGetWindowInfo(Display *display,
-                    XVisualInfo *visual_info,
-                    XStandardColormap *map_info,
-                    MagickXPixelInfo *pixel,
-                    XFontStruct *font_info,
-                    MagickXResourceInfo *resource_info,
-                    MagickXWindowInfo *window)
+                     XVisualInfo *visual_info,
+                     XStandardColormap *map_info,
+                     MagickXPixelInfo *pixel,
+                     XFontStruct *font_info,
+                     MagickXResourceInfo *resource_info,
+                     MagickXWindowInfo *window)
 {
   /*
     Initialize window info.
@@ -4763,8 +4764,8 @@ MagickXGetWindowInfo(Display *display,
 */
 MagickExport void
 MagickXHighlightEllipse(Display *display,Window window,
-                       GC annotate_context,
-                       const RectangleInfo *highlight_info)
+                        GC annotate_context,
+                        const RectangleInfo *highlight_info)
 {
   assert(display != (Display *) NULL);
   assert(window != (Window) NULL);
@@ -4813,9 +4814,9 @@ MagickXHighlightEllipse(Display *display,Window window,
 %
 %
 */
-MagickExport void 
+MagickExport void
 MagickXHighlightLine(Display *display,Window window,
-                    GC annotate_context,const XSegment *highlight_info)
+                     GC annotate_context,const XSegment *highlight_info)
 {
   assert(display != (Display *) NULL);
   assert(window != (Window) NULL);
@@ -4860,8 +4861,8 @@ MagickXHighlightLine(Display *display,Window window,
 */
 MagickExport void
 MagickXHighlightRectangle(Display *display,Window window,
-                         GC annotate_context,
-                         const RectangleInfo *highlight_info)
+                          GC annotate_context,
+                          const RectangleInfo *highlight_info)
 {
   assert(display != (Display *) NULL);
   assert(window != (Window) NULL);
@@ -4905,7 +4906,7 @@ MagickXHighlightRectangle(Display *display,Window window,
 */
 MagickExport Image *
 MagickXImportImage(const ImageInfo *image_info,
-                  MagickXImportInfo *ximage_info)
+                   MagickXImportInfo *ximage_info)
 {
   Colormap
     *colormaps;
@@ -5173,7 +5174,7 @@ MagickXImportImage(const ImageInfo *image_info,
 */
 MagickExport MagickXWindows *
 MagickXInitializeWindows(Display *display,
-                        MagickXResourceInfo *resource_info)
+                         MagickXResourceInfo *resource_info)
 {
   Window
     root_window;
@@ -5373,8 +5374,8 @@ MagickXInitializeWindows(Display *display,
 */
 MagickExport Cursor
 MagickXMakeCursor(Display *display,Window window,
-                 Colormap colormap,char *background_color,
-                 char *foreground_color)
+                  Colormap colormap,char *background_color,
+                  char *foreground_color)
 {
 #define scope_height 17
 #define scope_x_hot 8
@@ -5481,13 +5482,13 @@ static const char *
 MagickXImageFormatToString(int xformat)
 {
   static const char
-    *formats[] = 
+    *formats[] =
     {
       "XYBitmap",
       "XYPixmap",
       "ZPixmap"
     };
-  
+
   const char
     *format = "Unknown";
 
@@ -5505,7 +5506,7 @@ MagickXByteOrderToString(int xbyte_order)
       "LSBFirst",
       "MSBFirst"
     };
-  
+
   const char
     *byte_order = "Unknown";
 
@@ -5516,10 +5517,10 @@ MagickXByteOrderToString(int xbyte_order)
 }
 MagickExport unsigned int
 MagickXMakeImage(Display *display,
-                const MagickXResourceInfo *resource_info,
-                MagickXWindowInfo *window,
-                Image *image,
-                unsigned int width,unsigned int height)
+                 const MagickXResourceInfo *resource_info,
+                 MagickXWindowInfo *window,
+                 Image *image,
+                 unsigned int width,unsigned int height)
 {
   int
     depth,
@@ -5552,7 +5553,7 @@ MagickXMakeImage(Display *display,
   if (window->image != (Image *) NULL)
     {
       MonitorHandler
-       handler=(MonitorHandler) NULL;
+        handler=(MonitorHandler) NULL;
 
       handler=SetMonitorHandler((MonitorHandler) NULL);
       if (window->crop_geometry)
@@ -5617,8 +5618,8 @@ MagickXMakeImage(Display *display,
             }
         }
       if ((window->image->matte != MagickFalse) &&
-         (window->pixel_info->colors == 0)
-         /* && (window->immutable == MagickFalse) */)
+          (window->pixel_info->colors == 0)
+          /* && (window->immutable == MagickFalse) */)
         {
           Image
             *texture;
@@ -5627,7 +5628,7 @@ MagickXMakeImage(Display *display,
             Tile background with texture according to opacity
           */
           strlcpy(resource_info->image_info->filename,"image:checkerboard",
-                 sizeof(resource_info->image_info->filename));
+                  sizeof(resource_info->image_info->filename));
           texture=ReadImage(resource_info->image_info,&window->image->exception);
           if (texture != (Image *) NULL)
             {
@@ -5635,20 +5636,20 @@ MagickXMakeImage(Display *display,
                 *textured_image;
 
               textured_image=CloneImage(window->image,0,0,MagickTrue,
-                                       &window->image->exception);
+                                        &window->image->exception);
               if (textured_image != (Image *) NULL)
                 {
                   if (TextureImage(textured_image,texture) != MagickFail)
-                   {
-                     if (window->image != image)
-                       DestroyImage(window->image);
-                     window->image=textured_image;
-                     window->destroy=MagickTrue;
-                   }
-                 else
-                   {
-                     DestroyImage(textured_image);
-                   }
+                    {
+                      if (window->image != image)
+                        DestroyImage(window->image);
+                      window->image=textured_image;
+                      window->destroy=MagickTrue;
+                    }
+                  else
+                    {
+                      DestroyImage(textured_image);
+                    }
                 }
               DestroyImage(texture);
               texture=(Image *) NULL;
@@ -5673,13 +5674,14 @@ MagickXMakeImage(Display *display,
         *segment_info;
 
       size_t
-       shm_extent;
+        shm_extent;
 
       segment_info=(XShmSegmentInfo *) window->segment_info;
       segment_info[1].shmid=(-1);
       segment_info[1].shmaddr=NULL;
+      shm_extent=0;
       ximage=XShmCreateImage(display,window->visual,depth,format,(char *) NULL,
-                            &segment_info[1],width,height);
+                             &segment_info[1],width,height);
       window->shared_memory &= (ximage != (XImage *) NULL);
 
       if (window->shared_memory)
@@ -5779,9 +5781,9 @@ MagickXMakeImage(Display *display,
       (void) LogMagickEvent(X11Event,GetMagickModule(),"  width x height: %dx%d",
         ximage->width,ximage->height);
       (void) LogMagickEvent(X11Event,GetMagickModule(),"  format: %s",
-                           MagickXImageFormatToString(ximage->format));
+                            MagickXImageFormatToString(ximage->format));
       (void) LogMagickEvent(X11Event,GetMagickModule(),"  byte order: %s",
-                           MagickXByteOrderToString(ximage->byte_order));
+                            MagickXByteOrderToString(ximage->byte_order));
       (void) LogMagickEvent(X11Event,GetMagickModule(),
         "  bitmap unit, bit order, pad: %d %d %d",ximage->bitmap_unit,
         ximage->bitmap_bit_order,ximage->bitmap_pad);
@@ -5798,13 +5800,25 @@ MagickXMakeImage(Display *display,
   if (!window->shared_memory)
     {
       if (ximage->format == XYBitmap)
-        ximage->data=
-         MagickAllocateArray(char *,
-                             MagickArraySize(ximage->height,ximage->bytes_per_line),
-                             ximage->depth);
+        {
+          ximage->data=
+            MagickAllocateArray(char *,
+                                MagickArraySize(ximage->height,
+                                                ximage->bytes_per_line),
+                                ximage->depth);
+          if (ximage->data != (char *) NULL)
+            (void) memset(ximage->data,0,
+                          (size_t) ximage->height*ximage->bytes_per_line*
+                          ximage->depth);
+        }
       else
-        ximage->data=
-         MagickAllocateArray(char *,ximage->height,ximage->bytes_per_line);
+        {
+          ximage->data=
+            MagickAllocateArray(char *,ximage->height,ximage->bytes_per_line);
+          if (ximage->data != (char *) NULL)
+            (void) memset(ximage->data,0,
+                          (size_t) ximage->height*ximage->bytes_per_line);
+        }
     }
   if (ximage->data == (char *) NULL)
     {
@@ -5852,7 +5866,7 @@ MagickXMakeImage(Display *display,
     {
       XShmSegmentInfo
         *segment_info;
-      
+
       segment_info=(XShmSegmentInfo *) window->segment_info;
       segment_info[0]=segment_info[1];
     }
@@ -5881,8 +5895,8 @@ MagickXMakeImage(Display *display,
               Allocate matte image pixel data.
             */
             length=MagickArraySize(MagickArraySize(matte_image->bytes_per_line,
-                                                  matte_image->height),
-                                  matte_image->depth);
+                                                   matte_image->height),
+                                   matte_image->depth);
             matte_image->data=MagickAllocateMemory(char *,length);
             if (matte_image->data == (char *) NULL)
               {
@@ -6002,8 +6016,8 @@ MagickXMakeImage(Display *display,
 */
 static void
 MagickXMakeImageLSBFirst(const MagickXResourceInfo *resource_info,
-                        const MagickXWindowInfo *window,Image *image,
-                        XImage *ximage,XImage *matte_image)
+                         const MagickXWindowInfo *window,Image *image,
+                         XImage *ximage,XImage *matte_image)
 {
   int
     y;
@@ -6560,8 +6574,8 @@ MagickXMakeImageLSBFirst(const MagickXResourceInfo *resource_info,
 */
 static void
 MagickXMakeImageMSBFirst(const MagickXResourceInfo *resource_info,
-                        const MagickXWindowInfo *window,Image *image,
-                        XImage *ximage,XImage *matte_image)
+                         const MagickXWindowInfo *window,Image *image,
+                         XImage *ximage,XImage *matte_image)
 {
   int
     y;
@@ -7111,7 +7125,7 @@ MagickXMakeImageMSBFirst(const MagickXResourceInfo *resource_info,
 %
 %
 */
-MagickExport void 
+MagickExport void
 MagickXMakeMagnifyImage(Display *display,MagickXWindows *windows)
 {
   char
@@ -7561,8 +7575,8 @@ MagickXMakeMagnifyImage(Display *display,MagickXWindows *windows)
 */
 static unsigned int
 MagickXMakePixmap(Display *display,
-                 const MagickXResourceInfo *resource_info,
-                 MagickXWindowInfo *window)
+                  const MagickXResourceInfo *resource_info,
+                  MagickXWindowInfo *window)
 {
   unsigned int
     height,
@@ -7698,11 +7712,11 @@ static int PopularityCompare(const void *x,const void *y)
 
 MagickExport void
 MagickXMakeStandardColormap(Display *display,
-                           XVisualInfo *visual_info,
-                           MagickXResourceInfo *resource_info,
-                           Image *image,
-                           XStandardColormap *map_info,
-                           MagickXPixelInfo *pixel)
+                            XVisualInfo *visual_info,
+                            MagickXResourceInfo *resource_info,
+                            Image *image,
+                            XStandardColormap *map_info,
+                            MagickXPixelInfo *pixel)
 {
   Colormap
     colormap;
@@ -7853,7 +7867,7 @@ MagickXMakeStandardColormap(Display *display,
       */
       number_colors=image->colors;
       colors=MagickAllocateArray(XColor *,
-                                visual_info->colormap_size,sizeof(XColor));
+                                 visual_info->colormap_size,sizeof(XColor));
       if (colors == (XColor *) NULL)
         MagickFatalError3(ResourceLimitError,MemoryAllocationFailed,
           UnableToCreateColormap);
@@ -7893,7 +7907,7 @@ MagickXMakeStandardColormap(Display *display,
       */
       number_colors=image->colors;
       colors=MagickAllocateArray(XColor *,
-                                visual_info->colormap_size,sizeof(XColor));
+                                 visual_info->colormap_size,sizeof(XColor));
       if (colors == (XColor *) NULL)
         MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
           UnableToCreateColormap);
@@ -7939,7 +7953,7 @@ MagickXMakeStandardColormap(Display *display,
             Define Standard colormap for shared GrayScale or PseudoColor visual.
           */
           diversity=MagickAllocateArray(DiversityPacket *,
-                                       image->colors,sizeof(DiversityPacket));
+                                        image->colors,sizeof(DiversityPacket));
           if (diversity == (DiversityPacket *) NULL)
             MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
               UnableToCreateColormap);
@@ -8001,8 +8015,8 @@ MagickXMakeStandardColormap(Display *display,
             Read X server colormap.
           */
           server_colors=MagickAllocateArray(XColor *,
-                                           visual_info->colormap_size,
-                                           sizeof(XColor));
+                                            visual_info->colormap_size,
+                                            sizeof(XColor));
           if (server_colors == (XColor *) NULL)
             MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
               UnableToCreateColormap);
@@ -8289,8 +8303,8 @@ MagickXMakeStandardColormap(Display *display,
 */
 MagickExport void
 MagickXMakeWindow(Display *display,Window parent,char **argv,
-                 int argc,XClassHint *class_hint,XWMHints *manager_hints,
-                 MagickXWindowInfo *window_info)
+                  int argc,XClassHint *class_hint,XWMHints *manager_hints,
+                  MagickXWindowInfo *window_info)
 {
 #define MinWindowSize  64
 
@@ -8536,8 +8550,8 @@ MagickXMakeWindow(Display *display,Window parent,char **argv,
 */
 MagickExport unsigned int
 MagickXMagickMonitor(const char *task,
-                    const magick_int64_t quantum,const magick_uint64_t span,
-                    ExceptionInfo *exception)
+                     const magick_int64_t quantum,const magick_uint64_t span,
+                     ExceptionInfo *exception)
 {
   MagickXWindows
     *windows;
@@ -8663,7 +8677,7 @@ MagickXQueryColorDatabase(const char *target,XColor *color)
 %
 %
 */
-MagickExport void 
+MagickExport void
 MagickXQueryPosition(Display *display,const Window window,int *x,int *y)
 {
   int
@@ -8716,7 +8730,7 @@ MagickXQueryPosition(Display *display,const Window window,int *x,int *y)
 */
 MagickExport void
 MagickXRefreshWindow(Display *display,const MagickXWindowInfo *window,
-                    const XEvent *event)
+                     const XEvent *event)
 {
   int
     x,
@@ -8822,7 +8836,7 @@ MagickXRefreshWindow(Display *display,const MagickXWindowInfo *window,
 */
 MagickExport unsigned int
 MagickXRemoteCommand(Display *display,const char *window,
-                    const char *filename)
+                     const char *filename)
 {
   Atom
     remote_atom;
@@ -9175,8 +9189,8 @@ MagickXSignalHandler(int status)
 */
 MagickExport void
 MagickXSetCursorState(Display *display,
-                     MagickXWindows *windows,
-                     const unsigned int state)
+                      MagickXWindows *windows,
+                      const unsigned int state)
 {
   assert(display != (Display *) NULL);
   assert(windows != (MagickXWindows *) NULL);
@@ -9393,7 +9407,7 @@ MagickXVisualClassName(const int visual_class)
 */
 MagickExport void
 MagickXWarning(const ExceptionType warning,
-              const char *reason,const char *description)
+               const char *reason,const char *description)
 {
   char
     text[MaxTextExtent];
@@ -9443,7 +9457,7 @@ MagickXWarning(const ExceptionType warning,
 */
 MagickExport Window
 MagickXWindowByID(Display *display,const Window root_window,
-                 const unsigned long id)
+                  const unsigned long id)
 {
   RectangleInfo
     rectangle_info;
@@ -9517,7 +9531,7 @@ MagickXWindowByID(Display *display,const Window root_window,
 */
 MagickExport Window
 MagickXWindowByName(Display *display,const Window root_window,
-                   const char *name)
+                    const char *name)
 {
   register int
     i;
@@ -9590,7 +9604,7 @@ MagickXWindowByName(Display *display,const Window root_window,
 */
 MagickExport Window
 MagickXWindowByProperty(Display *display,const Window window,
-                       const Atom property)
+                        const Atom property)
 {
   Atom
     type;
index b66ff97..ab0e072 100644 (file)
@@ -1,11 +1,11 @@
 /*
   Copyright (C) 2003 GraphicsMagick Group
   Copyright (C) 2002 ImageMagick Studio
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
   X11 Utility Methods for ImageMagick.
 */
 #ifndef _MAGICK_XWINDOW_H
@@ -534,7 +534,7 @@ extern MagickExport int
   MagickXError(Display *,XErrorEvent *);
 
 extern MagickExport unsigned int
-  MagickIsTrue(const char *),
+  MagickIsTrue(const char *) MAGICK_FUNC_PURE,
   MagickXAnnotateImage(Display *,const MagickXPixelInfo *,MagickXAnnotateInfo *,Image *),
   MagickXDisplayBackgroundImage(Display *,MagickXResourceInfo *,Image *),
   MagickXDrawImage(Display *,const MagickXPixelInfo *,MagickXDrawInfo *,Image *),
diff --git a/scripts/gmsymbols.sh b/scripts/gmsymbols.sh
new file mode 100755 (executable)
index 0000000..cbb6140
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# Execute like
+# gmsymbols.sh magick/.libs/libGraphicsMagick.a MAGICK
+
+LIB=$1
+SYM=$2
+
+cat <<EOF
+/*
+  Copyright (C) 2012-2018 GraphicsMagick Group
+
+  This program is covered by multiple licenses, which are described in
+  Copyright.txt. You should have received a copy of Copyright.txt with this
+  package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
+
+  Library symbol name-scoping support.
+*/
+
+#if !defined(_${SYM}_SYMBOLS_H)
+#define _${SYM}_SYMBOLS_H
+
+#if defined(PREFIX_MAGICK_SYMBOLS)
+
+EOF
+
+nm -p ${LIB} | grep ' [DT] ' | egrep -vi '^(Gm)|(GM)|(lt_)|(_)' | \
+egrep -v '(MagickError)|(MagickFatalError)|(MagickWarning)|(ThrowException)|(LoadImageText)|(SaveImageText)|(LoadImagesText)|(SaveImagesText)' | \
+awk '{ printf("#define %s Gm%s\n", $3, $3); }' | sort
+
+cat <<EOF
+
+#endif /* defined(PREFIX_MAGICK_SYMBOLS) */
+#endif /* defined(_${SYM}_SYMBOLS_H) */
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 2
+ * fill-column: 78
+ * End:
+ */
+EOF
index dcc983c..bb267bc 100644 (file)
@@ -55,7 +55,7 @@ nav_template = """
 footer_template = """
 <hr class="divider">
 <div class="footer">
-    <p><a href="%(url_prefix)sCopyright.html">Copyright</a>GraphicsMagick Group 2002 - 2017</p>
+    <p><a href="%(url_prefix)sCopyright.html">Copyright</a>GraphicsMagick Group 2002 - 2018</p>
 </div>
 """
 
index 9dd30a5..4db481b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 - 2013 GraphicsMagick Group
+ * Copyright (C) 2003 - 2018 GraphicsMagick Group
  * Copyright (C) 2003 ImageMagick Studio
  * Copyright 1991-1999 E. I. du Pont de Nemours and Company
  *
@@ -19,6 +19,7 @@
  */
 
 #include <magick/api.h>
+#include <magick/enum_strings.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -74,32 +75,14 @@ int main ( int argc, char **argv )
     {
       char
         *option = argv[arg];
-    
+
       if (*option == '-')
         {
           if (LocaleCompare("compress",option+1) == 0)
             {
               arg++;
               option=argv[arg];
-              imageInfo->compression=UndefinedCompression;
-              if (LocaleCompare("None",option) == 0)
-                imageInfo->compression=NoCompression;
-              if (LocaleCompare("BZip",option) == 0)
-                imageInfo->compression=BZipCompression;
-              if (LocaleCompare("Fax",option) == 0)
-                imageInfo->compression=FaxCompression;
-              if (LocaleCompare("Group4",option) == 0)
-                imageInfo->compression=Group4Compression;
-              if (LocaleCompare("JPEG",option) == 0)
-                imageInfo->compression=JPEGCompression;
-              if (LocaleCompare("Lossless",option) == 0)
-                imageInfo->compression=LosslessJPEGCompression;
-              if (LocaleCompare("LZW",option) == 0)
-                imageInfo->compression=LZWCompression;
-              if (LocaleCompare("RLE",option) == 0)
-                imageInfo->compression=RLECompression;
-              if (LocaleCompare("Zip",option) == 0)
-                imageInfo->compression=ZipCompression;
+              imageInfo->compression=StringToCompressionType(option);
             }
           else if (LocaleCompare("debug",option+1) == 0)
             {
@@ -117,10 +100,10 @@ int main ( int argc, char **argv )
                   goto program_exit;
                 }
               if(imageInfo->depth != 8 && imageInfo->depth != 16 &&
-                imageInfo->depth != 32)
+                 imageInfo->depth != 32)
                 {
                   (void) printf("-depth (%ld) not 8, 16, or 32\n",
-                               imageInfo->depth);
+                                imageInfo->depth);
                   (void) fflush(stdout);
                   exit_status = 1;
                   goto program_exit;
@@ -184,9 +167,9 @@ int main ( int argc, char **argv )
     {
       (void) printf("arg=%d, argc=%d\n", arg, argc);
       (void) printf ( "Usage: %s [-compress algorithm -debug events -depth "
-                     "integer -define value -log format -nocheck -quality quality "
+                      "integer -define value -log format -nocheck -quality quality "
                       "-size geometry -verbose] "
-                     "infile format\n", argv[0] );
+                      "infile format\n", argv[0] );
       (void) fflush(stdout);
       exit_status = 1;
       goto program_exit;
@@ -231,6 +214,8 @@ int main ( int argc, char **argv )
   original = ReadImage ( imageInfo, &exception );
   if (exception.severity != UndefinedException)
     {
+      if (exception.reason)
+        (void) printf("    reason:%s\n",exception.reason);
       CatchException(&exception);
       exit_status = 1;
       goto program_exit;
@@ -238,7 +223,7 @@ int main ( int argc, char **argv )
   if ( original == (Image *)NULL )
     {
       (void) printf ( "Failed to read original image %s\n",
-                     imageInfo->filename );
+                      imageInfo->filename );
       (void) fflush(stdout);
       exit_status = 1;
       goto program_exit;
@@ -270,14 +255,24 @@ int main ( int argc, char **argv )
   blob =(char *) ImageToBlob ( imageInfo, original, &blob_length, &exception );
   if (exception.severity != UndefinedException)
     {
+      if (exception.reason)
+        (void) printf("    reason:%s\n",exception.reason);
       CatchException(&exception);
       exit_status = 1;
       goto program_exit;
     }
   if ( blob == NULL )
     {
-      (void) printf ( "Failed to write BLOB in format %s\n",
-                     imageInfo->magick );
+      (void) printf ( "Failed to write BLOB in format %s (blob is NULL!)\n",
+                      imageInfo->magick );
+      (void) fflush(stdout);
+      exit_status = 1;
+      goto program_exit;
+    }
+  if ( blob_length == 0)
+    {
+      (void) printf ( "Failed to write BLOB in format %s (blob length is 0!)\n",
+                      imageInfo->magick );
       (void) fflush(stdout);
       exit_status = 1;
       goto program_exit;
@@ -303,28 +298,30 @@ int main ( int argc, char **argv )
     ping_image = PingBlob(imageInfo, blob, blob_length, &exception );
     if (exception.severity != UndefinedException)
       {
-       CatchException(&exception);
-       (void) fflush(stderr);
-       ping_error = MagickTrue;
+        if (exception.reason)
+          (void) printf("    reason:%s\n",exception.reason);
+        CatchException(&exception);
+        (void) fflush(stderr);
+        ping_error = MagickTrue;
       }
     if ( ping_image == (Image *)NULL )
       {
-       (void) printf ( "Failed to ping image from BLOB in format %s\n",
-                       imageInfo->magick );
-       (void) fflush(stdout);
-       ping_error = MagickTrue;
+        (void) printf ( "Failed to ping image from BLOB in format %s\n",
+                        imageInfo->magick );
+        (void) fflush(stdout);
+        ping_error = MagickTrue;
       }
     else
       {
-       /* Print a short description of the image to stdout */
-       DescribeImage( ping_image, stdout, MagickFalse );
-       (void) fflush(stdout);
-       DestroyImageList( ping_image );
+        /* Print a short description of the image to stdout */
+        DescribeImage( ping_image, stdout, MagickFalse );
+        (void) fflush(stdout);
+        DestroyImageList( ping_image );
       }
     if (ping_error)
       {
-       exit_status = 1;
-       goto program_exit;
+        exit_status = 1;
+        goto program_exit;
       }
   }
 
@@ -338,6 +335,8 @@ int main ( int argc, char **argv )
   original = BlobToImage( imageInfo, blob, blob_length, &exception );
   if (exception.severity != UndefinedException)
     {
+      if (exception.reason)
+        (void) printf("    reason:%s\n",exception.reason);
       CatchException(&exception);
       exit_status = 1;
       goto program_exit;
@@ -345,7 +344,7 @@ int main ( int argc, char **argv )
   if ( original == (Image *)NULL )
     {
       (void) printf ( "Failed to read image from BLOB in format %s\n",
-                     imageInfo->magick );
+                      imageInfo->magick );
       (void) fflush(stdout);
       exit_status = 1;
       goto program_exit;
@@ -361,9 +360,11 @@ int main ( int argc, char **argv )
   (void) strcpy( imageInfo->filename, "" );
   original->delay = 10;
   blob = (char *) ImageToBlob ( imageInfo, original, &blob_length,
-                               &exception );
+                                &exception );
   if (exception.severity != UndefinedException)
     {
+      if (exception.reason)
+        (void) printf("    reason:%s\n",exception.reason);
       CatchException(&exception);
       exit_status = 1;
       goto program_exit;
@@ -372,7 +373,7 @@ int main ( int argc, char **argv )
   if ( blob == NULL )
     {
       (void) printf ( "Failed to write BLOB in format %s\n",
-                     imageInfo->magick );
+                      imageInfo->magick );
       (void) fflush(stdout);
       exit_status = 1;
       goto program_exit;
@@ -390,6 +391,8 @@ int main ( int argc, char **argv )
   final = BlobToImage( imageInfo, blob, blob_length, &exception );
   if (exception.severity != UndefinedException)
     {
+      if (exception.reason)
+        (void) printf("    reason:%s\n",exception.reason);
       CatchException(&exception);
       exit_status = 1;
       goto program_exit;
@@ -397,7 +400,7 @@ int main ( int argc, char **argv )
   if ( final == (Image *)NULL )
     {
       (void) printf ( "Failed to read image from BLOB in format %s\n",
-                     imageInfo->magick );
+                      imageInfo->magick );
       (void) fflush(stdout);
       exit_status = 1;
       goto program_exit;
@@ -411,10 +414,10 @@ int main ( int argc, char **argv )
        * Check final output
        */
       double
-       fuzz_factor = 0;
+        fuzz_factor = 0;
 
       /*
-       Some formats are lossy.
+        Some formats are lossy.
       */
       if ((!strcmp( "CIN", format ) && (QuantumDepth == 8)) ||
           (!strcmp( "CMYK", format )) ||
@@ -433,76 +436,90 @@ int main ( int argc, char **argv )
           (final->compression == JPEGCompression))
         fuzz_factor = 0.06;
 
+      switch(imageInfo->compression)
+        {
+        case JPEGCompression:
+        case JPEG2000Compression:
+        case WebPCompression:
+          {
+            fuzz_factor = 0.06;
+            break;
+          }
+        default:
+          {
+          }
+        }
+
       {
-       Image
-         *o,
-         *f;
-       
-       unsigned long
-         frame=0;
-
-       /*
-         Verify that frame pixels are identical (or close enough).
-       */
-       for (o=original, f=final, frame=0;
-            ((o != (Image *) NULL) && (f != (Image *) NULL)) ;
-            o = o->next, f = f->next, frame++)
-         {
-           printf("Checking frame %ld...\n",frame);
-           if ( !IsImagesEqual(o, f ) &&
-                (original->error.normalized_mean_error > fuzz_factor) )
-             {
-               (void) printf( "R/W file check for format \"%s\" failed "
-                              "(frame = %ld): %.6f/%.6f/%.6fe\n",
-                              format,frame,
-                              original->error.mean_error_per_pixel,
-                              original->error.normalized_mean_error,
-                              original->error.normalized_maximum_error);
-               (void) fflush(stdout);
-               exit_status = 1;
-               goto program_exit;
-             }
-         }
-
-       if (check_for_added_frames)
-         {
-           /*
-             Verify that reads from BLOB R/W #1 and BLOB R/W #2 did
-             return the same number of frames.
-           */
-           if ((o != (Image *) NULL) && (f != (Image *) NULL))
-             {
-               (void) printf("R/W file check for format \"%s\" failed due to "
-                             "differing number of returned frames (%ld vs %ld)\n",
-                             format,
-                             GetImageListLength(original),
-                             GetImageListLength(final));
-               exit_status = 1;
-               goto program_exit;
-             }
-
-           /*
-             If format supports multiple frames, then we should expect
-             that frames are not lost (or spuriously added) due to
-             read/write of format.
-           */
-           if (magick_info->adjoin)
-             {
-               unsigned long
-                 final_frames;
-
-               final_frames=GetImageListLength(final);
-               if (original_frames != final_frames)
-                 {
-                   (void) printf("R/W file check for format \"%s\" failed due "
-                                 "to differing number of returned frames (%ld "
-                                 "vs %ld) from original file\n",
-                                 format,original_frames,final_frames);
-                   exit_status = 1;
-                   goto program_exit;
-                 }
-             }
-         }
+        Image
+          *o,
+          *f;
+
+        unsigned long
+          frame=0;
+
+        /*
+          Verify that frame pixels are identical (or close enough).
+        */
+        for (o=original, f=final, frame=0;
+             ((o != (Image *) NULL) && (f != (Image *) NULL)) ;
+             o = o->next, f = f->next, frame++)
+          {
+            printf("Checking frame %ld...\n",frame);
+            if ( !IsImagesEqual(o, f ) &&
+                 (original->error.normalized_mean_error > fuzz_factor) )
+              {
+                (void) printf( "R/W file check for format \"%s\" failed "
+                               "(frame = %ld): %.6f/%.6f/%.6fe\n",
+                               format,frame,
+                               original->error.mean_error_per_pixel,
+                               original->error.normalized_mean_error,
+                               original->error.normalized_maximum_error);
+                (void) fflush(stdout);
+                exit_status = 1;
+                goto program_exit;
+              }
+          }
+
+        if (check_for_added_frames)
+          {
+            /*
+              Verify that reads from BLOB R/W #1 and BLOB R/W #2 did
+              return the same number of frames.
+            */
+            if ((o != (Image *) NULL) && (f != (Image *) NULL))
+              {
+                (void) printf("R/W file check for format \"%s\" failed due to "
+                              "differing number of returned frames (%ld vs %ld)\n",
+                              format,
+                              GetImageListLength(original),
+                              GetImageListLength(final));
+                exit_status = 1;
+                goto program_exit;
+              }
+
+            /*
+              If format supports multiple frames, then we should expect
+              that frames are not lost (or spuriously added) due to
+              read/write of format.
+            */
+            if (magick_info->adjoin)
+              {
+                unsigned long
+                  final_frames;
+
+                final_frames=GetImageListLength(final);
+                if (original_frames != final_frames)
+                  {
+                    (void) printf("R/W file check for format \"%s\" failed due "
+                                  "to differing number of returned frames (%ld "
+                                  "vs %ld) from original file\n",
+                                  format,original_frames,final_frames);
+                    exit_status = 1;
+                    goto program_exit;
+                  }
+              }
+          }
       }
     }
 
index c78429a..8292c67 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (C) 2004-2015 GraphicsMagick Group
+# Copyright (C) 2004-2018 GraphicsMagick Group
 . ./common.shi
 . ${top_srcdir}/tests/common.shi
 
@@ -10,7 +10,7 @@ rwblob=./rwblob
 check_types='bilevel gray pallette truecolor'
 
 # Number of tests we plan to run
-test_plan_fn 204
+test_plan_fn 209
 
 # ART format
 for type in ${check_types}
@@ -29,6 +29,8 @@ for type in ${check_types}
 do
   test_command_fn "BMP ${type}" ${MEMCHECK} ${rwblob} "${SRCDIR}/input_${type}.miff" BMP
 done
+# Special test to verify that lower-case magick works
+test_command_fn "BMP truecolor" ${MEMCHECK} ${rwblob} "${SRCDIR}/input_${type}.miff" bmp
 
 # BMP2 format
 for type in ${check_types}
@@ -222,6 +224,12 @@ do
   test_command_fn "PPM ${type}" ${MEMCHECK} ${rwblob} "${SRCDIR}/input_${type}.miff" PPM
 done
 
+# PTIF format
+for type in ${check_types}
+do
+  test_command_fn "PTIF ${type}" -F TIFF ${MEMCHECK} ${rwblob} "${SRCDIR}/input_${type}.miff" PTIF
+done
+
 # RAS format
 for type in ${check_types}
 do
index 946688e..9bb151a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003 - 2013 GraphicsMagick Group
+ * Copyright (C) 2003 - 2018 GraphicsMagick Group
  * Copyright (C) 2003 ImageMagick Studio
  * Copyright 1991-1999 E. I. du Pont de Nemours and Company
  *
@@ -19,6 +19,7 @@
  * */
 
 #include <magick/api.h>
+#include <magick/enum_strings.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -81,34 +82,14 @@ int main ( int argc, char **argv )
     {
       char
         *option = argv[arg];
-    
+
       if (*option == '-')
         {
           if (LocaleCompare("compress",option+1) == 0)
             {
               arg++;
               option=argv[arg];
-              imageInfo->compression=UndefinedCompression;
-              if (LocaleCompare("Undefined",option) == 0)
-                imageInfo->compression=UndefinedCompression;
-              if (LocaleCompare("None",option) == 0)
-                imageInfo->compression=NoCompression;
-              if (LocaleCompare("BZip",option) == 0)
-                imageInfo->compression=BZipCompression;
-              if (LocaleCompare("Fax",option) == 0)
-                imageInfo->compression=FaxCompression;
-              if (LocaleCompare("Group4",option) == 0)
-                imageInfo->compression=Group4Compression;
-              if (LocaleCompare("JPEG",option) == 0)
-                imageInfo->compression=JPEGCompression;
-              if (LocaleCompare("Lossless",option) == 0)
-                imageInfo->compression=LosslessJPEGCompression;
-              if (LocaleCompare("LZW",option) == 0)
-                imageInfo->compression=LZWCompression;
-              if (LocaleCompare("RLE",option) == 0)
-                imageInfo->compression=RLECompression;
-              if (LocaleCompare("Zip",option) == 0)
-                imageInfo->compression=ZipCompression;
+              imageInfo->compression=StringToCompressionType(option);
             }
           else if (LocaleCompare("debug",option+1) == 0)
             {
@@ -142,19 +123,19 @@ int main ( int argc, char **argv )
                   goto program_exit;
                 }
               if(imageInfo->depth != 8 && imageInfo->depth != 16 &&
-                imageInfo->depth != 32)
+                 imageInfo->depth != 32)
                 {
                   (void) printf("-depth (%ld) not 8, 16, or 32\n",
-                               imageInfo->depth);
+                                imageInfo->depth);
                   (void) fflush(stdout);
                   exit_status = 1;
                   goto program_exit;
                 }
             }
-         else if (LocaleCompare("filespec",option+1) == 0)
-           {
-             (void) strcpy(basefilespec,argv[++arg]);
-           }
+          else if (LocaleCompare("filespec",option+1) == 0)
+            {
+              (void) strcpy(basefilespec,argv[++arg]);
+            }
           else if (LocaleCompare("log",option+1) == 0)
             {
               (void) SetLogFormat(argv[++arg]);
@@ -183,7 +164,7 @@ int main ( int argc, char **argv )
                 }
               (void) CloneString(&imageInfo->size,argv[arg]);
             }
-         else if (LocaleCompare("stdio",option+1) == 0)
+          else if (LocaleCompare("stdio",option+1) == 0)
             {
               use_stdio=MagickTrue;
             }
@@ -209,7 +190,7 @@ int main ( int argc, char **argv )
       exit_status = 1;
       goto program_exit;
     }
-  
+
   (void) strncpy(infile, argv[arg], MaxTextExtent-1 );
   arg++;
   (void) strncpy( format, argv[arg], MaxTextExtent-1 );
@@ -242,16 +223,16 @@ int main ( int argc, char **argv )
   if (use_stdio)
     {
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "Reading stdio image %s", infile);
+                            "Reading stdio image %s", infile);
       imageInfo->file=fopen(infile,"rb");
     }
   else
     {
       (void) strncpy( imageInfo->filename, infile, MaxTextExtent-1 );
       if (!magick_info->adjoin || !check_for_added_frames)
-       (void) strcat( imageInfo->filename, "[0]" );
+        (void) strcat( imageInfo->filename, "[0]" );
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "Reading image %s", imageInfo->filename);
+                            "Reading image %s", imageInfo->filename);
     }
   original = ReadImage ( imageInfo, &exception );
   if (use_stdio)
@@ -261,6 +242,8 @@ int main ( int argc, char **argv )
     }
   if (exception.severity != UndefinedException)
     {
+      if (exception.reason)
+        (void) printf("    reason:%s\n",exception.reason);
       CatchException(&exception);
       exit_status = 1;
       goto program_exit;
@@ -268,7 +251,7 @@ int main ( int argc, char **argv )
   if ( original == (Image *)NULL )
     {
       (void) printf ( "Failed to read original image %s\n",
-                     imageInfo->filename );
+                      imageInfo->filename );
       (void) fflush(stdout);
       exit_status = 1;
       goto program_exit;
@@ -295,7 +278,7 @@ int main ( int argc, char **argv )
   if (IgnoreExtensionTreatment == magick_info->extension_treatment)
     {
       /*
-       Prepend magic specifier if extension will be ignored.
+        Prepend magic specifier if extension will be ignored.
       */
       (void) strcpy(filespec,format);
       (void) strcat(filespec,":");
@@ -320,18 +303,20 @@ int main ( int argc, char **argv )
   if (use_stdio)
     {
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "Writing stdio image %s", filename);
+                            "Writing stdio image %s", filename);
       imageInfo->file=fopen(filename,"wb+");
     }
   else
     {
       (void) strncpy( original->filename, filename, MaxTextExtent-1 );
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "Writing image %s", original->filename);
+                            "Writing image %s", original->filename);
     }
   original->delay = 10;
   if (!WriteImage ( imageInfo, original ))
     {
+      if (exception.reason)
+        (void) printf("    reason:%s\n",exception.reason);
       CatchException(&original->exception);
       exit_status = 1;
       goto program_exit;
@@ -359,11 +344,11 @@ int main ( int argc, char **argv )
     (void) strncpy( imageInfo->magick, format, MaxTextExtent-1 );
     if (use_stdio)
       {
-       imageInfo->file=fopen(filename,"rb");
+        imageInfo->file=fopen(filename,"rb");
       }
     else
       {
-       strncpy( imageInfo->filename, filename, MaxTextExtent-1 );
+        strncpy( imageInfo->filename, filename, MaxTextExtent-1 );
       }
     if ( size[0] != '\0' )
       (void) CloneString( &imageInfo->size, size );
@@ -371,32 +356,34 @@ int main ( int argc, char **argv )
     ping_image = PingImage(imageInfo, &exception );
     if (use_stdio)
       {
-       (void) fclose(imageInfo->file);
-       imageInfo->file = (FILE *) NULL;
+        (void) fclose(imageInfo->file);
+        imageInfo->file = (FILE *) NULL;
       }
     if (exception.severity != UndefinedException)
       {
-       CatchException(&exception);
-       (void) fflush(stderr);
-       ping_error = MagickTrue;
+        if (exception.reason)
+          (void) printf("    reason:%s\n",exception.reason);
+        CatchException(&exception);
+        (void) fflush(stderr);
+        ping_error = MagickTrue;
       }
     if ( ping_image == (Image *)NULL )
       {
-       (void) printf ( "Failed to ping image from file \"%s\" in format %s\n",
-                       filename, imageInfo->magick );
-       (void) fflush(stdout);
-       ping_error = MagickTrue;
+        (void) printf ( "Failed to ping image from file \"%s\" in format %s\n",
+                        filename, imageInfo->magick );
+        (void) fflush(stdout);
+        ping_error = MagickTrue;
       }
     else
       {
-       /* Print a short description of the image to stdout */
-       DescribeImage( ping_image, stdout, MagickFalse );
-       DestroyImageList( ping_image );
+        /* Print a short description of the image to stdout */
+        DescribeImage( ping_image, stdout, MagickFalse );
+        DestroyImageList( ping_image );
       }
     if (ping_error)
       {
-       exit_status = 1;
-       goto program_exit;
+        exit_status = 1;
+        goto program_exit;
       }
   }
 
@@ -424,6 +411,8 @@ int main ( int argc, char **argv )
     }
   if (exception.severity != UndefinedException)
     {
+      if (exception.reason)
+        (void) printf("    reason:%s\n",exception.reason);
       CatchException(&exception);
       exit_status = 1;
       goto program_exit;
@@ -449,19 +438,21 @@ int main ( int argc, char **argv )
   if (use_stdio)
     {
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "Writing stdio image %s", filename);
+                            "Writing stdio image %s", filename);
       imageInfo->file=fopen(filename,"wb+");
     }
   else
     {
       (void) strncpy( original->filename, filename, MaxTextExtent-1 );
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                           "Writing stdio image %s", original->filename);
+                            "Writing stdio image %s", original->filename);
     }
   original->delay = 10;
   (void) fflush(stdout);
   if(!WriteImage (imageInfo,original))
     {
+      if (exception.reason)
+        (void) printf("    reason:%s\n",exception.reason);
       CatchException(&original->exception);
       exit_status = 1;
       goto program_exit;
@@ -493,6 +484,8 @@ int main ( int argc, char **argv )
   final = ReadImage ( imageInfo, &exception );
   if (exception.severity != UndefinedException)
     {
+      if (exception.reason)
+        (void) printf("    reason:%s\n",exception.reason);
       CatchException(&exception);
       exit_status = 1;
       goto program_exit;
@@ -512,10 +505,10 @@ int main ( int argc, char **argv )
        * Check final output
        */
       double
-       fuzz_factor = 0;
+        fuzz_factor = 0;
 
       /*
-       Some formats are lossy.
+        Some formats are lossy.
       */
       if ((!strcmp( "CIN", format ) && (QuantumDepth == 8)) ||
           (!strcmp( "CMYK", format )) ||
@@ -534,76 +527,90 @@ int main ( int argc, char **argv )
           (final->compression == JPEGCompression))
         fuzz_factor = 0.06;
 
+      switch(imageInfo->compression)
+        {
+        case JPEGCompression:
+        case JPEG2000Compression:
+        case WebPCompression:
+          {
+            fuzz_factor = 0.06;
+            break;
+          }
+        default:
+          {
+          }
+        }
+
       {
-       Image
-         *o,
-         *f;
-       
-       unsigned long
-         frame=0;
-
-       /*
-         Verify that frame pixels are identical (or close enough).
-       */
-       for (o=original, f=final, frame=0;
-            ((o != (Image *) NULL) && (f != (Image *) NULL)) ;
-            o = o->next, f = f->next, frame++)
-         {
-           printf("Checking frame %ld...\n",frame);
-           if ( !IsImagesEqual(o, f ) &&
-                (original->error.normalized_mean_error > fuzz_factor) )
-             {
-               (void) printf( "R/W file check for format \"%s\" failed "
-                              "(frame = %ld): %.6f/%.6f/%.6fe\n",
-                              format,frame,
-                              original->error.mean_error_per_pixel,
-                              original->error.normalized_mean_error,
-                              original->error.normalized_maximum_error);
-               (void) fflush(stdout);
-               exit_status = 1;
-               goto program_exit;
-             }
-         }
-       if (check_for_added_frames)
-         {
-           /*
-             Verify that reads from file R/W #1 and file R/W #2 did
-             return the same number of frames.
-           */
-           if ((o != (Image *) NULL) && (f != (Image *) NULL))
-             {
-               (void) printf("R/W file check for format \"%s\" failed due to "
-                             "differing number of returned frames (%ld vs %ld)\n",
-                             format,
-                             GetImageListLength(original),
-                             GetImageListLength(final));
-               exit_status = 1;
-               goto program_exit;
-             }
-
-           /*
-             If format supports multiple frames, then we should expect
-             that frames are not lost (or spuriously added) due to
-             read/write of format.
-           */
-           if (magick_info->adjoin)
-             {
-               unsigned long
-                 final_frames;
-
-               final_frames=GetImageListLength(final);
-               if (original_frames != final_frames)
-                 {
-                   (void) printf("R/W file check for format \"%s\" failed due "
-                                 "to differing number of returned frames (%ld "
-                                 "vs %ld) from original file\n",
-                                 format,original_frames,final_frames);
-                   exit_status = 1;
-                   goto program_exit;
-                 }
-             }
-         }
+        Image
+          *o,
+          *f;
+
+        unsigned long
+          frame=0;
+
+        /*
+          Verify that frame pixels are identical (or close enough).
+        */
+        for (o=original, f=final, frame=0;
+             ((o != (Image *) NULL) && (f != (Image *) NULL)) ;
+             o = o->next, f = f->next, frame++)
+          {
+            printf("Checking frame %ld...\n",frame);
+            if ( !IsImagesEqual(o, f ) &&
+                 (original->error.normalized_mean_error > fuzz_factor) )
+              {
+                (void) printf( "R/W file check for format \"%s\" failed "
+                               "(frame = %ld): %.6f/%.6f/%.6fe\n",
+                               format,frame,
+                               original->error.mean_error_per_pixel,
+                               original->error.normalized_mean_error,
+                               original->error.normalized_maximum_error);
+                (void) fflush(stdout);
+                exit_status = 1;
+                goto program_exit;
+              }
+          }
+
+        if (check_for_added_frames)
+          {
+            /*
+              Verify that reads from file R/W #1 and file R/W #2 did
+              return the same number of frames.
+            */
+            if ((o != (Image *) NULL) && (f != (Image *) NULL))
+              {
+                (void) printf("R/W file check for format \"%s\" failed due to "
+                              "differing number of returned frames (%ld vs %ld)\n",
+                              format,
+                              GetImageListLength(original),
+                              GetImageListLength(final));
+                exit_status = 1;
+                goto program_exit;
+              }
+
+            /*
+              If format supports multiple frames, then we should expect
+              that frames are not lost (or spuriously added) due to
+              read/write of format.
+            */
+            if (magick_info->adjoin)
+              {
+                unsigned long
+                  final_frames;
+
+                final_frames=GetImageListLength(final);
+                if (original_frames != final_frames)
+                  {
+                    (void) printf("R/W file check for format \"%s\" failed due "
+                                  "to differing number of returned frames (%ld "
+                                  "vs %ld) from original file\n",
+                                  format,original_frames,final_frames);
+                    exit_status = 1;
+                    goto program_exit;
+                  }
+              }
+          }
       }
     }
 
index f86c3a0..b26dee7 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # -*- shell-script -*-
-# Copyright (C) 2004-2015 GraphicsMagick Group
+# Copyright (C) 2004-2017 GraphicsMagick Group
 . ./common.shi
 . ${top_srcdir}/tests/common.shi
 
@@ -11,7 +11,7 @@ rwfile=./rwfile
 check_types='bilevel gray pallette truecolor'
 
 # Number of tests we plan to run
-test_plan_fn 564
+test_plan_fn 648
 
 # ART format
 for type in ${check_types}
@@ -202,6 +202,27 @@ do
   test_command_fn "MIFF ${type} (stdio)" ${MEMCHECK} ${rwfile} -stdio -filespec "out_${type}_stdio_%d" "${SRCDIR}/input_${type}.miff" MIFF
 done
 
+for type in ${check_types}
+do
+    test_command_fn "MIFF RLE compressed ${type}" ${MEMCHECK} ${rwfile} -compress RLE -filespec "out_${type}_rle_%d" "${SRCDIR}/input_${type}.miff" MIFF
+done
+
+# Normally one would expect that -F BZLIB is required, but bzip
+# compression is silently translated to no compression if not
+# available.
+for type in ${check_types}
+do
+    test_command_fn "MIFF BZIP compressed ${type}" ${MEMCHECK} ${rwfile} -compress BZIP -filespec "out_${type}_bzip_%d" "${SRCDIR}/input_${type}.miff" MIFF
+done
+
+# Normally one would expect that -F ZLIB is required, but zip
+# compression is silently translated to no compression if not
+# available.
+for type in ${check_types}
+do
+    test_command_fn "MIFF ZIP compressed ${type}" ${rwfile} -compress ZIP -filespec "out_${type}_zip_%d" "${SRCDIR}/input_${type}.miff" MIFF
+done
+
 # MNG format
 for type in ${check_types}
 do
@@ -406,10 +427,13 @@ do
 done
 
 # TIFF format
-for type in ${check_types}
+for compress in None Fax Group4 JPEG LZW RLE Zip LZMA WebP ZSTD
 do
-  test_command_fn "TIFF ${type}" -F TIFF ${MEMCHECK} ${rwfile} -filespec "out_${type}_%d" "${SRCDIR}/input_${type}.miff" TIFF
-  test_command_fn "TIFF ${type} (stdio)" -F TIFF ${MEMCHECK} ${rwfile} -stdio -filespec "out_${type}_stdio_%d" "${SRCDIR}/input_${type}.miff" TIFF
+  for type in ${check_types}
+  do
+    test_command_fn "TIFF ${type} compress=${compress}" -F TIFF ${MEMCHECK} ${rwfile} -compress ${compress} -filespec "out_${type}_${compress}_%d" "${SRCDIR}/input_${type}.miff" TIFF
+    test_command_fn "TIFF ${type}  compress=${compress} (stdio)" -F TIFF ${MEMCHECK} ${rwfile} -stdio -compress ${compress} -filespec "out_${type}_${compress}_stdio_%d" "${SRCDIR}/input_${type}.miff" TIFF
+  done
 done
 
 # VDA format
index 8b6178c..47e01c3 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2004-2012 GraphicsMagick Group
+# Copyright (C) 2004-2018 GraphicsMagick Group
 #
 # This program is covered by multiple licenses, which are described in
 # Copyright.txt. You should have received a copy of Copyright.txt with this
@@ -16,7 +16,7 @@ utilities_gm_LDFLAGS  = $(LDFLAGS)
 utilities_gm_SOURCES   = utilities/gm.c
 
 
-UTILITIES_XFAIL_TESTS = 
+UTILITIES_XFAIL_TESTS =
 
 # Tests to run
 UTILITIES_TESTS = \
@@ -32,7 +32,7 @@ UTILITIES_TESTS = \
        utilities/tests/preview.tap
 
 utilities/tests/montage.log : \
-       utilities/tests/effects.tap
+       utilities/tests/effects.log
 
 UTILITIES_MANS = \
        utilities/gm.1 \
index 889c3a1..3525e0b 100644 (file)
@@ -1,4 +1,4 @@
-.TH gm 1 "2017/01/29" "GraphicsMagick"
+.TH gm 1 "2018/10/14" "GraphicsMagick"
 .TP
 .in 15
 .in 15
@@ -1040,9 +1040,10 @@ space, then the change-image pixel intensities are used.
 \fRthe type of image compression
 
 Choices are: \fINone\fP, \fIBZip\fP, \fIFax\fP,
-\fIGroup4\fP,
+\fIGroup3\fP, \fIGroup4\fP,
 \fIJPEG\fP, \fILossless\fP,
-\fILZW\fP, \fIRLE\fP, \fIZip\fP, or \fILZMA\fP.
+\fILZW\fP, \fIRLE\fP, \fIZip\fP, \fILZMA\fP, \fIJPEG2000\fP,
+\fIJPEG2000\fP, \fIJBIG\fP, \fIJBIG2\fP, \fIWebP\fP, or \fIZSTD\fP.
 
 
 Specify \fB+compress\fP to store the binary image in an uncompressed format.
@@ -1052,10 +1053,11 @@ The default is the compression type of the specified image file.
 the JPEG library has been patched to support it. Use of lossless JPEG is
 generally not recommended.
 
-Use the \fB-quality\fP option to set the compression level to be used by
-JPEG, PNG, MIFF, and MPEG encoders. Use the \fB-sampling-factor\fP
-option to set the sampling factor to be used by the DPX, JPEG, MPEG, and
-YUV encoders for downsampling the chroma channels.
+Use the \fB-quality\fP option to set the compression level to be used
+by the JPEG, JPEG-2000, PNG, MIFF, MPEG, and TIFF encoders. Use the
+\fB-sampling-factor\fP option to set the sampling factor to be used
+by the DPX, JPEG, MPEG, and YUV encoders for downsampling the chroma
+channels.
 .TP
 .B "-contrast"
 \fRenhance or reduce the image contrast
@@ -1220,7 +1222,7 @@ type implied by the DPX header (if any).
 .in 20
 DPX samples are output within 32-bit words. They may be tightly
 packed end-to-end within the words ("packed"), padded with null bits to
-the right of the sample ("a" or "lsbpad), or padded with null bits to the
+the right of the sample ("a" or "lsbpad"), or padded with null bits to the
 left of the sample ("b" or "msbpad"). This option only has an effect for
 sample sizes of 10 or 12 bits. If samples are not packed, the DPX
 standard recommends type A padding. Many DPX readers demand a sample size
@@ -1297,11 +1299,31 @@ Enables or disables fancy upsampling when reading a JPEG file
 
 .in 15
 .in 15
-.B "jpeg:optimize-coding={true|false}"
+.B "jpeg:max-scan-number=<value>"
+.in 20
+ \fR
+.in 20
+Specifies an integer value for the maximum number of progressive
+scans allowed in a JPEG file.  The default maximum is 100 scans.  This
+limit is imposed due to a weakness in the JPEG standard which allows
+small JPEG files to take many minutes or hours to be read.
+
+.in 15
+.in 15
+.B "jpeg:max-warnings=<value>"
 .in 20
  \fR
 .in 20
+Specifies an integer value for how many warnings are allowed for
+any given error type before being promoted to a hard error.  JPEG
+files producing excessive warnings indicate a problem with the file.
 
+.in 15
+.in 15
+.B "jpeg:optimize-coding={true|false}"
+.in 20
+ \fR
+.in 20
 Selects if huffman encoding should be used. Huffman encoding is enabled
 by default, but may be disabled for very large images since it encoding
 requires that the entire image be buffered in memory. Huffman encoding
@@ -1333,6 +1355,17 @@ requested to scale the image to fit the page size (width and/or
 height).
 .in 15
 .in 15
+.B "mng:maximum-loops=<value>"
+.in 20
+ \fR
+.in 20
+mng:maximum-loops specifies the maximum number of loops allowed to
+be specified by a MNG LOOP chunk. Without an imposed limit, a MNG file
+could request up to 2147483647 loops, which could run for a very long
+time.  The current default limit is 512 loops.
+
+.in 15
+.in 15
 .B "pdf:use-cropbox={true|false}"
 .in 20
  \fR
@@ -1363,6 +1396,17 @@ imagemask operator instead of the image operator.
 
 .in 15
 .in 15
+.B "ptif:minimum-geometry=<geometry>"
+.in 20
+ \fR
+.in 20
+If the ptif:minimum-geometry key is defined, GraphicsMagick will
+use it to determine the minimum frame size to output when writing a
+pyramid TIFF file (a TIFF file containing a succession of reduced
+versions of the first frame). The default minimum geometry is 32x32.
+
+.in 15
+.in 15
 .B "tiff:alpha={unspecified|associated|unassociated}"
 .in 20
  \fR
@@ -1568,6 +1612,30 @@ Enables tiled TIFF if it has not already been enabled.
 
 .in 15
 .in 15
+.B "tiff:webp-lossless={TRUE|FALSE}"
+.in 20
+ \fR
+.in 20
+Specify a value of \fBTRUE\fP to enable lossless mode while
+writing WebP-compressed TIFF files. The WebP \fBwebp:lossless\fP
+option may also be used.  The quality factor set by the
+\fB-quality\fP option may be used to influence the level of effort
+expended while compressing.
+
+.in 15
+.in 15
+.B "tiff:zstd-compress-level=<value>"
+.in 20
+ \fR
+.in 20
+Specify the compression level to use while writing Zstd-compressed
+TIFF files. The valid range is 1 to 22. If this define is not
+specified, then the 'quality' value is used such that the default
+quality setting of 75 is translated to a compress level of 9 such that
+\'quality' has a useful range of 10-184 if used for this purpose.
+
+.in 15
+.in 15
 .B "webp:lossless={true|false}"
 .in 20
  \fR
@@ -3512,12 +3580,21 @@ first, e.g., with the "-gamma 0.45455" option.
 \fRoutput files to directory
 
 Use -output-directory to specify a directory under which to write the
-output files. Normally mogrify overwrites the input files but with this
-option the output files may be written to a different directory so that
-the input files are preserved. The algorithm used preserves all of the
-input path specification in the output path so that the user-specified
-input path (including any directory part) is appended to the output path.
-The user is responsible for creating the output directory.
+output files. Normally mogrify overwrites the input files, but with
+this option the output files may be written to a different directory
+tree so that the input files are preserved. The algorithm used
+preserves all of the input path specification in the output path so
+that the user-specified input path (including any sub-directory part)
+is appended to the output path. If the input file lacks an extension,
+then a suitable extension is automatically added to the output file.
+The user is responsible for creating the output directory specified as
+an argument, but subdirectories will be created as needed if the
+\fB-create-directories\fP option is supplied.  This option may be
+used to apply transformations on files from one directory and write
+the transformed files to a different directory.  In conjunction with
+\fB-create-directories\fP, this option is designed to support
+transforming whole directory trees of files provided that the relative
+path of the input file is included as part the list of filenames.
 .TP
 .B "-orient \fI<orientation>"\fP
 \fRSet the image orientation attribute
@@ -3819,7 +3896,7 @@ When writing a JNG image with transparency, two quality values are required,
 one for the main image and one for the grayscale image that conveys the
 opacity channel.  These are written as a single integer equal to the main
 image quality plus 1000 times the opacity quality.  For example, if you
-want to use quality 75 for the main image and quality 90 to compress 
+want to use quality 75 for the main image and quality 90 to compress
 the opacity data, use -quality 90075.
 
 For the PNM family of formats (PNM, PGM, and PPM) specify a quality
@@ -3827,6 +3904,14 @@ factor of zero in order to obtain the ASCII variant of the format. Note
 that -compress \fInone\fP used to be used to trigger ASCII output but
 provided the opposite result of what was expected as compared with other
 formats.
+
+For the TIFF format, the JPEG, WebP, Zip, and Zstd compression
+algorithms are influenced by the quality value.  JPEG and WebP provide
+lossy compression so higher quality produces a larger file with less
+degradation.  The Zip and Zstd compression algorithms (and WebP in
+lossless mode) are lossless and for these algorithms a higher
+\'quality' means to work harder to produce a smaller file, but with no
+difference in image quality.
 .TP
 .B "-raise \fI<width>x<height>"\fP
 \fRlighten or darken image edges
@@ -10430,35 +10515,35 @@ software was configured and the host system.
 .SH EXAMPLES
 To display the version information:
 
-  % gm -version
-  GraphicsMagick 1.3.19 2013-12-31 Q16 http://www.GraphicsMagick.org/
-  Copyright (C) 2002-2013 GraphicsMagick Group.
+  GraphicsMagick 1.3.27a 2017-12-11 Q16 http://www.GraphicsMagick.org/
+  Copyright (C) 2002-2017 GraphicsMagick Group.
   Additional copyrights and licenses apply to this software.
   See http://www.GraphicsMagick.org/www/Copyright.html for details.
   Feature Support:
-    Thread Safe              yes
+    Native Thread Safe       yes
     Large Files (> 32 bit)   yes
-    Large Memory (> 32 bit)  no
+    Large Memory (> 32 bit)  yes
     BZIP                     yes
     DPS                      no
     FlashPix                 no
     FreeType                 yes
     Ghostscript (Library)    no
-    JBIG                     no
+    JBIG                     yes
     JPEG-2000                yes
     JPEG                     yes
     Little CMS               yes
     Loadable Modules         no
-    OpenMP                   yes (201107)
+    OpenMP                   yes (201307)
     PNG                      yes
     TIFF                     yes
     TRIO                     no
-    UMEM                     yes
-    WMF                      no
+    UMEM                     no
+    WebP                     yes
+    WMF                      yes
     X11                      yes
     XML                      yes
     ZLIB                     yes
-  Host type: i386-pc-solaris2.11
+  Host type: x86_64-unknown-linux-gnu
   Configured using the command:
     ./configure  ...
   Final Build Parameters:
index 4ff58a6..b9ffa0c 100755 (executable)
@@ -17,7 +17,7 @@ PACKAGE_BUGREPORT='graphicsmagick-bugs@lists.sourceforge.net'
 
 # Package base version.  This is is the numeric version suffix applied to
 # PACKAGE_NAME (e.g. "1.2").
-PACKAGE_VERSION='1.3.26'
+PACKAGE_VERSION='1.3.31'
 
 #
 # Package name plus version string.
@@ -27,7 +27,7 @@ PACKAGE_STRING="$PACKAGE_NAME $PACKAGE_VERSION"
 #
 # Formal Package release date
 # Set to string "unreleased" if package is not a formal release.
-PACKAGE_RELEASE_DATE="2017-07-04"
+PACKAGE_RELEASE_DATE="2018-11-17"
 #PACKAGE_RELEASE_DATE="unreleased"
 
 #
@@ -50,7 +50,7 @@ fi
 #
 # Mercurial branch that this release is on.
 #
-HG_BRANCH_TAG=default
+HG_BRANCH_TAG=GraphicsMagick-1_3
 
 #
 # Libtool library revision control info
@@ -86,21 +86,20 @@ HG_BRANCH_TAG=default
 #
 # Magick library versioning
 #
-MAGICK_LIBRARY_CURRENT=19
-
+MAGICK_LIBRARY_CURRENT=22
 MAGICK_LIBRARY_REVISION=0
-MAGICK_LIBRARY_AGE=16
+MAGICK_LIBRARY_AGE=19
 
 #
 # Magick++ library versioning
 #
-MAGICK_PLUS_PLUS_LIBRARY_CURRENT=14
+MAGICK_PLUS_PLUS_LIBRARY_CURRENT=16
 MAGICK_PLUS_PLUS_LIBRARY_REVISION=0
-MAGICK_PLUS_PLUS_LIBRARY_AGE=2
+MAGICK_PLUS_PLUS_LIBRARY_AGE=4
 
 #
 # Magick Wand library versioning
 #
-MAGICK_WAND_LIBRARY_CURRENT=10
-MAGICK_WAND_LIBRARY_REVISION=0
-MAGICK_WAND_LIBRARY_AGE=8
+MAGICK_WAND_LIBRARY_CURRENT=11
+MAGICK_WAND_LIBRARY_REVISION=1
+MAGICK_WAND_LIBRARY_AGE=9
index aded420..a0fcb4e 100644 (file)
@@ -4,7 +4,7 @@
 .SH NAME
 GraphicsMagickWand-config \- get information about the installed version of GraphicsMagick
 .SH SYNOPSIS
-.B GraphicsMagickWand-config 
+.B GraphicsMagickWand-config
 .B [--cflags]
 .B [--cppflags]
 .B [--exec-prefix]
@@ -26,8 +26,8 @@ use:
 .nf
   GraphicsMagickWand-config --version
 .fi
-  
-To compile a program that calls the 
+
+To compile a program that calls the
 .B GraphicsMagick Wand
 Application Programmer Interface, use:
 
@@ -38,7 +38,7 @@ Application Programmer Interface, use:
 .SH OPTIONS
 .TP
 .B --cflags
-Print the compiler flags that were used to compile 
+Print the compiler flags that were used to compile
 .BR libGraphicsMagick .
 .TP
 .B --cppflags
index 55a1347..b4d82fa 100644 (file)
@@ -246,33 +246,33 @@ static int MvgPrintf(DrawingWand *drawing_wand,const char *format,...)
     */
     {
       size_t
-               space_available;
-      
+                space_available;
+
       space_available=drawing_wand->mvg_alloc-drawing_wand->mvg_length-1;
       formatted_length = -1;
       if (space_available > 0)
-       {
-         
-         va_start(argp, format);
+        {
+
+          va_start(argp, format);
 #if defined(HAVE_VSNPRINTF)
-         formatted_length=vsnprintf(drawing_wand->mvg+drawing_wand->mvg_length,
-                                    (size_t) space_available,format,argp);
+          formatted_length=vsnprintf(drawing_wand->mvg+drawing_wand->mvg_length,
+                                     (size_t) space_available,format,argp);
 #else
-         formatted_length=vsprintf(drawing_wand->mvg+drawing_wand->mvg_length,
-                                   format,argp);
+          formatted_length=vsprintf(drawing_wand->mvg+drawing_wand->mvg_length,
+                                    format,argp);
 #endif
-         va_end(argp);
-       }
+          va_end(argp);
+        }
       if ((formatted_length < 0) || ((size_t) formatted_length > space_available))
-       {
-         ThrowException(&drawing_wand->exception,DrawError,
-                        UnableToPrint,format);
-       }
+        {
+          ThrowException(&drawing_wand->exception,DrawError,
+                         UnableToPrint,format);
+        }
       else
-       {
-         drawing_wand->mvg_length+=formatted_length;
-         drawing_wand->mvg_width+=formatted_length;
-       }
+        {
+          drawing_wand->mvg_length+=formatted_length;
+          drawing_wand->mvg_width+=formatted_length;
+        }
     }
     drawing_wand->mvg[drawing_wand->mvg_length]=0;
     if ((drawing_wand->mvg_length > 1) &&
@@ -305,7 +305,7 @@ static int MvgAutoWrapPrintf(DrawingWand *drawing_wand,const char *format,...)
   if (formatted_length < 0)
     {
       ThrowException(&drawing_wand->exception,DrawError,
-                    UnableToPrint,format);
+                     UnableToPrint,format);
     }
   else
     {
@@ -396,20 +396,20 @@ static void AdjustAffine(DrawingWand *drawing_wand,const AffineMatrix *affine)
 %
 */
 WandExport DrawingWand *CloneDrawingWand(const DrawingWand *drawing_wand)
-{  
+{
   DrawingWand
     *clone_wand;
 
   ExceptionInfo
     exeption_info;
-  
+
   assert(drawing_wand != (DrawingWand *) NULL);
   assert(drawing_wand->signature == MagickSignature);
-  
+
   clone_wand=MagickAllocateMemory(DrawingWand *,sizeof(*clone_wand));
   if (clone_wand == (DrawingWand *) NULL)
     MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
-                     UnableToAllocateDrawingWand);
+                      UnableToAllocateDrawingWand);
 
   GetExceptionInfo(&exeption_info);
   (void) memcpy(clone_wand,drawing_wand,sizeof(*clone_wand));
@@ -418,25 +418,25 @@ WandExport DrawingWand *CloneDrawingWand(const DrawingWand *drawing_wand)
   clone_wand->mvg=(char *) NULL;
   clone_wand->pattern_id=(char *) NULL;
   clone_wand->graphic_context=(DrawInfo **) NULL;
-  
+
   clone_wand->own_image=MagickTrue;
   if (drawing_wand->image != (Image *) NULL)
     {
       clone_wand->image=CloneImage(drawing_wand->image,0,0,MagickTrue,
-                                  &exeption_info);
+                                   &exeption_info);
       if (clone_wand->image == (Image *) NULL)
-       goto clone_drawing_wand_fail;
+        goto clone_drawing_wand_fail;
     }
-  
+
   if (drawing_wand->mvg)
     {
       clone_wand->mvg=MagickAllocateMemory(char *,drawing_wand->mvg_alloc);
       if (clone_wand->mvg == (char *) NULL)
-       {
-         ThrowException3(&exeption_info,ResourceLimitError,
-                         MemoryAllocationFailed,UnableToCloneDrawingWand);
-         goto clone_drawing_wand_fail;
-       }
+        {
+          ThrowException3(&exeption_info,ResourceLimitError,
+                          MemoryAllocationFailed,UnableToCloneDrawingWand);
+          goto clone_drawing_wand_fail;
+        }
       (void) memcpy(clone_wand->mvg,drawing_wand->mvg,drawing_wand->mvg_length+1);
     }
 
@@ -446,28 +446,28 @@ WandExport DrawingWand *CloneDrawingWand(const DrawingWand *drawing_wand)
   if (drawing_wand->graphic_context != (DrawInfo **) NULL)
     {
       clone_wand->graphic_context=MagickAllocateArray(DrawInfo **,
-                                                     drawing_wand->index+1,
-                                                     sizeof(DrawInfo *));
+                                                      drawing_wand->index+1,
+                                                      sizeof(DrawInfo *));
       if (clone_wand->graphic_context == (DrawInfo **) NULL)
-       {
-         ThrowException3(&exeption_info,ResourceLimitError,
-                         MemoryAllocationFailed,UnableToCloneDrawingWand);
-         goto clone_drawing_wand_fail;
-       }
+        {
+          ThrowException3(&exeption_info,ResourceLimitError,
+                          MemoryAllocationFailed,UnableToCloneDrawingWand);
+          goto clone_drawing_wand_fail;
+        }
       (void) memset(clone_wand->graphic_context,0,
-                   (drawing_wand->index+1)*sizeof(DrawInfo *));
+                    (drawing_wand->index+1)*sizeof(DrawInfo *));
 
       for (clone_wand->index=0; clone_wand->index <= drawing_wand->index; clone_wand->index++)
-       {
-         clone_wand->graphic_context[clone_wand->index]=
-           CloneDrawInfo((ImageInfo*)NULL,drawing_wand->graphic_context[clone_wand->index]);
-         if (clone_wand->graphic_context[clone_wand->index] == (DrawInfo*) NULL)
-           {
-             ThrowException3(&exeption_info,ResourceLimitError,
-                             MemoryAllocationFailed,UnableToCloneDrawingWand);
-             goto clone_drawing_wand_fail;
-           }
-       }
+        {
+          clone_wand->graphic_context[clone_wand->index]=
+            CloneDrawInfo((ImageInfo*)NULL,drawing_wand->graphic_context[clone_wand->index]);
+          if (clone_wand->graphic_context[clone_wand->index] == (DrawInfo*) NULL)
+            {
+              ThrowException3(&exeption_info,ResourceLimitError,
+                              MemoryAllocationFailed,UnableToCloneDrawingWand);
+              goto clone_drawing_wand_fail;
+            }
+        }
       clone_wand->index=drawing_wand->index;
     }
 
@@ -482,11 +482,11 @@ clone_drawing_wand_fail:
   if (clone_wand->graphic_context != (DrawInfo **) NULL)
     {
       for ( ; clone_wand->index >= 0; clone_wand->index--)
-       {
-         if (clone_wand->graphic_context[clone_wand->index] != (DrawInfo*) NULL)
-           DestroyDrawInfo(clone_wand->graphic_context[clone_wand->index]);
-         clone_wand->graphic_context[clone_wand->index]=(DrawInfo*) NULL;
-       }
+        {
+          if (clone_wand->graphic_context[clone_wand->index] != (DrawInfo*) NULL)
+            DestroyDrawInfo(clone_wand->graphic_context[clone_wand->index]);
+          clone_wand->graphic_context[clone_wand->index]=(DrawInfo*) NULL;
+        }
       MagickFreeMemory(clone_wand->graphic_context);
     }
   (void) memset(clone_wand,0,sizeof(*clone_wand));
@@ -538,11 +538,11 @@ WandExport void DestroyDrawingWand(DrawingWand *drawing_wand)
   if (drawing_wand->graphic_context != (DrawInfo **) NULL)
     {
       for ( ; drawing_wand->index >= 0; drawing_wand->index--)
-       {
-         if (drawing_wand->graphic_context[drawing_wand->index] != (DrawInfo*) NULL)
-           DestroyDrawInfo(drawing_wand->graphic_context[drawing_wand->index]);
-         drawing_wand->graphic_context[drawing_wand->index]=(DrawInfo*) NULL;
-       }
+        {
+          if (drawing_wand->graphic_context[drawing_wand->index] != (DrawInfo*) NULL)
+            DestroyDrawInfo(drawing_wand->graphic_context[drawing_wand->index]);
+          drawing_wand->graphic_context[drawing_wand->index]=(DrawInfo*) NULL;
+        }
       MagickFreeMemory(drawing_wand->graphic_context);
     }
 
@@ -851,10 +851,12 @@ WandExport MagickBool DrawClearException(DrawingWand *drawing_wand)
 */
 WandExport char *DrawGetClipPath(const DrawingWand *drawing_wand)
 {
+  char * pClipPath ;
   assert(drawing_wand != (const DrawingWand *) NULL);
   assert(drawing_wand->signature == MagickSignature);
-  if (CurrentContext->clip_path != (char *) NULL)
-    return((char *) AcquireString(CurrentContext->clip_path));
+  pClipPath = *DrawInfoGetClipPath(CurrentContext);
+  if (pClipPath != (char *) NULL)
+    return((char *) AcquireString(pClipPath));
   return((char *) NULL);
 }
 \f
@@ -887,14 +889,16 @@ WandExport char *DrawGetClipPath(const DrawingWand *drawing_wand)
 WandExport void DrawSetClipPath(DrawingWand *drawing_wand,
   const char *clip_path)
 {
+  char **ppClipPath,*pClipPath;
   assert(drawing_wand != (DrawingWand *) NULL);
   assert(drawing_wand->signature == MagickSignature);
   assert(clip_path != (const char *) NULL);
-  if ((CurrentContext->clip_path == NULL) || drawing_wand->filter_off ||
-      LocaleCompare(CurrentContext->clip_path,clip_path) != 0)
+  pClipPath = *(ppClipPath = DrawInfoGetClipPath(CurrentContext));
+  if ((pClipPath == NULL) || drawing_wand->filter_off ||
+      LocaleCompare(pClipPath,clip_path) != 0)
     {
-      (void) CloneString(&CurrentContext->clip_path,clip_path);
-      if (CurrentContext->clip_path == (char*)NULL)
+      (void) CloneString(ppClipPath,clip_path);
+      if (*ppClipPath == (char*)NULL)
         ThrowException3(&drawing_wand->exception,ResourceLimitError,
           MemoryAllocationFailed,UnableToDrawOnImage);
       (void) MvgPrintf(drawing_wand,"clip-path url(#%s)\n",clip_path);
@@ -1040,12 +1044,12 @@ WandExport ClipPathUnits DrawGetClipUnits(const DrawingWand *drawing_wand)
 %
 */
 WandExport char *DrawGetException(const DrawingWand *drawing_wand,
-                                 ExceptionType *severity)
+                                  ExceptionType *severity)
 {
   char
     buffer[MaxTextExtent],
     *description;
-  
+
   assert(drawing_wand != (const DrawingWand *) NULL);
   assert(drawing_wand->signature == MagickSignature);
   assert(drawing_wand->exception.signature == MagickSignature);
@@ -1056,12 +1060,12 @@ WandExport char *DrawGetException(const DrawingWand *drawing_wand,
   if (drawing_wand->exception.severity != UndefinedException)
     {
       if (drawing_wand->exception.description)
-       FormatString(buffer,"%.1024s (%.1024s)",
-                    drawing_wand->exception.reason,
-                    drawing_wand->exception.description);
+        FormatString(buffer,"%.1024s (%.1024s)",
+                     drawing_wand->exception.reason,
+                     drawing_wand->exception.description);
       else
-       FormatString(buffer,"%.1024s",
-                    drawing_wand->exception.reason);
+        FormatString(buffer,"%.1024s",
+                     drawing_wand->exception.reason);
       CloneString(&description,buffer);
     }
 
index 9d37135..ffedbad 100644 (file)
@@ -250,18 +250,18 @@ extern WandExport char
   *DrawGetTextEncoding(const DrawingWand *);
 
 extern WandExport ClipPathUnits
-  DrawGetClipUnits(const DrawingWand *);
+  DrawGetClipUnits(const DrawingWand *) MAGICK_FUNC_PURE;
 
 extern WandExport DecorationType
-  DrawGetTextDecoration(const DrawingWand *);
+  DrawGetTextDecoration(const DrawingWand *) MAGICK_FUNC_PURE;
 
 extern WandExport double
-  DrawGetFillOpacity(const DrawingWand *),
-  DrawGetFontSize(const DrawingWand *),
+  DrawGetFillOpacity(const DrawingWand *) MAGICK_FUNC_PURE,
+  DrawGetFontSize(const DrawingWand *) MAGICK_FUNC_PURE,
   *DrawGetStrokeDashArray(const DrawingWand *,unsigned long *),
-  DrawGetStrokeDashOffset(const DrawingWand *),
-  DrawGetStrokeOpacity(const DrawingWand *),
-  DrawGetStrokeWidth(const DrawingWand *);
+  DrawGetStrokeDashOffset(const DrawingWand *) MAGICK_FUNC_PURE,
+  DrawGetStrokeOpacity(const DrawingWand *) MAGICK_FUNC_PURE,
+  DrawGetStrokeWidth(const DrawingWand *) MAGICK_FUNC_PURE;
 
 extern WandExport DrawInfo
   *DrawPeekGraphicContext(const DrawingWand *);
@@ -272,33 +272,33 @@ extern WandExport DrawingWand
   *NewDrawingWand(void);
 
 extern WandExport FillRule
-  DrawGetClipRule(const DrawingWand *),
-  DrawGetFillRule(const DrawingWand *);
+  DrawGetClipRule(const DrawingWand *) MAGICK_FUNC_PURE,
+  DrawGetFillRule(const DrawingWand *) MAGICK_FUNC_PURE;
 
 extern WandExport GravityType
-  DrawGetGravity(const DrawingWand *);
+  DrawGetGravity(const DrawingWand *) MAGICK_FUNC_PURE;
 
 extern WandExport LineCap
-  DrawGetStrokeLineCap(const DrawingWand *);
+  DrawGetStrokeLineCap(const DrawingWand *) MAGICK_FUNC_PURE;
 
 extern WandExport LineJoin
-  DrawGetStrokeLineJoin(const DrawingWand *);
+  DrawGetStrokeLineJoin(const DrawingWand *) MAGICK_FUNC_PURE;
 
 extern WandExport StretchType
-  DrawGetFontStretch(const DrawingWand *);
+  DrawGetFontStretch(const DrawingWand *) MAGICK_FUNC_PURE;
 
 extern WandExport StyleType
-  DrawGetFontStyle(const DrawingWand *);
+  DrawGetFontStyle(const DrawingWand *) MAGICK_FUNC_PURE;
 
 extern WandExport unsigned int
   DrawClearException(DrawingWand *),
-  DrawGetStrokeAntialias(const DrawingWand *),
-  DrawGetTextAntialias(const DrawingWand *),
+  DrawGetStrokeAntialias(const DrawingWand *) MAGICK_FUNC_PURE,
+  DrawGetTextAntialias(const DrawingWand *) MAGICK_FUNC_PURE,
   DrawRender(const DrawingWand *) MAGICK_ATTRIBUTE ((deprecated)); /* Use MagickDrawImage() instead */
 
 extern WandExport unsigned long
-  DrawGetFontWeight(const DrawingWand *),
-  DrawGetStrokeMiterLimit(const DrawingWand *);
+  DrawGetFontWeight(const DrawingWand *) MAGICK_FUNC_PURE,
+  DrawGetStrokeMiterLimit(const DrawingWand *) MAGICK_FUNC_PURE;
 
 extern WandExport void
   DrawAffine(DrawingWand *,const AffineMatrix *),
index 3e824d6..b181abc 100644 (file)
@@ -30,7 +30,7 @@ ScribbleImage (MagickWand *canvas)
   DrawPushGraphicContext(draw_wand);
   {
     DrawSetViewbox(draw_wand,0,0,MagickGetImageWidth(canvas),
-                  MagickGetImageHeight(canvas));
+                   MagickGetImageHeight(canvas));
     DrawScale(draw_wand,1.101,1.08);
     DrawTranslate(draw_wand,-23.69,-22.97);
     DrawRotate(draw_wand,0);
@@ -59,11 +59,11 @@ ScribbleImage (MagickWand *canvas)
       DrawPopClipPath(draw_wand);
     }
     DrawPopDefs(draw_wand);
-    
+
     DrawPushGraphicContext(draw_wand);
     {
       DrawSetClipPath(draw_wand, "url(#clip_1)");
-      
+
       DrawPushGraphicContext(draw_wand);
       {
         DrawSetStrokeAntialias(draw_wand,MagickTrue);
@@ -79,7 +79,7 @@ ScribbleImage (MagickWand *canvas)
         DrawRectangle(draw_wand,72,72,144,144);
       }
       DrawPopGraphicContext(draw_wand);
-      
+
       DrawPushGraphicContext(draw_wand);
       {
         DrawSetStrokeAntialias(draw_wand,MagickTrue);
@@ -95,7 +95,7 @@ ScribbleImage (MagickWand *canvas)
         DrawRoundRectangle(draw_wand,72,216,360,432,9,9);
       }
       DrawPopGraphicContext(draw_wand);
-      
+
       DrawPushGraphicContext(draw_wand);
       {
         const PointInfo points[37] =
@@ -111,7 +111,7 @@ ScribbleImage (MagickWand *canvas)
           { 346,114.8 },   { 347.1,111.5 }, { 348.9,108.5 }, { 351.4,105.8 },
           { 378.1,81.72 }
         };
-        
+
         DrawSetStrokeAntialias(draw_wand,MagickTrue);
         DrawSetStrokeWidth(draw_wand,2.016);
         DrawSetStrokeLineCap(draw_wand,RoundCap);
@@ -125,7 +125,7 @@ ScribbleImage (MagickWand *canvas)
         DrawPolygon(draw_wand,37,points);
       }
       DrawPopGraphicContext(draw_wand);
-      
+
       DrawPushGraphicContext(draw_wand);
       {
         DrawSetStrokeAntialias(draw_wand,MagickTrue);
@@ -141,7 +141,7 @@ ScribbleImage (MagickWand *canvas)
         DrawEllipse(draw_wand,489.6,424.8,72,129.6,0,360);
       }
       DrawPopGraphicContext(draw_wand);
-      
+
       DrawPushGraphicContext(draw_wand);
       {
         const PointInfo points[48] =
@@ -159,7 +159,7 @@ ScribbleImage (MagickWand *canvas)
           { 204,55.3 },    { 204.3,44.35 }, { 204.9,39.6 },  { 205.9,35.42 },
           { 207.4,31.82 }, { 209.2,28.87 }, { 211.3,26.64},  { 213.8,25.13 }
         };
-        
+
         DrawSetStrokeAntialias(draw_wand,MagickTrue);
         DrawSetStrokeWidth(draw_wand,3.024);
         DrawSetStrokeLineCap(draw_wand,RoundCap);
@@ -173,7 +173,7 @@ ScribbleImage (MagickWand *canvas)
         DrawPolygon(draw_wand,48,points);
       }
       DrawPopGraphicContext(draw_wand);
-      
+
       DrawPushGraphicContext(draw_wand);
       {
         DrawSetStrokeAntialias(draw_wand,MagickTrue);
@@ -212,7 +212,7 @@ ScribbleImage (MagickWand *canvas)
           { 180,504 }, { 282.7,578.6 }, { 243.5,699.4 }, { 116.5,699.4 },
           { 77.26,578.6 }, { 180,504 }
         };
-        
+
         DrawSetStrokeAntialias(draw_wand,MagickTrue);
         DrawSetStrokeWidth(draw_wand,9);
         DrawSetStrokeLineCap(draw_wand,RoundCap);
@@ -226,7 +226,7 @@ ScribbleImage (MagickWand *canvas)
         DrawPolygon(draw_wand,6,points);
       }
       DrawPopGraphicContext(draw_wand);
-      
+
       DrawPushGraphicContext(draw_wand);
       {
         const PointInfo points[11] =
@@ -235,7 +235,7 @@ ScribbleImage (MagickWand *canvas)
           { 243.5,699.4 }, { 180,666 },     { 116.5,699.4 }, { 128.7,628.7 },
           { 77.26,578.6 }, { 148.2,568.3 }, { 180,504 }
         };
-        
+
         DrawSetStrokeAntialias(draw_wand,MagickTrue);
         DrawSetStrokeWidth(draw_wand,9);
         DrawSetStrokeLineCap(draw_wand,RoundCap);
@@ -249,7 +249,7 @@ ScribbleImage (MagickWand *canvas)
         DrawPolygon(draw_wand,11,points);
       }
       DrawPopGraphicContext(draw_wand);
-      
+
       DrawPushGraphicContext(draw_wand);
       {
         const PointInfo points[15] =
@@ -259,7 +259,7 @@ ScribbleImage (MagickWand *canvas)
           { 525.6,93.6 },  { 496.8,158.4 }, { 532.8,136.8 }, { 518.4,180 },
           { 540,172.8 },   { 540,223.2 },   { 540,288 }
         };
-        
+
         DrawSetStrokeAntialias(draw_wand,MagickTrue);
         DrawSetStrokeWidth(draw_wand,5.976);
         DrawSetStrokeLineCap(draw_wand,RoundCap);
@@ -273,7 +273,7 @@ ScribbleImage (MagickWand *canvas)
         DrawPolygon(draw_wand,15,points);
       }
       DrawPopGraphicContext(draw_wand);
-      
+
       DrawPushGraphicContext(draw_wand);
       {
         const PointInfo points[7] =
@@ -281,7 +281,7 @@ ScribbleImage (MagickWand *canvas)
           { 57.6,640.8 }, { 57.6,784.8 }, { 194.4,799.2 }, { 259.2,777.6 },
           { 151.2,756 }, { 86.4,748.8 }, { 57.6,640.8 }
         };
-        
+
         DrawSetStrokeAntialias(draw_wand,MagickTrue);
         DrawSetStrokeWidth(draw_wand,5.976);
         DrawSetStrokeLineCap(draw_wand,RoundCap);
@@ -295,7 +295,7 @@ ScribbleImage (MagickWand *canvas)
         DrawPolygon(draw_wand,7,points);
       }
       DrawPopGraphicContext(draw_wand);
-      
+
       DrawPushGraphicContext(draw_wand);
       {
         const PointInfo points[193] =
@@ -314,7 +314,7 @@ ScribbleImage (MagickWand *canvas)
           { 428,531.2 },   { 434.6,532.9 }, { 436.7,533.8 }, { 437.8,534.9 },
           { 437.8,536.2 }, { 436.8,537.8 }, { 434.5,539.6 }, { 430.9,541.8 },
           { 419.3,547.6 }, { 401.3,555.2 }, { 342.4,577.9 }, {325.2,584.9 },
-          { 311,591.3 },   { 300,597.3 },   { 291.6,602.8 }, { 285.8,607.8 }, 
+          { 311,591.3 },   { 300,597.3 },   { 291.6,602.8 }, { 285.8,607.8 },
           { 282.3,612.3 }, { 281.4,614.4 }, { 280.9,616.2 }, { 281.2,619.6 },
           { 282.1,621.2 }, { 283.3,622.6 }, { 286.8,624.9 }, { 291.5,626.6 },
           { 297.1,627.8 }, { 303.6,628.3 }, { 310.5,628.3 }, { 317.9,627.6 },
@@ -350,7 +350,7 @@ ScribbleImage (MagickWand *canvas)
           { 27.86,597.4 }, { 27.29,595.2 }, { 26.64,588.7 }, { 26.86,578.8 },
           { 27.86,565.3 }
         };
-        
+
         DrawSetStrokeAntialias(draw_wand,MagickTrue);
         DrawSetStrokeWidth(draw_wand,5.904);
         DrawSetStrokeLineCap(draw_wand,RoundCap);
@@ -410,7 +410,7 @@ int main ( int argc, char **argv )
   if (MagickPass == status)
     if ((status = MagickReadImage( canvas, "xc:white" )) == MagickFail)
       printf ( "Failed to read canvas image %s\n", MagickGetFilename(canvas) );
-  
+
   /*
    * Scribble on image
    */
@@ -436,7 +436,7 @@ int main ( int argc, char **argv )
   if (MagickPass == status)
     if ((status = MagickWriteImage ( canvas, outfile )) == MagickFail)
       printf ( "Failed to write image file %s\n", outfile );
-  
+
   DestroyMagickWand( canvas );
   DestroyMagick();
 
index 9e6893a..b077568 100644 (file)
@@ -193,6 +193,9 @@ WandExport size_t CopyMagickString(char *destination,const char *source,
 */
 WandExport int FormatMagickStringList(char *string,const size_t length,
                                       const char *format,va_list operands)
+  MAGICK_ATTRIBUTE((__format__ (__printf__,3,0)));
+WandExport int FormatMagickStringList(char *string,const size_t length,
+                                      const char *format,va_list operands)
 {
   int
     count;
@@ -506,7 +509,7 @@ WandExport unsigned int ParseGeometry(const char *geometry,
         */
         GetExceptionInfo(&exception);
         image_info=CloneImageInfo((ImageInfo *) NULL);
-       (void) strlcpy(image_info->filename,geometry,sizeof(image_info->filename));
+        (void) strlcpy(image_info->filename,geometry,sizeof(image_info->filename));
         image=PingImage(image_info,&exception);
         if (image != (Image *) NULL)
           {
index e3df549..5dcc76f 100644 (file)
@@ -219,7 +219,7 @@ static MagickWand *CloneMagickWandWithImages(const MagickWand *wand,
   clone_wand=MagickAllocateMemory(MagickWand *,sizeof(MagickWand));
   if (clone_wand == (MagickWand *) NULL)
     MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
-                     UnableToAllocateWand);
+                      UnableToAllocateWand);
   (void) memset(clone_wand,0,sizeof(MagickWand));
   (void) MagickFormatString(clone_wand->id,MaxTextExtent,"MagickWand-%lu",
     GetMagickWandId());
@@ -1829,7 +1829,7 @@ WandExport char *MagickDescribeImage(MagickWand *wand)
   if ((file = AcquireTemporaryFileStream(filename, TextFileIOMode)) == (FILE *) NULL)
     {
       ThrowException(&wand->exception,FileOpenError,
-                    UnableToCreateTemporaryFile,filename);
+                     UnableToCreateTemporaryFile,filename);
     }
   else
     {
@@ -2227,9 +2227,9 @@ WandExport unsigned int MagickEqualizeImage(MagickWand *wand)
 %            on the new image.
 %
 */
-WandExport unsigned int 
+WandExport unsigned int
 MagickExtentImage(MagickWand *wand,const size_t width,const size_t height,
-                 const ssize_t x,const ssize_t y)
+                  const ssize_t x,const ssize_t y)
 {
   Image
     *extent_image;
@@ -2865,7 +2865,7 @@ WandExport MagickWand *MagickGetImage(MagickWand *wand)
 WandExport char *MagickGetImageAttribute(MagickWand *wand, const char *name)
 {
   const ImageAttribute
-         *attribute;
+          *attribute;
 
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == MagickSignature);
@@ -3031,8 +3031,8 @@ WandExport unsigned int MagickGetImageBorderColor(MagickWand *wand,
 */
 WandExport unsigned int
 MagickGetImageBoundingBox(MagickWand *wand,const double fuzz,
-                         unsigned long *width, unsigned long *height,
-                         long *x, long *y)
+                          unsigned long *width, unsigned long *height,
+                          long *x, long *y)
 {
   RectangleInfo
     rectangle;
@@ -3282,7 +3282,7 @@ WandExport unsigned int MagickGetImageChannelMean(MagickWand *wand,
     }
   deviation *= MaxRGBDouble;
   *standard_deviation = RoundDoubleToQuantum(deviation);
-  
+
   meanf *= MaxRGBDouble;
   *mean = RoundDoubleToQuantum(meanf);
 
@@ -4303,10 +4303,10 @@ WandExport unsigned char *MagickGetImageProfile(MagickWand *wand,
 
   const unsigned char
     *profile=0;
-  
+
   unsigned char
     *result=0;
-  
+
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == MagickSignature);
   *length=0;
@@ -5090,6 +5090,46 @@ WandExport MagickPassFail MagickHaldClutImage(MagickWand *wand,const MagickWand
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   M a g i c k H a s C o l o r M a p                                         %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  MagickHasColormap() returns True if the check was successful with the
+%  colormap parameter set to a boolean value indicating whether the current
+%  wand image uses a color map or not. Returns False if there are no wand
+%  images available.
+%
+%  The format of the MagickHasColormap method is:
+%
+%      unsigned int MagickHasColormap(MagickWand *wand,
+%        unsigned int *colormap)
+%
+%  A description of each parameter follows:
+%
+%    o wand: The magick wand.
+%
+%    o colormap: Set to True if current image uses a color map, False if not.
+%
+*/
+WandExport unsigned int MagickHasColormap(MagickWand *wand,
+  unsigned int *colormap)
+{
+  assert(wand != (MagickWand *) NULL);
+  assert(wand->signature == MagickSignature);
+  if (wand->images == (Image *) NULL)
+    ThrowWandException(WandError,WandContainsNoImages,wand->id);
+
+  *colormap = (wand->image->storage_class == PseudoClass ? True : False);
+  return(True);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   M a g i c k H a s N e x t I m a g e                                       %
 %                                                                             %
 %                                                                             %
@@ -5202,6 +5242,177 @@ WandExport unsigned int MagickImplodeImage(MagickWand *wand,const double amount)
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   M a g i c k I s G r a y I m a g e                                         %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  MagickIsGrayImage() returns True if the check was successful with the
+%  grayimage parameter set to a boolean value indicating whether the current
+%  wand image is a gray-scale image or not. Returns False if there was
+%  an error.
+%
+%  The format of the MagickIsGrayImage method is:
+%
+%      unsigned int MagickIsGrayImage(MagickWand *wand,
+%        unsigned int *grayimage)
+%
+%  A description of each parameter follows:
+%
+%    o wand: The magick wand.
+%
+%    o grayimage: Set to True if current image is a gray-scale image,
+%        False if not.
+%
+*/
+WandExport unsigned int MagickIsGrayImage(MagickWand *wand,
+  unsigned int *grayimage)
+{
+  assert(wand != (MagickWand *) NULL);
+  assert(wand->signature == MagickSignature);
+  assert(grayimage != (unsigned int *) NULL);
+  if (wand->images == (Image *) NULL)
+    ThrowWandException(WandError,WandContainsNoImages,wand->id);
+  MagickClearException(wand);
+  *grayimage = IsGrayImage(wand->image, &wand->exception);
+  return (wand->exception.severity == UndefinedException);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   M a g i c k I s M o n o c h r o m e I m a g e                             %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  MagickIsMonochromeImage() returns True if the check was successful with the
+%  monochrome parameter set to a boolean value indicating whether the current
+%  wand image is a monochrome image or not. Returns False if there was
+%  an error.
+%
+%  The format of the MagickIsMonochromeImage method is:
+%
+%      unsigned int MagickIsMonochromeImage(MagickWand *wand,
+%        unsigned int *monochrome)
+%
+%  A description of each parameter follows:
+%
+%    o wand: The magick wand.
+%
+%    o monochrome: Set to True if current image is a monochrome image,
+%        False if not.
+%
+*/
+WandExport unsigned int MagickIsMonochromeImage(MagickWand *wand,
+  unsigned int *monochrome)
+{
+  assert(wand != (MagickWand *) NULL);
+  assert(wand->signature == MagickSignature);
+  assert(monochrome != (unsigned int *) NULL);
+  if (wand->images == (Image *) NULL)
+    ThrowWandException(WandError,WandContainsNoImages,wand->id);
+  MagickClearException(wand);
+  *monochrome = IsMonochromeImage(wand->image, &wand->exception);
+  return (wand->exception.severity == UndefinedException);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   M a g i c k I s O p a q u e I m a g e                                     %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  MagickIsOpaqueImage() returns True if the check was successful with the
+%  opaque parameter set to a boolean value indicating whether the current
+%  wand image is entirely opaque or not. Returns False if there was
+%  an error.
+%
+%  The format of the MagickIsOpaqueImage method is:
+%
+%      unsigned int MagickIsOpaqueImage(MagickWand *wand,
+%        unsigned int *opaque)
+%
+%  A description of each parameter follows:
+%
+%    o wand: The magick wand.
+%
+%    o opaque: Set to True if current image is entirely opaque,
+%        False if not.
+%
+*/
+WandExport unsigned int MagickIsOpaqueImage(MagickWand *wand,
+  unsigned int *opaque)
+{
+  assert(wand != (MagickWand *) NULL);
+  assert(wand->signature == MagickSignature);
+  assert(opaque != (unsigned int *) NULL);
+  if (wand->images == (Image *) NULL)
+    ThrowWandException(WandError,WandContainsNoImages,wand->id);
+  MagickClearException(wand);
+  *opaque = IsOpaqueImage(wand->image, &wand->exception);
+  return (wand->exception.severity == UndefinedException);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%   M a g i c k I s P a l e t t e I m a g e                                   %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  MagickIsPaletteImage() returns True if the check was successful with the
+%  palette parameter set to a boolean value indicating whether the current
+%  wand image is an image with 256 unique colors or less. Returns False if
+%  there was an error. Note that a palette image does not necessarily use a
+%  colormap. See MagickHasColormap() if needing to determine whether a
+%  colormap is in use.
+%
+%
+%  The format of the MagickIsPaletteImage method is:
+%
+%      unsigned int MagickIsPaletteImage(MagickWand *wand,
+%        unsigned int *palette)
+%
+%  A description of each parameter follows:
+%
+%    o wand: The magick wand.
+%
+%    o palette: Set to True if current image is 256 colors or less,
+%        False if not.
+%
+*/
+WandExport unsigned int MagickIsPaletteImage(MagickWand *wand,
+  unsigned int *palette)
+{
+  assert(wand != (MagickWand *) NULL);
+  assert(wand->signature == MagickSignature);
+  assert(palette != (unsigned int *) NULL);
+  if (wand->images == (Image *) NULL)
+    ThrowWandException(WandError,WandContainsNoImages,wand->id);
+  MagickClearException(wand);
+  *palette = IsPaletteImage(wand->image, &wand->exception);
+  return (wand->exception.severity == UndefinedException);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   M a g i c k L a b e l I m a g e                                           %
 %                                                                             %
 %                                                                             %
@@ -6977,7 +7188,7 @@ WandExport unsigned int MagickReadImageBlob(MagickWand *wand,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-%  MagickReadImageFile() reads an image or image sequence from an open file 
+%  MagickReadImageFile() reads an image or image sequence from an open file
 %  descriptor.
 %
 %  The format of the MagickReadImageFile method is:
@@ -7648,20 +7859,20 @@ WandExport unsigned int MagickSeparateImageChannel(MagickWand *wand,
 %  -sampling-factor option to specify the factors for chroma
 %  downsampling.  To use the same quality value as that found by the
 %  JPEG decoder, use the -define jpeg:preserve-settings flag.
-% 
+%
 %  For the MIFF image format, and the TIFF format while using ZIP
 %  compression, quality/10 is the zlib compres- sion level, which is 0
 %  (worst but fastest compression) to 9 (best but slowest). It has no
 %  effect on the image appearance, since the compression is always
 %  lossless.
-% 
+%
 %  For the JPEG-2000 image format, quality is mapped using a non-linear
 %  equation to the compression ratio required by the Jasper library.
 %  This non-linear equation is intended to loosely approximate the
 %  quality provided by the JPEG v1 format.  The default quality value 75
 %  results in a request for 16:1 compression. The quality value 100
 %  results in a request for non-lossy compres- sion.
-% 
+%
 %  For the MNG and PNG image formats, the quality value sets the zlib
 %  compression level (quality / 10) and filter-type (quality % 10).
 %  Compression levels range from 0 (fastest compression) to 100 (best
@@ -7669,38 +7880,38 @@ WandExport unsigned int MagickSeparateImageChannel(MagickWand *wand,
 %  used, which is fastest but not necessarily the worst compression.  If
 %  filter-type is 4 or less, the specified filter-type is used for all
 %  scanlines:
-% 
+%
 %       0) none
 %       1) sub
 %       2) up
 %       3) average
 %       4) Paeth
-% 
+%
 %  If filter-type is 5, adaptive filtering is used when quality is
 %  greater than 50 and the image does not have a color map, otherwise no
 %  filtering is used.
-% 
+%
 %  If filter-type is 6, adaptive filtering with minimum-
 %  sum-of-absolute-values is used.
-% 
+%
 %  Only if the output is MNG, if filter-type is 7, the LOCO color
 %  transformation and adaptive filtering with
 %  minimum-sum-of-absolute-values are used.
-% 
+%
 %  The default is quality is 75, which means nearly the best compression
 %  with adaptive filtering.  The quality setting has no effect on the
 %  appearance of PNG and MNG images, since the compression is always
 %  lossless.
-% 
+%
 %  For further information, see the PNG specification.
-% 
+%
 %  When writing a JNG image with transparency, two quality values are
 %  required, one for the main image and one for the grayscale image that
 %  conveys the opacity channel.  These are written as a single integer
 %  equal to the main image quality plus 1000 times the opacity quality.
 %  For example, if you want to use quality 75 for the main image and
 %  quality 90 to compress the opacity data, use -quality 90075.
-% 
+%
 %  For the PNM family of formats (PNM, PGM, and PPM) specify a quality
 %  factor of zero in order to obtain the ASCII variant of the
 %  format. Note that -compress none used to be used to trigger ASCII
@@ -7903,11 +8114,11 @@ WandExport unsigned int MagickSetImage(MagickWand *wand,
 %    o value: The value of the attribute
 %
 */
-WandExport unsigned int MagickSetImageAttribute(MagickWand *wand, const char *name, 
+WandExport unsigned int MagickSetImageAttribute(MagickWand *wand, const char *name,
   const char *value)
 {
   unsigned int status;
-  
+
   assert(wand != (MagickWand *) NULL);
   assert(wand->signature == MagickSignature);
   if (wand->images == (Image *) NULL)
@@ -8496,7 +8707,7 @@ WandExport unsigned int MagickSetImageGamma(MagickWand *wand,const double gamma)
  %                                                                             %
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %
- %  MagickSetImageGeometry() sets the image geometry string. 
+ %  MagickSetImageGeometry() sets the image geometry string.
  %
  %  The format of the MagickSetImageGeometry method is:
  %
@@ -9470,7 +9681,7 @@ WandExport unsigned int MagickSetInterlaceScheme(MagickWand *wand,
 */
 WandExport unsigned int
 MagickSetResolution(MagickWand *wand,
-                   const double x_resolution,const double y_resolution)
+                    const double x_resolution,const double y_resolution)
 {
   char
     geometry[MaxTextExtent];
@@ -10736,7 +10947,7 @@ WandExport unsigned int MagickWriteImage(MagickWand *wand,const char *filename)
 %
 */
 WandExport unsigned int MagickWriteImagesFile(MagickWand *wand,FILE * file,
-                                             const unsigned int adjoin)
+                                              const unsigned int adjoin)
 {
   ImageInfo
     *write_info;
@@ -10941,7 +11152,7 @@ WandExport MagickWand *NewMagickWand(void)
   wand=MagickAllocateMemory(MagickWand *,sizeof(MagickWand));
   if (wand == (MagickWand *) NULL)
     MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
-                     UnableToAllocateWand);
+                      UnableToAllocateWand);
   (void) memset(wand,0,sizeof(MagickWand));
   (void) MagickFormatString(wand->id,MaxTextExtent,"MagickWand-%lu",
     GetMagickWandId());
index 41877d6..4277605 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003-2016 GraphicsMagick Group */
+/* Copyright (C) 2003-2018 GraphicsMagick Group */
 
 /*
   ImageMagick MagickWand interface.
@@ -54,7 +54,7 @@ typedef struct _MagickWand
 
 extern WandExport char
   *MagickDescribeImage(MagickWand *),
-  *MagickGetConfigureInfo(MagickWand *,const char *),
+  *MagickGetConfigureInfo(MagickWand *,const char *) MAGICK_FUNC_CONST,
   *MagickGetException(const MagickWand *,ExceptionType *),
   *MagickGetFilename(const MagickWand *),
   *MagickGetImageAttribute(MagickWand *, const char *),
@@ -74,13 +74,13 @@ extern WandExport CompressionType
   MagickGetImageCompression(MagickWand *);
 
 extern WandExport const char
-  *MagickGetCopyright(void),
-  *MagickGetHomeURL(void),
+  *MagickGetCopyright(void) MAGICK_FUNC_CONST,
+  *MagickGetHomeURL(void) MAGICK_FUNC_CONST,
   *MagickGetImageGeometry(MagickWand *),
-  *MagickGetPackageName(void),
+  *MagickGetPackageName(void) MAGICK_FUNC_CONST,
   *MagickGetQuantumDepth(unsigned long *),
-  *MagickGetReleaseDate(void),
-  *MagickGetVersion(unsigned long *);
+  *MagickGetReleaseDate(void) MAGICK_FUNC_CONST,
+  *MagickGetVersion(unsigned long *) MAGICK_FUNC_CONST;
 
 extern WandExport DisposeType
   MagickGetImageDispose(MagickWand *);
@@ -98,7 +98,7 @@ extern WandExport ImageType
   MagickGetImageType(MagickWand *);
 
 extern WandExport ImageType
-  MagickGetImageSavedType(MagickWand *);
+  MagickGetImageSavedType(MagickWand *) MAGICK_FUNC_CONST;
 
 extern WandExport InterlaceType
   MagickGetImageInterlaceScheme(MagickWand *);
@@ -215,9 +215,14 @@ extern WandExport unsigned int
   MagickGetImageWhitePoint(MagickWand *,double *,double *),
   MagickGetSize(const MagickWand *,unsigned long *,unsigned long *),
   MagickHaldClutImage(MagickWand *wand,const MagickWand *clut_wand),
+  MagickHasColormap(MagickWand *,unsigned int *),
   MagickHasNextImage(MagickWand *),
   MagickHasPreviousImage(MagickWand *),
   MagickImplodeImage(MagickWand *,const double),
+  MagickIsGrayImage(MagickWand *,unsigned int *),
+  MagickIsMonochromeImage(MagickWand *,unsigned int *),
+  MagickIsOpaqueImage(MagickWand *,unsigned int *),
+  MagickIsPaletteImage(MagickWand *,unsigned int *),
   MagickLabelImage(MagickWand *,const char *),
   MagickLevelImage(MagickWand *,const double,const double,const double),
   MagickLevelImageChannel(MagickWand *,const ChannelType,const double,
index 5c4841e..6dce09c 100644 (file)
@@ -23,14 +23,14 @@ extern WandExport char
   *PixelGetColorAsString(const PixelWand *);
 
 extern WandExport double
-  PixelGetBlack(const PixelWand *),
-  PixelGetBlue(const PixelWand *),
-  PixelGetCyan(const PixelWand *),
-  PixelGetGreen(const PixelWand *),
-  PixelGetMagenta(const PixelWand *),
-  PixelGetOpacity(const PixelWand *),
-  PixelGetRed(const PixelWand *),
-  PixelGetYellow(const PixelWand *);
+  PixelGetBlack(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetBlue(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetCyan(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetGreen(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetMagenta(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetOpacity(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetRed(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetYellow(const PixelWand *) MAGICK_FUNC_PURE;
 
 extern WandExport PixelWand
   *ClonePixelWand(const PixelWand *),
@@ -39,20 +39,20 @@ extern WandExport PixelWand
   **NewPixelWands(const unsigned long);
 
 extern WandExport Quantum
-  PixelGetBlackQuantum(const PixelWand *),
-  PixelGetBlueQuantum(const PixelWand *),
-  PixelGetCyanQuantum(const PixelWand *),
-  PixelGetGreenQuantum(const PixelWand *),
-  PixelGetMagentaQuantum(const PixelWand *),
-  PixelGetOpacityQuantum(const PixelWand *),
-  PixelGetRedQuantum(const PixelWand *),
-  PixelGetYellowQuantum(const PixelWand *);
+  PixelGetBlackQuantum(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetBlueQuantum(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetCyanQuantum(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetGreenQuantum(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetMagentaQuantum(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetOpacityQuantum(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetRedQuantum(const PixelWand *) MAGICK_FUNC_PURE,
+  PixelGetYellowQuantum(const PixelWand *) MAGICK_FUNC_PURE;
 
 extern WandExport unsigned int
   PixelSetColor(PixelWand *,const char *);
 
 extern WandExport unsigned long
-  PixelGetColorCount(const PixelWand *);
+  PixelGetColorCount(const PixelWand *) MAGICK_FUNC_PURE;
 
 extern WandExport void
   DestroyPixelWand(PixelWand *),
index 954ed10..5784254 100644 (file)
@@ -20,7 +20,7 @@ extern "C" {
  * mutli-threaded DLLs using the multithreaded runtime DLLs.
  **/
 #  if defined(_MT) && defined(_DLL) && !defined(_LIB)
-#    pragma warning( disable: 4273 )   /* Disable the stupid dll linkage warnings */
+#    pragma warning( disable: 4273 )    /* Disable the stupid dll linkage warnings */
 #    if !defined(_WANDLIB_)
 #      define WandExport __declspec(dllimport)
 #    else
index 387292e..5e4d095 100644 (file)
@@ -1,17 +1,11 @@
 /*
-  Copyright (C) 2012-2014 GraphicsMagick Group
+  Copyright (C) 2012-2018 GraphicsMagick Group
+
   This program is covered by multiple licenses, which are described in
   Copyright.txt. You should have received a copy of Copyright.txt with this
   package; otherwise see http://www.graphicsmagick.org/www/Copyright.html.
 
-  Library symbol name-scoping support.     
-
-  Obtained via:                                          
-
-  nm -p wand/.libs/libGraphicsMagickWand.a | grep ' T ' | egrep -vi '(Gm)|(lt_)' | \
-  awk '{ printf("#define %s Gm%s\n", $3, $3); }' | sort > wand/wand_symbols.h
-
+  Library symbol name-scoping support.
 */
 
 #if !defined(_MAGICK_WAND_SYMBOLS_H)
@@ -34,6 +28,7 @@
 #define MagickAnimateImages GmMagickAnimateImages
 #define MagickAnnotateImage GmMagickAnnotateImage
 #define MagickAppendImages GmMagickAppendImages
+#define MagickAutoOrientImage GmMagickAutoOrientImage
 #define MagickAverageImages GmMagickAverageImages
 #define MagickBlackThresholdImage GmMagickBlackThresholdImage
 #define MagickBlurImage GmMagickBlurImage
@@ -41,6 +36,7 @@
 #define MagickCdlImage GmMagickCdlImage
 #define MagickCharcoalImage GmMagickCharcoalImage
 #define MagickChopImage GmMagickChopImage
+#define MagickClearException GmMagickClearException
 #define MagickClipImage GmMagickClipImage
 #define MagickClipPathImage GmMagickClipPathImage
 #define MagickCloneDrawingWand GmMagickCloneDrawingWand
@@ -79,8 +75,8 @@
 #define MagickDrawGetFillColor GmMagickDrawGetFillColor
 #define MagickDrawGetFillOpacity GmMagickDrawGetFillOpacity
 #define MagickDrawGetFillRule GmMagickDrawGetFillRule
-#define MagickDrawGetFontFamily GmMagickDrawGetFontFamily
 #define MagickDrawGetFont GmMagickDrawGetFont
+#define MagickDrawGetFontFamily GmMagickDrawGetFontFamily
 #define MagickDrawGetFontSize GmMagickDrawGetFontSize
 #define MagickDrawGetFontStretch GmMagickDrawGetFontStretch
 #define MagickDrawGetFontStyle GmMagickDrawGetFontStyle
 #define MagickDrawSetFillOpacity GmMagickDrawSetFillOpacity
 #define MagickDrawSetFillPatternURL GmMagickDrawSetFillPatternURL
 #define MagickDrawSetFillRule GmMagickDrawSetFillRule
-#define MagickDrawSetFontFamily GmMagickDrawSetFontFamily
 #define MagickDrawSetFont GmMagickDrawSetFont
+#define MagickDrawSetFontFamily GmMagickDrawSetFontFamily
 #define MagickDrawSetFontSize GmMagickDrawSetFontSize
 #define MagickDrawSetFontStretch GmMagickDrawSetFontStretch
 #define MagickDrawSetFontStyle GmMagickDrawSetFontStyle
 #define MagickFlipImage GmMagickFlipImage
 #define MagickFlopImage GmMagickFlopImage
 #define MagickFrameImage GmMagickFrameImage
-#define MagickFxImageChannel GmMagickFxImageChannel
 #define MagickFxImage GmMagickFxImage
-#define MagickGammaImageChannel GmMagickGammaImageChannel
+#define MagickFxImageChannel GmMagickFxImageChannel
 #define MagickGammaImage GmMagickGammaImage
+#define MagickGammaImageChannel GmMagickGammaImageChannel
 #define MagickGetConfigureInfo GmMagickGetConfigureInfo
 #define MagickGetCopyright GmMagickGetCopyright
 #define MagickGetException GmMagickGetException
 #define MagickGetFilename GmMagickGetFilename
 #define MagickGetHomeURL GmMagickGetHomeURL
+#define MagickGetImage GmMagickGetImage
 #define MagickGetImageAttribute GmMagickGetImageAttribute
 #define MagickGetImageBackgroundColor GmMagickGetImageBackgroundColor
 #define MagickGetImageBluePrimary GmMagickGetImageBluePrimary
 #define MagickGetImageGamma GmMagickGetImageGamma
 #define MagickGetImageGeometry GmMagickGetImageGeometry
 #define MagickGetImageGravity GmMagickGetImageGravity
-#define MagickGetImage GmMagickGetImage
 #define MagickGetImageGreenPrimary GmMagickGetImageGreenPrimary
 #define MagickGetImageHeight GmMagickGetImageHeight
 #define MagickGetImageHistogram GmMagickGetImageHistogram
 #define MagickGetImageIterations GmMagickGetImageIterations
 #define MagickGetImageMatte GmMagickGetImageMatte
 #define MagickGetImageMatteColor GmMagickGetImageMatteColor
+#define MagickGetImageOrientation GmMagickGetImageOrientation
 #define MagickGetImagePage GmMagickGetImagePage
 #define MagickGetImagePixels GmMagickGetImagePixels
 #define MagickGetImageProfile GmMagickGetImageProfile
 #define MagickGetSize GmMagickGetSize
 #define MagickGetVersion GmMagickGetVersion
 #define MagickHaldClutImage GmMagickHaldClutImage
+#define MagickHasColormap GmMagickHasColormap
 #define MagickHasNextImage GmMagickHasNextImage
 #define MagickHasPreviousImage GmMagickHasPreviousImage
 #define MagickImplodeImage GmMagickImplodeImage
+#define MagickIsGrayImage GmMagickIsGrayImage
+#define MagickIsMonochromeImage GmMagickIsMonochromeImage
+#define MagickIsOpaqueImage GmMagickIsOpaqueImage
+#define MagickIsPaletteImage GmMagickIsPaletteImage
 #define MagickLabelImage GmMagickLabelImage
-#define MagickLevelImageChannel GmMagickLevelImageChannel
 #define MagickLevelImage GmMagickLevelImage
+#define MagickLevelImageChannel GmMagickLevelImageChannel
 #define MagickMagnifyImage GmMagickMagnifyImage
 #define MagickMapImage GmMagickMapImage
 #define MagickMatteFloodfillImage GmMagickMatteFloodfillImage
 #define MagickMorphImages GmMagickMorphImages
 #define MagickMosaicImages GmMagickMosaicImages
 #define MagickMotionBlurImage GmMagickMotionBlurImage
-#define MagickNegateImageChannel GmMagickNegateImageChannel
 #define MagickNegateImage GmMagickNegateImage
+#define MagickNegateImageChannel GmMagickNegateImageChannel
 #define MagickNewDrawingWand GmMagickNewDrawingWand
 #define MagickNextImage GmMagickNextImage
 #define MagickNormalizeImage GmMagickNormalizeImage
 #define MagickOilPaintImage GmMagickOilPaintImage
 #define MagickOpaqueImage GmMagickOpaqueImage
+#define MagickOperatorImageChannel GmMagickOperatorImageChannel
 #define MagickPingImage GmMagickPingImage
 #define MagickPreviewImages GmMagickPreviewImages
 #define MagickPreviousImage GmMagickPreviousImage
 #define MagickQueryFormats GmMagickQueryFormats
 #define MagickRadialBlurImage GmMagickRadialBlurImage
 #define MagickRaiseImage GmMagickRaiseImage
+#define MagickReadImage GmMagickReadImage
 #define MagickReadImageBlob GmMagickReadImageBlob
 #define MagickReadImageFile GmMagickReadImageFile
-#define MagickReadImage GmMagickReadImage
 #define MagickReduceNoiseImage GmMagickReduceNoiseImage
 #define MagickRelinquishMemory GmMagickRelinquishMemory
 #define MagickRemoveImage GmMagickRemoveImage
+#define MagickRemoveImageOption GmMagickRemoveImageOption
 #define MagickRemoveImageProfile GmMagickRemoveImageProfile
 #define MagickResampleImage GmMagickResampleImage
 #define MagickResetIterator GmMagickResetIterator
 #define MagickSetDepth GmMagickSetDepth
 #define MagickSetFilename GmMagickSetFilename
 #define MagickSetFormat GmMagickSetFormat
+#define MagickSetImage GmMagickSetImage
 #define MagickSetImageAttribute GmMagickSetImageAttribute
 #define MagickSetImageBackgroundColor GmMagickSetImageBackgroundColor
 #define MagickSetImageBluePrimary GmMagickSetImageBluePrimary
 #define MagickSetImageFormat GmMagickSetImageFormat
 #define MagickSetImageFuzz GmMagickSetImageFuzz
 #define MagickSetImageGamma GmMagickSetImageGamma
+#define MagickSetImageGeometry GmMagickSetImageGeometry
 #define MagickSetImageGravity GmMagickSetImageGravity
-#define MagickSetImage GmMagickSetImage
 #define MagickSetImageGreenPrimary GmMagickSetImageGreenPrimary
 #define MagickSetImageIndex GmMagickSetImageIndex
 #define MagickSetImageInterlaceScheme GmMagickSetImageInterlaceScheme
 #define MagickSetImageMatte GmMagickSetImageMatte
 #define MagickSetImageMatteColor GmMagickSetImageMatteColor
 #define MagickSetImageOption GmMagickSetImageOption
+#define MagickSetImageOrientation GmMagickSetImageOrientation
 #define MagickSetImagePage GmMagickSetImagePage
 #define MagickSetImagePixels GmMagickSetImagePixels
 #define MagickSetImageProfile GmMagickSetImageProfile
 #define MagickStripImage GmMagickStripImage
 #define MagickSwirlImage GmMagickSwirlImage
 #define MagickTextureImage GmMagickTextureImage
-#define MagickThresholdImageChannel GmMagickThresholdImageChannel
 #define MagickThresholdImage GmMagickThresholdImage
+#define MagickThresholdImageChannel GmMagickThresholdImageChannel
 #define MagickTintImage GmMagickTintImage
 #define MagickTransformImage GmMagickTransformImage
 #define MagickTransparentImage GmMagickTransparentImage
 #define MagickUnsharpMaskImage GmMagickUnsharpMaskImage
 #define MagickWaveImage GmMagickWaveImage
 #define MagickWhiteThresholdImage GmMagickWhiteThresholdImage
+#define MagickWriteImage GmMagickWriteImage
 #define MagickWriteImageBlob GmMagickWriteImageBlob
 #define MagickWriteImageFile GmMagickWriteImageFile
-#define MagickWriteImage GmMagickWriteImage
-#define MagickWriteImagesFile GmMagickWriteImagesFile
 #define MagickWriteImages GmMagickWriteImages
+#define MagickWriteImagesFile GmMagickWriteImagesFile
 #define NewMagickWand GmNewMagickWand
 #define NewPixelWand GmNewPixelWand
 #define NewPixelWands GmNewPixelWands
 #define PixelSetBlackQuantum GmPixelSetBlackQuantum
 #define PixelSetBlue GmPixelSetBlue
 #define PixelSetBlueQuantum GmPixelSetBlueQuantum
-#define PixelSetColorCount GmPixelSetColorCount
 #define PixelSetColor GmPixelSetColor
+#define PixelSetColorCount GmPixelSetColorCount
 #define PixelSetCyan GmPixelSetCyan
 #define PixelSetCyanQuantum GmPixelSetCyanQuantum
 #define PixelSetGreen GmPixelSetGreen
 
 #endif /* defined(PREFIX_MAGICK_SYMBOLS) */
 #endif /* defined(_MAGICK_WAND_SYMBOLS_H) */
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 2
+ * fill-column: 78
+ * End:
+ */
index 105cf18..28c8919 100644 (file)
@@ -101,7 +101,7 @@ int main(int argc,char **argv)
   MagickWand
     *clone_wand,
     *magick_wand;
+
   PixelWand
     *background,
     *fill;
@@ -132,7 +132,7 @@ int main(int argc,char **argv)
     char
       *p,
       path[MaxTextExtent];
-    
+
     path[0]=0;
     p=getenv("SRCDIR");
     if (p)
@@ -142,7 +142,7 @@ int main(int argc,char **argv)
           strcat(path,"/");
       }
     strcat(path,"sequence.miff");
-    
+
     status=MagickReadImage(magick_wand,path);
   }
   if (status == False)
diff --git a/www/ChangeLog-2017.html b/www/ChangeLog-2017.html
new file mode 100644 (file)
index 0000000..8ad6c1d
--- /dev/null
@@ -0,0 +1,1283 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="generator" content="Docutils 0.13.1: http://docutils.sourceforge.net/" />
+<title></title>
+<link rel="stylesheet" href="docutils-articles.css" type="text/css" />
+</head>
+<body>
+
+<div class="banner">
+<img src="images/gm-107x76.png" alt="GraphicMagick logo" width="107" height="76" />
+<span class="title">GraphicsMagick</span>
+<form action="http://www.google.com/search">
+       <input type="hidden" name="domains" value="www.graphicsmagick.org" />
+       <input type="hidden" name="sitesearch" value="www.graphicsmagick.org" />
+    <span class="nowrap"><input type="text" name="q" size="25" maxlength="255" />&nbsp;<input type="submit" name="sa" value="Search" /></span>
+</form>
+</div>
+
+<div class="navmenu">
+<ul>
+<li><a href="index.html">Home</a></li>
+<li><a href="project.html">Project</a></li>
+<li><a href="download.html">Download</a></li>
+<li><a href="README.html">Install</a></li>
+<li><a href="Hg.html">Source</a></li>
+<li><a href="NEWS.html">News</a> </li>
+<li><a href="utilities.html">Utilities</a></li>
+<li><a href="programming.html">Programming</a></li>
+<li><a href="reference.html">Reference</a></li>
+</ul>
+</div>
+<div class="document">
+
+
+<p>2017-12-25  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>tests/rwfile.tap: Add tests for MIFF compressed sub-formats.</li>
+</ul>
+</blockquote>
+<p>2017-12-24  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/blob.c (OpenBlob): Zlib 1.2.8 does not accept an open
+mode of &quot;w+b&quot; or &quot;wb+&quot;.  It seems to be allergic to '+'.  As a
+result, writing to &quot;.gz&quot; files was not working with Zlib 1.2.8.
+Note that &quot;w+b&quot; must be used in the normal case since the test
+suite fails otherwise!</li>
+</ul>
+</blockquote>
+<p>2017-12-22  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadMNGImage): Fix SourceForge issue #535
+&quot;heap-buffer-overflow in ReadMNGImage&quot;.  Problem was caused by
+accessing byte before testing that limit has been reached, rather
+than testing for limit before accessing the byte.  This means that
+it could only ever read one past the buffer allocation size.</li>
+<li>coders/webp.c (WriteWEBPImage): Fix SourceForge issue #536
+&quot;stack-buffer-overflow in WriteWEBPImage&quot;.  Due to a change to use
+WebPMemoryWriter as part of the EXIF and ICC profile support
+addition (enabled with libwebp 0.5.0), the progress indicator
+callback is now passed a pointer to a wrong structure.  This is
+quite unfortunate since the progress indication is useful.  The
+progress indication is temporarily disabled when the
+WebPMemoryWriter is in use until a solution is implemented.
+(ProgressCallback): Re-implement progress callback so that image
+pointer is stored/retrieved as thread-specific data.</li>
+<li>coders/png.c (ReadMNGImage): Fix SourceForge issue #537 &quot;null
+pointer dereference in ReadMNGImage&quot;.  DEFI chunk must be at least
+2 bytes long.</li>
+<li>coders/tiff.c (ReadNewsProfile): Fix SourceForge issue #533
+&quot;heap-buffer-overflow on LocaleNCompare&quot;.  LocaleNCompare() was
+being allowed to read heap data beyond the allocated region.</li>
+</ul>
+</blockquote>
+<p>2017-12-17  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/shear.c (IntegralRotateImage): Assure that reported error
+in rotate by 270 case does immediately terminate processing.
+Return a NULL Image pointer if there is a problem rather than a
+corrupted image.  Fix is related to SourceForge issue #532
+&quot;heap-buffer-overflow bug in ReadWPGImage&quot;.</li>
+<li>magick/pixel_cache.c (AcquireCacheNexus): Add a check that the
+pixel cache is compatible with the image dimensions.  Fix is
+related to SourceForge issue #532 &quot;heap-buffer-overflow bug in
+ReadWPGImage&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-12-16  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJNGImage): Fix SourceForge issue #530
+&quot;heap-buffer-overflow in ReadOneJNGImage&quot;.  In this case there is
+a read one byte beyond the oFFs chunk allocation size due to an
+error in specifying an offset into the chunk.</li>
+<li>coders/palm.c (ReadPALMImage): Fix SourceForge issue #529
+&quot;global-buffer-overflow in ReadPALMImage&quot;.  This issue only
+occured in builds with QuantumDepth=8 due to the small range of
+IndexPacket.</li>
+</ul>
+</blockquote>
+<p>2017-12-13  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>PerlMagick/{Magick.pm, Magick.pm.in, Makefile.PL.in}: Only base
+PerlMagick version on numeric portion of PACKAGE_VERSION.</li>
+</ul>
+</blockquote>
+<p>2017-12-09  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>www/index.rst: Update to 1.3.27.</li>
+<li>www/Changes.rst: Add 1.3.27</li>
+<li>version.sh: Update library versioning.</li>
+<li>NEWS.txt: Update NEWS in preparation for releasing 1.3.27.</li>
+</ul>
+</blockquote>
+<p>2017-12-08  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dcm.c (DCM_ReadElement): Change size checks addressing
+CVE-2017-12140 to be based on size_t rather than magick_off_t due
+to apparent instability of the previous check across compilers.</li>
+</ul>
+</blockquote>
+<p>2017-12-07  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (WriteOnePNGImage): Fix heap read access outside of
+allocated PixelPacket array while testing pixels for opacity.
+Resolves SourceForge issue #526 &quot;heap-buffer-overflow in
+WriteOnePNGImage&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-12-06  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pnm.c (WritePNMImage): Fix SourceForge bug #525
+&quot;heap-buffer-overflow in MagickBitStreamMSBWrite&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-12-05  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dcm.c (DCM_ReadElement): Eliminate huge memory allocation
+based on bogus length value. Addresses CVE-2017-12140. Problem was
+reported via email from Petr Gajdos on Tue, 5 Dec 2017.</li>
+</ul>
+</blockquote>
+<p>2017-12-03  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>Magick++/lib/Image.cpp (colorMap): Try to eliminate Coverity CID
+172796 &quot;Dereference after null check&quot; which seems to be bogus.</li>
+<li>coders/png.c (WriteOnePNGImage): Fix Coverity CID 168053
+&quot;Dereference after null check&quot;.  The check for null and the error
+report which attempted to use the null value was not needed at
+all.</li>
+<li>coders/cut.c (GetCutColors): Fix Coverity CID 10181: &quot;Null
+pointer dereferences&quot;. SetImagePixels() may return NULL.</li>
+<li>coders/rgb.c (ReadRGBImage): Fix SourceForge issue #523
+&quot;heap-buffer-overflow&quot;.  Similar issue to cmyk.c.</li>
+<li>coders/gray.c (ReadGRAYImage): Fix SourceForge issue #522
+&quot;heap-buffer-overflow&quot;.  Similar issue to cmyk.c.</li>
+<li>coders/cmyk.c (ReadCMYKImage): Fix SourceForge issue #521
+&quot;heap-buffer-overflow&quot;. The requested tile must be within the
+bounds of the image.  As it happens, 'montage' passes size and
+tile information which is useless for reading a raw image so it is
+not possible to read raw CMYK using 'montage'.</li>
+</ul>
+</blockquote>
+<p>2017-12-02  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pwp.c (ReadPWPImage): Eliminate dereference of null image
+pointer.  Addresses CVE-2017-11640.  Also address access to
+uninitialized memory.  Problem was reported via email from Petr
+Gajdos on Wed, 29 Nov 2017.</li>
+</ul>
+</blockquote>
+<p>2017-11-22  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wpg.c Additional check for wrong bpp CVE-2017-14342.</li>
+</ul>
+</blockquote>
+<p>2017-11-22  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>Magick++/lib/Image.cpp (autoOrient): Add method to auto-orient
+an image so it looks right-side up by default.  Based on patch by
+Przemysław Sobala submitted as SourceForge patch #53 &quot;Add
+Magick::Image::autoOrient() method to Magick++ library&quot;.</li>
+<li>www/download.rst: Change &quot;Czechoslovakian ftp mirror&quot; to &quot;Czech
+ftp mirror&quot;.  Resolves SourceForge bug #520 &quot;[web] Download sites:
+non-existent country&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-11-21  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wpg.c (ReadWPGImage): Fix excessive use of disk resources
+due to unreasonable record length.  Addresses CVE-2017-14341.
+Notified of this issue (with suggested patch) via email by Petr
+Gajdos on Tue, 21 Nov 2017.</li>
+</ul>
+</blockquote>
+<p>2017-11-19  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>README.txt: Comprehensive white-space clean-up across
+GraphicsMagick core source files.  Hard TAB character is converted
+to spaces.  Trailing white-space garbage is stripped.</li>
+<li>magick/colormap.c (MagickConstrainColormapIndex): Deprecate use
+of MagickConstrainColormapIndex() and prefer use of
+VerifyColormapIndex() and VerifyColormapIndexWithColors() due to
+avoiding dependence on index type, allowing provision of colors
+other than image-&gt;colors, and capturing more useful source file
+and line information.</li>
+<li>coders/{rle.c, mat.c, xbm.c, sgi.c, png.c}: Eliminate size_t vs
+unsigned 32 conversion warnings in WIN64 build.</li>
+</ul>
+</blockquote>
+<p>2017-11-18  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>tiff: Import libtiff 4.0.9.</li>
+</ul>
+</blockquote>
+<p>2017-11-12  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/bmp.c (DecodeImage): &quot;Right-size&quot; and &quot;Right-type&quot;
+DecodeImage() variables and check for EOF at every point of the
+way.  Pass buffer size as an argument.</li>
+<li>coders/dib.c (DecodeImage): &quot;Right-size&quot; and &quot;Right-type&quot;
+DecodeImage() variables and check for EOF at every point of the
+way.  Pass buffer size as an argument.</li>
+<li>coders/bmp.c (_BMPInfo): &quot;Right-size&quot; BMPInfo members.  The
+'long' type is promoted to 64-bit on LP64 systems and the large
+size is not needed.</li>
+</ul>
+</blockquote>
+<p>2017-11-11  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/webp.c: Incorporate patch by Jan Spitalnik to add EXIF
+and ICC metadata support to the WebP coder.  While WebP is still
+supported back to libwebp 0.1.99, the metadata support requires at
+least libwebp 0.5.0.  Resolves SourceForge patch #52 &quot;Add EXIF/ICC
+metadata support to WebP coder&quot;.</li>
+<li>coders/png.c (ReadOneJNGImage): Fix JNG memory leaks when JPEG
+image fails to be read.
+(WriteOnePNGImage): Promotion of indexed PNG to RGBA lacked
+setting of image matte, resulting in undersized buffer allocation
+and heap overflow.  Fixes SourceForge bug #453 &quot;Heap overflow in
+source-gra/coders/png.c&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-11-06  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/sfw.c (SFWScan): Fix heap buffer overflow
+(CVE-2017-13134).  Notified of problem via email (including a
+patch) from Petr Gajdos on Mon, 6 Nov 2017.</li>
+</ul>
+</blockquote>
+<p>2017-11-05  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wpg.c Wrong MaxMap check condition - fixed.</li>
+</ul>
+</blockquote>
+<p>2017-11-04  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wpg.c Check for InsertRow() return value.</li>
+</ul>
+</blockquote>
+<p>2017-11-04  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/export.c: Add not-null check for indexes pointer where
+needed.</li>
+<li>magick/import.c: Add not-null check for indexes pointer with
+associated exception report where the indexes pointer is needed.
+(ImportCMYKQuantumType): Was wrongly importing an opacity channel
+in some cases. Would have crashed if these cases were ever used.</li>
+<li>coders/wpg.c (ReadWPGImage): Assure that colormapped image is a
+PseudoClass type with valid colormapped indexes.  Fixes
+SourceForge bug 519 &quot;Null Pointer Dereference (Write) with
+malformed WPG Image&quot;.</li>
+<li>coders/sfw.c (ReadSFWImage): Avoid possible heap overflow while
+copying JFIF magic into buffer. Reject runt files.  Fixes
+CVE-2017-12983.  Notified of problem via email from Petr Gajdos on
+Thu, 2 Nov 2017.</li>
+</ul>
+</blockquote>
+<p>2017-10-28  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (DrawImage): Fix SourceForge bug #517 &quot;Push
+operations in DrawImage can lead to negative strncpy when looking
+for pop&quot;.  Interestingly, valgrind and ASAN only detected a
+problem with one of the test cases since exercised code which
+updated an array using the index.  It appears that Linux strncpy()
+simply ignores the bad request.</li>
+</ul>
+</blockquote>
+<p>2017-10-27  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJNGImage): Make sure that a reasonable
+exception is reported to the user when there is a read failure.</li>
+</ul>
+</blockquote>
+<p>2017-10-26  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJNGImage): Reject JNG files with
+unreasonable dimensions given the file size.</li>
+</ul>
+</blockquote>
+<p>2017-10-25  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJNGImage): Fix SourceForge bug #518 &quot;Null
+pointer in&quot;.  Also make sure that errors are reported properly due
+to problems with transferring JPEG scanlines.
+(ReadOneJNGImage): Add more checks for null value returned from
+SetImagePixels().</li>
+</ul>
+</blockquote>
+<p>2017-10-22  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/describe.c (DescribeImage): Fix possible heap read
+overflow while accessing heap data, and possible information
+disclosure while describing the IPTC profile.  Report was provided
+via email from Maor Shwartz to the graphicsmagick-security mail
+alias on Thu, 19 Oct 2017.  Independent security researchers,
+Jeremy Heng (&#64;nn_amon) and Terry Chia (Ayrx), reported this
+vulnerability to Beyond Security’s SecuriTeam Secure Disclosure
+program. Please note that this interface is usually (but not
+exclusively) used from within the command-line utility program, in
+which case there is not much useful information which might be
+disclosed.
+(DescribeImage): Fix possible heap write overflow when describing
+visual image directory.  Report was provided via email from Maor
+Shwartz to the graphicsmagick-security mail alias on Thu, 19 Oct
+2017.  Independent security researchers, Jeremy Heng (&#64;nn_amon)
+and Terry Chia (Ayrx), reported this vulnerability to Beyond
+Security’s SecuriTeam Secure Disclosure program. Please note that
+this interface is usually (but not exclusively) used from within
+the command-line utility program, in which case the only harm
+would be a program crash.</li>
+<li>magick/constitute.c (WriteImage): Assure that the errno present
+when the blob error status first occured is reported to the user.</li>
+<li>magick/blob.c (GetBlobStatus): Blob error status is now updated
+immediately upon the first error reported.
+(GetBlobFirstErrno): Returns errno value when the first blob error
+was reported.  This is useful for error reporting.</li>
+</ul>
+</blockquote>
+<p>2017-10-21  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/constitute.c (WriteImage): Restore use of GetBlobStatus()
+to test if an I/O error was encountered while writing output file.
+This assures that I/O failure in writers which do not themselves
+verify writes is assured to be reported.</li>
+</ul>
+</blockquote>
+<p>2017-10-17  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/webp.c (WriterCallback): WebP writer now detects partial
+write to output file.  Patch by Przemysław Sobala from a posting
+on Mon, 16 Oct 2017 via the graphicsmagick-help mailing list.</li>
+</ul>
+</blockquote>
+<p>2017-10-14  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/command.c (MontageImageCommand): Fix memory leaks in
+error return path.  Only people doing leak testing or the few who
+execute MontageImageCommand() as a function will care about this.</li>
+<li>magick/studio.h (NumberOfObjectsInArray): The
+NumberOfObjectsInArray() macro is used to compute the number of
+whole objects in an array.  Instead it was rounding up, resulting
+in scrambling the heap beyond the allocation.  Fixes
+CVE-2017-13737 &quot;There is an invalid free in the MagickFree
+function in magick/memory.c in GraphicsMagick 1.3.26 that will
+lead to a remote denial of service attack.&quot;</li>
+</ul>
+</blockquote>
+<p>2017-10-09  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOnePNGImage): Suppress &quot;comparison between
+signed and unsigned integer expressions&quot; warning.</li>
+<li>coders/png.c (ReadJNGImage): Fix memory leak in SourceForge
+Issue #469 &quot;use after free in ReadJNGImage&quot;.</li>
+<li>coders/png.c (ReadJNGImage): Fix memory leak in SourceForge
+Issue #470 &quot;Assert failure in writeblob&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-10-08  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>doc/options.imdoc: Fix SourceForge issue #444 &quot;gm mogrify: Wrong
+documentation for option -output-directory&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-10-07  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/module.c (InitializeModuleSearchPath): Verify that any
+component paths specified in MAGICK_CODER_MODULE_PATH and
+MAGICK_FILTER_MODULE_PATH exist before adding them to search paths
+actually used, and convert to real paths if possible.  This avoids
+possible use of relative paths to load modules (a possible
+security issue) and may improve efficiency by removing
+non-existent paths.</li>
+<li>coders/yuv.c (ReadYUVImage): Fix leak of scanline upon Image
+allocation failure.  Patch submitted by Petr Gajdos via email on
+Fri, 6 Oct 2017.</li>
+</ul>
+</blockquote>
+<p>2017-09-13  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Attempt to fix SourceForge Issue #469 &quot;use after
+free in ReadJNGImage&quot;.  Note that this change was found to replace
+a use after free with a memory leak so the problem is not solved
+yet.</li>
+</ul>
+</blockquote>
+<p>2017-10-03  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dcm.c (DCM_ReadNonNativeImages): Additional fix
+(improvement) for SourceForge issue #512 &quot;NULL Pointer Dereference
+in DICOM Decoder&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-10-01  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dcm.c (ReadDCMImage): Fix SourceForge issue #512 &quot;NULL
+Pointer Dereference in DICOM Decoder&quot;.</li>
+<li>coders/pict.c (ReadPICTImage): Fix SourceForge issue #511
+&quot;Memory Allocation error due to malformed image file&quot;.</li>
+<li>coders/pnm.c (WritePNMImage): Fix SourceForge issue #503 &quot;memory
+leak in WritePNMImage&quot;.</li>
+<li>coders/png.c (ReadMNGImage): Fix SourceForge issue #501 &quot;memory
+leak in ReadMNGImage&quot;.</li>
+<li>magick/segment.c (InitializeIntervalTree): Fix SourceForge issue
+#507 &quot;null pointer in segment.c&quot; and issue #508 &quot;null pointer in
+segment.c&quot;.</li>
+<li>coders/topol.c (ReadTOPOLImage): Fix SourceForge issue #510
+&quot;null pointer and meory leak in topol.c&quot;.</li>
+<li>magick/widget.c (MagickXFileBrowserWidget): Fix SourceForge
+issue #506 &quot;null pointer in widget.c&quot;.</li>
+<li>coders/tiff.c (WriteTIFFImage): Fix SourceForge issue #509
+&quot;Memory leak in tiff.c&quot;.</li>
+<li>magick/module.c (FindMagickModule): Fix SourceForge issue #502
+&quot;null pointer in module.c&quot;.</li>
+<li>coders/avs.c (ReadAVSImage): Fix Coverity CID 184115 &quot;Control
+flow issues (DEADCODE)&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-09-30  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/avs.c (ReadAVSImage): Fix SourceForge issue #499 &quot;memory
+leak in avs.c&quot;.</li>
+<li>coders/cmyk.c (ReadCMYKImage): Fix SourceForge issue #498
+&quot;memory leak in cmyk.c&quot;.</li>
+<li>coders/cut.c (ReadCUTImage): Fix SourceForge issue #497 &quot;memory
+leak in cut.c&quot;.</li>
+<li>coders/dpx.c (ReadDPXImage): Fix SourceForge issue #496 &quot;memory
+leak in dpx.c&quot;.</li>
+<li>coders/hdf.c (ReadHDFImage): Fix SourceForge issue #495 &quot;memory
+leak in hdf.c&quot;.</li>
+<li>coders/pcx.c (ReadPCXImage): Fix SourceForge issue #494 &quot;memory
+leak in pcx.c&quot;.</li>
+<li>coders/pcd.c (ReadPCDImage): Fix SourceForge issue #493 &quot;memory
+leak in ReadPCDImage&quot;.</li>
+<li>coders/histogram.c (WriteHISTOGRAMImage): Fix SourceForge issue
+#492 &quot;memory leak in WriteHISTOGRAMImage&quot;.</li>
+<li>coders/gif.c (WriteGIFImage): Fix SourceForge issue #491 &quot;memory
+leak in WriteGIFImage&quot;.</li>
+<li>coders/fits.c (WriteFITSImage): Fix SourceForge issue #490
+&quot;memory leak in WriteFITSImage&quot;.</li>
+<li>coders/palm.c (WritePALMImage): Fix SourceForge issue #489
+&quot;memory leak in WritePALMImage&quot;.</li>
+<li>coders/rgb.c (ReadRGBImage): Fix SourceForge issue #488 &quot;Memory
+leak in rgb.c&quot;.</li>
+<li>coders/palm.c (ReadPALMImage): Fix SourceForge issue #487 &quot;NULL
+pointer dereference in ReadPALMImage&quot;.</li>
+<li>Magick++/lib/Options.cpp (strokeDashArray): Fix SourceForge
+issue #486 &quot;NULL pointer dereference in
+Magick::Options::strokeDashArray&quot;.</li>
+<li>magick/nt_feature.c (NTGetTypeList): Fix SourceForge issue #485
+&quot;NULL pointer dereference in NTGetTypeList&quot;.</li>
+<li>coders/sun.c (ReadSUNImage): Fix SourceForge issue #484 &quot;Memory
+leak in sun.c&quot;.</li>
+<li>coders/tim.c (ReadTIMImage): Fix SourceForge issue #483 &quot;Memory
+leak in tim.c&quot;.</li>
+<li>magick/nt_base.c (NTRegistryKeyLookup): Fix SourceForge issue
+#482 &quot;NULL pointer dereference in NTRegistryKeyLookup&quot;.</li>
+<li>coders/viff.c (ReadVIFFImage): Fix SourceForge issue #481
+&quot;Memory leak in viff.c&quot;.</li>
+<li>magick/profile.c (SetImageProfile): Fix SourceForge issue #480
+&quot;assertion failure in MagickMapAllocateMap&quot;.</li>
+<li>coders/yuv.c (ReadYUVImage): Fix SourceForge issue #478 &quot;Memory
+leak in yuv.c&quot;.</li>
+<li>magick/map.c (MagickMapCloneMap): Fix SourceForge issue #477
+&quot;assertion failure in MagickMapIterateNext&quot;.</li>
+<li>coders/emf.c (ReadEnhMetaFile): Fix SourceForge issue #475 &quot;NULL
+pointer dereference in ReadEnhMetaFile&quot;.</li>
+<li>coders/cineon.c (ReadCINEONImage): Fix SourceForge issue #473
+&quot;NULL pointer dereference in ReadCINEONImage&quot;</li>
+<li>coders/tiff.c (TIFFIgnoreTags): Fix SourceForge issue #476 &quot;NULL
+Pointer in tiff.c&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-09-25  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/blob.c (GetConfigureBlob): Fix SourceForge issue #472
+&quot;NULL Pointer in GetConfigureBlob&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-09-24  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/rle.c (ReadRLEImage): Fix SourceForge issue #458 &quot;Heap
+out of bounds read in ReadRLEImage()&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-09-19  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/sgi.c (ReadSGIImage): Check for EOF while reading SGI
+file header.  Issue was brought to our attention by Petr Gajdos
+via email on Fri, 1 Sep 2017.</li>
+</ul>
+</blockquote>
+<p>2017-09-17  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/tiff.c (ReadTIFFImage): Allow a single scanline, strip,
+tile, to be 1000X larger than the input file in order to not cause
+problems for extremely compressible images or tile sizes much
+larger than the pixel dimensions.</li>
+</ul>
+</blockquote>
+<p>2017-09-16  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/symbols.h, wand/wand_symbols.h: Update C library symbols
+which should be prefixed with 'Gm'. However, GM will not move
+Magick++ namespace because of the ImageMagick version.  Resolves
+SourceForge issue #468 &quot;--enable-symbol-prefix does not prevent
+clashes with libMagick++ or libMagickWand?&quot;</li>
+<li>coders/png.c (DestroyJNG): DestroyJNG should be a static
+function.  Was wrongly exposed as DestroyJNGInfo in 1.3.26.  This
+is not a public function and was not intended to be part of the
+ABI.</li>
+<li>coders/tiff.c (ReadTIFFImage): Limit scanline, strip, and tile
+memory allocations based on file size multiplied by a maximum
+compression ratio.  Fixes SourceForge issues #460, #461, #462,
+#463, #464 &quot;allocation failure in ReadTIFFImage&quot;.</li>
+<li>coders/pnm.c (ReadPNMImage): Require that XV 332 format have 256
+colors.  Fixes SourceForge issue #465 &quot;NULL Pointer Dereference
+triggered by malformed file&quot;.  In our own testing the test case
+produced an assertion failure because assertions were enabled.</li>
+<li>magick/colormap.c (AllocateImageColormap): Use unsigned array
+index.</li>
+</ul>
+</blockquote>
+<p>2017-09-14  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c (ReadMATImage): Fix CVE-2016-10070, which is a heap
+overflow in the MAT reader due to an under-sized memory
+allocation.  Based on private email from Petr Gajdos on Mon, 11
+Sep 2017.</li>
+</ul>
+</blockquote>
+<p>2017-09-13  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Check MemoryResource before allocating
+ping_pixel array.</li>
+</ul>
+</blockquote>
+<p>2017-09-11  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li><dl class="first docutils">
+<dt>magick/shear.c: Possible evil loop might waste CPU for long time</dt>
+<dd>without any reason.</dd>
+</dl>
+</li>
+</ul>
+</blockquote>
+<p>2017-09-10  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (DrawImage): Fix SourceForge issue #448 &quot;Heap
+out of bounds read in DrawDashPolygon()&quot;.  Problem was reported by
+Kamil Frankowicz on August 28, 2017.</li>
+<li>coders/uil.c (WriteUILImage): Fix crash in UIL writer when
+writing image containing transparency.  Issue was reported by
+LCatro via email on 18 Jul 2017.</li>
+<li>coders/wpg.c (InsertRow): Fix crash which occurs if image is not
+PseudoClass but a PseudoColor scanline is needed.  Resolves
+SourceForge issue #449 &quot;Null pointer dereference in InsertRow()&quot;.</li>
+<li>coders/rle.c (ReadRLEImage): Impose image dimension limits
+according to Utah RLE specification. Cap number of planes handled
+internally at 4.  Remove non-standard multi-frame extension, which
+did not work anyway.</li>
+</ul>
+</blockquote>
+<p>2017-09-09  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadJNGImage): Complete fixing CVE-2017-8350 crash
+while reading a malformed JNG file.</li>
+<li>coders/{html.c, map.c, plasma.c, png.c, psd.c, rle.c, stegano.c,
+uil.c}: Downgrade claimed coder stability level for HTML, SHTML,
+MAP, FRACTAL, PLASMA, JNG, MNG, RLE, STEGANO, and UIL formats.</li>
+</ul>
+</blockquote>
+<p>2017-09-08  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadJNGImage): More efforts toward fixing
+CVE-2017-8350 while reading a malformed JNG file.</li>
+</ul>
+</blockquote>
+<p>2017-09-01  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/error.c (ThrowLoggedException): Capture the first
+exception at ErrorException level or greater, or only capture
+exception if it is more severe than an already reported exception.
+This should help lead to better error reports since the first
+error is usually the most significant.</li>
+<li>coders/png.c (ReadJNGImage): Add &quot;improper header&quot; exception
+reporting.</li>
+</ul>
+</blockquote>
+<p>2017-09-01  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadJNGImage): Efforts toward fixing CVE-2017-8350
+while reading a malformed JNG file.</li>
+</ul>
+</blockquote>
+<p>2017-08-30  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wpg.c (ReadWPGImage): Patch submitted by Petr Gajdos to
+check that .Width and .Height are greater than zero before they
+are assigned to image-&gt;columns and image-&gt;rows respectively
+(CVE-2014-9815).
+(ReadWPGImage): Do more validations on WPG_Palette.StartIndex and
+WPG_Palette.NumOfEntries.</li>
+</ul>
+</blockquote>
+<p>2017-08-29  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJNGImage): Fix for SourceForge issue #440
+&quot;use-after-free in CloseBlob (blob.c) (INCOMPLETE FIX FOR
+CVE-2017-11403)&quot; and SourceForge issue #438 &quot;heap use after free
+in CloseBlob&quot;.</li>
+<li>coders/png.c (ReadOneJNGImage): Fix for SourceForge issue #439
+&quot;assertion failure in magick/pixel_cache.c&quot;</li>
+</ul>
+</blockquote>
+<p>2017-08-27  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mpeg.c (WriteMPEGImage): Fix MPEG writer memory leak.
+Only the first image in the coalesce image list was being freed.
+Problem was reported by LCatro via email on July 15, 2017.</li>
+<li>magick/attribute.c (TracePSClippingPath, TraceSVGClippingPath):
+Fix SourceForge bug #447 &quot;Heap out of bounds read in
+ReadMSBShort()&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-08-26  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/xbm.c (ReadXBMImage): Fix two denial of service (DOS)
+issues in ReadXBMImage() which result in the reader not
+returning. Problem was reported via email on Wed Aug 23 2017 by
+Xiaohei and Wangchu from Alibaba Security Team.</li>
+<li>coders/jnx.c (ReadJNXImage): Fix denial of service (DOS) issue
+in ReadJNXImage() whereby large amounts of CPU and memory
+resources may be consumed although the file itself does not
+support the requests.  Problem was reported via email on Wed Aug
+23 2017 by Xiaohei and Wangchu from Alibaba Security Team.</li>
+</ul>
+</blockquote>
+<p>2017-08-14  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneMNGImage): Deal with invalid (too large)
+length of MNG chunks (bug #446).</li>
+</ul>
+</blockquote>
+<p>2017-08-20  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pnm.c (ReadPNMImage): Verify that sufficient file data
+exists to support what the file header requires before allocating
+memory for it.  Fixes problem reported by Agostino Sarubbo via
+email on Wed, 12 Jul 2017 and reported yet again via SourceForge
+bug #441 &quot;memory allocation failure in MagickRealloc&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-08-20  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c: Fix SourceForge bug #433 &quot;memory leak in
+ReadMATImage&quot;.  Credit for discovering and reporting the problem
+is &quot;ADLab of Venustech&quot;.</li>
+<li>coders/sun.c (ReadSUNImage): Fix failure to allocate memory due
+to inadequate file data to support claimed image width and height.
+First notified by email from Agostino Sarubbo on 14 Jul 2017 and
+then again as SourceForge bug #442 &quot;memory allocation failure in
+magickmalloc&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-08-16  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/svg.c (GetStyleTokens): Fix SourceForge bugs 434 &quot;heap
+buffer overflow in GetStyleTokens&quot;, 435 &quot;null pointer
+dereference_in_SVGStartElement&quot;, and 436 &quot;heap buffer overflow in
+GetStyleTokens&quot; which all originated from a heap buffer overflow
+in GetStyleStokens(), or inconsistent initialization.  Now the
+implementation truncates parsing for poorly-formed input (to avoid
+buffer overflow) while still correctly parsing well-formed input.
+The reproducers and problem reports are attributed to &quot;ADLab of
+Venustech&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-08-14  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJNGImage): Fixed double-free after
+reading a malformed JNG (Issue #438).</li>
+</ul>
+</blockquote>
+<p>2017-08-14  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pcd.c (ReadPCDImage): Fix memory leak on return path due
+to corrupted header.  Patch included in email on 14 Aug 2017 by
+Petr Gajdos (ImageMagick CVE CVE-2017-8351).</li>
+</ul>
+</blockquote>
+<p>2017-08-11  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/gif.c (ReadGIFImage): Assure that global colormap is
+initialized.</li>
+<li>coders/pict.c (ReadPICTImage): Fix memory leaks in error return
+path.  ImageMagick CVE CVE-2017-8353.  Patch by Petr Gajdos.</li>
+</ul>
+</blockquote>
+<p>2017-08-11  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>tests/rwblob.c and rwfile.c: Write the reason for FAIL in
+test-suite.log.</li>
+<li>magick/image.h: Revised table of image orientations to show
+Exif ImageOrientation values (which happen to be the same as
+the enum values 1 to 8).</li>
+<li>coders/png.c: ReadJNGIMage(): fix memory leak (Issue 431).</li>
+</ul>
+</blockquote>
+<p>2017-08-09  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mtv.c (ReadMTVImage): Fix memory leak in error return
+path upon unexpected EOF (ImageMagick CVE-2017-9142).  Problem was
+brought to our attention via email from Petr Gajdos on Wed, 9 Aug
+2017.  Also changed pixel cache access functions used to assure
+delivery of exception to the user.</li>
+</ul>
+</blockquote>
+<p>2017-08-05  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>configure.ac (SETJMP_IS_THREAD_SAFE): Decide if setjmp/longjmp
+are thread safe based on host OS.  Assume that these interfaces
+are thread safe by default.  Declared not to be thread safe under
+Solaris.  Declaring these interfaces to be thread safe increases
+available concurrency for coders which use setjmp/longjmp for
+error recovery (e.g. PNG and JPEG).</li>
+</ul>
+</blockquote>
+<p>2017-08-01  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/jpeg.c (RegisterJPEGImage): Add support for the
+SETJMP_IS_THREAD_SAFE preprocessor definition (already used by
+coders/png.c) to indicate if setjmp/longjmp are thread safe on
+this platform and that it is safe for multiple encoders/decoders
+to be active at one time.</li>
+</ul>
+</blockquote>
+<p>2017-07-31  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/sun.c: Fix heap read overflow while indexing into
+colormap. Problem was reported via email on 17 Jul 2017 by
+Agostino Sarubbo.</li>
+</ul>
+</blockquote>
+<p>2017-07-31  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadMNGImage): Stop a leak when rejecting a
+MNG image with dimensions that are too large.</li>
+</ul>
+</blockquote>
+<p>2017-07-26  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wmf.c (ReadWMFImage): Eliminate use of already freed heap
+data in error reporting path.  Problem was reported via email by
+Agostino Sarubbo on Fri, 14 Jul 2017</li>
+</ul>
+</blockquote>
+<p>2017-07-25  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadMNGImage) Free chunk allocation that remains
+after attempting to read a truncated file.</li>
+<li>coders/png.c: Removed some redundant checks for chunk length
+before MagickFreeMemory(chunk), which is safe to call with a
+NULL argument.</li>
+<li>coders/png.c: Fixed writer bug due to missing brackets; a Log
+statement should have been inside the &quot;i&quot; loop but instead was
+using i++ left over from the loop.  Bug report by L. Catro.</li>
+<li>coders/png.c: Reject a MNG with dimensions greater than 65k
+by 65k.</li>
+<li>coders/png.c (WriteOnePNGImage): Return without crashing if
+WriteOnePNGImage is passed a NULL image. Fixes CVE-2017-11522.</li>
+</ul>
+</blockquote>
+<p>2017-07-22  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pcl.c (WritePCLImage): Fix null pointer dereference in
+PCL writer when writing monochrome images.  Problem was reported
+by LCatro via email on July 18.</li>
+<li>magick/pixel_cache.c (PersistCache): Fix memory leak while
+writing a MPC file.  Problem was reported by LCatro via email on
+July 18.</li>
+<li>coders/map.c (WriteMAPImage): Fix null pointer dereference or
+segmentation violation in the MAP writer if the input image is not
+already colormapped.  Problem was reported by LCatro via email on
+July 18.</li>
+<li>coders/gray.c (WriteGRAYImage): Improve tracing and tidy up.</li>
+<li>coders/rgb.c (WriteRGBImage): Fix heap overwrite in raw RGB
+writer (all output subformats) given a multiframe sequence using
+different widths.  Problem was reported by LCatro via email on
+July 18.</li>
+<li>coders/cmyk.c (WriteCMYKImage): Fix heap overwrite in raw CMYK
+writer (all output subformats) given a multiframe sequence using
+different widths.  Also fix wrong output of CMYKA (and vice-versa)
+when CMYK was intended.  Problem was reported by LCatro via email
+on July 18.</li>
+<li>coders/palm.c: Disable the PALM writer since the writer is a
+work in progress and still has implementation problems.  Perhaps
+no one in the world remains who cares about the undocumented PALM
+format.  Resolves heap overflow and assertion issues reported by
+LCatro via emails on July 11th, and 12th, 2017.</li>
+<li>magick/colormap.c (ReplaceImageColormap): Throw an exception
+rather than assertion if the input image is not colormapped.</li>
+</ul>
+</blockquote>
+<p>2017-07-13  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Implemented eXIf chunk support.</li>
+</ul>
+</blockquote>
+<p>2017-07-12  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Fix typecast of left shifts (patch by Bob F)</li>
+</ul>
+</blockquote>
+<p>2017-07-12  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/ps.c (ReadPSImage): Fix reference to constant NULL image
+argument which is dereferenced to pass an exception to
+MagickMonitorFormatted().  Problem was reported by Agostino
+Sarubbo via email on Wed, 12 Jul 2017.</li>
+</ul>
+</blockquote>
+<p>2017-07-10  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/blob.c: Add casts to fix undefined behavior in left
+shifts.  Issue was reported by Agostino Sarubbo via email on Mon,
+10 Jul 2017.</li>
+</ul>
+</blockquote>
+<p>2017-07-10  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJNGImage): Ignore out-of-bounds MOVE
+and CLIP object_id's.</li>
+<li>coders/png.c (ReadMNGImage): Fix apparent off-by-one error
+in MNG FRAM change_clipping processing.</li>
+<li>coders/png.c (ReadMNGImage): Fix out-of-order CloseBlob()
+and DestroyImageList() that caused a use-after-free crash.
+Fixes CVE-2017-11403.  This bug was discovered by Agostino Sarubbo.</li>
+</ul>
+</blockquote>
+<p>2017-07-08  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJngImage): Revised double-free fix.</li>
+</ul>
+</blockquote>
+<p>2017-07-08  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJNGImage): Fix double-frees caused by
+commit on 2017-07-06.</li>
+<li>coders/jpeg.c (ReadJPEGImage): Defer creating pixel cache until
+after successfully reading first scanline.  Classify some serious
+libjpeg reported &quot;warnings&quot; as errors and quit processing
+scanlines immediately upon first error so that corrupt JPEG does
+not consume excessive resources.  Resolves excessive resource
+consumption issue reported for two JPEG files provided via email
+by LCatro on Tue, 4 Jul 2017.</li>
+</ul>
+</blockquote>
+<p>2017-07-06  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJNGImage): Remove spurious 'n' from log
+statement.</li>
+</ul>
+</blockquote>
+<p>2017-07-06  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Consolidate JNG cleanup into a new DestroyJNG()
+function.</li>
+</ul>
+</blockquote>
+<p>2017-07-05  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: prevent a crash due to zero-length color_image
+while reading a JNG image. (CVE-2017-11102)</li>
+</ul>
+</blockquote>
+<p>2017-07-04  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>NEWS.txt: Make sure is up to date.</li>
+<li>www/index.rst: Update for 1.3.26 release.</li>
+<li>version.sh: Update library versioning for 1.3.26 release.</li>
+<li>magick/command.c (BatchCommand): Add ferror() checks around
+batch input loop.</li>
+</ul>
+</blockquote>
+<p>2017-07-03  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Reject a PNG file if the file size is too small
+(less than 61 bytes).  Reject a JNG file if it is too small (less
+than 147 bytes).</li>
+<li>coders/jpeg.c: Reject a JPEG file if the file size is too small
+(less than 107 bytes).</li>
+</ul>
+</blockquote>
+<p>2017-07-02  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dpx.c (ReadDPXImage): Compute required file size and
+verify that sufficient data exists in file before allocating
+memory to decode the image data.  Resolves problem with DPX file
+with valid header (but a huge claimed image width) provided
+provided via email on Thu, 29 Jun 2017 by LCatro.  This issue has
+been assigned CVE-2017-10799.</li>
+</ul>
+</blockquote>
+<p>2016-07-02  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c Check whether reported object size overflows file size.</li>
+</ul>
+</blockquote>
+<p>2016-07-01  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c Safety check for forged and or corrupted data.
+This issue has been assigned CVE-2017-10800.</li>
+</ul>
+</blockquote>
+<p>2017-07-01  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/tiff.c (&quot;QuantumTransferMode&quot;): Use a generalized method
+to enforce that buffer overflow can not happen while importing
+pixels.  Resolves problem with RGB TIFF claiming only one sample
+per pixel provided via email on Thu, 29 Jun 2017 by LCatro.  This
+issue has been assigned CVE-2017-10794.</li>
+</ul>
+</blockquote>
+<p>2017-06-29  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/command.c: Convert bare 'unsigned int' to MagickPassFail
+where suitable to make intentions clear.  Convert True/False to
+MagickTrue/MagickFalse or MagickPass/MagickFail according to
+purpose.  This is a continuation of a gradual migration and does
+not represent an API change.</li>
+</ul>
+</blockquote>
+<p>2017-06-25  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Avoid NULL dereference when MAGN chunk processing
+fails (<a class="reference external" href="https://sourceforge.net/p/graphicsmagick/bugs/426/">https://sourceforge.net/p/graphicsmagick/bugs/426/</a>). Expand
+TABs.</li>
+</ul>
+</blockquote>
+<p>2017-06-25  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>NEWS.txt: Update NEWS with changes since the previous release.</li>
+<li>www/programming.rst: Switch the Lua link to
+<a class="reference external" href="https://github.com/arcapos/luagraphicsmagick">https://github.com/arcapos/luagraphicsmagick</a>, which is a more
+complete and direct interface from Lua to GraphicsMagick's Wand
+API.</li>
+</ul>
+</blockquote>
+<p>2017-06-24  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>VisualMagick/installer/gm-foo-dll.iss: Remove PerlMagick from
+the slim Inno Setup installer builder and remove mention of
+PerlMagick from the installer documentation.</li>
+<li>TclMagick/generic/TclMagick.c (magickCmd): Resolve SourceForge
+patch #51 &quot;TclMagick: memory access error; possible segfault&quot;.
+(newMagickObj): Fix formatting of pointer value so it is 64-bit
+safe.  Resolves SourceForge patch #50 &quot;TclMagick: 64-bit
+portability issue&quot;.</li>
+<li>coders/pict.c (ReadPICTImage): Avoid possible use of negative
+value when indexing array, which would cause buffer overflow.
+Resolves SourceForge issue #427 &quot;One possible buffer overflow
+vulnerability in
+GraphicsMagick-1.3.25/coders/pict.c:ReadPICTImage()&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-06-22  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Stop memory leak when reading invalid JNG image.
+Fixes CVE-2017-8350.</li>
+</ul>
+</blockquote>
+<p>2017-06-18  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Fix lcms2.h inclusion logic.</li>
+<li>wand/magick_wand.c (MagickSetImageOrientation): Eliminate use of
+snprintf, which is not supported by older Visual Studio.</li>
+</ul>
+</blockquote>
+<p>2017-06-09  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Accept exIf chunks whose data segment
+erroneously begins with &quot;Exif00&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-06-01  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Removed experimental zxIF chunk support.  That
+proposal is dead.</li>
+</ul>
+</blockquote>
+<p>2017-05-27  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>config/log.mgk: Added documentation suggested by SourceForge
+issue #419 &quot;Consider a small patch to log.mgk&quot;.</li>
+<li>www/Changes.rst: Add missing link to most recent changes.</li>
+</ul>
+</blockquote>
+<p>2017-05-24  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>www/Magick++/Image.rst: Improve documentation for Magick++
+Image::iccColorProfile() and Image::renderingIntent().</li>
+</ul>
+</blockquote>
+<p>2017-05-21  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>tiff: Update to libtiff 4.0.8.</li>
+</ul>
+</blockquote>
+<p>2017-03-19  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Quieted a new Coverity complaint about a potential
+text buffer overrun.</li>
+</ul>
+</blockquote>
+<p>2017-03-19  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/image.c (SetImageInfo): Ignore empty magic prefix
+specification and do not remove colon character from start of
+filename.  Resolves SourceForge bug #415 &quot;Inconsistent Behavior w/
+input_file Parameter&quot;.</li>
+</ul>
+</blockquote>
+<p>2017-03-18  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Added new private orNT PNG chunk, to
+preserve image-&gt;orientation when it is defined and not
+the default TopLeft.</li>
+<li>coders/jpeg.c: Mention image-&gt;orientation in the log when
+writing a JPEG.</li>
+</ul>
+</blockquote>
+<p>2017-03-15  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (WriteOnePNGImage): Add version info about
+gm, libpng, zlib, and lcms to the PNG debug log.</li>
+</ul>
+</blockquote>
+<p>2017-03-04  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/command.c (ImportImageCommand): Fix handling of -frame
+options. Option handling was incorrect due to option checking the
+frame option after it had been freed.  Checking the frame dash
+option before freeing the argument solves the problem.  From patch
+provided by Victor Ananjevsky as SourceForge patch #49 &quot;-frame
+doesn't work in gm import&quot;.</li>
+<li>Magick++/lib/Image.cpp (attribute): Added Image attribute method
+which accepts a 'char *' argument, and will remove the attribute
+if the value argument is NULL.  From patch provided by &quot;Gints&quot; as
+SourceForge patch #46 &quot;C++ api - method to clear/remove
+attribute&quot;.</li>
+<li>VisualMagick/configure/configure.cpp (InitInstance): Applied
+patch by Paul McConkey to allow the quantum command line argument
+to set the default value in the wizard drop list.  This allows
+setting the quantum depth when the /nowizard argument was
+supplied.  Resolves SourceForge patch #48 &quot;When running from the
+command line configure.exe does not use the quantum argument&quot;.
+The provided configure.exe still needs to be rebuilt to
+incorporate this change.</li>
+<li>magick/command.c (MogrifyImage): The -orient command now also
+updates the orientation in the EXIF profile, if it exists.</li>
+<li>Magick++/lib/Image.cpp (orientation): Update orientation in EXIF
+profile, if it exists.</li>
+</ul>
+</blockquote>
+<p>2017-03-03  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/jp2.c: Support PGX JPEG 2000 format for reading and
+writing (within the bounds of what JasPer supports).</li>
+</ul>
+</blockquote>
+<p>2017-02-23  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/tiff.c (QuantumTransferMode): Fix out of bounds read when
+reading CMYKA TIFF which claims to have only 2 samples per pixel.
+Problem was reported via email on February 15, 2017 by Valon
+Chu. This issue was assigned CVE-2017-6335.</li>
+</ul>
+</blockquote>
+<p>2017-01-29  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>doc/options.imdoc (-geometry): Geometry documentation changes
+suggested by Jon Wong.</li>
+</ul>
+</blockquote>
+<p>2017-01-26  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Added support for a proposed new PNG chunk
+(zxIf, read-only) that is currently being discussed on the
+png-mng-misc at lists.sourceforge.net mailing list.  Enable
+exIf and zxIf with CPPFLAGS=&quot;-DexIf_SUPPORTED -DxzIf_SUPPORTED&quot;.
+If exIf is enabled, only the uncompressed exIF chunk will be
+written and the hex-encoded zTXt chunk containing the raw Exif
+profile won't be written.</li>
+</ul>
+</blockquote>
+<p>2017-01-25  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/msl.c (MSLStartElement): Change test for NULL image
+pointer to before it is used rather than after it is used.
+Problem reported by Petr Gajdos on 2017-01-25.</li>
+</ul>
+</blockquote>
+<p>2017-01-22  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>TclMagick/unix/m4/tcl.m4: Update tcl.m4 to TEA 3.10.  File
+supplied by Massimo Manghi.</li>
+</ul>
+</blockquote>
+<p>2017-01-21  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Added support for a proposed new PNG
+chunk (exIf read-write, eXIf read-only) that is currently
+being discussed on the png-mng-misc at lists.sourceforge.net
+mailing list.</li>
+</ul>
+</blockquote>
+<p>2017-01-21  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c: Added read_user_chunk_callback() function
+and used it to implement a private PNG caNv (canvas) chunk
+for remembering the original dimensions and offsets when an
+image is cropped.  Previously we used the oFFs chunk for this
+purpose, but this had potential conflicts with other applications
+that also use the oFFs chunk.</li>
+</ul>
+</blockquote>
+<p>2017-01-07  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>TclMagick/Makefile.am (AM_DISTCHECK_CONFIGURE_FLAGS): Applied
+patch by Massimo Manghi to set AM_DISTCHECK_CONFIGURE_FLAGS so
+that 'make distcheck' remembers configuration options, and also to
+uninstall pkgIndex.tcl.</li>
+<li>magick/image.c (SetImageEx): Use PixelIterateMonoSet() for
+possibly improved efficiency.</li>
+<li>magick/pixel_iterator.c (PixelIterateMonoSet): New pixel
+iterator intended for use when initializing image pixels, without
+regard to existing values.</li>
+</ul>
+</blockquote>
+<p>2017-01-01  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>Copyright.txt: Bump copyright years and rotate ChangeLog.</li>
+</ul>
+</blockquote>
+</div>
+</body>
+</html>
diff --git a/www/ChangeLog-2017.rst b/www/ChangeLog-2017.rst
new file mode 100644 (file)
index 0000000..8a34df7
--- /dev/null
@@ -0,0 +1,1108 @@
+2017-12-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - tests/rwfile.tap: Add tests for MIFF compressed sub-formats.
+
+2017-12-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/blob.c (OpenBlob): Zlib 1.2.8 does not accept an open
+    mode of "w+b" or "wb+".  It seems to be allergic to '+'.  As a
+    result, writing to ".gz" files was not working with Zlib 1.2.8.
+    Note that "w+b" must be used in the normal case since the test
+    suite fails otherwise!
+
+2017-12-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadMNGImage): Fix SourceForge issue #535
+    "heap-buffer-overflow in ReadMNGImage".  Problem was caused by
+    accessing byte before testing that limit has been reached, rather
+    than testing for limit before accessing the byte.  This means that
+    it could only ever read one past the buffer allocation size.
+
+  - coders/webp.c (WriteWEBPImage): Fix SourceForge issue #536
+    "stack-buffer-overflow in WriteWEBPImage".  Due to a change to use
+    WebPMemoryWriter as part of the EXIF and ICC profile support
+    addition (enabled with libwebp 0.5.0), the progress indicator
+    callback is now passed a pointer to a wrong structure.  This is
+    quite unfortunate since the progress indication is useful.  The
+    progress indication is temporarily disabled when the
+    WebPMemoryWriter is in use until a solution is implemented.
+    (ProgressCallback): Re-implement progress callback so that image
+    pointer is stored/retrieved as thread-specific data.
+
+  - coders/png.c (ReadMNGImage): Fix SourceForge issue #537 "null
+    pointer dereference in ReadMNGImage".  DEFI chunk must be at least
+    2 bytes long.
+
+  - coders/tiff.c (ReadNewsProfile): Fix SourceForge issue #533
+    "heap-buffer-overflow on LocaleNCompare".  LocaleNCompare() was
+    being allowed to read heap data beyond the allocated region.
+
+2017-12-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/shear.c (IntegralRotateImage): Assure that reported error
+    in rotate by 270 case does immediately terminate processing.
+    Return a NULL Image pointer if there is a problem rather than a
+    corrupted image.  Fix is related to SourceForge issue #532
+    "heap-buffer-overflow bug in ReadWPGImage".
+
+  - magick/pixel\_cache.c (AcquireCacheNexus): Add a check that the
+    pixel cache is compatible with the image dimensions.  Fix is
+    related to SourceForge issue #532 "heap-buffer-overflow bug in
+    ReadWPGImage".
+
+2017-12-16  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJNGImage): Fix SourceForge issue #530
+    "heap-buffer-overflow in ReadOneJNGImage".  In this case there is
+    a read one byte beyond the oFFs chunk allocation size due to an
+    error in specifying an offset into the chunk.
+
+  - coders/palm.c (ReadPALMImage): Fix SourceForge issue #529
+    "global-buffer-overflow in ReadPALMImage".  This issue only
+    occured in builds with QuantumDepth=8 due to the small range of
+    IndexPacket.
+
+2017-12-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - PerlMagick/{Magick.pm, Magick.pm.in, Makefile.PL.in}: Only base
+    PerlMagick version on numeric portion of PACKAGE\_VERSION.
+
+2017-12-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - www/index.rst: Update to 1.3.27.
+
+  - www/Changes.rst: Add 1.3.27
+
+  - version.sh: Update library versioning.
+
+  - NEWS.txt: Update NEWS in preparation for releasing 1.3.27.
+
+2017-12-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dcm.c (DCM\_ReadElement): Change size checks addressing
+    CVE-2017-12140 to be based on size\_t rather than magick\_off\_t due
+    to apparent instability of the previous check across compilers.
+
+2017-12-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (WriteOnePNGImage): Fix heap read access outside of
+    allocated PixelPacket array while testing pixels for opacity.
+    Resolves SourceForge issue #526 "heap-buffer-overflow in
+    WriteOnePNGImage".
+
+2017-12-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pnm.c (WritePNMImage): Fix SourceForge bug #525
+    "heap-buffer-overflow in MagickBitStreamMSBWrite".
+
+2017-12-05  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dcm.c (DCM\_ReadElement): Eliminate huge memory allocation
+    based on bogus length value. Addresses CVE-2017-12140. Problem was
+    reported via email from Petr Gajdos on Tue, 5 Dec 2017.
+
+2017-12-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - Magick++/lib/Image.cpp (colorMap): Try to eliminate Coverity CID
+    172796 "Dereference after null check" which seems to be bogus.
+
+  - coders/png.c (WriteOnePNGImage): Fix Coverity CID 168053
+    "Dereference after null check".  The check for null and the error
+    report which attempted to use the null value was not needed at
+    all.
+
+  - coders/cut.c (GetCutColors): Fix Coverity CID 10181: "Null
+    pointer dereferences". SetImagePixels() may return NULL.
+
+  - coders/rgb.c (ReadRGBImage): Fix SourceForge issue #523
+    "heap-buffer-overflow".  Similar issue to cmyk.c.
+
+  - coders/gray.c (ReadGRAYImage): Fix SourceForge issue #522
+    "heap-buffer-overflow".  Similar issue to cmyk.c.
+
+  - coders/cmyk.c (ReadCMYKImage): Fix SourceForge issue #521
+    "heap-buffer-overflow". The requested tile must be within the
+    bounds of the image.  As it happens, 'montage' passes size and
+    tile information which is useless for reading a raw image so it is
+    not possible to read raw CMYK using 'montage'.
+
+2017-12-02  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pwp.c (ReadPWPImage): Eliminate dereference of null image
+    pointer.  Addresses CVE-2017-11640.  Also address access to
+    uninitialized memory.  Problem was reported via email from Petr
+    Gajdos on Wed, 29 Nov 2017.
+
+2017-11-22  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/wpg.c Additional check for wrong bpp CVE-2017-14342.
+
+
+2017-11-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - Magick++/lib/Image.cpp (autoOrient): Add method to auto-orient
+    an image so it looks right-side up by default.  Based on patch by
+    Przemysław Sobala submitted as SourceForge patch #53 "Add
+    Magick::Image::autoOrient() method to Magick++ library".
+
+  - www/download.rst: Change "Czechoslovakian ftp mirror" to "Czech
+    ftp mirror".  Resolves SourceForge bug #520 "[web] Download sites:
+    non-existent country".
+
+2017-11-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/wpg.c (ReadWPGImage): Fix excessive use of disk resources
+    due to unreasonable record length.  Addresses CVE-2017-14341.
+    Notified of this issue (with suggested patch) via email by Petr
+    Gajdos on Tue, 21 Nov 2017.
+
+2017-11-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - README.txt: Comprehensive white-space clean-up across
+    GraphicsMagick core source files.  Hard TAB character is converted
+    to spaces.  Trailing white-space garbage is stripped.
+
+  - magick/colormap.c (MagickConstrainColormapIndex): Deprecate use
+    of MagickConstrainColormapIndex() and prefer use of
+    VerifyColormapIndex() and VerifyColormapIndexWithColors() due to
+    avoiding dependence on index type, allowing provision of colors
+    other than image->colors, and capturing more useful source file
+    and line information.
+
+  - coders/{rle.c, mat.c, xbm.c, sgi.c, png.c}: Eliminate size\_t vs
+    unsigned 32 conversion warnings in WIN64 build.
+
+2017-11-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - tiff: Import libtiff 4.0.9.
+
+2017-11-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/bmp.c (DecodeImage): "Right-size" and "Right-type"
+    DecodeImage() variables and check for EOF at every point of the
+    way.  Pass buffer size as an argument.
+
+  - coders/dib.c (DecodeImage): "Right-size" and "Right-type"
+    DecodeImage() variables and check for EOF at every point of the
+    way.  Pass buffer size as an argument.
+
+  - coders/bmp.c (\_BMPInfo): "Right-size" BMPInfo members.  The
+    'long' type is promoted to 64-bit on LP64 systems and the large
+    size is not needed.
+
+2017-11-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/webp.c: Incorporate patch by Jan Spitalnik to add EXIF
+    and ICC metadata support to the WebP coder.  While WebP is still
+    supported back to libwebp 0.1.99, the metadata support requires at
+    least libwebp 0.5.0.  Resolves SourceForge patch #52 "Add EXIF/ICC
+    metadata support to WebP coder".
+
+  - coders/png.c (ReadOneJNGImage): Fix JNG memory leaks when JPEG
+    image fails to be read.
+    (WriteOnePNGImage): Promotion of indexed PNG to RGBA lacked
+    setting of image matte, resulting in undersized buffer allocation
+    and heap overflow.  Fixes SourceForge bug #453 "Heap overflow in
+    source-gra/coders/png.c".
+
+2017-11-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/sfw.c (SFWScan): Fix heap buffer overflow
+    (CVE-2017-13134).  Notified of problem via email (including a
+    patch) from Petr Gajdos on Mon, 6 Nov 2017.
+
+2017-11-05  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/wpg.c Wrong MaxMap check condition - fixed.
+
+2017-11-04  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/wpg.c Check for InsertRow() return value.
+
+2017-11-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/export.c: Add not-null check for indexes pointer where
+    needed.
+
+  - magick/import.c: Add not-null check for indexes pointer with
+    associated exception report where the indexes pointer is needed.
+    (ImportCMYKQuantumType): Was wrongly importing an opacity channel
+    in some cases. Would have crashed if these cases were ever used.
+
+  - coders/wpg.c (ReadWPGImage): Assure that colormapped image is a
+    PseudoClass type with valid colormapped indexes.  Fixes
+    SourceForge bug 519 "Null Pointer Dereference (Write) with
+    malformed WPG Image".
+
+  - coders/sfw.c (ReadSFWImage): Avoid possible heap overflow while
+    copying JFIF magic into buffer. Reject runt files.  Fixes
+    CVE-2017-12983.  Notified of problem via email from Petr Gajdos on
+    Thu, 2 Nov 2017.
+
+2017-10-28  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/render.c (DrawImage): Fix SourceForge bug #517 "Push
+    operations in DrawImage can lead to negative strncpy when looking
+    for pop".  Interestingly, valgrind and ASAN only detected a
+    problem with one of the test cases since exercised code which
+    updated an array using the index.  It appears that Linux strncpy()
+    simply ignores the bad request.
+
+2017-10-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJNGImage): Make sure that a reasonable
+    exception is reported to the user when there is a read failure.
+
+2017-10-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJNGImage): Reject JNG files with
+    unreasonable dimensions given the file size.
+
+2017-10-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJNGImage): Fix SourceForge bug #518 "Null
+    pointer in".  Also make sure that errors are reported properly due
+    to problems with transferring JPEG scanlines.
+    (ReadOneJNGImage): Add more checks for null value returned from
+    SetImagePixels().
+
+2017-10-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/describe.c (DescribeImage): Fix possible heap read
+    overflow while accessing heap data, and possible information
+    disclosure while describing the IPTC profile.  Report was provided
+    via email from Maor Shwartz to the graphicsmagick-security mail
+    alias on Thu, 19 Oct 2017.  Independent security researchers,
+    Jeremy Heng (@nn\_amon) and Terry Chia (Ayrx), reported this
+    vulnerability to Beyond Security’s SecuriTeam Secure Disclosure
+    program. Please note that this interface is usually (but not
+    exclusively) used from within the command-line utility program, in
+    which case there is not much useful information which might be
+    disclosed.
+    (DescribeImage): Fix possible heap write overflow when describing
+    visual image directory.  Report was provided via email from Maor
+    Shwartz to the graphicsmagick-security mail alias on Thu, 19 Oct
+    2017.  Independent security researchers, Jeremy Heng (@nn\_amon)
+    and Terry Chia (Ayrx), reported this vulnerability to Beyond
+    Security’s SecuriTeam Secure Disclosure program. Please note that
+    this interface is usually (but not exclusively) used from within
+    the command-line utility program, in which case the only harm
+    would be a program crash.
+
+  - magick/constitute.c (WriteImage): Assure that the errno present
+    when the blob error status first occured is reported to the user.
+
+  - magick/blob.c (GetBlobStatus): Blob error status is now updated
+    immediately upon the first error reported.
+    (GetBlobFirstErrno): Returns errno value when the first blob error
+    was reported.  This is useful for error reporting.
+
+2017-10-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/constitute.c (WriteImage): Restore use of GetBlobStatus()
+    to test if an I/O error was encountered while writing output file.
+    This assures that I/O failure in writers which do not themselves
+    verify writes is assured to be reported.
+
+2017-10-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/webp.c (WriterCallback): WebP writer now detects partial
+    write to output file.  Patch by Przemysław Sobala from a posting
+    on Mon, 16 Oct 2017 via the graphicsmagick-help mailing list.
+
+2017-10-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/command.c (MontageImageCommand): Fix memory leaks in
+    error return path.  Only people doing leak testing or the few who
+    execute MontageImageCommand() as a function will care about this.
+
+  - magick/studio.h (NumberOfObjectsInArray): The
+    NumberOfObjectsInArray() macro is used to compute the number of
+    whole objects in an array.  Instead it was rounding up, resulting
+    in scrambling the heap beyond the allocation.  Fixes
+    CVE-2017-13737 "There is an invalid free in the MagickFree
+    function in magick/memory.c in GraphicsMagick 1.3.26 that will
+    lead to a remote denial of service attack."
+
+2017-10-09  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOnePNGImage): Suppress "comparison between
+    signed and unsigned integer expressions" warning.
+  - coders/png.c (ReadJNGImage): Fix memory leak in SourceForge
+    Issue #469 "use after free in ReadJNGImage".
+  - coders/png.c (ReadJNGImage): Fix memory leak in SourceForge
+    Issue #470 "Assert failure in writeblob".
+
+2017-10-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - doc/options.imdoc: Fix SourceForge issue #444 "gm mogrify: Wrong
+    documentation for option -output-directory".
+
+2017-10-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/module.c (InitializeModuleSearchPath): Verify that any
+    component paths specified in MAGICK\_CODER\_MODULE\_PATH and
+    MAGICK\_FILTER\_MODULE\_PATH exist before adding them to search paths
+    actually used, and convert to real paths if possible.  This avoids
+    possible use of relative paths to load modules (a possible
+    security issue) and may improve efficiency by removing
+    non-existent paths.
+
+  - coders/yuv.c (ReadYUVImage): Fix leak of scanline upon Image
+    allocation failure.  Patch submitted by Petr Gajdos via email on
+    Fri, 6 Oct 2017.
+
+2017-09-13  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Attempt to fix SourceForge Issue #469 "use after
+    free in ReadJNGImage".  Note that this change was found to replace
+    a use after free with a memory leak so the problem is not solved
+    yet.
+
+2017-10-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dcm.c (DCM\_ReadNonNativeImages): Additional fix
+    (improvement) for SourceForge issue #512 "NULL Pointer Dereference
+    in DICOM Decoder".
+
+2017-10-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dcm.c (ReadDCMImage): Fix SourceForge issue #512 "NULL
+    Pointer Dereference in DICOM Decoder".
+
+  - coders/pict.c (ReadPICTImage): Fix SourceForge issue #511
+    "Memory Allocation error due to malformed image file".
+
+  - coders/pnm.c (WritePNMImage): Fix SourceForge issue #503 "memory
+    leak in WritePNMImage".
+
+  - coders/png.c (ReadMNGImage): Fix SourceForge issue #501 "memory
+    leak in ReadMNGImage".
+
+  - magick/segment.c (InitializeIntervalTree): Fix SourceForge issue
+    #507 "null pointer in segment.c" and issue #508 "null pointer in
+    segment.c".
+
+  - coders/topol.c (ReadTOPOLImage): Fix SourceForge issue #510
+    "null pointer and meory leak in topol.c".
+
+  - magick/widget.c (MagickXFileBrowserWidget): Fix SourceForge
+    issue #506 "null pointer in widget.c".
+
+  - coders/tiff.c (WriteTIFFImage): Fix SourceForge issue #509
+    "Memory leak in tiff.c".
+
+  - magick/module.c (FindMagickModule): Fix SourceForge issue #502
+    "null pointer in module.c".
+
+  - coders/avs.c (ReadAVSImage): Fix Coverity CID 184115 "Control
+    flow issues (DEADCODE)".
+
+2017-09-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/avs.c (ReadAVSImage): Fix SourceForge issue #499 "memory
+    leak in avs.c".
+
+  - coders/cmyk.c (ReadCMYKImage): Fix SourceForge issue #498
+    "memory leak in cmyk.c".
+
+  - coders/cut.c (ReadCUTImage): Fix SourceForge issue #497 "memory
+    leak in cut.c".
+
+  - coders/dpx.c (ReadDPXImage): Fix SourceForge issue #496 "memory
+    leak in dpx.c".
+
+  - coders/hdf.c (ReadHDFImage): Fix SourceForge issue #495 "memory
+    leak in hdf.c".
+
+  - coders/pcx.c (ReadPCXImage): Fix SourceForge issue #494 "memory
+    leak in pcx.c".
+
+  - coders/pcd.c (ReadPCDImage): Fix SourceForge issue #493 "memory
+    leak in ReadPCDImage".
+
+  - coders/histogram.c (WriteHISTOGRAMImage): Fix SourceForge issue
+    #492 "memory leak in WriteHISTOGRAMImage".
+
+  - coders/gif.c (WriteGIFImage): Fix SourceForge issue #491 "memory
+    leak in WriteGIFImage".
+
+  - coders/fits.c (WriteFITSImage): Fix SourceForge issue #490
+    "memory leak in WriteFITSImage".
+
+  - coders/palm.c (WritePALMImage): Fix SourceForge issue #489
+    "memory leak in WritePALMImage".
+
+  - coders/rgb.c (ReadRGBImage): Fix SourceForge issue #488 "Memory
+    leak in rgb.c".
+
+  - coders/palm.c (ReadPALMImage): Fix SourceForge issue #487 "NULL
+    pointer dereference in ReadPALMImage".
+
+  - Magick++/lib/Options.cpp (strokeDashArray): Fix SourceForge
+    issue #486 "NULL pointer dereference in
+    Magick::Options::strokeDashArray".
+
+  - magick/nt\_feature.c (NTGetTypeList): Fix SourceForge issue #485
+    "NULL pointer dereference in NTGetTypeList".
+
+  - coders/sun.c (ReadSUNImage): Fix SourceForge issue #484 "Memory
+    leak in sun.c".
+
+  - coders/tim.c (ReadTIMImage): Fix SourceForge issue #483 "Memory
+    leak in tim.c".
+
+  - magick/nt\_base.c (NTRegistryKeyLookup): Fix SourceForge issue
+    #482 "NULL pointer dereference in NTRegistryKeyLookup".
+
+  - coders/viff.c (ReadVIFFImage): Fix SourceForge issue #481
+    "Memory leak in viff.c".
+
+  - magick/profile.c (SetImageProfile): Fix SourceForge issue #480
+    "assertion failure in MagickMapAllocateMap".
+
+  - coders/yuv.c (ReadYUVImage): Fix SourceForge issue #478 "Memory
+    leak in yuv.c".
+
+  - magick/map.c (MagickMapCloneMap): Fix SourceForge issue #477
+    "assertion failure in MagickMapIterateNext".
+
+  - coders/emf.c (ReadEnhMetaFile): Fix SourceForge issue #475 "NULL
+    pointer dereference in ReadEnhMetaFile".
+
+  - coders/cineon.c (ReadCINEONImage): Fix SourceForge issue #473
+    "NULL pointer dereference in ReadCINEONImage"
+
+  - coders/tiff.c (TIFFIgnoreTags): Fix SourceForge issue #476 "NULL
+    Pointer in tiff.c".
+
+2017-09-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/blob.c (GetConfigureBlob): Fix SourceForge issue #472
+    "NULL Pointer in GetConfigureBlob".
+
+2017-09-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/rle.c (ReadRLEImage): Fix SourceForge issue #458 "Heap
+    out of bounds read in ReadRLEImage()".
+
+2017-09-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/sgi.c (ReadSGIImage): Check for EOF while reading SGI
+    file header.  Issue was brought to our attention by Petr Gajdos
+    via email on Fri, 1 Sep 2017.
+
+2017-09-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/tiff.c (ReadTIFFImage): Allow a single scanline, strip,
+    tile, to be 1000X larger than the input file in order to not cause
+    problems for extremely compressible images or tile sizes much
+    larger than the pixel dimensions.
+
+2017-09-16  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/symbols.h, wand/wand\_symbols.h: Update C library symbols
+    which should be prefixed with 'Gm'. However, GM will not move
+    Magick++ namespace because of the ImageMagick version.  Resolves
+    SourceForge issue #468 "--enable-symbol-prefix does not prevent
+    clashes with libMagick++ or libMagickWand?"
+
+  - coders/png.c (DestroyJNG): DestroyJNG should be a static
+    function.  Was wrongly exposed as DestroyJNGInfo in 1.3.26.  This
+    is not a public function and was not intended to be part of the
+    ABI.
+
+  - coders/tiff.c (ReadTIFFImage): Limit scanline, strip, and tile
+    memory allocations based on file size multiplied by a maximum
+    compression ratio.  Fixes SourceForge issues #460, #461, #462,
+    #463, #464 "allocation failure in ReadTIFFImage".
+
+  - coders/pnm.c (ReadPNMImage): Require that XV 332 format have 256
+    colors.  Fixes SourceForge issue #465 "NULL Pointer Dereference
+    triggered by malformed file".  In our own testing the test case
+    produced an assertion failure because assertions were enabled.
+
+  - magick/colormap.c (AllocateImageColormap): Use unsigned array
+    index.
+
+2017-09-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/mat.c (ReadMATImage): Fix CVE-2016-10070, which is a heap
+    overflow in the MAT reader due to an under-sized memory
+    allocation.  Based on private email from Petr Gajdos on Mon, 11
+    Sep 2017.
+
+2017-09-13  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Check MemoryResource before allocating
+    ping\_pixel array.
+
+2017-09-11  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - magick/shear.c: Possible evil loop might waste CPU for long time
+        without any reason.
+
+2017-09-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/render.c (DrawImage): Fix SourceForge issue #448 "Heap
+    out of bounds read in DrawDashPolygon()".  Problem was reported by
+    Kamil Frankowicz on August 28, 2017.
+
+  - coders/uil.c (WriteUILImage): Fix crash in UIL writer when
+    writing image containing transparency.  Issue was reported by
+    LCatro via email on 18 Jul 2017.
+
+  - coders/wpg.c (InsertRow): Fix crash which occurs if image is not
+    PseudoClass but a PseudoColor scanline is needed.  Resolves
+    SourceForge issue #449 "Null pointer dereference in InsertRow()".
+
+  - coders/rle.c (ReadRLEImage): Impose image dimension limits
+    according to Utah RLE specification. Cap number of planes handled
+    internally at 4.  Remove non-standard multi-frame extension, which
+    did not work anyway.
+
+2017-09-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadJNGImage): Complete fixing CVE-2017-8350 crash
+    while reading a malformed JNG file.
+
+  - coders/{html.c, map.c, plasma.c, png.c, psd.c, rle.c, stegano.c,
+    uil.c}: Downgrade claimed coder stability level for HTML, SHTML,
+    MAP, FRACTAL, PLASMA, JNG, MNG, RLE, STEGANO, and UIL formats.
+
+2017-09-08  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c (ReadJNGImage): More efforts toward fixing
+    CVE-2017-8350 while reading a malformed JNG file.
+
+2017-09-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/error.c (ThrowLoggedException): Capture the first
+    exception at ErrorException level or greater, or only capture
+    exception if it is more severe than an already reported exception.
+    This should help lead to better error reports since the first
+    error is usually the most significant.
+
+  - coders/png.c (ReadJNGImage): Add "improper header" exception
+    reporting.
+
+2017-09-01  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c (ReadJNGImage): Efforts toward fixing CVE-2017-8350
+    while reading a malformed JNG file.
+
+2017-08-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/wpg.c (ReadWPGImage): Patch submitted by Petr Gajdos to
+    check that .Width and .Height are greater than zero before they
+    are assigned to image->columns and image->rows respectively
+    (CVE-2014-9815).
+    (ReadWPGImage): Do more validations on WPG\_Palette.StartIndex and
+    WPG\_Palette.NumOfEntries.
+
+2017-08-29  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJNGImage): Fix for SourceForge issue #440
+    "use-after-free in CloseBlob (blob.c) (INCOMPLETE FIX FOR
+    CVE-2017-11403)" and SourceForge issue #438 "heap use after free
+    in CloseBlob".
+  - coders/png.c (ReadOneJNGImage): Fix for SourceForge issue #439
+    "assertion failure in magick/pixel\_cache.c"
+
+2017-08-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/mpeg.c (WriteMPEGImage): Fix MPEG writer memory leak.
+    Only the first image in the coalesce image list was being freed.
+    Problem was reported by LCatro via email on July 15, 2017.
+
+  - magick/attribute.c (TracePSClippingPath, TraceSVGClippingPath):
+    Fix SourceForge bug #447 "Heap out of bounds read in
+    ReadMSBShort()".
+
+2017-08-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/xbm.c (ReadXBMImage): Fix two denial of service (DOS)
+    issues in ReadXBMImage() which result in the reader not
+    returning. Problem was reported via email on Wed Aug 23 2017 by
+    Xiaohei and Wangchu from Alibaba Security Team.
+
+  - coders/jnx.c (ReadJNXImage): Fix denial of service (DOS) issue
+    in ReadJNXImage() whereby large amounts of CPU and memory
+    resources may be consumed although the file itself does not
+    support the requests.  Problem was reported via email on Wed Aug
+    23 2017 by Xiaohei and Wangchu from Alibaba Security Team.
+
+2017-08-14  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneMNGImage): Deal with invalid (too large)
+    length of MNG chunks (bug #446).
+
+2017-08-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pnm.c (ReadPNMImage): Verify that sufficient file data
+    exists to support what the file header requires before allocating
+    memory for it.  Fixes problem reported by Agostino Sarubbo via
+    email on Wed, 12 Jul 2017 and reported yet again via SourceForge
+    bug #441 "memory allocation failure in MagickRealloc".
+
+2017-08-20  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c: Fix SourceForge bug #433 "memory leak in
+    ReadMATImage".  Credit for discovering and reporting the problem
+    is "ADLab of Venustech".
+
+  - coders/sun.c (ReadSUNImage): Fix failure to allocate memory due
+    to inadequate file data to support claimed image width and height.
+    First notified by email from Agostino Sarubbo on 14 Jul 2017 and
+    then again as SourceForge bug #442 "memory allocation failure in
+    magickmalloc".
+
+2017-08-16  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/svg.c (GetStyleTokens): Fix SourceForge bugs 434 "heap
+    buffer overflow in GetStyleTokens", 435 "null pointer
+    dereference\_in\_SVGStartElement", and 436 "heap buffer overflow in
+    GetStyleTokens" which all originated from a heap buffer overflow
+    in GetStyleStokens(), or inconsistent initialization.  Now the
+    implementation truncates parsing for poorly-formed input (to avoid
+    buffer overflow) while still correctly parsing well-formed input.
+    The reproducers and problem reports are attributed to "ADLab of
+    Venustech".
+
+2017-08-14  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJNGImage): Fixed double-free after
+    reading a malformed JNG (Issue #438).
+
+2017-08-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pcd.c (ReadPCDImage): Fix memory leak on return path due
+    to corrupted header.  Patch included in email on 14 Aug 2017 by
+    Petr Gajdos (ImageMagick CVE CVE-2017-8351).
+
+2017-08-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/gif.c (ReadGIFImage): Assure that global colormap is
+    initialized.
+
+  - coders/pict.c (ReadPICTImage): Fix memory leaks in error return
+    path.  ImageMagick CVE CVE-2017-8353.  Patch by Petr Gajdos.
+
+2017-08-11  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - tests/rwblob.c and rwfile.c: Write the reason for FAIL in
+    test-suite.log.
+  - magick/image.h: Revised table of image orientations to show
+    Exif ImageOrientation values (which happen to be the same as
+    the enum values 1 to 8).
+  - coders/png.c: ReadJNGIMage(): fix memory leak (Issue 431).
+
+2017-08-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/mtv.c (ReadMTVImage): Fix memory leak in error return
+    path upon unexpected EOF (ImageMagick CVE-2017-9142).  Problem was
+    brought to our attention via email from Petr Gajdos on Wed, 9 Aug
+    2017.  Also changed pixel cache access functions used to assure
+    delivery of exception to the user.
+
+2017-08-05  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - configure.ac (SETJMP\_IS\_THREAD\_SAFE): Decide if setjmp/longjmp
+    are thread safe based on host OS.  Assume that these interfaces
+    are thread safe by default.  Declared not to be thread safe under
+    Solaris.  Declaring these interfaces to be thread safe increases
+    available concurrency for coders which use setjmp/longjmp for
+    error recovery (e.g. PNG and JPEG).
+
+2017-08-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/jpeg.c (RegisterJPEGImage): Add support for the
+    SETJMP\_IS\_THREAD\_SAFE preprocessor definition (already used by
+    coders/png.c) to indicate if setjmp/longjmp are thread safe on
+    this platform and that it is safe for multiple encoders/decoders
+    to be active at one time.
+
+2017-07-31  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/sun.c: Fix heap read overflow while indexing into
+    colormap. Problem was reported via email on 17 Jul 2017 by
+    Agostino Sarubbo.
+
+2017-07-31  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c (ReadMNGImage): Stop a leak when rejecting a
+    MNG image with dimensions that are too large.
+
+2017-07-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/wmf.c (ReadWMFImage): Eliminate use of already freed heap
+    data in error reporting path.  Problem was reported via email by
+    Agostino Sarubbo on Fri, 14 Jul 2017
+
+2017-07-25  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c (ReadMNGImage) Free chunk allocation that remains
+    after attempting to read a truncated file.
+  - coders/png.c: Removed some redundant checks for chunk length
+    before MagickFreeMemory(chunk), which is safe to call with a
+    NULL argument.
+  - coders/png.c: Fixed writer bug due to missing brackets; a Log
+    statement should have been inside the "i" loop but instead was
+    using i++ left over from the loop.  Bug report by L. Catro.
+  - coders/png.c: Reject a MNG with dimensions greater than 65k
+    by 65k.
+  - coders/png.c (WriteOnePNGImage): Return without crashing if
+    WriteOnePNGImage is passed a NULL image. Fixes CVE-2017-11522.
+
+2017-07-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pcl.c (WritePCLImage): Fix null pointer dereference in
+    PCL writer when writing monochrome images.  Problem was reported
+    by LCatro via email on July 18.
+
+  - magick/pixel\_cache.c (PersistCache): Fix memory leak while
+    writing a MPC file.  Problem was reported by LCatro via email on
+    July 18.
+
+  - coders/map.c (WriteMAPImage): Fix null pointer dereference or
+    segmentation violation in the MAP writer if the input image is not
+    already colormapped.  Problem was reported by LCatro via email on
+    July 18.
+
+  - coders/gray.c (WriteGRAYImage): Improve tracing and tidy up.
+
+  - coders/rgb.c (WriteRGBImage): Fix heap overwrite in raw RGB
+    writer (all output subformats) given a multiframe sequence using
+    different widths.  Problem was reported by LCatro via email on
+    July 18.
+
+  - coders/cmyk.c (WriteCMYKImage): Fix heap overwrite in raw CMYK
+    writer (all output subformats) given a multiframe sequence using
+    different widths.  Also fix wrong output of CMYKA (and vice-versa)
+    when CMYK was intended.  Problem was reported by LCatro via email
+    on July 18.
+
+  - coders/palm.c: Disable the PALM writer since the writer is a
+    work in progress and still has implementation problems.  Perhaps
+    no one in the world remains who cares about the undocumented PALM
+    format.  Resolves heap overflow and assertion issues reported by
+    LCatro via emails on July 11th, and 12th, 2017.
+
+  - magick/colormap.c (ReplaceImageColormap): Throw an exception
+    rather than assertion if the input image is not colormapped.
+
+2017-07-13  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Implemented eXIf chunk support.
+
+2017-07-12  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Fix typecast of left shifts (patch by Bob F)
+
+2017-07-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/ps.c (ReadPSImage): Fix reference to constant NULL image
+    argument which is dereferenced to pass an exception to
+    MagickMonitorFormatted().  Problem was reported by Agostino
+    Sarubbo via email on Wed, 12 Jul 2017.
+
+2017-07-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/blob.c: Add casts to fix undefined behavior in left
+    shifts.  Issue was reported by Agostino Sarubbo via email on Mon,
+    10 Jul 2017.
+
+2017-07-10  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJNGImage): Ignore out-of-bounds MOVE
+    and CLIP object\_id's.
+  - coders/png.c (ReadMNGImage): Fix apparent off-by-one error
+    in MNG FRAM change\_clipping processing.
+  - coders/png.c (ReadMNGImage): Fix out-of-order CloseBlob()
+    and DestroyImageList() that caused a use-after-free crash.
+    Fixes CVE-2017-11403.  This bug was discovered by Agostino Sarubbo.
+
+2017-07-08  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJngImage): Revised double-free fix.
+
+2017-07-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJNGImage): Fix double-frees caused by
+    commit on 2017-07-06.
+
+  - coders/jpeg.c (ReadJPEGImage): Defer creating pixel cache until
+    after successfully reading first scanline.  Classify some serious
+    libjpeg reported "warnings" as errors and quit processing
+    scanlines immediately upon first error so that corrupt JPEG does
+    not consume excessive resources.  Resolves excessive resource
+    consumption issue reported for two JPEG files provided via email
+    by LCatro on Tue, 4 Jul 2017.
+
+2017-07-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJNGImage): Remove spurious '\n' from log
+    statement.
+
+2017-07-06  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Consolidate JNG cleanup into a new DestroyJNG()
+    function.
+
+2017-07-05  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: prevent a crash due to zero-length color\_image
+    while reading a JNG image. (CVE-2017-11102)
+
+2017-07-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - NEWS.txt: Make sure is up to date.
+
+  - www/index.rst: Update for 1.3.26 release.
+
+  - version.sh: Update library versioning for 1.3.26 release.
+
+  - magick/command.c (BatchCommand): Add ferror() checks around
+    batch input loop.
+
+2017-07-03  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Reject a PNG file if the file size is too small
+    (less than 61 bytes).  Reject a JNG file if it is too small (less
+    than 147 bytes).
+  - coders/jpeg.c: Reject a JPEG file if the file size is too small
+    (less than 107 bytes).
+
+2017-07-02  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dpx.c (ReadDPXImage): Compute required file size and
+    verify that sufficient data exists in file before allocating
+    memory to decode the image data.  Resolves problem with DPX file
+    with valid header (but a huge claimed image width) provided
+    provided via email on Thu, 29 Jun 2017 by LCatro.  This issue has
+    been assigned CVE-2017-10799.
+
+2016-07-02  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c Check whether reported object size overflows file size.
+
+2016-07-01  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c Safety check for forged and or corrupted data.
+    This issue has been assigned CVE-2017-10800.
+
+2017-07-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/tiff.c ("QuantumTransferMode"): Use a generalized method
+    to enforce that buffer overflow can not happen while importing
+    pixels.  Resolves problem with RGB TIFF claiming only one sample
+    per pixel provided via email on Thu, 29 Jun 2017 by LCatro.  This
+    issue has been assigned CVE-2017-10794.
+
+2017-06-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/command.c: Convert bare 'unsigned int' to MagickPassFail
+    where suitable to make intentions clear.  Convert True/False to
+    MagickTrue/MagickFalse or MagickPass/MagickFail according to
+    purpose.  This is a continuation of a gradual migration and does
+    not represent an API change.
+
+2017-06-25  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Avoid NULL dereference when MAGN chunk processing
+    fails (https://sourceforge.net/p/graphicsmagick/bugs/426/). Expand
+    TABs.
+
+2017-06-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - NEWS.txt: Update NEWS with changes since the previous release.
+
+  - www/programming.rst: Switch the Lua link to
+    https://github.com/arcapos/luagraphicsmagick, which is a more
+    complete and direct interface from Lua to GraphicsMagick's Wand
+    API.
+
+2017-06-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - VisualMagick/installer/gm-foo-dll.iss: Remove PerlMagick from
+    the slim Inno Setup installer builder and remove mention of
+    PerlMagick from the installer documentation.
+
+  - TclMagick/generic/TclMagick.c (magickCmd): Resolve SourceForge
+    patch #51 "TclMagick: memory access error; possible segfault".
+    (newMagickObj): Fix formatting of pointer value so it is 64-bit
+    safe.  Resolves SourceForge patch #50 "TclMagick: 64-bit
+    portability issue".
+
+  - coders/pict.c (ReadPICTImage): Avoid possible use of negative
+    value when indexing array, which would cause buffer overflow.
+    Resolves SourceForge issue #427 "One possible buffer overflow
+    vulnerability in
+    GraphicsMagick-1.3.25/coders/pict.c:ReadPICTImage()".
+
+2017-06-22  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Stop memory leak when reading invalid JNG image.
+    Fixes CVE-2017-8350.
+
+2017-06-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c: Fix lcms2.h inclusion logic.
+
+  - wand/magick\_wand.c (MagickSetImageOrientation): Eliminate use of
+    snprintf, which is not supported by older Visual Studio.
+
+2017-06-09  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Accept exIf chunks whose data segment
+    erroneously begins with "Exif\0\0".
+
+2017-06-01  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Removed experimental zxIF chunk support.  That
+    proposal is dead.
+
+2017-05-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - config/log.mgk: Added documentation suggested by SourceForge
+    issue #419 "Consider a small patch to log.mgk".
+
+  - www/Changes.rst: Add missing link to most recent changes.
+
+2017-05-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - www/Magick++/Image.rst: Improve documentation for Magick++
+    Image::iccColorProfile() and Image::renderingIntent().
+
+2017-05-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - tiff: Update to libtiff 4.0.8.
+
+2017-03-19  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Quieted a new Coverity complaint about a potential
+    text buffer overrun.
+
+2017-03-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/image.c (SetImageInfo): Ignore empty magic prefix
+    specification and do not remove colon character from start of
+    filename.  Resolves SourceForge bug #415 "Inconsistent Behavior w/
+    input\_file Parameter".
+
+2017-03-18  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Added new private orNT PNG chunk, to
+    preserve image->orientation when it is defined and not
+    the default TopLeft.
+  - coders/jpeg.c: Mention image->orientation in the log when
+    writing a JPEG.
+
+2017-03-15  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c (WriteOnePNGImage): Add version info about
+    gm, libpng, zlib, and lcms to the PNG debug log.
+
+2017-03-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/command.c (ImportImageCommand): Fix handling of -frame
+    options. Option handling was incorrect due to option checking the
+    frame option after it had been freed.  Checking the frame dash
+    option before freeing the argument solves the problem.  From patch
+    provided by Victor Ananjevsky as SourceForge patch #49 "-frame
+    doesn't work in gm import".
+
+  - Magick++/lib/Image.cpp (attribute): Added Image attribute method
+    which accepts a 'char \*' argument, and will remove the attribute
+    if the value argument is NULL.  From patch provided by "Gints" as
+    SourceForge patch #46 "C++ api - method to clear/remove
+    attribute".
+
+  - VisualMagick/configure/configure.cpp (InitInstance): Applied
+    patch by Paul McConkey to allow the quantum command line argument
+    to set the default value in the wizard drop list.  This allows
+    setting the quantum depth when the /nowizard argument was
+    supplied.  Resolves SourceForge patch #48 "When running from the
+    command line configure.exe does not use the quantum argument".
+    The provided configure.exe still needs to be rebuilt to
+    incorporate this change.
+
+  - magick/command.c (MogrifyImage): The -orient command now also
+    updates the orientation in the EXIF profile, if it exists.
+
+  - Magick++/lib/Image.cpp (orientation): Update orientation in EXIF
+    profile, if it exists.
+
+2017-03-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/jp2.c: Support PGX JPEG 2000 format for reading and
+    writing (within the bounds of what JasPer supports).
+
+2017-02-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/tiff.c (QuantumTransferMode): Fix out of bounds read when
+    reading CMYKA TIFF which claims to have only 2 samples per pixel.
+    Problem was reported via email on February 15, 2017 by Valon
+    Chu. This issue was assigned CVE-2017-6335.
+
+2017-01-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - doc/options.imdoc (-geometry): Geometry documentation changes
+    suggested by Jon Wong.
+
+2017-01-26  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Added support for a proposed new PNG chunk
+    (zxIf, read-only) that is currently being discussed on the
+    png-mng-misc at lists.sourceforge.net mailing list.  Enable
+    exIf and zxIf with CPPFLAGS="-DexIf\_SUPPORTED -DxzIf\_SUPPORTED".
+    If exIf is enabled, only the uncompressed exIF chunk will be
+    written and the hex-encoded zTXt chunk containing the raw Exif
+    profile won't be written.
+
+2017-01-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/msl.c (MSLStartElement): Change test for NULL image
+    pointer to before it is used rather than after it is used.
+    Problem reported by Petr Gajdos on 2017-01-25.
+
+2017-01-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - TclMagick/unix/m4/tcl.m4: Update tcl.m4 to TEA 3.10.  File
+    supplied by Massimo Manghi.
+
+2017-01-21  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Added support for a proposed new PNG
+    chunk (exIf read-write, eXIf read-only) that is currently
+    being discussed on the png-mng-misc at lists.sourceforge.net
+    mailing list.
+
+2017-01-21  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+
+  - coders/png.c: Added read\_user\_chunk\_callback() function
+    and used it to implement a private PNG caNv (canvas) chunk
+    for remembering the original dimensions and offsets when an
+    image is cropped.  Previously we used the oFFs chunk for this
+    purpose, but this had potential conflicts with other applications
+    that also use the oFFs chunk.
+
+2017-01-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - TclMagick/Makefile.am (AM\_DISTCHECK\_CONFIGURE\_FLAGS): Applied
+    patch by Massimo Manghi to set AM\_DISTCHECK\_CONFIGURE\_FLAGS so
+    that 'make distcheck' remembers configuration options, and also to
+    uninstall pkgIndex.tcl.
+
+  - magick/image.c (SetImageEx): Use PixelIterateMonoSet() for
+    possibly improved efficiency.
+
+  - magick/pixel\_iterator.c (PixelIterateMonoSet): New pixel
+    iterator intended for use when initializing image pixels, without
+    regard to existing values.
+
+2017-01-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - Copyright.txt: Bump copyright years and rotate ChangeLog.
+
+
index f98b69b..ec73f11 100644 (file)
 <div class="document">
 
 
-<p>2017-07-04  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-11-17  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>NEWS.txt: Make sure is up to date.</li>
-<li>www/index.rst: Update for 1.3.26 release.</li>
-<li>version.sh: Update library versioning for 1.3.26 release.</li>
-<li>magick/command.c (BatchCommand): Add ferror() checks around
-batch input loop.</li>
+<li>www/index.rst: Update in preparation for 1.3.31 release.</li>
+<li>version.sh: Update library versioning in preparation for
+1.3.31 release.</li>
+<li>NEWS.txt: Update news in preparation for 1.3.31 release.</li>
 </ul>
 </blockquote>
-<p>2017-07-03  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-11-15  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/png.c: Reject a PNG file if the file size is too small
-(less than 61 bytes).  Reject a JNG file if it is too small (less
-than 147 bytes).</li>
-<li>coders/jpeg.c: Reject a JPEG file if the file size is too small
-(less than 107 bytes).</li>
+<li>magick/command.c (BenchmarkUsage): Document the benchmark
+command better.</li>
 </ul>
 </blockquote>
-<p>2017-07-02  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-11-14  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/dpx.c (ReadDPXImage): Compute required file size and
-verify that sufficient data exists in file before allocating
-memory to decode the image data.  Resolves problem with DPX file
-with valid header (but a huge claimed image width) provided
-provided via email on Thu, 29 Jun 2017 by LCatro.  This issue has
-been assigned CVE-2017-10799.</li>
+<li>magick/resize.c (HorizontalFilter, VerticalFilter): quantum is a
+pointer so it's value can not be usefully flushed.  Use a local
+variable and then update quantum pointer when done.</li>
 </ul>
 </blockquote>
-<p>2016-07-02  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<p>2018-11-11  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/mat.c Check whether reported object size overflows file size.</li>
+<li>magick/*: Changed row_count tallying to use 'omp atomic' and
+status update to use 'omp flush' for progress and error
+indication.  This replaces most use of 'omp critical' for this
+purpose.  Changed some lumpy algorithms which were using 'static'
+scheduling to 'guided' scheduling due to observing better results.
+Also added prolific 'restrict' annotations where they were
+missing.</li>
+<li>www/security.rst: Documented a PGP private key for file signing
+or private correspondence.</li>
 </ul>
 </blockquote>
-<p>2016-07-01  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<p>2018-11-10  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/mat.c Safety check for forged and or corrupted data.
-This issue has been assigned CVE-2017-10800.</li>
+<li>www/authors.rst: Moved &quot;Glenn Randers-Pehrson&quot; and &quot;Gregory J
+Wolfe&quot; to the &quot;Former Contributor&quot; category.</li>
 </ul>
 </blockquote>
-<p>2017-07-01  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-11-09  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/tiff.c (&quot;QuantumTransferMode&quot;): Use a generalized method
-to enforce that buffer overflow can not happen while importing
-pixels.  Resolves problem with RGB TIFF claiming only one sample
-per pixel provided via email on Thu, 29 Jun 2017 by LCatro.  This
-issue has been assigned CVE-2017-10794.</li>
+<li>Added many GCC function annotations in the libraries and coders.</li>
 </ul>
 </blockquote>
-<p>2017-06-29  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-11-07  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>magick/command.c: Convert bare 'unsigned int' to MagickPassFail
-where suitable to make intentions clear.  Convert True/False to
-MagickTrue/MagickFalse or MagickPass/MagickFail according to
-purpose.  This is a continuation of a gradual migration and does
-not represent an API change.</li>
+<li>configure.ac: Use printf rather than echo to portably expand tab
+requests in configuration summary.</li>
 </ul>
 </blockquote>
-<p>2017-06-25  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-11-01  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/png.c: Avoid NULL dereference when MAGN chunk processing
-fails (<a class="reference external" href="https://sourceforge.net/p/graphicsmagick/bugs/426/">https://sourceforge.net/p/graphicsmagick/bugs/426/</a>). Expand
-TABs.</li>
+<li>configure.ac: Use pkg-config data as the initial choice when
+configuring for FreeType 2.0 and libxml-2.0.  Only fall back to
+invoking an external script (and then traditional methods) if
+pkg-config fails.</li>
+<li>coders/msl.c (ProcessMSLScript): Release msl_image if OpenBlob
+fails.  Similar to ImageMagick CVE-2018-18544.  Problem was
+reported to us via email from Petr Gajdos on Thu, 1 Nov 2018.</li>
 </ul>
 </blockquote>
-<p>2017-06-25  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-10-27  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>NEWS.txt: Update NEWS with changes since the previous release.</li>
-<li>www/programming.rst: Switch the Lua link to
-<a class="reference external" href="https://github.com/arcapos/luagraphicsmagick">https://github.com/arcapos/luagraphicsmagick</a>, which is a more
-complete and direct interface from Lua to GraphicsMagick's Wand
-API.</li>
+<li>coders/miff.c (WriteMIFFImage): Only run
+strlen(attribute-&gt;value) once per attribute since the length won't
+change.  May address oss-fuzz 11158
+&quot;graphicsmagick/coder_MIFF_fuzzer: Timeout in
+graphicsmagick_coder_MIFF_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>Fix compilation warnings observed with GCC 8.2.0.</li>
 </ul>
 </blockquote>
-<p>2017-06-24  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-10-26  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>VisualMagick/installer/gm-foo-dll.iss: Remove PerlMagick from
-the slim Inno Setup installer builder and remove mention of
-PerlMagick from the installer documentation.</li>
-<li>TclMagick/generic/TclMagick.c (magickCmd): Resolve SourceForge
-patch #51 &quot;TclMagick: memory access error; possible segfault&quot;.
-(newMagickObj): Fix formatting of pointer value so it is 64-bit
-safe.  Resolves SourceForge patch #50 &quot;TclMagick: 64-bit
-portability issue&quot;.</li>
-<li>coders/pict.c (ReadPICTImage): Avoid possible use of negative
-value when indexing array, which would cause buffer overflow.
-Resolves SourceForge issue #427 &quot;One possible buffer overflow
-vulnerability in
-GraphicsMagick-1.3.25/coders/pict.c:ReadPICTImage()&quot;.</li>
+<li>magick/pixel_iterator.c (PixelIterateMonoModifyImplementation):
+Use atomic and flush rather than critical construct for a small
+speedup.</li>
+<li>magick/monitor.c (MagickMonitorFormatted): Serialize calls to
+the progress monitor so that the caller does not need to perform
+this serialization.
+(MagickMonitor): Serialize calls to the progress monitor so that
+the caller does not need to perform this serialization.  This
+function is now marked as deprecated.
+(InitializeMagickMonitor): New private function to initialize
+monitor functionality.
+(DestroyMagickMonitor): New private function to destroy monitor
+functionality.</li>
 </ul>
 </blockquote>
-<p>2017-06-22  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-10-23  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/png.c: Stop memory leak when reading invalid JNG image.
-Fixes CVE-2017-8350.</li>
+<li>coders/gif.c (ReadGIFImage): Improve the efficiency of storing a
+GIF comment in order to avoid a DOS opportunity.  Fixes oss-fuzz
+11096 &quot;graphicsmagick/coder_GIF_fuzzer: Timeout in
+graphicsmagick_coder_GIF_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
 </ul>
 </blockquote>
-<p>2017-06-18  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-10-21  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/png.c: Fix lcms2.h inclusion logic.</li>
-<li>wand/magick_wand.c (MagickSetImageOrientation): Eliminate use of
-snprintf, which is not supported by older Visual Studio.</li>
+<li>PerlMagick/Makefile.PL.in: Use MAGICK_API_LIBS to obtain the
+list of libraries to use when linking.</li>
+<li>configure.ac: OpenMP library is normally supplied due to a
+CFLAGS option so only supply it in cases where the CFLAGS option
+may be lost or it might not be used.  Otherwise the compiler may
+apply the library twice when linking.</li>
 </ul>
 </blockquote>
-<p>2017-06-09  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-10-20  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/png.c: Accept exIf chunks whose data segment
-erroneously begins with &quot;Exif00&quot;.</li>
+<li>configure.ac: Remove Ghostscript library support (--with-gslib)
+from configure script.  The 'HasGS' pre-processor defines which
+were enabled by this remain in the source code so it is still
+possible to use this library if absolutely necessary
+(e.g. CPPFLAGS=-DHasGS LIBS=-lgs).</li>
+<li>tests/rwfile.tap: Test TIFF format with all supported
+compression options.</li>
+<li>tests/{rwblob.c, rwfile.c} (main): Use StringToCompressionType()
+to parse compression option. Also consider requested compression
+algorithm when deciding if format is lossy.</li>
+<li>coders/tiff.c (WriteTIFFImage): WebP compression needs
+PHOTOMETRIC_RGB. Fix wrong rows-per-strip calculation when using
+LZMA compression.</li>
+<li>tests/rwblob.tap: Added a rwblob test to verify that lower-case
+magick works.</li>
+<li>magick/static.c (OpenModule): Upper case magick string before
+searching static modules list.  Fixes Debian bug 911386
+&quot;libgraphicsmagick-q16-3: graphicsmagick 1.3.30 has made formats
+case-sensitive at the API level&quot;.</li>
+<li>filters/analyze.c (AnalyzeImage): X and y should be unsigned
+long to match image rows/columns type.  Calculate total pixels by
+simple multiplication rather than counting.</li>
 </ul>
 </blockquote>
-<p>2017-06-01  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-10-14  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/png.c: Removed experimental zxIF chunk support.  That
-proposal is dead.</li>
+<li>coders/tiff.c (WriteTIFFImage): Support WebP compression in
+TIFF. This requires a libtiff release after 4.0.9.</li>
+<li>magick/image.h (&quot;C&quot;): WebPCompression added to CompressionType
+enumeration.</li>
 </ul>
 </blockquote>
-<p>2017-05-27  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-10-13  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>config/log.mgk: Added documentation suggested by SourceForge
-issue #419 &quot;Consider a small patch to log.mgk&quot;.</li>
-<li>www/Changes.rst: Add missing link to most recent changes.</li>
+<li>configure.ac: Configure for the Zstd library.  Use
+--without-zstd to disable searching for this library.  Libtiff may
+require this library to successfully link so static linkage could
+fail if searching for libzstd is disabled.</li>
+<li>magick/image.h (&quot;C&quot;): ZSTDCompression added to CompressionType
+enumeration.</li>
+<li>coders/tiff.c (WriteTIFFImage): Support Zstd compression in
+TIFF.  This requires a libtiff release after 4.0.9.</li>
 </ul>
 </blockquote>
-<p>2017-05-24  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-10-10  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>www/Magick++/Image.rst: Improve documentation for Magick++
-Image::iccColorProfile() and Image::renderingIntent().</li>
+<li>magick/command.c (GMCommandSingle): Add 'compare' to the list of
+command names that gm will support as a command if copied to or
+linked from that name.  There was already a 'compare' link
+installed when the '--enable-magick-compat' configure option is
+used, but it could not possibly function without being blessed by
+this list.  Related to Debian bug #910652
+&quot;graphicsmagick-imagemagick-compat: Doesn't ship a compare tool&quot;.</li>
 </ul>
 </blockquote>
-<p>2017-05-21  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-09-30  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>tiff: Update to libtiff 4.0.8.</li>
+<li>Magick++/lib/Magick++/Drawable.h: Block unused-private-field
+warnings from Clang due to _dummy members which were intentionally
+included in some parent class definitions.</li>
+<li>magick/widget.c (XEditText): Fix compilation warnings about
+cases which fall-through.</li>
+<li>magick/display.c (MagickXAnnotateEditImage): Fix compilation
+warnings about cases which fall-through.</li>
+<li>coders/pict.c (WritePICTImage): Add more checks to memory
+allocation calculations.</li>
+<li>magick/pixel_cache.c (DestroyCacheInfo): Eliminate intentional
+fall-through logic in switch statement which results in compiler
+warnings.  Eliminate switch statements entirely and split
+unrelated logic.</li>
+<li>coders/txt.c (ReadTXTImage): Fix comparison between pointer and
+'0' rather than NULL as was obviously intended.</li>
+<li>coders/msl.c (MSLStartElement): Add missing 'break' statements
+after ThrowException() calls.  Otherwise execution falls through
+into unrelated switch cases and throws a redundant exception.</li>
 </ul>
 </blockquote>
-<p>2017-03-19  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-09-29  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/png.c: Quieted a new Coverity complaint about a potential
-text buffer overrun.</li>
+<li>coders/meta.c (parse8BIM): Eliminate repeated use of strlen()
+which scans the entire remaining string on each cycle.  Fixes
+oss-fuzz 10667 &quot;graphicsmagick/coder_IPTCTEXT_fuzzer: Timeout in
+graphicsmagick_coder_IPTCTEXT_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
 </ul>
 </blockquote>
-<p>2017-03-19  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-09-26  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>magick/image.c (SetImageInfo): Ignore empty magic prefix
-specification and do not remove colon character from start of
-filename.  Resolves SourceForge bug #415 &quot;Inconsistent Behavior w/
-input_file Parameter&quot;.</li>
+<li>magick/utility.c (MagickGetToken): Fix possible read up to four
+bytes beyond end of stack allocated token buffer.  Fixes oss-fuzz
+10653 &quot;graphicsmagick/coder_MVG_fuzzer: Stack-buffer-overflow in
+MagickGetToken&quot;. (Credit to OSS-Fuzz)</li>
 </ul>
 </blockquote>
-<p>2017-03-18  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-09-22  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/png.c: Added new private orNT PNG chunk, to
-preserve image-&gt;orientation when it is defined and not
-the default TopLeft.</li>
-<li>coders/jpeg.c: Mention image-&gt;orientation in the log when
-writing a JPEG.</li>
+<li>fuzzing/coder_fuzzer.cc (LLVMFuzzerTestOneInput): Limit the
+maximum number of JPEG progressive scans to 50.</li>
+<li>coders/jpeg.c (ReadJPEGImage): Apply a default limit of 100
+progressive scans before the reader quits with an error.  This
+limit may be adjusted using the -define mechanism like -define
+JPEG:max-scan-number=500.  Also respond more quickly to files
+which exceed the maximum image dimensions.  Fixes oss-fuzz 10258
+&quot;graphicsmagick/coder_JPEG_fuzzer: Timeout in
+graphicsmagick_coder_JPEG_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
 </ul>
 </blockquote>
-<p>2017-03-15  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-09-20  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/png.c (WriteOnePNGImage): Add version info about
-gm, libpng, zlib, and lcms to the PNG debug log.</li>
+<li>coders/png.c (ReadMNGImage): mng_LOOP chunk must be at least 5
+bytes long.  Fixes oss-fuzz 10455
+&quot;graphicsmagick/coder_MNG_fuzzer: Use-of-uninitialized-value in
+ReadMNGImage&quot;. (Credit to OSS-Fuzz)</li>
 </ul>
 </blockquote>
-<p>2017-03-04  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-09-15  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>magick/command.c (ImportImageCommand): Fix handling of -frame
-options. Option handling was incorrect due to option checking the
-frame option after it had been freed.  Checking the frame dash
-option before freeing the argument solves the problem.  From patch
-provided by Victor Ananjevsky as SourceForge patch #49 &quot;-frame
-doesn't work in gm import&quot;.</li>
-<li>Magick++/lib/Image.cpp (attribute): Added Image attribute method
-which accepts a 'char *' argument, and will remove the attribute
-if the value argument is NULL.  From patch provided by &quot;Gints&quot; as
-SourceForge patch #46 &quot;C++ api - method to clear/remove
-attribute&quot;.</li>
-<li>VisualMagick/configure/configure.cpp (InitInstance): Applied
-patch by Paul McConkey to allow the quantum command line argument
-to set the default value in the wizard drop list.  This allows
-setting the quantum depth when the /nowizard argument was
-supplied.  Resolves SourceForge patch #48 &quot;When running from the
-command line configure.exe does not use the quantum argument&quot;.
-The provided configure.exe still needs to be rebuilt to
-incorporate this change.</li>
-<li>magick/command.c (MogrifyImage): The -orient command now also
-updates the orientation in the EXIF profile, if it exists.</li>
-<li>Magick++/lib/Image.cpp (orientation): Update orientation in EXIF
-profile, if it exists.</li>
+<li>magick/render.c (TraceEllipse): Detect arithmetic overflow when
+computing the number of points to allocate for an ellipse.  Fixes
+oss-fuzz 10306 &quot;graphicsmagick/coder_MVG_fuzzer:
+Heap-buffer-overflow in TracePoint&quot;. (Credit to OSS-Fuzz)</li>
 </ul>
 </blockquote>
-<p>2017-03-03  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-09-12  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/jp2.c: Support PGX JPEG 2000 format for reading and
-writing (within the bounds of what JasPer supports).</li>
+<li>magick/attribute.c (GenerateEXIFAttribute): Eliminate undefined
+shift.  Also right-sized involved data types.  Fixes oss-fuzz
+10309 &quot;graphicsmagick/coder_JPG_fuzzer: Undefined-shift in
+Read32s&quot;. (Credit to OSS-Fuzz)</li>
 </ul>
 </blockquote>
-<p>2017-02-23  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-09-09  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/tiff.c (QuantumTransferMode): Fix out of bounds read when
-reading CMYKA TIFF which claims to have only 2 samples per pixel.
-Problem was reported via email on February 15, 2017 by Valon
-Chu. This issue was assigned CVE-2017-6335.</li>
+<li>magick/render.c (DrawClipPath): Fix Coverity 319663 &quot;Null
+pointer dereferences&quot;.  Totally insignificant.</li>
+<li>coders/wpg.c (ReadWPGImage): Mask/fix Coverity 319664 &quot;Error
+handling issues&quot;.</li>
+<li>magick/attribute.c (FindEXIFAttribute): Change size types from
+signed to unsigned and check for unsigned overflow.
+(GenerateEXIFAttribute): Change size types from signed to unsigned
+and check for unsigned overflow. Fixes oss-fuzz 10283
+&quot;graphicsmagick/coder_JPG_fuzzer: Integer-overflow in
+GenerateEXIFAttribute&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/sfw.c (ReadSFWImage): Enforce that file is read using the
+JPEG reader. (Credit to OSS-Fuzz)</li>
+<li>coders/miff.c (ReadMIFFImage): Fix leak of 'values' buffer due
+to change made yesterday.</li>
+<li>coders/mpc.c (ReadMPCImage): Fix leak of 'values' buffer due to
+change made yesterday.  Fixes oss-fuzz 10277
+&quot;graphicsmagick/coder_MPC_fuzzer: Direct-leak in
+ReadMPCImage&quot;. (Credit to OSS-Fuzz)</li>
 </ul>
 </blockquote>
-<p>2017-01-29  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-09-08  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>doc/options.imdoc (-geometry): Geometry documentation changes
-suggested by Jon Wong.</li>
+<li>coders/miff.c (ReadMIFFImage): Support legacy keyword
+'color-profile' for ICC color profile as was used by ImageMagick
+4.2.9.</li>
+<li>coders/mpc.c (ReadMPCImage): Require that first keyword/value be
+id=MagickCache</li>
+<li>coders/miff.c (ReadMIFFImage): Require that first keyword/value
+be id=ImageMagick.</li>
 </ul>
 </blockquote>
-<p>2017-01-26  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-09-06  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/png.c: Added support for a proposed new PNG chunk
-(zxIf, read-only) that is currently being discussed on the
-png-mng-misc at lists.sourceforge.net mailing list.  Enable
-exIf and zxIf with CPPFLAGS=&quot;-DexIf_SUPPORTED -DxzIf_SUPPORTED&quot;.
-If exIf is enabled, only the uncompressed exIF chunk will be
-written and the hex-encoded zTXt chunk containing the raw Exif
-profile won't be written.</li>
+<li>coders/dcm.c (DCM_ReadElement): Add more size checks.</li>
+<li>coders/jnx.c (ExtractTileJPG): Enforce that JPEG tiles are read
+by the JPEG coder.  Fixes oss-fuzz 10147
+&quot;graphicsmagick/coder_JNX_fuzzer: Use-of-uninitialized-value in
+funcDCM_PhotometricInterpretation&quot;. (Credit to OSS-Fuzz)</li>
 </ul>
 </blockquote>
-<p>2017-01-25  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-09-10  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/msl.c (MSLStartElement): Change test for NULL image
-pointer to before it is used rather than after it is used.
-Problem reported by Petr Gajdos on 2017-01-25.</li>
+<li>coders/wpg.c Zero fill raster error recovery.</li>
 </ul>
 </blockquote>
-<p>2017-01-22  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-08-29  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>TclMagick/unix/m4/tcl.m4: Update tcl.m4 to TEA 3.10.  File
-supplied by Massimo Manghi.</li>
+<li>magick/render.c (ConvertPrimitiveToPath): Second attempt to
+prevent heap write overflow of PathInfo array.  Fixes oss-fuzz
+10096 &quot;Heap-buffer-overflow in ConvertPrimitiveToPath&quot;. (Credit to
+OSS-Fuzz)</li>
 </ul>
 </blockquote>
-<p>2017-01-21  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-08-25  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/png.c: Added support for a proposed new PNG
-chunk (exIf read-write, eXIf read-only) that is currently
-being discussed on the png-mng-misc at lists.sourceforge.net
-mailing list.</li>
+<li>coders/tiff.c (&quot;QuantumTransferMode&quot;): CIE Log images with an
+alpha channel are not supported.  Fixes oss-fuzz 10013
+&quot;graphicsmagick/coder_TIFF_fuzzer: Use-of-uninitialized-value in
+DisassociateAlphaRegion&quot;. (Credit to OSS-Fuzz)</li>
+<li>magick/render.c (DrawImage): SetImageAttribute() appends new
+text to any existing value, leading to every increasing memory
+consumption if the existing value is not deleted first by the
+unwary.  Fixes oss-fuzz 9983 &quot;graphicsmagick/coder_MVG_fuzzer:
+Timeout in graphicsmagick_coder_MVG_fuzzer&quot; and oss-fuzz 10016
+&quot;graphicsmagick/coder_MVG_fuzzer: Out-of-memory in
+graphicsmagick_coder_MVG_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>magick/utility.c (TranslateTextEx): Fix off-by-one in loop
+bounds check which allowed a one-byte stack write overflow.  Fixes
+oss-fuzz 10055 &quot;graphicsmagick/coder_MVG_fuzzer:
+Stack-buffer-overflow in TranslateTextEx&quot;. (Credit to OSS-Fuzz)</li>
+<li>magick/render.c (DrawImage): Be more precise about error
+detection and reporting, and return from an error more quickly.
+Also added MAX_DRAWIMAGE_RECURSION pre-processor definition to
+allow adjusting the drawing recursion limit.  The drawing
+recursion limit is still 100, which seems exceptionally generous.</li>
+<li>magick/constitute.c (WriteImage): Produce a more useful error
+message if an encoding delegate is not available.</li>
+<li>magick/nt_base.h (isnan): Try adding a MSVC replacement for
+missing isnan() function.  Not yet tested.</li>
 </ul>
 </blockquote>
-<p>2017-01-21  Glenn Randers-Pehrson  &lt;<a class="reference external" href="mailto:glennrp&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">glennrp<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-08-25  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>coders/png.c: Added read_user_chunk_callback() function
-and used it to implement a private PNG caNv (canvas) chunk
-for remembering the original dimensions and offsets when an
-image is cropped.  Previously we used the oFFs chunk for this
-purpose, but this had potential conflicts with other applications
-that also use the oFFs chunk.</li>
+<li>coders/wpg.c This should fix intentional 64 bit file offset
+overflow as depictedin OSS-fuzz-9936. Thanks to OSS-Fuzz.</li>
 </ul>
 </blockquote>
-<p>2017-01-07  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-08-22  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li>TclMagick/Makefile.am (AM_DISTCHECK_CONFIGURE_FLAGS): Applied
-patch by Massimo Manghi to set AM_DISTCHECK_CONFIGURE_FLAGS so
-that 'make distcheck' remembers configuration options, and also to
-uninstall pkgIndex.tcl.</li>
-<li>magick/image.c (SetImageEx): Use PixelIterateMonoSet() for
-possibly improved efficiency.</li>
-<li>magick/pixel_iterator.c (PixelIterateMonoSet): New pixel
-iterator intended for use when initializing image pixels, without
-regard to existing values.</li>
+<li>magick/render.c (ConvertPrimitiveToPath): Need to enlarge
+PathInfo array allocation to avoid possible heap write overflow.
+Fixes oss-fuzz 9651 &quot;graphicsmagick/coder_MVG_fuzzer:
+Heap-buffer-overflow in ConvertPrimitiveToPath&quot;. (Credit to
+OSS-Fuzz)</li>
 </ul>
 </blockquote>
-<p>2017-01-01  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<p>2018-08-20  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mpc.c (ReadMPCImage): Insist that the format be
+identified prior to any comment, and that there is only one
+comment.</li>
+<li>coders/miff.c (ReadMIFFImage): Insist that the format be
+identified prior to any comment, and that there is only one
+comment.  Fixes oss-fuzz 9979 &quot;graphicsmagick/coder_MIFF_fuzzer:
+Timeout in graphicsmagick_coder_MIFF_fuzzer&quot;.  This is not a
+serious issue, but the code runs slowly under UBSAN.  (Credit to
+OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-08-19  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/utility.c (MagickAtoFChk): Add additional validation
+checks for floating point values.  NAN and +/- INFINITY values
+also map to 0.0. Fixes oss-fuzz 9630
+&quot;graphicsmagick/coder_MVG_fuzzer: Integer-overflow in
+IsNexusInCore&quot; and oss-fuzz 9612 &quot;graphicsmagick/coder_MVG_fuzzer:
+Integer-overflow in SetCacheNexus&quot;. (Credit to OSS-Fuzz)</li>
+<li>magick/render.c (DrawImage): Add missing error-reporting logic
+to return immediately upon memory reallocation failure.  Apply
+memory resource limits to PrimitiveInfo array allocation.  Fixes
+oss-fuzz 9576 &quot;graphicsmagick/coder_MVG_fuzzer: Null-dereference
+READ in DrawImage&quot;, oss-fuzz 9593
+&quot;graphicsmagick/coder_MVG_fuzzer: Out-of-memory in
+graphicsmagick_coder_MVG_fuzzer&quot;, oss-fuzz 9648
+&quot;graphicsmagick/coder_MVG_fuzzer: Unknown signal in
+DrawImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-08-16  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coder/mat.c Explicitly reject non-seekable streams.</li>
+</ul>
+</blockquote>
+<p>2018-08-15  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coder/mat.c Correctly check GetBlobSize(image) even for zipstreams.</li>
+</ul>
+</blockquote>
+<p>2018-08-14  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c More aggresive data corruption checking.</li>
+</ul>
+</blockquote>
+<p>2018-08-09  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/xbm.c (XBMInteger): Limit the number of hex digits parsed
+to avoid signed integer overflow.  Fixes oss-fuzz 9746
+&quot;graphicsmagick/coder_XBM_fuzzer: Undefined-shift in
+XBMInteger&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-08-07  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c Typecast difference to quantum.</li>
+</ul>
+</blockquote>
+<p>2018-08-05  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c (InsertComplexFloatRow): Avoid signed
+overflow. Fixes oss-fuzz 9667 &quot;graphicsmagick/coder_MAT_fuzzer:
+Integer-overflow in InsertComplexFloatRow&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/xbm.c (ReadXBMImage): Add validations for row and column
+dimensions.  Fixes oss-fuzz 9736 &quot;graphicsmagick/coder_XBM_fuzzer:
+Out-of-memory in graphicsmagick_coder_XBM_fuzzer&quot;. (Credit to
+OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-08-04  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wpg.c Add mechanism to approve embedded subformats in
+WPG.  This should mute oss-fuzz 9559.  (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-07-24  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mvg.c (ReadMVGImage): Fix memory leak added on
+2018-07-21.  Fixes oss-fuzz 9548 &quot;graphicsmagick/coder_MVG_fuzzer:
+Direct-leak in CloneDrawInfo&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-07-23  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/cineon.c (ReadCINEONImage): Fix SourceForge issue 571
+&quot;Unexpected hang on a crafted Cineon image&quot; by detecting and
+quitting on EOF appropriately, and verifying that file size is
+sufficient for claimed pixel dimensions when possible.</li>
+<li>fuzzing/oss-fuzz-build.sh, fuzzing/dictionaries/MVG.dict: Added
+MVG fuzzing dictionary by Alex Gaynor.</li>
+</ul>
+</blockquote>
+<p>2018-07-22  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/pixel_cache.c (SetNexus): For requests one pixel tall,
+SetNexus() was wrongly using pixels in-core rather than using a
+staging area for the case where the nexus rows extend beyond the
+image raster boundary, leading to heap overflow.  This can happen
+when virtual pixels outside the image bounds are accessed.  Fixes
+oss-fuzz 9512 &quot;graphicsmagick/graphicsmagick_coder_MVG_fuzzer:
+Heap-buffer-overflow in AcquireCacheNexus&quot;. (Credit to OSS-Fuzz)</li>
+<li>magick/render.c (ExtractTokensBetweenPushPop):
+ExtractTokensBetweenPushPop() needs to always return a valid
+pointer into the primitive string.  Fixes oss-fuzz 9511
+&quot;graphicsmagick/graphicsmagick_coder_MVG_fuzzer: Null-dereference
+READ in DrawImage&quot;. (Credit to OSS-Fuzz)
+(DrawPolygonPrimitive): Fix leak of polygon set when object is
+completely outside image.  Fixes oss-fuzz 9513
+&quot;graphicsmagick/graphicsmagick_coder_MVG_fuzzer: Direct-leak in
+AllocateThreadViewDataSet&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-07-21  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/blob.c (FileToBlob): Use confirm access APIs to verify
+that read access to this path is allowed by policy.  Check that
+file is a regular file before proceeding to open and read from it.</li>
+<li>coders/mvg.c (ReadMVGImage): Don't allow MVG files to side-load
+a file as the drawing primitive using '&#64;' syntax.  Fixes oss-fuzz
+9494 &quot;graphicsmagick/coder_MVG_fuzzer: Sanitizer CHECK failure in
+&quot;((0)) != (0)&quot; (0x0, 0x0)&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-07-19  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mvg.c (ReadMVGImage): Don't assume that in-memory MVG
+blob is a null-terminated C string. Fixes oss-fuzz 9469
+&quot;graphicsmagick/coder_MVG_fuzzer: Heap-buffer-overflow in
+AllocateString&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-07-12  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/miff.c (ReadMIFFImage): Detect EOF when reading using
+ReadBlobZC() and avoid subsequent heap read overflow.  Fixes
+oss-fuzz 9357 &quot;graphicsmagick/coder_MIFF_fuzzer:
+Heap-buffer-overflow in ImportRGBQuantumType&quot;. (Credit to
+OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-07-11  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>fuzzing/oss-fuzz-build.sh (CFLAGS): Try disabling SIMD
+instructions in libjpeg-turbo build.</li>
+</ul>
+</blockquote>
+<p>2018-07-10  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (WriteOnePNGImage): Free png_pixels as soon as
+possible.  This might help with oss-fuzz 9334
+&quot;graphicsmagick/coder_PNG8_fuzzer: Direct-leak in
+WriteOnePNGImage&quot;, which we have yet to reproduce.  It is not
+clear if png_pixels is being clobbered by longjmp or if something
+else is going on.</li>
+</ul>
+</blockquote>
+<p>2018-06-26  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/jpeg.c (ReadJPEGImage): Provide a memory resource limit
+(of 1/5th the memory resource limit for Graphicsmagick) to libjpeg
+to limit how much memory it might consume for itself while reading
+a file.  Fixes oss-fuzz 9096 &quot;graphicsmagick/coder_JPEG_fuzzer:
+Timeout in graphicsmagick_coder_JPEG_fuzzer&quot;.  (Credit to
+OSS-Fuzz)
+(ReadJPEGImage): Make sure that JPEG pixels array is initialized
+in case libjpeg fails to completely initialize it.  May fix
+oss-fuzz 9115 &quot;graphicsmagick/coder_JPEG_fuzzer:
+Use-of-uninitialized-value in ReadJPEGImage&quot;.  We are not sure
+since the problem was not reproduced.  (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-06-23  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>version.sh: Update library versioning for 1.3.30 release.</li>
+<li>NEWS.txt: Update news for 1.3.30 release.</li>
+</ul>
+</blockquote>
+<p>2018-06-22  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dpx.c (ReadDPXImage): Report exception on EOF file
+reading DPX pixel data. Fixes oss-fuzz 8104
+&quot;graphicsmagick/coder_DPX_fuzzer: Use-of-uninitialized-value in
+WriteDPXImage&quot;, oss-fuzz 8297 &quot;graphicsmagick/enhance_fuzzer:
+Use-of-uninitialized-value in EnhanceImage&quot;, and oss-fuzz 8133
+&quot;graphicsmagick/coder_DPX_fuzzer: Use-of-uninitialized-value in
+RGBTransformPackets&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-06-20  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/cmyk.c (ReadCMYKImage): Free scanline buffer in error
+path. Fixes SourceForge issue #567 &quot;small memory leak in rgb.c,
+gray.c and cmyk.c&quot; reported by Petr Gajdos.</li>
+<li>coders/gray.c (ReadGRAYImage): Free scanline buffer in error
+path. Fixes SourceForge issue #567 &quot;small memory leak in rgb.c,
+gray.c and cmyk.c&quot; reported by Petr Gajdos.</li>
+<li>coders/rgb.c (ReadRGBImage): Free scanline buffer in error
+path. Fixes SourceForge issue #567 &quot;small memory leak in rgb.c,
+gray.c and cmyk.c&quot; reported by Petr Gajdos.</li>
+<li>coders/jpeg.c (ReadJPEGImage): Avoid memory leak of profile
+buffer when longjmp-based exception is thrown while reading a
+profile. Fixes oss-fuzz 8957 &quot;graphicsmagick/enhance_fuzzer:
+Direct-leak in ReadGenericProfile&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-06-17  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/xcf.c (load_level): Make sure to free 'tile_image' before
+returning exception.  Fixes oss-fuzz 8935
+&quot;graphicsmagick/coder_XCF_fuzzer: Indirect-leak in
+CloneImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/jpeg.c (ReadJPEGImage): Allow three warnings of any given
+type before promoting the next warning of the same type to a hard
+error.  The warning limit may be adjusted by the user using
+-define jpeg:max-warnings=&lt;value&gt;.  Fixes oss-fuzz 8704
+&quot;graphicsmagick/coder_JPG_fuzzer: Out-of-memory in
+graphicsmagick_coder_JPG_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/png.c (ReadPNGImage): Detect EOF when reading
+magic_number.  Fixes oss-fuzz 8944
+&quot;graphicsmagick/coder_PNG_fuzzer: Use-of-uninitialized-value in
+ReadPNGImage&quot;.  (Credit to OSS-Fuzz)
+(ReadPNGImage, ReadJNGImage): Makes sure that return value of
+ReadBlob() is always checked to detect EOF.</li>
+</ul>
+</blockquote>
+<p>2018-06-16  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/tiff.c (ReadTIFFImage): Re-structure exception reporting
+so that QuantumTransferMode() exceptions thrown for
+PLANARCONFIG_SEPARATE images are handled immediately.  Fixes
+oss-fuzz 8896 &quot;graphicsmagick/coder_BIGTIFF_fuzzer:
+Use-of-uninitialized-value in DisassociateAlphaRegion&quot;. (Credit to
+OSS-Fuzz)
+(ReadTIFFImage): tsize_t is a signed type so be prepared for
+unexpected negative values produced by libtiff size functions.
+Fixes oss-fuzz 8934 &quot;graphicsmagick/coder_TIFF_fuzzer: Sanitizer
+CHECK failure in &quot;((0)) != (0)&quot; (0x0, 0x0)&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-06-16  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wpg.c Fix oss-fuzz 7735 &quot;graphicsmagick/coder_WPG_fuzzer:
+Use-of-uninitialized-value in ReadWPGImage&quot;.  (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-06-11  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadMNGImage): ENDL chunk must be at least one
+byte in size. Fixes oss-fuzz 8832
+&quot;graphicsmagick/coder_MNG_fuzzer: Null-dereference READ in
+ReadMNGImage&quot;. (Credit to OSS-Fuzz)
+(ReadMNGImage): Length of DISC chunk must be evenly divisible by
+2.  Fixes oss-fuzz 8834 &quot;graphicsmagick/coder_MNG_fuzzer:
+Heap-buffer-overflow in ReadMNGImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-06-10  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mpc.c (ReadMPCImage): Detect end of file while reading
+image directory.  Similar to MIFF fixes for ImageMagick
+CVE-2017-18272.
+(RegisterMPCImage): Require seekable stream since MPC is strictly
+a file-based format and so GetBlobSize() is assured to work.
+Similar to MIFF behavior.  Claimed to be part of the resolution
+for ImageMagick CVE CVE-2017-11449. Suggested by Petr Gajdos via
+email on January 3, 2018.</li>
+</ul>
+</blockquote>
+<p>2018-06-09  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/miff.c (ReadMIFFImage): Detect end of file while reading
+image directory. Fixes SourceForge issue 565 &quot;ImageMagick
+CVE-2017-18272 applies to GraphicsMagick&quot;.  Thanks to Petr Gajdos
+for reporting this issue to us.</li>
+<li>magick/import.c (ImportViewPixelArea): Use appropriate
+bits_per_sample validations for FloatQuantumSampleType. Fixes
+oss-fuzz 8780 &quot;graphicsmagick/coder_PTIF_fuzzer:
+Use-of-uninitialized-value in HorizontalFilter&quot;. (Credit to
+OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-06-09  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c More than 4GiB are not supported in MAT!</li>
+</ul>
+</blockquote>
+<p>2018-06-09  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c (ReadMATImage): Add casts to avoid arithmetic
+overflow when computing size and offsets.  Fixes oss-fuzz 8801
+&quot;graphicsmagick/coder_MAT_fuzzer: Timeout in
+graphicsmagick_coder_MAT_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>magick/blob.c (ReadBlobLSBDoubles, ReadBlobMSBDoubles): Only
+byte-swap doubles or test doubles for NAN if we have read enough
+bytes for at least one double value.
+(ReadBlob): Add an assertion to enforce that ReadBlob() will never
+report reading more bytes than requested due to some
+implementation issue.</li>
+</ul>
+</blockquote>
+<p>2018-06-08  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/blob.c (ReadBlob, WriteBlob): gzread(), BZ2_bzread(),
+gzwrite(), BZ2_bzwrite() return type 'int' rather than 'size_t'
+like their stdio equivalents.  Use correct signed type to avoid
+returning a negative value into an unsigned type, forming a huge
+positive value.  Fixes oss-fuzz 8600
+&quot;graphicsmagick/coder_MAT_fuzzer: Heap-buffer-overflow in
+ReadBlobLSBDoubles&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-06-07  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (png_read_raw_profile): Try to shore up parsing of
+raw profile reading to avoid heap read overruns.  Fixes oss-fuzz
+8763 &quot;graphicsmagick/coder_PNG32_fuzzer: Heap-buffer-overflow in
+png_read_raw_profile&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-06-07  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c Reduce stack usage for 64 bit architecture.</li>
+</ul>
+</blockquote>
+<p>2018-06-06  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wpg.c Check return values of SeekBlob for more safety.</li>
+</ul>
+</blockquote>
+<p>2018-06-06  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJNGImage): Use DestroyImageList() rather
+than DestroyImage() on returned Image from supposed read of JPEG
+data, in case multiple frames were unexpectedly returned.  Also
+add &quot;JPEG:&quot; prefix to filename when reading from temporary file to
+force that it can only be read as a JPEG file, disabling format
+auto-detection based on file header.  Fixes oss-fuzz 8755
+&quot;graphicsmagick/coder_JNG_fuzzer: Indirect-leak in
+AllocateImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-06-05  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/blob.c (EOFBlob): Implement EOF detection for ZipStream.
+Does some archaic zlib not provide gzeof()?  Fixes oss-fuzz 8550
+&quot;graphicsmagick/coder_MAT_fuzzer: Timeout in
+graphicsmagick_coder_MAT_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-06-04  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOnePNGImage): Skip adding empty raw profile.
+Fixes oss-fuzz &quot;graphicsmagick/coder_PNG_fuzzer:
+Heap-buffer-overflow in png_read_raw_profile&quot;. (Credit to
+OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-06-03  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>NEWS.txt: Update NEWS with latest changes.</li>
+<li>coders/dcm.c (DCM_ReadRGBImage): Force the image to DirectClass
+to avoid later use of uninitialized indexes.  Fixes oss-fuzz 8602
+&quot;graphicsmagick/coder_DCM_fuzzer: Use-of-uninitialized-value in
+DCM_PostRescaleImage&quot;. (Credit to OSS-Fuzz)
+(DCM_ReadPlanarRGBImage): Force the image to DirectClass to avoid
+later use of uninitialized indexes.</li>
+<li>coders/png.c (ReadMNGImage): Free chunk memory in error
+reporting path to avoid leak.  Fixes oss-fuzz 8721
+&quot;graphicsmagick/coder_MNG_fuzzer: Direct-leak in
+ReadMNGImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-06-02  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/constitute.c (ReadImage): Assure that an error exception
+is thrown if coder returns null without properly reporting an
+exception.</li>
+<li>magick/blob.c (BlobToImage): Assure that an error exception is
+thrown if coder returns null without properly reporting an
+exception.</li>
+<li>coders/png.c (ReadMNGImage): Disable mystery &quot;linked list is
+corrupted&quot; code.  Assure that exceptions are reported to the
+correct place so they are not lost.  Fixes oss-fuzz 8710
+&quot;graphicsmagick/coder_MNG_fuzzer: Indirect-leak in
+AllocateImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/tiff.c (ReadTIFFImage): Initialize allocated scanline,
+strip, or tile to zero in order to avoid complaint about use of
+uninitialized data if libtiff fails to write all the bytes.  Fixes
+oss-fuzz 8551 &quot;graphicsmagick/coder_TIFF_fuzzer:
+Use-of-uninitialized-value in ImportGrayQuantumType&quot;. (Credit to
+OSS-Fuzz)</li>
+<li>magick/annotate.c (RenderFreetype): Throw an exception if
+DrawInfo font is null.  Should fix oss-fuzz 8557
+&quot;graphicsmagick/coder_PCD_fuzzer: Unknown signal in
+RenderFreetype&quot; and may fix oss-fuzz 8544
+&quot;graphicsmagick/coder_PCD_fuzzer: Null-dereference READ in
+RenderFreetype&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/jpeg.c (ReadGenericProfile): Add/improve tracing for
+profile size and when JPEG header is being read.</li>
+</ul>
+</blockquote>
+<p>2018-06-01  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJNGImage): Report a useful exception for
+the case when the JNG file fails to provide the necessary image
+chunks to allocate the color image.  Inspired by oss-fuzz 8666
+&quot;graphicsmagick/coder_JNG_fuzzer: ASSERT: data != (const char *)
+NULL&quot; although the reported issue was not reproduced.</li>
+</ul>
+</blockquote>
+<p>2018-05-31  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadMNGImage): Fix off-by-one in length validation
+for TERM chunk which allowed one byte heap read overflow.  Fixes
+oss-fuzz 8615 &quot;graphicsmagick/coder_MNG_fuzzer:
+Heap-buffer-overflow in mng_get_long&quot;. (Credit to OSS-Fuzz)
+(ReadMNGImage): Fix leak of MngInfo in error reporting path.
+Fixes oss-fuzz 8604 &quot;graphicsmagick/coder_MNG_fuzzer: Direct-leak
+in ReadMNGImage&quot;. (Credit to OSS-Fuzz)
+(ReadMNGImage): Verify that claimed chunk size does not exceed
+input size.  Fixes oss-fuzz 8564 &quot;graphicsmagick/coder_MNG_fuzzer:
+Out-of-memory in graphicsmagick_coder_MNG_fuzzer&quot;. (Credit to
+OSS-Fuzz)</li>
+<li>coders/tiff.c (ReadTIFFImage): Reject files with excessive
+samples-per-pixel or extra-samples. Avoids potential issues
+observed in oss-fuzz 8634 &quot;graphicsmagick/coder_BIGTIFF_fuzzer:
+Undefined-shift in ImportAlphaQuantumType&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-05-30  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadMNGImage): Assure that object id index is
+always less than MNG_MAX_OBJECTS to avoid overflow.  Fixes
+oss-fuzz 8596 &quot;graphicsmagick/coder_MNG_fuzzer:
+Index-out-of-bounds in ReadMNGImage&quot; and likely other issues yet
+to be reported. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-05-30  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (CompareEdges): Per ticket #562,
+function CompareEdges() did not conform to the qsort()
+requirement that if CompareEdges(edge0,edge1) returns
+-1 (i.e., edge0 &quot;less than&quot; edge1), then
+CompareEdges(edge1,edge0) should return 1 (edge1
+&quot;greater than&quot; edge0).  This has been fixed.</li>
+</ul>
+</blockquote>
+<p>2018-05-30  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJNGImage): Deal with JDAA JNG chunk with
+length zero.  Fixes oss-fuzz 8562
+&quot;graphicsmagick/coder_JNG_fuzzer: ASSERT: data != (const char *)
+NULL&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/tiff.c (ReadTIFFImage): Check that the bits-per-sample is
+supported by the implementation before attempting to decode the
+image. Fixes oss-fuzz 8554 &quot;graphicsmagick/coder_BIGTIFF_fuzzer:
+Undefined-shift in MagickBitStreamMSBWrite&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/png.c (ReadMNGImage): Eliminate use of uninitialized
+header magic data by checking for EOF first.  Fixes oss-fuzz 8597
+&quot;graphicsmagick/coder_MNG_fuzzer: Use-of-uninitialized-value in
+ReadMNGImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-05-25  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>fuzzing/oss-fuzz-build.sh: More fixes based on what is observed
+in oss-fuzz build log.</li>
+</ul>
+</blockquote>
+<p>2018-05-24  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/jnx.c The attribute should belong to only one scene and
+not to whole image list.</li>
+</ul>
+</blockquote>
+<p>2018-05-24  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>fuzzing/oss-fuzz-build.sh: Changes to add CPPFLAGS to configure
+executions to hopefully get oss-fuzz build closer to success.</li>
+</ul>
+</blockquote>
+<p>2018-05-23  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>PerlMagick/t/jpeg/read.t: Add a JNX reader test case.</li>
+<li>coders/jnx.c (ReadJNXImage): JNX image depth should be 8.</li>
+<li>fuzzing/oss-fuzz-build.sh: Apply patch from Alex Gaynor to
+switch libpng to autotools build system, as well as configure
+GraphicsMagick with '--with-quantum-depth=16'.</li>
+</ul>
+</blockquote>
+<p>2018-05-22  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/tiff.c (ReadTIFFImage): Validate tile memory requests for
+the TIFFReadRGBATile() case in the same way as the TIFFReadTile()
+case.  Fixes oss-fuzz 8434 &quot;graphicsmagick/coder_BIGTIFF_fuzzer:
+Out-of-memory in graphicsmagick_coder_BIGTIFF_fuzzer&quot;. (Credit to
+OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-05-21  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/tile.c (ReadTILEImage): Remove any existing size request
+when while image to tile.  This avoids size being used for both
+the input image size and the tile image size.  Fixes SourceForge
+issue #563 &quot;tile:&lt;image&gt; appears to blow image up by 100% before
+applying tiling&quot;.</li>
+</ul>
+</blockquote>
+<p>2018-05-20  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>fuzzing/oss-fuzz-build.sh: Patch from Paul Kehrer to disable
+libpng test programs and binaries while building libpng in support
+of oss-fuzz testing.</li>
+<li>coders/dcm.c (DCM_ReadGrayscaleImage): If a palette was
+provided, the image may be in PseudoClass but we need DirectClass
+for gray image when GRAYSCALE_USES_PALETTE is not defined.  Fixes
+oss-fuzz 7550 &quot;graphicsmagick/coder_DCM_fuzzer:
+Use-of-uninitialized-value in SyncImageCallBack&quot;. (Credit to
+OSS-Fuzz)
+(ReadDCMImage): Restore use of DCM_PostRescaleImage() in order to
+obtain suitably scaled DICOM again.  Hopefully it is more robust
+now.
+(DCM_ReadPaletteImage): Assure that DirectClass pixels are
+initialized.</li>
+</ul>
+</blockquote>
+<p>2018-05-19  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/tiff.c (ReadTIFFImage): Remove strange addition of
+image-&gt;columns to pixel buffer offsets which now causes a heap
+overflow since the buffer has been right-sized.  Perhaps the extra
+offset plus the over-sized allocation was some attempt to avoid
+buffer over/underflows due to bugs in libtiff. Fixes oss-fuzz 8384
+&quot;graphicsmagick/coder_BIGTIFF_fuzzer: Heap-buffer-overflow in
+put1bitbwtile&quot; which is described to be a regression. (Credit to
+OSS-Fuzz)</li>
+<li>magick/render.c (DrawImage): Fix wrong range checks which caused
+spurious &quot;Parsing of SVG images fail with &quot;Non-conforming drawing
+primitive definition (push)&quot; failure.  Fixes SourceForge issue 561
+&quot;Parsing of SVG images fail with &quot;Non-conforming drawing primitive
+definition (push)&quot;&quot; which is due to problems caused by the fix for
+SourceForge issue 517.</li>
+<li>coders/tiff.c (WritePTIFImage): Use '-define
+ptif:minimum-geometry=&lt;geometry&gt;' to specify the smallest
+subresolution frame which is produced by the PTIF (Pyramid TIFF)
+writer.</li>
+</ul>
+</blockquote>
+<p>2018-05-18  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/tiff.c (WritePTIFImage): Allow 1x1 input image to be
+supported.</li>
+<li>coders/png.c (ReadOneJNGImage): Unconditionally free JDAT chunk
+memory.  Fixes oss-fuzz 8366 &quot;graphicsmagick/coder_JNG_fuzzer:
+Direct-leak in ReadOneJNGImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/tiff.c (WritePTIFImage): Fix leak of pyramid Image list
+if ResizeImage() fails.  Fixes oss-fuzz 8364
+&quot;graphicsmagick/coder_PTIF_fuzzer: Indirect-leak in
+CloneImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-05-17  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/tiff.c (WriteTIFFImage): Add and use
+ThrowTIFFWriterException() macro to consistently clean-up when
+throwing writer exception.  May fix oss-fuzz 8321
+&quot;graphicsmagick/coder_EPT_fuzzer: Direct-leak in
+TIFFClientOpen&quot;. (Credit to OSS-Fuzz)
+(ReadTIFFImage): Add and use ThrowTIFFReaderException() macro to
+consistently clean-up when throwing reader exception.</li>
+</ul>
+</blockquote>
+<p>2018-05-16  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul>
+<li><p class="first">magick/alpha_composite.h (AlphaCompositePixel): The
+macro definition for MagickAlphaCompositeQuantum in
+alpha_composite.h computes an expression of the form:</p>
+<p>a * b + c * d * e</p>
+<p>Code in function AlphaCompositePixel() (also in
+alpha_composite.h) multiplies the result of this macro
+by variable &quot;delta&quot; as follows:</p>
+<p>delta * a * b + c * d * e</p>
+<p>However, the intended result is actually:</p>
+<p>delta * ( a * b + c * d * e )</p>
+<p>The macro definition has been modified to enclose the
+entire expression in parentheses.</p>
+<p>The effects of this bug were particularly evident at the
+boundary between a stroked polygon and a transparent
+black region. More generally, an incorrect composited
+pixel value was being computed by AlphaCompositePixel()
+whenever the output alpha value was not 100% opaque.</p>
+</li>
+</ul>
+</blockquote>
+<p>2018-05-16  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>tests/rwblob.tap: Add a test for PTIF format.</li>
+<li>coders/tiff.c (WritePTIFImage): Fix Image blob referencing in
+order to avoid double-free when writing PTIF to memory BLOB. Fixes
+oss-fuzz 8280 &quot;graphicsmagick/coder_PTIF_fuzzer: Heap-double-free
+in Magick::BlobRef::~BlobRef&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-05-14  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/tiff.c (WriteTIFFImage): Use libtiff's
+TIFFDefaultStripSize() function rather than an old porting macro
+required by some defunct libtiff version.  Expected to fix
+oss-fuzz 8248 &quot;graphicsmagick/coder_EPT_fuzzer:
+Floating-point-exception in WriteTIFFImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-05-13  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c Fix potentional leak when compressed object is
+corrupted. Fixes oss-fuzz 8251 (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-05-13  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/tiff.c (ReadTIFFImage): Fix leak of Image when
+TIFFReadRGBAImage() reports failure.  Also harden buffer
+allocation calculation.  Fixes oss-fuzz 8275
+&quot;graphicsmagick/coder_BIGTIFF_fuzzer: Indirect-leak in
+AllocateImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/ept.c (ReadEPTImage): Add validations of 'count' and
+'filesize' read from EPT file. In response to oss-fuzz 8248
+&quot;graphicsmagick/coder_EPT_fuzzer: Floating-point-exception in
+WriteTIFFImage&quot; but we are unable to recreate the oss-fuzz issue
+since the EPT reader already immediately reports an EOF exception.</li>
+</ul>
+</blockquote>
+<p>2018-05-12  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>fuzzing/oss-fuzz-build.sh: Apply SourceForge patch #57 &quot;Add
+fuzzing support for jpeg + freetype delegates&quot; by Alex Gaynor.</li>
+<li>coders/png.c (read_user_chunk_callback): Fix memory leak and use
+of uninitialized memory when handling eXIf chunk. Fixes oss-fuzz
+8247 &quot;graphicsmagick/coder_PNG24_fuzzer: Direct-leak in
+png_malloc&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-05-11  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>fuzzing/oss-fuzz-build.sh: Apply SourceForge patch #56 &quot;Use a
+few delegate libraries in fuzzing&quot; by Alex Gaynor.</li>
+</ul>
+</blockquote>
+<p>2018-05-10  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>tests/rwfile.tap: MIFF zip and bzip compression tests do not
+fail if zlib and bzlib are not available because the compression
+request is silently changed to no compression.</li>
+</ul>
+</blockquote>
+<p>2018-05-07  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (DrawImage, InsertAttributeIntoInputStream):
+For a reference such as 'class=&quot;classname&quot;', the &quot;classname&quot;
+is now allowed to be undefined.</li>
+<li>coders.svg.c (ProcessStyleClassDefs): Class definitions
+defined within a &lt;style&gt; block may now be empty.</li>
+<li>These relaxed conditions are not specifically called out in
+the SVG spec as being either acceptable or unacceptable, but
+other SVG renderers (e.g., Chrome) handle them this way. These
+changes do not resolve, but are related to, ticket #307.</li>
+</ul>
+</blockquote>
+<p>2018-05-05  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>utilities/Makefile.am (utilities/tests/montage.log): Fix
+dependency rule so that effects.tap is fully executed before
+execution of montage.tap starts.</li>
+</ul>
+</blockquote>
+<p>2018-05-04  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (DrawImage, TraceXXX): The PrimitiveInfo
+array used to store points generated by TraceEllipse(), the
+other TraceXXX() functions, and DrawImage() was not always
+being expanded when needed, resulting in writes beyond the
+end of the currently allocated storage. To fix this problem,
+a new data structure PrimitiveInfoMgr, and an associated
+function, PrimtiveInfoRealloc(), were written to handle
+expanding the PrimitiveInfo array as needed. DrawImage() and
+the TraceXXX() functions were modified to prevent the out of
+bounds writes to memory. This fixes ticket #516.</li>
+</ul>
+</blockquote>
+<p>2018-05-03  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOneJNGImage): Add more JNG chunk
+validations. Fixes an issue reported by &quot;Trace Probe&quot; via a
+follow-up post to SourceForge issue 437 &quot;assertion failure in
+WriteBlob&quot;, although the issue described was not reproduced.</li>
+<li>coders/meta.c (ReadMETAImage): Detect and report 8BIMTEXT and
+8BIMWTEXT decoding problems.  Fixes oss-fuzz 8125
+&quot;graphicsmagick/coder_8BIMTEXT_fuzzer: Use-of-uninitialized-value
+in format8BIM&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-05-02  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (TraceStrokePolygon): Excessively
+large values of stroke-width were cascading through
+other computations, causing the function to write beyond
+the end of it's array of points when the stroke-linejoin
+attribute value was &quot;round&quot;. Code was added to reallocate
+the array of points as needed, and to limit the size of
+stroke-width (for computational purposes) to no more than
+approximately twice the diagonal size of the output image.
+Fixes ticket #515.</li>
+<li>The same limit on stroke-width was applied to all other
+instances of the same computation in render.c.</li>
+</ul>
+</blockquote>
+<p>2018-05-01  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>This change set fixes ticket #471.</li>
+<li>magick/render.c (DrawImage): Polylines with fewer
+than two points were being flagged as an error. The
+SVG spec has no such restriction (fixed).</li>
+<li>coders/svg.c (SVGStartElement) Inner &lt;svg&gt; elements
+could modify the output image dimensions if a geometry
+string was supplied. Now the output image dimensions
+are determined by the outermost &lt;svg&gt; only.</li>
+</ul>
+</blockquote>
+<p>2018-05-01  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (TraceEllipse, TraceRectangle,
+TraceRoundRectangle): Per the SVG spec, rectangles and
+round rectangles having a width or height of zero are
+not rendered. Also per the spec, ellipses having an x
+or y radius of zero are not rendered.  Fixes ticket #457.</li>
+</ul>
+</blockquote>
+<p>2018-04-30  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.h, (PrimitiveInfo), magick/render.c: Added
+member &quot;flags&quot; to PrimitiveInfo to support indicating closed
+shapes (e.g., rectangle, circle, path closed using 'z' or 'Z').
+Updated code in render.c (functions TraceXXX) to indicate
+closed shapes.  This replaces the previous policy of detecing
+closed shapes by comparing the first and last points to see if
+they are identical (within MagickEpsilon). The old policy
+prevented open subpaths with the same first and last point from
+being rendered properly (per the SVG spec) when round or square
+endcaps were enabled.  Part of the fix for ticket #322.</li>
+<li>magick/render.c (ConvertPrimitiveToPath): Modified duplicate
+point elimination code so that the first and last points of
+a subpath are always preserved.  Consequences: (1) Allows
+for the correct rendering of the sequence &quot;move x1 y1 line
+x1 y1&quot; with round or square endcaps.  Part of the fix for
+ticket #322. (2) Fixes a bug in which eliminating the last
+point as a duplicate caused a closed shape to no longer be
+closed. This would manifest itself, for example, as a small
+&quot;nub&quot; on the boundary of a filled circle.</li>
+<li>magick/render.c (GetPixelOpacity): Fixed a bug in the
+code that computed the distance between a point and a
+segment (polygon edge).  Prior to this fix, for zero length
+segments this code would generate a divide-by-zero and
+incorrect output. Part of the fix for ticket #322.</li>
+<li>magick/render.c (DrawPolygonPrimitive): Polygons/paths with
+zero or one points are no longer rendered per the SVG spec.</li>
+<li>magick/render.c (DrawStrokePolygon): Per the SVG spec, a
+polygon consisting of a single move-to command is not stroked.</li>
+<li>magick/render.c (TracePath): Per the SVG spec, if the
+endpoints (x1, y1) and (x2, y2) of an arc subpath are identical,
+then this is equivalent to omitting the elliptical arc segment
+entirely.  For rendering purposes the zero length arc is
+treated like a zero length &quot;line to&quot; command to the current
+point.</li>
+<li>magick/render.c (TraceStrokePolygon): Added code to detect
+zero length open subpaths and return a stroked polygon containing
+no points when round or square endcaps are not enabled.  This
+satisfies the SVG spec requirement that zero length subpaths are
+only stroked if the 'stroke-linecap' property has a value of
+round or square.</li>
+<li>magick/render.c (TracePath): Fixed a bug in which if a &quot;move to&quot;
+command was followed by additional pairs of points, indicating
+implied &quot;line to&quot; commands, each point was added twice.</li>
+</ul>
+</blockquote>
+<p>2018-04-30  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pcx.c (ReadPCXImage): Colormap from PCX header is only
+used if colors &lt;= 16. Determination of DirectClass image was
+wrong.  Fixes oss-fuzz 8093 &quot;graphicsmagick/coder_PCX_fuzzer:
+Use-of-uninitialized-value in IsMonochromeImage&quot;. (Credit to
+OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-29  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>version.sh: Updates to prepare for the 1.3.29 release.</li>
+<li>coders/pict.c (DecodeImage): Assure that scanline is initialized
+to avoid use of uninitialized data.  Fixes oss-fuzz 8063
+&quot;graphicsmagick/coder_WPG_fuzzer: Use-of-uninitialized-value in
+ReadPICTImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/dpx.c (ReadDPXImage): Assure that NULL pixels is not
+used.  Fixes oss-fuzz 8078 &quot;graphicsmagick/coder_DPX_fuzzer:
+Null-dereference WRITE in ReadDPXImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>NEWS.txt: Update NEWS file with information about changes since
+last release.</li>
+</ul>
+</blockquote>
+<p>2018-04-28  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dib.c (ReadDIBImage): Disable EOF tests for &quot;ICODIB&quot;
+subformat due to icon file provided by SourceForge issue #557
+&quot;ErrorCorruptImage: Magick: Unexpected end-of-file ()&quot; where an
+EOF error was reported due to no mask data being supplied.</li>
+<li>coders/png.c (ReadOneJNGImage): The embedded JPEG image is
+required to have the same dimensions as the JNG image as provided
+by JHDR.  Fixes SourceForge bug 555 &quot;heap-buffer-overflow in
+AcquireCacheNexus when processing jng file&quot;.  It is likely that
+this issue is precipitated by using 'montage' which seems to set a
+default non-zero image size.
+(ReadMNGImage): By default limit the maximum loops specifiable by
+the MNG LOOP chunk to 512 loops, but allow this to be modified by
+'-define mng:maximum-loops=value'.  Also assure that the value is
+in the range of 0-2147483647 as per the MNG specification.  This
+is to address the denial of service issue described by
+CVE-2018-10177.  This problem was reported to us by Petr Gajdos
+via email on Fri, 20 Apr 2018.</li>
+<li>coders/dpx.c (ReadDPXImage): Move misplaced channel validation
+code.  Fixes oss-fuzz 8041 &quot;graphicsmagick/coder_DPX_fuzzer:
+Use-of-uninitialized-value in WriteDPXImage&quot; and oss-fuzz 8055
+&quot;graphicsmagick/enhance_fuzzer: Use-of-uninitialized-value in
+EnhanceImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-27  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/xpm.c (StringToListMod): Algorithm fixes to fix use of
+uninitialized data.  Fixes oss-fuzz 8046
+&quot;graphicsmagick/coder_XPM_fuzzer: Use-of-uninitialized-value in
+StringToListMod&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-26  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/xpm.c (ReadXPMImage): Reduce memory consumption further.
+Hopefully fixes oss-fuzz 8013 &quot;graphicsmagick/coder_XPM_fuzzer:
+Out-of-memory in graphicsmagick_coder_XPM_fuzzer&quot;. (Credit to
+OSS-Fuzz)</li>
+<li>magick/utility.c (StringToList): Only allocate the memory
+required when converting string to an ASCII list.  May or may not
+fix oss-fuzz 8013 &quot;graphicsmagick/coder_XPM_fuzzer: Out-of-memory
+in graphicsmagick_coder_XPM_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-24  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/bmp.c (ReadBMPImage): Fix benign use of uninitialized
+data when testing header magick.  Fixes oss-fuzz 7980
+&quot;graphicsmagick/coder_BMP_fuzzer: Use-of-uninitialized-value in
+LocaleNCompare&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/dpx.c (ReadDPXImage): ColorDifferenceCbCr does require
+even image width. Fixes oss-fuzz 7966
+&quot;graphicsmagick/coder_DPX_fuzzer: Unknown signal in
+TentUpsampleChroma&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-23  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dpx.c (ReadDPXImage): ColorDifferenceCbCr element
+requires two samples/pixel, not one. Fixes oss-fuzz 7951
+&quot;graphicsmagick/coder_DPX_fuzzer: Heap-buffer-overflow in
+ReadDPXImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-22  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pdb.c (ReadPDBImage): Assure that pixels buffer is
+initialized.  Fixes oss-fuzz 7937
+&quot;graphicsmagick/coder_PDB_fuzzer: Use-of-uninitialized-value in
+ReadPDBImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/mvg.c (ReadMVGImage): Assure that MVG viewbox parameters
+were supplied.  Fixes oss-fuzz 7936
+&quot;graphicsmagick/coder_MVG_fuzzer: Use-of-uninitialized-value in
+ReadMVGImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/dpx.c (ReadDPXImage): Element descriptors CbYCrY422 and
+CbYACrYA4224 require that the image width be evenly divisible by 2
+so enforce that.  Fixes oss-fuzz 7935
+&quot;graphicsmagick/coder_DPX_fuzzer: Heap-buffer-overflow in
+ReadDPXImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-21  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dpx.c (ReadDPXImage): Reject DPX files which claim to use
+signed data.  Fixes oss-fuzz 7758
+&quot;graphicsmagick/coder_DPX_fuzzer: Use-of-uninitialized-value in
+WriteDPXImage&quot;. (Credit to OSS-Fuzz)
+(ReadDPXImage): Validate that the image elements do update all of
+the channels, including the alpha channel.  Now report an error if
+a color channel is missing.  Fixes oss-fuzz 7758
+&quot;graphicsmagick/coder_DPX_fuzzer: Use-of-uninitialized-value in
+WriteDPXImage&quot;.</li>
+<li>coders/gif.c (DecodeImage): Finally fix oss-fuzz 7732
+&quot;graphicsmagick/coder_GIF_fuzzer: Heap-buffer-overflow in
+DecodeImage&quot; which was not actually fixed with previous
+changes. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-21  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li><dl class="first docutils">
+<dt>coders/topol.c Emit error when tile storage overflows image data;</dt>
+<dd>fixes oss-fuzz 7769 thanks to oss-fuzz.</dd>
+</dl>
+</li>
+</ul>
+</blockquote>
+<p>2018-04-20  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (ConvertPrimitiveToPath):  Fixed a bug
+in which SVG paths containing multiple open subpaths were
+not being processed correctly, resulting in incorrect
+output.  This fixes ticket #94.</li>
+</ul>
+</blockquote>
+<p>2018-04-18  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/gif.c (DecodeImage): Fix use of uninitialized memory
+during error condition in decoder. Fixes oss-fuzz 7732
+&quot;graphicsmagick/coder_GIF_fuzzer: Heap-buffer-overflow in
+DecodeImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/txt.c (ReadTXTImage): Assure that all image pixels are
+initialized to black.</li>
+<li>Magick++/demo/zoom.cpp (main): Add a -read-blob option to read
+input file into a Blob so that it is read by the Blob reader
+rather than the file reader.  Default the output Geometry to the
+input image geometry in case the user does not specify a resize
+resolution or geometry.</li>
+<li>Magick++/tests/readWriteBlob.cpp (main): Improve the quality of
+code which reads a file into memory for Blob testing.</li>
+<li>magick/blob.c (BlobToImage): Add exception reports for the cases
+where 'magick' was not set and the file format could not be
+deduced from its header.  Previously a null Image pointer was
+being returned without any exception being thrown.</li>
+</ul>
+</blockquote>
+<p>2018-04-15  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dpx.c (ReadDPXImage): Assure that CbCr layer initializes
+all channels if it is the first element of a planar DPX.  Fixes
+oss-fuzz 7703 &quot;graphicsmagick/coder_DPX_fuzzer:
+Use-of-uninitialized-value in WriteDPXImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/pict.c (ReadPICTImage): Don't refer to filename member of
+ImageInfo which was just destroyed. Much thanks to Alex Gaynor for
+finding this.  Should fix oss-fuzz 6867
+&quot;graphicsmagick/coder_PCT_fuzzer: Heap-use-after-free in
+GetLocaleExceptionMessage&quot;. (Credit to OSS-Fuzz).</li>
+</ul>
+</blockquote>
+<p>2018-04-14  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/sgi.c (ReadSGIImage): Assure that iris pixels are fully
+initialized.  Fixes oss-fuzz 7543
+&quot;graphicsmagick/coder_SGI_fuzzer: Use-of-uninitialized-value in
+SGIEncode&quot;. (Credit to OSS-Fuzz).</li>
+<li>coders/xcf.c (ReadXCFImage): Restore SetImage() which was
+previously commented out.  This is needed to assure initialized
+pixels.  Fixes oss-fuzz 7430 &quot;graphicsmagick/coder_XCF_fuzzer:
+Use-of-uninitialized-value in AlphaCompositePixel&quot;. (Credit to
+OSS-Fuzz).</li>
+<li>coders/pict.c (ReadPICTImage): Properly initialize &quot;black
+canvas&quot; that tiles may be composed on.  Fixes oss-fuzz 7574
+&quot;graphicsmagick/enhance_fuzzer: Use-of-uninitialized-value in
+EnhanceImage&quot;. (Credit to OSS-Fuzz).</li>
+<li>coders/rle.c (ReadRLEImage): Check for EOF when reading comment.
+Fixes oss-fuzz 7667 &quot;graphicsmagick/coder_RLE_fuzzer:
+Use-of-uninitialized-value in ReadRLEImage&quot;. (Credit to OSS-Fuzz).</li>
+<li>coders/pdb.c (WritePDBImage): Avoid use of uninitialized
+bytes. Fixes oss-fuzz 7638 &quot;graphicsmagick/coder_PDB_fuzzer:
+Use-of-uninitialized-value in WritePDBImage&quot;. (Credit to
+OSS-Fuzz).</li>
+<li>coders/rla.c (ReadRLAImage): Add many more validations,
+including scanline offsets and number of channels.  Fixes oss-fuzz
+7653 &quot;graphicsmagick/coder_RLA_fuzzer: Timeout in
+graphicsmagick_coder_RLA_fuzzer&quot;. (Credit to OSS-Fuzz).</li>
+<li>coders/txt.c (ReadTXTImage): Implement missing subrange logic to
+read only the specified range of frames.  Limits frames read from
+oss-fuzz test case
+clusterfuzz-testcase-minimized-coder_TEXT_fuzzer-6061076048248832
+&quot;graphicsmagick/coder_TEXT_fuzzer: Timeout in
+graphicsmagick_coder_TEXT_fuzzer&quot;. (Credit to OSS-Fuzz).</li>
+<li>Magick++/lib/Image.cpp (read): Set subrange = 1 since this
+interface is intended to read just one frame from the input file.
+Use the STL-based interfaces to read multiple frames.</li>
+<li>coders/fits.c (ReadFITSImage): Verify FITS header before reading
+further.  Rejects file from oss-fuzz 7650
+&quot;graphicsmagick/coder_FITS_fuzzer: Out-of-memory in
+graphicsmagick_coder_FITS_fuzzer&quot;.  (Credit to OSS-Fuzz).</li>
+<li>PerlMagick/Magick.xs (Get): Fix PerlMagick compilation problem
+due to rename/repurposing of image-&gt;clip_mask.</li>
+</ul>
+</blockquote>
+<p>2018-04-13  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/image.c, magick/image.h:  In order to be able to
+support SVG masks, and to be able to further extend the
+Image data structure without changing its size, new data
+structure ImageExtra (struct _ImageExtra) has been added.
+Header file image.h contains only a forward declaration;
+the members of ImageExtra are defined in file image.c.
+Image member variable Image * clip_mask has been replaced
+by ImageExtra * extra, and function prototypes that enable
+access to ImageExtra have been added to image.h.  The
+clip_mask member variable now resides in ImageExtra.  All
+references to Image::clip_mask in the GraphicsMagick
+source code have either been replaced with direct references
+to ImageExtra::clip_mask (image.c), or have been replaced
+with calls to access function ImageGetClipMask().</li>
+<li>magick/render.c, magick/render.h:  In order to be able to
+support SVG masks, and to be able to further extend the
+DrawInfo data structure without changing its size, new data
+structure DrawInfoExtra (struct _DrawInfoExtra) has been added.
+Header file render.h contains only a forward declaration;
+the members of DrawInfoExtra are defined in file render.c.
+DrawInfo member variable char * clip_path has been replaced by
+DrawInfoExtra * extra, and function prototypes that enable
+access to DrawInfoExtra have been added to render.h.  The
+clip_path member variable now resides in ImageExtra.  All
+references to DrawInfo::clip_path in the GraphicsMagick
+source code have either been replaced with direct references
+to DrawInfoExtra::clip_path (render.c), or have been
+replaced with calls to access function DrawInfoGetClipPath().</li>
+<li>magick/image.c (new functions CompositePathImage,
+CompositeMaskImage, GetImageCompositeMask,
+SetImageCompositeMask):  Defined new data structure ImageExtra,
+added create/destroy logic, and implemented associated access
+functions.  Implemented SVG masks.</li>
+<li>magick/render.c (DrawImage, new function DrawCompositeMask):
+Defined new data structure DrawInfoExtra, added create/destroy
+logic, and implemented associated access functions.  Impemented
+SVG masks.</li>
+<li>magick/pixel_cache.c (SyncCacheNexus, new function
+CompositeCacheNexus):  Fixed references to Image::clip_mask.
+Implemented SVG masks.</li>
+<li>coders/svg.c (SVGStartElement, SVGEndElement): Implemented
+SVG masks.</li>
+<li>locale/c.mgk, magick/gm_messages.mc, magick/local_c.h:
+Added new error codes to support SVG masks.</li>
+<li>coders/ps3.c, magick/enhance.c: Fixed references to
+Image::clip_mask.</li>
+<li>magick/draw.c, wand/drawing_wand.c: Fixed references to
+DrawInfo::clip_path.</li>
+</ul>
+</blockquote>
+<p>2018-04-13  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wpg.c Crash on row overflow fixed oss-fuzz 7639 thanks to oss-fuzz.</li>
+</ul>
+</blockquote>
+<p>2018-04-11  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dpx.c (ReadDPXImage): Add more header validations.
+Always assure that scanline is initialized for Luma channel. Fixes
+oss-fuzz 7544 &quot;graphicsmagick/coder_DPX_fuzzer:
+Use-of-uninitialized-value in WriteDPXImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/pdb.c (ReadPDBImage): Add more EOF checks to avoid benign
+use of uninitialized data.  Fixes oss-fuzz 7545
+&quot;graphicsmagick/coder_PDB_fuzzer: Use-of-uninitialized-value in
+ReadPDBImage&quot;.</li>
+<li>coders/wpg.c (InsertRow, UnpackWPGRaster): x &amp; y should be
+'unsigned long' to match type used by pixel cache APIs and image
+rows/columns.</li>
+</ul>
+</blockquote>
+<p>2018-04-08  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wpg.c Stop reading when last row is reached.
+This should stop oss-fuzz 7528 thanks to oss-fuzz.</li>
+</ul>
+</blockquote>
+<p>2018-04-10  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/xcf.c (ReadXCFImage): Fix use of uninitialized data in
+magick header string for runt file.  Fixes oss-fuzz 7521
+&quot;graphicsmagick/coder_XCF_fuzzer: Use-of-uninitialized-value in
+LocaleNCompare&quot;. (Credit to OSS-Fuzz).</li>
+</ul>
+</blockquote>
+<p>2018-04-09  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>OVERVIEW: Change set 9aaeeca0224c modified the drawing
+of clipping paths to conform to the SVG spec.  This change
+set restores the previous behavior for non-SVG clients of
+render.c, while still satisfying the SVG spec for SVG clients.</li>
+<li>magick/render.h (DrawInfo): Added a bit field in member
+&quot;flags&quot; to indicate that drawing should be SVG compliant.</li>
+<li>magick/render.c (DrawImage): Now recognizes keyword
+&quot;svg-compliant&quot;, and tags DrawInfo accordingly.  This
+allows for existing features in render.c to be changed
+to comply with the SVG spec without impacting the previous
+behavior expected by non-SVG clients.</li>
+<li>magick/render.c (DrawImage): Now uses DrawInfo &quot;flags&quot;
+bit for SVG compliance in conjunction with &quot;flags&quot; bit
+for &quot;clipping path&quot; to determine when to ignore changes
+to fill color, stroke color, etc.  This restores the
+previous behavior for clipping paths for non-SVG clients.</li>
+<li>coders/svg.c (SVGStartElement): The initial set of
+MVG commands for rendering an SVG file now includes
+new keyword &quot;svg-compliant&quot; (to indicate that certain
+graphical elements should be drawn according to the
+SVG spec), and includes an intialization of the SVG
+&quot;fill-rule&quot; to &quot;nonzero&quot; (the SVG default) instead of
+the internally initialized value of &quot;evenodd&quot;.</li>
+<li>coders/wpg.c: Fixed C99 &quot;//&quot; comments.</li>
+</ul>
+</blockquote>
+<p>2018-04-08  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pict.c (ReadPICTImage): Copy tile exception info to main
+image and don't composite tile if it has a problem.  Fixes
+oss-fuzz 7169 &quot;graphicsmagick/enhance_fuzzer:
+Use-of-uninitialized-value in EnhanceImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/dib.c (ReadDIBImage): Do not increase decode bits/pixel
+if compression=2, but use it to increase pixel packet size when
+estimating bytes per line for decode buffer.  Fixes oss-fuzz issue
+7324 &quot;graphicsmagick/coder_WPG_fuzzer: Use-of-uninitialized-value
+in ReadDIBImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/dpx.c (ReadDPXImage): When handling the first element of
+a planar DPX, assure that the other channels are
+initialized. Fixes oss-fuzz 7841 &quot;graphicsmagick/coder_DPX_fuzzer:
+Use-of-uninitialized-value in WriteDPXImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/tim.c (ReadTIMImage): Only 4 and 8 bit TIM requires a
+colormap. For other depths, force reading as DirectClass even if
+the TIM file provides a colormap.  Fixes oss-fuzz 7407
+&quot;graphicsmagick/coder_TIM_fuzzer: Use-of-uninitialized-value in
+SyncImageCallBack&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-08  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c The unread data contains crap in memory,
+erase current image data. This should mute oss-fuzz 6604.</li>
+<li>coders/wpg.c - condition &quot;if(y&lt;1) continue;&quot; is redundant
+and could be removed completely.
+Allow logging in MatlabV4 module.</li>
+<li>coders/svg.c - Do not use C++ syntax in C code - removed.</li>
+</ul>
+</blockquote>
+<p>2018-04-07  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wpg.c (UnpackWPGRaster): Fix uninitialized row 0 when
+row-based RLE is used.  Fixes oss-fuzz 6603
+&quot;graphicsmagick/enhance_fuzzer: Use-of-uninitialized-value in
+BlendCompositePixel&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/pcd.c: Fix many issues, including oss-fuzz 6016
+&quot;graphicsmagick/coder_PCD_fuzzer: Heap-double-free in
+MagickRealloc&quot; and oss-fuzz 6108 &quot;graphicsmagick/coder_PCD_fuzzer:
+Unknown signal in AllocateThreadViewDataSet&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-06  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dcm.c (funcDCM_BitsStored): Limit DICOM significant bits
+to 16.  Otherwise rescale map code blows up.  Fixes oss-fuzz 7435
+&quot;graphicsmagick/coder_DCM_fuzzer: Out-of-memory in
+graphicsmagick_coder_DCM_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/pix.c (ReadPIXImage): Detect EOF.  Reject RLE lenth of
+zero.  Fixes oss-fuzz 7440 &quot;graphicsmagick/coder_PIX_fuzzer:
+Out-of-memory in graphicsmagick_coder_PIX_fuzzer&quot;. (Credit to
+OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-05  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dpx.c (ReadDPXImage): Insist on having an element
+descriptor we understand since otherwise we can not decode the
+image.  Fixes oss-fuzz 7410 &quot;graphicsmagick/coder_DPX_fuzzer:
+Use-of-uninitialized-value in WriteDPXImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/avs.c, etc... (WriteAVSImage): Cache image list length
+before writing image sequence so that progress monitor is
+scalable.  Helps with oss-fuzz 7404
+&quot;graphicsmagick/coder_AVS_fuzzer: Timeout in
+graphicsmagick_coder_AVS_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-05  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/svg.c (SVGStartElement, SVGEndElement),
+magick/render.c (DrawImage): The current text position
+is now maintained by DrawImage() instead of by
+SVGStartElement() and SVGEndElement().  This change was
+made to support the recently implmemented &quot;use&quot; and
+&quot;class&quot; elements, which may make changes to the font
+size that are not visible to the code in svg.c.</li>
+<li>coders/svg.c (GetStyleTokens, SVGStartElement): The
+list of SVG attributes is now reordered so that
+&quot;font-size&quot;, &quot;class&quot;, and &quot;style&quot; are processed first.
+This ensures that a change to the font size will be
+processed before any dimensional attribute whose value
+may depend on the font size (e.g., a width value
+specified in &quot;em&quot; units).</li>
+<li>coders/svg.c (ProcessStyleClassDefs): Fixed two memory
+leaks associated with making an early return when
+malformed input is detected.</li>
+<li>magick/render.c (ExtractTokensBetweenPushPop): Fixed
+an uninitialized variable condition which can occur when
+malformed input is detected.</li>
+<li>magick/render.h (DrawInfo), magick/render.c: DrawInfo
+member &quot;unused1&quot; has been renamed &quot;flags&quot;.  It is now
+used to tag a DrawInfo as being a clipping path or a
+compositing mask.</li>
+</ul>
+</blockquote>
+<p>2018-04-04  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pdb.c (ReadPDBImage): Update DirectClass pixels to avoid
+use of uninitialized memory for 2 bits/pixel.  Fixes oss-fuzz 7350
+&quot;graphicsmagick/coder_PDB_fuzzer: Use-of-uninitialized-value in
+WritePDBImage&quot;.  (Credit to OSS-Fuzz)</li>
+<li>coders/palm.c (ReadPALMImage): Fix use of uninitialized memory.
+Fixes oss-fuzz 7325 &quot;graphicsmagick/coder_PALM_fuzzer:
+Use-of-uninitialized-value in TransparentImageCallBack&quot;. (Credit
+to OSS-Fuzz)</li>
+<li>coders/dcm.c (DCM_ReadNonNativeImages): Break out of reading
+loop on EOF and properly report exception.  Fixes oss-fuzz 7349
+&quot;graphicsmagick/coder_DCM_fuzzer: Timeout in
+graphicsmagick_coder_DCM_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-03  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/xcf.c (ReadXCFImage): Require that XCF file offsets be in
+ascending order to avoid DOS.  Fixes oss-fuzz 7333
+&quot;graphicsmagick/coder_XCF_fuzzer: Out-of-memory in
+graphicsmagick_coder_XCF_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/wpg.c (UnpackWPGRaster): Fix memory leak in error return
+path. Fixes oss-fuzz 7338 &quot;graphicsmagick/enhance_fuzzer:
+Direct-leak in UnpackWPGRaster&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-03  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/svg.c (SVGStartElement): This changeset adds
+support for SVG geometric transforms specified using the
+style=&quot;transform: ...&quot; syntax.  This syntax is sometimes
+used when exporting SVG files from Adobe Illustrator.</li>
+</ul>
+</blockquote>
+<p>2018-04-02  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dpx.c (ReadDPXImage): Validate DPX packing method.  Fixes
+oss-fuzz 7296 &quot;graphicsmagick/coder_DPX_fuzzer:
+Use-of-uninitialized-value in WriteDPXImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-04-02  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/svg.c (SVGStartElement, SVGEndElement),
+magick/render.c (DrawImage): This changeset adds support for
+&quot;class&quot; styling attributes within a &lt;style&gt; section within
+the &lt;defs&gt; section, and the ability to reference them from
+other SVG elements by class=&quot;classname&quot;.  SVG files exported
+from Adobe Illustrator make extensive use of &quot;class&quot; definitions.</li>
+</ul>
+</blockquote>
+<p>2018-04-01  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pict.c (ReadPICTImage): Fix leak of tile image on EOF.
+This is a recent regression.  Fixes oss-fuzz 7287
+&quot;graphicsmagick/coder_PCT_fuzzer: Indirect-leak in
+CloneImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>magick/pixel_cache.c (OpenCache): Use image-&gt;scene rather than
+GetImageIndexInList(image) for scene-id part of cache info file
+name.</li>
+<li>coders/txt.c (WriteTXTImage): Optimize the progress indicator
+since it is very inefficient with a large number of scenes and
+oss-fuzz 7090 &quot;graphicsmagick/coder_TEXT_fuzzer: Timeout in
+graphicsmagick_coder_TEXT_fuzzer&quot; consistently shows
+GetImageListLength() in its stack traces.</li>
+<li>coders/dcm.c (ReadDCMImage): DICOM reader was no longer
+immediately quitting with excessive samples per pixel.  This
+caused spinning for a very long time when reading planar images
+with large samples per pixel.  This is a regression due to recent
+changes.  Fixes oss-fuzz 7269 &quot;graphicsmagick/coder_DCM_fuzzer:
+Timeout in graphicsmagick_coder_DCM_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/xcf.c (ReadXCFImage): Destroy layer info before returning
+due to exception.  This is a new regression due to adding more
+checks. Fixes oss-fuzz 7277 &quot;graphicsmagick/coder_XCF_fuzzer:
+Direct-leak in ReadXCFImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/pdb.c (ReadPDBImage): Assure that all bytes of scanline
+are initialized while decoding.  Fixes oss-fuzz 7051
+&quot;graphicsmagick/coder_PDB_fuzzer: Use-of-uninitialized-value in
+WritePDBImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-03-31  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pcx.c (ReadPCXImage): Assure that scanline is
+initialized.  Fixes oss-fuzz 6612
+&quot;graphicsmagick/coder_PCX_fuzzer: Use-of-uninitialized-value in
+WriteRLEPixels&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/wpg.c (ReadWPGImage): Detect unexpected EOF and avoid use
+of uninitialized data.  Fixes oss-fuzz 6601
+&quot;graphicsmagick/enhance_fuzzer: Use-of-uninitialized-value in
+ImportIndexQuantumType&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/sgi.c (ReadSGIImage): Assure that RLE decode buffer is
+initialized.  Fixes oss-fuzz 6599
+&quot;graphicsmagick/coder_SGI_fuzzer: Use-of-uninitialized-value in
+SyncImageCallBack&quot; and oss-fuzz 6600
+&quot;graphicsmagick/coder_SGI_fuzzer: Use-of-uninitialized-value in
+SGIEncode&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/viff.c (ReadVIFFImage): Fix blob I/O size validation to
+avoid use of uninitialized data. Fixes oss-fuzz 6597
+&quot;graphicsmagick/coder_VIFF_fuzzer: Use-of-uninitialized-value in
+ThresholdImage&quot;. (Credit to OSS-Fuzz)
+(ReadVIFFImage): Don't execute SetImageType(image,BilevelType) on
+an image which has no pixels yet in order to avoid use of
+uninitialized data. Fixes oss-fuzz 6597.  (Credit to OSS-Fuzz)</li>
+<li>coders/wbmp.c (ReadWBMPImage): Fix blob I/O size validation to
+avoid use of uninitialized data. Fixes oss-fuzz 7047
+&quot;graphicsmagick/coder_WBMP_fuzzer: Use-of-uninitialized-value in
+ReadWBMPImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/wpg.c (ExtractPostscript): Allow non-Postscript content
+but force reading using the magick we already detected.  Also log
+the format that we detected.</li>
+<li>coders/xcf.c (ReadOneLayer): Reject layer size of 0x0.  Fixes
+oss-fuzz 6636 &quot;graphicsmagick/coder_XCF_fuzzer: Direct-leak in
+MagickMallocAligned&quot;. (Credit to OSS-Fuzz)
+(ReadXCFImage): Verify that seek offsets are within the bounds of
+the file data. Fixes oss-fuzz 6682
+&quot;graphicsmagick/coder_XCF_fuzzer: Out-of-memory in
+graphicsmagick_coder_XCF_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>magick/pixel_cache.c (ModifyCache): Destroy CacheInfo if
+OpenCache() fails so it is not leaked.</li>
+<li>coders/wpg.c (ExtractPostscript): Enforce that embedded file is
+a Postscript file.  Fixes oss-fuzz 7235
+&quot;graphicsmagick/coder_WPG_fuzzer: Indirect-leak in MagickRealloc&quot;.
+This is indicated to be a regression. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-03-30  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pict.c (ReadPICTImage): Check image pixel limits before
+allocating memory for tile.  Fixes oss-fuzz 7217
+&quot;graphicsmagick/coder_PICT_fuzzer: Out-of-memory in
+graphicsmagick_coder_PICT_fuzzer&quot;.</li>
+</ul>
+</blockquote>
+<p>2018-03-29  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pcd.c (ReadPCDImage): Add checks for EOF. Fixes oss-fuzz
+issue 7180 &quot;graphicsmagick/coder_PCDS_fuzzer: Timeout in
+graphicsmagick_coder_PCDS_fuzzer&quot;.  (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-03-29  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul>
+<li><p class="first">coders/svg.c (SVGStartElement, SVGEndElement),
+magick/render.c (DrawImage): This changeset implements the SVG
+&quot;use&quot; element.  Graphical elements (e.g., &quot;rect&quot;, &quot;text&quot;, etc.)
+can be tagged with an identifier using 'id=&quot;identifier&quot;' when
+defined within the &quot;defs&quot; section.  They can then be referenced
+elsewhere in the SVG file using:</p>
+<p>&lt;use xlink:href=&quot;#identifier&quot; ... /&gt;</p>
+<p>When referencing a graphical element by its identifier, the
+following syntaxes are now treated as being the same:</p>
+<p>href=&quot;#identifier&quot;
+href=&quot;url(#identifier)&quot;
+xlink:href=&quot;#identifier&quot;
+xlink:href=&quot;url(#identifier)&quot;</p>
+</li>
+</ul>
+</blockquote>
+<p>2018-03-27  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/tim.c (ReadTIMImage): Reader was not observing subimage
+and subrange to quit after the specified frame range.  Inspired by
+oss-fuzz 7132 &quot;graphicsmagick/coder_TIM_fuzzer: Timeout in
+graphicsmagick_coder_TIM_fuzzer&quot; (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-03-27  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/svg.c (SVGStartElement): Enable setting the
+background color from the SVG file when the client
+specifies style=&quot;background:color&quot; inside the &lt;svg&gt;
+... &lt;/svg&gt; element.</li>
+</ul>
+</blockquote>
+<p>2018-03-25  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mtv.c (ReadMTVImage): Add some elementary tracing to MTV
+reader.</li>
+<li>coders/png.c (ReadMNGImage): Fix SourceForge issue 554
+&quot;Divide-by-zero in ReadMNGImage (coders/png.c)&quot;.  (Credit to Trace
+Probe)</li>
+<li>coders/bmp.c (ReadBMPImage): Assure that start position always
+advances to avoid looping BMPs.  Fixes oss-fuzz 7045
+&quot;graphicsmagick/coder_BMP_fuzzer: Timeout in
+graphicsmagick_coder_BMP_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/pict.c (DecodeImage): Verify that sufficient backing data
+exists before allocating memory to read it.  Fixes oss-fuzz 6629
+&quot;graphicsmagick/coder_PCT_fuzzer: Out-of-memory in
+graphicsmagick_coder_PCT_fuzzer&quot;.
+(ReadPICTImage): Destroy tile_image in ThrowPICTReaderException()
+macro to simplify logic.</li>
+</ul>
+</blockquote>
+<p>2018-03-25  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c Check whether datablock is really read.
+Fixes oss-fuzz 7056 (Credit to OSS-Fuzz)</li>
+<li>coders/txt.c Duplicate image check for data with fixed geometry
+previous check is skipped. Fixes oss-fuzz 7090.</li>
+</ul>
+</blockquote>
+<p>2018-03-24  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dcm.c (ReadDCMImage): Validate that samples per pixel is
+in valid range.  Fixes oss-fuzz 6260
+&quot;graphicsmagick/coder_DCM_fuzzer: Out-of-memory in
+graphicsmagick_coder_DCM_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/meta.c (format8BIM): Allocate space for null termination
+and null terminate string.  Fixes oss-fuzz 5985
+&quot;graphicsmagick/coder_8BIMTEXT_fuzzer: Heap-buffer-overflow in
+formatIPTCfromBuffer&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/fits.c (ReadFITSImage): Include number of FITS scenes in
+file size validations.  Fixes oss-fuzz 6781
+&quot;graphicsmagick/coder_FITS_fuzzer: Timeout in
+graphicsmagick_coder_FITS_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-03-23  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/meta.c (format8BIM): Validate size request prior to
+allocation. Fixes oss-fuzz issue 5974
+&quot;graphicsmagick/coder_8BIMTEXT_fuzzer: Out-of-memory in
+graphicsmagick_coder_8BIMTEXT_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-03-23  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul>
+<li><p class="first">coders/mat.c Fix forged amount of frames 7076. (Credit to OSS-Fuzz)</p>
+<blockquote>
+<p>* coders/topol.c Check for forged image that overflows file size
+(fuzz 6836).</p>
+</blockquote>
+</li>
+</ul>
+</blockquote>
+<p>2018-03-23  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul>
+<li><p class="first">magick/render.c, render.h (DrawInfo, CloneDrawInfo,
+DrawClipPath, DrawImage, GetDrawInfo): According to the SVG
+spec, a clipping path is defined only by the geometry of its
+constituent elements, and is not dependent on fill color/opacity,
+stroke color/opacity, or stroke width.  To ensure conformity
+with the spec, when a clipping path is created, these SVG
+elements are set to appropriate values, and any attempt to
+modify them is ignored.</p>
+<p>Also, whenever a clipping path is drawn, the associated image
+attributes are now updated from the parent image structure.
+This ensures that any added or modified attributes are up to
+date.</p>
+</li>
+</ul>
+</blockquote>
+<p>2018-03-22  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul>
+<li><dl class="first docutils">
+<dt>coders/topol.c Use rather MagickSwabArrayOfUInt32() to</dt>
+<dd><p class="first">flip all array elements at once.</p>
+<p class="last">* magick/annotate.c Compilation issue - using C++ syntax in C code.</p>
+</dd>
+</dl>
+</li>
+</ul>
+</blockquote>
+<p>2018-03-20  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dpx.c (ReadDPXImage): Validate header length and offset
+properties.  Fixes oss-fuzz &quot;graphicsmagick/coder_DPX_fuzzer:
+Use-of-uninitialized-value in WriteDPXImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-03-20  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/annotate.c (RenderType): According to the SVG
+spec, the 'font-family' element can be a comma-separated
+list of one or more font family names.  Function RenderType
+in file annotate.c has been modified to support multiple
+font family names as follows.  The comma-separated list is
+processed until the first available font family is found.
+If no font family is found, or if font substitution occurred,
+then the entire font family string is tested to see if it
+exactly matches a font name, or if the font family string
+with blanks changed to hypens exactly matches a font name.
+If a font name match is found, the matched font overrides
+the font substution.  The font name matching functionality
+is beyond what's in the SVG spec and is provided as a
+convenience to the user.</li>
+</ul>
+</blockquote>
+<p>2018-03-20  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c Fix forged amount of frames 6755. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-03-20  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/topol.c Redesign ReadBlobDwordLSB() to be more effective.</li>
+</ul>
+</blockquote>
+<p>2018-03-19  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/xpm.c (ReadXPMImage): Reject XPM if its condensed version
+contains non-whitespace control characters.  Fixes oss-fuzz 7027
+&quot;graphicsmagick/coder_XPM_fuzzer: Timeout in
+graphicsmagick_coder_XPM_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-03-19  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/topol.c Fix tile index overflow fuzz 6634. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-03-19  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dcm.c (DCM_ReadGrayscaleImage): Don't use rescale map if
+it was not allocated.  This issue was induced in this development
+cycle due to disabling generating the rescale map.  Fixes oss-fuzz
+7021 &quot;graphicsmagick/coder_DCM_fuzzer: Null-dereference READ in
+DCM_ReadGrayscaleImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-03-18  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/color_lookup.c (QueryColorDatabase): Defend against
+partial scanf() expression matching, resulting in use of
+uninitialized data.  Likely fixes oss-fuzz 6596
+&quot;graphicsmagick/coder_XPM_fuzzer: Use-of-uninitialized-value in
+IsMonochromeImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/rle.c (ReadRLEImage): Validate number of colormap bits to
+avoid undefined shift behavior.  Fixes oss-fuzz 6630
+&quot;graphicsmagick/enhance_fuzzer: Undefined-shift in
+ReadRLEImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/dcm.c (DCM_ReadRGBImage): Don't use rescale map if it was
+not allocated.  This issue was induced in this development cycle
+due to disabling generating the rescale map.  Fixes oss-fuzz 6995
+&quot;graphicsmagick/coder_DCM_fuzzer: Null-dereference READ in
+DCM_ReadRGBImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/dib.c (DecodeImage): Report failure to decode to expected
+amount of pixel data as an error.  Fixes oss-fuzz 7007
+&quot;graphicsmagick/enhance_fuzzer: Use-of-uninitialized-value in
+EnhanceImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/bmp.c (ReadBMPImage): Add file size and offset/seek
+validations.  Fixes oss-fuzz 6623
+&quot;graphicsmagick/coder_BMP_fuzzer: Timeout in
+graphicsmagick_coder_BMP_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-03-17  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>dcraw/dcraw.c Updated to version 9.27</li>
+</ul>
+</blockquote>
+<p>2018-03-15  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/gif.c (ReadGIFImage): Fix botched fixes for use of
+uninitialized data when reading GIF extension blocks.  Hopefully
+ok now.</li>
+</ul>
+</blockquote>
+<p>2018-03-13  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/gif.c (ReadGIFImage): Fix use of uninitialized data when
+reading GIF extension blocks.  Fixes oss-fuzz 6609
+&quot;graphicsmagick/coder_GIF_fuzzer: Use-of-uninitialized-value in
+MagickArraySize&quot;. This seems to be a totally benign issue. (Credit
+to OSS-Fuzz)</li>
+<li>magick/magick.c (MagickSignal): Use an alternate signal stack,
+if available.  This is required for Go lang C language extensions
+since Go lang requests an alternate signal sack, and uses small
+stacks for its threads.  If the library user has not allocated an
+alternate signal stack, then behavior should be just as before.
+Issue was originally reported by yzh杨振宏 on March 1, 2018 via
+the graphicsmagick-help SourceForge mailing list.</li>
+</ul>
+</blockquote>
+<p>2018-02-28  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/pixel_cache.c (AcquireCacheNexus): Add a check that the
+pixel cache is compatible with the image dimensions.  Fixes
+oss-fuzz issues 5978 5988 5989 5990 5993 6016, and 6056, which are
+all related to the PICT writer. (Credit to OSS-Fuzz)</li>
+<li>magick/draw.c (DrawGetStrokeDashArray): Check for failure to
+allocate memory.  Patch submited by Petr Gajdos via email on
+February 28, 2018.</li>
+</ul>
+</blockquote>
+<p>2018-02-27  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/fits.c (ReadFITSImage): Fix signed integer overflow when
+computing pixels size.  Fixes oss-fuzz 6586
+&quot;graphicsmagick/coder_FITS_fuzzer: Integer-overflow in
+ReadFITSImage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-27  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/svg.c (SVGStartElement, SVGEndElement): From the
+SVG spec:  &quot;The 'foreignObject' element allows for inclusion
+of a foreign namespace which has its graphical content drawn
+by a different user agent.&quot;  Code has been added to consume
+and discard the 'foreignObject' element and any settings (e.g.,
+fill color) internal to it.  Previously, settings internal
+to the 'foreignObject' element would persist and &quot;leak&quot; into
+the graphic elements that followed it, resulting in undesired
+side effects (e.g., fill color other than the expected default).</li>
+</ul>
+</blockquote>
+<p>2018-02-27  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (DrawPolygonPrimitive): Fixed a bug
+introduced by changeset 39102dd1d456.  For SVG, this
+changeset applied both the group AND the fill opacity
+values to fill patterns (similarly for stroke).  For WMF,
+however, this caused the fill pattern to be rendered as
+100% transparent.  A closer reading of the SVG spec does
+NOT show that the fill opacity should be applied to the
+fill pattern, so as of this latest changeset only the group
+opacity value is applied to fill and stroke patterns.</li>
+</ul>
+</blockquote>
+<p>2018-02-27  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/bmp.c (ReadBMPImage): Fix divide by zero regression added
+by latest fixes.  Fixes oss-fuzz 6583
+&quot;graphicsmagick/coder_BMP_fuzzer: Divide-by-zero in ReadBMPImage&quot;.
+(Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-26  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pict.c (ReadPICTImage): Validate that PICT rectangles do
+not have zero dimensions.  Specify expected file type when reading
+from a temporary file.  Trace PICT rectangle dimensions.  More
+detection of blob EOF and more error handling.  Fixes oss-fuzz
+issue 6193 &quot;graphicsmagick/coder_PCT_fuzzer: Unknown signal in
+AllocateImageColormap&quot; and likely many oss-fuzz ASAN/UBSAN issues
+reported against &quot;PCT&quot; and &quot;PICT&quot; since this one problem appears
+to be causing a spew of reports.</li>
+<li>coders/png.c (ReadMNGImage): Detect and handle failure to
+allocate global PLTE.  Problem was reported via email from Petr
+Gajdos on February 26, 2018.</li>
+</ul>
+</blockquote>
+<p>2018-02-25  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/blob.c (ReadBlobLSBDouble): Make sure imported double is
+a normal value.
+(ReadBlobLSBDoubles): Make sure imported doubles are normal
+values.
+(ReadBlobLSBFloat): Make sure imported float is a normal value.
+(ReadBlobLSBFloats): Make sure imported floats are normal values.
+(ReadBlobMSBFloat): Make sure imported float is a normal value.
+(ReadBlobMSBFloats): Make sure imported floats are normal values.
+(ReadBlobMSBDouble): Make sure imported double is a normal value.
+(ReadBlobMSBDoubles): Make sure imported doubles are normal
+values.</li>
+<li>magick/import.c (ImportFloat32Quantum): Make sure imported float
+is a normal value.
+(ImportFloat64Quantum): Make sure imported double is a normal
+value.</li>
+<li>magick/image.h (RoundDoubleToQuantum): Restore previous behavior
+(from earlier today).
+(RoundFloatToQuantum): Restore previous behavior (from earlier
+today).</li>
+<li>coders/bmp.c (ReadBMPImage): Fix UBSAN runtime error: left shift
+of 205 by 24 places cannot be represented in type 'int'.</li>
+<li>coders/ept.c (ReadEPTImage): Fix dereference of NULL pointer
+which was detected by UBSAN in the test suite.</li>
+<li>magick/image.h (RoundDoubleToQuantum): Check double value for
+NaN and infinity in order to avoid undefined behavior.
+(RoundFloatToQuantum): Check float value for NaN and infinity in
+order to avoid undefined behavior.</li>
+<li>magick/common.h (MAGICK_ISNAN): Add a isnan() wrapper macro.
+(MAGICK_ISINF): Add a isinf() wrapper macro.</li>
+</ul>
+</blockquote>
+<p>2018-02-25  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c Fix oss-fuzz issue 6273 - Heap-use-after-free in
+GetLocaleExceptionMessage. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-24  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dcm.c (DCM_PostRescaleImage): Remove use of
+DCM_PostRescaleImage() since its implementation is wrong and
+accesses non-allocated heap memory.  Problem was reported by Petr
+Gajdos via email on February 8, 2018.</li>
+<li>coders/jp2.c (ReadJP2Image): Use a ThrowJP2ReaderException macro
+to automatically clean up when throwing an exception.</li>
+<li>coders/bmp.c (ReadBMPImage): Report an error if RLE decode does
+not produce the expected number of bytes.  Fixes oss-fuzz issue
+6015 &quot;graphicsmagick/coder_BMP_fuzzer: Out-of-memory in
+graphicsmagick_coder_BMP_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-23  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (DrawImage): Fixed a bug in which graphical
+elements defined within &lt;defs&gt; ... &lt;/defs&gt; were being rendered,
+contrary to the SVG spec.</li>
+</ul>
+</blockquote>
+<p>2018-02-23  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (DrawPolygonPrimitive): When filling or
+stroking a polygon using a pattern, the fill (or stroke)
+and group/object opacity values were not being applied to
+the pattern (fixed).</li>
+</ul>
+</blockquote>
+<p>2018-02-23  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/bmp.c (ReadBMPImage): Fix SeekBlob() return value checks.
+Add more EOF checks.  Require that a provided ba_offset be a
+forward seek in order to avoid the possibility of endless looping.</li>
+</ul>
+</blockquote>
+<p>2018-02-23  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c Fix oss-fuzz issue 6301. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-22  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/alpha_composite.c (BlendQuantumOpacity): The
+pixel compositing equation used when compositing an
+image into the output was incorrect and has been fixed.</li>
+<li>magick/render.c (DrawPolygonPrimitive): When
+compositing polygon edge pixels over a transparent
+black background, the code would composite as if the
+background were opaque black, resulting in the edge
+pixels being too dark (fixed).</li>
+</ul>
+</blockquote>
+<p>2018-02-21  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul>
+<li><p class="first">magick/render.c (DrawImage): Per the SVG spec, opacity,
+fill-opacity, and stroke-opacity values are now clamped
+to [0,1].</p>
+<p>Also fixed two bugs introduced by changeset 91de8039f27d
+(dated 2018-02-12): (1) a group/object opacity value
+specified using a percentage was not being converted to a
+value in [0,1]; (2) if fill-opacity or stroke-opacity was
+1, and the group/object opacity value was set to 1, the
+resulting fill-opacity or stroke-opacity value would be
+set to 0 instead of 1.</p>
+</li>
+</ul>
+</blockquote>
+<p>2018-02-19  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/viff.c (ReadVIFFImage): Fix excessive memory usage.
+Fixes oss-fuzz 6006 &quot;graphicsmagick/coder_XV_fuzzer: Out-of-memory
+in graphicsmagick_coder_XV_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/txt.c (ReadInt): Avoid benign signed integer overflow due
+to accepting an arbitrary number of digits.  Fixes oss-fuzz 6002
+&quot;graphicsmagick/coder_TEXT_fuzzer: Integer-overflow in
+ReadInt&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/viff.c (ReadVIFFImage): Verify that there is sufficient
+data to back up colormap allocation request.  Fixes oss-fuzz 5986
+&quot;graphicsmagick/coder_VIFF_fuzzer: Out-of-memory in
+graphicsmagick_coder_VIFF_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>magick/memory.c: Define MAGICK_MEMORY_HARD_LIMIT=value to abort
+when memory request exceeds value.  Useful to find location of
+excessive memory requests.</li>
+</ul>
+</blockquote>
+<p>2018-02-19  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/svg.c (SVGStartElement): Per the SVG spec, the
+SVG coder now initializes the MVG coder (which renders
+SVG graphical elements) with the the SVG defaults for
+fill color, fill-opacity, stroke color, stroke-opacity,
+and stroke-width.  This makes the SVG coder independent
+of the MVG coder intial state.</li>
+</ul>
+</blockquote>
+<p>2018-02-19  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/svg.c (SVGStartElement): Fixed initialization of
+x and y attributes per the SVG spec:  for graphical elements
+&quot;image&quot;, &quot;pattern&quot;, &quot;text&quot;, &quot;rect&quot;, and &quot;use&quot;, if the x or y
+attribute is not specified, the effect is as if a value of
+&quot;0&quot; were specified.</li>
+</ul>
+</blockquote>
+<p>2018-02-18  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/sun.c (ReadSUNImage): Fix edge case which broke file-size
+validation logic.  Fixes oss-fuzz issue 5981
+&quot;graphicsmagick/coder_SUN_fuzzer: Out-of-memory in
+graphicsmagick_coder_SUN_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/txt.c (ReadTXTImage): Validate that file size is
+sufficient for claimed image properties.  Fixes oss-fuzz issue
+5960 &quot;graphicsmagick/coder_TXT_fuzzer: Out-of-memory in
+graphicsmagick_coder_TXT_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/tga.c (ReadTGAImage): Only allow 1 and 8 bit
+colormapped/grey images. Fixes oss-fuzz issue 6314
+&quot;graphicsmagick/coder_ICB_fuzzer: Undefined-shift in
+ReadTGAImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/bmp.c (ReadBMPImage): Detect and report when BMP height
+value is out of range (too negative). Fixes oss-fuzz issue 6394
+&quot;graphicsmagick/coder_BMP_fuzzer: Integer-overflow in
+ReadBMPImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/rla.c (ReadRLAImage): Detect when RLE decoding is
+producing too many samples and report as an error.  Fixes oss-fuzz
+issue 6312 &quot;graphicsmagick/coder_RLA_fuzzer: Timeout in
+graphicsmagick_coder_RLA_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/fits.c (ReadFITSImage): Validate that file size is
+sufficient for claimed image properties.  Fixes oss-fuzz issue
+6429 &quot;graphicsmagick/coder_FITS_fuzzer: Timeout in
+graphicsmagick_coder_FITS_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>magick/image.c (CloneImage): Check image pixel limits in
+CloneImage() when it is used to change the image dimensions.  This
+avoids depending on the using code to detect and report such
+issues.</li>
+<li>coders/xcf.c (ReadXCFImage): Check image pixel limits after each
+CloneImage() to assure that image is within specified resource
+limits.  Fixes oss-fuzz issue 6399 &quot;graphicsmagick/enhance_fuzzer:
+Timeout in graphicsmagick_enhance_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-16  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (TracePath): TracePath() was not
+correctly processing multiple sets of cubic or quadratic
+Bezier coordinates when the previous path data command was
+not a cubic or quadratic Bezier command.  This would result
+in the first control point being equal to the current path
+point instead of being computed using the current path
+point and the second control point of the previous Bezier
+command.</li>
+</ul>
+</blockquote>
+<p>2018-02-15  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (TracePath): TracePath() was not
+consuming commas (if present) at the end of a set of
+points when multiple sets of points were specified for
+various path commands (e.g., line, Bezier). This
+resulted in the remaining sets of points being ignored
+(fixed).</li>
+</ul>
+</blockquote>
+<p>2018-02-15  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (TraceArcPath): No points are generated
+by TraceArcPath() if the starting and ending arc points
+are the same.  For this case, the coordinate count was not
+being set to zero before returning (fixed).</li>
+</ul>
+</blockquote>
+<p>2018-02-15  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (DrawImage): Clipping of polygons in
+DrawImage() would sometime result in a starting pixel
+location that was greater than the ending pixel location,
+causing a subsequent call to GetImagePixelsEx() to fail
+due a column count &lt;= 0.  Modified the clipping code to
+eliminate this condition, and also to return early if
+the polygon lies completely outside the image boundaries.
+Also fixed variable declarations from a previous commit
+that were causing problems for the C89 compiler.</li>
+</ul>
+</blockquote>
+<p>2018-02-13  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/topol.c (ReadTOPOLImage): Detect EOF immediately rather
+than spinning.  Fixes oss-fuzz issue 6303
+&quot;graphicsmagick/coder_TOPOL_fuzzer: Timeout in
+graphicsmagick_coder_TOPOL_fuzzer&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/dcm.c (DCM_SetupRescaleMap): Avoid excessive left shift.
+Fixes oss-fuzz issue 6256 &quot;graphicsmagick/coder_DCM_fuzzer:
+Undefined-shift in DCM_SetupRescaleMap&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-12  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wpg.c (ExtractPostscript): Detect EOF on input while
+transferring bytes to Postscript file.  Fixes oss-fuzz issue 6087
+&quot;graphicsmagick/coder_WPG_fuzzer: NULL&quot;.  Later identified to be
+CVE-2017-17682 as previously discovered in ImageMagick.  (Credit to
+OSS-Fuzz)</li>
+<li>coders/pdb.c (ReadPDBImage): Quit attempting to read image data
+immediately at EOF. Fixes oss-fuzz issue 6252
+&quot;graphicsmagick/coder_PDB_fuzzer: Timeout in
+graphicsmagick_coder_PDB_fuzzer&quot;.  (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-12  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/topol.c (ReadTOPOLImage): Avoid index out of bounds when
+input filename does not use a file extension. Fixes oss-fuzz issue
+6237 &quot;graphicsmagick/coder_TOPOL_fuzzer: Index-out-of-bounds in
+ReadTOPOLImage&quot;.  (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-12  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (DrawImage): Object/group opacity,
+when set in DrawImage(), would overwrite the fill
+and stroke opacities. This has been fixed so that
+the object opacity is now combined with the fill
+and stroke opacities per the SVG spec.</li>
+</ul>
+</blockquote>
+<p>2018-02-12  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/mat.c Fix oss-fuzz issue 6021. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-11  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dcm.c (ReadDCMImage): Avoid undefined left shift of
+short.  Fix memory leaks in error reporting paths.  Fixes oss-fuzz
+issue 6217 &quot;graphicsmagick/coder_DCM_fuzzer: Undefined-shift in
+ReadDCMImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/dpx.c (ReadDPXImage): Avoid divide by zero exception in
+the case where reference high equals reference low. Fixes oss-fuzz
+issue 6215 &quot;graphicsmagick/coder_DPX_fuzzer: Divide-by-zero in
+ReadDPXImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/topol.c (ReadTOPOLImage): Avoid index out of bounds when
+input filename does not use a file extension.</li>
+<li>coders/cut.c (ReadCUTImage): Avoid index out of bounds when
+input filename does not use a file extension. Fixes oss-fuzz issue
+6218 &quot;graphicsmagick/coder_CUT_fuzzer: Index-out-of-bounds in
+ReadCUTImage&quot;.  (Credit to OSS-Fuzz)</li>
+<li>coders/pwp.c (ReadPWPImage): Force temporary file to be read as
+a SFW file rather than autodetecting the format.  Fixes oss-fuzz
+issue 6220 &quot;graphicsmagick/coder_PWP_fuzzer: Indirect-leak in
+AllocateImage&quot;.  (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-10  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pdf.c (WritePDFImage): Assure that xref memory is not
+leaked if an exception is thrown.  Fixes oss-fuzz issue 5968
+&quot;graphicsmagick/coder_EPDF_fuzzer: Direct-leak in MagickRealloc&quot;.
+(Credit to OSS-Fuzz)</li>
+<li>coders/tim.c (ReadTIMImage): Verify that 4/8 bit PSX TIM
+provides a CLUT and verify indexes.  Fixes oss-fuzz issue 5972
+&quot;graphicsmagick/coder_TIM_fuzzer: Null-dereference WRITE in
+ReadTIMImage&quot;.  (Credit to OSS-Fuzz)</li>
+<li>coders/topol.c (ReadTOPOLImage): Add additional header
+validations.  Fixes oss-fuzz issue 5975
+&quot;graphicsmagick/coder_TOPOL_fuzzer: Floating-point-exception in
+ReadTOPOLImage&quot;.  (Credit to OSS-Fuzz)</li>
+<li>coders/bmp.c (ReadBMPImage): Avoid possible division by zero
+when decoding CIE primary values. (Credit to OSS-Fuzz)</li>
+<li>magick/export.c (ExportViewPixelArea): Only compute
+unsigned_maxvalue if sample_bits &lt;= 32.</li>
+<li>magick/import.c (ImportViewPixelArea): Assure that
+double_maxvalue minus double_minvalue is not zero, or excessively
+close to zero to avoid divide by zero exception or impossible
+scaling factor. (Credit to OSS-Fuzz)
+(ImportViewPixelArea): Only compute unsigned_maxvalue if
+sample_bits &lt;= 32.</li>
+</ul>
+</blockquote>
+<p>2018-02-09  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dib.c (ReadDIBImage): Validate that image width is not
+too negative such that it's absolute value can not fit in 32-bit
+unsigned width. Resolves oss-fuzz issue 6179
+&quot;graphicsmagick/coder_ICO_fuzzer: Integer-overflow in
+ReadDIBImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/dcm.c (funcDCM_BitsStored): Validate DICOM datum size.
+Use a different means to determine the maximum value which does
+not use excessive shifting.  Resolves oss-fuzz issue 6165
+&quot;graphicsmagick/coder_DCM_fuzzer: Undefined-shift in
+funcDCM_BitsStored&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-08  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/dpx.c (ReadWordU32BE): Add casts to avoid default type
+promotion from unsigned char to 'int' leading to undefined
+behavior for 24 bit shift. Fixes oss-fuzz issue 6058
+&quot;graphicsmagick/coder_DPX_fuzzer: Undefined-shift in
+ReadWordU32BE&quot;. (Credit to OSS-Fuzz)
+(ReadDPXImage): Require that the file has at least one element.
+Add bountiful casts for values which are left-shifted.  Fixes
+oss-fuzz issue 5962 &quot;graphicsmagick/coder_DPX_fuzzer:
+Undefined-shift in ReadDPXImage&quot;. (Credit to OSS-Fuzz)</li>
+<li>coders/dcm.c (DCM_ReadOffsetTable): Add casts Add casts to avoid
+default type promotion from unsigned char to 'int' leading to
+undefined behavior for 16 bit shift. Fixes oss-fuzz issue 5980
+&quot;graphicsmagick/coder_DCM_fuzzer: Undefined-shift in
+DCM_ReadOffsetTable&quot;. (Credit to OSS-Fuzz)</li>
+<li>magick/module_aliases.h (ModuleAliases): Add missing mapping
+from &quot;ICODIB&quot; format to &quot;DIB&quot; module.</li>
+<li>magick/import.c (ImportUInt32Quantum): Add casts to avoid
+default type promotion from unsigned char to 'int' leading to
+undefined behavior for 24 bit shift.  Fixes oss-fuzz
+&quot;graphicsmagick/coder_P7_fuzzer: Undefined-shift in
+ImportRGBQuantumType&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-07  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/wpg.c Fix oss-fuzz issue 5964
+&quot;graphicsmagick/coder_MAT_fuzzer: Heap-use-after-free in
+GetLocaleExceptionMessage&quot;. (Credit to OSS-Fuzz)</li>
+</ul>
+</blockquote>
+<p>2018-02-07    Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/render.c (IsPoint): Fixed a bug in which
+IsPoint() would reject as a valid coordinate value
+strings that did not begin with an integer: e.g.,
+&quot;0.25&quot; would be accepted, but &quot;.25&quot; would not.</li>
+</ul>
+</blockquote>
+<p>2018-02-07  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/cut.c (ReadCUTImage): Fix DestroyImageInfo() of NULL
+pointer leading to assertion.  Fixes oss-fuzz issue 6067
+&quot;graphicsmagick/coder_CUT_fuzzer: Unknown signal in
+DestroyImageInfo&quot;.</li>
+<li>coders/tga.c (ReadTGAImage): Throw exception rather than
+assertion for unexpected comment size.  Fixes oss-fuzz issue 5961
+&quot;graphicsmagick/coder_ICB_fuzzer: ASSERT: (size_t)
+(tga_info.id_length+1) == commentsize&quot;.</li>
+</ul>
+</blockquote>
+<p>2018-02-06  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pdf.c (WritePDFImage): Free 'xref' allocation before
+error return.  Fixes oss-fuzz issue 5968
+&quot;graphicsmagick/coder_EPDF_fuzzer: Direct-leak in MagickRealloc&quot;.</li>
+</ul>
+</blockquote>
+<p>2018-02-04  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/pdb.c (ReadPDBImage): Fix heap buffer overflow if blob is
+already at EOF when comment is read.  Fixes oss-fuzz issue 5997
+&quot;graphicsmagick/coder_PDB_fuzzer: Heap-buffer-overflow in
+SetImageAttribute&quot;.</li>
+<li>coders/dpx.c (ReadDPXImage): Fix memory leak of user data if
+user data is truncated.  Fix consumption of one uninitialized
+stack bytes.  Fixes oss-fuzz issue 5973:
+graphicsmagick/enhance_fuzzer: Direct-leak in ReadDPXImage.</li>
+<li>coders/pnm.c (ReadPNMImage): Detect and avoid division by zero.
+Fixes Issue 5959 in oss-fuzz: graphicsmagick/coder_P7_fuzzer:
+Divide-by-zero in ReadPNMImage</li>
+<li>magick/xwindow.c (MagickXClientMessage): Eliminate valgrind
+gripe about use of uninitialized stack data by clearing allocation
+to zero.
+(MagickXMakeImage): Eliminate valgrind gripe about use of
+uninitialized heap data by clearing allocation to zero.</li>
+<li>coders/pwp.c (ReadPWPImage): Remove bogus EOF test on an image
+with a closed blob.  Fixes Issue 5957 in oss-fuzz:
+graphicsmagick/coder_PWP_fuzzer: ASSERT: image-&gt;blob-&gt;type !=
+UndefinedStream.</li>
+<li>www/Changes.rst: Fix typo with spelling &quot;ChangeLog-2017.html&quot;.
+Resolves SourceForge issue #544 &quot;dead link 2017 changelog page on
+GraphicsMagick web site&quot;.</li>
+</ul>
+</blockquote>
+<p>2018-02-03  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/static.c (OpenModule): Assure that status is initialized.
+Resolves Coverity 261207 &quot;Uninitialized scalar variable&quot;.</li>
+<li>wand/magick_wand.c (MagickHasColormap): New function to test if
+the image has a colormap.
+(MagickIsGrayImage): New function to test if the image uses only
+gray pixels.
+(MagickIsMonochromeImage): New function to test if the image uses
+only monochrome pixels.
+(MagickIsOpaqueImage): New function to test if the image uses only
+opaque pixels.
+(MagickIsPaletteImage): New function to test if the image is based
+on a color palette.  Above functions are written by Troy Patteson
+and submitted via SourceForge patch #54 &quot;Wand API patches: has
+colormap, is gray image, is monochrome image, is opaque image, is
+palette image&quot;.</li>
+<li>fuzzing: Added initial OSS-Fuzz integration by Alex Gaynor.
+From SourceForge patch #55 &quot;OSS-Fuzz integration&quot;</li>
+<li>coders/png.c (ReadMNGImage): Fix free using possibly unallocated
+pointer value.</li>
+<li>magick/blob.c (SeekBlob): Remove implicit extension of blob
+allocation size based on seek offset.  Besides making an
+assumption about how the blob memory was allocated, this
+reallocation feature provides a memory DOS opportunity.  Resolves
+issue reported by Alex Gaynor via email entitled &quot;Security issue
+with memory management in Magick++&quot; to the graphicsmagick-security
+list on 31 Jan 2018.
+(SeekBlob):</li>
+<li>coders/jpeg.c (ReadIPTCProfile): Revert inadvertent wrong return
+codes added by change on December 9, 2017.  Fixes SourceForge bug
+542 &quot;Improper call to JPEG library in state 201&quot; since 1.3.28.</li>
+</ul>
+</blockquote>
+<p>2018-02-01  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/annotate.c (RenderFreetype): Fixed the text
+opacity computation in RenderFreeType(). This bug caused
+the text fill color to bleed into the character cell when
+the SVG &quot;fill-opacity&quot; is less than 1.0.</li>
+</ul>
+</blockquote>
+<p>2018-02-01  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/attribute.c (CloneImageAttributes): Fixed a bug
+in which the source image attributes would always replace
+the destination image attributes instead of being appended
+to them, and the destination image attributes would become
+a memory leak.</li>
+</ul>
+</blockquote>
+<p>2018-01-31  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/svg.c (SVGStartElement): Fixed a bug in which the
+x,y location values for a &lt;text&gt; or &lt;tspan&gt; were overwritten
+by the x,y values for the next &lt;tspan&gt; before the previous
+values were used.  This caused the text associated with the
+previous &lt;text&gt; or &lt;tspan&gt; to appear at the location
+specified for the next &lt;tspan&gt;.</li>
+</ul>
+</blockquote>
+<p>2018-01-30  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/static.c: Use !defined(SupportMagickModules) to enable
+static module loader.  Fixes SourceForge bug #543 &quot;Multiple
+definition of &quot;OpenModule&quot; (etc) when cross-compiling shared&quot;.</li>
+</ul>
+</blockquote>
+<p>2018-01-29  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/svg.c (SVGStartElement): A terminating '&gt;' in
+a geometry string is interpreted to mean that the dimensions
+of an image should only be changed if its width or height
+exceeds the geometry specification.  For an unapparent and
+undocumented reason, a terminating '&gt;', if present, was
+being nulled out, making this feature unusable for SVG files
+(now fixed).</li>
+</ul>
+</blockquote>
+<p>2018-01-29  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/svg.c (ReadSVGImage): If there is a geometry string
+in image_info-&gt;size (e.g., gm convert -size &quot;50x50%&quot; in.svg
+out.png), AllocateImage() sets image-&gt;columns and image-&gt;rows
+to the width and height values from the size string.  However,
+this makes no sense if the size string was something like
+&quot;50x50%&quot; (we'll get columns = rows = 50).  So we set columns
+and rows to 0 after AllocateImage(), which is the same as if
+no size string was supplied by the client.  This also results
+in svg_info.bounds to be set to 0,0 (i.e., unknown), so that
+svg_info.bounds will later be set using the image size
+information from either the svg &quot;canvas&quot; width/height or from
+the viewbox.  Later, variable &quot;page&quot; is set from
+svg_info-&gt;bounds. Then the geometry string in image_info-&gt;size
+gets applied to the (now known) &quot;page&quot; width and height when
+SvgStartElement() calls GetMagickGeometry(), and the intended
+result is obtained.</li>
+</ul>
+</blockquote>
+<p>2018-01-24  Greg Wolfe  &lt;<a class="reference external" href="mailto:gregory&#46;wolfe&#37;&#52;&#48;kodakalaris&#46;com">gregory<span>&#46;</span>wolfe<span>&#64;</span>kodakalaris<span>&#46;</span>com</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/svg.c (SVGStartElement): When the density (DPI)
+is specified using the ImageInfo::density member, the derived
+scale factor is incorrectly applied a second time to the
+width and height members of variable RectangleInfo page.
+Fixes SourceForge ticket #451.</li>
+</ul>
+</blockquote>
+<p>2018-01-23  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/static.c: Use a lazy-loader for static modules with the
+same external interface as the lazy-loader for dynamic modules.</li>
+</ul>
+</blockquote>
+<p>2018-01-20  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>NEWS.txt: Prepare for 1.3.28 release.</li>
+</ul>
+</blockquote>
+<p>2018-01-17  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>NEWS.txt: Update with changes since previous release.</li>
+</ul>
+</blockquote>
+<p>2018-01-14  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>PerlMagick/Magick.xs: Compiler warnings reduction.</li>
+<li>magick/pixel_cache.h: Mark GetPixels(), GetIndexes(), and
+GetOnePixel() as deprecated.  Compilers may produce a warning if
+these functions are used.</li>
+<li>magick/pixel_cache.c (InterpolateColor): Return black pixel if
+InterpolateViewColor() reports failure.</li>
+<li>coders/png.c (ReadMNGImage): Fix memory leak of chunk and
+mng_info in error path.</li>
+<li>coders/gif.c (ReadGIFImage): Fix memory leak of global colormap.</li>
+</ul>
+</blockquote>
+<p>2018-01-13  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/symbols.h: Fix SourceForge issue #538 &quot;13 symbols in
+common with ImageMagick despite --enable-symbol-prefix&quot;.</li>
+<li>coders/bmp.c (ReadBMPImage): Fix non-terminal loop due to
+unexpected bit-field mask value.  Fixes SourceForge issue #541
+&quot;Infinite Loop in ReadBMPImage (coders/bmp.c)&quot;.</li>
+<li>coders/jpeg.c (JPEGMessageHandler): Revert code added on
+2017-07-08 to promote certain warnings from libjpeg to errors.
+Add code to rationalize claimed image dimensions based on file
+size.  Resolves SourceForge issue #539 &quot;Images with libjpeg
+warnings result in error&quot;.</li>
+</ul>
+</blockquote>
+<p>2018-01-11  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;seznam&#46;cz">JaFojtik<span>&#64;</span>seznam<span>&#46;</span>cz</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li><dl class="first docutils">
+<dt>coders/wpg.c Recursive ReadImage could return multiple scenes</dt>
+<dd>fixed.</dd>
+</dl>
+</li>
+</ul>
+</blockquote>
+<p>2018-01-07  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>coders/png.c (ReadOnePNGImage): Quit 'passes' loop if we
+encountered an error</li>
+<li>magick/pixel_cache.c (SetNexus): Fix heap overwrite in
+AcquireCacheNexus() due to SetNexus() not using an allocated
+staging area for the pixels like it should.  This problem impacts
+all 1.3.X releases.  Resolves SourceForge issues 532
+&quot;heap-buffer-overflow bug in ReadWPGImage&quot; and #531
+&quot;heap-buffer-overflow in AcquireCacheNexus&quot;.</li>
+<li>magick/pixel_cache.c (InterpolateViewColor): Now returns
+MagickPassFail rather than void.  Code using this function is
+updated to check the return status.</li>
+</ul>
+</blockquote>
+<p>2018-01-01  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/describe.c (DescribeImage): Discriminate between
+AcquireImagePixels() returning NULL or finding a transparent
+pixel.  This avoids use of a null pointer in the case where
+AcquireImagePixels() returns NULL.</li>
+</ul>
+</blockquote>
+<p>2017-12-31  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li>magick/static.c: Change static module initialization to be based
+on an initialized list rather than a squence of function calls in
+order to simplify maintenance and possibly address future
+requirements.</li>
+</ul>
+</blockquote>
+<p>2017-12-30  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
 <li>Copyright.txt: Bump copyright years and rotate ChangeLog.</li>
index 50e2029..6eb13e0 100644 (file)
-2017-07-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-11-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - NEWS.txt: Make sure is up to date.
+  - www/index.rst: Update in preparation for 1.3.31 release.
 
-  - www/index.rst: Update for 1.3.26 release.
+  - version.sh: Update library versioning in preparation for
+    1.3.31 release.
 
-  - version.sh: Update library versioning for 1.3.26 release.
+  - NEWS.txt: Update news in preparation for 1.3.31 release.
 
-  - magick/command.c (BatchCommand): Add ferror() checks around
-    batch input loop.
+2018-11-15  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-07-03  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+  - magick/command.c (BenchmarkUsage): Document the benchmark
+    command better.
 
-  - coders/png.c: Reject a PNG file if the file size is too small
-    (less than 61 bytes).  Reject a JNG file if it is too small (less
-    than 147 bytes).
-  - coders/jpeg.c: Reject a JPEG file if the file size is too small
-    (less than 107 bytes).
+2018-11-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-07-02  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+  - magick/resize.c (HorizontalFilter, VerticalFilter): quantum is a
+    pointer so it's value can not be usefully flushed.  Use a local
+    variable and then update quantum pointer when done.
 
-  - coders/dpx.c (ReadDPXImage): Compute required file size and
-    verify that sufficient data exists in file before allocating
-    memory to decode the image data.  Resolves problem with DPX file
-    with valid header (but a huge claimed image width) provided
-    provided via email on Thu, 29 Jun 2017 by LCatro.  This issue has
-    been assigned CVE-2017-10799.
+2018-11-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2016-07-02  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+  - magick/\*: Changed row\_count tallying to use 'omp atomic' and
+    status update to use 'omp flush' for progress and error
+    indication.  This replaces most use of 'omp critical' for this
+    purpose.  Changed some lumpy algorithms which were using 'static'
+    scheduling to 'guided' scheduling due to observing better results.
+    Also added prolific 'restrict' annotations where they were
+    missing.
 
-  - coders/mat.c Check whether reported object size overflows file size.
+  - www/security.rst: Documented a PGP private key for file signing
+    or private correspondence.
 
-2016-07-01  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+2018-11-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - coders/mat.c Safety check for forged and or corrupted data.
-    This issue has been assigned CVE-2017-10800.
+  - www/authors.rst: Moved "Glenn Randers-Pehrson" and "Gregory J
+    Wolfe" to the "Former Contributor" category.
 
-2017-07-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-11-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - coders/tiff.c ("QuantumTransferMode"): Use a generalized method
-    to enforce that buffer overflow can not happen while importing
-    pixels.  Resolves problem with RGB TIFF claiming only one sample
-    per pixel provided via email on Thu, 29 Jun 2017 by LCatro.  This
-    issue has been assigned CVE-2017-10794.
+  - Added many GCC function annotations in the libraries and coders.
 
-2017-06-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-11-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - magick/command.c: Convert bare 'unsigned int' to MagickPassFail
-    where suitable to make intentions clear.  Convert True/False to
-    MagickTrue/MagickFalse or MagickPass/MagickFail according to
-    purpose.  This is a continuation of a gradual migration and does
-    not represent an API change.
+  - configure.ac: Use printf rather than echo to portably expand tab
+    requests in configuration summary.
 
-2017-06-25  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+2018-11-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - coders/png.c: Avoid NULL dereference when MAGN chunk processing
-    fails (https://sourceforge.net/p/graphicsmagick/bugs/426/). Expand
-    TABs.
+  - configure.ac: Use pkg-config data as the initial choice when
+    configuring for FreeType 2.0 and libxml-2.0.  Only fall back to
+    invoking an external script (and then traditional methods) if
+    pkg-config fails.
 
-2017-06-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+  - coders/msl.c (ProcessMSLScript): Release msl\_image if OpenBlob
+    fails.  Similar to ImageMagick CVE-2018-18544.  Problem was
+    reported to us via email from Petr Gajdos on Thu, 1 Nov 2018.
 
-  - NEWS.txt: Update NEWS with changes since the previous release.
+2018-10-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - www/programming.rst: Switch the Lua link to
-    https://github.com/arcapos/luagraphicsmagick, which is a more
-    complete and direct interface from Lua to GraphicsMagick's Wand
-    API.
+  - coders/miff.c (WriteMIFFImage): Only run
+    strlen(attribute->value) once per attribute since the length won't
+    change.  May address oss-fuzz 11158
+    "graphicsmagick/coder\_MIFF\_fuzzer: Timeout in
+    graphicsmagick\_coder\_MIFF\_fuzzer". (Credit to OSS-Fuzz)
 
-2017-06-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+  - Fix compilation warnings observed with GCC 8.2.0.
 
-  - VisualMagick/installer/gm-foo-dll.iss: Remove PerlMagick from
-    the slim Inno Setup installer builder and remove mention of
-    PerlMagick from the installer documentation.
+2018-10-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - TclMagick/generic/TclMagick.c (magickCmd): Resolve SourceForge
-    patch #51 "TclMagick: memory access error; possible segfault".
-    (newMagickObj): Fix formatting of pointer value so it is 64-bit
-    safe.  Resolves SourceForge patch #50 "TclMagick: 64-bit
-    portability issue".
+  - magick/pixel\_iterator.c (PixelIterateMonoModifyImplementation):
+    Use atomic and flush rather than critical construct for a small
+    speedup.
 
-  - coders/pict.c (ReadPICTImage): Avoid possible use of negative
-    value when indexing array, which would cause buffer overflow.
-    Resolves SourceForge issue #427 "One possible buffer overflow
-    vulnerability in
-    GraphicsMagick-1.3.25/coders/pict.c:ReadPICTImage()".
+  - magick/monitor.c (MagickMonitorFormatted): Serialize calls to
+    the progress monitor so that the caller does not need to perform
+    this serialization.
+    (MagickMonitor): Serialize calls to the progress monitor so that
+    the caller does not need to perform this serialization.  This
+    function is now marked as deprecated.
+    (InitializeMagickMonitor): New private function to initialize
+    monitor functionality.
+    (DestroyMagickMonitor): New private function to destroy monitor
+    functionality.
 
-2017-06-22  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+2018-10-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - coders/png.c: Stop memory leak when reading invalid JNG image.
-    Fixes CVE-2017-8350.
+  - coders/gif.c (ReadGIFImage): Improve the efficiency of storing a
+    GIF comment in order to avoid a DOS opportunity.  Fixes oss-fuzz
+    11096 "graphicsmagick/coder\_GIF\_fuzzer: Timeout in
+    graphicsmagick\_coder\_GIF\_fuzzer". (Credit to OSS-Fuzz)
 
-2017-06-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-10-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - coders/png.c: Fix lcms2.h inclusion logic.
+  - PerlMagick/Makefile.PL.in: Use MAGICK\_API\_LIBS to obtain the
+    list of libraries to use when linking.
 
-  - wand/magick\_wand.c (MagickSetImageOrientation): Eliminate use of
-    snprintf, which is not supported by older Visual Studio.
+  - configure.ac: OpenMP library is normally supplied due to a
+    CFLAGS option so only supply it in cases where the CFLAGS option
+    may be lost or it might not be used.  Otherwise the compiler may
+    apply the library twice when linking.
 
-2017-06-09  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+2018-10-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - coders/png.c: Accept exIf chunks whose data segment
-    erroneously begins with "Exif\0\0".
+  - configure.ac: Remove Ghostscript library support (--with-gslib)
+    from configure script.  The 'HasGS' pre-processor defines which
+    were enabled by this remain in the source code so it is still
+    possible to use this library if absolutely necessary
+    (e.g. CPPFLAGS=-DHasGS LIBS=-lgs).
 
-2017-06-01  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+  - tests/rwfile.tap: Test TIFF format with all supported
+    compression options.
 
-  - coders/png.c: Removed experimental zxIF chunk support.  That
-    proposal is dead.
+  - tests/{rwblob.c, rwfile.c} (main): Use StringToCompressionType()
+    to parse compression option. Also consider requested compression
+    algorithm when deciding if format is lossy.
 
-2017-05-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+  - coders/tiff.c (WriteTIFFImage): WebP compression needs
+    PHOTOMETRIC\_RGB. Fix wrong rows-per-strip calculation when using
+    LZMA compression.
 
-  - config/log.mgk: Added documentation suggested by SourceForge
-    issue #419 "Consider a small patch to log.mgk".
+  - tests/rwblob.tap: Added a rwblob test to verify that lower-case
+    magick works.
 
-  - www/Changes.rst: Add missing link to most recent changes.
+  - magick/static.c (OpenModule): Upper case magick string before
+    searching static modules list.  Fixes Debian bug 911386
+    "libgraphicsmagick-q16-3: graphicsmagick 1.3.30 has made formats
+    case-sensitive at the API level".
 
-2017-05-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+  - filters/analyze.c (AnalyzeImage): X and y should be unsigned
+    long to match image rows/columns type.  Calculate total pixels by
+    simple multiplication rather than counting.
 
-  - www/Magick++/Image.rst: Improve documentation for Magick++
-    Image::iccColorProfile() and Image::renderingIntent().
+2018-10-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-05-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+  - coders/tiff.c (WriteTIFFImage): Support WebP compression in
+    TIFF. This requires a libtiff release after 4.0.9.
 
-  - tiff: Update to libtiff 4.0.8.
+  - magick/image.h ("C"): WebPCompression added to CompressionType
+    enumeration.
 
-2017-03-19  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+2018-10-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - coders/png.c: Quieted a new Coverity complaint about a potential
-    text buffer overrun.
+  - configure.ac: Configure for the Zstd library.  Use
+    --without-zstd to disable searching for this library.  Libtiff may
+    require this library to successfully link so static linkage could
+    fail if searching for libzstd is disabled.
 
-2017-03-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+  - magick/image.h ("C"): ZSTDCompression added to CompressionType
+    enumeration.
 
-  - magick/image.c (SetImageInfo): Ignore empty magic prefix
-    specification and do not remove colon character from start of
-    filename.  Resolves SourceForge bug #415 "Inconsistent Behavior w/
-    input\_file Parameter".
+  - coders/tiff.c (WriteTIFFImage): Support Zstd compression in
+    TIFF.  This requires a libtiff release after 4.0.9.
 
-2017-03-18  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+2018-10-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - coders/png.c: Added new private orNT PNG chunk, to
-    preserve image->orientation when it is defined and not
-    the default TopLeft.
-  - coders/jpeg.c: Mention image->orientation in the log when
-    writing a JPEG.
+  - magick/command.c (GMCommandSingle): Add 'compare' to the list of
+    command names that gm will support as a command if copied to or
+    linked from that name.  There was already a 'compare' link
+    installed when the '--enable-magick-compat' configure option is
+    used, but it could not possibly function without being blessed by
+    this list.  Related to Debian bug #910652
+    "graphicsmagick-imagemagick-compat: Doesn't ship a compare tool".
 
-2017-03-15  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+2018-09-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - coders/png.c (WriteOnePNGImage): Add version info about
-    gm, libpng, zlib, and lcms to the PNG debug log.
+  - Magick++/lib/Magick++/Drawable.h: Block unused-private-field
+    warnings from Clang due to \_dummy members which were intentionally
+    included in some parent class definitions.
 
-2017-03-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+  - magick/widget.c (XEditText): Fix compilation warnings about
+    cases which fall-through.
 
-  - magick/command.c (ImportImageCommand): Fix handling of -frame
-    options. Option handling was incorrect due to option checking the
-    frame option after it had been freed.  Checking the frame dash
-    option before freeing the argument solves the problem.  From patch
-    provided by Victor Ananjevsky as SourceForge patch #49 "-frame
-    doesn't work in gm import".
+  - magick/display.c (MagickXAnnotateEditImage): Fix compilation
+    warnings about cases which fall-through.
 
-  - Magick++/lib/Image.cpp (attribute): Added Image attribute method
-    which accepts a 'char \*' argument, and will remove the attribute
-    if the value argument is NULL.  From patch provided by "Gints" as
-    SourceForge patch #46 "C++ api - method to clear/remove
-    attribute".
+  - coders/pict.c (WritePICTImage): Add more checks to memory
+    allocation calculations.
 
-  - VisualMagick/configure/configure.cpp (InitInstance): Applied
-    patch by Paul McConkey to allow the quantum command line argument
-    to set the default value in the wizard drop list.  This allows
-    setting the quantum depth when the /nowizard argument was
-    supplied.  Resolves SourceForge patch #48 "When running from the
-    command line configure.exe does not use the quantum argument".
-    The provided configure.exe still needs to be rebuilt to
-    incorporate this change.
+  - magick/pixel\_cache.c (DestroyCacheInfo): Eliminate intentional
+    fall-through logic in switch statement which results in compiler
+    warnings.  Eliminate switch statements entirely and split
+    unrelated logic.
 
-  - magick/command.c (MogrifyImage): The -orient command now also
-    updates the orientation in the EXIF profile, if it exists.
+  - coders/txt.c (ReadTXTImage): Fix comparison between pointer and
+    '\0' rather than NULL as was obviously intended.
 
-  - Magick++/lib/Image.cpp (orientation): Update orientation in EXIF
-    profile, if it exists.
+  - coders/msl.c (MSLStartElement): Add missing 'break' statements
+    after ThrowException() calls.  Otherwise execution falls through
+    into unrelated switch cases and throws a redundant exception.
 
-2017-03-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-09-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - coders/jp2.c: Support PGX JPEG 2000 format for reading and
-    writing (within the bounds of what JasPer supports).
+  - coders/meta.c (parse8BIM): Eliminate repeated use of strlen()
+    which scans the entire remaining string on each cycle.  Fixes
+    oss-fuzz 10667 "graphicsmagick/coder\_IPTCTEXT\_fuzzer: Timeout in
+    graphicsmagick\_coder\_IPTCTEXT\_fuzzer". (Credit to OSS-Fuzz)
 
-2017-02-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-09-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - coders/tiff.c (QuantumTransferMode): Fix out of bounds read when
-    reading CMYKA TIFF which claims to have only 2 samples per pixel.
-    Problem was reported via email on February 15, 2017 by Valon
-    Chu. This issue was assigned CVE-2017-6335.
+  - magick/utility.c (MagickGetToken): Fix possible read up to four
+    bytes beyond end of stack allocated token buffer.  Fixes oss-fuzz
+    10653 "graphicsmagick/coder\_MVG\_fuzzer: Stack-buffer-overflow in
+    MagickGetToken". (Credit to OSS-Fuzz)
 
-2017-01-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-09-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - doc/options.imdoc (-geometry): Geometry documentation changes
-    suggested by Jon Wong.
+  - fuzzing/coder\_fuzzer.cc (LLVMFuzzerTestOneInput): Limit the
+    maximum number of JPEG progressive scans to 50.
 
-2017-01-26  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+  - coders/jpeg.c (ReadJPEGImage): Apply a default limit of 100
+    progressive scans before the reader quits with an error.  This
+    limit may be adjusted using the -define mechanism like -define
+    JPEG:max-scan-number=500.  Also respond more quickly to files
+    which exceed the maximum image dimensions.  Fixes oss-fuzz 10258
+    "graphicsmagick/coder\_JPEG\_fuzzer: Timeout in
+    graphicsmagick\_coder\_JPEG\_fuzzer". (Credit to OSS-Fuzz)
 
-  - coders/png.c: Added support for a proposed new PNG chunk
-    (zxIf, read-only) that is currently being discussed on the
-    png-mng-misc at lists.sourceforge.net mailing list.  Enable
-    exIf and zxIf with CPPFLAGS="-DexIf\_SUPPORTED -DxzIf\_SUPPORTED".
-    If exIf is enabled, only the uncompressed exIF chunk will be
-    written and the hex-encoded zTXt chunk containing the raw Exif
-    profile won't be written.
+2018-09-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-01-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+  - coders/png.c (ReadMNGImage): mng\_LOOP chunk must be at least 5
+    bytes long.  Fixes oss-fuzz 10455
+    "graphicsmagick/coder\_MNG\_fuzzer: Use-of-uninitialized-value in
+    ReadMNGImage". (Credit to OSS-Fuzz)
 
-  - coders/msl.c (MSLStartElement): Change test for NULL image
-    pointer to before it is used rather than after it is used.
-    Problem reported by Petr Gajdos on 2017-01-25.
+2018-09-15  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-01-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+  - magick/render.c (TraceEllipse): Detect arithmetic overflow when
+    computing the number of points to allocate for an ellipse.  Fixes
+    oss-fuzz 10306 "graphicsmagick/coder\_MVG\_fuzzer:
+    Heap-buffer-overflow in TracePoint". (Credit to OSS-Fuzz)
 
-  - TclMagick/unix/m4/tcl.m4: Update tcl.m4 to TEA 3.10.  File
-    supplied by Massimo Manghi.
+2018-09-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-01-21  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+  - magick/attribute.c (GenerateEXIFAttribute): Eliminate undefined
+    shift.  Also right-sized involved data types.  Fixes oss-fuzz
+    10309 "graphicsmagick/coder\_JPG\_fuzzer: Undefined-shift in
+    Read32s". (Credit to OSS-Fuzz)
 
-  - coders/png.c: Added support for a proposed new PNG
-    chunk (exIf read-write, eXIf read-only) that is currently
-    being discussed on the png-mng-misc at lists.sourceforge.net
-    mailing list.
+2018-09-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-2017-01-21  Glenn Randers-Pehrson  <glennrp@simple.dallas.tx.us>
+  - magick/render.c (DrawClipPath): Fix Coverity 319663 "Null
+    pointer dereferences".  Totally insignificant.
 
-  - coders/png.c: Added read\_user\_chunk\_callback() function
-    and used it to implement a private PNG caNv (canvas) chunk
-    for remembering the original dimensions and offsets when an
-    image is cropped.  Previously we used the oFFs chunk for this
-    purpose, but this had potential conflicts with other applications
-    that also use the oFFs chunk.
+  - coders/wpg.c (ReadWPGImage): Mask/fix Coverity 319664 "Error
+    handling issues".
 
-2017-01-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+  - magick/attribute.c (FindEXIFAttribute): Change size types from
+    signed to unsigned and check for unsigned overflow.
+    (GenerateEXIFAttribute): Change size types from signed to unsigned
+    and check for unsigned overflow. Fixes oss-fuzz 10283
+    "graphicsmagick/coder\_JPG\_fuzzer: Integer-overflow in
+    GenerateEXIFAttribute". (Credit to OSS-Fuzz)
 
-  - TclMagick/Makefile.am (AM\_DISTCHECK\_CONFIGURE\_FLAGS): Applied
-    patch by Massimo Manghi to set AM\_DISTCHECK\_CONFIGURE\_FLAGS so
-    that 'make distcheck' remembers configuration options, and also to
-    uninstall pkgIndex.tcl.
+  - coders/sfw.c (ReadSFWImage): Enforce that file is read using the
+    JPEG reader. (Credit to OSS-Fuzz)
 
-  - magick/image.c (SetImageEx): Use PixelIterateMonoSet() for
-    possibly improved efficiency.
+  - coders/miff.c (ReadMIFFImage): Fix leak of 'values' buffer due
+    to change made yesterday.
 
-  - magick/pixel\_iterator.c (PixelIterateMonoSet): New pixel
-    iterator intended for use when initializing image pixels, without
-    regard to existing values.
+  - coders/mpc.c (ReadMPCImage): Fix leak of 'values' buffer due to
+    change made yesterday.  Fixes oss-fuzz 10277
+    "graphicsmagick/coder\_MPC\_fuzzer: Direct-leak in
+    ReadMPCImage". (Credit to OSS-Fuzz)
 
-2017-01-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+2018-09-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
-  - Copyright.txt: Bump copyright years and rotate ChangeLog.
+  - coders/miff.c (ReadMIFFImage): Support legacy keyword
+    'color-profile' for ICC color profile as was used by ImageMagick
+    4.2.9.
+
+  - coders/mpc.c (ReadMPCImage): Require that first keyword/value be
+    id=MagickCache
+
+  - coders/miff.c (ReadMIFFImage): Require that first keyword/value
+    be id=ImageMagick.
+
+2018-09-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dcm.c (DCM\_ReadElement): Add more size checks.
+
+  - coders/jnx.c (ExtractTileJPG): Enforce that JPEG tiles are read
+    by the JPEG coder.  Fixes oss-fuzz 10147
+    "graphicsmagick/coder\_JNX\_fuzzer: Use-of-uninitialized-value in
+    funcDCM\_PhotometricInterpretation". (Credit to OSS-Fuzz)
+
+2018-09-10  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/wpg.c Zero fill raster error recovery.
+
+2018-08-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/render.c (ConvertPrimitiveToPath): Second attempt to
+    prevent heap write overflow of PathInfo array.  Fixes oss-fuzz
+    10096 "Heap-buffer-overflow in ConvertPrimitiveToPath". (Credit to
+    OSS-Fuzz)
+
+2018-08-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/tiff.c ("QuantumTransferMode"): CIE Log images with an
+    alpha channel are not supported.  Fixes oss-fuzz 10013
+    "graphicsmagick/coder\_TIFF\_fuzzer: Use-of-uninitialized-value in
+    DisassociateAlphaRegion". (Credit to OSS-Fuzz)
+
+  - magick/render.c (DrawImage): SetImageAttribute() appends new
+    text to any existing value, leading to every increasing memory
+    consumption if the existing value is not deleted first by the
+    unwary.  Fixes oss-fuzz 9983 "graphicsmagick/coder\_MVG\_fuzzer:
+    Timeout in graphicsmagick\_coder\_MVG\_fuzzer" and oss-fuzz 10016
+    "graphicsmagick/coder\_MVG\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_MVG\_fuzzer". (Credit to OSS-Fuzz)
+
+  - magick/utility.c (TranslateTextEx): Fix off-by-one in loop
+    bounds check which allowed a one-byte stack write overflow.  Fixes
+    oss-fuzz 10055 "graphicsmagick/coder\_MVG\_fuzzer:
+    Stack-buffer-overflow in TranslateTextEx". (Credit to OSS-Fuzz)
+
+  - magick/render.c (DrawImage): Be more precise about error
+    detection and reporting, and return from an error more quickly.
+    Also added MAX\_DRAWIMAGE\_RECURSION pre-processor definition to
+    allow adjusting the drawing recursion limit.  The drawing
+    recursion limit is still 100, which seems exceptionally generous.
+
+  - magick/constitute.c (WriteImage): Produce a more useful error
+    message if an encoding delegate is not available.
+
+  - magick/nt\_base.h (isnan): Try adding a MSVC replacement for
+    missing isnan() function.  Not yet tested.
+
+2018-08-25  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/wpg.c This should fix intentional 64 bit file offset
+    overflow as depictedin OSS-fuzz-9936. Thanks to OSS-Fuzz.
+
+2018-08-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/render.c (ConvertPrimitiveToPath): Need to enlarge
+    PathInfo array allocation to avoid possible heap write overflow.
+    Fixes oss-fuzz 9651 "graphicsmagick/coder\_MVG\_fuzzer:
+    Heap-buffer-overflow in ConvertPrimitiveToPath". (Credit to
+    OSS-Fuzz)
+
+2018-08-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/mpc.c (ReadMPCImage): Insist that the format be
+    identified prior to any comment, and that there is only one
+    comment.
+
+  - coders/miff.c (ReadMIFFImage): Insist that the format be
+    identified prior to any comment, and that there is only one
+    comment.  Fixes oss-fuzz 9979 "graphicsmagick/coder\_MIFF\_fuzzer:
+    Timeout in graphicsmagick\_coder\_MIFF\_fuzzer".  This is not a
+    serious issue, but the code runs slowly under UBSAN.  (Credit to
+    OSS-Fuzz)
+
+2018-08-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/utility.c (MagickAtoFChk): Add additional validation
+    checks for floating point values.  NAN and +/- INFINITY values
+    also map to 0.0. Fixes oss-fuzz 9630
+    "graphicsmagick/coder\_MVG\_fuzzer: Integer-overflow in
+    IsNexusInCore" and oss-fuzz 9612 "graphicsmagick/coder\_MVG\_fuzzer:
+    Integer-overflow in SetCacheNexus". (Credit to OSS-Fuzz)
+
+  - magick/render.c (DrawImage): Add missing error-reporting logic
+    to return immediately upon memory reallocation failure.  Apply
+    memory resource limits to PrimitiveInfo array allocation.  Fixes
+    oss-fuzz 9576 "graphicsmagick/coder\_MVG\_fuzzer: Null-dereference
+    READ in DrawImage", oss-fuzz 9593
+    "graphicsmagick/coder\_MVG\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_MVG\_fuzzer", oss-fuzz 9648
+    "graphicsmagick/coder\_MVG\_fuzzer: Unknown signal in
+    DrawImage". (Credit to OSS-Fuzz)
+
+2018-08-16  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coder/mat.c Explicitly reject non-seekable streams.
+
+2018-08-15  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coder/mat.c Correctly check GetBlobSize(image) even for zipstreams.
+
+2018-08-14  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c More aggresive data corruption checking.
+
+2018-08-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/xbm.c (XBMInteger): Limit the number of hex digits parsed
+    to avoid signed integer overflow.  Fixes oss-fuzz 9746
+    "graphicsmagick/coder\_XBM\_fuzzer: Undefined-shift in
+    XBMInteger". (Credit to OSS-Fuzz)
+
+2018-08-07  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c Typecast difference to quantum.
+
+2018-08-05  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/mat.c (InsertComplexFloatRow): Avoid signed
+    overflow. Fixes oss-fuzz 9667 "graphicsmagick/coder\_MAT\_fuzzer:
+    Integer-overflow in InsertComplexFloatRow". (Credit to OSS-Fuzz)
+
+  - coders/xbm.c (ReadXBMImage): Add validations for row and column
+    dimensions.  Fixes oss-fuzz 9736 "graphicsmagick/coder\_XBM\_fuzzer:
+    Out-of-memory in graphicsmagick\_coder\_XBM\_fuzzer". (Credit to
+    OSS-Fuzz)
+
+2018-08-04  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/wpg.c Add mechanism to approve embedded subformats in
+    WPG.  This should mute oss-fuzz 9559.  (Credit to OSS-Fuzz)
+
+2018-07-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/mvg.c (ReadMVGImage): Fix memory leak added on
+    2018-07-21.  Fixes oss-fuzz 9548 "graphicsmagick/coder\_MVG\_fuzzer:
+    Direct-leak in CloneDrawInfo". (Credit to OSS-Fuzz)
+
+2018-07-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/cineon.c (ReadCINEONImage): Fix SourceForge issue 571
+    "Unexpected hang on a crafted Cineon image" by detecting and
+    quitting on EOF appropriately, and verifying that file size is
+    sufficient for claimed pixel dimensions when possible.
+
+  - fuzzing/oss-fuzz-build.sh, fuzzing/dictionaries/MVG.dict: Added
+    MVG fuzzing dictionary by Alex Gaynor.
+
+2018-07-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/pixel\_cache.c (SetNexus): For requests one pixel tall,
+    SetNexus() was wrongly using pixels in-core rather than using a
+    staging area for the case where the nexus rows extend beyond the
+    image raster boundary, leading to heap overflow.  This can happen
+    when virtual pixels outside the image bounds are accessed.  Fixes
+    oss-fuzz 9512 "graphicsmagick/graphicsmagick\_coder\_MVG\_fuzzer:
+    Heap-buffer-overflow in AcquireCacheNexus". (Credit to OSS-Fuzz)
+
+  - magick/render.c (ExtractTokensBetweenPushPop):
+    ExtractTokensBetweenPushPop() needs to always return a valid
+    pointer into the primitive string.  Fixes oss-fuzz 9511
+    "graphicsmagick/graphicsmagick\_coder\_MVG\_fuzzer: Null-dereference
+    READ in DrawImage". (Credit to OSS-Fuzz)
+    (DrawPolygonPrimitive): Fix leak of polygon set when object is
+    completely outside image.  Fixes oss-fuzz 9513
+    "graphicsmagick/graphicsmagick\_coder\_MVG\_fuzzer: Direct-leak in
+    AllocateThreadViewDataSet". (Credit to OSS-Fuzz)
+
+2018-07-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/blob.c (FileToBlob): Use confirm access APIs to verify
+    that read access to this path is allowed by policy.  Check that
+    file is a regular file before proceeding to open and read from it.
+
+  - coders/mvg.c (ReadMVGImage): Don't allow MVG files to side-load
+    a file as the drawing primitive using '@' syntax.  Fixes oss-fuzz
+    9494 "graphicsmagick/coder\_MVG\_fuzzer: Sanitizer CHECK failure in
+    "((0)) != (0)" (0x0, 0x0)". (Credit to OSS-Fuzz)
+
+2018-07-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/mvg.c (ReadMVGImage): Don't assume that in-memory MVG
+    blob is a null-terminated C string. Fixes oss-fuzz 9469
+    "graphicsmagick/coder\_MVG\_fuzzer: Heap-buffer-overflow in
+    AllocateString". (Credit to OSS-Fuzz)
+
+2018-07-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/miff.c (ReadMIFFImage): Detect EOF when reading using
+    ReadBlobZC() and avoid subsequent heap read overflow.  Fixes
+    oss-fuzz 9357 "graphicsmagick/coder\_MIFF\_fuzzer:
+    Heap-buffer-overflow in ImportRGBQuantumType". (Credit to
+    OSS-Fuzz)
+
+2018-07-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - fuzzing/oss-fuzz-build.sh (CFLAGS): Try disabling SIMD
+    instructions in libjpeg-turbo build.
+
+2018-07-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (WriteOnePNGImage): Free png\_pixels as soon as
+    possible.  This might help with oss-fuzz 9334
+    "graphicsmagick/coder\_PNG8\_fuzzer: Direct-leak in
+    WriteOnePNGImage", which we have yet to reproduce.  It is not
+    clear if png\_pixels is being clobbered by longjmp or if something
+    else is going on.
+
+2018-06-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/jpeg.c (ReadJPEGImage): Provide a memory resource limit
+    (of 1/5th the memory resource limit for Graphicsmagick) to libjpeg
+    to limit how much memory it might consume for itself while reading
+    a file.  Fixes oss-fuzz 9096 "graphicsmagick/coder\_JPEG\_fuzzer:
+    Timeout in graphicsmagick\_coder\_JPEG\_fuzzer".  (Credit to
+    OSS-Fuzz)
+    (ReadJPEGImage): Make sure that JPEG pixels array is initialized
+    in case libjpeg fails to completely initialize it.  May fix
+    oss-fuzz 9115 "graphicsmagick/coder\_JPEG\_fuzzer:
+    Use-of-uninitialized-value in ReadJPEGImage".  We are not sure
+    since the problem was not reproduced.  (Credit to OSS-Fuzz)
+
+2018-06-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - version.sh: Update library versioning for 1.3.30 release.
+
+  - NEWS.txt: Update news for 1.3.30 release.
+
+2018-06-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dpx.c (ReadDPXImage): Report exception on EOF file
+    reading DPX pixel data. Fixes oss-fuzz 8104
+    "graphicsmagick/coder\_DPX\_fuzzer: Use-of-uninitialized-value in
+    WriteDPXImage", oss-fuzz 8297 "graphicsmagick/enhance\_fuzzer:
+    Use-of-uninitialized-value in EnhanceImage", and oss-fuzz 8133
+    "graphicsmagick/coder\_DPX\_fuzzer: Use-of-uninitialized-value in
+    RGBTransformPackets". (Credit to OSS-Fuzz)
+
+2018-06-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/cmyk.c (ReadCMYKImage): Free scanline buffer in error
+    path. Fixes SourceForge issue #567 "small memory leak in rgb.c,
+    gray.c and cmyk.c" reported by Petr Gajdos.
+
+  - coders/gray.c (ReadGRAYImage): Free scanline buffer in error
+    path. Fixes SourceForge issue #567 "small memory leak in rgb.c,
+    gray.c and cmyk.c" reported by Petr Gajdos.
+
+  - coders/rgb.c (ReadRGBImage): Free scanline buffer in error
+    path. Fixes SourceForge issue #567 "small memory leak in rgb.c,
+    gray.c and cmyk.c" reported by Petr Gajdos.
+
+  - coders/jpeg.c (ReadJPEGImage): Avoid memory leak of profile
+    buffer when longjmp-based exception is thrown while reading a
+    profile. Fixes oss-fuzz 8957 "graphicsmagick/enhance\_fuzzer:
+    Direct-leak in ReadGenericProfile". (Credit to OSS-Fuzz)
+
+2018-06-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/xcf.c (load\_level): Make sure to free 'tile\_image' before
+    returning exception.  Fixes oss-fuzz 8935
+    "graphicsmagick/coder\_XCF\_fuzzer: Indirect-leak in
+    CloneImage". (Credit to OSS-Fuzz)
+
+  - coders/jpeg.c (ReadJPEGImage): Allow three warnings of any given
+    type before promoting the next warning of the same type to a hard
+    error.  The warning limit may be adjusted by the user using
+    -define jpeg:max-warnings=<value>.  Fixes oss-fuzz 8704
+    "graphicsmagick/coder\_JPG\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_JPG\_fuzzer". (Credit to OSS-Fuzz)
+
+  - coders/png.c (ReadPNGImage): Detect EOF when reading
+    magic\_number.  Fixes oss-fuzz 8944
+    "graphicsmagick/coder\_PNG\_fuzzer: Use-of-uninitialized-value in
+    ReadPNGImage".  (Credit to OSS-Fuzz)
+    (ReadPNGImage, ReadJNGImage): Makes sure that return value of
+    ReadBlob() is always checked to detect EOF.
+
+2018-06-16  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/tiff.c (ReadTIFFImage): Re-structure exception reporting
+    so that QuantumTransferMode() exceptions thrown for
+    PLANARCONFIG\_SEPARATE images are handled immediately.  Fixes
+    oss-fuzz 8896 "graphicsmagick/coder\_BIGTIFF\_fuzzer:
+    Use-of-uninitialized-value in DisassociateAlphaRegion". (Credit to
+    OSS-Fuzz)
+    (ReadTIFFImage): tsize\_t is a signed type so be prepared for
+    unexpected negative values produced by libtiff size functions.
+    Fixes oss-fuzz 8934 "graphicsmagick/coder\_TIFF\_fuzzer: Sanitizer
+    CHECK failure in "((0)) != (0)" (0x0, 0x0)". (Credit to OSS-Fuzz)
+
+2018-06-16  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/wpg.c Fix oss-fuzz 7735 "graphicsmagick/coder\_WPG\_fuzzer:
+    Use-of-uninitialized-value in ReadWPGImage".  (Credit to OSS-Fuzz)
+
+2018-06-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadMNGImage): ENDL chunk must be at least one
+    byte in size. Fixes oss-fuzz 8832
+    "graphicsmagick/coder\_MNG\_fuzzer: Null-dereference READ in
+    ReadMNGImage". (Credit to OSS-Fuzz)
+    (ReadMNGImage): Length of DISC chunk must be evenly divisible by
+    2.  Fixes oss-fuzz 8834 "graphicsmagick/coder\_MNG\_fuzzer:
+    Heap-buffer-overflow in ReadMNGImage". (Credit to OSS-Fuzz)
+
+2018-06-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/mpc.c (ReadMPCImage): Detect end of file while reading
+    image directory.  Similar to MIFF fixes for ImageMagick
+    CVE-2017-18272.
+    (RegisterMPCImage): Require seekable stream since MPC is strictly
+    a file-based format and so GetBlobSize() is assured to work.
+    Similar to MIFF behavior.  Claimed to be part of the resolution
+    for ImageMagick CVE CVE-2017-11449. Suggested by Petr Gajdos via
+    email on January 3, 2018.
+
+2018-06-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/miff.c (ReadMIFFImage): Detect end of file while reading
+    image directory. Fixes SourceForge issue 565 "ImageMagick
+    CVE-2017-18272 applies to GraphicsMagick".  Thanks to Petr Gajdos
+    for reporting this issue to us.
+
+  - magick/import.c (ImportViewPixelArea): Use appropriate
+    bits\_per\_sample validations for FloatQuantumSampleType. Fixes
+    oss-fuzz 8780 "graphicsmagick/coder\_PTIF\_fuzzer:
+    Use-of-uninitialized-value in HorizontalFilter". (Credit to
+    OSS-Fuzz)
+
+2018-06-09  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c More than 4GiB are not supported in MAT!
+
+2018-06-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/mat.c (ReadMATImage): Add casts to avoid arithmetic
+    overflow when computing size and offsets.  Fixes oss-fuzz 8801
+    "graphicsmagick/coder\_MAT\_fuzzer: Timeout in
+    graphicsmagick\_coder\_MAT\_fuzzer". (Credit to OSS-Fuzz)
+
+  - magick/blob.c (ReadBlobLSBDoubles, ReadBlobMSBDoubles): Only
+    byte-swap doubles or test doubles for NAN if we have read enough
+    bytes for at least one double value.
+    (ReadBlob): Add an assertion to enforce that ReadBlob() will never
+    report reading more bytes than requested due to some
+    implementation issue.
+
+2018-06-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/blob.c (ReadBlob, WriteBlob): gzread(), BZ2\_bzread(),
+    gzwrite(), BZ2\_bzwrite() return type 'int' rather than 'size\_t'
+    like their stdio equivalents.  Use correct signed type to avoid
+    returning a negative value into an unsigned type, forming a huge
+    positive value.  Fixes oss-fuzz 8600
+    "graphicsmagick/coder\_MAT\_fuzzer: Heap-buffer-overflow in
+    ReadBlobLSBDoubles". (Credit to OSS-Fuzz)
+
+2018-06-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (png\_read\_raw\_profile): Try to shore up parsing of
+    raw profile reading to avoid heap read overruns.  Fixes oss-fuzz
+    8763 "graphicsmagick/coder\_PNG32\_fuzzer: Heap-buffer-overflow in
+    png\_read\_raw\_profile". (Credit to OSS-Fuzz)
+
+2018-06-07  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c Reduce stack usage for 64 bit architecture.
+
+2018-06-06  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/wpg.c Check return values of SeekBlob for more safety.
+
+2018-06-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJNGImage): Use DestroyImageList() rather
+    than DestroyImage() on returned Image from supposed read of JPEG
+    data, in case multiple frames were unexpectedly returned.  Also
+    add "JPEG:" prefix to filename when reading from temporary file to
+    force that it can only be read as a JPEG file, disabling format
+    auto-detection based on file header.  Fixes oss-fuzz 8755
+    "graphicsmagick/coder\_JNG\_fuzzer: Indirect-leak in
+    AllocateImage". (Credit to OSS-Fuzz)
+
+2018-06-05  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/blob.c (EOFBlob): Implement EOF detection for ZipStream.
+    Does some archaic zlib not provide gzeof()?  Fixes oss-fuzz 8550
+    "graphicsmagick/coder\_MAT\_fuzzer: Timeout in
+    graphicsmagick\_coder\_MAT\_fuzzer". (Credit to OSS-Fuzz)
+
+2018-06-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOnePNGImage): Skip adding empty raw profile.
+    Fixes oss-fuzz "graphicsmagick/coder\_PNG\_fuzzer:
+    Heap-buffer-overflow in png\_read\_raw\_profile". (Credit to
+    OSS-Fuzz)
+
+2018-06-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - NEWS.txt: Update NEWS with latest changes.
+
+  - coders/dcm.c (DCM\_ReadRGBImage): Force the image to DirectClass
+    to avoid later use of uninitialized indexes.  Fixes oss-fuzz 8602
+    "graphicsmagick/coder\_DCM\_fuzzer: Use-of-uninitialized-value in
+    DCM\_PostRescaleImage". (Credit to OSS-Fuzz)
+    (DCM\_ReadPlanarRGBImage): Force the image to DirectClass to avoid
+    later use of uninitialized indexes.
+
+  - coders/png.c (ReadMNGImage): Free chunk memory in error
+    reporting path to avoid leak.  Fixes oss-fuzz 8721
+    "graphicsmagick/coder\_MNG\_fuzzer: Direct-leak in
+    ReadMNGImage". (Credit to OSS-Fuzz)
+
+2018-06-02  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/constitute.c (ReadImage): Assure that an error exception
+    is thrown if coder returns null without properly reporting an
+    exception.
+
+  - magick/blob.c (BlobToImage): Assure that an error exception is
+    thrown if coder returns null without properly reporting an
+    exception.
+
+  - coders/png.c (ReadMNGImage): Disable mystery "linked list is
+    corrupted" code.  Assure that exceptions are reported to the
+    correct place so they are not lost.  Fixes oss-fuzz 8710
+    "graphicsmagick/coder\_MNG\_fuzzer: Indirect-leak in
+    AllocateImage". (Credit to OSS-Fuzz)
+
+  - coders/tiff.c (ReadTIFFImage): Initialize allocated scanline,
+    strip, or tile to zero in order to avoid complaint about use of
+    uninitialized data if libtiff fails to write all the bytes.  Fixes
+    oss-fuzz 8551 "graphicsmagick/coder\_TIFF\_fuzzer:
+    Use-of-uninitialized-value in ImportGrayQuantumType". (Credit to
+    OSS-Fuzz)
+
+  - magick/annotate.c (RenderFreetype): Throw an exception if
+    DrawInfo font is null.  Should fix oss-fuzz 8557
+    "graphicsmagick/coder\_PCD\_fuzzer: Unknown signal in
+    RenderFreetype" and may fix oss-fuzz 8544
+    "graphicsmagick/coder\_PCD\_fuzzer: Null-dereference READ in
+    RenderFreetype". (Credit to OSS-Fuzz)
+
+  - coders/jpeg.c (ReadGenericProfile): Add/improve tracing for
+    profile size and when JPEG header is being read.
+
+2018-06-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJNGImage): Report a useful exception for
+    the case when the JNG file fails to provide the necessary image
+    chunks to allocate the color image.  Inspired by oss-fuzz 8666
+    "graphicsmagick/coder\_JNG\_fuzzer: ASSERT: data != (const char \*)
+    NULL" although the reported issue was not reproduced.
+
+2018-05-31  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadMNGImage): Fix off-by-one in length validation
+    for TERM chunk which allowed one byte heap read overflow.  Fixes
+    oss-fuzz 8615 "graphicsmagick/coder\_MNG\_fuzzer:
+    Heap-buffer-overflow in mng\_get\_long". (Credit to OSS-Fuzz)
+    (ReadMNGImage): Fix leak of MngInfo in error reporting path.
+    Fixes oss-fuzz 8604 "graphicsmagick/coder\_MNG\_fuzzer: Direct-leak
+    in ReadMNGImage". (Credit to OSS-Fuzz)
+    (ReadMNGImage): Verify that claimed chunk size does not exceed
+    input size.  Fixes oss-fuzz 8564 "graphicsmagick/coder\_MNG\_fuzzer:
+    Out-of-memory in graphicsmagick\_coder\_MNG\_fuzzer". (Credit to
+    OSS-Fuzz)
+
+  - coders/tiff.c (ReadTIFFImage): Reject files with excessive
+    samples-per-pixel or extra-samples. Avoids potential issues
+    observed in oss-fuzz 8634 "graphicsmagick/coder\_BIGTIFF\_fuzzer:
+    Undefined-shift in ImportAlphaQuantumType". (Credit to OSS-Fuzz)
+
+2018-05-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadMNGImage): Assure that object id index is
+    always less than MNG\_MAX\_OBJECTS to avoid overflow.  Fixes
+    oss-fuzz 8596 "graphicsmagick/coder\_MNG\_fuzzer:
+    Index-out-of-bounds in ReadMNGImage" and likely other issues yet
+    to be reported. (Credit to OSS-Fuzz)
+
+2018-05-30  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (CompareEdges): Per ticket #562,
+    function CompareEdges() did not conform to the qsort()
+    requirement that if CompareEdges(edge0,edge1) returns
+    -1 (i.e., edge0 "less than" edge1), then
+    CompareEdges(edge1,edge0) should return 1 (edge1
+    "greater than" edge0).  This has been fixed.
+
+2018-05-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJNGImage): Deal with JDAA JNG chunk with
+    length zero.  Fixes oss-fuzz 8562
+    "graphicsmagick/coder\_JNG\_fuzzer: ASSERT: data != (const char \*)
+    NULL". (Credit to OSS-Fuzz)
+
+  - coders/tiff.c (ReadTIFFImage): Check that the bits-per-sample is
+    supported by the implementation before attempting to decode the
+    image. Fixes oss-fuzz 8554 "graphicsmagick/coder\_BIGTIFF\_fuzzer:
+    Undefined-shift in MagickBitStreamMSBWrite". (Credit to OSS-Fuzz)
+
+  - coders/png.c (ReadMNGImage): Eliminate use of uninitialized
+    header magic data by checking for EOF first.  Fixes oss-fuzz 8597
+    "graphicsmagick/coder\_MNG\_fuzzer: Use-of-uninitialized-value in
+    ReadMNGImage". (Credit to OSS-Fuzz)
+
+2018-05-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - fuzzing/oss-fuzz-build.sh: More fixes based on what is observed
+    in oss-fuzz build log.
+
+2018-05-24  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/jnx.c The attribute should belong to only one scene and
+    not to whole image list.
+
+2018-05-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - fuzzing/oss-fuzz-build.sh: Changes to add CPPFLAGS to configure
+    executions to hopefully get oss-fuzz build closer to success.
+
+2018-05-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - PerlMagick/t/jpeg/read.t: Add a JNX reader test case.
+
+  - coders/jnx.c (ReadJNXImage): JNX image depth should be 8.
+
+  - fuzzing/oss-fuzz-build.sh: Apply patch from Alex Gaynor to
+    switch libpng to autotools build system, as well as configure
+    GraphicsMagick with '--with-quantum-depth=16'.
+
+2018-05-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/tiff.c (ReadTIFFImage): Validate tile memory requests for
+    the TIFFReadRGBATile() case in the same way as the TIFFReadTile()
+    case.  Fixes oss-fuzz 8434 "graphicsmagick/coder\_BIGTIFF\_fuzzer:
+    Out-of-memory in graphicsmagick\_coder\_BIGTIFF\_fuzzer". (Credit to
+    OSS-Fuzz)
+
+2018-05-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/tile.c (ReadTILEImage): Remove any existing size request
+    when while image to tile.  This avoids size being used for both
+    the input image size and the tile image size.  Fixes SourceForge
+    issue #563 "tile:<image> appears to blow image up by 100% before
+    applying tiling".
+
+2018-05-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - fuzzing/oss-fuzz-build.sh: Patch from Paul Kehrer to disable
+    libpng test programs and binaries while building libpng in support
+    of oss-fuzz testing.
+
+  - coders/dcm.c (DCM\_ReadGrayscaleImage): If a palette was
+    provided, the image may be in PseudoClass but we need DirectClass
+    for gray image when GRAYSCALE\_USES\_PALETTE is not defined.  Fixes
+    oss-fuzz 7550 "graphicsmagick/coder\_DCM\_fuzzer:
+    Use-of-uninitialized-value in SyncImageCallBack". (Credit to
+    OSS-Fuzz)
+    (ReadDCMImage): Restore use of DCM\_PostRescaleImage() in order to
+    obtain suitably scaled DICOM again.  Hopefully it is more robust
+    now.
+    (DCM\_ReadPaletteImage): Assure that DirectClass pixels are
+    initialized.
+
+2018-05-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/tiff.c (ReadTIFFImage): Remove strange addition of
+    image->columns to pixel buffer offsets which now causes a heap
+    overflow since the buffer has been right-sized.  Perhaps the extra
+    offset plus the over-sized allocation was some attempt to avoid
+    buffer over/underflows due to bugs in libtiff. Fixes oss-fuzz 8384
+    "graphicsmagick/coder\_BIGTIFF\_fuzzer: Heap-buffer-overflow in
+    put1bitbwtile" which is described to be a regression. (Credit to
+    OSS-Fuzz)
+
+  - magick/render.c (DrawImage): Fix wrong range checks which caused
+    spurious "Parsing of SVG images fail with "Non-conforming drawing
+    primitive definition (push)" failure.  Fixes SourceForge issue 561
+    "Parsing of SVG images fail with "Non-conforming drawing primitive
+    definition (push)"" which is due to problems caused by the fix for
+    SourceForge issue 517.
+
+  - coders/tiff.c (WritePTIFImage): Use '-define
+    ptif:minimum-geometry=<geometry>' to specify the smallest
+    subresolution frame which is produced by the PTIF (Pyramid TIFF)
+    writer.
+
+2018-05-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/tiff.c (WritePTIFImage): Allow 1x1 input image to be
+    supported.
+
+  - coders/png.c (ReadOneJNGImage): Unconditionally free JDAT chunk
+    memory.  Fixes oss-fuzz 8366 "graphicsmagick/coder\_JNG\_fuzzer:
+    Direct-leak in ReadOneJNGImage". (Credit to OSS-Fuzz)
+
+  - coders/tiff.c (WritePTIFImage): Fix leak of pyramid Image list
+    if ResizeImage() fails.  Fixes oss-fuzz 8364
+    "graphicsmagick/coder\_PTIF\_fuzzer: Indirect-leak in
+    CloneImage". (Credit to OSS-Fuzz)
+
+2018-05-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/tiff.c (WriteTIFFImage): Add and use
+    ThrowTIFFWriterException() macro to consistently clean-up when
+    throwing writer exception.  May fix oss-fuzz 8321
+    "graphicsmagick/coder\_EPT\_fuzzer: Direct-leak in
+    TIFFClientOpen". (Credit to OSS-Fuzz)
+    (ReadTIFFImage): Add and use ThrowTIFFReaderException() macro to
+    consistently clean-up when throwing reader exception.
+
+2018-05-16  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/alpha\_composite.h (AlphaCompositePixel): The
+    macro definition for MagickAlphaCompositeQuantum in
+    alpha\_composite.h computes an expression of the form:
+
+    a \* b + c \* d \* e
+
+    Code in function AlphaCompositePixel() (also in
+    alpha\_composite.h) multiplies the result of this macro
+    by variable "delta" as follows:
+
+    delta \* a \* b + c \* d \* e
+
+    However, the intended result is actually:
+
+    delta \* ( a \* b + c \* d \* e )
+
+    The macro definition has been modified to enclose the
+    entire expression in parentheses.
+
+    The effects of this bug were particularly evident at the
+    boundary between a stroked polygon and a transparent
+    black region. More generally, an incorrect composited
+    pixel value was being computed by AlphaCompositePixel()
+    whenever the output alpha value was not 100% opaque.
+
+2018-05-16  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - tests/rwblob.tap: Add a test for PTIF format.
+
+  - coders/tiff.c (WritePTIFImage): Fix Image blob referencing in
+    order to avoid double-free when writing PTIF to memory BLOB. Fixes
+    oss-fuzz 8280 "graphicsmagick/coder\_PTIF\_fuzzer: Heap-double-free
+    in Magick::BlobRef::~BlobRef". (Credit to OSS-Fuzz)
+
+2018-05-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/tiff.c (WriteTIFFImage): Use libtiff's
+    TIFFDefaultStripSize() function rather than an old porting macro
+    required by some defunct libtiff version.  Expected to fix
+    oss-fuzz 8248 "graphicsmagick/coder\_EPT\_fuzzer:
+    Floating-point-exception in WriteTIFFImage". (Credit to OSS-Fuzz)
+
+2018-05-13  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c Fix potentional leak when compressed object is
+    corrupted. Fixes oss-fuzz 8251 (Credit to OSS-Fuzz)
+
+2018-05-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/tiff.c (ReadTIFFImage): Fix leak of Image when
+    TIFFReadRGBAImage() reports failure.  Also harden buffer
+    allocation calculation.  Fixes oss-fuzz 8275
+    "graphicsmagick/coder\_BIGTIFF\_fuzzer: Indirect-leak in
+    AllocateImage". (Credit to OSS-Fuzz)
+
+  - coders/ept.c (ReadEPTImage): Add validations of 'count' and
+    'filesize' read from EPT file. In response to oss-fuzz 8248
+    "graphicsmagick/coder\_EPT\_fuzzer: Floating-point-exception in
+    WriteTIFFImage" but we are unable to recreate the oss-fuzz issue
+    since the EPT reader already immediately reports an EOF exception.
+
+2018-05-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - fuzzing/oss-fuzz-build.sh: Apply SourceForge patch #57 "Add
+    fuzzing support for jpeg + freetype delegates" by Alex Gaynor.
+
+  - coders/png.c (read\_user\_chunk\_callback): Fix memory leak and use
+    of uninitialized memory when handling eXIf chunk. Fixes oss-fuzz
+    8247 "graphicsmagick/coder\_PNG24\_fuzzer: Direct-leak in
+    png\_malloc". (Credit to OSS-Fuzz)
+
+2018-05-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - fuzzing/oss-fuzz-build.sh: Apply SourceForge patch #56 "Use a
+    few delegate libraries in fuzzing" by Alex Gaynor.
+
+2018-05-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - tests/rwfile.tap: MIFF zip and bzip compression tests do not
+    fail if zlib and bzlib are not available because the compression
+    request is silently changed to no compression.
 
+2018-05-07  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
 
+  - magick/render.c (DrawImage, InsertAttributeIntoInputStream):
+    For a reference such as 'class="classname"', the "classname"
+    is now allowed to be undefined.
+
+  - coders.svg.c (ProcessStyleClassDefs): Class definitions
+    defined within a <style> block may now be empty.
+
+  - These relaxed conditions are not specifically called out in
+    the SVG spec as being either acceptable or unacceptable, but
+    other SVG renderers (e.g., Chrome) handle them this way. These
+    changes do not resolve, but are related to, ticket #307.
+
+2018-05-05  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - utilities/Makefile.am (utilities/tests/montage.log): Fix
+    dependency rule so that effects.tap is fully executed before
+    execution of montage.tap starts.
+
+2018-05-04  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (DrawImage, TraceXXX): The PrimitiveInfo
+    array used to store points generated by TraceEllipse(), the
+    other TraceXXX() functions, and DrawImage() was not always
+    being expanded when needed, resulting in writes beyond the
+    end of the currently allocated storage. To fix this problem,
+    a new data structure PrimitiveInfoMgr, and an associated
+    function, PrimtiveInfoRealloc(), were written to handle
+    expanding the PrimitiveInfo array as needed. DrawImage() and
+    the TraceXXX() functions were modified to prevent the out of
+    bounds writes to memory. This fixes ticket #516.
+
+2018-05-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOneJNGImage): Add more JNG chunk
+    validations. Fixes an issue reported by "Trace Probe" via a
+    follow-up post to SourceForge issue 437 "assertion failure in
+    WriteBlob", although the issue described was not reproduced.
+
+  - coders/meta.c (ReadMETAImage): Detect and report 8BIMTEXT and
+    8BIMWTEXT decoding problems.  Fixes oss-fuzz 8125
+    "graphicsmagick/coder\_8BIMTEXT\_fuzzer: Use-of-uninitialized-value
+    in format8BIM". (Credit to OSS-Fuzz)
+
+2018-05-02  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (TraceStrokePolygon): Excessively
+    large values of stroke-width were cascading through
+    other computations, causing the function to write beyond
+    the end of it's array of points when the stroke-linejoin
+    attribute value was "round". Code was added to reallocate
+    the array of points as needed, and to limit the size of
+    stroke-width (for computational purposes) to no more than
+    approximately twice the diagonal size of the output image.
+    Fixes ticket #515.
+
+  - The same limit on stroke-width was applied to all other
+    instances of the same computation in render.c.
+
+2018-05-01  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - This change set fixes ticket #471.
+
+  - magick/render.c (DrawImage): Polylines with fewer
+    than two points were being flagged as an error. The
+    SVG spec has no such restriction (fixed).
+
+  - coders/svg.c (SVGStartElement) Inner <svg> elements
+    could modify the output image dimensions if a geometry
+    string was supplied. Now the output image dimensions
+    are determined by the outermost <svg> only.
+
+2018-05-01  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (TraceEllipse, TraceRectangle,
+    TraceRoundRectangle): Per the SVG spec, rectangles and
+    round rectangles having a width or height of zero are
+    not rendered. Also per the spec, ellipses having an x
+    or y radius of zero are not rendered.  Fixes ticket #457.
+
+2018-04-30  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.h, (PrimitiveInfo), magick/render.c: Added
+    member "flags" to PrimitiveInfo to support indicating closed
+    shapes (e.g., rectangle, circle, path closed using 'z' or 'Z').
+    Updated code in render.c (functions TraceXXX) to indicate
+    closed shapes.  This replaces the previous policy of detecing
+    closed shapes by comparing the first and last points to see if
+    they are identical (within MagickEpsilon). The old policy
+    prevented open subpaths with the same first and last point from
+    being rendered properly (per the SVG spec) when round or square
+    endcaps were enabled.  Part of the fix for ticket #322.
+
+  - magick/render.c (ConvertPrimitiveToPath): Modified duplicate
+    point elimination code so that the first and last points of
+    a subpath are always preserved.  Consequences: (1) Allows
+    for the correct rendering of the sequence "move x1 y1 line
+    x1 y1" with round or square endcaps.  Part of the fix for
+    ticket #322. (2) Fixes a bug in which eliminating the last
+    point as a duplicate caused a closed shape to no longer be
+    closed. This would manifest itself, for example, as a small
+    "nub" on the boundary of a filled circle.
+
+  - magick/render.c (GetPixelOpacity): Fixed a bug in the
+    code that computed the distance between a point and a
+    segment (polygon edge).  Prior to this fix, for zero length
+    segments this code would generate a divide-by-zero and
+    incorrect output. Part of the fix for ticket #322.
+
+  - magick/render.c (DrawPolygonPrimitive): Polygons/paths with
+    zero or one points are no longer rendered per the SVG spec.
+
+  - magick/render.c (DrawStrokePolygon): Per the SVG spec, a
+    polygon consisting of a single move-to command is not stroked.
+
+  - magick/render.c (TracePath): Per the SVG spec, if the
+    endpoints (x1, y1) and (x2, y2) of an arc subpath are identical,
+    then this is equivalent to omitting the elliptical arc segment
+    entirely.  For rendering purposes the zero length arc is
+    treated like a zero length "line to" command to the current
+    point.
+
+  - magick/render.c (TraceStrokePolygon): Added code to detect
+    zero length open subpaths and return a stroked polygon containing
+    no points when round or square endcaps are not enabled.  This
+    satisfies the SVG spec requirement that zero length subpaths are
+    only stroked if the 'stroke-linecap' property has a value of
+    round or square.
+
+  - magick/render.c (TracePath): Fixed a bug in which if a "move to"
+    command was followed by additional pairs of points, indicating
+    implied "line to" commands, each point was added twice.
+
+2018-04-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pcx.c (ReadPCXImage): Colormap from PCX header is only
+    used if colors <= 16. Determination of DirectClass image was
+    wrong.  Fixes oss-fuzz 8093 "graphicsmagick/coder\_PCX\_fuzzer:
+    Use-of-uninitialized-value in IsMonochromeImage". (Credit to
+    OSS-Fuzz)
+
+2018-04-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - version.sh: Updates to prepare for the 1.3.29 release.
+
+  - coders/pict.c (DecodeImage): Assure that scanline is initialized
+    to avoid use of uninitialized data.  Fixes oss-fuzz 8063
+    "graphicsmagick/coder\_WPG\_fuzzer: Use-of-uninitialized-value in
+    ReadPICTImage". (Credit to OSS-Fuzz)
+
+  - coders/dpx.c (ReadDPXImage): Assure that NULL pixels is not
+    used.  Fixes oss-fuzz 8078 "graphicsmagick/coder\_DPX\_fuzzer:
+    Null-dereference WRITE in ReadDPXImage". (Credit to OSS-Fuzz)
+
+  - NEWS.txt: Update NEWS file with information about changes since
+    last release.
+
+2018-04-28  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dib.c (ReadDIBImage): Disable EOF tests for "ICODIB"
+    subformat due to icon file provided by SourceForge issue #557
+    "ErrorCorruptImage: Magick: Unexpected end-of-file ()" where an
+    EOF error was reported due to no mask data being supplied.
+
+  - coders/png.c (ReadOneJNGImage): The embedded JPEG image is
+    required to have the same dimensions as the JNG image as provided
+    by JHDR.  Fixes SourceForge bug 555 "heap-buffer-overflow in
+    AcquireCacheNexus when processing jng file".  It is likely that
+    this issue is precipitated by using 'montage' which seems to set a
+    default non-zero image size.
+    (ReadMNGImage): By default limit the maximum loops specifiable by
+    the MNG LOOP chunk to 512 loops, but allow this to be modified by
+    '-define mng:maximum-loops=value'.  Also assure that the value is
+    in the range of 0-2147483647 as per the MNG specification.  This
+    is to address the denial of service issue described by
+    CVE-2018-10177.  This problem was reported to us by Petr Gajdos
+    via email on Fri, 20 Apr 2018.
+
+  - coders/dpx.c (ReadDPXImage): Move misplaced channel validation
+    code.  Fixes oss-fuzz 8041 "graphicsmagick/coder\_DPX\_fuzzer:
+    Use-of-uninitialized-value in WriteDPXImage" and oss-fuzz 8055
+    "graphicsmagick/enhance\_fuzzer: Use-of-uninitialized-value in
+    EnhanceImage". (Credit to OSS-Fuzz)
+
+2018-04-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/xpm.c (StringToListMod): Algorithm fixes to fix use of
+    uninitialized data.  Fixes oss-fuzz 8046
+    "graphicsmagick/coder\_XPM\_fuzzer: Use-of-uninitialized-value in
+    StringToListMod". (Credit to OSS-Fuzz)
+
+2018-04-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/xpm.c (ReadXPMImage): Reduce memory consumption further.
+    Hopefully fixes oss-fuzz 8013 "graphicsmagick/coder\_XPM\_fuzzer:
+    Out-of-memory in graphicsmagick\_coder\_XPM\_fuzzer". (Credit to
+    OSS-Fuzz)
+
+  - magick/utility.c (StringToList): Only allocate the memory
+    required when converting string to an ASCII list.  May or may not
+    fix oss-fuzz 8013 "graphicsmagick/coder\_XPM\_fuzzer: Out-of-memory
+    in graphicsmagick\_coder\_XPM\_fuzzer". (Credit to OSS-Fuzz)
+
+2018-04-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/bmp.c (ReadBMPImage): Fix benign use of uninitialized
+    data when testing header magick.  Fixes oss-fuzz 7980
+    "graphicsmagick/coder\_BMP\_fuzzer: Use-of-uninitialized-value in
+    LocaleNCompare". (Credit to OSS-Fuzz)
+
+  - coders/dpx.c (ReadDPXImage): ColorDifferenceCbCr does require
+    even image width. Fixes oss-fuzz 7966
+    "graphicsmagick/coder\_DPX\_fuzzer: Unknown signal in
+    TentUpsampleChroma". (Credit to OSS-Fuzz)
+
+2018-04-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dpx.c (ReadDPXImage): ColorDifferenceCbCr element
+    requires two samples/pixel, not one. Fixes oss-fuzz 7951
+    "graphicsmagick/coder\_DPX\_fuzzer: Heap-buffer-overflow in
+    ReadDPXImage". (Credit to OSS-Fuzz)
+
+2018-04-22  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pdb.c (ReadPDBImage): Assure that pixels buffer is
+    initialized.  Fixes oss-fuzz 7937
+    "graphicsmagick/coder\_PDB\_fuzzer: Use-of-uninitialized-value in
+    ReadPDBImage". (Credit to OSS-Fuzz)
+
+  - coders/mvg.c (ReadMVGImage): Assure that MVG viewbox parameters
+    were supplied.  Fixes oss-fuzz 7936
+    "graphicsmagick/coder\_MVG\_fuzzer: Use-of-uninitialized-value in
+    ReadMVGImage". (Credit to OSS-Fuzz)
+
+  - coders/dpx.c (ReadDPXImage): Element descriptors CbYCrY422 and
+    CbYACrYA4224 require that the image width be evenly divisible by 2
+    so enforce that.  Fixes oss-fuzz 7935
+    "graphicsmagick/coder\_DPX\_fuzzer: Heap-buffer-overflow in
+    ReadDPXImage". (Credit to OSS-Fuzz)
+
+2018-04-21  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dpx.c (ReadDPXImage): Reject DPX files which claim to use
+    signed data.  Fixes oss-fuzz 7758
+    "graphicsmagick/coder\_DPX\_fuzzer: Use-of-uninitialized-value in
+    WriteDPXImage". (Credit to OSS-Fuzz)
+    (ReadDPXImage): Validate that the image elements do update all of
+    the channels, including the alpha channel.  Now report an error if
+    a color channel is missing.  Fixes oss-fuzz 7758
+    "graphicsmagick/coder\_DPX\_fuzzer: Use-of-uninitialized-value in
+    WriteDPXImage".
+
+  - coders/gif.c (DecodeImage): Finally fix oss-fuzz 7732
+    "graphicsmagick/coder\_GIF\_fuzzer: Heap-buffer-overflow in
+    DecodeImage" which was not actually fixed with previous
+    changes. (Credit to OSS-Fuzz)
+
+2018-04-21  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/topol.c Emit error when tile storage overflows image data;
+        fixes oss-fuzz 7769 thanks to oss-fuzz.
+
+2018-04-20  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (ConvertPrimitiveToPath):  Fixed a bug
+    in which SVG paths containing multiple open subpaths were
+    not being processed correctly, resulting in incorrect
+    output.  This fixes ticket #94.
+
+2018-04-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/gif.c (DecodeImage): Fix use of uninitialized memory
+    during error condition in decoder. Fixes oss-fuzz 7732
+    "graphicsmagick/coder\_GIF\_fuzzer: Heap-buffer-overflow in
+    DecodeImage". (Credit to OSS-Fuzz)
+
+  - coders/txt.c (ReadTXTImage): Assure that all image pixels are
+    initialized to black.
+
+  - Magick++/demo/zoom.cpp (main): Add a -read-blob option to read
+    input file into a Blob so that it is read by the Blob reader
+    rather than the file reader.  Default the output Geometry to the
+    input image geometry in case the user does not specify a resize
+    resolution or geometry.
+
+  - Magick++/tests/readWriteBlob.cpp (main): Improve the quality of
+    code which reads a file into memory for Blob testing.
+
+  - magick/blob.c (BlobToImage): Add exception reports for the cases
+    where 'magick' was not set and the file format could not be
+    deduced from its header.  Previously a null Image pointer was
+    being returned without any exception being thrown.
+
+2018-04-15  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dpx.c (ReadDPXImage): Assure that CbCr layer initializes
+    all channels if it is the first element of a planar DPX.  Fixes
+    oss-fuzz 7703 "graphicsmagick/coder\_DPX\_fuzzer:
+    Use-of-uninitialized-value in WriteDPXImage". (Credit to OSS-Fuzz)
+
+  - coders/pict.c (ReadPICTImage): Don't refer to filename member of
+    ImageInfo which was just destroyed. Much thanks to Alex Gaynor for
+    finding this.  Should fix oss-fuzz 6867
+    "graphicsmagick/coder\_PCT\_fuzzer: Heap-use-after-free in
+    GetLocaleExceptionMessage". (Credit to OSS-Fuzz).
+
+2018-04-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/sgi.c (ReadSGIImage): Assure that iris pixels are fully
+    initialized.  Fixes oss-fuzz 7543
+    "graphicsmagick/coder\_SGI\_fuzzer: Use-of-uninitialized-value in
+    SGIEncode". (Credit to OSS-Fuzz).
+
+  - coders/xcf.c (ReadXCFImage): Restore SetImage() which was
+    previously commented out.  This is needed to assure initialized
+    pixels.  Fixes oss-fuzz 7430 "graphicsmagick/coder\_XCF\_fuzzer:
+    Use-of-uninitialized-value in AlphaCompositePixel". (Credit to
+    OSS-Fuzz).
+
+  - coders/pict.c (ReadPICTImage): Properly initialize "black
+    canvas" that tiles may be composed on.  Fixes oss-fuzz 7574
+    "graphicsmagick/enhance\_fuzzer: Use-of-uninitialized-value in
+    EnhanceImage". (Credit to OSS-Fuzz).
+
+  - coders/rle.c (ReadRLEImage): Check for EOF when reading comment.
+    Fixes oss-fuzz 7667 "graphicsmagick/coder\_RLE\_fuzzer:
+    Use-of-uninitialized-value in ReadRLEImage". (Credit to OSS-Fuzz).
+
+  - coders/pdb.c (WritePDBImage): Avoid use of uninitialized
+    bytes. Fixes oss-fuzz 7638 "graphicsmagick/coder\_PDB\_fuzzer:
+    Use-of-uninitialized-value in WritePDBImage". (Credit to
+    OSS-Fuzz).
+
+  - coders/rla.c (ReadRLAImage): Add many more validations,
+    including scanline offsets and number of channels.  Fixes oss-fuzz
+    7653 "graphicsmagick/coder\_RLA\_fuzzer: Timeout in
+    graphicsmagick\_coder\_RLA\_fuzzer". (Credit to OSS-Fuzz).
+
+  - coders/txt.c (ReadTXTImage): Implement missing subrange logic to
+    read only the specified range of frames.  Limits frames read from
+    oss-fuzz test case
+    clusterfuzz-testcase-minimized-coder\_TEXT\_fuzzer-6061076048248832
+    "graphicsmagick/coder\_TEXT\_fuzzer: Timeout in
+    graphicsmagick\_coder\_TEXT\_fuzzer". (Credit to OSS-Fuzz).
+
+  - Magick++/lib/Image.cpp (read): Set subrange = 1 since this
+    interface is intended to read just one frame from the input file.
+    Use the STL-based interfaces to read multiple frames.
+
+  - coders/fits.c (ReadFITSImage): Verify FITS header before reading
+    further.  Rejects file from oss-fuzz 7650
+    "graphicsmagick/coder\_FITS\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_FITS\_fuzzer".  (Credit to OSS-Fuzz).
+
+  - PerlMagick/Magick.xs (Get): Fix PerlMagick compilation problem
+    due to rename/repurposing of image->clip\_mask.
+
+2018-04-13  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/image.c, magick/image.h:  In order to be able to
+    support SVG masks, and to be able to further extend the
+    Image data structure without changing its size, new data
+    structure ImageExtra (struct \_ImageExtra) has been added.
+    Header file image.h contains only a forward declaration;
+    the members of ImageExtra are defined in file image.c.
+    Image member variable Image \* clip\_mask has been replaced
+    by ImageExtra \* extra, and function prototypes that enable
+    access to ImageExtra have been added to image.h.  The
+    clip\_mask member variable now resides in ImageExtra.  All
+    references to Image::clip\_mask in the GraphicsMagick
+    source code have either been replaced with direct references
+    to ImageExtra::clip\_mask (image.c), or have been replaced
+    with calls to access function ImageGetClipMask().
+
+  - magick/render.c, magick/render.h:  In order to be able to
+    support SVG masks, and to be able to further extend the
+    DrawInfo data structure without changing its size, new data
+    structure DrawInfoExtra (struct \_DrawInfoExtra) has been added.
+    Header file render.h contains only a forward declaration;
+    the members of DrawInfoExtra are defined in file render.c.
+    DrawInfo member variable char \* clip\_path has been replaced by
+    DrawInfoExtra \* extra, and function prototypes that enable
+    access to DrawInfoExtra have been added to render.h.  The
+    clip\_path member variable now resides in ImageExtra.  All
+    references to DrawInfo::clip\_path in the GraphicsMagick
+    source code have either been replaced with direct references
+    to DrawInfoExtra::clip\_path (render.c), or have been
+    replaced with calls to access function DrawInfoGetClipPath().
+
+  - magick/image.c (new functions CompositePathImage,
+    CompositeMaskImage, GetImageCompositeMask,
+    SetImageCompositeMask):  Defined new data structure ImageExtra,
+    added create/destroy logic, and implemented associated access
+    functions.  Implemented SVG masks.
+
+  - magick/render.c (DrawImage, new function DrawCompositeMask):
+    Defined new data structure DrawInfoExtra, added create/destroy
+    logic, and implemented associated access functions.  Impemented
+    SVG masks.
+
+  - magick/pixel\_cache.c (SyncCacheNexus, new function
+    CompositeCacheNexus):  Fixed references to Image::clip\_mask.
+    Implemented SVG masks.
+
+  - coders/svg.c (SVGStartElement, SVGEndElement): Implemented
+    SVG masks.
+
+  - locale/c.mgk, magick/gm\_messages.mc, magick/local\_c.h:
+    Added new error codes to support SVG masks.
+
+  - coders/ps3.c, magick/enhance.c: Fixed references to
+    Image::clip\_mask.
+
+  - magick/draw.c, wand/drawing\_wand.c: Fixed references to
+    DrawInfo::clip\_path.
+
+2018-04-13  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/wpg.c Crash on row overflow fixed oss-fuzz 7639 thanks to oss-fuzz.
+
+2018-04-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dpx.c (ReadDPXImage): Add more header validations.
+    Always assure that scanline is initialized for Luma channel. Fixes
+    oss-fuzz 7544 "graphicsmagick/coder\_DPX\_fuzzer:
+    Use-of-uninitialized-value in WriteDPXImage". (Credit to OSS-Fuzz)
+
+  - coders/pdb.c (ReadPDBImage): Add more EOF checks to avoid benign
+    use of uninitialized data.  Fixes oss-fuzz 7545
+    "graphicsmagick/coder\_PDB\_fuzzer: Use-of-uninitialized-value in
+    ReadPDBImage".
+
+  - coders/wpg.c (InsertRow, UnpackWPGRaster): x & y should be
+    'unsigned long' to match type used by pixel cache APIs and image
+    rows/columns.
+
+2018-04-08  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/wpg.c Stop reading when last row is reached.
+    This should stop oss-fuzz 7528 thanks to oss-fuzz.
+
+
+2018-04-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/xcf.c (ReadXCFImage): Fix use of uninitialized data in
+    magick header string for runt file.  Fixes oss-fuzz 7521
+    "graphicsmagick/coder\_XCF\_fuzzer: Use-of-uninitialized-value in
+    LocaleNCompare". (Credit to OSS-Fuzz).
+
+2018-04-09  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - OVERVIEW: Change set 9aaeeca0224c modified the drawing
+    of clipping paths to conform to the SVG spec.  This change
+    set restores the previous behavior for non-SVG clients of
+    render.c, while still satisfying the SVG spec for SVG clients.
+
+  - magick/render.h (DrawInfo): Added a bit field in member
+    "flags" to indicate that drawing should be SVG compliant.
+
+  - magick/render.c (DrawImage): Now recognizes keyword
+    "svg-compliant", and tags DrawInfo accordingly.  This
+    allows for existing features in render.c to be changed
+    to comply with the SVG spec without impacting the previous
+    behavior expected by non-SVG clients.
+
+  - magick/render.c (DrawImage): Now uses DrawInfo "flags"
+    bit for SVG compliance in conjunction with "flags" bit
+    for "clipping path" to determine when to ignore changes
+    to fill color, stroke color, etc.  This restores the
+    previous behavior for clipping paths for non-SVG clients.
+
+  - coders/svg.c (SVGStartElement): The initial set of
+    MVG commands for rendering an SVG file now includes
+    new keyword "svg-compliant" (to indicate that certain
+    graphical elements should be drawn according to the
+    SVG spec), and includes an intialization of the SVG
+    "fill-rule" to "nonzero" (the SVG default) instead of
+    the internally initialized value of "evenodd".
+
+  - coders/wpg.c: Fixed C99 "//" comments.
+
+2018-04-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pict.c (ReadPICTImage): Copy tile exception info to main
+    image and don't composite tile if it has a problem.  Fixes
+    oss-fuzz 7169 "graphicsmagick/enhance\_fuzzer:
+    Use-of-uninitialized-value in EnhanceImage". (Credit to OSS-Fuzz)
+
+  - coders/dib.c (ReadDIBImage): Do not increase decode bits/pixel
+    if compression=2, but use it to increase pixel packet size when
+    estimating bytes per line for decode buffer.  Fixes oss-fuzz issue
+    7324 "graphicsmagick/coder\_WPG\_fuzzer: Use-of-uninitialized-value
+    in ReadDIBImage". (Credit to OSS-Fuzz)
+
+  - coders/dpx.c (ReadDPXImage): When handling the first element of
+    a planar DPX, assure that the other channels are
+    initialized. Fixes oss-fuzz 7841 "graphicsmagick/coder\_DPX\_fuzzer:
+    Use-of-uninitialized-value in WriteDPXImage". (Credit to OSS-Fuzz)
+
+  - coders/tim.c (ReadTIMImage): Only 4 and 8 bit TIM requires a
+    colormap. For other depths, force reading as DirectClass even if
+    the TIM file provides a colormap.  Fixes oss-fuzz 7407
+    "graphicsmagick/coder\_TIM\_fuzzer: Use-of-uninitialized-value in
+    SyncImageCallBack". (Credit to OSS-Fuzz)
+
+2018-04-08  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c The unread data contains crap in memory,
+    erase current image data. This should mute oss-fuzz 6604.
+
+  - coders/wpg.c - condition "if(y<1) continue;" is redundant
+    and could be removed completely.
+    Allow logging in MatlabV4 module.
+
+  - coders/svg.c - Do not use C++ syntax in C code - removed.
+
+2018-04-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/wpg.c (UnpackWPGRaster): Fix uninitialized row 0 when
+    row-based RLE is used.  Fixes oss-fuzz 6603
+    "graphicsmagick/enhance\_fuzzer: Use-of-uninitialized-value in
+    BlendCompositePixel". (Credit to OSS-Fuzz)
+
+  - coders/pcd.c: Fix many issues, including oss-fuzz 6016
+    "graphicsmagick/coder\_PCD\_fuzzer: Heap-double-free in
+    MagickRealloc" and oss-fuzz 6108 "graphicsmagick/coder\_PCD\_fuzzer:
+    Unknown signal in AllocateThreadViewDataSet". (Credit to OSS-Fuzz)
+
+2018-04-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dcm.c (funcDCM\_BitsStored): Limit DICOM significant bits
+    to 16.  Otherwise rescale map code blows up.  Fixes oss-fuzz 7435
+    "graphicsmagick/coder\_DCM\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_DCM\_fuzzer". (Credit to OSS-Fuzz)
+
+  - coders/pix.c (ReadPIXImage): Detect EOF.  Reject RLE lenth of
+    zero.  Fixes oss-fuzz 7440 "graphicsmagick/coder\_PIX\_fuzzer:
+    Out-of-memory in graphicsmagick\_coder\_PIX\_fuzzer". (Credit to
+    OSS-Fuzz)
+
+2018-04-05  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dpx.c (ReadDPXImage): Insist on having an element
+    descriptor we understand since otherwise we can not decode the
+    image.  Fixes oss-fuzz 7410 "graphicsmagick/coder\_DPX\_fuzzer:
+    Use-of-uninitialized-value in WriteDPXImage". (Credit to OSS-Fuzz)
+
+  - coders/avs.c, etc... (WriteAVSImage): Cache image list length
+    before writing image sequence so that progress monitor is
+    scalable.  Helps with oss-fuzz 7404
+    "graphicsmagick/coder\_AVS\_fuzzer: Timeout in
+    graphicsmagick\_coder\_AVS\_fuzzer". (Credit to OSS-Fuzz)
+
+2018-04-05  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - coders/svg.c (SVGStartElement, SVGEndElement),
+    magick/render.c (DrawImage): The current text position
+    is now maintained by DrawImage() instead of by
+    SVGStartElement() and SVGEndElement().  This change was
+    made to support the recently implmemented "use" and
+    "class" elements, which may make changes to the font
+    size that are not visible to the code in svg.c.
+
+  - coders/svg.c (GetStyleTokens, SVGStartElement): The
+    list of SVG attributes is now reordered so that
+    "font-size", "class", and "style" are processed first.
+    This ensures that a change to the font size will be
+    processed before any dimensional attribute whose value
+    may depend on the font size (e.g., a width value
+    specified in "em" units).
+
+  - coders/svg.c (ProcessStyleClassDefs): Fixed two memory
+    leaks associated with making an early return when
+    malformed input is detected.
+
+  - magick/render.c (ExtractTokensBetweenPushPop): Fixed
+    an uninitialized variable condition which can occur when
+    malformed input is detected.
+
+  - magick/render.h (DrawInfo), magick/render.c: DrawInfo
+    member "unused1" has been renamed "flags".  It is now
+    used to tag a DrawInfo as being a clipping path or a
+    compositing mask.
+
+2018-04-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pdb.c (ReadPDBImage): Update DirectClass pixels to avoid
+    use of uninitialized memory for 2 bits/pixel.  Fixes oss-fuzz 7350
+    "graphicsmagick/coder\_PDB\_fuzzer: Use-of-uninitialized-value in
+    WritePDBImage".  (Credit to OSS-Fuzz)
+
+  - coders/palm.c (ReadPALMImage): Fix use of uninitialized memory.
+    Fixes oss-fuzz 7325 "graphicsmagick/coder\_PALM\_fuzzer:
+    Use-of-uninitialized-value in TransparentImageCallBack". (Credit
+    to OSS-Fuzz)
+
+  - coders/dcm.c (DCM\_ReadNonNativeImages): Break out of reading
+    loop on EOF and properly report exception.  Fixes oss-fuzz 7349
+    "graphicsmagick/coder\_DCM\_fuzzer: Timeout in
+    graphicsmagick\_coder\_DCM\_fuzzer". (Credit to OSS-Fuzz)
+
+2018-04-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/xcf.c (ReadXCFImage): Require that XCF file offsets be in
+    ascending order to avoid DOS.  Fixes oss-fuzz 7333
+    "graphicsmagick/coder\_XCF\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_XCF\_fuzzer". (Credit to OSS-Fuzz)
+
+  - coders/wpg.c (UnpackWPGRaster): Fix memory leak in error return
+    path. Fixes oss-fuzz 7338 "graphicsmagick/enhance\_fuzzer:
+    Direct-leak in UnpackWPGRaster". (Credit to OSS-Fuzz)
+
+2018-04-03  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - coders/svg.c (SVGStartElement): This changeset adds
+    support for SVG geometric transforms specified using the
+    style="transform: ..." syntax.  This syntax is sometimes
+    used when exporting SVG files from Adobe Illustrator.
+
+2018-04-02  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dpx.c (ReadDPXImage): Validate DPX packing method.  Fixes
+    oss-fuzz 7296 "graphicsmagick/coder\_DPX\_fuzzer:
+    Use-of-uninitialized-value in WriteDPXImage". (Credit to OSS-Fuzz)
+
+2018-04-02  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - coders/svg.c (SVGStartElement, SVGEndElement),
+    magick/render.c (DrawImage): This changeset adds support for
+    "class" styling attributes within a <style> section within
+    the <defs> section, and the ability to reference them from
+    other SVG elements by class="classname".  SVG files exported
+    from Adobe Illustrator make extensive use of "class" definitions.
+
+2018-04-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pict.c (ReadPICTImage): Fix leak of tile image on EOF.
+    This is a recent regression.  Fixes oss-fuzz 7287
+    "graphicsmagick/coder\_PCT\_fuzzer: Indirect-leak in
+    CloneImage". (Credit to OSS-Fuzz)
+
+  - magick/pixel\_cache.c (OpenCache): Use image->scene rather than
+    GetImageIndexInList(image) for scene-id part of cache info file
+    name.
+
+  - coders/txt.c (WriteTXTImage): Optimize the progress indicator
+    since it is very inefficient with a large number of scenes and
+    oss-fuzz 7090 "graphicsmagick/coder\_TEXT\_fuzzer: Timeout in
+    graphicsmagick\_coder\_TEXT\_fuzzer" consistently shows
+    GetImageListLength() in its stack traces.
+
+  - coders/dcm.c (ReadDCMImage): DICOM reader was no longer
+    immediately quitting with excessive samples per pixel.  This
+    caused spinning for a very long time when reading planar images
+    with large samples per pixel.  This is a regression due to recent
+    changes.  Fixes oss-fuzz 7269 "graphicsmagick/coder\_DCM\_fuzzer:
+    Timeout in graphicsmagick\_coder\_DCM\_fuzzer". (Credit to OSS-Fuzz)
+
+  - coders/xcf.c (ReadXCFImage): Destroy layer info before returning
+    due to exception.  This is a new regression due to adding more
+    checks. Fixes oss-fuzz 7277 "graphicsmagick/coder\_XCF\_fuzzer:
+    Direct-leak in ReadXCFImage". (Credit to OSS-Fuzz)
+
+  - coders/pdb.c (ReadPDBImage): Assure that all bytes of scanline
+    are initialized while decoding.  Fixes oss-fuzz 7051
+    "graphicsmagick/coder\_PDB\_fuzzer: Use-of-uninitialized-value in
+    WritePDBImage". (Credit to OSS-Fuzz)
+
+2018-03-31  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pcx.c (ReadPCXImage): Assure that scanline is
+    initialized.  Fixes oss-fuzz 6612
+    "graphicsmagick/coder\_PCX\_fuzzer: Use-of-uninitialized-value in
+    WriteRLEPixels". (Credit to OSS-Fuzz)
+
+  - coders/wpg.c (ReadWPGImage): Detect unexpected EOF and avoid use
+    of uninitialized data.  Fixes oss-fuzz 6601
+    "graphicsmagick/enhance\_fuzzer: Use-of-uninitialized-value in
+    ImportIndexQuantumType". (Credit to OSS-Fuzz)
+
+  - coders/sgi.c (ReadSGIImage): Assure that RLE decode buffer is
+    initialized.  Fixes oss-fuzz 6599
+    "graphicsmagick/coder\_SGI\_fuzzer: Use-of-uninitialized-value in
+    SyncImageCallBack" and oss-fuzz 6600
+    "graphicsmagick/coder\_SGI\_fuzzer: Use-of-uninitialized-value in
+    SGIEncode". (Credit to OSS-Fuzz)
+
+  - coders/viff.c (ReadVIFFImage): Fix blob I/O size validation to
+    avoid use of uninitialized data. Fixes oss-fuzz 6597
+    "graphicsmagick/coder\_VIFF\_fuzzer: Use-of-uninitialized-value in
+    ThresholdImage". (Credit to OSS-Fuzz)
+    (ReadVIFFImage): Don't execute SetImageType(image,BilevelType) on
+    an image which has no pixels yet in order to avoid use of
+    uninitialized data. Fixes oss-fuzz 6597.  (Credit to OSS-Fuzz)
+
+  - coders/wbmp.c (ReadWBMPImage): Fix blob I/O size validation to
+    avoid use of uninitialized data. Fixes oss-fuzz 7047
+    "graphicsmagick/coder\_WBMP\_fuzzer: Use-of-uninitialized-value in
+    ReadWBMPImage". (Credit to OSS-Fuzz)
+
+  - coders/wpg.c (ExtractPostscript): Allow non-Postscript content
+    but force reading using the magick we already detected.  Also log
+    the format that we detected.
+
+  - coders/xcf.c (ReadOneLayer): Reject layer size of 0x0.  Fixes
+    oss-fuzz 6636 "graphicsmagick/coder\_XCF\_fuzzer: Direct-leak in
+    MagickMallocAligned". (Credit to OSS-Fuzz)
+    (ReadXCFImage): Verify that seek offsets are within the bounds of
+    the file data. Fixes oss-fuzz 6682
+    "graphicsmagick/coder\_XCF\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_XCF\_fuzzer". (Credit to OSS-Fuzz)
+
+  - magick/pixel\_cache.c (ModifyCache): Destroy CacheInfo if
+    OpenCache() fails so it is not leaked.
+
+  - coders/wpg.c (ExtractPostscript): Enforce that embedded file is
+    a Postscript file.  Fixes oss-fuzz 7235
+    "graphicsmagick/coder\_WPG\_fuzzer: Indirect-leak in MagickRealloc".
+    This is indicated to be a regression. (Credit to OSS-Fuzz)
+
+2018-03-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pict.c (ReadPICTImage): Check image pixel limits before
+    allocating memory for tile.  Fixes oss-fuzz 7217
+    "graphicsmagick/coder\_PICT\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_PICT\_fuzzer".
+
+2018-03-29  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pcd.c (ReadPCDImage): Add checks for EOF. Fixes oss-fuzz
+    issue 7180 "graphicsmagick/coder\_PCDS\_fuzzer: Timeout in
+    graphicsmagick\_coder\_PCDS\_fuzzer".  (Credit to OSS-Fuzz)
+
+2018-03-29  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - coders/svg.c (SVGStartElement, SVGEndElement),
+    magick/render.c (DrawImage): This changeset implements the SVG
+    "use" element.  Graphical elements (e.g., "rect", "text", etc.)
+    can be tagged with an identifier using 'id="identifier"' when
+    defined within the "defs" section.  They can then be referenced
+    elsewhere in the SVG file using:
+
+    <use xlink:href="#identifier" ... />
+
+    When referencing a graphical element by its identifier, the
+    following syntaxes are now treated as being the same:
+
+    href="#identifier"
+    href="url(#identifier)"
+    xlink:href="#identifier"
+    xlink:href="url(#identifier)"
+
+2018-03-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/tim.c (ReadTIMImage): Reader was not observing subimage
+    and subrange to quit after the specified frame range.  Inspired by
+    oss-fuzz 7132 "graphicsmagick/coder\_TIM\_fuzzer: Timeout in
+    graphicsmagick\_coder\_TIM\_fuzzer" (Credit to OSS-Fuzz)
+
+2018-03-27  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - coders/svg.c (SVGStartElement): Enable setting the
+    background color from the SVG file when the client
+    specifies style="background:color" inside the <svg>
+    ... </svg> element.
+
+2018-03-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/mtv.c (ReadMTVImage): Add some elementary tracing to MTV
+    reader.
+
+  - coders/png.c (ReadMNGImage): Fix SourceForge issue 554
+    "Divide-by-zero in ReadMNGImage (coders/png.c)".  (Credit to Trace
+    Probe)
+
+  - coders/bmp.c (ReadBMPImage): Assure that start position always
+    advances to avoid looping BMPs.  Fixes oss-fuzz 7045
+    "graphicsmagick/coder\_BMP\_fuzzer: Timeout in
+    graphicsmagick\_coder\_BMP\_fuzzer". (Credit to OSS-Fuzz)
+
+  - coders/pict.c (DecodeImage): Verify that sufficient backing data
+    exists before allocating memory to read it.  Fixes oss-fuzz 6629
+    "graphicsmagick/coder\_PCT\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_PCT\_fuzzer".
+    (ReadPICTImage): Destroy tile\_image in ThrowPICTReaderException()
+    macro to simplify logic.
+
+2018-03-25  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c Check whether datablock is really read.
+    Fixes oss-fuzz 7056 (Credit to OSS-Fuzz)
+
+  - coders/txt.c Duplicate image check for data with fixed geometry
+    previous check is skipped. Fixes oss-fuzz 7090.
+
+2018-03-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dcm.c (ReadDCMImage): Validate that samples per pixel is
+    in valid range.  Fixes oss-fuzz 6260
+    "graphicsmagick/coder\_DCM\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_DCM\_fuzzer". (Credit to OSS-Fuzz)
+
+  - coders/meta.c (format8BIM): Allocate space for null termination
+    and null terminate string.  Fixes oss-fuzz 5985
+    "graphicsmagick/coder\_8BIMTEXT\_fuzzer: Heap-buffer-overflow in
+    formatIPTCfromBuffer". (Credit to OSS-Fuzz)
+
+  - coders/fits.c (ReadFITSImage): Include number of FITS scenes in
+    file size validations.  Fixes oss-fuzz 6781
+    "graphicsmagick/coder\_FITS\_fuzzer: Timeout in
+    graphicsmagick\_coder\_FITS\_fuzzer". (Credit to OSS-Fuzz)
+
+2018-03-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/meta.c (format8BIM): Validate size request prior to
+    allocation. Fixes oss-fuzz issue 5974
+    "graphicsmagick/coder\_8BIMTEXT\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_8BIMTEXT\_fuzzer". (Credit to OSS-Fuzz)
+
+2018-03-23  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c Fix forged amount of frames 7076. (Credit to OSS-Fuzz)
+
+        \* coders/topol.c Check for forged image that overflows file size
+        (fuzz 6836).
+
+2018-03-23  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c, render.h (DrawInfo, CloneDrawInfo,
+    DrawClipPath, DrawImage, GetDrawInfo): According to the SVG
+    spec, a clipping path is defined only by the geometry of its
+    constituent elements, and is not dependent on fill color/opacity,
+    stroke color/opacity, or stroke width.  To ensure conformity
+    with the spec, when a clipping path is created, these SVG
+    elements are set to appropriate values, and any attempt to
+    modify them is ignored.
+
+    Also, whenever a clipping path is drawn, the associated image
+    attributes are now updated from the parent image structure.
+    This ensures that any added or modified attributes are up to
+    date.
+
+2018-03-22  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/topol.c Use rather MagickSwabArrayOfUInt32() to
+        flip all array elements at once.
+
+        \* magick/annotate.c Compilation issue - using C++ syntax in C code.
+
+2018-03-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dpx.c (ReadDPXImage): Validate header length and offset
+    properties.  Fixes oss-fuzz "graphicsmagick/coder\_DPX\_fuzzer:
+    Use-of-uninitialized-value in WriteDPXImage". (Credit to OSS-Fuzz)
+
+2018-03-20  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/annotate.c (RenderType): According to the SVG
+    spec, the 'font-family' element can be a comma-separated
+    list of one or more font family names.  Function RenderType
+    in file annotate.c has been modified to support multiple
+    font family names as follows.  The comma-separated list is
+    processed until the first available font family is found.
+    If no font family is found, or if font substitution occurred,
+    then the entire font family string is tested to see if it
+    exactly matches a font name, or if the font family string
+    with blanks changed to hypens exactly matches a font name.
+    If a font name match is found, the matched font overrides
+    the font substution.  The font name matching functionality
+    is beyond what's in the SVG spec and is provided as a
+    convenience to the user.
+
+2018-03-20  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c Fix forged amount of frames 6755. (Credit to OSS-Fuzz)
+
+2018-03-20  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/topol.c Redesign ReadBlobDwordLSB() to be more effective.
+
+2018-03-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/xpm.c (ReadXPMImage): Reject XPM if its condensed version
+    contains non-whitespace control characters.  Fixes oss-fuzz 7027
+    "graphicsmagick/coder\_XPM\_fuzzer: Timeout in
+    graphicsmagick\_coder\_XPM\_fuzzer". (Credit to OSS-Fuzz)
+
+2018-03-19  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/topol.c Fix tile index overflow fuzz 6634. (Credit to OSS-Fuzz)
+
+2018-03-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dcm.c (DCM\_ReadGrayscaleImage): Don't use rescale map if
+    it was not allocated.  This issue was induced in this development
+    cycle due to disabling generating the rescale map.  Fixes oss-fuzz
+    7021 "graphicsmagick/coder\_DCM\_fuzzer: Null-dereference READ in
+    DCM\_ReadGrayscaleImage". (Credit to OSS-Fuzz)
+
+2018-03-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/color\_lookup.c (QueryColorDatabase): Defend against
+    partial scanf() expression matching, resulting in use of
+    uninitialized data.  Likely fixes oss-fuzz 6596
+    "graphicsmagick/coder\_XPM\_fuzzer: Use-of-uninitialized-value in
+    IsMonochromeImage". (Credit to OSS-Fuzz)
+
+  - coders/rle.c (ReadRLEImage): Validate number of colormap bits to
+    avoid undefined shift behavior.  Fixes oss-fuzz 6630
+    "graphicsmagick/enhance\_fuzzer: Undefined-shift in
+    ReadRLEImage". (Credit to OSS-Fuzz)
+
+  - coders/dcm.c (DCM\_ReadRGBImage): Don't use rescale map if it was
+    not allocated.  This issue was induced in this development cycle
+    due to disabling generating the rescale map.  Fixes oss-fuzz 6995
+    "graphicsmagick/coder\_DCM\_fuzzer: Null-dereference READ in
+    DCM\_ReadRGBImage". (Credit to OSS-Fuzz)
+
+  - coders/dib.c (DecodeImage): Report failure to decode to expected
+    amount of pixel data as an error.  Fixes oss-fuzz 7007
+    "graphicsmagick/enhance\_fuzzer: Use-of-uninitialized-value in
+    EnhanceImage". (Credit to OSS-Fuzz)
+
+  - coders/bmp.c (ReadBMPImage): Add file size and offset/seek
+    validations.  Fixes oss-fuzz 6623
+    "graphicsmagick/coder\_BMP\_fuzzer: Timeout in
+    graphicsmagick\_coder\_BMP\_fuzzer". (Credit to OSS-Fuzz)
+
+2018-03-17  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - dcraw/dcraw.c Updated to version 9.27
+
+2018-03-15  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/gif.c (ReadGIFImage): Fix botched fixes for use of
+    uninitialized data when reading GIF extension blocks.  Hopefully
+    ok now.
+
+2018-03-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/gif.c (ReadGIFImage): Fix use of uninitialized data when
+    reading GIF extension blocks.  Fixes oss-fuzz 6609
+    "graphicsmagick/coder\_GIF\_fuzzer: Use-of-uninitialized-value in
+    MagickArraySize". This seems to be a totally benign issue. (Credit
+    to OSS-Fuzz)
+
+  - magick/magick.c (MagickSignal): Use an alternate signal stack,
+    if available.  This is required for Go lang C language extensions
+    since Go lang requests an alternate signal sack, and uses small
+    stacks for its threads.  If the library user has not allocated an
+    alternate signal stack, then behavior should be just as before.
+    Issue was originally reported by yzh杨振宏 on March 1, 2018 via
+    the graphicsmagick-help SourceForge mailing list.
+
+2018-02-28  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/pixel\_cache.c (AcquireCacheNexus): Add a check that the
+    pixel cache is compatible with the image dimensions.  Fixes
+    oss-fuzz issues 5978 5988 5989 5990 5993 6016, and 6056, which are
+    all related to the PICT writer. (Credit to OSS-Fuzz)
+
+  - magick/draw.c (DrawGetStrokeDashArray): Check for failure to
+    allocate memory.  Patch submited by Petr Gajdos via email on
+    February 28, 2018.
+
+2018-02-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/fits.c (ReadFITSImage): Fix signed integer overflow when
+    computing pixels size.  Fixes oss-fuzz 6586
+    "graphicsmagick/coder\_FITS\_fuzzer: Integer-overflow in
+    ReadFITSImage". (Credit to OSS-Fuzz)
+
+2018-02-27  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - coders/svg.c (SVGStartElement, SVGEndElement): From the
+    SVG spec:  "The 'foreignObject' element allows for inclusion
+    of a foreign namespace which has its graphical content drawn
+    by a different user agent."  Code has been added to consume
+    and discard the 'foreignObject' element and any settings (e.g.,
+    fill color) internal to it.  Previously, settings internal
+    to the 'foreignObject' element would persist and "leak" into
+    the graphic elements that followed it, resulting in undesired
+    side effects (e.g., fill color other than the expected default).
+
+2018-02-27  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (DrawPolygonPrimitive): Fixed a bug
+    introduced by changeset 39102dd1d456.  For SVG, this
+    changeset applied both the group AND the fill opacity
+    values to fill patterns (similarly for stroke).  For WMF,
+    however, this caused the fill pattern to be rendered as
+    100% transparent.  A closer reading of the SVG spec does
+    NOT show that the fill opacity should be applied to the
+    fill pattern, so as of this latest changeset only the group
+    opacity value is applied to fill and stroke patterns.
+
+2018-02-27  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/bmp.c (ReadBMPImage): Fix divide by zero regression added
+    by latest fixes.  Fixes oss-fuzz 6583
+    "graphicsmagick/coder\_BMP\_fuzzer: Divide-by-zero in ReadBMPImage".
+    (Credit to OSS-Fuzz)
+
+2018-02-26  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pict.c (ReadPICTImage): Validate that PICT rectangles do
+    not have zero dimensions.  Specify expected file type when reading
+    from a temporary file.  Trace PICT rectangle dimensions.  More
+    detection of blob EOF and more error handling.  Fixes oss-fuzz
+    issue 6193 "graphicsmagick/coder\_PCT\_fuzzer: Unknown signal in
+    AllocateImageColormap" and likely many oss-fuzz ASAN/UBSAN issues
+    reported against "PCT" and "PICT" since this one problem appears
+    to be causing a spew of reports.
+
+  - coders/png.c (ReadMNGImage): Detect and handle failure to
+    allocate global PLTE.  Problem was reported via email from Petr
+    Gajdos on February 26, 2018.
+
+2018-02-25  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/blob.c (ReadBlobLSBDouble): Make sure imported double is
+    a normal value.
+    (ReadBlobLSBDoubles): Make sure imported doubles are normal
+    values.
+    (ReadBlobLSBFloat): Make sure imported float is a normal value.
+    (ReadBlobLSBFloats): Make sure imported floats are normal values.
+    (ReadBlobMSBFloat): Make sure imported float is a normal value.
+    (ReadBlobMSBFloats): Make sure imported floats are normal values.
+    (ReadBlobMSBDouble): Make sure imported double is a normal value.
+    (ReadBlobMSBDoubles): Make sure imported doubles are normal
+    values.
+
+  - magick/import.c (ImportFloat32Quantum): Make sure imported float
+    is a normal value.
+    (ImportFloat64Quantum): Make sure imported double is a normal
+    value.
+
+  - magick/image.h (RoundDoubleToQuantum): Restore previous behavior
+    (from earlier today).
+    (RoundFloatToQuantum): Restore previous behavior (from earlier
+    today).
+
+  - coders/bmp.c (ReadBMPImage): Fix UBSAN runtime error: left shift
+    of 205 by 24 places cannot be represented in type 'int'.
+
+  - coders/ept.c (ReadEPTImage): Fix dereference of NULL pointer
+    which was detected by UBSAN in the test suite.
+
+  - magick/image.h (RoundDoubleToQuantum): Check double value for
+    NaN and infinity in order to avoid undefined behavior.
+    (RoundFloatToQuantum): Check float value for NaN and infinity in
+    order to avoid undefined behavior.
+
+  - magick/common.h (MAGICK\_ISNAN): Add a isnan() wrapper macro.
+    (MAGICK\_ISINF): Add a isinf() wrapper macro.
+
+2018-02-25  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c Fix oss-fuzz issue 6273 - Heap-use-after-free in
+    GetLocaleExceptionMessage. (Credit to OSS-Fuzz)
+
+2018-02-24  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dcm.c (DCM\_PostRescaleImage): Remove use of
+    DCM\_PostRescaleImage() since its implementation is wrong and
+    accesses non-allocated heap memory.  Problem was reported by Petr
+    Gajdos via email on February 8, 2018.
+
+  - coders/jp2.c (ReadJP2Image): Use a ThrowJP2ReaderException macro
+    to automatically clean up when throwing an exception.
+
+  - coders/bmp.c (ReadBMPImage): Report an error if RLE decode does
+    not produce the expected number of bytes.  Fixes oss-fuzz issue
+    6015 "graphicsmagick/coder\_BMP\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_BMP\_fuzzer". (Credit to OSS-Fuzz)
+
+2018-02-23  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (DrawImage): Fixed a bug in which graphical
+    elements defined within <defs> ... </defs> were being rendered,
+    contrary to the SVG spec.
+
+2018-02-23  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (DrawPolygonPrimitive): When filling or
+    stroking a polygon using a pattern, the fill (or stroke)
+    and group/object opacity values were not being applied to
+    the pattern (fixed).
+
+2018-02-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/bmp.c (ReadBMPImage): Fix SeekBlob() return value checks.
+    Add more EOF checks.  Require that a provided ba\_offset be a
+    forward seek in order to avoid the possibility of endless looping.
+
+2018-02-23  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c Fix oss-fuzz issue 6301. (Credit to OSS-Fuzz)
+
+2018-02-22  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/alpha\_composite.c (BlendQuantumOpacity): The
+    pixel compositing equation used when compositing an
+    image into the output was incorrect and has been fixed.
+
+  - magick/render.c (DrawPolygonPrimitive): When
+    compositing polygon edge pixels over a transparent
+    black background, the code would composite as if the
+    background were opaque black, resulting in the edge
+    pixels being too dark (fixed).
+
+2018-02-21  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (DrawImage): Per the SVG spec, opacity,
+    fill-opacity, and stroke-opacity values are now clamped
+    to [0,1].
+
+    Also fixed two bugs introduced by changeset 91de8039f27d
+    (dated 2018-02-12): (1) a group/object opacity value
+    specified using a percentage was not being converted to a
+    value in [0,1]; (2) if fill-opacity or stroke-opacity was
+    1, and the group/object opacity value was set to 1, the
+    resulting fill-opacity or stroke-opacity value would be
+    set to 0 instead of 1.
+    
+2018-02-19  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/viff.c (ReadVIFFImage): Fix excessive memory usage.
+    Fixes oss-fuzz 6006 "graphicsmagick/coder\_XV\_fuzzer: Out-of-memory
+    in graphicsmagick\_coder\_XV\_fuzzer". (Credit to OSS-Fuzz)
+
+  - coders/txt.c (ReadInt): Avoid benign signed integer overflow due
+    to accepting an arbitrary number of digits.  Fixes oss-fuzz 6002
+    "graphicsmagick/coder\_TEXT\_fuzzer: Integer-overflow in
+    ReadInt". (Credit to OSS-Fuzz)
+
+  - coders/viff.c (ReadVIFFImage): Verify that there is sufficient
+    data to back up colormap allocation request.  Fixes oss-fuzz 5986
+    "graphicsmagick/coder\_VIFF\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_VIFF\_fuzzer". (Credit to OSS-Fuzz)
+
+  - magick/memory.c: Define MAGICK\_MEMORY\_HARD\_LIMIT=value to abort
+    when memory request exceeds value.  Useful to find location of
+    excessive memory requests.
+
+2018-02-19  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - coders/svg.c (SVGStartElement): Per the SVG spec, the
+    SVG coder now initializes the MVG coder (which renders
+    SVG graphical elements) with the the SVG defaults for
+    fill color, fill-opacity, stroke color, stroke-opacity,
+    and stroke-width.  This makes the SVG coder independent
+    of the MVG coder intial state.
+
+2018-02-19  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - coders/svg.c (SVGStartElement): Fixed initialization of
+    x and y attributes per the SVG spec:  for graphical elements
+    "image", "pattern", "text", "rect", and "use", if the x or y
+    attribute is not specified, the effect is as if a value of
+    "0" were specified.
+
+2018-02-18  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/sun.c (ReadSUNImage): Fix edge case which broke file-size
+    validation logic.  Fixes oss-fuzz issue 5981
+    "graphicsmagick/coder\_SUN\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_SUN\_fuzzer". (Credit to OSS-Fuzz)
+
+  - coders/txt.c (ReadTXTImage): Validate that file size is
+    sufficient for claimed image properties.  Fixes oss-fuzz issue
+    5960 "graphicsmagick/coder\_TXT\_fuzzer: Out-of-memory in
+    graphicsmagick\_coder\_TXT\_fuzzer". (Credit to OSS-Fuzz)
+
+  - coders/tga.c (ReadTGAImage): Only allow 1 and 8 bit
+    colormapped/grey images. Fixes oss-fuzz issue 6314
+    "graphicsmagick/coder\_ICB\_fuzzer: Undefined-shift in
+    ReadTGAImage". (Credit to OSS-Fuzz)
+
+  - coders/bmp.c (ReadBMPImage): Detect and report when BMP height
+    value is out of range (too negative). Fixes oss-fuzz issue 6394
+    "graphicsmagick/coder\_BMP\_fuzzer: Integer-overflow in
+    ReadBMPImage". (Credit to OSS-Fuzz)
+
+  - coders/rla.c (ReadRLAImage): Detect when RLE decoding is
+    producing too many samples and report as an error.  Fixes oss-fuzz
+    issue 6312 "graphicsmagick/coder\_RLA\_fuzzer: Timeout in
+    graphicsmagick\_coder\_RLA\_fuzzer". (Credit to OSS-Fuzz)
+
+  - coders/fits.c (ReadFITSImage): Validate that file size is
+    sufficient for claimed image properties.  Fixes oss-fuzz issue
+    6429 "graphicsmagick/coder\_FITS\_fuzzer: Timeout in
+    graphicsmagick\_coder\_FITS\_fuzzer". (Credit to OSS-Fuzz)
+
+  - magick/image.c (CloneImage): Check image pixel limits in
+    CloneImage() when it is used to change the image dimensions.  This
+    avoids depending on the using code to detect and report such
+    issues.
+
+  - coders/xcf.c (ReadXCFImage): Check image pixel limits after each
+    CloneImage() to assure that image is within specified resource
+    limits.  Fixes oss-fuzz issue 6399 "graphicsmagick/enhance\_fuzzer:
+    Timeout in graphicsmagick\_enhance\_fuzzer". (Credit to OSS-Fuzz)
+
+2018-02-16  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (TracePath): TracePath() was not
+    correctly processing multiple sets of cubic or quadratic
+    Bezier coordinates when the previous path data command was
+    not a cubic or quadratic Bezier command.  This would result
+    in the first control point being equal to the current path
+    point instead of being computed using the current path
+    point and the second control point of the previous Bezier
+    command.
+
+2018-02-15  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (TracePath): TracePath() was not
+    consuming commas (if present) at the end of a set of
+    points when multiple sets of points were specified for
+    various path commands (e.g., line, Bezier). This
+    resulted in the remaining sets of points being ignored
+    (fixed).
+
+2018-02-15  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (TraceArcPath): No points are generated
+    by TraceArcPath() if the starting and ending arc points
+    are the same.  For this case, the coordinate count was not
+    being set to zero before returning (fixed).
+
+2018-02-15  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (DrawImage): Clipping of polygons in
+    DrawImage() would sometime result in a starting pixel
+    location that was greater than the ending pixel location,
+    causing a subsequent call to GetImagePixelsEx() to fail
+    due a column count <= 0.  Modified the clipping code to
+    eliminate this condition, and also to return early if
+    the polygon lies completely outside the image boundaries.
+    Also fixed variable declarations from a previous commit
+    that were causing problems for the C89 compiler.
+
+2018-02-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/topol.c (ReadTOPOLImage): Detect EOF immediately rather
+    than spinning.  Fixes oss-fuzz issue 6303
+    "graphicsmagick/coder\_TOPOL\_fuzzer: Timeout in
+    graphicsmagick\_coder\_TOPOL\_fuzzer". (Credit to OSS-Fuzz)
+
+  - coders/dcm.c (DCM\_SetupRescaleMap): Avoid excessive left shift.
+    Fixes oss-fuzz issue 6256 "graphicsmagick/coder\_DCM\_fuzzer:
+    Undefined-shift in DCM\_SetupRescaleMap". (Credit to OSS-Fuzz)
+
+2018-02-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/wpg.c (ExtractPostscript): Detect EOF on input while
+    transferring bytes to Postscript file.  Fixes oss-fuzz issue 6087
+    "graphicsmagick/coder\_WPG\_fuzzer: NULL".  Later identified to be
+    CVE-2017-17682 as previously discovered in ImageMagick.  (Credit to
+    OSS-Fuzz)
+
+  - coders/pdb.c (ReadPDBImage): Quit attempting to read image data
+    immediately at EOF. Fixes oss-fuzz issue 6252
+    "graphicsmagick/coder\_PDB\_fuzzer: Timeout in
+    graphicsmagick\_coder\_PDB\_fuzzer".  (Credit to OSS-Fuzz)
+
+2018-02-12  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/topol.c (ReadTOPOLImage): Avoid index out of bounds when
+    input filename does not use a file extension. Fixes oss-fuzz issue
+    6237 "graphicsmagick/coder\_TOPOL\_fuzzer: Index-out-of-bounds in
+    ReadTOPOLImage".  (Credit to OSS-Fuzz)
+
+2018-02-12  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (DrawImage): Object/group opacity,
+    when set in DrawImage(), would overwrite the fill
+    and stroke opacities. This has been fixed so that
+    the object opacity is now combined with the fill
+    and stroke opacities per the SVG spec.
+
+2018-02-12  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/mat.c Fix oss-fuzz issue 6021. (Credit to OSS-Fuzz)
+
+2018-02-11  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dcm.c (ReadDCMImage): Avoid undefined left shift of
+    short.  Fix memory leaks in error reporting paths.  Fixes oss-fuzz
+    issue 6217 "graphicsmagick/coder\_DCM\_fuzzer: Undefined-shift in
+    ReadDCMImage". (Credit to OSS-Fuzz)
+
+  - coders/dpx.c (ReadDPXImage): Avoid divide by zero exception in
+    the case where reference high equals reference low. Fixes oss-fuzz
+    issue 6215 "graphicsmagick/coder\_DPX\_fuzzer: Divide-by-zero in
+    ReadDPXImage". (Credit to OSS-Fuzz)
+
+  - coders/topol.c (ReadTOPOLImage): Avoid index out of bounds when
+    input filename does not use a file extension.
+
+  - coders/cut.c (ReadCUTImage): Avoid index out of bounds when
+    input filename does not use a file extension. Fixes oss-fuzz issue
+    6218 "graphicsmagick/coder\_CUT\_fuzzer: Index-out-of-bounds in
+    ReadCUTImage".  (Credit to OSS-Fuzz)
+
+  - coders/pwp.c (ReadPWPImage): Force temporary file to be read as
+    a SFW file rather than autodetecting the format.  Fixes oss-fuzz
+    issue 6220 "graphicsmagick/coder\_PWP\_fuzzer: Indirect-leak in
+    AllocateImage".  (Credit to OSS-Fuzz)
+
+2018-02-10  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pdf.c (WritePDFImage): Assure that xref memory is not
+    leaked if an exception is thrown.  Fixes oss-fuzz issue 5968
+    "graphicsmagick/coder\_EPDF\_fuzzer: Direct-leak in MagickRealloc".
+    (Credit to OSS-Fuzz)
+
+  - coders/tim.c (ReadTIMImage): Verify that 4/8 bit PSX TIM
+    provides a CLUT and verify indexes.  Fixes oss-fuzz issue 5972
+    "graphicsmagick/coder\_TIM\_fuzzer: Null-dereference WRITE in
+    ReadTIMImage".  (Credit to OSS-Fuzz)
+
+  - coders/topol.c (ReadTOPOLImage): Add additional header
+    validations.  Fixes oss-fuzz issue 5975
+    "graphicsmagick/coder\_TOPOL\_fuzzer: Floating-point-exception in
+    ReadTOPOLImage".  (Credit to OSS-Fuzz)
+
+  - coders/bmp.c (ReadBMPImage): Avoid possible division by zero
+    when decoding CIE primary values. (Credit to OSS-Fuzz)
+
+  - magick/export.c (ExportViewPixelArea): Only compute
+    unsigned\_maxvalue if sample\_bits <= 32.
+
+  - magick/import.c (ImportViewPixelArea): Assure that
+    double\_maxvalue minus double\_minvalue is not zero, or excessively
+    close to zero to avoid divide by zero exception or impossible
+    scaling factor. (Credit to OSS-Fuzz)
+    (ImportViewPixelArea): Only compute unsigned\_maxvalue if
+    sample\_bits <= 32.
+
+2018-02-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dib.c (ReadDIBImage): Validate that image width is not
+    too negative such that it's absolute value can not fit in 32-bit
+    unsigned width. Resolves oss-fuzz issue 6179
+    "graphicsmagick/coder\_ICO\_fuzzer: Integer-overflow in
+    ReadDIBImage". (Credit to OSS-Fuzz)
+
+  - coders/dcm.c (funcDCM\_BitsStored): Validate DICOM datum size.
+    Use a different means to determine the maximum value which does
+    not use excessive shifting.  Resolves oss-fuzz issue 6165
+    "graphicsmagick/coder\_DCM\_fuzzer: Undefined-shift in
+    funcDCM\_BitsStored". (Credit to OSS-Fuzz)
+
+2018-02-08  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/dpx.c (ReadWordU32BE): Add casts to avoid default type
+    promotion from unsigned char to 'int' leading to undefined
+    behavior for 24 bit shift. Fixes oss-fuzz issue 6058
+    "graphicsmagick/coder\_DPX\_fuzzer: Undefined-shift in
+    ReadWordU32BE". (Credit to OSS-Fuzz)
+    (ReadDPXImage): Require that the file has at least one element.
+    Add bountiful casts for values which are left-shifted.  Fixes
+    oss-fuzz issue 5962 "graphicsmagick/coder\_DPX\_fuzzer:
+    Undefined-shift in ReadDPXImage". (Credit to OSS-Fuzz)
+
+  - coders/dcm.c (DCM\_ReadOffsetTable): Add casts Add casts to avoid
+    default type promotion from unsigned char to 'int' leading to
+    undefined behavior for 16 bit shift. Fixes oss-fuzz issue 5980
+    "graphicsmagick/coder\_DCM\_fuzzer: Undefined-shift in
+    DCM\_ReadOffsetTable". (Credit to OSS-Fuzz)
+
+  - magick/module\_aliases.h (ModuleAliases): Add missing mapping
+    from "ICODIB" format to "DIB" module.
+
+  - magick/import.c (ImportUInt32Quantum): Add casts to avoid
+    default type promotion from unsigned char to 'int' leading to
+    undefined behavior for 24 bit shift.  Fixes oss-fuzz
+    "graphicsmagick/coder\_P7\_fuzzer: Undefined-shift in
+    ImportRGBQuantumType". (Credit to OSS-Fuzz)
+
+2018-02-07  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/wpg.c Fix oss-fuzz issue 5964
+    "graphicsmagick/coder\_MAT\_fuzzer: Heap-use-after-free in
+    GetLocaleExceptionMessage". (Credit to OSS-Fuzz)
+
+2018-02-07    Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/render.c (IsPoint): Fixed a bug in which
+    IsPoint() would reject as a valid coordinate value
+    strings that did not begin with an integer: e.g.,
+    "0.25" would be accepted, but ".25" would not.
+
+2018-02-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/cut.c (ReadCUTImage): Fix DestroyImageInfo() of NULL
+    pointer leading to assertion.  Fixes oss-fuzz issue 6067
+    "graphicsmagick/coder\_CUT\_fuzzer: Unknown signal in
+    DestroyImageInfo".
+
+  - coders/tga.c (ReadTGAImage): Throw exception rather than
+    assertion for unexpected comment size.  Fixes oss-fuzz issue 5961
+    "graphicsmagick/coder\_ICB\_fuzzer: ASSERT: (size\_t)
+    (tga\_info.id\_length+1) == commentsize".
+
+2018-02-06  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pdf.c (WritePDFImage): Free 'xref' allocation before
+    error return.  Fixes oss-fuzz issue 5968
+    "graphicsmagick/coder\_EPDF\_fuzzer: Direct-leak in MagickRealloc".
+
+2018-02-04  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/pdb.c (ReadPDBImage): Fix heap buffer overflow if blob is
+    already at EOF when comment is read.  Fixes oss-fuzz issue 5997
+    "graphicsmagick/coder\_PDB\_fuzzer: Heap-buffer-overflow in
+    SetImageAttribute".
+
+  - coders/dpx.c (ReadDPXImage): Fix memory leak of user data if
+    user data is truncated.  Fix consumption of one uninitialized
+    stack bytes.  Fixes oss-fuzz issue 5973:
+    graphicsmagick/enhance\_fuzzer: Direct-leak in ReadDPXImage.
+
+  - coders/pnm.c (ReadPNMImage): Detect and avoid division by zero.
+    Fixes Issue 5959 in oss-fuzz: graphicsmagick/coder\_P7\_fuzzer:
+    Divide-by-zero in ReadPNMImage
+
+  - magick/xwindow.c (MagickXClientMessage): Eliminate valgrind
+    gripe about use of uninitialized stack data by clearing allocation
+    to zero.
+    (MagickXMakeImage): Eliminate valgrind gripe about use of
+    uninitialized heap data by clearing allocation to zero.
+
+  - coders/pwp.c (ReadPWPImage): Remove bogus EOF test on an image
+    with a closed blob.  Fixes Issue 5957 in oss-fuzz:
+    graphicsmagick/coder\_PWP\_fuzzer: ASSERT: image->blob->type !=
+    UndefinedStream.
+
+  - www/Changes.rst: Fix typo with spelling "ChangeLog-2017.html".
+    Resolves SourceForge issue #544 "dead link 2017 changelog page on
+    GraphicsMagick web site".
+
+2018-02-03  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/static.c (OpenModule): Assure that status is initialized.
+    Resolves Coverity 261207 "Uninitialized scalar variable".
+
+  - wand/magick\_wand.c (MagickHasColormap): New function to test if
+    the image has a colormap.
+    (MagickIsGrayImage): New function to test if the image uses only
+    gray pixels.
+    (MagickIsMonochromeImage): New function to test if the image uses
+    only monochrome pixels.
+    (MagickIsOpaqueImage): New function to test if the image uses only
+    opaque pixels.
+    (MagickIsPaletteImage): New function to test if the image is based
+    on a color palette.  Above functions are written by Troy Patteson
+    and submitted via SourceForge patch #54 "Wand API patches: has
+    colormap, is gray image, is monochrome image, is opaque image, is
+    palette image".
+
+  - fuzzing: Added initial OSS-Fuzz integration by Alex Gaynor.
+    From SourceForge patch #55 "OSS-Fuzz integration"
+
+  - coders/png.c (ReadMNGImage): Fix free using possibly unallocated
+    pointer value.
+
+  - magick/blob.c (SeekBlob): Remove implicit extension of blob
+    allocation size based on seek offset.  Besides making an
+    assumption about how the blob memory was allocated, this
+    reallocation feature provides a memory DOS opportunity.  Resolves
+    issue reported by Alex Gaynor via email entitled "Security issue
+    with memory management in Magick++" to the graphicsmagick-security
+    list on 31 Jan 2018.
+    (SeekBlob):
+
+  - coders/jpeg.c (ReadIPTCProfile): Revert inadvertent wrong return
+    codes added by change on December 9, 2017.  Fixes SourceForge bug
+    542 "Improper call to JPEG library in state 201" since 1.3.28.
+
+2018-02-01  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/annotate.c (RenderFreetype): Fixed the text
+    opacity computation in RenderFreeType(). This bug caused
+    the text fill color to bleed into the character cell when
+    the SVG "fill-opacity" is less than 1.0.
+
+2018-02-01  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - magick/attribute.c (CloneImageAttributes): Fixed a bug
+    in which the source image attributes would always replace
+    the destination image attributes instead of being appended
+    to them, and the destination image attributes would become
+    a memory leak.
+
+2018-01-31  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - coders/svg.c (SVGStartElement): Fixed a bug in which the
+    x,y location values for a <text> or <tspan> were overwritten
+    by the x,y values for the next <tspan> before the previous
+    values were used.  This caused the text associated with the
+    previous <text> or <tspan> to appear at the location
+    specified for the next <tspan>.
+
+2018-01-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/static.c: Use !defined(SupportMagickModules) to enable
+    static module loader.  Fixes SourceForge bug #543 "Multiple
+    definition of "OpenModule" (etc) when cross-compiling shared".
+
+2018-01-29  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - coders/svg.c (SVGStartElement): A terminating '>' in
+    a geometry string is interpreted to mean that the dimensions
+    of an image should only be changed if its width or height
+    exceeds the geometry specification.  For an unapparent and
+    undocumented reason, a terminating '>', if present, was
+    being nulled out, making this feature unusable for SVG files
+    (now fixed).
+
+2018-01-29  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - coders/svg.c (ReadSVGImage): If there is a geometry string
+    in image\_info->size (e.g., gm convert -size "50x50%" in.svg
+    out.png), AllocateImage() sets image->columns and image->rows
+    to the width and height values from the size string.  However,
+    this makes no sense if the size string was something like
+    "50x50%" (we'll get columns = rows = 50).  So we set columns
+    and rows to 0 after AllocateImage(), which is the same as if
+    no size string was supplied by the client.  This also results
+    in svg\_info.bounds to be set to 0,0 (i.e., unknown), so that
+    svg\_info.bounds will later be set using the image size
+    information from either the svg "canvas" width/height or from
+    the viewbox.  Later, variable "page" is set from
+    svg\_info->bounds. Then the geometry string in image\_info->size
+    gets applied to the (now known) "page" width and height when
+    SvgStartElement() calls GetMagickGeometry(), and the intended
+    result is obtained.
+
+
+2018-01-24  Greg Wolfe  <gregory.wolfe@kodakalaris.com>
+
+  - coders/svg.c (SVGStartElement): When the density (DPI)
+    is specified using the ImageInfo::density member, the derived
+    scale factor is incorrectly applied a second time to the
+    width and height members of variable RectangleInfo page.
+    Fixes SourceForge ticket #451.
+
+2018-01-23  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/static.c: Use a lazy-loader for static modules with the
+    same external interface as the lazy-loader for dynamic modules.
+
+2018-01-20  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - NEWS.txt: Prepare for 1.3.28 release.
+
+2018-01-17  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - NEWS.txt: Update with changes since previous release.
+
+2018-01-14  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - PerlMagick/Magick.xs: Compiler warnings reduction.
+
+  - magick/pixel\_cache.h: Mark GetPixels(), GetIndexes(), and
+    GetOnePixel() as deprecated.  Compilers may produce a warning if
+    these functions are used.
+
+  - magick/pixel\_cache.c (InterpolateColor): Return black pixel if
+    InterpolateViewColor() reports failure.
+
+  - coders/png.c (ReadMNGImage): Fix memory leak of chunk and
+    mng\_info in error path.
+
+  - coders/gif.c (ReadGIFImage): Fix memory leak of global colormap.
+
+2018-01-13  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/symbols.h: Fix SourceForge issue #538 "13 symbols in
+    common with ImageMagick despite --enable-symbol-prefix".
+
+  - coders/bmp.c (ReadBMPImage): Fix non-terminal loop due to
+    unexpected bit-field mask value.  Fixes SourceForge issue #541
+    "Infinite Loop in ReadBMPImage (coders/bmp.c)".
+
+  - coders/jpeg.c (JPEGMessageHandler): Revert code added on
+    2017-07-08 to promote certain warnings from libjpeg to errors.
+    Add code to rationalize claimed image dimensions based on file
+    size.  Resolves SourceForge issue #539 "Images with libjpeg
+    warnings result in error".
+
+2018-01-11  Fojtik Jaroslav  <JaFojtik@seznam.cz>
+
+  - coders/wpg.c Recursive ReadImage could return multiple scenes
+          fixed.
+
+2018-01-07  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - coders/png.c (ReadOnePNGImage): Quit 'passes' loop if we
+    encountered an error
+
+  - magick/pixel\_cache.c (SetNexus): Fix heap overwrite in
+    AcquireCacheNexus() due to SetNexus() not using an allocated
+    staging area for the pixels like it should.  This problem impacts
+    all 1.3.X releases.  Resolves SourceForge issues 532
+    "heap-buffer-overflow bug in ReadWPGImage" and #531
+    "heap-buffer-overflow in AcquireCacheNexus".
+
+  - magick/pixel\_cache.c (InterpolateViewColor): Now returns
+    MagickPassFail rather than void.  Code using this function is
+    updated to check the return status.
+
+2018-01-01  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/describe.c (DescribeImage): Discriminate between
+    AcquireImagePixels() returning NULL or finding a transparent
+    pixel.  This avoids use of a null pointer in the case where
+    AcquireImagePixels() returns NULL.
+
+2017-12-31  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - magick/static.c: Change static module initialization to be based
+    on an initialized list rather than a squence of function calls in
+    order to simplify maintenance and possibly address future
+    requirements.
+
+2017-12-30  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
+
+  - Copyright.txt: Bump copyright years and rotate ChangeLog.
index 36c4a6d..b7f3f93 100644 (file)
@@ -5,8 +5,8 @@
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <meta name="generator" content="Docutils 0.13.1: http://docutils.sourceforge.net/" />
 <title>GraphicsMagick Change Logs</title>
-<meta content="GraphicsMagick is a robust collection of tools and libraries to read, write, and manipulate an image in any of the more popular image formats including GIF, JPEG, PNG, PDF, and Photo CD. With GraphicsMagick you can create GIFs dynamically making it suitable for Web applications. You can also resize, rotate, sharpen, color reduce, or add special effects to an image and save your completed work in the same or differing image format. " name="description" />
-<meta content="GraphicsMagick, Image Magick, Image Magic, PerlMagick, Perl Magick, Perl Magic, CineMagick, PixelMagick, Pixel Magic, WebMagick, Web Magic, visualization, image processing, software development, simulation, image, software, AniMagick, Animagic, Magick++" name="keywords" />
+<meta content="GraphicsMagick is a robust collection of tools and libraries to read, write, and manipulate an image in any of the more popular image formats including GIF, JPEG, PNG, PDF, and WebP. With GraphicsMagick you can create GIFs dynamically making it suitable for Web applications. You can also resize, rotate, sharpen, color reduce, or add special effects to an image and save your completed work in the same or differing image format. " name="description" />
+<meta content="GraphicsMagick, GM, PerlMagick, Perl Magick, Perl Magic, image processing, software development, TclMagick, Magick++" name="keywords" />
 <link rel="stylesheet" href="docutils-articles.css" type="text/css" />
 </head>
 <body>
@@ -43,7 +43,8 @@
 <p>The following are the <tt class="docutils literal">GraphicsMagick</tt> change logs since 2001:</p>
 <blockquote>
 <ul class="simple">
-<li><a class="reference external" href="Changelog.html">2017</a> (1.3.26 released)</li>
+<li><a class="reference external" href="Changelog.html">2018</a> (1.3.28, 1.3.29, 1.3.30 released)</li>
+<li><a class="reference external" href="ChangeLog-2017.html">2017</a> (1.3.26, 1.3.27, 1.3.27a released)</li>
 <li><a class="reference external" href="ChangeLog-2016.html">2016</a> (1.3.24, 1.3.25 released)</li>
 <li><a class="reference external" href="ChangeLog-2015.html">2015</a> (1.3.21 - 1.3.23 released)</li>
 <li><a class="reference external" href="ChangeLog-2014.html">2014</a> (1.3.20 released)</li>
@@ -63,7 +64,7 @@
 </ul>
 </blockquote>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </body>
 </html>
index 1114877..d12f54c 100644 (file)
@@ -10,21 +10,19 @@ GraphicsMagick Change Logs
    :description: GraphicsMagick is a robust collection of tools and
                  libraries to read, write, and manipulate an image in any
                  of the more popular image formats including GIF, JPEG,
-                 PNG, PDF, and Photo CD. With GraphicsMagick you can
+                 PNG, PDF, and WebP. With GraphicsMagick you can
                  create GIFs dynamically making it suitable for Web
                  applications. You can also resize, rotate, sharpen,
                  color reduce, or add special effects to an image and
                  save your completed work in the same or differing image
                  format.
 
-   :keywords: GraphicsMagick, Image Magick, Image Magic, PerlMagick,
-              Perl Magick, Perl Magic, CineMagick, PixelMagick, Pixel
-              Magic, WebMagick, Web Magic, visualization, image
-              processing, software development, simulation, image,
-              software, AniMagick, Animagic, Magick++
+   :keywords: GraphicsMagick, GM, PerlMagick, Perl Magick, Perl Magic,
+              image processing, software development, TclMagick, Magick++
 
 .. _GraphicsMagick : index.html
-.. _2017 : Changelog.html
+.. _2018 : Changelog.html
+.. _2017 : ChangeLog-2017.html
 .. _2016 : ChangeLog-2016.html
 .. _2015 : ChangeLog-2015.html
 .. _2014 : ChangeLog-2014.html
@@ -44,7 +42,9 @@ GraphicsMagick Change Logs
 
 The following are the ``GraphicsMagick`` change logs since 2001:
 
-  * 2017_ (1.3.26 released)
+  * 2018_ (1.3.28, 1.3.29, 1.3.30 released)
+
+  * 2017_ (1.3.26, 1.3.27, 1.3.27a released)
 
   * 2016_ (1.3.24, 1.3.25 released)
 
@@ -83,4 +83,4 @@ The following are the ``GraphicsMagick`` change logs since 2001:
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index ac7ace8..b8ea064 100644 (file)
@@ -51,7 +51,7 @@ to changing one line of code.</em>]</blockquote>
 <li><p class="first">In November 2002, the GraphicsMagick Group created GraphicsMagick
 from ImageMagick Studio's ImageMagick and applied the &quot;MIT&quot; style
 license:</p>
-<p>Copyright (C) 2002 - 2017 GraphicsMagick Group</p>
+<p>Copyright (C) 2002 - 2018 GraphicsMagick Group</p>
 <p>Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation files
 (the &quot;Software&quot;), to deal in the Software without restriction,
@@ -260,7 +260,7 @@ licenses for these libraries is provided in a &quot;licenses&quot; directory.</p
 </li>
 </ol>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </body>
 </html>
index dbe92a9..bb4560c 100644 (file)
@@ -792,7 +792,7 @@ seaworld.jpg JPEG 1530x1020+0+0 DirectClass 8-bit 204.0K 0.000u 0:01
 </pre>
 <p>but with -verbose it can report on a large number of properties.</p>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index 1c4a274..d338282 100644 (file)
@@ -773,4 +773,4 @@ but with -verbose it can report on a large number of properties.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index bb9aaab..4c68800 100644 (file)
@@ -1271,9 +1271,10 @@ width=15><b><font face="Helvetica, Arial"
 <table width="90%" border="0" cellspacing="0"              cellpadding="8">              <tr><td width="6%"><br></td><td>the type of image compression</td></tr></table>
 <table width="90%" border="0" cellspacing="0"             cellpadding="8">             <tr><td width="6%"><br></td><td><font size="-1">
 Choices are: <em>None</em>, <em>BZip</em>, <em>Fax</em>,
-<em>Group4</em>,
+<em>Group3</em>, <em>Group4</em>,
 <em>JPEG</em>, <em>Lossless</em>,
-<em>LZW</em>, <em>RLE</em>, <em>Zip</em>, or <em>LZMA</em>.
+<em>LZW</em>, <em>RLE</em>, <em>Zip</em>, <em>LZMA</em>, <em>JPEG2000</em>,
+<em>JPEG2000</em>, <em>JBIG</em>, <em>JBIG2</em>, <em>WebP</em>, or <em>ZSTD</em>.
 </font></td></tr></table>
 <table width="90%" border="0" cellspacing="0"             cellpadding="8">             <tr><td width="6%"><br></td><td><font size="-1">
 Specify <strong>+compress</strong> to store the binary image in an uncompressed format.
@@ -1283,10 +1284,11 @@ The default is the compression type of the specified image file.</font></td></tr
 the JPEG library has been patched to support it. Use of lossless JPEG is
 generally not recommended.</font></td></tr></table>
 <table width="90%" border="0" cellspacing="0"             cellpadding="8">             <tr><td width="6%"><br></td><td><font size="-1">
-Use the <strong>-quality</strong> option to set the compression level to be used by
-JPEG, PNG, MIFF, and MPEG encoders. Use the <strong>-sampling-factor</strong>
-option to set the sampling factor to be used by the DPX, JPEG, MPEG, and
-YUV encoders for downsampling the chroma channels.</font></td></tr></table>
+Use the <strong>-quality</strong> option to set the compression level to be used
+by the JPEG, JPEG-2000, PNG, MIFF, MPEG, and TIFF encoders. Use the
+<strong>-sampling-factor</strong> option to set the sampling factor to be used
+by the DPX, JPEG, MPEG, and YUV encoders for downsampling the chroma
+channels.</font></td></tr></table>
 <table BORDER=0 WIDTH="94%">
 <tr>
 <td width="3%"><br></td> 
@@ -1495,7 +1497,7 @@ type implied by the DPX header (if any).
 <dt>dpx:packing-method={packed|a|b|lsbpad|msbpad}</dt>
 <dd>DPX samples are output within 32-bit words. They may be tightly
 packed end-to-end within the words ("packed"), padded with null bits to
-the right of the sample ("a" or "lsbpad), or padded with null bits to the
+the right of the sample ("a" or "lsbpad"), or padded with null bits to the
 left of the sample ("b" or "msbpad"). This option only has an effect for
 sample sizes of 10 or 12 bits. If samples are not packed, the DPX
 standard recommends type A padding. Many DPX readers demand a sample size
@@ -1540,9 +1542,19 @@ behaves.
 <dd>Enables or disables fancy upsampling when reading a JPEG file
 (default enabled).
 </dd>
+<dt>jpeg:max-scan-number=&lt;value&gt;</dt>
+<dd>Specifies an integer value for the maximum number of progressive
+scans allowed in a JPEG file.  The default maximum is 100 scans.  This
+limit is imposed due to a weakness in the JPEG standard which allows
+small JPEG files to take many minutes or hours to be read.
+</dd>
+<dt>jpeg:max-warnings=&lt;value&gt;</dt>
+<dd>Specifies an integer value for how many warnings are allowed for
+any given error type before being promoted to a hard error.  JPEG
+files producing excessive warnings indicate a problem with the file.
+</dd>
 <dt>jpeg:optimize-coding={true|false}</dt>
-<dd>
-Selects if huffman encoding should be used. Huffman encoding is enabled
+<dd>Selects if huffman encoding should be used. Huffman encoding is enabled
 by default, but may be disabled for very large images since it encoding
 requires that the entire image be buffered in memory. Huffman encoding
 produces smaller JPEG files at the expense of added compression time and
@@ -1561,6 +1573,12 @@ are not.
 <dd>If the pcl:fit-to-page flag is defined, then the printer is
 requested to scale the image to fit the page size (width and/or
 height).</dd>
+<dt>mng:maximum-loops=&lt;value&gt;</dt>
+<dd>mng:maximum-loops specifies the maximum number of loops allowed to
+be specified by a MNG LOOP chunk. Without an imposed limit, a MNG file
+could request up to 2147483647 loops, which could run for a very long
+time.  The current default limit is 512 loops.
+</dd>
 <dt>pdf:use-cropbox={true|false}</dt>
 <dd>If the pdf:use-cropbox flag is set to <strong>true</strong>, then
 Ghostscript is requested to apply the PDF crop box.
@@ -1576,6 +1594,12 @@ requested pages.
 create Postscript files that render bilevel images with the Postscript
 imagemask operator instead of the image operator.
 </dd>
+<dt>ptif:minimum-geometry=&lt;geometry&gt;</dt>
+<dd>If the ptif:minimum-geometry key is defined, GraphicsMagick will
+use it to determine the minimum frame size to output when writing a
+pyramid TIFF file (a TIFF file containing a succession of reduced
+versions of the first frame). The default minimum geometry is 32x32.
+</dd>
 <dt>tiff:alpha={unspecified|associated|unassociated}</dt>
 <dd>Specify the TIFF alpha channel type when reading or writing TIFF files,
 overriding the normal value. The default alpha channel type for new files
@@ -1701,6 +1725,20 @@ is then defaulted to an appropriate size. Height should be a multiple of
 16. If the value is not a multiple of 16, then it will be rounded down.
 Enables tiled TIFF if it has not already been enabled.
 </dd>
+<dt>tiff:webp-lossless={TRUE|FALSE}</dt>
+<dd>Specify a value of <strong>TRUE</strong> to enable lossless mode while
+writing WebP-compressed TIFF files. The WebP <strong>webp:lossless</strong>
+option may also be used.  The quality factor set by the
+<strong>-quality</strong> option may be used to influence the level of effort
+expended while compressing.
+</dd>
+<dt>tiff:zstd-compress-level=&lt;value&gt;</dt>
+<dd>Specify the compression level to use while writing Zstd-compressed
+TIFF files. The valid range is 1 to 22. If this define is not
+specified, then the 'quality' value is used such that the default
+quality setting of 75 is translated to a compress level of 9 such that
+'quality' has a useful range of 10-184 if used for this purpose.
+</dd>
 <dt>webp:lossless={true|false}</dt>
 <dd>Enable lossless encoding.
 </dd>
@@ -4038,12 +4076,21 @@ width=15><b><font face="Helvetica, Arial"
 <table width="90%" border="0" cellspacing="0"              cellpadding="8">              <tr><td width="6%"><br></td><td>output files to directory</td></tr></table>
 <table width="90%" border="0" cellspacing="0"             cellpadding="8">             <tr><td width="6%"><br></td><td><font size="-1">
 Use -output-directory to specify a directory under which to write the
-output files. Normally mogrify overwrites the input files but with this
-option the output files may be written to a different directory so that
-the input files are preserved. The algorithm used preserves all of the
-input path specification in the output path so that the user-specified
-input path (including any directory part) is appended to the output path.
-The user is responsible for creating the output directory.</font></td></tr></table>
+output files. Normally mogrify overwrites the input files, but with
+this option the output files may be written to a different directory
+tree so that the input files are preserved. The algorithm used
+preserves all of the input path specification in the output path so
+that the user-specified input path (including any sub-directory part)
+is appended to the output path. If the input file lacks an extension,
+then a suitable extension is automatically added to the output file.
+The user is responsible for creating the output directory specified as
+an argument, but subdirectories will be created as needed if the
+<strong>-create-directories</strong> option is supplied.  This option may be
+used to apply transformations on files from one directory and write
+the transformed files to a different directory.  In conjunction with
+<strong>-create-directories</strong>, this option is designed to support
+transforming whole directory trees of files provided that the relative
+path of the input file is included as part the list of filenames.</font></td></tr></table>
 <table BORDER=0 WIDTH="94%">
 <tr>
 <td width="3%"><br></td> 
@@ -4457,7 +4504,7 @@ When writing a JNG image with transparency, two quality values are required,
 one for the main image and one for the grayscale image that conveys the
 opacity channel.  These are written as a single integer equal to the main
 image quality plus 1000 times the opacity quality.  For example, if you
-want to use quality 75 for the main image and quality 90 to compress 
+want to use quality 75 for the main image and quality 90 to compress
 the opacity data, use <tt>-quality 90075</tt>.</font></td></tr></table>
 <table width="90%" border="0" cellspacing="0"             cellpadding="8">             <tr><td width="6%"><br></td><td><font size="-1">
 For the PNM family of formats (PNM, PGM, and PPM) specify a quality
@@ -4465,6 +4512,14 @@ factor of zero in order to obtain the ASCII variant of the format. Note
 that -compress <em>none</em> used to be used to trigger ASCII output but
 provided the opposite result of what was expected as compared with other
 formats.</font></td></tr></table>
+<table width="90%" border="0" cellspacing="0"             cellpadding="8">             <tr><td width="6%"><br></td><td><font size="-1">
+For the TIFF format, the JPEG, WebP, Zip, and Zstd compression
+algorithms are influenced by the quality value.  JPEG and WebP provide
+lossy compression so higher quality produces a larger file with less
+degradation.  The Zip and Zstd compression algorithms (and WebP in
+lossless mode) are lossless and for these algorithms a higher
+'quality' means to work harder to produce a smaller file, but with no
+difference in image quality.</font></td></tr></table>
 <table BORDER=0 WIDTH="94%">
 <tr>
 <td width="3%"><br></td> 
@@ -6354,7 +6409,7 @@ color="#00B04F"><font size="+1">
 <table width="94%" border="0" cellspacing="0" cellpadding="8">
 <tr><td width="3%"><br></td><td>
 <p>
-<strong>Copyright (C) 2002 - 2017 GraphicsMagick Group.</strong> Additional
+<strong>Copyright (C) 2002 - 2018 GraphicsMagick Group.</strong> Additional
 copyrights apply. Please see see
 http://www.GraphicsMagick.org/Copyright.html for details.
 <p>
@@ -6366,6 +6421,6 @@ http://www.GraphicsMagick.org/Copyright.html for details.
 
 [<a href="index.html">Home</a>] [<a href="utilities.html">Utilities Index</a>]
 <BR>
-<p align=center <a href="Copyright.html">Copyright &#169; GraphicsMagick Group 2002 - 2017</a></p></td>
+<p align=center <a href="Copyright.html">Copyright &#169; GraphicsMagick Group 2002 - 2018</a></p></td>
 </tr></table>
 </body></html>
index 4138a80..72acd2a 100644 (file)
@@ -281,7 +281,7 @@ hg update
 <li><a class="reference external" href="https://www.mercurial-scm.org/wiki/TipsAndTricks#Keep_.22My.22_or_.22Their.22_files_when_doing_a_merge">Keep &quot;My&quot; or &quot;Their&quot; files when doing a merge</a></li>
 </ul>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2012 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2012 - 2018</p>
 </div>
 </div>
 </body>
index dca73b8..4457795 100644 (file)
@@ -265,4 +265,4 @@ Mercurial Topics
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2012 - 2017
+Copyright |copy| GraphicsMagick Group 2012 - 2018
index 2f79c01..01f0c36 100644 (file)
@@ -322,12 +322,12 @@ directory (only one can be used for development)</td></tr>
 <kbd><span class="option">--with-fpx</span></kbd></td>
 <td>enable FlashPIX support</td></tr>
 <tr><td class="option-group">
-<kbd><span class="option">--with-gslib</span></kbd></td>
-<td>enable Ghostscript library support (not recommended)</td></tr>
-<tr><td class="option-group">
 <kbd><span class="option">--without-jbig</span></kbd></td>
 <td>disable JBIG support</td></tr>
 <tr><td class="option-group">
+<kbd><span class="option">--without-webp</span></kbd></td>
+<td>disable WEBP support</td></tr>
+<tr><td class="option-group">
 <kbd><span class="option">--without-jp2</span></kbd></td>
 <td>disable JPEG v2 support</td></tr>
 <tr><td class="option-group">
@@ -380,6 +380,9 @@ directory (only one can be used for development)</td></tr>
 <kbd><span class="option">--without-zlib</span></kbd></td>
 <td>disable ZLIB support</td></tr>
 <tr><td class="option-group">
+<kbd><span class="option">--without-zstd</span></kbd></td>
+<td>disable Zstd support</td></tr>
+<tr><td class="option-group">
 <kbd><span class="option">--with-x</span></kbd></td>
 <td>use the X Window System</td></tr>
 <tr><td class="option-group" colspan="2">
@@ -1002,7 +1005,7 @@ the developer's environment environment and your own may include the
 compiler, the CPU type, and the library versions used. The
 GraphicsMagick developers use the current release of all dependent
 libraries.</p>
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index d24add7..dc6484e 100644 (file)
@@ -285,14 +285,14 @@ Optional Packages/Options
 
     enable FlashPIX support
 
---with-gslib
-
-    enable Ghostscript library support (not recommended)
-
 --without-jbig
 
     disable JBIG support
 
+--without-webp
+
+    disable WEBP support
+
 --without-jp2
 
     disable JPEG v2 support
@@ -357,6 +357,10 @@ Optional Packages/Options
 
     disable ZLIB support
 
+--without-zstd
+
+    disable Zstd support
+
 --with-x
 
     use the X Window System
@@ -981,4 +985,4 @@ libraries.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index e9acccf..1e24991 100644 (file)
@@ -168,7 +168,7 @@ to continue.</blockquote>
 <div class="section" id="select-additional-tasks">
 <h2><a class="toc-backref" href="#id8">Select Additional Tasks</a></h2>
 <blockquote>
-<p>A screen is displayed which presents most (or all) of the following
+<p>A screen is displayed which presents some (or all) of the following
 options:</p>
 <ul class="simple">
 <li>Create a desktop icon</li>
@@ -235,7 +235,7 @@ type</p>
 <blockquote>
 <pre class="literal-block">
 gm convert logo: logo.miff
-gmdisplay logo.miff
+gm convert logo.miff win:
 </pre>
 </blockquote>
 <p>and the GraphicsMagick logo should be displayed in a window.</p>
@@ -778,7 +778,7 @@ double-clicking from Windows Explorer.<ol class="loweralpha">
 <tt class="docutils literal"><span class="pre">GM\VisualMagick\bin\GraphicsMagick-1.3-Q8-dll.exe</span></tt></li>
 </ol>
 </blockquote>
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </div>
index 89f2949..2358c1d 100644 (file)
@@ -115,7 +115,7 @@ Select Start Menu Folder
 Select Additional Tasks
 -----------------------
 
-  A screen is displayed which presents most (or all) of the following
+  A screen is displayed which presents some (or all) of the following
   options:
 
   * Create a desktop icon
@@ -188,7 +188,7 @@ Testing The Installation
     ::
 
       gm convert logo: logo.miff
-      gmdisplay logo.miff
+      gm convert logo.miff win:
 
   and the GraphicsMagick logo should be displayed in a window.
 
@@ -768,4 +768,4 @@ Windows Distribution Build Procedure
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 9433c02..05fe5eb 100644 (file)
@@ -126,7 +126,7 @@ working.</p>
 <p>Sometime in the future, MagickCMD may assume the place of gm.exe in the
 &quot;utils&quot; distribution in order to decrease the overall package size.</p>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index c10ed03..5984eb0 100644 (file)
@@ -127,4 +127,4 @@ Sometime in the future, MagickCMD may assume the place of gm.exe in the
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 1446f0b..508bdf7 100644 (file)
@@ -115,7 +115,7 @@ public:
 
 };
 </pre>
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </body>
 </html>
index a55635a..8b4919d 100644 (file)
@@ -89,5 +89,4 @@ The following is the definition of the Magick::Blob class::
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
-
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index c0d2da5..907dd71 100644 (file)
@@ -1,6 +1,6 @@
 
 Copyright 1999 - 2015 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
-                                                                          
+
 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation
 files ("Magick++"), to deal in Magick++ without restriction,
@@ -8,10 +8,10 @@ including without limitation the rights to use, copy, modify,
 merge, publish, distribute, sublicense, and/or sell copies of
 Magick++, and to permit persons to whom the Magick++ 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 Magick++.
-                                                                          
+
 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
@@ -19,4 +19,3 @@ noninfringement. In no event shall Bob Friesenhahn 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 Magick++ or the use or other dealings in Magick++.
-
index 8c4e34b..50159a6 100644 (file)
@@ -114,7 +114,7 @@ namespace Magick
   };
 }
 </pre>
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </body>
 </html>
index 7e10ce8..e4a066f 100644 (file)
@@ -34,7 +34,7 @@ The following code fragment illustrates how CoderInfo may be used::
       cout << "true";
     else
       cout << "false";
-    cout << endl; 
+    cout << endl;
 
 The definition of class 'Magick::CoderInfo' is::
 
@@ -45,9 +45,9 @@ The definition of class 'Magick::CoderInfo' is::
     public:
 
       enum MatchType {
-        AnyMatch,      // match any coder
-        TrueMatch,     // match coder if true
-        FalseMatch     // match coder if false
+        AnyMatch,       // match any coder
+        TrueMatch,      // match coder if true
+        FalseMatch      // match coder if false
       };
 
       // Default constructor
@@ -85,5 +85,4 @@ The definition of class 'Magick::CoderInfo' is::
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
-
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index 16c308a..b371918 100644 (file)
@@ -377,7 +377,7 @@ public:
 
 };
 </pre>
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </div>
 </body>
index b4bb445..d370d69 100644 (file)
@@ -87,12 +87,12 @@ The following is the definition of the Color class::
   {
   public:
     Color ( Quantum red_,
-           Quantum green_,
-           Quantum blue_ );
+            Quantum green_,
+            Quantum blue_ );
     Color ( Quantum red_,
-           Quantum green_,
-           Quantum blue_,
-           Quantum alpha_ );
+            Quantum green_,
+            Quantum blue_,
+            Quantum alpha_ );
     Color ( const std::string &x11color_ );
     Color ( const char * x11color_ );
     Color ( void );
@@ -119,11 +119,11 @@ The following is the definition of the Color class::
     // (range opaque=0 to transparent=1.0)
     void           alpha ( double alpha_ );
     double         alpha ( void ) const;
-        
+
     // Does object contain valid color?
     void           isValid ( bool valid_ );
     bool           isValid ( void ) const;
-    
+
     // Set color via X11 color specification string
     const Color& operator= ( const std::string &x11color_ );
     const Color& operator= ( const char * x11color_ );
@@ -180,13 +180,13 @@ set via the alpha() method in the Color base class::
     ColorRGB ( void );
     ColorRGB ( const Color & color_ );
     /* virtual */  ~ColorRGB ( void );
-    
+
     void           red ( double red_ );
     double         red ( void ) const;
-    
+
     void           green ( double green_ );
     double         green ( void ) const;
-    
+
     void           blue ( double blue_ );
     double         blue ( void ) const;
 
@@ -237,7 +237,7 @@ pixel)::
     ColorMono ( void );
     ColorMono ( const Color & color_ );
     /* virtual */ ~ColorMono ();
-    
+
     void           mono ( bool mono_ );
     bool           mono ( void ) const;
 
@@ -259,13 +259,13 @@ Representation of a color in Hue/Saturation/Luminosity (HSL) colorspace::
     ColorHSL ( void );
     ColorHSL ( const Color & color_ );
     /* virtual */  ~ColorHSL ( );
-    
+
     void           hue ( double hue_ );
     double         hue ( void ) const;
-    
+
     void           saturation ( double saturation_ );
     double         saturation ( void ) const;
-    
+
     void           luminosity ( double luminosity_ );
     double         luminosity ( void ) const;
 
@@ -284,7 +284,7 @@ television transmission).  Argument ranges are
   ==  =================
   Y   0.0 through 1.0
   U   -0.5 through 0.5
-  V   -0.5 through 0.5 
+  V   -0.5 through 0.5
   ==  =================
 
 ::
@@ -296,13 +296,13 @@ television transmission).  Argument ranges are
     ColorYUV ( void );
     ColorYUV ( const Color & color_ );
     /* virtual */ ~ColorYUV ( void );
-    
+
     void           u ( double u_ );
     double         u ( void ) const;
-    
+
     void           v ( double v_ );
     double         v ( void ) const;
-    
+
     void           y ( double y_ );
     double         y ( void ) const;
 
@@ -313,5 +313,4 @@ television transmission).  Argument ranges are
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
-
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index 0a03eed..189481c 100644 (file)
@@ -1117,7 +1117,7 @@ PathArcRel ( const PathArcArgs &amp;coordinates_ );
 <pre class="literal-block">
 PathArcRel ( const PathArcArgsList &amp;coordinates_ );
 </pre>
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </div>
 </div>
index d5508d6..b931919 100644 (file)
@@ -313,7 +313,7 @@ Draw an ellipse using the stroke color and thickness, specified
 origin, x & y radius, as well as specified start and end of arc in
 degrees. If a fill color is specified, then the object is filled::
 
-  DrawableEllipse ( double originX_, double originY_, 
+  DrawableEllipse ( double originX_, double originY_,
                     double radiusX_, double radiusY_,
                     double arcStart_, double arcEnd_ )
 
@@ -1051,5 +1051,4 @@ Draw multiple arc segments::
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
-
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index 662f514..667abe1 100644 (file)
@@ -1314,7 +1314,7 @@ enumeration may be specified for a wildcard match.</p>
 </tr>
 </tbody>
 </table>
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </div>
 </body>
index 17fd27d..6dfc663 100644 (file)
@@ -41,7 +41,7 @@ pixel format.
 ClassType
 ---------
 
-*ClassType* specifies the image storage class. 
+*ClassType* specifies the image storage class.
 
 .. table:: ClassType
 
@@ -181,7 +181,7 @@ algorithm.
    CopyMagentaCompositeOp
    CopyYellowCompositeOp
    CopyBlackCompositeOp     Copy CMYK Black (K) channel.
-   DivideCompositeOp        Change-image / base-image. This is useful for 
+   DivideCompositeOp        Change-image / base-image. This is useful for
                             improving the readability of text on unevenly
                             illuminated photos. (by using a gaussian blurred
                             copy of change-image as base-image)
@@ -336,7 +336,7 @@ gravity is *NorthWestGravity*.
 ImageType
 ---------
 
-*ImageType* indicates the type classification of the image. 
+*ImageType* indicates the type classification of the image.
 
 .. table:: ImageType
 
@@ -679,5 +679,4 @@ enumeration may be specified for a wildcard match.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
-
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index 1b7d606..9194c5d 100644 (file)
@@ -294,7 +294,7 @@ subordinate program is missing (but is needed).</td>
 </table>
 <p>Note that <em>ErrorMissingDelegate</em> is a &quot;catch-all&quot; error reported when
 GraphicsMagick is unable to figure out how to open the file.</p>
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </body>
 </html>
index 6e37c60..28aeea9 100644 (file)
@@ -42,7 +42,7 @@ The pseudo code for the main loop of your program may look like::
       // Construct an image instance first so that we don't have to worry
       // about object construction failure due to a minor warning exception
       // being thrown.
-      Magick::Image image; 
+      Magick::Image image;
 
       // Determine if Warning exceptions are thrown.
       // Use is optional.  Set to true to block Warning exceptions.
@@ -66,8 +66,8 @@ The pseudo code for the main loop of your program may look like::
         // Handle any other Magick++ warning.
         cerr << “Warning: “ << warning.what() << endl;
       }
-      catch( Magick::ErrorFileOpen &error ) 
-      { 
+      catch( Magick::ErrorFileOpen &error )
+      {
         // Process Magick++ file open error
         cerr << “Error: “ << error.what() << endl;
         continue; // Try next image.
@@ -82,16 +82,16 @@ The pseudo code for the main loop of your program may look like::
          cerr << “Caught Magick++ exception: “ << error.what() << endl;
       }
     }
-    catch( std::exception &error ) 
-    { 
+    catch( std::exception &error )
+    {
        // Process any other exceptions derived from standard C++ exception
        cerr << “Caught C++ STD exception: “ << error.what() << endl;
-    } 
-    catch( ... ) 
-    { 
+    }
+    catch( ... )
+    {
       // Process *any* exception (last-ditch effort). There is not a lot
       // you can do here other to retry the operation that failed, or exit
-      // the program. 
+      // the program.
     }
   }
 
@@ -120,7 +120,7 @@ and continuing on. Exceptions derived from *Error* are thrown to
 represent fatal errors that can not produce a valid result
 (e.g. attempting to read a file which does not exist).
 
-The specific derived exception classes are shown in the following tables: 
+The specific derived exception classes are shown in the following tables:
 
 .. table:: Warning (Suspect but completed) Sub-Classes
 
@@ -180,5 +180,4 @@ GraphicsMagick is unable to figure out how to open the file.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
-
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index 7753215..bdad54d 100644 (file)
@@ -101,7 +101,7 @@ table:</p>
 </tr>
 </tbody>
 </table>
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </body>
 </html>
index 8078498..fcbe5d2 100644 (file)
@@ -38,5 +38,4 @@ table:
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
-
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index 0847607..dd05473 100644 (file)
@@ -420,7 +420,7 @@ public:
 
 };
 </pre>
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </div>
 </body>
index 7d1691d..41f26f1 100644 (file)
@@ -157,43 +157,43 @@ The following is the definition of the Magick::Geometry class::
   class Geometry
   {
   public:
-    
+
     Geometry ( unsigned int width_,
-              unsigned int height_,
-              unsigned int xOff_ = 0,
-              unsigned int yOff_ = 0,
-              bool xNegative_ = false,
-              bool yNegative_ = false );
+               unsigned int height_,
+               unsigned int xOff_ = 0,
+               unsigned int yOff_ = 0,
+               bool xNegative_ = false,
+               bool yNegative_ = false );
     Geometry ( const std::string &geometry_ );
     Geometry ( const char * geometry_ );
     Geometry ( const Geometry &geometry_ );
     Geometry ( );
     ~Geometry ( void );
-    
+
     // Width
     void          width ( unsigned int width_ );
     unsigned int  width ( void ) const;
-    
+
     // Height
     void          height ( unsigned int height_ );
     unsigned int  height ( void ) const;
-    
+
     // X offset from origin
     void          xOff ( unsigned int xOff_ );
     unsigned int  xOff ( void ) const;
-    
+
     // Y offset from origin
     void          yOff ( unsigned int yOff_ );
     unsigned int  yOff ( void ) const;
-    
+
     // Sign of X offset negative? (X origin at right)
     void          xNegative ( bool xNegative_ );
     bool          xNegative ( void ) const;
-    
+
     // Sign of Y offset negative? (Y origin at bottom)
     void          yNegative ( bool yNegative_ );
     bool          yNegative ( void ) const;
-    
+
     // Width and height are expressed as percentages
     void          percent ( bool percent_ );
     bool          percent ( void ) const;
@@ -201,11 +201,11 @@ The following is the definition of the Magick::Geometry class::
     // Resize without preserving aspect ratio (!)
     void          aspect ( bool aspect_ );
     bool          aspect ( void ) const;
-    
+
     // Resize if image is greater than size (>)
     void          greater ( bool greater_ );
     bool          greater ( void ) const;
-    
+
     // Resize if image is less than size (<)
     void          less ( bool less_ );
     bool          less ( void ) const;
@@ -217,24 +217,23 @@ The following is the definition of the Magick::Geometry class::
     // Dimensions are treated as minimum rather than maximum values (^)
     void          fillArea ( bool fillArea_ );
     bool          fillArea ( void ) const;
-    
+
     // Does object contain valid geometry?
     void          isValid ( bool isValid_ );
     bool          isValid ( void ) const;
-    
+
     // Set via geometry string
     const Geometry& operator = ( const std::string &geometry_ );
     const Geometry& operator = ( const char * geometry_ );
 
     // Assignment operator
     Geometry& operator= ( const Geometry& Geometry_ );
-    
+
     // Return geometry string
     operator std::string() const;
-    
+
   };
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
-
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index 99da532..d92cab3 100644 (file)
@@ -447,94 +447,95 @@ image.write(&quot;myImage.tiff&quot;);
 <li><a class="reference internal" href="#addnoisechannel" id="id21">addNoiseChannel</a></li>
 <li><a class="reference internal" href="#affinetransform" id="id22">affineTransform</a></li>
 <li><a class="reference internal" href="#annotate" id="id23">annotate</a></li>
-<li><a class="reference internal" href="#blur" id="id24">blur</a></li>
-<li><a class="reference internal" href="#blurchannel" id="id25">blurChannel</a></li>
-<li><a class="reference internal" href="#border" id="id26">border</a></li>
-<li><a class="reference internal" href="#cdl" id="id27">cdl</a></li>
-<li><a class="reference internal" href="#channel" id="id28">channel</a></li>
-<li><a class="reference internal" href="#channeldepth" id="id29">channelDepth</a></li>
-<li><a class="reference internal" href="#charcoal" id="id30">charcoal</a></li>
-<li><a class="reference internal" href="#chop" id="id31">chop</a></li>
-<li><a class="reference internal" href="#colorize" id="id32">colorize</a></li>
-<li><a class="reference internal" href="#colormatrix" id="id33">colorMatrix</a></li>
-<li><a class="reference internal" href="#comment" id="id34">comment</a></li>
-<li><a class="reference internal" href="#compare" id="id35">compare</a></li>
-<li><a class="reference internal" href="#composite" id="id36">composite</a></li>
-<li><a class="reference internal" href="#contrast" id="id37">contrast</a></li>
-<li><a class="reference internal" href="#convolve" id="id38">convolve</a></li>
-<li><a class="reference internal" href="#crop" id="id39">crop</a></li>
-<li><a class="reference internal" href="#cyclecolormap" id="id40">cycleColormap</a></li>
-<li><a class="reference internal" href="#despeckle" id="id41">despeckle</a></li>
-<li><a class="reference internal" href="#display" id="id42">display</a></li>
-<li><a class="reference internal" href="#draw" id="id43">draw</a></li>
-<li><a class="reference internal" href="#edge" id="id44">edge</a></li>
-<li><a class="reference internal" href="#emboss" id="id45">emboss</a></li>
-<li><a class="reference internal" href="#enhance" id="id46">enhance</a></li>
-<li><a class="reference internal" href="#equalize" id="id47">equalize</a></li>
-<li><a class="reference internal" href="#erase" id="id48">erase</a></li>
-<li><a class="reference internal" href="#extent" id="id49">extent</a></li>
-<li><a class="reference internal" href="#flip" id="id50">flip</a></li>
-<li><a class="reference internal" href="#floodfillcolor" id="id51">floodFillColor</a></li>
-<li><a class="reference internal" href="#floodfillopacity" id="id52">floodFillOpacity</a></li>
-<li><a class="reference internal" href="#floodfilltexture" id="id53">floodFillTexture</a></li>
-<li><a class="reference internal" href="#flop" id="id54">flop</a></li>
-<li><a class="reference internal" href="#frame" id="id55">frame</a></li>
-<li><a class="reference internal" href="#gamma" id="id56">gamma</a></li>
-<li><a class="reference internal" href="#gaussianblur" id="id57">gaussianBlur</a></li>
-<li><a class="reference internal" href="#gaussianblurchannel" id="id58">gaussianBlurChannel</a></li>
-<li><a class="reference internal" href="#implode" id="id59">implode</a></li>
-<li><a class="reference internal" href="#haldclut" id="id60">haldClut</a></li>
-<li><a class="reference internal" href="#label" id="id61">label</a></li>
-<li><a class="reference internal" href="#level" id="id62">level</a></li>
-<li><a class="reference internal" href="#levelchannel" id="id63">levelChannel</a></li>
-<li><a class="reference internal" href="#magnify" id="id64">magnify</a></li>
-<li><a class="reference internal" href="#map" id="id65">map</a></li>
-<li><a class="reference internal" href="#mattefloodfill" id="id66">matteFloodfill</a></li>
-<li><a class="reference internal" href="#medianfilter" id="id67">medianFilter</a></li>
-<li><a class="reference internal" href="#minify" id="id68">minify</a></li>
-<li><a class="reference internal" href="#modifyimage" id="id69">modifyImage</a></li>
-<li><a class="reference internal" href="#modulate" id="id70">modulate</a></li>
-<li><a class="reference internal" href="#motionblur" id="id71">motionBlur</a></li>
-<li><a class="reference internal" href="#negate" id="id72">negate</a></li>
-<li><a class="reference internal" href="#normalize" id="id73">normalize</a></li>
-<li><a class="reference internal" href="#oilpaint" id="id74">oilPaint</a></li>
-<li><a class="reference internal" href="#opacity" id="id75">opacity</a></li>
-<li><a class="reference internal" href="#opaque" id="id76">opaque</a></li>
-<li><a class="reference internal" href="#quantize" id="id77">quantize</a></li>
-<li><a class="reference internal" href="#quantumoperator" id="id78">quantumOperator</a></li>
-<li><a class="reference internal" href="#process" id="id79">process</a></li>
-<li><a class="reference internal" href="#raise" id="id80">raise</a></li>
-<li><a class="reference internal" href="#randomthreshold" id="id81">randomThreshold</a></li>
-<li><a class="reference internal" href="#randomthresholdchannel" id="id82">randomThresholdChannel</a></li>
-<li><a class="reference internal" href="#reducenoise" id="id83">reduceNoise</a></li>
-<li><a class="reference internal" href="#resize" id="id84">resize</a></li>
-<li><a class="reference internal" href="#roll" id="id85">roll</a></li>
-<li><a class="reference internal" href="#rotate" id="id86">rotate</a></li>
-<li><a class="reference internal" href="#sample" id="id87">sample</a></li>
-<li><a class="reference internal" href="#scale" id="id88">scale</a></li>
-<li><a class="reference internal" href="#thumbnail" id="id89">thumbnail</a></li>
-<li><a class="reference internal" href="#segment" id="id90">segment</a></li>
-<li><a class="reference internal" href="#shade" id="id91">shade</a></li>
-<li><a class="reference internal" href="#sharpen" id="id92">sharpen</a></li>
-<li><a class="reference internal" href="#sharpenchannel" id="id93">sharpenChannel</a></li>
-<li><a class="reference internal" href="#shave" id="id94">shave</a></li>
-<li><a class="reference internal" href="#shear" id="id95">shear</a></li>
-<li><a class="reference internal" href="#solarize" id="id96">solarize</a></li>
-<li><a class="reference internal" href="#spread" id="id97">spread</a></li>
-<li><a class="reference internal" href="#stegano" id="id98">stegano</a></li>
-<li><a class="reference internal" href="#stereo" id="id99">stereo</a></li>
-<li><a class="reference internal" href="#strip" id="id100">strip</a></li>
-<li><a class="reference internal" href="#swirl" id="id101">swirl</a></li>
-<li><a class="reference internal" href="#texture" id="id102">texture</a></li>
-<li><a class="reference internal" href="#threshold" id="id103">threshold</a></li>
-<li><a class="reference internal" href="#transform" id="id104">transform</a></li>
-<li><a class="reference internal" href="#transparent" id="id105">transparent</a></li>
-<li><a class="reference internal" href="#trim" id="id106">trim</a></li>
-<li><a class="reference internal" href="#type" id="id107">type</a></li>
-<li><a class="reference internal" href="#unsharpmask" id="id108">unsharpmask</a></li>
-<li><a class="reference internal" href="#unsharpmaskchannel" id="id109">unsharpmaskChannel</a></li>
-<li><a class="reference internal" href="#wave" id="id110">wave</a></li>
-<li><a class="reference internal" href="#zoom" id="id111">zoom</a></li>
+<li><a class="reference internal" href="#autoorient" id="id24">autoOrient</a></li>
+<li><a class="reference internal" href="#blur" id="id25">blur</a></li>
+<li><a class="reference internal" href="#blurchannel" id="id26">blurChannel</a></li>
+<li><a class="reference internal" href="#border" id="id27">border</a></li>
+<li><a class="reference internal" href="#cdl" id="id28">cdl</a></li>
+<li><a class="reference internal" href="#channel" id="id29">channel</a></li>
+<li><a class="reference internal" href="#channeldepth" id="id30">channelDepth</a></li>
+<li><a class="reference internal" href="#charcoal" id="id31">charcoal</a></li>
+<li><a class="reference internal" href="#chop" id="id32">chop</a></li>
+<li><a class="reference internal" href="#colorize" id="id33">colorize</a></li>
+<li><a class="reference internal" href="#colormatrix" id="id34">colorMatrix</a></li>
+<li><a class="reference internal" href="#comment" id="id35">comment</a></li>
+<li><a class="reference internal" href="#compare" id="id36">compare</a></li>
+<li><a class="reference internal" href="#composite" id="id37">composite</a></li>
+<li><a class="reference internal" href="#contrast" id="id38">contrast</a></li>
+<li><a class="reference internal" href="#convolve" id="id39">convolve</a></li>
+<li><a class="reference internal" href="#crop" id="id40">crop</a></li>
+<li><a class="reference internal" href="#cyclecolormap" id="id41">cycleColormap</a></li>
+<li><a class="reference internal" href="#despeckle" id="id42">despeckle</a></li>
+<li><a class="reference internal" href="#display" id="id43">display</a></li>
+<li><a class="reference internal" href="#draw" id="id44">draw</a></li>
+<li><a class="reference internal" href="#edge" id="id45">edge</a></li>
+<li><a class="reference internal" href="#emboss" id="id46">emboss</a></li>
+<li><a class="reference internal" href="#enhance" id="id47">enhance</a></li>
+<li><a class="reference internal" href="#equalize" id="id48">equalize</a></li>
+<li><a class="reference internal" href="#erase" id="id49">erase</a></li>
+<li><a class="reference internal" href="#extent" id="id50">extent</a></li>
+<li><a class="reference internal" href="#flip" id="id51">flip</a></li>
+<li><a class="reference internal" href="#floodfillcolor" id="id52">floodFillColor</a></li>
+<li><a class="reference internal" href="#floodfillopacity" id="id53">floodFillOpacity</a></li>
+<li><a class="reference internal" href="#floodfilltexture" id="id54">floodFillTexture</a></li>
+<li><a class="reference internal" href="#flop" id="id55">flop</a></li>
+<li><a class="reference internal" href="#frame" id="id56">frame</a></li>
+<li><a class="reference internal" href="#gamma" id="id57">gamma</a></li>
+<li><a class="reference internal" href="#gaussianblur" id="id58">gaussianBlur</a></li>
+<li><a class="reference internal" href="#gaussianblurchannel" id="id59">gaussianBlurChannel</a></li>
+<li><a class="reference internal" href="#implode" id="id60">implode</a></li>
+<li><a class="reference internal" href="#haldclut" id="id61">haldClut</a></li>
+<li><a class="reference internal" href="#label" id="id62">label</a></li>
+<li><a class="reference internal" href="#level" id="id63">level</a></li>
+<li><a class="reference internal" href="#levelchannel" id="id64">levelChannel</a></li>
+<li><a class="reference internal" href="#magnify" id="id65">magnify</a></li>
+<li><a class="reference internal" href="#map" id="id66">map</a></li>
+<li><a class="reference internal" href="#mattefloodfill" id="id67">matteFloodfill</a></li>
+<li><a class="reference internal" href="#medianfilter" id="id68">medianFilter</a></li>
+<li><a class="reference internal" href="#minify" id="id69">minify</a></li>
+<li><a class="reference internal" href="#modifyimage" id="id70">modifyImage</a></li>
+<li><a class="reference internal" href="#modulate" id="id71">modulate</a></li>
+<li><a class="reference internal" href="#motionblur" id="id72">motionBlur</a></li>
+<li><a class="reference internal" href="#negate" id="id73">negate</a></li>
+<li><a class="reference internal" href="#normalize" id="id74">normalize</a></li>
+<li><a class="reference internal" href="#oilpaint" id="id75">oilPaint</a></li>
+<li><a class="reference internal" href="#opacity" id="id76">opacity</a></li>
+<li><a class="reference internal" href="#opaque" id="id77">opaque</a></li>
+<li><a class="reference internal" href="#quantize" id="id78">quantize</a></li>
+<li><a class="reference internal" href="#quantumoperator" id="id79">quantumOperator</a></li>
+<li><a class="reference internal" href="#process" id="id80">process</a></li>
+<li><a class="reference internal" href="#raise" id="id81">raise</a></li>
+<li><a class="reference internal" href="#randomthreshold" id="id82">randomThreshold</a></li>
+<li><a class="reference internal" href="#randomthresholdchannel" id="id83">randomThresholdChannel</a></li>
+<li><a class="reference internal" href="#reducenoise" id="id84">reduceNoise</a></li>
+<li><a class="reference internal" href="#resize" id="id85">resize</a></li>
+<li><a class="reference internal" href="#roll" id="id86">roll</a></li>
+<li><a class="reference internal" href="#rotate" id="id87">rotate</a></li>
+<li><a class="reference internal" href="#sample" id="id88">sample</a></li>
+<li><a class="reference internal" href="#scale" id="id89">scale</a></li>
+<li><a class="reference internal" href="#thumbnail" id="id90">thumbnail</a></li>
+<li><a class="reference internal" href="#segment" id="id91">segment</a></li>
+<li><a class="reference internal" href="#shade" id="id92">shade</a></li>
+<li><a class="reference internal" href="#sharpen" id="id93">sharpen</a></li>
+<li><a class="reference internal" href="#sharpenchannel" id="id94">sharpenChannel</a></li>
+<li><a class="reference internal" href="#shave" id="id95">shave</a></li>
+<li><a class="reference internal" href="#shear" id="id96">shear</a></li>
+<li><a class="reference internal" href="#solarize" id="id97">solarize</a></li>
+<li><a class="reference internal" href="#spread" id="id98">spread</a></li>
+<li><a class="reference internal" href="#stegano" id="id99">stegano</a></li>
+<li><a class="reference internal" href="#stereo" id="id100">stereo</a></li>
+<li><a class="reference internal" href="#strip" id="id101">strip</a></li>
+<li><a class="reference internal" href="#swirl" id="id102">swirl</a></li>
+<li><a class="reference internal" href="#texture" id="id103">texture</a></li>
+<li><a class="reference internal" href="#threshold" id="id104">threshold</a></li>
+<li><a class="reference internal" href="#transform" id="id105">transform</a></li>
+<li><a class="reference internal" href="#transparent" id="id106">transparent</a></li>
+<li><a class="reference internal" href="#trim" id="id107">trim</a></li>
+<li><a class="reference internal" href="#type" id="id108">type</a></li>
+<li><a class="reference internal" href="#unsharpmask" id="id109">unsharpmask</a></li>
+<li><a class="reference internal" href="#unsharpmaskchannel" id="id110">unsharpmaskChannel</a></li>
+<li><a class="reference internal" href="#wave" id="id111">wave</a></li>
+<li><a class="reference internal" href="#zoom" id="id112">zoom</a></li>
 </ul>
 </div>
 <div class="section" id="adaptivethreshold">
@@ -629,8 +630,17 @@ void            annotate ( const std::string &amp;text_,
                            const GravityType gravity_ )
 </pre>
 </div>
+<div class="section" id="autoorient">
+<h2><a class="toc-backref" href="#id24">autoOrient</a></h2>
+<p>Automatically orient image to be right-side up based on its current
+orientation attribute.  This allows the image to be viewed correctly
+when the orientation attribute is not available, or is not respected:</p>
+<pre class="literal-block">
+void            autoOrient( void )
+</pre>
+</div>
 <div class="section" id="blur">
-<h2><a class="toc-backref" href="#id24">blur</a></h2>
+<h2><a class="toc-backref" href="#id25">blur</a></h2>
 <p>Blur an image with the specified blur factor.</p>
 <p>The <cite>radius</cite> parameter specifies the radius of the Gaussian, in
 pixels, not counting the center pixel.  The <cite>sigma</cite> parameter
@@ -641,7 +651,7 @@ void            blur ( const double radius_ = 0.0,
 </pre>
 </div>
 <div class="section" id="blurchannel">
-<h2><a class="toc-backref" href="#id25">blurChannel</a></h2>
+<h2><a class="toc-backref" href="#id26">blurChannel</a></h2>
 <p>Blur an image channel with the specified blur factor.</p>
 <p>The <cite>channel</cite> parameter specifies the channel to modify. The <cite>radius</cite>
 parameter specifies the radius of the Gaussian, in pixels, not
@@ -654,7 +664,7 @@ void            blurChannel ( const ChannelType channel_,
 </pre>
 </div>
 <div class="section" id="border">
-<h2><a class="toc-backref" href="#id26">border</a></h2>
+<h2><a class="toc-backref" href="#id27">border</a></h2>
 <p>Border image (add border to image).  The <a class="reference external" href="Color.html">color</a> of the border is
 specified by the borderColor attribute:</p>
 <pre class="literal-block">
@@ -663,7 +673,7 @@ void            border ( const Geometry &amp;geometry_
 </pre>
 </div>
 <div class="section" id="cdl">
-<h2><a class="toc-backref" href="#id27">cdl</a></h2>
+<h2><a class="toc-backref" href="#id28">cdl</a></h2>
 <p>Bake in the ASC-CDL, which is a convention for the for the exchange of
 basic primary color grading information between for the exchange of
 basic primary color grading information between equipment and software
@@ -674,7 +684,7 @@ void            cdl ( const std::string &amp;cdl_ )</blockquote>
 <p>See <a class="reference external" href="../api/cdl.html#cdlimage">CdlImage</a> for more details on the ASC-CDL.</p>
 </div>
 <div class="section" id="channel">
-<h2><a class="toc-backref" href="#id28">channel</a></h2>
+<h2><a class="toc-backref" href="#id29">channel</a></h2>
 <p>Extract channel from image. Use this option to extract a particular
 channel from the image.  MatteChannel for example, is useful for
 extracting the opacity values from an image:</p>
@@ -683,7 +693,7 @@ void            channel ( const ChannelType channel_ )
 </pre>
 </div>
 <div class="section" id="channeldepth">
-<h2><a class="toc-backref" href="#id29">channelDepth</a></h2>
+<h2><a class="toc-backref" href="#id30">channelDepth</a></h2>
 <p>Set or obtain modulus channel depth:</p>
 <pre class="literal-block">
 void            channelDepth ( const ChannelType channel_,
@@ -693,7 +703,7 @@ unsigned int    channelDepth ( const ChannelType channel_ )
 </pre>
 </div>
 <div class="section" id="charcoal">
-<h2><a class="toc-backref" href="#id30">charcoal</a></h2>
+<h2><a class="toc-backref" href="#id31">charcoal</a></h2>
 <p>Charcoal effect image (looks like charcoal sketch).</p>
 <p>The <cite>radius</cite> parameter specifies the radius of the Gaussian, in
 pixels, not counting the center pixel.  The <cite>sigma</cite> parameter
@@ -704,14 +714,14 @@ void            charcoal ( const double radius_ = 0.0,
 </pre>
 </div>
 <div class="section" id="chop">
-<h2><a class="toc-backref" href="#id31">chop</a></h2>
+<h2><a class="toc-backref" href="#id32">chop</a></h2>
 <p>Chop image (remove vertical or horizontal subregion of image):</p>
 <pre class="literal-block">
 void            chop ( const Geometry &amp;geometry_ )
 </pre>
 </div>
 <div class="section" id="colorize">
-<h2><a class="toc-backref" href="#id32">colorize</a></h2>
+<h2><a class="toc-backref" href="#id33">colorize</a></h2>
 <p>Colorize image with pen <a class="reference external" href="Color.html">color</a>, using specified percent opacity for
 red, green, and blue quantums:</p>
 <pre class="literal-block">
@@ -727,7 +737,7 @@ void            colorize ( const unsigned int opacity_,
 </pre>
 </div>
 <div class="section" id="colormatrix">
-<h2><a class="toc-backref" href="#id33">colorMatrix</a></h2>
+<h2><a class="toc-backref" href="#id34">colorMatrix</a></h2>
 <p>Apply a color matrix to the image channels.  The user supplied matrix
 may be of order 1 to 5 (1x1 through 5x5):</p>
 <pre class="literal-block">
@@ -737,7 +747,7 @@ void            colorMatrix (const unsigned int order_,
 <p>See <a class="reference external" href="../api/fx.html#colormatriximage">ColorMatrixImage</a> for more details.</p>
 </div>
 <div class="section" id="comment">
-<h2><a class="toc-backref" href="#id34">comment</a></h2>
+<h2><a class="toc-backref" href="#id35">comment</a></h2>
 <p>Comment image (add comment string to image). By default, each image is
 commented with its file name. Use this method to assign a specific
 comment to the image.  Optionally you can include the image filename,
@@ -748,7 +758,7 @@ void            comment ( const std::string &amp;comment_ )
 </pre>
 </div>
 <div class="section" id="compare">
-<h2><a class="toc-backref" href="#id35">compare</a></h2>
+<h2><a class="toc-backref" href="#id36">compare</a></h2>
 <p>Compare current image with another image.  Sets meanErrorPerPixel,
 normalizedMaxError, and normalizedMeanError in the current
 image. False is returned if the images are identical. An ErrorOption
@@ -759,7 +769,7 @@ bool            compare ( const Image &amp;reference_ )
 </pre>
 </div>
 <div class="section" id="composite">
-<h2><a class="toc-backref" href="#id36">composite</a></h2>
+<h2><a class="toc-backref" href="#id37">composite</a></h2>
 <p>Compose an image onto another at specified x and y offset and using a
 specified algorithm:</p>
 <pre class="literal-block">
@@ -781,14 +791,14 @@ void            composite ( const Image &amp;compositeImage_,
 </pre>
 </div>
 <div class="section" id="contrast">
-<h2><a class="toc-backref" href="#id37">contrast</a></h2>
+<h2><a class="toc-backref" href="#id38">contrast</a></h2>
 <p>Contrast image (enhance intensity differences in image):</p>
 <pre class="literal-block">
 void            contrast ( const unsigned int sharpen_ )
 </pre>
 </div>
 <div class="section" id="convolve">
-<h2><a class="toc-backref" href="#id38">convolve</a></h2>
+<h2><a class="toc-backref" href="#id39">convolve</a></h2>
 <p>Convolve image.  Applies a user-specified convolution to the image.
 The <cite>order</cite> parameter represents the number of columns and rows in the
 filter kernel while <cite>kernel</cite> is a two-dimensional array of doubles
@@ -799,28 +809,28 @@ void            convolve ( const unsigned int order_,
 </pre>
 </div>
 <div class="section" id="crop">
-<h2><a class="toc-backref" href="#id39">crop</a></h2>
+<h2><a class="toc-backref" href="#id40">crop</a></h2>
 <p>Crop image (return subregion of original image):</p>
 <pre class="literal-block">
 void            crop ( const Geometry &amp;geometry_ )
 </pre>
 </div>
 <div class="section" id="cyclecolormap">
-<h2><a class="toc-backref" href="#id40">cycleColormap</a></h2>
+<h2><a class="toc-backref" href="#id41">cycleColormap</a></h2>
 <p>Cycle (rotate) image colormap:</p>
 <pre class="literal-block">
 void            cycleColormap ( const int amount_ )
 </pre>
 </div>
 <div class="section" id="despeckle">
-<h2><a class="toc-backref" href="#id41">despeckle</a></h2>
+<h2><a class="toc-backref" href="#id42">despeckle</a></h2>
 <p>Despeckle image (reduce speckle noise):</p>
 <pre class="literal-block">
 void            despeckle ( void )
 </pre>
 </div>
 <div class="section" id="display">
-<h2><a class="toc-backref" href="#id42">display</a></h2>
+<h2><a class="toc-backref" href="#id43">display</a></h2>
 <p>Display image on screen. Caution: if an image format is is not
 compatible with the display visual (e.g. JPEG on a colormapped
 display) then the original image will be altered. Use a copy of the
@@ -829,7 +839,7 @@ original if this is a problem:</p>
 void            display ( void )</blockquote>
 </div>
 <div class="section" id="draw">
-<h2><a class="toc-backref" href="#id43">draw</a></h2>
+<h2><a class="toc-backref" href="#id44">draw</a></h2>
 <p>Draw shape or text on image using a single <a class="reference external" href="Drawable.html">drawable</a> object:</p>
 <pre class="literal-block">
 void            draw ( const Drawable &amp;drawable_ );
@@ -843,7 +853,7 @@ void            draw ( const std::list&lt;Magick::Drawable&gt; &amp;drawable_ );
 </pre>
 </div>
 <div class="section" id="edge">
-<h2><a class="toc-backref" href="#id44">edge</a></h2>
+<h2><a class="toc-backref" href="#id45">edge</a></h2>
 <p>Edge image (hilight edges in image).  The radius is the radius of the
 pixel neighborhood.. Specify a radius of zero for automatic radius
 selection:</p>
@@ -852,7 +862,7 @@ void            edge ( const double radius_ = 0.0 )
 </pre>
 </div>
 <div class="section" id="emboss">
-<h2><a class="toc-backref" href="#id45">emboss</a></h2>
+<h2><a class="toc-backref" href="#id46">emboss</a></h2>
 <p>Emboss image (hilight edges with 3D effect).  The <cite>radius</cite> parameter
 specifies the radius of the Gaussian, in pixels, not counting the
 center pixel.  The <cite>sigma</cite> parameter specifies the standard deviation
@@ -863,28 +873,28 @@ void            emboss ( const double radius_ = 0.0,
 </pre>
 </div>
 <div class="section" id="enhance">
-<h2><a class="toc-backref" href="#id46">enhance</a></h2>
+<h2><a class="toc-backref" href="#id47">enhance</a></h2>
 <p>Enhance image (minimize noise):</p>
 <pre class="literal-block">
 void            enhance ( void );
 </pre>
 </div>
 <div class="section" id="equalize">
-<h2><a class="toc-backref" href="#id47">equalize</a></h2>
+<h2><a class="toc-backref" href="#id48">equalize</a></h2>
 <p>Equalize image (histogram equalization):</p>
 <pre class="literal-block">
 void            equalize ( void )
 </pre>
 </div>
 <div class="section" id="erase">
-<h2><a class="toc-backref" href="#id48">erase</a></h2>
+<h2><a class="toc-backref" href="#id49">erase</a></h2>
 <p>Set all image pixels to the current background color:</p>
 <pre class="literal-block">
 void            erase ( void )
 </pre>
 </div>
 <div class="section" id="extent">
-<h2><a class="toc-backref" href="#id49">extent</a></h2>
+<h2><a class="toc-backref" href="#id50">extent</a></h2>
 <p>Create an image canvas using background color sized according to
 geometry and composite existing image on it, with image placement
 controlled by gravity.  Parameters are obtained from existing image
@@ -906,14 +916,14 @@ void            extent ( const Geometry &amp;geometry_,
 </pre>
 </div>
 <div class="section" id="flip">
-<h2><a class="toc-backref" href="#id50">flip</a></h2>
+<h2><a class="toc-backref" href="#id51">flip</a></h2>
 <p>Flip image (reflect each scanline in the vertical direction):</p>
 <pre class="literal-block">
 void            flip ( void )
 </pre>
 </div>
 <div class="section" id="floodfillcolor">
-<h2><a class="toc-backref" href="#id51">floodFillColor</a></h2>
+<h2><a class="toc-backref" href="#id52">floodFillColor</a></h2>
 <p>Flood-fill <a class="reference external" href="Color.html">color</a> across pixels that match the <a class="reference external" href="Color.html">color</a> of the target
 pixel and are neighbors of the target pixel.  Uses current fuzz
 setting when determining <a class="reference external" href="Color.html">color</a> match:</p>
@@ -940,7 +950,7 @@ void            floodFillColor( const Geometry &amp;point_,
 </pre>
 </div>
 <div class="section" id="floodfillopacity">
-<h2><a class="toc-backref" href="#id52">floodFillOpacity</a></h2>
+<h2><a class="toc-backref" href="#id53">floodFillOpacity</a></h2>
 <p>Flood-fill pixels matching <a class="reference external" href="Color.html">color</a> (within fuzz factor) of target
 pixel(x,y) with replacement opacity value using method:</p>
 <pre class="literal-block">
@@ -951,7 +961,7 @@ void            floodFillOpacity ( const unsigned int x_,
 </pre>
 </div>
 <div class="section" id="floodfilltexture">
-<h2><a class="toc-backref" href="#id53">floodFillTexture</a></h2>
+<h2><a class="toc-backref" href="#id54">floodFillTexture</a></h2>
 <p>Flood-fill texture across pixels that match the <a class="reference external" href="Color.html">color</a> of the
 target pixel and are neighbors of the target pixel.
 Uses current fuzz setting when determining <a class="reference external" href="Color.html">color</a> match:</p>
@@ -978,14 +988,14 @@ void            floodFillTexture( const Geometry &amp;point_,
 </pre>
 </div>
 <div class="section" id="flop">
-<h2><a class="toc-backref" href="#id54">flop</a></h2>
+<h2><a class="toc-backref" href="#id55">flop</a></h2>
 <p>Flop image (reflect each scanline in the horizontal direction):</p>
 <pre class="literal-block">
 void            flop ( void );
 </pre>
 </div>
 <div class="section" id="frame">
-<h2><a class="toc-backref" href="#id55">frame</a></h2>
+<h2><a class="toc-backref" href="#id56">frame</a></h2>
 <p>Draw a decorative frame around the image:</p>
 <pre class="literal-block">
 void            frame ( const Geometry &amp;geometry_ = frameGeometryDefault )
@@ -997,7 +1007,7 @@ void            frame ( const unsigned int width_,
 </pre>
 </div>
 <div class="section" id="gamma">
-<h2><a class="toc-backref" href="#id56">gamma</a></h2>
+<h2><a class="toc-backref" href="#id57">gamma</a></h2>
 <p>Gamma correct the image or individual image channels:</p>
 <pre class="literal-block">
 void            gamma ( const double gamma_ )
@@ -1008,7 +1018,7 @@ void            gamma ( const double gammaRed_,
 </pre>
 </div>
 <div class="section" id="gaussianblur">
-<h2><a class="toc-backref" href="#id57">gaussianBlur</a></h2>
+<h2><a class="toc-backref" href="#id58">gaussianBlur</a></h2>
 <p>Gaussian blur image.  The number of neighbor pixels to be included in
 the convolution mask is specified by <cite>width</cite>. The standard deviation
 of the gaussian bell curve is specified by <cite>sigma</cite>:</p>
@@ -1017,7 +1027,7 @@ void            gaussianBlur ( const double width_, const double sigma_ )
 </pre>
 </div>
 <div class="section" id="gaussianblurchannel">
-<h2><a class="toc-backref" href="#id58">gaussianBlurChannel</a></h2>
+<h2><a class="toc-backref" href="#id59">gaussianBlurChannel</a></h2>
 <p>Gaussian blur image channel.  The number of neighbor pixels to be
 included in the convolution mask is specified by <cite>width</cite>. The
 standard deviation of the gaussian bell curve is specified by
@@ -1029,14 +1039,14 @@ void            gaussianBlurChannel ( const ChannelType channel_,
 </pre>
 </div>
 <div class="section" id="implode">
-<h2><a class="toc-backref" href="#id59">implode</a></h2>
+<h2><a class="toc-backref" href="#id60">implode</a></h2>
 <p>Implode image (special effect):</p>
 <pre class="literal-block">
 void            implode ( const double factor_ )
 </pre>
 </div>
 <div class="section" id="haldclut">
-<h2><a class="toc-backref" href="#id60">haldClut</a></h2>
+<h2><a class="toc-backref" href="#id61">haldClut</a></h2>
 <p>Apply a color lookup table (Hald CLUT) to the image:</p>
 <pre class="literal-block">
 void            haldClut ( const Image &amp;clutImage_ )
@@ -1044,7 +1054,7 @@ void            haldClut ( const Image &amp;clutImage_ )
 <p>See <a class="reference external" href="../api/hclut.html#haldclutimage">HaldClutImage</a> for more details.</p>
 </div>
 <div class="section" id="label">
-<h2><a class="toc-backref" href="#id61">label</a></h2>
+<h2><a class="toc-backref" href="#id62">label</a></h2>
 <p>Assign a label to an image. Use this option to assign a specific label
 to the image. Optionally you can include the image filename, type,
 width, height, or scene number in the label by embedding <a class="reference external" href="FormatCharacters.html">special
@@ -1057,7 +1067,7 @@ void            label ( const std::string &amp;label_ )
 </pre>
 </div>
 <div class="section" id="level">
-<h2><a class="toc-backref" href="#id62">level</a></h2>
+<h2><a class="toc-backref" href="#id63">level</a></h2>
 <p>Level image to increase image contrast, and/or adjust image
 gamma. Adjust the levels of the image by scaling the colors falling
 between specified white and black points to the full available quantum
@@ -1076,7 +1086,7 @@ void            level ( const double black_point,
 </pre>
 </div>
 <div class="section" id="levelchannel">
-<h2><a class="toc-backref" href="#id63">levelChannel</a></h2>
+<h2><a class="toc-backref" href="#id64">levelChannel</a></h2>
 <p>Level image channel to increase image contrast, and/or adjust image
 gamma. Adjust the levels of the image channel by scaling the colors
 falling between specified white and black points to the full available
@@ -1096,14 +1106,14 @@ void            levelChannel ( const ChannelType channel,
 </pre>
 </div>
 <div class="section" id="magnify">
-<h2><a class="toc-backref" href="#id64">magnify</a></h2>
+<h2><a class="toc-backref" href="#id65">magnify</a></h2>
 <p>Magnify image by integral size (double the dimensions):</p>
 <pre class="literal-block">
 void            magnify ( void )
 </pre>
 </div>
 <div class="section" id="map">
-<h2><a class="toc-backref" href="#id65">map</a></h2>
+<h2><a class="toc-backref" href="#id66">map</a></h2>
 <p>Remap image colors with closest color from a reference image. Set
 <cite>dither</cite> to true in to apply Floyd/Steinberg error diffusion to the
 image. By default, color reduction chooses an optimal set of colors
@@ -1115,7 +1125,7 @@ void            map ( const Image &amp;mapImage_ ,
 </pre>
 </div>
 <div class="section" id="mattefloodfill">
-<h2><a class="toc-backref" href="#id66">matteFloodfill</a></h2>
+<h2><a class="toc-backref" href="#id67">matteFloodfill</a></h2>
 <p>Floodfill designated area with a replacement opacity value:</p>
 <pre class="literal-block">
 void            matteFloodfill ( const Color &amp;target_ ,
@@ -1125,7 +1135,7 @@ void            matteFloodfill ( const Color &amp;target_ ,
 </pre>
 </div>
 <div class="section" id="medianfilter">
-<h2><a class="toc-backref" href="#id67">medianFilter</a></h2>
+<h2><a class="toc-backref" href="#id68">medianFilter</a></h2>
 <p>Filter image by replacing each pixel component with the median color
 in a circular neighborhood:</p>
 <pre class="literal-block">
@@ -1133,14 +1143,14 @@ void            medianFilter ( const double radius_ = 0.0 )
 </pre>
 </div>
 <div class="section" id="minify">
-<h2><a class="toc-backref" href="#id68">minify</a></h2>
+<h2><a class="toc-backref" href="#id69">minify</a></h2>
 <p>Reduce image by integral (half) size:</p>
 <pre class="literal-block">
 void            minify ( void )
 </pre>
 </div>
 <div class="section" id="modifyimage">
-<h2><a class="toc-backref" href="#id69">modifyImage</a></h2>
+<h2><a class="toc-backref" href="#id70">modifyImage</a></h2>
 <p>Prepare to update image (copy if reference &gt; 1). Normally Magick++'s
 implicit reference counting takes care of all instance management.  In
 the rare case that the automatic instance management does not work,
@@ -1153,7 +1163,7 @@ void            modifyImage ( void )
 </pre>
 </div>
 <div class="section" id="modulate">
-<h2><a class="toc-backref" href="#id70">modulate</a></h2>
+<h2><a class="toc-backref" href="#id71">modulate</a></h2>
 <p>Modulate percent hue, saturation, and brightness of an image.
 Modulation of saturation and brightness is as a ratio of the current
 value (1.0 for no change). Modulation of hue is an absolute rotation
@@ -1166,7 +1176,7 @@ void            modulate ( const double brightness_,
 </pre>
 </div>
 <div class="section" id="motionblur">
-<h2><a class="toc-backref" href="#id71">motionBlur</a></h2>
+<h2><a class="toc-backref" href="#id72">motionBlur</a></h2>
 <p>Motion blur image with specified blur factor. The <cite>radius</cite> parameter
 specifies the radius of the Gaussian, in pixels, not counting the
 center pixel.  The <cite>sigma</cite> parameter specifies the standard
@@ -1180,7 +1190,7 @@ void            motionBlur ( const double radius_,
 </pre>
 </div>
 <div class="section" id="negate">
-<h2><a class="toc-backref" href="#id72">negate</a></h2>
+<h2><a class="toc-backref" href="#id73">negate</a></h2>
 <p>Negate colors in image.  Set <cite>grayscale</cite> to only negate grayscale
 values in image:</p>
 <pre class="literal-block">
@@ -1188,7 +1198,7 @@ void            negate ( const bool grayscale_ = false )
 </pre>
 </div>
 <div class="section" id="normalize">
-<h2><a class="toc-backref" href="#id73">normalize</a></h2>
+<h2><a class="toc-backref" href="#id74">normalize</a></h2>
 <p>Normalize image (increase contrast by normalizing the pixel values to
 span the full range of color values):</p>
 <pre class="literal-block">
@@ -1196,14 +1206,14 @@ void            normalize ( void )
 </pre>
 </div>
 <div class="section" id="oilpaint">
-<h2><a class="toc-backref" href="#id74">oilPaint</a></h2>
+<h2><a class="toc-backref" href="#id75">oilPaint</a></h2>
 <p>Oilpaint image (image looks like an oil painting):</p>
 <pre class="literal-block">
 void            oilPaint ( const double radius_ = 3.0 )
 </pre>
 </div>
 <div class="section" id="opacity">
-<h2><a class="toc-backref" href="#id75">opacity</a></h2>
+<h2><a class="toc-backref" href="#id76">opacity</a></h2>
 <p>Set or attenuate the opacity channel in the image. If the image pixels
 are opaque then they are set to the specified opacity value, otherwise
 they are blended with the supplied opacity value.  The value of
@@ -1215,7 +1225,7 @@ void            opacity ( const unsigned int opacity_ )
 </pre>
 </div>
 <div class="section" id="opaque">
-<h2><a class="toc-backref" href="#id76">opaque</a></h2>
+<h2><a class="toc-backref" href="#id77">opaque</a></h2>
 <p>Change <a class="reference external" href="Color.html">color</a> of specified opaque pixel to specified pen <a class="reference external" href="Color.html">color</a>:</p>
 <pre class="literal-block">
 void            opaque ( const Color &amp;opaqueColor_,
@@ -1223,7 +1233,7 @@ void            opaque ( const Color &amp;opaqueColor_,
 </pre>
 </div>
 <div class="section" id="quantize">
-<h2><a class="toc-backref" href="#id77">quantize</a></h2>
+<h2><a class="toc-backref" href="#id78">quantize</a></h2>
 <p>Quantize image (reduce number of colors). Set <cite>measureError</cite> to true
 in order to calculate error attributes:</p>
 <pre class="literal-block">
@@ -1231,7 +1241,7 @@ void            quantize ( const bool measureError_ = false )
 </pre>
 </div>
 <div class="section" id="quantumoperator">
-<h2><a class="toc-backref" href="#id78">quantumOperator</a></h2>
+<h2><a class="toc-backref" href="#id79">quantumOperator</a></h2>
 <p>Apply an arithmetic or bitwise operator to the image pixel quantums:</p>
 <pre class="literal-block">
 void            quantumOperator ( const ChannelType channel_,
@@ -1247,7 +1257,7 @@ void            quantumOperator ( const int x_,const int y_,
 </pre>
 </div>
 <div class="section" id="process">
-<h2><a class="toc-backref" href="#id79">process</a></h2>
+<h2><a class="toc-backref" href="#id80">process</a></h2>
 <p>Execute a named process module using an argc/argv syntax similar to
 that accepted by a C 'main' routine. An exception is thrown if the
 requested process module doesn't exist, fails to load, or fails during
@@ -1259,7 +1269,7 @@ void            process ( std::string name_,
 </pre>
 </div>
 <div class="section" id="raise">
-<h2><a class="toc-backref" href="#id80">raise</a></h2>
+<h2><a class="toc-backref" href="#id81">raise</a></h2>
 <p>Raise image (lighten or darken the edges of an image to give a 3-D
 raised or lowered effect):</p>
 <pre class="literal-block">
@@ -1268,7 +1278,7 @@ void            raise ( const Geometry &amp;geometry_ = &quot;6x6+0+0&quot;,
 </pre>
 </div>
 <div class="section" id="randomthreshold">
-<h2><a class="toc-backref" href="#id81">randomThreshold</a></h2>
+<h2><a class="toc-backref" href="#id82">randomThreshold</a></h2>
 <p>Random threshold image.</p>
 <p>Changes the value of individual pixels based on the intensity
 of each pixel compared to a random threshold.  The result is a
@@ -1283,7 +1293,7 @@ void            randomThreshold( const Geometry &amp;thresholds_ )
 </pre>
 </div>
 <div class="section" id="randomthresholdchannel">
-<h2><a class="toc-backref" href="#id82">randomThresholdChannel</a></h2>
+<h2><a class="toc-backref" href="#id83">randomThresholdChannel</a></h2>
 <p>Random threshold image channel.</p>
 <p>Changes the value of individual pixels based on the intensity of each
 pixel compared to a random threshold.  The result is a low-contrast,
@@ -1299,7 +1309,7 @@ void            randomThresholdChannel( const Geometry &amp;thresholds_,
 </pre>
 </div>
 <div class="section" id="reducenoise">
-<h2><a class="toc-backref" href="#id83">reduceNoise</a></h2>
+<h2><a class="toc-backref" href="#id84">reduceNoise</a></h2>
 <p>Reduce noise in image using a noise peak elimination filter:</p>
 <pre class="literal-block">
 void            reduceNoise ( void )
@@ -1308,7 +1318,7 @@ void            reduceNoise ( const double order_ )
 </pre>
 </div>
 <div class="section" id="resize">
-<h2><a class="toc-backref" href="#id84">resize</a></h2>
+<h2><a class="toc-backref" href="#id85">resize</a></h2>
 <p>Resize image, specifying geometry, filter, and blur (blur &gt; 1.0 is
 more blurry and &lt; 1.0 is sharper):</p>
 <pre class="literal-block">
@@ -1329,7 +1339,7 @@ void            resize ( const Geometry &amp;geometry_ );
 </pre>
 </div>
 <div class="section" id="roll">
-<h2><a class="toc-backref" href="#id85">roll</a></h2>
+<h2><a class="toc-backref" href="#id86">roll</a></h2>
 <p>Roll image (rolls image vertically and horizontally) by specified
 number of columnms and rows):</p>
 <pre class="literal-block">
@@ -1340,21 +1350,21 @@ void            roll ( const unsigned int columns_,
 </pre>
 </div>
 <div class="section" id="rotate">
-<h2><a class="toc-backref" href="#id86">rotate</a></h2>
+<h2><a class="toc-backref" href="#id87">rotate</a></h2>
 <p>Rotate image counter-clockwise by specified number of degrees:</p>
 <pre class="literal-block">
 void            rotate ( const double degrees_ )
 </pre>
 </div>
 <div class="section" id="sample">
-<h2><a class="toc-backref" href="#id87">sample</a></h2>
+<h2><a class="toc-backref" href="#id88">sample</a></h2>
 <p>Resize image by using pixel sampling algorithm:</p>
 <pre class="literal-block">
 void            sample ( const Geometry &amp;geometry_ )
 </pre>
 </div>
 <div class="section" id="scale">
-<h2><a class="toc-backref" href="#id88">scale</a></h2>
+<h2><a class="toc-backref" href="#id89">scale</a></h2>
 <p>Resize image by using simple ratio algorithm which provides good
 quality:</p>
 <pre class="literal-block">
@@ -1362,7 +1372,7 @@ void            scale ( const Geometry &amp;geometry_ )
 </pre>
 </div>
 <div class="section" id="thumbnail">
-<h2><a class="toc-backref" href="#id89">thumbnail</a></h2>
+<h2><a class="toc-backref" href="#id90">thumbnail</a></h2>
 <p>Resize image using several algorithms to make smaller images very
 quickly.  This is very useful to create thumbnails from large images
 but usually works well for any image resizing purpose:</p>
@@ -1371,7 +1381,7 @@ void            thumbnail ( const Geometry &amp;geometry_ );
 </pre>
 </div>
 <div class="section" id="segment">
-<h2><a class="toc-backref" href="#id90">segment</a></h2>
+<h2><a class="toc-backref" href="#id91">segment</a></h2>
 <p>Segment (coalesce similar image components) by analyzing the
 histograms of the color components and identifying units that are
 homogeneous with the fuzzy c-means technique.  A histogram is built
@@ -1392,7 +1402,7 @@ void            segment ( const double clusterThreshold_ = 1.0,
 </pre>
 </div>
 <div class="section" id="shade">
-<h2><a class="toc-backref" href="#id91">shade</a></h2>
+<h2><a class="toc-backref" href="#id92">shade</a></h2>
 <p>Shade image using distant light source. Specify <cite>azimuth</cite> and
 <cite>elevation</cite> as the position of the light source. By default, the
 shading results as a grayscale image.. Set <cite>colorShading</cite> to true to
@@ -1404,7 +1414,7 @@ void            shade ( const double azimuth_ = 30,
 </pre>
 </div>
 <div class="section" id="sharpen">
-<h2><a class="toc-backref" href="#id92">sharpen</a></h2>
+<h2><a class="toc-backref" href="#id93">sharpen</a></h2>
 <p>Sharpen pixels in image.  The <cite>radius</cite> parameter specifies the radius
 of the Gaussian, in pixels, not counting the center pixel.  The
 <cite>sigma</cite> parameter specifies the standard deviation of the Laplacian,
@@ -1415,7 +1425,7 @@ void            sharpen ( const double radius_ = 0.0,
 </pre>
 </div>
 <div class="section" id="sharpenchannel">
-<h2><a class="toc-backref" href="#id93">sharpenChannel</a></h2>
+<h2><a class="toc-backref" href="#id94">sharpenChannel</a></h2>
 <p>Sharpen pixels in image channel.  The <cite>radius</cite> parameter specifies the
 radius of the Gaussian, in pixels, not counting the center pixel.  The
 <cite>sigma</cite> parameter specifies the standard deviation of the Laplacian,
@@ -1427,14 +1437,14 @@ void            sharpenChannel ( const ChannelType channel_,
 </pre>
 </div>
 <div class="section" id="shave">
-<h2><a class="toc-backref" href="#id94">shave</a></h2>
+<h2><a class="toc-backref" href="#id95">shave</a></h2>
 <p>Shave pixels from image edges:</p>
 <pre class="literal-block">
 void            shave ( const Geometry &amp;geometry_ )
 </pre>
 </div>
 <div class="section" id="shear">
-<h2><a class="toc-backref" href="#id95">shear</a></h2>
+<h2><a class="toc-backref" href="#id96">shear</a></h2>
 <p>Shear image (create parallelogram by sliding image by X or Y
 axis). Shearing slides one edge of an image along the X or Y axis,
 creating a parallelogram.  An X direction shear slides an edge along
@@ -1450,7 +1460,7 @@ void            shear ( const double xShearAngle_,
 </pre>
 </div>
 <div class="section" id="solarize">
-<h2><a class="toc-backref" href="#id96">solarize</a></h2>
+<h2><a class="toc-backref" href="#id97">solarize</a></h2>
 <p>Solarize image (similar to effect seen when exposing a photographic
 film to light during the development process):</p>
 <pre class="literal-block">
@@ -1458,21 +1468,21 @@ void            solarize ( const double factor_ = 50.0 )
 </pre>
 </div>
 <div class="section" id="spread">
-<h2><a class="toc-backref" href="#id97">spread</a></h2>
+<h2><a class="toc-backref" href="#id98">spread</a></h2>
 <p>Spread pixels randomly within image by specified ammount:</p>
 <pre class="literal-block">
 void            spread ( const unsigned int amount_ = 3 )
 </pre>
 </div>
 <div class="section" id="stegano">
-<h2><a class="toc-backref" href="#id98">stegano</a></h2>
+<h2><a class="toc-backref" href="#id99">stegano</a></h2>
 <p>Add a digital watermark to the image (based on second image):</p>
 <pre class="literal-block">
 void            stegano ( const Image &amp;watermark_ )
 </pre>
 </div>
 <div class="section" id="stereo">
-<h2><a class="toc-backref" href="#id99">stereo</a></h2>
+<h2><a class="toc-backref" href="#id100">stereo</a></h2>
 <p>Create an image which appears in stereo when viewed with red-blue
 glasses (Red image on left, blue on right):</p>
 <pre class="literal-block">
@@ -1480,27 +1490,27 @@ void            stereo ( const Image &amp;rightImage_ )
 </pre>
 </div>
 <div class="section" id="strip">
-<h2><a class="toc-backref" href="#id100">strip</a></h2>
+<h2><a class="toc-backref" href="#id101">strip</a></h2>
 <p>Remove all profiles and text attributes from the image.</p>
 <blockquote>
 void            strip ( void );</blockquote>
 </div>
 <div class="section" id="swirl">
-<h2><a class="toc-backref" href="#id101">swirl</a></h2>
+<h2><a class="toc-backref" href="#id102">swirl</a></h2>
 <p>Swirl image (image pixels are rotated by degrees):</p>
 <pre class="literal-block">
 void            swirl ( const double degrees_ )
 </pre>
 </div>
 <div class="section" id="texture">
-<h2><a class="toc-backref" href="#id102">texture</a></h2>
+<h2><a class="toc-backref" href="#id103">texture</a></h2>
 <p>Channel a texture on pixels matching image background <a class="reference external" href="Color.html">color</a>:</p>
 <pre class="literal-block">
 void            texture ( const Image &amp;texture_ )
 </pre>
 </div>
 <div class="section" id="threshold">
-<h2><a class="toc-backref" href="#id103">threshold</a></h2>
+<h2><a class="toc-backref" href="#id104">threshold</a></h2>
 <p>Threshold image channels (below threshold becomes black, above
 threshold becomes white).  The range of the threshold parameter is 0
 to MaxRGB:</p>
@@ -1509,7 +1519,7 @@ void            threshold ( const double threshold_ )
 </pre>
 </div>
 <div class="section" id="transform">
-<h2><a class="toc-backref" href="#id104">transform</a></h2>
+<h2><a class="toc-backref" href="#id105">transform</a></h2>
 <p>Transform image based on image and crop geometries. Crop geometry is
 optional:</p>
 <pre class="literal-block">
@@ -1520,7 +1530,7 @@ void            transform ( const Geometry &amp;imageGeometry_,
 </pre>
 </div>
 <div class="section" id="transparent">
-<h2><a class="toc-backref" href="#id105">transparent</a></h2>
+<h2><a class="toc-backref" href="#id106">transparent</a></h2>
 <p>Add matte channel to image, setting pixels matching <a class="reference external" href="Color.html">color</a> to
 transparent:</p>
 <pre class="literal-block">
@@ -1528,14 +1538,14 @@ void            transparent ( const Color &amp;color_ )
 </pre>
 </div>
 <div class="section" id="trim">
-<h2><a class="toc-backref" href="#id106">trim</a></h2>
+<h2><a class="toc-backref" href="#id107">trim</a></h2>
 <p>Trim edges that are the background <a class="reference external" href="Color.html">color</a> from the image:</p>
 <pre class="literal-block">
 void            trim ( void )
 </pre>
 </div>
 <div class="section" id="type">
-<h2><a class="toc-backref" href="#id107">type</a></h2>
+<h2><a class="toc-backref" href="#id108">type</a></h2>
 <p>Convert the image representation to the specified type or retrieve the
 current image type.  If the image is reduced to an inferior type, then
 image information may be lost (e.g. color changed to grayscale).</p>
@@ -1571,7 +1581,7 @@ ImageType       type ( void ) const
 </pre>
 </div>
 <div class="section" id="unsharpmask">
-<h2><a class="toc-backref" href="#id108">unsharpmask</a></h2>
+<h2><a class="toc-backref" href="#id109">unsharpmask</a></h2>
 <p>Replace image with a sharpened version of the original image using the
 unsharp mask algorithm.</p>
 <blockquote>
@@ -1596,7 +1606,7 @@ void            unsharpmask ( const double radius_,
 </pre>
 </div>
 <div class="section" id="unsharpmaskchannel">
-<h2><a class="toc-backref" href="#id109">unsharpmaskChannel</a></h2>
+<h2><a class="toc-backref" href="#id110">unsharpmaskChannel</a></h2>
 <p>Replace image channel with a sharpened version of the original image
 using the unsharp mask algorithm.</p>
 <blockquote>
@@ -1624,7 +1634,7 @@ void            unsharpmaskChannel ( const ChannelType channel_,
 </pre>
 </div>
 <div class="section" id="wave">
-<h2><a class="toc-backref" href="#id110">wave</a></h2>
+<h2><a class="toc-backref" href="#id111">wave</a></h2>
 <p>Map image pixels to a sine wave:</p>
 <pre class="literal-block">
 void            wave ( const double amplitude_ = 25.0,
@@ -1632,7 +1642,7 @@ void            wave ( const double amplitude_ = 25.0,
 </pre>
 </div>
 <div class="section" id="zoom">
-<h2><a class="toc-backref" href="#id111">zoom</a></h2>
+<h2><a class="toc-backref" href="#id112">zoom</a></h2>
 <p>Zoom (resize) image to specified size:</p>
 <pre class="literal-block">
 void            zoom ( const Geometry &amp;geometry_ )
@@ -1659,117 +1669,117 @@ image.write(filename)
 <p>The following image attribute methods are available:</p>
 <div class="contents local topic" id="id3">
 <ul class="simple">
-<li><a class="reference internal" href="#adjoin" id="id112">adjoin</a></li>
-<li><a class="reference internal" href="#antialias" id="id113">antiAlias</a></li>
-<li><a class="reference internal" href="#animationdelay" id="id114">animationDelay</a></li>
-<li><a class="reference internal" href="#animationiterations" id="id115">animationIterations</a></li>
-<li><a class="reference internal" href="#attribute" id="id116">attribute</a></li>
-<li><a class="reference internal" href="#backgroundcolor" id="id117">backgroundColor</a></li>
-<li><a class="reference internal" href="#backgroundtexture" id="id118">backgroundTexture</a></li>
-<li><a class="reference internal" href="#basecolumns" id="id119">baseColumns</a></li>
-<li><a class="reference internal" href="#basefilename" id="id120">baseFilename</a></li>
-<li><a class="reference internal" href="#baserows" id="id121">baseRows</a></li>
-<li><a class="reference internal" href="#bordercolor" id="id122">borderColor</a></li>
-<li><a class="reference internal" href="#boundingbox" id="id123">boundingBox</a></li>
-<li><a class="reference internal" href="#boxcolor" id="id124">boxColor</a></li>
-<li><a class="reference internal" href="#cachethreshold" id="id125">cacheThreshold</a></li>
-<li><a class="reference internal" href="#chromablueprimary" id="id126">chromaBluePrimary</a></li>
-<li><a class="reference internal" href="#chromagreenprimary" id="id127">chromaGreenPrimary</a></li>
-<li><a class="reference internal" href="#chromaredprimary" id="id128">chromaRedPrimary</a></li>
-<li><a class="reference internal" href="#chromawhitepoint" id="id129">chromaWhitePoint</a></li>
-<li><a class="reference internal" href="#classtype" id="id130">classType</a></li>
-<li><a class="reference internal" href="#clipmask" id="id131">clipMask</a></li>
-<li><a class="reference internal" href="#colorfuzz" id="id132">colorFuzz</a></li>
-<li><a class="reference internal" href="#colormap" id="id133">colorMap</a></li>
-<li><a class="reference internal" href="#colormapsize" id="id134">colorMapSize</a></li>
-<li><a class="reference internal" href="#colorspace" id="id135">colorSpace</a></li>
-<li><a class="reference internal" href="#columns" id="id136">columns</a></li>
-<li><a class="reference internal" href="#id4" id="id137">comment</a></li>
-<li><a class="reference internal" href="#compose" id="id138">compose</a></li>
-<li><a class="reference internal" href="#compresstype" id="id139">compressType</a></li>
-<li><a class="reference internal" href="#debug" id="id140">debug</a></li>
-<li><a class="reference internal" href="#definevalue" id="id141">defineValue</a></li>
-<li><a class="reference internal" href="#defineset" id="id142">defineSet</a></li>
-<li><a class="reference internal" href="#density" id="id143">density</a></li>
-<li><a class="reference internal" href="#depth" id="id144">depth</a></li>
-<li><a class="reference internal" href="#directory" id="id145">directory</a></li>
-<li><a class="reference internal" href="#endian" id="id146">endian</a></li>
-<li><a class="reference internal" href="#filename" id="id147">fileName</a></li>
-<li><a class="reference internal" href="#filesize" id="id148">fileSize</a></li>
-<li><a class="reference internal" href="#fillcolor" id="id149">fillColor</a></li>
-<li><a class="reference internal" href="#fillpattern" id="id150">fillPattern</a></li>
-<li><a class="reference internal" href="#fillrule" id="id151">fillRule</a></li>
-<li><a class="reference internal" href="#filtertype" id="id152">filterType</a></li>
-<li><a class="reference internal" href="#font" id="id153">font</a></li>
-<li><a class="reference internal" href="#fontpointsize" id="id154">fontPointsize</a></li>
-<li><a class="reference internal" href="#fonttypemetrics" id="id155">fontTypeMetrics</a></li>
-<li><a class="reference internal" href="#format" id="id156">format</a></li>
-<li><a class="reference internal" href="#formatexpression" id="id157">formatExpression</a></li>
-<li><a class="reference internal" href="#id5" id="id158">gamma</a></li>
-<li><a class="reference internal" href="#id6" id="id159">geometry</a></li>
-<li><a class="reference internal" href="#gifdisposemethod" id="id160">gifDisposeMethod</a></li>
-<li><a class="reference internal" href="#icccolorprofile" id="id161">iccColorProfile</a></li>
-<li><a class="reference internal" href="#interlacetype" id="id162">interlaceType</a></li>
-<li><a class="reference internal" href="#iptcprofile" id="id163">iptcProfile</a></li>
-<li><a class="reference internal" href="#isvalid" id="id164">isValid</a></li>
-<li><a class="reference internal" href="#id7" id="id165">label</a></li>
-<li><a class="reference internal" href="#linewidth" id="id166">lineWidth</a></li>
-<li><a class="reference internal" href="#magick" id="id167">magick</a></li>
-<li><a class="reference internal" href="#matte" id="id168">matte</a></li>
-<li><a class="reference internal" href="#mattecolor" id="id169">matteColor</a></li>
-<li><a class="reference internal" href="#meanerrorperpixel" id="id170">meanErrorPerPixel</a></li>
-<li><a class="reference internal" href="#modulusdepth" id="id171">modulusDepth</a></li>
-<li><a class="reference internal" href="#monochrome" id="id172">monochrome</a></li>
-<li><a class="reference internal" href="#montagegeometry" id="id173">montageGeometry</a></li>
-<li><a class="reference internal" href="#normalizedmaxerror" id="id174">normalizedMaxError</a></li>
-<li><a class="reference internal" href="#normalizedmeanerror" id="id175">normalizedMeanError</a></li>
-<li><a class="reference internal" href="#orientation" id="id176">orientation</a></li>
-<li><a class="reference internal" href="#page" id="id177">page</a></li>
-<li><a class="reference internal" href="#pixelcolor" id="id178">pixelColor</a></li>
-<li><a class="reference internal" href="#profile" id="id179">profile</a></li>
-<li><a class="reference internal" href="#quality" id="id180">quality</a></li>
-<li><a class="reference internal" href="#quantizecolors" id="id181">quantizeColors</a></li>
-<li><a class="reference internal" href="#quantizecolorspace" id="id182">quantizeColorSpace</a></li>
-<li><a class="reference internal" href="#quantizedither" id="id183">quantizeDither</a></li>
-<li><a class="reference internal" href="#quantizetreedepth" id="id184">quantizeTreeDepth</a></li>
-<li><a class="reference internal" href="#quiet" id="id185">quiet</a></li>
-<li><a class="reference internal" href="#renderingintent" id="id186">renderingIntent</a></li>
-<li><a class="reference internal" href="#repage" id="id187">repage</a></li>
-<li><a class="reference internal" href="#resolutionunits" id="id188">resolutionUnits</a></li>
-<li><a class="reference internal" href="#rows" id="id189">rows</a></li>
-<li><a class="reference internal" href="#scene" id="id190">scene</a></li>
-<li><a class="reference internal" href="#signature" id="id191">signature</a></li>
-<li><a class="reference internal" href="#size" id="id192">size</a></li>
-<li><a class="reference internal" href="#statistics" id="id193">statistics</a></li>
-<li><a class="reference internal" href="#strokeantialias" id="id194">strokeAntiAlias</a></li>
-<li><a class="reference internal" href="#strokecolor" id="id195">strokeColor</a></li>
-<li><a class="reference internal" href="#strokedasharray" id="id196">strokeDashArray</a></li>
-<li><a class="reference internal" href="#strokedashoffset" id="id197">strokeDashOffset</a></li>
-<li><a class="reference internal" href="#strokelinecap" id="id198">strokeLineCap</a></li>
-<li><a class="reference internal" href="#strokelinejoin" id="id199">strokeLineJoin</a></li>
-<li><a class="reference internal" href="#strokemiterlimit" id="id200">strokeMiterLimit</a></li>
-<li><a class="reference internal" href="#strokepattern" id="id201">strokePattern</a></li>
-<li><a class="reference internal" href="#strokewidth" id="id202">strokeWidth</a></li>
-<li><a class="reference internal" href="#subimage" id="id203">subImage</a></li>
-<li><a class="reference internal" href="#subrange" id="id204">subRange</a></li>
-<li><a class="reference internal" href="#textencoding" id="id205">textEncoding</a></li>
-<li><a class="reference internal" href="#tilename" id="id206">tileName</a></li>
-<li><a class="reference internal" href="#totalcolors" id="id207">totalColors</a></li>
-<li><a class="reference internal" href="#transformorigin" id="id208">transformOrigin</a></li>
-<li><a class="reference internal" href="#transformrotation" id="id209">transformRotation</a></li>
-<li><a class="reference internal" href="#transformreset" id="id210">transformReset</a></li>
-<li><a class="reference internal" href="#transformscale" id="id211">transformScale</a></li>
-<li><a class="reference internal" href="#transformskewx" id="id212">transformSkewX</a></li>
-<li><a class="reference internal" href="#transformskewy" id="id213">transformSkewY</a></li>
-<li><a class="reference internal" href="#verbose" id="id214">verbose</a></li>
-<li><a class="reference internal" href="#view" id="id215">view</a></li>
-<li><a class="reference internal" href="#x11display" id="id216">x11Display</a></li>
-<li><a class="reference internal" href="#xresolution" id="id217">xResolution</a></li>
-<li><a class="reference internal" href="#yresolution" id="id218">yResolution</a></li>
+<li><a class="reference internal" href="#adjoin" id="id113">adjoin</a></li>
+<li><a class="reference internal" href="#antialias" id="id114">antiAlias</a></li>
+<li><a class="reference internal" href="#animationdelay" id="id115">animationDelay</a></li>
+<li><a class="reference internal" href="#animationiterations" id="id116">animationIterations</a></li>
+<li><a class="reference internal" href="#attribute" id="id117">attribute</a></li>
+<li><a class="reference internal" href="#backgroundcolor" id="id118">backgroundColor</a></li>
+<li><a class="reference internal" href="#backgroundtexture" id="id119">backgroundTexture</a></li>
+<li><a class="reference internal" href="#basecolumns" id="id120">baseColumns</a></li>
+<li><a class="reference internal" href="#basefilename" id="id121">baseFilename</a></li>
+<li><a class="reference internal" href="#baserows" id="id122">baseRows</a></li>
+<li><a class="reference internal" href="#bordercolor" id="id123">borderColor</a></li>
+<li><a class="reference internal" href="#boundingbox" id="id124">boundingBox</a></li>
+<li><a class="reference internal" href="#boxcolor" id="id125">boxColor</a></li>
+<li><a class="reference internal" href="#cachethreshold" id="id126">cacheThreshold</a></li>
+<li><a class="reference internal" href="#chromablueprimary" id="id127">chromaBluePrimary</a></li>
+<li><a class="reference internal" href="#chromagreenprimary" id="id128">chromaGreenPrimary</a></li>
+<li><a class="reference internal" href="#chromaredprimary" id="id129">chromaRedPrimary</a></li>
+<li><a class="reference internal" href="#chromawhitepoint" id="id130">chromaWhitePoint</a></li>
+<li><a class="reference internal" href="#classtype" id="id131">classType</a></li>
+<li><a class="reference internal" href="#clipmask" id="id132">clipMask</a></li>
+<li><a class="reference internal" href="#colorfuzz" id="id133">colorFuzz</a></li>
+<li><a class="reference internal" href="#colormap" id="id134">colorMap</a></li>
+<li><a class="reference internal" href="#colormapsize" id="id135">colorMapSize</a></li>
+<li><a class="reference internal" href="#colorspace" id="id136">colorSpace</a></li>
+<li><a class="reference internal" href="#columns" id="id137">columns</a></li>
+<li><a class="reference internal" href="#id4" id="id138">comment</a></li>
+<li><a class="reference internal" href="#compose" id="id139">compose</a></li>
+<li><a class="reference internal" href="#compresstype" id="id140">compressType</a></li>
+<li><a class="reference internal" href="#debug" id="id141">debug</a></li>
+<li><a class="reference internal" href="#definevalue" id="id142">defineValue</a></li>
+<li><a class="reference internal" href="#defineset" id="id143">defineSet</a></li>
+<li><a class="reference internal" href="#density" id="id144">density</a></li>
+<li><a class="reference internal" href="#depth" id="id145">depth</a></li>
+<li><a class="reference internal" href="#directory" id="id146">directory</a></li>
+<li><a class="reference internal" href="#endian" id="id147">endian</a></li>
+<li><a class="reference internal" href="#filename" id="id148">fileName</a></li>
+<li><a class="reference internal" href="#filesize" id="id149">fileSize</a></li>
+<li><a class="reference internal" href="#fillcolor" id="id150">fillColor</a></li>
+<li><a class="reference internal" href="#fillpattern" id="id151">fillPattern</a></li>
+<li><a class="reference internal" href="#fillrule" id="id152">fillRule</a></li>
+<li><a class="reference internal" href="#filtertype" id="id153">filterType</a></li>
+<li><a class="reference internal" href="#font" id="id154">font</a></li>
+<li><a class="reference internal" href="#fontpointsize" id="id155">fontPointsize</a></li>
+<li><a class="reference internal" href="#fonttypemetrics" id="id156">fontTypeMetrics</a></li>
+<li><a class="reference internal" href="#format" id="id157">format</a></li>
+<li><a class="reference internal" href="#formatexpression" id="id158">formatExpression</a></li>
+<li><a class="reference internal" href="#id5" id="id159">gamma</a></li>
+<li><a class="reference internal" href="#id6" id="id160">geometry</a></li>
+<li><a class="reference internal" href="#gifdisposemethod" id="id161">gifDisposeMethod</a></li>
+<li><a class="reference internal" href="#icccolorprofile" id="id162">iccColorProfile</a></li>
+<li><a class="reference internal" href="#interlacetype" id="id163">interlaceType</a></li>
+<li><a class="reference internal" href="#iptcprofile" id="id164">iptcProfile</a></li>
+<li><a class="reference internal" href="#isvalid" id="id165">isValid</a></li>
+<li><a class="reference internal" href="#id7" id="id166">label</a></li>
+<li><a class="reference internal" href="#linewidth" id="id167">lineWidth</a></li>
+<li><a class="reference internal" href="#magick" id="id168">magick</a></li>
+<li><a class="reference internal" href="#matte" id="id169">matte</a></li>
+<li><a class="reference internal" href="#mattecolor" id="id170">matteColor</a></li>
+<li><a class="reference internal" href="#meanerrorperpixel" id="id171">meanErrorPerPixel</a></li>
+<li><a class="reference internal" href="#modulusdepth" id="id172">modulusDepth</a></li>
+<li><a class="reference internal" href="#monochrome" id="id173">monochrome</a></li>
+<li><a class="reference internal" href="#montagegeometry" id="id174">montageGeometry</a></li>
+<li><a class="reference internal" href="#normalizedmaxerror" id="id175">normalizedMaxError</a></li>
+<li><a class="reference internal" href="#normalizedmeanerror" id="id176">normalizedMeanError</a></li>
+<li><a class="reference internal" href="#orientation" id="id177">orientation</a></li>
+<li><a class="reference internal" href="#page" id="id178">page</a></li>
+<li><a class="reference internal" href="#pixelcolor" id="id179">pixelColor</a></li>
+<li><a class="reference internal" href="#profile" id="id180">profile</a></li>
+<li><a class="reference internal" href="#quality" id="id181">quality</a></li>
+<li><a class="reference internal" href="#quantizecolors" id="id182">quantizeColors</a></li>
+<li><a class="reference internal" href="#quantizecolorspace" id="id183">quantizeColorSpace</a></li>
+<li><a class="reference internal" href="#quantizedither" id="id184">quantizeDither</a></li>
+<li><a class="reference internal" href="#quantizetreedepth" id="id185">quantizeTreeDepth</a></li>
+<li><a class="reference internal" href="#quiet" id="id186">quiet</a></li>
+<li><a class="reference internal" href="#renderingintent" id="id187">renderingIntent</a></li>
+<li><a class="reference internal" href="#repage" id="id188">repage</a></li>
+<li><a class="reference internal" href="#resolutionunits" id="id189">resolutionUnits</a></li>
+<li><a class="reference internal" href="#rows" id="id190">rows</a></li>
+<li><a class="reference internal" href="#scene" id="id191">scene</a></li>
+<li><a class="reference internal" href="#signature" id="id192">signature</a></li>
+<li><a class="reference internal" href="#size" id="id193">size</a></li>
+<li><a class="reference internal" href="#statistics" id="id194">statistics</a></li>
+<li><a class="reference internal" href="#strokeantialias" id="id195">strokeAntiAlias</a></li>
+<li><a class="reference internal" href="#strokecolor" id="id196">strokeColor</a></li>
+<li><a class="reference internal" href="#strokedasharray" id="id197">strokeDashArray</a></li>
+<li><a class="reference internal" href="#strokedashoffset" id="id198">strokeDashOffset</a></li>
+<li><a class="reference internal" href="#strokelinecap" id="id199">strokeLineCap</a></li>
+<li><a class="reference internal" href="#strokelinejoin" id="id200">strokeLineJoin</a></li>
+<li><a class="reference internal" href="#strokemiterlimit" id="id201">strokeMiterLimit</a></li>
+<li><a class="reference internal" href="#strokepattern" id="id202">strokePattern</a></li>
+<li><a class="reference internal" href="#strokewidth" id="id203">strokeWidth</a></li>
+<li><a class="reference internal" href="#subimage" id="id204">subImage</a></li>
+<li><a class="reference internal" href="#subrange" id="id205">subRange</a></li>
+<li><a class="reference internal" href="#textencoding" id="id206">textEncoding</a></li>
+<li><a class="reference internal" href="#tilename" id="id207">tileName</a></li>
+<li><a class="reference internal" href="#totalcolors" id="id208">totalColors</a></li>
+<li><a class="reference internal" href="#transformorigin" id="id209">transformOrigin</a></li>
+<li><a class="reference internal" href="#transformrotation" id="id210">transformRotation</a></li>
+<li><a class="reference internal" href="#transformreset" id="id211">transformReset</a></li>
+<li><a class="reference internal" href="#transformscale" id="id212">transformScale</a></li>
+<li><a class="reference internal" href="#transformskewx" id="id213">transformSkewX</a></li>
+<li><a class="reference internal" href="#transformskewy" id="id214">transformSkewY</a></li>
+<li><a class="reference internal" href="#verbose" id="id215">verbose</a></li>
+<li><a class="reference internal" href="#view" id="id216">view</a></li>
+<li><a class="reference internal" href="#x11display" id="id217">x11Display</a></li>
+<li><a class="reference internal" href="#xresolution" id="id218">xResolution</a></li>
+<li><a class="reference internal" href="#yresolution" id="id219">yResolution</a></li>
 </ul>
 </div>
 <div class="section" id="adjoin">
-<h2><a class="toc-backref" href="#id112">adjoin</a></h2>
+<h2><a class="toc-backref" href="#id113">adjoin</a></h2>
 <p>Join images into a single multi-image file:</p>
 <pre class="literal-block">
 void            adjoin ( const bool flag_ )
@@ -1778,7 +1788,7 @@ bool            adjoin ( void ) const
 </pre>
 </div>
 <div class="section" id="antialias">
-<h2><a class="toc-backref" href="#id113">antiAlias</a></h2>
+<h2><a class="toc-backref" href="#id114">antiAlias</a></h2>
 <p>Control antialiasing of rendered Postscript and Postscript or TrueType
 fonts. Enabled by default:</p>
 <pre class="literal-block">
@@ -1788,7 +1798,7 @@ bool            antiAlias( void )
 </pre>
 </div>
 <div class="section" id="animationdelay">
-<h2><a class="toc-backref" href="#id114">animationDelay</a></h2>
+<h2><a class="toc-backref" href="#id115">animationDelay</a></h2>
 <p>Time in 1/100ths of a second (0 to 65535) which must expire before
 displaying the next image in an animated sequence. This option is
 useful for regulating the animation of a sequence of GIF images within
@@ -1800,7 +1810,7 @@ unsigned int    animationDelay ( void ) const
 </pre>
 </div>
 <div class="section" id="animationiterations">
-<h2><a class="toc-backref" href="#id115">animationIterations</a></h2>
+<h2><a class="toc-backref" href="#id116">animationIterations</a></h2>
 <p>Number of iterations to loop an animation (e.g. Netscape loop
 extension) for:</p>
 <pre class="literal-block">
@@ -1810,7 +1820,7 @@ unsigned int    animationIterations ( void ) const
 </pre>
 </div>
 <div class="section" id="attribute">
-<h2><a class="toc-backref" href="#id116">attribute</a></h2>
+<h2><a class="toc-backref" href="#id117">attribute</a></h2>
 <p>Access or update an arbitrary named image attribute. Any number of
 named attributes may be attached to the image. For example, the image
 comment is a named image attribute with the name &quot;comment&quot;.  If the
@@ -1831,7 +1841,7 @@ std::string     attribute ( const std::string name_ )
 </pre>
 </div>
 <div class="section" id="backgroundcolor">
-<h2><a class="toc-backref" href="#id117">backgroundColor</a></h2>
+<h2><a class="toc-backref" href="#id118">backgroundColor</a></h2>
 <p>Image background <a class="reference external" href="Color.html">color</a>:</p>
 <pre class="literal-block">
 void            backgroundColor ( const Color &amp;color_ )
@@ -1840,7 +1850,7 @@ Color           backgroundColor ( void ) const
 </pre>
 </div>
 <div class="section" id="backgroundtexture">
-<h2><a class="toc-backref" href="#id118">backgroundTexture</a></h2>
+<h2><a class="toc-backref" href="#id119">backgroundTexture</a></h2>
 <p>Image file name to use as the background texture. Does not modify
 image pixels:</p>
 <pre class="literal-block">
@@ -1850,28 +1860,28 @@ std::string     backgroundTexture ( void ) const
 </pre>
 </div>
 <div class="section" id="basecolumns">
-<h2><a class="toc-backref" href="#id119">baseColumns</a></h2>
+<h2><a class="toc-backref" href="#id120">baseColumns</a></h2>
 <p>Base image width (before transformations):</p>
 <pre class="literal-block">
 unsigned int    baseColumns ( void ) const
 </pre>
 </div>
 <div class="section" id="basefilename">
-<h2><a class="toc-backref" href="#id120">baseFilename</a></h2>
+<h2><a class="toc-backref" href="#id121">baseFilename</a></h2>
 <p>Base image filename (before transformations):</p>
 <pre class="literal-block">
 std::string     baseFilename ( void ) const
 </pre>
 </div>
 <div class="section" id="baserows">
-<h2><a class="toc-backref" href="#id121">baseRows</a></h2>
+<h2><a class="toc-backref" href="#id122">baseRows</a></h2>
 <p>Base image height (before transformations):</p>
 <pre class="literal-block">
 unsigned int    baseRows ( void ) const
 </pre>
 </div>
 <div class="section" id="bordercolor">
-<h2><a class="toc-backref" href="#id122">borderColor</a></h2>
+<h2><a class="toc-backref" href="#id123">borderColor</a></h2>
 <p>Image border <a class="reference external" href="Color.html">color</a>:</p>
 <pre class="literal-block">
 void            borderColor ( const Color &amp;color_ )
@@ -1880,7 +1890,7 @@ Color           borderColor ( void ) const
 </pre>
 </div>
 <div class="section" id="boundingbox">
-<h2><a class="toc-backref" href="#id123">boundingBox</a></h2>
+<h2><a class="toc-backref" href="#id124">boundingBox</a></h2>
 <p>Return smallest bounding box enclosing non-border pixels. The
 current fuzz value is used when discriminating between pixels.
 This is the crop bounding box used by <tt class="docutils literal">crop(Geometry(0,0))</tt>:</p>
@@ -1889,7 +1899,7 @@ Geometry        boundingBox ( void ) const
 </pre>
 </div>
 <div class="section" id="boxcolor">
-<h2><a class="toc-backref" href="#id124">boxColor</a></h2>
+<h2><a class="toc-backref" href="#id125">boxColor</a></h2>
 <p>Base <a class="reference external" href="Color.html">color</a> that annotation text is rendered on (default none):</p>
 <pre class="literal-block">
 void            boxColor ( const Color &amp;boxColor_ )
@@ -1898,7 +1908,7 @@ Color           boxColor ( void ) const
 </pre>
 </div>
 <div class="section" id="cachethreshold">
-<h2><a class="toc-backref" href="#id125">cacheThreshold</a></h2>
+<h2><a class="toc-backref" href="#id126">cacheThreshold</a></h2>
 <p>Pixel cache threshold in megabytes.  Once this memory threshold is
 exceeded, all subsequent pixels cache operations are to/from disk.
 This setting is shared by all Image objects:</p>
@@ -1907,7 +1917,7 @@ static void     cacheThreshold ( const unsigned int threshold_ )
 </pre>
 </div>
 <div class="section" id="chromablueprimary">
-<h2><a class="toc-backref" href="#id126">chromaBluePrimary</a></h2>
+<h2><a class="toc-backref" href="#id127">chromaBluePrimary</a></h2>
 <p>Chromaticity blue primary point (e.g. x=0.15, y=0.06):</p>
 <pre class="literal-block">
 void            chromaBluePrimary ( const double x_, const double y_ )
@@ -1916,7 +1926,7 @@ void            chromaBluePrimary ( double *x_, double *y_ ) const
 </pre>
 </div>
 <div class="section" id="chromagreenprimary">
-<h2><a class="toc-backref" href="#id127">chromaGreenPrimary</a></h2>
+<h2><a class="toc-backref" href="#id128">chromaGreenPrimary</a></h2>
 <p>Chromaticity green primary point (e.g. x=0.3, y=0.6):</p>
 <pre class="literal-block">
 void            chromaGreenPrimary ( const double x_, const double y_ )
@@ -1925,7 +1935,7 @@ void            chromaGreenPrimary ( double *x_, double *y_ ) const
 </pre>
 </div>
 <div class="section" id="chromaredprimary">
-<h2><a class="toc-backref" href="#id128">chromaRedPrimary</a></h2>
+<h2><a class="toc-backref" href="#id129">chromaRedPrimary</a></h2>
 <p>Chromaticity red primary point (e.g. x=0.64, y=0.33):</p>
 <pre class="literal-block">
 void            chromaRedPrimary ( const double x_, const double y_ )
@@ -1934,7 +1944,7 @@ void            chromaRedPrimary ( double *x_, double *y_ ) const
 </pre>
 </div>
 <div class="section" id="chromawhitepoint">
-<h2><a class="toc-backref" href="#id129">chromaWhitePoint</a></h2>
+<h2><a class="toc-backref" href="#id130">chromaWhitePoint</a></h2>
 <p>Chromaticity white point (e.g. x=0.3127, y=0.329):</p>
 <pre class="literal-block">
 void            chromaWhitePoint ( const double x_, const double y_ )
@@ -1942,7 +1952,7 @@ void            chromaWhitePoint ( double *x_, double *y_ ) const
 </pre>
 </div>
 <div class="section" id="classtype">
-<h2><a class="toc-backref" href="#id130">classType</a></h2>
+<h2><a class="toc-backref" href="#id131">classType</a></h2>
 <p>Image class (DirectClass or PseudoClass).  NOTE: setting a DirectClass
 image to PseudoClass will result in the loss of color information if
 the number of colors in the image is greater than the maximum palette
@@ -1955,7 +1965,7 @@ ClassType       classType ( void ) const
 </pre>
 </div>
 <div class="section" id="clipmask">
-<h2><a class="toc-backref" href="#id131">clipMask</a></h2>
+<h2><a class="toc-backref" href="#id132">clipMask</a></h2>
 <p>Associate a clip mask image with the current image. The clip mask
 image must have the same dimensions as the current image or an
 exception is thrown. Clipping occurs wherever pixels are transparent
@@ -1968,7 +1978,7 @@ Image           clipMask ( void  ) const
 </pre>
 </div>
 <div class="section" id="colorfuzz">
-<h2><a class="toc-backref" href="#id132">colorFuzz</a></h2>
+<h2><a class="toc-backref" href="#id133">colorFuzz</a></h2>
 <p>Colors within this distance are considered equal. A number of
 algorithms search for a target color. By default the color must be
 exact. Use this option to match colors that are close to the target
@@ -1980,7 +1990,7 @@ double          colorFuzz ( void ) const
 </pre>
 </div>
 <div class="section" id="colormap">
-<h2><a class="toc-backref" href="#id133">colorMap</a></h2>
+<h2><a class="toc-backref" href="#id134">colorMap</a></h2>
 <p><a class="reference external" href="Color.html">Color</a> at colormap position <cite>index</cite>:</p>
 <pre class="literal-block">
 void            colorMap ( const unsigned int index_,
@@ -1990,7 +2000,7 @@ Color           colorMap ( const unsigned int index_ ) const
 </pre>
 </div>
 <div class="section" id="colormapsize">
-<h2><a class="toc-backref" href="#id134">colorMapSize</a></h2>
+<h2><a class="toc-backref" href="#id135">colorMapSize</a></h2>
 <p>Number of entries in the colormap. Setting the colormap size may
 extend or truncate the colormap. The maximum number of supported
 entries is specified by the MaxColormapSize constant, and is dependent
@@ -2005,7 +2015,7 @@ unsigned int    colorMapSize ( void )
 </pre>
 </div>
 <div class="section" id="colorspace">
-<h2><a class="toc-backref" href="#id135">colorSpace</a></h2>
+<h2><a class="toc-backref" href="#id136">colorSpace</a></h2>
 <p>The colorspace (e.g. CMYK) used to represent the image pixel colors:</p>
 <pre class="literal-block">
 void            colorSpace( const ColorspaceType colorSpace_ )
@@ -2014,21 +2024,21 @@ ColorspaceType  colorSpace ( void ) const
 </pre>
 </div>
 <div class="section" id="columns">
-<h2><a class="toc-backref" href="#id136">columns</a></h2>
+<h2><a class="toc-backref" href="#id137">columns</a></h2>
 <p>Image width:</p>
 <pre class="literal-block">
 unsigned int    columns ( void ) const
 </pre>
 </div>
 <div class="section" id="id4">
-<h2><a class="toc-backref" href="#id137">comment</a></h2>
+<h2><a class="toc-backref" href="#id138">comment</a></h2>
 <p>Image comment:</p>
 <pre class="literal-block">
 std::string     comment ( void ) const
 </pre>
 </div>
 <div class="section" id="compose">
-<h2><a class="toc-backref" href="#id138">compose</a></h2>
+<h2><a class="toc-backref" href="#id139">compose</a></h2>
 <p>Composition operator to be used when composition is implicitly
 used (such as for image flattening):</p>
 <pre class="literal-block">
@@ -2038,7 +2048,7 @@ CompositeOperator compose ( void ) const
 </pre>
 </div>
 <div class="section" id="compresstype">
-<h2><a class="toc-backref" href="#id139">compressType</a></h2>
+<h2><a class="toc-backref" href="#id140">compressType</a></h2>
 <p>Image compresion type. The default is the compression type of the
 input image file:</p>
 <pre class="literal-block">
@@ -2048,7 +2058,7 @@ CompressionType compressType ( void ) const
 </pre>
 </div>
 <div class="section" id="debug">
-<h2><a class="toc-backref" href="#id140">debug</a></h2>
+<h2><a class="toc-backref" href="#id141">debug</a></h2>
 <p>Enable printing of debug messages from GraphicsMagick as it executes:</p>
 <pre class="literal-block">
 void            debug ( const bool flag_ )
@@ -2057,7 +2067,7 @@ bool            debug ( void ) const
 </pre>
 </div>
 <div class="section" id="definevalue">
-<h2><a class="toc-backref" href="#id141">defineValue</a></h2>
+<h2><a class="toc-backref" href="#id142">defineValue</a></h2>
 <p>Set or obtain a definition string to applied when encoding or decoding
 the specified format. The meanings of the definitions are format
 specific. The format is designated by the <cite>magick</cite> argument, the
@@ -2074,7 +2084,7 @@ std::string     defineValue ( const std::string &amp;magick_,
 </pre>
 </div>
 <div class="section" id="defineset">
-<h2><a class="toc-backref" href="#id142">defineSet</a></h2>
+<h2><a class="toc-backref" href="#id143">defineSet</a></h2>
 <p>Set or obtain a definition flag to applied when encoding or decoding
 the specified format. Similar to the defineValue() method except that
 passing the <cite>flag</cite> value 'true' creates a value-less define with that
@@ -2091,7 +2101,7 @@ bool            defineSet ( const std::string &amp;magick_,
 </pre>
 </div>
 <div class="section" id="density">
-<h2><a class="toc-backref" href="#id143">density</a></h2>
+<h2><a class="toc-backref" href="#id144">density</a></h2>
 <p>Vertical and horizontal resolution in pixels of the image. This option
 specifies an image density when decoding a Postscript or Portable
 Document page. Often used with <cite>psPageSize</cite>:</p>
@@ -2109,7 +2119,7 @@ floating point.</p>
 <p>The resolution units may be obtained via the resolutionUnits() method.</p>
 </div>
 <div class="section" id="depth">
-<h2><a class="toc-backref" href="#id144">depth</a></h2>
+<h2><a class="toc-backref" href="#id145">depth</a></h2>
 <p>Image depth (bits allocated to red/green/blue components). Used to
 specify the bit depth when reading or writing raw images or when the
 output format supports multiple depths. Defaults to the quantum depth
@@ -2121,14 +2131,14 @@ unsigned int    depth ( void ) const
 </pre>
 </div>
 <div class="section" id="directory">
-<h2><a class="toc-backref" href="#id145">directory</a></h2>
+<h2><a class="toc-backref" href="#id146">directory</a></h2>
 <p>Tile names from within an image montage:</p>
 <pre class="literal-block">
 std::string     directory ( void ) const
 </pre>
 </div>
 <div class="section" id="endian">
-<h2><a class="toc-backref" href="#id146">endian</a></h2>
+<h2><a class="toc-backref" href="#id147">endian</a></h2>
 <p>Endianness (<cite>LSBEndian</cite> like Intel, <cite>MSBEndian</cite> like SPARC, or
 <cite>NativeEndian</cite> for what this computer uses) for image formats which
 support endian-specific options:</p>
@@ -2139,7 +2149,7 @@ EndianType      endian ( void ) const
 </pre>
 </div>
 <div class="section" id="filename">
-<h2><a class="toc-backref" href="#id147">fileName</a></h2>
+<h2><a class="toc-backref" href="#id148">fileName</a></h2>
 <p>Image file name:</p>
 <pre class="literal-block">
 void            fileName ( const std::string &amp;fileName_ )
@@ -2148,14 +2158,14 @@ std::string     fileName ( void ) const
 </pre>
 </div>
 <div class="section" id="filesize">
-<h2><a class="toc-backref" href="#id148">fileSize</a></h2>
+<h2><a class="toc-backref" href="#id149">fileSize</a></h2>
 <p>Number of bytes of the image on disk:</p>
 <pre class="literal-block">
 off_t          fileSize ( void ) const
 </pre>
 </div>
 <div class="section" id="fillcolor">
-<h2><a class="toc-backref" href="#id149">fillColor</a></h2>
+<h2><a class="toc-backref" href="#id150">fillColor</a></h2>
 <p><a class="reference external" href="Color.html">Color</a> to use when filling drawn objects:</p>
 <pre class="literal-block">
 void            fillColor ( const Color &amp;fillColor_ )
@@ -2164,7 +2174,7 @@ Color           fillColor ( void ) const
 </pre>
 </div>
 <div class="section" id="fillpattern">
-<h2><a class="toc-backref" href="#id150">fillPattern</a></h2>
+<h2><a class="toc-backref" href="#id151">fillPattern</a></h2>
 <p>Pattern to use while filling drawn objects:</p>
 <pre class="literal-block">
 void            fillPattern ( const Image &amp;fillPattern_ )
@@ -2173,7 +2183,7 @@ Image           fillPattern ( void  ) const
 </pre>
 </div>
 <div class="section" id="fillrule">
-<h2><a class="toc-backref" href="#id151">fillRule</a></h2>
+<h2><a class="toc-backref" href="#id152">fillRule</a></h2>
 <p>Rule to use when filling drawn objects:</p>
 <pre class="literal-block">
 void            fillRule ( const FillRule &amp;fillRule_ )
@@ -2182,7 +2192,7 @@ FillRule        fillRule ( void ) const
 </pre>
 </div>
 <div class="section" id="filtertype">
-<h2><a class="toc-backref" href="#id152">filterType</a></h2>
+<h2><a class="toc-backref" href="#id153">filterType</a></h2>
 <p>Filter to use when resizing image. The reduction filter employed has a
 sigificant effect on the time required to resize an image and the
 resulting quality. The default filter is Lanczos which has been shown
@@ -2194,7 +2204,7 @@ FilterTypes     filterType ( void ) const
 </pre>
 </div>
 <div class="section" id="font">
-<h2><a class="toc-backref" href="#id153">font</a></h2>
+<h2><a class="toc-backref" href="#id154">font</a></h2>
 <p>Text rendering font. If the font is a fully qualified X server font
 name, the font is obtained from an X server. To use a TrueType font,
 precede the TrueType filename with an &#64;. Otherwise, specify a
@@ -2206,7 +2216,7 @@ std::string     font ( void ) const
 </pre>
 </div>
 <div class="section" id="fontpointsize">
-<h2><a class="toc-backref" href="#id154">fontPointsize</a></h2>
+<h2><a class="toc-backref" href="#id155">fontPointsize</a></h2>
 <p>Text rendering font point size:</p>
 <pre class="literal-block">
 void            fontPointsize ( const double pointSize_ )
@@ -2215,7 +2225,7 @@ double          fontPointsize ( void ) const
 </pre>
 </div>
 <div class="section" id="fonttypemetrics">
-<h2><a class="toc-backref" href="#id155">fontTypeMetrics</a></h2>
+<h2><a class="toc-backref" href="#id156">fontTypeMetrics</a></h2>
 <p>Obtain font metrics (see <a class="reference external" href="TypeMetric.html">TypeMetric</a>) for text string given current
 font, pointsize, and density settings.  This information is necessary
 in order to do fancy layout of text:</p>
@@ -2225,14 +2235,14 @@ void            fontTypeMetrics( const std::string &amp;text_,
 </pre>
 </div>
 <div class="section" id="format">
-<h2><a class="toc-backref" href="#id156">format</a></h2>
+<h2><a class="toc-backref" href="#id157">format</a></h2>
 <p>Long image format description:</p>
 <pre class="literal-block">
 std::string     format ( void ) const
 </pre>
 </div>
 <div class="section" id="formatexpression">
-<h2><a class="toc-backref" href="#id157">formatExpression</a></h2>
+<h2><a class="toc-backref" href="#id158">formatExpression</a></h2>
 <p>Format a string based on image properties similar to <cite>identify</cite>
 <cite>-format</cite>.  For example, the format expression &quot;%wx%h&quot; is converted to
 a string containing image WIDTHxHEIGHT like &quot;640x480&quot;:</p>
@@ -2244,7 +2254,7 @@ Image object and will assure a reference count of one) and it <em>may</em>
 throw an exception if there is an internal error.</p>
 </div>
 <div class="section" id="id5">
-<h2><a class="toc-backref" href="#id158">gamma</a></h2>
+<h2><a class="toc-backref" href="#id159">gamma</a></h2>
 <p>Gamma level of the image.  Gamma is a pow() function which converts
 between the linear light representation and the representation for the
 computer display.  Most computer images are gamma corrected to 2.2
@@ -2255,14 +2265,14 @@ double          gamma ( void ) const
 </pre>
 </div>
 <div class="section" id="id6">
-<h2><a class="toc-backref" href="#id159">geometry</a></h2>
+<h2><a class="toc-backref" href="#id160">geometry</a></h2>
 <p>Preferred size of the image when encoding:</p>
 <pre class="literal-block">
 Geometry        geometry ( void ) const
 </pre>
 </div>
 <div class="section" id="gifdisposemethod">
-<h2><a class="toc-backref" href="#id160">gifDisposeMethod</a></h2>
+<h2><a class="toc-backref" href="#id161">gifDisposeMethod</a></h2>
 <p>GIF disposal method. This option (specific to the GIF file format) is
 used to control how successive frames are rendered (how the preceding
 frame is disposed of) when creating a GIF animation:</p>
@@ -2273,7 +2283,7 @@ unsigned int    gifDisposeMethod ( void ) const
 </pre>
 </div>
 <div class="section" id="icccolorprofile">
-<h2><a class="toc-backref" href="#id161">iccColorProfile</a></h2>
+<h2><a class="toc-backref" href="#id162">iccColorProfile</a></h2>
 <p>ICC color profile. Supplied via a <a class="reference external" href="Blob.html">Blob</a> since Magick++/ and
 GraphicsMagick do not currently support formating this data structure
 directly.</p>
@@ -2294,7 +2304,7 @@ Blob            iccColorProfile( void ) const
 </pre>
 </div>
 <div class="section" id="interlacetype">
-<h2><a class="toc-backref" href="#id162">interlaceType</a></h2>
+<h2><a class="toc-backref" href="#id163">interlaceType</a></h2>
 <p>The type of interlacing scheme (default <cite>NoInterlace</cite> ). This option
 is used to specify the type of interlacing scheme for raw image
 formats such as RGB or YUV. <cite>NoInterlace</cite> means do not interlace,
@@ -2311,7 +2321,7 @@ InterlaceType   interlaceType ( void ) const
 </pre>
 </div>
 <div class="section" id="iptcprofile">
-<h2><a class="toc-backref" href="#id163">iptcProfile</a></h2>
+<h2><a class="toc-backref" href="#id164">iptcProfile</a></h2>
 <p>IPTC profile. Supplied via a <a class="reference external" href="Blob.html">Blob</a> since Magick++ and GraphicsMagick do
 not currently support formating this data structure
 directly. Specifications are available from the International Press
@@ -2323,7 +2333,7 @@ Blob            iptcProfile( void ) const
 </pre>
 </div>
 <div class="section" id="isvalid">
-<h2><a class="toc-backref" href="#id164">isValid</a></h2>
+<h2><a class="toc-backref" href="#id165">isValid</a></h2>
 <p>Does object contain valid image? Set to <cite>false</cite> in order to invalidate
 the image. Images constructed via the default constructor are invalid
 images and isValid() will return false:</p>
@@ -2334,14 +2344,14 @@ bool            isValid ( void ) const
 </pre>
 </div>
 <div class="section" id="id7">
-<h2><a class="toc-backref" href="#id165">label</a></h2>
+<h2><a class="toc-backref" href="#id166">label</a></h2>
 <p>Image label:</p>
 <pre class="literal-block">
 std::string     label ( void ) const
 </pre>
 </div>
 <div class="section" id="linewidth">
-<h2><a class="toc-backref" href="#id166">lineWidth</a></h2>
+<h2><a class="toc-backref" href="#id167">lineWidth</a></h2>
 <p>Stroke width for drawing vector objects (default one)
 This method is now deprecated. Please use strokeWidth instead:</p>
 <pre class="literal-block">
@@ -2351,7 +2361,7 @@ double          lineWidth ( void ) const
 </pre>
 </div>
 <div class="section" id="magick">
-<h2><a class="toc-backref" href="#id167">magick</a></h2>
+<h2><a class="toc-backref" href="#id168">magick</a></h2>
 <p>File type magick identifier (.e.g &quot;GIF&quot;):</p>
 <pre class="literal-block">
 void            magick ( const std::string &amp;magick_ )
@@ -2360,7 +2370,7 @@ std::string     magick ( void ) const
 </pre>
 </div>
 <div class="section" id="matte">
-<h2><a class="toc-backref" href="#id168">matte</a></h2>
+<h2><a class="toc-backref" href="#id169">matte</a></h2>
 <p>Image supports transparency (matte channel):</p>
 <pre class="literal-block">
 void            matte ( const bool matteFlag_ )
@@ -2369,7 +2379,7 @@ bool            matte ( void ) const
 </pre>
 </div>
 <div class="section" id="mattecolor">
-<h2><a class="toc-backref" href="#id169">matteColor</a></h2>
+<h2><a class="toc-backref" href="#id170">matteColor</a></h2>
 <p>Image matte (frame) <a class="reference external" href="Color.html">color</a>:</p>
 <pre class="literal-block">
 void            matteColor ( const Color &amp;matteColor_ )
@@ -2378,7 +2388,7 @@ Color           matteColor ( void ) const
 </pre>
 </div>
 <div class="section" id="meanerrorperpixel">
-<h2><a class="toc-backref" href="#id170">meanErrorPerPixel</a></h2>
+<h2><a class="toc-backref" href="#id171">meanErrorPerPixel</a></h2>
 <p>The mean error per pixel computed when an image is color reduced. This
 parameter is only valid if verbose is set to true and the image has
 just been quantized:</p>
@@ -2387,7 +2397,7 @@ double          meanErrorPerPixel ( void ) const
 </pre>
 </div>
 <div class="section" id="modulusdepth">
-<h2><a class="toc-backref" href="#id171">modulusDepth</a></h2>
+<h2><a class="toc-backref" href="#id172">modulusDepth</a></h2>
 <p>Image modulus depth (minimum number of bits required to support
 red/green/blue components without loss of accuracy). The pixel modulus
 depth may be decreased by supplying a value which is less than the
@@ -2401,7 +2411,7 @@ unsigned int    modulusDepth ( void ) const
 </pre>
 </div>
 <div class="section" id="monochrome">
-<h2><a class="toc-backref" href="#id172">monochrome</a></h2>
+<h2><a class="toc-backref" href="#id173">monochrome</a></h2>
 <p>Transform image to black and white while color reducing (quantizing):</p>
 <pre class="literal-block">
 void            monochrome ( const bool monochromeFlag_ )
@@ -2410,7 +2420,7 @@ bool            monochrome ( void ) const
 </pre>
 </div>
 <div class="section" id="montagegeometry">
-<h2><a class="toc-backref" href="#id173">montageGeometry</a></h2>
+<h2><a class="toc-backref" href="#id174">montageGeometry</a></h2>
 <p>Tile size and offset within an image montage. Only valid for montage
 images:</p>
 <pre class="literal-block">
@@ -2418,7 +2428,7 @@ Geometry        montageGeometry ( void ) const
 </pre>
 </div>
 <div class="section" id="normalizedmaxerror">
-<h2><a class="toc-backref" href="#id174">normalizedMaxError</a></h2>
+<h2><a class="toc-backref" href="#id175">normalizedMaxError</a></h2>
 <p>The normalized max error per pixel computed when an image is color
 reduced. This parameter is only valid if verbose is set to true and
 the image has just been quantized:</p>
@@ -2427,7 +2437,7 @@ double          normalizedMaxError ( void ) const
 </pre>
 </div>
 <div class="section" id="normalizedmeanerror">
-<h2><a class="toc-backref" href="#id175">normalizedMeanError</a></h2>
+<h2><a class="toc-backref" href="#id176">normalizedMeanError</a></h2>
 <p>The normalized mean error per pixel computed when an image is color
 reduced. This parameter is only valid if verbose is set to true and
 the image has just been quantized:</p>
@@ -2436,7 +2446,7 @@ double          normalizedMeanError ( void ) const
 </pre>
 </div>
 <div class="section" id="orientation">
-<h2><a class="toc-backref" href="#id176">orientation</a></h2>
+<h2><a class="toc-backref" href="#id177">orientation</a></h2>
 <p>Image orientation.  Supported by some file formats such as DPX and
 TIFF. Useful for turning the right way up:</p>
 <pre class="literal-block">
@@ -2446,7 +2456,7 @@ OrientationType orientation ( void ) const
 </pre>
 </div>
 <div class="section" id="page">
-<h2><a class="toc-backref" href="#id177">page</a></h2>
+<h2><a class="toc-backref" href="#id178">page</a></h2>
 <p>Preferred size and location of an image canvas.</p>
 <p>Use this option to specify the dimensions and position of the
 Postscript page in dots per inch or a TEXT page in pixels. This option
@@ -2460,7 +2470,7 @@ Geometry        page ( void ) const
 </pre>
 </div>
 <div class="section" id="pixelcolor">
-<h2><a class="toc-backref" href="#id178">pixelColor</a></h2>
+<h2><a class="toc-backref" href="#id179">pixelColor</a></h2>
 <p>Get/set pixel <a class="reference external" href="Color.html">color</a> at location x &amp; y:</p>
 <pre class="literal-block">
 void            pixelColor ( const unsigned int x_,
@@ -2472,7 +2482,7 @@ Color           pixelColor ( const unsigned int x_,
 </pre>
 </div>
 <div class="section" id="profile">
-<h2><a class="toc-backref" href="#id179">profile</a></h2>
+<h2><a class="toc-backref" href="#id180">profile</a></h2>
 <p>Add or remove a named profile to/from the image. Remove the
 profile by passing an empty <a class="reference external" href="Blob.html">Blob</a> (e.g. Blob()). Valid names are
 &quot;*&quot;, &quot;8BIM&quot;, &quot;ICM&quot;, &quot;IPTC&quot;, or a user/format-defined profile name:</p>
@@ -2488,7 +2498,7 @@ Blob            profile( const std::string name_ ) const
 </pre>
 </div>
 <div class="section" id="quality">
-<h2><a class="toc-backref" href="#id180">quality</a></h2>
+<h2><a class="toc-backref" href="#id181">quality</a></h2>
 <p>JPEG/MIFF/PNG compression level (default 75):</p>
 <pre class="literal-block">
 void            quality ( const unsigned int quality_ )
@@ -2497,7 +2507,7 @@ unsigned int    quality ( void ) const
 </pre>
 </div>
 <div class="section" id="quantizecolors">
-<h2><a class="toc-backref" href="#id181">quantizeColors</a></h2>
+<h2><a class="toc-backref" href="#id182">quantizeColors</a></h2>
 <p>Maximum number of colors to quantize to:</p>
 <pre class="literal-block">
 void            quantizeColors ( const unsigned int colors_ )
@@ -2506,7 +2516,7 @@ unsigned int    quantizeColors ( void ) const
 </pre>
 </div>
 <div class="section" id="quantizecolorspace">
-<h2><a class="toc-backref" href="#id182">quantizeColorSpace</a></h2>
+<h2><a class="toc-backref" href="#id183">quantizeColorSpace</a></h2>
 <p>Colorspace to quantize in (default RGB). Empirical evidence suggests
 that distances in color spaces such as YUV or YIQ correspond to
 perceptual color differences more closely than do distances in RGB
@@ -2519,7 +2529,7 @@ ColorspaceType  quantizeColorSpace ( void ) const
 </pre>
 </div>
 <div class="section" id="quantizedither">
-<h2><a class="toc-backref" href="#id183">quantizeDither</a></h2>
+<h2><a class="toc-backref" href="#id184">quantizeDither</a></h2>
 <p>Apply Floyd/Steinberg error diffusion to the image. The basic strategy
 of dithering is to trade intensity resolution for spatial resolution
 by averaging the intensities of several neighboring pixels. Images
@@ -2533,7 +2543,7 @@ bool            quantizeDither ( void ) const
 </pre>
 </div>
 <div class="section" id="quantizetreedepth">
-<h2><a class="toc-backref" href="#id184">quantizeTreeDepth</a></h2>
+<h2><a class="toc-backref" href="#id185">quantizeTreeDepth</a></h2>
 <p>Depth of the quantization color classification tree. Values of 0 or 1
 allow selection of the optimal tree depth for the color reduction
 algorithm. Values between 2 and 8 may be used to manually adjust the
@@ -2545,7 +2555,7 @@ unsigned int    quantizeTreeDepth ( void ) const
 </pre>
 </div>
 <div class="section" id="quiet">
-<h2><a class="toc-backref" href="#id185">quiet</a></h2>
+<h2><a class="toc-backref" href="#id186">quiet</a></h2>
 <p>Determines if Warning exceptions will be thrown, or suppressed.
 The default is that warnings will be thrown (i.e. false):</p>
 <pre class="literal-block">
@@ -2554,7 +2564,7 @@ bool            quiet ( void ) const;
 </pre>
 </div>
 <div class="section" id="renderingintent">
-<h2><a class="toc-backref" href="#id186">renderingIntent</a></h2>
+<h2><a class="toc-backref" href="#id187">renderingIntent</a></h2>
 <p>The type of rendering intent (used when applying an ICC color
 profile using <a class="reference internal" href="#icccolorprofile">iccColorProfile</a>):</p>
 <pre class="literal-block">
@@ -2564,14 +2574,14 @@ RenderingIntent renderingIntent ( void ) const
 </pre>
 </div>
 <div class="section" id="repage">
-<h2><a class="toc-backref" href="#id187">repage</a></h2>
+<h2><a class="toc-backref" href="#id188">repage</a></h2>
 <p>Reset the image page canvas and position:</p>
 <pre class="literal-block">
 void            repage();
 </pre>
 </div>
 <div class="section" id="resolutionunits">
-<h2><a class="toc-backref" href="#id188">resolutionUnits</a></h2>
+<h2><a class="toc-backref" href="#id189">resolutionUnits</a></h2>
 <p>Units of image resolution:</p>
 <pre class="literal-block">
 void            resolutionUnits ( const ResolutionType resolutionUnits_ )
@@ -2580,14 +2590,14 @@ ResolutionType  resolutionUnits ( void ) const
 </pre>
 </div>
 <div class="section" id="rows">
-<h2><a class="toc-backref" href="#id189">rows</a></h2>
+<h2><a class="toc-backref" href="#id190">rows</a></h2>
 <p>The number of pixel rows in the image:</p>
 <pre class="literal-block">
 unsigned int    rows ( void ) const
 </pre>
 </div>
 <div class="section" id="scene">
-<h2><a class="toc-backref" href="#id190">scene</a></h2>
+<h2><a class="toc-backref" href="#id191">scene</a></h2>
 <p>Image scene number:</p>
 <pre class="literal-block">
 void            scene ( const unsigned int scene_ )
@@ -2596,7 +2606,7 @@ unsigned int    scene ( void ) const
 </pre>
 </div>
 <div class="section" id="signature">
-<h2><a class="toc-backref" href="#id191">signature</a></h2>
+<h2><a class="toc-backref" href="#id192">signature</a></h2>
 <p>Image textual signature.  Set <cite>force</cite> to true in order to re-calculate
 the signature regardless of whether the image data has been modified:</p>
 <pre class="literal-block">
@@ -2604,7 +2614,7 @@ std::string     signature ( const bool force_ = false ) const
 </pre>
 </div>
 <div class="section" id="size">
-<h2><a class="toc-backref" href="#id192">size</a></h2>
+<h2><a class="toc-backref" href="#id193">size</a></h2>
 <p>Width and height of a raw image (an image which does not support width
 and height information).  Size may also be used to affect the image
 size read from a multi-resolution format (e.g. Photo CD, JBIG, or
@@ -2616,7 +2626,7 @@ Geometry        size ( void ) const
 </pre>
 </div>
 <div class="section" id="statistics">
-<h2><a class="toc-backref" href="#id193">statistics</a></h2>
+<h2><a class="toc-backref" href="#id194">statistics</a></h2>
 <p>Obtain image statistics. Statistics are normalized to the range
 of 0.0 to 1.0 and are output to the specified ImageStatistics
 structure:</p>
@@ -2625,7 +2635,7 @@ void            statistics ( ImageStatistics *statistics ) const
 </pre>
 </div>
 <div class="section" id="strokeantialias">
-<h2><a class="toc-backref" href="#id194">strokeAntiAlias</a></h2>
+<h2><a class="toc-backref" href="#id195">strokeAntiAlias</a></h2>
 <p>Enable/disable stroke anti-aliasing:</p>
 <pre class="literal-block">
 void            strokeAntiAlias( const bool flag_ )
@@ -2634,7 +2644,7 @@ bool            strokeAntiAlias( void ) const
 </pre>
 </div>
 <div class="section" id="strokecolor">
-<h2><a class="toc-backref" href="#id195">strokeColor</a></h2>
+<h2><a class="toc-backref" href="#id196">strokeColor</a></h2>
 <p><a class="reference external" href="Color.html">Color</a> to use when drawing object outlines:</p>
 <pre class="literal-block">
 void            strokeColor ( const Color &amp;strokeColor_ )
@@ -2643,7 +2653,7 @@ Color           strokeColor ( void ) const
 </pre>
 </div>
 <div class="section" id="strokedasharray">
-<h2><a class="toc-backref" href="#id196">strokeDashArray</a></h2>
+<h2><a class="toc-backref" href="#id197">strokeDashArray</a></h2>
 <p>Specify the pattern of dashes and gaps used to stroke paths. The
 strokeDashArray represents a zero-terminated array of numbers that
 specify the lengths of alternating dashes and gaps in pixels. If an
@@ -2658,7 +2668,7 @@ const double*   strokeDashArray ( void ) const
 </pre>
 </div>
 <div class="section" id="strokedashoffset">
-<h2><a class="toc-backref" href="#id197">strokeDashOffset</a></h2>
+<h2><a class="toc-backref" href="#id198">strokeDashOffset</a></h2>
 <p>While drawing using a dash pattern, specify distance into the
 dash pattern to start the dash (default 0):</p>
 <pre class="literal-block">
@@ -2668,7 +2678,7 @@ double          strokeDashOffset ( void ) const
 </pre>
 </div>
 <div class="section" id="strokelinecap">
-<h2><a class="toc-backref" href="#id198">strokeLineCap</a></h2>
+<h2><a class="toc-backref" href="#id199">strokeLineCap</a></h2>
 <p>Specify the shape to be used at the end of open subpaths when
 they are stroked. Values of LineCap are UndefinedCap, ButtCap,
 RoundCap, and SquareCap:</p>
@@ -2679,7 +2689,7 @@ LineCap         strokeLineCap ( void ) const
 </pre>
 </div>
 <div class="section" id="strokelinejoin">
-<h2><a class="toc-backref" href="#id199">strokeLineJoin</a></h2>
+<h2><a class="toc-backref" href="#id200">strokeLineJoin</a></h2>
 <p>Specify the shape to be used at the corners of paths (or other
 vector shapes) when they are stroked. Values of LineJoin are
 UndefinedJoin, MiterJoin, RoundJoin, and BevelJoin:</p>
@@ -2690,7 +2700,7 @@ LineJoin        strokeLineJoin ( void ) const
 </pre>
 </div>
 <div class="section" id="strokemiterlimit">
-<h2><a class="toc-backref" href="#id200">strokeMiterLimit</a></h2>
+<h2><a class="toc-backref" href="#id201">strokeMiterLimit</a></h2>
 <p>Specify miter limit. When two line segments meet at a sharp
 angle and miter joins have been specified for 'lineJoin', it is
 possible for the miter to extend far beyond the thickness of
@@ -2704,7 +2714,7 @@ unsigned int    strokeMiterLimit ( void ) const
 </pre>
 </div>
 <div class="section" id="strokepattern">
-<h2><a class="toc-backref" href="#id201">strokePattern</a></h2>
+<h2><a class="toc-backref" href="#id202">strokePattern</a></h2>
 <p>Pattern image to use while stroking object outlines:</p>
 <pre class="literal-block">
 void            strokePattern ( const Image &amp;strokePattern_ )
@@ -2713,7 +2723,7 @@ Image           strokePattern ( void  ) const
 </pre>
 </div>
 <div class="section" id="strokewidth">
-<h2><a class="toc-backref" href="#id202">strokeWidth</a></h2>
+<h2><a class="toc-backref" href="#id203">strokeWidth</a></h2>
 <p>Stroke width for drawing vector objects (default one):</p>
 <pre class="literal-block">
 void            strokeWidth ( const double strokeWidth_ )
@@ -2722,7 +2732,7 @@ double          strokeWidth ( void ) const
 </pre>
 </div>
 <div class="section" id="subimage">
-<h2><a class="toc-backref" href="#id203">subImage</a></h2>
+<h2><a class="toc-backref" href="#id204">subImage</a></h2>
 <p>Subimage of an image sequence:</p>
 <pre class="literal-block">
 void            subImage ( const unsigned int subImage_ )
@@ -2731,7 +2741,7 @@ unsigned int    subImage ( void ) const
 </pre>
 </div>
 <div class="section" id="subrange">
-<h2><a class="toc-backref" href="#id204">subRange</a></h2>
+<h2><a class="toc-backref" href="#id205">subRange</a></h2>
 <p>Number of images relative to the base image:</p>
 <pre class="literal-block">
 void            subRange ( const unsigned int subRange_ )
@@ -2740,7 +2750,7 @@ unsigned int    subRange ( void ) const
 </pre>
 </div>
 <div class="section" id="textencoding">
-<h2><a class="toc-backref" href="#id205">textEncoding</a></h2>
+<h2><a class="toc-backref" href="#id206">textEncoding</a></h2>
 <p>Annotation text encoding (e.g. &quot;UTF-16&quot;):</p>
 <pre class="literal-block">
 void            textEncoding ( const std::string &amp;encoding_ )
@@ -2749,7 +2759,7 @@ std::string     textEncoding ( void ) const
 </pre>
 </div>
 <div class="section" id="tilename">
-<h2><a class="toc-backref" href="#id206">tileName</a></h2>
+<h2><a class="toc-backref" href="#id207">tileName</a></h2>
 <p>Tile name:</p>
 <pre class="literal-block">
 void            tileName ( const std::string &amp;tileName_ )
@@ -2758,56 +2768,56 @@ std::string     tileName ( void ) const
 </pre>
 </div>
 <div class="section" id="totalcolors">
-<h2><a class="toc-backref" href="#id207">totalColors</a></h2>
+<h2><a class="toc-backref" href="#id208">totalColors</a></h2>
 <p>Number of colors in the image:</p>
 <pre class="literal-block">
 unsigned long   totalColors ( void )
 </pre>
 </div>
 <div class="section" id="transformorigin">
-<h2><a class="toc-backref" href="#id208">transformOrigin</a></h2>
+<h2><a class="toc-backref" href="#id209">transformOrigin</a></h2>
 <p>Origin of coordinate system to use when annotating with text or drawing:</p>
 <pre class="literal-block">
 void            transformOrigin ( const double x_,const  double y_ )
 </pre>
 </div>
 <div class="section" id="transformrotation">
-<h2><a class="toc-backref" href="#id209">transformRotation</a></h2>
+<h2><a class="toc-backref" href="#id210">transformRotation</a></h2>
 <p>Rotation to use when annotating with text or drawing:</p>
 <pre class="literal-block">
 void            transformRotation ( const double angle_ )
 </pre>
 </div>
 <div class="section" id="transformreset">
-<h2><a class="toc-backref" href="#id210">transformReset</a></h2>
+<h2><a class="toc-backref" href="#id211">transformReset</a></h2>
 <p>Reset transformation parameters to default:</p>
 <pre class="literal-block">
 void            transformReset ( void )
 </pre>
 </div>
 <div class="section" id="transformscale">
-<h2><a class="toc-backref" href="#id211">transformScale</a></h2>
+<h2><a class="toc-backref" href="#id212">transformScale</a></h2>
 <p>Scale to use when annotating with text or drawing:</p>
 <pre class="literal-block">
 void            transformScale ( const double sx_, const double sy_ )
 </pre>
 </div>
 <div class="section" id="transformskewx">
-<h2><a class="toc-backref" href="#id212">transformSkewX</a></h2>
+<h2><a class="toc-backref" href="#id213">transformSkewX</a></h2>
 <p>Skew to use in X axis when annotating with text or drawing:</p>
 <pre class="literal-block">
 void            transformSkewX ( const double skewx_ )
 </pre>
 </div>
 <div class="section" id="transformskewy">
-<h2><a class="toc-backref" href="#id213">transformSkewY</a></h2>
+<h2><a class="toc-backref" href="#id214">transformSkewY</a></h2>
 <p>Skew to use in Y axis when annotating with text or drawing:</p>
 <pre class="literal-block">
 void            transformSkewY ( const double skewy_ )
 </pre>
 </div>
 <div class="section" id="verbose">
-<h2><a class="toc-backref" href="#id214">verbose</a></h2>
+<h2><a class="toc-backref" href="#id215">verbose</a></h2>
 <p>Print detailed information about the image:</p>
 <pre class="literal-block">
 void            verbose ( const bool verboseFlag_ )
@@ -2816,7 +2826,7 @@ bool            verbose ( void ) const
 </pre>
 </div>
 <div class="section" id="view">
-<h2><a class="toc-backref" href="#id215">view</a></h2>
+<h2><a class="toc-backref" href="#id216">view</a></h2>
 <p>FlashPix viewing parameters:</p>
 <pre class="literal-block">
 void            view ( const std::string &amp;view_ )
@@ -2825,7 +2835,7 @@ std::string     view ( void ) const
 </pre>
 </div>
 <div class="section" id="x11display">
-<h2><a class="toc-backref" href="#id216">x11Display</a></h2>
+<h2><a class="toc-backref" href="#id217">x11Display</a></h2>
 <p>X11 display to display to, obtain fonts from, or to capture
 image from:</p>
 <pre class="literal-block">
@@ -2835,7 +2845,7 @@ std::string     x11Display ( void ) const
 </pre>
 </div>
 <div class="section" id="xresolution">
-<h2><a class="toc-backref" href="#id217">xResolution</a></h2>
+<h2><a class="toc-backref" href="#id218">xResolution</a></h2>
 <p>x resolution of the image:</p>
 <pre class="literal-block">
 void            xResolution ( const double x_resolution )
@@ -2843,7 +2853,7 @@ double          xResolution ( void ) const
 </pre>
 </div>
 <div class="section" id="yresolution">
-<h2><a class="toc-backref" href="#id218">yResolution</a></h2>
+<h2><a class="toc-backref" href="#id219">yResolution</a></h2>
 <p>y resolution of the image:</p>
 <pre class="literal-block">
 void            yResolution ( const double y_resolution )
@@ -2914,18 +2924,18 @@ image.write(&quot;horse.png&quot;);
 <p>The image cache supports the following methods:</p>
 <div class="contents local topic" id="id8">
 <ul class="simple">
-<li><a class="reference internal" href="#getconstpixels" id="id219">getConstPixels</a></li>
-<li><a class="reference internal" href="#getindexes" id="id220">getIndexes</a></li>
-<li><a class="reference internal" href="#getconstindexes" id="id221">getConstIndexes</a></li>
-<li><a class="reference internal" href="#getpixels" id="id222">getPixels</a></li>
-<li><a class="reference internal" href="#setpixels" id="id223">setPixels</a></li>
-<li><a class="reference internal" href="#syncpixels" id="id224">syncPixels</a></li>
-<li><a class="reference internal" href="#readpixels" id="id225">readPixels</a></li>
-<li><a class="reference internal" href="#writepixels" id="id226">writePixels</a></li>
+<li><a class="reference internal" href="#getconstpixels" id="id220">getConstPixels</a></li>
+<li><a class="reference internal" href="#getindexes" id="id221">getIndexes</a></li>
+<li><a class="reference internal" href="#getconstindexes" id="id222">getConstIndexes</a></li>
+<li><a class="reference internal" href="#getpixels" id="id223">getPixels</a></li>
+<li><a class="reference internal" href="#setpixels" id="id224">setPixels</a></li>
+<li><a class="reference internal" href="#syncpixels" id="id225">syncPixels</a></li>
+<li><a class="reference internal" href="#readpixels" id="id226">readPixels</a></li>
+<li><a class="reference internal" href="#writepixels" id="id227">writePixels</a></li>
 </ul>
 </div>
 <div class="section" id="getconstpixels">
-<h2><a class="toc-backref" href="#id219">getConstPixels</a></h2>
+<h2><a class="toc-backref" href="#id220">getConstPixels</a></h2>
 <p>Transfers read-only pixels from the image to the pixel cache as
 defined by the specified region:</p>
 <pre class="literal-block">
@@ -2935,21 +2945,21 @@ const PixelPacket* getConstPixels ( const int x_, const int y_,
 </pre>
 </div>
 <div class="section" id="getindexes">
-<h2><a class="toc-backref" href="#id220">getIndexes</a></h2>
+<h2><a class="toc-backref" href="#id221">getIndexes</a></h2>
 <p>Obtain mutable image pixel indexes (valid for PseudoClass images):</p>
 <pre class="literal-block">
 IndexPacket* getIndexes ( void )
 </pre>
 </div>
 <div class="section" id="getconstindexes">
-<h2><a class="toc-backref" href="#id221">getConstIndexes</a></h2>
+<h2><a class="toc-backref" href="#id222">getConstIndexes</a></h2>
 <p>Obtain immutable image pixel indexes (valid for PseudoClass images):</p>
 <pre class="literal-block">
 const IndexPacket* getConstIndexes ( void ) const
 </pre>
 </div>
 <div class="section" id="getpixels">
-<h2><a class="toc-backref" href="#id222">getPixels</a></h2>
+<h2><a class="toc-backref" href="#id223">getPixels</a></h2>
 <p>Transfers pixels from the image to the pixel cache as defined by the
 specified region. Modified pixels may be subsequently transferred back
 to the image via syncPixels.  This method is valid for DirectClass
@@ -2961,7 +2971,7 @@ PixelPacket* getPixels ( const int x_, const int y_,
 </pre>
 </div>
 <div class="section" id="setpixels">
-<h2><a class="toc-backref" href="#id223">setPixels</a></h2>
+<h2><a class="toc-backref" href="#id224">setPixels</a></h2>
 <p>Allocates a pixel cache region to store image pixels as defined by the
 region rectangle.  This area is subsequently transferred from the
 pixel cache to the image via syncPixels:</p>
@@ -2972,14 +2982,14 @@ PixelPacket* setPixels ( const int x_, const int y_,
 </pre>
 </div>
 <div class="section" id="syncpixels">
-<h2><a class="toc-backref" href="#id224">syncPixels</a></h2>
+<h2><a class="toc-backref" href="#id225">syncPixels</a></h2>
 <p>Transfers the image cache pixels to the image:</p>
 <pre class="literal-block">
 void syncPixels ( void )
 </pre>
 </div>
 <div class="section" id="readpixels">
-<h2><a class="toc-backref" href="#id225">readPixels</a></h2>
+<h2><a class="toc-backref" href="#id226">readPixels</a></h2>
 <p>Transfers one or more pixel components from a buffer or file into the
 image pixel cache of an image.  Used to support image decoders:</p>
 <pre class="literal-block">
@@ -2988,14 +2998,14 @@ void readPixels ( const QuantumType quantum_,
 </pre>
 </div>
 <div class="section" id="writepixels">
-<h2><a class="toc-backref" href="#id226">writePixels</a></h2>
+<h2><a class="toc-backref" href="#id227">writePixels</a></h2>
 <p>Transfers one or more pixel components from the image pixel cache to a
 buffer or file.  Used to support image encoders:</p>
 <pre class="literal-block">
 void writePixels ( const QuantumType quantum_,
                    unsigned char *destination_ )
 </pre>
-<p>Copyright © <a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">Bob Friesenhahn</a> 1999 - 2017</p>
+<p>Copyright © <a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">Bob Friesenhahn</a> 1999 - 2018</p>
 </div>
 </div>
 </div>
index aca5e4b..aad3188 100644 (file)
@@ -167,7 +167,7 @@ the lines::
 
     image.quantizeColorSpace( GRAYColorspace );
     image.quantizeColors( 256 );
-    image.quantize( ); 
+    image.quantize( );
 
 or, more simply::
 
@@ -248,7 +248,7 @@ operators are available:
 Construct from image file or image specification::
 
     Image( const std::string &imageSpec_ )
-    
+
 Construct a blank image canvas of specified size and `color`_::
 
     Image( const Geometry &size_, const Color &color_ )
@@ -270,7 +270,7 @@ Construct Image of specified size, depth, and format from in-memory `Blob`_::
 
     Image ( const Blob &blob_, const Geometry &size,
             const unsigned int depth_,
-           const std::string &magick_ )
+            const std::string &magick_ )
 
 Construct Image of specified size, and format from in-memory `Blob`_::
 
@@ -293,7 +293,7 @@ Default constructor::
 Copy constructor::
 
     Image ( const Image & image_ )
-    
+
 Assignment operator::
 
     Image& operator= ( const Image &image_ )
@@ -314,7 +314,7 @@ Other attributes may also be available.  The image pixels are not
 valid after calling ping::
 
     void            ping ( const std::string &imageSpec_ )
-    
+
 Ping is similar to read except only enough of the image is read
 to determine the image columns, rows, and filesize.  Access the
 columns(), rows(), and fileSize() attributes after invoking
@@ -324,7 +324,7 @@ ping.  The image pixels are not valid after calling ping::
 
 read
 ++++
-    
+
 Read single image frame into current object.  Use ping_ instead if you
 want to obtain the basic attributes of the image without reading the
 whole file/blob::
@@ -334,7 +334,7 @@ whole file/blob::
 Read single image frame of specified size into current object::
 
     void            read ( const Geometry &size_,
-                          const std::string &imageSpec_ )
+                           const std::string &imageSpec_ )
 
 Read single image frame from in-memory `Blob`_::
 
@@ -343,29 +343,29 @@ Read single image frame from in-memory `Blob`_::
 Read single image frame of specified size from in-memory `Blob`_::
 
     void            read ( const Blob        &blob_,
-                          const Geometry    &size_ )
+                           const Geometry    &size_ )
 
 Read single image frame of specified size and depth from in-memory
 `Blob`_::
 
     void            read ( const Blob         &blob_,
-                          const Geometry     &size_,
-                          const unsigned int depth_ )
+                           const Geometry     &size_,
+                           const unsigned int depth_ )
 
 Read single image frame of specified size, depth, and format from
 in-memory `Blob`_::
 
     void            read ( const Blob         &blob_,
-                          const Geometry     &size_,
-                          const unsigned int depth_,
-                          const std::string  &magick_ )
+                           const Geometry     &size_,
+                           const unsigned int depth_,
+                           const std::string  &magick_ )
 
 Read single image frame of specified size, and format from in-memory
 `Blob`_::
 
     void            read ( const Blob         &blob_,
-                          const Geometry     &size_,
-                          const std::string  &magick_ )
+                           const Geometry     &size_,
+                           const std::string  &magick_ )
 
 Read single image frame from an array of raw pixels, with
 specified storage type (ConstituteImage), e.g.
@@ -379,7 +379,7 @@ specified storage type (ConstituteImage), e.g.
 
 write
 +++++
-    
+
 Write single image frame to a file::
 
     void            write ( const std::string &imageSpec_ )
@@ -390,11 +390,11 @@ adjoin parameters::
     void            write ( Blob *blob_ )
 
     void            write ( Blob *blob_,
-                           const std::string &magick_ )
+                            const std::string &magick_ )
 
     void            write ( Blob *blob_,
-                           const std::string &magick_,
-                           const unsigned int depth_ )
+                            const std::string &magick_,
+                            const unsigned int depth_ )
 
 Write single image frame to an array of pixels with storage type
 specified by user (DispatchImage), e.g.  ``image.write( 0, 0, 640, 1,
@@ -503,31 +503,41 @@ SouthEastGravity
 Annotate using specified text, and placement location::
 
     void            annotate ( const std::string &text_,
-                              const Geometry &location_ )
+                               const Geometry &location_ )
 
 Annotate using specified text, bounding area, and placement gravity::
 
     void            annotate ( const std::string &text_,
-                              const Geometry &boundingArea_,
-                              const GravityType gravity_ )
+                               const Geometry &boundingArea_,
+                               const GravityType gravity_ )
 
 Annotate with text using specified text, bounding area, placement
 gravity, and rotation::
 
     void            annotate ( const std::string &text_,
-                              const Geometry &boundingArea_,
-                              const GravityType gravity_,
-                              const double degrees_ )
+                               const Geometry &boundingArea_,
+                               const GravityType gravity_,
+                               const double degrees_ )
 
 Annotate with text (bounding area is entire image) and placement
 gravity::
 
     void            annotate ( const std::string &text_,
-                              const GravityType gravity_ )
+                               const GravityType gravity_ )
+
+autoOrient
+++++++++++
+
+Automatically orient image to be right-side up based on its current
+orientation attribute.  This allows the image to be viewed correctly
+when the orientation attribute is not available, or is not respected::
+
+    void            autoOrient( void )
+
 
 blur
 ++++
-    
+
 Blur an image with the specified blur factor.
 
 The `radius` parameter specifies the radius of the Gaussian, in
@@ -620,12 +630,12 @@ red, green, and blue quantums::
     void            colorize ( const unsigned int opacityRed_,
                                const unsigned int opacityGreen_,
                                const unsigned int opacityBlue_,
-                              const Color &penColor_ )
+                               const Color &penColor_ )
 
 Colorize image with pen `color`_, using specified percent opacity::
 
     void            colorize ( const unsigned int opacity_,
-                              const Color &penColor_ )
+                               const Color &penColor_ )
 
 colorMatrix
 +++++++++++
@@ -634,13 +644,13 @@ Apply a color matrix to the image channels.  The user supplied matrix
 may be of order 1 to 5 (1x1 through 5x5)::
 
     void            colorMatrix (const unsigned int order_,
-                                const double *color_matrix_)
+                                 const double *color_matrix_)
 
 See `ColorMatrixImage <../api/fx.html#colormatriximage>`_ for more details.
 
 comment
 +++++++
-    
+
 Comment image (add comment string to image). By default, each image is
 commented with its file name. Use this method to assign a specific
 comment to the image.  Optionally you can include the image filename,
@@ -667,24 +677,24 @@ Compose an image onto another at specified x and y offset and using a
 specified algorithm::
 
     void            composite ( const Image &compositeImage_,
-                               const int xOffset_,
-                               const int yOffset_,
-                               const CompositeOperator compose_
+                                const int xOffset_,
+                                const int yOffset_,
+                                const CompositeOperator compose_
                                 = InCompositeOp )
 
     void            composite ( const Image &compositeImage_,
-                               const Geometry &offset_,
-                               const CompositeOperator compose_
+                                const Geometry &offset_,
+                                const CompositeOperator compose_
                                 = InCompositeOp )
 
     void            composite ( const Image &compositeImage_,
-                               const GravityType gravity_,
-                               const CompositeOperator compose_
+                                const GravityType gravity_,
+                                const CompositeOperator compose_
                                 = InCompositeOp )
 
 contrast
 ++++++++
-    
+
 Contrast image (enhance intensity differences in image)::
 
     void            contrast ( const unsigned int sharpen_ )
@@ -709,7 +719,7 @@ Crop image (return subregion of original image)::
 
 cycleColormap
 +++++++++++++
-    
+
 Cycle (rotate) image colormap::
 
     void            cycleColormap ( const int amount_ )
@@ -733,7 +743,7 @@ original if this is a problem:
 
 draw
 ++++
-    
+
 Draw shape or text on image using a single `drawable`_ object::
 
     void            draw ( const Drawable &drawable_ );
@@ -756,7 +766,7 @@ selection::
 
 emboss
 ++++++
-    
+
 Emboss image (hilight edges with 3D effect).  The `radius` parameter
 specifies the radius of the Gaussian, in pixels, not counting the
 center pixel.  The `sigma` parameter specifies the standard deviation
@@ -767,14 +777,14 @@ of the Laplacian, in pixels::
 
 enhance
 +++++++
-    
+
 Enhance image (minimize noise)::
 
     void            enhance ( void );
 
 equalize
 ++++++++
-    
+
 Equalize image (histogram equalization)::
 
     void            equalize ( void )
@@ -811,7 +821,7 @@ and backgroundColor) update those image properties as a side-effect::
 
 flip
 ++++
-    
+
 Flip image (reflect each scanline in the vertical direction)::
 
     void            flip ( void )
@@ -825,10 +835,10 @@ setting when determining `color`_ match::
 
     void            floodFillColor( const unsigned int x_,
                                     const unsigned int y_,
-                                   const Color &fillColor_ )
+                                    const Color &fillColor_ )
 
     void            floodFillColor( const Geometry &point_,
-                                   const Color &fillColor_ )
+                                    const Color &fillColor_ )
 
 Flood-fill `color`_ across pixels starting at target-pixel and stopping
 at pixels matching specified border `color`_.  Uses current fuzz setting
@@ -836,12 +846,12 @@ when determining `color`_ match::
 
     void            floodFillColor( const unsigned int x_,
                                     const unsigned int y_,
-                                   const Color &fillColor_,
-                                   const Color &borderColor_ )
+                                    const Color &fillColor_,
+                                    const Color &borderColor_ )
 
     void            floodFillColor( const Geometry &point_,
-                                   const Color &fillColor_,
-                                   const Color &borderColor_ )
+                                    const Color &fillColor_,
+                                    const Color &borderColor_ )
 
 floodFillOpacity
 ++++++++++++++++
@@ -863,10 +873,10 @@ Uses current fuzz setting when determining `color`_ match::
 
     void            floodFillTexture( const unsigned int x_,
                                       const unsigned int y_,
-                                     const Image &texture_ )
+                                      const Image &texture_ )
 
     void            floodFillTexture( const Geometry &point_,
-                                     const Image &texture_ )
+                                      const Image &texture_ )
 
 Flood-fill texture across pixels starting at target-pixel and
 stopping at pixels matching specified border `color`_.
@@ -874,12 +884,12 @@ Uses current fuzz setting when determining `color`_ match::
 
     void            floodFillTexture( const unsigned int x_,
                                       const unsigned int y_,
-                                     const Image &texture_,
-                                     const Color &borderColor_ )
+                                      const Image &texture_,
+                                      const Color &borderColor_ )
 
     void            floodFillTexture( const Geometry &point_,
-                                     const Image &texture_,
-                                     const Color &borderColor_ )
+                                      const Image &texture_,
+                                      const Color &borderColor_ )
 
 flop
 ++++
@@ -890,26 +900,26 @@ Flop image (reflect each scanline in the horizontal direction)::
 
 frame
 +++++
-    
+
 Draw a decorative frame around the image::
 
     void            frame ( const Geometry &geometry_ = frameGeometryDefault )
 
     void            frame ( const unsigned int width_,
                             const unsigned int height_,
-                           const int innerBevel_ = 6,
+                            const int innerBevel_ = 6,
                             const int outerBevel_ = 6 )
 
 gamma
 +++++
-    
+
 Gamma correct the image or individual image channels::
 
     void            gamma ( const double gamma_ )
 
     void            gamma ( const double gammaRed_,
-                           const double gammaGreen_,
-                           const double gammaBlue_ )
+                            const double gammaGreen_,
+                            const double gammaBlue_ )
 
 gaussianBlur
 ++++++++++++
@@ -934,7 +944,7 @@ standard deviation of the gaussian bell curve is specified by
 
 implode
 +++++++
-    
+
 Implode image (special effect)::
 
     void            implode ( const double factor_ )
@@ -950,7 +960,7 @@ See `HaldClutImage <../api/hclut.html#haldclutimage>`_ for more details.
 
 label
 +++++
-    
+
 Assign a label to an image. Use this option to assign a specific label
 to the image. Optionally you can include the image filename, type,
 width, height, or scene number in the label by embedding `special
@@ -1009,7 +1019,7 @@ Magnify image by integral size (double the dimensions)::
 
 map
 +++
-    
+
 Remap image colors with closest color from a reference image. Set
 `dither` to true in to apply Floyd/Steinberg error diffusion to the
 image. By default, color reduction chooses an optimal set of colors
@@ -1021,13 +1031,13 @@ a particular set of colors from an image file with this option::
 
 matteFloodfill
 ++++++++++++++
-    
+
 Floodfill designated area with a replacement opacity value::
 
     void            matteFloodfill ( const Color &target_ ,
-                                    const unsigned int opacity_,
-                                    const int x_, const int y_,
-                                    const PaintMethod method_ )
+                                     const unsigned int opacity_,
+                                     const int x_, const int y_,
+                                     const PaintMethod method_ )
 
 medianFilter
 ++++++++++++
@@ -1039,7 +1049,7 @@ in a circular neighborhood::
 
 minify
 ++++++
-    
+
 Reduce image by integral (half) size::
 
     void            minify ( void )
@@ -1059,7 +1069,7 @@ multiple references::
 
 modulate
 ++++++++
-    
+
 Modulate percent hue, saturation, and brightness of an image.
 Modulation of saturation and brightness is as a ratio of the current
 value (1.0 for no change). Modulation of hue is an absolute rotation
@@ -1067,8 +1077,8 @@ of -180 degrees to +180 degrees from the current position
 corresponding to an argument range of 0 to 2.0 (1.0 for no change)::
 
     void            modulate ( const double brightness_,
-                              const double saturation_,
-                              const double hue_ )
+                               const double saturation_,
+                               const double hue_ )
 
 motionBlur
 ++++++++++
@@ -1086,7 +1096,7 @@ degrees is from the right)::
 
 negate
 ++++++
-    
+
 Negate colors in image.  Set `grayscale` to only negate grayscale
 values in image::
 
@@ -1094,7 +1104,7 @@ values in image::
 
 normalize
 +++++++++
-    
+
 Normalize image (increase contrast by normalizing the pixel values to
 span the full range of color values)::
 
@@ -1102,7 +1112,7 @@ span the full range of color values)::
 
 oilPaint
 ++++++++
-    
+
 Oilpaint image (image looks like an oil painting)::
 
     void            oilPaint ( const double radius_ = 3.0 )
@@ -1125,7 +1135,7 @@ opaque
 Change `color`_ of specified opaque pixel to specified pen `color`_::
 
     void            opaque ( const Color &opaqueColor_,
-                            const Color &penColor_ )
+                             const Color &penColor_ )
 
 quantize
 ++++++++
@@ -1170,7 +1180,7 @@ Raise image (lighten or darken the edges of an image to give a 3-D
 raised or lowered effect)::
 
     void            raise ( const Geometry &geometry_ = "6x6+0+0",
-                           const bool raisedFlag_ = false )
+                            const bool raisedFlag_ = false )
 
 randomThreshold
 +++++++++++++++
@@ -1238,32 +1248,32 @@ from Image default.  Provides the same result as the `zoom` method::
 
 roll
 ++++
-    
+
 Roll image (rolls image vertically and horizontally) by specified
 number of columnms and rows)::
 
     void            roll ( const Geometry &roll_ )
 
     void            roll ( const unsigned int columns_,
-                          const unsigned int rows_ )
+                           const unsigned int rows_ )
 
 rotate
 ++++++
-    
+
 Rotate image counter-clockwise by specified number of degrees::
 
     void            rotate ( const double degrees_ )
 
 sample
 ++++++
-    
+
 Resize image by using pixel sampling algorithm::
 
     void            sample ( const Geometry &geometry_ )
 
 scale
 +++++
-    
+
 Resize image by using simple ratio algorithm which provides good
 quality::
 
@@ -1280,7 +1290,7 @@ but usually works well for any image resizing purpose::
 
 segment
 +++++++
-    
+
 Segment (coalesce similar image components) by analyzing the
 histograms of the color components and identifying units that are
 homogeneous with the fuzzy c-means technique.  A histogram is built
@@ -1296,24 +1306,24 @@ valid. `SmoothingThreshold` eliminates noise in the second derivative
 of the histogram. As the value is increased, you can expect a smoother
 second derivative.  The default is 1.5::
 
-    void            segment ( const double clusterThreshold_ = 1.0, 
-                             const double smoothingThreshold_ = 1.5 )
+    void            segment ( const double clusterThreshold_ = 1.0,
+                              const double smoothingThreshold_ = 1.5 )
 
 shade
 +++++
-    
+
 Shade image using distant light source. Specify `azimuth` and
 `elevation` as the position of the light source. By default, the
 shading results as a grayscale image.. Set `colorShading` to true to
 shade the red, green, and blue components of the image::
 
     void            shade ( const double azimuth_ = 30,
-                           const double elevation_ = 30,
-                           const bool   colorShading_ = false )
+                            const double elevation_ = 30,
+                            const bool   colorShading_ = false )
 
 sharpen
 +++++++
-    
+
 Sharpen pixels in image.  The `radius` parameter specifies the radius
 of the Gaussian, in pixels, not counting the center pixel.  The
 `sigma` parameter specifies the standard deviation of the Laplacian,
@@ -1343,7 +1353,7 @@ Shave pixels from image edges::
 
 shear
 +++++
-    
+
 Shear image (create parallelogram by sliding image by X or Y
 axis). Shearing slides one edge of an image along the X or Y axis,
 creating a parallelogram.  An X direction shear slides an edge along
@@ -1355,11 +1365,11 @@ the X axis. Empty triangles left over from shearing the image are
 filled with the `color`_ defined as borderColor::
 
     void            shear ( const double xShearAngle_,
-                           const double yShearAngle_ )
+                            const double yShearAngle_ )
 
 solarize
 ++++++++
-    
+
 Solarize image (similar to effect seen when exposing a photographic
 film to light during the development process)::
 
@@ -1367,21 +1377,21 @@ film to light during the development process)::
 
 spread
 ++++++
-    
+
 Spread pixels randomly within image by specified ammount::
 
     void            spread ( const unsigned int amount_ = 3 )
 
 stegano
 +++++++
-    
+
 Add a digital watermark to the image (based on second image)::
 
     void            stegano ( const Image &watermark_ )
 
 stereo
 ++++++
-    
+
 Create an image which appears in stereo when viewed with red-blue
 glasses (Red image on left, blue on right)::
 
@@ -1396,21 +1406,21 @@ Remove all profiles and text attributes from the image.
 
 swirl
 +++++
-    
+
 Swirl image (image pixels are rotated by degrees)::
 
     void            swirl ( const double degrees_ )
 
 texture
 +++++++
-    
+
 Channel a texture on pixels matching image background `color`_::
 
     void            texture ( const Image &texture_ )
 
 threshold
 +++++++++
-    
+
 Threshold image channels (below threshold becomes black, above
 threshold becomes white).  The range of the threshold parameter is 0
 to MaxRGB::
@@ -1419,14 +1429,14 @@ to MaxRGB::
 
 transform
 +++++++++
-    
+
 Transform image based on image and crop geometries. Crop geometry is
 optional::
 
     void            transform ( const Geometry &imageGeometry_ )
 
     void            transform ( const Geometry &imageGeometry_,
-                               const Geometry &cropGeometry_  )
+                                const Geometry &cropGeometry_  )
 
 transparent
 +++++++++++
@@ -1438,7 +1448,7 @@ transparent::
 
 trim
 ++++
-    
+
 Trim edges that are the background `color`_ from the image::
 
     void            trim ( void )
@@ -1540,7 +1550,7 @@ Map image pixels to a sine wave::
 
 zoom
 ++++
-    
+
 Zoom (resize) image to specified size::
 
     void            zoom ( const Geometry &geometry_ )
@@ -1581,7 +1591,7 @@ Join images into a single multi-image file::
 
 antiAlias
 +++++++++
-    
+
 Control antialiasing of rendered Postscript and Postscript or TrueType
 fonts. Enabled by default::
 
@@ -1591,7 +1601,7 @@ fonts. Enabled by default::
 
 animationDelay
 ++++++++++++++
-    
+
 Time in 1/100ths of a second (0 to 65535) which must expire before
 displaying the next image in an animated sequence. This option is
 useful for regulating the animation of a sequence of GIF images within
@@ -1603,7 +1613,7 @@ Netscape::
 
 animationIterations
 +++++++++++++++++++
-    
+
 Number of iterations to loop an animation (e.g. Netscape loop
 extension) for::
 
@@ -1635,7 +1645,7 @@ syntax "EXIF:<tag>" to request an EXIF tag similar to
 
 backgroundColor
 +++++++++++++++
-    
+
 Image background `color`_::
 
     void            backgroundColor ( const Color &color_ )
@@ -1644,7 +1654,7 @@ Image background `color`_::
 
 backgroundTexture
 +++++++++++++++++
-    
+
 Image file name to use as the background texture. Does not modify
 image pixels::
 
@@ -1654,14 +1664,14 @@ image pixels::
 
 baseColumns
 +++++++++++
-    
+
 Base image width (before transformations)::
 
     unsigned int    baseColumns ( void ) const
 
 baseFilename
 ++++++++++++
-    
+
 Base image filename (before transformations)::
 
     std::string     baseFilename ( void ) const
@@ -1675,7 +1685,7 @@ Base image height (before transformations)::
 
 borderColor
 +++++++++++
-    
+
 Image border `color`_::
 
     void            borderColor ( const Color &color_ )
@@ -1693,7 +1703,7 @@ This is the crop bounding box used by ``crop(Geometry(0,0))``::
 
 boxColor
 ++++++++
-    
+
 Base `color`_ that annotation text is rendered on (default none)::
 
     void            boxColor ( const Color &boxColor_ )
@@ -1711,7 +1721,7 @@ This setting is shared by all Image objects::
 
 chromaBluePrimary
 +++++++++++++++++
-    
+
 Chromaticity blue primary point (e.g. x=0.15, y=0.06)::
 
     void            chromaBluePrimary ( const double x_, const double y_ )
@@ -1720,7 +1730,7 @@ Chromaticity blue primary point (e.g. x=0.15, y=0.06)::
 
 chromaGreenPrimary
 ++++++++++++++++++
-    
+
 Chromaticity green primary point (e.g. x=0.3, y=0.6)::
 
     void            chromaGreenPrimary ( const double x_, const double y_ )
@@ -1729,7 +1739,7 @@ Chromaticity green primary point (e.g. x=0.3, y=0.6)::
 
 chromaRedPrimary
 ++++++++++++++++
-    
+
 Chromaticity red primary point (e.g. x=0.64, y=0.33)::
 
     void            chromaRedPrimary ( const double x_, const double y_ )
@@ -1738,7 +1748,7 @@ Chromaticity red primary point (e.g. x=0.64, y=0.33)::
 
 chromaWhitePoint
 ++++++++++++++++
-    
+
 Chromaticity white point (e.g. x=0.3127, y=0.329)::
 
     void            chromaWhitePoint ( const double x_, const double y_ )
@@ -1746,7 +1756,7 @@ Chromaticity white point (e.g. x=0.3127, y=0.329)::
 
 classType
 +++++++++
-    
+
 Image class (DirectClass or PseudoClass).  NOTE: setting a DirectClass
 image to PseudoClass will result in the loss of color information if
 the number of colors in the image is greater than the maximum palette
@@ -1772,7 +1782,7 @@ existing clip mask::
 
 colorFuzz
 +++++++++
-    
+
 Colors within this distance are considered equal. A number of
 algorithms search for a target color. By default the color must be
 exact. Use this option to match colors that are close to the target
@@ -1784,7 +1794,7 @@ color in RGB space::
 
 colorMap
 ++++++++
-    
+
 `Color`_ at colormap position `index`::
 
     void            colorMap ( const unsigned int index_,
@@ -1825,7 +1835,7 @@ Image width::
 
 comment
 +++++++
-    
+
 Image comment::
 
     std::string     comment ( void ) const
@@ -1842,7 +1852,7 @@ used (such as for image flattening)::
 
 compressType
 ++++++++++++
-    
+
 Image compresion type. The default is the compression type of the
 input image file::
 
@@ -2170,7 +2180,7 @@ File type magick identifier (.e.g "GIF")::
 
 matte
 +++++
-    
+
 Image supports transparency (matte channel)::
 
     void            matte ( const bool matteFlag_ )
@@ -2179,7 +2189,7 @@ Image supports transparency (matte channel)::
 
 matteColor
 ++++++++++
-    
+
 Image matte (frame) `color`_::
 
     void            matteColor ( const Color &matteColor_ )
@@ -2188,7 +2198,7 @@ Image matte (frame) `color`_::
 
 meanErrorPerPixel
 +++++++++++++++++
-    
+
 The mean error per pixel computed when an image is color reduced. This
 parameter is only valid if verbose is set to true and the image has
 just been quantized::
@@ -2277,7 +2287,7 @@ Get/set pixel `color`_ at location x & y::
 
     void            pixelColor ( const unsigned int x_,
                                  const unsigned int y_,
-                                const Color &color_ )
+                                 const Color &color_ )
 
     Color           pixelColor ( const unsigned int x_,
                                  const unsigned int y_ ) const
@@ -2309,7 +2319,7 @@ JPEG/MIFF/PNG compression level (default 75)::
 
 quantizeColors
 ++++++++++++++
-    
+
 Maximum number of colors to quantize to::
 
     void            quantizeColors ( const unsigned int colors_ )
@@ -2318,7 +2328,7 @@ Maximum number of colors to quantize to::
 
 quantizeColorSpace
 ++++++++++++++++++
-    
+
 Colorspace to quantize in (default RGB). Empirical evidence suggests
 that distances in color spaces such as YUV or YIQ correspond to
 perceptual color differences more closely than do distances in RGB
@@ -2331,7 +2341,7 @@ an image::
 
 quantizeDither
 ++++++++++++++
-    
+
 Apply Floyd/Steinberg error diffusion to the image. The basic strategy
 of dithering is to trade intensity resolution for spatial resolution
 by averaging the intensities of several neighboring pixels. Images
@@ -2492,7 +2502,7 @@ RoundCap, and SquareCap::
 
 strokeLineJoin
 ++++++++++++++
-    
+
 Specify the shape to be used at the corners of paths (or other
 vector shapes) when they are stroked. Values of LineJoin are
 UndefinedJoin, MiterJoin, RoundJoin, and BevelJoin::
@@ -2629,7 +2639,7 @@ Print detailed information about the image::
 
 view
 ++++
-    
+
 FlashPix viewing parameters::
 
     void            view ( const std::string &view_ )
@@ -2771,7 +2781,7 @@ to the image via syncPixels.  This method is valid for DirectClass
 images::
 
     PixelPacket* getPixels ( const int x_, const int y_,
-                            const unsigned int columns_,
+                             const unsigned int columns_,
                              const unsigned int rows_ )
 
 setPixels
@@ -2782,7 +2792,7 @@ region rectangle.  This area is subsequently transferred from the
 pixel cache to the image via syncPixels::
 
     PixelPacket* setPixels ( const int x_, const int y_,
-                            const unsigned int columns_,
+                             const unsigned int columns_,
                              const unsigned int rows_ )
 
 syncPixels
@@ -2799,19 +2809,18 @@ Transfers one or more pixel components from a buffer or file into the
 image pixel cache of an image.  Used to support image decoders::
 
     void readPixels ( const QuantumType quantum_,
-                     const unsigned char *source_ )
+                      const unsigned char *source_ )
 
 writePixels
 +++++++++++
-    
+
 Transfers one or more pixel components from the image pixel cache to a
 buffer or file.  Used to support image encoders::
 
     void writePixels ( const QuantumType quantum_,
-                      unsigned char *destination_ )
+                       unsigned char *destination_ )
 
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| `Bob Friesenhahn`_ 1999 - 2017
-
+Copyright |copy| `Bob Friesenhahn`_ 1999 - 2018
index 47eed0a..dd7dc28 100644 (file)
@@ -49,7 +49,7 @@ reference count on the old image becomes zero, then the associated
 reference and data are deleted. This strategy represents a simple (but
 effective) form of garbage collection.</p>
 <img alt="Figure showing Image class design" src="Image.png" style="width: 910px; height: 490px;" />
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </body>
 </html>
index b7bfdb2..4a5a68b 100644 (file)
@@ -24,5 +24,4 @@ effective) form of garbage collection.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
-
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index 308e6a4..baa89c4 100644 (file)
@@ -201,7 +201,7 @@ public:
 
 };
 </pre>
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </div>
 </body>
index dc5ed5c..8bc4603 100644 (file)
@@ -92,7 +92,7 @@ The following is the definition of the Magick::Montage class::
     // specification
     void              gravity ( GravityType gravity_ );
     GravityType       gravity ( void ) const;
-    
+
     // Specifies the format used for the image label. Special format
     // characters may be embedded in the format string to include
     // information about the image.
@@ -132,7 +132,7 @@ The following is the definition of the Magick::Montage class::
     // Specifies the montage title
     void              title ( const std::string &title_ );
     std::string       title ( void ) const;
-    
+
     // Specifies a montage color to set transparent. This option can
     // be set the same as the background color in order for the
     // thumbnails to appear without a background when rendered on an
@@ -197,5 +197,4 @@ The following is the definition of the Magick::MontageFramed class::
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
-
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index dca9cf7..1da29ee 100644 (file)
@@ -132,7 +132,7 @@ are shown in the following table:</p>
 totally opaque).</p>
 <p>Note that for CMYKColorspace + matte (CMYKA), the opacity is stored in
 the assocated IndexPacket.</p>
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </body>
 </html>
index 94f2b5f..2b03e9d 100644 (file)
@@ -54,4 +54,4 @@ the assocated IndexPacket.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index 23b858c..769540b 100644 (file)
@@ -164,7 +164,7 @@ public:
 
 };
 </pre>
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </body>
 </html>
index 44dec5c..0957c21 100644 (file)
@@ -88,7 +88,7 @@ text)::
   view.sync();
 
   // Set pixel at position 108,94 to red
-  *(view.get(108,94,1,1)) = Color("red");  
+  *(view.get(108,94,1,1)) = Color("red");
 
   // Save changes to image.
   view.sync();
@@ -104,27 +104,27 @@ The following is the definition of the Magick::Pixels class::
 
     // Destroy pixel view
     ~Pixels( void );
-    
+
     // Transfer pixels from the image to the pixel view as defined by
     // the specified region. Modified pixels may be subsequently
     // transferred back to the image via sync.
     PixelPacket* get ( const int x_, const int y_,
-                      const unsigned int columns_,const  unsigned int rows_ );
+                       const unsigned int columns_,const  unsigned int rows_ );
 
     // Transfer read-only pixels from the image to the pixel view as
     // defined by the specified region.
     const PixelPacket* getConst ( const int x_, const int y_,
                                   const unsigned int columns_,
                                   const unsigned int rows_ );
-    
+
     // Transfers the image view pixels to the image.
     void sync ( void );
-    
+
     // Allocate a pixel view region to store image pixels as defined
     // by the region rectangle.  This area is subsequently transferred
     // from the pixel view to the image via sync.
     PixelPacket* set ( const int x_, const int y_,
-                      const unsigned int columns_, const unsigned int rows_ );
+                       const unsigned int columns_, const unsigned int rows_ );
 
     // Return pixel colormap index array
     IndexPacket* indexes ( void );
@@ -145,5 +145,4 @@ The following is the definition of the Magick::Pixels class::
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
-
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index 8e76b1b..f910d7b 100644 (file)
@@ -89,7 +89,7 @@ public:
 
 };
 </pre>
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </body>
 </html>
index c6a7e16..f4c0e9c 100644 (file)
@@ -38,7 +38,7 @@ The following is the definition of the Magick::TypeMetric class::
   {
     friend class Image;
   public:
-    
+
     TypeMetric ( void );
     ~TypeMetric ( void );
 
@@ -64,5 +64,4 @@ The following is the definition of the Magick::TypeMetric class::
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
-
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index 5f88a2d..c4d4e89 100644 (file)
@@ -231,7 +231,7 @@ initialize GraphicsMagick will result in an application crash.</p>
 <h1><a class="toc-backref" href="#id6">Reporting Bugs</a></h1>
 <p>Please report any bugs via the <a class="reference external" href="http://sourceforge.net/projects/graphicsmagick/">GraphicsMagick Bug Tracker</a>. Questions
 regarding usage should be directed to <a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">Bob Friesenhahn</a>.</p>
-<p>Copyright © Bob Friesenhahn 1999 - 2017</p>
+<p>Copyright © Bob Friesenhahn 1999 - 2018</p>
 </div>
 </div>
 </body>
index ac84d77..d997cb0 100644 (file)
@@ -222,5 +222,4 @@ regarding usage should be directed to `Bob Friesenhahn`_.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| Bob Friesenhahn 1999 - 2017
-
+Copyright |copy| Bob Friesenhahn 1999 - 2018
index 5cfdde3..505f68d 100644 (file)
@@ -52,6 +52,7 @@ RST2HTML_TARGETS = \
        $(WWWDIR)/ChangeLog-2014.html \
        $(WWWDIR)/ChangeLog-2015.html \
        $(WWWDIR)/ChangeLog-2016.html \
+       $(WWWDIR)/ChangeLog-2017.html \
        $(WWWDIR)/Changelog.html \
        $(WWWDIR)/Changes.html \
        $(WWWDIR)/Copyright.html \
@@ -166,6 +167,7 @@ WWW_HTML_FILES = \
        $(WWWDIR)/ChangeLog-2014.html \
        $(WWWDIR)/ChangeLog-2015.html \
        $(WWWDIR)/ChangeLog-2016.html \
+       $(WWWDIR)/ChangeLog-2017.html \
        $(WWWDIR)/Changelog.html \
        $(WWWDIR)/Changes.html \
        $(WWWDIR)/Copyright.html \
@@ -268,6 +270,9 @@ CHANGELOG2RST=$(top_srcdir)/scripts/changelog2rst.sh
 $(top_srcdir)/www/Changelog.rst: $(top_srcdir)/ChangeLog
        $(CHANGELOG2RST) < $^ > $@
 
+$(top_srcdir)/www/ChangeLog-2017.rst: $(top_srcdir)/ChangeLog.2017
+       $(CHANGELOG2RST) < $^ > $@
+
 $(top_srcdir)/www/ChangeLog-2016.rst: $(top_srcdir)/ChangeLog.2016
        $(CHANGELOG2RST) < $^ > $@
 
index 8f00e47..62bddf1 100644 (file)
 <!-- -*- mode: rst -*- -->
 <!-- This text is in reStucturedText format, so it may look a bit odd. -->
 <!-- See http://docutils.sourceforge.net/rst.html for details. -->
-<p>This file was last updated on July 4, 2017</p>
+<p>This file was last updated on November 17, 2018</p>
 <p>Please note that this file records news for the associated development
 branch and that each development branch has its own NEWS file. See the
-ChangeLog file for full details.</p>
+ChangeLog file, and/or the Mercurial changesets, for full details.</p>
+<p>Due to significant issues being discovered and addressed for almost
+every release, it is recommended to update to the most current
+release and not attempt to patch older releases.</p>
 <div class="contents local topic" id="contents">
 <ul class="simple">
-<li><a class="reference internal" href="#july-4-2017" id="id4">1.3.26 (July 4, 2017)</a></li>
-<li><a class="reference internal" href="#september-5-2016" id="id5">1.3.25 (September 5, 2016)</a></li>
-<li><a class="reference internal" href="#may-30-2016" id="id6">1.3.24 (May 30, 2016)</a></li>
-<li><a class="reference internal" href="#november-7-2015" id="id7">1.3.23 (November 7, 2015)</a></li>
-<li><a class="reference internal" href="#october-4-2015" id="id8">1.3.22 (October 4, 2015)</a></li>
-<li><a class="reference internal" href="#february-28-2015" id="id9">1.3.21 (February 28, 2015)</a></li>
-<li><a class="reference internal" href="#august-16-2014" id="id10">1.3.20 (August 16, 2014)</a></li>
-<li><a class="reference internal" href="#december-31-2013" id="id11">1.3.19 (December 31, 2013)</a></li>
-<li><a class="reference internal" href="#march-10-2013" id="id12">1.3.18 (March 10, 2013)</a></li>
-<li><a class="reference internal" href="#october-13-2012" id="id13">1.3.17 (October 13, 2012)</a></li>
-<li><a class="reference internal" href="#june-24-2012" id="id14">1.3.16 (June 24, 2012)</a></li>
-<li><a class="reference internal" href="#april-28-2012" id="id15">1.3.15 (April 28, 2012)</a></li>
-<li><a class="reference internal" href="#february-25-2012" id="id16">1.3.14 (February 25, 2012)</a></li>
-<li><a class="reference internal" href="#december-24-2011" id="id17">1.3.13 (December 24, 2011)</a></li>
-<li><a class="reference internal" href="#march-8-2010" id="id18">1.3.12 (March 8, 2010)</a></li>
-<li><a class="reference internal" href="#february-21-2010" id="id19">1.3.11 (February 21, 2010)</a></li>
-<li><a class="reference internal" href="#february-10-2010" id="id20">1.3.10 (February 10, 2010)</a></li>
-<li><a class="reference internal" href="#february-4-2010" id="id21">1.3.9 (February 4, 2010)</a></li>
-<li><a class="reference internal" href="#january-21-2010" id="id22">1.3.8 (January 21, 2010)</a></li>
-<li><a class="reference internal" href="#september-17-2009" id="id23">1.3.7 (September 17, 2009)</a></li>
-<li><a class="reference internal" href="#july-25-2009" id="id24">1.3.6 (July 25, 2009)</a></li>
-<li><a class="reference internal" href="#january-26-2009" id="id25">1.3.5 (January 26, 2009)</a></li>
-<li><a class="reference internal" href="#january-13-2009" id="id26">1.3.4 (January 13, 2009)</a></li>
-<li><a class="reference internal" href="#december-9-2008" id="id27">1.3.3 (December 9, 2008)</a></li>
-<li><a class="reference internal" href="#november-29-2008" id="id28">1.3.2 (November 29, 2008)</a></li>
-<li><a class="reference internal" href="#november-17-2008" id="id29">1.3.1 (November 17, 2008)</a></li>
-<li><a class="reference internal" href="#november-9-2008" id="id30">1.3 (November 9, 2008)</a></li>
-<li><a class="reference internal" href="#april-29-2008" id="id31">1.2 (April 29, 2008)</a></li>
-<li><a class="reference internal" href="#released-april-4-2004" id="id32">1.1 (Released April 4, 2004)</a></li>
-<li><a class="reference internal" href="#released-in-may-2003" id="id33">1.0 (Released in May, 2003)</a></li>
+<li><a class="reference internal" href="#november-17-2018" id="id2">1.3.31 (November 17, 2018)</a></li>
+<li><a class="reference internal" href="#june-23-2018" id="id3">1.3.30 (June 23, 2018)</a></li>
+<li><a class="reference internal" href="#april-29-2018" id="id4">1.3.29 (April 29, 2018)</a></li>
+<li><a class="reference internal" href="#january-20-2018" id="id5">1.3.28 (January 20, 2018)</a></li>
+<li><a class="reference internal" href="#december-9-2017" id="id6">1.3.27 (December 9, 2017)</a></li>
+<li><a class="reference internal" href="#july-4-2017" id="id7">1.3.26 (July 4, 2017)</a></li>
+<li><a class="reference internal" href="#september-5-2016" id="id8">1.3.25 (September 5, 2016)</a></li>
+<li><a class="reference internal" href="#may-30-2016" id="id9">1.3.24 (May 30, 2016)</a></li>
+<li><a class="reference internal" href="#november-7-2015" id="id10">1.3.23 (November 7, 2015)</a></li>
+<li><a class="reference internal" href="#october-4-2015" id="id11">1.3.22 (October 4, 2015)</a></li>
+<li><a class="reference internal" href="#february-28-2015" id="id12">1.3.21 (February 28, 2015)</a></li>
+<li><a class="reference internal" href="#august-16-2014" id="id13">1.3.20 (August 16, 2014)</a></li>
+<li><a class="reference internal" href="#december-31-2013" id="id14">1.3.19 (December 31, 2013)</a></li>
+<li><a class="reference internal" href="#march-10-2013" id="id15">1.3.18 (March 10, 2013)</a></li>
+<li><a class="reference internal" href="#october-13-2012" id="id16">1.3.17 (October 13, 2012)</a></li>
+<li><a class="reference internal" href="#june-24-2012" id="id17">1.3.16 (June 24, 2012)</a></li>
+<li><a class="reference internal" href="#april-28-2012" id="id18">1.3.15 (April 28, 2012)</a></li>
+<li><a class="reference internal" href="#february-25-2012" id="id19">1.3.14 (February 25, 2012)</a></li>
+<li><a class="reference internal" href="#december-24-2011" id="id20">1.3.13 (December 24, 2011)</a></li>
+<li><a class="reference internal" href="#march-8-2010" id="id21">1.3.12 (March 8, 2010)</a></li>
+<li><a class="reference internal" href="#february-21-2010" id="id22">1.3.11 (February 21, 2010)</a></li>
+<li><a class="reference internal" href="#february-10-2010" id="id23">1.3.10 (February 10, 2010)</a></li>
+<li><a class="reference internal" href="#february-4-2010" id="id24">1.3.9 (February 4, 2010)</a></li>
+<li><a class="reference internal" href="#january-21-2010" id="id25">1.3.8 (January 21, 2010)</a></li>
+<li><a class="reference internal" href="#september-17-2009" id="id26">1.3.7 (September 17, 2009)</a></li>
+<li><a class="reference internal" href="#july-25-2009" id="id27">1.3.6 (July 25, 2009)</a></li>
+<li><a class="reference internal" href="#january-26-2009" id="id28">1.3.5 (January 26, 2009)</a></li>
+<li><a class="reference internal" href="#january-13-2009" id="id29">1.3.4 (January 13, 2009)</a></li>
+<li><a class="reference internal" href="#december-9-2008" id="id30">1.3.3 (December 9, 2008)</a></li>
+<li><a class="reference internal" href="#november-29-2008" id="id31">1.3.2 (November 29, 2008)</a></li>
+<li><a class="reference internal" href="#november-17-2008" id="id32">1.3.1 (November 17, 2008)</a></li>
+<li><a class="reference internal" href="#november-9-2008" id="id33">1.3 (November 9, 2008)</a></li>
+<li><a class="reference internal" href="#april-29-2008" id="id34">1.2 (April 29, 2008)</a></li>
+<li><a class="reference internal" href="#released-april-4-2004" id="id35">1.1 (Released April 4, 2004)</a></li>
+<li><a class="reference internal" href="#released-in-may-2003" id="id36">1.0 (Released in May, 2003)</a></li>
+</ul>
+</div>
+<div class="section" id="november-17-2018">
+<h1><a class="toc-backref" href="#id2">1.3.31 (November 17, 2018)</a></h1>
+<p>Special Issues:</p>
+<ul class="simple">
+<li>Firmware and operating system updates to address the Spectre
+vulnerability (and possibly to some extent the Meltdown
+vulnerability) have substantially penalized GraphicsMagick's OpenMP
+performance.  Performance is reduced even with GCC 7 and 8's
+improved optimizers. There does not appear to be anything we can do
+about this.</li>
+</ul>
+<p>Security Fixes:</p>
+<ul class="simple">
+<li>GraphicsMagick is now participating in Google's oss-fuzz project due
+to the contributions and assistance of Alex Gaynor. Since February 4
+2018, 292 issues have been opened by oss-fuzz and 279 of those
+issues have been resolved.  The issues list is available at
+<a class="reference external" href="https://bugs.chromium.org/p/oss-fuzz/issues/list">https://bugs.chromium.org/p/oss-fuzz/issues/list</a> under search term
+&quot;graphicsmagick&quot;.  Issues are available for anyone to view and
+duplicate if they have been in &quot;Verified&quot; status for 30 days, or if
+they have been in &quot;New&quot; status for 90 days.  There are too many
+fixes to list here.  Please consult the GraphicsMagick ChangeLog
+file, Mercurial repository commit log, and the oss-fuzz issues list
+for details.</li>
+</ul>
+<p>Bug fixes:</p>
+<ul class="simple">
+<li>See above note about oss-fuzz fixes.</li>
+<li>CINEON: Fix unexpected hang on a crafted Cineon image.  SourceForge
+issue 571.</li>
+<li>Drawing recursion is limited to 100 and may be tuned via the
+MAX_DRAWIMAGE_RECURSION pre-processor definition.</li>
+<li>Fix reading MIFF files using legacy keyword 'color-profile' for ICC
+color profile as was used by ImageMagick 4.2.9.</li>
+<li>Fix reading/writing files when 'magick' is specified in lower case.
+This bug was a regression in 1.3.30.</li>
+</ul>
+<p>New Features:</p>
+<ul class="simple">
+<li>TIFF: Support Zstd compression in TIFF.  This requires libtiff
+4.0.10 or later.</li>
+<li>TIFF: Support WebP compression in TIFF.  This requires libtiff
+4.0.10 or later.</li>
+</ul>
+<p>API Updates:</p>
+<ul class="simple">
+<li>MagickMonitor() is marked as deprecated.  Code should not be using
+this function any more.</li>
+</ul>
+<p>Feature improvements:</p>
+<ul class="simple">
+<li>The progress monitor callbacks (registered using MagickMonitor() or
+MagickMonitorFormatted()) are serialized via a common semaphore
+rather than via critical sections in OpenMP loops.  OpenMP loops are
+updated to use OpenMP 'atomic' and 'flush' to update shared loop
+variables rather than using a OpenMP 'critical' construct, reducing
+contention.  Performance on some targets is observed to have been
+improved by this change.</li>
+</ul>
+<p>Windows Delegate Updates/Additions:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>Build Changes:</p>
+<ul class="simple">
+<li>There was already a 'compare' command installed with the
+'--enable-magick-compat' configure option was used but it did not
+function.  Now it functions.  There was no <cite>compare</cite> command in
+ImageMagick 5.5.2 and this compare command is only roughly similar
+to a <cite>compare</cite> command in some subsequent ImageMagick release.</li>
+<li>Removed Remove Ghostscript library support (--with-gslib) from
+configure script.  The 'HasGS' pre-processor defines which were
+enabled by this remain in the source code so it is still possible to
+use this library if absolutely necessary (e.g. CPPFLAGS=-DHasGS
+LIBS=-lgs).</li>
+<li>No longer explicitly link with the OpenMP library when it will be
+supplied already due to CFLAGS.</li>
+</ul>
+<p>Behavior Changes:</p>
+<ul class="simple">
+<li>JPEG: Libjpeg-turbo is allowed 1/5th the memory resource limit
+provided for Graphicsmagick via the cinfo-&gt;mem-&gt;max_memory_to_use
+option, which is part of the IJG JPEG API/ABI, but usually not
+supported there.  This feature works for libjpeg-turbo 1.5.2 and
+later.  Limiting the memory usage is useful since libjpeg-turbo may
+otherwise consume arbitrary amounts of memory even before
+Graphicsmagick is informed of the image dimensions.</li>
+<li>JPEG: The maximum number of JPEG progressive scans is limited to 50.
+Otherwise some technically valid files could be read for almost
+forever.</li>
+</ul>
+</div>
+<div class="section" id="june-23-2018">
+<h1><a class="toc-backref" href="#id3">1.3.30 (June 23, 2018)</a></h1>
+<p>Special Issues:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>Security Fixes:</p>
+<ul class="simple">
+<li>GraphicsMagick is now participating in Google's oss-fuzz project due
+to the contributions and assistance of Alex Gaynor. Since February 4
+2018, 238 issues have been opened by oss-fuzz and 230 of those
+issues have been resolved.  The issues list is available at
+<a class="reference external" href="https://bugs.chromium.org/p/oss-fuzz/issues/list">https://bugs.chromium.org/p/oss-fuzz/issues/list</a> under search term
+&quot;graphicsmagick&quot;.  Issues are available for anyone to view and
+duplicate if they have been in &quot;Verified&quot; status for 30 days, or if
+they have been in &quot;New&quot; status for 90 days.  There are too many
+fixes to list here.  Please consult the GraphicsMagick ChangeLog
+file, Mercurial repository commit log, and the oss-fuzz issues list
+for details.</li>
+<li>SVG/Rendering: Fix heap write overflow of PrimitiveInfo and
+PointInfo arrays.  This is another manefestation of CVE-2016-2317,
+which should finally be fixed correctly due to active
+detection/correction of pending overflow rather than using
+estimation.</li>
+</ul>
+<p>Bug fixes:</p>
+<ul class="simple">
+<li>Many oss-fuzz fixes are bug fixes.</li>
+<li>Drawing/Rendering: Many more fixes by Gregory J Wolfe (see the ChangeLog).</li>
+<li>MIFF: Detect end of file while reading image directory.</li>
+<li>SVG: Many more fixes by Gregory J Wolfe (see the ChangeLog).</li>
+<li>The AlphaCompositePixel macro was producing wrong results when the
+output alpha value was not 100% opaque. This is a regression
+introduced in 1.3.29.</li>
+<li>TILE: Fix problem with tiling JPEG images because the size request
+used by the TILE algorithm was also causing re-scaling in the JPEG
+reader.  The problem is solved by stripping the size request before
+reading the image.</li>
+</ul>
+<p>New Features:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>API Updates:</p>
+<ul class="simple">
+<li>The size of PrimitiveInfo (believed to be an internal/private
+structure but in a header which is installed, has been increased to
+store a 'flags' argument. This is intended to be an internal
+interface but but may be detected as an ABI change.</li>
+</ul>
+<p>Feature improvements:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>Windows Delegate Updates/Additions:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>Build Changes:</p>
+<ul class="simple">
+<li>The oss-fuzz build script (fuzzing/oss-fuzz-build.sh) now includes
+many delegate libraries such as zlib, libpng, libtiff, libjpeg, and
+freetype, resulting in more comprehensive testing.  The Q16 build is
+now being tested rather than the 'configure' default of Q8.</li>
+</ul>
+<p>Behavior Changes:</p>
+<ul class="simple">
+<li>JPEG: The JPEG reader now allows 3 warnings of any particular type
+before giving up on reading and throwing an exception.  This choice
+was made after observing files which produce hundreds of warnings
+and consume massive amounts of memory before reading the image data
+has even started.  It is currently unknown how many files which were
+previously accepted will be rejected by default.  The number of
+allowed warnings may be adjusted using '-define
+jpeg:max-warnings=&lt;value&gt;'.  The default limit will be adjusted
+based on reported user experiences and may be adjusted prior to
+compilation via the MaxWarningCount definition in coders/jpeg.c.</li>
+</ul>
+</div>
+<div class="section" id="april-29-2018">
+<h1><a class="toc-backref" href="#id4">1.3.29 (April 29, 2018)</a></h1>
+<p>Special Issues:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>Security Fixes:</p>
+<ul class="simple">
+<li>GraphicsMagick is now participating in Google's oss-fuzz project due
+to the contributions and assistance of Alex Gaynor. Since February 4
+2018, 180 issues have been opened by oss-fuzz and 173 of those
+issues have been resolved.  The issues list is available at
+<a class="reference external" href="https://bugs.chromium.org/p/oss-fuzz/issues/list">https://bugs.chromium.org/p/oss-fuzz/issues/list</a> under search term
+&quot;graphicsmagick&quot;.  Issues are available for anyone to view and
+duplicate if they have been in &quot;Verified&quot; status for 30 days, or if
+they have been in &quot;New&quot; status for 90 days.  There are too many
+fixes to list here.  Please consult the GraphicsMagick ChangeLog
+file, Mercurial repository commit log, and the oss-fuzz issues list
+for details.</li>
+<li>JNG: Require that the embedded JPEG image have the same dimensions
+as the JNG image as provided by JHDR. Avoids a heap write overflow.</li>
+<li>MNG: Arbitrarily limit the number of loops which may be requested by
+the MNG LOOP chunk to 512 loops, and provide the '-define
+mng:maximum-loops=value' option in case the user wants to change the
+limit.  This fixes a denial of service caused by large LOOP
+specifications.</li>
+</ul>
+<p>Bug fixes:</p>
+<ul class="simple">
+<li>Many oss-fuzz fixes are bug fixes.</li>
+<li>DICOM: Pre/post rescale functions are temporarily disabled (until
+the implementation is fixed).</li>
+<li>JPEG: Fix regression in last release in which reading some JPEG
+files produces the error &quot;Improper call to JPEG library in state
+201&quot;.</li>
+<li>ICON: Some DIB-based Windows ICON files were reported as corrupt to
+an unexpectedly missing opacity mask image.</li>
+<li>In-memory Blob I/O: Don't implicitly increase the allocation size
+due to seek offsets.</li>
+<li>MNG: Detect and handle failure to allocate global PLTE. Fix divide
+by zero.</li>
+<li>DrawGetStrokeDashArray(): Check for failure to allocate memory.</li>
+<li>BlobToImage(): Now produces useful exception reports to cover the
+cases where 'magick' was not set and the file format could not be
+deduced from its header.</li>
+</ul>
+<p>New Features:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>API Updates:</p>
+<ul class="simple">
+<li>Wand API: Added MagickIsPaletteImage(), MagickIsOpaqueImage(),
+MagickIsMonochromeImage(), MagickIsGrayImage(), MagickHasColormap()
+based on contributions by Troy Patteson.</li>
+<li>New structure ImageExtra added and Image 'clip_mask' member is
+replaced by 'extra' which points to private ImageExtra allocation.
+The ImageGetClipMask() function now provides access to the clip mask
+image.</li>
+<li>New structure DrawInfoExtra and DrawInfo 'clip_path' is replaced by
+'extra' which points to private DrawInfoExtra allocation.  The
+DrawInfoGetClipPath() function now provides access to the clip path.</li>
+<li>New core library functions: GetImageCompositeMask(),
+CompositeMaskImage(), CompositePathImage(), SetImageCompositeMask(),
+ImageGetClipMask(), ImageGetCompositeMask(), DrawInfoGetClipPath(),
+DrawInfoGetCompositePath()</li>
+<li>Deprecated core library functions: RegisterStaticModules(),
+UnregisterStaticModules().</li>
+</ul>
+<p>Feature improvements:</p>
+<ul class="simple">
+<li>Static modules (in static library or shared library without
+dynamically loadable modules) are now lazy-loaded using the same
+external interface as the lazy-loader for dynamic modules.  This
+results in more similarity between the builds and reduces the fixed
+initialization overhead by only initializing the modules which are
+used.</li>
+<li>SVG: The quality of SVG support has been significantly improved due
+to the efforts of Greg Wolfe.</li>
+<li>FreeType/TTF rendering: Rendering fixes for opacity.</li>
+</ul>
+<p>Windows Delegate Updates/Additions:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>Build Changes:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>Behavior Changes:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+</div>
+<div class="section" id="january-20-2018">
+<h1><a class="toc-backref" href="#id5">1.3.28 (January 20, 2018)</a></h1>
+<p>Special Issues:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>Security Fixes:</p>
+<ul class="simple">
+<li>BMP: Fix non-terminal loop due to unexpected bit-field mask value
+(DOS opportunity).</li>
+<li>PALM: Fix heap buffer underflow in builds with QuantumDepth=8.</li>
+<li>SetNexus() Fix heap overwrite under certain conditions due to using
+a wrong destination buffer.  This issue impacts all 1.3.X releases.</li>
+<li>TIFF: Fix heap buffer read overflow in LocaleNCompare() when parsing
+NEWS profile.</li>
+</ul>
+<p>Bug fixes:</p>
+<ul class="simple">
+<li>DescribeImage(): Eliminate possible use of null pointer.</li>
+<li>GIF: Fix memory leak of global colormap in error path.</li>
+<li>GZ: Writing to gzip files with the extension &quot;.gz&quot; was not working
+with Zlib 1.2.8.</li>
+<li>JNG: Fix buffer read overflow (a tiny fixed overflow of just one byte).</li>
+<li>JPEG: Promoting certain libjpeg warnings to errors caused much more
+problems than expected.  The promotion of warnings to errors is
+removed.  Claimed pixel dimensions are validated by file size before
+allocating memory for the pixels.</li>
+<li>IntegralRotateImage(): Assure that reported error in rotate by 270
+case does immediately terminate processing.</li>
+<li>MNG: Fix possible null pointer reference related to DEFI chunk
+parsing.  Fix minor heap read overflow (constrained to just one
+byte) due to an ordering issue in a limit check.  Fix memory leaks
+in error path.</li>
+<li>WebP: Fix stack buffer overflow in WriteWEBPImage() which occurs
+with libwebp 0.5.0 or newer due to a structure type change in the
+structure passed to the progress monitor callback.</li>
+<li>WPG: Memory leaks fixed.</li>
+</ul>
+<p>New Features:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>API Updates:</p>
+<ul class="simple">
+<li>InterpolateViewColor(): This function now returns MagickPassFail (an
+unsigned int) rather than void so that errors can be efficiently
+reported.</li>
+<li>The magick/pixel_cache.h header is updated to add deprecation
+attributes such that code using GetPixels(), GetIndexes(), and
+GetOnePixel() will produce deprecation warnings for compilers which
+support them.  These functions will not be removed in the 1.3.X
+release series and when they are removed, pre-processor macros will
+be added so a replacement function is used instead.  There is a
+long-term objective to eliminate functionally-redundant pixel cache
+functions to only the ones with the best properties since this
+reduces maintenance and may reduce the depth of the call stack
+(improving performance).</li>
+</ul>
+<p>Feature improvements:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>Windows Delegate Updates/Additions:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>Build Changes:</p>
+<ul class="simple">
+<li>PerlMagick: Sanitize PACKAGE_VERSION so that Perl is not confused by
+any trailing alpha character.</li>
+<li>Improved symbol renaming due to adding --enable-symbol-prefix.  Some
+symbols (for static const strings) were not being included in the
+renaming.</li>
+</ul>
+<p>Behavior Changes:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+</div>
+<div class="section" id="december-9-2017">
+<h1><a class="toc-backref" href="#id6">1.3.27 (December 9, 2017)</a></h1>
+<p>Special Issues:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>Security Fixes:</p>
+<ul class="simple">
+<li>CMYK: Fix heap overwrites in raw CMYK writer.  Fix heap overwrites
+in raw CMYK reader (noticed when doing montage).</li>
+<li>GIF: Assure that global colormap is initialized.</li>
+<li>DescribeImage(): Fix possible heap write overflow when describing
+visual image directory. Fix possible heap read overflow while
+accessing heap data, and possible information disclosure while
+describing the IPTC profile.</li>
+<li>DICOM: Fix huge memory allocation based on bogus length value (DOS
+opportunity).</li>
+<li>DrawDashPolygon(): Fix heap out of bounds read in render code.</li>
+<li>GRAY: Fix heap overwrites in raw GRAY reader (noticed when doing
+montage).</li>
+<li>JNG: Fix heap overruns.  Fix assertions.</li>
+<li>JNG: Prevent a crash due to zero-length color_image while reading a
+JNG image. (CVE-2017-11102).  Reject JNG files with unreasonable
+dimensions given the file size (avoid DOS).</li>
+<li>JNX: Fix DOS due to excessive memory allocations with corrupt file.</li>
+<li>JPEG: Do not allocate backing image pixels until a scanline has been
+successfully read.  Avoids DOS opportunity with suitably
+manufactured file.</li>
+<li>MAP: Fix null pointer dereference or segmentation violation.</li>
+<li>MAT: Fix heap write overflow.</li>
+<li>MNG: Reject over-large (65k by 65k) image.  Fix heap overwrites.</li>
+<li>PAM: Fix heap buffer overflow in PAM writer for 1 bit/sample + alpha.</li>
+<li>PICT: Fix excessive memory allocation due to malformed image file.</li>
+<li>PNG: Fix heap buffer overflow in PNG writer when promoting from
+indexed PNG to RGBA.</li>
+<li>PNM: Fix DOS due to excessive memory allocations with corrupt file.</li>
+<li>RGB: Fix heap overwrite in raw RGB writer. Fix heap overwrites in
+raw RGB reader (noticed when doing montage).</li>
+<li>RLE: Fix DOS opportunities due to false claims in image header.  Fix
+heap out of bounds read.</li>
+<li>SFW: Avoid possible heap write overflow.</li>
+<li>SUN: Fix heap read overflow.  Fix DOS due to excessive memory
+allocations with corrupt file.</li>
+<li>SVG: Fix heap write overflow.</li>
+<li>TIFF: Use heuristics to avoid DOS (excessive memory use) due to
+false claims by input file.  It is possible that this may reject
+some valid files.  Fix possible small heap overwrite beyond the
+allocated scanline buffer due to the NumberOfObjectsInArray() macro
+rounding up rather than down.</li>
+<li>UIL: Fix heap overwrite in writer.</li>
+<li>WPG: Fix DOS issues (memory, disk space, CPU time) due to
+insufficient validations.  Fix heap overwrites.</li>
+<li>XBM: Fix DOS issue where code remains stuck in loop and does not
+return.</li>
+<li>XV 332 (PNM): Fix null pointer dereference due to malformed file.</li>
+<li>TracePSClippingPath()/TraceSVGClippingPath(): Fix heap out of bounds
+read.</li>
+<li>Validate path entries in the MAGICK_CODER_MODULE_PATH and
+MAGICK_FILTER_MODULE_PATH environment variables and convert all
+paths to real paths if possible. This avoids possible use of
+relative paths to load modules (a possible security issue), or the
+possibility of adding a directory which was in the path, but
+missing, and may improve efficiency by removing non-existent paths.</li>
+</ul>
+<p>Bug fixes:</p>
+<ul class="simple">
+<li>AVS: Memory leaks eliminated.</li>
+<li>CINEON: Fix possible use of NULL pointer.</li>
+<li>CMYK: Memory leaks eliminated.</li>
+<li>CUT: Memory leaks eliminated.  Fix possible use of NULL pointer.</li>
+<li>DCM: Fix possible use of NULL pointer.</li>
+<li>DrawImage(): Avoid &quot;negative&quot; strncpy().  This seems to be benign
+with glibc but perhaps not with other implementations.</li>
+<li>DPX: Memory leaks eliminated.</li>
+<li>EMF: Fix possible use of NULL pointer.</li>
+<li>FindMagickModule(): Fix possible use of NULL pointer.</li>
+<li>FITS: Fix memory leak.</li>
+<li>GIF: Fix memory leak.</li>
+<li>HDF: Memory leaks eliminated.</li>
+<li>HISTOGRAM: Fix memory leak.</li>
+<li>JNG: Memory leaks eliminated. Memory use after free and double-free
+issues eliminated.  Error reporting fixes.</li>
+<li>Magick::Options::strokeDashArray(): Fix possible use of NULL pointer.</li>
+<li>MagickXFileBrowserWidget(): Fix possible use of NULL pointer.</li>
+<li>MAT: Memory leaks eliminated.</li>
+<li>MagickMapCloneMap(): Fix possible assertion failure.</li>
+<li>MNG: Memory use after free issues eliminated.  Fix possible use of
+NULL pointer.  Fix memory leaks.</li>
+<li>MontageImageCommand(): Fix memory leaks.</li>
+<li>MPC: Fix memory leak in writer.</li>
+<li>MPEG: Fix memory leaks in writer.</li>
+<li>MTV: Memory leaks eliminated.</li>
+<li>NTRegistryKeyLookup(): Fix possible use of NULL pointer.</li>
+<li>NTGetTypeList(): Fix possible use of NULL pointer.</li>
+<li>PCD: Memory leaks eliminated.</li>
+<li>PCL: Fix null pointer dereference in PCL writer.</li>
+<li>PCX: Memory leaks eliminated.</li>
+<li>PALM: Fix possible use of NULL pointer. Fix memory leak.</li>
+<li>PICT: Memory leaks eliminated.</li>
+<li>PNG: Fix small (one-off) heap read overflow.</li>
+<li>PNM: Fix memory leaks.</li>
+<li>PS: Fix use of null pointer in error path.</li>
+<li>PWP: Fix possible use of null pointer.</li>
+<li>ReplaceImageColormap(): Throw an exception rather than assertion if
+the input image is not colormapped.</li>
+<li>RGB: Fix memory leak.</li>
+<li>SegmentImage(): Fix possible use of NULL pointer.</li>
+<li>SetImageProfile(): Fix possible assertion failure.</li>
+<li>SGI: Check for EOF while reading SGI file header.</li>
+<li>SUN: Fix memory leak.</li>
+<li>TIFF: Fix possible use of NULL pointer.  Fix memory leaks in writer.</li>
+<li>TIM: Fix memory leak.</li>
+<li>TOPOL: Fix possible use of NULL pointer.  Fix memory leaks.</li>
+<li>VIFF: Fix memory leak.</li>
+<li>WEBP: Detect partial write to output file.</li>
+<li>WPG: Fix possible use of null pointer. Fix excessive use of disk
+resources due to insufficient validations.</li>
+<li>WriteImage(): Restore use of GetBlobStatus() to test if an I/O error
+was encountered while writing output file. This assures that I/O
+failure in writers which do not themselves verify writes is assured
+to be reported.</li>
+<li>WMF: Memory use after free issues eliminated.</li>
+<li>YUV: Fix memory leaks.</li>
+</ul>
+<p>New Features:</p>
+<ul class="simple">
+<li>PNG: Implemented eXIf chunk support.</li>
+<li>WEBP: Add support for EXIF and ICC metadata provided that at least
+libwebp 0.5.0 is used.</li>
+<li>Magick++ Image autoOrient(): New Image method to auto-orient an
+image so it looks right-side up by default.</li>
+</ul>
+<p>Feature improvements:</p>
+<ul class="simple">
+<li>None</li>
+</ul>
+<p>Windows Delegate Updates/Additions:</p>
+<ul class="simple">
+<li>Libtiff is updated to libtiff 4.0.9.</li>
+</ul>
+<p>Build Changes:</p>
+<ul class="simple">
+<li>JPEG/PNG: The SETJMP_IS_THREAD_SAFE definition is used to determine
+if setjmp/longjmp are thread safe.  If these interfaces are thread
+safe, then concurrent reads/writes are possible.  This definition is
+false for Solaris but true for Linux.  JPEG and PNG will be fully
+concurrent if this definition is enabled.</li>
+</ul>
+<p>Behavior Changes:</p>
+<ul class="simple">
+<li>PALM: PALM writer is disabled.</li>
+<li>ThrowLoggedException(): Capture the first exception at
+ErrorException level or greater, or only capture exception if it is
+more severe than an already reported exception.</li>
+<li>DestroyJNG(): This internal function is now declared static and is
+removed from shared library or DLL namespace.</li>
 </ul>
 </div>
 <div class="section" id="july-4-2017">
-<h1><a class="toc-backref" href="#id4">1.3.26 (July 4, 2017)</a></h1>
+<h1><a class="toc-backref" href="#id7">1.3.26 (July 4, 2017)</a></h1>
 <p>Special Issues:</p>
 <ul class="simple">
 <li>None</li>
@@ -136,33 +646,22 @@ library in state 0. (LibJpeg).&quot;).</li>
 <li>XCF: Error checking is improved.</li>
 </ul>
 <p>New Features:</p>
-<ul>
-<li><p class="first">EXIF rotation: Support is added such that the EXIF orientation tag
-is updated when the image is rotated.</p>
-</li>
-<li><p class="first">MAT: Now support reading multiple images from Matlab V4 format.</p>
-</li>
-<li><p class="first">Magick++: Orientation method now updates orientation in EXIF
-profile, if it exists.</p>
-</li>
-<li><p class="first">Magick++: Added Image attribute method which accepts a 'char <a href="#id1"><span class="problematic" id="id2">*</span></a>'
-argument, and will remove the attribute if the value argument is
-NULL.</p>
-<div class="system-message" id="id1">
-<p class="system-message-title">System Message: WARNING/2 (<tt class="docutils">/home/bfriesen/src/graphics/GM/NEWS.txt</tt>, line 114); <em><a href="#id2">backlink</a></em></p>
-<p>Inline emphasis start-string without end-string.</p>
-</div>
-</li>
-<li><p class="first">-orient: The -orient command line option now also updates the
-orientation in the EXIF profile, if it exists.</p>
-</li>
-<li><p class="first">PGX: Support PGX JPEG 2000 format for reading and writing (within
-the bounds of what JasPer supports).</p>
-</li>
-<li><p class="first">Wand API: Added MagickAutoOrientImage(),
+<ul class="simple">
+<li>EXIF rotation: Support is added such that the EXIF orientation tag
+is updated when the image is rotated.</li>
+<li>MAT: Now support reading multiple images from Matlab V4 format.</li>
+<li>Magick++: Orientation method now updates orientation in EXIF
+profile, if it exists.</li>
+<li>Magick++: Added Image attribute method which accepts a character
+pointer argument, and will remove the attribute if the value
+argument is NULL.</li>
+<li>-orient: The -orient command line option now also updates the
+orientation in the EXIF profile, if it exists.</li>
+<li>PGX: Support PGX JPEG 2000 format for reading and writing (within
+the bounds of what JasPer supports).</li>
+<li>Wand API: Added MagickAutoOrientImage(),
 MagickGetImageOrientation(), MagickSetImageOrientation(),
-MagickRemoveImageOption(), and MagickClearException().</p>
-</li>
+MagickRemoveImageOption(), and MagickClearException().</li>
 </ul>
 <p>Feature improvements:</p>
 <ul class="simple">
@@ -191,7 +690,7 @@ source tree.  All of these depend on proprietary components.</li>
 </ul>
 </div>
 <div class="section" id="september-5-2016">
-<h1><a class="toc-backref" href="#id5">1.3.25 (September 5, 2016)</a></h1>
+<h1><a class="toc-backref" href="#id8">1.3.25 (September 5, 2016)</a></h1>
 <p>Special Issues:</p>
 <ul class="simple">
 <li>None</li>
@@ -268,7 +767,7 @@ seconds precision in in elapsed time output.</li>
 </ul>
 </div>
 <div class="section" id="may-30-2016">
-<h1><a class="toc-backref" href="#id6">1.3.24 (May 30, 2016)</a></h1>
+<h1><a class="toc-backref" href="#id9">1.3.24 (May 30, 2016)</a></h1>
 <p>Special Issues:</p>
 <ul class="simple">
 <li>A shell exploit (CVE-2016-5118) was discovered associated with a
@@ -390,7 +889,7 @@ delegate.mgk file.</li>
 </ul>
 </div>
 <div class="section" id="november-7-2015">
-<h1><a class="toc-backref" href="#id7">1.3.23 (November 7, 2015)</a></h1>
+<h1><a class="toc-backref" href="#id10">1.3.23 (November 7, 2015)</a></h1>
 <p>Special Issues:</p>
 <ul class="simple">
 <li>Due to <a class="reference external" href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53967">GCC bug 53967</a>, several key agorithms (e.g. convolution)
@@ -455,7 +954,7 @@ available in recent Ghostscript.</li>
 </ul>
 </div>
 <div class="section" id="october-4-2015">
-<h1><a class="toc-backref" href="#id8">1.3.22 (October 4, 2015)</a></h1>
+<h1><a class="toc-backref" href="#id11">1.3.22 (October 4, 2015)</a></h1>
 <p>Thanks:</p>
 <ul class="simple">
 <li>Coverity: We thank Coverity for providing free service for free
@@ -564,7 +1063,7 @@ The STL function-object equivalent of the deprecated method is removed
 entirely.</p>
 </div>
 <div class="section" id="february-28-2015">
-<h1><a class="toc-backref" href="#id9">1.3.21 (February 28, 2015)</a></h1>
+<h1><a class="toc-backref" href="#id12">1.3.21 (February 28, 2015)</a></h1>
 <p>Thanks:</p>
 <blockquote>
 <ul class="simple">
@@ -801,7 +1300,7 @@ for an RGB image.</li>
 </blockquote>
 </div>
 <div class="section" id="august-16-2014">
-<h1><a class="toc-backref" href="#id10">1.3.20 (August 16, 2014)</a></h1>
+<h1><a class="toc-backref" href="#id13">1.3.20 (August 16, 2014)</a></h1>
 <p>Special Issues:</p>
 <blockquote>
 <ul class="simple">
@@ -965,7 +1464,7 @@ optimizations since their implementations have been problematic.</li>
 </blockquote>
 </div>
 <div class="section" id="december-31-2013">
-<h1><a class="toc-backref" href="#id11">1.3.19 (December 31, 2013)</a></h1>
+<h1><a class="toc-backref" href="#id14">1.3.19 (December 31, 2013)</a></h1>
 <p>Special Issues:</p>
 <blockquote>
 <ul class="simple">
@@ -1124,7 +1623,7 @@ multiple Ghostscript versions.</li>
 </blockquote>
 </div>
 <div class="section" id="march-10-2013">
-<h1><a class="toc-backref" href="#id12">1.3.18 (March 10, 2013)</a></h1>
+<h1><a class="toc-backref" href="#id15">1.3.18 (March 10, 2013)</a></h1>
 <p>Special Issues:</p>
 <blockquote>
 <ul class="simple">
@@ -1238,7 +1737,7 @@ color is in the same colorspace as the image.</li>
 </blockquote>
 </div>
 <div class="section" id="october-13-2012">
-<h1><a class="toc-backref" href="#id13">1.3.17 (October 13, 2012)</a></h1>
+<h1><a class="toc-backref" href="#id16">1.3.17 (October 13, 2012)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -1325,7 +1824,7 @@ will search for firefox, google-chrome, mozilla (in that order).</li>
 </blockquote>
 </div>
 <div class="section" id="june-24-2012">
-<h1><a class="toc-backref" href="#id14">1.3.16 (June 24, 2012)</a></h1>
+<h1><a class="toc-backref" href="#id17">1.3.16 (June 24, 2012)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -1390,7 +1889,7 @@ include OpenMP support for it by default.</li>
 None</blockquote>
 </div>
 <div class="section" id="april-28-2012">
-<h1><a class="toc-backref" href="#id15">1.3.15 (April 28, 2012)</a></h1>
+<h1><a class="toc-backref" href="#id18">1.3.15 (April 28, 2012)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -1464,7 +1963,7 @@ anticipate the automatic file numbering.</li>
 </blockquote>
 </div>
 <div class="section" id="february-25-2012">
-<h1><a class="toc-backref" href="#id16">1.3.14 (February 25, 2012)</a></h1>
+<h1><a class="toc-backref" href="#id19">1.3.14 (February 25, 2012)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -1521,7 +2020,7 @@ was using the filter setting from the Image structure instead.</li>
 </blockquote>
 </div>
 <div class="section" id="december-24-2011">
-<h1><a class="toc-backref" href="#id17">1.3.13 (December 24, 2011)</a></h1>
+<h1><a class="toc-backref" href="#id20">1.3.13 (December 24, 2011)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 None</blockquote>
@@ -1675,7 +2174,7 @@ static builds.</li>
 </blockquote>
 </div>
 <div class="section" id="march-8-2010">
-<h1><a class="toc-backref" href="#id18">1.3.12 (March 8, 2010)</a></h1>
+<h1><a class="toc-backref" href="#id21">1.3.12 (March 8, 2010)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -1719,7 +2218,7 @@ would be written.</li>
 </blockquote>
 </div>
 <div class="section" id="february-21-2010">
-<h1><a class="toc-backref" href="#id19">1.3.11 (February 21, 2010)</a></h1>
+<h1><a class="toc-backref" href="#id22">1.3.11 (February 21, 2010)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -1771,7 +2270,7 @@ opaque.</li>
 </blockquote>
 </div>
 <div class="section" id="february-10-2010">
-<h1><a class="toc-backref" href="#id20">1.3.10 (February 10, 2010)</a></h1>
+<h1><a class="toc-backref" href="#id23">1.3.10 (February 10, 2010)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -1818,7 +2317,7 @@ scene number substition is desired in the output file names.</li>
 </blockquote>
 </div>
 <div class="section" id="february-4-2010">
-<h1><a class="toc-backref" href="#id21">1.3.9 (February 4, 2010)</a></h1>
+<h1><a class="toc-backref" href="#id24">1.3.9 (February 4, 2010)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -1878,7 +2377,7 @@ image in the list if it is not already opaque.</li>
 </blockquote>
 </div>
 <div class="section" id="january-21-2010">
-<h1><a class="toc-backref" href="#id22">1.3.8 (January 21, 2010)</a></h1>
+<h1><a class="toc-backref" href="#id25">1.3.8 (January 21, 2010)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -2032,7 +2531,7 @@ distributed.</li>
 </blockquote>
 </div>
 <div class="section" id="september-17-2009">
-<h1><a class="toc-backref" href="#id23">1.3.7 (September 17, 2009)</a></h1>
+<h1><a class="toc-backref" href="#id26">1.3.7 (September 17, 2009)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -2122,7 +2621,7 @@ structure is clean prior to invoking a function.</li>
 </blockquote>
 </div>
 <div class="section" id="july-25-2009">
-<h1><a class="toc-backref" href="#id24">1.3.6 (July 25, 2009)</a></h1>
+<h1><a class="toc-backref" href="#id27">1.3.6 (July 25, 2009)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -2256,7 +2755,7 @@ progressive JPEG.</li>
 </blockquote>
 </div>
 <div class="section" id="january-26-2009">
-<h1><a class="toc-backref" href="#id25">1.3.5 (January 26, 2009)</a></h1>
+<h1><a class="toc-backref" href="#id28">1.3.5 (January 26, 2009)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -2295,7 +2794,7 @@ not available.</li>
 </blockquote>
 </div>
 <div class="section" id="january-13-2009">
-<h1><a class="toc-backref" href="#id26">1.3.4 (January 13, 2009)</a></h1>
+<h1><a class="toc-backref" href="#id29">1.3.4 (January 13, 2009)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -2334,7 +2833,7 @@ not available.</li>
 </blockquote>
 </div>
 <div class="section" id="december-9-2008">
-<h1><a class="toc-backref" href="#id27">1.3.3 (December 9, 2008)</a></h1>
+<h1><a class="toc-backref" href="#id30">1.3.3 (December 9, 2008)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -2366,7 +2865,7 @@ used in a directory containing a million files.</li>
 </blockquote>
 </div>
 <div class="section" id="november-29-2008">
-<h1><a class="toc-backref" href="#id28">1.3.2 (November 29, 2008)</a></h1>
+<h1><a class="toc-backref" href="#id31">1.3.2 (November 29, 2008)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -2400,7 +2899,7 @@ process the opacity channel unless the image has one.</li>
 </blockquote>
 </div>
 <div class="section" id="november-17-2008">
-<h1><a class="toc-backref" href="#id29">1.3.1 (November 17, 2008)</a></h1>
+<h1><a class="toc-backref" href="#id32">1.3.1 (November 17, 2008)</a></h1>
 <p>Security Fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -2438,7 +2937,7 @@ encoding is used via jpeg:optimize-coding define.</li>
 </blockquote>
 </div>
 <div class="section" id="november-9-2008">
-<h1><a class="toc-backref" href="#id30">1.3 (November 9, 2008)</a></h1>
+<h1><a class="toc-backref" href="#id33">1.3 (November 9, 2008)</a></h1>
 <p>Security fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -2646,7 +3145,7 @@ dither any named channel.</li>
 </blockquote>
 </div>
 <div class="section" id="april-29-2008">
-<h1><a class="toc-backref" href="#id31">1.2 (April 29, 2008)</a></h1>
+<h1><a class="toc-backref" href="#id34">1.2 (April 29, 2008)</a></h1>
 <p>Security fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -2902,7 +3401,7 @@ distributed).</li>
 </blockquote>
 </div>
 <div class="section" id="released-april-4-2004">
-<h1><a class="toc-backref" href="#id32">1.1 (Released April 4, 2004)</a></h1>
+<h1><a class="toc-backref" href="#id35">1.1 (Released April 4, 2004)</a></h1>
 <p>Bug fixes:</p>
 <blockquote>
 <ul class="simple">
@@ -3142,7 +3641,7 @@ logging system.</li>
 </div>
 <hr class="docutils" />
 <div class="section" id="released-in-may-2003">
-<h1><a class="toc-backref" href="#id33">1.0 (Released in May, 2003)</a></h1>
+<h1><a class="toc-backref" href="#id36">1.0 (Released in May, 2003)</a></h1>
 <p>GraphicsMagick support services:</p>
 <blockquote>
 <ul class="simple">
@@ -3288,7 +3787,7 @@ ImageMagick, several days before the ImageMagick 5.5.2 release.</p>
 </ul>
 </blockquote>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index d2ab11a..57ee09c 100644 (file)
@@ -10103,7 +10103,7 @@ bonded to a L3 cache in the same chip package.</p>
 </table>
 <hr class="docutils" />
 <div class="line-block">
-<div class="line">Copyright (C) 2008 - 2017 GraphicsMagick Group</div>
+<div class="line">Copyright (C) 2008 - 2018 GraphicsMagick Group</div>
 </div>
 <p>This program is covered by multiple licenses, which are described in
 Copyright.txt. You should have received a copy of Copyright.txt with this
index 1f03cec..0118a44 100644 (file)
@@ -1482,7 +1482,7 @@ The following shows the performance boost for a Q16 build:
 
 --------------------------------------------------------------------------
 
-| Copyright (C) 2008 - 2017 GraphicsMagick Group
+| Copyright (C) 2008 - 2018 GraphicsMagick Group
 
 This program is covered by multiple licenses, which are described in
 Copyright.txt. You should have received a copy of Copyright.txt with this
index 9805021..d528326 100644 (file)
@@ -146,8 +146,7 @@ available as</p>
 </blockquote>
 <p>to annotate with TrueType and Postscript Type 1 fonts.</p>
 </li>
-<li><p class="first">GraphicsMagick requires Ghostscript software (version 9.04
-recommended) available from</p>
+<li><p class="first">GraphicsMagick requires Ghostscript software available from</p>
 <blockquote>
 <p><a class="reference external" href="http://pages.cs.wisc.edu/~ghost/">http://pages.cs.wisc.edu/~ghost/</a></p>
 <blockquote>
@@ -160,6 +159,15 @@ recommended) available from</p>
 <blockquote>
 <p><a class="reference external" href="https://sourceforge.net/projects/gs-fonts/">https://sourceforge.net/projects/gs-fonts/</a></p>
 </blockquote>
+<p>Ghostscript (at the time this text is written in October, 2018) has
+been observed to have severe security issues when reading untrusted
+Postscript files (does not apply to PDF).  Examples of these severe
+security issues are being tricked into reading or writing arbitrary
+files when executing in &quot;-dSAFER&quot; mode, which which is supposed to
+prevent such access.  Users of Ghostscript who may encounter
+untrusted Postscript files are recommended to assure that all
+security patches have been applied and it might be necessary to use
+the latest upstream release.</p>
 <p>Ghostscript is available for use under both free (GPL) and
 commercial licenses.  We are not lawyers so we can not provide
 advice as to when the commercial license from Artifex is required.
@@ -373,9 +381,16 @@ distributed with &quot;.xz&quot; or &quot;.lzma&quot; extensions.</p>
 </blockquote>
 <p>to read or write the PNG or Zip compressed MIFF images.</p>
 </li>
+<li><p class="first">GraphicsMagick requires the Zstd library from</p>
+<blockquote>
+<p><a class="reference external" href="https://facebook.github.io/zstd/">https://facebook.github.io/zstd/</a></p>
+</blockquote>
+<p>to read or write Zstd compressed TIFF images.  In the future it is
+likely that other purposes will be found for Zstd.</p>
+</li>
 </ul>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index e7c4449..9ad45ce 100644 (file)
@@ -280,7 +280,7 @@ out.miff'.</p>
 compile the GraphicsMagick utilities. Using compatible options ensures that
 your program will compile and run.</p>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </body>
 </html>
index 1bc70b0..dc5e86d 100644 (file)
@@ -301,5 +301,5 @@ your program will compile and run.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
 
index 573c51d..8168993 100644 (file)
@@ -57,7 +57,7 @@ MagickPassFail CloneImageAttributes( <a class="reference external" href="../api/
 </div>
 <div class="section" id="description">
 <h2>Description</h2>
-<p>CloneImageAttributes() copies the text attibutes from one image to another.
+<p>CloneImageAttributes() copies the text attributes from one image to another.
 Any text attributes in the destination image are preserved.
 CloneImageAttributes returns MagickPass if all of the attribututes are
 successfully cloned or MagickFail if there is a memory allocation error.</p>
index e690eb6..b2c70d7 100644 (file)
 <div class="contents topic" id="contents">
 <p class="topic-title first">Contents</p>
 <ul class="simple">
-<li><a class="reference internal" href="#attachblob" id="id43">AttachBlob</a></li>
-<li><a class="reference internal" href="#blobisseekable" id="id44">BlobIsSeekable</a></li>
-<li><a class="reference internal" href="#blobreservesize" id="id45">BlobReserveSize</a></li>
-<li><a class="reference internal" href="#blobtofile" id="id46">BlobToFile</a></li>
-<li><a class="reference internal" href="#blobtoimage" id="id47">BlobToImage</a></li>
-<li><a class="reference internal" href="#cloneblobinfo" id="id48">CloneBlobInfo</a></li>
-<li><a class="reference internal" href="#destroyblob" id="id49">DestroyBlob</a></li>
-<li><a class="reference internal" href="#destroyblobinfo" id="id50">DestroyBlobInfo</a></li>
-<li><a class="reference internal" href="#detachblob" id="id51">DetachBlob</a></li>
-<li><a class="reference internal" href="#filetoblob" id="id52">FileToBlob</a></li>
-<li><a class="reference internal" href="#getblobfilehandle" id="id53">GetBlobFileHandle</a></li>
-<li><a class="reference internal" href="#getblobinfo" id="id54">GetBlobInfo</a></li>
-<li><a class="reference internal" href="#getblobstatus" id="id55">GetBlobStatus</a></li>
-<li><a class="reference internal" href="#getblobstreamdata" id="id56">GetBlobStreamData</a></li>
-<li><a class="reference internal" href="#getblobtemporary" id="id57">GetBlobTemporary</a></li>
-<li><a class="reference internal" href="#getconfigureblob" id="id58">GetConfigureBlob</a></li>
-<li><a class="reference internal" href="#imagetoblob" id="id59">ImageToBlob</a></li>
-<li><a class="reference internal" href="#imagetofile" id="id60">ImageToFile</a></li>
-<li><a class="reference internal" href="#pingblob" id="id61">PingBlob</a></li>
-<li><a class="reference internal" href="#referenceblob" id="id62">ReferenceBlob</a></li>
-<li><a class="reference internal" href="#setblobclosable" id="id63">SetBlobClosable</a></li>
-<li><a class="reference internal" href="#setblobtemporary" id="id64">SetBlobTemporary</a></li>
+<li><a class="reference internal" href="#attachblob" id="id45">AttachBlob</a></li>
+<li><a class="reference internal" href="#blobisseekable" id="id46">BlobIsSeekable</a></li>
+<li><a class="reference internal" href="#blobreservesize" id="id47">BlobReserveSize</a></li>
+<li><a class="reference internal" href="#blobtofile" id="id48">BlobToFile</a></li>
+<li><a class="reference internal" href="#blobtoimage" id="id49">BlobToImage</a></li>
+<li><a class="reference internal" href="#cloneblobinfo" id="id50">CloneBlobInfo</a></li>
+<li><a class="reference internal" href="#destroyblob" id="id51">DestroyBlob</a></li>
+<li><a class="reference internal" href="#destroyblobinfo" id="id52">DestroyBlobInfo</a></li>
+<li><a class="reference internal" href="#detachblob" id="id53">DetachBlob</a></li>
+<li><a class="reference internal" href="#filetoblob" id="id54">FileToBlob</a></li>
+<li><a class="reference internal" href="#getblobfilehandle" id="id55">GetBlobFileHandle</a></li>
+<li><a class="reference internal" href="#getblobinfo" id="id56">GetBlobInfo</a></li>
+<li><a class="reference internal" href="#getblobstatus" id="id57">GetBlobStatus</a></li>
+<li><a class="reference internal" href="#getblobfirsterrno" id="id58">GetBlobFirstErrno</a></li>
+<li><a class="reference internal" href="#getblobstreamdata" id="id59">GetBlobStreamData</a></li>
+<li><a class="reference internal" href="#getblobtemporary" id="id60">GetBlobTemporary</a></li>
+<li><a class="reference internal" href="#getconfigureblob" id="id61">GetConfigureBlob</a></li>
+<li><a class="reference internal" href="#imagetoblob" id="id62">ImageToBlob</a></li>
+<li><a class="reference internal" href="#imagetofile" id="id63">ImageToFile</a></li>
+<li><a class="reference internal" href="#pingblob" id="id64">PingBlob</a></li>
+<li><a class="reference internal" href="#referenceblob" id="id65">ReferenceBlob</a></li>
+<li><a class="reference internal" href="#setblobclosable" id="id66">SetBlobClosable</a></li>
+<li><a class="reference internal" href="#setblobtemporary" id="id67">SetBlobTemporary</a></li>
 </ul>
 </div>
 <div class="section" id="attachblob">
-<h1><a class="toc-backref" href="#id43">AttachBlob</a></h1>
+<h1><a class="toc-backref" href="#id45">AttachBlob</a></h1>
 <div class="section" id="synopsis">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -91,7 +92,7 @@ understood by GraphicsMagick.</dd>
 </div>
 </div>
 <div class="section" id="blobisseekable">
-<h1><a class="toc-backref" href="#id44">BlobIsSeekable</a></h1>
+<h1><a class="toc-backref" href="#id46">BlobIsSeekable</a></h1>
 <div class="section" id="id1">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -114,7 +115,7 @@ MagickBool BlobIsSeekable( const <a class="reference external" href="../api/type
 </div>
 </div>
 <div class="section" id="blobreservesize">
-<h1><a class="toc-backref" href="#id45">BlobReserveSize</a></h1>
+<h1><a class="toc-backref" href="#id47">BlobReserveSize</a></h1>
 <div class="section" id="id3">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -143,7 +144,7 @@ MagickPassFail BlobReserveSize( <a class="reference external" href="../api/types
 </div>
 </div>
 <div class="section" id="blobtofile">
-<h1><a class="toc-backref" href="#id46">BlobToFile</a></h1>
+<h1><a class="toc-backref" href="#id48">BlobToFile</a></h1>
 <div class="section" id="id5">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -176,7 +177,7 @@ returns MagickFail if an error occurs.</dd>
 </div>
 </div>
 <div class="section" id="blobtoimage">
-<h1><a class="toc-backref" href="#id47">BlobToImage</a></h1>
+<h1><a class="toc-backref" href="#id49">BlobToImage</a></h1>
 <div class="section" id="id7">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -207,7 +208,7 @@ understood by GraphicsMagick.</dd>
 </div>
 </div>
 <div class="section" id="cloneblobinfo">
-<h1><a class="toc-backref" href="#id48">CloneBlobInfo</a></h1>
+<h1><a class="toc-backref" href="#id50">CloneBlobInfo</a></h1>
 <div class="section" id="id9">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -233,7 +234,7 @@ blob info, or if blob info is NULL a new one.</dd>
 </div>
 </div>
 <div class="section" id="destroyblob">
-<h1><a class="toc-backref" href="#id49">DestroyBlob</a></h1>
+<h1><a class="toc-backref" href="#id51">DestroyBlob</a></h1>
 <div class="section" id="id11">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -257,7 +258,7 @@ void DestroyBlob( <a class="reference external" href="../api/types.html#image">I
 </div>
 </div>
 <div class="section" id="destroyblobinfo">
-<h1><a class="toc-backref" href="#id50">DestroyBlobInfo</a></h1>
+<h1><a class="toc-backref" href="#id52">DestroyBlobInfo</a></h1>
 <div class="section" id="id13">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -283,7 +284,7 @@ void DestroyBlobInfo( <a class="reference external" href="../api/types.html#blob
 </div>
 </div>
 <div class="section" id="detachblob">
-<h1><a class="toc-backref" href="#id51">DetachBlob</a></h1>
+<h1><a class="toc-backref" href="#id53">DetachBlob</a></h1>
 <div class="section" id="id15">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -305,7 +306,7 @@ void DetachBlob( <a class="reference external" href="../api/types.html#blobinfo"
 </div>
 </div>
 <div class="section" id="filetoblob">
-<h1><a class="toc-backref" href="#id52">FileToBlob</a></h1>
+<h1><a class="toc-backref" href="#id54">FileToBlob</a></h1>
 <div class="section" id="id17">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -341,7 +342,7 @@ blob.  On return, it reflects the actual length of the blob.</dd>
 </div>
 </div>
 <div class="section" id="getblobfilehandle">
-<h1><a class="toc-backref" href="#id53">GetBlobFileHandle</a></h1>
+<h1><a class="toc-backref" href="#id55">GetBlobFileHandle</a></h1>
 <div class="section" id="id19">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -365,7 +366,7 @@ FILE *GetBlobFileHandle( const <a class="reference external" href="../api/types.
 </div>
 </div>
 <div class="section" id="getblobinfo">
-<h1><a class="toc-backref" href="#id54">GetBlobInfo</a></h1>
+<h1><a class="toc-backref" href="#id56">GetBlobInfo</a></h1>
 <div class="section" id="id21">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -387,7 +388,7 @@ void GetBlobInfo( <a class="reference external" href="../api/types.html#blobinfo
 </div>
 </div>
 <div class="section" id="getblobstatus">
-<h1><a class="toc-backref" href="#id55">GetBlobStatus</a></h1>
+<h1><a class="toc-backref" href="#id57">GetBlobStatus</a></h1>
 <div class="section" id="id23">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -396,7 +397,9 @@ int GetBlobStatus( const <a class="reference external" href="../api/types.html#i
 </div>
 <div class="section" id="id24">
 <h2>Description</h2>
-<p>GetBlobStatus() returns the blob error status.</p>
+<p>GetBlobStatus() returns the blob error status.  For GraphicsMagick
+1.3.26 and earlier, this was only set by CloseBlob() but now it is
+set immediately upon error.</p>
 <p>The format of the GetBlobStatus method is:</p>
 <pre class="literal-block">
 int GetBlobStatus( const <a class="reference external" href="../api/types.html#image">Image</a> *image );
@@ -408,16 +411,41 @@ int GetBlobStatus( const <a class="reference external" href="../api/types.html#i
 </dl>
 </div>
 </div>
-<div class="section" id="getblobstreamdata">
-<h1><a class="toc-backref" href="#id56">GetBlobStreamData</a></h1>
+<div class="section" id="getblobfirsterrno">
+<h1><a class="toc-backref" href="#id58">GetBlobFirstErrno</a></h1>
 <div class="section" id="id25">
 <h2>Synopsis</h2>
 <pre class="literal-block">
-unsigned char *GetBlobStreamData( const <a class="reference external" href="../api/types.html#image">Image</a> *image );
+int GetBlobFirstErrno( const <a class="reference external" href="../api/types.html#image">Image</a> *image );
 </pre>
 </div>
 <div class="section" id="id26">
 <h2>Description</h2>
+<p>GetBlobFirstErrno() returns the errno present (if any) when the blob
+first encountered as error, as indicated by GetBlobStatus().  The
+the purpose of this function is to help improve the quality of error
+reporting.</p>
+<p>The format of the GetBlobFirstErrno method is:</p>
+<pre class="literal-block">
+int GetBlobFirstErrno( const <a class="reference external" href="../api/types.html#image">Image</a> *image );
+</pre>
+<p>A description of each parameter follows:</p>
+<dl class="docutils">
+<dt>image:</dt>
+<dd>The image.</dd>
+</dl>
+</div>
+</div>
+<div class="section" id="getblobstreamdata">
+<h1><a class="toc-backref" href="#id59">GetBlobStreamData</a></h1>
+<div class="section" id="id27">
+<h2>Synopsis</h2>
+<pre class="literal-block">
+unsigned char *GetBlobStreamData( const <a class="reference external" href="../api/types.html#image">Image</a> *image );
+</pre>
+</div>
+<div class="section" id="id28">
+<h2>Description</h2>
 <p>GetBlobStreamData() returns the stream data for the image. The data is only
 available if the data is stored on the heap, or is memory mapped.
 Otherwise a NULL value is returned.</p>
@@ -433,14 +461,14 @@ unsigned char *GetBlobStreamData( const <a class="reference external" href="../a
 </div>
 </div>
 <div class="section" id="getblobtemporary">
-<h1><a class="toc-backref" href="#id57">GetBlobTemporary</a></h1>
-<div class="section" id="id27">
+<h1><a class="toc-backref" href="#id60">GetBlobTemporary</a></h1>
+<div class="section" id="id29">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickBool GetBlobTemporary( const <a class="reference external" href="../api/types.html#image">Image</a> *image );
 </pre>
 </div>
-<div class="section" id="id28">
+<div class="section" id="id30">
 <h2>Description</h2>
 <p>GetBlobTemporary() returns MagickTrue if the file associated with the blob
 is a temporary file and should be removed when the associated image is
@@ -457,14 +485,14 @@ MagickBool GetBlobTemporary( const <a class="reference external" href="../api/ty
 </div>
 </div>
 <div class="section" id="getconfigureblob">
-<h1><a class="toc-backref" href="#id58">GetConfigureBlob</a></h1>
-<div class="section" id="id29">
+<h1><a class="toc-backref" href="#id61">GetConfigureBlob</a></h1>
+<div class="section" id="id31">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 void *GetConfigureBlob( const char *filename, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
 </pre>
 </div>
-<div class="section" id="id30">
+<div class="section" id="id32">
 <h2>Description</h2>
 <p>GetConfigureBlob() returns the specified configure file as a blob.</p>
 <p>The format of the GetConfigureBlob method is:</p>
@@ -486,15 +514,15 @@ blob.  On return, it reflects the actual length of the blob.</dd>
 </div>
 </div>
 <div class="section" id="imagetoblob">
-<h1><a class="toc-backref" href="#id59">ImageToBlob</a></h1>
-<div class="section" id="id31">
+<h1><a class="toc-backref" href="#id62">ImageToBlob</a></h1>
+<div class="section" id="id33">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 void *ImageToBlob( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image, size_t *length,
                    <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
 </pre>
 </div>
-<div class="section" id="id32">
+<div class="section" id="id34">
 <h2>Description</h2>
 <p>ImageToBlob() implements direct to memory image formats.  It returns the
 image as a formatted blob and its length.  The magick member of the Image
@@ -520,15 +548,15 @@ blob.  On return, it reflects the actual length of the blob.</dd>
 </div>
 </div>
 <div class="section" id="imagetofile">
-<h1><a class="toc-backref" href="#id60">ImageToFile</a></h1>
-<div class="section" id="id33">
+<h1><a class="toc-backref" href="#id63">ImageToFile</a></h1>
+<div class="section" id="id35">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickPassFail ImageToFile( <a class="reference external" href="../api/types.html#image">Image</a> *image, const char *filename,
                             <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
 </pre>
 </div>
-<div class="section" id="id34">
+<div class="section" id="id36">
 <h2>Description</h2>
 <p>ImageToFile() copies the input image from an open blob stream to a file.
 It returns False if an error occurs otherwise True.  This function is used
@@ -554,15 +582,15 @@ returns MagickFail if an error occurs.</dd>
 </div>
 </div>
 <div class="section" id="pingblob">
-<h1><a class="toc-backref" href="#id61">PingBlob</a></h1>
-<div class="section" id="id35">
+<h1><a class="toc-backref" href="#id64">PingBlob</a></h1>
+<div class="section" id="id37">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 <a class="reference external" href="../api/types.html#image">Image</a> *PingBlob( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, const void *blob, const size_t length,
                  <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
 </pre>
 </div>
-<div class="section" id="id36">
+<div class="section" id="id38">
 <h2>Description</h2>
 <p>PingBlob() returns all the attributes of an image or image sequence except
 for the pixels.  It is much faster and consumes far less memory than
@@ -587,14 +615,14 @@ understood by GraphicsMagick.</dd>
 </div>
 </div>
 <div class="section" id="referenceblob">
-<h1><a class="toc-backref" href="#id62">ReferenceBlob</a></h1>
-<div class="section" id="id37">
+<h1><a class="toc-backref" href="#id65">ReferenceBlob</a></h1>
+<div class="section" id="id39">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 <a class="reference external" href="../api/types.html#blobinfo">BlobInfo</a> ReferenceBlob( <a class="reference external" href="../api/types.html#blobinfo">BlobInfo</a> *blob_info );
 </pre>
 </div>
-<div class="section" id="id38">
+<div class="section" id="id40">
 <h2>Description</h2>
 <p>ReferenceBlob() increments the reference count associated with the pixel
 blob, returning a pointer to the blob.</p>
@@ -610,14 +638,14 @@ blob, returning a pointer to the blob.</p>
 </div>
 </div>
 <div class="section" id="setblobclosable">
-<h1><a class="toc-backref" href="#id63">SetBlobClosable</a></h1>
-<div class="section" id="id39">
+<h1><a class="toc-backref" href="#id66">SetBlobClosable</a></h1>
+<div class="section" id="id41">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 void SetBlobClosable( <a class="reference external" href="../api/types.html#image">Image</a> *image, MagickBool closeable );
 </pre>
 </div>
-<div class="section" id="id40">
+<div class="section" id="id42">
 <h2>Description</h2>
 <p>SetBlobClosable() enables closing the blob if MagickTrue is passed, and
 exempts the blob from being closed if False is passed.  Blobs are closable
@@ -636,14 +664,14 @@ void SetBlobClosable( <a class="reference external" href="../api/types.html#imag
 </div>
 </div>
 <div class="section" id="setblobtemporary">
-<h1><a class="toc-backref" href="#id64">SetBlobTemporary</a></h1>
-<div class="section" id="id41">
+<h1><a class="toc-backref" href="#id67">SetBlobTemporary</a></h1>
+<div class="section" id="id43">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 void SetBlobTemporary( <a class="reference external" href="../api/types.html#image">Image</a> *image, MagickBool isTemporary );
 </pre>
 </div>
-<div class="section" id="id42">
+<div class="section" id="id44">
 <h2>Description</h2>
 <p>SetBlobTemporary() sets a boolean flag (default False) to specify if
 the file associated with the blob is a temporary file and should be
index 7e86691..02a5c1e 100644 (file)
@@ -259,19 +259,20 @@ describes the reason for the failure.</p>
 <div class="section" id="id9">
 <h2>Synopsis</h2>
 <pre class="literal-block">
-unsigned int WriteImage( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image );
+MagickPassFail WriteImage( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image );
 </pre>
 </div>
 <div class="section" id="id10">
 <h2>Description</h2>
 <p>Use WriteImage() to write an image or an image sequence to a file or
 filehandle.  If writing to a file on disk, the name is defined by the
-filename member of the image structure.  Write() returns 0 is there is a
-memory shortage or if the image cannot be written.  Check the exception
-member of image to determine the cause for any failure.</p>
+filename member of the image structure.  WriteImage() returns
+MagickFailure is there is a memory shortage or if the image cannot be
+written.  Check the exception member of image to determine the cause
+for any failure.</p>
 <p>The format of the WriteImage method is:</p>
 <pre class="literal-block">
-unsigned int WriteImage( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image );
+MagickPassFail WriteImage( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image );
 </pre>
 <p>A description of each parameter follows:</p>
 <dl class="docutils">
@@ -287,8 +288,8 @@ unsigned int WriteImage( const <a class="reference external" href="../api/types.
 <div class="section" id="id11">
 <h2>Synopsis</h2>
 <pre class="literal-block">
-unsigned int WriteImages( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image,
-                          const char *filename, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
+MagickPassFail WriteImages( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image,
+                            const char *filename, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
 </pre>
 </div>
 <div class="section" id="id12">
@@ -303,8 +304,8 @@ to include a printf-style formatting string for the frame number (e.g.
 &quot;image%02d.miff&quot;) so that the frames may be written.</p>
 <p>The format of the WriteImages method is:</p>
 <pre class="literal-block">
-unsigned int WriteImages( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image,
-                          const char *filename, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
+MagickPassFail WriteImages( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image,
+                            const char *filename, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
 </pre>
 <dl class="docutils">
 <dt>image_info:</dt>
index 34f1692..a8caca5 100644 (file)
@@ -1257,7 +1257,7 @@ void DrawPathCurveToAbsolute( <a class="reference external" href="../api/types.h
 </div>
 <div class="section" id="id84">
 <h2>Description</h2>
-<p>DrawPathCurveToAbsolute() draws a cubic Bézier curve from the current
+<p>DrawPathCurveToAbsolute() draws a cubic Bezier curve from the current
 point to (x,y) using (x1,y1) as the control point at the beginning of
 the curve and (x2,y2) as the control point at the end of the curve using
 absolute coordinates. At the end of the command, the new current point
@@ -1298,7 +1298,7 @@ void DrawPathCurveToRelative( <a class="reference external" href="../api/types.h
 </div>
 <div class="section" id="id86">
 <h2>Description</h2>
-<p>DrawPathCurveToRelative() draws a cubic Bézier curve from the current
+<p>DrawPathCurveToRelative() draws a cubic Bezier curve from the current
 point to (x,y) using (x1,y1) as the control point at the beginning of
 the curve and (x2,y2) as the control point at the end of the curve using
 relative coordinates. At the end of the command, the new current point
@@ -1339,7 +1339,7 @@ void DrawPathCurveToQuadraticBezierAbsolute( <a class="reference external" href=
 </div>
 <div class="section" id="id88">
 <h2>Description</h2>
-<p>DrawPathCurveToQuadraticBezierAbsolute() draws a quadratic Bézier curve
+<p>DrawPathCurveToQuadraticBezierAbsolute() draws a quadratic Bezier curve
 from the current point to (x,y) using (x1,y1) as the control point using
 absolute coordinates. At the end of the command, the new current point
 becomes the final (x,y) coordinate pair used in the polybezier.</p>
@@ -1375,7 +1375,7 @@ void DrawPathCurveToQuadraticBezierRelative( <a class="reference external" href=
 </div>
 <div class="section" id="id90">
 <h2>Description</h2>
-<p>DrawPathCurveToQuadraticBezierRelative() draws a quadratic Bézier curve
+<p>DrawPathCurveToQuadraticBezierRelative() draws a quadratic Bezier curve
 from the current point to (x,y) using (x1,y1) as the control point using
 relative coordinates. At the end of the command, the new current point
 becomes the final (x,y) coordinate pair used in the polybezier.</p>
@@ -1411,7 +1411,7 @@ void DrawPathCurveToQuadraticBezierSmoothAbsolute( <a class="reference external"
 <div class="section" id="id92">
 <h2>Description</h2>
 <p>DrawPathCurveToQuadraticBezierSmoothAbsolute() draws a quadratic
-Bézier curve (using absolute coordinates) from the current point to
+Bezier curve (using absolute coordinates) from the current point to
 (x,y). The control point is assumed to be the reflection of the
 control point on the previous command relative to the current
 point. (If there is no previous command or if the previous command was
@@ -1449,7 +1449,7 @@ void DrawPathCurveToQuadraticBezierSmoothRelative( <a class="reference external"
 <div class="section" id="id94">
 <h2>Description</h2>
 <p>DrawPathCurveToQuadraticBezierSmoothAbsolute() draws a quadratic
-Bézier curve (using relative coordinates) from the current point to
+Bezier curve (using relative coordinates) from the current point to
 (x,y). The control point is assumed to be the reflection of the
 control point on the previous command relative to the current
 point. (If there is no previous command or if the previous command was
@@ -1486,7 +1486,7 @@ void DrawPathCurveToSmoothAbsolute( <a class="reference external" href="../api/t
 </div>
 <div class="section" id="id96">
 <h2>Description</h2>
-<p>DrawPathCurveToSmoothAbsolute() draws a cubic Bézier curve from the
+<p>DrawPathCurveToSmoothAbsolute() draws a cubic Bezier curve from the
 current point to (x,y) using absolute coordinates. The first control
 point is assumed to be the reflection of the second control point on
 the previous command relative to the current point. (If there is no
@@ -1527,7 +1527,7 @@ void DrawPathCurveToSmoothRelative( <a class="reference external" href="../api/t
 </div>
 <div class="section" id="id98">
 <h2>Description</h2>
-<p>DrawPathCurveToSmoothRelative() draws a cubic Bézier curve from the
+<p>DrawPathCurveToSmoothRelative() draws a cubic Bezier curve from the
 current point to (x,y) using relative coordinates. The first control
 point is assumed to be the reflection of the second control point on
 the previous command relative to the current point. (If there is no
index acf02b1..c2b8a08 100644 (file)
@@ -392,6 +392,8 @@ void ThrowLoggedException( <a class="reference external" href="../api/types.html
 <p>ThrowLoggedException() throws an exception with the specified severity code,
 reason, optional description, source filename, function name, and line
 number. If logging is enabled, the exception is also logged.</p>
+<p>If the exception already contains an ErrorException (or greater) or the
+existing exception is more severe, then it is ignored.</p>
 <p>The format of the ThrowLoggedException method is:</p>
 <pre class="literal-block">
 void ThrowLoggedException( <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception, const <a class="reference external" href="../api/types.html#exceptiontype">ExceptionType</a> severity,
index 0aa1d40..05083f1 100644 (file)
 <div class="contents topic" id="contents">
 <p class="topic-title first">Contents</p>
 <ul class="simple">
-<li><a class="reference internal" href="#accessdefinition" id="id64">AccessDefinition</a></li>
-<li><a class="reference internal" href="#adddefinition" id="id65">AddDefinition</a></li>
-<li><a class="reference internal" href="#adddefinitions" id="id66">AddDefinitions</a></li>
-<li><a class="reference internal" href="#allocateimage" id="id67">AllocateImage</a></li>
-<li><a class="reference internal" href="#allocatenextimage" id="id68">AllocateNextImage</a></li>
-<li><a class="reference internal" href="#animateimages" id="id69">AnimateImages</a></li>
-<li><a class="reference internal" href="#appendimages" id="id70">AppendImages</a></li>
-<li><a class="reference internal" href="#catchimageexception" id="id71">CatchImageException</a></li>
-<li><a class="reference internal" href="#clippathimage" id="id72">ClipPathImage</a></li>
-<li><a class="reference internal" href="#cloneimage" id="id73">CloneImage</a></li>
-<li><a class="reference internal" href="#cloneimageinfo" id="id74">CloneImageInfo</a></li>
-<li><a class="reference internal" href="#destroyimage" id="id75">DestroyImage</a></li>
-<li><a class="reference internal" href="#destroyimageinfo" id="id76">DestroyImageInfo</a></li>
-<li><a class="reference internal" href="#displayimages" id="id77">DisplayImages</a></li>
-<li><a class="reference internal" href="#getimageclipmask" id="id78">GetImageClipMask</a></li>
-<li><a class="reference internal" href="#getimageexception" id="id79">GetImageException</a></li>
-<li><a class="reference internal" href="#getimagegeometry" id="id80">GetImageGeometry</a></li>
-<li><a class="reference internal" href="#getimageinfo" id="id81">GetImageInfo</a></li>
-<li><a class="reference internal" href="#istaintimage" id="id82">IsTaintImage</a></li>
-<li><a class="reference internal" href="#modifyimage" id="id83">ModifyImage</a></li>
-<li><a class="reference internal" href="#referenceimage" id="id84">ReferenceImage</a></li>
-<li><a class="reference internal" href="#removedefinitions" id="id85">RemoveDefinitions</a></li>
-<li><a class="reference internal" href="#resetimagepage" id="id86">ResetImagePage</a></li>
-<li><a class="reference internal" href="#setimageex" id="id87">SetImageEx</a></li>
-<li><a class="reference internal" href="#setimage" id="id88">SetImage</a></li>
-<li><a class="reference internal" href="#setimagecolor" id="id89">SetImageColor</a></li>
-<li><a class="reference internal" href="#setimagecolorregion" id="id90">SetImageColorRegion</a></li>
-<li><a class="reference internal" href="#setimageclipmask" id="id91">SetImageClipMask</a></li>
-<li><a class="reference internal" href="#setimagedepth" id="id92">SetImageDepth</a></li>
-<li><a class="reference internal" href="#setimageopacity" id="id93">SetImageOpacity</a></li>
-<li><a class="reference internal" href="#setimagetype" id="id94">SetImageType</a></li>
-<li><a class="reference internal" href="#stripimage" id="id95">StripImage</a></li>
+<li><a class="reference internal" href="#accessdefinition" id="id70">AccessDefinition</a></li>
+<li><a class="reference internal" href="#adddefinition" id="id71">AddDefinition</a></li>
+<li><a class="reference internal" href="#adddefinitions" id="id72">AddDefinitions</a></li>
+<li><a class="reference internal" href="#allocateimage" id="id73">AllocateImage</a></li>
+<li><a class="reference internal" href="#allocatenextimage" id="id74">AllocateNextImage</a></li>
+<li><a class="reference internal" href="#animateimages" id="id75">AnimateImages</a></li>
+<li><a class="reference internal" href="#appendimages" id="id76">AppendImages</a></li>
+<li><a class="reference internal" href="#catchimageexception" id="id77">CatchImageException</a></li>
+<li><a class="reference internal" href="#clippathimage" id="id78">ClipPathImage</a></li>
+<li><a class="reference internal" href="#compositepathimage" id="id79">CompositePathImage</a></li>
+<li><a class="reference internal" href="#cloneimage" id="id80">CloneImage</a></li>
+<li><a class="reference internal" href="#cloneimageinfo" id="id81">CloneImageInfo</a></li>
+<li><a class="reference internal" href="#destroyimage" id="id82">DestroyImage</a></li>
+<li><a class="reference internal" href="#destroyimageinfo" id="id83">DestroyImageInfo</a></li>
+<li><a class="reference internal" href="#displayimages" id="id84">DisplayImages</a></li>
+<li><a class="reference internal" href="#getimageclipmask" id="id85">GetImageClipMask</a></li>
+<li><a class="reference internal" href="#getimagecompositemask" id="id86">GetImageCompositeMask</a></li>
+<li><a class="reference internal" href="#getimageexception" id="id87">GetImageException</a></li>
+<li><a class="reference internal" href="#getimagegeometry" id="id88">GetImageGeometry</a></li>
+<li><a class="reference internal" href="#getimageinfo" id="id89">GetImageInfo</a></li>
+<li><a class="reference internal" href="#istaintimage" id="id90">IsTaintImage</a></li>
+<li><a class="reference internal" href="#modifyimage" id="id91">ModifyImage</a></li>
+<li><a class="reference internal" href="#referenceimage" id="id92">ReferenceImage</a></li>
+<li><a class="reference internal" href="#removedefinitions" id="id93">RemoveDefinitions</a></li>
+<li><a class="reference internal" href="#resetimagepage" id="id94">ResetImagePage</a></li>
+<li><a class="reference internal" href="#setimageex" id="id95">SetImageEx</a></li>
+<li><a class="reference internal" href="#setimage" id="id96">SetImage</a></li>
+<li><a class="reference internal" href="#setimagecolor" id="id97">SetImageColor</a></li>
+<li><a class="reference internal" href="#setimagecolorregion" id="id98">SetImageColorRegion</a></li>
+<li><a class="reference internal" href="#setimageclipmask" id="id99">SetImageClipMask</a></li>
+<li><a class="reference internal" href="#setimagecompositemask" id="id100">SetImageCompositeMask</a></li>
+<li><a class="reference internal" href="#setimagedepth" id="id101">SetImageDepth</a></li>
+<li><a class="reference internal" href="#setimageopacity" id="id102">SetImageOpacity</a></li>
+<li><a class="reference internal" href="#setimagetype" id="id103">SetImageType</a></li>
+<li><a class="reference internal" href="#stripimage" id="id104">StripImage</a></li>
 </ul>
 </div>
 <div class="section" id="accessdefinition">
-<h1><a class="toc-backref" href="#id64">AccessDefinition</a></h1>
+<h1><a class="toc-backref" href="#id70">AccessDefinition</a></h1>
 <div class="section" id="synopsis">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -102,7 +105,7 @@ const char *AccessDefinition( const <a class="reference external" href="../api/t
 </div>
 </div>
 <div class="section" id="adddefinition">
-<h1><a class="toc-backref" href="#id65">AddDefinition</a></h1>
+<h1><a class="toc-backref" href="#id71">AddDefinition</a></h1>
 <div class="section" id="id2">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -135,7 +138,7 @@ MagickPassFail AddDefinition( <a class="reference external" href="../api/types.h
 </div>
 </div>
 <div class="section" id="adddefinitions">
-<h1><a class="toc-backref" href="#id66">AddDefinitions</a></h1>
+<h1><a class="toc-backref" href="#id72">AddDefinitions</a></h1>
 <div class="section" id="id4">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -166,7 +169,7 @@ length string as value for a key.</dd>
 </div>
 </div>
 <div class="section" id="allocateimage">
-<h1><a class="toc-backref" href="#id67">AllocateImage</a></h1>
+<h1><a class="toc-backref" href="#id73">AllocateImage</a></h1>
 <div class="section" id="id6">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -191,7 +194,7 @@ and others.</dd>
 </div>
 </div>
 <div class="section" id="allocatenextimage">
-<h1><a class="toc-backref" href="#id68">AllocateNextImage</a></h1>
+<h1><a class="toc-backref" href="#id74">AllocateNextImage</a></h1>
 <div class="section" id="id8">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -219,7 +222,7 @@ and others.</dd>
 </div>
 </div>
 <div class="section" id="animateimages">
-<h1><a class="toc-backref" href="#id69">AnimateImages</a></h1>
+<h1><a class="toc-backref" href="#id75">AnimateImages</a></h1>
 <div class="section" id="id10">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -245,7 +248,7 @@ unsigned int AnimateImages( const <a class="reference external" href="../api/typ
 </div>
 </div>
 <div class="section" id="appendimages">
-<h1><a class="toc-backref" href="#id70">AppendImages</a></h1>
+<h1><a class="toc-backref" href="#id76">AppendImages</a></h1>
 <div class="section" id="id12">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -273,7 +276,7 @@ other top-to-bottom if the stack parameter is true, otherwise left-to-right.</p>
 </div>
 </div>
 <div class="section" id="catchimageexception">
-<h1><a class="toc-backref" href="#id71">CatchImageException</a></h1>
+<h1><a class="toc-backref" href="#id77">CatchImageException</a></h1>
 <div class="section" id="id14">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -297,7 +300,7 @@ it as a warning or error depending on the severity.</p>
 </div>
 </div>
 <div class="section" id="clippathimage">
-<h1><a class="toc-backref" href="#id72">ClipPathImage</a></h1>
+<h1><a class="toc-backref" href="#id78">ClipPathImage</a></h1>
 <div class="section" id="id16">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -326,17 +329,47 @@ Otherwise later operations take effect outside clipping path.</dd>
 </dl>
 </div>
 </div>
-<div class="section" id="cloneimage">
-<h1><a class="toc-backref" href="#id73">CloneImage</a></h1>
+<div class="section" id="compositepathimage">
+<h1><a class="toc-backref" href="#id79">CompositePathImage</a></h1>
 <div class="section" id="id18">
 <h2>Synopsis</h2>
 <pre class="literal-block">
+unsigned int CompositePathImage( <a class="reference external" href="../api/types.html#image">Image</a> *image, const char *pathname,
+                                 const unsigned int inside );
+</pre>
+</div>
+<div class="section" id="id19">
+<h2>Description</h2>
+<p>CompositePathImage() sets the image composite mask based any compositing path information
+if it exists.</p>
+<p>The format of the CompositePathImage method is:</p>
+<pre class="literal-block">
+unsigned int CompositePathImage( <a class="reference external" href="../api/types.html#image">Image</a> *image, const char *pathname,
+                                 const unsigned int inside );
+</pre>
+<dl class="docutils">
+<dt>image:</dt>
+<dd>The image.</dd>
+<dt>pathname:</dt>
+<dd>name of compositing path resource. If name is preceded by #, use
+compositing path numbered by name.</dd>
+<dt>inside:</dt>
+<dd>if non-zero, later operations take effect inside compositing path.
+Otherwise later operations take effect outside compositing path.</dd>
+</dl>
+</div>
+</div>
+<div class="section" id="cloneimage">
+<h1><a class="toc-backref" href="#id80">CloneImage</a></h1>
+<div class="section" id="id20">
+<h2>Synopsis</h2>
+<pre class="literal-block">
 <a class="reference external" href="../api/types.html#image">Image</a> *CloneImage( const <a class="reference external" href="../api/types.html#image">Image</a> *image, const unsigned long columns,
                    const unsigned long rows, const unsigned int orphan,
                    <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
 </pre>
 </div>
-<div class="section" id="id19">
+<div class="section" id="id21">
 <h2>Description</h2>
 <p>CloneImage() copies an image and returns the copy as a new image object.
 If the specified columns and rows is 0, an exact copy of the image is
@@ -368,14 +401,14 @@ NULL.</dd>
 </div>
 </div>
 <div class="section" id="cloneimageinfo">
-<h1><a class="toc-backref" href="#id74">CloneImageInfo</a></h1>
-<div class="section" id="id20">
+<h1><a class="toc-backref" href="#id81">CloneImageInfo</a></h1>
+<div class="section" id="id22">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *CloneImageInfo( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info );
 </pre>
 </div>
-<div class="section" id="id21">
+<div class="section" id="id23">
 <h2>Description</h2>
 <p>CloneImageInfo() makes a copy of the given image info structure.  If
 NULL is specified, a new image info structure is created initialized to
@@ -392,17 +425,18 @@ default values.</p>
 </div>
 </div>
 <div class="section" id="destroyimage">
-<h1><a class="toc-backref" href="#id75">DestroyImage</a></h1>
-<div class="section" id="id22">
+<h1><a class="toc-backref" href="#id82">DestroyImage</a></h1>
+<div class="section" id="id24">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 void DestroyImage( <a class="reference external" href="../api/types.html#image">Image</a> *image );
 </pre>
 </div>
-<div class="section" id="id23">
+<div class="section" id="id25">
 <h2>Description</h2>
 <p>DestroyImage() dereferences an image, deallocating memory associated with
-the image if the reference count becomes zero.</p>
+the image if the reference count becomes zero.  There is no effect if the
+image pointer is null.</p>
 <p>The format of the DestroyImage method is:</p>
 <pre class="literal-block">
 void DestroyImage( <a class="reference external" href="../api/types.html#image">Image</a> *image );
@@ -415,14 +449,14 @@ void DestroyImage( <a class="reference external" href="../api/types.html#image">
 </div>
 </div>
 <div class="section" id="destroyimageinfo">
-<h1><a class="toc-backref" href="#id76">DestroyImageInfo</a></h1>
-<div class="section" id="id24">
+<h1><a class="toc-backref" href="#id83">DestroyImageInfo</a></h1>
+<div class="section" id="id26">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 void DestroyImageInfo( <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info );
 </pre>
 </div>
-<div class="section" id="id25">
+<div class="section" id="id27">
 <h2>Description</h2>
 <p>DestroyImageInfo() deallocates memory associated with a ImageInfo
 structure.</p>
@@ -438,14 +472,14 @@ void DestroyImageInfo( <a class="reference external" href="../api/types.html#ima
 </div>
 </div>
 <div class="section" id="displayimages">
-<h1><a class="toc-backref" href="#id77">DisplayImages</a></h1>
-<div class="section" id="id26">
+<h1><a class="toc-backref" href="#id84">DisplayImages</a></h1>
+<div class="section" id="id28">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int DisplayImages( const <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, <a class="reference external" href="../api/types.html#image">Image</a> *image );
 </pre>
 </div>
-<div class="section" id="id27">
+<div class="section" id="id29">
 <h2>Description</h2>
 <p>DisplayImages() displays an image sequence to any X window screen.  It
 returns a value other than 0 if successful.  Check the exception member
@@ -464,14 +498,14 @@ unsigned int DisplayImages( const <a class="reference external" href="../api/typ
 </div>
 </div>
 <div class="section" id="getimageclipmask">
-<h1><a class="toc-backref" href="#id78">GetImageClipMask</a></h1>
-<div class="section" id="id28">
+<h1><a class="toc-backref" href="#id85">GetImageClipMask</a></h1>
+<div class="section" id="id30">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 <a class="reference external" href="../api/types.html#image">Image</a> *GetImageClipMask( const <a class="reference external" href="../api/types.html#image">Image</a> *image, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
 </pre>
 </div>
-<div class="section" id="id29">
+<div class="section" id="id31">
 <h2>Description</h2>
 <p>GetImageClipMask returns a reference-counted copy of the current image
 clip mask. This copy must be deallocated using DestroyImage() once it is
@@ -500,15 +534,52 @@ the image colormap is globally shared by all pixels in a PseudoClass image.</p>
 </dl>
 </div>
 </div>
+<div class="section" id="getimagecompositemask">
+<h1><a class="toc-backref" href="#id86">GetImageCompositeMask</a></h1>
+<div class="section" id="id32">
+<h2>Synopsis</h2>
+<pre class="literal-block">
+<a class="reference external" href="../api/types.html#image">Image</a> *GetImageCompositeMask( const <a class="reference external" href="../api/types.html#image">Image</a> *image, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
+</pre>
+</div>
+<div class="section" id="id33">
+<h2>Description</h2>
+<p>GetImageCompositeMask returns a reference-counted copy of the current image
+composite mask. This copy must be deallocated using DestroyImage() once it is
+no longer needed.  If the image does not have an associated composite mask,
+then NULL is returned.  Use SetImageCompositeMask() to add a composite mask to an
+image, or remove a composite mask.</p>
+<p>If a component of the composite mask is set to TransparentOpacity (maximum
+value) then the corresponding image pixel component will not be updated
+when SyncImagePixels() is applied. The composite mask may be used to constrain
+the results of an image processing operation to a region of the image.
+Regions outside those allowed by the composite mask may be processed, but only
+pixel quantums allowed by the composite mask will actually be updated.</p>
+<p>The composite mask protects the DirectClass pixels and PseudoClass pixel indexes
+from modification. The composite mask does <em>not</em> protect the image colormap since
+the image colormap is globally shared by all pixels in a PseudoClass image.</p>
+<p>The format of the GetImageCompositeMask method is</p>
+<pre class="literal-block">
+<a class="reference external" href="../api/types.html#image">Image</a> *GetImageCompositeMask( const <a class="reference external" href="../api/types.html#image">Image</a> *image, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
+</pre>
+<p>A descripton of each parameter follows:</p>
+<dl class="docutils">
+<dt>image:</dt>
+<dd>The image.</dd>
+<dt>exception:</dt>
+<dd>Reason for failure.</dd>
+</dl>
+</div>
+</div>
 <div class="section" id="getimageexception">
-<h1><a class="toc-backref" href="#id79">GetImageException</a></h1>
-<div class="section" id="id30">
+<h1><a class="toc-backref" href="#id87">GetImageException</a></h1>
+<div class="section" id="id34">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 void GetImageException( <a class="reference external" href="../api/types.html#image">Image</a> *image, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
 </pre>
 </div>
-<div class="section" id="id31">
+<div class="section" id="id35">
 <h2>Description</h2>
 <p>GetImageException() traverses an image sequence and returns any
 error more severe than noted by the exception parameter.</p>
@@ -526,15 +597,15 @@ void GetImageException( <a class="reference external" href="../api/types.html#im
 </div>
 </div>
 <div class="section" id="getimagegeometry">
-<h1><a class="toc-backref" href="#id80">GetImageGeometry</a></h1>
-<div class="section" id="id32">
+<h1><a class="toc-backref" href="#id88">GetImageGeometry</a></h1>
+<div class="section" id="id36">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 int GetImageGeometry( const <a class="reference external" href="../api/types.html#image">Image</a> *image, const char *geometry,
                       const unsigned int size_to_fit, <a class="reference external" href="../api/types.html#rectangleinfo">RectangleInfo</a> *region_info );
 </pre>
 </div>
-<div class="section" id="id33">
+<div class="section" id="id37">
 <h2>Description</h2>
 <p>GetImageGeometry() returns a region as defined by the geometry string with
 respect to the image and its gravity.</p>
@@ -559,14 +630,14 @@ respect to the image and its gravity.</dd>
 </div>
 </div>
 <div class="section" id="getimageinfo">
-<h1><a class="toc-backref" href="#id81">GetImageInfo</a></h1>
-<div class="section" id="id34">
+<h1><a class="toc-backref" href="#id89">GetImageInfo</a></h1>
+<div class="section" id="id38">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 void GetImageInfo( <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info );
 </pre>
 </div>
-<div class="section" id="id35">
+<div class="section" id="id39">
 <h2>Description</h2>
 <p>GetImageInfo() initializes image_info to default values.</p>
 <p>The format of the GetImageInfo method is:</p>
@@ -581,14 +652,14 @@ void GetImageInfo( <a class="reference external" href="../api/types.html#imagein
 </div>
 </div>
 <div class="section" id="istaintimage">
-<h1><a class="toc-backref" href="#id82">IsTaintImage</a></h1>
-<div class="section" id="id36">
+<h1><a class="toc-backref" href="#id90">IsTaintImage</a></h1>
+<div class="section" id="id40">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int IsTaintImage( const <a class="reference external" href="../api/types.html#image">Image</a> *image );
 </pre>
 </div>
-<div class="section" id="id37">
+<div class="section" id="id41">
 <h2>Description</h2>
 <p>IsTaintImage() returns a value other than 0 if any pixel in the image
 has been altered since it was first constituted.</p>
@@ -604,14 +675,14 @@ unsigned int IsTaintImage( const <a class="reference external" href="../api/type
 </div>
 </div>
 <div class="section" id="modifyimage">
-<h1><a class="toc-backref" href="#id83">ModifyImage</a></h1>
-<div class="section" id="id38">
+<h1><a class="toc-backref" href="#id91">ModifyImage</a></h1>
+<div class="section" id="id42">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 ModifyImage( <a class="reference external" href="../api/types.html#image">Image</a> *image, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
 </pre>
 </div>
-<div class="section" id="id39">
+<div class="section" id="id43">
 <h2>Description</h2>
 <p>ModifyImage() ensures that there is only a single reference to the image
 to be modified, updating the provided image pointer to point to a clone of
@@ -630,14 +701,14 @@ ModifyImage( <a class="reference external" href="../api/types.html#image">Image<
 </div>
 </div>
 <div class="section" id="referenceimage">
-<h1><a class="toc-backref" href="#id84">ReferenceImage</a></h1>
-<div class="section" id="id40">
+<h1><a class="toc-backref" href="#id92">ReferenceImage</a></h1>
+<div class="section" id="id44">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 <a class="reference external" href="../api/types.html#image">Image</a> *ReferenceImage( <a class="reference external" href="../api/types.html#image">Image</a> *image );
 </pre>
 </div>
-<div class="section" id="id41">
+<div class="section" id="id45">
 <h2>Description</h2>
 <p>ReferenceImage() increments the reference count associated with an image
 returning a pointer to the image.</p>
@@ -653,14 +724,14 @@ returning a pointer to the image.</p>
 </div>
 </div>
 <div class="section" id="removedefinitions">
-<h1><a class="toc-backref" href="#id85">RemoveDefinitions</a></h1>
-<div class="section" id="id42">
+<h1><a class="toc-backref" href="#id93">RemoveDefinitions</a></h1>
+<div class="section" id="id46">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 void RemoveDefinitions( <a class="reference external" href="../api/types.html#imageinfo">ImageInfo</a> *image_info, const char *options );
 </pre>
 </div>
-<div class="section" id="id43">
+<div class="section" id="id47">
 <h2>Description</h2>
 <p>RemoveDefinitions() removes definitions from the current map of definitions
 in ImageInfo. Definitions may be used by coders/decoders that read and
@@ -685,14 +756,14 @@ succeeds.</dd>
 </div>
 </div>
 <div class="section" id="resetimagepage">
-<h1><a class="toc-backref" href="#id86">ResetImagePage</a></h1>
-<div class="section" id="id44">
+<h1><a class="toc-backref" href="#id94">ResetImagePage</a></h1>
+<div class="section" id="id48">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickPassFail ResetImagePage( <a class="reference external" href="../api/types.html#image">Image</a> *image, const char *page );
 </pre>
 </div>
-<div class="section" id="id45">
+<div class="section" id="id49">
 <h2>Description</h2>
 <p>ResetImagePage adjusts the current page canvas and position based on a
 relative page specification.</p>
@@ -710,14 +781,14 @@ MagickPassFail ResetImagePage( <a class="reference external" href="../api/types.
 </div>
 </div>
 <div class="section" id="setimageex">
-<h1><a class="toc-backref" href="#id87">SetImageEx</a></h1>
-<div class="section" id="id46">
+<h1><a class="toc-backref" href="#id95">SetImageEx</a></h1>
+<div class="section" id="id50">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 void SetImageEx( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#quantum">Quantum</a> opacity, <a class="reference external" href="../api/types.html#exceptioninfo">ExceptionInfo</a> *exception );
 </pre>
 </div>
-<div class="section" id="id47">
+<div class="section" id="id51">
 <h2>Description</h2>
 <p>SetImageEx() sets the red, green, and blue components of each pixel to
 the image background color and the opacity component to the specified
@@ -738,14 +809,14 @@ void SetImageEx( <a class="reference external" href="../api/types.html#image">Im
 </div>
 </div>
 <div class="section" id="setimage">
-<h1><a class="toc-backref" href="#id88">SetImage</a></h1>
-<div class="section" id="id48">
+<h1><a class="toc-backref" href="#id96">SetImage</a></h1>
+<div class="section" id="id52">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 void SetImage( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#quantum">Quantum</a> opacity );
 </pre>
 </div>
-<div class="section" id="id49">
+<div class="section" id="id53">
 <h2>Description</h2>
 <p>SetImage() sets the red, green, and blue components of each pixel to
 the image background color and the opacity component to the specified
@@ -766,14 +837,14 @@ void SetImage( <a class="reference external" href="../api/types.html#image">Imag
 </div>
 </div>
 <div class="section" id="setimagecolor">
-<h1><a class="toc-backref" href="#id89">SetImageColor</a></h1>
-<div class="section" id="id50">
+<h1><a class="toc-backref" href="#id97">SetImageColor</a></h1>
+<div class="section" id="id54">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickPassFail SetImageColor( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#pixelpacket">PixelPacket</a> *pixel );
 </pre>
 </div>
-<div class="section" id="id51">
+<div class="section" id="id55">
 <h2>Description</h2>
 <p>SetImageColor() sets the red, green, blue and opacity components of each
 pixel to those from a specified pixel value.</p>
@@ -791,15 +862,15 @@ MagickPassFail SetImageColor( <a class="reference external" href="../api/types.h
 </div>
 </div>
 <div class="section" id="setimagecolorregion">
-<h1><a class="toc-backref" href="#id90">SetImageColorRegion</a></h1>
-<div class="section" id="id52">
+<h1><a class="toc-backref" href="#id98">SetImageColorRegion</a></h1>
+<div class="section" id="id56">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickPassFail SetImageColorRegion( <a class="reference external" href="../api/types.html#image">Image</a> *image, long x, long y, unsigned long width,
                                     unsigned long height, const <a class="reference external" href="../api/types.html#pixelpacket">PixelPacket</a> *pixel );
 </pre>
 </div>
-<div class="section" id="id53">
+<div class="section" id="id57">
 <h2>Description</h2>
 <p>SetImageColorRegion() sets the red, green, blue and opacity components
 of each pixel in the specified region to those from a specified pixel
@@ -819,14 +890,14 @@ MagickPassFail SetImageColorRegion( <a class="reference external" href="../api/t
 </div>
 </div>
 <div class="section" id="setimageclipmask">
-<h1><a class="toc-backref" href="#id91">SetImageClipMask</a></h1>
-<div class="section" id="id54">
+<h1><a class="toc-backref" href="#id99">SetImageClipMask</a></h1>
+<div class="section" id="id58">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int SetImageClipMask( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#image">Image</a> *clip_mask );
 </pre>
 </div>
-<div class="section" id="id55">
+<div class="section" id="id59">
 <h2>Description</h2>
 <p>SetImageClipMask() associates a clip mask with the image.  The clip mask
 must be the same dimensions as the image.</p>
@@ -852,15 +923,49 @@ unsigned int SetImageClipMask( <a class="reference external" href="../api/types.
 </dl>
 </div>
 </div>
+<div class="section" id="setimagecompositemask">
+<h1><a class="toc-backref" href="#id100">SetImageCompositeMask</a></h1>
+<div class="section" id="id60">
+<h2>Synopsis</h2>
+<pre class="literal-block">
+unsigned int SetImageCompositeMask( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#image">Image</a> *composite_mask );
+</pre>
+</div>
+<div class="section" id="id61">
+<h2>Description</h2>
+<p>SetImageCompositeMask() associates a composite mask with the image.  The mask
+must be the same dimensions as the image.</p>
+<p>If a component of the composite mask is set to TransparentOpacity (maximum
+value) then the corresponding image pixel component will not be updated
+when SyncImagePixels() is applied. The composite mask may be used to composite
+the results of an image processing operation to a region of the image.
+Regions outside those allowed by the composite mask may be processed, but only
+pixel quantums covered by the composite mask will actually be updated.</p>
+<p>The composite mask protects the DirectClass pixels and PseudoClass pixel indexes
+from modification. The composite mask does <em>not</em> protect the image colormap since
+the image colormap is globally shared by all pixels in a PseudoClass image.</p>
+<p>The format of the SetImageCompositeMask method is:</p>
+<pre class="literal-block">
+unsigned int SetImageCompositeMask( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#image">Image</a> *composite_mask );
+</pre>
+<p>A description of each parameter follows:</p>
+<dl class="docutils">
+<dt>image:</dt>
+<dd>The image.</dd>
+<dt>composite_mask:</dt>
+<dd>The image composite mask.</dd>
+</dl>
+</div>
+</div>
 <div class="section" id="setimagedepth">
-<h1><a class="toc-backref" href="#id92">SetImageDepth</a></h1>
-<div class="section" id="id56">
+<h1><a class="toc-backref" href="#id101">SetImageDepth</a></h1>
+<div class="section" id="id62">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int SetImageDepth( <a class="reference external" href="../api/types.html#image">Image</a> *image, const unsigned long depth );
 </pre>
 </div>
-<div class="section" id="id57">
+<div class="section" id="id63">
 <h2>Description</h2>
 <p>SetImageDepth() translates the pixel quantums across all of the channels
 so that if they are later divided to fit within the specified bit
@@ -883,14 +988,14 @@ unsigned int SetImageDepth( <a class="reference external" href="../api/types.htm
 </div>
 </div>
 <div class="section" id="setimageopacity">
-<h1><a class="toc-backref" href="#id93">SetImageOpacity</a></h1>
-<div class="section" id="id58">
+<h1><a class="toc-backref" href="#id102">SetImageOpacity</a></h1>
+<div class="section" id="id64">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 void SetImageOpacity( <a class="reference external" href="../api/types.html#image">Image</a> *image, const unsigned int opacity );
 </pre>
 </div>
-<div class="section" id="id59">
+<div class="section" id="id65">
 <h2>Description</h2>
 <p>SetImageOpacity() attenuates the opacity channel of an image.  If the
 image pixels are opaque, they are set to the specified opacity level.
@@ -911,14 +1016,14 @@ fully transparent.</dd>
 </div>
 </div>
 <div class="section" id="setimagetype">
-<h1><a class="toc-backref" href="#id94">SetImageType</a></h1>
-<div class="section" id="id60">
+<h1><a class="toc-backref" href="#id103">SetImageType</a></h1>
+<div class="section" id="id66">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 ( void )SetImageType( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#imagetype">ImageType</a> image_type );
 </pre>
 </div>
-<div class="section" id="id61">
+<div class="section" id="id67">
 <h2>Description</h2>
 <p>(void) SetImageType() sets the type of image.  Choose from these types:</p>
 <p>BilevelType, GrayscaleType, GrayscaleMatteType, PaletteType,
@@ -938,14 +1043,14 @@ ColorSeparationType, ColorSeparationMatteType, OptimizeType</p>
 </div>
 </div>
 <div class="section" id="stripimage">
-<h1><a class="toc-backref" href="#id95">StripImage</a></h1>
-<div class="section" id="id62">
+<h1><a class="toc-backref" href="#id104">StripImage</a></h1>
+<div class="section" id="id68">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickPassFail StripImage( <a class="reference external" href="../api/types.html#image">Image</a> *image );
 </pre>
 </div>
-<div class="section" id="id63">
+<div class="section" id="id69">
 <h2>Description</h2>
 <p>StripImage removes all profiles and text attributes from the image.</p>
 <p>The format of the StripImage method is:</p>
index f390b75..993abe4 100644 (file)
@@ -142,7 +142,8 @@ void DestroyImageList( <a class="reference external" href="../api/types.html#ima
 </div>
 <div class="section" id="id6">
 <h2>Description</h2>
-<p>DestroyImageList() destroys an image list.</p>
+<p>DestroyImageList() destroys an image list.  There is no effect if the
+image pointer is null.</p>
 <p>The format of the DestroyImageList method is:</p>
 <pre class="literal-block">
 void DestroyImageList( <a class="reference external" href="../api/types.html#image">Image</a> *image );
index 1b55312..984de83 100644 (file)
@@ -59,6 +59,7 @@ MagickPassFail MagickMonitor( const char *text, const magick_int64_t quantum,
 describes the task and a measure of completion.  The method returns True
 on success otherwise False if an error is encountered, e.g. if there was a
 user interrupt.</p>
+<p>This function is deprecated.  Please use MagickMonitorFormatted() instead.</p>
 <p>The format of the MagickMonitor method is:</p>
 <pre class="literal-block">
 MagickPassFail MagickMonitor( const char *text, const magick_int64_t quantum,
@@ -93,8 +94,15 @@ MagickPassFail MagickMonitorFormatted( const magick_int64_t quantum,
 <p>MagickMonitorFormatted() calls the monitor handler method with a
 printf type format specification and variable argument list.  Also
 passed are quantum and span values which provide a measure of
-completion.  The method returns True on success otherwise False if
-an error is encountered, e.g. if there was a user interrupt.</p>
+completion.  The method returns MagickPass on success otherwise
+MagickFail if an error is encountered, e.g. if there was a user
+interrupt.  If MagickFail is returned, the calling code is expected
+to terminate whatever is being monitored as soon as possible.</p>
+<p>Most callers of this function will use the QuantumTick() macro to
+decide when it should be called.  The QuantumTick() macro is designed
+to deliver no more than 100 events in a span (representing 1-100%)
+and to distribute events as evenly as possible over the span so that
+events are reported for every 1% of progress when possible.</p>
 <p>The format of the MagickMonitorFormatted method is:</p>
 <pre class="literal-block">
 MagickPassFail MagickMonitorFormatted( const magick_int64_t quantum,
index 515a81b..7c9d2d0 100644 (file)
 <div class="contents topic" id="contents">
 <p class="topic-title first">Contents</p>
 <ul class="simple">
-<li><a class="reference internal" href="#clonedrawinfo" id="id11">CloneDrawInfo</a></li>
-<li><a class="reference internal" href="#destroydrawinfo" id="id12">DestroyDrawInfo</a></li>
-<li><a class="reference internal" href="#drawaffineimage" id="id13">DrawAffineImage</a></li>
-<li><a class="reference internal" href="#drawclippath" id="id14">DrawClipPath</a></li>
-<li><a class="reference internal" href="#drawimage" id="id15">DrawImage</a></li>
-<li><a class="reference internal" href="#drawpatternpath" id="id16">DrawPatternPath</a></li>
+<li><a class="reference internal" href="#clonedrawinfo" id="id13">CloneDrawInfo</a></li>
+<li><a class="reference internal" href="#destroydrawinfo" id="id14">DestroyDrawInfo</a></li>
+<li><a class="reference internal" href="#drawaffineimage" id="id15">DrawAffineImage</a></li>
+<li><a class="reference internal" href="#drawclippath" id="id16">DrawClipPath</a></li>
+<li><a class="reference internal" href="#drawcompositemask" id="id17">DrawCompositeMask</a></li>
+<li><a class="reference internal" href="#drawimage" id="id18">DrawImage</a></li>
+<li><a class="reference internal" href="#drawpatternpath" id="id19">DrawPatternPath</a></li>
 </ul>
 </div>
 <div class="section" id="clonedrawinfo">
-<h1><a class="toc-backref" href="#id11">CloneDrawInfo</a></h1>
+<h1><a class="toc-backref" href="#id13">CloneDrawInfo</a></h1>
 <div class="section" id="synopsis">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -73,7 +74,7 @@ default values.</p>
 </div>
 </div>
 <div class="section" id="destroydrawinfo">
-<h1><a class="toc-backref" href="#id12">DestroyDrawInfo</a></h1>
+<h1><a class="toc-backref" href="#id14">DestroyDrawInfo</a></h1>
 <div class="section" id="id1">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -96,7 +97,7 @@ void DestroyDrawInfo( <a class="reference external" href="../api/types.html#draw
 </div>
 </div>
 <div class="section" id="drawaffineimage">
-<h1><a class="toc-backref" href="#id13">DrawAffineImage</a></h1>
+<h1><a class="toc-backref" href="#id15">DrawAffineImage</a></h1>
 <div class="section" id="id3">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -124,7 +125,7 @@ unsigned int DrawAffineImage( <a class="reference external" href="../api/types.h
 </div>
 </div>
 <div class="section" id="drawclippath">
-<h1><a class="toc-backref" href="#id14">DrawClipPath</a></h1>
+<h1><a class="toc-backref" href="#id16">DrawClipPath</a></h1>
 <div class="section" id="id5">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -150,16 +151,43 @@ MagickPassFail DrawClipPath( <a class="reference external" href="../api/types.ht
 </dl>
 </div>
 </div>
-<div class="section" id="drawimage">
-<h1><a class="toc-backref" href="#id15">DrawImage</a></h1>
+<div class="section" id="drawcompositemask">
+<h1><a class="toc-backref" href="#id17">DrawCompositeMask</a></h1>
 <div class="section" id="id7">
 <h2>Synopsis</h2>
 <pre class="literal-block">
-MagickPassFail DrawImage( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#drawinfo">DrawInfo</a> *draw_info );
+MagickPassFail DrawCompositeMask( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#drawinfo">DrawInfo</a> *draw_info,
+                                  const char *name );
 </pre>
 </div>
 <div class="section" id="id8">
 <h2>Description</h2>
+<p>DrawCompositeMask() draws the composite mask on the image mask.</p>
+<p>The format of the DrawCompositeMask method is:</p>
+<pre class="literal-block">
+MagickPassFail DrawCompositeMask( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#drawinfo">DrawInfo</a> *draw_info,
+                                  const char *name );
+</pre>
+<dl class="docutils">
+<dt>image:</dt>
+<dd>The image.</dd>
+<dt>draw_info:</dt>
+<dd>The draw info.</dd>
+<dt>name:</dt>
+<dd>The name of the composite mask.</dd>
+</dl>
+</div>
+</div>
+<div class="section" id="drawimage">
+<h1><a class="toc-backref" href="#id18">DrawImage</a></h1>
+<div class="section" id="id9">
+<h2>Synopsis</h2>
+<pre class="literal-block">
+MagickPassFail DrawImage( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#drawinfo">DrawInfo</a> *draw_info );
+</pre>
+</div>
+<div class="section" id="id10">
+<h2>Description</h2>
 <p>Use DrawImage() to draw a graphic primitive on your image.  The primitive
 may be represented as a string or filename.  Precede the filename with an
 &quot;at&quot; sign (&#64;) and the contents of the file are drawn on the image.  You
@@ -182,15 +210,15 @@ MagickPassFail DrawImage( <a class="reference external" href="../api/types.html#
 </div>
 </div>
 <div class="section" id="drawpatternpath">
-<h1><a class="toc-backref" href="#id16">DrawPatternPath</a></h1>
-<div class="section" id="id9">
+<h1><a class="toc-backref" href="#id19">DrawPatternPath</a></h1>
+<div class="section" id="id11">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickPassFail DrawPatternPath( <a class="reference external" href="../api/types.html#image">Image</a> *image, const <a class="reference external" href="../api/types.html#drawinfo">DrawInfo</a> *draw_info,
                                 const char *name, <a class="reference external" href="../api/types.html#image">Image</a> ** pattern );
 </pre>
 </div>
-<div class="section" id="id10">
+<div class="section" id="id12">
 <h2>Description</h2>
 <p>DrawPatternPath() draws a pattern.</p>
 <p>The format of the DrawPatternPath method is:</p>
index 534c124..c28bbea 100644 (file)
@@ -2837,7 +2837,7 @@ typedef struct _XResourceInfo
 } XResourceInfo;
 </pre>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index 32c6fc4..181bfb6 100644 (file)
@@ -2070,5 +2070,4 @@ MagickXResourceInfo
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
-
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 75c6b3b..1a1d1ae 100644 (file)
@@ -60,14 +60,6 @@ configure/make facility, Windows setup.exe style
 installer, WMF renderer, C API documentation formatter,
 and the C, C++, and Perl test suites used by ImageMagick
 and GraphicsMagick.</dd>
-<dt>Glenn Randers-Pehrson</dt>
-<dd>Contributed significantly to the utilities, including
-writing the 'gm' utility wrapper. Authored support for
-JNG, MNG, and PNG formats. Provided significant support
-for the BMP format. Significant improvements to the
-documentation, including creating a documentation
-authoring environment based on the &lt;imdoc&gt; format.
-Maintains the SourceForge mailing lists.</dd>
 <dt>Jaroslav Fojtik</dt>
 <dd>Authored the ART, CUT, HRZ, JNX, MAC, MATLAB, TOPOL,
 and WPG coder modules. Improved the FITS and TXT coder
@@ -79,6 +71,19 @@ Visual Studio.</dd>
 <div class="section" id="former-graphicsmagick-contributors">
 <h1><a class="toc-backref" href="#id2">Former GraphicsMagick Contributors</a></h1>
 <dl class="docutils">
+<dt>Glenn Randers-Pehrson</dt>
+<dd>Contributed significantly to the utilities, including
+writing the 'gm' utility wrapper. Authored support for
+JNG, MNG, and PNG formats. Provided significant
+support for the BMP format. Significant improvements
+to the documentation, including creating a
+documentation authoring environment based on the
+&lt;imdoc&gt; format.  Maintained the SourceForge mailing
+lists.  GraphicsMagick would not be what it is today
+without Glenn and he will always be remembered.</dd>
+<dt>Gregory J Wolfe</dt>
+<dd>Contributed significant improvements to the SVG
+parsing and rendering code.</dd>
 <dt>Kenneth Xu</dt>
 <dd>Contributed the implementation of 'gm batch', a simple
 batch mode for GraphicsMagick.</dd>
@@ -192,7 +197,7 @@ Wireless Access Protocol.</dd>
 </dl>
 <hr class="docutils" />
 <div class="line-block">
-<div class="line">Copyright © GraphicsMagick Group 2002 - 2017</div>
+<div class="line">Copyright © GraphicsMagick Group 2002 - 2018</div>
 </div>
 <p>This program is covered by multiple licenses, which are described in
 Copyright.txt. You should have received a copy of Copyright.txt with this
index f9533d1..4b58e60 100644 (file)
@@ -18,35 +18,40 @@ Active GraphicsMagick Contributors
 ==================================
 
 Bob Friesenhahn
-               Principal maintainer of GraphicsMagick. Author of
-               Magick++ (C++ API to ImageMagick and GraphicsMagick).
-               Author of module loader facility, automatic file
-               identification (magic) support, Unix/Cygwin/MinGW
-               configure/make facility, Windows setup.exe style
-               installer, WMF renderer, C API documentation formatter,
-               and the C, C++, and Perl test suites used by ImageMagick
-               and GraphicsMagick.
-
-Glenn Randers-Pehrson
-               Contributed significantly to the utilities, including
-               writing the 'gm' utility wrapper. Authored support for
-               JNG, MNG, and PNG formats. Provided significant support
-               for the BMP format. Significant improvements to the
-               documentation, including creating a documentation
-               authoring environment based on the <imdoc> format.
-               Maintains the SourceForge mailing lists.
+                Principal maintainer of GraphicsMagick. Author of
+                Magick++ (C++ API to ImageMagick and GraphicsMagick).
+                Author of module loader facility, automatic file
+                identification (magic) support, Unix/Cygwin/MinGW
+                configure/make facility, Windows setup.exe style
+                installer, WMF renderer, C API documentation formatter,
+                and the C, C++, and Perl test suites used by ImageMagick
+                and GraphicsMagick.
 
 Jaroslav Fojtik
-               Authored the ART, CUT, HRZ, JNX, MAC, MATLAB, TOPOL,
+                Authored the ART, CUT, HRZ, JNX, MAC, MATLAB, TOPOL,
                 and WPG coder modules. Improved the FITS and TXT coder
                 modules.  VisualMagick 'configure' improvements and
                 build testing/fixes for many versions of Microsoft
                 Visual Studio.
 
-
 Former GraphicsMagick Contributors
 ==================================
 
+Glenn Randers-Pehrson
+                Contributed significantly to the utilities, including
+                writing the 'gm' utility wrapper. Authored support for
+                JNG, MNG, and PNG formats. Provided significant
+                support for the BMP format. Significant improvements
+                to the documentation, including creating a
+                documentation authoring environment based on the
+                <imdoc> format.  Maintained the SourceForge mailing
+                lists.  GraphicsMagick would not be what it is today
+                without Glenn and he will always be remembered.
+
+Gregory J Wolfe
+                Contributed significant improvements to the SVG
+                parsing and rendering code.
+
 Kenneth Xu
                 Contributed the implementation of 'gm batch', a simple
                 batch mode for GraphicsMagick.
@@ -76,42 +81,42 @@ Roman Hiestand
                 Contributed WebP coder improvements.
 
 Mike Chiarappa
-               Created and maintains the Borland C++ Builder 6.0 build
-               environment for GraphicsMagick.
+                Created and maintains the Borland C++ Builder 6.0 build
+                environment for GraphicsMagick.
 
 Daniel Kobras
-               Provided many security patches and fixes from the Debian
-               project.
+                Provided many security patches and fixes from the Debian
+                project.
 
 William Radcliffe
-               Author of the VisualMagick project configure facility for
-               Visual C++. Author of FlashPix module. Author of the
-               ImageMagickObject COM object for Windows. Author of the
-               EMF, XTRN, and META coders. Significant contributions to
-               the MSL, JPEG, TIFF, SVG, and URL coders. Authored
-               "process" module support. Wrote the micro-timer facility
-               used by 'identify'. Ported module loader support to
-               Windows. Significantly improved polygon rendering
-               performance.
+                Author of the VisualMagick project configure facility for
+                Visual C++. Author of FlashPix module. Author of the
+                ImageMagickObject COM object for Windows. Author of the
+                EMF, XTRN, and META coders. Significant contributions to
+                the MSL, JPEG, TIFF, SVG, and URL coders. Authored
+                "process" module support. Wrote the micro-timer facility
+                used by 'identify'. Ported module loader support to
+                Windows. Significantly improved polygon rendering
+                performance.
 
 Leonard Rosenthol
-               Authored the 'conjure' utility and associated MSL
-               execution environment. Provided MacOS support. Authored
-               the CLIPBOARD, XCF, and PSD coders. Postscript and PDF
-               expertise. Significant drawing enhancements including
-               support for dash patterns, linecap stroking, clipping
-               masks and a mask image.
+                Authored the 'conjure' utility and associated MSL
+                execution environment. Provided MacOS support. Authored
+                the CLIPBOARD, XCF, and PSD coders. Postscript and PDF
+                expertise. Significant drawing enhancements including
+                support for dash patterns, linecap stroking, clipping
+                masks and a mask image.
 
 Lars Ruben Skyum
-               Contributed the -clippath functionality, added
-               -define support, improved color profile support,
-               and re-wrote the PS3 coder.
+                Contributed the -clippath functionality, added
+                -define support, improved color profile support,
+                and re-wrote the PS3 coder.
 
 Rolf Schroedter
-               Principal author of TclMagick.
+                Principal author of TclMagick.
 
 David N. Welton
-               Co-author of TclMagick, particularly in the Unix environment.
+                Co-author of TclMagick, particularly in the Unix environment.
 
 Mark Mitchell
                 Contributed a new design for the web pages, including the
@@ -119,17 +124,17 @@ Mark Mitchell
                 format.
 
 Richard Nolde
-               Contributed code for converting between native floating
-               point types, and short (16/24) bit float types.
+                Contributed code for converting between native floating
+                point types, and short (16/24) bit float types.
 
 Clément Follet
-               Contributed Hald CLUT and ASC-CDL implementations.
+                Contributed Hald CLUT and ASC-CDL implementations.
 
 John Sergeant
-               Re-wrote the HP PCL writer to work much better,
-               including support for compression.  Implemented
-               support for CALS type 1 format.  Re-wrote the DICOM
-               reader.
+                Re-wrote the HP PCL writer to work much better,
+                including support for compression.  Implemented
+                support for CALS type 1 format.  Re-wrote the DICOM
+                reader.
 
 Roberto de Deus Barbosa Murta
                 Contributed the adaptive threshold implementation
@@ -141,58 +146,57 @@ Other Contributors (via ImageMagick)
 ====================================
 
 John Cristy
-               Creator, principal author, and principal maintainer of
-               ImageMagick, from which GraphicsMagick is originally
-               derived (from ImageMagick 5.5.2).  Also the author of
-               the Wand API to ImageMagick which is incorporated as
-               a stand-alone library by GraphicsMagick.
+                Creator, principal author, and principal maintainer of
+                ImageMagick, from which GraphicsMagick is originally
+                derived (from ImageMagick 5.5.2).  Also the author of
+                the Wand API to ImageMagick which is incorporated as
+                a stand-alone library by GraphicsMagick.
 
 Kelly Bergougnoux
-               Authored the initial Cineon coder (which has since been
-               replaced).
+                Authored the initial Cineon coder (which has since been
+                replaced).
 
 Christopher R. Hawks
-               Authored the PALM coder.
+                Authored the PALM coder.
 
 Francis J. Franklin
-               Ported the WMF coder to the libwmf 0.2 API.
+                Ported the WMF coder to the libwmf 0.2 API.
 
 Rick Mabry
-               Contributed code to support filling drawn objects using a
-               pattern image.
+                Contributed code to support filling drawn objects using a
+                pattern image.
 Nathan Brown
-               Original author of the JP2 coder.
+                Original author of the JP2 coder.
 
 Kyle Shorter
-               Original author of PerlMagick. Original author of the
-               LOCALE coder.
+                Original author of PerlMagick. Original author of the
+                LOCALE coder.
 
 Markus Friedl
-               Original author of Base64 encode/decode sources.
+                Original author of Base64 encode/decode sources.
 
 David Harr
-               Contributed (with Leonard Rosenthol) dash pattern,
-               linecap stroking algorithm, and minor rendering
-               improvements.
+                Contributed (with Leonard Rosenthol) dash pattern,
+                linecap stroking algorithm, and minor rendering
+                improvements.
 
 Troy Edwards
-               Authored the source RPM spec file for GraphicsMagick.
+                Authored the source RPM spec file for GraphicsMagick.
 
 Milan Votava
-               Contributed support for Wireless BitMap, used in WAP -
-               Wireless Access Protocol.
+                Contributed support for Wireless BitMap, used in WAP -
+                Wireless Access Protocol.
 
 Mike Edmonds
-               Contributed the median filter algorithm.
+                Contributed the median filter algorithm.
 
 
 ---------------------------------------------------------------------------
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-| Copyright |copy| GraphicsMagick Group 2002 - 2017
+| Copyright |copy| GraphicsMagick Group 2002 - 2018
 
 This program is covered by multiple licenses, which are described in
 Copyright.txt. You should have received a copy of Copyright.txt with this
 package; otherwise see http://www.graphicsmagick.org/Copyright.html.
-
index 21e58b6..1411fd9 100644 (file)
@@ -170,7 +170,7 @@ done 2&gt;&amp;1
 </pre>
 <hr class="docutils" />
 <div class="line-block">
-<div class="line">Copyright (C) 2008 - 2017 GraphicsMagick Group</div>
+<div class="line">Copyright (C) 2008 - 2018 GraphicsMagick Group</div>
 </div>
 <p>This program is covered by multiple licenses, which are described in
 Copyright.txt. You should have received a copy of Copyright.txt with this
index 727c295..50ffeaa 100644 (file)
@@ -141,7 +141,7 @@ Here is the simple benchmark script::
 
 --------------------------------------------------------------------------
 
-| Copyright (C) 2008 - 2017 GraphicsMagick Group
+| Copyright (C) 2008 - 2018 GraphicsMagick Group
 
 This program is covered by multiple licenses, which are described in
 Copyright.txt. You should have received a copy of Copyright.txt with this
index 0f88f39..09f4a38 100644 (file)
@@ -39,7 +39,7 @@
 <!-- This text is in reStucturedText format, so it may look a bit odd. -->
 <!-- See http://docutils.sourceforge.net/rst.html for details. -->
 <p>The following bugs are known to exist in GraphicsMagick. Please report
-any additional bugs to the GraphicsMagick <a class="reference external" href="http://sourceforge.net/tracker/?group_id=73485">bug tracker</a> at SourceForge.</p>
+any additional bugs to the GraphicsMagick <a class="reference external" href="https://sourceforge.net/p/graphicsmagick/_list/tickets">bug tracker</a> at SourceForge.</p>
 <blockquote>
 <ul class="simple">
 <li>BMP reader is not working for some obscure low-color packed files.</li>
@@ -47,15 +47,14 @@ any additional bugs to the GraphicsMagick <a class="reference external" href="ht
 samples spill over the storage word boundary. This means that
 single-channel/grayscale 10-bit DPX files will only work for widths
 evenly divisible by three. (SF 1533184)</li>
-<li>PSD reader is not working for some files. Can fix by extracting the
-already rendered image from the PSD file rather than the layers.</li>
+<li>The PSD reader is disabled by default because it does not work well
+enough and several man-years worth of dedicated volunteer time is
+required to make it work properly.</li>
 <li>Scitex reader is not working for some files.</li>
-<li>SVG writer works only if you are particularly luckly.</li>
+<li>SVG writer works only if you are particularly luckly and so it is
+not included in the build by default..</li>
 <li>SVG reader mishandles basic units and many other syntax elements (SF
 1231547, 1298606).</li>
-<li>BlobToImage ignores the value of the 'magick' parameter. I don't know
-how to fix this due to how things work. (SF 1839932).</li>
-<li>Text annotation options do not work perfectly (SF 1539050, 1539052, 1539059)</li>
 </ul>
 </blockquote>
 </div>
index 726c083..fbcbc9d 100644 (file)
@@ -8,7 +8,7 @@ GraphicsMagick Bugs
 
 The following bugs are known to exist in GraphicsMagick. Please report
 any additional bugs to the GraphicsMagick `bug tracker
-<http://sourceforge.net/tracker/?group_id=73485>`_ at SourceForge.
+<https://sourceforge.net/p/graphicsmagick/_list/tickets>`_ at SourceForge.
 
  * BMP reader is not working for some obscure low-color packed files.
 
@@ -17,17 +17,14 @@ any additional bugs to the GraphicsMagick `bug tracker
    single-channel/grayscale 10-bit DPX files will only work for widths
    evenly divisible by three. (SF 1533184)
 
- * PSD reader is not working for some files. Can fix by extracting the
-   already rendered image from the PSD file rather than the layers.
+ * The PSD reader is disabled by default because it does not work well
+   enough and several man-years worth of dedicated volunteer time is
+   required to make it work properly.
 
  * Scitex reader is not working for some files.
 
- * SVG writer works only if you are particularly luckly.
+ * SVG writer works only if you are particularly luckly and so it is
+   not included in the build by default..
 
  * SVG reader mishandles basic units and many other syntax elements (SF
    1231547, 1298606).
-
- * BlobToImage ignores the value of the 'magick' parameter. I don't know
-   how to fix this due to how things work. (SF 1839932).
-
- * Text annotation options do not work perfectly (SF 1539050, 1539052, 1539059)
index 1c36ca4..1e98503 100644 (file)
@@ -114,7 +114,7 @@ explore.</li>
 delegate under Windows.</li>
 </ul>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index 2a0124c..c4e865b 100644 (file)
@@ -107,4 +107,4 @@ the GraphicsMagick project:
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 8c6e74f..92a770c 100644 (file)
@@ -91,12 +91,12 @@ Visual C++ workspace) may be found here.</blockquote>
 <p>Here are some known download sites for GraphicsMagick:</p>
 <blockquote>
 <p><a class="reference external" href="https://sourceforge.net/projects/graphicsmagick/files/">SourceForge file download</a> (http protocol)</p>
-<p><a class="reference external" href="http://78.108.103.11/MIRROR/ftp/GraphicsMagick/">Czechoslovakian ftp mirror</a> (http protocol)</p>
+<p><a class="reference external" href="http://78.108.103.11/MIRROR/ftp/GraphicsMagick/">Czech ftp mirror</a> (http protocol)</p>
 <p><a class="reference external" href="ftp://ftp.icm.edu.pl/pub/unix/graphics/GraphicsMagick/">Polish ftp mirror via ftp</a> (ftp protocol)</p>
 <p><a class="reference external" href="http://ftp.icm.edu.pl/pub/unix/graphics/GraphicsMagick/">Polish ftp mirror via http</a> (http protocol)</p>
 </blockquote>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index d74c1fe..eacf742 100644 (file)
@@ -76,7 +76,7 @@ Here are some known download sites for GraphicsMagick:
 
   `SourceForge file download <https://sourceforge.net/projects/graphicsmagick/files/>`_ (http protocol)
 
-  `Czechoslovakian ftp mirror <http://78.108.103.11/MIRROR/ftp/GraphicsMagick/>`_ (http protocol)
+  `Czech ftp mirror <http://78.108.103.11/MIRROR/ftp/GraphicsMagick/>`_ (http protocol)
 
   `Polish ftp mirror via ftp <ftp://ftp.icm.edu.pl/pub/unix/graphics/GraphicsMagick/>`_ (ftp protocol)
 
@@ -86,4 +86,4 @@ Here are some known download sites for GraphicsMagick:
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 7ebc96c..1a56906 100644 (file)
@@ -549,7 +549,8 @@ PostScript file</td>
 <td>RW</td>
 <td>Adobe Photoshop bitmap
 file</td>
-<td>&nbsp;</td>
+<td>PSD format is no longer supported since the
+1.3.24 release.</td>
 </tr>
 <tr><td>PTIF</td>
 <td>RW</td>
@@ -1285,7 +1286,7 @@ extensions: .gz for Zip compression, .Z for Unix compression, and .bz2
 for block compression. For example, a PNM image called image.pnm.gz is
 automatically uncompressed while the image is read.</p>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </body>
 </html>
index ddda975..7b6deb7 100644 (file)
@@ -344,8 +344,8 @@ image formats.
    | PS3          | RW   | Adobe Level III           | Requires Ghostscript_ to read.                   |
    |              |      | PostScript file           |                                                  |
    +--------------+------+---------------------------+--------------------------------------------------+
-   | PSD          | RW   | Adobe Photoshop bitmap    |                                                  |
-   |              |      | file                      |                                                  |
+   | PSD          | RW   | Adobe Photoshop bitmap    | PSD format is no longer supported since the      |
+   |              |      | file                      | 1.3.24 release.                                  |
    +--------------+------+---------------------------+--------------------------------------------------+
    |              |      |                           | Multi-resolution TIFF_ containing successively   |
    | PTIF         | RW   | Pyramid encoded TIFF_     | smaller versions of the image down to the size   |
@@ -812,4 +812,4 @@ automatically uncompressed while the image is read.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 4d30281..c7d7fb1 100644 (file)
@@ -1234,9 +1234,10 @@ width=15><b><font face="Helvetica, Arial"
 <table width="90%" border="0" cellspacing="0"              cellpadding="8">              <tr><td width="6%"><br></td><td>the type of image compression</td></tr></table>
 <table width="90%" border="0" cellspacing="0"             cellpadding="8">             <tr><td width="6%"><br></td><td><font size="-1">
 Choices are: <em>None</em>, <em>BZip</em>, <em>Fax</em>,
-<em>Group4</em>,
+<em>Group3</em>, <em>Group4</em>,
 <em>JPEG</em>, <em>Lossless</em>,
-<em>LZW</em>, <em>RLE</em>, <em>Zip</em>, or <em>LZMA</em>.
+<em>LZW</em>, <em>RLE</em>, <em>Zip</em>, <em>LZMA</em>, <em>JPEG2000</em>,
+<em>JPEG2000</em>, <em>JBIG</em>, <em>JBIG2</em>, <em>WebP</em>, or <em>ZSTD</em>.
 </font></td></tr></table>
 <table width="90%" border="0" cellspacing="0"             cellpadding="8">             <tr><td width="6%"><br></td><td><font size="-1">
 Specify <strong>+compress</strong> to store the binary image in an uncompressed format.
@@ -1246,10 +1247,11 @@ The default is the compression type of the specified image file.</font></td></tr
 the JPEG library has been patched to support it. Use of lossless JPEG is
 generally not recommended.</font></td></tr></table>
 <table width="90%" border="0" cellspacing="0"             cellpadding="8">             <tr><td width="6%"><br></td><td><font size="-1">
-Use the <strong>-quality</strong> option to set the compression level to be used by
-JPEG, PNG, MIFF, and MPEG encoders. Use the <strong>-sampling-factor</strong>
-option to set the sampling factor to be used by the DPX, JPEG, MPEG, and
-YUV encoders for downsampling the chroma channels.</font></td></tr></table>
+Use the <strong>-quality</strong> option to set the compression level to be used
+by the JPEG, JPEG-2000, PNG, MIFF, MPEG, and TIFF encoders. Use the
+<strong>-sampling-factor</strong> option to set the sampling factor to be used
+by the DPX, JPEG, MPEG, and YUV encoders for downsampling the chroma
+channels.</font></td></tr></table>
 <table BORDER=0 WIDTH="94%">
 <tr>
 <td width="3%"><br></td> 
@@ -1458,7 +1460,7 @@ type implied by the DPX header (if any).
 <dt>dpx:packing-method={packed|a|b|lsbpad|msbpad}</dt>
 <dd>DPX samples are output within 32-bit words. They may be tightly
 packed end-to-end within the words ("packed"), padded with null bits to
-the right of the sample ("a" or "lsbpad), or padded with null bits to the
+the right of the sample ("a" or "lsbpad"), or padded with null bits to the
 left of the sample ("b" or "msbpad"). This option only has an effect for
 sample sizes of 10 or 12 bits. If samples are not packed, the DPX
 standard recommends type A padding. Many DPX readers demand a sample size
@@ -1503,9 +1505,19 @@ behaves.
 <dd>Enables or disables fancy upsampling when reading a JPEG file
 (default enabled).
 </dd>
+<dt>jpeg:max-scan-number=&lt;value&gt;</dt>
+<dd>Specifies an integer value for the maximum number of progressive
+scans allowed in a JPEG file.  The default maximum is 100 scans.  This
+limit is imposed due to a weakness in the JPEG standard which allows
+small JPEG files to take many minutes or hours to be read.
+</dd>
+<dt>jpeg:max-warnings=&lt;value&gt;</dt>
+<dd>Specifies an integer value for how many warnings are allowed for
+any given error type before being promoted to a hard error.  JPEG
+files producing excessive warnings indicate a problem with the file.
+</dd>
 <dt>jpeg:optimize-coding={true|false}</dt>
-<dd>
-Selects if huffman encoding should be used. Huffman encoding is enabled
+<dd>Selects if huffman encoding should be used. Huffman encoding is enabled
 by default, but may be disabled for very large images since it encoding
 requires that the entire image be buffered in memory. Huffman encoding
 produces smaller JPEG files at the expense of added compression time and
@@ -1524,6 +1536,12 @@ are not.
 <dd>If the pcl:fit-to-page flag is defined, then the printer is
 requested to scale the image to fit the page size (width and/or
 height).</dd>
+<dt>mng:maximum-loops=&lt;value&gt;</dt>
+<dd>mng:maximum-loops specifies the maximum number of loops allowed to
+be specified by a MNG LOOP chunk. Without an imposed limit, a MNG file
+could request up to 2147483647 loops, which could run for a very long
+time.  The current default limit is 512 loops.
+</dd>
 <dt>pdf:use-cropbox={true|false}</dt>
 <dd>If the pdf:use-cropbox flag is set to <strong>true</strong>, then
 Ghostscript is requested to apply the PDF crop box.
@@ -1539,6 +1557,12 @@ requested pages.
 create Postscript files that render bilevel images with the Postscript
 imagemask operator instead of the image operator.
 </dd>
+<dt>ptif:minimum-geometry=&lt;geometry&gt;</dt>
+<dd>If the ptif:minimum-geometry key is defined, GraphicsMagick will
+use it to determine the minimum frame size to output when writing a
+pyramid TIFF file (a TIFF file containing a succession of reduced
+versions of the first frame). The default minimum geometry is 32x32.
+</dd>
 <dt>tiff:alpha={unspecified|associated|unassociated}</dt>
 <dd>Specify the TIFF alpha channel type when reading or writing TIFF files,
 overriding the normal value. The default alpha channel type for new files
@@ -1664,6 +1688,20 @@ is then defaulted to an appropriate size. Height should be a multiple of
 16. If the value is not a multiple of 16, then it will be rounded down.
 Enables tiled TIFF if it has not already been enabled.
 </dd>
+<dt>tiff:webp-lossless={TRUE|FALSE}</dt>
+<dd>Specify a value of <strong>TRUE</strong> to enable lossless mode while
+writing WebP-compressed TIFF files. The WebP <strong>webp:lossless</strong>
+option may also be used.  The quality factor set by the
+<strong>-quality</strong> option may be used to influence the level of effort
+expended while compressing.
+</dd>
+<dt>tiff:zstd-compress-level=&lt;value&gt;</dt>
+<dd>Specify the compression level to use while writing Zstd-compressed
+TIFF files. The valid range is 1 to 22. If this define is not
+specified, then the 'quality' value is used such that the default
+quality setting of 75 is translated to a compress level of 9 such that
+'quality' has a useful range of 10-184 if used for this purpose.
+</dd>
 <dt>webp:lossless={true|false}</dt>
 <dd>Enable lossless encoding.
 </dd>
@@ -4001,12 +4039,21 @@ width=15><b><font face="Helvetica, Arial"
 <table width="90%" border="0" cellspacing="0"              cellpadding="8">              <tr><td width="6%"><br></td><td>output files to directory</td></tr></table>
 <table width="90%" border="0" cellspacing="0"             cellpadding="8">             <tr><td width="6%"><br></td><td><font size="-1">
 Use -output-directory to specify a directory under which to write the
-output files. Normally mogrify overwrites the input files but with this
-option the output files may be written to a different directory so that
-the input files are preserved. The algorithm used preserves all of the
-input path specification in the output path so that the user-specified
-input path (including any directory part) is appended to the output path.
-The user is responsible for creating the output directory.</font></td></tr></table>
+output files. Normally mogrify overwrites the input files, but with
+this option the output files may be written to a different directory
+tree so that the input files are preserved. The algorithm used
+preserves all of the input path specification in the output path so
+that the user-specified input path (including any sub-directory part)
+is appended to the output path. If the input file lacks an extension,
+then a suitable extension is automatically added to the output file.
+The user is responsible for creating the output directory specified as
+an argument, but subdirectories will be created as needed if the
+<strong>-create-directories</strong> option is supplied.  This option may be
+used to apply transformations on files from one directory and write
+the transformed files to a different directory.  In conjunction with
+<strong>-create-directories</strong>, this option is designed to support
+transforming whole directory trees of files provided that the relative
+path of the input file is included as part the list of filenames.</font></td></tr></table>
 <table BORDER=0 WIDTH="94%">
 <tr>
 <td width="3%"><br></td> 
@@ -4420,7 +4467,7 @@ When writing a JNG image with transparency, two quality values are required,
 one for the main image and one for the grayscale image that conveys the
 opacity channel.  These are written as a single integer equal to the main
 image quality plus 1000 times the opacity quality.  For example, if you
-want to use quality 75 for the main image and quality 90 to compress 
+want to use quality 75 for the main image and quality 90 to compress
 the opacity data, use <tt>-quality 90075</tt>.</font></td></tr></table>
 <table width="90%" border="0" cellspacing="0"             cellpadding="8">             <tr><td width="6%"><br></td><td><font size="-1">
 For the PNM family of formats (PNM, PGM, and PPM) specify a quality
@@ -4428,6 +4475,14 @@ factor of zero in order to obtain the ASCII variant of the format. Note
 that -compress <em>none</em> used to be used to trigger ASCII output but
 provided the opposite result of what was expected as compared with other
 formats.</font></td></tr></table>
+<table width="90%" border="0" cellspacing="0"             cellpadding="8">             <tr><td width="6%"><br></td><td><font size="-1">
+For the TIFF format, the JPEG, WebP, Zip, and Zstd compression
+algorithms are influenced by the quality value.  JPEG and WebP provide
+lossy compression so higher quality produces a larger file with less
+degradation.  The Zip and Zstd compression algorithms (and WebP in
+lossless mode) are lossless and for these algorithms a higher
+'quality' means to work harder to produce a smaller file, but with no
+difference in image quality.</font></td></tr></table>
 <table BORDER=0 WIDTH="94%">
 <tr>
 <td width="3%"><br></td> 
@@ -17995,35 +18050,35 @@ color="#00B04F"><font size="+1">
 <tr><td width="3%"><br></td><td>
 <p>To display the version information:
 <pre>
-  % gm -version
-  GraphicsMagick 1.3.19 2013-12-31 Q16 http://www.GraphicsMagick.org/
-  Copyright (C) 2002-2013 GraphicsMagick Group.
+  GraphicsMagick 1.3.27a 2017-12-11 Q16 http://www.GraphicsMagick.org/
+  Copyright (C) 2002-2017 GraphicsMagick Group.
   Additional copyrights and licenses apply to this software.
   See http://www.GraphicsMagick.org/www/Copyright.html for details.
   Feature Support:
-    Thread Safe              yes
+    Native Thread Safe       yes
     Large Files (&gt; 32 bit)   yes
-    Large Memory (&gt; 32 bit)  no
+    Large Memory (&gt; 32 bit)  yes
     BZIP                     yes
     DPS                      no
     FlashPix                 no
     FreeType                 yes
     Ghostscript (Library)    no
-    JBIG                     no
+    JBIG                     yes
     JPEG-2000                yes
     JPEG                     yes
     Little CMS               yes
     Loadable Modules         no
-    OpenMP                   yes (201107)
+    OpenMP                   yes (201307)
     PNG                      yes
     TIFF                     yes
     TRIO                     no
-    UMEM                     yes
-    WMF                      no
+    UMEM                     no
+    WebP                     yes
+    WMF                      yes
     X11                      yes
     XML                      yes
     ZLIB                     yes
-  Host type: i386-pc-solaris2.11
+  Host type: x86_64-unknown-linux-gnu
   Configured using the command:
     ./configure  ...
   Final Build Parameters:
index 03952c0..9a327d0 100644 (file)
@@ -5,8 +5,8 @@
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <meta name="generator" content="Docutils 0.13.1: http://docutils.sourceforge.net/" />
 <title>GraphicsMagick Image Processing System</title>
-<meta content="GraphicsMagick is a robust collection of tools and libraries to read, write, and manipulate an image in any of the more popular image formats including GIF, JPEG, PNG, PDF, and WebP. With GraphicsMagick you can create GIFs dynamically making it suitable for Web applications.  You can also resize, rotate, sharpen, color reduce, or add special effects to an image and save your completed work in the same or different image format. " name="description" />
-<meta content="GraphicsMagick, ImageMagick, PerlMagick, image processing, OpenMP software development library, image, photo, software, Magick++, TclMagick" name="keywords" />
+<meta content="GraphicsMagick is a robust collection of tools and libraries to read, write, and manipulate an image in any of the more popular image formats including GIF, JPEG, PNG, PDF, and WebP. With GraphicsMagick you can create GIFs dynamically making it suitable for Web applications. You can also resize, rotate, sharpen, color reduce, or add special effects to an image and save your completed work in the same or differing image format. " name="description" />
+<meta content="GraphicsMagick, GM, PerlMagick, Perl Magick, Perl Magic, image processing, software development, TclMagick, Magick++" name="keywords" />
 <link rel="stylesheet" href="docutils-articles.css" type="text/css" />
 </head>
 <body>
@@ -47,7 +47,7 @@
 </colgroup>
 <tbody valign="top">
 <tr><td>Current Release</td>
-<td>1.3.26 (Released July 4, 2017) <a class="reference external" href="http://sourceforge.net/projects/graphicsmagick/files/">download release</a></td>
+<td>1.3.31 (Released November 17, 2018) <a class="reference external" href="http://sourceforge.net/projects/graphicsmagick/files/">download release</a></td>
 </tr>
 <tr><td>Development Snapshots</td>
 <td>(Updated frequently) <a class="reference external" href="ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/snapshots/">download development snapshots</a></td>
@@ -138,7 +138,7 @@ image</li>
 </ul>
 </blockquote>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </body>
 </html>
index 0413a07..b34c8e5 100644 (file)
@@ -7,17 +7,18 @@ GraphicsMagick Image Processing System
 ======================================
 
 .. meta::
-   :description: GraphicsMagick is a robust collection of tools and libraries to read,
-                 write, and manipulate an image in any of the more popular
-                 image formats including GIF, JPEG, PNG, PDF, and WebP.
-                 With GraphicsMagick you can create GIFs dynamically making it
-                 suitable for Web applications.  You can also resize, rotate,
-                 sharpen, color reduce, or add special effects to an image and
-                 save your completed work in the same or different image format.
+   :description: GraphicsMagick is a robust collection of tools and
+                 libraries to read, write, and manipulate an image in any
+                 of the more popular image formats including GIF, JPEG,
+                 PNG, PDF, and WebP. With GraphicsMagick you can
+                 create GIFs dynamically making it suitable for Web
+                 applications. You can also resize, rotate, sharpen,
+                 color reduce, or add special effects to an image and
+                 save your completed work in the same or differing image
+                 format.
 
-   :keywords: GraphicsMagick, ImageMagick, PerlMagick, image processing, OpenMP
-              software development library, image, photo, software, Magick++,
-              TclMagick
+   :keywords: GraphicsMagick, GM, PerlMagick, Perl Magick, Perl Magic,
+              image processing, software development, TclMagick, Magick++
 
 
 .. _download GraphicsMagick release : http://sourceforge.net/projects/graphicsmagick/files/
@@ -27,7 +28,7 @@ GraphicsMagick Image Processing System
 .. _programming : programming.html
 
 ===========================  ========================================================
-Current Release              1.3.26 (Released July 4, 2017) `download release`__
+Current Release              1.3.31 (Released November 17, 2018) `download release`__
 Development Snapshots        (Updated frequently) `download development snapshots`__
 Mercurial Repository         (Updated frequently) `visit Mercurial repository`__
 ===========================  ========================================================
@@ -106,25 +107,25 @@ Here are some reasons to prefer GraphicsMagick over ImageMagick:
 
   * GM is used to process billions of files at the world's largest photo
     sites (e.g. `Flickr`_ and `Etsy`_).
-  
+
   * GM does not conflict with other installed software.
 
   * GM suffers from fewer security issues and exploits.
 
   * GM `valgrind`_'s 100% clean (memcheck and helgrind).
-  
+
   * GM passes rigorous memory error testing using `ASan_`.
 
   * GM comes with a comprehensive `manual page`_.
-  
+
   * GM provides API and ABI stability and managed releases that you can
     count on.
-  
+
   * GM provides detailed yet comprehensible `ChangeLog`_ and `NEWS`_ files.
-  
+
   * GM is available for free, and may be used to support both open and
     proprietary applications.
-  
+
   * GM is distributed under an X11-style license (`MIT License`_),
     approved by the `Open Source Initiative`_, recommended for use by
     the `OSSCC`_, and compatible with the `GNU GPL`_.
@@ -144,28 +145,28 @@ Group as well as many others.
 Here are just a few examples of what GraphicsMagick can do:
 
   * Convert an image from one format to another (e.g. TIFF to JPEG)
-  
+
   * Resize, rotate, sharpen, color reduce, or add special effects to an
     image
-  
-  * Create a montage of image thumbnails  
-  
+
+  * Create a montage of image thumbnails
+
   * Create a transparent image suitable for use on the Web
 
   * Compare two images
-  
+
   * Turn a group of images into a GIF animation sequence
-  
-  * Create a composite image by combining several separate images  
-  
-  * Draw shapes or text on an image  
-  
-  * Decorate an image with a border or frame  
-  
+
+  * Create a composite image by combining several separate images
+
+  * Draw shapes or text on an image
+
+  * Decorate an image with a border or frame
+
   * Describe the format and characteristics of an image
 
 ------------
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index b2bbfc6..0207346 100644 (file)
 <div class="contents topic" id="contents">
 <p class="topic-title first">Contents</p>
 <ul class="simple">
-<li><a class="reference internal" href="#graphicsmagick-topics" id="id6">GraphicsMagick Topics</a></li>
-<li><a class="reference internal" href="#graphicsmagick-vulnerabilities" id="id7">GraphicsMagick Vulnerabilities</a></li>
-<li><a class="reference internal" href="#image-processing-topics" id="id8">Image Processing Topics</a></li>
-<li><a class="reference internal" href="#color-technology-related-topics" id="id9">Color Technology Related Topics</a></li>
-<li><a class="reference internal" href="#gamma-related-topics" id="id10">Gamma Related Topics</a></li>
-<li><a class="reference internal" href="#tiff-related-topics" id="id11">TIFF Related Topics</a></li>
-<li><a class="reference internal" href="#jpeg-related-topics" id="id12">JPEG Related Topics</a></li>
-<li><a class="reference internal" href="#dicom-related-topics" id="id13">DICOM Related Topics</a></li>
-<li><a class="reference internal" href="#metadata-associated-data-topics" id="id14">Metadata (Associated Data) Topics</a></li>
-<li><a class="reference internal" href="#high-dynamic-range-topics" id="id15">High Dynamic Range Topics</a></li>
-<li><a class="reference internal" href="#motion-picture-links" id="id16">Motion Picture Links</a></li>
-<li><a class="reference internal" href="#video-topics" id="id17">Video Topics</a></li>
-<li><a class="reference internal" href="#other-software-packages" id="id18">Other Software Packages</a></li>
-<li><a class="reference internal" href="#stock-photos" id="id19">Stock Photos</a></li>
+<li><a class="reference internal" href="#graphicsmagick-topics" id="id7">GraphicsMagick Topics</a></li>
+<li><a class="reference internal" href="#graphicsmagick-vulnerabilities" id="id8">GraphicsMagick Vulnerabilities</a></li>
+<li><a class="reference internal" href="#image-processing-topics" id="id9">Image Processing Topics</a></li>
+<li><a class="reference internal" href="#color-technology-related-topics" id="id10">Color Technology Related Topics</a></li>
+<li><a class="reference internal" href="#gamma-related-topics" id="id11">Gamma Related Topics</a></li>
+<li><a class="reference internal" href="#tiff-related-topics" id="id12">TIFF Related Topics</a></li>
+<li><a class="reference internal" href="#jpeg-related-topics" id="id13">JPEG Related Topics</a></li>
+<li><a class="reference internal" href="#dicom-related-topics" id="id14">DICOM Related Topics</a></li>
+<li><a class="reference internal" href="#metadata-associated-data-topics" id="id15">Metadata (Associated Data) Topics</a></li>
+<li><a class="reference internal" href="#high-dynamic-range-topics" id="id16">High Dynamic Range Topics</a></li>
+<li><a class="reference internal" href="#motion-picture-links" id="id17">Motion Picture Links</a></li>
+<li><a class="reference internal" href="#video-topics" id="id18">Video Topics</a></li>
+<li><a class="reference internal" href="#other-software-packages" id="id19">Other Software Packages</a></li>
+<li><a class="reference internal" href="#stock-photos" id="id20">Stock Photos</a></li>
 </ul>
 </div>
 <div class="section" id="graphicsmagick-topics">
-<h1><a class="toc-backref" href="#id6">GraphicsMagick Topics</a></h1>
+<h1><a class="toc-backref" href="#id7">GraphicsMagick Topics</a></h1>
 <p><a class="reference external" href="http://directory.fsf.org/project/GraphicsMagick/">Free Software Foundation</a> GraphicsMagick Entry.</p>
 <p><a class="reference external" href="https://www.freshports.org/graphics/GraphicsMagick/">FreeBSD port</a> for GraphicsMagick.</p>
 <p><a class="reference external" href="http://pkgsrc.se/graphics/GraphicsMagick/">NetBSD/pkgsrc port</a> for GraphicsMagick.</p>
 <p><a class="reference external" href="https://abi-laboratory.pro/tracker/timeline/graphicsmagick/">GraphicsMagick ABI/API Changes</a>.</p>
 </div>
 <div class="section" id="graphicsmagick-vulnerabilities">
-<h1><a class="toc-backref" href="#id7">GraphicsMagick Vulnerabilities</a></h1>
-<p>Search the CVE site at MITRE for <a class="reference external" href="http://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=GraphicsMagick">GraphicsMagick</a> vulnerabilities (seems to be stale).</p>
+<h1><a class="toc-backref" href="#id8">GraphicsMagick Vulnerabilities</a></h1>
+<p>Search for <a class="reference external" href="https://www.cvedetails.com/vulnerability-list/vendor_id-2802/Graphicsmagick.html">GraphicsMagick</a> CVEs.</p>
 <p>Seach SecurityFocus Bugtraq for <a class="reference external" href="http://www.securityfocus.com/bid">GraphicsMagick</a> vulnerabilities (select Vendor 'GraphicsMagick').</p>
 <p>Debian vulnerabilities in <a class="reference external" href="https://security-tracker.debian.org/tracker/source-package/graphicsmagick">GraphicsMagick</a>.</p>
+<p>Oss-fuzz issues pertaining to <a class="reference external" href="https://bugs.chromium.org/p/oss-fuzz/issues/list?q=graphicsmagick">GraphicsMagick</a>.</p>
 </div>
 <div class="section" id="image-processing-topics">
-<h1><a class="toc-backref" href="#id8">Image Processing Topics</a></h1>
+<h1><a class="toc-backref" href="#id9">Image Processing Topics</a></h1>
 <p><a class="reference external" href="http://homepages.inf.ed.ac.uk/rbf/HIPR2/">HyperMedia Image Processing Reference</a>,
 A guide to image processing algorithms, many of which are supported by GraphicsMagick.</p>
 </div>
 <div class="section" id="color-technology-related-topics">
-<h1><a class="toc-backref" href="#id9">Color Technology Related Topics</a></h1>
+<h1><a class="toc-backref" href="#id10">Color Technology Related Topics</a></h1>
 <p>Charles Poynton's <a class="reference external" href="http://www.poynton.com/Poynton-color.html">Color technology FAQs</a>,
 very useful documentation on color technologies.</p>
 <p><a class="reference external" href="http://www.color.org/">International Color Consortium</a>,
@@ -102,7 +103,7 @@ A standard default color space for the Internet.</p>
 an analysis by Greg Ward of various HDR encodings.</p>
 </div>
 <div class="section" id="gamma-related-topics">
-<h1><a class="toc-backref" href="#id10">Gamma Related Topics</a></h1>
+<h1><a class="toc-backref" href="#id11">Gamma Related Topics</a></h1>
 <p>While most computer images are encoded with a gamma of 2.2 (really 2.2
 to 2.6), GraphicsMagick does not attempt to convert images to
 linear-light before applying image processing operations since it is
@@ -127,7 +128,7 @@ and when you don't want it.</p>
 of how image resize on gamma-corrected images can cause distortion.</p>
 </div>
 <div class="section" id="tiff-related-topics">
-<h1><a class="toc-backref" href="#id11">TIFF Related Topics</a></h1>
+<h1><a class="toc-backref" href="#id12">TIFF Related Topics</a></h1>
 <p><a class="reference external" href="http://www.simplesystems.org/libtiff/">LibTIFF</a>,
 Libtiff library and TIFF format mailing list.</p>
 <p>AWare Systems <a class="reference external" href="http://www.awaresystems.be/imaging/tiff.html">TIFF</a> site.
@@ -139,24 +140,24 @@ Adobe TIFF specification for digital camera raw images.</p>
 A way to store HDR images using TIFF.</p>
 </div>
 <div class="section" id="jpeg-related-topics">
-<h1><a class="toc-backref" href="#id12">JPEG Related Topics</a></h1>
+<h1><a class="toc-backref" href="#id13">JPEG Related Topics</a></h1>
 <p><a class="reference external" href="http://www.ijg.org/">Independent JPEG Group</a> (home of IJG JPEG library).</p>
 <p><a class="reference external" href="http://jpegclub.org/">Guido Vollbeding's JPEG site</a>, including various patches to IJG JPEG release 6b.</p>
 </div>
 <div class="section" id="dicom-related-topics">
-<h1><a class="toc-backref" href="#id13">DICOM Related Topics</a></h1>
+<h1><a class="toc-backref" href="#id14">DICOM Related Topics</a></h1>
 <p><a class="reference external" href="http://www.dclunie.com/">David Clunie's Medical Image Format Site</a>,
 information about medical images.</p>
 </div>
 <div class="section" id="metadata-associated-data-topics">
-<h1><a class="toc-backref" href="#id14">Metadata (Associated Data) Topics</a></h1>
+<h1><a class="toc-backref" href="#id15">Metadata (Associated Data) Topics</a></h1>
 <p><a class="reference external" href="http://www.adobe.com/products/xmp/index.html">Extensible Metadata Platform (XMP)</a>,
 Adobe's XML-based embedded metadata format.</p>
 <p><a class="reference external" href="http://www.exif.org/">EXIF</a>,
 Format for metadata in images, particularly JPEG files from digital cameras.</p>
 </div>
 <div class="section" id="high-dynamic-range-topics">
-<h1><a class="toc-backref" href="#id15">High Dynamic Range Topics</a></h1>
+<h1><a class="toc-backref" href="#id16">High Dynamic Range Topics</a></h1>
 <p><a class="reference external" href="http://www.anyhere.com/gward/hdrenc/hdr_encodings.html">High Dynamic Range Image Encodings</a>,
 An analsys by Greg Ward of various HDR encodings.</p>
 <p><a class="reference external" href="http://www.anyhere.com/gward/pixformat/tiffluv.html">LogLuv Encoding for TIFF Images</a>,
@@ -165,7 +166,7 @@ A way to store HDR images using TIFF.</p>
 library and sample tools for dealing with high dynamic-range (HDR) images.</p>
 </div>
 <div class="section" id="motion-picture-links">
-<h1><a class="toc-backref" href="#id16">Motion Picture Links</a></h1>
+<h1><a class="toc-backref" href="#id17">Motion Picture Links</a></h1>
 <p><a class="reference external" href="http://www.lightillusion.com/home.htm">Light Illusion</a>,
 white papers by Steve Shaw regarding HD video cameras, log color spaces, and digital intermediate.</p>
 <p><a class="reference external" href="http://www.digitalintermediates.org/">Digital Intermediates</a>,
@@ -176,11 +177,11 @@ DCI offers the first complete specification for digital cinema delivery.</p>
 audio capture, transcoding and network file serving.  From the BBC.</p>
 </div>
 <div class="section" id="video-topics">
-<h1><a class="toc-backref" href="#id17">Video Topics</a></h1>
+<h1><a class="toc-backref" href="#id18">Video Topics</a></h1>
 <p><a class="reference external" href="http://www.fourcc.org/">Video Codecs and Pixel Formats</a>, offers a summary of YUV encoding formats.</p>
 </div>
 <div class="section" id="other-software-packages">
-<h1><a class="toc-backref" href="#id18">Other Software Packages</a></h1>
+<h1><a class="toc-backref" href="#id19">Other Software Packages</a></h1>
 <p><a class="reference external" href="http://dmmd.net/main_wp/visere/">DMMD Visere</a>,
 truly outstanding image viewing/browsing software for Microsoft Windows.
 Visere is based on GraphicsMagick.</p>
@@ -211,10 +212,10 @@ for reading and writing images, and a bunch of related classes,
 utilities, and applications.</p>
 </div>
 <div class="section" id="stock-photos">
-<h1><a class="toc-backref" href="#id19">Stock Photos</a></h1>
+<h1><a class="toc-backref" href="#id20">Stock Photos</a></h1>
 <p><a class="reference external" href="http://www.morguefile.com/">MorgueFile</a>, Free high-resolution stock photo images.</p>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index 0de1155..fe1b2cb 100644 (file)
@@ -41,9 +41,9 @@ Debian `GraphicsMagick packages <http://packages.debian.org/search?keywords=Grap
 GraphicsMagick Vulnerabilities
 ==============================
 
-Search the CVE site at MITRE for `GraphicsMagick`__ vulnerabilities (seems to be stale).
+Search for `GraphicsMagick`__ CVEs.
 
-.. _CVE_GraphicsMagick : http://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=GraphicsMagick
+.. _CVE_GraphicsMagick : https://www.cvedetails.com/vulnerability-list/vendor_id-2802/Graphicsmagick.html
 
 __ CVE_GraphicsMagick_
 
@@ -59,6 +59,11 @@ Debian vulnerabilities in `GraphicsMagick`__.
 
 __ Debian_GraphicsMagick_
 
+Oss-fuzz issues pertaining to `GraphicsMagick`__.
+
+.. _oss_fuzz_reports : https://bugs.chromium.org/p/oss-fuzz/issues/list?q=graphicsmagick
+
+__ oss_fuzz_reports_
 
 
 Image Processing Topics
@@ -248,4 +253,4 @@ Stock Photos
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 9a95aa3..b14888b 100644 (file)
@@ -416,7 +416,7 @@ individual image (composed of a header and image data) into one file.</p>
 <p>John Cristy, <a class="reference external" href="mailto:magick-users&#37;&#52;&#48;imagemagick&#46;org">magick-users<span>&#64;</span>imagemagick<span>&#46;</span>org</a> ImageMagick Studio LLC.</p>
 <p>Maintained since 2002 by Bob Friesenhahn, GraphicsMagick Group.</p>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index 73a82ef..7d745df 100644 (file)
@@ -356,4 +356,4 @@ Maintained since 2002 by Bob Friesenhahn, GraphicsMagick Group.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 4218f29..b910e90 100644 (file)
@@ -63,7 +63,7 @@ GraphicsMagick a stable component in Linux and BSD distributions.</li>
 <li>Value, and respect the contributions of developers, and observe and
 respect the copyrights of other projects.</li>
 </ul>
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </body>
 </html>
index 8cae978..d9d08b1 100644 (file)
@@ -44,4 +44,4 @@ The objectives of the GraphicsMagick project are to:
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 2e83001..2f58b5c 100644 (file)
@@ -783,7 +783,7 @@ gm identify -format '%[dpx:*]' foo.dpx
 </pre>
 <p>to list all DPX header attributes.</p>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </div>
index 6533f13..b95ee36 100644 (file)
@@ -640,4 +640,4 @@ to list all DPX header attributes.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index b47cb0d..8a6a99a 100644 (file)
@@ -2036,7 +2036,7 @@ $status =~ /(\d+)/;
 die &quot;unable to continue&quot; if ($1 == ResourceLimitError);
 </pre>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index 92d1de9..b5c7fde 100644 (file)
@@ -1499,4 +1499,4 @@ The following illustrates how you can use a numeric status code::
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 65a8b74..48d4d5f 100644 (file)
@@ -120,7 +120,7 @@ final release.</p>
 <p>Exit Criteria: None</p>
 </blockquote>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </div>
index 7fcc20d..4d7a405 100644 (file)
@@ -99,4 +99,4 @@ Release Phase
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 451eae5..bf01ae9 100644 (file)
@@ -104,7 +104,7 @@ a COM+ object.</td>
 <p><em>Some of these languages and scripting environments are supported by the
 GraphicsMagick Group while others are developed and supported by third parties.</em></p>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </body>
 </html>
index e9fee7a..1c995ce 100644 (file)
@@ -70,4 +70,4 @@ GraphicsMagick Group while others are developed and supported by third parties.*
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index ae8f939..5a292bc 100644 (file)
@@ -55,7 +55,7 @@
 <p><a class="reference external" href="thanks.html">Thanks</a> - Read about those who helped in ways other than contributing code.</p>
 <p><a class="reference external" href="Hg.html">Source Control</a> - Source control is important.  We now use Mercurial.</p>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2012 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2012 - 2018</p>
 </div>
 </body>
 </html>
index b5927c1..a8ac0be 100644 (file)
@@ -59,4 +59,4 @@ GraphicsMagick Project Information
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2012 - 2017
+Copyright |copy| GraphicsMagick Group 2012 - 2018
index 5d4eca4..03e4836 100644 (file)
@@ -244,7 +244,7 @@ values in the image.</dd>
 of using space subdivision for the color reduction algorithm. With Paul's
 permission, this document is an adaptation from a document he wrote.</p>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index 2eaf44f..03ad83c 100644 (file)
@@ -240,5 +240,4 @@ permission, this document is an adaptation from a document he wrote.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
-
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 3476a39..2d0e406 100644 (file)
@@ -44,7 +44,7 @@
 <p><a class="reference external" href="miff.html">MIFF</a> - Magick Image File Format.</p>
 <p><a class="reference external" href="links.html">Links</a> - Some links we find useful.</p>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2012 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2012 - 2018</p>
 </div>
 </body>
 </html>
index 47abe8c..3260dff 100644 (file)
@@ -26,4 +26,4 @@ Links_ - Some links we find useful.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2012 - 2017
+Copyright |copy| GraphicsMagick Group 2012 - 2018
index c54024a..3ed62e0 100644 (file)
@@ -45,7 +45,7 @@ very important consideration for GraphicsMagick.  GraphicsMagick may
 be used to open files and URLs produced by an untrusted party.  Given
 a suitable weakness (which we make every effort to prevent), an
 intentionally constructed file might be able to cause the software to
-crash, leak memory, request huge amounts memory, run forever, or in
+crash, leak memory, request huge amounts of memory, run forever, or in
 the worst case execute arbitrary code, including shell code.
 GraphicsMagick is very powerful and complex software supporting many
 capabilities and so untrusted parties should never be allowed to
@@ -69,9 +69,19 @@ not constraining what its users may do with the software.</p>
 then it may be addressed by email directly to the GraphicsMagick
 maintainers or to the <a class="reference external" href="mailto:graphicsmagick-security&#37;&#52;&#48;graphicsmagick&#46;org">GraphicsMagick Security</a> mail address.  More
 minor issues are best addressed via the <a class="reference external" href="https://sourceforge.net/p/graphicsmagick/bugs/">GraphicsMagick Bug Tracker</a>
-at SourceForge.</p>
+at SourceForge.  Please remember to set the bug to 'private' if you
+use the bug tracker or else someone may aquire a zero-day exploit from
+your report.  We wil set the bug to 'public' as soon as a remedy has
+been made available.</p>
 <p>Reporting an issue will allow us to fix it so that future releases of
 the software won't suffer from the problem.</p>
+<p>The remedy available to us is to submit a changeset to the
+GraphicsMagick Mercurial repository, and include the changes in the
+next release.  Regardless of how an issue becomes known to us, the
+issue will become public knowledge as soon as we commit a fix to the
+source code repository.  Only in exceedingly rare and dire
+circumstances (e.g a previously-unknown zero-day shell exploit) might
+we do anything different.</p>
 </div>
 <div class="section" id="safe-use-of-the-software">
 <h1>Safe Use Of The Software</h1>
@@ -134,7 +144,173 @@ access of http and ftp URLs (<a class="reference external" href="https://cwe.mit
 block SVG renderer access to read local image files.</p>
 </li>
 </ol>
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+</div>
+<div class="section" id="pgp-public-key">
+<h1>PGP Public Key</h1>
+<p>The following PGP public key (belonging to Bob Friesenhahn) is used to
+sign release files on the ftp site and may be used for private
+correspondence:</p>
+<pre class="literal-block">
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+
+mQMuBFvWDmMRCACvO+aWyRPlp7jezY8m4t8q+MkLQXczLCoC8sUVQ5qd5T28HsfD
+rUVzrFYY6pWT1K3AgTTKZnVcBO5lyZtLLS6HQI41FESp1Gp/FtyisYbOlQAeOvfG
+yJVCQe16QoaHye0UIC8rs2VqH055nSewk7YOpEg9PNdHce0/Mvajkxyj2Eb6C4jp
+mZuvcPhU4MaEqo9yAlSnRztwqmmDwvO60LPEoS7WRUB3oEqDGGR8wnMARbCwjlVn
+kMHd5BqgOnFDhqxxGnQzq+dv9C4RKGZtpIFl+jVpx9m5DszF9ZYEDtNMwxAoCIia
+mZE0DkxTwI5lbwe9Pc3HZSK/wEF7Df1HC/U7AQDoVpk/g33Tllvsd52UYUZM1aca
+3qaPM6orhVLXysaI+Qf+LoRoQgTlQX4IP19Z2t8MIx7VP08SOsrZdNAwIgHO4fhs
+dOX6okfwpiYOl1bGqnakprit4HarAhtSM0Xd8JPtXImPqzHN07yz6jhCKZBIFWGC
+kJSzPFar+P/jCmCWArL7DfBelBw0aHiV7HmSqEQJsyKVZBYjgHmXzjLkp3zsFRaR
+tAj3TnB+nN4uXCchv63bVmYd3Cv55AZyugJb49Kl5PHqHarcle39Gbhg/UPPiduo
+zIQKqtsKZcLckxZWi5f3XF/BnIY+uKdbOssTY0u8hyCqj904KdUl50GtYEb274EZ
+a7ZepmcSp6a3aTtQmmHMf1MP/5U7Z6c6fNha4N3Xwwf+O1Zhc0Y11JSEV8G/2gAC
+rjwYCIQ17w6/KDUe4nflxZpCsTP7+YOwmaXRSBqBoCz5N3ZH9jTp0xu73l6hK5wY
+LodkfYHRhIMSyRCrW4T7yalUlpcuJy0NhFUnCDALgkjAhLUi4goJ+nsnOIJWC1dp
+5DhZtClRTWNIHWK1AmIrWAUBuodpcp6K1NouJFenQB/NtwHS71J+ILli9LTxt6jM
+CvaOAseRjvOs8JxG3pBm2LPOvZDyvQQFvfrTgqOlcMgqVp4mIqTKeEtXa2AQWrCG
+QK5Ig3ZxfiQuNYIYNRsbag8Xyo8/udvbMDXVOAWQlmQz2B/Ge23rTGQZPMixoA+e
+JrQuQm9iIEZyaWVzZW5oYWhuIDxiZnJpZXNlbkBzaW1wbGUuZGFsbGFzLnR4LnVz
+PoiZBBMRCABBAhsDBQkSzAMABQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAFiEE69/b
+IbAg7o/RUaiN4wEEfeEZiXUFAlvWDvECGQEACgkQ4wEEfeEZiXXLpgEAqPfOR6nD
+iq8o/5RZ57f8UFNSPBiLTFbi/FTHhn9FV/oA/14uiKfpWhhKib3INfOZweDC0sHX
+GdULE2Nrbx54Rn/otCxCb2IgRnJpZXNlbmhhaG4gPGJmcmllc2VuQHNpbXBsZXN5
+c3RlbXMub3JnPoiWBBMRCAA+FiEE69/bIbAg7o/RUaiN4wEEfeEZiXUFAlvWDskC
+GwMFCRLMAwAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQ4wEEfeEZiXWxkwD8
+DK9I1UeGW8TIQQ5zzyk9Ue2+0C3RP5R45Dg3cg9W01oA+gIELZMu+15wCOG22dRO
+NAvZUjNS8TrGIWtGvQNE5IYctC1Cb2IgRnJpZXNlbmhhaG4gPGJmcmllc2VuQGdy
+YXBoaWNzbWFnaWNrLm9yZz6IlgQTEQgAPhYhBOvf2yGwIO6P0VGojeMBBH3hGYl1
+BQJb1g7jAhsDBQkSzAMABQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEOMBBH3h
+GYl1RekA/2UUHeqkrePzLtI10VfprqAgjYYRIb4Ue/Y18hzSHYEyAP4+LBt/y6CS
+5kq5G7RtM072ujLm4LMRu+KKGmSVQz1u2LQrQm9iIEZyaWVzZW5oYWhuIDxib2Jq
+ZnJpZXNlbmhhaG5AZ21haWwuY29tPoiWBBMRCAA+FiEE69/bIbAg7o/RUaiN4wEE
+feEZiXUFAlvWIvsCGwMFCRLMAwAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQ
+4wEEfeEZiXWYugEAv6hEjxqDR2pZu6/2qrG642OMk0lHVlFjla3F8hpMabIBALNd
+pWvc+nb/HbZTWT5cebhA8Z/dExYTjB9jUIdNYAbU0dKI0oYBEAABAQAAAAAAAAAA
+AAAAAP/Y/+AAEEpGSUYAAQEBAEgASAAA/9sAQwAUDg8SDw0UEhASFxUUGB4yIR4c
+HB49LC4kMklATEtHQEZFUFpzYlBVbVZFRmSIZW13e4GCgU5gjZeMfZZzfoF8/9sA
+QwEVFxceGh47ISE7fFNGU3x8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8
+fHx8fHx8fHx8fHx8fHx8fHx8/8AAEQgBBQDEAwEiAAIRAQMRAf/EABoAAAIDAQEA
+AAAAAAAAAAAAAAABAwQFAgb/xAA1EAABBAAFAgQEBQQDAQEAAAABAAIDEQQSITFB
+BVETImFxIzKBkRRCUqHBBrHR8CRy4VPx/8QAGQEAAwEBAQAAAAAAAAAAAAAAAAEC
+AwQF/8QAIBEBAQACAgMAAwEAAAAAAAAAAAECERIhAzFBFDJRcf/aAAwDAQACEQMR
+AD8A9MmkmmgJoQmDQhCQNCEJgJoQgBChfiWtdlaM55rYKE44NP5SeaKQ0uoConqL
+QdRp6FdjHMcQMzWj1KNjS4hQiYH8wPsVK0gj0QDTQhACEIQAhCaASaEJGEIQglZN
+CYVAIQmkAmhNACFHNNHBGXyvDWjkrCxfW5Z3+Dg2lpPNalAk228RiocMLleAeByV
+hdQ67mOSG+xA3/ZRswMkvmxMpBO4adT7lWoMLDh21FG1oUXJrMGZHJ1DEnWIhg2B
+8oVhuFxjmgOdG0e5K02hdAJbaTBnfgZq0kafbRP8JiAKDz9Fo0utktjgyM0+HdYF
+fRXML1YWGygtPcK0Q1wIcL91Tn6bHJrGSw71xacqbg2sPiGTMBa4G+ymXlRJicBJ
+rY107Fa3TerxYs5H3HJtR2JVysrjpqpICaaQhCEAIQhIwhCEwrppBNBBNJNANRYn
+ENw8ZcdTsB3K7cQBrovO9Z6sG3HCC52wQNKWOkxvUcaIswaOa2aFo4TDRYSPJENe
+XHd3uocLF4MWvzu1ee5VtgtZ2t8cdJAuwEmhdtClqAF1SNF0AkZUhd0kgOU6QnSA
+5dG2RpY8AtPBWH1LAOw5EjLLBs69R7rfASexsjCxwBaRRBTlRZtmdK6zKwtixJL2
+HQOO4Xo2PbIwOYQWnYheHxMBwGLfEbyEW0ntwtro+Py0x7hlO/v3WkrDLF6BCN0K
+kBCEIMIQhIK6a5TTI00knGmknhAZfWcb4bPBjdT3D7DuvN4MHEYwvqo4/wBypMXi
+XYnETSa+c0PZWcHEIcO0VqdSprTGLrNQpmLiIeVdtWbeJ2KVoChYpm6pKMjZABXR
+GyKQBRQbQUAoBhMhIFdboIkIQgMzrmFM+E8WNtyRa1+ochY+EmEbWk2WO0BPHofV
+eqdq0grzpwrRPPh3aNJtp7K8WWT1PT5fGwcbr1Aoqysb+nZiYJIX6PYdVtLRjSQm
+kgBCEICradri07SDu1V6nJ4XT53XRy0FYtZ3XnV0yQDckD90B5iMgkWTZND0C1I9
+aWTCfi2BY2WzBVWpya4rLRQXbVwx7CaDh90zLGzXMFDVO1WGBZoxsPiZQ4WrsMzX
+mgUHtMQlei6cQHNHcII8pSNxVrsNSZRFrtppAKkFPMLSKZBCSaROSsrGDLjWkfmF
+LVKzce23NPY/ZVPaMvSfpALcWTW4ylbqxeln/lHs4X9VtLVhSQhCAEIQgKNp2uLT
+CRurWT/UcmXAtHd9/YKx1PqLenQskdE6QOdXl4WTNjGdadFC1ro3B1lpB2re0QMv
+COLpAaJA9F3iJ5nGg6OMcHxAD9la69HHh3RQxU1gZfue5WWMGHZRkKSoCZLP/Miv
+uHKF7cQbAlbIPR4/ytODpTHfN9lbHRoDu0JbiuNYMMkkcgE7HjsSKXpOm4gkgA7L
+lvTGZXZSAGiyCd0mxtwoYQCHXr29KSt2qTTXM2ado9FZcaiJWTA/PPm4AWpYdGaI
+Oilr8V/xGRt/dU39Re3K0aOOps1SeJJaSwDlVHYbO5zpDZIqhsE5EZVHP158DnBu
+R3uaXcX9SsLR4jCL5GyryYPENPwGRtHfIFxLh+pvykyE0KALQaH2VaiO2tF1yB58
+pDh2vVaWHxcOIAyPAJ4O68m6PFRn4kMT/eMD+ynwxLZB5fCdwWmwfoUuJ8q9Udln
+Yt2Ug+qs4fEGQZJBlkq/Rw7hVMfpde6J7F9LfSac8G9iVsLB6K4+O5vG63lowoQh
+CAEIQgM5MJJhSpFisNHi8O6GUeV3bceqzWfisFQxERxAhGWN8ernt9u4/dXsTjRC
+7K0Znc9gqb8cXzxOc0AMu6PCNq43W2L1iZmM6lD4Ts8bwKKslrImhzjoOUY0RzdV
+bNGwCm+Z1VZTdEZt9ApyqsIrnqDi7LG0l36Rx7lVD1jEFxADQB3ctiHBxsbo0A9w
+qj+hwPmLjI5oOtCkTSrMvjnD46RznNf8KRhymzmaT7qeWd0rSx7HAkfk1P0XYwMU
+EJjiILXGzm3KpY1skdRRE+cZRR2vc/b+6OtjvisdJwgxbc80kjh2ugtg9Oa2KoJZ
+YqN+V3P1UfTomxQNa3QAK8HdlO6vj0ycOZfFlbNL4hj2NV/pUj5mMbZIACrYvxIc
+c4Rg1I5poC7Gx/hdy4enEtIIGluKdTHbMW0nRjj76KwMYx7ySyu+TWvosHHskjlH
+ntuW96srnARfiMZGGZ2fMXAPuv8AdE5iVy1XpS1k7aaQ4Kv+CLHG2HKPTZRQmWHE
+hshzEEVIBv6OW9IGyREtcNtdUr0VZ2KbL4DPw+UTAjIXbLOkxM4kP4uB7DYAIAyg
+HueVrv8AmjB4dazuqPANO0BBBVQrFzpDSzFubd0KK3Fh9Ft09uGoYL96C3FcZX2a
+EIQQQhCAzkwkmFKnmcU/EPnd4ZoXa4OctIkAtwG3ZX8RHlne0dyFWxDalib62foF
+M9ujP1NOWktpsu36uPr2V6JrXNGWj7KvCddiphDC45sgB7jT+yVTFlsY5T8JlWVA
+2Ng2dKB2zlN0UVate/8A7OJSaK+JkYDkiGd/YbD3PCqMjLpc7zmLef8AHorkoOXK
+0BjewUIAAIQFvDSHQBXm7WVRwjL1V9tbIUrYuMuyyNoOadCos4l/LRG4PBV1zbBB
+5UEmHsB2ocNnD+U0a7Rsa2sr42lvqF3Fh4Y3EsjDeNBS5D5GkAta760rDJHf/B59
+i0/ygWQNaL2UwBaw1suAZSfLAR/2cAuvDlefiva1v6Wc+5KNFa5Z8WW26sZoD3Kp
+45oc9xrYi/RabGhgDQKA4VHGNqU38sjKKcqMp0v9MhbDDmLgZH6nXYdlfCzGECJl
+18o3VrDSX5bscaqpl8Tl4+trKEIVMjQhCAzkwuUwpUz8c0NxLT31WdibGJbppS1e
+os0jkH5TSysa4eNC6xRtR9bzvBZw40Vto0VSA6BWwdLCRwz2pRuPCkvRRlJcQTaN
+Vbeh6qxLqCoZAI47JArkpwq0sOwBgpTtjJdfCp9PxQljFEEjkG1fbJqnobJzK1Qw
+A6cIkkFgWBabRWyVDh+HadQFy1mUiiVYCKHZAJgJ5K7DAEAUmChNjl26p4s3LG29
+CDatuPmIWfijnxbQD8oTib30vvY2SLVunCjwTGxYtwYTltSQOaWZfRPBsJlc/gFE
+9rvWNX0JJrVyBCaEBmphJNSpzMzxInN53C851T4Yjygb3/lemWB1pmWUNrRwJCWu
+1S9acYV9sDuFfD7CxMDMdWna91psfbjSmtcatNdaHBcRFSOdQUtIrzGmk9lR6phn
+Y3Dhsb6G/ur0725aOqpRNklcRH5GcknhOSllZ9VukwzYAeeqcbIBsLdje5xvhcQw
+HIM2ulFdyOc1lMGwGytH+MjDx4t/Vn4rEkhpcWMHGXhejjdY0WdHIS5zHjQa3Wy0
+ImgN02U1eNmkoXYXC6UmLpLNok86KJ7twE00y7c9lVgp0ksjt/l912ZBIQBzofRT
+QYcZibHsq+Il7EIy2eFoQMyRAcnUqsxpfLVeUH7q4njC82Xw00k1bAIQhAZqaSal
+RrI64wlraGpBC11Q6nHnaK7FEDzTSYbaBbgaF+ivYeexRNqji7YGyaeTUqOCcNkA
+HJ0SsaS6egErWNtxpVZcc296UTneNJlGrWts+/CrFzTiBoSAaHb3SmKrn/E7ZjPI
+QbAHqruGDYcwNOOVun3A/hZ2Ghe3ERmVvlPblabXND3Ea63/AIVRnbatRSF0Ugde
+hoouwATR0B9FA2VrXObqc2ug5Xcbmud5tB8pKD7jp7PzaZxYschd4fEtbe9Hj91F
+LMDbjoAwnTdUnYjMyMtNOePlHFIolsb7XtdsV2CsSLEB5zG8xOlaa+qvYfFEnI/R
+1WPVZ2NZktvIrVUZJhZYDr3UuImHgmjqs2I+JJbtDv8A+pyJtWMI7MTffRbDQAL5
+WbhoqnAO1rVijsAnbgKtI3Jd1JGzKL5K7QhX6ZW7uzCaSaAEIQgM0JpIUKNQ4ttx
+X2UyT252FvdM3kuoRfDu9CdlR8PLK0uFNvfst7FQZnlrhq02FRmhysLq0bdE+qDP
+DuAwbnEAEmw30vS/suIp4g03Ys73qVSfO4wsDXZW0AQe4U7Mr21ltu59UWiTa67F
+RuBLi0nvey6in8RtMzEDaguIRFuYmj6LSiEeW7LfdTttJFOOZ7Xi2kV6Ky97nNrK
+6uNFbbC0nyuFrsQkncE+6e1ajOLixpu6OtEKIRxHKYyAW3QWx4RHDQqs+Fhf53AE
+j9OiNpsjL8Tw3hwNg7g8lW2yuzMNgDVwJ40Uc+AY0Zm2Ne9rqDD5mPr5kts6c2Iz
+OaRdEbKaOIuexxGlVf7qsxpMoBAFG233W3HBUbB20KqQrRGLksC/MFpMFNAKqYaE
+tdbtVcTZ0JpJpkaaSEgaEIQGahJNSo0wkmg1PHRA+YDcarzmNmtkrR5gR27L1szP
+EiI5XnJoWsxZz2WuFaDdUGPgsE7FSuLh5Wmr4Wo+BkDQ2MXQ0FLRw8LI4sopjBtl
+1v8A9XMsVyBxbduAq1NVjYrQQuOYvdmIFG9gVaw7GeEC46uK5ja510QBZvTSu391
+wHRweGXmg11C+AnBdrD/AJ5Xg5ctAWp35hqDu0G/2KqR4qN7HuLSA55FuG9jT/fZ
+TjENcMgIOawD/CeoXKos73ucMxB0+65aHaG/RdNzid7OTlN/79FbDAS5vqVOlckD
+2ktoV6qCAmKUHSgav0WjHCxwNGtPsoMVhHPBLBrzXdKQWqFEvAPzBxP0tbuCOaNz
+SSaNi1jx+WVjng+ITRJ5W5hIso13O6uIqxEKGqkXIFBNNBppJpA0IQgGhCEBmJpI
+UqNNJCDdcLHxI82bkHstdYeLxELZ/Bc8ZydAnCaOGa3L5tXFtk9go3NzyNNO9PQJ
+wvDi4N9zamyB7zuTaoRAGBpNN04pRmIOcKs9waVp7fLTSA0bmlAb8IAD5jeqixrL
+tCYBK5zKto3ICkiw4I20F/dON1AtbppqfqVLC7LGe5KQcxsBc11eZhrbcKWhmIH0
++6cDT+IBrQ3f0XToyXuGxHyn90y6d4YuzBrxRHNbqyYhR9eFxDTmBx0J0KlJNU5X
+IzyrMlhBkAduTuB6/wB1oYY39lBLXzVvpqpMGbkefRK3s9dbW00kIQaaSaAaEIQD
+QhCAy01nP6o0HyRkjuTSgl6nK8VG0R+u5UbjaeLKtaSVkTc0jg0dys6Tq4LqhZYH
+LlmyOe+3PcXHuSowKAStbY+GfV6TqM8gIz0D2FKiyFrfinWV+uZMLsaxt9giU88Z
+J0u4Kf5g7QVS1mWBodatedIc0B7SR7LTwWLa/IzMb222WkrmyxXg24DfJJUZFAkg
+VltqkJDRpyVG7zUAf97J6TtXaKlDBp5QSiEF2dw+UaV90nSZJiSNtR9f/wAUkJIj
+JA1ddUlo9rTfJzsAfupqtmY6ktUbMpaTuC0BSBwzDsdE9Fak0aRtqkX2wncqOaQE
+V2XG+vdO3QmOyldXl4CgzOaSWuLT3C7fqVGNzysbW8nWleXFdQwzi9jzOz9JAsf5
+VrB9Y8ePMWA8GtCEZbVANEeJmrSyL96RuqmMy6sehgxMc/yHXsd1MvOxyEPsGloY
+HqQcfCnPmGzj/KqZIz8NncaaEgbTVOc0IQgPE7hACGbJhYvSIjRcOFKalwQg0QUk
+Y+Dr7LghOF/mew+4REeT0sxAFhB4UbmOifnZpym05JG9ireXM2+FW2FiGLGTM3dp
+6q14zZAasGvuoBC0k1SnjhA11VyouJkGQEHbddMaWM0qq0U0cYI7Fd+BYT2nTiKS
+mhrj7qbOKAC48Dm1IG0jkOLkMvfZdONBdcKJ5oKLWkmnPdyTBaZ0aiMeW0jDnBjS
+47ALLa4yFz/1G1Zx8t1C3d2/sq7RQUtvHPqRpoEqOJxyl252Se7yn9l3EKbXYIaL
+cONlhAyutvYq5H1iO8srHA9wLCyeKKVJy2M8vHjl7egb1DCuF+KB7hCwLpCrkj8f
+FRYu0IUtjCCEISNG4KJxyzMI5tpQhETn+q05vw77K9hzcYtCE4wFZXabFStOtUhC
+ok7ApWuIQhNNMnZG6EJAHZQu+coQkopRTVy55jgLhqUIQGVGS8ukcbc4qW9EIUuq
+enG8jRxuu2H4lIQg3ZCChCCcOOqEITD/2YiWBBMRCAA+FiEE69/bIbAg7o/RUaiN
+4wEEfeEZiXUFAlvWLooCGwMFCRLMAwAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AA
+CgkQ4wEEfeEZiXUcvgD8Dd3c9PMFe8l36YcKLs1ubSEF30mu3b/s8oG7CgeBdOcA
+/062qY6F+Hy0GK/kc5WN9pr5rvFcdS/Tz8wDq5d1shjYuQINBFvWDmMQCAC0JHbI
+pX4rz6HzifXiVvPKKgOFdxRs4xZkOA8/sPcK3rB34waMuOgBme6jL7iJNfbC60eo
+TIMv75i0C1MWxQReoR+UA+mQctuvpcrkzzceEYH2JWFf0NZZtT5wYoJ8JNfW1ngi
+r/QhPRWC4fNfJQiJhWdf4sdP2BnW0hi5IIPnmkHQ44G0xBQpOqPrv7A8F97ROGYD
+oS3LNmKmfLV9nKRBH+NmQ+zdaToNcQTOlSbMVZ/hag1F9LSmAUFcqXr9bKKk/qKj
+RBkEweAsYppTgn0N7StNtcT9aR5zZkqJ9FBgls6LSr2H6QPiaGZeixZrywjxz2ku
+xz5C1D92ZVAe0qhTAAMFCACyCRhU7YmWUdC3D5rMna97JhFu2fQygn5FQEuHOFao
+abaUicXCxlW3IKQqBjOcpN6rZl+crapYVKGCGM4nMvmxEqqRBYAHLw8vc3Nfys/O
+AXWxI6kiZlVAIX/Q0IZveFejRCoEo6bBabGSfDHWH7QqZXEo2TNWiGJ6oLOyIISl
+x1MM4e9jRSufukrtTfsU8HDoWKycRSnaxtYOz4FAAofrCeQ6/Nf3Vf887NXXD1I6
+xMp9vyuYqx68SrqtmX9FauagsHzmLylYI42JciTCvje09D9kAHFaidkR58DVgzPW
+xFQCGBDO8Rrk1lVjO2gX2bVzKW1J+67ENM1YdWjiVzt9iH4EGBEIACYWIQTr39sh
+sCDuj9FRqI3jAQR94RmJdQUCW9YOYwIbDAUJEswDAAAKCRDjAQR94RmJdRzqAQCZ
+KJFm7j0Zug7NN+IPTqnIrPCioJkt1iGbec6SbBHh5AEAy5JEbI2ugQEePaIMGWVV
+akWaTz0WKIOiD9Lm2ylI9J0=
+=UAq2
+-----END PGP PUBLIC KEY BLOCK-----
+</pre>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index 7d5bed3..2bc14a2 100644 (file)
@@ -16,7 +16,7 @@ very important consideration for GraphicsMagick.  GraphicsMagick may
 be used to open files and URLs produced by an untrusted party.  Given
 a suitable weakness (which we make every effort to prevent), an
 intentionally constructed file might be able to cause the software to
-crash, leak memory, request huge amounts memory, run forever, or in
+crash, leak memory, request huge amounts of memory, run forever, or in
 the worst case execute arbitrary code, including shell code.
 GraphicsMagick is very powerful and complex software supporting many
 capabilities and so untrusted parties should never be allowed to
@@ -47,11 +47,22 @@ If you become aware of a serious security issue with GraphicsMagick,
 then it may be addressed by email directly to the GraphicsMagick
 maintainers or to the `GraphicsMagick Security`_ mail address.  More
 minor issues are best addressed via the `GraphicsMagick Bug Tracker`_
-at SourceForge.
+at SourceForge.  Please remember to set the bug to 'private' if you
+use the bug tracker or else someone may aquire a zero-day exploit from
+your report.  We wil set the bug to 'public' as soon as a remedy has
+been made available.
 
 Reporting an issue will allow us to fix it so that future releases of
 the software won't suffer from the problem.
 
+The remedy available to us is to submit a changeset to the
+GraphicsMagick Mercurial repository, and include the changes in the
+next release.  Regardless of how an issue becomes known to us, the
+issue will become public knowledge as soon as we commit a fix to the
+source code repository.  Only in exceedingly rare and dire
+circumstances (e.g a previously-unknown zero-day shell exploit) might
+we do anything different.
+
 
 Safe Use Of The Software
 ------------------------
@@ -122,7 +133,173 @@ risk.  These are steps which can be taken:
    access of http and ftp URLs (`SSRF`_ vulnerability), but does not
    block SVG renderer access to read local image files.
 
+PGP Public Key
+--------------
+
+The following PGP public key (belonging to Bob Friesenhahn) is used to
+sign release files on the ftp site and may be used for private
+correspondence::
+
+  -----BEGIN PGP PUBLIC KEY BLOCK-----
+
+  mQMuBFvWDmMRCACvO+aWyRPlp7jezY8m4t8q+MkLQXczLCoC8sUVQ5qd5T28HsfD
+  rUVzrFYY6pWT1K3AgTTKZnVcBO5lyZtLLS6HQI41FESp1Gp/FtyisYbOlQAeOvfG
+  yJVCQe16QoaHye0UIC8rs2VqH055nSewk7YOpEg9PNdHce0/Mvajkxyj2Eb6C4jp
+  mZuvcPhU4MaEqo9yAlSnRztwqmmDwvO60LPEoS7WRUB3oEqDGGR8wnMARbCwjlVn
+  kMHd5BqgOnFDhqxxGnQzq+dv9C4RKGZtpIFl+jVpx9m5DszF9ZYEDtNMwxAoCIia
+  mZE0DkxTwI5lbwe9Pc3HZSK/wEF7Df1HC/U7AQDoVpk/g33Tllvsd52UYUZM1aca
+  3qaPM6orhVLXysaI+Qf+LoRoQgTlQX4IP19Z2t8MIx7VP08SOsrZdNAwIgHO4fhs
+  dOX6okfwpiYOl1bGqnakprit4HarAhtSM0Xd8JPtXImPqzHN07yz6jhCKZBIFWGC
+  kJSzPFar+P/jCmCWArL7DfBelBw0aHiV7HmSqEQJsyKVZBYjgHmXzjLkp3zsFRaR
+  tAj3TnB+nN4uXCchv63bVmYd3Cv55AZyugJb49Kl5PHqHarcle39Gbhg/UPPiduo
+  zIQKqtsKZcLckxZWi5f3XF/BnIY+uKdbOssTY0u8hyCqj904KdUl50GtYEb274EZ
+  a7ZepmcSp6a3aTtQmmHMf1MP/5U7Z6c6fNha4N3Xwwf+O1Zhc0Y11JSEV8G/2gAC
+  rjwYCIQ17w6/KDUe4nflxZpCsTP7+YOwmaXRSBqBoCz5N3ZH9jTp0xu73l6hK5wY
+  LodkfYHRhIMSyRCrW4T7yalUlpcuJy0NhFUnCDALgkjAhLUi4goJ+nsnOIJWC1dp
+  5DhZtClRTWNIHWK1AmIrWAUBuodpcp6K1NouJFenQB/NtwHS71J+ILli9LTxt6jM
+  CvaOAseRjvOs8JxG3pBm2LPOvZDyvQQFvfrTgqOlcMgqVp4mIqTKeEtXa2AQWrCG
+  QK5Ig3ZxfiQuNYIYNRsbag8Xyo8/udvbMDXVOAWQlmQz2B/Ge23rTGQZPMixoA+e
+  JrQuQm9iIEZyaWVzZW5oYWhuIDxiZnJpZXNlbkBzaW1wbGUuZGFsbGFzLnR4LnVz
+  PoiZBBMRCABBAhsDBQkSzAMABQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAFiEE69/b
+  IbAg7o/RUaiN4wEEfeEZiXUFAlvWDvECGQEACgkQ4wEEfeEZiXXLpgEAqPfOR6nD
+  iq8o/5RZ57f8UFNSPBiLTFbi/FTHhn9FV/oA/14uiKfpWhhKib3INfOZweDC0sHX
+  GdULE2Nrbx54Rn/otCxCb2IgRnJpZXNlbmhhaG4gPGJmcmllc2VuQHNpbXBsZXN5
+  c3RlbXMub3JnPoiWBBMRCAA+FiEE69/bIbAg7o/RUaiN4wEEfeEZiXUFAlvWDskC
+  GwMFCRLMAwAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQ4wEEfeEZiXWxkwD8
+  DK9I1UeGW8TIQQ5zzyk9Ue2+0C3RP5R45Dg3cg9W01oA+gIELZMu+15wCOG22dRO
+  NAvZUjNS8TrGIWtGvQNE5IYctC1Cb2IgRnJpZXNlbmhhaG4gPGJmcmllc2VuQGdy
+  YXBoaWNzbWFnaWNrLm9yZz6IlgQTEQgAPhYhBOvf2yGwIO6P0VGojeMBBH3hGYl1
+  BQJb1g7jAhsDBQkSzAMABQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEOMBBH3h
+  GYl1RekA/2UUHeqkrePzLtI10VfprqAgjYYRIb4Ue/Y18hzSHYEyAP4+LBt/y6CS
+  5kq5G7RtM072ujLm4LMRu+KKGmSVQz1u2LQrQm9iIEZyaWVzZW5oYWhuIDxib2Jq
+  ZnJpZXNlbmhhaG5AZ21haWwuY29tPoiWBBMRCAA+FiEE69/bIbAg7o/RUaiN4wEE
+  feEZiXUFAlvWIvsCGwMFCRLMAwAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQ
+  4wEEfeEZiXWYugEAv6hEjxqDR2pZu6/2qrG642OMk0lHVlFjla3F8hpMabIBALNd
+  pWvc+nb/HbZTWT5cebhA8Z/dExYTjB9jUIdNYAbU0dKI0oYBEAABAQAAAAAAAAAA
+  AAAAAP/Y/+AAEEpGSUYAAQEBAEgASAAA/9sAQwAUDg8SDw0UEhASFxUUGB4yIR4c
+  HB49LC4kMklATEtHQEZFUFpzYlBVbVZFRmSIZW13e4GCgU5gjZeMfZZzfoF8/9sA
+  QwEVFxceGh47ISE7fFNGU3x8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8
+  fHx8fHx8fHx8fHx8fHx8fHx8/8AAEQgBBQDEAwEiAAIRAQMRAf/EABoAAAIDAQEA
+  AAAAAAAAAAAAAAABAwQFAgb/xAA1EAABBAAFAgQEBQQDAQEAAAABAAIDEQQSITFB
+  BVETImFxIzKBkRRCUqHBBrHR8CRy4VPx/8QAGQEAAwEBAQAAAAAAAAAAAAAAAAEC
+  AwQF/8QAIBEBAQACAgMAAwEAAAAAAAAAAAECERIhAzFBFDJRcf/aAAwDAQACEQMR
+  AD8A9MmkmmgJoQmDQhCQNCEJgJoQgBChfiWtdlaM55rYKE44NP5SeaKQ0uoConqL
+  QdRp6FdjHMcQMzWj1KNjS4hQiYH8wPsVK0gj0QDTQhACEIQAhCaASaEJGEIQglZN
+  CYVAIQmkAmhNACFHNNHBGXyvDWjkrCxfW5Z3+Dg2lpPNalAk228RiocMLleAeByV
+  hdQ67mOSG+xA3/ZRswMkvmxMpBO4adT7lWoMLDh21FG1oUXJrMGZHJ1DEnWIhg2B
+  8oVhuFxjmgOdG0e5K02hdAJbaTBnfgZq0kafbRP8JiAKDz9Fo0utktjgyM0+HdYF
+  fRXML1YWGygtPcK0Q1wIcL91Tn6bHJrGSw71xacqbg2sPiGTMBa4G+ymXlRJicBJ
+  rY107Fa3TerxYs5H3HJtR2JVysrjpqpICaaQhCEAIQhIwhCEwrppBNBBNJNANRYn
+  ENw8ZcdTsB3K7cQBrovO9Z6sG3HCC52wQNKWOkxvUcaIswaOa2aFo4TDRYSPJENe
+  XHd3uocLF4MWvzu1ee5VtgtZ2t8cdJAuwEmhdtClqAF1SNF0AkZUhd0kgOU6QnSA
+  5dG2RpY8AtPBWH1LAOw5EjLLBs69R7rfASexsjCxwBaRRBTlRZtmdK6zKwtixJL2
+  HQOO4Xo2PbIwOYQWnYheHxMBwGLfEbyEW0ntwtro+Py0x7hlO/v3WkrDLF6BCN0K
+  kBCEIMIQhIK6a5TTI00knGmknhAZfWcb4bPBjdT3D7DuvN4MHEYwvqo4/wBypMXi
+  XYnETSa+c0PZWcHEIcO0VqdSprTGLrNQpmLiIeVdtWbeJ2KVoChYpm6pKMjZABXR
+  GyKQBRQbQUAoBhMhIFdboIkIQgMzrmFM+E8WNtyRa1+ochY+EmEbWk2WO0BPHofV
+  eqdq0grzpwrRPPh3aNJtp7K8WWT1PT5fGwcbr1Aoqysb+nZiYJIX6PYdVtLRjSQm
+  kgBCEICradri07SDu1V6nJ4XT53XRy0FYtZ3XnV0yQDckD90B5iMgkWTZND0C1I9
+  aWTCfi2BY2WzBVWpya4rLRQXbVwx7CaDh90zLGzXMFDVO1WGBZoxsPiZQ4WrsMzX
+  mgUHtMQlei6cQHNHcII8pSNxVrsNSZRFrtppAKkFPMLSKZBCSaROSsrGDLjWkfmF
+  LVKzce23NPY/ZVPaMvSfpALcWTW4ylbqxeln/lHs4X9VtLVhSQhCAEIQgKNp2uLT
+  CRurWT/UcmXAtHd9/YKx1PqLenQskdE6QOdXl4WTNjGdadFC1ro3B1lpB2re0QMv
+  COLpAaJA9F3iJ5nGg6OMcHxAD9la69HHh3RQxU1gZfue5WWMGHZRkKSoCZLP/Miv
+  uHKF7cQbAlbIPR4/ytODpTHfN9lbHRoDu0JbiuNYMMkkcgE7HjsSKXpOm4gkgA7L
+  lvTGZXZSAGiyCd0mxtwoYQCHXr29KSt2qTTXM2ado9FZcaiJWTA/PPm4AWpYdGaI
+  Oilr8V/xGRt/dU39Re3K0aOOps1SeJJaSwDlVHYbO5zpDZIqhsE5EZVHP158DnBu
+  R3uaXcX9SsLR4jCL5GyryYPENPwGRtHfIFxLh+pvykyE0KALQaH2VaiO2tF1yB58
+  pDh2vVaWHxcOIAyPAJ4O68m6PFRn4kMT/eMD+ynwxLZB5fCdwWmwfoUuJ8q9Udln
+  Yt2Ug+qs4fEGQZJBlkq/Rw7hVMfpde6J7F9LfSac8G9iVsLB6K4+O5vG63lowoQh
+  CAEIQgM5MJJhSpFisNHi8O6GUeV3bceqzWfisFQxERxAhGWN8ernt9u4/dXsTjRC
+  7K0Znc9gqb8cXzxOc0AMu6PCNq43W2L1iZmM6lD4Ts8bwKKslrImhzjoOUY0RzdV
+  bNGwCm+Z1VZTdEZt9ApyqsIrnqDi7LG0l36Rx7lVD1jEFxADQB3ctiHBxsbo0A9w
+  qj+hwPmLjI5oOtCkTSrMvjnD46RznNf8KRhymzmaT7qeWd0rSx7HAkfk1P0XYwMU
+  EJjiILXGzm3KpY1skdRRE+cZRR2vc/b+6OtjvisdJwgxbc80kjh2ugtg9Oa2KoJZ
+  YqN+V3P1UfTomxQNa3QAK8HdlO6vj0ycOZfFlbNL4hj2NV/pUj5mMbZIACrYvxIc
+  c4Rg1I5poC7Gx/hdy4enEtIIGluKdTHbMW0nRjj76KwMYx7ySyu+TWvosHHskjlH
+  ntuW96srnARfiMZGGZ2fMXAPuv8AdE5iVy1XpS1k7aaQ4Kv+CLHG2HKPTZRQmWHE
+  hshzEEVIBv6OW9IGyREtcNtdUr0VZ2KbL4DPw+UTAjIXbLOkxM4kP4uB7DYAIAyg
+  HueVrv8AmjB4dazuqPANO0BBBVQrFzpDSzFubd0KK3Fh9Ft09uGoYL96C3FcZX2a
+  EIQQQhCAzkwkmFKnmcU/EPnd4ZoXa4OctIkAtwG3ZX8RHlne0dyFWxDalib62foF
+  M9ujP1NOWktpsu36uPr2V6JrXNGWj7KvCddiphDC45sgB7jT+yVTFlsY5T8JlWVA
+  2Ng2dKB2zlN0UVate/8A7OJSaK+JkYDkiGd/YbD3PCqMjLpc7zmLef8AHorkoOXK
+  0BjewUIAAIQFvDSHQBXm7WVRwjL1V9tbIUrYuMuyyNoOadCos4l/LRG4PBV1zbBB
+  5UEmHsB2ocNnD+U0a7Rsa2sr42lvqF3Fh4Y3EsjDeNBS5D5GkAta760rDJHf/B59
+  i0/ygWQNaL2UwBaw1suAZSfLAR/2cAuvDlefiva1v6Wc+5KNFa5Z8WW26sZoD3Kp
+  45oc9xrYi/RabGhgDQKA4VHGNqU38sjKKcqMp0v9MhbDDmLgZH6nXYdlfCzGECJl
+  18o3VrDSX5bscaqpl8Tl4+trKEIVMjQhCAzkwuUwpUz8c0NxLT31WdibGJbppS1e
+  os0jkH5TSysa4eNC6xRtR9bzvBZw40Vto0VSA6BWwdLCRwz2pRuPCkvRRlJcQTaN
+  Vbeh6qxLqCoZAI47JArkpwq0sOwBgpTtjJdfCp9PxQljFEEjkG1fbJqnobJzK1Qw
+  A6cIkkFgWBabRWyVDh+HadQFy1mUiiVYCKHZAJgJ5K7DAEAUmChNjl26p4s3LG29
+  CDatuPmIWfijnxbQD8oTib30vvY2SLVunCjwTGxYtwYTltSQOaWZfRPBsJlc/gFE
+  9rvWNX0JJrVyBCaEBmphJNSpzMzxInN53C851T4Yjygb3/lemWB1pmWUNrRwJCWu
+  1S9acYV9sDuFfD7CxMDMdWna91psfbjSmtcatNdaHBcRFSOdQUtIrzGmk9lR6phn
+  Y3Dhsb6G/ur0725aOqpRNklcRH5GcknhOSllZ9VukwzYAeeqcbIBsLdje5xvhcQw
+  HIM2ulFdyOc1lMGwGytH+MjDx4t/Vn4rEkhpcWMHGXhejjdY0WdHIS5zHjQa3Wy0
+  ImgN02U1eNmkoXYXC6UmLpLNok86KJ7twE00y7c9lVgp0ksjt/l912ZBIQBzofRT
+  QYcZibHsq+Il7EIy2eFoQMyRAcnUqsxpfLVeUH7q4njC82Xw00k1bAIQhAZqaSal
+  RrI64wlraGpBC11Q6nHnaK7FEDzTSYbaBbgaF+ivYeexRNqji7YGyaeTUqOCcNkA
+  HJ0SsaS6egErWNtxpVZcc296UTneNJlGrWts+/CrFzTiBoSAaHb3SmKrn/E7ZjPI
+  QbAHqruGDYcwNOOVun3A/hZ2Ghe3ERmVvlPblabXND3Ea63/AIVRnbatRSF0Ugde
+  hoouwATR0B9FA2VrXObqc2ug5Xcbmud5tB8pKD7jp7PzaZxYschd4fEtbe9Hj91F
+  LMDbjoAwnTdUnYjMyMtNOePlHFIolsb7XtdsV2CsSLEB5zG8xOlaa+qvYfFEnI/R
+  1WPVZ2NZktvIrVUZJhZYDr3UuImHgmjqs2I+JJbtDv8A+pyJtWMI7MTffRbDQAL5
+  WbhoqnAO1rVijsAnbgKtI3Jd1JGzKL5K7QhX6ZW7uzCaSaAEIQgM0JpIUKNQ4ttx
+  X2UyT252FvdM3kuoRfDu9CdlR8PLK0uFNvfst7FQZnlrhq02FRmhysLq0bdE+qDP
+  DuAwbnEAEmw30vS/suIp4g03Ys73qVSfO4wsDXZW0AQe4U7Mr21ltu59UWiTa67F
+  RuBLi0nvey6in8RtMzEDaguIRFuYmj6LSiEeW7LfdTttJFOOZ7Xi2kV6Ky97nNrK
+  6uNFbbC0nyuFrsQkncE+6e1ajOLixpu6OtEKIRxHKYyAW3QWx4RHDQqs+Fhf53AE
+  j9OiNpsjL8Tw3hwNg7g8lW2yuzMNgDVwJ40Uc+AY0Zm2Ne9rqDD5mPr5kts6c2Iz
+  OaRdEbKaOIuexxGlVf7qsxpMoBAFG233W3HBUbB20KqQrRGLksC/MFpMFNAKqYaE
+  tdbtVcTZ0JpJpkaaSEgaEIQGahJNSo0wkmg1PHRA+YDcarzmNmtkrR5gR27L1szP
+  EiI5XnJoWsxZz2WuFaDdUGPgsE7FSuLh5Wmr4Wo+BkDQ2MXQ0FLRw8LI4sopjBtl
+  1v8A9XMsVyBxbduAq1NVjYrQQuOYvdmIFG9gVaw7GeEC46uK5ja510QBZvTSu391
+  wHRweGXmg11C+AnBdrD/AJ5Xg5ctAWp35hqDu0G/2KqR4qN7HuLSA55FuG9jT/fZ
+  TjENcMgIOawD/CeoXKos73ucMxB0+65aHaG/RdNzid7OTlN/79FbDAS5vqVOlckD
+  2ktoV6qCAmKUHSgav0WjHCxwNGtPsoMVhHPBLBrzXdKQWqFEvAPzBxP0tbuCOaNz
+  SSaNi1jx+WVjng+ITRJ5W5hIso13O6uIqxEKGqkXIFBNNBppJpA0IQgGhCEBmJpI
+  UqNNJCDdcLHxI82bkHstdYeLxELZ/Bc8ZydAnCaOGa3L5tXFtk9go3NzyNNO9PQJ
+  wvDi4N9zamyB7zuTaoRAGBpNN04pRmIOcKs9waVp7fLTSA0bmlAb8IAD5jeqixrL
+  tCYBK5zKto3ICkiw4I20F/dON1AtbppqfqVLC7LGe5KQcxsBc11eZhrbcKWhmIH0
+  +6cDT+IBrQ3f0XToyXuGxHyn90y6d4YuzBrxRHNbqyYhR9eFxDTmBx0J0KlJNU5X
+  IzyrMlhBkAduTuB6/wB1oYY39lBLXzVvpqpMGbkefRK3s9dbW00kIQaaSaAaEIQD
+  QhCAy01nP6o0HyRkjuTSgl6nK8VG0R+u5UbjaeLKtaSVkTc0jg0dys6Tq4LqhZYH
+  LlmyOe+3PcXHuSowKAStbY+GfV6TqM8gIz0D2FKiyFrfinWV+uZMLsaxt9giU88Z
+  J0u4Kf5g7QVS1mWBodatedIc0B7SR7LTwWLa/IzMb222WkrmyxXg24DfJJUZFAkg
+  VltqkJDRpyVG7zUAf97J6TtXaKlDBp5QSiEF2dw+UaV90nSZJiSNtR9f/wAUkJIj
+  JA1ddUlo9rTfJzsAfupqtmY6ktUbMpaTuC0BSBwzDsdE9Fak0aRtqkX2wncqOaQE
+  V2XG+vdO3QmOyldXl4CgzOaSWuLT3C7fqVGNzysbW8nWleXFdQwzi9jzOz9JAsf5
+  VrB9Y8ePMWA8GtCEZbVANEeJmrSyL96RuqmMy6sehgxMc/yHXsd1MvOxyEPsGloY
+  HqQcfCnPmGzj/KqZIz8NncaaEgbTVOc0IQgPE7hACGbJhYvSIjRcOFKalwQg0QUk
+  Y+Dr7LghOF/mew+4REeT0sxAFhB4UbmOifnZpym05JG9ireXM2+FW2FiGLGTM3dp
+  6q14zZAasGvuoBC0k1SnjhA11VyouJkGQEHbddMaWM0qq0U0cYI7Fd+BYT2nTiKS
+  mhrj7qbOKAC48Dm1IG0jkOLkMvfZdONBdcKJ5oKLWkmnPdyTBaZ0aiMeW0jDnBjS
+  47ALLa4yFz/1G1Zx8t1C3d2/sq7RQUtvHPqRpoEqOJxyl252Se7yn9l3EKbXYIaL
+  cONlhAyutvYq5H1iO8srHA9wLCyeKKVJy2M8vHjl7egb1DCuF+KB7hCwLpCrkj8f
+  FRYu0IUtjCCEISNG4KJxyzMI5tpQhETn+q05vw77K9hzcYtCE4wFZXabFStOtUhC
+  ok7ApWuIQhNNMnZG6EJAHZQu+coQkopRTVy55jgLhqUIQGVGS8ukcbc4qW9EIUuq
+  enG8jRxuu2H4lIQg3ZCChCCcOOqEITD/2YiWBBMRCAA+FiEE69/bIbAg7o/RUaiN
+  4wEEfeEZiXUFAlvWLooCGwMFCRLMAwAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AA
+  CgkQ4wEEfeEZiXUcvgD8Dd3c9PMFe8l36YcKLs1ubSEF30mu3b/s8oG7CgeBdOcA
+  /062qY6F+Hy0GK/kc5WN9pr5rvFcdS/Tz8wDq5d1shjYuQINBFvWDmMQCAC0JHbI
+  pX4rz6HzifXiVvPKKgOFdxRs4xZkOA8/sPcK3rB34waMuOgBme6jL7iJNfbC60eo
+  TIMv75i0C1MWxQReoR+UA+mQctuvpcrkzzceEYH2JWFf0NZZtT5wYoJ8JNfW1ngi
+  r/QhPRWC4fNfJQiJhWdf4sdP2BnW0hi5IIPnmkHQ44G0xBQpOqPrv7A8F97ROGYD
+  oS3LNmKmfLV9nKRBH+NmQ+zdaToNcQTOlSbMVZ/hag1F9LSmAUFcqXr9bKKk/qKj
+  RBkEweAsYppTgn0N7StNtcT9aR5zZkqJ9FBgls6LSr2H6QPiaGZeixZrywjxz2ku
+  xz5C1D92ZVAe0qhTAAMFCACyCRhU7YmWUdC3D5rMna97JhFu2fQygn5FQEuHOFao
+  abaUicXCxlW3IKQqBjOcpN6rZl+crapYVKGCGM4nMvmxEqqRBYAHLw8vc3Nfys/O
+  AXWxI6kiZlVAIX/Q0IZveFejRCoEo6bBabGSfDHWH7QqZXEo2TNWiGJ6oLOyIISl
+  x1MM4e9jRSufukrtTfsU8HDoWKycRSnaxtYOz4FAAofrCeQ6/Nf3Vf887NXXD1I6
+  xMp9vyuYqx68SrqtmX9FauagsHzmLylYI42JciTCvje09D9kAHFaidkR58DVgzPW
+  xFQCGBDO8Rrk1lVjO2gX2bVzKW1J+67ENM1YdWjiVzt9iH4EGBEIACYWIQTr39sh
+  sCDuj9FRqI3jAQR94RmJdQUCW9YOYwIbDAUJEswDAAAKCRDjAQR94RmJdRzqAQCZ
+  KJFm7j0Zug7NN+IPTqnIrPCioJkt1iGbec6SbBHh5AEAy5JEbI2ugQEePaIMGWVV
+  akWaTz0WKIOiD9Lm2ylI9J0=
+  =UAq2
+  -----END PGP PUBLIC KEY BLOCK-----
+
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 3b8afe5..c6fc1fe 100644 (file)
@@ -72,6 +72,7 @@ ways:</p>
 <li>John Lightsey</li>
 <li>David Chan</li>
 <li>Federico Larumbe</li>
+<li>Petr Gajdos</li>
 </ul>
 </blockquote>
 </div>
@@ -135,7 +136,7 @@ reduction.</dd>
 </dl>
 <hr class="docutils" />
 <div class="line-block">
-<div class="line">Copyright © GraphicsMagick Group 2002 - 2017</div>
+<div class="line">Copyright © GraphicsMagick Group 2002 - 2018</div>
 </div>
 <p>This program is covered by multiple licenses, which are described in
 Copyright.txt. You should have received a copy of Copyright.txt with this
index d2d8d7b..28660bd 100644 (file)
@@ -41,6 +41,8 @@ Security Analysis/Reports
 
   * Federico Larumbe
 
+  * Petr Gajdos
+
 Static Code Analysis
 --------------------
 
@@ -119,9 +121,8 @@ Thomas R Crimmins
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-| Copyright |copy| GraphicsMagick Group 2002 - 2017
+| Copyright |copy| GraphicsMagick Group 2002 - 2018
 
 This program is covered by multiple licenses, which are described in
 Copyright.txt. You should have received a copy of Copyright.txt with this
 package; otherwise see http://www.graphicsmagick.org/Copyright.html.
-
index 60fd658..72b0982 100644 (file)
@@ -177,7 +177,7 @@ a rotated version of them in TIFF format:</p>
 <p><a class="reference external" href="montage.html">Montage</a> creates a composite by combining several separate images. The
 images are tiled on a composite image with the name of the image and its
 properties optionally appearing just below the individual tile.</p>
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </div>
 </body>
index 1a57851..e4bc364 100644 (file)
@@ -170,5 +170,5 @@ properties optionally appearing just below the individual tile.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
+Copyright |copy| GraphicsMagick Group 2002 - 2018
 
index 6d64838..c7fa26d 100644 (file)
@@ -97,7 +97,7 @@ commands are as follows:</p>
 </tbody>
 </table>
 <hr class="docutils" />
-<p>Copyright © GraphicsMagick Group 2002 - 2017</p>
+<p>Copyright © GraphicsMagick Group 2002 - 2018</p>
 </div>
 </body>
 </html>
index fe208c0..7e01599 100644 (file)
@@ -66,5 +66,4 @@ version_         Report GraphicsMagick version, features, and build options.
 
 .. |copy|   unicode:: U+000A9 .. COPYRIGHT SIGN
 
-Copyright |copy| GraphicsMagick Group 2002 - 2017
-
+Copyright |copy| GraphicsMagick Group 2002 - 2018
index 2f92ee6..3a80d5e 100644 (file)
@@ -108,35 +108,35 @@ color="#00B04F"><font size="+1">
 <tr><td width="3%"><br></td><td>
 <p>To display the version information:
 <pre>
-  % gm -version
-  GraphicsMagick 1.3.19 2013-12-31 Q16 http://www.GraphicsMagick.org/
-  Copyright (C) 2002-2013 GraphicsMagick Group.
+  GraphicsMagick 1.3.27a 2017-12-11 Q16 http://www.GraphicsMagick.org/
+  Copyright (C) 2002-2017 GraphicsMagick Group.
   Additional copyrights and licenses apply to this software.
   See http://www.GraphicsMagick.org/www/Copyright.html for details.
   Feature Support:
-    Thread Safe              yes
+    Native Thread Safe       yes
     Large Files (&gt; 32 bit)   yes
-    Large Memory (&gt; 32 bit)  no
+    Large Memory (&gt; 32 bit)  yes
     BZIP                     yes
     DPS                      no
     FlashPix                 no
     FreeType                 yes
     Ghostscript (Library)    no
-    JBIG                     no
+    JBIG                     yes
     JPEG-2000                yes
     JPEG                     yes
     Little CMS               yes
     Loadable Modules         no
-    OpenMP                   yes (201107)
+    OpenMP                   yes (201307)
     PNG                      yes
     TIFF                     yes
     TRIO                     no
-    UMEM                     yes
-    WMF                      no
+    UMEM                     no
+    WebP                     yes
+    WMF                      yes
     X11                      yes
     XML                      yes
     ZLIB                     yes
-  Host type: i386-pc-solaris2.11
+  Host type: x86_64-unknown-linux-gnu
   Configured using the command:
     ./configure  ...
   Final Build Parameters:
index 0296feb..69ea7ba 100644 (file)
 <div class="contents topic" id="contents">
 <p class="topic-title first">Contents</p>
 <ul class="simple">
-<li><a class="reference internal" href="#clonemagickwand" id="id463">CloneMagickWand</a></li>
-<li><a class="reference internal" href="#destroymagickwand" id="id464">DestroyMagickWand</a></li>
-<li><a class="reference internal" href="#magickadaptivethresholdimage" id="id465">MagickAdaptiveThresholdImage</a></li>
-<li><a class="reference internal" href="#magickaddimage" id="id466">MagickAddImage</a></li>
-<li><a class="reference internal" href="#magickaddnoiseimage" id="id467">MagickAddNoiseImage</a></li>
-<li><a class="reference internal" href="#magickaffinetransformimage" id="id468">MagickAffineTransformImage</a></li>
-<li><a class="reference internal" href="#magickannotateimage" id="id469">MagickAnnotateImage</a></li>
-<li><a class="reference internal" href="#magickanimateimages" id="id470">MagickAnimateImages</a></li>
-<li><a class="reference internal" href="#magickappendimages" id="id471">MagickAppendImages</a></li>
-<li><a class="reference internal" href="#magickautoorientimage" id="id472">MagickAutoOrientImage</a></li>
-<li><a class="reference internal" href="#magickaverageimages" id="id473">MagickAverageImages</a></li>
-<li><a class="reference internal" href="#magickblackthresholdimage" id="id474">MagickBlackThresholdImage</a></li>
-<li><a class="reference internal" href="#magickblurimage" id="id475">MagickBlurImage</a></li>
-<li><a class="reference internal" href="#magickborderimage" id="id476">MagickBorderImage</a></li>
-<li><a class="reference internal" href="#magickcdlimage" id="id477">MagickCdlImage</a></li>
-<li><a class="reference internal" href="#magickcharcoalimage" id="id478">MagickCharcoalImage</a></li>
-<li><a class="reference internal" href="#magickchopimage" id="id479">MagickChopImage</a></li>
-<li><a class="reference internal" href="#magickclearexception" id="id480">MagickClearException</a></li>
-<li><a class="reference internal" href="#magickclipimage" id="id481">MagickClipImage</a></li>
-<li><a class="reference internal" href="#magickclippathimage" id="id482">MagickClipPathImage</a></li>
-<li><a class="reference internal" href="#magickcoalesceimages" id="id483">MagickCoalesceImages</a></li>
-<li><a class="reference internal" href="#magickcolorfloodfillimage" id="id484">MagickColorFloodfillImage</a></li>
-<li><a class="reference internal" href="#magickcolorizeimage" id="id485">MagickColorizeImage</a></li>
-<li><a class="reference internal" href="#magickcommentimage" id="id486">MagickCommentImage</a></li>
-<li><a class="reference internal" href="#magickcompareimagechannels" id="id487">MagickCompareImageChannels</a></li>
-<li><a class="reference internal" href="#magickcompareimages" id="id488">MagickCompareImages</a></li>
-<li><a class="reference internal" href="#magickcompositeimage" id="id489">MagickCompositeImage</a></li>
-<li><a class="reference internal" href="#magickcontrastimage" id="id490">MagickContrastImage</a></li>
-<li><a class="reference internal" href="#magickconvolveimage" id="id491">MagickConvolveImage</a></li>
-<li><a class="reference internal" href="#magickcropimage" id="id492">MagickCropImage</a></li>
-<li><a class="reference internal" href="#magickcyclecolormapimage" id="id493">MagickCycleColormapImage</a></li>
-<li><a class="reference internal" href="#magickdeconstructimages" id="id494">MagickDeconstructImages</a></li>
-<li><a class="reference internal" href="#magickdescribeimage" id="id495">MagickDescribeImage</a></li>
-<li><a class="reference internal" href="#magickdespeckleimage" id="id496">MagickDespeckleImage</a></li>
-<li><a class="reference internal" href="#magickdisplayimage" id="id497">MagickDisplayImage</a></li>
-<li><a class="reference internal" href="#magickdisplayimages" id="id498">MagickDisplayImages</a></li>
-<li><a class="reference internal" href="#magickdrawimage" id="id499">MagickDrawImage</a></li>
-<li><a class="reference internal" href="#magickedgeimage" id="id500">MagickEdgeImage</a></li>
-<li><a class="reference internal" href="#magickembossimage" id="id501">MagickEmbossImage</a></li>
-<li><a class="reference internal" href="#magickenhanceimage" id="id502">MagickEnhanceImage</a></li>
-<li><a class="reference internal" href="#magickequalizeimage" id="id503">MagickEqualizeImage</a></li>
-<li><a class="reference internal" href="#magickextentimage" id="id504">MagickExtentImage</a></li>
-<li><a class="reference internal" href="#magickflattenimages" id="id505">MagickFlattenImages</a></li>
-<li><a class="reference internal" href="#magickflipimage" id="id506">MagickFlipImage</a></li>
-<li><a class="reference internal" href="#magickflopimage" id="id507">MagickFlopImage</a></li>
-<li><a class="reference internal" href="#magickframeimage" id="id508">MagickFrameImage</a></li>
-<li><a class="reference internal" href="#magickfximage" id="id509">MagickFxImage</a></li>
-<li><a class="reference internal" href="#magickfximagechannel" id="id510">MagickFxImageChannel</a></li>
-<li><a class="reference internal" href="#magickgammaimage" id="id511">MagickGammaImage</a></li>
-<li><a class="reference internal" href="#magickgammaimagechannel" id="id512">MagickGammaImageChannel</a></li>
-<li><a class="reference internal" href="#magickgetconfigureinfo" id="id513">MagickGetConfigureInfo</a></li>
-<li><a class="reference internal" href="#magickgetcopyright" id="id514">MagickGetCopyright</a></li>
-<li><a class="reference internal" href="#magickgetexception" id="id515">MagickGetException</a></li>
-<li><a class="reference internal" href="#magickgetfilename" id="id516">MagickGetFilename</a></li>
-<li><a class="reference internal" href="#magickgethomeurl" id="id517">MagickGetHomeURL</a></li>
-<li><a class="reference internal" href="#magickgetimage" id="id518">MagickGetImage</a></li>
-<li><a class="reference internal" href="#magickgetimageattribute" id="id519">MagickGetImageAttribute</a></li>
-<li><a class="reference internal" href="#magickgetimagebackgroundcolor" id="id520">MagickGetImageBackgroundColor</a></li>
-<li><a class="reference internal" href="#magickgetimageblueprimary" id="id521">MagickGetImageBluePrimary</a></li>
-<li><a class="reference internal" href="#magickgetimagebordercolor" id="id522">MagickGetImageBorderColor</a></li>
-<li><a class="reference internal" href="#magickgetimageboundingbox" id="id523">MagickGetImageBoundingBox</a></li>
-<li><a class="reference internal" href="#magickgetimagechanneldepth" id="id524">MagickGetImageChannelDepth</a></li>
-<li><a class="reference internal" href="#magickgetimagechannelextrema" id="id525">MagickGetImageChannelExtrema</a></li>
-<li><a class="reference internal" href="#magickgetimagechannelmean" id="id526">MagickGetImageChannelMean</a></li>
-<li><a class="reference internal" href="#magickgetimagecolormapcolor" id="id527">MagickGetImageColormapColor</a></li>
-<li><a class="reference internal" href="#magickgetimagecolors" id="id528">MagickGetImageColors</a></li>
-<li><a class="reference internal" href="#magickgetimagecolorspace" id="id529">MagickGetImageColorspace</a></li>
-<li><a class="reference internal" href="#magickgetimagecompose" id="id530">MagickGetImageCompose</a></li>
-<li><a class="reference internal" href="#magickgetimagecompression" id="id531">MagickGetImageCompression</a></li>
-<li><a class="reference internal" href="#magickgetimagedelay" id="id532">MagickGetImageDelay</a></li>
-<li><a class="reference internal" href="#magickgetimagedepth" id="id533">MagickGetImageDepth</a></li>
-<li><a class="reference internal" href="#magickgetimageextrema" id="id534">MagickGetImageExtrema</a></li>
-<li><a class="reference internal" href="#magickgetimagedispose" id="id535">MagickGetImageDispose</a></li>
-<li><a class="reference internal" href="#magickgetimagefilename" id="id536">MagickGetImageFilename</a></li>
-<li><a class="reference internal" href="#magickgetimageformat" id="id537">MagickGetImageFormat</a></li>
-<li><a class="reference internal" href="#magickgetimagefuzz" id="id538">MagickGetImageFuzz</a></li>
-<li><a class="reference internal" href="#magickgetimagegamma" id="id539">MagickGetImageGamma</a></li>
-<li><a class="reference internal" href="#magickgetimagegravity" id="id540">MagickGetImageGravity</a></li>
-<li><a class="reference internal" href="#magickgetimagegreenprimary" id="id541">MagickGetImageGreenPrimary</a></li>
-<li><a class="reference internal" href="#magickgetimageheight" id="id542">MagickGetImageHeight</a></li>
-<li><a class="reference internal" href="#magickgetimagehistogram" id="id543">MagickGetImageHistogram</a></li>
-<li><a class="reference internal" href="#magickgetimageindex" id="id544">MagickGetImageIndex</a></li>
-<li><a class="reference internal" href="#magickgetimageinterlacescheme" id="id545">MagickGetImageInterlaceScheme</a></li>
-<li><a class="reference internal" href="#magickgetimageiterations" id="id546">MagickGetImageIterations</a></li>
-<li><a class="reference internal" href="#magickgetimagemattecolor" id="id547">MagickGetImageMatteColor</a></li>
-<li><a class="reference internal" href="#magickgetimageorientation" id="id548">MagickGetImageOrientation</a></li>
-<li><a class="reference internal" href="#magickgetimagepage" id="id549">MagickGetImagePage</a></li>
-<li><a class="reference internal" href="#magickgetimagepixels" id="id550">MagickGetImagePixels</a></li>
-<li><a class="reference internal" href="#magickgetimageprofile" id="id551">MagickGetImageProfile</a></li>
-<li><a class="reference internal" href="#magickgetimageredprimary" id="id552">MagickGetImageRedPrimary</a></li>
-<li><a class="reference internal" href="#magickgetimagerenderingintent" id="id553">MagickGetImageRenderingIntent</a></li>
-<li><a class="reference internal" href="#magickgetimageresolution" id="id554">MagickGetImageResolution</a></li>
-<li><a class="reference internal" href="#magickgetimagescene" id="id555">MagickGetImageScene</a></li>
-<li><a class="reference internal" href="#magickgetimagesignature" id="id556">MagickGetImageSignature</a></li>
-<li><a class="reference internal" href="#magickgetimagesize" id="id557">MagickGetImageSize</a></li>
-<li><a class="reference internal" href="#magickgetimagetype" id="id558">MagickGetImageType</a></li>
-<li><a class="reference internal" href="#magickgetimagesavedtype" id="id559">MagickGetImageSavedType</a></li>
-<li><a class="reference internal" href="#magickgetimageunits" id="id560">MagickGetImageUnits</a></li>
-<li><a class="reference internal" href="#magickgetimagevirtualpixelmethod" id="id561">MagickGetImageVirtualPixelMethod</a></li>
-<li><a class="reference internal" href="#magickgetimagewhitepoint" id="id562">MagickGetImageWhitePoint</a></li>
-<li><a class="reference internal" href="#magickgetimagewidth" id="id563">MagickGetImageWidth</a></li>
-<li><a class="reference internal" href="#magickgetnumberimages" id="id564">MagickGetNumberImages</a></li>
-<li><a class="reference internal" href="#magickgetpackagename" id="id565">MagickGetPackageName</a></li>
-<li><a class="reference internal" href="#magickgetquantumdepth" id="id566">MagickGetQuantumDepth</a></li>
-<li><a class="reference internal" href="#magickgetreleasedate" id="id567">MagickGetReleaseDate</a></li>
-<li><a class="reference internal" href="#magickgetresourcelimit" id="id568">MagickGetResourceLimit</a></li>
-<li><a class="reference internal" href="#magickgetsamplingfactors" id="id569">MagickGetSamplingFactors</a></li>
-<li><a class="reference internal" href="#magickgetsize" id="id570">MagickGetSize</a></li>
-<li><a class="reference internal" href="#magickgetversion" id="id571">MagickGetVersion</a></li>
-<li><a class="reference internal" href="#magickhaldclutimage" id="id572">MagickHaldClutImage</a></li>
-<li><a class="reference internal" href="#magickhasnextimage" id="id573">MagickHasNextImage</a></li>
-<li><a class="reference internal" href="#magickhaspreviousimage" id="id574">MagickHasPreviousImage</a></li>
-<li><a class="reference internal" href="#magickimplodeimage" id="id575">MagickImplodeImage</a></li>
-<li><a class="reference internal" href="#magicklabelimage" id="id576">MagickLabelImage</a></li>
-<li><a class="reference internal" href="#magicklevelimage" id="id577">MagickLevelImage</a></li>
-<li><a class="reference internal" href="#magicklevelimagechannel" id="id578">MagickLevelImageChannel</a></li>
-<li><a class="reference internal" href="#magickmagnifyimage" id="id579">MagickMagnifyImage</a></li>
-<li><a class="reference internal" href="#magickmapimage" id="id580">MagickMapImage</a></li>
-<li><a class="reference internal" href="#magickmattefloodfillimage" id="id581">MagickMatteFloodfillImage</a></li>
-<li><a class="reference internal" href="#magickmedianfilterimage" id="id582">MagickMedianFilterImage</a></li>
-<li><a class="reference internal" href="#magickminifyimage" id="id583">MagickMinifyImage</a></li>
-<li><a class="reference internal" href="#magickmodulateimage" id="id584">MagickModulateImage</a></li>
-<li><a class="reference internal" href="#magickmontageimage" id="id585">MagickMontageImage</a></li>
-<li><a class="reference internal" href="#magickmorphimages" id="id586">MagickMorphImages</a></li>
-<li><a class="reference internal" href="#magickmosaicimages" id="id587">MagickMosaicImages</a></li>
-<li><a class="reference internal" href="#magickmotionblurimage" id="id588">MagickMotionBlurImage</a></li>
-<li><a class="reference internal" href="#magicknegateimage" id="id589">MagickNegateImage</a></li>
-<li><a class="reference internal" href="#magicknegateimagechannel" id="id590">MagickNegateImageChannel</a></li>
-<li><a class="reference internal" href="#magicknextimage" id="id591">MagickNextImage</a></li>
-<li><a class="reference internal" href="#magicknormalizeimage" id="id592">MagickNormalizeImage</a></li>
-<li><a class="reference internal" href="#magickoilpaintimage" id="id593">MagickOilPaintImage</a></li>
-<li><a class="reference internal" href="#magickopaqueimage" id="id594">MagickOpaqueImage</a></li>
-<li><a class="reference internal" href="#magickpingimage" id="id595">MagickPingImage</a></li>
-<li><a class="reference internal" href="#magickpreviewimages" id="id596">MagickPreviewImages</a></li>
-<li><a class="reference internal" href="#magickpreviousimage" id="id597">MagickPreviousImage</a></li>
-<li><a class="reference internal" href="#magickprofileimage" id="id598">MagickProfileImage</a></li>
-<li><a class="reference internal" href="#magickquantizeimage" id="id599">MagickQuantizeImage</a></li>
-<li><a class="reference internal" href="#magickquantizeimages" id="id600">MagickQuantizeImages</a></li>
-<li><a class="reference internal" href="#magickqueryfontmetrics" id="id601">MagickQueryFontMetrics</a></li>
-<li><a class="reference internal" href="#magickqueryfonts" id="id602">MagickQueryFonts</a></li>
-<li><a class="reference internal" href="#magickqueryformats" id="id603">MagickQueryFormats</a></li>
-<li><a class="reference internal" href="#magickradialblurimage" id="id604">MagickRadialBlurImage</a></li>
-<li><a class="reference internal" href="#magickraiseimage" id="id605">MagickRaiseImage</a></li>
-<li><a class="reference internal" href="#magickreadimage" id="id606">MagickReadImage</a></li>
-<li><a class="reference internal" href="#magickreadimageblob" id="id607">MagickReadImageBlob</a></li>
-<li><a class="reference internal" href="#magickreadimagefile" id="id608">MagickReadImageFile</a></li>
-<li><a class="reference internal" href="#magickreducenoiseimage" id="id609">MagickReduceNoiseImage</a></li>
-<li><a class="reference internal" href="#magickrelinquishmemory" id="id610">MagickRelinquishMemory</a></li>
-<li><a class="reference internal" href="#magickremoveimage" id="id611">MagickRemoveImage</a></li>
-<li><a class="reference internal" href="#magickremoveimageoption" id="id612">MagickRemoveImageOption</a></li>
-<li><a class="reference internal" href="#magickremoveimageprofile" id="id613">MagickRemoveImageProfile</a></li>
-<li><a class="reference internal" href="#magickresetiterator" id="id614">MagickResetIterator</a></li>
-<li><a class="reference internal" href="#magickresampleimage" id="id615">MagickResampleImage</a></li>
-<li><a class="reference internal" href="#magickresizeimage" id="id616">MagickResizeImage</a></li>
-<li><a class="reference internal" href="#magickrollimage" id="id617">MagickRollImage</a></li>
-<li><a class="reference internal" href="#magickrotateimage" id="id618">MagickRotateImage</a></li>
-<li><a class="reference internal" href="#magicksampleimage" id="id619">MagickSampleImage</a></li>
-<li><a class="reference internal" href="#magickscaleimage" id="id620">MagickScaleImage</a></li>
-<li><a class="reference internal" href="#magickseparateimagechannel" id="id621">MagickSeparateImageChannel</a></li>
-<li><a class="reference internal" href="#magicksetcompressionquality" id="id622">MagickSetCompressionQuality</a></li>
-<li><a class="reference internal" href="#magicksetdepth" id="id623">MagickSetDepth</a></li>
-<li><a class="reference internal" href="#magicksetfilename" id="id624">MagickSetFilename</a></li>
-<li><a class="reference internal" href="#magicksetformat" id="id625">MagickSetFormat</a></li>
-<li><a class="reference internal" href="#magicksetimage" id="id626">MagickSetImage</a></li>
-<li><a class="reference internal" href="#magicksetimageattribute" id="id627">MagickSetImageAttribute</a></li>
-<li><a class="reference internal" href="#magicksetimagebackgroundcolor" id="id628">MagickSetImageBackgroundColor</a></li>
-<li><a class="reference internal" href="#magicksetimageblueprimary" id="id629">MagickSetImageBluePrimary</a></li>
-<li><a class="reference internal" href="#magicksetimagebordercolor" id="id630">MagickSetImageBorderColor</a></li>
-<li><a class="reference internal" href="#magicksetimagecolormapcolor" id="id631">MagickSetImageColormapColor</a></li>
-<li><a class="reference internal" href="#magicksetimagecolorspace" id="id632">MagickSetImageColorspace</a></li>
-<li><a class="reference internal" href="#magicksetimagecompose" id="id633">MagickSetImageCompose</a></li>
-<li><a class="reference internal" href="#magicksetimagecompression" id="id634">MagickSetImageCompression</a></li>
-<li><a class="reference internal" href="#magicksetimagedelay" id="id635">MagickSetImageDelay</a></li>
-<li><a class="reference internal" href="#magicksetimagechanneldepth" id="id636">MagickSetImageChannelDepth</a></li>
-<li><a class="reference internal" href="#magicksetimagedepth" id="id637">MagickSetImageDepth</a></li>
-<li><a class="reference internal" href="#magicksetimagedispose" id="id638">MagickSetImageDispose</a></li>
-<li><a class="reference internal" href="#magicksetimagefilename" id="id639">MagickSetImageFilename</a></li>
-<li><a class="reference internal" href="#magicksetimageformat" id="id640">MagickSetImageFormat</a></li>
-<li><a class="reference internal" href="#magicksetimagefuzz" id="id641">MagickSetImageFuzz</a></li>
-<li><a class="reference internal" href="#magicksetimagegamma" id="id642">MagickSetImageGamma</a></li>
-<li><a class="reference internal" href="#magicksetimagegravity" id="id643">MagickSetImageGravity</a></li>
-<li><a class="reference internal" href="#magicksetimagegreenprimary" id="id644">MagickSetImageGreenPrimary</a></li>
-<li><a class="reference internal" href="#magicksetimageindex" id="id645">MagickSetImageIndex</a></li>
-<li><a class="reference internal" href="#magicksetimageinterlacescheme" id="id646">MagickSetImageInterlaceScheme</a></li>
-<li><a class="reference internal" href="#magicksetimageiterations" id="id647">MagickSetImageIterations</a></li>
-<li><a class="reference internal" href="#magicksetimagemattecolor" id="id648">MagickSetImageMatteColor</a></li>
-<li><a class="reference internal" href="#magicksetimageoption" id="id649">MagickSetImageOption</a></li>
-<li><a class="reference internal" href="#magicksetimageorientation" id="id650">MagickSetImageOrientation</a></li>
-<li><a class="reference internal" href="#magicksetimagepage" id="id651">MagickSetImagePage</a></li>
-<li><a class="reference internal" href="#magicksetimagepixels" id="id652">MagickSetImagePixels</a></li>
-<li><a class="reference internal" href="#magicksetimageprofile" id="id653">MagickSetImageProfile</a></li>
-<li><a class="reference internal" href="#magicksetimageredprimary" id="id654">MagickSetImageRedPrimary</a></li>
-<li><a class="reference internal" href="#magicksetimagerenderingintent" id="id655">MagickSetImageRenderingIntent</a></li>
-<li><a class="reference internal" href="#magicksetimageresolution" id="id656">MagickSetImageResolution</a></li>
-<li><a class="reference internal" href="#magicksetimagescene" id="id657">MagickSetImageScene</a></li>
-<li><a class="reference internal" href="#magicksetimagetype" id="id658">MagickSetImageType</a></li>
-<li><a class="reference internal" href="#magicksetimagesavedtype" id="id659">MagickSetImageSavedType</a></li>
-<li><a class="reference internal" href="#magicksetimageunits" id="id660">MagickSetImageUnits</a></li>
-<li><a class="reference internal" href="#magicksetimagevirtualpixelmethod" id="id661">MagickSetImageVirtualPixelMethod</a></li>
-<li><a class="reference internal" href="#magicksetinterlacescheme" id="id662">MagickSetInterlaceScheme</a></li>
-<li><a class="reference internal" href="#magicksetresolution" id="id663">MagickSetResolution</a></li>
-<li><a class="reference internal" href="#magicksetresolutionunits" id="id664">MagickSetResolutionUnits</a></li>
-<li><a class="reference internal" href="#magicksetresourcelimit" id="id665">MagickSetResourceLimit</a></li>
-<li><a class="reference internal" href="#magicksetsamplingfactors" id="id666">MagickSetSamplingFactors</a></li>
-<li><a class="reference internal" href="#magicksetsize" id="id667">MagickSetSize</a></li>
-<li><a class="reference internal" href="#magicksetimagewhitepoint" id="id668">MagickSetImageWhitePoint</a></li>
-<li><a class="reference internal" href="#magicksetpassphrase" id="id669">MagickSetPassphrase</a></li>
-<li><a class="reference internal" href="#magicksharpenimage" id="id670">MagickSharpenImage</a></li>
-<li><a class="reference internal" href="#magickshaveimage" id="id671">MagickShaveImage</a></li>
-<li><a class="reference internal" href="#magickshearimage" id="id672">MagickShearImage</a></li>
-<li><a class="reference internal" href="#magicksolarizeimage" id="id673">MagickSolarizeImage</a></li>
-<li><a class="reference internal" href="#magickspreadimage" id="id674">MagickSpreadImage</a></li>
-<li><a class="reference internal" href="#magicksteganoimage" id="id675">MagickSteganoImage</a></li>
-<li><a class="reference internal" href="#magickstereoimage" id="id676">MagickStereoImage</a></li>
-<li><a class="reference internal" href="#magickstripimage" id="id677">MagickStripImage</a></li>
-<li><a class="reference internal" href="#magickswirlimage" id="id678">MagickSwirlImage</a></li>
-<li><a class="reference internal" href="#magicktextureimage" id="id679">MagickTextureImage</a></li>
-<li><a class="reference internal" href="#magickthresholdimage" id="id680">MagickThresholdImage</a></li>
-<li><a class="reference internal" href="#magickthresholdimagechannel" id="id681">MagickThresholdImageChannel</a></li>
-<li><a class="reference internal" href="#magicktintimage" id="id682">MagickTintImage</a></li>
-<li><a class="reference internal" href="#magicktransformimage" id="id683">MagickTransformImage</a></li>
-<li><a class="reference internal" href="#magicktransparentimage" id="id684">MagickTransparentImage</a></li>
-<li><a class="reference internal" href="#magicktrimimage" id="id685">MagickTrimImage</a></li>
-<li><a class="reference internal" href="#magickunsharpmaskimage" id="id686">MagickUnsharpMaskImage</a></li>
-<li><a class="reference internal" href="#magickwaveimage" id="id687">MagickWaveImage</a></li>
-<li><a class="reference internal" href="#magickwhitethresholdimage" id="id688">MagickWhiteThresholdImage</a></li>
-<li><a class="reference internal" href="#magickwriteimage" id="id689">MagickWriteImage</a></li>
-<li><a class="reference internal" href="#magickwriteimagesfile" id="id690">MagickWriteImagesFile</a></li>
-<li><a class="reference internal" href="#magickwriteimageblob" id="id691">MagickWriteImageBlob</a></li>
-<li><a class="reference internal" href="#magickwriteimagefile" id="id692">MagickWriteImageFile</a></li>
-<li><a class="reference internal" href="#magickwriteimages" id="id693">MagickWriteImages</a></li>
-<li><a class="reference internal" href="#newmagickwand" id="id694">NewMagickWand</a></li>
+<li><a class="reference internal" href="#clonemagickwand" id="id477">CloneMagickWand</a></li>
+<li><a class="reference internal" href="#destroymagickwand" id="id478">DestroyMagickWand</a></li>
+<li><a class="reference internal" href="#magickadaptivethresholdimage" id="id479">MagickAdaptiveThresholdImage</a></li>
+<li><a class="reference internal" href="#magickaddimage" id="id480">MagickAddImage</a></li>
+<li><a class="reference internal" href="#magickaddnoiseimage" id="id481">MagickAddNoiseImage</a></li>
+<li><a class="reference internal" href="#magickaffinetransformimage" id="id482">MagickAffineTransformImage</a></li>
+<li><a class="reference internal" href="#magickannotateimage" id="id483">MagickAnnotateImage</a></li>
+<li><a class="reference internal" href="#magickanimateimages" id="id484">MagickAnimateImages</a></li>
+<li><a class="reference internal" href="#magickappendimages" id="id485">MagickAppendImages</a></li>
+<li><a class="reference internal" href="#magickautoorientimage" id="id486">MagickAutoOrientImage</a></li>
+<li><a class="reference internal" href="#magickaverageimages" id="id487">MagickAverageImages</a></li>
+<li><a class="reference internal" href="#magickblackthresholdimage" id="id488">MagickBlackThresholdImage</a></li>
+<li><a class="reference internal" href="#magickblurimage" id="id489">MagickBlurImage</a></li>
+<li><a class="reference internal" href="#magickborderimage" id="id490">MagickBorderImage</a></li>
+<li><a class="reference internal" href="#magickcdlimage" id="id491">MagickCdlImage</a></li>
+<li><a class="reference internal" href="#magickcharcoalimage" id="id492">MagickCharcoalImage</a></li>
+<li><a class="reference internal" href="#magickchopimage" id="id493">MagickChopImage</a></li>
+<li><a class="reference internal" href="#magickclearexception" id="id494">MagickClearException</a></li>
+<li><a class="reference internal" href="#magickclipimage" id="id495">MagickClipImage</a></li>
+<li><a class="reference internal" href="#magickclippathimage" id="id496">MagickClipPathImage</a></li>
+<li><a class="reference internal" href="#magickcoalesceimages" id="id497">MagickCoalesceImages</a></li>
+<li><a class="reference internal" href="#magickcolorfloodfillimage" id="id498">MagickColorFloodfillImage</a></li>
+<li><a class="reference internal" href="#magickcolorizeimage" id="id499">MagickColorizeImage</a></li>
+<li><a class="reference internal" href="#magickcommentimage" id="id500">MagickCommentImage</a></li>
+<li><a class="reference internal" href="#magickcompareimagechannels" id="id501">MagickCompareImageChannels</a></li>
+<li><a class="reference internal" href="#magickcompareimages" id="id502">MagickCompareImages</a></li>
+<li><a class="reference internal" href="#magickcompositeimage" id="id503">MagickCompositeImage</a></li>
+<li><a class="reference internal" href="#magickcontrastimage" id="id504">MagickContrastImage</a></li>
+<li><a class="reference internal" href="#magickconvolveimage" id="id505">MagickConvolveImage</a></li>
+<li><a class="reference internal" href="#magickcropimage" id="id506">MagickCropImage</a></li>
+<li><a class="reference internal" href="#magickcyclecolormapimage" id="id507">MagickCycleColormapImage</a></li>
+<li><a class="reference internal" href="#magickdeconstructimages" id="id508">MagickDeconstructImages</a></li>
+<li><a class="reference internal" href="#magickdescribeimage" id="id509">MagickDescribeImage</a></li>
+<li><a class="reference internal" href="#magickdespeckleimage" id="id510">MagickDespeckleImage</a></li>
+<li><a class="reference internal" href="#magickdisplayimage" id="id511">MagickDisplayImage</a></li>
+<li><a class="reference internal" href="#magickdisplayimages" id="id512">MagickDisplayImages</a></li>
+<li><a class="reference internal" href="#magickdrawimage" id="id513">MagickDrawImage</a></li>
+<li><a class="reference internal" href="#magickedgeimage" id="id514">MagickEdgeImage</a></li>
+<li><a class="reference internal" href="#magickembossimage" id="id515">MagickEmbossImage</a></li>
+<li><a class="reference internal" href="#magickenhanceimage" id="id516">MagickEnhanceImage</a></li>
+<li><a class="reference internal" href="#magickequalizeimage" id="id517">MagickEqualizeImage</a></li>
+<li><a class="reference internal" href="#magickextentimage" id="id518">MagickExtentImage</a></li>
+<li><a class="reference internal" href="#magickflattenimages" id="id519">MagickFlattenImages</a></li>
+<li><a class="reference internal" href="#magickflipimage" id="id520">MagickFlipImage</a></li>
+<li><a class="reference internal" href="#magickflopimage" id="id521">MagickFlopImage</a></li>
+<li><a class="reference internal" href="#magickframeimage" id="id522">MagickFrameImage</a></li>
+<li><a class="reference internal" href="#magickfximage" id="id523">MagickFxImage</a></li>
+<li><a class="reference internal" href="#magickfximagechannel" id="id524">MagickFxImageChannel</a></li>
+<li><a class="reference internal" href="#magickgammaimage" id="id525">MagickGammaImage</a></li>
+<li><a class="reference internal" href="#magickgammaimagechannel" id="id526">MagickGammaImageChannel</a></li>
+<li><a class="reference internal" href="#magickgetconfigureinfo" id="id527">MagickGetConfigureInfo</a></li>
+<li><a class="reference internal" href="#magickgetcopyright" id="id528">MagickGetCopyright</a></li>
+<li><a class="reference internal" href="#magickgetexception" id="id529">MagickGetException</a></li>
+<li><a class="reference internal" href="#magickgetfilename" id="id530">MagickGetFilename</a></li>
+<li><a class="reference internal" href="#magickgethomeurl" id="id531">MagickGetHomeURL</a></li>
+<li><a class="reference internal" href="#magickgetimage" id="id532">MagickGetImage</a></li>
+<li><a class="reference internal" href="#magickgetimageattribute" id="id533">MagickGetImageAttribute</a></li>
+<li><a class="reference internal" href="#magickgetimagebackgroundcolor" id="id534">MagickGetImageBackgroundColor</a></li>
+<li><a class="reference internal" href="#magickgetimageblueprimary" id="id535">MagickGetImageBluePrimary</a></li>
+<li><a class="reference internal" href="#magickgetimagebordercolor" id="id536">MagickGetImageBorderColor</a></li>
+<li><a class="reference internal" href="#magickgetimageboundingbox" id="id537">MagickGetImageBoundingBox</a></li>
+<li><a class="reference internal" href="#magickgetimagechanneldepth" id="id538">MagickGetImageChannelDepth</a></li>
+<li><a class="reference internal" href="#magickgetimagechannelextrema" id="id539">MagickGetImageChannelExtrema</a></li>
+<li><a class="reference internal" href="#magickgetimagechannelmean" id="id540">MagickGetImageChannelMean</a></li>
+<li><a class="reference internal" href="#magickgetimagecolormapcolor" id="id541">MagickGetImageColormapColor</a></li>
+<li><a class="reference internal" href="#magickgetimagecolors" id="id542">MagickGetImageColors</a></li>
+<li><a class="reference internal" href="#magickgetimagecolorspace" id="id543">MagickGetImageColorspace</a></li>
+<li><a class="reference internal" href="#magickgetimagecompose" id="id544">MagickGetImageCompose</a></li>
+<li><a class="reference internal" href="#magickgetimagecompression" id="id545">MagickGetImageCompression</a></li>
+<li><a class="reference internal" href="#magickgetimagedelay" id="id546">MagickGetImageDelay</a></li>
+<li><a class="reference internal" href="#magickgetimagedepth" id="id547">MagickGetImageDepth</a></li>
+<li><a class="reference internal" href="#magickgetimageextrema" id="id548">MagickGetImageExtrema</a></li>
+<li><a class="reference internal" href="#magickgetimagedispose" id="id549">MagickGetImageDispose</a></li>
+<li><a class="reference internal" href="#magickgetimagefilename" id="id550">MagickGetImageFilename</a></li>
+<li><a class="reference internal" href="#magickgetimageformat" id="id551">MagickGetImageFormat</a></li>
+<li><a class="reference internal" href="#magickgetimagefuzz" id="id552">MagickGetImageFuzz</a></li>
+<li><a class="reference internal" href="#magickgetimagegamma" id="id553">MagickGetImageGamma</a></li>
+<li><a class="reference internal" href="#magickgetimagegravity" id="id554">MagickGetImageGravity</a></li>
+<li><a class="reference internal" href="#magickgetimagegreenprimary" id="id555">MagickGetImageGreenPrimary</a></li>
+<li><a class="reference internal" href="#magickgetimageheight" id="id556">MagickGetImageHeight</a></li>
+<li><a class="reference internal" href="#magickgetimagehistogram" id="id557">MagickGetImageHistogram</a></li>
+<li><a class="reference internal" href="#magickgetimageindex" id="id558">MagickGetImageIndex</a></li>
+<li><a class="reference internal" href="#magickgetimageinterlacescheme" id="id559">MagickGetImageInterlaceScheme</a></li>
+<li><a class="reference internal" href="#magickgetimageiterations" id="id560">MagickGetImageIterations</a></li>
+<li><a class="reference internal" href="#magickgetimagemattecolor" id="id561">MagickGetImageMatteColor</a></li>
+<li><a class="reference internal" href="#magickgetimageorientation" id="id562">MagickGetImageOrientation</a></li>
+<li><a class="reference internal" href="#magickgetimagepage" id="id563">MagickGetImagePage</a></li>
+<li><a class="reference internal" href="#magickgetimagepixels" id="id564">MagickGetImagePixels</a></li>
+<li><a class="reference internal" href="#magickgetimageprofile" id="id565">MagickGetImageProfile</a></li>
+<li><a class="reference internal" href="#magickgetimageredprimary" id="id566">MagickGetImageRedPrimary</a></li>
+<li><a class="reference internal" href="#magickgetimagerenderingintent" id="id567">MagickGetImageRenderingIntent</a></li>
+<li><a class="reference internal" href="#magickgetimageresolution" id="id568">MagickGetImageResolution</a></li>
+<li><a class="reference internal" href="#magickgetimagescene" id="id569">MagickGetImageScene</a></li>
+<li><a class="reference internal" href="#magickgetimagesignature" id="id570">MagickGetImageSignature</a></li>
+<li><a class="reference internal" href="#magickgetimagesize" id="id571">MagickGetImageSize</a></li>
+<li><a class="reference internal" href="#magickgetimagetype" id="id572">MagickGetImageType</a></li>
+<li><a class="reference internal" href="#magickgetimagesavedtype" id="id573">MagickGetImageSavedType</a></li>
+<li><a class="reference internal" href="#magickgetimageunits" id="id574">MagickGetImageUnits</a></li>
+<li><a class="reference internal" href="#magickgetimagevirtualpixelmethod" id="id575">MagickGetImageVirtualPixelMethod</a></li>
+<li><a class="reference internal" href="#magickgetimagewhitepoint" id="id576">MagickGetImageWhitePoint</a></li>
+<li><a class="reference internal" href="#magickgetimagewidth" id="id577">MagickGetImageWidth</a></li>
+<li><a class="reference internal" href="#magickgetnumberimages" id="id578">MagickGetNumberImages</a></li>
+<li><a class="reference internal" href="#magickgetpackagename" id="id579">MagickGetPackageName</a></li>
+<li><a class="reference internal" href="#magickgetquantumdepth" id="id580">MagickGetQuantumDepth</a></li>
+<li><a class="reference internal" href="#magickgetreleasedate" id="id581">MagickGetReleaseDate</a></li>
+<li><a class="reference internal" href="#magickgetresourcelimit" id="id582">MagickGetResourceLimit</a></li>
+<li><a class="reference internal" href="#magickgetsamplingfactors" id="id583">MagickGetSamplingFactors</a></li>
+<li><a class="reference internal" href="#magickgetsize" id="id584">MagickGetSize</a></li>
+<li><a class="reference internal" href="#magickgetversion" id="id585">MagickGetVersion</a></li>
+<li><a class="reference internal" href="#magickhaldclutimage" id="id586">MagickHaldClutImage</a></li>
+<li><a class="reference internal" href="#magickhascolormap" id="id587">MagickHasColorMap</a></li>
+<li><a class="reference internal" href="#magickhasnextimage" id="id588">MagickHasNextImage</a></li>
+<li><a class="reference internal" href="#magickhaspreviousimage" id="id589">MagickHasPreviousImage</a></li>
+<li><a class="reference internal" href="#magickimplodeimage" id="id590">MagickImplodeImage</a></li>
+<li><a class="reference internal" href="#magickisgrayimage" id="id591">MagickIsGrayImage</a></li>
+<li><a class="reference internal" href="#magickismonochromeimage" id="id592">MagickIsMonochromeImage</a></li>
+<li><a class="reference internal" href="#magickisopaqueimage" id="id593">MagickIsOpaqueImage</a></li>
+<li><a class="reference internal" href="#magickispaletteimage" id="id594">MagickIsPaletteImage</a></li>
+<li><a class="reference internal" href="#magicklabelimage" id="id595">MagickLabelImage</a></li>
+<li><a class="reference internal" href="#magicklevelimage" id="id596">MagickLevelImage</a></li>
+<li><a class="reference internal" href="#magicklevelimagechannel" id="id597">MagickLevelImageChannel</a></li>
+<li><a class="reference internal" href="#magickmagnifyimage" id="id598">MagickMagnifyImage</a></li>
+<li><a class="reference internal" href="#magickmapimage" id="id599">MagickMapImage</a></li>
+<li><a class="reference internal" href="#magickmattefloodfillimage" id="id600">MagickMatteFloodfillImage</a></li>
+<li><a class="reference internal" href="#magickmedianfilterimage" id="id601">MagickMedianFilterImage</a></li>
+<li><a class="reference internal" href="#magickminifyimage" id="id602">MagickMinifyImage</a></li>
+<li><a class="reference internal" href="#magickmodulateimage" id="id603">MagickModulateImage</a></li>
+<li><a class="reference internal" href="#magickmontageimage" id="id604">MagickMontageImage</a></li>
+<li><a class="reference internal" href="#magickmorphimages" id="id605">MagickMorphImages</a></li>
+<li><a class="reference internal" href="#magickmosaicimages" id="id606">MagickMosaicImages</a></li>
+<li><a class="reference internal" href="#magickmotionblurimage" id="id607">MagickMotionBlurImage</a></li>
+<li><a class="reference internal" href="#magicknegateimage" id="id608">MagickNegateImage</a></li>
+<li><a class="reference internal" href="#magicknegateimagechannel" id="id609">MagickNegateImageChannel</a></li>
+<li><a class="reference internal" href="#magicknextimage" id="id610">MagickNextImage</a></li>
+<li><a class="reference internal" href="#magicknormalizeimage" id="id611">MagickNormalizeImage</a></li>
+<li><a class="reference internal" href="#magickoilpaintimage" id="id612">MagickOilPaintImage</a></li>
+<li><a class="reference internal" href="#magickopaqueimage" id="id613">MagickOpaqueImage</a></li>
+<li><a class="reference internal" href="#magickpingimage" id="id614">MagickPingImage</a></li>
+<li><a class="reference internal" href="#magickpreviewimages" id="id615">MagickPreviewImages</a></li>
+<li><a class="reference internal" href="#magickpreviousimage" id="id616">MagickPreviousImage</a></li>
+<li><a class="reference internal" href="#magickprofileimage" id="id617">MagickProfileImage</a></li>
+<li><a class="reference internal" href="#magickquantizeimage" id="id618">MagickQuantizeImage</a></li>
+<li><a class="reference internal" href="#magickquantizeimages" id="id619">MagickQuantizeImages</a></li>
+<li><a class="reference internal" href="#magickqueryfontmetrics" id="id620">MagickQueryFontMetrics</a></li>
+<li><a class="reference internal" href="#magickqueryfonts" id="id621">MagickQueryFonts</a></li>
+<li><a class="reference internal" href="#magickqueryformats" id="id622">MagickQueryFormats</a></li>
+<li><a class="reference internal" href="#magickradialblurimage" id="id623">MagickRadialBlurImage</a></li>
+<li><a class="reference internal" href="#magickraiseimage" id="id624">MagickRaiseImage</a></li>
+<li><a class="reference internal" href="#magickreadimage" id="id625">MagickReadImage</a></li>
+<li><a class="reference internal" href="#magickreadimageblob" id="id626">MagickReadImageBlob</a></li>
+<li><a class="reference internal" href="#magickreadimagefile" id="id627">MagickReadImageFile</a></li>
+<li><a class="reference internal" href="#magickreducenoiseimage" id="id628">MagickReduceNoiseImage</a></li>
+<li><a class="reference internal" href="#magickrelinquishmemory" id="id629">MagickRelinquishMemory</a></li>
+<li><a class="reference internal" href="#magickremoveimage" id="id630">MagickRemoveImage</a></li>
+<li><a class="reference internal" href="#magickremoveimageoption" id="id631">MagickRemoveImageOption</a></li>
+<li><a class="reference internal" href="#magickremoveimageprofile" id="id632">MagickRemoveImageProfile</a></li>
+<li><a class="reference internal" href="#magickresetiterator" id="id633">MagickResetIterator</a></li>
+<li><a class="reference internal" href="#magickresampleimage" id="id634">MagickResampleImage</a></li>
+<li><a class="reference internal" href="#magickresizeimage" id="id635">MagickResizeImage</a></li>
+<li><a class="reference internal" href="#magickrollimage" id="id636">MagickRollImage</a></li>
+<li><a class="reference internal" href="#magickrotateimage" id="id637">MagickRotateImage</a></li>
+<li><a class="reference internal" href="#magicksampleimage" id="id638">MagickSampleImage</a></li>
+<li><a class="reference internal" href="#magickscaleimage" id="id639">MagickScaleImage</a></li>
+<li><a class="reference internal" href="#magickseparateimagechannel" id="id640">MagickSeparateImageChannel</a></li>
+<li><a class="reference internal" href="#magicksetcompressionquality" id="id641">MagickSetCompressionQuality</a></li>
+<li><a class="reference internal" href="#magicksetdepth" id="id642">MagickSetDepth</a></li>
+<li><a class="reference internal" href="#magicksetfilename" id="id643">MagickSetFilename</a></li>
+<li><a class="reference internal" href="#magicksetformat" id="id644">MagickSetFormat</a></li>
+<li><a class="reference internal" href="#magicksetimage" id="id645">MagickSetImage</a></li>
+<li><a class="reference internal" href="#magicksetimageattribute" id="id646">MagickSetImageAttribute</a></li>
+<li><a class="reference internal" href="#magicksetimagebackgroundcolor" id="id647">MagickSetImageBackgroundColor</a></li>
+<li><a class="reference internal" href="#magicksetimageblueprimary" id="id648">MagickSetImageBluePrimary</a></li>
+<li><a class="reference internal" href="#magicksetimagebordercolor" id="id649">MagickSetImageBorderColor</a></li>
+<li><a class="reference internal" href="#magicksetimagecolormapcolor" id="id650">MagickSetImageColormapColor</a></li>
+<li><a class="reference internal" href="#magicksetimagecolorspace" id="id651">MagickSetImageColorspace</a></li>
+<li><a class="reference internal" href="#magicksetimagecompose" id="id652">MagickSetImageCompose</a></li>
+<li><a class="reference internal" href="#magicksetimagecompression" id="id653">MagickSetImageCompression</a></li>
+<li><a class="reference internal" href="#magicksetimagedelay" id="id654">MagickSetImageDelay</a></li>
+<li><a class="reference internal" href="#magicksetimagechanneldepth" id="id655">MagickSetImageChannelDepth</a></li>
+<li><a class="reference internal" href="#magicksetimagedepth" id="id656">MagickSetImageDepth</a></li>
+<li><a class="reference internal" href="#magicksetimagedispose" id="id657">MagickSetImageDispose</a></li>
+<li><a class="reference internal" href="#magicksetimagefilename" id="id658">MagickSetImageFilename</a></li>
+<li><a class="reference internal" href="#magicksetimageformat" id="id659">MagickSetImageFormat</a></li>
+<li><a class="reference internal" href="#magicksetimagefuzz" id="id660">MagickSetImageFuzz</a></li>
+<li><a class="reference internal" href="#magicksetimagegamma" id="id661">MagickSetImageGamma</a></li>
+<li><a class="reference internal" href="#magicksetimagegravity" id="id662">MagickSetImageGravity</a></li>
+<li><a class="reference internal" href="#magicksetimagegreenprimary" id="id663">MagickSetImageGreenPrimary</a></li>
+<li><a class="reference internal" href="#magicksetimageindex" id="id664">MagickSetImageIndex</a></li>
+<li><a class="reference internal" href="#magicksetimageinterlacescheme" id="id665">MagickSetImageInterlaceScheme</a></li>
+<li><a class="reference internal" href="#magicksetimageiterations" id="id666">MagickSetImageIterations</a></li>
+<li><a class="reference internal" href="#magicksetimagemattecolor" id="id667">MagickSetImageMatteColor</a></li>
+<li><a class="reference internal" href="#magicksetimageoption" id="id668">MagickSetImageOption</a></li>
+<li><a class="reference internal" href="#magicksetimageorientation" id="id669">MagickSetImageOrientation</a></li>
+<li><a class="reference internal" href="#magicksetimagepage" id="id670">MagickSetImagePage</a></li>
+<li><a class="reference internal" href="#magicksetimagepixels" id="id671">MagickSetImagePixels</a></li>
+<li><a class="reference internal" href="#magicksetimageprofile" id="id672">MagickSetImageProfile</a></li>
+<li><a class="reference internal" href="#magicksetimageredprimary" id="id673">MagickSetImageRedPrimary</a></li>
+<li><a class="reference internal" href="#magicksetimagerenderingintent" id="id674">MagickSetImageRenderingIntent</a></li>
+<li><a class="reference internal" href="#magicksetimageresolution" id="id675">MagickSetImageResolution</a></li>
+<li><a class="reference internal" href="#magicksetimagescene" id="id676">MagickSetImageScene</a></li>
+<li><a class="reference internal" href="#magicksetimagetype" id="id677">MagickSetImageType</a></li>
+<li><a class="reference internal" href="#magicksetimagesavedtype" id="id678">MagickSetImageSavedType</a></li>
+<li><a class="reference internal" href="#magicksetimageunits" id="id679">MagickSetImageUnits</a></li>
+<li><a class="reference internal" href="#magicksetimagevirtualpixelmethod" id="id680">MagickSetImageVirtualPixelMethod</a></li>
+<li><a class="reference internal" href="#magicksetinterlacescheme" id="id681">MagickSetInterlaceScheme</a></li>
+<li><a class="reference internal" href="#magicksetresolution" id="id682">MagickSetResolution</a></li>
+<li><a class="reference internal" href="#magicksetresolutionunits" id="id683">MagickSetResolutionUnits</a></li>
+<li><a class="reference internal" href="#magicksetresourcelimit" id="id684">MagickSetResourceLimit</a></li>
+<li><a class="reference internal" href="#magicksetsamplingfactors" id="id685">MagickSetSamplingFactors</a></li>
+<li><a class="reference internal" href="#magicksetsize" id="id686">MagickSetSize</a></li>
+<li><a class="reference internal" href="#magicksetimagewhitepoint" id="id687">MagickSetImageWhitePoint</a></li>
+<li><a class="reference internal" href="#magicksetpassphrase" id="id688">MagickSetPassphrase</a></li>
+<li><a class="reference internal" href="#magicksharpenimage" id="id689">MagickSharpenImage</a></li>
+<li><a class="reference internal" href="#magickshaveimage" id="id690">MagickShaveImage</a></li>
+<li><a class="reference internal" href="#magickshearimage" id="id691">MagickShearImage</a></li>
+<li><a class="reference internal" href="#magicksolarizeimage" id="id692">MagickSolarizeImage</a></li>
+<li><a class="reference internal" href="#magickspreadimage" id="id693">MagickSpreadImage</a></li>
+<li><a class="reference internal" href="#magicksteganoimage" id="id694">MagickSteganoImage</a></li>
+<li><a class="reference internal" href="#magickstereoimage" id="id695">MagickStereoImage</a></li>
+<li><a class="reference internal" href="#magickstripimage" id="id696">MagickStripImage</a></li>
+<li><a class="reference internal" href="#magickswirlimage" id="id697">MagickSwirlImage</a></li>
+<li><a class="reference internal" href="#magicktextureimage" id="id698">MagickTextureImage</a></li>
+<li><a class="reference internal" href="#magickthresholdimage" id="id699">MagickThresholdImage</a></li>
+<li><a class="reference internal" href="#magickthresholdimagechannel" id="id700">MagickThresholdImageChannel</a></li>
+<li><a class="reference internal" href="#magicktintimage" id="id701">MagickTintImage</a></li>
+<li><a class="reference internal" href="#magicktransformimage" id="id702">MagickTransformImage</a></li>
+<li><a class="reference internal" href="#magicktransparentimage" id="id703">MagickTransparentImage</a></li>
+<li><a class="reference internal" href="#magicktrimimage" id="id704">MagickTrimImage</a></li>
+<li><a class="reference internal" href="#magickunsharpmaskimage" id="id705">MagickUnsharpMaskImage</a></li>
+<li><a class="reference internal" href="#magickwaveimage" id="id706">MagickWaveImage</a></li>
+<li><a class="reference internal" href="#magickwhitethresholdimage" id="id707">MagickWhiteThresholdImage</a></li>
+<li><a class="reference internal" href="#magickwriteimage" id="id708">MagickWriteImage</a></li>
+<li><a class="reference internal" href="#magickwriteimagesfile" id="id709">MagickWriteImagesFile</a></li>
+<li><a class="reference internal" href="#magickwriteimageblob" id="id710">MagickWriteImageBlob</a></li>
+<li><a class="reference internal" href="#magickwriteimagefile" id="id711">MagickWriteImageFile</a></li>
+<li><a class="reference internal" href="#magickwriteimages" id="id712">MagickWriteImages</a></li>
+<li><a class="reference internal" href="#newmagickwand" id="id713">NewMagickWand</a></li>
 </ul>
 </div>
 <div class="section" id="clonemagickwand">
-<h1><a class="toc-backref" href="#id463">CloneMagickWand</a></h1>
+<h1><a class="toc-backref" href="#id477">CloneMagickWand</a></h1>
 <div class="section" id="synopsis">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -296,7 +301,7 @@ MagickWand *CloneMagickWand( const MagickWand *wand );
 </div>
 </div>
 <div class="section" id="destroymagickwand">
-<h1><a class="toc-backref" href="#id464">DestroyMagickWand</a></h1>
+<h1><a class="toc-backref" href="#id478">DestroyMagickWand</a></h1>
 <div class="section" id="id1">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -318,7 +323,7 @@ void DestroyMagickWand( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickadaptivethresholdimage">
-<h1><a class="toc-backref" href="#id465">MagickAdaptiveThresholdImage</a></h1>
+<h1><a class="toc-backref" href="#id479">MagickAdaptiveThresholdImage</a></h1>
 <div class="section" id="id3">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -350,7 +355,7 @@ unsigned int MagickAdaptiveThresholdImage( MagickWand *wand, const unsigned long
 </div>
 </div>
 <div class="section" id="magickaddimage">
-<h1><a class="toc-backref" href="#id466">MagickAddImage</a></h1>
+<h1><a class="toc-backref" href="#id480">MagickAddImage</a></h1>
 <div class="section" id="id5">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -373,7 +378,7 @@ unsigned int MagickAddImage( MagickWand *wand, const MagickWand *add_wand );
 </div>
 </div>
 <div class="section" id="magickaddnoiseimage">
-<h1><a class="toc-backref" href="#id467">MagickAddNoiseImage</a></h1>
+<h1><a class="toc-backref" href="#id481">MagickAddNoiseImage</a></h1>
 <div class="section" id="id7">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -397,7 +402,7 @@ Impulse, Laplacian, Poisson, or Random.</dd>
 </div>
 </div>
 <div class="section" id="magickaffinetransformimage">
-<h1><a class="toc-backref" href="#id468">MagickAffineTransformImage</a></h1>
+<h1><a class="toc-backref" href="#id482">MagickAffineTransformImage</a></h1>
 <div class="section" id="id9">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -421,7 +426,7 @@ unsigned int MagickAffineTransformImage( MagickWand *wand, const DrawingWand *dr
 </div>
 </div>
 <div class="section" id="magickannotateimage">
-<h1><a class="toc-backref" href="#id469">MagickAnnotateImage</a></h1>
+<h1><a class="toc-backref" href="#id483">MagickAnnotateImage</a></h1>
 <div class="section" id="id11">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -456,7 +461,7 @@ unsigned int MagickAnnotateImage( MagickWand *wand, const DrawingWand *drawing_w
 </div>
 </div>
 <div class="section" id="magickanimateimages">
-<h1><a class="toc-backref" href="#id470">MagickAnimateImages</a></h1>
+<h1><a class="toc-backref" href="#id484">MagickAnimateImages</a></h1>
 <div class="section" id="id13">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -479,7 +484,7 @@ unsigned int MagickAnimateImages( MagickWand *wand, const char *server_name );
 </div>
 </div>
 <div class="section" id="magickappendimages">
-<h1><a class="toc-backref" href="#id471">MagickAppendImages</a></h1>
+<h1><a class="toc-backref" href="#id485">MagickAppendImages</a></h1>
 <div class="section" id="id15">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -503,7 +508,7 @@ to stack them top-to-bottom.</dd>
 </div>
 </div>
 <div class="section" id="magickautoorientimage">
-<h1><a class="toc-backref" href="#id472">MagickAutoOrientImage</a></h1>
+<h1><a class="toc-backref" href="#id486">MagickAutoOrientImage</a></h1>
 <div class="section" id="id17">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -551,7 +556,7 @@ EXIF orientation tag.</p>
 </div>
 </div>
 <div class="section" id="magickaverageimages">
-<h1><a class="toc-backref" href="#id473">MagickAverageImages</a></h1>
+<h1><a class="toc-backref" href="#id487">MagickAverageImages</a></h1>
 <div class="section" id="id19">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -573,7 +578,7 @@ MagickWand *MagickAverageImages( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickblackthresholdimage">
-<h1><a class="toc-backref" href="#id474">MagickBlackThresholdImage</a></h1>
+<h1><a class="toc-backref" href="#id488">MagickBlackThresholdImage</a></h1>
 <div class="section" id="id21">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -598,7 +603,7 @@ unsigned int MagickBlackThresholdImage( MagickWand *wand, const PixelWand *thres
 </div>
 </div>
 <div class="section" id="magickblurimage">
-<h1><a class="toc-backref" href="#id475">MagickBlurImage</a></h1>
+<h1><a class="toc-backref" href="#id489">MagickBlurImage</a></h1>
 <div class="section" id="id23">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -627,7 +632,7 @@ pixel.</dd>
 </div>
 </div>
 <div class="section" id="magickborderimage">
-<h1><a class="toc-backref" href="#id476">MagickBorderImage</a></h1>
+<h1><a class="toc-backref" href="#id490">MagickBorderImage</a></h1>
 <div class="section" id="id25">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -657,7 +662,7 @@ unsigned int MagickBorderImage( MagickWand *wand, const PixelWand *bordercolor,
 </div>
 </div>
 <div class="section" id="magickcdlimage">
-<h1><a class="toc-backref" href="#id477">MagickCdlImage</a></h1>
+<h1><a class="toc-backref" href="#id491">MagickCdlImage</a></h1>
 <div class="section" id="id27">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -697,7 +702,7 @@ red green and blue channels, plus saturation.</dd>
 </div>
 </div>
 <div class="section" id="magickcharcoalimage">
-<h1><a class="toc-backref" href="#id478">MagickCharcoalImage</a></h1>
+<h1><a class="toc-backref" href="#id492">MagickCharcoalImage</a></h1>
 <div class="section" id="id29">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -723,7 +728,7 @@ pixel.</dd>
 </div>
 </div>
 <div class="section" id="magickchopimage">
-<h1><a class="toc-backref" href="#id479">MagickChopImage</a></h1>
+<h1><a class="toc-backref" href="#id493">MagickChopImage</a></h1>
 <div class="section" id="id31">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -755,7 +760,7 @@ unsigned int MagickChopImage( MagickWand *wand, const unsigned long width,
 </div>
 </div>
 <div class="section" id="magickclearexception">
-<h1><a class="toc-backref" href="#id480">MagickClearException</a></h1>
+<h1><a class="toc-backref" href="#id494">MagickClearException</a></h1>
 <div class="section" id="id33">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -777,7 +782,7 @@ void MagickClearException( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickclipimage">
-<h1><a class="toc-backref" href="#id481">MagickClipImage</a></h1>
+<h1><a class="toc-backref" href="#id495">MagickClipImage</a></h1>
 <div class="section" id="id35">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -800,7 +805,7 @@ unsigned int MagickClipImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickclippathimage">
-<h1><a class="toc-backref" href="#id482">MagickClipPathImage</a></h1>
+<h1><a class="toc-backref" href="#id496">MagickClipPathImage</a></h1>
 <div class="section" id="id37">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -832,7 +837,7 @@ Otherwise later operations take effect outside clipping path.</dd>
 </div>
 </div>
 <div class="section" id="magickcoalesceimages">
-<h1><a class="toc-backref" href="#id483">MagickCoalesceImages</a></h1>
+<h1><a class="toc-backref" href="#id497">MagickCoalesceImages</a></h1>
 <div class="section" id="id39">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -859,7 +864,7 @@ MagickWand *MagickCoalesceImages( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickcolorfloodfillimage">
-<h1><a class="toc-backref" href="#id484">MagickColorFloodfillImage</a></h1>
+<h1><a class="toc-backref" href="#id498">MagickColorFloodfillImage</a></h1>
 <div class="section" id="id41">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -900,7 +905,7 @@ as the same color for the purposes of the floodfill.</dd>
 </div>
 </div>
 <div class="section" id="magickcolorizeimage">
-<h1><a class="toc-backref" href="#id485">MagickColorizeImage</a></h1>
+<h1><a class="toc-backref" href="#id499">MagickColorizeImage</a></h1>
 <div class="section" id="id43">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -927,7 +932,7 @@ unsigned int MagickColorizeImage( MagickWand *wand, const PixelWand *colorize,
 </div>
 </div>
 <div class="section" id="magickcommentimage">
-<h1><a class="toc-backref" href="#id486">MagickCommentImage</a></h1>
+<h1><a class="toc-backref" href="#id500">MagickCommentImage</a></h1>
 <div class="section" id="id45">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -951,7 +956,7 @@ unsigned int MagickCommentImage( MagickWand *wand, const char *comment );
 </div>
 </div>
 <div class="section" id="magickcompareimagechannels">
-<h1><a class="toc-backref" href="#id487">MagickCompareImageChannels</a></h1>
+<h1><a class="toc-backref" href="#id501">MagickCompareImageChannels</a></h1>
 <div class="section" id="id47">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -985,7 +990,7 @@ MagickWand *MagickCompareImageChannels( MagickWand *wand, const MagickWand *refe
 </div>
 </div>
 <div class="section" id="magickcompareimages">
-<h1><a class="toc-backref" href="#id488">MagickCompareImages</a></h1>
+<h1><a class="toc-backref" href="#id502">MagickCompareImages</a></h1>
 <div class="section" id="id49">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1015,7 +1020,7 @@ MagickWand *MagickCompareImages( MagickWand *wand, const MagickWand *reference,
 </div>
 </div>
 <div class="section" id="magickcompositeimage">
-<h1><a class="toc-backref" href="#id489">MagickCompositeImage</a></h1>
+<h1><a class="toc-backref" href="#id503">MagickCompositeImage</a></h1>
 <div class="section" id="id51">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1057,7 +1062,7 @@ DisplaceCompositeOP</p>
 </div>
 </div>
 <div class="section" id="magickcontrastimage">
-<h1><a class="toc-backref" href="#id490">MagickContrastImage</a></h1>
+<h1><a class="toc-backref" href="#id504">MagickContrastImage</a></h1>
 <div class="section" id="id53">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1082,7 +1087,7 @@ unsigned int MagickContrastImage( MagickWand *wand, const unsigned int sharpen )
 </div>
 </div>
 <div class="section" id="magickconvolveimage">
-<h1><a class="toc-backref" href="#id491">MagickConvolveImage</a></h1>
+<h1><a class="toc-backref" href="#id505">MagickConvolveImage</a></h1>
 <div class="section" id="id55">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1109,7 +1114,7 @@ unsigned int MagickConvolveImage( MagickWand *wand, const unsigned long order,
 </div>
 </div>
 <div class="section" id="magickcropimage">
-<h1><a class="toc-backref" href="#id492">MagickCropImage</a></h1>
+<h1><a class="toc-backref" href="#id506">MagickCropImage</a></h1>
 <div class="section" id="id57">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1140,7 +1145,7 @@ unsigned int MagickCropImage( MagickWand *wand, const unsigned long width,
 </div>
 </div>
 <div class="section" id="magickcyclecolormapimage">
-<h1><a class="toc-backref" href="#id493">MagickCycleColormapImage</a></h1>
+<h1><a class="toc-backref" href="#id507">MagickCycleColormapImage</a></h1>
 <div class="section" id="id59">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1165,7 +1170,7 @@ unsigned int MagickCycleColormapImage( MagickWand *wand, const long displace );
 </div>
 </div>
 <div class="section" id="magickdeconstructimages">
-<h1><a class="toc-backref" href="#id494">MagickDeconstructImages</a></h1>
+<h1><a class="toc-backref" href="#id508">MagickDeconstructImages</a></h1>
 <div class="section" id="id61">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1189,7 +1194,7 @@ MagickWand *MagickDeconstructImages( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickdescribeimage">
-<h1><a class="toc-backref" href="#id495">MagickDescribeImage</a></h1>
+<h1><a class="toc-backref" href="#id509">MagickDescribeImage</a></h1>
 <div class="section" id="id63">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1214,7 +1219,7 @@ const char *MagickDescribeImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickdespeckleimage">
-<h1><a class="toc-backref" href="#id496">MagickDespeckleImage</a></h1>
+<h1><a class="toc-backref" href="#id510">MagickDespeckleImage</a></h1>
 <div class="section" id="id65">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1237,7 +1242,7 @@ unsigned int MagickDespeckleImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickdisplayimage">
-<h1><a class="toc-backref" href="#id497">MagickDisplayImage</a></h1>
+<h1><a class="toc-backref" href="#id511">MagickDisplayImage</a></h1>
 <div class="section" id="id67">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1261,7 +1266,7 @@ unsigned int MagickDisplayImage( MagickWand *wand, const char *server_name );
 </div>
 </div>
 <div class="section" id="magickdisplayimages">
-<h1><a class="toc-backref" href="#id498">MagickDisplayImages</a></h1>
+<h1><a class="toc-backref" href="#id512">MagickDisplayImages</a></h1>
 <div class="section" id="id69">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1284,7 +1289,7 @@ unsigned int MagickDisplayImages( MagickWand *wand, const char *server_name );
 </div>
 </div>
 <div class="section" id="magickdrawimage">
-<h1><a class="toc-backref" href="#id499">MagickDrawImage</a></h1>
+<h1><a class="toc-backref" href="#id513">MagickDrawImage</a></h1>
 <div class="section" id="id71">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1307,7 +1312,7 @@ unsigned int MagickDrawImage( MagickWand *wand, const DrawingWand *drawing_wand
 </div>
 </div>
 <div class="section" id="magickedgeimage">
-<h1><a class="toc-backref" href="#id500">MagickEdgeImage</a></h1>
+<h1><a class="toc-backref" href="#id514">MagickEdgeImage</a></h1>
 <div class="section" id="id73">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1333,7 +1338,7 @@ unsigned int MagickEdgeImage( MagickWand *wand, const double radius );
 </div>
 </div>
 <div class="section" id="magickembossimage">
-<h1><a class="toc-backref" href="#id501">MagickEmbossImage</a></h1>
+<h1><a class="toc-backref" href="#id515">MagickEmbossImage</a></h1>
 <div class="section" id="id75">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1363,7 +1368,7 @@ pixel.</dd>
 </div>
 </div>
 <div class="section" id="magickenhanceimage">
-<h1><a class="toc-backref" href="#id502">MagickEnhanceImage</a></h1>
+<h1><a class="toc-backref" href="#id516">MagickEnhanceImage</a></h1>
 <div class="section" id="id77">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1386,7 +1391,7 @@ unsigned int MagickEnhanceImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickequalizeimage">
-<h1><a class="toc-backref" href="#id503">MagickEqualizeImage</a></h1>
+<h1><a class="toc-backref" href="#id517">MagickEqualizeImage</a></h1>
 <div class="section" id="id79">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1408,7 +1413,7 @@ unsigned int MagickEqualizeImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickextentimage">
-<h1><a class="toc-backref" href="#id504">MagickExtentImage</a></h1>
+<h1><a class="toc-backref" href="#id518">MagickExtentImage</a></h1>
 <div class="section" id="id81">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1442,7 +1447,7 @@ on the new image.</dd>
 </div>
 </div>
 <div class="section" id="magickflattenimages">
-<h1><a class="toc-backref" href="#id505">MagickFlattenImages</a></h1>
+<h1><a class="toc-backref" href="#id519">MagickFlattenImages</a></h1>
 <div class="section" id="id83">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1465,7 +1470,7 @@ MagickWand *MagickFlattenImages( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickflipimage">
-<h1><a class="toc-backref" href="#id506">MagickFlipImage</a></h1>
+<h1><a class="toc-backref" href="#id520">MagickFlipImage</a></h1>
 <div class="section" id="id85">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1488,7 +1493,7 @@ unsigned int MagickFlipImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickflopimage">
-<h1><a class="toc-backref" href="#id507">MagickFlopImage</a></h1>
+<h1><a class="toc-backref" href="#id521">MagickFlopImage</a></h1>
 <div class="section" id="id87">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1511,7 +1516,7 @@ unsigned int MagickFlopImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickframeimage">
-<h1><a class="toc-backref" href="#id508">MagickFrameImage</a></h1>
+<h1><a class="toc-backref" href="#id522">MagickFrameImage</a></h1>
 <div class="section" id="id89">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1549,7 +1554,7 @@ unsigned int MagickFrameImage( MagickWand *wand, const PixelWand *matte_color,
 </div>
 </div>
 <div class="section" id="magickfximage">
-<h1><a class="toc-backref" href="#id509">MagickFxImage</a></h1>
+<h1><a class="toc-backref" href="#id523">MagickFxImage</a></h1>
 <div class="section" id="id91">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1573,7 +1578,7 @@ MagickWand *MagickFxImage( MagickWand *wand, const char *expression );
 </div>
 </div>
 <div class="section" id="magickfximagechannel">
-<h1><a class="toc-backref" href="#id510">MagickFxImageChannel</a></h1>
+<h1><a class="toc-backref" href="#id524">MagickFxImageChannel</a></h1>
 <div class="section" id="id93">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1603,7 +1608,7 @@ BlackChannel.</dd>
 </div>
 </div>
 <div class="section" id="magickgammaimage">
-<h1><a class="toc-backref" href="#id511">MagickGammaImage</a></h1>
+<h1><a class="toc-backref" href="#id525">MagickGammaImage</a></h1>
 <div class="section" id="id95">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1633,7 +1638,7 @@ unsigned int MagickGammaImage( MagickWand *wand, const double gamma );
 </div>
 </div>
 <div class="section" id="magickgammaimagechannel">
-<h1><a class="toc-backref" href="#id512">MagickGammaImageChannel</a></h1>
+<h1><a class="toc-backref" href="#id526">MagickGammaImageChannel</a></h1>
 <div class="section" id="id97">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1666,7 +1671,7 @@ unsigned int MagickGammaImageChannel( MagickWand *wand, const <a class="referenc
 </div>
 </div>
 <div class="section" id="magickgetconfigureinfo">
-<h1><a class="toc-backref" href="#id513">MagickGetConfigureInfo</a></h1>
+<h1><a class="toc-backref" href="#id527">MagickGetConfigureInfo</a></h1>
 <div class="section" id="id99">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1691,7 +1696,7 @@ char *MagickGetConfigureInfo( MagickWand *wand, const char *name );
 </div>
 </div>
 <div class="section" id="magickgetcopyright">
-<h1><a class="toc-backref" href="#id514">MagickGetCopyright</a></h1>
+<h1><a class="toc-backref" href="#id528">MagickGetCopyright</a></h1>
 <div class="section" id="id101">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1708,7 +1713,7 @@ const char *MagickGetCopyright( void );
 </div>
 </div>
 <div class="section" id="magickgetexception">
-<h1><a class="toc-backref" href="#id515">MagickGetException</a></h1>
+<h1><a class="toc-backref" href="#id529">MagickGetException</a></h1>
 <div class="section" id="id103">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1733,7 +1738,7 @@ char *MagickGetException( const MagickWand *wand, <a class="reference external"
 </div>
 </div>
 <div class="section" id="magickgetfilename">
-<h1><a class="toc-backref" href="#id516">MagickGetFilename</a></h1>
+<h1><a class="toc-backref" href="#id530">MagickGetFilename</a></h1>
 <div class="section" id="id105">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1755,7 +1760,7 @@ const char *MagickGetFilename( const MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgethomeurl">
-<h1><a class="toc-backref" href="#id517">MagickGetHomeURL</a></h1>
+<h1><a class="toc-backref" href="#id531">MagickGetHomeURL</a></h1>
 <div class="section" id="id107">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1772,7 +1777,7 @@ const char *MagickGetHomeURL( void );
 </div>
 </div>
 <div class="section" id="magickgetimage">
-<h1><a class="toc-backref" href="#id518">MagickGetImage</a></h1>
+<h1><a class="toc-backref" href="#id532">MagickGetImage</a></h1>
 <div class="section" id="id109">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1794,7 +1799,7 @@ MagickWand *MagickGetImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimageattribute">
-<h1><a class="toc-backref" href="#id519">MagickGetImageAttribute</a></h1>
+<h1><a class="toc-backref" href="#id533">MagickGetImageAttribute</a></h1>
 <div class="section" id="id111">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1818,7 +1823,7 @@ char *MagickGetImageAttribute( MagickWand *wand, const char *name );
 </div>
 </div>
 <div class="section" id="magickgetimagebackgroundcolor">
-<h1><a class="toc-backref" href="#id520">MagickGetImageBackgroundColor</a></h1>
+<h1><a class="toc-backref" href="#id534">MagickGetImageBackgroundColor</a></h1>
 <div class="section" id="id113">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1841,7 +1846,7 @@ unsigned int MagickGetImageBackgroundColor( MagickWand *wand, PixelWand *backgro
 </div>
 </div>
 <div class="section" id="magickgetimageblueprimary">
-<h1><a class="toc-backref" href="#id521">MagickGetImageBluePrimary</a></h1>
+<h1><a class="toc-backref" href="#id535">MagickGetImageBluePrimary</a></h1>
 <div class="section" id="id115">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1867,7 +1872,7 @@ unsigned int MagickGetImageBluePrimary( MagickWand *wand, double *x, double *y )
 </div>
 </div>
 <div class="section" id="magickgetimagebordercolor">
-<h1><a class="toc-backref" href="#id522">MagickGetImageBorderColor</a></h1>
+<h1><a class="toc-backref" href="#id536">MagickGetImageBorderColor</a></h1>
 <div class="section" id="id117">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1890,7 +1895,7 @@ unsigned int MagickGetImageBorderColor( MagickWand *wand, PixelWand *border_colo
 </div>
 </div>
 <div class="section" id="magickgetimageboundingbox">
-<h1><a class="toc-backref" href="#id523">MagickGetImageBoundingBox</a></h1>
+<h1><a class="toc-backref" href="#id537">MagickGetImageBoundingBox</a></h1>
 <div class="section" id="id119">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1929,7 +1934,7 @@ unsigned int MagickGetImageBoundingBox( MagickWand *wand, const double fuzz,
 </div>
 </div>
 <div class="section" id="magickgetimagechanneldepth">
-<h1><a class="toc-backref" href="#id524">MagickGetImageChannelDepth</a></h1>
+<h1><a class="toc-backref" href="#id538">MagickGetImageChannelDepth</a></h1>
 <div class="section" id="id121">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1954,7 +1959,7 @@ BlackChannel.</dd>
 </div>
 </div>
 <div class="section" id="magickgetimagechannelextrema">
-<h1><a class="toc-backref" href="#id525">MagickGetImageChannelExtrema</a></h1>
+<h1><a class="toc-backref" href="#id539">MagickGetImageChannelExtrema</a></h1>
 <div class="section" id="id123">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -1986,7 +1991,7 @@ or BlackChannel.</dd>
 </div>
 </div>
 <div class="section" id="magickgetimagechannelmean">
-<h1><a class="toc-backref" href="#id526">MagickGetImageChannelMean</a></h1>
+<h1><a class="toc-backref" href="#id540">MagickGetImageChannelMean</a></h1>
 <div class="section" id="id125">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2018,7 +2023,7 @@ or BlackChannel.</dd>
 </div>
 </div>
 <div class="section" id="magickgetimagecolormapcolor">
-<h1><a class="toc-backref" href="#id527">MagickGetImageColormapColor</a></h1>
+<h1><a class="toc-backref" href="#id541">MagickGetImageColormapColor</a></h1>
 <div class="section" id="id127">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2046,7 +2051,7 @@ unsigned int MagickGetImageColormapColor( MagickWand *wand, const unsigned long
 </div>
 </div>
 <div class="section" id="magickgetimagecolors">
-<h1><a class="toc-backref" href="#id528">MagickGetImageColors</a></h1>
+<h1><a class="toc-backref" href="#id542">MagickGetImageColors</a></h1>
 <div class="section" id="id129">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2068,7 +2073,7 @@ unsigned long MagickGetImageColors( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagecolorspace">
-<h1><a class="toc-backref" href="#id529">MagickGetImageColorspace</a></h1>
+<h1><a class="toc-backref" href="#id543">MagickGetImageColorspace</a></h1>
 <div class="section" id="id131">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2090,7 +2095,7 @@ unsigned long MagickGetImageColors( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagecompose">
-<h1><a class="toc-backref" href="#id530">MagickGetImageCompose</a></h1>
+<h1><a class="toc-backref" href="#id544">MagickGetImageCompose</a></h1>
 <div class="section" id="id133">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2113,7 +2118,7 @@ image.</p>
 </div>
 </div>
 <div class="section" id="magickgetimagecompression">
-<h1><a class="toc-backref" href="#id531">MagickGetImageCompression</a></h1>
+<h1><a class="toc-backref" href="#id545">MagickGetImageCompression</a></h1>
 <div class="section" id="id135">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2135,7 +2140,7 @@ image.</p>
 </div>
 </div>
 <div class="section" id="magickgetimagedelay">
-<h1><a class="toc-backref" href="#id532">MagickGetImageDelay</a></h1>
+<h1><a class="toc-backref" href="#id546">MagickGetImageDelay</a></h1>
 <div class="section" id="id137">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2157,7 +2162,7 @@ unsigned long MagickGetImageDelay( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagedepth">
-<h1><a class="toc-backref" href="#id533">MagickGetImageDepth</a></h1>
+<h1><a class="toc-backref" href="#id547">MagickGetImageDepth</a></h1>
 <div class="section" id="id139">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2179,7 +2184,7 @@ unsigned long MagickGetImageDepth( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimageextrema">
-<h1><a class="toc-backref" href="#id534">MagickGetImageExtrema</a></h1>
+<h1><a class="toc-backref" href="#id548">MagickGetImageExtrema</a></h1>
 <div class="section" id="id141">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2206,7 +2211,7 @@ unsigned int MagickGetImageExtrema( MagickWand *wand, unsigned long *min,
 </div>
 </div>
 <div class="section" id="magickgetimagedispose">
-<h1><a class="toc-backref" href="#id535">MagickGetImageDispose</a></h1>
+<h1><a class="toc-backref" href="#id549">MagickGetImageDispose</a></h1>
 <div class="section" id="id143">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2228,7 +2233,7 @@ DisposeType MagickGetImageDispose( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagefilename">
-<h1><a class="toc-backref" href="#id536">MagickGetImageFilename</a></h1>
+<h1><a class="toc-backref" href="#id550">MagickGetImageFilename</a></h1>
 <div class="section" id="id145">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2251,7 +2256,7 @@ const char MagickGetImageFilename( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimageformat">
-<h1><a class="toc-backref" href="#id537">MagickGetImageFormat</a></h1>
+<h1><a class="toc-backref" href="#id551">MagickGetImageFormat</a></h1>
 <div class="section" id="id147">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2274,7 +2279,7 @@ const char MagickGetImageFormat( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagefuzz">
-<h1><a class="toc-backref" href="#id538">MagickGetImageFuzz</a></h1>
+<h1><a class="toc-backref" href="#id552">MagickGetImageFuzz</a></h1>
 <div class="section" id="id149">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2299,7 +2304,7 @@ double MagickGetImageFuzz( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagegamma">
-<h1><a class="toc-backref" href="#id539">MagickGetImageGamma</a></h1>
+<h1><a class="toc-backref" href="#id553">MagickGetImageGamma</a></h1>
 <div class="section" id="id151">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2321,7 +2326,7 @@ double MagickGetImageGamma( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagegravity">
-<h1><a class="toc-backref" href="#id540">MagickGetImageGravity</a></h1>
+<h1><a class="toc-backref" href="#id554">MagickGetImageGravity</a></h1>
 <div class="section" id="id153">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2343,7 +2348,7 @@ double MagickGetImageGamma( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagegreenprimary">
-<h1><a class="toc-backref" href="#id541">MagickGetImageGreenPrimary</a></h1>
+<h1><a class="toc-backref" href="#id555">MagickGetImageGreenPrimary</a></h1>
 <div class="section" id="id155">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2368,7 +2373,7 @@ unsigned int MagickGetImageGreenPrimary( MagickWand *wand, double *x, double *y
 </div>
 </div>
 <div class="section" id="magickgetimageheight">
-<h1><a class="toc-backref" href="#id542">MagickGetImageHeight</a></h1>
+<h1><a class="toc-backref" href="#id556">MagickGetImageHeight</a></h1>
 <div class="section" id="id157">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2390,7 +2395,7 @@ unsigned long MagickGetImageHeight( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagehistogram">
-<h1><a class="toc-backref" href="#id543">MagickGetImageHistogram</a></h1>
+<h1><a class="toc-backref" href="#id557">MagickGetImageHistogram</a></h1>
 <div class="section" id="id159">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2415,7 +2420,7 @@ of pixel wands returned.</dd>
 </div>
 </div>
 <div class="section" id="magickgetimageindex">
-<h1><a class="toc-backref" href="#id544">MagickGetImageIndex</a></h1>
+<h1><a class="toc-backref" href="#id558">MagickGetImageIndex</a></h1>
 <div class="section" id="id161">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2437,7 +2442,7 @@ unsigned int MagickGetImageIndex( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimageinterlacescheme">
-<h1><a class="toc-backref" href="#id545">MagickGetImageInterlaceScheme</a></h1>
+<h1><a class="toc-backref" href="#id559">MagickGetImageInterlaceScheme</a></h1>
 <div class="section" id="id163">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2459,7 +2464,7 @@ unsigned int MagickGetImageIndex( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimageiterations">
-<h1><a class="toc-backref" href="#id546">MagickGetImageIterations</a></h1>
+<h1><a class="toc-backref" href="#id560">MagickGetImageIterations</a></h1>
 <div class="section" id="id165">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2481,7 +2486,7 @@ unsigned long MagickGetImageIterations( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagemattecolor">
-<h1><a class="toc-backref" href="#id547">MagickGetImageMatteColor</a></h1>
+<h1><a class="toc-backref" href="#id561">MagickGetImageMatteColor</a></h1>
 <div class="section" id="id167">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2504,7 +2509,7 @@ unsigned int MagickGetImageMatteColor( MagickWand *wand, PixelWand *matte_color
 </div>
 </div>
 <div class="section" id="magickgetimageorientation">
-<h1><a class="toc-backref" href="#id548">MagickGetImageOrientation</a></h1>
+<h1><a class="toc-backref" href="#id562">MagickGetImageOrientation</a></h1>
 <div class="section" id="id169">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2535,7 +2540,7 @@ OrientationType MagickGetImageOrientation( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagepage">
-<h1><a class="toc-backref" href="#id549">MagickGetImagePage</a></h1>
+<h1><a class="toc-backref" href="#id563">MagickGetImagePage</a></h1>
 <div class="section" id="id171">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2564,7 +2569,7 @@ which to composite image data.</dd>
 </div>
 </div>
 <div class="section" id="magickgetimagepixels">
-<h1><a class="toc-backref" href="#id550">MagickGetImagePixels</a></h1>
+<h1><a class="toc-backref" href="#id564">MagickGetImagePixels</a></h1>
 <div class="section" id="id173">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2614,7 +2619,7 @@ length varies depending on the values of width, height, map, and type.</dd>
 </div>
 </div>
 <div class="section" id="magickgetimageprofile">
-<h1><a class="toc-backref" href="#id551">MagickGetImageProfile</a></h1>
+<h1><a class="toc-backref" href="#id565">MagickGetImageProfile</a></h1>
 <div class="section" id="id175">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2641,7 +2646,7 @@ unsigned char *MagickGetImageProfile( MagickWand *wand, const char *name,
 </div>
 </div>
 <div class="section" id="magickgetimageredprimary">
-<h1><a class="toc-backref" href="#id552">MagickGetImageRedPrimary</a></h1>
+<h1><a class="toc-backref" href="#id566">MagickGetImageRedPrimary</a></h1>
 <div class="section" id="id177">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2666,7 +2671,7 @@ unsigned int MagickGetImageRedPrimary( MagickWand *wand, double *x, double *y );
 </div>
 </div>
 <div class="section" id="magickgetimagerenderingintent">
-<h1><a class="toc-backref" href="#id553">MagickGetImageRenderingIntent</a></h1>
+<h1><a class="toc-backref" href="#id567">MagickGetImageRenderingIntent</a></h1>
 <div class="section" id="id179">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2688,7 +2693,7 @@ unsigned int MagickGetImageRedPrimary( MagickWand *wand, double *x, double *y );
 </div>
 </div>
 <div class="section" id="magickgetimageresolution">
-<h1><a class="toc-backref" href="#id554">MagickGetImageResolution</a></h1>
+<h1><a class="toc-backref" href="#id568">MagickGetImageResolution</a></h1>
 <div class="section" id="id181">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2713,7 +2718,7 @@ unsigned int MagickGetImageResolution( MagickWand *wand, double *x, double *y );
 </div>
 </div>
 <div class="section" id="magickgetimagescene">
-<h1><a class="toc-backref" href="#id555">MagickGetImageScene</a></h1>
+<h1><a class="toc-backref" href="#id569">MagickGetImageScene</a></h1>
 <div class="section" id="id183">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2735,7 +2740,7 @@ unsigned long MagickGetImageScene( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagesignature">
-<h1><a class="toc-backref" href="#id556">MagickGetImageSignature</a></h1>
+<h1><a class="toc-backref" href="#id570">MagickGetImageSignature</a></h1>
 <div class="section" id="id185">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2758,7 +2763,7 @@ const char MagickGetImageSignature( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagesize">
-<h1><a class="toc-backref" href="#id557">MagickGetImageSize</a></h1>
+<h1><a class="toc-backref" href="#id571">MagickGetImageSize</a></h1>
 <div class="section" id="id187">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2780,7 +2785,7 @@ MagickSizeType MagickGetImageSize( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagetype">
-<h1><a class="toc-backref" href="#id558">MagickGetImageType</a></h1>
+<h1><a class="toc-backref" href="#id572">MagickGetImageType</a></h1>
 <div class="section" id="id189">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2802,7 +2807,7 @@ MagickSizeType MagickGetImageSize( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetimagesavedtype">
-<h1><a class="toc-backref" href="#id559">MagickGetImageSavedType</a></h1>
+<h1><a class="toc-backref" href="#id573">MagickGetImageSavedType</a></h1>
 <div class="section" id="id191">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2826,7 +2831,7 @@ by MagickGetImageType().</p>
 </div>
 </div>
 <div class="section" id="magickgetimageunits">
-<h1><a class="toc-backref" href="#id560">MagickGetImageUnits</a></h1>
+<h1><a class="toc-backref" href="#id574">MagickGetImageUnits</a></h1>
 <div class="section" id="id193">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2848,7 +2853,7 @@ by MagickGetImageType().</p>
 </div>
 </div>
 <div class="section" id="magickgetimagevirtualpixelmethod">
-<h1><a class="toc-backref" href="#id561">MagickGetImageVirtualPixelMethod</a></h1>
+<h1><a class="toc-backref" href="#id575">MagickGetImageVirtualPixelMethod</a></h1>
 <div class="section" id="id195">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2871,7 +2876,7 @@ sepcified image.</p>
 </div>
 </div>
 <div class="section" id="magickgetimagewhitepoint">
-<h1><a class="toc-backref" href="#id562">MagickGetImageWhitePoint</a></h1>
+<h1><a class="toc-backref" href="#id576">MagickGetImageWhitePoint</a></h1>
 <div class="section" id="id197">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2896,7 +2901,7 @@ unsigned int MagickGetImageWhitePoint( MagickWand *wand, double *x, double *y );
 </div>
 </div>
 <div class="section" id="magickgetimagewidth">
-<h1><a class="toc-backref" href="#id563">MagickGetImageWidth</a></h1>
+<h1><a class="toc-backref" href="#id577">MagickGetImageWidth</a></h1>
 <div class="section" id="id199">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2918,7 +2923,7 @@ unsigned long MagickGetImageWidth( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetnumberimages">
-<h1><a class="toc-backref" href="#id564">MagickGetNumberImages</a></h1>
+<h1><a class="toc-backref" href="#id578">MagickGetNumberImages</a></h1>
 <div class="section" id="id201">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2941,7 +2946,7 @@ unsigned long MagickGetNumberImages( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickgetpackagename">
-<h1><a class="toc-backref" href="#id565">MagickGetPackageName</a></h1>
+<h1><a class="toc-backref" href="#id579">MagickGetPackageName</a></h1>
 <div class="section" id="id203">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2958,7 +2963,7 @@ const char *MagickGetPackageName( void );
 </div>
 </div>
 <div class="section" id="magickgetquantumdepth">
-<h1><a class="toc-backref" href="#id566">MagickGetQuantumDepth</a></h1>
+<h1><a class="toc-backref" href="#id580">MagickGetQuantumDepth</a></h1>
 <div class="section" id="id205">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2980,7 +2985,7 @@ const char *MagickGetQuantumDepth( unsigned long *depth );
 </div>
 </div>
 <div class="section" id="magickgetreleasedate">
-<h1><a class="toc-backref" href="#id567">MagickGetReleaseDate</a></h1>
+<h1><a class="toc-backref" href="#id581">MagickGetReleaseDate</a></h1>
 <div class="section" id="id207">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -2997,7 +3002,7 @@ const char *MagickGetReleaseDate( void );
 </div>
 </div>
 <div class="section" id="magickgetresourcelimit">
-<h1><a class="toc-backref" href="#id568">MagickGetResourceLimit</a></h1>
+<h1><a class="toc-backref" href="#id582">MagickGetResourceLimit</a></h1>
 <div class="section" id="id209">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -3019,7 +3024,7 @@ unsigned long MagickGetResourceLimit( const <a class="reference external" href="
 </div>
 </div>
 <div class="section" id="magickgetsamplingfactors">
-<h1><a class="toc-backref" href="#id569">MagickGetSamplingFactors</a></h1>
+<h1><a class="toc-backref" href="#id583">MagickGetSamplingFactors</a></h1>
 <div class="section" id="id211">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -3042,7 +3047,7 @@ double *MagickGetSamplingFactors( MagickWand *wand, unsigned long *number_factor
 </div>
 </div>
 <div class="section" id="magickgetsize">
-<h1><a class="toc-backref" href="#id570">MagickGetSize</a></h1>
+<h1><a class="toc-backref" href="#id584">MagickGetSize</a></h1>
 <div class="section" id="id213">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -3069,7 +3074,7 @@ unsigned int MagickGetSize( const MagickWand *wand, unsigned long *columns,
 </div>
 </div>
 <div class="section" id="magickgetversion">
-<h1><a class="toc-backref" href="#id571">MagickGetVersion</a></h1>
+<h1><a class="toc-backref" href="#id585">MagickGetVersion</a></h1>
 <div class="section" id="id215">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -3092,7 +3097,7 @@ const char *MagickGetVersion( unsigned long *version );
 </div>
 </div>
 <div class="section" id="magickhaldclutimage">
-<h1><a class="toc-backref" href="#id572">MagickHaldClutImage</a></h1>
+<h1><a class="toc-backref" href="#id586">MagickHaldClutImage</a></h1>
 <div class="section" id="id217">
 <h2>Synopsis</h2>
 <pre class="literal-block">
@@ -3132,15 +3137,41 @@ MagickPassFail MagickHaldClutImage( MagickWand *wand, const MagickWand *clut_wan
 </dl>
 </div>
 </div>
-<div class="section" id="magickhasnextimage">
-<h1><a class="toc-backref" href="#id573">MagickHasNextImage</a></h1>
+<div class="section" id="magickhascolormap">
+<h1><a class="toc-backref" href="#id587">MagickHasColorMap</a></h1>
 <div class="section" id="id219">
 <h2>Synopsis</h2>
+<p>None</p>
+</div>
+<div class="section" id="id220">
+<h2>Description</h2>
+<p>MagickHasColormap() returns True if the check was successful with the
+colormap parameter set to a boolean value indicating whether the current
+wand image uses a color map or not. Returns False if there are no wand
+images available.</p>
+<p>The format of the MagickHasColormap method is:</p>
+<p>unsigned int MagickHasColormap(MagickWand <a href="#id221"><span class="problematic" id="id222">*</span></a>wand,
+unsigned int <a href="#id223"><span class="problematic" id="id224">*</span></a>colormap)</p>
+<div class="system-message" id="id221">
+<p class="system-message-title">System Message: WARNING/2 (<tt class="docutils">/home/bfriesen/src/graphics/GM/www/wand/magick_wand.apirst</tt>, line 3413); <em><a href="#id222">backlink</a></em></p>
+Inline emphasis start-string without end-string.</div>
+<div class="system-message" id="id223">
+<p class="system-message-title">System Message: WARNING/2 (<tt class="docutils">/home/bfriesen/src/graphics/GM/www/wand/magick_wand.apirst</tt>, line 3413); <em><a href="#id224">backlink</a></em></p>
+Inline emphasis start-string without end-string.</div>
+<p>A description of each parameter follows:</p>
+<p>o wand: The magick wand.</p>
+<p>o colormap: Set to True if current image uses a color map, False if not.</p>
+</div>
+</div>
+<div class="section" id="magickhasnextimage">
+<h1><a class="toc-backref" href="#id588">MagickHasNextImage</a></h1>
+<div class="section" id="id225">
+<h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickHasNextImage( MagickWand *wand );
 </pre>
 </div>
-<div class="section" id="id220">
+<div class="section" id="id226">
 <h2>Description</h2>
 <p>MagickHasNextImage() returns True if the wand has more images when
 traversing the list in the forward direction</p>
@@ -3156,14 +3187,14 @@ unsigned int MagickHasNextImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickhaspreviousimage">
-<h1><a class="toc-backref" href="#id574">MagickHasPreviousImage</a></h1>
-<div class="section" id="id221">
+<h1><a class="toc-backref" href="#id589">MagickHasPreviousImage</a></h1>
+<div class="section" id="id227">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickHasPreviousImage( MagickWand *wand );
 </pre>
 </div>
-<div class="section" id="id222">
+<div class="section" id="id228">
 <h2>Description</h2>
 <p>MagickHasPreviousImage() returns True if the wand has more images when
 traversing the list in the reverse direction</p>
@@ -3179,14 +3210,14 @@ unsigned int MagickHasPreviousImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickimplodeimage">
-<h1><a class="toc-backref" href="#id575">MagickImplodeImage</a></h1>
-<div class="section" id="id223">
+<h1><a class="toc-backref" href="#id590">MagickImplodeImage</a></h1>
+<div class="section" id="id229">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickImplodeImage( MagickWand *wand, const double radius );
 </pre>
 </div>
-<div class="section" id="id224">
+<div class="section" id="id230">
 <h2>Description</h2>
 <p>MagickImplodeImage() creates a new image that is a copy of an existing
 one with the image pixels &quot;implode&quot; by the specified percentage.  It
@@ -3205,15 +3236,125 @@ unsigned int MagickImplodeImage( MagickWand *wand, const double radius );
 </dl>
 </div>
 </div>
+<div class="section" id="magickisgrayimage">
+<h1><a class="toc-backref" href="#id591">MagickIsGrayImage</a></h1>
+<div class="section" id="id231">
+<h2>Synopsis</h2>
+<pre class="literal-block">
+unsigned int MagickIsGrayImage( MagickWand *wand, unsigned int *grayimage );
+</pre>
+</div>
+<div class="section" id="id232">
+<h2>Description</h2>
+<p>MagickIsGrayImage() returns True if the check was successful with the
+grayimage parameter set to a boolean value indicating whether the current
+wand image is a gray-scale image or not. Returns False if there was
+an error.</p>
+<p>The format of the MagickIsGrayImage method is:</p>
+<pre class="literal-block">
+unsigned int MagickIsGrayImage( MagickWand *wand, unsigned int *grayimage );
+</pre>
+<dl class="docutils">
+<dt>wand:</dt>
+<dd>The magick wand.</dd>
+<dt>grayimage:</dt>
+<dd>Set to True if current image is a gray-scale image,
+False if not.</dd>
+</dl>
+</div>
+</div>
+<div class="section" id="magickismonochromeimage">
+<h1><a class="toc-backref" href="#id592">MagickIsMonochromeImage</a></h1>
+<div class="section" id="id233">
+<h2>Synopsis</h2>
+<pre class="literal-block">
+unsigned int MagickIsMonochromeImage( MagickWand *wand, unsigned int *monochrome );
+</pre>
+</div>
+<div class="section" id="id234">
+<h2>Description</h2>
+<p>MagickIsMonochromeImage() returns True if the check was successful with the
+monochrome parameter set to a boolean value indicating whether the current
+wand image is a monochrome image or not. Returns False if there was
+an error.</p>
+<p>The format of the MagickIsMonochromeImage method is:</p>
+<pre class="literal-block">
+unsigned int MagickIsMonochromeImage( MagickWand *wand, unsigned int *monochrome );
+</pre>
+<dl class="docutils">
+<dt>wand:</dt>
+<dd>The magick wand.</dd>
+<dt>monochrome:</dt>
+<dd>Set to True if current image is a monochrome image,
+False if not.</dd>
+</dl>
+</div>
+</div>
+<div class="section" id="magickisopaqueimage">
+<h1><a class="toc-backref" href="#id593">MagickIsOpaqueImage</a></h1>
+<div class="section" id="id235">
+<h2>Synopsis</h2>
+<pre class="literal-block">
+unsigned int MagickIsOpaqueImage( MagickWand *wand, unsigned int *opaque );
+</pre>
+</div>
+<div class="section" id="id236">
+<h2>Description</h2>
+<p>MagickIsOpaqueImage() returns True if the check was successful with the
+opaque parameter set to a boolean value indicating whether the current
+wand image is entirely opaque or not. Returns False if there was
+an error.</p>
+<p>The format of the MagickIsOpaqueImage method is:</p>
+<pre class="literal-block">
+unsigned int MagickIsOpaqueImage( MagickWand *wand, unsigned int *opaque );
+</pre>
+<dl class="docutils">
+<dt>wand:</dt>
+<dd>The magick wand.</dd>
+<dt>opaque:</dt>
+<dd>Set to True if current image is entirely opaque,
+False if not.</dd>
+</dl>
+</div>
+</div>
+<div class="section" id="magickispaletteimage">
+<h1><a class="toc-backref" href="#id594">MagickIsPaletteImage</a></h1>
+<div class="section" id="id237">
+<h2>Synopsis</h2>
+<pre class="literal-block">
+unsigned int MagickIsPaletteImage( MagickWand *wand, unsigned int *palette );
+</pre>
+</div>
+<div class="section" id="id238">
+<h2>Description</h2>
+<p>MagickIsPaletteImage() returns True if the check was successful with the
+palette parameter set to a boolean value indicating whether the current
+wand image is an image with 256 unique colors or less. Returns False if
+there was an error. Note that a palette image does not necessarily use a
+colormap. See MagickHasColormap() if needing to determine whether a
+colormap is in use.</p>
+<p>The format of the MagickIsPaletteImage method is:</p>
+<pre class="literal-block">
+unsigned int MagickIsPaletteImage( MagickWand *wand, unsigned int *palette );
+</pre>
+<dl class="docutils">
+<dt>wand:</dt>
+<dd>The magick wand.</dd>
+<dt>palette:</dt>
+<dd>Set to True if current image is 256 colors or less,
+False if not.</dd>
+</dl>
+</div>
+</div>
 <div class="section" id="magicklabelimage">
-<h1><a class="toc-backref" href="#id576">MagickLabelImage</a></h1>
-<div class="section" id="id225">
+<h1><a class="toc-backref" href="#id595">MagickLabelImage</a></h1>
+<div class="section" id="id239">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickLabelImage( MagickWand *wand, const char *label );
 </pre>
 </div>
-<div class="section" id="id226">
+<div class="section" id="id240">
 <h2>Description</h2>
 <p>MagickLabelImage() adds a label to your image.</p>
 <p>The format of the MagickLabelImage method is:</p>
@@ -3230,15 +3371,15 @@ unsigned int MagickLabelImage( MagickWand *wand, const char *label );
 </div>
 </div>
 <div class="section" id="magicklevelimage">
-<h1><a class="toc-backref" href="#id577">MagickLevelImage</a></h1>
-<div class="section" id="id227">
+<h1><a class="toc-backref" href="#id596">MagickLevelImage</a></h1>
+<div class="section" id="id241">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickLevelImage( MagickWand *wand, const double black_point, const double gamma,
                                const double white_point );
 </pre>
 </div>
-<div class="section" id="id228">
+<div class="section" id="id242">
 <h2>Description</h2>
 <p>MagickLevelImage() adjusts the levels of an image by scaling the colors
 falling between specified white and black points to the full available
@@ -3266,8 +3407,8 @@ unsigned int MagickLevelImage( MagickWand *wand, const double black_point, const
 </div>
 </div>
 <div class="section" id="magicklevelimagechannel">
-<h1><a class="toc-backref" href="#id578">MagickLevelImageChannel</a></h1>
-<div class="section" id="id229">
+<h1><a class="toc-backref" href="#id597">MagickLevelImageChannel</a></h1>
+<div class="section" id="id243">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickLevelImageChannel( MagickWand *wand, const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel,
@@ -3275,7 +3416,7 @@ unsigned int MagickLevelImageChannel( MagickWand *wand, const <a class="referenc
                                       const double white_point );
 </pre>
 </div>
-<div class="section" id="id230">
+<div class="section" id="id244">
 <h2>Description</h2>
 <p>MagickLevelImageChannel() adjusts the levels of the specified channel of
 the reference image by scaling the colors falling between specified white
@@ -3308,14 +3449,14 @@ BlackChannel.</dd>
 </div>
 </div>
 <div class="section" id="magickmagnifyimage">
-<h1><a class="toc-backref" href="#id579">MagickMagnifyImage</a></h1>
-<div class="section" id="id231">
+<h1><a class="toc-backref" href="#id598">MagickMagnifyImage</a></h1>
+<div class="section" id="id245">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickMagnifyImage( MagickWand *wand );
 </pre>
 </div>
-<div class="section" id="id232">
+<div class="section" id="id246">
 <h2>Description</h2>
 <p>MagickMagnifyImage() is a convenience method that scales an image
 proportionally to twice its original size.</p>
@@ -3331,15 +3472,15 @@ unsigned int MagickMagnifyImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickmapimage">
-<h1><a class="toc-backref" href="#id580">MagickMapImage</a></h1>
-<div class="section" id="id233">
+<h1><a class="toc-backref" href="#id599">MagickMapImage</a></h1>
+<div class="section" id="id247">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickMapImage( MagickWand *wand, const MagickWand *map_wand,
                              const unsigned int dither );
 </pre>
 </div>
-<div class="section" id="id234">
+<div class="section" id="id248">
 <h2>Description</h2>
 <p>MagickMapImage() replaces the colors of an image with the closest color
 from a reference image.</p>
@@ -3360,8 +3501,8 @@ the mapped image.</dd>
 </div>
 </div>
 <div class="section" id="magickmattefloodfillimage">
-<h1><a class="toc-backref" href="#id581">MagickMatteFloodfillImage</a></h1>
-<div class="section" id="id235">
+<h1><a class="toc-backref" href="#id600">MagickMatteFloodfillImage</a></h1>
+<div class="section" id="id249">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickMatteFloodfillImage( MagickWand *wand, const <a class="reference external" href="../api/types.html#quantum">Quantum</a> opacity,
@@ -3369,7 +3510,7 @@ unsigned int MagickMatteFloodfillImage( MagickWand *wand, const <a class="refere
                                         const long x, const long y );
 </pre>
 </div>
-<div class="section" id="id236">
+<div class="section" id="id250">
 <h2>Description</h2>
 <p>MagickMatteFloodfillImage() changes the transparency value of any pixel that
 matches target and is an immediate neighbor.  If the method
@@ -3401,14 +3542,14 @@ as the same color for the purposes of the floodfill.</dd>
 </div>
 </div>
 <div class="section" id="magickmedianfilterimage">
-<h1><a class="toc-backref" href="#id582">MagickMedianFilterImage</a></h1>
-<div class="section" id="id237">
+<h1><a class="toc-backref" href="#id601">MagickMedianFilterImage</a></h1>
+<div class="section" id="id251">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickMedianFilterImage( MagickWand *wand, const double radius );
 </pre>
 </div>
-<div class="section" id="id238">
+<div class="section" id="id252">
 <h2>Description</h2>
 <p>MagickMedianFilterImage() applies a digital filter that improves the quality
 of a noisy image.  Each pixel is replaced by the median in a set of
@@ -3426,14 +3567,14 @@ unsigned int MagickMedianFilterImage( MagickWand *wand, const double radius );
 </div>
 </div>
 <div class="section" id="magickminifyimage">
-<h1><a class="toc-backref" href="#id583">MagickMinifyImage</a></h1>
-<div class="section" id="id239">
+<h1><a class="toc-backref" href="#id602">MagickMinifyImage</a></h1>
+<div class="section" id="id253">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickMinifyImage( MagickWand *wand );
 </pre>
 </div>
-<div class="section" id="id240">
+<div class="section" id="id254">
 <h2>Description</h2>
 <p>MagickMinifyImage() is a convenience method that scales an image
 proportionally to one-half its original size</p>
@@ -3449,15 +3590,15 @@ unsigned int MagickMinifyImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickmodulateimage">
-<h1><a class="toc-backref" href="#id584">MagickModulateImage</a></h1>
-<div class="section" id="id241">
+<h1><a class="toc-backref" href="#id603">MagickModulateImage</a></h1>
+<div class="section" id="id255">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickModulateImage( MagickWand *wand, const double brightness,
                                   const double saturation, const double hue );
 </pre>
 </div>
-<div class="section" id="id242">
+<div class="section" id="id256">
 <h2>Description</h2>
 <p>MagickModulateImage() lets you control the brightness, saturation, and hue
 of an image.</p>
@@ -3479,8 +3620,8 @@ unsigned int MagickModulateImage( MagickWand *wand, const double brightness,
 </div>
 </div>
 <div class="section" id="magickmontageimage">
-<h1><a class="toc-backref" href="#id585">MagickMontageImage</a></h1>
-<div class="section" id="id243">
+<h1><a class="toc-backref" href="#id604">MagickMontageImage</a></h1>
+<div class="section" id="id257">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickWand MagickMontageImage( MagickWand *wand, const DrawingWand drawing_wand,
@@ -3488,7 +3629,7 @@ MagickWand MagickMontageImage( MagickWand *wand, const DrawingWand drawing_wand,
                                const MontageMode mode, const char *frame );
 </pre>
 </div>
-<div class="section" id="id244">
+<div class="section" id="id258">
 <h2>Description</h2>
 <p>Use MagickMontageImage() to create a composite image by combining several
 separate images. The images are tiled on the composite image with the name
@@ -3519,14 +3660,14 @@ The frame color is that of the thumbnail's matte color.</dd>
 </div>
 </div>
 <div class="section" id="magickmorphimages">
-<h1><a class="toc-backref" href="#id586">MagickMorphImages</a></h1>
-<div class="section" id="id245">
+<h1><a class="toc-backref" href="#id605">MagickMorphImages</a></h1>
+<div class="section" id="id259">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickWand *MagickMorphImages( MagickWand *wand, const unsigned long number_frames );
 </pre>
 </div>
-<div class="section" id="id246">
+<div class="section" id="id260">
 <h2>Description</h2>
 <p>MagickMorphImages() method morphs a set of images.  Both the image pixels
 and size are linearly interpolated to give the appearance of a
@@ -3544,14 +3685,14 @@ MagickWand *MagickMorphImages( MagickWand *wand, const unsigned long number_fram
 </div>
 </div>
 <div class="section" id="magickmosaicimages">
-<h1><a class="toc-backref" href="#id587">MagickMosaicImages</a></h1>
-<div class="section" id="id247">
+<h1><a class="toc-backref" href="#id606">MagickMosaicImages</a></h1>
+<div class="section" id="id261">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickWand *MagickMosaicImages( MagickWand *wand );
 </pre>
 </div>
-<div class="section" id="id248">
+<div class="section" id="id262">
 <h2>Description</h2>
 <p>MagickMosaicImages() inlays an image sequence to form a single coherent
 picture.  It returns a wand with each image in the sequence composited at
@@ -3568,15 +3709,15 @@ MagickWand *MagickMosaicImages( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickmotionblurimage">
-<h1><a class="toc-backref" href="#id588">MagickMotionBlurImage</a></h1>
-<div class="section" id="id249">
+<h1><a class="toc-backref" href="#id607">MagickMotionBlurImage</a></h1>
+<div class="section" id="id263">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickMotionBlurImage( MagickWand *wand, const double radius, const double sigma,
                                     const double angle );
 </pre>
 </div>
-<div class="section" id="id250">
+<div class="section" id="id264">
 <h2>Description</h2>
 <p>MagickMotionBlurImage() simulates motion blur.  We convolve the image with a
 Gaussian operator of the given radius and standard deviation (sigma).
@@ -3602,14 +3743,14 @@ the center pixel.</dd>
 </div>
 </div>
 <div class="section" id="magicknegateimage">
-<h1><a class="toc-backref" href="#id589">MagickNegateImage</a></h1>
-<div class="section" id="id251">
+<h1><a class="toc-backref" href="#id608">MagickNegateImage</a></h1>
+<div class="section" id="id265">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickNegateImage( MagickWand *wand, const unsigned int gray );
 </pre>
 </div>
-<div class="section" id="id252">
+<div class="section" id="id266">
 <h2>Description</h2>
 <p>MagickNegateImage() negates the colors in the reference image.  The
 Grayscale option means that only grayscale values within the image are
@@ -3630,15 +3771,15 @@ unsigned int MagickNegateImage( MagickWand *wand, const unsigned int gray );
 </div>
 </div>
 <div class="section" id="magicknegateimagechannel">
-<h1><a class="toc-backref" href="#id590">MagickNegateImageChannel</a></h1>
-<div class="section" id="id253">
+<h1><a class="toc-backref" href="#id609">MagickNegateImageChannel</a></h1>
+<div class="section" id="id267">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickNegateImageChannel( MagickWand *wand, const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel,
                                        const unsigned int gray );
 </pre>
 </div>
-<div class="section" id="id254">
+<div class="section" id="id268">
 <h2>Description</h2>
 <p>MagickNegateImageChannel() negates the colors in the specified channel of the
 reference image.  The Grayscale option means that only grayscale values
@@ -3664,14 +3805,14 @@ BlackChannel.</dd>
 </div>
 </div>
 <div class="section" id="magicknextimage">
-<h1><a class="toc-backref" href="#id591">MagickNextImage</a></h1>
-<div class="section" id="id255">
+<h1><a class="toc-backref" href="#id610">MagickNextImage</a></h1>
+<div class="section" id="id269">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickNextImage( MagickWand *wand );
 </pre>
 </div>
-<div class="section" id="id256">
+<div class="section" id="id270">
 <h2>Description</h2>
 <p>MagickNextImage() associates the next image in the image list with a magick
 wand.  True is returned if the Wand iterated to a next image, or False is
@@ -3688,14 +3829,14 @@ unsigned int MagickNextImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magicknormalizeimage">
-<h1><a class="toc-backref" href="#id592">MagickNormalizeImage</a></h1>
-<div class="section" id="id257">
+<h1><a class="toc-backref" href="#id611">MagickNormalizeImage</a></h1>
+<div class="section" id="id271">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickNormalizeImage( MagickWand *wand );
 </pre>
 </div>
-<div class="section" id="id258">
+<div class="section" id="id272">
 <h2>Description</h2>
 <p>MagickNormalizeImage() enhances the contrast of a color image by adjusting
 the pixels color to span the entire range of colors available</p>
@@ -3713,14 +3854,14 @@ unsigned int MagickNormalizeImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickoilpaintimage">
-<h1><a class="toc-backref" href="#id593">MagickOilPaintImage</a></h1>
-<div class="section" id="id259">
+<h1><a class="toc-backref" href="#id612">MagickOilPaintImage</a></h1>
+<div class="section" id="id273">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickOilPaintImage( MagickWand *wand, const double radius );
 </pre>
 </div>
-<div class="section" id="id260">
+<div class="section" id="id274">
 <h2>Description</h2>
 <p>MagickOilPaintImage() applies a special effect filter that simulates an oil
 painting.  Each pixel is replaced by the most frequent color occurring
@@ -3739,15 +3880,15 @@ unsigned int MagickOilPaintImage( MagickWand *wand, const double radius );
 </div>
 </div>
 <div class="section" id="magickopaqueimage">
-<h1><a class="toc-backref" href="#id594">MagickOpaqueImage</a></h1>
-<div class="section" id="id261">
+<h1><a class="toc-backref" href="#id613">MagickOpaqueImage</a></h1>
+<div class="section" id="id275">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickOpaqueImage( MagickWand *wand, const PixelWand *target,
                                 const PixelWand *fill, const double fuzz );
 </pre>
 </div>
-<div class="section" id="id262">
+<div class="section" id="id276">
 <h2>Description</h2>
 <p>MagickOpaqueImage() changes any pixel that matches color with the color
 defined by fill.</p>
@@ -3774,14 +3915,14 @@ as the same color for the purposes of the floodfill.</dd>
 </div>
 </div>
 <div class="section" id="magickpingimage">
-<h1><a class="toc-backref" href="#id595">MagickPingImage</a></h1>
-<div class="section" id="id263">
+<h1><a class="toc-backref" href="#id614">MagickPingImage</a></h1>
+<div class="section" id="id277">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickPingImage( MagickWand *wand, const char *filename );
 </pre>
 </div>
-<div class="section" id="id264">
+<div class="section" id="id278">
 <h2>Description</h2>
 <p>MagickPingImage() is like MagickReadImage() except the only valid
 information returned is the image width, height, size, and format.  It
@@ -3801,14 +3942,14 @@ unsigned int MagickPingImage( MagickWand *wand, const char *filename );
 </div>
 </div>
 <div class="section" id="magickpreviewimages">
-<h1><a class="toc-backref" href="#id596">MagickPreviewImages</a></h1>
-<div class="section" id="id265">
+<h1><a class="toc-backref" href="#id615">MagickPreviewImages</a></h1>
+<div class="section" id="id279">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickWand *MagickPreviewImages( MagickWand *wand, const PreviewType preview );
 </pre>
 </div>
-<div class="section" id="id266">
+<div class="section" id="id280">
 <h2>Description</h2>
 <p>MagickPreviewImages() tiles 9 thumbnails of the specified image with an
 image processing operation applied at varying strengths.  This is helpful
@@ -3827,14 +3968,14 @@ MagickWand *MagickPreviewImages( MagickWand *wand, const PreviewType preview );
 </div>
 </div>
 <div class="section" id="magickpreviousimage">
-<h1><a class="toc-backref" href="#id597">MagickPreviousImage</a></h1>
-<div class="section" id="id267">
+<h1><a class="toc-backref" href="#id616">MagickPreviousImage</a></h1>
+<div class="section" id="id281">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickPreviousImage( MagickWand *wand );
 </pre>
 </div>
-<div class="section" id="id268">
+<div class="section" id="id282">
 <h2>Description</h2>
 <p>MagickPreviousImage() selects the previous image associated with a magick
 wand.</p>
@@ -3850,15 +3991,15 @@ unsigned int MagickPreviousImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickprofileimage">
-<h1><a class="toc-backref" href="#id598">MagickProfileImage</a></h1>
-<div class="section" id="id269">
+<h1><a class="toc-backref" href="#id617">MagickProfileImage</a></h1>
+<div class="section" id="id283">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickProfileImage( MagickWand *wand, const char *name,
                                  const unsigned char *profile, const size_t length );
 </pre>
 </div>
-<div class="section" id="id270">
+<div class="section" id="id284">
 <h2>Description</h2>
 <p>Use MagickProfileImage() to add or remove a ICC, IPTC, or generic profile
 from an image.  If the profile is NULL, it is removed from the image
@@ -3882,8 +4023,8 @@ unsigned int MagickProfileImage( MagickWand *wand, const char *name,
 </div>
 </div>
 <div class="section" id="magickquantizeimage">
-<h1><a class="toc-backref" href="#id599">MagickQuantizeImage</a></h1>
-<div class="section" id="id271">
+<h1><a class="toc-backref" href="#id618">MagickQuantizeImage</a></h1>
+<div class="section" id="id285">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickQuantizeImage( MagickWand *wand, const unsigned long number_colors,
@@ -3892,7 +4033,7 @@ unsigned int MagickQuantizeImage( MagickWand *wand, const unsigned long number_c
                                   const unsigned int measure_error );
 </pre>
 </div>
-<div class="section" id="id272">
+<div class="section" id="id286">
 <h2>Description</h2>
 <p>MagickQuantizeImage() analyzes the colors within a reference image and
 chooses a fixed number of colors to represent the image.  The goal of the
@@ -3935,8 +4076,8 @@ pixel value and its quantized value.</dd>
 </div>
 </div>
 <div class="section" id="magickquantizeimages">
-<h1><a class="toc-backref" href="#id600">MagickQuantizeImages</a></h1>
-<div class="section" id="id273">
+<h1><a class="toc-backref" href="#id619">MagickQuantizeImages</a></h1>
+<div class="section" id="id287">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickQuantizeImages( MagickWand *wand, const unsigned long number_colors,
@@ -3945,7 +4086,7 @@ unsigned int MagickQuantizeImages( MagickWand *wand, const unsigned long number_
                                    const unsigned int measure_error );
 </pre>
 </div>
-<div class="section" id="id274">
+<div class="section" id="id288">
 <h2>Description</h2>
 <p>MagickQuantizeImage() analyzes the colors within a sequence of images and
 chooses a fixed number of colors to represent the image.  The goal of the
@@ -3988,15 +4129,15 @@ pixel value and its quantized value.</dd>
 </div>
 </div>
 <div class="section" id="magickqueryfontmetrics">
-<h1><a class="toc-backref" href="#id601">MagickQueryFontMetrics</a></h1>
-<div class="section" id="id275">
+<h1><a class="toc-backref" href="#id620">MagickQueryFontMetrics</a></h1>
+<div class="section" id="id289">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 double *MagickQueryFontMetrics( MagickWand *wand, const DrawingWand *drawing_wand,
                                 const char *text );
 </pre>
 </div>
-<div class="section" id="id276">
+<div class="section" id="id290">
 <h2>Description</h2>
 <p>MagickQueryFontMetrics() returns a 7 element array representing the
 following font metrics:</p>
@@ -4026,14 +4167,14 @@ double *MagickQueryFontMetrics( MagickWand *wand, const DrawingWand *drawing_wan
 </div>
 </div>
 <div class="section" id="magickqueryfonts">
-<h1><a class="toc-backref" href="#id602">MagickQueryFonts</a></h1>
-<div class="section" id="id277">
+<h1><a class="toc-backref" href="#id621">MagickQueryFonts</a></h1>
+<div class="section" id="id291">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 char ** MagickQueryFonts( const char *pattern, unsigned long *number_fonts );
 </pre>
 </div>
-<div class="section" id="id278">
+<div class="section" id="id292">
 <h2>Description</h2>
 <p>MagickQueryFonts() returns any font that match the specified pattern.</p>
 <p>The format of the MagickQueryFonts function is:</p>
@@ -4050,14 +4191,14 @@ char ** MagickQueryFonts( const char *pattern, unsigned long *number_fonts );
 </div>
 </div>
 <div class="section" id="magickqueryformats">
-<h1><a class="toc-backref" href="#id603">MagickQueryFormats</a></h1>
-<div class="section" id="id279">
+<h1><a class="toc-backref" href="#id622">MagickQueryFormats</a></h1>
+<div class="section" id="id293">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 char ** MagickQueryFormats( const char *pattern, unsigned long *number_formats );
 </pre>
 </div>
-<div class="section" id="id280">
+<div class="section" id="id294">
 <h2>Description</h2>
 <p>MagickQueryFormats() returns any image formats that match the specified
 pattern.</p>
@@ -4075,14 +4216,14 @@ list.</dd>
 </div>
 </div>
 <div class="section" id="magickradialblurimage">
-<h1><a class="toc-backref" href="#id604">MagickRadialBlurImage</a></h1>
-<div class="section" id="id281">
+<h1><a class="toc-backref" href="#id623">MagickRadialBlurImage</a></h1>
+<div class="section" id="id295">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickRadialBlurImage( MagickWand *wand, const double angle );
 </pre>
 </div>
-<div class="section" id="id282">
+<div class="section" id="id296">
 <h2>Description</h2>
 <p>MagickRadialBlurImage() radial blurs an image.</p>
 <p>The format of the MagickRadialBlurImage method is:</p>
@@ -4099,8 +4240,8 @@ unsigned int MagickRadialBlurImage( MagickWand *wand, const double angle );
 </div>
 </div>
 <div class="section" id="magickraiseimage">
-<h1><a class="toc-backref" href="#id605">MagickRaiseImage</a></h1>
-<div class="section" id="id283">
+<h1><a class="toc-backref" href="#id624">MagickRaiseImage</a></h1>
+<div class="section" id="id297">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickRaiseImage( MagickWand *wand, const unsigned long width,
@@ -4108,7 +4249,7 @@ unsigned int MagickRaiseImage( MagickWand *wand, const unsigned long width,
                                const unsigned int raise_flag );
 </pre>
 </div>
-<div class="section" id="id284">
+<div class="section" id="id298">
 <h2>Description</h2>
 <p>MagickRaiseImage() creates a simulated three-dimensional button-like effect
 by lightening and darkening the edges of the image.  Members width and
@@ -4132,14 +4273,14 @@ otherwise it has a lowered effect.</dd>
 </div>
 </div>
 <div class="section" id="magickreadimage">
-<h1><a class="toc-backref" href="#id606">MagickReadImage</a></h1>
-<div class="section" id="id285">
+<h1><a class="toc-backref" href="#id625">MagickReadImage</a></h1>
+<div class="section" id="id299">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickReadImage( MagickWand *wand, const char *filename );
 </pre>
 </div>
-<div class="section" id="id286">
+<div class="section" id="id300">
 <h2>Description</h2>
 <p>MagickReadImage() reads an image or image sequence.</p>
 <p>The format of the MagickReadImage method is:</p>
@@ -4156,15 +4297,15 @@ unsigned int MagickReadImage( MagickWand *wand, const char *filename );
 </div>
 </div>
 <div class="section" id="magickreadimageblob">
-<h1><a class="toc-backref" href="#id607">MagickReadImageBlob</a></h1>
-<div class="section" id="id287">
+<h1><a class="toc-backref" href="#id626">MagickReadImageBlob</a></h1>
+<div class="section" id="id301">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickReadImageBlob( MagickWand *wand, const unsigned char *blob,
                                   const size_t length );
 </pre>
 </div>
-<div class="section" id="id288">
+<div class="section" id="id302">
 <h2>Description</h2>
 <p>MagickReadImageBlob() reads an image or image sequence from a blob.</p>
 <p>The format of the MagickReadImageBlob method is:</p>
@@ -4183,14 +4324,14 @@ unsigned int MagickReadImageBlob( MagickWand *wand, const unsigned char *blob,
 </div>
 </div>
 <div class="section" id="magickreadimagefile">
-<h1><a class="toc-backref" href="#id608">MagickReadImageFile</a></h1>
-<div class="section" id="id289">
+<h1><a class="toc-backref" href="#id627">MagickReadImageFile</a></h1>
+<div class="section" id="id303">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickReadImageFile( MagickWand *wand, FILE *file );
 </pre>
 </div>
-<div class="section" id="id290">
+<div class="section" id="id304">
 <h2>Description</h2>
 <p>MagickReadImageFile() reads an image or image sequence from an open file
 descriptor.</p>
@@ -4208,14 +4349,14 @@ unsigned int MagickReadImageFile( MagickWand *wand, FILE *file );
 </div>
 </div>
 <div class="section" id="magickreducenoiseimage">
-<h1><a class="toc-backref" href="#id609">MagickReduceNoiseImage</a></h1>
-<div class="section" id="id291">
+<h1><a class="toc-backref" href="#id628">MagickReduceNoiseImage</a></h1>
+<div class="section" id="id305">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickReduceNoiseImage( MagickWand *wand, const double radius );
 </pre>
 </div>
-<div class="section" id="id292">
+<div class="section" id="id306">
 <h2>Description</h2>
 <p>MagickReduceNoiseImage() smooths the contours of an image while still
 preserving edge information.  The algorithm works by replacing each pixel
@@ -4235,14 +4376,14 @@ unsigned int MagickReduceNoiseImage( MagickWand *wand, const double radius );
 </div>
 </div>
 <div class="section" id="magickrelinquishmemory">
-<h1><a class="toc-backref" href="#id610">MagickRelinquishMemory</a></h1>
-<div class="section" id="id293">
+<h1><a class="toc-backref" href="#id629">MagickRelinquishMemory</a></h1>
+<div class="section" id="id307">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickRelinquishMemory( void *resource );
 </pre>
 </div>
-<div class="section" id="id294">
+<div class="section" id="id308">
 <h2>Description</h2>
 <p>MagickRelinquishMemory() relinquishes memory resources returned by such
 methods as MagickDescribeImage(), MagickGetException(), etc.</p>
@@ -4258,14 +4399,14 @@ unsigned int MagickRelinquishMemory( void *resource );
 </div>
 </div>
 <div class="section" id="magickremoveimage">
-<h1><a class="toc-backref" href="#id611">MagickRemoveImage</a></h1>
-<div class="section" id="id295">
+<h1><a class="toc-backref" href="#id630">MagickRemoveImage</a></h1>
+<div class="section" id="id309">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickRemoveImage( MagickWand *wand );
 </pre>
 </div>
-<div class="section" id="id296">
+<div class="section" id="id310">
 <h2>Description</h2>
 <p>MagickRemoveImage() removes an image from the image list.</p>
 <p>The format of the MagickRemoveImage method is:</p>
@@ -4280,15 +4421,15 @@ unsigned int MagickRemoveImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickremoveimageoption">
-<h1><a class="toc-backref" href="#id612">MagickRemoveImageOption</a></h1>
-<div class="section" id="id297">
+<h1><a class="toc-backref" href="#id631">MagickRemoveImageOption</a></h1>
+<div class="section" id="id311">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickRemoveImageOption( MagickWand *wand, const char *format,
                                       const char *key );
 </pre>
 </div>
-<div class="section" id="id298">
+<div class="section" id="id312">
 <h2>Description</h2>
 <p>MagickRemoveImageOption() removes an image format-specific option from the
 the image (.e.g MagickRemoveImageOption(wand,&quot;jpeg&quot;,&quot;preserve-settings&quot;).</p>
@@ -4308,15 +4449,15 @@ unsigned int MagickRemoveImageOption( MagickWand *wand, const char *format,
 </div>
 </div>
 <div class="section" id="magickremoveimageprofile">
-<h1><a class="toc-backref" href="#id613">MagickRemoveImageProfile</a></h1>
-<div class="section" id="id299">
+<h1><a class="toc-backref" href="#id632">MagickRemoveImageProfile</a></h1>
+<div class="section" id="id313">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned char *MagickRemoveImageProfile( MagickWand *wand, const char *name,
                                          unsigned long *length );
 </pre>
 </div>
-<div class="section" id="id300">
+<div class="section" id="id314">
 <h2>Description</h2>
 <p>MagickRemoveImageProfile() removes the named image profile and returns it.</p>
 <p>The format of the MagickRemoveImageProfile method is:</p>
@@ -4335,14 +4476,14 @@ unsigned char *MagickRemoveImageProfile( MagickWand *wand, const char *name,
 </div>
 </div>
 <div class="section" id="magickresetiterator">
-<h1><a class="toc-backref" href="#id614">MagickResetIterator</a></h1>
-<div class="section" id="id301">
+<h1><a class="toc-backref" href="#id633">MagickResetIterator</a></h1>
+<div class="section" id="id315">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 void MagickResetIterator( MagickWand *wand );
 </pre>
 </div>
-<div class="section" id="id302">
+<div class="section" id="id316">
 <h2>Description</h2>
 <p>MagickReset() resets the wand iterator.  Use it in conjunction
 with MagickNextImage() to iterate over all the images in a wand
@@ -4359,8 +4500,8 @@ void MagickResetIterator( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickresampleimage">
-<h1><a class="toc-backref" href="#id615">MagickResampleImage</a></h1>
-<div class="section" id="id303">
+<h1><a class="toc-backref" href="#id634">MagickResampleImage</a></h1>
+<div class="section" id="id317">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickResampleImage( MagickWand *wand, const double x_resolution,
@@ -4368,7 +4509,7 @@ unsigned int MagickResampleImage( MagickWand *wand, const double x_resolution,
                                   const double blur );
 </pre>
 </div>
-<div class="section" id="id304">
+<div class="section" id="id318">
 <h2>Description</h2>
 <p>MagickResampleImage() resample image to desired resolution.</p>
 <p>Bessel   Blackman   Box
@@ -4400,8 +4541,8 @@ unsigned int MagickResampleImage( MagickWand *wand, const double x_resolution,
 </div>
 </div>
 <div class="section" id="magickresizeimage">
-<h1><a class="toc-backref" href="#id616">MagickResizeImage</a></h1>
-<div class="section" id="id305">
+<h1><a class="toc-backref" href="#id635">MagickResizeImage</a></h1>
+<div class="section" id="id319">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickResizeImage( MagickWand *wand, const unsigned long columns,
@@ -4409,7 +4550,7 @@ unsigned int MagickResizeImage( MagickWand *wand, const unsigned long columns,
                                 const double blur );
 </pre>
 </div>
-<div class="section" id="id306">
+<div class="section" id="id320">
 <h2>Description</h2>
 <p>MagickResizeImage() scales an image to the desired dimensions with one of
 these filters:</p>
@@ -4442,15 +4583,15 @@ unsigned int MagickResizeImage( MagickWand *wand, const unsigned long columns,
 </div>
 </div>
 <div class="section" id="magickrollimage">
-<h1><a class="toc-backref" href="#id617">MagickRollImage</a></h1>
-<div class="section" id="id307">
+<h1><a class="toc-backref" href="#id636">MagickRollImage</a></h1>
+<div class="section" id="id321">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickRollImage( MagickWand *wand, const long x_offset,
                               const unsigned long y_offset );
 </pre>
 </div>
-<div class="section" id="id308">
+<div class="section" id="id322">
 <h2>Description</h2>
 <p>MagickRollImage() offsets an image as defined by x_offset and y_offset.</p>
 <p>The format of the MagickRollImage method is:</p>
@@ -4469,15 +4610,15 @@ unsigned int MagickRollImage( MagickWand *wand, const long x_offset,
 </div>
 </div>
 <div class="section" id="magickrotateimage">
-<h1><a class="toc-backref" href="#id618">MagickRotateImage</a></h1>
-<div class="section" id="id309">
+<h1><a class="toc-backref" href="#id637">MagickRotateImage</a></h1>
+<div class="section" id="id323">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickRotateImage( MagickWand *wand, const PixelWand *background,
                                 const double degrees );
 </pre>
 </div>
-<div class="section" id="id310">
+<div class="section" id="id324">
 <h2>Description</h2>
 <p>MagickRotateImage() rotates an image the specified number of degrees. Empty
 triangles left over from rotating the image are filled with the
@@ -4498,15 +4639,15 @@ unsigned int MagickRotateImage( MagickWand *wand, const PixelWand *background,
 </div>
 </div>
 <div class="section" id="magicksampleimage">
-<h1><a class="toc-backref" href="#id619">MagickSampleImage</a></h1>
-<div class="section" id="id311">
+<h1><a class="toc-backref" href="#id638">MagickSampleImage</a></h1>
+<div class="section" id="id325">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSampleImage( MagickWand *wand, const unsigned long columns,
                                 const unsigned long rows );
 </pre>
 </div>
-<div class="section" id="id312">
+<div class="section" id="id326">
 <h2>Description</h2>
 <p>MagickSampleImage() scales an image to the desired dimensions with pixel
 sampling.  Unlike other scaling methods, this method does not introduce
@@ -4527,15 +4668,15 @@ unsigned int MagickSampleImage( MagickWand *wand, const unsigned long columns,
 </div>
 </div>
 <div class="section" id="magickscaleimage">
-<h1><a class="toc-backref" href="#id620">MagickScaleImage</a></h1>
-<div class="section" id="id313">
+<h1><a class="toc-backref" href="#id639">MagickScaleImage</a></h1>
+<div class="section" id="id327">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickScaleImage( MagickWand *wand, const unsigned long columns,
                                const unsigned long rows );
 </pre>
 </div>
-<div class="section" id="id314">
+<div class="section" id="id328">
 <h2>Description</h2>
 <p>MagickScaleImage() scales the size of an image to the given dimensions.</p>
 <p>The format of the MagickScaleImage method is:</p>
@@ -4554,14 +4695,14 @@ unsigned int MagickScaleImage( MagickWand *wand, const unsigned long columns,
 </div>
 </div>
 <div class="section" id="magickseparateimagechannel">
-<h1><a class="toc-backref" href="#id621">MagickSeparateImageChannel</a></h1>
-<div class="section" id="id315">
+<h1><a class="toc-backref" href="#id640">MagickSeparateImageChannel</a></h1>
+<div class="section" id="id329">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSeparateImageChannel( MagickWand *wand, const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel );
 </pre>
 </div>
-<div class="section" id="id316">
+<div class="section" id="id330">
 <h2>Description</h2>
 <p>MagickChannelImage() separates a channel from the image and returns a
 grayscale image.  A channel is a particular color component of each pixel
@@ -4581,14 +4722,14 @@ BlackChannel.</dd>
 </div>
 </div>
 <div class="section" id="magicksetcompressionquality">
-<h1><a class="toc-backref" href="#id622">MagickSetCompressionQuality</a></h1>
-<div class="section" id="id317">
+<h1><a class="toc-backref" href="#id641">MagickSetCompressionQuality</a></h1>
+<div class="section" id="id331">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetCompressionQuality( MagickWand *wand, const unsigned long quality );
 </pre>
 </div>
-<div class="section" id="id318">
+<div class="section" id="id332">
 <h2>Description</h2>
 <p>MagickSetCompressionQuality() sets the image quality factor, which
 determines compression options when saving the file.</p>
@@ -4660,14 +4801,14 @@ unsigned int MagickSetCompressionQuality( MagickWand *wand, const unsigned long
 </div>
 </div>
 <div class="section" id="magicksetdepth">
-<h1><a class="toc-backref" href="#id623">MagickSetDepth</a></h1>
-<div class="section" id="id319">
+<h1><a class="toc-backref" href="#id642">MagickSetDepth</a></h1>
+<div class="section" id="id333">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetDepth( MagickWand *wand, const size_t depth );
 </pre>
 </div>
-<div class="section" id="id320">
+<div class="section" id="id334">
 <h2>Description</h2>
 <p>MagickSetDepth() sets the sample depth to be used when reading from a
 raw image or a format which requires that the depth be specified in
@@ -4686,14 +4827,14 @@ unsigned int MagickSetDepth( MagickWand *wand, const size_t depth );
 </div>
 </div>
 <div class="section" id="magicksetfilename">
-<h1><a class="toc-backref" href="#id624">MagickSetFilename</a></h1>
-<div class="section" id="id321">
+<h1><a class="toc-backref" href="#id643">MagickSetFilename</a></h1>
+<div class="section" id="id335">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetFilename( MagickWand *wand, const char *filename );
 </pre>
 </div>
-<div class="section" id="id322">
+<div class="section" id="id336">
 <h2>Description</h2>
 <p>MagickSetFilename() sets the filename before you read or write an image file.</p>
 <p>The format of the MagickSetFilename method is:</p>
@@ -4710,14 +4851,14 @@ unsigned int MagickSetFilename( MagickWand *wand, const char *filename );
 </div>
 </div>
 <div class="section" id="magicksetformat">
-<h1><a class="toc-backref" href="#id625">MagickSetFormat</a></h1>
-<div class="section" id="id323">
+<h1><a class="toc-backref" href="#id644">MagickSetFormat</a></h1>
+<div class="section" id="id337">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetFormat( MagickWand *wand, const char *format );
 </pre>
 </div>
-<div class="section" id="id324">
+<div class="section" id="id338">
 <h2>Description</h2>
 <p>MagickSetFormat() sets the file or blob format (e.g. &quot;BMP&quot;) to be used
 when a file or blob is read.  Usually this is not necessary because
@@ -4739,14 +4880,14 @@ unsigned int MagickSetFormat( MagickWand *wand, const char *format );
 </div>
 </div>
 <div class="section" id="magicksetimage">
-<h1><a class="toc-backref" href="#id626">MagickSetImage</a></h1>
-<div class="section" id="id325">
+<h1><a class="toc-backref" href="#id645">MagickSetImage</a></h1>
+<div class="section" id="id339">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImage( MagickWand *wand, const MagickWand *set_wand );
 </pre>
 </div>
-<div class="section" id="id326">
+<div class="section" id="id340">
 <h2>Description</h2>
 <p>MagickSetImage() replaces the last image returned by MagickSetImageIndex(),
 MagickNextImage(), MagickPreviousImage() with the images from the specified
@@ -4765,15 +4906,15 @@ unsigned int MagickSetImage( MagickWand *wand, const MagickWand *set_wand );
 </div>
 </div>
 <div class="section" id="magicksetimageattribute">
-<h1><a class="toc-backref" href="#id627">MagickSetImageAttribute</a></h1>
-<div class="section" id="id327">
+<h1><a class="toc-backref" href="#id646">MagickSetImageAttribute</a></h1>
+<div class="section" id="id341">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageAttribute( MagickWand *wand, const char *name,
                                       const char *value );
 </pre>
 </div>
-<div class="section" id="id328">
+<div class="section" id="id342">
 <h2>Description</h2>
 <p>MagickSetImageAttribute sets an image attribute</p>
 <p>The format of the MagickSetImageAttribute method is:</p>
@@ -4793,14 +4934,14 @@ unsigned int MagickSetImageAttribute( MagickWand *wand, const char *name,
 </div>
 </div>
 <div class="section" id="magicksetimagebackgroundcolor">
-<h1><a class="toc-backref" href="#id628">MagickSetImageBackgroundColor</a></h1>
-<div class="section" id="id329">
+<h1><a class="toc-backref" href="#id647">MagickSetImageBackgroundColor</a></h1>
+<div class="section" id="id343">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageBackgroundColor( MagickWand *wand, const PixelWand *background );
 </pre>
 </div>
-<div class="section" id="id330">
+<div class="section" id="id344">
 <h2>Description</h2>
 <p>MagickSetImageBackgroundColor() sets the image background color.</p>
 <p>The format of the MagickSetImageBackgroundColor method is:</p>
@@ -4816,14 +4957,14 @@ unsigned int MagickSetImageBackgroundColor( MagickWand *wand, const PixelWand *b
 </div>
 </div>
 <div class="section" id="magicksetimageblueprimary">
-<h1><a class="toc-backref" href="#id629">MagickSetImageBluePrimary</a></h1>
-<div class="section" id="id331">
+<h1><a class="toc-backref" href="#id648">MagickSetImageBluePrimary</a></h1>
+<div class="section" id="id345">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageBluePrimary( MagickWand *wand, const double x, const double y );
 </pre>
 </div>
-<div class="section" id="id332">
+<div class="section" id="id346">
 <h2>Description</h2>
 <p>MagickSetImageBluePrimary() sets the image chromaticity blue primary point.</p>
 <p>The format of the MagickSetImageBluePrimary method is:</p>
@@ -4841,14 +4982,14 @@ unsigned int MagickSetImageBluePrimary( MagickWand *wand, const double x, const
 </div>
 </div>
 <div class="section" id="magicksetimagebordercolor">
-<h1><a class="toc-backref" href="#id630">MagickSetImageBorderColor</a></h1>
-<div class="section" id="id333">
+<h1><a class="toc-backref" href="#id649">MagickSetImageBorderColor</a></h1>
+<div class="section" id="id347">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageBorderColor( MagickWand *wand, const PixelWand *border );
 </pre>
 </div>
-<div class="section" id="id334">
+<div class="section" id="id348">
 <h2>Description</h2>
 <p>MagickSetImageBorderColor() sets the image border color.</p>
 <p>The format of the MagickSetImageBorderColor method is:</p>
@@ -4864,15 +5005,15 @@ unsigned int MagickSetImageBorderColor( MagickWand *wand, const PixelWand *borde
 </div>
 </div>
 <div class="section" id="magicksetimagecolormapcolor">
-<h1><a class="toc-backref" href="#id631">MagickSetImageColormapColor</a></h1>
-<div class="section" id="id335">
+<h1><a class="toc-backref" href="#id650">MagickSetImageColormapColor</a></h1>
+<div class="section" id="id349">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageColormapColor( MagickWand *wand, const unsigned long index,
                                           const PixelWand *color );
 </pre>
 </div>
-<div class="section" id="id336">
+<div class="section" id="id350">
 <h2>Description</h2>
 <p>MagickSetImageColormapColor() sets the color of the specified colormap
 index.</p>
@@ -4892,14 +5033,14 @@ unsigned int MagickSetImageColormapColor( MagickWand *wand, const unsigned long
 </div>
 </div>
 <div class="section" id="magicksetimagecolorspace">
-<h1><a class="toc-backref" href="#id632">MagickSetImageColorspace</a></h1>
-<div class="section" id="id337">
+<h1><a class="toc-backref" href="#id651">MagickSetImageColorspace</a></h1>
+<div class="section" id="id351">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageColorspace( MagickWand *wand, const <a class="reference external" href="../api/types.html#colorspacetype">ColorspaceType</a> colorspace );
 </pre>
 </div>
-<div class="section" id="id338">
+<div class="section" id="id352">
 <h2>Description</h2>
 <p>MagickSetImageColorspace() sets the image colorspace.</p>
 <p>The format of the MagickSetImageColorspace method is:</p>
@@ -4919,14 +5060,14 @@ HSLColorspace, or HWBColorspace.</dd>
 </div>
 </div>
 <div class="section" id="magicksetimagecompose">
-<h1><a class="toc-backref" href="#id633">MagickSetImageCompose</a></h1>
-<div class="section" id="id339">
+<h1><a class="toc-backref" href="#id652">MagickSetImageCompose</a></h1>
+<div class="section" id="id353">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageCompose( MagickWand *wand, const <a class="reference external" href="../api/types.html#compositeoperator">CompositeOperator</a> compose );
 </pre>
 </div>
-<div class="section" id="id340">
+<div class="section" id="id354">
 <h2>Description</h2>
 <p>MagickSetImageCompose() sets the image composite operator, useful for
 specifying how to composite the image thumbnail when using the
@@ -4944,15 +5085,15 @@ unsigned int MagickSetImageCompose( MagickWand *wand, const <a class="reference
 </div>
 </div>
 <div class="section" id="magicksetimagecompression">
-<h1><a class="toc-backref" href="#id634">MagickSetImageCompression</a></h1>
-<div class="section" id="id341">
+<h1><a class="toc-backref" href="#id653">MagickSetImageCompression</a></h1>
+<div class="section" id="id355">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageCompression( MagickWand *wand,
                                         const <a class="reference external" href="../api/types.html#compressiontype">CompressionType</a> compression );
 </pre>
 </div>
-<div class="section" id="id342">
+<div class="section" id="id356">
 <h2>Description</h2>
 <p>MagickSetImageCompression() sets the image compression.</p>
 <p>The format of the MagickSetImageCompression method is:</p>
@@ -4969,14 +5110,14 @@ unsigned int MagickSetImageCompression( MagickWand *wand,
 </div>
 </div>
 <div class="section" id="magicksetimagedelay">
-<h1><a class="toc-backref" href="#id635">MagickSetImageDelay</a></h1>
-<div class="section" id="id343">
+<h1><a class="toc-backref" href="#id654">MagickSetImageDelay</a></h1>
+<div class="section" id="id357">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageDelay( MagickWand *wand, const unsigned long delay );
 </pre>
 </div>
-<div class="section" id="id344">
+<div class="section" id="id358">
 <h2>Description</h2>
 <p>MagickSetImageDelay() sets the image delay.</p>
 <p>The format of the MagickSetImageDelay method is:</p>
@@ -4992,15 +5133,15 @@ unsigned int MagickSetImageDelay( MagickWand *wand, const unsigned long delay );
 </div>
 </div>
 <div class="section" id="magicksetimagechanneldepth">
-<h1><a class="toc-backref" href="#id636">MagickSetImageChannelDepth</a></h1>
-<div class="section" id="id345">
+<h1><a class="toc-backref" href="#id655">MagickSetImageChannelDepth</a></h1>
+<div class="section" id="id359">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageChannelDepth( MagickWand *wand, const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel,
                                          const unsigned long depth );
 </pre>
 </div>
-<div class="section" id="id346">
+<div class="section" id="id360">
 <h2>Description</h2>
 <p>MagickSetImageChannelDepth() sets the depth of a particular image channel.</p>
 <p>The format of the MagickSetImageChannelDepth method is:</p>
@@ -5021,14 +5162,14 @@ BlackChannel.</dd>
 </div>
 </div>
 <div class="section" id="magicksetimagedepth">
-<h1><a class="toc-backref" href="#id637">MagickSetImageDepth</a></h1>
-<div class="section" id="id347">
+<h1><a class="toc-backref" href="#id656">MagickSetImageDepth</a></h1>
+<div class="section" id="id361">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageDepth( MagickWand *wand, const unsigned long depth );
 </pre>
 </div>
-<div class="section" id="id348">
+<div class="section" id="id362">
 <h2>Description</h2>
 <p>MagickSetImageDepth() sets the image depth.</p>
 <p>The format of the MagickSetImageDepth method is:</p>
@@ -5044,14 +5185,14 @@ unsigned int MagickSetImageDepth( MagickWand *wand, const unsigned long depth );
 </div>
 </div>
 <div class="section" id="magicksetimagedispose">
-<h1><a class="toc-backref" href="#id638">MagickSetImageDispose</a></h1>
-<div class="section" id="id349">
+<h1><a class="toc-backref" href="#id657">MagickSetImageDispose</a></h1>
+<div class="section" id="id363">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageDispose( MagickWand *wand, const DisposeType dispose );
 </pre>
 </div>
-<div class="section" id="id350">
+<div class="section" id="id364">
 <h2>Description</h2>
 <p>MagickSetImageDispose() sets the image disposal method.</p>
 <p>The format of the MagickSetImageDispose method is:</p>
@@ -5067,14 +5208,14 @@ unsigned int MagickSetImageDispose( MagickWand *wand, const DisposeType dispose
 </div>
 </div>
 <div class="section" id="magicksetimagefilename">
-<h1><a class="toc-backref" href="#id639">MagickSetImageFilename</a></h1>
-<div class="section" id="id351">
+<h1><a class="toc-backref" href="#id658">MagickSetImageFilename</a></h1>
+<div class="section" id="id365">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageFilename( MagickWand *wand, const char *filename );
 </pre>
 </div>
-<div class="section" id="id352">
+<div class="section" id="id366">
 <h2>Description</h2>
 <p>MagickSetImageFilename() sets the filename of a particular image in a
 sequence.</p>
@@ -5091,14 +5232,14 @@ unsigned int MagickSetImageFilename( MagickWand *wand, const char *filename );
 </div>
 </div>
 <div class="section" id="magicksetimageformat">
-<h1><a class="toc-backref" href="#id640">MagickSetImageFormat</a></h1>
-<div class="section" id="id353">
+<h1><a class="toc-backref" href="#id659">MagickSetImageFormat</a></h1>
+<div class="section" id="id367">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageFormat( MagickWand *wand, const char *format );
 </pre>
 </div>
-<div class="section" id="id354">
+<div class="section" id="id368">
 <h2>Description</h2>
 <p>MagickSetImageFormat() sets the format of a particular image in a
 sequence.  The format is designated by a magick string (e.g. &quot;GIF&quot;).</p>
@@ -5115,14 +5256,14 @@ unsigned int MagickSetImageFormat( MagickWand *wand, const char *format );
 </div>
 </div>
 <div class="section" id="magicksetimagefuzz">
-<h1><a class="toc-backref" href="#id641">MagickSetImageFuzz</a></h1>
-<div class="section" id="id355">
+<h1><a class="toc-backref" href="#id660">MagickSetImageFuzz</a></h1>
+<div class="section" id="id369">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageFuzz( MagickWand *wand, const double fuzz );
 </pre>
 </div>
-<div class="section" id="id356">
+<div class="section" id="id370">
 <h2>Description</h2>
 <p>MagickSetImageFuzz() sets the color comparison fuzz factor.  Colors
 closer than the fuzz factor are considered to be the same when comparing
@@ -5142,14 +5283,14 @@ unsigned int MagickSetImageFuzz( MagickWand *wand, const double fuzz );
 </div>
 </div>
 <div class="section" id="magicksetimagegamma">
-<h1><a class="toc-backref" href="#id642">MagickSetImageGamma</a></h1>
-<div class="section" id="id357">
+<h1><a class="toc-backref" href="#id661">MagickSetImageGamma</a></h1>
+<div class="section" id="id371">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageGamma( MagickWand *wand, const double gamma );
 </pre>
 </div>
-<div class="section" id="id358">
+<div class="section" id="id372">
 <h2>Description</h2>
 <p>MagickSetImageGamma() sets the image gamma.</p>
 <p>The format of the MagickSetImageGamma method is:</p>
@@ -5166,14 +5307,14 @@ unsigned int MagickSetImageGamma( MagickWand *wand, const double gamma );
 </div>
 </div>
 <div class="section" id="magicksetimagegravity">
-<h1><a class="toc-backref" href="#id643">MagickSetImageGravity</a></h1>
-<div class="section" id="id359">
+<h1><a class="toc-backref" href="#id662">MagickSetImageGravity</a></h1>
+<div class="section" id="id373">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageGravity( MagickWand *wand, const <a class="reference external" href="../api/types.html#gravitytype">GravityType</a> );
 </pre>
 </div>
-<div class="section" id="id360">
+<div class="section" id="id374">
 <h2>Description</h2>
 <p>MagickSetImageGravity() sets the image gravity.  This is used
 when evaluating regions defined by a geometry and the image
@@ -5200,14 +5341,14 @@ SouthEastGravity, and StaticGravity</dd>
 </div>
 </div>
 <div class="section" id="magicksetimagegreenprimary">
-<h1><a class="toc-backref" href="#id644">MagickSetImageGreenPrimary</a></h1>
-<div class="section" id="id361">
+<h1><a class="toc-backref" href="#id663">MagickSetImageGreenPrimary</a></h1>
+<div class="section" id="id375">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageGreenPrimary( MagickWand *wand, const double x, const double y );
 </pre>
 </div>
-<div class="section" id="id362">
+<div class="section" id="id376">
 <h2>Description</h2>
 <p>MagickSetImageGreenPrimary() sets the image chromaticity green primary
 point.</p>
@@ -5226,14 +5367,14 @@ unsigned int MagickSetImageGreenPrimary( MagickWand *wand, const double x, const
 </div>
 </div>
 <div class="section" id="magicksetimageindex">
-<h1><a class="toc-backref" href="#id645">MagickSetImageIndex</a></h1>
-<div class="section" id="id363">
+<h1><a class="toc-backref" href="#id664">MagickSetImageIndex</a></h1>
+<div class="section" id="id377">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageIndex( MagickWand *wand, const long index );
 </pre>
 </div>
-<div class="section" id="id364">
+<div class="section" id="id378">
 <h2>Description</h2>
 <p>MagickSetImageIndex() set the current image to the position of the list
 specified with the index parameter.</p>
@@ -5251,15 +5392,15 @@ unsigned int MagickSetImageIndex( MagickWand *wand, const long index );
 </div>
 </div>
 <div class="section" id="magicksetimageinterlacescheme">
-<h1><a class="toc-backref" href="#id646">MagickSetImageInterlaceScheme</a></h1>
-<div class="section" id="id365">
+<h1><a class="toc-backref" href="#id665">MagickSetImageInterlaceScheme</a></h1>
+<div class="section" id="id379">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageInterlaceScheme( MagickWand *wand,
                                             const <a class="reference external" href="../api/types.html#interlacetype">InterlaceType</a> interlace_scheme );
 </pre>
 </div>
-<div class="section" id="id366">
+<div class="section" id="id380">
 <h2>Description</h2>
 <p>MagickSetImageInterlaceScheme() sets the image interlace scheme.  Please
 use SetInterlaceScheme() instead to change the interlace scheme used when
@@ -5279,14 +5420,14 @@ PlaneInterlace, PartitionInterlace.</dd>
 </div>
 </div>
 <div class="section" id="magicksetimageiterations">
-<h1><a class="toc-backref" href="#id647">MagickSetImageIterations</a></h1>
-<div class="section" id="id367">
+<h1><a class="toc-backref" href="#id666">MagickSetImageIterations</a></h1>
+<div class="section" id="id381">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageIterations( MagickWand *wand, const unsigned long iterations );
 </pre>
 </div>
-<div class="section" id="id368">
+<div class="section" id="id382">
 <h2>Description</h2>
 <p>MagickSetImageIterations() sets the image iterations.</p>
 <p>The format of the MagickSetImageIterations method is:</p>
@@ -5302,14 +5443,14 @@ unsigned int MagickSetImageIterations( MagickWand *wand, const unsigned long ite
 </div>
 </div>
 <div class="section" id="magicksetimagemattecolor">
-<h1><a class="toc-backref" href="#id648">MagickSetImageMatteColor</a></h1>
-<div class="section" id="id369">
+<h1><a class="toc-backref" href="#id667">MagickSetImageMatteColor</a></h1>
+<div class="section" id="id383">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageMatteColor( MagickWand *wand, const PixelWand *matte );
 </pre>
 </div>
-<div class="section" id="id370">
+<div class="section" id="id384">
 <h2>Description</h2>
 <p>MagickSetImageMatteColor() sets the image matte color.</p>
 <p>The format of the MagickSetImageMatteColor method is:</p>
@@ -5325,15 +5466,15 @@ unsigned int MagickSetImageMatteColor( MagickWand *wand, const PixelWand *matte
 </div>
 </div>
 <div class="section" id="magicksetimageoption">
-<h1><a class="toc-backref" href="#id649">MagickSetImageOption</a></h1>
-<div class="section" id="id371">
+<h1><a class="toc-backref" href="#id668">MagickSetImageOption</a></h1>
+<div class="section" id="id385">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageOption( MagickWand *wand, const char *format, const char *key,
                                    const char *value );
 </pre>
 </div>
-<div class="section" id="id372">
+<div class="section" id="id386">
 <h2>Description</h2>
 <p>MagickSetImageOption() associates one or options with a particular image
 format (.e.g MagickSetImageOption(wand,&quot;jpeg&quot;,&quot;preserve-settings&quot;,&quot;true&quot;).</p>
@@ -5355,14 +5496,14 @@ unsigned int MagickSetImageOption( MagickWand *wand, const char *format, const c
 </div>
 </div>
 <div class="section" id="magicksetimageorientation">
-<h1><a class="toc-backref" href="#id650">MagickSetImageOrientation</a></h1>
-<div class="section" id="id373">
+<h1><a class="toc-backref" href="#id669">MagickSetImageOrientation</a></h1>
+<div class="section" id="id387">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickSetImageOrientation( MagickWand *wand, OrientationType new_orientation );
 </pre>
 </div>
-<div class="section" id="id374">
+<div class="section" id="id388">
 <h2>Description</h2>
 <p>MagickSetImageOrientation() sets the internal image orientation type.
 The EXIF orientation tag will be updated if present.</p>
@@ -5389,15 +5530,15 @@ LeftBottomOrientation   Bottom to top and Left to right.</p>
 </div>
 </div>
 <div class="section" id="magicksetimagepage">
-<h1><a class="toc-backref" href="#id651">MagickSetImagePage</a></h1>
-<div class="section" id="id375">
+<h1><a class="toc-backref" href="#id670">MagickSetImagePage</a></h1>
+<div class="section" id="id389">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImagePage( MagickWand *wand, const unsigned long width,
                                  const unsigned long height, const long x, const long y );
 </pre>
 </div>
-<div class="section" id="id376">
+<div class="section" id="id390">
 <h2>Description</h2>
 <p>MagickSetImagePage() sets the image page size and offset used when
 placing (e.g. compositing) the image.  Pass all zeros for the
@@ -5419,8 +5560,8 @@ which to composite image data.</dd>
 </div>
 </div>
 <div class="section" id="magicksetimagepixels">
-<h1><a class="toc-backref" href="#id652">MagickSetImagePixels</a></h1>
-<div class="section" id="id377">
+<h1><a class="toc-backref" href="#id671">MagickSetImagePixels</a></h1>
+<div class="section" id="id391">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImagePixels( MagickWand *wand, const long x_offset, const long y_offset,
@@ -5429,7 +5570,7 @@ unsigned int MagickSetImagePixels( MagickWand *wand, const long x_offset, const
                                    unsigned char *pixels );
 </pre>
 </div>
-<div class="section" id="id378">
+<div class="section" id="id392">
 <h2>Description</h2>
 <p>MagickSetImagePixels() accepts pixel data and stores it in the image at the
 location you specify.  The method returns False on success otherwise True
@@ -5474,8 +5615,8 @@ length varies depending on the values of width, height, map, and type.</dd>
 </div>
 </div>
 <div class="section" id="magicksetimageprofile">
-<h1><a class="toc-backref" href="#id653">MagickSetImageProfile</a></h1>
-<div class="section" id="id379">
+<h1><a class="toc-backref" href="#id672">MagickSetImageProfile</a></h1>
+<div class="section" id="id393">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageProfile( MagickWand *wand, const char *name,
@@ -5483,7 +5624,7 @@ unsigned int MagickSetImageProfile( MagickWand *wand, const char *name,
                                     const unsigned long length );
 </pre>
 </div>
-<div class="section" id="id380">
+<div class="section" id="id394">
 <h2>Description</h2>
 <p>MagickSetImageProfile() adds a named profile to the magick wand.  If a
 profile with the same name already exists, it is replaced.  This method
@@ -5508,14 +5649,14 @@ unsigned int MagickSetImageProfile( MagickWand *wand, const char *name,
 </div>
 </div>
 <div class="section" id="magicksetimageredprimary">
-<h1><a class="toc-backref" href="#id654">MagickSetImageRedPrimary</a></h1>
-<div class="section" id="id381">
+<h1><a class="toc-backref" href="#id673">MagickSetImageRedPrimary</a></h1>
+<div class="section" id="id395">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageRedPrimary( MagickWand *wand, const double x, const double y );
 </pre>
 </div>
-<div class="section" id="id382">
+<div class="section" id="id396">
 <h2>Description</h2>
 <p>MagickSetImageRedPrimary() sets the image chromaticity red primary point.</p>
 <p>The format of the MagickSetImageRedPrimary method is:</p>
@@ -5533,15 +5674,15 @@ unsigned int MagickSetImageRedPrimary( MagickWand *wand, const double x, const d
 </div>
 </div>
 <div class="section" id="magicksetimagerenderingintent">
-<h1><a class="toc-backref" href="#id655">MagickSetImageRenderingIntent</a></h1>
-<div class="section" id="id383">
+<h1><a class="toc-backref" href="#id674">MagickSetImageRenderingIntent</a></h1>
+<div class="section" id="id397">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageRenderingIntent( MagickWand *wand,
                                             const <a class="reference external" href="../api/types.html#renderingintent">RenderingIntent</a> rendering_intent );
 </pre>
 </div>
-<div class="section" id="id384">
+<div class="section" id="id398">
 <h2>Description</h2>
 <p>MagickSetImageRenderingIntent() sets the image rendering intent.</p>
 <p>The format of the MagickSetImageRenderingIntent method is:</p>
@@ -5559,15 +5700,15 @@ SaturationIntent, PerceptualIntent, AbsoluteIntent, or RelativeIntent.</dd>
 </div>
 </div>
 <div class="section" id="magicksetimageresolution">
-<h1><a class="toc-backref" href="#id656">MagickSetImageResolution</a></h1>
-<div class="section" id="id385">
+<h1><a class="toc-backref" href="#id675">MagickSetImageResolution</a></h1>
+<div class="section" id="id399">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageResolution( MagickWand *wand, const double x_resolution,
                                        const doubtl y_resolution );
 </pre>
 </div>
-<div class="section" id="id386">
+<div class="section" id="id400">
 <h2>Description</h2>
 <p>MagickSetImageResolution() sets the image resolution.</p>
 <p>The format of the MagickSetImageResolution method is:</p>
@@ -5586,14 +5727,14 @@ unsigned int MagickSetImageResolution( MagickWand *wand, const double x_resoluti
 </div>
 </div>
 <div class="section" id="magicksetimagescene">
-<h1><a class="toc-backref" href="#id657">MagickSetImageScene</a></h1>
-<div class="section" id="id387">
+<h1><a class="toc-backref" href="#id676">MagickSetImageScene</a></h1>
+<div class="section" id="id401">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageScene( MagickWand *wand, const unsigned long scene );
 </pre>
 </div>
-<div class="section" id="id388">
+<div class="section" id="id402">
 <h2>Description</h2>
 <p>MagickSetImageScene() sets the image scene.</p>
 <p>The format of the MagickSetImageScene method is:</p>
@@ -5609,14 +5750,14 @@ unsigned int MagickSetImageScene( MagickWand *wand, const unsigned long scene );
 </div>
 </div>
 <div class="section" id="magicksetimagetype">
-<h1><a class="toc-backref" href="#id658">MagickSetImageType</a></h1>
-<div class="section" id="id389">
+<h1><a class="toc-backref" href="#id677">MagickSetImageType</a></h1>
+<div class="section" id="id403">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageType( MagickWand *wand, const <a class="reference external" href="../api/types.html#imagetype">ImageType</a> image_type );
 </pre>
 </div>
-<div class="section" id="id390">
+<div class="section" id="id404">
 <h2>Description</h2>
 <p>MagickSetImageType() sets the image type.</p>
 <p>The format of the MagickSetImageType method is:</p>
@@ -5635,14 +5776,14 @@ or OptimizeType.</dd>
 </div>
 </div>
 <div class="section" id="magicksetimagesavedtype">
-<h1><a class="toc-backref" href="#id659">MagickSetImageSavedType</a></h1>
-<div class="section" id="id391">
+<h1><a class="toc-backref" href="#id678">MagickSetImageSavedType</a></h1>
+<div class="section" id="id405">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageSavedType( MagickWand *wand, const <a class="reference external" href="../api/types.html#imagetype">ImageType</a> image_type );
 </pre>
 </div>
-<div class="section" id="id392">
+<div class="section" id="id406">
 <h2>Description</h2>
 <p>MagickSetImageSavedType() sets the image type that will be used when the
 image is saved.</p>
@@ -5662,14 +5803,14 @@ or OptimizeType.</dd>
 </div>
 </div>
 <div class="section" id="magicksetimageunits">
-<h1><a class="toc-backref" href="#id660">MagickSetImageUnits</a></h1>
-<div class="section" id="id393">
+<h1><a class="toc-backref" href="#id679">MagickSetImageUnits</a></h1>
+<div class="section" id="id407">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageUnits( MagickWand *wand, const <a class="reference external" href="../api/types.html#resolutiontype">ResolutionType</a> units );
 </pre>
 </div>
-<div class="section" id="id394">
+<div class="section" id="id408">
 <h2>Description</h2>
 <p>MagickSetImageUnits() sets the image units of resolution.</p>
 <p>The format of the MagickSetImageUnits method is:</p>
@@ -5686,15 +5827,15 @@ PixelsPerInchResolution, or PixelsPerCentimeterResolution.</dd>
 </div>
 </div>
 <div class="section" id="magicksetimagevirtualpixelmethod">
-<h1><a class="toc-backref" href="#id661">MagickSetImageVirtualPixelMethod</a></h1>
-<div class="section" id="id395">
+<h1><a class="toc-backref" href="#id680">MagickSetImageVirtualPixelMethod</a></h1>
+<div class="section" id="id409">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageVirtualPixelMethod( MagickWand *wand,
                                                const <a class="reference external" href="../api/types.html#virtualpixelmethod">VirtualPixelMethod</a> method );
 </pre>
 </div>
-<div class="section" id="id396">
+<div class="section" id="id410">
 <h2>Description</h2>
 <p>MagickSetImageVirtualPixelMethod() sets the image virtual pixel method.</p>
 <p>The format of the MagickSetImageVirtualPixelMethod method is:</p>
@@ -5713,15 +5854,15 @@ MirrorVirtualPixelMethod, or TileVirtualPixelMethod.</dd>
 </div>
 </div>
 <div class="section" id="magicksetinterlacescheme">
-<h1><a class="toc-backref" href="#id662">MagickSetInterlaceScheme</a></h1>
-<div class="section" id="id397">
+<h1><a class="toc-backref" href="#id681">MagickSetInterlaceScheme</a></h1>
+<div class="section" id="id411">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetInterlaceScheme( MagickWand *wand,
                                        const <a class="reference external" href="../api/types.html#interlacetype">InterlaceType</a> interlace_scheme );
 </pre>
 </div>
-<div class="section" id="id398">
+<div class="section" id="id412">
 <h2>Description</h2>
 <p>MagickSetInterlaceScheme() sets the interlace scheme used when writing
 the image.</p>
@@ -5740,15 +5881,15 @@ PlaneInterlace, PartitionInterlace.</dd>
 </div>
 </div>
 <div class="section" id="magicksetresolution">
-<h1><a class="toc-backref" href="#id663">MagickSetResolution</a></h1>
-<div class="section" id="id399">
+<h1><a class="toc-backref" href="#id682">MagickSetResolution</a></h1>
+<div class="section" id="id413">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetResolution( MagickWand *wand, const double x_resolution,
                                   const double y_resolution );
 </pre>
 </div>
-<div class="section" id="id400">
+<div class="section" id="id414">
 <h2>Description</h2>
 <p>MagickSetResolution() sets the resolution (density) of the magick wand.
 Set it before you read an EPS, PDF, or Postscript file in order to
@@ -5773,14 +5914,14 @@ unsigned int MagickSetResolution( MagickWand *wand, const double x_resolution,
 </div>
 </div>
 <div class="section" id="magicksetresolutionunits">
-<h1><a class="toc-backref" href="#id664">MagickSetResolutionUnits</a></h1>
-<div class="section" id="id401">
+<h1><a class="toc-backref" href="#id683">MagickSetResolutionUnits</a></h1>
+<div class="section" id="id415">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetResolutionUnits( MagickWand *wand, const <a class="reference external" href="../api/types.html#resolutiontype">ResolutionType</a> units );
 </pre>
 </div>
-<div class="section" id="id402">
+<div class="section" id="id416">
 <h2>Description</h2>
 <p>MagickSetResolutionUnits() sets the resolution units of the magick wand.
 It should be used in conjunction with MagickSetResolution().
@@ -5801,14 +5942,14 @@ PixelsPerInchResolution, or PixelsPerCentimeterResolution.</dd>
 </div>
 </div>
 <div class="section" id="magicksetresourcelimit">
-<h1><a class="toc-backref" href="#id665">MagickSetResourceLimit</a></h1>
-<div class="section" id="id403">
+<h1><a class="toc-backref" href="#id684">MagickSetResourceLimit</a></h1>
+<div class="section" id="id417">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetResourceLimit( const <a class="reference external" href="../api/types.html#resourcetype">ResourceType</a> type, const unsigned long *limit );
 </pre>
 </div>
-<div class="section" id="id404">
+<div class="section" id="id418">
 <h2>Description</h2>
 <p>MagickSetResourceLimit() sets the limit for a particular resource in
 megabytes.</p>
@@ -5826,15 +5967,15 @@ HeightResource.</dd>
 </div>
 </div>
 <div class="section" id="magicksetsamplingfactors">
-<h1><a class="toc-backref" href="#id666">MagickSetSamplingFactors</a></h1>
-<div class="section" id="id405">
+<h1><a class="toc-backref" href="#id685">MagickSetSamplingFactors</a></h1>
+<div class="section" id="id419">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetSamplingFactors( MagickWand *wand, const unsigned long number_factors,
                                        const double *sampling_factors );
 </pre>
 </div>
-<div class="section" id="id406">
+<div class="section" id="id420">
 <h2>Description</h2>
 <p>MagickSetSamplingFactors() sets the image sampling factors.</p>
 <p>The format of the MagickSetSamplingFactors method is:</p>
@@ -5854,15 +5995,15 @@ for each color component (in RGB order).</dd>
 </div>
 </div>
 <div class="section" id="magicksetsize">
-<h1><a class="toc-backref" href="#id667">MagickSetSize</a></h1>
-<div class="section" id="id407">
+<h1><a class="toc-backref" href="#id686">MagickSetSize</a></h1>
+<div class="section" id="id421">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetSize( MagickWand *wand, const unsigned long columns,
                             const unsigned long rows );
 </pre>
 </div>
-<div class="section" id="id408">
+<div class="section" id="id422">
 <h2>Description</h2>
 <p>MagickSetSize() sets the size of the magick wand.  Set it before you
 read a raw image format such as RGB, GRAY, or CMYK.</p>
@@ -5882,14 +6023,14 @@ unsigned int MagickSetSize( MagickWand *wand, const unsigned long columns,
 </div>
 </div>
 <div class="section" id="magicksetimagewhitepoint">
-<h1><a class="toc-backref" href="#id668">MagickSetImageWhitePoint</a></h1>
-<div class="section" id="id409">
+<h1><a class="toc-backref" href="#id687">MagickSetImageWhitePoint</a></h1>
+<div class="section" id="id423">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetImageWhitePoint( MagickWand *wand, const double x, const double y );
 </pre>
 </div>
-<div class="section" id="id410">
+<div class="section" id="id424">
 <h2>Description</h2>
 <p>MagickSetImageWhitePoint() sets the image chromaticity white point.</p>
 <p>The format of the MagickSetImageWhitePoint method is:</p>
@@ -5907,14 +6048,14 @@ unsigned int MagickSetImageWhitePoint( MagickWand *wand, const double x, const d
 </div>
 </div>
 <div class="section" id="magicksetpassphrase">
-<h1><a class="toc-backref" href="#id669">MagickSetPassphrase</a></h1>
-<div class="section" id="id411">
+<h1><a class="toc-backref" href="#id688">MagickSetPassphrase</a></h1>
+<div class="section" id="id425">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSetPassphrase( MagickWand *wand, const char *passphrase );
 </pre>
 </div>
-<div class="section" id="id412">
+<div class="section" id="id426">
 <h2>Description</h2>
 <p>MagickSetPassphrase() sets the passphrase.</p>
 <p>The format of the MagickSetPassphrase method is:</p>
@@ -5931,14 +6072,14 @@ unsigned int MagickSetPassphrase( MagickWand *wand, const char *passphrase );
 </div>
 </div>
 <div class="section" id="magicksharpenimage">
-<h1><a class="toc-backref" href="#id670">MagickSharpenImage</a></h1>
-<div class="section" id="id413">
+<h1><a class="toc-backref" href="#id689">MagickSharpenImage</a></h1>
+<div class="section" id="id427">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSharpenImage( MagickWand *wand, const double radius, const double sigma );
 </pre>
 </div>
-<div class="section" id="id414">
+<div class="section" id="id428">
 <h2>Description</h2>
 <p>MagickSharpenImage() sharpens an image.  We convolve the image with a Gaussian
 operator of the given radius and standard deviation (sigma).
@@ -5960,15 +6101,15 @@ pixel.</dd>
 </div>
 </div>
 <div class="section" id="magickshaveimage">
-<h1><a class="toc-backref" href="#id671">MagickShaveImage</a></h1>
-<div class="section" id="id415">
+<h1><a class="toc-backref" href="#id690">MagickShaveImage</a></h1>
+<div class="section" id="id429">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickShaveImage( MagickWand *wand, const unsigned long columns,
                                const unsigned long rows );
 </pre>
 </div>
-<div class="section" id="id416">
+<div class="section" id="id430">
 <h2>Description</h2>
 <p>MagickShaveImage() shaves pixels from the image edges.  It allocates the
 memory necessary for the new Image structure and returns a pointer to the
@@ -5989,15 +6130,15 @@ unsigned int MagickShaveImage( MagickWand *wand, const unsigned long columns,
 </div>
 </div>
 <div class="section" id="magickshearimage">
-<h1><a class="toc-backref" href="#id672">MagickShearImage</a></h1>
-<div class="section" id="id417">
+<h1><a class="toc-backref" href="#id691">MagickShearImage</a></h1>
+<div class="section" id="id431">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickShearImage( MagickWand *wand, const PixelWand *background,
                                const double x_shear, onst double y_shear );
 </pre>
 </div>
-<div class="section" id="id418">
+<div class="section" id="id432">
 <h2>Description</h2>
 <p>MagickShearImage() slides one edge of an image along the X or Y axis,
 creating a parallelogram.  An X direction shear slides an edge along the X
@@ -6024,14 +6165,14 @@ unsigned int MagickShearImage( MagickWand *wand, const PixelWand *background,
 </div>
 </div>
 <div class="section" id="magicksolarizeimage">
-<h1><a class="toc-backref" href="#id673">MagickSolarizeImage</a></h1>
-<div class="section" id="id419">
+<h1><a class="toc-backref" href="#id692">MagickSolarizeImage</a></h1>
+<div class="section" id="id433">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSolarizeImage( MagickWand *wand, const double threshold );
 </pre>
 </div>
-<div class="section" id="id420">
+<div class="section" id="id434">
 <h2>Description</h2>
 <p>MagickSolarizeImage() applies a special effect to the image, similar to the
 effect achieved in a photo darkroom by selectively exposing areas of photo
@@ -6051,14 +6192,14 @@ unsigned int MagickSolarizeImage( MagickWand *wand, const double threshold );
 </div>
 </div>
 <div class="section" id="magickspreadimage">
-<h1><a class="toc-backref" href="#id674">MagickSpreadImage</a></h1>
-<div class="section" id="id421">
+<h1><a class="toc-backref" href="#id693">MagickSpreadImage</a></h1>
+<div class="section" id="id435">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSpreadImage( MagickWand *wand, const double radius );
 </pre>
 </div>
-<div class="section" id="id422">
+<div class="section" id="id436">
 <h2>Description</h2>
 <p>MagickSpreadImage() is a special effects method that randomly displaces each
 pixel in a block defined by the radius parameter.</p>
@@ -6076,15 +6217,15 @@ unsigned int MagickSpreadImage( MagickWand *wand, const double radius );
 </div>
 </div>
 <div class="section" id="magicksteganoimage">
-<h1><a class="toc-backref" href="#id675">MagickSteganoImage</a></h1>
-<div class="section" id="id423">
+<h1><a class="toc-backref" href="#id694">MagickSteganoImage</a></h1>
+<div class="section" id="id437">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickWand *MagickSteganoImage( MagickWand *wand, const MagickWand *watermark_wand,
                                 const long offset );
 </pre>
 </div>
-<div class="section" id="id424">
+<div class="section" id="id438">
 <h2>Description</h2>
 <p>Use MagickSteganoImage() to hide a digital watermark within the image.
 Recover the hidden watermark later to prove that the authenticity of
@@ -6106,14 +6247,14 @@ MagickWand *MagickSteganoImage( MagickWand *wand, const MagickWand *watermark_wa
 </div>
 </div>
 <div class="section" id="magickstereoimage">
-<h1><a class="toc-backref" href="#id676">MagickStereoImage</a></h1>
-<div class="section" id="id425">
+<h1><a class="toc-backref" href="#id695">MagickStereoImage</a></h1>
+<div class="section" id="id439">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickWand *MagickStereoImage( MagickWand *wand, const MagickWand *offset_wand );
 </pre>
 </div>
-<div class="section" id="id426">
+<div class="section" id="id440">
 <h2>Description</h2>
 <p>MagickStereoImage() composites two images and produces a single image that
 is the composite of a left and right image of a stereo pair</p>
@@ -6130,14 +6271,14 @@ MagickWand *MagickStereoImage( MagickWand *wand, const MagickWand *offset_wand )
 </div>
 </div>
 <div class="section" id="magickstripimage">
-<h1><a class="toc-backref" href="#id677">MagickStripImage</a></h1>
-<div class="section" id="id427">
+<h1><a class="toc-backref" href="#id696">MagickStripImage</a></h1>
+<div class="section" id="id441">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickStripImage( MagickWand *wand );
 </pre>
 </div>
-<div class="section" id="id428">
+<div class="section" id="id442">
 <h2>Description</h2>
 <p>MagickStripImage() removes all profiles and text attributes from the image.</p>
 <p>The format of the MagickStripImage method is:</p>
@@ -6152,14 +6293,14 @@ unsigned int MagickStripImage( MagickWand *wand );
 </div>
 </div>
 <div class="section" id="magickswirlimage">
-<h1><a class="toc-backref" href="#id678">MagickSwirlImage</a></h1>
-<div class="section" id="id429">
+<h1><a class="toc-backref" href="#id697">MagickSwirlImage</a></h1>
+<div class="section" id="id443">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickSwirlImage( MagickWand *wand, const double degrees );
 </pre>
 </div>
-<div class="section" id="id430">
+<div class="section" id="id444">
 <h2>Description</h2>
 <p>MagickSwirlImage() swirls the pixels about the center of the image, where
 degrees indicates the sweep of the arc through which each pixel is moved.
@@ -6178,14 +6319,14 @@ unsigned int MagickSwirlImage( MagickWand *wand, const double degrees );
 </div>
 </div>
 <div class="section" id="magicktextureimage">
-<h1><a class="toc-backref" href="#id679">MagickTextureImage</a></h1>
-<div class="section" id="id431">
+<h1><a class="toc-backref" href="#id698">MagickTextureImage</a></h1>
+<div class="section" id="id445">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickWand *MagickTextureImage( MagickWand *wand, const MagickWand *texture_wand );
 </pre>
 </div>
-<div class="section" id="id432">
+<div class="section" id="id446">
 <h2>Description</h2>
 <p>MagickTextureImage() repeatedly tiles the texture image across and down the
 image canvas.</p>
@@ -6202,14 +6343,14 @@ MagickWand *MagickTextureImage( MagickWand *wand, const MagickWand *texture_wand
 </div>
 </div>
 <div class="section" id="magickthresholdimage">
-<h1><a class="toc-backref" href="#id680">MagickThresholdImage</a></h1>
-<div class="section" id="id433">
+<h1><a class="toc-backref" href="#id699">MagickThresholdImage</a></h1>
+<div class="section" id="id447">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickThresholdImage( MagickWand *wand, const double threshold );
 </pre>
 </div>
-<div class="section" id="id434">
+<div class="section" id="id448">
 <h2>Description</h2>
 <p>MagickThresholdImage() changes the value of individual pixels based on
 the intensity of each pixel compared to threshold.  The result is a
@@ -6227,15 +6368,15 @@ unsigned int MagickThresholdImage( MagickWand *wand, const double threshold );
 </div>
 </div>
 <div class="section" id="magickthresholdimagechannel">
-<h1><a class="toc-backref" href="#id681">MagickThresholdImageChannel</a></h1>
-<div class="section" id="id435">
+<h1><a class="toc-backref" href="#id700">MagickThresholdImageChannel</a></h1>
+<div class="section" id="id449">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickThresholdImageChannel( MagickWand *wand, const <a class="reference external" href="../api/types.html#channeltype">ChannelType</a> channel,
                                           const double threshold );
 </pre>
 </div>
-<div class="section" id="id436">
+<div class="section" id="id450">
 <h2>Description</h2>
 <p>MagickThresholdImageChannel() changes the value of individual pixel
 component based on the intensity of each pixel compared to threshold.  The
@@ -6256,15 +6397,15 @@ unsigned int MagickThresholdImageChannel( MagickWand *wand, const <a class="refe
 </div>
 </div>
 <div class="section" id="magicktintimage">
-<h1><a class="toc-backref" href="#id682">MagickTintImage</a></h1>
-<div class="section" id="id437">
+<h1><a class="toc-backref" href="#id701">MagickTintImage</a></h1>
+<div class="section" id="id451">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickTintImage( MagickWand *wand, const PixelWand *tint,
                               const PixelWand *opacity );
 </pre>
 </div>
-<div class="section" id="id438">
+<div class="section" id="id452">
 <h2>Description</h2>
 <p>MagickTintImage() applies a color vector to each pixel in the image.  The
 length of the vector is 0 for black and white and at its maximum for the
@@ -6286,15 +6427,15 @@ unsigned int MagickTintImage( MagickWand *wand, const PixelWand *tint,
 </div>
 </div>
 <div class="section" id="magicktransformimage">
-<h1><a class="toc-backref" href="#id683">MagickTransformImage</a></h1>
-<div class="section" id="id439">
+<h1><a class="toc-backref" href="#id702">MagickTransformImage</a></h1>
+<div class="section" id="id453">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickWand *MagickTransformImage( MagickWand *wand, const char *crop,
                                   const char *geometry );
 </pre>
 </div>
-<div class="section" id="id440">
+<div class="section" id="id454">
 <h2>Description</h2>
 <p>MagickTransformImage() is a convenience method that behaves like
 MagickResizeImage() or MagickCropImage() but accepts scaling and/or cropping
@@ -6318,15 +6459,15 @@ size of the image.</dd>
 </div>
 </div>
 <div class="section" id="magicktransparentimage">
-<h1><a class="toc-backref" href="#id684">MagickTransparentImage</a></h1>
-<div class="section" id="id441">
+<h1><a class="toc-backref" href="#id703">MagickTransparentImage</a></h1>
+<div class="section" id="id455">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickTransparentImage( MagickWand *wand, const PixelWand *target,
                                      const unsigned int opacity, const double fuzz );
 </pre>
 </div>
-<div class="section" id="id442">
+<div class="section" id="id456">
 <h2>Description</h2>
 <p>MagickTransparentImage() changes any pixel that matches color with the color
 defined by fill.</p>
@@ -6354,14 +6495,14 @@ as the same color for the purposes of the floodfill.</dd>
 </div>
 </div>
 <div class="section" id="magicktrimimage">
-<h1><a class="toc-backref" href="#id685">MagickTrimImage</a></h1>
-<div class="section" id="id443">
+<h1><a class="toc-backref" href="#id704">MagickTrimImage</a></h1>
+<div class="section" id="id457">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickTrimImage( MagickWand *wand, const double fuzz );
 </pre>
 </div>
-<div class="section" id="id444">
+<div class="section" id="id458">
 <h2>Description</h2>
 <p>MagickTrimImage() remove edges that are the background color from the image.</p>
 <p>The format of the MagickTrimImage method is:</p>
@@ -6383,15 +6524,15 @@ as the same color for the purposes of the floodfill.</dd>
 </div>
 </div>
 <div class="section" id="magickunsharpmaskimage">
-<h1><a class="toc-backref" href="#id686">MagickUnsharpMaskImage</a></h1>
-<div class="section" id="id445">
+<h1><a class="toc-backref" href="#id705">MagickUnsharpMaskImage</a></h1>
+<div class="section" id="id459">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickUnsharpMaskImage( MagickWand *wand, const double radius, const double sigma,
                                      const double amount, const double threshold );
 </pre>
 </div>
-<div class="section" id="id446">
+<div class="section" id="id460">
 <h2>Description</h2>
 <p>MagickUnsharpMaskImage() sharpens an image.  We convolve the image with a
 Gaussian operator of the given radius and standard deviation (sigma).
@@ -6419,15 +6560,15 @@ blur image that is added back into the original.</dd>
 </div>
 </div>
 <div class="section" id="magickwaveimage">
-<h1><a class="toc-backref" href="#id687">MagickWaveImage</a></h1>
-<div class="section" id="id447">
+<h1><a class="toc-backref" href="#id706">MagickWaveImage</a></h1>
+<div class="section" id="id461">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickWaveImage( MagickWand *wand, const double amplitude,
                               const double wave_length );
 </pre>
 </div>
-<div class="section" id="id448">
+<div class="section" id="id462">
 <h2>Description</h2>
 <p>MagickWaveImage()  creates a &quot;ripple&quot; effect in the image by shifting
 the pixels vertically along a sine wave whose amplitude and wavelength
@@ -6447,14 +6588,14 @@ sine wave.</dd>
 </div>
 </div>
 <div class="section" id="magickwhitethresholdimage">
-<h1><a class="toc-backref" href="#id688">MagickWhiteThresholdImage</a></h1>
-<div class="section" id="id449">
+<h1><a class="toc-backref" href="#id707">MagickWhiteThresholdImage</a></h1>
+<div class="section" id="id463">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickWhiteThresholdImage( MagickWand *wand, const PixelWand *threshold );
 </pre>
 </div>
-<div class="section" id="id450">
+<div class="section" id="id464">
 <h2>Description</h2>
 <p>MagickWhiteThresholdImage() is like ThresholdImage() but  forces all pixels
 above the threshold into white while leaving all pixels below the threshold
@@ -6472,14 +6613,14 @@ unsigned int MagickWhiteThresholdImage( MagickWand *wand, const PixelWand *thres
 </div>
 </div>
 <div class="section" id="magickwriteimage">
-<h1><a class="toc-backref" href="#id689">MagickWriteImage</a></h1>
-<div class="section" id="id451">
+<h1><a class="toc-backref" href="#id708">MagickWriteImage</a></h1>
+<div class="section" id="id465">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickWriteImage( MagickWand *wand, const char *filename );
 </pre>
 </div>
-<div class="section" id="id452">
+<div class="section" id="id466">
 <h2>Description</h2>
 <p>MagickWriteImage() writes an image.</p>
 <p>The format of the MagickWriteImage method is:</p>
@@ -6496,14 +6637,14 @@ unsigned int MagickWriteImage( MagickWand *wand, const char *filename );
 </div>
 </div>
 <div class="section" id="magickwriteimagesfile">
-<h1><a class="toc-backref" href="#id690">MagickWriteImagesFile</a></h1>
-<div class="section" id="id453">
+<h1><a class="toc-backref" href="#id709">MagickWriteImagesFile</a></h1>
+<div class="section" id="id467">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickWriteImagesFile( MagickWand *wand, FILE *file, const unsigned int adjoin );
 </pre>
 </div>
-<div class="section" id="id454">
+<div class="section" id="id468">
 <h2>Description</h2>
 <p>MagickWriteImagesFile() writes an image or image sequence to a stdio
 FILE handle.  This may be used to append an encoded image to an already
@@ -6524,14 +6665,14 @@ unsigned int MagickWriteImagesFile( MagickWand *wand, FILE *file, const unsigned
 </div>
 </div>
 <div class="section" id="magickwriteimageblob">
-<h1><a class="toc-backref" href="#id691">MagickWriteImageBlob</a></h1>
-<div class="section" id="id455">
+<h1><a class="toc-backref" href="#id710">MagickWriteImageBlob</a></h1>
+<div class="section" id="id469">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned char *MagickWriteImageBlob( MagickWand *wand, size_t *length );
 </pre>
 </div>
-<div class="section" id="id456">
+<div class="section" id="id470">
 <h2>Description</h2>
 <p>MagickWriteImageBlob() implements direct to memory image formats.  It
 returns the image as a blob (a formatted &quot;file&quot; in memory) and its
@@ -6555,14 +6696,14 @@ unsigned char *MagickWriteImageBlob( MagickWand *wand, size_t *length );
 </div>
 </div>
 <div class="section" id="magickwriteimagefile">
-<h1><a class="toc-backref" href="#id692">MagickWriteImageFile</a></h1>
-<div class="section" id="id457">
+<h1><a class="toc-backref" href="#id711">MagickWriteImageFile</a></h1>
+<div class="section" id="id471">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickWriteImageFile( MagickWand *wand, FILE *file );
 </pre>
 </div>
-<div class="section" id="id458">
+<div class="section" id="id472">
 <h2>Description</h2>
 <p>MagickWriteImageFile() writes an image to an open file descriptor.</p>
 <p>The format of the MagickWandToFile method is:</p>
@@ -6579,15 +6720,15 @@ unsigned int MagickWriteImageFile( MagickWand *wand, FILE *file );
 </div>
 </div>
 <div class="section" id="magickwriteimages">
-<h1><a class="toc-backref" href="#id693">MagickWriteImages</a></h1>
-<div class="section" id="id459">
+<h1><a class="toc-backref" href="#id712">MagickWriteImages</a></h1>
+<div class="section" id="id473">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 unsigned int MagickWriteImages( MagickWand *wand, const char *filename,
                                 const unsigned int adjoin );
 </pre>
 </div>
-<div class="section" id="id460">
+<div class="section" id="id474">
 <h2>Description</h2>
 <p>MagickWriteImages() writes an image or image sequence.  If the wand
 represents an image sequence, then it is written starting at the first
@@ -6608,14 +6749,14 @@ unsigned int MagickWriteImages( MagickWand *wand, const char *filename,
 </div>
 </div>
 <div class="section" id="newmagickwand">
-<h1><a class="toc-backref" href="#id694">NewMagickWand</a></h1>
-<div class="section" id="id461">
+<h1><a class="toc-backref" href="#id713">NewMagickWand</a></h1>
+<div class="section" id="id475">
 <h2>Synopsis</h2>
 <pre class="literal-block">
 MagickWand NewMagickWand( void );
 </pre>
 </div>
-<div class="section" id="id462">
+<div class="section" id="id476">
 <h2>Description</h2>
 <p>NewMagickWand() returns a wand required for all other methods in the API.</p>
 <p>The format of the NewMagickWand method is:</p>