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 | 16af1cb | 2009-12-11 21:38:29 +0000 | [diff] [blame] | 20 | % Copyright 1999-2010 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 | /* |
| 60 | Constant declaration. |
| 61 | */ |
| 62 | static const char |
cristy | 7138c59 | 2009-09-08 13:58:52 +0000 | [diff] [blame] | 63 | BackgroundColor[] = "#fff", /* white */ |
| 64 | BorderColor[] = "#dfdfdf", /* gray */ |
| 65 | MatteColor[] = "#bdbdbd"; /* gray */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 66 | |
| 67 | /* |
| 68 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 69 | % % |
| 70 | % % |
| 71 | % % |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 72 | + M a g i c k C o m m a n d G e n e s i s % |
| 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, |
| 84 | % MagickCommand command,const int argc,const char **argv,Image **image) |
| 85 | % |
| 86 | % A description of each parameter follows: |
| 87 | % |
| 88 | % o image_info: the image info. |
| 89 | % |
| 90 | % o command: the magick command. |
| 91 | % |
| 92 | % o argc: Specifies a pointer to an integer describing the number of |
| 93 | % elements in the argument vector. |
| 94 | % |
| 95 | % o argv: Specifies a pointer to a text array containing the command line |
| 96 | % arguments. |
| 97 | % |
| 98 | % o image: the image. |
| 99 | % |
| 100 | % o exception: return any errors or warnings in this structure. |
| 101 | % |
| 102 | */ |
| 103 | WandExport MagickBooleanType MagickCommandGenesis(ImageInfo *image_info, |
| 104 | MagickCommand command,int argc,char **argv,char **metadata, |
| 105 | ExceptionInfo *exception) |
| 106 | { |
| 107 | char |
| 108 | *option; |
| 109 | |
| 110 | double |
| 111 | duration, |
| 112 | elapsed_time, |
| 113 | user_time; |
| 114 | |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 115 | MagickBooleanType |
| 116 | concurrent, |
| 117 | regard_warnings, |
| 118 | status; |
| 119 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 120 | register ssize_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 121 | i; |
| 122 | |
| 123 | TimerInfo |
| 124 | *timer; |
| 125 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 126 | size_t |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 127 | iterations; |
| 128 | |
cristy | d0a94fa | 2010-03-12 14:18:11 +0000 | [diff] [blame] | 129 | (void) setlocale(LC_ALL,""); |
| 130 | (void) setlocale(LC_NUMERIC,"C"); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 131 | concurrent=MagickFalse; |
| 132 | duration=(-1.0); |
| 133 | iterations=1; |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 134 | status=MagickFalse; |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 135 | regard_warnings=MagickFalse; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 136 | for (i=1; i < (ssize_t) (argc-1); i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 137 | { |
| 138 | option=argv[i]; |
| 139 | if ((strlen(option) == 1) || ((*option != '-') && (*option != '+'))) |
| 140 | continue; |
| 141 | if (LocaleCompare("bench",option+1) == 0) |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 142 | iterations=StringToUnsignedLong(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 143 | if (LocaleCompare("concurrent",option+1) == 0) |
| 144 | concurrent=MagickTrue; |
| 145 | if (LocaleCompare("debug",option+1) == 0) |
| 146 | (void) SetLogEventMask(argv[++i]); |
| 147 | if (LocaleCompare("duration",option+1) == 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 148 | duration=StringToDouble(argv[++i]); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 149 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 150 | regard_warnings=MagickTrue; |
| 151 | } |
| 152 | timer=AcquireTimerInfo(); |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 153 | if (concurrent == MagickFalse) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 154 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 155 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 156 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 157 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 158 | continue; |
| 159 | if (duration > 0) |
| 160 | { |
| 161 | if (GetElapsedTime(timer) > duration) |
| 162 | continue; |
| 163 | (void) ContinueTimer(timer); |
| 164 | } |
| 165 | status=command(image_info,argc,argv,metadata,exception); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 166 | if (exception->severity != UndefinedException) |
| 167 | { |
| 168 | if ((exception->severity > ErrorException) || |
| 169 | (regard_warnings != MagickFalse)) |
| 170 | status=MagickTrue; |
| 171 | CatchException(exception); |
| 172 | } |
cristy | 3d1a551 | 2009-10-25 21:23:27 +0000 | [diff] [blame] | 173 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 174 | { |
| 175 | (void) fputs(*metadata,stdout); |
| 176 | (void) fputc('\n',stdout); |
| 177 | *metadata=DestroyString(*metadata); |
| 178 | } |
| 179 | } |
| 180 | } |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 181 | else |
| 182 | { |
| 183 | SetOpenMPNested(1); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 184 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 185 | # pragma omp parallel for shared(status) |
| 186 | #endif |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 187 | for (i=0; i < (ssize_t) iterations; i++) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 188 | { |
cristy | 33557d7 | 2009-11-06 00:54:33 +0000 | [diff] [blame] | 189 | if (status != MagickFalse) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 190 | continue; |
| 191 | if (duration > 0) |
| 192 | { |
| 193 | if (GetElapsedTime(timer) > duration) |
| 194 | continue; |
| 195 | (void) ContinueTimer(timer); |
| 196 | } |
| 197 | status=command(image_info,argc,argv,metadata,exception); |
cristy | b5d5f72 | 2009-11-04 03:03:49 +0000 | [diff] [blame] | 198 | #if defined(MAGICKCORE_OPENMP_SUPPORT) |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 199 | # pragma omp critical (MagickCore_CommandGenesis) |
cristy | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 200 | #endif |
| 201 | { |
| 202 | if (exception->severity != UndefinedException) |
| 203 | { |
| 204 | if ((exception->severity > ErrorException) || |
| 205 | (regard_warnings != MagickFalse)) |
| 206 | status=MagickTrue; |
| 207 | CatchException(exception); |
| 208 | } |
| 209 | if ((metadata != (char **) NULL) && (*metadata != (char *) NULL)) |
| 210 | { |
| 211 | (void) fputs(*metadata,stdout); |
| 212 | (void) fputc('\n',stdout); |
| 213 | *metadata=DestroyString(*metadata); |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | } |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 218 | if (iterations > 1) |
| 219 | { |
| 220 | elapsed_time=GetElapsedTime(timer); |
| 221 | user_time=GetUserTime(timer); |
cristy | 8cd5b31 | 2010-01-07 01:10:24 +0000 | [diff] [blame] | 222 | (void) fprintf(stderr, |
cristy | e8c25f9 | 2010-06-03 00:53:06 +0000 | [diff] [blame] | 223 | "Performance: %.20gi %gips %0.3fu %.20g:%02g.%03g\n",(double) |
| 224 | iterations,1.0*iterations/elapsed_time,user_time,(double) |
| 225 | (elapsed_time/60.0),floor(fmod(elapsed_time,60.0)),(double) |
| 226 | (1000.0*(elapsed_time-floor(elapsed_time)))); |
cristy | 524549f | 2010-06-20 21:10:20 +0000 | [diff] [blame] | 227 | (void) fflush(stderr); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 228 | } |
| 229 | timer=DestroyTimerInfo(timer); |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 230 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | /* |
| 234 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 235 | % % |
| 236 | % % |
| 237 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 238 | + M o g r i f y I m a g e % |
| 239 | % % |
| 240 | % % |
| 241 | % % |
| 242 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 243 | % |
| 244 | % MogrifyImage() applies image processing options to an image as prescribed |
| 245 | % by command line options. |
| 246 | % |
| 247 | % The format of the MogrifyImage method is: |
| 248 | % |
| 249 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 250 | % const char **argv,Image **image) |
| 251 | % |
| 252 | % A description of each parameter follows: |
| 253 | % |
| 254 | % o image_info: the image info.. |
| 255 | % |
| 256 | % o argc: Specifies a pointer to an integer describing the number of |
| 257 | % elements in the argument vector. |
| 258 | % |
| 259 | % o argv: Specifies a pointer to a text array containing the command line |
| 260 | % arguments. |
| 261 | % |
| 262 | % o image: the image. |
| 263 | % |
| 264 | % o exception: return any errors or warnings in this structure. |
| 265 | % |
| 266 | */ |
| 267 | |
| 268 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 269 | ExceptionInfo *exception) |
| 270 | { |
| 271 | char |
| 272 | key[MaxTextExtent]; |
| 273 | |
| 274 | ExceptionInfo |
| 275 | *sans_exception; |
| 276 | |
| 277 | Image |
| 278 | *image; |
| 279 | |
| 280 | ImageInfo |
| 281 | *read_info; |
| 282 | |
| 283 | (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path); |
| 284 | sans_exception=AcquireExceptionInfo(); |
| 285 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 286 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 287 | if (image != (Image *) NULL) |
| 288 | return(image); |
| 289 | read_info=CloneImageInfo(image_info); |
| 290 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 291 | image=ReadImage(read_info,exception); |
| 292 | read_info=DestroyImageInfo(read_info); |
| 293 | if (image != (Image *) NULL) |
| 294 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 295 | return(image); |
| 296 | } |
| 297 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 298 | static MagickBooleanType IsPathWritable(const char *path) |
| 299 | { |
| 300 | if (IsPathAccessible(path) == MagickFalse) |
| 301 | return(MagickFalse); |
| 302 | if (access(path,W_OK) != 0) |
| 303 | return(MagickFalse); |
| 304 | return(MagickTrue); |
| 305 | } |
| 306 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 307 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 308 | { |
| 309 | if (x > y) |
| 310 | return(x); |
| 311 | return(y); |
| 312 | } |
| 313 | |
| 314 | static MagickBooleanType MonitorProgress(const char *text, |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 315 | const MagickOffsetType offset,const MagickSizeType extent, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 316 | void *wand_unused(client_data)) |
| 317 | { |
| 318 | char |
| 319 | message[MaxTextExtent], |
| 320 | tag[MaxTextExtent]; |
| 321 | |
| 322 | const char |
| 323 | *locale_message; |
| 324 | |
| 325 | register char |
| 326 | *p; |
| 327 | |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 328 | if (extent < 2) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 329 | return(MagickTrue); |
| 330 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 331 | p=strrchr(tag,'/'); |
| 332 | if (p != (char *) NULL) |
| 333 | *p='\0'; |
| 334 | (void) FormatMagickString(message,MaxTextExtent,"Monitor/%s",tag); |
| 335 | locale_message=GetLocaleMessage(message); |
| 336 | if (locale_message == message) |
| 337 | locale_message=tag; |
| 338 | if (p == (char *) NULL) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 339 | (void) fprintf(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message, |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 340 | (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 341 | else |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 342 | (void) fprintf(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 343 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 344 | (100L*offset/(extent-1))); |
| 345 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 346 | (void) fprintf(stderr,"\n"); |
| 347 | (void) fflush(stderr); |
| 348 | return(MagickTrue); |
| 349 | } |
| 350 | |
| 351 | static Image *SparseColorOption(const Image *image,const ChannelType channel, |
| 352 | const SparseColorMethod method,const char *arguments, |
| 353 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 354 | { |
| 355 | ChannelType |
| 356 | channels; |
| 357 | |
| 358 | char |
| 359 | token[MaxTextExtent]; |
| 360 | |
| 361 | const char |
| 362 | *p; |
| 363 | |
| 364 | double |
| 365 | *sparse_arguments; |
| 366 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 367 | register size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 368 | x; |
| 369 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 370 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 371 | number_arguments; |
| 372 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 373 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 374 | number_colors; |
| 375 | |
| 376 | Image |
| 377 | *sparse_image; |
| 378 | |
| 379 | MagickPixelPacket |
| 380 | color; |
| 381 | |
| 382 | MagickBooleanType |
| 383 | error; |
| 384 | |
| 385 | assert(image != (Image *) NULL); |
| 386 | assert(image->signature == MagickSignature); |
| 387 | if (image->debug != MagickFalse) |
| 388 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 389 | assert(exception != (ExceptionInfo *) NULL); |
| 390 | assert(exception->signature == MagickSignature); |
| 391 | /* |
| 392 | Limit channels according to image - and add up number of color channel. |
| 393 | */ |
| 394 | channels=channel; |
| 395 | if (image->colorspace != CMYKColorspace) |
| 396 | channels=(ChannelType) (channels & ~IndexChannel); /* no index channel */ |
| 397 | if (image->matte == MagickFalse) |
| 398 | channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */ |
| 399 | number_colors=0; |
| 400 | if ((channels & RedChannel) != 0) |
| 401 | number_colors++; |
| 402 | if ((channels & GreenChannel) != 0) |
| 403 | number_colors++; |
| 404 | if ((channels & BlueChannel) != 0) |
| 405 | number_colors++; |
| 406 | if ((channels & IndexChannel) != 0) |
| 407 | number_colors++; |
| 408 | if ((channels & OpacityChannel) != 0) |
| 409 | number_colors++; |
| 410 | /* |
| 411 | Read string, to determine number of arguments needed, |
| 412 | */ |
| 413 | p=arguments; |
| 414 | x=0; |
| 415 | while( *p != '\0' ) |
| 416 | { |
| 417 | GetMagickToken(p,&p,token); |
| 418 | if ( token[0] == ',' ) continue; |
| 419 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 420 | if ( color_from_image ) { |
| 421 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 422 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 423 | "Color arg given, when colors are coming from image"); |
| 424 | return( (Image *)NULL); |
| 425 | } |
| 426 | x += number_colors; /* color argument */ |
| 427 | } |
| 428 | else { |
| 429 | x++; /* floating point argument */ |
| 430 | } |
| 431 | } |
| 432 | error=MagickTrue; |
| 433 | if ( color_from_image ) { |
| 434 | /* just the control points are being given */ |
| 435 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 436 | number_arguments=(x/2)*(2+number_colors); |
| 437 | } |
| 438 | else { |
| 439 | /* control points and color values */ |
| 440 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 441 | number_arguments=x; |
| 442 | } |
| 443 | if ( error ) { |
| 444 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 445 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 446 | "Invalid number of Arguments"); |
| 447 | return( (Image *)NULL); |
| 448 | } |
| 449 | |
| 450 | /* Allocate and fill in the floating point arguments */ |
| 451 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 452 | sizeof(*sparse_arguments)); |
| 453 | if (sparse_arguments == (double *) NULL) { |
| 454 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 455 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 456 | return( (Image *)NULL); |
| 457 | } |
| 458 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 459 | sizeof(*sparse_arguments)); |
| 460 | p=arguments; |
| 461 | x=0; |
| 462 | while( *p != '\0' && x < number_arguments ) { |
| 463 | /* X coordinate */ |
| 464 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 465 | if ( token[0] == '\0' ) break; |
| 466 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 467 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 468 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 469 | "Color found, instead of X-coord"); |
| 470 | error = MagickTrue; |
| 471 | break; |
| 472 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 473 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 474 | /* Y coordinate */ |
| 475 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 476 | if ( token[0] == '\0' ) break; |
| 477 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 478 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 479 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 480 | "Color found, instead of Y-coord"); |
| 481 | error = MagickTrue; |
| 482 | break; |
| 483 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 484 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 485 | /* color values for this control point */ |
| 486 | #if 0 |
| 487 | if ( (color_from_image ) { |
| 488 | /* get color from image */ |
| 489 | /* HOW??? */ |
| 490 | } |
| 491 | else |
| 492 | #endif |
| 493 | { |
| 494 | /* color name or function given in string argument */ |
| 495 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 496 | if ( token[0] == '\0' ) break; |
| 497 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 498 | /* Color string given */ |
| 499 | (void) QueryMagickColor(token,&color,exception); |
| 500 | if ( channels & RedChannel ) |
| 501 | sparse_arguments[x++] = QuantumScale*color.red; |
| 502 | if ( channels & GreenChannel ) |
| 503 | sparse_arguments[x++] = QuantumScale*color.green; |
| 504 | if ( channels & BlueChannel ) |
| 505 | sparse_arguments[x++] = QuantumScale*color.blue; |
| 506 | if ( channels & IndexChannel ) |
| 507 | sparse_arguments[x++] = QuantumScale*color.index; |
| 508 | if ( channels & OpacityChannel ) |
| 509 | sparse_arguments[x++] = QuantumScale*color.opacity; |
| 510 | } |
| 511 | else { |
| 512 | #if 0 |
| 513 | /* the color name/function/value was not found - error */ |
| 514 | break; |
| 515 | #else |
| 516 | /* Colors given as a set of floating point values - experimental */ |
| 517 | /* NB: token contains the first floating point value to use! */ |
| 518 | if ( channels & RedChannel ) { |
| 519 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 520 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 521 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 522 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 523 | token[0] = ','; /* used this token - get another */ |
| 524 | } |
| 525 | if ( channels & GreenChannel ) { |
| 526 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 527 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 528 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 529 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 530 | token[0] = ','; /* used this token - get another */ |
| 531 | } |
| 532 | if ( channels & BlueChannel ) { |
| 533 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 534 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 535 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 536 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 537 | token[0] = ','; /* used this token - get another */ |
| 538 | } |
| 539 | if ( channels & IndexChannel ) { |
| 540 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 541 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 542 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 543 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 544 | token[0] = ','; /* used this token - get another */ |
| 545 | } |
| 546 | if ( channels & OpacityChannel ) { |
| 547 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 548 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 549 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 550 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 551 | token[0] = ','; /* used this token - get another */ |
| 552 | } |
| 553 | #endif |
| 554 | } |
| 555 | } |
| 556 | } |
| 557 | if ( number_arguments != x && !error ) { |
| 558 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 559 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 560 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 561 | return( (Image *)NULL); |
| 562 | } |
| 563 | if ( error ) |
| 564 | return( (Image *)NULL); |
| 565 | |
| 566 | /* Call the Interpolation function with the parsed arguments */ |
| 567 | sparse_image=SparseColorImage(image,channels,method,number_arguments, |
| 568 | sparse_arguments,exception); |
| 569 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 570 | return( sparse_image ); |
| 571 | } |
| 572 | |
| 573 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 574 | const char **argv,Image **image,ExceptionInfo *exception) |
| 575 | { |
| 576 | ChannelType |
| 577 | channel; |
| 578 | |
| 579 | const char |
| 580 | *format, |
| 581 | *option; |
| 582 | |
| 583 | DrawInfo |
| 584 | *draw_info; |
| 585 | |
| 586 | GeometryInfo |
| 587 | geometry_info; |
| 588 | |
| 589 | Image |
| 590 | *region_image; |
| 591 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 592 | ImageInfo |
| 593 | *mogrify_info; |
| 594 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 595 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 596 | count; |
| 597 | |
| 598 | MagickBooleanType |
| 599 | status; |
| 600 | |
| 601 | MagickPixelPacket |
| 602 | fill; |
| 603 | |
| 604 | MagickStatusType |
| 605 | flags; |
| 606 | |
| 607 | QuantizeInfo |
| 608 | *quantize_info; |
| 609 | |
| 610 | RectangleInfo |
| 611 | geometry, |
| 612 | region_geometry; |
| 613 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 614 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 615 | i; |
| 616 | |
| 617 | /* |
| 618 | Initialize method variables. |
| 619 | */ |
| 620 | assert(image_info != (const ImageInfo *) NULL); |
| 621 | assert(image_info->signature == MagickSignature); |
| 622 | assert(image != (Image **) NULL); |
| 623 | assert((*image)->signature == MagickSignature); |
| 624 | if ((*image)->debug != MagickFalse) |
| 625 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 626 | if (argc < 0) |
| 627 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 628 | mogrify_info=CloneImageInfo(image_info); |
| 629 | draw_info=CloneDrawInfo(mogrify_info,(DrawInfo *) NULL); |
| 630 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 631 | SetGeometryInfo(&geometry_info); |
| 632 | GetMagickPixelPacket(*image,&fill); |
| 633 | SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL, |
| 634 | &fill); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 635 | channel=mogrify_info->channel; |
| 636 | format=GetImageOption(mogrify_info,"format"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 637 | SetGeometry(*image,®ion_geometry); |
| 638 | region_image=NewImageList(); |
| 639 | /* |
| 640 | Transmogrify the image. |
| 641 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 642 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 643 | { |
| 644 | option=argv[i]; |
| 645 | if (IsMagickOption(option) == MagickFalse) |
| 646 | continue; |
| 647 | count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option), |
| 648 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 649 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 650 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 651 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 652 | switch (*(option+1)) |
| 653 | { |
| 654 | case 'a': |
| 655 | { |
| 656 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 657 | { |
| 658 | Image |
| 659 | *blur_image; |
| 660 | |
| 661 | /* |
| 662 | Adaptive blur image. |
| 663 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 664 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 665 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 666 | if ((flags & SigmaValue) == 0) |
| 667 | geometry_info.sigma=1.0; |
| 668 | blur_image=AdaptiveBlurImageChannel(*image,channel, |
| 669 | geometry_info.rho,geometry_info.sigma,exception); |
| 670 | if (blur_image == (Image *) NULL) |
| 671 | break; |
| 672 | *image=DestroyImage(*image); |
| 673 | *image=blur_image; |
| 674 | break; |
| 675 | } |
| 676 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 677 | { |
| 678 | Image |
| 679 | *resize_image; |
| 680 | |
| 681 | /* |
| 682 | Adaptive resize image. |
| 683 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 684 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 685 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 686 | resize_image=AdaptiveResizeImage(*image,geometry.width, |
| 687 | geometry.height,exception); |
| 688 | if (resize_image == (Image *) NULL) |
| 689 | break; |
| 690 | *image=DestroyImage(*image); |
| 691 | *image=resize_image; |
| 692 | break; |
| 693 | } |
| 694 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 695 | { |
| 696 | Image |
| 697 | *sharp_image; |
| 698 | |
| 699 | /* |
| 700 | Adaptive sharpen image. |
| 701 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 702 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 703 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 704 | if ((flags & SigmaValue) == 0) |
| 705 | geometry_info.sigma=1.0; |
| 706 | sharp_image=AdaptiveSharpenImageChannel(*image,channel, |
| 707 | geometry_info.rho,geometry_info.sigma,exception); |
| 708 | if (sharp_image == (Image *) NULL) |
| 709 | break; |
| 710 | *image=DestroyImage(*image); |
| 711 | *image=sharp_image; |
| 712 | break; |
| 713 | } |
| 714 | if (LocaleCompare("affine",option+1) == 0) |
| 715 | { |
| 716 | /* |
| 717 | Affine matrix. |
| 718 | */ |
| 719 | if (*option == '+') |
| 720 | { |
| 721 | GetAffineMatrix(&draw_info->affine); |
| 722 | break; |
| 723 | } |
| 724 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 725 | break; |
| 726 | } |
| 727 | if (LocaleCompare("alpha",option+1) == 0) |
| 728 | { |
| 729 | AlphaChannelType |
| 730 | alpha_type; |
| 731 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 732 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 733 | alpha_type=(AlphaChannelType) ParseMagickOption(MagickAlphaOptions, |
| 734 | MagickFalse,argv[i+1]); |
| 735 | (void) SetImageAlphaChannel(*image,alpha_type); |
| 736 | InheritException(exception,&(*image)->exception); |
| 737 | break; |
| 738 | } |
| 739 | if (LocaleCompare("annotate",option+1) == 0) |
| 740 | { |
| 741 | char |
| 742 | *text, |
| 743 | geometry[MaxTextExtent]; |
| 744 | |
| 745 | /* |
| 746 | Annotate image. |
| 747 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 748 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 749 | SetGeometryInfo(&geometry_info); |
| 750 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 751 | if ((flags & SigmaValue) == 0) |
| 752 | geometry_info.sigma=geometry_info.rho; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 753 | text=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 754 | InheritException(exception,&(*image)->exception); |
| 755 | if (text == (char *) NULL) |
| 756 | break; |
| 757 | (void) CloneString(&draw_info->text,text); |
| 758 | text=DestroyString(text); |
| 759 | (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f", |
| 760 | geometry_info.xi,geometry_info.psi); |
| 761 | (void) CloneString(&draw_info->geometry,geometry); |
| 762 | draw_info->affine.sx=cos(DegreesToRadians( |
| 763 | fmod(geometry_info.rho,360.0))); |
| 764 | draw_info->affine.rx=sin(DegreesToRadians( |
| 765 | fmod(geometry_info.rho,360.0))); |
| 766 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 767 | fmod(geometry_info.sigma,360.0)))); |
| 768 | draw_info->affine.sy=cos(DegreesToRadians( |
| 769 | fmod(geometry_info.sigma,360.0))); |
| 770 | (void) AnnotateImage(*image,draw_info); |
| 771 | InheritException(exception,&(*image)->exception); |
| 772 | break; |
| 773 | } |
| 774 | if (LocaleCompare("antialias",option+1) == 0) |
| 775 | { |
| 776 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 777 | MagickFalse; |
| 778 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 779 | MagickFalse; |
| 780 | break; |
| 781 | } |
| 782 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 783 | { |
| 784 | /* |
| 785 | Auto Adjust Gamma of image based on its mean |
| 786 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 787 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 788 | (void) AutoGammaImageChannel(*image,channel); |
| 789 | break; |
| 790 | } |
| 791 | if (LocaleCompare("auto-level",option+1) == 0) |
| 792 | { |
| 793 | /* |
| 794 | Perfectly Normalize (max/min stretch) the image |
| 795 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 796 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 797 | (void) AutoLevelImageChannel(*image,channel); |
| 798 | break; |
| 799 | } |
| 800 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 801 | { |
| 802 | Image |
| 803 | *orient_image; |
| 804 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 805 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 806 | orient_image=NewImageList(); |
| 807 | switch ((*image)->orientation) |
| 808 | { |
| 809 | case TopRightOrientation: |
| 810 | { |
| 811 | orient_image=FlopImage(*image,exception); |
| 812 | break; |
| 813 | } |
| 814 | case BottomRightOrientation: |
| 815 | { |
| 816 | orient_image=RotateImage(*image,180.0,exception); |
| 817 | break; |
| 818 | } |
| 819 | case BottomLeftOrientation: |
| 820 | { |
| 821 | orient_image=FlipImage(*image,exception); |
| 822 | break; |
| 823 | } |
| 824 | case LeftTopOrientation: |
| 825 | { |
| 826 | orient_image=TransposeImage(*image,exception); |
| 827 | break; |
| 828 | } |
| 829 | case RightTopOrientation: |
| 830 | { |
| 831 | orient_image=RotateImage(*image,90.0,exception); |
| 832 | break; |
| 833 | } |
| 834 | case RightBottomOrientation: |
| 835 | { |
| 836 | orient_image=TransverseImage(*image,exception); |
| 837 | break; |
| 838 | } |
| 839 | case LeftBottomOrientation: |
| 840 | { |
| 841 | orient_image=RotateImage(*image,270.0,exception); |
| 842 | break; |
| 843 | } |
| 844 | default: |
| 845 | break; |
| 846 | } |
| 847 | if (orient_image == (Image *) NULL) |
| 848 | break; |
| 849 | orient_image->orientation=TopLeftOrientation; |
| 850 | *image=DestroyImage(*image); |
| 851 | *image=orient_image; |
| 852 | break; |
| 853 | } |
| 854 | break; |
| 855 | } |
| 856 | case 'b': |
| 857 | { |
| 858 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 859 | { |
| 860 | /* |
| 861 | Black threshold image. |
| 862 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 863 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 864 | (void) BlackThresholdImageChannel(*image,channel,argv[i+1], |
| 865 | exception); |
| 866 | InheritException(exception,&(*image)->exception); |
| 867 | break; |
| 868 | } |
| 869 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 870 | { |
| 871 | Image |
| 872 | *shift_image; |
| 873 | |
| 874 | /* |
| 875 | Blue shift image. |
| 876 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 877 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 878 | geometry_info.rho=1.5; |
| 879 | if (*option == '-') |
| 880 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 881 | shift_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 882 | if (shift_image == (Image *) NULL) |
| 883 | break; |
| 884 | *image=DestroyImage(*image); |
| 885 | *image=shift_image; |
| 886 | break; |
| 887 | } |
| 888 | if (LocaleCompare("blur",option+1) == 0) |
| 889 | { |
| 890 | Image |
| 891 | *blur_image; |
| 892 | |
| 893 | /* |
| 894 | Gaussian blur image. |
| 895 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 896 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 897 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 898 | if ((flags & SigmaValue) == 0) |
| 899 | geometry_info.sigma=1.0; |
| 900 | blur_image=BlurImageChannel(*image,channel,geometry_info.rho, |
| 901 | geometry_info.sigma,exception); |
| 902 | if (blur_image == (Image *) NULL) |
| 903 | break; |
| 904 | *image=DestroyImage(*image); |
| 905 | *image=blur_image; |
| 906 | break; |
| 907 | } |
| 908 | if (LocaleCompare("border",option+1) == 0) |
| 909 | { |
| 910 | Image |
| 911 | *border_image; |
| 912 | |
| 913 | /* |
| 914 | Surround image with a border of solid color. |
| 915 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 916 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 917 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 918 | if ((flags & SigmaValue) == 0) |
| 919 | geometry.height=geometry.width; |
| 920 | border_image=BorderImage(*image,&geometry,exception); |
| 921 | if (border_image == (Image *) NULL) |
| 922 | break; |
| 923 | *image=DestroyImage(*image); |
| 924 | *image=border_image; |
| 925 | break; |
| 926 | } |
| 927 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 928 | { |
| 929 | if (*option == '+') |
| 930 | { |
| 931 | (void) QueryColorDatabase(BorderColor,&draw_info->border_color, |
| 932 | exception); |
| 933 | break; |
| 934 | } |
| 935 | (void) QueryColorDatabase(argv[i+1],&draw_info->border_color, |
| 936 | exception); |
| 937 | break; |
| 938 | } |
| 939 | if (LocaleCompare("box",option+1) == 0) |
| 940 | { |
| 941 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 942 | exception); |
| 943 | break; |
| 944 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 945 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 946 | { |
| 947 | double |
| 948 | brightness, |
| 949 | contrast; |
| 950 | |
| 951 | GeometryInfo |
| 952 | geometry_info; |
| 953 | |
| 954 | MagickStatusType |
| 955 | flags; |
| 956 | |
| 957 | /* |
| 958 | Brightness / contrast image. |
| 959 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 960 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 961 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 962 | brightness=geometry_info.rho; |
cristy | 81fbc8b | 2010-01-11 20:04:07 +0000 | [diff] [blame] | 963 | contrast=0.0; |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 964 | if ((flags & SigmaValue) != 0) |
| 965 | contrast=geometry_info.sigma; |
cristy | 02cc0f2 | 2010-01-12 00:02:32 +0000 | [diff] [blame] | 966 | (void) BrightnessContrastImageChannel(*image,channel,brightness, |
| 967 | contrast); |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 968 | InheritException(exception,&(*image)->exception); |
| 969 | break; |
| 970 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 971 | break; |
| 972 | } |
| 973 | case 'c': |
| 974 | { |
| 975 | if (LocaleCompare("cdl",option+1) == 0) |
| 976 | { |
| 977 | char |
| 978 | *color_correction_collection; |
| 979 | |
| 980 | /* |
| 981 | Color correct with a color decision list. |
| 982 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 983 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 984 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 985 | if (color_correction_collection == (char *) NULL) |
| 986 | break; |
| 987 | (void) ColorDecisionListImage(*image,color_correction_collection); |
| 988 | InheritException(exception,&(*image)->exception); |
| 989 | break; |
| 990 | } |
| 991 | if (LocaleCompare("channel",option+1) == 0) |
| 992 | { |
| 993 | if (*option == '+') |
| 994 | { |
| 995 | channel=DefaultChannels; |
| 996 | break; |
| 997 | } |
| 998 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 999 | break; |
| 1000 | } |
| 1001 | if (LocaleCompare("charcoal",option+1) == 0) |
| 1002 | { |
| 1003 | Image |
| 1004 | *charcoal_image; |
| 1005 | |
| 1006 | /* |
| 1007 | Charcoal image. |
| 1008 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1009 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1010 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1011 | if ((flags & SigmaValue) == 0) |
| 1012 | geometry_info.sigma=1.0; |
| 1013 | charcoal_image=CharcoalImage(*image,geometry_info.rho, |
| 1014 | geometry_info.sigma,exception); |
| 1015 | if (charcoal_image == (Image *) NULL) |
| 1016 | break; |
| 1017 | *image=DestroyImage(*image); |
| 1018 | *image=charcoal_image; |
| 1019 | break; |
| 1020 | } |
| 1021 | if (LocaleCompare("chop",option+1) == 0) |
| 1022 | { |
| 1023 | Image |
| 1024 | *chop_image; |
| 1025 | |
| 1026 | /* |
| 1027 | Chop the image. |
| 1028 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1029 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1030 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1031 | chop_image=ChopImage(*image,&geometry,exception); |
| 1032 | if (chop_image == (Image *) NULL) |
| 1033 | break; |
| 1034 | *image=DestroyImage(*image); |
| 1035 | *image=chop_image; |
| 1036 | break; |
| 1037 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 1038 | if (LocaleCompare("clamp",option+1) == 0) |
| 1039 | { |
| 1040 | /* |
| 1041 | Clamp image. |
| 1042 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1043 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 1044 | (void) ClampImageChannel(*image,channel); |
| 1045 | InheritException(exception,&(*image)->exception); |
| 1046 | break; |
| 1047 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1048 | if (LocaleCompare("clip",option+1) == 0) |
| 1049 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1050 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1051 | if (*option == '+') |
| 1052 | { |
| 1053 | (void) SetImageClipMask(*image,(Image *) NULL); |
| 1054 | InheritException(exception,&(*image)->exception); |
| 1055 | break; |
| 1056 | } |
| 1057 | (void) ClipImage(*image); |
| 1058 | InheritException(exception,&(*image)->exception); |
| 1059 | break; |
| 1060 | } |
| 1061 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1062 | { |
| 1063 | Image |
| 1064 | *mask; |
| 1065 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1066 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1067 | y; |
| 1068 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1069 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1070 | x; |
| 1071 | |
| 1072 | register PixelPacket |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 1073 | *restrict q; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1074 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1075 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1076 | if (*option == '+') |
| 1077 | { |
| 1078 | /* |
| 1079 | Remove a mask. |
| 1080 | */ |
| 1081 | (void) SetImageMask(*image,(Image *) NULL); |
| 1082 | InheritException(exception,&(*image)->exception); |
| 1083 | break; |
| 1084 | } |
| 1085 | /* |
| 1086 | Set the image mask. |
| 1087 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1088 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1089 | if (mask == (Image *) NULL) |
| 1090 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1091 | for (y=0; y < (ssize_t) mask->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1092 | { |
| 1093 | q=GetAuthenticPixels(mask,0,y,mask->columns,1,exception); |
| 1094 | if (q == (PixelPacket *) NULL) |
| 1095 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1096 | for (x=0; x < (ssize_t) mask->columns; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1097 | { |
| 1098 | if (mask->matte == MagickFalse) |
| 1099 | q->opacity=PixelIntensityToQuantum(q); |
| 1100 | q->red=q->opacity; |
| 1101 | q->green=q->opacity; |
| 1102 | q->blue=q->opacity; |
| 1103 | q++; |
| 1104 | } |
| 1105 | if (SyncAuthenticPixels(mask,exception) == MagickFalse) |
| 1106 | break; |
| 1107 | } |
| 1108 | if (SetImageStorageClass(mask,DirectClass) == MagickFalse) |
| 1109 | return(MagickFalse); |
| 1110 | mask->matte=MagickTrue; |
| 1111 | (void) SetImageClipMask(*image,mask); |
| 1112 | mask=DestroyImage(mask); |
| 1113 | InheritException(exception,&(*image)->exception); |
| 1114 | break; |
| 1115 | } |
| 1116 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1117 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1118 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1119 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
| 1120 | MagickFalse); |
| 1121 | InheritException(exception,&(*image)->exception); |
| 1122 | break; |
| 1123 | } |
| 1124 | if (LocaleCompare("colorize",option+1) == 0) |
| 1125 | { |
| 1126 | Image |
| 1127 | *colorize_image; |
| 1128 | |
| 1129 | /* |
| 1130 | Colorize the image. |
| 1131 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1132 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1133 | colorize_image=ColorizeImage(*image,argv[i+1],draw_info->fill, |
| 1134 | exception); |
| 1135 | if (colorize_image == (Image *) NULL) |
| 1136 | break; |
| 1137 | *image=DestroyImage(*image); |
| 1138 | *image=colorize_image; |
| 1139 | break; |
| 1140 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1141 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1142 | { |
| 1143 | Image |
| 1144 | *color_image; |
| 1145 | |
| 1146 | KernelInfo |
| 1147 | *kernel; |
| 1148 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1149 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1150 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1151 | if (kernel == (KernelInfo *) NULL) |
| 1152 | break; |
| 1153 | color_image=ColorMatrixImage(*image,kernel,exception); |
| 1154 | kernel=DestroyKernelInfo(kernel); |
| 1155 | if (color_image == (Image *) NULL) |
| 1156 | break; |
| 1157 | *image=DestroyImage(*image); |
| 1158 | *image=color_image; |
| 1159 | break; |
| 1160 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1161 | if (LocaleCompare("colors",option+1) == 0) |
| 1162 | { |
| 1163 | /* |
| 1164 | Reduce the number of colors in the image. |
| 1165 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1166 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1167 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1168 | if (quantize_info->number_colors == 0) |
| 1169 | break; |
| 1170 | if (((*image)->storage_class == DirectClass) || |
| 1171 | (*image)->colors > quantize_info->number_colors) |
| 1172 | (void) QuantizeImage(quantize_info,*image); |
| 1173 | else |
| 1174 | (void) CompressImageColormap(*image); |
| 1175 | InheritException(exception,&(*image)->exception); |
| 1176 | break; |
| 1177 | } |
| 1178 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1179 | { |
| 1180 | ColorspaceType |
| 1181 | colorspace; |
| 1182 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1183 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1184 | if (*option == '+') |
| 1185 | { |
| 1186 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1187 | InheritException(exception,&(*image)->exception); |
| 1188 | break; |
| 1189 | } |
| 1190 | colorspace=(ColorspaceType) ParseMagickOption( |
| 1191 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1192 | (void) TransformImageColorspace(*image,colorspace); |
| 1193 | InheritException(exception,&(*image)->exception); |
| 1194 | break; |
| 1195 | } |
| 1196 | if (LocaleCompare("contrast",option+1) == 0) |
| 1197 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1198 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1199 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
| 1200 | MagickFalse); |
| 1201 | InheritException(exception,&(*image)->exception); |
| 1202 | break; |
| 1203 | } |
| 1204 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1205 | { |
| 1206 | double |
| 1207 | black_point, |
| 1208 | white_point; |
| 1209 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1210 | MagickStatusType |
| 1211 | flags; |
| 1212 | |
| 1213 | /* |
| 1214 | Contrast stretch image. |
| 1215 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1216 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1217 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1218 | black_point=geometry_info.rho; |
| 1219 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1220 | black_point; |
| 1221 | if ((flags & PercentValue) != 0) |
| 1222 | { |
| 1223 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1224 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1225 | } |
| 1226 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1227 | white_point; |
| 1228 | (void) ContrastStretchImageChannel(*image,channel,black_point, |
| 1229 | white_point); |
| 1230 | InheritException(exception,&(*image)->exception); |
| 1231 | break; |
| 1232 | } |
| 1233 | if (LocaleCompare("convolve",option+1) == 0) |
| 1234 | { |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1235 | double |
| 1236 | gamma; |
| 1237 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1238 | Image |
| 1239 | *convolve_image; |
| 1240 | |
cristy | 2be1538 | 2010-01-21 02:38:03 +0000 | [diff] [blame] | 1241 | KernelInfo |
cristy | 56a9e51 | 2010-01-06 18:18:55 +0000 | [diff] [blame] | 1242 | *kernel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1243 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1244 | register ssize_t |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1245 | j; |
| 1246 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1247 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 2be1538 | 2010-01-21 02:38:03 +0000 | [diff] [blame] | 1248 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1249 | if (kernel == (KernelInfo *) NULL) |
cristy | 56a9e51 | 2010-01-06 18:18:55 +0000 | [diff] [blame] | 1250 | break; |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1251 | gamma=0.0; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1252 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1253 | gamma+=kernel->values[j]; |
| 1254 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1255 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1256 | kernel->values[j]*=gamma; |
cristy | 6771f1e | 2010-03-05 19:43:39 +0000 | [diff] [blame] | 1257 | convolve_image=FilterImageChannel(*image,channel,kernel,exception); |
anthony | 83ba99b | 2010-01-24 08:48:15 +0000 | [diff] [blame] | 1258 | kernel=DestroyKernelInfo(kernel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1259 | if (convolve_image == (Image *) NULL) |
| 1260 | break; |
| 1261 | *image=DestroyImage(*image); |
| 1262 | *image=convolve_image; |
| 1263 | break; |
| 1264 | } |
| 1265 | if (LocaleCompare("crop",option+1) == 0) |
| 1266 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1267 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1268 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1269 | if (((geometry.width != 0) || (geometry.height != 0)) && |
| 1270 | ((flags & XValue) == 0) && ((flags & YValue) == 0)) |
| 1271 | break; |
| 1272 | (void) TransformImage(image,argv[i+1],(char *) NULL); |
| 1273 | InheritException(exception,&(*image)->exception); |
| 1274 | break; |
| 1275 | } |
| 1276 | if (LocaleCompare("cycle",option+1) == 0) |
| 1277 | { |
| 1278 | /* |
| 1279 | Cycle an image colormap. |
| 1280 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1281 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1282 | (void) CycleColormapImage(*image,StringToLong(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1283 | InheritException(exception,&(*image)->exception); |
| 1284 | break; |
| 1285 | } |
| 1286 | break; |
| 1287 | } |
| 1288 | case 'd': |
| 1289 | { |
| 1290 | if (LocaleCompare("decipher",option+1) == 0) |
| 1291 | { |
| 1292 | StringInfo |
| 1293 | *passkey; |
| 1294 | |
| 1295 | /* |
| 1296 | Decipher pixels. |
| 1297 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1298 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1299 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1300 | if (passkey != (StringInfo *) NULL) |
| 1301 | { |
| 1302 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1303 | passkey=DestroyStringInfo(passkey); |
| 1304 | } |
| 1305 | break; |
| 1306 | } |
| 1307 | if (LocaleCompare("density",option+1) == 0) |
| 1308 | { |
| 1309 | /* |
| 1310 | Set image density. |
| 1311 | */ |
| 1312 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1313 | break; |
| 1314 | } |
| 1315 | if (LocaleCompare("depth",option+1) == 0) |
| 1316 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1317 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1318 | if (*option == '+') |
| 1319 | { |
| 1320 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1321 | break; |
| 1322 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1323 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1324 | break; |
| 1325 | } |
| 1326 | if (LocaleCompare("deskew",option+1) == 0) |
| 1327 | { |
| 1328 | double |
| 1329 | threshold; |
| 1330 | |
| 1331 | Image |
| 1332 | *deskew_image; |
| 1333 | |
| 1334 | /* |
| 1335 | Straighten the image. |
| 1336 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1337 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1338 | if (*option == '+') |
| 1339 | threshold=40.0*QuantumRange/100.0; |
| 1340 | else |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1341 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1342 | deskew_image=DeskewImage(*image,threshold,exception); |
| 1343 | if (deskew_image == (Image *) NULL) |
| 1344 | break; |
| 1345 | *image=DestroyImage(*image); |
| 1346 | *image=deskew_image; |
| 1347 | break; |
| 1348 | } |
| 1349 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1350 | { |
| 1351 | Image |
| 1352 | *despeckle_image; |
| 1353 | |
| 1354 | /* |
| 1355 | Reduce the speckles within an image. |
| 1356 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1357 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1358 | despeckle_image=DespeckleImage(*image,exception); |
| 1359 | if (despeckle_image == (Image *) NULL) |
| 1360 | break; |
| 1361 | *image=DestroyImage(*image); |
| 1362 | *image=despeckle_image; |
| 1363 | break; |
| 1364 | } |
| 1365 | if (LocaleCompare("display",option+1) == 0) |
| 1366 | { |
| 1367 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1368 | break; |
| 1369 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1370 | if (LocaleCompare("distort",option+1) == 0) |
| 1371 | { |
| 1372 | char |
| 1373 | *args, |
| 1374 | token[MaxTextExtent]; |
| 1375 | |
| 1376 | const char |
| 1377 | *p; |
| 1378 | |
| 1379 | DistortImageMethod |
| 1380 | method; |
| 1381 | |
| 1382 | double |
| 1383 | *arguments; |
| 1384 | |
| 1385 | Image |
| 1386 | *distort_image; |
| 1387 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1388 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1389 | x; |
| 1390 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1391 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1392 | number_arguments; |
| 1393 | |
| 1394 | /* |
| 1395 | Distort image. |
| 1396 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1397 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1398 | method=(DistortImageMethod) ParseMagickOption(MagickDistortOptions, |
| 1399 | MagickFalse,argv[i+1]); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1400 | args=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1401 | InheritException(exception,&(*image)->exception); |
| 1402 | if (args == (char *) NULL) |
| 1403 | break; |
| 1404 | p=(char *) args; |
| 1405 | for (x=0; *p != '\0'; x++) |
| 1406 | { |
| 1407 | GetMagickToken(p,&p,token); |
| 1408 | if (*token == ',') |
| 1409 | GetMagickToken(p,&p,token); |
| 1410 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1411 | number_arguments=(size_t) x; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1412 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1413 | sizeof(*arguments)); |
| 1414 | if (arguments == (double *) NULL) |
| 1415 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1416 | "MemoryAllocationFailed",(*image)->filename); |
| 1417 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1418 | sizeof(*arguments)); |
| 1419 | p=(char *) args; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1420 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1421 | { |
| 1422 | GetMagickToken(p,&p,token); |
| 1423 | if (*token == ',') |
| 1424 | GetMagickToken(p,&p,token); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1425 | arguments[x]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1426 | } |
| 1427 | args=DestroyString(args); |
| 1428 | distort_image=DistortImage(*image,method,number_arguments,arguments, |
| 1429 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1430 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1431 | if (distort_image == (Image *) NULL) |
| 1432 | break; |
| 1433 | *image=DestroyImage(*image); |
| 1434 | *image=distort_image; |
| 1435 | break; |
| 1436 | } |
| 1437 | if (LocaleCompare("dither",option+1) == 0) |
| 1438 | { |
| 1439 | if (*option == '+') |
| 1440 | { |
| 1441 | quantize_info->dither=MagickFalse; |
| 1442 | break; |
| 1443 | } |
| 1444 | quantize_info->dither=MagickTrue; |
| 1445 | quantize_info->dither_method=(DitherMethod) ParseMagickOption( |
| 1446 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1447 | if (quantize_info->dither_method == NoDitherMethod) |
| 1448 | quantize_info->dither=MagickFalse; |
| 1449 | break; |
| 1450 | } |
| 1451 | if (LocaleCompare("draw",option+1) == 0) |
| 1452 | { |
| 1453 | /* |
| 1454 | Draw image. |
| 1455 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1456 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1457 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
| 1458 | (void) DrawImage(*image,draw_info); |
| 1459 | InheritException(exception,&(*image)->exception); |
| 1460 | break; |
| 1461 | } |
| 1462 | break; |
| 1463 | } |
| 1464 | case 'e': |
| 1465 | { |
| 1466 | if (LocaleCompare("edge",option+1) == 0) |
| 1467 | { |
| 1468 | Image |
| 1469 | *edge_image; |
| 1470 | |
| 1471 | /* |
| 1472 | Enhance edges in the image. |
| 1473 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1474 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1475 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1476 | if ((flags & SigmaValue) == 0) |
| 1477 | geometry_info.sigma=1.0; |
| 1478 | edge_image=EdgeImage(*image,geometry_info.rho,exception); |
| 1479 | if (edge_image == (Image *) NULL) |
| 1480 | break; |
| 1481 | *image=DestroyImage(*image); |
| 1482 | *image=edge_image; |
| 1483 | break; |
| 1484 | } |
| 1485 | if (LocaleCompare("emboss",option+1) == 0) |
| 1486 | { |
| 1487 | Image |
| 1488 | *emboss_image; |
| 1489 | |
| 1490 | /* |
| 1491 | Gaussian embossen image. |
| 1492 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1493 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1494 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1495 | if ((flags & SigmaValue) == 0) |
| 1496 | geometry_info.sigma=1.0; |
| 1497 | emboss_image=EmbossImage(*image,geometry_info.rho, |
| 1498 | geometry_info.sigma,exception); |
| 1499 | if (emboss_image == (Image *) NULL) |
| 1500 | break; |
| 1501 | *image=DestroyImage(*image); |
| 1502 | *image=emboss_image; |
| 1503 | break; |
| 1504 | } |
| 1505 | if (LocaleCompare("encipher",option+1) == 0) |
| 1506 | { |
| 1507 | StringInfo |
| 1508 | *passkey; |
| 1509 | |
| 1510 | /* |
| 1511 | Encipher pixels. |
| 1512 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1513 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1514 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1515 | if (passkey != (StringInfo *) NULL) |
| 1516 | { |
| 1517 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1518 | passkey=DestroyStringInfo(passkey); |
| 1519 | } |
| 1520 | break; |
| 1521 | } |
| 1522 | if (LocaleCompare("encoding",option+1) == 0) |
| 1523 | { |
| 1524 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1525 | break; |
| 1526 | } |
| 1527 | if (LocaleCompare("enhance",option+1) == 0) |
| 1528 | { |
| 1529 | Image |
| 1530 | *enhance_image; |
| 1531 | |
| 1532 | /* |
| 1533 | Enhance image. |
| 1534 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1535 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1536 | enhance_image=EnhanceImage(*image,exception); |
| 1537 | if (enhance_image == (Image *) NULL) |
| 1538 | break; |
| 1539 | *image=DestroyImage(*image); |
| 1540 | *image=enhance_image; |
| 1541 | break; |
| 1542 | } |
| 1543 | if (LocaleCompare("equalize",option+1) == 0) |
| 1544 | { |
| 1545 | /* |
| 1546 | Equalize image. |
| 1547 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1548 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1549 | (void) EqualizeImageChannel(*image,channel); |
| 1550 | InheritException(exception,&(*image)->exception); |
| 1551 | break; |
| 1552 | } |
| 1553 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1554 | { |
| 1555 | double |
| 1556 | constant; |
| 1557 | |
| 1558 | MagickEvaluateOperator |
| 1559 | op; |
| 1560 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1561 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1562 | op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions, |
| 1563 | MagickFalse,argv[i+1]); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1564 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1565 | (void) EvaluateImageChannel(*image,channel,op,constant,exception); |
| 1566 | break; |
| 1567 | } |
| 1568 | if (LocaleCompare("extent",option+1) == 0) |
| 1569 | { |
| 1570 | Image |
| 1571 | *extent_image; |
| 1572 | |
| 1573 | /* |
| 1574 | Set the image extent. |
| 1575 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1576 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1577 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
cristy | f0bbfd9 | 2009-11-25 14:12:31 +0000 | [diff] [blame] | 1578 | if (geometry.width == 0) |
cristy | 2ea9a4e | 2009-11-25 14:30:22 +0000 | [diff] [blame] | 1579 | geometry.width=(*image)->columns; |
cristy | f0bbfd9 | 2009-11-25 14:12:31 +0000 | [diff] [blame] | 1580 | if (geometry.height == 0) |
cristy | 2ea9a4e | 2009-11-25 14:30:22 +0000 | [diff] [blame] | 1581 | geometry.height=(*image)->rows; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1582 | geometry.x=(-geometry.x); |
| 1583 | geometry.y=(-geometry.y); |
| 1584 | extent_image=ExtentImage(*image,&geometry,exception); |
| 1585 | if (extent_image == (Image *) NULL) |
| 1586 | break; |
| 1587 | *image=DestroyImage(*image); |
| 1588 | *image=extent_image; |
| 1589 | break; |
| 1590 | } |
| 1591 | break; |
| 1592 | } |
| 1593 | case 'f': |
| 1594 | { |
| 1595 | if (LocaleCompare("family",option+1) == 0) |
| 1596 | { |
| 1597 | if (*option == '+') |
| 1598 | { |
| 1599 | if (draw_info->family != (char *) NULL) |
| 1600 | draw_info->family=DestroyString(draw_info->family); |
| 1601 | break; |
| 1602 | } |
| 1603 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1604 | break; |
| 1605 | } |
cristy | 0fe961c | 2010-01-30 03:09:54 +0000 | [diff] [blame] | 1606 | if (LocaleCompare("features",option+1) == 0) |
| 1607 | { |
| 1608 | if (*option == '+') |
| 1609 | { |
| 1610 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1611 | break; |
| 1612 | } |
| 1613 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1614 | break; |
| 1615 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1616 | if (LocaleCompare("fill",option+1) == 0) |
| 1617 | { |
| 1618 | ExceptionInfo |
| 1619 | *sans; |
| 1620 | |
| 1621 | GetMagickPixelPacket(*image,&fill); |
| 1622 | if (*option == '+') |
| 1623 | { |
| 1624 | (void) QueryMagickColor("none",&fill,exception); |
| 1625 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1626 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1627 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1628 | break; |
| 1629 | } |
| 1630 | sans=AcquireExceptionInfo(); |
| 1631 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1632 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1633 | sans=DestroyExceptionInfo(sans); |
| 1634 | if (status == MagickFalse) |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1635 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1636 | exception); |
| 1637 | break; |
| 1638 | } |
| 1639 | if (LocaleCompare("flip",option+1) == 0) |
| 1640 | { |
| 1641 | Image |
| 1642 | *flip_image; |
| 1643 | |
| 1644 | /* |
| 1645 | Flip image scanlines. |
| 1646 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1647 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1648 | flip_image=FlipImage(*image,exception); |
| 1649 | if (flip_image == (Image *) NULL) |
| 1650 | break; |
| 1651 | *image=DestroyImage(*image); |
| 1652 | *image=flip_image; |
| 1653 | break; |
| 1654 | } |
| 1655 | if (LocaleCompare("flop",option+1) == 0) |
| 1656 | { |
| 1657 | Image |
| 1658 | *flop_image; |
| 1659 | |
| 1660 | /* |
| 1661 | Flop image scanlines. |
| 1662 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1663 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1664 | flop_image=FlopImage(*image,exception); |
| 1665 | if (flop_image == (Image *) NULL) |
| 1666 | break; |
| 1667 | *image=DestroyImage(*image); |
| 1668 | *image=flop_image; |
| 1669 | break; |
| 1670 | } |
| 1671 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1672 | { |
| 1673 | MagickPixelPacket |
| 1674 | target; |
| 1675 | |
| 1676 | /* |
| 1677 | Floodfill image. |
| 1678 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1679 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1680 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1681 | (void) QueryMagickColor(argv[i+2],&target,exception); |
| 1682 | (void) FloodfillPaintImage(*image,channel,draw_info,&target, |
| 1683 | geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue); |
| 1684 | InheritException(exception,&(*image)->exception); |
| 1685 | break; |
| 1686 | } |
| 1687 | if (LocaleCompare("font",option+1) == 0) |
| 1688 | { |
| 1689 | if (*option == '+') |
| 1690 | { |
| 1691 | if (draw_info->font != (char *) NULL) |
| 1692 | draw_info->font=DestroyString(draw_info->font); |
| 1693 | break; |
| 1694 | } |
| 1695 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1696 | break; |
| 1697 | } |
| 1698 | if (LocaleCompare("format",option+1) == 0) |
| 1699 | { |
| 1700 | format=argv[i+1]; |
| 1701 | break; |
| 1702 | } |
| 1703 | if (LocaleCompare("frame",option+1) == 0) |
| 1704 | { |
| 1705 | FrameInfo |
| 1706 | frame_info; |
| 1707 | |
| 1708 | Image |
| 1709 | *frame_image; |
| 1710 | |
| 1711 | /* |
| 1712 | Surround image with an ornamental border. |
| 1713 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1714 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1715 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1716 | frame_info.width=geometry.width; |
| 1717 | frame_info.height=geometry.height; |
| 1718 | if ((flags & HeightValue) == 0) |
| 1719 | frame_info.height=geometry.width; |
| 1720 | frame_info.outer_bevel=geometry.x; |
| 1721 | frame_info.inner_bevel=geometry.y; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1722 | frame_info.x=(ssize_t) frame_info.width; |
| 1723 | frame_info.y=(ssize_t) frame_info.height; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1724 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1725 | frame_info.height=(*image)->rows+2*frame_info.height; |
| 1726 | frame_image=FrameImage(*image,&frame_info,exception); |
| 1727 | if (frame_image == (Image *) NULL) |
| 1728 | break; |
| 1729 | *image=DestroyImage(*image); |
| 1730 | *image=frame_image; |
| 1731 | break; |
| 1732 | } |
| 1733 | if (LocaleCompare("function",option+1) == 0) |
| 1734 | { |
| 1735 | char |
| 1736 | *arguments, |
| 1737 | token[MaxTextExtent]; |
| 1738 | |
| 1739 | const char |
| 1740 | *p; |
| 1741 | |
| 1742 | double |
| 1743 | *parameters; |
| 1744 | |
| 1745 | MagickFunction |
| 1746 | function; |
| 1747 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1748 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1749 | x; |
| 1750 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1751 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1752 | number_parameters; |
| 1753 | |
| 1754 | /* |
| 1755 | Function Modify Image Values |
| 1756 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1757 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1758 | function=(MagickFunction) ParseMagickOption(MagickFunctionOptions, |
| 1759 | MagickFalse,argv[i+1]); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1760 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1761 | InheritException(exception,&(*image)->exception); |
| 1762 | if (arguments == (char *) NULL) |
| 1763 | break; |
| 1764 | p=(char *) arguments; |
| 1765 | for (x=0; *p != '\0'; x++) |
| 1766 | { |
| 1767 | GetMagickToken(p,&p,token); |
| 1768 | if (*token == ',') |
| 1769 | GetMagickToken(p,&p,token); |
| 1770 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1771 | number_parameters=(size_t) x; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1772 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1773 | sizeof(*parameters)); |
| 1774 | if (parameters == (double *) NULL) |
| 1775 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1776 | "MemoryAllocationFailed",(*image)->filename); |
| 1777 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1778 | sizeof(*parameters)); |
| 1779 | p=(char *) arguments; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1780 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1781 | { |
| 1782 | GetMagickToken(p,&p,token); |
| 1783 | if (*token == ',') |
| 1784 | GetMagickToken(p,&p,token); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1785 | parameters[x]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1786 | } |
| 1787 | arguments=DestroyString(arguments); |
| 1788 | (void) FunctionImageChannel(*image,channel,function, |
| 1789 | number_parameters,parameters,exception); |
| 1790 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1791 | break; |
| 1792 | } |
| 1793 | break; |
| 1794 | } |
| 1795 | case 'g': |
| 1796 | { |
| 1797 | if (LocaleCompare("gamma",option+1) == 0) |
| 1798 | { |
| 1799 | /* |
| 1800 | Gamma image. |
| 1801 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1802 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1803 | if (*option == '+') |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1804 | (*image)->gamma=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1805 | else |
| 1806 | { |
| 1807 | if (strchr(argv[i+1],',') != (char *) NULL) |
| 1808 | (void) GammaImage(*image,argv[i+1]); |
| 1809 | else |
cristy | a5447be | 2010-01-11 00:20:51 +0000 | [diff] [blame] | 1810 | (void) GammaImageChannel(*image,channel, |
| 1811 | StringToDouble(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1812 | InheritException(exception,&(*image)->exception); |
| 1813 | } |
| 1814 | break; |
| 1815 | } |
| 1816 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1817 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1818 | { |
| 1819 | Image |
| 1820 | *gaussian_image; |
| 1821 | |
| 1822 | /* |
| 1823 | Gaussian blur image. |
| 1824 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1825 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1826 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1827 | if ((flags & SigmaValue) == 0) |
| 1828 | geometry_info.sigma=1.0; |
| 1829 | gaussian_image=GaussianBlurImageChannel(*image,channel, |
| 1830 | geometry_info.rho,geometry_info.sigma,exception); |
| 1831 | if (gaussian_image == (Image *) NULL) |
| 1832 | break; |
| 1833 | *image=DestroyImage(*image); |
| 1834 | *image=gaussian_image; |
| 1835 | break; |
| 1836 | } |
| 1837 | if (LocaleCompare("geometry",option+1) == 0) |
| 1838 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1839 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1840 | if (*option == '+') |
| 1841 | { |
| 1842 | if ((*image)->geometry != (char *) NULL) |
| 1843 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1844 | break; |
| 1845 | } |
| 1846 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1847 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1848 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1849 | else |
| 1850 | { |
| 1851 | Image |
| 1852 | *zoom_image; |
| 1853 | |
| 1854 | /* |
| 1855 | Resize image. |
| 1856 | */ |
| 1857 | zoom_image=ZoomImage(*image,geometry.width,geometry.height, |
| 1858 | exception); |
| 1859 | if (zoom_image == (Image *) NULL) |
| 1860 | break; |
| 1861 | *image=DestroyImage(*image); |
| 1862 | *image=zoom_image; |
| 1863 | } |
| 1864 | break; |
| 1865 | } |
| 1866 | if (LocaleCompare("gravity",option+1) == 0) |
| 1867 | { |
| 1868 | if (*option == '+') |
| 1869 | { |
| 1870 | draw_info->gravity=UndefinedGravity; |
| 1871 | break; |
| 1872 | } |
| 1873 | draw_info->gravity=(GravityType) ParseMagickOption( |
| 1874 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1875 | break; |
| 1876 | } |
| 1877 | break; |
| 1878 | } |
| 1879 | case 'h': |
| 1880 | { |
| 1881 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1882 | { |
| 1883 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1884 | break; |
| 1885 | } |
| 1886 | break; |
| 1887 | } |
| 1888 | case 'i': |
| 1889 | { |
| 1890 | if (LocaleCompare("identify",option+1) == 0) |
| 1891 | { |
| 1892 | char |
| 1893 | *text; |
| 1894 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1895 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1896 | if (format == (char *) NULL) |
| 1897 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1898 | (void) IdentifyImage(*image,stdout,mogrify_info->verbose); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1899 | InheritException(exception,&(*image)->exception); |
| 1900 | break; |
| 1901 | } |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1902 | text=InterpretImageProperties(mogrify_info,*image,format); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1903 | InheritException(exception,&(*image)->exception); |
| 1904 | if (text == (char *) NULL) |
| 1905 | break; |
| 1906 | (void) fputs(text,stdout); |
| 1907 | (void) fputc('\n',stdout); |
| 1908 | text=DestroyString(text); |
| 1909 | break; |
| 1910 | } |
| 1911 | if (LocaleCompare("implode",option+1) == 0) |
| 1912 | { |
| 1913 | Image |
| 1914 | *implode_image; |
| 1915 | |
| 1916 | /* |
| 1917 | Implode image. |
| 1918 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1919 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1920 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1921 | implode_image=ImplodeImage(*image,geometry_info.rho,exception); |
| 1922 | if (implode_image == (Image *) NULL) |
| 1923 | break; |
| 1924 | *image=DestroyImage(*image); |
| 1925 | *image=implode_image; |
| 1926 | break; |
| 1927 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 1928 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1929 | { |
| 1930 | if (*option == '+') |
| 1931 | (void) ParseGeometry("0",&geometry_info); |
| 1932 | else |
| 1933 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1934 | draw_info->interline_spacing=geometry_info.rho; |
| 1935 | break; |
| 1936 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1937 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1938 | { |
| 1939 | if (*option == '+') |
| 1940 | (void) ParseGeometry("0",&geometry_info); |
| 1941 | else |
| 1942 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1943 | draw_info->interword_spacing=geometry_info.rho; |
| 1944 | break; |
| 1945 | } |
| 1946 | break; |
| 1947 | } |
| 1948 | case 'k': |
| 1949 | { |
| 1950 | if (LocaleCompare("kerning",option+1) == 0) |
| 1951 | { |
| 1952 | if (*option == '+') |
| 1953 | (void) ParseGeometry("0",&geometry_info); |
| 1954 | else |
| 1955 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1956 | draw_info->kerning=geometry_info.rho; |
| 1957 | break; |
| 1958 | } |
| 1959 | break; |
| 1960 | } |
| 1961 | case 'l': |
| 1962 | { |
| 1963 | if (LocaleCompare("lat",option+1) == 0) |
| 1964 | { |
| 1965 | Image |
| 1966 | *threshold_image; |
| 1967 | |
| 1968 | /* |
| 1969 | Local adaptive threshold image. |
| 1970 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1971 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1972 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1973 | if ((flags & PercentValue) != 0) |
| 1974 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1975 | threshold_image=AdaptiveThresholdImage(*image,(size_t) |
| 1976 | geometry_info.rho,(size_t) geometry_info.sigma, |
| 1977 | (ssize_t) geometry_info.xi,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1978 | if (threshold_image == (Image *) NULL) |
| 1979 | break; |
| 1980 | *image=DestroyImage(*image); |
| 1981 | *image=threshold_image; |
| 1982 | break; |
| 1983 | } |
| 1984 | if (LocaleCompare("level",option+1) == 0) |
| 1985 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1986 | MagickRealType |
| 1987 | black_point, |
| 1988 | gamma, |
| 1989 | white_point; |
| 1990 | |
| 1991 | MagickStatusType |
| 1992 | flags; |
| 1993 | |
| 1994 | /* |
| 1995 | Parse levels. |
| 1996 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 1997 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1998 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1999 | black_point=geometry_info.rho; |
| 2000 | white_point=(MagickRealType) QuantumRange; |
| 2001 | if ((flags & SigmaValue) != 0) |
| 2002 | white_point=geometry_info.sigma; |
| 2003 | gamma=1.0; |
| 2004 | if ((flags & XiValue) != 0) |
| 2005 | gamma=geometry_info.xi; |
| 2006 | if ((flags & PercentValue) != 0) |
| 2007 | { |
| 2008 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 2009 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 2010 | } |
| 2011 | if ((flags & SigmaValue) == 0) |
| 2012 | white_point=(MagickRealType) QuantumRange-black_point; |
| 2013 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
| 2014 | (void) LevelizeImageChannel(*image,channel,black_point, |
| 2015 | white_point,gamma); |
| 2016 | else |
| 2017 | (void) LevelImageChannel(*image,channel,black_point,white_point, |
| 2018 | gamma); |
| 2019 | InheritException(exception,&(*image)->exception); |
| 2020 | break; |
| 2021 | } |
| 2022 | if (LocaleCompare("level-colors",option+1) == 0) |
| 2023 | { |
| 2024 | char |
| 2025 | token[MaxTextExtent]; |
| 2026 | |
| 2027 | const char |
| 2028 | *p; |
| 2029 | |
| 2030 | MagickPixelPacket |
| 2031 | black_point, |
| 2032 | white_point; |
| 2033 | |
| 2034 | p=(const char *) argv[i+1]; |
| 2035 | GetMagickToken(p,&p,token); /* get black point color */ |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2036 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2037 | (void) QueryMagickColor(token,&black_point,exception); |
| 2038 | else |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2039 | (void) QueryMagickColor("#000000",&black_point,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2040 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 2041 | GetMagickToken(p,&p,token); |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2042 | if (*token == '\0') |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2043 | white_point=black_point; /* set everything to that color */ |
| 2044 | else |
| 2045 | { |
| 2046 | /* |
| 2047 | Get white point color. |
| 2048 | */ |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2049 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2050 | GetMagickToken(p,&p,token); |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2051 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2052 | (void) QueryMagickColor(token,&white_point,exception); |
| 2053 | else |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2054 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2055 | } |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 2056 | (void) LevelColorsImageChannel(*image,channel,&black_point, |
| 2057 | &white_point,*option == '+' ? MagickTrue : MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2058 | break; |
| 2059 | } |
| 2060 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 2061 | { |
| 2062 | double |
| 2063 | black_point, |
| 2064 | white_point; |
| 2065 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2066 | MagickStatusType |
| 2067 | flags; |
| 2068 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2069 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2070 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2071 | black_point=geometry_info.rho; |
| 2072 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 2073 | if ((flags & SigmaValue) != 0) |
| 2074 | white_point=geometry_info.sigma; |
| 2075 | if ((flags & PercentValue) != 0) |
| 2076 | { |
| 2077 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 2078 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 2079 | } |
| 2080 | if ((flags & SigmaValue) == 0) |
| 2081 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 2082 | black_point; |
| 2083 | (void) LinearStretchImage(*image,black_point,white_point); |
| 2084 | InheritException(exception,&(*image)->exception); |
| 2085 | break; |
| 2086 | } |
| 2087 | if (LocaleCompare("linewidth",option+1) == 0) |
| 2088 | { |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2089 | draw_info->stroke_width=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2090 | break; |
| 2091 | } |
| 2092 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 2093 | { |
| 2094 | Image |
| 2095 | *resize_image; |
| 2096 | |
| 2097 | /* |
| 2098 | Liquid rescale image. |
| 2099 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2100 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2101 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2102 | if ((flags & XValue) == 0) |
| 2103 | geometry.x=1; |
| 2104 | if ((flags & YValue) == 0) |
| 2105 | geometry.y=0; |
| 2106 | resize_image=LiquidRescaleImage(*image,geometry.width, |
| 2107 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 2108 | if (resize_image == (Image *) NULL) |
| 2109 | break; |
| 2110 | *image=DestroyImage(*image); |
| 2111 | *image=resize_image; |
| 2112 | break; |
| 2113 | } |
| 2114 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 2115 | { |
| 2116 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 2117 | break; |
| 2118 | } |
| 2119 | break; |
| 2120 | } |
| 2121 | case 'm': |
| 2122 | { |
| 2123 | if (LocaleCompare("map",option+1) == 0) |
| 2124 | { |
| 2125 | Image |
| 2126 | *remap_image; |
| 2127 | |
| 2128 | /* |
| 2129 | Transform image colors to match this set of colors. |
| 2130 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2131 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2132 | if (*option == '+') |
| 2133 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2134 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2135 | if (remap_image == (Image *) NULL) |
| 2136 | break; |
| 2137 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2138 | InheritException(exception,&(*image)->exception); |
| 2139 | remap_image=DestroyImage(remap_image); |
| 2140 | break; |
| 2141 | } |
| 2142 | if (LocaleCompare("mask",option+1) == 0) |
| 2143 | { |
| 2144 | Image |
| 2145 | *mask; |
| 2146 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2147 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2148 | if (*option == '+') |
| 2149 | { |
| 2150 | /* |
| 2151 | Remove a mask. |
| 2152 | */ |
| 2153 | (void) SetImageMask(*image,(Image *) NULL); |
| 2154 | InheritException(exception,&(*image)->exception); |
| 2155 | break; |
| 2156 | } |
| 2157 | /* |
| 2158 | Set the image mask. |
| 2159 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2160 | mask=GetImageCache(mogrify_info,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2161 | if (mask == (Image *) NULL) |
| 2162 | break; |
| 2163 | (void) SetImageMask(*image,mask); |
| 2164 | mask=DestroyImage(mask); |
| 2165 | InheritException(exception,&(*image)->exception); |
| 2166 | break; |
| 2167 | } |
| 2168 | if (LocaleCompare("matte",option+1) == 0) |
| 2169 | { |
| 2170 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
| 2171 | SetAlphaChannel : DeactivateAlphaChannel ); |
| 2172 | InheritException(exception,&(*image)->exception); |
| 2173 | break; |
| 2174 | } |
| 2175 | if (LocaleCompare("median",option+1) == 0) |
| 2176 | { |
| 2177 | Image |
| 2178 | *median_image; |
| 2179 | |
| 2180 | /* |
| 2181 | Median filter image. |
| 2182 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2183 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2184 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2185 | median_image=MedianFilterImage(*image,geometry_info.rho,exception); |
| 2186 | if (median_image == (Image *) NULL) |
| 2187 | break; |
| 2188 | *image=DestroyImage(*image); |
| 2189 | *image=median_image; |
| 2190 | break; |
| 2191 | } |
| 2192 | if (LocaleCompare("modulate",option+1) == 0) |
| 2193 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2194 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2195 | (void) ModulateImage(*image,argv[i+1]); |
| 2196 | InheritException(exception,&(*image)->exception); |
| 2197 | break; |
| 2198 | } |
| 2199 | if (LocaleCompare("monitor",option+1) == 0) |
| 2200 | { |
cristy | 7d34ef2 | 2010-03-25 01:11:22 +0000 | [diff] [blame] | 2201 | if (*option == '+') |
| 2202 | { |
| 2203 | (void) SetImageProgressMonitor(*image, |
| 2204 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2205 | break; |
| 2206 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2207 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2208 | (void *) NULL); |
| 2209 | break; |
| 2210 | } |
| 2211 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2212 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2213 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2214 | (void) SetImageType(*image,BilevelType); |
| 2215 | InheritException(exception,&(*image)->exception); |
| 2216 | break; |
| 2217 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2218 | if (LocaleCompare("morphology",option+1) == 0) |
| 2219 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2220 | char |
| 2221 | token[MaxTextExtent]; |
| 2222 | |
| 2223 | const char |
| 2224 | *p; |
| 2225 | |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2226 | Image |
| 2227 | *morphology_image; |
| 2228 | |
| 2229 | KernelInfo |
| 2230 | *kernel; |
| 2231 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2232 | ssize_t |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2233 | iterations; |
| 2234 | |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2235 | MorphologyMethod |
| 2236 | method; |
| 2237 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2238 | /* |
| 2239 | Morphological Image Operation |
| 2240 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2241 | (void) SyncImageSettings(mogrify_info,*image); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2242 | p=argv[i+1]; |
| 2243 | GetMagickToken(p,&p,token); |
| 2244 | method=(MorphologyMethod) ParseMagickOption(MagickMorphologyOptions, |
cristy | d2c1e1e | 2010-05-08 01:05:44 +0000 | [diff] [blame] | 2245 | MagickFalse,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2246 | iterations=1L; |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2247 | GetMagickToken(p,&p,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2248 | if ((*p == ':') || (*p == ',')) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2249 | GetMagickToken(p,&p,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2250 | if ((*p != '\0')) |
| 2251 | iterations=StringToLong(p); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2252 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2253 | if (kernel == (KernelInfo *) NULL) |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2254 | { |
| 2255 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2256 | OptionError,"UnabletoParseKernel","morphology"); |
| 2257 | status=MagickFalse; |
| 2258 | break; |
| 2259 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2260 | morphology_image=MorphologyImageChannel(*image,channel,method, |
cristy | 02d5b4f | 2010-02-01 01:08:27 +0000 | [diff] [blame] | 2261 | iterations,kernel,exception); |
anthony | 83ba99b | 2010-01-24 08:48:15 +0000 | [diff] [blame] | 2262 | kernel=DestroyKernelInfo(kernel); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2263 | if (morphology_image == (Image *) NULL) |
| 2264 | break; |
| 2265 | *image=DestroyImage(*image); |
| 2266 | *image=morphology_image; |
| 2267 | break; |
| 2268 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2269 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2270 | { |
| 2271 | Image |
| 2272 | *blur_image; |
| 2273 | |
| 2274 | /* |
| 2275 | Motion blur image. |
| 2276 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2277 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2278 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2279 | if ((flags & SigmaValue) == 0) |
| 2280 | geometry_info.sigma=1.0; |
| 2281 | blur_image=MotionBlurImageChannel(*image,channel,geometry_info.rho, |
| 2282 | geometry_info.sigma,geometry_info.xi,exception); |
| 2283 | if (blur_image == (Image *) NULL) |
| 2284 | break; |
| 2285 | *image=DestroyImage(*image); |
| 2286 | *image=blur_image; |
| 2287 | break; |
| 2288 | } |
| 2289 | break; |
| 2290 | } |
| 2291 | case 'n': |
| 2292 | { |
| 2293 | if (LocaleCompare("negate",option+1) == 0) |
| 2294 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2295 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2296 | (void) NegateImageChannel(*image,channel,*option == '+' ? |
| 2297 | MagickTrue : MagickFalse); |
| 2298 | InheritException(exception,&(*image)->exception); |
| 2299 | break; |
| 2300 | } |
| 2301 | if (LocaleCompare("noise",option+1) == 0) |
| 2302 | { |
| 2303 | Image |
| 2304 | *noisy_image; |
| 2305 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2306 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2307 | if (*option == '-') |
| 2308 | { |
| 2309 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2310 | noisy_image=ReduceNoiseImage(*image,geometry_info.rho, |
| 2311 | exception); |
| 2312 | } |
| 2313 | else |
| 2314 | { |
| 2315 | NoiseType |
| 2316 | noise; |
| 2317 | |
| 2318 | noise=(NoiseType) ParseMagickOption(MagickNoiseOptions, |
| 2319 | MagickFalse,argv[i+1]); |
| 2320 | noisy_image=AddNoiseImageChannel(*image,channel,noise, |
| 2321 | exception); |
| 2322 | } |
| 2323 | if (noisy_image == (Image *) NULL) |
| 2324 | break; |
| 2325 | *image=DestroyImage(*image); |
| 2326 | *image=noisy_image; |
| 2327 | break; |
| 2328 | } |
| 2329 | if (LocaleCompare("normalize",option+1) == 0) |
| 2330 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2331 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2332 | (void) NormalizeImageChannel(*image,channel); |
| 2333 | InheritException(exception,&(*image)->exception); |
| 2334 | break; |
| 2335 | } |
| 2336 | break; |
| 2337 | } |
| 2338 | case 'o': |
| 2339 | { |
| 2340 | if (LocaleCompare("opaque",option+1) == 0) |
| 2341 | { |
| 2342 | MagickPixelPacket |
| 2343 | target; |
| 2344 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2345 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2346 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2347 | (void) OpaquePaintImageChannel(*image,channel,&target,&fill, |
| 2348 | *option == '-' ? MagickFalse : MagickTrue); |
| 2349 | break; |
| 2350 | } |
| 2351 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2352 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2353 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2354 | (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1], |
| 2355 | exception); |
| 2356 | break; |
| 2357 | } |
| 2358 | break; |
| 2359 | } |
| 2360 | case 'p': |
| 2361 | { |
| 2362 | if (LocaleCompare("paint",option+1) == 0) |
| 2363 | { |
| 2364 | Image |
| 2365 | *paint_image; |
| 2366 | |
| 2367 | /* |
| 2368 | Oil paint image. |
| 2369 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2370 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2371 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2372 | paint_image=OilPaintImage(*image,geometry_info.rho,exception); |
| 2373 | if (paint_image == (Image *) NULL) |
| 2374 | break; |
| 2375 | *image=DestroyImage(*image); |
| 2376 | *image=paint_image; |
| 2377 | break; |
| 2378 | } |
| 2379 | if (LocaleCompare("pen",option+1) == 0) |
| 2380 | { |
| 2381 | if (*option == '+') |
| 2382 | { |
| 2383 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2384 | break; |
| 2385 | } |
| 2386 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2387 | break; |
| 2388 | } |
| 2389 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2390 | { |
| 2391 | if (*option == '+') |
| 2392 | (void) ParseGeometry("12",&geometry_info); |
| 2393 | else |
| 2394 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2395 | draw_info->pointsize=geometry_info.rho; |
| 2396 | break; |
| 2397 | } |
| 2398 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2399 | { |
| 2400 | double |
| 2401 | angle; |
| 2402 | |
| 2403 | Image |
| 2404 | *polaroid_image; |
| 2405 | |
| 2406 | RandomInfo |
| 2407 | *random_info; |
| 2408 | |
| 2409 | /* |
| 2410 | Simulate a Polaroid picture. |
| 2411 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2412 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2413 | random_info=AcquireRandomInfo(); |
| 2414 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2415 | random_info=DestroyRandomInfo(random_info); |
| 2416 | if (*option == '-') |
| 2417 | { |
| 2418 | SetGeometryInfo(&geometry_info); |
| 2419 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2420 | angle=geometry_info.rho; |
| 2421 | } |
| 2422 | polaroid_image=PolaroidImage(*image,draw_info,angle,exception); |
| 2423 | if (polaroid_image == (Image *) NULL) |
| 2424 | break; |
| 2425 | *image=DestroyImage(*image); |
| 2426 | *image=polaroid_image; |
| 2427 | break; |
| 2428 | } |
| 2429 | if (LocaleCompare("posterize",option+1) == 0) |
| 2430 | { |
| 2431 | /* |
| 2432 | Posterize image. |
| 2433 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2434 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 2435 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2436 | quantize_info->dither); |
| 2437 | InheritException(exception,&(*image)->exception); |
| 2438 | break; |
| 2439 | } |
| 2440 | if (LocaleCompare("preview",option+1) == 0) |
| 2441 | { |
| 2442 | Image |
| 2443 | *preview_image; |
| 2444 | |
| 2445 | PreviewType |
| 2446 | preview_type; |
| 2447 | |
| 2448 | /* |
| 2449 | Preview image. |
| 2450 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2451 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2452 | if (*option == '+') |
| 2453 | preview_type=UndefinedPreview; |
| 2454 | else |
| 2455 | preview_type=(PreviewType) ParseMagickOption(MagickPreviewOptions, |
| 2456 | MagickFalse,argv[i+1]); |
| 2457 | preview_image=PreviewImage(*image,preview_type,exception); |
| 2458 | if (preview_image == (Image *) NULL) |
| 2459 | break; |
| 2460 | *image=DestroyImage(*image); |
| 2461 | *image=preview_image; |
| 2462 | break; |
| 2463 | } |
| 2464 | if (LocaleCompare("profile",option+1) == 0) |
| 2465 | { |
| 2466 | const char |
| 2467 | *name; |
| 2468 | |
| 2469 | const StringInfo |
| 2470 | *profile; |
| 2471 | |
| 2472 | Image |
| 2473 | *profile_image; |
| 2474 | |
| 2475 | ImageInfo |
| 2476 | *profile_info; |
| 2477 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2478 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2479 | if (*option == '+') |
| 2480 | { |
| 2481 | /* |
| 2482 | Remove a profile from the image. |
| 2483 | */ |
| 2484 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2485 | NULL,0,MagickTrue); |
| 2486 | InheritException(exception,&(*image)->exception); |
| 2487 | break; |
| 2488 | } |
| 2489 | /* |
| 2490 | Associate a profile with the image. |
| 2491 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2492 | profile_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2493 | profile=GetImageProfile(*image,"iptc"); |
| 2494 | if (profile != (StringInfo *) NULL) |
| 2495 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2496 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2497 | profile_info=DestroyImageInfo(profile_info); |
| 2498 | if (profile_image == (Image *) NULL) |
| 2499 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2500 | StringInfo |
| 2501 | *profile; |
| 2502 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2503 | profile_info=CloneImageInfo(mogrify_info); |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2504 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2505 | MaxTextExtent); |
| 2506 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2507 | if (profile != (StringInfo *) NULL) |
| 2508 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2509 | (void) ProfileImage(*image,profile_info->magick, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2510 | GetStringInfoDatum(profile),(size_t) |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2511 | GetStringInfoLength(profile),MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2512 | profile=DestroyStringInfo(profile); |
| 2513 | } |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2514 | profile_info=DestroyImageInfo(profile_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2515 | break; |
| 2516 | } |
| 2517 | ResetImageProfileIterator(profile_image); |
| 2518 | name=GetNextImageProfile(profile_image); |
| 2519 | while (name != (const char *) NULL) |
| 2520 | { |
| 2521 | profile=GetImageProfile(profile_image,name); |
| 2522 | if (profile != (StringInfo *) NULL) |
| 2523 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2524 | (size_t) GetStringInfoLength(profile),MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2525 | name=GetNextImageProfile(profile_image); |
| 2526 | } |
| 2527 | profile_image=DestroyImage(profile_image); |
| 2528 | break; |
| 2529 | } |
| 2530 | break; |
| 2531 | } |
| 2532 | case 'q': |
| 2533 | { |
| 2534 | if (LocaleCompare("quantize",option+1) == 0) |
| 2535 | { |
| 2536 | if (*option == '+') |
| 2537 | { |
| 2538 | quantize_info->colorspace=UndefinedColorspace; |
| 2539 | break; |
| 2540 | } |
| 2541 | quantize_info->colorspace=(ColorspaceType) ParseMagickOption( |
| 2542 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2543 | break; |
| 2544 | } |
| 2545 | break; |
| 2546 | } |
| 2547 | case 'r': |
| 2548 | { |
| 2549 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2550 | { |
| 2551 | Image |
| 2552 | *blur_image; |
| 2553 | |
| 2554 | /* |
| 2555 | Radial blur image. |
| 2556 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2557 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | a5447be | 2010-01-11 00:20:51 +0000 | [diff] [blame] | 2558 | blur_image=RadialBlurImageChannel(*image,channel, |
| 2559 | StringToDouble(argv[i+1]),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2560 | if (blur_image == (Image *) NULL) |
| 2561 | break; |
| 2562 | *image=DestroyImage(*image); |
| 2563 | *image=blur_image; |
| 2564 | break; |
| 2565 | } |
| 2566 | if (LocaleCompare("raise",option+1) == 0) |
| 2567 | { |
| 2568 | /* |
| 2569 | Surround image with a raise of solid color. |
| 2570 | */ |
| 2571 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2572 | if ((flags & SigmaValue) == 0) |
| 2573 | geometry.height=geometry.width; |
| 2574 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
| 2575 | MagickFalse); |
| 2576 | InheritException(exception,&(*image)->exception); |
| 2577 | break; |
| 2578 | } |
| 2579 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2580 | { |
| 2581 | /* |
| 2582 | Threshold image. |
| 2583 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2584 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2585 | (void) RandomThresholdImageChannel(*image,channel,argv[i+1], |
| 2586 | exception); |
| 2587 | break; |
| 2588 | } |
| 2589 | if (LocaleCompare("recolor",option+1) == 0) |
| 2590 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2591 | Image |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2592 | *color_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2593 | |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2594 | KernelInfo |
| 2595 | *kernel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2596 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2597 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2598 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2599 | if (kernel == (KernelInfo *) NULL) |
| 2600 | break; |
| 2601 | color_image=ColorMatrixImage(*image,kernel,exception); |
| 2602 | kernel=DestroyKernelInfo(kernel); |
| 2603 | if (color_image == (Image *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2604 | break; |
| 2605 | *image=DestroyImage(*image); |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2606 | *image=color_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2607 | break; |
| 2608 | } |
| 2609 | if (LocaleCompare("region",option+1) == 0) |
| 2610 | { |
| 2611 | Image |
| 2612 | *crop_image; |
| 2613 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2614 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2615 | if (region_image != (Image *) NULL) |
| 2616 | { |
| 2617 | /* |
| 2618 | Composite region. |
| 2619 | */ |
| 2620 | (void) CompositeImage(region_image,(*image)->matte != |
| 2621 | MagickFalse ? OverCompositeOp : CopyCompositeOp,*image, |
| 2622 | region_geometry.x,region_geometry.y); |
| 2623 | InheritException(exception,®ion_image->exception); |
| 2624 | *image=DestroyImage(*image); |
| 2625 | *image=region_image; |
| 2626 | } |
| 2627 | if (*option == '+') |
| 2628 | { |
| 2629 | if (region_image != (Image *) NULL) |
| 2630 | region_image=DestroyImage(region_image); |
| 2631 | break; |
| 2632 | } |
| 2633 | /* |
| 2634 | Apply transformations to a selected region of the image. |
| 2635 | */ |
| 2636 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2637 | exception); |
| 2638 | crop_image=CropImage(*image,®ion_geometry,exception); |
| 2639 | if (crop_image == (Image *) NULL) |
| 2640 | break; |
| 2641 | region_image=(*image); |
| 2642 | *image=crop_image; |
| 2643 | break; |
| 2644 | } |
| 2645 | if (LocaleCompare("render",option+1) == 0) |
| 2646 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2647 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2648 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2649 | break; |
| 2650 | } |
| 2651 | if (LocaleCompare("remap",option+1) == 0) |
| 2652 | { |
| 2653 | Image |
| 2654 | *remap_image; |
| 2655 | |
| 2656 | /* |
| 2657 | Transform image colors to match this set of colors. |
| 2658 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2659 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2660 | if (*option == '+') |
| 2661 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2662 | remap_image=GetImageCache(mogrify_info,argv[i+1],exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2663 | if (remap_image == (Image *) NULL) |
| 2664 | break; |
| 2665 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2666 | InheritException(exception,&(*image)->exception); |
| 2667 | remap_image=DestroyImage(remap_image); |
| 2668 | break; |
| 2669 | } |
| 2670 | if (LocaleCompare("repage",option+1) == 0) |
| 2671 | { |
| 2672 | if (*option == '+') |
| 2673 | { |
| 2674 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2675 | break; |
| 2676 | } |
| 2677 | (void) ResetImagePage(*image,argv[i+1]); |
| 2678 | InheritException(exception,&(*image)->exception); |
| 2679 | break; |
| 2680 | } |
| 2681 | if (LocaleCompare("resample",option+1) == 0) |
| 2682 | { |
| 2683 | Image |
| 2684 | *resample_image; |
| 2685 | |
| 2686 | /* |
| 2687 | Resample image. |
| 2688 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2689 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2690 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2691 | if ((flags & SigmaValue) == 0) |
| 2692 | geometry_info.sigma=geometry_info.rho; |
| 2693 | resample_image=ResampleImage(*image,geometry_info.rho, |
| 2694 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2695 | if (resample_image == (Image *) NULL) |
| 2696 | break; |
| 2697 | *image=DestroyImage(*image); |
| 2698 | *image=resample_image; |
| 2699 | break; |
| 2700 | } |
| 2701 | if (LocaleCompare("resize",option+1) == 0) |
| 2702 | { |
| 2703 | Image |
| 2704 | *resize_image; |
| 2705 | |
| 2706 | /* |
| 2707 | Resize image. |
| 2708 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2709 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2710 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2711 | resize_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2712 | (*image)->filter,(*image)->blur,exception); |
| 2713 | if (resize_image == (Image *) NULL) |
| 2714 | break; |
| 2715 | *image=DestroyImage(*image); |
| 2716 | *image=resize_image; |
| 2717 | break; |
| 2718 | } |
| 2719 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 2720 | { |
| 2721 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 2722 | break; |
| 2723 | } |
| 2724 | if (LocaleCompare("roll",option+1) == 0) |
| 2725 | { |
| 2726 | Image |
| 2727 | *roll_image; |
| 2728 | |
| 2729 | /* |
| 2730 | Roll image. |
| 2731 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2732 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2733 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2734 | roll_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2735 | if (roll_image == (Image *) NULL) |
| 2736 | break; |
| 2737 | *image=DestroyImage(*image); |
| 2738 | *image=roll_image; |
| 2739 | break; |
| 2740 | } |
| 2741 | if (LocaleCompare("rotate",option+1) == 0) |
| 2742 | { |
| 2743 | char |
| 2744 | *geometry; |
| 2745 | |
| 2746 | Image |
| 2747 | *rotate_image; |
| 2748 | |
| 2749 | /* |
| 2750 | Check for conditional image rotation. |
| 2751 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2752 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2753 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2754 | if ((*image)->columns <= (*image)->rows) |
| 2755 | break; |
| 2756 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2757 | if ((*image)->columns >= (*image)->rows) |
| 2758 | break; |
| 2759 | /* |
| 2760 | Rotate image. |
| 2761 | */ |
| 2762 | geometry=ConstantString(argv[i+1]); |
| 2763 | (void) SubstituteString(&geometry,">",""); |
| 2764 | (void) SubstituteString(&geometry,"<",""); |
| 2765 | (void) ParseGeometry(geometry,&geometry_info); |
| 2766 | geometry=DestroyString(geometry); |
| 2767 | rotate_image=RotateImage(*image,geometry_info.rho,exception); |
| 2768 | if (rotate_image == (Image *) NULL) |
| 2769 | break; |
| 2770 | *image=DestroyImage(*image); |
| 2771 | *image=rotate_image; |
| 2772 | break; |
| 2773 | } |
| 2774 | break; |
| 2775 | } |
| 2776 | case 's': |
| 2777 | { |
| 2778 | if (LocaleCompare("sample",option+1) == 0) |
| 2779 | { |
| 2780 | Image |
| 2781 | *sample_image; |
| 2782 | |
| 2783 | /* |
| 2784 | Sample image with pixel replication. |
| 2785 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2786 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2787 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2788 | sample_image=SampleImage(*image,geometry.width,geometry.height, |
| 2789 | exception); |
| 2790 | if (sample_image == (Image *) NULL) |
| 2791 | break; |
| 2792 | *image=DestroyImage(*image); |
| 2793 | *image=sample_image; |
| 2794 | break; |
| 2795 | } |
| 2796 | if (LocaleCompare("scale",option+1) == 0) |
| 2797 | { |
| 2798 | Image |
| 2799 | *scale_image; |
| 2800 | |
| 2801 | /* |
| 2802 | Resize image. |
| 2803 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2804 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2805 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2806 | scale_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2807 | exception); |
| 2808 | if (scale_image == (Image *) NULL) |
| 2809 | break; |
| 2810 | *image=DestroyImage(*image); |
| 2811 | *image=scale_image; |
| 2812 | break; |
| 2813 | } |
| 2814 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2815 | { |
| 2816 | Image |
| 2817 | *blur_image; |
| 2818 | |
| 2819 | /* |
| 2820 | Selectively blur pixels within a contrast threshold. |
| 2821 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2822 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2823 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2824 | if ((flags & PercentValue) != 0) |
| 2825 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 2826 | blur_image=SelectiveBlurImageChannel(*image,channel, |
| 2827 | geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception); |
| 2828 | if (blur_image == (Image *) NULL) |
| 2829 | break; |
| 2830 | *image=DestroyImage(*image); |
| 2831 | *image=blur_image; |
| 2832 | break; |
| 2833 | } |
| 2834 | if (LocaleCompare("separate",option+1) == 0) |
| 2835 | { |
| 2836 | Image |
| 2837 | *separate_images; |
| 2838 | |
| 2839 | /* |
| 2840 | Break channels into separate images. |
| 2841 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2842 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2843 | separate_images=SeparateImages(*image,channel,exception); |
| 2844 | if (separate_images == (Image *) NULL) |
| 2845 | break; |
| 2846 | *image=DestroyImage(*image); |
| 2847 | *image=separate_images; |
| 2848 | break; |
| 2849 | } |
| 2850 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2851 | { |
| 2852 | double |
| 2853 | threshold; |
| 2854 | |
| 2855 | Image |
| 2856 | *sepia_image; |
| 2857 | |
| 2858 | /* |
| 2859 | Sepia-tone image. |
| 2860 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2861 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2862 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2863 | sepia_image=SepiaToneImage(*image,threshold,exception); |
| 2864 | if (sepia_image == (Image *) NULL) |
| 2865 | break; |
| 2866 | *image=DestroyImage(*image); |
| 2867 | *image=sepia_image; |
| 2868 | break; |
| 2869 | } |
| 2870 | if (LocaleCompare("segment",option+1) == 0) |
| 2871 | { |
| 2872 | /* |
| 2873 | Segment image. |
| 2874 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2875 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2876 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2877 | if ((flags & SigmaValue) == 0) |
| 2878 | geometry_info.sigma=1.0; |
cristy | 7e6164a | 2010-07-22 20:43:57 +0000 | [diff] [blame] | 2879 | (void) SegmentImage(*image,(*image)->colorspace, |
| 2880 | mogrify_info->verbose,geometry_info.rho,geometry_info.sigma); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2881 | InheritException(exception,&(*image)->exception); |
| 2882 | break; |
| 2883 | } |
| 2884 | if (LocaleCompare("set",option+1) == 0) |
| 2885 | { |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2886 | char |
| 2887 | *value; |
| 2888 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2889 | /* |
| 2890 | Set image option. |
| 2891 | */ |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2892 | if (*option == '+') |
| 2893 | { |
| 2894 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2895 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2896 | else |
| 2897 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
cristy | 7e10958 | 2010-06-01 12:56:44 +0000 | [diff] [blame] | 2898 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2899 | (void) DeleteImageOption(mogrify_info,argv[i+1]+7); |
cristy | 7e10958 | 2010-06-01 12:56:44 +0000 | [diff] [blame] | 2900 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2901 | } |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2902 | else |
| 2903 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2904 | break; |
| 2905 | } |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2906 | value=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2907 | if (value == (char *) NULL) |
| 2908 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2909 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2910 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2911 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2912 | else |
| 2913 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2914 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2915 | (void) SetImageOption(mogrify_info,argv[i+1]+7,value); |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2916 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2917 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2918 | else |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2919 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2920 | value=DestroyString(value); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2921 | break; |
| 2922 | } |
| 2923 | if (LocaleCompare("shade",option+1) == 0) |
| 2924 | { |
| 2925 | Image |
| 2926 | *shade_image; |
| 2927 | |
| 2928 | /* |
| 2929 | Shade image. |
| 2930 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2931 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2932 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2933 | if ((flags & SigmaValue) == 0) |
| 2934 | geometry_info.sigma=1.0; |
| 2935 | shade_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2936 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2937 | if (shade_image == (Image *) NULL) |
| 2938 | break; |
| 2939 | *image=DestroyImage(*image); |
| 2940 | *image=shade_image; |
| 2941 | break; |
| 2942 | } |
| 2943 | if (LocaleCompare("shadow",option+1) == 0) |
| 2944 | { |
| 2945 | Image |
| 2946 | *shadow_image; |
| 2947 | |
| 2948 | /* |
| 2949 | Shadow image. |
| 2950 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2951 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2952 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2953 | if ((flags & SigmaValue) == 0) |
| 2954 | geometry_info.sigma=1.0; |
| 2955 | if ((flags & XiValue) == 0) |
| 2956 | geometry_info.xi=4.0; |
| 2957 | if ((flags & PsiValue) == 0) |
| 2958 | geometry_info.psi=4.0; |
| 2959 | shadow_image=ShadowImage(*image,geometry_info.rho, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2960 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
cristy | 0534a6b | 2010-03-18 01:19:38 +0000 | [diff] [blame] | 2961 | ceil(geometry_info.psi-0.5),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2962 | if (shadow_image == (Image *) NULL) |
| 2963 | break; |
| 2964 | *image=DestroyImage(*image); |
| 2965 | *image=shadow_image; |
| 2966 | break; |
| 2967 | } |
| 2968 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2969 | { |
| 2970 | Image |
| 2971 | *sharp_image; |
| 2972 | |
| 2973 | /* |
| 2974 | Sharpen image. |
| 2975 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2976 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2977 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2978 | if ((flags & SigmaValue) == 0) |
| 2979 | geometry_info.sigma=1.0; |
| 2980 | sharp_image=SharpenImageChannel(*image,channel,geometry_info.rho, |
| 2981 | geometry_info.sigma,exception); |
| 2982 | if (sharp_image == (Image *) NULL) |
| 2983 | break; |
| 2984 | *image=DestroyImage(*image); |
| 2985 | *image=sharp_image; |
| 2986 | break; |
| 2987 | } |
| 2988 | if (LocaleCompare("shave",option+1) == 0) |
| 2989 | { |
| 2990 | Image |
| 2991 | *shave_image; |
| 2992 | |
| 2993 | /* |
| 2994 | Shave the image edges. |
| 2995 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 2996 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2997 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2998 | shave_image=ShaveImage(*image,&geometry,exception); |
| 2999 | if (shave_image == (Image *) NULL) |
| 3000 | break; |
| 3001 | *image=DestroyImage(*image); |
| 3002 | *image=shave_image; |
| 3003 | break; |
| 3004 | } |
| 3005 | if (LocaleCompare("shear",option+1) == 0) |
| 3006 | { |
| 3007 | Image |
| 3008 | *shear_image; |
| 3009 | |
| 3010 | /* |
| 3011 | Shear image. |
| 3012 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3013 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3014 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3015 | if ((flags & SigmaValue) == 0) |
| 3016 | geometry_info.sigma=geometry_info.rho; |
| 3017 | shear_image=ShearImage(*image,geometry_info.rho,geometry_info.sigma, |
| 3018 | exception); |
| 3019 | if (shear_image == (Image *) NULL) |
| 3020 | break; |
| 3021 | *image=DestroyImage(*image); |
| 3022 | *image=shear_image; |
| 3023 | break; |
| 3024 | } |
| 3025 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 3026 | { |
| 3027 | /* |
| 3028 | Sigmoidal non-linearity contrast control. |
| 3029 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3030 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3031 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3032 | if ((flags & SigmaValue) == 0) |
| 3033 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 3034 | if ((flags & PercentValue) != 0) |
| 3035 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 3036 | 100.0; |
| 3037 | (void) SigmoidalContrastImageChannel(*image,channel, |
| 3038 | (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho, |
| 3039 | geometry_info.sigma); |
| 3040 | InheritException(exception,&(*image)->exception); |
| 3041 | break; |
| 3042 | } |
| 3043 | if (LocaleCompare("sketch",option+1) == 0) |
| 3044 | { |
| 3045 | Image |
| 3046 | *sketch_image; |
| 3047 | |
| 3048 | /* |
| 3049 | Sketch image. |
| 3050 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3051 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3052 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3053 | if ((flags & SigmaValue) == 0) |
| 3054 | geometry_info.sigma=1.0; |
| 3055 | sketch_image=SketchImage(*image,geometry_info.rho, |
| 3056 | geometry_info.sigma,geometry_info.xi,exception); |
| 3057 | if (sketch_image == (Image *) NULL) |
| 3058 | break; |
| 3059 | *image=DestroyImage(*image); |
| 3060 | *image=sketch_image; |
| 3061 | break; |
| 3062 | } |
| 3063 | if (LocaleCompare("solarize",option+1) == 0) |
| 3064 | { |
| 3065 | double |
| 3066 | threshold; |
| 3067 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3068 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 3069 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3070 | (void) SolarizeImage(*image,threshold); |
| 3071 | InheritException(exception,&(*image)->exception); |
| 3072 | break; |
| 3073 | } |
| 3074 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 3075 | { |
| 3076 | Image |
| 3077 | *sparse_image; |
| 3078 | |
| 3079 | SparseColorMethod |
| 3080 | method; |
| 3081 | |
| 3082 | char |
| 3083 | *arguments; |
| 3084 | |
| 3085 | /* |
| 3086 | Sparse Color Interpolated Gradient |
| 3087 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3088 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3089 | method=(SparseColorMethod) ParseMagickOption( |
| 3090 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3091 | arguments=InterpretImageProperties(mogrify_info,*image,argv[i+2]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3092 | InheritException(exception,&(*image)->exception); |
| 3093 | if (arguments == (char *) NULL) |
| 3094 | break; |
| 3095 | sparse_image=SparseColorOption(*image,channel,method,arguments, |
| 3096 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 3097 | arguments=DestroyString(arguments); |
| 3098 | if (sparse_image == (Image *) NULL) |
| 3099 | break; |
| 3100 | *image=DestroyImage(*image); |
| 3101 | *image=sparse_image; |
| 3102 | break; |
| 3103 | } |
| 3104 | if (LocaleCompare("splice",option+1) == 0) |
| 3105 | { |
| 3106 | Image |
| 3107 | *splice_image; |
| 3108 | |
| 3109 | /* |
| 3110 | Splice a solid color into the image. |
| 3111 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3112 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3113 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 3114 | splice_image=SpliceImage(*image,&geometry,exception); |
| 3115 | if (splice_image == (Image *) NULL) |
| 3116 | break; |
| 3117 | *image=DestroyImage(*image); |
| 3118 | *image=splice_image; |
| 3119 | break; |
| 3120 | } |
| 3121 | if (LocaleCompare("spread",option+1) == 0) |
| 3122 | { |
| 3123 | Image |
| 3124 | *spread_image; |
| 3125 | |
| 3126 | /* |
| 3127 | Spread an image. |
| 3128 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3129 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3130 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 3131 | spread_image=SpreadImage(*image,geometry_info.rho,exception); |
| 3132 | if (spread_image == (Image *) NULL) |
| 3133 | break; |
| 3134 | *image=DestroyImage(*image); |
| 3135 | *image=spread_image; |
| 3136 | break; |
| 3137 | } |
| 3138 | if (LocaleCompare("stretch",option+1) == 0) |
| 3139 | { |
| 3140 | if (*option == '+') |
| 3141 | { |
| 3142 | draw_info->stretch=UndefinedStretch; |
| 3143 | break; |
| 3144 | } |
| 3145 | draw_info->stretch=(StretchType) ParseMagickOption( |
| 3146 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 3147 | break; |
| 3148 | } |
| 3149 | if (LocaleCompare("strip",option+1) == 0) |
| 3150 | { |
| 3151 | /* |
| 3152 | Strip image of profiles and comments. |
| 3153 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3154 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3155 | (void) StripImage(*image); |
| 3156 | InheritException(exception,&(*image)->exception); |
| 3157 | break; |
| 3158 | } |
| 3159 | if (LocaleCompare("stroke",option+1) == 0) |
| 3160 | { |
| 3161 | ExceptionInfo |
| 3162 | *sans; |
| 3163 | |
| 3164 | if (*option == '+') |
| 3165 | { |
| 3166 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 3167 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 3168 | draw_info->stroke_pattern=DestroyImage( |
| 3169 | draw_info->stroke_pattern); |
| 3170 | break; |
| 3171 | } |
| 3172 | sans=AcquireExceptionInfo(); |
| 3173 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 3174 | sans=DestroyExceptionInfo(sans); |
| 3175 | if (status == MagickFalse) |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3176 | draw_info->stroke_pattern=GetImageCache(mogrify_info,argv[i+1], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3177 | exception); |
| 3178 | break; |
| 3179 | } |
| 3180 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 3181 | { |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 3182 | draw_info->stroke_width=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3183 | break; |
| 3184 | } |
| 3185 | if (LocaleCompare("style",option+1) == 0) |
| 3186 | { |
| 3187 | if (*option == '+') |
| 3188 | { |
| 3189 | draw_info->style=UndefinedStyle; |
| 3190 | break; |
| 3191 | } |
| 3192 | draw_info->style=(StyleType) ParseMagickOption(MagickStyleOptions, |
| 3193 | MagickFalse,argv[i+1]); |
| 3194 | break; |
| 3195 | } |
| 3196 | if (LocaleCompare("swirl",option+1) == 0) |
| 3197 | { |
| 3198 | Image |
| 3199 | *swirl_image; |
| 3200 | |
| 3201 | /* |
| 3202 | Swirl image. |
| 3203 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3204 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3205 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 3206 | swirl_image=SwirlImage(*image,geometry_info.rho,exception); |
| 3207 | if (swirl_image == (Image *) NULL) |
| 3208 | break; |
| 3209 | *image=DestroyImage(*image); |
| 3210 | *image=swirl_image; |
| 3211 | break; |
| 3212 | } |
| 3213 | break; |
| 3214 | } |
| 3215 | case 't': |
| 3216 | { |
| 3217 | if (LocaleCompare("threshold",option+1) == 0) |
| 3218 | { |
| 3219 | double |
| 3220 | threshold; |
| 3221 | |
| 3222 | /* |
| 3223 | Threshold image. |
| 3224 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3225 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3226 | if (*option == '+') |
| 3227 | threshold=(double) QuantumRange/2.5; |
| 3228 | else |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 3229 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3230 | (void) BilevelImageChannel(*image,channel,threshold); |
| 3231 | InheritException(exception,&(*image)->exception); |
| 3232 | break; |
| 3233 | } |
| 3234 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 3235 | { |
| 3236 | Image |
| 3237 | *thumbnail_image; |
| 3238 | |
| 3239 | /* |
| 3240 | Thumbnail image. |
| 3241 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3242 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3243 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 3244 | thumbnail_image=ThumbnailImage(*image,geometry.width, |
| 3245 | geometry.height,exception); |
| 3246 | if (thumbnail_image == (Image *) NULL) |
| 3247 | break; |
| 3248 | *image=DestroyImage(*image); |
| 3249 | *image=thumbnail_image; |
| 3250 | break; |
| 3251 | } |
| 3252 | if (LocaleCompare("tile",option+1) == 0) |
| 3253 | { |
| 3254 | if (*option == '+') |
| 3255 | { |
| 3256 | if (draw_info->fill_pattern != (Image *) NULL) |
| 3257 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 3258 | break; |
| 3259 | } |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3260 | draw_info->fill_pattern=GetImageCache(mogrify_info,argv[i+1], |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3261 | exception); |
| 3262 | break; |
| 3263 | } |
| 3264 | if (LocaleCompare("tint",option+1) == 0) |
| 3265 | { |
| 3266 | Image |
| 3267 | *tint_image; |
| 3268 | |
| 3269 | /* |
| 3270 | Tint the image. |
| 3271 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3272 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3273 | tint_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 3274 | if (tint_image == (Image *) NULL) |
| 3275 | break; |
| 3276 | *image=DestroyImage(*image); |
| 3277 | *image=tint_image; |
| 3278 | break; |
| 3279 | } |
| 3280 | if (LocaleCompare("transform",option+1) == 0) |
| 3281 | { |
| 3282 | Image |
| 3283 | *transform_image; |
| 3284 | |
| 3285 | /* |
| 3286 | Affine transform image. |
| 3287 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3288 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3289 | transform_image=AffineTransformImage(*image,&draw_info->affine, |
| 3290 | exception); |
| 3291 | if (transform_image == (Image *) NULL) |
| 3292 | break; |
| 3293 | *image=DestroyImage(*image); |
| 3294 | *image=transform_image; |
| 3295 | break; |
| 3296 | } |
| 3297 | if (LocaleCompare("transparent",option+1) == 0) |
| 3298 | { |
| 3299 | MagickPixelPacket |
| 3300 | target; |
| 3301 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3302 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3303 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 3304 | (void) TransparentPaintImage(*image,&target,(Quantum) |
| 3305 | TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue); |
| 3306 | InheritException(exception,&(*image)->exception); |
| 3307 | break; |
| 3308 | } |
| 3309 | if (LocaleCompare("transpose",option+1) == 0) |
| 3310 | { |
| 3311 | Image |
| 3312 | *transpose_image; |
| 3313 | |
| 3314 | /* |
| 3315 | Transpose image scanlines. |
| 3316 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3317 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3318 | transpose_image=TransposeImage(*image,exception); |
| 3319 | if (transpose_image == (Image *) NULL) |
| 3320 | break; |
| 3321 | *image=DestroyImage(*image); |
| 3322 | *image=transpose_image; |
| 3323 | break; |
| 3324 | } |
| 3325 | if (LocaleCompare("transverse",option+1) == 0) |
| 3326 | { |
| 3327 | Image |
| 3328 | *transverse_image; |
| 3329 | |
| 3330 | /* |
| 3331 | Transverse image scanlines. |
| 3332 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3333 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3334 | transverse_image=TransverseImage(*image,exception); |
| 3335 | if (transverse_image == (Image *) NULL) |
| 3336 | break; |
| 3337 | *image=DestroyImage(*image); |
| 3338 | *image=transverse_image; |
| 3339 | break; |
| 3340 | } |
| 3341 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3342 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 3343 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3344 | break; |
| 3345 | } |
| 3346 | if (LocaleCompare("trim",option+1) == 0) |
| 3347 | { |
| 3348 | Image |
| 3349 | *trim_image; |
| 3350 | |
| 3351 | /* |
| 3352 | Trim image. |
| 3353 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3354 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3355 | trim_image=TrimImage(*image,exception); |
| 3356 | if (trim_image == (Image *) NULL) |
| 3357 | break; |
| 3358 | *image=DestroyImage(*image); |
| 3359 | *image=trim_image; |
| 3360 | break; |
| 3361 | } |
| 3362 | if (LocaleCompare("type",option+1) == 0) |
| 3363 | { |
| 3364 | ImageType |
| 3365 | type; |
| 3366 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3367 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3368 | if (*option == '+') |
| 3369 | type=UndefinedType; |
| 3370 | else |
| 3371 | type=(ImageType) ParseMagickOption(MagickTypeOptions,MagickFalse, |
| 3372 | argv[i+1]); |
| 3373 | (*image)->type=UndefinedType; |
| 3374 | (void) SetImageType(*image,type); |
| 3375 | InheritException(exception,&(*image)->exception); |
| 3376 | break; |
| 3377 | } |
| 3378 | break; |
| 3379 | } |
| 3380 | case 'u': |
| 3381 | { |
| 3382 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3383 | { |
| 3384 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3385 | exception); |
| 3386 | break; |
| 3387 | } |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3388 | if (LocaleCompare("unique",option+1) == 0) |
| 3389 | { |
| 3390 | if (*option == '+') |
| 3391 | { |
cristy | 83fae87 | 2010-04-22 15:04:16 +0000 | [diff] [blame] | 3392 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3393 | break; |
| 3394 | } |
cristy | 83fae87 | 2010-04-22 15:04:16 +0000 | [diff] [blame] | 3395 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
cristy | 7e6164a | 2010-07-22 20:43:57 +0000 | [diff] [blame] | 3396 | (void) SetImageArtifact(*image,"identify:verbose","true"); |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3397 | break; |
| 3398 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3399 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3400 | { |
| 3401 | Image |
| 3402 | *unique_image; |
| 3403 | |
| 3404 | /* |
| 3405 | Unique image colors. |
| 3406 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3407 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3408 | unique_image=UniqueImageColors(*image,exception); |
| 3409 | if (unique_image == (Image *) NULL) |
| 3410 | break; |
| 3411 | *image=DestroyImage(*image); |
| 3412 | *image=unique_image; |
| 3413 | break; |
| 3414 | } |
| 3415 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3416 | { |
| 3417 | Image |
| 3418 | *unsharp_image; |
| 3419 | |
| 3420 | /* |
| 3421 | Unsharp mask image. |
| 3422 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3423 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3424 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3425 | if ((flags & SigmaValue) == 0) |
| 3426 | geometry_info.sigma=1.0; |
| 3427 | if ((flags & XiValue) == 0) |
| 3428 | geometry_info.xi=1.0; |
| 3429 | if ((flags & PsiValue) == 0) |
| 3430 | geometry_info.psi=0.05; |
| 3431 | unsharp_image=UnsharpMaskImageChannel(*image,channel, |
| 3432 | geometry_info.rho,geometry_info.sigma,geometry_info.xi, |
| 3433 | geometry_info.psi,exception); |
| 3434 | if (unsharp_image == (Image *) NULL) |
| 3435 | break; |
| 3436 | *image=DestroyImage(*image); |
| 3437 | *image=unsharp_image; |
| 3438 | break; |
| 3439 | } |
| 3440 | break; |
| 3441 | } |
| 3442 | case 'v': |
| 3443 | { |
| 3444 | if (LocaleCompare("verbose",option+1) == 0) |
| 3445 | { |
| 3446 | (void) SetImageArtifact(*image,option+1, |
| 3447 | *option == '+' ? "false" : "true"); |
| 3448 | break; |
| 3449 | } |
| 3450 | if (LocaleCompare("vignette",option+1) == 0) |
| 3451 | { |
| 3452 | Image |
| 3453 | *vignette_image; |
| 3454 | |
| 3455 | /* |
| 3456 | Vignette image. |
| 3457 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3458 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3459 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3460 | if ((flags & SigmaValue) == 0) |
| 3461 | geometry_info.sigma=1.0; |
| 3462 | if ((flags & XiValue) == 0) |
| 3463 | geometry_info.xi=0.1*(*image)->columns; |
| 3464 | if ((flags & PsiValue) == 0) |
| 3465 | geometry_info.psi=0.1*(*image)->rows; |
| 3466 | vignette_image=VignetteImage(*image,geometry_info.rho, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3467 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
cristy | 0534a6b | 2010-03-18 01:19:38 +0000 | [diff] [blame] | 3468 | ceil(geometry_info.psi-0.5),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3469 | if (vignette_image == (Image *) NULL) |
| 3470 | break; |
| 3471 | *image=DestroyImage(*image); |
| 3472 | *image=vignette_image; |
| 3473 | break; |
| 3474 | } |
| 3475 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3476 | { |
| 3477 | if (*option == '+') |
| 3478 | { |
| 3479 | (void) SetImageVirtualPixelMethod(*image, |
| 3480 | UndefinedVirtualPixelMethod); |
| 3481 | break; |
| 3482 | } |
| 3483 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3484 | ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 3485 | argv[i+1])); |
| 3486 | break; |
| 3487 | } |
| 3488 | break; |
| 3489 | } |
| 3490 | case 'w': |
| 3491 | { |
| 3492 | if (LocaleCompare("wave",option+1) == 0) |
| 3493 | { |
| 3494 | Image |
| 3495 | *wave_image; |
| 3496 | |
| 3497 | /* |
| 3498 | Wave image. |
| 3499 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3500 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3501 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3502 | if ((flags & SigmaValue) == 0) |
| 3503 | geometry_info.sigma=1.0; |
| 3504 | wave_image=WaveImage(*image,geometry_info.rho,geometry_info.sigma, |
| 3505 | exception); |
| 3506 | if (wave_image == (Image *) NULL) |
| 3507 | break; |
| 3508 | *image=DestroyImage(*image); |
| 3509 | *image=wave_image; |
| 3510 | break; |
| 3511 | } |
| 3512 | if (LocaleCompare("weight",option+1) == 0) |
| 3513 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 3514 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3515 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3516 | draw_info->weight=0; |
| 3517 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3518 | draw_info->weight=700; |
| 3519 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3520 | if (draw_info->weight <= 800) |
| 3521 | draw_info->weight+=100; |
| 3522 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3523 | if (draw_info->weight >= 100) |
| 3524 | draw_info->weight-=100; |
| 3525 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3526 | draw_info->weight=400; |
| 3527 | break; |
| 3528 | } |
| 3529 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3530 | { |
| 3531 | /* |
| 3532 | White threshold image. |
| 3533 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3534 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3535 | (void) WhiteThresholdImageChannel(*image,channel,argv[i+1], |
| 3536 | exception); |
| 3537 | InheritException(exception,&(*image)->exception); |
| 3538 | break; |
| 3539 | } |
| 3540 | break; |
| 3541 | } |
| 3542 | default: |
| 3543 | break; |
| 3544 | } |
| 3545 | i+=count; |
| 3546 | } |
| 3547 | if (region_image != (Image *) NULL) |
| 3548 | { |
| 3549 | /* |
| 3550 | Composite transformed region onto image. |
| 3551 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3552 | (void) SyncImageSettings(mogrify_info,*image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3553 | (void) CompositeImage(region_image,(*image)->matte != MagickFalse ? |
| 3554 | OverCompositeOp : CopyCompositeOp,*image,region_geometry.x, |
| 3555 | region_geometry.y); |
| 3556 | InheritException(exception,®ion_image->exception); |
| 3557 | *image=DestroyImage(*image); |
| 3558 | *image=region_image; |
| 3559 | } |
| 3560 | /* |
| 3561 | Free resources. |
| 3562 | */ |
| 3563 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3564 | draw_info=DestroyDrawInfo(draw_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 3565 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 3566 | status=(*image)->exception.severity == UndefinedException ? MagickTrue : |
| 3567 | MagickFalse; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3568 | return(status); |
| 3569 | } |
| 3570 | |
| 3571 | /* |
| 3572 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3573 | % % |
| 3574 | % % |
| 3575 | % % |
| 3576 | % M o g r i f y I m a g e C o m m a n d % |
| 3577 | % % |
| 3578 | % % |
| 3579 | % % |
| 3580 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3581 | % |
| 3582 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3583 | % transforms include image scaling, image rotation, color reduction, and |
| 3584 | % others. The transmogrified image overwrites the original image. |
| 3585 | % |
| 3586 | % The format of the MogrifyImageCommand method is: |
| 3587 | % |
| 3588 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3589 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3590 | % |
| 3591 | % A description of each parameter follows: |
| 3592 | % |
| 3593 | % o image_info: the image info. |
| 3594 | % |
| 3595 | % o argc: the number of elements in the argument vector. |
| 3596 | % |
| 3597 | % o argv: A text array containing the command line arguments. |
| 3598 | % |
| 3599 | % o metadata: any metadata is returned here. |
| 3600 | % |
| 3601 | % o exception: return any errors or warnings in this structure. |
| 3602 | % |
| 3603 | */ |
| 3604 | |
| 3605 | static MagickBooleanType MogrifyUsage(void) |
| 3606 | { |
| 3607 | static const char |
| 3608 | *miscellaneous[]= |
| 3609 | { |
| 3610 | "-debug events display copious debugging information", |
| 3611 | "-help print program options", |
| 3612 | "-list type print a list of supported option arguments", |
| 3613 | "-log format format of debugging information", |
| 3614 | "-version print version information", |
| 3615 | (char *) NULL |
| 3616 | }, |
| 3617 | *operators[]= |
| 3618 | { |
| 3619 | "-adaptive-blur geometry", |
| 3620 | " adaptively blur pixels; decrease effect near edges", |
| 3621 | "-adaptive-resize geometry", |
| 3622 | " adaptively resize image using 'mesh' interpolation", |
| 3623 | "-adaptive-sharpen geometry", |
| 3624 | " adaptively sharpen pixels; increase effect near edges", |
| 3625 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3626 | " transparent, extract, background, or shape", |
| 3627 | "-annotate geometry text", |
| 3628 | " annotate the image with text", |
| 3629 | "-auto-gamma automagically adjust gamma level of image", |
| 3630 | "-auto-level automagically adjust color levels of image", |
| 3631 | "-auto-orient automagically orient (rotate) image", |
| 3632 | "-bench iterations measure performance", |
| 3633 | "-black-threshold value", |
| 3634 | " force all pixels below the threshold into black", |
| 3635 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3636 | "-blur geometry reduce image noise and reduce detail levels", |
| 3637 | "-border geometry surround image with a border of color", |
| 3638 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3639 | "-brightness-contrast geometry", |
| 3640 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3641 | "-cdl filename color correct with a color decision list", |
| 3642 | "-charcoal radius simulate a charcoal drawing", |
| 3643 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3644 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3645 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3646 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3647 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3648 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3649 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3650 | "-contrast enhance or reduce the image contrast", |
| 3651 | "-contrast-stretch geometry", |
| 3652 | " improve contrast by `stretching' the intensity range", |
| 3653 | "-convolve coefficients", |
| 3654 | " apply a convolution kernel to the image", |
| 3655 | "-cycle amount cycle the image colormap", |
| 3656 | "-decipher filename convert cipher pixels to plain pixels", |
| 3657 | "-deskew threshold straighten an image", |
| 3658 | "-despeckle reduce the speckles within an image", |
| 3659 | "-distort method args", |
| 3660 | " distort images according to given method ad args", |
| 3661 | "-draw string annotate the image with a graphic primitive", |
| 3662 | "-edge radius apply a filter to detect edges in the image", |
| 3663 | "-encipher filename convert plain pixels to cipher pixels", |
| 3664 | "-emboss radius emboss an image", |
| 3665 | "-enhance apply a digital filter to enhance a noisy image", |
| 3666 | "-equalize perform histogram equalization to an image", |
| 3667 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3668 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3669 | "-extent geometry set the image size", |
| 3670 | "-extract geometry extract area from image", |
| 3671 | "-fft implements the discrete Fourier transform (DFT)", |
| 3672 | "-flip flip image vertically", |
| 3673 | "-floodfill geometry color", |
| 3674 | " floodfill the image with color", |
| 3675 | "-flop flop image horizontally", |
| 3676 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3677 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3678 | " apply function over image values", |
| 3679 | "-gamma value level of gamma correction", |
| 3680 | "-gaussian-blur geometry", |
| 3681 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3682 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3683 | "-identify identify the format and characteristics of the image", |
| 3684 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3685 | "-implode amount implode image pixels about the center", |
| 3686 | "-lat geometry local adaptive thresholding", |
| 3687 | "-layers method optimize, merge, or compare image layers", |
| 3688 | "-level value adjust the level of image contrast", |
| 3689 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3690 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3691 | "-linear-stretch geometry", |
| 3692 | " improve contrast by `stretching with saturation'", |
| 3693 | "-liquid-rescale geometry", |
| 3694 | " rescale image with seam-carving", |
| 3695 | "-median radius apply a median filter to the image", |
| 3696 | "-modulate value vary the brightness, saturation, and hue", |
| 3697 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3698 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3699 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3700 | "-motion-blur geometry", |
| 3701 | " simulate motion blur", |
| 3702 | "-negate replace every pixel with its complementary color ", |
| 3703 | "-noise radius add or reduce noise in an image", |
| 3704 | "-normalize transform image to span the full range of colors", |
| 3705 | "-opaque color change this color to the fill color", |
| 3706 | "-ordered-dither NxN", |
| 3707 | " add a noise pattern to the image with specific", |
| 3708 | " amplitudes", |
| 3709 | "-paint radius simulate an oil painting", |
| 3710 | "-polaroid angle simulate a Polaroid picture", |
| 3711 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3712 | "-profile filename add, delete, or apply an image profile", |
| 3713 | "-quantize colorspace reduce colors in this colorspace", |
| 3714 | "-radial-blur angle radial blur the image", |
| 3715 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3716 | "-random-threshold low,high", |
| 3717 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3718 | "-region geometry apply options to a portion of the image", |
| 3719 | "-render render vector graphics", |
| 3720 | "-repage geometry size and location of an image canvas", |
| 3721 | "-resample geometry change the resolution of an image", |
| 3722 | "-resize geometry resize the image", |
| 3723 | "-roll geometry roll an image vertically or horizontally", |
| 3724 | "-rotate degrees apply Paeth rotation to the image", |
| 3725 | "-sample geometry scale image with pixel sampling", |
| 3726 | "-scale geometry scale the image", |
| 3727 | "-segment values segment an image", |
| 3728 | "-selective-blur geometry", |
| 3729 | " selectively blur pixels within a contrast threshold", |
| 3730 | "-sepia-tone threshold", |
| 3731 | " simulate a sepia-toned photo", |
| 3732 | "-set property value set an image property", |
| 3733 | "-shade degrees shade the image using a distant light source", |
| 3734 | "-shadow geometry simulate an image shadow", |
| 3735 | "-sharpen geometry sharpen the image", |
| 3736 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3737 | "-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] | 3738 | "-sigmoidal-contrast geometry", |
| 3739 | " increase the contrast without saturating highlights or shadows", |
| 3740 | "-sketch geometry simulate a pencil sketch", |
| 3741 | "-solarize threshold negate all pixels above the threshold level", |
| 3742 | "-sparse-color method args", |
| 3743 | " fill in a image based on a few color points", |
| 3744 | "-splice geometry splice the background color into the image", |
| 3745 | "-spread radius displace image pixels by a random amount", |
| 3746 | "-strip strip image of all profiles and comments", |
| 3747 | "-swirl degrees swirl image pixels about the center", |
| 3748 | "-threshold value threshold the image", |
| 3749 | "-thumbnail geometry create a thumbnail of the image", |
| 3750 | "-tile filename tile image when filling a graphic primitive", |
| 3751 | "-tint value tint the image with the fill color", |
| 3752 | "-transform affine transform image", |
| 3753 | "-transparent color make this color transparent within the image", |
| 3754 | "-transpose flip image vertically and rotate 90 degrees", |
| 3755 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3756 | "-trim trim image edges", |
| 3757 | "-type type image type", |
| 3758 | "-unique-colors discard all but one of any pixel color", |
| 3759 | "-unsharp geometry sharpen the image", |
| 3760 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3761 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3762 | "-white-threshold value", |
| 3763 | " force all pixels above the threshold into white", |
| 3764 | (char *) NULL |
| 3765 | }, |
| 3766 | *sequence_operators[]= |
| 3767 | { |
| 3768 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3769 | "-clut apply a color lookup table to the image", |
| 3770 | "-coalesce merge a sequence of images", |
| 3771 | "-combine combine a sequence of images", |
| 3772 | "-composite composite image", |
| 3773 | "-crop geometry cut out a rectangular region of the image", |
| 3774 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3775 | "-evaluate-sequence operator", |
| 3776 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3777 | "-flatten flatten a sequence of images", |
| 3778 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3779 | "-hald-clut apply a Hald color lookup table to the image", |
| 3780 | "-morph value morph an image sequence", |
| 3781 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3782 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3783 | "-process arguments process the image with a custom image filter", |
| 3784 | "-reverse reverse image sequence", |
| 3785 | "-separate separate an image channel into a grayscale image", |
| 3786 | "-write filename write images to this file", |
| 3787 | (char *) NULL |
| 3788 | }, |
| 3789 | *settings[]= |
| 3790 | { |
| 3791 | "-adjoin join images into a single multi-image file", |
| 3792 | "-affine matrix affine transform matrix", |
| 3793 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3794 | "-antialias remove pixel-aliasing", |
| 3795 | "-authenticate password", |
| 3796 | " decipher image with this password", |
| 3797 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3798 | "-background color background color", |
| 3799 | "-bias value add bias when convolving an image", |
| 3800 | "-black-point-compensation", |
| 3801 | " use black point compensation", |
| 3802 | "-blue-primary point chromaticity blue primary point", |
| 3803 | "-bordercolor color border color", |
| 3804 | "-caption string assign a caption to an image", |
| 3805 | "-channel type apply option to select image channels", |
| 3806 | "-colors value preferred number of colors in the image", |
| 3807 | "-colorspace type alternate image colorspace", |
| 3808 | "-comment string annotate image with comment", |
| 3809 | "-compose operator set image composite operator", |
| 3810 | "-compress type type of pixel compression when writing the image", |
| 3811 | "-define format:option", |
| 3812 | " define one or more image format options", |
| 3813 | "-delay value display the next image after pausing", |
| 3814 | "-density geometry horizontal and vertical density of the image", |
| 3815 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3816 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3817 | "-display server get image or font from this X server", |
| 3818 | "-dispose method layer disposal method", |
| 3819 | "-dither method apply error diffusion to image", |
| 3820 | "-encoding type text encoding type", |
| 3821 | "-endian type endianness (MSB or LSB) of the image", |
| 3822 | "-family name render text with this font family", |
| 3823 | "-fill color color to use when filling a graphic primitive", |
| 3824 | "-filter type use this filter when resizing an image", |
| 3825 | "-font name render text with this font", |
| 3826 | "-format \"string\" output formatted image characteristics", |
| 3827 | "-fuzz distance colors within this distance are considered equal", |
| 3828 | "-gravity type horizontal and vertical text placement", |
| 3829 | "-green-primary point chromaticity green primary point", |
| 3830 | "-intent type type of rendering intent when managing the image color", |
| 3831 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3832 | "-interline-spacing value", |
| 3833 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3834 | "-interpolate method pixel color interpolation method", |
| 3835 | "-interword-spacing value", |
| 3836 | " set the space between two words", |
| 3837 | "-kerning value set the space between two letters", |
| 3838 | "-label string assign a label to an image", |
| 3839 | "-limit type value pixel cache resource limit", |
| 3840 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3841 | "-mask filename associate a mask with the image", |
| 3842 | "-mattecolor color frame color", |
| 3843 | "-monitor monitor progress", |
| 3844 | "-orient type image orientation", |
| 3845 | "-page geometry size and location of an image canvas (setting)", |
| 3846 | "-ping efficiently determine image attributes", |
| 3847 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3848 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3849 | "-preview type image preview type", |
| 3850 | "-quality value JPEG/MIFF/PNG compression level", |
| 3851 | "-quiet suppress all warning messages", |
| 3852 | "-red-primary point chromaticity red primary point", |
| 3853 | "-regard-warnings pay attention to warning messages", |
| 3854 | "-remap filename transform image colors to match this set of colors", |
| 3855 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3856 | "-sampling-factor geometry", |
| 3857 | " horizontal and vertical sampling factor", |
| 3858 | "-scene value image scene number", |
| 3859 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3860 | "-size geometry width and height of image", |
| 3861 | "-stretch type render text with this font stretch", |
| 3862 | "-stroke color graphic primitive stroke color", |
| 3863 | "-strokewidth value graphic primitive stroke width", |
| 3864 | "-style type render text with this font style", |
| 3865 | "-taint image as ineligible for bi-modal delegate", |
| 3866 | "-texture filename name of texture to tile onto the image background", |
| 3867 | "-tile-offset geometry", |
| 3868 | " tile offset", |
| 3869 | "-treedepth value color tree depth", |
| 3870 | "-transparent-color color", |
| 3871 | " transparent color", |
| 3872 | "-undercolor color annotation bounding box color", |
| 3873 | "-units type the units of image resolution", |
| 3874 | "-verbose print detailed information about the image", |
| 3875 | "-view FlashPix viewing transforms", |
| 3876 | "-virtual-pixel method", |
| 3877 | " virtual pixel access method", |
| 3878 | "-weight type render text with this font weight", |
| 3879 | "-white-point point chromaticity white point", |
| 3880 | (char *) NULL |
| 3881 | }, |
| 3882 | *stack_operators[]= |
| 3883 | { |
| 3884 | "-clone index clone an image", |
| 3885 | "-delete index delete the image from the image sequence", |
| 3886 | "-insert index insert last image into the image sequence", |
| 3887 | "-swap indexes swap two images in the image sequence", |
| 3888 | (char *) NULL |
| 3889 | }; |
| 3890 | |
| 3891 | const char |
| 3892 | **p; |
| 3893 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3894 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3895 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3896 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3897 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3898 | GetClientName()); |
| 3899 | (void) printf("\nImage Settings:\n"); |
| 3900 | for (p=settings; *p != (char *) NULL; p++) |
| 3901 | (void) printf(" %s\n",*p); |
| 3902 | (void) printf("\nImage Operators:\n"); |
| 3903 | for (p=operators; *p != (char *) NULL; p++) |
| 3904 | (void) printf(" %s\n",*p); |
| 3905 | (void) printf("\nImage Sequence Operators:\n"); |
| 3906 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3907 | (void) printf(" %s\n",*p); |
| 3908 | (void) printf("\nImage Stack Operators:\n"); |
| 3909 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3910 | (void) printf(" %s\n",*p); |
| 3911 | (void) printf("\nMiscellaneous Options:\n"); |
| 3912 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3913 | (void) printf(" %s\n",*p); |
| 3914 | (void) printf( |
| 3915 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3916 | (void) printf( |
| 3917 | "number. To specify a particular image format, precede the filename\n"); |
| 3918 | (void) printf( |
| 3919 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3920 | (void) printf( |
| 3921 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3922 | (void) printf("'-' for standard input or output.\n"); |
| 3923 | return(MagickFalse); |
| 3924 | } |
| 3925 | |
| 3926 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3927 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3928 | { |
| 3929 | #define DestroyMogrify() \ |
| 3930 | { \ |
| 3931 | if (format != (char *) NULL) \ |
| 3932 | format=DestroyString(format); \ |
| 3933 | if (path != (char *) NULL) \ |
| 3934 | path=DestroyString(path); \ |
| 3935 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3936 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3937 | argv[i]=DestroyString(argv[i]); \ |
| 3938 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3939 | } |
| 3940 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3941 | { \ |
| 3942 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3943 | option); \ |
| 3944 | DestroyMogrify(); \ |
| 3945 | return(MagickFalse); \ |
| 3946 | } |
| 3947 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3948 | { \ |
| 3949 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3950 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3951 | DestroyMogrify(); \ |
| 3952 | return(MagickFalse); \ |
| 3953 | } |
| 3954 | |
| 3955 | char |
| 3956 | *format, |
| 3957 | *option, |
| 3958 | *path; |
| 3959 | |
| 3960 | Image |
| 3961 | *image; |
| 3962 | |
| 3963 | ImageStack |
| 3964 | image_stack[MaxImageStackDepth+1]; |
| 3965 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3966 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3967 | j, |
| 3968 | k; |
| 3969 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3970 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3971 | i; |
| 3972 | |
| 3973 | MagickBooleanType |
| 3974 | global_colormap; |
| 3975 | |
| 3976 | MagickBooleanType |
| 3977 | fire, |
| 3978 | pend; |
| 3979 | |
| 3980 | MagickStatusType |
| 3981 | status; |
| 3982 | |
| 3983 | /* |
| 3984 | Set defaults. |
| 3985 | */ |
| 3986 | assert(image_info != (ImageInfo *) NULL); |
| 3987 | assert(image_info->signature == MagickSignature); |
| 3988 | if (image_info->debug != MagickFalse) |
| 3989 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3990 | assert(exception != (ExceptionInfo *) NULL); |
| 3991 | if (argc == 2) |
| 3992 | { |
| 3993 | option=argv[1]; |
| 3994 | if ((LocaleCompare("version",option+1) == 0) || |
| 3995 | (LocaleCompare("-version",option+1) == 0)) |
| 3996 | { |
| 3997 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3998 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3999 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 4000 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4001 | return(MagickFalse); |
| 4002 | } |
| 4003 | } |
| 4004 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 4005 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4006 | format=(char *) NULL; |
| 4007 | path=(char *) NULL; |
| 4008 | global_colormap=MagickFalse; |
| 4009 | k=0; |
| 4010 | j=1; |
| 4011 | NewImageStack(); |
| 4012 | option=(char *) NULL; |
| 4013 | pend=MagickFalse; |
| 4014 | status=MagickTrue; |
| 4015 | /* |
| 4016 | Parse command line. |
| 4017 | */ |
| 4018 | ReadCommandlLine(argc,&argv); |
| 4019 | status=ExpandFilenames(&argc,&argv); |
| 4020 | if (status == MagickFalse) |
| 4021 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 4022 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4023 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4024 | { |
| 4025 | option=argv[i]; |
| 4026 | if (LocaleCompare(option,"(") == 0) |
| 4027 | { |
| 4028 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 4029 | if (k == MaxImageStackDepth) |
| 4030 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 4031 | option); |
| 4032 | PushImageStack(); |
| 4033 | continue; |
| 4034 | } |
| 4035 | if (LocaleCompare(option,")") == 0) |
| 4036 | { |
| 4037 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 4038 | if (k == 0) |
| 4039 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 4040 | PopImageStack(); |
| 4041 | continue; |
| 4042 | } |
| 4043 | if (IsMagickOption(option) == MagickFalse) |
| 4044 | { |
| 4045 | char |
| 4046 | backup_filename[MaxTextExtent], |
| 4047 | *filename; |
| 4048 | |
| 4049 | Image |
| 4050 | *images; |
| 4051 | |
| 4052 | /* |
| 4053 | Option is a file name: begin by reading image from specified file. |
| 4054 | */ |
| 4055 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 4056 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 4057 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4058 | filename=argv[++i]; |
| 4059 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 4060 | images=ReadImages(image_info,exception); |
| 4061 | status&=(images != (Image *) NULL) && |
| 4062 | (exception->severity < ErrorException); |
| 4063 | if (images == (Image *) NULL) |
| 4064 | continue; |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 4065 | if (format != (char *) NULL) |
| 4066 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 4067 | MaxTextExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4068 | if (path != (char *) NULL) |
| 4069 | { |
| 4070 | GetPathComponent(option,TailPath,filename); |
| 4071 | (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s", |
| 4072 | path,*DirectorySeparator,filename); |
| 4073 | } |
| 4074 | if (format != (char *) NULL) |
cristy | daa7660 | 2010-06-30 13:05:11 +0000 | [diff] [blame] | 4075 | AppendImageFormat(format,images->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4076 | AppendImageStack(images); |
| 4077 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 4078 | if (global_colormap != MagickFalse) |
| 4079 | { |
| 4080 | QuantizeInfo |
| 4081 | *quantize_info; |
| 4082 | |
| 4083 | quantize_info=AcquireQuantizeInfo(image_info); |
| 4084 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 4085 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 4086 | } |
| 4087 | *backup_filename='\0'; |
| 4088 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 4089 | (IsPathWritable(image->filename) != MagickFalse)) |
| 4090 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4091 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4092 | i; |
| 4093 | |
| 4094 | /* |
| 4095 | Rename image file as backup. |
| 4096 | */ |
| 4097 | (void) CopyMagickString(backup_filename,image->filename, |
| 4098 | MaxTextExtent); |
| 4099 | for (i=0; i < 6; i++) |
| 4100 | { |
| 4101 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 4102 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 4103 | break; |
| 4104 | } |
| 4105 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 4106 | (rename(image->filename,backup_filename) != 0)) |
| 4107 | *backup_filename='\0'; |
| 4108 | } |
| 4109 | /* |
| 4110 | Write transmogrified image to disk. |
| 4111 | */ |
| 4112 | image_info->synchronize=MagickTrue; |
| 4113 | status&=WriteImages(image_info,image,image->filename,exception); |
| 4114 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 4115 | (void) remove(backup_filename); |
| 4116 | RemoveAllImageStack(); |
| 4117 | continue; |
| 4118 | } |
| 4119 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 4120 | switch (*(option+1)) |
| 4121 | { |
| 4122 | case 'a': |
| 4123 | { |
| 4124 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 4125 | { |
| 4126 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4127 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4128 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4129 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4130 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4131 | break; |
| 4132 | } |
| 4133 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 4134 | { |
| 4135 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4136 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4137 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4138 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4139 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4140 | break; |
| 4141 | } |
| 4142 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 4143 | { |
| 4144 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4145 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4146 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4147 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4148 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4149 | break; |
| 4150 | } |
| 4151 | if (LocaleCompare("affine",option+1) == 0) |
| 4152 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame^] | 4153 | KernelInfo |
| 4154 | *kernel_info; |
| 4155 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4156 | if (*option == '+') |
| 4157 | break; |
| 4158 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4159 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4160 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame^] | 4161 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4162 | if (kernel_info == (KernelInfo *) NULL) |
| 4163 | ThrowConvertInvalidArgumentException(option,argv[i]); |
| 4164 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4165 | break; |
| 4166 | } |
| 4167 | if (LocaleCompare("alpha",option+1) == 0) |
| 4168 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4169 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4170 | type; |
| 4171 | |
| 4172 | if (*option == '+') |
| 4173 | break; |
| 4174 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4175 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4176 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4177 | type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]); |
| 4178 | if (type < 0) |
| 4179 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 4180 | argv[i]); |
| 4181 | break; |
| 4182 | } |
| 4183 | if (LocaleCompare("annotate",option+1) == 0) |
| 4184 | { |
| 4185 | if (*option == '+') |
| 4186 | break; |
| 4187 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4188 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4189 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4190 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4191 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4192 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4193 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4194 | i++; |
| 4195 | break; |
| 4196 | } |
| 4197 | if (LocaleCompare("antialias",option+1) == 0) |
| 4198 | break; |
| 4199 | if (LocaleCompare("append",option+1) == 0) |
| 4200 | break; |
| 4201 | if (LocaleCompare("attenuate",option+1) == 0) |
| 4202 | { |
| 4203 | if (*option == '+') |
| 4204 | break; |
| 4205 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4206 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4207 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4208 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4209 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4210 | break; |
| 4211 | } |
| 4212 | if (LocaleCompare("authenticate",option+1) == 0) |
| 4213 | { |
| 4214 | if (*option == '+') |
| 4215 | break; |
| 4216 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4217 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4218 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4219 | break; |
| 4220 | } |
| 4221 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 4222 | break; |
| 4223 | if (LocaleCompare("auto-level",option+1) == 0) |
| 4224 | break; |
| 4225 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 4226 | break; |
| 4227 | if (LocaleCompare("average",option+1) == 0) |
| 4228 | break; |
| 4229 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4230 | } |
| 4231 | case 'b': |
| 4232 | { |
| 4233 | if (LocaleCompare("background",option+1) == 0) |
| 4234 | { |
| 4235 | if (*option == '+') |
| 4236 | break; |
| 4237 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4238 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4239 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4240 | break; |
| 4241 | } |
| 4242 | if (LocaleCompare("bias",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-1)) |
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 | } |
| 4253 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 4254 | break; |
| 4255 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 4256 | { |
| 4257 | if (*option == '+') |
| 4258 | break; |
| 4259 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4260 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4261 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4262 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4263 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4264 | break; |
| 4265 | } |
| 4266 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 4267 | { |
| 4268 | if (*option == '+') |
| 4269 | break; |
| 4270 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4271 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4272 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4273 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4274 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4275 | break; |
| 4276 | } |
| 4277 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 4278 | { |
| 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("blur",option+1) == 0) |
| 4287 | { |
| 4288 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4289 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4290 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4291 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4292 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4293 | break; |
| 4294 | } |
| 4295 | if (LocaleCompare("border",option+1) == 0) |
| 4296 | { |
| 4297 | if (*option == '+') |
| 4298 | break; |
| 4299 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4300 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4301 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4302 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4303 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4304 | break; |
| 4305 | } |
| 4306 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 4307 | { |
| 4308 | if (*option == '+') |
| 4309 | break; |
| 4310 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4311 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4312 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4313 | break; |
| 4314 | } |
| 4315 | if (LocaleCompare("box",option+1) == 0) |
| 4316 | { |
| 4317 | if (*option == '+') |
| 4318 | break; |
| 4319 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4320 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4321 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4322 | break; |
| 4323 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 4324 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 4325 | { |
| 4326 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4327 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 4328 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4329 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4330 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4331 | break; |
| 4332 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4333 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4334 | } |
| 4335 | case 'c': |
| 4336 | { |
| 4337 | if (LocaleCompare("cache",option+1) == 0) |
| 4338 | { |
| 4339 | if (*option == '+') |
| 4340 | break; |
| 4341 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4342 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4343 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4344 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4345 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4346 | break; |
| 4347 | } |
| 4348 | if (LocaleCompare("caption",option+1) == 0) |
| 4349 | { |
| 4350 | if (*option == '+') |
| 4351 | break; |
| 4352 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4353 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4354 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4355 | break; |
| 4356 | } |
| 4357 | if (LocaleCompare("channel",option+1) == 0) |
| 4358 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4359 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4360 | channel; |
| 4361 | |
| 4362 | if (*option == '+') |
| 4363 | break; |
| 4364 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4365 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4366 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4367 | channel=ParseChannelOption(argv[i]); |
| 4368 | if (channel < 0) |
| 4369 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4370 | argv[i]); |
| 4371 | break; |
| 4372 | } |
| 4373 | if (LocaleCompare("cdl",option+1) == 0) |
| 4374 | { |
| 4375 | if (*option == '+') |
| 4376 | break; |
| 4377 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4378 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4379 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4380 | break; |
| 4381 | } |
| 4382 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4383 | { |
| 4384 | if (*option == '+') |
| 4385 | break; |
| 4386 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4387 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4388 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4389 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4390 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4391 | break; |
| 4392 | } |
| 4393 | if (LocaleCompare("chop",option+1) == 0) |
| 4394 | { |
| 4395 | if (*option == '+') |
| 4396 | break; |
| 4397 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4398 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4399 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4400 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4401 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4402 | break; |
| 4403 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4404 | if (LocaleCompare("clamp",option+1) == 0) |
| 4405 | break; |
| 4406 | if (LocaleCompare("clip",option+1) == 0) |
| 4407 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4408 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4409 | { |
| 4410 | if (*option == '+') |
| 4411 | break; |
| 4412 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4413 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4414 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4415 | break; |
| 4416 | } |
| 4417 | if (LocaleCompare("clut",option+1) == 0) |
| 4418 | break; |
| 4419 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4420 | break; |
| 4421 | if (LocaleCompare("colorize",option+1) == 0) |
| 4422 | { |
| 4423 | if (*option == '+') |
| 4424 | break; |
| 4425 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4426 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4427 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4428 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4429 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4430 | break; |
| 4431 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4432 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 4433 | { |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame^] | 4434 | KernelInfo |
| 4435 | *kernel_info; |
| 4436 | |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4437 | if (*option == '+') |
| 4438 | break; |
| 4439 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4440 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4441 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame^] | 4442 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4443 | if (kernel_info == (KernelInfo *) NULL) |
| 4444 | ThrowConvertInvalidArgumentException(option,argv[i]); |
| 4445 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4446 | break; |
| 4447 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4448 | if (LocaleCompare("colors",option+1) == 0) |
| 4449 | { |
| 4450 | if (*option == '+') |
| 4451 | break; |
| 4452 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4453 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4454 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4455 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4456 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4457 | break; |
| 4458 | } |
| 4459 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4460 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4461 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4462 | colorspace; |
| 4463 | |
| 4464 | if (*option == '+') |
| 4465 | break; |
| 4466 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4467 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4468 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4469 | colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse, |
| 4470 | argv[i]); |
| 4471 | if (colorspace < 0) |
| 4472 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4473 | argv[i]); |
| 4474 | break; |
| 4475 | } |
| 4476 | if (LocaleCompare("combine",option+1) == 0) |
| 4477 | break; |
| 4478 | if (LocaleCompare("comment",option+1) == 0) |
| 4479 | { |
| 4480 | if (*option == '+') |
| 4481 | break; |
| 4482 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4483 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4484 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4485 | break; |
| 4486 | } |
| 4487 | if (LocaleCompare("composite",option+1) == 0) |
| 4488 | break; |
| 4489 | if (LocaleCompare("compress",option+1) == 0) |
| 4490 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4491 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4492 | compress; |
| 4493 | |
| 4494 | if (*option == '+') |
| 4495 | break; |
| 4496 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4497 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4498 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4499 | compress=ParseMagickOption(MagickCompressOptions,MagickFalse, |
| 4500 | argv[i]); |
| 4501 | if (compress < 0) |
| 4502 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4503 | argv[i]); |
| 4504 | break; |
| 4505 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4506 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4507 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4508 | if (LocaleCompare("contrast",option+1) == 0) |
| 4509 | break; |
| 4510 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4511 | { |
| 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("convolve",option+1) == 0) |
| 4520 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 4521 | char |
| 4522 | token[MaxTextExtent]; |
| 4523 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame^] | 4524 | KernelInfo |
| 4525 | *kernel_info; |
| 4526 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4527 | if (*option == '+') |
| 4528 | break; |
| 4529 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4530 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4531 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame^] | 4532 | kernel_info=AcquireKernelInfo(argv[i]); |
| 4533 | if (kernel_info == (KernelInfo *) NULL) |
| 4534 | ThrowConvertInvalidArgumentException(option,argv[i]); |
| 4535 | kernel_info=DestroyKernelInfo(kernel_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4536 | break; |
| 4537 | } |
| 4538 | if (LocaleCompare("crop",option+1) == 0) |
| 4539 | { |
| 4540 | if (*option == '+') |
| 4541 | break; |
| 4542 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4543 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4544 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4545 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4546 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4547 | break; |
| 4548 | } |
| 4549 | if (LocaleCompare("cycle",option+1) == 0) |
| 4550 | { |
| 4551 | if (*option == '+') |
| 4552 | break; |
| 4553 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4554 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4555 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4556 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4557 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4558 | break; |
| 4559 | } |
| 4560 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4561 | } |
| 4562 | case 'd': |
| 4563 | { |
| 4564 | if (LocaleCompare("decipher",option+1) == 0) |
| 4565 | { |
| 4566 | if (*option == '+') |
| 4567 | break; |
| 4568 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4569 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4570 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4571 | break; |
| 4572 | } |
| 4573 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 4574 | break; |
| 4575 | if (LocaleCompare("debug",option+1) == 0) |
| 4576 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4577 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4578 | event; |
| 4579 | |
| 4580 | if (*option == '+') |
| 4581 | break; |
| 4582 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4583 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4584 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4585 | event=ParseMagickOption(MagickLogEventOptions,MagickFalse,argv[i]); |
| 4586 | if (event < 0) |
| 4587 | ThrowMogrifyException(OptionError,"UnrecognizedEventType", |
| 4588 | argv[i]); |
| 4589 | (void) SetLogEventMask(argv[i]); |
| 4590 | break; |
| 4591 | } |
| 4592 | if (LocaleCompare("define",option+1) == 0) |
| 4593 | { |
| 4594 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4595 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4596 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4597 | if (*option == '+') |
| 4598 | { |
| 4599 | const char |
| 4600 | *define; |
| 4601 | |
| 4602 | define=GetImageOption(image_info,argv[i]); |
| 4603 | if (define == (const char *) NULL) |
| 4604 | ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); |
| 4605 | break; |
| 4606 | } |
| 4607 | break; |
| 4608 | } |
| 4609 | if (LocaleCompare("delay",option+1) == 0) |
| 4610 | { |
| 4611 | if (*option == '+') |
| 4612 | break; |
| 4613 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4614 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4615 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4616 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4617 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4618 | break; |
| 4619 | } |
| 4620 | if (LocaleCompare("density",option+1) == 0) |
| 4621 | { |
| 4622 | if (*option == '+') |
| 4623 | break; |
| 4624 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4625 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4626 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4627 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4628 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4629 | break; |
| 4630 | } |
| 4631 | if (LocaleCompare("depth",option+1) == 0) |
| 4632 | { |
| 4633 | if (*option == '+') |
| 4634 | break; |
| 4635 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4636 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4637 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4638 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4639 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4640 | break; |
| 4641 | } |
| 4642 | if (LocaleCompare("deskew",option+1) == 0) |
| 4643 | { |
| 4644 | if (*option == '+') |
| 4645 | break; |
| 4646 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4647 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4648 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4649 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4650 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4651 | break; |
| 4652 | } |
| 4653 | if (LocaleCompare("despeckle",option+1) == 0) |
| 4654 | break; |
| 4655 | if (LocaleCompare("dft",option+1) == 0) |
| 4656 | break; |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4657 | if (LocaleCompare("direction",option+1) == 0) |
| 4658 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4659 | ssize_t |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4660 | direction; |
| 4661 | |
| 4662 | if (*option == '+') |
| 4663 | break; |
| 4664 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4665 | if (i == (ssize_t) argc) |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 4666 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4667 | direction=ParseMagickOption(MagickDirectionOptions,MagickFalse, |
| 4668 | argv[i]); |
| 4669 | if (direction < 0) |
| 4670 | ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", |
| 4671 | argv[i]); |
| 4672 | break; |
| 4673 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4674 | if (LocaleCompare("display",option+1) == 0) |
| 4675 | { |
| 4676 | if (*option == '+') |
| 4677 | break; |
| 4678 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4679 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4680 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4681 | break; |
| 4682 | } |
| 4683 | if (LocaleCompare("dispose",option+1) == 0) |
| 4684 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4685 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4686 | dispose; |
| 4687 | |
| 4688 | if (*option == '+') |
| 4689 | break; |
| 4690 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4691 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4692 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4693 | dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]); |
| 4694 | if (dispose < 0) |
| 4695 | ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", |
| 4696 | argv[i]); |
| 4697 | break; |
| 4698 | } |
| 4699 | if (LocaleCompare("distort",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 | op; |
| 4703 | |
| 4704 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4705 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4706 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4707 | op=ParseMagickOption(MagickDistortOptions,MagickFalse,argv[i]); |
| 4708 | if (op < 0) |
| 4709 | ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", |
| 4710 | argv[i]); |
| 4711 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4712 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4713 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4714 | break; |
| 4715 | } |
| 4716 | if (LocaleCompare("dither",option+1) == 0) |
| 4717 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4718 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4719 | method; |
| 4720 | |
| 4721 | if (*option == '+') |
| 4722 | break; |
| 4723 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4724 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4725 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4726 | method=ParseMagickOption(MagickDitherOptions,MagickFalse,argv[i]); |
| 4727 | if (method < 0) |
| 4728 | ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", |
| 4729 | argv[i]); |
| 4730 | break; |
| 4731 | } |
| 4732 | if (LocaleCompare("draw",option+1) == 0) |
| 4733 | { |
| 4734 | if (*option == '+') |
| 4735 | break; |
| 4736 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4737 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4738 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4739 | break; |
| 4740 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4741 | if (LocaleCompare("duration",option+1) == 0) |
| 4742 | { |
| 4743 | if (*option == '+') |
| 4744 | break; |
| 4745 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4746 | if (i == (ssize_t) (argc-1)) |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4747 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4748 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4749 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4750 | break; |
| 4751 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4752 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4753 | } |
| 4754 | case 'e': |
| 4755 | { |
| 4756 | if (LocaleCompare("edge",option+1) == 0) |
| 4757 | { |
| 4758 | if (*option == '+') |
| 4759 | break; |
| 4760 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4761 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4762 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4763 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4764 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4765 | break; |
| 4766 | } |
| 4767 | if (LocaleCompare("emboss",option+1) == 0) |
| 4768 | { |
| 4769 | if (*option == '+') |
| 4770 | break; |
| 4771 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4772 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4773 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4774 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4775 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4776 | break; |
| 4777 | } |
| 4778 | if (LocaleCompare("encipher",option+1) == 0) |
| 4779 | { |
| 4780 | if (*option == '+') |
| 4781 | break; |
| 4782 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4783 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4784 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4785 | break; |
| 4786 | } |
| 4787 | if (LocaleCompare("encoding",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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4793 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4794 | break; |
| 4795 | } |
| 4796 | if (LocaleCompare("endian",option+1) == 0) |
| 4797 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4798 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4799 | endian; |
| 4800 | |
| 4801 | if (*option == '+') |
| 4802 | break; |
| 4803 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4804 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4805 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4806 | endian=ParseMagickOption(MagickEndianOptions,MagickFalse,argv[i]); |
| 4807 | if (endian < 0) |
| 4808 | ThrowMogrifyException(OptionError,"UnrecognizedEndianType", |
| 4809 | argv[i]); |
| 4810 | break; |
| 4811 | } |
| 4812 | if (LocaleCompare("enhance",option+1) == 0) |
| 4813 | break; |
| 4814 | if (LocaleCompare("equalize",option+1) == 0) |
| 4815 | break; |
| 4816 | if (LocaleCompare("evaluate",option+1) == 0) |
| 4817 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4818 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4819 | op; |
| 4820 | |
| 4821 | if (*option == '+') |
| 4822 | break; |
| 4823 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4824 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4825 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4826 | op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
| 4827 | if (op < 0) |
| 4828 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4829 | argv[i]); |
| 4830 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4831 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4832 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4833 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4834 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4835 | break; |
| 4836 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4837 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 4838 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4839 | ssize_t |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4840 | op; |
| 4841 | |
| 4842 | if (*option == '+') |
| 4843 | break; |
| 4844 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4845 | if (i == (ssize_t) argc) |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 4846 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4847 | op=ParseMagickOption(MagickEvaluateOptions,MagickFalse,argv[i]); |
| 4848 | if (op < 0) |
| 4849 | ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", |
| 4850 | argv[i]); |
| 4851 | break; |
| 4852 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4853 | if (LocaleCompare("extent",option+1) == 0) |
| 4854 | { |
| 4855 | if (*option == '+') |
| 4856 | break; |
| 4857 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4858 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4859 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4860 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4861 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4862 | break; |
| 4863 | } |
| 4864 | if (LocaleCompare("extract",option+1) == 0) |
| 4865 | { |
| 4866 | if (*option == '+') |
| 4867 | break; |
| 4868 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4869 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4870 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4871 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4872 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4873 | break; |
| 4874 | } |
| 4875 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4876 | } |
| 4877 | case 'f': |
| 4878 | { |
| 4879 | if (LocaleCompare("family",option+1) == 0) |
| 4880 | { |
| 4881 | if (*option == '+') |
| 4882 | break; |
| 4883 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4884 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4885 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4886 | break; |
| 4887 | } |
| 4888 | if (LocaleCompare("fill",option+1) == 0) |
| 4889 | { |
| 4890 | if (*option == '+') |
| 4891 | break; |
| 4892 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4893 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4894 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4895 | break; |
| 4896 | } |
| 4897 | if (LocaleCompare("filter",option+1) == 0) |
| 4898 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4899 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4900 | filter; |
| 4901 | |
| 4902 | if (*option == '+') |
| 4903 | break; |
| 4904 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4905 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4906 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4907 | filter=ParseMagickOption(MagickFilterOptions,MagickFalse,argv[i]); |
| 4908 | if (filter < 0) |
| 4909 | ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", |
| 4910 | argv[i]); |
| 4911 | break; |
| 4912 | } |
| 4913 | if (LocaleCompare("flatten",option+1) == 0) |
| 4914 | break; |
| 4915 | if (LocaleCompare("flip",option+1) == 0) |
| 4916 | break; |
| 4917 | if (LocaleCompare("flop",option+1) == 0) |
| 4918 | break; |
| 4919 | if (LocaleCompare("floodfill",option+1) == 0) |
| 4920 | { |
| 4921 | if (*option == '+') |
| 4922 | break; |
| 4923 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4924 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4925 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4926 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4927 | ThrowMogrifyInvalidArgumentException(option,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 | break; |
| 4932 | } |
| 4933 | if (LocaleCompare("font",option+1) == 0) |
| 4934 | { |
| 4935 | if (*option == '+') |
| 4936 | break; |
| 4937 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4938 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4939 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4940 | break; |
| 4941 | } |
| 4942 | if (LocaleCompare("format",option+1) == 0) |
| 4943 | { |
| 4944 | (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); |
| 4945 | (void) CloneString(&format,(char *) NULL); |
| 4946 | if (*option == '+') |
| 4947 | break; |
| 4948 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4949 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4950 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4951 | (void) CloneString(&format,argv[i]); |
| 4952 | (void) CopyMagickString(image_info->filename,format,MaxTextExtent); |
| 4953 | (void) ConcatenateMagickString(image_info->filename,":", |
| 4954 | MaxTextExtent); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 4955 | (void) SetImageInfo(image_info,0,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4956 | if (*image_info->magick == '\0') |
| 4957 | ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", |
| 4958 | format); |
| 4959 | break; |
| 4960 | } |
| 4961 | if (LocaleCompare("frame",option+1) == 0) |
| 4962 | { |
| 4963 | if (*option == '+') |
| 4964 | break; |
| 4965 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4966 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4967 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4968 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4969 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4970 | break; |
| 4971 | } |
| 4972 | if (LocaleCompare("function",option+1) == 0) |
| 4973 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4974 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4975 | op; |
| 4976 | |
| 4977 | if (*option == '+') |
| 4978 | break; |
| 4979 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4980 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4981 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4982 | op=ParseMagickOption(MagickFunctionOptions,MagickFalse,argv[i]); |
| 4983 | if (op < 0) |
| 4984 | ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); |
| 4985 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4986 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4987 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4988 | break; |
| 4989 | } |
| 4990 | if (LocaleCompare("fuzz",option+1) == 0) |
| 4991 | { |
| 4992 | if (*option == '+') |
| 4993 | break; |
| 4994 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4995 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4996 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4997 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4998 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4999 | break; |
| 5000 | } |
| 5001 | if (LocaleCompare("fx",option+1) == 0) |
| 5002 | { |
| 5003 | if (*option == '+') |
| 5004 | break; |
| 5005 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5006 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5007 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5008 | break; |
| 5009 | } |
| 5010 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5011 | } |
| 5012 | case 'g': |
| 5013 | { |
| 5014 | if (LocaleCompare("gamma",option+1) == 0) |
| 5015 | { |
| 5016 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5017 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5018 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5019 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5020 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5021 | break; |
| 5022 | } |
| 5023 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 5024 | (LocaleCompare("gaussian",option+1) == 0)) |
| 5025 | { |
| 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("geometry",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 | } |
| 5044 | if (LocaleCompare("gravity",option+1) == 0) |
| 5045 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5046 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5047 | gravity; |
| 5048 | |
| 5049 | if (*option == '+') |
| 5050 | break; |
| 5051 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5052 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5053 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5054 | gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]); |
| 5055 | if (gravity < 0) |
| 5056 | ThrowMogrifyException(OptionError,"UnrecognizedGravityType", |
| 5057 | argv[i]); |
| 5058 | break; |
| 5059 | } |
| 5060 | if (LocaleCompare("green-primary",option+1) == 0) |
| 5061 | { |
| 5062 | if (*option == '+') |
| 5063 | break; |
| 5064 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5065 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5066 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5067 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5068 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5069 | break; |
| 5070 | } |
| 5071 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5072 | } |
| 5073 | case 'h': |
| 5074 | { |
| 5075 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 5076 | break; |
| 5077 | if ((LocaleCompare("help",option+1) == 0) || |
| 5078 | (LocaleCompare("-help",option+1) == 0)) |
| 5079 | return(MogrifyUsage()); |
| 5080 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5081 | } |
| 5082 | case 'i': |
| 5083 | { |
| 5084 | if (LocaleCompare("identify",option+1) == 0) |
| 5085 | break; |
| 5086 | if (LocaleCompare("idft",option+1) == 0) |
| 5087 | break; |
| 5088 | if (LocaleCompare("implode",option+1) == 0) |
| 5089 | { |
| 5090 | if (*option == '+') |
| 5091 | break; |
| 5092 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5093 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5094 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5095 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5096 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5097 | break; |
| 5098 | } |
| 5099 | if (LocaleCompare("intent",option+1) == 0) |
| 5100 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5101 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5102 | intent; |
| 5103 | |
| 5104 | if (*option == '+') |
| 5105 | break; |
| 5106 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5107 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5108 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5109 | intent=ParseMagickOption(MagickIntentOptions,MagickFalse,argv[i]); |
| 5110 | if (intent < 0) |
| 5111 | ThrowMogrifyException(OptionError,"UnrecognizedIntentType", |
| 5112 | argv[i]); |
| 5113 | break; |
| 5114 | } |
| 5115 | if (LocaleCompare("interlace",option+1) == 0) |
| 5116 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5117 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5118 | interlace; |
| 5119 | |
| 5120 | if (*option == '+') |
| 5121 | break; |
| 5122 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5123 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5124 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5125 | interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse, |
| 5126 | argv[i]); |
| 5127 | if (interlace < 0) |
| 5128 | ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", |
| 5129 | argv[i]); |
| 5130 | break; |
| 5131 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 5132 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 5133 | { |
| 5134 | if (*option == '+') |
| 5135 | break; |
| 5136 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5137 | if (i == (ssize_t) (argc-1)) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 5138 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5139 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5140 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5141 | break; |
| 5142 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5143 | if (LocaleCompare("interpolate",option+1) == 0) |
| 5144 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5145 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5146 | interpolate; |
| 5147 | |
| 5148 | if (*option == '+') |
| 5149 | break; |
| 5150 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5151 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5152 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5153 | interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse, |
| 5154 | argv[i]); |
| 5155 | if (interpolate < 0) |
| 5156 | ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", |
| 5157 | argv[i]); |
| 5158 | break; |
| 5159 | } |
| 5160 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 5161 | { |
| 5162 | if (*option == '+') |
| 5163 | break; |
| 5164 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5165 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5166 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5167 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5168 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5169 | break; |
| 5170 | } |
| 5171 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5172 | } |
| 5173 | case 'k': |
| 5174 | { |
| 5175 | if (LocaleCompare("kerning",option+1) == 0) |
| 5176 | { |
| 5177 | if (*option == '+') |
| 5178 | break; |
| 5179 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5180 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5181 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5182 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5183 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5184 | break; |
| 5185 | } |
| 5186 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5187 | } |
| 5188 | case 'l': |
| 5189 | { |
| 5190 | if (LocaleCompare("label",option+1) == 0) |
| 5191 | { |
| 5192 | if (*option == '+') |
| 5193 | break; |
| 5194 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5195 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5196 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5197 | break; |
| 5198 | } |
| 5199 | if (LocaleCompare("lat",option+1) == 0) |
| 5200 | { |
| 5201 | if (*option == '+') |
| 5202 | break; |
| 5203 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5204 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5205 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5206 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5207 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5208 | } |
| 5209 | if (LocaleCompare("layers",option+1) == 0) |
| 5210 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5211 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5212 | type; |
| 5213 | |
| 5214 | if (*option == '+') |
| 5215 | break; |
| 5216 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5217 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5218 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5219 | type=ParseMagickOption(MagickLayerOptions,MagickFalse,argv[i]); |
| 5220 | if (type < 0) |
| 5221 | ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", |
| 5222 | argv[i]); |
| 5223 | break; |
| 5224 | } |
| 5225 | if (LocaleCompare("level",option+1) == 0) |
| 5226 | { |
| 5227 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5228 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5229 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5230 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5231 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5232 | break; |
| 5233 | } |
| 5234 | if (LocaleCompare("level-colors",option+1) == 0) |
| 5235 | { |
| 5236 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5237 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5238 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5239 | break; |
| 5240 | } |
| 5241 | if (LocaleCompare("linewidth",option+1) == 0) |
| 5242 | { |
| 5243 | if (*option == '+') |
| 5244 | break; |
| 5245 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5246 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5247 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5248 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5249 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5250 | break; |
| 5251 | } |
| 5252 | if (LocaleCompare("limit",option+1) == 0) |
| 5253 | { |
| 5254 | char |
| 5255 | *p; |
| 5256 | |
| 5257 | double |
| 5258 | value; |
| 5259 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5260 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5261 | resource; |
| 5262 | |
| 5263 | if (*option == '+') |
| 5264 | break; |
| 5265 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5266 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5267 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5268 | resource=ParseMagickOption(MagickResourceOptions,MagickFalse, |
| 5269 | argv[i]); |
| 5270 | if (resource < 0) |
| 5271 | ThrowMogrifyException(OptionError,"UnrecognizedResourceType", |
| 5272 | argv[i]); |
| 5273 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5274 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5275 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5276 | value=strtod(argv[i],&p); |
| 5277 | if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) |
| 5278 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5279 | break; |
| 5280 | } |
| 5281 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 5282 | { |
| 5283 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5284 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5285 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5286 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5287 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5288 | break; |
| 5289 | } |
| 5290 | if (LocaleCompare("list",option+1) == 0) |
| 5291 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5292 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5293 | list; |
| 5294 | |
| 5295 | if (*option == '+') |
| 5296 | break; |
| 5297 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5298 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5299 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5300 | list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i]); |
| 5301 | if (list < 0) |
| 5302 | ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 5303 | status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5304 | argv+j,exception); |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 5305 | return(status != 0 ? MagickFalse : MagickTrue); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5306 | } |
| 5307 | if (LocaleCompare("log",option+1) == 0) |
| 5308 | { |
| 5309 | if (*option == '+') |
| 5310 | break; |
| 5311 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5312 | if ((i == (ssize_t) argc) || |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5313 | (strchr(argv[i],'%') == (char *) NULL)) |
| 5314 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5315 | break; |
| 5316 | } |
| 5317 | if (LocaleCompare("loop",option+1) == 0) |
| 5318 | { |
| 5319 | if (*option == '+') |
| 5320 | break; |
| 5321 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5322 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5323 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5324 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5325 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5326 | break; |
| 5327 | } |
| 5328 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5329 | } |
| 5330 | case 'm': |
| 5331 | { |
| 5332 | if (LocaleCompare("map",option+1) == 0) |
| 5333 | { |
| 5334 | global_colormap=(*option == '+') ? MagickTrue : MagickFalse; |
| 5335 | if (*option == '+') |
| 5336 | break; |
| 5337 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5338 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5339 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5340 | break; |
| 5341 | } |
| 5342 | if (LocaleCompare("mask",option+1) == 0) |
| 5343 | { |
| 5344 | if (*option == '+') |
| 5345 | break; |
| 5346 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5347 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5348 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5349 | break; |
| 5350 | } |
| 5351 | if (LocaleCompare("matte",option+1) == 0) |
| 5352 | break; |
| 5353 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 5354 | { |
| 5355 | if (*option == '+') |
| 5356 | break; |
| 5357 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5358 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5359 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5360 | break; |
| 5361 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5362 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5363 | break; |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 5364 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 5365 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5366 | if (LocaleCompare("modulate",option+1) == 0) |
| 5367 | { |
| 5368 | if (*option == '+') |
| 5369 | break; |
| 5370 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5371 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5372 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5373 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5374 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5375 | break; |
| 5376 | } |
| 5377 | if (LocaleCompare("median",option+1) == 0) |
| 5378 | { |
| 5379 | if (*option == '+') |
| 5380 | break; |
| 5381 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5382 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5383 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5384 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5385 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5386 | break; |
| 5387 | } |
| 5388 | if (LocaleCompare("monitor",option+1) == 0) |
| 5389 | break; |
| 5390 | if (LocaleCompare("monochrome",option+1) == 0) |
| 5391 | break; |
| 5392 | if (LocaleCompare("morph",option+1) == 0) |
| 5393 | { |
| 5394 | if (*option == '+') |
| 5395 | break; |
| 5396 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5397 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5398 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5399 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5400 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5401 | break; |
| 5402 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5403 | if (LocaleCompare("morphology",option+1) == 0) |
| 5404 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5405 | char |
| 5406 | token[MaxTextExtent]; |
| 5407 | |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame^] | 5408 | KernelInfo |
| 5409 | *kernel_info; |
| 5410 | |
| 5411 | ssize_t |
| 5412 | op; |
| 5413 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5414 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5415 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5416 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5417 | GetMagickToken(argv[i],NULL,token); |
| 5418 | op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token); |
| 5419 | if (op < 0) |
| 5420 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5421 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5422 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5423 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5424 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
cristy | b6bd4ad | 2010-08-08 01:12:27 +0000 | [diff] [blame^] | 5425 | kernel_info=AcquireKernelInfo(argv[i]); |
| 5426 | if (kernel_info == (KernelInfo *) NULL) |
| 5427 | ThrowConvertInvalidArgumentException(option,argv[i]); |
| 5428 | kernel_info=DestroyKernelInfo(kernel_info); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5429 | break; |
| 5430 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5431 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5432 | break; |
| 5433 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5434 | { |
| 5435 | if (*option == '+') |
| 5436 | break; |
| 5437 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5438 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5439 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5440 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5441 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5442 | break; |
| 5443 | } |
| 5444 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5445 | } |
| 5446 | case 'n': |
| 5447 | { |
| 5448 | if (LocaleCompare("negate",option+1) == 0) |
| 5449 | break; |
| 5450 | if (LocaleCompare("noise",option+1) == 0) |
| 5451 | { |
| 5452 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5453 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5454 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5455 | if (*option == '+') |
| 5456 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5457 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5458 | noise; |
| 5459 | |
| 5460 | noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]); |
| 5461 | if (noise < 0) |
| 5462 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5463 | argv[i]); |
| 5464 | break; |
| 5465 | } |
| 5466 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5467 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5468 | break; |
| 5469 | } |
| 5470 | if (LocaleCompare("noop",option+1) == 0) |
| 5471 | break; |
| 5472 | if (LocaleCompare("normalize",option+1) == 0) |
| 5473 | break; |
| 5474 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5475 | } |
| 5476 | case 'o': |
| 5477 | { |
| 5478 | if (LocaleCompare("opaque",option+1) == 0) |
| 5479 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5480 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5481 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5482 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5483 | break; |
| 5484 | } |
| 5485 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5486 | { |
| 5487 | if (*option == '+') |
| 5488 | break; |
| 5489 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5490 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5491 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5492 | break; |
| 5493 | } |
| 5494 | if (LocaleCompare("orient",option+1) == 0) |
| 5495 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5496 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5497 | orientation; |
| 5498 | |
| 5499 | orientation=UndefinedOrientation; |
| 5500 | if (*option == '+') |
| 5501 | break; |
| 5502 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5503 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5504 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5505 | orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse, |
| 5506 | argv[i]); |
| 5507 | if (orientation < 0) |
| 5508 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5509 | argv[i]); |
| 5510 | break; |
| 5511 | } |
| 5512 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5513 | } |
| 5514 | case 'p': |
| 5515 | { |
| 5516 | if (LocaleCompare("page",option+1) == 0) |
| 5517 | { |
| 5518 | if (*option == '+') |
| 5519 | break; |
| 5520 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5521 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5522 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5523 | break; |
| 5524 | } |
| 5525 | if (LocaleCompare("paint",option+1) == 0) |
| 5526 | { |
| 5527 | if (*option == '+') |
| 5528 | break; |
| 5529 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5530 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5531 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5532 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5533 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5534 | break; |
| 5535 | } |
| 5536 | if (LocaleCompare("path",option+1) == 0) |
| 5537 | { |
| 5538 | (void) CloneString(&path,(char *) NULL); |
| 5539 | if (*option == '+') |
| 5540 | break; |
| 5541 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5542 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5543 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5544 | (void) CloneString(&path,argv[i]); |
| 5545 | break; |
| 5546 | } |
| 5547 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5548 | { |
| 5549 | if (*option == '+') |
| 5550 | break; |
| 5551 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5552 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5553 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5554 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5555 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5556 | break; |
| 5557 | } |
| 5558 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5559 | { |
| 5560 | if (*option == '+') |
| 5561 | break; |
| 5562 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5563 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5564 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5565 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5566 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5567 | break; |
| 5568 | } |
| 5569 | if (LocaleCompare("posterize",option+1) == 0) |
| 5570 | { |
| 5571 | if (*option == '+') |
| 5572 | break; |
| 5573 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5574 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5575 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5576 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5577 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5578 | break; |
| 5579 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5580 | if (LocaleCompare("precision",option+1) == 0) |
| 5581 | { |
| 5582 | if (*option == '+') |
| 5583 | break; |
| 5584 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5585 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5586 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5587 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5588 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5589 | break; |
| 5590 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5591 | if (LocaleCompare("print",option+1) == 0) |
| 5592 | { |
| 5593 | if (*option == '+') |
| 5594 | break; |
| 5595 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5596 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5597 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5598 | break; |
| 5599 | } |
| 5600 | if (LocaleCompare("process",option+1) == 0) |
| 5601 | { |
| 5602 | if (*option == '+') |
| 5603 | break; |
| 5604 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5605 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5606 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5607 | break; |
| 5608 | } |
| 5609 | if (LocaleCompare("profile",option+1) == 0) |
| 5610 | { |
| 5611 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5612 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5613 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5614 | break; |
| 5615 | } |
| 5616 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5617 | } |
| 5618 | case 'q': |
| 5619 | { |
| 5620 | if (LocaleCompare("quality",option+1) == 0) |
| 5621 | { |
| 5622 | if (*option == '+') |
| 5623 | break; |
| 5624 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5625 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5626 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5627 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5628 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5629 | break; |
| 5630 | } |
| 5631 | if (LocaleCompare("quantize",option+1) == 0) |
| 5632 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5633 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5634 | colorspace; |
| 5635 | |
| 5636 | if (*option == '+') |
| 5637 | break; |
| 5638 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5639 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5640 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5641 | colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse, |
| 5642 | argv[i]); |
| 5643 | if (colorspace < 0) |
| 5644 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5645 | argv[i]); |
| 5646 | break; |
| 5647 | } |
| 5648 | if (LocaleCompare("quiet",option+1) == 0) |
| 5649 | break; |
| 5650 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5651 | } |
| 5652 | case 'r': |
| 5653 | { |
| 5654 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5655 | { |
| 5656 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5657 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5658 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5659 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5660 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5661 | break; |
| 5662 | } |
| 5663 | if (LocaleCompare("raise",option+1) == 0) |
| 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); |
| 5668 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5669 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5670 | break; |
| 5671 | } |
| 5672 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5673 | { |
| 5674 | if (*option == '+') |
| 5675 | break; |
| 5676 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5677 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5678 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5679 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5680 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5681 | break; |
| 5682 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5683 | if (LocaleCompare("recolor",option+1) == 0) |
| 5684 | { |
| 5685 | if (*option == '+') |
| 5686 | break; |
| 5687 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5688 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5689 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5690 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5691 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5692 | break; |
| 5693 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5694 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5695 | { |
| 5696 | if (*option == '+') |
| 5697 | break; |
| 5698 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5699 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5700 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5701 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5702 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5703 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5704 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5705 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5706 | if (LocaleCompare("region",option+1) == 0) |
| 5707 | { |
| 5708 | if (*option == '+') |
| 5709 | break; |
| 5710 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5711 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5712 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5713 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5714 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5715 | break; |
| 5716 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5717 | if (LocaleCompare("remap",option+1) == 0) |
| 5718 | { |
| 5719 | if (*option == '+') |
| 5720 | break; |
| 5721 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5722 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5723 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5724 | break; |
| 5725 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5726 | if (LocaleCompare("render",option+1) == 0) |
| 5727 | break; |
| 5728 | if (LocaleCompare("repage",option+1) == 0) |
| 5729 | { |
| 5730 | if (*option == '+') |
| 5731 | break; |
| 5732 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5733 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5734 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5735 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5736 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5737 | break; |
| 5738 | } |
| 5739 | if (LocaleCompare("resample",option+1) == 0) |
| 5740 | { |
| 5741 | if (*option == '+') |
| 5742 | break; |
| 5743 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5744 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5745 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5746 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5747 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5748 | break; |
| 5749 | } |
| 5750 | if (LocaleCompare("resize",option+1) == 0) |
| 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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5756 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5757 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5758 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5759 | break; |
| 5760 | } |
| 5761 | if (LocaleCompare("reverse",option+1) == 0) |
| 5762 | break; |
| 5763 | if (LocaleCompare("roll",option+1) == 0) |
| 5764 | { |
| 5765 | if (*option == '+') |
| 5766 | break; |
| 5767 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5768 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5769 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5770 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5771 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5772 | break; |
| 5773 | } |
| 5774 | if (LocaleCompare("rotate",option+1) == 0) |
| 5775 | { |
| 5776 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5777 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5778 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5779 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5780 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5781 | break; |
| 5782 | } |
| 5783 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5784 | } |
| 5785 | case 's': |
| 5786 | { |
| 5787 | if (LocaleCompare("sample",option+1) == 0) |
| 5788 | { |
| 5789 | if (*option == '+') |
| 5790 | break; |
| 5791 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5792 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5793 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5794 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5795 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5796 | break; |
| 5797 | } |
| 5798 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5799 | { |
| 5800 | if (*option == '+') |
| 5801 | break; |
| 5802 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5803 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5804 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5805 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5806 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5807 | break; |
| 5808 | } |
| 5809 | if (LocaleCompare("scale",option+1) == 0) |
| 5810 | { |
| 5811 | if (*option == '+') |
| 5812 | break; |
| 5813 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5814 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5815 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5816 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5817 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5818 | break; |
| 5819 | } |
| 5820 | if (LocaleCompare("scene",option+1) == 0) |
| 5821 | { |
| 5822 | if (*option == '+') |
| 5823 | break; |
| 5824 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5825 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5826 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5827 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5828 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5829 | break; |
| 5830 | } |
| 5831 | if (LocaleCompare("seed",option+1) == 0) |
| 5832 | { |
| 5833 | if (*option == '+') |
| 5834 | break; |
| 5835 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5836 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5837 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5838 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5839 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5840 | break; |
| 5841 | } |
| 5842 | if (LocaleCompare("segment",option+1) == 0) |
| 5843 | { |
| 5844 | if (*option == '+') |
| 5845 | break; |
| 5846 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5847 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5848 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5849 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5850 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5851 | break; |
| 5852 | } |
| 5853 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5854 | { |
| 5855 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5856 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5857 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5858 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5859 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5860 | break; |
| 5861 | } |
| 5862 | if (LocaleCompare("separate",option+1) == 0) |
| 5863 | break; |
| 5864 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5865 | { |
| 5866 | if (*option == '+') |
| 5867 | break; |
| 5868 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5869 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5870 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5871 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5872 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5873 | break; |
| 5874 | } |
| 5875 | if (LocaleCompare("set",option+1) == 0) |
| 5876 | { |
| 5877 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5878 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5879 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5880 | if (*option == '+') |
| 5881 | break; |
| 5882 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5883 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5884 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5885 | break; |
| 5886 | } |
| 5887 | if (LocaleCompare("shade",option+1) == 0) |
| 5888 | { |
| 5889 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5890 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5891 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5892 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5893 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5894 | break; |
| 5895 | } |
| 5896 | if (LocaleCompare("shadow",option+1) == 0) |
| 5897 | { |
| 5898 | if (*option == '+') |
| 5899 | break; |
| 5900 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5901 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5902 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5903 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5904 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5905 | break; |
| 5906 | } |
| 5907 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5908 | { |
| 5909 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5910 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5911 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5912 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5913 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5914 | break; |
| 5915 | } |
| 5916 | if (LocaleCompare("shave",option+1) == 0) |
| 5917 | { |
| 5918 | if (*option == '+') |
| 5919 | break; |
| 5920 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5921 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5922 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5923 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5924 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5925 | break; |
| 5926 | } |
| 5927 | if (LocaleCompare("shear",option+1) == 0) |
| 5928 | { |
| 5929 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5930 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5931 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5932 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5933 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5934 | break; |
| 5935 | } |
| 5936 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5937 | { |
| 5938 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5939 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5940 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5941 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5942 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5943 | break; |
| 5944 | } |
| 5945 | if (LocaleCompare("size",option+1) == 0) |
| 5946 | { |
| 5947 | if (*option == '+') |
| 5948 | break; |
| 5949 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5950 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5951 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5952 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5953 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5954 | break; |
| 5955 | } |
| 5956 | if (LocaleCompare("sketch",option+1) == 0) |
| 5957 | { |
| 5958 | if (*option == '+') |
| 5959 | break; |
| 5960 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5961 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5962 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5963 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5964 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5965 | break; |
| 5966 | } |
| 5967 | if (LocaleCompare("solarize",option+1) == 0) |
| 5968 | { |
| 5969 | if (*option == '+') |
| 5970 | break; |
| 5971 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5972 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5973 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5974 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5975 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5976 | break; |
| 5977 | } |
| 5978 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5979 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5980 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5981 | op; |
| 5982 | |
| 5983 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5984 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5985 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5986 | op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
| 5987 | if (op < 0) |
| 5988 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5989 | argv[i]); |
| 5990 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5991 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5992 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5993 | break; |
| 5994 | } |
| 5995 | if (LocaleCompare("spread",option+1) == 0) |
| 5996 | { |
| 5997 | if (*option == '+') |
| 5998 | break; |
| 5999 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6000 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6001 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6002 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6003 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6004 | break; |
| 6005 | } |
| 6006 | if (LocaleCompare("stretch",option+1) == 0) |
| 6007 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6008 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6009 | stretch; |
| 6010 | |
| 6011 | if (*option == '+') |
| 6012 | break; |
| 6013 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6014 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6015 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6016 | stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,argv[i]); |
| 6017 | if (stretch < 0) |
| 6018 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 6019 | argv[i]); |
| 6020 | break; |
| 6021 | } |
| 6022 | if (LocaleCompare("strip",option+1) == 0) |
| 6023 | break; |
| 6024 | if (LocaleCompare("stroke",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 | break; |
| 6032 | } |
| 6033 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 6034 | { |
| 6035 | if (*option == '+') |
| 6036 | break; |
| 6037 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6038 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6039 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6040 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6041 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6042 | break; |
| 6043 | } |
| 6044 | if (LocaleCompare("style",option+1) == 0) |
| 6045 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6046 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6047 | style; |
| 6048 | |
| 6049 | if (*option == '+') |
| 6050 | break; |
| 6051 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6052 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6053 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6054 | style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]); |
| 6055 | if (style < 0) |
| 6056 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 6057 | argv[i]); |
| 6058 | break; |
| 6059 | } |
| 6060 | if (LocaleCompare("swirl",option+1) == 0) |
| 6061 | { |
| 6062 | if (*option == '+') |
| 6063 | break; |
| 6064 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6065 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6066 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6067 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6068 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6069 | break; |
| 6070 | } |
| 6071 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6072 | } |
| 6073 | case 't': |
| 6074 | { |
| 6075 | if (LocaleCompare("taint",option+1) == 0) |
| 6076 | break; |
| 6077 | if (LocaleCompare("texture",option+1) == 0) |
| 6078 | { |
| 6079 | if (*option == '+') |
| 6080 | break; |
| 6081 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6082 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6083 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6084 | break; |
| 6085 | } |
| 6086 | if (LocaleCompare("tile",option+1) == 0) |
| 6087 | { |
| 6088 | if (*option == '+') |
| 6089 | break; |
| 6090 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6091 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6092 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6093 | break; |
| 6094 | } |
| 6095 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 6096 | { |
| 6097 | if (*option == '+') |
| 6098 | break; |
| 6099 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6100 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6101 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6102 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6103 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6104 | break; |
| 6105 | } |
| 6106 | if (LocaleCompare("tint",option+1) == 0) |
| 6107 | { |
| 6108 | if (*option == '+') |
| 6109 | break; |
| 6110 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6111 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6112 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6113 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6114 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6115 | break; |
| 6116 | } |
| 6117 | if (LocaleCompare("transform",option+1) == 0) |
| 6118 | break; |
| 6119 | if (LocaleCompare("transpose",option+1) == 0) |
| 6120 | break; |
| 6121 | if (LocaleCompare("transverse",option+1) == 0) |
| 6122 | break; |
| 6123 | if (LocaleCompare("threshold",option+1) == 0) |
| 6124 | { |
| 6125 | if (*option == '+') |
| 6126 | break; |
| 6127 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6128 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6129 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6130 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6131 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6132 | break; |
| 6133 | } |
| 6134 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 6135 | { |
| 6136 | if (*option == '+') |
| 6137 | break; |
| 6138 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6139 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6140 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6141 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6142 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6143 | break; |
| 6144 | } |
| 6145 | if (LocaleCompare("transparent",option+1) == 0) |
| 6146 | { |
| 6147 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6148 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6149 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6150 | break; |
| 6151 | } |
| 6152 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 6153 | { |
| 6154 | if (*option == '+') |
| 6155 | break; |
| 6156 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6157 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6158 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6159 | break; |
| 6160 | } |
| 6161 | if (LocaleCompare("treedepth",option+1) == 0) |
| 6162 | { |
| 6163 | if (*option == '+') |
| 6164 | break; |
| 6165 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6166 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6167 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6168 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6169 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6170 | break; |
| 6171 | } |
| 6172 | if (LocaleCompare("trim",option+1) == 0) |
| 6173 | break; |
| 6174 | if (LocaleCompare("type",option+1) == 0) |
| 6175 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6176 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6177 | type; |
| 6178 | |
| 6179 | if (*option == '+') |
| 6180 | break; |
| 6181 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6182 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6183 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6184 | type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]); |
| 6185 | if (type < 0) |
| 6186 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 6187 | argv[i]); |
| 6188 | break; |
| 6189 | } |
| 6190 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6191 | } |
| 6192 | case 'u': |
| 6193 | { |
| 6194 | if (LocaleCompare("undercolor",option+1) == 0) |
| 6195 | { |
| 6196 | if (*option == '+') |
| 6197 | break; |
| 6198 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6199 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6200 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6201 | break; |
| 6202 | } |
| 6203 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 6204 | break; |
| 6205 | if (LocaleCompare("units",option+1) == 0) |
| 6206 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6207 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6208 | units; |
| 6209 | |
| 6210 | if (*option == '+') |
| 6211 | break; |
| 6212 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6213 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6214 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6215 | units=ParseMagickOption(MagickResolutionOptions,MagickFalse, |
| 6216 | argv[i]); |
| 6217 | if (units < 0) |
| 6218 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 6219 | argv[i]); |
| 6220 | break; |
| 6221 | } |
| 6222 | if (LocaleCompare("unsharp",option+1) == 0) |
| 6223 | { |
| 6224 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6225 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6226 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6227 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6228 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6229 | break; |
| 6230 | } |
| 6231 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6232 | } |
| 6233 | case 'v': |
| 6234 | { |
| 6235 | if (LocaleCompare("verbose",option+1) == 0) |
| 6236 | { |
| 6237 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 6238 | break; |
| 6239 | } |
| 6240 | if ((LocaleCompare("version",option+1) == 0) || |
| 6241 | (LocaleCompare("-version",option+1) == 0)) |
| 6242 | { |
| 6243 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6244 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 6245 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 6246 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6247 | break; |
| 6248 | } |
| 6249 | if (LocaleCompare("view",option+1) == 0) |
| 6250 | { |
| 6251 | if (*option == '+') |
| 6252 | break; |
| 6253 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6254 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6255 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6256 | break; |
| 6257 | } |
| 6258 | if (LocaleCompare("vignette",option+1) == 0) |
| 6259 | { |
| 6260 | if (*option == '+') |
| 6261 | break; |
| 6262 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6263 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6264 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6265 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6266 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6267 | break; |
| 6268 | } |
| 6269 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 6270 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6271 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6272 | method; |
| 6273 | |
| 6274 | if (*option == '+') |
| 6275 | break; |
| 6276 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6277 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6278 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6279 | method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 6280 | argv[i]); |
| 6281 | if (method < 0) |
| 6282 | ThrowMogrifyException(OptionError, |
| 6283 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 6284 | break; |
| 6285 | } |
| 6286 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6287 | } |
| 6288 | case 'w': |
| 6289 | { |
| 6290 | if (LocaleCompare("wave",option+1) == 0) |
| 6291 | { |
| 6292 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6293 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6294 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6295 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6296 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6297 | break; |
| 6298 | } |
| 6299 | if (LocaleCompare("weight",option+1) == 0) |
| 6300 | { |
| 6301 | if (*option == '+') |
| 6302 | break; |
| 6303 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6304 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6305 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6306 | break; |
| 6307 | } |
| 6308 | if (LocaleCompare("white-point",option+1) == 0) |
| 6309 | { |
| 6310 | if (*option == '+') |
| 6311 | break; |
| 6312 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6313 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6314 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6315 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6316 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6317 | break; |
| 6318 | } |
| 6319 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6320 | { |
| 6321 | if (*option == '+') |
| 6322 | break; |
| 6323 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6324 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6325 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6326 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6327 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6328 | break; |
| 6329 | } |
| 6330 | if (LocaleCompare("write",option+1) == 0) |
| 6331 | { |
| 6332 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6333 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6334 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6335 | break; |
| 6336 | } |
| 6337 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6338 | } |
| 6339 | case '?': |
| 6340 | break; |
| 6341 | default: |
| 6342 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6343 | } |
| 6344 | fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ? |
| 6345 | MagickFalse : MagickTrue; |
| 6346 | if (fire != MagickFalse) |
| 6347 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6348 | } |
| 6349 | if (k != 0) |
| 6350 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6351 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6352 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6353 | DestroyMogrify(); |
| 6354 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6355 | } |
| 6356 | |
| 6357 | /* |
| 6358 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6359 | % % |
| 6360 | % % |
| 6361 | % % |
| 6362 | + M o g r i f y I m a g e I n f o % |
| 6363 | % % |
| 6364 | % % |
| 6365 | % % |
| 6366 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6367 | % |
| 6368 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6369 | % prescribed by command line options. |
| 6370 | % |
| 6371 | % The format of the MogrifyImageInfo method is: |
| 6372 | % |
| 6373 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6374 | % const char **argv,ExceptionInfo *exception) |
| 6375 | % |
| 6376 | % A description of each parameter follows: |
| 6377 | % |
| 6378 | % o image_info: the image info.. |
| 6379 | % |
| 6380 | % o argc: Specifies a pointer to an integer describing the number of |
| 6381 | % elements in the argument vector. |
| 6382 | % |
| 6383 | % o argv: Specifies a pointer to a text array containing the command line |
| 6384 | % arguments. |
| 6385 | % |
| 6386 | % o exception: return any errors or warnings in this structure. |
| 6387 | % |
| 6388 | */ |
| 6389 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6390 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6391 | { |
| 6392 | const char |
| 6393 | *option; |
| 6394 | |
| 6395 | GeometryInfo |
| 6396 | geometry_info; |
| 6397 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6398 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6399 | count; |
| 6400 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6401 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6402 | i; |
| 6403 | |
| 6404 | /* |
| 6405 | Initialize method variables. |
| 6406 | */ |
| 6407 | assert(image_info != (ImageInfo *) NULL); |
| 6408 | assert(image_info->signature == MagickSignature); |
| 6409 | if (image_info->debug != MagickFalse) |
| 6410 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6411 | image_info->filename); |
| 6412 | if (argc < 0) |
| 6413 | return(MagickTrue); |
| 6414 | /* |
| 6415 | Set the image settings. |
| 6416 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6417 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6418 | { |
| 6419 | option=argv[i]; |
| 6420 | if (IsMagickOption(option) == MagickFalse) |
| 6421 | continue; |
| 6422 | count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option), |
| 6423 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6424 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6425 | break; |
| 6426 | switch (*(option+1)) |
| 6427 | { |
| 6428 | case 'a': |
| 6429 | { |
| 6430 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6431 | { |
| 6432 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6433 | break; |
| 6434 | } |
| 6435 | if (LocaleCompare("antialias",option+1) == 0) |
| 6436 | { |
| 6437 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6438 | break; |
| 6439 | } |
| 6440 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6441 | { |
| 6442 | if (*option == '+') |
| 6443 | { |
| 6444 | (void) DeleteImageOption(image_info,option+1); |
| 6445 | break; |
| 6446 | } |
| 6447 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6448 | break; |
| 6449 | } |
| 6450 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6451 | { |
| 6452 | if (*option == '+') |
| 6453 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6454 | else |
| 6455 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6456 | break; |
| 6457 | } |
| 6458 | break; |
| 6459 | } |
| 6460 | case 'b': |
| 6461 | { |
| 6462 | if (LocaleCompare("background",option+1) == 0) |
| 6463 | { |
| 6464 | if (*option == '+') |
| 6465 | { |
| 6466 | (void) DeleteImageOption(image_info,option+1); |
| 6467 | (void) QueryColorDatabase(BackgroundColor, |
| 6468 | &image_info->background_color,exception); |
| 6469 | break; |
| 6470 | } |
| 6471 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6472 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6473 | exception); |
| 6474 | break; |
| 6475 | } |
| 6476 | if (LocaleCompare("bias",option+1) == 0) |
| 6477 | { |
| 6478 | if (*option == '+') |
| 6479 | { |
| 6480 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6481 | break; |
| 6482 | } |
| 6483 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6484 | break; |
| 6485 | } |
| 6486 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6487 | { |
| 6488 | if (*option == '+') |
| 6489 | { |
| 6490 | (void) SetImageOption(image_info,option+1,"false"); |
| 6491 | break; |
| 6492 | } |
| 6493 | (void) SetImageOption(image_info,option+1,"true"); |
| 6494 | break; |
| 6495 | } |
| 6496 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6497 | { |
| 6498 | if (*option == '+') |
| 6499 | { |
| 6500 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6501 | break; |
| 6502 | } |
| 6503 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6504 | break; |
| 6505 | } |
| 6506 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6507 | { |
| 6508 | if (*option == '+') |
| 6509 | { |
| 6510 | (void) DeleteImageOption(image_info,option+1); |
| 6511 | (void) QueryColorDatabase(BorderColor,&image_info->border_color, |
| 6512 | exception); |
| 6513 | break; |
| 6514 | } |
| 6515 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6516 | exception); |
| 6517 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6518 | break; |
| 6519 | } |
| 6520 | if (LocaleCompare("box",option+1) == 0) |
| 6521 | { |
| 6522 | if (*option == '+') |
| 6523 | { |
| 6524 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6525 | break; |
| 6526 | } |
| 6527 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6528 | break; |
| 6529 | } |
| 6530 | break; |
| 6531 | } |
| 6532 | case 'c': |
| 6533 | { |
| 6534 | if (LocaleCompare("cache",option+1) == 0) |
| 6535 | { |
| 6536 | MagickSizeType |
| 6537 | limit; |
| 6538 | |
| 6539 | limit=MagickResourceInfinity; |
| 6540 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6541 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6542 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6543 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6544 | break; |
| 6545 | } |
| 6546 | if (LocaleCompare("caption",option+1) == 0) |
| 6547 | { |
| 6548 | if (*option == '+') |
| 6549 | { |
| 6550 | (void) DeleteImageOption(image_info,option+1); |
| 6551 | break; |
| 6552 | } |
| 6553 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6554 | break; |
| 6555 | } |
| 6556 | if (LocaleCompare("channel",option+1) == 0) |
| 6557 | { |
| 6558 | if (*option == '+') |
| 6559 | { |
| 6560 | image_info->channel=DefaultChannels; |
| 6561 | break; |
| 6562 | } |
| 6563 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6564 | break; |
| 6565 | } |
| 6566 | if (LocaleCompare("colors",option+1) == 0) |
| 6567 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6568 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6569 | break; |
| 6570 | } |
| 6571 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6572 | { |
| 6573 | if (*option == '+') |
| 6574 | { |
| 6575 | image_info->colorspace=UndefinedColorspace; |
| 6576 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6577 | break; |
| 6578 | } |
| 6579 | image_info->colorspace=(ColorspaceType) ParseMagickOption( |
| 6580 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6581 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6582 | break; |
| 6583 | } |
| 6584 | if (LocaleCompare("compress",option+1) == 0) |
| 6585 | { |
| 6586 | if (*option == '+') |
| 6587 | { |
| 6588 | image_info->compression=UndefinedCompression; |
| 6589 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6590 | break; |
| 6591 | } |
| 6592 | image_info->compression=(CompressionType) ParseMagickOption( |
| 6593 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6594 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6595 | break; |
| 6596 | } |
| 6597 | if (LocaleCompare("comment",option+1) == 0) |
| 6598 | { |
| 6599 | if (*option == '+') |
| 6600 | { |
| 6601 | (void) DeleteImageOption(image_info,option+1); |
| 6602 | break; |
| 6603 | } |
| 6604 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6605 | break; |
| 6606 | } |
| 6607 | if (LocaleCompare("compose",option+1) == 0) |
| 6608 | { |
| 6609 | if (*option == '+') |
| 6610 | { |
| 6611 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6612 | break; |
| 6613 | } |
| 6614 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6615 | break; |
| 6616 | } |
| 6617 | if (LocaleCompare("compress",option+1) == 0) |
| 6618 | { |
| 6619 | if (*option == '+') |
| 6620 | { |
| 6621 | image_info->compression=UndefinedCompression; |
| 6622 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6623 | break; |
| 6624 | } |
| 6625 | image_info->compression=(CompressionType) ParseMagickOption( |
| 6626 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6627 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6628 | break; |
| 6629 | } |
| 6630 | break; |
| 6631 | } |
| 6632 | case 'd': |
| 6633 | { |
| 6634 | if (LocaleCompare("debug",option+1) == 0) |
| 6635 | { |
| 6636 | if (*option == '+') |
| 6637 | (void) SetLogEventMask("none"); |
| 6638 | else |
| 6639 | (void) SetLogEventMask(argv[i+1]); |
| 6640 | image_info->debug=IsEventLogging(); |
| 6641 | break; |
| 6642 | } |
| 6643 | if (LocaleCompare("define",option+1) == 0) |
| 6644 | { |
| 6645 | if (*option == '+') |
| 6646 | { |
| 6647 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6648 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6649 | else |
| 6650 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6651 | break; |
| 6652 | } |
| 6653 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6654 | { |
| 6655 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6656 | exception); |
| 6657 | break; |
| 6658 | } |
| 6659 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6660 | break; |
| 6661 | } |
| 6662 | if (LocaleCompare("delay",option+1) == 0) |
| 6663 | { |
| 6664 | if (*option == '+') |
| 6665 | { |
| 6666 | (void) SetImageOption(image_info,option+1,"0"); |
| 6667 | break; |
| 6668 | } |
| 6669 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6670 | break; |
| 6671 | } |
| 6672 | if (LocaleCompare("density",option+1) == 0) |
| 6673 | { |
| 6674 | /* |
| 6675 | Set image density. |
| 6676 | */ |
| 6677 | if (*option == '+') |
| 6678 | { |
| 6679 | if (image_info->density != (char *) NULL) |
| 6680 | image_info->density=DestroyString(image_info->density); |
| 6681 | (void) SetImageOption(image_info,option+1,"72"); |
| 6682 | break; |
| 6683 | } |
| 6684 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6685 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6686 | break; |
| 6687 | } |
| 6688 | if (LocaleCompare("depth",option+1) == 0) |
| 6689 | { |
| 6690 | if (*option == '+') |
| 6691 | { |
| 6692 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6693 | break; |
| 6694 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6695 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6696 | break; |
| 6697 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6698 | if (LocaleCompare("direction",option+1) == 0) |
| 6699 | { |
| 6700 | if (*option == '+') |
| 6701 | { |
| 6702 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6703 | break; |
| 6704 | } |
| 6705 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6706 | break; |
| 6707 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6708 | if (LocaleCompare("display",option+1) == 0) |
| 6709 | { |
| 6710 | if (*option == '+') |
| 6711 | { |
| 6712 | if (image_info->server_name != (char *) NULL) |
| 6713 | image_info->server_name=DestroyString( |
| 6714 | image_info->server_name); |
| 6715 | break; |
| 6716 | } |
| 6717 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6718 | break; |
| 6719 | } |
| 6720 | if (LocaleCompare("dispose",option+1) == 0) |
| 6721 | { |
| 6722 | if (*option == '+') |
| 6723 | { |
| 6724 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6725 | break; |
| 6726 | } |
| 6727 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6728 | break; |
| 6729 | } |
| 6730 | if (LocaleCompare("dither",option+1) == 0) |
| 6731 | { |
| 6732 | if (*option == '+') |
| 6733 | { |
| 6734 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame] | 6735 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6736 | break; |
| 6737 | } |
| 6738 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6739 | image_info->dither=MagickTrue; |
| 6740 | break; |
| 6741 | } |
| 6742 | break; |
| 6743 | } |
| 6744 | case 'e': |
| 6745 | { |
| 6746 | if (LocaleCompare("encoding",option+1) == 0) |
| 6747 | { |
| 6748 | if (*option == '+') |
| 6749 | { |
| 6750 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6751 | break; |
| 6752 | } |
| 6753 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6754 | break; |
| 6755 | } |
| 6756 | if (LocaleCompare("endian",option+1) == 0) |
| 6757 | { |
| 6758 | if (*option == '+') |
| 6759 | { |
| 6760 | image_info->endian=UndefinedEndian; |
| 6761 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6762 | break; |
| 6763 | } |
| 6764 | image_info->endian=(EndianType) ParseMagickOption( |
| 6765 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6766 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6767 | break; |
| 6768 | } |
| 6769 | if (LocaleCompare("extract",option+1) == 0) |
| 6770 | { |
| 6771 | /* |
| 6772 | Set image extract geometry. |
| 6773 | */ |
| 6774 | if (*option == '+') |
| 6775 | { |
| 6776 | if (image_info->extract != (char *) NULL) |
| 6777 | image_info->extract=DestroyString(image_info->extract); |
| 6778 | break; |
| 6779 | } |
| 6780 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6781 | break; |
| 6782 | } |
| 6783 | break; |
| 6784 | } |
| 6785 | case 'f': |
| 6786 | { |
| 6787 | if (LocaleCompare("fill",option+1) == 0) |
| 6788 | { |
| 6789 | if (*option == '+') |
| 6790 | { |
| 6791 | (void) SetImageOption(image_info,option+1,"none"); |
| 6792 | break; |
| 6793 | } |
| 6794 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6795 | break; |
| 6796 | } |
| 6797 | if (LocaleCompare("filter",option+1) == 0) |
| 6798 | { |
| 6799 | if (*option == '+') |
| 6800 | { |
| 6801 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6802 | break; |
| 6803 | } |
| 6804 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6805 | break; |
| 6806 | } |
| 6807 | if (LocaleCompare("font",option+1) == 0) |
| 6808 | { |
| 6809 | if (*option == '+') |
| 6810 | { |
| 6811 | if (image_info->font != (char *) NULL) |
| 6812 | image_info->font=DestroyString(image_info->font); |
| 6813 | break; |
| 6814 | } |
| 6815 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6816 | break; |
| 6817 | } |
| 6818 | if (LocaleCompare("format",option+1) == 0) |
| 6819 | { |
| 6820 | register const char |
| 6821 | *q; |
| 6822 | |
| 6823 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
| 6824 | if (strchr("gkrz@[#",*(q+1)) != (char *) NULL) |
| 6825 | image_info->ping=MagickFalse; |
| 6826 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6827 | break; |
| 6828 | } |
| 6829 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6830 | { |
| 6831 | if (*option == '+') |
| 6832 | { |
| 6833 | image_info->fuzz=0.0; |
| 6834 | (void) SetImageOption(image_info,option+1,"0"); |
| 6835 | break; |
| 6836 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6837 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6838 | 1.0); |
| 6839 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6840 | break; |
| 6841 | } |
| 6842 | break; |
| 6843 | } |
| 6844 | case 'g': |
| 6845 | { |
| 6846 | if (LocaleCompare("gravity",option+1) == 0) |
| 6847 | { |
| 6848 | if (*option == '+') |
| 6849 | { |
| 6850 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6851 | break; |
| 6852 | } |
| 6853 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6854 | break; |
| 6855 | } |
| 6856 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6857 | { |
| 6858 | if (*option == '+') |
| 6859 | { |
| 6860 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6861 | break; |
| 6862 | } |
| 6863 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6864 | break; |
| 6865 | } |
| 6866 | break; |
| 6867 | } |
| 6868 | case 'i': |
| 6869 | { |
| 6870 | if (LocaleCompare("intent",option+1) == 0) |
| 6871 | { |
| 6872 | if (*option == '+') |
| 6873 | { |
| 6874 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6875 | break; |
| 6876 | } |
| 6877 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6878 | break; |
| 6879 | } |
| 6880 | if (LocaleCompare("interlace",option+1) == 0) |
| 6881 | { |
| 6882 | if (*option == '+') |
| 6883 | { |
| 6884 | image_info->interlace=UndefinedInterlace; |
| 6885 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6886 | break; |
| 6887 | } |
| 6888 | image_info->interlace=(InterlaceType) ParseMagickOption( |
| 6889 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6890 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6891 | break; |
| 6892 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6893 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6894 | { |
| 6895 | if (*option == '+') |
| 6896 | { |
| 6897 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6898 | break; |
| 6899 | } |
| 6900 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6901 | break; |
| 6902 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6903 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6904 | { |
| 6905 | if (*option == '+') |
| 6906 | { |
| 6907 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6908 | break; |
| 6909 | } |
| 6910 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6911 | break; |
| 6912 | } |
| 6913 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6914 | { |
| 6915 | if (*option == '+') |
| 6916 | { |
| 6917 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6918 | break; |
| 6919 | } |
| 6920 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6921 | break; |
| 6922 | } |
| 6923 | break; |
| 6924 | } |
| 6925 | case 'k': |
| 6926 | { |
| 6927 | if (LocaleCompare("kerning",option+1) == 0) |
| 6928 | { |
| 6929 | if (*option == '+') |
| 6930 | { |
| 6931 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6932 | break; |
| 6933 | } |
| 6934 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6935 | break; |
| 6936 | } |
| 6937 | break; |
| 6938 | } |
| 6939 | case 'l': |
| 6940 | { |
| 6941 | if (LocaleCompare("label",option+1) == 0) |
| 6942 | { |
| 6943 | if (*option == '+') |
| 6944 | { |
| 6945 | (void) DeleteImageOption(image_info,option+1); |
| 6946 | break; |
| 6947 | } |
| 6948 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6949 | break; |
| 6950 | } |
| 6951 | if (LocaleCompare("limit",option+1) == 0) |
| 6952 | { |
| 6953 | MagickSizeType |
| 6954 | limit; |
| 6955 | |
| 6956 | ResourceType |
| 6957 | type; |
| 6958 | |
| 6959 | if (*option == '+') |
| 6960 | break; |
| 6961 | type=(ResourceType) ParseMagickOption(MagickResourceOptions, |
| 6962 | MagickFalse,argv[i+1]); |
| 6963 | limit=MagickResourceInfinity; |
| 6964 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6965 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6966 | (void) SetMagickResourceLimit(type,limit); |
| 6967 | break; |
| 6968 | } |
| 6969 | if (LocaleCompare("list",option+1) == 0) |
| 6970 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6971 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6972 | list; |
| 6973 | |
| 6974 | /* |
| 6975 | Display configuration list. |
| 6976 | */ |
| 6977 | list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i+1]); |
| 6978 | switch (list) |
| 6979 | { |
| 6980 | case MagickCoderOptions: |
| 6981 | { |
| 6982 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6983 | break; |
| 6984 | } |
| 6985 | case MagickColorOptions: |
| 6986 | { |
| 6987 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6988 | break; |
| 6989 | } |
| 6990 | case MagickConfigureOptions: |
| 6991 | { |
| 6992 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6993 | break; |
| 6994 | } |
| 6995 | case MagickDelegateOptions: |
| 6996 | { |
| 6997 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6998 | break; |
| 6999 | } |
| 7000 | case MagickFontOptions: |
| 7001 | { |
| 7002 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 7003 | break; |
| 7004 | } |
| 7005 | case MagickFormatOptions: |
| 7006 | { |
| 7007 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 7008 | break; |
| 7009 | } |
| 7010 | case MagickLocaleOptions: |
| 7011 | { |
| 7012 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 7013 | break; |
| 7014 | } |
| 7015 | case MagickLogOptions: |
| 7016 | { |
| 7017 | (void) ListLogInfo((FILE *) NULL,exception); |
| 7018 | break; |
| 7019 | } |
| 7020 | case MagickMagicOptions: |
| 7021 | { |
| 7022 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 7023 | break; |
| 7024 | } |
| 7025 | case MagickMimeOptions: |
| 7026 | { |
| 7027 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 7028 | break; |
| 7029 | } |
| 7030 | case MagickModuleOptions: |
| 7031 | { |
| 7032 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 7033 | break; |
| 7034 | } |
| 7035 | case MagickPolicyOptions: |
| 7036 | { |
| 7037 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 7038 | break; |
| 7039 | } |
| 7040 | case MagickResourceOptions: |
| 7041 | { |
| 7042 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 7043 | break; |
| 7044 | } |
| 7045 | case MagickThresholdOptions: |
| 7046 | { |
| 7047 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 7048 | break; |
| 7049 | } |
| 7050 | default: |
| 7051 | { |
| 7052 | (void) ListMagickOptions((FILE *) NULL,(MagickOption) list, |
| 7053 | exception); |
| 7054 | break; |
| 7055 | } |
| 7056 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 7057 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7058 | } |
| 7059 | if (LocaleCompare("log",option+1) == 0) |
| 7060 | { |
| 7061 | if (*option == '+') |
| 7062 | break; |
| 7063 | (void) SetLogFormat(argv[i+1]); |
| 7064 | break; |
| 7065 | } |
| 7066 | if (LocaleCompare("loop",option+1) == 0) |
| 7067 | { |
| 7068 | if (*option == '+') |
| 7069 | { |
| 7070 | (void) SetImageOption(image_info,option+1,"0"); |
| 7071 | break; |
| 7072 | } |
| 7073 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7074 | break; |
| 7075 | } |
| 7076 | break; |
| 7077 | } |
| 7078 | case 'm': |
| 7079 | { |
| 7080 | if (LocaleCompare("matte",option+1) == 0) |
| 7081 | { |
| 7082 | if (*option == '+') |
| 7083 | { |
| 7084 | (void) SetImageOption(image_info,option+1,"false"); |
| 7085 | break; |
| 7086 | } |
| 7087 | (void) SetImageOption(image_info,option+1,"true"); |
| 7088 | break; |
| 7089 | } |
| 7090 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 7091 | { |
| 7092 | if (*option == '+') |
| 7093 | { |
| 7094 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7095 | (void) QueryColorDatabase(MatteColor,&image_info->matte_color, |
| 7096 | exception); |
| 7097 | break; |
| 7098 | } |
| 7099 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7100 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 7101 | exception); |
| 7102 | break; |
| 7103 | } |
| 7104 | if (LocaleCompare("monitor",option+1) == 0) |
| 7105 | { |
| 7106 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 7107 | (void *) NULL); |
| 7108 | break; |
| 7109 | } |
| 7110 | if (LocaleCompare("monochrome",option+1) == 0) |
| 7111 | { |
| 7112 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 7113 | break; |
| 7114 | } |
| 7115 | break; |
| 7116 | } |
| 7117 | case 'o': |
| 7118 | { |
| 7119 | if (LocaleCompare("orient",option+1) == 0) |
| 7120 | { |
| 7121 | if (*option == '+') |
| 7122 | { |
| 7123 | image_info->orientation=UndefinedOrientation; |
| 7124 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7125 | break; |
| 7126 | } |
| 7127 | image_info->orientation=(OrientationType) ParseMagickOption( |
| 7128 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
cristy | c6e214d | 2010-08-08 00:31:08 +0000 | [diff] [blame] | 7129 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7130 | break; |
| 7131 | } |
| 7132 | } |
| 7133 | case 'p': |
| 7134 | { |
| 7135 | if (LocaleCompare("page",option+1) == 0) |
| 7136 | { |
| 7137 | char |
| 7138 | *canonical_page, |
| 7139 | page[MaxTextExtent]; |
| 7140 | |
| 7141 | const char |
| 7142 | *image_option; |
| 7143 | |
| 7144 | MagickStatusType |
| 7145 | flags; |
| 7146 | |
| 7147 | RectangleInfo |
| 7148 | geometry; |
| 7149 | |
| 7150 | if (*option == '+') |
| 7151 | { |
| 7152 | (void) DeleteImageOption(image_info,option+1); |
| 7153 | (void) CloneString(&image_info->page,(char *) NULL); |
| 7154 | break; |
| 7155 | } |
| 7156 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 7157 | image_option=GetImageOption(image_info,"page"); |
| 7158 | if (image_option != (const char *) NULL) |
| 7159 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 7160 | canonical_page=GetPageGeometry(argv[i+1]); |
| 7161 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 7162 | canonical_page=DestroyString(canonical_page); |
| 7163 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 7164 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7165 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7166 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 7167 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 7168 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7169 | (void) SetImageOption(image_info,option+1,page); |
| 7170 | (void) CloneString(&image_info->page,page); |
| 7171 | break; |
| 7172 | } |
| 7173 | if (LocaleCompare("pen",option+1) == 0) |
| 7174 | { |
| 7175 | if (*option == '+') |
| 7176 | { |
| 7177 | (void) SetImageOption(image_info,option+1,"none"); |
| 7178 | break; |
| 7179 | } |
| 7180 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7181 | break; |
| 7182 | } |
| 7183 | if (LocaleCompare("ping",option+1) == 0) |
| 7184 | { |
| 7185 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 7186 | break; |
| 7187 | } |
| 7188 | if (LocaleCompare("pointsize",option+1) == 0) |
| 7189 | { |
| 7190 | if (*option == '+') |
| 7191 | geometry_info.rho=0.0; |
| 7192 | else |
| 7193 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 7194 | image_info->pointsize=geometry_info.rho; |
| 7195 | break; |
| 7196 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 7197 | if (LocaleCompare("precision",option+1) == 0) |
| 7198 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 7199 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 7200 | break; |
| 7201 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7202 | if (LocaleCompare("preview",option+1) == 0) |
| 7203 | { |
| 7204 | /* |
| 7205 | Preview image. |
| 7206 | */ |
| 7207 | if (*option == '+') |
| 7208 | { |
| 7209 | image_info->preview_type=UndefinedPreview; |
| 7210 | break; |
| 7211 | } |
| 7212 | image_info->preview_type=(PreviewType) ParseMagickOption( |
| 7213 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 7214 | break; |
| 7215 | } |
| 7216 | break; |
| 7217 | } |
| 7218 | case 'q': |
| 7219 | { |
| 7220 | if (LocaleCompare("quality",option+1) == 0) |
| 7221 | { |
| 7222 | /* |
| 7223 | Set image compression quality. |
| 7224 | */ |
| 7225 | if (*option == '+') |
| 7226 | { |
| 7227 | image_info->quality=UndefinedCompressionQuality; |
| 7228 | (void) SetImageOption(image_info,option+1,"0"); |
| 7229 | break; |
| 7230 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7231 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7232 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7233 | break; |
| 7234 | } |
| 7235 | if (LocaleCompare("quiet",option+1) == 0) |
| 7236 | { |
| 7237 | static WarningHandler |
| 7238 | warning_handler = (WarningHandler) NULL; |
| 7239 | |
| 7240 | if (*option == '+') |
| 7241 | { |
| 7242 | /* |
| 7243 | Restore error or warning messages. |
| 7244 | */ |
| 7245 | warning_handler=SetWarningHandler(warning_handler); |
| 7246 | break; |
| 7247 | } |
| 7248 | /* |
| 7249 | Suppress error or warning messages. |
| 7250 | */ |
| 7251 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 7252 | break; |
| 7253 | } |
| 7254 | break; |
| 7255 | } |
| 7256 | case 'r': |
| 7257 | { |
| 7258 | if (LocaleCompare("red-primary",option+1) == 0) |
| 7259 | { |
| 7260 | if (*option == '+') |
| 7261 | { |
| 7262 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7263 | break; |
| 7264 | } |
| 7265 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7266 | break; |
| 7267 | } |
| 7268 | break; |
| 7269 | } |
| 7270 | case 's': |
| 7271 | { |
| 7272 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 7273 | { |
| 7274 | /* |
| 7275 | Set image sampling factor. |
| 7276 | */ |
| 7277 | if (*option == '+') |
| 7278 | { |
| 7279 | if (image_info->sampling_factor != (char *) NULL) |
| 7280 | image_info->sampling_factor=DestroyString( |
| 7281 | image_info->sampling_factor); |
| 7282 | break; |
| 7283 | } |
| 7284 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 7285 | break; |
| 7286 | } |
| 7287 | if (LocaleCompare("scene",option+1) == 0) |
| 7288 | { |
| 7289 | /* |
| 7290 | Set image scene. |
| 7291 | */ |
| 7292 | if (*option == '+') |
| 7293 | { |
| 7294 | image_info->scene=0; |
| 7295 | (void) SetImageOption(image_info,option+1,"0"); |
| 7296 | break; |
| 7297 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7298 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7299 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7300 | break; |
| 7301 | } |
| 7302 | if (LocaleCompare("seed",option+1) == 0) |
| 7303 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7304 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7305 | seed; |
| 7306 | |
| 7307 | if (*option == '+') |
| 7308 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7309 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7310 | SeedPseudoRandomGenerator(seed); |
| 7311 | break; |
| 7312 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7313 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7314 | SeedPseudoRandomGenerator(seed); |
| 7315 | break; |
| 7316 | } |
| 7317 | if (LocaleCompare("size",option+1) == 0) |
| 7318 | { |
| 7319 | if (*option == '+') |
| 7320 | { |
| 7321 | if (image_info->size != (char *) NULL) |
| 7322 | image_info->size=DestroyString(image_info->size); |
| 7323 | break; |
| 7324 | } |
| 7325 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7326 | break; |
| 7327 | } |
| 7328 | if (LocaleCompare("stroke",option+1) == 0) |
| 7329 | { |
| 7330 | if (*option == '+') |
| 7331 | { |
| 7332 | (void) SetImageOption(image_info,option+1,"none"); |
| 7333 | break; |
| 7334 | } |
| 7335 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7336 | break; |
| 7337 | } |
| 7338 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7339 | { |
| 7340 | if (*option == '+') |
| 7341 | { |
| 7342 | (void) SetImageOption(image_info,option+1,"0"); |
| 7343 | break; |
| 7344 | } |
| 7345 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7346 | break; |
| 7347 | } |
| 7348 | break; |
| 7349 | } |
| 7350 | case 't': |
| 7351 | { |
| 7352 | if (LocaleCompare("taint",option+1) == 0) |
| 7353 | { |
| 7354 | if (*option == '+') |
| 7355 | { |
| 7356 | (void) SetImageOption(image_info,option+1,"false"); |
| 7357 | break; |
| 7358 | } |
| 7359 | (void) SetImageOption(image_info,option+1,"true"); |
| 7360 | break; |
| 7361 | } |
| 7362 | if (LocaleCompare("texture",option+1) == 0) |
| 7363 | { |
| 7364 | if (*option == '+') |
| 7365 | { |
| 7366 | if (image_info->texture != (char *) NULL) |
| 7367 | image_info->texture=DestroyString(image_info->texture); |
| 7368 | break; |
| 7369 | } |
| 7370 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7371 | break; |
| 7372 | } |
| 7373 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7374 | { |
| 7375 | if (*option == '+') |
| 7376 | { |
| 7377 | (void) SetImageOption(image_info,option+1,"0"); |
| 7378 | break; |
| 7379 | } |
| 7380 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7381 | break; |
| 7382 | } |
| 7383 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7384 | { |
| 7385 | if (*option == '+') |
| 7386 | { |
| 7387 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7388 | (void) SetImageOption(image_info,option+1,"none"); |
| 7389 | break; |
| 7390 | } |
| 7391 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7392 | exception); |
| 7393 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7394 | break; |
| 7395 | } |
| 7396 | if (LocaleCompare("type",option+1) == 0) |
| 7397 | { |
| 7398 | if (*option == '+') |
| 7399 | { |
| 7400 | image_info->type=UndefinedType; |
| 7401 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7402 | break; |
| 7403 | } |
| 7404 | image_info->type=(ImageType) ParseMagickOption(MagickTypeOptions, |
| 7405 | MagickFalse,argv[i+1]); |
| 7406 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7407 | break; |
| 7408 | } |
| 7409 | break; |
| 7410 | } |
| 7411 | case 'u': |
| 7412 | { |
| 7413 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7414 | { |
| 7415 | if (*option == '+') |
| 7416 | { |
| 7417 | (void) DeleteImageOption(image_info,option+1); |
| 7418 | break; |
| 7419 | } |
| 7420 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7421 | break; |
| 7422 | } |
| 7423 | if (LocaleCompare("units",option+1) == 0) |
| 7424 | { |
| 7425 | if (*option == '+') |
| 7426 | { |
| 7427 | image_info->units=UndefinedResolution; |
| 7428 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7429 | break; |
| 7430 | } |
| 7431 | image_info->units=(ResolutionType) ParseMagickOption( |
| 7432 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7433 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7434 | break; |
| 7435 | } |
| 7436 | break; |
| 7437 | } |
| 7438 | case 'v': |
| 7439 | { |
| 7440 | if (LocaleCompare("verbose",option+1) == 0) |
| 7441 | { |
| 7442 | if (*option == '+') |
| 7443 | { |
| 7444 | image_info->verbose=MagickFalse; |
| 7445 | break; |
| 7446 | } |
| 7447 | image_info->verbose=MagickTrue; |
| 7448 | image_info->ping=MagickFalse; |
| 7449 | break; |
| 7450 | } |
| 7451 | if (LocaleCompare("view",option+1) == 0) |
| 7452 | { |
| 7453 | if (*option == '+') |
| 7454 | { |
| 7455 | if (image_info->view != (char *) NULL) |
| 7456 | image_info->view=DestroyString(image_info->view); |
| 7457 | break; |
| 7458 | } |
| 7459 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7460 | break; |
| 7461 | } |
| 7462 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7463 | { |
| 7464 | if (*option == '+') |
| 7465 | { |
| 7466 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7467 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7468 | break; |
| 7469 | } |
| 7470 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
| 7471 | ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 7472 | argv[i+1]); |
| 7473 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7474 | break; |
| 7475 | } |
| 7476 | break; |
| 7477 | } |
| 7478 | case 'w': |
| 7479 | { |
| 7480 | if (LocaleCompare("white-point",option+1) == 0) |
| 7481 | { |
| 7482 | if (*option == '+') |
| 7483 | { |
| 7484 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7485 | break; |
| 7486 | } |
| 7487 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7488 | break; |
| 7489 | } |
| 7490 | break; |
| 7491 | } |
| 7492 | default: |
| 7493 | break; |
| 7494 | } |
| 7495 | i+=count; |
| 7496 | } |
| 7497 | return(MagickTrue); |
| 7498 | } |
| 7499 | |
| 7500 | /* |
| 7501 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7502 | % % |
| 7503 | % % |
| 7504 | % % |
| 7505 | + M o g r i f y I m a g e L i s t % |
| 7506 | % % |
| 7507 | % % |
| 7508 | % % |
| 7509 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7510 | % |
| 7511 | % MogrifyImageList() applies any command line options that might affect the |
| 7512 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7513 | % |
| 7514 | % The format of the MogrifyImage method is: |
| 7515 | % |
| 7516 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7517 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7518 | % |
| 7519 | % A description of each parameter follows: |
| 7520 | % |
| 7521 | % o image_info: the image info.. |
| 7522 | % |
| 7523 | % o argc: Specifies a pointer to an integer describing the number of |
| 7524 | % elements in the argument vector. |
| 7525 | % |
| 7526 | % o argv: Specifies a pointer to a text array containing the command line |
| 7527 | % arguments. |
| 7528 | % |
| 7529 | % o images: the images. |
| 7530 | % |
| 7531 | % o exception: return any errors or warnings in this structure. |
| 7532 | % |
| 7533 | */ |
| 7534 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7535 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7536 | { |
| 7537 | ChannelType |
| 7538 | channel; |
| 7539 | |
| 7540 | const char |
| 7541 | *option; |
| 7542 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7543 | ImageInfo |
| 7544 | *mogrify_info; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7545 | |
| 7546 | MagickStatusType |
| 7547 | status; |
| 7548 | |
| 7549 | QuantizeInfo |
| 7550 | *quantize_info; |
| 7551 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7552 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7553 | i; |
| 7554 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7555 | ssize_t |
| 7556 | count, |
| 7557 | index; |
| 7558 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7559 | /* |
| 7560 | Apply options to the image list. |
| 7561 | */ |
| 7562 | assert(image_info != (ImageInfo *) NULL); |
| 7563 | assert(image_info->signature == MagickSignature); |
| 7564 | assert(images != (Image **) NULL); |
| 7565 | assert((*images)->signature == MagickSignature); |
| 7566 | if ((*images)->debug != MagickFalse) |
| 7567 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7568 | (*images)->filename); |
| 7569 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7570 | return(MagickTrue); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7571 | mogrify_info=CloneImageInfo(image_info); |
| 7572 | quantize_info=AcquireQuantizeInfo(mogrify_info); |
| 7573 | channel=mogrify_info->channel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7574 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7575 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7576 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7577 | if (*images == (Image *) NULL) |
| 7578 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7579 | option=argv[i]; |
| 7580 | if (IsMagickOption(option) == MagickFalse) |
| 7581 | continue; |
| 7582 | count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option), |
| 7583 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7584 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7585 | break; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7586 | status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7587 | switch (*(option+1)) |
| 7588 | { |
| 7589 | case 'a': |
| 7590 | { |
| 7591 | if (LocaleCompare("affinity",option+1) == 0) |
| 7592 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7593 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7594 | if (*option == '+') |
| 7595 | { |
| 7596 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7597 | InheritException(exception,&(*images)->exception); |
| 7598 | break; |
| 7599 | } |
| 7600 | i++; |
| 7601 | break; |
| 7602 | } |
| 7603 | if (LocaleCompare("append",option+1) == 0) |
| 7604 | { |
| 7605 | Image |
| 7606 | *append_image; |
| 7607 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7608 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7609 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7610 | MagickFalse,exception); |
| 7611 | if (append_image == (Image *) NULL) |
| 7612 | { |
| 7613 | status=MagickFalse; |
| 7614 | break; |
| 7615 | } |
| 7616 | *images=DestroyImageList(*images); |
| 7617 | *images=append_image; |
| 7618 | break; |
| 7619 | } |
| 7620 | if (LocaleCompare("average",option+1) == 0) |
| 7621 | { |
| 7622 | Image |
| 7623 | *average_image; |
| 7624 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7625 | /* |
| 7626 | Average an image sequence (deprecated). |
| 7627 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7628 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7629 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7630 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7631 | if (average_image == (Image *) NULL) |
| 7632 | { |
| 7633 | status=MagickFalse; |
| 7634 | break; |
| 7635 | } |
| 7636 | *images=DestroyImageList(*images); |
| 7637 | *images=average_image; |
| 7638 | break; |
| 7639 | } |
| 7640 | break; |
| 7641 | } |
| 7642 | case 'c': |
| 7643 | { |
| 7644 | if (LocaleCompare("channel",option+1) == 0) |
| 7645 | { |
| 7646 | if (*option == '+') |
| 7647 | { |
| 7648 | channel=DefaultChannels; |
| 7649 | break; |
| 7650 | } |
| 7651 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 7652 | break; |
| 7653 | } |
| 7654 | if (LocaleCompare("clut",option+1) == 0) |
| 7655 | { |
| 7656 | Image |
| 7657 | *clut_image, |
| 7658 | *image; |
| 7659 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7660 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7661 | image=RemoveFirstImageFromList(images); |
| 7662 | clut_image=RemoveFirstImageFromList(images); |
| 7663 | if (clut_image == (Image *) NULL) |
| 7664 | { |
| 7665 | status=MagickFalse; |
| 7666 | break; |
| 7667 | } |
| 7668 | (void) ClutImageChannel(image,channel,clut_image); |
| 7669 | clut_image=DestroyImage(clut_image); |
| 7670 | InheritException(exception,&image->exception); |
| 7671 | *images=DestroyImageList(*images); |
| 7672 | *images=image; |
| 7673 | break; |
| 7674 | } |
| 7675 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7676 | { |
| 7677 | Image |
| 7678 | *coalesce_image; |
| 7679 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7680 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7681 | coalesce_image=CoalesceImages(*images,exception); |
| 7682 | if (coalesce_image == (Image *) NULL) |
| 7683 | { |
| 7684 | status=MagickFalse; |
| 7685 | break; |
| 7686 | } |
| 7687 | *images=DestroyImageList(*images); |
| 7688 | *images=coalesce_image; |
| 7689 | break; |
| 7690 | } |
| 7691 | if (LocaleCompare("combine",option+1) == 0) |
| 7692 | { |
| 7693 | Image |
| 7694 | *combine_image; |
| 7695 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7696 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7697 | combine_image=CombineImages(*images,channel,exception); |
| 7698 | if (combine_image == (Image *) NULL) |
| 7699 | { |
| 7700 | status=MagickFalse; |
| 7701 | break; |
| 7702 | } |
| 7703 | *images=DestroyImageList(*images); |
| 7704 | *images=combine_image; |
| 7705 | break; |
| 7706 | } |
| 7707 | if (LocaleCompare("composite",option+1) == 0) |
| 7708 | { |
| 7709 | Image |
| 7710 | *mask_image, |
| 7711 | *composite_image, |
| 7712 | *image; |
| 7713 | |
| 7714 | RectangleInfo |
| 7715 | geometry; |
| 7716 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7717 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7718 | image=RemoveFirstImageFromList(images); |
| 7719 | composite_image=RemoveFirstImageFromList(images); |
| 7720 | if (composite_image == (Image *) NULL) |
| 7721 | { |
| 7722 | status=MagickFalse; |
| 7723 | break; |
| 7724 | } |
| 7725 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7726 | composite_image->geometry); |
| 7727 | SetGeometry(composite_image,&geometry); |
| 7728 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7729 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7730 | &geometry); |
| 7731 | mask_image=RemoveFirstImageFromList(images); |
| 7732 | if (mask_image != (Image *) NULL) |
| 7733 | { |
| 7734 | if ((image->compose == DisplaceCompositeOp) || |
| 7735 | (image->compose == DistortCompositeOp)) |
| 7736 | { |
| 7737 | /* |
| 7738 | Merge Y displacement into X displacement image. |
| 7739 | */ |
| 7740 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7741 | mask_image,0,0); |
| 7742 | mask_image=DestroyImage(mask_image); |
| 7743 | } |
| 7744 | else |
| 7745 | { |
| 7746 | /* |
| 7747 | Set a blending mask for the composition. |
| 7748 | */ |
| 7749 | image->mask=mask_image; |
| 7750 | (void) NegateImage(image->mask,MagickFalse); |
| 7751 | } |
| 7752 | } |
| 7753 | (void) CompositeImageChannel(image,channel,image->compose, |
| 7754 | composite_image,geometry.x,geometry.y); |
| 7755 | if (image->mask != (Image *) NULL) |
| 7756 | image->mask=DestroyImage(image->mask); |
| 7757 | composite_image=DestroyImage(composite_image); |
| 7758 | InheritException(exception,&image->exception); |
| 7759 | *images=DestroyImageList(*images); |
| 7760 | *images=image; |
| 7761 | break; |
| 7762 | } |
| 7763 | if (LocaleCompare("crop",option+1) == 0) |
| 7764 | { |
| 7765 | MagickStatusType |
| 7766 | flags; |
| 7767 | |
| 7768 | RectangleInfo |
| 7769 | geometry; |
| 7770 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7771 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7772 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7773 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7774 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7775 | break; |
| 7776 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7777 | InheritException(exception,&(*images)->exception); |
| 7778 | break; |
| 7779 | } |
| 7780 | break; |
| 7781 | } |
| 7782 | case 'd': |
| 7783 | { |
| 7784 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7785 | { |
| 7786 | Image |
| 7787 | *deconstruct_image; |
| 7788 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7789 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7790 | deconstruct_image=DeconstructImages(*images,exception); |
| 7791 | if (deconstruct_image == (Image *) NULL) |
| 7792 | { |
| 7793 | status=MagickFalse; |
| 7794 | break; |
| 7795 | } |
| 7796 | *images=DestroyImageList(*images); |
| 7797 | *images=deconstruct_image; |
| 7798 | break; |
| 7799 | } |
| 7800 | if (LocaleCompare("delete",option+1) == 0) |
| 7801 | { |
| 7802 | if (*option == '+') |
| 7803 | DeleteImages(images,"-1",exception); |
| 7804 | else |
| 7805 | DeleteImages(images,argv[i+1],exception); |
| 7806 | break; |
| 7807 | } |
| 7808 | if (LocaleCompare("dither",option+1) == 0) |
| 7809 | { |
| 7810 | if (*option == '+') |
| 7811 | { |
| 7812 | quantize_info->dither=MagickFalse; |
| 7813 | break; |
| 7814 | } |
| 7815 | quantize_info->dither=MagickTrue; |
| 7816 | quantize_info->dither_method=(DitherMethod) ParseMagickOption( |
| 7817 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7818 | break; |
| 7819 | } |
| 7820 | break; |
| 7821 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7822 | case 'e': |
| 7823 | { |
| 7824 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7825 | { |
| 7826 | Image |
| 7827 | *evaluate_image; |
| 7828 | |
| 7829 | MagickEvaluateOperator |
| 7830 | op; |
| 7831 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7832 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7833 | op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions, |
| 7834 | MagickFalse,argv[i+1]); |
| 7835 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7836 | if (evaluate_image == (Image *) NULL) |
| 7837 | { |
| 7838 | status=MagickFalse; |
| 7839 | break; |
| 7840 | } |
| 7841 | *images=DestroyImageList(*images); |
| 7842 | *images=evaluate_image; |
| 7843 | break; |
| 7844 | } |
| 7845 | break; |
| 7846 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7847 | case 'f': |
| 7848 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7849 | if (LocaleCompare("fft",option+1) == 0) |
| 7850 | { |
| 7851 | Image |
| 7852 | *fourier_image; |
| 7853 | |
| 7854 | /* |
| 7855 | Implements the discrete Fourier transform (DFT). |
| 7856 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7857 | (void) SyncImageSettings(mogrify_info,*images); |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7858 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7859 | MagickTrue : MagickFalse,exception); |
| 7860 | if (fourier_image == (Image *) NULL) |
| 7861 | break; |
| 7862 | *images=DestroyImage(*images); |
| 7863 | *images=fourier_image; |
| 7864 | break; |
| 7865 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7866 | if (LocaleCompare("flatten",option+1) == 0) |
| 7867 | { |
| 7868 | Image |
| 7869 | *flatten_image; |
| 7870 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7871 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7872 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7873 | if (flatten_image == (Image *) NULL) |
| 7874 | break; |
| 7875 | *images=DestroyImageList(*images); |
| 7876 | *images=flatten_image; |
| 7877 | break; |
| 7878 | } |
| 7879 | if (LocaleCompare("fx",option+1) == 0) |
| 7880 | { |
| 7881 | Image |
| 7882 | *fx_image; |
| 7883 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7884 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7885 | fx_image=FxImageChannel(*images,channel,argv[i+1],exception); |
| 7886 | if (fx_image == (Image *) NULL) |
| 7887 | { |
| 7888 | status=MagickFalse; |
| 7889 | break; |
| 7890 | } |
| 7891 | *images=DestroyImageList(*images); |
| 7892 | *images=fx_image; |
| 7893 | break; |
| 7894 | } |
| 7895 | break; |
| 7896 | } |
| 7897 | case 'h': |
| 7898 | { |
| 7899 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7900 | { |
| 7901 | Image |
| 7902 | *hald_image, |
| 7903 | *image; |
| 7904 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7905 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7906 | image=RemoveFirstImageFromList(images); |
| 7907 | hald_image=RemoveFirstImageFromList(images); |
| 7908 | if (hald_image == (Image *) NULL) |
| 7909 | { |
| 7910 | status=MagickFalse; |
| 7911 | break; |
| 7912 | } |
| 7913 | (void) HaldClutImageChannel(image,channel,hald_image); |
| 7914 | hald_image=DestroyImage(hald_image); |
| 7915 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7916 | if (*images != (Image *) NULL) |
| 7917 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7918 | *images=image; |
| 7919 | break; |
| 7920 | } |
| 7921 | break; |
| 7922 | } |
| 7923 | case 'i': |
| 7924 | { |
| 7925 | if (LocaleCompare("ift",option+1) == 0) |
| 7926 | { |
| 7927 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7928 | *fourier_image, |
| 7929 | *magnitude_image, |
| 7930 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7931 | |
| 7932 | /* |
| 7933 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7934 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 7935 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7936 | magnitude_image=RemoveFirstImageFromList(images); |
| 7937 | phase_image=RemoveFirstImageFromList(images); |
| 7938 | if (phase_image == (Image *) NULL) |
| 7939 | { |
| 7940 | status=MagickFalse; |
| 7941 | break; |
| 7942 | } |
| 7943 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7944 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7945 | if (fourier_image == (Image *) NULL) |
| 7946 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7947 | if (*images != (Image *) NULL) |
| 7948 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7949 | *images=fourier_image; |
| 7950 | break; |
| 7951 | } |
| 7952 | if (LocaleCompare("insert",option+1) == 0) |
| 7953 | { |
| 7954 | Image |
| 7955 | *p, |
| 7956 | *q; |
| 7957 | |
| 7958 | index=0; |
| 7959 | if (*option != '+') |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 7960 | index=StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7961 | p=RemoveLastImageFromList(images); |
| 7962 | if (p == (Image *) NULL) |
| 7963 | { |
| 7964 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7965 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7966 | status=MagickFalse; |
| 7967 | break; |
| 7968 | } |
| 7969 | q=p; |
| 7970 | if (index == 0) |
| 7971 | PrependImageToList(images,q); |
| 7972 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7973 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7974 | AppendImageToList(images,q); |
| 7975 | else |
| 7976 | { |
| 7977 | q=GetImageFromList(*images,index-1); |
| 7978 | if (q == (Image *) NULL) |
| 7979 | { |
| 7980 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7981 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7982 | status=MagickFalse; |
| 7983 | break; |
| 7984 | } |
| 7985 | InsertImageInList(&q,p); |
| 7986 | } |
| 7987 | *images=GetFirstImageInList(q); |
| 7988 | break; |
| 7989 | } |
| 7990 | break; |
| 7991 | } |
| 7992 | case 'l': |
| 7993 | { |
| 7994 | if (LocaleCompare("layers",option+1) == 0) |
| 7995 | { |
| 7996 | Image |
| 7997 | *layers; |
| 7998 | |
| 7999 | ImageLayerMethod |
| 8000 | method; |
| 8001 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8002 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8003 | layers=(Image *) NULL; |
| 8004 | method=(ImageLayerMethod) ParseMagickOption(MagickLayerOptions, |
| 8005 | MagickFalse,argv[i+1]); |
| 8006 | switch (method) |
| 8007 | { |
| 8008 | case CoalesceLayer: |
| 8009 | { |
| 8010 | layers=CoalesceImages(*images,exception); |
| 8011 | break; |
| 8012 | } |
| 8013 | case CompareAnyLayer: |
| 8014 | case CompareClearLayer: |
| 8015 | case CompareOverlayLayer: |
| 8016 | default: |
| 8017 | { |
| 8018 | layers=CompareImageLayers(*images,method,exception); |
| 8019 | break; |
| 8020 | } |
| 8021 | case MergeLayer: |
| 8022 | case FlattenLayer: |
| 8023 | case MosaicLayer: |
| 8024 | case TrimBoundsLayer: |
| 8025 | { |
| 8026 | layers=MergeImageLayers(*images,method,exception); |
| 8027 | break; |
| 8028 | } |
| 8029 | case DisposeLayer: |
| 8030 | { |
| 8031 | layers=DisposeImages(*images,exception); |
| 8032 | break; |
| 8033 | } |
| 8034 | case OptimizeImageLayer: |
| 8035 | { |
| 8036 | layers=OptimizeImageLayers(*images,exception); |
| 8037 | break; |
| 8038 | } |
| 8039 | case OptimizePlusLayer: |
| 8040 | { |
| 8041 | layers=OptimizePlusImageLayers(*images,exception); |
| 8042 | break; |
| 8043 | } |
| 8044 | case OptimizeTransLayer: |
| 8045 | { |
| 8046 | OptimizeImageTransparency(*images,exception); |
| 8047 | break; |
| 8048 | } |
| 8049 | case RemoveDupsLayer: |
| 8050 | { |
| 8051 | RemoveDuplicateLayers(images,exception); |
| 8052 | break; |
| 8053 | } |
| 8054 | case RemoveZeroLayer: |
| 8055 | { |
| 8056 | RemoveZeroDelayLayers(images,exception); |
| 8057 | break; |
| 8058 | } |
| 8059 | case OptimizeLayer: |
| 8060 | { |
| 8061 | /* |
| 8062 | General Purpose, GIF Animation Optimizer. |
| 8063 | */ |
| 8064 | layers=CoalesceImages(*images,exception); |
| 8065 | if (layers == (Image *) NULL) |
| 8066 | { |
| 8067 | status=MagickFalse; |
| 8068 | break; |
| 8069 | } |
| 8070 | InheritException(exception,&layers->exception); |
| 8071 | *images=DestroyImageList(*images); |
| 8072 | *images=layers; |
| 8073 | layers=OptimizeImageLayers(*images,exception); |
| 8074 | if (layers == (Image *) NULL) |
| 8075 | { |
| 8076 | status=MagickFalse; |
| 8077 | break; |
| 8078 | } |
| 8079 | InheritException(exception,&layers->exception); |
| 8080 | *images=DestroyImageList(*images); |
| 8081 | *images=layers; |
| 8082 | layers=(Image *) NULL; |
| 8083 | OptimizeImageTransparency(*images,exception); |
| 8084 | InheritException(exception,&(*images)->exception); |
| 8085 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 8086 | break; |
| 8087 | } |
| 8088 | case CompositeLayer: |
| 8089 | { |
| 8090 | CompositeOperator |
| 8091 | compose; |
| 8092 | |
| 8093 | Image |
| 8094 | *source; |
| 8095 | |
| 8096 | RectangleInfo |
| 8097 | geometry; |
| 8098 | |
| 8099 | /* |
| 8100 | Split image sequence at the first 'NULL:' image. |
| 8101 | */ |
| 8102 | source=(*images); |
| 8103 | while (source != (Image *) NULL) |
| 8104 | { |
| 8105 | source=GetNextImageInList(source); |
| 8106 | if ((source != (Image *) NULL) && |
| 8107 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 8108 | break; |
| 8109 | } |
| 8110 | if (source != (Image *) NULL) |
| 8111 | { |
| 8112 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 8113 | (GetNextImageInList(source) == (Image *) NULL)) |
| 8114 | source=(Image *) NULL; |
| 8115 | else |
| 8116 | { |
| 8117 | /* |
| 8118 | Separate the two lists, junk the null: image. |
| 8119 | */ |
| 8120 | source=SplitImageList(source->previous); |
| 8121 | DeleteImageFromList(&source); |
| 8122 | } |
| 8123 | } |
| 8124 | if (source == (Image *) NULL) |
| 8125 | { |
| 8126 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8127 | OptionError,"MissingNullSeparator","layers Composite"); |
| 8128 | status=MagickFalse; |
| 8129 | break; |
| 8130 | } |
| 8131 | /* |
| 8132 | Adjust offset with gravity and virtual canvas. |
| 8133 | */ |
| 8134 | SetGeometry(*images,&geometry); |
| 8135 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 8136 | geometry.width=source->page.width != 0 ? |
| 8137 | source->page.width : source->columns; |
| 8138 | geometry.height=source->page.height != 0 ? |
| 8139 | source->page.height : source->rows; |
| 8140 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 8141 | (*images)->page.width : (*images)->columns, |
| 8142 | (*images)->page.height != 0 ? (*images)->page.height : |
| 8143 | (*images)->rows,(*images)->gravity,&geometry); |
| 8144 | compose=OverCompositeOp; |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8145 | option=GetImageOption(mogrify_info,"compose"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8146 | if (option != (const char *) NULL) |
| 8147 | compose=(CompositeOperator) ParseMagickOption( |
| 8148 | MagickComposeOptions,MagickFalse,option); |
| 8149 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 8150 | exception); |
| 8151 | source=DestroyImageList(source); |
| 8152 | break; |
| 8153 | } |
| 8154 | } |
| 8155 | if (layers == (Image *) NULL) |
| 8156 | break; |
| 8157 | InheritException(exception,&layers->exception); |
| 8158 | *images=DestroyImageList(*images); |
| 8159 | *images=layers; |
| 8160 | break; |
| 8161 | } |
| 8162 | break; |
| 8163 | } |
| 8164 | case 'm': |
| 8165 | { |
| 8166 | if (LocaleCompare("map",option+1) == 0) |
| 8167 | { |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8168 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8169 | if (*option == '+') |
| 8170 | { |
| 8171 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 8172 | InheritException(exception,&(*images)->exception); |
| 8173 | break; |
| 8174 | } |
| 8175 | i++; |
| 8176 | break; |
| 8177 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8178 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8179 | { |
| 8180 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8181 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8182 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 8183 | /* |
| 8184 | Maximum image sequence (deprecated). |
| 8185 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8186 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 8187 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8188 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8189 | { |
| 8190 | status=MagickFalse; |
| 8191 | break; |
| 8192 | } |
| 8193 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8194 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8195 | break; |
| 8196 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8197 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8198 | { |
| 8199 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8200 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8201 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 8202 | /* |
| 8203 | Minimum image sequence (deprecated). |
| 8204 | */ |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8205 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 8206 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8207 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8208 | { |
| 8209 | status=MagickFalse; |
| 8210 | break; |
| 8211 | } |
| 8212 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8213 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8214 | break; |
| 8215 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8216 | if (LocaleCompare("morph",option+1) == 0) |
| 8217 | { |
| 8218 | Image |
| 8219 | *morph_image; |
| 8220 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8221 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 8222 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8223 | exception); |
| 8224 | if (morph_image == (Image *) NULL) |
| 8225 | { |
| 8226 | status=MagickFalse; |
| 8227 | break; |
| 8228 | } |
| 8229 | *images=DestroyImageList(*images); |
| 8230 | *images=morph_image; |
| 8231 | break; |
| 8232 | } |
| 8233 | if (LocaleCompare("mosaic",option+1) == 0) |
| 8234 | { |
| 8235 | Image |
| 8236 | *mosaic_image; |
| 8237 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8238 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8239 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 8240 | if (mosaic_image == (Image *) NULL) |
| 8241 | { |
| 8242 | status=MagickFalse; |
| 8243 | break; |
| 8244 | } |
| 8245 | *images=DestroyImageList(*images); |
| 8246 | *images=mosaic_image; |
| 8247 | break; |
| 8248 | } |
| 8249 | break; |
| 8250 | } |
| 8251 | case 'p': |
| 8252 | { |
| 8253 | if (LocaleCompare("print",option+1) == 0) |
| 8254 | { |
| 8255 | char |
| 8256 | *string; |
| 8257 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8258 | (void) SyncImagesSettings(mogrify_info,*images); |
| 8259 | string=InterpretImageProperties(mogrify_info,*images,argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8260 | if (string == (char *) NULL) |
| 8261 | break; |
| 8262 | InheritException(exception,&(*images)->exception); |
| 8263 | (void) fprintf(stdout,"%s",string); |
| 8264 | string=DestroyString(string); |
| 8265 | } |
| 8266 | if (LocaleCompare("process",option+1) == 0) |
| 8267 | { |
| 8268 | char |
| 8269 | **arguments; |
| 8270 | |
| 8271 | int |
| 8272 | j, |
| 8273 | number_arguments; |
| 8274 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8275 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8276 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8277 | if (arguments == (char **) NULL) |
| 8278 | break; |
| 8279 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8280 | { |
| 8281 | char |
| 8282 | breaker, |
| 8283 | quote, |
| 8284 | *token; |
| 8285 | |
| 8286 | const char |
| 8287 | *arguments; |
| 8288 | |
| 8289 | int |
| 8290 | next, |
| 8291 | status; |
| 8292 | |
| 8293 | size_t |
| 8294 | length; |
| 8295 | |
| 8296 | TokenInfo |
| 8297 | *token_info; |
| 8298 | |
| 8299 | /* |
| 8300 | Support old style syntax, filter="-option arg". |
| 8301 | */ |
| 8302 | length=strlen(argv[i+1]); |
| 8303 | token=(char *) NULL; |
| 8304 | if (~length >= MaxTextExtent) |
| 8305 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8306 | sizeof(*token)); |
| 8307 | if (token == (char *) NULL) |
| 8308 | break; |
| 8309 | next=0; |
| 8310 | arguments=argv[i+1]; |
| 8311 | token_info=AcquireTokenInfo(); |
| 8312 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8313 | "\"",'\0',&breaker,&next,"e); |
| 8314 | token_info=DestroyTokenInfo(token_info); |
| 8315 | if (status == 0) |
| 8316 | { |
| 8317 | const char |
| 8318 | *argv; |
| 8319 | |
| 8320 | argv=(&(arguments[next])); |
| 8321 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8322 | exception); |
| 8323 | } |
| 8324 | token=DestroyString(token); |
| 8325 | break; |
| 8326 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8327 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8328 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8329 | number_arguments-2,(const char **) arguments+2,exception); |
| 8330 | for (j=0; j < number_arguments; j++) |
| 8331 | arguments[j]=DestroyString(arguments[j]); |
| 8332 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8333 | break; |
| 8334 | } |
| 8335 | break; |
| 8336 | } |
| 8337 | case 'r': |
| 8338 | { |
| 8339 | if (LocaleCompare("reverse",option+1) == 0) |
| 8340 | { |
| 8341 | ReverseImageList(images); |
| 8342 | InheritException(exception,&(*images)->exception); |
| 8343 | break; |
| 8344 | } |
| 8345 | break; |
| 8346 | } |
| 8347 | case 's': |
| 8348 | { |
| 8349 | if (LocaleCompare("swap",option+1) == 0) |
| 8350 | { |
| 8351 | Image |
| 8352 | *p, |
| 8353 | *q, |
| 8354 | *swap; |
| 8355 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8356 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8357 | swap_index; |
| 8358 | |
| 8359 | index=(-1); |
| 8360 | swap_index=(-2); |
| 8361 | if (*option != '+') |
| 8362 | { |
| 8363 | GeometryInfo |
| 8364 | geometry_info; |
| 8365 | |
| 8366 | MagickStatusType |
| 8367 | flags; |
| 8368 | |
| 8369 | swap_index=(-1); |
| 8370 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8371 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8372 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8373 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8374 | } |
| 8375 | p=GetImageFromList(*images,index); |
| 8376 | q=GetImageFromList(*images,swap_index); |
| 8377 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8378 | { |
| 8379 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8380 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8381 | status=MagickFalse; |
| 8382 | break; |
| 8383 | } |
| 8384 | if (p == q) |
| 8385 | break; |
| 8386 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8387 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8388 | ReplaceImageInList(&q,swap); |
| 8389 | *images=GetFirstImageInList(q); |
| 8390 | break; |
| 8391 | } |
| 8392 | break; |
| 8393 | } |
| 8394 | case 'w': |
| 8395 | { |
| 8396 | if (LocaleCompare("write",option+1) == 0) |
| 8397 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8398 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8399 | key[MaxTextExtent]; |
| 8400 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8401 | Image |
| 8402 | *write_images; |
| 8403 | |
| 8404 | ImageInfo |
| 8405 | *write_info; |
| 8406 | |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8407 | (void) SyncImagesSettings(mogrify_info,*images); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8408 | (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
| 8409 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8410 | write_images=(*images); |
| 8411 | if (*option == '+') |
| 8412 | write_images=CloneImageList(*images,exception); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8413 | write_info=CloneImageInfo(mogrify_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8414 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8415 | write_info=DestroyImageInfo(write_info); |
| 8416 | if (*option == '+') |
| 8417 | write_images=DestroyImageList(write_images); |
| 8418 | break; |
| 8419 | } |
| 8420 | break; |
| 8421 | } |
| 8422 | default: |
| 8423 | break; |
| 8424 | } |
| 8425 | i+=count; |
| 8426 | } |
| 8427 | quantize_info=DestroyQuantizeInfo(quantize_info); |
cristy | 6b3da3a | 2010-06-20 02:21:46 +0000 | [diff] [blame] | 8428 | mogrify_info=DestroyImageInfo(mogrify_info); |
| 8429 | status&=MogrifyImageInfo(image_info,argc,argv,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8430 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8431 | } |
| 8432 | |
| 8433 | /* |
| 8434 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8435 | % % |
| 8436 | % % |
| 8437 | % % |
| 8438 | + M o g r i f y I m a g e s % |
| 8439 | % % |
| 8440 | % % |
| 8441 | % % |
| 8442 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8443 | % |
| 8444 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8445 | % prescribed by command line options. |
| 8446 | % |
| 8447 | % The format of the MogrifyImage method is: |
| 8448 | % |
| 8449 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8450 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8451 | % Image **images,Exceptioninfo *exception) |
| 8452 | % |
| 8453 | % A description of each parameter follows: |
| 8454 | % |
| 8455 | % o image_info: the image info.. |
| 8456 | % |
| 8457 | % o post: If true, post process image list operators otherwise pre-process. |
| 8458 | % |
| 8459 | % o argc: Specifies a pointer to an integer describing the number of |
| 8460 | % elements in the argument vector. |
| 8461 | % |
| 8462 | % o argv: Specifies a pointer to a text array containing the command line |
| 8463 | % arguments. |
| 8464 | % |
| 8465 | % o images: the images. |
| 8466 | % |
| 8467 | % o exception: return any errors or warnings in this structure. |
| 8468 | % |
| 8469 | */ |
| 8470 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8471 | const MagickBooleanType post,const int argc,const char **argv, |
| 8472 | Image **images,ExceptionInfo *exception) |
| 8473 | { |
| 8474 | #define MogrifyImageTag "Mogrify/Image" |
| 8475 | |
| 8476 | Image |
| 8477 | *image, |
| 8478 | *mogrify_images; |
| 8479 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8480 | MagickBooleanType |
| 8481 | proceed; |
| 8482 | |
| 8483 | MagickSizeType |
| 8484 | number_images; |
| 8485 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8486 | MagickStatusType |
| 8487 | status; |
| 8488 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8489 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8490 | i; |
| 8491 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8492 | /* |
| 8493 | Apply options to individual images in the list. |
| 8494 | */ |
| 8495 | assert(image_info != (ImageInfo *) NULL); |
| 8496 | assert(image_info->signature == MagickSignature); |
| 8497 | if (images == (Image **) NULL) |
| 8498 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
| 8499 | assert((*images)->signature == MagickSignature); |
| 8500 | if ((*images)->debug != MagickFalse) |
| 8501 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8502 | (*images)->filename); |
| 8503 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8504 | return(MagickTrue); |
| 8505 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8506 | (void *) NULL); |
| 8507 | mogrify_images=NewImageList(); |
| 8508 | number_images=GetImageListLength(*images); |
| 8509 | status=0; |
| 8510 | if (post == MagickFalse) |
| 8511 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8512 | for (i=0; i < (ssize_t) number_images; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8513 | { |
| 8514 | image=RemoveFirstImageFromList(images); |
| 8515 | if (image == (Image *) NULL) |
| 8516 | continue; |
| 8517 | status&=MogrifyImage(image_info,argc,argv,&image,exception); |
| 8518 | AppendImageToList(&mogrify_images,image); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8519 | proceed=SetImageProgress(image,MogrifyImageTag,(MagickOffsetType) i, |
| 8520 | number_images); |
| 8521 | if (proceed == MagickFalse) |
| 8522 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8523 | } |
| 8524 | if (post != MagickFalse) |
| 8525 | status&=MogrifyImageList(image_info,argc,argv,&mogrify_images,exception); |
| 8526 | *images=mogrify_images; |
| 8527 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8528 | } |