PageRenderTime 3ms CodeModel.GetById 6ms app.highlight 71ms RepoModel.GetById 1ms app.codeStats 0ms

/MagickWand/identify.c

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