| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* | 
 | 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 3 | %                                                                             % | 
 | 4 | %                                                                             % | 
 | 5 | %                                                                             % | 
 | 6 | %              M   M   OOO   GGGGG  RRRR   IIIII  FFFFF  Y   Y                % | 
 | 7 | %              MM MM  O   O  G      R   R    I    F       Y Y                 % | 
 | 8 | %              M M M  O   O  G GGG  RRRR     I    FFF      Y                  % | 
 | 9 | %              M   M  O   O  G   G  R R      I    F        Y                  % | 
 | 10 | %              M   M   OOO   GGGG   R  R   IIIII  F        Y                  % | 
 | 11 | %                                                                             % | 
 | 12 | %                                                                             % | 
 | 13 | %                         MagickWand Module Methods                           % | 
 | 14 | %                                                                             % | 
 | 15 | %                              Software Design                                % | 
 | 16 | %                                John Cristy                                  % | 
 | 17 | %                                March 2000                                   % | 
 | 18 | %                                                                             % | 
 | 19 | %                                                                             % | 
| cristy | 7e41fe8 | 2010-12-04 23:12:08 +0000 | [diff] [blame] | 20 | %  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      % | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | %  dedicated to making software imaging solutions freely available.           % | 
 | 22 | %                                                                             % | 
 | 23 | %  You may not use this file except in compliance with the License.  You may  % | 
 | 24 | %  obtain a copy of the License at                                            % | 
 | 25 | %                                                                             % | 
 | 26 | %    http://www.imagemagick.org/script/license.php                            % | 
 | 27 | %                                                                             % | 
 | 28 | %  Unless required by applicable law or agreed to in writing, software        % | 
 | 29 | %  distributed under the License is distributed on an "AS IS" BASIS,          % | 
 | 30 | %  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   % | 
 | 31 | %  See the License for the specific language governing permissions and        % | 
 | 32 | %  limitations under the License.                                             % | 
 | 33 | %                                                                             % | 
 | 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 35 | % | 
 | 36 | %  Use the mogrify program to resize an image, blur, crop, despeckle, dither, | 
 | 37 | %  draw on, flip, join, re-sample, and much more. This tool is similiar to | 
 | 38 | %  convert except that the original image file is overwritten (unless you | 
 | 39 | %  change the file suffix with the -format option) with any changes you | 
| cristy | 6a917d9 | 2009-10-06 19:23:54 +0000 | [diff] [blame] | 40 | %  request. | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 41 | % | 
 | 42 | */ | 
 | 43 |  | 
 | 44 | /* | 
 | 45 |   Include declarations. | 
 | 46 | */ | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 47 | #include "MagickWand/studio.h" | 
 | 48 | #include "MagickWand/MagickWand.h" | 
 | 49 | #include "MagickWand/mogrify-private.h" | 
 | 50 | #undef DegreesToRadians | 
 | 51 | #undef RadiansToDegrees | 
 | 52 | #include "MagickCore/image-private.h" | 
 | 53 | #include "MagickCore/monitor-private.h" | 
 | 54 | #include "MagickCore/thread-private.h" | 
 | 55 | #include "MagickCore/string-private.h" | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 56 |  | 
 | 57 | /* | 
| cristy | 154fa9d | 2011-08-05 14:25:15 +0000 | [diff] [blame^] | 58 |  Constant declaration. | 
 | 59 | */ | 
 | 60 | const char | 
 | 61 |   BackgroundColor[] = "#ffffff",  /* white */ | 
 | 62 |   BorderColor[] = "#dfdfdf",  /* gray */ | 
 | 63 |   MatteColor[] = "#bdbdbd";  /* gray */ | 
 | 64 |  | 
 | 65 | /* | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 66 |   Define declarations. | 
 | 67 | */ | 
 | 68 | #define UndefinedCompressionQuality  0UL | 
 | 69 |  | 
 | 70 | /* | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 71 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 72 | %                                                                             % | 
 | 73 | %                                                                             % | 
 | 74 | %                                                                             % | 
| cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 75 | %     M a g i c k C o m m a n d G e n e s i s                                 % | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 76 | %                                                                             % | 
 | 77 | %                                                                             % | 
 | 78 | %                                                                             % | 
 | 79 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 80 | % | 
 | 81 | %  MagickCommandGenesis() applies image processing options to an image as | 
 | 82 | %  prescribed by command line options. | 
 | 83 | % | 
 | 84 | %  The format of the MagickCommandGenesis method is: | 
 | 85 | % | 
 | 86 | %      MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, | 
| cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 87 | %        MagickCommand command,int argc,char **argv,char **metadata, | 
 | 88 | %        ExceptionInfo *exception) | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 89 | % | 
 | 90 | %  A description of each parameter follows: | 
 | 91 | % | 
 | 92 | %    o image_info: the image info. | 
 | 93 | % | 
| cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 94 | %    o command: Choose from ConvertImageCommand, IdentifyImageCommand, | 
| cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 95 | %      MogrifyImageCommand, CompositeImageCommand, CompareImagesCommand, | 
| cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 96 | %      ConjureImageCommand, StreamImageCommand, ImportImageCommand, | 
 | 97 | %      DisplayImageCommand, or AnimateImageCommand. | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 98 | % | 
 | 99 | %    o argc: Specifies a pointer to an integer describing the number of | 
 | 100 | %      elements in the argument vector. | 
 | 101 | % | 
 | 102 | %    o argv: Specifies a pointer to a text array containing the command line | 
 | 103 | %      arguments. | 
 | 104 | % | 
| cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 105 | %    o metadata: any metadata is returned here. | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 106 | % | 
 | 107 | %    o exception: return any errors or warnings in this structure. | 
 | 108 | % | 
 | 109 | */ | 
 | 110 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, | 
 | 111 |   MagickCommand command,int argc,char **argv,char **metadata, | 
 | 112 |   ExceptionInfo *exception) | 
 | 113 | { | 
 | 114 |   char | 
 | 115 |     *option; | 
 | 116 |  | 
 | 117 |   double | 
 | 118 |     duration, | 
 | 119 |     elapsed_time, | 
 | 120 |     user_time; | 
 | 121 |  | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 122 |   MagickBooleanType | 
 | 123 |     concurrent, | 
 | 124 |     regard_warnings, | 
 | 125 |     status; | 
 | 126 |  | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 127 |   register ssize_t | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 128 |     i; | 
 | 129 |  | 
 | 130 |   TimerInfo | 
 | 131 |     *timer; | 
 | 132 |  | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 133 |   size_t | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 134 |     iterations; | 
 | 135 |  | 
| cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 136 |   (void) setlocale(LC_ALL,""); | 
 | 137 |   (void) setlocale(LC_NUMERIC,"C"); | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 138 |   concurrent=MagickFalse; | 
 | 139 |   duration=(-1.0); | 
 | 140 |   iterations=1; | 
| cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 141 |   status=MagickFalse; | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 142 |   regard_warnings=MagickFalse; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 143 |   for (i=1; i < (ssize_t) (argc-1); i++) | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 144 |   { | 
 | 145 |     option=argv[i]; | 
 | 146 |     if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) | 
 | 147 |       continue; | 
 | 148 |     if (LocaleCompare("bench",option+1) == 0) | 
| cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 149 |       iterations=StringToUnsignedLong(argv[++i]); | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 150 |     if (LocaleCompare("concurrent",option+1) == 0) | 
 | 151 |       concurrent=MagickTrue; | 
 | 152 |     if (LocaleCompare("debug",option+1) == 0) | 
 | 153 |       (void) SetLogEventMask(argv[++i]); | 
 | 154 |     if (LocaleCompare("duration",option+1) == 0) | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 155 |       duration=InterpretLocaleValue(argv[++i],(char **) NULL); | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 156 |     if (LocaleCompare("regard-warnings",option+1) == 0) | 
 | 157 |       regard_warnings=MagickTrue; | 
 | 158 |   } | 
 | 159 |   timer=AcquireTimerInfo(); | 
| cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 160 |   if (concurrent == MagickFalse) | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 161 |     { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 162 |       for (i=0; i < (ssize_t) iterations; i++) | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 163 |       { | 
| cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 164 |         if (status != MagickFalse) | 
| cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 165 |           continue; | 
 | 166 |         if (duration > 0) | 
 | 167 |           { | 
 | 168 |             if (GetElapsedTime(timer) > duration) | 
 | 169 |               continue; | 
 | 170 |             (void) ContinueTimer(timer); | 
 | 171 |           } | 
 | 172 |         status=command(image_info,argc,argv,metadata,exception); | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 173 |         if (exception->severity != UndefinedException) | 
 | 174 |           { | 
 | 175 |             if ((exception->severity > ErrorException) || | 
 | 176 |                 (regard_warnings != MagickFalse)) | 
 | 177 |               status=MagickTrue; | 
 | 178 |             CatchException(exception); | 
 | 179 |           } | 
| cristy | 3d1a551 | 2009-10-25 21:23:27 +0000 | [diff] [blame] | 180 |         if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 181 |           { | 
 | 182 |             (void) fputs(*metadata,stdout); | 
 | 183 |             (void) fputc('\n',stdout); | 
 | 184 |             *metadata=DestroyString(*metadata); | 
 | 185 |           } | 
 | 186 |       } | 
 | 187 |     } | 
| cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 188 |   else | 
 | 189 |     { | 
 | 190 |       SetOpenMPNested(1); | 
| cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 191 | #if defined(MAGICKCORE_OPENMP_SUPPORT) | 
| cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 192 |   # pragma omp parallel for shared(status) | 
 | 193 | #endif | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 194 |       for (i=0; i < (ssize_t) iterations; i++) | 
| cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 195 |       { | 
| cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 196 |         if (status != MagickFalse) | 
| cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 197 |           continue; | 
 | 198 |         if (duration > 0) | 
 | 199 |           { | 
 | 200 |             if (GetElapsedTime(timer) > duration) | 
 | 201 |               continue; | 
 | 202 |             (void) ContinueTimer(timer); | 
 | 203 |           } | 
 | 204 |         status=command(image_info,argc,argv,metadata,exception); | 
| cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 205 | #if defined(MAGICKCORE_OPENMP_SUPPORT) | 
| cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 206 |   # pragma omp critical (MagickCore_CommandGenesis) | 
| cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 207 | #endif | 
 | 208 |         { | 
 | 209 |           if (exception->severity != UndefinedException) | 
 | 210 |             { | 
 | 211 |               if ((exception->severity > ErrorException) || | 
 | 212 |                   (regard_warnings != MagickFalse)) | 
 | 213 |                 status=MagickTrue; | 
 | 214 |               CatchException(exception); | 
 | 215 |             } | 
 | 216 |           if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) | 
 | 217 |             { | 
 | 218 |               (void) fputs(*metadata,stdout); | 
 | 219 |               (void) fputc('\n',stdout); | 
 | 220 |               *metadata=DestroyString(*metadata); | 
 | 221 |             } | 
 | 222 |         } | 
 | 223 |       } | 
 | 224 |     } | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 225 |   if (iterations > 1) | 
 | 226 |     { | 
 | 227 |       elapsed_time=GetElapsedTime(timer); | 
 | 228 |       user_time=GetUserTime(timer); | 
| cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 229 |       (void) FormatLocaleFile(stderr, | 
| cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 230 |         "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double) | 
 | 231 |         iterations,1.0*iterations/elapsed_time,user_time,(double) | 
 | 232 |         (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double) | 
 | 233 |         (1000.0*(elapsed_time-floor(elapsed_time)))); | 
| cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 234 |       (void) fflush(stderr); | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 235 |     } | 
 | 236 |   timer=DestroyTimerInfo(timer); | 
| cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 237 |   return(status); | 
| cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 238 | } | 
 | 239 |  | 
 | 240 | /* | 
 | 241 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 242 | %                                                                             % | 
 | 243 | %                                                                             % | 
 | 244 | %                                                                             % | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 245 | +     M o g r i f y I m a g e                                                 % | 
 | 246 | %                                                                             % | 
 | 247 | %                                                                             % | 
 | 248 | %                                                                             % | 
 | 249 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 250 | % | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 251 | %  MogrifyImage() applies simple single image processing options to a single | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 252 | %  image that may be part of a large list, but also handles any 'region' | 
 | 253 | %  image handling. | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 254 | % | 
 | 255 | %  The image in the list may be modified in three different ways... | 
 | 256 | % | 
 | 257 | %    * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), | 
 | 258 | %    * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) | 
 | 259 | %    * replace by a list of images (only the -separate option!) | 
 | 260 | % | 
 | 261 | %  In each case the result is returned into the list, and a pointer to the | 
 | 262 | %  modified image (last image added if replaced by a list of images) is | 
 | 263 | %  returned. | 
 | 264 | % | 
 | 265 | %  ASIDE: The -crop is present but restricted to non-tile single image crops | 
 | 266 | % | 
 | 267 | %  This means if all the images are being processed (such as by | 
 | 268 | %  MogrifyImages(), next image to be processed will be as per the pointer | 
 | 269 | %  (*image)->next.  Also the image list may grow as a result of some specific | 
 | 270 | %  operations but as images are never merged or deleted, it will never shrink | 
 | 271 | %  in length.  Typically the list will remain the same length. | 
 | 272 | % | 
 | 273 | %  WARNING: As the image pointed to may be replaced, the first image in the | 
 | 274 | %  list may also change.  GetFirstImageInList() should be used by caller if | 
 | 275 | %  they wish return the Image pointer to the first image in list. | 
 | 276 | % | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 277 | % | 
 | 278 | %  The format of the MogrifyImage method is: | 
 | 279 | % | 
 | 280 | %      MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, | 
 | 281 | %        const char **argv,Image **image) | 
 | 282 | % | 
 | 283 | %  A description of each parameter follows: | 
 | 284 | % | 
 | 285 | %    o image_info: the image info.. | 
 | 286 | % | 
 | 287 | %    o argc: Specifies a pointer to an integer describing the number of | 
 | 288 | %      elements in the argument vector. | 
 | 289 | % | 
 | 290 | %    o argv: Specifies a pointer to a text array containing the command line | 
 | 291 | %      arguments. | 
 | 292 | % | 
 | 293 | %    o image: the image. | 
 | 294 | % | 
 | 295 | %    o exception: return any errors or warnings in this structure. | 
 | 296 | % | 
 | 297 | */ | 
 | 298 |  | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 299 | /* | 
 | 300 | ** GetImageCache() will read an image into a image cache if not already | 
 | 301 | ** present then return the image that is in the cache under that filename. | 
 | 302 | */ | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 303 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, | 
 | 304 |   ExceptionInfo *exception) | 
 | 305 | { | 
 | 306 |   char | 
 | 307 |     key[MaxTextExtent]; | 
 | 308 |  | 
 | 309 |   ExceptionInfo | 
 | 310 |     *sans_exception; | 
 | 311 |  | 
 | 312 |   Image | 
 | 313 |     *image; | 
 | 314 |  | 
 | 315 |   ImageInfo | 
 | 316 |     *read_info; | 
 | 317 |  | 
| cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 318 |   (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 319 |   sans_exception=AcquireExceptionInfo(); | 
 | 320 |   image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); | 
 | 321 |   sans_exception=DestroyExceptionInfo(sans_exception); | 
 | 322 |   if (image != (Image *) NULL) | 
 | 323 |     return(image); | 
 | 324 |   read_info=CloneImageInfo(image_info); | 
 | 325 |   (void) CopyMagickString(read_info->filename,path,MaxTextExtent); | 
 | 326 |   image=ReadImage(read_info,exception); | 
 | 327 |   read_info=DestroyImageInfo(read_info); | 
 | 328 |   if (image != (Image *) NULL) | 
 | 329 |     (void) SetImageRegistry(ImageRegistryType,key,image,exception); | 
 | 330 |   return(image); | 
 | 331 | } | 
 | 332 |  | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 333 | static MagickBooleanType IsPathWritable(const char *path) | 
 | 334 | { | 
 | 335 |   if (IsPathAccessible(path) == MagickFalse) | 
 | 336 |     return(MagickFalse); | 
 | 337 |   if (access(path,W_OK) != 0) | 
 | 338 |     return(MagickFalse); | 
 | 339 |   return(MagickTrue); | 
 | 340 | } | 
 | 341 |  | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 342 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 343 | { | 
 | 344 |   if (x > y) | 
 | 345 |     return(x); | 
 | 346 |   return(y); | 
 | 347 | } | 
 | 348 |  | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 349 | static MagickBooleanType MonitorProgress(const char *text, | 
 | 350 |   const MagickOffsetType offset,const MagickSizeType extent, | 
 | 351 |   void *wand_unused(client_data)) | 
 | 352 | { | 
 | 353 |   char | 
 | 354 |     message[MaxTextExtent], | 
 | 355 |     tag[MaxTextExtent]; | 
 | 356 |  | 
 | 357 |   const char | 
 | 358 |     *locale_message; | 
 | 359 |  | 
 | 360 |   register char | 
 | 361 |     *p; | 
 | 362 |  | 
 | 363 |   if (extent < 2) | 
 | 364 |     return(MagickTrue); | 
 | 365 |   (void) CopyMagickMemory(tag,text,MaxTextExtent); | 
 | 366 |   p=strrchr(tag,'/'); | 
 | 367 |   if (p != (char *) NULL) | 
 | 368 |     *p='\0'; | 
| cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 369 |   (void) FormatLocaleString(message,MaxTextExtent,"Monitor/%s",tag); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 370 |   locale_message=GetLocaleMessage(message); | 
 | 371 |   if (locale_message == message) | 
 | 372 |     locale_message=tag; | 
 | 373 |   if (p == (char *) NULL) | 
| cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 374 |     (void) FormatLocaleFile(stderr,"%s: %ld of %lu, %02ld%% complete\r", | 
 | 375 |       locale_message,(long) offset,(unsigned long) extent,(long) | 
 | 376 |       (100L*offset/(extent-1))); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 377 |   else | 
| cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 378 |     (void) FormatLocaleFile(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 379 |       locale_message,p+1,(long) offset,(unsigned long) extent,(long) | 
 | 380 |       (100L*offset/(extent-1))); | 
 | 381 |   if (offset == (MagickOffsetType) (extent-1)) | 
| cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 382 |     (void) FormatLocaleFile(stderr,"\n"); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 383 |   (void) fflush(stderr); | 
 | 384 |   return(MagickTrue); | 
 | 385 | } | 
 | 386 |  | 
 | 387 | /* | 
| anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 388 | ** SparseColorOption() parses the complex -sparse-color argument into an | 
 | 389 | ** an array of floating point values then calls SparseColorImage(). | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 390 | ** Argument is a complex mix of floating-point pixel coodinates, and color | 
 | 391 | ** specifications (or direct floating point numbers).  The number of floats | 
| anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 392 | ** needed to represent a color varies depending on the current channel | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 393 | ** setting. | 
 | 394 | */ | 
| cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 395 | static Image *SparseColorOption(const Image *image, | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 396 |   const SparseColorMethod method,const char *arguments, | 
 | 397 |   const MagickBooleanType color_from_image,ExceptionInfo *exception) | 
 | 398 | { | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 399 |   char | 
 | 400 |     token[MaxTextExtent]; | 
 | 401 |  | 
 | 402 |   const char | 
 | 403 |     *p; | 
 | 404 |  | 
 | 405 |   double | 
 | 406 |     *sparse_arguments; | 
 | 407 |  | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 408 |   Image | 
 | 409 |     *sparse_image; | 
 | 410 |  | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 411 |   PixelInfo | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 412 |     color; | 
 | 413 |  | 
 | 414 |   MagickBooleanType | 
 | 415 |     error; | 
 | 416 |  | 
| cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 417 |   register size_t | 
 | 418 |     x; | 
 | 419 |  | 
 | 420 |   size_t | 
 | 421 |     number_arguments, | 
 | 422 |     number_colors; | 
 | 423 |  | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 424 |   assert(image != (Image *) NULL); | 
 | 425 |   assert(image->signature == MagickSignature); | 
 | 426 |   if (image->debug != MagickFalse) | 
 | 427 |     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); | 
 | 428 |   assert(exception != (ExceptionInfo *) NULL); | 
 | 429 |   assert(exception->signature == MagickSignature); | 
 | 430 |   /* | 
 | 431 |     Limit channels according to image - and add up number of color channel. | 
 | 432 |   */ | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 433 |   number_colors=0; | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 434 |   if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 435 |     number_colors++; | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 436 |   if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 437 |     number_colors++; | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 438 |   if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 439 |     number_colors++; | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 440 |   if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && | 
| cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 441 |       (image->colorspace == CMYKColorspace)) | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 442 |     number_colors++; | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 443 |   if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && | 
| cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 444 |       (image->matte != MagickFalse)) | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 445 |     number_colors++; | 
 | 446 |  | 
 | 447 |   /* | 
 | 448 |     Read string, to determine number of arguments needed, | 
 | 449 |   */ | 
 | 450 |   p=arguments; | 
 | 451 |   x=0; | 
 | 452 |   while( *p != '\0' ) | 
 | 453 |   { | 
 | 454 |     GetMagickToken(p,&p,token); | 
 | 455 |     if ( token[0] == ',' ) continue; | 
 | 456 |     if ( isalpha((int) token[0]) || token[0] == '#' ) { | 
 | 457 |       if ( color_from_image ) { | 
 | 458 |         (void) ThrowMagickException(exception,GetMagickModule(), | 
 | 459 |             OptionError, "InvalidArgument", "`%s': %s", "sparse-color", | 
 | 460 |             "Color arg given, when colors are coming from image"); | 
 | 461 |         return( (Image *)NULL); | 
 | 462 |       } | 
 | 463 |       x += number_colors;  /* color argument */ | 
 | 464 |     } | 
 | 465 |     else { | 
 | 466 |       x++;   /* floating point argument */ | 
 | 467 |     } | 
 | 468 |   } | 
 | 469 |   error=MagickTrue; | 
 | 470 |   if ( color_from_image ) { | 
 | 471 |     /* just the control points are being given */ | 
 | 472 |     error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; | 
 | 473 |     number_arguments=(x/2)*(2+number_colors); | 
 | 474 |   } | 
 | 475 |   else { | 
 | 476 |     /* control points and color values */ | 
 | 477 |     error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; | 
 | 478 |     number_arguments=x; | 
 | 479 |   } | 
 | 480 |   if ( error ) { | 
 | 481 |     (void) ThrowMagickException(exception,GetMagickModule(), | 
 | 482 |                OptionError, "InvalidArgument", "`%s': %s", "sparse-color", | 
 | 483 |                "Invalid number of Arguments"); | 
 | 484 |     return( (Image *)NULL); | 
 | 485 |   } | 
 | 486 |  | 
 | 487 |   /* Allocate and fill in the floating point arguments */ | 
 | 488 |   sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, | 
 | 489 |     sizeof(*sparse_arguments)); | 
 | 490 |   if (sparse_arguments == (double *) NULL) { | 
 | 491 |     (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, | 
 | 492 |       "MemoryAllocationFailed","%s","SparseColorOption"); | 
 | 493 |     return( (Image *)NULL); | 
 | 494 |   } | 
 | 495 |   (void) ResetMagickMemory(sparse_arguments,0,number_arguments* | 
 | 496 |     sizeof(*sparse_arguments)); | 
 | 497 |   p=arguments; | 
 | 498 |   x=0; | 
 | 499 |   while( *p != '\0' && x < number_arguments ) { | 
 | 500 |     /* X coordinate */ | 
 | 501 |     token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
 | 502 |     if ( token[0] == '\0' ) break; | 
 | 503 |     if ( isalpha((int) token[0]) || token[0] == '#' ) { | 
 | 504 |       (void) ThrowMagickException(exception,GetMagickModule(), | 
 | 505 |             OptionError, "InvalidArgument", "`%s': %s", "sparse-color", | 
 | 506 |             "Color found, instead of X-coord"); | 
 | 507 |       error = MagickTrue; | 
 | 508 |       break; | 
 | 509 |     } | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 510 |     sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 511 |     /* Y coordinate */ | 
 | 512 |     token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
 | 513 |     if ( token[0] == '\0' ) break; | 
 | 514 |     if ( isalpha((int) token[0]) || token[0] == '#' ) { | 
 | 515 |       (void) ThrowMagickException(exception,GetMagickModule(), | 
 | 516 |             OptionError, "InvalidArgument", "`%s': %s", "sparse-color", | 
 | 517 |             "Color found, instead of Y-coord"); | 
 | 518 |       error = MagickTrue; | 
 | 519 |       break; | 
 | 520 |     } | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 521 |     sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 522 |     /* color values for this control point */ | 
 | 523 | #if 0 | 
 | 524 |     if ( (color_from_image ) { | 
 | 525 |       /* get color from image */ | 
 | 526 |       /* HOW??? */ | 
 | 527 |     } | 
 | 528 |     else | 
 | 529 | #endif | 
 | 530 |     { | 
 | 531 |       /* color name or function given in string argument */ | 
 | 532 |       token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
 | 533 |       if ( token[0] == '\0' ) break; | 
 | 534 |       if ( isalpha((int) token[0]) || token[0] == '#' ) { | 
 | 535 |         /* Color string given */ | 
 | 536 |         (void) QueryMagickColor(token,&color,exception); | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 537 |         if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 538 |           sparse_arguments[x++] = QuantumScale*color.red; | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 539 |         if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 540 |           sparse_arguments[x++] = QuantumScale*color.green; | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 541 |         if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 542 |           sparse_arguments[x++] = QuantumScale*color.blue; | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 543 |         if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && | 
| cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 544 |             (image->colorspace == CMYKColorspace)) | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 545 |           sparse_arguments[x++] = QuantumScale*color.black; | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 546 |         if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && | 
| cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 547 |             (image->matte != MagickFalse)) | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 548 |           sparse_arguments[x++] = QuantumScale*color.alpha; | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 549 |       } | 
 | 550 |       else { | 
 | 551 |         /* Colors given as a set of floating point values - experimental */ | 
 | 552 |         /* NB: token contains the first floating point value to use! */ | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 553 |         if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) | 
| cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 554 |           { | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 555 |           while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
 | 556 |           if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) | 
 | 557 |             break; | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 558 |           sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 559 |           token[0] = ','; /* used this token - get another */ | 
 | 560 |         } | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 561 |         if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) | 
| cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 562 |           { | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 563 |           while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
 | 564 |           if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) | 
 | 565 |             break; | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 566 |           sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 567 |           token[0] = ','; /* used this token - get another */ | 
 | 568 |         } | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 569 |         if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) | 
| cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 570 |           { | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 571 |           while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
 | 572 |           if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) | 
 | 573 |             break; | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 574 |           sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 575 |           token[0] = ','; /* used this token - get another */ | 
 | 576 |         } | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 577 |         if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) && | 
| cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 578 |             (image->colorspace == CMYKColorspace)) | 
 | 579 |           { | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 580 |           while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
 | 581 |           if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) | 
 | 582 |             break; | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 583 |           sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 584 |           token[0] = ','; /* used this token - get another */ | 
 | 585 |         } | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 586 |         if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) && | 
| cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 587 |             (image->matte != MagickFalse)) | 
 | 588 |           { | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 589 |           while ( token[0] == ',' ) GetMagickToken(p,&p,token); | 
 | 590 |           if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) | 
 | 591 |             break; | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 592 |           sparse_arguments[x++]=InterpretLocaleValue(token,(char **) NULL); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 593 |           token[0] = ','; /* used this token - get another */ | 
 | 594 |         } | 
 | 595 |       } | 
 | 596 |     } | 
 | 597 |   } | 
 | 598 |   if ( number_arguments != x && !error ) { | 
 | 599 |     (void) ThrowMagickException(exception,GetMagickModule(),OptionError, | 
 | 600 |       "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); | 
 | 601 |     sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); | 
 | 602 |     return( (Image *)NULL); | 
 | 603 |   } | 
 | 604 |   if ( error ) | 
 | 605 |     return( (Image *)NULL); | 
 | 606 |  | 
 | 607 |   /* Call the Interpolation function with the parsed arguments */ | 
| cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 608 |   sparse_image=SparseColorImage(image,method,number_arguments,sparse_arguments, | 
 | 609 |     exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 610 |   sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); | 
 | 611 |   return( sparse_image ); | 
 | 612 | } | 
 | 613 |  | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 614 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, | 
 | 615 |   const char **argv,Image **image,ExceptionInfo *exception) | 
 | 616 | { | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 617 |   ChannelType | 
 | 618 |     channel; | 
 | 619 |  | 
 | 620 |   const char | 
 | 621 |     *format, | 
 | 622 |     *option; | 
 | 623 |  | 
 | 624 |   DrawInfo | 
 | 625 |     *draw_info; | 
 | 626 |  | 
 | 627 |   GeometryInfo | 
 | 628 |     geometry_info; | 
 | 629 |  | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 630 |   Image | 
 | 631 |     *region_image; | 
 | 632 |  | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 633 |   ImageInfo | 
 | 634 |     *mogrify_info; | 
 | 635 |  | 
| cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 636 |   MagickStatusType | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 637 |     status; | 
 | 638 |  | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 639 |   PixelInfo | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 640 |     fill; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 641 |  | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 642 |   MagickStatusType | 
 | 643 |     flags; | 
 | 644 |  | 
 | 645 |   QuantizeInfo | 
 | 646 |     *quantize_info; | 
 | 647 |  | 
 | 648 |   RectangleInfo | 
 | 649 |     geometry, | 
 | 650 |     region_geometry; | 
| anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 651 |  | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 652 |   register ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 653 |     i; | 
 | 654 |  | 
 | 655 |   /* | 
 | 656 |     Initialize method variables. | 
 | 657 |   */ | 
 | 658 |   assert(image_info != (const ImageInfo *) NULL); | 
 | 659 |   assert(image_info->signature == MagickSignature); | 
 | 660 |   assert(image != (Image **) NULL); | 
 | 661 |   assert((*image)->signature == MagickSignature); | 
 | 662 |   if ((*image)->debug != MagickFalse) | 
 | 663 |     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); | 
 | 664 |   if (argc < 0) | 
 | 665 |     return(MagickTrue); | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 666 |   mogrify_info=CloneImageInfo(image_info); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 667 |   draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); | 
 | 668 |   quantize_info=AcquireQuantizeInfo(mogrify_info); | 
 | 669 |   SetGeometryInfo(&geometry_info); | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 670 |   GetPixelInfo(*image,&fill); | 
 | 671 |   SetPixelInfoPacket(*image,&(*image)->background_color,&fill); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 672 |   channel=mogrify_info->channel; | 
 | 673 |   format=GetImageOption(mogrify_info,"format"); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 674 |   SetGeometry(*image,®ion_geometry); | 
 | 675 |   region_image=NewImageList(); | 
 | 676 |   /* | 
 | 677 |     Transmogrify the image. | 
 | 678 |   */ | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 679 |   for (i=0; i < (ssize_t) argc; i++) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 680 |   { | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 681 |     Image | 
 | 682 |       *mogrify_image; | 
 | 683 |  | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 684 |     ssize_t | 
 | 685 |       count; | 
 | 686 |  | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 687 |     option=argv[i]; | 
 | 688 |     if (IsCommandOption(option) == MagickFalse) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 689 |       continue; | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 690 |     count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), | 
 | 691 |       0L); | 
| cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 692 |     if ((i+count) >= (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 693 |       break; | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 694 |     status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 695 |     mogrify_image=(Image *)NULL; | 
 | 696 |     switch (*(option+1)) | 
 | 697 |     { | 
 | 698 |       case 'a': | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 699 |       { | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 700 |         if (LocaleCompare("adaptive-blur",option+1) == 0) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 701 |           { | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 702 |             /* | 
 | 703 |               Adaptive blur image. | 
 | 704 |             */ | 
 | 705 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 706 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 707 |             if ((flags & SigmaValue) == 0) | 
 | 708 |               geometry_info.sigma=1.0; | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 709 |             mogrify_image=AdaptiveBlurImage(*image,geometry_info.rho, | 
 | 710 |               geometry_info.sigma,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 711 |             break; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 712 |           } | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 713 |         if (LocaleCompare("adaptive-resize",option+1) == 0) | 
 | 714 |           { | 
 | 715 |             /* | 
 | 716 |               Adaptive resize image. | 
 | 717 |             */ | 
 | 718 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 719 |             (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); | 
 | 720 |             mogrify_image=AdaptiveResizeImage(*image,geometry.width, | 
 | 721 |               geometry.height,exception); | 
 | 722 |             break; | 
 | 723 |           } | 
 | 724 |         if (LocaleCompare("adaptive-sharpen",option+1) == 0) | 
 | 725 |           { | 
 | 726 |             /* | 
 | 727 |               Adaptive sharpen image. | 
 | 728 |             */ | 
 | 729 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 730 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 731 |             if ((flags & SigmaValue) == 0) | 
 | 732 |               geometry_info.sigma=1.0; | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 733 |             mogrify_image=AdaptiveSharpenImage(*image,geometry_info.rho, | 
 | 734 |               geometry_info.sigma,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 735 |             break; | 
 | 736 |           } | 
 | 737 |         if (LocaleCompare("affine",option+1) == 0) | 
 | 738 |           { | 
 | 739 |             /* | 
 | 740 |               Affine matrix. | 
 | 741 |             */ | 
 | 742 |             if (*option == '+') | 
 | 743 |               { | 
 | 744 |                 GetAffineMatrix(&draw_info->affine); | 
 | 745 |                 break; | 
 | 746 |               } | 
 | 747 |             (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); | 
 | 748 |             break; | 
 | 749 |           } | 
 | 750 |         if (LocaleCompare("alpha",option+1) == 0) | 
 | 751 |           { | 
 | 752 |             AlphaChannelType | 
 | 753 |               alpha_type; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 754 |  | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 755 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 756 |             alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, | 
 | 757 |               MagickFalse,argv[i+1]); | 
 | 758 |             (void) SetImageAlphaChannel(*image,alpha_type); | 
 | 759 |             InheritException(exception,&(*image)->exception); | 
 | 760 |             break; | 
 | 761 |           } | 
 | 762 |         if (LocaleCompare("annotate",option+1) == 0) | 
 | 763 |           { | 
 | 764 |             char | 
 | 765 |               *text, | 
 | 766 |               geometry[MaxTextExtent]; | 
 | 767 |  | 
 | 768 |             /* | 
 | 769 |               Annotate image. | 
 | 770 |             */ | 
 | 771 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 772 |             SetGeometryInfo(&geometry_info); | 
 | 773 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 774 |             if ((flags & SigmaValue) == 0) | 
 | 775 |               geometry_info.sigma=geometry_info.rho; | 
 | 776 |             text=InterpretImageProperties(mogrify_info,*image,argv[i+2]); | 
 | 777 |             InheritException(exception,&(*image)->exception); | 
 | 778 |             if (text == (char *) NULL) | 
 | 779 |               break; | 
 | 780 |             (void) CloneString(&draw_info->text,text); | 
 | 781 |             text=DestroyString(text); | 
| cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 782 |             (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f", | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 783 |               geometry_info.xi,geometry_info.psi); | 
 | 784 |             (void) CloneString(&draw_info->geometry,geometry); | 
 | 785 |             draw_info->affine.sx=cos(DegreesToRadians( | 
 | 786 |               fmod(geometry_info.rho,360.0))); | 
 | 787 |             draw_info->affine.rx=sin(DegreesToRadians( | 
 | 788 |               fmod(geometry_info.rho,360.0))); | 
 | 789 |             draw_info->affine.ry=(-sin(DegreesToRadians( | 
 | 790 |               fmod(geometry_info.sigma,360.0)))); | 
 | 791 |             draw_info->affine.sy=cos(DegreesToRadians( | 
 | 792 |               fmod(geometry_info.sigma,360.0))); | 
 | 793 |             (void) AnnotateImage(*image,draw_info); | 
 | 794 |             InheritException(exception,&(*image)->exception); | 
 | 795 |             break; | 
 | 796 |           } | 
 | 797 |         if (LocaleCompare("antialias",option+1) == 0) | 
 | 798 |           { | 
 | 799 |             draw_info->stroke_antialias=(*option == '-') ? MagickTrue : | 
 | 800 |               MagickFalse; | 
 | 801 |             draw_info->text_antialias=(*option == '-') ? MagickTrue : | 
 | 802 |               MagickFalse; | 
 | 803 |             break; | 
 | 804 |           } | 
 | 805 |         if (LocaleCompare("auto-gamma",option+1) == 0) | 
 | 806 |           { | 
 | 807 |             /* | 
 | 808 |               Auto Adjust Gamma of image based on its mean | 
 | 809 |             */ | 
 | 810 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | ab01585 | 2011-07-06 01:03:32 +0000 | [diff] [blame] | 811 |             (void) AutoGammaImage(*image); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 812 |             break; | 
 | 813 |           } | 
 | 814 |         if (LocaleCompare("auto-level",option+1) == 0) | 
 | 815 |           { | 
 | 816 |             /* | 
 | 817 |               Perfectly Normalize (max/min stretch) the image | 
 | 818 |             */ | 
 | 819 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | ab01585 | 2011-07-06 01:03:32 +0000 | [diff] [blame] | 820 |             (void) AutoLevelImage(*image); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 821 |             break; | 
 | 822 |           } | 
 | 823 |         if (LocaleCompare("auto-orient",option+1) == 0) | 
 | 824 |           { | 
 | 825 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 826 |             switch ((*image)->orientation) | 
 | 827 |             { | 
 | 828 |               case TopRightOrientation: | 
 | 829 |               { | 
 | 830 |                 mogrify_image=FlopImage(*image,exception); | 
 | 831 |                 break; | 
 | 832 |               } | 
 | 833 |               case BottomRightOrientation: | 
 | 834 |               { | 
 | 835 |                 mogrify_image=RotateImage(*image,180.0,exception); | 
 | 836 |                 break; | 
 | 837 |               } | 
 | 838 |               case BottomLeftOrientation: | 
 | 839 |               { | 
 | 840 |                 mogrify_image=FlipImage(*image,exception); | 
 | 841 |                 break; | 
 | 842 |               } | 
 | 843 |               case LeftTopOrientation: | 
 | 844 |               { | 
 | 845 |                 mogrify_image=TransposeImage(*image,exception); | 
 | 846 |                 break; | 
 | 847 |               } | 
 | 848 |               case RightTopOrientation: | 
 | 849 |               { | 
 | 850 |                 mogrify_image=RotateImage(*image,90.0,exception); | 
 | 851 |                 break; | 
 | 852 |               } | 
 | 853 |               case RightBottomOrientation: | 
 | 854 |               { | 
 | 855 |                 mogrify_image=TransverseImage(*image,exception); | 
 | 856 |                 break; | 
 | 857 |               } | 
 | 858 |               case LeftBottomOrientation: | 
 | 859 |               { | 
 | 860 |                 mogrify_image=RotateImage(*image,270.0,exception); | 
 | 861 |                 break; | 
 | 862 |               } | 
 | 863 |               default: | 
 | 864 |                 break; | 
 | 865 |             } | 
 | 866 |             if (mogrify_image != (Image *) NULL) | 
 | 867 |               mogrify_image->orientation=TopLeftOrientation; | 
 | 868 |             break; | 
 | 869 |           } | 
 | 870 |         break; | 
 | 871 |       } | 
 | 872 |       case 'b': | 
 | 873 |       { | 
 | 874 |         if (LocaleCompare("black-threshold",option+1) == 0) | 
 | 875 |           { | 
 | 876 |             /* | 
 | 877 |               Black threshold image. | 
 | 878 |             */ | 
 | 879 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 880 |             (void) BlackThresholdImage(*image,argv[i+1],exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 881 |             InheritException(exception,&(*image)->exception); | 
 | 882 |             break; | 
 | 883 |           } | 
 | 884 |         if (LocaleCompare("blue-shift",option+1) == 0) | 
 | 885 |           { | 
 | 886 |             /* | 
 | 887 |               Blue shift image. | 
 | 888 |             */ | 
 | 889 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 890 |             geometry_info.rho=1.5; | 
 | 891 |             if (*option == '-') | 
 | 892 |               flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 893 |             mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); | 
 | 894 |             break; | 
 | 895 |           } | 
 | 896 |         if (LocaleCompare("blur",option+1) == 0) | 
 | 897 |           { | 
 | 898 |             /* | 
 | 899 |               Gaussian blur image. | 
 | 900 |             */ | 
 | 901 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 902 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 903 |             if ((flags & SigmaValue) == 0) | 
 | 904 |               geometry_info.sigma=1.0; | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 905 |             mogrify_image=BlurImage(*image,geometry_info.rho, | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 906 |               geometry_info.sigma,exception); | 
 | 907 |             break; | 
 | 908 |           } | 
 | 909 |         if (LocaleCompare("border",option+1) == 0) | 
 | 910 |           { | 
 | 911 |             /* | 
 | 912 |               Surround image with a border of solid color. | 
 | 913 |             */ | 
 | 914 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 915 |             flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); | 
 | 916 |             if ((flags & SigmaValue) == 0) | 
 | 917 |               geometry.height=geometry.width; | 
 | 918 |             mogrify_image=BorderImage(*image,&geometry,exception); | 
 | 919 |             break; | 
 | 920 |           } | 
 | 921 |         if (LocaleCompare("bordercolor",option+1) == 0) | 
 | 922 |           { | 
 | 923 |             if (*option == '+') | 
 | 924 |               { | 
 | 925 |                 (void) QueryColorDatabase(BorderColor,&draw_info->border_color, | 
 | 926 |                   exception); | 
 | 927 |                 break; | 
 | 928 |               } | 
 | 929 |             (void) QueryColorDatabase(argv[i+1],&draw_info->border_color, | 
 | 930 |               exception); | 
 | 931 |             break; | 
 | 932 |           } | 
 | 933 |         if (LocaleCompare("box",option+1) == 0) | 
 | 934 |           { | 
 | 935 |             (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, | 
 | 936 |               exception); | 
 | 937 |             break; | 
 | 938 |           } | 
 | 939 |         if (LocaleCompare("brightness-contrast",option+1) == 0) | 
 | 940 |           { | 
 | 941 |             double | 
 | 942 |               brightness, | 
 | 943 |               contrast; | 
 | 944 |  | 
 | 945 |             GeometryInfo | 
 | 946 |               geometry_info; | 
 | 947 |  | 
 | 948 |             MagickStatusType | 
 | 949 |               flags; | 
 | 950 |  | 
 | 951 |             /* | 
 | 952 |               Brightness / contrast image. | 
 | 953 |             */ | 
 | 954 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 955 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 956 |             brightness=geometry_info.rho; | 
 | 957 |             contrast=0.0; | 
 | 958 |             if ((flags & SigmaValue) != 0) | 
 | 959 |               contrast=geometry_info.sigma; | 
| cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 960 |             (void) BrightnessContrastImage(*image,brightness,contrast); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 961 |             InheritException(exception,&(*image)->exception); | 
 | 962 |             break; | 
 | 963 |           } | 
 | 964 |         break; | 
 | 965 |       } | 
 | 966 |       case 'c': | 
 | 967 |       { | 
 | 968 |         if (LocaleCompare("cdl",option+1) == 0) | 
 | 969 |           { | 
 | 970 |             char | 
 | 971 |               *color_correction_collection; | 
 | 972 |  | 
 | 973 |             /* | 
 | 974 |               Color correct with a color decision list. | 
 | 975 |             */ | 
 | 976 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 977 |             color_correction_collection=FileToString(argv[i+1],~0,exception); | 
 | 978 |             if (color_correction_collection == (char *) NULL) | 
 | 979 |               break; | 
 | 980 |             (void) ColorDecisionListImage(*image,color_correction_collection); | 
 | 981 |             InheritException(exception,&(*image)->exception); | 
 | 982 |             break; | 
 | 983 |           } | 
 | 984 |         if (LocaleCompare("channel",option+1) == 0) | 
 | 985 |           { | 
 | 986 |             if (*option == '+') | 
| cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 987 |               channel=DefaultChannels; | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 988 |             else | 
| cristy | fa806a7 | 2011-07-04 02:06:13 +0000 | [diff] [blame] | 989 |               channel=(ChannelType) ParseChannelOption(argv[i+1]); | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 990 |             SetPixelChannelMap(*image,channel); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 991 |             break; | 
 | 992 |           } | 
 | 993 |         if (LocaleCompare("charcoal",option+1) == 0) | 
 | 994 |           { | 
 | 995 |             /* | 
 | 996 |               Charcoal image. | 
 | 997 |             */ | 
 | 998 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 999 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 1000 |             if ((flags & SigmaValue) == 0) | 
 | 1001 |               geometry_info.sigma=1.0; | 
 | 1002 |             mogrify_image=CharcoalImage(*image,geometry_info.rho, | 
 | 1003 |               geometry_info.sigma,exception); | 
 | 1004 |             break; | 
 | 1005 |           } | 
 | 1006 |         if (LocaleCompare("chop",option+1) == 0) | 
 | 1007 |           { | 
 | 1008 |             /* | 
 | 1009 |               Chop the image. | 
 | 1010 |             */ | 
 | 1011 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1012 |             (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); | 
 | 1013 |             mogrify_image=ChopImage(*image,&geometry,exception); | 
 | 1014 |             break; | 
 | 1015 |           } | 
 | 1016 |         if (LocaleCompare("clamp",option+1) == 0) | 
 | 1017 |           { | 
 | 1018 |             /* | 
 | 1019 |               Clamp image. | 
 | 1020 |             */ | 
 | 1021 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1022 |             (void) ClampImage(*image); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1023 |             InheritException(exception,&(*image)->exception); | 
 | 1024 |             break; | 
 | 1025 |           } | 
 | 1026 |         if (LocaleCompare("clip",option+1) == 0) | 
 | 1027 |           { | 
 | 1028 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1029 |             if (*option == '+') | 
 | 1030 |               { | 
 | 1031 |                 (void) SetImageClipMask(*image,(Image *) NULL); | 
 | 1032 |                 InheritException(exception,&(*image)->exception); | 
 | 1033 |                 break; | 
 | 1034 |               } | 
 | 1035 |             (void) ClipImage(*image); | 
 | 1036 |             InheritException(exception,&(*image)->exception); | 
 | 1037 |             break; | 
 | 1038 |           } | 
 | 1039 |         if (LocaleCompare("clip-mask",option+1) == 0) | 
 | 1040 |           { | 
 | 1041 |             CacheView | 
 | 1042 |               *mask_view; | 
 | 1043 |  | 
 | 1044 |             Image | 
 | 1045 |               *mask_image; | 
 | 1046 |  | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1047 |             register Quantum | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1048 |               *restrict q; | 
 | 1049 |  | 
 | 1050 |             register ssize_t | 
 | 1051 |               x; | 
 | 1052 |  | 
 | 1053 |             ssize_t | 
 | 1054 |               y; | 
 | 1055 |  | 
 | 1056 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1057 |             if (*option == '+') | 
 | 1058 |               { | 
 | 1059 |                 /* | 
 | 1060 |                   Remove a mask. | 
 | 1061 |                 */ | 
 | 1062 |                 (void) SetImageMask(*image,(Image *) NULL); | 
 | 1063 |                 InheritException(exception,&(*image)->exception); | 
 | 1064 |                 break; | 
 | 1065 |               } | 
 | 1066 |             /* | 
 | 1067 |               Set the image mask. | 
 | 1068 |               FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. | 
 | 1069 |             */ | 
 | 1070 |             mask_image=GetImageCache(mogrify_info,argv[i+1],exception); | 
 | 1071 |             if (mask_image == (Image *) NULL) | 
 | 1072 |               break; | 
| cristy | 574cc26 | 2011-08-05 01:23:58 +0000 | [diff] [blame] | 1073 |             if (SetImageStorageClass(mask_image,DirectClass,exception) == MagickFalse) | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1074 |               return(MagickFalse); | 
 | 1075 |             mask_view=AcquireCacheView(mask_image); | 
 | 1076 |             for (y=0; y < (ssize_t) mask_image->rows; y++) | 
 | 1077 |             { | 
 | 1078 |               q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, | 
 | 1079 |                 exception); | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1080 |               if (q == (const Quantum *) NULL) | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1081 |                 break; | 
 | 1082 |               for (x=0; x < (ssize_t) mask_image->columns; x++) | 
 | 1083 |               { | 
 | 1084 |                 if (mask_image->matte == MagickFalse) | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1085 |                   SetPixelAlpha(mask_image,GetPixelIntensity(mask_image,q),q); | 
 | 1086 |                 SetPixelRed(mask_image,GetPixelAlpha(mask_image,q),q); | 
 | 1087 |                 SetPixelGreen(mask_image,GetPixelAlpha(mask_image,q),q); | 
 | 1088 |                 SetPixelBlue(mask_image,GetPixelAlpha(mask_image,q),q); | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 1089 |                 q+=GetPixelChannels(mask_image); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1090 |               } | 
 | 1091 |               if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) | 
 | 1092 |                 break; | 
 | 1093 |             } | 
 | 1094 |             mask_view=DestroyCacheView(mask_view); | 
 | 1095 |             mask_image->matte=MagickTrue; | 
 | 1096 |             (void) SetImageClipMask(*image,mask_image); | 
 | 1097 |             mask_image=DestroyImage(mask_image); | 
 | 1098 |             InheritException(exception,&(*image)->exception); | 
 | 1099 |             break; | 
 | 1100 |           } | 
 | 1101 |         if (LocaleCompare("clip-path",option+1) == 0) | 
 | 1102 |           { | 
 | 1103 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1104 |             (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : | 
 | 1105 |               MagickFalse); | 
 | 1106 |             InheritException(exception,&(*image)->exception); | 
 | 1107 |             break; | 
 | 1108 |           } | 
 | 1109 |         if (LocaleCompare("colorize",option+1) == 0) | 
 | 1110 |           { | 
 | 1111 |             /* | 
 | 1112 |               Colorize the image. | 
 | 1113 |             */ | 
 | 1114 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1115 |             mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill, | 
 | 1116 |               exception); | 
 | 1117 |             break; | 
 | 1118 |           } | 
 | 1119 |         if (LocaleCompare("color-matrix",option+1) == 0) | 
 | 1120 |           { | 
 | 1121 |             KernelInfo | 
 | 1122 |               *kernel; | 
 | 1123 |  | 
 | 1124 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1125 |             kernel=AcquireKernelInfo(argv[i+1]); | 
 | 1126 |             if (kernel == (KernelInfo *) NULL) | 
 | 1127 |               break; | 
 | 1128 |             mogrify_image=ColorMatrixImage(*image,kernel,exception); | 
 | 1129 |             kernel=DestroyKernelInfo(kernel); | 
 | 1130 |             break; | 
 | 1131 |           } | 
 | 1132 |         if (LocaleCompare("colors",option+1) == 0) | 
 | 1133 |           { | 
 | 1134 |             /* | 
 | 1135 |               Reduce the number of colors in the image. | 
 | 1136 |             */ | 
 | 1137 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1138 |             quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); | 
 | 1139 |             if (quantize_info->number_colors == 0) | 
 | 1140 |               break; | 
 | 1141 |             if (((*image)->storage_class == DirectClass) || | 
 | 1142 |                 (*image)->colors > quantize_info->number_colors) | 
 | 1143 |               (void) QuantizeImage(quantize_info,*image); | 
 | 1144 |             else | 
 | 1145 |               (void) CompressImageColormap(*image); | 
 | 1146 |             InheritException(exception,&(*image)->exception); | 
 | 1147 |             break; | 
 | 1148 |           } | 
 | 1149 |         if (LocaleCompare("colorspace",option+1) == 0) | 
 | 1150 |           { | 
 | 1151 |             ColorspaceType | 
 | 1152 |               colorspace; | 
 | 1153 |  | 
 | 1154 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1155 |             if (*option == '+') | 
 | 1156 |               { | 
 | 1157 |                 (void) TransformImageColorspace(*image,RGBColorspace); | 
 | 1158 |                 InheritException(exception,&(*image)->exception); | 
 | 1159 |                 break; | 
 | 1160 |               } | 
 | 1161 |             colorspace=(ColorspaceType) ParseCommandOption( | 
 | 1162 |               MagickColorspaceOptions,MagickFalse,argv[i+1]); | 
 | 1163 |             (void) TransformImageColorspace(*image,colorspace); | 
 | 1164 |             InheritException(exception,&(*image)->exception); | 
 | 1165 |             break; | 
 | 1166 |           } | 
 | 1167 |         if (LocaleCompare("contrast",option+1) == 0) | 
 | 1168 |           { | 
 | 1169 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1170 |             (void) ContrastImage(*image,(*option == '-') ? MagickTrue : | 
 | 1171 |               MagickFalse); | 
 | 1172 |             InheritException(exception,&(*image)->exception); | 
 | 1173 |             break; | 
 | 1174 |           } | 
 | 1175 |         if (LocaleCompare("contrast-stretch",option+1) == 0) | 
 | 1176 |           { | 
 | 1177 |             double | 
 | 1178 |               black_point, | 
 | 1179 |               white_point; | 
 | 1180 |  | 
 | 1181 |             MagickStatusType | 
 | 1182 |               flags; | 
 | 1183 |  | 
 | 1184 |             /* | 
 | 1185 |               Contrast stretch image. | 
 | 1186 |             */ | 
 | 1187 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1188 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 1189 |             black_point=geometry_info.rho; | 
 | 1190 |             white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : | 
 | 1191 |               black_point; | 
 | 1192 |             if ((flags & PercentValue) != 0) | 
 | 1193 |               { | 
 | 1194 |                 black_point*=(double) (*image)->columns*(*image)->rows/100.0; | 
 | 1195 |                 white_point*=(double) (*image)->columns*(*image)->rows/100.0; | 
 | 1196 |               } | 
 | 1197 |             white_point=(MagickRealType) (*image)->columns*(*image)->rows- | 
 | 1198 |               white_point; | 
| cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1199 |             (void) ContrastStretchImage(*image,black_point,white_point); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1200 |             InheritException(exception,&(*image)->exception); | 
 | 1201 |             break; | 
 | 1202 |           } | 
 | 1203 |         if (LocaleCompare("convolve",option+1) == 0) | 
 | 1204 |           { | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1205 |             KernelInfo | 
| cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1206 |               *kernel_info; | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1207 |  | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1208 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1209 |             kernel_info=AcquireKernelInfo(argv[i+1]); | 
 | 1210 |             if (kernel_info == (KernelInfo *) NULL) | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1211 |               break; | 
| cristy | 0a92238 | 2011-07-16 15:30:34 +0000 | [diff] [blame] | 1212 |             kernel_info->bias=(*image)->bias; | 
| cristy | 5e6be1e | 2011-07-16 01:23:39 +0000 | [diff] [blame] | 1213 |             mogrify_image=ConvolveImage(*image,kernel_info,exception); | 
| cristy | 41cbe68 | 2011-07-15 19:12:37 +0000 | [diff] [blame] | 1214 |             kernel_info=DestroyKernelInfo(kernel_info); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1215 |             break; | 
 | 1216 |           } | 
 | 1217 |         if (LocaleCompare("crop",option+1) == 0) | 
 | 1218 |           { | 
 | 1219 |             /* | 
 | 1220 |               Crop a image to a smaller size | 
 | 1221 |             */ | 
 | 1222 |             (void) SyncImageSettings(mogrify_info,*image); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1223 |             mogrify_image=CropImageToTiles(*image,argv[i+1],exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1224 |             break; | 
 | 1225 |           } | 
 | 1226 |         if (LocaleCompare("cycle",option+1) == 0) | 
 | 1227 |           { | 
 | 1228 |             /* | 
 | 1229 |               Cycle an image colormap. | 
 | 1230 |             */ | 
 | 1231 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1232 |             (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1])); | 
 | 1233 |             InheritException(exception,&(*image)->exception); | 
 | 1234 |             break; | 
 | 1235 |           } | 
 | 1236 |         break; | 
 | 1237 |       } | 
 | 1238 |       case 'd': | 
 | 1239 |       { | 
 | 1240 |         if (LocaleCompare("decipher",option+1) == 0) | 
 | 1241 |           { | 
 | 1242 |             StringInfo | 
 | 1243 |               *passkey; | 
 | 1244 |  | 
 | 1245 |             /* | 
 | 1246 |               Decipher pixels. | 
 | 1247 |             */ | 
 | 1248 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1249 |             passkey=FileToStringInfo(argv[i+1],~0,exception); | 
 | 1250 |             if (passkey != (StringInfo *) NULL) | 
 | 1251 |               { | 
 | 1252 |                 (void) PasskeyDecipherImage(*image,passkey,exception); | 
 | 1253 |                 passkey=DestroyStringInfo(passkey); | 
 | 1254 |               } | 
 | 1255 |             break; | 
 | 1256 |           } | 
 | 1257 |         if (LocaleCompare("density",option+1) == 0) | 
 | 1258 |           { | 
 | 1259 |             /* | 
 | 1260 |               Set image density. | 
 | 1261 |             */ | 
 | 1262 |             (void) CloneString(&draw_info->density,argv[i+1]); | 
 | 1263 |             break; | 
 | 1264 |           } | 
 | 1265 |         if (LocaleCompare("depth",option+1) == 0) | 
 | 1266 |           { | 
 | 1267 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1268 |             if (*option == '+') | 
 | 1269 |               { | 
 | 1270 |                 (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); | 
 | 1271 |                 break; | 
 | 1272 |               } | 
 | 1273 |             (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); | 
 | 1274 |             break; | 
 | 1275 |           } | 
 | 1276 |         if (LocaleCompare("deskew",option+1) == 0) | 
 | 1277 |           { | 
 | 1278 |             double | 
 | 1279 |               threshold; | 
 | 1280 |  | 
 | 1281 |             /* | 
 | 1282 |               Straighten the image. | 
 | 1283 |             */ | 
 | 1284 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1285 |             if (*option == '+') | 
 | 1286 |               threshold=40.0*QuantumRange/100.0; | 
 | 1287 |             else | 
 | 1288 |               threshold=SiPrefixToDouble(argv[i+1],QuantumRange); | 
 | 1289 |             mogrify_image=DeskewImage(*image,threshold,exception); | 
 | 1290 |             break; | 
 | 1291 |           } | 
 | 1292 |         if (LocaleCompare("despeckle",option+1) == 0) | 
 | 1293 |           { | 
 | 1294 |             /* | 
 | 1295 |               Reduce the speckles within an image. | 
 | 1296 |             */ | 
 | 1297 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1298 |             mogrify_image=DespeckleImage(*image,exception); | 
 | 1299 |             break; | 
 | 1300 |           } | 
 | 1301 |         if (LocaleCompare("display",option+1) == 0) | 
 | 1302 |           { | 
 | 1303 |             (void) CloneString(&draw_info->server_name,argv[i+1]); | 
 | 1304 |             break; | 
 | 1305 |           } | 
 | 1306 |         if (LocaleCompare("distort",option+1) == 0) | 
 | 1307 |           { | 
 | 1308 |             char | 
 | 1309 |               *args, | 
 | 1310 |               token[MaxTextExtent]; | 
 | 1311 |  | 
 | 1312 |             const char | 
 | 1313 |               *p; | 
 | 1314 |  | 
 | 1315 |             DistortImageMethod | 
 | 1316 |               method; | 
 | 1317 |  | 
 | 1318 |             double | 
 | 1319 |               *arguments; | 
 | 1320 |  | 
 | 1321 |             register ssize_t | 
 | 1322 |               x; | 
 | 1323 |  | 
 | 1324 |             size_t | 
 | 1325 |               number_arguments; | 
 | 1326 |  | 
 | 1327 |             /* | 
 | 1328 |               Distort image. | 
 | 1329 |             */ | 
 | 1330 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1331 |             method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, | 
 | 1332 |               MagickFalse,argv[i+1]); | 
 | 1333 |             if ( method == ResizeDistortion ) | 
 | 1334 |               { | 
 | 1335 |                  /* Special Case - Argument is actually a resize geometry! | 
 | 1336 |                  ** Convert that to an appropriate distortion argument array. | 
 | 1337 |                  */ | 
 | 1338 |                  double | 
 | 1339 |                    resize_args[2]; | 
 | 1340 |                  (void) ParseRegionGeometry(*image,argv[i+2],&geometry, | 
 | 1341 |                       exception); | 
 | 1342 |                  resize_args[0]=(double)geometry.width; | 
 | 1343 |                  resize_args[1]=(double)geometry.height; | 
 | 1344 |                  mogrify_image=DistortImage(*image,method,(size_t)2, | 
 | 1345 |                       resize_args,MagickTrue,exception); | 
 | 1346 |                  break; | 
 | 1347 |               } | 
 | 1348 |             args=InterpretImageProperties(mogrify_info,*image,argv[i+2]); | 
 | 1349 |             InheritException(exception,&(*image)->exception); | 
 | 1350 |             if (args == (char *) NULL) | 
 | 1351 |               break; | 
 | 1352 |             p=(char *) args; | 
 | 1353 |             for (x=0; *p != '\0'; x++) | 
 | 1354 |             { | 
 | 1355 |               GetMagickToken(p,&p,token); | 
 | 1356 |               if (*token == ',') | 
 | 1357 |                 GetMagickToken(p,&p,token); | 
 | 1358 |             } | 
 | 1359 |             number_arguments=(size_t) x; | 
 | 1360 |             arguments=(double *) AcquireQuantumMemory(number_arguments, | 
 | 1361 |               sizeof(*arguments)); | 
 | 1362 |             if (arguments == (double *) NULL) | 
 | 1363 |               ThrowWandFatalException(ResourceLimitFatalError, | 
 | 1364 |                 "MemoryAllocationFailed",(*image)->filename); | 
 | 1365 |             (void) ResetMagickMemory(arguments,0,number_arguments* | 
 | 1366 |               sizeof(*arguments)); | 
 | 1367 |             p=(char *) args; | 
 | 1368 |             for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) | 
 | 1369 |             { | 
 | 1370 |               GetMagickToken(p,&p,token); | 
 | 1371 |               if (*token == ',') | 
 | 1372 |                 GetMagickToken(p,&p,token); | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1373 |               arguments[x]=InterpretLocaleValue(token,(char **) NULL); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1374 |             } | 
 | 1375 |             args=DestroyString(args); | 
 | 1376 |             mogrify_image=DistortImage(*image,method,number_arguments,arguments, | 
 | 1377 |               (*option == '+') ? MagickTrue : MagickFalse,exception); | 
 | 1378 |             arguments=(double *) RelinquishMagickMemory(arguments); | 
 | 1379 |             break; | 
 | 1380 |           } | 
 | 1381 |         if (LocaleCompare("dither",option+1) == 0) | 
 | 1382 |           { | 
 | 1383 |             if (*option == '+') | 
 | 1384 |               { | 
 | 1385 |                 quantize_info->dither=MagickFalse; | 
 | 1386 |                 break; | 
 | 1387 |               } | 
 | 1388 |             quantize_info->dither=MagickTrue; | 
 | 1389 |             quantize_info->dither_method=(DitherMethod) ParseCommandOption( | 
 | 1390 |               MagickDitherOptions,MagickFalse,argv[i+1]); | 
 | 1391 |             if (quantize_info->dither_method == NoDitherMethod) | 
 | 1392 |               quantize_info->dither=MagickFalse; | 
 | 1393 |             break; | 
 | 1394 |           } | 
 | 1395 |         if (LocaleCompare("draw",option+1) == 0) | 
 | 1396 |           { | 
 | 1397 |             /* | 
 | 1398 |               Draw image. | 
 | 1399 |             */ | 
 | 1400 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1401 |             (void) CloneString(&draw_info->primitive,argv[i+1]); | 
 | 1402 |             (void) DrawImage(*image,draw_info); | 
 | 1403 |             InheritException(exception,&(*image)->exception); | 
 | 1404 |             break; | 
 | 1405 |           } | 
 | 1406 |         break; | 
 | 1407 |       } | 
 | 1408 |       case 'e': | 
 | 1409 |       { | 
 | 1410 |         if (LocaleCompare("edge",option+1) == 0) | 
 | 1411 |           { | 
 | 1412 |             /* | 
 | 1413 |               Enhance edges in the image. | 
 | 1414 |             */ | 
 | 1415 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1416 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 1417 |             if ((flags & SigmaValue) == 0) | 
 | 1418 |               geometry_info.sigma=1.0; | 
 | 1419 |             mogrify_image=EdgeImage(*image,geometry_info.rho,exception); | 
 | 1420 |             break; | 
 | 1421 |           } | 
 | 1422 |         if (LocaleCompare("emboss",option+1) == 0) | 
 | 1423 |           { | 
 | 1424 |             /* | 
 | 1425 |               Gaussian embossen image. | 
 | 1426 |             */ | 
 | 1427 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1428 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 1429 |             if ((flags & SigmaValue) == 0) | 
 | 1430 |               geometry_info.sigma=1.0; | 
 | 1431 |             mogrify_image=EmbossImage(*image,geometry_info.rho, | 
 | 1432 |               geometry_info.sigma,exception); | 
 | 1433 |             break; | 
 | 1434 |           } | 
 | 1435 |         if (LocaleCompare("encipher",option+1) == 0) | 
 | 1436 |           { | 
 | 1437 |             StringInfo | 
 | 1438 |               *passkey; | 
 | 1439 |  | 
 | 1440 |             /* | 
 | 1441 |               Encipher pixels. | 
 | 1442 |             */ | 
 | 1443 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1444 |             passkey=FileToStringInfo(argv[i+1],~0,exception); | 
 | 1445 |             if (passkey != (StringInfo *) NULL) | 
 | 1446 |               { | 
 | 1447 |                 (void) PasskeyEncipherImage(*image,passkey,exception); | 
 | 1448 |                 passkey=DestroyStringInfo(passkey); | 
 | 1449 |               } | 
 | 1450 |             break; | 
 | 1451 |           } | 
 | 1452 |         if (LocaleCompare("encoding",option+1) == 0) | 
 | 1453 |           { | 
 | 1454 |             (void) CloneString(&draw_info->encoding,argv[i+1]); | 
 | 1455 |             break; | 
 | 1456 |           } | 
 | 1457 |         if (LocaleCompare("enhance",option+1) == 0) | 
 | 1458 |           { | 
 | 1459 |             /* | 
 | 1460 |               Enhance image. | 
 | 1461 |             */ | 
 | 1462 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1463 |             mogrify_image=EnhanceImage(*image,exception); | 
 | 1464 |             break; | 
 | 1465 |           } | 
 | 1466 |         if (LocaleCompare("equalize",option+1) == 0) | 
 | 1467 |           { | 
 | 1468 |             /* | 
 | 1469 |               Equalize image. | 
 | 1470 |             */ | 
 | 1471 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1472 |             (void) EqualizeImage(*image); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1473 |             InheritException(exception,&(*image)->exception); | 
 | 1474 |             break; | 
 | 1475 |           } | 
 | 1476 |         if (LocaleCompare("evaluate",option+1) == 0) | 
 | 1477 |           { | 
 | 1478 |             double | 
 | 1479 |               constant; | 
 | 1480 |  | 
 | 1481 |             MagickEvaluateOperator | 
 | 1482 |               op; | 
 | 1483 |  | 
 | 1484 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1485 |             op=(MagickEvaluateOperator) ParseCommandOption( | 
 | 1486 |               MagickEvaluateOptions,MagickFalse,argv[i+1]); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1487 |             constant=SiPrefixToDouble(argv[i+2],QuantumRange); | 
| cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1488 |             (void) EvaluateImage(*image,op,constant,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1489 |             break; | 
 | 1490 |           } | 
 | 1491 |         if (LocaleCompare("extent",option+1) == 0) | 
 | 1492 |           { | 
 | 1493 |             /* | 
 | 1494 |               Set the image extent. | 
 | 1495 |             */ | 
 | 1496 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1497 |             flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); | 
 | 1498 |             if (geometry.width == 0) | 
 | 1499 |               geometry.width=(*image)->columns; | 
 | 1500 |             if (geometry.height == 0) | 
 | 1501 |               geometry.height=(*image)->rows; | 
 | 1502 |             mogrify_image=ExtentImage(*image,&geometry,exception); | 
 | 1503 |             break; | 
 | 1504 |           } | 
 | 1505 |         break; | 
 | 1506 |       } | 
 | 1507 |       case 'f': | 
 | 1508 |       { | 
 | 1509 |         if (LocaleCompare("family",option+1) == 0) | 
 | 1510 |           { | 
 | 1511 |             if (*option == '+') | 
 | 1512 |               { | 
 | 1513 |                 if (draw_info->family != (char *) NULL) | 
 | 1514 |                   draw_info->family=DestroyString(draw_info->family); | 
 | 1515 |                 break; | 
 | 1516 |               } | 
 | 1517 |             (void) CloneString(&draw_info->family,argv[i+1]); | 
 | 1518 |             break; | 
 | 1519 |           } | 
 | 1520 |         if (LocaleCompare("features",option+1) == 0) | 
 | 1521 |           { | 
 | 1522 |             if (*option == '+') | 
 | 1523 |               { | 
 | 1524 |                 (void) DeleteImageArtifact(*image,"identify:features"); | 
 | 1525 |                 break; | 
 | 1526 |               } | 
 | 1527 |             (void) SetImageArtifact(*image,"identify:features",argv[i+1]); | 
 | 1528 |             break; | 
 | 1529 |           } | 
 | 1530 |         if (LocaleCompare("fill",option+1) == 0) | 
 | 1531 |           { | 
 | 1532 |             ExceptionInfo | 
 | 1533 |               *sans; | 
 | 1534 |  | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1535 |             GetPixelInfo(*image,&fill); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1536 |             if (*option == '+') | 
 | 1537 |               { | 
 | 1538 |                 (void) QueryMagickColor("none",&fill,exception); | 
 | 1539 |                 (void) QueryColorDatabase("none",&draw_info->fill,exception); | 
 | 1540 |                 if (draw_info->fill_pattern != (Image *) NULL) | 
 | 1541 |                   draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); | 
 | 1542 |                 break; | 
 | 1543 |               } | 
 | 1544 |             sans=AcquireExceptionInfo(); | 
 | 1545 |             (void) QueryMagickColor(argv[i+1],&fill,sans); | 
 | 1546 |             status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); | 
 | 1547 |             sans=DestroyExceptionInfo(sans); | 
 | 1548 |             if (status == MagickFalse) | 
 | 1549 |               draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], | 
 | 1550 |                 exception); | 
 | 1551 |             break; | 
 | 1552 |           } | 
 | 1553 |         if (LocaleCompare("flip",option+1) == 0) | 
 | 1554 |           { | 
 | 1555 |             /* | 
 | 1556 |               Flip image scanlines. | 
 | 1557 |             */ | 
 | 1558 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1559 |             mogrify_image=FlipImage(*image,exception); | 
 | 1560 |             break; | 
 | 1561 |           } | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1562 |         if (LocaleCompare("floodfill",option+1) == 0) | 
 | 1563 |           { | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1564 |             PixelInfo | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1565 |               target; | 
 | 1566 |  | 
 | 1567 |             /* | 
 | 1568 |               Floodfill image. | 
 | 1569 |             */ | 
 | 1570 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1571 |             (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); | 
 | 1572 |             (void) QueryMagickColor(argv[i+2],&target,exception); | 
| cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1573 |             (void) FloodfillPaintImage(*image,draw_info,&target,geometry.x, | 
 | 1574 |               geometry.y,*option == '-' ? MagickFalse : MagickTrue); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1575 |             InheritException(exception,&(*image)->exception); | 
 | 1576 |             break; | 
 | 1577 |           } | 
| anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 1578 |         if (LocaleCompare("flop",option+1) == 0) | 
 | 1579 |           { | 
 | 1580 |             /* | 
 | 1581 |               Flop image scanlines. | 
 | 1582 |             */ | 
 | 1583 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1584 |             mogrify_image=FlopImage(*image,exception); | 
 | 1585 |             break; | 
 | 1586 |           } | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1587 |         if (LocaleCompare("font",option+1) == 0) | 
 | 1588 |           { | 
 | 1589 |             if (*option == '+') | 
 | 1590 |               { | 
 | 1591 |                 if (draw_info->font != (char *) NULL) | 
 | 1592 |                   draw_info->font=DestroyString(draw_info->font); | 
 | 1593 |                 break; | 
 | 1594 |               } | 
 | 1595 |             (void) CloneString(&draw_info->font,argv[i+1]); | 
 | 1596 |             break; | 
 | 1597 |           } | 
 | 1598 |         if (LocaleCompare("format",option+1) == 0) | 
 | 1599 |           { | 
 | 1600 |             format=argv[i+1]; | 
 | 1601 |             break; | 
 | 1602 |           } | 
 | 1603 |         if (LocaleCompare("frame",option+1) == 0) | 
 | 1604 |           { | 
 | 1605 |             FrameInfo | 
 | 1606 |               frame_info; | 
 | 1607 |  | 
 | 1608 |             /* | 
 | 1609 |               Surround image with an ornamental border. | 
 | 1610 |             */ | 
 | 1611 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1612 |             flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); | 
 | 1613 |             frame_info.width=geometry.width; | 
 | 1614 |             frame_info.height=geometry.height; | 
 | 1615 |             if ((flags & HeightValue) == 0) | 
 | 1616 |               frame_info.height=geometry.width; | 
 | 1617 |             frame_info.outer_bevel=geometry.x; | 
 | 1618 |             frame_info.inner_bevel=geometry.y; | 
 | 1619 |             frame_info.x=(ssize_t) frame_info.width; | 
 | 1620 |             frame_info.y=(ssize_t) frame_info.height; | 
 | 1621 |             frame_info.width=(*image)->columns+2*frame_info.width; | 
 | 1622 |             frame_info.height=(*image)->rows+2*frame_info.height; | 
 | 1623 |             mogrify_image=FrameImage(*image,&frame_info,exception); | 
 | 1624 |             break; | 
 | 1625 |           } | 
 | 1626 |         if (LocaleCompare("function",option+1) == 0) | 
 | 1627 |           { | 
 | 1628 |             char | 
 | 1629 |               *arguments, | 
 | 1630 |               token[MaxTextExtent]; | 
 | 1631 |  | 
 | 1632 |             const char | 
 | 1633 |               *p; | 
 | 1634 |  | 
 | 1635 |             double | 
 | 1636 |               *parameters; | 
 | 1637 |  | 
 | 1638 |             MagickFunction | 
 | 1639 |               function; | 
 | 1640 |  | 
 | 1641 |             register ssize_t | 
 | 1642 |               x; | 
 | 1643 |  | 
 | 1644 |             size_t | 
 | 1645 |               number_parameters; | 
 | 1646 |  | 
 | 1647 |             /* | 
 | 1648 |               Function Modify Image Values | 
 | 1649 |             */ | 
 | 1650 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1651 |             function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, | 
 | 1652 |               MagickFalse,argv[i+1]); | 
 | 1653 |             arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); | 
 | 1654 |             InheritException(exception,&(*image)->exception); | 
 | 1655 |             if (arguments == (char *) NULL) | 
 | 1656 |               break; | 
 | 1657 |             p=(char *) arguments; | 
 | 1658 |             for (x=0; *p != '\0'; x++) | 
 | 1659 |             { | 
 | 1660 |               GetMagickToken(p,&p,token); | 
 | 1661 |               if (*token == ',') | 
 | 1662 |                 GetMagickToken(p,&p,token); | 
 | 1663 |             } | 
 | 1664 |             number_parameters=(size_t) x; | 
 | 1665 |             parameters=(double *) AcquireQuantumMemory(number_parameters, | 
 | 1666 |               sizeof(*parameters)); | 
 | 1667 |             if (parameters == (double *) NULL) | 
 | 1668 |               ThrowWandFatalException(ResourceLimitFatalError, | 
 | 1669 |                 "MemoryAllocationFailed",(*image)->filename); | 
 | 1670 |             (void) ResetMagickMemory(parameters,0,number_parameters* | 
 | 1671 |               sizeof(*parameters)); | 
 | 1672 |             p=(char *) arguments; | 
 | 1673 |             for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) | 
 | 1674 |             { | 
 | 1675 |               GetMagickToken(p,&p,token); | 
 | 1676 |               if (*token == ',') | 
 | 1677 |                 GetMagickToken(p,&p,token); | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1678 |               parameters[x]=InterpretLocaleValue(token,(char **) NULL); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1679 |             } | 
 | 1680 |             arguments=DestroyString(arguments); | 
| cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 1681 |             (void) FunctionImage(*image,function,number_parameters,parameters, | 
 | 1682 |               exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1683 |             parameters=(double *) RelinquishMagickMemory(parameters); | 
 | 1684 |             break; | 
 | 1685 |           } | 
 | 1686 |         break; | 
 | 1687 |       } | 
 | 1688 |       case 'g': | 
 | 1689 |       { | 
 | 1690 |         if (LocaleCompare("gamma",option+1) == 0) | 
 | 1691 |           { | 
 | 1692 |             /* | 
 | 1693 |               Gamma image. | 
 | 1694 |             */ | 
 | 1695 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1696 |             if (*option == '+') | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1697 |               (*image)->gamma=InterpretLocaleValue(argv[i+1],(char **) NULL); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1698 |             else | 
| cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 1699 |               (void) GammaImage(*image,InterpretLocaleValue(argv[i+1], | 
 | 1700 |                 (char **) NULL),exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1701 |             break; | 
 | 1702 |           } | 
 | 1703 |         if ((LocaleCompare("gaussian-blur",option+1) == 0) || | 
 | 1704 |             (LocaleCompare("gaussian",option+1) == 0)) | 
 | 1705 |           { | 
 | 1706 |             /* | 
 | 1707 |               Gaussian blur image. | 
 | 1708 |             */ | 
 | 1709 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1710 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 1711 |             if ((flags & SigmaValue) == 0) | 
 | 1712 |               geometry_info.sigma=1.0; | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 1713 |             mogrify_image=GaussianBlurImage(*image,geometry_info.rho, | 
 | 1714 |               geometry_info.sigma,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1715 |             break; | 
 | 1716 |           } | 
 | 1717 |         if (LocaleCompare("geometry",option+1) == 0) | 
 | 1718 |           { | 
 | 1719 |               /* | 
 | 1720 |                 Record Image offset, Resize last image. | 
 | 1721 |               */ | 
 | 1722 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1723 |             if (*option == '+') | 
 | 1724 |               { | 
 | 1725 |                 if ((*image)->geometry != (char *) NULL) | 
 | 1726 |                   (*image)->geometry=DestroyString((*image)->geometry); | 
 | 1727 |                 break; | 
 | 1728 |               } | 
 | 1729 |             flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); | 
 | 1730 |             if (((flags & XValue) != 0) || ((flags & YValue) != 0)) | 
 | 1731 |               (void) CloneString(&(*image)->geometry,argv[i+1]); | 
 | 1732 |             else | 
 | 1733 |               mogrify_image=ResizeImage(*image,geometry.width,geometry.height, | 
 | 1734 |                 (*image)->filter,(*image)->blur,exception); | 
 | 1735 |             break; | 
 | 1736 |           } | 
 | 1737 |         if (LocaleCompare("gravity",option+1) == 0) | 
 | 1738 |           { | 
 | 1739 |             if (*option == '+') | 
 | 1740 |               { | 
 | 1741 |                 draw_info->gravity=UndefinedGravity; | 
 | 1742 |                 break; | 
 | 1743 |               } | 
 | 1744 |             draw_info->gravity=(GravityType) ParseCommandOption( | 
 | 1745 |               MagickGravityOptions,MagickFalse,argv[i+1]); | 
 | 1746 |             break; | 
 | 1747 |           } | 
 | 1748 |         break; | 
 | 1749 |       } | 
 | 1750 |       case 'h': | 
 | 1751 |       { | 
 | 1752 |         if (LocaleCompare("highlight-color",option+1) == 0) | 
 | 1753 |           { | 
 | 1754 |             (void) SetImageArtifact(*image,option+1,argv[i+1]); | 
 | 1755 |             break; | 
 | 1756 |           } | 
 | 1757 |         break; | 
 | 1758 |       } | 
 | 1759 |       case 'i': | 
 | 1760 |       { | 
 | 1761 |         if (LocaleCompare("identify",option+1) == 0) | 
 | 1762 |           { | 
 | 1763 |             char | 
 | 1764 |               *text; | 
 | 1765 |  | 
 | 1766 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1767 |             if (format == (char *) NULL) | 
 | 1768 |               { | 
 | 1769 |                 (void) IdentifyImage(*image,stdout,mogrify_info->verbose); | 
 | 1770 |                 InheritException(exception,&(*image)->exception); | 
 | 1771 |                 break; | 
 | 1772 |               } | 
 | 1773 |             text=InterpretImageProperties(mogrify_info,*image,format); | 
 | 1774 |             InheritException(exception,&(*image)->exception); | 
 | 1775 |             if (text == (char *) NULL) | 
 | 1776 |               break; | 
 | 1777 |             (void) fputs(text,stdout); | 
 | 1778 |             (void) fputc('\n',stdout); | 
 | 1779 |             text=DestroyString(text); | 
 | 1780 |             break; | 
 | 1781 |           } | 
 | 1782 |         if (LocaleCompare("implode",option+1) == 0) | 
 | 1783 |           { | 
 | 1784 |             /* | 
 | 1785 |               Implode image. | 
 | 1786 |             */ | 
 | 1787 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1788 |             (void) ParseGeometry(argv[i+1],&geometry_info); | 
 | 1789 |             mogrify_image=ImplodeImage(*image,geometry_info.rho,exception); | 
 | 1790 |             break; | 
 | 1791 |           } | 
 | 1792 |         if (LocaleCompare("interline-spacing",option+1) == 0) | 
 | 1793 |           { | 
 | 1794 |             if (*option == '+') | 
 | 1795 |               (void) ParseGeometry("0",&geometry_info); | 
 | 1796 |             else | 
 | 1797 |               (void) ParseGeometry(argv[i+1],&geometry_info); | 
 | 1798 |             draw_info->interline_spacing=geometry_info.rho; | 
 | 1799 |             break; | 
 | 1800 |           } | 
 | 1801 |         if (LocaleCompare("interword-spacing",option+1) == 0) | 
 | 1802 |           { | 
 | 1803 |             if (*option == '+') | 
 | 1804 |               (void) ParseGeometry("0",&geometry_info); | 
 | 1805 |             else | 
 | 1806 |               (void) ParseGeometry(argv[i+1],&geometry_info); | 
 | 1807 |             draw_info->interword_spacing=geometry_info.rho; | 
 | 1808 |             break; | 
 | 1809 |           } | 
 | 1810 |         break; | 
 | 1811 |       } | 
 | 1812 |       case 'k': | 
 | 1813 |       { | 
 | 1814 |         if (LocaleCompare("kerning",option+1) == 0) | 
 | 1815 |           { | 
 | 1816 |             if (*option == '+') | 
 | 1817 |               (void) ParseGeometry("0",&geometry_info); | 
 | 1818 |             else | 
 | 1819 |               (void) ParseGeometry(argv[i+1],&geometry_info); | 
 | 1820 |             draw_info->kerning=geometry_info.rho; | 
 | 1821 |             break; | 
 | 1822 |           } | 
 | 1823 |         break; | 
 | 1824 |       } | 
 | 1825 |       case 'l': | 
 | 1826 |       { | 
 | 1827 |         if (LocaleCompare("lat",option+1) == 0) | 
 | 1828 |           { | 
 | 1829 |             /* | 
 | 1830 |               Local adaptive threshold image. | 
 | 1831 |             */ | 
 | 1832 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1833 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 1834 |             if ((flags & PercentValue) != 0) | 
 | 1835 |               geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; | 
 | 1836 |             mogrify_image=AdaptiveThresholdImage(*image,(size_t) | 
| cristy | de5cc63 | 2011-07-18 14:47:00 +0000 | [diff] [blame] | 1837 |               geometry_info.rho,(size_t) geometry_info.sigma,(double) | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1838 |               geometry_info.xi,exception); | 
 | 1839 |             break; | 
 | 1840 |           } | 
 | 1841 |         if (LocaleCompare("level",option+1) == 0) | 
 | 1842 |           { | 
 | 1843 |             MagickRealType | 
 | 1844 |               black_point, | 
 | 1845 |               gamma, | 
 | 1846 |               white_point; | 
 | 1847 |  | 
 | 1848 |             MagickStatusType | 
 | 1849 |               flags; | 
 | 1850 |  | 
 | 1851 |             /* | 
 | 1852 |               Parse levels. | 
 | 1853 |             */ | 
 | 1854 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1855 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 1856 |             black_point=geometry_info.rho; | 
 | 1857 |             white_point=(MagickRealType) QuantumRange; | 
 | 1858 |             if ((flags & SigmaValue) != 0) | 
 | 1859 |               white_point=geometry_info.sigma; | 
 | 1860 |             gamma=1.0; | 
 | 1861 |             if ((flags & XiValue) != 0) | 
 | 1862 |               gamma=geometry_info.xi; | 
 | 1863 |             if ((flags & PercentValue) != 0) | 
 | 1864 |               { | 
 | 1865 |                 black_point*=(MagickRealType) (QuantumRange/100.0); | 
 | 1866 |                 white_point*=(MagickRealType) (QuantumRange/100.0); | 
 | 1867 |               } | 
 | 1868 |             if ((flags & SigmaValue) == 0) | 
 | 1869 |               white_point=(MagickRealType) QuantumRange-black_point; | 
 | 1870 |             if ((*option == '+') || ((flags & AspectValue) != 0)) | 
| cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 1871 |               (void) LevelizeImage(*image,black_point,white_point,gamma); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1872 |             else | 
| cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 1873 |               (void) LevelImage(*image,black_point,white_point,gamma); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1874 |             InheritException(exception,&(*image)->exception); | 
 | 1875 |             break; | 
 | 1876 |           } | 
 | 1877 |         if (LocaleCompare("level-colors",option+1) == 0) | 
 | 1878 |           { | 
 | 1879 |             char | 
 | 1880 |               token[MaxTextExtent]; | 
 | 1881 |  | 
 | 1882 |             const char | 
 | 1883 |               *p; | 
 | 1884 |  | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1885 |             PixelInfo | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1886 |               black_point, | 
 | 1887 |               white_point; | 
 | 1888 |  | 
 | 1889 |             p=(const char *) argv[i+1]; | 
 | 1890 |             GetMagickToken(p,&p,token);  /* get black point color */ | 
 | 1891 |             if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) | 
 | 1892 |               (void) QueryMagickColor(token,&black_point,exception); | 
 | 1893 |             else | 
 | 1894 |               (void) QueryMagickColor("#000000",&black_point,exception); | 
 | 1895 |             if (isalpha((int) token[0]) || (token[0] == '#')) | 
 | 1896 |               GetMagickToken(p,&p,token); | 
 | 1897 |             if (*token == '\0') | 
 | 1898 |               white_point=black_point; /* set everything to that color */ | 
 | 1899 |             else | 
 | 1900 |               { | 
 | 1901 |                 if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) | 
 | 1902 |                   GetMagickToken(p,&p,token); /* Get white point color. */ | 
 | 1903 |                 if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) | 
 | 1904 |                   (void) QueryMagickColor(token,&white_point,exception); | 
 | 1905 |                 else | 
 | 1906 |                   (void) QueryMagickColor("#ffffff",&white_point,exception); | 
 | 1907 |               } | 
| cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 1908 |             (void) LevelImageColors(*image,&black_point,&white_point, | 
 | 1909 |               *option == '+' ? MagickTrue : MagickFalse); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1910 |             break; | 
 | 1911 |           } | 
 | 1912 |         if (LocaleCompare("linear-stretch",option+1) == 0) | 
 | 1913 |           { | 
 | 1914 |             double | 
 | 1915 |               black_point, | 
 | 1916 |               white_point; | 
 | 1917 |  | 
 | 1918 |             MagickStatusType | 
 | 1919 |               flags; | 
 | 1920 |  | 
 | 1921 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1922 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 1923 |             black_point=geometry_info.rho; | 
 | 1924 |             white_point=(MagickRealType) (*image)->columns*(*image)->rows; | 
 | 1925 |             if ((flags & SigmaValue) != 0) | 
 | 1926 |               white_point=geometry_info.sigma; | 
 | 1927 |             if ((flags & PercentValue) != 0) | 
 | 1928 |               { | 
 | 1929 |                 black_point*=(double) (*image)->columns*(*image)->rows/100.0; | 
 | 1930 |                 white_point*=(double) (*image)->columns*(*image)->rows/100.0; | 
 | 1931 |               } | 
 | 1932 |             if ((flags & SigmaValue) == 0) | 
 | 1933 |               white_point=(MagickRealType) (*image)->columns*(*image)->rows- | 
 | 1934 |                 black_point; | 
 | 1935 |             (void) LinearStretchImage(*image,black_point,white_point); | 
 | 1936 |             InheritException(exception,&(*image)->exception); | 
 | 1937 |             break; | 
 | 1938 |           } | 
 | 1939 |         if (LocaleCompare("linewidth",option+1) == 0) | 
 | 1940 |           { | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 1941 |             draw_info->stroke_width=InterpretLocaleValue(argv[i+1], | 
 | 1942 |               (char **) NULL); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1943 |             break; | 
 | 1944 |           } | 
 | 1945 |         if (LocaleCompare("liquid-rescale",option+1) == 0) | 
 | 1946 |           { | 
 | 1947 |             /* | 
 | 1948 |               Liquid rescale image. | 
 | 1949 |             */ | 
 | 1950 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1951 |             flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); | 
 | 1952 |             if ((flags & XValue) == 0) | 
 | 1953 |               geometry.x=1; | 
 | 1954 |             if ((flags & YValue) == 0) | 
 | 1955 |               geometry.y=0; | 
 | 1956 |             mogrify_image=LiquidRescaleImage(*image,geometry.width, | 
 | 1957 |               geometry.height,1.0*geometry.x,1.0*geometry.y,exception); | 
 | 1958 |             break; | 
 | 1959 |           } | 
 | 1960 |         if (LocaleCompare("lowlight-color",option+1) == 0) | 
 | 1961 |           { | 
 | 1962 |             (void) SetImageArtifact(*image,option+1,argv[i+1]); | 
 | 1963 |             break; | 
 | 1964 |           } | 
 | 1965 |         break; | 
 | 1966 |       } | 
 | 1967 |       case 'm': | 
 | 1968 |       { | 
 | 1969 |         if (LocaleCompare("map",option+1) == 0) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1970 |           { | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1971 |             Image | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1972 |               *remap_image; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1973 |  | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1974 |             /* | 
 | 1975 |               Transform image colors to match this set of colors. | 
 | 1976 |             */ | 
 | 1977 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1978 |             if (*option == '+') | 
 | 1979 |               break; | 
 | 1980 |             remap_image=GetImageCache(mogrify_info,argv[i+1],exception); | 
 | 1981 |             if (remap_image == (Image *) NULL) | 
 | 1982 |               break; | 
 | 1983 |             (void) RemapImage(quantize_info,*image,remap_image); | 
 | 1984 |             InheritException(exception,&(*image)->exception); | 
 | 1985 |             remap_image=DestroyImage(remap_image); | 
 | 1986 |             break; | 
 | 1987 |           } | 
 | 1988 |         if (LocaleCompare("mask",option+1) == 0) | 
 | 1989 |           { | 
 | 1990 |             Image | 
 | 1991 |               *mask; | 
 | 1992 |  | 
 | 1993 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 1994 |             if (*option == '+') | 
 | 1995 |               { | 
 | 1996 |                 /* | 
 | 1997 |                   Remove a mask. | 
 | 1998 |                 */ | 
 | 1999 |                 (void) SetImageMask(*image,(Image *) NULL); | 
 | 2000 |                 InheritException(exception,&(*image)->exception); | 
 | 2001 |                 break; | 
 | 2002 |               } | 
 | 2003 |             /* | 
 | 2004 |               Set the image mask. | 
 | 2005 |             */ | 
 | 2006 |             mask=GetImageCache(mogrify_info,argv[i+1],exception); | 
 | 2007 |             if (mask == (Image *) NULL) | 
 | 2008 |               break; | 
 | 2009 |             (void) SetImageMask(*image,mask); | 
 | 2010 |             mask=DestroyImage(mask); | 
 | 2011 |             InheritException(exception,&(*image)->exception); | 
 | 2012 |             break; | 
 | 2013 |           } | 
 | 2014 |         if (LocaleCompare("matte",option+1) == 0) | 
 | 2015 |           { | 
 | 2016 |             (void) SetImageAlphaChannel(*image,(*option == '-') ? | 
 | 2017 |               SetAlphaChannel : DeactivateAlphaChannel ); | 
 | 2018 |             InheritException(exception,&(*image)->exception); | 
 | 2019 |             break; | 
 | 2020 |           } | 
 | 2021 |         if (LocaleCompare("median",option+1) == 0) | 
 | 2022 |           { | 
 | 2023 |             /* | 
 | 2024 |               Median filter image. | 
 | 2025 |             */ | 
 | 2026 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2027 |             (void) ParseGeometry(argv[i+1],&geometry_info); | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2028 |             mogrify_image=StatisticImage(*image,MedianStatistic,(size_t) | 
 | 2029 |               geometry_info.rho,(size_t) geometry_info.rho,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2030 |             break; | 
 | 2031 |           } | 
 | 2032 |         if (LocaleCompare("mode",option+1) == 0) | 
 | 2033 |           { | 
 | 2034 |             /* | 
 | 2035 |               Mode image. | 
 | 2036 |             */ | 
 | 2037 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2038 |             (void) ParseGeometry(argv[i+1],&geometry_info); | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2039 |             mogrify_image=StatisticImage(*image,ModeStatistic,(size_t) | 
 | 2040 |               geometry_info.rho,(size_t) geometry_info.rho,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2041 |             break; | 
 | 2042 |           } | 
 | 2043 |         if (LocaleCompare("modulate",option+1) == 0) | 
 | 2044 |           { | 
 | 2045 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2046 |             (void) ModulateImage(*image,argv[i+1]); | 
 | 2047 |             InheritException(exception,&(*image)->exception); | 
 | 2048 |             break; | 
 | 2049 |           } | 
 | 2050 |         if (LocaleCompare("monitor",option+1) == 0) | 
 | 2051 |           { | 
 | 2052 |             if (*option == '+') | 
 | 2053 |               { | 
 | 2054 |                 (void) SetImageProgressMonitor(*image, | 
 | 2055 |                   (MagickProgressMonitor) NULL,(void *) NULL); | 
 | 2056 |                 break; | 
 | 2057 |               } | 
 | 2058 |             (void) SetImageProgressMonitor(*image,MonitorProgress, | 
 | 2059 |               (void *) NULL); | 
 | 2060 |             break; | 
 | 2061 |           } | 
 | 2062 |         if (LocaleCompare("monochrome",option+1) == 0) | 
 | 2063 |           { | 
 | 2064 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2065 |             (void) SetImageType(*image,BilevelType); | 
 | 2066 |             InheritException(exception,&(*image)->exception); | 
 | 2067 |             break; | 
 | 2068 |           } | 
 | 2069 |         if (LocaleCompare("morphology",option+1) == 0) | 
 | 2070 |           { | 
 | 2071 |             char | 
 | 2072 |               token[MaxTextExtent]; | 
 | 2073 |  | 
 | 2074 |             const char | 
 | 2075 |               *p; | 
 | 2076 |  | 
 | 2077 |             KernelInfo | 
 | 2078 |               *kernel; | 
 | 2079 |  | 
 | 2080 |             MorphologyMethod | 
 | 2081 |               method; | 
 | 2082 |  | 
 | 2083 |             ssize_t | 
 | 2084 |               iterations; | 
 | 2085 |  | 
 | 2086 |             /* | 
 | 2087 |               Morphological Image Operation | 
 | 2088 |             */ | 
 | 2089 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2090 |             p=argv[i+1]; | 
 | 2091 |             GetMagickToken(p,&p,token); | 
 | 2092 |             method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions, | 
 | 2093 |               MagickFalse,token); | 
 | 2094 |             iterations=1L; | 
 | 2095 |             GetMagickToken(p,&p,token); | 
 | 2096 |             if ((*p == ':') || (*p == ',')) | 
 | 2097 |               GetMagickToken(p,&p,token); | 
 | 2098 |             if ((*p != '\0')) | 
 | 2099 |               iterations=(ssize_t) StringToLong(p); | 
 | 2100 |             kernel=AcquireKernelInfo(argv[i+2]); | 
 | 2101 |             if (kernel == (KernelInfo *) NULL) | 
 | 2102 |               { | 
 | 2103 |                 (void) ThrowMagickException(exception,GetMagickModule(), | 
 | 2104 |                   OptionError,"UnabletoParseKernel","morphology"); | 
 | 2105 |                 status=MagickFalse; | 
 | 2106 |                 break; | 
 | 2107 |               } | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2108 |             mogrify_image=MorphologyImage(*image,method,iterations,kernel, | 
 | 2109 |               exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2110 |             kernel=DestroyKernelInfo(kernel); | 
 | 2111 |             break; | 
 | 2112 |           } | 
 | 2113 |         if (LocaleCompare("motion-blur",option+1) == 0) | 
 | 2114 |           { | 
 | 2115 |             /* | 
 | 2116 |               Motion blur image. | 
 | 2117 |             */ | 
 | 2118 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2119 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 2120 |             if ((flags & SigmaValue) == 0) | 
 | 2121 |               geometry_info.sigma=1.0; | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2122 |             mogrify_image=MotionBlurImage(*image,geometry_info.rho, | 
 | 2123 |               geometry_info.sigma,geometry_info.xi,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2124 |             break; | 
 | 2125 |           } | 
 | 2126 |         break; | 
 | 2127 |       } | 
 | 2128 |       case 'n': | 
 | 2129 |       { | 
 | 2130 |         if (LocaleCompare("negate",option+1) == 0) | 
 | 2131 |           { | 
 | 2132 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2133 |             (void) NegateImage(*image,*option == '+' ? MagickTrue : | 
| cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 2134 |               MagickFalse,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2135 |             break; | 
 | 2136 |           } | 
 | 2137 |         if (LocaleCompare("noise",option+1) == 0) | 
 | 2138 |           { | 
 | 2139 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2140 |             if (*option == '-') | 
 | 2141 |               { | 
 | 2142 |                 (void) ParseGeometry(argv[i+1],&geometry_info); | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2143 |                 mogrify_image=StatisticImage(*image,NonpeakStatistic,(size_t) | 
 | 2144 |                   geometry_info.rho,(size_t) geometry_info.rho,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2145 |               } | 
 | 2146 |             else | 
 | 2147 |               { | 
 | 2148 |                 NoiseType | 
 | 2149 |                   noise; | 
 | 2150 |  | 
 | 2151 |                 noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, | 
 | 2152 |                   MagickFalse,argv[i+1]); | 
| cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 2153 |                 mogrify_image=AddNoiseImage(*image,noise,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2154 |               } | 
 | 2155 |             break; | 
 | 2156 |           } | 
 | 2157 |         if (LocaleCompare("normalize",option+1) == 0) | 
 | 2158 |           { | 
 | 2159 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | 50fbc38 | 2011-07-07 02:19:17 +0000 | [diff] [blame] | 2160 |             (void) NormalizeImage(*image); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2161 |             InheritException(exception,&(*image)->exception); | 
 | 2162 |             break; | 
 | 2163 |           } | 
 | 2164 |         break; | 
 | 2165 |       } | 
 | 2166 |       case 'o': | 
 | 2167 |       { | 
 | 2168 |         if (LocaleCompare("opaque",option+1) == 0) | 
 | 2169 |           { | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2170 |             PixelInfo | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2171 |               target; | 
 | 2172 |  | 
 | 2173 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2174 |             (void) QueryMagickColor(argv[i+1],&target,exception); | 
| cristy | d42d995 | 2011-07-08 14:21:50 +0000 | [diff] [blame] | 2175 |             (void) OpaquePaintImage(*image,&target,&fill,*option == '-' ? | 
 | 2176 |               MagickFalse : MagickTrue); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2177 |             break; | 
 | 2178 |           } | 
 | 2179 |         if (LocaleCompare("ordered-dither",option+1) == 0) | 
 | 2180 |           { | 
 | 2181 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | 1302067 | 2011-07-08 02:33:26 +0000 | [diff] [blame] | 2182 |             (void) OrderedPosterizeImage(*image,argv[i+1],exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2183 |             break; | 
 | 2184 |           } | 
 | 2185 |         break; | 
 | 2186 |       } | 
 | 2187 |       case 'p': | 
 | 2188 |       { | 
 | 2189 |         if (LocaleCompare("paint",option+1) == 0) | 
 | 2190 |           { | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2191 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2192 |             (void) ParseGeometry(argv[i+1],&geometry_info); | 
| anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame] | 2193 |             mogrify_image=OilPaintImage(*image,geometry_info.rho,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2194 |             break; | 
 | 2195 |           } | 
 | 2196 |         if (LocaleCompare("pen",option+1) == 0) | 
 | 2197 |           { | 
 | 2198 |             if (*option == '+') | 
 | 2199 |               { | 
 | 2200 |                 (void) QueryColorDatabase("none",&draw_info->fill,exception); | 
 | 2201 |                 break; | 
 | 2202 |               } | 
 | 2203 |             (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); | 
 | 2204 |             break; | 
 | 2205 |           } | 
 | 2206 |         if (LocaleCompare("pointsize",option+1) == 0) | 
 | 2207 |           { | 
 | 2208 |             if (*option == '+') | 
 | 2209 |               (void) ParseGeometry("12",&geometry_info); | 
 | 2210 |             else | 
 | 2211 |               (void) ParseGeometry(argv[i+1],&geometry_info); | 
 | 2212 |             draw_info->pointsize=geometry_info.rho; | 
 | 2213 |             break; | 
 | 2214 |           } | 
 | 2215 |         if (LocaleCompare("polaroid",option+1) == 0) | 
 | 2216 |           { | 
 | 2217 |             double | 
 | 2218 |               angle; | 
 | 2219 |  | 
 | 2220 |             RandomInfo | 
 | 2221 |               *random_info; | 
 | 2222 |  | 
 | 2223 |             /* | 
 | 2224 |               Simulate a Polaroid picture. | 
 | 2225 |             */ | 
 | 2226 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2227 |             random_info=AcquireRandomInfo(); | 
 | 2228 |             angle=22.5*(GetPseudoRandomValue(random_info)-0.5); | 
 | 2229 |             random_info=DestroyRandomInfo(random_info); | 
 | 2230 |             if (*option == '-') | 
 | 2231 |               { | 
 | 2232 |                 SetGeometryInfo(&geometry_info); | 
 | 2233 |                 flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 2234 |                 angle=geometry_info.rho; | 
 | 2235 |               } | 
 | 2236 |             mogrify_image=PolaroidImage(*image,draw_info,angle,exception); | 
 | 2237 |             break; | 
 | 2238 |           } | 
 | 2239 |         if (LocaleCompare("posterize",option+1) == 0) | 
 | 2240 |           { | 
 | 2241 |             /* | 
 | 2242 |               Posterize image. | 
 | 2243 |             */ | 
 | 2244 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2245 |             (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), | 
 | 2246 |               quantize_info->dither); | 
 | 2247 |             InheritException(exception,&(*image)->exception); | 
 | 2248 |             break; | 
 | 2249 |           } | 
 | 2250 |         if (LocaleCompare("preview",option+1) == 0) | 
 | 2251 |           { | 
 | 2252 |             PreviewType | 
 | 2253 |               preview_type; | 
 | 2254 |  | 
 | 2255 |             /* | 
 | 2256 |               Preview image. | 
 | 2257 |             */ | 
 | 2258 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2259 |             if (*option == '+') | 
 | 2260 |               preview_type=UndefinedPreview; | 
 | 2261 |             else | 
 | 2262 |               preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, | 
 | 2263 |                 MagickFalse,argv[i+1]); | 
 | 2264 |             mogrify_image=PreviewImage(*image,preview_type,exception); | 
 | 2265 |             break; | 
 | 2266 |           } | 
 | 2267 |         if (LocaleCompare("profile",option+1) == 0) | 
 | 2268 |           { | 
 | 2269 |             const char | 
 | 2270 |               *name; | 
 | 2271 |  | 
 | 2272 |             const StringInfo | 
 | 2273 |               *profile; | 
 | 2274 |  | 
 | 2275 |             Image | 
 | 2276 |               *profile_image; | 
 | 2277 |  | 
 | 2278 |             ImageInfo | 
 | 2279 |               *profile_info; | 
 | 2280 |  | 
 | 2281 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2282 |             if (*option == '+') | 
 | 2283 |               { | 
 | 2284 |                 /* | 
 | 2285 |                   Remove a profile from the image. | 
 | 2286 |                 */ | 
 | 2287 |                 (void) ProfileImage(*image,argv[i+1],(const unsigned char *) | 
 | 2288 |                   NULL,0,MagickTrue); | 
 | 2289 |                 InheritException(exception,&(*image)->exception); | 
 | 2290 |                 break; | 
 | 2291 |               } | 
 | 2292 |             /* | 
 | 2293 |               Associate a profile with the image. | 
 | 2294 |             */ | 
 | 2295 |             profile_info=CloneImageInfo(mogrify_info); | 
 | 2296 |             profile=GetImageProfile(*image,"iptc"); | 
 | 2297 |             if (profile != (StringInfo *) NULL) | 
 | 2298 |               profile_info->profile=(void *) CloneStringInfo(profile); | 
 | 2299 |             profile_image=GetImageCache(profile_info,argv[i+1],exception); | 
 | 2300 |             profile_info=DestroyImageInfo(profile_info); | 
 | 2301 |             if (profile_image == (Image *) NULL) | 
 | 2302 |               { | 
 | 2303 |                 StringInfo | 
 | 2304 |                   *profile; | 
 | 2305 |  | 
 | 2306 |                 profile_info=CloneImageInfo(mogrify_info); | 
 | 2307 |                 (void) CopyMagickString(profile_info->filename,argv[i+1], | 
 | 2308 |                   MaxTextExtent); | 
 | 2309 |                 profile=FileToStringInfo(profile_info->filename,~0UL,exception); | 
 | 2310 |                 if (profile != (StringInfo *) NULL) | 
 | 2311 |                   { | 
 | 2312 |                     (void) ProfileImage(*image,profile_info->magick, | 
 | 2313 |                       GetStringInfoDatum(profile),(size_t) | 
 | 2314 |                       GetStringInfoLength(profile),MagickFalse); | 
 | 2315 |                     profile=DestroyStringInfo(profile); | 
 | 2316 |                   } | 
 | 2317 |                 profile_info=DestroyImageInfo(profile_info); | 
 | 2318 |                 break; | 
 | 2319 |               } | 
 | 2320 |             ResetImageProfileIterator(profile_image); | 
 | 2321 |             name=GetNextImageProfile(profile_image); | 
 | 2322 |             while (name != (const char *) NULL) | 
 | 2323 |             { | 
 | 2324 |               profile=GetImageProfile(profile_image,name); | 
 | 2325 |               if (profile != (StringInfo *) NULL) | 
 | 2326 |                 (void) ProfileImage(*image,name,GetStringInfoDatum(profile), | 
 | 2327 |                   (size_t) GetStringInfoLength(profile),MagickFalse); | 
 | 2328 |               name=GetNextImageProfile(profile_image); | 
 | 2329 |             } | 
 | 2330 |             profile_image=DestroyImage(profile_image); | 
 | 2331 |             break; | 
 | 2332 |           } | 
 | 2333 |         break; | 
 | 2334 |       } | 
 | 2335 |       case 'q': | 
 | 2336 |       { | 
 | 2337 |         if (LocaleCompare("quantize",option+1) == 0) | 
 | 2338 |           { | 
 | 2339 |             if (*option == '+') | 
 | 2340 |               { | 
 | 2341 |                 quantize_info->colorspace=UndefinedColorspace; | 
 | 2342 |                 break; | 
 | 2343 |               } | 
 | 2344 |             quantize_info->colorspace=(ColorspaceType) ParseCommandOption( | 
 | 2345 |               MagickColorspaceOptions,MagickFalse,argv[i+1]); | 
 | 2346 |             break; | 
 | 2347 |           } | 
 | 2348 |         break; | 
 | 2349 |       } | 
 | 2350 |       case 'r': | 
 | 2351 |       { | 
 | 2352 |         if (LocaleCompare("radial-blur",option+1) == 0) | 
 | 2353 |           { | 
 | 2354 |             /* | 
 | 2355 |               Radial blur image. | 
 | 2356 |             */ | 
 | 2357 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2358 |             mogrify_image=RadialBlurImage(*image,InterpretLocaleValue(argv[i+1], | 
 | 2359 |               (char **) NULL),exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2360 |             break; | 
 | 2361 |           } | 
 | 2362 |         if (LocaleCompare("raise",option+1) == 0) | 
 | 2363 |           { | 
 | 2364 |             /* | 
 | 2365 |               Surround image with a raise of solid color. | 
 | 2366 |             */ | 
 | 2367 |             flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); | 
 | 2368 |             if ((flags & SigmaValue) == 0) | 
 | 2369 |               geometry.height=geometry.width; | 
 | 2370 |             (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : | 
 | 2371 |               MagickFalse); | 
 | 2372 |             InheritException(exception,&(*image)->exception); | 
 | 2373 |             break; | 
 | 2374 |           } | 
 | 2375 |         if (LocaleCompare("random-threshold",option+1) == 0) | 
 | 2376 |           { | 
 | 2377 |             /* | 
 | 2378 |               Threshold image. | 
 | 2379 |             */ | 
 | 2380 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2381 |             (void) RandomThresholdImage(*image,argv[i+1],exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2382 |             break; | 
 | 2383 |           } | 
 | 2384 |         if (LocaleCompare("recolor",option+1) == 0) | 
 | 2385 |           { | 
 | 2386 |             KernelInfo | 
 | 2387 |               *kernel; | 
 | 2388 |  | 
 | 2389 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2390 |             kernel=AcquireKernelInfo(argv[i+1]); | 
 | 2391 |             if (kernel == (KernelInfo *) NULL) | 
 | 2392 |               break; | 
 | 2393 |             mogrify_image=ColorMatrixImage(*image,kernel,exception); | 
 | 2394 |             kernel=DestroyKernelInfo(kernel); | 
 | 2395 |             break; | 
 | 2396 |           } | 
 | 2397 |         if (LocaleCompare("region",option+1) == 0) | 
 | 2398 |           { | 
 | 2399 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2400 |             if (region_image != (Image *) NULL) | 
 | 2401 |               { | 
 | 2402 |                 /* | 
 | 2403 |                   Composite region. | 
 | 2404 |                 */ | 
 | 2405 |                 (void) CompositeImage(region_image,region_image->matte != | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2406 |                    MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, | 
 | 2407 |                    region_geometry.x,region_geometry.y); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2408 |                 InheritException(exception,®ion_image->exception); | 
 | 2409 |                 *image=DestroyImage(*image); | 
 | 2410 |                 *image=region_image; | 
 | 2411 |                 region_image = (Image *) NULL; | 
 | 2412 |               } | 
 | 2413 |             if (*option == '+') | 
 | 2414 |               break; | 
 | 2415 |             /* | 
 | 2416 |               Apply transformations to a selected region of the image. | 
 | 2417 |             */ | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2418 |             (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, | 
 | 2419 |               exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2420 |             mogrify_image=CropImage(*image,®ion_geometry,exception); | 
 | 2421 |             if (mogrify_image == (Image *) NULL) | 
 | 2422 |               break; | 
 | 2423 |             region_image=(*image); | 
 | 2424 |             *image=mogrify_image; | 
 | 2425 |             mogrify_image=(Image *) NULL; | 
 | 2426 |             break; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2427 |           } | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2428 |         if (LocaleCompare("render",option+1) == 0) | 
 | 2429 |           { | 
 | 2430 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2431 |             draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; | 
 | 2432 |             break; | 
 | 2433 |           } | 
 | 2434 |         if (LocaleCompare("remap",option+1) == 0) | 
 | 2435 |           { | 
 | 2436 |             Image | 
 | 2437 |               *remap_image; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2438 |  | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2439 |             /* | 
 | 2440 |               Transform image colors to match this set of colors. | 
 | 2441 |             */ | 
 | 2442 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2443 |             if (*option == '+') | 
 | 2444 |               break; | 
 | 2445 |             remap_image=GetImageCache(mogrify_info,argv[i+1],exception); | 
 | 2446 |             if (remap_image == (Image *) NULL) | 
 | 2447 |               break; | 
 | 2448 |             (void) RemapImage(quantize_info,*image,remap_image); | 
 | 2449 |             InheritException(exception,&(*image)->exception); | 
 | 2450 |             remap_image=DestroyImage(remap_image); | 
 | 2451 |             break; | 
 | 2452 |           } | 
 | 2453 |         if (LocaleCompare("repage",option+1) == 0) | 
 | 2454 |           { | 
 | 2455 |             if (*option == '+') | 
 | 2456 |               { | 
 | 2457 |                 (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); | 
 | 2458 |                 break; | 
 | 2459 |               } | 
 | 2460 |             (void) ResetImagePage(*image,argv[i+1]); | 
 | 2461 |             InheritException(exception,&(*image)->exception); | 
 | 2462 |             break; | 
 | 2463 |           } | 
 | 2464 |         if (LocaleCompare("resample",option+1) == 0) | 
 | 2465 |           { | 
 | 2466 |             /* | 
 | 2467 |               Resample image. | 
 | 2468 |             */ | 
 | 2469 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2470 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 2471 |             if ((flags & SigmaValue) == 0) | 
 | 2472 |               geometry_info.sigma=geometry_info.rho; | 
 | 2473 |             mogrify_image=ResampleImage(*image,geometry_info.rho, | 
 | 2474 |               geometry_info.sigma,(*image)->filter,(*image)->blur,exception); | 
 | 2475 |             break; | 
 | 2476 |           } | 
 | 2477 |         if (LocaleCompare("resize",option+1) == 0) | 
 | 2478 |           { | 
 | 2479 |             /* | 
 | 2480 |               Resize image. | 
 | 2481 |             */ | 
 | 2482 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2483 |             (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); | 
 | 2484 |             mogrify_image=ResizeImage(*image,geometry.width,geometry.height, | 
 | 2485 |               (*image)->filter,(*image)->blur,exception); | 
 | 2486 |             break; | 
 | 2487 |           } | 
 | 2488 |         if (LocaleCompare("roll",option+1) == 0) | 
 | 2489 |           { | 
 | 2490 |             /* | 
 | 2491 |               Roll image. | 
 | 2492 |             */ | 
 | 2493 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2494 |             (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); | 
 | 2495 |             mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); | 
 | 2496 |             break; | 
 | 2497 |           } | 
 | 2498 |         if (LocaleCompare("rotate",option+1) == 0) | 
 | 2499 |           { | 
 | 2500 |             char | 
 | 2501 |               *geometry; | 
 | 2502 |  | 
 | 2503 |             /* | 
 | 2504 |               Check for conditional image rotation. | 
 | 2505 |             */ | 
 | 2506 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2507 |             if (strchr(argv[i+1],'>') != (char *) NULL) | 
 | 2508 |               if ((*image)->columns <= (*image)->rows) | 
 | 2509 |                 break; | 
 | 2510 |             if (strchr(argv[i+1],'<') != (char *) NULL) | 
 | 2511 |               if ((*image)->columns >= (*image)->rows) | 
 | 2512 |                 break; | 
 | 2513 |             /* | 
 | 2514 |               Rotate image. | 
 | 2515 |             */ | 
 | 2516 |             geometry=ConstantString(argv[i+1]); | 
 | 2517 |             (void) SubstituteString(&geometry,">",""); | 
 | 2518 |             (void) SubstituteString(&geometry,"<",""); | 
 | 2519 |             (void) ParseGeometry(geometry,&geometry_info); | 
 | 2520 |             geometry=DestroyString(geometry); | 
 | 2521 |             mogrify_image=RotateImage(*image,geometry_info.rho,exception); | 
 | 2522 |             break; | 
 | 2523 |           } | 
 | 2524 |         break; | 
 | 2525 |       } | 
 | 2526 |       case 's': | 
 | 2527 |       { | 
 | 2528 |         if (LocaleCompare("sample",option+1) == 0) | 
 | 2529 |           { | 
 | 2530 |             /* | 
 | 2531 |               Sample image with pixel replication. | 
 | 2532 |             */ | 
 | 2533 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2534 |             (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); | 
 | 2535 |             mogrify_image=SampleImage(*image,geometry.width,geometry.height, | 
 | 2536 |               exception); | 
 | 2537 |             break; | 
 | 2538 |           } | 
 | 2539 |         if (LocaleCompare("scale",option+1) == 0) | 
 | 2540 |           { | 
 | 2541 |             /* | 
 | 2542 |               Resize image. | 
 | 2543 |             */ | 
 | 2544 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2545 |             (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); | 
 | 2546 |             mogrify_image=ScaleImage(*image,geometry.width,geometry.height, | 
 | 2547 |               exception); | 
 | 2548 |             break; | 
 | 2549 |           } | 
 | 2550 |         if (LocaleCompare("selective-blur",option+1) == 0) | 
 | 2551 |           { | 
 | 2552 |             /* | 
 | 2553 |               Selectively blur pixels within a contrast threshold. | 
 | 2554 |             */ | 
 | 2555 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2556 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 2557 |             if ((flags & PercentValue) != 0) | 
 | 2558 |               geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2559 |             mogrify_image=SelectiveBlurImage(*image,geometry_info.rho, | 
 | 2560 |               geometry_info.sigma,geometry_info.xi,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2561 |             break; | 
 | 2562 |           } | 
 | 2563 |         if (LocaleCompare("separate",option+1) == 0) | 
 | 2564 |           { | 
 | 2565 |             /* | 
 | 2566 |               Break channels into separate images. | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2567 |             */ | 
 | 2568 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 2569 |             mogrify_image=SeparateImages(*image,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2570 |             break; | 
 | 2571 |           } | 
 | 2572 |         if (LocaleCompare("sepia-tone",option+1) == 0) | 
 | 2573 |           { | 
 | 2574 |             double | 
 | 2575 |               threshold; | 
 | 2576 |  | 
 | 2577 |             /* | 
 | 2578 |               Sepia-tone image. | 
 | 2579 |             */ | 
 | 2580 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2581 |             threshold=SiPrefixToDouble(argv[i+1],QuantumRange); | 
 | 2582 |             mogrify_image=SepiaToneImage(*image,threshold,exception); | 
 | 2583 |             break; | 
 | 2584 |           } | 
 | 2585 |         if (LocaleCompare("segment",option+1) == 0) | 
 | 2586 |           { | 
 | 2587 |             /* | 
 | 2588 |               Segment image. | 
 | 2589 |             */ | 
 | 2590 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2591 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 2592 |             if ((flags & SigmaValue) == 0) | 
 | 2593 |               geometry_info.sigma=1.0; | 
 | 2594 |             (void) SegmentImage(*image,(*image)->colorspace, | 
 | 2595 |               mogrify_info->verbose,geometry_info.rho,geometry_info.sigma); | 
 | 2596 |             InheritException(exception,&(*image)->exception); | 
 | 2597 |             break; | 
 | 2598 |           } | 
 | 2599 |         if (LocaleCompare("set",option+1) == 0) | 
 | 2600 |           { | 
 | 2601 |             char | 
 | 2602 |               *value; | 
 | 2603 |  | 
 | 2604 |             /* | 
 | 2605 |               Set image option. | 
 | 2606 |             */ | 
 | 2607 |             if (*option == '+') | 
 | 2608 |               { | 
 | 2609 |                 if (LocaleNCompare(argv[i+1],"registry:",9) == 0) | 
 | 2610 |                   (void) DeleteImageRegistry(argv[i+1]+9); | 
 | 2611 |                 else | 
 | 2612 |                   if (LocaleNCompare(argv[i+1],"option:",7) == 0) | 
 | 2613 |                     { | 
 | 2614 |                       (void) DeleteImageOption(mogrify_info,argv[i+1]+7); | 
 | 2615 |                       (void) DeleteImageArtifact(*image,argv[i+1]+7); | 
 | 2616 |                     } | 
 | 2617 |                   else | 
 | 2618 |                     (void) DeleteImageProperty(*image,argv[i+1]); | 
 | 2619 |                 break; | 
 | 2620 |               } | 
 | 2621 |             value=InterpretImageProperties(mogrify_info,*image,argv[i+2]); | 
 | 2622 |             if (value == (char *) NULL) | 
 | 2623 |               break; | 
 | 2624 |             if (LocaleNCompare(argv[i+1],"registry:",9) == 0) | 
 | 2625 |               (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, | 
 | 2626 |                 exception); | 
 | 2627 |             else | 
 | 2628 |               if (LocaleNCompare(argv[i+1],"option:",7) == 0) | 
 | 2629 |                 { | 
 | 2630 |                   (void) SetImageOption(image_info,argv[i+1]+7,value); | 
 | 2631 |                   (void) SetImageOption(mogrify_info,argv[i+1]+7,value); | 
 | 2632 |                   (void) SetImageArtifact(*image,argv[i+1]+7,value); | 
 | 2633 |                 } | 
 | 2634 |               else | 
 | 2635 |                 (void) SetImageProperty(*image,argv[i+1],value); | 
 | 2636 |             value=DestroyString(value); | 
 | 2637 |             break; | 
 | 2638 |           } | 
 | 2639 |         if (LocaleCompare("shade",option+1) == 0) | 
 | 2640 |           { | 
 | 2641 |             /* | 
 | 2642 |               Shade image. | 
 | 2643 |             */ | 
 | 2644 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2645 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 2646 |             if ((flags & SigmaValue) == 0) | 
 | 2647 |               geometry_info.sigma=1.0; | 
 | 2648 |             mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : | 
 | 2649 |               MagickFalse,geometry_info.rho,geometry_info.sigma,exception); | 
 | 2650 |             break; | 
 | 2651 |           } | 
 | 2652 |         if (LocaleCompare("shadow",option+1) == 0) | 
 | 2653 |           { | 
 | 2654 |             /* | 
 | 2655 |               Shadow image. | 
 | 2656 |             */ | 
 | 2657 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2658 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 2659 |             if ((flags & SigmaValue) == 0) | 
 | 2660 |               geometry_info.sigma=1.0; | 
 | 2661 |             if ((flags & XiValue) == 0) | 
 | 2662 |               geometry_info.xi=4.0; | 
 | 2663 |             if ((flags & PsiValue) == 0) | 
 | 2664 |               geometry_info.psi=4.0; | 
 | 2665 |             mogrify_image=ShadowImage(*image,geometry_info.rho, | 
 | 2666 |               geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) | 
 | 2667 |               ceil(geometry_info.psi-0.5),exception); | 
 | 2668 |             break; | 
 | 2669 |           } | 
 | 2670 |         if (LocaleCompare("sharpen",option+1) == 0) | 
 | 2671 |           { | 
 | 2672 |             /* | 
 | 2673 |               Sharpen image. | 
 | 2674 |             */ | 
 | 2675 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2676 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 2677 |             if ((flags & SigmaValue) == 0) | 
 | 2678 |               geometry_info.sigma=1.0; | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2679 |             mogrify_image=SharpenImage(*image,geometry_info.rho, | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2680 |               geometry_info.sigma,exception); | 
 | 2681 |             break; | 
 | 2682 |           } | 
 | 2683 |         if (LocaleCompare("shave",option+1) == 0) | 
 | 2684 |           { | 
 | 2685 |             /* | 
 | 2686 |               Shave the image edges. | 
 | 2687 |             */ | 
 | 2688 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2689 |             flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); | 
 | 2690 |             mogrify_image=ShaveImage(*image,&geometry,exception); | 
 | 2691 |             break; | 
 | 2692 |           } | 
 | 2693 |         if (LocaleCompare("shear",option+1) == 0) | 
 | 2694 |           { | 
 | 2695 |             /* | 
 | 2696 |               Shear image. | 
 | 2697 |             */ | 
 | 2698 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2699 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 2700 |             if ((flags & SigmaValue) == 0) | 
 | 2701 |               geometry_info.sigma=geometry_info.rho; | 
 | 2702 |             mogrify_image=ShearImage(*image,geometry_info.rho, | 
 | 2703 |               geometry_info.sigma,exception); | 
 | 2704 |             break; | 
 | 2705 |           } | 
 | 2706 |         if (LocaleCompare("sigmoidal-contrast",option+1) == 0) | 
 | 2707 |           { | 
 | 2708 |             /* | 
 | 2709 |               Sigmoidal non-linearity contrast control. | 
 | 2710 |             */ | 
 | 2711 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2712 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 2713 |             if ((flags & SigmaValue) == 0) | 
 | 2714 |               geometry_info.sigma=(double) QuantumRange/2.0; | 
 | 2715 |             if ((flags & PercentValue) != 0) | 
 | 2716 |               geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ | 
 | 2717 |                 100.0; | 
| cristy | 9ee6094 | 2011-07-06 14:54:38 +0000 | [diff] [blame] | 2718 |             (void) SigmoidalContrastImage(*image,(*option == '-') ? | 
 | 2719 |               MagickTrue : MagickFalse,geometry_info.rho,geometry_info.sigma); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2720 |             InheritException(exception,&(*image)->exception); | 
 | 2721 |             break; | 
 | 2722 |           } | 
 | 2723 |         if (LocaleCompare("sketch",option+1) == 0) | 
 | 2724 |           { | 
 | 2725 |             /* | 
 | 2726 |               Sketch image. | 
 | 2727 |             */ | 
 | 2728 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2729 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 2730 |             if ((flags & SigmaValue) == 0) | 
 | 2731 |               geometry_info.sigma=1.0; | 
 | 2732 |             mogrify_image=SketchImage(*image,geometry_info.rho, | 
 | 2733 |               geometry_info.sigma,geometry_info.xi,exception); | 
 | 2734 |             break; | 
 | 2735 |           } | 
 | 2736 |         if (LocaleCompare("solarize",option+1) == 0) | 
 | 2737 |           { | 
 | 2738 |             double | 
 | 2739 |               threshold; | 
 | 2740 |  | 
 | 2741 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2742 |             threshold=SiPrefixToDouble(argv[i+1],QuantumRange); | 
 | 2743 |             (void) SolarizeImage(*image,threshold); | 
 | 2744 |             InheritException(exception,&(*image)->exception); | 
 | 2745 |             break; | 
 | 2746 |           } | 
 | 2747 |         if (LocaleCompare("sparse-color",option+1) == 0) | 
 | 2748 |           { | 
 | 2749 |             SparseColorMethod | 
 | 2750 |               method; | 
 | 2751 |  | 
 | 2752 |             char | 
 | 2753 |               *arguments; | 
 | 2754 |  | 
 | 2755 |             /* | 
 | 2756 |               Sparse Color Interpolated Gradient | 
 | 2757 |             */ | 
 | 2758 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2759 |             method=(SparseColorMethod) ParseCommandOption( | 
 | 2760 |               MagickSparseColorOptions,MagickFalse,argv[i+1]); | 
 | 2761 |             arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); | 
 | 2762 |             InheritException(exception,&(*image)->exception); | 
 | 2763 |             if (arguments == (char *) NULL) | 
 | 2764 |               break; | 
| cristy | 3884f69 | 2011-07-08 18:00:18 +0000 | [diff] [blame] | 2765 |             mogrify_image=SparseColorOption(*image,method,arguments, | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2766 |               option[0] == '+' ? MagickTrue : MagickFalse,exception); | 
 | 2767 |             arguments=DestroyString(arguments); | 
 | 2768 |             break; | 
 | 2769 |           } | 
 | 2770 |         if (LocaleCompare("splice",option+1) == 0) | 
 | 2771 |           { | 
 | 2772 |             /* | 
 | 2773 |               Splice a solid color into the image. | 
 | 2774 |             */ | 
 | 2775 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2776 |             (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); | 
 | 2777 |             mogrify_image=SpliceImage(*image,&geometry,exception); | 
 | 2778 |             break; | 
 | 2779 |           } | 
 | 2780 |         if (LocaleCompare("spread",option+1) == 0) | 
 | 2781 |           { | 
 | 2782 |             /* | 
 | 2783 |               Spread an image. | 
 | 2784 |             */ | 
 | 2785 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2786 |             (void) ParseGeometry(argv[i+1],&geometry_info); | 
 | 2787 |             mogrify_image=SpreadImage(*image,geometry_info.rho,exception); | 
 | 2788 |             break; | 
 | 2789 |           } | 
 | 2790 |         if (LocaleCompare("statistic",option+1) == 0) | 
 | 2791 |           { | 
 | 2792 |             StatisticType | 
 | 2793 |               type; | 
 | 2794 |  | 
 | 2795 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2796 |             type=(StatisticType) ParseCommandOption(MagickStatisticOptions, | 
 | 2797 |               MagickFalse,argv[i+1]); | 
 | 2798 |             (void) ParseGeometry(argv[i+2],&geometry_info); | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2799 |             mogrify_image=StatisticImage(*image,type,(size_t) geometry_info.rho, | 
 | 2800 |               (size_t) geometry_info.sigma,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2801 |             break; | 
 | 2802 |           } | 
 | 2803 |         if (LocaleCompare("stretch",option+1) == 0) | 
 | 2804 |           { | 
 | 2805 |             if (*option == '+') | 
 | 2806 |               { | 
 | 2807 |                 draw_info->stretch=UndefinedStretch; | 
 | 2808 |                 break; | 
 | 2809 |               } | 
 | 2810 |             draw_info->stretch=(StretchType) ParseCommandOption( | 
 | 2811 |               MagickStretchOptions,MagickFalse,argv[i+1]); | 
 | 2812 |             break; | 
 | 2813 |           } | 
 | 2814 |         if (LocaleCompare("strip",option+1) == 0) | 
 | 2815 |           { | 
 | 2816 |             /* | 
 | 2817 |               Strip image of profiles and comments. | 
 | 2818 |             */ | 
 | 2819 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2820 |             (void) StripImage(*image); | 
 | 2821 |             InheritException(exception,&(*image)->exception); | 
 | 2822 |             break; | 
 | 2823 |           } | 
 | 2824 |         if (LocaleCompare("stroke",option+1) == 0) | 
 | 2825 |           { | 
 | 2826 |             ExceptionInfo | 
 | 2827 |               *sans; | 
 | 2828 |  | 
 | 2829 |             if (*option == '+') | 
 | 2830 |               { | 
 | 2831 |                 (void) QueryColorDatabase("none",&draw_info->stroke,exception); | 
 | 2832 |                 if (draw_info->stroke_pattern != (Image *) NULL) | 
 | 2833 |                   draw_info->stroke_pattern=DestroyImage( | 
 | 2834 |                     draw_info->stroke_pattern); | 
 | 2835 |                 break; | 
 | 2836 |               } | 
 | 2837 |             sans=AcquireExceptionInfo(); | 
 | 2838 |             status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); | 
 | 2839 |             sans=DestroyExceptionInfo(sans); | 
 | 2840 |             if (status == MagickFalse) | 
 | 2841 |               draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], | 
 | 2842 |                 exception); | 
 | 2843 |             break; | 
 | 2844 |           } | 
 | 2845 |         if (LocaleCompare("strokewidth",option+1) == 0) | 
 | 2846 |           { | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 2847 |             draw_info->stroke_width=InterpretLocaleValue(argv[i+1], | 
 | 2848 |               (char **) NULL); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2849 |             break; | 
 | 2850 |           } | 
 | 2851 |         if (LocaleCompare("style",option+1) == 0) | 
 | 2852 |           { | 
 | 2853 |             if (*option == '+') | 
 | 2854 |               { | 
 | 2855 |                 draw_info->style=UndefinedStyle; | 
 | 2856 |                 break; | 
 | 2857 |               } | 
 | 2858 |             draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, | 
 | 2859 |               MagickFalse,argv[i+1]); | 
 | 2860 |             break; | 
 | 2861 |           } | 
 | 2862 |         if (LocaleCompare("swirl",option+1) == 0) | 
 | 2863 |           { | 
 | 2864 |             /* | 
 | 2865 |               Swirl image. | 
 | 2866 |             */ | 
 | 2867 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2868 |             (void) ParseGeometry(argv[i+1],&geometry_info); | 
 | 2869 |             mogrify_image=SwirlImage(*image,geometry_info.rho,exception); | 
 | 2870 |             break; | 
 | 2871 |           } | 
 | 2872 |         break; | 
 | 2873 |       } | 
 | 2874 |       case 't': | 
 | 2875 |       { | 
 | 2876 |         if (LocaleCompare("threshold",option+1) == 0) | 
 | 2877 |           { | 
 | 2878 |             double | 
 | 2879 |               threshold; | 
 | 2880 |  | 
 | 2881 |             /* | 
 | 2882 |               Threshold image. | 
 | 2883 |             */ | 
 | 2884 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2885 |             if (*option == '+') | 
| anthony | 247a86d | 2011-05-03 13:18:18 +0000 | [diff] [blame] | 2886 |               threshold=(double) QuantumRange/2; | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2887 |             else | 
 | 2888 |               threshold=SiPrefixToDouble(argv[i+1],QuantumRange); | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 2889 |             (void) BilevelImage(*image,threshold); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2890 |             InheritException(exception,&(*image)->exception); | 
 | 2891 |             break; | 
 | 2892 |           } | 
 | 2893 |         if (LocaleCompare("thumbnail",option+1) == 0) | 
 | 2894 |           { | 
 | 2895 |             /* | 
 | 2896 |               Thumbnail image. | 
 | 2897 |             */ | 
 | 2898 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2899 |             (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); | 
 | 2900 |             mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, | 
 | 2901 |               exception); | 
 | 2902 |             break; | 
 | 2903 |           } | 
 | 2904 |         if (LocaleCompare("tile",option+1) == 0) | 
 | 2905 |           { | 
 | 2906 |             if (*option == '+') | 
 | 2907 |               { | 
 | 2908 |                 if (draw_info->fill_pattern != (Image *) NULL) | 
 | 2909 |                   draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); | 
 | 2910 |                 break; | 
 | 2911 |               } | 
 | 2912 |             draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], | 
 | 2913 |               exception); | 
 | 2914 |             break; | 
 | 2915 |           } | 
 | 2916 |         if (LocaleCompare("tint",option+1) == 0) | 
 | 2917 |           { | 
 | 2918 |             /* | 
 | 2919 |               Tint the image. | 
 | 2920 |             */ | 
 | 2921 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2922 |             mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); | 
 | 2923 |             break; | 
 | 2924 |           } | 
 | 2925 |         if (LocaleCompare("transform",option+1) == 0) | 
 | 2926 |           { | 
 | 2927 |             /* | 
 | 2928 |               Affine transform image. | 
 | 2929 |             */ | 
 | 2930 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2931 |             mogrify_image=AffineTransformImage(*image,&draw_info->affine, | 
 | 2932 |               exception); | 
 | 2933 |             break; | 
 | 2934 |           } | 
 | 2935 |         if (LocaleCompare("transparent",option+1) == 0) | 
 | 2936 |           { | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2937 |             PixelInfo | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2938 |               target; | 
 | 2939 |  | 
 | 2940 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2941 |             (void) QueryMagickColor(argv[i+1],&target,exception); | 
 | 2942 |             (void) TransparentPaintImage(*image,&target,(Quantum) | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2943 |               TransparentAlpha,*option == '-' ? MagickFalse : MagickTrue); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2944 |             InheritException(exception,&(*image)->exception); | 
 | 2945 |             break; | 
 | 2946 |           } | 
 | 2947 |         if (LocaleCompare("transpose",option+1) == 0) | 
 | 2948 |           { | 
 | 2949 |             /* | 
 | 2950 |               Transpose image scanlines. | 
 | 2951 |             */ | 
 | 2952 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2953 |             mogrify_image=TransposeImage(*image,exception); | 
 | 2954 |             break; | 
 | 2955 |           } | 
 | 2956 |         if (LocaleCompare("transverse",option+1) == 0) | 
 | 2957 |           { | 
 | 2958 |             /* | 
 | 2959 |               Transverse image scanlines. | 
 | 2960 |             */ | 
 | 2961 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2962 |             mogrify_image=TransverseImage(*image,exception); | 
 | 2963 |             break; | 
 | 2964 |           } | 
 | 2965 |         if (LocaleCompare("treedepth",option+1) == 0) | 
 | 2966 |           { | 
 | 2967 |             quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); | 
 | 2968 |             break; | 
 | 2969 |           } | 
 | 2970 |         if (LocaleCompare("trim",option+1) == 0) | 
 | 2971 |           { | 
 | 2972 |             /* | 
 | 2973 |               Trim image. | 
 | 2974 |             */ | 
 | 2975 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2976 |             mogrify_image=TrimImage(*image,exception); | 
 | 2977 |             break; | 
 | 2978 |           } | 
 | 2979 |         if (LocaleCompare("type",option+1) == 0) | 
 | 2980 |           { | 
 | 2981 |             ImageType | 
 | 2982 |               type; | 
 | 2983 |  | 
 | 2984 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 2985 |             if (*option == '+') | 
 | 2986 |               type=UndefinedType; | 
 | 2987 |             else | 
 | 2988 |               type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, | 
 | 2989 |                 argv[i+1]); | 
 | 2990 |             (*image)->type=UndefinedType; | 
 | 2991 |             (void) SetImageType(*image,type); | 
 | 2992 |             InheritException(exception,&(*image)->exception); | 
 | 2993 |             break; | 
 | 2994 |           } | 
 | 2995 |         break; | 
 | 2996 |       } | 
 | 2997 |       case 'u': | 
 | 2998 |       { | 
 | 2999 |         if (LocaleCompare("undercolor",option+1) == 0) | 
 | 3000 |           { | 
 | 3001 |             (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, | 
 | 3002 |               exception); | 
 | 3003 |             break; | 
 | 3004 |           } | 
 | 3005 |         if (LocaleCompare("unique",option+1) == 0) | 
 | 3006 |           { | 
 | 3007 |             if (*option == '+') | 
 | 3008 |               { | 
 | 3009 |                 (void) DeleteImageArtifact(*image,"identify:unique-colors"); | 
 | 3010 |                 break; | 
 | 3011 |               } | 
 | 3012 |             (void) SetImageArtifact(*image,"identify:unique-colors","true"); | 
 | 3013 |             (void) SetImageArtifact(*image,"verbose","true"); | 
 | 3014 |             break; | 
 | 3015 |           } | 
 | 3016 |         if (LocaleCompare("unique-colors",option+1) == 0) | 
 | 3017 |           { | 
 | 3018 |             /* | 
 | 3019 |               Unique image colors. | 
 | 3020 |             */ | 
 | 3021 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 3022 |             mogrify_image=UniqueImageColors(*image,exception); | 
 | 3023 |             break; | 
 | 3024 |           } | 
 | 3025 |         if (LocaleCompare("unsharp",option+1) == 0) | 
 | 3026 |           { | 
 | 3027 |             /* | 
 | 3028 |               Unsharp mask image. | 
 | 3029 |             */ | 
 | 3030 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 3031 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 3032 |             if ((flags & SigmaValue) == 0) | 
 | 3033 |               geometry_info.sigma=1.0; | 
 | 3034 |             if ((flags & XiValue) == 0) | 
 | 3035 |               geometry_info.xi=1.0; | 
 | 3036 |             if ((flags & PsiValue) == 0) | 
 | 3037 |               geometry_info.psi=0.05; | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3038 |             mogrify_image=UnsharpMaskImage(*image,geometry_info.rho, | 
 | 3039 |               geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3040 |             break; | 
 | 3041 |           } | 
 | 3042 |         break; | 
 | 3043 |       } | 
 | 3044 |       case 'v': | 
 | 3045 |       { | 
 | 3046 |         if (LocaleCompare("verbose",option+1) == 0) | 
 | 3047 |           { | 
 | 3048 |             (void) SetImageArtifact(*image,option+1, | 
 | 3049 |               *option == '+' ? "false" : "true"); | 
 | 3050 |             break; | 
 | 3051 |           } | 
 | 3052 |         if (LocaleCompare("vignette",option+1) == 0) | 
 | 3053 |           { | 
 | 3054 |             /* | 
 | 3055 |               Vignette image. | 
 | 3056 |             */ | 
 | 3057 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 3058 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 3059 |             if ((flags & SigmaValue) == 0) | 
 | 3060 |               geometry_info.sigma=1.0; | 
 | 3061 |             if ((flags & XiValue) == 0) | 
 | 3062 |               geometry_info.xi=0.1*(*image)->columns; | 
 | 3063 |             if ((flags & PsiValue) == 0) | 
 | 3064 |               geometry_info.psi=0.1*(*image)->rows; | 
 | 3065 |             mogrify_image=VignetteImage(*image,geometry_info.rho, | 
 | 3066 |               geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) | 
 | 3067 |               ceil(geometry_info.psi-0.5),exception); | 
 | 3068 |             break; | 
 | 3069 |           } | 
 | 3070 |         if (LocaleCompare("virtual-pixel",option+1) == 0) | 
 | 3071 |           { | 
 | 3072 |             if (*option == '+') | 
 | 3073 |               { | 
 | 3074 |                 (void) SetImageVirtualPixelMethod(*image, | 
 | 3075 |                   UndefinedVirtualPixelMethod); | 
 | 3076 |                 break; | 
 | 3077 |               } | 
 | 3078 |             (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) | 
 | 3079 |               ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, | 
 | 3080 |               argv[i+1])); | 
 | 3081 |             break; | 
 | 3082 |           } | 
 | 3083 |         break; | 
 | 3084 |       } | 
 | 3085 |       case 'w': | 
 | 3086 |       { | 
 | 3087 |         if (LocaleCompare("wave",option+1) == 0) | 
 | 3088 |           { | 
 | 3089 |             /* | 
 | 3090 |               Wave image. | 
 | 3091 |             */ | 
 | 3092 |             (void) SyncImageSettings(mogrify_info,*image); | 
 | 3093 |             flags=ParseGeometry(argv[i+1],&geometry_info); | 
 | 3094 |             if ((flags & SigmaValue) == 0) | 
 | 3095 |               geometry_info.sigma=1.0; | 
 | 3096 |             mogrify_image=WaveImage(*image,geometry_info.rho, | 
 | 3097 |               geometry_info.sigma,exception); | 
 | 3098 |             break; | 
 | 3099 |           } | 
 | 3100 |         if (LocaleCompare("weight",option+1) == 0) | 
 | 3101 |           { | 
 | 3102 |             draw_info->weight=StringToUnsignedLong(argv[i+1]); | 
 | 3103 |             if (LocaleCompare(argv[i+1],"all") == 0) | 
 | 3104 |               draw_info->weight=0; | 
 | 3105 |             if (LocaleCompare(argv[i+1],"bold") == 0) | 
 | 3106 |               draw_info->weight=700; | 
 | 3107 |             if (LocaleCompare(argv[i+1],"bolder") == 0) | 
 | 3108 |               if (draw_info->weight <= 800) | 
 | 3109 |                 draw_info->weight+=100; | 
 | 3110 |             if (LocaleCompare(argv[i+1],"lighter") == 0) | 
 | 3111 |               if (draw_info->weight >= 100) | 
 | 3112 |                 draw_info->weight-=100; | 
 | 3113 |             if (LocaleCompare(argv[i+1],"normal") == 0) | 
 | 3114 |               draw_info->weight=400; | 
 | 3115 |             break; | 
 | 3116 |           } | 
 | 3117 |         if (LocaleCompare("white-threshold",option+1) == 0) | 
 | 3118 |           { | 
 | 3119 |             /* | 
 | 3120 |               White threshold image. | 
 | 3121 |             */ | 
 | 3122 |             (void) SyncImageSettings(mogrify_info,*image); | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3123 |             (void) WhiteThresholdImage(*image,argv[i+1],exception); | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3124 |             InheritException(exception,&(*image)->exception); | 
 | 3125 |             break; | 
 | 3126 |           } | 
 | 3127 |         break; | 
 | 3128 |       } | 
 | 3129 |       default: | 
 | 3130 |         break; | 
 | 3131 |     } | 
 | 3132 |     /* | 
 | 3133 |        Replace current image with any image that was generated | 
 | 3134 |     */ | 
 | 3135 |     if (mogrify_image != (Image *) NULL) | 
 | 3136 |       ReplaceImageInListReturnLast(image,mogrify_image); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3137 |     i+=count; | 
 | 3138 |   } | 
 | 3139 |   if (region_image != (Image *) NULL) | 
 | 3140 |     { | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3141 |       /* | 
 | 3142 |         Composite transformed region onto image. | 
 | 3143 |       */ | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3144 |       (void) SyncImageSettings(mogrify_info,*image); | 
| anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3145 |       (void) CompositeImage(region_image,region_image->matte != | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 3146 |          MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, | 
 | 3147 |          region_geometry.x,region_geometry.y); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3148 |       InheritException(exception,®ion_image->exception); | 
 | 3149 |       *image=DestroyImage(*image); | 
 | 3150 |       *image=region_image; | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3151 |       region_image = (Image *) NULL; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3152 |     } | 
 | 3153 |   /* | 
 | 3154 |     Free resources. | 
 | 3155 |   */ | 
| anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3156 |   quantize_info=DestroyQuantizeInfo(quantize_info); | 
 | 3157 |   draw_info=DestroyDrawInfo(draw_info); | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3158 |   mogrify_info=DestroyImageInfo(mogrify_info); | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 3159 |   status=(MagickStatusType) ((*image)->exception.severity == | 
| cristy | 5f09d85 | 2011-05-29 01:39:29 +0000 | [diff] [blame] | 3160 |     UndefinedException ? 1 : 0); | 
| cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3161 |   return(status == 0 ? MagickFalse : MagickTrue); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3162 | } | 
 | 3163 |  | 
 | 3164 | /* | 
 | 3165 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 3166 | %                                                                             % | 
 | 3167 | %                                                                             % | 
 | 3168 | %                                                                             % | 
| cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3169 | +    M o g r i f y I m a g e C o m m a n d                                    % | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3170 | %                                                                             % | 
 | 3171 | %                                                                             % | 
 | 3172 | %                                                                             % | 
 | 3173 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 3174 | % | 
 | 3175 | %  MogrifyImageCommand() transforms an image or a sequence of images. These | 
 | 3176 | %  transforms include image scaling, image rotation, color reduction, and | 
 | 3177 | %  others. The transmogrified image overwrites the original image. | 
 | 3178 | % | 
 | 3179 | %  The format of the MogrifyImageCommand method is: | 
 | 3180 | % | 
 | 3181 | %      MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, | 
 | 3182 | %        const char **argv,char **metadata,ExceptionInfo *exception) | 
 | 3183 | % | 
 | 3184 | %  A description of each parameter follows: | 
 | 3185 | % | 
 | 3186 | %    o image_info: the image info. | 
 | 3187 | % | 
 | 3188 | %    o argc: the number of elements in the argument vector. | 
 | 3189 | % | 
 | 3190 | %    o argv: A text array containing the command line arguments. | 
 | 3191 | % | 
 | 3192 | %    o metadata: any metadata is returned here. | 
 | 3193 | % | 
 | 3194 | %    o exception: return any errors or warnings in this structure. | 
 | 3195 | % | 
 | 3196 | */ | 
 | 3197 |  | 
 | 3198 | static MagickBooleanType MogrifyUsage(void) | 
 | 3199 | { | 
 | 3200 |   static const char | 
 | 3201 |     *miscellaneous[]= | 
 | 3202 |     { | 
 | 3203 |       "-debug events        display copious debugging information", | 
 | 3204 |       "-help                print program options", | 
 | 3205 |       "-list type           print a list of supported option arguments", | 
 | 3206 |       "-log format          format of debugging information", | 
 | 3207 |       "-version             print version information", | 
 | 3208 |       (char *) NULL | 
 | 3209 |     }, | 
 | 3210 |     *operators[]= | 
 | 3211 |     { | 
 | 3212 |       "-adaptive-blur geometry", | 
 | 3213 |       "                     adaptively blur pixels; decrease effect near edges", | 
 | 3214 |       "-adaptive-resize geometry", | 
 | 3215 |       "                     adaptively resize image using 'mesh' interpolation", | 
 | 3216 |       "-adaptive-sharpen geometry", | 
 | 3217 |       "                     adaptively sharpen pixels; increase effect near edges", | 
 | 3218 |       "-alpha option        on, activate, off, deactivate, set, opaque, copy", | 
 | 3219 |       "                     transparent, extract, background, or shape", | 
 | 3220 |       "-annotate geometry text", | 
 | 3221 |       "                     annotate the image with text", | 
 | 3222 |       "-auto-gamma          automagically adjust gamma level of image", | 
 | 3223 |       "-auto-level          automagically adjust color levels of image", | 
 | 3224 |       "-auto-orient         automagically orient (rotate) image", | 
 | 3225 |       "-bench iterations    measure performance", | 
 | 3226 |       "-black-threshold value", | 
 | 3227 |       "                     force all pixels below the threshold into black", | 
 | 3228 |       "-blue-shift          simulate a scene at nighttime in the moonlight", | 
 | 3229 |       "-blur geometry       reduce image noise and reduce detail levels", | 
 | 3230 |       "-border geometry     surround image with a border of color", | 
 | 3231 |       "-bordercolor color   border color", | 
| cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3232 |       "-brightness-contrast geometry", | 
 | 3233 |       "                     improve brightness / contrast of the image", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3234 |       "-cdl filename        color correct with a color decision list", | 
 | 3235 |       "-charcoal radius     simulate a charcoal drawing", | 
 | 3236 |       "-chop geometry       remove pixels from the image interior", | 
| cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3237 |       "-clamp               restrict pixel range from 0 to the quantum depth", | 
| cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3238 |       "-clip                clip along the first path from the 8BIM profile", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3239 |       "-clip-mask filename  associate a clip mask with the image", | 
| cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3240 |       "-clip-path id        clip along a named path from the 8BIM profile", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3241 |       "-colorize value      colorize the image with the fill color", | 
| cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3242 |       "-color-matrix matrix apply color correction to the image", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3243 |       "-contrast            enhance or reduce the image contrast", | 
 | 3244 |       "-contrast-stretch geometry", | 
 | 3245 |       "                     improve contrast by `stretching' the intensity range", | 
 | 3246 |       "-convolve coefficients", | 
 | 3247 |       "                     apply a convolution kernel to the image", | 
 | 3248 |       "-cycle amount        cycle the image colormap", | 
 | 3249 |       "-decipher filename   convert cipher pixels to plain pixels", | 
 | 3250 |       "-deskew threshold    straighten an image", | 
 | 3251 |       "-despeckle           reduce the speckles within an image", | 
 | 3252 |       "-distort method args", | 
 | 3253 |       "                     distort images according to given method ad args", | 
 | 3254 |       "-draw string         annotate the image with a graphic primitive", | 
 | 3255 |       "-edge radius         apply a filter to detect edges in the image", | 
 | 3256 |       "-encipher filename   convert plain pixels to cipher pixels", | 
 | 3257 |       "-emboss radius       emboss an image", | 
 | 3258 |       "-enhance             apply a digital filter to enhance a noisy image", | 
 | 3259 |       "-equalize            perform histogram equalization to an image", | 
 | 3260 |       "-evaluate operator value", | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3261 |       "                     evaluate an arithmetic, relational, or logical expression", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3262 |       "-extent geometry     set the image size", | 
 | 3263 |       "-extract geometry    extract area from image", | 
 | 3264 |       "-fft                 implements the discrete Fourier transform (DFT)", | 
 | 3265 |       "-flip                flip image vertically", | 
 | 3266 |       "-floodfill geometry color", | 
 | 3267 |       "                     floodfill the image with color", | 
 | 3268 |       "-flop                flop image horizontally", | 
 | 3269 |       "-frame geometry      surround image with an ornamental border", | 
| cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3270 |       "-function name parameters", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3271 |       "                     apply function over image values", | 
 | 3272 |       "-gamma value         level of gamma correction", | 
 | 3273 |       "-gaussian-blur geometry", | 
 | 3274 |       "                     reduce image noise and reduce detail levels", | 
| cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3275 |       "-geometry geometry   preferred size or location of the image", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3276 |       "-identify            identify the format and characteristics of the image", | 
 | 3277 |       "-ift                 implements the inverse discrete Fourier transform (DFT)", | 
 | 3278 |       "-implode amount      implode image pixels about the center", | 
 | 3279 |       "-lat geometry        local adaptive thresholding", | 
 | 3280 |       "-layers method       optimize, merge,  or compare image layers", | 
 | 3281 |       "-level value         adjust the level of image contrast", | 
 | 3282 |       "-level-colors color,color", | 
| cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3283 |       "                     level image with the given colors", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3284 |       "-linear-stretch geometry", | 
 | 3285 |       "                     improve contrast by `stretching with saturation'", | 
 | 3286 |       "-liquid-rescale geometry", | 
 | 3287 |       "                     rescale image with seam-carving", | 
| cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3288 |       "-median geometry     apply a median filter to the image", | 
| glennrp | 30d2dc6 | 2011-06-25 03:17:16 +0000 | [diff] [blame] | 3289 |       "-mode geometry       make each pixel the 'predominant color' of the neighborhood", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3290 |       "-modulate value      vary the brightness, saturation, and hue", | 
 | 3291 |       "-monochrome          transform image to black and white", | 
| cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3292 |       "-morphology method kernel", | 
| anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3293 |       "                     apply a morphology method to the image", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3294 |       "-motion-blur geometry", | 
 | 3295 |       "                     simulate motion blur", | 
 | 3296 |       "-negate              replace every pixel with its complementary color ", | 
| cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3297 |       "-noise geometry      add or reduce noise in an image", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3298 |       "-normalize           transform image to span the full range of colors", | 
 | 3299 |       "-opaque color        change this color to the fill color", | 
 | 3300 |       "-ordered-dither NxN", | 
 | 3301 |       "                     add a noise pattern to the image with specific", | 
 | 3302 |       "                     amplitudes", | 
 | 3303 |       "-paint radius        simulate an oil painting", | 
 | 3304 |       "-polaroid angle      simulate a Polaroid picture", | 
 | 3305 |       "-posterize levels    reduce the image to a limited number of color levels", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3306 |       "-profile filename    add, delete, or apply an image profile", | 
 | 3307 |       "-quantize colorspace reduce colors in this colorspace", | 
 | 3308 |       "-radial-blur angle   radial blur the image", | 
 | 3309 |       "-raise value         lighten/darken image edges to create a 3-D effect", | 
 | 3310 |       "-random-threshold low,high", | 
 | 3311 |       "                     random threshold the image", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3312 |       "-region geometry     apply options to a portion of the image", | 
 | 3313 |       "-render              render vector graphics", | 
 | 3314 |       "-repage geometry     size and location of an image canvas", | 
 | 3315 |       "-resample geometry   change the resolution of an image", | 
 | 3316 |       "-resize geometry     resize the image", | 
 | 3317 |       "-roll geometry       roll an image vertically or horizontally", | 
 | 3318 |       "-rotate degrees      apply Paeth rotation to the image", | 
 | 3319 |       "-sample geometry     scale image with pixel sampling", | 
 | 3320 |       "-scale geometry      scale the image", | 
 | 3321 |       "-segment values      segment an image", | 
 | 3322 |       "-selective-blur geometry", | 
 | 3323 |       "                     selectively blur pixels within a contrast threshold", | 
 | 3324 |       "-sepia-tone threshold", | 
 | 3325 |       "                     simulate a sepia-toned photo", | 
 | 3326 |       "-set property value  set an image property", | 
 | 3327 |       "-shade degrees       shade the image using a distant light source", | 
 | 3328 |       "-shadow geometry     simulate an image shadow", | 
 | 3329 |       "-sharpen geometry    sharpen the image", | 
 | 3330 |       "-shave geometry      shave pixels from the image edges", | 
| cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3331 |       "-shear geometry      slide one edge of the image along the X or Y axis", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3332 |       "-sigmoidal-contrast geometry", | 
 | 3333 |       "                     increase the contrast without saturating highlights or shadows", | 
 | 3334 |       "-sketch geometry     simulate a pencil sketch", | 
 | 3335 |       "-solarize threshold  negate all pixels above the threshold level", | 
 | 3336 |       "-sparse-color method args", | 
 | 3337 |       "                     fill in a image based on a few color points", | 
 | 3338 |       "-splice geometry     splice the background color into the image", | 
 | 3339 |       "-spread radius       displace image pixels by a random amount", | 
| cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3340 |       "-statistic type radius", | 
 | 3341 |       "                     replace each pixel with corresponding statistic from the neighborhood", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3342 |       "-strip               strip image of all profiles and comments", | 
 | 3343 |       "-swirl degrees       swirl image pixels about the center", | 
 | 3344 |       "-threshold value     threshold the image", | 
 | 3345 |       "-thumbnail geometry  create a thumbnail of the image", | 
 | 3346 |       "-tile filename       tile image when filling a graphic primitive", | 
 | 3347 |       "-tint value          tint the image with the fill color", | 
 | 3348 |       "-transform           affine transform image", | 
 | 3349 |       "-transparent color   make this color transparent within the image", | 
 | 3350 |       "-transpose           flip image vertically and rotate 90 degrees", | 
 | 3351 |       "-transverse          flop image horizontally and rotate 270 degrees", | 
 | 3352 |       "-trim                trim image edges", | 
 | 3353 |       "-type type           image type", | 
 | 3354 |       "-unique-colors       discard all but one of any pixel color", | 
 | 3355 |       "-unsharp geometry    sharpen the image", | 
 | 3356 |       "-vignette geometry   soften the edges of the image in vignette style", | 
| cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3357 |       "-wave geometry       alter an image along a sine wave", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3358 |       "-white-threshold value", | 
 | 3359 |       "                     force all pixels above the threshold into white", | 
 | 3360 |       (char *) NULL | 
 | 3361 |     }, | 
 | 3362 |     *sequence_operators[]= | 
 | 3363 |     { | 
| cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3364 |       "-append              append an image sequence", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3365 |       "-clut                apply a color lookup table to the image", | 
 | 3366 |       "-coalesce            merge a sequence of images", | 
 | 3367 |       "-combine             combine a sequence of images", | 
 | 3368 |       "-composite           composite image", | 
 | 3369 |       "-crop geometry       cut out a rectangular region of the image", | 
 | 3370 |       "-deconstruct         break down an image sequence into constituent parts", | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3371 |       "-evaluate-sequence operator", | 
 | 3372 |       "                     evaluate an arithmetic, relational, or logical expression", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3373 |       "-flatten             flatten a sequence of images", | 
 | 3374 |       "-fx expression       apply mathematical expression to an image channel(s)", | 
 | 3375 |       "-hald-clut           apply a Hald color lookup table to the image", | 
 | 3376 |       "-morph value         morph an image sequence", | 
 | 3377 |       "-mosaic              create a mosaic from an image sequence", | 
| cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3378 |       "-print string        interpret string and print to console", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3379 |       "-process arguments   process the image with a custom image filter", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3380 |       "-separate            separate an image channel into a grayscale image", | 
| cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3381 |       "-smush geometry      smush an image sequence together", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3382 |       "-write filename      write images to this file", | 
 | 3383 |       (char *) NULL | 
 | 3384 |     }, | 
 | 3385 |     *settings[]= | 
 | 3386 |     { | 
 | 3387 |       "-adjoin              join images into a single multi-image file", | 
 | 3388 |       "-affine matrix       affine transform matrix", | 
 | 3389 |       "-alpha option        activate, deactivate, reset, or set the alpha channel", | 
 | 3390 |       "-antialias           remove pixel-aliasing", | 
 | 3391 |       "-authenticate password", | 
 | 3392 |       "                     decipher image with this password", | 
 | 3393 |       "-attenuate value     lessen (or intensify) when adding noise to an image", | 
 | 3394 |       "-background color    background color", | 
 | 3395 |       "-bias value          add bias when convolving an image", | 
 | 3396 |       "-black-point-compensation", | 
 | 3397 |       "                     use black point compensation", | 
 | 3398 |       "-blue-primary point  chromaticity blue primary point", | 
 | 3399 |       "-bordercolor color   border color", | 
 | 3400 |       "-caption string      assign a caption to an image", | 
 | 3401 |       "-channel type        apply option to select image channels", | 
 | 3402 |       "-colors value        preferred number of colors in the image", | 
 | 3403 |       "-colorspace type     alternate image colorspace", | 
 | 3404 |       "-comment string      annotate image with comment", | 
 | 3405 |       "-compose operator    set image composite operator", | 
 | 3406 |       "-compress type       type of pixel compression when writing the image", | 
 | 3407 |       "-define format:option", | 
 | 3408 |       "                     define one or more image format options", | 
 | 3409 |       "-delay value         display the next image after pausing", | 
 | 3410 |       "-density geometry    horizontal and vertical density of the image", | 
 | 3411 |       "-depth value         image depth", | 
| cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3412 |       "-direction type      render text right-to-left or left-to-right", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3413 |       "-display server      get image or font from this X server", | 
 | 3414 |       "-dispose method      layer disposal method", | 
 | 3415 |       "-dither method       apply error diffusion to image", | 
 | 3416 |       "-encoding type       text encoding type", | 
 | 3417 |       "-endian type         endianness (MSB or LSB) of the image", | 
 | 3418 |       "-family name         render text with this font family", | 
 | 3419 |       "-fill color          color to use when filling a graphic primitive", | 
 | 3420 |       "-filter type         use this filter when resizing an image", | 
 | 3421 |       "-font name           render text with this font", | 
 | 3422 |       "-format \"string\"     output formatted image characteristics", | 
 | 3423 |       "-fuzz distance       colors within this distance are considered equal", | 
 | 3424 |       "-gravity type        horizontal and vertical text placement", | 
 | 3425 |       "-green-primary point chromaticity green primary point", | 
 | 3426 |       "-intent type         type of rendering intent when managing the image color", | 
 | 3427 |       "-interlace type      type of image interlacing scheme", | 
| cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3428 |       "-interline-spacing value", | 
 | 3429 |       "                     set the space between two text lines", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3430 |       "-interpolate method  pixel color interpolation method", | 
 | 3431 |       "-interword-spacing value", | 
 | 3432 |       "                     set the space between two words", | 
 | 3433 |       "-kerning value       set the space between two letters", | 
 | 3434 |       "-label string        assign a label to an image", | 
 | 3435 |       "-limit type value    pixel cache resource limit", | 
 | 3436 |       "-loop iterations     add Netscape loop extension to your GIF animation", | 
 | 3437 |       "-mask filename       associate a mask with the image", | 
 | 3438 |       "-mattecolor color    frame color", | 
 | 3439 |       "-monitor             monitor progress", | 
 | 3440 |       "-orient type         image orientation", | 
 | 3441 |       "-page geometry       size and location of an image canvas (setting)", | 
 | 3442 |       "-ping                efficiently determine image attributes", | 
 | 3443 |       "-pointsize value     font point size", | 
| cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3444 |       "-precision value     maximum number of significant digits to print", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3445 |       "-preview type        image preview type", | 
 | 3446 |       "-quality value       JPEG/MIFF/PNG compression level", | 
 | 3447 |       "-quiet               suppress all warning messages", | 
 | 3448 |       "-red-primary point   chromaticity red primary point", | 
 | 3449 |       "-regard-warnings     pay attention to warning messages", | 
 | 3450 |       "-remap filename      transform image colors to match this set of colors", | 
 | 3451 |       "-respect-parentheses settings remain in effect until parenthesis boundary", | 
 | 3452 |       "-sampling-factor geometry", | 
 | 3453 |       "                     horizontal and vertical sampling factor", | 
 | 3454 |       "-scene value         image scene number", | 
 | 3455 |       "-seed value          seed a new sequence of pseudo-random numbers", | 
 | 3456 |       "-size geometry       width and height of image", | 
 | 3457 |       "-stretch type        render text with this font stretch", | 
 | 3458 |       "-stroke color        graphic primitive stroke color", | 
 | 3459 |       "-strokewidth value   graphic primitive stroke width", | 
 | 3460 |       "-style type          render text with this font style", | 
| cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3461 |       "-synchronize         synchronize image to storage device", | 
 | 3462 |       "-taint               declare the image as modified", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3463 |       "-texture filename    name of texture to tile onto the image background", | 
 | 3464 |       "-tile-offset geometry", | 
 | 3465 |       "                     tile offset", | 
 | 3466 |       "-treedepth value     color tree depth", | 
 | 3467 |       "-transparent-color color", | 
 | 3468 |       "                     transparent color", | 
 | 3469 |       "-undercolor color    annotation bounding box color", | 
 | 3470 |       "-units type          the units of image resolution", | 
 | 3471 |       "-verbose             print detailed information about the image", | 
 | 3472 |       "-view                FlashPix viewing transforms", | 
 | 3473 |       "-virtual-pixel method", | 
 | 3474 |       "                     virtual pixel access method", | 
 | 3475 |       "-weight type         render text with this font weight", | 
 | 3476 |       "-white-point point   chromaticity white point", | 
 | 3477 |       (char *) NULL | 
 | 3478 |     }, | 
 | 3479 |     *stack_operators[]= | 
 | 3480 |     { | 
| anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3481 |       "-delete indexes      delete the image from the image sequence", | 
 | 3482 |       "-duplicate count,indexes", | 
| cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3483 |       "                     duplicate an image one or more times", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3484 |       "-insert index        insert last image into the image sequence", | 
| anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3485 |       "-reverse             reverse image sequence", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3486 |       "-swap indexes        swap two images in the image sequence", | 
 | 3487 |       (char *) NULL | 
 | 3488 |     }; | 
 | 3489 |  | 
 | 3490 |   const char | 
 | 3491 |     **p; | 
 | 3492 |  | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3493 |   (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); | 
| cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3494 |   (void) printf("Copyright: %s\n",GetMagickCopyright()); | 
 | 3495 |   (void) printf("Features: %s\n\n",GetMagickFeatures()); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3496 |   (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", | 
 | 3497 |     GetClientName()); | 
 | 3498 |   (void) printf("\nImage Settings:\n"); | 
 | 3499 |   for (p=settings; *p != (char *) NULL; p++) | 
 | 3500 |     (void) printf("  %s\n",*p); | 
 | 3501 |   (void) printf("\nImage Operators:\n"); | 
 | 3502 |   for (p=operators; *p != (char *) NULL; p++) | 
 | 3503 |     (void) printf("  %s\n",*p); | 
 | 3504 |   (void) printf("\nImage Sequence Operators:\n"); | 
 | 3505 |   for (p=sequence_operators; *p != (char *) NULL; p++) | 
 | 3506 |     (void) printf("  %s\n",*p); | 
 | 3507 |   (void) printf("\nImage Stack Operators:\n"); | 
 | 3508 |   for (p=stack_operators; *p != (char *) NULL; p++) | 
 | 3509 |     (void) printf("  %s\n",*p); | 
 | 3510 |   (void) printf("\nMiscellaneous Options:\n"); | 
 | 3511 |   for (p=miscellaneous; *p != (char *) NULL; p++) | 
 | 3512 |     (void) printf("  %s\n",*p); | 
 | 3513 |   (void) printf( | 
 | 3514 |     "\nBy default, the image format of `file' is determined by its magic\n"); | 
 | 3515 |   (void) printf( | 
 | 3516 |     "number.  To specify a particular image format, precede the filename\n"); | 
 | 3517 |   (void) printf( | 
 | 3518 |     "with an image format name and a colon (i.e. ps:image) or specify the\n"); | 
 | 3519 |   (void) printf( | 
 | 3520 |     "image type as the filename suffix (i.e. image.ps).  Specify 'file' as\n"); | 
 | 3521 |   (void) printf("'-' for standard input or output.\n"); | 
 | 3522 |   return(MagickFalse); | 
 | 3523 | } | 
 | 3524 |  | 
 | 3525 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, | 
 | 3526 |   int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) | 
 | 3527 | { | 
 | 3528 | #define DestroyMogrify() \ | 
 | 3529 | { \ | 
 | 3530 |   if (format != (char *) NULL) \ | 
 | 3531 |     format=DestroyString(format); \ | 
 | 3532 |   if (path != (char *) NULL) \ | 
 | 3533 |     path=DestroyString(path); \ | 
 | 3534 |   DestroyImageStack(); \ | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3535 |   for (i=0; i < (ssize_t) argc; i++) \ | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3536 |     argv[i]=DestroyString(argv[i]); \ | 
 | 3537 |   argv=(char **) RelinquishMagickMemory(argv); \ | 
 | 3538 | } | 
 | 3539 | #define ThrowMogrifyException(asperity,tag,option) \ | 
 | 3540 | { \ | 
 | 3541 |   (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ | 
 | 3542 |     option); \ | 
 | 3543 |   DestroyMogrify(); \ | 
 | 3544 |   return(MagickFalse); \ | 
 | 3545 | } | 
 | 3546 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ | 
 | 3547 | { \ | 
 | 3548 |   (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ | 
 | 3549 |     "InvalidArgument","`%s': %s",argument,option); \ | 
 | 3550 |   DestroyMogrify(); \ | 
 | 3551 |   return(MagickFalse); \ | 
 | 3552 | } | 
 | 3553 |  | 
 | 3554 |   char | 
 | 3555 |     *format, | 
 | 3556 |     *option, | 
 | 3557 |     *path; | 
 | 3558 |  | 
 | 3559 |   Image | 
 | 3560 |     *image; | 
 | 3561 |  | 
 | 3562 |   ImageStack | 
 | 3563 |     image_stack[MaxImageStackDepth+1]; | 
 | 3564 |  | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3565 |   MagickBooleanType | 
 | 3566 |     global_colormap; | 
 | 3567 |  | 
 | 3568 |   MagickBooleanType | 
 | 3569 |     fire, | 
| cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3570 |     pend, | 
 | 3571 |     respect_parenthesis; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3572 |  | 
 | 3573 |   MagickStatusType | 
 | 3574 |     status; | 
 | 3575 |  | 
| cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3576 |   register ssize_t | 
 | 3577 |     i; | 
 | 3578 |  | 
 | 3579 |   ssize_t | 
 | 3580 |     j, | 
 | 3581 |     k; | 
 | 3582 |  | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3583 |   /* | 
 | 3584 |     Set defaults. | 
 | 3585 |   */ | 
 | 3586 |   assert(image_info != (ImageInfo *) NULL); | 
 | 3587 |   assert(image_info->signature == MagickSignature); | 
 | 3588 |   if (image_info->debug != MagickFalse) | 
 | 3589 |     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); | 
 | 3590 |   assert(exception != (ExceptionInfo *) NULL); | 
 | 3591 |   if (argc == 2) | 
 | 3592 |     { | 
 | 3593 |       option=argv[1]; | 
 | 3594 |       if ((LocaleCompare("version",option+1) == 0) || | 
 | 3595 |           (LocaleCompare("-version",option+1) == 0)) | 
 | 3596 |         { | 
| cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3597 |           (void) FormatLocaleFile(stdout,"Version: %s\n", | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3598 |             GetMagickVersion((size_t *) NULL)); | 
| cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 3599 |           (void) FormatLocaleFile(stdout,"Copyright: %s\n", | 
 | 3600 |             GetMagickCopyright()); | 
 | 3601 |           (void) FormatLocaleFile(stdout,"Features: %s\n\n", | 
 | 3602 |             GetMagickFeatures()); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3603 |           return(MagickFalse); | 
 | 3604 |         } | 
 | 3605 |     } | 
 | 3606 |   if (argc < 2) | 
| cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3607 |     return(MogrifyUsage()); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3608 |   format=(char *) NULL; | 
 | 3609 |   path=(char *) NULL; | 
 | 3610 |   global_colormap=MagickFalse; | 
 | 3611 |   k=0; | 
 | 3612 |   j=1; | 
 | 3613 |   NewImageStack(); | 
 | 3614 |   option=(char *) NULL; | 
 | 3615 |   pend=MagickFalse; | 
| cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3616 |   respect_parenthesis=MagickFalse; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3617 |   status=MagickTrue; | 
 | 3618 |   /* | 
 | 3619 |     Parse command line. | 
 | 3620 |   */ | 
 | 3621 |   ReadCommandlLine(argc,&argv); | 
 | 3622 |   status=ExpandFilenames(&argc,&argv); | 
 | 3623 |   if (status == MagickFalse) | 
 | 3624 |     ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", | 
 | 3625 |       GetExceptionMessage(errno)); | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3626 |   for (i=1; i < (ssize_t) argc; i++) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3627 |   { | 
 | 3628 |     option=argv[i]; | 
 | 3629 |     if (LocaleCompare(option,"(") == 0) | 
 | 3630 |       { | 
 | 3631 |         FireImageStack(MagickFalse,MagickTrue,pend); | 
 | 3632 |         if (k == MaxImageStackDepth) | 
 | 3633 |           ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", | 
 | 3634 |             option); | 
 | 3635 |         PushImageStack(); | 
 | 3636 |         continue; | 
 | 3637 |       } | 
 | 3638 |     if (LocaleCompare(option,")") == 0) | 
 | 3639 |       { | 
 | 3640 |         FireImageStack(MagickFalse,MagickTrue,MagickTrue); | 
 | 3641 |         if (k == 0) | 
 | 3642 |           ThrowMogrifyException(OptionError,"UnableToParseExpression",option); | 
 | 3643 |         PopImageStack(); | 
 | 3644 |         continue; | 
 | 3645 |       } | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3646 |     if (IsCommandOption(option) == MagickFalse) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3647 |       { | 
 | 3648 |         char | 
 | 3649 |           backup_filename[MaxTextExtent], | 
 | 3650 |           *filename; | 
 | 3651 |  | 
 | 3652 |         Image | 
 | 3653 |           *images; | 
 | 3654 |  | 
 | 3655 |         /* | 
 | 3656 |           Option is a file name: begin by reading image from specified file. | 
 | 3657 |         */ | 
 | 3658 |         FireImageStack(MagickFalse,MagickFalse,pend); | 
 | 3659 |         filename=argv[i]; | 
| cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3660 |         if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3661 |           filename=argv[++i]; | 
 | 3662 |         (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); | 
 | 3663 |         images=ReadImages(image_info,exception); | 
 | 3664 |         status&=(images != (Image *) NULL) && | 
 | 3665 |           (exception->severity < ErrorException); | 
 | 3666 |         if (images == (Image *) NULL) | 
 | 3667 |           continue; | 
| cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3668 |         if (format != (char *) NULL) | 
 | 3669 |           (void) CopyMagickString(images->filename,images->magick_filename, | 
 | 3670 |             MaxTextExtent); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3671 |         if (path != (char *) NULL) | 
 | 3672 |           { | 
 | 3673 |             GetPathComponent(option,TailPath,filename); | 
| cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 3674 |             (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3675 |               path,*DirectorySeparator,filename); | 
 | 3676 |           } | 
 | 3677 |         if (format != (char *) NULL) | 
| cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3678 |           AppendImageFormat(format,images->filename); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3679 |         AppendImageStack(images); | 
 | 3680 |         FinalizeImageSettings(image_info,image,MagickFalse); | 
 | 3681 |         if (global_colormap != MagickFalse) | 
 | 3682 |           { | 
 | 3683 |             QuantizeInfo | 
 | 3684 |               *quantize_info; | 
 | 3685 |  | 
 | 3686 |             quantize_info=AcquireQuantizeInfo(image_info); | 
 | 3687 |             (void) RemapImages(quantize_info,images,(Image *) NULL); | 
 | 3688 |             quantize_info=DestroyQuantizeInfo(quantize_info); | 
 | 3689 |           } | 
 | 3690 |         *backup_filename='\0'; | 
 | 3691 |         if ((LocaleCompare(image->filename,"-") != 0) && | 
 | 3692 |             (IsPathWritable(image->filename) != MagickFalse)) | 
 | 3693 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3694 |             register ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3695 |               i; | 
 | 3696 |  | 
 | 3697 |             /* | 
 | 3698 |               Rename image file as backup. | 
 | 3699 |             */ | 
 | 3700 |             (void) CopyMagickString(backup_filename,image->filename, | 
 | 3701 |               MaxTextExtent); | 
 | 3702 |             for (i=0; i < 6; i++) | 
 | 3703 |             { | 
 | 3704 |               (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); | 
 | 3705 |               if (IsPathAccessible(backup_filename) == MagickFalse) | 
 | 3706 |                 break; | 
 | 3707 |             } | 
 | 3708 |             if ((IsPathAccessible(backup_filename) != MagickFalse) || | 
 | 3709 |                 (rename(image->filename,backup_filename) != 0)) | 
 | 3710 |               *backup_filename='\0'; | 
 | 3711 |           } | 
 | 3712 |         /* | 
 | 3713 |           Write transmogrified image to disk. | 
 | 3714 |         */ | 
 | 3715 |         image_info->synchronize=MagickTrue; | 
 | 3716 |         status&=WriteImages(image_info,image,image->filename,exception); | 
 | 3717 |         if ((status == MagickFalse) && (*backup_filename != '\0')) | 
 | 3718 |           (void) remove(backup_filename); | 
 | 3719 |         RemoveAllImageStack(); | 
 | 3720 |         continue; | 
 | 3721 |       } | 
 | 3722 |     pend=image != (Image *) NULL ? MagickTrue : MagickFalse; | 
 | 3723 |     switch (*(option+1)) | 
 | 3724 |     { | 
 | 3725 |       case 'a': | 
 | 3726 |       { | 
 | 3727 |         if (LocaleCompare("adaptive-blur",option+1) == 0) | 
 | 3728 |           { | 
 | 3729 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3730 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3731 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3732 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3733 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3734 |             break; | 
 | 3735 |           } | 
 | 3736 |         if (LocaleCompare("adaptive-resize",option+1) == 0) | 
 | 3737 |           { | 
 | 3738 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3739 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3740 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3741 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3742 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3743 |             break; | 
 | 3744 |           } | 
 | 3745 |         if (LocaleCompare("adaptive-sharpen",option+1) == 0) | 
 | 3746 |           { | 
 | 3747 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3748 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3749 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3750 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3751 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3752 |             break; | 
 | 3753 |           } | 
 | 3754 |         if (LocaleCompare("affine",option+1) == 0) | 
 | 3755 |           { | 
 | 3756 |             if (*option == '+') | 
 | 3757 |               break; | 
 | 3758 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3759 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3760 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3761 |             break; | 
 | 3762 |           } | 
 | 3763 |         if (LocaleCompare("alpha",option+1) == 0) | 
 | 3764 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3765 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3766 |               type; | 
 | 3767 |  | 
 | 3768 |             if (*option == '+') | 
 | 3769 |               break; | 
 | 3770 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3771 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3772 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3773 |             type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3774 |             if (type < 0) | 
 | 3775 |               ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", | 
 | 3776 |                 argv[i]); | 
 | 3777 |             break; | 
 | 3778 |           } | 
 | 3779 |         if (LocaleCompare("annotate",option+1) == 0) | 
 | 3780 |           { | 
 | 3781 |             if (*option == '+') | 
 | 3782 |               break; | 
 | 3783 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3784 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3785 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3786 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3787 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3788 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3789 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3790 |             i++; | 
 | 3791 |             break; | 
 | 3792 |           } | 
 | 3793 |         if (LocaleCompare("antialias",option+1) == 0) | 
 | 3794 |           break; | 
 | 3795 |         if (LocaleCompare("append",option+1) == 0) | 
 | 3796 |           break; | 
 | 3797 |         if (LocaleCompare("attenuate",option+1) == 0) | 
 | 3798 |           { | 
 | 3799 |             if (*option == '+') | 
 | 3800 |               break; | 
 | 3801 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3802 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3803 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3804 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3805 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3806 |             break; | 
 | 3807 |           } | 
 | 3808 |         if (LocaleCompare("authenticate",option+1) == 0) | 
 | 3809 |           { | 
 | 3810 |             if (*option == '+') | 
 | 3811 |               break; | 
 | 3812 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3813 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3814 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3815 |             break; | 
 | 3816 |           } | 
 | 3817 |         if (LocaleCompare("auto-gamma",option+1) == 0) | 
 | 3818 |           break; | 
 | 3819 |         if (LocaleCompare("auto-level",option+1) == 0) | 
 | 3820 |           break; | 
 | 3821 |         if (LocaleCompare("auto-orient",option+1) == 0) | 
 | 3822 |           break; | 
 | 3823 |         if (LocaleCompare("average",option+1) == 0) | 
 | 3824 |           break; | 
 | 3825 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 3826 |       } | 
 | 3827 |       case 'b': | 
 | 3828 |       { | 
 | 3829 |         if (LocaleCompare("background",option+1) == 0) | 
 | 3830 |           { | 
 | 3831 |             if (*option == '+') | 
 | 3832 |               break; | 
 | 3833 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3834 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3835 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3836 |             break; | 
 | 3837 |           } | 
 | 3838 |         if (LocaleCompare("bias",option+1) == 0) | 
 | 3839 |           { | 
 | 3840 |             if (*option == '+') | 
 | 3841 |               break; | 
 | 3842 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3843 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3844 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3845 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3846 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3847 |             break; | 
 | 3848 |           } | 
 | 3849 |         if (LocaleCompare("black-point-compensation",option+1) == 0) | 
 | 3850 |           break; | 
 | 3851 |         if (LocaleCompare("black-threshold",option+1) == 0) | 
 | 3852 |           { | 
 | 3853 |             if (*option == '+') | 
 | 3854 |               break; | 
 | 3855 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3856 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3857 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3858 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3859 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3860 |             break; | 
 | 3861 |           } | 
 | 3862 |         if (LocaleCompare("blue-primary",option+1) == 0) | 
 | 3863 |           { | 
 | 3864 |             if (*option == '+') | 
 | 3865 |               break; | 
 | 3866 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3867 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3868 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3869 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3870 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3871 |             break; | 
 | 3872 |           } | 
 | 3873 |         if (LocaleCompare("blue-shift",option+1) == 0) | 
 | 3874 |           { | 
 | 3875 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3876 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3877 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3878 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3879 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3880 |             break; | 
 | 3881 |           } | 
 | 3882 |         if (LocaleCompare("blur",option+1) == 0) | 
 | 3883 |           { | 
 | 3884 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3885 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3886 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3887 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3888 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3889 |             break; | 
 | 3890 |           } | 
 | 3891 |         if (LocaleCompare("border",option+1) == 0) | 
 | 3892 |           { | 
 | 3893 |             if (*option == '+') | 
 | 3894 |               break; | 
 | 3895 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3896 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3897 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3898 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3899 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3900 |             break; | 
 | 3901 |           } | 
 | 3902 |         if (LocaleCompare("bordercolor",option+1) == 0) | 
 | 3903 |           { | 
 | 3904 |             if (*option == '+') | 
 | 3905 |               break; | 
 | 3906 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3907 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3908 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3909 |             break; | 
 | 3910 |           } | 
 | 3911 |         if (LocaleCompare("box",option+1) == 0) | 
 | 3912 |           { | 
 | 3913 |             if (*option == '+') | 
 | 3914 |               break; | 
 | 3915 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3916 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3917 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3918 |             break; | 
 | 3919 |           } | 
| cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3920 |         if (LocaleCompare("brightness-contrast",option+1) == 0) | 
 | 3921 |           { | 
 | 3922 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3923 |             if (i == (ssize_t) argc) | 
| cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3924 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3925 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3926 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3927 |             break; | 
 | 3928 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3929 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 3930 |       } | 
 | 3931 |       case 'c': | 
 | 3932 |       { | 
 | 3933 |         if (LocaleCompare("cache",option+1) == 0) | 
 | 3934 |           { | 
 | 3935 |             if (*option == '+') | 
 | 3936 |               break; | 
 | 3937 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3938 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3939 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3940 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3941 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3942 |             break; | 
 | 3943 |           } | 
 | 3944 |         if (LocaleCompare("caption",option+1) == 0) | 
 | 3945 |           { | 
 | 3946 |             if (*option == '+') | 
 | 3947 |               break; | 
 | 3948 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3949 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3950 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3951 |             break; | 
 | 3952 |           } | 
 | 3953 |         if (LocaleCompare("channel",option+1) == 0) | 
 | 3954 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3955 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3956 |               channel; | 
 | 3957 |  | 
 | 3958 |             if (*option == '+') | 
 | 3959 |               break; | 
 | 3960 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3961 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3962 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3963 |             channel=ParseChannelOption(argv[i]); | 
 | 3964 |             if (channel < 0) | 
 | 3965 |               ThrowMogrifyException(OptionError,"UnrecognizedChannelType", | 
 | 3966 |                 argv[i]); | 
 | 3967 |             break; | 
 | 3968 |           } | 
 | 3969 |         if (LocaleCompare("cdl",option+1) == 0) | 
 | 3970 |           { | 
 | 3971 |             if (*option == '+') | 
 | 3972 |               break; | 
 | 3973 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3974 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3975 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3976 |             break; | 
 | 3977 |           } | 
 | 3978 |         if (LocaleCompare("charcoal",option+1) == 0) | 
 | 3979 |           { | 
 | 3980 |             if (*option == '+') | 
 | 3981 |               break; | 
 | 3982 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3983 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3984 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3985 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3986 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3987 |             break; | 
 | 3988 |           } | 
 | 3989 |         if (LocaleCompare("chop",option+1) == 0) | 
 | 3990 |           { | 
 | 3991 |             if (*option == '+') | 
 | 3992 |               break; | 
 | 3993 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3994 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3995 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 3996 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 3997 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 3998 |             break; | 
 | 3999 |           } | 
| cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4000 |         if (LocaleCompare("clamp",option+1) == 0) | 
 | 4001 |           break; | 
 | 4002 |         if (LocaleCompare("clip",option+1) == 0) | 
 | 4003 |           break; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4004 |         if (LocaleCompare("clip-mask",option+1) == 0) | 
 | 4005 |           { | 
 | 4006 |             if (*option == '+') | 
 | 4007 |               break; | 
 | 4008 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4009 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4010 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4011 |             break; | 
 | 4012 |           } | 
 | 4013 |         if (LocaleCompare("clut",option+1) == 0) | 
 | 4014 |           break; | 
 | 4015 |         if (LocaleCompare("coalesce",option+1) == 0) | 
 | 4016 |           break; | 
 | 4017 |         if (LocaleCompare("colorize",option+1) == 0) | 
 | 4018 |           { | 
 | 4019 |             if (*option == '+') | 
 | 4020 |               break; | 
 | 4021 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4022 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4023 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4024 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4025 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4026 |             break; | 
 | 4027 |           } | 
| cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4028 |         if (LocaleCompare("color-matrix",option+1) == 0) | 
 | 4029 |           { | 
| cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4030 |             KernelInfo | 
 | 4031 |               *kernel_info; | 
 | 4032 |  | 
| cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4033 |             if (*option == '+') | 
 | 4034 |               break; | 
 | 4035 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4036 |             if (i == (ssize_t) (argc-1)) | 
| cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4037 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4038 |             kernel_info=AcquireKernelInfo(argv[i]); | 
 | 4039 |             if (kernel_info == (KernelInfo *) NULL) | 
| cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4040 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
| cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4041 |             kernel_info=DestroyKernelInfo(kernel_info); | 
| cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4042 |             break; | 
 | 4043 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4044 |         if (LocaleCompare("colors",option+1) == 0) | 
 | 4045 |           { | 
 | 4046 |             if (*option == '+') | 
 | 4047 |               break; | 
 | 4048 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4049 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4050 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4051 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4052 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4053 |             break; | 
 | 4054 |           } | 
 | 4055 |         if (LocaleCompare("colorspace",option+1) == 0) | 
 | 4056 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4057 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4058 |               colorspace; | 
 | 4059 |  | 
 | 4060 |             if (*option == '+') | 
 | 4061 |               break; | 
 | 4062 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4063 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4064 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4065 |             colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4066 |               argv[i]); | 
 | 4067 |             if (colorspace < 0) | 
 | 4068 |               ThrowMogrifyException(OptionError,"UnrecognizedColorspace", | 
 | 4069 |                 argv[i]); | 
 | 4070 |             break; | 
 | 4071 |           } | 
 | 4072 |         if (LocaleCompare("combine",option+1) == 0) | 
 | 4073 |           break; | 
 | 4074 |         if (LocaleCompare("comment",option+1) == 0) | 
 | 4075 |           { | 
 | 4076 |             if (*option == '+') | 
 | 4077 |               break; | 
 | 4078 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4079 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4080 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4081 |             break; | 
 | 4082 |           } | 
 | 4083 |         if (LocaleCompare("composite",option+1) == 0) | 
 | 4084 |           break; | 
 | 4085 |         if (LocaleCompare("compress",option+1) == 0) | 
 | 4086 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4087 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4088 |               compress; | 
 | 4089 |  | 
 | 4090 |             if (*option == '+') | 
 | 4091 |               break; | 
 | 4092 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4093 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4094 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4095 |             compress=ParseCommandOption(MagickCompressOptions,MagickFalse, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4096 |               argv[i]); | 
 | 4097 |             if (compress < 0) | 
 | 4098 |               ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", | 
 | 4099 |                 argv[i]); | 
 | 4100 |             break; | 
 | 4101 |           } | 
| cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4102 |         if (LocaleCompare("concurrent",option+1) == 0) | 
 | 4103 |           break; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4104 |         if (LocaleCompare("contrast",option+1) == 0) | 
 | 4105 |           break; | 
 | 4106 |         if (LocaleCompare("contrast-stretch",option+1) == 0) | 
 | 4107 |           { | 
 | 4108 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4109 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4110 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4111 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4112 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4113 |             break; | 
 | 4114 |           } | 
 | 4115 |         if (LocaleCompare("convolve",option+1) == 0) | 
 | 4116 |           { | 
| cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4117 |             KernelInfo | 
 | 4118 |               *kernel_info; | 
 | 4119 |  | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4120 |             if (*option == '+') | 
 | 4121 |               break; | 
 | 4122 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4123 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4124 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4125 |             kernel_info=AcquireKernelInfo(argv[i]); | 
 | 4126 |             if (kernel_info == (KernelInfo *) NULL) | 
| cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4127 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
| cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4128 |             kernel_info=DestroyKernelInfo(kernel_info); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4129 |             break; | 
 | 4130 |           } | 
 | 4131 |         if (LocaleCompare("crop",option+1) == 0) | 
 | 4132 |           { | 
 | 4133 |             if (*option == '+') | 
 | 4134 |               break; | 
 | 4135 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4136 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4137 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4138 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4139 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4140 |             break; | 
 | 4141 |           } | 
 | 4142 |         if (LocaleCompare("cycle",option+1) == 0) | 
 | 4143 |           { | 
 | 4144 |             if (*option == '+') | 
 | 4145 |               break; | 
 | 4146 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4147 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4148 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4149 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4150 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4151 |             break; | 
 | 4152 |           } | 
 | 4153 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 4154 |       } | 
 | 4155 |       case 'd': | 
 | 4156 |       { | 
 | 4157 |         if (LocaleCompare("decipher",option+1) == 0) | 
 | 4158 |           { | 
 | 4159 |             if (*option == '+') | 
 | 4160 |               break; | 
 | 4161 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4162 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4163 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4164 |             break; | 
 | 4165 |           } | 
 | 4166 |         if (LocaleCompare("deconstruct",option+1) == 0) | 
 | 4167 |           break; | 
 | 4168 |         if (LocaleCompare("debug",option+1) == 0) | 
 | 4169 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4170 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4171 |               event; | 
 | 4172 |  | 
 | 4173 |             if (*option == '+') | 
 | 4174 |               break; | 
 | 4175 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4176 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4177 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4178 |             event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4179 |             if (event < 0) | 
 | 4180 |               ThrowMogrifyException(OptionError,"UnrecognizedEventType", | 
 | 4181 |                 argv[i]); | 
 | 4182 |             (void) SetLogEventMask(argv[i]); | 
 | 4183 |             break; | 
 | 4184 |           } | 
 | 4185 |         if (LocaleCompare("define",option+1) == 0) | 
 | 4186 |           { | 
 | 4187 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4188 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4189 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4190 |             if (*option == '+') | 
 | 4191 |               { | 
 | 4192 |                 const char | 
 | 4193 |                   *define; | 
 | 4194 |  | 
 | 4195 |                 define=GetImageOption(image_info,argv[i]); | 
 | 4196 |                 if (define == (const char *) NULL) | 
 | 4197 |                   ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); | 
 | 4198 |                 break; | 
 | 4199 |               } | 
 | 4200 |             break; | 
 | 4201 |           } | 
 | 4202 |         if (LocaleCompare("delay",option+1) == 0) | 
 | 4203 |           { | 
 | 4204 |             if (*option == '+') | 
 | 4205 |               break; | 
 | 4206 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4207 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4208 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4209 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4210 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4211 |             break; | 
 | 4212 |           } | 
| cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4213 |         if (LocaleCompare("delete",option+1) == 0) | 
 | 4214 |           { | 
 | 4215 |             if (*option == '+') | 
 | 4216 |               break; | 
 | 4217 |             i++; | 
 | 4218 |             if (i == (ssize_t) (argc-1)) | 
 | 4219 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4220 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4221 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4222 |             break; | 
 | 4223 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4224 |         if (LocaleCompare("density",option+1) == 0) | 
 | 4225 |           { | 
 | 4226 |             if (*option == '+') | 
 | 4227 |               break; | 
 | 4228 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4229 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4230 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4231 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4232 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4233 |             break; | 
 | 4234 |           } | 
 | 4235 |         if (LocaleCompare("depth",option+1) == 0) | 
 | 4236 |           { | 
 | 4237 |             if (*option == '+') | 
 | 4238 |               break; | 
 | 4239 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4240 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4241 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4242 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4243 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4244 |             break; | 
 | 4245 |           } | 
 | 4246 |         if (LocaleCompare("deskew",option+1) == 0) | 
 | 4247 |           { | 
 | 4248 |             if (*option == '+') | 
 | 4249 |               break; | 
 | 4250 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4251 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4252 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4253 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4254 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4255 |             break; | 
 | 4256 |           } | 
 | 4257 |         if (LocaleCompare("despeckle",option+1) == 0) | 
 | 4258 |           break; | 
 | 4259 |         if (LocaleCompare("dft",option+1) == 0) | 
 | 4260 |           break; | 
| cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4261 |         if (LocaleCompare("direction",option+1) == 0) | 
 | 4262 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4263 |             ssize_t | 
| cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4264 |               direction; | 
 | 4265 |  | 
 | 4266 |             if (*option == '+') | 
 | 4267 |               break; | 
 | 4268 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4269 |             if (i == (ssize_t) argc) | 
| cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4270 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4271 |             direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, | 
| cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4272 |               argv[i]); | 
 | 4273 |             if (direction < 0) | 
 | 4274 |               ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", | 
 | 4275 |                 argv[i]); | 
 | 4276 |             break; | 
 | 4277 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4278 |         if (LocaleCompare("display",option+1) == 0) | 
 | 4279 |           { | 
 | 4280 |             if (*option == '+') | 
 | 4281 |               break; | 
 | 4282 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4283 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4284 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4285 |             break; | 
 | 4286 |           } | 
 | 4287 |         if (LocaleCompare("dispose",option+1) == 0) | 
 | 4288 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4289 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4290 |               dispose; | 
 | 4291 |  | 
 | 4292 |             if (*option == '+') | 
 | 4293 |               break; | 
 | 4294 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4295 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4296 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4297 |             dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4298 |             if (dispose < 0) | 
 | 4299 |               ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", | 
 | 4300 |                 argv[i]); | 
 | 4301 |             break; | 
 | 4302 |           } | 
 | 4303 |         if (LocaleCompare("distort",option+1) == 0) | 
 | 4304 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4305 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4306 |               op; | 
 | 4307 |  | 
 | 4308 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4309 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4310 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4311 |             op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4312 |             if (op < 0) | 
 | 4313 |               ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", | 
 | 4314 |                 argv[i]); | 
 | 4315 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4316 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4317 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4318 |             break; | 
 | 4319 |           } | 
 | 4320 |         if (LocaleCompare("dither",option+1) == 0) | 
 | 4321 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4322 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4323 |               method; | 
 | 4324 |  | 
 | 4325 |             if (*option == '+') | 
 | 4326 |               break; | 
 | 4327 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4328 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4329 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4330 |             method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4331 |             if (method < 0) | 
 | 4332 |               ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", | 
 | 4333 |                 argv[i]); | 
 | 4334 |             break; | 
 | 4335 |           } | 
 | 4336 |         if (LocaleCompare("draw",option+1) == 0) | 
 | 4337 |           { | 
 | 4338 |             if (*option == '+') | 
 | 4339 |               break; | 
 | 4340 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4341 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4342 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4343 |             break; | 
 | 4344 |           } | 
| cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4345 |         if (LocaleCompare("duplicate",option+1) == 0) | 
 | 4346 |           { | 
 | 4347 |             if (*option == '+') | 
 | 4348 |               break; | 
 | 4349 |             i++; | 
 | 4350 |             if (i == (ssize_t) (argc-1)) | 
 | 4351 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4352 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4353 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4354 |             break; | 
 | 4355 |           } | 
| cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4356 |         if (LocaleCompare("duration",option+1) == 0) | 
 | 4357 |           { | 
 | 4358 |             if (*option == '+') | 
 | 4359 |               break; | 
 | 4360 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4361 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4362 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4363 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4364 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4365 |             break; | 
 | 4366 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4367 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 4368 |       } | 
 | 4369 |       case 'e': | 
 | 4370 |       { | 
 | 4371 |         if (LocaleCompare("edge",option+1) == 0) | 
 | 4372 |           { | 
 | 4373 |             if (*option == '+') | 
 | 4374 |               break; | 
 | 4375 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4376 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4377 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4378 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4379 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4380 |             break; | 
 | 4381 |           } | 
 | 4382 |         if (LocaleCompare("emboss",option+1) == 0) | 
 | 4383 |           { | 
 | 4384 |             if (*option == '+') | 
 | 4385 |               break; | 
 | 4386 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4387 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4388 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4389 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4390 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4391 |             break; | 
 | 4392 |           } | 
 | 4393 |         if (LocaleCompare("encipher",option+1) == 0) | 
 | 4394 |           { | 
 | 4395 |             if (*option == '+') | 
 | 4396 |               break; | 
 | 4397 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4398 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4399 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4400 |             break; | 
 | 4401 |           } | 
 | 4402 |         if (LocaleCompare("encoding",option+1) == 0) | 
 | 4403 |           { | 
 | 4404 |             if (*option == '+') | 
 | 4405 |               break; | 
 | 4406 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4407 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4408 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4409 |             break; | 
 | 4410 |           } | 
 | 4411 |         if (LocaleCompare("endian",option+1) == 0) | 
 | 4412 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4413 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4414 |               endian; | 
 | 4415 |  | 
 | 4416 |             if (*option == '+') | 
 | 4417 |               break; | 
 | 4418 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4419 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4420 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4421 |             endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4422 |             if (endian < 0) | 
 | 4423 |               ThrowMogrifyException(OptionError,"UnrecognizedEndianType", | 
 | 4424 |                 argv[i]); | 
 | 4425 |             break; | 
 | 4426 |           } | 
 | 4427 |         if (LocaleCompare("enhance",option+1) == 0) | 
 | 4428 |           break; | 
 | 4429 |         if (LocaleCompare("equalize",option+1) == 0) | 
 | 4430 |           break; | 
 | 4431 |         if (LocaleCompare("evaluate",option+1) == 0) | 
 | 4432 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4433 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4434 |               op; | 
 | 4435 |  | 
 | 4436 |             if (*option == '+') | 
 | 4437 |               break; | 
 | 4438 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4439 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4440 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4441 |             op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4442 |             if (op < 0) | 
 | 4443 |               ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", | 
 | 4444 |                 argv[i]); | 
 | 4445 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4446 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4447 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4448 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4449 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4450 |             break; | 
 | 4451 |           } | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4452 |         if (LocaleCompare("evaluate-sequence",option+1) == 0) | 
 | 4453 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4454 |             ssize_t | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4455 |               op; | 
 | 4456 |  | 
 | 4457 |             if (*option == '+') | 
 | 4458 |               break; | 
 | 4459 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4460 |             if (i == (ssize_t) argc) | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4461 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4462 |             op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4463 |             if (op < 0) | 
 | 4464 |               ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", | 
 | 4465 |                 argv[i]); | 
 | 4466 |             break; | 
 | 4467 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4468 |         if (LocaleCompare("extent",option+1) == 0) | 
 | 4469 |           { | 
 | 4470 |             if (*option == '+') | 
 | 4471 |               break; | 
 | 4472 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4473 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4474 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4475 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4476 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4477 |             break; | 
 | 4478 |           } | 
 | 4479 |         if (LocaleCompare("extract",option+1) == 0) | 
 | 4480 |           { | 
 | 4481 |             if (*option == '+') | 
 | 4482 |               break; | 
 | 4483 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4484 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4485 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4486 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4487 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4488 |             break; | 
 | 4489 |           } | 
 | 4490 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 4491 |       } | 
 | 4492 |       case 'f': | 
 | 4493 |       { | 
 | 4494 |         if (LocaleCompare("family",option+1) == 0) | 
 | 4495 |           { | 
 | 4496 |             if (*option == '+') | 
 | 4497 |               break; | 
 | 4498 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4499 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4500 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4501 |             break; | 
 | 4502 |           } | 
 | 4503 |         if (LocaleCompare("fill",option+1) == 0) | 
 | 4504 |           { | 
 | 4505 |             if (*option == '+') | 
 | 4506 |               break; | 
 | 4507 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4508 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4509 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4510 |             break; | 
 | 4511 |           } | 
 | 4512 |         if (LocaleCompare("filter",option+1) == 0) | 
 | 4513 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4514 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4515 |               filter; | 
 | 4516 |  | 
 | 4517 |             if (*option == '+') | 
 | 4518 |               break; | 
 | 4519 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4520 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4521 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4522 |             filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4523 |             if (filter < 0) | 
 | 4524 |               ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", | 
 | 4525 |                 argv[i]); | 
 | 4526 |             break; | 
 | 4527 |           } | 
 | 4528 |         if (LocaleCompare("flatten",option+1) == 0) | 
 | 4529 |           break; | 
 | 4530 |         if (LocaleCompare("flip",option+1) == 0) | 
 | 4531 |           break; | 
 | 4532 |         if (LocaleCompare("flop",option+1) == 0) | 
 | 4533 |           break; | 
 | 4534 |         if (LocaleCompare("floodfill",option+1) == 0) | 
 | 4535 |           { | 
 | 4536 |             if (*option == '+') | 
 | 4537 |               break; | 
 | 4538 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4539 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4540 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4541 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4542 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4543 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4544 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4545 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4546 |             break; | 
 | 4547 |           } | 
 | 4548 |         if (LocaleCompare("font",option+1) == 0) | 
 | 4549 |           { | 
 | 4550 |             if (*option == '+') | 
 | 4551 |               break; | 
 | 4552 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4553 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4554 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4555 |             break; | 
 | 4556 |           } | 
 | 4557 |         if (LocaleCompare("format",option+1) == 0) | 
 | 4558 |           { | 
 | 4559 |             (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); | 
 | 4560 |             (void) CloneString(&format,(char *) NULL); | 
 | 4561 |             if (*option == '+') | 
 | 4562 |               break; | 
 | 4563 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4564 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4565 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4566 |             (void) CloneString(&format,argv[i]); | 
 | 4567 |             (void) CopyMagickString(image_info->filename,format,MaxTextExtent); | 
 | 4568 |             (void) ConcatenateMagickString(image_info->filename,":", | 
 | 4569 |               MaxTextExtent); | 
| cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4570 |             (void) SetImageInfo(image_info,0,exception); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4571 |             if (*image_info->magick == '\0') | 
 | 4572 |               ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", | 
 | 4573 |                 format); | 
 | 4574 |             break; | 
 | 4575 |           } | 
 | 4576 |         if (LocaleCompare("frame",option+1) == 0) | 
 | 4577 |           { | 
 | 4578 |             if (*option == '+') | 
 | 4579 |               break; | 
 | 4580 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4581 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4582 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4583 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4584 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4585 |             break; | 
 | 4586 |           } | 
 | 4587 |         if (LocaleCompare("function",option+1) == 0) | 
 | 4588 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4589 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4590 |               op; | 
 | 4591 |  | 
 | 4592 |             if (*option == '+') | 
 | 4593 |               break; | 
 | 4594 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4595 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4596 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4597 |             op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4598 |             if (op < 0) | 
 | 4599 |               ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); | 
 | 4600 |              i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4601 |              if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4602 |                ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4603 |             break; | 
 | 4604 |           } | 
 | 4605 |         if (LocaleCompare("fuzz",option+1) == 0) | 
 | 4606 |           { | 
 | 4607 |             if (*option == '+') | 
 | 4608 |               break; | 
 | 4609 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4610 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4611 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4612 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4613 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4614 |             break; | 
 | 4615 |           } | 
 | 4616 |         if (LocaleCompare("fx",option+1) == 0) | 
 | 4617 |           { | 
 | 4618 |             if (*option == '+') | 
 | 4619 |               break; | 
 | 4620 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4621 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4622 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4623 |             break; | 
 | 4624 |           } | 
 | 4625 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 4626 |       } | 
 | 4627 |       case 'g': | 
 | 4628 |       { | 
 | 4629 |         if (LocaleCompare("gamma",option+1) == 0) | 
 | 4630 |           { | 
 | 4631 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4632 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4633 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4634 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4635 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4636 |             break; | 
 | 4637 |           } | 
 | 4638 |         if ((LocaleCompare("gaussian-blur",option+1) == 0) || | 
 | 4639 |             (LocaleCompare("gaussian",option+1) == 0)) | 
 | 4640 |           { | 
 | 4641 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4642 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4643 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4644 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4645 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4646 |             break; | 
 | 4647 |           } | 
 | 4648 |         if (LocaleCompare("geometry",option+1) == 0) | 
 | 4649 |           { | 
 | 4650 |             if (*option == '+') | 
 | 4651 |               break; | 
 | 4652 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4653 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4654 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4655 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4656 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4657 |             break; | 
 | 4658 |           } | 
 | 4659 |         if (LocaleCompare("gravity",option+1) == 0) | 
 | 4660 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4661 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4662 |               gravity; | 
 | 4663 |  | 
 | 4664 |             if (*option == '+') | 
 | 4665 |               break; | 
 | 4666 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4667 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4668 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4669 |             gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4670 |             if (gravity < 0) | 
 | 4671 |               ThrowMogrifyException(OptionError,"UnrecognizedGravityType", | 
 | 4672 |                 argv[i]); | 
 | 4673 |             break; | 
 | 4674 |           } | 
 | 4675 |         if (LocaleCompare("green-primary",option+1) == 0) | 
 | 4676 |           { | 
 | 4677 |             if (*option == '+') | 
 | 4678 |               break; | 
 | 4679 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4680 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4681 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4682 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4683 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4684 |             break; | 
 | 4685 |           } | 
 | 4686 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 4687 |       } | 
 | 4688 |       case 'h': | 
 | 4689 |       { | 
 | 4690 |         if (LocaleCompare("hald-clut",option+1) == 0) | 
 | 4691 |           break; | 
 | 4692 |         if ((LocaleCompare("help",option+1) == 0) || | 
 | 4693 |             (LocaleCompare("-help",option+1) == 0)) | 
 | 4694 |           return(MogrifyUsage()); | 
 | 4695 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 4696 |       } | 
 | 4697 |       case 'i': | 
 | 4698 |       { | 
 | 4699 |         if (LocaleCompare("identify",option+1) == 0) | 
 | 4700 |           break; | 
 | 4701 |         if (LocaleCompare("idft",option+1) == 0) | 
 | 4702 |           break; | 
 | 4703 |         if (LocaleCompare("implode",option+1) == 0) | 
 | 4704 |           { | 
 | 4705 |             if (*option == '+') | 
 | 4706 |               break; | 
 | 4707 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4708 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4709 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4710 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4711 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4712 |             break; | 
 | 4713 |           } | 
 | 4714 |         if (LocaleCompare("intent",option+1) == 0) | 
 | 4715 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4716 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4717 |               intent; | 
 | 4718 |  | 
 | 4719 |             if (*option == '+') | 
 | 4720 |               break; | 
 | 4721 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4722 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4723 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4724 |             intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4725 |             if (intent < 0) | 
 | 4726 |               ThrowMogrifyException(OptionError,"UnrecognizedIntentType", | 
 | 4727 |                 argv[i]); | 
 | 4728 |             break; | 
 | 4729 |           } | 
 | 4730 |         if (LocaleCompare("interlace",option+1) == 0) | 
 | 4731 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4732 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4733 |               interlace; | 
 | 4734 |  | 
 | 4735 |             if (*option == '+') | 
 | 4736 |               break; | 
 | 4737 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4738 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4739 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4740 |             interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4741 |               argv[i]); | 
 | 4742 |             if (interlace < 0) | 
 | 4743 |               ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", | 
 | 4744 |                 argv[i]); | 
 | 4745 |             break; | 
 | 4746 |           } | 
| cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4747 |         if (LocaleCompare("interline-spacing",option+1) == 0) | 
 | 4748 |           { | 
 | 4749 |             if (*option == '+') | 
 | 4750 |               break; | 
 | 4751 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4752 |             if (i == (ssize_t) (argc-1)) | 
| cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4753 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4754 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4755 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4756 |             break; | 
 | 4757 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4758 |         if (LocaleCompare("interpolate",option+1) == 0) | 
 | 4759 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4760 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4761 |               interpolate; | 
 | 4762 |  | 
 | 4763 |             if (*option == '+') | 
 | 4764 |               break; | 
 | 4765 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4766 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4767 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4768 |             interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4769 |               argv[i]); | 
 | 4770 |             if (interpolate < 0) | 
 | 4771 |               ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", | 
 | 4772 |                 argv[i]); | 
 | 4773 |             break; | 
 | 4774 |           } | 
 | 4775 |         if (LocaleCompare("interword-spacing",option+1) == 0) | 
 | 4776 |           { | 
 | 4777 |             if (*option == '+') | 
 | 4778 |               break; | 
 | 4779 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4780 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4781 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4782 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4783 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4784 |             break; | 
 | 4785 |           } | 
 | 4786 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 4787 |       } | 
 | 4788 |       case 'k': | 
 | 4789 |       { | 
 | 4790 |         if (LocaleCompare("kerning",option+1) == 0) | 
 | 4791 |           { | 
 | 4792 |             if (*option == '+') | 
 | 4793 |               break; | 
 | 4794 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4795 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4796 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4797 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4798 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4799 |             break; | 
 | 4800 |           } | 
 | 4801 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 4802 |       } | 
 | 4803 |       case 'l': | 
 | 4804 |       { | 
 | 4805 |         if (LocaleCompare("label",option+1) == 0) | 
 | 4806 |           { | 
 | 4807 |             if (*option == '+') | 
 | 4808 |               break; | 
 | 4809 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4810 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4811 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4812 |             break; | 
 | 4813 |           } | 
 | 4814 |         if (LocaleCompare("lat",option+1) == 0) | 
 | 4815 |           { | 
 | 4816 |             if (*option == '+') | 
 | 4817 |               break; | 
 | 4818 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4819 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4820 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4821 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4822 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4823 |           } | 
 | 4824 |         if (LocaleCompare("layers",option+1) == 0) | 
 | 4825 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4826 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4827 |               type; | 
 | 4828 |  | 
 | 4829 |             if (*option == '+') | 
 | 4830 |               break; | 
 | 4831 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4832 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4833 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4834 |             type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4835 |             if (type < 0) | 
 | 4836 |               ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", | 
 | 4837 |                 argv[i]); | 
 | 4838 |             break; | 
 | 4839 |           } | 
 | 4840 |         if (LocaleCompare("level",option+1) == 0) | 
 | 4841 |           { | 
 | 4842 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4843 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4844 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4845 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4846 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4847 |             break; | 
 | 4848 |           } | 
 | 4849 |         if (LocaleCompare("level-colors",option+1) == 0) | 
 | 4850 |           { | 
 | 4851 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4852 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4853 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4854 |             break; | 
 | 4855 |           } | 
 | 4856 |         if (LocaleCompare("linewidth",option+1) == 0) | 
 | 4857 |           { | 
 | 4858 |             if (*option == '+') | 
 | 4859 |               break; | 
 | 4860 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4861 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4862 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4863 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4864 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4865 |             break; | 
 | 4866 |           } | 
 | 4867 |         if (LocaleCompare("limit",option+1) == 0) | 
 | 4868 |           { | 
 | 4869 |             char | 
 | 4870 |               *p; | 
 | 4871 |  | 
 | 4872 |             double | 
 | 4873 |               value; | 
 | 4874 |  | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4875 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4876 |               resource; | 
 | 4877 |  | 
 | 4878 |             if (*option == '+') | 
 | 4879 |               break; | 
 | 4880 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4881 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4882 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4883 |             resource=ParseCommandOption(MagickResourceOptions,MagickFalse, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4884 |               argv[i]); | 
 | 4885 |             if (resource < 0) | 
 | 4886 |               ThrowMogrifyException(OptionError,"UnrecognizedResourceType", | 
 | 4887 |                 argv[i]); | 
 | 4888 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4889 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4890 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | c1acd84 | 2011-05-19 23:05:47 +0000 | [diff] [blame] | 4891 |             value=InterpretLocaleValue(argv[i],&p); | 
| cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4892 |             (void) value; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4893 |             if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) | 
 | 4894 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4895 |             break; | 
 | 4896 |           } | 
 | 4897 |         if (LocaleCompare("liquid-rescale",option+1) == 0) | 
 | 4898 |           { | 
 | 4899 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4900 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4901 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4902 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4903 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4904 |             break; | 
 | 4905 |           } | 
 | 4906 |         if (LocaleCompare("list",option+1) == 0) | 
 | 4907 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4908 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4909 |               list; | 
 | 4910 |  | 
 | 4911 |             if (*option == '+') | 
 | 4912 |               break; | 
 | 4913 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4914 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4915 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4916 |             list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4917 |             if (list < 0) | 
 | 4918 |               ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); | 
| cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4919 |             status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4920 |               argv+j,exception); | 
| cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4921 |             return(status != 0 ? MagickFalse : MagickTrue); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4922 |           } | 
 | 4923 |         if (LocaleCompare("log",option+1) == 0) | 
 | 4924 |           { | 
 | 4925 |             if (*option == '+') | 
 | 4926 |               break; | 
 | 4927 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4928 |             if ((i == (ssize_t) argc) || | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4929 |                 (strchr(argv[i],'%') == (char *) NULL)) | 
 | 4930 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4931 |             break; | 
 | 4932 |           } | 
 | 4933 |         if (LocaleCompare("loop",option+1) == 0) | 
 | 4934 |           { | 
 | 4935 |             if (*option == '+') | 
 | 4936 |               break; | 
 | 4937 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4938 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4939 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4940 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4941 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4942 |             break; | 
 | 4943 |           } | 
 | 4944 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 4945 |       } | 
 | 4946 |       case 'm': | 
 | 4947 |       { | 
 | 4948 |         if (LocaleCompare("map",option+1) == 0) | 
 | 4949 |           { | 
 | 4950 |             global_colormap=(*option == '+') ? MagickTrue : MagickFalse; | 
 | 4951 |             if (*option == '+') | 
 | 4952 |               break; | 
 | 4953 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4954 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4955 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4956 |             break; | 
 | 4957 |           } | 
 | 4958 |         if (LocaleCompare("mask",option+1) == 0) | 
 | 4959 |           { | 
 | 4960 |             if (*option == '+') | 
 | 4961 |               break; | 
 | 4962 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4963 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4964 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4965 |             break; | 
 | 4966 |           } | 
 | 4967 |         if (LocaleCompare("matte",option+1) == 0) | 
 | 4968 |           break; | 
 | 4969 |         if (LocaleCompare("mattecolor",option+1) == 0) | 
 | 4970 |           { | 
 | 4971 |             if (*option == '+') | 
 | 4972 |               break; | 
 | 4973 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4974 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4975 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4976 |             break; | 
 | 4977 |           } | 
| cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4978 |         if (LocaleCompare("maximum",option+1) == 0) | 
| cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4979 |           break; | 
| cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 4980 |         if (LocaleCompare("minimum",option+1) == 0) | 
| cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 4981 |           break; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4982 |         if (LocaleCompare("modulate",option+1) == 0) | 
 | 4983 |           { | 
 | 4984 |             if (*option == '+') | 
 | 4985 |               break; | 
 | 4986 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4987 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4988 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 4989 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 4990 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 4991 |             break; | 
 | 4992 |           } | 
 | 4993 |         if (LocaleCompare("median",option+1) == 0) | 
 | 4994 |           { | 
 | 4995 |             if (*option == '+') | 
 | 4996 |               break; | 
 | 4997 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4998 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4999 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5000 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5001 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5002 |             break; | 
 | 5003 |           } | 
| cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5004 |         if (LocaleCompare("mode",option+1) == 0) | 
 | 5005 |           { | 
 | 5006 |             if (*option == '+') | 
 | 5007 |               break; | 
 | 5008 |             i++; | 
 | 5009 |             if (i == (ssize_t) argc) | 
 | 5010 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5011 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5012 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5013 |             break; | 
 | 5014 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5015 |         if (LocaleCompare("monitor",option+1) == 0) | 
 | 5016 |           break; | 
 | 5017 |         if (LocaleCompare("monochrome",option+1) == 0) | 
 | 5018 |           break; | 
 | 5019 |         if (LocaleCompare("morph",option+1) == 0) | 
 | 5020 |           { | 
 | 5021 |             if (*option == '+') | 
 | 5022 |               break; | 
 | 5023 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5024 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5025 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5026 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5027 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5028 |             break; | 
 | 5029 |           } | 
| anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5030 |         if (LocaleCompare("morphology",option+1) == 0) | 
 | 5031 |           { | 
| anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5032 |             char | 
 | 5033 |               token[MaxTextExtent]; | 
 | 5034 |  | 
| cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5035 |             KernelInfo | 
 | 5036 |               *kernel_info; | 
 | 5037 |  | 
 | 5038 |             ssize_t | 
 | 5039 |               op; | 
 | 5040 |  | 
| anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5041 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5042 |             if (i == (ssize_t) argc) | 
| anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5043 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5044 |             GetMagickToken(argv[i],NULL,token); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5045 |             op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); | 
| anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5046 |             if (op < 0) | 
 | 5047 |               ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", | 
| cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5048 |                 token); | 
| anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5049 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5050 |             if (i == (ssize_t) (argc-1)) | 
| anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5051 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5052 |             kernel_info=AcquireKernelInfo(argv[i]); | 
 | 5053 |             if (kernel_info == (KernelInfo *) NULL) | 
| cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5054 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
| cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5055 |             kernel_info=DestroyKernelInfo(kernel_info); | 
| anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5056 |             break; | 
 | 5057 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5058 |         if (LocaleCompare("mosaic",option+1) == 0) | 
 | 5059 |           break; | 
 | 5060 |         if (LocaleCompare("motion-blur",option+1) == 0) | 
 | 5061 |           { | 
 | 5062 |             if (*option == '+') | 
 | 5063 |               break; | 
 | 5064 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5065 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5066 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5067 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5068 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5069 |             break; | 
 | 5070 |           } | 
 | 5071 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 5072 |       } | 
 | 5073 |       case 'n': | 
 | 5074 |       { | 
 | 5075 |         if (LocaleCompare("negate",option+1) == 0) | 
 | 5076 |           break; | 
 | 5077 |         if (LocaleCompare("noise",option+1) == 0) | 
 | 5078 |           { | 
 | 5079 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5080 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5081 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5082 |             if (*option == '+') | 
 | 5083 |               { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5084 |                 ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5085 |                   noise; | 
 | 5086 |  | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5087 |                 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5088 |                 if (noise < 0) | 
 | 5089 |                   ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", | 
 | 5090 |                     argv[i]); | 
 | 5091 |                 break; | 
 | 5092 |               } | 
 | 5093 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5094 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5095 |             break; | 
 | 5096 |           } | 
 | 5097 |         if (LocaleCompare("noop",option+1) == 0) | 
 | 5098 |           break; | 
 | 5099 |         if (LocaleCompare("normalize",option+1) == 0) | 
 | 5100 |           break; | 
 | 5101 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 5102 |       } | 
 | 5103 |       case 'o': | 
 | 5104 |       { | 
 | 5105 |         if (LocaleCompare("opaque",option+1) == 0) | 
 | 5106 |           { | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5107 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5108 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5109 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5110 |             break; | 
 | 5111 |           } | 
 | 5112 |         if (LocaleCompare("ordered-dither",option+1) == 0) | 
 | 5113 |           { | 
 | 5114 |             if (*option == '+') | 
 | 5115 |               break; | 
 | 5116 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5117 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5118 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5119 |             break; | 
 | 5120 |           } | 
 | 5121 |         if (LocaleCompare("orient",option+1) == 0) | 
 | 5122 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5123 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5124 |               orientation; | 
 | 5125 |  | 
 | 5126 |             orientation=UndefinedOrientation; | 
 | 5127 |             if (*option == '+') | 
 | 5128 |               break; | 
 | 5129 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5130 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5131 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5132 |             orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5133 |               argv[i]); | 
 | 5134 |             if (orientation < 0) | 
 | 5135 |               ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", | 
 | 5136 |                 argv[i]); | 
 | 5137 |             break; | 
 | 5138 |           } | 
 | 5139 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 5140 |       } | 
 | 5141 |       case 'p': | 
 | 5142 |       { | 
 | 5143 |         if (LocaleCompare("page",option+1) == 0) | 
 | 5144 |           { | 
 | 5145 |             if (*option == '+') | 
 | 5146 |               break; | 
 | 5147 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5148 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5149 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5150 |             break; | 
 | 5151 |           } | 
 | 5152 |         if (LocaleCompare("paint",option+1) == 0) | 
 | 5153 |           { | 
 | 5154 |             if (*option == '+') | 
 | 5155 |               break; | 
 | 5156 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5157 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5158 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5159 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5160 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5161 |             break; | 
 | 5162 |           } | 
 | 5163 |         if (LocaleCompare("path",option+1) == 0) | 
 | 5164 |           { | 
 | 5165 |             (void) CloneString(&path,(char *) NULL); | 
 | 5166 |             if (*option == '+') | 
 | 5167 |               break; | 
 | 5168 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5169 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5170 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5171 |             (void) CloneString(&path,argv[i]); | 
 | 5172 |             break; | 
 | 5173 |           } | 
 | 5174 |         if (LocaleCompare("pointsize",option+1) == 0) | 
 | 5175 |           { | 
 | 5176 |             if (*option == '+') | 
 | 5177 |               break; | 
 | 5178 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5179 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5180 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5181 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5182 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5183 |             break; | 
 | 5184 |           } | 
 | 5185 |         if (LocaleCompare("polaroid",option+1) == 0) | 
 | 5186 |           { | 
 | 5187 |             if (*option == '+') | 
 | 5188 |               break; | 
 | 5189 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5190 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5191 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5192 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5193 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5194 |             break; | 
 | 5195 |           } | 
 | 5196 |         if (LocaleCompare("posterize",option+1) == 0) | 
 | 5197 |           { | 
 | 5198 |             if (*option == '+') | 
 | 5199 |               break; | 
 | 5200 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5201 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5202 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5203 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5204 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5205 |             break; | 
 | 5206 |           } | 
| cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5207 |         if (LocaleCompare("precision",option+1) == 0) | 
 | 5208 |           { | 
 | 5209 |             if (*option == '+') | 
 | 5210 |               break; | 
 | 5211 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5212 |             if (i == (ssize_t) argc) | 
| cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5213 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5214 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5215 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5216 |             break; | 
 | 5217 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5218 |         if (LocaleCompare("print",option+1) == 0) | 
 | 5219 |           { | 
 | 5220 |             if (*option == '+') | 
 | 5221 |               break; | 
 | 5222 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5223 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5224 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5225 |             break; | 
 | 5226 |           } | 
 | 5227 |         if (LocaleCompare("process",option+1) == 0) | 
 | 5228 |           { | 
 | 5229 |             if (*option == '+') | 
 | 5230 |               break; | 
 | 5231 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5232 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5233 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5234 |             break; | 
 | 5235 |           } | 
 | 5236 |         if (LocaleCompare("profile",option+1) == 0) | 
 | 5237 |           { | 
 | 5238 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5239 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5240 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5241 |             break; | 
 | 5242 |           } | 
 | 5243 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 5244 |       } | 
 | 5245 |       case 'q': | 
 | 5246 |       { | 
 | 5247 |         if (LocaleCompare("quality",option+1) == 0) | 
 | 5248 |           { | 
 | 5249 |             if (*option == '+') | 
 | 5250 |               break; | 
 | 5251 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5252 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5253 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5254 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5255 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5256 |             break; | 
 | 5257 |           } | 
 | 5258 |         if (LocaleCompare("quantize",option+1) == 0) | 
 | 5259 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5260 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5261 |               colorspace; | 
 | 5262 |  | 
 | 5263 |             if (*option == '+') | 
 | 5264 |               break; | 
 | 5265 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5266 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5267 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5268 |             colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5269 |               argv[i]); | 
 | 5270 |             if (colorspace < 0) | 
 | 5271 |               ThrowMogrifyException(OptionError,"UnrecognizedColorspace", | 
 | 5272 |                 argv[i]); | 
 | 5273 |             break; | 
 | 5274 |           } | 
 | 5275 |         if (LocaleCompare("quiet",option+1) == 0) | 
 | 5276 |           break; | 
 | 5277 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 5278 |       } | 
 | 5279 |       case 'r': | 
 | 5280 |       { | 
 | 5281 |         if (LocaleCompare("radial-blur",option+1) == 0) | 
 | 5282 |           { | 
 | 5283 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5284 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5285 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5286 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5287 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5288 |             break; | 
 | 5289 |           } | 
 | 5290 |         if (LocaleCompare("raise",option+1) == 0) | 
 | 5291 |           { | 
 | 5292 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5293 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5294 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5295 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5296 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5297 |             break; | 
 | 5298 |           } | 
 | 5299 |         if (LocaleCompare("random-threshold",option+1) == 0) | 
 | 5300 |           { | 
 | 5301 |             if (*option == '+') | 
 | 5302 |               break; | 
 | 5303 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5304 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5305 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5306 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5307 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5308 |             break; | 
 | 5309 |           } | 
| cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5310 |         if (LocaleCompare("recolor",option+1) == 0) | 
 | 5311 |           { | 
 | 5312 |             if (*option == '+') | 
 | 5313 |               break; | 
 | 5314 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5315 |             if (i == (ssize_t) (argc-1)) | 
| cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5316 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5317 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5318 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5319 |             break; | 
 | 5320 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5321 |         if (LocaleCompare("red-primary",option+1) == 0) | 
 | 5322 |           { | 
 | 5323 |             if (*option == '+') | 
 | 5324 |               break; | 
 | 5325 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5326 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5327 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5328 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5329 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5330 |           } | 
| cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5331 |         if (LocaleCompare("regard-warnings",option+1) == 0) | 
 | 5332 |           break; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5333 |         if (LocaleCompare("region",option+1) == 0) | 
 | 5334 |           { | 
 | 5335 |             if (*option == '+') | 
 | 5336 |               break; | 
 | 5337 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5338 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5339 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5340 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5341 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5342 |             break; | 
 | 5343 |           } | 
| cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5344 |         if (LocaleCompare("remap",option+1) == 0) | 
 | 5345 |           { | 
 | 5346 |             if (*option == '+') | 
 | 5347 |               break; | 
 | 5348 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5349 |             if (i == (ssize_t) (argc-1)) | 
| cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5350 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5351 |             break; | 
 | 5352 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5353 |         if (LocaleCompare("render",option+1) == 0) | 
 | 5354 |           break; | 
 | 5355 |         if (LocaleCompare("repage",option+1) == 0) | 
 | 5356 |           { | 
 | 5357 |             if (*option == '+') | 
 | 5358 |               break; | 
 | 5359 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5360 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5361 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5362 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5363 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5364 |             break; | 
 | 5365 |           } | 
 | 5366 |         if (LocaleCompare("resample",option+1) == 0) | 
 | 5367 |           { | 
 | 5368 |             if (*option == '+') | 
 | 5369 |               break; | 
 | 5370 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5371 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5372 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5373 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5374 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5375 |             break; | 
 | 5376 |           } | 
 | 5377 |         if (LocaleCompare("resize",option+1) == 0) | 
 | 5378 |           { | 
 | 5379 |             if (*option == '+') | 
 | 5380 |               break; | 
 | 5381 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5382 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5383 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5384 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5385 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5386 |             break; | 
 | 5387 |           } | 
| cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5388 |         if (LocaleNCompare("respect-parentheses",option+1,17) == 0) | 
 | 5389 |           { | 
 | 5390 |             respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; | 
 | 5391 |             break; | 
 | 5392 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5393 |         if (LocaleCompare("reverse",option+1) == 0) | 
 | 5394 |           break; | 
 | 5395 |         if (LocaleCompare("roll",option+1) == 0) | 
 | 5396 |           { | 
 | 5397 |             if (*option == '+') | 
 | 5398 |               break; | 
 | 5399 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5400 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5401 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5402 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5403 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5404 |             break; | 
 | 5405 |           } | 
 | 5406 |         if (LocaleCompare("rotate",option+1) == 0) | 
 | 5407 |           { | 
 | 5408 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5409 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5410 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5411 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5412 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5413 |             break; | 
 | 5414 |           } | 
 | 5415 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 5416 |       } | 
 | 5417 |       case 's': | 
 | 5418 |       { | 
 | 5419 |         if (LocaleCompare("sample",option+1) == 0) | 
 | 5420 |           { | 
 | 5421 |             if (*option == '+') | 
 | 5422 |               break; | 
 | 5423 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5424 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5425 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5426 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5427 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5428 |             break; | 
 | 5429 |           } | 
 | 5430 |         if (LocaleCompare("sampling-factor",option+1) == 0) | 
 | 5431 |           { | 
 | 5432 |             if (*option == '+') | 
 | 5433 |               break; | 
 | 5434 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5435 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5436 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5437 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5438 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5439 |             break; | 
 | 5440 |           } | 
 | 5441 |         if (LocaleCompare("scale",option+1) == 0) | 
 | 5442 |           { | 
 | 5443 |             if (*option == '+') | 
 | 5444 |               break; | 
 | 5445 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5446 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5447 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5448 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5449 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5450 |             break; | 
 | 5451 |           } | 
 | 5452 |         if (LocaleCompare("scene",option+1) == 0) | 
 | 5453 |           { | 
 | 5454 |             if (*option == '+') | 
 | 5455 |               break; | 
 | 5456 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5457 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5458 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5459 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5460 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5461 |             break; | 
 | 5462 |           } | 
 | 5463 |         if (LocaleCompare("seed",option+1) == 0) | 
 | 5464 |           { | 
 | 5465 |             if (*option == '+') | 
 | 5466 |               break; | 
 | 5467 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5468 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5469 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5470 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5471 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5472 |             break; | 
 | 5473 |           } | 
 | 5474 |         if (LocaleCompare("segment",option+1) == 0) | 
 | 5475 |           { | 
 | 5476 |             if (*option == '+') | 
 | 5477 |               break; | 
 | 5478 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5479 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5480 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5481 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5482 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5483 |             break; | 
 | 5484 |           } | 
 | 5485 |         if (LocaleCompare("selective-blur",option+1) == 0) | 
 | 5486 |           { | 
 | 5487 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5488 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5489 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5490 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5491 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5492 |             break; | 
 | 5493 |           } | 
 | 5494 |         if (LocaleCompare("separate",option+1) == 0) | 
 | 5495 |           break; | 
 | 5496 |         if (LocaleCompare("sepia-tone",option+1) == 0) | 
 | 5497 |           { | 
 | 5498 |             if (*option == '+') | 
 | 5499 |               break; | 
 | 5500 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5501 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5502 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5503 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5504 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5505 |             break; | 
 | 5506 |           } | 
 | 5507 |         if (LocaleCompare("set",option+1) == 0) | 
 | 5508 |           { | 
 | 5509 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5510 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5511 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5512 |             if (*option == '+') | 
 | 5513 |               break; | 
 | 5514 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5515 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5516 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5517 |             break; | 
 | 5518 |           } | 
 | 5519 |         if (LocaleCompare("shade",option+1) == 0) | 
 | 5520 |           { | 
 | 5521 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5522 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5523 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5524 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5525 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5526 |             break; | 
 | 5527 |           } | 
 | 5528 |         if (LocaleCompare("shadow",option+1) == 0) | 
 | 5529 |           { | 
 | 5530 |             if (*option == '+') | 
 | 5531 |               break; | 
 | 5532 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5533 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5534 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5535 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5536 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5537 |             break; | 
 | 5538 |           } | 
 | 5539 |         if (LocaleCompare("sharpen",option+1) == 0) | 
 | 5540 |           { | 
 | 5541 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5542 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5543 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5544 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5545 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5546 |             break; | 
 | 5547 |           } | 
 | 5548 |         if (LocaleCompare("shave",option+1) == 0) | 
 | 5549 |           { | 
 | 5550 |             if (*option == '+') | 
 | 5551 |               break; | 
 | 5552 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5553 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5554 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5555 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5556 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5557 |             break; | 
 | 5558 |           } | 
 | 5559 |         if (LocaleCompare("shear",option+1) == 0) | 
 | 5560 |           { | 
 | 5561 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5562 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5563 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5564 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5565 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5566 |             break; | 
 | 5567 |           } | 
 | 5568 |         if (LocaleCompare("sigmoidal-contrast",option+1) == 0) | 
 | 5569 |           { | 
 | 5570 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5571 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5572 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5573 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5574 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5575 |             break; | 
 | 5576 |           } | 
 | 5577 |         if (LocaleCompare("size",option+1) == 0) | 
 | 5578 |           { | 
 | 5579 |             if (*option == '+') | 
 | 5580 |               break; | 
 | 5581 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5582 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5583 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5584 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5585 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5586 |             break; | 
 | 5587 |           } | 
 | 5588 |         if (LocaleCompare("sketch",option+1) == 0) | 
 | 5589 |           { | 
 | 5590 |             if (*option == '+') | 
 | 5591 |               break; | 
 | 5592 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5593 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5594 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5595 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5596 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5597 |             break; | 
 | 5598 |           } | 
| cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5599 |         if (LocaleCompare("smush",option+1) == 0) | 
 | 5600 |           { | 
| cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5601 |             i++; | 
 | 5602 |             if (i == (ssize_t) argc) | 
 | 5603 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5604 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5605 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
| cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5606 |             i++; | 
 | 5607 |             break; | 
 | 5608 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5609 |         if (LocaleCompare("solarize",option+1) == 0) | 
 | 5610 |           { | 
 | 5611 |             if (*option == '+') | 
 | 5612 |               break; | 
 | 5613 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5614 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5615 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5616 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5617 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5618 |             break; | 
 | 5619 |           } | 
 | 5620 |         if (LocaleCompare("sparse-color",option+1) == 0) | 
 | 5621 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5622 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5623 |               op; | 
 | 5624 |  | 
 | 5625 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5626 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5627 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5628 |             op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5629 |             if (op < 0) | 
 | 5630 |               ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", | 
 | 5631 |                 argv[i]); | 
 | 5632 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5633 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5634 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5635 |             break; | 
 | 5636 |           } | 
 | 5637 |         if (LocaleCompare("spread",option+1) == 0) | 
 | 5638 |           { | 
 | 5639 |             if (*option == '+') | 
 | 5640 |               break; | 
 | 5641 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5642 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5643 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5644 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5645 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5646 |             break; | 
 | 5647 |           } | 
| cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5648 |         if (LocaleCompare("statistic",option+1) == 0) | 
 | 5649 |           { | 
 | 5650 |             ssize_t | 
 | 5651 |               op; | 
 | 5652 |  | 
 | 5653 |             if (*option == '+') | 
 | 5654 |               break; | 
 | 5655 |             i++; | 
 | 5656 |             if (i == (ssize_t) argc) | 
 | 5657 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5658 |             op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); | 
| cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5659 |             if (op < 0) | 
 | 5660 |               ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", | 
 | 5661 |                 argv[i]); | 
 | 5662 |             i++; | 
 | 5663 |             if (i == (ssize_t) (argc-1)) | 
 | 5664 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5665 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5666 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5667 |             break; | 
 | 5668 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5669 |         if (LocaleCompare("stretch",option+1) == 0) | 
 | 5670 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5671 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5672 |               stretch; | 
 | 5673 |  | 
 | 5674 |             if (*option == '+') | 
 | 5675 |               break; | 
 | 5676 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5677 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5678 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5679 |             stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5680 |             if (stretch < 0) | 
 | 5681 |               ThrowMogrifyException(OptionError,"UnrecognizedStyleType", | 
 | 5682 |                 argv[i]); | 
 | 5683 |             break; | 
 | 5684 |           } | 
 | 5685 |         if (LocaleCompare("strip",option+1) == 0) | 
 | 5686 |           break; | 
 | 5687 |         if (LocaleCompare("stroke",option+1) == 0) | 
 | 5688 |           { | 
 | 5689 |             if (*option == '+') | 
 | 5690 |               break; | 
 | 5691 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5692 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5693 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5694 |             break; | 
 | 5695 |           } | 
 | 5696 |         if (LocaleCompare("strokewidth",option+1) == 0) | 
 | 5697 |           { | 
 | 5698 |             if (*option == '+') | 
 | 5699 |               break; | 
 | 5700 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5701 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5702 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5703 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5704 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5705 |             break; | 
 | 5706 |           } | 
 | 5707 |         if (LocaleCompare("style",option+1) == 0) | 
 | 5708 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5709 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5710 |               style; | 
 | 5711 |  | 
 | 5712 |             if (*option == '+') | 
 | 5713 |               break; | 
 | 5714 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5715 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5716 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5717 |             style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5718 |             if (style < 0) | 
 | 5719 |               ThrowMogrifyException(OptionError,"UnrecognizedStyleType", | 
 | 5720 |                 argv[i]); | 
 | 5721 |             break; | 
 | 5722 |           } | 
| cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5723 |         if (LocaleCompare("swap",option+1) == 0) | 
 | 5724 |           { | 
 | 5725 |             if (*option == '+') | 
 | 5726 |               break; | 
 | 5727 |             i++; | 
 | 5728 |             if (i == (ssize_t) (argc-1)) | 
 | 5729 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5730 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5731 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5732 |             break; | 
 | 5733 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5734 |         if (LocaleCompare("swirl",option+1) == 0) | 
 | 5735 |           { | 
 | 5736 |             if (*option == '+') | 
 | 5737 |               break; | 
 | 5738 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5739 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5740 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5741 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5742 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5743 |             break; | 
 | 5744 |           } | 
| cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5745 |         if (LocaleCompare("synchronize",option+1) == 0) | 
 | 5746 |           break; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5747 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 5748 |       } | 
 | 5749 |       case 't': | 
 | 5750 |       { | 
 | 5751 |         if (LocaleCompare("taint",option+1) == 0) | 
 | 5752 |           break; | 
 | 5753 |         if (LocaleCompare("texture",option+1) == 0) | 
 | 5754 |           { | 
 | 5755 |             if (*option == '+') | 
 | 5756 |               break; | 
 | 5757 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5758 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5759 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5760 |             break; | 
 | 5761 |           } | 
 | 5762 |         if (LocaleCompare("tile",option+1) == 0) | 
 | 5763 |           { | 
 | 5764 |             if (*option == '+') | 
 | 5765 |               break; | 
 | 5766 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5767 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5768 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5769 |             break; | 
 | 5770 |           } | 
 | 5771 |         if (LocaleCompare("tile-offset",option+1) == 0) | 
 | 5772 |           { | 
 | 5773 |             if (*option == '+') | 
 | 5774 |               break; | 
 | 5775 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5776 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5777 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5778 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5779 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5780 |             break; | 
 | 5781 |           } | 
 | 5782 |         if (LocaleCompare("tint",option+1) == 0) | 
 | 5783 |           { | 
 | 5784 |             if (*option == '+') | 
 | 5785 |               break; | 
 | 5786 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5787 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5788 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5789 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5790 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5791 |             break; | 
 | 5792 |           } | 
 | 5793 |         if (LocaleCompare("transform",option+1) == 0) | 
 | 5794 |           break; | 
 | 5795 |         if (LocaleCompare("transpose",option+1) == 0) | 
 | 5796 |           break; | 
 | 5797 |         if (LocaleCompare("transverse",option+1) == 0) | 
 | 5798 |           break; | 
 | 5799 |         if (LocaleCompare("threshold",option+1) == 0) | 
 | 5800 |           { | 
 | 5801 |             if (*option == '+') | 
 | 5802 |               break; | 
 | 5803 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5804 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5805 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5806 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5807 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5808 |             break; | 
 | 5809 |           } | 
 | 5810 |         if (LocaleCompare("thumbnail",option+1) == 0) | 
 | 5811 |           { | 
 | 5812 |             if (*option == '+') | 
 | 5813 |               break; | 
 | 5814 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5815 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5816 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5817 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5818 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5819 |             break; | 
 | 5820 |           } | 
 | 5821 |         if (LocaleCompare("transparent",option+1) == 0) | 
 | 5822 |           { | 
 | 5823 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5824 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5825 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5826 |             break; | 
 | 5827 |           } | 
 | 5828 |         if (LocaleCompare("transparent-color",option+1) == 0) | 
 | 5829 |           { | 
 | 5830 |             if (*option == '+') | 
 | 5831 |               break; | 
 | 5832 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5833 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5834 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5835 |             break; | 
 | 5836 |           } | 
 | 5837 |         if (LocaleCompare("treedepth",option+1) == 0) | 
 | 5838 |           { | 
 | 5839 |             if (*option == '+') | 
 | 5840 |               break; | 
 | 5841 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5842 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5843 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5844 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5845 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5846 |             break; | 
 | 5847 |           } | 
 | 5848 |         if (LocaleCompare("trim",option+1) == 0) | 
 | 5849 |           break; | 
 | 5850 |         if (LocaleCompare("type",option+1) == 0) | 
 | 5851 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5852 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5853 |               type; | 
 | 5854 |  | 
 | 5855 |             if (*option == '+') | 
 | 5856 |               break; | 
 | 5857 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5858 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5859 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5860 |             type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5861 |             if (type < 0) | 
 | 5862 |               ThrowMogrifyException(OptionError,"UnrecognizedImageType", | 
 | 5863 |                 argv[i]); | 
 | 5864 |             break; | 
 | 5865 |           } | 
 | 5866 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 5867 |       } | 
 | 5868 |       case 'u': | 
 | 5869 |       { | 
 | 5870 |         if (LocaleCompare("undercolor",option+1) == 0) | 
 | 5871 |           { | 
 | 5872 |             if (*option == '+') | 
 | 5873 |               break; | 
 | 5874 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5875 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5876 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5877 |             break; | 
 | 5878 |           } | 
 | 5879 |         if (LocaleCompare("unique-colors",option+1) == 0) | 
 | 5880 |           break; | 
 | 5881 |         if (LocaleCompare("units",option+1) == 0) | 
 | 5882 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5883 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5884 |               units; | 
 | 5885 |  | 
 | 5886 |             if (*option == '+') | 
 | 5887 |               break; | 
 | 5888 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5889 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5890 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5891 |             units=ParseCommandOption(MagickResolutionOptions,MagickFalse, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5892 |               argv[i]); | 
 | 5893 |             if (units < 0) | 
 | 5894 |               ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", | 
 | 5895 |                 argv[i]); | 
 | 5896 |             break; | 
 | 5897 |           } | 
 | 5898 |         if (LocaleCompare("unsharp",option+1) == 0) | 
 | 5899 |           { | 
 | 5900 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5901 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5902 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5903 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5904 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5905 |             break; | 
 | 5906 |           } | 
 | 5907 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 5908 |       } | 
 | 5909 |       case 'v': | 
 | 5910 |       { | 
 | 5911 |         if (LocaleCompare("verbose",option+1) == 0) | 
 | 5912 |           { | 
 | 5913 |             image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; | 
 | 5914 |             break; | 
 | 5915 |           } | 
 | 5916 |         if ((LocaleCompare("version",option+1) == 0) || | 
 | 5917 |             (LocaleCompare("-version",option+1) == 0)) | 
 | 5918 |           { | 
| cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 5919 |             (void) FormatLocaleFile(stdout,"Version: %s\n", | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5920 |               GetMagickVersion((size_t *) NULL)); | 
| cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 5921 |             (void) FormatLocaleFile(stdout,"Copyright: %s\n", | 
 | 5922 |               GetMagickCopyright()); | 
 | 5923 |             (void) FormatLocaleFile(stdout,"Features: %s\n\n", | 
 | 5924 |               GetMagickFeatures()); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5925 |             break; | 
 | 5926 |           } | 
 | 5927 |         if (LocaleCompare("view",option+1) == 0) | 
 | 5928 |           { | 
 | 5929 |             if (*option == '+') | 
 | 5930 |               break; | 
 | 5931 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5932 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5933 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5934 |             break; | 
 | 5935 |           } | 
 | 5936 |         if (LocaleCompare("vignette",option+1) == 0) | 
 | 5937 |           { | 
 | 5938 |             if (*option == '+') | 
 | 5939 |               break; | 
 | 5940 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5941 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5942 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5943 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5944 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5945 |             break; | 
 | 5946 |           } | 
 | 5947 |         if (LocaleCompare("virtual-pixel",option+1) == 0) | 
 | 5948 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5949 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5950 |               method; | 
 | 5951 |  | 
 | 5952 |             if (*option == '+') | 
 | 5953 |               break; | 
 | 5954 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5955 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5956 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5957 |             method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5958 |               argv[i]); | 
 | 5959 |             if (method < 0) | 
 | 5960 |               ThrowMogrifyException(OptionError, | 
 | 5961 |                 "UnrecognizedVirtualPixelMethod",argv[i]); | 
 | 5962 |             break; | 
 | 5963 |           } | 
 | 5964 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 5965 |       } | 
 | 5966 |       case 'w': | 
 | 5967 |       { | 
 | 5968 |         if (LocaleCompare("wave",option+1) == 0) | 
 | 5969 |           { | 
 | 5970 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5971 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5972 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5973 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5974 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5975 |             break; | 
 | 5976 |           } | 
 | 5977 |         if (LocaleCompare("weight",option+1) == 0) | 
 | 5978 |           { | 
 | 5979 |             if (*option == '+') | 
 | 5980 |               break; | 
 | 5981 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5982 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5983 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5984 |             break; | 
 | 5985 |           } | 
 | 5986 |         if (LocaleCompare("white-point",option+1) == 0) | 
 | 5987 |           { | 
 | 5988 |             if (*option == '+') | 
 | 5989 |               break; | 
 | 5990 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5991 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5992 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 5993 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 5994 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 5995 |             break; | 
 | 5996 |           } | 
 | 5997 |         if (LocaleCompare("white-threshold",option+1) == 0) | 
 | 5998 |           { | 
 | 5999 |             if (*option == '+') | 
 | 6000 |               break; | 
 | 6001 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6002 |             if (i == (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6003 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 6004 |             if (IsGeometry(argv[i]) == MagickFalse) | 
 | 6005 |               ThrowMogrifyInvalidArgumentException(option,argv[i]); | 
 | 6006 |             break; | 
 | 6007 |           } | 
 | 6008 |         if (LocaleCompare("write",option+1) == 0) | 
 | 6009 |           { | 
 | 6010 |             i++; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6011 |             if (i == (ssize_t) (argc-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6012 |               ThrowMogrifyException(OptionError,"MissingArgument",option); | 
 | 6013 |             break; | 
 | 6014 |           } | 
 | 6015 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 6016 |       } | 
 | 6017 |       case '?': | 
 | 6018 |         break; | 
 | 6019 |       default: | 
 | 6020 |         ThrowMogrifyException(OptionError,"UnrecognizedOption",option) | 
 | 6021 |     } | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6022 |     fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & | 
 | 6023 |       FireOptionFlag) == 0 ?  MagickFalse : MagickTrue; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6024 |     if (fire != MagickFalse) | 
 | 6025 |       FireImageStack(MagickFalse,MagickTrue,MagickTrue); | 
 | 6026 |   } | 
 | 6027 |   if (k != 0) | 
 | 6028 |     ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); | 
| cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6029 |   if (i != (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6030 |     ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); | 
 | 6031 |   DestroyMogrify(); | 
 | 6032 |   return(status != 0 ? MagickTrue : MagickFalse); | 
 | 6033 | } | 
 | 6034 |  | 
 | 6035 | /* | 
 | 6036 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 6037 | %                                                                             % | 
 | 6038 | %                                                                             % | 
 | 6039 | %                                                                             % | 
 | 6040 | +     M o g r i f y I m a g e I n f o                                         % | 
 | 6041 | %                                                                             % | 
 | 6042 | %                                                                             % | 
 | 6043 | %                                                                             % | 
 | 6044 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 6045 | % | 
 | 6046 | %  MogrifyImageInfo() applies image processing settings to the image as | 
 | 6047 | %  prescribed by command line options. | 
 | 6048 | % | 
 | 6049 | %  The format of the MogrifyImageInfo method is: | 
 | 6050 | % | 
 | 6051 | %      MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, | 
 | 6052 | %        const char **argv,ExceptionInfo *exception) | 
 | 6053 | % | 
 | 6054 | %  A description of each parameter follows: | 
 | 6055 | % | 
 | 6056 | %    o image_info: the image info.. | 
 | 6057 | % | 
 | 6058 | %    o argc: Specifies a pointer to an integer describing the number of | 
 | 6059 | %      elements in the argument vector. | 
 | 6060 | % | 
 | 6061 | %    o argv: Specifies a pointer to a text array containing the command line | 
 | 6062 | %      arguments. | 
 | 6063 | % | 
 | 6064 | %    o exception: return any errors or warnings in this structure. | 
 | 6065 | % | 
 | 6066 | */ | 
 | 6067 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, | 
 | 6068 |   const int argc,const char **argv,ExceptionInfo *exception) | 
 | 6069 | { | 
 | 6070 |   const char | 
 | 6071 |     *option; | 
 | 6072 |  | 
 | 6073 |   GeometryInfo | 
 | 6074 |     geometry_info; | 
 | 6075 |  | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6076 |   ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6077 |     count; | 
 | 6078 |  | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6079 |   register ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6080 |     i; | 
 | 6081 |  | 
 | 6082 |   /* | 
 | 6083 |     Initialize method variables. | 
 | 6084 |   */ | 
 | 6085 |   assert(image_info != (ImageInfo *) NULL); | 
 | 6086 |   assert(image_info->signature == MagickSignature); | 
 | 6087 |   if (image_info->debug != MagickFalse) | 
 | 6088 |     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", | 
 | 6089 |       image_info->filename); | 
 | 6090 |   if (argc < 0) | 
 | 6091 |     return(MagickTrue); | 
 | 6092 |   /* | 
 | 6093 |     Set the image settings. | 
 | 6094 |   */ | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6095 |   for (i=0; i < (ssize_t) argc; i++) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6096 |   { | 
 | 6097 |     option=argv[i]; | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6098 |     if (IsCommandOption(option) == MagickFalse) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6099 |       continue; | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6100 |     count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); | 
| anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6101 |     count=MagickMax(count,0L); | 
| cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6102 |     if ((i+count) >= (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6103 |       break; | 
 | 6104 |     switch (*(option+1)) | 
 | 6105 |     { | 
 | 6106 |       case 'a': | 
 | 6107 |       { | 
 | 6108 |         if (LocaleCompare("adjoin",option+1) == 0) | 
 | 6109 |           { | 
 | 6110 |             image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; | 
 | 6111 |             break; | 
 | 6112 |           } | 
 | 6113 |         if (LocaleCompare("antialias",option+1) == 0) | 
 | 6114 |           { | 
 | 6115 |             image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; | 
 | 6116 |             break; | 
 | 6117 |           } | 
 | 6118 |         if (LocaleCompare("attenuate",option+1) == 0) | 
 | 6119 |           { | 
 | 6120 |             if (*option == '+') | 
 | 6121 |               { | 
 | 6122 |                 (void) DeleteImageOption(image_info,option+1); | 
 | 6123 |                 break; | 
 | 6124 |               } | 
 | 6125 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6126 |             break; | 
 | 6127 |           } | 
 | 6128 |         if (LocaleCompare("authenticate",option+1) == 0) | 
 | 6129 |           { | 
 | 6130 |             if (*option == '+') | 
 | 6131 |               (void) CloneString(&image_info->authenticate,(char *) NULL); | 
 | 6132 |             else | 
 | 6133 |               (void) CloneString(&image_info->authenticate,argv[i+1]); | 
 | 6134 |             break; | 
 | 6135 |           } | 
 | 6136 |         break; | 
 | 6137 |       } | 
 | 6138 |       case 'b': | 
 | 6139 |       { | 
 | 6140 |         if (LocaleCompare("background",option+1) == 0) | 
 | 6141 |           { | 
 | 6142 |             if (*option == '+') | 
 | 6143 |               { | 
 | 6144 |                 (void) DeleteImageOption(image_info,option+1); | 
 | 6145 |                 (void) QueryColorDatabase(BackgroundColor, | 
 | 6146 |                   &image_info->background_color,exception); | 
 | 6147 |                 break; | 
 | 6148 |               } | 
 | 6149 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6150 |             (void) QueryColorDatabase(argv[i+1],&image_info->background_color, | 
 | 6151 |               exception); | 
 | 6152 |             break; | 
 | 6153 |           } | 
 | 6154 |         if (LocaleCompare("bias",option+1) == 0) | 
 | 6155 |           { | 
 | 6156 |             if (*option == '+') | 
 | 6157 |               { | 
 | 6158 |                 (void) SetImageOption(image_info,option+1,"0.0"); | 
 | 6159 |                 break; | 
 | 6160 |               } | 
 | 6161 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6162 |             break; | 
 | 6163 |           } | 
 | 6164 |         if (LocaleCompare("black-point-compensation",option+1) == 0) | 
 | 6165 |           { | 
 | 6166 |             if (*option == '+') | 
 | 6167 |               { | 
 | 6168 |                 (void) SetImageOption(image_info,option+1,"false"); | 
 | 6169 |                 break; | 
 | 6170 |               } | 
 | 6171 |             (void) SetImageOption(image_info,option+1,"true"); | 
 | 6172 |             break; | 
 | 6173 |           } | 
 | 6174 |         if (LocaleCompare("blue-primary",option+1) == 0) | 
 | 6175 |           { | 
 | 6176 |             if (*option == '+') | 
 | 6177 |               { | 
 | 6178 |                 (void) SetImageOption(image_info,option+1,"0.0"); | 
 | 6179 |                 break; | 
 | 6180 |               } | 
 | 6181 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6182 |             break; | 
 | 6183 |           } | 
 | 6184 |         if (LocaleCompare("bordercolor",option+1) == 0) | 
 | 6185 |           { | 
 | 6186 |             if (*option == '+') | 
 | 6187 |               { | 
 | 6188 |                 (void) DeleteImageOption(image_info,option+1); | 
 | 6189 |                 (void) QueryColorDatabase(BorderColor,&image_info->border_color, | 
 | 6190 |                   exception); | 
 | 6191 |                 break; | 
 | 6192 |               } | 
 | 6193 |             (void) QueryColorDatabase(argv[i+1],&image_info->border_color, | 
 | 6194 |               exception); | 
 | 6195 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6196 |             break; | 
 | 6197 |           } | 
 | 6198 |         if (LocaleCompare("box",option+1) == 0) | 
 | 6199 |           { | 
 | 6200 |             if (*option == '+') | 
 | 6201 |               { | 
 | 6202 |                 (void) SetImageOption(image_info,"undercolor","none"); | 
 | 6203 |                 break; | 
 | 6204 |               } | 
 | 6205 |             (void) SetImageOption(image_info,"undercolor",argv[i+1]); | 
 | 6206 |             break; | 
 | 6207 |           } | 
 | 6208 |         break; | 
 | 6209 |       } | 
 | 6210 |       case 'c': | 
 | 6211 |       { | 
 | 6212 |         if (LocaleCompare("cache",option+1) == 0) | 
 | 6213 |           { | 
 | 6214 |             MagickSizeType | 
 | 6215 |               limit; | 
 | 6216 |  | 
 | 6217 |             limit=MagickResourceInfinity; | 
 | 6218 |             if (LocaleCompare("unlimited",argv[i+1]) != 0) | 
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6219 |               limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6220 |             (void) SetMagickResourceLimit(MemoryResource,limit); | 
 | 6221 |             (void) SetMagickResourceLimit(MapResource,2*limit); | 
 | 6222 |             break; | 
 | 6223 |           } | 
 | 6224 |         if (LocaleCompare("caption",option+1) == 0) | 
 | 6225 |           { | 
 | 6226 |             if (*option == '+') | 
 | 6227 |               { | 
 | 6228 |                 (void) DeleteImageOption(image_info,option+1); | 
 | 6229 |                 break; | 
 | 6230 |               } | 
 | 6231 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6232 |             break; | 
 | 6233 |           } | 
 | 6234 |         if (LocaleCompare("channel",option+1) == 0) | 
 | 6235 |           { | 
 | 6236 |             if (*option == '+') | 
 | 6237 |               { | 
 | 6238 |                 image_info->channel=DefaultChannels; | 
 | 6239 |                 break; | 
 | 6240 |               } | 
 | 6241 |             image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); | 
 | 6242 |             break; | 
 | 6243 |           } | 
 | 6244 |         if (LocaleCompare("colors",option+1) == 0) | 
 | 6245 |           { | 
| cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6246 |             image_info->colors=StringToUnsignedLong(argv[i+1]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6247 |             break; | 
 | 6248 |           } | 
 | 6249 |         if (LocaleCompare("colorspace",option+1) == 0) | 
 | 6250 |           { | 
 | 6251 |             if (*option == '+') | 
 | 6252 |               { | 
 | 6253 |                 image_info->colorspace=UndefinedColorspace; | 
 | 6254 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6255 |                 break; | 
 | 6256 |               } | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6257 |             image_info->colorspace=(ColorspaceType) ParseCommandOption( | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6258 |               MagickColorspaceOptions,MagickFalse,argv[i+1]); | 
 | 6259 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6260 |             break; | 
 | 6261 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6262 |         if (LocaleCompare("comment",option+1) == 0) | 
 | 6263 |           { | 
 | 6264 |             if (*option == '+') | 
 | 6265 |               { | 
 | 6266 |                 (void) DeleteImageOption(image_info,option+1); | 
 | 6267 |                 break; | 
 | 6268 |               } | 
 | 6269 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6270 |             break; | 
 | 6271 |           } | 
 | 6272 |         if (LocaleCompare("compose",option+1) == 0) | 
 | 6273 |           { | 
 | 6274 |             if (*option == '+') | 
 | 6275 |               { | 
 | 6276 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6277 |                 break; | 
 | 6278 |               } | 
 | 6279 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6280 |             break; | 
 | 6281 |           } | 
 | 6282 |         if (LocaleCompare("compress",option+1) == 0) | 
 | 6283 |           { | 
 | 6284 |             if (*option == '+') | 
 | 6285 |               { | 
 | 6286 |                 image_info->compression=UndefinedCompression; | 
 | 6287 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6288 |                 break; | 
 | 6289 |               } | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6290 |             image_info->compression=(CompressionType) ParseCommandOption( | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6291 |               MagickCompressOptions,MagickFalse,argv[i+1]); | 
 | 6292 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6293 |             break; | 
 | 6294 |           } | 
 | 6295 |         break; | 
 | 6296 |       } | 
 | 6297 |       case 'd': | 
 | 6298 |       { | 
 | 6299 |         if (LocaleCompare("debug",option+1) == 0) | 
 | 6300 |           { | 
 | 6301 |             if (*option == '+') | 
 | 6302 |               (void) SetLogEventMask("none"); | 
 | 6303 |             else | 
 | 6304 |               (void) SetLogEventMask(argv[i+1]); | 
 | 6305 |             image_info->debug=IsEventLogging(); | 
 | 6306 |             break; | 
 | 6307 |           } | 
 | 6308 |         if (LocaleCompare("define",option+1) == 0) | 
 | 6309 |           { | 
 | 6310 |             if (*option == '+') | 
 | 6311 |               { | 
 | 6312 |                 if (LocaleNCompare(argv[i+1],"registry:",9) == 0) | 
 | 6313 |                   (void) DeleteImageRegistry(argv[i+1]+9); | 
 | 6314 |                 else | 
 | 6315 |                   (void) DeleteImageOption(image_info,argv[i+1]); | 
 | 6316 |                 break; | 
 | 6317 |               } | 
 | 6318 |             if (LocaleNCompare(argv[i+1],"registry:",9) == 0) | 
 | 6319 |               { | 
 | 6320 |                 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, | 
 | 6321 |                   exception); | 
 | 6322 |                 break; | 
 | 6323 |               } | 
 | 6324 |             (void) DefineImageOption(image_info,argv[i+1]); | 
 | 6325 |             break; | 
 | 6326 |           } | 
 | 6327 |         if (LocaleCompare("delay",option+1) == 0) | 
 | 6328 |           { | 
 | 6329 |             if (*option == '+') | 
 | 6330 |               { | 
 | 6331 |                 (void) SetImageOption(image_info,option+1,"0"); | 
 | 6332 |                 break; | 
 | 6333 |               } | 
 | 6334 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6335 |             break; | 
 | 6336 |           } | 
 | 6337 |         if (LocaleCompare("density",option+1) == 0) | 
 | 6338 |           { | 
 | 6339 |             /* | 
 | 6340 |               Set image density. | 
 | 6341 |             */ | 
 | 6342 |             if (*option == '+') | 
 | 6343 |               { | 
 | 6344 |                 if (image_info->density != (char *) NULL) | 
 | 6345 |                   image_info->density=DestroyString(image_info->density); | 
 | 6346 |                 (void) SetImageOption(image_info,option+1,"72"); | 
 | 6347 |                 break; | 
 | 6348 |               } | 
 | 6349 |             (void) CloneString(&image_info->density,argv[i+1]); | 
 | 6350 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6351 |             break; | 
 | 6352 |           } | 
 | 6353 |         if (LocaleCompare("depth",option+1) == 0) | 
 | 6354 |           { | 
 | 6355 |             if (*option == '+') | 
 | 6356 |               { | 
 | 6357 |                 image_info->depth=MAGICKCORE_QUANTUM_DEPTH; | 
 | 6358 |                 break; | 
 | 6359 |               } | 
| cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6360 |             image_info->depth=StringToUnsignedLong(argv[i+1]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6361 |             break; | 
 | 6362 |           } | 
| cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6363 |         if (LocaleCompare("direction",option+1) == 0) | 
 | 6364 |           { | 
 | 6365 |             if (*option == '+') | 
 | 6366 |               { | 
 | 6367 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6368 |                 break; | 
 | 6369 |               } | 
 | 6370 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6371 |             break; | 
 | 6372 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6373 |         if (LocaleCompare("display",option+1) == 0) | 
 | 6374 |           { | 
 | 6375 |             if (*option == '+') | 
 | 6376 |               { | 
 | 6377 |                 if (image_info->server_name != (char *) NULL) | 
 | 6378 |                   image_info->server_name=DestroyString( | 
 | 6379 |                     image_info->server_name); | 
 | 6380 |                 break; | 
 | 6381 |               } | 
 | 6382 |             (void) CloneString(&image_info->server_name,argv[i+1]); | 
 | 6383 |             break; | 
 | 6384 |           } | 
 | 6385 |         if (LocaleCompare("dispose",option+1) == 0) | 
 | 6386 |           { | 
 | 6387 |             if (*option == '+') | 
 | 6388 |               { | 
 | 6389 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6390 |                 break; | 
 | 6391 |               } | 
 | 6392 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6393 |             break; | 
 | 6394 |           } | 
 | 6395 |         if (LocaleCompare("dither",option+1) == 0) | 
 | 6396 |           { | 
 | 6397 |             if (*option == '+') | 
 | 6398 |               { | 
 | 6399 |                 image_info->dither=MagickFalse; | 
| cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6400 |                 (void) SetImageOption(image_info,option+1,"none"); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6401 |                 break; | 
 | 6402 |               } | 
 | 6403 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6404 |             image_info->dither=MagickTrue; | 
 | 6405 |             break; | 
 | 6406 |           } | 
 | 6407 |         break; | 
 | 6408 |       } | 
 | 6409 |       case 'e': | 
 | 6410 |       { | 
 | 6411 |         if (LocaleCompare("encoding",option+1) == 0) | 
 | 6412 |           { | 
 | 6413 |             if (*option == '+') | 
 | 6414 |               { | 
 | 6415 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6416 |                 break; | 
 | 6417 |               } | 
 | 6418 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6419 |             break; | 
 | 6420 |           } | 
 | 6421 |         if (LocaleCompare("endian",option+1) == 0) | 
 | 6422 |           { | 
 | 6423 |             if (*option == '+') | 
 | 6424 |               { | 
 | 6425 |                 image_info->endian=UndefinedEndian; | 
 | 6426 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6427 |                 break; | 
 | 6428 |               } | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6429 |             image_info->endian=(EndianType) ParseCommandOption( | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6430 |               MagickEndianOptions,MagickFalse,argv[i+1]); | 
 | 6431 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6432 |             break; | 
 | 6433 |           } | 
 | 6434 |         if (LocaleCompare("extract",option+1) == 0) | 
 | 6435 |           { | 
 | 6436 |             /* | 
 | 6437 |               Set image extract geometry. | 
 | 6438 |             */ | 
 | 6439 |             if (*option == '+') | 
 | 6440 |               { | 
 | 6441 |                 if (image_info->extract != (char *) NULL) | 
 | 6442 |                   image_info->extract=DestroyString(image_info->extract); | 
 | 6443 |                 break; | 
 | 6444 |               } | 
 | 6445 |             (void) CloneString(&image_info->extract,argv[i+1]); | 
 | 6446 |             break; | 
 | 6447 |           } | 
 | 6448 |         break; | 
 | 6449 |       } | 
 | 6450 |       case 'f': | 
 | 6451 |       { | 
 | 6452 |         if (LocaleCompare("fill",option+1) == 0) | 
 | 6453 |           { | 
 | 6454 |             if (*option == '+') | 
 | 6455 |               { | 
 | 6456 |                 (void) SetImageOption(image_info,option+1,"none"); | 
 | 6457 |                 break; | 
 | 6458 |               } | 
 | 6459 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6460 |             break; | 
 | 6461 |           } | 
 | 6462 |         if (LocaleCompare("filter",option+1) == 0) | 
 | 6463 |           { | 
 | 6464 |             if (*option == '+') | 
 | 6465 |               { | 
 | 6466 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6467 |                 break; | 
 | 6468 |               } | 
 | 6469 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6470 |             break; | 
 | 6471 |           } | 
 | 6472 |         if (LocaleCompare("font",option+1) == 0) | 
 | 6473 |           { | 
 | 6474 |             if (*option == '+') | 
 | 6475 |               { | 
 | 6476 |                 if (image_info->font != (char *) NULL) | 
 | 6477 |                   image_info->font=DestroyString(image_info->font); | 
 | 6478 |                 break; | 
 | 6479 |               } | 
 | 6480 |             (void) CloneString(&image_info->font,argv[i+1]); | 
 | 6481 |             break; | 
 | 6482 |           } | 
 | 6483 |         if (LocaleCompare("format",option+1) == 0) | 
 | 6484 |           { | 
 | 6485 |             register const char | 
 | 6486 |               *q; | 
 | 6487 |  | 
 | 6488 |             for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) | 
| cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6489 |               if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6490 |                 image_info->ping=MagickFalse; | 
 | 6491 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6492 |             break; | 
 | 6493 |           } | 
 | 6494 |         if (LocaleCompare("fuzz",option+1) == 0) | 
 | 6495 |           { | 
 | 6496 |             if (*option == '+') | 
 | 6497 |               { | 
 | 6498 |                 image_info->fuzz=0.0; | 
 | 6499 |                 (void) SetImageOption(image_info,option+1,"0"); | 
 | 6500 |                 break; | 
 | 6501 |               } | 
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6502 |             image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6503 |               1.0); | 
 | 6504 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6505 |             break; | 
 | 6506 |           } | 
 | 6507 |         break; | 
 | 6508 |       } | 
 | 6509 |       case 'g': | 
 | 6510 |       { | 
 | 6511 |         if (LocaleCompare("gravity",option+1) == 0) | 
 | 6512 |           { | 
 | 6513 |             if (*option == '+') | 
 | 6514 |               { | 
 | 6515 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6516 |                 break; | 
 | 6517 |               } | 
 | 6518 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6519 |             break; | 
 | 6520 |           } | 
 | 6521 |         if (LocaleCompare("green-primary",option+1) == 0) | 
 | 6522 |           { | 
 | 6523 |             if (*option == '+') | 
 | 6524 |               { | 
 | 6525 |                 (void) SetImageOption(image_info,option+1,"0.0"); | 
 | 6526 |                 break; | 
 | 6527 |               } | 
 | 6528 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6529 |             break; | 
 | 6530 |           } | 
 | 6531 |         break; | 
 | 6532 |       } | 
 | 6533 |       case 'i': | 
 | 6534 |       { | 
 | 6535 |         if (LocaleCompare("intent",option+1) == 0) | 
 | 6536 |           { | 
 | 6537 |             if (*option == '+') | 
 | 6538 |               { | 
 | 6539 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6540 |                 break; | 
 | 6541 |               } | 
 | 6542 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6543 |             break; | 
 | 6544 |           } | 
 | 6545 |         if (LocaleCompare("interlace",option+1) == 0) | 
 | 6546 |           { | 
 | 6547 |             if (*option == '+') | 
 | 6548 |               { | 
 | 6549 |                 image_info->interlace=UndefinedInterlace; | 
 | 6550 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6551 |                 break; | 
 | 6552 |               } | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6553 |             image_info->interlace=(InterlaceType) ParseCommandOption( | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6554 |               MagickInterlaceOptions,MagickFalse,argv[i+1]); | 
 | 6555 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6556 |             break; | 
 | 6557 |           } | 
| cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6558 |         if (LocaleCompare("interline-spacing",option+1) == 0) | 
 | 6559 |           { | 
 | 6560 |             if (*option == '+') | 
 | 6561 |               { | 
 | 6562 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6563 |                 break; | 
 | 6564 |               } | 
 | 6565 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6566 |             break; | 
 | 6567 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6568 |         if (LocaleCompare("interpolate",option+1) == 0) | 
 | 6569 |           { | 
 | 6570 |             if (*option == '+') | 
 | 6571 |               { | 
 | 6572 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6573 |                 break; | 
 | 6574 |               } | 
 | 6575 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6576 |             break; | 
 | 6577 |           } | 
 | 6578 |         if (LocaleCompare("interword-spacing",option+1) == 0) | 
 | 6579 |           { | 
 | 6580 |             if (*option == '+') | 
 | 6581 |               { | 
 | 6582 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6583 |                 break; | 
 | 6584 |               } | 
 | 6585 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6586 |             break; | 
 | 6587 |           } | 
 | 6588 |         break; | 
 | 6589 |       } | 
 | 6590 |       case 'k': | 
 | 6591 |       { | 
 | 6592 |         if (LocaleCompare("kerning",option+1) == 0) | 
 | 6593 |           { | 
 | 6594 |             if (*option == '+') | 
 | 6595 |               { | 
 | 6596 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6597 |                 break; | 
 | 6598 |               } | 
 | 6599 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6600 |             break; | 
 | 6601 |           } | 
 | 6602 |         break; | 
 | 6603 |       } | 
 | 6604 |       case 'l': | 
 | 6605 |       { | 
 | 6606 |         if (LocaleCompare("label",option+1) == 0) | 
 | 6607 |           { | 
 | 6608 |             if (*option == '+') | 
 | 6609 |               { | 
 | 6610 |                 (void) DeleteImageOption(image_info,option+1); | 
 | 6611 |                 break; | 
 | 6612 |               } | 
 | 6613 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6614 |             break; | 
 | 6615 |           } | 
 | 6616 |         if (LocaleCompare("limit",option+1) == 0) | 
 | 6617 |           { | 
 | 6618 |             MagickSizeType | 
 | 6619 |               limit; | 
 | 6620 |  | 
 | 6621 |             ResourceType | 
 | 6622 |               type; | 
 | 6623 |  | 
 | 6624 |             if (*option == '+') | 
 | 6625 |               break; | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6626 |             type=(ResourceType) ParseCommandOption(MagickResourceOptions, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6627 |               MagickFalse,argv[i+1]); | 
 | 6628 |             limit=MagickResourceInfinity; | 
 | 6629 |             if (LocaleCompare("unlimited",argv[i+2]) != 0) | 
| cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6630 |               limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6631 |             (void) SetMagickResourceLimit(type,limit); | 
 | 6632 |             break; | 
 | 6633 |           } | 
 | 6634 |         if (LocaleCompare("list",option+1) == 0) | 
 | 6635 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6636 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6637 |               list; | 
 | 6638 |  | 
 | 6639 |             /* | 
 | 6640 |               Display configuration list. | 
 | 6641 |             */ | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6642 |             list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6643 |             switch (list) | 
 | 6644 |             { | 
 | 6645 |               case MagickCoderOptions: | 
 | 6646 |               { | 
 | 6647 |                 (void) ListCoderInfo((FILE *) NULL,exception); | 
 | 6648 |                 break; | 
 | 6649 |               } | 
 | 6650 |               case MagickColorOptions: | 
 | 6651 |               { | 
 | 6652 |                 (void) ListColorInfo((FILE *) NULL,exception); | 
 | 6653 |                 break; | 
 | 6654 |               } | 
 | 6655 |               case MagickConfigureOptions: | 
 | 6656 |               { | 
 | 6657 |                 (void) ListConfigureInfo((FILE *) NULL,exception); | 
 | 6658 |                 break; | 
 | 6659 |               } | 
 | 6660 |               case MagickDelegateOptions: | 
 | 6661 |               { | 
 | 6662 |                 (void) ListDelegateInfo((FILE *) NULL,exception); | 
 | 6663 |                 break; | 
 | 6664 |               } | 
 | 6665 |               case MagickFontOptions: | 
 | 6666 |               { | 
 | 6667 |                 (void) ListTypeInfo((FILE *) NULL,exception); | 
 | 6668 |                 break; | 
 | 6669 |               } | 
 | 6670 |               case MagickFormatOptions: | 
 | 6671 |               { | 
 | 6672 |                 (void) ListMagickInfo((FILE *) NULL,exception); | 
 | 6673 |                 break; | 
 | 6674 |               } | 
 | 6675 |               case MagickLocaleOptions: | 
 | 6676 |               { | 
 | 6677 |                 (void) ListLocaleInfo((FILE *) NULL,exception); | 
 | 6678 |                 break; | 
 | 6679 |               } | 
 | 6680 |               case MagickLogOptions: | 
 | 6681 |               { | 
 | 6682 |                 (void) ListLogInfo((FILE *) NULL,exception); | 
 | 6683 |                 break; | 
 | 6684 |               } | 
 | 6685 |               case MagickMagicOptions: | 
 | 6686 |               { | 
 | 6687 |                 (void) ListMagicInfo((FILE *) NULL,exception); | 
 | 6688 |                 break; | 
 | 6689 |               } | 
 | 6690 |               case MagickMimeOptions: | 
 | 6691 |               { | 
 | 6692 |                 (void) ListMimeInfo((FILE *) NULL,exception); | 
 | 6693 |                 break; | 
 | 6694 |               } | 
 | 6695 |               case MagickModuleOptions: | 
 | 6696 |               { | 
 | 6697 |                 (void) ListModuleInfo((FILE *) NULL,exception); | 
 | 6698 |                 break; | 
 | 6699 |               } | 
 | 6700 |               case MagickPolicyOptions: | 
 | 6701 |               { | 
 | 6702 |                 (void) ListPolicyInfo((FILE *) NULL,exception); | 
 | 6703 |                 break; | 
 | 6704 |               } | 
 | 6705 |               case MagickResourceOptions: | 
 | 6706 |               { | 
 | 6707 |                 (void) ListMagickResourceInfo((FILE *) NULL,exception); | 
 | 6708 |                 break; | 
 | 6709 |               } | 
 | 6710 |               case MagickThresholdOptions: | 
 | 6711 |               { | 
 | 6712 |                 (void) ListThresholdMaps((FILE *) NULL,exception); | 
 | 6713 |                 break; | 
 | 6714 |               } | 
 | 6715 |               default: | 
 | 6716 |               { | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6717 |                 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6718 |                   exception); | 
 | 6719 |                 break; | 
 | 6720 |               } | 
 | 6721 |             } | 
| cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6722 |             break; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6723 |           } | 
 | 6724 |         if (LocaleCompare("log",option+1) == 0) | 
 | 6725 |           { | 
 | 6726 |             if (*option == '+') | 
 | 6727 |               break; | 
 | 6728 |             (void) SetLogFormat(argv[i+1]); | 
 | 6729 |             break; | 
 | 6730 |           } | 
 | 6731 |         if (LocaleCompare("loop",option+1) == 0) | 
 | 6732 |           { | 
 | 6733 |             if (*option == '+') | 
 | 6734 |               { | 
 | 6735 |                 (void) SetImageOption(image_info,option+1,"0"); | 
 | 6736 |                 break; | 
 | 6737 |               } | 
 | 6738 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6739 |             break; | 
 | 6740 |           } | 
 | 6741 |         break; | 
 | 6742 |       } | 
 | 6743 |       case 'm': | 
 | 6744 |       { | 
 | 6745 |         if (LocaleCompare("matte",option+1) == 0) | 
 | 6746 |           { | 
 | 6747 |             if (*option == '+') | 
 | 6748 |               { | 
 | 6749 |                 (void) SetImageOption(image_info,option+1,"false"); | 
 | 6750 |                 break; | 
 | 6751 |               } | 
 | 6752 |             (void) SetImageOption(image_info,option+1,"true"); | 
 | 6753 |             break; | 
 | 6754 |           } | 
 | 6755 |         if (LocaleCompare("mattecolor",option+1) == 0) | 
 | 6756 |           { | 
 | 6757 |             if (*option == '+') | 
 | 6758 |               { | 
 | 6759 |                 (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6760 |                 (void) QueryColorDatabase(MatteColor,&image_info->matte_color, | 
 | 6761 |                   exception); | 
 | 6762 |                 break; | 
 | 6763 |               } | 
 | 6764 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6765 |             (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, | 
 | 6766 |               exception); | 
 | 6767 |             break; | 
 | 6768 |           } | 
 | 6769 |         if (LocaleCompare("monitor",option+1) == 0) | 
 | 6770 |           { | 
 | 6771 |             (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, | 
 | 6772 |               (void *) NULL); | 
 | 6773 |             break; | 
 | 6774 |           } | 
 | 6775 |         if (LocaleCompare("monochrome",option+1) == 0) | 
 | 6776 |           { | 
 | 6777 |             image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; | 
 | 6778 |             break; | 
 | 6779 |           } | 
 | 6780 |         break; | 
 | 6781 |       } | 
 | 6782 |       case 'o': | 
 | 6783 |       { | 
 | 6784 |         if (LocaleCompare("orient",option+1) == 0) | 
 | 6785 |           { | 
 | 6786 |             if (*option == '+') | 
 | 6787 |               { | 
 | 6788 |                 image_info->orientation=UndefinedOrientation; | 
 | 6789 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 6790 |                 break; | 
 | 6791 |               } | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6792 |             image_info->orientation=(OrientationType) ParseCommandOption( | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6793 |               MagickOrientationOptions,MagickFalse,argv[i+1]); | 
| cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6794 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6795 |             break; | 
 | 6796 |           } | 
 | 6797 |       } | 
 | 6798 |       case 'p': | 
 | 6799 |       { | 
 | 6800 |         if (LocaleCompare("page",option+1) == 0) | 
 | 6801 |           { | 
 | 6802 |             char | 
 | 6803 |               *canonical_page, | 
 | 6804 |               page[MaxTextExtent]; | 
 | 6805 |  | 
 | 6806 |             const char | 
 | 6807 |               *image_option; | 
 | 6808 |  | 
 | 6809 |             MagickStatusType | 
 | 6810 |               flags; | 
 | 6811 |  | 
 | 6812 |             RectangleInfo | 
 | 6813 |               geometry; | 
 | 6814 |  | 
 | 6815 |             if (*option == '+') | 
 | 6816 |               { | 
 | 6817 |                 (void) DeleteImageOption(image_info,option+1); | 
 | 6818 |                 (void) CloneString(&image_info->page,(char *) NULL); | 
 | 6819 |                 break; | 
 | 6820 |               } | 
 | 6821 |             (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); | 
 | 6822 |             image_option=GetImageOption(image_info,"page"); | 
 | 6823 |             if (image_option != (const char *) NULL) | 
 | 6824 |               flags=ParseAbsoluteGeometry(image_option,&geometry); | 
 | 6825 |             canonical_page=GetPageGeometry(argv[i+1]); | 
 | 6826 |             flags=ParseAbsoluteGeometry(canonical_page,&geometry); | 
 | 6827 |             canonical_page=DestroyString(canonical_page); | 
| cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6828 |             (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", | 
| cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6829 |               (unsigned long) geometry.width,(unsigned long) geometry.height); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6830 |             if (((flags & XValue) != 0) || ((flags & YValue) != 0)) | 
| cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 6831 |               (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", | 
| cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6832 |                 (unsigned long) geometry.width,(unsigned long) geometry.height, | 
 | 6833 |                 (long) geometry.x,(long) geometry.y); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6834 |             (void) SetImageOption(image_info,option+1,page); | 
 | 6835 |             (void) CloneString(&image_info->page,page); | 
 | 6836 |             break; | 
 | 6837 |           } | 
 | 6838 |         if (LocaleCompare("pen",option+1) == 0) | 
 | 6839 |           { | 
 | 6840 |             if (*option == '+') | 
 | 6841 |               { | 
 | 6842 |                 (void) SetImageOption(image_info,option+1,"none"); | 
 | 6843 |                 break; | 
 | 6844 |               } | 
 | 6845 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6846 |             break; | 
 | 6847 |           } | 
 | 6848 |         if (LocaleCompare("ping",option+1) == 0) | 
 | 6849 |           { | 
 | 6850 |             image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; | 
 | 6851 |             break; | 
 | 6852 |           } | 
 | 6853 |         if (LocaleCompare("pointsize",option+1) == 0) | 
 | 6854 |           { | 
 | 6855 |             if (*option == '+') | 
 | 6856 |               geometry_info.rho=0.0; | 
 | 6857 |             else | 
 | 6858 |               (void) ParseGeometry(argv[i+1],&geometry_info); | 
 | 6859 |             image_info->pointsize=geometry_info.rho; | 
 | 6860 |             break; | 
 | 6861 |           } | 
| cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6862 |         if (LocaleCompare("precision",option+1) == 0) | 
 | 6863 |           { | 
| cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6864 |             (void) SetMagickPrecision(StringToInteger(argv[i+1])); | 
| cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6865 |             break; | 
 | 6866 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6867 |         if (LocaleCompare("preview",option+1) == 0) | 
 | 6868 |           { | 
 | 6869 |             /* | 
 | 6870 |               Preview image. | 
 | 6871 |             */ | 
 | 6872 |             if (*option == '+') | 
 | 6873 |               { | 
 | 6874 |                 image_info->preview_type=UndefinedPreview; | 
 | 6875 |                 break; | 
 | 6876 |               } | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6877 |             image_info->preview_type=(PreviewType) ParseCommandOption( | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6878 |               MagickPreviewOptions,MagickFalse,argv[i+1]); | 
 | 6879 |             break; | 
 | 6880 |           } | 
 | 6881 |         break; | 
 | 6882 |       } | 
 | 6883 |       case 'q': | 
 | 6884 |       { | 
 | 6885 |         if (LocaleCompare("quality",option+1) == 0) | 
 | 6886 |           { | 
 | 6887 |             /* | 
 | 6888 |               Set image compression quality. | 
 | 6889 |             */ | 
 | 6890 |             if (*option == '+') | 
 | 6891 |               { | 
 | 6892 |                 image_info->quality=UndefinedCompressionQuality; | 
 | 6893 |                 (void) SetImageOption(image_info,option+1,"0"); | 
 | 6894 |                 break; | 
 | 6895 |               } | 
| cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6896 |             image_info->quality=StringToUnsignedLong(argv[i+1]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6897 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6898 |             break; | 
 | 6899 |           } | 
 | 6900 |         if (LocaleCompare("quiet",option+1) == 0) | 
 | 6901 |           { | 
 | 6902 |             static WarningHandler | 
 | 6903 |               warning_handler = (WarningHandler) NULL; | 
 | 6904 |  | 
 | 6905 |             if (*option == '+') | 
 | 6906 |               { | 
 | 6907 |                 /* | 
 | 6908 |                   Restore error or warning messages. | 
 | 6909 |                 */ | 
 | 6910 |                 warning_handler=SetWarningHandler(warning_handler); | 
 | 6911 |                 break; | 
 | 6912 |               } | 
 | 6913 |             /* | 
 | 6914 |               Suppress error or warning messages. | 
 | 6915 |             */ | 
 | 6916 |             warning_handler=SetWarningHandler((WarningHandler) NULL); | 
 | 6917 |             break; | 
 | 6918 |           } | 
 | 6919 |         break; | 
 | 6920 |       } | 
 | 6921 |       case 'r': | 
 | 6922 |       { | 
 | 6923 |         if (LocaleCompare("red-primary",option+1) == 0) | 
 | 6924 |           { | 
 | 6925 |             if (*option == '+') | 
 | 6926 |               { | 
 | 6927 |                 (void) SetImageOption(image_info,option+1,"0.0"); | 
 | 6928 |                 break; | 
 | 6929 |               } | 
 | 6930 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6931 |             break; | 
 | 6932 |           } | 
 | 6933 |         break; | 
 | 6934 |       } | 
 | 6935 |       case 's': | 
 | 6936 |       { | 
 | 6937 |         if (LocaleCompare("sampling-factor",option+1) == 0) | 
 | 6938 |           { | 
 | 6939 |             /* | 
 | 6940 |               Set image sampling factor. | 
 | 6941 |             */ | 
 | 6942 |             if (*option == '+') | 
 | 6943 |               { | 
 | 6944 |                 if (image_info->sampling_factor != (char *) NULL) | 
 | 6945 |                   image_info->sampling_factor=DestroyString( | 
 | 6946 |                     image_info->sampling_factor); | 
 | 6947 |                 break; | 
 | 6948 |               } | 
 | 6949 |             (void) CloneString(&image_info->sampling_factor,argv[i+1]); | 
 | 6950 |             break; | 
 | 6951 |           } | 
 | 6952 |         if (LocaleCompare("scene",option+1) == 0) | 
 | 6953 |           { | 
 | 6954 |             /* | 
 | 6955 |               Set image scene. | 
 | 6956 |             */ | 
 | 6957 |             if (*option == '+') | 
 | 6958 |               { | 
 | 6959 |                 image_info->scene=0; | 
 | 6960 |                 (void) SetImageOption(image_info,option+1,"0"); | 
 | 6961 |                 break; | 
 | 6962 |               } | 
| cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6963 |             image_info->scene=StringToUnsignedLong(argv[i+1]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6964 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 6965 |             break; | 
 | 6966 |           } | 
 | 6967 |         if (LocaleCompare("seed",option+1) == 0) | 
 | 6968 |           { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6969 |             size_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6970 |               seed; | 
 | 6971 |  | 
 | 6972 |             if (*option == '+') | 
 | 6973 |               { | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6974 |                 seed=(size_t) time((time_t *) NULL); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6975 |                 SeedPseudoRandomGenerator(seed); | 
 | 6976 |                 break; | 
 | 6977 |               } | 
| cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6978 |             seed=StringToUnsignedLong(argv[i+1]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6979 |             SeedPseudoRandomGenerator(seed); | 
 | 6980 |             break; | 
 | 6981 |           } | 
 | 6982 |         if (LocaleCompare("size",option+1) == 0) | 
 | 6983 |           { | 
 | 6984 |             if (*option == '+') | 
 | 6985 |               { | 
 | 6986 |                 if (image_info->size != (char *) NULL) | 
 | 6987 |                   image_info->size=DestroyString(image_info->size); | 
 | 6988 |                 break; | 
 | 6989 |               } | 
 | 6990 |             (void) CloneString(&image_info->size,argv[i+1]); | 
 | 6991 |             break; | 
 | 6992 |           } | 
 | 6993 |         if (LocaleCompare("stroke",option+1) == 0) | 
 | 6994 |           { | 
 | 6995 |             if (*option == '+') | 
 | 6996 |               { | 
 | 6997 |                 (void) SetImageOption(image_info,option+1,"none"); | 
 | 6998 |                 break; | 
 | 6999 |               } | 
 | 7000 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 7001 |             break; | 
 | 7002 |           } | 
 | 7003 |         if (LocaleCompare("strokewidth",option+1) == 0) | 
 | 7004 |           { | 
 | 7005 |             if (*option == '+') | 
 | 7006 |               { | 
 | 7007 |                 (void) SetImageOption(image_info,option+1,"0"); | 
 | 7008 |                 break; | 
 | 7009 |               } | 
 | 7010 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 7011 |             break; | 
 | 7012 |           } | 
| cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7013 |         if (LocaleCompare("synchronize",option+1) == 0) | 
 | 7014 |           { | 
 | 7015 |             if (*option == '+') | 
 | 7016 |               { | 
 | 7017 |                 image_info->synchronize=MagickFalse; | 
 | 7018 |                 break; | 
 | 7019 |               } | 
 | 7020 |             image_info->synchronize=MagickTrue; | 
 | 7021 |             break; | 
 | 7022 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7023 |         break; | 
 | 7024 |       } | 
 | 7025 |       case 't': | 
 | 7026 |       { | 
 | 7027 |         if (LocaleCompare("taint",option+1) == 0) | 
 | 7028 |           { | 
 | 7029 |             if (*option == '+') | 
 | 7030 |               { | 
 | 7031 |                 (void) SetImageOption(image_info,option+1,"false"); | 
 | 7032 |                 break; | 
 | 7033 |               } | 
 | 7034 |             (void) SetImageOption(image_info,option+1,"true"); | 
 | 7035 |             break; | 
 | 7036 |           } | 
 | 7037 |         if (LocaleCompare("texture",option+1) == 0) | 
 | 7038 |           { | 
 | 7039 |             if (*option == '+') | 
 | 7040 |               { | 
 | 7041 |                 if (image_info->texture != (char *) NULL) | 
 | 7042 |                   image_info->texture=DestroyString(image_info->texture); | 
 | 7043 |                 break; | 
 | 7044 |               } | 
 | 7045 |             (void) CloneString(&image_info->texture,argv[i+1]); | 
 | 7046 |             break; | 
 | 7047 |           } | 
 | 7048 |         if (LocaleCompare("tile-offset",option+1) == 0) | 
 | 7049 |           { | 
 | 7050 |             if (*option == '+') | 
 | 7051 |               { | 
 | 7052 |                 (void) SetImageOption(image_info,option+1,"0"); | 
 | 7053 |                 break; | 
 | 7054 |               } | 
 | 7055 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 7056 |             break; | 
 | 7057 |           } | 
 | 7058 |         if (LocaleCompare("transparent-color",option+1) == 0) | 
 | 7059 |           { | 
 | 7060 |             if (*option == '+') | 
 | 7061 |               { | 
 | 7062 |                 (void) QueryColorDatabase("none",&image_info->transparent_color,                  exception); | 
 | 7063 |                 (void) SetImageOption(image_info,option+1,"none"); | 
 | 7064 |                 break; | 
 | 7065 |               } | 
 | 7066 |             (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, | 
 | 7067 |               exception); | 
 | 7068 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 7069 |             break; | 
 | 7070 |           } | 
 | 7071 |         if (LocaleCompare("type",option+1) == 0) | 
 | 7072 |           { | 
 | 7073 |             if (*option == '+') | 
 | 7074 |               { | 
| cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7075 |                 image_info->type=UndefinedType; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7076 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 7077 |                 break; | 
 | 7078 |               } | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7079 |             image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7080 |               MagickFalse,argv[i+1]); | 
 | 7081 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 7082 |             break; | 
 | 7083 |           } | 
 | 7084 |         break; | 
 | 7085 |       } | 
 | 7086 |       case 'u': | 
 | 7087 |       { | 
 | 7088 |         if (LocaleCompare("undercolor",option+1) == 0) | 
 | 7089 |           { | 
 | 7090 |             if (*option == '+') | 
 | 7091 |               { | 
 | 7092 |                 (void) DeleteImageOption(image_info,option+1); | 
 | 7093 |                 break; | 
 | 7094 |               } | 
 | 7095 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 7096 |             break; | 
 | 7097 |           } | 
 | 7098 |         if (LocaleCompare("units",option+1) == 0) | 
 | 7099 |           { | 
 | 7100 |             if (*option == '+') | 
 | 7101 |               { | 
 | 7102 |                 image_info->units=UndefinedResolution; | 
 | 7103 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 7104 |                 break; | 
 | 7105 |               } | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7106 |             image_info->units=(ResolutionType) ParseCommandOption( | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7107 |               MagickResolutionOptions,MagickFalse,argv[i+1]); | 
 | 7108 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 7109 |             break; | 
 | 7110 |           } | 
 | 7111 |         break; | 
 | 7112 |       } | 
 | 7113 |       case 'v': | 
 | 7114 |       { | 
 | 7115 |         if (LocaleCompare("verbose",option+1) == 0) | 
 | 7116 |           { | 
 | 7117 |             if (*option == '+') | 
 | 7118 |               { | 
 | 7119 |                 image_info->verbose=MagickFalse; | 
 | 7120 |                 break; | 
 | 7121 |               } | 
 | 7122 |             image_info->verbose=MagickTrue; | 
 | 7123 |             image_info->ping=MagickFalse; | 
 | 7124 |             break; | 
 | 7125 |           } | 
 | 7126 |         if (LocaleCompare("view",option+1) == 0) | 
 | 7127 |           { | 
 | 7128 |             if (*option == '+') | 
 | 7129 |               { | 
 | 7130 |                 if (image_info->view != (char *) NULL) | 
 | 7131 |                   image_info->view=DestroyString(image_info->view); | 
 | 7132 |                 break; | 
 | 7133 |               } | 
 | 7134 |             (void) CloneString(&image_info->view,argv[i+1]); | 
 | 7135 |             break; | 
 | 7136 |           } | 
 | 7137 |         if (LocaleCompare("virtual-pixel",option+1) == 0) | 
 | 7138 |           { | 
 | 7139 |             if (*option == '+') | 
 | 7140 |               { | 
 | 7141 |                 image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; | 
 | 7142 |                 (void) SetImageOption(image_info,option+1,"undefined"); | 
 | 7143 |                 break; | 
 | 7144 |               } | 
 | 7145 |             image_info->virtual_pixel_method=(VirtualPixelMethod) | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7146 |               ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7147 |               argv[i+1]); | 
 | 7148 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 7149 |             break; | 
 | 7150 |           } | 
 | 7151 |         break; | 
 | 7152 |       } | 
 | 7153 |       case 'w': | 
 | 7154 |       { | 
 | 7155 |         if (LocaleCompare("white-point",option+1) == 0) | 
 | 7156 |           { | 
 | 7157 |             if (*option == '+') | 
 | 7158 |               { | 
 | 7159 |                 (void) SetImageOption(image_info,option+1,"0.0"); | 
 | 7160 |                 break; | 
 | 7161 |               } | 
 | 7162 |             (void) SetImageOption(image_info,option+1,argv[i+1]); | 
 | 7163 |             break; | 
 | 7164 |           } | 
 | 7165 |         break; | 
 | 7166 |       } | 
 | 7167 |       default: | 
 | 7168 |         break; | 
 | 7169 |     } | 
 | 7170 |     i+=count; | 
 | 7171 |   } | 
 | 7172 |   return(MagickTrue); | 
 | 7173 | } | 
 | 7174 |  | 
 | 7175 | /* | 
 | 7176 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 7177 | %                                                                             % | 
 | 7178 | %                                                                             % | 
 | 7179 | %                                                                             % | 
 | 7180 | +     M o g r i f y I m a g e L i s t                                         % | 
 | 7181 | %                                                                             % | 
 | 7182 | %                                                                             % | 
 | 7183 | %                                                                             % | 
 | 7184 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 7185 | % | 
 | 7186 | %  MogrifyImageList() applies any command line options that might affect the | 
 | 7187 | %  entire image list (e.g. -append, -coalesce, etc.). | 
 | 7188 | % | 
 | 7189 | %  The format of the MogrifyImage method is: | 
 | 7190 | % | 
 | 7191 | %      MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, | 
 | 7192 | %        const char **argv,Image **images,ExceptionInfo *exception) | 
 | 7193 | % | 
 | 7194 | %  A description of each parameter follows: | 
 | 7195 | % | 
 | 7196 | %    o image_info: the image info.. | 
 | 7197 | % | 
 | 7198 | %    o argc: Specifies a pointer to an integer describing the number of | 
 | 7199 | %      elements in the argument vector. | 
 | 7200 | % | 
 | 7201 | %    o argv: Specifies a pointer to a text array containing the command line | 
 | 7202 | %      arguments. | 
 | 7203 | % | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7204 | %    o images: pointer to pointer of the first image in image list. | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7205 | % | 
 | 7206 | %    o exception: return any errors or warnings in this structure. | 
 | 7207 | % | 
 | 7208 | */ | 
 | 7209 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, | 
 | 7210 |   const int argc,const char **argv,Image **images,ExceptionInfo *exception) | 
 | 7211 | { | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7212 |   const char | 
 | 7213 |     *option; | 
 | 7214 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7215 |   ImageInfo | 
 | 7216 |     *mogrify_info; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7217 |  | 
 | 7218 |   MagickStatusType | 
 | 7219 |     status; | 
 | 7220 |  | 
 | 7221 |   QuantizeInfo | 
 | 7222 |     *quantize_info; | 
 | 7223 |  | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7224 |   register ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7225 |     i; | 
 | 7226 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7227 |   ssize_t | 
 | 7228 |     count, | 
 | 7229 |     index; | 
 | 7230 |  | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7231 |   /* | 
 | 7232 |     Apply options to the image list. | 
 | 7233 |   */ | 
 | 7234 |   assert(image_info != (ImageInfo *) NULL); | 
 | 7235 |   assert(image_info->signature == MagickSignature); | 
 | 7236 |   assert(images != (Image **) NULL); | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7237 |   assert((*images)->previous == (Image *) NULL); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7238 |   assert((*images)->signature == MagickSignature); | 
 | 7239 |   if ((*images)->debug != MagickFalse) | 
 | 7240 |     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", | 
 | 7241 |       (*images)->filename); | 
 | 7242 |   if ((argc <= 0) || (*argv == (char *) NULL)) | 
 | 7243 |     return(MagickTrue); | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7244 |   mogrify_info=CloneImageInfo(image_info); | 
 | 7245 |   quantize_info=AcquireQuantizeInfo(mogrify_info); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7246 |   status=MagickTrue; | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7247 |   for (i=0; i < (ssize_t) argc; i++) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7248 |   { | 
| cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7249 |     if (*images == (Image *) NULL) | 
 | 7250 |       break; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7251 |     option=argv[i]; | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7252 |     if (IsCommandOption(option) == MagickFalse) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7253 |       continue; | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7254 |     count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); | 
| anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7255 |     count=MagickMax(count,0L); | 
| cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7256 |     if ((i+count) >= (ssize_t) argc) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7257 |       break; | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7258 |     status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7259 |     switch (*(option+1)) | 
 | 7260 |     { | 
 | 7261 |       case 'a': | 
 | 7262 |       { | 
 | 7263 |         if (LocaleCompare("affinity",option+1) == 0) | 
 | 7264 |           { | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7265 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7266 |             if (*option == '+') | 
 | 7267 |               { | 
 | 7268 |                 (void) RemapImages(quantize_info,*images,(Image *) NULL); | 
 | 7269 |                 InheritException(exception,&(*images)->exception); | 
 | 7270 |                 break; | 
 | 7271 |               } | 
 | 7272 |             i++; | 
 | 7273 |             break; | 
 | 7274 |           } | 
 | 7275 |         if (LocaleCompare("append",option+1) == 0) | 
 | 7276 |           { | 
 | 7277 |             Image | 
 | 7278 |               *append_image; | 
 | 7279 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7280 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7281 |             append_image=AppendImages(*images,*option == '-' ? MagickTrue : | 
 | 7282 |               MagickFalse,exception); | 
 | 7283 |             if (append_image == (Image *) NULL) | 
 | 7284 |               { | 
 | 7285 |                 status=MagickFalse; | 
 | 7286 |                 break; | 
 | 7287 |               } | 
 | 7288 |             *images=DestroyImageList(*images); | 
 | 7289 |             *images=append_image; | 
 | 7290 |             break; | 
 | 7291 |           } | 
 | 7292 |         if (LocaleCompare("average",option+1) == 0) | 
 | 7293 |           { | 
 | 7294 |             Image | 
 | 7295 |               *average_image; | 
 | 7296 |  | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7297 |             /* | 
 | 7298 |               Average an image sequence (deprecated). | 
 | 7299 |             */ | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7300 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7301 |             average_image=EvaluateImages(*images,MeanEvaluateOperator, | 
 | 7302 |               exception); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7303 |             if (average_image == (Image *) NULL) | 
 | 7304 |               { | 
 | 7305 |                 status=MagickFalse; | 
 | 7306 |                 break; | 
 | 7307 |               } | 
 | 7308 |             *images=DestroyImageList(*images); | 
 | 7309 |             *images=average_image; | 
 | 7310 |             break; | 
 | 7311 |           } | 
 | 7312 |         break; | 
 | 7313 |       } | 
 | 7314 |       case 'c': | 
 | 7315 |       { | 
 | 7316 |         if (LocaleCompare("channel",option+1) == 0) | 
 | 7317 |           { | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7318 |             ChannelType | 
 | 7319 |               channel; | 
 | 7320 |  | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7321 |             if (*option == '+') | 
 | 7322 |               { | 
 | 7323 |                 channel=DefaultChannels; | 
 | 7324 |                 break; | 
 | 7325 |               } | 
 | 7326 |             channel=(ChannelType) ParseChannelOption(argv[i+1]); | 
| cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 7327 |             SetPixelChannelMap(*images,channel); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7328 |             break; | 
 | 7329 |           } | 
 | 7330 |         if (LocaleCompare("clut",option+1) == 0) | 
 | 7331 |           { | 
 | 7332 |             Image | 
 | 7333 |               *clut_image, | 
 | 7334 |               *image; | 
 | 7335 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7336 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7337 |             image=RemoveFirstImageFromList(images); | 
 | 7338 |             clut_image=RemoveFirstImageFromList(images); | 
 | 7339 |             if (clut_image == (Image *) NULL) | 
 | 7340 |               { | 
 | 7341 |                 status=MagickFalse; | 
 | 7342 |                 break; | 
 | 7343 |               } | 
| cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 7344 |             (void) ClutImage(image,clut_image); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7345 |             clut_image=DestroyImage(clut_image); | 
 | 7346 |             InheritException(exception,&image->exception); | 
 | 7347 |             *images=DestroyImageList(*images); | 
 | 7348 |             *images=image; | 
 | 7349 |             break; | 
 | 7350 |           } | 
 | 7351 |         if (LocaleCompare("coalesce",option+1) == 0) | 
 | 7352 |           { | 
 | 7353 |             Image | 
 | 7354 |               *coalesce_image; | 
 | 7355 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7356 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7357 |             coalesce_image=CoalesceImages(*images,exception); | 
 | 7358 |             if (coalesce_image == (Image *) NULL) | 
 | 7359 |               { | 
 | 7360 |                 status=MagickFalse; | 
 | 7361 |                 break; | 
 | 7362 |               } | 
 | 7363 |             *images=DestroyImageList(*images); | 
 | 7364 |             *images=coalesce_image; | 
 | 7365 |             break; | 
 | 7366 |           } | 
 | 7367 |         if (LocaleCompare("combine",option+1) == 0) | 
 | 7368 |           { | 
 | 7369 |             Image | 
 | 7370 |               *combine_image; | 
 | 7371 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7372 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 3139dc2 | 2011-07-08 00:11:42 +0000 | [diff] [blame] | 7373 |             combine_image=CombineImages(*images,exception); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7374 |             if (combine_image == (Image *) NULL) | 
 | 7375 |               { | 
 | 7376 |                 status=MagickFalse; | 
 | 7377 |                 break; | 
 | 7378 |               } | 
 | 7379 |             *images=DestroyImageList(*images); | 
 | 7380 |             *images=combine_image; | 
 | 7381 |             break; | 
 | 7382 |           } | 
 | 7383 |         if (LocaleCompare("composite",option+1) == 0) | 
 | 7384 |           { | 
 | 7385 |             Image | 
 | 7386 |               *mask_image, | 
 | 7387 |               *composite_image, | 
 | 7388 |               *image; | 
 | 7389 |  | 
 | 7390 |             RectangleInfo | 
 | 7391 |               geometry; | 
 | 7392 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7393 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7394 |             image=RemoveFirstImageFromList(images); | 
 | 7395 |             composite_image=RemoveFirstImageFromList(images); | 
 | 7396 |             if (composite_image == (Image *) NULL) | 
 | 7397 |               { | 
 | 7398 |                 status=MagickFalse; | 
 | 7399 |                 break; | 
 | 7400 |               } | 
 | 7401 |             (void) TransformImage(&composite_image,(char *) NULL, | 
 | 7402 |               composite_image->geometry); | 
 | 7403 |             SetGeometry(composite_image,&geometry); | 
 | 7404 |             (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); | 
 | 7405 |             GravityAdjustGeometry(image->columns,image->rows,image->gravity, | 
 | 7406 |               &geometry); | 
 | 7407 |             mask_image=RemoveFirstImageFromList(images); | 
 | 7408 |             if (mask_image != (Image *) NULL) | 
 | 7409 |               { | 
 | 7410 |                 if ((image->compose == DisplaceCompositeOp) || | 
 | 7411 |                     (image->compose == DistortCompositeOp)) | 
 | 7412 |                   { | 
 | 7413 |                     /* | 
 | 7414 |                       Merge Y displacement into X displacement image. | 
 | 7415 |                     */ | 
 | 7416 |                     (void) CompositeImage(composite_image,CopyGreenCompositeOp, | 
 | 7417 |                       mask_image,0,0); | 
 | 7418 |                     mask_image=DestroyImage(mask_image); | 
 | 7419 |                   } | 
 | 7420 |                 else | 
 | 7421 |                   { | 
 | 7422 |                     /* | 
 | 7423 |                       Set a blending mask for the composition. | 
 | 7424 |                     */ | 
| anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7425 |                     /* POSIBLE ERROR; what if image->mask already set */ | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7426 |                     image->mask=mask_image; | 
| cristy | b3e7c6c | 2011-07-24 01:43:55 +0000 | [diff] [blame] | 7427 |                     (void) NegateImage(image->mask,MagickFalse,exception); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7428 |                   } | 
 | 7429 |               } | 
| cristy | f4ad9df | 2011-07-08 16:49:03 +0000 | [diff] [blame] | 7430 |             (void) CompositeImage(image,image->compose,composite_image, | 
 | 7431 |               geometry.x,geometry.y); | 
| anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7432 |             if (mask_image != (Image *) NULL) | 
 | 7433 |               mask_image=image->mask=DestroyImage(image->mask); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7434 |             composite_image=DestroyImage(composite_image); | 
 | 7435 |             InheritException(exception,&image->exception); | 
 | 7436 |             *images=DestroyImageList(*images); | 
 | 7437 |             *images=image; | 
 | 7438 |             break; | 
 | 7439 |           } | 
| anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7440 | #if 0 | 
 | 7441 | This has been merged completely into MogrifyImage() | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7442 |         if (LocaleCompare("crop",option+1) == 0) | 
 | 7443 |           { | 
 | 7444 |             MagickStatusType | 
 | 7445 |               flags; | 
 | 7446 |  | 
 | 7447 |             RectangleInfo | 
 | 7448 |               geometry; | 
 | 7449 |  | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7450 |             /* | 
| anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7451 |               Crop Image. | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7452 |             */ | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7453 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7454 |             flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); | 
 | 7455 |             if (((geometry.width == 0) && (geometry.height == 0)) || | 
 | 7456 |                 ((flags & XValue) != 0) || ((flags & YValue) != 0)) | 
 | 7457 |               break; | 
 | 7458 |             (void) TransformImages(images,argv[i+1],(char *) NULL); | 
 | 7459 |             InheritException(exception,&(*images)->exception); | 
 | 7460 |             break; | 
 | 7461 |           } | 
| anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7462 | #endif | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7463 |         break; | 
 | 7464 |       } | 
 | 7465 |       case 'd': | 
 | 7466 |       { | 
 | 7467 |         if (LocaleCompare("deconstruct",option+1) == 0) | 
 | 7468 |           { | 
 | 7469 |             Image | 
 | 7470 |               *deconstruct_image; | 
 | 7471 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7472 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7473 |             deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, | 
| cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 7474 |               exception); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7475 |             if (deconstruct_image == (Image *) NULL) | 
 | 7476 |               { | 
 | 7477 |                 status=MagickFalse; | 
 | 7478 |                 break; | 
 | 7479 |               } | 
 | 7480 |             *images=DestroyImageList(*images); | 
 | 7481 |             *images=deconstruct_image; | 
 | 7482 |             break; | 
 | 7483 |           } | 
 | 7484 |         if (LocaleCompare("delete",option+1) == 0) | 
 | 7485 |           { | 
 | 7486 |             if (*option == '+') | 
 | 7487 |               DeleteImages(images,"-1",exception); | 
 | 7488 |             else | 
 | 7489 |               DeleteImages(images,argv[i+1],exception); | 
 | 7490 |             break; | 
 | 7491 |           } | 
 | 7492 |         if (LocaleCompare("dither",option+1) == 0) | 
 | 7493 |           { | 
 | 7494 |             if (*option == '+') | 
 | 7495 |               { | 
 | 7496 |                 quantize_info->dither=MagickFalse; | 
 | 7497 |                 break; | 
 | 7498 |               } | 
 | 7499 |             quantize_info->dither=MagickTrue; | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7500 |             quantize_info->dither_method=(DitherMethod) ParseCommandOption( | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7501 |               MagickDitherOptions,MagickFalse,argv[i+1]); | 
 | 7502 |             break; | 
 | 7503 |           } | 
| cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7504 |         if (LocaleCompare("duplicate",option+1) == 0) | 
 | 7505 |           { | 
| cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7506 |             Image | 
 | 7507 |               *duplicate_images; | 
| cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7508 |  | 
| anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7509 |             if (*option == '+') | 
| cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7510 |               duplicate_images=DuplicateImages(*images,1,"-1",exception); | 
 | 7511 |             else | 
 | 7512 |               { | 
 | 7513 |                 const char | 
 | 7514 |                   *p; | 
 | 7515 |  | 
| anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7516 |                 size_t | 
 | 7517 |                   number_duplicates; | 
| anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7518 |  | 
| anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7519 |                 number_duplicates=(size_t) StringToLong(argv[i+1]); | 
| cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7520 |                 p=strchr(argv[i+1],','); | 
 | 7521 |                 if (p == (const char *) NULL) | 
 | 7522 |                   duplicate_images=DuplicateImages(*images,number_duplicates, | 
 | 7523 |                     "-1",exception); | 
| anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7524 |                 else | 
| cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7525 |                   duplicate_images=DuplicateImages(*images,number_duplicates,p, | 
 | 7526 |                     exception); | 
| anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7527 |               } | 
 | 7528 |             AppendImageToList(images, duplicate_images); | 
 | 7529 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7530 |             break; | 
 | 7531 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7532 |         break; | 
 | 7533 |       } | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7534 |       case 'e': | 
 | 7535 |       { | 
 | 7536 |         if (LocaleCompare("evaluate-sequence",option+1) == 0) | 
 | 7537 |           { | 
 | 7538 |             Image | 
 | 7539 |               *evaluate_image; | 
 | 7540 |  | 
 | 7541 |             MagickEvaluateOperator | 
 | 7542 |               op; | 
 | 7543 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7544 |             (void) SyncImageSettings(mogrify_info,*images); | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7545 |             op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7546 |               MagickFalse,argv[i+1]); | 
 | 7547 |             evaluate_image=EvaluateImages(*images,op,exception); | 
 | 7548 |             if (evaluate_image == (Image *) NULL) | 
 | 7549 |               { | 
 | 7550 |                 status=MagickFalse; | 
 | 7551 |                 break; | 
 | 7552 |               } | 
 | 7553 |             *images=DestroyImageList(*images); | 
 | 7554 |             *images=evaluate_image; | 
 | 7555 |             break; | 
 | 7556 |           } | 
 | 7557 |         break; | 
 | 7558 |       } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7559 |       case 'f': | 
 | 7560 |       { | 
| cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7561 |         if (LocaleCompare("fft",option+1) == 0) | 
 | 7562 |           { | 
 | 7563 |             Image | 
 | 7564 |               *fourier_image; | 
 | 7565 |  | 
 | 7566 |             /* | 
 | 7567 |               Implements the discrete Fourier transform (DFT). | 
 | 7568 |             */ | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7569 |             (void) SyncImageSettings(mogrify_info,*images); | 
| cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7570 |             fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? | 
 | 7571 |               MagickTrue : MagickFalse,exception); | 
 | 7572 |             if (fourier_image == (Image *) NULL) | 
 | 7573 |               break; | 
 | 7574 |             *images=DestroyImage(*images); | 
 | 7575 |             *images=fourier_image; | 
 | 7576 |             break; | 
 | 7577 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7578 |         if (LocaleCompare("flatten",option+1) == 0) | 
 | 7579 |           { | 
 | 7580 |             Image | 
 | 7581 |               *flatten_image; | 
 | 7582 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7583 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7584 |             flatten_image=MergeImageLayers(*images,FlattenLayer,exception); | 
 | 7585 |             if (flatten_image == (Image *) NULL) | 
 | 7586 |               break; | 
 | 7587 |             *images=DestroyImageList(*images); | 
 | 7588 |             *images=flatten_image; | 
 | 7589 |             break; | 
 | 7590 |           } | 
 | 7591 |         if (LocaleCompare("fx",option+1) == 0) | 
 | 7592 |           { | 
 | 7593 |             Image | 
 | 7594 |               *fx_image; | 
 | 7595 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7596 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 490408a | 2011-07-07 14:42:05 +0000 | [diff] [blame] | 7597 |             fx_image=FxImage(*images,argv[i+1],exception); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7598 |             if (fx_image == (Image *) NULL) | 
 | 7599 |               { | 
 | 7600 |                 status=MagickFalse; | 
 | 7601 |                 break; | 
 | 7602 |               } | 
 | 7603 |             *images=DestroyImageList(*images); | 
 | 7604 |             *images=fx_image; | 
 | 7605 |             break; | 
 | 7606 |           } | 
 | 7607 |         break; | 
 | 7608 |       } | 
 | 7609 |       case 'h': | 
 | 7610 |       { | 
 | 7611 |         if (LocaleCompare("hald-clut",option+1) == 0) | 
 | 7612 |           { | 
 | 7613 |             Image | 
 | 7614 |               *hald_image, | 
 | 7615 |               *image; | 
 | 7616 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7617 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7618 |             image=RemoveFirstImageFromList(images); | 
 | 7619 |             hald_image=RemoveFirstImageFromList(images); | 
 | 7620 |             if (hald_image == (Image *) NULL) | 
 | 7621 |               { | 
 | 7622 |                 status=MagickFalse; | 
 | 7623 |                 break; | 
 | 7624 |               } | 
| cristy | f89cb1d | 2011-07-07 01:24:37 +0000 | [diff] [blame] | 7625 |             (void) HaldClutImage(image,hald_image); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7626 |             hald_image=DestroyImage(hald_image); | 
 | 7627 |             InheritException(exception,&image->exception); | 
| cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7628 |             if (*images != (Image *) NULL) | 
 | 7629 |               *images=DestroyImageList(*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7630 |             *images=image; | 
 | 7631 |             break; | 
 | 7632 |           } | 
 | 7633 |         break; | 
 | 7634 |       } | 
 | 7635 |       case 'i': | 
 | 7636 |       { | 
 | 7637 |         if (LocaleCompare("ift",option+1) == 0) | 
 | 7638 |           { | 
 | 7639 |             Image | 
| cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7640 |               *fourier_image, | 
 | 7641 |               *magnitude_image, | 
 | 7642 |               *phase_image; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7643 |  | 
 | 7644 |             /* | 
 | 7645 |               Implements the inverse fourier discrete Fourier transform (DFT). | 
 | 7646 |             */ | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7647 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7648 |             magnitude_image=RemoveFirstImageFromList(images); | 
 | 7649 |             phase_image=RemoveFirstImageFromList(images); | 
 | 7650 |             if (phase_image == (Image *) NULL) | 
 | 7651 |               { | 
 | 7652 |                 status=MagickFalse; | 
 | 7653 |                 break; | 
 | 7654 |               } | 
 | 7655 |             fourier_image=InverseFourierTransformImage(magnitude_image, | 
 | 7656 |               phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7657 |             if (fourier_image == (Image *) NULL) | 
 | 7658 |               break; | 
| cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7659 |             if (*images != (Image *) NULL) | 
 | 7660 |               *images=DestroyImage(*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7661 |             *images=fourier_image; | 
 | 7662 |             break; | 
 | 7663 |           } | 
 | 7664 |         if (LocaleCompare("insert",option+1) == 0) | 
 | 7665 |           { | 
 | 7666 |             Image | 
 | 7667 |               *p, | 
 | 7668 |               *q; | 
 | 7669 |  | 
 | 7670 |             index=0; | 
 | 7671 |             if (*option != '+') | 
| cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7672 |               index=(ssize_t) StringToLong(argv[i+1]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7673 |             p=RemoveLastImageFromList(images); | 
 | 7674 |             if (p == (Image *) NULL) | 
 | 7675 |               { | 
 | 7676 |                 (void) ThrowMagickException(exception,GetMagickModule(), | 
 | 7677 |                   OptionError,"NoSuchImage","`%s'",argv[i+1]); | 
 | 7678 |                 status=MagickFalse; | 
 | 7679 |                 break; | 
 | 7680 |               } | 
 | 7681 |             q=p; | 
 | 7682 |             if (index == 0) | 
 | 7683 |               PrependImageToList(images,q); | 
 | 7684 |             else | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7685 |               if (index == (ssize_t) GetImageListLength(*images)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7686 |                 AppendImageToList(images,q); | 
 | 7687 |               else | 
 | 7688 |                 { | 
 | 7689 |                    q=GetImageFromList(*images,index-1); | 
 | 7690 |                    if (q == (Image *) NULL) | 
 | 7691 |                      { | 
 | 7692 |                        (void) ThrowMagickException(exception,GetMagickModule(), | 
 | 7693 |                          OptionError,"NoSuchImage","`%s'",argv[i+1]); | 
 | 7694 |                        status=MagickFalse; | 
 | 7695 |                        break; | 
 | 7696 |                      } | 
 | 7697 |                   InsertImageInList(&q,p); | 
 | 7698 |                 } | 
 | 7699 |             *images=GetFirstImageInList(q); | 
 | 7700 |             break; | 
 | 7701 |           } | 
 | 7702 |         break; | 
 | 7703 |       } | 
 | 7704 |       case 'l': | 
 | 7705 |       { | 
 | 7706 |         if (LocaleCompare("layers",option+1) == 0) | 
 | 7707 |           { | 
 | 7708 |             Image | 
 | 7709 |               *layers; | 
 | 7710 |  | 
 | 7711 |             ImageLayerMethod | 
 | 7712 |               method; | 
 | 7713 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7714 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7715 |             layers=(Image *) NULL; | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7716 |             method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7717 |               MagickFalse,argv[i+1]); | 
 | 7718 |             switch (method) | 
 | 7719 |             { | 
 | 7720 |               case CoalesceLayer: | 
 | 7721 |               { | 
 | 7722 |                 layers=CoalesceImages(*images,exception); | 
 | 7723 |                 break; | 
 | 7724 |               } | 
 | 7725 |               case CompareAnyLayer: | 
 | 7726 |               case CompareClearLayer: | 
 | 7727 |               case CompareOverlayLayer: | 
 | 7728 |               default: | 
 | 7729 |               { | 
| cristy | 8a9106f | 2011-07-05 14:39:26 +0000 | [diff] [blame] | 7730 |                 layers=CompareImagesLayers(*images,method,exception); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7731 |                 break; | 
 | 7732 |               } | 
 | 7733 |               case MergeLayer: | 
 | 7734 |               case FlattenLayer: | 
 | 7735 |               case MosaicLayer: | 
 | 7736 |               case TrimBoundsLayer: | 
 | 7737 |               { | 
 | 7738 |                 layers=MergeImageLayers(*images,method,exception); | 
 | 7739 |                 break; | 
 | 7740 |               } | 
 | 7741 |               case DisposeLayer: | 
 | 7742 |               { | 
 | 7743 |                 layers=DisposeImages(*images,exception); | 
 | 7744 |                 break; | 
 | 7745 |               } | 
 | 7746 |               case OptimizeImageLayer: | 
 | 7747 |               { | 
 | 7748 |                 layers=OptimizeImageLayers(*images,exception); | 
 | 7749 |                 break; | 
 | 7750 |               } | 
 | 7751 |               case OptimizePlusLayer: | 
 | 7752 |               { | 
 | 7753 |                 layers=OptimizePlusImageLayers(*images,exception); | 
 | 7754 |                 break; | 
 | 7755 |               } | 
 | 7756 |               case OptimizeTransLayer: | 
 | 7757 |               { | 
 | 7758 |                 OptimizeImageTransparency(*images,exception); | 
 | 7759 |                 break; | 
 | 7760 |               } | 
 | 7761 |               case RemoveDupsLayer: | 
 | 7762 |               { | 
 | 7763 |                 RemoveDuplicateLayers(images,exception); | 
 | 7764 |                 break; | 
 | 7765 |               } | 
 | 7766 |               case RemoveZeroLayer: | 
 | 7767 |               { | 
 | 7768 |                 RemoveZeroDelayLayers(images,exception); | 
 | 7769 |                 break; | 
 | 7770 |               } | 
 | 7771 |               case OptimizeLayer: | 
 | 7772 |               { | 
 | 7773 |                 /* | 
 | 7774 |                   General Purpose, GIF Animation Optimizer. | 
 | 7775 |                 */ | 
 | 7776 |                 layers=CoalesceImages(*images,exception); | 
 | 7777 |                 if (layers == (Image *) NULL) | 
 | 7778 |                   { | 
 | 7779 |                     status=MagickFalse; | 
 | 7780 |                     break; | 
 | 7781 |                   } | 
 | 7782 |                 InheritException(exception,&layers->exception); | 
 | 7783 |                 *images=DestroyImageList(*images); | 
 | 7784 |                 *images=layers; | 
 | 7785 |                 layers=OptimizeImageLayers(*images,exception); | 
 | 7786 |                 if (layers == (Image *) NULL) | 
 | 7787 |                   { | 
 | 7788 |                     status=MagickFalse; | 
 | 7789 |                     break; | 
 | 7790 |                   } | 
 | 7791 |                 InheritException(exception,&layers->exception); | 
 | 7792 |                 *images=DestroyImageList(*images); | 
 | 7793 |                 *images=layers; | 
 | 7794 |                 layers=(Image *) NULL; | 
 | 7795 |                 OptimizeImageTransparency(*images,exception); | 
 | 7796 |                 InheritException(exception,&(*images)->exception); | 
 | 7797 |                 (void) RemapImages(quantize_info,*images,(Image *) NULL); | 
 | 7798 |                 break; | 
 | 7799 |               } | 
 | 7800 |               case CompositeLayer: | 
 | 7801 |               { | 
 | 7802 |                 CompositeOperator | 
 | 7803 |                   compose; | 
 | 7804 |  | 
 | 7805 |                 Image | 
 | 7806 |                   *source; | 
 | 7807 |  | 
 | 7808 |                 RectangleInfo | 
 | 7809 |                   geometry; | 
 | 7810 |  | 
 | 7811 |                 /* | 
 | 7812 |                   Split image sequence at the first 'NULL:' image. | 
 | 7813 |                 */ | 
 | 7814 |                 source=(*images); | 
 | 7815 |                 while (source != (Image *) NULL) | 
 | 7816 |                 { | 
 | 7817 |                   source=GetNextImageInList(source); | 
 | 7818 |                   if ((source != (Image *) NULL) && | 
 | 7819 |                       (LocaleCompare(source->magick,"NULL") == 0)) | 
 | 7820 |                     break; | 
 | 7821 |                 } | 
 | 7822 |                 if (source != (Image *) NULL) | 
 | 7823 |                   { | 
 | 7824 |                     if ((GetPreviousImageInList(source) == (Image *) NULL) || | 
 | 7825 |                         (GetNextImageInList(source) == (Image *) NULL)) | 
 | 7826 |                       source=(Image *) NULL; | 
 | 7827 |                     else | 
 | 7828 |                       { | 
 | 7829 |                         /* | 
 | 7830 |                           Separate the two lists, junk the null: image. | 
 | 7831 |                         */ | 
 | 7832 |                         source=SplitImageList(source->previous); | 
 | 7833 |                         DeleteImageFromList(&source); | 
 | 7834 |                       } | 
 | 7835 |                   } | 
 | 7836 |                 if (source == (Image *) NULL) | 
 | 7837 |                   { | 
 | 7838 |                     (void) ThrowMagickException(exception,GetMagickModule(), | 
 | 7839 |                       OptionError,"MissingNullSeparator","layers Composite"); | 
 | 7840 |                     status=MagickFalse; | 
 | 7841 |                     break; | 
 | 7842 |                   } | 
 | 7843 |                 /* | 
 | 7844 |                   Adjust offset with gravity and virtual canvas. | 
 | 7845 |                 */ | 
 | 7846 |                 SetGeometry(*images,&geometry); | 
 | 7847 |                 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); | 
 | 7848 |                 geometry.width=source->page.width != 0 ? | 
 | 7849 |                   source->page.width : source->columns; | 
 | 7850 |                 geometry.height=source->page.height != 0 ? | 
 | 7851 |                  source->page.height : source->rows; | 
 | 7852 |                 GravityAdjustGeometry((*images)->page.width != 0 ? | 
 | 7853 |                   (*images)->page.width : (*images)->columns, | 
 | 7854 |                   (*images)->page.height != 0 ? (*images)->page.height : | 
 | 7855 |                   (*images)->rows,(*images)->gravity,&geometry); | 
 | 7856 |                 compose=OverCompositeOp; | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7857 |                 option=GetImageOption(mogrify_info,"compose"); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7858 |                 if (option != (const char *) NULL) | 
| cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7859 |                   compose=(CompositeOperator) ParseCommandOption( | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7860 |                     MagickComposeOptions,MagickFalse,option); | 
 | 7861 |                 CompositeLayers(*images,compose,source,geometry.x,geometry.y, | 
 | 7862 |                   exception); | 
 | 7863 |                 source=DestroyImageList(source); | 
 | 7864 |                 break; | 
 | 7865 |               } | 
 | 7866 |             } | 
 | 7867 |             if (layers == (Image *) NULL) | 
 | 7868 |               break; | 
 | 7869 |             InheritException(exception,&layers->exception); | 
 | 7870 |             *images=DestroyImageList(*images); | 
 | 7871 |             *images=layers; | 
 | 7872 |             break; | 
 | 7873 |           } | 
 | 7874 |         break; | 
 | 7875 |       } | 
 | 7876 |       case 'm': | 
 | 7877 |       { | 
 | 7878 |         if (LocaleCompare("map",option+1) == 0) | 
 | 7879 |           { | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7880 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7881 |             if (*option == '+') | 
 | 7882 |               { | 
 | 7883 |                 (void) RemapImages(quantize_info,*images,(Image *) NULL); | 
 | 7884 |                 InheritException(exception,&(*images)->exception); | 
 | 7885 |                 break; | 
 | 7886 |               } | 
 | 7887 |             i++; | 
 | 7888 |             break; | 
 | 7889 |           } | 
| cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7890 |         if (LocaleCompare("maximum",option+1) == 0) | 
| cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7891 |           { | 
 | 7892 |             Image | 
| cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7893 |               *maximum_image; | 
| cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7894 |  | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7895 |             /* | 
 | 7896 |               Maximum image sequence (deprecated). | 
 | 7897 |             */ | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7898 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7899 |             maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); | 
| cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7900 |             if (maximum_image == (Image *) NULL) | 
| cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7901 |               { | 
 | 7902 |                 status=MagickFalse; | 
 | 7903 |                 break; | 
 | 7904 |               } | 
 | 7905 |             *images=DestroyImageList(*images); | 
| cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7906 |             *images=maximum_image; | 
| cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7907 |             break; | 
 | 7908 |           } | 
| cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7909 |         if (LocaleCompare("minimum",option+1) == 0) | 
| cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7910 |           { | 
 | 7911 |             Image | 
| cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7912 |               *minimum_image; | 
| cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7913 |  | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7914 |             /* | 
 | 7915 |               Minimum image sequence (deprecated). | 
 | 7916 |             */ | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7917 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7918 |             minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); | 
| cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7919 |             if (minimum_image == (Image *) NULL) | 
| cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7920 |               { | 
 | 7921 |                 status=MagickFalse; | 
 | 7922 |                 break; | 
 | 7923 |               } | 
 | 7924 |             *images=DestroyImageList(*images); | 
| cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7925 |             *images=minimum_image; | 
| cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7926 |             break; | 
 | 7927 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7928 |         if (LocaleCompare("morph",option+1) == 0) | 
 | 7929 |           { | 
 | 7930 |             Image | 
 | 7931 |               *morph_image; | 
 | 7932 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7933 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7934 |             morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7935 |               exception); | 
 | 7936 |             if (morph_image == (Image *) NULL) | 
 | 7937 |               { | 
 | 7938 |                 status=MagickFalse; | 
 | 7939 |                 break; | 
 | 7940 |               } | 
 | 7941 |             *images=DestroyImageList(*images); | 
 | 7942 |             *images=morph_image; | 
 | 7943 |             break; | 
 | 7944 |           } | 
 | 7945 |         if (LocaleCompare("mosaic",option+1) == 0) | 
 | 7946 |           { | 
 | 7947 |             Image | 
 | 7948 |               *mosaic_image; | 
 | 7949 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7950 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7951 |             mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); | 
 | 7952 |             if (mosaic_image == (Image *) NULL) | 
 | 7953 |               { | 
 | 7954 |                 status=MagickFalse; | 
 | 7955 |                 break; | 
 | 7956 |               } | 
 | 7957 |             *images=DestroyImageList(*images); | 
 | 7958 |             *images=mosaic_image; | 
 | 7959 |             break; | 
 | 7960 |           } | 
 | 7961 |         break; | 
 | 7962 |       } | 
 | 7963 |       case 'p': | 
 | 7964 |       { | 
 | 7965 |         if (LocaleCompare("print",option+1) == 0) | 
 | 7966 |           { | 
 | 7967 |             char | 
 | 7968 |               *string; | 
 | 7969 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7970 |             (void) SyncImagesSettings(mogrify_info,*images); | 
 | 7971 |             string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7972 |             if (string == (char *) NULL) | 
 | 7973 |               break; | 
 | 7974 |             InheritException(exception,&(*images)->exception); | 
| cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 7975 |             (void) FormatLocaleFile(stdout,"%s",string); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7976 |             string=DestroyString(string); | 
 | 7977 |           } | 
 | 7978 |         if (LocaleCompare("process",option+1) == 0) | 
 | 7979 |           { | 
 | 7980 |             char | 
 | 7981 |               **arguments; | 
 | 7982 |  | 
 | 7983 |             int | 
 | 7984 |               j, | 
 | 7985 |               number_arguments; | 
 | 7986 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7987 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7988 |             arguments=StringToArgv(argv[i+1],&number_arguments); | 
 | 7989 |             if (arguments == (char **) NULL) | 
 | 7990 |               break; | 
 | 7991 |             if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) | 
 | 7992 |               { | 
 | 7993 |                 char | 
 | 7994 |                   breaker, | 
 | 7995 |                   quote, | 
 | 7996 |                   *token; | 
 | 7997 |  | 
 | 7998 |                 const char | 
 | 7999 |                   *arguments; | 
 | 8000 |  | 
 | 8001 |                 int | 
 | 8002 |                   next, | 
 | 8003 |                   status; | 
 | 8004 |  | 
 | 8005 |                 size_t | 
 | 8006 |                   length; | 
 | 8007 |  | 
 | 8008 |                 TokenInfo | 
 | 8009 |                   *token_info; | 
 | 8010 |  | 
 | 8011 |                 /* | 
 | 8012 |                   Support old style syntax, filter="-option arg". | 
 | 8013 |                 */ | 
 | 8014 |                 length=strlen(argv[i+1]); | 
 | 8015 |                 token=(char *) NULL; | 
| cristy | 37e0b38 | 2011-06-07 13:31:21 +0000 | [diff] [blame] | 8016 |                 if (~length >= (MaxTextExtent-1)) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8017 |                   token=(char *) AcquireQuantumMemory(length+MaxTextExtent, | 
 | 8018 |                     sizeof(*token)); | 
 | 8019 |                 if (token == (char *) NULL) | 
 | 8020 |                   break; | 
 | 8021 |                 next=0; | 
 | 8022 |                 arguments=argv[i+1]; | 
 | 8023 |                 token_info=AcquireTokenInfo(); | 
 | 8024 |                 status=Tokenizer(token_info,0,token,length,arguments,"","=", | 
 | 8025 |                   "\"",'\0',&breaker,&next,"e); | 
 | 8026 |                 token_info=DestroyTokenInfo(token_info); | 
 | 8027 |                 if (status == 0) | 
 | 8028 |                   { | 
 | 8029 |                     const char | 
 | 8030 |                       *argv; | 
 | 8031 |  | 
 | 8032 |                     argv=(&(arguments[next])); | 
 | 8033 |                     (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, | 
 | 8034 |                       exception); | 
 | 8035 |                   } | 
 | 8036 |                 token=DestroyString(token); | 
 | 8037 |                 break; | 
 | 8038 |               } | 
| cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8039 |             (void) SubstituteString(&arguments[1],"-",""); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8040 |             (void) InvokeDynamicImageFilter(arguments[1],&(*images), | 
 | 8041 |               number_arguments-2,(const char **) arguments+2,exception); | 
 | 8042 |             for (j=0; j < number_arguments; j++) | 
 | 8043 |               arguments[j]=DestroyString(arguments[j]); | 
 | 8044 |             arguments=(char **) RelinquishMagickMemory(arguments); | 
 | 8045 |             break; | 
 | 8046 |           } | 
 | 8047 |         break; | 
 | 8048 |       } | 
 | 8049 |       case 'r': | 
 | 8050 |       { | 
 | 8051 |         if (LocaleCompare("reverse",option+1) == 0) | 
 | 8052 |           { | 
 | 8053 |             ReverseImageList(images); | 
 | 8054 |             InheritException(exception,&(*images)->exception); | 
 | 8055 |             break; | 
 | 8056 |           } | 
 | 8057 |         break; | 
 | 8058 |       } | 
 | 8059 |       case 's': | 
 | 8060 |       { | 
| cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8061 |         if (LocaleCompare("smush",option+1) == 0) | 
 | 8062 |           { | 
 | 8063 |             Image | 
 | 8064 |               *smush_image; | 
 | 8065 |  | 
 | 8066 |             ssize_t | 
 | 8067 |               offset; | 
 | 8068 |  | 
 | 8069 |             (void) SyncImagesSettings(mogrify_info,*images); | 
 | 8070 |             offset=(ssize_t) StringToLong(argv[i+1]); | 
 | 8071 |             smush_image=SmushImages(*images,*option == '-' ? MagickTrue : | 
 | 8072 |               MagickFalse,offset,exception); | 
 | 8073 |             if (smush_image == (Image *) NULL) | 
 | 8074 |               { | 
 | 8075 |                 status=MagickFalse; | 
 | 8076 |                 break; | 
 | 8077 |               } | 
 | 8078 |             *images=DestroyImageList(*images); | 
 | 8079 |             *images=smush_image; | 
 | 8080 |             break; | 
 | 8081 |           } | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8082 |         if (LocaleCompare("swap",option+1) == 0) | 
 | 8083 |           { | 
 | 8084 |             Image | 
 | 8085 |               *p, | 
 | 8086 |               *q, | 
 | 8087 |               *swap; | 
 | 8088 |  | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8089 |             ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8090 |               swap_index; | 
 | 8091 |  | 
 | 8092 |             index=(-1); | 
 | 8093 |             swap_index=(-2); | 
 | 8094 |             if (*option != '+') | 
 | 8095 |               { | 
 | 8096 |                 GeometryInfo | 
 | 8097 |                   geometry_info; | 
 | 8098 |  | 
 | 8099 |                 MagickStatusType | 
 | 8100 |                   flags; | 
 | 8101 |  | 
 | 8102 |                 swap_index=(-1); | 
 | 8103 |                 flags=ParseGeometry(argv[i+1],&geometry_info); | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8104 |                 index=(ssize_t) geometry_info.rho; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8105 |                 if ((flags & SigmaValue) != 0) | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8106 |                   swap_index=(ssize_t) geometry_info.sigma; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8107 |               } | 
 | 8108 |             p=GetImageFromList(*images,index); | 
 | 8109 |             q=GetImageFromList(*images,swap_index); | 
 | 8110 |             if ((p == (Image *) NULL) || (q == (Image *) NULL)) | 
 | 8111 |               { | 
 | 8112 |                 (void) ThrowMagickException(exception,GetMagickModule(), | 
 | 8113 |                   OptionError,"NoSuchImage","`%s'",(*images)->filename); | 
 | 8114 |                 status=MagickFalse; | 
 | 8115 |                 break; | 
 | 8116 |               } | 
 | 8117 |             if (p == q) | 
 | 8118 |               break; | 
 | 8119 |             swap=CloneImage(p,0,0,MagickTrue,exception); | 
 | 8120 |             ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); | 
 | 8121 |             ReplaceImageInList(&q,swap); | 
 | 8122 |             *images=GetFirstImageInList(q); | 
 | 8123 |             break; | 
 | 8124 |           } | 
 | 8125 |         break; | 
 | 8126 |       } | 
 | 8127 |       case 'w': | 
 | 8128 |       { | 
 | 8129 |         if (LocaleCompare("write",option+1) == 0) | 
 | 8130 |           { | 
| cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8131 |             char | 
| cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8132 |               key[MaxTextExtent]; | 
 | 8133 |  | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8134 |             Image | 
 | 8135 |               *write_images; | 
 | 8136 |  | 
 | 8137 |             ImageInfo | 
 | 8138 |               *write_info; | 
 | 8139 |  | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8140 |             (void) SyncImagesSettings(mogrify_info,*images); | 
| cristy | b51dff5 | 2011-05-19 16:55:47 +0000 | [diff] [blame] | 8141 |             (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); | 
| cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8142 |             (void) DeleteImageRegistry(key); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8143 |             write_images=(*images); | 
 | 8144 |             if (*option == '+') | 
 | 8145 |               write_images=CloneImageList(*images,exception); | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8146 |             write_info=CloneImageInfo(mogrify_info); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8147 |             status&=WriteImages(write_info,write_images,argv[i+1],exception); | 
 | 8148 |             write_info=DestroyImageInfo(write_info); | 
 | 8149 |             if (*option == '+') | 
 | 8150 |               write_images=DestroyImageList(write_images); | 
 | 8151 |             break; | 
 | 8152 |           } | 
 | 8153 |         break; | 
 | 8154 |       } | 
 | 8155 |       default: | 
 | 8156 |         break; | 
 | 8157 |     } | 
 | 8158 |     i+=count; | 
 | 8159 |   } | 
 | 8160 |   quantize_info=DestroyQuantizeInfo(quantize_info); | 
| cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8161 |   mogrify_info=DestroyImageInfo(mogrify_info); | 
 | 8162 |   status&=MogrifyImageInfo(image_info,argc,argv,exception); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8163 |   return(status != 0 ? MagickTrue : MagickFalse); | 
 | 8164 | } | 
 | 8165 |  | 
 | 8166 | /* | 
 | 8167 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 8168 | %                                                                             % | 
 | 8169 | %                                                                             % | 
 | 8170 | %                                                                             % | 
 | 8171 | +     M o g r i f y I m a g e s                                               % | 
 | 8172 | %                                                                             % | 
 | 8173 | %                                                                             % | 
 | 8174 | %                                                                             % | 
 | 8175 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 
 | 8176 | % | 
 | 8177 | %  MogrifyImages() applies image processing options to a sequence of images as | 
 | 8178 | %  prescribed by command line options. | 
 | 8179 | % | 
 | 8180 | %  The format of the MogrifyImage method is: | 
 | 8181 | % | 
 | 8182 | %      MagickBooleanType MogrifyImages(ImageInfo *image_info, | 
 | 8183 | %        const MagickBooleanType post,const int argc,const char **argv, | 
 | 8184 | %        Image **images,Exceptioninfo *exception) | 
 | 8185 | % | 
 | 8186 | %  A description of each parameter follows: | 
 | 8187 | % | 
 | 8188 | %    o image_info: the image info.. | 
 | 8189 | % | 
 | 8190 | %    o post: If true, post process image list operators otherwise pre-process. | 
 | 8191 | % | 
 | 8192 | %    o argc: Specifies a pointer to an integer describing the number of | 
 | 8193 | %      elements in the argument vector. | 
 | 8194 | % | 
 | 8195 | %    o argv: Specifies a pointer to a text array containing the command line | 
 | 8196 | %      arguments. | 
 | 8197 | % | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8198 | %    o images: pointer to a pointer of the first image in image list. | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8199 | % | 
 | 8200 | %    o exception: return any errors or warnings in this structure. | 
 | 8201 | % | 
 | 8202 | */ | 
 | 8203 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, | 
 | 8204 |   const MagickBooleanType post,const int argc,const char **argv, | 
 | 8205 |   Image **images,ExceptionInfo *exception) | 
 | 8206 | { | 
 | 8207 | #define MogrifyImageTag  "Mogrify/Image" | 
 | 8208 |  | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8209 |   MagickStatusType | 
 | 8210 |     status; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8211 |  | 
| cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8212 |   MagickBooleanType | 
 | 8213 |     proceed; | 
 | 8214 |  | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8215 |   size_t | 
 | 8216 |     n; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8217 |  | 
| cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8218 |   register ssize_t | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8219 |     i; | 
 | 8220 |  | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8221 |   assert(image_info != (ImageInfo *) NULL); | 
 | 8222 |   assert(image_info->signature == MagickSignature); | 
 | 8223 |   if (images == (Image **) NULL) | 
 | 8224 |     return(MogrifyImage(image_info,argc,argv,images,exception)); | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8225 |   assert((*images)->previous == (Image *) NULL); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8226 |   assert((*images)->signature == MagickSignature); | 
 | 8227 |   if ((*images)->debug != MagickFalse) | 
 | 8228 |     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", | 
 | 8229 |       (*images)->filename); | 
 | 8230 |   if ((argc <= 0) || (*argv == (char *) NULL)) | 
 | 8231 |     return(MagickTrue); | 
 | 8232 |   (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, | 
 | 8233 |     (void *) NULL); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8234 |   status=0; | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8235 |  | 
| anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8236 | #if 0 | 
| cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8237 |   (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, | 
 | 8238 |     post?"post":"pre"); | 
| anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8239 | #endif | 
 | 8240 |  | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8241 |   /* | 
 | 8242 |     Pre-process multi-image sequence operators | 
 | 8243 |   */ | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8244 |   if (post == MagickFalse) | 
 | 8245 |     status&=MogrifyImageList(image_info,argc,argv,images,exception); | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8246 |   /* | 
 | 8247 |     For each image, process simple single image operators | 
 | 8248 |   */ | 
 | 8249 |   i=0; | 
 | 8250 |   n=GetImageListLength(*images); | 
 | 8251 |   for (;;) | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8252 |   { | 
| anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8253 | #if 0 | 
| cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8254 |   (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) | 
 | 8255 |     GetImageIndexInList(*images),(long)GetImageListLength(*images)); | 
| anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8256 | #endif | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8257 |     status&=MogrifyImage(image_info,argc,argv,images,exception); | 
 | 8258 |     proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); | 
| cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8259 |     if (proceed == MagickFalse) | 
 | 8260 |       break; | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8261 |     if ( (*images)->next == (Image *) NULL ) | 
 | 8262 |       break; | 
 | 8263 |     *images=(*images)->next; | 
 | 8264 |     i++; | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8265 |   } | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8266 |   assert( *images != (Image *) NULL ); | 
| anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8267 | #if 0 | 
| cristy | 1e60481 | 2011-05-19 18:07:50 +0000 | [diff] [blame] | 8268 |   (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) | 
 | 8269 |     GetImageIndexInList(*images),(long)GetImageListLength(*images)); | 
| anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8270 | #endif | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8271 |  | 
 | 8272 |   /* | 
 | 8273 |     Post-process, multi-image sequence operators | 
 | 8274 |   */ | 
 | 8275 |   *images=GetFirstImageInList(*images); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8276 |   if (post != MagickFalse) | 
| anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8277 |     status&=MogrifyImageList(image_info,argc,argv,images,exception); | 
| cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8278 |   return(status != 0 ? MagickTrue : MagickFalse); | 
 | 8279 | } |