]> granicus.if.org Git - imagemagick/blobdiff - tests/validate.c
Validation tests for magick pipes
[imagemagick] / tests / validate.c
index a090a2b08373eef4bf838b4f0f988c1c0031fa23..23423fdd3de656f7f949d91465c641aca07c8216 100644 (file)
@@ -18,7 +18,7 @@
 %                               March 2001                                    %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -45,8 +45,9 @@
 #include <string.h>
 #include <ctype.h>
 #include <math.h>
-#include "wand/MagickWand.h"
-#include "magick/string-private.h"
+#include "MagickWand/MagickWand.h"
+#include "MagickCore/colorspace-private.h"
+#include "MagickCore/string-private.h"
 #include "validate.h"
 \f
 /*
@@ -104,35 +105,37 @@ static size_t ValidateCompareCommand(ImageInfo *image_info,
     test;
 
   test=0;
-  (void) fprintf(stdout,"validate compare command line program:\n");
+  (void) FormatLocaleFile(stdout,"validate compare command line program:\n");
   for (i=0; compare_options[i] != (char *) NULL; i++)
   {
     CatchException(exception);
-    (void) fprintf(stdout,"  test %.20g: %s",(double) (test++),
+    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) (test++),
       compare_options[i]);
-    (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s",
+    (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s %s",
       compare_options[i],reference_filename,reference_filename,output_filename);
     arguments=StringToArgv(command,&number_arguments);
     if (arguments == (char **) NULL)
       {
-        (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+          GetMagickModule());
         (*fail)++;
         continue;
       }
-    status=CompareImageCommand(image_info,number_arguments,arguments,
+    status=CompareImagesCommand(image_info,number_arguments,arguments,
       (char **) NULL,exception);
-    for (j=0; j < number_arguments; j++)
+    for (j=0; j < (ssize_t) number_arguments; j++)
       arguments[j]=DestroyString(arguments[j]);
     arguments=(char **) RelinquishMagickMemory(arguments);
     if (status != MagickFalse)
       {
-        (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+          GetMagickModule());
         (*fail)++;
         continue;
       }
-    (void) fprintf(stdout,"... pass.\n");
+    (void) FormatLocaleFile(stdout,"... pass.\n");
   }
-  (void) fprintf(stdout,
+  (void) FormatLocaleFile(stdout,
     "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
     (double) (test-(*fail)),(double) *fail);
   return(test);
@@ -193,36 +196,38 @@ static size_t ValidateCompositeCommand(ImageInfo *image_info,
     test;
 
   test=0;
-  (void) fprintf(stdout,"validate composite command line program:\n");
+  (void) FormatLocaleFile(stdout,"validate composite command line program:\n");
   for (i=0; composite_options[i] != (char *) NULL; i++)
   {
     CatchException(exception);
-    (void) fprintf(stdout,"  test %.20g: %s",(double) (test++),
+    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) (test++),
       composite_options[i]);
-    (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s",
+    (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s %s",
       reference_filename,composite_options[i],reference_filename,
       output_filename);
     arguments=StringToArgv(command,&number_arguments);
     if (arguments == (char **) NULL)
       {
-        (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+          GetMagickModule());
         (*fail)++;
         continue;
       }
     status=CompositeImageCommand(image_info,number_arguments,arguments,
       (char **) NULL,exception);
-    for (j=0; j < number_arguments; j++)
+    for (j=0; j < (ssize_t) number_arguments; j++)
       arguments[j]=DestroyString(arguments[j]);
     arguments=(char **) RelinquishMagickMemory(arguments);
     if (status != MagickFalse)
       {
-        (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+          GetMagickModule());
         (*fail)++;
         continue;
       }
-    (void) fprintf(stdout,"... pass.\n");
+    (void) FormatLocaleFile(stdout,"... pass.\n");
   }
-  (void) fprintf(stdout,
+  (void) FormatLocaleFile(stdout,
     "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
     (double) (test-(*fail)),(double) *fail);
   return(test);
@@ -283,35 +288,37 @@ static size_t ValidateConvertCommand(ImageInfo *image_info,
     test;
 
   test=0;
-  (void) fprintf(stdout,"validate convert command line program:\n");
+  (void) FormatLocaleFile(stdout,"validate convert command line program:\n");
   for (i=0; convert_options[i] != (char *) NULL; i++)
   {
     CatchException(exception);
-    (void) fprintf(stdout,"  test %.20g: %s",(double) test++,
+    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) test++,
       convert_options[i]);
-    (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s",
+    (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s %s",
       reference_filename,convert_options[i],reference_filename,output_filename);
     arguments=StringToArgv(command,&number_arguments);
     if (arguments == (char **) NULL)
       {
-        (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+          GetMagickModule());
         (*fail)++;
         continue;
       }
     status=ConvertImageCommand(image_info,number_arguments,arguments,
       (char **) NULL,exception);
-    for (j=0; j < number_arguments; j++)
+    for (j=0; j < (ssize_t) number_arguments; j++)
       arguments[j]=DestroyString(arguments[j]);
     arguments=(char **) RelinquishMagickMemory(arguments);
     if (status != MagickFalse)
       {
-        (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+          GetMagickModule());
         (*fail)++;
         continue;
       }
-    (void) fprintf(stdout,"... pass.\n");
+    (void) FormatLocaleFile(stdout,"... pass.\n");
   }
-  (void) fprintf(stdout,
+  (void) FormatLocaleFile(stdout,
     "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
     (double) (test-(*fail)),(double) *fail);
   return(test);
@@ -373,35 +380,37 @@ static size_t ValidateIdentifyCommand(ImageInfo *image_info,
 
   (void) output_filename;
   test=0;
-  (void) fprintf(stdout,"validate identify command line program:\n");
+  (void) FormatLocaleFile(stdout,"validate identify command line program:\n");
   for (i=0; identify_options[i] != (char *) NULL; i++)
   {
     CatchException(exception);
-    (void) fprintf(stdout,"  test %.20g: %s",(double) test++,
+    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) test++,
       identify_options[i]);
-    (void) FormatMagickString(command,MaxTextExtent,"%s %s",
+    (void) FormatLocaleString(command,MaxTextExtent,"%s %s",
       identify_options[i],reference_filename);
     arguments=StringToArgv(command,&number_arguments);
     if (arguments == (char **) NULL)
       {
-        (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+          GetMagickModule());
         (*fail)++;
         continue;
       }
     status=IdentifyImageCommand(image_info,number_arguments,arguments,
       (char **) NULL,exception);
-    for (j=0; j < number_arguments; j++)
+    for (j=0; j < (ssize_t) number_arguments; j++)
       arguments[j]=DestroyString(arguments[j]);
     arguments=(char **) RelinquishMagickMemory(arguments);
     if (status != MagickFalse)
       {
-        (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+          GetMagickModule());
         (*fail)++;
         continue;
       }
-    (void) fprintf(stdout,"... pass.\n");
+    (void) FormatLocaleFile(stdout,"... pass.\n");
   }
-  (void) fprintf(stdout,
+  (void) FormatLocaleFile(stdout,
     "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
     (double) (test-(*fail)),(double) *fail);
   return(test);
@@ -456,8 +465,8 @@ static size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
 
   Image
     *difference_image,
-    *reference_image,
-    *reconstruct_image;
+    *reconstruct_image,
+    *reference_image;
 
   MagickBooleanType
     status;
@@ -467,16 +476,14 @@ static size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
     j;
 
   size_t
-    length;
+    length,
+    test;
 
   unsigned char
     *blob;
 
-  size_t
-    test;
-
   test=0;
-  (void) fprintf(stdout,"validate image formats in memory:\n");
+  (void) FormatLocaleFile(stdout,"validate image formats in memory:\n");
   for (i=0; reference_formats[i].magick != (char *) NULL; i++)
   {
     magick_info=GetMagickInfo(reference_formats[i].magick,exception);
@@ -490,8 +497,8 @@ static size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
         Generate reference image.
       */
       CatchException(exception);
-      (void) fprintf(stdout,"  test %.20g: %s/%s/%s/%.20g-bits",(double)
-        (test++),reference_formats[i].magick,CommandOptionToMnemonic(
+      (void) FormatLocaleFile(stdout,"  test %.20g: %s/%s/%s/%.20g-bits",
+        (double) (test++),reference_formats[i].magick,CommandOptionToMnemonic(
         MagickCompressOptions,reference_formats[i].compression),
         CommandOptionToMnemonic(MagickTypeOptions,reference_types[j].type),
         (double) reference_types[j].depth);
@@ -500,63 +507,65 @@ static size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
       reference_image=ReadImage(image_info,exception);
       if (reference_image == (Image *) NULL)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           continue;
         }
       /*
         Write reference image.
       */
-      (void) FormatMagickString(size,MaxTextExtent,"%.20gx%.20g",
+      (void) FormatLocaleString(size,MaxTextExtent,"%.20gx%.20g",
         (double) reference_image->columns,(double) reference_image->rows);
       (void) CloneString(&image_info->size,size);
       image_info->depth=reference_types[j].depth;
-      (void) FormatMagickString(reference_image->filename,MaxTextExtent,"%s:%s",
+      (void) FormatLocaleString(reference_image->filename,MaxTextExtent,"%s:%s",
         reference_formats[i].magick,output_filename);
-      status=SetImageType(reference_image,reference_types[j].type);
-      InheritException(exception,&reference_image->exception);
+      status=SetImageType(reference_image,reference_types[j].type,exception);
       if (status == MagickFalse)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           reference_image=DestroyImage(reference_image);
           continue;
         }
-      status=SetImageDepth(reference_image,reference_types[j].depth);
-      InheritException(exception,&reference_image->exception);
+      status=SetImageDepth(reference_image,reference_types[j].depth,exception);
       if (status == MagickFalse)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           reference_image=DestroyImage(reference_image);
           continue;
         }
       reference_image->compression=reference_formats[i].compression;
-      status=WriteImage(image_info,reference_image);
-      InheritException(exception,&reference_image->exception);
+      status=WriteImage(image_info,reference_image,exception);
       reference_image=DestroyImage(reference_image);
       if (status == MagickFalse)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           continue;
         }
       /*
         Read reference image.
       */
-      (void) FormatMagickString(image_info->filename,MaxTextExtent,"%s:%s",
+      (void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
         reference_formats[i].magick,output_filename);
       reference_image=ReadImage(image_info,exception);
       if (reference_image == (Image *) NULL)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           continue;
         }
       /*
         Write reference image.
       */
-      (void) FormatMagickString(reference_image->filename,MaxTextExtent,"%s:%s",
+      (void) FormatLocaleString(reference_image->filename,MaxTextExtent,"%s:%s",
         reference_formats[i].magick,output_filename);
       (void) CopyMagickString(image_info->magick,reference_formats[i].magick,
         MaxTextExtent);
@@ -566,7 +575,8 @@ static size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
       blob=ImageToBlob(image_info,reference_image,&length,exception);
       if (blob == (unsigned char *) NULL)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           reference_image=DestroyImage(reference_image);
           continue;
@@ -574,13 +584,14 @@ static size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
       /*
         Read reconstruct image.
       */
-      (void) FormatMagickString(image_info->filename,MaxTextExtent,"%s:%s",
+      (void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
         reference_formats[i].magick,output_filename);
       reconstruct_image=BlobToImage(image_info,blob,length,exception);
       blob=(unsigned char *) RelinquishMagickMemory(blob);
       if (reconstruct_image == (Image *) NULL)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           reference_image=DestroyImage(reference_image);
           continue;
@@ -594,31 +605,32 @@ static size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
 #if defined(MAGICKCORE_HDRI_SUPPORT)
       fuzz+=0.003;
 #endif
-      if (reference_image->colorspace != RGBColorspace)
+      if (IsRGBColorspace(reference_image->colorspace) == MagickFalse)
         fuzz+=0.3;
       fuzz+=MagickEpsilon;
-      difference_image=CompareImageChannels(reference_image,reconstruct_image,
-        AllChannels,MeanSquaredErrorMetric,&distortion,exception);
+      difference_image=CompareImages(reference_image,reconstruct_image,
+        MeanSquaredErrorMetric,&distortion,exception);
       reconstruct_image=DestroyImage(reconstruct_image);
       reference_image=DestroyImage(reference_image);
       if (difference_image == (Image *) NULL)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           continue;
         }
       difference_image=DestroyImage(difference_image);
       if ((distortion/QuantumRange) > fuzz)
         {
-          (void) fprintf(stdout,"... fail (with distortion %g).\n",
+          (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
             distortion/QuantumRange);
           (*fail)++;
           continue;
         }
-      (void) fprintf(stdout,"... pass.\n");
+      (void) FormatLocaleFile(stdout,"... pass.\n");
     }
   }
-  (void) fprintf(stdout,
+  (void) FormatLocaleFile(stdout,
     "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
     (double) (test-(*fail)),(double) *fail);
   return(test);
@@ -687,7 +699,7 @@ static size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
     test;
 
   test=0;
-  (void) fprintf(stdout,"validate image formats on disk:\n");
+  (void) FormatLocaleFile(stdout,"validate image formats on disk:\n");
   for (i=0; reference_formats[i].magick != (char *) NULL; i++)
   {
     magick_info=GetMagickInfo(reference_formats[i].magick,exception);
@@ -701,8 +713,8 @@ static size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
         Generate reference image.
       */
       CatchException(exception);
-      (void) fprintf(stdout,"  test %.20g: %s/%s/%s/%.20g-bits",(double)
-        (test++),reference_formats[i].magick,CommandOptionToMnemonic(
+      (void) FormatLocaleFile(stdout,"  test %.20g: %s/%s/%s/%.20g-bits",
+        (double) (test++),reference_formats[i].magick,CommandOptionToMnemonic(
         MagickCompressOptions,reference_formats[i].compression),
         CommandOptionToMnemonic(MagickTypeOptions,reference_types[j].type),
         (double) reference_types[j].depth);
@@ -711,71 +723,73 @@ static size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
       reference_image=ReadImage(image_info,exception);
       if (reference_image == (Image *) NULL)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           continue;
         }
       /*
         Write reference image.
       */
-      (void) FormatMagickString(size,MaxTextExtent,"%.20gx%.20g",
+      (void) FormatLocaleString(size,MaxTextExtent,"%.20gx%.20g",
         (double) reference_image->columns,(double) reference_image->rows);
       (void) CloneString(&image_info->size,size);
       image_info->depth=reference_types[j].depth;
-      (void) FormatMagickString(reference_image->filename,MaxTextExtent,"%s:%s",
+      (void) FormatLocaleString(reference_image->filename,MaxTextExtent,"%s:%s",
         reference_formats[i].magick,output_filename);
-      status=SetImageType(reference_image,reference_types[j].type);
-      InheritException(exception,&reference_image->exception);
+      status=SetImageType(reference_image,reference_types[j].type,exception);
       if (status == MagickFalse)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           reference_image=DestroyImage(reference_image);
           continue;
         }
-      status=SetImageDepth(reference_image,reference_types[j].depth);
-      InheritException(exception,&reference_image->exception);
+      status=SetImageDepth(reference_image,reference_types[j].depth,exception);
       if (status == MagickFalse)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           reference_image=DestroyImage(reference_image);
           continue;
         }
       reference_image->compression=reference_formats[i].compression;
-      status=WriteImage(image_info,reference_image);
-      InheritException(exception,&reference_image->exception);
+      status=WriteImage(image_info,reference_image,exception);
       reference_image=DestroyImage(reference_image);
       if (status == MagickFalse)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           continue;
         }
       /*
         Read reference image.
       */
-      (void) FormatMagickString(image_info->filename,MaxTextExtent,"%s:%s",
+      (void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
         reference_formats[i].magick,output_filename);
       reference_image=ReadImage(image_info,exception);
       if (reference_image == (Image *) NULL)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           continue;
         }
       /*
         Write reference image.
       */
-      (void) FormatMagickString(reference_image->filename,MaxTextExtent,"%s:%s",
+      (void) FormatLocaleString(reference_image->filename,MaxTextExtent,"%s:%s",
         reference_formats[i].magick,output_filename);
       reference_image->depth=reference_types[j].depth;
       reference_image->compression=reference_formats[i].compression;
-      status=WriteImage(image_info,reference_image);
-      InheritException(exception,&reference_image->exception);
+      status=WriteImage(image_info,reference_image,exception);
       if (status == MagickFalse)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           reference_image=DestroyImage(reference_image);
           continue;
@@ -783,12 +797,13 @@ static size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
       /*
         Read reconstruct image.
       */
-      (void) FormatMagickString(image_info->filename,MaxTextExtent,"%s:%s",
+      (void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
         reference_formats[i].magick,output_filename);
       reconstruct_image=ReadImage(image_info,exception);
       if (reconstruct_image == (Image *) NULL)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           reference_image=DestroyImage(reference_image);
           continue;
@@ -802,31 +817,32 @@ static size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
 #if defined(MAGICKCORE_HDRI_SUPPORT)
       fuzz+=0.003;
 #endif
-      if (reference_image->colorspace != RGBColorspace)
+      if (IsRGBColorspace(reference_image->colorspace) == MagickFalse)
         fuzz+=0.3;
       fuzz+=MagickEpsilon;
-      difference_image=CompareImageChannels(reference_image,reconstruct_image,
-        AllChannels,MeanSquaredErrorMetric,&distortion,exception);
+      difference_image=CompareImages(reference_image,reconstruct_image,
+        MeanSquaredErrorMetric,&distortion,exception);
       reconstruct_image=DestroyImage(reconstruct_image);
       reference_image=DestroyImage(reference_image);
       if (difference_image == (Image *) NULL)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           continue;
         }
       difference_image=DestroyImage(difference_image);
       if ((distortion/QuantumRange) > fuzz)
         {
-          (void) fprintf(stdout,"... fail (with distortion %g).\n",
+          (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
             distortion/QuantumRange);
           (*fail)++;
           continue;
         }
-      (void) fprintf(stdout,"... pass.\n");
+      (void) FormatLocaleFile(stdout,"... pass.\n");
     }
   }
-  (void) fprintf(stdout,
+  (void) FormatLocaleFile(stdout,
     "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
     (double) (test-(*fail)),(double) *fail);
   return(test);
@@ -895,7 +911,8 @@ static size_t ValidateImportExportPixels(ImageInfo *image_info,
 
   (void) output_filename;
   test=0;
-  (void) fprintf(stdout,"validate the import and export of image pixels:\n");
+  (void) FormatLocaleFile(stdout,
+    "validate the import and export of image pixels:\n");
   for (i=0; reference_map[i] != (char *) NULL; i++)
   {
     for (j=0; reference_storage[j].type != UndefinedPixel; j++)
@@ -904,7 +921,7 @@ static size_t ValidateImportExportPixels(ImageInfo *image_info,
         Generate reference image.
       */
       CatchException(exception);
-      (void) fprintf(stdout,"  test %.20g: %s/%s",(double) (test++),
+      (void) FormatLocaleFile(stdout,"  test %.20g: %s/%s",(double) (test++),
         reference_map[i],CommandOptionToMnemonic(MagickStorageOptions,
         reference_storage[j].type));
       (void) CopyMagickString(image_info->filename,reference_filename,
@@ -912,18 +929,20 @@ static size_t ValidateImportExportPixels(ImageInfo *image_info,
       reference_image=ReadImage(image_info,exception);
       if (reference_image == (Image *) NULL)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           continue;
         }
       if (LocaleNCompare(reference_map[i],"cmy",3) == 0)
-        (void) TransformImageColorspace(reference_image,CMYKColorspace);
+        reference_image->colorspace=CMYKColorspace;
       length=strlen(reference_map[i])*reference_image->columns*
         reference_image->rows*reference_storage[j].quantum;
       pixels=(unsigned char *) AcquireQuantumMemory(length,sizeof(*pixels));
       if (pixels == (unsigned char *) NULL)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           reference_image=DestroyImage(reference_image);
           continue;
@@ -934,20 +953,21 @@ static size_t ValidateImportExportPixels(ImageInfo *image_info,
         exception);
       if (status == MagickFalse)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           pixels=(unsigned char *) RelinquishMagickMemory(pixels);
           reference_image=DestroyImage(reference_image);
           continue;
         }
-      (void) SetImageBackgroundColor(reference_image);
+      (void) SetImageBackgroundColor(reference_image,exception);
       status=ImportImagePixels(reference_image,0,0,reference_image->columns,
         reference_image->rows,reference_map[i],reference_storage[j].type,
-        pixels);
-      InheritException(exception,&reference_image->exception);
+        pixels,exception);
       if (status == MagickFalse)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
            pixels=(unsigned char *) RelinquishMagickMemory(pixels);
           reference_image=DestroyImage(reference_image);
@@ -956,19 +976,20 @@ static size_t ValidateImportExportPixels(ImageInfo *image_info,
       /*
         Read reconstruct image.
       */
-      reconstruct_image=AcquireImage(image_info);
+      reconstruct_image=AcquireImage(image_info,exception);
       (void) SetImageExtent(reconstruct_image,reference_image->columns,
-        reference_image->rows);
-      (void) SetImageColorspace(reconstruct_image,reference_image->colorspace);
-      (void) SetImageBackgroundColor(reconstruct_image);
+        reference_image->rows,exception);
+      (void) SetImageColorspace(reconstruct_image,reference_image->colorspace,
+        exception);
+      (void) SetImageBackgroundColor(reconstruct_image,exception);
       status=ImportImagePixels(reconstruct_image,0,0,reconstruct_image->columns,
         reconstruct_image->rows,reference_map[i],reference_storage[j].type,
-        pixels);
-      InheritException(exception,&reconstruct_image->exception);
+        pixels,exception);
       pixels=(unsigned char *) RelinquishMagickMemory(pixels);
       if (status == MagickFalse)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           reference_image=DestroyImage(reference_image);
           continue;
@@ -976,28 +997,29 @@ static size_t ValidateImportExportPixels(ImageInfo *image_info,
       /*
         Compare reference to reconstruct image.
       */
-      difference_image=CompareImageChannels(reference_image,reconstruct_image,
-        AllChannels,MeanSquaredErrorMetric,&distortion,exception);
+      difference_image=CompareImages(reference_image,reconstruct_image,
+        MeanSquaredErrorMetric,&distortion,exception);
       reconstruct_image=DestroyImage(reconstruct_image);
       reference_image=DestroyImage(reference_image);
       if (difference_image == (Image *) NULL)
         {
-          (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
           (*fail)++;
           continue;
         }
       difference_image=DestroyImage(difference_image);
       if ((distortion/QuantumRange) > 0.0)
         {
-          (void) fprintf(stdout,"... fail (with distortion %g).\n",
+          (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
             distortion/QuantumRange);
           (*fail)++;
           continue;
         }
-      (void) fprintf(stdout,"... pass.\n");
+      (void) FormatLocaleFile(stdout,"... pass.\n");
     }
   }
-  (void) fprintf(stdout,
+  (void) FormatLocaleFile(stdout,
     "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
     (double) (test-(*fail)),(double) *fail);
   return(test);
@@ -1058,36 +1080,38 @@ static size_t ValidateMontageCommand(ImageInfo *image_info,
     test;
 
   test=0;
-  (void) fprintf(stdout,"validate montage command line program:\n");
+  (void) FormatLocaleFile(stdout,"validate montage command line program:\n");
   for (i=0; montage_options[i] != (char *) NULL; i++)
   {
     CatchException(exception);
-    (void) fprintf(stdout,"  test %.20g: %s",(double) (test++),
+    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) (test++),
       montage_options[i]);
-    (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s",
+    (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s %s",
       reference_filename,montage_options[i],reference_filename,
       output_filename);
     arguments=StringToArgv(command,&number_arguments);
     if (arguments == (char **) NULL)
       {
-        (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
         (*fail)++;
         continue;
       }
     status=MontageImageCommand(image_info,number_arguments,arguments,
       (char **) NULL,exception);
-    for (j=0; j < number_arguments; j++)
+    for (j=0; j < (ssize_t) number_arguments; j++)
       arguments[j]=DestroyString(arguments[j]);
     arguments=(char **) RelinquishMagickMemory(arguments);
     if (status != MagickFalse)
       {
-        (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
         (*fail)++;
         continue;
       }
-    (void) fprintf(stdout,"... pass.\n");
+    (void) FormatLocaleFile(stdout,"... pass.\n");
   }
-  (void) fprintf(stdout,
+  (void) FormatLocaleFile(stdout,
     "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
     (double) (test-(*fail)),(double) *fail);
   return(test);
@@ -1148,35 +1172,37 @@ static size_t ValidateStreamCommand(ImageInfo *image_info,
     test;
 
   test=0;
-  (void) fprintf(stdout,"validate stream command line program:\n");
+  (void) FormatLocaleFile(stdout,"validate stream command line program:\n");
   for (i=0; stream_options[i] != (char *) NULL; i++)
   {
     CatchException(exception);
-    (void) fprintf(stdout,"  test %.20g: %s",(double) (test++),
+    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) (test++),
       stream_options[i]);
-    (void) FormatMagickString(command,MaxTextExtent,"%s %s %s",
+    (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s",
       stream_options[i],reference_filename,output_filename);
     arguments=StringToArgv(command,&number_arguments);
     if (arguments == (char **) NULL)
       {
-        (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
         (*fail)++;
         continue;
       }
     status=StreamImageCommand(image_info,number_arguments,arguments,
       (char **) NULL,exception);
-    for (j=0; j < number_arguments; j++)
+    for (j=0; j < (ssize_t) number_arguments; j++)
       arguments[j]=DestroyString(arguments[j]);
     arguments=(char **) RelinquishMagickMemory(arguments);
     if (status != MagickFalse)
       {
-        (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
+        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
         (*fail)++;
         continue;
       }
-    (void) fprintf(stdout,"... pass.\n");
+    (void) FormatLocaleFile(stdout,"... pass.\n");
   }
-  (void) fprintf(stdout,
+  (void) FormatLocaleFile(stdout,
     "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
     (double) (test-(*fail)),(double) *fail);
   return(test);
@@ -1374,10 +1400,12 @@ int main(int argc,char **argv)
         if ((LocaleCompare("version",option+1) == 0) ||
             (LocaleCompare("-version",option+1) == 0))
           {
-            (void) fprintf(stdout,"Version: %s\n",
+            (void) FormatLocaleFile(stdout,"Version: %s\n",
               GetMagickVersion((size_t *) NULL));
-            (void) fprintf(stdout,"Copyright: %s\n\n",GetMagickCopyright());
-            (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
+            (void) FormatLocaleFile(stdout,"Copyright: %s\n\n",
+              GetMagickCopyright());
+            (void) FormatLocaleFile(stdout,"Features: %s\n\n",
+              GetMagickFeatures());
             return(0);
           }
         ThrowValidateException(OptionError,"UnrecognizedOption",option)
@@ -1403,19 +1431,19 @@ int main(int argc,char **argv)
       (void) AcquireUniqueFilename(output_filename);
       (void) CopyMagickString(reference_image->filename,reference_filename,
         MaxTextExtent);
-      status=WriteImage(image_info,reference_image);
-      InheritException(exception,&reference_image->exception);
+      status=WriteImage(image_info,reference_image,exception);
       reference_image=DestroyImage(reference_image);
       if (status == MagickFalse)
         fail++;
       else
         {
-          (void) fprintf(stdout,"Version: %s\n",
+          (void) FormatLocaleFile(stdout,"Version: %s\n",
             GetMagickVersion((size_t *) NULL));
-          (void) fprintf(stdout,"Copyright: %s\n\n",
+          (void) FormatLocaleFile(stdout,"Copyright: %s\n\n",
             GetMagickCopyright());
-          (void) fprintf(stdout,"ImageMagick Validation Suite (%s)\n\n",
-            CommandOptionToMnemonic(MagickValidateOptions,(ssize_t) type));
+          (void) FormatLocaleFile(stdout,
+            "ImageMagick Validation Suite (%s)\n\n",CommandOptionToMnemonic(
+            MagickValidateOptions,(ssize_t) type));
           if ((type & CompareValidate) != 0)
             tests+=ValidateCompareCommand(image_info,reference_filename,
               output_filename,&fail,exception);
@@ -1443,7 +1471,7 @@ int main(int argc,char **argv)
           if ((type & StreamValidate) != 0)
             tests+=ValidateStreamCommand(image_info,reference_filename,
               output_filename,&fail,exception);
-          (void) fprintf(stdout,
+          (void) FormatLocaleFile(stdout,
             "validation suite: %.20g tests; %.20g passed; %.20g failed.\n",
             (double) tests,(double) (tests-fail),(double) fail);
         }
@@ -1456,7 +1484,7 @@ int main(int argc,char **argv)
     {
       elapsed_time=GetElapsedTime(timer);
       user_time=GetUserTime(timer);
-      (void) fprintf(stderr,
+      (void) FormatLocaleFile(stderr,
         "Performance: %.20gi %gips %0.3fu %ld:%02ld.%03ld\n",(double)
         iterations,1.0*iterations/elapsed_time,user_time,(long)
         (elapsed_time/60.0),(long) ceil(fmod(elapsed_time,60.0)),