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