blob: 31afcd6303e21aebe95c831511db203959e802d6 [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% %
cristy16af1cb2009-12-11 21:38:29 +000020% Copyright 1999-2010 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 },
107 *settings[]=
108 {
109 "-alpha option on, activate, off, deactivate, set, opaque, copy",
110 " transparent, extract, background, or shape",
111 "-antialias remove pixel-aliasing",
112 "-authenticate password",
113 " decipher image with this password",
114 "-channel type apply option to select image channels",
115 "-colorspace type alternate image colorspace",
116 "-crop geometry cut out a rectangular region of the image",
117 "-define format:option",
118 " define one or more image format options",
119 "-density geometry horizontal and vertical density of the image",
120 "-depth value image depth",
121 "-extract geometry extract area from image",
cristy02d5b4f2010-02-01 01:08:27 +0000122 "-features distance display image features (e.g. contrast, correlation)",
cristy3ed852e2009-09-05 21:47:34 +0000123 "-format \"string\" output formatted image characteristics",
124 "-fuzz distance colors within this distance are considered equal",
cristycd483f12010-01-26 15:30:08 +0000125 "-gamma value of gamma correction",
cristy3ed852e2009-09-05 21:47:34 +0000126 "-interlace type type of image interlacing scheme",
127 "-interpolate method pixel color interpolation method",
128 "-limit type value pixel cache resource limit",
129 "-monitor monitor progress",
130 "-ping efficiently determine image attributes",
131 "-quiet suppress all warning messages",
132 "-regard-warnings pay attention to warning messages",
133 "-respect-parentheses settings remain in effect until parenthesis boundary",
134 "-sampling-factor geometry",
135 " horizontal and vertical sampling factor",
136 "-seed value seed a new sequence of pseudo-random numbers",
137 "-set attribute value set an image attribute",
138 "-size geometry width and height of image",
139 "-strip strip image of all profiles and comments",
cristy045bd902010-01-30 18:56:24 +0000140 "-unique display the number of unique colors in the image",
cristy3ed852e2009-09-05 21:47:34 +0000141 "-units type the units of image resolution",
142 "-verbose print detailed information about the image",
143 "-virtual-pixel method",
144 " virtual pixel access method",
145 (char *) NULL
146 };
147
148 (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
cristy610b2e22009-10-22 14:59:43 +0000149 (void) printf("Copyright: %s\n",GetMagickCopyright());
150 (void) printf("Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +0000151 (void) printf("Usage: %s [options ...] file [ [options ...] "
152 "file ... ]\n",GetClientName());
153 (void) printf("\nImage Settings:\n");
154 for (p=settings; *p != (char *) NULL; p++)
155 (void) printf(" %s\n",*p);
156 (void) printf("\nMiscellaneous Options:\n");
157 for (p=miscellaneous; *p != (char *) NULL; p++)
158 (void) printf(" %s\n",*p);
159 (void) printf(
160 "\nBy default, the image format of `file' is determined by its magic\n");
161 (void) printf(
162 "number. To specify a particular image format, precede the filename\n");
163 (void) printf(
164 "with an image format name and a colon (i.e. ps:image) or specify the\n");
165 (void) printf(
166 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
167 (void) printf("'-' for standard input or output.\n");
168 return(MagickFalse);
169}
170
171WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
172 int argc,char **argv,char **metadata,ExceptionInfo *exception)
173{
174#define DestroyIdentify() \
175{ \
176 DestroyImageStack(); \
177 for (i=0; i < (long) argc; i++) \
178 argv[i]=DestroyString(argv[i]); \
179 argv=(char **) RelinquishMagickMemory(argv); \
180}
181#define ThrowIdentifyException(asperity,tag,option) \
182{ \
183 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
184 option); \
185 DestroyIdentify(); \
186 return(MagickFalse); \
187}
188#define ThrowIdentifyInvalidArgumentException(option,argument) \
189{ \
190 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
191 "InvalidArgument","`%s': %s",option,argument); \
192 DestroyIdentify(); \
193 return(MagickFalse); \
194}
195
196 const char
197 *format,
198 *option;
199
200 Image
201 *image;
202
203 ImageStack
204 image_stack[MaxImageStackDepth+1];
205
206 long
207 j,
208 k;
209
210 MagickBooleanType
211 fire,
212 pend;
213
214 MagickStatusType
215 status;
216
217 register long
218 i;
219
220 unsigned long
221 count;
222
223 /*
224 Set defaults.
225 */
226 assert(image_info != (ImageInfo *) NULL);
227 assert(image_info->signature == MagickSignature);
228 if (image_info->debug != MagickFalse)
229 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
230 assert(exception != (ExceptionInfo *) NULL);
231 if (argc == 2)
232 {
233 option=argv[1];
234 if ((LocaleCompare("version",option+1) == 0) ||
235 (LocaleCompare("-version",option+1) == 0))
236 {
237 (void) fprintf(stdout,"Version: %s\n",
238 GetMagickVersion((unsigned long *) NULL));
cristy3980b0d2009-10-25 14:37:13 +0000239 (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
cristy104cea82009-10-25 02:26:51 +0000240 (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +0000241 return(MagickFalse);
242 }
243 }
244 if (argc < 2)
245 {
246 (void) IdentifyUsage();
247 return(MagickTrue);
248 }
249 count=0;
250 format=NULL;
251 j=1;
252 k=0;
253 NewImageStack();
254 option=(char *) NULL;
255 pend=MagickFalse;
256 status=MagickTrue;
257 /*
258 Identify an image.
259 */
260 ReadCommandlLine(argc,&argv);
261 status=ExpandFilenames(&argc,&argv);
262 if (status == MagickFalse)
263 ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed",
264 GetExceptionMessage(errno));
265 image_info->ping=MagickTrue;
266 for (i=1; i < (long) argc; i++)
267 {
268 option=argv[i];
269 if (LocaleCompare(option,"(") == 0)
270 {
271 FireImageStack(MagickFalse,MagickTrue,pend);
272 if (k == MaxImageStackDepth)
273 ThrowIdentifyException(OptionError,"ParenthesisNestedTooDeeply",
274 option);
275 PushImageStack();
276 continue;
277 }
278 if (LocaleCompare(option,")") == 0)
279 {
280 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
281 if (k == 0)
282 ThrowIdentifyException(OptionError,"UnableToParseExpression",option);
283 PopImageStack();
284 continue;
285 }
286 if (IsMagickOption(option) == MagickFalse)
287 {
288 char
289 *filename;
290
291 Image
292 *images;
293
294 ImageInfo
295 *identify_info;
296
297 /*
298 Read input image.
299 */
300 FireImageStack(MagickFalse,MagickFalse,pend);
301 identify_info=CloneImageInfo(image_info);
302 identify_info->verbose=MagickFalse;
303 filename=argv[i];
304 if ((LocaleCompare(filename,"--") == 0) && (i < (argc-1)))
305 filename=argv[++i];
306 (void) CopyMagickString(identify_info->filename,filename,MaxTextExtent);
307 if (identify_info->ping != MagickFalse)
308 images=PingImages(identify_info,exception);
309 else
310 images=ReadImages(identify_info,exception);
311 identify_info=DestroyImageInfo(identify_info);
312 status&=(images != (Image *) NULL) &&
313 (exception->severity < ErrorException);
314 if (images == (Image *) NULL)
315 continue;
316 AppendImageStack(images);
317 FinalizeImageSettings(image_info,image,MagickFalse);
318 for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
319 {
320 if (image->scene == 0)
321 image->scene=count++;
322 if (format == (char *) NULL)
323 {
324 (void) IdentifyImage(image,stdout,image_info->verbose);
325 continue;
326 }
327 if (metadata != (char **) NULL)
328 {
329 char
330 *text;
331
332 text=InterpretImageProperties(image_info,image,format);
333 if (text == (char *) NULL)
334 ThrowIdentifyException(ResourceLimitError,
335 "MemoryAllocationFailed",GetExceptionMessage(errno));
336 (void) ConcatenateString(&(*metadata),text);
337 text=DestroyString(text);
338 if (LocaleCompare(format,"%n") == 0)
339 break;
340 }
341 }
342 RemoveAllImageStack();
343 continue;
344 }
345 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
346 switch (*(option+1))
347 {
348 case 'a':
349 {
350 if (LocaleCompare("alpha",option+1) == 0)
351 {
352 long
353 type;
354
355 if (*option == '+')
356 break;
357 i++;
358 if (i == (long) argc)
359 ThrowIdentifyException(OptionError,"MissingArgument",option);
360 type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
361 if (type < 0)
362 ThrowIdentifyException(OptionError,"UnrecognizedAlphaChannelType",
363 argv[i]);
364 break;
365 }
366 if (LocaleCompare("antialias",option+1) == 0)
367 break;
368 if (LocaleCompare("authenticate",option+1) == 0)
369 {
370 if (*option == '+')
371 break;
372 i++;
373 if (i == (long) (argc-1))
374 ThrowIdentifyException(OptionError,"MissingArgument",option);
375 break;
376 }
377 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
378 }
379 case 'c':
380 {
381 if (LocaleCompare("cache",option+1) == 0)
382 {
383 if (*option == '+')
384 break;
385 i++;
386 if (i == (long) argc)
387 ThrowIdentifyException(OptionError,"MissingArgument",option);
388 if (IsGeometry(argv[i]) == MagickFalse)
389 ThrowIdentifyInvalidArgumentException(option,argv[i]);
390 break;
391 }
392 if (LocaleCompare("channel",option+1) == 0)
393 {
394 long
395 channel;
396
397 if (*option == '+')
398 break;
399 i++;
400 if (i == (long) (argc-1))
401 ThrowIdentifyException(OptionError,"MissingArgument",option);
402 channel=ParseChannelOption(argv[i]);
403 if (channel < 0)
404 ThrowIdentifyException(OptionError,"UnrecognizedChannelType",
405 argv[i]);
406 break;
407 }
408 if (LocaleCompare("colorspace",option+1) == 0)
409 {
410 long
411 colorspace;
412
413 if (*option == '+')
414 break;
415 i++;
416 if (i == (long) (argc-1))
417 ThrowIdentifyException(OptionError,"MissingArgument",option);
418 colorspace=ParseMagickOption(MagickColorspaceOptions,
419 MagickFalse,argv[i]);
420 if (colorspace < 0)
421 ThrowIdentifyException(OptionError,"UnrecognizedColorspace",
422 argv[i]);
423 break;
424 }
425 if (LocaleCompare("crop",option+1) == 0)
426 {
427 if (*option == '+')
428 break;
429 i++;
430 if (i == (long) (argc-1))
431 ThrowIdentifyException(OptionError,"MissingArgument",option);
432 if (IsGeometry(argv[i]) == MagickFalse)
433 ThrowIdentifyInvalidArgumentException(option,argv[i]);
434 image_info->ping=MagickFalse;
435 break;
436 }
cristy22879752009-10-25 23:55:40 +0000437 if (LocaleCompare("concurrent",option+1) == 0)
438 break;
cristy3ed852e2009-09-05 21:47:34 +0000439 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
440 }
441 case 'd':
442 {
443 if (LocaleCompare("debug",option+1) == 0)
444 {
445 long
446 event;
447
448 if (*option == '+')
449 break;
450 i++;
451 if (i == (long) argc)
452 ThrowIdentifyException(OptionError,"MissingArgument",option);
453 event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
454 if (event < 0)
455 ThrowIdentifyException(OptionError,"UnrecognizedEventType",
456 argv[i]);
457 (void) SetLogEventMask(argv[i]);
458 break;
459 }
460 if (LocaleCompare("define",option+1) == 0)
461 {
462 i++;
463 if (i == (long) argc)
464 ThrowIdentifyException(OptionError,"MissingArgument",option);
465 if (*option == '+')
466 {
467 const char
468 *define;
469
470 define=GetImageOption(image_info,argv[i]);
471 if (define == (const char *) NULL)
472 ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]);
473 break;
474 }
475 break;
476 }
477 if (LocaleCompare("density",option+1) == 0)
478 {
479 if (*option == '+')
480 break;
481 i++;
482 if (i == (long) argc)
483 ThrowIdentifyException(OptionError,"MissingArgument",option);
484 if (IsGeometry(argv[i]) == MagickFalse)
485 ThrowIdentifyInvalidArgumentException(option,argv[i]);
486 break;
487 }
488 if (LocaleCompare("depth",option+1) == 0)
489 {
490 if (*option == '+')
491 break;
492 i++;
493 if (i == (long) argc)
494 ThrowIdentifyException(OptionError,"MissingArgument",option);
495 if (IsGeometry(argv[i]) == MagickFalse)
496 ThrowIdentifyInvalidArgumentException(option,argv[i]);
497 break;
498 }
cristy22879752009-10-25 23:55:40 +0000499 if (LocaleCompare("duration",option+1) == 0)
500 {
501 if (*option == '+')
502 break;
503 i++;
504 if (i == (long) (argc-1))
505 ThrowIdentifyException(OptionError,"MissingArgument",option);
506 if (IsGeometry(argv[i]) == MagickFalse)
507 ThrowIdentifyInvalidArgumentException(option,argv[i]);
508 break;
509 }
cristy3ed852e2009-09-05 21:47:34 +0000510 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
511 }
512 case 'f':
513 {
cristy549a37e2010-01-26 15:24:15 +0000514 if (LocaleCompare("features",option+1) == 0)
cristycd483f12010-01-26 15:30:08 +0000515 {
516 if (*option == '+')
517 break;
518 i++;
519 if (i == (long) (argc-1))
520 ThrowIdentifyException(OptionError,"MissingArgument",option);
521 if (IsGeometry(argv[i]) == MagickFalse)
522 ThrowIdentifyInvalidArgumentException(option,argv[i]);
523 break;
524 }
cristy3ed852e2009-09-05 21:47:34 +0000525 if (LocaleCompare("format",option+1) == 0)
526 {
527 format=(char *) NULL;
528 if (*option == '+')
529 break;
530 i++;
531 if (i == (long) argc)
532 ThrowIdentifyException(OptionError,"MissingArgument",option);
533 format=argv[i];
534 break;
535 }
536 if (LocaleCompare("fuzz",option+1) == 0)
537 {
538 if (*option == '+')
539 break;
540 i++;
541 if (i == (long) (argc-1))
542 ThrowIdentifyException(OptionError,"MissingArgument",option);
543 if (IsGeometry(argv[i]) == MagickFalse)
544 ThrowIdentifyInvalidArgumentException(option,argv[i]);
545 break;
546 }
547 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
548 }
549 case 'g':
550 {
551 if (LocaleCompare("gamma",option+1) == 0)
552 {
553 i++;
554 if (i == (long) (argc-1))
555 ThrowIdentifyException(OptionError,"MissingArgument",option);
556 if (IsGeometry(argv[i]) == MagickFalse)
557 ThrowIdentifyInvalidArgumentException(option,argv[i]);
558 break;
559 }
560 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
561 }
562 case 'h':
563 {
564 if ((LocaleCompare("help",option+1) == 0) ||
565 (LocaleCompare("-help",option+1) == 0))
566 return(IdentifyUsage());
567 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
568 }
569 case 'i':
570 {
571 if (LocaleCompare("interlace",option+1) == 0)
572 {
573 long
574 interlace;
575
576 if (*option == '+')
577 break;
578 i++;
579 if (i == (long) argc)
580 ThrowIdentifyException(OptionError,"MissingArgument",option);
581 interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
582 argv[i]);
583 if (interlace < 0)
584 ThrowIdentifyException(OptionError,
585 "UnrecognizedInterlaceType",argv[i]);
586 break;
587 }
588 if (LocaleCompare("interpolate",option+1) == 0)
589 {
590 long
591 interpolate;
592
593 if (*option == '+')
594 break;
595 i++;
596 if (i == (long) argc)
597 ThrowIdentifyException(OptionError,"MissingArgument",option);
598 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
599 argv[i]);
600 if (interpolate < 0)
601 ThrowIdentifyException(OptionError,
602 "UnrecognizedInterpolateMethod",argv[i]);
603 break;
604 }
605 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
606 }
607 case 'l':
608 {
609 if (LocaleCompare("limit",option+1) == 0)
610 {
611 char
612 *p;
613
614 double
615 value;
616
617 long
618 resource;
619
620 if (*option == '+')
621 break;
622 i++;
623 if (i == (long) argc)
624 ThrowIdentifyException(OptionError,"MissingArgument",option);
625 resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
626 argv[i]);
627 if (resource < 0)
628 ThrowIdentifyException(OptionError,"UnrecognizedResourceType",
629 argv[i]);
630 i++;
631 if (i == (long) argc)
632 ThrowIdentifyException(OptionError,"MissingArgument",option);
633 value=strtod(argv[i],&p);
634 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
635 ThrowIdentifyInvalidArgumentException(option,argv[i]);
636 break;
637 }
638 if (LocaleCompare("list",option+1) == 0)
639 {
640 long
641 list;
642
643 if (*option == '+')
644 break;
645 i++;
646 if (i == (long) argc)
647 ThrowIdentifyException(OptionError,"MissingArgument",option);
648 list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
649 if (list < 0)
650 ThrowIdentifyException(OptionError,"UnrecognizedListType",
651 argv[i]);
652 (void) MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
653 argv+j,exception);
654 DestroyIdentify();
655 return(MagickTrue);
656 }
657 if (LocaleCompare("log",option+1) == 0)
658 {
659 if (*option == '+')
660 break;
661 i++;
662 if ((i == (long) argc) ||
663 (strchr(argv[i],'%') == (char *) NULL))
664 ThrowIdentifyException(OptionError,"MissingArgument",option);
665 break;
666 }
667 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
668 }
669 case 'm':
670 {
671 if (LocaleCompare("matte",option+1) == 0)
672 break;
673 if (LocaleCompare("monitor",option+1) == 0)
674 break;
675 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
676 }
677 case 'p':
678 {
679 if (LocaleCompare("ping",option+1) == 0)
680 break;
681 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
682 }
683 case 'q':
684 {
685 if (LocaleCompare("quiet",option+1) == 0)
686 break;
687 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
688 }
689 case 'r':
690 {
691 if (LocaleCompare("regard-warnings",option+1) == 0)
692 break;
693 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
694 {
695 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
696 break;
697 }
698 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
699 }
700 case 's':
701 {
702 if (LocaleCompare("sampling-factor",option+1) == 0)
703 {
704 if (*option == '+')
705 break;
706 i++;
707 if (i == (long) argc)
708 ThrowIdentifyException(OptionError,"MissingArgument",option);
709 if (IsGeometry(argv[i]) == MagickFalse)
710 ThrowIdentifyInvalidArgumentException(option,argv[i]);
711 break;
712 }
713 if (LocaleCompare("seed",option+1) == 0)
714 {
715 if (*option == '+')
716 break;
717 i++;
718 if (i == (long) (argc-1))
719 ThrowIdentifyException(OptionError,"MissingArgument",option);
720 if (IsGeometry(argv[i]) == MagickFalse)
721 ThrowIdentifyInvalidArgumentException(option,argv[i]);
722 break;
723 }
724 if (LocaleCompare("set",option+1) == 0)
725 {
726 i++;
727 if (i == (long) argc)
728 ThrowIdentifyException(OptionError,"MissingArgument",option);
729 if (*option == '+')
730 break;
731 i++;
732 if (i == (long) argc)
733 ThrowIdentifyException(OptionError,"MissingArgument",option);
734 break;
735 }
736 if (LocaleCompare("size",option+1) == 0)
737 {
738 if (*option == '+')
739 break;
740 i++;
741 if (i == (long) argc)
742 ThrowIdentifyException(OptionError,"MissingArgument",option);
743 if (IsGeometry(argv[i]) == MagickFalse)
744 ThrowIdentifyInvalidArgumentException(option,argv[i]);
745 break;
746 }
747 if (LocaleCompare("strip",option+1) == 0)
748 break;
749 if (LocaleCompare("support",option+1) == 0)
750 {
751 if (*option == '+')
752 break;
753 i++;
754 if (i == (long) argc)
755 ThrowIdentifyException(OptionError,"MissingArgument",option);
756 if (IsGeometry(argv[i]) == MagickFalse)
757 ThrowIdentifyInvalidArgumentException(option,argv[i]);
758 break;
759 }
760 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
761 }
762 case 'u':
763 {
cristy045bd902010-01-30 18:56:24 +0000764 if (LocaleCompare("unique",option+1) == 0)
765 break;
cristy3ed852e2009-09-05 21:47:34 +0000766 if (LocaleCompare("units",option+1) == 0)
767 {
768 long
769 units;
770
771 if (*option == '+')
772 break;
773 i++;
774 if (i == (long) (argc-1))
775 ThrowIdentifyException(OptionError,"MissingArgument",option);
776 units=ParseMagickOption(MagickResolutionOptions,MagickFalse,
777 argv[i]);
778 if (units < 0)
779 ThrowIdentifyException(OptionError,"UnrecognizedUnitsType",
780 argv[i]);
781 break;
782 }
783 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
784 }
785 case 'v':
786 {
787 if (LocaleCompare("verbose",option+1) == 0)
788 break;
789 if (LocaleCompare("virtual-pixel",option+1) == 0)
790 {
791 long
792 method;
793
794 if (*option == '+')
795 break;
796 i++;
797 if (i == (long) (argc-1))
798 ThrowIdentifyException(OptionError,"MissingArgument",option);
799 method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
800 argv[i]);
801 if (method < 0)
802 ThrowIdentifyException(OptionError,
803 "UnrecognizedVirtualPixelMethod",argv[i]);
804 break;
805 }
806 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
807 }
808 case '?':
809 break;
810 default:
811 ThrowIdentifyException(OptionError,"UnrecognizedOption",option)
812 }
cristy6a917d92009-10-06 19:23:54 +0000813 fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ?
cristy3ed852e2009-09-05 21:47:34 +0000814 MagickFalse : MagickTrue;
815 if (fire != MagickFalse)
816 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
817 }
818 if (k != 0)
819 ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]);
820 if (i != argc)
821 ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]);
822 DestroyIdentify();
823 return(status != 0 ? MagickTrue : MagickFalse);
824}