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