44#include "wand/studio.h"
45#include "wand/MagickWand.h"
46#include "wand/mogrify-private.h"
47#include "magick/display-private.h"
48#include "magick/string-private.h"
94static MagickBooleanType DisplayUsage(
void)
98 " 1 press to map or unmap the Command widget\n"
99 " 2 press and drag to magnify a region of an image\n"
100 " 3 press to load an image from a visual image directory",
102 " -debug events display copious debugging information\n"
103 " -help print program options\n"
104 " -list type print a list of supported option arguments\n"
105 " -log format format of debugging information\n"
106 " -version print version information",
108 " -auto-orient automagically orient image\n"
109 " -border geometry surround image with a border of color\n"
110 " -clip clip along the first path from the 8BIM profile\n"
111 " -clip-path id clip along a named path from the 8BIM profile\n"
112 " -colors value preferred number of colors in the image\n"
113 " -contrast enhance or reduce the image contrast\n"
114 " -crop geometry preferred size and location of the cropped image\n"
115 " -decipher filename convert cipher pixels to plain pixels\n"
116 " -deskew threshold straighten an image\n"
117 " -despeckle reduce the speckles within an image\n"
118 " -edge factor apply a filter to detect edges in the image\n"
119 " -enhance apply a digital filter to enhance a noisy image\n"
120 " -equalize perform histogram equalization to an image\n"
121 " -extract geometry extract area from image\n"
122 " -flip flip image in the vertical direction\n"
123 " -flop flop image in the horizontal direction\n"
124 " -frame geometry surround image with an ornamental border\n"
125 " -fuzz distance colors within this distance are considered equal\n"
126 " -gamma value level of gamma correction\n"
127 " -monochrome transform image to black and white\n"
128 " -negate replace every pixel with its complementary color\n"
129 " -normalize transform image to span the full range of colors\n"
130 " -raise value lighten/darken image edges to create a 3-D effect\n"
131 " -resample geometry change the resolution of an image\n"
132 " -resize geometry resize the image\n"
133 " -roll geometry roll an image vertically or horizontally\n"
134 " -rotate degrees apply Paeth rotation to the image\n"
135 " -sample geometry scale image with pixel sampling\n"
136 " -segment value segment an image\n"
137 " -sharpen geometry sharpen the image\n"
138 " -strip strip image of all profiles and comments\n"
139 " -threshold value threshold the image\n"
140 " -thumbnail geometry create a thumbnail of the image\n"
141 " -trim trim image edges",
143 " -alpha option on, activate, off, deactivate, set, opaque, copy\n"
144 " transparent, extract, background, or shape\n"
145 " -antialias remove pixel-aliasing\n"
146 " -authenticate password\n"
147 " decipher image with this password\n"
148 " -backdrop display image centered on a backdrop\n"
149 " -channel type apply option to select image channels\n"
150 " -colormap type Shared or Private\n"
151 " -colorspace type alternate image colorspace\n"
152 " -comment string annotate image with comment\n"
153 " -compress type type of pixel compression when writing the image\n"
154 " -define format:option\n"
155 " define one or more image format options\n"
156 " -delay value display the next image after pausing\n"
157 " -density geometry horizontal and vertical density of the image\n"
158 " -depth value image depth\n"
159 " -display server display image to this X server\n"
160 " -dispose method layer disposal method\n"
161 " -dither method apply error diffusion to image\n"
162 " -endian type endianness (MSB or LSB) of the image\n"
163 " -filter type use this filter when resizing an image\n"
164 " -format string output formatted image characteristics\n"
165 " -geometry geometry preferred size and location of the Image window\n"
166 " -gravity type horizontal and vertical backdrop placement\n"
167 " -identify identify the format and characteristics of the image\n"
168 " -immutable displayed image cannot be modified\n"
169 " -interlace type type of image interlacing scheme\n"
170 " -interpolate method pixel color interpolation method\n"
171 " -label string assign a label to an image\n"
172 " -limit type value pixel cache resource limit\n"
173 " -loop iterations loop images then exit\n"
174 " -map type display image using this Standard Colormap\n"
175 " -matte store matte channel if the image has one\n"
176 " -monitor monitor progress\n"
177 " -nostdin do not try to open stdin\n"
178 " -page geometry size and location of an image canvas\n"
179 " -profile filename add, delete, or apply an image profile\n"
180 " -quality value JPEG/MIFF/PNG compression level\n"
181 " -quantize colorspace reduce colors in this colorspace\n"
182 " -quiet suppress all warning messages\n"
183 " -regard-warnings pay attention to warning messages\n"
184 " -remote command execute a command in an remote display process\n"
185 " -repage geometry size and location of an image canvas (operator)\n"
186 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
187 " -sampling-factor geometry\n"
188 " horizontal and vertical sampling factor\n"
189 " -scenes range image scene range\n"
190 " -seed value seed a new sequence of pseudo-random numbers\n"
191 " -set property value set an image property\n"
192 " -size geometry width and height of image\n"
193 " -support factor resize support: > 1.0 is blurry, < 1.0 is sharp\n"
194 " -texture filename name of texture to tile onto the image background\n"
195 " -transparent-color color\n"
196 " transparent color\n"
197 " -treedepth value color tree depth\n"
198 " -update seconds detect when image file is modified and redisplay\n"
199 " -verbose print detailed information about the image\n"
200 " -visual type display image using this visual type\n"
201 " -virtual-pixel method\n"
202 " virtual pixel access method\n"
203 " -window id display image to background of this window\n"
204 " -window-group id exit program when this window id is destroyed\n"
205 " -write filename write image to a file",
206 sequence_operators[] =
207 " -coalesce merge a sequence of images\n"
208 " -flatten flatten a sequence of images";
210 ListMagickVersion(stdout);
211 (void) printf(
"Usage: %s [options ...] file [ [options ...] file ...]\n",
213 (void) printf(
"\nImage Settings:\n");
214 (void) puts(settings);
215 (void) printf(
"\nImage Operators:\n");
216 (void) puts(operators);
217 (void) printf(
"\nImage Sequence Operators:\n");
218 (void) puts(sequence_operators);
219 (void) printf(
"\nMiscellaneous Options:\n");
220 (void) puts(miscellaneous);
222 "\nIn addition to those listed above, you can specify these standard X\n");
224 "resources as command line options: -background, -bordercolor,\n");
226 "-borderwidth, -font, -foreground, -iconGeometry, -iconic, -mattecolor,\n");
227 (void) printf(
"-name, -shared-memory, -usePixmap, or -title.\n");
229 "\nBy default, the image format of `file' is determined by its magic\n");
231 "number. To specify a particular image format, precede the filename\n");
233 "with an image format name and a colon (i.e. ps:image) or specify the\n");
235 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
236 (void) printf(
"'-' for standard input or output.\n");
237 (void) printf(
"\nButtons: \n");
238 (void) puts(buttons);
242WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
243 int argc,
char **argv,
char **wand_unused(metadata),ExceptionInfo *exception)
245#if defined(MAGICKCORE_X11_DELEGATE)
246#define DestroyDisplay() \
248 if ((state & ExitState) == 0) \
249 DestroyXResources(); \
250 if (display != (Display *) NULL) \
252 XCloseDisplay(display); \
253 display=(Display *) NULL; \
255 XDestroyResourceInfo(&resource_info); \
256 DestroyImageStack(); \
257 if (image_marker != (size_t *) NULL) \
258 image_marker=(size_t *) RelinquishMagickMemory(image_marker); \
259 for (i=0; i < (ssize_t) argc; i++) \
260 argv[i]=DestroyString(argv[i]); \
261 argv=(char **) RelinquishMagickMemory(argv); \
263#define ThrowDisplayException(asperity,tag,option) \
265 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
268 return(MagickFalse); \
270#define ThrowDisplayInvalidArgumentException(option,argument) \
272 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
273 "InvalidArgument","`%s': %s",option,argument); \
275 return(MagickFalse); \
292 image_stack[MaxImageStackDepth+1];
328 wand_unreferenced(metadata);
333 assert(image_info != (ImageInfo *) NULL);
334 assert(image_info->signature == MagickCoreSignature);
335 assert(exception != (ExceptionInfo *) NULL);
336 if (IsEventLogging() != MagickFalse)
337 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
341 if ((LocaleCompare(
"version",option+1) == 0) ||
342 (LocaleCompare(
"-version",option+1) == 0))
344 ListMagickVersion(stdout);
349 display=(Display *) NULL;
352 image_marker=(
size_t *) NULL;
356 option=(
char *) NULL;
358 respect_parenthesis=MagickFalse;
360 resource_database=(XrmDatabase) NULL;
361 (void) memset(&resource_info,0,
sizeof(resource_info));
362 server_name=(
char *) NULL;
365 ReadCommandlLine(argc,&argv);
366 status=ExpandFilenames(&argc,&argv);
367 if (status == MagickFalse)
368 ThrowDisplayException(ResourceLimitError,
"MemoryAllocationFailed",
369 GetExceptionMessage(errno));
370 image_marker=(
size_t *) AcquireQuantumMemory((
size_t) argc+1UL,
371 sizeof(*image_marker));
372 if (image_marker == (
size_t *) NULL)
373 ThrowDisplayException(ResourceLimitError,
"MemoryAllocationFailed",
374 GetExceptionMessage(errno));
375 for (i=0; i <= (ssize_t) argc; i++)
376 image_marker[i]=(
size_t) argc;
380 for (i=1; i < (ssize_t) argc; i++)
386 if (IsCommandOption(option) == MagickFalse)
388 if (LocaleCompare(
"display",option+1) == 0)
394 if (i == (ssize_t) argc)
395 ThrowDisplayException(OptionError,
"MissingArgument",option);
398 if (LocaleCompare(
"nostdin",option+1) == 0)
400 if ((LocaleCompare(
"help",option+1) == 0) ||
401 (LocaleCompare(
"-help",option+1) == 0))
404 return(DisplayUsage());
410 display=XOpenDisplay(server_name);
411 if (display == (Display *) NULL)
412 ThrowDisplayException(XServerError,
"UnableToOpenXServer",
413 XDisplayName(server_name));
414 (void) XSetErrorHandler(XError);
415 resource_database=XGetResourceDatabase(display,GetClientName());
416 XGetResourceInfo(image_info,resource_database,GetClientName(),
418 quantize_info=resource_info.quantize_info;
419 image_info->density=XGetResourceInstance(resource_database,GetClientName(),
420 "density",(
char *) NULL);
421 if (image_info->density == (
char *) NULL)
422 image_info->density=XGetScreenDensity(display);
423 resource_value=XGetResourceInstance(resource_database,GetClientName(),
425 image_info->interlace=(InterlaceType)
426 ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value);
427 image_info->page=XGetResourceInstance(resource_database,GetClientName(),
428 "pageGeometry",(
char *) NULL);
429 resource_value=XGetResourceInstance(resource_database,GetClientName(),
431 image_info->quality=StringToUnsignedLong(resource_value);
432 resource_value=XGetResourceInstance(resource_database,GetClientName(),
434 image_info->verbose=IsMagickTrue(resource_value);
435 resource_value=XGetResourceInstance(resource_database,GetClientName(),
437 quantize_info->dither=IsMagickTrue(resource_value);
442 for (i=1; ((i <= (ssize_t) argc) && ((state & ExitState) == 0)); i++)
444 if (i < (ssize_t) argc)
447 if (image != (Image *) NULL)
450 if (isatty(STDIN_FILENO) != MagickFalse || (nostdin != MagickFalse))
454 if (LocaleCompare(option,
"(") == 0)
456 FireImageStack(MagickFalse,MagickTrue,pend);
457 if (k == MaxImageStackDepth)
458 ThrowDisplayException(OptionError,
"ParenthesisNestedTooDeeply",
463 if (LocaleCompare(option,
")") == 0)
465 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
467 ThrowDisplayException(OptionError,
"UnableToParseExpression",option);
471 if (IsCommandOption(option) == MagickFalse)
484 FireImageStack(MagickFalse,MagickFalse,pend);
486 if ((LocaleCompare(filename,
"--") == 0) && (i < (ssize_t) (argc-1)))
491 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
492 images=ReadImage(image_info,exception);
493 CatchException(exception);
494 status&=(images != (Image *) NULL) &&
495 (exception->severity < ErrorException);
496 if (images == (Image *) NULL)
498 AppendImageStack(images);
499 FinalizeImageSettings(image_info,image,MagickFalse);
500 iterations=image->iterations;
501 image_list=CloneImageList(image,exception);
502 if (image_list == (Image *) NULL)
503 ThrowDisplayException(ResourceLimitError,
"MemoryAllocationFailed",
504 GetExceptionMessage(errno));
505 display_image=image_list;
511 resource_info.quantum=1;
512 if (resource_info.window_id != (
char *) NULL)
517 status=XDisplayBackgroundImage(display,&resource_info,
519 if (status != MagickFalse)
521 state|=RetainColorsState;
524 if (GetNextImageInList(display_image) == (Image *) NULL)
536 if (resource_info.delay != 1)
537 display_image->delay=resource_info.delay;
538 nexus=XDisplayImage(display,&resource_info,argv,argc,
539 &display_image,&state);
540 if (nexus == (Image *) NULL)
542 while ((nexus != (Image *) NULL) && ((state & ExitState) == 0))
547 if (nexus->montage != (
char *) NULL)
555 next=XDisplayImage(display,&resource_info,argv,argc,&nexus,
557 if ((next == (Image *) NULL) &&
558 (GetNextImageInList(nexus) != (Image *) NULL))
560 display_image=GetNextImageInList(nexus);
561 nexus=NewImageList();
565 if (nexus != display_image)
566 nexus=DestroyImageList(nexus);
570 }
while ((state & ExitState) == 0);
571 if (resource_info.write_filename != (
char *) NULL)
576 (void) CopyMagickString(display_image->filename,
577 resource_info.write_filename,MaxTextExtent);
578 (void) SetImageInfo(image_info,1,&display_image->exception);
579 status&=WriteImage(image_info,display_image);
580 GetImageException(display_image,exception);
585 if ((state & FormerImageState) != 0)
586 for (l=0; l < (ssize_t) resource_info.quantum; l++)
588 if (GetPreviousImageInList(display_image) == (Image *) NULL)
590 display_image=GetPreviousImageInList(display_image);
593 for (l=0; l < (ssize_t) resource_info.quantum; l++)
595 if (GetNextImageInList(display_image) == (Image *) NULL)
597 display_image=GetNextImageInList(display_image);
599 if (l < (ssize_t) resource_info.quantum)
601 }
while ((display_image != (Image *) NULL) &&
602 ((state & ExitState) == 0));
606 display_image=DestroyImageList(display_image);
607 if ((state & FormerImageState) == 0)
609 last_image=(size_t) image_number;
610 image_marker[i]=(size_t) image_number++;
617 for (i--; i > 0; i--)
618 if (image_marker[i] == (
size_t) (image_number-2))
622 if ((i == (ssize_t) argc) && ((state & ExitState) == 0))
624 if ((state & ExitState) != 0)
629 if (image_number < 0)
631 if ((state & FormerImageState) != 0)
634 for (i=1; i < (ssize_t) (argc-2); i++)
635 if (last_image == image_marker[i])
637 image_number=(ssize_t) image_marker[i]+1;
641 if (resource_info.window_id != (
char *) NULL)
645 if (++iteration == (ssize_t) iterations)
649 if (LocaleCompare(filename,
"-") == 0)
651 RemoveAllImageStack();
654 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
659 if (LocaleCompare(
"alpha",option+1) == 0)
667 if (i == (ssize_t) argc)
668 ThrowDisplayException(OptionError,
"MissingArgument",option);
669 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
671 ThrowDisplayException(OptionError,
"UnrecognizedAlphaChannelType",
675 if (LocaleCompare(
"antialias",option+1) == 0)
677 if (LocaleCompare(
"authenticate",option+1) == 0)
682 if (i == (ssize_t) argc)
683 ThrowDisplayException(OptionError,
"MissingArgument",option);
686 if (LocaleCompare(
"auto-orient",option+1) == 0)
688 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
692 if (LocaleCompare(
"backdrop",option+1) == 0)
694 resource_info.backdrop=(*option ==
'-') ? MagickTrue : MagickFalse;
697 if (LocaleCompare(
"background",option+1) == 0)
702 if (i == (ssize_t) argc)
703 ThrowDisplayException(OptionError,
"MissingArgument",option);
704 resource_info.background_color=argv[i];
707 if (LocaleCompare(
"border",option+1) == 0)
712 if (i == (ssize_t) argc)
713 ThrowDisplayException(OptionError,
"MissingArgument",option);
714 if (IsGeometry(argv[i]) == MagickFalse)
715 ThrowDisplayInvalidArgumentException(option,argv[i]);
718 if (LocaleCompare(
"bordercolor",option+1) == 0)
723 if (i == (ssize_t) argc)
724 ThrowDisplayException(OptionError,
"MissingArgument",option);
725 resource_info.border_color=argv[i];
728 if (LocaleCompare(
"borderwidth",option+1) == 0)
730 resource_info.border_width=0;
734 if (i == (ssize_t) argc)
735 ThrowDisplayException(OptionError,
"MissingArgument",option);
736 if (IsGeometry(argv[i]) == MagickFalse)
737 ThrowDisplayInvalidArgumentException(option,argv[i]);
738 resource_info.border_width=(
unsigned int)
739 StringToUnsignedLong(argv[i]);
742 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
746 if (LocaleCompare(
"cache",option+1) == 0)
751 if (i == (ssize_t) argc)
752 ThrowDisplayException(OptionError,
"MissingArgument",option);
753 if (IsGeometry(argv[i]) == MagickFalse)
754 ThrowDisplayInvalidArgumentException(option,argv[i]);
757 if (LocaleCompare(
"channel",option+1) == 0)
765 if (i == (ssize_t) argc)
766 ThrowDisplayException(OptionError,
"MissingArgument",option);
767 channel=ParseChannelOption(argv[i]);
769 ThrowDisplayException(OptionError,
"UnrecognizedChannelType",
773 if (LocaleCompare(
"clip",option+1) == 0)
775 if (LocaleCompare(
"clip-path",option+1) == 0)
778 if (i == (ssize_t) argc)
779 ThrowDisplayException(OptionError,
"MissingArgument",option);
782 if (LocaleCompare(
"coalesce",option+1) == 0)
784 if (LocaleCompare(
"colormap",option+1) == 0)
786 resource_info.colormap=PrivateColormap;
790 if (i == (ssize_t) argc)
791 ThrowDisplayException(OptionError,
"MissingArgument",option);
792 resource_info.colormap=UndefinedColormap;
793 if (LocaleCompare(
"private",argv[i]) == 0)
794 resource_info.colormap=PrivateColormap;
795 if (LocaleCompare(
"shared",argv[i]) == 0)
796 resource_info.colormap=SharedColormap;
797 if (resource_info.colormap == UndefinedColormap)
798 ThrowDisplayException(OptionError,
"UnrecognizedColormapType",
802 if (LocaleCompare(
"colors",option+1) == 0)
804 quantize_info->number_colors=0;
808 if (i == (ssize_t) argc)
809 ThrowDisplayException(OptionError,
"MissingArgument",option);
810 if (IsGeometry(argv[i]) == MagickFalse)
811 ThrowDisplayInvalidArgumentException(option,argv[i]);
812 quantize_info->number_colors=StringToUnsignedLong(argv[i]);
815 if (LocaleCompare(
"colorspace",option+1) == 0)
823 if (i == (ssize_t) argc)
824 ThrowDisplayException(OptionError,
"MissingArgument",option);
825 colorspace=ParseCommandOption(MagickColorspaceOptions,
826 MagickFalse,argv[i]);
828 ThrowDisplayException(OptionError,
"UnrecognizedColorspace",
832 if (LocaleCompare(
"comment",option+1) == 0)
837 if (i == (ssize_t) argc)
838 ThrowDisplayException(OptionError,
"MissingArgument",option);
841 if (LocaleCompare(
"compress",option+1) == 0)
849 if (i == (ssize_t) argc)
850 ThrowDisplayException(OptionError,
"MissingArgument",option);
851 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
854 ThrowDisplayException(OptionError,
"UnrecognizedImageCompression",
858 if (LocaleCompare(
"concurrent",option+1) == 0)
860 if (LocaleCompare(
"contrast",option+1) == 0)
862 if (LocaleCompare(
"crop",option+1) == 0)
867 if (i == (ssize_t) argc)
868 ThrowDisplayException(OptionError,
"MissingArgument",option);
869 if (IsGeometry(argv[i]) == MagickFalse)
870 ThrowDisplayInvalidArgumentException(option,argv[i]);
873 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
877 if (LocaleCompare(
"debug",option+1) == 0)
885 if (i == (ssize_t) argc)
886 ThrowDisplayException(OptionError,
"MissingArgument",option);
887 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
889 ThrowDisplayException(OptionError,
"UnrecognizedEventType",
891 (void) SetLogEventMask(argv[i]);
894 if (LocaleCompare(
"decipher",option+1) == 0)
899 if (i == (ssize_t) argc)
900 ThrowDisplayException(OptionError,
"MissingArgument",option);
903 if (LocaleCompare(
"define",option+1) == 0)
906 if (i == (ssize_t) argc)
907 ThrowDisplayException(OptionError,
"MissingArgument",option);
913 define=GetImageOption(image_info,argv[i]);
914 if (define == (
const char *) NULL)
915 ThrowDisplayException(OptionError,
"NoSuchOption",argv[i]);
920 if (LocaleCompare(
"delay",option+1) == 0)
925 if (i == (ssize_t) argc)
926 ThrowDisplayException(OptionError,
"MissingArgument",option);
927 if (IsGeometry(argv[i]) == MagickFalse)
928 ThrowDisplayInvalidArgumentException(option,argv[i]);
931 if (LocaleCompare(
"density",option+1) == 0)
936 if (i == (ssize_t) argc)
937 ThrowDisplayException(OptionError,
"MissingArgument",option);
938 if (IsGeometry(argv[i]) == MagickFalse)
939 ThrowDisplayInvalidArgumentException(option,argv[i]);
942 if (LocaleCompare(
"depth",option+1) == 0)
947 if (i == (ssize_t) argc)
948 ThrowDisplayException(OptionError,
"MissingArgument",option);
949 if (IsGeometry(argv[i]) == MagickFalse)
950 ThrowDisplayInvalidArgumentException(option,argv[i]);
953 if (LocaleCompare(
"deskew",option+1) == 0)
958 if (i == (ssize_t) argc)
959 ThrowDisplayException(OptionError,
"MissingArgument",option);
960 if (IsGeometry(argv[i]) == MagickFalse)
961 ThrowDisplayInvalidArgumentException(option,argv[i]);
964 if (LocaleCompare(
"despeckle",option+1) == 0)
966 if (LocaleCompare(
"display",option+1) == 0)
971 if (i == (ssize_t) argc)
972 ThrowDisplayException(OptionError,
"MissingArgument",option);
975 if (LocaleCompare(
"dispose",option+1) == 0)
983 if (i == (ssize_t) argc)
984 ThrowDisplayException(OptionError,
"MissingArgument",option);
985 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
987 ThrowDisplayException(OptionError,
"UnrecognizedDisposeMethod",
991 if (LocaleCompare(
"dither",option+1) == 0)
996 quantize_info->dither=MagickFalse;
1000 if (i == (ssize_t) argc)
1001 ThrowDisplayException(OptionError,
"MissingArgument",option);
1002 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
1004 ThrowDisplayException(OptionError,
"UnrecognizedDitherMethod",
1006 quantize_info->dither=MagickTrue;
1007 quantize_info->dither_method=(DitherMethod) method;
1010 if (LocaleCompare(
"duration",option+1) == 0)
1015 if (i == (ssize_t) argc)
1016 ThrowDisplayException(OptionError,
"MissingArgument",option);
1017 if (IsGeometry(argv[i]) == MagickFalse)
1018 ThrowDisplayInvalidArgumentException(option,argv[i]);
1021 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1025 if (LocaleCompare(
"edge",option+1) == 0)
1030 if (i == (ssize_t) argc)
1031 ThrowDisplayException(OptionError,
"MissingArgument",option);
1032 if (IsGeometry(argv[i]) == MagickFalse)
1033 ThrowDisplayInvalidArgumentException(option,argv[i]);
1036 if (LocaleCompare(
"endian",option+1) == 0)
1044 if (i == (ssize_t) argc)
1045 ThrowDisplayException(OptionError,
"MissingArgument",option);
1046 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
1049 ThrowDisplayException(OptionError,
"UnrecognizedEndianType",
1053 if (LocaleCompare(
"enhance",option+1) == 0)
1055 if (LocaleCompare(
"equalize",option+1) == 0)
1057 if (LocaleCompare(
"extract",option+1) == 0)
1062 if (i == (ssize_t) argc)
1063 ThrowDisplayException(OptionError,
"MissingArgument",option);
1064 if (IsGeometry(argv[i]) == MagickFalse)
1065 ThrowDisplayInvalidArgumentException(option,argv[i]);
1068 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1072 if (LocaleCompare(
"filter",option+1) == 0)
1080 if (i == (ssize_t) argc)
1081 ThrowDisplayException(OptionError,
"MissingArgument",option);
1082 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
1084 ThrowDisplayException(OptionError,
"UnrecognizedImageFilter",
1088 if (LocaleCompare(
"flatten",option+1) == 0)
1090 if (LocaleCompare(
"flip",option+1) == 0)
1092 if (LocaleCompare(
"flop",option+1) == 0)
1094 if (LocaleCompare(
"font",option+1) == 0)
1099 if (i == (ssize_t) argc)
1100 ThrowDisplayException(OptionError,
"MissingArgument",option);
1101 resource_info.font=XGetResourceClass(resource_database,
1102 GetClientName(),
"font",argv[i]);
1105 if (LocaleCompare(
"foreground",option+1) == 0)
1110 if (i == (ssize_t) argc)
1111 ThrowDisplayException(OptionError,
"MissingArgument",option);
1112 resource_info.foreground_color=argv[i];
1115 if (LocaleCompare(
"format",option+1) == 0)
1120 if (i == (ssize_t) argc)
1121 ThrowDisplayException(OptionError,
"MissingArgument",option);
1124 if (LocaleCompare(
"frame",option+1) == 0)
1129 if (i == (ssize_t) argc)
1130 ThrowDisplayException(OptionError,
"MissingArgument",option);
1131 if (IsGeometry(argv[i]) == MagickFalse)
1132 ThrowDisplayInvalidArgumentException(option,argv[i]);
1135 if (LocaleCompare(
"fuzz",option+1) == 0)
1140 if (i == (ssize_t) argc)
1141 ThrowDisplayException(OptionError,
"MissingArgument",option);
1142 if (IsGeometry(argv[i]) == MagickFalse)
1143 ThrowDisplayInvalidArgumentException(option,argv[i]);
1146 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1150 if (LocaleCompare(
"gamma",option+1) == 0)
1153 if (i == (ssize_t) argc)
1154 ThrowDisplayException(OptionError,
"MissingArgument",option);
1155 if (IsGeometry(argv[i]) == MagickFalse)
1156 ThrowDisplayInvalidArgumentException(option,argv[i]);
1159 if (LocaleCompare(
"geometry",option+1) == 0)
1161 resource_info.image_geometry=(
char *) NULL;
1164 (void) CopyMagickString(argv[i]+1,
"sans",MaxTextExtent);
1166 if (i == (ssize_t) argc)
1167 ThrowDisplayException(OptionError,
"MissingArgument",option);
1168 if (IsGeometry(argv[i]) == MagickFalse)
1169 ThrowDisplayInvalidArgumentException(option,argv[i]);
1170 resource_info.image_geometry=ConstantString(argv[i]);
1173 if (LocaleCompare(
"gravity",option+1) == 0)
1181 if (i == (ssize_t) argc)
1182 ThrowDisplayException(OptionError,
"MissingArgument",option);
1183 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
1186 ThrowDisplayException(OptionError,
"UnrecognizedGravityType",
1190 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1194 if ((LocaleCompare(
"help",option+1) == 0) ||
1195 (LocaleCompare(
"-help",option+1) == 0))
1197 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1201 if (LocaleCompare(
"identify",option+1) == 0)
1203 if (LocaleCompare(
"iconGeometry",option+1) == 0)
1205 resource_info.icon_geometry=(
char *) NULL;
1209 if (i == (ssize_t) argc)
1210 ThrowDisplayException(OptionError,
"MissingArgument",option);
1211 if (IsGeometry(argv[i]) == MagickFalse)
1212 ThrowDisplayInvalidArgumentException(option,argv[i]);
1213 resource_info.icon_geometry=argv[i];
1216 if (LocaleCompare(
"iconic",option+1) == 0)
1218 resource_info.iconic=(*option ==
'-') ? MagickTrue : MagickFalse;
1221 if (LocaleCompare(
"immutable",option+1) == 0)
1223 resource_info.immutable=(*option ==
'-') ? MagickTrue : MagickFalse;
1226 if (LocaleCompare(
"interlace",option+1) == 0)
1234 if (i == (ssize_t) argc)
1235 ThrowDisplayException(OptionError,
"MissingArgument",option);
1236 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
1239 ThrowDisplayException(OptionError,
"UnrecognizedInterlaceType",
1243 if (LocaleCompare(
"interpolate",option+1) == 0)
1251 if (i == (ssize_t) argc)
1252 ThrowDisplayException(OptionError,
"MissingArgument",option);
1253 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
1255 if (interpolate < 0)
1256 ThrowDisplayException(OptionError,
"UnrecognizedInterpolateMethod",
1260 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1264 if (LocaleCompare(
"label",option+1) == 0)
1269 if (i == (ssize_t) argc)
1270 ThrowDisplayException(OptionError,
"MissingArgument",option);
1273 if (LocaleCompare(
"limit",option+1) == 0)
1287 if (i == (ssize_t) argc)
1288 ThrowDisplayException(OptionError,
"MissingArgument",option);
1289 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1292 ThrowDisplayException(OptionError,
"UnrecognizedResourceType",
1295 if (i == (ssize_t) argc)
1296 ThrowDisplayException(OptionError,
"MissingArgument",option);
1297 value=StringToDouble(argv[i],&p);
1299 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
1300 ThrowDisplayInvalidArgumentException(option,argv[i]);
1303 if (LocaleCompare(
"list",option+1) == 0)
1311 if (i == (ssize_t) argc)
1312 ThrowDisplayException(OptionError,
"MissingArgument",option);
1313 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1315 ThrowDisplayException(OptionError,
"UnrecognizedListType",argv[i]);
1316 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
1319 return(status == 0 ? MagickFalse : MagickTrue);
1321 if (LocaleCompare(
"log",option+1) == 0)
1326 if ((i == (ssize_t) argc) ||
1327 (strchr(argv[i],
'%') == (
char *) NULL))
1328 ThrowDisplayException(OptionError,
"MissingArgument",option);
1331 if (LocaleCompare(
"loop",option+1) == 0)
1336 if (i == (ssize_t) argc)
1337 ThrowDisplayException(OptionError,
"MissingArgument",option);
1338 if (IsGeometry(argv[i]) == MagickFalse)
1339 ThrowDisplayInvalidArgumentException(option,argv[i]);
1340 iterations=StringToUnsignedLong(argv[i]);
1343 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1347 if (LocaleCompare(
"magnify",option+1) == 0)
1349 resource_info.magnify=2;
1353 if (i == (ssize_t) argc)
1354 ThrowDisplayException(OptionError,
"MissingArgument",option);
1355 if (IsGeometry(argv[i]) == MagickFalse)
1356 ThrowDisplayInvalidArgumentException(option,argv[i]);
1357 resource_info.magnify=(
unsigned int) StringToUnsignedLong(argv[i]);
1360 if (LocaleCompare(
"map",option+1) == 0)
1362 resource_info.map_type=(
char *) NULL;
1365 (void) CopyMagickString(argv[i]+1,
"sans",strlen(argv[i]+1)+1);
1367 if (i == (ssize_t) argc)
1368 ThrowDisplayException(OptionError,
"MissingArgument",option);
1369 resource_info.map_type=argv[i];
1372 if (LocaleCompare(
"matte",option+1) == 0)
1374 if (LocaleCompare(
"mattecolor",option+1) == 0)
1379 if (i == (ssize_t) argc)
1380 ThrowDisplayException(OptionError,
"MissingArgument",option);
1381 resource_info.matte_color=argv[i];
1384 if (LocaleCompare(
"monitor",option+1) == 0)
1386 if (LocaleCompare(
"monochrome",option+1) == 0)
1390 quantize_info->number_colors=2;
1391 quantize_info->colorspace=GRAYColorspace;
1394 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1398 if (LocaleCompare(
"name",option+1) == 0)
1400 resource_info.name=(
char *) NULL;
1404 if (i == (ssize_t) argc)
1405 ThrowDisplayException(OptionError,
"MissingArgument",option);
1406 resource_info.name=ConstantString(argv[i]);
1409 if (LocaleCompare(
"negate",option+1) == 0)
1411 if (LocaleCompare(
"noop",option+1) == 0)
1413 if (LocaleCompare(
"normalize",option+1) == 0)
1415 if (LocaleCompare(
"nostdin",option+1) == 0)
1417 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1421 if (LocaleCompare(
"page",option+1) == 0)
1423 resource_info.image_geometry=(
char *) NULL;
1427 if (i == (ssize_t) argc)
1428 ThrowDisplayException(OptionError,
"MissingArgument",option);
1429 resource_info.image_geometry=ConstantString(argv[i]);
1432 if (LocaleCompare(
"profile",option+1) == 0)
1435 if (i == (ssize_t) argc)
1436 ThrowDisplayException(OptionError,
"MissingArgument",option);
1439 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1443 if (LocaleCompare(
"quality",option+1) == 0)
1448 if (i == (ssize_t) argc)
1449 ThrowDisplayException(OptionError,
"MissingArgument",option);
1450 if (IsGeometry(argv[i]) == MagickFalse)
1451 ThrowDisplayInvalidArgumentException(option,argv[i]);
1454 if (LocaleCompare(
"quantize",option+1) == 0)
1462 if (i == (ssize_t) argc)
1463 ThrowDisplayException(OptionError,
"MissingArgument",option);
1464 colorspace=ParseCommandOption(MagickColorspaceOptions,
1465 MagickFalse,argv[i]);
1467 ThrowDisplayException(OptionError,
"UnrecognizedColorspace",
1471 if (LocaleCompare(
"quiet",option+1) == 0)
1473 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1477 if (LocaleCompare(
"raise",option+1) == 0)
1480 if (i == (ssize_t) argc)
1481 ThrowDisplayException(OptionError,
"MissingArgument",option);
1482 if (IsGeometry(argv[i]) == MagickFalse)
1483 ThrowDisplayInvalidArgumentException(option,argv[i]);
1486 if (LocaleCompare(
"regard-warnings",option+1) == 0)
1488 if (LocaleCompare(
"remote",option+1) == 0)
1491 if (i == (ssize_t) argc)
1492 ThrowDisplayException(OptionError,
"MissingArgument",option);
1493 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1496 return(MagickFalse);
1501 if (LocaleCompare(
"repage",option+1) == 0)
1506 if (i == (ssize_t) argc)
1507 ThrowDisplayException(OptionError,
"MissingArgument",option);
1508 if (IsGeometry(argv[i]) == MagickFalse)
1509 ThrowDisplayInvalidArgumentException(option,argv[i]);
1512 if (LocaleCompare(
"resample",option+1) == 0)
1517 if (i == (ssize_t) argc)
1518 ThrowDisplayException(OptionError,
"MissingArgument",option);
1519 if (IsGeometry(argv[i]) == MagickFalse)
1520 ThrowDisplayInvalidArgumentException(option,argv[i]);
1523 if (LocaleCompare(
"resize",option+1) == 0)
1528 if (i == (ssize_t) argc)
1529 ThrowDisplayException(OptionError,
"MissingArgument",option);
1530 if (IsGeometry(argv[i]) == MagickFalse)
1531 ThrowDisplayInvalidArgumentException(option,argv[i]);
1534 if (LocaleNCompare(
"respect-parentheses",option+1,17) == 0)
1536 respect_parenthesis=(*option ==
'-') ? MagickTrue : MagickFalse;
1539 if (LocaleCompare(
"roll",option+1) == 0)
1544 if (i == (ssize_t) argc)
1545 ThrowDisplayException(OptionError,
"MissingArgument",option);
1546 if (IsGeometry(argv[i]) == MagickFalse)
1547 ThrowDisplayInvalidArgumentException(option,argv[i]);
1550 if (LocaleCompare(
"rotate",option+1) == 0)
1553 if (i == (ssize_t) argc)
1554 ThrowDisplayException(OptionError,
"MissingArgument",option);
1555 if (IsGeometry(argv[i]) == MagickFalse)
1556 ThrowDisplayInvalidArgumentException(option,argv[i]);
1559 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1563 if (LocaleCompare(
"sample",option+1) == 0)
1568 if (i == (ssize_t) argc)
1569 ThrowDisplayException(OptionError,
"MissingArgument",option);
1570 if (IsGeometry(argv[i]) == MagickFalse)
1571 ThrowDisplayInvalidArgumentException(option,argv[i]);
1574 if (LocaleCompare(
"sampling-factor",option+1) == 0)
1579 if (i == (ssize_t) argc)
1580 ThrowDisplayException(OptionError,
"MissingArgument",option);
1581 if (IsGeometry(argv[i]) == MagickFalse)
1582 ThrowDisplayInvalidArgumentException(option,argv[i]);
1585 if (LocaleCompare(
"scenes",option+1) == 0)
1590 if (i == (ssize_t) argc)
1591 ThrowDisplayException(OptionError,
"MissingArgument",option);
1592 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1593 ThrowDisplayInvalidArgumentException(option,argv[i]);
1596 if (LocaleCompare(
"seed",option+1) == 0)
1601 if (i == (ssize_t) argc)
1602 ThrowDisplayException(OptionError,
"MissingArgument",option);
1603 if (IsGeometry(argv[i]) == MagickFalse)
1604 ThrowDisplayInvalidArgumentException(option,argv[i]);
1607 if (LocaleCompare(
"segment",option+1) == 0)
1612 if (i == (ssize_t) argc)
1613 ThrowDisplayException(OptionError,
"MissingArgument",option);
1614 if (IsGeometry(argv[i]) == MagickFalse)
1615 ThrowDisplayInvalidArgumentException(option,argv[i]);
1618 if (LocaleCompare(
"set",option+1) == 0)
1621 if (i == (ssize_t) argc)
1622 ThrowDisplayException(OptionError,
"MissingArgument",option);
1626 if (i == (ssize_t) argc)
1627 ThrowDisplayException(OptionError,
"MissingArgument",option);
1630 if (LocaleCompare(
"sharpen",option+1) == 0)
1635 if (i == (ssize_t) argc)
1636 ThrowDisplayException(OptionError,
"MissingArgument",option);
1637 if (IsGeometry(argv[i]) == MagickFalse)
1638 ThrowDisplayInvalidArgumentException(option,argv[i]);
1641 if (LocaleCompare(
"shared-memory",option+1) == 0)
1643 resource_info.use_shared_memory= (*option ==
'-') ? MagickTrue :
1647 if (LocaleCompare(
"size",option+1) == 0)
1652 if (i == (ssize_t) argc)
1653 ThrowDisplayException(OptionError,
"MissingArgument",option);
1654 if (IsGeometry(argv[i]) == MagickFalse)
1655 ThrowDisplayInvalidArgumentException(option,argv[i]);
1658 if (LocaleCompare(
"strip",option+1) == 0)
1660 if (LocaleCompare(
"support",option+1) == 0)
1665 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1669 if (LocaleCompare(
"text-font",option+1) == 0)
1671 resource_info.text_font=(
char *) NULL;
1675 if (i == (ssize_t) argc)
1676 ThrowDisplayException(OptionError,
"MissingArgument",option);
1677 resource_info.text_font=XGetResourceClass(resource_database,
1678 GetClientName(),
"font",argv[i]);
1681 if (LocaleCompare(
"texture",option+1) == 0)
1686 if (i == (ssize_t) argc)
1687 ThrowDisplayException(OptionError,
"MissingArgument",option);
1690 if (LocaleCompare(
"threshold",option+1) == 0)
1695 if (i == (ssize_t) argc)
1696 ThrowDisplayException(OptionError,
"MissingArgument",option);
1697 if (IsGeometry(argv[i]) == MagickFalse)
1698 ThrowDisplayInvalidArgumentException(option,argv[i]);
1701 if (LocaleCompare(
"thumbnail",option+1) == 0)
1706 if (i == (ssize_t) argc)
1707 ThrowDisplayException(OptionError,
"MissingArgument",option);
1708 if (IsGeometry(argv[i]) == MagickFalse)
1709 ThrowDisplayInvalidArgumentException(option,argv[i]);
1712 if (LocaleCompare(
"title",option+1) == 0)
1714 resource_info.title=(
char *) NULL;
1718 if (i == (ssize_t) argc)
1719 ThrowDisplayException(OptionError,
"MissingArgument",option);
1720 resource_info.title=argv[i];
1723 if (LocaleCompare(
"transparent-color",option+1) == 0)
1728 if (i == (ssize_t) argc)
1729 ThrowDisplayException(OptionError,
"MissingArgument",option);
1732 if (LocaleCompare(
"treedepth",option+1) == 0)
1734 quantize_info->tree_depth=0;
1738 if (i == (ssize_t) argc)
1739 ThrowDisplayException(OptionError,
"MissingArgument",option);
1740 if (IsGeometry(argv[i]) == MagickFalse)
1741 ThrowDisplayInvalidArgumentException(option,argv[i]);
1742 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1745 if (LocaleCompare(
"trim",option+1) == 0)
1747 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1751 if (LocaleCompare(
"update",option+1) == 0)
1753 resource_info.update=(
unsigned int) (*option ==
'-');
1757 if (i == (ssize_t) argc)
1758 ThrowDisplayException(OptionError,
"MissingArgument",option);
1759 if (IsGeometry(argv[i]) == MagickFalse)
1760 ThrowDisplayInvalidArgumentException(option,argv[i]);
1761 resource_info.update=(
unsigned int) StringToUnsignedLong(argv[i]);
1764 if (LocaleCompare(
"use-pixmap",option+1) == 0)
1766 resource_info.use_pixmap=(*option ==
'-') ? MagickTrue :
1770 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1774 if (LocaleCompare(
"verbose",option+1) == 0)
1776 if ((LocaleCompare(
"version",option+1) == 0) ||
1777 (LocaleCompare(
"-version",option+1) == 0))
1779 ListMagickVersion(stdout);
1782 if (LocaleCompare(
"visual",option+1) == 0)
1784 resource_info.visual_type=(
char *) NULL;
1788 if (i == (ssize_t) argc)
1789 ThrowDisplayException(OptionError,
"MissingArgument",option);
1790 resource_info.visual_type=argv[i];
1793 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
1801 if (i == (ssize_t) argc)
1802 ThrowDisplayException(OptionError,
"MissingArgument",option);
1803 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1806 ThrowDisplayException(OptionError,
1807 "UnrecognizedVirtualPixelMethod",argv[i]);
1810 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1814 if (LocaleCompare(
"window",option+1) == 0)
1816 resource_info.window_id=(
char *) NULL;
1820 if (i == (ssize_t) argc)
1821 ThrowDisplayException(OptionError,
"MissingArgument",option);
1822 resource_info.window_id=argv[i];
1825 if (LocaleCompare(
"window-group",option+1) == 0)
1827 resource_info.window_group=(
char *) NULL;
1831 if (i == (ssize_t) argc)
1832 ThrowDisplayException(OptionError,
"MissingArgument",option);
1833 if (StringToDouble(argv[i],(
char **) NULL) != 0)
1834 resource_info.window_group=argv[i];
1837 if (LocaleCompare(
"write",option+1) == 0)
1839 resource_info.write_filename=(
char *) NULL;
1843 if (i == (ssize_t) argc)
1844 ThrowDisplayException(OptionError,
"MissingArgument",option);
1845 resource_info.write_filename=argv[i];
1846 if (IsPathAccessible(resource_info.write_filename) != MagickFalse)
1852 (void) FormatLocaleFile(stderr,
"Overwrite %s? ",
1853 resource_info.write_filename);
1854 p=fgets(answer,(
int)
sizeof(answer),stdin);
1856 if (((*answer !=
'y') && (*answer !=
'Y')))
1857 return(MagickFalse);
1861 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1866 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1868 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1869 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1870 if (fire != MagickFalse)
1871 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1874 ThrowDisplayException(OptionError,
"UnbalancedParenthesis",argv[i]);
1875 if (state & RetainColorsState)
1877 XRetainWindowColors(display,XRootWindow(display,XDefaultScreen(display)));
1878 (void) XSync(display,MagickFalse);
1881 return(status != 0 ? MagickTrue : MagickFalse);
1883 magick_unreferenced(argc);
1884 magick_unreferenced(argv);
1885 magick_unreferenced(metadata);
1887 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1888 "DelegateLibrarySupportNotBuiltIn",
"`%s' (X11)",image_info->filename);
1889 return(DisplayUsage());