cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % % |
| 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 % |
| 12 | % % |
| 13 | % % |
| 14 | % ImageMagick Validation Suite % |
| 15 | % % |
| 16 | % Software Design % |
cristy | de984cd | 2013-12-01 14:49:27 +0000 | [diff] [blame] | 17 | % Cristy % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 18 | % March 2001 % |
| 19 | % % |
| 20 | % % |
Cristy | f6ff9ea | 2016-12-05 09:53:35 -0500 | [diff] [blame] | 21 | % Copyright 1999-2017 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 22 | % dedicated to making software imaging solutions freely available. % |
| 23 | % % |
| 24 | % You may not use this file except in compliance with the License. You may % |
| 25 | % obtain a copy of the License at % |
| 26 | % % |
Cristy | f19d414 | 2017-04-24 11:34:30 -0400 | [diff] [blame] | 27 | % https://www.imagemagick.org/script/license.php % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 28 | % % |
| 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. % |
| 34 | % % |
| 35 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 36 | % |
| 37 | % |
| 38 | */ |
| 39 | |
| 40 | /* |
| 41 | Include declarations. |
| 42 | */ |
| 43 | #include <stdio.h> |
cristy | 5e8e981 | 2009-12-17 15:13:38 +0000 | [diff] [blame] | 44 | #include <stdlib.h> |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 45 | #include <string.h> |
cristy | 5e8e981 | 2009-12-17 15:13:38 +0000 | [diff] [blame] | 46 | #include <ctype.h> |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 47 | #include <math.h> |
cristy | e260574 | 2012-12-12 11:18:34 +0000 | [diff] [blame] | 48 | #include <locale.h> |
cristy | 9883b45 | 2011-07-01 23:37:21 +0000 | [diff] [blame] | 49 | #include "MagickWand/MagickWand.h" |
cristy | 510d06a | 2011-07-06 23:43:54 +0000 | [diff] [blame] | 50 | #include "MagickCore/colorspace-private.h" |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 51 | #include "MagickCore/gem.h" |
glennrp | 4084cda | 2012-12-11 14:13:35 +0000 | [diff] [blame] | 52 | #include "MagickCore/resource_.h" |
cristy | 9883b45 | 2011-07-01 23:37:21 +0000 | [diff] [blame] | 53 | #include "MagickCore/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 54 | #include "validate.h" |
| 55 | |
| 56 | /* |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 57 | Define declarations. |
| 58 | */ |
| 59 | #define CIEEpsilon (216.0/24389.0) |
| 60 | #define CIEK (24389.0/27.0) |
| 61 | #define D65X 0.950456 |
| 62 | #define D65Y 1.0 |
| 63 | #define D65Z 1.088754 |
cristy | a7230ee | 2013-07-25 11:51:29 +0000 | [diff] [blame] | 64 | #define ReferenceEpsilon (QuantumRange*1.0e-2) |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 65 | |
| 66 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 67 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 68 | % % |
| 69 | % % |
| 70 | % % |
cristy | 572e097 | 2013-05-07 12:51:28 +0000 | [diff] [blame] | 71 | % V a l i d a t e C o l o r s p a c e s % |
cristy | 80e870e | 2013-05-07 12:23:02 +0000 | [diff] [blame] | 72 | % % |
| 73 | % % |
| 74 | % % |
| 75 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 76 | % |
cristy | 572e097 | 2013-05-07 12:51:28 +0000 | [diff] [blame] | 77 | % ValidateColorspaces() validates the ImageMagick colorspaces and returns the |
| 78 | % number of validation tests that passed and failed. |
cristy | 80e870e | 2013-05-07 12:23:02 +0000 | [diff] [blame] | 79 | % |
cristy | 572e097 | 2013-05-07 12:51:28 +0000 | [diff] [blame] | 80 | % The format of the ValidateColorspaces method is: |
cristy | 80e870e | 2013-05-07 12:23:02 +0000 | [diff] [blame] | 81 | % |
cristy | 572e097 | 2013-05-07 12:51:28 +0000 | [diff] [blame] | 82 | % size_t ValidateColorspaces(ImageInfo *image_info,size_t *fail, |
| 83 | % ExceptionInfo *exception) |
cristy | 80e870e | 2013-05-07 12:23:02 +0000 | [diff] [blame] | 84 | % |
| 85 | % A description of each parameter follows: |
| 86 | % |
| 87 | % o image_info: the image info. |
| 88 | % |
cristy | 80e870e | 2013-05-07 12:23:02 +0000 | [diff] [blame] | 89 | % o fail: return the number of validation tests that pass. |
| 90 | % |
| 91 | % o exception: return any errors or warnings in this structure. |
| 92 | % |
| 93 | */ |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 94 | |
| 95 | static void ConvertHSIToRGB(const double hue,const double saturation, |
| 96 | const double intensity,double *red,double *green,double *blue) |
| 97 | { |
| 98 | double |
| 99 | h; |
| 100 | |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 101 | h=360.0*hue; |
| 102 | h-=360.0*floor(h/360.0); |
| 103 | if (h < 120.0) |
| 104 | { |
| 105 | *blue=intensity*(1.0-saturation); |
| 106 | *red=intensity*(1.0+saturation*cos(h*(MagickPI/180.0))/cos((60.0-h)* |
| 107 | (MagickPI/180.0))); |
| 108 | *green=3.0*intensity-*red-*blue; |
| 109 | } |
| 110 | else |
| 111 | if (h < 240.0) |
| 112 | { |
| 113 | h-=120.0; |
| 114 | *red=intensity*(1.0-saturation); |
| 115 | *green=intensity*(1.0+saturation*cos(h*(MagickPI/180.0))/cos((60.0-h)* |
| 116 | (MagickPI/180.0))); |
| 117 | *blue=3.0*intensity-*red-*green; |
| 118 | } |
| 119 | else |
| 120 | { |
| 121 | h-=240.0; |
| 122 | *green=intensity*(1.0-saturation); |
| 123 | *blue=intensity*(1.0+saturation*cos(h*(MagickPI/180.0))/cos((60.0-h)* |
| 124 | (MagickPI/180.0))); |
| 125 | *red=3.0*intensity-*green-*blue; |
| 126 | } |
| 127 | *red*=QuantumRange; |
| 128 | *green*=QuantumRange; |
| 129 | *blue*=QuantumRange; |
| 130 | } |
| 131 | |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 132 | static void ConvertRGBToHSI(const double red,const double green, |
| 133 | const double blue,double *hue,double *saturation,double *intensity) |
| 134 | { |
| 135 | double |
| 136 | alpha, |
| 137 | beta; |
| 138 | |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 139 | *intensity=(QuantumScale*red+QuantumScale*green+QuantumScale*blue)/3.0; |
| 140 | if (*intensity <= 0.0) |
| 141 | { |
| 142 | *hue=0.0; |
| 143 | *saturation=0.0; |
| 144 | return; |
| 145 | } |
| 146 | *saturation=1.0-MagickMin(QuantumScale*red,MagickMin(QuantumScale*green, |
| 147 | QuantumScale*blue))/(*intensity); |
| 148 | alpha=0.5*(2.0*QuantumScale*red-QuantumScale*green-QuantumScale*blue); |
| 149 | beta=0.8660254037844385*(QuantumScale*green-QuantumScale*blue); |
| 150 | *hue=atan2(beta,alpha)*(180.0/MagickPI)/360.0; |
| 151 | if (*hue < 0.0) |
| 152 | *hue+=1.0; |
| 153 | } |
| 154 | |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 155 | static void ConvertHSVToRGB(const double hue,const double saturation, |
| 156 | const double value,double *red,double *green,double *blue) |
| 157 | { |
| 158 | double |
| 159 | c, |
| 160 | h, |
| 161 | min, |
| 162 | x; |
| 163 | |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 164 | h=hue*360.0; |
| 165 | c=value*saturation; |
| 166 | min=value-c; |
| 167 | h-=360.0*floor(h/360.0); |
| 168 | h/=60.0; |
| 169 | x=c*(1.0-fabs(h-2.0*floor(h/2.0)-1.0)); |
| 170 | switch ((int) floor(h)) |
| 171 | { |
| 172 | case 0: |
| 173 | { |
| 174 | *red=QuantumRange*(min+c); |
| 175 | *green=QuantumRange*(min+x); |
| 176 | *blue=QuantumRange*min; |
| 177 | break; |
| 178 | } |
| 179 | case 1: |
| 180 | { |
| 181 | *red=QuantumRange*(min+x); |
| 182 | *green=QuantumRange*(min+c); |
| 183 | *blue=QuantumRange*min; |
| 184 | break; |
| 185 | } |
| 186 | case 2: |
| 187 | { |
| 188 | *red=QuantumRange*min; |
| 189 | *green=QuantumRange*(min+c); |
| 190 | *blue=QuantumRange*(min+x); |
| 191 | break; |
| 192 | } |
| 193 | case 3: |
| 194 | { |
| 195 | *red=QuantumRange*min; |
| 196 | *green=QuantumRange*(min+x); |
| 197 | *blue=QuantumRange*(min+c); |
| 198 | break; |
| 199 | } |
| 200 | case 4: |
| 201 | { |
| 202 | *red=QuantumRange*(min+x); |
| 203 | *green=QuantumRange*min; |
| 204 | *blue=QuantumRange*(min+c); |
| 205 | break; |
| 206 | } |
| 207 | case 5: |
| 208 | { |
| 209 | *red=QuantumRange*(min+c); |
| 210 | *green=QuantumRange*min; |
| 211 | *blue=QuantumRange*(min+x); |
| 212 | break; |
| 213 | } |
| 214 | default: |
| 215 | { |
| 216 | *red=0.0; |
| 217 | *green=0.0; |
| 218 | *blue=0.0; |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | static inline void ConvertRGBToXYZ(const double red,const double green, |
| 224 | const double blue,double *X,double *Y,double *Z) |
| 225 | { |
| 226 | double |
| 227 | b, |
| 228 | g, |
| 229 | r; |
| 230 | |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 231 | r=QuantumScale*DecodePixelGamma(red); |
| 232 | g=QuantumScale*DecodePixelGamma(green); |
| 233 | b=QuantumScale*DecodePixelGamma(blue); |
| 234 | *X=0.41239558896741421610*r+0.35758343076371481710*g+0.18049264738170157350*b; |
| 235 | *Y=0.21258623078559555160*r+0.71517030370341084990*g+0.07220049864333622685*b; |
| 236 | *Z=0.01929721549174694484*r+0.11918386458084853180*g+0.95049712513157976600*b; |
| 237 | } |
| 238 | |
| 239 | static inline void ConvertXYZToLab(const double X,const double Y,const double Z, |
| 240 | double *L,double *a,double *b) |
| 241 | { |
| 242 | double |
| 243 | x, |
| 244 | y, |
| 245 | z; |
| 246 | |
| 247 | if ((X/D65X) > CIEEpsilon) |
| 248 | x=pow(X/D65X,1.0/3.0); |
| 249 | else |
| 250 | x=(CIEK*X/D65X+16.0)/116.0; |
| 251 | if ((Y/D65Y) > CIEEpsilon) |
| 252 | y=pow(Y/D65Y,1.0/3.0); |
| 253 | else |
| 254 | y=(CIEK*Y/D65Y+16.0)/116.0; |
| 255 | if ((Z/D65Z) > CIEEpsilon) |
| 256 | z=pow(Z/D65Z,1.0/3.0); |
| 257 | else |
| 258 | z=(CIEK*Z/D65Z+16.0)/116.0; |
| 259 | *L=((116.0*y)-16.0)/100.0; |
| 260 | *a=(500.0*(x-y))/255.0+0.5; |
| 261 | *b=(200.0*(y-z))/255.0+0.5; |
| 262 | } |
| 263 | |
| 264 | static void ConvertRGBToLab(const double red,const double green, |
| 265 | const double blue,double *L,double *a,double *b) |
| 266 | { |
| 267 | double |
| 268 | X, |
| 269 | Y, |
| 270 | Z; |
| 271 | |
| 272 | ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z); |
| 273 | ConvertXYZToLab(X,Y,Z,L,a,b); |
| 274 | } |
| 275 | |
| 276 | static inline void ConvertLabToXYZ(const double L,const double a,const double b, |
| 277 | double *X,double *Y,double *Z) |
| 278 | { |
| 279 | double |
| 280 | x, |
| 281 | y, |
| 282 | z; |
| 283 | |
| 284 | y=(L+16.0)/116.0; |
| 285 | x=y+a/500.0; |
| 286 | z=y-b/200.0; |
| 287 | if ((x*x*x) > CIEEpsilon) |
| 288 | x=(x*x*x); |
| 289 | else |
| 290 | x=(116.0*x-16.0)/CIEK; |
| 291 | if ((y*y*y) > CIEEpsilon) |
| 292 | y=(y*y*y); |
| 293 | else |
| 294 | y=L/CIEK; |
| 295 | if ((z*z*z) > CIEEpsilon) |
| 296 | z=(z*z*z); |
| 297 | else |
| 298 | z=(116.0*z-16.0)/CIEK; |
| 299 | *X=D65X*x; |
| 300 | *Y=D65Y*y; |
| 301 | *Z=D65Z*z; |
| 302 | } |
| 303 | |
| 304 | static inline void ConvertXYZToRGB(const double x,const double y,const double z, |
| 305 | double *red,double *green,double *blue) |
| 306 | { |
| 307 | double |
| 308 | b, |
| 309 | g, |
| 310 | r; |
| 311 | |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 312 | r=3.2406*x-1.5372*y-0.4986*z; |
| 313 | g=(-0.9689*x+1.8758*y+0.0415*z); |
| 314 | b=0.0557*x-0.2040*y+1.0570*z; |
| 315 | *red=EncodePixelGamma(QuantumRange*r); |
| 316 | *green=EncodePixelGamma(QuantumRange*g); |
| 317 | *blue=EncodePixelGamma(QuantumRange*b); |
| 318 | } |
| 319 | |
| 320 | static inline void ConvertLabToRGB(const double L,const double a, |
| 321 | const double b,double *red,double *green,double *blue) |
| 322 | { |
| 323 | double |
| 324 | X, |
| 325 | Y, |
| 326 | Z; |
| 327 | |
| 328 | ConvertLabToXYZ(L*100.0,255.0*(a-0.5),255.0*(b-0.5),&X,&Y,&Z); |
| 329 | ConvertXYZToRGB(X,Y,Z,red,green,blue); |
| 330 | } |
| 331 | |
| 332 | static void ConvertRGBToYPbPr(const double red,const double green, |
| 333 | const double blue,double *Y,double *Pb,double *Pr) |
| 334 | { |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 335 | *Y=QuantumScale*(0.298839*red+0.586811*green+0.114350*blue); |
| 336 | *Pb=QuantumScale*((-0.1687367)*red-0.331264*green+0.5*blue)+0.5; |
| 337 | *Pr=QuantumScale*(0.5*red-0.418688*green-0.081312*blue)+0.5; |
| 338 | } |
| 339 | |
| 340 | static void ConvertRGBToYCbCr(const double red,const double green, |
| 341 | const double blue,double *Y,double *Cb,double *Cr) |
| 342 | { |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 343 | ConvertRGBToYPbPr(red,green,blue,Y,Cb,Cr); |
| 344 | } |
| 345 | |
| 346 | static void ConvertYPbPrToRGB(const double Y,const double Pb,const double Pr, |
| 347 | double *red,double *green,double *blue) |
| 348 | { |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 349 | *red=QuantumRange*(0.99999999999914679361*Y-1.2188941887145875e-06*(Pb-0.5)+ |
| 350 | 1.4019995886561440468*(Pr-0.5)); |
| 351 | *green=QuantumRange*(0.99999975910502514331*Y-0.34413567816504303521*(Pb-0.5)- |
| 352 | 0.71413649331646789076*(Pr-0.5)); |
| 353 | *blue=QuantumRange*(1.00000124040004623180*Y+1.77200006607230409200*(Pb-0.5)+ |
| 354 | 2.1453384174593273e-06*(Pr-0.5)); |
| 355 | } |
| 356 | |
| 357 | static void ConvertYCbCrToRGB(const double Y,const double Cb, |
| 358 | const double Cr,double *red,double *green,double *blue) |
| 359 | { |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 360 | ConvertYPbPrToRGB(Y,Cb,Cr,red,green,blue); |
| 361 | } |
| 362 | |
| 363 | static inline void ConvertLCHabToXYZ(const double luma,const double chroma, |
| 364 | const double hue,double *X,double *Y,double *Z) |
| 365 | { |
| 366 | ConvertLabToXYZ(luma,chroma*cos(hue*MagickPI/180.0),chroma* |
| 367 | sin(hue*MagickPI/180.0),X,Y,Z); |
| 368 | } |
| 369 | |
| 370 | static void ConvertLCHabToRGB(const double luma,const double chroma, |
| 371 | const double hue,double *red,double *green,double *blue) |
| 372 | { |
| 373 | double |
| 374 | X, |
| 375 | Y, |
| 376 | Z; |
| 377 | |
cristy | 6d897c7 | 2013-06-19 19:20:40 +0000 | [diff] [blame] | 378 | ConvertLCHabToXYZ(luma*100.0,255.0*(chroma-0.5),360.0*hue,&X,&Y,&Z); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 379 | ConvertXYZToRGB(X,Y,Z,red,green,blue); |
| 380 | } |
| 381 | |
| 382 | static void ConvertRGBToHSV(const double red,const double green, |
| 383 | const double blue,double *hue,double *saturation,double *value) |
| 384 | { |
| 385 | double |
| 386 | c, |
| 387 | max, |
| 388 | min; |
| 389 | |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 390 | max=MagickMax(QuantumScale*red,MagickMax(QuantumScale*green, |
| 391 | QuantumScale*blue)); |
| 392 | min=MagickMin(QuantumScale*red,MagickMin(QuantumScale*green, |
| 393 | QuantumScale*blue)); |
| 394 | c=max-min; |
| 395 | *value=max; |
| 396 | if (c <= 0.0) |
| 397 | { |
| 398 | *hue=0.0; |
| 399 | *saturation=0.0; |
| 400 | return; |
| 401 | } |
| 402 | if (max == (QuantumScale*red)) |
| 403 | { |
| 404 | *hue=(QuantumScale*green-QuantumScale*blue)/c; |
| 405 | if ((QuantumScale*green) < (QuantumScale*blue)) |
| 406 | *hue+=6.0; |
| 407 | } |
| 408 | else |
| 409 | if (max == (QuantumScale*green)) |
| 410 | *hue=2.0+(QuantumScale*blue-QuantumScale*red)/c; |
| 411 | else |
| 412 | *hue=4.0+(QuantumScale*red-QuantumScale*green)/c; |
| 413 | *hue*=60.0/360.0; |
| 414 | *saturation=c/max; |
| 415 | } |
| 416 | |
| 417 | static inline void ConvertXYZToLCHab(const double X,const double Y, |
| 418 | const double Z,double *luma,double *chroma,double *hue) |
| 419 | { |
| 420 | double |
| 421 | a, |
| 422 | b; |
| 423 | |
| 424 | ConvertXYZToLab(X,Y,Z,luma,&a,&b); |
cristy | 846740b | 2013-06-19 18:19:55 +0000 | [diff] [blame] | 425 | *chroma=hypot(255.0*(a-0.5),255.0*(b-0.5))/255.0+0.5; |
cristy | 6d897c7 | 2013-06-19 19:20:40 +0000 | [diff] [blame] | 426 | *hue=180.0*atan2(255.0*(b-0.5),255.0*(a-0.5))/MagickPI/360.0; |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 427 | if (*hue < 0.0) |
| 428 | *hue+=1.0; |
| 429 | } |
| 430 | |
| 431 | static void ConvertRGBToLCHab(const double red,const double green, |
| 432 | const double blue,double *luma,double *chroma,double *hue) |
| 433 | { |
| 434 | double |
| 435 | X, |
| 436 | Y, |
| 437 | Z; |
| 438 | |
| 439 | ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z); |
| 440 | ConvertXYZToLCHab(X,Y,Z,luma,chroma,hue); |
| 441 | } |
| 442 | |
| 443 | static inline void ConvertLMSToXYZ(const double L,const double M,const double S, |
| 444 | double *X,double *Y,double *Z) |
| 445 | { |
| 446 | *X=1.096123820835514*L-0.278869000218287*M+0.182745179382773*S; |
| 447 | *Y=0.454369041975359*L+0.473533154307412*M+0.072097803717229*S; |
| 448 | *Z=(-0.009627608738429)*L-0.005698031216113*M+1.015325639954543*S; |
| 449 | } |
| 450 | |
| 451 | static inline void ConvertLMSToRGB(const double L,const double M, |
| 452 | const double S,double *red,double *green,double *blue) |
| 453 | { |
| 454 | double |
| 455 | X, |
| 456 | Y, |
| 457 | Z; |
| 458 | |
| 459 | ConvertLMSToXYZ(L,M,S,&X,&Y,&Z); |
| 460 | ConvertXYZToRGB(X,Y,Z,red,green,blue); |
| 461 | } |
| 462 | |
| 463 | static inline void ConvertXYZToLMS(const double x,const double y, |
| 464 | const double z,double *L,double *M,double *S) |
| 465 | { |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 466 | *L=0.7328*x+0.4296*y-0.1624*z; |
| 467 | *M=(-0.7036*x+1.6975*y+0.0061*z); |
| 468 | *S=0.0030*x+0.0136*y+0.9834*z; |
| 469 | } |
| 470 | |
| 471 | static void ConvertRGBToLMS(const double red,const double green, |
| 472 | const double blue,double *L,double *M,double *S) |
| 473 | { |
| 474 | double |
| 475 | X, |
| 476 | Y, |
| 477 | Z; |
| 478 | |
| 479 | ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z); |
| 480 | ConvertXYZToLMS(X,Y,Z,L,M,S); |
| 481 | } |
| 482 | |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 483 | static inline void ConvertXYZToLuv(const double X,const double Y,const double Z, |
| 484 | double *L,double *u,double *v) |
| 485 | { |
| 486 | double |
| 487 | alpha; |
| 488 | |
| 489 | if ((Y/D65Y) > CIEEpsilon) |
| 490 | *L=(double) (116.0*pow(Y/D65Y,1.0/3.0)-16.0); |
| 491 | else |
| 492 | *L=CIEK*(Y/D65Y); |
| 493 | alpha=PerceptibleReciprocal(X+15.0*Y+3.0*Z); |
| 494 | *u=13.0*(*L)*((4.0*alpha*X)-(4.0*D65X/(D65X+15.0*D65Y+3.0*D65Z))); |
| 495 | *v=13.0*(*L)*((9.0*alpha*Y)-(9.0*D65Y/(D65X+15.0*D65Y+3.0*D65Z))); |
| 496 | *L/=100.0; |
| 497 | *u=(*u+134.0)/354.0; |
| 498 | *v=(*v+140.0)/262.0; |
| 499 | } |
| 500 | |
| 501 | static void ConvertRGBToLuv(const double red,const double green, |
| 502 | const double blue,double *L,double *u,double *v) |
| 503 | { |
| 504 | double |
| 505 | X, |
| 506 | Y, |
| 507 | Z; |
| 508 | |
| 509 | ConvertRGBToXYZ(red,green,blue,&X,&Y,&Z); |
| 510 | ConvertXYZToLuv(X,Y,Z,L,u,v); |
| 511 | } |
| 512 | |
| 513 | static inline void ConvertLuvToXYZ(const double L,const double u,const double v, |
| 514 | double *X,double *Y,double *Z) |
| 515 | { |
| 516 | if (L > (CIEK*CIEEpsilon)) |
| 517 | *Y=(double) pow((L+16.0)/116.0,3.0); |
| 518 | else |
| 519 | *Y=L/CIEK; |
| 520 | *X=((*Y*((39.0*L/(v+13.0*L*(9.0*D65Y/(D65X+15.0*D65Y+3.0*D65Z))))-5.0))+ |
| 521 | 5.0*(*Y))/((((52.0f*L/(u+13.0*L*(4.0*D65X/(D65X+15.0*D65Y+3.0*D65Z))))-1.0)/ |
| 522 | 3.0)-(-1.0/3.0)); |
| 523 | *Z=(*X*(((52.0f*L/(u+13.0*L*(4.0*D65X/(D65X+15.0*D65Y+3.0*D65Z))))-1.0)/3.0))- |
| 524 | 5.0*(*Y); |
| 525 | } |
| 526 | |
| 527 | static inline void ConvertLuvToRGB(const double L,const double u, |
| 528 | const double v,double *red,double *green,double *blue) |
| 529 | { |
| 530 | double |
| 531 | X, |
| 532 | Y, |
| 533 | Z; |
| 534 | |
| 535 | ConvertLuvToXYZ(100.0*L,354.0*u-134.0,262.0*v-140.0,&X,&Y,&Z); |
| 536 | ConvertXYZToRGB(X,Y,Z,red,green,blue); |
| 537 | } |
| 538 | |
| 539 | static void ConvertRGBToYDbDr(const double red,const double green, |
| 540 | const double blue,double *Y,double *Db,double *Dr) |
| 541 | { |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 542 | *Y=QuantumScale*(0.298839*red+0.586811*green+0.114350*blue); |
| 543 | *Db=QuantumScale*(-0.450*red-0.883*green+1.333*blue)+0.5; |
| 544 | *Dr=QuantumScale*(-1.333*red+1.116*green+0.217*blue)+0.5; |
| 545 | } |
| 546 | |
| 547 | static void ConvertYDbDrToRGB(const double Y,const double Db,const double Dr, |
| 548 | double *red,double *green,double *blue) |
| 549 | { |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 550 | *red=QuantumRange*(Y+9.2303716147657e-05*(Db-0.5)-0.52591263066186533* |
| 551 | (Dr-0.5)); |
| 552 | *green=QuantumRange*(Y-0.12913289889050927*(Db-0.5)+0.26789932820759876* |
| 553 | (Dr-0.5)); |
| 554 | *blue=QuantumRange*(Y+0.66467905997895482*(Db-0.5)-7.9202543533108e-05* |
| 555 | (Dr-0.5)); |
| 556 | } |
| 557 | |
| 558 | static void ConvertRGBToYIQ(const double red,const double green, |
| 559 | const double blue,double *Y,double *I,double *Q) |
| 560 | { |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 561 | *Y=QuantumScale*(0.298839*red+0.586811*green+0.114350*blue); |
| 562 | *I=QuantumScale*(0.595716*red-0.274453*green-0.321263*blue)+0.5; |
| 563 | *Q=QuantumScale*(0.211456*red-0.522591*green+0.311135*blue)+0.5; |
| 564 | } |
| 565 | |
| 566 | static void ConvertYIQToRGB(const double Y,const double I,const double Q, |
| 567 | double *red,double *green,double *blue) |
| 568 | { |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 569 | *red=QuantumRange*(Y+0.9562957197589482261*(I-0.5)+0.6210244164652610754* |
| 570 | (Q-0.5)); |
| 571 | *green=QuantumRange*(Y-0.2721220993185104464*(I-0.5)-0.6473805968256950427* |
| 572 | (Q-0.5)); |
| 573 | *blue=QuantumRange*(Y-1.1069890167364901945*(I-0.5)+1.7046149983646481374* |
| 574 | (Q-0.5)); |
| 575 | } |
| 576 | |
| 577 | static void ConvertRGBToYUV(const double red,const double green, |
| 578 | const double blue,double *Y,double *U,double *V) |
| 579 | { |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 580 | *Y=QuantumScale*(0.298839*red+0.586811*green+0.114350*blue); |
| 581 | *U=QuantumScale*((-0.147)*red-0.289*green+0.436*blue)+0.5; |
| 582 | *V=QuantumScale*(0.615*red-0.515*green-0.100*blue)+0.5; |
| 583 | } |
| 584 | |
| 585 | static void ConvertYUVToRGB(const double Y,const double U,const double V, |
| 586 | double *red,double *green,double *blue) |
| 587 | { |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 588 | *red=QuantumRange*(Y-3.945707070708279e-05*(U-0.5)+1.1398279671717170825* |
| 589 | (V-0.5)); |
| 590 | *green=QuantumRange*(Y-0.3946101641414141437*(U-0.5)-0.5805003156565656797* |
| 591 | (V-0.5)); |
| 592 | *blue=QuantumRange*(Y+2.0319996843434342537*(U-0.5)-4.813762626262513e-04* |
| 593 | (V-0.5)); |
| 594 | } |
| 595 | |
| 596 | static MagickBooleanType ValidateHSIToRGB() |
| 597 | { |
| 598 | double |
| 599 | r, |
| 600 | g, |
| 601 | b; |
| 602 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 603 | (void) FormatLocaleFile(stdout," HSIToRGB"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 604 | ConvertHSIToRGB(111.244375/360.0,0.295985,0.658734,&r,&g,&b); |
| 605 | if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) || |
| 606 | (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) || |
| 607 | (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon)) |
| 608 | return(MagickFalse); |
| 609 | return(MagickTrue); |
| 610 | } |
| 611 | |
| 612 | static MagickBooleanType ValidateRGBToHSI() |
| 613 | { |
| 614 | double |
| 615 | h, |
| 616 | i, |
| 617 | s; |
| 618 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 619 | (void) FormatLocaleFile(stdout," RGBToHSI"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 620 | ConvertRGBToHSI(0.545877*QuantumRange,0.966567*QuantumRange, |
| 621 | 0.463759*QuantumRange,&h,&s,&i); |
| 622 | if ((fabs(h-111.244374/360.0) >= ReferenceEpsilon) || |
| 623 | (fabs(s-0.295985) >= ReferenceEpsilon) || |
| 624 | (fabs(i-0.658734) >= ReferenceEpsilon)) |
| 625 | return(MagickFalse); |
| 626 | return(MagickTrue); |
| 627 | } |
| 628 | |
| 629 | static MagickBooleanType ValidateHSLToRGB() |
| 630 | { |
| 631 | double |
| 632 | r, |
| 633 | g, |
| 634 | b; |
| 635 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 636 | (void) FormatLocaleFile(stdout," HSLToRGB"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 637 | ConvertHSLToRGB(110.200859/360.0,0.882623,0.715163,&r,&g,&b); |
| 638 | if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) || |
| 639 | (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) || |
| 640 | (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon)) |
| 641 | return(MagickFalse); |
| 642 | return(MagickTrue); |
| 643 | } |
| 644 | |
| 645 | static MagickBooleanType ValidateRGBToHSL() |
| 646 | { |
| 647 | double |
| 648 | h, |
| 649 | l, |
| 650 | s; |
| 651 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 652 | (void) FormatLocaleFile(stdout," RGBToHSL"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 653 | ConvertRGBToHSL(0.545877*QuantumRange,0.966567*QuantumRange, |
| 654 | 0.463759*QuantumRange,&h,&s,&l); |
| 655 | if ((fabs(h-110.200859/360.0) >= ReferenceEpsilon) || |
| 656 | (fabs(s-0.882623) >= ReferenceEpsilon) || |
| 657 | (fabs(l-0.715163) >= ReferenceEpsilon)) |
| 658 | return(MagickFalse); |
| 659 | return(MagickTrue); |
| 660 | } |
| 661 | |
| 662 | static MagickBooleanType ValidateHSVToRGB() |
| 663 | { |
| 664 | double |
| 665 | r, |
| 666 | g, |
| 667 | b; |
| 668 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 669 | (void) FormatLocaleFile(stdout," HSVToRGB"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 670 | ConvertHSVToRGB(110.200859/360.0,0.520200,0.966567,&r,&g,&b); |
| 671 | if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) || |
| 672 | (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) || |
| 673 | (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon)) |
| 674 | return(MagickFalse); |
| 675 | return(MagickTrue); |
| 676 | } |
| 677 | |
| 678 | static MagickBooleanType ValidateRGBToHSV() |
| 679 | { |
| 680 | double |
| 681 | h, |
| 682 | s, |
| 683 | v; |
| 684 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 685 | (void) FormatLocaleFile(stdout," RGBToHSV"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 686 | ConvertRGBToHSV(0.545877*QuantumRange,0.966567*QuantumRange, |
| 687 | 0.463759*QuantumRange,&h,&s,&v); |
| 688 | if ((fabs(h-110.200859/360.0) >= ReferenceEpsilon) || |
| 689 | (fabs(s-0.520200) >= ReferenceEpsilon) || |
| 690 | (fabs(v-0.966567) >= ReferenceEpsilon)) |
| 691 | return(MagickFalse); |
| 692 | return(MagickTrue); |
| 693 | } |
| 694 | |
| 695 | static MagickBooleanType ValidateRGBToJPEGYCbCr() |
| 696 | { |
| 697 | double |
| 698 | Cb, |
| 699 | Cr, |
| 700 | Y; |
| 701 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 702 | (void) FormatLocaleFile(stdout," RGBToJPEGYCbCr"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 703 | ConvertRGBToYCbCr(0.545877*QuantumRange,0.966567*QuantumRange, |
| 704 | 0.463759*QuantumRange,&Y,&Cb,&Cr); |
| 705 | if ((fabs(Y-0.783460) >= ReferenceEpsilon) || |
| 706 | (fabs(Cb-0.319581) >= ReferenceEpsilon) || |
| 707 | (fabs(Cr-0.330539) >= ReferenceEpsilon)) |
| 708 | return(MagickFalse); |
| 709 | return(MagickTrue); |
| 710 | } |
| 711 | |
| 712 | static MagickBooleanType ValidateJPEGYCbCrToRGB() |
| 713 | { |
| 714 | double |
| 715 | r, |
| 716 | g, |
| 717 | b; |
| 718 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 719 | (void) FormatLocaleFile(stdout," JPEGYCbCrToRGB"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 720 | ConvertYCbCrToRGB(0.783460,0.319581,0.330539,&r,&g,&b); |
| 721 | if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) || |
| 722 | (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) || |
| 723 | (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon)) |
| 724 | return(MagickFalse); |
| 725 | return(MagickTrue); |
| 726 | } |
| 727 | |
| 728 | static MagickBooleanType ValidateLabToRGB() |
| 729 | { |
| 730 | double |
| 731 | r, |
| 732 | g, |
| 733 | b; |
| 734 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 735 | (void) FormatLocaleFile(stdout," LabToRGB"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 736 | ConvertLabToRGB(88.456154/100.0,-54.671483/255+0.5,51.662818/255.0+0.5, |
| 737 | &r,&g,&b); |
| 738 | if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) || |
| 739 | (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) || |
| 740 | (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon)) |
| 741 | return(MagickFalse); |
| 742 | return(MagickTrue); |
| 743 | } |
| 744 | |
| 745 | static MagickBooleanType ValidateRGBToLab() |
| 746 | { |
| 747 | double |
| 748 | a, |
| 749 | b, |
| 750 | L; |
| 751 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 752 | (void) FormatLocaleFile(stdout," RGBToLab"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 753 | ConvertRGBToLab(0.545877*QuantumRange,0.966567*QuantumRange, |
| 754 | 0.463759*QuantumRange,&L,&a,&b); |
| 755 | if ((fabs(L-(88.456154/100.0)) >= ReferenceEpsilon) || |
| 756 | (fabs(a-(-54.671483/255.0+0.5)) >= ReferenceEpsilon) || |
| 757 | (fabs(b-(51.662818/255.0+0.5)) >= ReferenceEpsilon)) |
| 758 | return(MagickFalse); |
| 759 | return(MagickTrue); |
| 760 | } |
| 761 | |
| 762 | static MagickBooleanType ValidateLchToRGB() |
| 763 | { |
| 764 | double |
| 765 | b, |
| 766 | g, |
| 767 | r; |
| 768 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 769 | (void) FormatLocaleFile(stdout," LchToRGB"); |
cristy | a44ed13 | 2013-06-19 23:56:32 +0000 | [diff] [blame] | 770 | ConvertLCHabToRGB(88.456154/100.0,75.219797/255.0+0.5,136.620717/360.0, |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 771 | &r,&g,&b); |
| 772 | if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) || |
| 773 | (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) || |
| 774 | (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon)) |
| 775 | return(MagickFalse); |
| 776 | return(MagickTrue); |
| 777 | } |
| 778 | |
| 779 | static MagickBooleanType ValidateRGBToLch() |
| 780 | { |
| 781 | double |
| 782 | c, |
| 783 | h, |
| 784 | L; |
| 785 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 786 | (void) FormatLocaleFile(stdout," RGBToLch"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 787 | ConvertRGBToLCHab(0.545877*QuantumRange,0.966567*QuantumRange, |
| 788 | 0.463759*QuantumRange,&L,&c,&h); |
| 789 | if ((fabs(L-88.456154/100.0) >= ReferenceEpsilon) || |
| 790 | (fabs(c-(75.219797/255.0+0.5)) >= ReferenceEpsilon) || |
| 791 | (fabs(h-(136.620717/255.0+0.5)) >= ReferenceEpsilon)) |
| 792 | return(MagickFalse); |
| 793 | return(MagickTrue); |
| 794 | } |
| 795 | |
| 796 | static MagickBooleanType ValidateRGBToLMS() |
| 797 | { |
| 798 | double |
| 799 | L, |
| 800 | M, |
| 801 | S; |
| 802 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 803 | (void) FormatLocaleFile(stdout," RGBToLMS"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 804 | ConvertRGBToLMS(0.545877*QuantumRange,0.966567*QuantumRange, |
| 805 | 0.463759*QuantumRange,&L,&M,&S); |
| 806 | if ((fabs(L-0.611749) >= ReferenceEpsilon) || |
| 807 | (fabs(M-0.910088) >= ReferenceEpsilon) || |
| 808 | (fabs(S-0.294880) >= ReferenceEpsilon)) |
| 809 | return(MagickFalse); |
| 810 | return(MagickTrue); |
| 811 | } |
| 812 | |
| 813 | static MagickBooleanType ValidateLMSToRGB() |
| 814 | { |
| 815 | double |
| 816 | r, |
| 817 | g, |
| 818 | b; |
| 819 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 820 | (void) FormatLocaleFile(stdout," LMSToRGB"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 821 | ConvertLMSToRGB(0.611749,0.910088,0.294880,&r,&g,&b); |
| 822 | if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) || |
| 823 | (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) || |
| 824 | (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon)) |
| 825 | return(MagickFalse); |
| 826 | return(MagickTrue); |
| 827 | } |
| 828 | |
| 829 | static MagickBooleanType ValidateRGBToLuv() |
| 830 | { |
| 831 | double |
| 832 | l, |
| 833 | u, |
| 834 | v; |
| 835 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 836 | (void) FormatLocaleFile(stdout," RGBToLuv"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 837 | ConvertRGBToLuv(0.545877*QuantumRange,0.966567*QuantumRange, |
| 838 | 0.463759*QuantumRange,&l,&u,&v); |
| 839 | if ((fabs(l-88.456154/262.0) >= ReferenceEpsilon) || |
| 840 | (fabs(u-(-51.330414+134.0)/354.0) >= ReferenceEpsilon) || |
| 841 | (fabs(v-(76.405526+140.0)/262.0) >= ReferenceEpsilon)) |
| 842 | return(MagickFalse); |
| 843 | return(MagickTrue); |
| 844 | } |
| 845 | |
| 846 | static MagickBooleanType ValidateLuvToRGB() |
| 847 | { |
| 848 | double |
| 849 | r, |
| 850 | g, |
| 851 | b; |
| 852 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 853 | (void) FormatLocaleFile(stdout," LuvToRGB"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 854 | ConvertLuvToRGB(88.456154/100.0,(-51.330414+134.0)/354.0, |
| 855 | (76.405526+140.0)/262.0,&r,&g,&b); |
| 856 | if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) || |
| 857 | (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) || |
| 858 | (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon)) |
| 859 | return(MagickFalse); |
| 860 | return(MagickTrue); |
| 861 | } |
| 862 | |
| 863 | static MagickBooleanType ValidateRGBToXYZ() |
| 864 | { |
| 865 | double |
| 866 | x, |
| 867 | y, |
| 868 | z; |
| 869 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 870 | (void) FormatLocaleFile(stdout," RGBToXYZ"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 871 | ConvertRGBToXYZ(0.545877*QuantumRange,0.966567*QuantumRange, |
| 872 | 0.463759*QuantumRange,&x,&y,&z); |
| 873 | if ((fabs(x-0.470646) >= ReferenceEpsilon) || |
| 874 | (fabs(y-0.730178) >= ReferenceEpsilon) || |
| 875 | (fabs(z-0.288324) >= ReferenceEpsilon)) |
| 876 | return(MagickFalse); |
| 877 | return(MagickTrue); |
| 878 | } |
| 879 | |
| 880 | static MagickBooleanType ValidateXYZToRGB() |
| 881 | { |
| 882 | double |
| 883 | r, |
| 884 | g, |
| 885 | b; |
| 886 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 887 | (void) FormatLocaleFile(stdout," XYZToRGB"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 888 | ConvertXYZToRGB(0.470646,0.730178,0.288324,&r,&g,&b); |
| 889 | if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) || |
| 890 | (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) || |
| 891 | (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon)) |
| 892 | return(MagickFalse); |
| 893 | return(MagickTrue); |
| 894 | } |
| 895 | |
| 896 | static MagickBooleanType ValidateYDbDrToRGB() |
| 897 | { |
| 898 | double |
| 899 | r, |
| 900 | g, |
| 901 | b; |
| 902 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 903 | (void) FormatLocaleFile(stdout," YDbDrToRGB"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 904 | ConvertYDbDrToRGB(0.783460,-0.480932+0.5,0.451670+0.5,&r,&g,&b); |
| 905 | if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) || |
| 906 | (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) || |
| 907 | (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon)) |
| 908 | return(MagickFalse); |
| 909 | return(MagickTrue); |
| 910 | } |
| 911 | |
| 912 | static MagickBooleanType ValidateRGBToYDbDr() |
| 913 | { |
| 914 | double |
| 915 | Db, |
| 916 | Dr, |
| 917 | Y; |
| 918 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 919 | (void) FormatLocaleFile(stdout," RGBToYDbDr"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 920 | ConvertRGBToYDbDr(0.545877*QuantumRange,0.966567*QuantumRange, |
| 921 | 0.463759*QuantumRange,&Y,&Db,&Dr); |
| 922 | if ((fabs(Y-0.783460) >= ReferenceEpsilon) || |
| 923 | (fabs(Db-(-0.480932)) >= ReferenceEpsilon) || |
| 924 | (fabs(Dr-0.451670) >= ReferenceEpsilon)) |
| 925 | return(MagickFalse); |
| 926 | return(MagickTrue); |
| 927 | } |
| 928 | |
| 929 | static MagickBooleanType ValidateRGBToYIQ() |
| 930 | { |
| 931 | double |
| 932 | i, |
| 933 | q, |
| 934 | y; |
| 935 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 936 | (void) FormatLocaleFile(stdout," RGBToYIQ"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 937 | ConvertRGBToYIQ(0.545877*QuantumRange,0.966567*QuantumRange, |
| 938 | 0.463759*QuantumRange,&y,&i,&q); |
| 939 | if ((fabs(y-0.783460) >= ReferenceEpsilon) || |
| 940 | (fabs(i-(-0.089078)) >= ReferenceEpsilon) || |
| 941 | (fabs(q-(-0.245399)) >= ReferenceEpsilon)) |
| 942 | return(MagickFalse); |
| 943 | return(MagickTrue); |
| 944 | } |
| 945 | |
| 946 | static MagickBooleanType ValidateYIQToRGB() |
| 947 | { |
| 948 | double |
| 949 | r, |
| 950 | g, |
| 951 | b; |
| 952 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 953 | (void) FormatLocaleFile(stdout," YIQToRGB"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 954 | ConvertYIQToRGB(0.783460,-0.089078+0.5,-0.245399+0.5,&r,&g,&b); |
| 955 | if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) || |
| 956 | (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) || |
| 957 | (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon)) |
| 958 | return(MagickFalse); |
| 959 | return(MagickTrue); |
| 960 | } |
| 961 | |
| 962 | static MagickBooleanType ValidateRGBToYPbPr() |
| 963 | { |
| 964 | double |
cristy | 4ae2e76 | 2013-05-07 13:19:24 +0000 | [diff] [blame] | 965 | Pb, |
| 966 | Pr, |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 967 | y; |
| 968 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 969 | (void) FormatLocaleFile(stdout," RGBToYPbPr"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 970 | ConvertRGBToYPbPr(0.545877*QuantumRange,0.966567*QuantumRange, |
cristy | 4ae2e76 | 2013-05-07 13:19:24 +0000 | [diff] [blame] | 971 | 0.463759*QuantumRange,&y,&Pb,&Pr); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 972 | if ((fabs(y-0.783460) >= ReferenceEpsilon) || |
cristy | 4ae2e76 | 2013-05-07 13:19:24 +0000 | [diff] [blame] | 973 | (fabs(Pb-(-0.180419)) >= ReferenceEpsilon) || |
| 974 | (fabs(Pr-(-0.169461)) >= ReferenceEpsilon)) |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 975 | return(MagickFalse); |
| 976 | return(MagickTrue); |
| 977 | } |
| 978 | |
| 979 | static MagickBooleanType ValidateYPbPrToRGB() |
| 980 | { |
| 981 | double |
| 982 | r, |
| 983 | g, |
| 984 | b; |
| 985 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 986 | (void) FormatLocaleFile(stdout," YPbPrToRGB"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 987 | ConvertYPbPrToRGB(0.783460,-0.180419+0.5,-0.169461+0.5,&r,&g,&b); |
| 988 | if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) || |
| 989 | (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) || |
| 990 | (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon)) |
| 991 | return(MagickFalse); |
| 992 | return(MagickTrue); |
| 993 | } |
| 994 | |
| 995 | static MagickBooleanType ValidateRGBToYUV() |
| 996 | { |
| 997 | double |
| 998 | U, |
| 999 | V, |
| 1000 | Y; |
| 1001 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 1002 | (void) FormatLocaleFile(stdout," RGBToYUV"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 1003 | ConvertRGBToYUV(0.545877*QuantumRange,0.966567*QuantumRange, |
| 1004 | 0.463759*QuantumRange,&Y,&U,&V); |
| 1005 | if ((fabs(Y-0.783460) >= ReferenceEpsilon) || |
| 1006 | (fabs(U-(-0.157383)) >= ReferenceEpsilon) || |
| 1007 | (fabs(V-(-0.208443)) >= ReferenceEpsilon)) |
| 1008 | return(MagickFalse); |
| 1009 | return(MagickTrue); |
| 1010 | } |
| 1011 | |
| 1012 | static MagickBooleanType ValidateYUVToRGB() |
| 1013 | { |
| 1014 | double |
| 1015 | r, |
| 1016 | g, |
| 1017 | b; |
| 1018 | |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 1019 | (void) FormatLocaleFile(stdout," YUVToRGB"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 1020 | ConvertYUVToRGB(0.783460,-0.157383+0.5,-0.208443+0.5,&r,&g,&b); |
| 1021 | if ((fabs(r-0.545877*QuantumRange) >= ReferenceEpsilon) || |
| 1022 | (fabs(g-0.966567*QuantumRange) >= ReferenceEpsilon) || |
| 1023 | (fabs(b-0.463759*QuantumRange) >= ReferenceEpsilon)) |
| 1024 | return(MagickFalse); |
| 1025 | return(MagickTrue); |
| 1026 | } |
| 1027 | |
cristy | 572e097 | 2013-05-07 12:51:28 +0000 | [diff] [blame] | 1028 | static size_t ValidateColorspaces(ImageInfo *image_info,size_t *fail, |
cristy | 80e870e | 2013-05-07 12:23:02 +0000 | [diff] [blame] | 1029 | ExceptionInfo *exception) |
| 1030 | { |
| 1031 | MagickBooleanType |
| 1032 | status; |
| 1033 | |
cristy | 80e870e | 2013-05-07 12:23:02 +0000 | [diff] [blame] | 1034 | size_t |
| 1035 | test; |
| 1036 | |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 1037 | /* |
cristy | 92e5cea | 2013-05-08 12:24:12 +0000 | [diff] [blame] | 1038 | Reference: https://code.google.com/p/chroma. |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 1039 | |
| 1040 | Illuminant = D65 |
| 1041 | Observer = 2° (1931) |
| 1042 | |
| 1043 | XYZ 0.470645, 0.730177, 0.288323 |
| 1044 | sRGB 0.545877, 0.966567, 0.463759 |
| 1045 | CAT02 LMS 0.611749, 0.910088, 0.294880 |
| 1046 | Y'DbDr 0.783460, -0.480932, 0.451670 |
| 1047 | Y'IQ 0.783460, -0.089078, -0.245399 |
| 1048 | Y'PbPr 0.783460, -0.180419, -0.169461 |
| 1049 | Y'UV 0.783460, -0.157383, -0.208443 |
| 1050 | JPEG-Y'CbCr 0.783460, 0.319581, 0.330539 |
| 1051 | L*u*v* 88.456154, -51.330414, 76.405526 |
| 1052 | L*a*b* 88.456154, -54.671483, 51.662818 |
| 1053 | L*C*H* 88.456154, 75.219797, 136.620717 |
| 1054 | HSV 110.200859, 0.520200, 0.966567 |
| 1055 | HSL 110.200859, 0.882623, 0.715163 |
| 1056 | HSI 111.244375, 0.295985, 0.658734 |
| 1057 | Y'CbCr 187.577791, 87.586330, 90.040886 |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 1058 | */ |
cristy | 80e870e | 2013-05-07 12:23:02 +0000 | [diff] [blame] | 1059 | (void) FormatLocaleFile(stdout,"validate colorspaces:\n"); |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 1060 | for (test=0; test < 26; test++) |
| 1061 | { |
| 1062 | CatchException(exception); |
| 1063 | (void) FormatLocaleFile(stdout," test %.20g: ",(double) test); |
| 1064 | switch (test) |
cristy | 80e870e | 2013-05-07 12:23:02 +0000 | [diff] [blame] | 1065 | { |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 1066 | case 0: status=ValidateHSIToRGB(); break; |
| 1067 | case 1: status=ValidateRGBToHSI(); break; |
| 1068 | case 2: status=ValidateHSLToRGB(); break; |
| 1069 | case 3: status=ValidateRGBToHSL(); break; |
| 1070 | case 4: status=ValidateHSVToRGB(); break; |
| 1071 | case 5: status=ValidateRGBToHSV(); break; |
| 1072 | case 6: status=ValidateJPEGYCbCrToRGB(); break; |
| 1073 | case 7: status=ValidateRGBToJPEGYCbCr(); break; |
| 1074 | case 8: status=ValidateLabToRGB(); break; |
| 1075 | case 9: status=ValidateRGBToLab(); break; |
| 1076 | case 10: status=ValidateLchToRGB(); break; |
| 1077 | case 11: status=ValidateRGBToLch(); break; |
| 1078 | case 12: status=ValidateLMSToRGB(); break; |
| 1079 | case 13: status=ValidateRGBToLMS(); break; |
| 1080 | case 14: status=ValidateLuvToRGB(); break; |
| 1081 | case 15: status=ValidateRGBToLuv(); break; |
| 1082 | case 16: status=ValidateXYZToRGB(); break; |
| 1083 | case 17: status=ValidateRGBToXYZ(); break; |
| 1084 | case 18: status=ValidateYDbDrToRGB(); break; |
| 1085 | case 19: status=ValidateRGBToYDbDr(); break; |
| 1086 | case 20: status=ValidateYIQToRGB(); break; |
| 1087 | case 21: status=ValidateRGBToYIQ(); break; |
| 1088 | case 22: status=ValidateYPbPrToRGB(); break; |
| 1089 | case 23: status=ValidateRGBToYPbPr(); break; |
| 1090 | case 24: status=ValidateYUVToRGB(); break; |
| 1091 | case 25: status=ValidateRGBToYUV(); break; |
| 1092 | default: status=MagickFalse; |
cristy | 80e870e | 2013-05-07 12:23:02 +0000 | [diff] [blame] | 1093 | } |
cristy | b8588ab | 2013-05-07 13:17:38 +0000 | [diff] [blame] | 1094 | if (status == MagickFalse) |
cristy | 8d24e06 | 2013-05-07 12:48:19 +0000 | [diff] [blame] | 1095 | { |
| 1096 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1097 | GetMagickModule()); |
| 1098 | (*fail)++; |
| 1099 | continue; |
| 1100 | } |
| 1101 | (void) FormatLocaleFile(stdout,"... pass.\n"); |
| 1102 | } |
cristy | 80e870e | 2013-05-07 12:23:02 +0000 | [diff] [blame] | 1103 | (void) FormatLocaleFile(stdout, |
| 1104 | " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 1105 | (double) (test-(*fail)),(double) *fail); |
| 1106 | return(test); |
| 1107 | } |
| 1108 | |
| 1109 | /* |
| 1110 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1111 | % % |
| 1112 | % % |
| 1113 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1114 | % V a l i d a t e C o m p a r e C o m m a n d % |
| 1115 | % % |
| 1116 | % % |
| 1117 | % % |
| 1118 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1119 | % |
| 1120 | % ValidateCompareCommand() validates the ImageMagick compare command line |
| 1121 | % program and returns the number of validation tests that passed and failed. |
| 1122 | % |
| 1123 | % The format of the ValidateCompareCommand method is: |
| 1124 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1125 | % size_t ValidateCompareCommand(ImageInfo *image_info, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1126 | % const char *reference_filename,const char *output_filename, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1127 | % size_t *fail,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1128 | % |
| 1129 | % A description of each parameter follows: |
| 1130 | % |
| 1131 | % o image_info: the image info. |
| 1132 | % |
| 1133 | % o reference_filename: the reference image filename. |
| 1134 | % |
| 1135 | % o output_filename: the output image filename. |
| 1136 | % |
| 1137 | % o fail: return the number of validation tests that pass. |
| 1138 | % |
| 1139 | % o exception: return any errors or warnings in this structure. |
| 1140 | % |
| 1141 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1142 | static size_t ValidateCompareCommand(ImageInfo *image_info, |
cristy | 0d772ed | 2012-11-10 14:34:50 +0000 | [diff] [blame] | 1143 | const char *reference_filename,const char *output_filename,size_t *fail, |
| 1144 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1145 | { |
| 1146 | char |
| 1147 | **arguments, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1148 | command[MagickPathExtent]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1149 | |
| 1150 | int |
| 1151 | number_arguments; |
| 1152 | |
| 1153 | MagickBooleanType |
| 1154 | status; |
| 1155 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1156 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1157 | i, |
| 1158 | j; |
| 1159 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1160 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1161 | test; |
| 1162 | |
| 1163 | test=0; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1164 | (void) FormatLocaleFile(stdout,"validate compare command line program:\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1165 | for (i=0; compare_options[i] != (char *) NULL; i++) |
| 1166 | { |
| 1167 | CatchException(exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1168 | (void) FormatLocaleFile(stdout," test %.20g: %s",(double) (test++), |
cristy | 6aa47ad | 2010-05-28 19:32:32 +0000 | [diff] [blame] | 1169 | compare_options[i]); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1170 | (void) FormatLocaleString(command,MagickPathExtent,"%s %s %s %s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1171 | compare_options[i],reference_filename,reference_filename,output_filename); |
| 1172 | arguments=StringToArgv(command,&number_arguments); |
| 1173 | if (arguments == (char **) NULL) |
| 1174 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1175 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1176 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1177 | (void) LogMagickEvent(ExceptionEvent,GetMagickModule(),"%s", |
| 1178 | exception->reason); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1179 | (*fail)++; |
| 1180 | continue; |
| 1181 | } |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 1182 | status=CompareImagesCommand(image_info,number_arguments,arguments, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1183 | (char **) NULL,exception); |
cristy | e42f658 | 2012-02-11 17:59:50 +0000 | [diff] [blame] | 1184 | for (j=0; j < (ssize_t) number_arguments; j++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1185 | arguments[j]=DestroyString(arguments[j]); |
| 1186 | arguments=(char **) RelinquishMagickMemory(arguments); |
cristy | 3589219 | 2014-05-26 12:04:36 +0000 | [diff] [blame] | 1187 | if (status == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1188 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1189 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1190 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1191 | (void) LogMagickEvent(ExceptionEvent,GetMagickModule(),"%s", |
| 1192 | exception->reason); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1193 | (*fail)++; |
| 1194 | continue; |
| 1195 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1196 | (void) FormatLocaleFile(stdout,"... pass.\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1197 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1198 | (void) FormatLocaleFile(stdout, |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 1199 | " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 1200 | (double) (test-(*fail)),(double) *fail); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1201 | return(test); |
| 1202 | } |
| 1203 | |
| 1204 | /* |
| 1205 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1206 | % % |
| 1207 | % % |
| 1208 | % % |
| 1209 | % V a l i d a t e C o m p o s i t e C o m m a n d % |
| 1210 | % % |
| 1211 | % % |
| 1212 | % % |
| 1213 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1214 | % |
| 1215 | % ValidateCompositeCommand() validates the ImageMagick composite command line |
| 1216 | % program and returns the number of validation tests that passed and failed. |
| 1217 | % |
| 1218 | % The format of the ValidateCompositeCommand method is: |
| 1219 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1220 | % size_t ValidateCompositeCommand(ImageInfo *image_info, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1221 | % const char *reference_filename,const char *output_filename, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1222 | % size_t *fail,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1223 | % |
| 1224 | % A description of each parameter follows: |
| 1225 | % |
| 1226 | % o image_info: the image info. |
| 1227 | % |
| 1228 | % o reference_filename: the reference image filename. |
| 1229 | % |
| 1230 | % o output_filename: the output image filename. |
| 1231 | % |
| 1232 | % o fail: return the number of validation tests that pass. |
| 1233 | % |
| 1234 | % o exception: return any errors or warnings in this structure. |
| 1235 | % |
| 1236 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1237 | static size_t ValidateCompositeCommand(ImageInfo *image_info, |
cristy | 0d772ed | 2012-11-10 14:34:50 +0000 | [diff] [blame] | 1238 | const char *reference_filename,const char *output_filename,size_t *fail, |
| 1239 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1240 | { |
| 1241 | char |
| 1242 | **arguments, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1243 | command[MagickPathExtent]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1244 | |
| 1245 | int |
| 1246 | number_arguments; |
| 1247 | |
| 1248 | MagickBooleanType |
| 1249 | status; |
| 1250 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1251 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1252 | i, |
| 1253 | j; |
| 1254 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1255 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1256 | test; |
| 1257 | |
| 1258 | test=0; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1259 | (void) FormatLocaleFile(stdout,"validate composite command line program:\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1260 | for (i=0; composite_options[i] != (char *) NULL; i++) |
| 1261 | { |
| 1262 | CatchException(exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1263 | (void) FormatLocaleFile(stdout," test %.20g: %s",(double) (test++), |
cristy | 6aa47ad | 2010-05-28 19:32:32 +0000 | [diff] [blame] | 1264 | composite_options[i]); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1265 | (void) FormatLocaleString(command,MagickPathExtent,"%s %s %s %s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1266 | reference_filename,composite_options[i],reference_filename, |
| 1267 | output_filename); |
| 1268 | arguments=StringToArgv(command,&number_arguments); |
| 1269 | if (arguments == (char **) NULL) |
| 1270 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1271 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1272 | GetMagickModule()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1273 | (*fail)++; |
| 1274 | continue; |
| 1275 | } |
| 1276 | status=CompositeImageCommand(image_info,number_arguments,arguments, |
| 1277 | (char **) NULL,exception); |
cristy | e42f658 | 2012-02-11 17:59:50 +0000 | [diff] [blame] | 1278 | for (j=0; j < (ssize_t) number_arguments; j++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1279 | arguments[j]=DestroyString(arguments[j]); |
| 1280 | arguments=(char **) RelinquishMagickMemory(arguments); |
cristy | 3589219 | 2014-05-26 12:04:36 +0000 | [diff] [blame] | 1281 | if (status == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1282 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1283 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1284 | GetMagickModule()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1285 | (*fail)++; |
| 1286 | continue; |
| 1287 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1288 | (void) FormatLocaleFile(stdout,"... pass.\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1289 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1290 | (void) FormatLocaleFile(stdout, |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 1291 | " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 1292 | (double) (test-(*fail)),(double) *fail); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1293 | return(test); |
| 1294 | } |
| 1295 | |
| 1296 | /* |
| 1297 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1298 | % % |
| 1299 | % % |
| 1300 | % % |
| 1301 | % V a l i d a t e C o n v e r t C o m m a n d % |
| 1302 | % % |
| 1303 | % % |
| 1304 | % % |
| 1305 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1306 | % |
| 1307 | % ValidateConvertCommand() validates the ImageMagick convert command line |
| 1308 | % program and returns the number of validation tests that passed and failed. |
| 1309 | % |
| 1310 | % The format of the ValidateConvertCommand method is: |
| 1311 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1312 | % size_t ValidateConvertCommand(ImageInfo *image_info, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1313 | % const char *reference_filename,const char *output_filename, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1314 | % size_t *fail,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1315 | % |
| 1316 | % A description of each parameter follows: |
| 1317 | % |
| 1318 | % o image_info: the image info. |
| 1319 | % |
| 1320 | % o reference_filename: the reference image filename. |
| 1321 | % |
| 1322 | % o output_filename: the output image filename. |
| 1323 | % |
| 1324 | % o fail: return the number of validation tests that pass. |
| 1325 | % |
| 1326 | % o exception: return any errors or warnings in this structure. |
| 1327 | % |
| 1328 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1329 | static size_t ValidateConvertCommand(ImageInfo *image_info, |
cristy | 0d772ed | 2012-11-10 14:34:50 +0000 | [diff] [blame] | 1330 | const char *reference_filename,const char *output_filename,size_t *fail, |
| 1331 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1332 | { |
| 1333 | char |
| 1334 | **arguments, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1335 | command[MagickPathExtent]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1336 | |
| 1337 | int |
| 1338 | number_arguments; |
| 1339 | |
| 1340 | MagickBooleanType |
| 1341 | status; |
| 1342 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1343 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1344 | i, |
| 1345 | j; |
| 1346 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1347 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1348 | test; |
| 1349 | |
| 1350 | test=0; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1351 | (void) FormatLocaleFile(stdout,"validate convert command line program:\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1352 | for (i=0; convert_options[i] != (char *) NULL; i++) |
| 1353 | { |
| 1354 | CatchException(exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1355 | (void) FormatLocaleFile(stdout," test %.20g: %s",(double) test++, |
cristy | 6aa47ad | 2010-05-28 19:32:32 +0000 | [diff] [blame] | 1356 | convert_options[i]); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1357 | (void) FormatLocaleString(command,MagickPathExtent,"%s %s %s %s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1358 | reference_filename,convert_options[i],reference_filename,output_filename); |
| 1359 | arguments=StringToArgv(command,&number_arguments); |
| 1360 | if (arguments == (char **) NULL) |
| 1361 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1362 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1363 | GetMagickModule()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1364 | (*fail)++; |
| 1365 | continue; |
| 1366 | } |
| 1367 | status=ConvertImageCommand(image_info,number_arguments,arguments, |
| 1368 | (char **) NULL,exception); |
cristy | e42f658 | 2012-02-11 17:59:50 +0000 | [diff] [blame] | 1369 | for (j=0; j < (ssize_t) number_arguments; j++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1370 | arguments[j]=DestroyString(arguments[j]); |
| 1371 | arguments=(char **) RelinquishMagickMemory(arguments); |
cristy | 3589219 | 2014-05-26 12:04:36 +0000 | [diff] [blame] | 1372 | if (status == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1373 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1374 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1375 | GetMagickModule()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1376 | (*fail)++; |
| 1377 | continue; |
| 1378 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1379 | (void) FormatLocaleFile(stdout,"... pass.\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1380 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1381 | (void) FormatLocaleFile(stdout, |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 1382 | " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 1383 | (double) (test-(*fail)),(double) *fail); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1384 | return(test); |
| 1385 | } |
| 1386 | |
| 1387 | /* |
| 1388 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1389 | % % |
| 1390 | % % |
| 1391 | % % |
| 1392 | % V a l i d a t e I d e n t i f y C o m m a n d % |
| 1393 | % % |
| 1394 | % % |
| 1395 | % % |
| 1396 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1397 | % |
| 1398 | % ValidateIdentifyCommand() validates the ImageMagick identify command line |
| 1399 | % program and returns the number of validation tests that passed and failed. |
| 1400 | % |
| 1401 | % The format of the ValidateIdentifyCommand method is: |
| 1402 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1403 | % size_t ValidateIdentifyCommand(ImageInfo *image_info, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1404 | % const char *reference_filename,const char *output_filename, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1405 | % size_t *fail,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1406 | % |
| 1407 | % A description of each parameter follows: |
| 1408 | % |
| 1409 | % o image_info: the image info. |
| 1410 | % |
| 1411 | % o reference_filename: the reference image filename. |
| 1412 | % |
| 1413 | % o output_filename: the output image filename. |
| 1414 | % |
| 1415 | % o fail: return the number of validation tests that pass. |
| 1416 | % |
| 1417 | % o exception: return any errors or warnings in this structure. |
| 1418 | % |
| 1419 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1420 | static size_t ValidateIdentifyCommand(ImageInfo *image_info, |
cristy | 0d772ed | 2012-11-10 14:34:50 +0000 | [diff] [blame] | 1421 | const char *reference_filename,const char *output_filename,size_t *fail, |
| 1422 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1423 | { |
| 1424 | char |
| 1425 | **arguments, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1426 | command[MagickPathExtent]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1427 | |
| 1428 | int |
| 1429 | number_arguments; |
| 1430 | |
| 1431 | MagickBooleanType |
| 1432 | status; |
| 1433 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1434 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1435 | i, |
| 1436 | j; |
| 1437 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1438 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1439 | test; |
| 1440 | |
| 1441 | (void) output_filename; |
| 1442 | test=0; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1443 | (void) FormatLocaleFile(stdout,"validate identify command line program:\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1444 | for (i=0; identify_options[i] != (char *) NULL; i++) |
| 1445 | { |
| 1446 | CatchException(exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1447 | (void) FormatLocaleFile(stdout," test %.20g: %s",(double) test++, |
cristy | 6aa47ad | 2010-05-28 19:32:32 +0000 | [diff] [blame] | 1448 | identify_options[i]); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1449 | (void) FormatLocaleString(command,MagickPathExtent,"%s %s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1450 | identify_options[i],reference_filename); |
| 1451 | arguments=StringToArgv(command,&number_arguments); |
| 1452 | if (arguments == (char **) NULL) |
| 1453 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1454 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1455 | GetMagickModule()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1456 | (*fail)++; |
| 1457 | continue; |
| 1458 | } |
| 1459 | status=IdentifyImageCommand(image_info,number_arguments,arguments, |
| 1460 | (char **) NULL,exception); |
cristy | e42f658 | 2012-02-11 17:59:50 +0000 | [diff] [blame] | 1461 | for (j=0; j < (ssize_t) number_arguments; j++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1462 | arguments[j]=DestroyString(arguments[j]); |
| 1463 | arguments=(char **) RelinquishMagickMemory(arguments); |
cristy | 3589219 | 2014-05-26 12:04:36 +0000 | [diff] [blame] | 1464 | if (status == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1465 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1466 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1467 | GetMagickModule()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1468 | (*fail)++; |
| 1469 | continue; |
| 1470 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1471 | (void) FormatLocaleFile(stdout,"... pass.\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1472 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1473 | (void) FormatLocaleFile(stdout, |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 1474 | " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 1475 | (double) (test-(*fail)),(double) *fail); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1476 | return(test); |
| 1477 | } |
| 1478 | |
| 1479 | /* |
| 1480 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1481 | % % |
| 1482 | % % |
| 1483 | % % |
| 1484 | % 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 % |
| 1485 | % % |
| 1486 | % % |
| 1487 | % % |
| 1488 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1489 | % |
| 1490 | % ValidateImageFormatsInMemory() validates the ImageMagick image formats in |
| 1491 | % memory and returns the number of validation tests that passed and failed. |
| 1492 | % |
| 1493 | % The format of the ValidateImageFormatsInMemory method is: |
| 1494 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1495 | % size_t ValidateImageFormatsInMemory(ImageInfo *image_info, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1496 | % const char *reference_filename,const char *output_filename, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1497 | % size_t *fail,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1498 | % |
| 1499 | % A description of each parameter follows: |
| 1500 | % |
| 1501 | % o image_info: the image info. |
| 1502 | % |
| 1503 | % o reference_filename: the reference image filename. |
| 1504 | % |
| 1505 | % o output_filename: the output image filename. |
| 1506 | % |
| 1507 | % o fail: return the number of validation tests that pass. |
| 1508 | % |
| 1509 | % o exception: return any errors or warnings in this structure. |
| 1510 | % |
| 1511 | */ |
glennrp | 4084cda | 2012-12-11 14:13:35 +0000 | [diff] [blame] | 1512 | |
cristy | 725833f | 2012-12-13 17:40:53 +0000 | [diff] [blame] | 1513 | /* |
| 1514 | Enable this to count remaining $TMPDIR/magick-* files. Note that the count |
| 1515 | includes any files left over from other runs. |
| 1516 | */ |
| 1517 | #undef MagickCountTempFiles |
glennrp | 4084cda | 2012-12-11 14:13:35 +0000 | [diff] [blame] | 1518 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1519 | static size_t ValidateImageFormatsInMemory(ImageInfo *image_info, |
cristy | 0d772ed | 2012-11-10 14:34:50 +0000 | [diff] [blame] | 1520 | const char *reference_filename,const char *output_filename,size_t *fail, |
| 1521 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1522 | { |
| 1523 | char |
glennrp | 4084cda | 2012-12-11 14:13:35 +0000 | [diff] [blame] | 1524 | #ifdef MagickCountTempFiles |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1525 | path[MagickPathExtent], |
| 1526 | SystemCommand[MagickPathExtent], |
glennrp | 4084cda | 2012-12-11 14:13:35 +0000 | [diff] [blame] | 1527 | #endif |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1528 | size[MagickPathExtent]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1529 | |
| 1530 | const MagickInfo |
| 1531 | *magick_info; |
| 1532 | |
| 1533 | double |
| 1534 | distortion, |
| 1535 | fuzz; |
| 1536 | |
| 1537 | Image |
| 1538 | *difference_image, |
cristy | 2c40422 | 2012-06-10 15:36:30 +0000 | [diff] [blame] | 1539 | *ping_image, |
cristy | 6b9ae3f | 2012-06-10 15:39:34 +0000 | [diff] [blame] | 1540 | *reconstruct_image, |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1541 | *reference_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1542 | |
| 1543 | MagickBooleanType |
| 1544 | status; |
| 1545 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1546 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1547 | i, |
| 1548 | j; |
| 1549 | |
| 1550 | size_t |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1551 | length, |
| 1552 | test; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1553 | |
| 1554 | unsigned char |
| 1555 | *blob; |
| 1556 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1557 | test=0; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1558 | (void) FormatLocaleFile(stdout,"validate image formats in memory:\n"); |
glennrp | 4084cda | 2012-12-11 14:13:35 +0000 | [diff] [blame] | 1559 | |
| 1560 | #ifdef MagickCountTempFiles |
| 1561 | (void)GetPathTemplate(path); |
glennrp | 33fb803 | 2013-01-07 18:43:03 +0000 | [diff] [blame] | 1562 | /* Remove file template except for the leading "/path/to/magick-" */ |
glennrp | 4084cda | 2012-12-11 14:13:35 +0000 | [diff] [blame] | 1563 | path[strlen(path)-17]='\0'; |
| 1564 | (void) FormatLocaleFile(stdout," tmp path is '%s*'\n",path); |
| 1565 | #endif |
| 1566 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1567 | for (i=0; reference_formats[i].magick != (char *) NULL; i++) |
| 1568 | { |
| 1569 | magick_info=GetMagickInfo(reference_formats[i].magick,exception); |
| 1570 | if ((magick_info == (const MagickInfo *) NULL) || |
| 1571 | (magick_info->decoder == (DecodeImageHandler *) NULL) || |
| 1572 | (magick_info->encoder == (EncodeImageHandler *) NULL)) |
| 1573 | continue; |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 1574 | for (j=0; reference_types[j].type != UndefinedType; j++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1575 | { |
| 1576 | /* |
| 1577 | Generate reference image. |
| 1578 | */ |
| 1579 | CatchException(exception); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1580 | (void) FormatLocaleFile(stdout," test %.20g: %s/%s/%s/%.20g-bits", |
| 1581 | (double) (test++),reference_formats[i].magick,CommandOptionToMnemonic( |
cristy | 7998e5f | 2009-10-08 02:45:33 +0000 | [diff] [blame] | 1582 | MagickCompressOptions,reference_formats[i].compression), |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1583 | CommandOptionToMnemonic(MagickTypeOptions,reference_types[j].type), |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 1584 | (double) reference_types[j].depth); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1585 | (void) CopyMagickString(image_info->filename,reference_filename, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1586 | MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1587 | reference_image=ReadImage(image_info,exception); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1588 | if ((reference_image == (Image *) NULL) || |
| 1589 | (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1590 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1591 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1592 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1593 | if (exception->reason != (char *) NULL) |
| 1594 | (void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1595 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1596 | (*fail)++; |
| 1597 | continue; |
| 1598 | } |
| 1599 | /* |
| 1600 | Write reference image. |
| 1601 | */ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1602 | (void) FormatLocaleString(size,MagickPathExtent,"%.20gx%.20g", |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 1603 | (double) reference_image->columns,(double) reference_image->rows); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1604 | (void) CloneString(&image_info->size,size); |
| 1605 | image_info->depth=reference_types[j].depth; |
Cristy | 114baf5 | 2017-07-12 19:21:05 -0400 | [diff] [blame] | 1606 | (void) FormatLocaleString(reference_image->filename,MagickPathExtent, |
| 1607 | "%s:%s",reference_formats[i].magick,output_filename); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1608 | status=SetImageType(reference_image,reference_types[j].type,exception); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1609 | if (status == MagickFalse || (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1610 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1611 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1612 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1613 | if (exception->reason != (char *) NULL) |
| 1614 | (void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1615 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1616 | (*fail)++; |
| 1617 | reference_image=DestroyImage(reference_image); |
| 1618 | continue; |
| 1619 | } |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1620 | status=SetImageDepth(reference_image,reference_types[j].depth,exception); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1621 | if (status == MagickFalse || (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1622 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1623 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1624 | GetMagickModule()); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1625 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1626 | (*fail)++; |
| 1627 | reference_image=DestroyImage(reference_image); |
| 1628 | continue; |
| 1629 | } |
cristy | 7998e5f | 2009-10-08 02:45:33 +0000 | [diff] [blame] | 1630 | reference_image->compression=reference_formats[i].compression; |
cristy | 6f9e0d3 | 2011-08-28 16:32:09 +0000 | [diff] [blame] | 1631 | status=WriteImage(image_info,reference_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1632 | reference_image=DestroyImage(reference_image); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1633 | if (status == MagickFalse || (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1634 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1635 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1636 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1637 | if (exception->reason != (char *) NULL) |
| 1638 | (void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1639 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1640 | (*fail)++; |
| 1641 | continue; |
| 1642 | } |
| 1643 | /* |
cristy | 2c40422 | 2012-06-10 15:36:30 +0000 | [diff] [blame] | 1644 | Ping reference image. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1645 | */ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1646 | (void) FormatLocaleString(image_info->filename,MagickPathExtent,"%s:%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1647 | reference_formats[i].magick,output_filename); |
cristy | 2c40422 | 2012-06-10 15:36:30 +0000 | [diff] [blame] | 1648 | ping_image=PingImage(image_info,exception); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1649 | if (ping_image == (Image *) NULL || |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1650 | (exception->severity >= ErrorException)) |
cristy | 2c40422 | 2012-06-10 15:36:30 +0000 | [diff] [blame] | 1651 | { |
| 1652 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1653 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1654 | if (exception->reason != (char *) NULL) |
| 1655 | (void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1656 | CatchException(exception); |
cristy | 2c40422 | 2012-06-10 15:36:30 +0000 | [diff] [blame] | 1657 | (*fail)++; |
| 1658 | continue; |
| 1659 | } |
| 1660 | ping_image=DestroyImage(ping_image); |
| 1661 | /* |
| 1662 | Read reference image. |
| 1663 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1664 | reference_image=ReadImage(image_info,exception); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1665 | if ((reference_image == (Image *) NULL) || |
| 1666 | (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1667 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1668 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1669 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1670 | if (exception->reason != (char *) NULL) |
| 1671 | (void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1672 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1673 | (*fail)++; |
| 1674 | continue; |
| 1675 | } |
| 1676 | /* |
| 1677 | Write reference image. |
| 1678 | */ |
Cristy | 114baf5 | 2017-07-12 19:21:05 -0400 | [diff] [blame] | 1679 | (void) FormatLocaleString(reference_image->filename,MagickPathExtent, |
| 1680 | "%s:%s",reference_formats[i].magick,output_filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1681 | (void) CopyMagickString(image_info->magick,reference_formats[i].magick, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1682 | MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1683 | reference_image->depth=reference_types[j].depth; |
cristy | 7998e5f | 2009-10-08 02:45:33 +0000 | [diff] [blame] | 1684 | reference_image->compression=reference_formats[i].compression; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1685 | length=8192; |
| 1686 | blob=ImageToBlob(image_info,reference_image,&length,exception); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1687 | if ((blob == (unsigned char *) NULL) || |
| 1688 | (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1689 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1690 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1691 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1692 | if (exception->reason != (char *) NULL) |
| 1693 | (void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1694 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1695 | (*fail)++; |
| 1696 | reference_image=DestroyImage(reference_image); |
| 1697 | continue; |
| 1698 | } |
| 1699 | /* |
cristy | 2c40422 | 2012-06-10 15:36:30 +0000 | [diff] [blame] | 1700 | Ping reference blob. |
| 1701 | */ |
| 1702 | ping_image=PingBlob(image_info,blob,length,exception); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1703 | if (ping_image == (Image *) NULL || |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1704 | (exception->severity >= ErrorException)) |
cristy | 2c40422 | 2012-06-10 15:36:30 +0000 | [diff] [blame] | 1705 | { |
| 1706 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1707 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1708 | if (exception->reason != (char *) NULL) |
| 1709 | (void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1710 | CatchException(exception); |
cristy | 2c40422 | 2012-06-10 15:36:30 +0000 | [diff] [blame] | 1711 | (*fail)++; |
| 1712 | blob=(unsigned char *) RelinquishMagickMemory(blob); |
| 1713 | continue; |
| 1714 | } |
| 1715 | ping_image=DestroyImage(ping_image); |
| 1716 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1717 | Read reconstruct image. |
| 1718 | */ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1719 | (void) FormatLocaleString(image_info->filename,MagickPathExtent,"%s:%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1720 | reference_formats[i].magick,output_filename); |
| 1721 | reconstruct_image=BlobToImage(image_info,blob,length,exception); |
| 1722 | blob=(unsigned char *) RelinquishMagickMemory(blob); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1723 | if (reconstruct_image == (Image *) NULL || |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1724 | (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1725 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1726 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1727 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1728 | if (exception->reason != (char *) NULL) |
| 1729 | (void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1730 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1731 | (*fail)++; |
| 1732 | reference_image=DestroyImage(reference_image); |
| 1733 | continue; |
| 1734 | } |
| 1735 | /* |
| 1736 | Compare reference to reconstruct image. |
| 1737 | */ |
cristy | 93540ab | 2013-03-30 19:59:41 +0000 | [diff] [blame] | 1738 | fuzz=0.003; /* grayscale */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1739 | if (reference_formats[i].fuzz != 0.0) |
| 1740 | fuzz=reference_formats[i].fuzz; |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 1741 | difference_image=CompareImages(reference_image,reconstruct_image, |
cristy | 864c6a8 | 2012-06-19 16:45:22 +0000 | [diff] [blame] | 1742 | RootMeanSquaredErrorMetric,&distortion,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1743 | reconstruct_image=DestroyImage(reconstruct_image); |
| 1744 | reference_image=DestroyImage(reference_image); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1745 | if (difference_image == (Image *) NULL || |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1746 | (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1747 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1748 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1749 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1750 | if (exception->reason != (char *) NULL) |
| 1751 | (void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1752 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1753 | (*fail)++; |
| 1754 | continue; |
| 1755 | } |
| 1756 | difference_image=DestroyImage(difference_image); |
cristy | 1415422 | 2012-06-15 23:21:49 +0000 | [diff] [blame] | 1757 | if ((QuantumScale*distortion) > fuzz) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1758 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1759 | (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n", |
cristy | 1415422 | 2012-06-15 23:21:49 +0000 | [diff] [blame] | 1760 | QuantumScale*distortion); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1761 | (*fail)++; |
| 1762 | continue; |
| 1763 | } |
glennrp | 4084cda | 2012-12-11 14:13:35 +0000 | [diff] [blame] | 1764 | #ifdef MagickCountTempFiles |
| 1765 | (void) FormatLocaleFile(stdout,"... pass, "); |
| 1766 | (void) fflush(stdout); |
| 1767 | SystemCommand[0]='\0'; |
cristy | 77b33ba | 2013-03-28 13:23:13 +0000 | [diff] [blame] | 1768 | (void) strncat(SystemCommand,"echo `ls ",9); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1769 | (void) strncat(SystemCommand,path,MagickPathExtent-31); |
cristy | 77b33ba | 2013-03-28 13:23:13 +0000 | [diff] [blame] | 1770 | (void) strncat(SystemCommand,"* | wc -w` tmp files.",20); |
| 1771 | (void) system(SystemCommand); |
glennrp | 4084cda | 2012-12-11 14:13:35 +0000 | [diff] [blame] | 1772 | (void) fflush(stdout); |
| 1773 | #else |
| 1774 | (void) FormatLocaleFile(stdout,"... pass\n"); |
| 1775 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1776 | } |
| 1777 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1778 | (void) FormatLocaleFile(stdout, |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 1779 | " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 1780 | (double) (test-(*fail)),(double) *fail); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1781 | return(test); |
| 1782 | } |
| 1783 | |
| 1784 | /* |
| 1785 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1786 | % % |
| 1787 | % % |
| 1788 | % % |
| 1789 | % 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 % |
| 1790 | % % |
| 1791 | % % |
| 1792 | % % |
| 1793 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1794 | % |
| 1795 | % ValidateImageFormatsOnDisk() validates the ImageMagick image formats on disk |
| 1796 | % and returns the number of validation tests that passed and failed. |
| 1797 | % |
| 1798 | % The format of the ValidateImageFormatsOnDisk method is: |
| 1799 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1800 | % size_t ValidateImageFormatsOnDisk(ImageInfo *image_info, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1801 | % const char *reference_filename,const char *output_filename, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1802 | % size_t *fail,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1803 | % |
| 1804 | % A description of each parameter follows: |
| 1805 | % |
| 1806 | % o image_info: the image info. |
| 1807 | % |
| 1808 | % o reference_filename: the reference image filename. |
| 1809 | % |
| 1810 | % o output_filename: the output image filename. |
| 1811 | % |
| 1812 | % o fail: return the number of validation tests that pass. |
| 1813 | % |
| 1814 | % o exception: return any errors or warnings in this structure. |
| 1815 | % |
| 1816 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1817 | static size_t ValidateImageFormatsOnDisk(ImageInfo *image_info, |
cristy | 0d772ed | 2012-11-10 14:34:50 +0000 | [diff] [blame] | 1818 | const char *reference_filename,const char *output_filename,size_t *fail, |
| 1819 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1820 | { |
| 1821 | char |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1822 | size[MagickPathExtent]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1823 | |
| 1824 | const MagickInfo |
| 1825 | *magick_info; |
| 1826 | |
| 1827 | double |
| 1828 | distortion, |
| 1829 | fuzz; |
| 1830 | |
| 1831 | Image |
| 1832 | *difference_image, |
| 1833 | *reference_image, |
| 1834 | *reconstruct_image; |
| 1835 | |
| 1836 | MagickBooleanType |
| 1837 | status; |
| 1838 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1839 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1840 | i, |
| 1841 | j; |
| 1842 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1843 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1844 | test; |
| 1845 | |
| 1846 | test=0; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1847 | (void) FormatLocaleFile(stdout,"validate image formats on disk:\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1848 | for (i=0; reference_formats[i].magick != (char *) NULL; i++) |
| 1849 | { |
| 1850 | magick_info=GetMagickInfo(reference_formats[i].magick,exception); |
| 1851 | if ((magick_info == (const MagickInfo *) NULL) || |
| 1852 | (magick_info->decoder == (DecodeImageHandler *) NULL) || |
| 1853 | (magick_info->encoder == (EncodeImageHandler *) NULL)) |
| 1854 | continue; |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 1855 | for (j=0; reference_types[j].type != UndefinedType; j++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1856 | { |
| 1857 | /* |
| 1858 | Generate reference image. |
| 1859 | */ |
| 1860 | CatchException(exception); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1861 | (void) FormatLocaleFile(stdout," test %.20g: %s/%s/%s/%.20g-bits", |
| 1862 | (double) (test++),reference_formats[i].magick,CommandOptionToMnemonic( |
cristy | 7998e5f | 2009-10-08 02:45:33 +0000 | [diff] [blame] | 1863 | MagickCompressOptions,reference_formats[i].compression), |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1864 | CommandOptionToMnemonic(MagickTypeOptions,reference_types[j].type), |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 1865 | (double) reference_types[j].depth); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1866 | (void) CopyMagickString(image_info->filename,reference_filename, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1867 | MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1868 | reference_image=ReadImage(image_info,exception); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1869 | if ((reference_image == (Image *) NULL) || |
| 1870 | (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1871 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1872 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1873 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1874 | if (exception->reason != (char *) NULL) |
| 1875 | (void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1876 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1877 | (*fail)++; |
| 1878 | continue; |
| 1879 | } |
| 1880 | /* |
| 1881 | Write reference image. |
| 1882 | */ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1883 | (void) FormatLocaleString(size,MagickPathExtent,"%.20gx%.20g", |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 1884 | (double) reference_image->columns,(double) reference_image->rows); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1885 | (void) CloneString(&image_info->size,size); |
| 1886 | image_info->depth=reference_types[j].depth; |
Cristy | 114baf5 | 2017-07-12 19:21:05 -0400 | [diff] [blame] | 1887 | (void) FormatLocaleString(reference_image->filename,MagickPathExtent, |
| 1888 | "%s:%s",reference_formats[i].magick,output_filename); |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1889 | status=SetImageType(reference_image,reference_types[j].type,exception); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1890 | if (status == MagickFalse || (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1891 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1892 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1893 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1894 | if (exception->reason != (char *) NULL) |
| 1895 | (void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1896 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1897 | (*fail)++; |
| 1898 | reference_image=DestroyImage(reference_image); |
| 1899 | continue; |
| 1900 | } |
cristy | 8a11cb1 | 2011-10-19 23:53:34 +0000 | [diff] [blame] | 1901 | status=SetImageDepth(reference_image,reference_types[j].depth,exception); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1902 | if (status == MagickFalse || (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1903 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1904 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1905 | GetMagickModule()); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1906 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1907 | (*fail)++; |
| 1908 | reference_image=DestroyImage(reference_image); |
| 1909 | continue; |
| 1910 | } |
cristy | 7998e5f | 2009-10-08 02:45:33 +0000 | [diff] [blame] | 1911 | reference_image->compression=reference_formats[i].compression; |
cristy | 6f9e0d3 | 2011-08-28 16:32:09 +0000 | [diff] [blame] | 1912 | status=WriteImage(image_info,reference_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1913 | reference_image=DestroyImage(reference_image); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1914 | if (status == MagickFalse || (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1915 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1916 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1917 | GetMagickModule()); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1918 | if (exception->reason != (char *) NULL) |
| 1919 | (void) FormatLocaleFile(stdout," reason:%s\n",exception->reason); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1920 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1921 | (*fail)++; |
| 1922 | continue; |
| 1923 | } |
| 1924 | /* |
| 1925 | Read reference image. |
| 1926 | */ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1927 | (void) FormatLocaleString(image_info->filename,MagickPathExtent,"%s:%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1928 | reference_formats[i].magick,output_filename); |
| 1929 | reference_image=ReadImage(image_info,exception); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1930 | if ((reference_image == (Image *) NULL) || |
| 1931 | (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1932 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1933 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1934 | GetMagickModule()); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1935 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1936 | (*fail)++; |
| 1937 | continue; |
| 1938 | } |
| 1939 | /* |
| 1940 | Write reference image. |
| 1941 | */ |
Cristy | 114baf5 | 2017-07-12 19:21:05 -0400 | [diff] [blame] | 1942 | (void) FormatLocaleString(reference_image->filename,MagickPathExtent, |
| 1943 | "%s:%s",reference_formats[i].magick,output_filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1944 | reference_image->depth=reference_types[j].depth; |
cristy | 7998e5f | 2009-10-08 02:45:33 +0000 | [diff] [blame] | 1945 | reference_image->compression=reference_formats[i].compression; |
cristy | 6f9e0d3 | 2011-08-28 16:32:09 +0000 | [diff] [blame] | 1946 | status=WriteImage(image_info,reference_image,exception); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1947 | if (status == MagickFalse ||exception->severity >= ErrorException) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1948 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1949 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1950 | GetMagickModule()); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1951 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1952 | (*fail)++; |
| 1953 | reference_image=DestroyImage(reference_image); |
| 1954 | continue; |
| 1955 | } |
| 1956 | /* |
| 1957 | Read reconstruct image. |
| 1958 | */ |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1959 | (void) FormatLocaleString(image_info->filename,MagickPathExtent,"%s:%s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1960 | reference_formats[i].magick,output_filename); |
| 1961 | reconstruct_image=ReadImage(image_info,exception); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1962 | if (reconstruct_image == (Image *) NULL || |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1963 | (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1964 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1965 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1966 | GetMagickModule()); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1967 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1968 | (*fail)++; |
| 1969 | reference_image=DestroyImage(reference_image); |
| 1970 | continue; |
| 1971 | } |
| 1972 | /* |
| 1973 | Compare reference to reconstruct image. |
| 1974 | */ |
cristy | 93540ab | 2013-03-30 19:59:41 +0000 | [diff] [blame] | 1975 | fuzz=0.003; /* grayscale */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1976 | if (reference_formats[i].fuzz != 0.0) |
| 1977 | fuzz=reference_formats[i].fuzz; |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 1978 | difference_image=CompareImages(reference_image,reconstruct_image, |
cristy | 864c6a8 | 2012-06-19 16:45:22 +0000 | [diff] [blame] | 1979 | RootMeanSquaredErrorMetric,&distortion,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1980 | reconstruct_image=DestroyImage(reconstruct_image); |
| 1981 | reference_image=DestroyImage(reference_image); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1982 | if (difference_image == (Image *) NULL || |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 1983 | (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1984 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 1985 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 1986 | GetMagickModule()); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 1987 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1988 | (*fail)++; |
| 1989 | continue; |
| 1990 | } |
| 1991 | difference_image=DestroyImage(difference_image); |
cristy | 1415422 | 2012-06-15 23:21:49 +0000 | [diff] [blame] | 1992 | if ((QuantumScale*distortion) > fuzz) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1993 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1994 | (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n", |
cristy | 1415422 | 2012-06-15 23:21:49 +0000 | [diff] [blame] | 1995 | QuantumScale*distortion); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1996 | (*fail)++; |
| 1997 | continue; |
| 1998 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1999 | (void) FormatLocaleFile(stdout,"... pass.\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2000 | } |
| 2001 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2002 | (void) FormatLocaleFile(stdout, |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 2003 | " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 2004 | (double) (test-(*fail)),(double) *fail); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2005 | return(test); |
| 2006 | } |
| 2007 | |
| 2008 | /* |
| 2009 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2010 | % % |
| 2011 | % % |
| 2012 | % % |
| 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 % |
| 2014 | % % |
| 2015 | % % |
| 2016 | % % |
| 2017 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2018 | % |
| 2019 | % ValidateImportExportPixels() validates the pixel import and export methods. |
| 2020 | % It returns the number of validation tests that passed and failed. |
| 2021 | % |
| 2022 | % The format of the ValidateImportExportPixels method is: |
| 2023 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2024 | % size_t ValidateImportExportPixels(ImageInfo *image_info, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2025 | % const char *reference_filename,const char *output_filename, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2026 | % size_t *fail,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2027 | % |
| 2028 | % A description of each parameter follows: |
| 2029 | % |
| 2030 | % o image_info: the image info. |
| 2031 | % |
| 2032 | % o reference_filename: the reference image filename. |
| 2033 | % |
| 2034 | % o output_filename: the output image filename. |
| 2035 | % |
| 2036 | % o fail: return the number of validation tests that pass. |
| 2037 | % |
| 2038 | % o exception: return any errors or warnings in this structure. |
| 2039 | % |
| 2040 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2041 | static size_t ValidateImportExportPixels(ImageInfo *image_info, |
cristy | 0d772ed | 2012-11-10 14:34:50 +0000 | [diff] [blame] | 2042 | const char *reference_filename,const char *output_filename,size_t *fail, |
| 2043 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2044 | { |
| 2045 | double |
| 2046 | distortion; |
| 2047 | |
| 2048 | Image |
| 2049 | *difference_image, |
| 2050 | *reference_image, |
| 2051 | *reconstruct_image; |
| 2052 | |
| 2053 | MagickBooleanType |
| 2054 | status; |
| 2055 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2056 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2057 | i, |
| 2058 | j; |
| 2059 | |
| 2060 | size_t |
| 2061 | length; |
| 2062 | |
| 2063 | unsigned char |
| 2064 | *pixels; |
| 2065 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2066 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2067 | test; |
| 2068 | |
| 2069 | (void) output_filename; |
| 2070 | test=0; |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 2071 | (void) FormatLocaleFile(stdout, |
| 2072 | "validate the import and export of image pixels:\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2073 | for (i=0; reference_map[i] != (char *) NULL; i++) |
| 2074 | { |
| 2075 | for (j=0; reference_storage[j].type != UndefinedPixel; j++) |
| 2076 | { |
| 2077 | /* |
| 2078 | Generate reference image. |
| 2079 | */ |
| 2080 | CatchException(exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2081 | (void) FormatLocaleFile(stdout," test %.20g: %s/%s",(double) (test++), |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2082 | reference_map[i],CommandOptionToMnemonic(MagickStorageOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2083 | reference_storage[j].type)); |
| 2084 | (void) CopyMagickString(image_info->filename,reference_filename, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2085 | MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2086 | reference_image=ReadImage(image_info,exception); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 2087 | if ((reference_image == (Image *) NULL) || |
| 2088 | (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2089 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 2090 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 2091 | GetMagickModule()); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 2092 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2093 | (*fail)++; |
| 2094 | continue; |
| 2095 | } |
| 2096 | if (LocaleNCompare(reference_map[i],"cmy",3) == 0) |
cristy | 2c40422 | 2012-06-10 15:36:30 +0000 | [diff] [blame] | 2097 | (void) SetImageColorspace(reference_image,CMYKColorspace,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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)); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 2101 | if (pixels == (unsigned char *) NULL || |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 2102 | (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2103 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 2104 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 2105 | GetMagickModule()); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 2106 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2107 | (*fail)++; |
| 2108 | reference_image=DestroyImage(reference_image); |
| 2109 | continue; |
| 2110 | } |
| 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, |
| 2114 | exception); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 2115 | if (status == MagickFalse || (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2116 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 2117 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 2118 | GetMagickModule()); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 2119 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2120 | (*fail)++; |
| 2121 | pixels=(unsigned char *) RelinquishMagickMemory(pixels); |
| 2122 | reference_image=DestroyImage(reference_image); |
| 2123 | continue; |
| 2124 | } |
cristy | d55c935 | 2011-10-20 15:29:22 +0000 | [diff] [blame] | 2125 | (void) SetImageBackgroundColor(reference_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2126 | status=ImportImagePixels(reference_image,0,0,reference_image->columns, |
| 2127 | reference_image->rows,reference_map[i],reference_storage[j].type, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2128 | pixels,exception); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 2129 | if (status == MagickFalse || (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2130 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 2131 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 2132 | GetMagickModule()); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 2133 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2134 | (*fail)++; |
| 2135 | pixels=(unsigned char *) RelinquishMagickMemory(pixels); |
| 2136 | reference_image=DestroyImage(reference_image); |
| 2137 | continue; |
| 2138 | } |
| 2139 | /* |
| 2140 | Read reconstruct image. |
| 2141 | */ |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 2142 | reconstruct_image=AcquireImage(image_info,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2143 | (void) SetImageExtent(reconstruct_image,reference_image->columns, |
cristy | 655a8d1 | 2011-08-05 19:24:28 +0000 | [diff] [blame] | 2144 | reference_image->rows,exception); |
| 2145 | (void) SetImageColorspace(reconstruct_image,reference_image->colorspace, |
| 2146 | exception); |
cristy | d55c935 | 2011-10-20 15:29:22 +0000 | [diff] [blame] | 2147 | (void) SetImageBackgroundColor(reconstruct_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2148 | status=ImportImagePixels(reconstruct_image,0,0,reconstruct_image->columns, |
| 2149 | reconstruct_image->rows,reference_map[i],reference_storage[j].type, |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 2150 | pixels,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2151 | pixels=(unsigned char *) RelinquishMagickMemory(pixels); |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 2152 | if (status == MagickFalse || (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2153 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 2154 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 2155 | GetMagickModule()); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 2156 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2157 | (*fail)++; |
| 2158 | reference_image=DestroyImage(reference_image); |
| 2159 | continue; |
| 2160 | } |
| 2161 | /* |
| 2162 | Compare reference to reconstruct image. |
| 2163 | */ |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 2164 | difference_image=CompareImages(reference_image,reconstruct_image, |
cristy | 864c6a8 | 2012-06-19 16:45:22 +0000 | [diff] [blame] | 2165 | RootMeanSquaredErrorMetric,&distortion,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2166 | reconstruct_image=DestroyImage(reconstruct_image); |
| 2167 | reference_image=DestroyImage(reference_image); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 2168 | if (difference_image == (Image *) NULL || |
Cristy | e287985 | 2017-08-13 12:53:45 -0400 | [diff] [blame] | 2169 | (exception->severity >= ErrorException)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2170 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 2171 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 2172 | GetMagickModule()); |
dirk | 775194c | 2014-05-17 19:47:54 +0000 | [diff] [blame] | 2173 | CatchException(exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2174 | (*fail)++; |
| 2175 | continue; |
| 2176 | } |
| 2177 | difference_image=DestroyImage(difference_image); |
cristy | 1415422 | 2012-06-15 23:21:49 +0000 | [diff] [blame] | 2178 | if ((QuantumScale*distortion) > 0.0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2179 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2180 | (void) FormatLocaleFile(stdout,"... fail (with distortion %g).\n", |
cristy | 1415422 | 2012-06-15 23:21:49 +0000 | [diff] [blame] | 2181 | QuantumScale*distortion); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2182 | (*fail)++; |
| 2183 | continue; |
| 2184 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2185 | (void) FormatLocaleFile(stdout,"... pass.\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2186 | } |
| 2187 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2188 | (void) FormatLocaleFile(stdout, |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 2189 | " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 2190 | (double) (test-(*fail)),(double) *fail); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2191 | return(test); |
| 2192 | } |
| 2193 | |
| 2194 | /* |
| 2195 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2196 | % % |
| 2197 | % % |
| 2198 | % % |
| 2199 | % V a l i d a t e M o n t a g e C o m m a n d % |
| 2200 | % % |
| 2201 | % % |
| 2202 | % % |
| 2203 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2204 | % |
| 2205 | % ValidateMontageCommand() validates the ImageMagick montage command line |
| 2206 | % program and returns the number of validation tests that passed and failed. |
| 2207 | % |
| 2208 | % The format of the ValidateMontageCommand method is: |
| 2209 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2210 | % size_t ValidateMontageCommand(ImageInfo *image_info, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2211 | % const char *reference_filename,const char *output_filename, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2212 | % size_t *fail,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2213 | % |
| 2214 | % A description of each parameter follows: |
| 2215 | % |
| 2216 | % o image_info: the image info. |
| 2217 | % |
| 2218 | % o reference_filename: the reference image filename. |
| 2219 | % |
| 2220 | % o output_filename: the output image filename. |
| 2221 | % |
| 2222 | % o fail: return the number of validation tests that pass. |
| 2223 | % |
| 2224 | % o exception: return any errors or warnings in this structure. |
| 2225 | % |
| 2226 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2227 | static size_t ValidateMontageCommand(ImageInfo *image_info, |
cristy | 0d772ed | 2012-11-10 14:34:50 +0000 | [diff] [blame] | 2228 | const char *reference_filename,const char *output_filename,size_t *fail, |
| 2229 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2230 | { |
| 2231 | char |
| 2232 | **arguments, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2233 | command[MagickPathExtent]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2234 | |
| 2235 | int |
| 2236 | number_arguments; |
| 2237 | |
| 2238 | MagickBooleanType |
| 2239 | status; |
| 2240 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2241 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2242 | i, |
| 2243 | j; |
| 2244 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2245 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2246 | test; |
| 2247 | |
| 2248 | test=0; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2249 | (void) FormatLocaleFile(stdout,"validate montage command line program:\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2250 | for (i=0; montage_options[i] != (char *) NULL; i++) |
| 2251 | { |
| 2252 | CatchException(exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2253 | (void) FormatLocaleFile(stdout," test %.20g: %s",(double) (test++), |
cristy | 6aa47ad | 2010-05-28 19:32:32 +0000 | [diff] [blame] | 2254 | montage_options[i]); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2255 | (void) FormatLocaleString(command,MagickPathExtent,"%s %s %s %s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2256 | reference_filename,montage_options[i],reference_filename, |
| 2257 | output_filename); |
| 2258 | arguments=StringToArgv(command,&number_arguments); |
| 2259 | if (arguments == (char **) NULL) |
| 2260 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 2261 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 2262 | GetMagickModule()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2263 | (*fail)++; |
| 2264 | continue; |
| 2265 | } |
| 2266 | status=MontageImageCommand(image_info,number_arguments,arguments, |
| 2267 | (char **) NULL,exception); |
cristy | e42f658 | 2012-02-11 17:59:50 +0000 | [diff] [blame] | 2268 | for (j=0; j < (ssize_t) number_arguments; j++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2269 | arguments[j]=DestroyString(arguments[j]); |
| 2270 | arguments=(char **) RelinquishMagickMemory(arguments); |
cristy | 3589219 | 2014-05-26 12:04:36 +0000 | [diff] [blame] | 2271 | if (status == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2272 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 2273 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 2274 | GetMagickModule()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2275 | (*fail)++; |
| 2276 | continue; |
| 2277 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2278 | (void) FormatLocaleFile(stdout,"... pass.\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2279 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2280 | (void) FormatLocaleFile(stdout, |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 2281 | " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 2282 | (double) (test-(*fail)),(double) *fail); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2283 | return(test); |
| 2284 | } |
| 2285 | |
| 2286 | /* |
| 2287 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2288 | % % |
| 2289 | % % |
| 2290 | % % |
| 2291 | % V a l i d a t e S t r e a m C o m m a n d % |
| 2292 | % % |
| 2293 | % % |
| 2294 | % % |
| 2295 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2296 | % |
| 2297 | % ValidateStreamCommand() validates the ImageMagick stream command line |
| 2298 | % program and returns the number of validation tests that passed and failed. |
| 2299 | % |
| 2300 | % The format of the ValidateStreamCommand method is: |
| 2301 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2302 | % size_t ValidateStreamCommand(ImageInfo *image_info, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2303 | % const char *reference_filename,const char *output_filename, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2304 | % size_t *fail,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2305 | % |
| 2306 | % A description of each parameter follows: |
| 2307 | % |
| 2308 | % o image_info: the image info. |
| 2309 | % |
| 2310 | % o reference_filename: the reference image filename. |
| 2311 | % |
| 2312 | % o output_filename: the output image filename. |
| 2313 | % |
| 2314 | % o fail: return the number of validation tests that pass. |
| 2315 | % |
| 2316 | % o exception: return any errors or warnings in this structure. |
| 2317 | % |
| 2318 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2319 | static size_t ValidateStreamCommand(ImageInfo *image_info, |
cristy | 0d772ed | 2012-11-10 14:34:50 +0000 | [diff] [blame] | 2320 | const char *reference_filename,const char *output_filename,size_t *fail, |
| 2321 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2322 | { |
| 2323 | char |
| 2324 | **arguments, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2325 | command[MagickPathExtent]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2326 | |
| 2327 | int |
| 2328 | number_arguments; |
| 2329 | |
| 2330 | MagickBooleanType |
| 2331 | status; |
| 2332 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2333 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2334 | i, |
| 2335 | j; |
| 2336 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2337 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2338 | test; |
| 2339 | |
| 2340 | test=0; |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2341 | (void) FormatLocaleFile(stdout,"validate stream command line program:\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2342 | for (i=0; stream_options[i] != (char *) NULL; i++) |
| 2343 | { |
| 2344 | CatchException(exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2345 | (void) FormatLocaleFile(stdout," test %.20g: %s",(double) (test++), |
cristy | 6aa47ad | 2010-05-28 19:32:32 +0000 | [diff] [blame] | 2346 | stream_options[i]); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2347 | (void) FormatLocaleString(command,MagickPathExtent,"%s %s %s", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2348 | stream_options[i],reference_filename,output_filename); |
| 2349 | arguments=StringToArgv(command,&number_arguments); |
| 2350 | if (arguments == (char **) NULL) |
| 2351 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 2352 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 2353 | GetMagickModule()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2354 | (*fail)++; |
| 2355 | continue; |
| 2356 | } |
| 2357 | status=StreamImageCommand(image_info,number_arguments,arguments, |
| 2358 | (char **) NULL,exception); |
cristy | e42f658 | 2012-02-11 17:59:50 +0000 | [diff] [blame] | 2359 | for (j=0; j < (ssize_t) number_arguments; j++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2360 | arguments[j]=DestroyString(arguments[j]); |
| 2361 | arguments=(char **) RelinquishMagickMemory(arguments); |
cristy | 3589219 | 2014-05-26 12:04:36 +0000 | [diff] [blame] | 2362 | if (status == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2363 | { |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 2364 | (void) FormatLocaleFile(stdout,"... fail @ %s/%s/%lu.\n", |
| 2365 | GetMagickModule()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2366 | (*fail)++; |
| 2367 | continue; |
| 2368 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2369 | (void) FormatLocaleFile(stdout,"... pass.\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2370 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2371 | (void) FormatLocaleFile(stdout, |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 2372 | " summary: %.20g subtests; %.20g passed; %.20g failed.\n",(double) test, |
| 2373 | (double) (test-(*fail)),(double) *fail); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2374 | return(test); |
| 2375 | } |
| 2376 | |
| 2377 | /* |
| 2378 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2379 | % % |
| 2380 | % % |
| 2381 | % % |
| 2382 | % M a i n % |
| 2383 | % % |
| 2384 | % % |
| 2385 | % % |
| 2386 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2387 | % |
| 2388 | % |
| 2389 | */ |
| 2390 | |
| 2391 | static MagickBooleanType ValidateUsage(void) |
| 2392 | { |
| 2393 | const char |
| 2394 | **p; |
| 2395 | |
| 2396 | static const char |
| 2397 | *miscellaneous[]= |
| 2398 | { |
| 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", |
| 2404 | (char *) NULL |
| 2405 | }, |
| 2406 | *settings[]= |
| 2407 | { |
| 2408 | "-regard-warnings pay attention to warning messages", |
| 2409 | "-verbose print detailed information about the image", |
| 2410 | (char *) NULL |
| 2411 | }; |
| 2412 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2413 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2414 | (void) printf("Copyright: %s\n\n",GetMagickCopyright()); |
cristy | b28d647 | 2009-10-17 20:13:35 +0000 | [diff] [blame] | 2415 | (void) printf("Features: %s\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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); |
| 2423 | return(MagickTrue); |
| 2424 | } |
| 2425 | |
| 2426 | int main(int argc,char **argv) |
| 2427 | { |
| 2428 | #define DestroyValidate() \ |
| 2429 | { \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2430 | image_info=DestroyImageInfo(image_info); \ |
| 2431 | exception=DestroyExceptionInfo(exception); \ |
| 2432 | } |
| 2433 | #define ThrowValidateException(asperity,tag,option) \ |
| 2434 | { \ |
| 2435 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 2436 | option); \ |
| 2437 | CatchException(exception); \ |
| 2438 | DestroyValidate(); \ |
| 2439 | return(MagickFalse); \ |
| 2440 | } |
| 2441 | |
| 2442 | char |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2443 | output_filename[MagickPathExtent], |
| 2444 | reference_filename[MagickPathExtent], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2445 | *option; |
| 2446 | |
| 2447 | double |
| 2448 | elapsed_time, |
| 2449 | user_time; |
| 2450 | |
| 2451 | ExceptionInfo |
| 2452 | *exception; |
| 2453 | |
| 2454 | Image |
| 2455 | *reference_image; |
| 2456 | |
| 2457 | ImageInfo |
| 2458 | *image_info; |
| 2459 | |
| 2460 | MagickBooleanType |
| 2461 | regard_warnings, |
| 2462 | status; |
| 2463 | |
cristy | 9cafe59 | 2012-11-17 21:17:59 +0000 | [diff] [blame] | 2464 | MagickSizeType |
| 2465 | memory_resource, |
| 2466 | map_resource; |
| 2467 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2468 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2469 | i; |
| 2470 | |
| 2471 | TimerInfo |
| 2472 | *timer; |
| 2473 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2474 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2475 | fail, |
| 2476 | iterations, |
| 2477 | tests; |
| 2478 | |
| 2479 | ValidateType |
| 2480 | type; |
| 2481 | |
| 2482 | /* |
| 2483 | Validate the ImageMagick image processing suite. |
| 2484 | */ |
cristy | b4d552c | 2012-12-13 15:42:17 +0000 | [diff] [blame] | 2485 | MagickCoreGenesis(*argv,MagickTrue); |
cristy | ef2fdc6 | 2012-12-12 11:16:48 +0000 | [diff] [blame] | 2486 | (void) setlocale(LC_ALL,""); |
| 2487 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2488 | iterations=1; |
| 2489 | status=MagickFalse; |
| 2490 | type=AllValidate; |
| 2491 | regard_warnings=MagickFalse; |
cristy | d886290 | 2011-02-20 21:12:27 +0000 | [diff] [blame] | 2492 | (void) regard_warnings; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2493 | exception=AcquireExceptionInfo(); |
| 2494 | image_info=AcquireImageInfo(); |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2495 | (void) CopyMagickString(image_info->filename,ReferenceFilename,MagickPathExtent); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2496 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2497 | { |
| 2498 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2499 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2500 | { |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2501 | (void) CopyMagickString(image_info->filename,option,MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2502 | continue; |
| 2503 | } |
| 2504 | switch (*(option+1)) |
| 2505 | { |
| 2506 | case 'b': |
| 2507 | { |
| 2508 | if (LocaleCompare("bench",option+1) == 0) |
| 2509 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 2510 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2511 | break; |
| 2512 | } |
| 2513 | ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2514 | } |
| 2515 | case 'd': |
| 2516 | { |
| 2517 | if (LocaleCompare("debug",option+1) == 0) |
| 2518 | { |
| 2519 | (void) SetLogEventMask(argv[++i]); |
| 2520 | break; |
| 2521 | } |
| 2522 | ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2523 | } |
| 2524 | case 'h': |
| 2525 | { |
| 2526 | if (LocaleCompare("help",option+1) == 0) |
| 2527 | { |
| 2528 | (void) ValidateUsage(); |
| 2529 | return(0); |
| 2530 | } |
| 2531 | ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2532 | } |
| 2533 | case 'l': |
| 2534 | { |
| 2535 | if (LocaleCompare("log",option+1) == 0) |
| 2536 | { |
| 2537 | if (*option != '+') |
| 2538 | (void) SetLogFormat(argv[i+1]); |
| 2539 | break; |
| 2540 | } |
| 2541 | ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2542 | } |
| 2543 | case 'r': |
| 2544 | { |
| 2545 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 2546 | { |
| 2547 | regard_warnings=MagickTrue; |
| 2548 | break; |
| 2549 | } |
| 2550 | ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2551 | } |
| 2552 | case 'v': |
| 2553 | { |
| 2554 | if (LocaleCompare("validate",option+1) == 0) |
| 2555 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2556 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2557 | validate; |
| 2558 | |
| 2559 | if (*option == '+') |
| 2560 | break; |
| 2561 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 2562 | if (i >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2563 | ThrowValidateException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 2564 | validate=ParseCommandOption(MagickValidateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2565 | argv[i]); |
| 2566 | if (validate < 0) |
| 2567 | ThrowValidateException(OptionError,"UnrecognizedValidateType", |
| 2568 | argv[i]); |
| 2569 | type=(ValidateType) validate; |
| 2570 | break; |
| 2571 | } |
| 2572 | if ((LocaleCompare("version",option+1) == 0) || |
| 2573 | (LocaleCompare("-version",option+1) == 0)) |
| 2574 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2575 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2576 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 2577 | (void) FormatLocaleFile(stdout,"Copyright: %s\n\n", |
| 2578 | GetMagickCopyright()); |
| 2579 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 2580 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2581 | return(0); |
| 2582 | } |
| 2583 | ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2584 | } |
| 2585 | default: |
| 2586 | ThrowValidateException(OptionError,"UnrecognizedOption",option) |
| 2587 | } |
| 2588 | } |
cristy | 205e21f | 2009-09-28 19:01:46 +0000 | [diff] [blame] | 2589 | timer=(TimerInfo *) NULL; |
cristy | 8b76e55 | 2009-09-28 18:20:20 +0000 | [diff] [blame] | 2590 | if (iterations > 1) |
| 2591 | timer=AcquireTimerInfo(); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2592 | reference_image=ReadImage(image_info,exception); |
| 2593 | tests=0; |
| 2594 | fail=0; |
| 2595 | if (reference_image == (Image *) NULL) |
| 2596 | fail++; |
| 2597 | else |
| 2598 | { |
| 2599 | if (LocaleCompare(image_info->filename,ReferenceFilename) == 0) |
| 2600 | (void) CopyMagickString(reference_image->magick,ReferenceImageFormat, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2601 | MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2602 | (void) AcquireUniqueFilename(reference_filename); |
| 2603 | (void) AcquireUniqueFilename(output_filename); |
| 2604 | (void) CopyMagickString(reference_image->filename,reference_filename, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 2605 | MagickPathExtent); |
cristy | 6f9e0d3 | 2011-08-28 16:32:09 +0000 | [diff] [blame] | 2606 | status=WriteImage(image_info,reference_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2607 | reference_image=DestroyImage(reference_image); |
| 2608 | if (status == MagickFalse) |
| 2609 | fail++; |
| 2610 | else |
| 2611 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2612 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2613 | GetMagickVersion((size_t *) NULL)); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2614 | (void) FormatLocaleFile(stdout,"Copyright: %s\n\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2615 | GetMagickCopyright()); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 2616 | (void) FormatLocaleFile(stdout, |
| 2617 | "ImageMagick Validation Suite (%s)\n\n",CommandOptionToMnemonic( |
| 2618 | MagickValidateOptions,(ssize_t) type)); |
cristy | 80e870e | 2013-05-07 12:23:02 +0000 | [diff] [blame] | 2619 | if ((type & ColorspaceValidate) != 0) |
cristy | 572e097 | 2013-05-07 12:51:28 +0000 | [diff] [blame] | 2620 | tests+=ValidateColorspaces(image_info,&fail,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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); |
cristy | 247eebde | 2013-06-13 01:01:43 +0000 | [diff] [blame] | 2630 | if ((type & FormatsDiskValidate) != 0) |
cristy | f044a4d | 2012-11-17 21:10:20 +0000 | [diff] [blame] | 2631 | { |
cristy | 9cafe59 | 2012-11-17 21:17:59 +0000 | [diff] [blame] | 2632 | memory_resource=SetMagickResourceLimit(MemoryResource,0); |
cristy | 247eebde | 2013-06-13 01:01:43 +0000 | [diff] [blame] | 2633 | map_resource=SetMagickResourceLimit(MapResource,0); |
| 2634 | (void) FormatLocaleFile(stdout,"[pixel-cache: disk] "); |
cristy | f044a4d | 2012-11-17 21:10:20 +0000 | [diff] [blame] | 2635 | tests+=ValidateImageFormatsInMemory(image_info,reference_filename, |
| 2636 | output_filename,&fail,exception); |
| 2637 | (void) FormatLocaleFile(stdout,"[pixel-cache: disk] "); |
cristy | 247eebde | 2013-06-13 01:01:43 +0000 | [diff] [blame] | 2638 | tests+=ValidateImageFormatsOnDisk(image_info,reference_filename, |
cristy | f044a4d | 2012-11-17 21:10:20 +0000 | [diff] [blame] | 2639 | output_filename,&fail,exception); |
cristy | 9cafe59 | 2012-11-17 21:17:59 +0000 | [diff] [blame] | 2640 | (void) SetMagickResourceLimit(MemoryResource,memory_resource); |
| 2641 | (void) SetMagickResourceLimit(MapResource,map_resource); |
cristy | f044a4d | 2012-11-17 21:10:20 +0000 | [diff] [blame] | 2642 | } |
cristy | 247eebde | 2013-06-13 01:01:43 +0000 | [diff] [blame] | 2643 | if ((type & FormatsMapValidate) != 0) |
cristy | bda201a | 2012-11-08 16:44:00 +0000 | [diff] [blame] | 2644 | { |
cristy | 247eebde | 2013-06-13 01:01:43 +0000 | [diff] [blame] | 2645 | memory_resource=SetMagickResourceLimit(MemoryResource,0); |
| 2646 | (void) FormatLocaleFile(stdout,"[pixel-cache: memory-mapped] "); |
| 2647 | tests+=ValidateImageFormatsInMemory(image_info,reference_filename, |
cristy | bda201a | 2012-11-08 16:44:00 +0000 | [diff] [blame] | 2648 | output_filename,&fail,exception); |
cristy | 34c290f | 2012-11-09 00:44:12 +0000 | [diff] [blame] | 2649 | (void) FormatLocaleFile(stdout,"[pixel-cache: memory-mapped] "); |
cristy | bda201a | 2012-11-08 16:44:00 +0000 | [diff] [blame] | 2650 | tests+=ValidateImageFormatsOnDisk(image_info,reference_filename, |
| 2651 | output_filename,&fail,exception); |
cristy | 9cafe59 | 2012-11-17 21:17:59 +0000 | [diff] [blame] | 2652 | (void) SetMagickResourceLimit(MemoryResource,memory_resource); |
cristy | 247eebde | 2013-06-13 01:01:43 +0000 | [diff] [blame] | 2653 | } |
| 2654 | if ((type & FormatsMemoryValidate) != 0) |
| 2655 | { |
| 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); |
cristy | bda201a | 2012-11-08 16:44:00 +0000 | [diff] [blame] | 2662 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2675 | (void) FormatLocaleFile(stdout, |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 2676 | "validation suite: %.20g tests; %.20g passed; %.20g failed.\n", |
| 2677 | (double) tests,(double) (tests-fail),(double) fail); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2678 | } |
| 2679 | (void) RelinquishUniqueFileResource(output_filename); |
| 2680 | (void) RelinquishUniqueFileResource(reference_filename); |
| 2681 | } |
| 2682 | if (exception->severity != UndefinedException) |
| 2683 | CatchException(exception); |
| 2684 | if (iterations > 1) |
| 2685 | { |
| 2686 | elapsed_time=GetElapsedTime(timer); |
| 2687 | user_time=GetUserTime(timer); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 2688 | (void) FormatLocaleFile(stderr, |
cristy | 75a2623 | 2010-06-03 17:15:02 +0000 | [diff] [blame] | 2689 | "Performance: %.20gi %gips %0.3fu %ld:%02ld.%03ld\n",(double) |
cristy | 6aa47ad | 2010-05-28 19:32:32 +0000 | [diff] [blame] | 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)))); |
cristy | 8b76e55 | 2009-09-28 18:20:20 +0000 | [diff] [blame] | 2693 | timer=DestroyTimerInfo(timer); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2694 | } |
| 2695 | DestroyValidate(); |
| 2696 | MagickCoreTerminus(); |
| 2697 | return(fail == 0 ? 0 : 1); |
| 2698 | } |