blob: 25f8517de5c2f101754fa0f3cfcd3fbac33d2106 [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 %
16% John Cristy %
17% September 1994 %
18% %
19% %
cristy7e41fe82010-12-04 23:12:08 +000020% Copyright 1999-2011 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"
cristy3ed852e2009-09-05 21:47:34 +000053
54/*
55%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56% %
57% %
58% %
59+ I d e n t i f y I m a g e C o m m a n d %
60% %
61% %
62% %
63%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
64%
65% IdentifyImageCommand() describes the format and characteristics of one or
66% more image files. It will also report if an image is incomplete or corrupt.
67% The information displayed includes the scene number, the file name, the
68% width and height of the image, whether the image is colormapped or not,
69% the number of colors in the image, the number of bytes in the image, the
70% format of the image (JPEG, PNM, etc.), and finally the number of seconds
71% it took to read and process the image.
72%
73% The format of the IdentifyImageCommand method is:
74%
75% MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,int argc,
76% char **argv,char **metadata,ExceptionInfo *exception)
77%
78% A description of each parameter follows:
79%
80% o image_info: the image info.
81%
82% o argc: the number of elements in the argument vector.
83%
84% o argv: A text array containing the command line arguments.
85%
86% o metadata: any metadata is returned here.
87%
88% o exception: return any errors or warnings in this structure.
89%
90*/
91
92static MagickBooleanType IdentifyUsage(void)
93{
94 const char
95 **p;
96
97 static const char
98 *miscellaneous[]=
99 {
100 "-debug events display copious debugging information",
101 "-help print program options",
102 "-list type print a list of supported option arguments",
103 "-log format format of debugging information",
104 "-version print version information",
105 (char *) NULL
106 },
cristye48c6a92010-02-01 01:25:42 +0000107 *operators[]=
108 {
109 "-negate replace every pixel with its complementary color ",
110 (char *) NULL
111 },
cristy3ed852e2009-09-05 21:47:34 +0000112 *settings[]=
113 {
114 "-alpha option on, activate, off, deactivate, set, opaque, copy",
115 " transparent, extract, background, or shape",
116 "-antialias remove pixel-aliasing",
117 "-authenticate password",
118 " decipher image with this password",
119 "-channel type apply option to select image channels",
120 "-colorspace type alternate image colorspace",
121 "-crop geometry cut out a rectangular region of the image",
122 "-define format:option",
123 " define one or more image format options",
124 "-density geometry horizontal and vertical density of the image",
125 "-depth value image depth",
126 "-extract geometry extract area from image",
cristy02d5b4f2010-02-01 01:08:27 +0000127 "-features distance display image features (e.g. contrast, correlation)",
cristy3ed852e2009-09-05 21:47:34 +0000128 "-format \"string\" output formatted image characteristics",
129 "-fuzz distance colors within this distance are considered equal",
cristycd483f12010-01-26 15:30:08 +0000130 "-gamma value of gamma correction",
cristy3ed852e2009-09-05 21:47:34 +0000131 "-interlace type type of image interlacing scheme",
132 "-interpolate method pixel color interpolation method",
133 "-limit type value pixel cache resource limit",
134 "-monitor monitor progress",
135 "-ping efficiently determine image attributes",
136 "-quiet suppress all warning messages",
137 "-regard-warnings pay attention to warning messages",
138 "-respect-parentheses settings remain in effect until parenthesis boundary",
139 "-sampling-factor geometry",
140 " horizontal and vertical sampling factor",
141 "-seed value seed a new sequence of pseudo-random numbers",
142 "-set attribute value set an image attribute",
143 "-size geometry width and height of image",
144 "-strip strip image of all profiles and comments",
cristy045bd902010-01-30 18:56:24 +0000145 "-unique display the number of unique colors in the image",
cristy3ed852e2009-09-05 21:47:34 +0000146 "-units type the units of image resolution",
147 "-verbose print detailed information about the image",
148 "-virtual-pixel method",
149 " virtual pixel access method",
150 (char *) NULL
151 };
152
cristybb503372010-05-27 20:51:26 +0000153 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
cristy610b2e22009-10-22 14:59:43 +0000154 (void) printf("Copyright: %s\n",GetMagickCopyright());
155 (void) printf("Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +0000156 (void) printf("Usage: %s [options ...] file [ [options ...] "
157 "file ... ]\n",GetClientName());
158 (void) printf("\nImage Settings:\n");
159 for (p=settings; *p != (char *) NULL; p++)
160 (void) printf(" %s\n",*p);
cristye48c6a92010-02-01 01:25:42 +0000161 (void) printf("\nImage Operators:\n");
162 for (p=operators; *p != (char *) NULL; p++)
163 (void) printf(" %s\n",*p);
cristy3ed852e2009-09-05 21:47:34 +0000164 (void) printf("\nMiscellaneous Options:\n");
165 for (p=miscellaneous; *p != (char *) NULL; p++)
166 (void) printf(" %s\n",*p);
167 (void) printf(
168 "\nBy default, the image format of `file' is determined by its magic\n");
169 (void) printf(
170 "number. To specify a particular image format, precede the filename\n");
171 (void) printf(
172 "with an image format name and a colon (i.e. ps:image) or specify the\n");
173 (void) printf(
174 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
175 (void) printf("'-' for standard input or output.\n");
176 return(MagickFalse);
177}
178
179WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
180 int argc,char **argv,char **metadata,ExceptionInfo *exception)
181{
182#define DestroyIdentify() \
183{ \
184 DestroyImageStack(); \
cristybb503372010-05-27 20:51:26 +0000185 for (i=0; i < (ssize_t) argc; i++) \
cristy3ed852e2009-09-05 21:47:34 +0000186 argv[i]=DestroyString(argv[i]); \
187 argv=(char **) RelinquishMagickMemory(argv); \
188}
189#define ThrowIdentifyException(asperity,tag,option) \
190{ \
191 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
192 option); \
193 DestroyIdentify(); \
194 return(MagickFalse); \
195}
196#define ThrowIdentifyInvalidArgumentException(option,argument) \
197{ \
198 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
199 "InvalidArgument","`%s': %s",option,argument); \
200 DestroyIdentify(); \
201 return(MagickFalse); \
202}
203
204 const char
205 *format,
206 *option;
207
208 Image
209 *image;
210
211 ImageStack
212 image_stack[MaxImageStackDepth+1];
213
cristy3ed852e2009-09-05 21:47:34 +0000214 MagickBooleanType
215 fire,
cristyebbcfea2011-02-25 02:43:54 +0000216 pend,
217 respect_parenthesis;
cristy3ed852e2009-09-05 21:47:34 +0000218
219 MagickStatusType
220 status;
221
cristybb503372010-05-27 20:51:26 +0000222 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000223 i;
224
cristybb503372010-05-27 20:51:26 +0000225 size_t
cristy3ed852e2009-09-05 21:47:34 +0000226 count;
227
cristy9d314ff2011-03-09 01:30:28 +0000228 ssize_t
229 j,
230 k;
231
cristy3ed852e2009-09-05 21:47:34 +0000232 /*
233 Set defaults.
234 */
235 assert(image_info != (ImageInfo *) NULL);
236 assert(image_info->signature == MagickSignature);
237 if (image_info->debug != MagickFalse)
238 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
239 assert(exception != (ExceptionInfo *) NULL);
240 if (argc == 2)
241 {
242 option=argv[1];
243 if ((LocaleCompare("version",option+1) == 0) ||
244 (LocaleCompare("-version",option+1) == 0))
245 {
cristyb51dff52011-05-19 16:55:47 +0000246 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +0000247 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +0000248 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
249 GetMagickCopyright());
250 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
251 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +0000252 return(MagickFalse);
253 }
254 }
255 if (argc < 2)
cristy13e61a12010-02-04 20:19:00 +0000256 return(IdentifyUsage());
cristy3ed852e2009-09-05 21:47:34 +0000257 count=0;
258 format=NULL;
259 j=1;
260 k=0;
261 NewImageStack();
262 option=(char *) NULL;
263 pend=MagickFalse;
cristyebbcfea2011-02-25 02:43:54 +0000264 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +0000265 status=MagickTrue;
266 /*
267 Identify an image.
268 */
269 ReadCommandlLine(argc,&argv);
270 status=ExpandFilenames(&argc,&argv);
271 if (status == MagickFalse)
272 ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed",
273 GetExceptionMessage(errno));
274 image_info->ping=MagickTrue;
cristybb503372010-05-27 20:51:26 +0000275 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000276 {
277 option=argv[i];
278 if (LocaleCompare(option,"(") == 0)
279 {
280 FireImageStack(MagickFalse,MagickTrue,pend);
281 if (k == MaxImageStackDepth)
282 ThrowIdentifyException(OptionError,"ParenthesisNestedTooDeeply",
283 option);
284 PushImageStack();
285 continue;
286 }
287 if (LocaleCompare(option,")") == 0)
288 {
289 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
290 if (k == 0)
291 ThrowIdentifyException(OptionError,"UnableToParseExpression",option);
292 PopImageStack();
293 continue;
294 }
cristy042ee782011-04-22 18:48:30 +0000295 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000296 {
297 char
298 *filename;
299
300 Image
301 *images;
302
303 ImageInfo
304 *identify_info;
305
306 /*
307 Read input image.
308 */
309 FireImageStack(MagickFalse,MagickFalse,pend);
310 identify_info=CloneImageInfo(image_info);
311 identify_info->verbose=MagickFalse;
312 filename=argv[i];
cristycee97112010-05-28 00:44:52 +0000313 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
cristy3ed852e2009-09-05 21:47:34 +0000314 filename=argv[++i];
315 (void) CopyMagickString(identify_info->filename,filename,MaxTextExtent);
316 if (identify_info->ping != MagickFalse)
317 images=PingImages(identify_info,exception);
318 else
319 images=ReadImages(identify_info,exception);
320 identify_info=DestroyImageInfo(identify_info);
321 status&=(images != (Image *) NULL) &&
322 (exception->severity < ErrorException);
323 if (images == (Image *) NULL)
324 continue;
325 AppendImageStack(images);
326 FinalizeImageSettings(image_info,image,MagickFalse);
327 for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
328 {
329 if (image->scene == 0)
330 image->scene=count++;
331 if (format == (char *) NULL)
332 {
333 (void) IdentifyImage(image,stdout,image_info->verbose);
334 continue;
335 }
336 if (metadata != (char **) NULL)
337 {
338 char
339 *text;
340
341 text=InterpretImageProperties(image_info,image,format);
342 if (text == (char *) NULL)
343 ThrowIdentifyException(ResourceLimitError,
344 "MemoryAllocationFailed",GetExceptionMessage(errno));
345 (void) ConcatenateString(&(*metadata),text);
346 text=DestroyString(text);
347 if (LocaleCompare(format,"%n") == 0)
348 break;
349 }
350 }
351 RemoveAllImageStack();
352 continue;
353 }
354 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
355 switch (*(option+1))
356 {
357 case 'a':
358 {
359 if (LocaleCompare("alpha",option+1) == 0)
360 {
cristybb503372010-05-27 20:51:26 +0000361 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000362 type;
363
364 if (*option == '+')
365 break;
366 i++;
cristybb503372010-05-27 20:51:26 +0000367 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000368 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000369 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000370 if (type < 0)
371 ThrowIdentifyException(OptionError,"UnrecognizedAlphaChannelType",
372 argv[i]);
373 break;
374 }
375 if (LocaleCompare("antialias",option+1) == 0)
376 break;
377 if (LocaleCompare("authenticate",option+1) == 0)
378 {
379 if (*option == '+')
380 break;
381 i++;
cristybb503372010-05-27 20:51:26 +0000382 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000383 ThrowIdentifyException(OptionError,"MissingArgument",option);
384 break;
385 }
386 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
387 }
388 case 'c':
389 {
390 if (LocaleCompare("cache",option+1) == 0)
391 {
392 if (*option == '+')
393 break;
394 i++;
cristybb503372010-05-27 20:51:26 +0000395 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000396 ThrowIdentifyException(OptionError,"MissingArgument",option);
397 if (IsGeometry(argv[i]) == MagickFalse)
398 ThrowIdentifyInvalidArgumentException(option,argv[i]);
399 break;
400 }
401 if (LocaleCompare("channel",option+1) == 0)
402 {
cristybb503372010-05-27 20:51:26 +0000403 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000404 channel;
405
406 if (*option == '+')
407 break;
408 i++;
cristybb503372010-05-27 20:51:26 +0000409 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000410 ThrowIdentifyException(OptionError,"MissingArgument",option);
411 channel=ParseChannelOption(argv[i]);
412 if (channel < 0)
413 ThrowIdentifyException(OptionError,"UnrecognizedChannelType",
414 argv[i]);
415 break;
416 }
417 if (LocaleCompare("colorspace",option+1) == 0)
418 {
cristybb503372010-05-27 20:51:26 +0000419 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000420 colorspace;
421
422 if (*option == '+')
423 break;
424 i++;
cristybb503372010-05-27 20:51:26 +0000425 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000426 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000427 colorspace=ParseCommandOption(MagickColorspaceOptions,
cristy3ed852e2009-09-05 21:47:34 +0000428 MagickFalse,argv[i]);
429 if (colorspace < 0)
430 ThrowIdentifyException(OptionError,"UnrecognizedColorspace",
431 argv[i]);
432 break;
433 }
434 if (LocaleCompare("crop",option+1) == 0)
435 {
436 if (*option == '+')
437 break;
438 i++;
cristybb503372010-05-27 20:51:26 +0000439 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000440 ThrowIdentifyException(OptionError,"MissingArgument",option);
441 if (IsGeometry(argv[i]) == MagickFalse)
442 ThrowIdentifyInvalidArgumentException(option,argv[i]);
443 image_info->ping=MagickFalse;
444 break;
445 }
cristy22879752009-10-25 23:55:40 +0000446 if (LocaleCompare("concurrent",option+1) == 0)
447 break;
cristy3ed852e2009-09-05 21:47:34 +0000448 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
449 }
450 case 'd':
451 {
452 if (LocaleCompare("debug",option+1) == 0)
453 {
cristybb503372010-05-27 20:51:26 +0000454 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000455 event;
456
457 if (*option == '+')
458 break;
459 i++;
cristybb503372010-05-27 20:51:26 +0000460 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000461 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000462 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000463 if (event < 0)
464 ThrowIdentifyException(OptionError,"UnrecognizedEventType",
465 argv[i]);
466 (void) SetLogEventMask(argv[i]);
467 break;
468 }
469 if (LocaleCompare("define",option+1) == 0)
470 {
471 i++;
cristybb503372010-05-27 20:51:26 +0000472 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000473 ThrowIdentifyException(OptionError,"MissingArgument",option);
474 if (*option == '+')
475 {
476 const char
477 *define;
478
479 define=GetImageOption(image_info,argv[i]);
480 if (define == (const char *) NULL)
481 ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]);
482 break;
483 }
484 break;
485 }
486 if (LocaleCompare("density",option+1) == 0)
487 {
488 if (*option == '+')
489 break;
490 i++;
cristybb503372010-05-27 20:51:26 +0000491 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000492 ThrowIdentifyException(OptionError,"MissingArgument",option);
493 if (IsGeometry(argv[i]) == MagickFalse)
494 ThrowIdentifyInvalidArgumentException(option,argv[i]);
495 break;
496 }
497 if (LocaleCompare("depth",option+1) == 0)
498 {
499 if (*option == '+')
500 break;
501 i++;
cristybb503372010-05-27 20:51:26 +0000502 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000503 ThrowIdentifyException(OptionError,"MissingArgument",option);
504 if (IsGeometry(argv[i]) == MagickFalse)
505 ThrowIdentifyInvalidArgumentException(option,argv[i]);
506 break;
507 }
cristy22879752009-10-25 23:55:40 +0000508 if (LocaleCompare("duration",option+1) == 0)
509 {
510 if (*option == '+')
511 break;
512 i++;
cristybb503372010-05-27 20:51:26 +0000513 if (i == (ssize_t) (argc-1))
cristy22879752009-10-25 23:55:40 +0000514 ThrowIdentifyException(OptionError,"MissingArgument",option);
515 if (IsGeometry(argv[i]) == MagickFalse)
516 ThrowIdentifyInvalidArgumentException(option,argv[i]);
517 break;
518 }
cristy3ed852e2009-09-05 21:47:34 +0000519 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
520 }
521 case 'f':
522 {
cristy549a37e2010-01-26 15:24:15 +0000523 if (LocaleCompare("features",option+1) == 0)
cristycd483f12010-01-26 15:30:08 +0000524 {
525 if (*option == '+')
526 break;
527 i++;
cristybb503372010-05-27 20:51:26 +0000528 if (i == (ssize_t) (argc-1))
cristycd483f12010-01-26 15:30:08 +0000529 ThrowIdentifyException(OptionError,"MissingArgument",option);
530 if (IsGeometry(argv[i]) == MagickFalse)
531 ThrowIdentifyInvalidArgumentException(option,argv[i]);
532 break;
533 }
cristy3ed852e2009-09-05 21:47:34 +0000534 if (LocaleCompare("format",option+1) == 0)
535 {
536 format=(char *) NULL;
537 if (*option == '+')
538 break;
539 i++;
cristybb503372010-05-27 20:51:26 +0000540 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000541 ThrowIdentifyException(OptionError,"MissingArgument",option);
542 format=argv[i];
543 break;
544 }
545 if (LocaleCompare("fuzz",option+1) == 0)
546 {
547 if (*option == '+')
548 break;
549 i++;
cristybb503372010-05-27 20:51:26 +0000550 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000551 ThrowIdentifyException(OptionError,"MissingArgument",option);
552 if (IsGeometry(argv[i]) == MagickFalse)
553 ThrowIdentifyInvalidArgumentException(option,argv[i]);
554 break;
555 }
556 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
557 }
558 case 'g':
559 {
560 if (LocaleCompare("gamma",option+1) == 0)
561 {
562 i++;
cristybb503372010-05-27 20:51:26 +0000563 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000564 ThrowIdentifyException(OptionError,"MissingArgument",option);
565 if (IsGeometry(argv[i]) == MagickFalse)
566 ThrowIdentifyInvalidArgumentException(option,argv[i]);
567 break;
568 }
569 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
570 }
571 case 'h':
572 {
573 if ((LocaleCompare("help",option+1) == 0) ||
574 (LocaleCompare("-help",option+1) == 0))
575 return(IdentifyUsage());
576 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
577 }
578 case 'i':
579 {
580 if (LocaleCompare("interlace",option+1) == 0)
581 {
cristybb503372010-05-27 20:51:26 +0000582 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000583 interlace;
584
585 if (*option == '+')
586 break;
587 i++;
cristybb503372010-05-27 20:51:26 +0000588 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000589 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000590 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000591 argv[i]);
592 if (interlace < 0)
593 ThrowIdentifyException(OptionError,
594 "UnrecognizedInterlaceType",argv[i]);
595 break;
596 }
597 if (LocaleCompare("interpolate",option+1) == 0)
598 {
cristybb503372010-05-27 20:51:26 +0000599 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000600 interpolate;
601
602 if (*option == '+')
603 break;
604 i++;
cristybb503372010-05-27 20:51:26 +0000605 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000606 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000607 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000608 argv[i]);
609 if (interpolate < 0)
610 ThrowIdentifyException(OptionError,
611 "UnrecognizedInterpolateMethod",argv[i]);
612 break;
613 }
614 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
615 }
616 case 'l':
617 {
618 if (LocaleCompare("limit",option+1) == 0)
619 {
620 char
621 *p;
622
623 double
624 value;
625
cristybb503372010-05-27 20:51:26 +0000626 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000627 resource;
628
629 if (*option == '+')
630 break;
631 i++;
cristybb503372010-05-27 20:51:26 +0000632 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000633 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000634 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000635 argv[i]);
636 if (resource < 0)
637 ThrowIdentifyException(OptionError,"UnrecognizedResourceType",
638 argv[i]);
639 i++;
cristybb503372010-05-27 20:51:26 +0000640 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000641 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristyc1acd842011-05-19 23:05:47 +0000642 value=InterpretLocaleValue(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +0000643 (void) value;
cristy3ed852e2009-09-05 21:47:34 +0000644 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
645 ThrowIdentifyInvalidArgumentException(option,argv[i]);
646 break;
647 }
648 if (LocaleCompare("list",option+1) == 0)
649 {
cristybb503372010-05-27 20:51:26 +0000650 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000651 list;
652
653 if (*option == '+')
654 break;
655 i++;
cristybb503372010-05-27 20:51:26 +0000656 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000657 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000658 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000659 if (list < 0)
660 ThrowIdentifyException(OptionError,"UnrecognizedListType",
661 argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +0000662 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +0000663 argv+j,exception);
664 DestroyIdentify();
cristyaeb2cbc2010-05-07 13:28:58 +0000665 return(status != 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +0000666 }
667 if (LocaleCompare("log",option+1) == 0)
668 {
669 if (*option == '+')
670 break;
671 i++;
cristybb503372010-05-27 20:51:26 +0000672 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +0000673 (strchr(argv[i],'%') == (char *) NULL))
674 ThrowIdentifyException(OptionError,"MissingArgument",option);
675 break;
676 }
677 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
678 }
679 case 'm':
680 {
681 if (LocaleCompare("matte",option+1) == 0)
682 break;
683 if (LocaleCompare("monitor",option+1) == 0)
684 break;
685 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
686 }
cristye48c6a92010-02-01 01:25:42 +0000687 case 'n':
688 {
689 if (LocaleCompare("negate",option+1) == 0)
690 break;
691 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
692 }
cristy3ed852e2009-09-05 21:47:34 +0000693 case 'p':
694 {
695 if (LocaleCompare("ping",option+1) == 0)
696 break;
697 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
698 }
699 case 'q':
700 {
701 if (LocaleCompare("quiet",option+1) == 0)
702 break;
703 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
704 }
705 case 'r':
706 {
707 if (LocaleCompare("regard-warnings",option+1) == 0)
708 break;
709 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
710 {
711 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
712 break;
713 }
714 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
715 }
716 case 's':
717 {
718 if (LocaleCompare("sampling-factor",option+1) == 0)
719 {
720 if (*option == '+')
721 break;
722 i++;
cristybb503372010-05-27 20:51:26 +0000723 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000724 ThrowIdentifyException(OptionError,"MissingArgument",option);
725 if (IsGeometry(argv[i]) == MagickFalse)
726 ThrowIdentifyInvalidArgumentException(option,argv[i]);
727 break;
728 }
729 if (LocaleCompare("seed",option+1) == 0)
730 {
731 if (*option == '+')
732 break;
733 i++;
cristybb503372010-05-27 20:51:26 +0000734 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000735 ThrowIdentifyException(OptionError,"MissingArgument",option);
736 if (IsGeometry(argv[i]) == MagickFalse)
737 ThrowIdentifyInvalidArgumentException(option,argv[i]);
738 break;
739 }
740 if (LocaleCompare("set",option+1) == 0)
741 {
742 i++;
cristybb503372010-05-27 20:51:26 +0000743 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000744 ThrowIdentifyException(OptionError,"MissingArgument",option);
745 if (*option == '+')
746 break;
747 i++;
cristybb503372010-05-27 20:51:26 +0000748 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000749 ThrowIdentifyException(OptionError,"MissingArgument",option);
750 break;
751 }
752 if (LocaleCompare("size",option+1) == 0)
753 {
754 if (*option == '+')
755 break;
756 i++;
cristybb503372010-05-27 20:51:26 +0000757 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000758 ThrowIdentifyException(OptionError,"MissingArgument",option);
759 if (IsGeometry(argv[i]) == MagickFalse)
760 ThrowIdentifyInvalidArgumentException(option,argv[i]);
761 break;
762 }
763 if (LocaleCompare("strip",option+1) == 0)
764 break;
765 if (LocaleCompare("support",option+1) == 0)
766 {
767 if (*option == '+')
768 break;
769 i++;
cristybb503372010-05-27 20:51:26 +0000770 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000771 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 'u':
779 {
cristy045bd902010-01-30 18:56:24 +0000780 if (LocaleCompare("unique",option+1) == 0)
781 break;
cristy3ed852e2009-09-05 21:47:34 +0000782 if (LocaleCompare("units",option+1) == 0)
783 {
cristybb503372010-05-27 20:51:26 +0000784 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000785 units;
786
787 if (*option == '+')
788 break;
789 i++;
cristybb503372010-05-27 20:51:26 +0000790 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000791 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000792 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000793 argv[i]);
794 if (units < 0)
795 ThrowIdentifyException(OptionError,"UnrecognizedUnitsType",
796 argv[i]);
797 break;
798 }
799 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
800 }
801 case 'v':
802 {
803 if (LocaleCompare("verbose",option+1) == 0)
804 break;
805 if (LocaleCompare("virtual-pixel",option+1) == 0)
806 {
cristybb503372010-05-27 20:51:26 +0000807 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000808 method;
809
810 if (*option == '+')
811 break;
812 i++;
cristybb503372010-05-27 20:51:26 +0000813 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000814 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000815 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000816 argv[i]);
817 if (method < 0)
818 ThrowIdentifyException(OptionError,
819 "UnrecognizedVirtualPixelMethod",argv[i]);
820 break;
821 }
822 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
823 }
824 case '?':
825 break;
826 default:
827 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
828 }
cristy042ee782011-04-22 18:48:30 +0000829 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
830 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +0000831 if (fire != MagickFalse)
832 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
833 }
834 if (k != 0)
835 ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]);
cristycee97112010-05-28 00:44:52 +0000836 if (i != (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000837 ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]);
838 DestroyIdentify();
839 return(status != 0 ? MagickTrue : MagickFalse);
840}