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 char *message = GetExceptionMessage(errno); \
266 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag, \
267 "`%s'",option == (char *) NULL ? message : option); \
268 message=DestroyString(message); \
270 return(MagickFalse); \
272#define ThrowDisplayInvalidArgumentException(option,argument) \
274 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
275 "InvalidArgument","`%s': %s",option,argument); \
277 return(MagickFalse); \
294 image_stack[MaxImageStackDepth+1];
330 wand_unreferenced(metadata);
335 assert(image_info != (ImageInfo *) NULL);
336 assert(image_info->signature == MagickCoreSignature);
337 assert(exception != (ExceptionInfo *) NULL);
338 if (IsEventLogging() != MagickFalse)
339 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
343 if ((LocaleCompare(
"version",option+1) == 0) ||
344 (LocaleCompare(
"-version",option+1) == 0))
346 ListMagickVersion(stdout);
351 display=(Display *) NULL;
354 image_marker=(
size_t *) NULL;
358 option=(
char *) NULL;
360 respect_parenthesis=MagickFalse;
362 resource_database=(XrmDatabase) NULL;
363 (void) memset(&resource_info,0,
sizeof(resource_info));
364 server_name=(
char *) NULL;
367 ReadCommandlLine(argc,&argv);
368 status=ExpandFilenames(&argc,&argv);
369 if (status == MagickFalse)
370 ThrowDisplayException(ResourceLimitError,
"MemoryAllocationFailed",
372 image_marker=(
size_t *) AcquireQuantumMemory((
size_t) argc+1UL,
373 sizeof(*image_marker));
374 if (image_marker == (
size_t *) NULL)
375 ThrowDisplayException(ResourceLimitError,
"MemoryAllocationFailed",
377 for (i=0; i <= (ssize_t) argc; i++)
378 image_marker[i]=(
size_t) argc;
382 for (i=1; i < (ssize_t) argc; i++)
388 if (IsCommandOption(option) == MagickFalse)
390 if (LocaleCompare(
"display",option+1) == 0)
396 if (i == (ssize_t) argc)
397 ThrowDisplayException(OptionError,
"MissingArgument",option);
400 if (LocaleCompare(
"nostdin",option+1) == 0)
402 if ((LocaleCompare(
"help",option+1) == 0) ||
403 (LocaleCompare(
"-help",option+1) == 0))
406 return(DisplayUsage());
412 display=XOpenDisplay(server_name);
413 if (display == (Display *) NULL)
414 ThrowDisplayException(XServerError,
"UnableToOpenXServer",
415 XDisplayName(server_name));
416 (void) XSetErrorHandler(XError);
417 resource_database=XGetResourceDatabase(display,GetClientName());
418 XGetResourceInfo(image_info,resource_database,GetClientName(),
420 quantize_info=resource_info.quantize_info;
421 image_info->density=XGetResourceInstance(resource_database,GetClientName(),
422 "density",(
char *) NULL);
423 if (image_info->density == (
char *) NULL)
424 image_info->density=XGetScreenDensity(display);
425 resource_value=XGetResourceInstance(resource_database,GetClientName(),
427 image_info->interlace=(InterlaceType)
428 ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value);
429 image_info->page=XGetResourceInstance(resource_database,GetClientName(),
430 "pageGeometry",(
char *) NULL);
431 resource_value=XGetResourceInstance(resource_database,GetClientName(),
433 image_info->quality=StringToUnsignedLong(resource_value);
434 resource_value=XGetResourceInstance(resource_database,GetClientName(),
436 image_info->verbose=IsMagickTrue(resource_value);
437 resource_value=XGetResourceInstance(resource_database,GetClientName(),
439 quantize_info->dither=IsMagickTrue(resource_value);
444 for (i=1; ((i <= (ssize_t) argc) && ((state & ExitState) == 0)); i++)
446 if (i < (ssize_t) argc)
449 if (image != (Image *) NULL)
452 if (isatty(STDIN_FILENO) != MagickFalse || (nostdin != MagickFalse))
456 if (LocaleCompare(option,
"(") == 0)
458 FireImageStack(MagickFalse,MagickTrue,pend);
459 if (k == MaxImageStackDepth)
460 ThrowDisplayException(OptionError,
"ParenthesisNestedTooDeeply",
465 if (LocaleCompare(option,
")") == 0)
467 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
469 ThrowDisplayException(OptionError,
"UnableToParseExpression",option);
473 if (IsCommandOption(option) == MagickFalse)
486 FireImageStack(MagickFalse,MagickFalse,pend);
488 if ((LocaleCompare(filename,
"--") == 0) && (i < ((ssize_t) argc-1)))
493 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
494 images=ReadImage(image_info,exception);
495 CatchException(exception);
496 status&=(images != (Image *) NULL) &&
497 (exception->severity < ErrorException);
498 if (images == (Image *) NULL)
500 AppendImageStack(images);
501 FinalizeImageSettings(image_info,image,MagickFalse);
502 iterations=image->iterations;
503 image_list=CloneImageList(image,exception);
504 if (image_list == (Image *) NULL)
505 ThrowDisplayException(ResourceLimitError,
"MemoryAllocationFailed",
507 display_image=image_list;
513 resource_info.quantum=1;
514 if (resource_info.window_id != (
char *) NULL)
519 status=XDisplayBackgroundImage(display,&resource_info,
521 if (status != MagickFalse)
523 state|=RetainColorsState;
526 if (GetNextImageInList(display_image) == (Image *) NULL)
538 if (resource_info.delay != 1)
539 display_image->delay=resource_info.delay;
540 nexus=XDisplayImage(display,&resource_info,argv,argc,
541 &display_image,&state);
542 if (nexus == (Image *) NULL)
544 while ((nexus != (Image *) NULL) && ((state & ExitState) == 0))
549 if (nexus->montage != (
char *) NULL)
557 next=XDisplayImage(display,&resource_info,argv,argc,&nexus,
559 if ((next == (Image *) NULL) &&
560 (GetNextImageInList(nexus) != (Image *) NULL))
562 display_image=GetNextImageInList(nexus);
563 nexus=NewImageList();
567 if (nexus != display_image)
568 nexus=DestroyImageList(nexus);
572 }
while ((state & ExitState) == 0);
573 if (resource_info.write_filename != (
char *) NULL)
578 (void) CopyMagickString(display_image->filename,
579 resource_info.write_filename,MaxTextExtent);
580 (void) SetImageInfo(image_info,1,&display_image->exception);
581 status&=WriteImage(image_info,display_image);
582 GetImageException(display_image,exception);
587 if ((state & FormerImageState) != 0)
588 for (l=0; l < (ssize_t) resource_info.quantum; l++)
590 if (GetPreviousImageInList(display_image) == (Image *) NULL)
592 display_image=GetPreviousImageInList(display_image);
595 for (l=0; l < (ssize_t) resource_info.quantum; l++)
597 if (GetNextImageInList(display_image) == (Image *) NULL)
599 display_image=GetNextImageInList(display_image);
601 if (l < (ssize_t) resource_info.quantum)
603 }
while ((display_image != (Image *) NULL) &&
604 ((state & ExitState) == 0));
608 display_image=DestroyImageList(display_image);
609 if ((state & FormerImageState) == 0)
611 last_image=(size_t) image_number;
612 image_marker[i]=(size_t) image_number++;
619 for (i--; i > 0; i--)
620 if (image_marker[i] == (
size_t) (image_number-2))
624 if ((i == (ssize_t) argc) && ((state & ExitState) == 0))
626 if ((state & ExitState) != 0)
631 if (image_number < 0)
633 if ((state & FormerImageState) != 0)
636 for (i=1; i < ((ssize_t) argc-2); i++)
637 if (last_image == image_marker[i])
639 image_number=(ssize_t) image_marker[i]+1;
643 if (resource_info.window_id != (
char *) NULL)
647 if (++iteration == (ssize_t) iterations)
651 if (LocaleCompare(filename,
"-") == 0)
653 RemoveAllImageStack();
656 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
661 if (LocaleCompare(
"alpha",option+1) == 0)
669 if (i == (ssize_t) argc)
670 ThrowDisplayException(OptionError,
"MissingArgument",option);
671 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
673 ThrowDisplayException(OptionError,
"UnrecognizedAlphaChannelType",
677 if (LocaleCompare(
"antialias",option+1) == 0)
679 if (LocaleCompare(
"authenticate",option+1) == 0)
684 if (i == (ssize_t) argc)
685 ThrowDisplayException(OptionError,
"MissingArgument",option);
688 if (LocaleCompare(
"auto-orient",option+1) == 0)
690 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
694 if (LocaleCompare(
"backdrop",option+1) == 0)
696 resource_info.backdrop=(*option ==
'-') ? MagickTrue : MagickFalse;
699 if (LocaleCompare(
"background",option+1) == 0)
704 if (i == (ssize_t) argc)
705 ThrowDisplayException(OptionError,
"MissingArgument",option);
706 resource_info.background_color=argv[i];
709 if (LocaleCompare(
"border",option+1) == 0)
714 if (i == (ssize_t) argc)
715 ThrowDisplayException(OptionError,
"MissingArgument",option);
716 if (IsGeometry(argv[i]) == MagickFalse)
717 ThrowDisplayInvalidArgumentException(option,argv[i]);
720 if (LocaleCompare(
"bordercolor",option+1) == 0)
725 if (i == (ssize_t) argc)
726 ThrowDisplayException(OptionError,
"MissingArgument",option);
727 resource_info.border_color=argv[i];
730 if (LocaleCompare(
"borderwidth",option+1) == 0)
732 resource_info.border_width=0;
736 if (i == (ssize_t) argc)
737 ThrowDisplayException(OptionError,
"MissingArgument",option);
738 if (IsGeometry(argv[i]) == MagickFalse)
739 ThrowDisplayInvalidArgumentException(option,argv[i]);
740 resource_info.border_width=(
unsigned int)
741 StringToUnsignedLong(argv[i]);
744 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
748 if (LocaleCompare(
"cache",option+1) == 0)
753 if (i == (ssize_t) argc)
754 ThrowDisplayException(OptionError,
"MissingArgument",option);
755 if (IsGeometry(argv[i]) == MagickFalse)
756 ThrowDisplayInvalidArgumentException(option,argv[i]);
759 if (LocaleCompare(
"channel",option+1) == 0)
767 if (i == (ssize_t) argc)
768 ThrowDisplayException(OptionError,
"MissingArgument",option);
769 channel=ParseChannelOption(argv[i]);
771 ThrowDisplayException(OptionError,
"UnrecognizedChannelType",
775 if (LocaleCompare(
"clip",option+1) == 0)
777 if (LocaleCompare(
"clip-path",option+1) == 0)
780 if (i == (ssize_t) argc)
781 ThrowDisplayException(OptionError,
"MissingArgument",option);
784 if (LocaleCompare(
"coalesce",option+1) == 0)
786 if (LocaleCompare(
"colormap",option+1) == 0)
788 resource_info.colormap=PrivateColormap;
792 if (i == (ssize_t) argc)
793 ThrowDisplayException(OptionError,
"MissingArgument",option);
794 resource_info.colormap=UndefinedColormap;
795 if (LocaleCompare(
"private",argv[i]) == 0)
796 resource_info.colormap=PrivateColormap;
797 if (LocaleCompare(
"shared",argv[i]) == 0)
798 resource_info.colormap=SharedColormap;
799 if (resource_info.colormap == UndefinedColormap)
800 ThrowDisplayException(OptionError,
"UnrecognizedColormapType",
804 if (LocaleCompare(
"colors",option+1) == 0)
806 quantize_info->number_colors=0;
810 if (i == (ssize_t) argc)
811 ThrowDisplayException(OptionError,
"MissingArgument",option);
812 if (IsGeometry(argv[i]) == MagickFalse)
813 ThrowDisplayInvalidArgumentException(option,argv[i]);
814 quantize_info->number_colors=StringToUnsignedLong(argv[i]);
817 if (LocaleCompare(
"colorspace",option+1) == 0)
825 if (i == (ssize_t) argc)
826 ThrowDisplayException(OptionError,
"MissingArgument",option);
827 colorspace=ParseCommandOption(MagickColorspaceOptions,
828 MagickFalse,argv[i]);
830 ThrowDisplayException(OptionError,
"UnrecognizedColorspace",
834 if (LocaleCompare(
"comment",option+1) == 0)
839 if (i == (ssize_t) argc)
840 ThrowDisplayException(OptionError,
"MissingArgument",option);
843 if (LocaleCompare(
"compress",option+1) == 0)
851 if (i == (ssize_t) argc)
852 ThrowDisplayException(OptionError,
"MissingArgument",option);
853 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
856 ThrowDisplayException(OptionError,
"UnrecognizedImageCompression",
860 if (LocaleCompare(
"concurrent",option+1) == 0)
862 if (LocaleCompare(
"contrast",option+1) == 0)
864 if (LocaleCompare(
"crop",option+1) == 0)
869 if (i == (ssize_t) argc)
870 ThrowDisplayException(OptionError,
"MissingArgument",option);
871 if (IsGeometry(argv[i]) == MagickFalse)
872 ThrowDisplayInvalidArgumentException(option,argv[i]);
875 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
879 if (LocaleCompare(
"debug",option+1) == 0)
887 if (i == (ssize_t) argc)
888 ThrowDisplayException(OptionError,
"MissingArgument",option);
889 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
891 ThrowDisplayException(OptionError,
"UnrecognizedEventType",
893 (void) SetLogEventMask(argv[i]);
896 if (LocaleCompare(
"decipher",option+1) == 0)
901 if (i == (ssize_t) argc)
902 ThrowDisplayException(OptionError,
"MissingArgument",option);
905 if (LocaleCompare(
"define",option+1) == 0)
908 if (i == (ssize_t) argc)
909 ThrowDisplayException(OptionError,
"MissingArgument",option);
915 define=GetImageOption(image_info,argv[i]);
916 if (define == (
const char *) NULL)
917 ThrowDisplayException(OptionError,
"NoSuchOption",argv[i]);
922 if (LocaleCompare(
"delay",option+1) == 0)
927 if (i == (ssize_t) argc)
928 ThrowDisplayException(OptionError,
"MissingArgument",option);
929 if (IsGeometry(argv[i]) == MagickFalse)
930 ThrowDisplayInvalidArgumentException(option,argv[i]);
933 if (LocaleCompare(
"density",option+1) == 0)
938 if (i == (ssize_t) argc)
939 ThrowDisplayException(OptionError,
"MissingArgument",option);
940 if (IsGeometry(argv[i]) == MagickFalse)
941 ThrowDisplayInvalidArgumentException(option,argv[i]);
944 if (LocaleCompare(
"depth",option+1) == 0)
949 if (i == (ssize_t) argc)
950 ThrowDisplayException(OptionError,
"MissingArgument",option);
951 if (IsGeometry(argv[i]) == MagickFalse)
952 ThrowDisplayInvalidArgumentException(option,argv[i]);
955 if (LocaleCompare(
"deskew",option+1) == 0)
960 if (i == (ssize_t) argc)
961 ThrowDisplayException(OptionError,
"MissingArgument",option);
962 if (IsGeometry(argv[i]) == MagickFalse)
963 ThrowDisplayInvalidArgumentException(option,argv[i]);
966 if (LocaleCompare(
"despeckle",option+1) == 0)
968 if (LocaleCompare(
"display",option+1) == 0)
973 if (i == (ssize_t) argc)
974 ThrowDisplayException(OptionError,
"MissingArgument",option);
977 if (LocaleCompare(
"dispose",option+1) == 0)
985 if (i == (ssize_t) argc)
986 ThrowDisplayException(OptionError,
"MissingArgument",option);
987 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
989 ThrowDisplayException(OptionError,
"UnrecognizedDisposeMethod",
993 if (LocaleCompare(
"dither",option+1) == 0)
998 quantize_info->dither=MagickFalse;
1002 if (i == (ssize_t) argc)
1003 ThrowDisplayException(OptionError,
"MissingArgument",option);
1004 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
1006 ThrowDisplayException(OptionError,
"UnrecognizedDitherMethod",
1008 quantize_info->dither=MagickTrue;
1009 quantize_info->dither_method=(DitherMethod) method;
1012 if (LocaleCompare(
"duration",option+1) == 0)
1017 if (i == (ssize_t) argc)
1018 ThrowDisplayException(OptionError,
"MissingArgument",option);
1019 if (IsGeometry(argv[i]) == MagickFalse)
1020 ThrowDisplayInvalidArgumentException(option,argv[i]);
1023 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1027 if (LocaleCompare(
"edge",option+1) == 0)
1032 if (i == (ssize_t) argc)
1033 ThrowDisplayException(OptionError,
"MissingArgument",option);
1034 if (IsGeometry(argv[i]) == MagickFalse)
1035 ThrowDisplayInvalidArgumentException(option,argv[i]);
1038 if (LocaleCompare(
"endian",option+1) == 0)
1046 if (i == (ssize_t) argc)
1047 ThrowDisplayException(OptionError,
"MissingArgument",option);
1048 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
1051 ThrowDisplayException(OptionError,
"UnrecognizedEndianType",
1055 if (LocaleCompare(
"enhance",option+1) == 0)
1057 if (LocaleCompare(
"equalize",option+1) == 0)
1059 if (LocaleCompare(
"extract",option+1) == 0)
1064 if (i == (ssize_t) argc)
1065 ThrowDisplayException(OptionError,
"MissingArgument",option);
1066 if (IsGeometry(argv[i]) == MagickFalse)
1067 ThrowDisplayInvalidArgumentException(option,argv[i]);
1070 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1074 if (LocaleCompare(
"filter",option+1) == 0)
1082 if (i == (ssize_t) argc)
1083 ThrowDisplayException(OptionError,
"MissingArgument",option);
1084 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
1086 ThrowDisplayException(OptionError,
"UnrecognizedImageFilter",
1090 if (LocaleCompare(
"flatten",option+1) == 0)
1092 if (LocaleCompare(
"flip",option+1) == 0)
1094 if (LocaleCompare(
"flop",option+1) == 0)
1096 if (LocaleCompare(
"font",option+1) == 0)
1101 if (i == (ssize_t) argc)
1102 ThrowDisplayException(OptionError,
"MissingArgument",option);
1103 resource_info.font=XGetResourceClass(resource_database,
1104 GetClientName(),
"font",argv[i]);
1107 if (LocaleCompare(
"foreground",option+1) == 0)
1112 if (i == (ssize_t) argc)
1113 ThrowDisplayException(OptionError,
"MissingArgument",option);
1114 resource_info.foreground_color=argv[i];
1117 if (LocaleCompare(
"format",option+1) == 0)
1122 if (i == (ssize_t) argc)
1123 ThrowDisplayException(OptionError,
"MissingArgument",option);
1126 if (LocaleCompare(
"frame",option+1) == 0)
1131 if (i == (ssize_t) argc)
1132 ThrowDisplayException(OptionError,
"MissingArgument",option);
1133 if (IsGeometry(argv[i]) == MagickFalse)
1134 ThrowDisplayInvalidArgumentException(option,argv[i]);
1137 if (LocaleCompare(
"fuzz",option+1) == 0)
1142 if (i == (ssize_t) argc)
1143 ThrowDisplayException(OptionError,
"MissingArgument",option);
1144 if (IsGeometry(argv[i]) == MagickFalse)
1145 ThrowDisplayInvalidArgumentException(option,argv[i]);
1148 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1152 if (LocaleCompare(
"gamma",option+1) == 0)
1155 if (i == (ssize_t) argc)
1156 ThrowDisplayException(OptionError,
"MissingArgument",option);
1157 if (IsGeometry(argv[i]) == MagickFalse)
1158 ThrowDisplayInvalidArgumentException(option,argv[i]);
1161 if (LocaleCompare(
"geometry",option+1) == 0)
1163 resource_info.image_geometry=(
char *) NULL;
1166 (void) CopyMagickString(argv[i]+1,
"sans",MaxTextExtent);
1168 if (i == (ssize_t) argc)
1169 ThrowDisplayException(OptionError,
"MissingArgument",option);
1170 if (IsGeometry(argv[i]) == MagickFalse)
1171 ThrowDisplayInvalidArgumentException(option,argv[i]);
1172 resource_info.image_geometry=ConstantString(argv[i]);
1175 if (LocaleCompare(
"gravity",option+1) == 0)
1183 if (i == (ssize_t) argc)
1184 ThrowDisplayException(OptionError,
"MissingArgument",option);
1185 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
1188 ThrowDisplayException(OptionError,
"UnrecognizedGravityType",
1192 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1196 if ((LocaleCompare(
"help",option+1) == 0) ||
1197 (LocaleCompare(
"-help",option+1) == 0))
1199 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1203 if (LocaleCompare(
"identify",option+1) == 0)
1205 if (LocaleCompare(
"iconGeometry",option+1) == 0)
1207 resource_info.icon_geometry=(
char *) NULL;
1211 if (i == (ssize_t) argc)
1212 ThrowDisplayException(OptionError,
"MissingArgument",option);
1213 if (IsGeometry(argv[i]) == MagickFalse)
1214 ThrowDisplayInvalidArgumentException(option,argv[i]);
1215 resource_info.icon_geometry=argv[i];
1218 if (LocaleCompare(
"iconic",option+1) == 0)
1220 resource_info.iconic=(*option ==
'-') ? MagickTrue : MagickFalse;
1223 if (LocaleCompare(
"immutable",option+1) == 0)
1225 resource_info.immutable=(*option ==
'-') ? MagickTrue : MagickFalse;
1228 if (LocaleCompare(
"interlace",option+1) == 0)
1236 if (i == (ssize_t) argc)
1237 ThrowDisplayException(OptionError,
"MissingArgument",option);
1238 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
1241 ThrowDisplayException(OptionError,
"UnrecognizedInterlaceType",
1245 if (LocaleCompare(
"interpolate",option+1) == 0)
1253 if (i == (ssize_t) argc)
1254 ThrowDisplayException(OptionError,
"MissingArgument",option);
1255 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
1257 if (interpolate < 0)
1258 ThrowDisplayException(OptionError,
"UnrecognizedInterpolateMethod",
1262 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1266 if (LocaleCompare(
"label",option+1) == 0)
1271 if (i == (ssize_t) argc)
1272 ThrowDisplayException(OptionError,
"MissingArgument",option);
1275 if (LocaleCompare(
"limit",option+1) == 0)
1289 if (i == (ssize_t) argc)
1290 ThrowDisplayException(OptionError,
"MissingArgument",option);
1291 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1294 ThrowDisplayException(OptionError,
"UnrecognizedResourceType",
1297 if (i == (ssize_t) argc)
1298 ThrowDisplayException(OptionError,
"MissingArgument",option);
1299 value=StringToDouble(argv[i],&p);
1301 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
1302 ThrowDisplayInvalidArgumentException(option,argv[i]);
1305 if (LocaleCompare(
"list",option+1) == 0)
1313 if (i == (ssize_t) argc)
1314 ThrowDisplayException(OptionError,
"MissingArgument",option);
1315 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1317 ThrowDisplayException(OptionError,
"UnrecognizedListType",argv[i]);
1318 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
1321 return(status == 0 ? MagickFalse : MagickTrue);
1323 if (LocaleCompare(
"log",option+1) == 0)
1328 if ((i == (ssize_t) argc) ||
1329 (strchr(argv[i],
'%') == (
char *) NULL))
1330 ThrowDisplayException(OptionError,
"MissingArgument",option);
1333 if (LocaleCompare(
"loop",option+1) == 0)
1338 if (i == (ssize_t) argc)
1339 ThrowDisplayException(OptionError,
"MissingArgument",option);
1340 if (IsGeometry(argv[i]) == MagickFalse)
1341 ThrowDisplayInvalidArgumentException(option,argv[i]);
1342 iterations=StringToUnsignedLong(argv[i]);
1345 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1349 if (LocaleCompare(
"magnify",option+1) == 0)
1351 resource_info.magnify=2;
1355 if (i == (ssize_t) argc)
1356 ThrowDisplayException(OptionError,
"MissingArgument",option);
1357 if (IsGeometry(argv[i]) == MagickFalse)
1358 ThrowDisplayInvalidArgumentException(option,argv[i]);
1359 resource_info.magnify=(
unsigned int) StringToUnsignedLong(argv[i]);
1362 if (LocaleCompare(
"map",option+1) == 0)
1364 resource_info.map_type=(
char *) NULL;
1367 (void) CopyMagickString(argv[i]+1,
"sans",strlen(argv[i]+1)+1);
1369 if (i == (ssize_t) argc)
1370 ThrowDisplayException(OptionError,
"MissingArgument",option);
1371 resource_info.map_type=argv[i];
1374 if (LocaleCompare(
"matte",option+1) == 0)
1376 if (LocaleCompare(
"mattecolor",option+1) == 0)
1381 if (i == (ssize_t) argc)
1382 ThrowDisplayException(OptionError,
"MissingArgument",option);
1383 resource_info.matte_color=argv[i];
1386 if (LocaleCompare(
"monitor",option+1) == 0)
1388 if (LocaleCompare(
"monochrome",option+1) == 0)
1392 quantize_info->number_colors=2;
1393 quantize_info->colorspace=GRAYColorspace;
1396 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1400 if (LocaleCompare(
"name",option+1) == 0)
1402 resource_info.name=(
char *) NULL;
1406 if (i == (ssize_t) argc)
1407 ThrowDisplayException(OptionError,
"MissingArgument",option);
1408 resource_info.name=ConstantString(argv[i]);
1411 if (LocaleCompare(
"negate",option+1) == 0)
1413 if (LocaleCompare(
"noop",option+1) == 0)
1415 if (LocaleCompare(
"normalize",option+1) == 0)
1417 if (LocaleCompare(
"nostdin",option+1) == 0)
1419 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1423 if (LocaleCompare(
"page",option+1) == 0)
1425 resource_info.image_geometry=(
char *) NULL;
1429 if (i == (ssize_t) argc)
1430 ThrowDisplayException(OptionError,
"MissingArgument",option);
1431 resource_info.image_geometry=ConstantString(argv[i]);
1434 if (LocaleCompare(
"profile",option+1) == 0)
1437 if (i == (ssize_t) argc)
1438 ThrowDisplayException(OptionError,
"MissingArgument",option);
1441 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1445 if (LocaleCompare(
"quality",option+1) == 0)
1450 if (i == (ssize_t) argc)
1451 ThrowDisplayException(OptionError,
"MissingArgument",option);
1452 if (IsGeometry(argv[i]) == MagickFalse)
1453 ThrowDisplayInvalidArgumentException(option,argv[i]);
1456 if (LocaleCompare(
"quantize",option+1) == 0)
1464 if (i == (ssize_t) argc)
1465 ThrowDisplayException(OptionError,
"MissingArgument",option);
1466 colorspace=ParseCommandOption(MagickColorspaceOptions,
1467 MagickFalse,argv[i]);
1469 ThrowDisplayException(OptionError,
"UnrecognizedColorspace",
1473 if (LocaleCompare(
"quiet",option+1) == 0)
1475 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1479 if (LocaleCompare(
"raise",option+1) == 0)
1482 if (i == (ssize_t) argc)
1483 ThrowDisplayException(OptionError,
"MissingArgument",option);
1484 if (IsGeometry(argv[i]) == MagickFalse)
1485 ThrowDisplayInvalidArgumentException(option,argv[i]);
1488 if (LocaleCompare(
"regard-warnings",option+1) == 0)
1490 if (LocaleCompare(
"remote",option+1) == 0)
1493 if (i == (ssize_t) argc)
1494 ThrowDisplayException(OptionError,
"MissingArgument",option);
1495 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1498 return(MagickFalse);
1503 if (LocaleCompare(
"repage",option+1) == 0)
1508 if (i == (ssize_t) argc)
1509 ThrowDisplayException(OptionError,
"MissingArgument",option);
1510 if (IsGeometry(argv[i]) == MagickFalse)
1511 ThrowDisplayInvalidArgumentException(option,argv[i]);
1514 if (LocaleCompare(
"resample",option+1) == 0)
1519 if (i == (ssize_t) argc)
1520 ThrowDisplayException(OptionError,
"MissingArgument",option);
1521 if (IsGeometry(argv[i]) == MagickFalse)
1522 ThrowDisplayInvalidArgumentException(option,argv[i]);
1525 if (LocaleCompare(
"resize",option+1) == 0)
1530 if (i == (ssize_t) argc)
1531 ThrowDisplayException(OptionError,
"MissingArgument",option);
1532 if (IsGeometry(argv[i]) == MagickFalse)
1533 ThrowDisplayInvalidArgumentException(option,argv[i]);
1536 if (LocaleNCompare(
"respect-parentheses",option+1,17) == 0)
1538 respect_parenthesis=(*option ==
'-') ? MagickTrue : MagickFalse;
1541 if (LocaleCompare(
"roll",option+1) == 0)
1546 if (i == (ssize_t) argc)
1547 ThrowDisplayException(OptionError,
"MissingArgument",option);
1548 if (IsGeometry(argv[i]) == MagickFalse)
1549 ThrowDisplayInvalidArgumentException(option,argv[i]);
1552 if (LocaleCompare(
"rotate",option+1) == 0)
1555 if (i == (ssize_t) argc)
1556 ThrowDisplayException(OptionError,
"MissingArgument",option);
1557 if (IsGeometry(argv[i]) == MagickFalse)
1558 ThrowDisplayInvalidArgumentException(option,argv[i]);
1561 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1565 if (LocaleCompare(
"sample",option+1) == 0)
1570 if (i == (ssize_t) argc)
1571 ThrowDisplayException(OptionError,
"MissingArgument",option);
1572 if (IsGeometry(argv[i]) == MagickFalse)
1573 ThrowDisplayInvalidArgumentException(option,argv[i]);
1576 if (LocaleCompare(
"sampling-factor",option+1) == 0)
1581 if (i == (ssize_t) argc)
1582 ThrowDisplayException(OptionError,
"MissingArgument",option);
1583 if (IsGeometry(argv[i]) == MagickFalse)
1584 ThrowDisplayInvalidArgumentException(option,argv[i]);
1587 if (LocaleCompare(
"scenes",option+1) == 0)
1592 if (i == (ssize_t) argc)
1593 ThrowDisplayException(OptionError,
"MissingArgument",option);
1594 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1595 ThrowDisplayInvalidArgumentException(option,argv[i]);
1598 if (LocaleCompare(
"seed",option+1) == 0)
1603 if (i == (ssize_t) argc)
1604 ThrowDisplayException(OptionError,
"MissingArgument",option);
1605 if (IsGeometry(argv[i]) == MagickFalse)
1606 ThrowDisplayInvalidArgumentException(option,argv[i]);
1609 if (LocaleCompare(
"segment",option+1) == 0)
1614 if (i == (ssize_t) argc)
1615 ThrowDisplayException(OptionError,
"MissingArgument",option);
1616 if (IsGeometry(argv[i]) == MagickFalse)
1617 ThrowDisplayInvalidArgumentException(option,argv[i]);
1620 if (LocaleCompare(
"set",option+1) == 0)
1623 if (i == (ssize_t) argc)
1624 ThrowDisplayException(OptionError,
"MissingArgument",option);
1628 if (i == (ssize_t) argc)
1629 ThrowDisplayException(OptionError,
"MissingArgument",option);
1632 if (LocaleCompare(
"sharpen",option+1) == 0)
1637 if (i == (ssize_t) argc)
1638 ThrowDisplayException(OptionError,
"MissingArgument",option);
1639 if (IsGeometry(argv[i]) == MagickFalse)
1640 ThrowDisplayInvalidArgumentException(option,argv[i]);
1643 if (LocaleCompare(
"shared-memory",option+1) == 0)
1645 resource_info.use_shared_memory= (*option ==
'-') ? MagickTrue :
1649 if (LocaleCompare(
"size",option+1) == 0)
1654 if (i == (ssize_t) argc)
1655 ThrowDisplayException(OptionError,
"MissingArgument",option);
1656 if (IsGeometry(argv[i]) == MagickFalse)
1657 ThrowDisplayInvalidArgumentException(option,argv[i]);
1660 if (LocaleCompare(
"strip",option+1) == 0)
1662 if (LocaleCompare(
"support",option+1) == 0)
1667 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1671 if (LocaleCompare(
"text-font",option+1) == 0)
1673 resource_info.text_font=(
char *) NULL;
1677 if (i == (ssize_t) argc)
1678 ThrowDisplayException(OptionError,
"MissingArgument",option);
1679 resource_info.text_font=XGetResourceClass(resource_database,
1680 GetClientName(),
"font",argv[i]);
1683 if (LocaleCompare(
"texture",option+1) == 0)
1688 if (i == (ssize_t) argc)
1689 ThrowDisplayException(OptionError,
"MissingArgument",option);
1692 if (LocaleCompare(
"threshold",option+1) == 0)
1697 if (i == (ssize_t) argc)
1698 ThrowDisplayException(OptionError,
"MissingArgument",option);
1699 if (IsGeometry(argv[i]) == MagickFalse)
1700 ThrowDisplayInvalidArgumentException(option,argv[i]);
1703 if (LocaleCompare(
"thumbnail",option+1) == 0)
1708 if (i == (ssize_t) argc)
1709 ThrowDisplayException(OptionError,
"MissingArgument",option);
1710 if (IsGeometry(argv[i]) == MagickFalse)
1711 ThrowDisplayInvalidArgumentException(option,argv[i]);
1714 if (LocaleCompare(
"title",option+1) == 0)
1716 resource_info.title=(
char *) NULL;
1720 if (i == (ssize_t) argc)
1721 ThrowDisplayException(OptionError,
"MissingArgument",option);
1722 resource_info.title=argv[i];
1725 if (LocaleCompare(
"transparent-color",option+1) == 0)
1730 if (i == (ssize_t) argc)
1731 ThrowDisplayException(OptionError,
"MissingArgument",option);
1734 if (LocaleCompare(
"treedepth",option+1) == 0)
1736 quantize_info->tree_depth=0;
1740 if (i == (ssize_t) argc)
1741 ThrowDisplayException(OptionError,
"MissingArgument",option);
1742 if (IsGeometry(argv[i]) == MagickFalse)
1743 ThrowDisplayInvalidArgumentException(option,argv[i]);
1744 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1747 if (LocaleCompare(
"trim",option+1) == 0)
1749 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1753 if (LocaleCompare(
"update",option+1) == 0)
1755 resource_info.update=(
unsigned int) (*option ==
'-');
1759 if (i == (ssize_t) argc)
1760 ThrowDisplayException(OptionError,
"MissingArgument",option);
1761 if (IsGeometry(argv[i]) == MagickFalse)
1762 ThrowDisplayInvalidArgumentException(option,argv[i]);
1763 resource_info.update=(
unsigned int) StringToUnsignedLong(argv[i]);
1766 if (LocaleCompare(
"use-pixmap",option+1) == 0)
1768 resource_info.use_pixmap=(*option ==
'-') ? MagickTrue :
1772 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1776 if (LocaleCompare(
"verbose",option+1) == 0)
1778 if ((LocaleCompare(
"version",option+1) == 0) ||
1779 (LocaleCompare(
"-version",option+1) == 0))
1781 ListMagickVersion(stdout);
1784 if (LocaleCompare(
"visual",option+1) == 0)
1786 resource_info.visual_type=(
char *) NULL;
1790 if (i == (ssize_t) argc)
1791 ThrowDisplayException(OptionError,
"MissingArgument",option);
1792 resource_info.visual_type=argv[i];
1795 if (LocaleCompare(
"virtual-pixel",option+1) == 0)
1803 if (i == (ssize_t) argc)
1804 ThrowDisplayException(OptionError,
"MissingArgument",option);
1805 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1808 ThrowDisplayException(OptionError,
1809 "UnrecognizedVirtualPixelMethod",argv[i]);
1812 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1816 if (LocaleCompare(
"window",option+1) == 0)
1818 resource_info.window_id=(
char *) NULL;
1822 if (i == (ssize_t) argc)
1823 ThrowDisplayException(OptionError,
"MissingArgument",option);
1824 resource_info.window_id=argv[i];
1827 if (LocaleCompare(
"window-group",option+1) == 0)
1829 resource_info.window_group=(
char *) NULL;
1833 if (i == (ssize_t) argc)
1834 ThrowDisplayException(OptionError,
"MissingArgument",option);
1835 if (StringToDouble(argv[i],(
char **) NULL) != 0)
1836 resource_info.window_group=argv[i];
1839 if (LocaleCompare(
"write",option+1) == 0)
1841 resource_info.write_filename=(
char *) NULL;
1845 if (i == (ssize_t) argc)
1846 ThrowDisplayException(OptionError,
"MissingArgument",option);
1847 resource_info.write_filename=argv[i];
1848 if (IsPathAccessible(resource_info.write_filename) != MagickFalse)
1854 (void) FormatLocaleFile(stderr,
"Overwrite %s? ",
1855 resource_info.write_filename);
1856 p=fgets(answer,(
int)
sizeof(answer),stdin);
1858 if (((*answer !=
'y') && (*answer !=
'Y')))
1859 return(MagickFalse);
1863 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1868 ThrowDisplayException(OptionError,
"UnrecognizedOption",option);
1870 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1871 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1872 if (fire != MagickFalse)
1873 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1876 ThrowDisplayException(OptionError,
"UnbalancedParenthesis",argv[i]);
1877 if (state & RetainColorsState)
1879 XRetainWindowColors(display,XRootWindow(display,XDefaultScreen(display)));
1880 (void) XSync(display,MagickFalse);
1883 return(status != 0 ? MagickTrue : MagickFalse);
1885 magick_unreferenced(argc);
1886 magick_unreferenced(argv);
1887 magick_unreferenced(metadata);
1889 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1890 "DelegateLibrarySupportNotBuiltIn",
"`%s' (X11)",image_info->filename);
1891 return(DisplayUsage());