2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 % V V AAA L IIIII DDDD AAA TTTTT EEEEE %
8 % V V A A L I D D A A T E %
9 % V V AAAAA L I D D AAAAA T EEE %
10 % V V A A L I D D A A T E %
11 % V A A LLLLL IIIII DDDD A A T EEEEE %
14 % ImageMagick Validation Suite %
21 % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
22 % dedicated to making software imaging solutions freely available. %
24 % You may not use this file except in compliance with the License. You may %
25 % obtain a copy of the License at %
27 % http://www.imagemagick.org/script/license.php %
29 % Unless required by applicable law or agreed to in writing, software %
30 % distributed under the License is distributed on an "AS IS" BASIS, %
31 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
32 % see the License for the specific language governing permissions and %
33 % limitations under the License. %
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49 #include "MagickWand/MagickWand.h"
50 #include "MagickCore/colorspace-private.h"
51 #include "MagickCore/gem.h"
52 #include "MagickCore/resource_.h"
53 #include "MagickCore/string-private.h"
59 #define CIEEpsilon (216.0/24389.0)
60 #define CIEK (24389.0/27.0)
64 #define ReferenceEpsilon (QuantumRange*1.0e-2)
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 % V a l i d a t e C o l o r s p a c e s %
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77 % ValidateColorspaces() validates the ImageMagick colorspaces and returns the
78 % number of validation tests that passed and failed.
80 % The format of the ValidateColorspaces method is:
82 % size_t ValidateColorspaces(ImageInfo *image_info,size_t *fail,
83 % ExceptionInfo *exception)
85 % A description of each parameter follows:
87 % o image_info: the image info.
89 % o fail: return the number of validation tests that pass.
91 % o exception: return any errors or warnings in this structure.
95 static void ConvertHSIToRGB(const double hue,const double saturation,
96 const double intensity,double *red,double *green,double *blue)
102 h-=360.0*floor(h/360.0);
105 *blue=intensity*(1.0-saturation);
106 *red=intensity*(1.0+saturation*cos(h*(MagickPI/180.0))/cos((60.0-h)*
108 *green=3.0*intensity-*red-*blue;
114 *red=intensity*(1.0-saturation);
115 *green=intensity*(1.0+saturation*cos(h*(MagickPI/180.0))/cos((60.0-h)*
117 *blue=3.0*intensity-*red-*green;
122 *green=intensity*(1.0-saturation);
123 *blue=intensity*(1.0+saturation*cos(h*(MagickPI/180.0))/cos((60.0-h)*
125 *red=3.0*intensity-*green-*blue;
128 *green*=QuantumRange;
132 static inline double MagickMin(const double x,const double y)
139 static void ConvertRGBToHSI(const double red,const double green,
140 const double blue,double *hue,double *saturation,double *intensity)
146 *intensity=(QuantumScale*red+QuantumScale*green+QuantumScale*blue)/3.0;
147 if (*intensity <= 0.0)
153 *saturation=1.0-MagickMin(QuantumScale*red,MagickMin(QuantumScale*green,
154 QuantumScale*blue))/(*intensity);
155 alpha=0.5*(2.0*QuantumScale*red-QuantumScale*green-QuantumScale*blue);
156 beta=0.8660254037844385*(QuantumScale*green-QuantumScale*blue);
157 *hue=atan2(beta,alpha)*(180.0/MagickPI)/360.0;
162 static inline double MagickMax(const double x,const double y)
169 static void ConvertHSVToRGB(const double hue,const double saturation,
170 const double value,double *red,double *green,double *blue)
181 h-=360.0*floor(h/360.0);
183 x=c*(1.0-fabs(h-2.0*floor(h/2.0)-1.0));
184 switch ((int) floor(h))
188 *red=QuantumRange*(min+c);
189 *green=QuantumRange*(min+x);
190 *blue=QuantumRange*min;
195 *red=QuantumRange*(min+x);
196 *green=QuantumRange*(min+c);
197 *blue=QuantumRange*min;
202 *red=QuantumRange*min;
203 *green=QuantumRange*(min+c);
204 *blue=QuantumRange*(min+x);
209 *red=QuantumRange*min;
210 *green=QuantumRange*(min+x);
211 *blue=QuantumRange*(min+c);
216 *red=QuantumRange*(min+x);
217 *green=QuantumRange*min;
218 *blue=QuantumRange*(min+c);
223 *red=QuantumRange*(min+c);
224 *green=QuantumRange*min;
225 *blue=QuantumRange*(min+x);
237 static inline void ConvertRGBToXYZ(const double red,const double green,
238 const double blue,double *X,double *Y,double *Z)
245 r=QuantumScale*DecodePixelGamma(red);
246 g=QuantumScale*DecodePixelGamma(green);
247 b=QuantumScale*DecodePixelGamma(blue);
248 *X=0.41239558896741421610*r+0.35758343076371481710*g+0.18049264738170157350*b;
249 *Y=0.21258623078559555160*r+0.71517030370341084990*g+0.07220049864333622685*b;
250 *Z=0.01929721549174694484*r+0.11918386458084853180*g+0.95049712513157976600*b;
253 static inline void ConvertXYZToLab(const double X,const double Y,const double Z,
254 double *L,double *a,double *b)
261 if ((X/D65X) > CIEEpsilon)
262 x=pow(X/D65X,1.0/3.0);
264 x=(CIEK*X/D65X+16.0)/116.0;
265 if ((Y/D65Y) > CIEEpsilon)
266 y=pow(Y/D65Y,1.0/3.0);
268 y=(CIEK*Y/D65Y+16.0)/116.0;
269 if ((Z/D65Z) > CIEEpsilon)
270 z=pow(Z/D65Z,1.0/3.0);
272 z=(CIEK*Z/D65Z+16.0)/116.0;
273 *L=((116.0*y)-16.0)/100.0;
274 *a=(500.0*(x-y))/255.0+0.5;
275 *b=(200.0*(y-z))/255.0+0.5;
278 static void ConvertRGBToLab(const double red,const double green,
279 const double blue,double *L,double *a,double *b)
286 ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z);
287 ConvertXYZToLab(X,Y,Z,L,a,b);
290 static inline void ConvertLabToXYZ(const double L,const double a,const double b,
291 double *X,double *Y,double *Z)
301 if ((x*x*x) > CIEEpsilon)
304 x=(116.0*x-16.0)/CIEK;
305 if ((y*y*y) > CIEEpsilon)
309 if ((z*z*z) > CIEEpsilon)
312 z=(116.0*z-16.0)/CIEK;
318 static inline void ConvertXYZToRGB(const double x,const double y,const double z,
319 double *red,double *green,double *blue)
326 r=3.2406*x-1.5372*y-0.4986*z;
327 g=(-0.9689*x+1.8758*y+0.0415*z);
328 b=0.0557*x-0.2040*y+1.0570*z;
329 *red=EncodePixelGamma(QuantumRange*r);
330 *green=EncodePixelGamma(QuantumRange*g);
331 *blue=EncodePixelGamma(QuantumRange*b);
334 static inline void ConvertLabToRGB(const double L,const double a,
335 const double b,double *red,double *green,double *blue)
342 ConvertLabToXYZ(L*100.0,255.0*(a-0.5),255.0*(b-0.5),&X,&Y,&Z);
343 ConvertXYZToRGB(X,Y,Z,red,green,blue);
346 static void ConvertRGBToYPbPr(const double red,const double green,
347 const double blue,double *Y,double *Pb,double *Pr)
349 *Y=QuantumScale*(0.298839*red+0.586811*green+0.114350*blue);
350 *Pb=QuantumScale*((-0.1687367)*red-0.331264*green+0.5*blue)+0.5;
351 *Pr=QuantumScale*(0.5*red-0.418688*green-0.081312*blue)+0.5;
354 static void ConvertRGBToYCbCr(const double red,const double green,
355 const double blue,double *Y,double *Cb,double *Cr)
357 ConvertRGBToYPbPr(red,green,blue,Y,Cb,Cr);
360 static void ConvertYPbPrToRGB(const double Y,const double Pb,const double Pr,
361 double *red,double *green,double *blue)
363 *red=QuantumRange*(0.99999999999914679361*Y-1.2188941887145875e-06*(Pb-0.5)+
364 1.4019995886561440468*(Pr-0.5));
365 *green=QuantumRange*(0.99999975910502514331*Y-0.34413567816504303521*(Pb-0.5)-
366 0.71413649331646789076*(Pr-0.5));
367 *blue=QuantumRange*(1.00000124040004623180*Y+1.77200006607230409200*(Pb-0.5)+
368 2.1453384174593273e-06*(Pr-0.5));
371 static void ConvertYCbCrToRGB(const double Y,const double Cb,
372 const double Cr,double *red,double *green,double *blue)
374 ConvertYPbPrToRGB(Y,Cb,Cr,red,green,blue);
377 static inline void ConvertLCHabToXYZ(const double luma,const double chroma,
378 const double hue,double *X,double *Y,double *Z)
380 ConvertLabToXYZ(luma,chroma*cos(hue*MagickPI/180.0),chroma*
381 sin(hue*MagickPI/180.0),X,Y,Z);
384 static void ConvertLCHabToRGB(const double luma,const double chroma,
385 const double hue,double *red,double *green,double *blue)
392 ConvertLCHabToXYZ(luma*100.0,255.0*(chroma-0.5),360.0*hue,&X,&Y,&Z);
393 ConvertXYZToRGB(X,Y,Z,red,green,blue);
396 static void ConvertRGBToHSV(const double red,const double green,
397 const double blue,double *hue,double *saturation,double *value)
404 max=MagickMax(QuantumScale*red,MagickMax(QuantumScale*green,
406 min=MagickMin(QuantumScale*red,MagickMin(QuantumScale*green,
416 if (max == (QuantumScale*red))
418 *hue=(QuantumScale*green-QuantumScale*blue)/c;
419 if ((QuantumScale*green) < (QuantumScale*blue))
423 if (max == (QuantumScale*green))
424 *hue=2.0+(QuantumScale*blue-QuantumScale*red)/c;
426 *hue=4.0+(QuantumScale*red-QuantumScale*green)/c;
431 static inline void ConvertXYZToLCHab(const double X,const double Y,
432 const double Z,double *luma,double *chroma,double *hue)
438 ConvertXYZToLab(X,Y,Z,luma,&a,&b);
439 *chroma=hypot(255.0*(a-0.5),255.0*(b-0.5))/255.0+0.5;
440 *hue=180.0*atan2(255.0*(b-0.5),255.0*(a-0.5))/MagickPI/360.0;
445 static void ConvertRGBToLCHab(const double red,const double green,
446 const double blue,double *luma,double *chroma,double *hue)
453 ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z);
454 ConvertXYZToLCHab(X,Y,Z,luma,chroma,hue);
457 static inline void ConvertLMSToXYZ(const double L,const double M,const double S,
458 double *X,double *Y,double *Z)
460 *X=1.096123820835514*L-0.278869000218287*M+0.182745179382773*S;
461 *Y=0.454369041975359*L+0.473533154307412*M+0.072097803717229*S;
462 *Z=(-0.009627608738429)*L-0.005698031216113*M+1.015325639954543*S;
465 static inline void ConvertLMSToRGB(const double L,const double M,
466 const double S,double *red,double *green,double *blue)
473 ConvertLMSToXYZ(L,M,S,&X,&Y,&Z);
474 ConvertXYZToRGB(X,Y,Z,red,green,blue);
477 static inline void ConvertXYZToLMS(const double x,const double y,
478 const double z,double *L,double *M,double *S)
480 *L=0.7328*x+0.4296*y-0.1624*z;
481 *M=(-0.7036*x+1.6975*y+0.0061*z);
482 *S=0.0030*x+0.0136*y+0.9834*z;
485 static void ConvertRGBToLMS(const double red,const double green,
486 const double blue,double *L,double *M,double *S)
493 ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z);
494 ConvertXYZToLMS(X,Y,Z,L,M,S);
497 static inline double PerceptibleReciprocal(const double x)
503 Return 1/x where x is perceptible (not unlimited or infinitesimal).
505 sign=x < 0.0 ? -1.0 : 1.0;
506 if ((sign*x) >= MagickEpsilon)
508 return(sign/MagickEpsilon);
511 static inline void ConvertXYZToLuv(const double X,const double Y,const double Z,
512 double *L,double *u,double *v)
517 if ((Y/D65Y) > CIEEpsilon)
518 *L=(double) (116.0*pow(Y/D65Y,1.0/3.0)-16.0);
521 alpha=PerceptibleReciprocal(X+15.0*Y+3.0*Z);
522 *u=13.0*(*L)*((4.0*alpha*X)-(4.0*D65X/(D65X+15.0*D65Y+3.0*D65Z)));
523 *v=13.0*(*L)*((9.0*alpha*Y)-(9.0*D65Y/(D65X+15.0*D65Y+3.0*D65Z)));
529 static void ConvertRGBToLuv(const double red,const double green,
530 const double blue,double *L,double *u,double *v)
537 ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z);
538 ConvertXYZToLuv(X,Y,Z,L,u,v);
541 static inline void ConvertLuvToXYZ(const double L,const double u,const double v,
542 double *X,double *Y,double *Z)
544 if (L > (CIEK*CIEEpsilon))
545 *Y=(double) pow((L+16.0)/116.0,3.0);
548 *X=((*Y*((39.0*L/(v+13.0*L*(9.0*D65Y/(D65X+15.0*D65Y+3.0*D65Z))))-5.0))+
549 5.0*(*Y))/((((52.0f*L/(u+13.0*L*(4.0*D65X/(D65X+15.0*D65Y+3.0*D65Z))))-1.0)/
551 *Z=(*X*(((52.0f*L/(u+13.0*L*(4.0*D65X/(D65X+15.0*D65Y+3.0*D65Z))))-1.0)/3.0))-
555 static inline void ConvertLuvToRGB(const double L,const double u,
556 const double v,double *red,double *green,double *blue)
563 ConvertLuvToXYZ(100.0*L,354.0*u-134.0,262.0*v-140.0,&X,&Y,&Z);
564 ConvertXYZToRGB(X,Y,Z,red,green,blue);
567 static void ConvertRGBToYDbDr(const double red,const double green,
568 const double blue,double *Y,double *Db,double *Dr)
570 *Y=QuantumScale*(0.298839*red+0.586811*green+0.114350*blue);
571 *Db=QuantumScale*(-0.450*red-0.883*green+1.333*blue)+0.5;
572 *Dr=QuantumScale*(-1.333*red+1.116*green+0.217*blue)+0.5;
575 static void ConvertYDbDrToRGB(const double Y,const double Db,const double Dr,
576 double *red,double *green,double *blue)
578 *red=QuantumRange*(Y+9.2303716147657e-05*(Db-0.5)-0.52591263066186533*
580 *green=QuantumRange*(Y-0.12913289889050927*(Db-0.5)+0.26789932820759876*
582 *blue=QuantumRange*(Y+0.66467905997895482*(Db-0.5)-7.9202543533108e-05*
586 static void ConvertRGBToYIQ(const double red,const double green,
587 const double blue,double *Y,double *I,double *Q)
589 *Y=QuantumScale*(0.298839*red+0.586811*green+0.114350*blue);
590 *I=QuantumScale*(0.595716*red-0.274453*green-0.321263*blue)+0.5;
591 *Q=QuantumScale*(0.211456*red-0.522591*green+0.311135*blue)+0.5;
594 static void ConvertYIQToRGB(const double Y,const double I,const double Q,
595 double *red,double *green,double *blue)
597 *red=QuantumRange*(Y+0.9562957197589482261*(I-0.5)+0.6210244164652610754*
599 *green=QuantumRange*(Y-0.2721220993185104464*(I-0.5)-0.6473805968256950427*
601 *blue=QuantumRange*(Y-1.1069890167364901945*(I-0.5)+1.7046149983646481374*
605 static void ConvertRGBToYUV(const double red,const double green,
606 const double blue,double *Y,double *U,double *V)
608 *Y=QuantumScale*(0.298839*red+0.586811*green+0.114350*blue);
609 *U=QuantumScale*((-0.147)*red-0.289*green+0.436*blue)+0.5;
610 *V=QuantumScale*(0.615*red-0.515*green-0.100*blue)+0.5;
613 static void ConvertYUVToRGB(const double Y,const double U,const double V,
614 double *red,double *green,double *blue)
616 *red=QuantumRange*(Y-3.945707070708279e-05*(U-0.5)+1.1398279671717170825*
618 *green=QuantumRange*(Y-0.3946101641414141437*(U-0.5)-0.5805003156565656797*
620 *blue=QuantumRange*(Y+2.0319996843434342537*(U-0.5)-4.813762626262513e-04*
624 static MagickBooleanType ValidateHSIToRGB()
631 (void) FormatLocaleFile(stdout," HSIToRGB");
632 ConvertHSIToRGB(111.244375/360.0,0.295985,0.658734,&r,&g,&b);
633 if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) ||
634 (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) ||
635 (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon))
640 static MagickBooleanType ValidateRGBToHSI()
647 (void) FormatLocaleFile(stdout," RGBToHSI");
648 ConvertRGBToHSI(0.545877*QuantumRange,0.966567*QuantumRange,
649 0.463759*QuantumRange,&h,&s,&i);
650 if ((fabs(h-111.244374/360.0) >= ReferenceEpsilon) ||
651 (fabs(s-0.295985) >= ReferenceEpsilon) ||
652 (fabs(i-0.658734) >= ReferenceEpsilon))
657 static MagickBooleanType ValidateHSLToRGB()
664 (void) FormatLocaleFile(stdout," HSLToRGB");
665 ConvertHSLToRGB(110.200859/360.0,0.882623,0.715163,&r,&g,&b);
666 if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) ||
667 (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) ||
668 (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon))
673 static MagickBooleanType ValidateRGBToHSL()
680 (void) FormatLocaleFile(stdout," RGBToHSL");
681 ConvertRGBToHSL(0.545877*QuantumRange,0.966567*QuantumRange,
682 0.463759*QuantumRange,&h,&s,&l);
683 if ((fabs(h-110.200859/360.0) >= ReferenceEpsilon) ||
684 (fabs(s-0.882623) >= ReferenceEpsilon) ||
685 (fabs(l-0.715163) >= ReferenceEpsilon))
690 static MagickBooleanType ValidateHSVToRGB()
697 (void) FormatLocaleFile(stdout," HSVToRGB");
698 ConvertHSVToRGB(110.200859/360.0,0.520200,0.966567,&r,&g,&b);
699 if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) ||
700 (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) ||
701 (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon))
706 static MagickBooleanType ValidateRGBToHSV()
713 (void) FormatLocaleFile(stdout," RGBToHSV");
714 ConvertRGBToHSV(0.545877*QuantumRange,0.966567*QuantumRange,
715 0.463759*QuantumRange,&h,&s,&v);
716 if ((fabs(h-110.200859/360.0) >= ReferenceEpsilon) ||
717 (fabs(s-0.520200) >= ReferenceEpsilon) ||
718 (fabs(v-0.966567) >= ReferenceEpsilon))
723 static MagickBooleanType ValidateRGBToJPEGYCbCr()
730 (void) FormatLocaleFile(stdout," RGBToJPEGYCbCr");
731 ConvertRGBToYCbCr(0.545877*QuantumRange,0.966567*QuantumRange,
732 0.463759*QuantumRange,&Y,&Cb,&Cr);
733 if ((fabs(Y-0.783460) >= ReferenceEpsilon) ||
734 (fabs(Cb-0.319581) >= ReferenceEpsilon) ||
735 (fabs(Cr-0.330539) >= ReferenceEpsilon))
740 static MagickBooleanType ValidateJPEGYCbCrToRGB()
747 (void) FormatLocaleFile(stdout," JPEGYCbCrToRGB");
748 ConvertYCbCrToRGB(0.783460,0.319581,0.330539,&r,&g,&b);
749 if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) ||
750 (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) ||
751 (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon))
756 static MagickBooleanType ValidateLabToRGB()
763 (void) FormatLocaleFile(stdout," LabToRGB");
764 ConvertLabToRGB(88.456154/100.0,-54.671483/255+0.5,51.662818/255.0+0.5,
766 if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) ||
767 (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) ||
768 (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon))
773 static MagickBooleanType ValidateRGBToLab()
780 (void) FormatLocaleFile(stdout," RGBToLab");
781 ConvertRGBToLab(0.545877*QuantumRange,0.966567*QuantumRange,
782 0.463759*QuantumRange,&L,&a,&b);
783 if ((fabs(L-(88.456154/100.0)) >= ReferenceEpsilon) ||
784 (fabs(a-(-54.671483/255.0+0.5)) >= ReferenceEpsilon) ||
785 (fabs(b-(51.662818/255.0+0.5)) >= ReferenceEpsilon))
790 static MagickBooleanType ValidateLchToRGB()
797 (void) FormatLocaleFile(stdout," LchToRGB");
798 ConvertLCHabToRGB(88.456154/100.0,75.219797/255.0+0.5,136.620717/360.0,
800 if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) ||
801 (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) ||
802 (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon))
807 static MagickBooleanType ValidateRGBToLch()
814 (void) FormatLocaleFile(stdout," RGBToLch");
815 ConvertRGBToLCHab(0.545877*QuantumRange,0.966567*QuantumRange,
816 0.463759*QuantumRange,&L,&c,&h);
817 if ((fabs(L-88.456154/100.0) >= ReferenceEpsilon) ||
818 (fabs(c-(75.219797/255.0+0.5)) >= ReferenceEpsilon) ||
819 (fabs(h-(136.620717/255.0+0.5)) >= ReferenceEpsilon))
824 static MagickBooleanType ValidateRGBToLMS()
831 (void) FormatLocaleFile(stdout," RGBToLMS");
832 ConvertRGBToLMS(0.545877*QuantumRange,0.966567*QuantumRange,
833 0.463759*QuantumRange,&L,&M,&S);
834 if ((fabs(L-0.611749) >= ReferenceEpsilon) ||
835 (fabs(M-0.910088) >= ReferenceEpsilon) ||
836 (fabs(S-0.294880) >= ReferenceEpsilon))
841 static MagickBooleanType ValidateLMSToRGB()
848 (void) FormatLocaleFile(stdout," LMSToRGB");
849 ConvertLMSToRGB(0.611749,0.910088,0.294880,&r,&g,&b);
850 if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) ||
851 (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) ||
852 (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon))
857 static MagickBooleanType ValidateRGBToLuv()
864 (void) FormatLocaleFile(stdout," RGBToLuv");
865 ConvertRGBToLuv(0.545877*QuantumRange,0.966567*QuantumRange,
866 0.463759*QuantumRange,&l,&u,&v);
867 if ((fabs(l-88.456154/262.0) >= ReferenceEpsilon) ||
868 (fabs(u-(-51.330414+134.0)/354.0) >= ReferenceEpsilon) ||
869 (fabs(v-(76.405526+140.0)/262.0) >= ReferenceEpsilon))
874 static MagickBooleanType ValidateLuvToRGB()
881 (void) FormatLocaleFile(stdout," LuvToRGB");
882 ConvertLuvToRGB(88.456154/100.0,(-51.330414+134.0)/354.0,
883 (76.405526+140.0)/262.0,&r,&g,&b);
884 if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) ||
885 (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) ||
886 (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon))
891 static MagickBooleanType ValidateRGBToXYZ()
898 (void) FormatLocaleFile(stdout," RGBToXYZ");
899 ConvertRGBToXYZ(0.545877*QuantumRange,0.966567*QuantumRange,
900 0.463759*QuantumRange,&x,&y,&z);
901 if ((fabs(x-0.470646) >= ReferenceEpsilon) ||
902 (fabs(y-0.730178) >= ReferenceEpsilon) ||
903 (fabs(z-0.288324) >= ReferenceEpsilon))
908 static MagickBooleanType ValidateXYZToRGB()
915 (void) FormatLocaleFile(stdout," XYZToRGB");
916 ConvertXYZToRGB(0.470646,0.730178,0.288324,&r,&g,&b);
917 if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) ||
918 (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) ||
919 (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon))
924 static MagickBooleanType ValidateYDbDrToRGB()
931 (void) FormatLocaleFile(stdout," YDbDrToRGB");
932 ConvertYDbDrToRGB(0.783460,-0.480932+0.5,0.451670+0.5,&r,&g,&b);
933 if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) ||
934 (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) ||
935 (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon))
940 static MagickBooleanType ValidateRGBToYDbDr()
947 (void) FormatLocaleFile(stdout," RGBToYDbDr");
948 ConvertRGBToYDbDr(0.545877*QuantumRange,0.966567*QuantumRange,
949 0.463759*QuantumRange,&Y,&Db,&Dr);
950 if ((fabs(Y-0.783460) >= ReferenceEpsilon) ||
951 (fabs(Db-(-0.480932)) >= ReferenceEpsilon) ||
952 (fabs(Dr-0.451670) >= ReferenceEpsilon))
957 static MagickBooleanType ValidateRGBToYIQ()
964 (void) FormatLocaleFile(stdout," RGBToYIQ");
965 ConvertRGBToYIQ(0.545877*QuantumRange,0.966567*QuantumRange,
966 0.463759*QuantumRange,&y,&i,&q);
967 if ((fabs(y-0.783460) >= ReferenceEpsilon) ||
968 (fabs(i-(-0.089078)) >= ReferenceEpsilon) ||
969 (fabs(q-(-0.245399)) >= ReferenceEpsilon))
974 static MagickBooleanType ValidateYIQToRGB()
981 (void) FormatLocaleFile(stdout," YIQToRGB");
982 ConvertYIQToRGB(0.783460,-0.089078+0.5,-0.245399+0.5,&r,&g,&b);
983 if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) ||
984 (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) ||
985 (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon))
990 static MagickBooleanType ValidateRGBToYPbPr()
997 (void) FormatLocaleFile(stdout," RGBToYPbPr");
998 ConvertRGBToYPbPr(0.545877*QuantumRange,0.966567*QuantumRange,
999 0.463759*QuantumRange,&y,&Pb,&Pr);
1000 if ((fabs(y-0.783460) >= ReferenceEpsilon) ||
1001 (fabs(Pb-(-0.180419)) >= ReferenceEpsilon) ||
1002 (fabs(Pr-(-0.169461)) >= ReferenceEpsilon))
1003 return(MagickFalse);
1007 static MagickBooleanType ValidateYPbPrToRGB()
1014 (void) FormatLocaleFile(stdout," YPbPrToRGB");
1015 ConvertYPbPrToRGB(0.783460,-0.180419+0.5,-0.169461+0.5,&r,&g,&b);
1016 if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) ||
1017 (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) ||
1018 (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon))
1019 return(MagickFalse);
1023 static MagickBooleanType ValidateRGBToYUV()
1030 (void) FormatLocaleFile(stdout," RGBToYUV");
1031 ConvertRGBToYUV(0.545877*QuantumRange,0.966567*QuantumRange,
1032 0.463759*QuantumRange,&Y,&U,&V);
1033 if ((fabs(Y-0.783460) >= ReferenceEpsilon) ||
1034 (fabs(U-(-0.157383)) >= ReferenceEpsilon) ||
1035 (fabs(V-(-0.208443)) >= ReferenceEpsilon))
1036 return(MagickFalse);
1040 static MagickBooleanType ValidateYUVToRGB()
1047 (void) FormatLocaleFile(stdout," YUVToRGB");
1048 ConvertYUVToRGB(0.783460,-0.157383+0.5,-0.208443+0.5,&r,&g,&b);
1049 if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) ||
1050 (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) ||
1051 (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon))
1052 return(MagickFalse);
1056 static size_t ValidateColorspaces(ImageInfo *image_info,size_t *fail,
1057 ExceptionInfo *exception)
1066 Reference: https://code.google.com/p/chroma.
1069 Observer = 2° (1931)
1071 XYZ 0.470645, 0.730177, 0.288323
1072 sRGB 0.545877, 0.966567, 0.463759
1073 CAT02 LMS 0.611749, 0.910088, 0.294880
1074 Y'DbDr 0.783460, -0.480932, 0.451670
1075 Y'IQ 0.783460, -0.089078, -0.245399
1076 Y'PbPr 0.783460, -0.180419, -0.169461
1077 Y'UV 0.783460, -0.157383, -0.208443
1078 JPEG-Y'CbCr 0.783460, 0.319581, 0.330539
1079 L*u*v* 88.456154, -51.330414, 76.405526
1080 L*a*b* 88.456154, -54.671483, 51.662818
1081 L*C*H* 88.456154, 75.219797, 136.620717
1082 HSV 110.200859, 0.520200, 0.966567
1083 HSL 110.200859, 0.882623, 0.715163
1084 HSI 111.244375, 0.295985, 0.658734
1085 Y'CbCr 187.577791, 87.586330, 90.040886
1087 (void) FormatLocaleFile(stdout,"validate colorspaces:\n");
1088 for (test=0; test < 26; test++)
1090 CatchException(exception);
1091 (void) FormatLocaleFile(stdout," test %.20g: ",(double) test);
1094 case 0: status=ValidateHSIToRGB(); break;
1095 case 1: status=ValidateRGBToHSI(); break;
1096 case 2: status=ValidateHSLToRGB(); break;
1097 case 3: status=ValidateRGBToHSL(); break;
1098 case 4: status=ValidateHSVToRGB(); break;
1099 case 5: status=ValidateRGBToHSV(); break;
1100 case 6: status=ValidateJPEGYCbCrToRGB(); break;
1101 case 7: status=ValidateRGBToJPEGYCbCr(); break;
1102 case 8: status=ValidateLabToRGB(); break;
1103 case 9: status=ValidateRGBToLab(); break;
1104 case 10: status=ValidateLchToRGB(); break;
1105 case 11: status=ValidateRGBToLch(); break;
1106 case 12: status=ValidateLMSToRGB(); break;
1107 case 13: status=ValidateRGBToLMS(); break;
1108 case 14: status=ValidateLuvToRGB(); break;
1109 case 15: status=ValidateRGBToLuv(); break;
1110 case 16: status=ValidateXYZToRGB(); break;
1111 case 17: status=ValidateRGBToXYZ(); break;
1112 case 18: status=ValidateYDbDrToRGB(); break;
1113 case 19: status=ValidateRGBToYDbDr(); break;
1114 case 20: status=ValidateYIQToRGB(); break;
1115 case 21: status=ValidateRGBToYIQ(); break;
1116 case 22: status=ValidateYPbPrToRGB(); break;
1117 case 23: status=ValidateRGBToYPbPr(); break;
1118 case 24: status=ValidateYUVToRGB(); break;
1119 case 25: status=ValidateRGBToYUV(); break;
1120 default: status=MagickFalse;
1122 if (status == MagickFalse)
1124 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1129 (void) FormatLocaleFile(stdout,"... pass.\n");
1131 (void) FormatLocaleFile(stdout,
1132 " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
1133 (double) (test-(*fail)),(double) *fail);
1138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1142 % V a l i d a t e C o m p a r e C o m m a n d %
1146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1148 % ValidateCompareCommand() validates the ImageMagick compare command line
1149 % program and returns the number of validation tests that passed and failed.
1151 % The format of the ValidateCompareCommand method is:
1153 % size_t ValidateCompareCommand(ImageInfo *image_info,
1154 % const char *reference_filename,const char *output_filename,
1155 % size_t *fail,ExceptionInfo *exception)
1157 % A description of each parameter follows:
1159 % o image_info: the image info.
1161 % o reference_filename: the reference image filename.
1163 % o output_filename: the output image filename.
1165 % o fail: return the number of validation tests that pass.
1167 % o exception: return any errors or warnings in this structure.
1170 static size_t ValidateCompareCommand(ImageInfo *image_info,
1171 const char *reference_filename,const char *output_filename,size_t *fail,
1172 ExceptionInfo *exception)
1176 command[MaxTextExtent];
1192 (void) FormatLocaleFile(stdout,"validate compare command line program:\n");
1193 for (i=0; compare_options[i] != (char *) NULL; i++)
1195 CatchException(exception);
1196 (void) FormatLocaleFile(stdout," test %.20g: %s",(double) (test++),
1197 compare_options[i]);
1198 (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s %s",
1199 compare_options[i],reference_filename,reference_filename,output_filename);
1200 arguments=StringToArgv(command,&number_arguments);
1201 if (arguments == (char **) NULL)
1203 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1208 status=CompareImagesCommand(image_info,number_arguments,arguments,
1209 (char **) NULL,exception);
1210 for (j=0; j < (ssize_t) number_arguments; j++)
1211 arguments[j]=DestroyString(arguments[j]);
1212 arguments=(char **) RelinquishMagickMemory(arguments);
1213 if (status != MagickFalse)
1215 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1220 (void) FormatLocaleFile(stdout,"... pass.\n");
1222 (void) FormatLocaleFile(stdout,
1223 " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
1224 (double) (test-(*fail)),(double) *fail);
1229 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1233 % V a l i d a t e C o m p o s i t e C o m m a n d %
1237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1239 % ValidateCompositeCommand() validates the ImageMagick composite command line
1240 % program and returns the number of validation tests that passed and failed.
1242 % The format of the ValidateCompositeCommand method is:
1244 % size_t ValidateCompositeCommand(ImageInfo *image_info,
1245 % const char *reference_filename,const char *output_filename,
1246 % size_t *fail,ExceptionInfo *exception)
1248 % A description of each parameter follows:
1250 % o image_info: the image info.
1252 % o reference_filename: the reference image filename.
1254 % o output_filename: the output image filename.
1256 % o fail: return the number of validation tests that pass.
1258 % o exception: return any errors or warnings in this structure.
1261 static size_t ValidateCompositeCommand(ImageInfo *image_info,
1262 const char *reference_filename,const char *output_filename,size_t *fail,
1263 ExceptionInfo *exception)
1267 command[MaxTextExtent];
1283 (void) FormatLocaleFile(stdout,"validate composite command line program:\n");
1284 for (i=0; composite_options[i] != (char *) NULL; i++)
1286 CatchException(exception);
1287 (void) FormatLocaleFile(stdout," test %.20g: %s",(double) (test++),
1288 composite_options[i]);
1289 (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s %s",
1290 reference_filename,composite_options[i],reference_filename,
1292 arguments=StringToArgv(command,&number_arguments);
1293 if (arguments == (char **) NULL)
1295 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1300 status=CompositeImageCommand(image_info,number_arguments,arguments,
1301 (char **) NULL,exception);
1302 for (j=0; j < (ssize_t) number_arguments; j++)
1303 arguments[j]=DestroyString(arguments[j]);
1304 arguments=(char **) RelinquishMagickMemory(arguments);
1305 if (status != MagickFalse)
1307 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1312 (void) FormatLocaleFile(stdout,"... pass.\n");
1314 (void) FormatLocaleFile(stdout,
1315 " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
1316 (double) (test-(*fail)),(double) *fail);
1321 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1325 % V a l i d a t e C o n v e r t C o m m a n d %
1329 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1331 % ValidateConvertCommand() validates the ImageMagick convert command line
1332 % program and returns the number of validation tests that passed and failed.
1334 % The format of the ValidateConvertCommand method is:
1336 % size_t ValidateConvertCommand(ImageInfo *image_info,
1337 % const char *reference_filename,const char *output_filename,
1338 % size_t *fail,ExceptionInfo *exception)
1340 % A description of each parameter follows:
1342 % o image_info: the image info.
1344 % o reference_filename: the reference image filename.
1346 % o output_filename: the output image filename.
1348 % o fail: return the number of validation tests that pass.
1350 % o exception: return any errors or warnings in this structure.
1353 static size_t ValidateConvertCommand(ImageInfo *image_info,
1354 const char *reference_filename,const char *output_filename,size_t *fail,
1355 ExceptionInfo *exception)
1359 command[MaxTextExtent];
1375 (void) FormatLocaleFile(stdout,"validate convert command line program:\n");
1376 for (i=0; convert_options[i] != (char *) NULL; i++)
1378 CatchException(exception);
1379 (void) FormatLocaleFile(stdout," test %.20g: %s",(double) test++,
1380 convert_options[i]);
1381 (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s %s",
1382 reference_filename,convert_options[i],reference_filename,output_filename);
1383 arguments=StringToArgv(command,&number_arguments);
1384 if (arguments == (char **) NULL)
1386 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1391 status=ConvertImageCommand(image_info,number_arguments,arguments,
1392 (char **) NULL,exception);
1393 for (j=0; j < (ssize_t) number_arguments; j++)
1394 arguments[j]=DestroyString(arguments[j]);
1395 arguments=(char **) RelinquishMagickMemory(arguments);
1396 if (status != MagickFalse)
1398 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1403 (void) FormatLocaleFile(stdout,"... pass.\n");
1405 (void) FormatLocaleFile(stdout,
1406 " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
1407 (double) (test-(*fail)),(double) *fail);
1412 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1416 % V a l i d a t e I d e n t i f y C o m m a n d %
1420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1422 % ValidateIdentifyCommand() validates the ImageMagick identify command line
1423 % program and returns the number of validation tests that passed and failed.
1425 % The format of the ValidateIdentifyCommand method is:
1427 % size_t ValidateIdentifyCommand(ImageInfo *image_info,
1428 % const char *reference_filename,const char *output_filename,
1429 % size_t *fail,ExceptionInfo *exception)
1431 % A description of each parameter follows:
1433 % o image_info: the image info.
1435 % o reference_filename: the reference image filename.
1437 % o output_filename: the output image filename.
1439 % o fail: return the number of validation tests that pass.
1441 % o exception: return any errors or warnings in this structure.
1444 static size_t ValidateIdentifyCommand(ImageInfo *image_info,
1445 const char *reference_filename,const char *output_filename,size_t *fail,
1446 ExceptionInfo *exception)
1450 command[MaxTextExtent];
1465 (void) output_filename;
1467 (void) FormatLocaleFile(stdout,"validate identify command line program:\n");
1468 for (i=0; identify_options[i] != (char *) NULL; i++)
1470 CatchException(exception);
1471 (void) FormatLocaleFile(stdout," test %.20g: %s",(double) test++,
1472 identify_options[i]);
1473 (void) FormatLocaleString(command,MaxTextExtent,"%s %s",
1474 identify_options[i],reference_filename);
1475 arguments=StringToArgv(command,&number_arguments);
1476 if (arguments == (char **) NULL)
1478 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1483 status=IdentifyImageCommand(image_info,number_arguments,arguments,
1484 (char **) NULL,exception);
1485 for (j=0; j < (ssize_t) number_arguments; j++)
1486 arguments[j]=DestroyString(arguments[j]);
1487 arguments=(char **) RelinquishMagickMemory(arguments);
1488 if (status != MagickFalse)
1490 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1495 (void) FormatLocaleFile(stdout,"... pass.\n");
1497 (void) FormatLocaleFile(stdout,
1498 " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
1499 (double) (test-(*fail)),(double) *fail);
1504 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1508 % 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 %
1512 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1514 % ValidateImageFormatsInMemory() validates the ImageMagick image formats in
1515 % memory and returns the number of validation tests that passed and failed.
1517 % The format of the ValidateImageFormatsInMemory method is:
1519 % size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
1520 % const char *reference_filename,const char *output_filename,
1521 % size_t *fail,ExceptionInfo *exception)
1523 % A description of each parameter follows:
1525 % o image_info: the image info.
1527 % o reference_filename: the reference image filename.
1529 % o output_filename: the output image filename.
1531 % o fail: return the number of validation tests that pass.
1533 % o exception: return any errors or warnings in this structure.
1538 Enable this to count remaining $TMPDIR/magick-* files. Note that the count
1539 includes any files left over from other runs.
1541 #undef MagickCountTempFiles
1543 static size_t ValidateImageFormatsInMemory(ImageInfo *image_info,
1544 const char *reference_filename,const char *output_filename,size_t *fail,
1545 ExceptionInfo *exception)
1548 #ifdef MagickCountTempFiles
1549 path[MaxTextExtent],
1550 SystemCommand[MaxTextExtent],
1552 size[MaxTextExtent];
1582 (void) FormatLocaleFile(stdout,"validate image formats in memory:\n");
1584 #ifdef MagickCountTempFiles
1585 (void)GetPathTemplate(path);
1586 /* Remove file template except for the leading "/path/to/magick-" */
1587 path[strlen(path)-17]='\0';
1588 (void) FormatLocaleFile(stdout," tmp path is '%s*'\n",path);
1591 for (i=0; reference_formats[i].magick != (char *) NULL; i++)
1593 magick_info=GetMagickInfo(reference_formats[i].magick,exception);
1594 if ((magick_info == (const MagickInfo *) NULL) ||
1595 (magick_info->decoder == (DecodeImageHandler *) NULL) ||
1596 (magick_info->encoder == (EncodeImageHandler *) NULL))
1598 for (j=0; reference_types[j].type != UndefinedType; j++)
1601 Generate reference image.
1603 CatchException(exception);
1604 (void) FormatLocaleFile(stdout," test %.20g: %s/%s/%s/%.20g-bits",
1605 (double) (test++),reference_formats[i].magick,CommandOptionToMnemonic(
1606 MagickCompressOptions,reference_formats[i].compression),
1607 CommandOptionToMnemonic(MagickTypeOptions,reference_types[j].type),
1608 (double) reference_types[j].depth);
1609 (void) CopyMagickString(image_info->filename,reference_filename,
1611 reference_image=ReadImage(image_info,exception);
1612 if (reference_image == (Image *) NULL ||
1613 exception->severity >= ErrorException)
1615 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1617 CatchException(exception);
1622 Write reference image.
1624 (void) FormatLocaleString(size,MaxTextExtent,"%.20gx%.20g",
1625 (double) reference_image->columns,(double) reference_image->rows);
1626 (void) CloneString(&image_info->size,size);
1627 image_info->depth=reference_types[j].depth;
1628 (void) FormatLocaleString(reference_image->filename,MaxTextExtent,"%s:%s",
1629 reference_formats[i].magick,output_filename);
1630 status=SetImageType(reference_image,reference_types[j].type,exception);
1631 if (status == MagickFalse || exception->severity >= ErrorException)
1633 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1635 CatchException(exception);
1637 reference_image=DestroyImage(reference_image);
1640 status=SetImageDepth(reference_image,reference_types[j].depth,exception);
1641 if (status == MagickFalse || exception->severity >= ErrorException)
1643 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1645 CatchException(exception);
1647 reference_image=DestroyImage(reference_image);
1650 reference_image->compression=reference_formats[i].compression;
1651 status=WriteImage(image_info,reference_image,exception);
1652 reference_image=DestroyImage(reference_image);
1653 if (status == MagickFalse || exception->severity >= ErrorException)
1655 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1657 CatchException(exception);
1662 Ping reference image.
1664 (void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
1665 reference_formats[i].magick,output_filename);
1666 ping_image=PingImage(image_info,exception);
1667 if (ping_image == (Image *) NULL ||
1668 exception->severity >= ErrorException)
1670 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1672 CatchException(exception);
1676 ping_image=DestroyImage(ping_image);
1678 Read reference image.
1680 reference_image=ReadImage(image_info,exception);
1681 if (reference_image == (Image *) NULL ||
1682 exception->severity >= ErrorException)
1684 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1686 CatchException(exception);
1691 Write reference image.
1693 (void) FormatLocaleString(reference_image->filename,MaxTextExtent,"%s:%s",
1694 reference_formats[i].magick,output_filename);
1695 (void) CopyMagickString(image_info->magick,reference_formats[i].magick,
1697 reference_image->depth=reference_types[j].depth;
1698 reference_image->compression=reference_formats[i].compression;
1700 blob=ImageToBlob(image_info,reference_image,&length,exception);
1701 if (blob == (unsigned char *) NULL ||
1702 exception->severity >= ErrorException)
1704 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1706 CatchException(exception);
1708 reference_image=DestroyImage(reference_image);
1712 Ping reference blob.
1714 ping_image=PingBlob(image_info,blob,length,exception);
1715 if (ping_image == (Image *) NULL ||
1716 exception->severity >= ErrorException)
1718 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1720 CatchException(exception);
1722 blob=(unsigned char *) RelinquishMagickMemory(blob);
1725 ping_image=DestroyImage(ping_image);
1727 Read reconstruct image.
1729 (void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
1730 reference_formats[i].magick,output_filename);
1731 reconstruct_image=BlobToImage(image_info,blob,length,exception);
1732 blob=(unsigned char *) RelinquishMagickMemory(blob);
1733 if (reconstruct_image == (Image *) NULL ||
1734 exception->severity >= ErrorException)
1736 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1738 CatchException(exception);
1740 reference_image=DestroyImage(reference_image);
1744 Compare reference to reconstruct image.
1746 fuzz=0.003; /* grayscale */
1747 if (reference_formats[i].fuzz != 0.0)
1748 fuzz=reference_formats[i].fuzz;
1749 difference_image=CompareImages(reference_image,reconstruct_image,
1750 RootMeanSquaredErrorMetric,&distortion,exception);
1751 reconstruct_image=DestroyImage(reconstruct_image);
1752 reference_image=DestroyImage(reference_image);
1753 if (difference_image == (Image *) NULL ||
1754 exception->severity >= ErrorException)
1756 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1758 CatchException(exception);
1762 difference_image=DestroyImage(difference_image);
1763 if ((QuantumScale*distortion) > fuzz)
1765 (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
1766 QuantumScale*distortion);
1770 #ifdef MagickCountTempFiles
1771 (void) FormatLocaleFile(stdout,"... pass, ");
1772 (void) fflush(stdout);
1773 SystemCommand[0]='\0';
1774 (void) strncat(SystemCommand,"echo `ls ",9);
1775 (void) strncat(SystemCommand,path,MaxTextExtent-31);
1776 (void) strncat(SystemCommand,"* | wc -w` tmp files.",20);
1777 (void) system(SystemCommand);
1778 (void) fflush(stdout);
1780 (void) FormatLocaleFile(stdout,"... pass\n");
1784 (void) FormatLocaleFile(stdout,
1785 " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
1786 (double) (test-(*fail)),(double) *fail);
1791 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1795 % 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 %
1799 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1801 % ValidateImageFormatsOnDisk() validates the ImageMagick image formats on disk
1802 % and returns the number of validation tests that passed and failed.
1804 % The format of the ValidateImageFormatsOnDisk method is:
1806 % size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
1807 % const char *reference_filename,const char *output_filename,
1808 % size_t *fail,ExceptionInfo *exception)
1810 % A description of each parameter follows:
1812 % o image_info: the image info.
1814 % o reference_filename: the reference image filename.
1816 % o output_filename: the output image filename.
1818 % o fail: return the number of validation tests that pass.
1820 % o exception: return any errors or warnings in this structure.
1823 static size_t ValidateImageFormatsOnDisk(ImageInfo *image_info,
1824 const char *reference_filename,const char *output_filename,size_t *fail,
1825 ExceptionInfo *exception)
1828 size[MaxTextExtent];
1853 (void) FormatLocaleFile(stdout,"validate image formats on disk:\n");
1854 for (i=0; reference_formats[i].magick != (char *) NULL; i++)
1856 magick_info=GetMagickInfo(reference_formats[i].magick,exception);
1857 if ((magick_info == (const MagickInfo *) NULL) ||
1858 (magick_info->decoder == (DecodeImageHandler *) NULL) ||
1859 (magick_info->encoder == (EncodeImageHandler *) NULL))
1861 for (j=0; reference_types[j].type != UndefinedType; j++)
1864 Generate reference image.
1866 CatchException(exception);
1867 (void) FormatLocaleFile(stdout," test %.20g: %s/%s/%s/%.20g-bits",
1868 (double) (test++),reference_formats[i].magick,CommandOptionToMnemonic(
1869 MagickCompressOptions,reference_formats[i].compression),
1870 CommandOptionToMnemonic(MagickTypeOptions,reference_types[j].type),
1871 (double) reference_types[j].depth);
1872 (void) CopyMagickString(image_info->filename,reference_filename,
1874 reference_image=ReadImage(image_info,exception);
1875 if (reference_image == (Image *) NULL ||
1876 exception->severity >= ErrorException)
1878 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1880 CatchException(exception);
1885 Write reference image.
1887 (void) FormatLocaleString(size,MaxTextExtent,"%.20gx%.20g",
1888 (double) reference_image->columns,(double) reference_image->rows);
1889 (void) CloneString(&image_info->size,size);
1890 image_info->depth=reference_types[j].depth;
1891 (void) FormatLocaleString(reference_image->filename,MaxTextExtent,"%s:%s",
1892 reference_formats[i].magick,output_filename);
1893 status=SetImageType(reference_image,reference_types[j].type,exception);
1894 if (status == MagickFalse || exception->severity >= ErrorException)
1896 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1898 CatchException(exception);
1900 reference_image=DestroyImage(reference_image);
1903 status=SetImageDepth(reference_image,reference_types[j].depth,exception);
1904 if (status == MagickFalse || exception->severity >= ErrorException)
1906 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1908 CatchException(exception);
1910 reference_image=DestroyImage(reference_image);
1913 reference_image->compression=reference_formats[i].compression;
1914 status=WriteImage(image_info,reference_image,exception);
1915 reference_image=DestroyImage(reference_image);
1916 if (status == MagickFalse || exception->severity >= ErrorException)
1918 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1920 CatchException(exception);
1925 Read reference image.
1927 (void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
1928 reference_formats[i].magick,output_filename);
1929 reference_image=ReadImage(image_info,exception);
1930 if (reference_image == (Image *) NULL ||
1931 exception->severity >= ErrorException)
1933 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1935 CatchException(exception);
1940 Write reference image.
1942 (void) FormatLocaleString(reference_image->filename,MaxTextExtent,"%s:%s",
1943 reference_formats[i].magick,output_filename);
1944 reference_image->depth=reference_types[j].depth;
1945 reference_image->compression=reference_formats[i].compression;
1946 status=WriteImage(image_info,reference_image,exception);
1947 if (status == MagickFalse ||exception->severity >= ErrorException)
1949 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1951 CatchException(exception);
1953 reference_image=DestroyImage(reference_image);
1957 Read reconstruct image.
1959 (void) FormatLocaleString(image_info->filename,MaxTextExtent,"%s:%s",
1960 reference_formats[i].magick,output_filename);
1961 reconstruct_image=ReadImage(image_info,exception);
1962 if (reconstruct_image == (Image *) NULL ||
1963 exception->severity >= ErrorException)
1965 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1967 CatchException(exception);
1969 reference_image=DestroyImage(reference_image);
1973 Compare reference to reconstruct image.
1975 fuzz=0.003; /* grayscale */
1976 if (reference_formats[i].fuzz != 0.0)
1977 fuzz=reference_formats[i].fuzz;
1978 difference_image=CompareImages(reference_image,reconstruct_image,
1979 RootMeanSquaredErrorMetric,&distortion,exception);
1980 reconstruct_image=DestroyImage(reconstruct_image);
1981 reference_image=DestroyImage(reference_image);
1982 if (difference_image == (Image *) NULL ||
1983 exception->severity >= ErrorException)
1985 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
1987 CatchException(exception);
1991 difference_image=DestroyImage(difference_image);
1992 if ((QuantumScale*distortion) > fuzz)
1994 (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
1995 QuantumScale*distortion);
1999 (void) FormatLocaleFile(stdout,"... pass.\n");
2002 (void) FormatLocaleFile(stdout,
2003 " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
2004 (double) (test-(*fail)),(double) *fail);
2009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2013 % 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 %
2017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2019 % ValidateImportExportPixels() validates the pixel import and export methods.
2020 % It returns the number of validation tests that passed and failed.
2022 % The format of the ValidateImportExportPixels method is:
2024 % size_t ValidateImportExportPixels(ImageInfo *image_info,
2025 % const char *reference_filename,const char *output_filename,
2026 % size_t *fail,ExceptionInfo *exception)
2028 % A description of each parameter follows:
2030 % o image_info: the image info.
2032 % o reference_filename: the reference image filename.
2034 % o output_filename: the output image filename.
2036 % o fail: return the number of validation tests that pass.
2038 % o exception: return any errors or warnings in this structure.
2041 static size_t ValidateImportExportPixels(ImageInfo *image_info,
2042 const char *reference_filename,const char *output_filename,size_t *fail,
2043 ExceptionInfo *exception)
2069 (void) output_filename;
2071 (void) FormatLocaleFile(stdout,
2072 "validate the import and export of image pixels:\n");
2073 for (i=0; reference_map[i] != (char *) NULL; i++)
2075 for (j=0; reference_storage[j].type != UndefinedPixel; j++)
2078 Generate reference image.
2080 CatchException(exception);
2081 (void) FormatLocaleFile(stdout," test %.20g: %s/%s",(double) (test++),
2082 reference_map[i],CommandOptionToMnemonic(MagickStorageOptions,
2083 reference_storage[j].type));
2084 (void) CopyMagickString(image_info->filename,reference_filename,
2086 reference_image=ReadImage(image_info,exception);
2087 if (reference_image == (Image *) NULL ||
2088 exception->severity >= ErrorException)
2090 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
2092 CatchException(exception);
2096 if (LocaleNCompare(reference_map[i],"cmy",3) == 0)
2097 (void) SetImageColorspace(reference_image,CMYKColorspace,exception);
2098 length=strlen(reference_map[i])*reference_image->columns*
2099 reference_image->rows*reference_storage[j].quantum;
2100 pixels=(unsigned char *) AcquireQuantumMemory(length,sizeof(*pixels));
2101 if (pixels == (unsigned char *) NULL ||
2102 exception->severity >= ErrorException)
2104 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
2106 CatchException(exception);
2108 reference_image=DestroyImage(reference_image);
2111 (void) ResetMagickMemory(pixels,0,length*sizeof(*pixels));
2112 status=ExportImagePixels(reference_image,0,0,reference_image->columns,
2113 reference_image->rows,reference_map[i],reference_storage[j].type,pixels,
2115 if (status == MagickFalse || exception->severity >= ErrorException)
2117 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
2119 CatchException(exception);
2121 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
2122 reference_image=DestroyImage(reference_image);
2125 (void) SetImageBackgroundColor(reference_image,exception);
2126 status=ImportImagePixels(reference_image,0,0,reference_image->columns,
2127 reference_image->rows,reference_map[i],reference_storage[j].type,
2129 if (status == MagickFalse || exception->severity >= ErrorException)
2131 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
2133 CatchException(exception);
2135 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
2136 reference_image=DestroyImage(reference_image);
2140 Read reconstruct image.
2142 reconstruct_image=AcquireImage(image_info,exception);
2143 (void) SetImageExtent(reconstruct_image,reference_image->columns,
2144 reference_image->rows,exception);
2145 (void) SetImageColorspace(reconstruct_image,reference_image->colorspace,
2147 (void) SetImageBackgroundColor(reconstruct_image,exception);
2148 status=ImportImagePixels(reconstruct_image,0,0,reconstruct_image->columns,
2149 reconstruct_image->rows,reference_map[i],reference_storage[j].type,
2151 pixels=(unsigned char *) RelinquishMagickMemory(pixels);
2152 if (status == MagickFalse || exception->severity >= ErrorException)
2154 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
2156 CatchException(exception);
2158 reference_image=DestroyImage(reference_image);
2162 Compare reference to reconstruct image.
2164 difference_image=CompareImages(reference_image,reconstruct_image,
2165 RootMeanSquaredErrorMetric,&distortion,exception);
2166 reconstruct_image=DestroyImage(reconstruct_image);
2167 reference_image=DestroyImage(reference_image);
2168 if (difference_image == (Image *) NULL ||
2169 exception->severity >= ErrorException)
2171 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
2173 CatchException(exception);
2177 difference_image=DestroyImage(difference_image);
2178 if ((QuantumScale*distortion) > 0.0)
2180 (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n",
2181 QuantumScale*distortion);
2185 (void) FormatLocaleFile(stdout,"... pass.\n");
2188 (void) FormatLocaleFile(stdout,
2189 " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
2190 (double) (test-(*fail)),(double) *fail);
2195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2199 % V a l i d a t e M o n t a g e C o m m a n d %
2203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2205 % ValidateMontageCommand() validates the ImageMagick montage command line
2206 % program and returns the number of validation tests that passed and failed.
2208 % The format of the ValidateMontageCommand method is:
2210 % size_t ValidateMontageCommand(ImageInfo *image_info,
2211 % const char *reference_filename,const char *output_filename,
2212 % size_t *fail,ExceptionInfo *exception)
2214 % A description of each parameter follows:
2216 % o image_info: the image info.
2218 % o reference_filename: the reference image filename.
2220 % o output_filename: the output image filename.
2222 % o fail: return the number of validation tests that pass.
2224 % o exception: return any errors or warnings in this structure.
2227 static size_t ValidateMontageCommand(ImageInfo *image_info,
2228 const char *reference_filename,const char *output_filename,size_t *fail,
2229 ExceptionInfo *exception)
2233 command[MaxTextExtent];
2249 (void) FormatLocaleFile(stdout,"validate montage command line program:\n");
2250 for (i=0; montage_options[i] != (char *) NULL; i++)
2252 CatchException(exception);
2253 (void) FormatLocaleFile(stdout," test %.20g: %s",(double) (test++),
2254 montage_options[i]);
2255 (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s %s",
2256 reference_filename,montage_options[i],reference_filename,
2258 arguments=StringToArgv(command,&number_arguments);
2259 if (arguments == (char **) NULL)
2261 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
2266 status=MontageImageCommand(image_info,number_arguments,arguments,
2267 (char **) NULL,exception);
2268 for (j=0; j < (ssize_t) number_arguments; j++)
2269 arguments[j]=DestroyString(arguments[j]);
2270 arguments=(char **) RelinquishMagickMemory(arguments);
2271 if (status != MagickFalse)
2273 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
2278 (void) FormatLocaleFile(stdout,"... pass.\n");
2280 (void) FormatLocaleFile(stdout,
2281 " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
2282 (double) (test-(*fail)),(double) *fail);
2287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2291 % V a l i d a t e S t r e a m C o m m a n d %
2295 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2297 % ValidateStreamCommand() validates the ImageMagick stream command line
2298 % program and returns the number of validation tests that passed and failed.
2300 % The format of the ValidateStreamCommand method is:
2302 % size_t ValidateStreamCommand(ImageInfo *image_info,
2303 % const char *reference_filename,const char *output_filename,
2304 % size_t *fail,ExceptionInfo *exception)
2306 % A description of each parameter follows:
2308 % o image_info: the image info.
2310 % o reference_filename: the reference image filename.
2312 % o output_filename: the output image filename.
2314 % o fail: return the number of validation tests that pass.
2316 % o exception: return any errors or warnings in this structure.
2319 static size_t ValidateStreamCommand(ImageInfo *image_info,
2320 const char *reference_filename,const char *output_filename,size_t *fail,
2321 ExceptionInfo *exception)
2325 command[MaxTextExtent];
2341 (void) FormatLocaleFile(stdout,"validate stream command line program:\n");
2342 for (i=0; stream_options[i] != (char *) NULL; i++)
2344 CatchException(exception);
2345 (void) FormatLocaleFile(stdout," test %.20g: %s",(double) (test++),
2347 (void) FormatLocaleString(command,MaxTextExtent,"%s %s %s",
2348 stream_options[i],reference_filename,output_filename);
2349 arguments=StringToArgv(command,&number_arguments);
2350 if (arguments == (char **) NULL)
2352 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
2357 status=StreamImageCommand(image_info,number_arguments,arguments,
2358 (char **) NULL,exception);
2359 for (j=0; j < (ssize_t) number_arguments; j++)
2360 arguments[j]=DestroyString(arguments[j]);
2361 arguments=(char **) RelinquishMagickMemory(arguments);
2362 if (status != MagickFalse)
2364 (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n",
2369 (void) FormatLocaleFile(stdout,"... pass.\n");
2371 (void) FormatLocaleFile(stdout,
2372 " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test,
2373 (double) (test-(*fail)),(double) *fail);
2378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2386 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2391 static MagickBooleanType ValidateUsage(void)
2399 "-debug events display copious debugging information",
2400 "-help print program options",
2401 "-log format format of debugging information",
2402 "-validate type validation type",
2403 "-version print version information",
2408 "-regard-warnings pay attention to warning messages",
2409 "-verbose print detailed information about the image",
2413 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
2414 (void) printf("Copyright: %s\n\n",GetMagickCopyright());
2415 (void) printf("Features: %s\n",GetMagickFeatures());
2416 (void) printf("Usage: %s [options ...] reference-file\n",GetClientName());
2417 (void) printf("\nValidate Settings:\n");
2418 for (p=settings; *p != (char *) NULL; p++)
2419 (void) printf(" %s\n",*p);
2420 (void) printf("\nMiscellaneous Options:\n");
2421 for (p=miscellaneous; *p != (char *) NULL; p++)
2422 (void) printf(" %s\n",*p);
2426 int main(int argc,char **argv)
2428 #define DestroyValidate() \
2430 image_info=DestroyImageInfo(image_info); \
2431 exception=DestroyExceptionInfo(exception); \
2433 #define ThrowValidateException(asperity,tag,option) \
2435 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
2437 CatchException(exception); \
2438 DestroyValidate(); \
2439 return(MagickFalse); \
2443 output_filename[MaxTextExtent],
2444 reference_filename[MaxTextExtent],
2483 Validate the ImageMagick image processing suite.
2485 MagickCoreGenesis(*argv,MagickTrue);
2486 (void) setlocale(LC_ALL,"");
2487 (void) setlocale(LC_NUMERIC,"C");
2491 regard_warnings=MagickFalse;
2492 (void) regard_warnings;
2493 exception=AcquireExceptionInfo();
2494 image_info=AcquireImageInfo();
2495 (void) CopyMagickString(image_info->filename,ReferenceFilename,MaxTextExtent);
2496 for (i=1; i < (ssize_t) argc; i++)
2499 if (IsCommandOption(option) == MagickFalse)
2501 (void) CopyMagickString(image_info->filename,option,MaxTextExtent);
2504 switch (*(option+1))
2508 if (LocaleCompare("bench",option+1) == 0)
2510 iterations=StringToUnsignedLong(argv[++i]);
2513 ThrowValidateException(OptionError,"UnrecognizedOption",option)
2517 if (LocaleCompare("debug",option+1) == 0)
2519 (void) SetLogEventMask(argv[++i]);
2522 ThrowValidateException(OptionError,"UnrecognizedOption",option)
2526 if (LocaleCompare("help",option+1) == 0)
2528 (void) ValidateUsage();
2531 ThrowValidateException(OptionError,"UnrecognizedOption",option)
2535 if (LocaleCompare("log",option+1) == 0)
2538 (void) SetLogFormat(argv[i+1]);
2541 ThrowValidateException(OptionError,"UnrecognizedOption",option)
2545 if (LocaleCompare("regard-warnings",option+1) == 0)
2547 regard_warnings=MagickTrue;
2550 ThrowValidateException(OptionError,"UnrecognizedOption",option)
2554 if (LocaleCompare("validate",option+1) == 0)
2562 if (i >= (ssize_t) argc)
2563 ThrowValidateException(OptionError,"MissingArgument",option);
2564 validate=ParseCommandOption(MagickValidateOptions,MagickFalse,
2567 ThrowValidateException(OptionError,"UnrecognizedValidateType",
2569 type=(ValidateType) validate;
2572 if ((LocaleCompare("version",option+1) == 0) ||
2573 (LocaleCompare("-version",option+1) == 0))
2575 (void) FormatLocaleFile(stdout,"Version: %s\n",
2576 GetMagickVersion((size_t *) NULL));
2577 (void) FormatLocaleFile(stdout,"Copyright: %s\n\n",
2578 GetMagickCopyright());
2579 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
2580 GetMagickFeatures());
2583 ThrowValidateException(OptionError,"UnrecognizedOption",option)
2586 ThrowValidateException(OptionError,"UnrecognizedOption",option)
2589 timer=(TimerInfo *) NULL;
2591 timer=AcquireTimerInfo();
2592 reference_image=ReadImage(image_info,exception);
2595 if (reference_image == (Image *) NULL)
2599 if (LocaleCompare(image_info->filename,ReferenceFilename) == 0)
2600 (void) CopyMagickString(reference_image->magick,ReferenceImageFormat,
2602 (void) AcquireUniqueFilename(reference_filename);
2603 (void) AcquireUniqueFilename(output_filename);
2604 (void) CopyMagickString(reference_image->filename,reference_filename,
2606 status=WriteImage(image_info,reference_image,exception);
2607 reference_image=DestroyImage(reference_image);
2608 if (status == MagickFalse)
2612 (void) FormatLocaleFile(stdout,"Version: %s\n",
2613 GetMagickVersion((size_t *) NULL));
2614 (void) FormatLocaleFile(stdout,"Copyright: %s\n\n",
2615 GetMagickCopyright());
2616 (void) FormatLocaleFile(stdout,
2617 "ImageMagick Validation Suite (%s)\n\n",CommandOptionToMnemonic(
2618 MagickValidateOptions,(ssize_t) type));
2619 if ((type & ColorspaceValidate) != 0)
2620 tests+=ValidateColorspaces(image_info,&fail,exception);
2621 if ((type & CompareValidate) != 0)
2622 tests+=ValidateCompareCommand(image_info,reference_filename,
2623 output_filename,&fail,exception);
2624 if ((type & CompositeValidate) != 0)
2625 tests+=ValidateCompositeCommand(image_info,reference_filename,
2626 output_filename,&fail,exception);
2627 if ((type & ConvertValidate) != 0)
2628 tests+=ValidateConvertCommand(image_info,reference_filename,
2629 output_filename,&fail,exception);
2630 if ((type & FormatsDiskValidate) != 0)
2632 memory_resource=SetMagickResourceLimit(MemoryResource,0);
2633 map_resource=SetMagickResourceLimit(MapResource,0);
2634 (void) FormatLocaleFile(stdout,"[pixel-cache: disk] ");
2635 tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
2636 output_filename,&fail,exception);
2637 (void) FormatLocaleFile(stdout,"[pixel-cache: disk] ");
2638 tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
2639 output_filename,&fail,exception);
2640 (void) SetMagickResourceLimit(MemoryResource,memory_resource);
2641 (void) SetMagickResourceLimit(MapResource,map_resource);
2643 if ((type & FormatsMapValidate) != 0)
2645 memory_resource=SetMagickResourceLimit(MemoryResource,0);
2646 (void) FormatLocaleFile(stdout,"[pixel-cache: memory-mapped] ");
2647 tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
2648 output_filename,&fail,exception);
2649 (void) FormatLocaleFile(stdout,"[pixel-cache: memory-mapped] ");
2650 tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
2651 output_filename,&fail,exception);
2652 (void) SetMagickResourceLimit(MemoryResource,memory_resource);
2654 if ((type & FormatsMemoryValidate) != 0)
2656 (void) FormatLocaleFile(stdout,"[pixel-cache: memory] ");
2657 tests+=ValidateImageFormatsInMemory(image_info,reference_filename,
2658 output_filename,&fail,exception);
2659 (void) FormatLocaleFile(stdout,"[pixel-cache: memory] ");
2660 tests+=ValidateImageFormatsOnDisk(image_info,reference_filename,
2661 output_filename,&fail,exception);
2663 if ((type & IdentifyValidate) != 0)
2664 tests+=ValidateIdentifyCommand(image_info,reference_filename,
2665 output_filename,&fail,exception);
2666 if ((type & ImportExportValidate) != 0)
2667 tests+=ValidateImportExportPixels(image_info,reference_filename,
2668 output_filename,&fail,exception);
2669 if ((type & MontageValidate) != 0)
2670 tests+=ValidateMontageCommand(image_info,reference_filename,
2671 output_filename,&fail,exception);
2672 if ((type & StreamValidate) != 0)
2673 tests+=ValidateStreamCommand(image_info,reference_filename,
2674 output_filename,&fail,exception);
2675 (void) FormatLocaleFile(stdout,
2676 "validation suite: %.20g tests; %.20g passed; %.20g failed.\n",
2677 (double) tests,(double) (tests-fail),(double) fail);
2679 (void) RelinquishUniqueFileResource(output_filename);
2680 (void) RelinquishUniqueFileResource(reference_filename);
2682 if (exception->severity != UndefinedException)
2683 CatchException(exception);
2686 elapsed_time=GetElapsedTime(timer);
2687 user_time=GetUserTime(timer);
2688 (void) FormatLocaleFile(stderr,
2689 "Performance: %.20gi %gips %0.3fu %ld:%02ld.%03ld\n",(double)
2690 iterations,1.0*iterations/elapsed_time,user_time,(long)
2691 (elapsed_time/60.0),(long) ceil(fmod(elapsed_time,60.0)),
2692 (long) (1000.0*(elapsed_time-floor(elapsed_time))));
2693 timer=DestroyTimerInfo(timer);
2696 MagickCoreTerminus();
2697 return(fail == 0 ? 0 : 1);