]> granicus.if.org Git - imagemagick/blob - MagickWand/identify.c
Removed 3 redundant lines of code from coders/png.c
[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         (void) CopyMagickString(identify_info->filename,filename,MaxTextExtent);
317         if (identify_info->ping != MagickFalse)
318           images=PingImages(identify_info,exception);
319         else
320           images=ReadImages(identify_info,exception);
321         identify_info=DestroyImageInfo(identify_info);
322         status&=(images != (Image *) NULL) &&
323           (exception->severity < ErrorException);
324         if (images == (Image *) NULL)
325           continue;
326         AppendImageStack(images);
327         FinalizeImageSettings(image_info,image,MagickFalse);
328         for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
329         {
330           if (image->scene == 0)
331             image->scene=count++;
332           if (format == (char *) NULL)
333             {
334               (void) IdentifyImage(image,stdout,image_info->verbose,exception);
335               continue;
336             }
337           if (metadata != (char **) NULL)
338             {
339               char
340                 *text;
341
342               text=InterpretImageProperties(image_info,image,format,exception);
343               if (text == (char *) NULL)
344                 ThrowIdentifyException(ResourceLimitError,
345                   "MemoryAllocationFailed",GetExceptionMessage(errno));
346               (void) ConcatenateString(&(*metadata),text);
347               text=DestroyString(text);
348               if (LocaleCompare(format,"%n") == 0)
349                 break;
350             }
351         }
352         RemoveAllImageStack();
353         continue;
354       }
355     pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
356     switch (*(option+1))
357     {
358       case 'a':
359       {
360         if (LocaleCompare("alpha",option+1) == 0)
361           {
362             ssize_t
363               type;
364
365             if (*option == '+')
366               break;
367             i++;
368             if (i == (ssize_t) argc)
369               ThrowIdentifyException(OptionError,"MissingArgument",option);
370             type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
371             if (type < 0)
372               ThrowIdentifyException(OptionError,"UnrecognizedAlphaChannelType",
373                 argv[i]);
374             break;
375           }
376         if (LocaleCompare("antialias",option+1) == 0)
377           break;
378         if (LocaleCompare("authenticate",option+1) == 0)
379           {
380             if (*option == '+')
381               break;
382             i++;
383             if (i == (ssize_t) (argc-1))
384               ThrowIdentifyException(OptionError,"MissingArgument",option);
385             break;
386           }
387         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
388       }
389       case 'c':
390       {
391         if (LocaleCompare("cache",option+1) == 0)
392           {
393             if (*option == '+')
394               break;
395             i++;
396             if (i == (ssize_t) argc)
397               ThrowIdentifyException(OptionError,"MissingArgument",option);
398             if (IsGeometry(argv[i]) == MagickFalse)
399               ThrowIdentifyInvalidArgumentException(option,argv[i]);
400             break;
401           }
402         if (LocaleCompare("channel",option+1) == 0)
403           {
404             ssize_t
405               channel;
406
407             if (*option == '+')
408               break;
409             i++;
410             if (i == (ssize_t) (argc-1))
411               ThrowIdentifyException(OptionError,"MissingArgument",option);
412             channel=ParseChannelOption(argv[i]);
413             if (channel < 0)
414               ThrowIdentifyException(OptionError,"UnrecognizedChannelType",
415                 argv[i]);
416             break;
417           }
418         if (LocaleCompare("colorspace",option+1) == 0)
419           {
420             ssize_t
421               colorspace;
422
423             if (*option == '+')
424               break;
425             i++;
426             if (i == (ssize_t) (argc-1))
427               ThrowIdentifyException(OptionError,"MissingArgument",option);
428             colorspace=ParseCommandOption(MagickColorspaceOptions,
429               MagickFalse,argv[i]);
430             if (colorspace < 0)
431               ThrowIdentifyException(OptionError,"UnrecognizedColorspace",
432                 argv[i]);
433             break;
434           }
435         if (LocaleCompare("crop",option+1) == 0)
436           {
437             if (*option == '+')
438               break;
439             i++;
440             if (i == (ssize_t) (argc-1))
441               ThrowIdentifyException(OptionError,"MissingArgument",option);
442             if (IsGeometry(argv[i]) == MagickFalse)
443               ThrowIdentifyInvalidArgumentException(option,argv[i]);
444             image_info->ping=MagickFalse;
445             break;
446           }
447         if (LocaleCompare("concurrent",option+1) == 0)
448           break;
449         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
450       }
451       case 'd':
452       {
453         if (LocaleCompare("debug",option+1) == 0)
454           {
455             ssize_t
456               event;
457
458             if (*option == '+')
459               break;
460             i++;
461             if (i == (ssize_t) argc)
462               ThrowIdentifyException(OptionError,"MissingArgument",option);
463             event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
464             if (event < 0)
465               ThrowIdentifyException(OptionError,"UnrecognizedEventType",
466                 argv[i]);
467             (void) SetLogEventMask(argv[i]);
468             break;
469           }
470         if (LocaleCompare("define",option+1) == 0)
471           {
472             i++;
473             if (i == (ssize_t) argc)
474               ThrowIdentifyException(OptionError,"MissingArgument",option);
475             if (*option == '+')
476               {
477                 const char
478                   *define;
479
480                 define=GetImageOption(image_info,argv[i]);
481                 if (define == (const char *) NULL)
482                   ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]);
483                 break;
484               }
485             break;
486           }
487         if (LocaleCompare("density",option+1) == 0)
488           {
489             if (*option == '+')
490               break;
491             i++;
492             if (i == (ssize_t) argc)
493               ThrowIdentifyException(OptionError,"MissingArgument",option);
494             if (IsGeometry(argv[i]) == MagickFalse)
495               ThrowIdentifyInvalidArgumentException(option,argv[i]);
496             break;
497           }
498         if (LocaleCompare("depth",option+1) == 0)
499           {
500             if (*option == '+')
501               break;
502             i++;
503             if (i == (ssize_t) argc)
504               ThrowIdentifyException(OptionError,"MissingArgument",option);
505             if (IsGeometry(argv[i]) == MagickFalse)
506               ThrowIdentifyInvalidArgumentException(option,argv[i]);
507             break;
508           }
509         if (LocaleCompare("duration",option+1) == 0)
510           {
511             if (*option == '+')
512               break;
513             i++;
514             if (i == (ssize_t) (argc-1))
515               ThrowIdentifyException(OptionError,"MissingArgument",option);
516             if (IsGeometry(argv[i]) == MagickFalse)
517               ThrowIdentifyInvalidArgumentException(option,argv[i]);
518             break;
519           }
520         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
521       }
522       case 'f':
523       {
524         if (LocaleCompare("features",option+1) == 0)
525           {
526             if (*option == '+')
527               break;
528             i++;
529             if (i == (ssize_t) (argc-1))
530               ThrowIdentifyException(OptionError,"MissingArgument",option);
531             if (IsGeometry(argv[i]) == MagickFalse)
532               ThrowIdentifyInvalidArgumentException(option,argv[i]);
533             break;
534           }
535         if (LocaleCompare("format",option+1) == 0)
536           {
537             format=(char *) NULL;
538             if (*option == '+')
539               break;
540             i++;
541             if (i == (ssize_t) argc)
542               ThrowIdentifyException(OptionError,"MissingArgument",option);
543             format=argv[i];
544             break;
545           }
546         if (LocaleCompare("fuzz",option+1) == 0)
547           {
548             if (*option == '+')
549               break;
550             i++;
551             if (i == (ssize_t) (argc-1))
552               ThrowIdentifyException(OptionError,"MissingArgument",option);
553             if (IsGeometry(argv[i]) == MagickFalse)
554               ThrowIdentifyInvalidArgumentException(option,argv[i]);
555             break;
556           }
557         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
558       }
559       case 'g':
560       {
561         if (LocaleCompare("gamma",option+1) == 0)
562           {
563             i++;
564             if (i == (ssize_t) (argc-1))
565               ThrowIdentifyException(OptionError,"MissingArgument",option);
566             if (IsGeometry(argv[i]) == MagickFalse)
567               ThrowIdentifyInvalidArgumentException(option,argv[i]);
568             break;
569           }
570         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
571       }
572       case 'h':
573       {
574         if ((LocaleCompare("help",option+1) == 0) ||
575             (LocaleCompare("-help",option+1) == 0))
576           return(IdentifyUsage());
577         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
578       }
579       case 'i':
580       {
581         if (LocaleCompare("interlace",option+1) == 0)
582           {
583             ssize_t
584               interlace;
585
586             if (*option == '+')
587               break;
588             i++;
589             if (i == (ssize_t) argc)
590               ThrowIdentifyException(OptionError,"MissingArgument",option);
591             interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
592               argv[i]);
593             if (interlace < 0)
594               ThrowIdentifyException(OptionError,
595                 "UnrecognizedInterlaceType",argv[i]);
596             break;
597           }
598         if (LocaleCompare("interpolate",option+1) == 0)
599           {
600             ssize_t
601               interpolate;
602
603             if (*option == '+')
604               break;
605             i++;
606             if (i == (ssize_t) argc)
607               ThrowIdentifyException(OptionError,"MissingArgument",option);
608             interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
609               argv[i]);
610             if (interpolate < 0)
611               ThrowIdentifyException(OptionError,
612                 "UnrecognizedInterpolateMethod",argv[i]);
613             break;
614           }
615         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
616       }
617       case 'l':
618       {
619         if (LocaleCompare("limit",option+1) == 0)
620           {
621             char
622               *p;
623
624             double
625               value;
626
627             ssize_t
628               resource;
629
630             if (*option == '+')
631               break;
632             i++;
633             if (i == (ssize_t) argc)
634               ThrowIdentifyException(OptionError,"MissingArgument",option);
635             resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
636               argv[i]);
637             if (resource < 0)
638               ThrowIdentifyException(OptionError,"UnrecognizedResourceType",
639                 argv[i]);
640             i++;
641             if (i == (ssize_t) argc)
642               ThrowIdentifyException(OptionError,"MissingArgument",option);
643             value=StringToDouble(argv[i],&p);
644             (void) value;
645             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
646               ThrowIdentifyInvalidArgumentException(option,argv[i]);
647             break;
648           }
649         if (LocaleCompare("list",option+1) == 0)
650           {
651             ssize_t
652               list;
653
654             if (*option == '+')
655               break;
656             i++;
657             if (i == (ssize_t) argc)
658               ThrowIdentifyException(OptionError,"MissingArgument",option);
659             list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
660             if (list < 0)
661               ThrowIdentifyException(OptionError,"UnrecognizedListType",
662                 argv[i]);
663             status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
664               argv+j,exception);
665             DestroyIdentify();
666             return(status != 0 ? MagickFalse : MagickTrue);
667           }
668         if (LocaleCompare("log",option+1) == 0)
669           {
670             if (*option == '+')
671               break;
672             i++;
673             if ((i == (ssize_t) argc) ||
674                 (strchr(argv[i],'%') == (char *) NULL))
675               ThrowIdentifyException(OptionError,"MissingArgument",option);
676             break;
677           }
678         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
679       }
680       case 'm':
681       {
682         if (LocaleCompare("matte",option+1) == 0)
683           break;
684         if (LocaleCompare("monitor",option+1) == 0)
685           break;
686         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
687       }
688       case 'n':
689       {
690         if (LocaleCompare("negate",option+1) == 0)
691           break;
692         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
693       }
694       case 'p':
695       {
696         if (LocaleCompare("ping",option+1) == 0)
697           break;
698         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
699       }
700       case 'q':
701       {
702         if (LocaleCompare("quiet",option+1) == 0)
703           break;
704         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
705       }
706       case 'r':
707       {
708         if (LocaleCompare("regard-warnings",option+1) == 0)
709           break;
710         if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
711           {
712             respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
713             break;
714           }
715         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
716       }
717       case 's':
718       {
719         if (LocaleCompare("sampling-factor",option+1) == 0)
720           {
721             if (*option == '+')
722               break;
723             i++;
724             if (i == (ssize_t) argc)
725               ThrowIdentifyException(OptionError,"MissingArgument",option);
726             if (IsGeometry(argv[i]) == MagickFalse)
727               ThrowIdentifyInvalidArgumentException(option,argv[i]);
728             break;
729           }
730         if (LocaleCompare("seed",option+1) == 0)
731           {
732             if (*option == '+')
733               break;
734             i++;
735             if (i == (ssize_t) (argc-1))
736               ThrowIdentifyException(OptionError,"MissingArgument",option);
737             if (IsGeometry(argv[i]) == MagickFalse)
738               ThrowIdentifyInvalidArgumentException(option,argv[i]);
739             break;
740           }
741         if (LocaleCompare("set",option+1) == 0)
742           {
743             i++;
744             if (i == (ssize_t) argc)
745               ThrowIdentifyException(OptionError,"MissingArgument",option);
746             if (*option == '+')
747               break;
748             i++;
749             if (i == (ssize_t) argc)
750               ThrowIdentifyException(OptionError,"MissingArgument",option);
751             break;
752           }
753         if (LocaleCompare("size",option+1) == 0)
754           {
755             if (*option == '+')
756               break;
757             i++;
758             if (i == (ssize_t) argc)
759               ThrowIdentifyException(OptionError,"MissingArgument",option);
760             if (IsGeometry(argv[i]) == MagickFalse)
761               ThrowIdentifyInvalidArgumentException(option,argv[i]);
762             break;
763           }
764         if (LocaleCompare("strip",option+1) == 0)
765           break;
766         if (LocaleCompare("support",option+1) == 0)
767           {
768             if (*option == '+')
769               break;
770             i++;
771             if (i == (ssize_t) argc)
772               ThrowIdentifyException(OptionError,"MissingArgument",option);
773             if (IsGeometry(argv[i]) == MagickFalse)
774               ThrowIdentifyInvalidArgumentException(option,argv[i]);
775             break;
776           }
777         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
778       }
779       case 'u':
780       {
781         if (LocaleCompare("unique",option+1) == 0)
782           break;
783         if (LocaleCompare("units",option+1) == 0)
784           {
785             ssize_t
786               units;
787
788             if (*option == '+')
789               break;
790             i++;
791             if (i == (ssize_t) (argc-1))
792               ThrowIdentifyException(OptionError,"MissingArgument",option);
793             units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
794               argv[i]);
795             if (units < 0)
796               ThrowIdentifyException(OptionError,"UnrecognizedUnitsType",
797                 argv[i]);
798             break;
799           }
800         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
801       }
802       case 'v':
803       {
804         if (LocaleCompare("verbose",option+1) == 0)
805           break;
806         if (LocaleCompare("virtual-pixel",option+1) == 0)
807           {
808             ssize_t
809               method;
810
811             if (*option == '+')
812               break;
813             i++;
814             if (i == (ssize_t) (argc-1))
815               ThrowIdentifyException(OptionError,"MissingArgument",option);
816             method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
817               argv[i]);
818             if (method < 0)
819               ThrowIdentifyException(OptionError,
820                 "UnrecognizedVirtualPixelMethod",argv[i]);
821             break;
822           }
823         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
824       }
825       case '?':
826         break;
827       default:
828         ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
829     }
830     fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
831       FireOptionFlag) == 0 ?  MagickFalse : MagickTrue;
832     if (fire != MagickFalse)
833       FireImageStack(MagickFalse,MagickTrue,MagickTrue);
834   }
835   if (k != 0)
836     ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]);
837   if (i != (ssize_t) argc)
838     ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]);
839   DestroyIdentify();
840   return(status != 0 ? MagickTrue : MagickFalse);
841 }