]> granicus.if.org Git - imagemagick/blob - MagickWand/identify.c
(no commit message)
[imagemagick] / MagickWand / identify.c
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %                                                                             %
4 %                                                                             %
5 %                                                                             %
6 %           IIIII  DDDD   EEEEE  N   N  TTTTT  IIIII  FFFFF  Y   Y            %
7 %             I    D   D  E      NN  N    T      I    F       Y Y             %
8 %             I    D   D  EEE    N N N    T      I    FFF      Y              %
9 %             I    D   D  E      N  NN    T      I    F        Y              %
10 %           IIIII  DDDD   EEEEE  N   N    T    IIIII  F        Y              %
11 %                                                                             %
12 %                                                                             %
13 %               Identify an Image Format and Characteristics.                 %
14 %                                                                             %
15 %                           Software Design                                   %
16 %                             John Cristy                                     %
17 %                            September 1994                                   %
18 %                                                                             %
19 %                                                                             %
20 %  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
21 %  dedicated to making software imaging solutions freely available.           %
22 %                                                                             %
23 %  You may not use this file except in compliance with the License.  You may  %
24 %  obtain a copy of the License at                                            %
25 %                                                                             %
26 %    http://www.imagemagick.org/script/license.php                            %
27 %                                                                             %
28 %  Unless required by applicable law or agreed to in writing, software        %
29 %  distributed under the License is distributed on an "AS IS" BASIS,          %
30 %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
31 %  See the License for the specific language governing permissions and        %
32 %  limitations under the License.                                             %
33 %                                                                             %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %  The identify program describes the format and characteristics of one or more
37 %  image files. It also reports if an image is incomplete or corrupt. The
38 %  information returned includes the image number, the file name, the width and
39 %  height of the image, whether the image is colormapped or not, the number of
40 %  colors in the image, the number of bytes in the image, the format of the
41 %  image (JPEG, PNM, etc.), and finally the number of seconds it took to read
42 %  and process the image. Many more attributes are available with the verbose
43 %  option.
44 %
45 */
46 \f
47 /*
48   Include declarations.
49 */
50 #include "MagickWand/studio.h"
51 #include "MagickWand/MagickWand.h"
52 #include "MagickWand/mogrify-private.h"
53 #include "MagickCore/string-private.h"
54 \f
55 /*
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 %                                                                             %
58 %                                                                             %
59 %                                                                             %
60 +   I d e n t i f y I m a g e C o m m a n d                                   %
61 %                                                                             %
62 %                                                                             %
63 %                                                                             %
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 %
66 %  IdentifyImageCommand() describes the format and characteristics of one or
67 %  more image files. It will also report if an image is incomplete or corrupt.
68 %  The information displayed includes the scene number, the file name, the
69 %  width and height of the image, whether the image is colormapped or not,
70 %  the number of colors in the image, the number of bytes in the image, the
71 %  format of the image (JPEG, PNM, etc.), and finally the number of seconds
72 %  it took to read and process the image.
73 %
74 %  The format of the IdentifyImageCommand method is:
75 %
76 %      MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,int argc,
77 %        char **argv,char **metadata,ExceptionInfo *exception)
78 %
79 %  A description of each parameter follows:
80 %
81 %    o image_info: the image info.
82 %
83 %    o argc: the number of elements in the argument vector.
84 %
85 %    o argv: A text array containing the command line arguments.
86 %
87 %    o metadata: any metadata is returned here.
88 %
89 %    o exception: return any errors or warnings in this structure.
90 %
91 */
92
93 static MagickBooleanType IdentifyUsage(void)
94 {
95   const char
96     **p;
97
98   static const char
99     *miscellaneous[]=
100     {
101       "-debug events        display copious debugging information",
102       "-help                print program options",
103       "-list type           print a list of supported option arguments",
104       "-log format          format of debugging information",
105       "-version             print version information",
106       (char *) NULL
107     },
108     *operators[]=
109     {
110       "-negate              replace every pixel with its complementary color ",
111       (char *) NULL
112     },
113     *settings[]=
114     {
115       "-alpha option        on, activate, off, deactivate, set, opaque, copy",
116       "                     transparent, extract, background, or shape",
117       "-antialias           remove pixel-aliasing",
118       "-authenticate password",
119       "                     decipher image with this password",
120       "-channel type        apply option to select image channels",
121       "-colorspace type     alternate image colorspace",
122       "-crop geometry       cut out a rectangular region of the image",
123       "-define format:option",
124       "                     define one or more image format options",
125       "-density geometry    horizontal and vertical density of the image",
126       "-depth value         image depth",
127       "-extract geometry    extract area from image",
128       "-features distance   display image features (e.g. contrast, correlation)",
129       "-format \"string\"     output formatted image characteristics",
130       "-fuzz distance       colors within this distance are considered equal",
131       "-gamma value         of gamma correction",
132       "-interlace type      type of image interlacing scheme",
133       "-interpolate method  pixel color interpolation method",
134       "-limit type value    pixel cache resource limit",
135       "-monitor             monitor progress",
136       "-ping                efficiently determine image attributes",
137       "-quiet               suppress all warning messages",
138       "-regard-warnings     pay attention to warning messages",
139       "-respect-parentheses settings remain in effect until parenthesis boundary",
140       "-sampling-factor geometry",
141       "                     horizontal and vertical sampling factor",
142       "-seed value          seed a new sequence of pseudo-random numbers",
143       "-set attribute value set an image attribute",
144       "-size geometry       width and height of image",
145       "-strip               strip image of all profiles and comments",
146       "-unique              display the number of unique colors in the image",
147       "-units type          the units of image resolution",
148       "-verbose             print detailed information about the image",
149       "-virtual-pixel method",
150       "                     virtual pixel access method",
151       (char *) NULL
152     };
153
154   (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
155   (void) printf("Copyright: %s\n",GetMagickCopyright());
156   (void) printf("Features: %s\n\n",GetMagickFeatures());
157   (void) printf("Usage: %s [options ...] file [ [options ...] "
158     "file ... ]\n",GetClientName());
159   (void) printf("\nImage Settings:\n");
160   for (p=settings; *p != (char *) NULL; p++)
161     (void) printf("  %s\n",*p);
162   (void) printf("\nImage Operators:\n");
163   for (p=operators; *p != (char *) NULL; p++)
164     (void) printf("  %s\n",*p);
165   (void) printf("\nMiscellaneous Options:\n");
166   for (p=miscellaneous; *p != (char *) NULL; p++)
167     (void) printf("  %s\n",*p);
168   (void) printf(
169     "\nBy default, the image format of 'file' is determined by its magic\n");
170   (void) printf(
171     "number.  To specify a particular image format, precede the filename\n");
172   (void) printf(
173     "with an image format name and a colon (i.e. ps:image) or specify the\n");
174   (void) printf(
175     "image type as the filename suffix (i.e. image.ps).  Specify 'file' as\n");
176   (void) printf("'-' for standard input or output.\n");
177   return(MagickFalse);
178 }
179
180 WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
181   int argc,char **argv,char **metadata,ExceptionInfo *exception)
182 {
183 #define DestroyIdentify() \
184 { \
185   DestroyImageStack(); \
186   for (i=0; i < (ssize_t) argc; i++) \
187     argv[i]=DestroyString(argv[i]); \
188   argv=(char **) RelinquishMagickMemory(argv); \
189 }
190 #define ThrowIdentifyException(asperity,tag,option) \
191 { \
192   (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"'%s'", \
193     option); \
194   DestroyIdentify(); \
195   return(MagickFalse); \
196 }
197 #define ThrowIdentifyInvalidArgumentException(option,argument) \
198 { \
199   (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
200     "InvalidArgument","'%s': %s",option,argument); \
201   DestroyIdentify(); \
202   return(MagickFalse); \
203 }
204
205   const char
206     *format,
207     *option;
208
209   Image
210     *image;
211
212   ImageStack
213     image_stack[MaxImageStackDepth+1];
214
215   MagickBooleanType
216     fire,
217     pend,
218     respect_parenthesis;
219
220   MagickStatusType
221     status;
222
223   register ssize_t
224     i;
225
226   size_t
227     count;
228
229   ssize_t
230     j,
231     k;
232
233   /*
234     Set defaults.
235   */
236   assert(image_info != (ImageInfo *) NULL);
237   assert(image_info->signature == MagickSignature);
238   if (image_info->debug != MagickFalse)
239     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
240   assert(exception != (ExceptionInfo *) NULL);
241   if (argc == 2)
242     {
243       option=argv[1];
244       if ((LocaleCompare("version",option+1) == 0) ||
245           (LocaleCompare("-version",option+1) == 0))
246         {
247           (void) FormatLocaleFile(stdout,"Version: %s\n",
248             GetMagickVersion((size_t *) NULL));
249           (void) FormatLocaleFile(stdout,"Copyright: %s\n",
250             GetMagickCopyright());
251           (void) FormatLocaleFile(stdout,"Features: %s\n\n",
252             GetMagickFeatures());
253           return(MagickFalse);
254         }
255     }
256   if (argc < 2)
257     return(IdentifyUsage());
258   count=0;
259   format=NULL;
260   j=1;
261   k=0;
262   NewImageStack();
263   option=(char *) NULL;
264   pend=MagickFalse;
265   respect_parenthesis=MagickFalse;
266   status=MagickTrue;
267   /*
268     Identify an image.
269   */
270   ReadCommandlLine(argc,&argv);
271   status=ExpandFilenames(&argc,&argv);
272   if (status == MagickFalse)
273     ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed",
274       GetExceptionMessage(errno));
275   image_info->ping=MagickTrue;
276   for (i=1; i < (ssize_t) argc; i++)
277   {
278     option=argv[i];
279     if (LocaleCompare(option,"(") == 0)
280       {
281         FireImageStack(MagickFalse,MagickTrue,pend);
282         if (k == MaxImageStackDepth)
283           ThrowIdentifyException(OptionError,"ParenthesisNestedTooDeeply",
284             option);
285         PushImageStack();
286         continue;
287       }
288     if (LocaleCompare(option,")") == 0)
289       {
290         FireImageStack(MagickFalse,MagickTrue,MagickTrue);
291         if (k == 0)
292           ThrowIdentifyException(OptionError,"UnableToParseExpression",option);
293         PopImageStack();
294         continue;
295       }
296     if (IsCommandOption(option) == MagickFalse)
297       {
298         char
299           *filename;
300
301         Image
302           *images;
303
304         ImageInfo
305           *identify_info;
306
307         /*
308           Read input image.
309         */
310         FireImageStack(MagickFalse,MagickFalse,pend);
311         identify_info=CloneImageInfo(image_info);
312         identify_info->verbose=MagickFalse;
313         filename=argv[i];
314         if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
315           filename=argv[++i];
316         if (identify_info->ping != MagickFalse)
317           images=PingImages(identify_info,filename,exception);
318         else
319           images=ReadImages(identify_info,filename,exception);
320         identify_info=DestroyImageInfo(identify_info);
321         status&=(images != (Image *) NULL) &&
322           (exception->severity < ErrorException);
323         if (images == (Image *) NULL)
324           continue;
325         AppendImageStack(images);
326         FinalizeImageSettings(image_info,image,MagickFalse);
327         for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
328         {
329           if (image->scene == 0)
330             image->scene=count++;
331           if (format == (char *) NULL)
332             {
333               (void) IdentifyImage(image,stdout,image_info->verbose,exception);
334               continue;
335             }
336           if (metadata != (char **) NULL)
337             {
338               char
339                 *text;
340
341               text=InterpretImageProperties(image_info,image,format,exception);
342               if (text == (char *) NULL)
343                 ThrowIdentifyException(ResourceLimitError,
344                   "MemoryAllocationFailed",GetExceptionMessage(errno));
345               (void) ConcatenateString(&(*metadata),text);
346               text=DestroyString(text);
347               if (LocaleCompare(format,"%n") == 0)
348                 break;
349             }
350         }
351         RemoveAllImageStack();
352         continue;
353       }
354     pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
355     switch (*(option+1))
356     {
357       case 'a':
358       {
359         if (LocaleCompare("alpha",option+1) == 0)
360           {
361             ssize_t
362               type;
363
364             if (*option == '+')
365               break;
366             i++;
367             if (i == (ssize_t) argc)
368               ThrowIdentifyException(OptionError,"MissingArgument",option);
369             type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
370             if (type < 0)
371               ThrowIdentifyException(OptionError,"UnrecognizedAlphaChannelType",
372                 argv[i]);
373             break;
374           }
375         if (LocaleCompare("antialias",option+1) == 0)
376           break;
377         if (LocaleCompare("authenticate",option+1) == 0)
378           {
379             if (*option == '+')
380               break;
381             i++;
382             if (i == (ssize_t) (argc-1))
383               ThrowIdentifyException(OptionError,"MissingArgument",option);
384             break;
385           }
386         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
387       }
388       case 'c':
389       {
390         if (LocaleCompare("cache",option+1) == 0)
391           {
392             if (*option == '+')
393               break;
394             i++;
395             if (i == (ssize_t) argc)
396               ThrowIdentifyException(OptionError,"MissingArgument",option);
397             if (IsGeometry(argv[i]) == MagickFalse)
398               ThrowIdentifyInvalidArgumentException(option,argv[i]);
399             break;
400           }
401         if (LocaleCompare("channel",option+1) == 0)
402           {
403             ssize_t
404               channel;
405
406             if (*option == '+')
407               break;
408             i++;
409             if (i == (ssize_t) (argc-1))
410               ThrowIdentifyException(OptionError,"MissingArgument",option);
411             channel=ParseChannelOption(argv[i]);
412             if (channel < 0)
413               ThrowIdentifyException(OptionError,"UnrecognizedChannelType",
414                 argv[i]);
415             break;
416           }
417         if (LocaleCompare("colorspace",option+1) == 0)
418           {
419             ssize_t
420               colorspace;
421
422             if (*option == '+')
423               break;
424             i++;
425             if (i == (ssize_t) (argc-1))
426               ThrowIdentifyException(OptionError,"MissingArgument",option);
427             colorspace=ParseCommandOption(MagickColorspaceOptions,
428               MagickFalse,argv[i]);
429             if (colorspace < 0)
430               ThrowIdentifyException(OptionError,"UnrecognizedColorspace",
431                 argv[i]);
432             break;
433           }
434         if (LocaleCompare("crop",option+1) == 0)
435           {
436             if (*option == '+')
437               break;
438             i++;
439             if (i == (ssize_t) (argc-1))
440               ThrowIdentifyException(OptionError,"MissingArgument",option);
441             if (IsGeometry(argv[i]) == MagickFalse)
442               ThrowIdentifyInvalidArgumentException(option,argv[i]);
443             image_info->ping=MagickFalse;
444             break;
445           }
446         if (LocaleCompare("concurrent",option+1) == 0)
447           break;
448         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
449       }
450       case 'd':
451       {
452         if (LocaleCompare("debug",option+1) == 0)
453           {
454             ssize_t
455               event;
456
457             if (*option == '+')
458               break;
459             i++;
460             if (i == (ssize_t) argc)
461               ThrowIdentifyException(OptionError,"MissingArgument",option);
462             event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
463             if (event < 0)
464               ThrowIdentifyException(OptionError,"UnrecognizedEventType",
465                 argv[i]);
466             (void) SetLogEventMask(argv[i]);
467             break;
468           }
469         if (LocaleCompare("define",option+1) == 0)
470           {
471             i++;
472             if (i == (ssize_t) argc)
473               ThrowIdentifyException(OptionError,"MissingArgument",option);
474             if (*option == '+')
475               {
476                 const char
477                   *define;
478
479                 define=GetImageOption(image_info,argv[i]);
480                 if (define == (const char *) NULL)
481                   ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]);
482                 break;
483               }
484             break;
485           }
486         if (LocaleCompare("density",option+1) == 0)
487           {
488             if (*option == '+')
489               break;
490             i++;
491             if (i == (ssize_t) argc)
492               ThrowIdentifyException(OptionError,"MissingArgument",option);
493             if (IsGeometry(argv[i]) == MagickFalse)
494               ThrowIdentifyInvalidArgumentException(option,argv[i]);
495             break;
496           }
497         if (LocaleCompare("depth",option+1) == 0)
498           {
499             if (*option == '+')
500               break;
501             i++;
502             if (i == (ssize_t) argc)
503               ThrowIdentifyException(OptionError,"MissingArgument",option);
504             if (IsGeometry(argv[i]) == MagickFalse)
505               ThrowIdentifyInvalidArgumentException(option,argv[i]);
506             break;
507           }
508         if (LocaleCompare("duration",option+1) == 0)
509           {
510             if (*option == '+')
511               break;
512             i++;
513             if (i == (ssize_t) (argc-1))
514               ThrowIdentifyException(OptionError,"MissingArgument",option);
515             if (IsGeometry(argv[i]) == MagickFalse)
516               ThrowIdentifyInvalidArgumentException(option,argv[i]);
517             break;
518           }
519         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
520       }
521       case 'f':
522       {
523         if (LocaleCompare("features",option+1) == 0)
524           {
525             if (*option == '+')
526               break;
527             i++;
528             if (i == (ssize_t) (argc-1))
529               ThrowIdentifyException(OptionError,"MissingArgument",option);
530             if (IsGeometry(argv[i]) == MagickFalse)
531               ThrowIdentifyInvalidArgumentException(option,argv[i]);
532             break;
533           }
534         if (LocaleCompare("format",option+1) == 0)
535           {
536             format=(char *) NULL;
537             if (*option == '+')
538               break;
539             i++;
540             if (i == (ssize_t) argc)
541               ThrowIdentifyException(OptionError,"MissingArgument",option);
542             format=argv[i];
543             break;
544           }
545         if (LocaleCompare("fuzz",option+1) == 0)
546           {
547             if (*option == '+')
548               break;
549             i++;
550             if (i == (ssize_t) (argc-1))
551               ThrowIdentifyException(OptionError,"MissingArgument",option);
552             if (IsGeometry(argv[i]) == MagickFalse)
553               ThrowIdentifyInvalidArgumentException(option,argv[i]);
554             break;
555           }
556         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
557       }
558       case 'g':
559       {
560         if (LocaleCompare("gamma",option+1) == 0)
561           {
562             i++;
563             if (i == (ssize_t) (argc-1))
564               ThrowIdentifyException(OptionError,"MissingArgument",option);
565             if (IsGeometry(argv[i]) == MagickFalse)
566               ThrowIdentifyInvalidArgumentException(option,argv[i]);
567             break;
568           }
569         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
570       }
571       case 'h':
572       {
573         if ((LocaleCompare("help",option+1) == 0) ||
574             (LocaleCompare("-help",option+1) == 0))
575           return(IdentifyUsage());
576         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
577       }
578       case 'i':
579       {
580         if (LocaleCompare("interlace",option+1) == 0)
581           {
582             ssize_t
583               interlace;
584
585             if (*option == '+')
586               break;
587             i++;
588             if (i == (ssize_t) argc)
589               ThrowIdentifyException(OptionError,"MissingArgument",option);
590             interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
591               argv[i]);
592             if (interlace < 0)
593               ThrowIdentifyException(OptionError,
594                 "UnrecognizedInterlaceType",argv[i]);
595             break;
596           }
597         if (LocaleCompare("interpolate",option+1) == 0)
598           {
599             ssize_t
600               interpolate;
601
602             if (*option == '+')
603               break;
604             i++;
605             if (i == (ssize_t) argc)
606               ThrowIdentifyException(OptionError,"MissingArgument",option);
607             interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
608               argv[i]);
609             if (interpolate < 0)
610               ThrowIdentifyException(OptionError,
611                 "UnrecognizedInterpolateMethod",argv[i]);
612             break;
613           }
614         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
615       }
616       case 'l':
617       {
618         if (LocaleCompare("limit",option+1) == 0)
619           {
620             char
621               *p;
622
623             double
624               value;
625
626             ssize_t
627               resource;
628
629             if (*option == '+')
630               break;
631             i++;
632             if (i == (ssize_t) argc)
633               ThrowIdentifyException(OptionError,"MissingArgument",option);
634             resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
635               argv[i]);
636             if (resource < 0)
637               ThrowIdentifyException(OptionError,"UnrecognizedResourceType",
638                 argv[i]);
639             i++;
640             if (i == (ssize_t) argc)
641               ThrowIdentifyException(OptionError,"MissingArgument",option);
642             value=StringToDouble(argv[i],&p);
643             (void) value;
644             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
645               ThrowIdentifyInvalidArgumentException(option,argv[i]);
646             break;
647           }
648         if (LocaleCompare("list",option+1) == 0)
649           {
650             ssize_t
651               list;
652
653             if (*option == '+')
654               break;
655             i++;
656             if (i == (ssize_t) argc)
657               ThrowIdentifyException(OptionError,"MissingArgument",option);
658             list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
659             if (list < 0)
660               ThrowIdentifyException(OptionError,"UnrecognizedListType",
661                 argv[i]);
662             status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
663               argv+j,exception);
664             DestroyIdentify();
665             return(status != 0 ? MagickFalse : MagickTrue);
666           }
667         if (LocaleCompare("log",option+1) == 0)
668           {
669             if (*option == '+')
670               break;
671             i++;
672             if ((i == (ssize_t) argc) ||
673                 (strchr(argv[i],'%') == (char *) NULL))
674               ThrowIdentifyException(OptionError,"MissingArgument",option);
675             break;
676           }
677         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
678       }
679       case 'm':
680       {
681         if (LocaleCompare("matte",option+1) == 0)
682           break;
683         if (LocaleCompare("monitor",option+1) == 0)
684           break;
685         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
686       }
687       case 'n':
688       {
689         if (LocaleCompare("negate",option+1) == 0)
690           break;
691         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
692       }
693       case 'p':
694       {
695         if (LocaleCompare("ping",option+1) == 0)
696           break;
697         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
698       }
699       case 'q':
700       {
701         if (LocaleCompare("quiet",option+1) == 0)
702           break;
703         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
704       }
705       case 'r':
706       {
707         if (LocaleCompare("regard-warnings",option+1) == 0)
708           break;
709         if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
710           {
711             respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
712             break;
713           }
714         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
715       }
716       case 's':
717       {
718         if (LocaleCompare("sampling-factor",option+1) == 0)
719           {
720             if (*option == '+')
721               break;
722             i++;
723             if (i == (ssize_t) argc)
724               ThrowIdentifyException(OptionError,"MissingArgument",option);
725             if (IsGeometry(argv[i]) == MagickFalse)
726               ThrowIdentifyInvalidArgumentException(option,argv[i]);
727             break;
728           }
729         if (LocaleCompare("seed",option+1) == 0)
730           {
731             if (*option == '+')
732               break;
733             i++;
734             if (i == (ssize_t) (argc-1))
735               ThrowIdentifyException(OptionError,"MissingArgument",option);
736             if (IsGeometry(argv[i]) == MagickFalse)
737               ThrowIdentifyInvalidArgumentException(option,argv[i]);
738             break;
739           }
740         if (LocaleCompare("set",option+1) == 0)
741           {
742             i++;
743             if (i == (ssize_t) argc)
744               ThrowIdentifyException(OptionError,"MissingArgument",option);
745             if (*option == '+')
746               break;
747             i++;
748             if (i == (ssize_t) argc)
749               ThrowIdentifyException(OptionError,"MissingArgument",option);
750             break;
751           }
752         if (LocaleCompare("size",option+1) == 0)
753           {
754             if (*option == '+')
755               break;
756             i++;
757             if (i == (ssize_t) argc)
758               ThrowIdentifyException(OptionError,"MissingArgument",option);
759             if (IsGeometry(argv[i]) == MagickFalse)
760               ThrowIdentifyInvalidArgumentException(option,argv[i]);
761             break;
762           }
763         if (LocaleCompare("strip",option+1) == 0)
764           break;
765         if (LocaleCompare("support",option+1) == 0)
766           {
767             if (*option == '+')
768               break;
769             i++;
770             if (i == (ssize_t) argc)
771               ThrowIdentifyException(OptionError,"MissingArgument",option);
772             if (IsGeometry(argv[i]) == MagickFalse)
773               ThrowIdentifyInvalidArgumentException(option,argv[i]);
774             break;
775           }
776         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
777       }
778       case 'u':
779       {
780         if (LocaleCompare("unique",option+1) == 0)
781           break;
782         if (LocaleCompare("units",option+1) == 0)
783           {
784             ssize_t
785               units;
786
787             if (*option == '+')
788               break;
789             i++;
790             if (i == (ssize_t) (argc-1))
791               ThrowIdentifyException(OptionError,"MissingArgument",option);
792             units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
793               argv[i]);
794             if (units < 0)
795               ThrowIdentifyException(OptionError,"UnrecognizedUnitsType",
796                 argv[i]);
797             break;
798           }
799         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
800       }
801       case 'v':
802       {
803         if (LocaleCompare("verbose",option+1) == 0)
804           break;
805         if (LocaleCompare("virtual-pixel",option+1) == 0)
806           {
807             ssize_t
808               method;
809
810             if (*option == '+')
811               break;
812             i++;
813             if (i == (ssize_t) (argc-1))
814               ThrowIdentifyException(OptionError,"MissingArgument",option);
815             method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
816               argv[i]);
817             if (method < 0)
818               ThrowIdentifyException(OptionError,
819                 "UnrecognizedVirtualPixelMethod",argv[i]);
820             break;
821           }
822         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
823       }
824       case '?':
825         break;
826       default:
827         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
828     }
829     fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
830       FireOptionFlag) == 0 ?  MagickFalse : MagickTrue;
831     if (fire != MagickFalse)
832       FireImageStack(MagickFalse,MagickTrue,MagickTrue);
833   }
834   if (k != 0)
835     ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]);
836   if (i != (ssize_t) argc)
837     ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]);
838   DestroyIdentify();
839   return(status != 0 ? MagickTrue : MagickFalse);
840 }