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