display.c

Go to the documentation of this file.
00001 /*
00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00003 %                                                                             %
00004 %                                                                             %
00005 %                                                                             %
00006 %               DDDD   IIIII  SSSSS  PPPP   L       AAA   Y   Y               %
00007 %               D   D    I    SS     P   P  L      A   A   Y Y                %
00008 %               D   D    I     SSS   PPPP   L      AAAAA    Y                 %
00009 %               D   D    I       SS  P      L      A   A    Y                 %
00010 %               DDDD   IIIII  SSSSS  P      LLLLL  A   A    Y                 %
00011 %                                                                             %
00012 %                                                                             %
00013 %              Methods to Interactively Display and Edit an Image             %
00014 %                                                                             %
00015 %                             Software Design                                 %
00016 %                               John Cristy                                   %
00017 %                                July 1992                                    %
00018 %                                                                             %
00019 %                                                                             %
00020 %  Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization      %
00021 %  dedicated to making software imaging solutions freely available.           %
00022 %                                                                             %
00023 %  You may not use this file except in compliance with the License.  You may  %
00024 %  obtain a copy of the License at                                            %
00025 %                                                                             %
00026 %    http://www.imagemagick.org/script/license.php                            %
00027 %                                                                             %
00028 %  Unless required by applicable law or agreed to in writing, software        %
00029 %  distributed under the License is distributed on an "AS IS" BASIS,          %
00030 %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   %
00031 %  See the License for the specific language governing permissions and        %
00032 %  limitations under the License.                                             %
00033 %                                                                             %
00034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00035 %
00036 %
00037 */
00038 
00039 /*
00040   Include declarations.
00041 */
00042 #include "wand/studio.h"
00043 #include "wand/MagickWand.h"
00044 #include "wand/mogrify-private.h"
00045 #include "magick/display-private.h"
00046 
00047 /*
00048 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00049 %                                                                             %
00050 %                                                                             %
00051 %                                                                             %
00052 +   D i s p l a y I m a g e C o m m a n d                                     %
00053 %                                                                             %
00054 %                                                                             %
00055 %                                                                             %
00056 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00057 %
00058 %  DisplayImageCommand() displays a sequence of images on any workstation
00059 %  display running an X server.  Display first determines the hardware
00060 %  capabilities of the workstation. If the number of unique colors in an image
00061 %  is less than or equal to the number the workstation can support, the image
00062 %  is displayed in an X window. Otherwise the number of colors in the image is
00063 %  first reduced to match the color resolution of the workstation before it is
00064 %  displayed.
00065 %
00066 %  This means that a continuous-tone 24 bits/pixel image can display on a 8
00067 %  bit pseudo-color device or monochrome device. In most instances the reduced
00068 %  color image closely resembles the original. Alternatively, a monochrome or
00069 %  pseudo-color image sequence can display on a continuous-tone 24 bits/pixels
00070 %  device.
00071 %
00072 %  The format of the DisplayImageCommand method is:
00073 %
00074 %      MagickBooleanType DisplayImageCommand(ImageInfo *image_info,int argc,
00075 %        char **argv,char **metadata,ExceptionInfo *exception)
00076 %
00077 %  A description of each parameter follows:
00078 %
00079 %    o image_info: the image info.
00080 %
00081 %    o argc: the number of elements in the argument vector.
00082 %
00083 %    o argv: A text array containing the command line arguments.
00084 %
00085 %    o metadata: any metadata is returned here.
00086 %
00087 %    o exception: return any errors or warnings in this structure.
00088 %
00089 */
00090 
00091 static void DisplayUsage(void)
00092 {
00093   const char
00094     **p;
00095 
00096   static const char
00097     *buttons[]=
00098     {
00099       "1    press to map or unmap the Command widget",
00100       "2    press and drag to magnify a region of an image",
00101       "3    press to load an image from a visual image directory",
00102       (char *) NULL
00103     },
00104     *miscellaneous[]=
00105     {
00106       "-debug events        display copious debugging information",
00107       "-help                print program options",
00108       "-list type           print a list of supported option arguments",
00109       "-log format          format of debugging information",
00110       "-version             print version information",
00111       (char *) NULL
00112     },
00113     *operators[]=
00114     {
00115       "-auto-orient         automatically orient image",
00116       "-border geometry     surround image with a border of color",
00117       "-clip                clip along the first path from the 8BIM profile",
00118       "-clip-path id        clip along a named path from the 8BIM profile",
00119       "-colors value        preferred number of colors in the image",
00120       "-contrast            enhance or reduce the image contrast",
00121       "-crop geometry       preferred size and location of the cropped image",
00122       "-decipher filename   convert cipher pixels to plain pixels",
00123       "-deskew threshold    straighten an image",
00124       "-despeckle           reduce the speckles within an image",
00125       "-edge factor         apply a filter to detect edges in the image",
00126       "-enhance             apply a digital filter to enhance a noisy image",
00127       "-extract geometry    extract area from image",
00128       "-flip                flip image in the vertical direction",
00129       "-flop                flop image in the horizontal direction",
00130       "-frame geometry      surround image with an ornamental border",
00131       "-fuzz distance       colors within this distance are considered equal",
00132       "-gamma value         level of gamma correction",
00133       "-monochrome          transform image to black and white",
00134       "-negate              replace every pixel with its complementary color",
00135       "-raise value         lighten/darken image edges to create a 3-D effect",
00136       "-resample geometry   change the resolution of an image",
00137       "-resize geometry     resize the image",
00138       "-roll geometry       roll an image vertically or horizontally",
00139       "-rotate degrees      apply Paeth rotation to the image",
00140       "-sample geometry     scale image with pixel sampling",
00141       "-segment value       segment an image",
00142       "-sharpen geometry    sharpen the image",
00143       "-strip               strip image of all profiles and comments",
00144       "-threshold value     threshold the image",
00145       "-trim                trim image edges",
00146       (char *) NULL
00147     },
00148     *settings[]=
00149     {
00150       "-alpha option        activate, deactivate, reset, or set the alpha channel",
00151       "-antialias           remove pixel-aliasing",
00152       "-authenticate password",
00153       "                     decipher image with this password",
00154       "-backdrop            display image centered on a backdrop",
00155       "-channel type        apply option to select image channels",
00156       "-colormap type       Shared or Private",
00157       "-colorspace type     alternate image colorspace",
00158       "-comment string      annotate image with comment",
00159       "-compress type       type of pixel compression when writing the image",
00160       "-define format:option",
00161       "                     define one or more image format options",
00162       "-delay value         display the next image after pausing",
00163       "-density geometry    horizontal and vertical density of the image",
00164       "-depth value         image depth",
00165       "-display server      display image to this X server",
00166       "-dispose method      layer disposal method",
00167       "-dither method       apply error diffusion to image",
00168       "-endian type         endianness (MSB or LSB) of the image",
00169       "-filter type         use this filter when resizing an image",
00170       "-format \"string\"     output formatted image characteristics",
00171       "-geometry geometry   preferred size and location of the Image window",
00172       "-identify            identify the format and characteristics of the image",
00173       "-immutable           displayed image cannot be modified",
00174       "-interlace type      type of image interlacing scheme",
00175       "-interpolate method  pixel color interpolation method",
00176       "-label string        assign a label to an image",
00177       "-limit type value    pixel cache resource limit",
00178       "-loop iterations     loop images then exit",
00179       "-map type            display image using this Standard Colormap",
00180       "-monitor             monitor progress",
00181       "-page geometry       size and location of an image canvas",
00182       "-profile filename    add, delete, or apply an image profile",
00183       "-quality value       JPEG/MIFF/PNG compression level",
00184       "-quantize colorspace reduce colors in this colorspace",
00185       "-quiet               suppress all warning messages",
00186       "-regard-warnings     pay attention to warning messages",
00187       "-remote command      execute a command in an remote display process",
00188       "-repage geometry     size and location of an image canvas (operator)",
00189       "-respect-parenthesis settings remain in effect until parenthesis boundary",
00190       "-sampling-factor geometry",
00191       "                     horizontal and vertical sampling factor",
00192       "-seed value          seed a new sequence of pseudo-random numbers",
00193       "-set property value  set an image property",
00194       "-size geometry       width and height of image",
00195       "-texture filename    name of texture to tile onto the image background",
00196       "-transparent-color color",
00197       "                     transparent color",
00198       "-treedepth value     color tree depth",
00199       "-update seconds      detect when image file is modified and redisplay",
00200       "-verbose             print detailed information about the image",
00201       "-visual type         display image using this visual type",
00202       "-virtual-pixel method",
00203       "                     virtual pixel access method",
00204       "-window id           display image to background of this window",
00205       "-window-group id     exit program when this window id is destroyed",
00206       "-write filename      write image to a file",
00207       (char *) NULL
00208     },
00209     *sequence_operators[]=
00210     {
00211       "-coalesce            merge a sequence of images",
00212       "-flatten             flatten a sequence of images",
00213       (char *) NULL
00214     };
00215 
00216   (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
00217   (void) printf("Copyright: %s\n\n",GetMagickCopyright());
00218   (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
00219     GetClientName());
00220   (void) printf("\nImage Settings:\n");
00221   for (p=settings; *p != (char *) NULL; p++)
00222     (void) printf("  %s\n",*p);
00223   (void) printf("\nImage Operators:\n");
00224   for (p=operators; *p != (char *) NULL; p++)
00225     (void) printf("  %s\n",*p);
00226   (void) printf("\nImage Sequence Operators:\n");
00227   for (p=sequence_operators; *p != (char *) NULL; p++)
00228     (void) printf("  %s\n",*p);
00229   (void) printf("\nMiscellaneous Options:\n");
00230   for (p=miscellaneous; *p != (char *) NULL; p++)
00231     (void) printf("  %s\n",*p);
00232   (void) printf(
00233     "\nIn addition to those listed above, you can specify these standard X\n");
00234   (void) printf(
00235     "resources as command line options:  -background, -bordercolor,\n");
00236   (void) printf(
00237     "-borderwidth, -font, -foreground, -iconGeometry, -iconic, -mattecolor,\n");
00238   (void) printf("-name, -shared-memory, -usePixmap, or -title.\n");
00239   (void) printf(
00240     "\nBy default, the image format of `file' is determined by its magic\n");
00241   (void) printf(
00242     "number.  To specify a particular image format, precede the filename\n");
00243   (void) printf(
00244     "with an image format name and a colon (i.e. ps:image) or specify the\n");
00245   (void) printf(
00246     "image type as the filename suffix (i.e. image.ps).  Specify 'file' as\n");
00247   (void) printf("'-' for standard input or output.\n");
00248   (void) printf("\nButtons: \n");
00249   for (p=buttons; *p != (char *) NULL; p++)
00250     (void) printf("  %s\n",*p);
00251   exit(0);
00252 }
00253 
00254 WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
00255   int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
00256 {
00257 #if defined(MAGICKCORE_X11_DELEGATE)
00258 #define DestroyDisplay() \
00259 { \
00260   if ((state & ExitState) == 0) \
00261     DestroyXResources(); \
00262   if (display != (Display *) NULL) \
00263     { \
00264       XCloseDisplay(display); \
00265       display=(Display *) NULL; \
00266     } \
00267   XDestroyResourceInfo(&resource_info); \
00268   DestroyImageStack(); \
00269   if (image_marker != (unsigned long *) NULL) \
00270     image_marker=(unsigned long *) RelinquishMagickMemory(image_marker); \
00271   for (i=0; i < (long) argc; i++) \
00272     argv[i]=DestroyString(argv[i]); \
00273   argv=(char **) RelinquishMagickMemory(argv); \
00274 }
00275 #define ThrowDisplayException(asperity,tag,option) \
00276 { \
00277   (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
00278     option); \
00279   DestroyDisplay(); \
00280   return(MagickFalse); \
00281 }
00282 #define ThrowDisplayInvalidArgumentException(option,argument) \
00283 { \
00284   (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
00285     "InvalidArgument","`%s': %s",argument,option); \
00286   DestroyDisplay(); \
00287   return(MagickFalse); \
00288 }
00289 
00290   char
00291     *resource_value,
00292     *server_name;
00293 
00294   const char
00295     *option;
00296 
00297   Display
00298     *display;
00299 
00300   Image
00301     *image;
00302 
00303   ImageStack
00304     image_stack[MaxImageStackDepth+1];
00305 
00306   long
00307     image_number,
00308     iteration,
00309     j,
00310     k,
00311     l;
00312 
00313   MagickBooleanType
00314     fire;
00315 
00316   MagickStatusType
00317     pend,
00318     status;
00319 
00320   QuantizeInfo
00321     *quantize_info;
00322 
00323   register long
00324     i;
00325 
00326   unsigned long
00327     *image_marker,
00328     iterations,
00329     last_image,
00330     state;
00331 
00332   XResourceInfo
00333     resource_info;
00334 
00335   XrmDatabase
00336     resource_database;
00337 
00338   /*
00339     Set defaults.
00340   */
00341   assert(image_info != (ImageInfo *) NULL);
00342   assert(image_info->signature == MagickSignature);
00343   if (image_info->debug != MagickFalse)
00344     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
00345   assert(exception != (ExceptionInfo *) NULL);
00346   if (argc == 2)
00347     {
00348       option=argv[1];
00349       if ((LocaleCompare("version",option+1) == 0) ||
00350           (LocaleCompare("-version",option+1) == 0))
00351         {
00352           (void) fprintf(stdout,"Version: %s\n",
00353             GetMagickVersion((unsigned long *) NULL));
00354           (void) fprintf(stdout,"Copyright: %s\n\n",GetMagickCopyright());
00355           return(MagickFalse);
00356         }
00357     }
00358   SetNotifyHandlers;
00359   display=(Display *) NULL;
00360   j=1;
00361   k=0;
00362   image_marker=(unsigned long *) NULL;
00363   image_number=0;
00364   last_image=0;
00365   NewImageStack();
00366   option=(char *) NULL;
00367   pend=MagickFalse;
00368   resource_database=(XrmDatabase) NULL;
00369   (void) ResetMagickMemory(&resource_info,0,sizeof(resource_info));
00370   server_name=(char *) NULL;
00371   state=0;
00372   status=MagickTrue;
00373   ReadCommandlLine(argc,&argv);
00374   status=ExpandFilenames(&argc,&argv);
00375   if (status == MagickFalse)
00376     ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed",
00377       strerror(errno));
00378   image_marker=(unsigned long *) AcquireQuantumMemory((size_t) argc+1UL,
00379     sizeof(*image_marker));
00380   if (image_marker == (unsigned long *) NULL)
00381     ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed",
00382       strerror(errno));
00383   for (i=0; i <= argc; i++)
00384     image_marker[i]=(unsigned long) argc;
00385   /*
00386     Check for server name specified on the command line.
00387   */
00388   for (i=1; i < (long) argc; i++)
00389   {
00390     /*
00391       Check command line for server name.
00392     */
00393     option=argv[i];
00394     if (IsMagickOption(option) == MagickFalse)
00395       continue;
00396     if (LocaleCompare("display",option+1) == 0)
00397       {
00398         /*
00399           User specified server name.
00400         */
00401         i++;
00402         if (i == (long) argc)
00403           ThrowDisplayException(OptionError,"MissingArgument",option);
00404         server_name=argv[i];
00405       }
00406     if ((LocaleCompare("help",option+1) == 0) ||
00407         (LocaleCompare("-help",option+1) == 0))
00408       DisplayUsage();
00409   }
00410   /*
00411     Get user defaults from X resource database.
00412   */
00413   display=XOpenDisplay(server_name);
00414   if (display == (Display *) NULL)
00415     ThrowDisplayException(XServerError,"UnableToOpenXServer",
00416       XDisplayName(server_name));
00417   (void) XSetErrorHandler(XError);
00418   resource_database=XGetResourceDatabase(display,GetClientName());
00419   XGetResourceInfo(image_info,resource_database,GetClientName(),
00420     &resource_info);
00421   quantize_info=resource_info.quantize_info;
00422   image_info->density=XGetResourceInstance(resource_database,GetClientName(),
00423     "density",(char *) NULL);
00424   if (image_info->density == (char *) NULL)
00425     image_info->density=XGetScreenDensity(display);
00426   resource_value=XGetResourceInstance(resource_database,GetClientName(),
00427     "interlace","none");
00428   image_info->interlace=(InterlaceType)
00429     ParseMagickOption(MagickInterlaceOptions,MagickFalse,resource_value);
00430   image_info->page=XGetResourceInstance(resource_database,GetClientName(),
00431     "pageGeometry",(char *) NULL);
00432   resource_value=XGetResourceInstance(resource_database,GetClientName(),
00433     "quality","75");
00434   image_info->quality=(unsigned long) atol(resource_value);
00435   resource_value=XGetResourceInstance(resource_database,GetClientName(),
00436     "verbose","False");
00437   image_info->verbose=IsMagickTrue(resource_value);
00438   resource_value=XGetResourceInstance(resource_database,GetClientName(),
00439     "dither","True");
00440   quantize_info->dither=IsMagickTrue(resource_value);
00441   /*
00442     Parse command line.
00443   */
00444   iteration=0;
00445   iterations=0;
00446   for (i=1; ((i <= (long) argc) && ((state & ExitState) == 0)); i++)
00447   {
00448     if (i < (long) argc)
00449       option=argv[i];
00450     else
00451       if (image != (Image *) NULL)
00452         break;
00453       else
00454         if (isatty(STDIN_FILENO) != MagickFalse)
00455           option="logo:";
00456         else
00457           {
00458             int
00459               c;
00460 
00461             c=getc(stdin);
00462             if (c == EOF)
00463               break;
00464             else
00465               {
00466                 c=ungetc(c,stdin);
00467                 option="-";
00468               }
00469           }
00470     if (LocaleCompare(option,"(") == 0)
00471       {
00472         FireImageStack(MagickFalse,MagickTrue,pend);
00473         if (k == MaxImageStackDepth)
00474           ThrowDisplayException(OptionError,"ParenthesisNestedTooDeeply",
00475             option);
00476         PushImageStack();
00477         continue;
00478       }
00479     if (LocaleCompare(option,")") == 0)
00480       {
00481         FireImageStack(MagickFalse,MagickTrue,MagickTrue);
00482         if (k == 0)
00483           ThrowDisplayException(OptionError,"UnableToParseExpression",option);
00484         PopImageStack();
00485         continue;
00486       }
00487     if (IsMagickOption(option) == MagickFalse)
00488       {
00489         const char
00490           *filename;
00491 
00492         Image
00493           *images;
00494 
00495         /*
00496           Option is a file name.
00497         */
00498         FireImageStack(MagickFalse,MagickFalse,pend);
00499         filename=option;
00500         if ((LocaleCompare(filename,"--") == 0) && (i < (argc-1)))
00501           {
00502             option=argv[++i];
00503             filename=option;
00504           }
00505         (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
00506         images=ReadImage(image_info,exception);
00507         CatchException(exception);
00508         status&=(images != (Image *) NULL) &&
00509           (exception->severity < ErrorException);
00510         if (images == (Image *) NULL)
00511           continue;
00512         AppendImageStack(images);
00513         FireImageStack(MagickFalse,MagickFalse,MagickTrue);
00514         do
00515         {
00516           /*
00517             Transmogrify image as defined by the image processing options.
00518           */
00519           resource_info.quantum=1;
00520           if (resource_info.window_id != (char *) NULL)
00521             {
00522               /*
00523                 Display image to a specified X window.
00524               */
00525               status=XDisplayBackgroundImage(display,&resource_info,image);
00526               if (status != MagickFalse)
00527                 state|=RetainColorsState;
00528             }
00529           else
00530             do
00531             {
00532               Image
00533                 *nexus;
00534 
00535               /*
00536                 Display image to X server.
00537               */
00538               nexus=XDisplayImage(display,&resource_info,argv,argc,&image,
00539                 &state);
00540               if (nexus == (Image *) NULL)
00541                 break;
00542               while ((nexus != (Image *) NULL) && ((state & ExitState) == 0))
00543               {
00544                 if (nexus->montage != (char *) NULL)
00545                   {
00546                     /*
00547                       User selected a visual directory image (montage).
00548                     */
00549                     RemoveAllImageStack()
00550                     image=nexus;
00551                     break;
00552                   }
00553                 image=XDisplayImage(display,&resource_info,argv,argc,&nexus,
00554                   &state);
00555                 if ((image == (Image *) NULL) &&
00556                     (GetNextImageInList(nexus) != (Image *) NULL))
00557                   {
00558                     RemoveAllImageStack()
00559                     image=GetNextImageInList(nexus);
00560                     nexus=NewImageList();
00561                   }
00562                 else
00563                   {
00564                     if (nexus != image)
00565                       nexus=DestroyImageList(nexus);
00566                     nexus=image;
00567                   }
00568               }
00569             } while ((state & ExitState) == 0);
00570           if (resource_info.write_filename != (char *) NULL)
00571             {
00572               /*
00573                 Write image.
00574               */
00575               (void) CopyMagickString(image->filename,
00576                 resource_info.write_filename,MaxTextExtent);
00577               (void) SetImageInfo(image_info,MagickTrue,
00578                 &image->exception);
00579               status&=WriteImage(image_info,image);
00580               GetImageException(image,exception);
00581             }
00582           /*
00583             Proceed to next/previous image.
00584           */
00585           if ((state & FormerImageState) != 0)
00586             for (l=0; l < resource_info.quantum; l++)
00587             {
00588               image=GetPreviousImageInList(image);
00589               if (image == (Image *) NULL)
00590                 break;
00591             }
00592           else
00593             for (l=0; l < resource_info.quantum; l++)
00594             {
00595               image=GetNextImageInList(image);
00596               if (image == (Image *) NULL)
00597                 break;
00598             }
00599         } while ((image != (Image *) NULL) && ((state & ExitState) == 0));
00600         /*
00601           Free image resources.
00602         */
00603         SetImageStack(image);
00604         RemoveAllImageStack();
00605         if ((state & FormerImageState) == 0)
00606           {
00607             last_image=(unsigned long) image_number;
00608             image_marker[i]=(unsigned long) image_number++;
00609           }
00610         else
00611           {
00612             /*
00613               Proceed to previous image.
00614             */
00615             for (i--; i > 0; i--)
00616               if (image_marker[i] == (unsigned long) (image_number-2))
00617                 break;
00618             image_number--;
00619           }
00620         if ((i == (long) (argc-1)) && ((state & ExitState) == 0))
00621           i=0;
00622         if ((state & ExitState) != 0)
00623           break;
00624         /*
00625           Determine if we should proceed to the first image.
00626         */
00627         if (image_number < 0)
00628           {
00629             if ((state & FormerImageState) != 0)
00630               {
00631 
00632                 for (i=1; i < (argc-2); i++)
00633                   if (last_image == image_marker[i])
00634                     break;
00635                 image_number=(long) image_marker[i]+1;
00636               }
00637             continue;
00638           }
00639         if (resource_info.window_id != (char *) NULL)
00640           state|=ExitState;
00641         if (iterations != 0)
00642           if (iteration == (long) iterations)
00643             state|=ExitState;
00644         iteration++;
00645         continue;
00646       }
00647     pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
00648     switch (*(option+1))
00649     {
00650       case 'a':
00651       {
00652         if (LocaleCompare("alpha",option+1) == 0)
00653           {
00654             long
00655               type;
00656 
00657             if (*option == '+')
00658               break;
00659             i++;
00660             if (i == (long) argc)
00661               ThrowDisplayException(OptionError,"MissingArgument",option);
00662             type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
00663             if (type < 0)
00664               ThrowDisplayException(OptionError,"UnrecognizedAlphaChannelType",
00665                 argv[i]);
00666             break;
00667           }
00668         if (LocaleCompare("antialias",option+1) == 0)
00669           break;
00670         if (LocaleCompare("authenticate",option+1) == 0)
00671           {
00672             if (*option == '+')
00673               break;
00674             i++;
00675             if (i == (long) argc)
00676               ThrowDisplayException(OptionError,"MissingArgument",option);
00677             break;
00678           }
00679         if (LocaleCompare("auto-orient",option+1) == 0)
00680           break;
00681         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
00682       }
00683       case 'b':
00684       {
00685         if (LocaleCompare("backdrop",option+1) == 0)
00686           {
00687             resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse;
00688             break;
00689           }
00690         if (LocaleCompare("background",option+1) == 0)
00691           {
00692             if (*option == '+')
00693               break;
00694             i++;
00695             if (i == (long) argc)
00696               ThrowDisplayException(OptionError,"MissingArgument",option);
00697             resource_info.background_color=argv[i];
00698             break;
00699           }
00700         if (LocaleCompare("border",option+1) == 0)
00701           {
00702             if (*option == '+')
00703               break;
00704             i++;
00705             if (i == (long) argc)
00706               ThrowDisplayException(OptionError,"MissingArgument",option);
00707             if (IsGeometry(argv[i]) == MagickFalse)
00708               ThrowDisplayInvalidArgumentException(option,argv[i]);
00709             break;
00710           }
00711         if (LocaleCompare("bordercolor",option+1) == 0)
00712           {
00713             if (*option == '+')
00714               break;
00715             i++;
00716             if (i == (long) argc)
00717               ThrowDisplayException(OptionError,"MissingArgument",option);
00718             resource_info.border_color=argv[i];
00719             break;
00720           }
00721         if (LocaleCompare("borderwidth",option+1) == 0)
00722           {
00723             resource_info.border_width=0;
00724             if (*option == '+')
00725               break;
00726             i++;
00727             if (i == (long) argc)
00728               ThrowDisplayException(OptionError,"MissingArgument",option);
00729             if (IsGeometry(argv[i]) == MagickFalse)
00730               ThrowDisplayInvalidArgumentException(option,argv[i]);
00731             resource_info.border_width=(unsigned int) atoi(argv[i]);
00732             break;
00733           }
00734         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
00735       }
00736       case 'c':
00737       {
00738         if (LocaleCompare("cache",option+1) == 0)
00739           {
00740             if (*option == '+')
00741               break;
00742             i++;
00743             if (i == (long) argc)
00744               ThrowDisplayException(OptionError,"MissingArgument",option);
00745             if (IsGeometry(argv[i]) == MagickFalse)
00746               ThrowDisplayInvalidArgumentException(option,argv[i]);
00747             break;
00748           }
00749         if (LocaleCompare("channel",option+1) == 0)
00750           {
00751             long
00752               channel;
00753 
00754             if (*option == '+')
00755               break;
00756             i++;
00757             if (i == (long) (argc-1))
00758               ThrowDisplayException(OptionError,"MissingArgument",option);
00759             channel=ParseChannelOption(argv[i]);
00760             if (channel < 0)
00761               ThrowDisplayException(OptionError,"UnrecognizedChannelType",
00762                 argv[i]);
00763             break;
00764           }
00765         if (LocaleCompare("clip",option+1) == 0)
00766           break;
00767         if (LocaleCompare("clip-path",option+1) == 0)
00768           {
00769             i++;
00770             if (i == (long) argc)
00771               ThrowDisplayException(OptionError,"MissingArgument",option);
00772             break;
00773           }
00774         if (LocaleCompare("coalesce",option+1) == 0)
00775           break;
00776         if (LocaleCompare("colormap",option+1) == 0)
00777           {
00778             resource_info.colormap=PrivateColormap;
00779             if (*option == '+')
00780               break;
00781             i++;
00782             if (i == (long) argc)
00783               ThrowDisplayException(OptionError,"MissingArgument",option);
00784             resource_info.colormap=UndefinedColormap;
00785             if (LocaleCompare("private",argv[i]) == 0)
00786               resource_info.colormap=PrivateColormap;
00787             if (LocaleCompare("shared",argv[i]) == 0)
00788               resource_info.colormap=SharedColormap;
00789             if (resource_info.colormap == UndefinedColormap)
00790               ThrowDisplayException(OptionError,"UnrecognizedColormapType",
00791                 argv[i]);
00792             break;
00793           }
00794         if (LocaleCompare("colors",option+1) == 0)
00795           {
00796             quantize_info->number_colors=0;
00797             if (*option == '+')
00798               break;
00799             i++;
00800             if (i == (long) argc)
00801               ThrowDisplayException(OptionError,"MissingArgument",option);
00802             if (IsGeometry(argv[i]) == MagickFalse)
00803               ThrowDisplayInvalidArgumentException(option,argv[i]);
00804             quantize_info->number_colors=(unsigned long) atol(argv[i]);
00805             break;
00806           }
00807         if (LocaleCompare("colorspace",option+1) == 0)
00808           {
00809             long
00810               colorspace;
00811 
00812             if (*option == '+')
00813               break;
00814             i++;
00815             if (i == (long) argc)
00816               ThrowDisplayException(OptionError,"MissingArgument",option);
00817             colorspace=ParseMagickOption(MagickColorspaceOptions,
00818               MagickFalse,argv[i]);
00819             if (colorspace < 0)
00820               ThrowDisplayException(OptionError,"UnrecognizedColorspace",
00821                 argv[i]);
00822             break;
00823           }
00824         if (LocaleCompare("comment",option+1) == 0)
00825           {
00826             if (*option == '+')
00827               break;
00828             i++;
00829             if (i == (long) argc)
00830               ThrowDisplayException(OptionError,"MissingArgument",option);
00831             break;
00832           }
00833         if (LocaleCompare("compress",option+1) == 0)
00834           {
00835             long
00836               compress;
00837 
00838             if (*option == '+')
00839               break;
00840             i++;
00841             if (i == (long) argc)
00842               ThrowDisplayException(OptionError,"MissingArgument",option);
00843             compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
00844               argv[i]);
00845             if (compress < 0)
00846               ThrowDisplayException(OptionError,"UnrecognizedImageCompression",
00847                 argv[i]);
00848             break;
00849           }
00850         if (LocaleCompare("contrast",option+1) == 0)
00851           break;
00852         if (LocaleCompare("crop",option+1) == 0)
00853           {
00854             if (*option == '+')
00855               break;
00856             i++;
00857             if (i == (long) argc)
00858               ThrowDisplayException(OptionError,"MissingArgument",option);
00859             if (IsGeometry(argv[i]) == MagickFalse)
00860               ThrowDisplayInvalidArgumentException(option,argv[i]);
00861             break;
00862           }
00863         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
00864       }
00865       case 'd':
00866       {
00867         if (LocaleCompare("debug",option+1) == 0)
00868           {
00869             long
00870               event;
00871 
00872             if (*option == '+')
00873               break;
00874             i++;
00875             if (i == (long) argc)
00876               ThrowDisplayException(OptionError,"MissingArgument",option);
00877             event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
00878             if (event < 0)
00879               ThrowDisplayException(OptionError,"UnrecognizedEventType",
00880                 argv[i]);
00881             (void) SetLogEventMask(argv[i]);
00882             break;
00883           }
00884         if (LocaleCompare("decipher",option+1) == 0)
00885           {
00886             if (*option == '+')
00887               break;
00888             i++;
00889             if (i == (long) (argc-1))
00890               ThrowDisplayException(OptionError,"MissingArgument",option);
00891             break;
00892           }
00893         if (LocaleCompare("define",option+1) == 0)
00894           {
00895             i++;
00896             if (i == (long) argc)
00897               ThrowDisplayException(OptionError,"MissingArgument",option);
00898             if (*option == '+')
00899               {
00900                 const char
00901                   *define;
00902 
00903                 define=GetImageOption(image_info,argv[i]);
00904                 if (define == (const char *) NULL)
00905                   ThrowDisplayException(OptionError,"NoSuchOption",argv[i]);
00906                 break;
00907               }
00908             break;
00909           }
00910         if (LocaleCompare("delay",option+1) == 0)
00911           {
00912             if (*option == '+')
00913               break;
00914             i++;
00915             if (i == (long) argc)
00916               ThrowDisplayException(OptionError,"MissingArgument",option);
00917             if (IsGeometry(argv[i]) == MagickFalse)
00918               ThrowDisplayInvalidArgumentException(option,argv[i]);
00919             break;
00920           }
00921         if (LocaleCompare("density",option+1) == 0)
00922           {
00923             if (*option == '+')
00924               break;
00925             i++;
00926             if (i == (long) argc)
00927               ThrowDisplayException(OptionError,"MissingArgument",option);
00928             if (IsGeometry(argv[i]) == MagickFalse)
00929               ThrowDisplayInvalidArgumentException(option,argv[i]);
00930             break;
00931           }
00932         if (LocaleCompare("depth",option+1) == 0)
00933           {
00934             if (*option == '+')
00935               break;
00936             i++;
00937             if (i == (long) argc)
00938               ThrowDisplayException(OptionError,"MissingArgument",option);
00939             if (IsGeometry(argv[i]) == MagickFalse)
00940               ThrowDisplayInvalidArgumentException(option,argv[i]);
00941             break;
00942           }
00943         if (LocaleCompare("deskew",option+1) == 0)
00944           {
00945             if (*option == '+')
00946               break;
00947             i++;
00948             if (i == (long) (argc-1))
00949               ThrowDisplayException(OptionError,"MissingArgument",option);
00950             if (IsGeometry(argv[i]) == MagickFalse)
00951               ThrowDisplayInvalidArgumentException(option,argv[i]);
00952             break;
00953           }
00954         if (LocaleCompare("despeckle",option+1) == 0)
00955           break;
00956         if (LocaleCompare("display",option+1) == 0)
00957           {
00958             if (*option == '+')
00959               break;
00960             i++;
00961             if (i == (long) argc)
00962               ThrowDisplayException(OptionError,"MissingArgument",option);
00963             break;
00964           }
00965         if (LocaleCompare("dispose",option+1) == 0)
00966           {
00967             long
00968               dispose;
00969 
00970             if (*option == '+')
00971               break;
00972             i++;
00973             if (i == (long) argc)
00974               ThrowDisplayException(OptionError,"MissingArgument",option);
00975             dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
00976             if (dispose < 0)
00977               ThrowDisplayException(OptionError,"UnrecognizedDisposeMethod",
00978                 argv[i]);
00979             break;
00980           }
00981         if (LocaleCompare("dither",option+1) == 0)
00982           {
00983             long
00984               method;
00985 
00986             quantize_info->dither=MagickFalse;
00987             if (*option == '+')
00988               break;
00989             i++;
00990             if (i == (long) argc)
00991               ThrowDisplayException(OptionError,"MissingArgument",option);
00992             method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
00993             if (method < 0)
00994               ThrowDisplayException(OptionError,"UnrecognizedDitherMethod",
00995                 argv[i]);
00996             quantize_info->dither=MagickTrue;
00997             quantize_info->dither_method=(DitherMethod) method;
00998             break;
00999           }
01000         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
01001       }
01002       case 'e':
01003       {
01004         if (LocaleCompare("edge",option+1) == 0)
01005           {
01006             if (*option == '+')
01007               break;
01008             i++;
01009             if (i == (long) argc)
01010               ThrowDisplayException(OptionError,"MissingArgument",option);
01011             if (IsGeometry(argv[i]) == MagickFalse)
01012               ThrowDisplayInvalidArgumentException(option,argv[i]);
01013             break;
01014           }
01015         if (LocaleCompare("endian",option+1) == 0)
01016           {
01017             long
01018               endian;
01019 
01020             if (*option == '+')
01021               break;
01022             i++;
01023             if (i == (long) argc)
01024               ThrowDisplayException(OptionError,"MissingArgument",option);
01025             endian=ParseMagickOption(MagickEndianOptions,MagickFalse,
01026               argv[i]);
01027             if (endian < 0)
01028               ThrowDisplayException(OptionError,"UnrecognizedEndianType",
01029                 argv[i]);
01030             break;
01031           }
01032         if (LocaleCompare("enhance",option+1) == 0)
01033           break;
01034         if (LocaleCompare("extract",option+1) == 0)
01035           {
01036             if (*option == '+')
01037               break;
01038             i++;
01039             if (i == (long) argc)
01040               ThrowDisplayException(OptionError,"MissingArgument",option);
01041             if (IsGeometry(argv[i]) == MagickFalse)
01042               ThrowDisplayInvalidArgumentException(option,argv[i]);
01043             break;
01044           }
01045         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
01046       }
01047       case 'f':
01048       {
01049         if (LocaleCompare("filter",option+1) == 0)
01050           {
01051             long
01052               filter;
01053 
01054             if (*option == '+')
01055               break;
01056             i++;
01057             if (i == (long) argc)
01058               ThrowDisplayException(OptionError,"MissingArgument",option);
01059             filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
01060             if (filter < 0)
01061               ThrowDisplayException(OptionError,"UnrecognizedImageFilter",
01062                 argv[i]);
01063             break;
01064           }
01065         if (LocaleCompare("flatten",option+1) == 0)
01066           break;
01067         if (LocaleCompare("flip",option+1) == 0)
01068           break;
01069         if (LocaleCompare("flop",option+1) == 0)
01070           break;
01071         if (LocaleCompare("font",option+1) == 0)
01072           {
01073             if (*option == '+')
01074               break;
01075             i++;
01076             if (i == (long) argc)
01077               ThrowDisplayException(OptionError,"MissingArgument",option);
01078             resource_info.font=XGetResourceClass(resource_database,
01079               GetClientName(),"font",argv[i]);
01080             break;
01081           }
01082         if (LocaleCompare("foreground",option+1) == 0)
01083           {
01084             if (*option == '+')
01085               break;
01086             i++;
01087             if (i == (long) argc)
01088               ThrowDisplayException(OptionError,"MissingArgument",option);
01089             resource_info.foreground_color=argv[i];
01090             break;
01091           }
01092         if (LocaleCompare("format",option+1) == 0)
01093           {
01094             if (*option == '+')
01095               break;
01096             i++;
01097             if (i == (long) (argc-1))
01098               ThrowDisplayException(OptionError,"MissingArgument",option);
01099             break;
01100           }
01101         if (LocaleCompare("frame",option+1) == 0)
01102           {
01103             if (*option == '+')
01104               break;
01105             i++;
01106             if (i == (long) argc)
01107               ThrowDisplayException(OptionError,"MissingArgument",option);
01108             if (IsGeometry(argv[i]) == MagickFalse)
01109               ThrowDisplayInvalidArgumentException(option,argv[i]);
01110             break;
01111           }
01112         if (LocaleCompare("fuzz",option+1) == 0)
01113           {
01114             if (*option == '+')
01115               break;
01116             i++;
01117             if (i == (long) (argc-1))
01118               ThrowDisplayException(OptionError,"MissingArgument",option);
01119             if (IsGeometry(argv[i]) == MagickFalse)
01120               ThrowDisplayInvalidArgumentException(option,argv[i]);
01121             break;
01122           }
01123         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
01124       }
01125       case 'g':
01126       {
01127         if (LocaleCompare("gamma",option+1) == 0)
01128           {
01129             i++;
01130             if (i == (long) argc)
01131               ThrowDisplayException(OptionError,"MissingArgument",option);
01132             if (IsGeometry(argv[i]) == MagickFalse)
01133               ThrowDisplayInvalidArgumentException(option,argv[i]);
01134             break;
01135           }
01136         if (LocaleCompare("geometry",option+1) == 0)
01137           {
01138             resource_info.image_geometry=(char *) NULL;
01139             if (*option == '+')
01140               break;
01141             (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
01142             i++;
01143             if (i == (long) argc)
01144               ThrowDisplayException(OptionError,"MissingArgument",option);
01145             if (IsGeometry(argv[i]) == MagickFalse)
01146               ThrowDisplayInvalidArgumentException(option,argv[i]);
01147             resource_info.image_geometry=ConstantString(argv[i]);
01148             break;
01149           }
01150         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
01151       }
01152       case 'h':
01153       {
01154         if ((LocaleCompare("help",option+1) == 0) ||
01155             (LocaleCompare("-help",option+1) == 0))
01156           break;
01157         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
01158       }
01159       case 'i':
01160       {
01161         if (LocaleCompare("identify",option+1) == 0)
01162           break;
01163         if (LocaleCompare("iconGeometry",option+1) == 0)
01164           {
01165             resource_info.icon_geometry=(char *) NULL;
01166             if (*option == '+')
01167               break;
01168             i++;
01169             if (i == (long) argc)
01170               ThrowDisplayException(OptionError,"MissingArgument",option);
01171             if (IsGeometry(argv[i]) == MagickFalse)
01172               ThrowDisplayInvalidArgumentException(option,argv[i]);
01173             resource_info.icon_geometry=argv[i];
01174             break;
01175           }
01176         if (LocaleCompare("iconic",option+1) == 0)
01177           {
01178             resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
01179             break;
01180           }
01181         if (LocaleCompare("immutable",option+1) == 0)
01182           {
01183             resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
01184             break;
01185           }
01186         if (LocaleCompare("interlace",option+1) == 0)
01187           {
01188             long
01189               interlace;
01190 
01191             if (*option == '+')
01192               break;
01193             i++;
01194             if (i == (long) argc)
01195               ThrowDisplayException(OptionError,"MissingArgument",option);
01196             interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
01197               argv[i]);
01198             if (interlace < 0)
01199               ThrowDisplayException(OptionError,"UnrecognizedInterlaceType",
01200                 argv[i]);
01201             break;
01202           }
01203         if (LocaleCompare("interpolate",option+1) == 0)
01204           {
01205             long
01206               interpolate;
01207 
01208             if (*option == '+')
01209               break;
01210             i++;
01211             if (i == (long) argc)
01212               ThrowDisplayException(OptionError,"MissingArgument",option);
01213             interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
01214               argv[i]);
01215             if (interpolate < 0)
01216               ThrowDisplayException(OptionError,"UnrecognizedInterpolateMethod",
01217                 argv[i]);
01218             break;
01219           }
01220         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
01221       }
01222       case 'l':
01223       {
01224         if (LocaleCompare("label",option+1) == 0)
01225           {
01226             if (*option == '+')
01227               break;
01228             i++;
01229             if (i == (long) argc)
01230               ThrowDisplayException(OptionError,"MissingArgument",option);
01231             break;
01232           }
01233         if (LocaleCompare("limit",option+1) == 0)
01234           {
01235             char
01236               *p;
01237 
01238             long
01239               resource;
01240 
01241             if (*option == '+')
01242               break;
01243             i++;
01244             if (i == (long) argc)
01245               ThrowDisplayException(OptionError,"MissingArgument",option);
01246             resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
01247               argv[i]);
01248             if (resource < 0)
01249               ThrowDisplayException(OptionError,"UnrecognizedResourceType",
01250                 argv[i]);
01251             i++;
01252             if (i == (long) argc)
01253               ThrowDisplayException(OptionError,"MissingArgument",option);
01254             (void) strtod(argv[i],&p);
01255             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
01256               ThrowDisplayInvalidArgumentException(option,argv[i]);
01257             break;
01258           }
01259         if (LocaleCompare("log",option+1) == 0)
01260           {
01261             if (*option == '+')
01262               break;
01263             i++;
01264             if ((i == (long) argc) ||
01265                 (strchr(argv[i],'%') == (char *) NULL))
01266               ThrowDisplayException(OptionError,"MissingArgument",option);
01267             break;
01268           }
01269         if (LocaleCompare("loop",option+1) == 0)
01270           {
01271             if (*option == '+')
01272               break;
01273             i++;
01274             if (i == (long) (argc-1))
01275               ThrowDisplayException(OptionError,"MissingArgument",option);
01276             if (IsGeometry(argv[i]) == MagickFalse)
01277               ThrowDisplayInvalidArgumentException(option,argv[i]);
01278             iterations=(unsigned long) atol(argv[i]);
01279             break;
01280           }
01281         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
01282       }
01283       case 'm':
01284       {
01285         if (LocaleCompare("magnify",option+1) == 0)
01286           {
01287             resource_info.magnify=2;
01288             if (*option == '+')
01289               break;
01290             i++;
01291             if (i == (long) argc)
01292               ThrowDisplayException(OptionError,"MissingArgument",option);
01293             if (IsGeometry(argv[i]) == MagickFalse)
01294               ThrowDisplayInvalidArgumentException(option,argv[i]);
01295             resource_info.magnify=(unsigned int) atoi(argv[i]);
01296             break;
01297           }
01298         if (LocaleCompare("map",option+1) == 0)
01299           {
01300             resource_info.map_type=(char *) NULL;
01301             if (*option == '+')
01302               break;
01303             (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
01304             i++;
01305             if (i == (long) argc)
01306               ThrowDisplayException(OptionError,"MissingArgument",option);
01307             resource_info.map_type=argv[i];
01308             break;
01309           }
01310         if (LocaleCompare("matte",option+1) == 0)
01311           break;
01312         if (LocaleCompare("mattecolor",option+1) == 0)
01313           {
01314             if (*option == '+')
01315               break;
01316             i++;
01317             if (i == (long) argc)
01318               ThrowDisplayException(OptionError,"MissingArgument",option);
01319             resource_info.matte_color=argv[i];
01320             break;
01321           }
01322         if (LocaleCompare("monitor",option+1) == 0)
01323           break;
01324         if (LocaleCompare("monochrome",option+1) == 0)
01325           {
01326             if (*option == '+')
01327               break;
01328             quantize_info->number_colors=2;
01329             quantize_info->colorspace=GRAYColorspace;
01330             break;
01331           }
01332         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
01333       }
01334       case 'n':
01335       {
01336         if (LocaleCompare("name",option+1) == 0)
01337           {
01338             resource_info.name=(char *) NULL;
01339             if (*option == '+')
01340               break;
01341             i++;
01342             if (i == (long) argc)
01343               ThrowDisplayException(OptionError,"MissingArgument",option);
01344             resource_info.name=ConstantString(argv[i]);
01345             break;
01346           }
01347         if (LocaleCompare("negate",option+1) == 0)
01348           break;
01349         if (LocaleCompare("noop",option+1) == 0)
01350           break;
01351         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
01352       }
01353       case 'p':
01354       {
01355         if (LocaleCompare("page",option+1) == 0)
01356           {
01357             resource_info.image_geometry=(char *) NULL;
01358             if (*option == '+')
01359               break;
01360             i++;
01361             if (i == (long) argc)
01362               ThrowDisplayException(OptionError,"MissingArgument",option);
01363             resource_info.image_geometry=ConstantString(argv[i]);
01364             break;
01365           }
01366         if (LocaleCompare("profile",option+1) == 0)
01367           {
01368             i++;
01369             if (i == (long) argc)
01370               ThrowDisplayException(OptionError,"MissingArgument",option);
01371             break;
01372           }
01373         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
01374       }
01375       case 'q':
01376       {
01377         if (LocaleCompare("quality",option+1) == 0)
01378           {
01379             if (*option == '+')
01380               break;
01381             i++;
01382             if (i == (long) argc)
01383               ThrowDisplayException(OptionError,"MissingArgument",option);
01384             if (IsGeometry(argv[i]) == MagickFalse)
01385               ThrowDisplayInvalidArgumentException(option,argv[i]);
01386             break;
01387           }
01388         if (LocaleCompare("quantize",option+1) == 0)
01389           {
01390             long
01391               colorspace;
01392 
01393             if (*option == '+')
01394               break;
01395             i++;
01396             if (i == (long) (argc-1))
01397               ThrowDisplayException(OptionError,"MissingArgument",option);
01398             colorspace=ParseMagickOption(MagickColorspaceOptions,
01399               MagickFalse,argv[i]);
01400             if (colorspace < 0)
01401               ThrowDisplayException(OptionError,"UnrecognizedColorspace",
01402                 argv[i]);
01403             break;
01404           }
01405         if (LocaleCompare("quiet",option+1) == 0)
01406           break;
01407         ThrowDisplayException(OptionError,"UnrecognizedOption",option);
01408       }
01409       case 'r':
01410       {
01411         if (LocaleCompare("raise",option+1) == 0)
01412           {
01413             i++;
01414             if (i == (long) argc)
01415               ThrowDisplayException(OptionError,"MissingArgument",option);
01416             if (IsGeometry(argv[i]) == MagickFalse)
01417               ThrowDisplayInvalidArgumentException(option,argv[i]);
01418             break;
01419           }
01420         if (LocaleCompare("regard-warnings",option+1) == 0)
01421           break;
01422