53 #include "MagickCore/string-private.h"
97 " -debug events display copious debugging information\n"
98 " -help print program options\n"
99 " -list type print a list of supported option arguments\n"
100 " -log format format of debugging information\n"
101 " -version print version information",
103 " -channel mask set the image channel mask\n"
104 " -grayscale method convert image to grayscale\n"
105 " -negate replace every pixel with its complementary color",
107 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
108 " transparent, extract, background, or shape\n"
109 " -antialias remove pixel-aliasing\n"
110 " -authenticate password\n"
111 " decipher image with this password\n"
112 " -clip clip along the first path from the 8BIM profile\n"
113 " -clip-mask filename associate a clip mask with the image\n"
114 " -clip-path id clip along a named path from the 8BIM profile\n"
115 " -colorspace type alternate image colorspace\n"
116 " -crop geometry cut out a rectangular region of the image\n"
117 " -define format:option\n"
118 " define one or more image format options\n"
119 " -density geometry horizontal and vertical density of the image\n"
120 " -depth value image depth\n"
121 " -endian type endianness (MSB or LSB) of the image\n"
122 " -extract geometry extract area from image\n"
123 " -features distance analyze image features (e.g. contrast, correlation)\n"
124 " -format \"string\" output formatted image characteristics\n"
125 " -fuzz distance colors within this distance are considered equal\n"
126 " -gamma value of gamma correction\n"
127 " -interlace type type of image interlacing scheme\n"
128 " -interpolate method pixel color interpolation method\n"
129 " -limit type value pixel cache resource limit\n"
130 " -matte store matte channel if the image has one\n"
131 " -moments report image moments\n"
132 " -monitor monitor progress\n"
133 " -ping efficiently determine image attributes\n"
134 " -precision value maximum number of significant digits to print\n"
135 " -quiet suppress all warning messages\n"
136 " -read-mask filename associate a read mask with the image\n"
137 " -regard-warnings pay attention to warning messages\n"
138 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
139 " -sampling-factor geometry\n"
140 " horizontal and vertical sampling factor\n"
141 " -seed value seed a new sequence of pseudo-random numbers\n"
142 " -set attribute value set an image attribute\n"
143 " -size geometry width and height of image\n"
144 " -strip strip image of all profiles and comments\n"
145 " -unique display the number of unique colors in the image\n"
146 " -units type the units of image resolution\n"
147 " -verbose print detailed information about the image\n"
148 " -virtual-pixel method\n"
149 " virtual pixel access method";
151 ListMagickVersion(stdout);
152 (void) printf(
"Usage: %s [options ...] file [ [options ...] "
153 "file ... ]\n",GetClientName());
154 (void) printf(
"\nImage Settings:\n");
155 (void) puts(settings);
156 (void) printf(
"\nImage Operators:\n");
157 (void) puts(operators);
158 (void) printf(
"\nMiscellaneous Options:\n");
159 (void) puts(miscellaneous);
161 "\nBy default, the image format of 'file' is determined by its magic\n");
163 "number. To specify a particular image format, precede the filename\n");
165 "with an image format name and a colon (i.e. ps:image) or specify the\n");
167 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
168 (void) printf(
"'-' for standard input or output.\n");
173 int argc,
char **argv,
char **metadata,ExceptionInfo *
exception)
175 #define DestroyIdentify() \
177 DestroyImageStack(); \
178 for (i=0; i < (ssize_t) argc; i++) \
179 argv[i]=DestroyString(argv[i]); \
180 argv=(char **) RelinquishMagickMemory(argv); \
182 #define ThrowIdentifyException(asperity,tag,option) \
184 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
187 return(MagickFalse); \
189 #define ThrowIdentifyInvalidArgumentException(option,argument) \
191 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
192 "InvalidArgument","'%s': %s",option,argument); \
194 return(MagickFalse); \
228 assert(image_info != (ImageInfo *) NULL);
229 assert(image_info->signature == MagickCoreSignature);
230 if (image_info->debug != MagickFalse)
231 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
232 assert(exception != (ExceptionInfo *) NULL);
236 if ((LocaleCompare(
"version",option+1) == 0) ||
237 (LocaleCompare(
"-version",option+1) == 0))
239 ListMagickVersion(stdout);
250 option=(
char *) NULL;
252 respect_parenthesis=MagickFalse;
258 status=ExpandFilenames(&argc,&argv);
259 if (status == MagickFalse)
261 GetExceptionMessage(errno));
262 image_info->ping=MagickTrue;
263 for (i=1; i < (ssize_t) argc; i++)
266 if (LocaleCompare(option,
"(") == 0)
275 if (LocaleCompare(option,
")") == 0)
283 if (IsCommandOption(option) == MagickFalse)
298 identify_info=CloneImageInfo(image_info);
299 identify_info->verbose=MagickFalse;
301 if ((LocaleCompare(filename,
"--") == 0) && (i < (ssize_t) (argc-1)))
303 if (identify_info->ping != MagickFalse)
304 images=PingImages(identify_info,filename,exception);
306 images=ReadImages(identify_info,filename,exception);
307 identify_info=DestroyImageInfo(identify_info);
308 status&=(images != (Image *) NULL) &&
309 (exception->severity < ErrorException);
310 if (images == (Image *) NULL)
315 for ( ; image != (Image *) NULL; image=GetNextImageInList(image))
317 if (image->scene == 0)
318 image->scene=count++;
319 if (format == (
char *) NULL)
321 (void) IdentifyImage(image,stdout,image_info->verbose,exception);
324 if (metadata != (
char **) NULL)
329 text=InterpretImageProperties(image_info,image,format,exception);
330 if (text == (
char *) NULL)
332 "MemoryAllocationFailed",GetExceptionMessage(errno));
333 (void) ConcatenateString(&(*metadata),text);
334 text=DestroyString(text);
340 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
345 if (LocaleCompare(
"alpha",option+1) == 0)
353 if (i == (ssize_t) argc)
355 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
359 "UnrecognizedAlphaChannelOption",argv[i]);
362 if (LocaleCompare(
"antialias",option+1) == 0)
364 if (LocaleCompare(
"authenticate",option+1) == 0)
369 if (i == (ssize_t) argc)
377 if (LocaleCompare(
"cache",option+1) == 0)
382 if (i == (ssize_t) argc)
384 if (IsGeometry(argv[i]) == MagickFalse)
388 if (LocaleCompare(
"channel",option+1) == 0)
396 if (i == (ssize_t) argc)
398 channel=ParseChannelOption(argv[i]);
404 if (LocaleCompare(
"clip",option+1) == 0)
406 if (LocaleCompare(
"clip-mask",option+1) == 0)
411 if (i == (ssize_t) argc)
415 if (LocaleCompare(
"clip-path",option+1) == 0)
418 if (i == (ssize_t) argc)
422 if (LocaleCompare(
"colorspace",option+1) == 0)
430 if (i == (ssize_t) argc)
432 colorspace=ParseCommandOption(MagickColorspaceOptions,
433 MagickFalse,argv[i]);
439 if (LocaleCompare(
"crop",option+1) == 0)
444 if (i == (ssize_t) argc)
446 if (IsGeometry(argv[i]) == MagickFalse)
448 image_info->ping=MagickFalse;
451 if (LocaleCompare(
"concurrent",option+1) == 0)
457 if (LocaleCompare(
"debug",option+1) == 0)
465 if (i == (ssize_t) argc)
467 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
471 (void) SetLogEventMask(argv[i]);
474 if (LocaleCompare(
"define",option+1) == 0)
477 if (i == (ssize_t) argc)
484 define=GetImageOption(image_info,argv[i]);
485 if (define == (
const char *) NULL)
489 if (LocaleNCompare(
"identify:locate",argv[i],15) == 0)
490 image_info->ping=MagickFalse;
493 if (LocaleCompare(
"density",option+1) == 0)
498 if (i == (ssize_t) argc)
500 if (IsGeometry(argv[i]) == MagickFalse)
504 if (LocaleCompare(
"depth",option+1) == 0)
509 if (i == (ssize_t) argc)
511 if (IsGeometry(argv[i]) == MagickFalse)
515 if (LocaleCompare(
"duration",option+1) == 0)
520 if (i == (ssize_t) argc)
522 if (IsGeometry(argv[i]) == MagickFalse)
530 if (LocaleCompare(
"endian",option+1) == 0)
538 if (i == (ssize_t) argc)
540 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
551 if (LocaleCompare(
"features",option+1) == 0)
556 if (i == (ssize_t) argc)
558 if (IsGeometry(argv[i]) == MagickFalse)
562 if (LocaleCompare(
"format",option+1) == 0)
564 format=(
char *) NULL;
568 if (i == (ssize_t) argc)
573 if (LocaleCompare(
"fuzz",option+1) == 0)
578 if (i == (ssize_t) argc)
580 if (IsGeometry(argv[i]) == MagickFalse)
588 if (LocaleCompare(
"gamma",option+1) == 0)
591 if (i == (ssize_t) argc)
593 if (IsGeometry(argv[i]) == MagickFalse)
597 if (LocaleCompare(
"grayscale",option+1) == 0)
605 if (i == (ssize_t) argc)
607 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
614 if (LocaleCompare(
"green-primary",option+1) == 0)
619 if (i == (ssize_t) argc)
621 if (IsGeometry(argv[i]) == MagickFalse)
629 if ((LocaleCompare(
"help",option+1) == 0) ||
630 (LocaleCompare(
"-help",option+1) == 0))
636 if (LocaleCompare(
"interlace",option+1) == 0)
644 if (i == (ssize_t) argc)
646 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
650 "UnrecognizedInterlaceType",argv[i]);
653 if (LocaleCompare(
"interpolate",option+1) == 0)
661 if (i == (ssize_t) argc)
663 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
667 "UnrecognizedInterpolateMethod",argv[i]);
674 if (LocaleCompare(
"limit",option+1) == 0)
688 if (i == (ssize_t) argc)
690 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
696 if (i == (ssize_t) argc)
698 value=StringToDouble(argv[i],&p);
700 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
704 if (LocaleCompare(
"list",option+1) == 0)
712 if (i == (ssize_t) argc)
714 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
721 return(status == 0 ? MagickFalse : MagickTrue);
723 if (LocaleCompare(
"log",option+1) == 0)
728 if ((i == (ssize_t) argc) ||
729 (strchr(argv[i],
'%') == (
char *) NULL))
737 if (LocaleCompare(
"mask",option+1) == 0)
742 if (i == (ssize_t) argc)
746 if (LocaleCompare(
"matte",option+1) == 0)
748 if (LocaleCompare(
"moments",option+1) == 0)
750 if (LocaleCompare(
"monitor",option+1) == 0)
756 if (LocaleCompare(
"negate",option+1) == 0)
762 if (LocaleCompare(
"ping",option+1) == 0)
764 if (LocaleCompare(
"precision",option+1) == 0)
769 if (i == (ssize_t) argc)
771 if (IsGeometry(argv[i]) == MagickFalse)
779 if (LocaleCompare(
"quiet",option+1) == 0)
785 if (LocaleCompare(
"regard-warnings",option+1) == 0)
787 if (LocaleNCompare(
"respect-parentheses",option+1,17) == 0)
789 respect_parenthesis=(*option ==
'-') ? MagickTrue : MagickFalse;
796 if (LocaleCompare(
"sampling-factor",option+1) == 0)
801 if (i == (ssize_t) argc)
803 if (IsGeometry(argv[i]) == MagickFalse)
807 if (LocaleCompare(
"seed",option+1) == 0)
812 if (i == (ssize_t) argc)
814 if (IsGeometry(argv[i]) == MagickFalse)
818 if (LocaleCompare(
"set",option+1) == 0)
821 if (i == (ssize_t) argc)
826 if (i == (ssize_t) argc)
830 if (LocaleCompare(
"size",option+1) == 0)
835 if (i == (ssize_t) argc)
837 if (IsGeometry(argv[i]) == MagickFalse)
841 if (LocaleCompare(
"strip",option+1) == 0)
843 if (LocaleCompare(
"support",option+1) == 0)
848 if (i == (ssize_t) argc)
850 if (IsGeometry(argv[i]) == MagickFalse)
858 if (LocaleCompare(
"unique",option+1) == 0)
860 if (LocaleCompare(
"units",option+1) == 0)
868 if (i == (ssize_t) argc)
870 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,
881 if (LocaleCompare(
"verbose",option+1) == 0)
883 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
891 if (i == (ssize_t) argc)
893 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
897 "UnrecognizedVirtualPixelMethod",argv[i]);
907 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
908 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
909 if (fire != MagickFalse)
914 if (i != (ssize_t) argc)
917 return(status != 0 ? MagickTrue : MagickFalse);
#define FinalizeImageSettings(image_info, image, advance)
WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info, int argc, char **argv, char **metadata, ExceptionInfo *exception)
#define AppendImageStack(images)
#define RemoveAllImageStack()
WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, const int argc, const char **argv, ExceptionInfo *exception)
static MagickBooleanType IdentifyUsage(void)
#define ThrowIdentifyInvalidArgumentException(option, argument)
#define ReadCommandlLine(argc, argv)
#define ThrowIdentifyException(asperity, tag, option)
#define DestroyIdentify()
ExceptionInfo * exception
#define FireImageStack(postfix, advance, fire)
#define MaxImageStackDepth