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