validate.c revision 4084cda465bf1f01d00c2f6e4a6d6f446889cad4
13ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
23ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
43ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
53ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
63ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
73ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%           V   V   AAA   L      IIIII  DDDD    AAA   TTTTT  EEEEE            %
83ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%           V   V  A   A  L        I    D   D  A   A    T    E                %
93ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%           V   V  AAAAA  L        I    D   D  AAAAA    T    EEE              %
103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%            V V   A   A  L        I    D   D  A   A    T    E                %
113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%             V    A   A  LLLLL  IIIII  DDDD   A   A    T    EEEEE            %
123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                        ImageMagick Validation Suite                         %
153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                             Software Design                                 %
173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                               John Cristy                                   %
183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                               March 2001                                    %
193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2145ef08fd6a09813e4a8f5ddadf85ba9e0ec2cdc7cristy%  Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization      %
223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  dedicated to making software imaging solutions freely available.           %
233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  You may not use this file except in compliance with the License.  You may  %
253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  obtain a copy of the License at                                            %
263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    http://www.imagemagick.org/script/license.php                            %
283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  Unless required by applicable law or agreed to in writing, software        %
303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  distributed under the License is distributed on an "AS IS" BASIS,          %
313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  see the License for the specific language governing permissions and        %
333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  limitations under the License.                                             %
343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  Include declarations.
423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include <stdio.h>
445e8e98117d8549131cd304db78537e04dde513f5cristy#include <stdlib.h>
453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include <string.h>
465e8e98117d8549131cd304db78537e04dde513f5cristy#include <ctype.h>
473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include <math.h>
489883b4524275800ecb55867d94952449dc519444cristy#include "MagickWand/MagickWand.h"
49510d06a3f7063e91993e13d546d5685048248074cristy#include "MagickCore/colorspace-private.h"
504084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp#include "MagickCore/resource_.h"
519883b4524275800ecb55867d94952449dc519444cristy#include "MagickCore/string-private.h"
523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#include "validate.h"
533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   V a l i d a t e C o m p a r e C o m m a n d                               %
603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  ValidateCompareCommand() validates the ImageMagick compare command line
663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  program and returns the number of validation tests that passed and failed.
673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the ValidateCompareCommand method is:
693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
70bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%      size_t ValidateCompareCommand(ImageInfo *image_info,
713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *reference_filename,const char *output_filename,
72bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%        size_t *fail,ExceptionInfo *exception)
733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o image_info: the image info.
773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reference_filename: the reference image filename.
793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o output_filename: the output image filename.
813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o fail: return the number of validation tests that pass.
833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: return any errors or warnings in this structure.
853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
87bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic size_t ValidateCompareCommand(ImageInfo *image_info,
880d772eda43795018942c81aac81ac0c8b3d92018cristy  const char *reference_filename,const char *output_filename,size_t *fail,
890d772eda43795018942c81aac81ac0c8b3d92018cristy  ExceptionInfo *exception)
903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  char
923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    **arguments,
933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    command[MaxTextExtent];
943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  int
963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    number_arguments;
973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status;
1003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
101bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  register ssize_t
1023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    i,
1033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    j;
1043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
105bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  size_t
1063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    test;
1073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  test=0;
109b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,"validate compare command line program:\n");
1103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  for (i=0; compare_options[i] != (char *) NULL; i++)
1113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
1123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    CatchException(exception);
113b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) (test++),
1146aa47adc8b43dfdf8d1c2b6323c0bb1f57a5f011cristy      compare_options[i]);
115b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s %s",
1163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      compare_options[i],reference_filename,reference_filename,output_filename);
1173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    arguments=StringToArgv(command,&number_arguments);
1183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (arguments == (char **) NULL)
1193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
1201e604812fad85bb96f757a2393015ae3d061c39acristy        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1211e604812fad85bb96f757a2393015ae3d061c39acristy          GetMagickModule());
1223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (*fail)++;
1233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
1243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
1258a9106f4d81487da0f318bd13b4caa4cd24f23afcristy    status=CompareImagesCommand(image_info,number_arguments,arguments,
1263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (char **) NULL,exception);
127e42f658533644aecb733785ffd91b286d6778deacristy    for (j=0; j < (ssize_t) number_arguments; j++)
1283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      arguments[j]=DestroyString(arguments[j]);
1293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    arguments=(char **) RelinquishMagickMemory(arguments);
1303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (status != MagickFalse)
1313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
1321e604812fad85bb96f757a2393015ae3d061c39acristy        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1331e604812fad85bb96f757a2393015ae3d061c39acristy          GetMagickModule());
1343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (*fail)++;
1353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
1363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
137b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stdout,"... pass.\n");
1383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
139b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,
14075a2623568540f98985ce5bb1d88687eb9c85d2ecristy    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
14175a2623568540f98985ce5bb1d88687eb9c85d2ecristy    (double) (test-(*fail)),(double) *fail);
1423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(test);
1433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
1443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
1463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   V a l i d a t e C o m p o s i t e C o m m a n d                           %
1513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
1543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  ValidateCompositeCommand() validates the ImageMagick composite command line
1573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  program and returns the number of validation tests that passed and failed.
1583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the ValidateCompositeCommand method is:
1603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
161bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%      size_t ValidateCompositeCommand(ImageInfo *image_info,
1623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *reference_filename,const char *output_filename,
163bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%        size_t *fail,ExceptionInfo *exception)
1643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
1663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o image_info: the image info.
1683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reference_filename: the reference image filename.
1703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o output_filename: the output image filename.
1723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o fail: return the number of validation tests that pass.
1743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: return any errors or warnings in this structure.
1763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
178bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic size_t ValidateCompositeCommand(ImageInfo *image_info,
1790d772eda43795018942c81aac81ac0c8b3d92018cristy  const char *reference_filename,const char *output_filename,size_t *fail,
1800d772eda43795018942c81aac81ac0c8b3d92018cristy  ExceptionInfo *exception)
1813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
1823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  char
1833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    **arguments,
1843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    command[MaxTextExtent];
1853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  int
1873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    number_arguments;
1883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
1903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status;
1913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
192bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  register ssize_t
1933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    i,
1943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    j;
1953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
196bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  size_t
1973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    test;
1983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  test=0;
200b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,"validate composite command line program:\n");
2013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  for (i=0; composite_options[i] != (char *) NULL; i++)
2023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
2033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    CatchException(exception);
204b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) (test++),
2056aa47adc8b43dfdf8d1c2b6323c0bb1f57a5f011cristy      composite_options[i]);
206b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s %s",
2073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_filename,composite_options[i],reference_filename,
2083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      output_filename);
2093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    arguments=StringToArgv(command,&number_arguments);
2103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (arguments == (char **) NULL)
2113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
2121e604812fad85bb96f757a2393015ae3d061c39acristy        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
2131e604812fad85bb96f757a2393015ae3d061c39acristy          GetMagickModule());
2143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (*fail)++;
2153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
2163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
2173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status=CompositeImageCommand(image_info,number_arguments,arguments,
2183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (char **) NULL,exception);
219e42f658533644aecb733785ffd91b286d6778deacristy    for (j=0; j < (ssize_t) number_arguments; j++)
2203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      arguments[j]=DestroyString(arguments[j]);
2213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    arguments=(char **) RelinquishMagickMemory(arguments);
2223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (status != MagickFalse)
2233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
2241e604812fad85bb96f757a2393015ae3d061c39acristy        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
2251e604812fad85bb96f757a2393015ae3d061c39acristy          GetMagickModule());
2263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (*fail)++;
2273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
2283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
229b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stdout,"... pass.\n");
2303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
231b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,
23275a2623568540f98985ce5bb1d88687eb9c85d2ecristy    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
23375a2623568540f98985ce5bb1d88687eb9c85d2ecristy    (double) (test-(*fail)),(double) *fail);
2343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(test);
2353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
2363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
2383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   V a l i d a t e C o n v e r t C o m m a n d                               %
2433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
2463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  ValidateConvertCommand() validates the ImageMagick convert command line
2493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  program and returns the number of validation tests that passed and failed.
2503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the ValidateConvertCommand method is:
2523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
253bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%      size_t ValidateConvertCommand(ImageInfo *image_info,
2543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *reference_filename,const char *output_filename,
255bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%        size_t *fail,ExceptionInfo *exception)
2563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
2583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o image_info: the image info.
2603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reference_filename: the reference image filename.
2623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o output_filename: the output image filename.
2643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o fail: return the number of validation tests that pass.
2663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: return any errors or warnings in this structure.
2683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
2693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
270bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic size_t ValidateConvertCommand(ImageInfo *image_info,
2710d772eda43795018942c81aac81ac0c8b3d92018cristy  const char *reference_filename,const char *output_filename,size_t *fail,
2720d772eda43795018942c81aac81ac0c8b3d92018cristy  ExceptionInfo *exception)
2733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
2743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  char
2753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    **arguments,
2763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    command[MaxTextExtent];
2773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  int
2793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    number_arguments;
2803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
2823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status;
2833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
284bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  register ssize_t
2853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    i,
2863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    j;
2873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
288bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  size_t
2893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    test;
2903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
2913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  test=0;
292b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,"validate convert command line program:\n");
2933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  for (i=0; convert_options[i] != (char *) NULL; i++)
2943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
2953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    CatchException(exception);
296b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) test++,
2976aa47adc8b43dfdf8d1c2b6323c0bb1f57a5f011cristy      convert_options[i]);
298b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s %s",
2993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_filename,convert_options[i],reference_filename,output_filename);
3003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    arguments=StringToArgv(command,&number_arguments);
3013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (arguments == (char **) NULL)
3023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
3031e604812fad85bb96f757a2393015ae3d061c39acristy        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
3041e604812fad85bb96f757a2393015ae3d061c39acristy          GetMagickModule());
3053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (*fail)++;
3063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
3073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
3083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status=ConvertImageCommand(image_info,number_arguments,arguments,
3093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (char **) NULL,exception);
310e42f658533644aecb733785ffd91b286d6778deacristy    for (j=0; j < (ssize_t) number_arguments; j++)
3113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      arguments[j]=DestroyString(arguments[j]);
3123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    arguments=(char **) RelinquishMagickMemory(arguments);
3133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (status != MagickFalse)
3143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
3151e604812fad85bb96f757a2393015ae3d061c39acristy        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
3161e604812fad85bb96f757a2393015ae3d061c39acristy          GetMagickModule());
3173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (*fail)++;
3183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
3193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
320b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stdout,"... pass.\n");
3213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
322b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,
32375a2623568540f98985ce5bb1d88687eb9c85d2ecristy    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
32475a2623568540f98985ce5bb1d88687eb9c85d2ecristy    (double) (test-(*fail)),(double) *fail);
3253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(test);
3263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
3273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
3293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   V a l i d a t e I d e n t i f y C o m m a n d                             %
3343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
3373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  ValidateIdentifyCommand() validates the ImageMagick identify command line
3403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  program and returns the number of validation tests that passed and failed.
3413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the ValidateIdentifyCommand method is:
3433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
344bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%      size_t ValidateIdentifyCommand(ImageInfo *image_info,
3453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *reference_filename,const char *output_filename,
346bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%        size_t *fail,ExceptionInfo *exception)
3473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
3493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o image_info: the image info.
3513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reference_filename: the reference image filename.
3533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o output_filename: the output image filename.
3553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o fail: return the number of validation tests that pass.
3573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: return any errors or warnings in this structure.
3593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
3603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
361bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic size_t ValidateIdentifyCommand(ImageInfo *image_info,
3620d772eda43795018942c81aac81ac0c8b3d92018cristy  const char *reference_filename,const char *output_filename,size_t *fail,
3630d772eda43795018942c81aac81ac0c8b3d92018cristy  ExceptionInfo *exception)
3643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
3653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  char
3663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    **arguments,
3673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    command[MaxTextExtent];
3683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  int
3703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    number_arguments;
3713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
3733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status;
3743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
375bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  register ssize_t
3763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    i,
3773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    j;
3783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
379bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  size_t
3803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    test;
3813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
3823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) output_filename;
3833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  test=0;
384b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,"validate identify command line program:\n");
3853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  for (i=0; identify_options[i] != (char *) NULL; i++)
3863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
3873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    CatchException(exception);
388b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) test++,
3896aa47adc8b43dfdf8d1c2b6323c0bb1f57a5f011cristy      identify_options[i]);
390b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleString(command,MaxTextExtent,"%s %s",
3913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      identify_options[i],reference_filename);
3923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    arguments=StringToArgv(command,&number_arguments);
3933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (arguments == (char **) NULL)
3943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
3951e604812fad85bb96f757a2393015ae3d061c39acristy        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
3961e604812fad85bb96f757a2393015ae3d061c39acristy          GetMagickModule());
3973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (*fail)++;
3983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
3993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
4003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status=IdentifyImageCommand(image_info,number_arguments,arguments,
4013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (char **) NULL,exception);
402e42f658533644aecb733785ffd91b286d6778deacristy    for (j=0; j < (ssize_t) number_arguments; j++)
4033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      arguments[j]=DestroyString(arguments[j]);
4043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    arguments=(char **) RelinquishMagickMemory(arguments);
4053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (status != MagickFalse)
4063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
4071e604812fad85bb96f757a2393015ae3d061c39acristy        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
4081e604812fad85bb96f757a2393015ae3d061c39acristy          GetMagickModule());
4093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (*fail)++;
4103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
4113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
412b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stdout,"... pass.\n");
4133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
414b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,
41575a2623568540f98985ce5bb1d88687eb9c85d2ecristy    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
41675a2623568540f98985ce5bb1d88687eb9c85d2ecristy    (double) (test-(*fail)),(double) *fail);
4173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(test);
4183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
4193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
4213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   V a l i d a t e I m a g e F o r m a t s I n M e m o r y                   %
4263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
4293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  ValidateImageFormatsInMemory() validates the ImageMagick image formats in
4323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  memory and returns the number of validation tests that passed and failed.
4333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the ValidateImageFormatsInMemory method is:
4353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
436bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%      size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
4373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *reference_filename,const char *output_filename,
438bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%        size_t *fail,ExceptionInfo *exception)
4393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
4413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o image_info: the image info.
4433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reference_filename: the reference image filename.
4453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o output_filename: the output image filename.
4473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o fail: return the number of validation tests that pass.
4493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: return any errors or warnings in this structure.
4513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
4523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
4534084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp
4544084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp/* Enable this to count remaining $TMPDIR/magick-* files.
4554084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp * Note that the count includes any files left over from other runs.
4564084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp */
4574084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp#define MagickCountTempFiles
4584084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp
459bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
4600d772eda43795018942c81aac81ac0c8b3d92018cristy  const char *reference_filename,const char *output_filename,size_t *fail,
4610d772eda43795018942c81aac81ac0c8b3d92018cristy  ExceptionInfo *exception)
4623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
4633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  char
4644084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp#ifdef MagickCountTempFiles
4654084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp    SystemCommand[MaxTextExtent],
4664084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp    path[MaxTextExtent],
4674084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp#endif
4683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    size[MaxTextExtent];
4693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const MagickInfo
4713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *magick_info;
4723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  double
4743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    distortion,
4753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    fuzz;
4763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  Image
4783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *difference_image,
4792c404226c827fe0799858fc345a1bea11f2cb546cristy    *ping_image,
4806b9ae3f81646d1b6a7d25f7125cb0ff943bad750cristy    *reconstruct_image,
481100b8d9c4f78f07a52dac4aec46abfe4c2013196cristy    *reference_image;
4823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
4843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status;
4853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
486bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  register ssize_t
4873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    i,
4883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    j;
4893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  size_t
491100b8d9c4f78f07a52dac4aec46abfe4c2013196cristy    length,
492100b8d9c4f78f07a52dac4aec46abfe4c2013196cristy    test;
4933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  unsigned char
4953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *blob;
4963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
4973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  test=0;
498b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,"validate image formats in memory:\n");
4994084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp
5004084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp#ifdef MagickCountTempFiles
5014084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp  (void)GetPathTemplate(path);
5024084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp  /* Remove file template except for the leading "magick-" */
5034084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp  path[strlen(path)-17]='\0';
5044084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp  (void) FormatLocaleFile(stdout," tmp path is '%s*'\n",path);
5054084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp#endif
5064084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp
5073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  for (i=0; reference_formats[i].magick != (char *) NULL; i++)
5083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
5093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    magick_info=GetMagickInfo(reference_formats[i].magick,exception);
5103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if ((magick_info == (const MagickInfo *) NULL) ||
5113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (magick_info->decoder == (DecodeImageHandler *) NULL) ||
5123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (magick_info->encoder == (EncodeImageHandler *) NULL))
5133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      continue;
5145f1c1fff2a55c4d8756556e78c1f307d352ed1b8cristy    for (j=0; reference_types[j].type != UndefinedType; j++)
5153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    {
5163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
5173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Generate reference image.
5183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
5193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      CatchException(exception);
5201e604812fad85bb96f757a2393015ae3d061c39acristy      (void) FormatLocaleFile(stdout,"  test %.20g: %s/%s/%s/%.20g-bits",
5211e604812fad85bb96f757a2393015ae3d061c39acristy        (double) (test++),reference_formats[i].magick,CommandOptionToMnemonic(
5227998e5fecd99cd9838e7a960168f48b92d38bbfccristy        MagickCompressOptions,reference_formats[i].compression),
523042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy        CommandOptionToMnemonic(MagickTypeOptions,reference_types[j].type),
52475a2623568540f98985ce5bb1d88687eb9c85d2ecristy        (double) reference_types[j].depth);
5253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (void) CopyMagickString(image_info->filename,reference_filename,
5263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        MaxTextExtent);
5273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_image=ReadImage(image_info,exception);
5283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (reference_image == (Image *) NULL)
5293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
5301e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
5311e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
5323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
5333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
5343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
5353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
5363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Write reference image.
5373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
538b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleString(size,MaxTextExtent,"%.20gx%.20g",
53975a2623568540f98985ce5bb1d88687eb9c85d2ecristy        (double) reference_image->columns,(double) reference_image->rows);
5403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (void) CloneString(&image_info->size,size);
5413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      image_info->depth=reference_types[j].depth;
542b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleString(reference_image->filename,MaxTextExtent,"%s:%s",
5433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        reference_formats[i].magick,output_filename);
544018f07f7333b25743d0afff892450cebdb905c1acristy      status=SetImageType(reference_image,reference_types[j].type,exception);
5453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (status == MagickFalse)
5463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
5471e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
5481e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
5493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
5503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          reference_image=DestroyImage(reference_image);
5513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
5523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
5538a11cb146177680bfc1b7d89a8cd0c8f2befe468cristy      status=SetImageDepth(reference_image,reference_types[j].depth,exception);
5543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (status == MagickFalse)
5553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
5561e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
5571e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
5583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
5593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          reference_image=DestroyImage(reference_image);
5603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
5613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
5627998e5fecd99cd9838e7a960168f48b92d38bbfccristy      reference_image->compression=reference_formats[i].compression;
5636f9e0d38526c24e02e6207b1d494fa8fad072b9ccristy      status=WriteImage(image_info,reference_image,exception);
5643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_image=DestroyImage(reference_image);
5653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (status == MagickFalse)
5663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
5671e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
5681e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
5693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
5703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
5713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
5723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
5732c404226c827fe0799858fc345a1bea11f2cb546cristy        Ping reference image.
5743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
575b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
5763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        reference_formats[i].magick,output_filename);
5772c404226c827fe0799858fc345a1bea11f2cb546cristy      ping_image=PingImage(image_info,exception);
5782c404226c827fe0799858fc345a1bea11f2cb546cristy      if (ping_image == (Image *) NULL)
5792c404226c827fe0799858fc345a1bea11f2cb546cristy        {
5802c404226c827fe0799858fc345a1bea11f2cb546cristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
5812c404226c827fe0799858fc345a1bea11f2cb546cristy            GetMagickModule());
5822c404226c827fe0799858fc345a1bea11f2cb546cristy          (*fail)++;
5832c404226c827fe0799858fc345a1bea11f2cb546cristy          continue;
5842c404226c827fe0799858fc345a1bea11f2cb546cristy        }
5852c404226c827fe0799858fc345a1bea11f2cb546cristy      ping_image=DestroyImage(ping_image);
5862c404226c827fe0799858fc345a1bea11f2cb546cristy      /*
5872c404226c827fe0799858fc345a1bea11f2cb546cristy        Read reference image.
5882c404226c827fe0799858fc345a1bea11f2cb546cristy      */
5893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_image=ReadImage(image_info,exception);
5903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (reference_image == (Image *) NULL)
5913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
5921e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
5931e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
5943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
5953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
5963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
5973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
5983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Write reference image.
5993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
600b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleString(reference_image->filename,MaxTextExtent,"%s:%s",
6013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        reference_formats[i].magick,output_filename);
6023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (void) CopyMagickString(image_info->magick,reference_formats[i].magick,
6033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        MaxTextExtent);
6043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_image->depth=reference_types[j].depth;
6057998e5fecd99cd9838e7a960168f48b92d38bbfccristy      reference_image->compression=reference_formats[i].compression;
6063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      length=8192;
6073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      blob=ImageToBlob(image_info,reference_image,&length,exception);
6083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (blob == (unsigned char *) NULL)
6093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
6101e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
6111e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
6123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
6133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          reference_image=DestroyImage(reference_image);
6143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
6153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
6163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
6172c404226c827fe0799858fc345a1bea11f2cb546cristy        Ping reference blob.
6182c404226c827fe0799858fc345a1bea11f2cb546cristy      */
6192c404226c827fe0799858fc345a1bea11f2cb546cristy      ping_image=PingBlob(image_info,blob,length,exception);
6202c404226c827fe0799858fc345a1bea11f2cb546cristy      if (ping_image == (Image *) NULL)
6212c404226c827fe0799858fc345a1bea11f2cb546cristy        {
6222c404226c827fe0799858fc345a1bea11f2cb546cristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
6232c404226c827fe0799858fc345a1bea11f2cb546cristy            GetMagickModule());
6242c404226c827fe0799858fc345a1bea11f2cb546cristy          (*fail)++;
6252c404226c827fe0799858fc345a1bea11f2cb546cristy          blob=(unsigned char *) RelinquishMagickMemory(blob);
6262c404226c827fe0799858fc345a1bea11f2cb546cristy          continue;
6272c404226c827fe0799858fc345a1bea11f2cb546cristy        }
6282c404226c827fe0799858fc345a1bea11f2cb546cristy      ping_image=DestroyImage(ping_image);
6292c404226c827fe0799858fc345a1bea11f2cb546cristy      /*
6303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Read reconstruct image.
6313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
632b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
6333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        reference_formats[i].magick,output_filename);
6343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reconstruct_image=BlobToImage(image_info,blob,length,exception);
6353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      blob=(unsigned char *) RelinquishMagickMemory(blob);
6363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (reconstruct_image == (Image *) NULL)
6373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
6381e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
6391e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
6403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
6413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          reference_image=DestroyImage(reference_image);
6423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
6433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
6443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
6453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Compare reference to reconstruct image.
6463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
6473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      fuzz=0.0;
6483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (reference_formats[i].fuzz != 0.0)
6493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        fuzz=reference_formats[i].fuzz;
6503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HDRI_SUPPORT)
6513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      fuzz+=0.003;
6523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif
653501c5597e8d10b6102a4566f2740f4166bdd545fcristy      if (IssRGBColorspace(reference_image->colorspace) == MagickFalse)
6543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        fuzz+=0.3;
6557e9255b649960d02c30b7c9fb9ed578506546320cristy      fuzz+=MagickEpsilon;
6568a9106f4d81487da0f318bd13b4caa4cd24f23afcristy      difference_image=CompareImages(reference_image,reconstruct_image,
657864c6a8f0dbf656fcc51e2f526c6a7c7a4d46c81cristy        RootMeanSquaredErrorMetric,&distortion,exception);
6583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reconstruct_image=DestroyImage(reconstruct_image);
6593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_image=DestroyImage(reference_image);
6603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (difference_image == (Image *) NULL)
6613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
6621e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
6631e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
6643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
6653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
6663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
6673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      difference_image=DestroyImage(difference_image);
66814154224e937198c540f38d146528c0cdc45d24dcristy      if ((QuantumScale*distortion) > fuzz)
6693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
670b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy          (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
67114154224e937198c540f38d146528c0cdc45d24dcristy            QuantumScale*distortion);
6723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
6733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
6743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
6754084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp
6764084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp#ifdef MagickCountTempFiles
6774084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp      (void) FormatLocaleFile(stdout,"... pass, ");
6784084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp      (void) fflush(stdout);
6794084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp      SystemCommand[0]='\0';
6804084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp      (void)strncat(SystemCommand,"echo `ls ",9);
6814084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp      (void)strncat(SystemCommand,path,MaxTextExtent-31);
6824084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp      (void)strncat(SystemCommand,"* | wc -w` tmp files.",20);
6834084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp      (void)system(SystemCommand);
6844084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp      (void) fflush(stdout);
6854084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp#else
6864084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp      (void) FormatLocaleFile(stdout,"... pass\n");
6874084cda465bf1f01d00c2f6e4a6d6f446889cad4glennrp#endif
6883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    }
6893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
690b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,
69175a2623568540f98985ce5bb1d88687eb9c85d2ecristy    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
69275a2623568540f98985ce5bb1d88687eb9c85d2ecristy    (double) (test-(*fail)),(double) *fail);
6933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(test);
6943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
6953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
6963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
6973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
6993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   V a l i d a t e I m a g e F o r m a t s O n D i s k                       %
7023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
7053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  ValidateImageFormatsOnDisk() validates the ImageMagick image formats on disk
7083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  and returns the number of validation tests that passed and failed.
7093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the ValidateImageFormatsOnDisk method is:
7113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
712bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%      size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
7133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *reference_filename,const char *output_filename,
714bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%        size_t *fail,ExceptionInfo *exception)
7153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
7173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o image_info: the image info.
7193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reference_filename: the reference image filename.
7213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o output_filename: the output image filename.
7233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o fail: return the number of validation tests that pass.
7253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: return any errors or warnings in this structure.
7273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
7283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
729bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
7300d772eda43795018942c81aac81ac0c8b3d92018cristy  const char *reference_filename,const char *output_filename,size_t *fail,
7310d772eda43795018942c81aac81ac0c8b3d92018cristy  ExceptionInfo *exception)
7323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
7333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  char
7343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    size[MaxTextExtent];
7353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
7363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const MagickInfo
7373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *magick_info;
7383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
7393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  double
7403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    distortion,
7413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    fuzz;
7423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
7433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  Image
7443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *difference_image,
7453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *reference_image,
7463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *reconstruct_image;
7473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
7483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
7493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status;
7503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
751bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  register ssize_t
7523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    i,
7533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    j;
7543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
755bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  size_t
7563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    test;
7573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
7583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  test=0;
759b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,"validate image formats on disk:\n");
7603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  for (i=0; reference_formats[i].magick != (char *) NULL; i++)
7613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
7623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    magick_info=GetMagickInfo(reference_formats[i].magick,exception);
7633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if ((magick_info == (const MagickInfo *) NULL) ||
7643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (magick_info->decoder == (DecodeImageHandler *) NULL) ||
7653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (magick_info->encoder == (EncodeImageHandler *) NULL))
7663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      continue;
7675f1c1fff2a55c4d8756556e78c1f307d352ed1b8cristy    for (j=0; reference_types[j].type != UndefinedType; j++)
7683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    {
7693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
7703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Generate reference image.
7713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
7723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      CatchException(exception);
7731e604812fad85bb96f757a2393015ae3d061c39acristy      (void) FormatLocaleFile(stdout,"  test %.20g: %s/%s/%s/%.20g-bits",
7741e604812fad85bb96f757a2393015ae3d061c39acristy        (double) (test++),reference_formats[i].magick,CommandOptionToMnemonic(
7757998e5fecd99cd9838e7a960168f48b92d38bbfccristy        MagickCompressOptions,reference_formats[i].compression),
776042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy        CommandOptionToMnemonic(MagickTypeOptions,reference_types[j].type),
77775a2623568540f98985ce5bb1d88687eb9c85d2ecristy        (double) reference_types[j].depth);
7783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (void) CopyMagickString(image_info->filename,reference_filename,
7793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        MaxTextExtent);
7803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_image=ReadImage(image_info,exception);
7813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (reference_image == (Image *) NULL)
7823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
7831e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
7841e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
7853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
7863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
7873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
7883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
7893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Write reference image.
7903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
791b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleString(size,MaxTextExtent,"%.20gx%.20g",
79275a2623568540f98985ce5bb1d88687eb9c85d2ecristy        (double) reference_image->columns,(double) reference_image->rows);
7933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (void) CloneString(&image_info->size,size);
7943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      image_info->depth=reference_types[j].depth;
795b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleString(reference_image->filename,MaxTextExtent,"%s:%s",
7963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        reference_formats[i].magick,output_filename);
797018f07f7333b25743d0afff892450cebdb905c1acristy      status=SetImageType(reference_image,reference_types[j].type,exception);
7983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (status == MagickFalse)
7993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
8001e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
8011e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
8023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
8033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          reference_image=DestroyImage(reference_image);
8043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
8053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
8068a11cb146177680bfc1b7d89a8cd0c8f2befe468cristy      status=SetImageDepth(reference_image,reference_types[j].depth,exception);
8073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (status == MagickFalse)
8083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
8091e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
8101e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
8113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
8123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          reference_image=DestroyImage(reference_image);
8133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
8143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
8157998e5fecd99cd9838e7a960168f48b92d38bbfccristy      reference_image->compression=reference_formats[i].compression;
8166f9e0d38526c24e02e6207b1d494fa8fad072b9ccristy      status=WriteImage(image_info,reference_image,exception);
8173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_image=DestroyImage(reference_image);
8183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (status == MagickFalse)
8193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
8201e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
8211e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
8223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
8233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
8243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
8253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
8263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Read reference image.
8273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
828b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
8293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        reference_formats[i].magick,output_filename);
8303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_image=ReadImage(image_info,exception);
8313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (reference_image == (Image *) NULL)
8323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
8331e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
8341e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
8353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
8363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
8373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
8383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
8393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Write reference image.
8403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
841b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleString(reference_image->filename,MaxTextExtent,"%s:%s",
8423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        reference_formats[i].magick,output_filename);
8433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_image->depth=reference_types[j].depth;
8447998e5fecd99cd9838e7a960168f48b92d38bbfccristy      reference_image->compression=reference_formats[i].compression;
8456f9e0d38526c24e02e6207b1d494fa8fad072b9ccristy      status=WriteImage(image_info,reference_image,exception);
8463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (status == MagickFalse)
8473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
8481e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
8491e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
8503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
8513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          reference_image=DestroyImage(reference_image);
8523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
8533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
8543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
8553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Read reconstruct image.
8563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
857b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
8583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        reference_formats[i].magick,output_filename);
8593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reconstruct_image=ReadImage(image_info,exception);
8603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (reconstruct_image == (Image *) NULL)
8613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
8621e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
8631e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
8643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
8653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          reference_image=DestroyImage(reference_image);
8663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
8673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
8683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
8693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Compare reference to reconstruct image.
8703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
8713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      fuzz=0.0;
8723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (reference_formats[i].fuzz != 0.0)
8733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        fuzz=reference_formats[i].fuzz;
8743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#if defined(MAGICKCORE_HDRI_SUPPORT)
8753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      fuzz+=0.003;
8763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#endif
8776abd4190834b17727ebdc5c6872dce24a42a0a71cristy      if (IssRGBColorspace(reference_image->colorspace) == MagickFalse)
8783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        fuzz+=0.3;
8797e9255b649960d02c30b7c9fb9ed578506546320cristy      fuzz+=MagickEpsilon;
8808a9106f4d81487da0f318bd13b4caa4cd24f23afcristy      difference_image=CompareImages(reference_image,reconstruct_image,
881864c6a8f0dbf656fcc51e2f526c6a7c7a4d46c81cristy        RootMeanSquaredErrorMetric,&distortion,exception);
8823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reconstruct_image=DestroyImage(reconstruct_image);
8833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_image=DestroyImage(reference_image);
8843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (difference_image == (Image *) NULL)
8853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
8861e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
8871e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
8883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
8893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
8903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
8913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      difference_image=DestroyImage(difference_image);
89214154224e937198c540f38d146528c0cdc45d24dcristy      if ((QuantumScale*distortion) > fuzz)
8933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
894b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy          (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
89514154224e937198c540f38d146528c0cdc45d24dcristy            QuantumScale*distortion);
8963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
8973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
8983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
899b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleFile(stdout,"... pass.\n");
9003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    }
9013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
902b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,
90375a2623568540f98985ce5bb1d88687eb9c85d2ecristy    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
90475a2623568540f98985ce5bb1d88687eb9c85d2ecristy    (double) (test-(*fail)),(double) *fail);
9053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(test);
9063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
9073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
9083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
9093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
9113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
9123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
9133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   V a l i d a t e I m p o r t E x p o r t P i x e l s                       %
9143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
9153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
9163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
9173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  ValidateImportExportPixels() validates the pixel import and export methods.
9203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  It returns the number of validation tests that passed and failed.
9213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the ValidateImportExportPixels method is:
9233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
924bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%      size_t ValidateImportExportPixels(ImageInfo *image_info,
9253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *reference_filename,const char *output_filename,
926bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%        size_t *fail,ExceptionInfo *exception)
9273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
9293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o image_info: the image info.
9313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reference_filename: the reference image filename.
9333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o output_filename: the output image filename.
9353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o fail: return the number of validation tests that pass.
9373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: return any errors or warnings in this structure.
9393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
9403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
941bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic size_t ValidateImportExportPixels(ImageInfo *image_info,
9420d772eda43795018942c81aac81ac0c8b3d92018cristy  const char *reference_filename,const char *output_filename,size_t *fail,
9430d772eda43795018942c81aac81ac0c8b3d92018cristy  ExceptionInfo *exception)
9443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
9453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  double
9463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    distortion;
9473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
9483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  Image
9493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *difference_image,
9503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *reference_image,
9513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *reconstruct_image;
9523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
9533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
9543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status;
9553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
956bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  register ssize_t
9573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    i,
9583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    j;
9593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
9603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  size_t
9613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    length;
9623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
9633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  unsigned char
9643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *pixels;
9653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
966bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  size_t
9673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    test;
9683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
9693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) output_filename;
9703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  test=0;
9711e604812fad85bb96f757a2393015ae3d061c39acristy  (void) FormatLocaleFile(stdout,
9721e604812fad85bb96f757a2393015ae3d061c39acristy    "validate the import and export of image pixels:\n");
9733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  for (i=0; reference_map[i] != (char *) NULL; i++)
9743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
9753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    for (j=0; reference_storage[j].type != UndefinedPixel; j++)
9763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    {
9773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
9783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Generate reference image.
9793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
9803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      CatchException(exception);
981b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleFile(stdout,"  test %.20g: %s/%s",(double) (test++),
982042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy        reference_map[i],CommandOptionToMnemonic(MagickStorageOptions,
9833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        reference_storage[j].type));
9843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (void) CopyMagickString(image_info->filename,reference_filename,
9853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        MaxTextExtent);
9863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_image=ReadImage(image_info,exception);
9873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (reference_image == (Image *) NULL)
9883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
9891e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
9901e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
9913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
9923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
9933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
9943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (LocaleNCompare(reference_map[i],"cmy",3) == 0)
9952c404226c827fe0799858fc345a1bea11f2cb546cristy        (void) SetImageColorspace(reference_image,CMYKColorspace,exception);
9963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      length=strlen(reference_map[i])*reference_image->columns*
9973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        reference_image->rows*reference_storage[j].quantum;
9983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      pixels=(unsigned char *) AcquireQuantumMemory(length,sizeof(*pixels));
9993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (pixels == (unsigned char *) NULL)
10003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
10011e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
10021e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
10033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
10043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          reference_image=DestroyImage(reference_image);
10053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
10063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
10073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (void) ResetMagickMemory(pixels,0,length*sizeof(*pixels));
10083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      status=ExportImagePixels(reference_image,0,0,reference_image->columns,
10093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        reference_image->rows,reference_map[i],reference_storage[j].type,pixels,
10103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        exception);
10113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (status == MagickFalse)
10123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
10131e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
10141e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
10153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
10163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          pixels=(unsigned char *) RelinquishMagickMemory(pixels);
10173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          reference_image=DestroyImage(reference_image);
10183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
10193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
1020d55c935b7c710346ac55d202ac08409d037a0166cristy      (void) SetImageBackgroundColor(reference_image,exception);
10213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      status=ImportImagePixels(reference_image,0,0,reference_image->columns,
10223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        reference_image->rows,reference_map[i],reference_storage[j].type,
1023018f07f7333b25743d0afff892450cebdb905c1acristy        pixels,exception);
10243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (status == MagickFalse)
10253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
10261e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
10271e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
10283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
10293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy           pixels=(unsigned char *) RelinquishMagickMemory(pixels);
10303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          reference_image=DestroyImage(reference_image);
10313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
10323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
10333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
10343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Read reconstruct image.
10353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
10369950d57e1124b73f684fb5946e206994cefda628cristy      reconstruct_image=AcquireImage(image_info,exception);
10373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (void) SetImageExtent(reconstruct_image,reference_image->columns,
1038655a8d1b809f9feb6926d06f03b3bd477da53ccacristy        reference_image->rows,exception);
1039655a8d1b809f9feb6926d06f03b3bd477da53ccacristy      (void) SetImageColorspace(reconstruct_image,reference_image->colorspace,
1040655a8d1b809f9feb6926d06f03b3bd477da53ccacristy        exception);
1041d55c935b7c710346ac55d202ac08409d037a0166cristy      (void) SetImageBackgroundColor(reconstruct_image,exception);
10423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      status=ImportImagePixels(reconstruct_image,0,0,reconstruct_image->columns,
10433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        reconstruct_image->rows,reference_map[i],reference_storage[j].type,
1044018f07f7333b25743d0afff892450cebdb905c1acristy        pixels,exception);
10453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      pixels=(unsigned char *) RelinquishMagickMemory(pixels);
10463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (status == MagickFalse)
10473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
10481e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
10491e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
10503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
10513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          reference_image=DestroyImage(reference_image);
10523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
10533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
10543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      /*
10553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        Compare reference to reconstruct image.
10563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      */
10578a9106f4d81487da0f318bd13b4caa4cd24f23afcristy      difference_image=CompareImages(reference_image,reconstruct_image,
1058864c6a8f0dbf656fcc51e2f526c6a7c7a4d46c81cristy        RootMeanSquaredErrorMetric,&distortion,exception);
10593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reconstruct_image=DestroyImage(reconstruct_image);
10603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_image=DestroyImage(reference_image);
10613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (difference_image == (Image *) NULL)
10623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
10631e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
10641e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
10653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
10663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
10673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
10683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      difference_image=DestroyImage(difference_image);
106914154224e937198c540f38d146528c0cdc45d24dcristy      if ((QuantumScale*distortion) > 0.0)
10703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
1071b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy          (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
107214154224e937198c540f38d146528c0cdc45d24dcristy            QuantumScale*distortion);
10733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          (*fail)++;
10743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          continue;
10753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
1076b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleFile(stdout,"... pass.\n");
10773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    }
10783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
1079b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,
108075a2623568540f98985ce5bb1d88687eb9c85d2ecristy    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
108175a2623568540f98985ce5bb1d88687eb9c85d2ecristy    (double) (test-(*fail)),(double) *fail);
10823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(test);
10833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
10843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
10853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
10863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
10883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
10893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
10903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   V a l i d a t e M o n t a g e C o m m a n d                               %
10913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
10923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
10933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
10943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
10963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  ValidateMontageCommand() validates the ImageMagick montage command line
10973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  program and returns the number of validation tests that passed and failed.
10983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
10993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the ValidateMontageCommand method is:
11003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1101bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%      size_t ValidateMontageCommand(ImageInfo *image_info,
11023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *reference_filename,const char *output_filename,
1103bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%        size_t *fail,ExceptionInfo *exception)
11043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
11053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
11063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
11073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o image_info: the image info.
11083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
11093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reference_filename: the reference image filename.
11103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
11113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o output_filename: the output image filename.
11123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
11133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o fail: return the number of validation tests that pass.
11143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
11153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: return any errors or warnings in this structure.
11163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
11173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
1118bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic size_t ValidateMontageCommand(ImageInfo *image_info,
11190d772eda43795018942c81aac81ac0c8b3d92018cristy  const char *reference_filename,const char *output_filename,size_t *fail,
11200d772eda43795018942c81aac81ac0c8b3d92018cristy  ExceptionInfo *exception)
11213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
11223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  char
11233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    **arguments,
11243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    command[MaxTextExtent];
11253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
11263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  int
11273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    number_arguments;
11283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
11293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
11303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status;
11313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1132bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  register ssize_t
11333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    i,
11343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    j;
11353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1136bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  size_t
11373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    test;
11383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
11393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  test=0;
1140b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,"validate montage command line program:\n");
11413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  for (i=0; montage_options[i] != (char *) NULL; i++)
11423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
11433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    CatchException(exception);
1144b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) (test++),
11456aa47adc8b43dfdf8d1c2b6323c0bb1f57a5f011cristy      montage_options[i]);
1146b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s %s",
11473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_filename,montage_options[i],reference_filename,
11483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      output_filename);
11493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    arguments=StringToArgv(command,&number_arguments);
11503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (arguments == (char **) NULL)
11513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
11521e604812fad85bb96f757a2393015ae3d061c39acristy        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
11531e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
11543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (*fail)++;
11553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
11563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
11573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status=MontageImageCommand(image_info,number_arguments,arguments,
11583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (char **) NULL,exception);
1159e42f658533644aecb733785ffd91b286d6778deacristy    for (j=0; j < (ssize_t) number_arguments; j++)
11603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      arguments[j]=DestroyString(arguments[j]);
11613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    arguments=(char **) RelinquishMagickMemory(arguments);
11623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (status != MagickFalse)
11633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
11641e604812fad85bb96f757a2393015ae3d061c39acristy        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
11651e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
11663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (*fail)++;
11673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
11683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
1169b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stdout,"... pass.\n");
11703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
1171b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,
117275a2623568540f98985ce5bb1d88687eb9c85d2ecristy    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
117375a2623568540f98985ce5bb1d88687eb9c85d2ecristy    (double) (test-(*fail)),(double) *fail);
11743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(test);
11753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
11763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
11773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
11783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
11803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
11813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
11823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%   V a l i d a t e S t r e a m C o m m a n d                                 %
11833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
11843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
11853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
11863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
11883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  ValidateStreamCommand() validates the ImageMagick stream command line
11893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  program and returns the number of validation tests that passed and failed.
11903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
11913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  The format of the ValidateStreamCommand method is:
11923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
1193bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%      size_t ValidateStreamCommand(ImageInfo *image_info,
11943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%        const char *reference_filename,const char *output_filename,
1195bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy%        size_t *fail,ExceptionInfo *exception)
11963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
11973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  A description of each parameter follows:
11983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
11993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o image_info: the image info.
12003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
12013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o reference_filename: the reference image filename.
12023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
12033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o output_filename: the output image filename.
12043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
12053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o fail: return the number of validation tests that pass.
12063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
12073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%    o exception: return any errors or warnings in this structure.
12083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
12093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
1210bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristystatic size_t ValidateStreamCommand(ImageInfo *image_info,
12110d772eda43795018942c81aac81ac0c8b3d92018cristy  const char *reference_filename,const char *output_filename,size_t *fail,
12120d772eda43795018942c81aac81ac0c8b3d92018cristy  ExceptionInfo *exception)
12133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
12143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  char
12153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    **arguments,
12163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    command[MaxTextExtent];
12173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
12183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  int
12193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    number_arguments;
12203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
12213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
12223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status;
12233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1224bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  register ssize_t
12253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    i,
12263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    j;
12273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1228bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  size_t
12293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    test;
12303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
12313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  test=0;
1232b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,"validate stream command line program:\n");
12333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  for (i=0; stream_options[i] != (char *) NULL; i++)
12343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
12353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    CatchException(exception);
1236b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stdout,"  test %.20g: %s",(double) (test++),
12376aa47adc8b43dfdf8d1c2b6323c0bb1f57a5f011cristy      stream_options[i]);
1238b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s",
12393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      stream_options[i],reference_filename,output_filename);
12403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    arguments=StringToArgv(command,&number_arguments);
12413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (arguments == (char **) NULL)
12423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
12431e604812fad85bb96f757a2393015ae3d061c39acristy        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
12441e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
12453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (*fail)++;
12463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
12473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
12483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status=StreamImageCommand(image_info,number_arguments,arguments,
12493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (char **) NULL,exception);
1250e42f658533644aecb733785ffd91b286d6778deacristy    for (j=0; j < (ssize_t) number_arguments; j++)
12513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      arguments[j]=DestroyString(arguments[j]);
12523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    arguments=(char **) RelinquishMagickMemory(arguments);
12533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    if (status != MagickFalse)
12543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
12551e604812fad85bb96f757a2393015ae3d061c39acristy        (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
12561e604812fad85bb96f757a2393015ae3d061c39acristy            GetMagickModule());
12573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (*fail)++;
12583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
12593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
1260b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy    (void) FormatLocaleFile(stdout,"... pass.\n");
12613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
1262b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy  (void) FormatLocaleFile(stdout,
126375a2623568540f98985ce5bb1d88687eb9c85d2ecristy    "  summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
126475a2623568540f98985ce5bb1d88687eb9c85d2ecristy    (double) (test-(*fail)),(double) *fail);
12653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(test);
12663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
12673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
12683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy/*
12693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
12713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
12723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
12733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%  M a i n                                                                    %
12743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
12753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
12763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%                                                                             %
12773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
12793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy%
12803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy*/
12813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
12823ed852eea50f9d4cd633efb8c2b054b8e33c253cristystatic MagickBooleanType ValidateUsage(void)
12833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
12843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  const char
12853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    **p;
12863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
12873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  static const char
12883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *miscellaneous[]=
12893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    {
12903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-debug events        display copious debugging information",
12913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-help                print program options",
12923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-log format          format of debugging information",
12933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-validate type       validation type",
12943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-version             print version information",
12953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (char *) NULL
12963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    },
12973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *settings[]=
12983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    {
12993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-regard-warnings     pay attention to warning messages",
13003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      "-verbose             print detailed information about the image",
13013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (char *) NULL
13023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    };
13033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1304bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
13053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) printf("Copyright: %s\n\n",GetMagickCopyright());
1306b28d64742e55a8b565085faf37e9aead51f89a83cristy  (void) printf("Features: %s\n",GetMagickFeatures());
13073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) printf("Usage: %s [options ...] reference-file\n",GetClientName());
13083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) printf("\nValidate Settings:\n");
13093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  for (p=settings; *p != (char *) NULL; p++)
13103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    (void) printf("  %s\n",*p);
13113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) printf("\nMiscellaneous Options:\n");
13123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  for (p=miscellaneous; *p != (char *) NULL; p++)
13133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    (void) printf("  %s\n",*p);
13143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(MagickTrue);
13153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
13163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
13173ed852eea50f9d4cd633efb8c2b054b8e33c253cristyint main(int argc,char **argv)
13183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{
13193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define DestroyValidate() \
13203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ \
13213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  image_info=DestroyImageInfo(image_info); \
13223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  exception=DestroyExceptionInfo(exception); \
13233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
13243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy#define ThrowValidateException(asperity,tag,option) \
13253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy{ \
13263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
13273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    option); \
13283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  CatchException(exception); \
13293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  DestroyValidate(); \
13303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(MagickFalse); \
13313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
13323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
13333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  char
13343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    output_filename[MaxTextExtent],
13353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    reference_filename[MaxTextExtent],
13363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *option;
13373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
13383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  double
13393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    elapsed_time,
13403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    user_time;
13413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
13423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  ExceptionInfo
13433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *exception;
13443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
13453ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  Image
13463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *reference_image;
13473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
13483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  ImageInfo
13493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *image_info;
13503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
13513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickBooleanType
13523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    regard_warnings,
13533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    status;
13543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
13559cafe595c0aaff879d99b073d73645866b418cd4cristy  MagickSizeType
13569cafe595c0aaff879d99b073d73645866b418cd4cristy    memory_resource,
13579cafe595c0aaff879d99b073d73645866b418cd4cristy    map_resource;
13589cafe595c0aaff879d99b073d73645866b418cd4cristy
1359bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  register ssize_t
13603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    i;
13613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
13623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  TimerInfo
13633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    *timer;
13643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
1365bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  size_t
13663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    fail,
13673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    iterations,
13683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    tests;
13693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
13703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  ValidateType
13713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    type;
13723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
13733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  /*
13743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    Validate the ImageMagick image processing suite.
13753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  */
13763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickCoreGenesis(*argv,MagickFalse);
13773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  iterations=1;
13783ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  status=MagickFalse;
13793ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  type=AllValidate;
13803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  regard_warnings=MagickFalse;
1381d886290b2a32bf23bbdc19b883f32cd4d364b310cristy  (void) regard_warnings;
13823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  exception=AcquireExceptionInfo();
13833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  image_info=AcquireImageInfo();
13843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  (void) CopyMagickString(image_info->filename,ReferenceFilename,MaxTextExtent);
1385bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy  for (i=1; i < (ssize_t) argc; i++)
13863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  {
13873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    option=argv[i];
1388042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy    if (IsCommandOption(option) == MagickFalse)
13893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
13903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (void) CopyMagickString(image_info->filename,option,MaxTextExtent);
13913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        continue;
13923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
13933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    switch (*(option+1))
13943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    {
13953ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'b':
13963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
13973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("bench",option+1) == 0)
13983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
1399e27293e706ca05b6b121e9512a83b16f7ad887f2cristy            iterations=StringToUnsignedLong(argv[++i]);
14003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
14013ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
14023ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowValidateException(OptionError,"UnrecognizedOption",option)
14033ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
14043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'd':
14053ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
14063ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("debug",option+1) == 0)
14073ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
14083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            (void) SetLogEventMask(argv[++i]);
14093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
14103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
14113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowValidateException(OptionError,"UnrecognizedOption",option)
14123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
14133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'h':
14143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
14153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("help",option+1) == 0)
14163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
14173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            (void) ValidateUsage();
14183ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            return(0);
14193ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
14203ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowValidateException(OptionError,"UnrecognizedOption",option)
14213ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
14223ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'l':
14233ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
14243ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("log",option+1) == 0)
14253ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
14263ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option != '+')
14273ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              (void) SetLogFormat(argv[i+1]);
14283ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
14293ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
14303ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowValidateException(OptionError,"UnrecognizedOption",option)
14313ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
14323ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'r':
14333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
14343ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("regard-warnings",option+1) == 0)
14353ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
14363ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            regard_warnings=MagickTrue;
14373ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
14383ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
14393ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowValidateException(OptionError,"UnrecognizedOption",option)
14403ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
14413ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      case 'v':
14423ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      {
14433ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if (LocaleCompare("validate",option+1) == 0)
14443ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
1445bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            ssize_t
14463ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              validate;
14473ed852eea50f9d4cd633efb8c2b054b8e33c253cristy
14483ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (*option == '+')
14493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              break;
14503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            i++;
1451bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            if (i == (ssize_t) argc)
14523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowValidateException(OptionError,"MissingArgument",option);
1453042ee78fa9004bf1ac6a95f09d9d1faca631dda1cristy            validate=ParseCommandOption(MagickValidateOptions,MagickFalse,
14543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              argv[i]);
14553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            if (validate < 0)
14563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              ThrowValidateException(OptionError,"UnrecognizedValidateType",
14573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy                argv[i]);
14583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            type=(ValidateType) validate;
14593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            break;
14603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
14613ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        if ((LocaleCompare("version",option+1) == 0) ||
14623ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            (LocaleCompare("-version",option+1) == 0))
14633ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          {
1464b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy            (void) FormatLocaleFile(stdout,"Version: %s\n",
1465bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy              GetMagickVersion((size_t *) NULL));
14661e604812fad85bb96f757a2393015ae3d061c39acristy            (void) FormatLocaleFile(stdout,"Copyright: %s\n\n",
14671e604812fad85bb96f757a2393015ae3d061c39acristy              GetMagickCopyright());
14681e604812fad85bb96f757a2393015ae3d061c39acristy            (void) FormatLocaleFile(stdout,"Features: %s\n\n",
14691e604812fad85bb96f757a2393015ae3d061c39acristy              GetMagickFeatures());
14703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            return(0);
14713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          }
14723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowValidateException(OptionError,"UnrecognizedOption",option)
14733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      }
14743ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      default:
14753ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        ThrowValidateException(OptionError,"UnrecognizedOption",option)
14763ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    }
14773ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  }
1478205e21f9b7ffdf5b0e48642ba0981b239959f8a9cristy  timer=(TimerInfo *) NULL;
14798b76e556a4f5e2cdd916c1c52a9af375a57ca4a6cristy  if (iterations > 1)
14808b76e556a4f5e2cdd916c1c52a9af375a57ca4a6cristy    timer=AcquireTimerInfo();
14813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  reference_image=ReadImage(image_info,exception);
14823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  tests=0;
14833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  fail=0;
14843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (reference_image == (Image *) NULL)
14853ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    fail++;
14863ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  else
14873ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    {
14883ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (LocaleCompare(image_info->filename,ReferenceFilename) == 0)
14893ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        (void) CopyMagickString(reference_image->magick,ReferenceImageFormat,
14903ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          MaxTextExtent);
14913ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (void) AcquireUniqueFilename(reference_filename);
14923ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (void) AcquireUniqueFilename(output_filename);
14933ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (void) CopyMagickString(reference_image->filename,reference_filename,
14943ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        MaxTextExtent);
14956f9e0d38526c24e02e6207b1d494fa8fad072b9ccristy      status=WriteImage(image_info,reference_image,exception);
14963ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      reference_image=DestroyImage(reference_image);
14973ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      if (status == MagickFalse)
14983ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        fail++;
14993ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      else
15003ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        {
1501b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy          (void) FormatLocaleFile(stdout,"Version: %s\n",
1502bb50337b2a8a16ca7e903cc04ab195ff0fd47ae6cristy            GetMagickVersion((size_t *) NULL));
1503b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy          (void) FormatLocaleFile(stdout,"Copyright: %s\n\n",
15043ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            GetMagickCopyright());
15051e604812fad85bb96f757a2393015ae3d061c39acristy          (void) FormatLocaleFile(stdout,
15061e604812fad85bb96f757a2393015ae3d061c39acristy            "ImageMagick Validation Suite (%s)\n\n",CommandOptionToMnemonic(
15071e604812fad85bb96f757a2393015ae3d061c39acristy            MagickValidateOptions,(ssize_t) type));
15083ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          if ((type & CompareValidate) != 0)
15093ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            tests+=ValidateCompareCommand(image_info,reference_filename,
15103ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              output_filename,&fail,exception);
15113ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          if ((type & CompositeValidate) != 0)
15123ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            tests+=ValidateCompositeCommand(image_info,reference_filename,
15133ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              output_filename,&fail,exception);
15143ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          if ((type & ConvertValidate) != 0)
15153ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            tests+=ValidateConvertCommand(image_info,reference_filename,
15163ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              output_filename,&fail,exception);
15173ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          if ((type & FormatsInMemoryValidate) != 0)
1518f044a4d421741ac56005ed3a37eb537de94423aacristy            {
1519f044a4d421741ac56005ed3a37eb537de94423aacristy              (void) FormatLocaleFile(stdout,"[pixel-cache: memory] ");
1520f044a4d421741ac56005ed3a37eb537de94423aacristy              tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
1521f044a4d421741ac56005ed3a37eb537de94423aacristy                output_filename,&fail,exception);
1522f044a4d421741ac56005ed3a37eb537de94423aacristy              (void) FormatLocaleFile(stdout,"[pixel-cache: memory-mapped] ");
15239cafe595c0aaff879d99b073d73645866b418cd4cristy              memory_resource=SetMagickResourceLimit(MemoryResource,0);
1524f044a4d421741ac56005ed3a37eb537de94423aacristy              tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
1525f044a4d421741ac56005ed3a37eb537de94423aacristy                output_filename,&fail,exception);
1526f044a4d421741ac56005ed3a37eb537de94423aacristy              (void) FormatLocaleFile(stdout,"[pixel-cache: disk] ");
15279cafe595c0aaff879d99b073d73645866b418cd4cristy              map_resource=SetMagickResourceLimit(MapResource,0);
1528f044a4d421741ac56005ed3a37eb537de94423aacristy              tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
1529f044a4d421741ac56005ed3a37eb537de94423aacristy                output_filename,&fail,exception);
15309cafe595c0aaff879d99b073d73645866b418cd4cristy              (void) SetMagickResourceLimit(MemoryResource,memory_resource);
15319cafe595c0aaff879d99b073d73645866b418cd4cristy              (void) SetMagickResourceLimit(MapResource,map_resource);
1532f044a4d421741ac56005ed3a37eb537de94423aacristy            }
15333ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          if ((type & FormatsOnDiskValidate) != 0)
1534bda201a1b108a687bb6889cb94b525e8fa5af79ccristy            {
153534c290f63ae56e219a57b0bae229f48b51364aeacristy              (void) FormatLocaleFile(stdout,"[pixel-cache: memory] ");
1536bda201a1b108a687bb6889cb94b525e8fa5af79ccristy              tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
1537bda201a1b108a687bb6889cb94b525e8fa5af79ccristy                output_filename,&fail,exception);
153834c290f63ae56e219a57b0bae229f48b51364aeacristy              (void) FormatLocaleFile(stdout,"[pixel-cache: memory-mapped] ");
15399cafe595c0aaff879d99b073d73645866b418cd4cristy              memory_resource=SetMagickResourceLimit(MemoryResource,0);
1540bda201a1b108a687bb6889cb94b525e8fa5af79ccristy              tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
1541bda201a1b108a687bb6889cb94b525e8fa5af79ccristy                output_filename,&fail,exception);
154234c290f63ae56e219a57b0bae229f48b51364aeacristy              (void) FormatLocaleFile(stdout,"[pixel-cache: disk] ");
15439cafe595c0aaff879d99b073d73645866b418cd4cristy              map_resource=SetMagickResourceLimit(MapResource,0);
1544bda201a1b108a687bb6889cb94b525e8fa5af79ccristy              tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
1545bda201a1b108a687bb6889cb94b525e8fa5af79ccristy                output_filename,&fail,exception);
15469cafe595c0aaff879d99b073d73645866b418cd4cristy              (void) SetMagickResourceLimit(MemoryResource,memory_resource);
15479cafe595c0aaff879d99b073d73645866b418cd4cristy              (void) SetMagickResourceLimit(MapResource,map_resource);
1548bda201a1b108a687bb6889cb94b525e8fa5af79ccristy            }
15493ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          if ((type & IdentifyValidate) != 0)
15503ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            tests+=ValidateIdentifyCommand(image_info,reference_filename,
15513ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              output_filename,&fail,exception);
15523ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          if ((type & ImportExportValidate) != 0)
15533ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            tests+=ValidateImportExportPixels(image_info,reference_filename,
15543ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              output_filename,&fail,exception);
15553ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          if ((type & MontageValidate) != 0)
15563ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            tests+=ValidateMontageCommand(image_info,reference_filename,
15573ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              output_filename,&fail,exception);
15583ed852eea50f9d4cd633efb8c2b054b8e33c253cristy          if ((type & StreamValidate) != 0)
15593ed852eea50f9d4cd633efb8c2b054b8e33c253cristy            tests+=ValidateStreamCommand(image_info,reference_filename,
15603ed852eea50f9d4cd633efb8c2b054b8e33c253cristy              output_filename,&fail,exception);
1561b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy          (void) FormatLocaleFile(stdout,
156275a2623568540f98985ce5bb1d88687eb9c85d2ecristy            "validation suite: %.20g tests; %.20g passed; %.20g failed.\n",
156375a2623568540f98985ce5bb1d88687eb9c85d2ecristy            (double) tests,(double) (tests-fail),(double) fail);
15643ed852eea50f9d4cd633efb8c2b054b8e33c253cristy        }
15653ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (void) RelinquishUniqueFileResource(output_filename);
15663ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      (void) RelinquishUniqueFileResource(reference_filename);
15673ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    }
15683ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (exception->severity != UndefinedException)
15693ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    CatchException(exception);
15703ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  if (iterations > 1)
15713ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    {
15723ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      elapsed_time=GetElapsedTime(timer);
15733ed852eea50f9d4cd633efb8c2b054b8e33c253cristy      user_time=GetUserTime(timer);
1574b51dff5c0d16a4c1b69ff683e786cb3b4c467694cristy      (void) FormatLocaleFile(stderr,
157575a2623568540f98985ce5bb1d88687eb9c85d2ecristy        "Performance: %.20gi %gips %0.3fu %ld:%02ld.%03ld\n",(double)
15766aa47adc8b43dfdf8d1c2b6323c0bb1f57a5f011cristy        iterations,1.0*iterations/elapsed_time,user_time,(long)
15776aa47adc8b43dfdf8d1c2b6323c0bb1f57a5f011cristy        (elapsed_time/60.0),(long) ceil(fmod(elapsed_time,60.0)),
15786aa47adc8b43dfdf8d1c2b6323c0bb1f57a5f011cristy        (long) (1000.0*(elapsed_time-floor(elapsed_time))));
15798b76e556a4f5e2cdd916c1c52a9af375a57ca4a6cristy      timer=DestroyTimerInfo(timer);
15803ed852eea50f9d4cd633efb8c2b054b8e33c253cristy    }
15813ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  DestroyValidate();
15823ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  MagickCoreTerminus();
15833ed852eea50f9d4cd633efb8c2b054b8e33c253cristy  return(fail == 0 ? 0 : 1);
15843ed852eea50f9d4cd633efb8c2b054b8e33c253cristy}
1585