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