mogrify.c

Go to the documentation of this file.
00001 /*
00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00003 %                                                                             %
00004 %                                                                             %
00005 %                                                                             %
00006 %              M   M   OOO   GGGGG  RRRR   IIIII  FFFFF  Y   Y                %
00007 %              MM MM  O   O  G      R   R    I    F       Y Y                 %
00008 %              M M M  O   O  G GGG  RRRR     I    FFF      Y                  %
00009 %              M   M  O   O  G   G  R R      I    F        Y                  %
00010 %              M   M   OOO   GGGG   R  R   IIIII  F        Y                  %
00011 %                                                                             %
00012 %                                                                             %
00013 %                         MagickWand Module Methods                           %
00014 %                                                                             %
00015 %                              Software Design                                %
00016 %                                John Cristy                                  %
00017 %                                March 2000                                   %
00018 %                                                                             %
00019 %                                                                             %
00020 %  Copyright 1999-2009 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 %  Use the mogrify program to resize an image, blur, crop, despeckle, dither,
00037 %  draw on, flip, join, re-sample, and much more. This tool is similiar to
00038 %  convert except that the original image file is overwritten (unless you
00039 %  change the file suffix with the -format option) with any changes you
00040 %  request.
00041 %
00042 */
00043 
00044 /*
00045   Include declarations.
00046 */
00047 #include "wand/studio.h"
00048 #include "wand/MagickWand.h"
00049 #include "wand/mogrify-private.h"
00050 #include "magick/thread-private.h"
00051 
00052 /*
00053   Define declarations.
00054 */
00055 #define UndefinedCompressionQuality  0UL
00056 
00057 /*
00058   Constant declaration.
00059 */
00060 static const char
00061   BackgroundColor[] = "#fff",  /* white */
00062   BorderColor[] = "#dfdfdf",  /* gray */
00063   MatteColor[] = "#bdbdbd";  /* gray */
00064 
00065 /*
00066 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00067 %                                                                             %
00068 %                                                                             %
00069 %                                                                             %
00070 +     M a g i c k C o m m a n d G e n e s i s                                 %
00071 %                                                                             %
00072 %                                                                             %
00073 %                                                                             %
00074 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00075 %
00076 %  MagickCommandGenesis() applies image processing options to an image as
00077 %  prescribed by command line options.
00078 %
00079 %  The format of the MagickCommandGenesis method is:
00080 %
00081 %      MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
00082 %        MagickCommand command,const int argc,const char **argv,Image **image)
00083 %
00084 %  A description of each parameter follows:
00085 %
00086 %    o image_info: the image info.
00087 %
00088 %    o command: the magick command.
00089 %
00090 %    o argc: Specifies a pointer to an integer describing the number of
00091 %      elements in the argument vector.
00092 %
00093 %    o argv: Specifies a pointer to a text array containing the command line
00094 %      arguments.
00095 %
00096 %    o image: the image.
00097 %
00098 %    o exception: return any errors or warnings in this structure.
00099 %
00100 */
00101 WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info,
00102   MagickCommand command,int argc,char **argv,char **metadata,
00103   ExceptionInfo *exception)
00104 {
00105   char
00106     *option;
00107 
00108   double
00109     duration,
00110     elapsed_time,
00111     user_time;
00112 
00113   MagickBooleanType
00114     concurrent,
00115     regard_warnings,
00116     status;
00117 
00118   register long
00119     i;
00120 
00121   TimerInfo
00122     *timer;
00123 
00124   unsigned long
00125     iterations;
00126 
00127   concurrent=MagickFalse;
00128   duration=(-1.0);
00129   iterations=1;
00130   status=MagickFalse;
00131   regard_warnings=MagickFalse;
00132   for (i=1; i < (long) (argc-1); i++)
00133   {
00134     option=argv[i];
00135     if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
00136       continue;
00137     if (LocaleCompare("bench",option+1) == 0)
00138       iterations=(unsigned long) atol(argv[++i]);
00139     if (LocaleCompare("concurrent",option+1) == 0)
00140       concurrent=MagickTrue;
00141     if (LocaleCompare("debug",option+1) == 0)
00142       (void) SetLogEventMask(argv[++i]);
00143     if (LocaleCompare("duration",option+1) == 0)
00144       duration=atof(argv[++i]);
00145     if (LocaleCompare("regard-warnings",option+1) == 0)
00146       regard_warnings=MagickTrue;
00147   }
00148   timer=AcquireTimerInfo();
00149   if (concurrent == MagickFalse)
00150     {
00151       for (i=0; i < (long) iterations; i++)
00152       {
00153         if (status != MagickFalse)
00154           continue;
00155         if (duration > 0)
00156           {
00157             if (GetElapsedTime(timer) > duration)
00158               continue;
00159             (void) ContinueTimer(timer);
00160           }
00161         status=command(image_info,argc,argv,metadata,exception);
00162         if (exception->severity != UndefinedException)
00163           {
00164             if ((exception->severity > ErrorException) ||
00165                 (regard_warnings != MagickFalse))
00166               status=MagickTrue;
00167             CatchException(exception);
00168           }
00169         if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
00170           {
00171             (void) fputs(*metadata,stdout);
00172             (void) fputc('\n',stdout);
00173             *metadata=DestroyString(*metadata);
00174           }
00175       }
00176     }
00177   else
00178     {
00179       SetOpenMPNested(1);
00180 #if defined(MAGICKCORE_OPENMP_SUPPORT)
00181   # pragma omp parallel for shared(status)
00182 #endif
00183       for (i=0; i < (long) iterations; i++)
00184       {
00185         if (status != MagickFalse)
00186           continue;
00187         if (duration > 0)
00188           {
00189             if (GetElapsedTime(timer) > duration)
00190               continue;
00191             (void) ContinueTimer(timer);
00192           }
00193         status=command(image_info,argc,argv,metadata,exception);
00194 #if defined(MAGICKCORE_OPENMP_SUPPORT)
00195   # pragma omp critical (MagickCore_Launch_Command)
00196 #endif
00197         {
00198           if (exception->severity != UndefinedException)
00199             {
00200               if ((exception->severity > ErrorException) ||
00201                   (regard_warnings != MagickFalse))
00202                 status=MagickTrue;
00203               CatchException(exception);
00204             }
00205           if ((metadata != (char **) NULL) && (*metadata != (char *) NULL))
00206             {
00207               (void) fputs(*metadata,stdout);
00208               (void) fputc('\n',stdout);
00209               *metadata=DestroyString(*metadata);
00210             }
00211         }
00212       }
00213     }
00214   if (iterations > 1)
00215     {
00216       elapsed_time=GetElapsedTime(timer);
00217       user_time=GetUserTime(timer);
00218       (void) fprintf(stderr,"Performance: %lui %gips %0.3fu %ld:%02ld.%03ld\n",
00219         iterations,1.0*iterations/elapsed_time,user_time,(long)
00220         (elapsed_time/60.0),(long) floor(fmod(elapsed_time,60.0)),
00221         (long) (1000.0*(elapsed_time-floor(elapsed_time))));
00222     }
00223   timer=DestroyTimerInfo(timer);
00224   return(status);
00225 }
00226 
00227 /*
00228 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00229 %                                                                             %
00230 %                                                                             %
00231 %                                                                             %
00232 +     M o g r i f y I m a g e                                                 %
00233 %                                                                             %
00234 %                                                                             %
00235 %                                                                             %
00236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00237 %
00238 %  MogrifyImage() applies image processing options to an image as prescribed
00239 %  by command line options.
00240 %
00241 %  The format of the MogrifyImage method is:
00242 %
00243 %      MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
00244 %        const char **argv,Image **image)
00245 %
00246 %  A description of each parameter follows:
00247 %
00248 %    o image_info: the image info..
00249 %
00250 %    o argc: Specifies a pointer to an integer describing the number of
00251 %      elements in the argument vector.
00252 %
00253 %    o argv: Specifies a pointer to a text array containing the command line
00254 %      arguments.
00255 %
00256 %    o image: the image.
00257 %
00258 %    o exception: return any errors or warnings in this structure.
00259 %
00260 */
00261 
00262 static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
00263   ExceptionInfo *exception)
00264 {
00265   char
00266     key[MaxTextExtent];
00267 
00268   ExceptionInfo
00269     *sans_exception;
00270 
00271   Image
00272     *image;
00273 
00274   ImageInfo
00275     *read_info;
00276 
00277   (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path);
00278   sans_exception=AcquireExceptionInfo();
00279   image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
00280   sans_exception=DestroyExceptionInfo(sans_exception);
00281   if (image != (Image *) NULL)
00282     return(image);
00283   read_info=CloneImageInfo(image_info);
00284   (void) CopyMagickString(read_info->filename,path,MaxTextExtent);
00285   image=ReadImage(read_info,exception);
00286   read_info=DestroyImageInfo(read_info);
00287   if (image != (Image *) NULL)
00288     (void) SetImageRegistry(ImageRegistryType,key,image,exception);
00289   return(image);
00290 }
00291 
00292 static int IsPathDirectory(const char *path)
00293 {
00294   MagickBooleanType
00295     status;
00296 
00297   struct stat
00298     attributes;
00299 
00300   if ((path == (const char *) NULL) || (*path == '\0'))
00301     return(MagickFalse);
00302   status=GetPathAttributes(path,&attributes);
00303   if (status == MagickFalse)
00304     return(-1);
00305   if (S_ISDIR(attributes.st_mode) == 0)
00306     return(0);
00307   return(1);
00308 }
00309 
00310 static MagickBooleanType IsPathWritable(const char *path)
00311 {
00312   if (IsPathAccessible(path) == MagickFalse)
00313     return(MagickFalse);
00314   if (access(path,W_OK) != 0)
00315     return(MagickFalse);
00316   return(MagickTrue);
00317 }
00318 
00319 static inline long MagickMax(const long x,const long y)
00320 {
00321   if (x > y)
00322     return(x);
00323   return(y);
00324 }
00325 
00326 static MagickBooleanType MonitorProgress(const char *text,
00327   const MagickOffsetType offset,const MagickSizeType extent,
00328   void *wand_unused(client_data))
00329 {
00330   char
00331     message[MaxTextExtent],
00332     tag[MaxTextExtent];
00333 
00334   const char
00335     *locale_message;
00336 
00337   register char
00338     *p;
00339 
00340   if (extent < 2)
00341     return(MagickTrue);
00342   (void) CopyMagickMemory(tag,text,MaxTextExtent);
00343   p=strrchr(tag,'/');
00344   if (p != (char *) NULL)
00345     *p='\0';
00346   (void) FormatMagickString(message,MaxTextExtent,"Monitor/%s",tag);
00347   locale_message=GetLocaleMessage(message);
00348   if (locale_message == message)
00349     locale_message=tag;
00350   if (p == (char *) NULL)
00351     (void) fprintf(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message,
00352       (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1)));
00353   else
00354     (void) fprintf(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r",
00355       locale_message,p+1,(long) offset,(unsigned long) extent,(long)
00356       (100L*offset/(extent-1)));
00357   if (offset == (MagickOffsetType) (extent-1))
00358     (void) fprintf(stderr,"\n");
00359   (void) fflush(stderr);
00360   return(MagickTrue);
00361 }
00362 
00363 static Image *SparseColorOption(const Image *image,const ChannelType channel,
00364   const SparseColorMethod method,const char *arguments,
00365   const MagickBooleanType color_from_image,ExceptionInfo *exception)
00366 {
00367   ChannelType
00368     channels;
00369 
00370   char
00371     token[MaxTextExtent];
00372 
00373   const char
00374     *p;
00375 
00376   double
00377     *sparse_arguments;
00378 
00379   register unsigned long
00380     x;
00381 
00382   unsigned long
00383     number_arguments;
00384 
00385   unsigned long
00386     number_colors;
00387 
00388   Image
00389     *sparse_image;
00390 
00391   MagickPixelPacket
00392     color;
00393 
00394   MagickBooleanType
00395     error;
00396 
00397   assert(image != (Image *) NULL);
00398   assert(image->signature == MagickSignature);
00399   if (image->debug != MagickFalse)
00400     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
00401   assert(exception != (ExceptionInfo *) NULL);
00402   assert(exception->signature == MagickSignature);
00403   /*
00404     Limit channels according to image - and add up number of color channel.
00405   */
00406   channels=channel;
00407   if (image->colorspace != CMYKColorspace)
00408     channels=(ChannelType) (channels & ~IndexChannel);  /* no index channel */
00409   if (image->matte == MagickFalse)
00410     channels=(ChannelType) (channels & ~OpacityChannel);  /* no alpha channel */
00411   number_colors=0;
00412   if ((channels & RedChannel) != 0)
00413     number_colors++;
00414   if ((channels & GreenChannel) != 0)
00415     number_colors++;
00416   if ((channels & BlueChannel) != 0)
00417     number_colors++;
00418   if ((channels & IndexChannel) != 0)
00419     number_colors++;
00420   if ((channels & OpacityChannel) != 0)
00421     number_colors++;
00422   /*
00423     Read string, to determine number of arguments needed,
00424   */
00425   p=arguments;
00426   x=0;
00427   while( *p != '\0' )
00428   {
00429     GetMagickToken(p,&p,token);
00430     if ( token[0] == ',' ) continue;
00431     if ( isalpha((int) token[0]) || token[0] == '#' ) {
00432       if ( color_from_image ) {
00433         (void) ThrowMagickException(exception,GetMagickModule(),
00434             OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
00435             "Color arg given, when colors are coming from image");
00436         return( (Image *)NULL);
00437       }
00438       x += number_colors;  /* color argument */
00439     }
00440     else {
00441       x++;   /* floating point argument */
00442     }
00443   }
00444   error=MagickTrue;
00445   if ( color_from_image ) {
00446     /* just the control points are being given */
00447     error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse;
00448     number_arguments=(x/2)*(2+number_colors);
00449   }
00450   else {
00451     /* control points and color values */
00452     error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse;
00453     number_arguments=x;
00454   }
00455   if ( error ) {
00456     (void) ThrowMagickException(exception,GetMagickModule(),
00457                OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
00458                "Invalid number of Arguments");
00459     return( (Image *)NULL);
00460   }
00461 
00462   /* Allocate and fill in the floating point arguments */
00463   sparse_arguments=(double *) AcquireQuantumMemory(number_arguments,
00464     sizeof(*sparse_arguments));
00465   if (sparse_arguments == (double *) NULL) {
00466     (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
00467       "MemoryAllocationFailed","%s","SparseColorOption");
00468     return( (Image *)NULL);
00469   }
00470   (void) ResetMagickMemory(sparse_arguments,0,number_arguments*
00471     sizeof(*sparse_arguments));
00472   p=arguments;
00473   x=0;
00474   while( *p != '\0' && x < number_arguments ) {
00475     /* X coordinate */
00476     token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
00477     if ( token[0] == '\0' ) break;
00478     if ( isalpha((int) token[0]) || token[0] == '#' ) {
00479       (void) ThrowMagickException(exception,GetMagickModule(),
00480             OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
00481             "Color found, instead of X-coord");
00482       error = MagickTrue;
00483       break;
00484     }
00485     sparse_arguments[x++]=atof(token);
00486     /* Y coordinate */
00487     token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
00488     if ( token[0] == '\0' ) break;
00489     if ( isalpha((int) token[0]) || token[0] == '#' ) {
00490       (void) ThrowMagickException(exception,GetMagickModule(),
00491             OptionError, "InvalidArgument", "`%s': %s", "sparse-color",
00492             "Color found, instead of Y-coord");
00493       error = MagickTrue;
00494       break;
00495     }
00496     sparse_arguments[x++]=atof(token);
00497     /* color values for this control point */
00498 #if 0
00499     if ( (color_from_image ) {
00500       /* get color from image */
00501       /* HOW??? */
00502     }
00503     else
00504 #endif
00505     {
00506       /* color name or function given in string argument */
00507       token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token);
00508       if ( token[0] == '\0' ) break;
00509       if ( isalpha((int) token[0]) || token[0] == '#' ) {
00510         /* Color string given */
00511         (void) QueryMagickColor(token,&color,exception);
00512         if ( channels & RedChannel )
00513           sparse_arguments[x++] = QuantumScale*color.red;
00514         if ( channels & GreenChannel )
00515           sparse_arguments[x++] = QuantumScale*color.green;
00516         if ( channels & BlueChannel )
00517           sparse_arguments[x++] = QuantumScale*color.blue;
00518         if ( channels & IndexChannel )
00519           sparse_arguments[x++] = QuantumScale*color.index;
00520         if ( channels & OpacityChannel )
00521           sparse_arguments[x++] = QuantumScale*color.opacity;
00522       }
00523       else {
00524 #if 0
00525         /* the color name/function/value was not found - error */
00526         break;
00527 #else
00528         /* Colors given as a set of floating point values - experimental */
00529         /* NB: token contains the first floating point value to use! */
00530         if ( channels & RedChannel ) {
00531           while ( token[0] == ',' ) GetMagickToken(p,&p,token);
00532           if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
00533             break;
00534           sparse_arguments[x++] = atof(token);
00535           token[0] = ','; /* used this token - get another */
00536         }
00537         if ( channels & GreenChannel ) {
00538           while ( token[0] == ',' ) GetMagickToken(p,&p,token);
00539           if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
00540             break;
00541           sparse_arguments[x++] = atof(token);
00542           token[0] = ','; /* used this token - get another */
00543         }
00544         if ( channels & BlueChannel ) {
00545           while ( token[0] == ',' ) GetMagickToken(p,&p,token);
00546           if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
00547             break;
00548           sparse_arguments[x++] = atof(token);
00549           token[0] = ','; /* used this token - get another */
00550         }
00551         if ( channels & IndexChannel ) {
00552           while ( token[0] == ',' ) GetMagickToken(p,&p,token);
00553           if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
00554             break;
00555           sparse_arguments[x++] = atof(token);
00556           token[0] = ','; /* used this token - get another */
00557         }
00558         if ( channels & OpacityChannel ) {
00559           while ( token[0] == ',' ) GetMagickToken(p,&p,token);
00560           if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' )
00561             break;
00562           sparse_arguments[x++] = atof(token);
00563           token[0] = ','; /* used this token - get another */
00564         }
00565 #endif
00566       }
00567     }
00568   }
00569   if ( number_arguments != x && !error ) {
00570     (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
00571       "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error");
00572     sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
00573     return( (Image *)NULL);
00574   }
00575   if ( error )
00576     return( (Image *)NULL);
00577 
00578   /* Call the Interpolation function with the parsed arguments */
00579   sparse_image=SparseColorImage(image,channels,method,number_arguments,
00580     sparse_arguments,exception);
00581   sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments);
00582   return( sparse_image );
00583 }
00584 
00585 WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc,
00586   const char **argv,Image **image,ExceptionInfo *exception)
00587 {
00588   ChannelType
00589     channel;
00590 
00591   const char
00592     *format,
00593     *option;
00594 
00595   DrawInfo
00596     *draw_info;
00597 
00598   GeometryInfo
00599     geometry_info;
00600 
00601   Image
00602     *region_image;
00603 
00604   long
00605     count;
00606 
00607   MagickBooleanType
00608     status;
00609 
00610   MagickPixelPacket
00611     fill;
00612 
00613   MagickStatusType
00614     flags;
00615 
00616   QuantizeInfo
00617     *quantize_info;
00618 
00619   RectangleInfo
00620     geometry,
00621     region_geometry;
00622 
00623   register long
00624     i;
00625 
00626   /*
00627     Initialize method variables.
00628   */
00629   assert(image_info != (const ImageInfo *) NULL);
00630   assert(image_info->signature == MagickSignature);
00631   assert(image != (Image **) NULL);
00632   assert((*image)->signature == MagickSignature);
00633   if ((*image)->debug != MagickFalse)
00634     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename);
00635   if (argc < 0)
00636     return(MagickTrue);
00637   draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
00638   quantize_info=AcquireQuantizeInfo(image_info);
00639   SetGeometryInfo(&geometry_info);
00640   GetMagickPixelPacket(*image,&fill);
00641   SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL,
00642     &fill);
00643   channel=image_info->channel;
00644   format=GetImageOption(image_info,"format");
00645   SetGeometry(*image,&region_geometry);
00646   region_image=NewImageList();
00647   /*
00648     Transmogrify the image.
00649   */
00650   for (i=0; i < (long) argc; i++)
00651   {
00652     option=argv[i];
00653     if (IsMagickOption(option) == MagickFalse)
00654       continue;
00655     count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option),
00656       0L);
00657     if ((i+count) >= argc)
00658       break;
00659     status=MogrifyImageInfo(image_info,count+1,argv+i,exception);
00660     switch (*(option+1))
00661     {
00662       case 'a':
00663       {
00664         if (LocaleCompare("adaptive-blur",option+1) == 0)
00665           {
00666             Image
00667               *blur_image;
00668 
00669             /*
00670               Adaptive blur image.
00671             */
00672             (void) SyncImageSettings(image_info,*image);
00673             flags=ParseGeometry(argv[i+1],&geometry_info);
00674             if ((flags & SigmaValue) == 0)
00675               geometry_info.sigma=1.0;
00676             blur_image=AdaptiveBlurImageChannel(*image,channel,
00677               geometry_info.rho,geometry_info.sigma,exception);
00678             if (blur_image == (Image *) NULL)
00679               break;
00680             *image=DestroyImage(*image);
00681             *image=blur_image;
00682             break;
00683           }
00684         if (LocaleCompare("adaptive-resize",option+1) == 0)
00685           {
00686             Image
00687               *resize_image;
00688 
00689             /*
00690               Adaptive resize image.
00691             */
00692             (void) SyncImageSettings(image_info,*image);
00693             (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
00694             resize_image=AdaptiveResizeImage(*image,geometry.width,
00695               geometry.height,exception);
00696             if (resize_image == (Image *) NULL)
00697               break;
00698             *image=DestroyImage(*image);
00699             *image=resize_image;
00700             break;
00701           }
00702         if (LocaleCompare("adaptive-sharpen",option+1) == 0)
00703           {
00704             Image
00705               *sharp_image;
00706 
00707             /*
00708               Adaptive sharpen image.
00709             */
00710             (void) SyncImageSettings(image_info,*image);
00711             flags=ParseGeometry(argv[i+1],&geometry_info);
00712             if ((flags & SigmaValue) == 0)
00713               geometry_info.sigma=1.0;
00714             sharp_image=AdaptiveSharpenImageChannel(*image,channel,
00715               geometry_info.rho,geometry_info.sigma,exception);
00716             if (sharp_image == (Image *) NULL)
00717               break;
00718             *image=DestroyImage(*image);
00719             *image=sharp_image;
00720             break;
00721           }
00722         if (LocaleCompare("affine",option+1) == 0)
00723           {
00724             /*
00725               Affine matrix.
00726             */
00727             if (*option == '+')
00728               {
00729                 GetAffineMatrix(&draw_info->affine);
00730                 break;
00731               }
00732             (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception);
00733             break;
00734           }
00735         if (LocaleCompare("alpha",option+1) == 0)
00736           {
00737             AlphaChannelType
00738               alpha_type;
00739 
00740             (void) SyncImageSettings(image_info,*image);
00741             alpha_type=(AlphaChannelType) ParseMagickOption(MagickAlphaOptions,
00742               MagickFalse,argv[i+1]);
00743             (void) SetImageAlphaChannel(*image,alpha_type);
00744             InheritException(exception,&(*image)->exception);
00745             break;
00746           }
00747         if (LocaleCompare("annotate",option+1) == 0)
00748           {
00749             char
00750               *text,
00751               geometry[MaxTextExtent];
00752 
00753             /*
00754               Annotate image.
00755             */
00756             (void) SyncImageSettings(image_info,*image);
00757             SetGeometryInfo(&geometry_info);
00758             flags=ParseGeometry(argv[i+1],&geometry_info);
00759             if ((flags & SigmaValue) == 0)
00760               geometry_info.sigma=geometry_info.rho;
00761             text=InterpretImageProperties(image_info,*image,argv[i+2]);
00762             InheritException(exception,&(*image)->exception);
00763             if (text == (char *) NULL)
00764               break;
00765             (void) CloneString(&draw_info->text,text);
00766             text=DestroyString(text);
00767             (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f",
00768               geometry_info.xi,geometry_info.psi);
00769             (void) CloneString(&draw_info->geometry,geometry);
00770             draw_info->affine.sx=cos(DegreesToRadians(
00771               fmod(geometry_info.rho,360.0)));
00772             draw_info->affine.rx=sin(DegreesToRadians(
00773               fmod(geometry_info.rho,360.0)));
00774             draw_info->affine.ry=(-sin(DegreesToRadians(
00775               fmod(geometry_info.sigma,360.0))));
00776             draw_info->affine.sy=cos(DegreesToRadians(
00777               fmod(geometry_info.sigma,360.0)));
00778             (void) AnnotateImage(*image,draw_info);
00779             InheritException(exception,&(*image)->exception);
00780             break;
00781           }
00782         if (LocaleCompare("antialias",option+1) == 0)
00783           {
00784             draw_info->stroke_antialias=(*option == '-') ? MagickTrue :
00785               MagickFalse;
00786             draw_info->text_antialias=(*option == '-') ? MagickTrue :
00787               MagickFalse;
00788             break;
00789           }
00790         if (LocaleCompare("auto-gamma",option+1) == 0)
00791           {
00792             /*
00793               Auto Adjust Gamma of image based on its mean
00794             */
00795             (void) SyncImageSettings(image_info,*image);
00796             (void) AutoGammaImageChannel(*image,channel);
00797             break;
00798           }
00799         if (LocaleCompare("auto-level",option+1) == 0)
00800           {
00801             /*
00802               Perfectly Normalize (max/min stretch) the image
00803             */
00804             (void) SyncImageSettings(image_info,*image);
00805             (void) AutoLevelImageChannel(*image,channel);
00806             break;
00807           }
00808         if (LocaleCompare("auto-orient",option+1) == 0)
00809           {
00810             Image
00811               *orient_image;
00812 
00813             (void) SyncImageSettings(image_info,*image);
00814             orient_image=NewImageList();
00815             switch ((*image)->orientation)
00816             {
00817               case TopRightOrientation:
00818               {
00819                 orient_image=FlopImage(*image,exception);
00820                 break;
00821               }
00822               case BottomRightOrientation:
00823               {
00824                 orient_image=RotateImage(*image,180.0,exception);
00825                 break;
00826               }
00827               case BottomLeftOrientation:
00828               {
00829                 orient_image=FlipImage(*image,exception);
00830                 break;
00831               }
00832               case LeftTopOrientation:
00833               {
00834                 orient_image=TransposeImage(*image,exception);
00835                 break;
00836               }
00837               case RightTopOrientation:
00838               {
00839                 orient_image=RotateImage(*image,90.0,exception);
00840                 break;
00841               }
00842               case RightBottomOrientation:
00843               {
00844                 orient_image=TransverseImage(*image,exception);
00845                 break;
00846               }
00847               case LeftBottomOrientation:
00848               {
00849                 orient_image=RotateImage(*image,270.0,exception);
00850                 break;
00851               }
00852               default:
00853                 break;
00854             }
00855             if (orient_image == (Image *) NULL)
00856               break;
00857             orient_image->orientation=TopLeftOrientation;
00858             *image=DestroyImage(*image);
00859             *image=orient_image;
00860             break;
00861           }
00862         break;
00863       }
00864       case 'b':
00865       {
00866         if (LocaleCompare("black-threshold",option+1) == 0)
00867           {
00868             /*
00869               Black threshold image.
00870             */
00871             (void) SyncImageSettings(image_info,*image);
00872             (void) BlackThresholdImageChannel(*image,channel,argv[i+1],
00873               exception);
00874             InheritException(exception,&(*image)->exception);
00875             break;
00876           }
00877         if (LocaleCompare("blue-shift",option+1) == 0)
00878           {
00879             Image
00880               *shift_image;
00881 
00882             /*
00883               Blue shift image.
00884             */
00885             (void) SyncImageSettings(image_info,*image);
00886             geometry_info.rho=1.5;
00887             if (*option == '-')
00888               flags=ParseGeometry(argv[i+1],&geometry_info);
00889             shift_image=BlueShiftImage(*image,geometry_info.rho,exception);
00890             if (shift_image == (Image *) NULL)
00891               break;
00892             *image=DestroyImage(*image);
00893             *image=shift_image;
00894             break;
00895           }
00896         if (LocaleCompare("blur",option+1) == 0)
00897           {
00898             Image
00899               *blur_image;
00900 
00901             /*
00902               Gaussian blur image.
00903             */
00904             (void) SyncImageSettings(image_info,*image);
00905             flags=ParseGeometry(argv[i+1],&geometry_info);
00906             if ((flags & SigmaValue) == 0)
00907               geometry_info.sigma=1.0;
00908             blur_image=BlurImageChannel(*image,channel,geometry_info.rho,
00909               geometry_info.sigma,exception);
00910             if (blur_image == (Image *) NULL)
00911               break;
00912             *image=DestroyImage(*image);
00913             *image=blur_image;
00914             break;
00915           }
00916         if (LocaleCompare("border",option+1) == 0)
00917           {
00918             Image
00919               *border_image;
00920 
00921             /*
00922               Surround image with a border of solid color.
00923             */
00924             (void) SyncImageSettings(image_info,*image);
00925             flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
00926             if ((flags & SigmaValue) == 0)
00927               geometry.height=geometry.width;
00928             border_image=BorderImage(*image,&geometry,exception);
00929             if (border_image == (Image *) NULL)
00930               break;
00931             *image=DestroyImage(*image);
00932             *image=border_image;
00933             break;
00934           }
00935         if (LocaleCompare("bordercolor",option+1) == 0)
00936           {
00937             if (*option == '+')
00938               {
00939                 (void) QueryColorDatabase(BorderColor,&draw_info->border_color,
00940                   exception);
00941                 break;
00942               }
00943             (void) QueryColorDatabase(argv[i+1],&draw_info->border_color,
00944               exception);
00945             break;
00946           }
00947         if (LocaleCompare("box",option+1) == 0)
00948           {
00949             (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
00950               exception);
00951             break;
00952           }
00953         break;
00954       }
00955       case 'c':
00956       {
00957         if (LocaleCompare("cdl",option+1) == 0)
00958           {
00959             char
00960               *color_correction_collection;
00961 
00962             /*
00963               Color correct with a color decision list.
00964             */
00965             (void) SyncImageSettings(image_info,*image);
00966             color_correction_collection=FileToString(argv[i+1],~0,exception);
00967             if (color_correction_collection == (char *) NULL)
00968               break;
00969             (void) ColorDecisionListImage(*image,color_correction_collection);
00970             InheritException(exception,&(*image)->exception);
00971             break;
00972           }
00973         if (LocaleCompare("channel",option+1) == 0)
00974           {
00975             if (*option == '+')
00976               {
00977                 channel=DefaultChannels;
00978                 break;
00979               }
00980             channel=(ChannelType) ParseChannelOption(argv[i+1]);
00981             break;
00982           }
00983         if (LocaleCompare("charcoal",option+1) == 0)
00984           {
00985             Image
00986               *charcoal_image;
00987 
00988             /*
00989               Charcoal image.
00990             */
00991             (void) SyncImageSettings(image_info,*image);
00992             flags=ParseGeometry(argv[i+1],&geometry_info);
00993             if ((flags & SigmaValue) == 0)
00994               geometry_info.sigma=1.0;
00995             charcoal_image=CharcoalImage(*image,geometry_info.rho,
00996               geometry_info.sigma,exception);
00997             if (charcoal_image == (Image *) NULL)
00998               break;
00999             *image=DestroyImage(*image);
01000             *image=charcoal_image;
01001             break;
01002           }
01003         if (LocaleCompare("chop",option+1) == 0)
01004           {
01005             Image
01006               *chop_image;
01007 
01008             /*
01009               Chop the image.
01010             */
01011             (void) SyncImageSettings(image_info,*image);
01012             (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
01013             chop_image=ChopImage(*image,&geometry,exception);
01014             if (chop_image == (Image *) NULL)
01015               break;
01016             *image=DestroyImage(*image);
01017             *image=chop_image;
01018             break;
01019           }
01020         if (LocaleCompare("clamp",option+1) == 0)
01021           {
01022             /*
01023               Clamp image.
01024             */
01025             (void) SyncImageSettings(image_info,*image);
01026             (void) ClampImageChannel(*image,channel);
01027             InheritException(exception,&(*image)->exception);
01028             break;
01029           }
01030         if (LocaleCompare("clip",option+1) == 0)
01031           {
01032             (void) SyncImageSettings(image_info,*image);
01033             if (*option == '+')
01034               {
01035                 (void) SetImageClipMask(*image,(Image *) NULL);
01036                 InheritException(exception,&(*image)->exception);
01037                 break;
01038               }
01039             (void) ClipImage(*image);
01040             InheritException(exception,&(*image)->exception);
01041             break;
01042           }
01043         if (LocaleCompare("clip-mask",option+1) == 0)
01044           {
01045             Image
01046               *mask;
01047 
01048             long
01049               y;
01050 
01051             register long
01052               x;
01053 
01054             register PixelPacket
01055               *__restrict q;
01056 
01057             (void) SyncImageSettings(image_info,*image);
01058             if (*option == '+')
01059               {
01060                 /*
01061                   Remove a mask.
01062                 */
01063                 (void) SetImageMask(*image,(Image *) NULL);
01064                 InheritException(exception,&(*image)->exception);
01065                 break;
01066               }
01067             /*
01068               Set the image mask.
01069             */
01070             mask=GetImageCache(image_info,argv[i+1],exception);
01071             if (mask == (Image *) NULL)
01072               break;
01073             for (y=0; y < (long) mask->rows; y++)
01074             {
01075               q=GetAuthenticPixels(mask,0,y,mask->columns,1,exception);
01076               if (q == (PixelPacket *) NULL)
01077                 break;
01078               for (x=0; x < (long) mask->columns; x++)
01079               {
01080                 if (mask->matte == MagickFalse)
01081                   q->opacity=PixelIntensityToQuantum(q);
01082                 q->red=q->opacity;
01083                 q->green=q->opacity;
01084                 q->blue=q->opacity;
01085                 q++;
01086               }
01087               if (SyncAuthenticPixels(mask,exception) == MagickFalse)
01088                 break;
01089             }
01090             if (SetImageStorageClass(mask,DirectClass) == MagickFalse)
01091               return(MagickFalse);
01092             mask->matte=MagickTrue;
01093             (void) SetImageClipMask(*image,mask);
01094             mask=DestroyImage(mask);
01095             InheritException(exception,&(*image)->exception);
01096             break;
01097           }
01098         if (LocaleCompare("clip-path",option+1) == 0)
01099           {
01100             (void) SyncImageSettings(image_info,*image);
01101             (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue :
01102               MagickFalse);
01103             InheritException(exception,&(*image)->exception);
01104             break;
01105           }
01106         if (LocaleCompare("colorize",option+1) == 0)
01107           {
01108             Image
01109               *colorize_image;
01110 
01111             /*
01112               Colorize the image.
01113             */
01114             (void) SyncImageSettings(image_info,*image);
01115             colorize_image=ColorizeImage(*image,argv[i+1],draw_info->fill,
01116               exception);
01117             if (colorize_image == (Image *) NULL)
01118               break;
01119             *image=DestroyImage(*image);
01120             *image=colorize_image;
01121             break;
01122           }
01123         if (LocaleCompare("colors",option+1) == 0)
01124           {
01125             /*
01126               Reduce the number of colors in the image.
01127             */
01128             (void) SyncImageSettings(image_info,*image);
01129             quantize_info->number_colors=(unsigned long) atol(argv[i+1]);
01130             if (quantize_info->number_colors == 0)
01131               break;
01132             if (((*image)->storage_class == DirectClass) ||
01133                 (*image)->colors > quantize_info->number_colors)
01134               (void) QuantizeImage(quantize_info,*image);
01135             else
01136               (void) CompressImageColormap(*image);
01137             InheritException(exception,&(*image)->exception);
01138             break;
01139           }
01140         if (LocaleCompare("colorspace",option+1) == 0)
01141           {
01142             ColorspaceType
01143               colorspace;
01144 
01145             (void) SyncImageSettings(image_info,*image);
01146             if (*option == '+')
01147               {
01148                 (void) TransformImageColorspace(*image,RGBColorspace);
01149                 InheritException(exception,&(*image)->exception);
01150                 break;
01151               }
01152             colorspace=(ColorspaceType) ParseMagickOption(
01153               MagickColorspaceOptions,MagickFalse,argv[i+1]);
01154             (void) TransformImageColorspace(*image,colorspace);
01155             InheritException(exception,&(*image)->exception);
01156             break;
01157           }
01158         if (LocaleCompare("contrast",option+1) == 0)
01159           {
01160             (void) SyncImageSettings(image_info,*image);
01161             (void) ContrastImage(*image,(*option == '-') ? MagickTrue :
01162               MagickFalse);
01163             InheritException(exception,&(*image)->exception);
01164             break;
01165           }
01166         if (LocaleCompare("contrast-stretch",option+1) == 0)
01167           {
01168             double
01169               black_point,
01170               white_point;
01171 
01172             GeometryInfo
01173               geometry_info;
01174 
01175             MagickStatusType
01176               flags;
01177 
01178             /*
01179               Contrast stretch image.
01180             */
01181             (void) SyncImageSettings(image_info,*image);
01182             flags=ParseGeometry(argv[i+1],&geometry_info);
01183             black_point=geometry_info.rho;
01184             white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
01185               black_point;
01186             if ((flags & PercentValue) != 0)
01187               {
01188                 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
01189                 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
01190               }
01191             white_point=(MagickRealType) (*image)->columns*(*image)->rows-
01192               white_point;
01193             (void) ContrastStretchImageChannel(*image,channel,black_point,
01194               white_point);
01195             InheritException(exception,&(*image)->exception);
01196             break;
01197           }
01198         if (LocaleCompare("convolve",option+1) == 0)
01199           {
01200             char
01201               token[MaxTextExtent];
01202 
01203             const char
01204               *p;
01205 
01206             double
01207               *kernel;
01208 
01209             Image
01210               *convolve_image;
01211 
01212             register long
01213               x;
01214 
01215             unsigned long
01216               order;
01217 
01218             /*
01219               Convolve image.
01220             */
01221             (void) SyncImageSettings(image_info,*image);
01222             p=(const char *) argv[i+1];
01223             for (x=0; *p != '\0'; x++)
01224             {
01225               GetMagickToken(p,&p,token);
01226               if (*token == ',')
01227                 GetMagickToken(p,&p,token);
01228             }
01229             order=(unsigned long) sqrt((double) x+1.0);
01230             kernel=(double *) AcquireQuantumMemory(order,order*sizeof(*kernel));
01231             if (kernel == (double *) NULL)
01232               ThrowWandFatalException(ResourceLimitFatalError,
01233                 "MemoryAllocationFailed",(*image)->filename);
01234             p=(const char *) argv[i+1];
01235             for (x=0; (x < (long) (order*order)) && (*p != '\0'); x++)
01236             {
01237               GetMagickToken(p,&p,token);
01238               if (*token == ',')
01239                 GetMagickToken(p,&p,token);
01240               kernel[x]=atof(token);
01241             }
01242             for ( ; x < (long) (order*order); x++)
01243               kernel[x]=0.0;
01244             convolve_image=ConvolveImageChannel(*image,channel,order,kernel,
01245               exception);
01246             kernel=(double *) RelinquishMagickMemory(kernel);
01247             if (convolve_image == (Image *) NULL)
01248               break;
01249             *image=DestroyImage(*image);
01250             *image=convolve_image;
01251             break;
01252           }
01253         if (LocaleCompare("crop",option+1) == 0)
01254           {
01255             (void) SyncImageSettings(image_info,*image);
01256             flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
01257             if (((geometry.width != 0) || (geometry.height != 0)) &&
01258                 ((flags & XValue) == 0) && ((flags & YValue) == 0))
01259               break;
01260             (void) TransformImage(image,argv[i+1],(char *) NULL);
01261             InheritException(exception,&(*image)->exception);
01262             break;
01263           }
01264         if (LocaleCompare("cycle",option+1) == 0)
01265           {
01266             /*
01267               Cycle an image colormap.
01268             */
01269             (void) SyncImageSettings(image_info,*image);
01270             (void) CycleColormapImage(*image,atoi(argv[i+1]));
01271             InheritException(exception,&(*image)->exception);
01272             break;
01273           }
01274         break;
01275       }
01276       case 'd':
01277       {
01278         if (LocaleCompare("decipher",option+1) == 0)
01279           {
01280             StringInfo
01281               *passkey;
01282 
01283             /*
01284               Decipher pixels.
01285             */
01286             (void) SyncImageSettings(image_info,*image);
01287             passkey=FileToStringInfo(argv[i+1],~0,exception);
01288             if (passkey != (StringInfo *) NULL)
01289               {
01290                 (void) PasskeyDecipherImage(*image,passkey,exception);
01291                 passkey=DestroyStringInfo(passkey);
01292               }
01293             break;
01294           }
01295         if (LocaleCompare("density",option+1) == 0)
01296           {
01297             /*
01298               Set image density.
01299             */
01300             (void) CloneString(&draw_info->density,argv[i+1]);
01301             break;
01302           }
01303         if (LocaleCompare("depth",option+1) == 0)
01304           {
01305             (void) SyncImageSettings(image_info,*image);
01306             if (*option == '+')
01307               {
01308                 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH);
01309                 break;
01310               }
01311             (void) SetImageDepth(*image,(unsigned long) atol(argv[i+1]));
01312             break;
01313           }
01314         if (LocaleCompare("deskew",option+1) == 0)
01315           {
01316             double
01317               threshold;
01318 
01319             Image
01320               *deskew_image;
01321 
01322             /*
01323               Straighten the image.
01324             */
01325             (void) SyncImageSettings(image_info,*image);
01326             if (*option == '+')
01327               threshold=40.0*QuantumRange/100.0;
01328             else
01329               threshold=StringToDouble(argv[i+1],QuantumRange);
01330             deskew_image=DeskewImage(*image,threshold,exception);
01331             if (deskew_image == (Image *) NULL)
01332               break;
01333             *image=DestroyImage(*image);
01334             *image=deskew_image;
01335             break;
01336           }
01337         if (LocaleCompare("despeckle",option+1) == 0)
01338           {
01339             Image
01340               *despeckle_image;
01341 
01342             /*
01343               Reduce the speckles within an image.
01344             */
01345             (void) SyncImageSettings(image_info,*image);
01346             despeckle_image=DespeckleImage(*image,exception);
01347             if (despeckle_image == (Image *) NULL)
01348               break;
01349             *image=DestroyImage(*image);
01350             *image=despeckle_image;
01351             break;
01352           }
01353         if (LocaleCompare("display",option+1) == 0)
01354           {
01355             (void) CloneString(&draw_info->server_name,argv[i+1]);
01356             break;
01357           }
01358         if (LocaleCompare("distort",option+1) == 0)
01359           {
01360             char
01361               *args,
01362               token[MaxTextExtent];
01363 
01364             const char
01365               *p;
01366 
01367             DistortImageMethod
01368               method;
01369 
01370             double
01371               *arguments;
01372 
01373             Image
01374               *distort_image;
01375 
01376             register long
01377               x;
01378 
01379             unsigned long
01380               number_arguments;
01381 
01382             /*
01383               Distort image.
01384             */
01385             (void) SyncImageSettings(image_info,*image);
01386             method=(DistortImageMethod) ParseMagickOption(MagickDistortOptions,
01387               MagickFalse,argv[i+1]);
01388             args=InterpretImageProperties(image_info,*image,argv[i+2]);
01389             InheritException(exception,&(*image)->exception);
01390             if (args == (char *) NULL)
01391               break;
01392             p=(char *) args;
01393             for (x=0; *p != '\0'; x++)
01394             {
01395               GetMagickToken(p,&p,token);
01396               if (*token == ',')
01397                 GetMagickToken(p,&p,token);
01398             }
01399             number_arguments=(unsigned long) x;
01400             arguments=(double *) AcquireQuantumMemory(number_arguments,
01401               sizeof(*arguments));
01402             if (arguments == (double *) NULL)
01403               ThrowWandFatalException(ResourceLimitFatalError,
01404                 "MemoryAllocationFailed",(*image)->filename);
01405             (void) ResetMagickMemory(arguments,0,number_arguments*
01406               sizeof(*arguments));
01407             p=(char *) args;
01408             for (x=0; (x < (long) number_arguments) && (*p != '\0'); x++)
01409             {
01410               GetMagickToken(p,&p,token);
01411               if (*token == ',')
01412                 GetMagickToken(p,&p,token);
01413               arguments[x]=atof(token);
01414             }
01415             args=DestroyString(args);
01416             distort_image=DistortImage(*image,method,number_arguments,arguments,
01417               (*option == '+') ? MagickTrue : MagickFalse,exception);
01418             arguments=(double *) RelinquishMagickMemory(arguments);
01419             if (distort_image == (Image *) NULL)
01420               break;
01421             *image=DestroyImage(*image);
01422             *image=distort_image;
01423             break;
01424           }
01425         if (LocaleCompare("dither",option+1) == 0)
01426           {
01427             if (*option == '+')
01428               {
01429                 quantize_info->dither=MagickFalse;
01430                 break;
01431               }
01432             quantize_info->dither=MagickTrue;
01433             quantize_info->dither_method=(DitherMethod) ParseMagickOption(
01434               MagickDitherOptions,MagickFalse,argv[i+1]);
01435             if (quantize_info->dither_method == NoDitherMethod)
01436               quantize_info->dither=MagickFalse;
01437             break;
01438           }
01439         if (LocaleCompare("draw",option+1) == 0)
01440           {
01441             /*
01442               Draw image.
01443             */
01444             (void) SyncImageSettings(image_info,*image);
01445             (void) CloneString(&draw_info->primitive,argv[i+1]);
01446             (void) DrawImage(*image,draw_info);
01447             InheritException(exception,&(*image)->exception);
01448             break;
01449           }
01450         break;
01451       }
01452       case 'e':
01453       {
01454         if (LocaleCompare("edge",option+1) == 0)
01455           {
01456             Image
01457               *edge_image;
01458 
01459             /*
01460               Enhance edges in the image.
01461             */
01462             (void) SyncImageSettings(image_info,*image);
01463             flags=ParseGeometry(argv[i+1],&geometry_info);
01464             if ((flags & SigmaValue) == 0)
01465               geometry_info.sigma=1.0;
01466             edge_image=EdgeImage(*image,geometry_info.rho,exception);
01467             if (edge_image == (Image *) NULL)
01468               break;
01469             *image=DestroyImage(*image);
01470             *image=edge_image;
01471             break;
01472           }
01473         if (LocaleCompare("emboss",option+1) == 0)
01474           {
01475             Image
01476               *emboss_image;
01477 
01478             /*
01479               Gaussian embossen image.
01480             */
01481             (void) SyncImageSettings(image_info,*image);
01482             flags=ParseGeometry(argv[i+1],&geometry_info);
01483             if ((flags & SigmaValue) == 0)
01484               geometry_info.sigma=1.0;
01485             emboss_image=EmbossImage(*image,geometry_info.rho,
01486               geometry_info.sigma,exception);
01487             if (emboss_image == (Image *) NULL)
01488               break;
01489             *image=DestroyImage(*image);
01490             *image=emboss_image;
01491             break;
01492           }
01493         if (LocaleCompare("encipher",option+1) == 0)
01494           {
01495             StringInfo
01496               *passkey;
01497 
01498             /*
01499               Encipher pixels.
01500             */
01501             (void) SyncImageSettings(image_info,*image);
01502             passkey=FileToStringInfo(argv[i+1],~0,exception);
01503             if (passkey != (StringInfo *) NULL)
01504               {
01505                 (void) PasskeyEncipherImage(*image,passkey,exception);
01506                 passkey=DestroyStringInfo(passkey);
01507               }
01508             break;
01509           }
01510         if (LocaleCompare("encoding",option+1) == 0)
01511           {
01512             (void) CloneString(&draw_info->encoding,argv[i+1]);
01513             break;
01514           }
01515         if (LocaleCompare("enhance",option+1) == 0)
01516           {
01517             Image
01518               *enhance_image;
01519 
01520             /*
01521               Enhance image.
01522             */
01523             (void) SyncImageSettings(image_info,*image);
01524             enhance_image=EnhanceImage(*image,exception);
01525             if (enhance_image == (Image *) NULL)
01526               break;
01527             *image=DestroyImage(*image);
01528             *image=enhance_image;
01529             break;
01530           }
01531         if (LocaleCompare("equalize",option+1) == 0)
01532           {
01533             /*
01534               Equalize image.
01535             */
01536             (void) SyncImageSettings(image_info,*image);
01537             (void) EqualizeImageChannel(*image,channel);
01538             InheritException(exception,&(*image)->exception);
01539             break;
01540           }
01541         if (LocaleCompare("evaluate",option+1) == 0)
01542           {
01543             double
01544               constant;
01545 
01546             MagickEvaluateOperator
01547               op;
01548 
01549             (void) SyncImageSettings(image_info,*image);
01550             op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions,
01551               MagickFalse,argv[i+1]);
01552             constant=StringToDouble(argv[i+2],QuantumRange);
01553             (void) EvaluateImageChannel(*image,channel,op,constant,exception);
01554             break;
01555           }
01556         if (LocaleCompare("extent",option+1) == 0)
01557           {
01558             Image
01559               *extent_image;
01560 
01561             /*
01562               Set the image extent.
01563             */
01564             (void) SyncImageSettings(image_info,*image);
01565             flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
01566             if ((geometry.width == 0) && (geometry.height == 0))
01567               break;
01568             geometry.x=(-geometry.x);
01569             geometry.y=(-geometry.y);
01570             extent_image=ExtentImage(*image,&geometry,exception);
01571             if (extent_image == (Image *) NULL)
01572               break;
01573             *image=DestroyImage(*image);
01574             *image=extent_image;
01575             break;
01576           }
01577         break;
01578       }
01579       case 'f':
01580       {
01581         if (LocaleCompare("family",option+1) == 0)
01582           {
01583             if (*option == '+')
01584               {
01585                 if (draw_info->family != (char *) NULL)
01586                   draw_info->family=DestroyString(draw_info->family);
01587                 break;
01588               }
01589             (void) CloneString(&draw_info->family,argv[i+1]);
01590             break;
01591           }
01592         if (LocaleCompare("fill",option+1) == 0)
01593           {
01594             ExceptionInfo
01595               *sans;
01596 
01597             GetMagickPixelPacket(*image,&fill);
01598             if (*option == '+')
01599               {
01600                 (void) QueryMagickColor("none",&fill,exception);
01601                 (void) QueryColorDatabase("none",&draw_info->fill,exception);
01602                 if (draw_info->fill_pattern != (Image *) NULL)
01603                   draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
01604                 break;
01605               }
01606             sans=AcquireExceptionInfo();
01607             (void) QueryMagickColor(argv[i+1],&fill,sans);
01608             status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans);
01609             sans=DestroyExceptionInfo(sans);
01610             if (status == MagickFalse)
01611               draw_info->fill_pattern=GetImageCache(image_info,argv[i+1],
01612                 exception);
01613             break;
01614           }
01615         if (LocaleCompare("flip",option+1) == 0)
01616           {
01617             Image
01618               *flip_image;
01619 
01620             /*
01621               Flip image scanlines.
01622             */
01623             (void) SyncImageSettings(image_info,*image);
01624             flip_image=FlipImage(*image,exception);
01625             if (flip_image == (Image *) NULL)
01626               break;
01627             *image=DestroyImage(*image);
01628             *image=flip_image;
01629             break;
01630           }
01631         if (LocaleCompare("flop",option+1) == 0)
01632           {
01633             Image
01634               *flop_image;
01635 
01636             /*
01637               Flop image scanlines.
01638             */
01639             (void) SyncImageSettings(image_info,*image);
01640             flop_image=FlopImage(*image,exception);
01641             if (flop_image == (Image *) NULL)
01642               break;
01643             *image=DestroyImage(*image);
01644             *image=flop_image;
01645             break;
01646           }
01647         if (LocaleCompare("floodfill",option+1) == 0)
01648           {
01649             MagickPixelPacket
01650               target;
01651 
01652             /*
01653               Floodfill image.
01654             */
01655             (void) SyncImageSettings(image_info,*image);
01656             (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
01657             (void) QueryMagickColor(argv[i+2],&target,exception);
01658             (void) FloodfillPaintImage(*image,channel,draw_info,&target,
01659               geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue);
01660             InheritException(exception,&(*image)->exception);
01661             break;
01662           }
01663         if (LocaleCompare("font",option+1) == 0)
01664           {
01665             if (*option == '+')
01666               {
01667                 if (draw_info->font != (char *) NULL)
01668                   draw_info->font=DestroyString(draw_info->font);
01669                 break;
01670               }
01671             (void) CloneString(&draw_info->font,argv[i+1]);
01672             break;
01673           }
01674         if (LocaleCompare("format",option+1) == 0)
01675           {
01676             format=argv[i+1];
01677             break;
01678           }
01679         if (LocaleCompare("frame",option+1) == 0)
01680           {
01681             FrameInfo
01682               frame_info;
01683 
01684             Image
01685               *frame_image;
01686 
01687             /*
01688               Surround image with an ornamental border.
01689             */
01690             (void) SyncImageSettings(image_info,*image);
01691             flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
01692             frame_info.width=geometry.width;
01693             frame_info.height=geometry.height;
01694             if ((flags & HeightValue) == 0)
01695               frame_info.height=geometry.width;
01696             frame_info.outer_bevel=geometry.x;
01697             frame_info.inner_bevel=geometry.y;
01698             frame_info.x=(long) frame_info.width;
01699             frame_info.y=(long) frame_info.height;
01700             frame_info.width=(*image)->columns+2*frame_info.width;
01701             frame_info.height=(*image)->rows+2*frame_info.height;
01702             frame_image=FrameImage(*image,&frame_info,exception);
01703             if (frame_image == (Image *) NULL)
01704               break;
01705             *image=DestroyImage(*image);
01706             *image=frame_image;
01707             break;
01708           }
01709         if (LocaleCompare("function",option+1) == 0)
01710           {
01711             char
01712               *arguments,
01713               token[MaxTextExtent];
01714 
01715             const char
01716               *p;
01717 
01718             double
01719               *parameters;
01720 
01721             MagickFunction
01722               function;
01723 
01724             register long
01725               x;
01726 
01727             unsigned long
01728               number_parameters;
01729 
01730             /*
01731               Function Modify Image Values
01732             */
01733             (void) SyncImageSettings(image_info,*image);
01734             function=(MagickFunction) ParseMagickOption(MagickFunctionOptions,
01735               MagickFalse,argv[i+1]);
01736             arguments=InterpretImageProperties(image_info,*image,argv[i+2]);
01737             InheritException(exception,&(*image)->exception);
01738             if (arguments == (char *) NULL)
01739               break;
01740             p=(char *) arguments;
01741             for (x=0; *p != '\0'; x++)
01742             {
01743               GetMagickToken(p,&p,token);
01744               if (*token == ',')
01745                 GetMagickToken(p,&p,token);
01746             }
01747             number_parameters=(unsigned long) x;
01748             parameters=(double *) AcquireQuantumMemory(number_parameters,
01749               sizeof(*parameters));
01750             if (parameters == (double *) NULL)
01751               ThrowWandFatalException(ResourceLimitFatalError,
01752                 "MemoryAllocationFailed",(*image)->filename);
01753             (void) ResetMagickMemory(parameters,0,number_parameters*
01754               sizeof(*parameters));
01755             p=(char *) arguments;
01756             for (x=0; (x < (long) number_parameters) && (*p != '\0'); x++)
01757             {
01758               GetMagickToken(p,&p,token);
01759               if (*token == ',')
01760                 GetMagickToken(p,&p,token);
01761               parameters[x]=atof(token);
01762             }
01763             arguments=DestroyString(arguments);
01764             (void) FunctionImageChannel(*image,channel,function,
01765               number_parameters,parameters,exception);
01766             parameters=(double *) RelinquishMagickMemory(parameters);
01767             break;
01768           }
01769         break;
01770       }
01771       case 'g':
01772       {
01773         if (LocaleCompare("gamma",option+1) == 0)
01774           {
01775             /*
01776               Gamma image.
01777             */
01778             (void) SyncImageSettings(image_info,*image);
01779             if (*option == '+')
01780               (*image)->gamma=atof(argv[i+1]);
01781             else
01782               {
01783                 if (strchr(argv[i+1],',') != (char *) NULL)
01784                   (void) GammaImage(*image,argv[i+1]);
01785                 else
01786                   (void) GammaImageChannel(*image,channel,atof(argv[i+1]));
01787                 InheritException(exception,&(*image)->exception);
01788               }
01789             break;
01790           }
01791         if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
01792             (LocaleCompare("gaussian",option+1) == 0))
01793           {
01794             Image
01795               *gaussian_image;
01796 
01797             /*
01798               Gaussian blur image.
01799             */
01800             (void) SyncImageSettings(image_info,*image);
01801             flags=ParseGeometry(argv[i+1],&geometry_info);
01802             if ((flags & SigmaValue) == 0)
01803               geometry_info.sigma=1.0;
01804             gaussian_image=GaussianBlurImageChannel(*image,channel,
01805               geometry_info.rho,geometry_info.sigma,exception);
01806             if (gaussian_image == (Image *) NULL)
01807               break;
01808             *image=DestroyImage(*image);
01809             *image=gaussian_image;
01810             break;
01811           }
01812         if (LocaleCompare("geometry",option+1) == 0)
01813           {
01814             (void) SyncImageSettings(image_info,*image);
01815             if (*option == '+')
01816               {
01817                 if ((*image)->geometry != (char *) NULL)
01818                   (*image)->geometry=DestroyString((*image)->geometry);
01819                 break;
01820               }
01821             flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
01822             if (((flags & XValue) != 0) || ((flags & YValue) != 0))
01823               (void) CloneString(&(*image)->geometry,argv[i+1]);
01824             else
01825               {
01826                 Image
01827                   *zoom_image;
01828 
01829                 /*
01830                   Resize image.
01831                 */
01832                 zoom_image=ZoomImage(*image,geometry.width,geometry.height,
01833                   exception);
01834                 if (zoom_image == (Image *) NULL)
01835                   break;
01836                 *image=DestroyImage(*image);
01837                 *image=zoom_image;
01838               }
01839             break;
01840           }
01841         if (LocaleCompare("gravity",option+1) == 0)
01842           {
01843             if (*option == '+')
01844               {
01845                 draw_info->gravity=UndefinedGravity;
01846                 break;
01847               }
01848             draw_info->gravity=(GravityType) ParseMagickOption(
01849               MagickGravityOptions,MagickFalse,argv[i+1]);
01850             break;
01851           }
01852         break;
01853       }
01854       case 'h':
01855       {
01856         if (LocaleCompare("highlight-color",option+1) == 0)
01857           {
01858             (void) SetImageArtifact(*image,option+1,argv[i+1]);
01859             break;
01860           }
01861         break;
01862       }
01863       case 'i':
01864       {
01865         if (LocaleCompare("identify",option+1) == 0)
01866           {
01867             char
01868               *text;
01869 
01870             (void) SyncImageSettings(image_info,*image);
01871             if (format == (char *) NULL)
01872               {
01873                 (void) IdentifyImage(*image,stdout,image_info->verbose);
01874                 InheritException(exception,&(*image)->exception);
01875                 break;
01876               }
01877             text=InterpretImageProperties(image_info,*image,format);
01878             InheritException(exception,&(*image)->exception);
01879             if (text == (char *) NULL)
01880               break;
01881             (void) fputs(text,stdout);
01882             (void) fputc('\n',stdout);
01883             text=DestroyString(text);
01884             break;
01885           }
01886         if (LocaleCompare("implode",option+1) == 0)
01887           {
01888             Image
01889               *implode_image;
01890 
01891             /*
01892               Implode image.
01893             */
01894             (void) SyncImageSettings(image_info,*image);
01895             (void) ParseGeometry(argv[i+1],&geometry_info);
01896             implode_image=ImplodeImage(*image,geometry_info.rho,exception);
01897             if (implode_image == (Image *) NULL)
01898               break;
01899             *image=DestroyImage(*image);
01900             *image=implode_image;
01901             break;
01902           }
01903         if (LocaleCompare("interline-spacing",option+1) == 0)
01904           {
01905             if (*option == '+')
01906               (void) ParseGeometry("0",&geometry_info);
01907             else
01908               (void) ParseGeometry(argv[i+1],&geometry_info);
01909             draw_info->interline_spacing=geometry_info.rho;
01910             break;
01911           }
01912         if (LocaleCompare("interword-spacing",option+1) == 0)
01913           {
01914             if (*option == '+')
01915               (void) ParseGeometry("0",&geometry_info);
01916             else
01917               (void) ParseGeometry(argv[i+1],&geometry_info);
01918             draw_info->interword_spacing=geometry_info.rho;
01919             break;
01920           }
01921         break;
01922       }
01923       case 'k':
01924       {
01925         if (LocaleCompare("kerning",option+1) == 0)
01926           {
01927             if (*option == '+')
01928               (void) ParseGeometry("0",&geometry_info);
01929             else
01930               (void) ParseGeometry(argv[i+1],&geometry_info);
01931             draw_info->kerning=geometry_info.rho;
01932             break;
01933           }
01934         break;
01935       }
01936       case 'l':
01937       {
01938         if (LocaleCompare("lat",option+1) == 0)
01939           {
01940             Image
01941               *threshold_image;
01942 
01943             /*
01944               Local adaptive threshold image.
01945             */
01946             (void) SyncImageSettings(image_info,*image);
01947             flags=ParseGeometry(argv[i+1],&geometry_info);
01948             if ((flags & PercentValue) != 0)
01949               geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
01950             threshold_image=AdaptiveThresholdImage(*image,(unsigned long)
01951               geometry_info.rho,(unsigned long) geometry_info.sigma,
01952               (long) geometry_info.xi,exception);
01953             if (threshold_image == (Image *) NULL)
01954               break;
01955             *image=DestroyImage(*image);
01956             *image=threshold_image;
01957             break;
01958           }
01959         if (LocaleCompare("level",option+1) == 0)
01960           {
01961             GeometryInfo
01962               geometry_info;
01963 
01964             MagickRealType
01965               black_point,
01966               gamma,
01967               white_point;
01968 
01969             MagickStatusType
01970               flags;
01971 
01972             /*
01973               Parse levels.
01974             */
01975             (void) SyncImageSettings(image_info,*image);
01976             flags=ParseGeometry(argv[i+1],&geometry_info);
01977             black_point=geometry_info.rho;
01978             white_point=(MagickRealType) QuantumRange;
01979             if ((flags & SigmaValue) != 0)
01980               white_point=geometry_info.sigma;
01981             gamma=1.0;
01982             if ((flags & XiValue) != 0)
01983               gamma=geometry_info.xi;
01984             if ((flags & PercentValue) != 0)
01985               {
01986                 black_point*=(MagickRealType) (QuantumRange/100.0);
01987                 white_point*=(MagickRealType) (QuantumRange/100.0);
01988               }
01989             if ((flags & SigmaValue) == 0)
01990               white_point=(MagickRealType) QuantumRange-black_point;
01991             if ((*option == '+') || ((flags & AspectValue) != 0))
01992               (void) LevelizeImageChannel(*image,channel,black_point,
01993                 white_point,gamma);
01994             else
01995               (void) LevelImageChannel(*image,channel,black_point,white_point,
01996                 gamma);
01997             InheritException(exception,&(*image)->exception);
01998             break;
01999           }
02000         if (LocaleCompare("level-colors",option+1) == 0)
02001           {
02002             char
02003               token[MaxTextExtent];
02004 
02005             const char
02006               *p;
02007 
02008             MagickPixelPacket
02009               black_point,
02010               white_point;
02011 
02012             p=(const char *) argv[i+1];
02013             GetMagickToken(p,&p,token);  /* get black point color */
02014             if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
02015               (void) QueryMagickColor(token,&black_point,exception);
02016             else
02017               (void) QueryMagickColor("#000000",&black_point,exception);
02018             if (isalpha((int) token[0]) || (token[0] == '#'))
02019               GetMagickToken(p,&p,token);
02020             if (*token == '\0')
02021               white_point=black_point; /* set everything to that color */
02022             else
02023               {
02024                 /*
02025                   Get white point color.
02026                 */
02027                 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0))
02028                   GetMagickToken(p,&p,token);
02029                 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0))
02030                   (void) QueryMagickColor(token,&white_point,exception);
02031                 else
02032                   (void) QueryMagickColor("#ffffff",&white_point,exception);
02033               }
02034             (void) LevelColorsImageChannel(*image,channel,&black_point,
02035               &white_point,*option == '+' ? MagickTrue : MagickFalse);
02036             break;
02037           }
02038         if (LocaleCompare("linear-stretch",option+1) == 0)
02039           {
02040             double
02041               black_point,
02042               white_point;
02043 
02044             GeometryInfo
02045               geometry_info;
02046 
02047             MagickStatusType
02048               flags;
02049 
02050             (void) SyncImageSettings(image_info,*image);
02051             flags=ParseGeometry(argv[i+1],&geometry_info);
02052             black_point=geometry_info.rho;
02053             white_point=(MagickRealType) (*image)->columns*(*image)->rows;
02054             if ((flags & SigmaValue) != 0)
02055               white_point=geometry_info.sigma;
02056             if ((flags & PercentValue) != 0)
02057               {
02058                 black_point*=(double) (*image)->columns*(*image)->rows/100.0;
02059                 white_point*=(double) (*image)->columns*(*image)->rows/100.0;
02060               }
02061             if ((flags & SigmaValue) == 0)
02062               white_point=(MagickRealType) (*image)->columns*(*image)->rows-
02063                 black_point;
02064             (void) LinearStretchImage(*image,black_point,white_point);
02065             InheritException(exception,&(*image)->exception);
02066             break;
02067           }
02068         if (LocaleCompare("linewidth",option+1) == 0)
02069           {
02070             draw_info->stroke_width=atof(argv[i+1]);
02071             break;
02072           }
02073         if (LocaleCompare("liquid-rescale",option+1) == 0)
02074           {
02075             Image
02076               *resize_image;
02077 
02078             /*
02079               Liquid rescale image.
02080             */
02081             (void) SyncImageSettings(image_info,*image);
02082             flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
02083             if ((flags & XValue) == 0)
02084               geometry.x=1;
02085             if ((flags & YValue) == 0)
02086               geometry.y=0;
02087             resize_image=LiquidRescaleImage(*image,geometry.width,
02088               geometry.height,1.0*geometry.x,1.0*geometry.y,exception);
02089             if (resize_image == (Image *) NULL)
02090               break;
02091             *image=DestroyImage(*image);
02092             *image=resize_image;
02093             break;
02094           }
02095         if (LocaleCompare("lowlight-color",option+1) == 0)
02096           {
02097             (void) SetImageArtifact(*image,option+1,argv[i+1]);
02098             break;
02099           }
02100         break;
02101       }
02102       case 'm':
02103       {
02104         if (LocaleCompare("map",option+1) == 0)
02105           {
02106             Image
02107               *remap_image;
02108 
02109             /*
02110               Transform image colors to match this set of colors.
02111             */
02112             (void) SyncImageSettings(image_info,*image);
02113             if (*option == '+')
02114               break;
02115             remap_image=GetImageCache(image_info,argv[i+1],exception);
02116             if (remap_image == (Image *) NULL)
02117               break;
02118             (void) RemapImage(quantize_info,*image,remap_image);
02119             InheritException(exception,&(*image)->exception);
02120             remap_image=DestroyImage(remap_image);
02121             break;
02122           }
02123         if (LocaleCompare("mask",option+1) == 0)
02124           {
02125             Image
02126               *mask;
02127 
02128             (void) SyncImageSettings(image_info,*image);
02129             if (*option == '+')
02130               {
02131                 /*
02132                   Remove a mask.
02133                 */
02134                 (void) SetImageMask(*image,(Image *) NULL);
02135                 InheritException(exception,&(*image)->exception);
02136                 break;
02137               }
02138             /*
02139               Set the image mask.
02140             */
02141             mask=GetImageCache(image_info,argv[i+1],exception);
02142             if (mask == (Image *) NULL)
02143               break;
02144             (void) SetImageMask(*image,mask);
02145             mask=DestroyImage(mask);
02146             InheritException(exception,&(*image)->exception);
02147             break;
02148           }
02149         if (LocaleCompare("matte",option+1) == 0)
02150           {
02151             (void) SetImageAlphaChannel(*image,(*option == '-') ?
02152               SetAlphaChannel : DeactivateAlphaChannel );
02153             InheritException(exception,&(*image)->exception);
02154             break;
02155           }
02156         if (LocaleCompare("median",option+1) == 0)
02157           {
02158             Image
02159               *median_image;
02160 
02161             /*
02162               Median filter image.
02163             */
02164             (void) SyncImageSettings(image_info,*image);
02165             (void) ParseGeometry(argv[i+1],&geometry_info);
02166             median_image=MedianFilterImage(*image,geometry_info.rho,exception);
02167             if (median_image == (Image *) NULL)
02168               break;
02169             *image=DestroyImage(*image);
02170             *image=median_image;
02171             break;
02172           }
02173         if (LocaleCompare("modulate",option+1) == 0)
02174           {
02175             (void) SyncImageSettings(image_info,*image);
02176             (void) ModulateImage(*image,argv[i+1]);
02177             InheritException(exception,&(*image)->exception);
02178             break;
02179           }
02180         if (LocaleCompare("monitor",option+1) == 0)
02181           {
02182             (void) SetImageProgressMonitor(*image,MonitorProgress,
02183               (void *) NULL);
02184             break;
02185           }
02186         if (LocaleCompare("monochrome",option+1) == 0)
02187           {
02188             (void) SyncImageSettings(image_info,*image);
02189             (void) SetImageType(*image,BilevelType);
02190             InheritException(exception,&(*image)->exception);
02191             break;
02192           }
02193         if (LocaleCompare("motion-blur",option+1) == 0)
02194           {
02195             Image
02196               *blur_image;
02197 
02198             /*
02199               Motion blur image.
02200             */
02201             (void) SyncImageSettings(image_info,*image);
02202             flags=ParseGeometry(argv[i+1],&geometry_info);
02203             if ((flags & SigmaValue) == 0)
02204               geometry_info.sigma=1.0;
02205             blur_image=MotionBlurImageChannel(*image,channel,geometry_info.rho,
02206               geometry_info.sigma,geometry_info.xi,exception);
02207             if (blur_image == (Image *) NULL)
02208               break;
02209             *image=DestroyImage(*image);
02210             *image=blur_image;
02211             break;
02212           }
02213         break;
02214       }
02215       case 'n':
02216       {
02217         if (LocaleCompare("negate",option+1) == 0)
02218           {
02219             (void) SyncImageSettings(image_info,*image);
02220             (void) NegateImageChannel(*image,channel,*option == '+' ?
02221               MagickTrue : MagickFalse);
02222             InheritException(exception,&(*image)->exception);
02223             break;
02224           }
02225         if (LocaleCompare("noise",option+1) == 0)
02226           {
02227             Image
02228               *noisy_image;
02229 
02230             (void) SyncImageSettings(image_info,*image);
02231             if (*option == '-')
02232               {
02233                 (void) ParseGeometry(argv[i+1],&geometry_info);
02234                 noisy_image=ReduceNoiseImage(*image,geometry_info.rho,
02235                   exception);
02236               }
02237             else
02238               {
02239                 NoiseType
02240                   noise;
02241 
02242                 noise=(NoiseType) ParseMagickOption(MagickNoiseOptions,
02243                   MagickFalse,argv[i+1]);
02244                 noisy_image=AddNoiseImageChannel(*image,channel,noise,
02245                   exception);
02246               }
02247             if (noisy_image == (Image *) NULL)
02248               break;
02249             *image=DestroyImage(*image);
02250             *image=noisy_image;
02251             break;
02252           }
02253         if (LocaleCompare("normalize",option+1) == 0)
02254           {
02255             (void) SyncImageSettings(image_info,*image);
02256             (void) NormalizeImageChannel(*image,channel);
02257             InheritException(exception,&(*image)->exception);
02258             break;
02259           }
02260         break;
02261       }
02262       case 'o':
02263       {
02264         if (LocaleCompare("opaque",option+1) == 0)
02265           {
02266             MagickPixelPacket
02267               target;
02268 
02269             (void) SyncImageSettings(image_info,*image);
02270             (void) QueryMagickColor(argv[i+1],&target,exception);
02271             (void) OpaquePaintImageChannel(*image,channel,&target,&fill,
02272               *option == '-' ? MagickFalse : MagickTrue);
02273             break;
02274           }
02275         if (LocaleCompare("ordered-dither",option+1) == 0)
02276           {
02277             (void) SyncImageSettings(image_info,*image);
02278             (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1],
02279               exception);
02280             break;
02281           }
02282         break;
02283       }
02284       case 'p':
02285       {
02286         if (LocaleCompare("paint",option+1) == 0)
02287           {
02288             Image
02289               *paint_image;
02290 
02291             /*
02292               Oil paint image.
02293             */
02294             (void) SyncImageSettings(image_info,*image);
02295             (void) ParseGeometry(argv[i+1],&geometry_info);
02296             paint_image=OilPaintImage(*image,geometry_info.rho,exception);
02297             if (paint_image == (Image *) NULL)
02298               break;
02299             *image=DestroyImage(*image);
02300             *image=paint_image;
02301             break;
02302           }
02303         if (LocaleCompare("pen",option+1) == 0)
02304           {
02305             if (*option == '+')
02306               {
02307                 (void) QueryColorDatabase("none",&draw_info->fill,exception);
02308                 break;
02309               }
02310             (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception);
02311             break;
02312           }
02313         if (LocaleCompare("pointsize",option+1) == 0)
02314           {
02315             if (*option == '+')
02316               (void) ParseGeometry("12",&geometry_info);
02317             else
02318               (void) ParseGeometry(argv[i+1],&geometry_info);
02319             draw_info->pointsize=geometry_info.rho;
02320             break;
02321           }
02322         if (LocaleCompare("polaroid",option+1) == 0)
02323           {
02324             double
02325               angle;
02326 
02327             Image
02328               *polaroid_image;
02329 
02330             RandomInfo
02331               *random_info;
02332 
02333             /*
02334               Simulate a Polaroid picture.
02335             */
02336             (void) SyncImageSettings(image_info,*image);
02337             random_info=AcquireRandomInfo();
02338             angle=22.5*(GetPseudoRandomValue(random_info)-0.5);
02339             random_info=DestroyRandomInfo(random_info);
02340             if (*option == '-')
02341               {
02342                 SetGeometryInfo(&geometry_info);
02343                 flags=ParseGeometry(argv[i+1],&geometry_info);
02344                 angle=geometry_info.rho;
02345               }
02346             polaroid_image=PolaroidImage(*image,draw_info,angle,exception);
02347             if (polaroid_image == (Image *) NULL)
02348               break;
02349             *image=DestroyImage(*image);
02350             *image=polaroid_image;
02351             break;
02352           }
02353         if (LocaleCompare("posterize",option+1) == 0)
02354           {
02355             /*
02356               Posterize image.
02357             */
02358             (void) SyncImageSettings(image_info,*image);
02359             (void) PosterizeImage(*image,(unsigned long) atol(argv[i+1]),
02360               quantize_info->dither);
02361             InheritException(exception,&(*image)->exception);
02362             break;
02363           }
02364         if (LocaleCompare("preview",option+1) == 0)
02365           {
02366             Image
02367               *preview_image;
02368 
02369             PreviewType
02370               preview_type;
02371 
02372             /*
02373               Preview image.
02374             */
02375             (void) SyncImageSettings(image_info,*image);
02376             if (*option == '+')
02377               preview_type=UndefinedPreview;
02378             else
02379               preview_type=(PreviewType) ParseMagickOption(MagickPreviewOptions,
02380                 MagickFalse,argv[i+1]);
02381             preview_image=PreviewImage(*image,preview_type,exception);
02382             if (preview_image == (Image *) NULL)
02383               break;
02384             *image=DestroyImage(*image);
02385             *image=preview_image;
02386             break;
02387           }
02388         if (LocaleCompare("profile",option+1) == 0)
02389           {
02390             const char
02391               *name;
02392 
02393             const StringInfo
02394               *profile;
02395 
02396             Image
02397               *profile_image;
02398 
02399             ImageInfo
02400               *profile_info;
02401 
02402             (void) SyncImageSettings(image_info,*image);
02403             if (*option == '+')
02404               {
02405                 /*
02406                   Remove a profile from the image.
02407                 */
02408                 (void) ProfileImage(*image,argv[i+1],(const unsigned char *)
02409                   NULL,0,MagickTrue);
02410                 InheritException(exception,&(*image)->exception);
02411                 break;
02412               }
02413             /*
02414               Associate a profile with the image.
02415             */
02416             profile_info=CloneImageInfo(image_info);
02417             profile=GetImageProfile(*image,"iptc");
02418             if (profile != (StringInfo *) NULL)
02419               profile_info->profile=(void *) CloneStringInfo(profile);
02420             profile_image=GetImageCache(profile_info,argv[i+1],exception);
02421             profile_info=DestroyImageInfo(profile_info);
02422             if (profile_image == (Image *) NULL)
02423               {
02424                 char
02425                   name[MaxTextExtent],
02426                   filename[MaxTextExtent];
02427 
02428                 register char
02429                   *p;
02430 
02431                 StringInfo
02432                   *profile;
02433 
02434                 (void) CopyMagickString(filename,argv[i+1],MaxTextExtent);
02435                 (void) CopyMagickString(name,argv[i+1],MaxTextExtent);
02436                 for (p=filename; *p != '\0'; p++)
02437                   if ((*p == ':') && (IsPathDirectory(argv[i+1]) < 0) &&
02438                       (IsPathAccessible(argv[i+1]) == MagickFalse))
02439                     {
02440                       register char
02441                         *q;
02442 
02443                       /*
02444                         Look for profile name (e.g. name:profile).
02445                       */
02446                       (void) CopyMagickString(name,filename,(size_t)
02447                         (p-filename+1));
02448                       for (q=filename; *q != '\0'; q++)
02449                         *q=(*++p);
02450                       break;
02451                     }
02452                 profile=FileToStringInfo(filename,~0UL,exception);
02453                 if (profile != (StringInfo *) NULL)
02454                   {
02455                     (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
02456                       (unsigned long) GetStringInfoLength(profile),MagickFalse);
02457                     profile=DestroyStringInfo(profile);
02458                   }
02459                 break;
02460               }
02461             ResetImageProfileIterator(profile_image);
02462             name=GetNextImageProfile(profile_image);
02463             while (name != (const char *) NULL)
02464             {
02465               profile=GetImageProfile(profile_image,name);
02466               if (profile != (StringInfo *) NULL)
02467                 (void) ProfileImage(*image,name,GetStringInfoDatum(profile),
02468                   (unsigned long) GetStringInfoLength(profile),MagickFalse);
02469               name=GetNextImageProfile(profile_image);
02470             }
02471             profile_image=DestroyImage(profile_image);
02472             break;
02473           }
02474         break;
02475       }
02476       case 'q':
02477       {
02478         if (LocaleCompare("quantize",option+1) == 0)
02479           {
02480             if (*option == '+')
02481               {
02482                 quantize_info->colorspace=UndefinedColorspace;
02483                 break;
02484               }
02485             quantize_info->colorspace=(ColorspaceType) ParseMagickOption(
02486               MagickColorspaceOptions,MagickFalse,argv[i+1]);
02487             break;
02488           }
02489         break;
02490       }
02491       case 'r':
02492       {
02493         if (LocaleCompare("radial-blur",option+1) == 0)
02494           {
02495             Image
02496               *blur_image;
02497 
02498             /*
02499               Radial blur image.
02500             */
02501             (void) SyncImageSettings(image_info,*image);
02502             blur_image=RadialBlurImageChannel(*image,channel,atof(argv[i+1]),
02503               exception);
02504             if (blur_image == (Image *) NULL)
02505               break;
02506             *image=DestroyImage(*image);
02507             *image=blur_image;
02508             break;
02509           }
02510         if (LocaleCompare("raise",option+1) == 0)
02511           {
02512             /*
02513               Surround image with a raise of solid color.
02514             */
02515             flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
02516             if ((flags & SigmaValue) == 0)
02517               geometry.height=geometry.width;
02518             (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue :
02519               MagickFalse);
02520             InheritException(exception,&(*image)->exception);
02521             break;
02522           }
02523         if (LocaleCompare("random-threshold",option+1) == 0)
02524           {
02525             /*
02526               Threshold image.
02527             */
02528             (void) SyncImageSettings(image_info,*image);
02529             (void) RandomThresholdImageChannel(*image,channel,argv[i+1],
02530               exception);
02531             break;
02532           }
02533         if (LocaleCompare("recolor",option+1) == 0)
02534           {
02535             char
02536               token[MaxTextExtent];
02537 
02538             const char
02539               *p;
02540 
02541             double
02542               *color_matrix;
02543 
02544             Image
02545               *recolor_image;
02546 
02547             register long
02548               x;
02549 
02550             unsigned long
02551               order;
02552 
02553             /*
02554               Transform color image.
02555             */
02556             (void) SyncImageSettings(image_info,*image);
02557             p=argv[i+1];
02558             for (x=0; *p != '\0'; x++)
02559             {
02560               GetMagickToken(p,&p,token);
02561               if (*token == ',')
02562                 GetMagickToken(p,&p,token);
02563             }
02564             order=(unsigned long) sqrt((double) x+1.0);
02565             color_matrix=(double *) AcquireQuantumMemory(order,order*
02566               sizeof(*color_matrix));
02567             if (color_matrix == (double *) NULL)
02568               ThrowWandFatalException(ResourceLimitFatalError,
02569                 "MemoryAllocationFailed",(*image)->filename);
02570             p=argv[i+1];
02571             for (x=0; (x < (long) (order*order)) && (*p != '\0'); x++)
02572             {
02573               GetMagickToken(p,&p,token);
02574               if (*token == ',')
02575                 GetMagickToken(p,&p,token);
02576               color_matrix[x]=atof(token);
02577             }
02578             for ( ; x < (long) (order*order); x++)
02579               color_matrix[x]=0.0;
02580             recolor_image=RecolorImage(*image,order,color_matrix,exception);
02581             color_matrix=(double *) RelinquishMagickMemory(color_matrix);
02582             if (recolor_image == (Image *) NULL)
02583               break;
02584             *image=DestroyImage(*image);
02585             *image=recolor_image;
02586             break;
02587           }
02588         if (LocaleCompare("region",option+1) == 0)
02589           {
02590             Image
02591               *crop_image;
02592 
02593             (void) SyncImageSettings(image_info,*image);
02594             if (region_image != (Image *) NULL)
02595               {
02596                 /*
02597                   Composite region.
02598                 */
02599                 (void) CompositeImage(region_image,(*image)->matte !=
02600                   MagickFalse ? OverCompositeOp : CopyCompositeOp,*image,
02601                   region_geometry.x,region_geometry.y);
02602                 InheritException(exception,&region_image->exception);
02603                 *image=DestroyImage(*image);
02604                 *image=region_image;
02605               }
02606             if (*option == '+')
02607               {
02608                 if (region_image != (Image *) NULL)
02609                   region_image=DestroyImage(region_image);
02610                 break;
02611               }
02612             /*
02613               Apply transformations to a selected region of the image.
02614             */
02615             (void) ParseGravityGeometry(*image,argv[i+1],&region_geometry,
02616               exception);
02617             crop_image=CropImage(*image,&region_geometry,exception);
02618             if (crop_image == (Image *) NULL)
02619               break;
02620             region_image=(*image);
02621             *image=crop_image;
02622             break;
02623           }
02624         if (LocaleCompare("render",option+1) == 0)
02625           {
02626             (void) SyncImageSettings(image_info,*image);
02627             draw_info->render=(*option == '+') ? MagickTrue : MagickFalse;
02628             break;
02629           }
02630         if (LocaleCompare("remap",option+1) == 0)
02631           {
02632             Image
02633               *remap_image;
02634 
02635             /*
02636               Transform image colors to match this set of colors.
02637             */
02638             (void) SyncImageSettings(image_info,*image);
02639             if (*option == '+')
02640               break;
02641             remap_image=GetImageCache(image_info,argv[i+1],exception);
02642             if (remap_image == (Image *) NULL)
02643               break;
02644             (void) RemapImage(quantize_info,*image,remap_image);
02645             InheritException(exception,&(*image)->exception);
02646             remap_image=DestroyImage(remap_image);
02647             break;
02648           }
02649         if (LocaleCompare("repage",option+1) == 0)
02650           {
02651             if (*option == '+')
02652               {
02653                 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
02654                 break;
02655               }
02656             (void) ResetImagePage(*image,argv[i+1]);
02657             InheritException(exception,&(*image)->exception);
02658             break;
02659           }
02660         if (LocaleCompare("resample",option+1) == 0)
02661           {
02662             Image
02663               *resample_image;
02664 
02665             /*
02666               Resample image.
02667             */
02668             (void) SyncImageSettings(image_info,*image);
02669             flags=ParseGeometry(argv[i+1],&geometry_info);
02670             if ((flags & SigmaValue) == 0)
02671               geometry_info.sigma=geometry_info.rho;
02672             resample_image=ResampleImage(*image,geometry_info.rho,
02673               geometry_info.sigma,(*image)->filter,(*image)->blur,exception);
02674             if (resample_image == (Image *) NULL)
02675               break;
02676             *image=DestroyImage(*image);
02677             *image=resample_image;
02678             break;
02679           }
02680         if (LocaleCompare("resize",option+1) == 0)
02681           {
02682             Image
02683               *resize_image;
02684 
02685             /*
02686               Resize image.
02687             */
02688             (void) SyncImageSettings(image_info,*image);
02689             (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
02690             resize_image=ResizeImage(*image,geometry.width,geometry.height,
02691               (*image)->filter,(*image)->blur,exception);
02692             if (resize_image == (Image *) NULL)
02693               break;
02694             *image=DestroyImage(*image);
02695             *image=resize_image;
02696             break;
02697           }
02698         if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
02699           {
02700             respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
02701             break;
02702           }
02703         if (LocaleCompare("roll",option+1) == 0)
02704           {
02705             Image
02706               *roll_image;
02707 
02708             /*
02709               Roll image.
02710             */
02711             (void) SyncImageSettings(image_info,*image);
02712             (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception);
02713             roll_image=RollImage(*image,geometry.x,geometry.y,exception);
02714             if (roll_image == (Image *) NULL)
02715               break;
02716             *image=DestroyImage(*image);
02717             *image=roll_image;
02718             break;
02719           }
02720         if (LocaleCompare("rotate",option+1) == 0)
02721           {
02722             char
02723               *geometry;
02724 
02725             Image
02726               *rotate_image;
02727 
02728             /*
02729               Check for conditional image rotation.
02730             */
02731             (void) SyncImageSettings(image_info,*image);
02732             if (strchr(argv[i+1],'>') != (char *) NULL)
02733               if ((*image)->columns <= (*image)->rows)
02734                 break;
02735             if (strchr(argv[i+1],'<') != (char *) NULL)
02736               if ((*image)->columns >= (*image)->rows)
02737                 break;
02738             /*
02739               Rotate image.
02740             */
02741             geometry=ConstantString(argv[i+1]);
02742             (void) SubstituteString(&geometry,">","");
02743             (void) SubstituteString(&geometry,"<","");
02744             (void) ParseGeometry(geometry,&geometry_info);
02745             geometry=DestroyString(geometry);
02746             rotate_image=RotateImage(*image,geometry_info.rho,exception);
02747             if (rotate_image == (Image *) NULL)
02748               break;
02749             *image=DestroyImage(*image);
02750             *image=rotate_image;
02751             break;
02752           }
02753         break;
02754       }
02755       case 's':
02756       {
02757         if (LocaleCompare("sample",option+1) == 0)
02758           {
02759             Image
02760               *sample_image;
02761 
02762             /*
02763               Sample image with pixel replication.
02764             */
02765             (void) SyncImageSettings(image_info,*image);
02766             (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
02767             sample_image=SampleImage(*image,geometry.width,geometry.height,
02768               exception);
02769             if (sample_image == (Image *) NULL)
02770               break;
02771             *image=DestroyImage(*image);
02772             *image=sample_image;
02773             break;
02774           }
02775         if (LocaleCompare("scale",option+1) == 0)
02776           {
02777             Image
02778               *scale_image;
02779 
02780             /*
02781               Resize image.
02782             */
02783             (void) SyncImageSettings(image_info,*image);
02784             (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
02785             scale_image=ScaleImage(*image,geometry.width,geometry.height,
02786               exception);
02787             if (scale_image == (Image *) NULL)
02788               break;
02789             *image=DestroyImage(*image);
02790             *image=scale_image;
02791             break;
02792           }
02793         if (LocaleCompare("selective-blur",option+1) == 0)
02794           {
02795             Image
02796               *blur_image;
02797 
02798             /*
02799               Selectively blur pixels within a contrast threshold.
02800             */
02801             (void) SyncImageSettings(image_info,*image);
02802             flags=ParseGeometry(argv[i+1],&geometry_info);
02803             if ((flags & PercentValue) != 0)
02804               geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0;
02805             blur_image=SelectiveBlurImageChannel(*image,channel,
02806               geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception);
02807             if (blur_image == (Image *) NULL)
02808               break;
02809             *image=DestroyImage(*image);
02810             *image=blur_image;
02811             break;
02812           }
02813         if (LocaleCompare("separate",option+1) == 0)
02814           {
02815             Image
02816               *separate_images;
02817 
02818             /*
02819               Break channels into separate images.
02820             */
02821             (void) SyncImageSettings(image_info,*image);
02822             separate_images=SeparateImages(*image,channel,exception);
02823             if (separate_images == (Image *) NULL)
02824               break;
02825             *image=DestroyImage(*image);
02826             *image=separate_images;
02827             break;
02828           }
02829         if (LocaleCompare("sepia-tone",option+1) == 0)
02830           {
02831             double
02832               threshold;
02833 
02834             Image
02835               *sepia_image;
02836 
02837             /*
02838               Sepia-tone image.
02839             */
02840             (void) SyncImageSettings(image_info,*image);
02841             threshold=StringToDouble(argv[i+1],QuantumRange);
02842             sepia_image=SepiaToneImage(*image,threshold,exception);
02843             if (sepia_image == (Image *) NULL)
02844               break;
02845             *image=DestroyImage(*image);
02846             *image=sepia_image;
02847             break;
02848           }
02849         if (LocaleCompare("segment",option+1) == 0)
02850           {
02851             /*
02852               Segment image.
02853             */
02854             (void) SyncImageSettings(image_info,*image);
02855             flags=ParseGeometry(argv[i+1],&geometry_info);
02856             if ((flags & SigmaValue) == 0)
02857               geometry_info.sigma=1.0;
02858             (void) SegmentImage(*image,(*image)->colorspace,image_info->verbose,
02859               geometry_info.rho,geometry_info.sigma);
02860             InheritException(exception,&(*image)->exception);
02861             break;
02862           }
02863         if (LocaleCompare("set",option+1) == 0)
02864           {
02865             /*
02866               Set image option.
02867             */
02868             if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
02869               (void) DeleteImageRegistry(argv[i+1]+9);
02870             else
02871               if (LocaleNCompare(argv[i+1],"option:",7) == 0)
02872                 (void) DeleteImageOption(image_info,argv[i+1]+7);
02873               else
02874                 (void) DeleteImageProperty(*image,argv[i+1]);
02875             if (*option == '-')
02876               {
02877                 char
02878                   *value;
02879 
02880                 value=InterpretImageProperties(image_info,*image,argv[i+2]);
02881                 if (value != (char *) NULL)
02882                   {
02883                     if (LocaleNCompare(argv[i+1],"registry:",9) == 0)
02884                       (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,
02885                         value,exception);
02886                     else
02887                       if (LocaleNCompare(argv[i+1],"option:",7) == 0)
02888                         {
02889                           (void) SetImageOption(image_info,argv[i+1]+7,value);
02890                           (void) SetImageArtifact(*image,argv[i+1]+7,value);
02891                         }
02892                       else
02893                         (void) SetImageProperty(*image,argv[i+1],value);
02894                     value=DestroyString(value);
02895                   }
02896               }
02897             break;
02898           }
02899         if (LocaleCompare("shade",option+1) == 0)
02900           {
02901             Image
02902               *shade_image;
02903 
02904             /*
02905               Shade image.
02906             */
02907             (void) SyncImageSettings(image_info,*image);
02908             flags=ParseGeometry(argv[i+1],&geometry_info);
02909             if ((flags & SigmaValue) == 0)
02910               geometry_info.sigma=1.0;
02911             shade_image=ShadeImage(*image,(*option == '-') ? MagickTrue :
02912               MagickFalse,geometry_info.rho,geometry_info.sigma,exception);
02913             if (shade_image == (Image *) NULL)
02914               break;
02915             *image=DestroyImage(*image);
02916             *image=shade_image;
02917             break;
02918           }
02919         if (LocaleCompare("shadow",option+1) == 0)
02920           {
02921             Image
02922               *shadow_image;
02923 
02924             /*
02925               Shadow image.
02926             */
02927             (void) SyncImageSettings(image_info,*image);
02928             flags=ParseGeometry(argv[i+1],&geometry_info);
02929             if ((flags & SigmaValue) == 0)
02930               geometry_info.sigma=1.0;
02931             if ((flags & XiValue) == 0)
02932               geometry_info.xi=4.0;
02933             if ((flags & PsiValue) == 0)
02934               geometry_info.psi=4.0;
02935             shadow_image=ShadowImage(*image,geometry_info.rho,
02936               geometry_info.sigma,(long) (geometry_info.xi+0.5),(long)
02937               (geometry_info.psi+0.5),exception);
02938             if (shadow_image == (Image *) NULL)
02939               break;
02940             *image=DestroyImage(*image);
02941             *image=shadow_image;
02942             break;
02943           }
02944         if (LocaleCompare("sharpen",option+1) == 0)
02945           {
02946             Image
02947               *sharp_image;
02948 
02949             /*
02950               Sharpen image.
02951             */
02952             (void) SyncImageSettings(image_info,*image);
02953             flags=ParseGeometry(argv[i+1],&geometry_info);
02954             if ((flags & SigmaValue) == 0)
02955               geometry_info.sigma=1.0;
02956             sharp_image=SharpenImageChannel(*image,channel,geometry_info.rho,
02957               geometry_info.sigma,exception);
02958             if (sharp_image == (Image *) NULL)
02959               break;
02960             *image=DestroyImage(*image);
02961             *image=sharp_image;
02962             break;
02963           }
02964         if (LocaleCompare("shave",option+1) == 0)
02965           {
02966             Image
02967               *shave_image;
02968 
02969             /*
02970               Shave the image edges.
02971             */
02972             (void) SyncImageSettings(image_info,*image);
02973             flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception);
02974             shave_image=ShaveImage(*image,&geometry,exception);
02975             if (shave_image == (Image *) NULL)
02976               break;
02977             *image=DestroyImage(*image);
02978             *image=shave_image;
02979             break;
02980           }
02981         if (LocaleCompare("shear",option+1) == 0)
02982           {
02983             Image
02984               *shear_image;
02985 
02986             /*
02987               Shear image.
02988             */
02989             (void) SyncImageSettings(image_info,*image);
02990             flags=ParseGeometry(argv[i+1],&geometry_info);
02991             if ((flags & SigmaValue) == 0)
02992               geometry_info.sigma=geometry_info.rho;
02993             shear_image=ShearImage(*image,geometry_info.rho,geometry_info.sigma,
02994               exception);
02995             if (shear_image == (Image *) NULL)
02996               break;
02997             *image=DestroyImage(*image);
02998             *image=shear_image;
02999             break;
03000           }
03001         if (LocaleCompare("sigmoidal-contrast",option+1) == 0)
03002           {
03003             /*
03004               Sigmoidal non-linearity contrast control.
03005             */
03006             (void) SyncImageSettings(image_info,*image);
03007             flags=ParseGeometry(argv[i+1],&geometry_info);
03008             if ((flags & SigmaValue) == 0)
03009               geometry_info.sigma=(double) QuantumRange/2.0;
03010             if ((flags & PercentValue) != 0)
03011               geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/
03012                 100.0;
03013             (void) SigmoidalContrastImageChannel(*image,channel,
03014               (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho,
03015               geometry_info.sigma);
03016             InheritException(exception,&(*image)->exception);
03017             break;
03018           }
03019         if (LocaleCompare("sketch",option+1) == 0)
03020           {
03021             Image
03022               *sketch_image;
03023 
03024             /*
03025               Sketch image.
03026             */
03027             (void) SyncImageSettings(image_info,*image);
03028             flags=ParseGeometry(argv[i+1],&geometry_info);
03029             if ((flags & SigmaValue) == 0)
03030               geometry_info.sigma=1.0;
03031             sketch_image=SketchImage(*image,geometry_info.rho,
03032               geometry_info.sigma,geometry_info.xi,exception);
03033             if (sketch_image == (Image *) NULL)
03034               break;
03035             *image=DestroyImage(*image);
03036             *image=sketch_image;
03037             break;
03038           }
03039         if (LocaleCompare("solarize",option+1) == 0)
03040           {
03041             double
03042               threshold;
03043 
03044             (void) SyncImageSettings(image_info,*image);
03045             threshold=StringToDouble(argv[i+1],QuantumRange);
03046             (void) SolarizeImage(*image,threshold);
03047             InheritException(exception,&(*image)->exception);
03048             break;
03049           }
03050         if (LocaleCompare("sparse-color",option+1) == 0)
03051           {
03052             Image
03053               *sparse_image;
03054 
03055             SparseColorMethod
03056               method;
03057 
03058             char
03059               *arguments;
03060 
03061             /*
03062               Sparse Color Interpolated Gradient
03063             */
03064             (void) SyncImageSettings(image_info,*image);
03065             method=(SparseColorMethod) ParseMagickOption(
03066               MagickSparseColorOptions,MagickFalse,argv[i+1]);
03067             arguments=InterpretImageProperties(image_info,*image,argv[i+2]);
03068             InheritException(exception,&(*image)->exception);
03069             if (arguments == (char *) NULL)
03070               break;
03071             sparse_image=SparseColorOption(*image,channel,method,arguments,
03072               option[0] == '+' ? MagickTrue : MagickFalse,exception);
03073             arguments=DestroyString(arguments);
03074             if (sparse_image == (Image *) NULL)
03075               break;
03076             *image=DestroyImage(*image);
03077             *image=sparse_image;
03078             break;
03079           }
03080         if (LocaleCompare("splice",option+1) == 0)
03081           {
03082             Image
03083               *splice_image;
03084 
03085             /*
03086               Splice a solid color into the image.
03087             */
03088             (void) SyncImageSettings(image_info,*image);
03089             (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception);
03090             splice_image=SpliceImage(*image,&geometry,exception);
03091             if (splice_image == (Image *) NULL)
03092               break;
03093             *image=DestroyImage(*image);
03094             *image=splice_image;
03095             break;
03096           }
03097         if (LocaleCompare("spread",option+1) == 0)
03098           {
03099             Image
03100               *spread_image;
03101 
03102             /*
03103               Spread an image.
03104             */
03105             (void) SyncImageSettings(image_info,*image);
03106             (void) ParseGeometry(argv[i+1],&geometry_info);
03107             spread_image=SpreadImage(*image,geometry_info.rho,exception);
03108             if (spread_image == (Image *) NULL)
03109               break;
03110             *image=DestroyImage(*image);
03111             *image=spread_image;
03112             break;
03113           }
03114         if (LocaleCompare("stretch",option+1) == 0)
03115           {
03116             if (*option == '+')
03117               {
03118                 draw_info->stretch=UndefinedStretch;
03119                 break;
03120               }
03121             draw_info->stretch=(StretchType) ParseMagickOption(
03122               MagickStretchOptions,MagickFalse,argv[i+1]);
03123             break;
03124           }
03125         if (LocaleCompare("strip",option+1) == 0)
03126           {
03127             /*
03128               Strip image of profiles and comments.
03129             */
03130             (void) SyncImageSettings(image_info,*image);
03131             (void) StripImage(*image);
03132             InheritException(exception,&(*image)->exception);
03133             break;
03134           }
03135         if (LocaleCompare("stroke",option+1) == 0)
03136           {
03137             ExceptionInfo
03138               *sans;
03139 
03140             if (*option == '+')
03141               {
03142                 (void) QueryColorDatabase("none",&draw_info->stroke,exception);
03143                 if (draw_info->stroke_pattern != (Image *) NULL)
03144                   draw_info->stroke_pattern=DestroyImage(
03145                     draw_info->stroke_pattern);
03146                 break;
03147               }
03148             sans=AcquireExceptionInfo();
03149             status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans);
03150             sans=DestroyExceptionInfo(sans);
03151             if (status == MagickFalse)
03152               draw_info->stroke_pattern=GetImageCache(image_info,argv[i+1],
03153                 exception);
03154             break;
03155           }
03156         if (LocaleCompare("strokewidth",option+1) == 0)
03157           {
03158             draw_info->stroke_width=atof(argv[i+1]);
03159             break;
03160           }
03161         if (LocaleCompare("style",option+1) == 0)
03162           {
03163             if (*option == '+')
03164               {
03165                 draw_info->style=UndefinedStyle;
03166                 break;
03167               }
03168             draw_info->style=(StyleType) ParseMagickOption(MagickStyleOptions,
03169               MagickFalse,argv[i+1]);
03170             break;
03171           }
03172         if (LocaleCompare("swirl",option+1) == 0)
03173           {
03174             Image
03175               *swirl_image;
03176 
03177             /*
03178               Swirl image.
03179             */
03180             (void) SyncImageSettings(image_info,*image);
03181             (void) ParseGeometry(argv[i+1],&geometry_info);
03182             swirl_image=SwirlImage(*image,geometry_info.rho,exception);
03183             if (swirl_image == (Image *) NULL)
03184               break;
03185             *image=DestroyImage(*image);
03186             *image=swirl_image;
03187             break;
03188           }
03189         break;
03190       }
03191       case 't':
03192       {
03193         if (LocaleCompare("threshold",option+1) == 0)
03194           {
03195             double
03196               threshold;
03197 
03198             /*
03199               Threshold image.
03200             */
03201             (void) SyncImageSettings(image_info,*image);
03202             if (*option == '+')
03203               threshold=(double) QuantumRange/2.5;
03204             else
03205               threshold=StringToDouble(argv[i+1],QuantumRange);
03206             (void) BilevelImageChannel(*image,channel,threshold);
03207             InheritException(exception,&(*image)->exception);
03208             break;
03209           }
03210         if (LocaleCompare("thumbnail",option+1) == 0)
03211           {
03212             Image
03213               *thumbnail_image;
03214 
03215             /*
03216               Thumbnail image.
03217             */
03218             (void) SyncImageSettings(image_info,*image);
03219             (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception);
03220             thumbnail_image=ThumbnailImage(*image,geometry.width,
03221               geometry.height,exception);
03222             if (thumbnail_image == (Image *) NULL)
03223               break;
03224             *image=DestroyImage(*image);
03225             *image=thumbnail_image;
03226             break;
03227           }
03228         if (LocaleCompare("tile",option+1) == 0)
03229           {
03230             if (*option == '+')
03231               {
03232                 if (draw_info->fill_pattern != (Image *) NULL)
03233                   draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern);
03234                 break;
03235               }
03236             draw_info->fill_pattern=GetImageCache(image_info,argv[i+1],
03237               exception);
03238             break;
03239           }
03240         if (LocaleCompare("tint",option+1) == 0)
03241           {
03242             Image
03243               *tint_image;
03244 
03245             /*
03246               Tint the image.
03247             */
03248             (void) SyncImageSettings(image_info,*image);
03249             tint_image=TintImage(*image,argv[i+1],draw_info->fill,exception);
03250             if (tint_image == (Image *) NULL)
03251               break;
03252             *image=DestroyImage(*image);
03253             *image=tint_image;
03254             break;
03255           }
03256         if (LocaleCompare("transform",option+1) == 0)
03257           {
03258             Image
03259               *transform_image;
03260 
03261             /*
03262               Affine transform image.
03263             */
03264             (void) SyncImageSettings(image_info,*image);
03265             transform_image=AffineTransformImage(*image,&draw_info->affine,
03266               exception);
03267             if (transform_image == (Image *) NULL)
03268               break;
03269             *image=DestroyImage(*image);
03270             *image=transform_image;
03271             break;
03272           }
03273         if (LocaleCompare("transparent",option+1) == 0)
03274           {
03275             MagickPixelPacket
03276               target;
03277 
03278             (void) SyncImageSettings(image_info,*image);
03279             (void) QueryMagickColor(argv[i+1],&target,exception);
03280             (void) TransparentPaintImage(*image,&target,(Quantum)
03281               TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue);
03282             InheritException(exception,&(*image)->exception);
03283             break;
03284           }
03285         if (LocaleCompare("transpose",option+1) == 0)
03286           {
03287             Image
03288               *transpose_image;
03289 
03290             /*
03291               Transpose image scanlines.
03292             */
03293             (void) SyncImageSettings(image_info,*image);
03294             transpose_image=TransposeImage(*image,exception);
03295             if (transpose_image == (Image *) NULL)
03296               break;
03297             *image=DestroyImage(*image);
03298             *image=transpose_image;
03299             break;
03300           }
03301         if (LocaleCompare("transverse",option+1) == 0)
03302           {
03303             Image
03304               *transverse_image;
03305 
03306             /*
03307               Transverse image scanlines.
03308             */
03309             (void) SyncImageSettings(image_info,*image);
03310             transverse_image=TransverseImage(*image,exception);
03311             if (transverse_image == (Image *) NULL)
03312               break;
03313             *image=DestroyImage(*image);
03314             *image=transverse_image;
03315             break;
03316           }
03317         if (LocaleCompare("treedepth",option+1) == 0)
03318           {
03319             quantize_info->tree_depth=(unsigned long) atol(argv[i+1]);
03320             break;
03321           }
03322         if (LocaleCompare("trim",option+1) == 0)
03323           {
03324             Image
03325               *trim_image;
03326 
03327             /*
03328               Trim image.
03329             */
03330             (void) SyncImageSettings(image_info,*image);
03331             trim_image=TrimImage(*image,exception);
03332             if (trim_image == (Image *) NULL)
03333               break;
03334             *image=DestroyImage(*image);
03335             *image=trim_image;
03336             break;
03337           }
03338         if (LocaleCompare("type",option+1) == 0)
03339           {
03340             ImageType
03341               type;
03342 
03343             (void) SyncImageSettings(image_info,*image);
03344             if (*option == '+')
03345               type=UndefinedType;
03346             else
03347               type=(ImageType) ParseMagickOption(MagickTypeOptions,MagickFalse,
03348                 argv[i+1]);
03349             (*image)->type=UndefinedType;
03350             (void) SetImageType(*image,type);
03351             InheritException(exception,&(*image)->exception);
03352             break;
03353           }
03354         break;
03355       }
03356       case 'u':
03357       {
03358         if (LocaleCompare("undercolor",option+1) == 0)
03359           {
03360             (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor,
03361               exception);
03362             break;
03363           }
03364         if (LocaleCompare("unique-colors",option+1) == 0)
03365           {
03366             Image
03367               *unique_image;
03368 
03369             /*
03370               Unique image colors.
03371             */
03372             (void) SyncImageSettings(image_info,*image);
03373             unique_image=UniqueImageColors(*image,exception);
03374             if (unique_image == (Image *) NULL)
03375               break;
03376             *image=DestroyImage(*image);
03377             *image=unique_image;
03378             break;
03379           }
03380         if (LocaleCompare("unsharp",option+1) == 0)
03381           {
03382             Image
03383               *unsharp_image;
03384 
03385             /*
03386               Unsharp mask image.
03387             */
03388             (void) SyncImageSettings(image_info,*image);
03389             flags=ParseGeometry(argv[i+1],&geometry_info);
03390             if ((flags & SigmaValue) == 0)
03391               geometry_info.sigma=1.0;
03392             if ((flags & XiValue) == 0)
03393               geometry_info.xi=1.0;
03394             if ((flags & PsiValue) == 0)
03395               geometry_info.psi=0.05;
03396             unsharp_image=UnsharpMaskImageChannel(*image,channel,
03397               geometry_info.rho,geometry_info.sigma,geometry_info.xi,
03398               geometry_info.psi,exception);
03399             if (unsharp_image == (Image *) NULL)
03400               break;
03401             *image=DestroyImage(*image);
03402             *image=unsharp_image;
03403             break;
03404           }
03405         break;
03406       }
03407       case 'v':
03408       {
03409         if (LocaleCompare("verbose",option+1) == 0)
03410           {
03411             (void) SetImageArtifact(*image,option+1,
03412               *option == '+' ? "false" : "true");
03413             break;
03414           }
03415         if (LocaleCompare("vignette",option+1) == 0)
03416           {
03417             Image
03418               *vignette_image;
03419 
03420             /*
03421               Vignette image.
03422             */
03423             (void) SyncImageSettings(image_info,*image);
03424             flags=ParseGeometry(argv[i+1],&geometry_info);
03425             if ((flags & SigmaValue) == 0)
03426               geometry_info.sigma=1.0;
03427             if ((flags & XiValue) == 0)
03428               geometry_info.xi=0.1*(*image)->columns;
03429             if ((flags & PsiValue) == 0)
03430               geometry_info.psi=0.1*(*image)->rows;
03431             vignette_image=VignetteImage(*image,geometry_info.rho,
03432               geometry_info.sigma,(long) (geometry_info.xi+0.5),(long)
03433               (geometry_info.psi+0.5),exception);
03434             if (vignette_image == (Image *) NULL)
03435               break;
03436             *image=DestroyImage(*image);
03437             *image=vignette_image;
03438             break;
03439           }
03440         if (LocaleCompare("virtual-pixel",option+1) == 0)
03441           {
03442             if (*option == '+')
03443               {
03444                 (void) SetImageVirtualPixelMethod(*image,
03445                   UndefinedVirtualPixelMethod);
03446                 break;
03447               }
03448             (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod)
03449               ParseMagickOption(MagickVirtualPixelOptions,MagickFalse,
03450               argv[i+1]));
03451             break;
03452           }
03453         break;
03454       }
03455       case 'w':
03456       {
03457         if (LocaleCompare("wave",option+1) == 0)
03458           {
03459             Image
03460               *wave_image;
03461 
03462             /*
03463               Wave image.
03464             */
03465             (void) SyncImageSettings(image_info,*image);
03466             flags=ParseGeometry(argv[i+1],&geometry_info);
03467             if ((flags & SigmaValue) == 0)
03468               geometry_info.sigma=1.0;
03469             wave_image=WaveImage(*image,geometry_info.rho,geometry_info.sigma,
03470               exception);
03471             if (wave_image == (Image *) NULL)
03472               break;
03473             *image=DestroyImage(*image);
03474             *image=wave_image;
03475             break;
03476           }
03477         if (LocaleCompare("weight",option+1) == 0)
03478           {
03479             draw_info->weight=(unsigned long) atol(argv[i+1]);
03480             if (LocaleCompare(argv[i+1],"all") == 0)
03481               draw_info->weight=0;
03482             if (LocaleCompare(argv[i+1],"bold") == 0)
03483               draw_info->weight=700;
03484             if (LocaleCompare(argv[i+1],"bolder") == 0)
03485               if (draw_info->weight <= 800)
03486                 draw_info->weight+=100;
03487             if (LocaleCompare(argv[i+1],"lighter") == 0)
03488               if (draw_info->weight >= 100)
03489                 draw_info->weight-=100;
03490             if (LocaleCompare(argv[i+1],"normal") == 0)
03491               draw_info->weight=400;
03492             break;
03493           }
03494         if (LocaleCompare("white-threshold",option+1) == 0)
03495           {
03496             /*
03497               White threshold image.
03498             */
03499             (void) SyncImageSettings(image_info,*image);
03500             (void) WhiteThresholdImageChannel(*image,channel,argv[i+1],
03501               exception);
03502             InheritException(exception,&(*image)->exception);
03503             break;
03504           }
03505         break;
03506       }
03507       default:
03508         break;
03509     }
03510     i+=count;
03511   }
03512   if (region_image != (Image *) NULL)
03513     {
03514       /*
03515         Composite transformed region onto image.
03516       */
03517       (void) SyncImageSettings(image_info,*image);
03518       (void) CompositeImage(region_image,(*image)->matte != MagickFalse ?
03519         OverCompositeOp : CopyCompositeOp,*image,region_geometry.x,
03520         region_geometry.y);
03521       InheritException(exception,&region_image->exception);
03522       *image=DestroyImage(*image);
03523       *image=region_image;
03524     }
03525   /*
03526     Free resources.
03527   */
03528   quantize_info=DestroyQuantizeInfo(quantize_info);
03529   draw_info=DestroyDrawInfo(draw_info);
03530   status=(*image)->exception.severity == UndefinedException ?
03531     MagickTrue : MagickFalse;
03532   return(status);
03533 }
03534 
03535 /*
03536 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
03537 %                                                                             %
03538 %                                                                             %
03539 %                                                                             %
03540 %    M o g r i f y I m a g e C o m m a n d                                    %
03541 %                                                                             %
03542 %                                                                             %
03543 %                                                                             %
03544 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
03545 %
03546 %  MogrifyImageCommand() transforms an image or a sequence of images. These
03547 %  transforms include image scaling, image rotation, color reduction, and
03548 %  others. The transmogrified image overwrites the original image.
03549 %
03550 %  The format of the MogrifyImageCommand method is:
03551 %
03552 %      MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc,
03553 %        const char **argv,char **metadata,ExceptionInfo *exception)
03554 %
03555 %  A description of each parameter follows:
03556 %
03557 %    o image_info: the image info.
03558 %
03559 %    o argc: the number of elements in the argument vector.
03560 %
03561 %    o argv: A text array containing the command line arguments.
03562 %
03563 %    o metadata: any metadata is returned here.
03564 %
03565 %    o exception: return any errors or warnings in this structure.
03566 %
03567 */
03568 
03569 static MagickBooleanType MogrifyUsage(void)
03570 {
03571   static const char
03572     *miscellaneous[]=
03573     {
03574       "-debug events        display copious debugging information",
03575       "-help                print program options",
03576       "-list type           print a list of supported option arguments",
03577       "-log format          format of debugging information",
03578       "-version             print version information",
03579       (char *) NULL
03580     },
03581     *operators[]=
03582     {
03583       "-adaptive-blur geometry",
03584       "                     adaptively blur pixels; decrease effect near edges",
03585       "-adaptive-resize geometry",
03586       "                     adaptively resize image using 'mesh' interpolation",
03587       "-adaptive-sharpen geometry",
03588       "                     adaptively sharpen pixels; increase effect near edges",
03589       "-alpha option        on, activate, off, deactivate, set, opaque, copy",
03590       "                     transparent, extract, background, or shape",
03591       "-annotate geometry text",
03592       "                     annotate the image with text",
03593       "-auto-gamma          automagically adjust gamma level of image",
03594       "-auto-level          automagically adjust color levels of image",
03595       "-auto-orient         automagically orient (rotate) image",
03596       "-bench iterations    measure performance",
03597       "-black-threshold value",
03598       "                     force all pixels below the threshold into black",
03599       "-blue-shift          simulate a scene at nighttime in the moonlight",
03600       "-blur geometry       reduce image noise and reduce detail levels",
03601       "-border geometry     surround image with a border of color",
03602       "-bordercolor color   border color",
03603       "-cdl filename        color correct with a color decision list",
03604       "-charcoal radius     simulate a charcoal drawing",
03605       "-chop geometry       remove pixels from the image interior",
03606       "-clamp               restrict pixel range from 0 to the quantum depth",
03607       "-clip                clip along the first path from the 8BIM profile",
03608       "-clip-mask filename  associate a clip mask with the image",
03609       "-clip-path id        clip along a named path from the 8BIM profile",
03610       "-colorize value      colorize the image with the fill color",
03611       "-contrast            enhance or reduce the image contrast",
03612       "-contrast-stretch geometry",
03613       "                     improve contrast by `stretching' the intensity range",
03614       "-convolve coefficients",
03615       "                     apply a convolution kernel to the image",
03616       "-cycle amount        cycle the image colormap",
03617       "-decipher filename   convert cipher pixels to plain pixels",
03618       "-deskew threshold    straighten an image",
03619       "-despeckle           reduce the speckles within an image",
03620       "-distort method args",
03621       "                     distort images according to given method ad args",
03622       "-draw string         annotate the image with a graphic primitive",
03623       "-edge radius         apply a filter to detect edges in the image",
03624       "-encipher filename   convert plain pixels to cipher pixels",
03625       "-emboss radius       emboss an image",
03626       "-enhance             apply a digital filter to enhance a noisy image",
03627       "-equalize            perform histogram equalization to an image",
03628       "-evaluate operator value",
03629       "                     evaluate an expression over image values",
03630       "-extent geometry     set the image size",
03631       "-extract geometry    extract area from image",
03632       "-fft                 implements the discrete Fourier transform (DFT)",
03633       "-flip                flip image vertically",
03634       "-floodfill geometry color",
03635       "                     floodfill the image with color",
03636       "-flop                flop image horizontally",
03637       "-frame geometry      surround image with an ornamental border",
03638       "-function name paramters",
03639       "                     apply function over image values",
03640       "-gamma value         level of gamma correction",
03641       "-gaussian-blur geometry",
03642       "                     reduce image noise and reduce detail levels",
03643       "-geometry geometry   preferred size or location of the image",
03644       "-identify            identify the format and characteristics of the image",
03645       "-ift                 implements the inverse discrete Fourier transform (DFT)",
03646       "-implode amount      implode image pixels about the center",
03647       "-lat geometry        local adaptive thresholding",
03648       "-layers method       optimize, merge,  or compare image layers",
03649       "-level value         adjust the level of image contrast",
03650       "-level-colors color,color",
03651       "                     level image with the given colors",
03652       "-linear-stretch geometry",
03653       "                     improve contrast by `stretching with saturation'",
03654       "-liquid-rescale geometry",
03655       "                     rescale image with seam-carving",
03656       "-median radius       apply a median filter to the image",
03657       "-modulate value      vary the brightness, saturation, and hue",
03658       "-monochrome          transform image to black and white",
03659       "-motion-blur geometry",
03660       "                     simulate motion blur",
03661       "-negate              replace every pixel with its complementary color ",
03662       "-noise radius        add or reduce noise in an image",
03663       "-normalize           transform image to span the full range of colors",
03664       "-opaque color        change this color to the fill color",
03665       "-ordered-dither NxN",
03666       "                     add a noise pattern to the image with specific",
03667       "                     amplitudes",
03668       "-paint radius        simulate an oil painting",
03669       "-polaroid angle      simulate a Polaroid picture",
03670       "-posterize levels    reduce the image to a limited number of color levels",
03671       "-print string        interpret string and print to console",
03672       "-profile filename    add, delete, or apply an image profile",
03673       "-quantize colorspace reduce colors in this colorspace",
03674       "-radial-blur angle   radial blur the image",
03675       "-raise value         lighten/darken image edges to create a 3-D effect",
03676       "-random-threshold low,high",
03677       "                     random threshold the image",
03678       "-recolor matrix      translate, scale, shear, or rotate image colors",
03679       "-region geometry     apply options to a portion of the image",
03680       "-render              render vector graphics",
03681       "-repage geometry     size and location of an image canvas",
03682       "-resample geometry   change the resolution of an image",
03683       "-resize geometry     resize the image",
03684       "-roll geometry       roll an image vertically or horizontally",
03685       "-rotate degrees      apply Paeth rotation to the image",
03686       "-sample geometry     scale image with pixel sampling",
03687       "-scale geometry      scale the image",
03688       "-segment values      segment an image",
03689       "-selective-blur geometry",
03690       "                     selectively blur pixels within a contrast threshold",
03691       "-sepia-tone threshold",
03692       "                     simulate a sepia-toned photo",
03693       "-set property value  set an image property",
03694       "-shade degrees       shade the image using a distant light source",
03695       "-shadow geometry     simulate an image shadow",
03696       "-sharpen geometry    sharpen the image",
03697       "-shave geometry      shave pixels from the image edges",
03698       "-shear geometry      slide one edge of the image along the X or Y axis",
03699       "-sigmoidal-contrast geometry",
03700       "                     increase the contrast without saturating highlights or shadows",
03701       "-sketch geometry     simulate a pencil sketch",
03702       "-solarize threshold  negate all pixels above the threshold level",
03703       "-sparse-color method args",
03704       "                     fill in a image based on a few color points",
03705       "-splice geometry     splice the background color into the image",
03706       "-spread radius       displace image pixels by a random amount",
03707       "-strip               strip image of all profiles and comments",
03708       "-swirl degrees       swirl image pixels about the center",
03709       "-threshold value     threshold the image",
03710       "-thumbnail geometry  create a thumbnail of the image",
03711       "-tile filename       tile image when filling a graphic primitive",
03712       "-tint value          tint the image with the fill color",
03713       "-transform           affine transform image",
03714       "-transparent color   make this color transparent within the image",
03715       "-transpose           flip image vertically and rotate 90 degrees",
03716       "-transverse          flop image horizontally and rotate 270 degrees",
03717       "-trim                trim image edges",
03718       "-type type           image type",
03719       "-unique-colors       discard all but one of any pixel color",
03720       "-unsharp geometry    sharpen the image",
03721       "-vignette geometry   soften the edges of the image in vignette style",
03722       "-wave geometry       alter an image along a sine wave",
03723       "-white-threshold value",
03724       "                     force all pixels above the threshold into white",
03725       (char *) NULL
03726     },
03727     *sequence_operators[]=
03728     {
03729       "-append              append an image sequence",
03730       "-average             average an image sequence",
03731       "-clut                apply a color lookup table to the image",
03732       "-coalesce            merge a sequence of images",
03733       "-combine             combine a sequence of images",
03734       "-composite           composite image",
03735       "-crop geometry       cut out a rectangular region of the image",
03736       "-deconstruct         break down an image sequence into constituent parts",
03737       "-flatten             flatten a sequence of images",
03738       "-fx expression       apply mathematical expression to an image channel(s)",
03739       "-hald-clut           apply a Hald color lookup table to the image",
03740       "-morph value         morph an image sequence",
03741       "-mosaic              create a mosaic from an image sequence",
03742       "-process arguments   process the image with a custom image filter",
03743       "-reverse             reverse image sequence",
03744       "-separate            separate an image channel into a grayscale image",
03745       "-write filename      write images to this file",
03746       (char *) NULL
03747     },
03748     *settings[]=
03749     {
03750       "-adjoin              join images into a single multi-image file",
03751       "-affine matrix       affine transform matrix",
03752       "-alpha option        activate, deactivate, reset, or set the alpha channel",
03753       "-antialias           remove pixel-aliasing",
03754       "-authenticate password",
03755       "                     decipher image with this password",
03756       "-attenuate value     lessen (or intensify) when adding noise to an image",
03757       "-background color    background color",
03758       "-bias value          add bias when convolving an image",
03759       "-black-point-compensation",
03760       "                     use black point compensation",
03761       "-blue-primary point  chromaticity blue primary point",
03762       "-bordercolor color   border color",
03763       "-caption string      assign a caption to an image",
03764       "-channel type        apply option to select image channels",
03765       "-colors value        preferred number of colors in the image",
03766       "-colorspace type     alternate image colorspace",
03767       "-comment string      annotate image with comment",
03768       "-compose operator    set image composite operator",
03769       "-compress type       type of pixel compression when writing the image",
03770       "-define format:option",
03771       "                     define one or more image format options",
03772       "-delay value         display the next image after pausing",
03773       "-density geometry    horizontal and vertical density of the image",
03774       "-depth value         image depth",
03775       "-display server      get image or font from this X server",
03776       "-dispose method      layer disposal method",
03777       "-dither method       apply error diffusion to image",
03778       "-encoding type       text encoding type",
03779       "-endian type         endianness (MSB or LSB) of the image",
03780       "-family name         render text with this font family",
03781       "-fill color          color to use when filling a graphic primitive",
03782       "-filter type         use this filter when resizing an image",
03783       "-font name           render text with this font",
03784       "-format \"string\"     output formatted image characteristics",
03785       "-fuzz distance       colors within this distance are considered equal",
03786       "-gravity type        horizontal and vertical text placement",
03787       "-green-primary point chromaticity green primary point",
03788       "-intent type         type of rendering intent when managing the image color",
03789       "-interlace type      type of image interlacing scheme",
03790       "-interline-spacing value",
03791       "                     set the space between two text lines",
03792       "-interpolate method  pixel color interpolation method",
03793       "-interword-spacing value",
03794       "                     set the space between two words",
03795       "-kerning value       set the space between two letters",
03796       "-label string        assign a label to an image",
03797       "-limit type value    pixel cache resource limit",
03798       "-loop iterations     add Netscape loop extension to your GIF animation",
03799       "-mask filename       associate a mask with the image",
03800       "-mattecolor color    frame color",
03801       "-monitor             monitor progress",
03802       "-orient type         image orientation",
03803       "-page geometry       size and location of an image canvas (setting)",
03804       "-ping                efficiently determine image attributes",
03805       "-pointsize value     font point size",
03806       "-preview type        image preview type",
03807       "-quality value       JPEG/MIFF/PNG compression level",
03808       "-quiet               suppress all warning messages",
03809       "-red-primary point   chromaticity red primary point",
03810       "-regard-warnings     pay attention to warning messages",
03811       "-remap filename      transform image colors to match this set of colors",
03812       "-respect-parentheses settings remain in effect until parenthesis boundary",
03813       "-sampling-factor geometry",
03814       "                     horizontal and vertical sampling factor",
03815       "-scene value         image scene number",
03816       "-seed value          seed a new sequence of pseudo-random numbers",
03817       "-size geometry       width and height of image",
03818       "-stretch type        render text with this font stretch",
03819       "-stroke color        graphic primitive stroke color",
03820       "-strokewidth value   graphic primitive stroke width",
03821       "-style type          render text with this font style",
03822       "-taint               image as ineligible for bi-modal delegate",
03823       "-texture filename    name of texture to tile onto the image background",
03824       "-tile-offset geometry",
03825       "                     tile offset",
03826       "-treedepth value     color tree depth",
03827       "-transparent-color color",
03828       "                     transparent color",
03829       "-undercolor color    annotation bounding box color",
03830       "-units type          the units of image resolution",
03831       "-verbose             print detailed information about the image",
03832       "-view                FlashPix viewing transforms",
03833       "-virtual-pixel method",
03834       "                     virtual pixel access method",
03835       "-weight type         render text with this font weight",
03836       "-white-point point   chromaticity white point",
03837       (char *) NULL
03838     },
03839     *stack_operators[]=
03840     {
03841       "-clone index         clone an image",
03842       "-delete index        delete the image from the image sequence",
03843       "-insert index        insert last image into the image sequence",
03844       "-swap indexes        swap two images in the image sequence",
03845       (char *) NULL
03846     };
03847 
03848   const char
03849     **p;
03850 
03851   (void) printf("Version: %s\n",GetMagickVersion((unsigned long *) NULL));
03852   (void) printf("Copyright: %s\n",GetMagickCopyright());
03853   (void) printf("Features: %s\n\n",GetMagickFeatures());
03854   (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
03855     GetClientName());
03856   (void) printf("\nImage Settings:\n");
03857   for (p=settings; *p != (char *) NULL; p++)
03858     (void) printf("  %s\n",*p);
03859   (void) printf("\nImage Operators:\n");
03860   for (p=operators; *p != (char *) NULL; p++)
03861     (void) printf("  %s\n",*p);
03862   (void) printf("\nImage Sequence Operators:\n");
03863   for (p=sequence_operators; *p != (char *) NULL; p++)
03864     (void) printf("  %s\n",*p);
03865   (void) printf("\nImage Stack Operators:\n");
03866   for (p=stack_operators; *p != (char *) NULL; p++)
03867     (void) printf("  %s\n",*p);
03868   (void) printf("\nMiscellaneous Options:\n");
03869   for (p=miscellaneous; *p != (char *) NULL; p++)
03870     (void) printf("  %s\n",*p);
03871   (void) printf(
03872     "\nBy default, the image format of `file' is determined by its magic\n");
03873   (void) printf(
03874     "number.  To specify a particular image format, precede the filename\n");
03875   (void) printf(
03876     "with an image format name and a colon (i.e. ps:image) or specify the\n");
03877   (void) printf(
03878     "image type as the filename suffix (i.e. image.ps).  Specify 'file' as\n");
03879   (void) printf("'-' for standard input or output.\n");
03880   return(MagickFalse);
03881 }
03882 
03883 WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,
03884   int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
03885 {
03886 #define DestroyMogrify() \
03887 { \
03888   if (format != (char *) NULL) \
03889     format=DestroyString(format); \
03890   if (path != (char *) NULL) \
03891     path=DestroyString(path); \
03892   DestroyImageStack(); \
03893   for (i=0; i < (long) argc; i++) \
03894     argv[i]=DestroyString(argv[i]); \
03895   argv=(char **) RelinquishMagickMemory(argv); \
03896 }
03897 #define ThrowMogrifyException(asperity,tag,option) \
03898 { \
03899   (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
03900     option); \
03901   DestroyMogrify(); \
03902   return(MagickFalse); \
03903 }
03904 #define ThrowMogrifyInvalidArgumentException(option,argument) \
03905 { \
03906   (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
03907     "InvalidArgument","`%s': %s",argument,option); \
03908   DestroyMogrify(); \
03909   return(MagickFalse); \
03910 }
03911 
03912   char
03913     *format,
03914     *option,
03915     *path;
03916 
03917   Image
03918     *image;
03919 
03920   ImageStack
03921     image_stack[MaxImageStackDepth+1];
03922 
03923   long
03924     j,
03925     k;
03926 
03927   register long
03928     i;
03929 
03930   MagickBooleanType
03931     global_colormap;
03932 
03933   MagickBooleanType
03934     fire,
03935     pend;
03936 
03937   MagickStatusType
03938     status;
03939 
03940   /*
03941     Set defaults.
03942   */
03943   assert(image_info != (ImageInfo *) NULL);
03944   assert(image_info->signature == MagickSignature);
03945   if (image_info->debug != MagickFalse)
03946     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
03947   assert(exception != (ExceptionInfo *) NULL);
03948   if (argc == 2)
03949     {
03950       option=argv[1];
03951       if ((LocaleCompare("version",option+1) == 0) ||
03952           (LocaleCompare("-version",option+1) == 0))
03953         {
03954           (void) fprintf(stdout,"Version: %s\n",
03955             GetMagickVersion((unsigned long *) NULL));
03956           (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright());
03957           (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures());
03958           return(MagickFalse);
03959         }
03960     }
03961   if (argc < 2)
03962     {
03963       (void) MogrifyUsage();
03964       return(MagickTrue);
03965     }
03966   format=(char *) NULL;
03967   path=(char *) NULL;
03968   global_colormap=MagickFalse;
03969   k=0;
03970   j=1;
03971   NewImageStack();
03972   option=(char *) NULL;
03973   pend=MagickFalse;
03974   status=MagickTrue;
03975   /*
03976     Parse command line.
03977   */
03978   ReadCommandlLine(argc,&argv);
03979   status=ExpandFilenames(&argc,&argv);
03980   if (status == MagickFalse)
03981     ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed",
03982       GetExceptionMessage(errno));
03983   for (i=1; i < (long) argc; i++)
03984   {
03985     option=argv[i];
03986     if (LocaleCompare(option,"(") == 0)
03987       {
03988         FireImageStack(MagickFalse,MagickTrue,pend);
03989         if (k == MaxImageStackDepth)
03990           ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply",
03991             option);
03992         PushImageStack();
03993         continue;
03994       }
03995     if (LocaleCompare(option,")") == 0)
03996       {
03997         FireImageStack(MagickFalse,MagickTrue,MagickTrue);
03998         if (k == 0)
03999           ThrowMogrifyException(OptionError,"UnableToParseExpression",option);
04000         PopImageStack();
04001         continue;
04002       }
04003     if (IsMagickOption(option) == MagickFalse)
04004       {
04005         char
04006           backup_filename[MaxTextExtent],
04007           *filename;
04008 
04009         Image
04010           *images;
04011 
04012         /*
04013           Option is a file name: begin by reading image from specified file.
04014         */
04015         FireImageStack(MagickFalse,MagickFalse,pend);
04016         filename=argv[i];
04017         if ((LocaleCompare(filename,"--") == 0) && (i < (argc-1)))
04018           filename=argv[++i];
04019         (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
04020         images=ReadImages(image_info,exception);
04021         status&=(images != (Image *) NULL) &&
04022           (exception->severity < ErrorException);
04023         if (images == (Image *) NULL)
04024           continue;
04025         if (path != (char *) NULL)
04026           {
04027             GetPathComponent(option,TailPath,filename);
04028             (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s",
04029               path,*DirectorySeparator,filename);
04030           }
04031         if (format != (char *) NULL)
04032           AppendImageFormat(format,images->filename);
04033         AppendImageStack(images);
04034         FinalizeImageSettings(image_info,image,MagickFalse);
04035         if (global_colormap != MagickFalse)
04036           {
04037             QuantizeInfo
04038               *quantize_info;
04039 
04040             quantize_info=AcquireQuantizeInfo(image_info);
04041             (void) RemapImages(quantize_info,images,(Image *) NULL);
04042             quantize_info=DestroyQuantizeInfo(quantize_info);
04043           }
04044         *backup_filename='\0';
04045         if ((LocaleCompare(image->filename,"-") != 0) &&
04046             (IsPathWritable(image->filename) != MagickFalse))
04047           {
04048             register long
04049               i;
04050 
04051             /*
04052               Rename image file as backup.
04053             */
04054             (void) CopyMagickString(backup_filename,image->filename,
04055               MaxTextExtent);
04056             for (i=0; i < 6; i++)
04057             {
04058               (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent);
04059               if (IsPathAccessible(backup_filename) == MagickFalse)
04060                 break;
04061             }
04062             if ((IsPathAccessible(backup_filename) != MagickFalse) ||
04063                 (rename(image->filename,backup_filename) != 0))
04064               *backup_filename='\0';
04065           }
04066         /*
04067           Write transmogrified image to disk.
04068         */
04069         image_info->synchronize=MagickTrue;
04070         status&=WriteImages(image_info,image,image->filename,exception);
04071         if ((status == MagickFalse) && (*backup_filename != '\0'))
04072           (void) remove(backup_filename);
04073         RemoveAllImageStack();
04074         continue;
04075       }
04076     pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
04077     switch (*(option+1))
04078     {
04079       case 'a':
04080       {
04081         if (LocaleCompare("adaptive-blur",option+1) == 0)
04082           {
04083             i++;
04084             if (i == (long) argc)
04085               ThrowMogrifyException(OptionError,"MissingArgument",option);
04086             if (IsGeometry(argv[i]) == MagickFalse)
04087               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04088             break;
04089           }
04090         if (LocaleCompare("adaptive-resize",option+1) == 0)
04091           {
04092             i++;
04093             if (i == (long) argc)
04094               ThrowMogrifyException(OptionError,"MissingArgument",option);
04095             if (IsGeometry(argv[i]) == MagickFalse)
04096               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04097             break;
04098           }
04099         if (LocaleCompare("adaptive-sharpen",option+1) == 0)
04100           {
04101             i++;
04102             if (i == (long) argc)
04103               ThrowMogrifyException(OptionError,"MissingArgument",option);
04104             if (IsGeometry(argv[i]) == MagickFalse)
04105               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04106             break;
04107           }
04108         if (LocaleCompare("affine",option+1) == 0)
04109           {
04110             if (*option == '+')
04111               break;
04112             i++;
04113             if (i == (long) argc)
04114               ThrowMogrifyException(OptionError,"MissingArgument",option);
04115             if (IsGeometry(argv[i]) == MagickFalse)
04116               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04117             break;
04118           }
04119         if (LocaleCompare("alpha",option+1) == 0)
04120           {
04121             long
04122               type;
04123 
04124             if (*option == '+')
04125               break;
04126             i++;
04127             if (i == (long) argc)
04128               ThrowMogrifyException(OptionError,"MissingArgument",option);
04129             type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]);
04130             if (type < 0)
04131               ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType",
04132                 argv[i]);
04133             break;
04134           }
04135         if (LocaleCompare("annotate",option+1) == 0)
04136           {
04137             if (*option == '+')
04138               break;
04139             i++;
04140             if (i == (long) argc)
04141               ThrowMogrifyException(OptionError,"MissingArgument",option);
04142             if (IsGeometry(argv[i]) == MagickFalse)
04143               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04144             if (i == (long) argc)
04145               ThrowMogrifyException(OptionError,"MissingArgument",option);
04146             i++;
04147             break;
04148           }
04149         if (LocaleCompare("antialias",option+1) == 0)
04150           break;
04151         if (LocaleCompare("append",option+1) == 0)
04152           break;
04153         if (LocaleCompare("attenuate",option+1) == 0)
04154           {
04155             if (*option == '+')
04156               break;
04157             i++;
04158             if (i == (long) (argc-1))
04159               ThrowMogrifyException(OptionError,"MissingArgument",option);
04160             if (IsGeometry(argv[i]) == MagickFalse)
04161               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04162             break;
04163           }
04164         if (LocaleCompare("authenticate",option+1) == 0)
04165           {
04166             if (*option == '+')
04167               break;
04168             i++;
04169             if (i == (long) argc)
04170               ThrowMogrifyException(OptionError,"MissingArgument",option);
04171             break;
04172           }
04173         if (LocaleCompare("auto-gamma",option+1) == 0)
04174           break;
04175         if (LocaleCompare("auto-level",option+1) == 0)
04176           break;
04177         if (LocaleCompare("auto-orient",option+1) == 0)
04178           break;
04179         if (LocaleCompare("average",option+1) == 0)
04180           break;
04181         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
04182       }
04183       case 'b':
04184       {
04185         if (LocaleCompare("background",option+1) == 0)
04186           {
04187             if (*option == '+')
04188               break;
04189             i++;
04190             if (i == (long) argc)
04191               ThrowMogrifyException(OptionError,"MissingArgument",option);
04192             break;
04193           }
04194         if (LocaleCompare("bias",option+1) == 0)
04195           {
04196             if (*option == '+')
04197               break;
04198             i++;
04199             if (i == (long) (argc-1))
04200               ThrowMogrifyException(OptionError,"MissingArgument",option);
04201             if (IsGeometry(argv[i]) == MagickFalse)
04202               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04203             break;
04204           }
04205         if (LocaleCompare("black-point-compensation",option+1) == 0)
04206           break;
04207         if (LocaleCompare("black-threshold",option+1) == 0)
04208           {
04209             if (*option == '+')
04210               break;
04211             i++;
04212             if (i == (long) argc)
04213               ThrowMogrifyException(OptionError,"MissingArgument",option);
04214             if (IsGeometry(argv[i]) == MagickFalse)
04215               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04216             break;
04217           }
04218         if (LocaleCompare("blue-primary",option+1) == 0)
04219           {
04220             if (*option == '+')
04221               break;
04222             i++;
04223             if (i == (long) argc)
04224               ThrowMogrifyException(OptionError,"MissingArgument",option);
04225             if (IsGeometry(argv[i]) == MagickFalse)
04226               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04227             break;
04228           }
04229         if (LocaleCompare("blue-shift",option+1) == 0)
04230           {
04231             i++;
04232             if (i == (long) argc)
04233               ThrowMogrifyException(OptionError,"MissingArgument",option);
04234             if (IsGeometry(argv[i]) == MagickFalse)
04235               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04236             break;
04237           }
04238         if (LocaleCompare("blur",option+1) == 0)
04239           {
04240             i++;
04241             if (i == (long) argc)
04242               ThrowMogrifyException(OptionError,"MissingArgument",option);
04243             if (IsGeometry(argv[i]) == MagickFalse)
04244               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04245             break;
04246           }
04247         if (LocaleCompare("border",option+1) == 0)
04248           {
04249             if (*option == '+')
04250               break;
04251             i++;
04252             if (i == (long) argc)
04253               ThrowMogrifyException(OptionError,"MissingArgument",option);
04254             if (IsGeometry(argv[i]) == MagickFalse)
04255               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04256             break;
04257           }
04258         if (LocaleCompare("bordercolor",option+1) == 0)
04259           {
04260             if (*option == '+')
04261               break;
04262             i++;
04263             if (i == (long) argc)
04264               ThrowMogrifyException(OptionError,"MissingArgument",option);
04265             break;
04266           }
04267         if (LocaleCompare("box",option+1) == 0)
04268           {
04269             if (*option == '+')
04270               break;
04271             i++;
04272             if (i == (long) argc)
04273               ThrowMogrifyException(OptionError,"MissingArgument",option);
04274             break;
04275           }
04276         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
04277       }
04278       case 'c':
04279       {
04280         if (LocaleCompare("cache",option+1) == 0)
04281           {
04282             if (*option == '+')
04283               break;
04284             i++;
04285             if (i == (long) argc)
04286               ThrowMogrifyException(OptionError,"MissingArgument",option);
04287             if (IsGeometry(argv[i]) == MagickFalse)
04288               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04289             break;
04290           }
04291         if (LocaleCompare("caption",option+1) == 0)
04292           {
04293             if (*option == '+')
04294               break;
04295             i++;
04296             if (i == (long) argc)
04297               ThrowMogrifyException(OptionError,"MissingArgument",option);
04298             break;
04299           }
04300         if (LocaleCompare("channel",option+1) == 0)
04301           {
04302             long
04303               channel;
04304 
04305             if (*option == '+')
04306               break;
04307             i++;
04308             if (i == (long) (argc-1))
04309               ThrowMogrifyException(OptionError,"MissingArgument",option);
04310             channel=ParseChannelOption(argv[i]);
04311             if (channel < 0)
04312               ThrowMogrifyException(OptionError,"UnrecognizedChannelType",
04313                 argv[i]);
04314             break;
04315           }
04316         if (LocaleCompare("cdl",option+1) == 0)
04317           {
04318             if (*option == '+')
04319               break;
04320             i++;
04321             if (i == (long) (argc-1))
04322               ThrowMogrifyException(OptionError,"MissingArgument",option);
04323             break;
04324           }
04325         if (LocaleCompare("charcoal",option+1) == 0)
04326           {
04327             if (*option == '+')
04328               break;
04329             i++;
04330             if (i == (long) argc)
04331               ThrowMogrifyException(OptionError,"MissingArgument",option);
04332             if (IsGeometry(argv[i]) == MagickFalse)
04333               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04334             break;
04335           }
04336         if (LocaleCompare("chop",option+1) == 0)
04337           {
04338             if (*option == '+')
04339               break;
04340             i++;
04341             if (i == (long) argc)
04342               ThrowMogrifyException(OptionError,"MissingArgument",option);
04343             if (IsGeometry(argv[i]) == MagickFalse)
04344               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04345             break;
04346           }
04347         if (LocaleCompare("clamp",option+1) == 0)
04348           break;
04349         if (LocaleCompare("clip",option+1) == 0)
04350           break;
04351         if (LocaleCompare("clip-mask",option+1) == 0)
04352           {
04353             if (*option == '+')
04354               break;
04355             i++;
04356             if (i == (long) argc)
04357               ThrowMogrifyException(OptionError,"MissingArgument",option);
04358             break;
04359           }
04360         if (LocaleCompare("clut",option+1) == 0)
04361           break;
04362         if (LocaleCompare("coalesce",option+1) == 0)
04363           break;
04364         if (LocaleCompare("colorize",option+1) == 0)
04365           {
04366             if (*option == '+')
04367               break;
04368             i++;
04369             if (i == (long) argc)
04370               ThrowMogrifyException(OptionError,"MissingArgument",option);
04371             if (IsGeometry(argv[i]) == MagickFalse)
04372               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04373             break;
04374           }
04375         if (LocaleCompare("colors",option+1) == 0)
04376           {
04377             if (*option == '+')
04378               break;
04379             i++;
04380             if (i == (long) argc)
04381               ThrowMogrifyException(OptionError,"MissingArgument",option);
04382             if (IsGeometry(argv[i]) == MagickFalse)
04383               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04384             break;
04385           }
04386         if (LocaleCompare("colorspace",option+1) == 0)
04387           {
04388             long
04389               colorspace;
04390 
04391             if (*option == '+')
04392               break;
04393             i++;
04394             if (i == (long) argc)
04395               ThrowMogrifyException(OptionError,"MissingArgument",option);
04396             colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
04397               argv[i]);
04398             if (colorspace < 0)
04399               ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
04400                 argv[i]);
04401             break;
04402           }
04403         if (LocaleCompare("combine",option+1) == 0)
04404           break;
04405         if (LocaleCompare("comment",option+1) == 0)
04406           {
04407             if (*option == '+')
04408               break;
04409             i++;
04410             if (i == (long) argc)
04411               ThrowMogrifyException(OptionError,"MissingArgument",option);
04412             break;
04413           }
04414         if (LocaleCompare("composite",option+1) == 0)
04415           break;
04416         if (LocaleCompare("compress",option+1) == 0)
04417           {
04418             long
04419               compress;
04420 
04421             if (*option == '+')
04422               break;
04423             i++;
04424             if (i == (long) argc)
04425               ThrowMogrifyException(OptionError,"MissingArgument",option);
04426             compress=ParseMagickOption(MagickCompressOptions,MagickFalse,
04427               argv[i]);
04428             if (compress < 0)
04429               ThrowMogrifyException(OptionError,"UnrecognizedImageCompression",
04430                 argv[i]);
04431             break;
04432           }
04433         if (LocaleCompare("concurrent",option+1) == 0)
04434           break;
04435         if (LocaleCompare("contrast",option+1) == 0)
04436           break;
04437         if (LocaleCompare("contrast-stretch",option+1) == 0)
04438           {
04439             i++;
04440             if (i == (long) argc)
04441               ThrowMogrifyException(OptionError,"MissingArgument",option);
04442             if (IsGeometry(argv[i]) == MagickFalse)
04443               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04444             break;
04445           }
04446         if (LocaleCompare("convolve",option+1) == 0)
04447           {
04448             if (*option == '+')
04449               break;
04450             i++;
04451             if (i == (long) argc)
04452               ThrowMogrifyException(OptionError,"MissingArgument",option);
04453             if (IsGeometry(argv[i]) == MagickFalse)
04454               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04455             break;
04456           }
04457         if (LocaleCompare("crop",option+1) == 0)
04458           {
04459             if (*option == '+')
04460               break;
04461             i++;
04462             if (i == (long) argc)
04463               ThrowMogrifyException(OptionError,"MissingArgument",option);
04464             if (IsGeometry(argv[i]) == MagickFalse)
04465               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04466             break;
04467           }
04468         if (LocaleCompare("cycle",option+1) == 0)
04469           {
04470             if (*option == '+')
04471               break;
04472             i++;
04473             if (i == (long) argc)
04474               ThrowMogrifyException(OptionError,"MissingArgument",option);
04475             if (IsGeometry(argv[i]) == MagickFalse)
04476               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04477             break;
04478           }
04479         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
04480       }
04481       case 'd':
04482       {
04483         if (LocaleCompare("decipher",option+1) == 0)
04484           {
04485             if (*option == '+')
04486               break;
04487             i++;
04488             if (i == (long) (argc-1))
04489               ThrowMogrifyException(OptionError,"MissingArgument",option);
04490             break;
04491           }
04492         if (LocaleCompare("deconstruct",option+1) == 0)
04493           break;
04494         if (LocaleCompare("debug",option+1) == 0)
04495           {
04496             long
04497               event;
04498 
04499             if (*option == '+')
04500               break;
04501             i++;
04502             if (i == (long) argc)
04503               ThrowMogrifyException(OptionError,"MissingArgument",option);
04504             event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]);
04505             if (event < 0)
04506               ThrowMogrifyException(OptionError,"UnrecognizedEventType",
04507                 argv[i]);
04508             (void) SetLogEventMask(argv[i]);
04509             break;
04510           }
04511         if (LocaleCompare("define",option+1) == 0)
04512           {
04513             i++;
04514             if (i == (long) argc)
04515               ThrowMogrifyException(OptionError,"MissingArgument",option);
04516             if (*option == '+')
04517               {
04518                 const char
04519                   *define;
04520 
04521                 define=GetImageOption(image_info,argv[i]);
04522                 if (define == (const char *) NULL)
04523                   ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]);
04524                 break;
04525               }
04526             break;
04527           }
04528         if (LocaleCompare("delay",option+1) == 0)
04529           {
04530             if (*option == '+')
04531               break;
04532             i++;
04533             if (i == (long) argc)
04534               ThrowMogrifyException(OptionError,"MissingArgument",option);
04535             if (IsGeometry(argv[i]) == MagickFalse)
04536               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04537             break;
04538           }
04539         if (LocaleCompare("density",option+1) == 0)
04540           {
04541             if (*option == '+')
04542               break;
04543             i++;
04544             if (i == (long) argc)
04545               ThrowMogrifyException(OptionError,"MissingArgument",option);
04546             if (IsGeometry(argv[i]) == MagickFalse)
04547               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04548             break;
04549           }
04550         if (LocaleCompare("depth",option+1) == 0)
04551           {
04552             if (*option == '+')
04553               break;
04554             i++;
04555             if (i == (long) argc)
04556               ThrowMogrifyException(OptionError,"MissingArgument",option);
04557             if (IsGeometry(argv[i]) == MagickFalse)
04558               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04559             break;
04560           }
04561         if (LocaleCompare("deskew",option+1) == 0)
04562           {
04563             if (*option == '+')
04564               break;
04565             i++;
04566             if (i == (long) argc)
04567               ThrowMogrifyException(OptionError,"MissingArgument",option);
04568             if (IsGeometry(argv[i]) == MagickFalse)
04569               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04570             break;
04571           }
04572         if (LocaleCompare("despeckle",option+1) == 0)
04573           break;
04574         if (LocaleCompare("dft",option+1) == 0)
04575           break;
04576         if (LocaleCompare("display",option+1) == 0)
04577           {
04578             if (*option == '+')
04579               break;
04580             i++;
04581             if (i == (long) argc)
04582               ThrowMogrifyException(OptionError,"MissingArgument",option);
04583             break;
04584           }
04585         if (LocaleCompare("dispose",option+1) == 0)
04586           {
04587             long
04588               dispose;
04589 
04590             if (*option == '+')
04591               break;
04592             i++;
04593             if (i == (long) argc)
04594               ThrowMogrifyException(OptionError,"MissingArgument",option);
04595             dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]);
04596             if (dispose < 0)
04597               ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod",
04598                 argv[i]);
04599             break;
04600           }
04601         if (LocaleCompare("distort",option+1) == 0)
04602           {
04603             long
04604               op;
04605 
04606             i++;
04607             if (i == (long) argc)
04608               ThrowMogrifyException(OptionError,"MissingArgument",option);
04609             op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]);
04610             if (op < 0)
04611               ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod",
04612                 argv[i]);
04613             i++;
04614             if (i == (long) (argc-1))
04615               ThrowMogrifyException(OptionError,"MissingArgument",option);
04616             break;
04617           }
04618         if (LocaleCompare("dither",option+1) == 0)
04619           {
04620             long
04621               method;
04622 
04623             if (*option == '+')
04624               break;
04625             i++;
04626             if (i == (long) argc)
04627               ThrowMogrifyException(OptionError,"MissingArgument",option);
04628             method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]);
04629             if (method < 0)
04630               ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod",
04631                 argv[i]);
04632             break;
04633           }
04634         if (LocaleCompare("draw",option+1) == 0)
04635           {
04636             if (*option == '+')
04637               break;
04638             i++;
04639             if (i == (long) argc)
04640               ThrowMogrifyException(OptionError,"MissingArgument",option);
04641             break;
04642           }
04643         if (LocaleCompare("duration",option+1) == 0)
04644           {
04645             if (*option == '+')
04646               break;
04647             i++;
04648             if (i == (long) (argc-1))
04649               ThrowMogrifyException(OptionError,"MissingArgument",option);
04650             if (IsGeometry(argv[i]) == MagickFalse)
04651               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04652             break;
04653           }
04654         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
04655       }
04656       case 'e':
04657       {
04658         if (LocaleCompare("edge",option+1) == 0)
04659           {
04660             if (*option == '+')
04661               break;
04662             i++;
04663             if (i == (long) argc)
04664               ThrowMogrifyException(OptionError,"MissingArgument",option);
04665             if (IsGeometry(argv[i]) == MagickFalse)
04666               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04667             break;
04668           }
04669         if (LocaleCompare("emboss",option+1) == 0)
04670           {
04671             if (*option == '+')
04672               break;
04673             i++;
04674             if (i == (long) argc)
04675               ThrowMogrifyException(OptionError,"MissingArgument",option);
04676             if (IsGeometry(argv[i]) == MagickFalse)
04677               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04678             break;
04679           }
04680         if (LocaleCompare("encipher",option+1) == 0)
04681           {
04682             if (*option == '+')
04683               break;
04684             i++;
04685             if (i == (long) argc)
04686               ThrowMogrifyException(OptionError,"MissingArgument",option);
04687             break;
04688           }
04689         if (LocaleCompare("encoding",option+1) == 0)
04690           {
04691             if (*option == '+')
04692               break;
04693             i++;
04694             if (i == (long) argc)
04695               ThrowMogrifyException(OptionError,"MissingArgument",option);
04696             break;
04697           }
04698         if (LocaleCompare("endian",option+1) == 0)
04699           {
04700             long
04701               endian;
04702 
04703             if (*option == '+')
04704               break;
04705             i++;
04706             if (i == (long) argc)
04707               ThrowMogrifyException(OptionError,"MissingArgument",option);
04708             endian=ParseMagickOption(MagickEndianOptions,MagickFalse,argv[i]);
04709             if (endian < 0)
04710               ThrowMogrifyException(OptionError,"UnrecognizedEndianType",
04711                 argv[i]);
04712             break;
04713           }
04714         if (LocaleCompare("enhance",option+1) == 0)
04715           break;
04716         if (LocaleCompare("equalize",option+1) == 0)
04717           break;
04718         if (LocaleCompare("evaluate",option+1) == 0)
04719           {
04720             long
04721               op;
04722 
04723             if (*option == '+')
04724               break;
04725             i++;
04726             if (i == (long) argc)
04727               ThrowMogrifyException(OptionError,"MissingArgument",option);
04728             op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]);
04729             if (op < 0)
04730               ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator",
04731                 argv[i]);
04732             i++;
04733             if (i == (long) (argc-1))
04734               ThrowMogrifyException(OptionError,"MissingArgument",option);
04735             if (IsGeometry(argv[i]) == MagickFalse)
04736               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04737             break;
04738           }
04739         if (LocaleCompare("extent",option+1) == 0)
04740           {
04741             if (*option == '+')
04742               break;
04743             i++;
04744             if (i == (long) argc)
04745               ThrowMogrifyException(OptionError,"MissingArgument",option);
04746             if (IsGeometry(argv[i]) == MagickFalse)
04747               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04748             break;
04749           }
04750         if (LocaleCompare("extract",option+1) == 0)
04751           {
04752             if (*option == '+')
04753               break;
04754             i++;
04755             if (i == (long) argc)
04756               ThrowMogrifyException(OptionError,"MissingArgument",option);
04757             if (IsGeometry(argv[i]) == MagickFalse)
04758               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04759             break;
04760           }
04761         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
04762       }
04763       case 'f':
04764       {
04765         if (LocaleCompare("family",option+1) == 0)
04766           {
04767             if (*option == '+')
04768               break;
04769             i++;
04770             if (i == (long) (argc-1))
04771               ThrowMogrifyException(OptionError,"MissingArgument",option);
04772             break;
04773           }
04774         if (LocaleCompare("fill",option+1) == 0)
04775           {
04776             if (*option == '+')
04777               break;
04778             i++;
04779             if (i == (long) argc)
04780               ThrowMogrifyException(OptionError,"MissingArgument",option);
04781             break;
04782           }
04783         if (LocaleCompare("filter",option+1) == 0)
04784           {
04785             long
04786               filter;
04787 
04788             if (*option == '+')
04789               break;
04790             i++;
04791             if (i == (long) argc)
04792               ThrowMogrifyException(OptionError,"MissingArgument",option);
04793             filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]);
04794             if (filter < 0)
04795               ThrowMogrifyException(OptionError,"UnrecognizedImageFilter",
04796                 argv[i]);
04797             break;
04798           }
04799         if (LocaleCompare("flatten",option+1) == 0)
04800           break;
04801         if (LocaleCompare("flip",option+1) == 0)
04802           break;
04803         if (LocaleCompare("flop",option+1) == 0)
04804           break;
04805         if (LocaleCompare("floodfill",option+1) == 0)
04806           {
04807             if (*option == '+')
04808               break;
04809             i++;
04810             if (i == (long) argc)
04811               ThrowMogrifyException(OptionError,"MissingArgument",option);
04812             if (IsGeometry(argv[i]) == MagickFalse)
04813               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04814             i++;
04815             if (i == (long) argc)
04816               ThrowMogrifyException(OptionError,"MissingArgument",option);
04817             break;
04818           }
04819         if (LocaleCompare("font",option+1) == 0)
04820           {
04821             if (*option == '+')
04822               break;
04823             i++;
04824             if (i == (long) argc)
04825               ThrowMogrifyException(OptionError,"MissingArgument",option);
04826             break;
04827           }
04828         if (LocaleCompare("format",option+1) == 0)
04829           {
04830             (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
04831             (void) CloneString(&format,(char *) NULL);
04832             if (*option == '+')
04833               break;
04834             i++;
04835             if (i == (long) argc)
04836               ThrowMogrifyException(OptionError,"MissingArgument",option);
04837             (void) CloneString(&format,argv[i]);
04838             (void) CopyMagickString(image_info->filename,format,MaxTextExtent);
04839             (void) ConcatenateMagickString(image_info->filename,":",
04840               MaxTextExtent);
04841             (void) SetImageInfo(image_info,MagickFalse,exception);
04842             if (*image_info->magick == '\0')
04843               ThrowMogrifyException(OptionError,"UnrecognizedImageFormat",
04844                 format);
04845             break;
04846           }
04847         if (LocaleCompare("frame",option+1) == 0)
04848           {
04849             if (*option == '+')
04850               break;
04851             i++;
04852             if (i == (long) argc)
04853               ThrowMogrifyException(OptionError,"MissingArgument",option);
04854             if (IsGeometry(argv[i]) == MagickFalse)
04855               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04856             break;
04857           }
04858         if (LocaleCompare("function",option+1) == 0)
04859           {
04860             long
04861               op;
04862 
04863             if (*option == '+')
04864               break;
04865             i++;
04866             if (i == (long) argc)
04867               ThrowMogrifyException(OptionError,"MissingArgument",option);
04868             op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]);
04869             if (op < 0)
04870               ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]);
04871              i++;
04872              if (i == (long) (argc-1))
04873                ThrowMogrifyException(OptionError,"MissingArgument",option);
04874             break;
04875           }
04876         if (LocaleCompare("fuzz",option+1) == 0)
04877           {
04878             if (*option == '+')
04879               break;
04880             i++;
04881             if (i == (long) argc)
04882               ThrowMogrifyException(OptionError,"MissingArgument",option);
04883             if (IsGeometry(argv[i]) == MagickFalse)
04884               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04885             break;
04886           }
04887         if (LocaleCompare("fx",option+1) == 0)
04888           {
04889             if (*option == '+')
04890               break;
04891             i++;
04892             if (i == (long) (argc-1))
04893               ThrowMogrifyException(OptionError,"MissingArgument",option);
04894             break;
04895           }
04896         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
04897       }
04898       case 'g':
04899       {
04900         if (LocaleCompare("gamma",option+1) == 0)
04901           {
04902             i++;
04903             if (i == (long) argc)
04904               ThrowMogrifyException(OptionError,"MissingArgument",option);
04905             if (IsGeometry(argv[i]) == MagickFalse)
04906               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04907             break;
04908           }
04909         if ((LocaleCompare("gaussian-blur",option+1) == 0) ||
04910             (LocaleCompare("gaussian",option+1) == 0))
04911           {
04912             i++;
04913             if (i == (long) argc)
04914               ThrowMogrifyException(OptionError,"MissingArgument",option);
04915             if (IsGeometry(argv[i]) == MagickFalse)
04916               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04917             break;
04918           }
04919         if (LocaleCompare("geometry",option+1) == 0)
04920           {
04921             if (*option == '+')
04922               break;
04923             i++;
04924             if (i == (long) argc)
04925               ThrowMogrifyException(OptionError,"MissingArgument",option);
04926             if (IsGeometry(argv[i]) == MagickFalse)
04927               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04928             break;
04929           }
04930         if (LocaleCompare("gravity",option+1) == 0)
04931           {
04932             long
04933               gravity;
04934 
04935             if (*option == '+')
04936               break;
04937             i++;
04938             if (i == (long) argc)
04939               ThrowMogrifyException(OptionError,"MissingArgument",option);
04940             gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]);
04941             if (gravity < 0)
04942               ThrowMogrifyException(OptionError,"UnrecognizedGravityType",
04943                 argv[i]);
04944             break;
04945           }
04946         if (LocaleCompare("green-primary",option+1) == 0)
04947           {
04948             if (*option == '+')
04949               break;
04950             i++;
04951             if (i == (long) argc)
04952               ThrowMogrifyException(OptionError,"MissingArgument",option);
04953             if (IsGeometry(argv[i]) == MagickFalse)
04954               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04955             break;
04956           }
04957         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
04958       }
04959       case 'h':
04960       {
04961         if (LocaleCompare("hald-clut",option+1) == 0)
04962           break;
04963         if ((LocaleCompare("help",option+1) == 0) ||
04964             (LocaleCompare("-help",option+1) == 0))
04965           return(MogrifyUsage());
04966         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
04967       }
04968       case 'i':
04969       {
04970         if (LocaleCompare("identify",option+1) == 0)
04971           break;
04972         if (LocaleCompare("idft",option+1) == 0)
04973           break;
04974         if (LocaleCompare("implode",option+1) == 0)
04975           {
04976             if (*option == '+')
04977               break;
04978             i++;
04979             if (i == (long) argc)
04980               ThrowMogrifyException(OptionError,"MissingArgument",option);
04981             if (IsGeometry(argv[i]) == MagickFalse)
04982               ThrowMogrifyInvalidArgumentException(option,argv[i]);
04983             break;
04984           }
04985         if (LocaleCompare("intent",option+1) == 0)
04986           {
04987             long
04988               intent;
04989 
04990             if (*option == '+')
04991               break;
04992             i++;
04993             if (i == (long) (argc-1))
04994               ThrowMogrifyException(OptionError,"MissingArgument",option);
04995             intent=ParseMagickOption(MagickIntentOptions,MagickFalse,argv[i]);
04996             if (intent < 0)
04997               ThrowMogrifyException(OptionError,"UnrecognizedIntentType",
04998                 argv[i]);
04999             break;
05000           }
05001         if (LocaleCompare("interlace",option+1) == 0)
05002           {
05003             long
05004               interlace;
05005 
05006             if (*option == '+')
05007               break;
05008             i++;
05009             if (i == (long) argc)
05010               ThrowMogrifyException(OptionError,"MissingArgument",option);
05011             interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse,
05012               argv[i]);
05013             if (interlace < 0)
05014               ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType",
05015                 argv[i]);
05016             break;
05017           }
05018         if (LocaleCompare("interline-spacing",option+1) == 0)
05019           {
05020             if (*option == '+')
05021               break;
05022             i++;
05023             if (i == (long) (argc-1))
05024               ThrowMogrifyException(OptionError,"MissingArgument",option);
05025             if (IsGeometry(argv[i]) == MagickFalse)
05026               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05027             break;
05028           }
05029         if (LocaleCompare("interpolate",option+1) == 0)
05030           {
05031             long
05032               interpolate;
05033 
05034             if (*option == '+')
05035               break;
05036             i++;
05037             if (i == (long) argc)
05038               ThrowMogrifyException(OptionError,"MissingArgument",option);
05039             interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
05040               argv[i]);
05041             if (interpolate < 0)
05042               ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod",
05043                 argv[i]);
05044             break;
05045           }
05046         if (LocaleCompare("interword-spacing",option+1) == 0)
05047           {
05048             if (*option == '+')
05049               break;
05050             i++;
05051             if (i == (long) (argc-1))
05052               ThrowMogrifyException(OptionError,"MissingArgument",option);
05053             if (IsGeometry(argv[i]) == MagickFalse)
05054               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05055             break;
05056           }
05057         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
05058       }
05059       case 'k':
05060       {
05061         if (LocaleCompare("kerning",option+1) == 0)
05062           {
05063             if (*option == '+')
05064               break;
05065             i++;
05066             if (i == (long) (argc-1))
05067               ThrowMogrifyException(OptionError,"MissingArgument",option);
05068             if (IsGeometry(argv[i]) == MagickFalse)
05069               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05070             break;
05071           }
05072         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
05073       }
05074       case 'l':
05075       {
05076         if (LocaleCompare("label",option+1) == 0)
05077           {
05078             if (*option == '+')
05079               break;
05080             i++;
05081             if (i == (long) argc)
05082               ThrowMogrifyException(OptionError,"MissingArgument",option);
05083             break;
05084           }
05085         if (LocaleCompare("lat",option+1) == 0)
05086           {
05087             if (*option == '+')
05088               break;
05089             i++;
05090             if (i == (long) argc)
05091               ThrowMogrifyException(OptionError,"MissingArgument",option);
05092             if (IsGeometry(argv[i]) == MagickFalse)
05093               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05094           }
05095         if (LocaleCompare("layers",option+1) == 0)
05096           {
05097             long
05098               type;
05099 
05100             if (*option == '+')
05101               break;
05102             i++;
05103             if (i == (long) (argc-1))
05104               ThrowMogrifyException(OptionError,"MissingArgument",option);
05105             type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]);
05106             if (type < 0)
05107               ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod",
05108                 argv[i]);
05109             break;
05110           }
05111         if (LocaleCompare("level",option+1) == 0)
05112           {
05113             i++;
05114             if (i == (long) argc)
05115               ThrowMogrifyException(OptionError,"MissingArgument",option);
05116             if (IsGeometry(argv[i]) == MagickFalse)
05117               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05118             break;
05119           }
05120         if (LocaleCompare("level-colors",option+1) == 0)
05121           {
05122             i++;
05123             if (i == (long) argc)
05124               ThrowMogrifyException(OptionError,"MissingArgument",option);
05125             break;
05126           }
05127         if (LocaleCompare("linewidth",option+1) == 0)
05128           {
05129             if (*option == '+')
05130               break;
05131             i++;
05132             if (i == (long) argc)
05133               ThrowMogrifyException(OptionError,"MissingArgument",option);
05134             if (IsGeometry(argv[i]) == MagickFalse)
05135               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05136             break;
05137           }
05138         if (LocaleCompare("limit",option+1) == 0)
05139           {
05140             char
05141               *p;
05142 
05143             double
05144               value;
05145 
05146             long
05147               resource;
05148 
05149             if (*option == '+')
05150               break;
05151             i++;
05152             if (i == (long) argc)
05153               ThrowMogrifyException(OptionError,"MissingArgument",option);
05154             resource=ParseMagickOption(MagickResourceOptions,MagickFalse,
05155               argv[i]);
05156             if (resource < 0)
05157               ThrowMogrifyException(OptionError,"UnrecognizedResourceType",
05158                 argv[i]);
05159             i++;
05160             if (i == (long) argc)
05161               ThrowMogrifyException(OptionError,"MissingArgument",option);
05162             value=strtod(argv[i],&p);
05163             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
05164               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05165             break;
05166           }
05167         if (LocaleCompare("liquid-rescale",option+1) == 0)
05168           {
05169             i++;
05170             if (i == (long) argc)
05171               ThrowMogrifyException(OptionError,"MissingArgument",option);
05172             if (IsGeometry(argv[i]) == MagickFalse)
05173               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05174             break;
05175           }
05176         if (LocaleCompare("list",option+1) == 0)
05177           {
05178             long
05179               list;
05180 
05181             if (*option == '+')
05182               break;
05183             i++;
05184             if (i == (long) argc)
05185               ThrowMogrifyException(OptionError,"MissingArgument",option);
05186             list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]);
05187             if (list < 0)
05188               ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]);
05189             (void) MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
05190               argv+j,exception);
05191             return(MagickTrue);
05192           }
05193         if (LocaleCompare("log",option+1) == 0)
05194           {
05195             if (*option == '+')
05196               break;
05197             i++;
05198             if ((i == (long) argc) ||
05199                 (strchr(argv[i],'%') == (char *) NULL))
05200               ThrowMogrifyException(OptionError,"MissingArgument",option);
05201             break;
05202           }
05203         if (LocaleCompare("loop",option+1) == 0)
05204           {
05205             if (*option == '+')
05206               break;
05207             i++;
05208             if (i == (long) argc)
05209               ThrowMogrifyException(OptionError,"MissingArgument",option);
05210             if (IsGeometry(argv[i]) == MagickFalse)
05211               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05212             break;
05213           }
05214         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
05215       }
05216       case 'm':
05217       {
05218         if (LocaleCompare("map",option+1) == 0)
05219           {
05220             global_colormap=(*option == '+') ? MagickTrue : MagickFalse;
05221             if (*option == '+')
05222               break;
05223             i++;
05224             if (i == (long) argc)
05225               ThrowMogrifyException(OptionError,"MissingArgument",option);
05226             break;
05227           }
05228         if (LocaleCompare("mask",option+1) == 0)
05229           {
05230             if (*option == '+')
05231               break;
05232             i++;
05233             if (i == (long) argc)
05234               ThrowMogrifyException(OptionError,"MissingArgument",option);
05235             break;
05236           }
05237         if (LocaleCompare("matte",option+1) == 0)
05238           break;
05239         if (LocaleCompare("mattecolor",option+1) == 0)
05240           {
05241             if (*option == '+')
05242               break;
05243             i++;
05244             if (i == (long) argc)
05245               ThrowMogrifyException(OptionError,"MissingArgument",option);
05246             break;
05247           }
05248         if (LocaleCompare("modulate",option+1) == 0)
05249           {
05250             if (*option == '+')
05251               break;
05252             i++;
05253             if (i == (long) argc)
05254               ThrowMogrifyException(OptionError,"MissingArgument",option);
05255             if (IsGeometry(argv[i]) == MagickFalse)
05256               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05257             break;
05258           }
05259         if (LocaleCompare("median",option+1) == 0)
05260           {
05261             if (*option == '+')
05262               break;
05263             i++;
05264             if (i == (long) argc)
05265               ThrowMogrifyException(OptionError,"MissingArgument",option);
05266             if (IsGeometry(argv[i]) == MagickFalse)
05267               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05268             break;
05269           }
05270         if (LocaleCompare("monitor",option+1) == 0)
05271           break;
05272         if (LocaleCompare("monochrome",option+1) == 0)
05273           break;
05274         if (LocaleCompare("morph",option+1) == 0)
05275           {
05276             if (*option == '+')
05277               break;
05278             i++;
05279             if (i == (long) (argc-1))
05280               ThrowMogrifyException(OptionError,"MissingArgument",option);
05281             if (IsGeometry(argv[i]) == MagickFalse)
05282               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05283             break;
05284           }
05285         if (LocaleCompare("mosaic",option+1) == 0)
05286           break;
05287         if (LocaleCompare("motion-blur",option+1) == 0)
05288           {
05289             if (*option == '+')
05290               break;
05291             i++;
05292             if (i == (long) argc)
05293               ThrowMogrifyException(OptionError,"MissingArgument",option);
05294             if (IsGeometry(argv[i]) == MagickFalse)
05295               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05296             break;
05297           }
05298         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
05299       }
05300       case 'n':
05301       {
05302         if (LocaleCompare("negate",option+1) == 0)
05303           break;
05304         if (LocaleCompare("noise",option+1) == 0)
05305           {
05306             i++;
05307             if (i == (long) argc)
05308               ThrowMogrifyException(OptionError,"MissingArgument",option);
05309             if (*option == '+')
05310               {
05311                 long
05312                   noise;
05313 
05314                 noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]);
05315                 if (noise < 0)
05316                   ThrowMogrifyException(OptionError,"UnrecognizedNoiseType",
05317                     argv[i]);
05318                 break;
05319               }
05320             if (IsGeometry(argv[i]) == MagickFalse)
05321               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05322             break;
05323           }
05324         if (LocaleCompare("noop",option+1) == 0)
05325           break;
05326         if (LocaleCompare("normalize",option+1) == 0)
05327           break;
05328         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
05329       }
05330       case 'o':
05331       {
05332         if (LocaleCompare("opaque",option+1) == 0)
05333           {
05334             if (*option == '+')
05335               break;
05336             i++;
05337             if (i == (long) argc)
05338               ThrowMogrifyException(OptionError,"MissingArgument",option);
05339             break;
05340           }
05341         if (LocaleCompare("ordered-dither",option+1) == 0)
05342           {
05343             if (*option == '+')
05344               break;
05345             i++;
05346             if (i == (long) argc)
05347               ThrowMogrifyException(OptionError,"MissingArgument",option);
05348             break;
05349           }
05350         if (LocaleCompare("orient",option+1) == 0)
05351           {
05352             long
05353               orientation;
05354 
05355             orientation=UndefinedOrientation;
05356             if (*option == '+')
05357               break;
05358             i++;
05359             if (i == (long) (argc-1))
05360               ThrowMogrifyException(OptionError,"MissingArgument",option);
05361             orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse,
05362               argv[i]);
05363             if (orientation < 0)
05364               ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation",
05365                 argv[i]);
05366             break;
05367           }
05368         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
05369       }
05370       case 'p':
05371       {
05372         if (LocaleCompare("page",option+1) == 0)
05373           {
05374             if (*option == '+')
05375               break;
05376             i++;
05377             if (i == (long) argc)
05378               ThrowMogrifyException(OptionError,"MissingArgument",option);
05379             break;
05380           }
05381         if (LocaleCompare("paint",option+1) == 0)
05382           {
05383             if (*option == '+')
05384               break;
05385             i++;
05386             if (i == (long) argc)
05387               ThrowMogrifyException(OptionError,"MissingArgument",option);
05388             if (IsGeometry(argv[i]) == MagickFalse)
05389               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05390             break;
05391           }
05392         if (LocaleCompare("path",option+1) == 0)
05393           {
05394             (void) CloneString(&path,(char *) NULL);
05395             if (*option == '+')
05396               break;
05397             i++;
05398             if (i == (long) argc)
05399               ThrowMogrifyException(OptionError,"MissingArgument",option);
05400             (void) CloneString(&path,argv[i]);
05401             break;
05402           }
05403         if (LocaleCompare("pointsize",option+1) == 0)
05404           {
05405             if (*option == '+')
05406               break;
05407             i++;
05408             if (i == (long) argc)
05409               ThrowMogrifyException(OptionError,"MissingArgument",option);
05410             if (IsGeometry(argv[i]) == MagickFalse)
05411               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05412             break;
05413           }
05414         if (LocaleCompare("polaroid",option+1) == 0)
05415           {
05416             if (*option == '+')
05417               break;
05418             i++;
05419             if (i == (long) argc)
05420               ThrowMogrifyException(OptionError,"MissingArgument",option);
05421             if (IsGeometry(argv[i]) == MagickFalse)
05422               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05423             break;
05424           }
05425         if (LocaleCompare("posterize",option+1) == 0)
05426           {
05427             if (*option == '+')
05428               break;
05429             i++;
05430             if (i == (long) argc)
05431               ThrowMogrifyException(OptionError,"MissingArgument",option);
05432             if (IsGeometry(argv[i]) == MagickFalse)
05433               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05434             break;
05435           }
05436         if (LocaleCompare("print",option+1) == 0)
05437           {
05438             if (*option == '+')
05439               break;
05440             i++;
05441             if (i == (long) argc)
05442               ThrowMogrifyException(OptionError,"MissingArgument",option);
05443             break;
05444           }
05445         if (LocaleCompare("process",option+1) == 0)
05446           {
05447             if (*option == '+')
05448               break;
05449             i++;
05450             if (i == (long) (argc-1))
05451               ThrowMogrifyException(OptionError,"MissingArgument",option);
05452             break;
05453           }
05454         if (LocaleCompare("profile",option+1) == 0)
05455           {
05456             i++;
05457             if (i == (long) argc)
05458               ThrowMogrifyException(OptionError,"MissingArgument",option);
05459             break;
05460           }
05461         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
05462       }
05463       case 'q':
05464       {
05465         if (LocaleCompare("quality",option+1) == 0)
05466           {
05467             if (*option == '+')
05468               break;
05469             i++;
05470             if (i == (long) argc)
05471               ThrowMogrifyException(OptionError,"MissingArgument",option);
05472             if (IsGeometry(argv[i]) == MagickFalse)
05473               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05474             break;
05475           }
05476         if (LocaleCompare("quantize",option+1) == 0)
05477           {
05478             long
05479               colorspace;
05480 
05481             if (*option == '+')
05482               break;
05483             i++;
05484             if (i == (long) (argc-1))
05485               ThrowMogrifyException(OptionError,"MissingArgument",option);
05486             colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
05487               argv[i]);
05488             if (colorspace < 0)
05489               ThrowMogrifyException(OptionError,"UnrecognizedColorspace",
05490                 argv[i]);
05491             break;
05492           }
05493         if (LocaleCompare("quiet",option+1) == 0)
05494           break;
05495         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
05496       }
05497       case 'r':
05498       {
05499         if (LocaleCompare("radial-blur",option+1) == 0)
05500           {
05501             i++;
05502             if (i == (long) argc)
05503               ThrowMogrifyException(OptionError,"MissingArgument",option);
05504             if (IsGeometry(argv[i]) == MagickFalse)
05505               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05506             break;
05507           }
05508         if (LocaleCompare("raise",option+1) == 0)
05509           {
05510             i++;
05511             if (i == (long) argc)
05512               ThrowMogrifyException(OptionError,"MissingArgument",option);
05513             if (IsGeometry(argv[i]) == MagickFalse)
05514               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05515             break;
05516           }
05517         if (LocaleCompare("random-threshold",option+1) == 0)
05518           {
05519             if (*option == '+')
05520               break;
05521             i++;
05522             if (i == (long) argc)
05523               ThrowMogrifyException(OptionError,"MissingArgument",option);
05524             if (IsGeometry(argv[i]) == MagickFalse)
05525               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05526             break;
05527           }
05528         if (LocaleCompare("red-primary",option+1) == 0)
05529           {
05530             if (*option == '+')
05531               break;
05532             i++;
05533             if (i == (long) argc)
05534               ThrowMogrifyException(OptionError,"MissingArgument",option);
05535             if (IsGeometry(argv[i]) == MagickFalse)
05536               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05537           }
05538         if (LocaleCompare("region",option+1) == 0)
05539           {
05540             if (*option == '+')
05541               break;
05542             i++;
05543             if (i == (long) argc)
05544               ThrowMogrifyException(OptionError,"MissingArgument",option);
05545             if (IsGeometry(argv[i]) == MagickFalse)
05546               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05547             break;
05548           }
05549         if (LocaleCompare("render",option+1) == 0)
05550           break;
05551         if (LocaleCompare("repage",option+1) == 0)
05552           {
05553             if (*option == '+')
05554               break;
05555             i++;
05556             if (i == (long) argc)
05557               ThrowMogrifyException(OptionError,"MissingArgument",option);
05558             if (IsGeometry(argv[i]) == MagickFalse)
05559               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05560             break;
05561           }
05562         if (LocaleCompare("resample",option+1) == 0)
05563           {
05564             if (*option == '+')
05565               break;
05566             i++;
05567             if (i == (long) argc)
05568               ThrowMogrifyException(OptionError,"MissingArgument",option);
05569             if (IsGeometry(argv[i]) == MagickFalse)
05570               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05571             break;
05572           }
05573         if (LocaleCompare("resize",option+1) == 0)
05574           {
05575             if (*option == '+')
05576               break;
05577             i++;
05578             if (i == (long) argc)
05579               ThrowMogrifyException(OptionError,"MissingArgument",option);
05580             if (IsGeometry(argv[i]) == MagickFalse)
05581               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05582             break;
05583           }
05584         if (LocaleCompare("reverse",option+1) == 0)
05585           break;
05586         if (LocaleCompare("roll",option+1) == 0)
05587           {
05588             if (*option == '+')
05589               break;
05590             i++;
05591             if (i == (long) argc)
05592               ThrowMogrifyException(OptionError,"MissingArgument",option);
05593             if (IsGeometry(argv[i]) == MagickFalse)
05594               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05595             break;
05596           }
05597         if (LocaleCompare("rotate",option+1) == 0)
05598           {
05599             i++;
05600             if (i == (long) argc)
05601               ThrowMogrifyException(OptionError,"MissingArgument",option);
05602             if (IsGeometry(argv[i]) == MagickFalse)
05603               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05604             break;
05605           }
05606         ThrowMogrifyException(OptionError,"UnrecognizedOption",option)
05607       }
05608       case 's':
05609       {
05610         if (LocaleCompare("sample",option+1) == 0)
05611           {
05612             if (*option == '+')
05613               break;
05614             i++;
05615             if (i == (long) argc)
05616               ThrowMogrifyException(OptionError,"MissingArgument",option);
05617             if (IsGeometry(argv[i]) == MagickFalse)
05618               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05619             break;
05620           }
05621         if (LocaleCompare("sampling-factor",option+1) == 0)
05622           {
05623             if (*option == '+')
05624               break;
05625             i++;
05626             if (i == (long) argc)
05627               ThrowMogrifyException(OptionError,"MissingArgument",option);
05628             if (IsGeometry(argv[i]) == MagickFalse)
05629               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05630             break;
05631           }
05632         if (LocaleCompare("scale",option+1) == 0)
05633           {
05634             if (*option == '+')
05635               break;
05636             i++;
05637             if (i == (long) argc)
05638               ThrowMogrifyException(OptionError,"MissingArgument",option);
05639             if (IsGeometry(argv[i]) == MagickFalse)
05640               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05641             break;
05642           }
05643         if (LocaleCompare("scene",option+1) == 0)
05644           {
05645             if (*option == '+')
05646               break;
05647             i++;
05648             if (i == (long) argc)
05649               ThrowMogrifyException(OptionError,"MissingArgument",option);
05650             if (IsGeometry(argv[i]) == MagickFalse)
05651               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05652             break;
05653           }
05654         if (LocaleCompare("seed",option+1) == 0)
05655           {
05656             if (*option == '+')
05657               break;
05658             i++;
05659             if (i == (long) argc)
05660               ThrowMogrifyException(OptionError,"MissingArgument",option);
05661             if (IsGeometry(argv[i]) == MagickFalse)
05662               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05663             break;
05664           }
05665         if (LocaleCompare("segment",option+1) == 0)
05666           {
05667             if (*option == '+')
05668               break;
05669             i++;
05670             if (i == (long) argc)
05671               ThrowMogrifyException(OptionError,"MissingArgument",option);
05672             if (IsGeometry(argv[i]) == MagickFalse)
05673               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05674             break;
05675           }
05676         if (LocaleCompare("selective-blur",option+1) == 0)
05677           {
05678             i++;
05679             if (i == (long) argc)
05680               ThrowMogrifyException(OptionError,"MissingArgument",option);
05681             if (IsGeometry(argv[i]) == MagickFalse)
05682               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05683             break;
05684           }
05685         if (LocaleCompare("separate",option+1) == 0)
05686           break;
05687         if (LocaleCompare("sepia-tone",option+1) == 0)
05688           {
05689             if (*option == '+')
05690               break;
05691             i++;
05692             if (i == (long) argc)
05693               ThrowMogrifyException(OptionError,"MissingArgument",option);
05694             if (IsGeometry(argv[i]) == MagickFalse)
05695               ThrowMogrifyInvalidArgumentException(option,argv[i]);
05696             break;
05697           }
05698         if (LocaleCompare("set",option+1) == 0)
05699           {
05700             i++;
05701             if (i == (long) argc)
05702               ThrowMogrifyException(OptionError,"MissingArgument",option);
05703             if (*option == '+')
05704               break;
05705             i++;
05706             if (i == (long) argc)
05707               ThrowMogrifyException(OptionError,"MissingArgument",option);
05708             break;
05709           }
05710         if (LocaleCompare("shade",option+1) == 0)
0