cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % CCCC OOO M M PPPP AAA RRRR EEEEE % |
| 7 | % C O O MM MM P P A A R R E % |
| 8 | % C O O M M M PPPP AAAAA RRRR EEE % |
| 9 | % C O O M M P A A R R E % |
| 10 | % CCCC OOO M M P A A R R EEEEE % |
| 11 | % % |
| 12 | % % |
| 13 | % Image Comparison Methods % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % December 2003 % |
| 18 | % % |
| 19 | % % |
cristy | 1454be7 | 2011-12-19 01:52:48 +0000 | [diff] [blame] | 20 | % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % Use the compare program to mathematically and visually annotate the |
cristy | 6a917d9 | 2009-10-06 19:23:54 +0000 | [diff] [blame] | 37 | % difference between an image and its reconstruction. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 38 | % |
| 39 | */ |
| 40 | |
| 41 | /* |
| 42 | Include declarations. |
| 43 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 44 | #include "MagickWand/studio.h" |
| 45 | #include "MagickWand/MagickWand.h" |
| 46 | #include "MagickWand/mogrify-private.h" |
| 47 | #include "MagickCore/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 51 | % % |
| 52 | % % |
| 53 | % % |
| 54 | % C o m p a r e I m a g e C o m m a n d % |
| 55 | % % |
| 56 | % % |
| 57 | % % |
| 58 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 59 | % |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 60 | % CompareImagesCommand() compares two images and returns the difference between |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 61 | % them as a distortion metric and as a new image visually annotating their |
| 62 | % differences. |
| 63 | % |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 64 | % The format of the CompareImagesCommand method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 65 | % |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 66 | % MagickBooleanType CompareImagesCommand(ImageInfo *image_info,int argc, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 67 | % char **argv,char **metadata,ExceptionInfo *exception) |
| 68 | % |
| 69 | % A description of each parameter follows: |
| 70 | % |
| 71 | % o image_info: the image info. |
| 72 | % |
| 73 | % o argc: the number of elements in the argument vector. |
| 74 | % |
| 75 | % o argv: A text array containing the command line arguments. |
| 76 | % |
| 77 | % o metadata: any metadata is returned here. |
| 78 | % |
| 79 | % o exception: return any errors or warnings in this structure. |
| 80 | % |
| 81 | */ |
| 82 | |
| 83 | static MagickBooleanType CompareUsage(void) |
| 84 | { |
| 85 | const char |
| 86 | **p; |
| 87 | |
| 88 | static const char |
| 89 | *miscellaneous[]= |
| 90 | { |
| 91 | "-debug events display copious debugging information", |
| 92 | "-help print program options", |
| 93 | "-list type print a list of supported option arguments", |
| 94 | "-log format format of debugging information", |
| 95 | (char *) NULL |
| 96 | }, |
| 97 | *settings[]= |
| 98 | { |
| 99 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 100 | " transparent, extract, background, or shape", |
| 101 | "-authenticate password", |
| 102 | " decipher image with this password", |
| 103 | "-channel type apply option to select image channels", |
| 104 | "-colorspace type alternate image colorspace", |
| 105 | "-compose operator set image composite operator", |
| 106 | "-compress type type of pixel compression when writing the image", |
| 107 | "-decipher filename convert cipher pixels to plain pixels", |
| 108 | "-define format:option", |
| 109 | " define one or more image format options", |
| 110 | "-density geometry horizontal and vertical density of the image", |
| 111 | "-depth value image depth", |
| 112 | "-dissimilarity-threshold value", |
cristy | ba029a5 | 2010-11-27 02:18:26 +0000 | [diff] [blame] | 113 | " maximum distortion for (sub)image match", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 114 | "-encipher filename convert plain pixels to cipher pixels", |
| 115 | "-extract geometry extract area from image", |
| 116 | "-format \"string\" output formatted image characteristics", |
| 117 | "-fuzz distance colors within this distance are considered equal", |
| 118 | "-highlight-color color", |
| 119 | " empasize pixel differences with this color", |
| 120 | "-identify identify the format and characteristics of the image", |
| 121 | "-interlace type type of image interlacing scheme", |
| 122 | "-limit type value pixel cache resource limit", |
| 123 | "-lowlight-color color", |
| 124 | " de-emphasize pixel differences with this color", |
| 125 | "-metric type measure differences between images with this metric", |
| 126 | "-monitor monitor progress", |
| 127 | "-passphrase filename get the passphrase from this file", |
| 128 | "-profile filename add, delete, or apply an image profile", |
| 129 | "-quality value JPEG/MIFF/PNG compression level", |
| 130 | "-quiet suppress all warning messages", |
| 131 | "-quantize colorspace reduce colors in this colorspace", |
| 132 | "-regard-warnings pay attention to warning messages", |
| 133 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 134 | "-sampling-factor geometry", |
| 135 | " horizontal and vertical sampling factor", |
| 136 | "-seed value seed a new sequence of pseudo-random numbers", |
| 137 | "-set attribute value set an image attribute", |
| 138 | "-quality value JPEG/MIFF/PNG compression level", |
| 139 | "-size geometry width and height of image", |
cristy | b949804 | 2010-08-09 01:14:07 +0000 | [diff] [blame] | 140 | "-subimage-search search for subimage", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 141 | "-transparent-color color", |
| 142 | " transparent color", |
| 143 | "-type type image type", |
| 144 | "-verbose print detailed information about the image", |
| 145 | "-version print version information", |
| 146 | "-virtual-pixel method", |
| 147 | " virtual pixel access method", |
| 148 | (char *) NULL |
| 149 | }; |
| 150 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 151 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 152 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 153 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 154 | (void) printf("Usage: %s [options ...] image reconstruct difference\n", |
| 155 | GetClientName()); |
| 156 | (void) printf("\nImage Settings:\n"); |
| 157 | for (p=settings; *p != (char *) NULL; p++) |
| 158 | (void) printf(" %s\n",*p); |
| 159 | (void) printf("\nMiscellaneous Options:\n"); |
| 160 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 161 | (void) printf(" %s\n",*p); |
| 162 | (void) printf( |
| 163 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 164 | (void) printf( |
| 165 | "number. To specify a particular image format, precede the filename\n"); |
| 166 | (void) printf( |
| 167 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 168 | (void) printf( |
| 169 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 170 | (void) printf("'-' for standard input or output.\n"); |
| 171 | return(MagickFalse); |
| 172 | } |
| 173 | |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 174 | WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 175 | int argc,char **argv,char **metadata,ExceptionInfo *exception) |
| 176 | { |
cristy | 2b70e80 | 2009-11-23 19:40:25 +0000 | [diff] [blame] | 177 | #define DefaultDissimilarityThreshold 0.31830988618379067154 |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 178 | #define DestroyCompare() \ |
| 179 | { \ |
| 180 | if (similarity_image != (Image *) NULL) \ |
| 181 | similarity_image=DestroyImageList(similarity_image); \ |
| 182 | if (difference_image != (Image *) NULL) \ |
| 183 | difference_image=DestroyImageList(difference_image); \ |
| 184 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 185 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 186 | argv[i]=DestroyString(argv[i]); \ |
| 187 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 188 | } |
| 189 | #define ThrowCompareException(asperity,tag,option) \ |
| 190 | { \ |
| 191 | if (exception->severity < (asperity)) \ |
| 192 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag, \ |
| 193 | "`%s'",option); \ |
| 194 | DestroyCompare(); \ |
| 195 | return(MagickFalse); \ |
| 196 | } |
| 197 | #define ThrowCompareInvalidArgumentException(option,argument) \ |
| 198 | { \ |
| 199 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 200 | "InvalidArgument","`%s': %s",option,argument); \ |
| 201 | DestroyCompare(); \ |
| 202 | return(MagickFalse); \ |
| 203 | } |
| 204 | |
| 205 | char |
| 206 | *filename, |
| 207 | *option; |
| 208 | |
| 209 | const char |
| 210 | *format; |
| 211 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 212 | double |
| 213 | dissimilarity_threshold, |
| 214 | distortion, |
| 215 | similarity_metric; |
| 216 | |
| 217 | Image |
| 218 | *difference_image, |
| 219 | *image, |
| 220 | *reconstruct_image, |
| 221 | *similarity_image; |
| 222 | |
| 223 | ImageStack |
| 224 | image_stack[MaxImageStackDepth+1]; |
| 225 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 226 | MagickBooleanType |
| 227 | fire, |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 228 | pend, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 229 | respect_parenthesis, |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 230 | subimage_search; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 231 | |
| 232 | MagickStatusType |
| 233 | status; |
| 234 | |
| 235 | MetricType |
| 236 | metric; |
| 237 | |
| 238 | RectangleInfo |
| 239 | offset; |
| 240 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 241 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 242 | i; |
| 243 | |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 244 | ssize_t |
| 245 | j, |
| 246 | k; |
| 247 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 248 | /* |
| 249 | Set defaults. |
| 250 | */ |
| 251 | assert(image_info != (ImageInfo *) NULL); |
| 252 | assert(image_info->signature == MagickSignature); |
| 253 | if (image_info->debug != MagickFalse) |
| 254 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 255 | assert(exception != (ExceptionInfo *) NULL); |
| 256 | if (argc == 2) |
| 257 | { |
| 258 | option=argv[1]; |
| 259 | if ((LocaleCompare("version",option+1) == 0) || |
| 260 | (LocaleCompare("-version",option+1) == 0)) |
| 261 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 262 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 263 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 264 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 265 | GetMagickCopyright()); |
| 266 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 267 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 268 | return(MagickFalse); |
| 269 | } |
| 270 | } |
| 271 | if (argc < 3) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 272 | return(CompareUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 273 | difference_image=NewImageList(); |
| 274 | similarity_image=NewImageList(); |
| 275 | dissimilarity_threshold=DefaultDissimilarityThreshold; |
| 276 | distortion=0.0; |
| 277 | format=(char *) NULL; |
| 278 | j=1; |
| 279 | k=0; |
| 280 | metric=UndefinedMetric; |
| 281 | NewImageStack(); |
| 282 | option=(char *) NULL; |
| 283 | pend=MagickFalse; |
| 284 | reconstruct_image=NewImageList(); |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 285 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 286 | status=MagickTrue; |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 287 | subimage_search=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 288 | /* |
| 289 | Compare an image. |
| 290 | */ |
| 291 | ReadCommandlLine(argc,&argv); |
| 292 | status=ExpandFilenames(&argc,&argv); |
| 293 | if (status == MagickFalse) |
| 294 | ThrowCompareException(ResourceLimitError,"MemoryAllocationFailed", |
| 295 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 296 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 297 | { |
| 298 | option=argv[i]; |
| 299 | if (LocaleCompare(option,"(") == 0) |
| 300 | { |
| 301 | FireImageStack(MagickTrue,MagickTrue,pend); |
| 302 | if (k == MaxImageStackDepth) |
| 303 | ThrowCompareException(OptionError,"ParenthesisNestedTooDeeply", |
| 304 | option); |
| 305 | PushImageStack(); |
| 306 | continue; |
| 307 | } |
| 308 | if (LocaleCompare(option,")") == 0) |
| 309 | { |
| 310 | FireImageStack(MagickTrue,MagickTrue,MagickTrue); |
| 311 | if (k == 0) |
| 312 | ThrowCompareException(OptionError,"UnableToParseExpression",option); |
| 313 | PopImageStack(); |
| 314 | continue; |
| 315 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 316 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 317 | { |
| 318 | Image |
| 319 | *images; |
| 320 | |
| 321 | /* |
| 322 | Read input image. |
| 323 | */ |
| 324 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 325 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 326 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 327 | filename=argv[++i]; |
cristy | 1b58f25 | 2012-03-01 01:41:41 +0000 | [diff] [blame] | 328 | images=ReadImages(image_info,filename,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 329 | status&=(images != (Image *) NULL) && |
| 330 | (exception->severity < ErrorException); |
| 331 | if (images == (Image *) NULL) |
| 332 | continue; |
| 333 | AppendImageStack(images); |
| 334 | continue; |
| 335 | } |
| 336 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 337 | switch (*(option+1)) |
| 338 | { |
| 339 | case 'a': |
| 340 | { |
| 341 | if (LocaleCompare("alpha",option+1) == 0) |
| 342 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 343 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 344 | type; |
| 345 | |
| 346 | if (*option == '+') |
| 347 | break; |
| 348 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 349 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 350 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 351 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 352 | if (type < 0) |
| 353 | ThrowCompareException(OptionError,"UnrecognizedAlphaChannelType", |
| 354 | argv[i]); |
| 355 | break; |
| 356 | } |
| 357 | if (LocaleCompare("authenticate",option+1) == 0) |
| 358 | { |
| 359 | if (*option == '+') |
| 360 | break; |
| 361 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 362 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 363 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 364 | break; |
| 365 | } |
| 366 | ThrowCompareException(OptionError,"UnrecognizedOption",option); |
| 367 | } |
| 368 | case 'c': |
| 369 | { |
| 370 | if (LocaleCompare("cache",option+1) == 0) |
| 371 | { |
| 372 | if (*option == '+') |
| 373 | break; |
| 374 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 375 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 376 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 377 | if (IsGeometry(argv[i]) == MagickFalse) |
| 378 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 379 | break; |
| 380 | } |
| 381 | if (LocaleCompare("channel",option+1) == 0) |
| 382 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 383 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 384 | channel; |
| 385 | |
| 386 | if (*option == '+') |
| 387 | break; |
| 388 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 389 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 390 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 391 | channel=ParseChannelOption(argv[i]); |
| 392 | if (channel < 0) |
| 393 | ThrowCompareException(OptionError,"UnrecognizedChannelType", |
| 394 | argv[i]); |
cristy | e2a912b | 2011-12-05 20:02:07 +0000 | [diff] [blame] | 395 | SetPixelChannelMapMask(image,(ChannelType) channel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 396 | break; |
| 397 | } |
| 398 | if (LocaleCompare("colorspace",option+1) == 0) |
| 399 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 400 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 401 | colorspace; |
| 402 | |
| 403 | if (*option == '+') |
| 404 | break; |
| 405 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 406 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 407 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 408 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 409 | argv[i]); |
| 410 | if (colorspace < 0) |
| 411 | ThrowCompareException(OptionError,"UnrecognizedColorspace", |
| 412 | argv[i]); |
| 413 | break; |
| 414 | } |
| 415 | if (LocaleCompare("compose",option+1) == 0) |
| 416 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 417 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 418 | compose; |
| 419 | |
| 420 | if (*option == '+') |
| 421 | break; |
| 422 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 423 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 424 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 425 | compose=ParseCommandOption(MagickComposeOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 426 | argv[i]); |
| 427 | if (compose < 0) |
| 428 | ThrowCompareException(OptionError,"UnrecognizedComposeOperator", |
| 429 | argv[i]); |
| 430 | break; |
| 431 | } |
| 432 | if (LocaleCompare("compress",option+1) == 0) |
| 433 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 434 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 435 | compress; |
| 436 | |
| 437 | if (*option == '+') |
| 438 | break; |
| 439 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 440 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 441 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 442 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 443 | argv[i]); |
| 444 | if (compress < 0) |
| 445 | ThrowCompareException(OptionError,"UnrecognizedImageCompression", |
| 446 | argv[i]); |
| 447 | break; |
| 448 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 449 | if (LocaleCompare("concurrent",option+1) == 0) |
| 450 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 451 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 452 | } |
| 453 | case 'd': |
| 454 | { |
| 455 | if (LocaleCompare("debug",option+1) == 0) |
| 456 | { |
| 457 | LogEventType |
| 458 | event_mask; |
| 459 | |
| 460 | if (*option == '+') |
| 461 | break; |
| 462 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 463 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 464 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 465 | event_mask=SetLogEventMask(argv[i]); |
| 466 | if (event_mask == UndefinedEvents) |
| 467 | ThrowCompareException(OptionError,"UnrecognizedEventType", |
| 468 | argv[i]); |
| 469 | break; |
| 470 | } |
| 471 | if (LocaleCompare("decipher",option+1) == 0) |
| 472 | { |
| 473 | if (*option == '+') |
| 474 | break; |
| 475 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 476 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 477 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 478 | break; |
| 479 | } |
| 480 | if (LocaleCompare("define",option+1) == 0) |
| 481 | { |
| 482 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 483 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 484 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 485 | if (*option == '+') |
| 486 | { |
| 487 | const char |
| 488 | *define; |
| 489 | |
| 490 | define=GetImageOption(image_info,argv[i]); |
| 491 | if (define == (const char *) NULL) |
| 492 | ThrowCompareException(OptionError,"NoSuchOption",argv[i]); |
| 493 | break; |
| 494 | } |
| 495 | break; |
| 496 | } |
| 497 | if (LocaleCompare("density",option+1) == 0) |
| 498 | { |
| 499 | if (*option == '+') |
| 500 | break; |
| 501 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 502 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 503 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 504 | if (IsGeometry(argv[i]) == MagickFalse) |
| 505 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 506 | break; |
| 507 | } |
| 508 | if (LocaleCompare("depth",option+1) == 0) |
| 509 | { |
| 510 | if (*option == '+') |
| 511 | break; |
| 512 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 513 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 514 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 515 | if (IsGeometry(argv[i]) == MagickFalse) |
| 516 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 517 | break; |
| 518 | } |
| 519 | if (LocaleCompare("dissimilarity-threshold",option+1) == 0) |
| 520 | { |
| 521 | if (*option == '+') |
| 522 | break; |
| 523 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 524 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 525 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 526 | if (IsGeometry(argv[i]) == MagickFalse) |
| 527 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 528 | if (*option == '+') |
| 529 | dissimilarity_threshold=DefaultDissimilarityThreshold; |
| 530 | else |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 531 | dissimilarity_threshold=StringToDouble(argv[i],(char **) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 532 | break; |
| 533 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 534 | if (LocaleCompare("duration",option+1) == 0) |
| 535 | { |
| 536 | if (*option == '+') |
| 537 | break; |
| 538 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 539 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 540 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 541 | if (IsGeometry(argv[i]) == MagickFalse) |
| 542 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 543 | break; |
| 544 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 545 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 546 | } |
| 547 | case 'e': |
| 548 | { |
| 549 | if (LocaleCompare("encipher",option+1) == 0) |
| 550 | { |
| 551 | if (*option == '+') |
| 552 | break; |
| 553 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 554 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 555 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 556 | break; |
| 557 | } |
| 558 | if (LocaleCompare("extract",option+1) == 0) |
| 559 | { |
| 560 | if (*option == '+') |
| 561 | break; |
| 562 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 563 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 564 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 565 | if (IsGeometry(argv[i]) == MagickFalse) |
| 566 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 567 | break; |
| 568 | } |
| 569 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 570 | } |
| 571 | case 'f': |
| 572 | { |
| 573 | if (LocaleCompare("format",option+1) == 0) |
| 574 | { |
| 575 | if (*option == '+') |
| 576 | break; |
| 577 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 578 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 579 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 580 | format=argv[i]; |
| 581 | break; |
| 582 | } |
| 583 | if (LocaleCompare("fuzz",option+1) == 0) |
| 584 | { |
| 585 | if (*option == '+') |
| 586 | break; |
| 587 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 588 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 589 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 590 | if (IsGeometry(argv[i]) == MagickFalse) |
| 591 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 592 | break; |
| 593 | } |
| 594 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 595 | } |
| 596 | case 'h': |
| 597 | { |
| 598 | if ((LocaleCompare("help",option+1) == 0) || |
| 599 | (LocaleCompare("-help",option+1) == 0)) |
| 600 | return(CompareUsage()); |
| 601 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 602 | { |
| 603 | if (*option == '+') |
| 604 | break; |
| 605 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 606 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 607 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 608 | break; |
| 609 | } |
| 610 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 611 | } |
| 612 | case 'i': |
| 613 | { |
| 614 | if (LocaleCompare("identify",option+1) == 0) |
| 615 | break; |
| 616 | if (LocaleCompare("interlace",option+1) == 0) |
| 617 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 618 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 619 | interlace; |
| 620 | |
| 621 | if (*option == '+') |
| 622 | break; |
| 623 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 624 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 625 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 626 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 627 | argv[i]); |
| 628 | if (interlace < 0) |
| 629 | ThrowCompareException(OptionError,"UnrecognizedInterlaceType", |
| 630 | argv[i]); |
| 631 | break; |
| 632 | } |
| 633 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 634 | } |
| 635 | case 'l': |
| 636 | { |
| 637 | if (LocaleCompare("limit",option+1) == 0) |
| 638 | { |
| 639 | char |
| 640 | *p; |
| 641 | |
| 642 | double |
| 643 | value; |
| 644 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 645 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 646 | resource; |
| 647 | |
| 648 | if (*option == '+') |
| 649 | break; |
| 650 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 651 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 652 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 653 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 654 | argv[i]); |
| 655 | if (resource < 0) |
| 656 | ThrowCompareException(OptionError,"UnrecognizedResourceType", |
| 657 | argv[i]); |
| 658 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 659 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 660 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 661 | value=StringToDouble(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 662 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 663 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 664 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 665 | break; |
| 666 | } |
| 667 | if (LocaleCompare("list",option+1) == 0) |
| 668 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 669 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 670 | list; |
| 671 | |
| 672 | if (*option == '+') |
| 673 | break; |
| 674 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 675 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 676 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 677 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 678 | if (list < 0) |
| 679 | ThrowCompareException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 680 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 681 | argv+j,exception); |
| 682 | DestroyCompare(); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 683 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 684 | } |
| 685 | if (LocaleCompare("log",option+1) == 0) |
| 686 | { |
| 687 | if (*option == '+') |
| 688 | break; |
| 689 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 690 | if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 691 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 692 | break; |
| 693 | } |
| 694 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 695 | { |
| 696 | if (*option == '+') |
| 697 | break; |
| 698 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 699 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 700 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 701 | break; |
| 702 | } |
| 703 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 704 | } |
| 705 | case 'm': |
| 706 | { |
| 707 | if (LocaleCompare("matte",option+1) == 0) |
| 708 | break; |
| 709 | if (LocaleCompare("metric",option+1) == 0) |
| 710 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 711 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 712 | type; |
| 713 | |
| 714 | if (*option == '+') |
| 715 | break; |
| 716 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 717 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 718 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 719 | type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 720 | if (type < 0) |
| 721 | ThrowCompareException(OptionError,"UnrecognizedMetricType", |
| 722 | argv[i]); |
| 723 | metric=(MetricType) type; |
| 724 | break; |
| 725 | } |
| 726 | if (LocaleCompare("monitor",option+1) == 0) |
| 727 | break; |
| 728 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 729 | } |
| 730 | case 'p': |
| 731 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 732 | if (LocaleCompare("profile",option+1) == 0) |
| 733 | { |
| 734 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 735 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 736 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 737 | break; |
| 738 | } |
| 739 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 740 | } |
| 741 | case 'q': |
| 742 | { |
| 743 | if (LocaleCompare("quality",option+1) == 0) |
| 744 | { |
| 745 | if (*option == '+') |
| 746 | break; |
| 747 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 748 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 749 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 750 | if (IsGeometry(argv[i]) == MagickFalse) |
| 751 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 752 | break; |
| 753 | } |
| 754 | if (LocaleCompare("quantize",option+1) == 0) |
| 755 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 756 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 757 | colorspace; |
| 758 | |
| 759 | if (*option == '+') |
| 760 | break; |
| 761 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 762 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 763 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 764 | colorspace=ParseCommandOption(MagickColorspaceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 765 | MagickFalse,argv[i]); |
| 766 | if (colorspace < 0) |
| 767 | ThrowCompareException(OptionError,"UnrecognizedColorspace", |
| 768 | argv[i]); |
| 769 | break; |
| 770 | } |
| 771 | if (LocaleCompare("quiet",option+1) == 0) |
| 772 | break; |
| 773 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 774 | } |
| 775 | case 'r': |
| 776 | { |
| 777 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 778 | break; |
| 779 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 780 | { |
| 781 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 782 | break; |
| 783 | } |
| 784 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 785 | } |
| 786 | case 's': |
| 787 | { |
| 788 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 789 | { |
| 790 | if (*option == '+') |
| 791 | break; |
| 792 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 793 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 794 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 795 | if (IsGeometry(argv[i]) == MagickFalse) |
| 796 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 797 | break; |
| 798 | } |
| 799 | if (LocaleCompare("seed",option+1) == 0) |
| 800 | { |
| 801 | if (*option == '+') |
| 802 | break; |
| 803 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 804 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 805 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 806 | if (IsGeometry(argv[i]) == MagickFalse) |
| 807 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 808 | break; |
| 809 | } |
| 810 | if (LocaleCompare("set",option+1) == 0) |
| 811 | { |
| 812 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 813 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 814 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 815 | if (*option == '+') |
| 816 | break; |
| 817 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 818 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 819 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 820 | break; |
| 821 | } |
| 822 | if (LocaleCompare("size",option+1) == 0) |
| 823 | { |
| 824 | if (*option == '+') |
| 825 | break; |
| 826 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 827 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 828 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 829 | if (IsGeometry(argv[i]) == MagickFalse) |
| 830 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 831 | break; |
| 832 | } |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 833 | if (LocaleCompare("subimage-search",option+1) == 0) |
| 834 | { |
| 835 | if (*option == '+') |
| 836 | { |
| 837 | subimage_search=MagickFalse; |
| 838 | break; |
| 839 | } |
| 840 | subimage_search=MagickTrue; |
| 841 | break; |
| 842 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 843 | if (LocaleCompare("synchronize",option+1) == 0) |
| 844 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 845 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 846 | } |
| 847 | case 't': |
| 848 | { |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 849 | if (LocaleCompare("taint",option+1) == 0) |
| 850 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 851 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 852 | { |
| 853 | if (*option == '+') |
| 854 | break; |
| 855 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 856 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 857 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 858 | break; |
| 859 | } |
| 860 | if (LocaleCompare("type",option+1) == 0) |
| 861 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 862 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 863 | type; |
| 864 | |
| 865 | if (*option == '+') |
| 866 | break; |
| 867 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 868 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 869 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 870 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 871 | if (type < 0) |
| 872 | ThrowCompareException(OptionError,"UnrecognizedImageType", |
| 873 | argv[i]); |
| 874 | break; |
| 875 | } |
| 876 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 877 | } |
| 878 | case 'v': |
| 879 | { |
| 880 | if (LocaleCompare("verbose",option+1) == 0) |
| 881 | break; |
| 882 | if ((LocaleCompare("version",option+1) == 0) || |
| 883 | (LocaleCompare("-version",option+1) == 0)) |
| 884 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 885 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 886 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 887 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 888 | GetMagickCopyright()); |
| 889 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 890 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 891 | break; |
| 892 | } |
| 893 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 894 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 895 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 896 | method; |
| 897 | |
| 898 | if (*option == '+') |
| 899 | break; |
| 900 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 901 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 902 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 903 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 904 | argv[i]); |
| 905 | if (method < 0) |
| 906 | ThrowCompareException(OptionError, |
| 907 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 908 | break; |
| 909 | } |
| 910 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 911 | } |
| 912 | case '?': |
| 913 | break; |
| 914 | default: |
| 915 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 916 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 917 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 918 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 919 | if (fire != MagickFalse) |
| 920 | FireImageStack(MagickTrue,MagickTrue,MagickTrue); |
| 921 | } |
| 922 | if (k != 0) |
| 923 | ThrowCompareException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 924 | if (i-- != (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 925 | ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); |
| 926 | if ((image == (Image *) NULL) || (GetImageListLength(image) < 2)) |
| 927 | ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); |
| 928 | FinalizeImageSettings(image_info,image,MagickTrue); |
cristy | 94f2007 | 2009-09-12 02:12:36 +0000 | [diff] [blame] | 929 | if ((image == (Image *) NULL) || (GetImageListLength(image) < 2)) |
| 930 | ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 931 | image=GetImageFromList(image,0); |
| 932 | reconstruct_image=GetImageFromList(image,1); |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 933 | if (subimage_search != MagickFalse) |
| 934 | { |
cristy | 0913681 | 2011-10-18 15:24:30 +0000 | [diff] [blame] | 935 | similarity_image=SimilarityImage(image,reconstruct_image,metric,&offset, |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 936 | &similarity_metric,exception); |
| 937 | if (similarity_metric > dissimilarity_threshold) |
| 938 | ThrowCompareException(ImageError,"ImagesTooDissimilar",image->filename); |
| 939 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 940 | if ((reconstruct_image->columns == image->columns) && |
| 941 | (reconstruct_image->rows == image->rows)) |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 942 | difference_image=CompareImages(image,reconstruct_image,metric,&distortion, |
| 943 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 944 | else |
cristy | fdad905 | 2010-08-15 20:15:35 +0000 | [diff] [blame] | 945 | if (similarity_image == (Image *) NULL) |
| 946 | ThrowCompareException(OptionError,"ImageWidthsOrHeightsDiffer", |
| 947 | image->filename) |
| 948 | else |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 949 | { |
| 950 | Image |
| 951 | *composite_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 952 | |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 953 | /* |
| 954 | Determine if reconstructed image is a subimage of the image. |
| 955 | */ |
| 956 | composite_image=CloneImage(image,0,0,MagickTrue,exception); |
| 957 | if (composite_image == (Image *) NULL) |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 958 | difference_image=CompareImages(image,reconstruct_image,metric, |
| 959 | &distortion,exception); |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 960 | else |
| 961 | { |
| 962 | (void) CompositeImage(composite_image,CopyCompositeOp, |
cristy | e941a75 | 2011-10-15 01:52:48 +0000 | [diff] [blame] | 963 | reconstruct_image,offset.x,offset.y,exception); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 964 | difference_image=CompareImages(image,composite_image,metric, |
| 965 | &distortion,exception); |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 966 | if (difference_image != (Image *) NULL) |
| 967 | { |
| 968 | difference_image->page.x=offset.x; |
| 969 | difference_image->page.y=offset.y; |
| 970 | } |
| 971 | composite_image=DestroyImage(composite_image); |
| 972 | } |
| 973 | if (difference_image != (Image *) NULL) |
| 974 | { |
| 975 | AppendImageToList(&difference_image,similarity_image); |
| 976 | similarity_image=(Image *) NULL; |
| 977 | } |
| 978 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 979 | if (difference_image == (Image *) NULL) |
| 980 | status=0; |
| 981 | else |
| 982 | { |
| 983 | if (image_info->verbose != MagickFalse) |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 984 | (void) IsImagesEqual(image,reconstruct_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 985 | if (*difference_image->magick == '\0') |
| 986 | (void) CopyMagickString(difference_image->magick,image->magick, |
| 987 | MaxTextExtent); |
| 988 | if (image_info->verbose == MagickFalse) |
| 989 | { |
| 990 | switch (metric) |
| 991 | { |
cristy | 343eee9 | 2010-12-11 02:17:57 +0000 | [diff] [blame] | 992 | case FuzzErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 993 | case MeanAbsoluteErrorMetric: |
| 994 | case MeanSquaredErrorMetric: |
| 995 | case RootMeanSquaredErrorMetric: |
| 996 | case PeakAbsoluteErrorMetric: |
| 997 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 998 | (void) FormatLocaleFile(stderr,"%g (%g)",QuantumRange*distortion, |
cristy | 8cd5b31 | 2010-01-07 01:10:24 +0000 | [diff] [blame] | 999 | (double) distortion); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1000 | if ((reconstruct_image->columns != image->columns) || |
| 1001 | (reconstruct_image->rows != image->rows)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1002 | (void) FormatLocaleFile(stderr," @ %.20g,%.20g",(double) |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1003 | difference_image->page.x,(double) difference_image->page.y); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1004 | (void) FormatLocaleFile(stderr,"\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1005 | break; |
| 1006 | } |
| 1007 | case AbsoluteErrorMetric: |
cristy | 4c929a7 | 2010-11-24 18:54:42 +0000 | [diff] [blame] | 1008 | case NormalizedCrossCorrelationErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1009 | case PeakSignalToNoiseRatioMetric: |
| 1010 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1011 | (void) FormatLocaleFile(stderr,"%g",distortion); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1012 | if ((reconstruct_image->columns != image->columns) || |
| 1013 | (reconstruct_image->rows != image->rows)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1014 | (void) FormatLocaleFile(stderr," @ %.20g,%.20g",(double) |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1015 | difference_image->page.x,(double) difference_image->page.y); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1016 | (void) FormatLocaleFile(stderr,"\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1017 | break; |
| 1018 | } |
| 1019 | case MeanErrorPerPixelMetric: |
| 1020 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1021 | (void) FormatLocaleFile(stderr,"%g (%g, %g)",distortion, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1022 | image->error.normalized_mean_error, |
| 1023 | image->error.normalized_maximum_error); |
| 1024 | if ((reconstruct_image->columns != image->columns) || |
| 1025 | (reconstruct_image->rows != image->rows)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1026 | (void) FormatLocaleFile(stderr," @ %.20g,%.20g",(double) |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1027 | difference_image->page.x,(double) difference_image->page.y); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1028 | (void) FormatLocaleFile(stderr,"\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1029 | break; |
| 1030 | } |
| 1031 | case UndefinedMetric: |
| 1032 | break; |
| 1033 | } |
| 1034 | } |
| 1035 | else |
| 1036 | { |
| 1037 | double |
| 1038 | *channel_distortion; |
| 1039 | |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 1040 | channel_distortion=GetImageDistortions(image,reconstruct_image, |
cristy | c82a27b | 2011-10-21 01:07:16 +0000 | [diff] [blame] | 1041 | metric,exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1042 | (void) FormatLocaleFile(stderr,"Image: %s\n",image->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1043 | if ((reconstruct_image->columns != image->columns) || |
| 1044 | (reconstruct_image->rows != image->rows)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1045 | (void) FormatLocaleFile(stderr,"Offset: %.20g,%.20g\n",(double) |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1046 | difference_image->page.x,(double) difference_image->page.y); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1047 | (void) FormatLocaleFile(stderr," Channel distortion: %s\n", |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1048 | CommandOptionToMnemonic(MagickMetricOptions,(ssize_t) metric)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1049 | switch (metric) |
| 1050 | { |
cristy | 343eee9 | 2010-12-11 02:17:57 +0000 | [diff] [blame] | 1051 | case FuzzErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1052 | case MeanAbsoluteErrorMetric: |
| 1053 | case MeanSquaredErrorMetric: |
| 1054 | case RootMeanSquaredErrorMetric: |
| 1055 | case PeakAbsoluteErrorMetric: |
| 1056 | { |
| 1057 | switch (image->colorspace) |
| 1058 | { |
| 1059 | case RGBColorspace: |
| 1060 | default: |
| 1061 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1062 | (void) FormatLocaleFile(stderr," red: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1063 | QuantumRange*channel_distortion[RedPixelChannel], |
| 1064 | channel_distortion[RedPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1065 | (void) FormatLocaleFile(stderr," green: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1066 | QuantumRange*channel_distortion[GreenPixelChannel], |
| 1067 | channel_distortion[GreenPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1068 | (void) FormatLocaleFile(stderr," blue: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1069 | QuantumRange*channel_distortion[BluePixelChannel], |
| 1070 | channel_distortion[BluePixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1071 | if (image->matte != MagickFalse) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1072 | (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1073 | QuantumRange*channel_distortion[AlphaPixelChannel], |
| 1074 | channel_distortion[AlphaPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1075 | break; |
| 1076 | } |
| 1077 | case CMYKColorspace: |
| 1078 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1079 | (void) FormatLocaleFile(stderr," cyan: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1080 | QuantumRange*channel_distortion[CyanPixelChannel], |
| 1081 | channel_distortion[CyanPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1082 | (void) FormatLocaleFile(stderr," magenta: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1083 | QuantumRange*channel_distortion[MagentaPixelChannel], |
| 1084 | channel_distortion[MagentaPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1085 | (void) FormatLocaleFile(stderr," yellow: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1086 | QuantumRange*channel_distortion[YellowPixelChannel], |
| 1087 | channel_distortion[YellowPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1088 | (void) FormatLocaleFile(stderr," black: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1089 | QuantumRange*channel_distortion[BlackPixelChannel], |
| 1090 | channel_distortion[BlackPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1091 | if (image->matte != MagickFalse) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1092 | (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1093 | QuantumRange*channel_distortion[AlphaPixelChannel], |
| 1094 | channel_distortion[AlphaPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1095 | break; |
| 1096 | } |
| 1097 | case GRAYColorspace: |
| 1098 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1099 | (void) FormatLocaleFile(stderr," gray: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1100 | QuantumRange*channel_distortion[GrayPixelChannel], |
| 1101 | channel_distortion[GrayPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1102 | if (image->matte != MagickFalse) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1103 | (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1104 | QuantumRange*channel_distortion[AlphaPixelChannel], |
| 1105 | channel_distortion[AlphaPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1106 | break; |
| 1107 | } |
| 1108 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1109 | (void) FormatLocaleFile(stderr," all: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1110 | QuantumRange*channel_distortion[MaxPixelChannels], |
| 1111 | channel_distortion[MaxPixelChannels]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1112 | break; |
| 1113 | } |
| 1114 | case AbsoluteErrorMetric: |
cristy | 4c929a7 | 2010-11-24 18:54:42 +0000 | [diff] [blame] | 1115 | case NormalizedCrossCorrelationErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1116 | case PeakSignalToNoiseRatioMetric: |
| 1117 | { |
| 1118 | switch (image->colorspace) |
| 1119 | { |
| 1120 | case RGBColorspace: |
| 1121 | default: |
| 1122 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1123 | (void) FormatLocaleFile(stderr," red: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1124 | channel_distortion[RedPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1125 | (void) FormatLocaleFile(stderr," green: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1126 | channel_distortion[GreenPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1127 | (void) FormatLocaleFile(stderr," blue: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1128 | channel_distortion[BluePixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1129 | if (image->matte != MagickFalse) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1130 | (void) FormatLocaleFile(stderr," alpha: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1131 | channel_distortion[AlphaPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1132 | break; |
| 1133 | } |
| 1134 | case CMYKColorspace: |
| 1135 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1136 | (void) FormatLocaleFile(stderr," cyan: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1137 | channel_distortion[CyanPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1138 | (void) FormatLocaleFile(stderr," magenta: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1139 | channel_distortion[MagentaPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1140 | (void) FormatLocaleFile(stderr," yellow: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1141 | channel_distortion[YellowPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1142 | (void) FormatLocaleFile(stderr," black: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1143 | channel_distortion[BlackPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1144 | if (image->matte != MagickFalse) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1145 | (void) FormatLocaleFile(stderr," alpha: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1146 | channel_distortion[AlphaPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1147 | break; |
| 1148 | } |
| 1149 | case GRAYColorspace: |
| 1150 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1151 | (void) FormatLocaleFile(stderr," gray: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1152 | channel_distortion[GrayPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1153 | if (image->matte != MagickFalse) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1154 | (void) FormatLocaleFile(stderr," alpha: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1155 | channel_distortion[AlphaPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1156 | break; |
| 1157 | } |
| 1158 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1159 | (void) FormatLocaleFile(stderr," all: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1160 | channel_distortion[MaxPixelChannels]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1161 | break; |
| 1162 | } |
| 1163 | case MeanErrorPerPixelMetric: |
| 1164 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1165 | (void) FormatLocaleFile(stderr," %g (%g, %g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1166 | channel_distortion[MaxPixelChannels], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1167 | image->error.normalized_mean_error, |
| 1168 | image->error.normalized_maximum_error); |
| 1169 | break; |
| 1170 | } |
| 1171 | case UndefinedMetric: |
| 1172 | break; |
| 1173 | } |
| 1174 | channel_distortion=(double *) RelinquishMagickMemory( |
| 1175 | channel_distortion); |
| 1176 | } |
| 1177 | status&=WriteImages(image_info,difference_image,argv[argc-1],exception); |
| 1178 | if ((metadata != (char **) NULL) && (format != (char *) NULL)) |
| 1179 | { |
| 1180 | char |
| 1181 | *text; |
| 1182 | |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1183 | text=InterpretImageProperties(image_info,difference_image,format, |
| 1184 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1185 | if (text == (char *) NULL) |
| 1186 | ThrowCompareException(ResourceLimitError,"MemoryAllocationFailed", |
| 1187 | GetExceptionMessage(errno)); |
| 1188 | (void) ConcatenateString(&(*metadata),text); |
| 1189 | (void) ConcatenateString(&(*metadata),"\n"); |
| 1190 | text=DestroyString(text); |
| 1191 | } |
| 1192 | difference_image=DestroyImageList(difference_image); |
| 1193 | } |
| 1194 | DestroyCompare(); |
| 1195 | return(status != 0 ? MagickTrue : MagickFalse); |
| 1196 | } |