forked from ImageMagick/ImageMagick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompare.c
1476 lines (1434 loc) · 54.4 KB
/
compare.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% CCCC OOO M M PPPP AAA RRRR EEEEE %
% C O O MM MM P P A A R R E %
% C O O M M M PPPP AAAAA RRRR EEE %
% C O O M M P A A R R E %
% CCCC OOO M M P A A R R EEEEE %
% %
% %
% Image Comparison Methods %
% %
% Software Design %
% Cristy %
% December 2003 %
% %
% %
% Copyright 1999-2020 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
% obtain a copy of the License at %
% %
% https://imagemagick.org/script/license.php %
% %
% Unless required by applicable law or agreed to in writing, software %
% distributed under the License is distributed on an "AS IS" BASIS, %
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
% See the License for the specific language governing permissions and %
% limitations under the License. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Use the compare program to mathematically and visually annotate the
% difference between an image and its reconstruction.
%
*/
/*
Include declarations.
*/
#include "MagickWand/studio.h"
#include "MagickWand/MagickWand.h"
#include "MagickWand/mogrify-private.h"
#include "MagickCore/string-private.h"
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% C o m p a r e I m a g e C o m m a n d %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% CompareImagesCommand() compares two images and returns the difference between
% them as a distortion metric and as a new image visually annotating their
% differences.
%
% The format of the CompareImagesCommand method is:
%
% MagickBooleanType CompareImagesCommand(ImageInfo *image_info,int argc,
% char **argv,char **metadata,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image_info: the image info.
%
% o argc: the number of elements in the argument vector.
%
% o argv: A text array containing the command line arguments.
%
% o metadata: any metadata is returned here.
%
% o exception: return any errors or warnings in this structure.
%
*/
static MagickBooleanType CompareUsage(void)
{
static const char
channel_operators[] =
" -separate separate an image channel into a grayscale image",
miscellaneous[] =
" -channel mask set the image channel mask\n"
" -debug events display copious debugging information\n"
" -help print program options\n"
" -list type print a list of supported option arguments\n"
" -log format format of debugging information",
operators[] =
" -brightness-contrast geometry\n"
" improve brightness / contrast of the image\n"
" -distort method args\n"
" distort images according to given method and args\n"
" -level value adjust the level of image contrast\n"
" -resize geometry resize the image\n"
" -rotate degrees apply Paeth rotation to the image\n"
" -sigmoidal-contrast geometry\n"
" increase the contrast without saturating highlights or\n"
" -trim trim image edges\n"
" -write filename write images to this file",
sequence_operators[] =
" -crop geometry cut out a rectangular region of the image",
settings[] =
" -alpha option on, activate, off, deactivate, set, opaque, copy\n"
" transparent, extract, background, or shape\n"
" -authenticate password\n"
" decipher image with this password\n"
" -background color background color\n"
" -colorspace type alternate image colorspace\n"
" -compose operator set image composite operator\n"
" -compress type type of pixel compression when writing the image\n"
" -decipher filename convert cipher pixels to plain pixels\n"
" -define format:option\n"
" define one or more image format options\n"
" -density geometry horizontal and vertical density of the image\n"
" -depth value image depth\n"
" -dissimilarity-threshold value\n"
" maximum distortion for (sub)image match\n"
" -encipher filename convert plain pixels to cipher pixels\n"
" -extract geometry extract area from image\n"
" -format \"string\" output formatted image characteristics\n"
" -fuzz distance colors within this distance are considered equal\n"
" -gravity type horizontal and vertical text placement\n"
" -highlight-color color\n"
" empasize pixel differences with this color\n"
" -identify identify the format and characteristics of the image\n"
" -interlace type type of image interlacing scheme\n"
" -limit type value pixel cache resource limit\n"
" -lowlight-color color\n"
" de-emphasize pixel differences with this color\n"
" -metric type measure differences between images with this metric\n"
" -monitor monitor progress\n"
" -negate replace every pixel with its complementary color \n"
" -passphrase filename get the passphrase from this file\n"
" -precision value maximum number of significant digits to print\n"
" -profile filename add, delete, or apply an image profile\n"
" -quality value JPEG/MIFF/PNG compression level\n"
" -quiet suppress all warning messages\n"
" -quantize colorspace reduce colors in this colorspace\n"
" -read-mask filename associate a read mask with the image\n"
" -regard-warnings pay attention to warning messages\n"
" -respect-parentheses settings remain in effect until parenthesis boundary\n"
" -sampling-factor geometry\n"
" horizontal and vertical sampling factor\n"
" -seed value seed a new sequence of pseudo-random numbers\n"
" -set attribute value set an image attribute\n"
" -quality value JPEG/MIFF/PNG compression level\n"
" -repage geometry size and location of an image canvas\n"
" -similarity-threshold value\n"
" minimum distortion for (sub)image match\n"
" -size geometry width and height of image\n"
" -subimage-search search for subimage\n"
" -synchronize synchronize image to storage device\n"
" -taint declare the image as modified\n"
" -transparent-color color\n"
" transparent color\n"
" -type type image type\n"
" -verbose print detailed information about the image\n"
" -version print version information\n"
" -virtual-pixel method\n"
" virtual pixel access method\n"
" -write-mask filename associate a write mask with the image",
stack_operators[] =
" -delete indexes delete the image from the image sequence";
ListMagickVersion(stdout);
(void) printf("Usage: %s [options ...] image reconstruct difference\n",
GetClientName());
(void) printf("\nImage Settings:\n");
(void) puts(settings);
(void) printf("\nImage Operators:\n");
(void) puts(operators);
(void) printf("\nImage Channel Operators:\n");
(void) puts(channel_operators);
(void) printf("\nImage Sequence Operators:\n");
(void) puts(sequence_operators);
(void) printf("\nImage Stack Operators:\n");
(void) puts(stack_operators);
(void) printf("\nMiscellaneous Options:\n");
(void) puts(miscellaneous);
(void) printf(
"\nBy default, the image format of 'file' is determined by its magic\n");
(void) printf(
"number. To specify a particular image format, precede the filename\n");
(void) printf(
"with an image format name and a colon (i.e. ps:image) or specify the\n");
(void) printf(
"image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
(void) printf("'-' for standard input or output.\n");
return(MagickFalse);
}
WandExport MagickBooleanType CompareImagesCommand(ImageInfo *image_info,
int argc,char **argv,char **metadata,ExceptionInfo *exception)
{
#define CompareEpsilon (1.0e-06)
#define DefaultDissimilarityThreshold 0.31830988618379067154
#define DefaultSimilarityThreshold (-1.0)
#define DestroyCompare() \
{ \
if (similarity_image != (Image *) NULL) \
similarity_image=DestroyImageList(similarity_image); \
if (difference_image != (Image *) NULL) \
difference_image=DestroyImageList(difference_image); \
DestroyImageStack(); \
for (i=0; i < (ssize_t) argc; i++) \
argv[i]=DestroyString(argv[i]); \
argv=(char **) RelinquishMagickMemory(argv); \
}
#define ThrowCompareException(asperity,tag,option) \
{ \
if (exception->severity < (asperity)) \
(void) ThrowMagickException(exception,GetMagickModule(),asperity,tag, \
"`%s'",option); \
DestroyCompare(); \
return(MagickFalse); \
}
#define ThrowCompareInvalidArgumentException(option,argument) \
{ \
(void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
"InvalidArgument","'%s': %s",option,argument); \
DestroyCompare(); \
return(MagickFalse); \
}
char
*filename,
*option;
const char
*format;
double
dissimilarity_threshold,
distortion,
similarity_metric,
similarity_threshold;
Image
*difference_image,
*image,
*reconstruct_image,
*similarity_image;
ImageStack
image_stack[MaxImageStackDepth+1];
MagickBooleanType
fire,
pend,
respect_parenthesis,
subimage_search;
MagickStatusType
status;
MetricType
metric;
RectangleInfo
offset;
register ssize_t
i;
ssize_t
j,
k;
/*
Set defaults.
*/
assert(image_info != (ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(exception != (ExceptionInfo *) NULL);
if (argc == 2)
{
option=argv[1];
if ((LocaleCompare("version",option+1) == 0) ||
(LocaleCompare("-version",option+1) == 0))
{
ListMagickVersion(stdout);
return(MagickTrue);
}
}
if (argc < 3)
return(CompareUsage());
difference_image=NewImageList();
similarity_image=NewImageList();
dissimilarity_threshold=DefaultDissimilarityThreshold;
similarity_threshold=DefaultSimilarityThreshold;
distortion=0.0;
format=(char *) NULL;
j=1;
k=0;
metric=UndefinedErrorMetric;
NewImageStack();
option=(char *) NULL;
pend=MagickFalse;
reconstruct_image=NewImageList();
respect_parenthesis=MagickFalse;
status=MagickTrue;
subimage_search=MagickFalse;
/*
Compare an image.
*/
ReadCommandlLine(argc,&argv);
status=ExpandFilenames(&argc,&argv);
if (status == MagickFalse)
ThrowCompareException(ResourceLimitError,"MemoryAllocationFailed",
GetExceptionMessage(errno));
for (i=1; i < (ssize_t) (argc-1); i++)
{
option=argv[i];
if (LocaleCompare(option,"(") == 0)
{
FireImageStack(MagickTrue,MagickTrue,pend);
if (k == MaxImageStackDepth)
ThrowCompareException(OptionError,"ParenthesisNestedTooDeeply",
option);
PushImageStack();
continue;
}
if (LocaleCompare(option,")") == 0)
{
FireImageStack(MagickTrue,MagickTrue,MagickTrue);
if (k == 0)
ThrowCompareException(OptionError,"UnableToParseExpression",option);
PopImageStack();
continue;
}
if (IsCommandOption(option) == MagickFalse)
{
Image
*images;
/*
Read input image.
*/
FireImageStack(MagickFalse,MagickFalse,pend);
filename=argv[i];
if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
filename=argv[++i];
images=ReadImages(image_info,filename,exception);
status&=(images != (Image *) NULL) &&
(exception->severity < ErrorException);
if (images == (Image *) NULL)
continue;
AppendImageStack(images);
continue;
}
pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
switch (*(option+1))
{
case 'a':
{
if (LocaleCompare("alpha",option+1) == 0)
{
ssize_t
type;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
argv[i]);
if (type < 0)
ThrowCompareException(OptionError,
"UnrecognizedAlphaChannelOption",argv[i]);
break;
}
if (LocaleCompare("authenticate",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
break;
}
ThrowCompareException(OptionError,"UnrecognizedOption",option);
}
case 'b':
{
if (LocaleCompare("background",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
break;
}
if (LocaleCompare("brightness-contrast",option+1) == 0)
{
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
ThrowCompareException(OptionError,"UnrecognizedOption",option);
}
case 'c':
{
if (LocaleCompare("cache",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("channel",option+1) == 0)
{
ssize_t
channel;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
channel=ParseChannelOption(argv[i]);
if (channel < 0)
ThrowCompareException(OptionError,"UnrecognizedChannelType",
argv[i]);
break;
}
if (LocaleCompare("colorspace",option+1) == 0)
{
ssize_t
colorspace;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
argv[i]);
if (colorspace < 0)
ThrowCompareException(OptionError,"UnrecognizedColorspace",
argv[i]);
break;
}
if (LocaleCompare("compose",option+1) == 0)
{
ssize_t
compose;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
compose=ParseCommandOption(MagickComposeOptions,MagickFalse,
argv[i]);
if (compose < 0)
ThrowCompareException(OptionError,"UnrecognizedComposeOperator",
argv[i]);
break;
}
if (LocaleCompare("compress",option+1) == 0)
{
ssize_t
compress;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
argv[i]);
if (compress < 0)
ThrowCompareException(OptionError,"UnrecognizedImageCompression",
argv[i]);
break;
}
if (LocaleCompare("concurrent",option+1) == 0)
break;
if (LocaleCompare("crop",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 'd':
{
if (LocaleCompare("debug",option+1) == 0)
{
LogEventType
event_mask;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
event_mask=SetLogEventMask(argv[i]);
if (event_mask == UndefinedEvents)
ThrowCompareException(OptionError,"UnrecognizedEventType",
argv[i]);
break;
}
if (LocaleCompare("decipher",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
break;
}
if (LocaleCompare("define",option+1) == 0)
{
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (*option == '+')
{
const char
*define;
define=GetImageOption(image_info,argv[i]);
if (define == (const char *) NULL)
ThrowCompareException(OptionError,"NoSuchOption",argv[i]);
break;
}
break;
}
if (LocaleCompare("delete",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("density",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("depth",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("dissimilarity-threshold",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
if (*option == '+')
dissimilarity_threshold=DefaultDissimilarityThreshold;
else
dissimilarity_threshold=StringToDouble(argv[i],(char **) NULL);
break;
}
if (LocaleCompare("distort",option+1) == 0)
{
ssize_t
op;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]);
if (op < 0)
ThrowCompareException(OptionError,"UnrecognizedDistortMethod",
argv[i]);
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
break;
}
if (LocaleCompare("duration",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 'e':
{
if (LocaleCompare("encipher",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
break;
}
if (LocaleCompare("extract",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 'f':
{
if (LocaleCompare("format",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
format=argv[i];
break;
}
if (LocaleCompare("fuzz",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 'g':
{
if (LocaleCompare("gravity",option+1) == 0)
{
ssize_t
gravity;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
argv[i]);
if (gravity < 0)
ThrowCompareException(OptionError,"UnrecognizedGravityType",
argv[i]);
break;
}
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 'h':
{
if ((LocaleCompare("help",option+1) == 0) ||
(LocaleCompare("-help",option+1) == 0))
return(CompareUsage());
if (LocaleCompare("highlight-color",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
break;
}
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 'i':
{
if (LocaleCompare("identify",option+1) == 0)
break;
if (LocaleCompare("interlace",option+1) == 0)
{
ssize_t
interlace;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
argv[i]);
if (interlace < 0)
ThrowCompareException(OptionError,"UnrecognizedInterlaceType",
argv[i]);
break;
}
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 'l':
{
if (LocaleCompare("level",option+1) == 0)
{
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("limit",option+1) == 0)
{
char
*p;
double
value;
ssize_t
resource;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
argv[i]);
if (resource < 0)
ThrowCompareException(OptionError,"UnrecognizedResourceType",
argv[i]);
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
value=StringToDouble(argv[i],&p);
(void) value;
if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("list",option+1) == 0)
{
ssize_t
list;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
if (list < 0)
ThrowCompareException(OptionError,"UnrecognizedListType",argv[i]);
status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
argv+j,exception);
DestroyCompare();
return(status == 0 ? MagickFalse : MagickTrue);
}
if (LocaleCompare("log",option+1) == 0)
{
if (*option == '+')
break;
i++;
if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL))
ThrowCompareException(OptionError,"MissingArgument",option);
break;
}
if (LocaleCompare("lowlight-color",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
break;
}
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 'm':
{
if (LocaleCompare("matte",option+1) == 0)
break;
if (LocaleCompare("metric",option+1) == 0)
{
ssize_t
type;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]);
if (type < 0)
ThrowCompareException(OptionError,"UnrecognizedMetricType",
argv[i]);
metric=(MetricType) type;
break;
}
if (LocaleCompare("monitor",option+1) == 0)
break;
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 'n':
{
if (LocaleCompare("negate",option+1) == 0)
break;
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 'p':
{
if (LocaleCompare("passphrase",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
break;
}
if (LocaleCompare("precision",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("profile",option+1) == 0)
{
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
break;
}
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 'q':
{
if (LocaleCompare("quality",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("quantize",option+1) == 0)
{
ssize_t
colorspace;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
colorspace=ParseCommandOption(MagickColorspaceOptions,
MagickFalse,argv[i]);
if (colorspace < 0)
ThrowCompareException(OptionError,"UnrecognizedColorspace",
argv[i]);
break;
}
if (LocaleCompare("quiet",option+1) == 0)
break;
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 'r':
{
if (LocaleCompare("read-mask",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
break;
}
if (LocaleCompare("regard-warnings",option+1) == 0)
break;
if (LocaleCompare("repage",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("resize",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
{
respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
break;
}
if (LocaleCompare("rotate",option+1) == 0)
{
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
ThrowCompareException(OptionError,"UnrecognizedOption",option)
}
case 's':
{
if (LocaleCompare("sampling-factor",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("seed",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowCompareInvalidArgumentException(option,argv[i]);
break;
}
if (LocaleCompare("separate",option+1) == 0)
break;
if (LocaleCompare("set",option+1) == 0)
{
i++;
if (i == (ssize_t) argc)
ThrowCompareException(OptionError,"MissingArgument",option);
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)