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