MagickWand  6.9.13-9
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/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 #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  (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
189  option); \
190  DestroyIdentify(); \
191  return(MagickFalse); \
192 }
193 #define ThrowIdentifyInvalidArgumentException(option,argument) \
194 { \
195  (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
196  "InvalidArgument","`%s': %s",option,argument); \
197  DestroyIdentify(); \
198  return(MagickFalse); \
199 }
200 
201  const char
202  *format,
203  *option;
204 
205  Image
206  *image;
207 
208  ImageStack
209  image_stack[MaxImageStackDepth+1];
210 
211  MagickBooleanType
212  fire,
213  pend,
214  respect_parenthesis;
215 
216  MagickStatusType
217  status;
218 
219  ssize_t
220  i;
221 
222  size_t
223  count;
224 
225  ssize_t
226  j,
227  k;
228 
229  /*
230  Set defaults.
231  */
232  assert(image_info != (ImageInfo *) NULL);
233  assert(image_info->signature == MagickCoreSignature);
234  assert(exception != (ExceptionInfo *) NULL);
235  if (IsEventLogging() != MagickFalse)
236  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
237  if (argc == 2)
238  {
239  option=argv[1];
240  if ((LocaleCompare("version",option+1) == 0) ||
241  (LocaleCompare("-version",option+1) == 0))
242  {
243  ListMagickVersion(stdout);
244  return(MagickTrue);
245  }
246  }
247  if (argc < 2)
248  {
249  (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
250  "MissingArgument","%s","");
251  (void) IdentifyUsage();
252  return(MagickFalse);
253  }
254  count=0;
255  format=NULL;
256  j=1;
257  k=0;
258  NewImageStack();
259  option=(char *) NULL;
260  pend=MagickFalse;
261  respect_parenthesis=MagickFalse;
262  status=MagickTrue;
263  /*
264  Identify an image.
265  */
266  ReadCommandlLine(argc,&argv);
267  status=ExpandFilenames(&argc,&argv);
268  if (status == MagickFalse)
269  ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed",
270  GetExceptionMessage(errno));
271  image_info->ping=MagickTrue;
272  for (i=1; i < (ssize_t) argc; i++)
273  {
274  option=argv[i];
275  if (LocaleCompare(option,"(") == 0)
276  {
277  FireImageStack(MagickFalse,MagickTrue,pend);
278  if (k == MaxImageStackDepth)
279  ThrowIdentifyException(OptionError,"ParenthesisNestedTooDeeply",
280  option);
281  PushImageStack();
282  continue;
283  }
284  if (LocaleCompare(option,")") == 0)
285  {
286  FireImageStack(MagickFalse,MagickTrue,MagickTrue);
287  if (k == 0)
288  ThrowIdentifyException(OptionError,"UnableToParseExpression",option);
289  PopImageStack();
290  continue;
291  }
292  if (IsCommandOption(option) == MagickFalse)
293  {
294  char
295  *filename;
296 
297  Image
298  *images;
299 
300  ImageInfo
301  *identify_info;
302 
303  /*
304  Read input image.
305  */
306  FireImageStack(MagickFalse,MagickFalse,pend);
307  identify_info=CloneImageInfo(image_info);
308  identify_info->verbose=MagickFalse;
309  filename=argv[i];
310  if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
311  filename=argv[++i];
312  (void) SetImageOption(image_info,"filename",filename);
313  (void) CopyMagickString(identify_info->filename,filename,MaxTextExtent);
314  if (identify_info->ping != MagickFalse)
315  images=PingImages(identify_info,exception);
316  else
317  images=ReadImages(identify_info,exception);
318  identify_info=DestroyImageInfo(identify_info);
319  status&=(images != (Image *) NULL) &&
320  (exception->severity < ErrorException);
321  if (images == (Image *) NULL)
322  continue;
323  AppendImageStack(images);
324  FinalizeImageSettings(image_info,image,MagickFalse);
325  count=0;
326  for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
327  {
328  if (image->scene == 0)
329  image->scene=count++;
330  if (format == (char *) NULL)
331  {
332  (void) IdentifyImage(image,stdout,image_info->verbose);
333  continue;
334  }
335  if (metadata != (char **) NULL)
336  {
337  char
338  *text;
339 
340  text=InterpretImageProperties(image_info,image,format);
341  InheritException(exception,&image->exception);
342  if (text == (char *) NULL)
343  ThrowIdentifyException(ResourceLimitError,
344  "MemoryAllocationFailed",GetExceptionMessage(errno));
345  (void) ConcatenateString(&(*metadata),text);
346  text=DestroyString(text);
347  }
348  }
349  RemoveAllImageStack();
350  continue;
351  }
352  pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
353  image_info->ping=MagickFalse;
354  switch (*(option+1))
355  {
356  case 'a':
357  {
358  if (LocaleCompare("alpha",option+1) == 0)
359  {
360  ssize_t
361  type;
362 
363  if (*option == '+')
364  break;
365  i++;
366  if (i == (ssize_t) argc)
367  ThrowIdentifyException(OptionError,"MissingArgument",option);
368  type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
369  if (type < 0)
370  ThrowIdentifyException(OptionError,"UnrecognizedAlphaChannelType",
371  argv[i]);
372  break;
373  }
374  if (LocaleCompare("antialias",option+1) == 0)
375  break;
376  if (LocaleCompare("authenticate",option+1) == 0)
377  {
378  if (*option == '+')
379  break;
380  i++;
381  if (i == (ssize_t) argc)
382  ThrowIdentifyException(OptionError,"MissingArgument",option);
383  break;
384  }
385  if (LocaleCompare("auto-orient",option+1) == 0)
386  break;
387  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
388  }
389  case 'c':
390  {
391  if (LocaleCompare("cache",option+1) == 0)
392  {
393  if (*option == '+')
394  break;
395  i++;
396  if (i == (ssize_t) argc)
397  ThrowIdentifyException(OptionError,"MissingArgument",option);
398  if (IsGeometry(argv[i]) == MagickFalse)
399  ThrowIdentifyInvalidArgumentException(option,argv[i]);
400  break;
401  }
402  if (LocaleCompare("channel",option+1) == 0)
403  {
404  ssize_t
405  channel;
406 
407  if (*option == '+')
408  break;
409  i++;
410  if (i == (ssize_t) argc)
411  ThrowIdentifyException(OptionError,"MissingArgument",option);
412  channel=ParseChannelOption(argv[i]);
413  if (channel < 0)
414  ThrowIdentifyException(OptionError,"UnrecognizedChannelType",
415  argv[i]);
416  break;
417  }
418  if (LocaleCompare("clip",option+1) == 0)
419  break;
420  if (LocaleCompare("clip-mask",option+1) == 0)
421  {
422  if (*option == '+')
423  break;
424  i++;
425  if (i == (ssize_t) argc)
426  ThrowIdentifyException(OptionError,"MissingArgument",option);
427  break;
428  }
429  if (LocaleCompare("clip-path",option+1) == 0)
430  {
431  i++;
432  if (i == (ssize_t) argc)
433  ThrowIdentifyException(OptionError,"MissingArgument",option);
434  break;
435  }
436  if (LocaleCompare("colorspace",option+1) == 0)
437  {
438  ssize_t
439  colorspace;
440 
441  if (*option == '+')
442  break;
443  i++;
444  if (i == (ssize_t) argc)
445  ThrowIdentifyException(OptionError,"MissingArgument",option);
446  colorspace=ParseCommandOption(MagickColorspaceOptions,
447  MagickFalse,argv[i]);
448  if (colorspace < 0)
449  ThrowIdentifyException(OptionError,"UnrecognizedColorspace",
450  argv[i]);
451  break;
452  }
453  if (LocaleCompare("crop",option+1) == 0)
454  {
455  if (*option == '+')
456  break;
457  i++;
458  if (i == (ssize_t) argc)
459  ThrowIdentifyException(OptionError,"MissingArgument",option);
460  if (IsGeometry(argv[i]) == MagickFalse)
461  ThrowIdentifyInvalidArgumentException(option,argv[i]);
462  break;
463  }
464  if (LocaleCompare("concurrent",option+1) == 0)
465  break;
466  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
467  }
468  case 'd':
469  {
470  if (LocaleCompare("debug",option+1) == 0)
471  {
472  ssize_t
473  event;
474 
475  if (*option == '+')
476  break;
477  i++;
478  if (i == (ssize_t) argc)
479  ThrowIdentifyException(OptionError,"MissingArgument",option);
480  event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
481  if (event < 0)
482  ThrowIdentifyException(OptionError,"UnrecognizedEventType",
483  argv[i]);
484  (void) SetLogEventMask(argv[i]);
485  break;
486  }
487  if (LocaleCompare("define",option+1) == 0)
488  {
489  i++;
490  if (i == (ssize_t) argc)
491  ThrowIdentifyException(OptionError,"MissingArgument",option);
492  if (*option == '+')
493  {
494  const char
495  *define;
496 
497  define=GetImageOption(image_info,argv[i]);
498  if (define == (const char *) NULL)
499  ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]);
500  break;
501  }
502  break;
503  }
504  if (LocaleCompare("density",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("depth",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  if (LocaleCompare("duration",option+1) == 0)
527  {
528  if (*option == '+')
529  break;
530  i++;
531  if (i == (ssize_t) argc)
532  ThrowIdentifyException(OptionError,"MissingArgument",option);
533  if (IsGeometry(argv[i]) == MagickFalse)
534  ThrowIdentifyInvalidArgumentException(option,argv[i]);
535  break;
536  }
537  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
538  }
539  case 'e':
540  {
541  if (LocaleCompare("endian",option+1) == 0)
542  {
543  ssize_t
544  endian;
545 
546  if (*option == '+')
547  break;
548  i++;
549  if (i == (ssize_t) argc)
550  ThrowIdentifyException(OptionError,"MissingArgument",option);
551  endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
552  argv[i]);
553  if (endian < 0)
554  ThrowIdentifyException(OptionError,"UnrecognizedEndianType",
555  argv[i]);
556  break;
557  }
558  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
559  }
560  case 'f':
561  {
562  if (LocaleCompare("features",option+1) == 0)
563  {
564  if (*option == '+')
565  break;
566  i++;
567  if (i == (ssize_t) argc)
568  ThrowIdentifyException(OptionError,"MissingArgument",option);
569  if (IsGeometry(argv[i]) == MagickFalse)
570  ThrowIdentifyInvalidArgumentException(option,argv[i]);
571  break;
572  }
573  if (LocaleCompare("format",option+1) == 0)
574  {
575  format=(char *) NULL;
576  if (*option == '+')
577  break;
578  i++;
579  if (i == (ssize_t) argc)
580  ThrowIdentifyException(OptionError,"MissingArgument",option);
581  format=argv[i];
582  break;
583  }
584  if (LocaleCompare("fuzz",option+1) == 0)
585  {
586  if (*option == '+')
587  break;
588  i++;
589  if (i == (ssize_t) argc)
590  ThrowIdentifyException(OptionError,"MissingArgument",option);
591  if (IsGeometry(argv[i]) == MagickFalse)
592  ThrowIdentifyInvalidArgumentException(option,argv[i]);
593  break;
594  }
595  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
596  }
597  case 'g':
598  {
599  if (LocaleCompare("gamma",option+1) == 0)
600  {
601  i++;
602  if (i == (ssize_t) argc)
603  ThrowIdentifyException(OptionError,"MissingArgument",option);
604  if (IsGeometry(argv[i]) == MagickFalse)
605  ThrowIdentifyInvalidArgumentException(option,argv[i]);
606  break;
607  }
608  if (LocaleCompare("grayscale",option+1) == 0)
609  {
610  ssize_t
611  method;
612 
613  if (*option == '+')
614  break;
615  i++;
616  if (i == (ssize_t) argc)
617  ThrowIdentifyException(OptionError,"MissingArgument",option);
618  method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
619  argv[i]);
620  if (method < 0)
621  ThrowIdentifyException(OptionError,"UnrecognizedIntensityMethod",
622  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  {
632  DestroyIdentify();
633  return(IdentifyUsage());
634  }
635  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
636  }
637  case 'i':
638  {
639  if (LocaleCompare("interlace",option+1) == 0)
640  {
641  ssize_t
642  interlace;
643 
644  if (*option == '+')
645  break;
646  i++;
647  if (i == (ssize_t) argc)
648  ThrowIdentifyException(OptionError,"MissingArgument",option);
649  interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
650  argv[i]);
651  if (interlace < 0)
652  ThrowIdentifyException(OptionError,"UnrecognizedInterlaceType",
653  argv[i]);
654  break;
655  }
656  if (LocaleCompare("interpolate",option+1) == 0)
657  {
658  ssize_t
659  interpolate;
660 
661  if (*option == '+')
662  break;
663  i++;
664  if (i == (ssize_t) argc)
665  ThrowIdentifyException(OptionError,"MissingArgument",option);
666  interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
667  argv[i]);
668  if (interpolate < 0)
669  ThrowIdentifyException(OptionError,
670  "UnrecognizedInterpolateMethod",argv[i]);
671  break;
672  }
673  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
674  }
675  case 'l':
676  {
677  if (LocaleCompare("limit",option+1) == 0)
678  {
679  char
680  *p;
681 
682  double
683  value;
684 
685  ssize_t
686  resource;
687 
688  if (*option == '+')
689  break;
690  i++;
691  if (i == (ssize_t) argc)
692  ThrowIdentifyException(OptionError,"MissingArgument",option);
693  resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
694  argv[i]);
695  if (resource < 0)
696  ThrowIdentifyException(OptionError,"UnrecognizedResourceType",
697  argv[i]);
698  i++;
699  if (i == (ssize_t) argc)
700  ThrowIdentifyException(OptionError,"MissingArgument",option);
701  value=StringToDouble(argv[i],&p);
702  (void) value;
703  if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
704  ThrowIdentifyInvalidArgumentException(option,argv[i]);
705  break;
706  }
707  if (LocaleCompare("list",option+1) == 0)
708  {
709  ssize_t
710  list;
711 
712  if (*option == '+')
713  break;
714  i++;
715  if (i == (ssize_t) argc)
716  ThrowIdentifyException(OptionError,"MissingArgument",option);
717  list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
718  if (list < 0)
719  ThrowIdentifyException(OptionError,"UnrecognizedListType",
720  argv[i]);
721  status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
722  argv+j,exception);
723  DestroyIdentify();
724  return(status == 0 ? MagickFalse : MagickTrue);
725  }
726  if (LocaleCompare("log",option+1) == 0)
727  {
728  if (*option == '+')
729  break;
730  i++;
731  if ((i == (ssize_t) argc) ||
732  (strchr(argv[i],'%') == (char *) NULL))
733  ThrowIdentifyException(OptionError,"MissingArgument",option);
734  break;
735  }
736  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
737  }
738  case 'm':
739  {
740  if (LocaleCompare("mask",option+1) == 0)
741  {
742  if (*option == '+')
743  break;
744  i++;
745  if (i == (ssize_t) argc)
746  ThrowIdentifyException(OptionError,"MissingArgument",option);
747  break;
748  }
749  if (LocaleCompare("matte",option+1) == 0)
750  break;
751  if (LocaleCompare("moments",option+1) == 0)
752  break;
753  if (LocaleCompare("monitor",option+1) == 0)
754  break;
755  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
756  }
757  case 'n':
758  {
759  if (LocaleCompare("negate",option+1) == 0)
760  break;
761  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
762  }
763  case 'p':
764  {
765  if (LocaleCompare("ping",option+1) == 0)
766  {
767  image_info->ping=MagickTrue;
768  break;
769  }
770  if (LocaleCompare("precision",option+1) == 0)
771  {
772  if (*option == '+')
773  break;
774  i++;
775  if (i == (ssize_t) argc)
776  ThrowIdentifyException(OptionError,"MissingArgument",option);
777  if (IsGeometry(argv[i]) == MagickFalse)
778  ThrowIdentifyInvalidArgumentException(option,argv[i]);
779  break;
780  }
781  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
782  }
783  case 'q':
784  {
785  if (LocaleCompare("quiet",option+1) == 0)
786  break;
787  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
788  }
789  case 'r':
790  {
791  if (LocaleCompare("regard-warnings",option+1) == 0)
792  break;
793  if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
794  {
795  respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
796  break;
797  }
798  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
799  }
800  case 's':
801  {
802  if (LocaleCompare("sampling-factor",option+1) == 0)
803  {
804  if (*option == '+')
805  break;
806  i++;
807  if (i == (ssize_t) argc)
808  ThrowIdentifyException(OptionError,"MissingArgument",option);
809  if (IsGeometry(argv[i]) == MagickFalse)
810  ThrowIdentifyInvalidArgumentException(option,argv[i]);
811  break;
812  }
813  if (LocaleCompare("seed",option+1) == 0)
814  {
815  if (*option == '+')
816  break;
817  i++;
818  if (i == (ssize_t) argc)
819  ThrowIdentifyException(OptionError,"MissingArgument",option);
820  if (IsGeometry(argv[i]) == MagickFalse)
821  ThrowIdentifyInvalidArgumentException(option,argv[i]);
822  break;
823  }
824  if (LocaleCompare("set",option+1) == 0)
825  {
826  i++;
827  if (i == (ssize_t) argc)
828  ThrowIdentifyException(OptionError,"MissingArgument",option);
829  if (*option == '+')
830  break;
831  i++;
832  if (i == (ssize_t) argc)
833  ThrowIdentifyException(OptionError,"MissingArgument",option);
834  break;
835  }
836  if (LocaleCompare("size",option+1) == 0)
837  {
838  if (*option == '+')
839  break;
840  i++;
841  if (i == (ssize_t) argc)
842  ThrowIdentifyException(OptionError,"MissingArgument",option);
843  if (IsGeometry(argv[i]) == MagickFalse)
844  ThrowIdentifyInvalidArgumentException(option,argv[i]);
845  break;
846  }
847  if (LocaleCompare("strip",option+1) == 0)
848  break;
849  if (LocaleCompare("support",option+1) == 0)
850  {
851  if (*option == '+')
852  break;
853  i++;
854  if (i == (ssize_t) argc)
855  ThrowIdentifyException(OptionError,"MissingArgument",option);
856  if (IsGeometry(argv[i]) == MagickFalse)
857  ThrowIdentifyInvalidArgumentException(option,argv[i]);
858  break;
859  }
860  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
861  }
862  case 'u':
863  {
864  if (LocaleCompare("unique",option+1) == 0)
865  break;
866  if (LocaleCompare("units",option+1) == 0)
867  {
868  ssize_t
869  units;
870 
871  if (*option == '+')
872  break;
873  i++;
874  if (i == (ssize_t) argc)
875  ThrowIdentifyException(OptionError,"MissingArgument",option);
876  units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
877  argv[i]);
878  if (units < 0)
879  ThrowIdentifyException(OptionError,"UnrecognizedUnitsType",
880  argv[i]);
881  break;
882  }
883  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
884  }
885  case 'v':
886  {
887  if (LocaleCompare("verbose",option+1) == 0)
888  break;
889  if (LocaleCompare("virtual-pixel",option+1) == 0)
890  {
891  ssize_t
892  method;
893 
894  if (*option == '+')
895  break;
896  i++;
897  if (i == (ssize_t) argc)
898  ThrowIdentifyException(OptionError,"MissingArgument",option);
899  method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
900  argv[i]);
901  if (method < 0)
902  ThrowIdentifyException(OptionError,
903  "UnrecognizedVirtualPixelMethod",argv[i]);
904  break;
905  }
906  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
907  }
908  case '?':
909  break;
910  default:
911  ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
912  }
913  fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
914  FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
915  if (fire != MagickFalse)
916  FireImageStack(MagickFalse,MagickTrue,MagickTrue);
917  }
918  if (k != 0)
919  ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]);
920  if (i != (ssize_t) argc)
921  ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]);
922  DestroyIdentify();
923  return(status != 0 ? MagickTrue : MagickFalse);
924 }