]> granicus.if.org Git - imagemagick/blob - MagickWand/display.c
...
[imagemagick] / MagickWand / display.c
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %                                                                             %
4 %                                                                             %
5 %                                                                             %
6 %               DDDD   IIIII  SSSSS  PPPP   L       AAA   Y   Y               %
7 %               D   D    I    SS     P   P  L      A   A   Y Y                %
8 %               D   D    I     SSS   PPPP   L      AAAAA    Y                 %
9 %               D   D    I       SS  P      L      A   A    Y                 %
10 %               DDDD   IIIII  SSSSS  P      LLLLL  A   A    Y                 %
11 %                                                                             %
12 %                                                                             %
13 %              Methods to Interactively Display and Edit an Image             %
14 %                                                                             %
15 %                             Software Design                                 %
16 %                                  Cristy                                     %
17 %                                July 1992                                    %
18 %                                                                             %
19 %                                                                             %
20 %  Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization      %
21 %  dedicated to making software imaging solutions freely available.           %
22 %                                                                             %
23 %  You may not use this file except in compliance with the License.  You may  %
24 %  obtain a copy of the License at                                            %
25 %                                                                             %
26 %    https://imagemagick.org/script/license.php                               %
27 %                                                                             %
28 %  Unless required by applicable law or agreed to in writing, software        %
29 %  distributed under the License is distributed on an "AS IS" BASIS,          %
30 %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
31 %  See the License for the specific language governing permissions and        %
32 %  limitations under the License.                                             %
33 %                                                                             %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 %
36 %  Use the display program to display an image or image sequence on any X
37 %  server.
38 %
39 */
40 \f
41 /*
42   Include declarations.
43 */
44 #include "MagickWand/studio.h"
45 #include "MagickWand/MagickWand.h"
46 #include "MagickWand/mogrify-private.h"
47 #include "MagickCore/display-private.h"
48 #include "MagickCore/string-private.h"
49 \f
50 /*
51 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52 %                                                                             %
53 %                                                                             %
54 %                                                                             %
55 +   D i s p l a y I m a g e C o m m a n d                                     %
56 %                                                                             %
57 %                                                                             %
58 %                                                                             %
59 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
60 %
61 %  DisplayImageCommand() displays a sequence of images on any workstation
62 %  display running an X server.  Display first determines the hardware
63 %  capabilities of the workstation. If the number of unique colors in an image
64 %  is less than or equal to the number the workstation can support, the image
65 %  is displayed in an X window. Otherwise the number of colors in the image is
66 %  first reduced to match the color resolution of the workstation before it is
67 %  displayed.
68 %
69 %  This means that a continuous-tone 24 bits/pixel image can display on a 8
70 %  bit pseudo-color device or monochrome device. In most instances the reduced
71 %  color image closely resembles the original. Alternatively, a monochrome or
72 %  pseudo-color image sequence can display on a continuous-tone 24 bits/pixels
73 %  device.
74 %
75 %  The format of the DisplayImageCommand method is:
76 %
77 %      MagickBooleanType DisplayImageCommand(ImageInfo *image_info,int argc,
78 %        char **argv,char **metadata,ExceptionInfo *exception)
79 %
80 %  A description of each parameter follows:
81 %
82 %    o image_info: the image info.
83 %
84 %    o argc: the number of elements in the argument vector.
85 %
86 %    o argv: A text array containing the command line arguments.
87 %
88 %    o metadata: any metadata is returned here.
89 %
90 %    o exception: return any errors or warnings in this structure.
91 %
92 */
93
94 static MagickBooleanType DisplayUsage(void)
95 {
96   const char
97     **p;
98
99   static const char
100     *buttons[]=
101     {
102       "1    press to map or unmap the Command widget",
103       "2    press and drag to magnify a region of an image",
104       "3    press to load an image from a visual image directory",
105       (char *) NULL
106     },
107     *miscellaneous[]=
108     {
109       "-debug events        display copious debugging information",
110       "-help                print program options",
111       "-list type           print a list of supported option arguments",
112       "-log format          format of debugging information",
113       "-version             print version information",
114       (char *) NULL
115     },
116     *operators[]=
117     {
118       "-auto-orient         automagically orient image",
119       "-border geometry     surround image with a border of color",
120       "-clip                clip along the first path from the 8BIM profile",
121       "-clip-path id        clip along a named path from the 8BIM profile",
122       "-colors value        preferred number of colors in the image",
123       "-contrast            enhance or reduce the image contrast",
124       "-crop geometry       preferred size and location of the cropped image",
125       "-decipher filename   convert cipher pixels to plain pixels",
126       "-deskew threshold    straighten an image",
127       "-despeckle           reduce the speckles within an image",
128       "-edge factor         apply a filter to detect edges in the image",
129       "-enhance             apply a digital filter to enhance a noisy image",
130       "-equalize            perform histogram equalization to an image",
131       "-extract geometry    extract area from image",
132       "-flip                flip image in the vertical direction",
133       "-flop                flop image in the horizontal direction",
134       "-frame geometry      surround image with an ornamental border",
135       "-fuzz distance       colors within this distance are considered equal",
136       "-gamma value         level of gamma correction",
137       "-monochrome          transform image to black and white",
138       "-negate              replace every pixel with its complementary color",
139       "-normalize           transform image to span the full range of colors",
140       "-raise value         lighten/darken image edges to create a 3-D effect",
141       "-resample geometry   change the resolution of an image",
142       "-resize geometry     resize the image",
143       "-roll geometry       roll an image vertically or horizontally",
144       "-rotate degrees      apply Paeth rotation to the image",
145       "-sample geometry     scale image with pixel sampling",
146       "-segment value       segment an image",
147       "-sharpen geometry    sharpen the image",
148       "-strip               strip image of all profiles and comments",
149       "-threshold value     threshold the image",
150       "-thumbnail geometry  create a thumbnail of the image",
151       "-trim                trim image edges",
152       (char *) NULL
153     },
154     *settings[]=
155     {
156       "-alpha option        on, activate, off, deactivate, set, opaque, copy",
157       "                     transparent, extract, background, or shape",
158       "-antialias           remove pixel-aliasing",
159       "-authenticate password",
160       "                     decipher image with this password",
161       "-backdrop            display image centered on a backdrop",
162       "-channel type        apply option to select image channels",
163       "-colormap type       Shared or Private",
164       "-colorspace type     alternate image colorspace",
165       "-comment string      annotate image with comment",
166       "-compress type       type of pixel compression when writing the image",
167       "-define format:option",
168       "                     define one or more image format options",
169       "-delay value         display the next image after pausing",
170       "-density geometry    horizontal and vertical density of the image",
171       "-depth value         image depth",
172       "-display server      display image to this X server",
173       "-dispose method      layer disposal method",
174       "-dither method       apply error diffusion to image",
175       "-endian type         endianness (MSB or LSB) of the image",
176       "-filter type         use this filter when resizing an image",
177       "-format string     output formatted image characteristics",
178       "-geometry geometry   preferred size and location of the Image window",
179       "-gravity type        horizontal and vertical backdrop placement",
180       "-identify            identify the format and characteristics of the image",
181       "-immutable           displayed image cannot be modified",
182       "-interlace type      type of image interlacing scheme",
183       "-interpolate method  pixel color interpolation method",
184       "-label string        assign a label to an image",
185       "-limit type value    pixel cache resource limit",
186       "-loop iterations     loop images then exit",
187       "-map type            display image using this Standard Colormap",
188       "-matte               store matte channel if the image has one",
189       "-monitor             monitor progress",
190       "-nostdin             do not try to open stdin",
191       "-page geometry       size and location of an image canvas",
192       "-profile filename    add, delete, or apply an image profile",
193       "-quality value       JPEG/MIFF/PNG compression level",
194       "-quantize colorspace reduce colors in this colorspace",
195       "-quiet               suppress all warning messages",
196       "-regard-warnings     pay attention to warning messages",
197       "-remote command      execute a command in an remote display process",
198       "-repage geometry     size and location of an image canvas (operator)",
199       "-respect-parentheses settings remain in effect until parenthesis boundary",
200       "-sampling-factor geometry",
201       "                     horizontal and vertical sampling factor",
202       "-scenes range        image scene range",
203       "-seed value          seed a new sequence of pseudo-random numbers",
204       "-set property value  set an image property",
205       "-size geometry       width and height of image",
206       "-support factor      resize support: > 1.0 is blurry, < 1.0 is sharp",
207       "-texture filename    name of texture to tile onto the image background",
208       "-transparent-color color",
209       "                     transparent color",
210       "-treedepth value     color tree depth",
211       "-update seconds      detect when image file is modified and redisplay",
212       "-verbose             print detailed information about the image",
213       "-visual type         display image using this visual type",
214       "-virtual-pixel method",
215       "                     virtual pixel access method",
216       "-window id           display image to background of this window",
217       "-window-group id     exit program when this window id is destroyed",
218       "-write filename      write image to a file",
219       (char *) NULL
220     },
221     *sequence_operators[]=
222     {
223       "-coalesce            merge a sequence of images",
224       "-flatten             flatten a sequence of images",
225       (char *) NULL
226     };
227
228   ListMagickVersion(stdout);
229   (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
230     GetClientName());
231   (void) printf("\nImage Settings:\n");
232   for (p=settings; *p != (char *) NULL; p++)
233     (void) printf("  %s\n",*p);
234   (void) printf("\nImage Operators:\n");
235   for (p=operators; *p != (char *) NULL; p++)
236     (void) printf("  %s\n",*p);
237   (void) printf("\nImage Sequence Operators:\n");
238   for (p=sequence_operators; *p != (char *) NULL; p++)
239     (void) printf("  %s\n",*p);
240   (void) printf("\nMiscellaneous Options:\n");
241   for (p=miscellaneous; *p != (char *) NULL; p++)
242     (void) printf("  %s\n",*p);
243   (void) printf(
244     "\nIn addition to those listed above, you can specify these standard X\n");
245   (void) printf(
246     "resources as command line options:  -background, -bordercolor,\n");
247   (void) printf(
248     " -mattecolor, -borderwidth, -font, -foreground, -iconGeometry,\n");
249   (void) printf("-iconic, -name, -shared-memory, -usePixmap, or -title.\n");
250   (void) printf(
251     "\nBy default, the image format of 'file' is determined by its magic\n");
252   (void) printf(
253     "number.  To specify a particular image format, precede the filename\n");
254   (void) printf(
255     "with an image format name and a colon (i.e. ps:image) or specify the\n");
256   (void) printf(
257     "image type as the filename suffix (i.e. image.ps).  Specify 'file' as\n");
258   (void) printf("'-' for standard input or output.\n");
259   (void) printf("\nButtons: \n");
260   for (p=buttons; *p != (char *) NULL; p++)
261     (void) printf("  %s\n",*p);
262   return(MagickFalse);
263 }
264
265 WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
266   int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
267 {
268 #if defined(MAGICKCORE_X11_DELEGATE)
269 #define DestroyDisplay() \
270 { \
271   if ((state & ExitState) == 0) \
272     DestroyXResources(); \
273   if (display != (Display *) NULL) \
274     { \
275       XCloseDisplay(display); \
276       display=(Display *) NULL; \
277     } \
278   XDestroyResourceInfo(&resource_info); \
279   DestroyImageStack(); \
280   if (image_marker != (size_t *) NULL) \
281     image_marker=(size_t *) RelinquishMagickMemory(image_marker); \
282   for (i=0; i < (ssize_t) argc; i++) \
283     argv[i]=DestroyString(argv[i]); \
284   argv=(char **) RelinquishMagickMemory(argv); \
285 }
286 #define ThrowDisplayException(asperity,tag,option) \
287 { \
288   (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
289     option); \
290   DestroyDisplay(); \
291   return(MagickFalse); \
292 }
293 #define ThrowDisplayInvalidArgumentException(option,argument) \
294 { \
295   (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
296     "InvalidArgument","'%s': %s",option,argument); \
297   DestroyDisplay(); \
298   return(MagickFalse); \
299 }
300
301   char
302     *resource_value,
303     *server_name;
304
305   const char
306     *option;
307
308   Display
309     *display;
310
311   Image
312     *image;
313
314   ImageStack
315     image_stack[MaxImageStackDepth+1];
316
317   MagickBooleanType
318     fire,
319     nostdin,
320     pend,
321     respect_parenthesis;
322
323   MagickStatusType
324     status;
325
326   QuantizeInfo
327     *quantize_info;
328
329   register ssize_t
330     i;
331
332   size_t
333     *image_marker,
334     iterations,
335     last_image,
336     state;
337
338   ssize_t
339     image_number,
340     iteration,
341     j,
342     k,
343     l;
344
345   XResourceInfo
346     resource_info;
347
348   XrmDatabase
349     resource_database;
350
351   /*
352     Set defaults.
353   */
354   assert(image_info != (ImageInfo *) NULL);
355   assert(image_info->signature == MagickCoreSignature);
356   if (image_info->debug != MagickFalse)
357     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
358   assert(exception != (ExceptionInfo *) NULL);
359   if (argc == 2)
360     {
361       option=argv[1];
362       if ((LocaleCompare("version",option+1) == 0) ||
363           (LocaleCompare("-version",option+1) == 0))
364         {
365           ListMagickVersion(stdout);
366           return(MagickTrue);
367         }
368     }
369   SetNotifyHandlers;
370   display=(Display *) NULL;
371   j=1;
372   k=0;
373   image_marker=(size_t *) NULL;
374   image_number=0;
375   last_image=0;
376   NewImageStack();
377   option=(char *) NULL;
378   pend=MagickFalse;
379   respect_parenthesis=MagickFalse;
380   nostdin=MagickFalse;
381   resource_database=(XrmDatabase) NULL;
382   (void) memset(&resource_info,0,sizeof(resource_info));
383   server_name=(char *) NULL;
384   state=0;
385   status=MagickTrue;
386   ReadCommandlLine(argc,&argv);
387   status=ExpandFilenames(&argc,&argv);
388   if (status == MagickFalse)
389     ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed",
390       GetExceptionMessage(errno));
391   image_marker=(size_t *) AcquireQuantumMemory((size_t) argc+1UL,
392     sizeof(*image_marker));
393   if (image_marker == (size_t *) NULL)
394     ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed",
395       GetExceptionMessage(errno));
396   for (i=0; i <= (ssize_t) argc; i++)
397     image_marker[i]=(size_t) argc;
398   /*
399     Check for server name specified on the command line.
400   */
401   for (i=1; i < (ssize_t) argc; i++)
402   {
403     /*
404       Check command line for server name.
405     */
406     option=argv[i];
407     if (IsCommandOption(option) == MagickFalse)
408       continue;
409     if (LocaleCompare("display",option+1) == 0)
410       {
411         /*
412           User specified server name.
413         */
414         i++;
415         if (i == (ssize_t) argc)
416           ThrowDisplayException(OptionError,"MissingArgument",option);
417         server_name=argv[i];
418       }
419     if (LocaleCompare("nostdin",option+1) == 0)
420       nostdin=MagickTrue;
421     if ((LocaleCompare("help",option+1) == 0) ||
422         (LocaleCompare("-help",option+1) == 0))
423       return(DisplayUsage());
424   }
425   /*
426     Get user defaults from X resource database.
427   */
428   display=XOpenDisplay(server_name);
429   if (display == (Display *) NULL)
430     ThrowDisplayException(XServerError,"UnableToOpenXServer",
431       XDisplayName(server_name));
432   (void) XSetErrorHandler(XError);
433   resource_database=XGetResourceDatabase(display,GetClientName());
434   XGetResourceInfo(image_info,resource_database,GetClientName(),
435     &resource_info);
436   quantize_info=resource_info.quantize_info;
437   image_info->density=XGetResourceInstance(resource_database,GetClientName(),
438     "density",(char *) NULL);
439   if (image_info->density == (char *) NULL)
440     image_info->density=XGetScreenDensity(display);
441   resource_value=XGetResourceInstance(resource_database,GetClientName(),
442     "interlace","none");
443   image_info->interlace=(InterlaceType)
444     ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value);
445   image_info->page=XGetResourceInstance(resource_database,GetClientName(),
446     "pageGeometry",(char *) NULL);
447   resource_value=XGetResourceInstance(resource_database,GetClientName(),
448     "quality","75");
449   image_info->quality=StringToUnsignedLong(resource_value);
450   resource_value=XGetResourceInstance(resource_database,GetClientName(),
451     "verbose","False");
452   image_info->verbose=IsStringTrue(resource_value);
453   resource_value=XGetResourceInstance(resource_database,GetClientName(),
454     "dither","True");
455   quantize_info->dither_method=IsStringTrue(resource_value) != MagickFalse ?
456     RiemersmaDitherMethod : NoDitherMethod;
457   /*
458     Parse command line.
459   */
460   iteration=0;
461   for (i=1; ((i <= (ssize_t) argc) && ((state & ExitState) == 0)); i++)
462   {
463     if (i < (ssize_t) argc)
464       option=argv[i];
465     else
466       if (image != (Image *) NULL)
467         break;
468       else
469         if (isatty(STDIN_FILENO) != MagickFalse || (nostdin != MagickFalse))
470           option="logo:";
471         else
472           option="-";
473     if (LocaleCompare(option,"(") == 0)
474       {
475         FireImageStack(MagickFalse,MagickTrue,pend);
476         if (k == MaxImageStackDepth)
477           ThrowDisplayException(OptionError,"ParenthesisNestedTooDeeply",
478             option);
479         PushImageStack();
480         continue;
481       }
482     if (LocaleCompare(option,")") == 0)
483       {
484         FireImageStack(MagickFalse,MagickTrue,MagickTrue);
485         if (k == 0)
486           ThrowDisplayException(OptionError,"UnableToParseExpression",option);
487         PopImageStack();
488         continue;
489       }
490     if (IsCommandOption(option) == MagickFalse)
491       {
492         const char
493           *filename;
494
495         Image
496           *display_image,
497           *image_list,
498           *images;
499
500         /*
501           Option is a file name.
502         */
503         FireImageStack(MagickFalse,MagickFalse,pend);
504         filename=option;
505         if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
506           {
507             option=argv[++i];
508             filename=option;
509           }
510         (void) CopyMagickString(image_info->filename,filename,MagickPathExtent);
511         images=ReadImage(image_info,exception);
512         CatchException(exception);
513         status&=(images != (Image *) NULL) &&
514           (exception->severity < ErrorException);
515         if (images == (Image *) NULL)
516           continue;
517         AppendImageStack(images);
518         FinalizeImageSettings(image_info,image,MagickFalse);
519         iterations=image->iterations;
520         image_list=CloneImageList(image,exception);
521         if (image_list == (Image *) NULL)
522           ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed",
523             GetExceptionMessage(errno));
524         display_image=image_list;
525         do
526         {
527           /*
528             Transmogrify image as defined by the image processing options.
529           */
530           resource_info.quantum=1;
531           if (resource_info.window_id != (char *) NULL)
532             {
533               /*
534                 Display image to a specified X window.
535               */
536               status=XDisplayBackgroundImage(display,&resource_info,
537                 display_image,exception);
538               if (status != MagickFalse)
539                 {
540                   state|=RetainColorsState;
541                   status=MagickFalse;
542                 }
543               if (GetNextImageInList(display_image) == (Image *) NULL)
544                 state|=ExitState;
545             }
546           else
547             do
548             {
549               Image
550                 *nexus;
551
552               /*
553                 Display image to X server.
554               */
555               if (resource_info.delay != 1)
556                 display_image->delay=resource_info.delay;
557               nexus=XDisplayImage(display,&resource_info,argv,argc,
558                 &display_image,&state,exception);
559               if (nexus == (Image *) NULL)
560                 break;
561               while ((nexus != (Image *) NULL) && ((state & ExitState) == 0))
562               {
563                 Image
564                   *next;
565
566                 if (nexus->montage != (char *) NULL)
567                   {
568                     /*
569                       User selected a visual directory image (montage).
570                     */
571                     display_image=nexus;
572                     break;
573                   }
574                 next=XDisplayImage(display,&resource_info,argv,argc,&nexus,
575                   &state,exception);
576                 if ((next == (Image *) NULL) &&
577                     (GetNextImageInList(nexus) != (Image *) NULL))
578                   {
579                     display_image=GetNextImageInList(nexus);
580                     nexus=NewImageList();
581                   }
582                 else
583                   {
584                     if (nexus != display_image)
585                       nexus=DestroyImageList(nexus);
586                     nexus=next;
587                   }
588               }
589             } while ((state & ExitState) == 0);
590           if (resource_info.write_filename != (char *) NULL)
591             {
592               /*
593                 Write image.
594               */
595               (void) CopyMagickString(display_image->filename,
596                 resource_info.write_filename,MagickPathExtent);
597               (void) SetImageInfo(image_info,1,exception);
598               status&=WriteImage(image_info,display_image,exception);
599             }
600           /*
601             Proceed to next/previous image.
602           */
603           if ((state & FormerImageState) != 0)
604             for (l=0; l < (ssize_t) resource_info.quantum; l++)
605             {
606               if (GetPreviousImageInList(display_image) == (Image *) NULL)
607                 break;
608               display_image=GetPreviousImageInList(display_image);
609             }
610           else
611             for (l=0; l < (ssize_t) resource_info.quantum; l++)
612             {
613               if (GetNextImageInList(display_image) == (Image *) NULL)
614                 break;
615               display_image=GetNextImageInList(display_image);
616             }
617           if (l < (ssize_t) resource_info.quantum)
618             break;
619         } while ((display_image != (Image *) NULL) && ((state & ExitState) == 0));
620         /*
621           Free image resources.
622         */
623         display_image=DestroyImageList(display_image);
624         if ((state & FormerImageState) == 0)
625           {
626             last_image=(size_t) image_number;
627             image_marker[i]=(size_t) image_number++;
628           }
629         else
630           {
631             /*
632               Proceed to previous image.
633             */
634             for (i--; i > 0; i--)
635               if (image_marker[i] == (size_t) (image_number-2))
636                 break;
637             image_number--;
638           }
639         if ((i == (ssize_t) argc) && ((state & ExitState) == 0))
640           i=0;
641         if ((state & ExitState) != 0)
642           break;
643         /*
644           Determine if we should proceed to the first image.
645         */
646         if (image_number < 0)
647           {
648             if ((state & FormerImageState) != 0)
649               {
650
651                 for (i=1; i < (ssize_t) (argc-2); i++)
652                   if (last_image == image_marker[i])
653                     break;
654                 image_number=(ssize_t) image_marker[i]+1;
655               }
656             continue;
657           }
658         if (resource_info.window_id != (char *) NULL)
659           state|=ExitState;
660         if (iterations != 0)
661           {
662             if (++iteration == (ssize_t) iterations)
663               state|=ExitState;
664             i=0;
665           }
666         if (LocaleCompare(filename,"-") == 0)
667           state|=ExitState;
668         RemoveAllImageStack();
669         continue;
670       }
671     pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
672     switch (*(option+1))
673     {
674       case 'a':
675       {
676         if (LocaleCompare("alpha",option+1) == 0)
677           {
678             ssize_t
679               type;
680
681             if (*option == '+')
682               break;
683             i++;
684             if (i == (ssize_t) argc)
685               ThrowDisplayException(OptionError,"MissingArgument",option);
686             type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,
687               argv[i]);
688             if (type < 0)
689               ThrowDisplayException(OptionError,
690                 "UnrecognizedAlphaChannelOption",argv[i]);
691             break;
692           }
693         if (LocaleCompare("antialias",option+1) == 0)
694           break;
695         if (LocaleCompare("authenticate",option+1) == 0)
696           {
697             if (*option == '+')
698               break;
699             i++;
700             if (i == (ssize_t) argc)
701               ThrowDisplayException(OptionError,"MissingArgument",option);
702             break;
703           }
704         if (LocaleCompare("auto-orient",option+1) == 0)
705           break;
706         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
707       }
708       case 'b':
709       {
710         if (LocaleCompare("backdrop",option+1) == 0)
711           {
712             resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse;
713             break;
714           }
715         if (LocaleCompare("background",option+1) == 0)
716           {
717             if (*option == '+')
718               break;
719             i++;
720             if (i == (ssize_t) argc)
721               ThrowDisplayException(OptionError,"MissingArgument",option);
722             resource_info.background_color=argv[i];
723             break;
724           }
725         if (LocaleCompare("border",option+1) == 0)
726           {
727             if (*option == '+')
728               break;
729             i++;
730             if (i == (ssize_t) argc)
731               ThrowDisplayException(OptionError,"MissingArgument",option);
732             if (IsGeometry(argv[i]) == MagickFalse)
733               ThrowDisplayInvalidArgumentException(option,argv[i]);
734             break;
735           }
736         if (LocaleCompare("bordercolor",option+1) == 0)
737           {
738             if (*option == '+')
739               break;
740             i++;
741             if (i == (ssize_t) argc)
742               ThrowDisplayException(OptionError,"MissingArgument",option);
743             resource_info.border_color=argv[i];
744             break;
745           }
746         if (LocaleCompare("borderwidth",option+1) == 0)
747           {
748             resource_info.border_width=0;
749             if (*option == '+')
750               break;
751             i++;
752             if (i == (ssize_t) argc)
753               ThrowDisplayException(OptionError,"MissingArgument",option);
754             if (IsGeometry(argv[i]) == MagickFalse)
755               ThrowDisplayInvalidArgumentException(option,argv[i]);
756             resource_info.border_width=(unsigned int)
757               StringToUnsignedLong(argv[i]);
758             break;
759           }
760         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
761       }
762       case 'c':
763       {
764         if (LocaleCompare("cache",option+1) == 0)
765           {
766             if (*option == '+')
767               break;
768             i++;
769             if (i == (ssize_t) argc)
770               ThrowDisplayException(OptionError,"MissingArgument",option);
771             if (IsGeometry(argv[i]) == MagickFalse)
772               ThrowDisplayInvalidArgumentException(option,argv[i]);
773             break;
774           }
775         if (LocaleCompare("channel",option+1) == 0)
776           {
777             ssize_t
778               channel;
779
780             if (*option == '+')
781               break;
782             i++;
783             if (i == (ssize_t) argc)
784               ThrowDisplayException(OptionError,"MissingArgument",option);
785             channel=ParseChannelOption(argv[i]);
786             if (channel < 0)
787               ThrowDisplayException(OptionError,"UnrecognizedChannelType",
788                 argv[i]);
789             break;
790           }
791         if (LocaleCompare("clip",option+1) == 0)
792           break;
793         if (LocaleCompare("clip-path",option+1) == 0)
794           {
795             i++;
796             if (i == (ssize_t) argc)
797               ThrowDisplayException(OptionError,"MissingArgument",option);
798             break;
799           }
800         if (LocaleCompare("coalesce",option+1) == 0)
801           break;
802         if (LocaleCompare("colormap",option+1) == 0)
803           {
804             resource_info.colormap=PrivateColormap;
805             if (*option == '+')
806               break;
807             i++;
808             if (i == (ssize_t) argc)
809               ThrowDisplayException(OptionError,"MissingArgument",option);
810             resource_info.colormap=UndefinedColormap;
811             if (LocaleCompare("private",argv[i]) == 0)
812               resource_info.colormap=PrivateColormap;
813             if (LocaleCompare("shared",argv[i]) == 0)
814               resource_info.colormap=SharedColormap;
815             if (resource_info.colormap == UndefinedColormap)
816               ThrowDisplayException(OptionError,"UnrecognizedColormapType",
817                 argv[i]);
818             break;
819           }
820         if (LocaleCompare("colors",option+1) == 0)
821           {
822             quantize_info->number_colors=0;
823             if (*option == '+')
824               break;
825             i++;
826             if (i == (ssize_t) argc)
827               ThrowDisplayException(OptionError,"MissingArgument",option);
828             if (IsGeometry(argv[i]) == MagickFalse)
829               ThrowDisplayInvalidArgumentException(option,argv[i]);
830             quantize_info->number_colors=StringToUnsignedLong(argv[i]);
831             break;
832           }
833         if (LocaleCompare("colorspace",option+1) == 0)
834           {
835             ssize_t
836               colorspace;
837
838             if (*option == '+')
839               break;
840             i++;
841             if (i == (ssize_t) argc)
842               ThrowDisplayException(OptionError,"MissingArgument",option);
843             colorspace=ParseCommandOption(MagickColorspaceOptions,
844               MagickFalse,argv[i]);
845             if (colorspace < 0)
846               ThrowDisplayException(OptionError,"UnrecognizedColorspace",
847                 argv[i]);
848             break;
849           }
850         if (LocaleCompare("comment",option+1) == 0)
851           {
852             if (*option == '+')
853               break;
854             i++;
855             if (i == (ssize_t) argc)
856               ThrowDisplayException(OptionError,"MissingArgument",option);
857             break;
858           }
859         if (LocaleCompare("compress",option+1) == 0)
860           {
861             ssize_t
862               compress;
863
864             if (*option == '+')
865               break;
866             i++;
867             if (i == (ssize_t) argc)
868               ThrowDisplayException(OptionError,"MissingArgument",option);
869             compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
870               argv[i]);
871             if (compress < 0)
872               ThrowDisplayException(OptionError,"UnrecognizedImageCompression",
873                 argv[i]);
874             break;
875           }
876         if (LocaleCompare("concurrent",option+1) == 0)
877           break;
878         if (LocaleCompare("contrast",option+1) == 0)
879           break;
880         if (LocaleCompare("crop",option+1) == 0)
881           {
882             if (*option == '+')
883               break;
884             i++;
885             if (i == (ssize_t) argc)
886               ThrowDisplayException(OptionError,"MissingArgument",option);
887             if (IsGeometry(argv[i]) == MagickFalse)
888               ThrowDisplayInvalidArgumentException(option,argv[i]);
889             break;
890           }
891         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
892       }
893       case 'd':
894       {
895         if (LocaleCompare("debug",option+1) == 0)
896           {
897             ssize_t
898               event;
899
900             if (*option == '+')
901               break;
902             i++;
903             if (i == (ssize_t) argc)
904               ThrowDisplayException(OptionError,"MissingArgument",option);
905             event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
906             if (event < 0)
907               ThrowDisplayException(OptionError,"UnrecognizedEventType",
908                 argv[i]);
909             (void) SetLogEventMask(argv[i]);
910             break;
911           }
912         if (LocaleCompare("decipher",option+1) == 0)
913           {
914             if (*option == '+')
915               break;
916             i++;
917             if (i == (ssize_t) argc)
918               ThrowDisplayException(OptionError,"MissingArgument",option);
919             break;
920           }
921         if (LocaleCompare("define",option+1) == 0)
922           {
923             i++;
924             if (i == (ssize_t) argc)
925               ThrowDisplayException(OptionError,"MissingArgument",option);
926             if (*option == '+')
927               {
928                 const char
929                   *define;
930
931                 define=GetImageOption(image_info,argv[i]);
932                 if (define == (const char *) NULL)
933                   ThrowDisplayException(OptionError,"NoSuchOption",argv[i]);
934                 break;
935               }
936             break;
937           }
938         if (LocaleCompare("delay",option+1) == 0)
939           {
940             if (*option == '+')
941               break;
942             i++;
943             if (i == (ssize_t) argc)
944               ThrowDisplayException(OptionError,"MissingArgument",option);
945             if (IsGeometry(argv[i]) == MagickFalse)
946               ThrowDisplayInvalidArgumentException(option,argv[i]);
947             break;
948           }
949         if (LocaleCompare("density",option+1) == 0)
950           {
951             if (*option == '+')
952               break;
953             i++;
954             if (i == (ssize_t) argc)
955               ThrowDisplayException(OptionError,"MissingArgument",option);
956             if (IsGeometry(argv[i]) == MagickFalse)
957               ThrowDisplayInvalidArgumentException(option,argv[i]);
958             break;
959           }
960         if (LocaleCompare("depth",option+1) == 0)
961           {
962             if (*option == '+')
963               break;
964             i++;
965             if (i == (ssize_t) argc)
966               ThrowDisplayException(OptionError,"MissingArgument",option);
967             if (IsGeometry(argv[i]) == MagickFalse)
968               ThrowDisplayInvalidArgumentException(option,argv[i]);
969             break;
970           }
971         if (LocaleCompare("deskew",option+1) == 0)
972           {
973             if (*option == '+')
974               break;
975             i++;
976             if (i == (ssize_t) argc)
977               ThrowDisplayException(OptionError,"MissingArgument",option);
978             if (IsGeometry(argv[i]) == MagickFalse)
979               ThrowDisplayInvalidArgumentException(option,argv[i]);
980             break;
981           }
982         if (LocaleCompare("despeckle",option+1) == 0)
983           break;
984         if (LocaleCompare("display",option+1) == 0)
985           {
986             if (*option == '+')
987               break;
988             i++;
989             if (i == (ssize_t) argc)
990               ThrowDisplayException(OptionError,"MissingArgument",option);
991             break;
992           }
993         if (LocaleCompare("dispose",option+1) == 0)
994           {
995             ssize_t
996               dispose;
997
998             if (*option == '+')
999               break;
1000             i++;
1001             if (i == (ssize_t) argc)
1002               ThrowDisplayException(OptionError,"MissingArgument",option);
1003             dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
1004             if (dispose < 0)
1005               ThrowDisplayException(OptionError,"UnrecognizedDisposeMethod",
1006                 argv[i]);
1007             break;
1008           }
1009         if (LocaleCompare("dither",option+1) == 0)
1010           {
1011             ssize_t
1012               method;
1013
1014             quantize_info->dither_method=NoDitherMethod;
1015             if (*option == '+')
1016               break;
1017             i++;
1018             if (i == (ssize_t) argc)
1019               ThrowDisplayException(OptionError,"MissingArgument",option);
1020             method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
1021             if (method < 0)
1022               ThrowDisplayException(OptionError,"UnrecognizedDitherMethod",
1023                 argv[i]);
1024             quantize_info->dither_method=(DitherMethod) method;
1025             break;
1026           }
1027         if (LocaleCompare("duration",option+1) == 0)
1028           {
1029             if (*option == '+')
1030               break;
1031             i++;
1032             if (i == (ssize_t) argc)
1033               ThrowDisplayException(OptionError,"MissingArgument",option);
1034             if (IsGeometry(argv[i]) == MagickFalse)
1035               ThrowDisplayInvalidArgumentException(option,argv[i]);
1036             break;
1037           }
1038         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1039       }
1040       case 'e':
1041       {
1042         if (LocaleCompare("edge",option+1) == 0)
1043           {
1044             if (*option == '+')
1045               break;
1046             i++;
1047             if (i == (ssize_t) argc)
1048               ThrowDisplayException(OptionError,"MissingArgument",option);
1049             if (IsGeometry(argv[i]) == MagickFalse)
1050               ThrowDisplayInvalidArgumentException(option,argv[i]);
1051             break;
1052           }
1053         if (LocaleCompare("endian",option+1) == 0)
1054           {
1055             ssize_t
1056               endian;
1057
1058             if (*option == '+')
1059               break;
1060             i++;
1061             if (i == (ssize_t) argc)
1062               ThrowDisplayException(OptionError,"MissingArgument",option);
1063             endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
1064               argv[i]);
1065             if (endian < 0)
1066               ThrowDisplayException(OptionError,"UnrecognizedEndianType",
1067                 argv[i]);
1068             break;
1069           }
1070         if (LocaleCompare("enhance",option+1) == 0)
1071           break;
1072         if (LocaleCompare("equalize",option+1) == 0)
1073           break;
1074         if (LocaleCompare("extract",option+1) == 0)
1075           {
1076             if (*option == '+')
1077               break;
1078             i++;
1079             if (i == (ssize_t) argc)
1080               ThrowDisplayException(OptionError,"MissingArgument",option);
1081             if (IsGeometry(argv[i]) == MagickFalse)
1082               ThrowDisplayInvalidArgumentException(option,argv[i]);
1083             break;
1084           }
1085         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1086       }
1087       case 'f':
1088       {
1089         if (LocaleCompare("filter",option+1) == 0)
1090           {
1091             ssize_t
1092               filter;
1093
1094             if (*option == '+')
1095               break;
1096             i++;
1097             if (i == (ssize_t) argc)
1098               ThrowDisplayException(OptionError,"MissingArgument",option);
1099             filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
1100             if (filter < 0)
1101               ThrowDisplayException(OptionError,"UnrecognizedImageFilter",
1102                 argv[i]);
1103             break;
1104           }
1105         if (LocaleCompare("flatten",option+1) == 0)
1106           break;
1107         if (LocaleCompare("flip",option+1) == 0)
1108           break;
1109         if (LocaleCompare("flop",option+1) == 0)
1110           break;
1111         if (LocaleCompare("font",option+1) == 0)
1112           {
1113             if (*option == '+')
1114               break;
1115             i++;
1116             if (i == (ssize_t) argc)
1117               ThrowDisplayException(OptionError,"MissingArgument",option);
1118             resource_info.font=XGetResourceClass(resource_database,
1119               GetClientName(),"font",argv[i]);
1120             break;
1121           }
1122         if (LocaleCompare("foreground",option+1) == 0)
1123           {
1124             if (*option == '+')
1125               break;
1126             i++;
1127             if (i == (ssize_t) argc)
1128               ThrowDisplayException(OptionError,"MissingArgument",option);
1129             resource_info.foreground_color=argv[i];
1130             break;
1131           }
1132         if (LocaleCompare("format",option+1) == 0)
1133           {
1134             if (*option == '+')
1135               break;
1136             i++;
1137             if (i == (ssize_t) argc)
1138               ThrowDisplayException(OptionError,"MissingArgument",option);
1139             break;
1140           }
1141         if (LocaleCompare("frame",option+1) == 0)
1142           {
1143             if (*option == '+')
1144               break;
1145             i++;
1146             if (i == (ssize_t) argc)
1147               ThrowDisplayException(OptionError,"MissingArgument",option);
1148             if (IsGeometry(argv[i]) == MagickFalse)
1149               ThrowDisplayInvalidArgumentException(option,argv[i]);
1150             break;
1151           }
1152         if (LocaleCompare("fuzz",option+1) == 0)
1153           {
1154             if (*option == '+')
1155               break;
1156             i++;
1157             if (i == (ssize_t) argc)
1158               ThrowDisplayException(OptionError,"MissingArgument",option);
1159             if (IsGeometry(argv[i]) == MagickFalse)
1160               ThrowDisplayInvalidArgumentException(option,argv[i]);
1161             break;
1162           }
1163         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1164       }
1165       case 'g':
1166       {
1167         if (LocaleCompare("gamma",option+1) == 0)
1168           {
1169             i++;
1170             if (i == (ssize_t) argc)
1171               ThrowDisplayException(OptionError,"MissingArgument",option);
1172             if (IsGeometry(argv[i]) == MagickFalse)
1173               ThrowDisplayInvalidArgumentException(option,argv[i]);
1174             break;
1175           }
1176         if (LocaleCompare("geometry",option+1) == 0)
1177           {
1178             resource_info.image_geometry=(char *) NULL;
1179             if (*option == '+')
1180               break;
1181             (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
1182             i++;
1183             if (i == (ssize_t) argc)
1184               ThrowDisplayException(OptionError,"MissingArgument",option);
1185             if (IsGeometry(argv[i]) == MagickFalse)
1186               ThrowDisplayInvalidArgumentException(option,argv[i]);
1187             resource_info.image_geometry=ConstantString(argv[i]);
1188             break;
1189           }
1190         if (LocaleCompare("gravity",option+1) == 0)
1191           {
1192             ssize_t
1193               gravity;
1194
1195             if (*option == '+')
1196               break;
1197             i++;
1198             if (i == (ssize_t) argc)
1199               ThrowDisplayException(OptionError,"MissingArgument",option);
1200             gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
1201               argv[i]);
1202             if (gravity < 0)
1203               ThrowDisplayException(OptionError,"UnrecognizedGravityType",
1204                 argv[i]);
1205             break;
1206           }
1207         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1208       }
1209       case 'h':
1210       {
1211         if ((LocaleCompare("help",option+1) == 0) ||
1212             (LocaleCompare("-help",option+1) == 0))
1213           break;
1214         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1215       }
1216       case 'i':
1217       {
1218         if (LocaleCompare("identify",option+1) == 0)
1219           break;
1220         if (LocaleCompare("iconGeometry",option+1) == 0)
1221           {
1222             resource_info.icon_geometry=(char *) NULL;
1223             if (*option == '+')
1224               break;
1225             i++;
1226             if (i == (ssize_t) argc)
1227               ThrowDisplayException(OptionError,"MissingArgument",option);
1228             if (IsGeometry(argv[i]) == MagickFalse)
1229               ThrowDisplayInvalidArgumentException(option,argv[i]);
1230             resource_info.icon_geometry=argv[i];
1231             break;
1232           }
1233         if (LocaleCompare("iconic",option+1) == 0)
1234           {
1235             resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
1236             break;
1237           }
1238         if (LocaleCompare("immutable",option+1) == 0)
1239           {
1240             resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
1241             break;
1242           }
1243         if (LocaleCompare("interlace",option+1) == 0)
1244           {
1245             ssize_t
1246               interlace;
1247
1248             if (*option == '+')
1249               break;
1250             i++;
1251             if (i == (ssize_t) argc)
1252               ThrowDisplayException(OptionError,"MissingArgument",option);
1253             interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
1254               argv[i]);
1255             if (interlace < 0)
1256               ThrowDisplayException(OptionError,"UnrecognizedInterlaceType",
1257                 argv[i]);
1258             break;
1259           }
1260         if (LocaleCompare("interpolate",option+1) == 0)
1261           {
1262             ssize_t
1263               interpolate;
1264
1265             if (*option == '+')
1266               break;
1267             i++;
1268             if (i == (ssize_t) argc)
1269               ThrowDisplayException(OptionError,"MissingArgument",option);
1270             interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
1271               argv[i]);
1272             if (interpolate < 0)
1273               ThrowDisplayException(OptionError,"UnrecognizedInterpolateMethod",
1274                 argv[i]);
1275             break;
1276           }
1277         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1278       }
1279       case 'l':
1280       {
1281         if (LocaleCompare("label",option+1) == 0)
1282           {
1283             if (*option == '+')
1284               break;
1285             i++;
1286             if (i == (ssize_t) argc)
1287               ThrowDisplayException(OptionError,"MissingArgument",option);
1288             break;
1289           }
1290         if (LocaleCompare("limit",option+1) == 0)
1291           {
1292             char
1293               *p;
1294
1295             double
1296               value;
1297
1298             ssize_t
1299               resource;
1300
1301             if (*option == '+')
1302               break;
1303             i++;
1304             if (i == (ssize_t) argc)
1305               ThrowDisplayException(OptionError,"MissingArgument",option);
1306             resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1307               argv[i]);
1308             if (resource < 0)
1309               ThrowDisplayException(OptionError,"UnrecognizedResourceType",
1310                 argv[i]);
1311             i++;
1312             if (i == (ssize_t) argc)
1313               ThrowDisplayException(OptionError,"MissingArgument",option);
1314             value=StringToDouble(argv[i],&p);
1315             (void) value;
1316             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1317               ThrowDisplayInvalidArgumentException(option,argv[i]);
1318             break;
1319           }
1320         if (LocaleCompare("list",option+1) == 0)
1321           {
1322             ssize_t
1323               list;
1324
1325             if (*option == '+')
1326               break;
1327             i++;
1328             if (i == (ssize_t) argc)
1329               ThrowDisplayException(OptionError,"MissingArgument",option);
1330             list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1331             if (list < 0)
1332               ThrowDisplayException(OptionError,"UnrecognizedListType",argv[i]);
1333             status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1334               argv+j,exception);
1335             DestroyDisplay();
1336             return(status == 0 ? MagickFalse : MagickTrue);
1337           }
1338         if (LocaleCompare("log",option+1) == 0)
1339           {
1340             if (*option == '+')
1341               break;
1342             i++;
1343             if ((i == (ssize_t) argc) ||
1344                 (strchr(argv[i],'%') == (char *) NULL))
1345               ThrowDisplayException(OptionError,"MissingArgument",option);
1346             break;
1347           }
1348         if (LocaleCompare("loop",option+1) == 0)
1349           {
1350             if (*option == '+')
1351               break;
1352             i++;
1353             if (i == (ssize_t) argc)
1354               ThrowDisplayException(OptionError,"MissingArgument",option);
1355             if (IsGeometry(argv[i]) == MagickFalse)
1356               ThrowDisplayInvalidArgumentException(option,argv[i]);
1357             iterations=StringToUnsignedLong(argv[i]);
1358             break;
1359           }
1360         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1361       }
1362       case 'm':
1363       {
1364         if (LocaleCompare("magnify",option+1) == 0)
1365           {
1366             resource_info.magnify=2;
1367             if (*option == '+')
1368               break;
1369             i++;
1370             if (i == (ssize_t) argc)
1371               ThrowDisplayException(OptionError,"MissingArgument",option);
1372             if (IsGeometry(argv[i]) == MagickFalse)
1373               ThrowDisplayInvalidArgumentException(option,argv[i]);
1374             resource_info.magnify=(unsigned int) StringToUnsignedLong(argv[i]);
1375             break;
1376           }
1377         if (LocaleCompare("map",option+1) == 0)
1378           {
1379             resource_info.map_type=(char *) NULL;
1380             if (*option == '+')
1381               break;
1382             (void) strcpy(argv[i]+1,"san");
1383             i++;
1384             if (i == (ssize_t) argc)
1385               ThrowDisplayException(OptionError,"MissingArgument",option);
1386             resource_info.map_type=argv[i];
1387             break;
1388           }
1389         if (LocaleCompare("matte",option+1) == 0)
1390           break;
1391         if (LocaleCompare("mattecolor",option+1) == 0)
1392           {
1393             if (*option == '+')
1394               break;
1395             i++;
1396             if (i == (ssize_t) argc)
1397               ThrowDisplayException(OptionError,"MissingArgument",option);
1398             resource_info.matte_color=argv[i];
1399             break;
1400           }
1401         if (LocaleCompare("monitor",option+1) == 0)
1402           break;
1403         if (LocaleCompare("monochrome",option+1) == 0)
1404           {
1405             if (*option == '+')
1406               break;
1407             quantize_info->number_colors=2;
1408             quantize_info->colorspace=GRAYColorspace;
1409             break;
1410           }
1411         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1412       }
1413       case 'n':
1414       {
1415         if (LocaleCompare("name",option+1) == 0)
1416           {
1417             resource_info.name=(char *) NULL;
1418             if (*option == '+')
1419               break;
1420             i++;
1421             if (i == (ssize_t) argc)
1422               ThrowDisplayException(OptionError,"MissingArgument",option);
1423             resource_info.name=ConstantString(argv[i]);
1424             break;
1425           }
1426         if (LocaleCompare("negate",option+1) == 0)
1427           break;
1428         if (LocaleCompare("noop",option+1) == 0)
1429           break;
1430         if (LocaleCompare("normalize",option+1) == 0)
1431           break;
1432         if (LocaleCompare("nostdin",option+1) == 0)
1433           break;
1434         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1435       }
1436       case 'p':
1437       {
1438         if (LocaleCompare("page",option+1) == 0)
1439           {
1440             resource_info.image_geometry=(char *) NULL;
1441             if (*option == '+')
1442               break;
1443             i++;
1444             if (i == (ssize_t) argc)
1445               ThrowDisplayException(OptionError,"MissingArgument",option);
1446             resource_info.image_geometry=ConstantString(argv[i]);
1447             break;
1448           }
1449         if (LocaleCompare("profile",option+1) == 0)
1450           {
1451             i++;
1452             if (i == (ssize_t) argc)
1453               ThrowDisplayException(OptionError,"MissingArgument",option);
1454             break;
1455           }
1456         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1457       }
1458       case 'q':
1459       {
1460         if (LocaleCompare("quality",option+1) == 0)
1461           {
1462             if (*option == '+')
1463               break;
1464             i++;
1465             if (i == (ssize_t) argc)
1466               ThrowDisplayException(OptionError,"MissingArgument",option);
1467             if (IsGeometry(argv[i]) == MagickFalse)
1468               ThrowDisplayInvalidArgumentException(option,argv[i]);
1469             break;
1470           }
1471         if (LocaleCompare("quantize",option+1) == 0)
1472           {
1473             ssize_t
1474               colorspace;
1475
1476             if (*option == '+')
1477               break;
1478             i++;
1479             if (i == (ssize_t) argc)
1480               ThrowDisplayException(OptionError,"MissingArgument",option);
1481             colorspace=ParseCommandOption(MagickColorspaceOptions,
1482               MagickFalse,argv[i]);
1483             if (colorspace < 0)
1484               ThrowDisplayException(OptionError,"UnrecognizedColorspace",
1485                 argv[i]);
1486             break;
1487           }
1488         if (LocaleCompare("quiet",option+1) == 0)
1489           break;
1490         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1491       }
1492       case 'r':
1493       {
1494         if (LocaleCompare("raise",option+1) == 0)
1495           {
1496             i++;
1497             if (i == (ssize_t) argc)
1498               ThrowDisplayException(OptionError,"MissingArgument",option);
1499             if (IsGeometry(argv[i]) == MagickFalse)
1500               ThrowDisplayInvalidArgumentException(option,argv[i]);
1501             break;
1502           }
1503         if (LocaleCompare("regard-warnings",option+1) == 0)
1504           break;
1505         if (LocaleCompare("remote",option+1) == 0)
1506           {
1507             i++;
1508             if (i == (ssize_t) argc)
1509               ThrowDisplayException(OptionError,"MissingArgument",option);
1510             if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1511               return(MagickFalse);
1512             i--;
1513             break;
1514           }
1515         if (LocaleCompare("repage",option+1) == 0)
1516           {
1517             if (*option == '+')
1518               break;
1519             i++;
1520             if (i == (ssize_t) argc)
1521               ThrowDisplayException(OptionError,"MissingArgument",option);
1522             if (IsGeometry(argv[i]) == MagickFalse)
1523               ThrowDisplayInvalidArgumentException(option,argv[i]);
1524             break;
1525           }
1526         if (LocaleCompare("resample",option+1) == 0)
1527           {
1528             if (*option == '+')
1529               break;
1530             i++;
1531             if (i == (ssize_t) argc)
1532               ThrowDisplayException(OptionError,"MissingArgument",option);
1533             if (IsGeometry(argv[i]) == MagickFalse)
1534               ThrowDisplayInvalidArgumentException(option,argv[i]);
1535             break;
1536           }
1537         if (LocaleCompare("resize",option+1) == 0)
1538           {
1539             if (*option == '+')
1540               break;
1541             i++;
1542             if (i == (ssize_t) argc)
1543               ThrowDisplayException(OptionError,"MissingArgument",option);
1544             if (IsGeometry(argv[i]) == MagickFalse)
1545               ThrowDisplayInvalidArgumentException(option,argv[i]);
1546             break;
1547           }
1548         if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1549           {
1550             respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1551             break;
1552           }
1553         if (LocaleCompare("roll",option+1) == 0)
1554           {
1555             if (*option == '+')
1556               break;
1557             i++;
1558             if (i == (ssize_t) argc)
1559               ThrowDisplayException(OptionError,"MissingArgument",option);
1560             if (IsGeometry(argv[i]) == MagickFalse)
1561               ThrowDisplayInvalidArgumentException(option,argv[i]);
1562             break;
1563           }
1564         if (LocaleCompare("rotate",option+1) == 0)
1565           {
1566             i++;
1567             if (i == (ssize_t) argc)
1568               ThrowDisplayException(OptionError,"MissingArgument",option);
1569             if (IsGeometry(argv[i]) == MagickFalse)
1570               ThrowDisplayInvalidArgumentException(option,argv[i]);
1571             break;
1572           }
1573         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1574       }
1575       case 's':
1576       {
1577         if (LocaleCompare("sample",option+1) == 0)
1578           {
1579             if (*option == '+')
1580               break;
1581             i++;
1582             if (i == (ssize_t) argc)
1583               ThrowDisplayException(OptionError,"MissingArgument",option);
1584             if (IsGeometry(argv[i]) == MagickFalse)
1585               ThrowDisplayInvalidArgumentException(option,argv[i]);
1586             break;
1587           }
1588         if (LocaleCompare("sampling-factor",option+1) == 0)
1589           {
1590             if (*option == '+')
1591               break;
1592             i++;
1593             if (i == (ssize_t) argc)
1594               ThrowDisplayException(OptionError,"MissingArgument",option);
1595             if (IsGeometry(argv[i]) == MagickFalse)
1596               ThrowDisplayInvalidArgumentException(option,argv[i]);
1597             break;
1598           }
1599         if (LocaleCompare("scenes",option+1) == 0)
1600           {
1601             if (*option == '+')
1602               break;
1603             i++;
1604             if (i == (ssize_t) argc)
1605               ThrowDisplayException(OptionError,"MissingArgument",option);
1606             if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1607               ThrowDisplayInvalidArgumentException(option,argv[i]);
1608             break;
1609           }
1610         if (LocaleCompare("seed",option+1) == 0)
1611           {
1612             if (*option == '+')
1613               break;
1614             i++;
1615             if (i == (ssize_t) argc)
1616               ThrowDisplayException(OptionError,"MissingArgument",option);
1617             if (IsGeometry(argv[i]) == MagickFalse)
1618               ThrowDisplayInvalidArgumentException(option,argv[i]);
1619             break;
1620           }
1621         if (LocaleCompare("segment",option+1) == 0)
1622           {
1623             if (*option == '+')
1624               break;
1625             i++;
1626             if (i == (ssize_t) argc)
1627               ThrowDisplayException(OptionError,"MissingArgument",option);
1628             if (IsGeometry(argv[i]) == MagickFalse)
1629               ThrowDisplayInvalidArgumentException(option,argv[i]);
1630             break;
1631           }
1632         if (LocaleCompare("set",option+1) == 0)
1633           {
1634             i++;
1635             if (i == (ssize_t) argc)
1636               ThrowDisplayException(OptionError,"MissingArgument",option);
1637             if (*option == '+')
1638               break;
1639             i++;
1640             if (i == (ssize_t) argc)
1641               ThrowDisplayException(OptionError,"MissingArgument",option);
1642             break;
1643           }
1644         if (LocaleCompare("sharpen",option+1) == 0)
1645           {
1646             if (*option == '+')
1647               break;
1648             i++;
1649             if (i == (ssize_t) argc)
1650               ThrowDisplayException(OptionError,"MissingArgument",option);
1651             if (IsGeometry(argv[i]) == MagickFalse)
1652               ThrowDisplayInvalidArgumentException(option,argv[i]);
1653             break;
1654           }
1655         if (LocaleCompare("shared-memory",option+1) == 0)
1656           {
1657             resource_info.use_shared_memory= (*option == '-') ? MagickTrue :
1658               MagickFalse;
1659             break;
1660           }
1661         if (LocaleCompare("size",option+1) == 0)
1662           {
1663             if (*option == '+')
1664               break;
1665             i++;
1666             if (i == (ssize_t) argc)
1667               ThrowDisplayException(OptionError,"MissingArgument",option);
1668             if (IsGeometry(argv[i]) == MagickFalse)
1669               ThrowDisplayInvalidArgumentException(option,argv[i]);
1670             break;
1671           }
1672         if (LocaleCompare("strip",option+1) == 0)
1673           break;
1674         if (LocaleCompare("support",option+1) == 0)
1675           {
1676             i++;  /* deprecated */
1677             break;
1678           }
1679         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1680       }
1681       case 't':
1682       {
1683         if (LocaleCompare("text-font",option+1) == 0)
1684           {
1685             resource_info.text_font=(char *) NULL;
1686             if (*option == '+')
1687               break;
1688             i++;
1689             if (i == (ssize_t) argc)
1690               ThrowDisplayException(OptionError,"MissingArgument",option);
1691             resource_info.text_font=XGetResourceClass(resource_database,
1692               GetClientName(),"font",argv[i]);
1693             break;
1694           }
1695         if (LocaleCompare("texture",option+1) == 0)
1696           {
1697             if (*option == '+')
1698               break;
1699             i++;
1700             if (i == (ssize_t) argc)
1701               ThrowDisplayException(OptionError,"MissingArgument",option);
1702             break;
1703           }
1704         if (LocaleCompare("threshold",option+1) == 0)
1705           {
1706             if (*option == '+')
1707               break;
1708             i++;
1709             if (i == (ssize_t) argc)
1710               ThrowDisplayException(OptionError,"MissingArgument",option);
1711             if (IsGeometry(argv[i]) == MagickFalse)
1712               ThrowDisplayInvalidArgumentException(option,argv[i]);
1713             break;
1714           }
1715         if (LocaleCompare("thumbnail",option+1) == 0)
1716           {
1717             if (*option == '+')
1718               break;
1719             i++;
1720             if (i == (ssize_t) argc)
1721               ThrowDisplayException(OptionError,"MissingArgument",option);
1722             if (IsGeometry(argv[i]) == MagickFalse)
1723               ThrowDisplayInvalidArgumentException(option,argv[i]);
1724             break;
1725           }
1726         if (LocaleCompare("title",option+1) == 0)
1727           {
1728             resource_info.title=(char *) NULL;
1729             if (*option == '+')
1730               break;
1731             i++;
1732             if (i == (ssize_t) argc)
1733               ThrowDisplayException(OptionError,"MissingArgument",option);
1734             resource_info.title=argv[i];
1735             break;
1736           }
1737         if (LocaleCompare("transparent-color",option+1) == 0)
1738           {
1739             if (*option == '+')
1740               break;
1741             i++;
1742             if (i == (ssize_t) argc)
1743               ThrowDisplayException(OptionError,"MissingArgument",option);
1744             break;
1745           }
1746         if (LocaleCompare("treedepth",option+1) == 0)
1747           {
1748             quantize_info->tree_depth=0;
1749             if (*option == '+')
1750               break;
1751             i++;
1752             if (i == (ssize_t) argc)
1753               ThrowDisplayException(OptionError,"MissingArgument",option);
1754             if (IsGeometry(argv[i]) == MagickFalse)
1755               ThrowDisplayInvalidArgumentException(option,argv[i]);
1756             quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1757             break;
1758           }
1759         if (LocaleCompare("trim",option+1) == 0)
1760           break;
1761         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1762       }
1763       case 'u':
1764       {
1765         if (LocaleCompare("update",option+1) == 0)
1766           {
1767             resource_info.update=(unsigned int) (*option == '-');
1768             if (*option == '+')
1769               break;
1770             i++;
1771             if (i == (ssize_t) argc)
1772               ThrowDisplayException(OptionError,"MissingArgument",option);
1773             if (IsGeometry(argv[i]) == MagickFalse)
1774               ThrowDisplayInvalidArgumentException(option,argv[i]);
1775             resource_info.update=(unsigned int) StringToUnsignedLong(argv[i]);
1776             break;
1777           }
1778         if (LocaleCompare("use-pixmap",option+1) == 0)
1779           {
1780             resource_info.use_pixmap=(*option == '-') ? MagickTrue :
1781               MagickFalse;
1782             break;
1783           }
1784         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1785       }
1786       case 'v':
1787       {
1788         if (LocaleCompare("verbose",option+1) == 0)
1789           break;
1790         if ((LocaleCompare("version",option+1) == 0) ||
1791             (LocaleCompare("-version",option+1) == 0))
1792           {
1793             ListMagickVersion(stdout);
1794             break;
1795           }
1796         if (LocaleCompare("visual",option+1) == 0)
1797           {
1798             resource_info.visual_type=(char *) NULL;
1799             if (*option == '+')
1800               break;
1801             i++;
1802             if (i == (ssize_t) argc)
1803               ThrowDisplayException(OptionError,"MissingArgument",option);
1804             resource_info.visual_type=argv[i];
1805             break;
1806           }
1807         if (LocaleCompare("virtual-pixel",option+1) == 0)
1808           {
1809             ssize_t
1810               method;
1811
1812             if (*option == '+')
1813               break;
1814             i++;
1815             if (i == (ssize_t) argc)
1816               ThrowDisplayException(OptionError,"MissingArgument",option);
1817             method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1818               argv[i]);
1819             if (method < 0)
1820               ThrowDisplayException(OptionError,
1821                 "UnrecognizedVirtualPixelMethod",argv[i]);
1822             break;
1823           }
1824         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1825       }
1826       case 'w':
1827       {
1828         if (LocaleCompare("window",option+1) == 0)
1829           {
1830             resource_info.window_id=(char *) NULL;
1831             if (*option == '+')
1832               break;
1833             i++;
1834             if (i == (ssize_t) argc)
1835               ThrowDisplayException(OptionError,"MissingArgument",option);
1836             resource_info.window_id=argv[i];
1837             break;
1838           }
1839         if (LocaleCompare("window-group",option+1) == 0)
1840           {
1841             resource_info.window_group=(char *) NULL;
1842             if (*option == '+')
1843               break;
1844             i++;
1845             if (i == (ssize_t) argc)
1846               ThrowDisplayException(OptionError,"MissingArgument",option);
1847             if (StringToDouble(argv[i],(char **) NULL) != 0)
1848               resource_info.window_group=argv[i];
1849             break;
1850           }
1851         if (LocaleCompare("write",option+1) == 0)
1852           {
1853             resource_info.write_filename=(char *) NULL;
1854             if (*option == '+')
1855               break;
1856             i++;
1857             if (i == (ssize_t) argc)
1858               ThrowDisplayException(OptionError,"MissingArgument",option);
1859             resource_info.write_filename=argv[i];
1860             if (IsPathAccessible(resource_info.write_filename) != MagickFalse)
1861               {
1862                 char
1863                   answer[2],
1864                   *p;
1865
1866                 (void) FormatLocaleFile(stderr,"Overwrite %s? ",
1867                   resource_info.write_filename);
1868                 p=fgets(answer,(int) sizeof(answer),stdin);
1869                 (void) p;
1870                 if (((*answer != 'y') && (*answer != 'Y')))
1871                   return(MagickFalse);
1872               }
1873             break;
1874           }
1875         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1876       }
1877       case '?':
1878         break;
1879       default:
1880         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1881     }
1882     fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1883       FireOptionFlag) == 0 ?  MagickFalse : MagickTrue;
1884     if (fire != MagickFalse)
1885       FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1886   }
1887   if (k != 0)
1888     ThrowDisplayException(OptionError,"UnbalancedParenthesis",argv[i]);
1889   if (state & RetainColorsState)
1890     {
1891       XRetainWindowColors(display,XRootWindow(display,XDefaultScreen(display)));
1892       (void) XSync(display,MagickFalse);
1893     }
1894   DestroyDisplay();
1895   return(status != 0 ? MagickTrue : MagickFalse);
1896 #else
1897   wand_unreferenced(argc);
1898   wand_unreferenced(argv);
1899   wand_unreferenced(metadata);
1900   (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1901     "DelegateLibrarySupportNotBuiltIn","'%s' (X11)",image_info->filename);
1902   return(DisplayUsage());
1903 #endif
1904 }