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 | 7e41fe8 | 2010-12-04 23:12:08 +0000 | [diff] [blame] | 20 | % Copyright 1999-2011 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 | */ |
| 44 | #include "wand/studio.h" |
| 45 | #include "wand/MagickWand.h" |
| 46 | #include "wand/mogrify-private.h" |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 47 | #include "magick/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 | % |
| 60 | % CompareImageCommand() compares two images and returns the difference between |
| 61 | % them as a distortion metric and as a new image visually annotating their |
| 62 | % differences. |
| 63 | % |
| 64 | % The format of the CompareImageCommand method is: |
| 65 | % |
| 66 | % MagickBooleanType CompareImageCommand(ImageInfo *image_info,int argc, |
| 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 | |
| 174 | WandExport MagickBooleanType CompareImageCommand(ImageInfo *image_info, |
| 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 | |
| 212 | ChannelType |
| 213 | channels; |
| 214 | |
| 215 | double |
| 216 | dissimilarity_threshold, |
| 217 | distortion, |
| 218 | similarity_metric; |
| 219 | |
| 220 | Image |
| 221 | *difference_image, |
| 222 | *image, |
| 223 | *reconstruct_image, |
| 224 | *similarity_image; |
| 225 | |
| 226 | ImageStack |
| 227 | image_stack[MaxImageStackDepth+1]; |
| 228 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 229 | MagickBooleanType |
| 230 | fire, |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 231 | pend, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 232 | respect_parenthesis, |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 233 | subimage_search; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 234 | |
| 235 | MagickStatusType |
| 236 | status; |
| 237 | |
| 238 | MetricType |
| 239 | metric; |
| 240 | |
| 241 | RectangleInfo |
| 242 | offset; |
| 243 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 244 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 245 | i; |
| 246 | |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 247 | ssize_t |
| 248 | j, |
| 249 | k; |
| 250 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 251 | /* |
| 252 | Set defaults. |
| 253 | */ |
| 254 | assert(image_info != (ImageInfo *) NULL); |
| 255 | assert(image_info->signature == MagickSignature); |
| 256 | if (image_info->debug != MagickFalse) |
| 257 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 258 | assert(exception != (ExceptionInfo *) NULL); |
| 259 | if (argc == 2) |
| 260 | { |
| 261 | option=argv[1]; |
| 262 | if ((LocaleCompare("version",option+1) == 0) || |
| 263 | (LocaleCompare("-version",option+1) == 0)) |
| 264 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 265 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 266 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame^] | 267 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 268 | GetMagickCopyright()); |
| 269 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 270 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 271 | return(MagickFalse); |
| 272 | } |
| 273 | } |
| 274 | if (argc < 3) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 275 | return(CompareUsage()); |
cristy | 9a9230e | 2011-04-26 14:56:14 +0000 | [diff] [blame] | 276 | channels=CompositeChannels; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 277 | difference_image=NewImageList(); |
| 278 | similarity_image=NewImageList(); |
| 279 | dissimilarity_threshold=DefaultDissimilarityThreshold; |
| 280 | distortion=0.0; |
| 281 | format=(char *) NULL; |
| 282 | j=1; |
| 283 | k=0; |
| 284 | metric=UndefinedMetric; |
| 285 | NewImageStack(); |
| 286 | option=(char *) NULL; |
| 287 | pend=MagickFalse; |
| 288 | reconstruct_image=NewImageList(); |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 289 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 290 | status=MagickTrue; |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 291 | subimage_search=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 292 | /* |
| 293 | Compare an image. |
| 294 | */ |
| 295 | ReadCommandlLine(argc,&argv); |
| 296 | status=ExpandFilenames(&argc,&argv); |
| 297 | if (status == MagickFalse) |
| 298 | ThrowCompareException(ResourceLimitError,"MemoryAllocationFailed", |
| 299 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 300 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 301 | { |
| 302 | option=argv[i]; |
| 303 | if (LocaleCompare(option,"(") == 0) |
| 304 | { |
| 305 | FireImageStack(MagickTrue,MagickTrue,pend); |
| 306 | if (k == MaxImageStackDepth) |
| 307 | ThrowCompareException(OptionError,"ParenthesisNestedTooDeeply", |
| 308 | option); |
| 309 | PushImageStack(); |
| 310 | continue; |
| 311 | } |
| 312 | if (LocaleCompare(option,")") == 0) |
| 313 | { |
| 314 | FireImageStack(MagickTrue,MagickTrue,MagickTrue); |
| 315 | if (k == 0) |
| 316 | ThrowCompareException(OptionError,"UnableToParseExpression",option); |
| 317 | PopImageStack(); |
| 318 | continue; |
| 319 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 320 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 321 | { |
| 322 | Image |
| 323 | *images; |
| 324 | |
| 325 | /* |
| 326 | Read input image. |
| 327 | */ |
| 328 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 329 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 330 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 331 | filename=argv[++i]; |
| 332 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 333 | images=ReadImages(image_info,exception); |
| 334 | status&=(images != (Image *) NULL) && |
| 335 | (exception->severity < ErrorException); |
| 336 | if (images == (Image *) NULL) |
| 337 | continue; |
| 338 | AppendImageStack(images); |
| 339 | continue; |
| 340 | } |
| 341 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 342 | switch (*(option+1)) |
| 343 | { |
| 344 | case 'a': |
| 345 | { |
| 346 | if (LocaleCompare("alpha",option+1) == 0) |
| 347 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 348 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 349 | type; |
| 350 | |
| 351 | if (*option == '+') |
| 352 | break; |
| 353 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 354 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 355 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 356 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 357 | if (type < 0) |
| 358 | ThrowCompareException(OptionError,"UnrecognizedAlphaChannelType", |
| 359 | argv[i]); |
| 360 | break; |
| 361 | } |
| 362 | if (LocaleCompare("authenticate",option+1) == 0) |
| 363 | { |
| 364 | if (*option == '+') |
| 365 | break; |
| 366 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 367 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 368 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 369 | break; |
| 370 | } |
| 371 | ThrowCompareException(OptionError,"UnrecognizedOption",option); |
| 372 | } |
| 373 | case 'c': |
| 374 | { |
| 375 | if (LocaleCompare("cache",option+1) == 0) |
| 376 | { |
| 377 | if (*option == '+') |
| 378 | break; |
| 379 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 380 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 381 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 382 | if (IsGeometry(argv[i]) == MagickFalse) |
| 383 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 384 | break; |
| 385 | } |
| 386 | if (LocaleCompare("channel",option+1) == 0) |
| 387 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 388 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 389 | channel; |
| 390 | |
| 391 | if (*option == '+') |
| 392 | break; |
| 393 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 394 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 395 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 396 | channel=ParseChannelOption(argv[i]); |
| 397 | if (channel < 0) |
| 398 | ThrowCompareException(OptionError,"UnrecognizedChannelType", |
| 399 | argv[i]); |
| 400 | channels=(ChannelType) channel; |
| 401 | break; |
| 402 | } |
| 403 | if (LocaleCompare("colorspace",option+1) == 0) |
| 404 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 405 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 406 | colorspace; |
| 407 | |
| 408 | if (*option == '+') |
| 409 | break; |
| 410 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 411 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 412 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 413 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 414 | argv[i]); |
| 415 | if (colorspace < 0) |
| 416 | ThrowCompareException(OptionError,"UnrecognizedColorspace", |
| 417 | argv[i]); |
| 418 | break; |
| 419 | } |
| 420 | if (LocaleCompare("compose",option+1) == 0) |
| 421 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 422 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 423 | compose; |
| 424 | |
| 425 | if (*option == '+') |
| 426 | break; |
| 427 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 428 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 429 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 430 | compose=ParseCommandOption(MagickComposeOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 431 | argv[i]); |
| 432 | if (compose < 0) |
| 433 | ThrowCompareException(OptionError,"UnrecognizedComposeOperator", |
| 434 | argv[i]); |
| 435 | break; |
| 436 | } |
| 437 | if (LocaleCompare("compress",option+1) == 0) |
| 438 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 439 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 440 | compress; |
| 441 | |
| 442 | if (*option == '+') |
| 443 | break; |
| 444 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 445 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 446 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 447 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 448 | argv[i]); |
| 449 | if (compress < 0) |
| 450 | ThrowCompareException(OptionError,"UnrecognizedImageCompression", |
| 451 | argv[i]); |
| 452 | break; |
| 453 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 454 | if (LocaleCompare("concurrent",option+1) == 0) |
| 455 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 456 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 457 | } |
| 458 | case 'd': |
| 459 | { |
| 460 | if (LocaleCompare("debug",option+1) == 0) |
| 461 | { |
| 462 | LogEventType |
| 463 | event_mask; |
| 464 | |
| 465 | if (*option == '+') |
| 466 | break; |
| 467 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 468 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 469 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 470 | event_mask=SetLogEventMask(argv[i]); |
| 471 | if (event_mask == UndefinedEvents) |
| 472 | ThrowCompareException(OptionError,"UnrecognizedEventType", |
| 473 | argv[i]); |
| 474 | break; |
| 475 | } |
| 476 | if (LocaleCompare("decipher",option+1) == 0) |
| 477 | { |
| 478 | if (*option == '+') |
| 479 | break; |
| 480 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 481 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 482 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 483 | break; |
| 484 | } |
| 485 | if (LocaleCompare("define",option+1) == 0) |
| 486 | { |
| 487 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 488 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 489 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 490 | if (*option == '+') |
| 491 | { |
| 492 | const char |
| 493 | *define; |
| 494 | |
| 495 | define=GetImageOption(image_info,argv[i]); |
| 496 | if (define == (const char *) NULL) |
| 497 | ThrowCompareException(OptionError,"NoSuchOption",argv[i]); |
| 498 | break; |
| 499 | } |
| 500 | break; |
| 501 | } |
| 502 | if (LocaleCompare("density",option+1) == 0) |
| 503 | { |
| 504 | if (*option == '+') |
| 505 | break; |
| 506 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 507 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 508 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 509 | if (IsGeometry(argv[i]) == MagickFalse) |
| 510 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 511 | break; |
| 512 | } |
| 513 | if (LocaleCompare("depth",option+1) == 0) |
| 514 | { |
| 515 | if (*option == '+') |
| 516 | break; |
| 517 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 518 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 519 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 520 | if (IsGeometry(argv[i]) == MagickFalse) |
| 521 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 522 | break; |
| 523 | } |
| 524 | if (LocaleCompare("dissimilarity-threshold",option+1) == 0) |
| 525 | { |
| 526 | if (*option == '+') |
| 527 | break; |
| 528 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 529 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 530 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 531 | if (IsGeometry(argv[i]) == MagickFalse) |
| 532 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 533 | if (*option == '+') |
| 534 | dissimilarity_threshold=DefaultDissimilarityThreshold; |
| 535 | else |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 536 | dissimilarity_threshold=LocaleToDouble(argv[i],(char **) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 537 | break; |
| 538 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 539 | if (LocaleCompare("duration",option+1) == 0) |
| 540 | { |
| 541 | if (*option == '+') |
| 542 | break; |
| 543 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 544 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 545 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 546 | if (IsGeometry(argv[i]) == MagickFalse) |
| 547 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 548 | break; |
| 549 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 550 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 551 | } |
| 552 | case 'e': |
| 553 | { |
| 554 | if (LocaleCompare("encipher",option+1) == 0) |
| 555 | { |
| 556 | if (*option == '+') |
| 557 | break; |
| 558 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 559 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 560 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 561 | break; |
| 562 | } |
| 563 | if (LocaleCompare("extract",option+1) == 0) |
| 564 | { |
| 565 | if (*option == '+') |
| 566 | break; |
| 567 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 568 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 569 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 570 | if (IsGeometry(argv[i]) == MagickFalse) |
| 571 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 572 | break; |
| 573 | } |
| 574 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 575 | } |
| 576 | case 'f': |
| 577 | { |
| 578 | if (LocaleCompare("format",option+1) == 0) |
| 579 | { |
| 580 | if (*option == '+') |
| 581 | break; |
| 582 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 583 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 584 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 585 | format=argv[i]; |
| 586 | break; |
| 587 | } |
| 588 | if (LocaleCompare("fuzz",option+1) == 0) |
| 589 | { |
| 590 | if (*option == '+') |
| 591 | break; |
| 592 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 593 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 594 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 595 | if (IsGeometry(argv[i]) == MagickFalse) |
| 596 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 597 | break; |
| 598 | } |
| 599 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 600 | } |
| 601 | case 'h': |
| 602 | { |
| 603 | if ((LocaleCompare("help",option+1) == 0) || |
| 604 | (LocaleCompare("-help",option+1) == 0)) |
| 605 | return(CompareUsage()); |
| 606 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 607 | { |
| 608 | if (*option == '+') |
| 609 | break; |
| 610 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 611 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 612 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 613 | break; |
| 614 | } |
| 615 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 616 | } |
| 617 | case 'i': |
| 618 | { |
| 619 | if (LocaleCompare("identify",option+1) == 0) |
| 620 | break; |
| 621 | if (LocaleCompare("interlace",option+1) == 0) |
| 622 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 623 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 624 | interlace; |
| 625 | |
| 626 | if (*option == '+') |
| 627 | break; |
| 628 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 629 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 630 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 631 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 632 | argv[i]); |
| 633 | if (interlace < 0) |
| 634 | ThrowCompareException(OptionError,"UnrecognizedInterlaceType", |
| 635 | argv[i]); |
| 636 | break; |
| 637 | } |
| 638 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 639 | } |
| 640 | case 'l': |
| 641 | { |
| 642 | if (LocaleCompare("limit",option+1) == 0) |
| 643 | { |
| 644 | char |
| 645 | *p; |
| 646 | |
| 647 | double |
| 648 | value; |
| 649 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 650 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 651 | resource; |
| 652 | |
| 653 | if (*option == '+') |
| 654 | break; |
| 655 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 656 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 657 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 658 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 659 | argv[i]); |
| 660 | if (resource < 0) |
| 661 | ThrowCompareException(OptionError,"UnrecognizedResourceType", |
| 662 | argv[i]); |
| 663 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 664 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 665 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 666 | value=LocaleToDouble(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 667 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 668 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 669 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 670 | break; |
| 671 | } |
| 672 | if (LocaleCompare("list",option+1) == 0) |
| 673 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 674 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 675 | list; |
| 676 | |
| 677 | if (*option == '+') |
| 678 | break; |
| 679 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 680 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 681 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 682 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 683 | if (list < 0) |
| 684 | ThrowCompareException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 685 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 686 | argv+j,exception); |
| 687 | DestroyCompare(); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 688 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 689 | } |
| 690 | if (LocaleCompare("log",option+1) == 0) |
| 691 | { |
| 692 | if (*option == '+') |
| 693 | break; |
| 694 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 695 | if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 696 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 697 | break; |
| 698 | } |
| 699 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 700 | { |
| 701 | if (*option == '+') |
| 702 | break; |
| 703 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 704 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 705 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 706 | break; |
| 707 | } |
| 708 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 709 | } |
| 710 | case 'm': |
| 711 | { |
| 712 | if (LocaleCompare("matte",option+1) == 0) |
| 713 | break; |
| 714 | if (LocaleCompare("metric",option+1) == 0) |
| 715 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 716 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 717 | type; |
| 718 | |
| 719 | if (*option == '+') |
| 720 | break; |
| 721 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 722 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 723 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 724 | type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 725 | if (type < 0) |
| 726 | ThrowCompareException(OptionError,"UnrecognizedMetricType", |
| 727 | argv[i]); |
| 728 | metric=(MetricType) type; |
| 729 | break; |
| 730 | } |
| 731 | if (LocaleCompare("monitor",option+1) == 0) |
| 732 | break; |
| 733 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 734 | } |
| 735 | case 'p': |
| 736 | { |
| 737 | if (LocaleCompare("passphrase",option+1) == 0) |
| 738 | { |
| 739 | if (*option == '+') |
| 740 | break; |
| 741 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 742 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 743 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 744 | break; |
| 745 | } |
| 746 | if (LocaleCompare("profile",option+1) == 0) |
| 747 | { |
| 748 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 749 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 750 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 751 | break; |
| 752 | } |
| 753 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 754 | } |
| 755 | case 'q': |
| 756 | { |
| 757 | if (LocaleCompare("quality",option+1) == 0) |
| 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); |
| 764 | if (IsGeometry(argv[i]) == MagickFalse) |
| 765 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 766 | break; |
| 767 | } |
| 768 | if (LocaleCompare("quantize",option+1) == 0) |
| 769 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 770 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 771 | colorspace; |
| 772 | |
| 773 | if (*option == '+') |
| 774 | break; |
| 775 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 776 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 777 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 778 | colorspace=ParseCommandOption(MagickColorspaceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 779 | MagickFalse,argv[i]); |
| 780 | if (colorspace < 0) |
| 781 | ThrowCompareException(OptionError,"UnrecognizedColorspace", |
| 782 | argv[i]); |
| 783 | break; |
| 784 | } |
| 785 | if (LocaleCompare("quiet",option+1) == 0) |
| 786 | break; |
| 787 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 788 | } |
| 789 | case 'r': |
| 790 | { |
| 791 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 792 | break; |
| 793 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 794 | { |
| 795 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 796 | break; |
| 797 | } |
| 798 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 799 | } |
| 800 | case 's': |
| 801 | { |
| 802 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 803 | { |
| 804 | if (*option == '+') |
| 805 | break; |
| 806 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 807 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 808 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 809 | if (IsGeometry(argv[i]) == MagickFalse) |
| 810 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 811 | break; |
| 812 | } |
| 813 | if (LocaleCompare("seed",option+1) == 0) |
| 814 | { |
| 815 | if (*option == '+') |
| 816 | break; |
| 817 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 818 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 819 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 820 | if (IsGeometry(argv[i]) == MagickFalse) |
| 821 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 822 | break; |
| 823 | } |
| 824 | if (LocaleCompare("set",option+1) == 0) |
| 825 | { |
| 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 (*option == '+') |
| 830 | break; |
| 831 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 832 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 833 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 834 | break; |
| 835 | } |
| 836 | if (LocaleCompare("size",option+1) == 0) |
| 837 | { |
| 838 | if (*option == '+') |
| 839 | break; |
| 840 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 841 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 842 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 843 | if (IsGeometry(argv[i]) == MagickFalse) |
| 844 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 845 | break; |
| 846 | } |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 847 | if (LocaleCompare("subimage-search",option+1) == 0) |
| 848 | { |
| 849 | if (*option == '+') |
| 850 | { |
| 851 | subimage_search=MagickFalse; |
| 852 | break; |
| 853 | } |
| 854 | subimage_search=MagickTrue; |
| 855 | break; |
| 856 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 857 | if (LocaleCompare("synchronize",option+1) == 0) |
| 858 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 859 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 860 | } |
| 861 | case 't': |
| 862 | { |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 863 | if (LocaleCompare("taint",option+1) == 0) |
| 864 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 865 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 866 | { |
| 867 | if (*option == '+') |
| 868 | break; |
| 869 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 870 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 871 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 872 | break; |
| 873 | } |
| 874 | if (LocaleCompare("type",option+1) == 0) |
| 875 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 876 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 877 | type; |
| 878 | |
| 879 | if (*option == '+') |
| 880 | break; |
| 881 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 882 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 883 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 884 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 885 | if (type < 0) |
| 886 | ThrowCompareException(OptionError,"UnrecognizedImageType", |
| 887 | argv[i]); |
| 888 | break; |
| 889 | } |
| 890 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 891 | } |
| 892 | case 'v': |
| 893 | { |
| 894 | if (LocaleCompare("verbose",option+1) == 0) |
| 895 | break; |
| 896 | if ((LocaleCompare("version",option+1) == 0) || |
| 897 | (LocaleCompare("-version",option+1) == 0)) |
| 898 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 899 | (void) FormatLocaleFile(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 900 | GetMagickVersion((size_t *) NULL)); |
cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame^] | 901 | (void) FormatLocaleFile(stdout,"Copyright: %s\n", |
| 902 | GetMagickCopyright()); |
| 903 | (void) FormatLocaleFile(stdout,"Features: %s\n\n", |
| 904 | GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 905 | break; |
| 906 | } |
| 907 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 908 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 909 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 910 | method; |
| 911 | |
| 912 | if (*option == '+') |
| 913 | break; |
| 914 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 915 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 916 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 917 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 918 | argv[i]); |
| 919 | if (method < 0) |
| 920 | ThrowCompareException(OptionError, |
| 921 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 922 | break; |
| 923 | } |
| 924 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 925 | } |
| 926 | case '?': |
| 927 | break; |
| 928 | default: |
| 929 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 930 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 931 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 932 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 933 | if (fire != MagickFalse) |
| 934 | FireImageStack(MagickTrue,MagickTrue,MagickTrue); |
| 935 | } |
| 936 | if (k != 0) |
| 937 | ThrowCompareException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 938 | if (i-- != (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 939 | ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); |
| 940 | if ((image == (Image *) NULL) || (GetImageListLength(image) < 2)) |
| 941 | ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); |
| 942 | FinalizeImageSettings(image_info,image,MagickTrue); |
cristy | 94f2007 | 2009-09-12 02:12:36 +0000 | [diff] [blame] | 943 | if ((image == (Image *) NULL) || (GetImageListLength(image) < 2)) |
| 944 | ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 945 | image=GetImageFromList(image,0); |
| 946 | reconstruct_image=GetImageFromList(image,1); |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 947 | if (subimage_search != MagickFalse) |
| 948 | { |
| 949 | similarity_image=SimilarityImage(image,reconstruct_image,&offset, |
| 950 | &similarity_metric,exception); |
| 951 | if (similarity_metric > dissimilarity_threshold) |
| 952 | ThrowCompareException(ImageError,"ImagesTooDissimilar",image->filename); |
| 953 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 954 | if ((reconstruct_image->columns == image->columns) && |
| 955 | (reconstruct_image->rows == image->rows)) |
| 956 | difference_image=CompareImageChannels(image,reconstruct_image,channels, |
| 957 | metric,&distortion,exception); |
| 958 | else |
cristy | fdad905 | 2010-08-15 20:15:35 +0000 | [diff] [blame] | 959 | if (similarity_image == (Image *) NULL) |
| 960 | ThrowCompareException(OptionError,"ImageWidthsOrHeightsDiffer", |
| 961 | image->filename) |
| 962 | else |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 963 | { |
| 964 | Image |
| 965 | *composite_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 966 | |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 967 | /* |
| 968 | Determine if reconstructed image is a subimage of the image. |
| 969 | */ |
| 970 | composite_image=CloneImage(image,0,0,MagickTrue,exception); |
| 971 | if (composite_image == (Image *) NULL) |
| 972 | difference_image=CompareImageChannels(image,reconstruct_image, |
| 973 | channels,metric,&distortion,exception); |
| 974 | else |
| 975 | { |
| 976 | (void) CompositeImage(composite_image,CopyCompositeOp, |
| 977 | reconstruct_image,offset.x,offset.y); |
| 978 | difference_image=CompareImageChannels(image,composite_image, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 979 | channels,metric,&distortion,exception); |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 980 | if (difference_image != (Image *) NULL) |
| 981 | { |
| 982 | difference_image->page.x=offset.x; |
| 983 | difference_image->page.y=offset.y; |
| 984 | } |
| 985 | composite_image=DestroyImage(composite_image); |
| 986 | } |
| 987 | if (difference_image != (Image *) NULL) |
| 988 | { |
| 989 | AppendImageToList(&difference_image,similarity_image); |
| 990 | similarity_image=(Image *) NULL; |
| 991 | } |
| 992 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 993 | if (difference_image == (Image *) NULL) |
| 994 | status=0; |
| 995 | else |
| 996 | { |
| 997 | if (image_info->verbose != MagickFalse) |
| 998 | (void) IsImagesEqual(image,reconstruct_image); |
| 999 | if (*difference_image->magick == '\0') |
| 1000 | (void) CopyMagickString(difference_image->magick,image->magick, |
| 1001 | MaxTextExtent); |
| 1002 | if (image_info->verbose == MagickFalse) |
| 1003 | { |
| 1004 | switch (metric) |
| 1005 | { |
cristy | 343eee9 | 2010-12-11 02:17:57 +0000 | [diff] [blame] | 1006 | case FuzzErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1007 | case MeanAbsoluteErrorMetric: |
| 1008 | case MeanSquaredErrorMetric: |
| 1009 | case RootMeanSquaredErrorMetric: |
| 1010 | case PeakAbsoluteErrorMetric: |
| 1011 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1012 | (void) FormatLocaleFile(stderr,"%g (%g)",QuantumRange*distortion, |
cristy | 8cd5b31 | 2010-01-07 01:10:24 +0000 | [diff] [blame] | 1013 | (double) distortion); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1014 | if ((reconstruct_image->columns != image->columns) || |
| 1015 | (reconstruct_image->rows != image->rows)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1016 | (void) FormatLocaleFile(stderr," @ %.20g,%.20g",(double) |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1017 | difference_image->page.x,(double) difference_image->page.y); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1018 | (void) FormatLocaleFile(stderr,"\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1019 | break; |
| 1020 | } |
| 1021 | case AbsoluteErrorMetric: |
cristy | 4c929a7 | 2010-11-24 18:54:42 +0000 | [diff] [blame] | 1022 | case NormalizedCrossCorrelationErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1023 | case PeakSignalToNoiseRatioMetric: |
| 1024 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1025 | (void) FormatLocaleFile(stderr,"%g",distortion); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1026 | if ((reconstruct_image->columns != image->columns) || |
| 1027 | (reconstruct_image->rows != image->rows)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1028 | (void) FormatLocaleFile(stderr," @ %.20g,%.20g",(double) |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1029 | difference_image->page.x,(double) difference_image->page.y); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1030 | (void) FormatLocaleFile(stderr,"\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1031 | break; |
| 1032 | } |
| 1033 | case MeanErrorPerPixelMetric: |
| 1034 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1035 | (void) FormatLocaleFile(stderr,"%g (%g, %g)",distortion, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1036 | image->error.normalized_mean_error, |
| 1037 | image->error.normalized_maximum_error); |
| 1038 | if ((reconstruct_image->columns != image->columns) || |
| 1039 | (reconstruct_image->rows != image->rows)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1040 | (void) FormatLocaleFile(stderr," @ %.20g,%.20g",(double) |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1041 | difference_image->page.x,(double) difference_image->page.y); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1042 | (void) FormatLocaleFile(stderr,"\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1043 | break; |
| 1044 | } |
| 1045 | case UndefinedMetric: |
| 1046 | break; |
| 1047 | } |
| 1048 | } |
| 1049 | else |
| 1050 | { |
| 1051 | double |
| 1052 | *channel_distortion; |
| 1053 | |
| 1054 | channel_distortion=GetImageChannelDistortions(image,reconstruct_image, |
| 1055 | metric,&image->exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1056 | (void) FormatLocaleFile(stderr,"Image: %s\n",image->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1057 | if ((reconstruct_image->columns != image->columns) || |
| 1058 | (reconstruct_image->rows != image->rows)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1059 | (void) FormatLocaleFile(stderr,"Offset: %.20g,%.20g\n",(double) |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1060 | difference_image->page.x,(double) difference_image->page.y); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1061 | (void) FormatLocaleFile(stderr," Channel distortion: %s\n", |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1062 | CommandOptionToMnemonic(MagickMetricOptions,(ssize_t) metric)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1063 | switch (metric) |
| 1064 | { |
cristy | 343eee9 | 2010-12-11 02:17:57 +0000 | [diff] [blame] | 1065 | case FuzzErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1066 | case MeanAbsoluteErrorMetric: |
| 1067 | case MeanSquaredErrorMetric: |
| 1068 | case RootMeanSquaredErrorMetric: |
| 1069 | case PeakAbsoluteErrorMetric: |
| 1070 | { |
| 1071 | switch (image->colorspace) |
| 1072 | { |
| 1073 | case RGBColorspace: |
| 1074 | default: |
| 1075 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1076 | (void) FormatLocaleFile(stderr," red: %g (%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1077 | QuantumRange*channel_distortion[RedChannel], |
| 1078 | channel_distortion[RedChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1079 | (void) FormatLocaleFile(stderr," green: %g (%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1080 | QuantumRange*channel_distortion[GreenChannel], |
| 1081 | channel_distortion[GreenChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1082 | (void) FormatLocaleFile(stderr," blue: %g (%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1083 | QuantumRange*channel_distortion[BlueChannel], |
| 1084 | channel_distortion[BlueChannel]); |
| 1085 | if (image->matte != MagickFalse) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1086 | (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1087 | QuantumRange*channel_distortion[OpacityChannel], |
| 1088 | channel_distortion[OpacityChannel]); |
| 1089 | break; |
| 1090 | } |
| 1091 | case CMYKColorspace: |
| 1092 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1093 | (void) FormatLocaleFile(stderr," cyan: %g (%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1094 | QuantumRange*channel_distortion[CyanChannel], |
| 1095 | channel_distortion[CyanChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1096 | (void) FormatLocaleFile(stderr," magenta: %g (%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1097 | QuantumRange*channel_distortion[MagentaChannel], |
| 1098 | channel_distortion[MagentaChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1099 | (void) FormatLocaleFile(stderr," yellow: %g (%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1100 | QuantumRange*channel_distortion[YellowChannel], |
| 1101 | channel_distortion[YellowChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1102 | (void) FormatLocaleFile(stderr," black: %g (%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1103 | QuantumRange*channel_distortion[BlackChannel], |
| 1104 | channel_distortion[BlackChannel]); |
| 1105 | if (image->matte != MagickFalse) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1106 | (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1107 | QuantumRange*channel_distortion[OpacityChannel], |
| 1108 | channel_distortion[OpacityChannel]); |
| 1109 | break; |
| 1110 | } |
| 1111 | case GRAYColorspace: |
| 1112 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1113 | (void) FormatLocaleFile(stderr," gray: %g (%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1114 | QuantumRange*channel_distortion[GrayChannel], |
| 1115 | channel_distortion[GrayChannel]); |
| 1116 | if (image->matte != MagickFalse) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1117 | (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1118 | QuantumRange*channel_distortion[OpacityChannel], |
| 1119 | channel_distortion[OpacityChannel]); |
| 1120 | break; |
| 1121 | } |
| 1122 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1123 | (void) FormatLocaleFile(stderr," all: %g (%g)\n", |
cristy | 9a9230e | 2011-04-26 14:56:14 +0000 | [diff] [blame] | 1124 | QuantumRange*channel_distortion[CompositeChannels], |
| 1125 | channel_distortion[CompositeChannels]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1126 | break; |
| 1127 | } |
| 1128 | case AbsoluteErrorMetric: |
cristy | 4c929a7 | 2010-11-24 18:54:42 +0000 | [diff] [blame] | 1129 | case NormalizedCrossCorrelationErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1130 | case PeakSignalToNoiseRatioMetric: |
| 1131 | { |
| 1132 | switch (image->colorspace) |
| 1133 | { |
| 1134 | case RGBColorspace: |
| 1135 | default: |
| 1136 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1137 | (void) FormatLocaleFile(stderr," red: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1138 | channel_distortion[RedChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1139 | (void) FormatLocaleFile(stderr," green: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1140 | channel_distortion[GreenChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1141 | (void) FormatLocaleFile(stderr," blue: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1142 | channel_distortion[BlueChannel]); |
| 1143 | if (image->matte != MagickFalse) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1144 | (void) FormatLocaleFile(stderr," alpha: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1145 | channel_distortion[OpacityChannel]); |
| 1146 | break; |
| 1147 | } |
| 1148 | case CMYKColorspace: |
| 1149 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1150 | (void) FormatLocaleFile(stderr," cyan: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1151 | channel_distortion[CyanChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1152 | (void) FormatLocaleFile(stderr," magenta: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1153 | channel_distortion[MagentaChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1154 | (void) FormatLocaleFile(stderr," yellow: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1155 | channel_distortion[YellowChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1156 | (void) FormatLocaleFile(stderr," black: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1157 | channel_distortion[BlackChannel]); |
| 1158 | if (image->matte != MagickFalse) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1159 | (void) FormatLocaleFile(stderr," alpha: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1160 | channel_distortion[OpacityChannel]); |
| 1161 | break; |
| 1162 | } |
| 1163 | case GRAYColorspace: |
| 1164 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1165 | (void) FormatLocaleFile(stderr," gray: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1166 | channel_distortion[GrayChannel]); |
| 1167 | if (image->matte != MagickFalse) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1168 | (void) FormatLocaleFile(stderr," alpha: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1169 | channel_distortion[OpacityChannel]); |
| 1170 | break; |
| 1171 | } |
| 1172 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1173 | (void) FormatLocaleFile(stderr," all: %g\n", |
cristy | 9a9230e | 2011-04-26 14:56:14 +0000 | [diff] [blame] | 1174 | channel_distortion[CompositeChannels]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1175 | break; |
| 1176 | } |
| 1177 | case MeanErrorPerPixelMetric: |
| 1178 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1179 | (void) FormatLocaleFile(stderr," %g (%g, %g)\n", |
cristy | 9a9230e | 2011-04-26 14:56:14 +0000 | [diff] [blame] | 1180 | channel_distortion[CompositeChannels], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1181 | image->error.normalized_mean_error, |
| 1182 | image->error.normalized_maximum_error); |
| 1183 | break; |
| 1184 | } |
| 1185 | case UndefinedMetric: |
| 1186 | break; |
| 1187 | } |
| 1188 | channel_distortion=(double *) RelinquishMagickMemory( |
| 1189 | channel_distortion); |
| 1190 | } |
| 1191 | status&=WriteImages(image_info,difference_image,argv[argc-1],exception); |
| 1192 | if ((metadata != (char **) NULL) && (format != (char *) NULL)) |
| 1193 | { |
| 1194 | char |
| 1195 | *text; |
| 1196 | |
| 1197 | text=InterpretImageProperties(image_info,difference_image,format); |
| 1198 | if (text == (char *) NULL) |
| 1199 | ThrowCompareException(ResourceLimitError,"MemoryAllocationFailed", |
| 1200 | GetExceptionMessage(errno)); |
| 1201 | (void) ConcatenateString(&(*metadata),text); |
| 1202 | (void) ConcatenateString(&(*metadata),"\n"); |
| 1203 | text=DestroyString(text); |
| 1204 | } |
| 1205 | difference_image=DestroyImageList(difference_image); |
| 1206 | } |
| 1207 | DestroyCompare(); |
| 1208 | return(status != 0 ? MagickTrue : MagickFalse); |
| 1209 | } |