blob: 687d5601c6fc68b930f47eaf85dbd8cf5e77066b [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*/
50#include "wand/studio.h"
51#include "wand/MagickWand.h"
52#include "wand/mogrify-private.h"
53
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));
cristyb51dff52011-05-19 16:55:47 +0000248 (void) FormatLocaleFile(stdout,"Copyright: %s\n",GetMagickCopyright());
249 (void) FormatLocaleFile(stdout,"Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +0000250 return(MagickFalse);
251 }
252 }
253 if (argc < 2)
cristy13e61a12010-02-04 20:19:00 +0000254 return(IdentifyUsage());
cristy3ed852e2009-09-05 21:47:34 +0000255 count=0;
256 format=NULL;
257 j=1;
258 k=0;
259 NewImageStack();
260 option=(char *) NULL;
261 pend=MagickFalse;
cristyebbcfea2011-02-25 02:43:54 +0000262 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +0000263 status=MagickTrue;
264 /*
265 Identify an image.
266 */
267 ReadCommandlLine(argc,&argv);
268 status=ExpandFilenames(&argc,&argv);
269 if (status == MagickFalse)
270 ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed",
271 GetExceptionMessage(errno));
272 image_info->ping=MagickTrue;
cristybb503372010-05-27 20:51:26 +0000273 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000274 {
275 option=argv[i];
276 if (LocaleCompare(option,"(") == 0)
277 {
278 FireImageStack(MagickFalse,MagickTrue,pend);
279 if (k == MaxImageStackDepth)
280 ThrowIdentifyException(OptionError,"ParenthesisNestedTooDeeply",
281 option);
282 PushImageStack();
283 continue;
284 }
285 if (LocaleCompare(option,")") == 0)
286 {
287 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
288 if (k == 0)
289 ThrowIdentifyException(OptionError,"UnableToParseExpression",option);
290 PopImageStack();
291 continue;
292 }
cristy042ee782011-04-22 18:48:30 +0000293 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000294 {
295 char
296 *filename;
297
298 Image
299 *images;
300
301 ImageInfo
302 *identify_info;
303
304 /*
305 Read input image.
306 */
307 FireImageStack(MagickFalse,MagickFalse,pend);
308 identify_info=CloneImageInfo(image_info);
309 identify_info->verbose=MagickFalse;
310 filename=argv[i];
cristycee97112010-05-28 00:44:52 +0000311 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
cristy3ed852e2009-09-05 21:47:34 +0000312 filename=argv[++i];
313 (void) CopyMagickString(identify_info->filename,filename,MaxTextExtent);
314 if (identify_info->ping != MagickFalse)
315 images=PingImages(identify_info,exception);
316 else
317 images=ReadImages(identify_info,exception);
318 identify_info=DestroyImageInfo(identify_info);
319 status&=(images != (Image *) NULL) &&
320 (exception->severity < ErrorException);
321 if (images == (Image *) NULL)
322 continue;
323 AppendImageStack(images);
324 FinalizeImageSettings(image_info,image,MagickFalse);
325 for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
326 {
327 if (image->scene == 0)
328 image->scene=count++;
329 if (format == (char *) NULL)
330 {
331 (void) IdentifyImage(image,stdout,image_info->verbose);
332 continue;
333 }
334 if (metadata != (char **) NULL)
335 {
336 char
337 *text;
338
339 text=InterpretImageProperties(image_info,image,format);
340 if (text == (char *) NULL)
341 ThrowIdentifyException(ResourceLimitError,
342 "MemoryAllocationFailed",GetExceptionMessage(errno));
343 (void) ConcatenateString(&(*metadata),text);
344 text=DestroyString(text);
345 if (LocaleCompare(format,"%n") == 0)
346 break;
347 }
348 }
349 RemoveAllImageStack();
350 continue;
351 }
352 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
353 switch (*(option+1))
354 {
355 case 'a':
356 {
357 if (LocaleCompare("alpha",option+1) == 0)
358 {
cristybb503372010-05-27 20:51:26 +0000359 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000360 type;
361
362 if (*option == '+')
363 break;
364 i++;
cristybb503372010-05-27 20:51:26 +0000365 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000366 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000367 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000368 if (type < 0)
369 ThrowIdentifyException(OptionError,"UnrecognizedAlphaChannelType",
370 argv[i]);
371 break;
372 }
373 if (LocaleCompare("antialias",option+1) == 0)
374 break;
375 if (LocaleCompare("authenticate",option+1) == 0)
376 {
377 if (*option == '+')
378 break;
379 i++;
cristybb503372010-05-27 20:51:26 +0000380 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000381 ThrowIdentifyException(OptionError,"MissingArgument",option);
382 break;
383 }
384 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
385 }
386 case 'c':
387 {
388 if (LocaleCompare("cache",option+1) == 0)
389 {
390 if (*option == '+')
391 break;
392 i++;
cristybb503372010-05-27 20:51:26 +0000393 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000394 ThrowIdentifyException(OptionError,"MissingArgument",option);
395 if (IsGeometry(argv[i]) == MagickFalse)
396 ThrowIdentifyInvalidArgumentException(option,argv[i]);
397 break;
398 }
399 if (LocaleCompare("channel",option+1) == 0)
400 {
cristybb503372010-05-27 20:51:26 +0000401 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000402 channel;
403
404 if (*option == '+')
405 break;
406 i++;
cristybb503372010-05-27 20:51:26 +0000407 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000408 ThrowIdentifyException(OptionError,"MissingArgument",option);
409 channel=ParseChannelOption(argv[i]);
410 if (channel < 0)
411 ThrowIdentifyException(OptionError,"UnrecognizedChannelType",
412 argv[i]);
413 break;
414 }
415 if (LocaleCompare("colorspace",option+1) == 0)
416 {
cristybb503372010-05-27 20:51:26 +0000417 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000418 colorspace;
419
420 if (*option == '+')
421 break;
422 i++;
cristybb503372010-05-27 20:51:26 +0000423 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000424 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000425 colorspace=ParseCommandOption(MagickColorspaceOptions,
cristy3ed852e2009-09-05 21:47:34 +0000426 MagickFalse,argv[i]);
427 if (colorspace < 0)
428 ThrowIdentifyException(OptionError,"UnrecognizedColorspace",
429 argv[i]);
430 break;
431 }
432 if (LocaleCompare("crop",option+1) == 0)
433 {
434 if (*option == '+')
435 break;
436 i++;
cristybb503372010-05-27 20:51:26 +0000437 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000438 ThrowIdentifyException(OptionError,"MissingArgument",option);
439 if (IsGeometry(argv[i]) == MagickFalse)
440 ThrowIdentifyInvalidArgumentException(option,argv[i]);
441 image_info->ping=MagickFalse;
442 break;
443 }
cristy22879752009-10-25 23:55:40 +0000444 if (LocaleCompare("concurrent",option+1) == 0)
445 break;
cristy3ed852e2009-09-05 21:47:34 +0000446 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
447 }
448 case 'd':
449 {
450 if (LocaleCompare("debug",option+1) == 0)
451 {
cristybb503372010-05-27 20:51:26 +0000452 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000453 event;
454
455 if (*option == '+')
456 break;
457 i++;
cristybb503372010-05-27 20:51:26 +0000458 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000459 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000460 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000461 if (event < 0)
462 ThrowIdentifyException(OptionError,"UnrecognizedEventType",
463 argv[i]);
464 (void) SetLogEventMask(argv[i]);
465 break;
466 }
467 if (LocaleCompare("define",option+1) == 0)
468 {
469 i++;
cristybb503372010-05-27 20:51:26 +0000470 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000471 ThrowIdentifyException(OptionError,"MissingArgument",option);
472 if (*option == '+')
473 {
474 const char
475 *define;
476
477 define=GetImageOption(image_info,argv[i]);
478 if (define == (const char *) NULL)
479 ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]);
480 break;
481 }
482 break;
483 }
484 if (LocaleCompare("density",option+1) == 0)
485 {
486 if (*option == '+')
487 break;
488 i++;
cristybb503372010-05-27 20:51:26 +0000489 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000490 ThrowIdentifyException(OptionError,"MissingArgument",option);
491 if (IsGeometry(argv[i]) == MagickFalse)
492 ThrowIdentifyInvalidArgumentException(option,argv[i]);
493 break;
494 }
495 if (LocaleCompare("depth",option+1) == 0)
496 {
497 if (*option == '+')
498 break;
499 i++;
cristybb503372010-05-27 20:51:26 +0000500 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000501 ThrowIdentifyException(OptionError,"MissingArgument",option);
502 if (IsGeometry(argv[i]) == MagickFalse)
503 ThrowIdentifyInvalidArgumentException(option,argv[i]);
504 break;
505 }
cristy22879752009-10-25 23:55:40 +0000506 if (LocaleCompare("duration",option+1) == 0)
507 {
508 if (*option == '+')
509 break;
510 i++;
cristybb503372010-05-27 20:51:26 +0000511 if (i == (ssize_t) (argc-1))
cristy22879752009-10-25 23:55:40 +0000512 ThrowIdentifyException(OptionError,"MissingArgument",option);
513 if (IsGeometry(argv[i]) == MagickFalse)
514 ThrowIdentifyInvalidArgumentException(option,argv[i]);
515 break;
516 }
cristy3ed852e2009-09-05 21:47:34 +0000517 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
518 }
519 case 'f':
520 {
cristy549a37e2010-01-26 15:24:15 +0000521 if (LocaleCompare("features",option+1) == 0)
cristycd483f12010-01-26 15:30:08 +0000522 {
523 if (*option == '+')
524 break;
525 i++;
cristybb503372010-05-27 20:51:26 +0000526 if (i == (ssize_t) (argc-1))
cristycd483f12010-01-26 15:30:08 +0000527 ThrowIdentifyException(OptionError,"MissingArgument",option);
528 if (IsGeometry(argv[i]) == MagickFalse)
529 ThrowIdentifyInvalidArgumentException(option,argv[i]);
530 break;
531 }
cristy3ed852e2009-09-05 21:47:34 +0000532 if (LocaleCompare("format",option+1) == 0)
533 {
534 format=(char *) NULL;
535 if (*option == '+')
536 break;
537 i++;
cristybb503372010-05-27 20:51:26 +0000538 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000539 ThrowIdentifyException(OptionError,"MissingArgument",option);
540 format=argv[i];
541 break;
542 }
543 if (LocaleCompare("fuzz",option+1) == 0)
544 {
545 if (*option == '+')
546 break;
547 i++;
cristybb503372010-05-27 20:51:26 +0000548 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000549 ThrowIdentifyException(OptionError,"MissingArgument",option);
550 if (IsGeometry(argv[i]) == MagickFalse)
551 ThrowIdentifyInvalidArgumentException(option,argv[i]);
552 break;
553 }
554 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
555 }
556 case 'g':
557 {
558 if (LocaleCompare("gamma",option+1) == 0)
559 {
560 i++;
cristybb503372010-05-27 20:51:26 +0000561 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000562 ThrowIdentifyException(OptionError,"MissingArgument",option);
563 if (IsGeometry(argv[i]) == MagickFalse)
564 ThrowIdentifyInvalidArgumentException(option,argv[i]);
565 break;
566 }
567 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
568 }
569 case 'h':
570 {
571 if ((LocaleCompare("help",option+1) == 0) ||
572 (LocaleCompare("-help",option+1) == 0))
573 return(IdentifyUsage());
574 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
575 }
576 case 'i':
577 {
578 if (LocaleCompare("interlace",option+1) == 0)
579 {
cristybb503372010-05-27 20:51:26 +0000580 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000581 interlace;
582
583 if (*option == '+')
584 break;
585 i++;
cristybb503372010-05-27 20:51:26 +0000586 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000587 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000588 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000589 argv[i]);
590 if (interlace < 0)
591 ThrowIdentifyException(OptionError,
592 "UnrecognizedInterlaceType",argv[i]);
593 break;
594 }
595 if (LocaleCompare("interpolate",option+1) == 0)
596 {
cristybb503372010-05-27 20:51:26 +0000597 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000598 interpolate;
599
600 if (*option == '+')
601 break;
602 i++;
cristybb503372010-05-27 20:51:26 +0000603 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000604 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000605 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000606 argv[i]);
607 if (interpolate < 0)
608 ThrowIdentifyException(OptionError,
609 "UnrecognizedInterpolateMethod",argv[i]);
610 break;
611 }
612 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
613 }
614 case 'l':
615 {
616 if (LocaleCompare("limit",option+1) == 0)
617 {
618 char
619 *p;
620
621 double
622 value;
623
cristybb503372010-05-27 20:51:26 +0000624 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000625 resource;
626
627 if (*option == '+')
628 break;
629 i++;
cristybb503372010-05-27 20:51:26 +0000630 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000631 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000632 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000633 argv[i]);
634 if (resource < 0)
635 ThrowIdentifyException(OptionError,"UnrecognizedResourceType",
636 argv[i]);
637 i++;
cristybb503372010-05-27 20:51:26 +0000638 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000639 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristyb51dff52011-05-19 16:55:47 +0000640 value=LocaleToDouble(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +0000641 (void) value;
cristy3ed852e2009-09-05 21:47:34 +0000642 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
643 ThrowIdentifyInvalidArgumentException(option,argv[i]);
644 break;
645 }
646 if (LocaleCompare("list",option+1) == 0)
647 {
cristybb503372010-05-27 20:51:26 +0000648 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000649 list;
650
651 if (*option == '+')
652 break;
653 i++;
cristybb503372010-05-27 20:51:26 +0000654 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000655 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000656 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000657 if (list < 0)
658 ThrowIdentifyException(OptionError,"UnrecognizedListType",
659 argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +0000660 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +0000661 argv+j,exception);
662 DestroyIdentify();
cristyaeb2cbc2010-05-07 13:28:58 +0000663 return(status != 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +0000664 }
665 if (LocaleCompare("log",option+1) == 0)
666 {
667 if (*option == '+')
668 break;
669 i++;
cristybb503372010-05-27 20:51:26 +0000670 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +0000671 (strchr(argv[i],'%') == (char *) NULL))
672 ThrowIdentifyException(OptionError,"MissingArgument",option);
673 break;
674 }
675 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
676 }
677 case 'm':
678 {
679 if (LocaleCompare("matte",option+1) == 0)
680 break;
681 if (LocaleCompare("monitor",option+1) == 0)
682 break;
683 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
684 }
cristye48c6a92010-02-01 01:25:42 +0000685 case 'n':
686 {
687 if (LocaleCompare("negate",option+1) == 0)
688 break;
689 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
690 }
cristy3ed852e2009-09-05 21:47:34 +0000691 case 'p':
692 {
693 if (LocaleCompare("ping",option+1) == 0)
694 break;
695 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
696 }
697 case 'q':
698 {
699 if (LocaleCompare("quiet",option+1) == 0)
700 break;
701 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
702 }
703 case 'r':
704 {
705 if (LocaleCompare("regard-warnings",option+1) == 0)
706 break;
707 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
708 {
709 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
710 break;
711 }
712 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
713 }
714 case 's':
715 {
716 if (LocaleCompare("sampling-factor",option+1) == 0)
717 {
718 if (*option == '+')
719 break;
720 i++;
cristybb503372010-05-27 20:51:26 +0000721 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000722 ThrowIdentifyException(OptionError,"MissingArgument",option);
723 if (IsGeometry(argv[i]) == MagickFalse)
724 ThrowIdentifyInvalidArgumentException(option,argv[i]);
725 break;
726 }
727 if (LocaleCompare("seed",option+1) == 0)
728 {
729 if (*option == '+')
730 break;
731 i++;
cristybb503372010-05-27 20:51:26 +0000732 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000733 ThrowIdentifyException(OptionError,"MissingArgument",option);
734 if (IsGeometry(argv[i]) == MagickFalse)
735 ThrowIdentifyInvalidArgumentException(option,argv[i]);
736 break;
737 }
738 if (LocaleCompare("set",option+1) == 0)
739 {
740 i++;
cristybb503372010-05-27 20:51:26 +0000741 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000742 ThrowIdentifyException(OptionError,"MissingArgument",option);
743 if (*option == '+')
744 break;
745 i++;
cristybb503372010-05-27 20:51:26 +0000746 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000747 ThrowIdentifyException(OptionError,"MissingArgument",option);
748 break;
749 }
750 if (LocaleCompare("size",option+1) == 0)
751 {
752 if (*option == '+')
753 break;
754 i++;
cristybb503372010-05-27 20:51:26 +0000755 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000756 ThrowIdentifyException(OptionError,"MissingArgument",option);
757 if (IsGeometry(argv[i]) == MagickFalse)
758 ThrowIdentifyInvalidArgumentException(option,argv[i]);
759 break;
760 }
761 if (LocaleCompare("strip",option+1) == 0)
762 break;
763 if (LocaleCompare("support",option+1) == 0)
764 {
765 if (*option == '+')
766 break;
767 i++;
cristybb503372010-05-27 20:51:26 +0000768 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000769 ThrowIdentifyException(OptionError,"MissingArgument",option);
770 if (IsGeometry(argv[i]) == MagickFalse)
771 ThrowIdentifyInvalidArgumentException(option,argv[i]);
772 break;
773 }
774 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
775 }
776 case 'u':
777 {
cristy045bd902010-01-30 18:56:24 +0000778 if (LocaleCompare("unique",option+1) == 0)
779 break;
cristy3ed852e2009-09-05 21:47:34 +0000780 if (LocaleCompare("units",option+1) == 0)
781 {
cristybb503372010-05-27 20:51:26 +0000782 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000783 units;
784
785 if (*option == '+')
786 break;
787 i++;
cristybb503372010-05-27 20:51:26 +0000788 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000789 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000790 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000791 argv[i]);
792 if (units < 0)
793 ThrowIdentifyException(OptionError,"UnrecognizedUnitsType",
794 argv[i]);
795 break;
796 }
797 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
798 }
799 case 'v':
800 {
801 if (LocaleCompare("verbose",option+1) == 0)
802 break;
803 if (LocaleCompare("virtual-pixel",option+1) == 0)
804 {
cristybb503372010-05-27 20:51:26 +0000805 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000806 method;
807
808 if (*option == '+')
809 break;
810 i++;
cristybb503372010-05-27 20:51:26 +0000811 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000812 ThrowIdentifyException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000813 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000814 argv[i]);
815 if (method < 0)
816 ThrowIdentifyException(OptionError,
817 "UnrecognizedVirtualPixelMethod",argv[i]);
818 break;
819 }
820 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
821 }
822 case '?':
823 break;
824 default:
825 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
826 }
cristy042ee782011-04-22 18:48:30 +0000827 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
828 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +0000829 if (fire != MagickFalse)
830 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
831 }
832 if (k != 0)
833 ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]);
cristycee97112010-05-28 00:44:52 +0000834 if (i != (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000835 ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]);
836 DestroyIdentify();
837 return(status != 0 ? MagickTrue : MagickFalse);
838}