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 | */ |
| 47 | #include "wand/studio.h" |
| 48 | #include "wand/MagickWand.h" |
| 49 | #include "wand/mogrify-private.h" |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 50 | #include "magick/monitor-private.h" |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 51 | #include "magick/thread-private.h" |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 52 | #include "magick/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 53 | |
| 54 | /* |
| 55 | Define declarations. |
| 56 | */ |
| 57 | #define UndefinedCompressionQuality 0UL |
| 58 | |
| 59 | /* |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 60 | Constant declaration. |
| 61 | */ |
| 62 | static const char |
| 63 | BackgroundColor[] = "#fff", /* white */ |
| 64 | BorderColor[] = "#dfdfdf", /* gray */ |
| 65 | MatteColor[] = "#bdbdbd"; /* gray */ |
| 66 | |
| 67 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 68 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 69 | % % |
| 70 | % % |
| 71 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 72 | % 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] | 73 | % % |
| 74 | % % |
| 75 | % % |
| 76 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 77 | % |
| 78 | % MagickCommandGenesis() applies image processing options to an image as |
| 79 | % prescribed by command line options. |
| 80 | % |
| 81 | % The format of the MagickCommandGenesis method is: |
| 82 | % |
| 83 | % MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 84 | % MagickCommand command,int argc,char **argv,char **metadata, |
| 85 | % ExceptionInfo *exception) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 86 | % |
| 87 | % A description of each parameter follows: |
| 88 | % |
| 89 | % o image_info: the image info. |
| 90 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 91 | % o command: Choose from ConvertImageCommand, IdentifyImageCommand, |
| 92 | % MogrifyImageCommand, CompositeImageCommand, CompareImageCommand, |
| 93 | % ConjureImageCommand, StreamImageCommand, ImportImageCommand, |
| 94 | % DisplayImageCommand, or AnimateImageCommand. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 95 | % |
| 96 | % o argc: Specifies a pointer to an integer describing the number of |
| 97 | % elements in the argument vector. |
| 98 | % |
| 99 | % o argv: Specifies a pointer to a text array containing the command line |
| 100 | % arguments. |
| 101 | % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 102 | % o metadata: any metadata is returned here. |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 103 | % |
| 104 | % o exception: return any errors or warnings in this structure. |
| 105 | % |
| 106 | */ |
| 107 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 108 | MagickCommand command,int argc,char **argv,char **metadata, |
| 109 | ExceptionInfo *exception) |
| 110 | { |
| 111 | char |
| 112 | *option; |
| 113 | |
| 114 | double |
| 115 | duration, |
| 116 | elapsed_time, |
| 117 | user_time; |
| 118 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 119 | MagickBooleanType |
| 120 | concurrent, |
| 121 | regard_warnings, |
| 122 | status; |
| 123 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 124 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 125 | i; |
| 126 | |
| 127 | TimerInfo |
| 128 | *timer; |
| 129 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 130 | size_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 131 | iterations; |
| 132 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 133 | (void) setlocale(LC_ALL,""); |
| 134 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 135 | concurrent=MagickFalse; |
| 136 | duration=(-1.0); |
| 137 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 138 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 139 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 140 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 141 | { |
| 142 | option=argv[i]; |
| 143 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 144 | continue; |
| 145 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 146 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 147 | if (LocaleCompare("concurrent",option+1) == 0) |
| 148 | concurrent=MagickTrue; |
| 149 | if (LocaleCompare("debug",option+1) == 0) |
| 150 | (void) SetLogEventMask(argv[++i]); |
| 151 | if (LocaleCompare("duration",option+1) == 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 152 | duration=StringToDouble(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 153 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 154 | regard_warnings=MagickTrue; |
| 155 | } |
| 156 | timer=AcquireTimerInfo(); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 157 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 158 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 159 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 160 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 161 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 162 | continue; |
| 163 | if (duration > 0) |
| 164 | { |
| 165 | if (GetElapsedTime(timer) > duration) |
| 166 | continue; |
| 167 | (void) ContinueTimer(timer); |
| 168 | } |
| 169 | status=command(image_info,argc,argv,metadata,exception); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 170 | if (exception->severity != UndefinedException) |
| 171 | { |
| 172 | if ((exception->severity > ErrorException) || |
| 173 | (regard_warnings != MagickFalse)) |
| 174 | status=MagickTrue; |
| 175 | CatchException(exception); |
| 176 | } |
cristy | 3d1a551 | 2009-10-25 21:23:27 +0000 | [diff] [blame] | 177 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 178 | { |
| 179 | (void) fputs(*metadata,stdout); |
| 180 | (void) fputc('\n',stdout); |
| 181 | *metadata=DestroyString(*metadata); |
| 182 | } |
| 183 | } |
| 184 | } |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 185 | else |
| 186 | { |
| 187 | SetOpenMPNested(1); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 188 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 189 | # pragma omp parallel for shared(status) |
| 190 | #endif |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 191 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 192 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 193 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 194 | continue; |
| 195 | if (duration > 0) |
| 196 | { |
| 197 | if (GetElapsedTime(timer) > duration) |
| 198 | continue; |
| 199 | (void) ContinueTimer(timer); |
| 200 | } |
| 201 | status=command(image_info,argc,argv,metadata,exception); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 202 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 203 | # pragma omp critical (MagickCore_CommandGenesis) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 204 | #endif |
| 205 | { |
| 206 | if (exception->severity != UndefinedException) |
| 207 | { |
| 208 | if ((exception->severity > ErrorException) || |
| 209 | (regard_warnings != MagickFalse)) |
| 210 | status=MagickTrue; |
| 211 | CatchException(exception); |
| 212 | } |
| 213 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 214 | { |
| 215 | (void) fputs(*metadata,stdout); |
| 216 | (void) fputc('\n',stdout); |
| 217 | *metadata=DestroyString(*metadata); |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | } |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 222 | if (iterations > 1) |
| 223 | { |
| 224 | elapsed_time=GetElapsedTime(timer); |
| 225 | user_time=GetUserTime(timer); |
cristy | 8cd5b31 | 2010-01-07 01:10:24 +0000 | [diff] [blame] | 226 | (void) fprintf(stderr, |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 227 | "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double) |
| 228 | iterations,1.0*iterations/elapsed_time,user_time,(double) |
| 229 | (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double) |
| 230 | (1000.0*(elapsed_time-floor(elapsed_time)))); |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 231 | (void) fflush(stderr); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 232 | } |
| 233 | timer=DestroyTimerInfo(timer); |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 234 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | /* |
| 238 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 239 | % % |
| 240 | % % |
| 241 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 242 | + M o g r i f y I m a g e % |
| 243 | % % |
| 244 | % % |
| 245 | % % |
| 246 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 247 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 248 | % MogrifyImage() applies simple single image processing options to a single |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 249 | % image that may be part of a large list, but also handles any 'region' |
| 250 | % image handling. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 251 | % |
| 252 | % The image in the list may be modified in three different ways... |
| 253 | % |
| 254 | % * directly modified (EG: -negate, -gamma, -level, -annotate, -draw), |
| 255 | % * replaced by a new image (EG: -spread, -resize, -rotate, -morphology) |
| 256 | % * replace by a list of images (only the -separate option!) |
| 257 | % |
| 258 | % In each case the result is returned into the list, and a pointer to the |
| 259 | % modified image (last image added if replaced by a list of images) is |
| 260 | % returned. |
| 261 | % |
| 262 | % ASIDE: The -crop is present but restricted to non-tile single image crops |
| 263 | % |
| 264 | % This means if all the images are being processed (such as by |
| 265 | % MogrifyImages(), next image to be processed will be as per the pointer |
| 266 | % (*image)->next. Also the image list may grow as a result of some specific |
| 267 | % operations but as images are never merged or deleted, it will never shrink |
| 268 | % in length. Typically the list will remain the same length. |
| 269 | % |
| 270 | % WARNING: As the image pointed to may be replaced, the first image in the |
| 271 | % list may also change. GetFirstImageInList() should be used by caller if |
| 272 | % they wish return the Image pointer to the first image in list. |
| 273 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 274 | % |
| 275 | % The format of the MogrifyImage method is: |
| 276 | % |
| 277 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 278 | % const char **argv,Image **image) |
| 279 | % |
| 280 | % A description of each parameter follows: |
| 281 | % |
| 282 | % o image_info: the image info.. |
| 283 | % |
| 284 | % o argc: Specifies a pointer to an integer describing the number of |
| 285 | % elements in the argument vector. |
| 286 | % |
| 287 | % o argv: Specifies a pointer to a text array containing the command line |
| 288 | % arguments. |
| 289 | % |
| 290 | % o image: the image. |
| 291 | % |
| 292 | % o exception: return any errors or warnings in this structure. |
| 293 | % |
| 294 | */ |
| 295 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 296 | /* |
| 297 | ** GetImageCache() will read an image into a image cache if not already |
| 298 | ** present then return the image that is in the cache under that filename. |
| 299 | */ |
| 300 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 301 | ExceptionInfo *exception) |
| 302 | { |
| 303 | char |
| 304 | key[MaxTextExtent]; |
| 305 | |
| 306 | ExceptionInfo |
| 307 | *sans_exception; |
| 308 | |
| 309 | Image |
| 310 | *image; |
| 311 | |
| 312 | ImageInfo |
| 313 | *read_info; |
| 314 | |
| 315 | (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path); |
| 316 | sans_exception=AcquireExceptionInfo(); |
| 317 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 318 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 319 | if (image != (Image *) NULL) |
| 320 | return(image); |
| 321 | read_info=CloneImageInfo(image_info); |
| 322 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 323 | image=ReadImage(read_info,exception); |
| 324 | read_info=DestroyImageInfo(read_info); |
| 325 | if (image != (Image *) NULL) |
| 326 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 327 | return(image); |
| 328 | } |
| 329 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 330 | static MagickBooleanType IsPathWritable(const char *path) |
| 331 | { |
| 332 | if (IsPathAccessible(path) == MagickFalse) |
| 333 | return(MagickFalse); |
| 334 | if (access(path,W_OK) != 0) |
| 335 | return(MagickFalse); |
| 336 | return(MagickTrue); |
| 337 | } |
| 338 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 339 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 340 | { |
| 341 | if (x > y) |
| 342 | return(x); |
| 343 | return(y); |
| 344 | } |
| 345 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 346 | static MagickBooleanType MonitorProgress(const char *text, |
| 347 | const MagickOffsetType offset,const MagickSizeType extent, |
| 348 | void *wand_unused(client_data)) |
| 349 | { |
| 350 | char |
| 351 | message[MaxTextExtent], |
| 352 | tag[MaxTextExtent]; |
| 353 | |
| 354 | const char |
| 355 | *locale_message; |
| 356 | |
| 357 | register char |
| 358 | *p; |
| 359 | |
| 360 | if (extent < 2) |
| 361 | return(MagickTrue); |
| 362 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 363 | p=strrchr(tag,'/'); |
| 364 | if (p != (char *) NULL) |
| 365 | *p='\0'; |
| 366 | (void) FormatMagickString(message,MaxTextExtent,"Monitor/%s",tag); |
| 367 | locale_message=GetLocaleMessage(message); |
| 368 | if (locale_message == message) |
| 369 | locale_message=tag; |
| 370 | if (p == (char *) NULL) |
| 371 | (void) fprintf(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message, |
| 372 | (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1))); |
| 373 | else |
| 374 | (void) fprintf(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
| 375 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
| 376 | (100L*offset/(extent-1))); |
| 377 | if (offset == (MagickOffsetType) (extent-1)) |
| 378 | (void) fprintf(stderr,"\n"); |
| 379 | (void) fflush(stderr); |
| 380 | return(MagickTrue); |
| 381 | } |
| 382 | |
| 383 | /* |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame^] | 384 | ** SparseColorOption() parses the complex -sparse-color argument into an |
| 385 | ** an array of floating point values then calls SparseColorImage(). |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 386 | ** Argument is a complex mix of floating-point pixel coodinates, and color |
| 387 | ** specifications (or direct floating point numbers). The number of floats |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame^] | 388 | ** needed to represent a color varies depending on the current channel |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 389 | ** setting. |
| 390 | */ |
| 391 | static Image *SparseColorOption(const Image *image,const ChannelType channel, |
| 392 | const SparseColorMethod method,const char *arguments, |
| 393 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 394 | { |
| 395 | ChannelType |
| 396 | channels; |
| 397 | |
| 398 | char |
| 399 | token[MaxTextExtent]; |
| 400 | |
| 401 | const char |
| 402 | *p; |
| 403 | |
| 404 | double |
| 405 | *sparse_arguments; |
| 406 | |
| 407 | register size_t |
| 408 | x; |
| 409 | |
| 410 | size_t |
| 411 | number_arguments; |
| 412 | |
| 413 | size_t |
| 414 | number_colors; |
| 415 | |
| 416 | Image |
| 417 | *sparse_image; |
| 418 | |
| 419 | MagickPixelPacket |
| 420 | color; |
| 421 | |
| 422 | MagickBooleanType |
| 423 | error; |
| 424 | |
| 425 | assert(image != (Image *) NULL); |
| 426 | assert(image->signature == MagickSignature); |
| 427 | if (image->debug != MagickFalse) |
| 428 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 429 | assert(exception != (ExceptionInfo *) NULL); |
| 430 | assert(exception->signature == MagickSignature); |
| 431 | /* |
| 432 | Limit channels according to image - and add up number of color channel. |
| 433 | */ |
| 434 | channels=channel; |
| 435 | if (image->colorspace != CMYKColorspace) |
| 436 | channels=(ChannelType) (channels & ~IndexChannel); /* no index channel */ |
| 437 | if (image->matte == MagickFalse) |
| 438 | channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */ |
| 439 | number_colors=0; |
| 440 | if ((channels & RedChannel) != 0) |
| 441 | number_colors++; |
| 442 | if ((channels & GreenChannel) != 0) |
| 443 | number_colors++; |
| 444 | if ((channels & BlueChannel) != 0) |
| 445 | number_colors++; |
| 446 | if ((channels & IndexChannel) != 0) |
| 447 | number_colors++; |
| 448 | if ((channels & OpacityChannel) != 0) |
| 449 | number_colors++; |
| 450 | |
| 451 | /* |
| 452 | Read string, to determine number of arguments needed, |
| 453 | */ |
| 454 | p=arguments; |
| 455 | x=0; |
| 456 | while( *p != '\0' ) |
| 457 | { |
| 458 | GetMagickToken(p,&p,token); |
| 459 | if ( token[0] == ',' ) continue; |
| 460 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 461 | if ( color_from_image ) { |
| 462 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 463 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 464 | "Color arg given, when colors are coming from image"); |
| 465 | return( (Image *)NULL); |
| 466 | } |
| 467 | x += number_colors; /* color argument */ |
| 468 | } |
| 469 | else { |
| 470 | x++; /* floating point argument */ |
| 471 | } |
| 472 | } |
| 473 | error=MagickTrue; |
| 474 | if ( color_from_image ) { |
| 475 | /* just the control points are being given */ |
| 476 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 477 | number_arguments=(x/2)*(2+number_colors); |
| 478 | } |
| 479 | else { |
| 480 | /* control points and color values */ |
| 481 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 482 | number_arguments=x; |
| 483 | } |
| 484 | if ( error ) { |
| 485 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 486 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 487 | "Invalid number of Arguments"); |
| 488 | return( (Image *)NULL); |
| 489 | } |
| 490 | |
| 491 | /* Allocate and fill in the floating point arguments */ |
| 492 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 493 | sizeof(*sparse_arguments)); |
| 494 | if (sparse_arguments == (double *) NULL) { |
| 495 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 496 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 497 | return( (Image *)NULL); |
| 498 | } |
| 499 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 500 | sizeof(*sparse_arguments)); |
| 501 | p=arguments; |
| 502 | x=0; |
| 503 | while( *p != '\0' && x < number_arguments ) { |
| 504 | /* X coordinate */ |
| 505 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 506 | if ( token[0] == '\0' ) break; |
| 507 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 508 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 509 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 510 | "Color found, instead of X-coord"); |
| 511 | error = MagickTrue; |
| 512 | break; |
| 513 | } |
| 514 | sparse_arguments[x++]=StringToDouble(token); |
| 515 | /* Y coordinate */ |
| 516 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 517 | if ( token[0] == '\0' ) break; |
| 518 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 519 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 520 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 521 | "Color found, instead of Y-coord"); |
| 522 | error = MagickTrue; |
| 523 | break; |
| 524 | } |
| 525 | sparse_arguments[x++]=StringToDouble(token); |
| 526 | /* color values for this control point */ |
| 527 | #if 0 |
| 528 | if ( (color_from_image ) { |
| 529 | /* get color from image */ |
| 530 | /* HOW??? */ |
| 531 | } |
| 532 | else |
| 533 | #endif |
| 534 | { |
| 535 | /* color name or function given in string argument */ |
| 536 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 537 | if ( token[0] == '\0' ) break; |
| 538 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 539 | /* Color string given */ |
| 540 | (void) QueryMagickColor(token,&color,exception); |
| 541 | if ( channels & RedChannel ) |
| 542 | sparse_arguments[x++] = QuantumScale*color.red; |
| 543 | if ( channels & GreenChannel ) |
| 544 | sparse_arguments[x++] = QuantumScale*color.green; |
| 545 | if ( channels & BlueChannel ) |
| 546 | sparse_arguments[x++] = QuantumScale*color.blue; |
| 547 | if ( channels & IndexChannel ) |
| 548 | sparse_arguments[x++] = QuantumScale*color.index; |
| 549 | if ( channels & OpacityChannel ) |
| 550 | sparse_arguments[x++] = QuantumScale*color.opacity; |
| 551 | } |
| 552 | else { |
| 553 | /* Colors given as a set of floating point values - experimental */ |
| 554 | /* NB: token contains the first floating point value to use! */ |
| 555 | if ( channels & RedChannel ) { |
| 556 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 557 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 558 | break; |
| 559 | sparse_arguments[x++]=StringToDouble(token); |
| 560 | token[0] = ','; /* used this token - get another */ |
| 561 | } |
| 562 | if ( channels & GreenChannel ) { |
| 563 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 564 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 565 | break; |
| 566 | sparse_arguments[x++]=StringToDouble(token); |
| 567 | token[0] = ','; /* used this token - get another */ |
| 568 | } |
| 569 | if ( channels & BlueChannel ) { |
| 570 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 571 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 572 | break; |
| 573 | sparse_arguments[x++]=StringToDouble(token); |
| 574 | token[0] = ','; /* used this token - get another */ |
| 575 | } |
| 576 | if ( channels & IndexChannel ) { |
| 577 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 578 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 579 | break; |
| 580 | sparse_arguments[x++]=StringToDouble(token); |
| 581 | token[0] = ','; /* used this token - get another */ |
| 582 | } |
| 583 | if ( channels & OpacityChannel ) { |
| 584 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 585 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 586 | break; |
| 587 | sparse_arguments[x++]=StringToDouble(token); |
| 588 | token[0] = ','; /* used this token - get another */ |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | } |
| 593 | if ( number_arguments != x && !error ) { |
| 594 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 595 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 596 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 597 | return( (Image *)NULL); |
| 598 | } |
| 599 | if ( error ) |
| 600 | return( (Image *)NULL); |
| 601 | |
| 602 | /* Call the Interpolation function with the parsed arguments */ |
| 603 | sparse_image=SparseColorImage(image,channels,method,number_arguments, |
| 604 | sparse_arguments,exception); |
| 605 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 606 | return( sparse_image ); |
| 607 | } |
| 608 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 609 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 610 | const char **argv,Image **image,ExceptionInfo *exception) |
| 611 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 612 | ChannelType |
| 613 | channel; |
| 614 | |
| 615 | const char |
| 616 | *format, |
| 617 | *option; |
| 618 | |
| 619 | DrawInfo |
| 620 | *draw_info; |
| 621 | |
| 622 | GeometryInfo |
| 623 | geometry_info; |
| 624 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 625 | Image |
| 626 | *region_image; |
| 627 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 628 | ImageInfo |
| 629 | *mogrify_info; |
| 630 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 631 | MagickStatusType |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 632 | status; |
| 633 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 634 | MagickPixelPacket |
| 635 | fill; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 636 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 637 | MagickStatusType |
| 638 | flags; |
| 639 | |
| 640 | QuantizeInfo |
| 641 | *quantize_info; |
| 642 | |
| 643 | RectangleInfo |
| 644 | geometry, |
| 645 | region_geometry; |
anthony | 56ad422 | 2011-04-25 11:04:27 +0000 | [diff] [blame] | 646 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 647 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 648 | i; |
| 649 | |
| 650 | /* |
| 651 | Initialize method variables. |
| 652 | */ |
| 653 | assert(image_info != (const ImageInfo *) NULL); |
| 654 | assert(image_info->signature == MagickSignature); |
| 655 | assert(image != (Image **) NULL); |
| 656 | assert((*image)->signature == MagickSignature); |
| 657 | if ((*image)->debug != MagickFalse) |
| 658 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 659 | if (argc < 0) |
| 660 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 661 | mogrify_info=CloneImageInfo(image_info); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 662 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 663 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 664 | SetGeometryInfo(&geometry_info); |
| 665 | GetMagickPixelPacket(*image,&fill); |
| 666 | SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL, |
| 667 | &fill); |
| 668 | channel=mogrify_info->channel; |
| 669 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 670 | SetGeometry(*image,®ion_geometry); |
| 671 | region_image=NewImageList(); |
| 672 | /* |
| 673 | Transmogrify the image. |
| 674 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 675 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 676 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 677 | Image |
| 678 | *mogrify_image; |
| 679 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 680 | ssize_t |
| 681 | count; |
| 682 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 683 | option=argv[i]; |
| 684 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 685 | continue; |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 686 | count=MagickMax(ParseCommandOption(MagickCommandOptions,MagickFalse,option), |
| 687 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 688 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 689 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 690 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 691 | mogrify_image=(Image *)NULL; |
| 692 | switch (*(option+1)) |
| 693 | { |
| 694 | case 'a': |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 695 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 696 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 697 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 698 | /* |
| 699 | Adaptive blur image. |
| 700 | */ |
| 701 | (void) SyncImageSettings(mogrify_info,*image); |
| 702 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 703 | if ((flags & SigmaValue) == 0) |
| 704 | geometry_info.sigma=1.0; |
| 705 | mogrify_image=AdaptiveBlurImageChannel(*image,channel, |
| 706 | geometry_info.rho,geometry_info.sigma,exception); |
| 707 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 708 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 709 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 710 | { |
| 711 | /* |
| 712 | Adaptive resize image. |
| 713 | */ |
| 714 | (void) SyncImageSettings(mogrify_info,*image); |
| 715 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 716 | mogrify_image=AdaptiveResizeImage(*image,geometry.width, |
| 717 | geometry.height,exception); |
| 718 | break; |
| 719 | } |
| 720 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 721 | { |
| 722 | /* |
| 723 | Adaptive sharpen image. |
| 724 | */ |
| 725 | (void) SyncImageSettings(mogrify_info,*image); |
| 726 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 727 | if ((flags & SigmaValue) == 0) |
| 728 | geometry_info.sigma=1.0; |
| 729 | mogrify_image=AdaptiveSharpenImageChannel(*image,channel, |
| 730 | geometry_info.rho,geometry_info.sigma,exception); |
| 731 | break; |
| 732 | } |
| 733 | if (LocaleCompare("affine",option+1) == 0) |
| 734 | { |
| 735 | /* |
| 736 | Affine matrix. |
| 737 | */ |
| 738 | if (*option == '+') |
| 739 | { |
| 740 | GetAffineMatrix(&draw_info->affine); |
| 741 | break; |
| 742 | } |
| 743 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 744 | break; |
| 745 | } |
| 746 | if (LocaleCompare("alpha",option+1) == 0) |
| 747 | { |
| 748 | AlphaChannelType |
| 749 | alpha_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 750 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 751 | (void) SyncImageSettings(mogrify_info,*image); |
| 752 | alpha_type=(AlphaChannelType) ParseCommandOption(MagickAlphaOptions, |
| 753 | MagickFalse,argv[i+1]); |
| 754 | (void) SetImageAlphaChannel(*image,alpha_type); |
| 755 | InheritException(exception,&(*image)->exception); |
| 756 | break; |
| 757 | } |
| 758 | if (LocaleCompare("annotate",option+1) == 0) |
| 759 | { |
| 760 | char |
| 761 | *text, |
| 762 | geometry[MaxTextExtent]; |
| 763 | |
| 764 | /* |
| 765 | Annotate image. |
| 766 | */ |
| 767 | (void) SyncImageSettings(mogrify_info,*image); |
| 768 | SetGeometryInfo(&geometry_info); |
| 769 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 770 | if ((flags & SigmaValue) == 0) |
| 771 | geometry_info.sigma=geometry_info.rho; |
| 772 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 773 | InheritException(exception,&(*image)->exception); |
| 774 | if (text == (char *) NULL) |
| 775 | break; |
| 776 | (void) CloneString(&draw_info->text,text); |
| 777 | text=DestroyString(text); |
| 778 | (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f", |
| 779 | geometry_info.xi,geometry_info.psi); |
| 780 | (void) CloneString(&draw_info->geometry,geometry); |
| 781 | draw_info->affine.sx=cos(DegreesToRadians( |
| 782 | fmod(geometry_info.rho,360.0))); |
| 783 | draw_info->affine.rx=sin(DegreesToRadians( |
| 784 | fmod(geometry_info.rho,360.0))); |
| 785 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 786 | fmod(geometry_info.sigma,360.0)))); |
| 787 | draw_info->affine.sy=cos(DegreesToRadians( |
| 788 | fmod(geometry_info.sigma,360.0))); |
| 789 | (void) AnnotateImage(*image,draw_info); |
| 790 | InheritException(exception,&(*image)->exception); |
| 791 | break; |
| 792 | } |
| 793 | if (LocaleCompare("antialias",option+1) == 0) |
| 794 | { |
| 795 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 796 | MagickFalse; |
| 797 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 798 | MagickFalse; |
| 799 | break; |
| 800 | } |
| 801 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 802 | { |
| 803 | /* |
| 804 | Auto Adjust Gamma of image based on its mean |
| 805 | */ |
| 806 | (void) SyncImageSettings(mogrify_info,*image); |
| 807 | (void) AutoGammaImageChannel(*image,channel); |
| 808 | break; |
| 809 | } |
| 810 | if (LocaleCompare("auto-level",option+1) == 0) |
| 811 | { |
| 812 | /* |
| 813 | Perfectly Normalize (max/min stretch) the image |
| 814 | */ |
| 815 | (void) SyncImageSettings(mogrify_info,*image); |
| 816 | (void) AutoLevelImageChannel(*image,channel); |
| 817 | break; |
| 818 | } |
| 819 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 820 | { |
| 821 | (void) SyncImageSettings(mogrify_info,*image); |
| 822 | switch ((*image)->orientation) |
| 823 | { |
| 824 | case TopRightOrientation: |
| 825 | { |
| 826 | mogrify_image=FlopImage(*image,exception); |
| 827 | break; |
| 828 | } |
| 829 | case BottomRightOrientation: |
| 830 | { |
| 831 | mogrify_image=RotateImage(*image,180.0,exception); |
| 832 | break; |
| 833 | } |
| 834 | case BottomLeftOrientation: |
| 835 | { |
| 836 | mogrify_image=FlipImage(*image,exception); |
| 837 | break; |
| 838 | } |
| 839 | case LeftTopOrientation: |
| 840 | { |
| 841 | mogrify_image=TransposeImage(*image,exception); |
| 842 | break; |
| 843 | } |
| 844 | case RightTopOrientation: |
| 845 | { |
| 846 | mogrify_image=RotateImage(*image,90.0,exception); |
| 847 | break; |
| 848 | } |
| 849 | case RightBottomOrientation: |
| 850 | { |
| 851 | mogrify_image=TransverseImage(*image,exception); |
| 852 | break; |
| 853 | } |
| 854 | case LeftBottomOrientation: |
| 855 | { |
| 856 | mogrify_image=RotateImage(*image,270.0,exception); |
| 857 | break; |
| 858 | } |
| 859 | default: |
| 860 | break; |
| 861 | } |
| 862 | if (mogrify_image != (Image *) NULL) |
| 863 | mogrify_image->orientation=TopLeftOrientation; |
| 864 | break; |
| 865 | } |
| 866 | break; |
| 867 | } |
| 868 | case 'b': |
| 869 | { |
| 870 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 871 | { |
| 872 | /* |
| 873 | Black threshold image. |
| 874 | */ |
| 875 | (void) SyncImageSettings(mogrify_info,*image); |
| 876 | (void) BlackThresholdImageChannel(*image,channel,argv[i+1], |
| 877 | exception); |
| 878 | InheritException(exception,&(*image)->exception); |
| 879 | break; |
| 880 | } |
| 881 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 882 | { |
| 883 | /* |
| 884 | Blue shift image. |
| 885 | */ |
| 886 | (void) SyncImageSettings(mogrify_info,*image); |
| 887 | geometry_info.rho=1.5; |
| 888 | if (*option == '-') |
| 889 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 890 | mogrify_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 891 | break; |
| 892 | } |
| 893 | if (LocaleCompare("blur",option+1) == 0) |
| 894 | { |
| 895 | /* |
| 896 | Gaussian blur image. |
| 897 | */ |
| 898 | (void) SyncImageSettings(mogrify_info,*image); |
| 899 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 900 | if ((flags & SigmaValue) == 0) |
| 901 | geometry_info.sigma=1.0; |
| 902 | mogrify_image=BlurImageChannel(*image,channel,geometry_info.rho, |
| 903 | geometry_info.sigma,exception); |
| 904 | break; |
| 905 | } |
| 906 | if (LocaleCompare("border",option+1) == 0) |
| 907 | { |
| 908 | /* |
| 909 | Surround image with a border of solid color. |
| 910 | */ |
| 911 | (void) SyncImageSettings(mogrify_info,*image); |
| 912 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 913 | if ((flags & SigmaValue) == 0) |
| 914 | geometry.height=geometry.width; |
| 915 | mogrify_image=BorderImage(*image,&geometry,exception); |
| 916 | break; |
| 917 | } |
| 918 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 919 | { |
| 920 | if (*option == '+') |
| 921 | { |
| 922 | (void) QueryColorDatabase(BorderColor,&draw_info->border_color, |
| 923 | exception); |
| 924 | break; |
| 925 | } |
| 926 | (void) QueryColorDatabase(argv[i+1],&draw_info->border_color, |
| 927 | exception); |
| 928 | break; |
| 929 | } |
| 930 | if (LocaleCompare("box",option+1) == 0) |
| 931 | { |
| 932 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 933 | exception); |
| 934 | break; |
| 935 | } |
| 936 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 937 | { |
| 938 | double |
| 939 | brightness, |
| 940 | contrast; |
| 941 | |
| 942 | GeometryInfo |
| 943 | geometry_info; |
| 944 | |
| 945 | MagickStatusType |
| 946 | flags; |
| 947 | |
| 948 | /* |
| 949 | Brightness / contrast image. |
| 950 | */ |
| 951 | (void) SyncImageSettings(mogrify_info,*image); |
| 952 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 953 | brightness=geometry_info.rho; |
| 954 | contrast=0.0; |
| 955 | if ((flags & SigmaValue) != 0) |
| 956 | contrast=geometry_info.sigma; |
| 957 | (void) BrightnessContrastImageChannel(*image,channel,brightness, |
| 958 | contrast); |
| 959 | InheritException(exception,&(*image)->exception); |
| 960 | break; |
| 961 | } |
| 962 | break; |
| 963 | } |
| 964 | case 'c': |
| 965 | { |
| 966 | if (LocaleCompare("cdl",option+1) == 0) |
| 967 | { |
| 968 | char |
| 969 | *color_correction_collection; |
| 970 | |
| 971 | /* |
| 972 | Color correct with a color decision list. |
| 973 | */ |
| 974 | (void) SyncImageSettings(mogrify_info,*image); |
| 975 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 976 | if (color_correction_collection == (char *) NULL) |
| 977 | break; |
| 978 | (void) ColorDecisionListImage(*image,color_correction_collection); |
| 979 | InheritException(exception,&(*image)->exception); |
| 980 | break; |
| 981 | } |
| 982 | if (LocaleCompare("channel",option+1) == 0) |
| 983 | { |
| 984 | if (*option == '+') |
| 985 | channel=DefaultChannels; |
| 986 | else |
| 987 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 988 | break; |
| 989 | } |
| 990 | if (LocaleCompare("charcoal",option+1) == 0) |
| 991 | { |
| 992 | /* |
| 993 | Charcoal image. |
| 994 | */ |
| 995 | (void) SyncImageSettings(mogrify_info,*image); |
| 996 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 997 | if ((flags & SigmaValue) == 0) |
| 998 | geometry_info.sigma=1.0; |
| 999 | mogrify_image=CharcoalImage(*image,geometry_info.rho, |
| 1000 | geometry_info.sigma,exception); |
| 1001 | break; |
| 1002 | } |
| 1003 | if (LocaleCompare("chop",option+1) == 0) |
| 1004 | { |
| 1005 | /* |
| 1006 | Chop the image. |
| 1007 | */ |
| 1008 | (void) SyncImageSettings(mogrify_info,*image); |
| 1009 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1010 | mogrify_image=ChopImage(*image,&geometry,exception); |
| 1011 | break; |
| 1012 | } |
| 1013 | if (LocaleCompare("clamp",option+1) == 0) |
| 1014 | { |
| 1015 | /* |
| 1016 | Clamp image. |
| 1017 | */ |
| 1018 | (void) SyncImageSettings(mogrify_info,*image); |
| 1019 | (void) ClampImageChannel(*image,channel); |
| 1020 | InheritException(exception,&(*image)->exception); |
| 1021 | break; |
| 1022 | } |
| 1023 | if (LocaleCompare("clip",option+1) == 0) |
| 1024 | { |
| 1025 | (void) SyncImageSettings(mogrify_info,*image); |
| 1026 | if (*option == '+') |
| 1027 | { |
| 1028 | (void) SetImageClipMask(*image,(Image *) NULL); |
| 1029 | InheritException(exception,&(*image)->exception); |
| 1030 | break; |
| 1031 | } |
| 1032 | (void) ClipImage(*image); |
| 1033 | InheritException(exception,&(*image)->exception); |
| 1034 | break; |
| 1035 | } |
| 1036 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1037 | { |
| 1038 | CacheView |
| 1039 | *mask_view; |
| 1040 | |
| 1041 | Image |
| 1042 | *mask_image; |
| 1043 | |
| 1044 | register PixelPacket |
| 1045 | *restrict q; |
| 1046 | |
| 1047 | register ssize_t |
| 1048 | x; |
| 1049 | |
| 1050 | ssize_t |
| 1051 | y; |
| 1052 | |
| 1053 | (void) SyncImageSettings(mogrify_info,*image); |
| 1054 | if (*option == '+') |
| 1055 | { |
| 1056 | /* |
| 1057 | Remove a mask. |
| 1058 | */ |
| 1059 | (void) SetImageMask(*image,(Image *) NULL); |
| 1060 | InheritException(exception,&(*image)->exception); |
| 1061 | break; |
| 1062 | } |
| 1063 | /* |
| 1064 | Set the image mask. |
| 1065 | FUTURE: This Should Be a SetImageAlphaChannel() call, Or two. |
| 1066 | */ |
| 1067 | mask_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 1068 | if (mask_image == (Image *) NULL) |
| 1069 | break; |
| 1070 | if (SetImageStorageClass(mask_image,DirectClass) == MagickFalse) |
| 1071 | return(MagickFalse); |
| 1072 | mask_view=AcquireCacheView(mask_image); |
| 1073 | for (y=0; y < (ssize_t) mask_image->rows; y++) |
| 1074 | { |
| 1075 | q=GetCacheViewAuthenticPixels(mask_view,0,y,mask_image->columns,1, |
| 1076 | exception); |
| 1077 | if (q == (PixelPacket *) NULL) |
| 1078 | break; |
| 1079 | for (x=0; x < (ssize_t) mask_image->columns; x++) |
| 1080 | { |
| 1081 | if (mask_image->matte == MagickFalse) |
| 1082 | q->opacity=PixelIntensityToQuantum(q); |
| 1083 | q->red=q->opacity; |
| 1084 | q->green=q->opacity; |
| 1085 | q->blue=q->opacity; |
| 1086 | q++; |
| 1087 | } |
| 1088 | if (SyncCacheViewAuthenticPixels(mask_view,exception) == MagickFalse) |
| 1089 | break; |
| 1090 | } |
| 1091 | mask_view=DestroyCacheView(mask_view); |
| 1092 | mask_image->matte=MagickTrue; |
| 1093 | (void) SetImageClipMask(*image,mask_image); |
| 1094 | mask_image=DestroyImage(mask_image); |
| 1095 | InheritException(exception,&(*image)->exception); |
| 1096 | break; |
| 1097 | } |
| 1098 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1099 | { |
| 1100 | (void) SyncImageSettings(mogrify_info,*image); |
| 1101 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
| 1102 | MagickFalse); |
| 1103 | InheritException(exception,&(*image)->exception); |
| 1104 | break; |
| 1105 | } |
| 1106 | if (LocaleCompare("colorize",option+1) == 0) |
| 1107 | { |
| 1108 | /* |
| 1109 | Colorize the image. |
| 1110 | */ |
| 1111 | (void) SyncImageSettings(mogrify_info,*image); |
| 1112 | mogrify_image=ColorizeImage(*image,argv[i+1],draw_info->fill, |
| 1113 | exception); |
| 1114 | break; |
| 1115 | } |
| 1116 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1117 | { |
| 1118 | KernelInfo |
| 1119 | *kernel; |
| 1120 | |
| 1121 | (void) SyncImageSettings(mogrify_info,*image); |
| 1122 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1123 | if (kernel == (KernelInfo *) NULL) |
| 1124 | break; |
| 1125 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 1126 | kernel=DestroyKernelInfo(kernel); |
| 1127 | break; |
| 1128 | } |
| 1129 | if (LocaleCompare("colors",option+1) == 0) |
| 1130 | { |
| 1131 | /* |
| 1132 | Reduce the number of colors in the image. |
| 1133 | */ |
| 1134 | (void) SyncImageSettings(mogrify_info,*image); |
| 1135 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
| 1136 | if (quantize_info->number_colors == 0) |
| 1137 | break; |
| 1138 | if (((*image)->storage_class == DirectClass) || |
| 1139 | (*image)->colors > quantize_info->number_colors) |
| 1140 | (void) QuantizeImage(quantize_info,*image); |
| 1141 | else |
| 1142 | (void) CompressImageColormap(*image); |
| 1143 | InheritException(exception,&(*image)->exception); |
| 1144 | break; |
| 1145 | } |
| 1146 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1147 | { |
| 1148 | ColorspaceType |
| 1149 | colorspace; |
| 1150 | |
| 1151 | (void) SyncImageSettings(mogrify_info,*image); |
| 1152 | if (*option == '+') |
| 1153 | { |
| 1154 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1155 | InheritException(exception,&(*image)->exception); |
| 1156 | break; |
| 1157 | } |
| 1158 | colorspace=(ColorspaceType) ParseCommandOption( |
| 1159 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1160 | (void) TransformImageColorspace(*image,colorspace); |
| 1161 | InheritException(exception,&(*image)->exception); |
| 1162 | break; |
| 1163 | } |
| 1164 | if (LocaleCompare("contrast",option+1) == 0) |
| 1165 | { |
| 1166 | (void) SyncImageSettings(mogrify_info,*image); |
| 1167 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
| 1168 | MagickFalse); |
| 1169 | InheritException(exception,&(*image)->exception); |
| 1170 | break; |
| 1171 | } |
| 1172 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1173 | { |
| 1174 | double |
| 1175 | black_point, |
| 1176 | white_point; |
| 1177 | |
| 1178 | MagickStatusType |
| 1179 | flags; |
| 1180 | |
| 1181 | /* |
| 1182 | Contrast stretch image. |
| 1183 | */ |
| 1184 | (void) SyncImageSettings(mogrify_info,*image); |
| 1185 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1186 | black_point=geometry_info.rho; |
| 1187 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1188 | black_point; |
| 1189 | if ((flags & PercentValue) != 0) |
| 1190 | { |
| 1191 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1192 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1193 | } |
| 1194 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1195 | white_point; |
| 1196 | (void) ContrastStretchImageChannel(*image,channel,black_point, |
| 1197 | white_point); |
| 1198 | InheritException(exception,&(*image)->exception); |
| 1199 | break; |
| 1200 | } |
| 1201 | if (LocaleCompare("convolve",option+1) == 0) |
| 1202 | { |
| 1203 | double |
| 1204 | gamma; |
| 1205 | |
| 1206 | KernelInfo |
| 1207 | *kernel; |
| 1208 | |
| 1209 | register ssize_t |
| 1210 | j; |
| 1211 | |
| 1212 | (void) SyncImageSettings(mogrify_info,*image); |
| 1213 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1214 | if (kernel == (KernelInfo *) NULL) |
| 1215 | break; |
| 1216 | gamma=0.0; |
| 1217 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
| 1218 | gamma+=kernel->values[j]; |
| 1219 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
| 1220 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
| 1221 | kernel->values[j]*=gamma; |
| 1222 | mogrify_image=FilterImageChannel(*image,channel,kernel,exception); |
| 1223 | kernel=DestroyKernelInfo(kernel); |
| 1224 | break; |
| 1225 | } |
| 1226 | if (LocaleCompare("crop",option+1) == 0) |
| 1227 | { |
| 1228 | /* |
| 1229 | Crop a image to a smaller size |
| 1230 | */ |
| 1231 | (void) SyncImageSettings(mogrify_info,*image); |
| 1232 | #if 0 |
| 1233 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1234 | if (((geometry.width != 0) || (geometry.height != 0)) && |
| 1235 | ((flags & XValue) == 0) && ((flags & YValue) == 0)) |
| 1236 | break; |
| 1237 | #endif |
| 1238 | #if 0 |
| 1239 | mogrify_image=CloneImage(*image,0,0,MagickTrue,&(*image)->exception); |
| 1240 | mogrify_image->next = mogrify_image->previous = (Image *)NULL; |
| 1241 | (void) TransformImage(&mogrify_image,argv[i+1],(char *) NULL); |
| 1242 | InheritException(exception,&mogrify_image->exception); |
| 1243 | #else |
| 1244 | mogrify_image=CropImageToTiles(*image,argv[i+1],exception); |
| 1245 | #endif |
| 1246 | break; |
| 1247 | } |
| 1248 | if (LocaleCompare("cycle",option+1) == 0) |
| 1249 | { |
| 1250 | /* |
| 1251 | Cycle an image colormap. |
| 1252 | */ |
| 1253 | (void) SyncImageSettings(mogrify_info,*image); |
| 1254 | (void) CycleColormapImage(*image,(ssize_t) StringToLong(argv[i+1])); |
| 1255 | InheritException(exception,&(*image)->exception); |
| 1256 | break; |
| 1257 | } |
| 1258 | break; |
| 1259 | } |
| 1260 | case 'd': |
| 1261 | { |
| 1262 | if (LocaleCompare("decipher",option+1) == 0) |
| 1263 | { |
| 1264 | StringInfo |
| 1265 | *passkey; |
| 1266 | |
| 1267 | /* |
| 1268 | Decipher pixels. |
| 1269 | */ |
| 1270 | (void) SyncImageSettings(mogrify_info,*image); |
| 1271 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1272 | if (passkey != (StringInfo *) NULL) |
| 1273 | { |
| 1274 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1275 | passkey=DestroyStringInfo(passkey); |
| 1276 | } |
| 1277 | break; |
| 1278 | } |
| 1279 | if (LocaleCompare("density",option+1) == 0) |
| 1280 | { |
| 1281 | /* |
| 1282 | Set image density. |
| 1283 | */ |
| 1284 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1285 | break; |
| 1286 | } |
| 1287 | if (LocaleCompare("depth",option+1) == 0) |
| 1288 | { |
| 1289 | (void) SyncImageSettings(mogrify_info,*image); |
| 1290 | if (*option == '+') |
| 1291 | { |
| 1292 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1293 | break; |
| 1294 | } |
| 1295 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
| 1296 | break; |
| 1297 | } |
| 1298 | if (LocaleCompare("deskew",option+1) == 0) |
| 1299 | { |
| 1300 | double |
| 1301 | threshold; |
| 1302 | |
| 1303 | /* |
| 1304 | Straighten the image. |
| 1305 | */ |
| 1306 | (void) SyncImageSettings(mogrify_info,*image); |
| 1307 | if (*option == '+') |
| 1308 | threshold=40.0*QuantumRange/100.0; |
| 1309 | else |
| 1310 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 1311 | mogrify_image=DeskewImage(*image,threshold,exception); |
| 1312 | break; |
| 1313 | } |
| 1314 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1315 | { |
| 1316 | /* |
| 1317 | Reduce the speckles within an image. |
| 1318 | */ |
| 1319 | (void) SyncImageSettings(mogrify_info,*image); |
| 1320 | mogrify_image=DespeckleImage(*image,exception); |
| 1321 | break; |
| 1322 | } |
| 1323 | if (LocaleCompare("display",option+1) == 0) |
| 1324 | { |
| 1325 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1326 | break; |
| 1327 | } |
| 1328 | if (LocaleCompare("distort",option+1) == 0) |
| 1329 | { |
| 1330 | char |
| 1331 | *args, |
| 1332 | token[MaxTextExtent]; |
| 1333 | |
| 1334 | const char |
| 1335 | *p; |
| 1336 | |
| 1337 | DistortImageMethod |
| 1338 | method; |
| 1339 | |
| 1340 | double |
| 1341 | *arguments; |
| 1342 | |
| 1343 | register ssize_t |
| 1344 | x; |
| 1345 | |
| 1346 | size_t |
| 1347 | number_arguments; |
| 1348 | |
| 1349 | /* |
| 1350 | Distort image. |
| 1351 | */ |
| 1352 | (void) SyncImageSettings(mogrify_info,*image); |
| 1353 | method=(DistortImageMethod) ParseCommandOption(MagickDistortOptions, |
| 1354 | MagickFalse,argv[i+1]); |
| 1355 | if ( method == ResizeDistortion ) |
| 1356 | { |
| 1357 | /* Special Case - Argument is actually a resize geometry! |
| 1358 | ** Convert that to an appropriate distortion argument array. |
| 1359 | */ |
| 1360 | double |
| 1361 | resize_args[2]; |
| 1362 | (void) ParseRegionGeometry(*image,argv[i+2],&geometry, |
| 1363 | exception); |
| 1364 | resize_args[0]=(double)geometry.width; |
| 1365 | resize_args[1]=(double)geometry.height; |
| 1366 | mogrify_image=DistortImage(*image,method,(size_t)2, |
| 1367 | resize_args,MagickTrue,exception); |
| 1368 | break; |
| 1369 | } |
| 1370 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1371 | InheritException(exception,&(*image)->exception); |
| 1372 | if (args == (char *) NULL) |
| 1373 | break; |
| 1374 | p=(char *) args; |
| 1375 | for (x=0; *p != '\0'; x++) |
| 1376 | { |
| 1377 | GetMagickToken(p,&p,token); |
| 1378 | if (*token == ',') |
| 1379 | GetMagickToken(p,&p,token); |
| 1380 | } |
| 1381 | number_arguments=(size_t) x; |
| 1382 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1383 | sizeof(*arguments)); |
| 1384 | if (arguments == (double *) NULL) |
| 1385 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1386 | "MemoryAllocationFailed",(*image)->filename); |
| 1387 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1388 | sizeof(*arguments)); |
| 1389 | p=(char *) args; |
| 1390 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
| 1391 | { |
| 1392 | GetMagickToken(p,&p,token); |
| 1393 | if (*token == ',') |
| 1394 | GetMagickToken(p,&p,token); |
| 1395 | arguments[x]=StringToDouble(token); |
| 1396 | } |
| 1397 | args=DestroyString(args); |
| 1398 | mogrify_image=DistortImage(*image,method,number_arguments,arguments, |
| 1399 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1400 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1401 | break; |
| 1402 | } |
| 1403 | if (LocaleCompare("dither",option+1) == 0) |
| 1404 | { |
| 1405 | if (*option == '+') |
| 1406 | { |
| 1407 | quantize_info->dither=MagickFalse; |
| 1408 | break; |
| 1409 | } |
| 1410 | quantize_info->dither=MagickTrue; |
| 1411 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
| 1412 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1413 | if (quantize_info->dither_method == NoDitherMethod) |
| 1414 | quantize_info->dither=MagickFalse; |
| 1415 | break; |
| 1416 | } |
| 1417 | if (LocaleCompare("draw",option+1) == 0) |
| 1418 | { |
| 1419 | /* |
| 1420 | Draw image. |
| 1421 | */ |
| 1422 | (void) SyncImageSettings(mogrify_info,*image); |
| 1423 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
| 1424 | (void) DrawImage(*image,draw_info); |
| 1425 | InheritException(exception,&(*image)->exception); |
| 1426 | break; |
| 1427 | } |
| 1428 | break; |
| 1429 | } |
| 1430 | case 'e': |
| 1431 | { |
| 1432 | if (LocaleCompare("edge",option+1) == 0) |
| 1433 | { |
| 1434 | /* |
| 1435 | Enhance edges in the image. |
| 1436 | */ |
| 1437 | (void) SyncImageSettings(mogrify_info,*image); |
| 1438 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1439 | if ((flags & SigmaValue) == 0) |
| 1440 | geometry_info.sigma=1.0; |
| 1441 | mogrify_image=EdgeImage(*image,geometry_info.rho,exception); |
| 1442 | break; |
| 1443 | } |
| 1444 | if (LocaleCompare("emboss",option+1) == 0) |
| 1445 | { |
| 1446 | /* |
| 1447 | Gaussian embossen image. |
| 1448 | */ |
| 1449 | (void) SyncImageSettings(mogrify_info,*image); |
| 1450 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1451 | if ((flags & SigmaValue) == 0) |
| 1452 | geometry_info.sigma=1.0; |
| 1453 | mogrify_image=EmbossImage(*image,geometry_info.rho, |
| 1454 | geometry_info.sigma,exception); |
| 1455 | break; |
| 1456 | } |
| 1457 | if (LocaleCompare("encipher",option+1) == 0) |
| 1458 | { |
| 1459 | StringInfo |
| 1460 | *passkey; |
| 1461 | |
| 1462 | /* |
| 1463 | Encipher pixels. |
| 1464 | */ |
| 1465 | (void) SyncImageSettings(mogrify_info,*image); |
| 1466 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1467 | if (passkey != (StringInfo *) NULL) |
| 1468 | { |
| 1469 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1470 | passkey=DestroyStringInfo(passkey); |
| 1471 | } |
| 1472 | break; |
| 1473 | } |
| 1474 | if (LocaleCompare("encoding",option+1) == 0) |
| 1475 | { |
| 1476 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1477 | break; |
| 1478 | } |
| 1479 | if (LocaleCompare("enhance",option+1) == 0) |
| 1480 | { |
| 1481 | /* |
| 1482 | Enhance image. |
| 1483 | */ |
| 1484 | (void) SyncImageSettings(mogrify_info,*image); |
| 1485 | mogrify_image=EnhanceImage(*image,exception); |
| 1486 | break; |
| 1487 | } |
| 1488 | if (LocaleCompare("equalize",option+1) == 0) |
| 1489 | { |
| 1490 | /* |
| 1491 | Equalize image. |
| 1492 | */ |
| 1493 | (void) SyncImageSettings(mogrify_info,*image); |
| 1494 | (void) EqualizeImageChannel(*image,channel); |
| 1495 | InheritException(exception,&(*image)->exception); |
| 1496 | break; |
| 1497 | } |
| 1498 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1499 | { |
| 1500 | double |
| 1501 | constant; |
| 1502 | |
| 1503 | MagickEvaluateOperator |
| 1504 | op; |
| 1505 | |
| 1506 | (void) SyncImageSettings(mogrify_info,*image); |
| 1507 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
| 1508 | MagickFalse,argv[i+1]); |
| 1509 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
| 1510 | (void) EvaluateImageChannel(*image,channel,op,constant,exception); |
| 1511 | break; |
| 1512 | } |
| 1513 | if (LocaleCompare("extent",option+1) == 0) |
| 1514 | { |
| 1515 | /* |
| 1516 | Set the image extent. |
| 1517 | */ |
| 1518 | (void) SyncImageSettings(mogrify_info,*image); |
| 1519 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1520 | if (geometry.width == 0) |
| 1521 | geometry.width=(*image)->columns; |
| 1522 | if (geometry.height == 0) |
| 1523 | geometry.height=(*image)->rows; |
| 1524 | mogrify_image=ExtentImage(*image,&geometry,exception); |
| 1525 | break; |
| 1526 | } |
| 1527 | break; |
| 1528 | } |
| 1529 | case 'f': |
| 1530 | { |
| 1531 | if (LocaleCompare("family",option+1) == 0) |
| 1532 | { |
| 1533 | if (*option == '+') |
| 1534 | { |
| 1535 | if (draw_info->family != (char *) NULL) |
| 1536 | draw_info->family=DestroyString(draw_info->family); |
| 1537 | break; |
| 1538 | } |
| 1539 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1540 | break; |
| 1541 | } |
| 1542 | if (LocaleCompare("features",option+1) == 0) |
| 1543 | { |
| 1544 | if (*option == '+') |
| 1545 | { |
| 1546 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1547 | break; |
| 1548 | } |
| 1549 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1550 | break; |
| 1551 | } |
| 1552 | if (LocaleCompare("fill",option+1) == 0) |
| 1553 | { |
| 1554 | ExceptionInfo |
| 1555 | *sans; |
| 1556 | |
| 1557 | GetMagickPixelPacket(*image,&fill); |
| 1558 | if (*option == '+') |
| 1559 | { |
| 1560 | (void) QueryMagickColor("none",&fill,exception); |
| 1561 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1562 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1563 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1564 | break; |
| 1565 | } |
| 1566 | sans=AcquireExceptionInfo(); |
| 1567 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1568 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1569 | sans=DestroyExceptionInfo(sans); |
| 1570 | if (status == MagickFalse) |
| 1571 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 1572 | exception); |
| 1573 | break; |
| 1574 | } |
| 1575 | if (LocaleCompare("flip",option+1) == 0) |
| 1576 | { |
| 1577 | /* |
| 1578 | Flip image scanlines. |
| 1579 | */ |
| 1580 | (void) SyncImageSettings(mogrify_info,*image); |
| 1581 | mogrify_image=FlipImage(*image,exception); |
| 1582 | break; |
| 1583 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1584 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1585 | { |
| 1586 | MagickPixelPacket |
| 1587 | target; |
| 1588 | |
| 1589 | /* |
| 1590 | Floodfill image. |
| 1591 | */ |
| 1592 | (void) SyncImageSettings(mogrify_info,*image); |
| 1593 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1594 | (void) QueryMagickColor(argv[i+2],&target,exception); |
| 1595 | (void) FloodfillPaintImage(*image,channel,draw_info,&target, |
| 1596 | geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue); |
| 1597 | InheritException(exception,&(*image)->exception); |
| 1598 | break; |
| 1599 | } |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame^] | 1600 | if (LocaleCompare("flop",option+1) == 0) |
| 1601 | { |
| 1602 | /* |
| 1603 | Flop image scanlines. |
| 1604 | */ |
| 1605 | (void) SyncImageSettings(mogrify_info,*image); |
| 1606 | mogrify_image=FlopImage(*image,exception); |
| 1607 | break; |
| 1608 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 1609 | if (LocaleCompare("font",option+1) == 0) |
| 1610 | { |
| 1611 | if (*option == '+') |
| 1612 | { |
| 1613 | if (draw_info->font != (char *) NULL) |
| 1614 | draw_info->font=DestroyString(draw_info->font); |
| 1615 | break; |
| 1616 | } |
| 1617 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1618 | break; |
| 1619 | } |
| 1620 | if (LocaleCompare("format",option+1) == 0) |
| 1621 | { |
| 1622 | format=argv[i+1]; |
| 1623 | break; |
| 1624 | } |
| 1625 | if (LocaleCompare("frame",option+1) == 0) |
| 1626 | { |
| 1627 | FrameInfo |
| 1628 | frame_info; |
| 1629 | |
| 1630 | /* |
| 1631 | Surround image with an ornamental border. |
| 1632 | */ |
| 1633 | (void) SyncImageSettings(mogrify_info,*image); |
| 1634 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1635 | frame_info.width=geometry.width; |
| 1636 | frame_info.height=geometry.height; |
| 1637 | if ((flags & HeightValue) == 0) |
| 1638 | frame_info.height=geometry.width; |
| 1639 | frame_info.outer_bevel=geometry.x; |
| 1640 | frame_info.inner_bevel=geometry.y; |
| 1641 | frame_info.x=(ssize_t) frame_info.width; |
| 1642 | frame_info.y=(ssize_t) frame_info.height; |
| 1643 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1644 | frame_info.height=(*image)->rows+2*frame_info.height; |
| 1645 | mogrify_image=FrameImage(*image,&frame_info,exception); |
| 1646 | break; |
| 1647 | } |
| 1648 | if (LocaleCompare("function",option+1) == 0) |
| 1649 | { |
| 1650 | char |
| 1651 | *arguments, |
| 1652 | token[MaxTextExtent]; |
| 1653 | |
| 1654 | const char |
| 1655 | *p; |
| 1656 | |
| 1657 | double |
| 1658 | *parameters; |
| 1659 | |
| 1660 | MagickFunction |
| 1661 | function; |
| 1662 | |
| 1663 | register ssize_t |
| 1664 | x; |
| 1665 | |
| 1666 | size_t |
| 1667 | number_parameters; |
| 1668 | |
| 1669 | /* |
| 1670 | Function Modify Image Values |
| 1671 | */ |
| 1672 | (void) SyncImageSettings(mogrify_info,*image); |
| 1673 | function=(MagickFunction) ParseCommandOption(MagickFunctionOptions, |
| 1674 | MagickFalse,argv[i+1]); |
| 1675 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 1676 | InheritException(exception,&(*image)->exception); |
| 1677 | if (arguments == (char *) NULL) |
| 1678 | break; |
| 1679 | p=(char *) arguments; |
| 1680 | for (x=0; *p != '\0'; x++) |
| 1681 | { |
| 1682 | GetMagickToken(p,&p,token); |
| 1683 | if (*token == ',') |
| 1684 | GetMagickToken(p,&p,token); |
| 1685 | } |
| 1686 | number_parameters=(size_t) x; |
| 1687 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1688 | sizeof(*parameters)); |
| 1689 | if (parameters == (double *) NULL) |
| 1690 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1691 | "MemoryAllocationFailed",(*image)->filename); |
| 1692 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1693 | sizeof(*parameters)); |
| 1694 | p=(char *) arguments; |
| 1695 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
| 1696 | { |
| 1697 | GetMagickToken(p,&p,token); |
| 1698 | if (*token == ',') |
| 1699 | GetMagickToken(p,&p,token); |
| 1700 | parameters[x]=StringToDouble(token); |
| 1701 | } |
| 1702 | arguments=DestroyString(arguments); |
| 1703 | (void) FunctionImageChannel(*image,channel,function, |
| 1704 | number_parameters,parameters,exception); |
| 1705 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1706 | break; |
| 1707 | } |
| 1708 | break; |
| 1709 | } |
| 1710 | case 'g': |
| 1711 | { |
| 1712 | if (LocaleCompare("gamma",option+1) == 0) |
| 1713 | { |
| 1714 | /* |
| 1715 | Gamma image. |
| 1716 | */ |
| 1717 | (void) SyncImageSettings(mogrify_info,*image); |
| 1718 | if (*option == '+') |
| 1719 | (*image)->gamma=StringToDouble(argv[i+1]); |
| 1720 | else |
| 1721 | { |
| 1722 | if (strchr(argv[i+1],',') != (char *) NULL) |
| 1723 | (void) GammaImage(*image,argv[i+1]); |
| 1724 | else |
| 1725 | (void) GammaImageChannel(*image,channel, |
| 1726 | StringToDouble(argv[i+1])); |
| 1727 | InheritException(exception,&(*image)->exception); |
| 1728 | } |
| 1729 | break; |
| 1730 | } |
| 1731 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1732 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1733 | { |
| 1734 | /* |
| 1735 | Gaussian blur image. |
| 1736 | */ |
| 1737 | (void) SyncImageSettings(mogrify_info,*image); |
| 1738 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1739 | if ((flags & SigmaValue) == 0) |
| 1740 | geometry_info.sigma=1.0; |
| 1741 | mogrify_image=GaussianBlurImageChannel(*image,channel, |
| 1742 | geometry_info.rho,geometry_info.sigma,exception); |
| 1743 | break; |
| 1744 | } |
| 1745 | if (LocaleCompare("geometry",option+1) == 0) |
| 1746 | { |
| 1747 | /* |
| 1748 | Record Image offset, Resize last image. |
| 1749 | */ |
| 1750 | (void) SyncImageSettings(mogrify_info,*image); |
| 1751 | if (*option == '+') |
| 1752 | { |
| 1753 | if ((*image)->geometry != (char *) NULL) |
| 1754 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1755 | break; |
| 1756 | } |
| 1757 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1758 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1759 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1760 | else |
| 1761 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 1762 | (*image)->filter,(*image)->blur,exception); |
| 1763 | break; |
| 1764 | } |
| 1765 | if (LocaleCompare("gravity",option+1) == 0) |
| 1766 | { |
| 1767 | if (*option == '+') |
| 1768 | { |
| 1769 | draw_info->gravity=UndefinedGravity; |
| 1770 | break; |
| 1771 | } |
| 1772 | draw_info->gravity=(GravityType) ParseCommandOption( |
| 1773 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1774 | break; |
| 1775 | } |
| 1776 | break; |
| 1777 | } |
| 1778 | case 'h': |
| 1779 | { |
| 1780 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1781 | { |
| 1782 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1783 | break; |
| 1784 | } |
| 1785 | break; |
| 1786 | } |
| 1787 | case 'i': |
| 1788 | { |
| 1789 | if (LocaleCompare("identify",option+1) == 0) |
| 1790 | { |
| 1791 | char |
| 1792 | *text; |
| 1793 | |
| 1794 | (void) SyncImageSettings(mogrify_info,*image); |
| 1795 | if (format == (char *) NULL) |
| 1796 | { |
| 1797 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose); |
| 1798 | InheritException(exception,&(*image)->exception); |
| 1799 | break; |
| 1800 | } |
| 1801 | text=InterpretImageProperties(mogrify_info,*image,format); |
| 1802 | InheritException(exception,&(*image)->exception); |
| 1803 | if (text == (char *) NULL) |
| 1804 | break; |
| 1805 | (void) fputs(text,stdout); |
| 1806 | (void) fputc('\n',stdout); |
| 1807 | text=DestroyString(text); |
| 1808 | break; |
| 1809 | } |
| 1810 | if (LocaleCompare("implode",option+1) == 0) |
| 1811 | { |
| 1812 | /* |
| 1813 | Implode image. |
| 1814 | */ |
| 1815 | (void) SyncImageSettings(mogrify_info,*image); |
| 1816 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1817 | mogrify_image=ImplodeImage(*image,geometry_info.rho,exception); |
| 1818 | break; |
| 1819 | } |
| 1820 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1821 | { |
| 1822 | if (*option == '+') |
| 1823 | (void) ParseGeometry("0",&geometry_info); |
| 1824 | else |
| 1825 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1826 | draw_info->interline_spacing=geometry_info.rho; |
| 1827 | break; |
| 1828 | } |
| 1829 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1830 | { |
| 1831 | if (*option == '+') |
| 1832 | (void) ParseGeometry("0",&geometry_info); |
| 1833 | else |
| 1834 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1835 | draw_info->interword_spacing=geometry_info.rho; |
| 1836 | break; |
| 1837 | } |
| 1838 | break; |
| 1839 | } |
| 1840 | case 'k': |
| 1841 | { |
| 1842 | if (LocaleCompare("kerning",option+1) == 0) |
| 1843 | { |
| 1844 | if (*option == '+') |
| 1845 | (void) ParseGeometry("0",&geometry_info); |
| 1846 | else |
| 1847 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1848 | draw_info->kerning=geometry_info.rho; |
| 1849 | break; |
| 1850 | } |
| 1851 | break; |
| 1852 | } |
| 1853 | case 'l': |
| 1854 | { |
| 1855 | if (LocaleCompare("lat",option+1) == 0) |
| 1856 | { |
| 1857 | /* |
| 1858 | Local adaptive threshold image. |
| 1859 | */ |
| 1860 | (void) SyncImageSettings(mogrify_info,*image); |
| 1861 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1862 | if ((flags & PercentValue) != 0) |
| 1863 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 1864 | mogrify_image=AdaptiveThresholdImage(*image,(size_t) |
| 1865 | geometry_info.rho,(size_t) geometry_info.sigma,(ssize_t) |
| 1866 | geometry_info.xi,exception); |
| 1867 | break; |
| 1868 | } |
| 1869 | if (LocaleCompare("level",option+1) == 0) |
| 1870 | { |
| 1871 | MagickRealType |
| 1872 | black_point, |
| 1873 | gamma, |
| 1874 | white_point; |
| 1875 | |
| 1876 | MagickStatusType |
| 1877 | flags; |
| 1878 | |
| 1879 | /* |
| 1880 | Parse levels. |
| 1881 | */ |
| 1882 | (void) SyncImageSettings(mogrify_info,*image); |
| 1883 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1884 | black_point=geometry_info.rho; |
| 1885 | white_point=(MagickRealType) QuantumRange; |
| 1886 | if ((flags & SigmaValue) != 0) |
| 1887 | white_point=geometry_info.sigma; |
| 1888 | gamma=1.0; |
| 1889 | if ((flags & XiValue) != 0) |
| 1890 | gamma=geometry_info.xi; |
| 1891 | if ((flags & PercentValue) != 0) |
| 1892 | { |
| 1893 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 1894 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 1895 | } |
| 1896 | if ((flags & SigmaValue) == 0) |
| 1897 | white_point=(MagickRealType) QuantumRange-black_point; |
| 1898 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
| 1899 | (void) LevelizeImageChannel(*image,channel,black_point, |
| 1900 | white_point,gamma); |
| 1901 | else |
| 1902 | (void) LevelImageChannel(*image,channel,black_point,white_point, |
| 1903 | gamma); |
| 1904 | InheritException(exception,&(*image)->exception); |
| 1905 | break; |
| 1906 | } |
| 1907 | if (LocaleCompare("level-colors",option+1) == 0) |
| 1908 | { |
| 1909 | char |
| 1910 | token[MaxTextExtent]; |
| 1911 | |
| 1912 | const char |
| 1913 | *p; |
| 1914 | |
| 1915 | MagickPixelPacket |
| 1916 | black_point, |
| 1917 | white_point; |
| 1918 | |
| 1919 | p=(const char *) argv[i+1]; |
| 1920 | GetMagickToken(p,&p,token); /* get black point color */ |
| 1921 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1922 | (void) QueryMagickColor(token,&black_point,exception); |
| 1923 | else |
| 1924 | (void) QueryMagickColor("#000000",&black_point,exception); |
| 1925 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 1926 | GetMagickToken(p,&p,token); |
| 1927 | if (*token == '\0') |
| 1928 | white_point=black_point; /* set everything to that color */ |
| 1929 | else |
| 1930 | { |
| 1931 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
| 1932 | GetMagickToken(p,&p,token); /* Get white point color. */ |
| 1933 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
| 1934 | (void) QueryMagickColor(token,&white_point,exception); |
| 1935 | else |
| 1936 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
| 1937 | } |
| 1938 | (void) LevelColorsImageChannel(*image,channel,&black_point, |
| 1939 | &white_point,*option == '+' ? MagickTrue : MagickFalse); |
| 1940 | break; |
| 1941 | } |
| 1942 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 1943 | { |
| 1944 | double |
| 1945 | black_point, |
| 1946 | white_point; |
| 1947 | |
| 1948 | MagickStatusType |
| 1949 | flags; |
| 1950 | |
| 1951 | (void) SyncImageSettings(mogrify_info,*image); |
| 1952 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1953 | black_point=geometry_info.rho; |
| 1954 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 1955 | if ((flags & SigmaValue) != 0) |
| 1956 | white_point=geometry_info.sigma; |
| 1957 | if ((flags & PercentValue) != 0) |
| 1958 | { |
| 1959 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1960 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1961 | } |
| 1962 | if ((flags & SigmaValue) == 0) |
| 1963 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1964 | black_point; |
| 1965 | (void) LinearStretchImage(*image,black_point,white_point); |
| 1966 | InheritException(exception,&(*image)->exception); |
| 1967 | break; |
| 1968 | } |
| 1969 | if (LocaleCompare("linewidth",option+1) == 0) |
| 1970 | { |
| 1971 | draw_info->stroke_width=StringToDouble(argv[i+1]); |
| 1972 | break; |
| 1973 | } |
| 1974 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 1975 | { |
| 1976 | /* |
| 1977 | Liquid rescale image. |
| 1978 | */ |
| 1979 | (void) SyncImageSettings(mogrify_info,*image); |
| 1980 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1981 | if ((flags & XValue) == 0) |
| 1982 | geometry.x=1; |
| 1983 | if ((flags & YValue) == 0) |
| 1984 | geometry.y=0; |
| 1985 | mogrify_image=LiquidRescaleImage(*image,geometry.width, |
| 1986 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 1987 | break; |
| 1988 | } |
| 1989 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 1990 | { |
| 1991 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1992 | break; |
| 1993 | } |
| 1994 | break; |
| 1995 | } |
| 1996 | case 'm': |
| 1997 | { |
| 1998 | if (LocaleCompare("map",option+1) == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1999 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2000 | Image |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2001 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2002 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2003 | /* |
| 2004 | Transform image colors to match this set of colors. |
| 2005 | */ |
| 2006 | (void) SyncImageSettings(mogrify_info,*image); |
| 2007 | if (*option == '+') |
| 2008 | break; |
| 2009 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2010 | if (remap_image == (Image *) NULL) |
| 2011 | break; |
| 2012 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2013 | InheritException(exception,&(*image)->exception); |
| 2014 | remap_image=DestroyImage(remap_image); |
| 2015 | break; |
| 2016 | } |
| 2017 | if (LocaleCompare("mask",option+1) == 0) |
| 2018 | { |
| 2019 | Image |
| 2020 | *mask; |
| 2021 | |
| 2022 | (void) SyncImageSettings(mogrify_info,*image); |
| 2023 | if (*option == '+') |
| 2024 | { |
| 2025 | /* |
| 2026 | Remove a mask. |
| 2027 | */ |
| 2028 | (void) SetImageMask(*image,(Image *) NULL); |
| 2029 | InheritException(exception,&(*image)->exception); |
| 2030 | break; |
| 2031 | } |
| 2032 | /* |
| 2033 | Set the image mask. |
| 2034 | */ |
| 2035 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2036 | if (mask == (Image *) NULL) |
| 2037 | break; |
| 2038 | (void) SetImageMask(*image,mask); |
| 2039 | mask=DestroyImage(mask); |
| 2040 | InheritException(exception,&(*image)->exception); |
| 2041 | break; |
| 2042 | } |
| 2043 | if (LocaleCompare("matte",option+1) == 0) |
| 2044 | { |
| 2045 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
| 2046 | SetAlphaChannel : DeactivateAlphaChannel ); |
| 2047 | InheritException(exception,&(*image)->exception); |
| 2048 | break; |
| 2049 | } |
| 2050 | if (LocaleCompare("median",option+1) == 0) |
| 2051 | { |
| 2052 | /* |
| 2053 | Median filter image. |
| 2054 | */ |
| 2055 | (void) SyncImageSettings(mogrify_info,*image); |
| 2056 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2057 | mogrify_image=StatisticImageChannel(*image,channel,MedianStatistic, |
| 2058 | (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception); |
| 2059 | break; |
| 2060 | } |
| 2061 | if (LocaleCompare("mode",option+1) == 0) |
| 2062 | { |
| 2063 | /* |
| 2064 | Mode image. |
| 2065 | */ |
| 2066 | (void) SyncImageSettings(mogrify_info,*image); |
| 2067 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2068 | mogrify_image=StatisticImageChannel(*image,channel,ModeStatistic, |
| 2069 | (size_t) geometry_info.rho,(size_t) geometry_info.rho,exception); |
| 2070 | break; |
| 2071 | } |
| 2072 | if (LocaleCompare("modulate",option+1) == 0) |
| 2073 | { |
| 2074 | (void) SyncImageSettings(mogrify_info,*image); |
| 2075 | (void) ModulateImage(*image,argv[i+1]); |
| 2076 | InheritException(exception,&(*image)->exception); |
| 2077 | break; |
| 2078 | } |
| 2079 | if (LocaleCompare("monitor",option+1) == 0) |
| 2080 | { |
| 2081 | if (*option == '+') |
| 2082 | { |
| 2083 | (void) SetImageProgressMonitor(*image, |
| 2084 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2085 | break; |
| 2086 | } |
| 2087 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2088 | (void *) NULL); |
| 2089 | break; |
| 2090 | } |
| 2091 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2092 | { |
| 2093 | (void) SyncImageSettings(mogrify_info,*image); |
| 2094 | (void) SetImageType(*image,BilevelType); |
| 2095 | InheritException(exception,&(*image)->exception); |
| 2096 | break; |
| 2097 | } |
| 2098 | if (LocaleCompare("morphology",option+1) == 0) |
| 2099 | { |
| 2100 | char |
| 2101 | token[MaxTextExtent]; |
| 2102 | |
| 2103 | const char |
| 2104 | *p; |
| 2105 | |
| 2106 | KernelInfo |
| 2107 | *kernel; |
| 2108 | |
| 2109 | MorphologyMethod |
| 2110 | method; |
| 2111 | |
| 2112 | ssize_t |
| 2113 | iterations; |
| 2114 | |
| 2115 | /* |
| 2116 | Morphological Image Operation |
| 2117 | */ |
| 2118 | (void) SyncImageSettings(mogrify_info,*image); |
| 2119 | p=argv[i+1]; |
| 2120 | GetMagickToken(p,&p,token); |
| 2121 | method=(MorphologyMethod) ParseCommandOption(MagickMorphologyOptions, |
| 2122 | MagickFalse,token); |
| 2123 | iterations=1L; |
| 2124 | GetMagickToken(p,&p,token); |
| 2125 | if ((*p == ':') || (*p == ',')) |
| 2126 | GetMagickToken(p,&p,token); |
| 2127 | if ((*p != '\0')) |
| 2128 | iterations=(ssize_t) StringToLong(p); |
| 2129 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2130 | if (kernel == (KernelInfo *) NULL) |
| 2131 | { |
| 2132 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2133 | OptionError,"UnabletoParseKernel","morphology"); |
| 2134 | status=MagickFalse; |
| 2135 | break; |
| 2136 | } |
| 2137 | mogrify_image=MorphologyImageChannel(*image,channel,method, |
| 2138 | iterations,kernel,exception); |
| 2139 | kernel=DestroyKernelInfo(kernel); |
| 2140 | break; |
| 2141 | } |
| 2142 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2143 | { |
| 2144 | /* |
| 2145 | Motion blur image. |
| 2146 | */ |
| 2147 | (void) SyncImageSettings(mogrify_info,*image); |
| 2148 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2149 | if ((flags & SigmaValue) == 0) |
| 2150 | geometry_info.sigma=1.0; |
| 2151 | mogrify_image=MotionBlurImageChannel(*image,channel, |
| 2152 | geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception); |
| 2153 | break; |
| 2154 | } |
| 2155 | break; |
| 2156 | } |
| 2157 | case 'n': |
| 2158 | { |
| 2159 | if (LocaleCompare("negate",option+1) == 0) |
| 2160 | { |
| 2161 | (void) SyncImageSettings(mogrify_info,*image); |
| 2162 | (void) NegateImageChannel(*image,channel,*option == '+' ? |
| 2163 | MagickTrue : MagickFalse); |
| 2164 | InheritException(exception,&(*image)->exception); |
| 2165 | break; |
| 2166 | } |
| 2167 | if (LocaleCompare("noise",option+1) == 0) |
| 2168 | { |
| 2169 | (void) SyncImageSettings(mogrify_info,*image); |
| 2170 | if (*option == '-') |
| 2171 | { |
| 2172 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2173 | mogrify_image=StatisticImageChannel(*image,channel, |
| 2174 | NonpeakStatistic,(size_t) geometry_info.rho,(size_t) |
| 2175 | geometry_info.rho,exception); |
| 2176 | } |
| 2177 | else |
| 2178 | { |
| 2179 | NoiseType |
| 2180 | noise; |
| 2181 | |
| 2182 | noise=(NoiseType) ParseCommandOption(MagickNoiseOptions, |
| 2183 | MagickFalse,argv[i+1]); |
| 2184 | mogrify_image=AddNoiseImageChannel(*image,channel,noise, |
| 2185 | exception); |
| 2186 | } |
| 2187 | break; |
| 2188 | } |
| 2189 | if (LocaleCompare("normalize",option+1) == 0) |
| 2190 | { |
| 2191 | (void) SyncImageSettings(mogrify_info,*image); |
| 2192 | (void) NormalizeImageChannel(*image,channel); |
| 2193 | InheritException(exception,&(*image)->exception); |
| 2194 | break; |
| 2195 | } |
| 2196 | break; |
| 2197 | } |
| 2198 | case 'o': |
| 2199 | { |
| 2200 | if (LocaleCompare("opaque",option+1) == 0) |
| 2201 | { |
| 2202 | MagickPixelPacket |
| 2203 | target; |
| 2204 | |
| 2205 | (void) SyncImageSettings(mogrify_info,*image); |
| 2206 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2207 | (void) OpaquePaintImageChannel(*image,channel,&target,&fill, |
| 2208 | *option == '-' ? MagickFalse : MagickTrue); |
| 2209 | break; |
| 2210 | } |
| 2211 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2212 | { |
| 2213 | (void) SyncImageSettings(mogrify_info,*image); |
| 2214 | (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1], |
| 2215 | exception); |
| 2216 | break; |
| 2217 | } |
| 2218 | break; |
| 2219 | } |
| 2220 | case 'p': |
| 2221 | { |
| 2222 | if (LocaleCompare("paint",option+1) == 0) |
| 2223 | { |
| 2224 | Image |
| 2225 | *paint_image; |
| 2226 | |
| 2227 | /* |
| 2228 | Oil paint image. |
| 2229 | */ |
| 2230 | (void) SyncImageSettings(mogrify_info,*image); |
| 2231 | (void) ParseGeometry(argv[i+1],&geometry_info); |
anthony | 3d2f486 | 2011-05-01 13:48:16 +0000 | [diff] [blame^] | 2232 | mogrify_image=OilPaintImage(*image,geometry_info.rho,exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2233 | break; |
| 2234 | } |
| 2235 | if (LocaleCompare("pen",option+1) == 0) |
| 2236 | { |
| 2237 | if (*option == '+') |
| 2238 | { |
| 2239 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2240 | break; |
| 2241 | } |
| 2242 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2243 | break; |
| 2244 | } |
| 2245 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2246 | { |
| 2247 | if (*option == '+') |
| 2248 | (void) ParseGeometry("12",&geometry_info); |
| 2249 | else |
| 2250 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2251 | draw_info->pointsize=geometry_info.rho; |
| 2252 | break; |
| 2253 | } |
| 2254 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2255 | { |
| 2256 | double |
| 2257 | angle; |
| 2258 | |
| 2259 | RandomInfo |
| 2260 | *random_info; |
| 2261 | |
| 2262 | /* |
| 2263 | Simulate a Polaroid picture. |
| 2264 | */ |
| 2265 | (void) SyncImageSettings(mogrify_info,*image); |
| 2266 | random_info=AcquireRandomInfo(); |
| 2267 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2268 | random_info=DestroyRandomInfo(random_info); |
| 2269 | if (*option == '-') |
| 2270 | { |
| 2271 | SetGeometryInfo(&geometry_info); |
| 2272 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2273 | angle=geometry_info.rho; |
| 2274 | } |
| 2275 | mogrify_image=PolaroidImage(*image,draw_info,angle,exception); |
| 2276 | break; |
| 2277 | } |
| 2278 | if (LocaleCompare("posterize",option+1) == 0) |
| 2279 | { |
| 2280 | /* |
| 2281 | Posterize image. |
| 2282 | */ |
| 2283 | (void) SyncImageSettings(mogrify_info,*image); |
| 2284 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
| 2285 | quantize_info->dither); |
| 2286 | InheritException(exception,&(*image)->exception); |
| 2287 | break; |
| 2288 | } |
| 2289 | if (LocaleCompare("preview",option+1) == 0) |
| 2290 | { |
| 2291 | PreviewType |
| 2292 | preview_type; |
| 2293 | |
| 2294 | /* |
| 2295 | Preview image. |
| 2296 | */ |
| 2297 | (void) SyncImageSettings(mogrify_info,*image); |
| 2298 | if (*option == '+') |
| 2299 | preview_type=UndefinedPreview; |
| 2300 | else |
| 2301 | preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions, |
| 2302 | MagickFalse,argv[i+1]); |
| 2303 | mogrify_image=PreviewImage(*image,preview_type,exception); |
| 2304 | break; |
| 2305 | } |
| 2306 | if (LocaleCompare("profile",option+1) == 0) |
| 2307 | { |
| 2308 | const char |
| 2309 | *name; |
| 2310 | |
| 2311 | const StringInfo |
| 2312 | *profile; |
| 2313 | |
| 2314 | Image |
| 2315 | *profile_image; |
| 2316 | |
| 2317 | ImageInfo |
| 2318 | *profile_info; |
| 2319 | |
| 2320 | (void) SyncImageSettings(mogrify_info,*image); |
| 2321 | if (*option == '+') |
| 2322 | { |
| 2323 | /* |
| 2324 | Remove a profile from the image. |
| 2325 | */ |
| 2326 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2327 | NULL,0,MagickTrue); |
| 2328 | InheritException(exception,&(*image)->exception); |
| 2329 | break; |
| 2330 | } |
| 2331 | /* |
| 2332 | Associate a profile with the image. |
| 2333 | */ |
| 2334 | profile_info=CloneImageInfo(mogrify_info); |
| 2335 | profile=GetImageProfile(*image,"iptc"); |
| 2336 | if (profile != (StringInfo *) NULL) |
| 2337 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2338 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2339 | profile_info=DestroyImageInfo(profile_info); |
| 2340 | if (profile_image == (Image *) NULL) |
| 2341 | { |
| 2342 | StringInfo |
| 2343 | *profile; |
| 2344 | |
| 2345 | profile_info=CloneImageInfo(mogrify_info); |
| 2346 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2347 | MaxTextExtent); |
| 2348 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
| 2349 | if (profile != (StringInfo *) NULL) |
| 2350 | { |
| 2351 | (void) ProfileImage(*image,profile_info->magick, |
| 2352 | GetStringInfoDatum(profile),(size_t) |
| 2353 | GetStringInfoLength(profile),MagickFalse); |
| 2354 | profile=DestroyStringInfo(profile); |
| 2355 | } |
| 2356 | profile_info=DestroyImageInfo(profile_info); |
| 2357 | break; |
| 2358 | } |
| 2359 | ResetImageProfileIterator(profile_image); |
| 2360 | name=GetNextImageProfile(profile_image); |
| 2361 | while (name != (const char *) NULL) |
| 2362 | { |
| 2363 | profile=GetImageProfile(profile_image,name); |
| 2364 | if (profile != (StringInfo *) NULL) |
| 2365 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
| 2366 | (size_t) GetStringInfoLength(profile),MagickFalse); |
| 2367 | name=GetNextImageProfile(profile_image); |
| 2368 | } |
| 2369 | profile_image=DestroyImage(profile_image); |
| 2370 | break; |
| 2371 | } |
| 2372 | break; |
| 2373 | } |
| 2374 | case 'q': |
| 2375 | { |
| 2376 | if (LocaleCompare("quantize",option+1) == 0) |
| 2377 | { |
| 2378 | if (*option == '+') |
| 2379 | { |
| 2380 | quantize_info->colorspace=UndefinedColorspace; |
| 2381 | break; |
| 2382 | } |
| 2383 | quantize_info->colorspace=(ColorspaceType) ParseCommandOption( |
| 2384 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2385 | break; |
| 2386 | } |
| 2387 | break; |
| 2388 | } |
| 2389 | case 'r': |
| 2390 | { |
| 2391 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2392 | { |
| 2393 | /* |
| 2394 | Radial blur image. |
| 2395 | */ |
| 2396 | (void) SyncImageSettings(mogrify_info,*image); |
| 2397 | mogrify_image=RadialBlurImageChannel(*image,channel, |
| 2398 | StringToDouble(argv[i+1]),exception); |
| 2399 | break; |
| 2400 | } |
| 2401 | if (LocaleCompare("raise",option+1) == 0) |
| 2402 | { |
| 2403 | /* |
| 2404 | Surround image with a raise of solid color. |
| 2405 | */ |
| 2406 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2407 | if ((flags & SigmaValue) == 0) |
| 2408 | geometry.height=geometry.width; |
| 2409 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
| 2410 | MagickFalse); |
| 2411 | InheritException(exception,&(*image)->exception); |
| 2412 | break; |
| 2413 | } |
| 2414 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2415 | { |
| 2416 | /* |
| 2417 | Threshold image. |
| 2418 | */ |
| 2419 | (void) SyncImageSettings(mogrify_info,*image); |
| 2420 | (void) RandomThresholdImageChannel(*image,channel,argv[i+1], |
| 2421 | exception); |
| 2422 | break; |
| 2423 | } |
| 2424 | if (LocaleCompare("recolor",option+1) == 0) |
| 2425 | { |
| 2426 | KernelInfo |
| 2427 | *kernel; |
| 2428 | |
| 2429 | (void) SyncImageSettings(mogrify_info,*image); |
| 2430 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2431 | if (kernel == (KernelInfo *) NULL) |
| 2432 | break; |
| 2433 | mogrify_image=ColorMatrixImage(*image,kernel,exception); |
| 2434 | kernel=DestroyKernelInfo(kernel); |
| 2435 | break; |
| 2436 | } |
| 2437 | if (LocaleCompare("region",option+1) == 0) |
| 2438 | { |
| 2439 | (void) SyncImageSettings(mogrify_info,*image); |
| 2440 | if (region_image != (Image *) NULL) |
| 2441 | { |
| 2442 | /* |
| 2443 | Composite region. |
| 2444 | */ |
| 2445 | (void) CompositeImage(region_image,region_image->matte != |
| 2446 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
| 2447 | region_geometry.x,region_geometry.y); |
| 2448 | InheritException(exception,®ion_image->exception); |
| 2449 | *image=DestroyImage(*image); |
| 2450 | *image=region_image; |
| 2451 | region_image = (Image *) NULL; |
| 2452 | } |
| 2453 | if (*option == '+') |
| 2454 | break; |
| 2455 | /* |
| 2456 | Apply transformations to a selected region of the image. |
| 2457 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2458 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2459 | exception); |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2460 | mogrify_image=CropImage(*image,®ion_geometry,exception); |
| 2461 | if (mogrify_image == (Image *) NULL) |
| 2462 | break; |
| 2463 | region_image=(*image); |
| 2464 | *image=mogrify_image; |
| 2465 | mogrify_image=(Image *) NULL; |
| 2466 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2467 | } |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2468 | if (LocaleCompare("render",option+1) == 0) |
| 2469 | { |
| 2470 | (void) SyncImageSettings(mogrify_info,*image); |
| 2471 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2472 | break; |
| 2473 | } |
| 2474 | if (LocaleCompare("remap",option+1) == 0) |
| 2475 | { |
| 2476 | Image |
| 2477 | *remap_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2478 | |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 2479 | /* |
| 2480 | Transform image colors to match this set of colors. |
| 2481 | */ |
| 2482 | (void) SyncImageSettings(mogrify_info,*image); |
| 2483 | if (*option == '+') |
| 2484 | break; |
| 2485 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
| 2486 | if (remap_image == (Image *) NULL) |
| 2487 | break; |
| 2488 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2489 | InheritException(exception,&(*image)->exception); |
| 2490 | remap_image=DestroyImage(remap_image); |
| 2491 | break; |
| 2492 | } |
| 2493 | if (LocaleCompare("repage",option+1) == 0) |
| 2494 | { |
| 2495 | if (*option == '+') |
| 2496 | { |
| 2497 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2498 | break; |
| 2499 | } |
| 2500 | (void) ResetImagePage(*image,argv[i+1]); |
| 2501 | InheritException(exception,&(*image)->exception); |
| 2502 | break; |
| 2503 | } |
| 2504 | if (LocaleCompare("resample",option+1) == 0) |
| 2505 | { |
| 2506 | /* |
| 2507 | Resample image. |
| 2508 | */ |
| 2509 | (void) SyncImageSettings(mogrify_info,*image); |
| 2510 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2511 | if ((flags & SigmaValue) == 0) |
| 2512 | geometry_info.sigma=geometry_info.rho; |
| 2513 | mogrify_image=ResampleImage(*image,geometry_info.rho, |
| 2514 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2515 | break; |
| 2516 | } |
| 2517 | if (LocaleCompare("resize",option+1) == 0) |
| 2518 | { |
| 2519 | /* |
| 2520 | Resize image. |
| 2521 | */ |
| 2522 | (void) SyncImageSettings(mogrify_info,*image); |
| 2523 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2524 | mogrify_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2525 | (*image)->filter,(*image)->blur,exception); |
| 2526 | break; |
| 2527 | } |
| 2528 | if (LocaleCompare("roll",option+1) == 0) |
| 2529 | { |
| 2530 | /* |
| 2531 | Roll image. |
| 2532 | */ |
| 2533 | (void) SyncImageSettings(mogrify_info,*image); |
| 2534 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2535 | mogrify_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2536 | break; |
| 2537 | } |
| 2538 | if (LocaleCompare("rotate",option+1) == 0) |
| 2539 | { |
| 2540 | char |
| 2541 | *geometry; |
| 2542 | |
| 2543 | /* |
| 2544 | Check for conditional image rotation. |
| 2545 | */ |
| 2546 | (void) SyncImageSettings(mogrify_info,*image); |
| 2547 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2548 | if ((*image)->columns <= (*image)->rows) |
| 2549 | break; |
| 2550 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2551 | if ((*image)->columns >= (*image)->rows) |
| 2552 | break; |
| 2553 | /* |
| 2554 | Rotate image. |
| 2555 | */ |
| 2556 | geometry=ConstantString(argv[i+1]); |
| 2557 | (void) SubstituteString(&geometry,">",""); |
| 2558 | (void) SubstituteString(&geometry,"<",""); |
| 2559 | (void) ParseGeometry(geometry,&geometry_info); |
| 2560 | geometry=DestroyString(geometry); |
| 2561 | mogrify_image=RotateImage(*image,geometry_info.rho,exception); |
| 2562 | break; |
| 2563 | } |
| 2564 | break; |
| 2565 | } |
| 2566 | case 's': |
| 2567 | { |
| 2568 | if (LocaleCompare("sample",option+1) == 0) |
| 2569 | { |
| 2570 | /* |
| 2571 | Sample image with pixel replication. |
| 2572 | */ |
| 2573 | (void) SyncImageSettings(mogrify_info,*image); |
| 2574 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2575 | mogrify_image=SampleImage(*image,geometry.width,geometry.height, |
| 2576 | exception); |
| 2577 | break; |
| 2578 | } |
| 2579 | if (LocaleCompare("scale",option+1) == 0) |
| 2580 | { |
| 2581 | /* |
| 2582 | Resize image. |
| 2583 | */ |
| 2584 | (void) SyncImageSettings(mogrify_info,*image); |
| 2585 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2586 | mogrify_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2587 | exception); |
| 2588 | break; |
| 2589 | } |
| 2590 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2591 | { |
| 2592 | /* |
| 2593 | Selectively blur pixels within a contrast threshold. |
| 2594 | */ |
| 2595 | (void) SyncImageSettings(mogrify_info,*image); |
| 2596 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2597 | if ((flags & PercentValue) != 0) |
| 2598 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 2599 | mogrify_image=SelectiveBlurImageChannel(*image,channel, |
| 2600 | geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception); |
| 2601 | break; |
| 2602 | } |
| 2603 | if (LocaleCompare("separate",option+1) == 0) |
| 2604 | { |
| 2605 | /* |
| 2606 | Break channels into separate images. |
| 2607 | WARNING: This can generate multiple images! |
| 2608 | */ |
| 2609 | (void) SyncImageSettings(mogrify_info,*image); |
| 2610 | mogrify_image=SeparateImages(*image,channel,exception); |
| 2611 | break; |
| 2612 | } |
| 2613 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2614 | { |
| 2615 | double |
| 2616 | threshold; |
| 2617 | |
| 2618 | /* |
| 2619 | Sepia-tone image. |
| 2620 | */ |
| 2621 | (void) SyncImageSettings(mogrify_info,*image); |
| 2622 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2623 | mogrify_image=SepiaToneImage(*image,threshold,exception); |
| 2624 | break; |
| 2625 | } |
| 2626 | if (LocaleCompare("segment",option+1) == 0) |
| 2627 | { |
| 2628 | /* |
| 2629 | Segment image. |
| 2630 | */ |
| 2631 | (void) SyncImageSettings(mogrify_info,*image); |
| 2632 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2633 | if ((flags & SigmaValue) == 0) |
| 2634 | geometry_info.sigma=1.0; |
| 2635 | (void) SegmentImage(*image,(*image)->colorspace, |
| 2636 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma); |
| 2637 | InheritException(exception,&(*image)->exception); |
| 2638 | break; |
| 2639 | } |
| 2640 | if (LocaleCompare("set",option+1) == 0) |
| 2641 | { |
| 2642 | char |
| 2643 | *value; |
| 2644 | |
| 2645 | /* |
| 2646 | Set image option. |
| 2647 | */ |
| 2648 | if (*option == '+') |
| 2649 | { |
| 2650 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2651 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2652 | else |
| 2653 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2654 | { |
| 2655 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
| 2656 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2657 | } |
| 2658 | else |
| 2659 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2660 | break; |
| 2661 | } |
| 2662 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2663 | if (value == (char *) NULL) |
| 2664 | break; |
| 2665 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2666 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2667 | exception); |
| 2668 | else |
| 2669 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
| 2670 | { |
| 2671 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2672 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
| 2673 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2674 | } |
| 2675 | else |
| 2676 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2677 | value=DestroyString(value); |
| 2678 | break; |
| 2679 | } |
| 2680 | if (LocaleCompare("shade",option+1) == 0) |
| 2681 | { |
| 2682 | /* |
| 2683 | Shade image. |
| 2684 | */ |
| 2685 | (void) SyncImageSettings(mogrify_info,*image); |
| 2686 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2687 | if ((flags & SigmaValue) == 0) |
| 2688 | geometry_info.sigma=1.0; |
| 2689 | mogrify_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2690 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2691 | break; |
| 2692 | } |
| 2693 | if (LocaleCompare("shadow",option+1) == 0) |
| 2694 | { |
| 2695 | /* |
| 2696 | Shadow 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=1.0; |
| 2702 | if ((flags & XiValue) == 0) |
| 2703 | geometry_info.xi=4.0; |
| 2704 | if ((flags & PsiValue) == 0) |
| 2705 | geometry_info.psi=4.0; |
| 2706 | mogrify_image=ShadowImage(*image,geometry_info.rho, |
| 2707 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 2708 | ceil(geometry_info.psi-0.5),exception); |
| 2709 | break; |
| 2710 | } |
| 2711 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2712 | { |
| 2713 | /* |
| 2714 | Sharpen image. |
| 2715 | */ |
| 2716 | (void) SyncImageSettings(mogrify_info,*image); |
| 2717 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2718 | if ((flags & SigmaValue) == 0) |
| 2719 | geometry_info.sigma=1.0; |
| 2720 | mogrify_image=SharpenImageChannel(*image,channel,geometry_info.rho, |
| 2721 | geometry_info.sigma,exception); |
| 2722 | break; |
| 2723 | } |
| 2724 | if (LocaleCompare("shave",option+1) == 0) |
| 2725 | { |
| 2726 | /* |
| 2727 | Shave the image edges. |
| 2728 | */ |
| 2729 | (void) SyncImageSettings(mogrify_info,*image); |
| 2730 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2731 | mogrify_image=ShaveImage(*image,&geometry,exception); |
| 2732 | break; |
| 2733 | } |
| 2734 | if (LocaleCompare("shear",option+1) == 0) |
| 2735 | { |
| 2736 | /* |
| 2737 | Shear image. |
| 2738 | */ |
| 2739 | (void) SyncImageSettings(mogrify_info,*image); |
| 2740 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2741 | if ((flags & SigmaValue) == 0) |
| 2742 | geometry_info.sigma=geometry_info.rho; |
| 2743 | mogrify_image=ShearImage(*image,geometry_info.rho, |
| 2744 | geometry_info.sigma,exception); |
| 2745 | break; |
| 2746 | } |
| 2747 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 2748 | { |
| 2749 | /* |
| 2750 | Sigmoidal non-linearity contrast control. |
| 2751 | */ |
| 2752 | (void) SyncImageSettings(mogrify_info,*image); |
| 2753 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2754 | if ((flags & SigmaValue) == 0) |
| 2755 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 2756 | if ((flags & PercentValue) != 0) |
| 2757 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 2758 | 100.0; |
| 2759 | (void) SigmoidalContrastImageChannel(*image,channel, |
| 2760 | (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho, |
| 2761 | geometry_info.sigma); |
| 2762 | InheritException(exception,&(*image)->exception); |
| 2763 | break; |
| 2764 | } |
| 2765 | if (LocaleCompare("sketch",option+1) == 0) |
| 2766 | { |
| 2767 | /* |
| 2768 | Sketch image. |
| 2769 | */ |
| 2770 | (void) SyncImageSettings(mogrify_info,*image); |
| 2771 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2772 | if ((flags & SigmaValue) == 0) |
| 2773 | geometry_info.sigma=1.0; |
| 2774 | mogrify_image=SketchImage(*image,geometry_info.rho, |
| 2775 | geometry_info.sigma,geometry_info.xi,exception); |
| 2776 | break; |
| 2777 | } |
| 2778 | if (LocaleCompare("solarize",option+1) == 0) |
| 2779 | { |
| 2780 | double |
| 2781 | threshold; |
| 2782 | |
| 2783 | (void) SyncImageSettings(mogrify_info,*image); |
| 2784 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2785 | (void) SolarizeImage(*image,threshold); |
| 2786 | InheritException(exception,&(*image)->exception); |
| 2787 | break; |
| 2788 | } |
| 2789 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 2790 | { |
| 2791 | SparseColorMethod |
| 2792 | method; |
| 2793 | |
| 2794 | char |
| 2795 | *arguments; |
| 2796 | |
| 2797 | /* |
| 2798 | Sparse Color Interpolated Gradient |
| 2799 | */ |
| 2800 | (void) SyncImageSettings(mogrify_info,*image); |
| 2801 | method=(SparseColorMethod) ParseCommandOption( |
| 2802 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
| 2803 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
| 2804 | InheritException(exception,&(*image)->exception); |
| 2805 | if (arguments == (char *) NULL) |
| 2806 | break; |
| 2807 | mogrify_image=SparseColorOption(*image,channel,method,arguments, |
| 2808 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 2809 | arguments=DestroyString(arguments); |
| 2810 | break; |
| 2811 | } |
| 2812 | if (LocaleCompare("splice",option+1) == 0) |
| 2813 | { |
| 2814 | /* |
| 2815 | Splice a solid color into the image. |
| 2816 | */ |
| 2817 | (void) SyncImageSettings(mogrify_info,*image); |
| 2818 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 2819 | mogrify_image=SpliceImage(*image,&geometry,exception); |
| 2820 | break; |
| 2821 | } |
| 2822 | if (LocaleCompare("spread",option+1) == 0) |
| 2823 | { |
| 2824 | /* |
| 2825 | Spread an image. |
| 2826 | */ |
| 2827 | (void) SyncImageSettings(mogrify_info,*image); |
| 2828 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2829 | mogrify_image=SpreadImage(*image,geometry_info.rho,exception); |
| 2830 | break; |
| 2831 | } |
| 2832 | if (LocaleCompare("statistic",option+1) == 0) |
| 2833 | { |
| 2834 | StatisticType |
| 2835 | type; |
| 2836 | |
| 2837 | (void) SyncImageSettings(mogrify_info,*image); |
| 2838 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 2839 | MagickFalse,argv[i+1]); |
| 2840 | (void) ParseGeometry(argv[i+2],&geometry_info); |
| 2841 | mogrify_image=StatisticImageChannel(*image,channel,type,(size_t) |
| 2842 | geometry_info.rho,(size_t) geometry_info.sigma,exception); |
| 2843 | break; |
| 2844 | } |
| 2845 | if (LocaleCompare("stretch",option+1) == 0) |
| 2846 | { |
| 2847 | if (*option == '+') |
| 2848 | { |
| 2849 | draw_info->stretch=UndefinedStretch; |
| 2850 | break; |
| 2851 | } |
| 2852 | draw_info->stretch=(StretchType) ParseCommandOption( |
| 2853 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 2854 | break; |
| 2855 | } |
| 2856 | if (LocaleCompare("strip",option+1) == 0) |
| 2857 | { |
| 2858 | /* |
| 2859 | Strip image of profiles and comments. |
| 2860 | */ |
| 2861 | (void) SyncImageSettings(mogrify_info,*image); |
| 2862 | (void) StripImage(*image); |
| 2863 | InheritException(exception,&(*image)->exception); |
| 2864 | break; |
| 2865 | } |
| 2866 | if (LocaleCompare("stroke",option+1) == 0) |
| 2867 | { |
| 2868 | ExceptionInfo |
| 2869 | *sans; |
| 2870 | |
| 2871 | if (*option == '+') |
| 2872 | { |
| 2873 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 2874 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 2875 | draw_info->stroke_pattern=DestroyImage( |
| 2876 | draw_info->stroke_pattern); |
| 2877 | break; |
| 2878 | } |
| 2879 | sans=AcquireExceptionInfo(); |
| 2880 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 2881 | sans=DestroyExceptionInfo(sans); |
| 2882 | if (status == MagickFalse) |
| 2883 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2884 | exception); |
| 2885 | break; |
| 2886 | } |
| 2887 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 2888 | { |
| 2889 | draw_info->stroke_width=StringToDouble(argv[i+1]); |
| 2890 | break; |
| 2891 | } |
| 2892 | if (LocaleCompare("style",option+1) == 0) |
| 2893 | { |
| 2894 | if (*option == '+') |
| 2895 | { |
| 2896 | draw_info->style=UndefinedStyle; |
| 2897 | break; |
| 2898 | } |
| 2899 | draw_info->style=(StyleType) ParseCommandOption(MagickStyleOptions, |
| 2900 | MagickFalse,argv[i+1]); |
| 2901 | break; |
| 2902 | } |
| 2903 | if (LocaleCompare("swirl",option+1) == 0) |
| 2904 | { |
| 2905 | /* |
| 2906 | Swirl image. |
| 2907 | */ |
| 2908 | (void) SyncImageSettings(mogrify_info,*image); |
| 2909 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2910 | mogrify_image=SwirlImage(*image,geometry_info.rho,exception); |
| 2911 | break; |
| 2912 | } |
| 2913 | break; |
| 2914 | } |
| 2915 | case 't': |
| 2916 | { |
| 2917 | if (LocaleCompare("threshold",option+1) == 0) |
| 2918 | { |
| 2919 | double |
| 2920 | threshold; |
| 2921 | |
| 2922 | /* |
| 2923 | Threshold image. |
| 2924 | */ |
| 2925 | (void) SyncImageSettings(mogrify_info,*image); |
| 2926 | if (*option == '+') |
| 2927 | threshold=(double) QuantumRange/2.5; |
| 2928 | else |
| 2929 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
| 2930 | (void) BilevelImageChannel(*image,channel,threshold); |
| 2931 | InheritException(exception,&(*image)->exception); |
| 2932 | break; |
| 2933 | } |
| 2934 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 2935 | { |
| 2936 | /* |
| 2937 | Thumbnail image. |
| 2938 | */ |
| 2939 | (void) SyncImageSettings(mogrify_info,*image); |
| 2940 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2941 | mogrify_image=ThumbnailImage(*image,geometry.width,geometry.height, |
| 2942 | exception); |
| 2943 | break; |
| 2944 | } |
| 2945 | if (LocaleCompare("tile",option+1) == 0) |
| 2946 | { |
| 2947 | if (*option == '+') |
| 2948 | { |
| 2949 | if (draw_info->fill_pattern != (Image *) NULL) |
| 2950 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 2951 | break; |
| 2952 | } |
| 2953 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
| 2954 | exception); |
| 2955 | break; |
| 2956 | } |
| 2957 | if (LocaleCompare("tint",option+1) == 0) |
| 2958 | { |
| 2959 | /* |
| 2960 | Tint the image. |
| 2961 | */ |
| 2962 | (void) SyncImageSettings(mogrify_info,*image); |
| 2963 | mogrify_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 2964 | break; |
| 2965 | } |
| 2966 | if (LocaleCompare("transform",option+1) == 0) |
| 2967 | { |
| 2968 | /* |
| 2969 | Affine transform image. |
| 2970 | */ |
| 2971 | (void) SyncImageSettings(mogrify_info,*image); |
| 2972 | mogrify_image=AffineTransformImage(*image,&draw_info->affine, |
| 2973 | exception); |
| 2974 | break; |
| 2975 | } |
| 2976 | if (LocaleCompare("transparent",option+1) == 0) |
| 2977 | { |
| 2978 | MagickPixelPacket |
| 2979 | target; |
| 2980 | |
| 2981 | (void) SyncImageSettings(mogrify_info,*image); |
| 2982 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2983 | (void) TransparentPaintImage(*image,&target,(Quantum) |
| 2984 | TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue); |
| 2985 | InheritException(exception,&(*image)->exception); |
| 2986 | break; |
| 2987 | } |
| 2988 | if (LocaleCompare("transpose",option+1) == 0) |
| 2989 | { |
| 2990 | /* |
| 2991 | Transpose image scanlines. |
| 2992 | */ |
| 2993 | (void) SyncImageSettings(mogrify_info,*image); |
| 2994 | mogrify_image=TransposeImage(*image,exception); |
| 2995 | break; |
| 2996 | } |
| 2997 | if (LocaleCompare("transverse",option+1) == 0) |
| 2998 | { |
| 2999 | /* |
| 3000 | Transverse image scanlines. |
| 3001 | */ |
| 3002 | (void) SyncImageSettings(mogrify_info,*image); |
| 3003 | mogrify_image=TransverseImage(*image,exception); |
| 3004 | break; |
| 3005 | } |
| 3006 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3007 | { |
| 3008 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
| 3009 | break; |
| 3010 | } |
| 3011 | if (LocaleCompare("trim",option+1) == 0) |
| 3012 | { |
| 3013 | /* |
| 3014 | Trim image. |
| 3015 | */ |
| 3016 | (void) SyncImageSettings(mogrify_info,*image); |
| 3017 | mogrify_image=TrimImage(*image,exception); |
| 3018 | break; |
| 3019 | } |
| 3020 | if (LocaleCompare("type",option+1) == 0) |
| 3021 | { |
| 3022 | ImageType |
| 3023 | type; |
| 3024 | |
| 3025 | (void) SyncImageSettings(mogrify_info,*image); |
| 3026 | if (*option == '+') |
| 3027 | type=UndefinedType; |
| 3028 | else |
| 3029 | type=(ImageType) ParseCommandOption(MagickTypeOptions,MagickFalse, |
| 3030 | argv[i+1]); |
| 3031 | (*image)->type=UndefinedType; |
| 3032 | (void) SetImageType(*image,type); |
| 3033 | InheritException(exception,&(*image)->exception); |
| 3034 | break; |
| 3035 | } |
| 3036 | break; |
| 3037 | } |
| 3038 | case 'u': |
| 3039 | { |
| 3040 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3041 | { |
| 3042 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3043 | exception); |
| 3044 | break; |
| 3045 | } |
| 3046 | if (LocaleCompare("unique",option+1) == 0) |
| 3047 | { |
| 3048 | if (*option == '+') |
| 3049 | { |
| 3050 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
| 3051 | break; |
| 3052 | } |
| 3053 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
| 3054 | (void) SetImageArtifact(*image,"verbose","true"); |
| 3055 | break; |
| 3056 | } |
| 3057 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3058 | { |
| 3059 | /* |
| 3060 | Unique image colors. |
| 3061 | */ |
| 3062 | (void) SyncImageSettings(mogrify_info,*image); |
| 3063 | mogrify_image=UniqueImageColors(*image,exception); |
| 3064 | break; |
| 3065 | } |
| 3066 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3067 | { |
| 3068 | /* |
| 3069 | Unsharp mask image. |
| 3070 | */ |
| 3071 | (void) SyncImageSettings(mogrify_info,*image); |
| 3072 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3073 | if ((flags & SigmaValue) == 0) |
| 3074 | geometry_info.sigma=1.0; |
| 3075 | if ((flags & XiValue) == 0) |
| 3076 | geometry_info.xi=1.0; |
| 3077 | if ((flags & PsiValue) == 0) |
| 3078 | geometry_info.psi=0.05; |
| 3079 | mogrify_image=UnsharpMaskImageChannel(*image,channel, |
| 3080 | geometry_info.rho,geometry_info.sigma,geometry_info.xi, |
| 3081 | geometry_info.psi,exception); |
| 3082 | break; |
| 3083 | } |
| 3084 | break; |
| 3085 | } |
| 3086 | case 'v': |
| 3087 | { |
| 3088 | if (LocaleCompare("verbose",option+1) == 0) |
| 3089 | { |
| 3090 | (void) SetImageArtifact(*image,option+1, |
| 3091 | *option == '+' ? "false" : "true"); |
| 3092 | break; |
| 3093 | } |
| 3094 | if (LocaleCompare("vignette",option+1) == 0) |
| 3095 | { |
| 3096 | /* |
| 3097 | Vignette image. |
| 3098 | */ |
| 3099 | (void) SyncImageSettings(mogrify_info,*image); |
| 3100 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3101 | if ((flags & SigmaValue) == 0) |
| 3102 | geometry_info.sigma=1.0; |
| 3103 | if ((flags & XiValue) == 0) |
| 3104 | geometry_info.xi=0.1*(*image)->columns; |
| 3105 | if ((flags & PsiValue) == 0) |
| 3106 | geometry_info.psi=0.1*(*image)->rows; |
| 3107 | mogrify_image=VignetteImage(*image,geometry_info.rho, |
| 3108 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
| 3109 | ceil(geometry_info.psi-0.5),exception); |
| 3110 | break; |
| 3111 | } |
| 3112 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3113 | { |
| 3114 | if (*option == '+') |
| 3115 | { |
| 3116 | (void) SetImageVirtualPixelMethod(*image, |
| 3117 | UndefinedVirtualPixelMethod); |
| 3118 | break; |
| 3119 | } |
| 3120 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3121 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
| 3122 | argv[i+1])); |
| 3123 | break; |
| 3124 | } |
| 3125 | break; |
| 3126 | } |
| 3127 | case 'w': |
| 3128 | { |
| 3129 | if (LocaleCompare("wave",option+1) == 0) |
| 3130 | { |
| 3131 | /* |
| 3132 | Wave image. |
| 3133 | */ |
| 3134 | (void) SyncImageSettings(mogrify_info,*image); |
| 3135 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3136 | if ((flags & SigmaValue) == 0) |
| 3137 | geometry_info.sigma=1.0; |
| 3138 | mogrify_image=WaveImage(*image,geometry_info.rho, |
| 3139 | geometry_info.sigma,exception); |
| 3140 | break; |
| 3141 | } |
| 3142 | if (LocaleCompare("weight",option+1) == 0) |
| 3143 | { |
| 3144 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
| 3145 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3146 | draw_info->weight=0; |
| 3147 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3148 | draw_info->weight=700; |
| 3149 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3150 | if (draw_info->weight <= 800) |
| 3151 | draw_info->weight+=100; |
| 3152 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3153 | if (draw_info->weight >= 100) |
| 3154 | draw_info->weight-=100; |
| 3155 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3156 | draw_info->weight=400; |
| 3157 | break; |
| 3158 | } |
| 3159 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3160 | { |
| 3161 | /* |
| 3162 | White threshold image. |
| 3163 | */ |
| 3164 | (void) SyncImageSettings(mogrify_info,*image); |
| 3165 | (void) WhiteThresholdImageChannel(*image,channel,argv[i+1], |
| 3166 | exception); |
| 3167 | InheritException(exception,&(*image)->exception); |
| 3168 | break; |
| 3169 | } |
| 3170 | break; |
| 3171 | } |
| 3172 | default: |
| 3173 | break; |
| 3174 | } |
| 3175 | /* |
| 3176 | Replace current image with any image that was generated |
| 3177 | */ |
| 3178 | if (mogrify_image != (Image *) NULL) |
| 3179 | ReplaceImageInListReturnLast(image,mogrify_image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3180 | i+=count; |
| 3181 | } |
| 3182 | if (region_image != (Image *) NULL) |
| 3183 | { |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3184 | /* |
| 3185 | Composite transformed region onto image. |
| 3186 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3187 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 3188 | (void) CompositeImage(region_image,region_image->matte != |
| 3189 | MagickFalse ? CopyCompositeOp : OverCompositeOp,*image, |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3190 | region_geometry.x,region_geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3191 | InheritException(exception,®ion_image->exception); |
| 3192 | *image=DestroyImage(*image); |
| 3193 | *image=region_image; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 3194 | region_image = (Image *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3195 | } |
| 3196 | /* |
| 3197 | Free resources. |
| 3198 | */ |
anthony | df8ebac | 2011-04-27 09:03:19 +0000 | [diff] [blame] | 3199 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3200 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3201 | mogrify_info=DestroyImageInfo(mogrify_info); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 3202 | status=(*image)->exception.severity == UndefinedException ? 1 : 0; |
| 3203 | return(status == 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3204 | } |
| 3205 | |
| 3206 | /* |
| 3207 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3208 | % % |
| 3209 | % % |
| 3210 | % % |
cristy | 5063d81 | 2010-10-19 16:28:10 +0000 | [diff] [blame] | 3211 | + 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] | 3212 | % % |
| 3213 | % % |
| 3214 | % % |
| 3215 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3216 | % |
| 3217 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3218 | % transforms include image scaling, image rotation, color reduction, and |
| 3219 | % others. The transmogrified image overwrites the original image. |
| 3220 | % |
| 3221 | % The format of the MogrifyImageCommand method is: |
| 3222 | % |
| 3223 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3224 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3225 | % |
| 3226 | % A description of each parameter follows: |
| 3227 | % |
| 3228 | % o image_info: the image info. |
| 3229 | % |
| 3230 | % o argc: the number of elements in the argument vector. |
| 3231 | % |
| 3232 | % o argv: A text array containing the command line arguments. |
| 3233 | % |
| 3234 | % o metadata: any metadata is returned here. |
| 3235 | % |
| 3236 | % o exception: return any errors or warnings in this structure. |
| 3237 | % |
| 3238 | */ |
| 3239 | |
| 3240 | static MagickBooleanType MogrifyUsage(void) |
| 3241 | { |
| 3242 | static const char |
| 3243 | *miscellaneous[]= |
| 3244 | { |
| 3245 | "-debug events display copious debugging information", |
| 3246 | "-help print program options", |
| 3247 | "-list type print a list of supported option arguments", |
| 3248 | "-log format format of debugging information", |
| 3249 | "-version print version information", |
| 3250 | (char *) NULL |
| 3251 | }, |
| 3252 | *operators[]= |
| 3253 | { |
| 3254 | "-adaptive-blur geometry", |
| 3255 | " adaptively blur pixels; decrease effect near edges", |
| 3256 | "-adaptive-resize geometry", |
| 3257 | " adaptively resize image using 'mesh' interpolation", |
| 3258 | "-adaptive-sharpen geometry", |
| 3259 | " adaptively sharpen pixels; increase effect near edges", |
| 3260 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3261 | " transparent, extract, background, or shape", |
| 3262 | "-annotate geometry text", |
| 3263 | " annotate the image with text", |
| 3264 | "-auto-gamma automagically adjust gamma level of image", |
| 3265 | "-auto-level automagically adjust color levels of image", |
| 3266 | "-auto-orient automagically orient (rotate) image", |
| 3267 | "-bench iterations measure performance", |
| 3268 | "-black-threshold value", |
| 3269 | " force all pixels below the threshold into black", |
| 3270 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3271 | "-blur geometry reduce image noise and reduce detail levels", |
| 3272 | "-border geometry surround image with a border of color", |
| 3273 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3274 | "-brightness-contrast geometry", |
| 3275 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3276 | "-cdl filename color correct with a color decision list", |
| 3277 | "-charcoal radius simulate a charcoal drawing", |
| 3278 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3279 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3280 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3281 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3282 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3283 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3284 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3285 | "-contrast enhance or reduce the image contrast", |
| 3286 | "-contrast-stretch geometry", |
| 3287 | " improve contrast by `stretching' the intensity range", |
| 3288 | "-convolve coefficients", |
| 3289 | " apply a convolution kernel to the image", |
| 3290 | "-cycle amount cycle the image colormap", |
| 3291 | "-decipher filename convert cipher pixels to plain pixels", |
| 3292 | "-deskew threshold straighten an image", |
| 3293 | "-despeckle reduce the speckles within an image", |
| 3294 | "-distort method args", |
| 3295 | " distort images according to given method ad args", |
| 3296 | "-draw string annotate the image with a graphic primitive", |
| 3297 | "-edge radius apply a filter to detect edges in the image", |
| 3298 | "-encipher filename convert plain pixels to cipher pixels", |
| 3299 | "-emboss radius emboss an image", |
| 3300 | "-enhance apply a digital filter to enhance a noisy image", |
| 3301 | "-equalize perform histogram equalization to an image", |
| 3302 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3303 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3304 | "-extent geometry set the image size", |
| 3305 | "-extract geometry extract area from image", |
| 3306 | "-fft implements the discrete Fourier transform (DFT)", |
| 3307 | "-flip flip image vertically", |
| 3308 | "-floodfill geometry color", |
| 3309 | " floodfill the image with color", |
| 3310 | "-flop flop image horizontally", |
| 3311 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3312 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3313 | " apply function over image values", |
| 3314 | "-gamma value level of gamma correction", |
| 3315 | "-gaussian-blur geometry", |
| 3316 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3317 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3318 | "-identify identify the format and characteristics of the image", |
| 3319 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3320 | "-implode amount implode image pixels about the center", |
| 3321 | "-lat geometry local adaptive thresholding", |
| 3322 | "-layers method optimize, merge, or compare image layers", |
| 3323 | "-level value adjust the level of image contrast", |
| 3324 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3325 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3326 | "-linear-stretch geometry", |
| 3327 | " improve contrast by `stretching with saturation'", |
| 3328 | "-liquid-rescale geometry", |
| 3329 | " rescale image with seam-carving", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3330 | "-median geometry apply a median filter to the image", |
| 3331 | "-mode geometry make each pixel the 'predominate color' of the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3332 | "-modulate value vary the brightness, saturation, and hue", |
| 3333 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3334 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3335 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3336 | "-motion-blur geometry", |
| 3337 | " simulate motion blur", |
| 3338 | "-negate replace every pixel with its complementary color ", |
cristy | 3c74150 | 2011-04-01 23:21:16 +0000 | [diff] [blame] | 3339 | "-noise geometry add or reduce noise in an image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3340 | "-normalize transform image to span the full range of colors", |
| 3341 | "-opaque color change this color to the fill color", |
| 3342 | "-ordered-dither NxN", |
| 3343 | " add a noise pattern to the image with specific", |
| 3344 | " amplitudes", |
| 3345 | "-paint radius simulate an oil painting", |
| 3346 | "-polaroid angle simulate a Polaroid picture", |
| 3347 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3348 | "-profile filename add, delete, or apply an image profile", |
| 3349 | "-quantize colorspace reduce colors in this colorspace", |
| 3350 | "-radial-blur angle radial blur the image", |
| 3351 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3352 | "-random-threshold low,high", |
| 3353 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3354 | "-region geometry apply options to a portion of the image", |
| 3355 | "-render render vector graphics", |
| 3356 | "-repage geometry size and location of an image canvas", |
| 3357 | "-resample geometry change the resolution of an image", |
| 3358 | "-resize geometry resize the image", |
| 3359 | "-roll geometry roll an image vertically or horizontally", |
| 3360 | "-rotate degrees apply Paeth rotation to the image", |
| 3361 | "-sample geometry scale image with pixel sampling", |
| 3362 | "-scale geometry scale the image", |
| 3363 | "-segment values segment an image", |
| 3364 | "-selective-blur geometry", |
| 3365 | " selectively blur pixels within a contrast threshold", |
| 3366 | "-sepia-tone threshold", |
| 3367 | " simulate a sepia-toned photo", |
| 3368 | "-set property value set an image property", |
| 3369 | "-shade degrees shade the image using a distant light source", |
| 3370 | "-shadow geometry simulate an image shadow", |
| 3371 | "-sharpen geometry sharpen the image", |
| 3372 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3373 | "-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] | 3374 | "-sigmoidal-contrast geometry", |
| 3375 | " increase the contrast without saturating highlights or shadows", |
| 3376 | "-sketch geometry simulate a pencil sketch", |
| 3377 | "-solarize threshold negate all pixels above the threshold level", |
| 3378 | "-sparse-color method args", |
| 3379 | " fill in a image based on a few color points", |
| 3380 | "-splice geometry splice the background color into the image", |
| 3381 | "-spread radius displace image pixels by a random amount", |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 3382 | "-statistic type radius", |
| 3383 | " replace each pixel with corresponding statistic from the neighborhood", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3384 | "-strip strip image of all profiles and comments", |
| 3385 | "-swirl degrees swirl image pixels about the center", |
| 3386 | "-threshold value threshold the image", |
| 3387 | "-thumbnail geometry create a thumbnail of the image", |
| 3388 | "-tile filename tile image when filling a graphic primitive", |
| 3389 | "-tint value tint the image with the fill color", |
| 3390 | "-transform affine transform image", |
| 3391 | "-transparent color make this color transparent within the image", |
| 3392 | "-transpose flip image vertically and rotate 90 degrees", |
| 3393 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3394 | "-trim trim image edges", |
| 3395 | "-type type image type", |
| 3396 | "-unique-colors discard all but one of any pixel color", |
| 3397 | "-unsharp geometry sharpen the image", |
| 3398 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3399 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3400 | "-white-threshold value", |
| 3401 | " force all pixels above the threshold into white", |
| 3402 | (char *) NULL |
| 3403 | }, |
| 3404 | *sequence_operators[]= |
| 3405 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3406 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3407 | "-clut apply a color lookup table to the image", |
| 3408 | "-coalesce merge a sequence of images", |
| 3409 | "-combine combine a sequence of images", |
| 3410 | "-composite composite image", |
| 3411 | "-crop geometry cut out a rectangular region of the image", |
| 3412 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3413 | "-evaluate-sequence operator", |
| 3414 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3415 | "-flatten flatten a sequence of images", |
| 3416 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3417 | "-hald-clut apply a Hald color lookup table to the image", |
| 3418 | "-morph value morph an image sequence", |
| 3419 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3420 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3421 | "-process arguments process the image with a custom image filter", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3422 | "-separate separate an image channel into a grayscale image", |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 3423 | "-smush geometry smush an image sequence together", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3424 | "-write filename write images to this file", |
| 3425 | (char *) NULL |
| 3426 | }, |
| 3427 | *settings[]= |
| 3428 | { |
| 3429 | "-adjoin join images into a single multi-image file", |
| 3430 | "-affine matrix affine transform matrix", |
| 3431 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3432 | "-antialias remove pixel-aliasing", |
| 3433 | "-authenticate password", |
| 3434 | " decipher image with this password", |
| 3435 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3436 | "-background color background color", |
| 3437 | "-bias value add bias when convolving an image", |
| 3438 | "-black-point-compensation", |
| 3439 | " use black point compensation", |
| 3440 | "-blue-primary point chromaticity blue primary point", |
| 3441 | "-bordercolor color border color", |
| 3442 | "-caption string assign a caption to an image", |
| 3443 | "-channel type apply option to select image channels", |
| 3444 | "-colors value preferred number of colors in the image", |
| 3445 | "-colorspace type alternate image colorspace", |
| 3446 | "-comment string annotate image with comment", |
| 3447 | "-compose operator set image composite operator", |
| 3448 | "-compress type type of pixel compression when writing the image", |
| 3449 | "-define format:option", |
| 3450 | " define one or more image format options", |
| 3451 | "-delay value display the next image after pausing", |
| 3452 | "-density geometry horizontal and vertical density of the image", |
| 3453 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3454 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3455 | "-display server get image or font from this X server", |
| 3456 | "-dispose method layer disposal method", |
| 3457 | "-dither method apply error diffusion to image", |
| 3458 | "-encoding type text encoding type", |
| 3459 | "-endian type endianness (MSB or LSB) of the image", |
| 3460 | "-family name render text with this font family", |
| 3461 | "-fill color color to use when filling a graphic primitive", |
| 3462 | "-filter type use this filter when resizing an image", |
| 3463 | "-font name render text with this font", |
| 3464 | "-format \"string\" output formatted image characteristics", |
| 3465 | "-fuzz distance colors within this distance are considered equal", |
| 3466 | "-gravity type horizontal and vertical text placement", |
| 3467 | "-green-primary point chromaticity green primary point", |
| 3468 | "-intent type type of rendering intent when managing the image color", |
| 3469 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3470 | "-interline-spacing value", |
| 3471 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3472 | "-interpolate method pixel color interpolation method", |
| 3473 | "-interword-spacing value", |
| 3474 | " set the space between two words", |
| 3475 | "-kerning value set the space between two letters", |
| 3476 | "-label string assign a label to an image", |
| 3477 | "-limit type value pixel cache resource limit", |
| 3478 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3479 | "-mask filename associate a mask with the image", |
| 3480 | "-mattecolor color frame color", |
| 3481 | "-monitor monitor progress", |
| 3482 | "-orient type image orientation", |
| 3483 | "-page geometry size and location of an image canvas (setting)", |
| 3484 | "-ping efficiently determine image attributes", |
| 3485 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3486 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3487 | "-preview type image preview type", |
| 3488 | "-quality value JPEG/MIFF/PNG compression level", |
| 3489 | "-quiet suppress all warning messages", |
| 3490 | "-red-primary point chromaticity red primary point", |
| 3491 | "-regard-warnings pay attention to warning messages", |
| 3492 | "-remap filename transform image colors to match this set of colors", |
| 3493 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3494 | "-sampling-factor geometry", |
| 3495 | " horizontal and vertical sampling factor", |
| 3496 | "-scene value image scene number", |
| 3497 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3498 | "-size geometry width and height of image", |
| 3499 | "-stretch type render text with this font stretch", |
| 3500 | "-stroke color graphic primitive stroke color", |
| 3501 | "-strokewidth value graphic primitive stroke width", |
| 3502 | "-style type render text with this font style", |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 3503 | "-synchronize synchronize image to storage device", |
| 3504 | "-taint declare the image as modified", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3505 | "-texture filename name of texture to tile onto the image background", |
| 3506 | "-tile-offset geometry", |
| 3507 | " tile offset", |
| 3508 | "-treedepth value color tree depth", |
| 3509 | "-transparent-color color", |
| 3510 | " transparent color", |
| 3511 | "-undercolor color annotation bounding box color", |
| 3512 | "-units type the units of image resolution", |
| 3513 | "-verbose print detailed information about the image", |
| 3514 | "-view FlashPix viewing transforms", |
| 3515 | "-virtual-pixel method", |
| 3516 | " virtual pixel access method", |
| 3517 | "-weight type render text with this font weight", |
| 3518 | "-white-point point chromaticity white point", |
| 3519 | (char *) NULL |
| 3520 | }, |
| 3521 | *stack_operators[]= |
| 3522 | { |
anthony | b69c4b3 | 2011-03-23 04:37:44 +0000 | [diff] [blame] | 3523 | "-delete indexes delete the image from the image sequence", |
| 3524 | "-duplicate count,indexes", |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 3525 | " duplicate an image one or more times", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3526 | "-insert index insert last image into the image sequence", |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 3527 | "-reverse reverse image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3528 | "-swap indexes swap two images in the image sequence", |
| 3529 | (char *) NULL |
| 3530 | }; |
| 3531 | |
| 3532 | const char |
| 3533 | **p; |
| 3534 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3535 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3536 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3537 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3538 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3539 | GetClientName()); |
| 3540 | (void) printf("\nImage Settings:\n"); |
| 3541 | for (p=settings; *p != (char *) NULL; p++) |
| 3542 | (void) printf(" %s\n",*p); |
| 3543 | (void) printf("\nImage Operators:\n"); |
| 3544 | for (p=operators; *p != (char *) NULL; p++) |
| 3545 | (void) printf(" %s\n",*p); |
| 3546 | (void) printf("\nImage Sequence Operators:\n"); |
| 3547 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3548 | (void) printf(" %s\n",*p); |
| 3549 | (void) printf("\nImage Stack Operators:\n"); |
| 3550 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3551 | (void) printf(" %s\n",*p); |
| 3552 | (void) printf("\nMiscellaneous Options:\n"); |
| 3553 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3554 | (void) printf(" %s\n",*p); |
| 3555 | (void) printf( |
| 3556 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3557 | (void) printf( |
| 3558 | "number. To specify a particular image format, precede the filename\n"); |
| 3559 | (void) printf( |
| 3560 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3561 | (void) printf( |
| 3562 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3563 | (void) printf("'-' for standard input or output.\n"); |
| 3564 | return(MagickFalse); |
| 3565 | } |
| 3566 | |
| 3567 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3568 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3569 | { |
| 3570 | #define DestroyMogrify() \ |
| 3571 | { \ |
| 3572 | if (format != (char *) NULL) \ |
| 3573 | format=DestroyString(format); \ |
| 3574 | if (path != (char *) NULL) \ |
| 3575 | path=DestroyString(path); \ |
| 3576 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3577 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3578 | argv[i]=DestroyString(argv[i]); \ |
| 3579 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3580 | } |
| 3581 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3582 | { \ |
| 3583 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3584 | option); \ |
| 3585 | DestroyMogrify(); \ |
| 3586 | return(MagickFalse); \ |
| 3587 | } |
| 3588 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3589 | { \ |
| 3590 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3591 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3592 | DestroyMogrify(); \ |
| 3593 | return(MagickFalse); \ |
| 3594 | } |
| 3595 | |
| 3596 | char |
| 3597 | *format, |
| 3598 | *option, |
| 3599 | *path; |
| 3600 | |
| 3601 | Image |
| 3602 | *image; |
| 3603 | |
| 3604 | ImageStack |
| 3605 | image_stack[MaxImageStackDepth+1]; |
| 3606 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3607 | MagickBooleanType |
| 3608 | global_colormap; |
| 3609 | |
| 3610 | MagickBooleanType |
| 3611 | fire, |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3612 | pend, |
| 3613 | respect_parenthesis; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3614 | |
| 3615 | MagickStatusType |
| 3616 | status; |
| 3617 | |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3618 | register ssize_t |
| 3619 | i; |
| 3620 | |
| 3621 | ssize_t |
| 3622 | j, |
| 3623 | k; |
| 3624 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3625 | /* |
| 3626 | Set defaults. |
| 3627 | */ |
| 3628 | assert(image_info != (ImageInfo *) NULL); |
| 3629 | assert(image_info->signature == MagickSignature); |
| 3630 | if (image_info->debug != MagickFalse) |
| 3631 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3632 | assert(exception != (ExceptionInfo *) NULL); |
| 3633 | if (argc == 2) |
| 3634 | { |
| 3635 | option=argv[1]; |
| 3636 | if ((LocaleCompare("version",option+1) == 0) || |
| 3637 | (LocaleCompare("-version",option+1) == 0)) |
| 3638 | { |
| 3639 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3640 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3641 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 3642 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3643 | return(MagickFalse); |
| 3644 | } |
| 3645 | } |
| 3646 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3647 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3648 | format=(char *) NULL; |
| 3649 | path=(char *) NULL; |
| 3650 | global_colormap=MagickFalse; |
| 3651 | k=0; |
| 3652 | j=1; |
| 3653 | NewImageStack(); |
| 3654 | option=(char *) NULL; |
| 3655 | pend=MagickFalse; |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 3656 | respect_parenthesis=MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3657 | status=MagickTrue; |
| 3658 | /* |
| 3659 | Parse command line. |
| 3660 | */ |
| 3661 | ReadCommandlLine(argc,&argv); |
| 3662 | status=ExpandFilenames(&argc,&argv); |
| 3663 | if (status == MagickFalse) |
| 3664 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 3665 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3666 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3667 | { |
| 3668 | option=argv[i]; |
| 3669 | if (LocaleCompare(option,"(") == 0) |
| 3670 | { |
| 3671 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 3672 | if (k == MaxImageStackDepth) |
| 3673 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 3674 | option); |
| 3675 | PushImageStack(); |
| 3676 | continue; |
| 3677 | } |
| 3678 | if (LocaleCompare(option,")") == 0) |
| 3679 | { |
| 3680 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 3681 | if (k == 0) |
| 3682 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 3683 | PopImageStack(); |
| 3684 | continue; |
| 3685 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3686 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3687 | { |
| 3688 | char |
| 3689 | backup_filename[MaxTextExtent], |
| 3690 | *filename; |
| 3691 | |
| 3692 | Image |
| 3693 | *images; |
| 3694 | |
| 3695 | /* |
| 3696 | Option is a file name: begin by reading image from specified file. |
| 3697 | */ |
| 3698 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 3699 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3700 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3701 | filename=argv[++i]; |
| 3702 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 3703 | images=ReadImages(image_info,exception); |
| 3704 | status&=(images != (Image *) NULL) && |
| 3705 | (exception->severity < ErrorException); |
| 3706 | if (images == (Image *) NULL) |
| 3707 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3708 | if (format != (char *) NULL) |
| 3709 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 3710 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3711 | if (path != (char *) NULL) |
| 3712 | { |
| 3713 | GetPathComponent(option,TailPath,filename); |
| 3714 | (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s", |
| 3715 | path,*DirectorySeparator,filename); |
| 3716 | } |
| 3717 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 3718 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3719 | AppendImageStack(images); |
| 3720 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 3721 | if (global_colormap != MagickFalse) |
| 3722 | { |
| 3723 | QuantizeInfo |
| 3724 | *quantize_info; |
| 3725 | |
| 3726 | quantize_info=AcquireQuantizeInfo(image_info); |
| 3727 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 3728 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3729 | } |
| 3730 | *backup_filename='\0'; |
| 3731 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 3732 | (IsPathWritable(image->filename) != MagickFalse)) |
| 3733 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3734 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3735 | i; |
| 3736 | |
| 3737 | /* |
| 3738 | Rename image file as backup. |
| 3739 | */ |
| 3740 | (void) CopyMagickString(backup_filename,image->filename, |
| 3741 | MaxTextExtent); |
| 3742 | for (i=0; i < 6; i++) |
| 3743 | { |
| 3744 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 3745 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 3746 | break; |
| 3747 | } |
| 3748 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 3749 | (rename(image->filename,backup_filename) != 0)) |
| 3750 | *backup_filename='\0'; |
| 3751 | } |
| 3752 | /* |
| 3753 | Write transmogrified image to disk. |
| 3754 | */ |
| 3755 | image_info->synchronize=MagickTrue; |
| 3756 | status&=WriteImages(image_info,image,image->filename,exception); |
| 3757 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 3758 | (void) remove(backup_filename); |
| 3759 | RemoveAllImageStack(); |
| 3760 | continue; |
| 3761 | } |
| 3762 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 3763 | switch (*(option+1)) |
| 3764 | { |
| 3765 | case 'a': |
| 3766 | { |
| 3767 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 3768 | { |
| 3769 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3770 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3771 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3772 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3773 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3774 | break; |
| 3775 | } |
| 3776 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 3777 | { |
| 3778 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3779 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3780 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3781 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3782 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3783 | break; |
| 3784 | } |
| 3785 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 3786 | { |
| 3787 | 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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3791 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3792 | break; |
| 3793 | } |
| 3794 | if (LocaleCompare("affine",option+1) == 0) |
| 3795 | { |
| 3796 | if (*option == '+') |
| 3797 | break; |
| 3798 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3799 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3800 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3801 | break; |
| 3802 | } |
| 3803 | if (LocaleCompare("alpha",option+1) == 0) |
| 3804 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3805 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3806 | type; |
| 3807 | |
| 3808 | if (*option == '+') |
| 3809 | break; |
| 3810 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3811 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3812 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 3813 | type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3814 | if (type < 0) |
| 3815 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 3816 | argv[i]); |
| 3817 | break; |
| 3818 | } |
| 3819 | if (LocaleCompare("annotate",option+1) == 0) |
| 3820 | { |
| 3821 | if (*option == '+') |
| 3822 | break; |
| 3823 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3824 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3825 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3826 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3827 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3828 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3829 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3830 | i++; |
| 3831 | break; |
| 3832 | } |
| 3833 | if (LocaleCompare("antialias",option+1) == 0) |
| 3834 | break; |
| 3835 | if (LocaleCompare("append",option+1) == 0) |
| 3836 | break; |
| 3837 | if (LocaleCompare("attenuate",option+1) == 0) |
| 3838 | { |
| 3839 | if (*option == '+') |
| 3840 | break; |
| 3841 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3842 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3843 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3844 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3845 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3846 | break; |
| 3847 | } |
| 3848 | if (LocaleCompare("authenticate",option+1) == 0) |
| 3849 | { |
| 3850 | if (*option == '+') |
| 3851 | break; |
| 3852 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3853 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3854 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3855 | break; |
| 3856 | } |
| 3857 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 3858 | break; |
| 3859 | if (LocaleCompare("auto-level",option+1) == 0) |
| 3860 | break; |
| 3861 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 3862 | break; |
| 3863 | if (LocaleCompare("average",option+1) == 0) |
| 3864 | break; |
| 3865 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3866 | } |
| 3867 | case 'b': |
| 3868 | { |
| 3869 | if (LocaleCompare("background",option+1) == 0) |
| 3870 | { |
| 3871 | if (*option == '+') |
| 3872 | break; |
| 3873 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3874 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3875 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3876 | break; |
| 3877 | } |
| 3878 | if (LocaleCompare("bias",option+1) == 0) |
| 3879 | { |
| 3880 | if (*option == '+') |
| 3881 | break; |
| 3882 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3883 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3884 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3885 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3886 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3887 | break; |
| 3888 | } |
| 3889 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 3890 | break; |
| 3891 | if (LocaleCompare("black-threshold",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("blue-primary",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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3910 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3911 | break; |
| 3912 | } |
| 3913 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 3914 | { |
| 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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3919 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3920 | break; |
| 3921 | } |
| 3922 | if (LocaleCompare("blur",option+1) == 0) |
| 3923 | { |
| 3924 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3925 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3926 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3927 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3928 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3929 | break; |
| 3930 | } |
| 3931 | if (LocaleCompare("border",option+1) == 0) |
| 3932 | { |
| 3933 | if (*option == '+') |
| 3934 | break; |
| 3935 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3936 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3937 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3938 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3939 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3940 | break; |
| 3941 | } |
| 3942 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 3943 | { |
| 3944 | if (*option == '+') |
| 3945 | break; |
| 3946 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3947 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3948 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3949 | break; |
| 3950 | } |
| 3951 | if (LocaleCompare("box",option+1) == 0) |
| 3952 | { |
| 3953 | if (*option == '+') |
| 3954 | break; |
| 3955 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3956 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3957 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3958 | break; |
| 3959 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3960 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 3961 | { |
| 3962 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3963 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3964 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3965 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3966 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3967 | break; |
| 3968 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3969 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 3970 | } |
| 3971 | case 'c': |
| 3972 | { |
| 3973 | if (LocaleCompare("cache",option+1) == 0) |
| 3974 | { |
| 3975 | if (*option == '+') |
| 3976 | break; |
| 3977 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3978 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3979 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3980 | if (IsGeometry(argv[i]) == MagickFalse) |
| 3981 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 3982 | break; |
| 3983 | } |
| 3984 | if (LocaleCompare("caption",option+1) == 0) |
| 3985 | { |
| 3986 | if (*option == '+') |
| 3987 | break; |
| 3988 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3989 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3990 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 3991 | break; |
| 3992 | } |
| 3993 | if (LocaleCompare("channel",option+1) == 0) |
| 3994 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3995 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3996 | channel; |
| 3997 | |
| 3998 | if (*option == '+') |
| 3999 | break; |
| 4000 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4001 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4002 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4003 | channel=ParseChannelOption(argv[i]); |
| 4004 | if (channel < 0) |
| 4005 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4006 | argv[i]); |
| 4007 | break; |
| 4008 | } |
| 4009 | if (LocaleCompare("cdl",option+1) == 0) |
| 4010 | { |
| 4011 | if (*option == '+') |
| 4012 | break; |
| 4013 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4014 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4015 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4016 | break; |
| 4017 | } |
| 4018 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4019 | { |
| 4020 | if (*option == '+') |
| 4021 | break; |
| 4022 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4023 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4024 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4025 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4026 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4027 | break; |
| 4028 | } |
| 4029 | if (LocaleCompare("chop",option+1) == 0) |
| 4030 | { |
| 4031 | if (*option == '+') |
| 4032 | break; |
| 4033 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4034 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4035 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4036 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4037 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4038 | break; |
| 4039 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4040 | if (LocaleCompare("clamp",option+1) == 0) |
| 4041 | break; |
| 4042 | if (LocaleCompare("clip",option+1) == 0) |
| 4043 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4044 | if (LocaleCompare("clip-mask",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 | break; |
| 4052 | } |
| 4053 | if (LocaleCompare("clut",option+1) == 0) |
| 4054 | break; |
| 4055 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4056 | break; |
| 4057 | if (LocaleCompare("colorize",option+1) == 0) |
| 4058 | { |
| 4059 | if (*option == '+') |
| 4060 | break; |
| 4061 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4062 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4063 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4064 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4065 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4066 | break; |
| 4067 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4068 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4069 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4070 | KernelInfo |
| 4071 | *kernel_info; |
| 4072 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4073 | if (*option == '+') |
| 4074 | break; |
| 4075 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4076 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4077 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4078 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4079 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4080 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4081 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4082 | break; |
| 4083 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4084 | if (LocaleCompare("colors",option+1) == 0) |
| 4085 | { |
| 4086 | if (*option == '+') |
| 4087 | break; |
| 4088 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4089 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4090 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4091 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4092 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4093 | break; |
| 4094 | } |
| 4095 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4096 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4097 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4098 | colorspace; |
| 4099 | |
| 4100 | if (*option == '+') |
| 4101 | break; |
| 4102 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4103 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4104 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4105 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4106 | argv[i]); |
| 4107 | if (colorspace < 0) |
| 4108 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4109 | argv[i]); |
| 4110 | break; |
| 4111 | } |
| 4112 | if (LocaleCompare("combine",option+1) == 0) |
| 4113 | break; |
| 4114 | if (LocaleCompare("comment",option+1) == 0) |
| 4115 | { |
| 4116 | if (*option == '+') |
| 4117 | break; |
| 4118 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4119 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4120 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4121 | break; |
| 4122 | } |
| 4123 | if (LocaleCompare("composite",option+1) == 0) |
| 4124 | break; |
| 4125 | if (LocaleCompare("compress",option+1) == 0) |
| 4126 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4127 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4128 | compress; |
| 4129 | |
| 4130 | if (*option == '+') |
| 4131 | break; |
| 4132 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4133 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4134 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4135 | compress=ParseCommandOption(MagickCompressOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4136 | argv[i]); |
| 4137 | if (compress < 0) |
| 4138 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4139 | argv[i]); |
| 4140 | break; |
| 4141 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4142 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4143 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4144 | if (LocaleCompare("contrast",option+1) == 0) |
| 4145 | break; |
| 4146 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4147 | { |
| 4148 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4149 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4150 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4151 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4152 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4153 | break; |
| 4154 | } |
| 4155 | if (LocaleCompare("convolve",option+1) == 0) |
| 4156 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4157 | KernelInfo |
| 4158 | *kernel_info; |
| 4159 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4160 | if (*option == '+') |
| 4161 | break; |
| 4162 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4163 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4164 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4165 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4166 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 4167 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 4168 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4169 | break; |
| 4170 | } |
| 4171 | if (LocaleCompare("crop",option+1) == 0) |
| 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); |
| 4178 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4179 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4180 | break; |
| 4181 | } |
| 4182 | if (LocaleCompare("cycle",option+1) == 0) |
| 4183 | { |
| 4184 | if (*option == '+') |
| 4185 | break; |
| 4186 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4187 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4188 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4189 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4190 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4191 | break; |
| 4192 | } |
| 4193 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4194 | } |
| 4195 | case 'd': |
| 4196 | { |
| 4197 | if (LocaleCompare("decipher",option+1) == 0) |
| 4198 | { |
| 4199 | if (*option == '+') |
| 4200 | break; |
| 4201 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4202 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4203 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4204 | break; |
| 4205 | } |
| 4206 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4207 | break; |
| 4208 | if (LocaleCompare("debug",option+1) == 0) |
| 4209 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4210 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4211 | event; |
| 4212 | |
| 4213 | if (*option == '+') |
| 4214 | break; |
| 4215 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4216 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4217 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4218 | event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4219 | if (event < 0) |
| 4220 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4221 | argv[i]); |
| 4222 | (void) SetLogEventMask(argv[i]); |
| 4223 | break; |
| 4224 | } |
| 4225 | if (LocaleCompare("define",option+1) == 0) |
| 4226 | { |
| 4227 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4228 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4229 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4230 | if (*option == '+') |
| 4231 | { |
| 4232 | const char |
| 4233 | *define; |
| 4234 | |
| 4235 | define=GetImageOption(image_info,argv[i]); |
| 4236 | if (define == (const char *) NULL) |
| 4237 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4238 | break; |
| 4239 | } |
| 4240 | break; |
| 4241 | } |
| 4242 | if (LocaleCompare("delay",option+1) == 0) |
| 4243 | { |
| 4244 | if (*option == '+') |
| 4245 | break; |
| 4246 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4247 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4248 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4249 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4250 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4251 | break; |
| 4252 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4253 | if (LocaleCompare("delete",option+1) == 0) |
| 4254 | { |
| 4255 | if (*option == '+') |
| 4256 | break; |
| 4257 | i++; |
| 4258 | if (i == (ssize_t) (argc-1)) |
| 4259 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4260 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4261 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4262 | break; |
| 4263 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4264 | if (LocaleCompare("density",option+1) == 0) |
| 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 | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4270 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4271 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4272 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4273 | break; |
| 4274 | } |
| 4275 | if (LocaleCompare("depth",option+1) == 0) |
| 4276 | { |
| 4277 | if (*option == '+') |
| 4278 | break; |
| 4279 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4280 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4281 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4282 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4283 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4284 | break; |
| 4285 | } |
| 4286 | if (LocaleCompare("deskew",option+1) == 0) |
| 4287 | { |
| 4288 | if (*option == '+') |
| 4289 | break; |
| 4290 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4291 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4292 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4293 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4294 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4295 | break; |
| 4296 | } |
| 4297 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4298 | break; |
| 4299 | if (LocaleCompare("dft",option+1) == 0) |
| 4300 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4301 | if (LocaleCompare("direction",option+1) == 0) |
| 4302 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4303 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4304 | direction; |
| 4305 | |
| 4306 | if (*option == '+') |
| 4307 | break; |
| 4308 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4309 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4310 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4311 | direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4312 | argv[i]); |
| 4313 | if (direction < 0) |
| 4314 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4315 | argv[i]); |
| 4316 | break; |
| 4317 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4318 | if (LocaleCompare("display",option+1) == 0) |
| 4319 | { |
| 4320 | if (*option == '+') |
| 4321 | break; |
| 4322 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4323 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4324 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4325 | break; |
| 4326 | } |
| 4327 | if (LocaleCompare("dispose",option+1) == 0) |
| 4328 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4329 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4330 | dispose; |
| 4331 | |
| 4332 | if (*option == '+') |
| 4333 | break; |
| 4334 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4335 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4336 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4337 | dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4338 | if (dispose < 0) |
| 4339 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4340 | argv[i]); |
| 4341 | break; |
| 4342 | } |
| 4343 | if (LocaleCompare("distort",option+1) == 0) |
| 4344 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4345 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4346 | op; |
| 4347 | |
| 4348 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4349 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4350 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4351 | op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4352 | if (op < 0) |
| 4353 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4354 | argv[i]); |
| 4355 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4356 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4357 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4358 | break; |
| 4359 | } |
| 4360 | if (LocaleCompare("dither",option+1) == 0) |
| 4361 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4362 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4363 | method; |
| 4364 | |
| 4365 | if (*option == '+') |
| 4366 | break; |
| 4367 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4368 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4369 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4370 | method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4371 | if (method < 0) |
| 4372 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4373 | argv[i]); |
| 4374 | break; |
| 4375 | } |
| 4376 | if (LocaleCompare("draw",option+1) == 0) |
| 4377 | { |
| 4378 | if (*option == '+') |
| 4379 | break; |
| 4380 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4381 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4382 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4383 | break; |
| 4384 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 4385 | if (LocaleCompare("duplicate",option+1) == 0) |
| 4386 | { |
| 4387 | if (*option == '+') |
| 4388 | break; |
| 4389 | i++; |
| 4390 | if (i == (ssize_t) (argc-1)) |
| 4391 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4392 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4393 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4394 | break; |
| 4395 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4396 | if (LocaleCompare("duration",option+1) == 0) |
| 4397 | { |
| 4398 | if (*option == '+') |
| 4399 | break; |
| 4400 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4401 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4402 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4403 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4404 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4405 | break; |
| 4406 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4407 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4408 | } |
| 4409 | case 'e': |
| 4410 | { |
| 4411 | if (LocaleCompare("edge",option+1) == 0) |
| 4412 | { |
| 4413 | if (*option == '+') |
| 4414 | break; |
| 4415 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4416 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4417 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4418 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4419 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4420 | break; |
| 4421 | } |
| 4422 | if (LocaleCompare("emboss",option+1) == 0) |
| 4423 | { |
| 4424 | if (*option == '+') |
| 4425 | break; |
| 4426 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4427 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4428 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4429 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4430 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4431 | break; |
| 4432 | } |
| 4433 | if (LocaleCompare("encipher",option+1) == 0) |
| 4434 | { |
| 4435 | if (*option == '+') |
| 4436 | break; |
| 4437 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4438 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4439 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4440 | break; |
| 4441 | } |
| 4442 | if (LocaleCompare("encoding",option+1) == 0) |
| 4443 | { |
| 4444 | if (*option == '+') |
| 4445 | break; |
| 4446 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4447 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4448 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4449 | break; |
| 4450 | } |
| 4451 | if (LocaleCompare("endian",option+1) == 0) |
| 4452 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4453 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4454 | endian; |
| 4455 | |
| 4456 | if (*option == '+') |
| 4457 | break; |
| 4458 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4459 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4460 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4461 | endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4462 | if (endian < 0) |
| 4463 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4464 | argv[i]); |
| 4465 | break; |
| 4466 | } |
| 4467 | if (LocaleCompare("enhance",option+1) == 0) |
| 4468 | break; |
| 4469 | if (LocaleCompare("equalize",option+1) == 0) |
| 4470 | break; |
| 4471 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4472 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4473 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4474 | op; |
| 4475 | |
| 4476 | if (*option == '+') |
| 4477 | break; |
| 4478 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4479 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4480 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4481 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4482 | if (op < 0) |
| 4483 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4484 | argv[i]); |
| 4485 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4486 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4487 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4488 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4489 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4490 | break; |
| 4491 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4492 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4493 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4494 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4495 | op; |
| 4496 | |
| 4497 | if (*option == '+') |
| 4498 | break; |
| 4499 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4500 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4501 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4502 | op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4503 | if (op < 0) |
| 4504 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4505 | argv[i]); |
| 4506 | break; |
| 4507 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4508 | if (LocaleCompare("extent",option+1) == 0) |
| 4509 | { |
| 4510 | if (*option == '+') |
| 4511 | break; |
| 4512 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4513 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4514 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4515 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4516 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4517 | break; |
| 4518 | } |
| 4519 | if (LocaleCompare("extract",option+1) == 0) |
| 4520 | { |
| 4521 | if (*option == '+') |
| 4522 | break; |
| 4523 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4524 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4525 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4526 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4527 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4528 | break; |
| 4529 | } |
| 4530 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4531 | } |
| 4532 | case 'f': |
| 4533 | { |
| 4534 | if (LocaleCompare("family",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-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4540 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4541 | break; |
| 4542 | } |
| 4543 | if (LocaleCompare("fill",option+1) == 0) |
| 4544 | { |
| 4545 | if (*option == '+') |
| 4546 | break; |
| 4547 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4548 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4549 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4550 | break; |
| 4551 | } |
| 4552 | if (LocaleCompare("filter",option+1) == 0) |
| 4553 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4554 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4555 | filter; |
| 4556 | |
| 4557 | if (*option == '+') |
| 4558 | break; |
| 4559 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4560 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4561 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4562 | filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4563 | if (filter < 0) |
| 4564 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4565 | argv[i]); |
| 4566 | break; |
| 4567 | } |
| 4568 | if (LocaleCompare("flatten",option+1) == 0) |
| 4569 | break; |
| 4570 | if (LocaleCompare("flip",option+1) == 0) |
| 4571 | break; |
| 4572 | if (LocaleCompare("flop",option+1) == 0) |
| 4573 | break; |
| 4574 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4575 | { |
| 4576 | if (*option == '+') |
| 4577 | break; |
| 4578 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4579 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4580 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4581 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4582 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4583 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4584 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4585 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4586 | break; |
| 4587 | } |
| 4588 | if (LocaleCompare("font",option+1) == 0) |
| 4589 | { |
| 4590 | if (*option == '+') |
| 4591 | break; |
| 4592 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4593 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4594 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4595 | break; |
| 4596 | } |
| 4597 | if (LocaleCompare("format",option+1) == 0) |
| 4598 | { |
| 4599 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4600 | (void) CloneString(&format,(char *) NULL); |
| 4601 | if (*option == '+') |
| 4602 | break; |
| 4603 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4604 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4605 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4606 | (void) CloneString(&format,argv[i]); |
| 4607 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4608 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4609 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4610 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4611 | if (*image_info->magick == '\0') |
| 4612 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4613 | format); |
| 4614 | break; |
| 4615 | } |
| 4616 | if (LocaleCompare("frame",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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4622 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4623 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4624 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4625 | break; |
| 4626 | } |
| 4627 | if (LocaleCompare("function",option+1) == 0) |
| 4628 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4629 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4630 | op; |
| 4631 | |
| 4632 | if (*option == '+') |
| 4633 | break; |
| 4634 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4635 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4636 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4637 | op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4638 | if (op < 0) |
| 4639 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4640 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4641 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4642 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4643 | break; |
| 4644 | } |
| 4645 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4646 | { |
| 4647 | if (*option == '+') |
| 4648 | break; |
| 4649 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4650 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4651 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4652 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4653 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4654 | break; |
| 4655 | } |
| 4656 | if (LocaleCompare("fx",option+1) == 0) |
| 4657 | { |
| 4658 | if (*option == '+') |
| 4659 | break; |
| 4660 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4661 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4662 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4663 | break; |
| 4664 | } |
| 4665 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4666 | } |
| 4667 | case 'g': |
| 4668 | { |
| 4669 | if (LocaleCompare("gamma",option+1) == 0) |
| 4670 | { |
| 4671 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4672 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4673 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4674 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4675 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4676 | break; |
| 4677 | } |
| 4678 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 4679 | (LocaleCompare("gaussian",option+1) == 0)) |
| 4680 | { |
| 4681 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4682 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4683 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4684 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4685 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4686 | break; |
| 4687 | } |
| 4688 | if (LocaleCompare("geometry",option+1) == 0) |
| 4689 | { |
| 4690 | if (*option == '+') |
| 4691 | break; |
| 4692 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4693 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4694 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4695 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4696 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4697 | break; |
| 4698 | } |
| 4699 | if (LocaleCompare("gravity",option+1) == 0) |
| 4700 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4701 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4702 | gravity; |
| 4703 | |
| 4704 | if (*option == '+') |
| 4705 | break; |
| 4706 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4707 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4708 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4709 | gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4710 | if (gravity < 0) |
| 4711 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 4712 | argv[i]); |
| 4713 | break; |
| 4714 | } |
| 4715 | if (LocaleCompare("green-primary",option+1) == 0) |
| 4716 | { |
| 4717 | if (*option == '+') |
| 4718 | break; |
| 4719 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4720 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4721 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4722 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4723 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4724 | break; |
| 4725 | } |
| 4726 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4727 | } |
| 4728 | case 'h': |
| 4729 | { |
| 4730 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 4731 | break; |
| 4732 | if ((LocaleCompare("help",option+1) == 0) || |
| 4733 | (LocaleCompare("-help",option+1) == 0)) |
| 4734 | return(MogrifyUsage()); |
| 4735 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4736 | } |
| 4737 | case 'i': |
| 4738 | { |
| 4739 | if (LocaleCompare("identify",option+1) == 0) |
| 4740 | break; |
| 4741 | if (LocaleCompare("idft",option+1) == 0) |
| 4742 | break; |
| 4743 | if (LocaleCompare("implode",option+1) == 0) |
| 4744 | { |
| 4745 | if (*option == '+') |
| 4746 | break; |
| 4747 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4748 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4749 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4750 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4751 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4752 | break; |
| 4753 | } |
| 4754 | if (LocaleCompare("intent",option+1) == 0) |
| 4755 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4756 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4757 | intent; |
| 4758 | |
| 4759 | if (*option == '+') |
| 4760 | break; |
| 4761 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4762 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4763 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4764 | intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4765 | if (intent < 0) |
| 4766 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 4767 | argv[i]); |
| 4768 | break; |
| 4769 | } |
| 4770 | if (LocaleCompare("interlace",option+1) == 0) |
| 4771 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4772 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4773 | interlace; |
| 4774 | |
| 4775 | if (*option == '+') |
| 4776 | break; |
| 4777 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4778 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4779 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4780 | interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4781 | argv[i]); |
| 4782 | if (interlace < 0) |
| 4783 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 4784 | argv[i]); |
| 4785 | break; |
| 4786 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4787 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 4788 | { |
| 4789 | if (*option == '+') |
| 4790 | break; |
| 4791 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4792 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 4793 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4794 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4795 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4796 | break; |
| 4797 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4798 | if (LocaleCompare("interpolate",option+1) == 0) |
| 4799 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4800 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4801 | interpolate; |
| 4802 | |
| 4803 | if (*option == '+') |
| 4804 | break; |
| 4805 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4806 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4807 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4808 | interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4809 | argv[i]); |
| 4810 | if (interpolate < 0) |
| 4811 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 4812 | argv[i]); |
| 4813 | break; |
| 4814 | } |
| 4815 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 4816 | { |
| 4817 | if (*option == '+') |
| 4818 | break; |
| 4819 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4820 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4821 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4822 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4823 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4824 | break; |
| 4825 | } |
| 4826 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4827 | } |
| 4828 | case 'k': |
| 4829 | { |
| 4830 | if (LocaleCompare("kerning",option+1) == 0) |
| 4831 | { |
| 4832 | if (*option == '+') |
| 4833 | break; |
| 4834 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4835 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4836 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4837 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4838 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4839 | break; |
| 4840 | } |
| 4841 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4842 | } |
| 4843 | case 'l': |
| 4844 | { |
| 4845 | if (LocaleCompare("label",option+1) == 0) |
| 4846 | { |
| 4847 | if (*option == '+') |
| 4848 | break; |
| 4849 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4850 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4851 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4852 | break; |
| 4853 | } |
| 4854 | if (LocaleCompare("lat",option+1) == 0) |
| 4855 | { |
| 4856 | if (*option == '+') |
| 4857 | break; |
| 4858 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4859 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4860 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4861 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4862 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4863 | } |
| 4864 | if (LocaleCompare("layers",option+1) == 0) |
| 4865 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4866 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4867 | type; |
| 4868 | |
| 4869 | if (*option == '+') |
| 4870 | break; |
| 4871 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4872 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4873 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4874 | type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4875 | if (type < 0) |
| 4876 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 4877 | argv[i]); |
| 4878 | break; |
| 4879 | } |
| 4880 | if (LocaleCompare("level",option+1) == 0) |
| 4881 | { |
| 4882 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4883 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4884 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4885 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4886 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4887 | break; |
| 4888 | } |
| 4889 | if (LocaleCompare("level-colors",option+1) == 0) |
| 4890 | { |
| 4891 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4892 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4893 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4894 | break; |
| 4895 | } |
| 4896 | if (LocaleCompare("linewidth",option+1) == 0) |
| 4897 | { |
| 4898 | if (*option == '+') |
| 4899 | break; |
| 4900 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4901 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4902 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4903 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4904 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4905 | break; |
| 4906 | } |
| 4907 | if (LocaleCompare("limit",option+1) == 0) |
| 4908 | { |
| 4909 | char |
| 4910 | *p; |
| 4911 | |
| 4912 | double |
| 4913 | value; |
| 4914 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4915 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4916 | resource; |
| 4917 | |
| 4918 | if (*option == '+') |
| 4919 | break; |
| 4920 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4921 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4922 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4923 | resource=ParseCommandOption(MagickResourceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4924 | argv[i]); |
| 4925 | if (resource < 0) |
| 4926 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 4927 | argv[i]); |
| 4928 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4929 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4930 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4931 | value=strtod(argv[i],&p); |
cristy | da16f16 | 2011-02-19 23:52:17 +0000 | [diff] [blame] | 4932 | (void) value; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4933 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 4934 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4935 | break; |
| 4936 | } |
| 4937 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 4938 | { |
| 4939 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4940 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4941 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4942 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4943 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4944 | break; |
| 4945 | } |
| 4946 | if (LocaleCompare("list",option+1) == 0) |
| 4947 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4948 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4949 | list; |
| 4950 | |
| 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); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 4956 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4957 | if (list < 0) |
| 4958 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4959 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4960 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 4961 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4962 | } |
| 4963 | if (LocaleCompare("log",option+1) == 0) |
| 4964 | { |
| 4965 | if (*option == '+') |
| 4966 | break; |
| 4967 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4968 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4969 | (strchr(argv[i],'%') == (char *) NULL)) |
| 4970 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4971 | break; |
| 4972 | } |
| 4973 | if (LocaleCompare("loop",option+1) == 0) |
| 4974 | { |
| 4975 | if (*option == '+') |
| 4976 | break; |
| 4977 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4978 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4979 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4980 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4981 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4982 | break; |
| 4983 | } |
| 4984 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4985 | } |
| 4986 | case 'm': |
| 4987 | { |
| 4988 | if (LocaleCompare("map",option+1) == 0) |
| 4989 | { |
| 4990 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 4991 | if (*option == '+') |
| 4992 | break; |
| 4993 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4994 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4995 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4996 | break; |
| 4997 | } |
| 4998 | if (LocaleCompare("mask",option+1) == 0) |
| 4999 | { |
| 5000 | if (*option == '+') |
| 5001 | break; |
| 5002 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5003 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5004 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5005 | break; |
| 5006 | } |
| 5007 | if (LocaleCompare("matte",option+1) == 0) |
| 5008 | break; |
| 5009 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 5010 | { |
| 5011 | if (*option == '+') |
| 5012 | break; |
| 5013 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5014 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5015 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5016 | break; |
| 5017 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5018 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5019 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5020 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5021 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5022 | if (LocaleCompare("modulate",option+1) == 0) |
| 5023 | { |
| 5024 | if (*option == '+') |
| 5025 | break; |
| 5026 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5027 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5028 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5029 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5030 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5031 | break; |
| 5032 | } |
| 5033 | if (LocaleCompare("median",option+1) == 0) |
| 5034 | { |
| 5035 | if (*option == '+') |
| 5036 | break; |
| 5037 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5038 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5039 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5040 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5041 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5042 | break; |
| 5043 | } |
cristy | 69ec32d | 2011-02-27 23:57:09 +0000 | [diff] [blame] | 5044 | if (LocaleCompare("mode",option+1) == 0) |
| 5045 | { |
| 5046 | if (*option == '+') |
| 5047 | break; |
| 5048 | i++; |
| 5049 | if (i == (ssize_t) argc) |
| 5050 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5051 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5052 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5053 | break; |
| 5054 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5055 | if (LocaleCompare("monitor",option+1) == 0) |
| 5056 | break; |
| 5057 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5058 | break; |
| 5059 | if (LocaleCompare("morph",option+1) == 0) |
| 5060 | { |
| 5061 | if (*option == '+') |
| 5062 | break; |
| 5063 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5064 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5065 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5066 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5067 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5068 | break; |
| 5069 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5070 | if (LocaleCompare("morphology",option+1) == 0) |
| 5071 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5072 | char |
| 5073 | token[MaxTextExtent]; |
| 5074 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5075 | KernelInfo |
| 5076 | *kernel_info; |
| 5077 | |
| 5078 | ssize_t |
| 5079 | op; |
| 5080 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5081 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5082 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5083 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5084 | GetMagickToken(argv[i],NULL,token); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5085 | op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5086 | if (op < 0) |
| 5087 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5088 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5089 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5090 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5091 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5092 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5093 | if (kernel_info == (KernelInfo *) NULL) |
cristy | f4e8c91 | 2010-08-08 01:51:19 +0000 | [diff] [blame] | 5094 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame] | 5095 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5096 | break; |
| 5097 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5098 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5099 | break; |
| 5100 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5101 | { |
| 5102 | if (*option == '+') |
| 5103 | break; |
| 5104 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5105 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5106 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5107 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5108 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5109 | break; |
| 5110 | } |
| 5111 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5112 | } |
| 5113 | case 'n': |
| 5114 | { |
| 5115 | if (LocaleCompare("negate",option+1) == 0) |
| 5116 | break; |
| 5117 | if (LocaleCompare("noise",option+1) == 0) |
| 5118 | { |
| 5119 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5120 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5121 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5122 | if (*option == '+') |
| 5123 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5124 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5125 | noise; |
| 5126 | |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5127 | noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5128 | if (noise < 0) |
| 5129 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5130 | argv[i]); |
| 5131 | break; |
| 5132 | } |
| 5133 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5134 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5135 | break; |
| 5136 | } |
| 5137 | if (LocaleCompare("noop",option+1) == 0) |
| 5138 | break; |
| 5139 | if (LocaleCompare("normalize",option+1) == 0) |
| 5140 | break; |
| 5141 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5142 | } |
| 5143 | case 'o': |
| 5144 | { |
| 5145 | if (LocaleCompare("opaque",option+1) == 0) |
| 5146 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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("ordered-dither",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 | break; |
| 5160 | } |
| 5161 | if (LocaleCompare("orient",option+1) == 0) |
| 5162 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5163 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5164 | orientation; |
| 5165 | |
| 5166 | orientation=UndefinedOrientation; |
| 5167 | if (*option == '+') |
| 5168 | break; |
| 5169 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5170 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5171 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5172 | orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5173 | argv[i]); |
| 5174 | if (orientation < 0) |
| 5175 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5176 | argv[i]); |
| 5177 | break; |
| 5178 | } |
| 5179 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5180 | } |
| 5181 | case 'p': |
| 5182 | { |
| 5183 | if (LocaleCompare("page",option+1) == 0) |
| 5184 | { |
| 5185 | if (*option == '+') |
| 5186 | break; |
| 5187 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5188 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5189 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5190 | break; |
| 5191 | } |
| 5192 | if (LocaleCompare("paint",option+1) == 0) |
| 5193 | { |
| 5194 | if (*option == '+') |
| 5195 | break; |
| 5196 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5197 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5198 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5199 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5200 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5201 | break; |
| 5202 | } |
| 5203 | if (LocaleCompare("path",option+1) == 0) |
| 5204 | { |
| 5205 | (void) CloneString(&path,(char *) NULL); |
| 5206 | if (*option == '+') |
| 5207 | break; |
| 5208 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5209 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5210 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5211 | (void) CloneString(&path,argv[i]); |
| 5212 | break; |
| 5213 | } |
| 5214 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5215 | { |
| 5216 | if (*option == '+') |
| 5217 | break; |
| 5218 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5219 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5220 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5221 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5222 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5223 | break; |
| 5224 | } |
| 5225 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5226 | { |
| 5227 | if (*option == '+') |
| 5228 | break; |
| 5229 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5230 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5231 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5232 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5233 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5234 | break; |
| 5235 | } |
| 5236 | if (LocaleCompare("posterize",option+1) == 0) |
| 5237 | { |
| 5238 | if (*option == '+') |
| 5239 | break; |
| 5240 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5241 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5242 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5243 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5244 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5245 | break; |
| 5246 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5247 | if (LocaleCompare("precision",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 | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5253 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5254 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5255 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5256 | break; |
| 5257 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5258 | if (LocaleCompare("print",option+1) == 0) |
| 5259 | { |
| 5260 | if (*option == '+') |
| 5261 | break; |
| 5262 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5263 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5264 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5265 | break; |
| 5266 | } |
| 5267 | if (LocaleCompare("process",option+1) == 0) |
| 5268 | { |
| 5269 | if (*option == '+') |
| 5270 | break; |
| 5271 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5272 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5273 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5274 | break; |
| 5275 | } |
| 5276 | if (LocaleCompare("profile",option+1) == 0) |
| 5277 | { |
| 5278 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5279 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5280 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5281 | break; |
| 5282 | } |
| 5283 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5284 | } |
| 5285 | case 'q': |
| 5286 | { |
| 5287 | if (LocaleCompare("quality",option+1) == 0) |
| 5288 | { |
| 5289 | if (*option == '+') |
| 5290 | break; |
| 5291 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5292 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5293 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5294 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5295 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5296 | break; |
| 5297 | } |
| 5298 | if (LocaleCompare("quantize",option+1) == 0) |
| 5299 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5300 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5301 | colorspace; |
| 5302 | |
| 5303 | if (*option == '+') |
| 5304 | break; |
| 5305 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5306 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5307 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5308 | colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5309 | argv[i]); |
| 5310 | if (colorspace < 0) |
| 5311 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5312 | argv[i]); |
| 5313 | break; |
| 5314 | } |
| 5315 | if (LocaleCompare("quiet",option+1) == 0) |
| 5316 | break; |
| 5317 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5318 | } |
| 5319 | case 'r': |
| 5320 | { |
| 5321 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5322 | { |
| 5323 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5324 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5325 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5326 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5327 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5328 | break; |
| 5329 | } |
| 5330 | if (LocaleCompare("raise",option+1) == 0) |
| 5331 | { |
| 5332 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5333 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5334 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5335 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5336 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5337 | break; |
| 5338 | } |
| 5339 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5340 | { |
| 5341 | if (*option == '+') |
| 5342 | break; |
| 5343 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5344 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5345 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5346 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5347 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5348 | break; |
| 5349 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5350 | if (LocaleCompare("recolor",option+1) == 0) |
| 5351 | { |
| 5352 | if (*option == '+') |
| 5353 | break; |
| 5354 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5355 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5356 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5357 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5358 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5359 | break; |
| 5360 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5361 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5362 | { |
| 5363 | if (*option == '+') |
| 5364 | break; |
| 5365 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5366 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5367 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5368 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5369 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5370 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5371 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5372 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5373 | if (LocaleCompare("region",option+1) == 0) |
| 5374 | { |
| 5375 | if (*option == '+') |
| 5376 | break; |
| 5377 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5378 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5379 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5380 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5381 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5382 | break; |
| 5383 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5384 | if (LocaleCompare("remap",option+1) == 0) |
| 5385 | { |
| 5386 | if (*option == '+') |
| 5387 | break; |
| 5388 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5389 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5390 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5391 | break; |
| 5392 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5393 | if (LocaleCompare("render",option+1) == 0) |
| 5394 | break; |
| 5395 | if (LocaleCompare("repage",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("resample",option+1) == 0) |
| 5407 | { |
| 5408 | if (*option == '+') |
| 5409 | break; |
| 5410 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5411 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5412 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5413 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5414 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5415 | break; |
| 5416 | } |
| 5417 | if (LocaleCompare("resize",option+1) == 0) |
| 5418 | { |
| 5419 | if (*option == '+') |
| 5420 | break; |
| 5421 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5422 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5423 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5424 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5425 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5426 | break; |
| 5427 | } |
cristy | ebbcfea | 2011-02-25 02:43:54 +0000 | [diff] [blame] | 5428 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 5429 | { |
| 5430 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 5431 | break; |
| 5432 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5433 | if (LocaleCompare("reverse",option+1) == 0) |
| 5434 | break; |
| 5435 | if (LocaleCompare("roll",option+1) == 0) |
| 5436 | { |
| 5437 | if (*option == '+') |
| 5438 | break; |
| 5439 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5440 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5441 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5442 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5443 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5444 | break; |
| 5445 | } |
| 5446 | if (LocaleCompare("rotate",option+1) == 0) |
| 5447 | { |
| 5448 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5449 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5450 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5451 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5452 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5453 | break; |
| 5454 | } |
| 5455 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5456 | } |
| 5457 | case 's': |
| 5458 | { |
| 5459 | if (LocaleCompare("sample",option+1) == 0) |
| 5460 | { |
| 5461 | if (*option == '+') |
| 5462 | break; |
| 5463 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5464 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5465 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5466 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5467 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5468 | break; |
| 5469 | } |
| 5470 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5471 | { |
| 5472 | if (*option == '+') |
| 5473 | break; |
| 5474 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5475 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5476 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5477 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5478 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5479 | break; |
| 5480 | } |
| 5481 | if (LocaleCompare("scale",option+1) == 0) |
| 5482 | { |
| 5483 | if (*option == '+') |
| 5484 | break; |
| 5485 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5486 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5487 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5488 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5489 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5490 | break; |
| 5491 | } |
| 5492 | if (LocaleCompare("scene",option+1) == 0) |
| 5493 | { |
| 5494 | if (*option == '+') |
| 5495 | break; |
| 5496 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5497 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5498 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5499 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5500 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5501 | break; |
| 5502 | } |
| 5503 | if (LocaleCompare("seed",option+1) == 0) |
| 5504 | { |
| 5505 | if (*option == '+') |
| 5506 | break; |
| 5507 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5508 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5509 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5510 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5511 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5512 | break; |
| 5513 | } |
| 5514 | if (LocaleCompare("segment",option+1) == 0) |
| 5515 | { |
| 5516 | if (*option == '+') |
| 5517 | break; |
| 5518 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5519 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5520 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5521 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5522 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5523 | break; |
| 5524 | } |
| 5525 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5526 | { |
| 5527 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5528 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5529 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5530 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5531 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5532 | break; |
| 5533 | } |
| 5534 | if (LocaleCompare("separate",option+1) == 0) |
| 5535 | break; |
| 5536 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5537 | { |
| 5538 | if (*option == '+') |
| 5539 | break; |
| 5540 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5541 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5542 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5543 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5544 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5545 | break; |
| 5546 | } |
| 5547 | if (LocaleCompare("set",option+1) == 0) |
| 5548 | { |
| 5549 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5550 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5551 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5552 | if (*option == '+') |
| 5553 | break; |
| 5554 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5555 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5556 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5557 | break; |
| 5558 | } |
| 5559 | if (LocaleCompare("shade",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("shadow",option+1) == 0) |
| 5569 | { |
| 5570 | if (*option == '+') |
| 5571 | break; |
| 5572 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5573 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5574 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5575 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5576 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5577 | break; |
| 5578 | } |
| 5579 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5580 | { |
| 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("shave",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 | } |
| 5599 | if (LocaleCompare("shear",option+1) == 0) |
| 5600 | { |
| 5601 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5602 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5603 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5604 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5605 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5606 | break; |
| 5607 | } |
| 5608 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5609 | { |
| 5610 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5611 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5612 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5613 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5614 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5615 | break; |
| 5616 | } |
| 5617 | if (LocaleCompare("size",option+1) == 0) |
| 5618 | { |
| 5619 | if (*option == '+') |
| 5620 | break; |
| 5621 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5622 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5623 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5624 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5625 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5626 | break; |
| 5627 | } |
| 5628 | if (LocaleCompare("sketch",option+1) == 0) |
| 5629 | { |
| 5630 | if (*option == '+') |
| 5631 | break; |
| 5632 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5633 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5634 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5635 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5636 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5637 | break; |
| 5638 | } |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5639 | if (LocaleCompare("smush",option+1) == 0) |
| 5640 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5641 | i++; |
| 5642 | if (i == (ssize_t) argc) |
| 5643 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5644 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5645 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 5646 | i++; |
| 5647 | break; |
| 5648 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5649 | if (LocaleCompare("solarize",option+1) == 0) |
| 5650 | { |
| 5651 | if (*option == '+') |
| 5652 | break; |
| 5653 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5654 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5655 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5656 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5657 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5658 | break; |
| 5659 | } |
| 5660 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5661 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5662 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5663 | op; |
| 5664 | |
| 5665 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5666 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5667 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5668 | op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5669 | if (op < 0) |
| 5670 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5671 | argv[i]); |
| 5672 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5673 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5674 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5675 | break; |
| 5676 | } |
| 5677 | if (LocaleCompare("spread",option+1) == 0) |
| 5678 | { |
| 5679 | if (*option == '+') |
| 5680 | break; |
| 5681 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5682 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5683 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5684 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5685 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5686 | break; |
| 5687 | } |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5688 | if (LocaleCompare("statistic",option+1) == 0) |
| 5689 | { |
| 5690 | ssize_t |
| 5691 | op; |
| 5692 | |
| 5693 | if (*option == '+') |
| 5694 | break; |
| 5695 | i++; |
| 5696 | if (i == (ssize_t) argc) |
| 5697 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5698 | op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); |
cristy | 0834d64 | 2011-03-18 18:26:08 +0000 | [diff] [blame] | 5699 | if (op < 0) |
| 5700 | ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", |
| 5701 | argv[i]); |
| 5702 | i++; |
| 5703 | if (i == (ssize_t) (argc-1)) |
| 5704 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5705 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5706 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5707 | break; |
| 5708 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5709 | if (LocaleCompare("stretch",option+1) == 0) |
| 5710 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5711 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5712 | stretch; |
| 5713 | |
| 5714 | if (*option == '+') |
| 5715 | break; |
| 5716 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5717 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5718 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5719 | stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5720 | if (stretch < 0) |
| 5721 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5722 | argv[i]); |
| 5723 | break; |
| 5724 | } |
| 5725 | if (LocaleCompare("strip",option+1) == 0) |
| 5726 | break; |
| 5727 | if (LocaleCompare("stroke",option+1) == 0) |
| 5728 | { |
| 5729 | if (*option == '+') |
| 5730 | break; |
| 5731 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5732 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5733 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5734 | break; |
| 5735 | } |
| 5736 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 5737 | { |
| 5738 | if (*option == '+') |
| 5739 | break; |
| 5740 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5741 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5742 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5743 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5744 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5745 | break; |
| 5746 | } |
| 5747 | if (LocaleCompare("style",option+1) == 0) |
| 5748 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5749 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5750 | style; |
| 5751 | |
| 5752 | if (*option == '+') |
| 5753 | break; |
| 5754 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5755 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5756 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5757 | style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5758 | if (style < 0) |
| 5759 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 5760 | argv[i]); |
| 5761 | break; |
| 5762 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 5763 | if (LocaleCompare("swap",option+1) == 0) |
| 5764 | { |
| 5765 | if (*option == '+') |
| 5766 | break; |
| 5767 | i++; |
| 5768 | if (i == (ssize_t) (argc-1)) |
| 5769 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5770 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5771 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5772 | break; |
| 5773 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5774 | if (LocaleCompare("swirl",option+1) == 0) |
| 5775 | { |
| 5776 | if (*option == '+') |
| 5777 | break; |
| 5778 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5779 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5780 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5781 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5782 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5783 | break; |
| 5784 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 5785 | if (LocaleCompare("synchronize",option+1) == 0) |
| 5786 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5787 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5788 | } |
| 5789 | case 't': |
| 5790 | { |
| 5791 | if (LocaleCompare("taint",option+1) == 0) |
| 5792 | break; |
| 5793 | if (LocaleCompare("texture",option+1) == 0) |
| 5794 | { |
| 5795 | if (*option == '+') |
| 5796 | break; |
| 5797 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5798 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5799 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5800 | break; |
| 5801 | } |
| 5802 | if (LocaleCompare("tile",option+1) == 0) |
| 5803 | { |
| 5804 | if (*option == '+') |
| 5805 | break; |
| 5806 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5807 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5808 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5809 | break; |
| 5810 | } |
| 5811 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 5812 | { |
| 5813 | if (*option == '+') |
| 5814 | break; |
| 5815 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5816 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5817 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5818 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5819 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5820 | break; |
| 5821 | } |
| 5822 | if (LocaleCompare("tint",option+1) == 0) |
| 5823 | { |
| 5824 | if (*option == '+') |
| 5825 | break; |
| 5826 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5827 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5828 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5829 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5830 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5831 | break; |
| 5832 | } |
| 5833 | if (LocaleCompare("transform",option+1) == 0) |
| 5834 | break; |
| 5835 | if (LocaleCompare("transpose",option+1) == 0) |
| 5836 | break; |
| 5837 | if (LocaleCompare("transverse",option+1) == 0) |
| 5838 | break; |
| 5839 | if (LocaleCompare("threshold",option+1) == 0) |
| 5840 | { |
| 5841 | if (*option == '+') |
| 5842 | break; |
| 5843 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5844 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5845 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5846 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5847 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5848 | break; |
| 5849 | } |
| 5850 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 5851 | { |
| 5852 | if (*option == '+') |
| 5853 | break; |
| 5854 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5855 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5856 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5857 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5858 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5859 | break; |
| 5860 | } |
| 5861 | if (LocaleCompare("transparent",option+1) == 0) |
| 5862 | { |
| 5863 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5864 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5865 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5866 | break; |
| 5867 | } |
| 5868 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 5869 | { |
| 5870 | if (*option == '+') |
| 5871 | break; |
| 5872 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5873 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5874 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5875 | break; |
| 5876 | } |
| 5877 | if (LocaleCompare("treedepth",option+1) == 0) |
| 5878 | { |
| 5879 | if (*option == '+') |
| 5880 | break; |
| 5881 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5882 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5883 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5884 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5885 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5886 | break; |
| 5887 | } |
| 5888 | if (LocaleCompare("trim",option+1) == 0) |
| 5889 | break; |
| 5890 | if (LocaleCompare("type",option+1) == 0) |
| 5891 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5892 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5893 | type; |
| 5894 | |
| 5895 | if (*option == '+') |
| 5896 | break; |
| 5897 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5898 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5899 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5900 | type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5901 | if (type < 0) |
| 5902 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 5903 | argv[i]); |
| 5904 | break; |
| 5905 | } |
| 5906 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5907 | } |
| 5908 | case 'u': |
| 5909 | { |
| 5910 | if (LocaleCompare("undercolor",option+1) == 0) |
| 5911 | { |
| 5912 | if (*option == '+') |
| 5913 | break; |
| 5914 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5915 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5916 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5917 | break; |
| 5918 | } |
| 5919 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 5920 | break; |
| 5921 | if (LocaleCompare("units",option+1) == 0) |
| 5922 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5923 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5924 | units; |
| 5925 | |
| 5926 | if (*option == '+') |
| 5927 | break; |
| 5928 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5929 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5930 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5931 | units=ParseCommandOption(MagickResolutionOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5932 | argv[i]); |
| 5933 | if (units < 0) |
| 5934 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 5935 | argv[i]); |
| 5936 | break; |
| 5937 | } |
| 5938 | if (LocaleCompare("unsharp",option+1) == 0) |
| 5939 | { |
| 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 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5948 | } |
| 5949 | case 'v': |
| 5950 | { |
| 5951 | if (LocaleCompare("verbose",option+1) == 0) |
| 5952 | { |
| 5953 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 5954 | break; |
| 5955 | } |
| 5956 | if ((LocaleCompare("version",option+1) == 0) || |
| 5957 | (LocaleCompare("-version",option+1) == 0)) |
| 5958 | { |
| 5959 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5960 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 5961 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 5962 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5963 | break; |
| 5964 | } |
| 5965 | if (LocaleCompare("view",option+1) == 0) |
| 5966 | { |
| 5967 | if (*option == '+') |
| 5968 | break; |
| 5969 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5970 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5971 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5972 | break; |
| 5973 | } |
| 5974 | if (LocaleCompare("vignette",option+1) == 0) |
| 5975 | { |
| 5976 | if (*option == '+') |
| 5977 | break; |
| 5978 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5979 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5980 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5981 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5982 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5983 | break; |
| 5984 | } |
| 5985 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 5986 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5987 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5988 | method; |
| 5989 | |
| 5990 | if (*option == '+') |
| 5991 | break; |
| 5992 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5993 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5994 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 5995 | method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5996 | argv[i]); |
| 5997 | if (method < 0) |
| 5998 | ThrowMogrifyException(OptionError, |
| 5999 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 6000 | break; |
| 6001 | } |
| 6002 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6003 | } |
| 6004 | case 'w': |
| 6005 | { |
| 6006 | if (LocaleCompare("wave",option+1) == 0) |
| 6007 | { |
| 6008 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6009 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6010 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6011 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6012 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6013 | break; |
| 6014 | } |
| 6015 | if (LocaleCompare("weight",option+1) == 0) |
| 6016 | { |
| 6017 | if (*option == '+') |
| 6018 | break; |
| 6019 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6020 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6021 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6022 | break; |
| 6023 | } |
| 6024 | if (LocaleCompare("white-point",option+1) == 0) |
| 6025 | { |
| 6026 | if (*option == '+') |
| 6027 | break; |
| 6028 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6029 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6030 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6031 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6032 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6033 | break; |
| 6034 | } |
| 6035 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6036 | { |
| 6037 | if (*option == '+') |
| 6038 | break; |
| 6039 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6040 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6041 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6042 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6043 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6044 | break; |
| 6045 | } |
| 6046 | if (LocaleCompare("write",option+1) == 0) |
| 6047 | { |
| 6048 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6049 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6050 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6051 | break; |
| 6052 | } |
| 6053 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6054 | } |
| 6055 | case '?': |
| 6056 | break; |
| 6057 | default: |
| 6058 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6059 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6060 | fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & |
| 6061 | FireOptionFlag) == 0 ? MagickFalse : MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6062 | if (fire != MagickFalse) |
| 6063 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6064 | } |
| 6065 | if (k != 0) |
| 6066 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6067 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6068 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6069 | DestroyMogrify(); |
| 6070 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6071 | } |
| 6072 | |
| 6073 | /* |
| 6074 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6075 | % % |
| 6076 | % % |
| 6077 | % % |
| 6078 | + M o g r i f y I m a g e I n f o % |
| 6079 | % % |
| 6080 | % % |
| 6081 | % % |
| 6082 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6083 | % |
| 6084 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6085 | % prescribed by command line options. |
| 6086 | % |
| 6087 | % The format of the MogrifyImageInfo method is: |
| 6088 | % |
| 6089 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6090 | % const char **argv,ExceptionInfo *exception) |
| 6091 | % |
| 6092 | % A description of each parameter follows: |
| 6093 | % |
| 6094 | % o image_info: the image info.. |
| 6095 | % |
| 6096 | % o argc: Specifies a pointer to an integer describing the number of |
| 6097 | % elements in the argument vector. |
| 6098 | % |
| 6099 | % o argv: Specifies a pointer to a text array containing the command line |
| 6100 | % arguments. |
| 6101 | % |
| 6102 | % o exception: return any errors or warnings in this structure. |
| 6103 | % |
| 6104 | */ |
| 6105 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6106 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6107 | { |
| 6108 | const char |
| 6109 | *option; |
| 6110 | |
| 6111 | GeometryInfo |
| 6112 | geometry_info; |
| 6113 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6114 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6115 | count; |
| 6116 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6117 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6118 | i; |
| 6119 | |
| 6120 | /* |
| 6121 | Initialize method variables. |
| 6122 | */ |
| 6123 | assert(image_info != (ImageInfo *) NULL); |
| 6124 | assert(image_info->signature == MagickSignature); |
| 6125 | if (image_info->debug != MagickFalse) |
| 6126 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6127 | image_info->filename); |
| 6128 | if (argc < 0) |
| 6129 | return(MagickTrue); |
| 6130 | /* |
| 6131 | Set the image settings. |
| 6132 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6133 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6134 | { |
| 6135 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6136 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6137 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6138 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 6139 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6140 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6141 | break; |
| 6142 | switch (*(option+1)) |
| 6143 | { |
| 6144 | case 'a': |
| 6145 | { |
| 6146 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6147 | { |
| 6148 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6149 | break; |
| 6150 | } |
| 6151 | if (LocaleCompare("antialias",option+1) == 0) |
| 6152 | { |
| 6153 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6154 | break; |
| 6155 | } |
| 6156 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6157 | { |
| 6158 | if (*option == '+') |
| 6159 | { |
| 6160 | (void) DeleteImageOption(image_info,option+1); |
| 6161 | break; |
| 6162 | } |
| 6163 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6164 | break; |
| 6165 | } |
| 6166 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6167 | { |
| 6168 | if (*option == '+') |
| 6169 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6170 | else |
| 6171 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6172 | break; |
| 6173 | } |
| 6174 | break; |
| 6175 | } |
| 6176 | case 'b': |
| 6177 | { |
| 6178 | if (LocaleCompare("background",option+1) == 0) |
| 6179 | { |
| 6180 | if (*option == '+') |
| 6181 | { |
| 6182 | (void) DeleteImageOption(image_info,option+1); |
| 6183 | (void) QueryColorDatabase(BackgroundColor, |
| 6184 | &image_info->background_color,exception); |
| 6185 | break; |
| 6186 | } |
| 6187 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6188 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6189 | exception); |
| 6190 | break; |
| 6191 | } |
| 6192 | if (LocaleCompare("bias",option+1) == 0) |
| 6193 | { |
| 6194 | if (*option == '+') |
| 6195 | { |
| 6196 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6197 | break; |
| 6198 | } |
| 6199 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6200 | break; |
| 6201 | } |
| 6202 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6203 | { |
| 6204 | if (*option == '+') |
| 6205 | { |
| 6206 | (void) SetImageOption(image_info,option+1,"false"); |
| 6207 | break; |
| 6208 | } |
| 6209 | (void) SetImageOption(image_info,option+1,"true"); |
| 6210 | break; |
| 6211 | } |
| 6212 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6213 | { |
| 6214 | if (*option == '+') |
| 6215 | { |
| 6216 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6217 | break; |
| 6218 | } |
| 6219 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6220 | break; |
| 6221 | } |
| 6222 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6223 | { |
| 6224 | if (*option == '+') |
| 6225 | { |
| 6226 | (void) DeleteImageOption(image_info,option+1); |
| 6227 | (void) QueryColorDatabase(BorderColor,&image_info->border_color, |
| 6228 | exception); |
| 6229 | break; |
| 6230 | } |
| 6231 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6232 | exception); |
| 6233 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6234 | break; |
| 6235 | } |
| 6236 | if (LocaleCompare("box",option+1) == 0) |
| 6237 | { |
| 6238 | if (*option == '+') |
| 6239 | { |
| 6240 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6241 | break; |
| 6242 | } |
| 6243 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6244 | break; |
| 6245 | } |
| 6246 | break; |
| 6247 | } |
| 6248 | case 'c': |
| 6249 | { |
| 6250 | if (LocaleCompare("cache",option+1) == 0) |
| 6251 | { |
| 6252 | MagickSizeType |
| 6253 | limit; |
| 6254 | |
| 6255 | limit=MagickResourceInfinity; |
| 6256 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6257 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6258 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6259 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6260 | break; |
| 6261 | } |
| 6262 | if (LocaleCompare("caption",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("channel",option+1) == 0) |
| 6273 | { |
| 6274 | if (*option == '+') |
| 6275 | { |
| 6276 | image_info->channel=DefaultChannels; |
| 6277 | break; |
| 6278 | } |
| 6279 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6280 | break; |
| 6281 | } |
| 6282 | if (LocaleCompare("colors",option+1) == 0) |
| 6283 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6284 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6285 | break; |
| 6286 | } |
| 6287 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6288 | { |
| 6289 | if (*option == '+') |
| 6290 | { |
| 6291 | image_info->colorspace=UndefinedColorspace; |
| 6292 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6293 | break; |
| 6294 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6295 | image_info->colorspace=(ColorspaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6296 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6297 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6298 | break; |
| 6299 | } |
| 6300 | if (LocaleCompare("compress",option+1) == 0) |
| 6301 | { |
| 6302 | if (*option == '+') |
| 6303 | { |
| 6304 | image_info->compression=UndefinedCompression; |
| 6305 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6306 | break; |
| 6307 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6308 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6309 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6310 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6311 | break; |
| 6312 | } |
| 6313 | if (LocaleCompare("comment",option+1) == 0) |
| 6314 | { |
| 6315 | if (*option == '+') |
| 6316 | { |
| 6317 | (void) DeleteImageOption(image_info,option+1); |
| 6318 | break; |
| 6319 | } |
| 6320 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6321 | break; |
| 6322 | } |
| 6323 | if (LocaleCompare("compose",option+1) == 0) |
| 6324 | { |
| 6325 | if (*option == '+') |
| 6326 | { |
| 6327 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6328 | break; |
| 6329 | } |
| 6330 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6331 | break; |
| 6332 | } |
| 6333 | if (LocaleCompare("compress",option+1) == 0) |
| 6334 | { |
| 6335 | if (*option == '+') |
| 6336 | { |
| 6337 | image_info->compression=UndefinedCompression; |
| 6338 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6339 | break; |
| 6340 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6341 | image_info->compression=(CompressionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6342 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6343 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6344 | break; |
| 6345 | } |
| 6346 | break; |
| 6347 | } |
| 6348 | case 'd': |
| 6349 | { |
| 6350 | if (LocaleCompare("debug",option+1) == 0) |
| 6351 | { |
| 6352 | if (*option == '+') |
| 6353 | (void) SetLogEventMask("none"); |
| 6354 | else |
| 6355 | (void) SetLogEventMask(argv[i+1]); |
| 6356 | image_info->debug=IsEventLogging(); |
| 6357 | break; |
| 6358 | } |
| 6359 | if (LocaleCompare("define",option+1) == 0) |
| 6360 | { |
| 6361 | if (*option == '+') |
| 6362 | { |
| 6363 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6364 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6365 | else |
| 6366 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6367 | break; |
| 6368 | } |
| 6369 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6370 | { |
| 6371 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6372 | exception); |
| 6373 | break; |
| 6374 | } |
| 6375 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6376 | break; |
| 6377 | } |
| 6378 | if (LocaleCompare("delay",option+1) == 0) |
| 6379 | { |
| 6380 | if (*option == '+') |
| 6381 | { |
| 6382 | (void) SetImageOption(image_info,option+1,"0"); |
| 6383 | break; |
| 6384 | } |
| 6385 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6386 | break; |
| 6387 | } |
| 6388 | if (LocaleCompare("density",option+1) == 0) |
| 6389 | { |
| 6390 | /* |
| 6391 | Set image density. |
| 6392 | */ |
| 6393 | if (*option == '+') |
| 6394 | { |
| 6395 | if (image_info->density != (char *) NULL) |
| 6396 | image_info->density=DestroyString(image_info->density); |
| 6397 | (void) SetImageOption(image_info,option+1,"72"); |
| 6398 | break; |
| 6399 | } |
| 6400 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6401 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6402 | break; |
| 6403 | } |
| 6404 | if (LocaleCompare("depth",option+1) == 0) |
| 6405 | { |
| 6406 | if (*option == '+') |
| 6407 | { |
| 6408 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6409 | break; |
| 6410 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6411 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6412 | break; |
| 6413 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6414 | if (LocaleCompare("direction",option+1) == 0) |
| 6415 | { |
| 6416 | if (*option == '+') |
| 6417 | { |
| 6418 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6419 | break; |
| 6420 | } |
| 6421 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6422 | break; |
| 6423 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6424 | if (LocaleCompare("display",option+1) == 0) |
| 6425 | { |
| 6426 | if (*option == '+') |
| 6427 | { |
| 6428 | if (image_info->server_name != (char *) NULL) |
| 6429 | image_info->server_name=DestroyString( |
| 6430 | image_info->server_name); |
| 6431 | break; |
| 6432 | } |
| 6433 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6434 | break; |
| 6435 | } |
| 6436 | if (LocaleCompare("dispose",option+1) == 0) |
| 6437 | { |
| 6438 | if (*option == '+') |
| 6439 | { |
| 6440 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6441 | break; |
| 6442 | } |
| 6443 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6444 | break; |
| 6445 | } |
| 6446 | if (LocaleCompare("dither",option+1) == 0) |
| 6447 | { |
| 6448 | if (*option == '+') |
| 6449 | { |
| 6450 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6451 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6452 | break; |
| 6453 | } |
| 6454 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6455 | image_info->dither=MagickTrue; |
| 6456 | break; |
| 6457 | } |
| 6458 | break; |
| 6459 | } |
| 6460 | case 'e': |
| 6461 | { |
| 6462 | if (LocaleCompare("encoding",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("endian",option+1) == 0) |
| 6473 | { |
| 6474 | if (*option == '+') |
| 6475 | { |
| 6476 | image_info->endian=UndefinedEndian; |
| 6477 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6478 | break; |
| 6479 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6480 | image_info->endian=(EndianType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6481 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6482 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6483 | break; |
| 6484 | } |
| 6485 | if (LocaleCompare("extract",option+1) == 0) |
| 6486 | { |
| 6487 | /* |
| 6488 | Set image extract geometry. |
| 6489 | */ |
| 6490 | if (*option == '+') |
| 6491 | { |
| 6492 | if (image_info->extract != (char *) NULL) |
| 6493 | image_info->extract=DestroyString(image_info->extract); |
| 6494 | break; |
| 6495 | } |
| 6496 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6497 | break; |
| 6498 | } |
| 6499 | break; |
| 6500 | } |
| 6501 | case 'f': |
| 6502 | { |
| 6503 | if (LocaleCompare("fill",option+1) == 0) |
| 6504 | { |
| 6505 | if (*option == '+') |
| 6506 | { |
| 6507 | (void) SetImageOption(image_info,option+1,"none"); |
| 6508 | break; |
| 6509 | } |
| 6510 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6511 | break; |
| 6512 | } |
| 6513 | if (LocaleCompare("filter",option+1) == 0) |
| 6514 | { |
| 6515 | if (*option == '+') |
| 6516 | { |
| 6517 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6518 | break; |
| 6519 | } |
| 6520 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6521 | break; |
| 6522 | } |
| 6523 | if (LocaleCompare("font",option+1) == 0) |
| 6524 | { |
| 6525 | if (*option == '+') |
| 6526 | { |
| 6527 | if (image_info->font != (char *) NULL) |
| 6528 | image_info->font=DestroyString(image_info->font); |
| 6529 | break; |
| 6530 | } |
| 6531 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6532 | break; |
| 6533 | } |
| 6534 | if (LocaleCompare("format",option+1) == 0) |
| 6535 | { |
| 6536 | register const char |
| 6537 | *q; |
| 6538 | |
| 6539 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
cristy | 9ed8567 | 2011-03-02 00:19:13 +0000 | [diff] [blame] | 6540 | if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6541 | image_info->ping=MagickFalse; |
| 6542 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6543 | break; |
| 6544 | } |
| 6545 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6546 | { |
| 6547 | if (*option == '+') |
| 6548 | { |
| 6549 | image_info->fuzz=0.0; |
| 6550 | (void) SetImageOption(image_info,option+1,"0"); |
| 6551 | break; |
| 6552 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6553 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6554 | 1.0); |
| 6555 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6556 | break; |
| 6557 | } |
| 6558 | break; |
| 6559 | } |
| 6560 | case 'g': |
| 6561 | { |
| 6562 | if (LocaleCompare("gravity",option+1) == 0) |
| 6563 | { |
| 6564 | if (*option == '+') |
| 6565 | { |
| 6566 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6567 | break; |
| 6568 | } |
| 6569 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6570 | break; |
| 6571 | } |
| 6572 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6573 | { |
| 6574 | if (*option == '+') |
| 6575 | { |
| 6576 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6577 | break; |
| 6578 | } |
| 6579 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6580 | break; |
| 6581 | } |
| 6582 | break; |
| 6583 | } |
| 6584 | case 'i': |
| 6585 | { |
| 6586 | if (LocaleCompare("intent",option+1) == 0) |
| 6587 | { |
| 6588 | if (*option == '+') |
| 6589 | { |
| 6590 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6591 | break; |
| 6592 | } |
| 6593 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6594 | break; |
| 6595 | } |
| 6596 | if (LocaleCompare("interlace",option+1) == 0) |
| 6597 | { |
| 6598 | if (*option == '+') |
| 6599 | { |
| 6600 | image_info->interlace=UndefinedInterlace; |
| 6601 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6602 | break; |
| 6603 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6604 | image_info->interlace=(InterlaceType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6605 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6606 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6607 | break; |
| 6608 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6609 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6610 | { |
| 6611 | if (*option == '+') |
| 6612 | { |
| 6613 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6614 | break; |
| 6615 | } |
| 6616 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6617 | break; |
| 6618 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6619 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6620 | { |
| 6621 | if (*option == '+') |
| 6622 | { |
| 6623 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6624 | break; |
| 6625 | } |
| 6626 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6627 | break; |
| 6628 | } |
| 6629 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6630 | { |
| 6631 | if (*option == '+') |
| 6632 | { |
| 6633 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6634 | break; |
| 6635 | } |
| 6636 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6637 | break; |
| 6638 | } |
| 6639 | break; |
| 6640 | } |
| 6641 | case 'k': |
| 6642 | { |
| 6643 | if (LocaleCompare("kerning",option+1) == 0) |
| 6644 | { |
| 6645 | if (*option == '+') |
| 6646 | { |
| 6647 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6648 | break; |
| 6649 | } |
| 6650 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6651 | break; |
| 6652 | } |
| 6653 | break; |
| 6654 | } |
| 6655 | case 'l': |
| 6656 | { |
| 6657 | if (LocaleCompare("label",option+1) == 0) |
| 6658 | { |
| 6659 | if (*option == '+') |
| 6660 | { |
| 6661 | (void) DeleteImageOption(image_info,option+1); |
| 6662 | break; |
| 6663 | } |
| 6664 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6665 | break; |
| 6666 | } |
| 6667 | if (LocaleCompare("limit",option+1) == 0) |
| 6668 | { |
| 6669 | MagickSizeType |
| 6670 | limit; |
| 6671 | |
| 6672 | ResourceType |
| 6673 | type; |
| 6674 | |
| 6675 | if (*option == '+') |
| 6676 | break; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6677 | type=(ResourceType) ParseCommandOption(MagickResourceOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6678 | MagickFalse,argv[i+1]); |
| 6679 | limit=MagickResourceInfinity; |
| 6680 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6681 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6682 | (void) SetMagickResourceLimit(type,limit); |
| 6683 | break; |
| 6684 | } |
| 6685 | if (LocaleCompare("list",option+1) == 0) |
| 6686 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6687 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6688 | list; |
| 6689 | |
| 6690 | /* |
| 6691 | Display configuration list. |
| 6692 | */ |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6693 | list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6694 | switch (list) |
| 6695 | { |
| 6696 | case MagickCoderOptions: |
| 6697 | { |
| 6698 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6699 | break; |
| 6700 | } |
| 6701 | case MagickColorOptions: |
| 6702 | { |
| 6703 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6704 | break; |
| 6705 | } |
| 6706 | case MagickConfigureOptions: |
| 6707 | { |
| 6708 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6709 | break; |
| 6710 | } |
| 6711 | case MagickDelegateOptions: |
| 6712 | { |
| 6713 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6714 | break; |
| 6715 | } |
| 6716 | case MagickFontOptions: |
| 6717 | { |
| 6718 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 6719 | break; |
| 6720 | } |
| 6721 | case MagickFormatOptions: |
| 6722 | { |
| 6723 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 6724 | break; |
| 6725 | } |
| 6726 | case MagickLocaleOptions: |
| 6727 | { |
| 6728 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 6729 | break; |
| 6730 | } |
| 6731 | case MagickLogOptions: |
| 6732 | { |
| 6733 | (void) ListLogInfo((FILE *) NULL,exception); |
| 6734 | break; |
| 6735 | } |
| 6736 | case MagickMagicOptions: |
| 6737 | { |
| 6738 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 6739 | break; |
| 6740 | } |
| 6741 | case MagickMimeOptions: |
| 6742 | { |
| 6743 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 6744 | break; |
| 6745 | } |
| 6746 | case MagickModuleOptions: |
| 6747 | { |
| 6748 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 6749 | break; |
| 6750 | } |
| 6751 | case MagickPolicyOptions: |
| 6752 | { |
| 6753 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 6754 | break; |
| 6755 | } |
| 6756 | case MagickResourceOptions: |
| 6757 | { |
| 6758 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 6759 | break; |
| 6760 | } |
| 6761 | case MagickThresholdOptions: |
| 6762 | { |
| 6763 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 6764 | break; |
| 6765 | } |
| 6766 | default: |
| 6767 | { |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6768 | (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6769 | exception); |
| 6770 | break; |
| 6771 | } |
| 6772 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 6773 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6774 | } |
| 6775 | if (LocaleCompare("log",option+1) == 0) |
| 6776 | { |
| 6777 | if (*option == '+') |
| 6778 | break; |
| 6779 | (void) SetLogFormat(argv[i+1]); |
| 6780 | break; |
| 6781 | } |
| 6782 | if (LocaleCompare("loop",option+1) == 0) |
| 6783 | { |
| 6784 | if (*option == '+') |
| 6785 | { |
| 6786 | (void) SetImageOption(image_info,option+1,"0"); |
| 6787 | break; |
| 6788 | } |
| 6789 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6790 | break; |
| 6791 | } |
| 6792 | break; |
| 6793 | } |
| 6794 | case 'm': |
| 6795 | { |
| 6796 | if (LocaleCompare("matte",option+1) == 0) |
| 6797 | { |
| 6798 | if (*option == '+') |
| 6799 | { |
| 6800 | (void) SetImageOption(image_info,option+1,"false"); |
| 6801 | break; |
| 6802 | } |
| 6803 | (void) SetImageOption(image_info,option+1,"true"); |
| 6804 | break; |
| 6805 | } |
| 6806 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 6807 | { |
| 6808 | if (*option == '+') |
| 6809 | { |
| 6810 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6811 | (void) QueryColorDatabase(MatteColor,&image_info->matte_color, |
| 6812 | exception); |
| 6813 | break; |
| 6814 | } |
| 6815 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6816 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 6817 | exception); |
| 6818 | break; |
| 6819 | } |
| 6820 | if (LocaleCompare("monitor",option+1) == 0) |
| 6821 | { |
| 6822 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 6823 | (void *) NULL); |
| 6824 | break; |
| 6825 | } |
| 6826 | if (LocaleCompare("monochrome",option+1) == 0) |
| 6827 | { |
| 6828 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 6829 | break; |
| 6830 | } |
| 6831 | break; |
| 6832 | } |
| 6833 | case 'o': |
| 6834 | { |
| 6835 | if (LocaleCompare("orient",option+1) == 0) |
| 6836 | { |
| 6837 | if (*option == '+') |
| 6838 | { |
| 6839 | image_info->orientation=UndefinedOrientation; |
| 6840 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6841 | break; |
| 6842 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6843 | image_info->orientation=(OrientationType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6844 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 6845 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6846 | break; |
| 6847 | } |
| 6848 | } |
| 6849 | case 'p': |
| 6850 | { |
| 6851 | if (LocaleCompare("page",option+1) == 0) |
| 6852 | { |
| 6853 | char |
| 6854 | *canonical_page, |
| 6855 | page[MaxTextExtent]; |
| 6856 | |
| 6857 | const char |
| 6858 | *image_option; |
| 6859 | |
| 6860 | MagickStatusType |
| 6861 | flags; |
| 6862 | |
| 6863 | RectangleInfo |
| 6864 | geometry; |
| 6865 | |
| 6866 | if (*option == '+') |
| 6867 | { |
| 6868 | (void) DeleteImageOption(image_info,option+1); |
| 6869 | (void) CloneString(&image_info->page,(char *) NULL); |
| 6870 | break; |
| 6871 | } |
| 6872 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 6873 | image_option=GetImageOption(image_info,"page"); |
| 6874 | if (image_option != (const char *) NULL) |
| 6875 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 6876 | canonical_page=GetPageGeometry(argv[i+1]); |
| 6877 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 6878 | canonical_page=DestroyString(canonical_page); |
| 6879 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6880 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6881 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 6882 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 6883 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 6884 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6885 | (void) SetImageOption(image_info,option+1,page); |
| 6886 | (void) CloneString(&image_info->page,page); |
| 6887 | break; |
| 6888 | } |
| 6889 | if (LocaleCompare("pen",option+1) == 0) |
| 6890 | { |
| 6891 | if (*option == '+') |
| 6892 | { |
| 6893 | (void) SetImageOption(image_info,option+1,"none"); |
| 6894 | break; |
| 6895 | } |
| 6896 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6897 | break; |
| 6898 | } |
| 6899 | if (LocaleCompare("ping",option+1) == 0) |
| 6900 | { |
| 6901 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 6902 | break; |
| 6903 | } |
| 6904 | if (LocaleCompare("pointsize",option+1) == 0) |
| 6905 | { |
| 6906 | if (*option == '+') |
| 6907 | geometry_info.rho=0.0; |
| 6908 | else |
| 6909 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 6910 | image_info->pointsize=geometry_info.rho; |
| 6911 | break; |
| 6912 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6913 | if (LocaleCompare("precision",option+1) == 0) |
| 6914 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 6915 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 6916 | break; |
| 6917 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6918 | if (LocaleCompare("preview",option+1) == 0) |
| 6919 | { |
| 6920 | /* |
| 6921 | Preview image. |
| 6922 | */ |
| 6923 | if (*option == '+') |
| 6924 | { |
| 6925 | image_info->preview_type=UndefinedPreview; |
| 6926 | break; |
| 6927 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 6928 | image_info->preview_type=(PreviewType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6929 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 6930 | break; |
| 6931 | } |
| 6932 | break; |
| 6933 | } |
| 6934 | case 'q': |
| 6935 | { |
| 6936 | if (LocaleCompare("quality",option+1) == 0) |
| 6937 | { |
| 6938 | /* |
| 6939 | Set image compression quality. |
| 6940 | */ |
| 6941 | if (*option == '+') |
| 6942 | { |
| 6943 | image_info->quality=UndefinedCompressionQuality; |
| 6944 | (void) SetImageOption(image_info,option+1,"0"); |
| 6945 | break; |
| 6946 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6947 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6948 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6949 | break; |
| 6950 | } |
| 6951 | if (LocaleCompare("quiet",option+1) == 0) |
| 6952 | { |
| 6953 | static WarningHandler |
| 6954 | warning_handler = (WarningHandler) NULL; |
| 6955 | |
| 6956 | if (*option == '+') |
| 6957 | { |
| 6958 | /* |
| 6959 | Restore error or warning messages. |
| 6960 | */ |
| 6961 | warning_handler=SetWarningHandler(warning_handler); |
| 6962 | break; |
| 6963 | } |
| 6964 | /* |
| 6965 | Suppress error or warning messages. |
| 6966 | */ |
| 6967 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 6968 | break; |
| 6969 | } |
| 6970 | break; |
| 6971 | } |
| 6972 | case 'r': |
| 6973 | { |
| 6974 | if (LocaleCompare("red-primary",option+1) == 0) |
| 6975 | { |
| 6976 | if (*option == '+') |
| 6977 | { |
| 6978 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6979 | break; |
| 6980 | } |
| 6981 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6982 | break; |
| 6983 | } |
| 6984 | break; |
| 6985 | } |
| 6986 | case 's': |
| 6987 | { |
| 6988 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 6989 | { |
| 6990 | /* |
| 6991 | Set image sampling factor. |
| 6992 | */ |
| 6993 | if (*option == '+') |
| 6994 | { |
| 6995 | if (image_info->sampling_factor != (char *) NULL) |
| 6996 | image_info->sampling_factor=DestroyString( |
| 6997 | image_info->sampling_factor); |
| 6998 | break; |
| 6999 | } |
| 7000 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 7001 | break; |
| 7002 | } |
| 7003 | if (LocaleCompare("scene",option+1) == 0) |
| 7004 | { |
| 7005 | /* |
| 7006 | Set image scene. |
| 7007 | */ |
| 7008 | if (*option == '+') |
| 7009 | { |
| 7010 | image_info->scene=0; |
| 7011 | (void) SetImageOption(image_info,option+1,"0"); |
| 7012 | break; |
| 7013 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7014 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7015 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7016 | break; |
| 7017 | } |
| 7018 | if (LocaleCompare("seed",option+1) == 0) |
| 7019 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7020 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7021 | seed; |
| 7022 | |
| 7023 | if (*option == '+') |
| 7024 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7025 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7026 | SeedPseudoRandomGenerator(seed); |
| 7027 | break; |
| 7028 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7029 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7030 | SeedPseudoRandomGenerator(seed); |
| 7031 | break; |
| 7032 | } |
| 7033 | if (LocaleCompare("size",option+1) == 0) |
| 7034 | { |
| 7035 | if (*option == '+') |
| 7036 | { |
| 7037 | if (image_info->size != (char *) NULL) |
| 7038 | image_info->size=DestroyString(image_info->size); |
| 7039 | break; |
| 7040 | } |
| 7041 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7042 | break; |
| 7043 | } |
| 7044 | if (LocaleCompare("stroke",option+1) == 0) |
| 7045 | { |
| 7046 | if (*option == '+') |
| 7047 | { |
| 7048 | (void) SetImageOption(image_info,option+1,"none"); |
| 7049 | break; |
| 7050 | } |
| 7051 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7052 | break; |
| 7053 | } |
| 7054 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7055 | { |
| 7056 | if (*option == '+') |
| 7057 | { |
| 7058 | (void) SetImageOption(image_info,option+1,"0"); |
| 7059 | break; |
| 7060 | } |
| 7061 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7062 | break; |
| 7063 | } |
cristy | d9a2919 | 2010-10-16 16:49:53 +0000 | [diff] [blame] | 7064 | if (LocaleCompare("synchronize",option+1) == 0) |
| 7065 | { |
| 7066 | if (*option == '+') |
| 7067 | { |
| 7068 | image_info->synchronize=MagickFalse; |
| 7069 | break; |
| 7070 | } |
| 7071 | image_info->synchronize=MagickTrue; |
| 7072 | break; |
| 7073 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7074 | break; |
| 7075 | } |
| 7076 | case 't': |
| 7077 | { |
| 7078 | if (LocaleCompare("taint",option+1) == 0) |
| 7079 | { |
| 7080 | if (*option == '+') |
| 7081 | { |
| 7082 | (void) SetImageOption(image_info,option+1,"false"); |
| 7083 | break; |
| 7084 | } |
| 7085 | (void) SetImageOption(image_info,option+1,"true"); |
| 7086 | break; |
| 7087 | } |
| 7088 | if (LocaleCompare("texture",option+1) == 0) |
| 7089 | { |
| 7090 | if (*option == '+') |
| 7091 | { |
| 7092 | if (image_info->texture != (char *) NULL) |
| 7093 | image_info->texture=DestroyString(image_info->texture); |
| 7094 | break; |
| 7095 | } |
| 7096 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7097 | break; |
| 7098 | } |
| 7099 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7100 | { |
| 7101 | if (*option == '+') |
| 7102 | { |
| 7103 | (void) SetImageOption(image_info,option+1,"0"); |
| 7104 | break; |
| 7105 | } |
| 7106 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7107 | break; |
| 7108 | } |
| 7109 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7110 | { |
| 7111 | if (*option == '+') |
| 7112 | { |
| 7113 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7114 | (void) SetImageOption(image_info,option+1,"none"); |
| 7115 | break; |
| 7116 | } |
| 7117 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7118 | exception); |
| 7119 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7120 | break; |
| 7121 | } |
| 7122 | if (LocaleCompare("type",option+1) == 0) |
| 7123 | { |
| 7124 | if (*option == '+') |
| 7125 | { |
cristy | 5f1c1ff | 2010-12-23 21:38:06 +0000 | [diff] [blame] | 7126 | image_info->type=UndefinedType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7127 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7128 | break; |
| 7129 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7130 | image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7131 | MagickFalse,argv[i+1]); |
| 7132 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7133 | break; |
| 7134 | } |
| 7135 | break; |
| 7136 | } |
| 7137 | case 'u': |
| 7138 | { |
| 7139 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7140 | { |
| 7141 | if (*option == '+') |
| 7142 | { |
| 7143 | (void) DeleteImageOption(image_info,option+1); |
| 7144 | break; |
| 7145 | } |
| 7146 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7147 | break; |
| 7148 | } |
| 7149 | if (LocaleCompare("units",option+1) == 0) |
| 7150 | { |
| 7151 | if (*option == '+') |
| 7152 | { |
| 7153 | image_info->units=UndefinedResolution; |
| 7154 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7155 | break; |
| 7156 | } |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7157 | image_info->units=(ResolutionType) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7158 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7159 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7160 | break; |
| 7161 | } |
| 7162 | break; |
| 7163 | } |
| 7164 | case 'v': |
| 7165 | { |
| 7166 | if (LocaleCompare("verbose",option+1) == 0) |
| 7167 | { |
| 7168 | if (*option == '+') |
| 7169 | { |
| 7170 | image_info->verbose=MagickFalse; |
| 7171 | break; |
| 7172 | } |
| 7173 | image_info->verbose=MagickTrue; |
| 7174 | image_info->ping=MagickFalse; |
| 7175 | break; |
| 7176 | } |
| 7177 | if (LocaleCompare("view",option+1) == 0) |
| 7178 | { |
| 7179 | if (*option == '+') |
| 7180 | { |
| 7181 | if (image_info->view != (char *) NULL) |
| 7182 | image_info->view=DestroyString(image_info->view); |
| 7183 | break; |
| 7184 | } |
| 7185 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7186 | break; |
| 7187 | } |
| 7188 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7189 | { |
| 7190 | if (*option == '+') |
| 7191 | { |
| 7192 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7193 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7194 | break; |
| 7195 | } |
| 7196 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7197 | ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7198 | argv[i+1]); |
| 7199 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7200 | break; |
| 7201 | } |
| 7202 | break; |
| 7203 | } |
| 7204 | case 'w': |
| 7205 | { |
| 7206 | if (LocaleCompare("white-point",option+1) == 0) |
| 7207 | { |
| 7208 | if (*option == '+') |
| 7209 | { |
| 7210 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7211 | break; |
| 7212 | } |
| 7213 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7214 | break; |
| 7215 | } |
| 7216 | break; |
| 7217 | } |
| 7218 | default: |
| 7219 | break; |
| 7220 | } |
| 7221 | i+=count; |
| 7222 | } |
| 7223 | return(MagickTrue); |
| 7224 | } |
| 7225 | |
| 7226 | /* |
| 7227 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7228 | % % |
| 7229 | % % |
| 7230 | % % |
| 7231 | + M o g r i f y I m a g e L i s t % |
| 7232 | % % |
| 7233 | % % |
| 7234 | % % |
| 7235 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7236 | % |
| 7237 | % MogrifyImageList() applies any command line options that might affect the |
| 7238 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7239 | % |
| 7240 | % The format of the MogrifyImage method is: |
| 7241 | % |
| 7242 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7243 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7244 | % |
| 7245 | % A description of each parameter follows: |
| 7246 | % |
| 7247 | % o image_info: the image info.. |
| 7248 | % |
| 7249 | % o argc: Specifies a pointer to an integer describing the number of |
| 7250 | % elements in the argument vector. |
| 7251 | % |
| 7252 | % o argv: Specifies a pointer to a text array containing the command line |
| 7253 | % arguments. |
| 7254 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7255 | % o images: pointer to pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7256 | % |
| 7257 | % o exception: return any errors or warnings in this structure. |
| 7258 | % |
| 7259 | */ |
| 7260 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7261 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7262 | { |
| 7263 | ChannelType |
| 7264 | channel; |
| 7265 | |
| 7266 | const char |
| 7267 | *option; |
| 7268 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7269 | ImageInfo |
| 7270 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7271 | |
| 7272 | MagickStatusType |
| 7273 | status; |
| 7274 | |
| 7275 | QuantizeInfo |
| 7276 | *quantize_info; |
| 7277 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7278 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7279 | i; |
| 7280 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7281 | ssize_t |
| 7282 | count, |
| 7283 | index; |
| 7284 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7285 | /* |
| 7286 | Apply options to the image list. |
| 7287 | */ |
| 7288 | assert(image_info != (ImageInfo *) NULL); |
| 7289 | assert(image_info->signature == MagickSignature); |
| 7290 | assert(images != (Image **) NULL); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7291 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7292 | assert((*images)->signature == MagickSignature); |
| 7293 | if ((*images)->debug != MagickFalse) |
| 7294 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7295 | (*images)->filename); |
| 7296 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7297 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7298 | mogrify_info=CloneImageInfo(image_info); |
| 7299 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 7300 | channel=mogrify_info->channel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7301 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7302 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7303 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7304 | if (*images == (Image *) NULL) |
| 7305 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7306 | option=argv[i]; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7307 | if (IsCommandOption(option) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7308 | continue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7309 | count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 7310 | count=MagickMax(count,0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7311 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7312 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7313 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7314 | switch (*(option+1)) |
| 7315 | { |
| 7316 | case 'a': |
| 7317 | { |
| 7318 | if (LocaleCompare("affinity",option+1) == 0) |
| 7319 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7320 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7321 | if (*option == '+') |
| 7322 | { |
| 7323 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7324 | InheritException(exception,&(*images)->exception); |
| 7325 | break; |
| 7326 | } |
| 7327 | i++; |
| 7328 | break; |
| 7329 | } |
| 7330 | if (LocaleCompare("append",option+1) == 0) |
| 7331 | { |
| 7332 | Image |
| 7333 | *append_image; |
| 7334 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7335 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7336 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7337 | MagickFalse,exception); |
| 7338 | if (append_image == (Image *) NULL) |
| 7339 | { |
| 7340 | status=MagickFalse; |
| 7341 | break; |
| 7342 | } |
| 7343 | *images=DestroyImageList(*images); |
| 7344 | *images=append_image; |
| 7345 | break; |
| 7346 | } |
| 7347 | if (LocaleCompare("average",option+1) == 0) |
| 7348 | { |
| 7349 | Image |
| 7350 | *average_image; |
| 7351 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7352 | /* |
| 7353 | Average an image sequence (deprecated). |
| 7354 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7355 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7356 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7357 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7358 | if (average_image == (Image *) NULL) |
| 7359 | { |
| 7360 | status=MagickFalse; |
| 7361 | break; |
| 7362 | } |
| 7363 | *images=DestroyImageList(*images); |
| 7364 | *images=average_image; |
| 7365 | break; |
| 7366 | } |
| 7367 | break; |
| 7368 | } |
| 7369 | case 'c': |
| 7370 | { |
| 7371 | if (LocaleCompare("channel",option+1) == 0) |
| 7372 | { |
| 7373 | if (*option == '+') |
| 7374 | { |
| 7375 | channel=DefaultChannels; |
| 7376 | break; |
| 7377 | } |
| 7378 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 7379 | break; |
| 7380 | } |
| 7381 | if (LocaleCompare("clut",option+1) == 0) |
| 7382 | { |
| 7383 | Image |
| 7384 | *clut_image, |
| 7385 | *image; |
| 7386 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7387 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7388 | image=RemoveFirstImageFromList(images); |
| 7389 | clut_image=RemoveFirstImageFromList(images); |
| 7390 | if (clut_image == (Image *) NULL) |
| 7391 | { |
| 7392 | status=MagickFalse; |
| 7393 | break; |
| 7394 | } |
| 7395 | (void) ClutImageChannel(image,channel,clut_image); |
| 7396 | clut_image=DestroyImage(clut_image); |
| 7397 | InheritException(exception,&image->exception); |
| 7398 | *images=DestroyImageList(*images); |
| 7399 | *images=image; |
| 7400 | break; |
| 7401 | } |
| 7402 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7403 | { |
| 7404 | Image |
| 7405 | *coalesce_image; |
| 7406 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7407 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7408 | coalesce_image=CoalesceImages(*images,exception); |
| 7409 | if (coalesce_image == (Image *) NULL) |
| 7410 | { |
| 7411 | status=MagickFalse; |
| 7412 | break; |
| 7413 | } |
| 7414 | *images=DestroyImageList(*images); |
| 7415 | *images=coalesce_image; |
| 7416 | break; |
| 7417 | } |
| 7418 | if (LocaleCompare("combine",option+1) == 0) |
| 7419 | { |
| 7420 | Image |
| 7421 | *combine_image; |
| 7422 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7423 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7424 | combine_image=CombineImages(*images,channel,exception); |
| 7425 | if (combine_image == (Image *) NULL) |
| 7426 | { |
| 7427 | status=MagickFalse; |
| 7428 | break; |
| 7429 | } |
| 7430 | *images=DestroyImageList(*images); |
| 7431 | *images=combine_image; |
| 7432 | break; |
| 7433 | } |
| 7434 | if (LocaleCompare("composite",option+1) == 0) |
| 7435 | { |
| 7436 | Image |
| 7437 | *mask_image, |
| 7438 | *composite_image, |
| 7439 | *image; |
| 7440 | |
| 7441 | RectangleInfo |
| 7442 | geometry; |
| 7443 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7444 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7445 | image=RemoveFirstImageFromList(images); |
| 7446 | composite_image=RemoveFirstImageFromList(images); |
| 7447 | if (composite_image == (Image *) NULL) |
| 7448 | { |
| 7449 | status=MagickFalse; |
| 7450 | break; |
| 7451 | } |
| 7452 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7453 | composite_image->geometry); |
| 7454 | SetGeometry(composite_image,&geometry); |
| 7455 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7456 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7457 | &geometry); |
| 7458 | mask_image=RemoveFirstImageFromList(images); |
| 7459 | if (mask_image != (Image *) NULL) |
| 7460 | { |
| 7461 | if ((image->compose == DisplaceCompositeOp) || |
| 7462 | (image->compose == DistortCompositeOp)) |
| 7463 | { |
| 7464 | /* |
| 7465 | Merge Y displacement into X displacement image. |
| 7466 | */ |
| 7467 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7468 | mask_image,0,0); |
| 7469 | mask_image=DestroyImage(mask_image); |
| 7470 | } |
| 7471 | else |
| 7472 | { |
| 7473 | /* |
| 7474 | Set a blending mask for the composition. |
| 7475 | */ |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7476 | /* POSIBLE ERROR; what if image->mask already set */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7477 | image->mask=mask_image; |
| 7478 | (void) NegateImage(image->mask,MagickFalse); |
| 7479 | } |
| 7480 | } |
| 7481 | (void) CompositeImageChannel(image,channel,image->compose, |
| 7482 | composite_image,geometry.x,geometry.y); |
anthony | a129f70 | 2011-04-14 01:08:48 +0000 | [diff] [blame] | 7483 | if (mask_image != (Image *) NULL) |
| 7484 | mask_image=image->mask=DestroyImage(image->mask); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7485 | composite_image=DestroyImage(composite_image); |
| 7486 | InheritException(exception,&image->exception); |
| 7487 | *images=DestroyImageList(*images); |
| 7488 | *images=image; |
| 7489 | break; |
| 7490 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7491 | #if 0 |
| 7492 | This has been merged completely into MogrifyImage() |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7493 | if (LocaleCompare("crop",option+1) == 0) |
| 7494 | { |
| 7495 | MagickStatusType |
| 7496 | flags; |
| 7497 | |
| 7498 | RectangleInfo |
| 7499 | geometry; |
| 7500 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7501 | /* |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7502 | Crop Image. |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 7503 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7504 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7505 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7506 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7507 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7508 | break; |
| 7509 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7510 | InheritException(exception,&(*images)->exception); |
| 7511 | break; |
| 7512 | } |
anthony | 9f4f034 | 2011-03-28 11:47:22 +0000 | [diff] [blame] | 7513 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7514 | break; |
| 7515 | } |
| 7516 | case 'd': |
| 7517 | { |
| 7518 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7519 | { |
| 7520 | Image |
| 7521 | *deconstruct_image; |
| 7522 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7523 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7524 | deconstruct_image=DeconstructImages(*images,exception); |
| 7525 | if (deconstruct_image == (Image *) NULL) |
| 7526 | { |
| 7527 | status=MagickFalse; |
| 7528 | break; |
| 7529 | } |
| 7530 | *images=DestroyImageList(*images); |
| 7531 | *images=deconstruct_image; |
| 7532 | break; |
| 7533 | } |
| 7534 | if (LocaleCompare("delete",option+1) == 0) |
| 7535 | { |
| 7536 | if (*option == '+') |
| 7537 | DeleteImages(images,"-1",exception); |
| 7538 | else |
| 7539 | DeleteImages(images,argv[i+1],exception); |
| 7540 | break; |
| 7541 | } |
| 7542 | if (LocaleCompare("dither",option+1) == 0) |
| 7543 | { |
| 7544 | if (*option == '+') |
| 7545 | { |
| 7546 | quantize_info->dither=MagickFalse; |
| 7547 | break; |
| 7548 | } |
| 7549 | quantize_info->dither=MagickTrue; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7550 | quantize_info->dither_method=(DitherMethod) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7551 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7552 | break; |
| 7553 | } |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7554 | if (LocaleCompare("duplicate",option+1) == 0) |
| 7555 | { |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7556 | Image |
| 7557 | *duplicate_images; |
cristy | bf95deb | 2011-03-23 00:25:36 +0000 | [diff] [blame] | 7558 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7559 | if (*option == '+') |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7560 | duplicate_images=DuplicateImages(*images,1,"-1",exception); |
| 7561 | else |
| 7562 | { |
| 7563 | const char |
| 7564 | *p; |
| 7565 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7566 | size_t |
| 7567 | number_duplicates; |
anthony | 9bd1549 | 2011-03-23 02:11:13 +0000 | [diff] [blame] | 7568 | |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7569 | number_duplicates=(size_t) StringToLong(argv[i+1]); |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7570 | p=strchr(argv[i+1],','); |
| 7571 | if (p == (const char *) NULL) |
| 7572 | duplicate_images=DuplicateImages(*images,number_duplicates, |
| 7573 | "-1",exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7574 | else |
cristy | 7298848 | 2011-03-29 16:34:38 +0000 | [diff] [blame] | 7575 | duplicate_images=DuplicateImages(*images,number_duplicates,p, |
| 7576 | exception); |
anthony | 2b6bcae | 2011-03-23 13:05:34 +0000 | [diff] [blame] | 7577 | } |
| 7578 | AppendImageToList(images, duplicate_images); |
| 7579 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | ecb10ff | 2011-03-22 13:14:03 +0000 | [diff] [blame] | 7580 | break; |
| 7581 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7582 | break; |
| 7583 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7584 | case 'e': |
| 7585 | { |
| 7586 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7587 | { |
| 7588 | Image |
| 7589 | *evaluate_image; |
| 7590 | |
| 7591 | MagickEvaluateOperator |
| 7592 | op; |
| 7593 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7594 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7595 | op=(MagickEvaluateOperator) ParseCommandOption(MagickEvaluateOptions, |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7596 | MagickFalse,argv[i+1]); |
| 7597 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7598 | if (evaluate_image == (Image *) NULL) |
| 7599 | { |
| 7600 | status=MagickFalse; |
| 7601 | break; |
| 7602 | } |
| 7603 | *images=DestroyImageList(*images); |
| 7604 | *images=evaluate_image; |
| 7605 | break; |
| 7606 | } |
| 7607 | break; |
| 7608 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7609 | case 'f': |
| 7610 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7611 | if (LocaleCompare("fft",option+1) == 0) |
| 7612 | { |
| 7613 | Image |
| 7614 | *fourier_image; |
| 7615 | |
| 7616 | /* |
| 7617 | Implements the discrete Fourier transform (DFT). |
| 7618 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7619 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7620 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7621 | MagickTrue : MagickFalse,exception); |
| 7622 | if (fourier_image == (Image *) NULL) |
| 7623 | break; |
| 7624 | *images=DestroyImage(*images); |
| 7625 | *images=fourier_image; |
| 7626 | break; |
| 7627 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7628 | if (LocaleCompare("flatten",option+1) == 0) |
| 7629 | { |
| 7630 | Image |
| 7631 | *flatten_image; |
| 7632 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7633 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7634 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7635 | if (flatten_image == (Image *) NULL) |
| 7636 | break; |
| 7637 | *images=DestroyImageList(*images); |
| 7638 | *images=flatten_image; |
| 7639 | break; |
| 7640 | } |
| 7641 | if (LocaleCompare("fx",option+1) == 0) |
| 7642 | { |
| 7643 | Image |
| 7644 | *fx_image; |
| 7645 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7646 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7647 | fx_image=FxImageChannel(*images,channel,argv[i+1],exception); |
| 7648 | if (fx_image == (Image *) NULL) |
| 7649 | { |
| 7650 | status=MagickFalse; |
| 7651 | break; |
| 7652 | } |
| 7653 | *images=DestroyImageList(*images); |
| 7654 | *images=fx_image; |
| 7655 | break; |
| 7656 | } |
| 7657 | break; |
| 7658 | } |
| 7659 | case 'h': |
| 7660 | { |
| 7661 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7662 | { |
| 7663 | Image |
| 7664 | *hald_image, |
| 7665 | *image; |
| 7666 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7667 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7668 | image=RemoveFirstImageFromList(images); |
| 7669 | hald_image=RemoveFirstImageFromList(images); |
| 7670 | if (hald_image == (Image *) NULL) |
| 7671 | { |
| 7672 | status=MagickFalse; |
| 7673 | break; |
| 7674 | } |
| 7675 | (void) HaldClutImageChannel(image,channel,hald_image); |
| 7676 | hald_image=DestroyImage(hald_image); |
| 7677 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7678 | if (*images != (Image *) NULL) |
| 7679 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7680 | *images=image; |
| 7681 | break; |
| 7682 | } |
| 7683 | break; |
| 7684 | } |
| 7685 | case 'i': |
| 7686 | { |
| 7687 | if (LocaleCompare("ift",option+1) == 0) |
| 7688 | { |
| 7689 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7690 | *fourier_image, |
| 7691 | *magnitude_image, |
| 7692 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7693 | |
| 7694 | /* |
| 7695 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7696 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7697 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7698 | magnitude_image=RemoveFirstImageFromList(images); |
| 7699 | phase_image=RemoveFirstImageFromList(images); |
| 7700 | if (phase_image == (Image *) NULL) |
| 7701 | { |
| 7702 | status=MagickFalse; |
| 7703 | break; |
| 7704 | } |
| 7705 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7706 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7707 | if (fourier_image == (Image *) NULL) |
| 7708 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7709 | if (*images != (Image *) NULL) |
| 7710 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7711 | *images=fourier_image; |
| 7712 | break; |
| 7713 | } |
| 7714 | if (LocaleCompare("insert",option+1) == 0) |
| 7715 | { |
| 7716 | Image |
| 7717 | *p, |
| 7718 | *q; |
| 7719 | |
| 7720 | index=0; |
| 7721 | if (*option != '+') |
cristy | 32c2aea | 2010-12-01 01:00:50 +0000 | [diff] [blame] | 7722 | index=(ssize_t) StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7723 | p=RemoveLastImageFromList(images); |
| 7724 | if (p == (Image *) NULL) |
| 7725 | { |
| 7726 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7727 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7728 | status=MagickFalse; |
| 7729 | break; |
| 7730 | } |
| 7731 | q=p; |
| 7732 | if (index == 0) |
| 7733 | PrependImageToList(images,q); |
| 7734 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7735 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7736 | AppendImageToList(images,q); |
| 7737 | else |
| 7738 | { |
| 7739 | q=GetImageFromList(*images,index-1); |
| 7740 | if (q == (Image *) NULL) |
| 7741 | { |
| 7742 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7743 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7744 | status=MagickFalse; |
| 7745 | break; |
| 7746 | } |
| 7747 | InsertImageInList(&q,p); |
| 7748 | } |
| 7749 | *images=GetFirstImageInList(q); |
| 7750 | break; |
| 7751 | } |
| 7752 | break; |
| 7753 | } |
| 7754 | case 'l': |
| 7755 | { |
| 7756 | if (LocaleCompare("layers",option+1) == 0) |
| 7757 | { |
| 7758 | Image |
| 7759 | *layers; |
| 7760 | |
| 7761 | ImageLayerMethod |
| 7762 | method; |
| 7763 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7764 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7765 | layers=(Image *) NULL; |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7766 | method=(ImageLayerMethod) ParseCommandOption(MagickLayerOptions, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7767 | MagickFalse,argv[i+1]); |
| 7768 | switch (method) |
| 7769 | { |
| 7770 | case CoalesceLayer: |
| 7771 | { |
| 7772 | layers=CoalesceImages(*images,exception); |
| 7773 | break; |
| 7774 | } |
| 7775 | case CompareAnyLayer: |
| 7776 | case CompareClearLayer: |
| 7777 | case CompareOverlayLayer: |
| 7778 | default: |
| 7779 | { |
| 7780 | layers=CompareImageLayers(*images,method,exception); |
| 7781 | break; |
| 7782 | } |
| 7783 | case MergeLayer: |
| 7784 | case FlattenLayer: |
| 7785 | case MosaicLayer: |
| 7786 | case TrimBoundsLayer: |
| 7787 | { |
| 7788 | layers=MergeImageLayers(*images,method,exception); |
| 7789 | break; |
| 7790 | } |
| 7791 | case DisposeLayer: |
| 7792 | { |
| 7793 | layers=DisposeImages(*images,exception); |
| 7794 | break; |
| 7795 | } |
| 7796 | case OptimizeImageLayer: |
| 7797 | { |
| 7798 | layers=OptimizeImageLayers(*images,exception); |
| 7799 | break; |
| 7800 | } |
| 7801 | case OptimizePlusLayer: |
| 7802 | { |
| 7803 | layers=OptimizePlusImageLayers(*images,exception); |
| 7804 | break; |
| 7805 | } |
| 7806 | case OptimizeTransLayer: |
| 7807 | { |
| 7808 | OptimizeImageTransparency(*images,exception); |
| 7809 | break; |
| 7810 | } |
| 7811 | case RemoveDupsLayer: |
| 7812 | { |
| 7813 | RemoveDuplicateLayers(images,exception); |
| 7814 | break; |
| 7815 | } |
| 7816 | case RemoveZeroLayer: |
| 7817 | { |
| 7818 | RemoveZeroDelayLayers(images,exception); |
| 7819 | break; |
| 7820 | } |
| 7821 | case OptimizeLayer: |
| 7822 | { |
| 7823 | /* |
| 7824 | General Purpose, GIF Animation Optimizer. |
| 7825 | */ |
| 7826 | layers=CoalesceImages(*images,exception); |
| 7827 | if (layers == (Image *) NULL) |
| 7828 | { |
| 7829 | status=MagickFalse; |
| 7830 | break; |
| 7831 | } |
| 7832 | InheritException(exception,&layers->exception); |
| 7833 | *images=DestroyImageList(*images); |
| 7834 | *images=layers; |
| 7835 | layers=OptimizeImageLayers(*images,exception); |
| 7836 | if (layers == (Image *) NULL) |
| 7837 | { |
| 7838 | status=MagickFalse; |
| 7839 | break; |
| 7840 | } |
| 7841 | InheritException(exception,&layers->exception); |
| 7842 | *images=DestroyImageList(*images); |
| 7843 | *images=layers; |
| 7844 | layers=(Image *) NULL; |
| 7845 | OptimizeImageTransparency(*images,exception); |
| 7846 | InheritException(exception,&(*images)->exception); |
| 7847 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7848 | break; |
| 7849 | } |
| 7850 | case CompositeLayer: |
| 7851 | { |
| 7852 | CompositeOperator |
| 7853 | compose; |
| 7854 | |
| 7855 | Image |
| 7856 | *source; |
| 7857 | |
| 7858 | RectangleInfo |
| 7859 | geometry; |
| 7860 | |
| 7861 | /* |
| 7862 | Split image sequence at the first 'NULL:' image. |
| 7863 | */ |
| 7864 | source=(*images); |
| 7865 | while (source != (Image *) NULL) |
| 7866 | { |
| 7867 | source=GetNextImageInList(source); |
| 7868 | if ((source != (Image *) NULL) && |
| 7869 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 7870 | break; |
| 7871 | } |
| 7872 | if (source != (Image *) NULL) |
| 7873 | { |
| 7874 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 7875 | (GetNextImageInList(source) == (Image *) NULL)) |
| 7876 | source=(Image *) NULL; |
| 7877 | else |
| 7878 | { |
| 7879 | /* |
| 7880 | Separate the two lists, junk the null: image. |
| 7881 | */ |
| 7882 | source=SplitImageList(source->previous); |
| 7883 | DeleteImageFromList(&source); |
| 7884 | } |
| 7885 | } |
| 7886 | if (source == (Image *) NULL) |
| 7887 | { |
| 7888 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7889 | OptionError,"MissingNullSeparator","layers Composite"); |
| 7890 | status=MagickFalse; |
| 7891 | break; |
| 7892 | } |
| 7893 | /* |
| 7894 | Adjust offset with gravity and virtual canvas. |
| 7895 | */ |
| 7896 | SetGeometry(*images,&geometry); |
| 7897 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 7898 | geometry.width=source->page.width != 0 ? |
| 7899 | source->page.width : source->columns; |
| 7900 | geometry.height=source->page.height != 0 ? |
| 7901 | source->page.height : source->rows; |
| 7902 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 7903 | (*images)->page.width : (*images)->columns, |
| 7904 | (*images)->page.height != 0 ? (*images)->page.height : |
| 7905 | (*images)->rows,(*images)->gravity,&geometry); |
| 7906 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7907 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7908 | if (option != (const char *) NULL) |
cristy | 042ee78 | 2011-04-22 18:48:30 +0000 | [diff] [blame] | 7909 | compose=(CompositeOperator) ParseCommandOption( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7910 | MagickComposeOptions,MagickFalse,option); |
| 7911 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 7912 | exception); |
| 7913 | source=DestroyImageList(source); |
| 7914 | break; |
| 7915 | } |
| 7916 | } |
| 7917 | if (layers == (Image *) NULL) |
| 7918 | break; |
| 7919 | InheritException(exception,&layers->exception); |
| 7920 | *images=DestroyImageList(*images); |
| 7921 | *images=layers; |
| 7922 | break; |
| 7923 | } |
| 7924 | break; |
| 7925 | } |
| 7926 | case 'm': |
| 7927 | { |
| 7928 | if (LocaleCompare("map",option+1) == 0) |
| 7929 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7930 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7931 | if (*option == '+') |
| 7932 | { |
| 7933 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7934 | InheritException(exception,&(*images)->exception); |
| 7935 | break; |
| 7936 | } |
| 7937 | i++; |
| 7938 | break; |
| 7939 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7940 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7941 | { |
| 7942 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7943 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7944 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7945 | /* |
| 7946 | Maximum image sequence (deprecated). |
| 7947 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7948 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7949 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7950 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7951 | { |
| 7952 | status=MagickFalse; |
| 7953 | break; |
| 7954 | } |
| 7955 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7956 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7957 | break; |
| 7958 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7959 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7960 | { |
| 7961 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7962 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7963 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7964 | /* |
| 7965 | Minimum image sequence (deprecated). |
| 7966 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7967 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7968 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7969 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7970 | { |
| 7971 | status=MagickFalse; |
| 7972 | break; |
| 7973 | } |
| 7974 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 7975 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 7976 | break; |
| 7977 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7978 | if (LocaleCompare("morph",option+1) == 0) |
| 7979 | { |
| 7980 | Image |
| 7981 | *morph_image; |
| 7982 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7983 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7984 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7985 | exception); |
| 7986 | if (morph_image == (Image *) NULL) |
| 7987 | { |
| 7988 | status=MagickFalse; |
| 7989 | break; |
| 7990 | } |
| 7991 | *images=DestroyImageList(*images); |
| 7992 | *images=morph_image; |
| 7993 | break; |
| 7994 | } |
| 7995 | if (LocaleCompare("mosaic",option+1) == 0) |
| 7996 | { |
| 7997 | Image |
| 7998 | *mosaic_image; |
| 7999 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8000 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8001 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 8002 | if (mosaic_image == (Image *) NULL) |
| 8003 | { |
| 8004 | status=MagickFalse; |
| 8005 | break; |
| 8006 | } |
| 8007 | *images=DestroyImageList(*images); |
| 8008 | *images=mosaic_image; |
| 8009 | break; |
| 8010 | } |
| 8011 | break; |
| 8012 | } |
| 8013 | case 'p': |
| 8014 | { |
| 8015 | if (LocaleCompare("print",option+1) == 0) |
| 8016 | { |
| 8017 | char |
| 8018 | *string; |
| 8019 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8020 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8021 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8022 | if (string == (char *) NULL) |
| 8023 | break; |
| 8024 | InheritException(exception,&(*images)->exception); |
| 8025 | (void) fprintf(stdout,"%s",string); |
| 8026 | string=DestroyString(string); |
| 8027 | } |
| 8028 | if (LocaleCompare("process",option+1) == 0) |
| 8029 | { |
| 8030 | char |
| 8031 | **arguments; |
| 8032 | |
| 8033 | int |
| 8034 | j, |
| 8035 | number_arguments; |
| 8036 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8037 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8038 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8039 | if (arguments == (char **) NULL) |
| 8040 | break; |
| 8041 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8042 | { |
| 8043 | char |
| 8044 | breaker, |
| 8045 | quote, |
| 8046 | *token; |
| 8047 | |
| 8048 | const char |
| 8049 | *arguments; |
| 8050 | |
| 8051 | int |
| 8052 | next, |
| 8053 | status; |
| 8054 | |
| 8055 | size_t |
| 8056 | length; |
| 8057 | |
| 8058 | TokenInfo |
| 8059 | *token_info; |
| 8060 | |
| 8061 | /* |
| 8062 | Support old style syntax, filter="-option arg". |
| 8063 | */ |
| 8064 | length=strlen(argv[i+1]); |
| 8065 | token=(char *) NULL; |
| 8066 | if (~length >= MaxTextExtent) |
| 8067 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8068 | sizeof(*token)); |
| 8069 | if (token == (char *) NULL) |
| 8070 | break; |
| 8071 | next=0; |
| 8072 | arguments=argv[i+1]; |
| 8073 | token_info=AcquireTokenInfo(); |
| 8074 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8075 | "\"",'\0',&breaker,&next,"e); |
| 8076 | token_info=DestroyTokenInfo(token_info); |
| 8077 | if (status == 0) |
| 8078 | { |
| 8079 | const char |
| 8080 | *argv; |
| 8081 | |
| 8082 | argv=(&(arguments[next])); |
| 8083 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8084 | exception); |
| 8085 | } |
| 8086 | token=DestroyString(token); |
| 8087 | break; |
| 8088 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8089 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8090 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8091 | number_arguments-2,(const char **) arguments+2,exception); |
| 8092 | for (j=0; j < number_arguments; j++) |
| 8093 | arguments[j]=DestroyString(arguments[j]); |
| 8094 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8095 | break; |
| 8096 | } |
| 8097 | break; |
| 8098 | } |
| 8099 | case 'r': |
| 8100 | { |
| 8101 | if (LocaleCompare("reverse",option+1) == 0) |
| 8102 | { |
| 8103 | ReverseImageList(images); |
| 8104 | InheritException(exception,&(*images)->exception); |
| 8105 | break; |
| 8106 | } |
| 8107 | break; |
| 8108 | } |
| 8109 | case 's': |
| 8110 | { |
cristy | 4285d78 | 2011-02-09 20:12:28 +0000 | [diff] [blame] | 8111 | if (LocaleCompare("smush",option+1) == 0) |
| 8112 | { |
| 8113 | Image |
| 8114 | *smush_image; |
| 8115 | |
| 8116 | ssize_t |
| 8117 | offset; |
| 8118 | |
| 8119 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8120 | offset=(ssize_t) StringToLong(argv[i+1]); |
| 8121 | smush_image=SmushImages(*images,*option == '-' ? MagickTrue : |
| 8122 | MagickFalse,offset,exception); |
| 8123 | if (smush_image == (Image *) NULL) |
| 8124 | { |
| 8125 | status=MagickFalse; |
| 8126 | break; |
| 8127 | } |
| 8128 | *images=DestroyImageList(*images); |
| 8129 | *images=smush_image; |
| 8130 | break; |
| 8131 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8132 | if (LocaleCompare("swap",option+1) == 0) |
| 8133 | { |
| 8134 | Image |
| 8135 | *p, |
| 8136 | *q, |
| 8137 | *swap; |
| 8138 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8139 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8140 | swap_index; |
| 8141 | |
| 8142 | index=(-1); |
| 8143 | swap_index=(-2); |
| 8144 | if (*option != '+') |
| 8145 | { |
| 8146 | GeometryInfo |
| 8147 | geometry_info; |
| 8148 | |
| 8149 | MagickStatusType |
| 8150 | flags; |
| 8151 | |
| 8152 | swap_index=(-1); |
| 8153 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8154 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8155 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8156 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8157 | } |
| 8158 | p=GetImageFromList(*images,index); |
| 8159 | q=GetImageFromList(*images,swap_index); |
| 8160 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8161 | { |
| 8162 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8163 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8164 | status=MagickFalse; |
| 8165 | break; |
| 8166 | } |
| 8167 | if (p == q) |
| 8168 | break; |
| 8169 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8170 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8171 | ReplaceImageInList(&q,swap); |
| 8172 | *images=GetFirstImageInList(q); |
| 8173 | break; |
| 8174 | } |
| 8175 | break; |
| 8176 | } |
| 8177 | case 'w': |
| 8178 | { |
| 8179 | if (LocaleCompare("write",option+1) == 0) |
| 8180 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8181 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8182 | key[MaxTextExtent]; |
| 8183 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8184 | Image |
| 8185 | *write_images; |
| 8186 | |
| 8187 | ImageInfo |
| 8188 | *write_info; |
| 8189 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8190 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8191 | (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
| 8192 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8193 | write_images=(*images); |
| 8194 | if (*option == '+') |
| 8195 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8196 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8197 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8198 | write_info=DestroyImageInfo(write_info); |
| 8199 | if (*option == '+') |
| 8200 | write_images=DestroyImageList(write_images); |
| 8201 | break; |
| 8202 | } |
| 8203 | break; |
| 8204 | } |
| 8205 | default: |
| 8206 | break; |
| 8207 | } |
| 8208 | i+=count; |
| 8209 | } |
| 8210 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8211 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8212 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8213 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8214 | } |
| 8215 | |
| 8216 | /* |
| 8217 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8218 | % % |
| 8219 | % % |
| 8220 | % % |
| 8221 | + M o g r i f y I m a g e s % |
| 8222 | % % |
| 8223 | % % |
| 8224 | % % |
| 8225 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8226 | % |
| 8227 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8228 | % prescribed by command line options. |
| 8229 | % |
| 8230 | % The format of the MogrifyImage method is: |
| 8231 | % |
| 8232 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8233 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8234 | % Image **images,Exceptioninfo *exception) |
| 8235 | % |
| 8236 | % A description of each parameter follows: |
| 8237 | % |
| 8238 | % o image_info: the image info.. |
| 8239 | % |
| 8240 | % o post: If true, post process image list operators otherwise pre-process. |
| 8241 | % |
| 8242 | % o argc: Specifies a pointer to an integer describing the number of |
| 8243 | % elements in the argument vector. |
| 8244 | % |
| 8245 | % o argv: Specifies a pointer to a text array containing the command line |
| 8246 | % arguments. |
| 8247 | % |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8248 | % o images: pointer to a pointer of the first image in image list. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8249 | % |
| 8250 | % o exception: return any errors or warnings in this structure. |
| 8251 | % |
| 8252 | */ |
| 8253 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8254 | const MagickBooleanType post,const int argc,const char **argv, |
| 8255 | Image **images,ExceptionInfo *exception) |
| 8256 | { |
| 8257 | #define MogrifyImageTag "Mogrify/Image" |
| 8258 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8259 | MagickStatusType |
| 8260 | status; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8261 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8262 | MagickBooleanType |
| 8263 | proceed; |
| 8264 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8265 | size_t |
| 8266 | n; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8267 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8268 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8269 | i; |
| 8270 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8271 | assert(image_info != (ImageInfo *) NULL); |
| 8272 | assert(image_info->signature == MagickSignature); |
| 8273 | if (images == (Image **) NULL) |
| 8274 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8275 | assert((*images)->previous == (Image *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8276 | assert((*images)->signature == MagickSignature); |
| 8277 | if ((*images)->debug != MagickFalse) |
| 8278 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8279 | (*images)->filename); |
| 8280 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8281 | return(MagickTrue); |
| 8282 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8283 | (void *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8284 | status=0; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8285 | |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8286 | #if 0 |
| 8287 | fprintf(stderr, "mogrify start %s %d (%s)\n",argv[0],argc,post?"post":"pre"); |
| 8288 | #endif |
| 8289 | |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8290 | /* |
| 8291 | Pre-process multi-image sequence operators |
| 8292 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8293 | if (post == MagickFalse) |
| 8294 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8295 | |
| 8296 | /* |
| 8297 | For each image, process simple single image operators |
| 8298 | */ |
| 8299 | i=0; |
| 8300 | n=GetImageListLength(*images); |
| 8301 | for (;;) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8302 | { |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8303 | #if 0 |
| 8304 | fprintf(stderr, "mogrify %ld of %ld\n", |
| 8305 | (long)GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
| 8306 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8307 | status&=MogrifyImage(image_info,argc,argv,images,exception); |
| 8308 | proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8309 | if (proceed == MagickFalse) |
| 8310 | break; |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8311 | if ( (*images)->next == (Image *) NULL ) |
| 8312 | break; |
| 8313 | *images=(*images)->next; |
| 8314 | i++; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8315 | } |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8316 | assert( *images != (Image *) NULL ); |
anthony | ce2716b | 2011-04-22 09:51:34 +0000 | [diff] [blame] | 8317 | #if 0 |
| 8318 | fprintf(stderr, "mogrify end %ld of %ld\n", |
| 8319 | (long)GetImageIndexInList(*images),(long)GetImageListLength(*images)); |
| 8320 | #endif |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8321 | |
| 8322 | /* |
| 8323 | Post-process, multi-image sequence operators |
| 8324 | */ |
| 8325 | *images=GetFirstImageInList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8326 | if (post != MagickFalse) |
anthony | e9c2719 | 2011-03-27 08:07:06 +0000 | [diff] [blame] | 8327 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8328 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8329 | } |