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