blob: 006914eefe327b00f4111499d85ccbbaea8b99b6 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
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 %
cristyde984cd2013-12-01 14:49:27 +000016% Cristy %
cristy3ed852e2009-09-05 21:47:34 +000017% September 1994 %
18% %
19% %
cristyfe676ee2013-11-18 13:03:38 +000020% Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% 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% http://www.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*/
cristy4c08aed2011-07-01 19:47:50 +000050#include "MagickWand/studio.h"
51#include "MagickWand/MagickWand.h"
52#include "MagickWand/mogrify-private.h"
cristy196372d2011-11-05 00:07:32 +000053#include "MagickCore/string-private.h"
cristy3ed852e2009-09-05 21:47:34 +000054
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
93static MagickBooleanType IdentifyUsage(void)
94{
95 const char
96 **p;
97
98 static const char
99 *miscellaneous[]=
100 {
101 "-debug events display copious debugging information",
102 "-help print program options",
103 "-list type print a list of supported option arguments",
104 "-log format format of debugging information",
105 "-version print version information",
106 (char *) NULL
107 },
cristye48c6a92010-02-01 01:25:42 +0000108 *operators[]=
109 {
cristy0a09e9d2013-09-01 19:08:23 +0000110 "-grayscale method convert image to grayscale",
cristye48c6a92010-02-01 01:25:42 +0000111 "-negate replace every pixel with its complementary color ",
112 (char *) NULL
113 },
cristy3ed852e2009-09-05 21:47:34 +0000114 *settings[]=
115 {
116 "-alpha option on, activate, off, deactivate, set, opaque, copy",
117 " transparent, extract, background, or shape",
118 "-antialias remove pixel-aliasing",
119 "-authenticate password",
120 " decipher image with this password",
121 "-channel type apply option to select image channels",
cristy1e618102013-03-17 14:52:31 +0000122 "-clip clip along the first path from the 8BIM profile",
123 "-clip-mask filename associate a clip mask with the image",
124 "-clip-path id clip along a named path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +0000125 "-colorspace type alternate image colorspace",
126 "-crop geometry cut out a rectangular region of the image",
127 "-define format:option",
128 " define one or more image format options",
129 "-density geometry horizontal and vertical density of the image",
130 "-depth value image depth",
cristy605e80d2012-09-12 11:34:39 +0000131 "-endian type endianness (MSB or LSB) of the image",
cristy3ed852e2009-09-05 21:47:34 +0000132 "-extract geometry extract area from image",
cristy14154222012-06-15 23:21:49 +0000133 "-features distance analyze image features (e.g. contrast, correlation)",
cristy3ed852e2009-09-05 21:47:34 +0000134 "-format \"string\" output formatted image characteristics",
135 "-fuzz distance colors within this distance are considered equal",
cristycd483f12010-01-26 15:30:08 +0000136 "-gamma value of gamma correction",
cristy3ed852e2009-09-05 21:47:34 +0000137 "-interlace type type of image interlacing scheme",
138 "-interpolate method pixel color interpolation method",
139 "-limit type value pixel cache resource limit",
cristy5048d302012-08-07 01:05:16 +0000140 "-mask filename associate a mask with the image",
cristye9252c22013-07-30 15:43:21 +0000141 "-matte store matte channel if the image has one",
cristybd4a3c22014-01-07 15:09:37 +0000142 "-moments report image moments",
cristy3ed852e2009-09-05 21:47:34 +0000143 "-monitor monitor progress",
144 "-ping efficiently determine image attributes",
cristya1b14862013-09-01 23:53:47 +0000145 "-precision value maximum number of significant digits to print",
cristy3ed852e2009-09-05 21:47:34 +0000146 "-quiet suppress all warning messages",
147 "-regard-warnings pay attention to warning messages",
148 "-respect-parentheses settings remain in effect until parenthesis boundary",
149 "-sampling-factor geometry",
150 " horizontal and vertical sampling factor",
151 "-seed value seed a new sequence of pseudo-random numbers",
152 "-set attribute value set an image attribute",
153 "-size geometry width and height of image",
154 "-strip strip image of all profiles and comments",
cristy045bd902010-01-30 18:56:24 +0000155 "-unique display the number of unique colors in the image",
cristy3ed852e2009-09-05 21:47:34 +0000156 "-units type the units of image resolution",
157 "-verbose print detailed information about the image",
158 "-virtual-pixel method",
159 " virtual pixel access method",
160 (char *) NULL
161 };
162
cristy4f7a6132012-12-23 00:35:19 +0000163 ListMagickVersion(stdout);
cristy3ed852e2009-09-05 21:47:34 +0000164 (void) printf("Usage: %s [options ...] file [ [options ...] "
165 "file ... ]\n",GetClientName());
166 (void) printf("\nImage Settings:\n");
167 for (p=settings; *p != (char *) NULL; p++)
168 (void) printf(" %s\n",*p);
cristye48c6a92010-02-01 01:25:42 +0000169 (void) printf("\nImage Operators:\n");
170 for (p=operators; *p != (char *) NULL; p++)
171 (void) printf(" %s\n",*p);
cristy3ed852e2009-09-05 21:47:34 +0000172 (void) printf("\nMiscellaneous Options:\n");
173 for (p=miscellaneous; *p != (char *) NULL; p++)
174 (void) printf(" %s\n",*p);
175 (void) printf(
anthonye5b39652012-04-21 05:37:29 +0000176 "\nBy default, the image format of 'file' is determined by its magic\n");
cristy3ed852e2009-09-05 21:47:34 +0000177 (void) printf(
178 "number. To specify a particular image format, precede the filename\n");
179 (void) printf(
180 "with an image format name and a colon (i.e. ps:image) or specify the\n");
181 (void) printf(
182 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
183 (void) printf("'-' for standard input or output.\n");
184 return(MagickFalse);
185}
186
187WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
188 int argc,char **argv,char **metadata,ExceptionInfo *exception)
189{
190#define DestroyIdentify() \
191{ \
192 DestroyImageStack(); \
cristybb503372010-05-27 20:51:26 +0000193 for (i=0; i < (ssize_t) argc; i++) \
cristy3ed852e2009-09-05 21:47:34 +0000194 argv[i]=DestroyString(argv[i]); \
195 argv=(char **) RelinquishMagickMemory(argv); \
196}
197#define ThrowIdentifyException(asperity,tag,option) \
198{ \
cristyefe601c2013-01-05 17:51:12 +0000199 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
cristy3ed852e2009-09-05 21:47:34 +0000200 option); \
201 DestroyIdentify(); \
202 return(MagickFalse); \
203}
204#define ThrowIdentifyInvalidArgumentException(option,argument) \
205{ \
206 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
anthonye5b39652012-04-21 05:37:29 +0000207 "InvalidArgument","'%s': %s",option,argument); \
cristy3ed852e2009-09-05 21:47:34 +0000208 DestroyIdentify(); \
209 return(MagickFalse); \
210}
211
212 const char
213 *format,
214 *option;
215
216 Image
217 *image;
218
219 ImageStack
220 image_stack[MaxImageStackDepth+1];
221
cristy3ed852e2009-09-05 21:47:34 +0000222 MagickBooleanType
223 fire,
cristyebbcfea2011-02-25 02:43:54 +0000224 pend,
225 respect_parenthesis;
cristy3ed852e2009-09-05 21:47:34 +0000226
227 MagickStatusType
228 status;
229
cristybb503372010-05-27 20:51:26 +0000230 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000231 i;
232
cristybb503372010-05-27 20:51:26 +0000233 size_t
cristy3ed852e2009-09-05 21:47:34 +0000234 count;
235
cristy9d314ff2011-03-09 01:30:28 +0000236 ssize_t
237 j,
238 k;
239
cristy3ed852e2009-09-05 21:47:34 +0000240 /*
241 Set defaults.
242 */
243 assert(image_info != (ImageInfo *) NULL);
244 assert(image_info->signature == MagickSignature);
245 if (image_info->debug != MagickFalse)
246 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
247 assert(exception != (ExceptionInfo *) NULL);
248 if (argc == 2)
249 {
250 option=argv[1];
251 if ((LocaleCompare("version",option+1) == 0) ||
252 (LocaleCompare("-version",option+1) == 0))
253 {
cristy4f7a6132012-12-23 00:35:19 +0000254 ListMagickVersion(stdout);
cristy3ed852e2009-09-05 21:47:34 +0000255 return(MagickFalse);
256 }
257 }
258 if (argc < 2)
cristy13e61a12010-02-04 20:19:00 +0000259 return(IdentifyUsage());
cristy3ed852e2009-09-05 21:47:34 +0000260 count=0;
261 format=NULL;
262 j=1;
263 k=0;
264 NewImageStack();
265 option=(char *) NULL;
266 pend=MagickFalse;
cristyebbcfea2011-02-25 02:43:54 +0000267 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +0000268 status=MagickTrue;
269 /*
270 Identify an image.
271 */
272 ReadCommandlLine(argc,&argv);
273 status=ExpandFilenames(&argc,&argv);
274 if (status == MagickFalse)
275 ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed",
276 GetExceptionMessage(errno));
277 image_info->ping=MagickTrue;
cristybb503372010-05-27 20:51:26 +0000278 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000279 {
280 option=argv[i];
281 if (LocaleCompare(option,"(") == 0)
282 {
283 FireImageStack(MagickFalse,MagickTrue,pend);
284 if (k == MaxImageStackDepth)
285 ThrowIdentifyException(OptionError,"ParenthesisNestedTooDeeply",
286 option);
287 PushImageStack();
288 continue;
289 }
290 if (LocaleCompare(option,")") == 0)
291 {
292 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
293 if (k == 0)
294 ThrowIdentifyException(OptionError,"UnableToParseExpression",option);
295 PopImageStack();
296 continue;
297 }
cristy042ee782011-04-22 18:48:30 +0000298 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000299 {
300 char
301 *filename;
302
303 Image
304 *images;
305
306 ImageInfo
307 *identify_info;
308
309 /*
310 Read input image.
311 */
312 FireImageStack(MagickFalse,MagickFalse,pend);
313 identify_info=CloneImageInfo(image_info);
314 identify_info->verbose=MagickFalse;
315 filename=argv[i];
cristycee97112010-05-28 00:44:52 +0000316 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
cristy3ed852e2009-09-05 21:47:34 +0000317 filename=argv[++i];
cristy3ed852e2009-09-05 21:47:34 +0000318 if (identify_info->ping != MagickFalse)
cristy1b58f252012-03-01 01:41:41 +0000319 images=PingImages(identify_info,filename,exception);
cristy3ed852e2009-09-05 21:47:34 +0000320 else
cristy1b58f252012-03-01 01:41:41 +0000321 images=ReadImages(identify_info,filename,exception);
cristy3ed852e2009-09-05 21:47:34 +0000322 identify_info=DestroyImageInfo(identify_info);
323 status&=(images != (Image *) NULL) &&
324 (exception->severity < ErrorException);
325 if (images == (Image *) NULL)
326 continue;
327 AppendImageStack(images);
328 FinalizeImageSettings(image_info,image,MagickFalse);
329 for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
330 {
331 if (image->scene == 0)
332 image->scene=count++;
333 if (format == (char *) NULL)
334 {
cristya4037272011-08-28 15:11:39 +0000335 (void) IdentifyImage(image,stdout,image_info->verbose,exception);
cristy3ed852e2009-09-05 21:47:34 +0000336 continue;
337 }
338 if (metadata != (char **) NULL)
339 {
340 char
341 *text;
342
cristy018f07f2011-09-04 21:15:19 +0000343 text=InterpretImageProperties(image_info,image,format,exception);
cristy3ed852e2009-09-05 21:47:34 +0000344 if (text == (char *) NULL)
345 ThrowIdentifyException(ResourceLimitError,
346 "MemoryAllocationFailed",GetExceptionMessage(errno));
347 (void) ConcatenateString(&(*metadata),text);
348 text=DestroyString(text);
cristy7023b3a2014-01-08 12:42:48 +0000349 if (GlobExpression(format,"*%n*",MagickFalse) != MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000350 break;
351 }
352 }
353 RemoveAllImageStack();
354 continue;
355 }
356 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
357 switch (*(option+1))
358 {
359 case 'a':
360 {
361 if (LocaleCompare("alpha",option+1) == 0)
362 {
cristybb503372010-05-27 20:51:26 +0000363 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000364 type;
365
366 if (*option == '+')
367 break;
368 i++;
cristybb503372010-05-27 20:51:26 +0000369 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000370 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy77ffd932012-09-05 11:19:57 +0000371 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
372 argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000373 if (type < 0)
cristy77ffd932012-09-05 11:19:57 +0000374 ThrowIdentifyException(OptionError,
375 "UnrecognizedAlphaChannelOption",argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000376 break;
377 }
378 if (LocaleCompare("antialias",option+1) == 0)
379 break;
380 if (LocaleCompare("authenticate",option+1) == 0)
381 {
382 if (*option == '+')
383 break;
384 i++;
cristye81f5522014-05-07 01:25:59 +0000385 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000386 ThrowIdentifyException(OptionError,"MissingArgument",option);
387 break;
388 }
389 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
390 }
391 case 'c':
392 {
393 if (LocaleCompare("cache",option+1) == 0)
394 {
395 if (*option == '+')
396 break;
397 i++;
cristybb503372010-05-27 20:51:26 +0000398 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000399 ThrowIdentifyException(OptionError,"MissingArgument",option);
400 if (IsGeometry(argv[i]) == MagickFalse)
401 ThrowIdentifyInvalidArgumentException(option,argv[i]);
402 break;
403 }
404 if (LocaleCompare("channel",option+1) == 0)
405 {
cristybb503372010-05-27 20:51:26 +0000406 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000407 channel;
408
409 if (*option == '+')
410 break;
411 i++;
cristye81f5522014-05-07 01:25:59 +0000412 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000413 ThrowIdentifyException(OptionError,"MissingArgument",option);
414 channel=ParseChannelOption(argv[i]);
415 if (channel < 0)
416 ThrowIdentifyException(OptionError,"UnrecognizedChannelType",
417 argv[i]);
418 break;
419 }
cristy1e618102013-03-17 14:52:31 +0000420 if (LocaleCompare("clip",option+1) == 0)
421 break;
422 if (LocaleCompare("clip-mask",option+1) == 0)
423 {
424 if (*option == '+')
425 break;
426 i++;
cristye81f5522014-05-07 01:25:59 +0000427 if (i == (ssize_t) argc)
cristy1e618102013-03-17 14:52:31 +0000428 ThrowIdentifyException(OptionError,"MissingArgument",option);
429 break;
430 }
431 if (LocaleCompare("clip-path",option+1) == 0)
432 {
433 i++;
cristye81f5522014-05-07 01:25:59 +0000434 if (i == (ssize_t) argc)
cristy1e618102013-03-17 14:52:31 +0000435 ThrowIdentifyException(OptionError,"MissingArgument",option);
436 break;
437 }
cristy3ed852e2009-09-05 21:47:34 +0000438 if (LocaleCompare("colorspace",option+1) == 0)
439 {
cristybb503372010-05-27 20:51:26 +0000440 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000441 colorspace;
442
443 if (*option == '+')
444 break;
445 i++;
cristye81f5522014-05-07 01:25:59 +0000446 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000447 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000448 colorspace=ParseCommandOption(MagickColorspaceOptions,
cristy3ed852e2009-09-05 21:47:34 +0000449 MagickFalse,argv[i]);
450 if (colorspace < 0)
451 ThrowIdentifyException(OptionError,"UnrecognizedColorspace",
452 argv[i]);
453 break;
454 }
455 if (LocaleCompare("crop",option+1) == 0)
456 {
457 if (*option == '+')
458 break;
459 i++;
cristye81f5522014-05-07 01:25:59 +0000460 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000461 ThrowIdentifyException(OptionError,"MissingArgument",option);
462 if (IsGeometry(argv[i]) == MagickFalse)
463 ThrowIdentifyInvalidArgumentException(option,argv[i]);
464 image_info->ping=MagickFalse;
465 break;
466 }
cristy22879752009-10-25 23:55:40 +0000467 if (LocaleCompare("concurrent",option+1) == 0)
468 break;
cristy3ed852e2009-09-05 21:47:34 +0000469 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
470 }
471 case 'd':
472 {
473 if (LocaleCompare("debug",option+1) == 0)
474 {
cristybb503372010-05-27 20:51:26 +0000475 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000476 event;
477
478 if (*option == '+')
479 break;
480 i++;
cristybb503372010-05-27 20:51:26 +0000481 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000482 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000483 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000484 if (event < 0)
485 ThrowIdentifyException(OptionError,"UnrecognizedEventType",
486 argv[i]);
487 (void) SetLogEventMask(argv[i]);
488 break;
489 }
490 if (LocaleCompare("define",option+1) == 0)
491 {
492 i++;
cristybb503372010-05-27 20:51:26 +0000493 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000494 ThrowIdentifyException(OptionError,"MissingArgument",option);
495 if (*option == '+')
496 {
497 const char
498 *define;
499
500 define=GetImageOption(image_info,argv[i]);
501 if (define == (const char *) NULL)
502 ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]);
503 break;
504 }
cristyfc0f4c52014-02-12 23:47:26 +0000505 if (LocaleNCompare("identify:locate",argv[i],15) == 0)
cristy7d8529e2013-09-01 17:03:36 +0000506 image_info->ping=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +0000507 break;
508 }
509 if (LocaleCompare("density",option+1) == 0)
510 {
511 if (*option == '+')
512 break;
513 i++;
cristybb503372010-05-27 20:51:26 +0000514 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000515 ThrowIdentifyException(OptionError,"MissingArgument",option);
516 if (IsGeometry(argv[i]) == MagickFalse)
517 ThrowIdentifyInvalidArgumentException(option,argv[i]);
518 break;
519 }
520 if (LocaleCompare("depth",option+1) == 0)
521 {
522 if (*option == '+')
523 break;
524 i++;
cristybb503372010-05-27 20:51:26 +0000525 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000526 ThrowIdentifyException(OptionError,"MissingArgument",option);
527 if (IsGeometry(argv[i]) == MagickFalse)
528 ThrowIdentifyInvalidArgumentException(option,argv[i]);
529 break;
530 }
cristy22879752009-10-25 23:55:40 +0000531 if (LocaleCompare("duration",option+1) == 0)
532 {
533 if (*option == '+')
534 break;
535 i++;
cristye81f5522014-05-07 01:25:59 +0000536 if (i == (ssize_t) argc)
cristy22879752009-10-25 23:55:40 +0000537 ThrowIdentifyException(OptionError,"MissingArgument",option);
538 if (IsGeometry(argv[i]) == MagickFalse)
539 ThrowIdentifyInvalidArgumentException(option,argv[i]);
540 break;
541 }
cristy3ed852e2009-09-05 21:47:34 +0000542 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
543 }
cristy1e618102013-03-17 14:52:31 +0000544 case 'e':
cristy605e80d2012-09-12 11:34:39 +0000545 {
546 if (LocaleCompare("endian",option+1) == 0)
547 {
548 ssize_t
549 endian;
550
551 if (*option == '+')
552 break;
553 i++;
cristye81f5522014-05-07 01:25:59 +0000554 if (i == (ssize_t) argc)
cristy605e80d2012-09-12 11:34:39 +0000555 ThrowIdentifyException(OptionError,"MissingArgument",option);
556 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
557 argv[i]);
558 if (endian < 0)
559 ThrowIdentifyException(OptionError,"UnrecognizedEndianType",
560 argv[i]);
561 break;
562 }
563 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
564 }
cristy3ed852e2009-09-05 21:47:34 +0000565 case 'f':
566 {
cristy549a37e2010-01-26 15:24:15 +0000567 if (LocaleCompare("features",option+1) == 0)
cristycd483f12010-01-26 15:30:08 +0000568 {
569 if (*option == '+')
570 break;
571 i++;
cristye81f5522014-05-07 01:25:59 +0000572 if (i == (ssize_t) argc)
cristycd483f12010-01-26 15:30:08 +0000573 ThrowIdentifyException(OptionError,"MissingArgument",option);
574 if (IsGeometry(argv[i]) == MagickFalse)
575 ThrowIdentifyInvalidArgumentException(option,argv[i]);
576 break;
577 }
cristy3ed852e2009-09-05 21:47:34 +0000578 if (LocaleCompare("format",option+1) == 0)
579 {
580 format=(char *) NULL;
581 if (*option == '+')
582 break;
583 i++;
cristybb503372010-05-27 20:51:26 +0000584 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000585 ThrowIdentifyException(OptionError,"MissingArgument",option);
586 format=argv[i];
587 break;
588 }
589 if (LocaleCompare("fuzz",option+1) == 0)
590 {
591 if (*option == '+')
592 break;
593 i++;
cristye81f5522014-05-07 01:25:59 +0000594 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000595 ThrowIdentifyException(OptionError,"MissingArgument",option);
596 if (IsGeometry(argv[i]) == MagickFalse)
597 ThrowIdentifyInvalidArgumentException(option,argv[i]);
598 break;
599 }
600 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
601 }
602 case 'g':
603 {
604 if (LocaleCompare("gamma",option+1) == 0)
605 {
606 i++;
cristye81f5522014-05-07 01:25:59 +0000607 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000608 ThrowIdentifyException(OptionError,"MissingArgument",option);
609 if (IsGeometry(argv[i]) == MagickFalse)
610 ThrowIdentifyInvalidArgumentException(option,argv[i]);
611 break;
612 }
cristy0a09e9d2013-09-01 19:08:23 +0000613 if (LocaleCompare("grayscale",option+1) == 0)
614 {
615 ssize_t
616 method;
617
618 if (*option == '+')
619 break;
620 i++;
cristye81f5522014-05-07 01:25:59 +0000621 if (i == (ssize_t) argc)
cristy0a09e9d2013-09-01 19:08:23 +0000622 ThrowIdentifyException(OptionError,"MissingArgument",option);
623 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
624 argv[i]);
625 if (method < 0)
626 ThrowIdentifyException(OptionError,"UnrecognizedIntensityMethod",
627 argv[i]);
628 break;
629 }
630 if (LocaleCompare("green-primary",option+1) == 0)
631 {
632 if (*option == '+')
633 break;
634 i++;
cristye81f5522014-05-07 01:25:59 +0000635 if (i == (ssize_t) argc)
cristy0a09e9d2013-09-01 19:08:23 +0000636 ThrowIdentifyException(OptionError,"MissingArgument",option);
637 if (IsGeometry(argv[i]) == MagickFalse)
638 ThrowIdentifyInvalidArgumentException(option,argv[i]);
639 break;
640 }
cristy3ed852e2009-09-05 21:47:34 +0000641 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
642 }
643 case 'h':
644 {
645 if ((LocaleCompare("help",option+1) == 0) ||
646 (LocaleCompare("-help",option+1) == 0))
647 return(IdentifyUsage());
648 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
649 }
650 case 'i':
651 {
652 if (LocaleCompare("interlace",option+1) == 0)
653 {
cristybb503372010-05-27 20:51:26 +0000654 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000655 interlace;
656
657 if (*option == '+')
658 break;
659 i++;
cristybb503372010-05-27 20:51:26 +0000660 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000661 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000662 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000663 argv[i]);
664 if (interlace < 0)
665 ThrowIdentifyException(OptionError,
666 "UnrecognizedInterlaceType",argv[i]);
667 break;
668 }
669 if (LocaleCompare("interpolate",option+1) == 0)
670 {
cristybb503372010-05-27 20:51:26 +0000671 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000672 interpolate;
673
674 if (*option == '+')
675 break;
676 i++;
cristybb503372010-05-27 20:51:26 +0000677 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000678 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000679 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000680 argv[i]);
681 if (interpolate < 0)
682 ThrowIdentifyException(OptionError,
683 "UnrecognizedInterpolateMethod",argv[i]);
684 break;
685 }
686 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
687 }
688 case 'l':
689 {
690 if (LocaleCompare("limit",option+1) == 0)
691 {
692 char
693 *p;
694
695 double
696 value;
697
cristybb503372010-05-27 20:51:26 +0000698 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000699 resource;
700
701 if (*option == '+')
702 break;
703 i++;
cristybb503372010-05-27 20:51:26 +0000704 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000705 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000706 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000707 argv[i]);
708 if (resource < 0)
709 ThrowIdentifyException(OptionError,"UnrecognizedResourceType",
710 argv[i]);
711 i++;
cristybb503372010-05-27 20:51:26 +0000712 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000713 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristydbdd0e32011-11-04 23:29:40 +0000714 value=StringToDouble(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +0000715 (void) value;
cristy3ed852e2009-09-05 21:47:34 +0000716 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
717 ThrowIdentifyInvalidArgumentException(option,argv[i]);
718 break;
719 }
720 if (LocaleCompare("list",option+1) == 0)
721 {
cristybb503372010-05-27 20:51:26 +0000722 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000723 list;
724
725 if (*option == '+')
726 break;
727 i++;
cristybb503372010-05-27 20:51:26 +0000728 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000729 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000730 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000731 if (list < 0)
732 ThrowIdentifyException(OptionError,"UnrecognizedListType",
733 argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +0000734 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +0000735 argv+j,exception);
736 DestroyIdentify();
cristyaeb2cbc2010-05-07 13:28:58 +0000737 return(status != 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +0000738 }
739 if (LocaleCompare("log",option+1) == 0)
740 {
741 if (*option == '+')
742 break;
743 i++;
cristybb503372010-05-27 20:51:26 +0000744 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +0000745 (strchr(argv[i],'%') == (char *) NULL))
746 ThrowIdentifyException(OptionError,"MissingArgument",option);
747 break;
748 }
749 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
750 }
751 case 'm':
752 {
cristy5048d302012-08-07 01:05:16 +0000753 if (LocaleCompare("mask",option+1) == 0)
754 {
755 if (*option == '+')
756 break;
757 i++;
cristye81f5522014-05-07 01:25:59 +0000758 if (i == (ssize_t) argc)
cristy5048d302012-08-07 01:05:16 +0000759 ThrowIdentifyException(OptionError,"MissingArgument",option);
760 break;
761 }
cristy3ed852e2009-09-05 21:47:34 +0000762 if (LocaleCompare("matte",option+1) == 0)
763 break;
cristye444b042014-01-07 15:28:15 +0000764 if (LocaleCompare("moments",option+1) == 0)
cristyd12341f2014-01-07 15:34:13 +0000765 break;
cristy3ed852e2009-09-05 21:47:34 +0000766 if (LocaleCompare("monitor",option+1) == 0)
767 break;
768 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
769 }
cristye48c6a92010-02-01 01:25:42 +0000770 case 'n':
771 {
772 if (LocaleCompare("negate",option+1) == 0)
773 break;
774 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
775 }
cristy3ed852e2009-09-05 21:47:34 +0000776 case 'p':
777 {
778 if (LocaleCompare("ping",option+1) == 0)
779 break;
cristya1b14862013-09-01 23:53:47 +0000780 if (LocaleCompare("precision",option+1) == 0)
781 {
782 if (*option == '+')
783 break;
784 i++;
cristye81f5522014-05-07 01:25:59 +0000785 if (i == (ssize_t) argc)
cristya1b14862013-09-01 23:53:47 +0000786 ThrowIdentifyException(OptionError,"MissingArgument",option);
787 if (IsGeometry(argv[i]) == MagickFalse)
788 ThrowIdentifyInvalidArgumentException(option,argv[i]);
789 break;
790 }
cristy3ed852e2009-09-05 21:47:34 +0000791 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
792 }
793 case 'q':
794 {
795 if (LocaleCompare("quiet",option+1) == 0)
796 break;
797 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
798 }
799 case 'r':
800 {
801 if (LocaleCompare("regard-warnings",option+1) == 0)
802 break;
803 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
804 {
805 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
806 break;
807 }
808 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
809 }
810 case 's':
811 {
812 if (LocaleCompare("sampling-factor",option+1) == 0)
813 {
814 if (*option == '+')
815 break;
816 i++;
cristybb503372010-05-27 20:51:26 +0000817 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000818 ThrowIdentifyException(OptionError,"MissingArgument",option);
819 if (IsGeometry(argv[i]) == MagickFalse)
820 ThrowIdentifyInvalidArgumentException(option,argv[i]);
821 break;
822 }
823 if (LocaleCompare("seed",option+1) == 0)
824 {
825 if (*option == '+')
826 break;
827 i++;
cristye81f5522014-05-07 01:25:59 +0000828 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000829 ThrowIdentifyException(OptionError,"MissingArgument",option);
830 if (IsGeometry(argv[i]) == MagickFalse)
831 ThrowIdentifyInvalidArgumentException(option,argv[i]);
832 break;
833 }
834 if (LocaleCompare("set",option+1) == 0)
835 {
836 i++;
cristybb503372010-05-27 20:51:26 +0000837 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000838 ThrowIdentifyException(OptionError,"MissingArgument",option);
839 if (*option == '+')
840 break;
841 i++;
cristybb503372010-05-27 20:51:26 +0000842 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000843 ThrowIdentifyException(OptionError,"MissingArgument",option);
844 break;
845 }
846 if (LocaleCompare("size",option+1) == 0)
847 {
848 if (*option == '+')
849 break;
850 i++;
cristybb503372010-05-27 20:51:26 +0000851 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000852 ThrowIdentifyException(OptionError,"MissingArgument",option);
853 if (IsGeometry(argv[i]) == MagickFalse)
854 ThrowIdentifyInvalidArgumentException(option,argv[i]);
855 break;
856 }
857 if (LocaleCompare("strip",option+1) == 0)
858 break;
859 if (LocaleCompare("support",option+1) == 0)
860 {
861 if (*option == '+')
862 break;
863 i++;
cristybb503372010-05-27 20:51:26 +0000864 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000865 ThrowIdentifyException(OptionError,"MissingArgument",option);
866 if (IsGeometry(argv[i]) == MagickFalse)
867 ThrowIdentifyInvalidArgumentException(option,argv[i]);
868 break;
869 }
870 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
871 }
872 case 'u':
873 {
cristy045bd902010-01-30 18:56:24 +0000874 if (LocaleCompare("unique",option+1) == 0)
875 break;
cristy3ed852e2009-09-05 21:47:34 +0000876 if (LocaleCompare("units",option+1) == 0)
877 {
cristybb503372010-05-27 20:51:26 +0000878 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000879 units;
880
881 if (*option == '+')
882 break;
883 i++;
cristye81f5522014-05-07 01:25:59 +0000884 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000885 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000886 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000887 argv[i]);
888 if (units < 0)
889 ThrowIdentifyException(OptionError,"UnrecognizedUnitsType",
890 argv[i]);
891 break;
892 }
893 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
894 }
895 case 'v':
896 {
897 if (LocaleCompare("verbose",option+1) == 0)
898 break;
899 if (LocaleCompare("virtual-pixel",option+1) == 0)
900 {
cristybb503372010-05-27 20:51:26 +0000901 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000902 method;
903
904 if (*option == '+')
905 break;
906 i++;
cristye81f5522014-05-07 01:25:59 +0000907 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000908 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000909 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000910 argv[i]);
911 if (method < 0)
912 ThrowIdentifyException(OptionError,
913 "UnrecognizedVirtualPixelMethod",argv[i]);
914 break;
915 }
916 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
917 }
918 case '?':
919 break;
920 default:
921 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
922 }
cristy042ee782011-04-22 18:48:30 +0000923 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
924 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +0000925 if (fire != MagickFalse)
926 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
927 }
928 if (k != 0)
929 ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]);
cristycee97112010-05-28 00:44:52 +0000930 if (i != (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000931 ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]);
932 DestroyIdentify();
933 return(status != 0 ? MagickTrue : MagickFalse);
934}