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