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