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