root/ImageMagick/trunk/wand/identify.c

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