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 | ceae09d | 2009-10-28 17:18:47 +0000 | [diff] [blame] | 199 | # pragma omp critical (MagickCore_Launch_Command) |
| 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 | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 227 | } |
| 228 | timer=DestroyTimerInfo(timer); |
cristy | 1f9e1ed | 2009-11-18 04:09:38 +0000 | [diff] [blame] | 229 | return(status); |
cristy | 3980b0d | 2009-10-25 14:37:13 +0000 | [diff] [blame] | 230 | } |
| 231 | |
| 232 | /* |
| 233 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 234 | % % |
| 235 | % % |
| 236 | % % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 237 | + M o g r i f y I m a g e % |
| 238 | % % |
| 239 | % % |
| 240 | % % |
| 241 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 242 | % |
| 243 | % MogrifyImage() applies image processing options to an image as prescribed |
| 244 | % by command line options. |
| 245 | % |
| 246 | % The format of the MogrifyImage method is: |
| 247 | % |
| 248 | % MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 249 | % const char **argv,Image **image) |
| 250 | % |
| 251 | % A description of each parameter follows: |
| 252 | % |
| 253 | % o image_info: the image info.. |
| 254 | % |
| 255 | % o argc: Specifies a pointer to an integer describing the number of |
| 256 | % elements in the argument vector. |
| 257 | % |
| 258 | % o argv: Specifies a pointer to a text array containing the command line |
| 259 | % arguments. |
| 260 | % |
| 261 | % o image: the image. |
| 262 | % |
| 263 | % o exception: return any errors or warnings in this structure. |
| 264 | % |
| 265 | */ |
| 266 | |
| 267 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path, |
| 268 | ExceptionInfo *exception) |
| 269 | { |
| 270 | char |
| 271 | key[MaxTextExtent]; |
| 272 | |
| 273 | ExceptionInfo |
| 274 | *sans_exception; |
| 275 | |
| 276 | Image |
| 277 | *image; |
| 278 | |
| 279 | ImageInfo |
| 280 | *read_info; |
| 281 | |
| 282 | (void) FormatMagickString(key,MaxTextExtent,"cache:%s",path); |
| 283 | sans_exception=AcquireExceptionInfo(); |
| 284 | image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception); |
| 285 | sans_exception=DestroyExceptionInfo(sans_exception); |
| 286 | if (image != (Image *) NULL) |
| 287 | return(image); |
| 288 | read_info=CloneImageInfo(image_info); |
| 289 | (void) CopyMagickString(read_info->filename,path,MaxTextExtent); |
| 290 | image=ReadImage(read_info,exception); |
| 291 | read_info=DestroyImageInfo(read_info); |
| 292 | if (image != (Image *) NULL) |
| 293 | (void) SetImageRegistry(ImageRegistryType,key,image,exception); |
| 294 | return(image); |
| 295 | } |
| 296 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 297 | static MagickBooleanType IsPathWritable(const char *path) |
| 298 | { |
| 299 | if (IsPathAccessible(path) == MagickFalse) |
| 300 | return(MagickFalse); |
| 301 | if (access(path,W_OK) != 0) |
| 302 | return(MagickFalse); |
| 303 | return(MagickTrue); |
| 304 | } |
| 305 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 306 | static inline ssize_t MagickMax(const ssize_t x,const ssize_t y) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 307 | { |
| 308 | if (x > y) |
| 309 | return(x); |
| 310 | return(y); |
| 311 | } |
| 312 | |
| 313 | static MagickBooleanType MonitorProgress(const char *text, |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 314 | const MagickOffsetType offset,const MagickSizeType extent, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 315 | void *wand_unused(client_data)) |
| 316 | { |
| 317 | char |
| 318 | message[MaxTextExtent], |
| 319 | tag[MaxTextExtent]; |
| 320 | |
| 321 | const char |
| 322 | *locale_message; |
| 323 | |
| 324 | register char |
| 325 | *p; |
| 326 | |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 327 | if (extent < 2) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 328 | return(MagickTrue); |
| 329 | (void) CopyMagickMemory(tag,text,MaxTextExtent); |
| 330 | p=strrchr(tag,'/'); |
| 331 | if (p != (char *) NULL) |
| 332 | *p='\0'; |
| 333 | (void) FormatMagickString(message,MaxTextExtent,"Monitor/%s",tag); |
| 334 | locale_message=GetLocaleMessage(message); |
| 335 | if (locale_message == message) |
| 336 | locale_message=tag; |
| 337 | if (p == (char *) NULL) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 338 | (void) fprintf(stderr,"%s: %ld of %lu, %02ld%% complete\r",locale_message, |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 339 | (long) offset,(unsigned long) extent,(long) (100L*offset/(extent-1))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 340 | else |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 341 | (void) fprintf(stderr,"%s[%s]: %ld of %lu, %02ld%% complete\r", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 342 | locale_message,p+1,(long) offset,(unsigned long) extent,(long) |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 343 | (100L*offset/(extent-1))); |
| 344 | if (offset == (MagickOffsetType) (extent-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 345 | (void) fprintf(stderr,"\n"); |
| 346 | (void) fflush(stderr); |
| 347 | return(MagickTrue); |
| 348 | } |
| 349 | |
| 350 | static Image *SparseColorOption(const Image *image,const ChannelType channel, |
| 351 | const SparseColorMethod method,const char *arguments, |
| 352 | const MagickBooleanType color_from_image,ExceptionInfo *exception) |
| 353 | { |
| 354 | ChannelType |
| 355 | channels; |
| 356 | |
| 357 | char |
| 358 | token[MaxTextExtent]; |
| 359 | |
| 360 | const char |
| 361 | *p; |
| 362 | |
| 363 | double |
| 364 | *sparse_arguments; |
| 365 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 366 | register size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 367 | x; |
| 368 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 369 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 370 | number_arguments; |
| 371 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 372 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 373 | number_colors; |
| 374 | |
| 375 | Image |
| 376 | *sparse_image; |
| 377 | |
| 378 | MagickPixelPacket |
| 379 | color; |
| 380 | |
| 381 | MagickBooleanType |
| 382 | error; |
| 383 | |
| 384 | assert(image != (Image *) NULL); |
| 385 | assert(image->signature == MagickSignature); |
| 386 | if (image->debug != MagickFalse) |
| 387 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 388 | assert(exception != (ExceptionInfo *) NULL); |
| 389 | assert(exception->signature == MagickSignature); |
| 390 | /* |
| 391 | Limit channels according to image - and add up number of color channel. |
| 392 | */ |
| 393 | channels=channel; |
| 394 | if (image->colorspace != CMYKColorspace) |
| 395 | channels=(ChannelType) (channels & ~IndexChannel); /* no index channel */ |
| 396 | if (image->matte == MagickFalse) |
| 397 | channels=(ChannelType) (channels & ~OpacityChannel); /* no alpha channel */ |
| 398 | number_colors=0; |
| 399 | if ((channels & RedChannel) != 0) |
| 400 | number_colors++; |
| 401 | if ((channels & GreenChannel) != 0) |
| 402 | number_colors++; |
| 403 | if ((channels & BlueChannel) != 0) |
| 404 | number_colors++; |
| 405 | if ((channels & IndexChannel) != 0) |
| 406 | number_colors++; |
| 407 | if ((channels & OpacityChannel) != 0) |
| 408 | number_colors++; |
| 409 | /* |
| 410 | Read string, to determine number of arguments needed, |
| 411 | */ |
| 412 | p=arguments; |
| 413 | x=0; |
| 414 | while( *p != '\0' ) |
| 415 | { |
| 416 | GetMagickToken(p,&p,token); |
| 417 | if ( token[0] == ',' ) continue; |
| 418 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 419 | if ( color_from_image ) { |
| 420 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 421 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 422 | "Color arg given, when colors are coming from image"); |
| 423 | return( (Image *)NULL); |
| 424 | } |
| 425 | x += number_colors; /* color argument */ |
| 426 | } |
| 427 | else { |
| 428 | x++; /* floating point argument */ |
| 429 | } |
| 430 | } |
| 431 | error=MagickTrue; |
| 432 | if ( color_from_image ) { |
| 433 | /* just the control points are being given */ |
| 434 | error = ( x % 2 != 0 ) ? MagickTrue : MagickFalse; |
| 435 | number_arguments=(x/2)*(2+number_colors); |
| 436 | } |
| 437 | else { |
| 438 | /* control points and color values */ |
| 439 | error = ( x % (2+number_colors) != 0 ) ? MagickTrue : MagickFalse; |
| 440 | number_arguments=x; |
| 441 | } |
| 442 | if ( error ) { |
| 443 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 444 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 445 | "Invalid number of Arguments"); |
| 446 | return( (Image *)NULL); |
| 447 | } |
| 448 | |
| 449 | /* Allocate and fill in the floating point arguments */ |
| 450 | sparse_arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 451 | sizeof(*sparse_arguments)); |
| 452 | if (sparse_arguments == (double *) NULL) { |
| 453 | (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError, |
| 454 | "MemoryAllocationFailed","%s","SparseColorOption"); |
| 455 | return( (Image *)NULL); |
| 456 | } |
| 457 | (void) ResetMagickMemory(sparse_arguments,0,number_arguments* |
| 458 | sizeof(*sparse_arguments)); |
| 459 | p=arguments; |
| 460 | x=0; |
| 461 | while( *p != '\0' && x < number_arguments ) { |
| 462 | /* X coordinate */ |
| 463 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 464 | if ( token[0] == '\0' ) break; |
| 465 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 466 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 467 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 468 | "Color found, instead of X-coord"); |
| 469 | error = MagickTrue; |
| 470 | break; |
| 471 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 472 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 473 | /* Y coordinate */ |
| 474 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 475 | if ( token[0] == '\0' ) break; |
| 476 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 477 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 478 | OptionError, "InvalidArgument", "`%s': %s", "sparse-color", |
| 479 | "Color found, instead of Y-coord"); |
| 480 | error = MagickTrue; |
| 481 | break; |
| 482 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 483 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 484 | /* color values for this control point */ |
| 485 | #if 0 |
| 486 | if ( (color_from_image ) { |
| 487 | /* get color from image */ |
| 488 | /* HOW??? */ |
| 489 | } |
| 490 | else |
| 491 | #endif |
| 492 | { |
| 493 | /* color name or function given in string argument */ |
| 494 | token[0]=','; while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 495 | if ( token[0] == '\0' ) break; |
| 496 | if ( isalpha((int) token[0]) || token[0] == '#' ) { |
| 497 | /* Color string given */ |
| 498 | (void) QueryMagickColor(token,&color,exception); |
| 499 | if ( channels & RedChannel ) |
| 500 | sparse_arguments[x++] = QuantumScale*color.red; |
| 501 | if ( channels & GreenChannel ) |
| 502 | sparse_arguments[x++] = QuantumScale*color.green; |
| 503 | if ( channels & BlueChannel ) |
| 504 | sparse_arguments[x++] = QuantumScale*color.blue; |
| 505 | if ( channels & IndexChannel ) |
| 506 | sparse_arguments[x++] = QuantumScale*color.index; |
| 507 | if ( channels & OpacityChannel ) |
| 508 | sparse_arguments[x++] = QuantumScale*color.opacity; |
| 509 | } |
| 510 | else { |
| 511 | #if 0 |
| 512 | /* the color name/function/value was not found - error */ |
| 513 | break; |
| 514 | #else |
| 515 | /* Colors given as a set of floating point values - experimental */ |
| 516 | /* NB: token contains the first floating point value to use! */ |
| 517 | if ( channels & RedChannel ) { |
| 518 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 519 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 520 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 521 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 522 | token[0] = ','; /* used this token - get another */ |
| 523 | } |
| 524 | if ( channels & GreenChannel ) { |
| 525 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 526 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 527 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 528 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 529 | token[0] = ','; /* used this token - get another */ |
| 530 | } |
| 531 | if ( channels & BlueChannel ) { |
| 532 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 533 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 534 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 535 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 536 | token[0] = ','; /* used this token - get another */ |
| 537 | } |
| 538 | if ( channels & IndexChannel ) { |
| 539 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 540 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 541 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 542 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 543 | token[0] = ','; /* used this token - get another */ |
| 544 | } |
| 545 | if ( channels & OpacityChannel ) { |
| 546 | while ( token[0] == ',' ) GetMagickToken(p,&p,token); |
| 547 | if ( token[0] == '\0' || isalpha((int)token[0]) || token[0] == '#' ) |
| 548 | break; |
cristy | 0f19e68 | 2009-12-17 14:55:51 +0000 | [diff] [blame] | 549 | sparse_arguments[x++]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 550 | token[0] = ','; /* used this token - get another */ |
| 551 | } |
| 552 | #endif |
| 553 | } |
| 554 | } |
| 555 | } |
| 556 | if ( number_arguments != x && !error ) { |
| 557 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
| 558 | "InvalidArgument","`%s': %s","sparse-color","Argument Parsing Error"); |
| 559 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 560 | return( (Image *)NULL); |
| 561 | } |
| 562 | if ( error ) |
| 563 | return( (Image *)NULL); |
| 564 | |
| 565 | /* Call the Interpolation function with the parsed arguments */ |
| 566 | sparse_image=SparseColorImage(image,channels,method,number_arguments, |
| 567 | sparse_arguments,exception); |
| 568 | sparse_arguments=(double *) RelinquishMagickMemory(sparse_arguments); |
| 569 | return( sparse_image ); |
| 570 | } |
| 571 | |
| 572 | WandExport MagickBooleanType MogrifyImage(ImageInfo *image_info,const int argc, |
| 573 | const char **argv,Image **image,ExceptionInfo *exception) |
| 574 | { |
| 575 | ChannelType |
| 576 | channel; |
| 577 | |
| 578 | const char |
| 579 | *format, |
| 580 | *option; |
| 581 | |
| 582 | DrawInfo |
| 583 | *draw_info; |
| 584 | |
| 585 | GeometryInfo |
| 586 | geometry_info; |
| 587 | |
| 588 | Image |
| 589 | *region_image; |
| 590 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 591 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 592 | count; |
| 593 | |
| 594 | MagickBooleanType |
| 595 | status; |
| 596 | |
| 597 | MagickPixelPacket |
| 598 | fill; |
| 599 | |
| 600 | MagickStatusType |
| 601 | flags; |
| 602 | |
| 603 | QuantizeInfo |
| 604 | *quantize_info; |
| 605 | |
| 606 | RectangleInfo |
| 607 | geometry, |
| 608 | region_geometry; |
| 609 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 610 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 611 | i; |
| 612 | |
| 613 | /* |
| 614 | Initialize method variables. |
| 615 | */ |
| 616 | assert(image_info != (const ImageInfo *) NULL); |
| 617 | assert(image_info->signature == MagickSignature); |
| 618 | assert(image != (Image **) NULL); |
| 619 | assert((*image)->signature == MagickSignature); |
| 620 | if ((*image)->debug != MagickFalse) |
| 621 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",(*image)->filename); |
| 622 | if (argc < 0) |
| 623 | return(MagickTrue); |
| 624 | draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL); |
| 625 | quantize_info=AcquireQuantizeInfo(image_info); |
| 626 | SetGeometryInfo(&geometry_info); |
| 627 | GetMagickPixelPacket(*image,&fill); |
| 628 | SetMagickPixelPacket(*image,&(*image)->background_color,(IndexPacket *) NULL, |
| 629 | &fill); |
| 630 | channel=image_info->channel; |
| 631 | format=GetImageOption(image_info,"format"); |
| 632 | SetGeometry(*image,®ion_geometry); |
| 633 | region_image=NewImageList(); |
| 634 | /* |
| 635 | Transmogrify the image. |
| 636 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 637 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 638 | { |
| 639 | option=argv[i]; |
| 640 | if (IsMagickOption(option) == MagickFalse) |
| 641 | continue; |
| 642 | count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option), |
| 643 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 644 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 645 | break; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 646 | status=MogrifyImageInfo(image_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 647 | switch (*(option+1)) |
| 648 | { |
| 649 | case 'a': |
| 650 | { |
| 651 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 652 | { |
| 653 | Image |
| 654 | *blur_image; |
| 655 | |
| 656 | /* |
| 657 | Adaptive blur image. |
| 658 | */ |
| 659 | (void) SyncImageSettings(image_info,*image); |
| 660 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 661 | if ((flags & SigmaValue) == 0) |
| 662 | geometry_info.sigma=1.0; |
| 663 | blur_image=AdaptiveBlurImageChannel(*image,channel, |
| 664 | geometry_info.rho,geometry_info.sigma,exception); |
| 665 | if (blur_image == (Image *) NULL) |
| 666 | break; |
| 667 | *image=DestroyImage(*image); |
| 668 | *image=blur_image; |
| 669 | break; |
| 670 | } |
| 671 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 672 | { |
| 673 | Image |
| 674 | *resize_image; |
| 675 | |
| 676 | /* |
| 677 | Adaptive resize image. |
| 678 | */ |
| 679 | (void) SyncImageSettings(image_info,*image); |
| 680 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 681 | resize_image=AdaptiveResizeImage(*image,geometry.width, |
| 682 | geometry.height,exception); |
| 683 | if (resize_image == (Image *) NULL) |
| 684 | break; |
| 685 | *image=DestroyImage(*image); |
| 686 | *image=resize_image; |
| 687 | break; |
| 688 | } |
| 689 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 690 | { |
| 691 | Image |
| 692 | *sharp_image; |
| 693 | |
| 694 | /* |
| 695 | Adaptive sharpen image. |
| 696 | */ |
| 697 | (void) SyncImageSettings(image_info,*image); |
| 698 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 699 | if ((flags & SigmaValue) == 0) |
| 700 | geometry_info.sigma=1.0; |
| 701 | sharp_image=AdaptiveSharpenImageChannel(*image,channel, |
| 702 | geometry_info.rho,geometry_info.sigma,exception); |
| 703 | if (sharp_image == (Image *) NULL) |
| 704 | break; |
| 705 | *image=DestroyImage(*image); |
| 706 | *image=sharp_image; |
| 707 | break; |
| 708 | } |
| 709 | if (LocaleCompare("affine",option+1) == 0) |
| 710 | { |
| 711 | /* |
| 712 | Affine matrix. |
| 713 | */ |
| 714 | if (*option == '+') |
| 715 | { |
| 716 | GetAffineMatrix(&draw_info->affine); |
| 717 | break; |
| 718 | } |
| 719 | (void) ParseAffineGeometry(argv[i+1],&draw_info->affine,exception); |
| 720 | break; |
| 721 | } |
| 722 | if (LocaleCompare("alpha",option+1) == 0) |
| 723 | { |
| 724 | AlphaChannelType |
| 725 | alpha_type; |
| 726 | |
| 727 | (void) SyncImageSettings(image_info,*image); |
| 728 | alpha_type=(AlphaChannelType) ParseMagickOption(MagickAlphaOptions, |
| 729 | MagickFalse,argv[i+1]); |
| 730 | (void) SetImageAlphaChannel(*image,alpha_type); |
| 731 | InheritException(exception,&(*image)->exception); |
| 732 | break; |
| 733 | } |
| 734 | if (LocaleCompare("annotate",option+1) == 0) |
| 735 | { |
| 736 | char |
| 737 | *text, |
| 738 | geometry[MaxTextExtent]; |
| 739 | |
| 740 | /* |
| 741 | Annotate image. |
| 742 | */ |
| 743 | (void) SyncImageSettings(image_info,*image); |
| 744 | SetGeometryInfo(&geometry_info); |
| 745 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 746 | if ((flags & SigmaValue) == 0) |
| 747 | geometry_info.sigma=geometry_info.rho; |
| 748 | text=InterpretImageProperties(image_info,*image,argv[i+2]); |
| 749 | InheritException(exception,&(*image)->exception); |
| 750 | if (text == (char *) NULL) |
| 751 | break; |
| 752 | (void) CloneString(&draw_info->text,text); |
| 753 | text=DestroyString(text); |
| 754 | (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f", |
| 755 | geometry_info.xi,geometry_info.psi); |
| 756 | (void) CloneString(&draw_info->geometry,geometry); |
| 757 | draw_info->affine.sx=cos(DegreesToRadians( |
| 758 | fmod(geometry_info.rho,360.0))); |
| 759 | draw_info->affine.rx=sin(DegreesToRadians( |
| 760 | fmod(geometry_info.rho,360.0))); |
| 761 | draw_info->affine.ry=(-sin(DegreesToRadians( |
| 762 | fmod(geometry_info.sigma,360.0)))); |
| 763 | draw_info->affine.sy=cos(DegreesToRadians( |
| 764 | fmod(geometry_info.sigma,360.0))); |
| 765 | (void) AnnotateImage(*image,draw_info); |
| 766 | InheritException(exception,&(*image)->exception); |
| 767 | break; |
| 768 | } |
| 769 | if (LocaleCompare("antialias",option+1) == 0) |
| 770 | { |
| 771 | draw_info->stroke_antialias=(*option == '-') ? MagickTrue : |
| 772 | MagickFalse; |
| 773 | draw_info->text_antialias=(*option == '-') ? MagickTrue : |
| 774 | MagickFalse; |
| 775 | break; |
| 776 | } |
| 777 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 778 | { |
| 779 | /* |
| 780 | Auto Adjust Gamma of image based on its mean |
| 781 | */ |
| 782 | (void) SyncImageSettings(image_info,*image); |
| 783 | (void) AutoGammaImageChannel(*image,channel); |
| 784 | break; |
| 785 | } |
| 786 | if (LocaleCompare("auto-level",option+1) == 0) |
| 787 | { |
| 788 | /* |
| 789 | Perfectly Normalize (max/min stretch) the image |
| 790 | */ |
| 791 | (void) SyncImageSettings(image_info,*image); |
| 792 | (void) AutoLevelImageChannel(*image,channel); |
| 793 | break; |
| 794 | } |
| 795 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 796 | { |
| 797 | Image |
| 798 | *orient_image; |
| 799 | |
| 800 | (void) SyncImageSettings(image_info,*image); |
| 801 | orient_image=NewImageList(); |
| 802 | switch ((*image)->orientation) |
| 803 | { |
| 804 | case TopRightOrientation: |
| 805 | { |
| 806 | orient_image=FlopImage(*image,exception); |
| 807 | break; |
| 808 | } |
| 809 | case BottomRightOrientation: |
| 810 | { |
| 811 | orient_image=RotateImage(*image,180.0,exception); |
| 812 | break; |
| 813 | } |
| 814 | case BottomLeftOrientation: |
| 815 | { |
| 816 | orient_image=FlipImage(*image,exception); |
| 817 | break; |
| 818 | } |
| 819 | case LeftTopOrientation: |
| 820 | { |
| 821 | orient_image=TransposeImage(*image,exception); |
| 822 | break; |
| 823 | } |
| 824 | case RightTopOrientation: |
| 825 | { |
| 826 | orient_image=RotateImage(*image,90.0,exception); |
| 827 | break; |
| 828 | } |
| 829 | case RightBottomOrientation: |
| 830 | { |
| 831 | orient_image=TransverseImage(*image,exception); |
| 832 | break; |
| 833 | } |
| 834 | case LeftBottomOrientation: |
| 835 | { |
| 836 | orient_image=RotateImage(*image,270.0,exception); |
| 837 | break; |
| 838 | } |
| 839 | default: |
| 840 | break; |
| 841 | } |
| 842 | if (orient_image == (Image *) NULL) |
| 843 | break; |
| 844 | orient_image->orientation=TopLeftOrientation; |
| 845 | *image=DestroyImage(*image); |
| 846 | *image=orient_image; |
| 847 | break; |
| 848 | } |
| 849 | break; |
| 850 | } |
| 851 | case 'b': |
| 852 | { |
| 853 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 854 | { |
| 855 | /* |
| 856 | Black threshold image. |
| 857 | */ |
| 858 | (void) SyncImageSettings(image_info,*image); |
| 859 | (void) BlackThresholdImageChannel(*image,channel,argv[i+1], |
| 860 | exception); |
| 861 | InheritException(exception,&(*image)->exception); |
| 862 | break; |
| 863 | } |
| 864 | if (LocaleCompare("blue-shift",option+1) == 0) |
| 865 | { |
| 866 | Image |
| 867 | *shift_image; |
| 868 | |
| 869 | /* |
| 870 | Blue shift image. |
| 871 | */ |
| 872 | (void) SyncImageSettings(image_info,*image); |
| 873 | geometry_info.rho=1.5; |
| 874 | if (*option == '-') |
| 875 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 876 | shift_image=BlueShiftImage(*image,geometry_info.rho,exception); |
| 877 | if (shift_image == (Image *) NULL) |
| 878 | break; |
| 879 | *image=DestroyImage(*image); |
| 880 | *image=shift_image; |
| 881 | break; |
| 882 | } |
| 883 | if (LocaleCompare("blur",option+1) == 0) |
| 884 | { |
| 885 | Image |
| 886 | *blur_image; |
| 887 | |
| 888 | /* |
| 889 | Gaussian blur image. |
| 890 | */ |
| 891 | (void) SyncImageSettings(image_info,*image); |
| 892 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 893 | if ((flags & SigmaValue) == 0) |
| 894 | geometry_info.sigma=1.0; |
| 895 | blur_image=BlurImageChannel(*image,channel,geometry_info.rho, |
| 896 | geometry_info.sigma,exception); |
| 897 | if (blur_image == (Image *) NULL) |
| 898 | break; |
| 899 | *image=DestroyImage(*image); |
| 900 | *image=blur_image; |
| 901 | break; |
| 902 | } |
| 903 | if (LocaleCompare("border",option+1) == 0) |
| 904 | { |
| 905 | Image |
| 906 | *border_image; |
| 907 | |
| 908 | /* |
| 909 | Surround image with a border of solid color. |
| 910 | */ |
| 911 | (void) SyncImageSettings(image_info,*image); |
| 912 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 913 | if ((flags & SigmaValue) == 0) |
| 914 | geometry.height=geometry.width; |
| 915 | border_image=BorderImage(*image,&geometry,exception); |
| 916 | if (border_image == (Image *) NULL) |
| 917 | break; |
| 918 | *image=DestroyImage(*image); |
| 919 | *image=border_image; |
| 920 | break; |
| 921 | } |
| 922 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 923 | { |
| 924 | if (*option == '+') |
| 925 | { |
| 926 | (void) QueryColorDatabase(BorderColor,&draw_info->border_color, |
| 927 | exception); |
| 928 | break; |
| 929 | } |
| 930 | (void) QueryColorDatabase(argv[i+1],&draw_info->border_color, |
| 931 | exception); |
| 932 | break; |
| 933 | } |
| 934 | if (LocaleCompare("box",option+1) == 0) |
| 935 | { |
| 936 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 937 | exception); |
| 938 | break; |
| 939 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 940 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 941 | { |
| 942 | double |
| 943 | brightness, |
| 944 | contrast; |
| 945 | |
| 946 | GeometryInfo |
| 947 | geometry_info; |
| 948 | |
| 949 | MagickStatusType |
| 950 | flags; |
| 951 | |
| 952 | /* |
| 953 | Brightness / contrast image. |
| 954 | */ |
| 955 | (void) SyncImageSettings(image_info,*image); |
| 956 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 957 | brightness=geometry_info.rho; |
cristy | 81fbc8b | 2010-01-11 20:04:07 +0000 | [diff] [blame] | 958 | contrast=0.0; |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 959 | if ((flags & SigmaValue) != 0) |
| 960 | contrast=geometry_info.sigma; |
cristy | 02cc0f2 | 2010-01-12 00:02:32 +0000 | [diff] [blame] | 961 | (void) BrightnessContrastImageChannel(*image,channel,brightness, |
| 962 | contrast); |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 963 | InheritException(exception,&(*image)->exception); |
| 964 | break; |
| 965 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 966 | break; |
| 967 | } |
| 968 | case 'c': |
| 969 | { |
| 970 | if (LocaleCompare("cdl",option+1) == 0) |
| 971 | { |
| 972 | char |
| 973 | *color_correction_collection; |
| 974 | |
| 975 | /* |
| 976 | Color correct with a color decision list. |
| 977 | */ |
| 978 | (void) SyncImageSettings(image_info,*image); |
| 979 | color_correction_collection=FileToString(argv[i+1],~0,exception); |
| 980 | if (color_correction_collection == (char *) NULL) |
| 981 | break; |
| 982 | (void) ColorDecisionListImage(*image,color_correction_collection); |
| 983 | InheritException(exception,&(*image)->exception); |
| 984 | break; |
| 985 | } |
| 986 | if (LocaleCompare("channel",option+1) == 0) |
| 987 | { |
| 988 | if (*option == '+') |
| 989 | { |
| 990 | channel=DefaultChannels; |
| 991 | break; |
| 992 | } |
| 993 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 994 | break; |
| 995 | } |
| 996 | if (LocaleCompare("charcoal",option+1) == 0) |
| 997 | { |
| 998 | Image |
| 999 | *charcoal_image; |
| 1000 | |
| 1001 | /* |
| 1002 | Charcoal image. |
| 1003 | */ |
| 1004 | (void) SyncImageSettings(image_info,*image); |
| 1005 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1006 | if ((flags & SigmaValue) == 0) |
| 1007 | geometry_info.sigma=1.0; |
| 1008 | charcoal_image=CharcoalImage(*image,geometry_info.rho, |
| 1009 | geometry_info.sigma,exception); |
| 1010 | if (charcoal_image == (Image *) NULL) |
| 1011 | break; |
| 1012 | *image=DestroyImage(*image); |
| 1013 | *image=charcoal_image; |
| 1014 | break; |
| 1015 | } |
| 1016 | if (LocaleCompare("chop",option+1) == 0) |
| 1017 | { |
| 1018 | Image |
| 1019 | *chop_image; |
| 1020 | |
| 1021 | /* |
| 1022 | Chop the image. |
| 1023 | */ |
| 1024 | (void) SyncImageSettings(image_info,*image); |
| 1025 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1026 | chop_image=ChopImage(*image,&geometry,exception); |
| 1027 | if (chop_image == (Image *) NULL) |
| 1028 | break; |
| 1029 | *image=DestroyImage(*image); |
| 1030 | *image=chop_image; |
| 1031 | break; |
| 1032 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 1033 | if (LocaleCompare("clamp",option+1) == 0) |
| 1034 | { |
| 1035 | /* |
| 1036 | Clamp image. |
| 1037 | */ |
| 1038 | (void) SyncImageSettings(image_info,*image); |
| 1039 | (void) ClampImageChannel(*image,channel); |
| 1040 | InheritException(exception,&(*image)->exception); |
| 1041 | break; |
| 1042 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1043 | if (LocaleCompare("clip",option+1) == 0) |
| 1044 | { |
| 1045 | (void) SyncImageSettings(image_info,*image); |
| 1046 | if (*option == '+') |
| 1047 | { |
| 1048 | (void) SetImageClipMask(*image,(Image *) NULL); |
| 1049 | InheritException(exception,&(*image)->exception); |
| 1050 | break; |
| 1051 | } |
| 1052 | (void) ClipImage(*image); |
| 1053 | InheritException(exception,&(*image)->exception); |
| 1054 | break; |
| 1055 | } |
| 1056 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 1057 | { |
| 1058 | Image |
| 1059 | *mask; |
| 1060 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1061 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1062 | y; |
| 1063 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1064 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1065 | x; |
| 1066 | |
| 1067 | register PixelPacket |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 1068 | *restrict q; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1069 | |
| 1070 | (void) SyncImageSettings(image_info,*image); |
| 1071 | if (*option == '+') |
| 1072 | { |
| 1073 | /* |
| 1074 | Remove a mask. |
| 1075 | */ |
| 1076 | (void) SetImageMask(*image,(Image *) NULL); |
| 1077 | InheritException(exception,&(*image)->exception); |
| 1078 | break; |
| 1079 | } |
| 1080 | /* |
| 1081 | Set the image mask. |
| 1082 | */ |
| 1083 | mask=GetImageCache(image_info,argv[i+1],exception); |
| 1084 | if (mask == (Image *) NULL) |
| 1085 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1086 | for (y=0; y < (ssize_t) mask->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1087 | { |
| 1088 | q=GetAuthenticPixels(mask,0,y,mask->columns,1,exception); |
| 1089 | if (q == (PixelPacket *) NULL) |
| 1090 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1091 | for (x=0; x < (ssize_t) mask->columns; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1092 | { |
| 1093 | if (mask->matte == MagickFalse) |
| 1094 | q->opacity=PixelIntensityToQuantum(q); |
| 1095 | q->red=q->opacity; |
| 1096 | q->green=q->opacity; |
| 1097 | q->blue=q->opacity; |
| 1098 | q++; |
| 1099 | } |
| 1100 | if (SyncAuthenticPixels(mask,exception) == MagickFalse) |
| 1101 | break; |
| 1102 | } |
| 1103 | if (SetImageStorageClass(mask,DirectClass) == MagickFalse) |
| 1104 | return(MagickFalse); |
| 1105 | mask->matte=MagickTrue; |
| 1106 | (void) SetImageClipMask(*image,mask); |
| 1107 | mask=DestroyImage(mask); |
| 1108 | InheritException(exception,&(*image)->exception); |
| 1109 | break; |
| 1110 | } |
| 1111 | if (LocaleCompare("clip-path",option+1) == 0) |
| 1112 | { |
| 1113 | (void) SyncImageSettings(image_info,*image); |
| 1114 | (void) ClipImagePath(*image,argv[i+1],*option == '-' ? MagickTrue : |
| 1115 | MagickFalse); |
| 1116 | InheritException(exception,&(*image)->exception); |
| 1117 | break; |
| 1118 | } |
| 1119 | if (LocaleCompare("colorize",option+1) == 0) |
| 1120 | { |
| 1121 | Image |
| 1122 | *colorize_image; |
| 1123 | |
| 1124 | /* |
| 1125 | Colorize the image. |
| 1126 | */ |
| 1127 | (void) SyncImageSettings(image_info,*image); |
| 1128 | colorize_image=ColorizeImage(*image,argv[i+1],draw_info->fill, |
| 1129 | exception); |
| 1130 | if (colorize_image == (Image *) NULL) |
| 1131 | break; |
| 1132 | *image=DestroyImage(*image); |
| 1133 | *image=colorize_image; |
| 1134 | break; |
| 1135 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 1136 | if (LocaleCompare("color-matrix",option+1) == 0) |
| 1137 | { |
| 1138 | Image |
| 1139 | *color_image; |
| 1140 | |
| 1141 | KernelInfo |
| 1142 | *kernel; |
| 1143 | |
| 1144 | (void) SyncImageSettings(image_info,*image); |
| 1145 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1146 | if (kernel == (KernelInfo *) NULL) |
| 1147 | break; |
| 1148 | color_image=ColorMatrixImage(*image,kernel,exception); |
| 1149 | kernel=DestroyKernelInfo(kernel); |
| 1150 | if (color_image == (Image *) NULL) |
| 1151 | break; |
| 1152 | *image=DestroyImage(*image); |
| 1153 | *image=color_image; |
| 1154 | break; |
| 1155 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1156 | if (LocaleCompare("colors",option+1) == 0) |
| 1157 | { |
| 1158 | /* |
| 1159 | Reduce the number of colors in the image. |
| 1160 | */ |
| 1161 | (void) SyncImageSettings(image_info,*image); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1162 | quantize_info->number_colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1163 | if (quantize_info->number_colors == 0) |
| 1164 | break; |
| 1165 | if (((*image)->storage_class == DirectClass) || |
| 1166 | (*image)->colors > quantize_info->number_colors) |
| 1167 | (void) QuantizeImage(quantize_info,*image); |
| 1168 | else |
| 1169 | (void) CompressImageColormap(*image); |
| 1170 | InheritException(exception,&(*image)->exception); |
| 1171 | break; |
| 1172 | } |
| 1173 | if (LocaleCompare("colorspace",option+1) == 0) |
| 1174 | { |
| 1175 | ColorspaceType |
| 1176 | colorspace; |
| 1177 | |
| 1178 | (void) SyncImageSettings(image_info,*image); |
| 1179 | if (*option == '+') |
| 1180 | { |
| 1181 | (void) TransformImageColorspace(*image,RGBColorspace); |
| 1182 | InheritException(exception,&(*image)->exception); |
| 1183 | break; |
| 1184 | } |
| 1185 | colorspace=(ColorspaceType) ParseMagickOption( |
| 1186 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 1187 | (void) TransformImageColorspace(*image,colorspace); |
| 1188 | InheritException(exception,&(*image)->exception); |
| 1189 | break; |
| 1190 | } |
| 1191 | if (LocaleCompare("contrast",option+1) == 0) |
| 1192 | { |
| 1193 | (void) SyncImageSettings(image_info,*image); |
| 1194 | (void) ContrastImage(*image,(*option == '-') ? MagickTrue : |
| 1195 | MagickFalse); |
| 1196 | InheritException(exception,&(*image)->exception); |
| 1197 | break; |
| 1198 | } |
| 1199 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 1200 | { |
| 1201 | double |
| 1202 | black_point, |
| 1203 | white_point; |
| 1204 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1205 | MagickStatusType |
| 1206 | flags; |
| 1207 | |
| 1208 | /* |
| 1209 | Contrast stretch image. |
| 1210 | */ |
| 1211 | (void) SyncImageSettings(image_info,*image); |
| 1212 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1213 | black_point=geometry_info.rho; |
| 1214 | white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma : |
| 1215 | black_point; |
| 1216 | if ((flags & PercentValue) != 0) |
| 1217 | { |
| 1218 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1219 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 1220 | } |
| 1221 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 1222 | white_point; |
| 1223 | (void) ContrastStretchImageChannel(*image,channel,black_point, |
| 1224 | white_point); |
| 1225 | InheritException(exception,&(*image)->exception); |
| 1226 | break; |
| 1227 | } |
| 1228 | if (LocaleCompare("convolve",option+1) == 0) |
| 1229 | { |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1230 | double |
| 1231 | gamma; |
| 1232 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1233 | Image |
| 1234 | *convolve_image; |
| 1235 | |
cristy | 2be1538 | 2010-01-21 02:38:03 +0000 | [diff] [blame] | 1236 | KernelInfo |
cristy | 56a9e51 | 2010-01-06 18:18:55 +0000 | [diff] [blame] | 1237 | *kernel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1238 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1239 | register ssize_t |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1240 | j; |
| 1241 | |
cristy | a651053 | 2010-03-06 13:09:30 +0000 | [diff] [blame] | 1242 | (void) SyncImageSettings(image_info,*image); |
cristy | 2be1538 | 2010-01-21 02:38:03 +0000 | [diff] [blame] | 1243 | kernel=AcquireKernelInfo(argv[i+1]); |
| 1244 | if (kernel == (KernelInfo *) NULL) |
cristy | 56a9e51 | 2010-01-06 18:18:55 +0000 | [diff] [blame] | 1245 | break; |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1246 | gamma=0.0; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1247 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1248 | gamma+=kernel->values[j]; |
| 1249 | gamma=1.0/(fabs((double) gamma) <= MagickEpsilon ? 1.0 : gamma); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1250 | for (j=0; j < (ssize_t) (kernel->width*kernel->height); j++) |
cristy | 36826ab | 2010-03-06 01:29:30 +0000 | [diff] [blame] | 1251 | kernel->values[j]*=gamma; |
cristy | 6771f1e | 2010-03-05 19:43:39 +0000 | [diff] [blame] | 1252 | convolve_image=FilterImageChannel(*image,channel,kernel,exception); |
anthony | 83ba99b | 2010-01-24 08:48:15 +0000 | [diff] [blame] | 1253 | kernel=DestroyKernelInfo(kernel); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1254 | if (convolve_image == (Image *) NULL) |
| 1255 | break; |
| 1256 | *image=DestroyImage(*image); |
| 1257 | *image=convolve_image; |
| 1258 | break; |
| 1259 | } |
| 1260 | if (LocaleCompare("crop",option+1) == 0) |
| 1261 | { |
| 1262 | (void) SyncImageSettings(image_info,*image); |
| 1263 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 1264 | if (((geometry.width != 0) || (geometry.height != 0)) && |
| 1265 | ((flags & XValue) == 0) && ((flags & YValue) == 0)) |
| 1266 | break; |
| 1267 | (void) TransformImage(image,argv[i+1],(char *) NULL); |
| 1268 | InheritException(exception,&(*image)->exception); |
| 1269 | break; |
| 1270 | } |
| 1271 | if (LocaleCompare("cycle",option+1) == 0) |
| 1272 | { |
| 1273 | /* |
| 1274 | Cycle an image colormap. |
| 1275 | */ |
| 1276 | (void) SyncImageSettings(image_info,*image); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1277 | (void) CycleColormapImage(*image,StringToLong(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1278 | InheritException(exception,&(*image)->exception); |
| 1279 | break; |
| 1280 | } |
| 1281 | break; |
| 1282 | } |
| 1283 | case 'd': |
| 1284 | { |
| 1285 | if (LocaleCompare("decipher",option+1) == 0) |
| 1286 | { |
| 1287 | StringInfo |
| 1288 | *passkey; |
| 1289 | |
| 1290 | /* |
| 1291 | Decipher pixels. |
| 1292 | */ |
| 1293 | (void) SyncImageSettings(image_info,*image); |
| 1294 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1295 | if (passkey != (StringInfo *) NULL) |
| 1296 | { |
| 1297 | (void) PasskeyDecipherImage(*image,passkey,exception); |
| 1298 | passkey=DestroyStringInfo(passkey); |
| 1299 | } |
| 1300 | break; |
| 1301 | } |
| 1302 | if (LocaleCompare("density",option+1) == 0) |
| 1303 | { |
| 1304 | /* |
| 1305 | Set image density. |
| 1306 | */ |
| 1307 | (void) CloneString(&draw_info->density,argv[i+1]); |
| 1308 | break; |
| 1309 | } |
| 1310 | if (LocaleCompare("depth",option+1) == 0) |
| 1311 | { |
| 1312 | (void) SyncImageSettings(image_info,*image); |
| 1313 | if (*option == '+') |
| 1314 | { |
| 1315 | (void) SetImageDepth(*image,MAGICKCORE_QUANTUM_DEPTH); |
| 1316 | break; |
| 1317 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 1318 | (void) SetImageDepth(*image,StringToUnsignedLong(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1319 | break; |
| 1320 | } |
| 1321 | if (LocaleCompare("deskew",option+1) == 0) |
| 1322 | { |
| 1323 | double |
| 1324 | threshold; |
| 1325 | |
| 1326 | Image |
| 1327 | *deskew_image; |
| 1328 | |
| 1329 | /* |
| 1330 | Straighten the image. |
| 1331 | */ |
| 1332 | (void) SyncImageSettings(image_info,*image); |
| 1333 | if (*option == '+') |
| 1334 | threshold=40.0*QuantumRange/100.0; |
| 1335 | else |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1336 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1337 | deskew_image=DeskewImage(*image,threshold,exception); |
| 1338 | if (deskew_image == (Image *) NULL) |
| 1339 | break; |
| 1340 | *image=DestroyImage(*image); |
| 1341 | *image=deskew_image; |
| 1342 | break; |
| 1343 | } |
| 1344 | if (LocaleCompare("despeckle",option+1) == 0) |
| 1345 | { |
| 1346 | Image |
| 1347 | *despeckle_image; |
| 1348 | |
| 1349 | /* |
| 1350 | Reduce the speckles within an image. |
| 1351 | */ |
| 1352 | (void) SyncImageSettings(image_info,*image); |
| 1353 | despeckle_image=DespeckleImage(*image,exception); |
| 1354 | if (despeckle_image == (Image *) NULL) |
| 1355 | break; |
| 1356 | *image=DestroyImage(*image); |
| 1357 | *image=despeckle_image; |
| 1358 | break; |
| 1359 | } |
| 1360 | if (LocaleCompare("display",option+1) == 0) |
| 1361 | { |
| 1362 | (void) CloneString(&draw_info->server_name,argv[i+1]); |
| 1363 | break; |
| 1364 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1365 | if (LocaleCompare("distort",option+1) == 0) |
| 1366 | { |
| 1367 | char |
| 1368 | *args, |
| 1369 | token[MaxTextExtent]; |
| 1370 | |
| 1371 | const char |
| 1372 | *p; |
| 1373 | |
| 1374 | DistortImageMethod |
| 1375 | method; |
| 1376 | |
| 1377 | double |
| 1378 | *arguments; |
| 1379 | |
| 1380 | Image |
| 1381 | *distort_image; |
| 1382 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1383 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1384 | x; |
| 1385 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1386 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1387 | number_arguments; |
| 1388 | |
| 1389 | /* |
| 1390 | Distort image. |
| 1391 | */ |
| 1392 | (void) SyncImageSettings(image_info,*image); |
| 1393 | method=(DistortImageMethod) ParseMagickOption(MagickDistortOptions, |
| 1394 | MagickFalse,argv[i+1]); |
| 1395 | args=InterpretImageProperties(image_info,*image,argv[i+2]); |
| 1396 | InheritException(exception,&(*image)->exception); |
| 1397 | if (args == (char *) NULL) |
| 1398 | break; |
| 1399 | p=(char *) args; |
| 1400 | for (x=0; *p != '\0'; x++) |
| 1401 | { |
| 1402 | GetMagickToken(p,&p,token); |
| 1403 | if (*token == ',') |
| 1404 | GetMagickToken(p,&p,token); |
| 1405 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1406 | number_arguments=(size_t) x; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1407 | arguments=(double *) AcquireQuantumMemory(number_arguments, |
| 1408 | sizeof(*arguments)); |
| 1409 | if (arguments == (double *) NULL) |
| 1410 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1411 | "MemoryAllocationFailed",(*image)->filename); |
| 1412 | (void) ResetMagickMemory(arguments,0,number_arguments* |
| 1413 | sizeof(*arguments)); |
| 1414 | p=(char *) args; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1415 | for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1416 | { |
| 1417 | GetMagickToken(p,&p,token); |
| 1418 | if (*token == ',') |
| 1419 | GetMagickToken(p,&p,token); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1420 | arguments[x]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1421 | } |
| 1422 | args=DestroyString(args); |
| 1423 | distort_image=DistortImage(*image,method,number_arguments,arguments, |
| 1424 | (*option == '+') ? MagickTrue : MagickFalse,exception); |
| 1425 | arguments=(double *) RelinquishMagickMemory(arguments); |
| 1426 | if (distort_image == (Image *) NULL) |
| 1427 | break; |
| 1428 | *image=DestroyImage(*image); |
| 1429 | *image=distort_image; |
| 1430 | break; |
| 1431 | } |
| 1432 | if (LocaleCompare("dither",option+1) == 0) |
| 1433 | { |
| 1434 | if (*option == '+') |
| 1435 | { |
| 1436 | quantize_info->dither=MagickFalse; |
| 1437 | break; |
| 1438 | } |
| 1439 | quantize_info->dither=MagickTrue; |
| 1440 | quantize_info->dither_method=(DitherMethod) ParseMagickOption( |
| 1441 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 1442 | if (quantize_info->dither_method == NoDitherMethod) |
| 1443 | quantize_info->dither=MagickFalse; |
| 1444 | break; |
| 1445 | } |
| 1446 | if (LocaleCompare("draw",option+1) == 0) |
| 1447 | { |
| 1448 | /* |
| 1449 | Draw image. |
| 1450 | */ |
| 1451 | (void) SyncImageSettings(image_info,*image); |
| 1452 | (void) CloneString(&draw_info->primitive,argv[i+1]); |
| 1453 | (void) DrawImage(*image,draw_info); |
| 1454 | InheritException(exception,&(*image)->exception); |
| 1455 | break; |
| 1456 | } |
| 1457 | break; |
| 1458 | } |
| 1459 | case 'e': |
| 1460 | { |
| 1461 | if (LocaleCompare("edge",option+1) == 0) |
| 1462 | { |
| 1463 | Image |
| 1464 | *edge_image; |
| 1465 | |
| 1466 | /* |
| 1467 | Enhance edges in the image. |
| 1468 | */ |
| 1469 | (void) SyncImageSettings(image_info,*image); |
| 1470 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1471 | if ((flags & SigmaValue) == 0) |
| 1472 | geometry_info.sigma=1.0; |
| 1473 | edge_image=EdgeImage(*image,geometry_info.rho,exception); |
| 1474 | if (edge_image == (Image *) NULL) |
| 1475 | break; |
| 1476 | *image=DestroyImage(*image); |
| 1477 | *image=edge_image; |
| 1478 | break; |
| 1479 | } |
| 1480 | if (LocaleCompare("emboss",option+1) == 0) |
| 1481 | { |
| 1482 | Image |
| 1483 | *emboss_image; |
| 1484 | |
| 1485 | /* |
| 1486 | Gaussian embossen image. |
| 1487 | */ |
| 1488 | (void) SyncImageSettings(image_info,*image); |
| 1489 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1490 | if ((flags & SigmaValue) == 0) |
| 1491 | geometry_info.sigma=1.0; |
| 1492 | emboss_image=EmbossImage(*image,geometry_info.rho, |
| 1493 | geometry_info.sigma,exception); |
| 1494 | if (emboss_image == (Image *) NULL) |
| 1495 | break; |
| 1496 | *image=DestroyImage(*image); |
| 1497 | *image=emboss_image; |
| 1498 | break; |
| 1499 | } |
| 1500 | if (LocaleCompare("encipher",option+1) == 0) |
| 1501 | { |
| 1502 | StringInfo |
| 1503 | *passkey; |
| 1504 | |
| 1505 | /* |
| 1506 | Encipher pixels. |
| 1507 | */ |
| 1508 | (void) SyncImageSettings(image_info,*image); |
| 1509 | passkey=FileToStringInfo(argv[i+1],~0,exception); |
| 1510 | if (passkey != (StringInfo *) NULL) |
| 1511 | { |
| 1512 | (void) PasskeyEncipherImage(*image,passkey,exception); |
| 1513 | passkey=DestroyStringInfo(passkey); |
| 1514 | } |
| 1515 | break; |
| 1516 | } |
| 1517 | if (LocaleCompare("encoding",option+1) == 0) |
| 1518 | { |
| 1519 | (void) CloneString(&draw_info->encoding,argv[i+1]); |
| 1520 | break; |
| 1521 | } |
| 1522 | if (LocaleCompare("enhance",option+1) == 0) |
| 1523 | { |
| 1524 | Image |
| 1525 | *enhance_image; |
| 1526 | |
| 1527 | /* |
| 1528 | Enhance image. |
| 1529 | */ |
| 1530 | (void) SyncImageSettings(image_info,*image); |
| 1531 | enhance_image=EnhanceImage(*image,exception); |
| 1532 | if (enhance_image == (Image *) NULL) |
| 1533 | break; |
| 1534 | *image=DestroyImage(*image); |
| 1535 | *image=enhance_image; |
| 1536 | break; |
| 1537 | } |
| 1538 | if (LocaleCompare("equalize",option+1) == 0) |
| 1539 | { |
| 1540 | /* |
| 1541 | Equalize image. |
| 1542 | */ |
| 1543 | (void) SyncImageSettings(image_info,*image); |
| 1544 | (void) EqualizeImageChannel(*image,channel); |
| 1545 | InheritException(exception,&(*image)->exception); |
| 1546 | break; |
| 1547 | } |
| 1548 | if (LocaleCompare("evaluate",option+1) == 0) |
| 1549 | { |
| 1550 | double |
| 1551 | constant; |
| 1552 | |
| 1553 | MagickEvaluateOperator |
| 1554 | op; |
| 1555 | |
| 1556 | (void) SyncImageSettings(image_info,*image); |
| 1557 | op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions, |
| 1558 | MagickFalse,argv[i+1]); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1559 | constant=SiPrefixToDouble(argv[i+2],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1560 | (void) EvaluateImageChannel(*image,channel,op,constant,exception); |
| 1561 | break; |
| 1562 | } |
| 1563 | if (LocaleCompare("extent",option+1) == 0) |
| 1564 | { |
| 1565 | Image |
| 1566 | *extent_image; |
| 1567 | |
| 1568 | /* |
| 1569 | Set the image extent. |
| 1570 | */ |
| 1571 | (void) SyncImageSettings(image_info,*image); |
| 1572 | flags=ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
cristy | f0bbfd9 | 2009-11-25 14:12:31 +0000 | [diff] [blame] | 1573 | if (geometry.width == 0) |
cristy | 2ea9a4e | 2009-11-25 14:30:22 +0000 | [diff] [blame] | 1574 | geometry.width=(*image)->columns; |
cristy | f0bbfd9 | 2009-11-25 14:12:31 +0000 | [diff] [blame] | 1575 | if (geometry.height == 0) |
cristy | 2ea9a4e | 2009-11-25 14:30:22 +0000 | [diff] [blame] | 1576 | geometry.height=(*image)->rows; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1577 | geometry.x=(-geometry.x); |
| 1578 | geometry.y=(-geometry.y); |
| 1579 | extent_image=ExtentImage(*image,&geometry,exception); |
| 1580 | if (extent_image == (Image *) NULL) |
| 1581 | break; |
| 1582 | *image=DestroyImage(*image); |
| 1583 | *image=extent_image; |
| 1584 | break; |
| 1585 | } |
| 1586 | break; |
| 1587 | } |
| 1588 | case 'f': |
| 1589 | { |
| 1590 | if (LocaleCompare("family",option+1) == 0) |
| 1591 | { |
| 1592 | if (*option == '+') |
| 1593 | { |
| 1594 | if (draw_info->family != (char *) NULL) |
| 1595 | draw_info->family=DestroyString(draw_info->family); |
| 1596 | break; |
| 1597 | } |
| 1598 | (void) CloneString(&draw_info->family,argv[i+1]); |
| 1599 | break; |
| 1600 | } |
cristy | 0fe961c | 2010-01-30 03:09:54 +0000 | [diff] [blame] | 1601 | if (LocaleCompare("features",option+1) == 0) |
| 1602 | { |
| 1603 | if (*option == '+') |
| 1604 | { |
| 1605 | (void) DeleteImageArtifact(*image,"identify:features"); |
| 1606 | break; |
| 1607 | } |
| 1608 | (void) SetImageArtifact(*image,"identify:features",argv[i+1]); |
| 1609 | break; |
| 1610 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1611 | if (LocaleCompare("fill",option+1) == 0) |
| 1612 | { |
| 1613 | ExceptionInfo |
| 1614 | *sans; |
| 1615 | |
| 1616 | GetMagickPixelPacket(*image,&fill); |
| 1617 | if (*option == '+') |
| 1618 | { |
| 1619 | (void) QueryMagickColor("none",&fill,exception); |
| 1620 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 1621 | if (draw_info->fill_pattern != (Image *) NULL) |
| 1622 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 1623 | break; |
| 1624 | } |
| 1625 | sans=AcquireExceptionInfo(); |
| 1626 | (void) QueryMagickColor(argv[i+1],&fill,sans); |
| 1627 | status=QueryColorDatabase(argv[i+1],&draw_info->fill,sans); |
| 1628 | sans=DestroyExceptionInfo(sans); |
| 1629 | if (status == MagickFalse) |
| 1630 | draw_info->fill_pattern=GetImageCache(image_info,argv[i+1], |
| 1631 | exception); |
| 1632 | break; |
| 1633 | } |
| 1634 | if (LocaleCompare("flip",option+1) == 0) |
| 1635 | { |
| 1636 | Image |
| 1637 | *flip_image; |
| 1638 | |
| 1639 | /* |
| 1640 | Flip image scanlines. |
| 1641 | */ |
| 1642 | (void) SyncImageSettings(image_info,*image); |
| 1643 | flip_image=FlipImage(*image,exception); |
| 1644 | if (flip_image == (Image *) NULL) |
| 1645 | break; |
| 1646 | *image=DestroyImage(*image); |
| 1647 | *image=flip_image; |
| 1648 | break; |
| 1649 | } |
| 1650 | if (LocaleCompare("flop",option+1) == 0) |
| 1651 | { |
| 1652 | Image |
| 1653 | *flop_image; |
| 1654 | |
| 1655 | /* |
| 1656 | Flop image scanlines. |
| 1657 | */ |
| 1658 | (void) SyncImageSettings(image_info,*image); |
| 1659 | flop_image=FlopImage(*image,exception); |
| 1660 | if (flop_image == (Image *) NULL) |
| 1661 | break; |
| 1662 | *image=DestroyImage(*image); |
| 1663 | *image=flop_image; |
| 1664 | break; |
| 1665 | } |
| 1666 | if (LocaleCompare("floodfill",option+1) == 0) |
| 1667 | { |
| 1668 | MagickPixelPacket |
| 1669 | target; |
| 1670 | |
| 1671 | /* |
| 1672 | Floodfill image. |
| 1673 | */ |
| 1674 | (void) SyncImageSettings(image_info,*image); |
| 1675 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1676 | (void) QueryMagickColor(argv[i+2],&target,exception); |
| 1677 | (void) FloodfillPaintImage(*image,channel,draw_info,&target, |
| 1678 | geometry.x,geometry.y,*option == '-' ? MagickFalse : MagickTrue); |
| 1679 | InheritException(exception,&(*image)->exception); |
| 1680 | break; |
| 1681 | } |
| 1682 | if (LocaleCompare("font",option+1) == 0) |
| 1683 | { |
| 1684 | if (*option == '+') |
| 1685 | { |
| 1686 | if (draw_info->font != (char *) NULL) |
| 1687 | draw_info->font=DestroyString(draw_info->font); |
| 1688 | break; |
| 1689 | } |
| 1690 | (void) CloneString(&draw_info->font,argv[i+1]); |
| 1691 | break; |
| 1692 | } |
| 1693 | if (LocaleCompare("format",option+1) == 0) |
| 1694 | { |
| 1695 | format=argv[i+1]; |
| 1696 | break; |
| 1697 | } |
| 1698 | if (LocaleCompare("frame",option+1) == 0) |
| 1699 | { |
| 1700 | FrameInfo |
| 1701 | frame_info; |
| 1702 | |
| 1703 | Image |
| 1704 | *frame_image; |
| 1705 | |
| 1706 | /* |
| 1707 | Surround image with an ornamental border. |
| 1708 | */ |
| 1709 | (void) SyncImageSettings(image_info,*image); |
| 1710 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 1711 | frame_info.width=geometry.width; |
| 1712 | frame_info.height=geometry.height; |
| 1713 | if ((flags & HeightValue) == 0) |
| 1714 | frame_info.height=geometry.width; |
| 1715 | frame_info.outer_bevel=geometry.x; |
| 1716 | frame_info.inner_bevel=geometry.y; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1717 | frame_info.x=(ssize_t) frame_info.width; |
| 1718 | frame_info.y=(ssize_t) frame_info.height; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1719 | frame_info.width=(*image)->columns+2*frame_info.width; |
| 1720 | frame_info.height=(*image)->rows+2*frame_info.height; |
| 1721 | frame_image=FrameImage(*image,&frame_info,exception); |
| 1722 | if (frame_image == (Image *) NULL) |
| 1723 | break; |
| 1724 | *image=DestroyImage(*image); |
| 1725 | *image=frame_image; |
| 1726 | break; |
| 1727 | } |
| 1728 | if (LocaleCompare("function",option+1) == 0) |
| 1729 | { |
| 1730 | char |
| 1731 | *arguments, |
| 1732 | token[MaxTextExtent]; |
| 1733 | |
| 1734 | const char |
| 1735 | *p; |
| 1736 | |
| 1737 | double |
| 1738 | *parameters; |
| 1739 | |
| 1740 | MagickFunction |
| 1741 | function; |
| 1742 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1743 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1744 | x; |
| 1745 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1746 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1747 | number_parameters; |
| 1748 | |
| 1749 | /* |
| 1750 | Function Modify Image Values |
| 1751 | */ |
| 1752 | (void) SyncImageSettings(image_info,*image); |
| 1753 | function=(MagickFunction) ParseMagickOption(MagickFunctionOptions, |
| 1754 | MagickFalse,argv[i+1]); |
| 1755 | arguments=InterpretImageProperties(image_info,*image,argv[i+2]); |
| 1756 | InheritException(exception,&(*image)->exception); |
| 1757 | if (arguments == (char *) NULL) |
| 1758 | break; |
| 1759 | p=(char *) arguments; |
| 1760 | for (x=0; *p != '\0'; x++) |
| 1761 | { |
| 1762 | GetMagickToken(p,&p,token); |
| 1763 | if (*token == ',') |
| 1764 | GetMagickToken(p,&p,token); |
| 1765 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1766 | number_parameters=(size_t) x; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1767 | parameters=(double *) AcquireQuantumMemory(number_parameters, |
| 1768 | sizeof(*parameters)); |
| 1769 | if (parameters == (double *) NULL) |
| 1770 | ThrowWandFatalException(ResourceLimitFatalError, |
| 1771 | "MemoryAllocationFailed",(*image)->filename); |
| 1772 | (void) ResetMagickMemory(parameters,0,number_parameters* |
| 1773 | sizeof(*parameters)); |
| 1774 | p=(char *) arguments; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1775 | for (x=0; (x < (ssize_t) number_parameters) && (*p != '\0'); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1776 | { |
| 1777 | GetMagickToken(p,&p,token); |
| 1778 | if (*token == ',') |
| 1779 | GetMagickToken(p,&p,token); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1780 | parameters[x]=StringToDouble(token); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1781 | } |
| 1782 | arguments=DestroyString(arguments); |
| 1783 | (void) FunctionImageChannel(*image,channel,function, |
| 1784 | number_parameters,parameters,exception); |
| 1785 | parameters=(double *) RelinquishMagickMemory(parameters); |
| 1786 | break; |
| 1787 | } |
| 1788 | break; |
| 1789 | } |
| 1790 | case 'g': |
| 1791 | { |
| 1792 | if (LocaleCompare("gamma",option+1) == 0) |
| 1793 | { |
| 1794 | /* |
| 1795 | Gamma image. |
| 1796 | */ |
| 1797 | (void) SyncImageSettings(image_info,*image); |
| 1798 | if (*option == '+') |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 1799 | (*image)->gamma=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1800 | else |
| 1801 | { |
| 1802 | if (strchr(argv[i+1],',') != (char *) NULL) |
| 1803 | (void) GammaImage(*image,argv[i+1]); |
| 1804 | else |
cristy | a5447be | 2010-01-11 00:20:51 +0000 | [diff] [blame] | 1805 | (void) GammaImageChannel(*image,channel, |
| 1806 | StringToDouble(argv[i+1])); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1807 | InheritException(exception,&(*image)->exception); |
| 1808 | } |
| 1809 | break; |
| 1810 | } |
| 1811 | if ((LocaleCompare("gaussian-blur",option+1) == 0) || |
| 1812 | (LocaleCompare("gaussian",option+1) == 0)) |
| 1813 | { |
| 1814 | Image |
| 1815 | *gaussian_image; |
| 1816 | |
| 1817 | /* |
| 1818 | Gaussian blur image. |
| 1819 | */ |
| 1820 | (void) SyncImageSettings(image_info,*image); |
| 1821 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1822 | if ((flags & SigmaValue) == 0) |
| 1823 | geometry_info.sigma=1.0; |
| 1824 | gaussian_image=GaussianBlurImageChannel(*image,channel, |
| 1825 | geometry_info.rho,geometry_info.sigma,exception); |
| 1826 | if (gaussian_image == (Image *) NULL) |
| 1827 | break; |
| 1828 | *image=DestroyImage(*image); |
| 1829 | *image=gaussian_image; |
| 1830 | break; |
| 1831 | } |
| 1832 | if (LocaleCompare("geometry",option+1) == 0) |
| 1833 | { |
| 1834 | (void) SyncImageSettings(image_info,*image); |
| 1835 | if (*option == '+') |
| 1836 | { |
| 1837 | if ((*image)->geometry != (char *) NULL) |
| 1838 | (*image)->geometry=DestroyString((*image)->geometry); |
| 1839 | break; |
| 1840 | } |
| 1841 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 1842 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 1843 | (void) CloneString(&(*image)->geometry,argv[i+1]); |
| 1844 | else |
| 1845 | { |
| 1846 | Image |
| 1847 | *zoom_image; |
| 1848 | |
| 1849 | /* |
| 1850 | Resize image. |
| 1851 | */ |
| 1852 | zoom_image=ZoomImage(*image,geometry.width,geometry.height, |
| 1853 | exception); |
| 1854 | if (zoom_image == (Image *) NULL) |
| 1855 | break; |
| 1856 | *image=DestroyImage(*image); |
| 1857 | *image=zoom_image; |
| 1858 | } |
| 1859 | break; |
| 1860 | } |
| 1861 | if (LocaleCompare("gravity",option+1) == 0) |
| 1862 | { |
| 1863 | if (*option == '+') |
| 1864 | { |
| 1865 | draw_info->gravity=UndefinedGravity; |
| 1866 | break; |
| 1867 | } |
| 1868 | draw_info->gravity=(GravityType) ParseMagickOption( |
| 1869 | MagickGravityOptions,MagickFalse,argv[i+1]); |
| 1870 | break; |
| 1871 | } |
| 1872 | break; |
| 1873 | } |
| 1874 | case 'h': |
| 1875 | { |
| 1876 | if (LocaleCompare("highlight-color",option+1) == 0) |
| 1877 | { |
| 1878 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 1879 | break; |
| 1880 | } |
| 1881 | break; |
| 1882 | } |
| 1883 | case 'i': |
| 1884 | { |
| 1885 | if (LocaleCompare("identify",option+1) == 0) |
| 1886 | { |
| 1887 | char |
| 1888 | *text; |
| 1889 | |
| 1890 | (void) SyncImageSettings(image_info,*image); |
| 1891 | if (format == (char *) NULL) |
| 1892 | { |
| 1893 | (void) IdentifyImage(*image,stdout,image_info->verbose); |
| 1894 | InheritException(exception,&(*image)->exception); |
| 1895 | break; |
| 1896 | } |
| 1897 | text=InterpretImageProperties(image_info,*image,format); |
| 1898 | InheritException(exception,&(*image)->exception); |
| 1899 | if (text == (char *) NULL) |
| 1900 | break; |
| 1901 | (void) fputs(text,stdout); |
| 1902 | (void) fputc('\n',stdout); |
| 1903 | text=DestroyString(text); |
| 1904 | break; |
| 1905 | } |
| 1906 | if (LocaleCompare("implode",option+1) == 0) |
| 1907 | { |
| 1908 | Image |
| 1909 | *implode_image; |
| 1910 | |
| 1911 | /* |
| 1912 | Implode image. |
| 1913 | */ |
| 1914 | (void) SyncImageSettings(image_info,*image); |
| 1915 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1916 | implode_image=ImplodeImage(*image,geometry_info.rho,exception); |
| 1917 | if (implode_image == (Image *) NULL) |
| 1918 | break; |
| 1919 | *image=DestroyImage(*image); |
| 1920 | *image=implode_image; |
| 1921 | break; |
| 1922 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 1923 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 1924 | { |
| 1925 | if (*option == '+') |
| 1926 | (void) ParseGeometry("0",&geometry_info); |
| 1927 | else |
| 1928 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1929 | draw_info->interline_spacing=geometry_info.rho; |
| 1930 | break; |
| 1931 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1932 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 1933 | { |
| 1934 | if (*option == '+') |
| 1935 | (void) ParseGeometry("0",&geometry_info); |
| 1936 | else |
| 1937 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1938 | draw_info->interword_spacing=geometry_info.rho; |
| 1939 | break; |
| 1940 | } |
| 1941 | break; |
| 1942 | } |
| 1943 | case 'k': |
| 1944 | { |
| 1945 | if (LocaleCompare("kerning",option+1) == 0) |
| 1946 | { |
| 1947 | if (*option == '+') |
| 1948 | (void) ParseGeometry("0",&geometry_info); |
| 1949 | else |
| 1950 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 1951 | draw_info->kerning=geometry_info.rho; |
| 1952 | break; |
| 1953 | } |
| 1954 | break; |
| 1955 | } |
| 1956 | case 'l': |
| 1957 | { |
| 1958 | if (LocaleCompare("lat",option+1) == 0) |
| 1959 | { |
| 1960 | Image |
| 1961 | *threshold_image; |
| 1962 | |
| 1963 | /* |
| 1964 | Local adaptive threshold image. |
| 1965 | */ |
| 1966 | (void) SyncImageSettings(image_info,*image); |
| 1967 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1968 | if ((flags & PercentValue) != 0) |
| 1969 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1970 | threshold_image=AdaptiveThresholdImage(*image,(size_t) |
| 1971 | geometry_info.rho,(size_t) geometry_info.sigma, |
| 1972 | (ssize_t) geometry_info.xi,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1973 | if (threshold_image == (Image *) NULL) |
| 1974 | break; |
| 1975 | *image=DestroyImage(*image); |
| 1976 | *image=threshold_image; |
| 1977 | break; |
| 1978 | } |
| 1979 | if (LocaleCompare("level",option+1) == 0) |
| 1980 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1981 | MagickRealType |
| 1982 | black_point, |
| 1983 | gamma, |
| 1984 | white_point; |
| 1985 | |
| 1986 | MagickStatusType |
| 1987 | flags; |
| 1988 | |
| 1989 | /* |
| 1990 | Parse levels. |
| 1991 | */ |
| 1992 | (void) SyncImageSettings(image_info,*image); |
| 1993 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 1994 | black_point=geometry_info.rho; |
| 1995 | white_point=(MagickRealType) QuantumRange; |
| 1996 | if ((flags & SigmaValue) != 0) |
| 1997 | white_point=geometry_info.sigma; |
| 1998 | gamma=1.0; |
| 1999 | if ((flags & XiValue) != 0) |
| 2000 | gamma=geometry_info.xi; |
| 2001 | if ((flags & PercentValue) != 0) |
| 2002 | { |
| 2003 | black_point*=(MagickRealType) (QuantumRange/100.0); |
| 2004 | white_point*=(MagickRealType) (QuantumRange/100.0); |
| 2005 | } |
| 2006 | if ((flags & SigmaValue) == 0) |
| 2007 | white_point=(MagickRealType) QuantumRange-black_point; |
| 2008 | if ((*option == '+') || ((flags & AspectValue) != 0)) |
| 2009 | (void) LevelizeImageChannel(*image,channel,black_point, |
| 2010 | white_point,gamma); |
| 2011 | else |
| 2012 | (void) LevelImageChannel(*image,channel,black_point,white_point, |
| 2013 | gamma); |
| 2014 | InheritException(exception,&(*image)->exception); |
| 2015 | break; |
| 2016 | } |
| 2017 | if (LocaleCompare("level-colors",option+1) == 0) |
| 2018 | { |
| 2019 | char |
| 2020 | token[MaxTextExtent]; |
| 2021 | |
| 2022 | const char |
| 2023 | *p; |
| 2024 | |
| 2025 | MagickPixelPacket |
| 2026 | black_point, |
| 2027 | white_point; |
| 2028 | |
| 2029 | p=(const char *) argv[i+1]; |
| 2030 | GetMagickToken(p,&p,token); /* get black point color */ |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2031 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2032 | (void) QueryMagickColor(token,&black_point,exception); |
| 2033 | else |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2034 | (void) QueryMagickColor("#000000",&black_point,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2035 | if (isalpha((int) token[0]) || (token[0] == '#')) |
| 2036 | GetMagickToken(p,&p,token); |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2037 | if (*token == '\0') |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2038 | white_point=black_point; /* set everything to that color */ |
| 2039 | else |
| 2040 | { |
| 2041 | /* |
| 2042 | Get white point color. |
| 2043 | */ |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2044 | if ((isalpha((int) *token) == 0) && ((*token == '#') == 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2045 | GetMagickToken(p,&p,token); |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2046 | if ((isalpha((int) *token) != 0) || ((*token == '#') != 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2047 | (void) QueryMagickColor(token,&white_point,exception); |
| 2048 | else |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 2049 | (void) QueryMagickColor("#ffffff",&white_point,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2050 | } |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 2051 | (void) LevelColorsImageChannel(*image,channel,&black_point, |
| 2052 | &white_point,*option == '+' ? MagickTrue : MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2053 | break; |
| 2054 | } |
| 2055 | if (LocaleCompare("linear-stretch",option+1) == 0) |
| 2056 | { |
| 2057 | double |
| 2058 | black_point, |
| 2059 | white_point; |
| 2060 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2061 | MagickStatusType |
| 2062 | flags; |
| 2063 | |
| 2064 | (void) SyncImageSettings(image_info,*image); |
| 2065 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2066 | black_point=geometry_info.rho; |
| 2067 | white_point=(MagickRealType) (*image)->columns*(*image)->rows; |
| 2068 | if ((flags & SigmaValue) != 0) |
| 2069 | white_point=geometry_info.sigma; |
| 2070 | if ((flags & PercentValue) != 0) |
| 2071 | { |
| 2072 | black_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 2073 | white_point*=(double) (*image)->columns*(*image)->rows/100.0; |
| 2074 | } |
| 2075 | if ((flags & SigmaValue) == 0) |
| 2076 | white_point=(MagickRealType) (*image)->columns*(*image)->rows- |
| 2077 | black_point; |
| 2078 | (void) LinearStretchImage(*image,black_point,white_point); |
| 2079 | InheritException(exception,&(*image)->exception); |
| 2080 | break; |
| 2081 | } |
| 2082 | if (LocaleCompare("linewidth",option+1) == 0) |
| 2083 | { |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2084 | draw_info->stroke_width=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2085 | break; |
| 2086 | } |
| 2087 | if (LocaleCompare("liquid-rescale",option+1) == 0) |
| 2088 | { |
| 2089 | Image |
| 2090 | *resize_image; |
| 2091 | |
| 2092 | /* |
| 2093 | Liquid rescale image. |
| 2094 | */ |
| 2095 | (void) SyncImageSettings(image_info,*image); |
| 2096 | flags=ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2097 | if ((flags & XValue) == 0) |
| 2098 | geometry.x=1; |
| 2099 | if ((flags & YValue) == 0) |
| 2100 | geometry.y=0; |
| 2101 | resize_image=LiquidRescaleImage(*image,geometry.width, |
| 2102 | geometry.height,1.0*geometry.x,1.0*geometry.y,exception); |
| 2103 | if (resize_image == (Image *) NULL) |
| 2104 | break; |
| 2105 | *image=DestroyImage(*image); |
| 2106 | *image=resize_image; |
| 2107 | break; |
| 2108 | } |
| 2109 | if (LocaleCompare("lowlight-color",option+1) == 0) |
| 2110 | { |
| 2111 | (void) SetImageArtifact(*image,option+1,argv[i+1]); |
| 2112 | break; |
| 2113 | } |
| 2114 | break; |
| 2115 | } |
| 2116 | case 'm': |
| 2117 | { |
| 2118 | if (LocaleCompare("map",option+1) == 0) |
| 2119 | { |
| 2120 | Image |
| 2121 | *remap_image; |
| 2122 | |
| 2123 | /* |
| 2124 | Transform image colors to match this set of colors. |
| 2125 | */ |
| 2126 | (void) SyncImageSettings(image_info,*image); |
| 2127 | if (*option == '+') |
| 2128 | break; |
| 2129 | remap_image=GetImageCache(image_info,argv[i+1],exception); |
| 2130 | if (remap_image == (Image *) NULL) |
| 2131 | break; |
| 2132 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2133 | InheritException(exception,&(*image)->exception); |
| 2134 | remap_image=DestroyImage(remap_image); |
| 2135 | break; |
| 2136 | } |
| 2137 | if (LocaleCompare("mask",option+1) == 0) |
| 2138 | { |
| 2139 | Image |
| 2140 | *mask; |
| 2141 | |
| 2142 | (void) SyncImageSettings(image_info,*image); |
| 2143 | if (*option == '+') |
| 2144 | { |
| 2145 | /* |
| 2146 | Remove a mask. |
| 2147 | */ |
| 2148 | (void) SetImageMask(*image,(Image *) NULL); |
| 2149 | InheritException(exception,&(*image)->exception); |
| 2150 | break; |
| 2151 | } |
| 2152 | /* |
| 2153 | Set the image mask. |
| 2154 | */ |
| 2155 | mask=GetImageCache(image_info,argv[i+1],exception); |
| 2156 | if (mask == (Image *) NULL) |
| 2157 | break; |
| 2158 | (void) SetImageMask(*image,mask); |
| 2159 | mask=DestroyImage(mask); |
| 2160 | InheritException(exception,&(*image)->exception); |
| 2161 | break; |
| 2162 | } |
| 2163 | if (LocaleCompare("matte",option+1) == 0) |
| 2164 | { |
| 2165 | (void) SetImageAlphaChannel(*image,(*option == '-') ? |
| 2166 | SetAlphaChannel : DeactivateAlphaChannel ); |
| 2167 | InheritException(exception,&(*image)->exception); |
| 2168 | break; |
| 2169 | } |
| 2170 | if (LocaleCompare("median",option+1) == 0) |
| 2171 | { |
| 2172 | Image |
| 2173 | *median_image; |
| 2174 | |
| 2175 | /* |
| 2176 | Median filter image. |
| 2177 | */ |
| 2178 | (void) SyncImageSettings(image_info,*image); |
| 2179 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2180 | median_image=MedianFilterImage(*image,geometry_info.rho,exception); |
| 2181 | if (median_image == (Image *) NULL) |
| 2182 | break; |
| 2183 | *image=DestroyImage(*image); |
| 2184 | *image=median_image; |
| 2185 | break; |
| 2186 | } |
| 2187 | if (LocaleCompare("modulate",option+1) == 0) |
| 2188 | { |
| 2189 | (void) SyncImageSettings(image_info,*image); |
| 2190 | (void) ModulateImage(*image,argv[i+1]); |
| 2191 | InheritException(exception,&(*image)->exception); |
| 2192 | break; |
| 2193 | } |
| 2194 | if (LocaleCompare("monitor",option+1) == 0) |
| 2195 | { |
cristy | 7d34ef2 | 2010-03-25 01:11:22 +0000 | [diff] [blame] | 2196 | if (*option == '+') |
| 2197 | { |
| 2198 | (void) SetImageProgressMonitor(*image, |
| 2199 | (MagickProgressMonitor) NULL,(void *) NULL); |
| 2200 | break; |
| 2201 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2202 | (void) SetImageProgressMonitor(*image,MonitorProgress, |
| 2203 | (void *) NULL); |
| 2204 | break; |
| 2205 | } |
| 2206 | if (LocaleCompare("monochrome",option+1) == 0) |
| 2207 | { |
| 2208 | (void) SyncImageSettings(image_info,*image); |
| 2209 | (void) SetImageType(*image,BilevelType); |
| 2210 | InheritException(exception,&(*image)->exception); |
| 2211 | break; |
| 2212 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2213 | if (LocaleCompare("morphology",option+1) == 0) |
| 2214 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2215 | char |
| 2216 | token[MaxTextExtent]; |
| 2217 | |
| 2218 | const char |
| 2219 | *p; |
| 2220 | |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2221 | Image |
| 2222 | *morphology_image; |
| 2223 | |
| 2224 | KernelInfo |
| 2225 | *kernel; |
| 2226 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2227 | ssize_t |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2228 | iterations; |
| 2229 | |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2230 | MorphologyMethod |
| 2231 | method; |
| 2232 | |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2233 | /* |
| 2234 | Morphological Image Operation |
| 2235 | */ |
| 2236 | (void) SyncImageSettings(image_info,*image); |
| 2237 | p=argv[i+1]; |
| 2238 | GetMagickToken(p,&p,token); |
| 2239 | method=(MorphologyMethod) ParseMagickOption(MagickMorphologyOptions, |
cristy | d2c1e1e | 2010-05-08 01:05:44 +0000 | [diff] [blame] | 2240 | MagickFalse,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2241 | iterations=1L; |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2242 | GetMagickToken(p,&p,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2243 | if ((*p == ':') || (*p == ',')) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2244 | GetMagickToken(p,&p,token); |
cristy | ef65691 | 2010-03-05 19:54:59 +0000 | [diff] [blame] | 2245 | if ((*p != '\0')) |
| 2246 | iterations=StringToLong(p); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2247 | kernel=AcquireKernelInfo(argv[i+2]); |
| 2248 | if (kernel == (KernelInfo *) NULL) |
cristy | e96405a | 2010-05-19 02:24:31 +0000 | [diff] [blame] | 2249 | { |
| 2250 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 2251 | OptionError,"UnabletoParseKernel","morphology"); |
| 2252 | status=MagickFalse; |
| 2253 | break; |
| 2254 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2255 | morphology_image=MorphologyImageChannel(*image,channel,method, |
cristy | 02d5b4f | 2010-02-01 01:08:27 +0000 | [diff] [blame] | 2256 | iterations,kernel,exception); |
anthony | 83ba99b | 2010-01-24 08:48:15 +0000 | [diff] [blame] | 2257 | kernel=DestroyKernelInfo(kernel); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 2258 | if (morphology_image == (Image *) NULL) |
| 2259 | break; |
| 2260 | *image=DestroyImage(*image); |
| 2261 | *image=morphology_image; |
| 2262 | break; |
| 2263 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2264 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 2265 | { |
| 2266 | Image |
| 2267 | *blur_image; |
| 2268 | |
| 2269 | /* |
| 2270 | Motion blur image. |
| 2271 | */ |
| 2272 | (void) SyncImageSettings(image_info,*image); |
| 2273 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2274 | if ((flags & SigmaValue) == 0) |
| 2275 | geometry_info.sigma=1.0; |
| 2276 | blur_image=MotionBlurImageChannel(*image,channel,geometry_info.rho, |
| 2277 | geometry_info.sigma,geometry_info.xi,exception); |
| 2278 | if (blur_image == (Image *) NULL) |
| 2279 | break; |
| 2280 | *image=DestroyImage(*image); |
| 2281 | *image=blur_image; |
| 2282 | break; |
| 2283 | } |
| 2284 | break; |
| 2285 | } |
| 2286 | case 'n': |
| 2287 | { |
| 2288 | if (LocaleCompare("negate",option+1) == 0) |
| 2289 | { |
| 2290 | (void) SyncImageSettings(image_info,*image); |
| 2291 | (void) NegateImageChannel(*image,channel,*option == '+' ? |
| 2292 | MagickTrue : MagickFalse); |
| 2293 | InheritException(exception,&(*image)->exception); |
| 2294 | break; |
| 2295 | } |
| 2296 | if (LocaleCompare("noise",option+1) == 0) |
| 2297 | { |
| 2298 | Image |
| 2299 | *noisy_image; |
| 2300 | |
| 2301 | (void) SyncImageSettings(image_info,*image); |
| 2302 | if (*option == '-') |
| 2303 | { |
| 2304 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2305 | noisy_image=ReduceNoiseImage(*image,geometry_info.rho, |
| 2306 | exception); |
| 2307 | } |
| 2308 | else |
| 2309 | { |
| 2310 | NoiseType |
| 2311 | noise; |
| 2312 | |
| 2313 | noise=(NoiseType) ParseMagickOption(MagickNoiseOptions, |
| 2314 | MagickFalse,argv[i+1]); |
| 2315 | noisy_image=AddNoiseImageChannel(*image,channel,noise, |
| 2316 | exception); |
| 2317 | } |
| 2318 | if (noisy_image == (Image *) NULL) |
| 2319 | break; |
| 2320 | *image=DestroyImage(*image); |
| 2321 | *image=noisy_image; |
| 2322 | break; |
| 2323 | } |
| 2324 | if (LocaleCompare("normalize",option+1) == 0) |
| 2325 | { |
| 2326 | (void) SyncImageSettings(image_info,*image); |
| 2327 | (void) NormalizeImageChannel(*image,channel); |
| 2328 | InheritException(exception,&(*image)->exception); |
| 2329 | break; |
| 2330 | } |
| 2331 | break; |
| 2332 | } |
| 2333 | case 'o': |
| 2334 | { |
| 2335 | if (LocaleCompare("opaque",option+1) == 0) |
| 2336 | { |
| 2337 | MagickPixelPacket |
| 2338 | target; |
| 2339 | |
| 2340 | (void) SyncImageSettings(image_info,*image); |
| 2341 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 2342 | (void) OpaquePaintImageChannel(*image,channel,&target,&fill, |
| 2343 | *option == '-' ? MagickFalse : MagickTrue); |
| 2344 | break; |
| 2345 | } |
| 2346 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 2347 | { |
| 2348 | (void) SyncImageSettings(image_info,*image); |
| 2349 | (void) OrderedPosterizeImageChannel(*image,channel,argv[i+1], |
| 2350 | exception); |
| 2351 | break; |
| 2352 | } |
| 2353 | break; |
| 2354 | } |
| 2355 | case 'p': |
| 2356 | { |
| 2357 | if (LocaleCompare("paint",option+1) == 0) |
| 2358 | { |
| 2359 | Image |
| 2360 | *paint_image; |
| 2361 | |
| 2362 | /* |
| 2363 | Oil paint image. |
| 2364 | */ |
| 2365 | (void) SyncImageSettings(image_info,*image); |
| 2366 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2367 | paint_image=OilPaintImage(*image,geometry_info.rho,exception); |
| 2368 | if (paint_image == (Image *) NULL) |
| 2369 | break; |
| 2370 | *image=DestroyImage(*image); |
| 2371 | *image=paint_image; |
| 2372 | break; |
| 2373 | } |
| 2374 | if (LocaleCompare("pen",option+1) == 0) |
| 2375 | { |
| 2376 | if (*option == '+') |
| 2377 | { |
| 2378 | (void) QueryColorDatabase("none",&draw_info->fill,exception); |
| 2379 | break; |
| 2380 | } |
| 2381 | (void) QueryColorDatabase(argv[i+1],&draw_info->fill,exception); |
| 2382 | break; |
| 2383 | } |
| 2384 | if (LocaleCompare("pointsize",option+1) == 0) |
| 2385 | { |
| 2386 | if (*option == '+') |
| 2387 | (void) ParseGeometry("12",&geometry_info); |
| 2388 | else |
| 2389 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 2390 | draw_info->pointsize=geometry_info.rho; |
| 2391 | break; |
| 2392 | } |
| 2393 | if (LocaleCompare("polaroid",option+1) == 0) |
| 2394 | { |
| 2395 | double |
| 2396 | angle; |
| 2397 | |
| 2398 | Image |
| 2399 | *polaroid_image; |
| 2400 | |
| 2401 | RandomInfo |
| 2402 | *random_info; |
| 2403 | |
| 2404 | /* |
| 2405 | Simulate a Polaroid picture. |
| 2406 | */ |
| 2407 | (void) SyncImageSettings(image_info,*image); |
| 2408 | random_info=AcquireRandomInfo(); |
| 2409 | angle=22.5*(GetPseudoRandomValue(random_info)-0.5); |
| 2410 | random_info=DestroyRandomInfo(random_info); |
| 2411 | if (*option == '-') |
| 2412 | { |
| 2413 | SetGeometryInfo(&geometry_info); |
| 2414 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2415 | angle=geometry_info.rho; |
| 2416 | } |
| 2417 | polaroid_image=PolaroidImage(*image,draw_info,angle,exception); |
| 2418 | if (polaroid_image == (Image *) NULL) |
| 2419 | break; |
| 2420 | *image=DestroyImage(*image); |
| 2421 | *image=polaroid_image; |
| 2422 | break; |
| 2423 | } |
| 2424 | if (LocaleCompare("posterize",option+1) == 0) |
| 2425 | { |
| 2426 | /* |
| 2427 | Posterize image. |
| 2428 | */ |
| 2429 | (void) SyncImageSettings(image_info,*image); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 2430 | (void) PosterizeImage(*image,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2431 | quantize_info->dither); |
| 2432 | InheritException(exception,&(*image)->exception); |
| 2433 | break; |
| 2434 | } |
| 2435 | if (LocaleCompare("preview",option+1) == 0) |
| 2436 | { |
| 2437 | Image |
| 2438 | *preview_image; |
| 2439 | |
| 2440 | PreviewType |
| 2441 | preview_type; |
| 2442 | |
| 2443 | /* |
| 2444 | Preview image. |
| 2445 | */ |
| 2446 | (void) SyncImageSettings(image_info,*image); |
| 2447 | if (*option == '+') |
| 2448 | preview_type=UndefinedPreview; |
| 2449 | else |
| 2450 | preview_type=(PreviewType) ParseMagickOption(MagickPreviewOptions, |
| 2451 | MagickFalse,argv[i+1]); |
| 2452 | preview_image=PreviewImage(*image,preview_type,exception); |
| 2453 | if (preview_image == (Image *) NULL) |
| 2454 | break; |
| 2455 | *image=DestroyImage(*image); |
| 2456 | *image=preview_image; |
| 2457 | break; |
| 2458 | } |
| 2459 | if (LocaleCompare("profile",option+1) == 0) |
| 2460 | { |
| 2461 | const char |
| 2462 | *name; |
| 2463 | |
| 2464 | const StringInfo |
| 2465 | *profile; |
| 2466 | |
| 2467 | Image |
| 2468 | *profile_image; |
| 2469 | |
| 2470 | ImageInfo |
| 2471 | *profile_info; |
| 2472 | |
| 2473 | (void) SyncImageSettings(image_info,*image); |
| 2474 | if (*option == '+') |
| 2475 | { |
| 2476 | /* |
| 2477 | Remove a profile from the image. |
| 2478 | */ |
| 2479 | (void) ProfileImage(*image,argv[i+1],(const unsigned char *) |
| 2480 | NULL,0,MagickTrue); |
| 2481 | InheritException(exception,&(*image)->exception); |
| 2482 | break; |
| 2483 | } |
| 2484 | /* |
| 2485 | Associate a profile with the image. |
| 2486 | */ |
| 2487 | profile_info=CloneImageInfo(image_info); |
| 2488 | profile=GetImageProfile(*image,"iptc"); |
| 2489 | if (profile != (StringInfo *) NULL) |
| 2490 | profile_info->profile=(void *) CloneStringInfo(profile); |
| 2491 | profile_image=GetImageCache(profile_info,argv[i+1],exception); |
| 2492 | profile_info=DestroyImageInfo(profile_info); |
| 2493 | if (profile_image == (Image *) NULL) |
| 2494 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2495 | StringInfo |
| 2496 | *profile; |
| 2497 | |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2498 | profile_info=CloneImageInfo(image_info); |
| 2499 | (void) CopyMagickString(profile_info->filename,argv[i+1], |
| 2500 | MaxTextExtent); |
| 2501 | profile=FileToStringInfo(profile_info->filename,~0UL,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2502 | if (profile != (StringInfo *) NULL) |
| 2503 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2504 | (void) ProfileImage(*image,profile_info->magick, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2505 | GetStringInfoDatum(profile),(size_t) |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2506 | GetStringInfoLength(profile),MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2507 | profile=DestroyStringInfo(profile); |
| 2508 | } |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 2509 | profile_info=DestroyImageInfo(profile_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2510 | break; |
| 2511 | } |
| 2512 | ResetImageProfileIterator(profile_image); |
| 2513 | name=GetNextImageProfile(profile_image); |
| 2514 | while (name != (const char *) NULL) |
| 2515 | { |
| 2516 | profile=GetImageProfile(profile_image,name); |
| 2517 | if (profile != (StringInfo *) NULL) |
| 2518 | (void) ProfileImage(*image,name,GetStringInfoDatum(profile), |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2519 | (size_t) GetStringInfoLength(profile),MagickFalse); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2520 | name=GetNextImageProfile(profile_image); |
| 2521 | } |
| 2522 | profile_image=DestroyImage(profile_image); |
| 2523 | break; |
| 2524 | } |
| 2525 | break; |
| 2526 | } |
| 2527 | case 'q': |
| 2528 | { |
| 2529 | if (LocaleCompare("quantize",option+1) == 0) |
| 2530 | { |
| 2531 | if (*option == '+') |
| 2532 | { |
| 2533 | quantize_info->colorspace=UndefinedColorspace; |
| 2534 | break; |
| 2535 | } |
| 2536 | quantize_info->colorspace=(ColorspaceType) ParseMagickOption( |
| 2537 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 2538 | break; |
| 2539 | } |
| 2540 | break; |
| 2541 | } |
| 2542 | case 'r': |
| 2543 | { |
| 2544 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 2545 | { |
| 2546 | Image |
| 2547 | *blur_image; |
| 2548 | |
| 2549 | /* |
| 2550 | Radial blur image. |
| 2551 | */ |
| 2552 | (void) SyncImageSettings(image_info,*image); |
cristy | a5447be | 2010-01-11 00:20:51 +0000 | [diff] [blame] | 2553 | blur_image=RadialBlurImageChannel(*image,channel, |
| 2554 | StringToDouble(argv[i+1]),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2555 | if (blur_image == (Image *) NULL) |
| 2556 | break; |
| 2557 | *image=DestroyImage(*image); |
| 2558 | *image=blur_image; |
| 2559 | break; |
| 2560 | } |
| 2561 | if (LocaleCompare("raise",option+1) == 0) |
| 2562 | { |
| 2563 | /* |
| 2564 | Surround image with a raise of solid color. |
| 2565 | */ |
| 2566 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2567 | if ((flags & SigmaValue) == 0) |
| 2568 | geometry.height=geometry.width; |
| 2569 | (void) RaiseImage(*image,&geometry,*option == '-' ? MagickTrue : |
| 2570 | MagickFalse); |
| 2571 | InheritException(exception,&(*image)->exception); |
| 2572 | break; |
| 2573 | } |
| 2574 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 2575 | { |
| 2576 | /* |
| 2577 | Threshold image. |
| 2578 | */ |
| 2579 | (void) SyncImageSettings(image_info,*image); |
| 2580 | (void) RandomThresholdImageChannel(*image,channel,argv[i+1], |
| 2581 | exception); |
| 2582 | break; |
| 2583 | } |
| 2584 | if (LocaleCompare("recolor",option+1) == 0) |
| 2585 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2586 | Image |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2587 | *color_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2588 | |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2589 | KernelInfo |
| 2590 | *kernel; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2591 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2592 | (void) SyncImageSettings(image_info,*image); |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2593 | kernel=AcquireKernelInfo(argv[i+1]); |
| 2594 | if (kernel == (KernelInfo *) NULL) |
| 2595 | break; |
| 2596 | color_image=ColorMatrixImage(*image,kernel,exception); |
| 2597 | kernel=DestroyKernelInfo(kernel); |
| 2598 | if (color_image == (Image *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2599 | break; |
| 2600 | *image=DestroyImage(*image); |
cristy | f055ae4 | 2010-04-02 23:01:38 +0000 | [diff] [blame] | 2601 | *image=color_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2602 | break; |
| 2603 | } |
| 2604 | if (LocaleCompare("region",option+1) == 0) |
| 2605 | { |
| 2606 | Image |
| 2607 | *crop_image; |
| 2608 | |
| 2609 | (void) SyncImageSettings(image_info,*image); |
| 2610 | if (region_image != (Image *) NULL) |
| 2611 | { |
| 2612 | /* |
| 2613 | Composite region. |
| 2614 | */ |
| 2615 | (void) CompositeImage(region_image,(*image)->matte != |
| 2616 | MagickFalse ? OverCompositeOp : CopyCompositeOp,*image, |
| 2617 | region_geometry.x,region_geometry.y); |
| 2618 | InheritException(exception,®ion_image->exception); |
| 2619 | *image=DestroyImage(*image); |
| 2620 | *image=region_image; |
| 2621 | } |
| 2622 | if (*option == '+') |
| 2623 | { |
| 2624 | if (region_image != (Image *) NULL) |
| 2625 | region_image=DestroyImage(region_image); |
| 2626 | break; |
| 2627 | } |
| 2628 | /* |
| 2629 | Apply transformations to a selected region of the image. |
| 2630 | */ |
| 2631 | (void) ParseGravityGeometry(*image,argv[i+1],®ion_geometry, |
| 2632 | exception); |
| 2633 | crop_image=CropImage(*image,®ion_geometry,exception); |
| 2634 | if (crop_image == (Image *) NULL) |
| 2635 | break; |
| 2636 | region_image=(*image); |
| 2637 | *image=crop_image; |
| 2638 | break; |
| 2639 | } |
| 2640 | if (LocaleCompare("render",option+1) == 0) |
| 2641 | { |
| 2642 | (void) SyncImageSettings(image_info,*image); |
| 2643 | draw_info->render=(*option == '+') ? MagickTrue : MagickFalse; |
| 2644 | break; |
| 2645 | } |
| 2646 | if (LocaleCompare("remap",option+1) == 0) |
| 2647 | { |
| 2648 | Image |
| 2649 | *remap_image; |
| 2650 | |
| 2651 | /* |
| 2652 | Transform image colors to match this set of colors. |
| 2653 | */ |
| 2654 | (void) SyncImageSettings(image_info,*image); |
| 2655 | if (*option == '+') |
| 2656 | break; |
| 2657 | remap_image=GetImageCache(image_info,argv[i+1],exception); |
| 2658 | if (remap_image == (Image *) NULL) |
| 2659 | break; |
| 2660 | (void) RemapImage(quantize_info,*image,remap_image); |
| 2661 | InheritException(exception,&(*image)->exception); |
| 2662 | remap_image=DestroyImage(remap_image); |
| 2663 | break; |
| 2664 | } |
| 2665 | if (LocaleCompare("repage",option+1) == 0) |
| 2666 | { |
| 2667 | if (*option == '+') |
| 2668 | { |
| 2669 | (void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page); |
| 2670 | break; |
| 2671 | } |
| 2672 | (void) ResetImagePage(*image,argv[i+1]); |
| 2673 | InheritException(exception,&(*image)->exception); |
| 2674 | break; |
| 2675 | } |
| 2676 | if (LocaleCompare("resample",option+1) == 0) |
| 2677 | { |
| 2678 | Image |
| 2679 | *resample_image; |
| 2680 | |
| 2681 | /* |
| 2682 | Resample image. |
| 2683 | */ |
| 2684 | (void) SyncImageSettings(image_info,*image); |
| 2685 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2686 | if ((flags & SigmaValue) == 0) |
| 2687 | geometry_info.sigma=geometry_info.rho; |
| 2688 | resample_image=ResampleImage(*image,geometry_info.rho, |
| 2689 | geometry_info.sigma,(*image)->filter,(*image)->blur,exception); |
| 2690 | if (resample_image == (Image *) NULL) |
| 2691 | break; |
| 2692 | *image=DestroyImage(*image); |
| 2693 | *image=resample_image; |
| 2694 | break; |
| 2695 | } |
| 2696 | if (LocaleCompare("resize",option+1) == 0) |
| 2697 | { |
| 2698 | Image |
| 2699 | *resize_image; |
| 2700 | |
| 2701 | /* |
| 2702 | Resize image. |
| 2703 | */ |
| 2704 | (void) SyncImageSettings(image_info,*image); |
| 2705 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2706 | resize_image=ResizeImage(*image,geometry.width,geometry.height, |
| 2707 | (*image)->filter,(*image)->blur,exception); |
| 2708 | if (resize_image == (Image *) NULL) |
| 2709 | break; |
| 2710 | *image=DestroyImage(*image); |
| 2711 | *image=resize_image; |
| 2712 | break; |
| 2713 | } |
| 2714 | if (LocaleNCompare("respect-parentheses",option+1,17) == 0) |
| 2715 | { |
| 2716 | respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; |
| 2717 | break; |
| 2718 | } |
| 2719 | if (LocaleCompare("roll",option+1) == 0) |
| 2720 | { |
| 2721 | Image |
| 2722 | *roll_image; |
| 2723 | |
| 2724 | /* |
| 2725 | Roll image. |
| 2726 | */ |
| 2727 | (void) SyncImageSettings(image_info,*image); |
| 2728 | (void) ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2729 | roll_image=RollImage(*image,geometry.x,geometry.y,exception); |
| 2730 | if (roll_image == (Image *) NULL) |
| 2731 | break; |
| 2732 | *image=DestroyImage(*image); |
| 2733 | *image=roll_image; |
| 2734 | break; |
| 2735 | } |
| 2736 | if (LocaleCompare("rotate",option+1) == 0) |
| 2737 | { |
| 2738 | char |
| 2739 | *geometry; |
| 2740 | |
| 2741 | Image |
| 2742 | *rotate_image; |
| 2743 | |
| 2744 | /* |
| 2745 | Check for conditional image rotation. |
| 2746 | */ |
| 2747 | (void) SyncImageSettings(image_info,*image); |
| 2748 | if (strchr(argv[i+1],'>') != (char *) NULL) |
| 2749 | if ((*image)->columns <= (*image)->rows) |
| 2750 | break; |
| 2751 | if (strchr(argv[i+1],'<') != (char *) NULL) |
| 2752 | if ((*image)->columns >= (*image)->rows) |
| 2753 | break; |
| 2754 | /* |
| 2755 | Rotate image. |
| 2756 | */ |
| 2757 | geometry=ConstantString(argv[i+1]); |
| 2758 | (void) SubstituteString(&geometry,">",""); |
| 2759 | (void) SubstituteString(&geometry,"<",""); |
| 2760 | (void) ParseGeometry(geometry,&geometry_info); |
| 2761 | geometry=DestroyString(geometry); |
| 2762 | rotate_image=RotateImage(*image,geometry_info.rho,exception); |
| 2763 | if (rotate_image == (Image *) NULL) |
| 2764 | break; |
| 2765 | *image=DestroyImage(*image); |
| 2766 | *image=rotate_image; |
| 2767 | break; |
| 2768 | } |
| 2769 | break; |
| 2770 | } |
| 2771 | case 's': |
| 2772 | { |
| 2773 | if (LocaleCompare("sample",option+1) == 0) |
| 2774 | { |
| 2775 | Image |
| 2776 | *sample_image; |
| 2777 | |
| 2778 | /* |
| 2779 | Sample image with pixel replication. |
| 2780 | */ |
| 2781 | (void) SyncImageSettings(image_info,*image); |
| 2782 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2783 | sample_image=SampleImage(*image,geometry.width,geometry.height, |
| 2784 | exception); |
| 2785 | if (sample_image == (Image *) NULL) |
| 2786 | break; |
| 2787 | *image=DestroyImage(*image); |
| 2788 | *image=sample_image; |
| 2789 | break; |
| 2790 | } |
| 2791 | if (LocaleCompare("scale",option+1) == 0) |
| 2792 | { |
| 2793 | Image |
| 2794 | *scale_image; |
| 2795 | |
| 2796 | /* |
| 2797 | Resize image. |
| 2798 | */ |
| 2799 | (void) SyncImageSettings(image_info,*image); |
| 2800 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 2801 | scale_image=ScaleImage(*image,geometry.width,geometry.height, |
| 2802 | exception); |
| 2803 | if (scale_image == (Image *) NULL) |
| 2804 | break; |
| 2805 | *image=DestroyImage(*image); |
| 2806 | *image=scale_image; |
| 2807 | break; |
| 2808 | } |
| 2809 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 2810 | { |
| 2811 | Image |
| 2812 | *blur_image; |
| 2813 | |
| 2814 | /* |
| 2815 | Selectively blur pixels within a contrast threshold. |
| 2816 | */ |
| 2817 | (void) SyncImageSettings(image_info,*image); |
| 2818 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2819 | if ((flags & PercentValue) != 0) |
| 2820 | geometry_info.xi=(double) QuantumRange*geometry_info.xi/100.0; |
| 2821 | blur_image=SelectiveBlurImageChannel(*image,channel, |
| 2822 | geometry_info.rho,geometry_info.sigma,geometry_info.xi,exception); |
| 2823 | if (blur_image == (Image *) NULL) |
| 2824 | break; |
| 2825 | *image=DestroyImage(*image); |
| 2826 | *image=blur_image; |
| 2827 | break; |
| 2828 | } |
| 2829 | if (LocaleCompare("separate",option+1) == 0) |
| 2830 | { |
| 2831 | Image |
| 2832 | *separate_images; |
| 2833 | |
| 2834 | /* |
| 2835 | Break channels into separate images. |
| 2836 | */ |
| 2837 | (void) SyncImageSettings(image_info,*image); |
| 2838 | separate_images=SeparateImages(*image,channel,exception); |
| 2839 | if (separate_images == (Image *) NULL) |
| 2840 | break; |
| 2841 | *image=DestroyImage(*image); |
| 2842 | *image=separate_images; |
| 2843 | break; |
| 2844 | } |
| 2845 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 2846 | { |
| 2847 | double |
| 2848 | threshold; |
| 2849 | |
| 2850 | Image |
| 2851 | *sepia_image; |
| 2852 | |
| 2853 | /* |
| 2854 | Sepia-tone image. |
| 2855 | */ |
| 2856 | (void) SyncImageSettings(image_info,*image); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 2857 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2858 | sepia_image=SepiaToneImage(*image,threshold,exception); |
| 2859 | if (sepia_image == (Image *) NULL) |
| 2860 | break; |
| 2861 | *image=DestroyImage(*image); |
| 2862 | *image=sepia_image; |
| 2863 | break; |
| 2864 | } |
| 2865 | if (LocaleCompare("segment",option+1) == 0) |
| 2866 | { |
| 2867 | /* |
| 2868 | Segment image. |
| 2869 | */ |
| 2870 | (void) SyncImageSettings(image_info,*image); |
| 2871 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2872 | if ((flags & SigmaValue) == 0) |
| 2873 | geometry_info.sigma=1.0; |
| 2874 | (void) SegmentImage(*image,(*image)->colorspace,image_info->verbose, |
| 2875 | geometry_info.rho,geometry_info.sigma); |
| 2876 | InheritException(exception,&(*image)->exception); |
| 2877 | break; |
| 2878 | } |
| 2879 | if (LocaleCompare("set",option+1) == 0) |
| 2880 | { |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2881 | char |
| 2882 | *value; |
| 2883 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2884 | /* |
| 2885 | Set image option. |
| 2886 | */ |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2887 | if (*option == '+') |
| 2888 | { |
| 2889 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 2890 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 2891 | else |
| 2892 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
cristy | 7e10958 | 2010-06-01 12:56:44 +0000 | [diff] [blame] | 2893 | { |
| 2894 | (void) DeleteImageOption(image_info,argv[i+1]+7); |
| 2895 | (void) DeleteImageArtifact(*image,argv[i+1]+7); |
| 2896 | } |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2897 | else |
| 2898 | (void) DeleteImageProperty(*image,argv[i+1]); |
| 2899 | break; |
| 2900 | } |
| 2901 | value=InterpretImageProperties(image_info,*image,argv[i+2]); |
| 2902 | if (value == (char *) NULL) |
| 2903 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2904 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2905 | (void) SetImageRegistry(StringRegistryType,argv[i+1]+9,value, |
| 2906 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2907 | else |
| 2908 | if (LocaleNCompare(argv[i+1],"option:",7) == 0) |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2909 | { |
| 2910 | (void) SetImageOption(image_info,argv[i+1]+7,value); |
| 2911 | (void) SetImageArtifact(*image,argv[i+1]+7,value); |
| 2912 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2913 | else |
cristy | 6d9a129 | 2010-05-31 14:17:06 +0000 | [diff] [blame] | 2914 | (void) SetImageProperty(*image,argv[i+1],value); |
| 2915 | value=DestroyString(value); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2916 | break; |
| 2917 | } |
| 2918 | if (LocaleCompare("shade",option+1) == 0) |
| 2919 | { |
| 2920 | Image |
| 2921 | *shade_image; |
| 2922 | |
| 2923 | /* |
| 2924 | Shade image. |
| 2925 | */ |
| 2926 | (void) SyncImageSettings(image_info,*image); |
| 2927 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2928 | if ((flags & SigmaValue) == 0) |
| 2929 | geometry_info.sigma=1.0; |
| 2930 | shade_image=ShadeImage(*image,(*option == '-') ? MagickTrue : |
| 2931 | MagickFalse,geometry_info.rho,geometry_info.sigma,exception); |
| 2932 | if (shade_image == (Image *) NULL) |
| 2933 | break; |
| 2934 | *image=DestroyImage(*image); |
| 2935 | *image=shade_image; |
| 2936 | break; |
| 2937 | } |
| 2938 | if (LocaleCompare("shadow",option+1) == 0) |
| 2939 | { |
| 2940 | Image |
| 2941 | *shadow_image; |
| 2942 | |
| 2943 | /* |
| 2944 | Shadow image. |
| 2945 | */ |
| 2946 | (void) SyncImageSettings(image_info,*image); |
| 2947 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2948 | if ((flags & SigmaValue) == 0) |
| 2949 | geometry_info.sigma=1.0; |
| 2950 | if ((flags & XiValue) == 0) |
| 2951 | geometry_info.xi=4.0; |
| 2952 | if ((flags & PsiValue) == 0) |
| 2953 | geometry_info.psi=4.0; |
| 2954 | shadow_image=ShadowImage(*image,geometry_info.rho, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2955 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
cristy | 0534a6b | 2010-03-18 01:19:38 +0000 | [diff] [blame] | 2956 | ceil(geometry_info.psi-0.5),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2957 | if (shadow_image == (Image *) NULL) |
| 2958 | break; |
| 2959 | *image=DestroyImage(*image); |
| 2960 | *image=shadow_image; |
| 2961 | break; |
| 2962 | } |
| 2963 | if (LocaleCompare("sharpen",option+1) == 0) |
| 2964 | { |
| 2965 | Image |
| 2966 | *sharp_image; |
| 2967 | |
| 2968 | /* |
| 2969 | Sharpen image. |
| 2970 | */ |
| 2971 | (void) SyncImageSettings(image_info,*image); |
| 2972 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 2973 | if ((flags & SigmaValue) == 0) |
| 2974 | geometry_info.sigma=1.0; |
| 2975 | sharp_image=SharpenImageChannel(*image,channel,geometry_info.rho, |
| 2976 | geometry_info.sigma,exception); |
| 2977 | if (sharp_image == (Image *) NULL) |
| 2978 | break; |
| 2979 | *image=DestroyImage(*image); |
| 2980 | *image=sharp_image; |
| 2981 | break; |
| 2982 | } |
| 2983 | if (LocaleCompare("shave",option+1) == 0) |
| 2984 | { |
| 2985 | Image |
| 2986 | *shave_image; |
| 2987 | |
| 2988 | /* |
| 2989 | Shave the image edges. |
| 2990 | */ |
| 2991 | (void) SyncImageSettings(image_info,*image); |
| 2992 | flags=ParsePageGeometry(*image,argv[i+1],&geometry,exception); |
| 2993 | shave_image=ShaveImage(*image,&geometry,exception); |
| 2994 | if (shave_image == (Image *) NULL) |
| 2995 | break; |
| 2996 | *image=DestroyImage(*image); |
| 2997 | *image=shave_image; |
| 2998 | break; |
| 2999 | } |
| 3000 | if (LocaleCompare("shear",option+1) == 0) |
| 3001 | { |
| 3002 | Image |
| 3003 | *shear_image; |
| 3004 | |
| 3005 | /* |
| 3006 | Shear image. |
| 3007 | */ |
| 3008 | (void) SyncImageSettings(image_info,*image); |
| 3009 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3010 | if ((flags & SigmaValue) == 0) |
| 3011 | geometry_info.sigma=geometry_info.rho; |
| 3012 | shear_image=ShearImage(*image,geometry_info.rho,geometry_info.sigma, |
| 3013 | exception); |
| 3014 | if (shear_image == (Image *) NULL) |
| 3015 | break; |
| 3016 | *image=DestroyImage(*image); |
| 3017 | *image=shear_image; |
| 3018 | break; |
| 3019 | } |
| 3020 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 3021 | { |
| 3022 | /* |
| 3023 | Sigmoidal non-linearity contrast control. |
| 3024 | */ |
| 3025 | (void) SyncImageSettings(image_info,*image); |
| 3026 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3027 | if ((flags & SigmaValue) == 0) |
| 3028 | geometry_info.sigma=(double) QuantumRange/2.0; |
| 3029 | if ((flags & PercentValue) != 0) |
| 3030 | geometry_info.sigma=(double) QuantumRange*geometry_info.sigma/ |
| 3031 | 100.0; |
| 3032 | (void) SigmoidalContrastImageChannel(*image,channel, |
| 3033 | (*option == '-') ? MagickTrue : MagickFalse,geometry_info.rho, |
| 3034 | geometry_info.sigma); |
| 3035 | InheritException(exception,&(*image)->exception); |
| 3036 | break; |
| 3037 | } |
| 3038 | if (LocaleCompare("sketch",option+1) == 0) |
| 3039 | { |
| 3040 | Image |
| 3041 | *sketch_image; |
| 3042 | |
| 3043 | /* |
| 3044 | Sketch image. |
| 3045 | */ |
| 3046 | (void) SyncImageSettings(image_info,*image); |
| 3047 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3048 | if ((flags & SigmaValue) == 0) |
| 3049 | geometry_info.sigma=1.0; |
| 3050 | sketch_image=SketchImage(*image,geometry_info.rho, |
| 3051 | geometry_info.sigma,geometry_info.xi,exception); |
| 3052 | if (sketch_image == (Image *) NULL) |
| 3053 | break; |
| 3054 | *image=DestroyImage(*image); |
| 3055 | *image=sketch_image; |
| 3056 | break; |
| 3057 | } |
| 3058 | if (LocaleCompare("solarize",option+1) == 0) |
| 3059 | { |
| 3060 | double |
| 3061 | threshold; |
| 3062 | |
| 3063 | (void) SyncImageSettings(image_info,*image); |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 3064 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3065 | (void) SolarizeImage(*image,threshold); |
| 3066 | InheritException(exception,&(*image)->exception); |
| 3067 | break; |
| 3068 | } |
| 3069 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 3070 | { |
| 3071 | Image |
| 3072 | *sparse_image; |
| 3073 | |
| 3074 | SparseColorMethod |
| 3075 | method; |
| 3076 | |
| 3077 | char |
| 3078 | *arguments; |
| 3079 | |
| 3080 | /* |
| 3081 | Sparse Color Interpolated Gradient |
| 3082 | */ |
| 3083 | (void) SyncImageSettings(image_info,*image); |
| 3084 | method=(SparseColorMethod) ParseMagickOption( |
| 3085 | MagickSparseColorOptions,MagickFalse,argv[i+1]); |
| 3086 | arguments=InterpretImageProperties(image_info,*image,argv[i+2]); |
| 3087 | InheritException(exception,&(*image)->exception); |
| 3088 | if (arguments == (char *) NULL) |
| 3089 | break; |
| 3090 | sparse_image=SparseColorOption(*image,channel,method,arguments, |
| 3091 | option[0] == '+' ? MagickTrue : MagickFalse,exception); |
| 3092 | arguments=DestroyString(arguments); |
| 3093 | if (sparse_image == (Image *) NULL) |
| 3094 | break; |
| 3095 | *image=DestroyImage(*image); |
| 3096 | *image=sparse_image; |
| 3097 | break; |
| 3098 | } |
| 3099 | if (LocaleCompare("splice",option+1) == 0) |
| 3100 | { |
| 3101 | Image |
| 3102 | *splice_image; |
| 3103 | |
| 3104 | /* |
| 3105 | Splice a solid color into the image. |
| 3106 | */ |
| 3107 | (void) SyncImageSettings(image_info,*image); |
| 3108 | (void) ParseGravityGeometry(*image,argv[i+1],&geometry,exception); |
| 3109 | splice_image=SpliceImage(*image,&geometry,exception); |
| 3110 | if (splice_image == (Image *) NULL) |
| 3111 | break; |
| 3112 | *image=DestroyImage(*image); |
| 3113 | *image=splice_image; |
| 3114 | break; |
| 3115 | } |
| 3116 | if (LocaleCompare("spread",option+1) == 0) |
| 3117 | { |
| 3118 | Image |
| 3119 | *spread_image; |
| 3120 | |
| 3121 | /* |
| 3122 | Spread an image. |
| 3123 | */ |
| 3124 | (void) SyncImageSettings(image_info,*image); |
| 3125 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 3126 | spread_image=SpreadImage(*image,geometry_info.rho,exception); |
| 3127 | if (spread_image == (Image *) NULL) |
| 3128 | break; |
| 3129 | *image=DestroyImage(*image); |
| 3130 | *image=spread_image; |
| 3131 | break; |
| 3132 | } |
| 3133 | if (LocaleCompare("stretch",option+1) == 0) |
| 3134 | { |
| 3135 | if (*option == '+') |
| 3136 | { |
| 3137 | draw_info->stretch=UndefinedStretch; |
| 3138 | break; |
| 3139 | } |
| 3140 | draw_info->stretch=(StretchType) ParseMagickOption( |
| 3141 | MagickStretchOptions,MagickFalse,argv[i+1]); |
| 3142 | break; |
| 3143 | } |
| 3144 | if (LocaleCompare("strip",option+1) == 0) |
| 3145 | { |
| 3146 | /* |
| 3147 | Strip image of profiles and comments. |
| 3148 | */ |
| 3149 | (void) SyncImageSettings(image_info,*image); |
| 3150 | (void) StripImage(*image); |
| 3151 | InheritException(exception,&(*image)->exception); |
| 3152 | break; |
| 3153 | } |
| 3154 | if (LocaleCompare("stroke",option+1) == 0) |
| 3155 | { |
| 3156 | ExceptionInfo |
| 3157 | *sans; |
| 3158 | |
| 3159 | if (*option == '+') |
| 3160 | { |
| 3161 | (void) QueryColorDatabase("none",&draw_info->stroke,exception); |
| 3162 | if (draw_info->stroke_pattern != (Image *) NULL) |
| 3163 | draw_info->stroke_pattern=DestroyImage( |
| 3164 | draw_info->stroke_pattern); |
| 3165 | break; |
| 3166 | } |
| 3167 | sans=AcquireExceptionInfo(); |
| 3168 | status=QueryColorDatabase(argv[i+1],&draw_info->stroke,sans); |
| 3169 | sans=DestroyExceptionInfo(sans); |
| 3170 | if (status == MagickFalse) |
| 3171 | draw_info->stroke_pattern=GetImageCache(image_info,argv[i+1], |
| 3172 | exception); |
| 3173 | break; |
| 3174 | } |
| 3175 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 3176 | { |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 3177 | draw_info->stroke_width=StringToDouble(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3178 | break; |
| 3179 | } |
| 3180 | if (LocaleCompare("style",option+1) == 0) |
| 3181 | { |
| 3182 | if (*option == '+') |
| 3183 | { |
| 3184 | draw_info->style=UndefinedStyle; |
| 3185 | break; |
| 3186 | } |
| 3187 | draw_info->style=(StyleType) ParseMagickOption(MagickStyleOptions, |
| 3188 | MagickFalse,argv[i+1]); |
| 3189 | break; |
| 3190 | } |
| 3191 | if (LocaleCompare("swirl",option+1) == 0) |
| 3192 | { |
| 3193 | Image |
| 3194 | *swirl_image; |
| 3195 | |
| 3196 | /* |
| 3197 | Swirl image. |
| 3198 | */ |
| 3199 | (void) SyncImageSettings(image_info,*image); |
| 3200 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 3201 | swirl_image=SwirlImage(*image,geometry_info.rho,exception); |
| 3202 | if (swirl_image == (Image *) NULL) |
| 3203 | break; |
| 3204 | *image=DestroyImage(*image); |
| 3205 | *image=swirl_image; |
| 3206 | break; |
| 3207 | } |
| 3208 | break; |
| 3209 | } |
| 3210 | case 't': |
| 3211 | { |
| 3212 | if (LocaleCompare("threshold",option+1) == 0) |
| 3213 | { |
| 3214 | double |
| 3215 | threshold; |
| 3216 | |
| 3217 | /* |
| 3218 | Threshold image. |
| 3219 | */ |
| 3220 | (void) SyncImageSettings(image_info,*image); |
| 3221 | if (*option == '+') |
| 3222 | threshold=(double) QuantumRange/2.5; |
| 3223 | else |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 3224 | threshold=SiPrefixToDouble(argv[i+1],QuantumRange); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3225 | (void) BilevelImageChannel(*image,channel,threshold); |
| 3226 | InheritException(exception,&(*image)->exception); |
| 3227 | break; |
| 3228 | } |
| 3229 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 3230 | { |
| 3231 | Image |
| 3232 | *thumbnail_image; |
| 3233 | |
| 3234 | /* |
| 3235 | Thumbnail image. |
| 3236 | */ |
| 3237 | (void) SyncImageSettings(image_info,*image); |
| 3238 | (void) ParseRegionGeometry(*image,argv[i+1],&geometry,exception); |
| 3239 | thumbnail_image=ThumbnailImage(*image,geometry.width, |
| 3240 | geometry.height,exception); |
| 3241 | if (thumbnail_image == (Image *) NULL) |
| 3242 | break; |
| 3243 | *image=DestroyImage(*image); |
| 3244 | *image=thumbnail_image; |
| 3245 | break; |
| 3246 | } |
| 3247 | if (LocaleCompare("tile",option+1) == 0) |
| 3248 | { |
| 3249 | if (*option == '+') |
| 3250 | { |
| 3251 | if (draw_info->fill_pattern != (Image *) NULL) |
| 3252 | draw_info->fill_pattern=DestroyImage(draw_info->fill_pattern); |
| 3253 | break; |
| 3254 | } |
| 3255 | draw_info->fill_pattern=GetImageCache(image_info,argv[i+1], |
| 3256 | exception); |
| 3257 | break; |
| 3258 | } |
| 3259 | if (LocaleCompare("tint",option+1) == 0) |
| 3260 | { |
| 3261 | Image |
| 3262 | *tint_image; |
| 3263 | |
| 3264 | /* |
| 3265 | Tint the image. |
| 3266 | */ |
| 3267 | (void) SyncImageSettings(image_info,*image); |
| 3268 | tint_image=TintImage(*image,argv[i+1],draw_info->fill,exception); |
| 3269 | if (tint_image == (Image *) NULL) |
| 3270 | break; |
| 3271 | *image=DestroyImage(*image); |
| 3272 | *image=tint_image; |
| 3273 | break; |
| 3274 | } |
| 3275 | if (LocaleCompare("transform",option+1) == 0) |
| 3276 | { |
| 3277 | Image |
| 3278 | *transform_image; |
| 3279 | |
| 3280 | /* |
| 3281 | Affine transform image. |
| 3282 | */ |
| 3283 | (void) SyncImageSettings(image_info,*image); |
| 3284 | transform_image=AffineTransformImage(*image,&draw_info->affine, |
| 3285 | exception); |
| 3286 | if (transform_image == (Image *) NULL) |
| 3287 | break; |
| 3288 | *image=DestroyImage(*image); |
| 3289 | *image=transform_image; |
| 3290 | break; |
| 3291 | } |
| 3292 | if (LocaleCompare("transparent",option+1) == 0) |
| 3293 | { |
| 3294 | MagickPixelPacket |
| 3295 | target; |
| 3296 | |
| 3297 | (void) SyncImageSettings(image_info,*image); |
| 3298 | (void) QueryMagickColor(argv[i+1],&target,exception); |
| 3299 | (void) TransparentPaintImage(*image,&target,(Quantum) |
| 3300 | TransparentOpacity,*option == '-' ? MagickFalse : MagickTrue); |
| 3301 | InheritException(exception,&(*image)->exception); |
| 3302 | break; |
| 3303 | } |
| 3304 | if (LocaleCompare("transpose",option+1) == 0) |
| 3305 | { |
| 3306 | Image |
| 3307 | *transpose_image; |
| 3308 | |
| 3309 | /* |
| 3310 | Transpose image scanlines. |
| 3311 | */ |
| 3312 | (void) SyncImageSettings(image_info,*image); |
| 3313 | transpose_image=TransposeImage(*image,exception); |
| 3314 | if (transpose_image == (Image *) NULL) |
| 3315 | break; |
| 3316 | *image=DestroyImage(*image); |
| 3317 | *image=transpose_image; |
| 3318 | break; |
| 3319 | } |
| 3320 | if (LocaleCompare("transverse",option+1) == 0) |
| 3321 | { |
| 3322 | Image |
| 3323 | *transverse_image; |
| 3324 | |
| 3325 | /* |
| 3326 | Transverse image scanlines. |
| 3327 | */ |
| 3328 | (void) SyncImageSettings(image_info,*image); |
| 3329 | transverse_image=TransverseImage(*image,exception); |
| 3330 | if (transverse_image == (Image *) NULL) |
| 3331 | break; |
| 3332 | *image=DestroyImage(*image); |
| 3333 | *image=transverse_image; |
| 3334 | break; |
| 3335 | } |
| 3336 | if (LocaleCompare("treedepth",option+1) == 0) |
| 3337 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 3338 | quantize_info->tree_depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3339 | break; |
| 3340 | } |
| 3341 | if (LocaleCompare("trim",option+1) == 0) |
| 3342 | { |
| 3343 | Image |
| 3344 | *trim_image; |
| 3345 | |
| 3346 | /* |
| 3347 | Trim image. |
| 3348 | */ |
| 3349 | (void) SyncImageSettings(image_info,*image); |
| 3350 | trim_image=TrimImage(*image,exception); |
| 3351 | if (trim_image == (Image *) NULL) |
| 3352 | break; |
| 3353 | *image=DestroyImage(*image); |
| 3354 | *image=trim_image; |
| 3355 | break; |
| 3356 | } |
| 3357 | if (LocaleCompare("type",option+1) == 0) |
| 3358 | { |
| 3359 | ImageType |
| 3360 | type; |
| 3361 | |
| 3362 | (void) SyncImageSettings(image_info,*image); |
| 3363 | if (*option == '+') |
| 3364 | type=UndefinedType; |
| 3365 | else |
| 3366 | type=(ImageType) ParseMagickOption(MagickTypeOptions,MagickFalse, |
| 3367 | argv[i+1]); |
| 3368 | (*image)->type=UndefinedType; |
| 3369 | (void) SetImageType(*image,type); |
| 3370 | InheritException(exception,&(*image)->exception); |
| 3371 | break; |
| 3372 | } |
| 3373 | break; |
| 3374 | } |
| 3375 | case 'u': |
| 3376 | { |
| 3377 | if (LocaleCompare("undercolor",option+1) == 0) |
| 3378 | { |
| 3379 | (void) QueryColorDatabase(argv[i+1],&draw_info->undercolor, |
| 3380 | exception); |
| 3381 | break; |
| 3382 | } |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3383 | if (LocaleCompare("unique",option+1) == 0) |
| 3384 | { |
| 3385 | if (*option == '+') |
| 3386 | { |
cristy | 83fae87 | 2010-04-22 15:04:16 +0000 | [diff] [blame] | 3387 | (void) DeleteImageArtifact(*image,"identify:unique-colors"); |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3388 | break; |
| 3389 | } |
cristy | 83fae87 | 2010-04-22 15:04:16 +0000 | [diff] [blame] | 3390 | (void) SetImageArtifact(*image,"identify:unique-colors","true"); |
cristy | 045bd90 | 2010-01-30 18:56:24 +0000 | [diff] [blame] | 3391 | break; |
| 3392 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3393 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 3394 | { |
| 3395 | Image |
| 3396 | *unique_image; |
| 3397 | |
| 3398 | /* |
| 3399 | Unique image colors. |
| 3400 | */ |
| 3401 | (void) SyncImageSettings(image_info,*image); |
| 3402 | unique_image=UniqueImageColors(*image,exception); |
| 3403 | if (unique_image == (Image *) NULL) |
| 3404 | break; |
| 3405 | *image=DestroyImage(*image); |
| 3406 | *image=unique_image; |
| 3407 | break; |
| 3408 | } |
| 3409 | if (LocaleCompare("unsharp",option+1) == 0) |
| 3410 | { |
| 3411 | Image |
| 3412 | *unsharp_image; |
| 3413 | |
| 3414 | /* |
| 3415 | Unsharp mask image. |
| 3416 | */ |
| 3417 | (void) SyncImageSettings(image_info,*image); |
| 3418 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3419 | if ((flags & SigmaValue) == 0) |
| 3420 | geometry_info.sigma=1.0; |
| 3421 | if ((flags & XiValue) == 0) |
| 3422 | geometry_info.xi=1.0; |
| 3423 | if ((flags & PsiValue) == 0) |
| 3424 | geometry_info.psi=0.05; |
| 3425 | unsharp_image=UnsharpMaskImageChannel(*image,channel, |
| 3426 | geometry_info.rho,geometry_info.sigma,geometry_info.xi, |
| 3427 | geometry_info.psi,exception); |
| 3428 | if (unsharp_image == (Image *) NULL) |
| 3429 | break; |
| 3430 | *image=DestroyImage(*image); |
| 3431 | *image=unsharp_image; |
| 3432 | break; |
| 3433 | } |
| 3434 | break; |
| 3435 | } |
| 3436 | case 'v': |
| 3437 | { |
| 3438 | if (LocaleCompare("verbose",option+1) == 0) |
| 3439 | { |
| 3440 | (void) SetImageArtifact(*image,option+1, |
| 3441 | *option == '+' ? "false" : "true"); |
| 3442 | break; |
| 3443 | } |
| 3444 | if (LocaleCompare("vignette",option+1) == 0) |
| 3445 | { |
| 3446 | Image |
| 3447 | *vignette_image; |
| 3448 | |
| 3449 | /* |
| 3450 | Vignette image. |
| 3451 | */ |
| 3452 | (void) SyncImageSettings(image_info,*image); |
| 3453 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3454 | if ((flags & SigmaValue) == 0) |
| 3455 | geometry_info.sigma=1.0; |
| 3456 | if ((flags & XiValue) == 0) |
| 3457 | geometry_info.xi=0.1*(*image)->columns; |
| 3458 | if ((flags & PsiValue) == 0) |
| 3459 | geometry_info.psi=0.1*(*image)->rows; |
| 3460 | vignette_image=VignetteImage(*image,geometry_info.rho, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3461 | geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) |
cristy | 0534a6b | 2010-03-18 01:19:38 +0000 | [diff] [blame] | 3462 | ceil(geometry_info.psi-0.5),exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3463 | if (vignette_image == (Image *) NULL) |
| 3464 | break; |
| 3465 | *image=DestroyImage(*image); |
| 3466 | *image=vignette_image; |
| 3467 | break; |
| 3468 | } |
| 3469 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 3470 | { |
| 3471 | if (*option == '+') |
| 3472 | { |
| 3473 | (void) SetImageVirtualPixelMethod(*image, |
| 3474 | UndefinedVirtualPixelMethod); |
| 3475 | break; |
| 3476 | } |
| 3477 | (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) |
| 3478 | ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 3479 | argv[i+1])); |
| 3480 | break; |
| 3481 | } |
| 3482 | break; |
| 3483 | } |
| 3484 | case 'w': |
| 3485 | { |
| 3486 | if (LocaleCompare("wave",option+1) == 0) |
| 3487 | { |
| 3488 | Image |
| 3489 | *wave_image; |
| 3490 | |
| 3491 | /* |
| 3492 | Wave image. |
| 3493 | */ |
| 3494 | (void) SyncImageSettings(image_info,*image); |
| 3495 | flags=ParseGeometry(argv[i+1],&geometry_info); |
| 3496 | if ((flags & SigmaValue) == 0) |
| 3497 | geometry_info.sigma=1.0; |
| 3498 | wave_image=WaveImage(*image,geometry_info.rho,geometry_info.sigma, |
| 3499 | exception); |
| 3500 | if (wave_image == (Image *) NULL) |
| 3501 | break; |
| 3502 | *image=DestroyImage(*image); |
| 3503 | *image=wave_image; |
| 3504 | break; |
| 3505 | } |
| 3506 | if (LocaleCompare("weight",option+1) == 0) |
| 3507 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 3508 | draw_info->weight=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3509 | if (LocaleCompare(argv[i+1],"all") == 0) |
| 3510 | draw_info->weight=0; |
| 3511 | if (LocaleCompare(argv[i+1],"bold") == 0) |
| 3512 | draw_info->weight=700; |
| 3513 | if (LocaleCompare(argv[i+1],"bolder") == 0) |
| 3514 | if (draw_info->weight <= 800) |
| 3515 | draw_info->weight+=100; |
| 3516 | if (LocaleCompare(argv[i+1],"lighter") == 0) |
| 3517 | if (draw_info->weight >= 100) |
| 3518 | draw_info->weight-=100; |
| 3519 | if (LocaleCompare(argv[i+1],"normal") == 0) |
| 3520 | draw_info->weight=400; |
| 3521 | break; |
| 3522 | } |
| 3523 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 3524 | { |
| 3525 | /* |
| 3526 | White threshold image. |
| 3527 | */ |
| 3528 | (void) SyncImageSettings(image_info,*image); |
| 3529 | (void) WhiteThresholdImageChannel(*image,channel,argv[i+1], |
| 3530 | exception); |
| 3531 | InheritException(exception,&(*image)->exception); |
| 3532 | break; |
| 3533 | } |
| 3534 | break; |
| 3535 | } |
| 3536 | default: |
| 3537 | break; |
| 3538 | } |
| 3539 | i+=count; |
| 3540 | } |
| 3541 | if (region_image != (Image *) NULL) |
| 3542 | { |
| 3543 | /* |
| 3544 | Composite transformed region onto image. |
| 3545 | */ |
| 3546 | (void) SyncImageSettings(image_info,*image); |
| 3547 | (void) CompositeImage(region_image,(*image)->matte != MagickFalse ? |
| 3548 | OverCompositeOp : CopyCompositeOp,*image,region_geometry.x, |
| 3549 | region_geometry.y); |
| 3550 | InheritException(exception,®ion_image->exception); |
| 3551 | *image=DestroyImage(*image); |
| 3552 | *image=region_image; |
| 3553 | } |
| 3554 | /* |
| 3555 | Free resources. |
| 3556 | */ |
| 3557 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 3558 | draw_info=DestroyDrawInfo(draw_info); |
| 3559 | status=(*image)->exception.severity == UndefinedException ? |
| 3560 | MagickTrue : MagickFalse; |
| 3561 | return(status); |
| 3562 | } |
| 3563 | |
| 3564 | /* |
| 3565 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3566 | % % |
| 3567 | % % |
| 3568 | % % |
| 3569 | % M o g r i f y I m a g e C o m m a n d % |
| 3570 | % % |
| 3571 | % % |
| 3572 | % % |
| 3573 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3574 | % |
| 3575 | % MogrifyImageCommand() transforms an image or a sequence of images. These |
| 3576 | % transforms include image scaling, image rotation, color reduction, and |
| 3577 | % others. The transmogrified image overwrites the original image. |
| 3578 | % |
| 3579 | % The format of the MogrifyImageCommand method is: |
| 3580 | % |
| 3581 | % MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, |
| 3582 | % const char **argv,char **metadata,ExceptionInfo *exception) |
| 3583 | % |
| 3584 | % A description of each parameter follows: |
| 3585 | % |
| 3586 | % o image_info: the image info. |
| 3587 | % |
| 3588 | % o argc: the number of elements in the argument vector. |
| 3589 | % |
| 3590 | % o argv: A text array containing the command line arguments. |
| 3591 | % |
| 3592 | % o metadata: any metadata is returned here. |
| 3593 | % |
| 3594 | % o exception: return any errors or warnings in this structure. |
| 3595 | % |
| 3596 | */ |
| 3597 | |
| 3598 | static MagickBooleanType MogrifyUsage(void) |
| 3599 | { |
| 3600 | static const char |
| 3601 | *miscellaneous[]= |
| 3602 | { |
| 3603 | "-debug events display copious debugging information", |
| 3604 | "-help print program options", |
| 3605 | "-list type print a list of supported option arguments", |
| 3606 | "-log format format of debugging information", |
| 3607 | "-version print version information", |
| 3608 | (char *) NULL |
| 3609 | }, |
| 3610 | *operators[]= |
| 3611 | { |
| 3612 | "-adaptive-blur geometry", |
| 3613 | " adaptively blur pixels; decrease effect near edges", |
| 3614 | "-adaptive-resize geometry", |
| 3615 | " adaptively resize image using 'mesh' interpolation", |
| 3616 | "-adaptive-sharpen geometry", |
| 3617 | " adaptively sharpen pixels; increase effect near edges", |
| 3618 | "-alpha option on, activate, off, deactivate, set, opaque, copy", |
| 3619 | " transparent, extract, background, or shape", |
| 3620 | "-annotate geometry text", |
| 3621 | " annotate the image with text", |
| 3622 | "-auto-gamma automagically adjust gamma level of image", |
| 3623 | "-auto-level automagically adjust color levels of image", |
| 3624 | "-auto-orient automagically orient (rotate) image", |
| 3625 | "-bench iterations measure performance", |
| 3626 | "-black-threshold value", |
| 3627 | " force all pixels below the threshold into black", |
| 3628 | "-blue-shift simulate a scene at nighttime in the moonlight", |
| 3629 | "-blur geometry reduce image noise and reduce detail levels", |
| 3630 | "-border geometry surround image with a border of color", |
| 3631 | "-bordercolor color border color", |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 3632 | "-brightness-contrast geometry", |
| 3633 | " improve brightness / contrast of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3634 | "-cdl filename color correct with a color decision list", |
| 3635 | "-charcoal radius simulate a charcoal drawing", |
| 3636 | "-chop geometry remove pixels from the image interior", |
cristy | ecb0c6d | 2009-09-25 16:50:09 +0000 | [diff] [blame] | 3637 | "-clamp restrict pixel range from 0 to the quantum depth", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3638 | "-clip clip along the first path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3639 | "-clip-mask filename associate a clip mask with the image", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3640 | "-clip-path id clip along a named path from the 8BIM profile", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3641 | "-colorize value colorize the image with the fill color", |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 3642 | "-color-matrix matrix apply color correction to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3643 | "-contrast enhance or reduce the image contrast", |
| 3644 | "-contrast-stretch geometry", |
| 3645 | " improve contrast by `stretching' the intensity range", |
| 3646 | "-convolve coefficients", |
| 3647 | " apply a convolution kernel to the image", |
| 3648 | "-cycle amount cycle the image colormap", |
| 3649 | "-decipher filename convert cipher pixels to plain pixels", |
| 3650 | "-deskew threshold straighten an image", |
| 3651 | "-despeckle reduce the speckles within an image", |
| 3652 | "-distort method args", |
| 3653 | " distort images according to given method ad args", |
| 3654 | "-draw string annotate the image with a graphic primitive", |
| 3655 | "-edge radius apply a filter to detect edges in the image", |
| 3656 | "-encipher filename convert plain pixels to cipher pixels", |
| 3657 | "-emboss radius emboss an image", |
| 3658 | "-enhance apply a digital filter to enhance a noisy image", |
| 3659 | "-equalize perform histogram equalization to an image", |
| 3660 | "-evaluate operator value", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3661 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3662 | "-extent geometry set the image size", |
| 3663 | "-extract geometry extract area from image", |
| 3664 | "-fft implements the discrete Fourier transform (DFT)", |
| 3665 | "-flip flip image vertically", |
| 3666 | "-floodfill geometry color", |
| 3667 | " floodfill the image with color", |
| 3668 | "-flop flop image horizontally", |
| 3669 | "-frame geometry surround image with an ornamental border", |
cristy | c2b730e | 2009-11-24 14:32:09 +0000 | [diff] [blame] | 3670 | "-function name parameters", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3671 | " apply function over image values", |
| 3672 | "-gamma value level of gamma correction", |
| 3673 | "-gaussian-blur geometry", |
| 3674 | " reduce image noise and reduce detail levels", |
cristy | 901f09d | 2009-10-16 22:56:10 +0000 | [diff] [blame] | 3675 | "-geometry geometry preferred size or location of the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3676 | "-identify identify the format and characteristics of the image", |
| 3677 | "-ift implements the inverse discrete Fourier transform (DFT)", |
| 3678 | "-implode amount implode image pixels about the center", |
| 3679 | "-lat geometry local adaptive thresholding", |
| 3680 | "-layers method optimize, merge, or compare image layers", |
| 3681 | "-level value adjust the level of image contrast", |
| 3682 | "-level-colors color,color", |
cristy | ee0f8d7 | 2009-09-19 00:58:29 +0000 | [diff] [blame] | 3683 | " level image with the given colors", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3684 | "-linear-stretch geometry", |
| 3685 | " improve contrast by `stretching with saturation'", |
| 3686 | "-liquid-rescale geometry", |
| 3687 | " rescale image with seam-carving", |
| 3688 | "-median radius apply a median filter to the image", |
| 3689 | "-modulate value vary the brightness, saturation, and hue", |
| 3690 | "-monochrome transform image to black and white", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3691 | "-morphology method kernel", |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 3692 | " apply a morphology method to the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3693 | "-motion-blur geometry", |
| 3694 | " simulate motion blur", |
| 3695 | "-negate replace every pixel with its complementary color ", |
| 3696 | "-noise radius add or reduce noise in an image", |
| 3697 | "-normalize transform image to span the full range of colors", |
| 3698 | "-opaque color change this color to the fill color", |
| 3699 | "-ordered-dither NxN", |
| 3700 | " add a noise pattern to the image with specific", |
| 3701 | " amplitudes", |
| 3702 | "-paint radius simulate an oil painting", |
| 3703 | "-polaroid angle simulate a Polaroid picture", |
| 3704 | "-posterize levels reduce the image to a limited number of color levels", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3705 | "-profile filename add, delete, or apply an image profile", |
| 3706 | "-quantize colorspace reduce colors in this colorspace", |
| 3707 | "-radial-blur angle radial blur the image", |
| 3708 | "-raise value lighten/darken image edges to create a 3-D effect", |
| 3709 | "-random-threshold low,high", |
| 3710 | " random threshold the image", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3711 | "-region geometry apply options to a portion of the image", |
| 3712 | "-render render vector graphics", |
| 3713 | "-repage geometry size and location of an image canvas", |
| 3714 | "-resample geometry change the resolution of an image", |
| 3715 | "-resize geometry resize the image", |
| 3716 | "-roll geometry roll an image vertically or horizontally", |
| 3717 | "-rotate degrees apply Paeth rotation to the image", |
| 3718 | "-sample geometry scale image with pixel sampling", |
| 3719 | "-scale geometry scale the image", |
| 3720 | "-segment values segment an image", |
| 3721 | "-selective-blur geometry", |
| 3722 | " selectively blur pixels within a contrast threshold", |
| 3723 | "-sepia-tone threshold", |
| 3724 | " simulate a sepia-toned photo", |
| 3725 | "-set property value set an image property", |
| 3726 | "-shade degrees shade the image using a distant light source", |
| 3727 | "-shadow geometry simulate an image shadow", |
| 3728 | "-sharpen geometry sharpen the image", |
| 3729 | "-shave geometry shave pixels from the image edges", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3730 | "-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] | 3731 | "-sigmoidal-contrast geometry", |
| 3732 | " increase the contrast without saturating highlights or shadows", |
| 3733 | "-sketch geometry simulate a pencil sketch", |
| 3734 | "-solarize threshold negate all pixels above the threshold level", |
| 3735 | "-sparse-color method args", |
| 3736 | " fill in a image based on a few color points", |
| 3737 | "-splice geometry splice the background color into the image", |
| 3738 | "-spread radius displace image pixels by a random amount", |
| 3739 | "-strip strip image of all profiles and comments", |
| 3740 | "-swirl degrees swirl image pixels about the center", |
| 3741 | "-threshold value threshold the image", |
| 3742 | "-thumbnail geometry create a thumbnail of the image", |
| 3743 | "-tile filename tile image when filling a graphic primitive", |
| 3744 | "-tint value tint the image with the fill color", |
| 3745 | "-transform affine transform image", |
| 3746 | "-transparent color make this color transparent within the image", |
| 3747 | "-transpose flip image vertically and rotate 90 degrees", |
| 3748 | "-transverse flop image horizontally and rotate 270 degrees", |
| 3749 | "-trim trim image edges", |
| 3750 | "-type type image type", |
| 3751 | "-unique-colors discard all but one of any pixel color", |
| 3752 | "-unsharp geometry sharpen the image", |
| 3753 | "-vignette geometry soften the edges of the image in vignette style", |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 3754 | "-wave geometry alter an image along a sine wave", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3755 | "-white-threshold value", |
| 3756 | " force all pixels above the threshold into white", |
| 3757 | (char *) NULL |
| 3758 | }, |
| 3759 | *sequence_operators[]= |
| 3760 | { |
| 3761 | "-append append an image sequence", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3762 | "-clut apply a color lookup table to the image", |
| 3763 | "-coalesce merge a sequence of images", |
| 3764 | "-combine combine a sequence of images", |
| 3765 | "-composite composite image", |
| 3766 | "-crop geometry cut out a rectangular region of the image", |
| 3767 | "-deconstruct break down an image sequence into constituent parts", |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 3768 | "-evaluate-sequence operator", |
| 3769 | " evaluate an arithmetic, relational, or logical expression", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3770 | "-flatten flatten a sequence of images", |
| 3771 | "-fx expression apply mathematical expression to an image channel(s)", |
| 3772 | "-hald-clut apply a Hald color lookup table to the image", |
| 3773 | "-morph value morph an image sequence", |
| 3774 | "-mosaic create a mosaic from an image sequence", |
cristy | 36b9482 | 2010-05-20 12:48:16 +0000 | [diff] [blame] | 3775 | "-print string interpret string and print to console", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3776 | "-process arguments process the image with a custom image filter", |
| 3777 | "-reverse reverse image sequence", |
| 3778 | "-separate separate an image channel into a grayscale image", |
| 3779 | "-write filename write images to this file", |
| 3780 | (char *) NULL |
| 3781 | }, |
| 3782 | *settings[]= |
| 3783 | { |
| 3784 | "-adjoin join images into a single multi-image file", |
| 3785 | "-affine matrix affine transform matrix", |
| 3786 | "-alpha option activate, deactivate, reset, or set the alpha channel", |
| 3787 | "-antialias remove pixel-aliasing", |
| 3788 | "-authenticate password", |
| 3789 | " decipher image with this password", |
| 3790 | "-attenuate value lessen (or intensify) when adding noise to an image", |
| 3791 | "-background color background color", |
| 3792 | "-bias value add bias when convolving an image", |
| 3793 | "-black-point-compensation", |
| 3794 | " use black point compensation", |
| 3795 | "-blue-primary point chromaticity blue primary point", |
| 3796 | "-bordercolor color border color", |
| 3797 | "-caption string assign a caption to an image", |
| 3798 | "-channel type apply option to select image channels", |
| 3799 | "-colors value preferred number of colors in the image", |
| 3800 | "-colorspace type alternate image colorspace", |
| 3801 | "-comment string annotate image with comment", |
| 3802 | "-compose operator set image composite operator", |
| 3803 | "-compress type type of pixel compression when writing the image", |
| 3804 | "-define format:option", |
| 3805 | " define one or more image format options", |
| 3806 | "-delay value display the next image after pausing", |
| 3807 | "-density geometry horizontal and vertical density of the image", |
| 3808 | "-depth value image depth", |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 3809 | "-direction type render text right-to-left or left-to-right", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3810 | "-display server get image or font from this X server", |
| 3811 | "-dispose method layer disposal method", |
| 3812 | "-dither method apply error diffusion to image", |
| 3813 | "-encoding type text encoding type", |
| 3814 | "-endian type endianness (MSB or LSB) of the image", |
| 3815 | "-family name render text with this font family", |
| 3816 | "-fill color color to use when filling a graphic primitive", |
| 3817 | "-filter type use this filter when resizing an image", |
| 3818 | "-font name render text with this font", |
| 3819 | "-format \"string\" output formatted image characteristics", |
| 3820 | "-fuzz distance colors within this distance are considered equal", |
| 3821 | "-gravity type horizontal and vertical text placement", |
| 3822 | "-green-primary point chromaticity green primary point", |
| 3823 | "-intent type type of rendering intent when managing the image color", |
| 3824 | "-interlace type type of image interlacing scheme", |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 3825 | "-interline-spacing value", |
| 3826 | " set the space between two text lines", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3827 | "-interpolate method pixel color interpolation method", |
| 3828 | "-interword-spacing value", |
| 3829 | " set the space between two words", |
| 3830 | "-kerning value set the space between two letters", |
| 3831 | "-label string assign a label to an image", |
| 3832 | "-limit type value pixel cache resource limit", |
| 3833 | "-loop iterations add Netscape loop extension to your GIF animation", |
| 3834 | "-mask filename associate a mask with the image", |
| 3835 | "-mattecolor color frame color", |
| 3836 | "-monitor monitor progress", |
| 3837 | "-orient type image orientation", |
| 3838 | "-page geometry size and location of an image canvas (setting)", |
| 3839 | "-ping efficiently determine image attributes", |
| 3840 | "-pointsize value font point size", |
cristy | 7c1b9fd | 2010-02-02 14:36:00 +0000 | [diff] [blame] | 3841 | "-precision value maximum number of significant digits to print", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3842 | "-preview type image preview type", |
| 3843 | "-quality value JPEG/MIFF/PNG compression level", |
| 3844 | "-quiet suppress all warning messages", |
| 3845 | "-red-primary point chromaticity red primary point", |
| 3846 | "-regard-warnings pay attention to warning messages", |
| 3847 | "-remap filename transform image colors to match this set of colors", |
| 3848 | "-respect-parentheses settings remain in effect until parenthesis boundary", |
| 3849 | "-sampling-factor geometry", |
| 3850 | " horizontal and vertical sampling factor", |
| 3851 | "-scene value image scene number", |
| 3852 | "-seed value seed a new sequence of pseudo-random numbers", |
| 3853 | "-size geometry width and height of image", |
| 3854 | "-stretch type render text with this font stretch", |
| 3855 | "-stroke color graphic primitive stroke color", |
| 3856 | "-strokewidth value graphic primitive stroke width", |
| 3857 | "-style type render text with this font style", |
| 3858 | "-taint image as ineligible for bi-modal delegate", |
| 3859 | "-texture filename name of texture to tile onto the image background", |
| 3860 | "-tile-offset geometry", |
| 3861 | " tile offset", |
| 3862 | "-treedepth value color tree depth", |
| 3863 | "-transparent-color color", |
| 3864 | " transparent color", |
| 3865 | "-undercolor color annotation bounding box color", |
| 3866 | "-units type the units of image resolution", |
| 3867 | "-verbose print detailed information about the image", |
| 3868 | "-view FlashPix viewing transforms", |
| 3869 | "-virtual-pixel method", |
| 3870 | " virtual pixel access method", |
| 3871 | "-weight type render text with this font weight", |
| 3872 | "-white-point point chromaticity white point", |
| 3873 | (char *) NULL |
| 3874 | }, |
| 3875 | *stack_operators[]= |
| 3876 | { |
| 3877 | "-clone index clone an image", |
| 3878 | "-delete index delete the image from the image sequence", |
| 3879 | "-insert index insert last image into the image sequence", |
| 3880 | "-swap indexes swap two images in the image sequence", |
| 3881 | (char *) NULL |
| 3882 | }; |
| 3883 | |
| 3884 | const char |
| 3885 | **p; |
| 3886 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3887 | (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3888 | (void) printf("Copyright: %s\n",GetMagickCopyright()); |
| 3889 | (void) printf("Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3890 | (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", |
| 3891 | GetClientName()); |
| 3892 | (void) printf("\nImage Settings:\n"); |
| 3893 | for (p=settings; *p != (char *) NULL; p++) |
| 3894 | (void) printf(" %s\n",*p); |
| 3895 | (void) printf("\nImage Operators:\n"); |
| 3896 | for (p=operators; *p != (char *) NULL; p++) |
| 3897 | (void) printf(" %s\n",*p); |
| 3898 | (void) printf("\nImage Sequence Operators:\n"); |
| 3899 | for (p=sequence_operators; *p != (char *) NULL; p++) |
| 3900 | (void) printf(" %s\n",*p); |
| 3901 | (void) printf("\nImage Stack Operators:\n"); |
| 3902 | for (p=stack_operators; *p != (char *) NULL; p++) |
| 3903 | (void) printf(" %s\n",*p); |
| 3904 | (void) printf("\nMiscellaneous Options:\n"); |
| 3905 | for (p=miscellaneous; *p != (char *) NULL; p++) |
| 3906 | (void) printf(" %s\n",*p); |
| 3907 | (void) printf( |
| 3908 | "\nBy default, the image format of `file' is determined by its magic\n"); |
| 3909 | (void) printf( |
| 3910 | "number. To specify a particular image format, precede the filename\n"); |
| 3911 | (void) printf( |
| 3912 | "with an image format name and a colon (i.e. ps:image) or specify the\n"); |
| 3913 | (void) printf( |
| 3914 | "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); |
| 3915 | (void) printf("'-' for standard input or output.\n"); |
| 3916 | return(MagickFalse); |
| 3917 | } |
| 3918 | |
| 3919 | WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, |
| 3920 | int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) |
| 3921 | { |
| 3922 | #define DestroyMogrify() \ |
| 3923 | { \ |
| 3924 | if (format != (char *) NULL) \ |
| 3925 | format=DestroyString(format); \ |
| 3926 | if (path != (char *) NULL) \ |
| 3927 | path=DestroyString(path); \ |
| 3928 | DestroyImageStack(); \ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3929 | for (i=0; i < (ssize_t) argc; i++) \ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3930 | argv[i]=DestroyString(argv[i]); \ |
| 3931 | argv=(char **) RelinquishMagickMemory(argv); \ |
| 3932 | } |
| 3933 | #define ThrowMogrifyException(asperity,tag,option) \ |
| 3934 | { \ |
| 3935 | (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ |
| 3936 | option); \ |
| 3937 | DestroyMogrify(); \ |
| 3938 | return(MagickFalse); \ |
| 3939 | } |
| 3940 | #define ThrowMogrifyInvalidArgumentException(option,argument) \ |
| 3941 | { \ |
| 3942 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ |
| 3943 | "InvalidArgument","`%s': %s",argument,option); \ |
| 3944 | DestroyMogrify(); \ |
| 3945 | return(MagickFalse); \ |
| 3946 | } |
| 3947 | |
| 3948 | char |
| 3949 | *format, |
| 3950 | *option, |
| 3951 | *path; |
| 3952 | |
| 3953 | Image |
| 3954 | *image; |
| 3955 | |
| 3956 | ImageStack |
| 3957 | image_stack[MaxImageStackDepth+1]; |
| 3958 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3959 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3960 | j, |
| 3961 | k; |
| 3962 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3963 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3964 | i; |
| 3965 | |
| 3966 | MagickBooleanType |
| 3967 | global_colormap; |
| 3968 | |
| 3969 | MagickBooleanType |
| 3970 | fire, |
| 3971 | pend; |
| 3972 | |
| 3973 | MagickStatusType |
| 3974 | status; |
| 3975 | |
| 3976 | /* |
| 3977 | Set defaults. |
| 3978 | */ |
| 3979 | assert(image_info != (ImageInfo *) NULL); |
| 3980 | assert(image_info->signature == MagickSignature); |
| 3981 | if (image_info->debug != MagickFalse) |
| 3982 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 3983 | assert(exception != (ExceptionInfo *) NULL); |
| 3984 | if (argc == 2) |
| 3985 | { |
| 3986 | option=argv[1]; |
| 3987 | if ((LocaleCompare("version",option+1) == 0) || |
| 3988 | (LocaleCompare("-version",option+1) == 0)) |
| 3989 | { |
| 3990 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 3991 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 3992 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 3993 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3994 | return(MagickFalse); |
| 3995 | } |
| 3996 | } |
| 3997 | if (argc < 2) |
cristy | 13e61a1 | 2010-02-04 20:19:00 +0000 | [diff] [blame] | 3998 | return(MogrifyUsage()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 3999 | format=(char *) NULL; |
| 4000 | path=(char *) NULL; |
| 4001 | global_colormap=MagickFalse; |
| 4002 | k=0; |
| 4003 | j=1; |
| 4004 | NewImageStack(); |
| 4005 | option=(char *) NULL; |
| 4006 | pend=MagickFalse; |
| 4007 | status=MagickTrue; |
| 4008 | /* |
| 4009 | Parse command line. |
| 4010 | */ |
| 4011 | ReadCommandlLine(argc,&argv); |
| 4012 | status=ExpandFilenames(&argc,&argv); |
| 4013 | if (status == MagickFalse) |
| 4014 | ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", |
| 4015 | GetExceptionMessage(errno)); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4016 | for (i=1; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4017 | { |
| 4018 | option=argv[i]; |
| 4019 | if (LocaleCompare(option,"(") == 0) |
| 4020 | { |
| 4021 | FireImageStack(MagickFalse,MagickTrue,pend); |
| 4022 | if (k == MaxImageStackDepth) |
| 4023 | ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", |
| 4024 | option); |
| 4025 | PushImageStack(); |
| 4026 | continue; |
| 4027 | } |
| 4028 | if (LocaleCompare(option,")") == 0) |
| 4029 | { |
| 4030 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 4031 | if (k == 0) |
| 4032 | ThrowMogrifyException(OptionError,"UnableToParseExpression",option); |
| 4033 | PopImageStack(); |
| 4034 | continue; |
| 4035 | } |
| 4036 | if (IsMagickOption(option) == MagickFalse) |
| 4037 | { |
| 4038 | char |
| 4039 | backup_filename[MaxTextExtent], |
| 4040 | *filename; |
| 4041 | |
| 4042 | Image |
| 4043 | *images; |
| 4044 | |
| 4045 | /* |
| 4046 | Option is a file name: begin by reading image from specified file. |
| 4047 | */ |
| 4048 | FireImageStack(MagickFalse,MagickFalse,pend); |
| 4049 | filename=argv[i]; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 4050 | if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4051 | filename=argv[++i]; |
| 4052 | (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); |
| 4053 | images=ReadImages(image_info,exception); |
| 4054 | status&=(images != (Image *) NULL) && |
| 4055 | (exception->severity < ErrorException); |
| 4056 | if (images == (Image *) NULL) |
| 4057 | continue; |
| 4058 | if (path != (char *) NULL) |
| 4059 | { |
| 4060 | GetPathComponent(option,TailPath,filename); |
| 4061 | (void) FormatMagickString(images->filename,MaxTextExtent,"%s%c%s", |
| 4062 | path,*DirectorySeparator,filename); |
| 4063 | } |
| 4064 | if (format != (char *) NULL) |
cristy | 212e262 | 2010-06-12 19:07:47 +0000 | [diff] [blame] | 4065 | { |
| 4066 | (void) CopyMagickString(images->filename,images->magick_filename, |
| 4067 | MaxTextExtent); |
| 4068 | AppendImageFormat(format,images->filename); |
| 4069 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4070 | AppendImageStack(images); |
| 4071 | FinalizeImageSettings(image_info,image,MagickFalse); |
| 4072 | if (global_colormap != MagickFalse) |
| 4073 | { |
| 4074 | QuantizeInfo |
| 4075 | *quantize_info; |
| 4076 | |
| 4077 | quantize_info=AcquireQuantizeInfo(image_info); |
| 4078 | (void) RemapImages(quantize_info,images,(Image *) NULL); |
| 4079 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 4080 | } |
| 4081 | *backup_filename='\0'; |
| 4082 | if ((LocaleCompare(image->filename,"-") != 0) && |
| 4083 | (IsPathWritable(image->filename) != MagickFalse)) |
| 4084 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4085 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4086 | i; |
| 4087 | |
| 4088 | /* |
| 4089 | Rename image file as backup. |
| 4090 | */ |
| 4091 | (void) CopyMagickString(backup_filename,image->filename, |
| 4092 | MaxTextExtent); |
| 4093 | for (i=0; i < 6; i++) |
| 4094 | { |
| 4095 | (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); |
| 4096 | if (IsPathAccessible(backup_filename) == MagickFalse) |
| 4097 | break; |
| 4098 | } |
| 4099 | if ((IsPathAccessible(backup_filename) != MagickFalse) || |
| 4100 | (rename(image->filename,backup_filename) != 0)) |
| 4101 | *backup_filename='\0'; |
| 4102 | } |
| 4103 | /* |
| 4104 | Write transmogrified image to disk. |
| 4105 | */ |
| 4106 | image_info->synchronize=MagickTrue; |
| 4107 | status&=WriteImages(image_info,image,image->filename,exception); |
| 4108 | if ((status == MagickFalse) && (*backup_filename != '\0')) |
| 4109 | (void) remove(backup_filename); |
| 4110 | RemoveAllImageStack(); |
| 4111 | continue; |
| 4112 | } |
| 4113 | pend=image != (Image *) NULL ? MagickTrue : MagickFalse; |
| 4114 | switch (*(option+1)) |
| 4115 | { |
| 4116 | case 'a': |
| 4117 | { |
| 4118 | if (LocaleCompare("adaptive-blur",option+1) == 0) |
| 4119 | { |
| 4120 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4121 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4122 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4123 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4124 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4125 | break; |
| 4126 | } |
| 4127 | if (LocaleCompare("adaptive-resize",option+1) == 0) |
| 4128 | { |
| 4129 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4130 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4131 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4132 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4133 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4134 | break; |
| 4135 | } |
| 4136 | if (LocaleCompare("adaptive-sharpen",option+1) == 0) |
| 4137 | { |
| 4138 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4139 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4140 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4141 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4142 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4143 | break; |
| 4144 | } |
| 4145 | if (LocaleCompare("affine",option+1) == 0) |
| 4146 | { |
| 4147 | if (*option == '+') |
| 4148 | break; |
| 4149 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4150 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4151 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4152 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4153 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4154 | break; |
| 4155 | } |
| 4156 | if (LocaleCompare("alpha",option+1) == 0) |
| 4157 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4158 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4159 | type; |
| 4160 | |
| 4161 | if (*option == '+') |
| 4162 | break; |
| 4163 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4164 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4165 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4166 | type=ParseMagickOption(MagickAlphaOptions,MagickFalse,argv[i]); |
| 4167 | if (type < 0) |
| 4168 | ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelType", |
| 4169 | argv[i]); |
| 4170 | break; |
| 4171 | } |
| 4172 | if (LocaleCompare("annotate",option+1) == 0) |
| 4173 | { |
| 4174 | if (*option == '+') |
| 4175 | break; |
| 4176 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4177 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4178 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4179 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4180 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4181 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4182 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4183 | i++; |
| 4184 | break; |
| 4185 | } |
| 4186 | if (LocaleCompare("antialias",option+1) == 0) |
| 4187 | break; |
| 4188 | if (LocaleCompare("append",option+1) == 0) |
| 4189 | break; |
| 4190 | if (LocaleCompare("attenuate",option+1) == 0) |
| 4191 | { |
| 4192 | if (*option == '+') |
| 4193 | break; |
| 4194 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4195 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4196 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4197 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4198 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4199 | break; |
| 4200 | } |
| 4201 | if (LocaleCompare("authenticate",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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4207 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4208 | break; |
| 4209 | } |
| 4210 | if (LocaleCompare("auto-gamma",option+1) == 0) |
| 4211 | break; |
| 4212 | if (LocaleCompare("auto-level",option+1) == 0) |
| 4213 | break; |
| 4214 | if (LocaleCompare("auto-orient",option+1) == 0) |
| 4215 | break; |
| 4216 | if (LocaleCompare("average",option+1) == 0) |
| 4217 | break; |
| 4218 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4219 | } |
| 4220 | case 'b': |
| 4221 | { |
| 4222 | if (LocaleCompare("background",option+1) == 0) |
| 4223 | { |
| 4224 | if (*option == '+') |
| 4225 | break; |
| 4226 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4227 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4228 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4229 | break; |
| 4230 | } |
| 4231 | if (LocaleCompare("bias",option+1) == 0) |
| 4232 | { |
| 4233 | if (*option == '+') |
| 4234 | break; |
| 4235 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4236 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4237 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4238 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4239 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4240 | break; |
| 4241 | } |
| 4242 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 4243 | break; |
| 4244 | if (LocaleCompare("black-threshold",option+1) == 0) |
| 4245 | { |
| 4246 | if (*option == '+') |
| 4247 | break; |
| 4248 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4249 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4250 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4251 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4252 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4253 | break; |
| 4254 | } |
| 4255 | if (LocaleCompare("blue-primary",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-shift",option+1) == 0) |
| 4267 | { |
| 4268 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4269 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4270 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4271 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4272 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4273 | break; |
| 4274 | } |
| 4275 | if (LocaleCompare("blur",option+1) == 0) |
| 4276 | { |
| 4277 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4278 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4279 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4280 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4281 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4282 | break; |
| 4283 | } |
| 4284 | if (LocaleCompare("border",option+1) == 0) |
| 4285 | { |
| 4286 | if (*option == '+') |
| 4287 | break; |
| 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("bordercolor",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 | break; |
| 4303 | } |
| 4304 | if (LocaleCompare("box",option+1) == 0) |
| 4305 | { |
| 4306 | if (*option == '+') |
| 4307 | break; |
| 4308 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4309 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4310 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4311 | break; |
| 4312 | } |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 4313 | if (LocaleCompare("brightness-contrast",option+1) == 0) |
| 4314 | { |
| 4315 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4316 | if (i == (ssize_t) argc) |
cristy | a28d6b8 | 2010-01-11 20:03:47 +0000 | [diff] [blame] | 4317 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4318 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4319 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4320 | break; |
| 4321 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4322 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 4323 | } |
| 4324 | case 'c': |
| 4325 | { |
| 4326 | if (LocaleCompare("cache",option+1) == 0) |
| 4327 | { |
| 4328 | if (*option == '+') |
| 4329 | break; |
| 4330 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4331 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4332 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4333 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4334 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4335 | break; |
| 4336 | } |
| 4337 | if (LocaleCompare("caption",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 | break; |
| 4345 | } |
| 4346 | if (LocaleCompare("channel",option+1) == 0) |
| 4347 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4348 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4349 | channel; |
| 4350 | |
| 4351 | if (*option == '+') |
| 4352 | break; |
| 4353 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4354 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4355 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4356 | channel=ParseChannelOption(argv[i]); |
| 4357 | if (channel < 0) |
| 4358 | ThrowMogrifyException(OptionError,"UnrecognizedChannelType", |
| 4359 | argv[i]); |
| 4360 | break; |
| 4361 | } |
| 4362 | if (LocaleCompare("cdl",option+1) == 0) |
| 4363 | { |
| 4364 | if (*option == '+') |
| 4365 | break; |
| 4366 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4367 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4368 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4369 | break; |
| 4370 | } |
| 4371 | if (LocaleCompare("charcoal",option+1) == 0) |
| 4372 | { |
| 4373 | if (*option == '+') |
| 4374 | break; |
| 4375 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4376 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4377 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4378 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4379 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4380 | break; |
| 4381 | } |
| 4382 | if (LocaleCompare("chop",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 | } |
cristy | 1eb45dd | 2009-09-25 16:38:06 +0000 | [diff] [blame] | 4393 | if (LocaleCompare("clamp",option+1) == 0) |
| 4394 | break; |
| 4395 | if (LocaleCompare("clip",option+1) == 0) |
| 4396 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4397 | if (LocaleCompare("clip-mask",option+1) == 0) |
| 4398 | { |
| 4399 | if (*option == '+') |
| 4400 | break; |
| 4401 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4402 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4403 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4404 | break; |
| 4405 | } |
| 4406 | if (LocaleCompare("clut",option+1) == 0) |
| 4407 | break; |
| 4408 | if (LocaleCompare("coalesce",option+1) == 0) |
| 4409 | break; |
| 4410 | if (LocaleCompare("colorize",option+1) == 0) |
| 4411 | { |
| 4412 | if (*option == '+') |
| 4413 | break; |
| 4414 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4415 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4416 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4417 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4418 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4419 | break; |
| 4420 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4421 | if (LocaleCompare("color-matrix",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-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 4427 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4428 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4429 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4430 | break; |
| 4431 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4432 | if (LocaleCompare("colors",option+1) == 0) |
| 4433 | { |
| 4434 | if (*option == '+') |
| 4435 | break; |
| 4436 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4437 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4438 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4439 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4440 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4441 | break; |
| 4442 | } |
| 4443 | if (LocaleCompare("colorspace",option+1) == 0) |
| 4444 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4445 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4446 | colorspace; |
| 4447 | |
| 4448 | if (*option == '+') |
| 4449 | break; |
| 4450 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4451 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4452 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4453 | colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse, |
| 4454 | argv[i]); |
| 4455 | if (colorspace < 0) |
| 4456 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 4457 | argv[i]); |
| 4458 | break; |
| 4459 | } |
| 4460 | if (LocaleCompare("combine",option+1) == 0) |
| 4461 | break; |
| 4462 | if (LocaleCompare("comment",option+1) == 0) |
| 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 | break; |
| 4470 | } |
| 4471 | if (LocaleCompare("composite",option+1) == 0) |
| 4472 | break; |
| 4473 | if (LocaleCompare("compress",option+1) == 0) |
| 4474 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4475 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4476 | compress; |
| 4477 | |
| 4478 | if (*option == '+') |
| 4479 | break; |
| 4480 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4481 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4482 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 4483 | compress=ParseMagickOption(MagickCompressOptions,MagickFalse, |
| 4484 | argv[i]); |
| 4485 | if (compress < 0) |
| 4486 | ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", |
| 4487 | argv[i]); |
| 4488 | break; |
| 4489 | } |
cristy | 2287975 | 2009-10-25 23:55:40 +0000 | [diff] [blame] | 4490 | if (LocaleCompare("concurrent",option+1) == 0) |
| 4491 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4492 | if (LocaleCompare("contrast",option+1) == 0) |
| 4493 | break; |
| 4494 | if (LocaleCompare("contrast-stretch",option+1) == 0) |
| 4495 | { |
| 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 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4500 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4501 | break; |
| 4502 | } |
| 4503 | if (LocaleCompare("convolve",option+1) == 0) |
| 4504 | { |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 4505 | char |
| 4506 | token[MaxTextExtent]; |
| 4507 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4508 | if (*option == '+') |
| 4509 | break; |
| 4510 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4511 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4512 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 4513 | #if 1 |
cristy | dfbe6ca | 2010-03-12 14:08:17 +0000 | [diff] [blame] | 4514 | (void) token; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 4515 | if (IsGeometry(argv[i]) == MagickFalse) |
| 4516 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 4517 | #else |
| 4518 | /* Allow the use of built-in kernels like 'gaussian' |
| 4519 | * These may not work for kernels with 'nan' values, like 'diamond' |
| 4520 | */ |
| 4521 | GetMagickToken(argv[i],NULL,token); |
| 4522 | if ( isalpha((int)token[0]) ) |
| 4523 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 4524 | ssize_t |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 4525 | op; |
| 4526 | |
| 4527 | op=ParseMagickOption(MagickKernelOptions,MagickFalse,token); |
| 4528 | if (op < 0) |
| 4529 | ThrowMogrifyException(OptionError,"UnrecognizedKernelType", |
| 4530 | token); |
| 4531 | } |
| 4532 | /* geometry current returns invalid if 'nan' values are used */ |
| 4533 | else if (IsGeometry(argv[i]) == MagickFalse) |
| 4534 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 4535 | #endif |
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 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5405 | ssize_t |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5406 | op; |
| 5407 | |
| 5408 | char |
| 5409 | token[MaxTextExtent]; |
| 5410 | |
| 5411 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5412 | if (i == (ssize_t) argc) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5413 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5414 | GetMagickToken(argv[i],NULL,token); |
| 5415 | op=ParseMagickOption(MagickMorphologyOptions,MagickFalse,token); |
| 5416 | if (op < 0) |
| 5417 | ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5418 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5419 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5420 | if (i == (ssize_t) (argc-1)) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5421 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5422 | GetMagickToken(argv[i],NULL,token); |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5423 | if (isalpha((int) ((unsigned char) *token)) != 0) |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5424 | { |
| 5425 | op=ParseMagickOption(MagickKernelOptions,MagickFalse,token); |
| 5426 | if (op < 0) |
| 5427 | ThrowMogrifyException(OptionError,"UnrecognizedKernelType", |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5428 | token); |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5429 | } |
anthony | 29188a8 | 2010-01-22 10:12:34 +0000 | [diff] [blame] | 5430 | break; |
| 5431 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5432 | if (LocaleCompare("mosaic",option+1) == 0) |
| 5433 | break; |
| 5434 | if (LocaleCompare("motion-blur",option+1) == 0) |
| 5435 | { |
| 5436 | if (*option == '+') |
| 5437 | break; |
| 5438 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5439 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5440 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5441 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5442 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5443 | break; |
| 5444 | } |
| 5445 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5446 | } |
| 5447 | case 'n': |
| 5448 | { |
| 5449 | if (LocaleCompare("negate",option+1) == 0) |
| 5450 | break; |
| 5451 | if (LocaleCompare("noise",option+1) == 0) |
| 5452 | { |
| 5453 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5454 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5455 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5456 | if (*option == '+') |
| 5457 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5458 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5459 | noise; |
| 5460 | |
| 5461 | noise=ParseMagickOption(MagickNoiseOptions,MagickFalse,argv[i]); |
| 5462 | if (noise < 0) |
| 5463 | ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", |
| 5464 | argv[i]); |
| 5465 | break; |
| 5466 | } |
| 5467 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5468 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5469 | break; |
| 5470 | } |
| 5471 | if (LocaleCompare("noop",option+1) == 0) |
| 5472 | break; |
| 5473 | if (LocaleCompare("normalize",option+1) == 0) |
| 5474 | break; |
| 5475 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5476 | } |
| 5477 | case 'o': |
| 5478 | { |
| 5479 | if (LocaleCompare("opaque",option+1) == 0) |
| 5480 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5481 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5482 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5483 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5484 | break; |
| 5485 | } |
| 5486 | if (LocaleCompare("ordered-dither",option+1) == 0) |
| 5487 | { |
| 5488 | if (*option == '+') |
| 5489 | break; |
| 5490 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5491 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5492 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5493 | break; |
| 5494 | } |
| 5495 | if (LocaleCompare("orient",option+1) == 0) |
| 5496 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5497 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5498 | orientation; |
| 5499 | |
| 5500 | orientation=UndefinedOrientation; |
| 5501 | if (*option == '+') |
| 5502 | break; |
| 5503 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5504 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5505 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5506 | orientation=ParseMagickOption(MagickOrientationOptions,MagickFalse, |
| 5507 | argv[i]); |
| 5508 | if (orientation < 0) |
| 5509 | ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", |
| 5510 | argv[i]); |
| 5511 | break; |
| 5512 | } |
| 5513 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5514 | } |
| 5515 | case 'p': |
| 5516 | { |
| 5517 | if (LocaleCompare("page",option+1) == 0) |
| 5518 | { |
| 5519 | if (*option == '+') |
| 5520 | break; |
| 5521 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5522 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5523 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5524 | break; |
| 5525 | } |
| 5526 | if (LocaleCompare("paint",option+1) == 0) |
| 5527 | { |
| 5528 | if (*option == '+') |
| 5529 | break; |
| 5530 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5531 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5532 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5533 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5534 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5535 | break; |
| 5536 | } |
| 5537 | if (LocaleCompare("path",option+1) == 0) |
| 5538 | { |
| 5539 | (void) CloneString(&path,(char *) NULL); |
| 5540 | if (*option == '+') |
| 5541 | break; |
| 5542 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5543 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5544 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5545 | (void) CloneString(&path,argv[i]); |
| 5546 | break; |
| 5547 | } |
| 5548 | if (LocaleCompare("pointsize",option+1) == 0) |
| 5549 | { |
| 5550 | if (*option == '+') |
| 5551 | break; |
| 5552 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5553 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5554 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5555 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5556 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5557 | break; |
| 5558 | } |
| 5559 | if (LocaleCompare("polaroid",option+1) == 0) |
| 5560 | { |
| 5561 | if (*option == '+') |
| 5562 | break; |
| 5563 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5564 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5565 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5566 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5567 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5568 | break; |
| 5569 | } |
| 5570 | if (LocaleCompare("posterize",option+1) == 0) |
| 5571 | { |
| 5572 | if (*option == '+') |
| 5573 | break; |
| 5574 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5575 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5576 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5577 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5578 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5579 | break; |
| 5580 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5581 | if (LocaleCompare("precision",option+1) == 0) |
| 5582 | { |
| 5583 | if (*option == '+') |
| 5584 | break; |
| 5585 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5586 | if (i == (ssize_t) argc) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 5587 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5588 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5589 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5590 | break; |
| 5591 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5592 | if (LocaleCompare("print",option+1) == 0) |
| 5593 | { |
| 5594 | if (*option == '+') |
| 5595 | break; |
| 5596 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5597 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5598 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5599 | break; |
| 5600 | } |
| 5601 | if (LocaleCompare("process",option+1) == 0) |
| 5602 | { |
| 5603 | if (*option == '+') |
| 5604 | break; |
| 5605 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5606 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5607 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5608 | break; |
| 5609 | } |
| 5610 | if (LocaleCompare("profile",option+1) == 0) |
| 5611 | { |
| 5612 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5613 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5614 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5615 | break; |
| 5616 | } |
| 5617 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5618 | } |
| 5619 | case 'q': |
| 5620 | { |
| 5621 | if (LocaleCompare("quality",option+1) == 0) |
| 5622 | { |
| 5623 | if (*option == '+') |
| 5624 | break; |
| 5625 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5626 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5627 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5628 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5629 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5630 | break; |
| 5631 | } |
| 5632 | if (LocaleCompare("quantize",option+1) == 0) |
| 5633 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5634 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5635 | colorspace; |
| 5636 | |
| 5637 | if (*option == '+') |
| 5638 | break; |
| 5639 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5640 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5641 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5642 | colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse, |
| 5643 | argv[i]); |
| 5644 | if (colorspace < 0) |
| 5645 | ThrowMogrifyException(OptionError,"UnrecognizedColorspace", |
| 5646 | argv[i]); |
| 5647 | break; |
| 5648 | } |
| 5649 | if (LocaleCompare("quiet",option+1) == 0) |
| 5650 | break; |
| 5651 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5652 | } |
| 5653 | case 'r': |
| 5654 | { |
| 5655 | if (LocaleCompare("radial-blur",option+1) == 0) |
| 5656 | { |
| 5657 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5658 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5659 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5660 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5661 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5662 | break; |
| 5663 | } |
| 5664 | if (LocaleCompare("raise",option+1) == 0) |
| 5665 | { |
| 5666 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5667 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5668 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5669 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5670 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5671 | break; |
| 5672 | } |
| 5673 | if (LocaleCompare("random-threshold",option+1) == 0) |
| 5674 | { |
| 5675 | if (*option == '+') |
| 5676 | break; |
| 5677 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5678 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5679 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5680 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5681 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5682 | break; |
| 5683 | } |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5684 | if (LocaleCompare("recolor",option+1) == 0) |
| 5685 | { |
| 5686 | if (*option == '+') |
| 5687 | break; |
| 5688 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5689 | if (i == (ssize_t) (argc-1)) |
cristy | e636559 | 2010-04-02 17:31:23 +0000 | [diff] [blame] | 5690 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5691 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5692 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5693 | break; |
| 5694 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5695 | if (LocaleCompare("red-primary",option+1) == 0) |
| 5696 | { |
| 5697 | if (*option == '+') |
| 5698 | break; |
| 5699 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5700 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5701 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5702 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5703 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5704 | } |
cristy | 9f2083a | 2010-04-22 19:48:05 +0000 | [diff] [blame] | 5705 | if (LocaleCompare("regard-warnings",option+1) == 0) |
| 5706 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5707 | if (LocaleCompare("region",option+1) == 0) |
| 5708 | { |
| 5709 | if (*option == '+') |
| 5710 | break; |
| 5711 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5712 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5713 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5714 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5715 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5716 | break; |
| 5717 | } |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5718 | if (LocaleCompare("remap",option+1) == 0) |
| 5719 | { |
| 5720 | if (*option == '+') |
| 5721 | break; |
| 5722 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5723 | if (i == (ssize_t) (argc-1)) |
cristy | f0c7823 | 2010-03-15 12:53:40 +0000 | [diff] [blame] | 5724 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5725 | break; |
| 5726 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5727 | if (LocaleCompare("render",option+1) == 0) |
| 5728 | break; |
| 5729 | if (LocaleCompare("repage",option+1) == 0) |
| 5730 | { |
| 5731 | if (*option == '+') |
| 5732 | break; |
| 5733 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5734 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5735 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5736 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5737 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5738 | break; |
| 5739 | } |
| 5740 | if (LocaleCompare("resample",option+1) == 0) |
| 5741 | { |
| 5742 | if (*option == '+') |
| 5743 | break; |
| 5744 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5745 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5746 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5747 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5748 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5749 | break; |
| 5750 | } |
| 5751 | if (LocaleCompare("resize",option+1) == 0) |
| 5752 | { |
| 5753 | if (*option == '+') |
| 5754 | break; |
| 5755 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5756 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5757 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5758 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5759 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5760 | break; |
| 5761 | } |
| 5762 | if (LocaleCompare("reverse",option+1) == 0) |
| 5763 | break; |
| 5764 | if (LocaleCompare("roll",option+1) == 0) |
| 5765 | { |
| 5766 | if (*option == '+') |
| 5767 | break; |
| 5768 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5769 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5770 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5771 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5772 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5773 | break; |
| 5774 | } |
| 5775 | if (LocaleCompare("rotate",option+1) == 0) |
| 5776 | { |
| 5777 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5778 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5779 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5780 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5781 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5782 | break; |
| 5783 | } |
| 5784 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 5785 | } |
| 5786 | case 's': |
| 5787 | { |
| 5788 | if (LocaleCompare("sample",option+1) == 0) |
| 5789 | { |
| 5790 | if (*option == '+') |
| 5791 | break; |
| 5792 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5793 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5794 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5795 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5796 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5797 | break; |
| 5798 | } |
| 5799 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 5800 | { |
| 5801 | if (*option == '+') |
| 5802 | break; |
| 5803 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5804 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5805 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5806 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5807 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5808 | break; |
| 5809 | } |
| 5810 | if (LocaleCompare("scale",option+1) == 0) |
| 5811 | { |
| 5812 | if (*option == '+') |
| 5813 | break; |
| 5814 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5815 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5816 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5817 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5818 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5819 | break; |
| 5820 | } |
| 5821 | if (LocaleCompare("scene",option+1) == 0) |
| 5822 | { |
| 5823 | if (*option == '+') |
| 5824 | break; |
| 5825 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5826 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5827 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5828 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5829 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5830 | break; |
| 5831 | } |
| 5832 | if (LocaleCompare("seed",option+1) == 0) |
| 5833 | { |
| 5834 | if (*option == '+') |
| 5835 | break; |
| 5836 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5837 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5838 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5839 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5840 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5841 | break; |
| 5842 | } |
| 5843 | if (LocaleCompare("segment",option+1) == 0) |
| 5844 | { |
| 5845 | if (*option == '+') |
| 5846 | break; |
| 5847 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5848 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5849 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5850 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5851 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5852 | break; |
| 5853 | } |
| 5854 | if (LocaleCompare("selective-blur",option+1) == 0) |
| 5855 | { |
| 5856 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5857 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5858 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5859 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5860 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5861 | break; |
| 5862 | } |
| 5863 | if (LocaleCompare("separate",option+1) == 0) |
| 5864 | break; |
| 5865 | if (LocaleCompare("sepia-tone",option+1) == 0) |
| 5866 | { |
| 5867 | if (*option == '+') |
| 5868 | break; |
| 5869 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5870 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5871 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5872 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5873 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5874 | break; |
| 5875 | } |
| 5876 | if (LocaleCompare("set",option+1) == 0) |
| 5877 | { |
| 5878 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5879 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5880 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5881 | if (*option == '+') |
| 5882 | break; |
| 5883 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5884 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5885 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5886 | break; |
| 5887 | } |
| 5888 | if (LocaleCompare("shade",option+1) == 0) |
| 5889 | { |
| 5890 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5891 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5892 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5893 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5894 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5895 | break; |
| 5896 | } |
| 5897 | if (LocaleCompare("shadow",option+1) == 0) |
| 5898 | { |
| 5899 | if (*option == '+') |
| 5900 | break; |
| 5901 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5902 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5903 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5904 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5905 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5906 | break; |
| 5907 | } |
| 5908 | if (LocaleCompare("sharpen",option+1) == 0) |
| 5909 | { |
| 5910 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5911 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5912 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5913 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5914 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5915 | break; |
| 5916 | } |
| 5917 | if (LocaleCompare("shave",option+1) == 0) |
| 5918 | { |
| 5919 | if (*option == '+') |
| 5920 | break; |
| 5921 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5922 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5923 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5924 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5925 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5926 | break; |
| 5927 | } |
| 5928 | if (LocaleCompare("shear",option+1) == 0) |
| 5929 | { |
| 5930 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5931 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5932 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5933 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5934 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5935 | break; |
| 5936 | } |
| 5937 | if (LocaleCompare("sigmoidal-contrast",option+1) == 0) |
| 5938 | { |
| 5939 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5940 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5941 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5942 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5943 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5944 | break; |
| 5945 | } |
| 5946 | if (LocaleCompare("size",option+1) == 0) |
| 5947 | { |
| 5948 | if (*option == '+') |
| 5949 | break; |
| 5950 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5951 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5952 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5953 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5954 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5955 | break; |
| 5956 | } |
| 5957 | if (LocaleCompare("sketch",option+1) == 0) |
| 5958 | { |
| 5959 | if (*option == '+') |
| 5960 | break; |
| 5961 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5962 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5963 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5964 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5965 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5966 | break; |
| 5967 | } |
| 5968 | if (LocaleCompare("solarize",option+1) == 0) |
| 5969 | { |
| 5970 | if (*option == '+') |
| 5971 | break; |
| 5972 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5973 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5974 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5975 | if (IsGeometry(argv[i]) == MagickFalse) |
| 5976 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 5977 | break; |
| 5978 | } |
| 5979 | if (LocaleCompare("sparse-color",option+1) == 0) |
| 5980 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5981 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5982 | op; |
| 5983 | |
| 5984 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5985 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5986 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5987 | op=ParseMagickOption(MagickSparseColorOptions,MagickFalse,argv[i]); |
| 5988 | if (op < 0) |
| 5989 | ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", |
| 5990 | argv[i]); |
| 5991 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 5992 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 5993 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 5994 | break; |
| 5995 | } |
| 5996 | if (LocaleCompare("spread",option+1) == 0) |
| 5997 | { |
| 5998 | if (*option == '+') |
| 5999 | break; |
| 6000 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6001 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6002 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6003 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6004 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6005 | break; |
| 6006 | } |
| 6007 | if (LocaleCompare("stretch",option+1) == 0) |
| 6008 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6009 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6010 | stretch; |
| 6011 | |
| 6012 | if (*option == '+') |
| 6013 | break; |
| 6014 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6015 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6016 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6017 | stretch=ParseMagickOption(MagickStretchOptions,MagickFalse,argv[i]); |
| 6018 | if (stretch < 0) |
| 6019 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 6020 | argv[i]); |
| 6021 | break; |
| 6022 | } |
| 6023 | if (LocaleCompare("strip",option+1) == 0) |
| 6024 | break; |
| 6025 | if (LocaleCompare("stroke",option+1) == 0) |
| 6026 | { |
| 6027 | if (*option == '+') |
| 6028 | break; |
| 6029 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6030 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6031 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6032 | break; |
| 6033 | } |
| 6034 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 6035 | { |
| 6036 | if (*option == '+') |
| 6037 | break; |
| 6038 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6039 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6040 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6041 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6042 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6043 | break; |
| 6044 | } |
| 6045 | if (LocaleCompare("style",option+1) == 0) |
| 6046 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6047 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6048 | style; |
| 6049 | |
| 6050 | if (*option == '+') |
| 6051 | break; |
| 6052 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6053 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6054 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6055 | style=ParseMagickOption(MagickStyleOptions,MagickFalse,argv[i]); |
| 6056 | if (style < 0) |
| 6057 | ThrowMogrifyException(OptionError,"UnrecognizedStyleType", |
| 6058 | argv[i]); |
| 6059 | break; |
| 6060 | } |
| 6061 | if (LocaleCompare("swirl",option+1) == 0) |
| 6062 | { |
| 6063 | if (*option == '+') |
| 6064 | break; |
| 6065 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6066 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6067 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6068 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6069 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6070 | break; |
| 6071 | } |
| 6072 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6073 | } |
| 6074 | case 't': |
| 6075 | { |
| 6076 | if (LocaleCompare("taint",option+1) == 0) |
| 6077 | break; |
| 6078 | if (LocaleCompare("texture",option+1) == 0) |
| 6079 | { |
| 6080 | if (*option == '+') |
| 6081 | break; |
| 6082 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6083 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6084 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6085 | break; |
| 6086 | } |
| 6087 | if (LocaleCompare("tile",option+1) == 0) |
| 6088 | { |
| 6089 | if (*option == '+') |
| 6090 | break; |
| 6091 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6092 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6093 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6094 | break; |
| 6095 | } |
| 6096 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 6097 | { |
| 6098 | if (*option == '+') |
| 6099 | break; |
| 6100 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6101 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6102 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6103 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6104 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6105 | break; |
| 6106 | } |
| 6107 | if (LocaleCompare("tint",option+1) == 0) |
| 6108 | { |
| 6109 | if (*option == '+') |
| 6110 | break; |
| 6111 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6112 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6113 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6114 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6115 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6116 | break; |
| 6117 | } |
| 6118 | if (LocaleCompare("transform",option+1) == 0) |
| 6119 | break; |
| 6120 | if (LocaleCompare("transpose",option+1) == 0) |
| 6121 | break; |
| 6122 | if (LocaleCompare("transverse",option+1) == 0) |
| 6123 | break; |
| 6124 | if (LocaleCompare("threshold",option+1) == 0) |
| 6125 | { |
| 6126 | if (*option == '+') |
| 6127 | break; |
| 6128 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6129 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6130 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6131 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6132 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6133 | break; |
| 6134 | } |
| 6135 | if (LocaleCompare("thumbnail",option+1) == 0) |
| 6136 | { |
| 6137 | if (*option == '+') |
| 6138 | break; |
| 6139 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6140 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6141 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6142 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6143 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6144 | break; |
| 6145 | } |
| 6146 | if (LocaleCompare("transparent",option+1) == 0) |
| 6147 | { |
| 6148 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6149 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6150 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6151 | break; |
| 6152 | } |
| 6153 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 6154 | { |
| 6155 | if (*option == '+') |
| 6156 | break; |
| 6157 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6158 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6159 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6160 | break; |
| 6161 | } |
| 6162 | if (LocaleCompare("treedepth",option+1) == 0) |
| 6163 | { |
| 6164 | if (*option == '+') |
| 6165 | break; |
| 6166 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6167 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6168 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6169 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6170 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6171 | break; |
| 6172 | } |
| 6173 | if (LocaleCompare("trim",option+1) == 0) |
| 6174 | break; |
| 6175 | if (LocaleCompare("type",option+1) == 0) |
| 6176 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6177 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6178 | type; |
| 6179 | |
| 6180 | if (*option == '+') |
| 6181 | break; |
| 6182 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6183 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6184 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6185 | type=ParseMagickOption(MagickTypeOptions,MagickFalse,argv[i]); |
| 6186 | if (type < 0) |
| 6187 | ThrowMogrifyException(OptionError,"UnrecognizedImageType", |
| 6188 | argv[i]); |
| 6189 | break; |
| 6190 | } |
| 6191 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6192 | } |
| 6193 | case 'u': |
| 6194 | { |
| 6195 | if (LocaleCompare("undercolor",option+1) == 0) |
| 6196 | { |
| 6197 | if (*option == '+') |
| 6198 | break; |
| 6199 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6200 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6201 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6202 | break; |
| 6203 | } |
| 6204 | if (LocaleCompare("unique-colors",option+1) == 0) |
| 6205 | break; |
| 6206 | if (LocaleCompare("units",option+1) == 0) |
| 6207 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6208 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6209 | units; |
| 6210 | |
| 6211 | if (*option == '+') |
| 6212 | break; |
| 6213 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6214 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6215 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6216 | units=ParseMagickOption(MagickResolutionOptions,MagickFalse, |
| 6217 | argv[i]); |
| 6218 | if (units < 0) |
| 6219 | ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", |
| 6220 | argv[i]); |
| 6221 | break; |
| 6222 | } |
| 6223 | if (LocaleCompare("unsharp",option+1) == 0) |
| 6224 | { |
| 6225 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6226 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6227 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6228 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6229 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6230 | break; |
| 6231 | } |
| 6232 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6233 | } |
| 6234 | case 'v': |
| 6235 | { |
| 6236 | if (LocaleCompare("verbose",option+1) == 0) |
| 6237 | { |
| 6238 | image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; |
| 6239 | break; |
| 6240 | } |
| 6241 | if ((LocaleCompare("version",option+1) == 0) || |
| 6242 | (LocaleCompare("-version",option+1) == 0)) |
| 6243 | { |
| 6244 | (void) fprintf(stdout,"Version: %s\n", |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6245 | GetMagickVersion((size_t *) NULL)); |
cristy | 610b2e2 | 2009-10-22 14:59:43 +0000 | [diff] [blame] | 6246 | (void) fprintf(stdout,"Copyright: %s\n",GetMagickCopyright()); |
| 6247 | (void) fprintf(stdout,"Features: %s\n\n",GetMagickFeatures()); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6248 | break; |
| 6249 | } |
| 6250 | if (LocaleCompare("view",option+1) == 0) |
| 6251 | { |
| 6252 | if (*option == '+') |
| 6253 | break; |
| 6254 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6255 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6256 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6257 | break; |
| 6258 | } |
| 6259 | if (LocaleCompare("vignette",option+1) == 0) |
| 6260 | { |
| 6261 | if (*option == '+') |
| 6262 | break; |
| 6263 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6264 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6265 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6266 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6267 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6268 | break; |
| 6269 | } |
| 6270 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 6271 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6272 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6273 | method; |
| 6274 | |
| 6275 | if (*option == '+') |
| 6276 | break; |
| 6277 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6278 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6279 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6280 | method=ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 6281 | argv[i]); |
| 6282 | if (method < 0) |
| 6283 | ThrowMogrifyException(OptionError, |
| 6284 | "UnrecognizedVirtualPixelMethod",argv[i]); |
| 6285 | break; |
| 6286 | } |
| 6287 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6288 | } |
| 6289 | case 'w': |
| 6290 | { |
| 6291 | if (LocaleCompare("wave",option+1) == 0) |
| 6292 | { |
| 6293 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6294 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6295 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6296 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6297 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6298 | break; |
| 6299 | } |
| 6300 | if (LocaleCompare("weight",option+1) == 0) |
| 6301 | { |
| 6302 | if (*option == '+') |
| 6303 | break; |
| 6304 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6305 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6306 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6307 | break; |
| 6308 | } |
| 6309 | if (LocaleCompare("white-point",option+1) == 0) |
| 6310 | { |
| 6311 | if (*option == '+') |
| 6312 | break; |
| 6313 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6314 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6315 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6316 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6317 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6318 | break; |
| 6319 | } |
| 6320 | if (LocaleCompare("white-threshold",option+1) == 0) |
| 6321 | { |
| 6322 | if (*option == '+') |
| 6323 | break; |
| 6324 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6325 | if (i == (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6326 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6327 | if (IsGeometry(argv[i]) == MagickFalse) |
| 6328 | ThrowMogrifyInvalidArgumentException(option,argv[i]); |
| 6329 | break; |
| 6330 | } |
| 6331 | if (LocaleCompare("write",option+1) == 0) |
| 6332 | { |
| 6333 | i++; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6334 | if (i == (ssize_t) (argc-1)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6335 | ThrowMogrifyException(OptionError,"MissingArgument",option); |
| 6336 | break; |
| 6337 | } |
| 6338 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6339 | } |
| 6340 | case '?': |
| 6341 | break; |
| 6342 | default: |
| 6343 | ThrowMogrifyException(OptionError,"UnrecognizedOption",option) |
| 6344 | } |
| 6345 | fire=ParseMagickOption(MagickImageListOptions,MagickFalse,option+1) < 0 ? |
| 6346 | MagickFalse : MagickTrue; |
| 6347 | if (fire != MagickFalse) |
| 6348 | FireImageStack(MagickFalse,MagickTrue,MagickTrue); |
| 6349 | } |
| 6350 | if (k != 0) |
| 6351 | ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6352 | if (i != (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6353 | ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); |
| 6354 | DestroyMogrify(); |
| 6355 | return(status != 0 ? MagickTrue : MagickFalse); |
| 6356 | } |
| 6357 | |
| 6358 | /* |
| 6359 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6360 | % % |
| 6361 | % % |
| 6362 | % % |
| 6363 | + M o g r i f y I m a g e I n f o % |
| 6364 | % % |
| 6365 | % % |
| 6366 | % % |
| 6367 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 6368 | % |
| 6369 | % MogrifyImageInfo() applies image processing settings to the image as |
| 6370 | % prescribed by command line options. |
| 6371 | % |
| 6372 | % The format of the MogrifyImageInfo method is: |
| 6373 | % |
| 6374 | % MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, |
| 6375 | % const char **argv,ExceptionInfo *exception) |
| 6376 | % |
| 6377 | % A description of each parameter follows: |
| 6378 | % |
| 6379 | % o image_info: the image info.. |
| 6380 | % |
| 6381 | % o argc: Specifies a pointer to an integer describing the number of |
| 6382 | % elements in the argument vector. |
| 6383 | % |
| 6384 | % o argv: Specifies a pointer to a text array containing the command line |
| 6385 | % arguments. |
| 6386 | % |
| 6387 | % o exception: return any errors or warnings in this structure. |
| 6388 | % |
| 6389 | */ |
| 6390 | WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, |
| 6391 | const int argc,const char **argv,ExceptionInfo *exception) |
| 6392 | { |
| 6393 | const char |
| 6394 | *option; |
| 6395 | |
| 6396 | GeometryInfo |
| 6397 | geometry_info; |
| 6398 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6399 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6400 | count; |
| 6401 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6402 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6403 | i; |
| 6404 | |
| 6405 | /* |
| 6406 | Initialize method variables. |
| 6407 | */ |
| 6408 | assert(image_info != (ImageInfo *) NULL); |
| 6409 | assert(image_info->signature == MagickSignature); |
| 6410 | if (image_info->debug != MagickFalse) |
| 6411 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 6412 | image_info->filename); |
| 6413 | if (argc < 0) |
| 6414 | return(MagickTrue); |
| 6415 | /* |
| 6416 | Set the image settings. |
| 6417 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6418 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6419 | { |
| 6420 | option=argv[i]; |
| 6421 | if (IsMagickOption(option) == MagickFalse) |
| 6422 | continue; |
| 6423 | count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option), |
| 6424 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 6425 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6426 | break; |
| 6427 | switch (*(option+1)) |
| 6428 | { |
| 6429 | case 'a': |
| 6430 | { |
| 6431 | if (LocaleCompare("adjoin",option+1) == 0) |
| 6432 | { |
| 6433 | image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; |
| 6434 | break; |
| 6435 | } |
| 6436 | if (LocaleCompare("antialias",option+1) == 0) |
| 6437 | { |
| 6438 | image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; |
| 6439 | break; |
| 6440 | } |
| 6441 | if (LocaleCompare("attenuate",option+1) == 0) |
| 6442 | { |
| 6443 | if (*option == '+') |
| 6444 | { |
| 6445 | (void) DeleteImageOption(image_info,option+1); |
| 6446 | break; |
| 6447 | } |
| 6448 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6449 | break; |
| 6450 | } |
| 6451 | if (LocaleCompare("authenticate",option+1) == 0) |
| 6452 | { |
| 6453 | if (*option == '+') |
| 6454 | (void) CloneString(&image_info->authenticate,(char *) NULL); |
| 6455 | else |
| 6456 | (void) CloneString(&image_info->authenticate,argv[i+1]); |
| 6457 | break; |
| 6458 | } |
| 6459 | break; |
| 6460 | } |
| 6461 | case 'b': |
| 6462 | { |
| 6463 | if (LocaleCompare("background",option+1) == 0) |
| 6464 | { |
| 6465 | if (*option == '+') |
| 6466 | { |
| 6467 | (void) DeleteImageOption(image_info,option+1); |
| 6468 | (void) QueryColorDatabase(BackgroundColor, |
| 6469 | &image_info->background_color,exception); |
| 6470 | break; |
| 6471 | } |
| 6472 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6473 | (void) QueryColorDatabase(argv[i+1],&image_info->background_color, |
| 6474 | exception); |
| 6475 | break; |
| 6476 | } |
| 6477 | if (LocaleCompare("bias",option+1) == 0) |
| 6478 | { |
| 6479 | if (*option == '+') |
| 6480 | { |
| 6481 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6482 | break; |
| 6483 | } |
| 6484 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6485 | break; |
| 6486 | } |
| 6487 | if (LocaleCompare("black-point-compensation",option+1) == 0) |
| 6488 | { |
| 6489 | if (*option == '+') |
| 6490 | { |
| 6491 | (void) SetImageOption(image_info,option+1,"false"); |
| 6492 | break; |
| 6493 | } |
| 6494 | (void) SetImageOption(image_info,option+1,"true"); |
| 6495 | break; |
| 6496 | } |
| 6497 | if (LocaleCompare("blue-primary",option+1) == 0) |
| 6498 | { |
| 6499 | if (*option == '+') |
| 6500 | { |
| 6501 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6502 | break; |
| 6503 | } |
| 6504 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6505 | break; |
| 6506 | } |
| 6507 | if (LocaleCompare("bordercolor",option+1) == 0) |
| 6508 | { |
| 6509 | if (*option == '+') |
| 6510 | { |
| 6511 | (void) DeleteImageOption(image_info,option+1); |
| 6512 | (void) QueryColorDatabase(BorderColor,&image_info->border_color, |
| 6513 | exception); |
| 6514 | break; |
| 6515 | } |
| 6516 | (void) QueryColorDatabase(argv[i+1],&image_info->border_color, |
| 6517 | exception); |
| 6518 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6519 | break; |
| 6520 | } |
| 6521 | if (LocaleCompare("box",option+1) == 0) |
| 6522 | { |
| 6523 | if (*option == '+') |
| 6524 | { |
| 6525 | (void) SetImageOption(image_info,"undercolor","none"); |
| 6526 | break; |
| 6527 | } |
| 6528 | (void) SetImageOption(image_info,"undercolor",argv[i+1]); |
| 6529 | break; |
| 6530 | } |
| 6531 | break; |
| 6532 | } |
| 6533 | case 'c': |
| 6534 | { |
| 6535 | if (LocaleCompare("cache",option+1) == 0) |
| 6536 | { |
| 6537 | MagickSizeType |
| 6538 | limit; |
| 6539 | |
| 6540 | limit=MagickResourceInfinity; |
| 6541 | if (LocaleCompare("unlimited",argv[i+1]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6542 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+1],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6543 | (void) SetMagickResourceLimit(MemoryResource,limit); |
| 6544 | (void) SetMagickResourceLimit(MapResource,2*limit); |
| 6545 | break; |
| 6546 | } |
| 6547 | if (LocaleCompare("caption",option+1) == 0) |
| 6548 | { |
| 6549 | if (*option == '+') |
| 6550 | { |
| 6551 | (void) DeleteImageOption(image_info,option+1); |
| 6552 | break; |
| 6553 | } |
| 6554 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6555 | break; |
| 6556 | } |
| 6557 | if (LocaleCompare("channel",option+1) == 0) |
| 6558 | { |
| 6559 | if (*option == '+') |
| 6560 | { |
| 6561 | image_info->channel=DefaultChannels; |
| 6562 | break; |
| 6563 | } |
| 6564 | image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 6565 | break; |
| 6566 | } |
| 6567 | if (LocaleCompare("colors",option+1) == 0) |
| 6568 | { |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6569 | image_info->colors=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6570 | break; |
| 6571 | } |
| 6572 | if (LocaleCompare("colorspace",option+1) == 0) |
| 6573 | { |
| 6574 | if (*option == '+') |
| 6575 | { |
| 6576 | image_info->colorspace=UndefinedColorspace; |
| 6577 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6578 | break; |
| 6579 | } |
| 6580 | image_info->colorspace=(ColorspaceType) ParseMagickOption( |
| 6581 | MagickColorspaceOptions,MagickFalse,argv[i+1]); |
| 6582 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6583 | break; |
| 6584 | } |
| 6585 | if (LocaleCompare("compress",option+1) == 0) |
| 6586 | { |
| 6587 | if (*option == '+') |
| 6588 | { |
| 6589 | image_info->compression=UndefinedCompression; |
| 6590 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6591 | break; |
| 6592 | } |
| 6593 | image_info->compression=(CompressionType) ParseMagickOption( |
| 6594 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6595 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6596 | break; |
| 6597 | } |
| 6598 | if (LocaleCompare("comment",option+1) == 0) |
| 6599 | { |
| 6600 | if (*option == '+') |
| 6601 | { |
| 6602 | (void) DeleteImageOption(image_info,option+1); |
| 6603 | break; |
| 6604 | } |
| 6605 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6606 | break; |
| 6607 | } |
| 6608 | if (LocaleCompare("compose",option+1) == 0) |
| 6609 | { |
| 6610 | if (*option == '+') |
| 6611 | { |
| 6612 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6613 | break; |
| 6614 | } |
| 6615 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6616 | break; |
| 6617 | } |
| 6618 | if (LocaleCompare("compress",option+1) == 0) |
| 6619 | { |
| 6620 | if (*option == '+') |
| 6621 | { |
| 6622 | image_info->compression=UndefinedCompression; |
| 6623 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6624 | break; |
| 6625 | } |
| 6626 | image_info->compression=(CompressionType) ParseMagickOption( |
| 6627 | MagickCompressOptions,MagickFalse,argv[i+1]); |
| 6628 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6629 | break; |
| 6630 | } |
| 6631 | break; |
| 6632 | } |
| 6633 | case 'd': |
| 6634 | { |
| 6635 | if (LocaleCompare("debug",option+1) == 0) |
| 6636 | { |
| 6637 | if (*option == '+') |
| 6638 | (void) SetLogEventMask("none"); |
| 6639 | else |
| 6640 | (void) SetLogEventMask(argv[i+1]); |
| 6641 | image_info->debug=IsEventLogging(); |
| 6642 | break; |
| 6643 | } |
| 6644 | if (LocaleCompare("define",option+1) == 0) |
| 6645 | { |
| 6646 | if (*option == '+') |
| 6647 | { |
| 6648 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6649 | (void) DeleteImageRegistry(argv[i+1]+9); |
| 6650 | else |
| 6651 | (void) DeleteImageOption(image_info,argv[i+1]); |
| 6652 | break; |
| 6653 | } |
| 6654 | if (LocaleNCompare(argv[i+1],"registry:",9) == 0) |
| 6655 | { |
| 6656 | (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, |
| 6657 | exception); |
| 6658 | break; |
| 6659 | } |
| 6660 | (void) DefineImageOption(image_info,argv[i+1]); |
| 6661 | break; |
| 6662 | } |
| 6663 | if (LocaleCompare("delay",option+1) == 0) |
| 6664 | { |
| 6665 | if (*option == '+') |
| 6666 | { |
| 6667 | (void) SetImageOption(image_info,option+1,"0"); |
| 6668 | break; |
| 6669 | } |
| 6670 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6671 | break; |
| 6672 | } |
| 6673 | if (LocaleCompare("density",option+1) == 0) |
| 6674 | { |
| 6675 | /* |
| 6676 | Set image density. |
| 6677 | */ |
| 6678 | if (*option == '+') |
| 6679 | { |
| 6680 | if (image_info->density != (char *) NULL) |
| 6681 | image_info->density=DestroyString(image_info->density); |
| 6682 | (void) SetImageOption(image_info,option+1,"72"); |
| 6683 | break; |
| 6684 | } |
| 6685 | (void) CloneString(&image_info->density,argv[i+1]); |
| 6686 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6687 | break; |
| 6688 | } |
| 6689 | if (LocaleCompare("depth",option+1) == 0) |
| 6690 | { |
| 6691 | if (*option == '+') |
| 6692 | { |
| 6693 | image_info->depth=MAGICKCORE_QUANTUM_DEPTH; |
| 6694 | break; |
| 6695 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 6696 | image_info->depth=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6697 | break; |
| 6698 | } |
cristy | c9b1295 | 2010-03-28 01:12:28 +0000 | [diff] [blame] | 6699 | if (LocaleCompare("direction",option+1) == 0) |
| 6700 | { |
| 6701 | if (*option == '+') |
| 6702 | { |
| 6703 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6704 | break; |
| 6705 | } |
| 6706 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6707 | break; |
| 6708 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6709 | if (LocaleCompare("display",option+1) == 0) |
| 6710 | { |
| 6711 | if (*option == '+') |
| 6712 | { |
| 6713 | if (image_info->server_name != (char *) NULL) |
| 6714 | image_info->server_name=DestroyString( |
| 6715 | image_info->server_name); |
| 6716 | break; |
| 6717 | } |
| 6718 | (void) CloneString(&image_info->server_name,argv[i+1]); |
| 6719 | break; |
| 6720 | } |
| 6721 | if (LocaleCompare("dispose",option+1) == 0) |
| 6722 | { |
| 6723 | if (*option == '+') |
| 6724 | { |
| 6725 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6726 | break; |
| 6727 | } |
| 6728 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6729 | break; |
| 6730 | } |
| 6731 | if (LocaleCompare("dither",option+1) == 0) |
| 6732 | { |
| 6733 | if (*option == '+') |
| 6734 | { |
| 6735 | image_info->dither=MagickFalse; |
cristy | d5acfd1 | 2010-06-15 00:11:38 +0000 | [diff] [blame^] | 6736 | (void) SetImageOption(image_info,option+1,"none"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6737 | break; |
| 6738 | } |
| 6739 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6740 | image_info->dither=MagickTrue; |
| 6741 | break; |
| 6742 | } |
| 6743 | break; |
| 6744 | } |
| 6745 | case 'e': |
| 6746 | { |
| 6747 | if (LocaleCompare("encoding",option+1) == 0) |
| 6748 | { |
| 6749 | if (*option == '+') |
| 6750 | { |
| 6751 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6752 | break; |
| 6753 | } |
| 6754 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6755 | break; |
| 6756 | } |
| 6757 | if (LocaleCompare("endian",option+1) == 0) |
| 6758 | { |
| 6759 | if (*option == '+') |
| 6760 | { |
| 6761 | image_info->endian=UndefinedEndian; |
| 6762 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6763 | break; |
| 6764 | } |
| 6765 | image_info->endian=(EndianType) ParseMagickOption( |
| 6766 | MagickEndianOptions,MagickFalse,argv[i+1]); |
| 6767 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6768 | break; |
| 6769 | } |
| 6770 | if (LocaleCompare("extract",option+1) == 0) |
| 6771 | { |
| 6772 | /* |
| 6773 | Set image extract geometry. |
| 6774 | */ |
| 6775 | if (*option == '+') |
| 6776 | { |
| 6777 | if (image_info->extract != (char *) NULL) |
| 6778 | image_info->extract=DestroyString(image_info->extract); |
| 6779 | break; |
| 6780 | } |
| 6781 | (void) CloneString(&image_info->extract,argv[i+1]); |
| 6782 | break; |
| 6783 | } |
| 6784 | break; |
| 6785 | } |
| 6786 | case 'f': |
| 6787 | { |
| 6788 | if (LocaleCompare("fill",option+1) == 0) |
| 6789 | { |
| 6790 | if (*option == '+') |
| 6791 | { |
| 6792 | (void) SetImageOption(image_info,option+1,"none"); |
| 6793 | break; |
| 6794 | } |
| 6795 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6796 | break; |
| 6797 | } |
| 6798 | if (LocaleCompare("filter",option+1) == 0) |
| 6799 | { |
| 6800 | if (*option == '+') |
| 6801 | { |
| 6802 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6803 | break; |
| 6804 | } |
| 6805 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6806 | break; |
| 6807 | } |
| 6808 | if (LocaleCompare("font",option+1) == 0) |
| 6809 | { |
| 6810 | if (*option == '+') |
| 6811 | { |
| 6812 | if (image_info->font != (char *) NULL) |
| 6813 | image_info->font=DestroyString(image_info->font); |
| 6814 | break; |
| 6815 | } |
| 6816 | (void) CloneString(&image_info->font,argv[i+1]); |
| 6817 | break; |
| 6818 | } |
| 6819 | if (LocaleCompare("format",option+1) == 0) |
| 6820 | { |
| 6821 | register const char |
| 6822 | *q; |
| 6823 | |
| 6824 | for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) |
| 6825 | if (strchr("gkrz@[#",*(q+1)) != (char *) NULL) |
| 6826 | image_info->ping=MagickFalse; |
| 6827 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6828 | break; |
| 6829 | } |
| 6830 | if (LocaleCompare("fuzz",option+1) == 0) |
| 6831 | { |
| 6832 | if (*option == '+') |
| 6833 | { |
| 6834 | image_info->fuzz=0.0; |
| 6835 | (void) SetImageOption(image_info,option+1,"0"); |
| 6836 | break; |
| 6837 | } |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6838 | image_info->fuzz=SiPrefixToDouble(argv[i+1],(double) QuantumRange+ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6839 | 1.0); |
| 6840 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6841 | break; |
| 6842 | } |
| 6843 | break; |
| 6844 | } |
| 6845 | case 'g': |
| 6846 | { |
| 6847 | if (LocaleCompare("gravity",option+1) == 0) |
| 6848 | { |
| 6849 | if (*option == '+') |
| 6850 | { |
| 6851 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6852 | break; |
| 6853 | } |
| 6854 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6855 | break; |
| 6856 | } |
| 6857 | if (LocaleCompare("green-primary",option+1) == 0) |
| 6858 | { |
| 6859 | if (*option == '+') |
| 6860 | { |
| 6861 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 6862 | break; |
| 6863 | } |
| 6864 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6865 | break; |
| 6866 | } |
| 6867 | break; |
| 6868 | } |
| 6869 | case 'i': |
| 6870 | { |
| 6871 | if (LocaleCompare("intent",option+1) == 0) |
| 6872 | { |
| 6873 | if (*option == '+') |
| 6874 | { |
| 6875 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6876 | break; |
| 6877 | } |
| 6878 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6879 | break; |
| 6880 | } |
| 6881 | if (LocaleCompare("interlace",option+1) == 0) |
| 6882 | { |
| 6883 | if (*option == '+') |
| 6884 | { |
| 6885 | image_info->interlace=UndefinedInterlace; |
| 6886 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6887 | break; |
| 6888 | } |
| 6889 | image_info->interlace=(InterlaceType) ParseMagickOption( |
| 6890 | MagickInterlaceOptions,MagickFalse,argv[i+1]); |
| 6891 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6892 | break; |
| 6893 | } |
cristy | b32b90a | 2009-09-07 21:45:48 +0000 | [diff] [blame] | 6894 | if (LocaleCompare("interline-spacing",option+1) == 0) |
| 6895 | { |
| 6896 | if (*option == '+') |
| 6897 | { |
| 6898 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6899 | break; |
| 6900 | } |
| 6901 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6902 | break; |
| 6903 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6904 | if (LocaleCompare("interpolate",option+1) == 0) |
| 6905 | { |
| 6906 | if (*option == '+') |
| 6907 | { |
| 6908 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6909 | break; |
| 6910 | } |
| 6911 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6912 | break; |
| 6913 | } |
| 6914 | if (LocaleCompare("interword-spacing",option+1) == 0) |
| 6915 | { |
| 6916 | if (*option == '+') |
| 6917 | { |
| 6918 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6919 | break; |
| 6920 | } |
| 6921 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6922 | break; |
| 6923 | } |
| 6924 | break; |
| 6925 | } |
| 6926 | case 'k': |
| 6927 | { |
| 6928 | if (LocaleCompare("kerning",option+1) == 0) |
| 6929 | { |
| 6930 | if (*option == '+') |
| 6931 | { |
| 6932 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 6933 | break; |
| 6934 | } |
| 6935 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6936 | break; |
| 6937 | } |
| 6938 | break; |
| 6939 | } |
| 6940 | case 'l': |
| 6941 | { |
| 6942 | if (LocaleCompare("label",option+1) == 0) |
| 6943 | { |
| 6944 | if (*option == '+') |
| 6945 | { |
| 6946 | (void) DeleteImageOption(image_info,option+1); |
| 6947 | break; |
| 6948 | } |
| 6949 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 6950 | break; |
| 6951 | } |
| 6952 | if (LocaleCompare("limit",option+1) == 0) |
| 6953 | { |
| 6954 | MagickSizeType |
| 6955 | limit; |
| 6956 | |
| 6957 | ResourceType |
| 6958 | type; |
| 6959 | |
| 6960 | if (*option == '+') |
| 6961 | break; |
| 6962 | type=(ResourceType) ParseMagickOption(MagickResourceOptions, |
| 6963 | MagickFalse,argv[i+1]); |
| 6964 | limit=MagickResourceInfinity; |
| 6965 | if (LocaleCompare("unlimited",argv[i+2]) != 0) |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 6966 | limit=(MagickSizeType) SiPrefixToDouble(argv[i+2],100.0); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6967 | (void) SetMagickResourceLimit(type,limit); |
| 6968 | break; |
| 6969 | } |
| 6970 | if (LocaleCompare("list",option+1) == 0) |
| 6971 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 6972 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 6973 | list; |
| 6974 | |
| 6975 | /* |
| 6976 | Display configuration list. |
| 6977 | */ |
| 6978 | list=ParseMagickOption(MagickListOptions,MagickFalse,argv[i+1]); |
| 6979 | switch (list) |
| 6980 | { |
| 6981 | case MagickCoderOptions: |
| 6982 | { |
| 6983 | (void) ListCoderInfo((FILE *) NULL,exception); |
| 6984 | break; |
| 6985 | } |
| 6986 | case MagickColorOptions: |
| 6987 | { |
| 6988 | (void) ListColorInfo((FILE *) NULL,exception); |
| 6989 | break; |
| 6990 | } |
| 6991 | case MagickConfigureOptions: |
| 6992 | { |
| 6993 | (void) ListConfigureInfo((FILE *) NULL,exception); |
| 6994 | break; |
| 6995 | } |
| 6996 | case MagickDelegateOptions: |
| 6997 | { |
| 6998 | (void) ListDelegateInfo((FILE *) NULL,exception); |
| 6999 | break; |
| 7000 | } |
| 7001 | case MagickFontOptions: |
| 7002 | { |
| 7003 | (void) ListTypeInfo((FILE *) NULL,exception); |
| 7004 | break; |
| 7005 | } |
| 7006 | case MagickFormatOptions: |
| 7007 | { |
| 7008 | (void) ListMagickInfo((FILE *) NULL,exception); |
| 7009 | break; |
| 7010 | } |
| 7011 | case MagickLocaleOptions: |
| 7012 | { |
| 7013 | (void) ListLocaleInfo((FILE *) NULL,exception); |
| 7014 | break; |
| 7015 | } |
| 7016 | case MagickLogOptions: |
| 7017 | { |
| 7018 | (void) ListLogInfo((FILE *) NULL,exception); |
| 7019 | break; |
| 7020 | } |
| 7021 | case MagickMagicOptions: |
| 7022 | { |
| 7023 | (void) ListMagicInfo((FILE *) NULL,exception); |
| 7024 | break; |
| 7025 | } |
| 7026 | case MagickMimeOptions: |
| 7027 | { |
| 7028 | (void) ListMimeInfo((FILE *) NULL,exception); |
| 7029 | break; |
| 7030 | } |
| 7031 | case MagickModuleOptions: |
| 7032 | { |
| 7033 | (void) ListModuleInfo((FILE *) NULL,exception); |
| 7034 | break; |
| 7035 | } |
| 7036 | case MagickPolicyOptions: |
| 7037 | { |
| 7038 | (void) ListPolicyInfo((FILE *) NULL,exception); |
| 7039 | break; |
| 7040 | } |
| 7041 | case MagickResourceOptions: |
| 7042 | { |
| 7043 | (void) ListMagickResourceInfo((FILE *) NULL,exception); |
| 7044 | break; |
| 7045 | } |
| 7046 | case MagickThresholdOptions: |
| 7047 | { |
| 7048 | (void) ListThresholdMaps((FILE *) NULL,exception); |
| 7049 | break; |
| 7050 | } |
| 7051 | default: |
| 7052 | { |
| 7053 | (void) ListMagickOptions((FILE *) NULL,(MagickOption) list, |
| 7054 | exception); |
| 7055 | break; |
| 7056 | } |
| 7057 | } |
cristy | aeb2cbc | 2010-05-07 13:28:58 +0000 | [diff] [blame] | 7058 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7059 | } |
| 7060 | if (LocaleCompare("log",option+1) == 0) |
| 7061 | { |
| 7062 | if (*option == '+') |
| 7063 | break; |
| 7064 | (void) SetLogFormat(argv[i+1]); |
| 7065 | break; |
| 7066 | } |
| 7067 | if (LocaleCompare("loop",option+1) == 0) |
| 7068 | { |
| 7069 | if (*option == '+') |
| 7070 | { |
| 7071 | (void) SetImageOption(image_info,option+1,"0"); |
| 7072 | break; |
| 7073 | } |
| 7074 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7075 | break; |
| 7076 | } |
| 7077 | break; |
| 7078 | } |
| 7079 | case 'm': |
| 7080 | { |
| 7081 | if (LocaleCompare("matte",option+1) == 0) |
| 7082 | { |
| 7083 | if (*option == '+') |
| 7084 | { |
| 7085 | (void) SetImageOption(image_info,option+1,"false"); |
| 7086 | break; |
| 7087 | } |
| 7088 | (void) SetImageOption(image_info,option+1,"true"); |
| 7089 | break; |
| 7090 | } |
| 7091 | if (LocaleCompare("mattecolor",option+1) == 0) |
| 7092 | { |
| 7093 | if (*option == '+') |
| 7094 | { |
| 7095 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7096 | (void) QueryColorDatabase(MatteColor,&image_info->matte_color, |
| 7097 | exception); |
| 7098 | break; |
| 7099 | } |
| 7100 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7101 | (void) QueryColorDatabase(argv[i+1],&image_info->matte_color, |
| 7102 | exception); |
| 7103 | break; |
| 7104 | } |
| 7105 | if (LocaleCompare("monitor",option+1) == 0) |
| 7106 | { |
| 7107 | (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, |
| 7108 | (void *) NULL); |
| 7109 | break; |
| 7110 | } |
| 7111 | if (LocaleCompare("monochrome",option+1) == 0) |
| 7112 | { |
| 7113 | image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; |
| 7114 | break; |
| 7115 | } |
| 7116 | break; |
| 7117 | } |
| 7118 | case 'o': |
| 7119 | { |
| 7120 | if (LocaleCompare("orient",option+1) == 0) |
| 7121 | { |
| 7122 | if (*option == '+') |
| 7123 | { |
| 7124 | image_info->orientation=UndefinedOrientation; |
| 7125 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7126 | break; |
| 7127 | } |
| 7128 | image_info->orientation=(OrientationType) ParseMagickOption( |
| 7129 | MagickOrientationOptions,MagickFalse,argv[i+1]); |
| 7130 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7131 | break; |
| 7132 | } |
| 7133 | } |
| 7134 | case 'p': |
| 7135 | { |
| 7136 | if (LocaleCompare("page",option+1) == 0) |
| 7137 | { |
| 7138 | char |
| 7139 | *canonical_page, |
| 7140 | page[MaxTextExtent]; |
| 7141 | |
| 7142 | const char |
| 7143 | *image_option; |
| 7144 | |
| 7145 | MagickStatusType |
| 7146 | flags; |
| 7147 | |
| 7148 | RectangleInfo |
| 7149 | geometry; |
| 7150 | |
| 7151 | if (*option == '+') |
| 7152 | { |
| 7153 | (void) DeleteImageOption(image_info,option+1); |
| 7154 | (void) CloneString(&image_info->page,(char *) NULL); |
| 7155 | break; |
| 7156 | } |
| 7157 | (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); |
| 7158 | image_option=GetImageOption(image_info,"page"); |
| 7159 | if (image_option != (const char *) NULL) |
| 7160 | flags=ParseAbsoluteGeometry(image_option,&geometry); |
| 7161 | canonical_page=GetPageGeometry(argv[i+1]); |
| 7162 | flags=ParseAbsoluteGeometry(canonical_page,&geometry); |
| 7163 | canonical_page=DestroyString(canonical_page); |
| 7164 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 7165 | (unsigned long) geometry.width,(unsigned long) geometry.height); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7166 | if (((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7167 | (void) FormatMagickString(page,MaxTextExtent,"%lux%lu%+ld%+ld", |
cristy | f2faecf | 2010-05-28 19:19:36 +0000 | [diff] [blame] | 7168 | (unsigned long) geometry.width,(unsigned long) geometry.height, |
| 7169 | (long) geometry.x,(long) geometry.y); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7170 | (void) SetImageOption(image_info,option+1,page); |
| 7171 | (void) CloneString(&image_info->page,page); |
| 7172 | break; |
| 7173 | } |
| 7174 | if (LocaleCompare("pen",option+1) == 0) |
| 7175 | { |
| 7176 | if (*option == '+') |
| 7177 | { |
| 7178 | (void) SetImageOption(image_info,option+1,"none"); |
| 7179 | break; |
| 7180 | } |
| 7181 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7182 | break; |
| 7183 | } |
| 7184 | if (LocaleCompare("ping",option+1) == 0) |
| 7185 | { |
| 7186 | image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; |
| 7187 | break; |
| 7188 | } |
| 7189 | if (LocaleCompare("pointsize",option+1) == 0) |
| 7190 | { |
| 7191 | if (*option == '+') |
| 7192 | geometry_info.rho=0.0; |
| 7193 | else |
| 7194 | (void) ParseGeometry(argv[i+1],&geometry_info); |
| 7195 | image_info->pointsize=geometry_info.rho; |
| 7196 | break; |
| 7197 | } |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 7198 | if (LocaleCompare("precision",option+1) == 0) |
| 7199 | { |
cristy | bf2766a | 2010-01-17 03:33:23 +0000 | [diff] [blame] | 7200 | (void) SetMagickPrecision(StringToInteger(argv[i+1])); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 7201 | break; |
| 7202 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7203 | if (LocaleCompare("preview",option+1) == 0) |
| 7204 | { |
| 7205 | /* |
| 7206 | Preview image. |
| 7207 | */ |
| 7208 | if (*option == '+') |
| 7209 | { |
| 7210 | image_info->preview_type=UndefinedPreview; |
| 7211 | break; |
| 7212 | } |
| 7213 | image_info->preview_type=(PreviewType) ParseMagickOption( |
| 7214 | MagickPreviewOptions,MagickFalse,argv[i+1]); |
| 7215 | break; |
| 7216 | } |
| 7217 | break; |
| 7218 | } |
| 7219 | case 'q': |
| 7220 | { |
| 7221 | if (LocaleCompare("quality",option+1) == 0) |
| 7222 | { |
| 7223 | /* |
| 7224 | Set image compression quality. |
| 7225 | */ |
| 7226 | if (*option == '+') |
| 7227 | { |
| 7228 | image_info->quality=UndefinedCompressionQuality; |
| 7229 | (void) SetImageOption(image_info,option+1,"0"); |
| 7230 | break; |
| 7231 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7232 | image_info->quality=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7233 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7234 | break; |
| 7235 | } |
| 7236 | if (LocaleCompare("quiet",option+1) == 0) |
| 7237 | { |
| 7238 | static WarningHandler |
| 7239 | warning_handler = (WarningHandler) NULL; |
| 7240 | |
| 7241 | if (*option == '+') |
| 7242 | { |
| 7243 | /* |
| 7244 | Restore error or warning messages. |
| 7245 | */ |
| 7246 | warning_handler=SetWarningHandler(warning_handler); |
| 7247 | break; |
| 7248 | } |
| 7249 | /* |
| 7250 | Suppress error or warning messages. |
| 7251 | */ |
| 7252 | warning_handler=SetWarningHandler((WarningHandler) NULL); |
| 7253 | break; |
| 7254 | } |
| 7255 | break; |
| 7256 | } |
| 7257 | case 'r': |
| 7258 | { |
| 7259 | if (LocaleCompare("red-primary",option+1) == 0) |
| 7260 | { |
| 7261 | if (*option == '+') |
| 7262 | { |
| 7263 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7264 | break; |
| 7265 | } |
| 7266 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7267 | break; |
| 7268 | } |
| 7269 | break; |
| 7270 | } |
| 7271 | case 's': |
| 7272 | { |
| 7273 | if (LocaleCompare("sampling-factor",option+1) == 0) |
| 7274 | { |
| 7275 | /* |
| 7276 | Set image sampling factor. |
| 7277 | */ |
| 7278 | if (*option == '+') |
| 7279 | { |
| 7280 | if (image_info->sampling_factor != (char *) NULL) |
| 7281 | image_info->sampling_factor=DestroyString( |
| 7282 | image_info->sampling_factor); |
| 7283 | break; |
| 7284 | } |
| 7285 | (void) CloneString(&image_info->sampling_factor,argv[i+1]); |
| 7286 | break; |
| 7287 | } |
| 7288 | if (LocaleCompare("scene",option+1) == 0) |
| 7289 | { |
| 7290 | /* |
| 7291 | Set image scene. |
| 7292 | */ |
| 7293 | if (*option == '+') |
| 7294 | { |
| 7295 | image_info->scene=0; |
| 7296 | (void) SetImageOption(image_info,option+1,"0"); |
| 7297 | break; |
| 7298 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7299 | image_info->scene=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7300 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7301 | break; |
| 7302 | } |
| 7303 | if (LocaleCompare("seed",option+1) == 0) |
| 7304 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7305 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7306 | seed; |
| 7307 | |
| 7308 | if (*option == '+') |
| 7309 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7310 | seed=(size_t) time((time_t *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7311 | SeedPseudoRandomGenerator(seed); |
| 7312 | break; |
| 7313 | } |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 7314 | seed=StringToUnsignedLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7315 | SeedPseudoRandomGenerator(seed); |
| 7316 | break; |
| 7317 | } |
| 7318 | if (LocaleCompare("size",option+1) == 0) |
| 7319 | { |
| 7320 | if (*option == '+') |
| 7321 | { |
| 7322 | if (image_info->size != (char *) NULL) |
| 7323 | image_info->size=DestroyString(image_info->size); |
| 7324 | break; |
| 7325 | } |
| 7326 | (void) CloneString(&image_info->size,argv[i+1]); |
| 7327 | break; |
| 7328 | } |
| 7329 | if (LocaleCompare("stroke",option+1) == 0) |
| 7330 | { |
| 7331 | if (*option == '+') |
| 7332 | { |
| 7333 | (void) SetImageOption(image_info,option+1,"none"); |
| 7334 | break; |
| 7335 | } |
| 7336 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7337 | break; |
| 7338 | } |
| 7339 | if (LocaleCompare("strokewidth",option+1) == 0) |
| 7340 | { |
| 7341 | if (*option == '+') |
| 7342 | { |
| 7343 | (void) SetImageOption(image_info,option+1,"0"); |
| 7344 | break; |
| 7345 | } |
| 7346 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7347 | break; |
| 7348 | } |
| 7349 | break; |
| 7350 | } |
| 7351 | case 't': |
| 7352 | { |
| 7353 | if (LocaleCompare("taint",option+1) == 0) |
| 7354 | { |
| 7355 | if (*option == '+') |
| 7356 | { |
| 7357 | (void) SetImageOption(image_info,option+1,"false"); |
| 7358 | break; |
| 7359 | } |
| 7360 | (void) SetImageOption(image_info,option+1,"true"); |
| 7361 | break; |
| 7362 | } |
| 7363 | if (LocaleCompare("texture",option+1) == 0) |
| 7364 | { |
| 7365 | if (*option == '+') |
| 7366 | { |
| 7367 | if (image_info->texture != (char *) NULL) |
| 7368 | image_info->texture=DestroyString(image_info->texture); |
| 7369 | break; |
| 7370 | } |
| 7371 | (void) CloneString(&image_info->texture,argv[i+1]); |
| 7372 | break; |
| 7373 | } |
| 7374 | if (LocaleCompare("tile-offset",option+1) == 0) |
| 7375 | { |
| 7376 | if (*option == '+') |
| 7377 | { |
| 7378 | (void) SetImageOption(image_info,option+1,"0"); |
| 7379 | break; |
| 7380 | } |
| 7381 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7382 | break; |
| 7383 | } |
| 7384 | if (LocaleCompare("transparent-color",option+1) == 0) |
| 7385 | { |
| 7386 | if (*option == '+') |
| 7387 | { |
| 7388 | (void) QueryColorDatabase("none",&image_info->transparent_color, exception); |
| 7389 | (void) SetImageOption(image_info,option+1,"none"); |
| 7390 | break; |
| 7391 | } |
| 7392 | (void) QueryColorDatabase(argv[i+1],&image_info->transparent_color, |
| 7393 | exception); |
| 7394 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7395 | break; |
| 7396 | } |
| 7397 | if (LocaleCompare("type",option+1) == 0) |
| 7398 | { |
| 7399 | if (*option == '+') |
| 7400 | { |
| 7401 | image_info->type=UndefinedType; |
| 7402 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7403 | break; |
| 7404 | } |
| 7405 | image_info->type=(ImageType) ParseMagickOption(MagickTypeOptions, |
| 7406 | MagickFalse,argv[i+1]); |
| 7407 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7408 | break; |
| 7409 | } |
| 7410 | break; |
| 7411 | } |
| 7412 | case 'u': |
| 7413 | { |
| 7414 | if (LocaleCompare("undercolor",option+1) == 0) |
| 7415 | { |
| 7416 | if (*option == '+') |
| 7417 | { |
| 7418 | (void) DeleteImageOption(image_info,option+1); |
| 7419 | break; |
| 7420 | } |
| 7421 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7422 | break; |
| 7423 | } |
| 7424 | if (LocaleCompare("units",option+1) == 0) |
| 7425 | { |
| 7426 | if (*option == '+') |
| 7427 | { |
| 7428 | image_info->units=UndefinedResolution; |
| 7429 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7430 | break; |
| 7431 | } |
| 7432 | image_info->units=(ResolutionType) ParseMagickOption( |
| 7433 | MagickResolutionOptions,MagickFalse,argv[i+1]); |
| 7434 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7435 | break; |
| 7436 | } |
| 7437 | break; |
| 7438 | } |
| 7439 | case 'v': |
| 7440 | { |
| 7441 | if (LocaleCompare("verbose",option+1) == 0) |
| 7442 | { |
| 7443 | if (*option == '+') |
| 7444 | { |
| 7445 | image_info->verbose=MagickFalse; |
| 7446 | break; |
| 7447 | } |
| 7448 | image_info->verbose=MagickTrue; |
| 7449 | image_info->ping=MagickFalse; |
| 7450 | break; |
| 7451 | } |
| 7452 | if (LocaleCompare("view",option+1) == 0) |
| 7453 | { |
| 7454 | if (*option == '+') |
| 7455 | { |
| 7456 | if (image_info->view != (char *) NULL) |
| 7457 | image_info->view=DestroyString(image_info->view); |
| 7458 | break; |
| 7459 | } |
| 7460 | (void) CloneString(&image_info->view,argv[i+1]); |
| 7461 | break; |
| 7462 | } |
| 7463 | if (LocaleCompare("virtual-pixel",option+1) == 0) |
| 7464 | { |
| 7465 | if (*option == '+') |
| 7466 | { |
| 7467 | image_info->virtual_pixel_method=UndefinedVirtualPixelMethod; |
| 7468 | (void) SetImageOption(image_info,option+1,"undefined"); |
| 7469 | break; |
| 7470 | } |
| 7471 | image_info->virtual_pixel_method=(VirtualPixelMethod) |
| 7472 | ParseMagickOption(MagickVirtualPixelOptions,MagickFalse, |
| 7473 | argv[i+1]); |
| 7474 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7475 | break; |
| 7476 | } |
| 7477 | break; |
| 7478 | } |
| 7479 | case 'w': |
| 7480 | { |
| 7481 | if (LocaleCompare("white-point",option+1) == 0) |
| 7482 | { |
| 7483 | if (*option == '+') |
| 7484 | { |
| 7485 | (void) SetImageOption(image_info,option+1,"0.0"); |
| 7486 | break; |
| 7487 | } |
| 7488 | (void) SetImageOption(image_info,option+1,argv[i+1]); |
| 7489 | break; |
| 7490 | } |
| 7491 | break; |
| 7492 | } |
| 7493 | default: |
| 7494 | break; |
| 7495 | } |
| 7496 | i+=count; |
| 7497 | } |
| 7498 | return(MagickTrue); |
| 7499 | } |
| 7500 | |
| 7501 | /* |
| 7502 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7503 | % % |
| 7504 | % % |
| 7505 | % % |
| 7506 | + M o g r i f y I m a g e L i s t % |
| 7507 | % % |
| 7508 | % % |
| 7509 | % % |
| 7510 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 7511 | % |
| 7512 | % MogrifyImageList() applies any command line options that might affect the |
| 7513 | % entire image list (e.g. -append, -coalesce, etc.). |
| 7514 | % |
| 7515 | % The format of the MogrifyImage method is: |
| 7516 | % |
| 7517 | % MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, |
| 7518 | % const char **argv,Image **images,ExceptionInfo *exception) |
| 7519 | % |
| 7520 | % A description of each parameter follows: |
| 7521 | % |
| 7522 | % o image_info: the image info.. |
| 7523 | % |
| 7524 | % o argc: Specifies a pointer to an integer describing the number of |
| 7525 | % elements in the argument vector. |
| 7526 | % |
| 7527 | % o argv: Specifies a pointer to a text array containing the command line |
| 7528 | % arguments. |
| 7529 | % |
| 7530 | % o images: the images. |
| 7531 | % |
| 7532 | % o exception: return any errors or warnings in this structure. |
| 7533 | % |
| 7534 | */ |
| 7535 | WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, |
| 7536 | const int argc,const char **argv,Image **images,ExceptionInfo *exception) |
| 7537 | { |
| 7538 | ChannelType |
| 7539 | channel; |
| 7540 | |
| 7541 | const char |
| 7542 | *option; |
| 7543 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7544 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7545 | count, |
| 7546 | index; |
| 7547 | |
| 7548 | MagickStatusType |
| 7549 | status; |
| 7550 | |
| 7551 | QuantizeInfo |
| 7552 | *quantize_info; |
| 7553 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7554 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7555 | i; |
| 7556 | |
| 7557 | /* |
| 7558 | Apply options to the image list. |
| 7559 | */ |
| 7560 | assert(image_info != (ImageInfo *) NULL); |
| 7561 | assert(image_info->signature == MagickSignature); |
| 7562 | assert(images != (Image **) NULL); |
| 7563 | assert((*images)->signature == MagickSignature); |
| 7564 | if ((*images)->debug != MagickFalse) |
| 7565 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 7566 | (*images)->filename); |
| 7567 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 7568 | return(MagickTrue); |
| 7569 | quantize_info=AcquireQuantizeInfo(image_info); |
| 7570 | channel=image_info->channel; |
| 7571 | status=MagickTrue; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7572 | for (i=0; i < (ssize_t) argc; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7573 | { |
cristy | 74fe8f1 | 2009-10-03 19:09:01 +0000 | [diff] [blame] | 7574 | if (*images == (Image *) NULL) |
| 7575 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7576 | option=argv[i]; |
| 7577 | if (IsMagickOption(option) == MagickFalse) |
| 7578 | continue; |
| 7579 | count=MagickMax(ParseMagickOption(MagickCommandOptions,MagickFalse,option), |
| 7580 | 0L); |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7581 | if ((i+count) >= (ssize_t) argc) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7582 | break; |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 7583 | status=MogrifyImageInfo(image_info,(int) count+1,argv+i,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7584 | switch (*(option+1)) |
| 7585 | { |
| 7586 | case 'a': |
| 7587 | { |
| 7588 | if (LocaleCompare("affinity",option+1) == 0) |
| 7589 | { |
| 7590 | (void) SyncImagesSettings(image_info,*images); |
| 7591 | if (*option == '+') |
| 7592 | { |
| 7593 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 7594 | InheritException(exception,&(*images)->exception); |
| 7595 | break; |
| 7596 | } |
| 7597 | i++; |
| 7598 | break; |
| 7599 | } |
| 7600 | if (LocaleCompare("append",option+1) == 0) |
| 7601 | { |
| 7602 | Image |
| 7603 | *append_image; |
| 7604 | |
| 7605 | (void) SyncImagesSettings(image_info,*images); |
| 7606 | append_image=AppendImages(*images,*option == '-' ? MagickTrue : |
| 7607 | MagickFalse,exception); |
| 7608 | if (append_image == (Image *) NULL) |
| 7609 | { |
| 7610 | status=MagickFalse; |
| 7611 | break; |
| 7612 | } |
| 7613 | *images=DestroyImageList(*images); |
| 7614 | *images=append_image; |
| 7615 | break; |
| 7616 | } |
| 7617 | if (LocaleCompare("average",option+1) == 0) |
| 7618 | { |
| 7619 | Image |
| 7620 | *average_image; |
| 7621 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7622 | /* |
| 7623 | Average an image sequence (deprecated). |
| 7624 | */ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7625 | (void) SyncImagesSettings(image_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7626 | average_image=EvaluateImages(*images,MeanEvaluateOperator, |
| 7627 | exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7628 | if (average_image == (Image *) NULL) |
| 7629 | { |
| 7630 | status=MagickFalse; |
| 7631 | break; |
| 7632 | } |
| 7633 | *images=DestroyImageList(*images); |
| 7634 | *images=average_image; |
| 7635 | break; |
| 7636 | } |
| 7637 | break; |
| 7638 | } |
| 7639 | case 'c': |
| 7640 | { |
| 7641 | if (LocaleCompare("channel",option+1) == 0) |
| 7642 | { |
| 7643 | if (*option == '+') |
| 7644 | { |
| 7645 | channel=DefaultChannels; |
| 7646 | break; |
| 7647 | } |
| 7648 | channel=(ChannelType) ParseChannelOption(argv[i+1]); |
| 7649 | break; |
| 7650 | } |
| 7651 | if (LocaleCompare("clut",option+1) == 0) |
| 7652 | { |
| 7653 | Image |
| 7654 | *clut_image, |
| 7655 | *image; |
| 7656 | |
| 7657 | (void) SyncImagesSettings(image_info,*images); |
| 7658 | image=RemoveFirstImageFromList(images); |
| 7659 | clut_image=RemoveFirstImageFromList(images); |
| 7660 | if (clut_image == (Image *) NULL) |
| 7661 | { |
| 7662 | status=MagickFalse; |
| 7663 | break; |
| 7664 | } |
| 7665 | (void) ClutImageChannel(image,channel,clut_image); |
| 7666 | clut_image=DestroyImage(clut_image); |
| 7667 | InheritException(exception,&image->exception); |
| 7668 | *images=DestroyImageList(*images); |
| 7669 | *images=image; |
| 7670 | break; |
| 7671 | } |
| 7672 | if (LocaleCompare("coalesce",option+1) == 0) |
| 7673 | { |
| 7674 | Image |
| 7675 | *coalesce_image; |
| 7676 | |
| 7677 | (void) SyncImagesSettings(image_info,*images); |
| 7678 | coalesce_image=CoalesceImages(*images,exception); |
| 7679 | if (coalesce_image == (Image *) NULL) |
| 7680 | { |
| 7681 | status=MagickFalse; |
| 7682 | break; |
| 7683 | } |
| 7684 | *images=DestroyImageList(*images); |
| 7685 | *images=coalesce_image; |
| 7686 | break; |
| 7687 | } |
| 7688 | if (LocaleCompare("combine",option+1) == 0) |
| 7689 | { |
| 7690 | Image |
| 7691 | *combine_image; |
| 7692 | |
| 7693 | (void) SyncImagesSettings(image_info,*images); |
| 7694 | combine_image=CombineImages(*images,channel,exception); |
| 7695 | if (combine_image == (Image *) NULL) |
| 7696 | { |
| 7697 | status=MagickFalse; |
| 7698 | break; |
| 7699 | } |
| 7700 | *images=DestroyImageList(*images); |
| 7701 | *images=combine_image; |
| 7702 | break; |
| 7703 | } |
| 7704 | if (LocaleCompare("composite",option+1) == 0) |
| 7705 | { |
| 7706 | Image |
| 7707 | *mask_image, |
| 7708 | *composite_image, |
| 7709 | *image; |
| 7710 | |
| 7711 | RectangleInfo |
| 7712 | geometry; |
| 7713 | |
| 7714 | (void) SyncImagesSettings(image_info,*images); |
| 7715 | image=RemoveFirstImageFromList(images); |
| 7716 | composite_image=RemoveFirstImageFromList(images); |
| 7717 | if (composite_image == (Image *) NULL) |
| 7718 | { |
| 7719 | status=MagickFalse; |
| 7720 | break; |
| 7721 | } |
| 7722 | (void) TransformImage(&composite_image,(char *) NULL, |
| 7723 | composite_image->geometry); |
| 7724 | SetGeometry(composite_image,&geometry); |
| 7725 | (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); |
| 7726 | GravityAdjustGeometry(image->columns,image->rows,image->gravity, |
| 7727 | &geometry); |
| 7728 | mask_image=RemoveFirstImageFromList(images); |
| 7729 | if (mask_image != (Image *) NULL) |
| 7730 | { |
| 7731 | if ((image->compose == DisplaceCompositeOp) || |
| 7732 | (image->compose == DistortCompositeOp)) |
| 7733 | { |
| 7734 | /* |
| 7735 | Merge Y displacement into X displacement image. |
| 7736 | */ |
| 7737 | (void) CompositeImage(composite_image,CopyGreenCompositeOp, |
| 7738 | mask_image,0,0); |
| 7739 | mask_image=DestroyImage(mask_image); |
| 7740 | } |
| 7741 | else |
| 7742 | { |
| 7743 | /* |
| 7744 | Set a blending mask for the composition. |
| 7745 | */ |
| 7746 | image->mask=mask_image; |
| 7747 | (void) NegateImage(image->mask,MagickFalse); |
| 7748 | } |
| 7749 | } |
| 7750 | (void) CompositeImageChannel(image,channel,image->compose, |
| 7751 | composite_image,geometry.x,geometry.y); |
| 7752 | if (image->mask != (Image *) NULL) |
| 7753 | image->mask=DestroyImage(image->mask); |
| 7754 | composite_image=DestroyImage(composite_image); |
| 7755 | InheritException(exception,&image->exception); |
| 7756 | *images=DestroyImageList(*images); |
| 7757 | *images=image; |
| 7758 | break; |
| 7759 | } |
| 7760 | if (LocaleCompare("crop",option+1) == 0) |
| 7761 | { |
| 7762 | MagickStatusType |
| 7763 | flags; |
| 7764 | |
| 7765 | RectangleInfo |
| 7766 | geometry; |
| 7767 | |
| 7768 | (void) SyncImagesSettings(image_info,*images); |
| 7769 | flags=ParseGravityGeometry(*images,argv[i+1],&geometry,exception); |
| 7770 | if (((geometry.width == 0) && (geometry.height == 0)) || |
| 7771 | ((flags & XValue) != 0) || ((flags & YValue) != 0)) |
| 7772 | break; |
| 7773 | (void) TransformImages(images,argv[i+1],(char *) NULL); |
| 7774 | InheritException(exception,&(*images)->exception); |
| 7775 | break; |
| 7776 | } |
| 7777 | break; |
| 7778 | } |
| 7779 | case 'd': |
| 7780 | { |
| 7781 | if (LocaleCompare("deconstruct",option+1) == 0) |
| 7782 | { |
| 7783 | Image |
| 7784 | *deconstruct_image; |
| 7785 | |
| 7786 | (void) SyncImagesSettings(image_info,*images); |
| 7787 | deconstruct_image=DeconstructImages(*images,exception); |
| 7788 | if (deconstruct_image == (Image *) NULL) |
| 7789 | { |
| 7790 | status=MagickFalse; |
| 7791 | break; |
| 7792 | } |
| 7793 | *images=DestroyImageList(*images); |
| 7794 | *images=deconstruct_image; |
| 7795 | break; |
| 7796 | } |
| 7797 | if (LocaleCompare("delete",option+1) == 0) |
| 7798 | { |
| 7799 | if (*option == '+') |
| 7800 | DeleteImages(images,"-1",exception); |
| 7801 | else |
| 7802 | DeleteImages(images,argv[i+1],exception); |
| 7803 | break; |
| 7804 | } |
| 7805 | if (LocaleCompare("dither",option+1) == 0) |
| 7806 | { |
| 7807 | if (*option == '+') |
| 7808 | { |
| 7809 | quantize_info->dither=MagickFalse; |
| 7810 | break; |
| 7811 | } |
| 7812 | quantize_info->dither=MagickTrue; |
| 7813 | quantize_info->dither_method=(DitherMethod) ParseMagickOption( |
| 7814 | MagickDitherOptions,MagickFalse,argv[i+1]); |
| 7815 | break; |
| 7816 | } |
| 7817 | break; |
| 7818 | } |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 7819 | case 'e': |
| 7820 | { |
| 7821 | if (LocaleCompare("evaluate-sequence",option+1) == 0) |
| 7822 | { |
| 7823 | Image |
| 7824 | *evaluate_image; |
| 7825 | |
| 7826 | MagickEvaluateOperator |
| 7827 | op; |
| 7828 | |
| 7829 | (void) SyncImageSettings(image_info,*images); |
| 7830 | op=(MagickEvaluateOperator) ParseMagickOption(MagickEvaluateOptions, |
| 7831 | MagickFalse,argv[i+1]); |
| 7832 | evaluate_image=EvaluateImages(*images,op,exception); |
| 7833 | if (evaluate_image == (Image *) NULL) |
| 7834 | { |
| 7835 | status=MagickFalse; |
| 7836 | break; |
| 7837 | } |
| 7838 | *images=DestroyImageList(*images); |
| 7839 | *images=evaluate_image; |
| 7840 | break; |
| 7841 | } |
| 7842 | break; |
| 7843 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7844 | case 'f': |
| 7845 | { |
cristy | f0a247f | 2009-10-04 00:20:03 +0000 | [diff] [blame] | 7846 | if (LocaleCompare("fft",option+1) == 0) |
| 7847 | { |
| 7848 | Image |
| 7849 | *fourier_image; |
| 7850 | |
| 7851 | /* |
| 7852 | Implements the discrete Fourier transform (DFT). |
| 7853 | */ |
| 7854 | (void) SyncImageSettings(image_info,*images); |
| 7855 | fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? |
| 7856 | MagickTrue : MagickFalse,exception); |
| 7857 | if (fourier_image == (Image *) NULL) |
| 7858 | break; |
| 7859 | *images=DestroyImage(*images); |
| 7860 | *images=fourier_image; |
| 7861 | break; |
| 7862 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7863 | if (LocaleCompare("flatten",option+1) == 0) |
| 7864 | { |
| 7865 | Image |
| 7866 | *flatten_image; |
| 7867 | |
| 7868 | (void) SyncImagesSettings(image_info,*images); |
| 7869 | flatten_image=MergeImageLayers(*images,FlattenLayer,exception); |
| 7870 | if (flatten_image == (Image *) NULL) |
| 7871 | break; |
| 7872 | *images=DestroyImageList(*images); |
| 7873 | *images=flatten_image; |
| 7874 | break; |
| 7875 | } |
| 7876 | if (LocaleCompare("fx",option+1) == 0) |
| 7877 | { |
| 7878 | Image |
| 7879 | *fx_image; |
| 7880 | |
| 7881 | (void) SyncImagesSettings(image_info,*images); |
| 7882 | fx_image=FxImageChannel(*images,channel,argv[i+1],exception); |
| 7883 | if (fx_image == (Image *) NULL) |
| 7884 | { |
| 7885 | status=MagickFalse; |
| 7886 | break; |
| 7887 | } |
| 7888 | *images=DestroyImageList(*images); |
| 7889 | *images=fx_image; |
| 7890 | break; |
| 7891 | } |
| 7892 | break; |
| 7893 | } |
| 7894 | case 'h': |
| 7895 | { |
| 7896 | if (LocaleCompare("hald-clut",option+1) == 0) |
| 7897 | { |
| 7898 | Image |
| 7899 | *hald_image, |
| 7900 | *image; |
| 7901 | |
| 7902 | (void) SyncImagesSettings(image_info,*images); |
| 7903 | image=RemoveFirstImageFromList(images); |
| 7904 | hald_image=RemoveFirstImageFromList(images); |
| 7905 | if (hald_image == (Image *) NULL) |
| 7906 | { |
| 7907 | status=MagickFalse; |
| 7908 | break; |
| 7909 | } |
| 7910 | (void) HaldClutImageChannel(image,channel,hald_image); |
| 7911 | hald_image=DestroyImage(hald_image); |
| 7912 | InheritException(exception,&image->exception); |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7913 | if (*images != (Image *) NULL) |
| 7914 | *images=DestroyImageList(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7915 | *images=image; |
| 7916 | break; |
| 7917 | } |
| 7918 | break; |
| 7919 | } |
| 7920 | case 'i': |
| 7921 | { |
| 7922 | if (LocaleCompare("ift",option+1) == 0) |
| 7923 | { |
| 7924 | Image |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7925 | *fourier_image, |
| 7926 | *magnitude_image, |
| 7927 | *phase_image; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7928 | |
| 7929 | /* |
| 7930 | Implements the inverse fourier discrete Fourier transform (DFT). |
| 7931 | */ |
| 7932 | (void) SyncImagesSettings(image_info,*images); |
cristy | 8587f88 | 2009-11-13 20:28:49 +0000 | [diff] [blame] | 7933 | magnitude_image=RemoveFirstImageFromList(images); |
| 7934 | phase_image=RemoveFirstImageFromList(images); |
| 7935 | if (phase_image == (Image *) NULL) |
| 7936 | { |
| 7937 | status=MagickFalse; |
| 7938 | break; |
| 7939 | } |
| 7940 | fourier_image=InverseFourierTransformImage(magnitude_image, |
| 7941 | phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7942 | if (fourier_image == (Image *) NULL) |
| 7943 | break; |
cristy | 0aff6ea | 2009-11-14 01:40:53 +0000 | [diff] [blame] | 7944 | if (*images != (Image *) NULL) |
| 7945 | *images=DestroyImage(*images); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7946 | *images=fourier_image; |
| 7947 | break; |
| 7948 | } |
| 7949 | if (LocaleCompare("insert",option+1) == 0) |
| 7950 | { |
| 7951 | Image |
| 7952 | *p, |
| 7953 | *q; |
| 7954 | |
| 7955 | index=0; |
| 7956 | if (*option != '+') |
cristy | f2f2727 | 2009-12-17 14:48:46 +0000 | [diff] [blame] | 7957 | index=StringToLong(argv[i+1]); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7958 | p=RemoveLastImageFromList(images); |
| 7959 | if (p == (Image *) NULL) |
| 7960 | { |
| 7961 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7962 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7963 | status=MagickFalse; |
| 7964 | break; |
| 7965 | } |
| 7966 | q=p; |
| 7967 | if (index == 0) |
| 7968 | PrependImageToList(images,q); |
| 7969 | else |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 7970 | if (index == (ssize_t) GetImageListLength(*images)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 7971 | AppendImageToList(images,q); |
| 7972 | else |
| 7973 | { |
| 7974 | q=GetImageFromList(*images,index-1); |
| 7975 | if (q == (Image *) NULL) |
| 7976 | { |
| 7977 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 7978 | OptionError,"NoSuchImage","`%s'",argv[i+1]); |
| 7979 | status=MagickFalse; |
| 7980 | break; |
| 7981 | } |
| 7982 | InsertImageInList(&q,p); |
| 7983 | } |
| 7984 | *images=GetFirstImageInList(q); |
| 7985 | break; |
| 7986 | } |
| 7987 | break; |
| 7988 | } |
| 7989 | case 'l': |
| 7990 | { |
| 7991 | if (LocaleCompare("layers",option+1) == 0) |
| 7992 | { |
| 7993 | Image |
| 7994 | *layers; |
| 7995 | |
| 7996 | ImageLayerMethod |
| 7997 | method; |
| 7998 | |
| 7999 | (void) SyncImagesSettings(image_info,*images); |
| 8000 | layers=(Image *) NULL; |
| 8001 | method=(ImageLayerMethod) ParseMagickOption(MagickLayerOptions, |
| 8002 | MagickFalse,argv[i+1]); |
| 8003 | switch (method) |
| 8004 | { |
| 8005 | case CoalesceLayer: |
| 8006 | { |
| 8007 | layers=CoalesceImages(*images,exception); |
| 8008 | break; |
| 8009 | } |
| 8010 | case CompareAnyLayer: |
| 8011 | case CompareClearLayer: |
| 8012 | case CompareOverlayLayer: |
| 8013 | default: |
| 8014 | { |
| 8015 | layers=CompareImageLayers(*images,method,exception); |
| 8016 | break; |
| 8017 | } |
| 8018 | case MergeLayer: |
| 8019 | case FlattenLayer: |
| 8020 | case MosaicLayer: |
| 8021 | case TrimBoundsLayer: |
| 8022 | { |
| 8023 | layers=MergeImageLayers(*images,method,exception); |
| 8024 | break; |
| 8025 | } |
| 8026 | case DisposeLayer: |
| 8027 | { |
| 8028 | layers=DisposeImages(*images,exception); |
| 8029 | break; |
| 8030 | } |
| 8031 | case OptimizeImageLayer: |
| 8032 | { |
| 8033 | layers=OptimizeImageLayers(*images,exception); |
| 8034 | break; |
| 8035 | } |
| 8036 | case OptimizePlusLayer: |
| 8037 | { |
| 8038 | layers=OptimizePlusImageLayers(*images,exception); |
| 8039 | break; |
| 8040 | } |
| 8041 | case OptimizeTransLayer: |
| 8042 | { |
| 8043 | OptimizeImageTransparency(*images,exception); |
| 8044 | break; |
| 8045 | } |
| 8046 | case RemoveDupsLayer: |
| 8047 | { |
| 8048 | RemoveDuplicateLayers(images,exception); |
| 8049 | break; |
| 8050 | } |
| 8051 | case RemoveZeroLayer: |
| 8052 | { |
| 8053 | RemoveZeroDelayLayers(images,exception); |
| 8054 | break; |
| 8055 | } |
| 8056 | case OptimizeLayer: |
| 8057 | { |
| 8058 | /* |
| 8059 | General Purpose, GIF Animation Optimizer. |
| 8060 | */ |
| 8061 | layers=CoalesceImages(*images,exception); |
| 8062 | if (layers == (Image *) NULL) |
| 8063 | { |
| 8064 | status=MagickFalse; |
| 8065 | break; |
| 8066 | } |
| 8067 | InheritException(exception,&layers->exception); |
| 8068 | *images=DestroyImageList(*images); |
| 8069 | *images=layers; |
| 8070 | layers=OptimizeImageLayers(*images,exception); |
| 8071 | if (layers == (Image *) NULL) |
| 8072 | { |
| 8073 | status=MagickFalse; |
| 8074 | break; |
| 8075 | } |
| 8076 | InheritException(exception,&layers->exception); |
| 8077 | *images=DestroyImageList(*images); |
| 8078 | *images=layers; |
| 8079 | layers=(Image *) NULL; |
| 8080 | OptimizeImageTransparency(*images,exception); |
| 8081 | InheritException(exception,&(*images)->exception); |
| 8082 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 8083 | break; |
| 8084 | } |
| 8085 | case CompositeLayer: |
| 8086 | { |
| 8087 | CompositeOperator |
| 8088 | compose; |
| 8089 | |
| 8090 | Image |
| 8091 | *source; |
| 8092 | |
| 8093 | RectangleInfo |
| 8094 | geometry; |
| 8095 | |
| 8096 | /* |
| 8097 | Split image sequence at the first 'NULL:' image. |
| 8098 | */ |
| 8099 | source=(*images); |
| 8100 | while (source != (Image *) NULL) |
| 8101 | { |
| 8102 | source=GetNextImageInList(source); |
| 8103 | if ((source != (Image *) NULL) && |
| 8104 | (LocaleCompare(source->magick,"NULL") == 0)) |
| 8105 | break; |
| 8106 | } |
| 8107 | if (source != (Image *) NULL) |
| 8108 | { |
| 8109 | if ((GetPreviousImageInList(source) == (Image *) NULL) || |
| 8110 | (GetNextImageInList(source) == (Image *) NULL)) |
| 8111 | source=(Image *) NULL; |
| 8112 | else |
| 8113 | { |
| 8114 | /* |
| 8115 | Separate the two lists, junk the null: image. |
| 8116 | */ |
| 8117 | source=SplitImageList(source->previous); |
| 8118 | DeleteImageFromList(&source); |
| 8119 | } |
| 8120 | } |
| 8121 | if (source == (Image *) NULL) |
| 8122 | { |
| 8123 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8124 | OptionError,"MissingNullSeparator","layers Composite"); |
| 8125 | status=MagickFalse; |
| 8126 | break; |
| 8127 | } |
| 8128 | /* |
| 8129 | Adjust offset with gravity and virtual canvas. |
| 8130 | */ |
| 8131 | SetGeometry(*images,&geometry); |
| 8132 | (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); |
| 8133 | geometry.width=source->page.width != 0 ? |
| 8134 | source->page.width : source->columns; |
| 8135 | geometry.height=source->page.height != 0 ? |
| 8136 | source->page.height : source->rows; |
| 8137 | GravityAdjustGeometry((*images)->page.width != 0 ? |
| 8138 | (*images)->page.width : (*images)->columns, |
| 8139 | (*images)->page.height != 0 ? (*images)->page.height : |
| 8140 | (*images)->rows,(*images)->gravity,&geometry); |
| 8141 | compose=OverCompositeOp; |
| 8142 | option=GetImageOption(image_info,"compose"); |
| 8143 | if (option != (const char *) NULL) |
| 8144 | compose=(CompositeOperator) ParseMagickOption( |
| 8145 | MagickComposeOptions,MagickFalse,option); |
| 8146 | CompositeLayers(*images,compose,source,geometry.x,geometry.y, |
| 8147 | exception); |
| 8148 | source=DestroyImageList(source); |
| 8149 | break; |
| 8150 | } |
| 8151 | } |
| 8152 | if (layers == (Image *) NULL) |
| 8153 | break; |
| 8154 | InheritException(exception,&layers->exception); |
| 8155 | *images=DestroyImageList(*images); |
| 8156 | *images=layers; |
| 8157 | break; |
| 8158 | } |
| 8159 | break; |
| 8160 | } |
| 8161 | case 'm': |
| 8162 | { |
| 8163 | if (LocaleCompare("map",option+1) == 0) |
| 8164 | { |
| 8165 | (void) SyncImagesSettings(image_info,*images); |
| 8166 | if (*option == '+') |
| 8167 | { |
| 8168 | (void) RemapImages(quantize_info,*images,(Image *) NULL); |
| 8169 | InheritException(exception,&(*images)->exception); |
| 8170 | break; |
| 8171 | } |
| 8172 | i++; |
| 8173 | break; |
| 8174 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8175 | if (LocaleCompare("maximum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8176 | { |
| 8177 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8178 | *maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8179 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 8180 | /* |
| 8181 | Maximum image sequence (deprecated). |
| 8182 | */ |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8183 | (void) SyncImagesSettings(image_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 8184 | maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8185 | if (maximum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8186 | { |
| 8187 | status=MagickFalse; |
| 8188 | break; |
| 8189 | } |
| 8190 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8191 | *images=maximum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8192 | break; |
| 8193 | } |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8194 | if (LocaleCompare("minimum",option+1) == 0) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8195 | { |
| 8196 | Image |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8197 | *minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8198 | |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 8199 | /* |
| 8200 | Minimum image sequence (deprecated). |
| 8201 | */ |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8202 | (void) SyncImagesSettings(image_info,*images); |
cristy | d18ae7c | 2010-03-07 17:39:52 +0000 | [diff] [blame] | 8203 | minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8204 | if (minimum_image == (Image *) NULL) |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8205 | { |
| 8206 | status=MagickFalse; |
| 8207 | break; |
| 8208 | } |
| 8209 | *images=DestroyImageList(*images); |
cristy | f40785b | 2010-03-06 02:27:27 +0000 | [diff] [blame] | 8210 | *images=minimum_image; |
cristy | 1c274c9 | 2010-03-06 02:06:45 +0000 | [diff] [blame] | 8211 | break; |
| 8212 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8213 | if (LocaleCompare("morph",option+1) == 0) |
| 8214 | { |
| 8215 | Image |
| 8216 | *morph_image; |
| 8217 | |
| 8218 | (void) SyncImagesSettings(image_info,*images); |
cristy | e27293e | 2009-12-18 02:53:20 +0000 | [diff] [blame] | 8219 | morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8220 | exception); |
| 8221 | if (morph_image == (Image *) NULL) |
| 8222 | { |
| 8223 | status=MagickFalse; |
| 8224 | break; |
| 8225 | } |
| 8226 | *images=DestroyImageList(*images); |
| 8227 | *images=morph_image; |
| 8228 | break; |
| 8229 | } |
| 8230 | if (LocaleCompare("mosaic",option+1) == 0) |
| 8231 | { |
| 8232 | Image |
| 8233 | *mosaic_image; |
| 8234 | |
| 8235 | (void) SyncImagesSettings(image_info,*images); |
| 8236 | mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); |
| 8237 | if (mosaic_image == (Image *) NULL) |
| 8238 | { |
| 8239 | status=MagickFalse; |
| 8240 | break; |
| 8241 | } |
| 8242 | *images=DestroyImageList(*images); |
| 8243 | *images=mosaic_image; |
| 8244 | break; |
| 8245 | } |
| 8246 | break; |
| 8247 | } |
| 8248 | case 'p': |
| 8249 | { |
| 8250 | if (LocaleCompare("print",option+1) == 0) |
| 8251 | { |
| 8252 | char |
| 8253 | *string; |
| 8254 | |
| 8255 | (void) SyncImagesSettings(image_info,*images); |
| 8256 | string=InterpretImageProperties(image_info,*images,argv[i+1]); |
| 8257 | if (string == (char *) NULL) |
| 8258 | break; |
| 8259 | InheritException(exception,&(*images)->exception); |
| 8260 | (void) fprintf(stdout,"%s",string); |
| 8261 | string=DestroyString(string); |
| 8262 | } |
| 8263 | if (LocaleCompare("process",option+1) == 0) |
| 8264 | { |
| 8265 | char |
| 8266 | **arguments; |
| 8267 | |
| 8268 | int |
| 8269 | j, |
| 8270 | number_arguments; |
| 8271 | |
| 8272 | (void) SyncImagesSettings(image_info,*images); |
| 8273 | arguments=StringToArgv(argv[i+1],&number_arguments); |
| 8274 | if (arguments == (char **) NULL) |
| 8275 | break; |
| 8276 | if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) |
| 8277 | { |
| 8278 | char |
| 8279 | breaker, |
| 8280 | quote, |
| 8281 | *token; |
| 8282 | |
| 8283 | const char |
| 8284 | *arguments; |
| 8285 | |
| 8286 | int |
| 8287 | next, |
| 8288 | status; |
| 8289 | |
| 8290 | size_t |
| 8291 | length; |
| 8292 | |
| 8293 | TokenInfo |
| 8294 | *token_info; |
| 8295 | |
| 8296 | /* |
| 8297 | Support old style syntax, filter="-option arg". |
| 8298 | */ |
| 8299 | length=strlen(argv[i+1]); |
| 8300 | token=(char *) NULL; |
| 8301 | if (~length >= MaxTextExtent) |
| 8302 | token=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 8303 | sizeof(*token)); |
| 8304 | if (token == (char *) NULL) |
| 8305 | break; |
| 8306 | next=0; |
| 8307 | arguments=argv[i+1]; |
| 8308 | token_info=AcquireTokenInfo(); |
| 8309 | status=Tokenizer(token_info,0,token,length,arguments,"","=", |
| 8310 | "\"",'\0',&breaker,&next,"e); |
| 8311 | token_info=DestroyTokenInfo(token_info); |
| 8312 | if (status == 0) |
| 8313 | { |
| 8314 | const char |
| 8315 | *argv; |
| 8316 | |
| 8317 | argv=(&(arguments[next])); |
| 8318 | (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, |
| 8319 | exception); |
| 8320 | } |
| 8321 | token=DestroyString(token); |
| 8322 | break; |
| 8323 | } |
cristy | 91c0da2 | 2010-05-02 01:44:07 +0000 | [diff] [blame] | 8324 | (void) SubstituteString(&arguments[1],"-",""); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8325 | (void) InvokeDynamicImageFilter(arguments[1],&(*images), |
| 8326 | number_arguments-2,(const char **) arguments+2,exception); |
| 8327 | for (j=0; j < number_arguments; j++) |
| 8328 | arguments[j]=DestroyString(arguments[j]); |
| 8329 | arguments=(char **) RelinquishMagickMemory(arguments); |
| 8330 | break; |
| 8331 | } |
| 8332 | break; |
| 8333 | } |
| 8334 | case 'r': |
| 8335 | { |
| 8336 | if (LocaleCompare("reverse",option+1) == 0) |
| 8337 | { |
| 8338 | ReverseImageList(images); |
| 8339 | InheritException(exception,&(*images)->exception); |
| 8340 | break; |
| 8341 | } |
| 8342 | break; |
| 8343 | } |
| 8344 | case 's': |
| 8345 | { |
| 8346 | if (LocaleCompare("swap",option+1) == 0) |
| 8347 | { |
| 8348 | Image |
| 8349 | *p, |
| 8350 | *q, |
| 8351 | *swap; |
| 8352 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8353 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8354 | swap_index; |
| 8355 | |
| 8356 | index=(-1); |
| 8357 | swap_index=(-2); |
| 8358 | if (*option != '+') |
| 8359 | { |
| 8360 | GeometryInfo |
| 8361 | geometry_info; |
| 8362 | |
| 8363 | MagickStatusType |
| 8364 | flags; |
| 8365 | |
| 8366 | swap_index=(-1); |
| 8367 | flags=ParseGeometry(argv[i+1],&geometry_info); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8368 | index=(ssize_t) geometry_info.rho; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8369 | if ((flags & SigmaValue) != 0) |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8370 | swap_index=(ssize_t) geometry_info.sigma; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8371 | } |
| 8372 | p=GetImageFromList(*images,index); |
| 8373 | q=GetImageFromList(*images,swap_index); |
| 8374 | if ((p == (Image *) NULL) || (q == (Image *) NULL)) |
| 8375 | { |
| 8376 | (void) ThrowMagickException(exception,GetMagickModule(), |
| 8377 | OptionError,"NoSuchImage","`%s'",(*images)->filename); |
| 8378 | status=MagickFalse; |
| 8379 | break; |
| 8380 | } |
| 8381 | if (p == q) |
| 8382 | break; |
| 8383 | swap=CloneImage(p,0,0,MagickTrue,exception); |
| 8384 | ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); |
| 8385 | ReplaceImageInList(&q,swap); |
| 8386 | *images=GetFirstImageInList(q); |
| 8387 | break; |
| 8388 | } |
| 8389 | break; |
| 8390 | } |
| 8391 | case 'w': |
| 8392 | { |
| 8393 | if (LocaleCompare("write",option+1) == 0) |
| 8394 | { |
cristy | 071dd7b | 2010-04-09 13:04:54 +0000 | [diff] [blame] | 8395 | char |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8396 | key[MaxTextExtent]; |
| 8397 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8398 | Image |
| 8399 | *write_images; |
| 8400 | |
| 8401 | ImageInfo |
| 8402 | *write_info; |
| 8403 | |
| 8404 | (void) SyncImagesSettings(image_info,*images); |
cristy | 06609ee | 2010-03-17 20:21:27 +0000 | [diff] [blame] | 8405 | (void) FormatMagickString(key,MaxTextExtent,"cache:%s",argv[i+1]); |
| 8406 | (void) DeleteImageRegistry(key); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8407 | write_images=(*images); |
| 8408 | if (*option == '+') |
| 8409 | write_images=CloneImageList(*images,exception); |
| 8410 | write_info=CloneImageInfo(image_info); |
| 8411 | status&=WriteImages(write_info,write_images,argv[i+1],exception); |
| 8412 | write_info=DestroyImageInfo(write_info); |
| 8413 | if (*option == '+') |
| 8414 | write_images=DestroyImageList(write_images); |
| 8415 | break; |
| 8416 | } |
| 8417 | break; |
| 8418 | } |
| 8419 | default: |
| 8420 | break; |
| 8421 | } |
| 8422 | i+=count; |
| 8423 | } |
| 8424 | quantize_info=DestroyQuantizeInfo(quantize_info); |
| 8425 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8426 | } |
| 8427 | |
| 8428 | /* |
| 8429 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8430 | % % |
| 8431 | % % |
| 8432 | % % |
| 8433 | + M o g r i f y I m a g e s % |
| 8434 | % % |
| 8435 | % % |
| 8436 | % % |
| 8437 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8438 | % |
| 8439 | % MogrifyImages() applies image processing options to a sequence of images as |
| 8440 | % prescribed by command line options. |
| 8441 | % |
| 8442 | % The format of the MogrifyImage method is: |
| 8443 | % |
| 8444 | % MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8445 | % const MagickBooleanType post,const int argc,const char **argv, |
| 8446 | % Image **images,Exceptioninfo *exception) |
| 8447 | % |
| 8448 | % A description of each parameter follows: |
| 8449 | % |
| 8450 | % o image_info: the image info.. |
| 8451 | % |
| 8452 | % o post: If true, post process image list operators otherwise pre-process. |
| 8453 | % |
| 8454 | % o argc: Specifies a pointer to an integer describing the number of |
| 8455 | % elements in the argument vector. |
| 8456 | % |
| 8457 | % o argv: Specifies a pointer to a text array containing the command line |
| 8458 | % arguments. |
| 8459 | % |
| 8460 | % o images: the images. |
| 8461 | % |
| 8462 | % o exception: return any errors or warnings in this structure. |
| 8463 | % |
| 8464 | */ |
| 8465 | WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, |
| 8466 | const MagickBooleanType post,const int argc,const char **argv, |
| 8467 | Image **images,ExceptionInfo *exception) |
| 8468 | { |
| 8469 | #define MogrifyImageTag "Mogrify/Image" |
| 8470 | |
| 8471 | Image |
| 8472 | *image, |
| 8473 | *mogrify_images; |
| 8474 | |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8475 | MagickBooleanType |
| 8476 | proceed; |
| 8477 | |
| 8478 | MagickSizeType |
| 8479 | number_images; |
| 8480 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8481 | MagickStatusType |
| 8482 | status; |
| 8483 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8484 | register ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8485 | i; |
| 8486 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8487 | /* |
| 8488 | Apply options to individual images in the list. |
| 8489 | */ |
| 8490 | assert(image_info != (ImageInfo *) NULL); |
| 8491 | assert(image_info->signature == MagickSignature); |
| 8492 | if (images == (Image **) NULL) |
| 8493 | return(MogrifyImage(image_info,argc,argv,images,exception)); |
| 8494 | assert((*images)->signature == MagickSignature); |
| 8495 | if ((*images)->debug != MagickFalse) |
| 8496 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 8497 | (*images)->filename); |
| 8498 | if ((argc <= 0) || (*argv == (char *) NULL)) |
| 8499 | return(MagickTrue); |
| 8500 | (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, |
| 8501 | (void *) NULL); |
| 8502 | mogrify_images=NewImageList(); |
| 8503 | number_images=GetImageListLength(*images); |
| 8504 | status=0; |
| 8505 | if (post == MagickFalse) |
| 8506 | status&=MogrifyImageList(image_info,argc,argv,images,exception); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 8507 | for (i=0; i < (ssize_t) number_images; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8508 | { |
| 8509 | image=RemoveFirstImageFromList(images); |
| 8510 | if (image == (Image *) NULL) |
| 8511 | continue; |
| 8512 | status&=MogrifyImage(image_info,argc,argv,&image,exception); |
| 8513 | AppendImageToList(&mogrify_images,image); |
cristy | 0e9f9c1 | 2010-02-11 03:00:47 +0000 | [diff] [blame] | 8514 | proceed=SetImageProgress(image,MogrifyImageTag,(MagickOffsetType) i, |
| 8515 | number_images); |
| 8516 | if (proceed == MagickFalse) |
| 8517 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 8518 | } |
| 8519 | if (post != MagickFalse) |
| 8520 | status&=MogrifyImageList(image_info,argc,argv,&mogrify_images,exception); |
| 8521 | *images=mogrify_images; |
| 8522 | return(status != 0 ? MagickTrue : MagickFalse); |
| 8523 | } |