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 % |
cristy | de984cd | 2013-12-01 14:49:27 +0000 | [diff] [blame] | 16 | % Cristy % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 17 | % December 2003 % |
| 18 | % % |
| 19 | % % |
Cristy | f6ff9ea | 2016-12-05 09:53:35 -0500 | [diff] [blame] | 20 | % Copyright 1999-2017 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 | % % |
Cristy | f19d414 | 2017-04-24 11:34:30 -0400 | [diff] [blame] | 26 | % https://www.imagemagick.org/script/license.php % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | { |
cristy | 17ada02 | 2014-11-07 22:12:23 +0000 | [diff] [blame] | 91 | "-channel mask set the image channel mask", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 92 | "-debug events display copious debugging information", |
| 93 | "-help print program options", |
| 94 | "-list type print a list of supported option arguments", |
| 95 | "-log format format of debugging information", |
| 96 | (char *) NULL |
| 97 | }, |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 98 | *operators[]= |
| 99 | { |
| 100 | "-brightness-contrast geometry", |
| 101 | " improve brightness / contrast of the image", |
| 102 | "-distort method args", |
Cristy | 002b27d | 2017-05-16 21:13:16 -0400 | [diff] [blame] | 103 | " distort images according to given method and args", |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 104 | "-level value adjust the level of image contrast", |
| 105 | "-resize geometry resize the image", |
| 106 | "-rotate degrees apply Paeth rotation to the image", |
| 107 | "-sigmoidal-contrast geometry", |
| 108 | " increase the contrast without saturating highlights or", |
Cristy | cd1c527 | 2017-05-16 21:11:13 -0400 | [diff] [blame] | 109 | "-trim trim image edges", |
| 110 | (char *) NULL |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 111 | }, |
| 112 | *sequence_operators[]= |
| 113 | { |
Cristy | cd1c527 | 2017-05-16 21:11:13 -0400 | [diff] [blame] | 114 | "-crop geometry cut out a rectangular region of the image", |
| 115 | (char *) NULL |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 116 | }, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 117 | *settings[]= |
| 118 | { |
| 119 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 120 | " transparent, extract, background, or shape", |
| 121 | "-authenticate password", |
| 122 | " decipher image with this password", |
Cristy | 63571f7 | 2017-05-17 15:11:19 -0400 | [diff] [blame] | 123 | "-background color background color", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 124 | "-colorspace type alternate image colorspace", |
| 125 | "-compose operator set image composite operator", |
| 126 | "-compress type type of pixel compression when writing the image", |
| 127 | "-decipher filename convert cipher pixels to plain pixels", |
| 128 | "-define format:option", |
| 129 | " define one or more image format options", |
| 130 | "-density geometry horizontal and vertical density of the image", |
| 131 | "-depth value image depth", |
| 132 | "-dissimilarity-threshold value", |
cristy | ba029a5 | 2010-11-27 02:18:26 +0000 | [diff] [blame] | 133 | " maximum distortion for (sub)image match", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 134 | "-encipher filename convert plain pixels to cipher pixels", |
| 135 | "-extract geometry extract area from image", |
| 136 | "-format \"string\" output formatted image characteristics", |
| 137 | "-fuzz distance colors within this distance are considered equal", |
| 138 | "-highlight-color color", |
| 139 | " empasize pixel differences with this color", |
| 140 | "-identify identify the format and characteristics of the image", |
| 141 | "-interlace type type of image interlacing scheme", |
| 142 | "-limit type value pixel cache resource limit", |
| 143 | "-lowlight-color color", |
| 144 | " de-emphasize pixel differences with this color", |
| 145 | "-metric type measure differences between images with this metric", |
| 146 | "-monitor monitor progress", |
Cristy | 6e6ce01 | 2016-11-26 19:00:03 -0500 | [diff] [blame] | 147 | "-negate replace every pixel with its complementary color ", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 148 | "-profile filename add, delete, or apply an image profile", |
| 149 | "-quality value JPEG/MIFF/PNG compression level", |
| 150 | "-quiet suppress all warning messages", |
| 151 | "-quantize colorspace reduce colors in this colorspace", |
Cristy | 55d3c44 | 2016-12-02 19:46:34 -0500 | [diff] [blame] | 152 | "-read-mask filename associate a read mask with the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 153 | "-regard-warnings pay attention to warning messages", |
| 154 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 155 | "-sampling-factor geometry", |
| 156 | " horizontal and vertical sampling factor", |
| 157 | "-seed value seed a new sequence of pseudo-random numbers", |
| 158 | "-set attribute value set an image attribute", |
| 159 | "-quality value JPEG/MIFF/PNG compression level", |
Cristy | d9589b1 | 2017-05-19 07:12:51 -0400 | [diff] [blame] | 160 | "-repage geometry size and location of an image canvas", |
cristy | 0ad4ab2 | 2013-03-15 01:14:59 +0000 | [diff] [blame] | 161 | "-similarity-threshold value", |
| 162 | " minimum distortion for (sub)image match", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 163 | "-size geometry width and height of image", |
cristy | b949804 | 2010-08-09 01:14:07 +0000 | [diff] [blame] | 164 | "-subimage-search search for subimage", |
cristy | e9252c2 | 2013-07-30 15:43:21 +0000 | [diff] [blame] | 165 | "-synchronize synchronize image to storage device", |
| 166 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 167 | "-transparent-color color", |
| 168 | " transparent color", |
| 169 | "-type type image type", |
| 170 | "-verbose print detailed information about the image", |
| 171 | "-version print version information", |
| 172 | "-virtual-pixel method", |
| 173 | " virtual pixel access method", |
Cristy | 55d3c44 | 2016-12-02 19:46:34 -0500 | [diff] [blame] | 174 | "-write-mask filename associate a write mask with the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 175 | (char *) NULL |
| 176 | }; |
| 177 | |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 178 | ListMagickVersion(stdout); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 179 | (void) printf("Usage: %s [options ...] image reconstruct difference\n", |
| 180 | GetClientName()); |
| 181 | (void) printf("\nImage Settings:\n"); |
| 182 | for (p=settings; *p != (char *) NULL; p++) |
| 183 | (void) printf(" %s\n",*p); |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 184 | (void) printf("\nImage Operators:\n"); |
| 185 | for (p=operators; *p != (char *) NULL; p++) |
| 186 | (void) printf(" %s\n",*p); |
| 187 | (void) printf("\nImage Sequence Operators:\n"); |
| 188 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 189 | (void) printf(" %s\n",*p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 190 | (void) printf("\nMiscellaneous Options:\n"); |
| 191 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 192 | (void) printf(" %s\n",*p); |
| 193 | (void) printf( |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 194 | "\nBy default, the image format of 'file' is determined by its magic\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 195 | (void) printf( |
| 196 | "number. To specify a particular image format, precede the filename\n"); |
| 197 | (void) printf( |
| 198 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 199 | (void) printf( |
| 200 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 201 | (void) printf("'-' for standard input or output.\n"); |
| 202 | return(MagickFalse); |
| 203 | } |
| 204 | |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 205 | WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 206 | int argc,char **argv,char **metadata,ExceptionInfo *exception) |
| 207 | { |
cristy | 2cb55d5 | 2013-07-10 22:20:51 +0000 | [diff] [blame] | 208 | #define CompareEpsilon (1.0e-06) |
cristy | 2b70e80 | 2009-11-23 19:40:25 +0000 | [diff] [blame] | 209 | #define DefaultDissimilarityThreshold 0.31830988618379067154 |
cristy | 7691e47 | 2013-04-28 01:48:12 +0000 | [diff] [blame] | 210 | #define DefaultSimilarityThreshold (-1.0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 211 | #define DestroyCompare() \ |
| 212 | { \ |
| 213 | if (similarity_image != (Image *) NULL) \ |
| 214 | similarity_image=DestroyImageList(similarity_image); \ |
| 215 | if (difference_image != (Image *) NULL) \ |
| 216 | difference_image=DestroyImageList(difference_image); \ |
| 217 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 218 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 219 | argv[i]=DestroyString(argv[i]); \ |
| 220 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 221 | } |
| 222 | #define ThrowCompareException(asperity,tag,option) \ |
| 223 | { \ |
| 224 | if (exception->severity < (asperity)) \ |
| 225 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag, \ |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 226 | "`%s'",option); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 227 | DestroyCompare(); \ |
| 228 | return(MagickFalse); \ |
| 229 | } |
| 230 | #define ThrowCompareInvalidArgumentException(option,argument) \ |
| 231 | { \ |
| 232 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
anthony | e5b3965 | 2012-04-21 05:37:29 +0000 | [diff] [blame] | 233 | "InvalidArgument","'%s': %s",option,argument); \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 234 | DestroyCompare(); \ |
| 235 | return(MagickFalse); \ |
| 236 | } |
| 237 | |
| 238 | char |
| 239 | *filename, |
| 240 | *option; |
| 241 | |
| 242 | const char |
| 243 | *format; |
| 244 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 245 | double |
| 246 | dissimilarity_threshold, |
| 247 | distortion, |
cristy | 4dab380 | 2013-03-15 22:08:15 +0000 | [diff] [blame] | 248 | similarity_metric, |
| 249 | similarity_threshold; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 250 | |
| 251 | Image |
| 252 | *difference_image, |
| 253 | *image, |
| 254 | *reconstruct_image, |
| 255 | *similarity_image; |
| 256 | |
| 257 | ImageStack |
| 258 | image_stack[MaxImageStackDepth+1]; |
| 259 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 260 | MagickBooleanType |
| 261 | fire, |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 262 | pend, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 263 | respect_parenthesis, |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 264 | subimage_search; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 265 | |
| 266 | MagickStatusType |
| 267 | status; |
| 268 | |
| 269 | MetricType |
| 270 | metric; |
| 271 | |
| 272 | RectangleInfo |
| 273 | offset; |
| 274 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 275 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 276 | i; |
| 277 | |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 278 | ssize_t |
| 279 | j, |
| 280 | k; |
| 281 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 282 | /* |
| 283 | Set defaults. |
| 284 | */ |
| 285 | assert(image_info != (ImageInfo *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 286 | assert(image_info->signature == MagickCoreSignature); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 287 | if (image_info->debug != MagickFalse) |
| 288 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 289 | assert(exception != (ExceptionInfo *) NULL); |
| 290 | if (argc == 2) |
| 291 | { |
| 292 | option=argv[1]; |
| 293 | if ((LocaleCompare("version",option+1) == 0) || |
| 294 | (LocaleCompare("-version",option+1) == 0)) |
| 295 | { |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 296 | ListMagickVersion(stdout); |
Cristy | df0b291 | 2016-05-17 16:00:28 -0400 | [diff] [blame] | 297 | return(MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 298 | } |
| 299 | } |
| 300 | if (argc < 3) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 301 | return(CompareUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 302 | difference_image=NewImageList(); |
| 303 | similarity_image=NewImageList(); |
| 304 | dissimilarity_threshold=DefaultDissimilarityThreshold; |
cristy | 62e5218 | 2013-03-15 14:26:17 +0000 | [diff] [blame] | 305 | similarity_threshold=DefaultSimilarityThreshold; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 306 | distortion=0.0; |
| 307 | format=(char *) NULL; |
| 308 | j=1; |
| 309 | k=0; |
cristy | 2cb55d5 | 2013-07-10 22:20:51 +0000 | [diff] [blame] | 310 | metric=UndefinedErrorMetric; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 311 | NewImageStack(); |
| 312 | option=(char *) NULL; |
| 313 | pend=MagickFalse; |
| 314 | reconstruct_image=NewImageList(); |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 315 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 316 | status=MagickTrue; |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 317 | subimage_search=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 318 | /* |
| 319 | Compare an image. |
| 320 | */ |
| 321 | ReadCommandlLine(argc,&argv); |
| 322 | status=ExpandFilenames(&argc,&argv); |
| 323 | if (status == MagickFalse) |
| 324 | ThrowCompareException(ResourceLimitError,"MemoryAllocationFailed", |
| 325 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 326 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 327 | { |
| 328 | option=argv[i]; |
| 329 | if (LocaleCompare(option,"(") == 0) |
| 330 | { |
| 331 | FireImageStack(MagickTrue,MagickTrue,pend); |
| 332 | if (k == MaxImageStackDepth) |
| 333 | ThrowCompareException(OptionError,"ParenthesisNestedTooDeeply", |
| 334 | option); |
| 335 | PushImageStack(); |
| 336 | continue; |
| 337 | } |
| 338 | if (LocaleCompare(option,")") == 0) |
| 339 | { |
| 340 | FireImageStack(MagickTrue,MagickTrue,MagickTrue); |
| 341 | if (k == 0) |
| 342 | ThrowCompareException(OptionError,"UnableToParseExpression",option); |
| 343 | PopImageStack(); |
| 344 | continue; |
| 345 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 346 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 347 | { |
| 348 | Image |
| 349 | *images; |
| 350 | |
| 351 | /* |
| 352 | Read input image. |
| 353 | */ |
| 354 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 355 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 356 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 357 | filename=argv[++i]; |
cristy | 1b58f25 | 2012-03-01 01:41:41 +0000 | [diff] [blame] | 358 | images=ReadImages(image_info,filename,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 359 | status&=(images != (Image *) NULL) && |
| 360 | (exception->severity < ErrorException); |
| 361 | if (images == (Image *) NULL) |
| 362 | continue; |
| 363 | AppendImageStack(images); |
| 364 | continue; |
| 365 | } |
| 366 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 367 | switch (*(option+1)) |
| 368 | { |
| 369 | case 'a': |
| 370 | { |
| 371 | if (LocaleCompare("alpha",option+1) == 0) |
| 372 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 373 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 374 | type; |
| 375 | |
| 376 | if (*option == '+') |
| 377 | break; |
| 378 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 379 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 380 | ThrowCompareException(OptionError,"MissingArgument",option); |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 381 | type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse, |
| 382 | argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 383 | if (type < 0) |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 384 | ThrowCompareException(OptionError, |
| 385 | "UnrecognizedAlphaChannelOption",argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 386 | break; |
| 387 | } |
| 388 | if (LocaleCompare("authenticate",option+1) == 0) |
| 389 | { |
| 390 | if (*option == '+') |
| 391 | break; |
| 392 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 393 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 394 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 395 | break; |
| 396 | } |
| 397 | ThrowCompareException(OptionError,"UnrecognizedOption",option); |
| 398 | } |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 399 | case 'b': |
| 400 | { |
Cristy | 63571f7 | 2017-05-17 15:11:19 -0400 | [diff] [blame] | 401 | if (LocaleCompare("background",option+1) == 0) |
| 402 | { |
| 403 | if (*option == '+') |
| 404 | break; |
| 405 | i++; |
| 406 | if (i == (ssize_t) argc) |
| 407 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 408 | break; |
| 409 | } |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 410 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 411 | { |
| 412 | i++; |
| 413 | if (i == (ssize_t) argc) |
| 414 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 415 | if (IsGeometry(argv[i]) == MagickFalse) |
| 416 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 417 | break; |
| 418 | } |
| 419 | ThrowCompareException(OptionError,"UnrecognizedOption",option); |
| 420 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 421 | case 'c': |
| 422 | { |
| 423 | if (LocaleCompare("cache",option+1) == 0) |
| 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); |
| 430 | if (IsGeometry(argv[i]) == MagickFalse) |
| 431 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 432 | break; |
| 433 | } |
| 434 | if (LocaleCompare("channel",option+1) == 0) |
| 435 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 436 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 437 | channel; |
| 438 | |
| 439 | if (*option == '+') |
| 440 | break; |
| 441 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 442 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 443 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 444 | channel=ParseChannelOption(argv[i]); |
| 445 | if (channel < 0) |
| 446 | ThrowCompareException(OptionError,"UnrecognizedChannelType", |
| 447 | argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 448 | break; |
| 449 | } |
| 450 | if (LocaleCompare("colorspace",option+1) == 0) |
| 451 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 452 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 453 | colorspace; |
| 454 | |
| 455 | if (*option == '+') |
| 456 | break; |
| 457 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 458 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 459 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 460 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 461 | argv[i]); |
| 462 | if (colorspace < 0) |
| 463 | ThrowCompareException(OptionError,"UnrecognizedColorspace", |
| 464 | argv[i]); |
| 465 | break; |
| 466 | } |
| 467 | if (LocaleCompare("compose",option+1) == 0) |
| 468 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 469 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 470 | compose; |
| 471 | |
| 472 | if (*option == '+') |
| 473 | break; |
| 474 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 475 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 476 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 477 | compose=ParseCommandOption(MagickComposeOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 478 | argv[i]); |
| 479 | if (compose < 0) |
| 480 | ThrowCompareException(OptionError,"UnrecognizedComposeOperator", |
| 481 | argv[i]); |
| 482 | break; |
| 483 | } |
| 484 | if (LocaleCompare("compress",option+1) == 0) |
| 485 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 486 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 487 | compress; |
| 488 | |
| 489 | if (*option == '+') |
| 490 | break; |
| 491 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 492 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 493 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 494 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 495 | argv[i]); |
| 496 | if (compress < 0) |
| 497 | ThrowCompareException(OptionError,"UnrecognizedImageCompression", |
| 498 | argv[i]); |
| 499 | break; |
| 500 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 501 | if (LocaleCompare("concurrent",option+1) == 0) |
| 502 | break; |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 503 | if (LocaleCompare("crop",option+1) == 0) |
| 504 | { |
| 505 | if (*option == '+') |
| 506 | break; |
| 507 | i++; |
| 508 | if (i == (ssize_t) argc) |
| 509 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 510 | if (IsGeometry(argv[i]) == MagickFalse) |
| 511 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 512 | break; |
| 513 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 514 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 515 | } |
| 516 | case 'd': |
| 517 | { |
| 518 | if (LocaleCompare("debug",option+1) == 0) |
| 519 | { |
| 520 | LogEventType |
| 521 | event_mask; |
| 522 | |
| 523 | if (*option == '+') |
| 524 | break; |
| 525 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 526 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 527 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 528 | event_mask=SetLogEventMask(argv[i]); |
| 529 | if (event_mask == UndefinedEvents) |
| 530 | ThrowCompareException(OptionError,"UnrecognizedEventType", |
| 531 | argv[i]); |
| 532 | break; |
| 533 | } |
| 534 | if (LocaleCompare("decipher",option+1) == 0) |
| 535 | { |
| 536 | if (*option == '+') |
| 537 | break; |
| 538 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 539 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 540 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 541 | break; |
| 542 | } |
| 543 | if (LocaleCompare("define",option+1) == 0) |
| 544 | { |
| 545 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 546 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 547 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 548 | if (*option == '+') |
| 549 | { |
| 550 | const char |
| 551 | *define; |
| 552 | |
| 553 | define=GetImageOption(image_info,argv[i]); |
| 554 | if (define == (const char *) NULL) |
| 555 | ThrowCompareException(OptionError,"NoSuchOption",argv[i]); |
| 556 | break; |
| 557 | } |
| 558 | break; |
| 559 | } |
| 560 | if (LocaleCompare("density",option+1) == 0) |
| 561 | { |
| 562 | if (*option == '+') |
| 563 | break; |
| 564 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 565 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 566 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 567 | if (IsGeometry(argv[i]) == MagickFalse) |
| 568 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 569 | break; |
| 570 | } |
| 571 | if (LocaleCompare("depth",option+1) == 0) |
| 572 | { |
| 573 | if (*option == '+') |
| 574 | break; |
| 575 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 576 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 577 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 578 | if (IsGeometry(argv[i]) == MagickFalse) |
| 579 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 580 | break; |
| 581 | } |
| 582 | if (LocaleCompare("dissimilarity-threshold",option+1) == 0) |
| 583 | { |
| 584 | if (*option == '+') |
| 585 | break; |
| 586 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 587 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 588 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 589 | if (IsGeometry(argv[i]) == MagickFalse) |
| 590 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 591 | if (*option == '+') |
| 592 | dissimilarity_threshold=DefaultDissimilarityThreshold; |
| 593 | else |
cristy | 9b34e30 | 2011-11-05 02:15:45 +0000 | [diff] [blame] | 594 | dissimilarity_threshold=StringToDouble(argv[i],(char **) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 595 | break; |
| 596 | } |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 597 | if (LocaleCompare("distort",option+1) == 0) |
| 598 | { |
| 599 | ssize_t |
| 600 | op; |
| 601 | |
| 602 | i++; |
| 603 | if (i == (ssize_t) argc) |
| 604 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 605 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
| 606 | if (op < 0) |
| 607 | ThrowCompareException(OptionError,"UnrecognizedDistortMethod", |
| 608 | argv[i]); |
| 609 | i++; |
| 610 | if (i == (ssize_t) argc) |
| 611 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 612 | break; |
| 613 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 614 | if (LocaleCompare("duration",option+1) == 0) |
| 615 | { |
| 616 | if (*option == '+') |
| 617 | break; |
| 618 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 619 | if (i == (ssize_t) argc) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 620 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 621 | if (IsGeometry(argv[i]) == MagickFalse) |
| 622 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 623 | break; |
| 624 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 625 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 626 | } |
| 627 | case 'e': |
| 628 | { |
| 629 | if (LocaleCompare("encipher",option+1) == 0) |
| 630 | { |
| 631 | if (*option == '+') |
| 632 | break; |
| 633 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 634 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 635 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 636 | break; |
| 637 | } |
| 638 | if (LocaleCompare("extract",option+1) == 0) |
| 639 | { |
| 640 | if (*option == '+') |
| 641 | break; |
| 642 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 643 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 644 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 645 | if (IsGeometry(argv[i]) == MagickFalse) |
| 646 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 647 | break; |
| 648 | } |
| 649 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 650 | } |
| 651 | case 'f': |
| 652 | { |
| 653 | if (LocaleCompare("format",option+1) == 0) |
| 654 | { |
| 655 | if (*option == '+') |
| 656 | break; |
| 657 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 658 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 659 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 660 | format=argv[i]; |
| 661 | break; |
| 662 | } |
| 663 | if (LocaleCompare("fuzz",option+1) == 0) |
| 664 | { |
| 665 | if (*option == '+') |
| 666 | break; |
| 667 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 668 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 669 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 670 | if (IsGeometry(argv[i]) == MagickFalse) |
| 671 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 672 | break; |
| 673 | } |
| 674 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 675 | } |
| 676 | case 'h': |
| 677 | { |
| 678 | if ((LocaleCompare("help",option+1) == 0) || |
| 679 | (LocaleCompare("-help",option+1) == 0)) |
| 680 | return(CompareUsage()); |
| 681 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 682 | { |
| 683 | if (*option == '+') |
| 684 | break; |
| 685 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 686 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 687 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 688 | break; |
| 689 | } |
| 690 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 691 | } |
| 692 | case 'i': |
| 693 | { |
| 694 | if (LocaleCompare("identify",option+1) == 0) |
| 695 | break; |
| 696 | if (LocaleCompare("interlace",option+1) == 0) |
| 697 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 698 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 699 | interlace; |
| 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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 705 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 706 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 707 | argv[i]); |
| 708 | if (interlace < 0) |
| 709 | ThrowCompareException(OptionError,"UnrecognizedInterlaceType", |
| 710 | argv[i]); |
| 711 | break; |
| 712 | } |
| 713 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 714 | } |
| 715 | case 'l': |
| 716 | { |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 717 | if (LocaleCompare("level",option+1) == 0) |
| 718 | { |
| 719 | i++; |
| 720 | if (i == (ssize_t) argc) |
| 721 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 722 | if (IsGeometry(argv[i]) == MagickFalse) |
| 723 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 724 | break; |
| 725 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 726 | if (LocaleCompare("limit",option+1) == 0) |
| 727 | { |
| 728 | char |
| 729 | *p; |
| 730 | |
| 731 | double |
| 732 | value; |
| 733 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 734 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 735 | resource; |
| 736 | |
| 737 | if (*option == '+') |
| 738 | break; |
| 739 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 740 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 741 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 742 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 743 | argv[i]); |
| 744 | if (resource < 0) |
| 745 | ThrowCompareException(OptionError,"UnrecognizedResourceType", |
| 746 | argv[i]); |
| 747 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 748 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 749 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | dbdd0e3 | 2011-11-04 23:29:40 +0000 | [diff] [blame] | 750 | value=StringToDouble(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 751 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 752 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 753 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 754 | break; |
| 755 | } |
| 756 | if (LocaleCompare("list",option+1) == 0) |
| 757 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 758 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 759 | list; |
| 760 | |
| 761 | if (*option == '+') |
| 762 | break; |
| 763 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 764 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 765 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 766 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 767 | if (list < 0) |
| 768 | ThrowCompareException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 769 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 770 | argv+j,exception); |
| 771 | DestroyCompare(); |
cristy | 32ce239 | 2014-09-24 19:08:53 +0000 | [diff] [blame] | 772 | return(status == 0 ? MagickTrue : MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 773 | } |
| 774 | if (LocaleCompare("log",option+1) == 0) |
| 775 | { |
| 776 | if (*option == '+') |
| 777 | break; |
| 778 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 779 | if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 780 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 781 | break; |
| 782 | } |
| 783 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 784 | { |
| 785 | if (*option == '+') |
| 786 | break; |
| 787 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 788 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 789 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 790 | break; |
| 791 | } |
| 792 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 793 | } |
| 794 | case 'm': |
| 795 | { |
| 796 | if (LocaleCompare("matte",option+1) == 0) |
| 797 | break; |
| 798 | if (LocaleCompare("metric",option+1) == 0) |
| 799 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 800 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 801 | type; |
| 802 | |
| 803 | if (*option == '+') |
| 804 | break; |
| 805 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 806 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 807 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 808 | type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 809 | if (type < 0) |
| 810 | ThrowCompareException(OptionError,"UnrecognizedMetricType", |
| 811 | argv[i]); |
| 812 | metric=(MetricType) type; |
| 813 | break; |
| 814 | } |
| 815 | if (LocaleCompare("monitor",option+1) == 0) |
| 816 | break; |
| 817 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 818 | } |
Cristy | 6e6ce01 | 2016-11-26 19:00:03 -0500 | [diff] [blame] | 819 | case 'n': |
| 820 | { |
| 821 | if (LocaleCompare("negate",option+1) == 0) |
| 822 | break; |
| 823 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 824 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 825 | case 'p': |
| 826 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 827 | if (LocaleCompare("profile",option+1) == 0) |
| 828 | { |
| 829 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 830 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 831 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 832 | break; |
| 833 | } |
| 834 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 835 | } |
| 836 | case 'q': |
| 837 | { |
| 838 | if (LocaleCompare("quality",option+1) == 0) |
| 839 | { |
| 840 | if (*option == '+') |
| 841 | break; |
| 842 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 843 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 844 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 845 | if (IsGeometry(argv[i]) == MagickFalse) |
| 846 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 847 | break; |
| 848 | } |
| 849 | if (LocaleCompare("quantize",option+1) == 0) |
| 850 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 851 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 852 | colorspace; |
| 853 | |
| 854 | if (*option == '+') |
| 855 | break; |
| 856 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 857 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 858 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 859 | colorspace=ParseCommandOption(MagickColorspaceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 860 | MagickFalse,argv[i]); |
| 861 | if (colorspace < 0) |
| 862 | ThrowCompareException(OptionError,"UnrecognizedColorspace", |
| 863 | argv[i]); |
| 864 | break; |
| 865 | } |
| 866 | if (LocaleCompare("quiet",option+1) == 0) |
| 867 | break; |
| 868 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 869 | } |
| 870 | case 'r': |
| 871 | { |
Cristy | 756a447 | 2016-11-26 09:17:41 -0500 | [diff] [blame] | 872 | if (LocaleCompare("read-mask",option+1) == 0) |
| 873 | { |
| 874 | if (*option == '+') |
| 875 | break; |
| 876 | i++; |
| 877 | if (i == (ssize_t) argc) |
| 878 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 879 | break; |
| 880 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 881 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 882 | break; |
Cristy | d9589b1 | 2017-05-19 07:12:51 -0400 | [diff] [blame] | 883 | if (LocaleCompare("repage",option+1) == 0) |
| 884 | { |
| 885 | if (*option == '+') |
| 886 | break; |
| 887 | i++; |
| 888 | if (i == (ssize_t) argc) |
| 889 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 890 | if (IsGeometry(argv[i]) == MagickFalse) |
| 891 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 892 | break; |
| 893 | } |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 894 | if (LocaleCompare("resize",option+1) == 0) |
| 895 | { |
| 896 | if (*option == '+') |
| 897 | break; |
| 898 | i++; |
| 899 | if (i == (ssize_t) argc) |
| 900 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 901 | if (IsGeometry(argv[i]) == MagickFalse) |
| 902 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 903 | break; |
| 904 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 905 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 906 | { |
| 907 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 908 | break; |
| 909 | } |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 910 | if (LocaleCompare("rotate",option+1) == 0) |
| 911 | { |
| 912 | i++; |
| 913 | if (i == (ssize_t) argc) |
| 914 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 915 | if (IsGeometry(argv[i]) == MagickFalse) |
| 916 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 917 | break; |
| 918 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 919 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 920 | } |
| 921 | case 's': |
| 922 | { |
| 923 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 924 | { |
| 925 | if (*option == '+') |
| 926 | break; |
| 927 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 928 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 929 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 930 | if (IsGeometry(argv[i]) == MagickFalse) |
| 931 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 932 | break; |
| 933 | } |
| 934 | if (LocaleCompare("seed",option+1) == 0) |
| 935 | { |
| 936 | if (*option == '+') |
| 937 | break; |
| 938 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 939 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 940 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 941 | if (IsGeometry(argv[i]) == MagickFalse) |
| 942 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 943 | break; |
| 944 | } |
| 945 | if (LocaleCompare("set",option+1) == 0) |
| 946 | { |
| 947 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 948 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 949 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 950 | if (*option == '+') |
| 951 | break; |
| 952 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 953 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 954 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 955 | break; |
| 956 | } |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 957 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 958 | { |
| 959 | i++; |
| 960 | if (i == (ssize_t) argc) |
| 961 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 962 | if (IsGeometry(argv[i]) == MagickFalse) |
| 963 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 964 | break; |
| 965 | } |
cristy | 62e5218 | 2013-03-15 14:26:17 +0000 | [diff] [blame] | 966 | if (LocaleCompare("similarity-threshold",option+1) == 0) |
| 967 | { |
| 968 | if (*option == '+') |
| 969 | break; |
| 970 | i++; |
| 971 | if (i == (ssize_t) argc) |
| 972 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 973 | if (IsGeometry(argv[i]) == MagickFalse) |
| 974 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 975 | if (*option == '+') |
| 976 | similarity_threshold=DefaultSimilarityThreshold; |
| 977 | else |
| 978 | similarity_threshold=StringToDouble(argv[i],(char **) NULL); |
| 979 | break; |
| 980 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 981 | if (LocaleCompare("size",option+1) == 0) |
| 982 | { |
| 983 | if (*option == '+') |
| 984 | break; |
| 985 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 986 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 987 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 988 | if (IsGeometry(argv[i]) == MagickFalse) |
| 989 | ThrowCompareInvalidArgumentException(option,argv[i]); |
| 990 | break; |
| 991 | } |
cristy | ae6203d | 2010-08-09 01:12:14 +0000 | [diff] [blame] | 992 | if (LocaleCompare("subimage-search",option+1) == 0) |
| 993 | { |
| 994 | if (*option == '+') |
| 995 | { |
| 996 | subimage_search=MagickFalse; |
| 997 | break; |
| 998 | } |
| 999 | subimage_search=MagickTrue; |
| 1000 | break; |
| 1001 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 1002 | if (LocaleCompare("synchronize",option+1) == 0) |
| 1003 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1004 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 1005 | } |
| 1006 | case 't': |
| 1007 | { |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 1008 | if (LocaleCompare("taint",option+1) == 0) |
| 1009 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1010 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 1011 | { |
| 1012 | if (*option == '+') |
| 1013 | break; |
| 1014 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 1015 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1016 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 1017 | break; |
| 1018 | } |
Cristy | f9ab515 | 2017-05-16 21:05:26 -0400 | [diff] [blame] | 1019 | if (LocaleCompare("trim",option+1) == 0) |
| 1020 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1021 | if (LocaleCompare("type",option+1) == 0) |
| 1022 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1023 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1024 | type; |
| 1025 | |
| 1026 | if (*option == '+') |
| 1027 | break; |
| 1028 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1029 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1030 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1031 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1032 | if (type < 0) |
| 1033 | ThrowCompareException(OptionError,"UnrecognizedImageType", |
| 1034 | argv[i]); |
| 1035 | break; |
| 1036 | } |
| 1037 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 1038 | } |
| 1039 | case 'v': |
| 1040 | { |
| 1041 | if (LocaleCompare("verbose",option+1) == 0) |
| 1042 | break; |
| 1043 | if ((LocaleCompare("version",option+1) == 0) || |
| 1044 | (LocaleCompare("-version",option+1) == 0)) |
| 1045 | { |
cristy | 4f7a613 | 2012-12-23 00:35:19 +0000 | [diff] [blame] | 1046 | ListMagickVersion(stdout); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1047 | break; |
| 1048 | } |
| 1049 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 1050 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1051 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1052 | method; |
| 1053 | |
| 1054 | if (*option == '+') |
| 1055 | break; |
| 1056 | i++; |
cristy | e81f552 | 2014-05-07 01:25:59 +0000 | [diff] [blame] | 1057 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1058 | ThrowCompareException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1059 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1060 | argv[i]); |
| 1061 | if (method < 0) |
| 1062 | ThrowCompareException(OptionError, |
| 1063 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 1064 | break; |
| 1065 | } |
| 1066 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 1067 | } |
Cristy | 55d3c44 | 2016-12-02 19:46:34 -0500 | [diff] [blame] | 1068 | case 'w': |
| 1069 | { |
| 1070 | if (LocaleCompare("write-mask",option+1) == 0) |
| 1071 | { |
| 1072 | if (*option == '+') |
| 1073 | break; |
| 1074 | i++; |
| 1075 | if (i == (ssize_t) argc) |
| 1076 | ThrowCompareException(OptionError,"MissingArgument",option); |
| 1077 | break; |
| 1078 | } |
| 1079 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 1080 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1081 | case '?': |
| 1082 | break; |
| 1083 | default: |
| 1084 | ThrowCompareException(OptionError,"UnrecognizedOption",option) |
| 1085 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1086 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 1087 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1088 | if (fire != MagickFalse) |
| 1089 | FireImageStack(MagickTrue,MagickTrue,MagickTrue); |
| 1090 | } |
| 1091 | if (k != 0) |
| 1092 | ThrowCompareException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1093 | if (i-- != (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1094 | ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); |
| 1095 | if ((image == (Image *) NULL) || (GetImageListLength(image) < 2)) |
| 1096 | ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); |
| 1097 | FinalizeImageSettings(image_info,image,MagickTrue); |
cristy | 94f2007 | 2009-09-12 02:12:36 +0000 | [diff] [blame] | 1098 | if ((image == (Image *) NULL) || (GetImageListLength(image) < 2)) |
| 1099 | ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1100 | image=GetImageFromList(image,0); |
| 1101 | reconstruct_image=GetImageFromList(image,1); |
cristy | ab0cc71 | 2013-11-03 22:18:45 +0000 | [diff] [blame] | 1102 | offset.x=0; |
| 1103 | offset.y=0; |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 1104 | if (subimage_search != MagickFalse) |
| 1105 | { |
cristy | 62e5218 | 2013-03-15 14:26:17 +0000 | [diff] [blame] | 1106 | similarity_image=SimilarityImage(image,reconstruct_image,metric, |
| 1107 | similarity_threshold,&offset,&similarity_metric,exception); |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 1108 | if (similarity_metric > dissimilarity_threshold) |
| 1109 | ThrowCompareException(ImageError,"ImagesTooDissimilar",image->filename); |
| 1110 | } |
cristy | 966f1f0 | 2014-02-02 16:27:24 +0000 | [diff] [blame] | 1111 | if ((reconstruct_image->columns == image->columns) && |
| 1112 | (reconstruct_image->rows == image->rows)) |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 1113 | difference_image=CompareImages(image,reconstruct_image,metric,&distortion, |
| 1114 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1115 | else |
cristy | 4fdfe68 | 2014-01-21 19:26:29 +0000 | [diff] [blame] | 1116 | if (similarity_image == (Image *) NULL) |
cristy | 7431bb2 | 2014-02-02 18:40:36 +0000 | [diff] [blame] | 1117 | { |
| 1118 | if (metric == PerceptualHashErrorMetric) |
cristy | 7e2f1aa | 2014-02-02 21:23:27 +0000 | [diff] [blame] | 1119 | difference_image=CompareImages(image,reconstruct_image,metric, |
| 1120 | &distortion,exception); |
cristy | 7431bb2 | 2014-02-02 18:40:36 +0000 | [diff] [blame] | 1121 | else |
| 1122 | ThrowCompareException(OptionError,"ImageWidthsOrHeightsDiffer", |
| 1123 | image->filename); |
| 1124 | } |
cristy | fdad905 | 2010-08-15 20:15:35 +0000 | [diff] [blame] | 1125 | else |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 1126 | { |
| 1127 | Image |
| 1128 | *composite_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1129 | |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 1130 | /* |
| 1131 | Determine if reconstructed image is a subimage of the image. |
| 1132 | */ |
| 1133 | composite_image=CloneImage(image,0,0,MagickTrue,exception); |
| 1134 | if (composite_image == (Image *) NULL) |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 1135 | difference_image=CompareImages(image,reconstruct_image,metric, |
| 1136 | &distortion,exception); |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 1137 | else |
| 1138 | { |
cristy | 95f8ae3 | 2013-06-17 12:26:57 +0000 | [diff] [blame] | 1139 | Image |
| 1140 | *distort_image; |
| 1141 | |
| 1142 | RectangleInfo |
| 1143 | page; |
| 1144 | |
cristy | feb3e96 | 2012-03-29 17:25:55 +0000 | [diff] [blame] | 1145 | (void) CompositeImage(composite_image,reconstruct_image, |
cristy | 3917240 | 2012-03-30 13:04:39 +0000 | [diff] [blame] | 1146 | CopyCompositeOp,MagickTrue,offset.x,offset.y,exception); |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 1147 | difference_image=CompareImages(image,composite_image,metric, |
| 1148 | &distortion,exception); |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 1149 | if (difference_image != (Image *) NULL) |
| 1150 | { |
| 1151 | difference_image->page.x=offset.x; |
| 1152 | difference_image->page.y=offset.y; |
| 1153 | } |
| 1154 | composite_image=DestroyImage(composite_image); |
cristy | 95f8ae3 | 2013-06-17 12:26:57 +0000 | [diff] [blame] | 1155 | page.width=reconstruct_image->columns; |
| 1156 | page.height=reconstruct_image->rows; |
| 1157 | page.x=offset.x; |
| 1158 | page.y=offset.y; |
| 1159 | distort_image=CropImage(image,&page,exception); |
| 1160 | if (distort_image != (Image *) NULL) |
| 1161 | { |
| 1162 | Image |
| 1163 | *sans_image; |
| 1164 | |
| 1165 | sans_image=CompareImages(distort_image,reconstruct_image,metric, |
| 1166 | &distortion,exception); |
| 1167 | distort_image=DestroyImage(distort_image); |
| 1168 | if (sans_image != (Image *) NULL) |
| 1169 | sans_image=DestroyImage(sans_image); |
| 1170 | } |
cristy | 8333093 | 2010-08-14 20:48:24 +0000 | [diff] [blame] | 1171 | } |
| 1172 | if (difference_image != (Image *) NULL) |
| 1173 | { |
| 1174 | AppendImageToList(&difference_image,similarity_image); |
| 1175 | similarity_image=(Image *) NULL; |
| 1176 | } |
| 1177 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1178 | if (difference_image == (Image *) NULL) |
| 1179 | status=0; |
| 1180 | else |
| 1181 | { |
| 1182 | if (image_info->verbose != MagickFalse) |
Cristy | f247981 | 2015-12-12 12:17:43 -0500 | [diff] [blame] | 1183 | (void) SetImageColorMetric(image,reconstruct_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1184 | if (*difference_image->magick == '\0') |
| 1185 | (void) CopyMagickString(difference_image->magick,image->magick, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 1186 | MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1187 | if (image_info->verbose == MagickFalse) |
| 1188 | { |
| 1189 | switch (metric) |
| 1190 | { |
cristy | 343eee9 | 2010-12-11 02:17:57 +0000 | [diff] [blame] | 1191 | case FuzzErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1192 | case MeanAbsoluteErrorMetric: |
| 1193 | case MeanSquaredErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1194 | case PeakAbsoluteErrorMetric: |
cristy | bc0adce | 2014-01-08 23:15:49 +0000 | [diff] [blame] | 1195 | case RootMeanSquaredErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1196 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1197 | (void) FormatLocaleFile(stderr,"%g (%g)",QuantumRange*distortion, |
cristy | 8cd5b31 | 2010-01-07 01:10:24 +0000 | [diff] [blame] | 1198 | (double) distortion); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1199 | break; |
| 1200 | } |
| 1201 | case AbsoluteErrorMetric: |
cristy | 4c929a7 | 2010-11-24 18:54:42 +0000 | [diff] [blame] | 1202 | case NormalizedCrossCorrelationErrorMetric: |
cristy | 03d6f86 | 2014-01-08 18:34:48 +0000 | [diff] [blame] | 1203 | case PeakSignalToNoiseRatioErrorMetric: |
cristy | 966f1f0 | 2014-02-02 16:27:24 +0000 | [diff] [blame] | 1204 | case PerceptualHashErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1205 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1206 | (void) FormatLocaleFile(stderr,"%g",distortion); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1207 | break; |
| 1208 | } |
cristy | 03fa69f | 2014-01-08 18:36:49 +0000 | [diff] [blame] | 1209 | case MeanErrorPerPixelErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1210 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1211 | (void) FormatLocaleFile(stderr,"%g (%g, %g)",distortion, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1212 | image->error.normalized_mean_error, |
| 1213 | image->error.normalized_maximum_error); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1214 | break; |
| 1215 | } |
cristy | 2cb55d5 | 2013-07-10 22:20:51 +0000 | [diff] [blame] | 1216 | case UndefinedErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1217 | break; |
| 1218 | } |
cristy | a5f84e0 | 2014-02-03 10:30:53 +0000 | [diff] [blame] | 1219 | if (subimage_search != MagickFalse) |
cristy | 7431bb2 | 2014-02-02 18:40:36 +0000 | [diff] [blame] | 1220 | (void) FormatLocaleFile(stderr," @ %.20g,%.20g",(double) |
| 1221 | difference_image->page.x,(double) difference_image->page.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1222 | } |
| 1223 | else |
| 1224 | { |
| 1225 | double |
| 1226 | *channel_distortion; |
| 1227 | |
cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 1228 | channel_distortion=GetImageDistortions(image,reconstruct_image, |
cristy | c82a27b | 2011-10-21 01:07:16 +0000 | [diff] [blame] | 1229 | metric,exception); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1230 | (void) FormatLocaleFile(stderr,"Image: %s\n",image->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1231 | if ((reconstruct_image->columns != image->columns) || |
| 1232 | (reconstruct_image->rows != image->rows)) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1233 | (void) FormatLocaleFile(stderr,"Offset: %.20g,%.20g\n",(double) |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 1234 | difference_image->page.x,(double) difference_image->page.y); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1235 | (void) FormatLocaleFile(stderr," Channel distortion: %s\n", |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 1236 | CommandOptionToMnemonic(MagickMetricOptions,(ssize_t) metric)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1237 | switch (metric) |
| 1238 | { |
cristy | 343eee9 | 2010-12-11 02:17:57 +0000 | [diff] [blame] | 1239 | case FuzzErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1240 | case MeanAbsoluteErrorMetric: |
| 1241 | case MeanSquaredErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1242 | case PeakAbsoluteErrorMetric: |
cristy | bc0adce | 2014-01-08 23:15:49 +0000 | [diff] [blame] | 1243 | case RootMeanSquaredErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1244 | { |
| 1245 | switch (image->colorspace) |
| 1246 | { |
| 1247 | case RGBColorspace: |
| 1248 | default: |
| 1249 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1250 | (void) FormatLocaleFile(stderr," red: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1251 | QuantumRange*channel_distortion[RedPixelChannel], |
| 1252 | channel_distortion[RedPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1253 | (void) FormatLocaleFile(stderr," green: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1254 | QuantumRange*channel_distortion[GreenPixelChannel], |
| 1255 | channel_distortion[GreenPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1256 | (void) FormatLocaleFile(stderr," blue: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1257 | QuantumRange*channel_distortion[BluePixelChannel], |
| 1258 | channel_distortion[BluePixelChannel]); |
cristy | 7d6d3d8 | 2014-11-09 17:00:16 +0000 | [diff] [blame] | 1259 | if (image->alpha_trait != UndefinedPixelTrait) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1260 | (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1261 | QuantumRange*channel_distortion[AlphaPixelChannel], |
| 1262 | channel_distortion[AlphaPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1263 | break; |
| 1264 | } |
| 1265 | case CMYKColorspace: |
| 1266 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1267 | (void) FormatLocaleFile(stderr," cyan: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1268 | QuantumRange*channel_distortion[CyanPixelChannel], |
| 1269 | channel_distortion[CyanPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1270 | (void) FormatLocaleFile(stderr," magenta: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1271 | QuantumRange*channel_distortion[MagentaPixelChannel], |
| 1272 | channel_distortion[MagentaPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1273 | (void) FormatLocaleFile(stderr," yellow: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1274 | QuantumRange*channel_distortion[YellowPixelChannel], |
| 1275 | channel_distortion[YellowPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1276 | (void) FormatLocaleFile(stderr," black: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1277 | QuantumRange*channel_distortion[BlackPixelChannel], |
| 1278 | channel_distortion[BlackPixelChannel]); |
cristy | 7d6d3d8 | 2014-11-09 17:00:16 +0000 | [diff] [blame] | 1279 | if (image->alpha_trait != UndefinedPixelTrait) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1280 | (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1281 | QuantumRange*channel_distortion[AlphaPixelChannel], |
| 1282 | channel_distortion[AlphaPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1283 | break; |
| 1284 | } |
| 1285 | case GRAYColorspace: |
| 1286 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1287 | (void) FormatLocaleFile(stderr," gray: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1288 | QuantumRange*channel_distortion[GrayPixelChannel], |
| 1289 | channel_distortion[GrayPixelChannel]); |
cristy | 7d6d3d8 | 2014-11-09 17:00:16 +0000 | [diff] [blame] | 1290 | if (image->alpha_trait != UndefinedPixelTrait) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1291 | (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1292 | QuantumRange*channel_distortion[AlphaPixelChannel], |
| 1293 | channel_distortion[AlphaPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1294 | break; |
| 1295 | } |
| 1296 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1297 | (void) FormatLocaleFile(stderr," all: %g (%g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1298 | QuantumRange*channel_distortion[MaxPixelChannels], |
| 1299 | channel_distortion[MaxPixelChannels]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1300 | break; |
| 1301 | } |
| 1302 | case AbsoluteErrorMetric: |
cristy | 4c929a7 | 2010-11-24 18:54:42 +0000 | [diff] [blame] | 1303 | case NormalizedCrossCorrelationErrorMetric: |
cristy | 03d6f86 | 2014-01-08 18:34:48 +0000 | [diff] [blame] | 1304 | case PeakSignalToNoiseRatioErrorMetric: |
cristy | 33caf0c | 2014-01-09 14:42:27 +0000 | [diff] [blame] | 1305 | case PerceptualHashErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1306 | { |
| 1307 | switch (image->colorspace) |
| 1308 | { |
| 1309 | case RGBColorspace: |
| 1310 | default: |
| 1311 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1312 | (void) FormatLocaleFile(stderr," red: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1313 | channel_distortion[RedPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1314 | (void) FormatLocaleFile(stderr," green: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1315 | channel_distortion[GreenPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1316 | (void) FormatLocaleFile(stderr," blue: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1317 | channel_distortion[BluePixelChannel]); |
cristy | 7d6d3d8 | 2014-11-09 17:00:16 +0000 | [diff] [blame] | 1318 | if (image->alpha_trait != UndefinedPixelTrait) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1319 | (void) FormatLocaleFile(stderr," alpha: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1320 | channel_distortion[AlphaPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1321 | break; |
| 1322 | } |
| 1323 | case CMYKColorspace: |
| 1324 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1325 | (void) FormatLocaleFile(stderr," cyan: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1326 | channel_distortion[CyanPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1327 | (void) FormatLocaleFile(stderr," magenta: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1328 | channel_distortion[MagentaPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1329 | (void) FormatLocaleFile(stderr," yellow: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1330 | channel_distortion[YellowPixelChannel]); |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1331 | (void) FormatLocaleFile(stderr," black: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1332 | channel_distortion[BlackPixelChannel]); |
cristy | 7d6d3d8 | 2014-11-09 17:00:16 +0000 | [diff] [blame] | 1333 | if (image->alpha_trait != UndefinedPixelTrait) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1334 | (void) FormatLocaleFile(stderr," alpha: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1335 | channel_distortion[AlphaPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1336 | break; |
| 1337 | } |
| 1338 | case GRAYColorspace: |
| 1339 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1340 | (void) FormatLocaleFile(stderr," gray: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1341 | channel_distortion[GrayPixelChannel]); |
cristy | 7d6d3d8 | 2014-11-09 17:00:16 +0000 | [diff] [blame] | 1342 | if (image->alpha_trait != UndefinedPixelTrait) |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1343 | (void) FormatLocaleFile(stderr," alpha: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1344 | channel_distortion[AlphaPixelChannel]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1345 | break; |
| 1346 | } |
| 1347 | } |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1348 | (void) FormatLocaleFile(stderr," all: %g\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1349 | channel_distortion[MaxPixelChannels]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1350 | break; |
| 1351 | } |
cristy | 03fa69f | 2014-01-08 18:36:49 +0000 | [diff] [blame] | 1352 | case MeanErrorPerPixelErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1353 | { |
cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 1354 | (void) FormatLocaleFile(stderr," %g (%g, %g)\n", |
cristy | d3090f9 | 2011-10-18 00:05:15 +0000 | [diff] [blame] | 1355 | channel_distortion[MaxPixelChannels], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1356 | image->error.normalized_mean_error, |
| 1357 | image->error.normalized_maximum_error); |
| 1358 | break; |
| 1359 | } |
cristy | 2cb55d5 | 2013-07-10 22:20:51 +0000 | [diff] [blame] | 1360 | case UndefinedErrorMetric: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1361 | break; |
| 1362 | } |
| 1363 | channel_distortion=(double *) RelinquishMagickMemory( |
| 1364 | channel_distortion); |
cristy | a5f84e0 | 2014-02-03 10:30:53 +0000 | [diff] [blame] | 1365 | if (subimage_search != MagickFalse) |
cristy | 7431bb2 | 2014-02-02 18:40:36 +0000 | [diff] [blame] | 1366 | (void) FormatLocaleFile(stderr," Offset: %.20g,%.20g\n",(double) |
| 1367 | difference_image->page.x,(double) difference_image->page.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1368 | } |
| 1369 | status&=WriteImages(image_info,difference_image,argv[argc-1],exception); |
| 1370 | if ((metadata != (char **) NULL) && (format != (char *) NULL)) |
| 1371 | { |
| 1372 | char |
| 1373 | *text; |
| 1374 | |
cristy | 018f07f | 2011-09-04 21:15:19 +0000 | [diff] [blame] | 1375 | text=InterpretImageProperties(image_info,difference_image,format, |
| 1376 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1377 | if (text == (char *) NULL) |
| 1378 | ThrowCompareException(ResourceLimitError,"MemoryAllocationFailed", |
| 1379 | GetExceptionMessage(errno)); |
| 1380 | (void) ConcatenateString(&(*metadata),text); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1381 | text=DestroyString(text); |
| 1382 | } |
| 1383 | difference_image=DestroyImageList(difference_image); |
| 1384 | } |
| 1385 | DestroyCompare(); |
cristy | 2cb55d5 | 2013-07-10 22:20:51 +0000 | [diff] [blame] | 1386 | if ((metric == NormalizedCrossCorrelationErrorMetric) || |
| 1387 | (metric == UndefinedErrorMetric)) |
| 1388 | { |
| 1389 | if (fabs(distortion-1.0) > CompareEpsilon) |
cristy | ebd71f4 | 2013-09-13 22:35:48 +0000 | [diff] [blame] | 1390 | (void) SetImageOption(image_info,"compare:dissimilar","true"); |
cristy | 2cb55d5 | 2013-07-10 22:20:51 +0000 | [diff] [blame] | 1391 | } |
| 1392 | else |
| 1393 | if (fabs(distortion) > CompareEpsilon) |
cristy | ebd71f4 | 2013-09-13 22:35:48 +0000 | [diff] [blame] | 1394 | (void) SetImageOption(image_info,"compare:dissimilar","true"); |
cristy | 2cb55d5 | 2013-07-10 22:20:51 +0000 | [diff] [blame] | 1395 | return(status != 0 ? MagickTrue : MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1396 | } |