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