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