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