]> granicus.if.org Git - imagemagick/blobdiff - tests/validate.c
(no commit message)
[imagemagick] / tests / validate.c
index 77f42491365b6b89ec3f5da87e7cdc4f3a406672..ef1547ebbe7c2fbb5c368946fd57bb9e79df3bfb 100644 (file)
@@ -18,7 +18,7 @@
 %                               March 2001                                    %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2013 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  %
   Include declarations.
 */
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 #include <math.h>
-#include "wand/MagickWand.h"
+#include <locale.h>
+#include "MagickWand/MagickWand.h"
+#include "MagickCore/colorspace-private.h"
+#include "MagickCore/resource_.h"
+#include "MagickCore/string-private.h"
 #include "validate.h"
 \f
 /*
@@ -62,9 +68,9 @@
 %
 %  The format of the ValidateCompareCommand method is:
 %
-%      unsigned long ValidateCompareCommand(ImageInfo *image_info,
+%      size_t ValidateCompareCommand(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -79,9 +85,9 @@
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateCompareCommand(ImageInfo *image_info,
-  const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+static size_t ValidateCompareCommand(ImageInfo *image_info,
+  const char *reference_filename,const char *output_filename,size_t *fail,
+  ExceptionInfo *exception)
 {
   char
     **arguments,
@@ -93,43 +99,47 @@ static unsigned long ValidateCompareCommand(ImageInfo *image_info,
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     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 %lu: %s",test++,compare_options[i]);
-    (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s",
+    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) (test++),
+      compare_options[i]);
+    (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,"  summary: %lu subtests; %lu passed; %lu failed.\n",
-    test,test-(*fail),*fail);
+  (void) FormatLocaleFile(stdout,
+    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
+    (double) (test-(*fail)),(double) *fail);
   return(test);
 }
 \f
@@ -149,9 +159,9 @@ static unsigned long ValidateCompareCommand(ImageInfo *image_info,
 %
 %  The format of the ValidateCompositeCommand method is:
 %
-%      unsigned long ValidateCompositeCommand(ImageInfo *image_info,
+%      size_t ValidateCompositeCommand(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -166,9 +176,9 @@ static unsigned long ValidateCompareCommand(ImageInfo *image_info,
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateCompositeCommand(ImageInfo *image_info,
-  const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+static size_t ValidateCompositeCommand(ImageInfo *image_info,
+  const char *reference_filename,const char *output_filename,size_t *fail,
+  ExceptionInfo *exception)
 {
   char
     **arguments,
@@ -180,44 +190,48 @@ static unsigned long ValidateCompositeCommand(ImageInfo *image_info,
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     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 %lu: %s",test++,composite_options[i]);
-    (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s",
+    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) (test++),
+      composite_options[i]);
+    (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,"  summary: %lu subtests; %lu passed; %lu failed.\n",
-    test,test-(*fail),*fail);
+  (void) FormatLocaleFile(stdout,
+    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
+    (double) (test-(*fail)),(double) *fail);
   return(test);
 }
 \f
@@ -237,9 +251,9 @@ static unsigned long ValidateCompositeCommand(ImageInfo *image_info,
 %
 %  The format of the ValidateConvertCommand method is:
 %
-%      unsigned long ValidateConvertCommand(ImageInfo *image_info,
+%      size_t ValidateConvertCommand(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -254,9 +268,9 @@ static unsigned long ValidateCompositeCommand(ImageInfo *image_info,
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateConvertCommand(ImageInfo *image_info,
-  const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+static size_t ValidateConvertCommand(ImageInfo *image_info,
+  const char *reference_filename,const char *output_filename,size_t *fail,
+  ExceptionInfo *exception)
 {
   char
     **arguments,
@@ -268,43 +282,47 @@ static unsigned long ValidateConvertCommand(ImageInfo *image_info,
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     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 %lu: %s",test++,convert_options[i]);
-    (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s",
+    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) test++,
+      convert_options[i]);
+    (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,"  summary: %lu subtests; %lu passed; %lu failed.\n",
-    test,test-(*fail),*fail);
+  (void) FormatLocaleFile(stdout,
+    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
+    (double) (test-(*fail)),(double) *fail);
   return(test);
 }
 \f
@@ -324,9 +342,9 @@ static unsigned long ValidateConvertCommand(ImageInfo *image_info,
 %
 %  The format of the ValidateIdentifyCommand method is:
 %
-%      unsigned long ValidateIdentifyCommand(ImageInfo *image_info,
+%      size_t ValidateIdentifyCommand(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -341,9 +359,9 @@ static unsigned long ValidateConvertCommand(ImageInfo *image_info,
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateIdentifyCommand(ImageInfo *image_info,
-  const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+static size_t ValidateIdentifyCommand(ImageInfo *image_info,
+  const char *reference_filename,const char *output_filename,size_t *fail,
+  ExceptionInfo *exception)
 {
   char
     **arguments,
@@ -355,44 +373,48 @@ static unsigned long ValidateIdentifyCommand(ImageInfo *image_info,
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     test;
 
   (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 %lu: %s",test++,identify_options[i]);
-    (void) FormatMagickString(command,MaxTextExtent,"%s %s",
+    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) test++,
+      identify_options[i]);
+    (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,"  summary: %lu subtests; %lu passed; %lu failed.\n",
-    test,test-(*fail),*fail);
+  (void) FormatLocaleFile(stdout,
+    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
+    (double) (test-(*fail)),(double) *fail);
   return(test);
 }
 \f
@@ -412,9 +434,9 @@ static unsigned long ValidateIdentifyCommand(ImageInfo *image_info,
 %
 %  The format of the ValidateImageFormatsInMemory method is:
 %
-%      unsigned long ValidateImageFormatsInMemory(ImageInfo *image_info,
+%      size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -429,11 +451,22 @@ static unsigned long ValidateIdentifyCommand(ImageInfo *image_info,
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateImageFormatsInMemory(ImageInfo *image_info,
-  const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+
+/*
+  Enable this to count remaining $TMPDIR/magick-* files.  Note that the count
+  includes any files left over from other runs.
+*/
+#undef MagickCountTempFiles
+
+static size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
+  const char *reference_filename,const char *output_filename,size_t *fail,
+  ExceptionInfo *exception)
 {
   char
+#ifdef MagickCountTempFiles
+    SystemCommand[MaxTextExtent],
+    path[MaxTextExtent],
+#endif
     size[MaxTextExtent];
 
   const MagickInfo
@@ -445,27 +478,34 @@ static unsigned long ValidateImageFormatsInMemory(ImageInfo *image_info,
 
   Image
     *difference_image,
-    *reference_image,
-    *reconstruct_image;
+    *ping_image,
+    *reconstruct_image,
+    *reference_image;
 
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
   size_t
-    length;
+    length,
+    test;
 
   unsigned char
     *blob;
 
-  unsigned long
-    test;
-
   test=0;
-  (void) fprintf(stdout,"validate image formats in memory:\n");
+  (void) FormatLocaleFile(stdout,"validate image formats in memory:\n");
+
+#ifdef MagickCountTempFiles
+  (void)GetPathTemplate(path);
+  /* Remove file template except for the leading "magick-" */
+  path[strlen(path)-17]='\0';
+  (void) FormatLocaleFile(stdout," tmp path is '%s*'\n",path);
+#endif
+
   for (i=0; reference_formats[i].magick != (char *) NULL; i++)
   {
     magick_info=GetMagickInfo(reference_formats[i].magick,exception);
@@ -479,73 +519,87 @@ static unsigned long ValidateImageFormatsInMemory(ImageInfo *image_info,
         Generate reference image.
       */
       CatchException(exception);
-      (void) fprintf(stdout,"  test %lu: %s/%s/%s/%lu-bits",test++,
-        reference_formats[i].magick,MagickOptionToMnemonic(
+      (void) FormatLocaleFile(stdout,"  test %.20g: %s/%s/%s/%.20g-bits",
+        (double) (test++),reference_formats[i].magick,CommandOptionToMnemonic(
         MagickCompressOptions,reference_formats[i].compression),
-        MagickOptionToMnemonic(MagickTypeOptions,reference_types[j].type),
-        reference_types[j].depth);
+        CommandOptionToMnemonic(MagickTypeOptions,reference_types[j].type),
+        (double) reference_types[j].depth);
       (void) CopyMagickString(image_info->filename,reference_filename,
         MaxTextExtent);
       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,"%lux%lu",
-        reference_image->columns,reference_image->rows);
+      (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.
+        Ping reference image.
       */
-      (void) FormatMagickString(image_info->filename,MaxTextExtent,"%s:%s",
+      (void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
         reference_formats[i].magick,output_filename);
+      ping_image=PingImage(image_info,exception);
+      if (ping_image == (Image *) NULL)
+        {
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
+          (*fail)++;
+          continue;
+        }
+      ping_image=DestroyImage(ping_image);
+      /*
+        Read reference image.
+      */
       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);
@@ -555,21 +609,36 @@ static unsigned long 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;
         }
+      /*
+        Ping reference blob.
+      */
+      ping_image=PingBlob(image_info,blob,length,exception);
+      if (ping_image == (Image *) NULL)
+        {
+          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
+            GetMagickModule());
+          (*fail)++;
+          blob=(unsigned char *) RelinquishMagickMemory(blob);
+          continue;
+        }
+      ping_image=DestroyImage(ping_image);
       /*
         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;
@@ -583,32 +652,45 @@ static unsigned long ValidateImageFormatsInMemory(ImageInfo *image_info,
 #if defined(MAGICKCORE_HDRI_SUPPORT)
       fuzz+=0.003;
 #endif
-      if (reference_image->colorspace != RGBColorspace)
+      if (IssRGBColorspace(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,
+        RootMeanSquaredErrorMetric,&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)
+      if ((QuantumScale*distortion) > fuzz)
         {
-          (void) fprintf(stdout,"... fail (with distortion %g).\n",distortion/
-            QuantumRange);
+          (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
+            QuantumScale*distortion);
           (*fail)++;
           continue;
         }
-      (void) fprintf(stdout,"... pass.\n");
+#ifdef MagickCountTempFiles
+      (void) FormatLocaleFile(stdout,"... pass, ");
+      (void) fflush(stdout);
+      SystemCommand[0]='\0';
+      (void)strncat(SystemCommand,"echo `ls ",9);
+      (void)strncat(SystemCommand,path,MaxTextExtent-31);
+      (void)strncat(SystemCommand,"* | wc -w` tmp files.",20);
+      (void)system(SystemCommand);
+      (void) fflush(stdout);
+#else
+      (void) FormatLocaleFile(stdout,"... pass\n");
+#endif
     }
   }
-  (void) fprintf(stdout,"  summary: %lu subtests; %lu passed; %lu failed.\n",
-    test,test-(*fail),*fail);
+  (void) FormatLocaleFile(stdout,
+    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
+    (double) (test-(*fail)),(double) *fail);
   return(test);
 }
 \f
@@ -628,9 +710,9 @@ static unsigned long ValidateImageFormatsInMemory(ImageInfo *image_info,
 %
 %  The format of the ValidateImageFormatsOnDisk method is:
 %
-%      unsigned long ValidateImageFormatsOnDisk(ImageInfo *image_info,
+%      size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -645,9 +727,9 @@ static unsigned long ValidateImageFormatsInMemory(ImageInfo *image_info,
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateImageFormatsOnDisk(ImageInfo *image_info,
-  const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+static size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
+  const char *reference_filename,const char *output_filename,size_t *fail,
+  ExceptionInfo *exception)
 {
   char
     size[MaxTextExtent];
@@ -667,15 +749,15 @@ static unsigned long ValidateImageFormatsOnDisk(ImageInfo *image_info,
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     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);
@@ -689,81 +771,83 @@ static unsigned long ValidateImageFormatsOnDisk(ImageInfo *image_info,
         Generate reference image.
       */
       CatchException(exception);
-      (void) fprintf(stdout,"  test %lu: %s/%s/%s/%lu-bits",test++,
-        reference_formats[i].magick,MagickOptionToMnemonic(
+      (void) FormatLocaleFile(stdout,"  test %.20g: %s/%s/%s/%.20g-bits",
+        (double) (test++),reference_formats[i].magick,CommandOptionToMnemonic(
         MagickCompressOptions,reference_formats[i].compression),
-        MagickOptionToMnemonic(MagickTypeOptions,reference_types[j].type),
-        reference_types[j].depth);
+        CommandOptionToMnemonic(MagickTypeOptions,reference_types[j].type),
+        (double) reference_types[j].depth);
       (void) CopyMagickString(image_info->filename,reference_filename,
         MaxTextExtent);
       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,"%lux%lu",
-        reference_image->columns,reference_image->rows);
+      (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;
@@ -771,12 +855,13 @@ static unsigned long 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;
@@ -790,32 +875,34 @@ static unsigned long ValidateImageFormatsOnDisk(ImageInfo *image_info,
 #if defined(MAGICKCORE_HDRI_SUPPORT)
       fuzz+=0.003;
 #endif
-      if (reference_image->colorspace != RGBColorspace)
+      if (IssRGBColorspace(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,
+        RootMeanSquaredErrorMetric,&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)
+      if ((QuantumScale*distortion) > fuzz)
         {
-          (void) fprintf(stdout,"... fail (with distortion %g).\n",distortion/
-            QuantumRange);
+          (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
+            QuantumScale*distortion);
           (*fail)++;
           continue;
         }
-      (void) fprintf(stdout,"... pass.\n");
+      (void) FormatLocaleFile(stdout,"... pass.\n");
     }
   }
-  (void) fprintf(stdout,"  summary: %lu subtests; %lu passed; %lu failed.\n",
-    test,test-(*fail),*fail);
+  (void) FormatLocaleFile(stdout,
+    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
+    (double) (test-(*fail)),(double) *fail);
   return(test);
 }
 \f
@@ -835,9 +922,9 @@ static unsigned long ValidateImageFormatsOnDisk(ImageInfo *image_info,
 %
 %  The format of the ValidateImportExportPixels method is:
 %
-%      unsigned long ValidateImportExportPixels(ImageInfo *image_info,
+%      size_t ValidateImportExportPixels(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -852,9 +939,9 @@ static unsigned long ValidateImageFormatsOnDisk(ImageInfo *image_info,
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateImportExportPixels(ImageInfo *image_info,
-  const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+static size_t ValidateImportExportPixels(ImageInfo *image_info,
+  const char *reference_filename,const char *output_filename,size_t *fail,
+  ExceptionInfo *exception)
 {
   double
     distortion;
@@ -867,7 +954,7 @@ static unsigned long ValidateImportExportPixels(ImageInfo *image_info,
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
@@ -877,12 +964,13 @@ static unsigned long ValidateImportExportPixels(ImageInfo *image_info,
   unsigned char
     *pixels;
 
-  unsigned long
+  size_t
     test;
 
   (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++)
@@ -891,26 +979,28 @@ static unsigned long ValidateImportExportPixels(ImageInfo *image_info,
         Generate reference image.
       */
       CatchException(exception);
-      (void) fprintf(stdout,"  test %lu: %s/%s",test++,
-        reference_map[i],MagickOptionToMnemonic(MagickStorageOptions,
+      (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,
         MaxTextExtent);
       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);
+        (void) SetImageColorspace(reference_image,CMYKColorspace,exception);
       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;
@@ -921,20 +1011,21 @@ static unsigned long 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);
@@ -943,19 +1034,20 @@ static unsigned long 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;
@@ -963,29 +1055,31 @@ static unsigned long 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,
+        RootMeanSquaredErrorMetric,&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)
+      if ((QuantumScale*distortion) > 0.0)
         {
-          (void) fprintf(stdout,"... fail (with distortion %g).\n",distortion/
-            QuantumRange);
+          (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
+            QuantumScale*distortion);
           (*fail)++;
           continue;
         }
-      (void) fprintf(stdout,"... pass.\n");
+      (void) FormatLocaleFile(stdout,"... pass.\n");
     }
   }
-  (void) fprintf(stdout,"  summary: %lu subtests; %lu passed; %lu failed.\n",
-    test,test-(*fail),*fail);
+  (void) FormatLocaleFile(stdout,
+    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
+    (double) (test-(*fail)),(double) *fail);
   return(test);
 }
 \f
@@ -1005,9 +1099,9 @@ static unsigned long ValidateImportExportPixels(ImageInfo *image_info,
 %
 %  The format of the ValidateMontageCommand method is:
 %
-%      unsigned long ValidateMontageCommand(ImageInfo *image_info,
+%      size_t ValidateMontageCommand(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -1022,9 +1116,9 @@ static unsigned long ValidateImportExportPixels(ImageInfo *image_info,
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateMontageCommand(ImageInfo *image_info,
-  const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+static size_t ValidateMontageCommand(ImageInfo *image_info,
+  const char *reference_filename,const char *output_filename,size_t *fail,
+  ExceptionInfo *exception)
 {
   char
     **arguments,
@@ -1036,44 +1130,48 @@ static unsigned long ValidateMontageCommand(ImageInfo *image_info,
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     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 %lu: %s",test++,montage_options[i]);
-    (void) FormatMagickString(command,MaxTextExtent,"%s %s %s %s",
+    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) (test++),
+      montage_options[i]);
+    (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,"  summary: %lu subtests; %lu passed; %lu failed.\n",
-    test,test-(*fail),*fail);
+  (void) FormatLocaleFile(stdout,
+    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
+    (double) (test-(*fail)),(double) *fail);
   return(test);
 }
 \f
@@ -1093,9 +1191,9 @@ static unsigned long ValidateMontageCommand(ImageInfo *image_info,
 %
 %  The format of the ValidateStreamCommand method is:
 %
-%      unsigned long ValidateStreamCommand(ImageInfo *image_info,
+%      size_t ValidateStreamCommand(ImageInfo *image_info,
 %        const char *reference_filename,const char *output_filename,
-%        unsigned long *fail,ExceptionInfo *exception)
+%        size_t *fail,ExceptionInfo *exception)
 %
 %  A description of each parameter follows:
 %
@@ -1110,9 +1208,9 @@ static unsigned long ValidateMontageCommand(ImageInfo *image_info,
 %    o exception: return any errors or warnings in this structure.
 %
 */
-static unsigned long ValidateStreamCommand(ImageInfo *image_info,
-  const char *reference_filename,const char *output_filename,
-  unsigned long *fail,ExceptionInfo *exception)
+static size_t ValidateStreamCommand(ImageInfo *image_info,
+  const char *reference_filename,const char *output_filename,size_t *fail,
+  ExceptionInfo *exception)
 {
   char
     **arguments,
@@ -1124,43 +1222,47 @@ static unsigned long ValidateStreamCommand(ImageInfo *image_info,
   MagickBooleanType
     status;
 
-  register long
+  register ssize_t
     i,
     j;
 
-  unsigned long
+  size_t
     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 %lu: %s",test++,stream_options[i]);
-    (void) FormatMagickString(command,MaxTextExtent,"%s %s %s",
+    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) (test++),
+      stream_options[i]);
+    (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,"  summary: %lu subtests; %lu passed; %lu failed.\n",
-    test,test-(*fail),*fail);
+  (void) FormatLocaleFile(stdout,
+    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
+    (double) (test-(*fail)),(double) *fail);
   return(test);
 }
 \f
@@ -1200,8 +1302,9 @@ static MagickBooleanType ValidateUsage(void)
       (char *) NULL
     };
 
-  (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
+  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
   (void) printf("Copyright: %s\n\n",GetMagickCopyright());
+  (void) printf("Features: %s\n",GetMagickFeatures());
   (void) printf("Usage: %s [options ...] reference-file\n",GetClientName());
   (void) printf("\nValidate Settings:\n");
   for (p=settings; *p != (char *) NULL; p++)
@@ -1250,13 +1353,17 @@ int main(int argc,char **argv)
     regard_warnings,
     status;
 
-  register long
+  MagickSizeType
+    memory_resource,
+    map_resource;
+
+  register ssize_t
     i;
 
   TimerInfo
     *timer;
 
-  unsigned long
+  size_t
     fail,
     iterations,
     tests;
@@ -1267,18 +1374,21 @@ int main(int argc,char **argv)
   /*
     Validate the ImageMagick image processing suite.
   */
-  MagickCoreGenesis(*argv,MagickFalse);
+  MagickCoreGenesis(*argv,MagickTrue);
+  (void) setlocale(LC_ALL,"");
+  (void) setlocale(LC_NUMERIC,"C");
   iterations=1;
   status=MagickFalse;
   type=AllValidate;
   regard_warnings=MagickFalse;
+  (void) regard_warnings;
   exception=AcquireExceptionInfo();
   image_info=AcquireImageInfo();
   (void) CopyMagickString(image_info->filename,ReferenceFilename,MaxTextExtent);
-  for (i=1; i < (long) argc; i++)
+  for (i=1; i < (ssize_t) argc; i++)
   {
     option=argv[i];
-    if (IsMagickOption(option) == MagickFalse)
+    if (IsCommandOption(option) == MagickFalse)
       {
         (void) CopyMagickString(image_info->filename,option,MaxTextExtent);
         continue;
@@ -1289,7 +1399,7 @@ int main(int argc,char **argv)
       {
         if (LocaleCompare("bench",option+1) == 0)
           {
-            iterations=(unsigned long) atol(argv[++i]);
+            iterations=StringToUnsignedLong(argv[++i]);
             break;
           }
         ThrowValidateException(OptionError,"UnrecognizedOption",option)
@@ -1335,15 +1445,15 @@ int main(int argc,char **argv)
       {
         if (LocaleCompare("validate",option+1) == 0)
           {
-            long
+            ssize_t
               validate;
 
             if (*option == '+')
               break;
             i++;
-            if (i == (long) argc)
+            if (i == (ssize_t) argc)
               ThrowValidateException(OptionError,"MissingArgument",option);
-            validate=ParseMagickOption(MagickValidateOptions,MagickFalse,
+            validate=ParseCommandOption(MagickValidateOptions,MagickFalse,
               argv[i]);
             if (validate < 0)
               ThrowValidateException(OptionError,"UnrecognizedValidateType",
@@ -1354,9 +1464,12 @@ int main(int argc,char **argv)
         if ((LocaleCompare("version",option+1) == 0) ||
             (LocaleCompare("-version",option+1) == 0))
           {
-            (void) fprintf(stdout,"Version: %s\n",
-              GetMagickVersion((unsigned long *) NULL));
-            (void) fprintf(stdout,"Copyright: %s\n\n",GetMagickCopyright());
+            (void) FormatLocaleFile(stdout,"Version: %s\n",
+              GetMagickVersion((size_t *) NULL));
+            (void) FormatLocaleFile(stdout,"Copyright: %s\n\n",
+              GetMagickCopyright());
+            (void) FormatLocaleFile(stdout,"Features: %s\n\n",
+              GetMagickFeatures());
             return(0);
           }
         ThrowValidateException(OptionError,"UnrecognizedOption",option)
@@ -1382,19 +1495,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",
-            GetMagickVersion((unsigned long *) NULL));
-          (void) fprintf(stdout,"Copyright: %s\n\n",
+          (void) FormatLocaleFile(stdout,"Version: %s\n",
+            GetMagickVersion((size_t *) NULL));
+          (void) FormatLocaleFile(stdout,"Copyright: %s\n\n",
             GetMagickCopyright());
-          (void) fprintf(stdout,"ImageMagick Validation Suite (%s)\n\n",
-            MagickOptionToMnemonic(MagickValidateOptions,(long) 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);
@@ -1405,11 +1518,37 @@ int main(int argc,char **argv)
             tests+=ValidateConvertCommand(image_info,reference_filename,
               output_filename,&fail,exception);
           if ((type & FormatsInMemoryValidate) != 0)
-            tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
-              output_filename,&fail,exception);
+            {
+              (void) FormatLocaleFile(stdout,"[pixel-cache: memory] ");
+              tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
+                output_filename,&fail,exception);
+              (void) FormatLocaleFile(stdout,"[pixel-cache: memory-mapped] ");
+              memory_resource=SetMagickResourceLimit(MemoryResource,0);
+              tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
+                output_filename,&fail,exception);
+              (void) FormatLocaleFile(stdout,"[pixel-cache: disk] ");
+              map_resource=SetMagickResourceLimit(MapResource,0);
+              tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
+                output_filename,&fail,exception);
+              (void) SetMagickResourceLimit(MemoryResource,memory_resource);
+              (void) SetMagickResourceLimit(MapResource,map_resource);
+            }
           if ((type & FormatsOnDiskValidate) != 0)
-            tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
-              output_filename,&fail,exception);
+            {
+              (void) FormatLocaleFile(stdout,"[pixel-cache: memory] ");
+              tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
+                output_filename,&fail,exception);
+              (void) FormatLocaleFile(stdout,"[pixel-cache: memory-mapped] ");
+              memory_resource=SetMagickResourceLimit(MemoryResource,0);
+              tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
+                output_filename,&fail,exception);
+              (void) FormatLocaleFile(stdout,"[pixel-cache: disk] ");
+              map_resource=SetMagickResourceLimit(MapResource,0);
+              tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
+                output_filename,&fail,exception);
+              (void) SetMagickResourceLimit(MemoryResource,memory_resource);
+              (void) SetMagickResourceLimit(MapResource,map_resource);
+            }
           if ((type & IdentifyValidate) != 0)
             tests+=ValidateIdentifyCommand(image_info,reference_filename,
               output_filename,&fail,exception);
@@ -1422,8 +1561,9 @@ int main(int argc,char **argv)
           if ((type & StreamValidate) != 0)
             tests+=ValidateStreamCommand(image_info,reference_filename,
               output_filename,&fail,exception);
-          (void) fprintf(stdout,"validation suite: %lu tests; %lu passed; "
-            "%lu failed.\n",tests,tests-fail,fail);
+          (void) FormatLocaleFile(stdout,
+            "validation suite: %.20g tests; %.20g passed; %.20g failed.\n",
+            (double) tests,(double) (tests-fail),(double) fail);
         }
       (void) RelinquishUniqueFileResource(output_filename);
       (void) RelinquishUniqueFileResource(reference_filename);
@@ -1434,7 +1574,8 @@ int main(int argc,char **argv)
     {
       elapsed_time=GetElapsedTime(timer);
       user_time=GetUserTime(timer);
-      (void) fprintf(stderr,"Performance: %lui %gips %0.3fu %ld:%02ld.%03ld\n",
+      (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)),
         (long) (1000.0*(elapsed_time-floor(elapsed_time))));