mogrify.c revision ebd71f4a4d535b9bd4465e44331c1825e32ee1ee
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-2013 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],~0,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],~0,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],~0,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 mogrify_image=VignetteImage(*image,geometry_info.rho, 3098 geometry_info.sigma,(ssize_t) ceil(geometry_info.xi-0.5), 3099 (ssize_t) ceil(geometry_info.psi-0.5),exception); 3100 break; 3101 } 3102 if (LocaleCompare("virtual-pixel",option+1) == 0) 3103 { 3104 if (*option == '+') 3105 { 3106 (void) SetImageVirtualPixelMethod(*image, 3107 UndefinedVirtualPixelMethod,exception); 3108 break; 3109 } 3110 (void) SetImageVirtualPixelMethod(*image,(VirtualPixelMethod) 3111 ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, 3112 argv[i+1]),exception); 3113 break; 3114 } 3115 break; 3116 } 3117 case 'w': 3118 { 3119 if (LocaleCompare("wave",option+1) == 0) 3120 { 3121 /* 3122 Wave image. 3123 */ 3124 (void) SyncImageSettings(mogrify_info,*image,exception); 3125 flags=ParseGeometry(argv[i+1],&geometry_info); 3126 if ((flags & SigmaValue) == 0) 3127 geometry_info.sigma=1.0; 3128 mogrify_image=WaveImage(*image,geometry_info.rho, 3129 geometry_info.sigma,interpolate_method,exception); 3130 break; 3131 } 3132 if (LocaleCompare("weight",option+1) == 0) 3133 { 3134 draw_info->weight=StringToUnsignedLong(argv[i+1]); 3135 if (LocaleCompare(argv[i+1],"all") == 0) 3136 draw_info->weight=0; 3137 if (LocaleCompare(argv[i+1],"bold") == 0) 3138 draw_info->weight=700; 3139 if (LocaleCompare(argv[i+1],"bolder") == 0) 3140 if (draw_info->weight <= 800) 3141 draw_info->weight+=100; 3142 if (LocaleCompare(argv[i+1],"lighter") == 0) 3143 if (draw_info->weight >= 100) 3144 draw_info->weight-=100; 3145 if (LocaleCompare(argv[i+1],"normal") == 0) 3146 draw_info->weight=400; 3147 break; 3148 } 3149 if (LocaleCompare("white-threshold",option+1) == 0) 3150 { 3151 /* 3152 White threshold image. 3153 */ 3154 (void) SyncImageSettings(mogrify_info,*image,exception); 3155 (void) WhiteThresholdImage(*image,argv[i+1],exception); 3156 break; 3157 } 3158 break; 3159 } 3160 default: 3161 break; 3162 } 3163 /* 3164 Replace current image with any image that was generated 3165 */ 3166 if (mogrify_image != (Image *) NULL) 3167 ReplaceImageInListReturnLast(image,mogrify_image); 3168 i+=count; 3169 } 3170 if (region_image != (Image *) NULL) 3171 { 3172 /* 3173 Composite transformed region onto image. 3174 */ 3175 (void) SyncImageSettings(mogrify_info,*image,exception); 3176 (void) CompositeImage(region_image,*image, 3177 region_image->alpha_trait == BlendPixelTrait ? CopyCompositeOp : 3178 OverCompositeOp,MagickTrue,region_geometry.x,region_geometry.y, 3179 exception); 3180 *image=DestroyImage(*image); 3181 *image=region_image; 3182 region_image = (Image *) NULL; 3183 } 3184 /* 3185 Free resources. 3186 */ 3187 quantize_info=DestroyQuantizeInfo(quantize_info); 3188 draw_info=DestroyDrawInfo(draw_info); 3189 mogrify_info=DestroyImageInfo(mogrify_info); 3190 status=(MagickStatusType) (exception->severity == UndefinedException ? 1 : 0); 3191 return(status == 0 ? MagickFalse : MagickTrue); 3192} 3193 3194/* 3195%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3196% % 3197% % 3198% % 3199+ M o g r i f y I m a g e C o m m a n d % 3200% % 3201% % 3202% % 3203%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3204% 3205% MogrifyImageCommand() transforms an image or a sequence of images. These 3206% transforms include image scaling, image rotation, color reduction, and 3207% others. The transmogrified image overwrites the original image. 3208% 3209% The format of the MogrifyImageCommand method is: 3210% 3211% MagickBooleanType MogrifyImageCommand(ImageInfo *image_info,int argc, 3212% const char **argv,char **metadata,ExceptionInfo *exception) 3213% 3214% A description of each parameter follows: 3215% 3216% o image_info: the image info. 3217% 3218% o argc: the number of elements in the argument vector. 3219% 3220% o argv: A text array containing the command line arguments. 3221% 3222% o metadata: any metadata is returned here. 3223% 3224% o exception: return any errors or warnings in this structure. 3225% 3226*/ 3227 3228static MagickBooleanType MogrifyUsage(void) 3229{ 3230 static const char 3231 *channel_operators[]= 3232 { 3233 "-channel-fx expression", 3234 " exchange, extract, or transfer one or more image channels", 3235 "-separate separate an image channel into a grayscale image", 3236 (char *) NULL 3237 }, 3238 *miscellaneous[]= 3239 { 3240 "-debug events display copious debugging information", 3241 "-distribute-cache port", 3242 " distributed pixel cache spanning one or more servers", 3243 "-help print program options", 3244 "-list type print a list of supported option arguments", 3245 "-log format format of debugging information", 3246 "-version print version information", 3247 (char *) NULL 3248 }, 3249 *operators[]= 3250 { 3251 "-adaptive-blur geometry", 3252 " adaptively blur pixels; decrease effect near edges", 3253 "-adaptive-resize geometry", 3254 " adaptively resize image using 'mesh' interpolation", 3255 "-adaptive-sharpen geometry", 3256 " adaptively sharpen pixels; increase effect near edges", 3257 "-alpha option on, activate, off, deactivate, set, opaque, copy", 3258 " transparent, extract, background, or shape", 3259 "-annotate geometry text", 3260 " annotate the image with text", 3261 "-auto-gamma automagically adjust gamma level of image", 3262 "-auto-level automagically adjust color levels of image", 3263 "-auto-orient automagically orient (rotate) image", 3264 "-bench iterations measure performance", 3265 "-black-threshold value", 3266 " force all pixels below the threshold into black", 3267 "-blue-shift simulate a scene at nighttime in the moonlight", 3268 "-blur geometry reduce image noise and reduce detail levels", 3269 "-border geometry surround image with a border of color", 3270 "-bordercolor color border color", 3271 "-brightness-contrast geometry", 3272 " improve brightness / contrast of the image", 3273 "-cdl filename color correct with a color decision list", 3274 "-charcoal geometry simulate a charcoal drawing", 3275 "-chop geometry remove pixels from the image interior", 3276 "-clamp keep pixel values in range (0-QuantumRange)", 3277 "-clip clip along the first path from the 8BIM profile", 3278 "-clip-mask filename associate a clip mask with the image", 3279 "-clip-path id clip along a named path from the 8BIM profile", 3280 "-colorize value colorize the image with the fill color", 3281 "-color-matrix matrix apply color correction to the image", 3282 "-contrast enhance or reduce the image contrast", 3283 "-contrast-stretch geometry", 3284 " improve contrast by 'stretching' the intensity range", 3285 "-convolve coefficients", 3286 " apply a convolution kernel to the image", 3287 "-cycle amount cycle the image colormap", 3288 "-decipher filename convert cipher pixels to plain pixels", 3289 "-deskew threshold straighten an image", 3290 "-despeckle reduce the speckles within an image", 3291 "-distort method args", 3292 " distort images according to given method ad args", 3293 "-draw string annotate the image with a graphic primitive", 3294 "-edge radius apply a filter to detect edges in the image", 3295 "-encipher filename convert plain pixels to cipher pixels", 3296 "-emboss radius emboss an image", 3297 "-enhance apply a digital filter to enhance a noisy image", 3298 "-equalize perform histogram equalization to an image", 3299 "-evaluate operator value", 3300 " evaluate an arithmetic, relational, or logical expression", 3301 "-extent geometry set the image size", 3302 "-extract geometry extract area from image", 3303 "-fft implements the discrete Fourier transform (DFT)", 3304 "-flip flip image vertically", 3305 "-floodfill geometry color", 3306 " floodfill the image with color", 3307 "-flop flop image horizontally", 3308 "-frame geometry surround image with an ornamental border", 3309 "-function name parameters", 3310 " apply function over image values", 3311 "-gamma value level of gamma correction", 3312 "-gaussian-blur geometry", 3313 " reduce image noise and reduce detail levels", 3314 "-geometry geometry preferred size or location of the image", 3315 "-grayscale method convert image to grayscale", 3316 "-identify identify the format and characteristics of the image", 3317 "-ift implements the inverse discrete Fourier transform (DFT)", 3318 "-implode amount implode image pixels about the center", 3319 "-interpolative-resize geometry", 3320 " resize image using interpolation", 3321 "-lat geometry local adaptive thresholding", 3322 "-level value adjust the level of image contrast", 3323 "-level-colors color,color", 3324 " level image with the given colors", 3325 "-linear-stretch geometry", 3326 " improve contrast by 'stretching with saturation'", 3327 "-liquid-rescale geometry", 3328 " rescale image with seam-carving", 3329 "-magnify double the size of the image with pixel art scaling", 3330 "-median geometry apply a median filter to the image", 3331 "-mode geometry make each pixel the 'predominant color' of the", 3332 " neighborhood", 3333 "-modulate value vary the brightness, saturation, and hue", 3334 "-monochrome transform image to black and white", 3335 "-morphology method kernel", 3336 " apply a morphology method to the image", 3337 "-motion-blur geometry", 3338 " simulate motion blur", 3339 "-negate replace every pixel with its complementary color ", 3340 "-noise geometry add or reduce noise in an image", 3341 "-normalize transform image to span the full range of colors", 3342 "-opaque color change this color to the fill color", 3343 "-ordered-dither NxN", 3344 " add a noise pattern to the image with specific", 3345 " amplitudes", 3346 "-paint radius simulate an oil painting", 3347 "-perceptible epsilon", 3348 " pixel value less than |epsilon| become epsilon or", 3349 " -epsilon", 3350 "-polaroid angle simulate a Polaroid picture", 3351 "-posterize levels reduce the image to a limited number of color levels", 3352 "-profile filename add, delete, or apply an image profile", 3353 "-quantize colorspace reduce colors in this colorspace", 3354 "-radial-blur angle radial blur the image", 3355 "-raise value lighten/darken image edges to create a 3-D effect", 3356 "-random-threshold low,high", 3357 " random threshold the image", 3358 "-region geometry apply options to a portion of the image", 3359 "-render render vector graphics", 3360 "-repage geometry size and location of an image canvas", 3361 "-resample geometry change the resolution of an image", 3362 "-resize geometry resize the image", 3363 "-roll geometry roll an image vertically or horizontally", 3364 "-rotate degrees apply Paeth rotation to the image", 3365 "-sample geometry scale image with pixel sampling", 3366 "-scale geometry scale the image", 3367 "-segment values segment an image", 3368 "-selective-blur geometry", 3369 " selectively blur pixels within a contrast threshold", 3370 "-sepia-tone threshold", 3371 " simulate a sepia-toned photo", 3372 "-set property value set an image property", 3373 "-shade degrees shade the image using a distant light source", 3374 "-shadow geometry simulate an image shadow", 3375 "-sharpen geometry sharpen the image", 3376 "-shave geometry shave pixels from the image edges", 3377 "-shear geometry slide one edge of the image along the X or Y axis", 3378 "-sigmoidal-contrast geometry", 3379 " increase the contrast without saturating highlights or", 3380 " shadows", 3381 "-sketch geometry simulate a pencil sketch", 3382 "-solarize threshold negate all pixels above the threshold level", 3383 "-sparse-color method args", 3384 " fill in a image based on a few color points", 3385 "-splice geometry splice the background color into the image", 3386 "-spread radius displace image pixels by a random amount", 3387 "-statistic type radius", 3388 " replace each pixel with corresponding statistic from the neighborhood", 3389 "-strip strip image of all profiles and comments", 3390 "-swirl degrees swirl image pixels about the center", 3391 "-threshold value threshold the image", 3392 "-thumbnail geometry create a thumbnail of the image", 3393 "-tile filename tile image when filling a graphic primitive", 3394 "-tint value tint the image with the fill color", 3395 "-transform affine transform image", 3396 "-transparent color make this color transparent within the image", 3397 "-transpose flip image vertically and rotate 90 degrees", 3398 "-transverse flop image horizontally and rotate 270 degrees", 3399 "-trim trim image edges", 3400 "-type type image type", 3401 "-unique-colors discard all but one of any pixel color", 3402 "-unsharp geometry sharpen the image", 3403 "-vignette geometry soften the edges of the image in vignette style", 3404 "-wave geometry alter an image along a sine wave", 3405 "-white-threshold value", 3406 " force all pixels above the threshold into white", 3407 (char *) NULL 3408 }, 3409 *sequence_operators[]= 3410 { 3411 "-affinity filename transform image colors to match this set of colors", 3412 "-append append an image sequence", 3413 "-clut apply a color lookup table to the image", 3414 "-coalesce merge a sequence of images", 3415 "-combine combine a sequence of images", 3416 "-compare mathematically and visually annotate the difference between an image and its reconstruction", 3417 "-composite composite image", 3418 "-crop geometry cut out a rectangular region of the image", 3419 "-deconstruct break down an image sequence into constituent parts", 3420 "-evaluate-sequence operator", 3421 " evaluate an arithmetic, relational, or logical expression", 3422 "-flatten flatten a sequence of images", 3423 "-fx expression apply mathematical expression to an image channel(s)", 3424 "-hald-clut apply a Hald color lookup table to the image", 3425 "-layers method optimize, merge, or compare image layers", 3426 "-morph value morph an image sequence", 3427 "-mosaic create a mosaic from an image sequence", 3428 "-poly terms build a polynomial from the image sequence and the corresponding", 3429 " terms (coefficients and degree pairs).", 3430 "-print string interpret string and print to console", 3431 "-process arguments process the image with a custom image filter", 3432 "-smush geometry smush an image sequence together", 3433 "-write filename write images to this file", 3434 (char *) NULL 3435 }, 3436 *settings[]= 3437 { 3438 "-adjoin join images into a single multi-image file", 3439 "-affine matrix affine transform matrix", 3440 "-alpha option activate, deactivate, reset, or set the alpha channel", 3441 "-antialias remove pixel-aliasing", 3442 "-authenticate password", 3443 " decipher image with this password", 3444 "-attenuate value lessen (or intensify) when adding noise to an image", 3445 "-background color background color", 3446 "-bias value add bias when convolving an image", 3447 "-black-point-compensation", 3448 " use black point compensation", 3449 "-blue-primary point chromaticity blue primary point", 3450 "-bordercolor color border color", 3451 "-caption string assign a caption to an image", 3452 "-channel type apply option to select image channels", 3453 "-colors value preferred number of colors in the image", 3454 "-colorspace type alternate image colorspace", 3455 "-comment string annotate image with comment", 3456 "-compose operator set image composite operator", 3457 "-compress type type of pixel compression when writing the image", 3458 "-define format:option=value", 3459 " define one or more image format options", 3460 "-delay value display the next image after pausing", 3461 "-density geometry horizontal and vertical density of the image", 3462 "-depth value image depth", 3463 "-direction type render text right-to-left or left-to-right", 3464 "-display server get image or font from this X server", 3465 "-dispose method layer disposal method", 3466 "-dither method apply error diffusion to image", 3467 "-encoding type text encoding type", 3468 "-endian type endianness (MSB or LSB) of the image", 3469 "-family name render text with this font family", 3470 "-features distance analyze image features (e.g. contrast, correlation)", 3471 "-fill color color to use when filling a graphic primitive", 3472 "-filter type use this filter when resizing an image", 3473 "-font name render text with this font", 3474 "-format \"string\" output formatted image characteristics", 3475 "-fuzz distance colors within this distance are considered equal", 3476 "-gravity type horizontal and vertical text placement", 3477 "-green-primary point chromaticity green primary point", 3478 "-intensity method method to generate an intensity value from a pixel", 3479 "-intent type type of rendering intent when managing the image color", 3480 "-interlace type type of image interlacing scheme", 3481 "-interline-spacing value", 3482 " set the space between two text lines", 3483 "-interpolate method pixel color interpolation method", 3484 "-interword-spacing value", 3485 " set the space between two words", 3486 "-kerning value set the space between two letters", 3487 "-label string assign a label to an image", 3488 "-limit type value pixel cache resource limit", 3489 "-loop iterations add Netscape loop extension to your GIF animation", 3490 "-mask filename associate a mask with the image", 3491 "-matte store matte channel if the image has one", 3492 "-mattecolor color frame color", 3493 "-monitor monitor progress", 3494 "-orient type image orientation", 3495 "-page geometry size and location of an image canvas (setting)", 3496 "-path path write images to this path on disk", 3497 "-ping efficiently determine image attributes", 3498 "-pointsize value font point size", 3499 "-precision value maximum number of significant digits to print", 3500 "-preview type image preview type", 3501 "-quality value JPEG/MIFF/PNG compression level", 3502 "-quiet suppress all warning messages", 3503 "-red-primary point chromaticity red primary point", 3504 "-regard-warnings pay attention to warning messages", 3505 "-remap filename transform image colors to match this set of colors", 3506 "-respect-parentheses settings remain in effect until parenthesis boundary", 3507 "-sampling-factor geometry", 3508 " horizontal and vertical sampling factor", 3509 "-scene value image scene number", 3510 "-seed value seed a new sequence of pseudo-random numbers", 3511 "-size geometry width and height of image", 3512 "-stretch type render text with this font stretch", 3513 "-stroke color graphic primitive stroke color", 3514 "-strokewidth value graphic primitive stroke width", 3515 "-style type render text with this font style", 3516 "-synchronize synchronize image to storage device", 3517 "-taint declare the image as modified", 3518 "-texture filename name of texture to tile onto the image background", 3519 "-tile-offset geometry", 3520 " tile offset", 3521 "-treedepth value color tree depth", 3522 "-transparent-color color", 3523 " transparent color", 3524 "-undercolor color annotation bounding box color", 3525 "-units type the units of image resolution", 3526 "-verbose print detailed information about the image", 3527 "-view FlashPix viewing transforms", 3528 "-virtual-pixel method", 3529 " virtual pixel access method", 3530 "-weight type render text with this font weight", 3531 "-white-point point chromaticity white point", 3532 (char *) NULL 3533 }, 3534 *stack_operators[]= 3535 { 3536 "-delete indexes delete the image from the image sequence", 3537 "-duplicate count,indexes", 3538 " duplicate an image one or more times", 3539 "-insert index insert last image into the image sequence", 3540 "-reverse reverse image sequence", 3541 "-swap indexes swap two images in the image sequence", 3542 (char *) NULL 3543 }; 3544 3545 const char 3546 **p; 3547 3548 ListMagickVersion(stdout); 3549 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", 3550 GetClientName()); 3551 (void) printf("\nImage Settings:\n"); 3552 for (p=settings; *p != (char *) NULL; p++) 3553 (void) printf(" %s\n",*p); 3554 (void) printf("\nImage Operators:\n"); 3555 for (p=operators; *p != (char *) NULL; p++) 3556 (void) printf(" %s\n",*p); 3557 (void) printf("\nImage Channel Operators:\n"); 3558 for (p=channel_operators; *p != (char *) NULL; p++) 3559 (void) printf(" %s\n",*p); 3560 (void) printf("\nImage Sequence Operators:\n"); 3561 for (p=sequence_operators; *p != (char *) NULL; p++) 3562 (void) printf(" %s\n",*p); 3563 (void) printf("\nImage Stack Operators:\n"); 3564 for (p=stack_operators; *p != (char *) NULL; p++) 3565 (void) printf(" %s\n",*p); 3566 (void) printf("\nMiscellaneous Options:\n"); 3567 for (p=miscellaneous; *p != (char *) NULL; p++) 3568 (void) printf(" %s\n",*p); 3569 (void) printf( 3570 "\nBy default, the image format of 'file' is determined by its magic\n"); 3571 (void) printf( 3572 "number. To specify a particular image format, precede the filename\n"); 3573 (void) printf( 3574 "with an image format name and a colon (i.e. ps:image) or specify the\n"); 3575 (void) printf( 3576 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); 3577 (void) printf("'-' for standard input or output.\n"); 3578 return(MagickFalse); 3579} 3580 3581WandExport MagickBooleanType MogrifyImageCommand(ImageInfo *image_info, 3582 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) 3583{ 3584#define DestroyMogrify() \ 3585{ \ 3586 if (format != (char *) NULL) \ 3587 format=DestroyString(format); \ 3588 if (path != (char *) NULL) \ 3589 path=DestroyString(path); \ 3590 DestroyImageStack(); \ 3591 for (i=0; i < (ssize_t) argc; i++) \ 3592 argv[i]=DestroyString(argv[i]); \ 3593 argv=(char **) RelinquishMagickMemory(argv); \ 3594} 3595#define ThrowMogrifyException(asperity,tag,option) \ 3596{ \ 3597 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ 3598 option); \ 3599 DestroyMogrify(); \ 3600 return(MagickFalse); \ 3601} 3602#define ThrowMogrifyInvalidArgumentException(option,argument) \ 3603{ \ 3604 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ 3605 "InvalidArgument","'%s': %s",argument,option); \ 3606 DestroyMogrify(); \ 3607 return(MagickFalse); \ 3608} 3609 3610 char 3611 *format, 3612 *option, 3613 *path; 3614 3615 Image 3616 *image; 3617 3618 ImageStack 3619 image_stack[MaxImageStackDepth+1]; 3620 3621 MagickBooleanType 3622 global_colormap; 3623 3624 MagickBooleanType 3625 fire, 3626 pend, 3627 respect_parenthesis; 3628 3629 MagickStatusType 3630 status; 3631 3632 register ssize_t 3633 i; 3634 3635 ssize_t 3636 j, 3637 k; 3638 3639 /* 3640 Set defaults. 3641 */ 3642 assert(image_info != (ImageInfo *) NULL); 3643 assert(image_info->signature == MagickSignature); 3644 if (image_info->debug != MagickFalse) 3645 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 3646 assert(exception != (ExceptionInfo *) NULL); 3647 if (argc == 2) 3648 { 3649 option=argv[1]; 3650 if ((LocaleCompare("version",option+1) == 0) || 3651 (LocaleCompare("-version",option+1) == 0)) 3652 { 3653 ListMagickVersion(stdout); 3654 return(MagickFalse); 3655 } 3656 } 3657 if (argc < 2) 3658 return(MogrifyUsage()); 3659 format=(char *) NULL; 3660 path=(char *) NULL; 3661 global_colormap=MagickFalse; 3662 k=0; 3663 j=1; 3664 NewImageStack(); 3665 option=(char *) NULL; 3666 pend=MagickFalse; 3667 respect_parenthesis=MagickFalse; 3668 status=MagickTrue; 3669 /* 3670 Parse command line. 3671 */ 3672 ReadCommandlLine(argc,&argv); 3673 status=ExpandFilenames(&argc,&argv); 3674 if (status == MagickFalse) 3675 ThrowMogrifyException(ResourceLimitError,"MemoryAllocationFailed", 3676 GetExceptionMessage(errno)); 3677 for (i=1; i < (ssize_t) argc; i++) 3678 { 3679 option=argv[i]; 3680 if (LocaleCompare(option,"(") == 0) 3681 { 3682 FireImageStack(MagickFalse,MagickTrue,pend); 3683 if (k == MaxImageStackDepth) 3684 ThrowMogrifyException(OptionError,"ParenthesisNestedTooDeeply", 3685 option); 3686 PushImageStack(); 3687 continue; 3688 } 3689 if (LocaleCompare(option,")") == 0) 3690 { 3691 FireImageStack(MagickFalse,MagickTrue,MagickTrue); 3692 if (k == 0) 3693 ThrowMogrifyException(OptionError,"UnableToParseExpression",option); 3694 PopImageStack(); 3695 continue; 3696 } 3697 if (IsCommandOption(option) == MagickFalse) 3698 { 3699 char 3700 backup_filename[MaxTextExtent], 3701 *filename; 3702 3703 Image 3704 *images; 3705 3706 /* 3707 Option is a file name: begin by reading image from specified file. 3708 */ 3709 FireImageStack(MagickFalse,MagickFalse,pend); 3710 filename=argv[i]; 3711 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) 3712 filename=argv[++i]; 3713 images=ReadImages(image_info,filename,exception); 3714 status&=(images != (Image *) NULL) && 3715 (exception->severity < ErrorException); 3716 if (images == (Image *) NULL) 3717 continue; 3718 if (format != (char *) NULL) 3719 (void) CopyMagickString(images->filename,images->magick_filename, 3720 MaxTextExtent); 3721 if (path != (char *) NULL) 3722 { 3723 GetPathComponent(option,TailPath,filename); 3724 (void) FormatLocaleString(images->filename,MaxTextExtent,"%s%c%s", 3725 path,*DirectorySeparator,filename); 3726 } 3727 if (format != (char *) NULL) 3728 AppendImageFormat(format,images->filename); 3729 AppendImageStack(images); 3730 FinalizeImageSettings(image_info,image,MagickFalse); 3731 if (global_colormap != MagickFalse) 3732 { 3733 QuantizeInfo 3734 *quantize_info; 3735 3736 quantize_info=AcquireQuantizeInfo(image_info); 3737 (void) RemapImages(quantize_info,images,(Image *) NULL,exception); 3738 quantize_info=DestroyQuantizeInfo(quantize_info); 3739 } 3740 *backup_filename='\0'; 3741 if ((LocaleCompare(image->filename,"-") != 0) && 3742 (IsPathWritable(image->filename) != MagickFalse)) 3743 { 3744 register ssize_t 3745 i; 3746 3747 /* 3748 Rename image file as backup. 3749 */ 3750 (void) CopyMagickString(backup_filename,image->filename, 3751 MaxTextExtent); 3752 for (i=0; i < 6; i++) 3753 { 3754 (void) ConcatenateMagickString(backup_filename,"~",MaxTextExtent); 3755 if (IsPathAccessible(backup_filename) == MagickFalse) 3756 break; 3757 } 3758 if ((IsPathAccessible(backup_filename) != MagickFalse) || 3759 (rename_utf8(image->filename,backup_filename) != 0)) 3760 *backup_filename='\0'; 3761 } 3762 /* 3763 Write transmogrified image to disk. 3764 */ 3765 image_info->synchronize=MagickTrue; 3766 status&=WriteImages(image_info,image,image->filename,exception); 3767 if ((status == MagickFalse) && (*backup_filename != '\0')) 3768 (void) remove_utf8(backup_filename); 3769 RemoveAllImageStack(); 3770 continue; 3771 } 3772 pend=image != (Image *) NULL ? MagickTrue : MagickFalse; 3773 switch (*(option+1)) 3774 { 3775 case 'a': 3776 { 3777 if (LocaleCompare("adaptive-blur",option+1) == 0) 3778 { 3779 i++; 3780 if (i == (ssize_t) argc) 3781 ThrowMogrifyException(OptionError,"MissingArgument",option); 3782 if (IsGeometry(argv[i]) == MagickFalse) 3783 ThrowMogrifyInvalidArgumentException(option,argv[i]); 3784 break; 3785 } 3786 if (LocaleCompare("adaptive-resize",option+1) == 0) 3787 { 3788 i++; 3789 if (i == (ssize_t) argc) 3790 ThrowMogrifyException(OptionError,"MissingArgument",option); 3791 if (IsGeometry(argv[i]) == MagickFalse) 3792 ThrowMogrifyInvalidArgumentException(option,argv[i]); 3793 break; 3794 } 3795 if (LocaleCompare("adaptive-sharpen",option+1) == 0) 3796 { 3797 i++; 3798 if (i == (ssize_t) argc) 3799 ThrowMogrifyException(OptionError,"MissingArgument",option); 3800 if (IsGeometry(argv[i]) == MagickFalse) 3801 ThrowMogrifyInvalidArgumentException(option,argv[i]); 3802 break; 3803 } 3804 if (LocaleCompare("affine",option+1) == 0) 3805 { 3806 if (*option == '+') 3807 break; 3808 i++; 3809 if (i == (ssize_t) argc) 3810 ThrowMogrifyException(OptionError,"MissingArgument",option); 3811 break; 3812 } 3813 if (LocaleCompare("alpha",option+1) == 0) 3814 { 3815 ssize_t 3816 type; 3817 3818 if (*option == '+') 3819 break; 3820 i++; 3821 if (i == (ssize_t) argc) 3822 ThrowMogrifyException(OptionError,"MissingArgument",option); 3823 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse,argv[i]); 3824 if (type < 0) 3825 ThrowMogrifyException(OptionError,"UnrecognizedAlphaChannelOption", 3826 argv[i]); 3827 break; 3828 } 3829 if (LocaleCompare("annotate",option+1) == 0) 3830 { 3831 if (*option == '+') 3832 break; 3833 i++; 3834 if (i == (ssize_t) argc) 3835 ThrowMogrifyException(OptionError,"MissingArgument",option); 3836 if (IsGeometry(argv[i]) == MagickFalse) 3837 ThrowMogrifyInvalidArgumentException(option,argv[i]); 3838 if (i == (ssize_t) argc) 3839 ThrowMogrifyException(OptionError,"MissingArgument",option); 3840 i++; 3841 break; 3842 } 3843 if (LocaleCompare("antialias",option+1) == 0) 3844 break; 3845 if (LocaleCompare("append",option+1) == 0) 3846 break; 3847 if (LocaleCompare("attenuate",option+1) == 0) 3848 { 3849 if (*option == '+') 3850 break; 3851 i++; 3852 if (i == (ssize_t) (argc-1)) 3853 ThrowMogrifyException(OptionError,"MissingArgument",option); 3854 if (IsGeometry(argv[i]) == MagickFalse) 3855 ThrowMogrifyInvalidArgumentException(option,argv[i]); 3856 break; 3857 } 3858 if (LocaleCompare("authenticate",option+1) == 0) 3859 { 3860 if (*option == '+') 3861 break; 3862 i++; 3863 if (i == (ssize_t) argc) 3864 ThrowMogrifyException(OptionError,"MissingArgument",option); 3865 break; 3866 } 3867 if (LocaleCompare("auto-gamma",option+1) == 0) 3868 break; 3869 if (LocaleCompare("auto-level",option+1) == 0) 3870 break; 3871 if (LocaleCompare("auto-orient",option+1) == 0) 3872 break; 3873 if (LocaleCompare("average",option+1) == 0) 3874 break; 3875 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 3876 } 3877 case 'b': 3878 { 3879 if (LocaleCompare("background",option+1) == 0) 3880 { 3881 if (*option == '+') 3882 break; 3883 i++; 3884 if (i == (ssize_t) argc) 3885 ThrowMogrifyException(OptionError,"MissingArgument",option); 3886 break; 3887 } 3888 if (LocaleCompare("bias",option+1) == 0) 3889 { 3890 if (*option == '+') 3891 break; 3892 i++; 3893 if (i == (ssize_t) (argc-1)) 3894 ThrowMogrifyException(OptionError,"MissingArgument",option); 3895 if (IsGeometry(argv[i]) == MagickFalse) 3896 ThrowMogrifyInvalidArgumentException(option,argv[i]); 3897 break; 3898 } 3899 if (LocaleCompare("black-point-compensation",option+1) == 0) 3900 break; 3901 if (LocaleCompare("black-threshold",option+1) == 0) 3902 { 3903 if (*option == '+') 3904 break; 3905 i++; 3906 if (i == (ssize_t) argc) 3907 ThrowMogrifyException(OptionError,"MissingArgument",option); 3908 if (IsGeometry(argv[i]) == MagickFalse) 3909 ThrowMogrifyInvalidArgumentException(option,argv[i]); 3910 break; 3911 } 3912 if (LocaleCompare("blue-primary",option+1) == 0) 3913 { 3914 if (*option == '+') 3915 break; 3916 i++; 3917 if (i == (ssize_t) argc) 3918 ThrowMogrifyException(OptionError,"MissingArgument",option); 3919 if (IsGeometry(argv[i]) == MagickFalse) 3920 ThrowMogrifyInvalidArgumentException(option,argv[i]); 3921 break; 3922 } 3923 if (LocaleCompare("blue-shift",option+1) == 0) 3924 { 3925 i++; 3926 if (i == (ssize_t) argc) 3927 ThrowMogrifyException(OptionError,"MissingArgument",option); 3928 if (IsGeometry(argv[i]) == MagickFalse) 3929 ThrowMogrifyInvalidArgumentException(option,argv[i]); 3930 break; 3931 } 3932 if (LocaleCompare("blur",option+1) == 0) 3933 { 3934 i++; 3935 if (i == (ssize_t) argc) 3936 ThrowMogrifyException(OptionError,"MissingArgument",option); 3937 if (IsGeometry(argv[i]) == MagickFalse) 3938 ThrowMogrifyInvalidArgumentException(option,argv[i]); 3939 break; 3940 } 3941 if (LocaleCompare("border",option+1) == 0) 3942 { 3943 if (*option == '+') 3944 break; 3945 i++; 3946 if (i == (ssize_t) argc) 3947 ThrowMogrifyException(OptionError,"MissingArgument",option); 3948 if (IsGeometry(argv[i]) == MagickFalse) 3949 ThrowMogrifyInvalidArgumentException(option,argv[i]); 3950 break; 3951 } 3952 if (LocaleCompare("bordercolor",option+1) == 0) 3953 { 3954 if (*option == '+') 3955 break; 3956 i++; 3957 if (i == (ssize_t) argc) 3958 ThrowMogrifyException(OptionError,"MissingArgument",option); 3959 break; 3960 } 3961 if (LocaleCompare("box",option+1) == 0) 3962 { 3963 if (*option == '+') 3964 break; 3965 i++; 3966 if (i == (ssize_t) argc) 3967 ThrowMogrifyException(OptionError,"MissingArgument",option); 3968 break; 3969 } 3970 if (LocaleCompare("brightness-contrast",option+1) == 0) 3971 { 3972 i++; 3973 if (i == (ssize_t) argc) 3974 ThrowMogrifyException(OptionError,"MissingArgument",option); 3975 if (IsGeometry(argv[i]) == MagickFalse) 3976 ThrowMogrifyInvalidArgumentException(option,argv[i]); 3977 break; 3978 } 3979 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 3980 } 3981 case 'c': 3982 { 3983 if (LocaleCompare("cache",option+1) == 0) 3984 { 3985 if (*option == '+') 3986 break; 3987 i++; 3988 if (i == (ssize_t) argc) 3989 ThrowMogrifyException(OptionError,"MissingArgument",option); 3990 if (IsGeometry(argv[i]) == MagickFalse) 3991 ThrowMogrifyInvalidArgumentException(option,argv[i]); 3992 break; 3993 } 3994 if (LocaleCompare("caption",option+1) == 0) 3995 { 3996 if (*option == '+') 3997 break; 3998 i++; 3999 if (i == (ssize_t) argc) 4000 ThrowMogrifyException(OptionError,"MissingArgument",option); 4001 break; 4002 } 4003 if (LocaleCompare("channel",option+1) == 0) 4004 { 4005 ssize_t 4006 channel; 4007 4008 if (*option == '+') 4009 break; 4010 i++; 4011 if (i == (ssize_t) (argc-1)) 4012 ThrowMogrifyException(OptionError,"MissingArgument",option); 4013 channel=ParseChannelOption(argv[i]); 4014 if (channel < 0) 4015 ThrowMogrifyException(OptionError,"UnrecognizedChannelType", 4016 argv[i]); 4017 break; 4018 } 4019 if (LocaleCompare("channel-fx",option+1) == 0) 4020 { 4021 ssize_t 4022 channel; 4023 4024 if (*option == '+') 4025 break; 4026 i++; 4027 if (i == (ssize_t) (argc-1)) 4028 ThrowMogrifyException(OptionError,"MissingArgument",option); 4029 channel=ParsePixelChannelOption(argv[i]); 4030 if (channel < 0) 4031 ThrowMogrifyException(OptionError,"UnrecognizedChannelType", 4032 argv[i]); 4033 break; 4034 } 4035 if (LocaleCompare("cdl",option+1) == 0) 4036 { 4037 if (*option == '+') 4038 break; 4039 i++; 4040 if (i == (ssize_t) (argc-1)) 4041 ThrowMogrifyException(OptionError,"MissingArgument",option); 4042 break; 4043 } 4044 if (LocaleCompare("charcoal",option+1) == 0) 4045 { 4046 if (*option == '+') 4047 break; 4048 i++; 4049 if (i == (ssize_t) argc) 4050 ThrowMogrifyException(OptionError,"MissingArgument",option); 4051 if (IsGeometry(argv[i]) == MagickFalse) 4052 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4053 break; 4054 } 4055 if (LocaleCompare("chop",option+1) == 0) 4056 { 4057 if (*option == '+') 4058 break; 4059 i++; 4060 if (i == (ssize_t) argc) 4061 ThrowMogrifyException(OptionError,"MissingArgument",option); 4062 if (IsGeometry(argv[i]) == MagickFalse) 4063 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4064 break; 4065 } 4066 if (LocaleCompare("clamp",option+1) == 0) 4067 break; 4068 if (LocaleCompare("clip",option+1) == 0) 4069 break; 4070 if (LocaleCompare("clip-mask",option+1) == 0) 4071 { 4072 if (*option == '+') 4073 break; 4074 i++; 4075 if (i == (ssize_t) argc) 4076 ThrowMogrifyException(OptionError,"MissingArgument",option); 4077 break; 4078 } 4079 if (LocaleCompare("clut",option+1) == 0) 4080 break; 4081 if (LocaleCompare("coalesce",option+1) == 0) 4082 break; 4083 if (LocaleCompare("colorize",option+1) == 0) 4084 { 4085 if (*option == '+') 4086 break; 4087 i++; 4088 if (i == (ssize_t) argc) 4089 ThrowMogrifyException(OptionError,"MissingArgument",option); 4090 if (IsGeometry(argv[i]) == MagickFalse) 4091 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4092 break; 4093 } 4094 if (LocaleCompare("color-matrix",option+1) == 0) 4095 { 4096 KernelInfo 4097 *kernel_info; 4098 4099 if (*option == '+') 4100 break; 4101 i++; 4102 if (i == (ssize_t) (argc-1)) 4103 ThrowMogrifyException(OptionError,"MissingArgument",option); 4104 kernel_info=AcquireKernelInfo(argv[i]); 4105 if (kernel_info == (KernelInfo *) NULL) 4106 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4107 kernel_info=DestroyKernelInfo(kernel_info); 4108 break; 4109 } 4110 if (LocaleCompare("colors",option+1) == 0) 4111 { 4112 if (*option == '+') 4113 break; 4114 i++; 4115 if (i == (ssize_t) argc) 4116 ThrowMogrifyException(OptionError,"MissingArgument",option); 4117 if (IsGeometry(argv[i]) == MagickFalse) 4118 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4119 break; 4120 } 4121 if (LocaleCompare("colorspace",option+1) == 0) 4122 { 4123 ssize_t 4124 colorspace; 4125 4126 if (*option == '+') 4127 break; 4128 i++; 4129 if (i == (ssize_t) argc) 4130 ThrowMogrifyException(OptionError,"MissingArgument",option); 4131 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, 4132 argv[i]); 4133 if (colorspace < 0) 4134 ThrowMogrifyException(OptionError,"UnrecognizedColorspace", 4135 argv[i]); 4136 break; 4137 } 4138 if (LocaleCompare("combine",option+1) == 0) 4139 { 4140 ssize_t 4141 colorspace; 4142 4143 if (*option == '+') 4144 break; 4145 i++; 4146 if (i == (ssize_t) argc) 4147 ThrowMogrifyException(OptionError,"MissingArgument",option); 4148 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, 4149 argv[i]); 4150 if (colorspace < 0) 4151 ThrowMogrifyException(OptionError,"UnrecognizedColorspace", 4152 argv[i]); 4153 break; 4154 } 4155 if (LocaleCompare("compare",option+1) == 0) 4156 break; 4157 if (LocaleCompare("comment",option+1) == 0) 4158 { 4159 if (*option == '+') 4160 break; 4161 i++; 4162 if (i == (ssize_t) argc) 4163 ThrowMogrifyException(OptionError,"MissingArgument",option); 4164 break; 4165 } 4166 if (LocaleCompare("composite",option+1) == 0) 4167 break; 4168 if (LocaleCompare("compress",option+1) == 0) 4169 { 4170 ssize_t 4171 compress; 4172 4173 if (*option == '+') 4174 break; 4175 i++; 4176 if (i == (ssize_t) argc) 4177 ThrowMogrifyException(OptionError,"MissingArgument",option); 4178 compress=ParseCommandOption(MagickCompressOptions,MagickFalse, 4179 argv[i]); 4180 if (compress < 0) 4181 ThrowMogrifyException(OptionError,"UnrecognizedImageCompression", 4182 argv[i]); 4183 break; 4184 } 4185 if (LocaleCompare("concurrent",option+1) == 0) 4186 break; 4187 if (LocaleCompare("contrast",option+1) == 0) 4188 break; 4189 if (LocaleCompare("contrast-stretch",option+1) == 0) 4190 { 4191 i++; 4192 if (i == (ssize_t) argc) 4193 ThrowMogrifyException(OptionError,"MissingArgument",option); 4194 if (IsGeometry(argv[i]) == MagickFalse) 4195 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4196 break; 4197 } 4198 if (LocaleCompare("convolve",option+1) == 0) 4199 { 4200 KernelInfo 4201 *kernel_info; 4202 4203 if (*option == '+') 4204 break; 4205 i++; 4206 if (i == (ssize_t) argc) 4207 ThrowMogrifyException(OptionError,"MissingArgument",option); 4208 kernel_info=AcquireKernelInfo(argv[i]); 4209 if (kernel_info == (KernelInfo *) NULL) 4210 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4211 kernel_info=DestroyKernelInfo(kernel_info); 4212 break; 4213 } 4214 if (LocaleCompare("crop",option+1) == 0) 4215 { 4216 if (*option == '+') 4217 break; 4218 i++; 4219 if (i == (ssize_t) argc) 4220 ThrowMogrifyException(OptionError,"MissingArgument",option); 4221 if (IsGeometry(argv[i]) == MagickFalse) 4222 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4223 break; 4224 } 4225 if (LocaleCompare("cycle",option+1) == 0) 4226 { 4227 if (*option == '+') 4228 break; 4229 i++; 4230 if (i == (ssize_t) argc) 4231 ThrowMogrifyException(OptionError,"MissingArgument",option); 4232 if (IsGeometry(argv[i]) == MagickFalse) 4233 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4234 break; 4235 } 4236 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 4237 } 4238 case 'd': 4239 { 4240 if (LocaleCompare("decipher",option+1) == 0) 4241 { 4242 if (*option == '+') 4243 break; 4244 i++; 4245 if (i == (ssize_t) (argc-1)) 4246 ThrowMogrifyException(OptionError,"MissingArgument",option); 4247 break; 4248 } 4249 if (LocaleCompare("deconstruct",option+1) == 0) 4250 break; 4251 if (LocaleCompare("debug",option+1) == 0) 4252 { 4253 ssize_t 4254 event; 4255 4256 if (*option == '+') 4257 break; 4258 i++; 4259 if (i == (ssize_t) argc) 4260 ThrowMogrifyException(OptionError,"MissingArgument",option); 4261 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); 4262 if (event < 0) 4263 ThrowMogrifyException(OptionError,"UnrecognizedEventType", 4264 argv[i]); 4265 (void) SetLogEventMask(argv[i]); 4266 break; 4267 } 4268 if (LocaleCompare("define",option+1) == 0) 4269 { 4270 i++; 4271 if (i == (ssize_t) argc) 4272 ThrowMogrifyException(OptionError,"MissingArgument",option); 4273 if (*option == '+') 4274 { 4275 const char 4276 *define; 4277 4278 define=GetImageOption(image_info,argv[i]); 4279 if (define == (const char *) NULL) 4280 ThrowMogrifyException(OptionError,"NoSuchOption",argv[i]); 4281 break; 4282 } 4283 break; 4284 } 4285 if (LocaleCompare("delay",option+1) == 0) 4286 { 4287 if (*option == '+') 4288 break; 4289 i++; 4290 if (i == (ssize_t) argc) 4291 ThrowMogrifyException(OptionError,"MissingArgument",option); 4292 if (IsGeometry(argv[i]) == MagickFalse) 4293 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4294 break; 4295 } 4296 if (LocaleCompare("delete",option+1) == 0) 4297 { 4298 if (*option == '+') 4299 break; 4300 i++; 4301 if (i == (ssize_t) (argc-1)) 4302 ThrowMogrifyException(OptionError,"MissingArgument",option); 4303 if (IsGeometry(argv[i]) == MagickFalse) 4304 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4305 break; 4306 } 4307 if (LocaleCompare("density",option+1) == 0) 4308 { 4309 if (*option == '+') 4310 break; 4311 i++; 4312 if (i == (ssize_t) argc) 4313 ThrowMogrifyException(OptionError,"MissingArgument",option); 4314 if (IsGeometry(argv[i]) == MagickFalse) 4315 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4316 break; 4317 } 4318 if (LocaleCompare("depth",option+1) == 0) 4319 { 4320 if (*option == '+') 4321 break; 4322 i++; 4323 if (i == (ssize_t) argc) 4324 ThrowMogrifyException(OptionError,"MissingArgument",option); 4325 if (IsGeometry(argv[i]) == MagickFalse) 4326 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4327 break; 4328 } 4329 if (LocaleCompare("deskew",option+1) == 0) 4330 { 4331 if (*option == '+') 4332 break; 4333 i++; 4334 if (i == (ssize_t) argc) 4335 ThrowMogrifyException(OptionError,"MissingArgument",option); 4336 if (IsGeometry(argv[i]) == MagickFalse) 4337 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4338 break; 4339 } 4340 if (LocaleCompare("despeckle",option+1) == 0) 4341 break; 4342 if (LocaleCompare("dft",option+1) == 0) 4343 break; 4344 if (LocaleCompare("direction",option+1) == 0) 4345 { 4346 ssize_t 4347 direction; 4348 4349 if (*option == '+') 4350 break; 4351 i++; 4352 if (i == (ssize_t) argc) 4353 ThrowMogrifyException(OptionError,"MissingArgument",option); 4354 direction=ParseCommandOption(MagickDirectionOptions,MagickFalse, 4355 argv[i]); 4356 if (direction < 0) 4357 ThrowMogrifyException(OptionError,"UnrecognizedDirectionType", 4358 argv[i]); 4359 break; 4360 } 4361 if (LocaleCompare("display",option+1) == 0) 4362 { 4363 if (*option == '+') 4364 break; 4365 i++; 4366 if (i == (ssize_t) argc) 4367 ThrowMogrifyException(OptionError,"MissingArgument",option); 4368 break; 4369 } 4370 if (LocaleCompare("dispose",option+1) == 0) 4371 { 4372 ssize_t 4373 dispose; 4374 4375 if (*option == '+') 4376 break; 4377 i++; 4378 if (i == (ssize_t) argc) 4379 ThrowMogrifyException(OptionError,"MissingArgument",option); 4380 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); 4381 if (dispose < 0) 4382 ThrowMogrifyException(OptionError,"UnrecognizedDisposeMethod", 4383 argv[i]); 4384 break; 4385 } 4386 if (LocaleCompare("distort",option+1) == 0) 4387 { 4388 ssize_t 4389 op; 4390 4391 i++; 4392 if (i == (ssize_t) argc) 4393 ThrowMogrifyException(OptionError,"MissingArgument",option); 4394 op=ParseCommandOption(MagickDistortOptions,MagickFalse,argv[i]); 4395 if (op < 0) 4396 ThrowMogrifyException(OptionError,"UnrecognizedDistortMethod", 4397 argv[i]); 4398 i++; 4399 if (i == (ssize_t) (argc-1)) 4400 ThrowMogrifyException(OptionError,"MissingArgument",option); 4401 break; 4402 } 4403 if (LocaleCompare("dither",option+1) == 0) 4404 { 4405 ssize_t 4406 method; 4407 4408 if (*option == '+') 4409 break; 4410 i++; 4411 if (i == (ssize_t) argc) 4412 ThrowMogrifyException(OptionError,"MissingArgument",option); 4413 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); 4414 if (method < 0) 4415 ThrowMogrifyException(OptionError,"UnrecognizedDitherMethod", 4416 argv[i]); 4417 break; 4418 } 4419 if (LocaleCompare("draw",option+1) == 0) 4420 { 4421 if (*option == '+') 4422 break; 4423 i++; 4424 if (i == (ssize_t) argc) 4425 ThrowMogrifyException(OptionError,"MissingArgument",option); 4426 break; 4427 } 4428 if (LocaleCompare("duplicate",option+1) == 0) 4429 { 4430 if (*option == '+') 4431 break; 4432 i++; 4433 if (i == (ssize_t) (argc-1)) 4434 ThrowMogrifyException(OptionError,"MissingArgument",option); 4435 if (IsGeometry(argv[i]) == MagickFalse) 4436 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4437 break; 4438 } 4439 if (LocaleCompare("duration",option+1) == 0) 4440 { 4441 if (*option == '+') 4442 break; 4443 i++; 4444 if (i == (ssize_t) (argc-1)) 4445 ThrowMogrifyException(OptionError,"MissingArgument",option); 4446 if (IsGeometry(argv[i]) == MagickFalse) 4447 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4448 break; 4449 } 4450 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 4451 } 4452 case 'e': 4453 { 4454 if (LocaleCompare("edge",option+1) == 0) 4455 { 4456 if (*option == '+') 4457 break; 4458 i++; 4459 if (i == (ssize_t) argc) 4460 ThrowMogrifyException(OptionError,"MissingArgument",option); 4461 if (IsGeometry(argv[i]) == MagickFalse) 4462 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4463 break; 4464 } 4465 if (LocaleCompare("emboss",option+1) == 0) 4466 { 4467 if (*option == '+') 4468 break; 4469 i++; 4470 if (i == (ssize_t) argc) 4471 ThrowMogrifyException(OptionError,"MissingArgument",option); 4472 if (IsGeometry(argv[i]) == MagickFalse) 4473 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4474 break; 4475 } 4476 if (LocaleCompare("encipher",option+1) == 0) 4477 { 4478 if (*option == '+') 4479 break; 4480 i++; 4481 if (i == (ssize_t) argc) 4482 ThrowMogrifyException(OptionError,"MissingArgument",option); 4483 break; 4484 } 4485 if (LocaleCompare("encoding",option+1) == 0) 4486 { 4487 if (*option == '+') 4488 break; 4489 i++; 4490 if (i == (ssize_t) argc) 4491 ThrowMogrifyException(OptionError,"MissingArgument",option); 4492 break; 4493 } 4494 if (LocaleCompare("endian",option+1) == 0) 4495 { 4496 ssize_t 4497 endian; 4498 4499 if (*option == '+') 4500 break; 4501 i++; 4502 if (i == (ssize_t) argc) 4503 ThrowMogrifyException(OptionError,"MissingArgument",option); 4504 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,argv[i]); 4505 if (endian < 0) 4506 ThrowMogrifyException(OptionError,"UnrecognizedEndianType", 4507 argv[i]); 4508 break; 4509 } 4510 if (LocaleCompare("enhance",option+1) == 0) 4511 break; 4512 if (LocaleCompare("equalize",option+1) == 0) 4513 break; 4514 if (LocaleCompare("evaluate",option+1) == 0) 4515 { 4516 ssize_t 4517 op; 4518 4519 if (*option == '+') 4520 break; 4521 i++; 4522 if (i == (ssize_t) argc) 4523 ThrowMogrifyException(OptionError,"MissingArgument",option); 4524 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); 4525 if (op < 0) 4526 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", 4527 argv[i]); 4528 i++; 4529 if (i == (ssize_t) (argc-1)) 4530 ThrowMogrifyException(OptionError,"MissingArgument",option); 4531 if (IsGeometry(argv[i]) == MagickFalse) 4532 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4533 break; 4534 } 4535 if (LocaleCompare("evaluate-sequence",option+1) == 0) 4536 { 4537 ssize_t 4538 op; 4539 4540 if (*option == '+') 4541 break; 4542 i++; 4543 if (i == (ssize_t) argc) 4544 ThrowMogrifyException(OptionError,"MissingArgument",option); 4545 op=ParseCommandOption(MagickEvaluateOptions,MagickFalse,argv[i]); 4546 if (op < 0) 4547 ThrowMogrifyException(OptionError,"UnrecognizedEvaluateOperator", 4548 argv[i]); 4549 break; 4550 } 4551 if (LocaleCompare("extent",option+1) == 0) 4552 { 4553 if (*option == '+') 4554 break; 4555 i++; 4556 if (i == (ssize_t) argc) 4557 ThrowMogrifyException(OptionError,"MissingArgument",option); 4558 if (IsGeometry(argv[i]) == MagickFalse) 4559 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4560 break; 4561 } 4562 if (LocaleCompare("extract",option+1) == 0) 4563 { 4564 if (*option == '+') 4565 break; 4566 i++; 4567 if (i == (ssize_t) argc) 4568 ThrowMogrifyException(OptionError,"MissingArgument",option); 4569 if (IsGeometry(argv[i]) == MagickFalse) 4570 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4571 break; 4572 } 4573 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 4574 } 4575 case 'f': 4576 { 4577 if (LocaleCompare("family",option+1) == 0) 4578 { 4579 if (*option == '+') 4580 break; 4581 i++; 4582 if (i == (ssize_t) (argc-1)) 4583 ThrowMogrifyException(OptionError,"MissingArgument",option); 4584 break; 4585 } 4586 if (LocaleCompare("features",option+1) == 0) 4587 { 4588 if (*option == '+') 4589 break; 4590 i++; 4591 if (i == (ssize_t) (argc-1)) 4592 ThrowMogrifyException(OptionError,"MissingArgument",option); 4593 if (IsGeometry(argv[i]) == MagickFalse) 4594 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4595 break; 4596 } 4597 if (LocaleCompare("fill",option+1) == 0) 4598 { 4599 if (*option == '+') 4600 break; 4601 i++; 4602 if (i == (ssize_t) argc) 4603 ThrowMogrifyException(OptionError,"MissingArgument",option); 4604 break; 4605 } 4606 if (LocaleCompare("filter",option+1) == 0) 4607 { 4608 ssize_t 4609 filter; 4610 4611 if (*option == '+') 4612 break; 4613 i++; 4614 if (i == (ssize_t) argc) 4615 ThrowMogrifyException(OptionError,"MissingArgument",option); 4616 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); 4617 if (filter < 0) 4618 ThrowMogrifyException(OptionError,"UnrecognizedImageFilter", 4619 argv[i]); 4620 break; 4621 } 4622 if (LocaleCompare("flatten",option+1) == 0) 4623 break; 4624 if (LocaleCompare("flip",option+1) == 0) 4625 break; 4626 if (LocaleCompare("flop",option+1) == 0) 4627 break; 4628 if (LocaleCompare("floodfill",option+1) == 0) 4629 { 4630 if (*option == '+') 4631 break; 4632 i++; 4633 if (i == (ssize_t) argc) 4634 ThrowMogrifyException(OptionError,"MissingArgument",option); 4635 if (IsGeometry(argv[i]) == MagickFalse) 4636 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4637 i++; 4638 if (i == (ssize_t) argc) 4639 ThrowMogrifyException(OptionError,"MissingArgument",option); 4640 break; 4641 } 4642 if (LocaleCompare("font",option+1) == 0) 4643 { 4644 if (*option == '+') 4645 break; 4646 i++; 4647 if (i == (ssize_t) argc) 4648 ThrowMogrifyException(OptionError,"MissingArgument",option); 4649 break; 4650 } 4651 if (LocaleCompare("format",option+1) == 0) 4652 { 4653 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); 4654 (void) CloneString(&format,(char *) NULL); 4655 if (*option == '+') 4656 break; 4657 i++; 4658 if (i == (ssize_t) argc) 4659 ThrowMogrifyException(OptionError,"MissingArgument",option); 4660 (void) CloneString(&format,argv[i]); 4661 (void) CopyMagickString(image_info->filename,format,MaxTextExtent); 4662 (void) ConcatenateMagickString(image_info->filename,":", 4663 MaxTextExtent); 4664 (void) SetImageInfo(image_info,0,exception); 4665 if (*image_info->magick == '\0') 4666 ThrowMogrifyException(OptionError,"UnrecognizedImageFormat", 4667 format); 4668 break; 4669 } 4670 if (LocaleCompare("frame",option+1) == 0) 4671 { 4672 if (*option == '+') 4673 break; 4674 i++; 4675 if (i == (ssize_t) argc) 4676 ThrowMogrifyException(OptionError,"MissingArgument",option); 4677 if (IsGeometry(argv[i]) == MagickFalse) 4678 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4679 break; 4680 } 4681 if (LocaleCompare("function",option+1) == 0) 4682 { 4683 ssize_t 4684 op; 4685 4686 if (*option == '+') 4687 break; 4688 i++; 4689 if (i == (ssize_t) argc) 4690 ThrowMogrifyException(OptionError,"MissingArgument",option); 4691 op=ParseCommandOption(MagickFunctionOptions,MagickFalse,argv[i]); 4692 if (op < 0) 4693 ThrowMogrifyException(OptionError,"UnrecognizedFunction",argv[i]); 4694 i++; 4695 if (i == (ssize_t) (argc-1)) 4696 ThrowMogrifyException(OptionError,"MissingArgument",option); 4697 break; 4698 } 4699 if (LocaleCompare("fuzz",option+1) == 0) 4700 { 4701 if (*option == '+') 4702 break; 4703 i++; 4704 if (i == (ssize_t) argc) 4705 ThrowMogrifyException(OptionError,"MissingArgument",option); 4706 if (IsGeometry(argv[i]) == MagickFalse) 4707 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4708 break; 4709 } 4710 if (LocaleCompare("fx",option+1) == 0) 4711 { 4712 if (*option == '+') 4713 break; 4714 i++; 4715 if (i == (ssize_t) (argc-1)) 4716 ThrowMogrifyException(OptionError,"MissingArgument",option); 4717 break; 4718 } 4719 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 4720 } 4721 case 'g': 4722 { 4723 if (LocaleCompare("gamma",option+1) == 0) 4724 { 4725 i++; 4726 if (i == (ssize_t) argc) 4727 ThrowMogrifyException(OptionError,"MissingArgument",option); 4728 if (IsGeometry(argv[i]) == MagickFalse) 4729 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4730 break; 4731 } 4732 if ((LocaleCompare("gaussian-blur",option+1) == 0) || 4733 (LocaleCompare("gaussian",option+1) == 0)) 4734 { 4735 i++; 4736 if (i == (ssize_t) argc) 4737 ThrowMogrifyException(OptionError,"MissingArgument",option); 4738 if (IsGeometry(argv[i]) == MagickFalse) 4739 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4740 break; 4741 } 4742 if (LocaleCompare("geometry",option+1) == 0) 4743 { 4744 if (*option == '+') 4745 break; 4746 i++; 4747 if (i == (ssize_t) argc) 4748 ThrowMogrifyException(OptionError,"MissingArgument",option); 4749 if (IsGeometry(argv[i]) == MagickFalse) 4750 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4751 break; 4752 } 4753 if (LocaleCompare("gravity",option+1) == 0) 4754 { 4755 ssize_t 4756 gravity; 4757 4758 if (*option == '+') 4759 break; 4760 i++; 4761 if (i == (ssize_t) argc) 4762 ThrowMogrifyException(OptionError,"MissingArgument",option); 4763 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse, 4764 argv[i]); 4765 if (gravity < 0) 4766 ThrowMogrifyException(OptionError,"UnrecognizedGravityType", 4767 argv[i]); 4768 break; 4769 } 4770 if (LocaleCompare("grayscale",option+1) == 0) 4771 { 4772 ssize_t 4773 method; 4774 4775 if (*option == '+') 4776 break; 4777 i++; 4778 if (i == (ssize_t) (argc-1)) 4779 ThrowMogrifyException(OptionError,"MissingArgument",option); 4780 method=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse, 4781 argv[i]); 4782 if (method < 0) 4783 ThrowMogrifyException(OptionError,"UnrecognizedIntensityMethod", 4784 argv[i]); 4785 break; 4786 } 4787 if (LocaleCompare("green-primary",option+1) == 0) 4788 { 4789 if (*option == '+') 4790 break; 4791 i++; 4792 if (i == (ssize_t) argc) 4793 ThrowMogrifyException(OptionError,"MissingArgument",option); 4794 if (IsGeometry(argv[i]) == MagickFalse) 4795 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4796 break; 4797 } 4798 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 4799 } 4800 case 'h': 4801 { 4802 if (LocaleCompare("hald-clut",option+1) == 0) 4803 break; 4804 if ((LocaleCompare("help",option+1) == 0) || 4805 (LocaleCompare("-help",option+1) == 0)) 4806 return(MogrifyUsage()); 4807 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 4808 } 4809 case 'i': 4810 { 4811 if (LocaleCompare("identify",option+1) == 0) 4812 break; 4813 if (LocaleCompare("idft",option+1) == 0) 4814 break; 4815 if (LocaleCompare("implode",option+1) == 0) 4816 { 4817 if (*option == '+') 4818 break; 4819 i++; 4820 if (i == (ssize_t) argc) 4821 ThrowMogrifyException(OptionError,"MissingArgument",option); 4822 if (IsGeometry(argv[i]) == MagickFalse) 4823 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4824 break; 4825 } 4826 if (LocaleCompare("intensity",option+1) == 0) 4827 { 4828 ssize_t 4829 intensity; 4830 4831 if (*option == '+') 4832 break; 4833 i++; 4834 if (i == (ssize_t) (argc-1)) 4835 ThrowMogrifyException(OptionError,"MissingArgument",option); 4836 intensity=ParseCommandOption(MagickPixelIntensityOptions, 4837 MagickFalse,argv[i]); 4838 if (intensity < 0) 4839 ThrowMogrifyException(OptionError, 4840 "UnrecognizedPixelIntensityMethod",argv[i]); 4841 break; 4842 } 4843 if (LocaleCompare("intent",option+1) == 0) 4844 { 4845 ssize_t 4846 intent; 4847 4848 if (*option == '+') 4849 break; 4850 i++; 4851 if (i == (ssize_t) (argc-1)) 4852 ThrowMogrifyException(OptionError,"MissingArgument",option); 4853 intent=ParseCommandOption(MagickIntentOptions,MagickFalse,argv[i]); 4854 if (intent < 0) 4855 ThrowMogrifyException(OptionError,"UnrecognizedIntentType", 4856 argv[i]); 4857 break; 4858 } 4859 if (LocaleCompare("interlace",option+1) == 0) 4860 { 4861 ssize_t 4862 interlace; 4863 4864 if (*option == '+') 4865 break; 4866 i++; 4867 if (i == (ssize_t) argc) 4868 ThrowMogrifyException(OptionError,"MissingArgument",option); 4869 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, 4870 argv[i]); 4871 if (interlace < 0) 4872 ThrowMogrifyException(OptionError,"UnrecognizedInterlaceType", 4873 argv[i]); 4874 break; 4875 } 4876 if (LocaleCompare("interline-spacing",option+1) == 0) 4877 { 4878 if (*option == '+') 4879 break; 4880 i++; 4881 if (i == (ssize_t) (argc-1)) 4882 ThrowMogrifyException(OptionError,"MissingArgument",option); 4883 if (IsGeometry(argv[i]) == MagickFalse) 4884 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4885 break; 4886 } 4887 if (LocaleCompare("interpolate",option+1) == 0) 4888 { 4889 ssize_t 4890 interpolate; 4891 4892 if (*option == '+') 4893 break; 4894 i++; 4895 if (i == (ssize_t) argc) 4896 ThrowMogrifyException(OptionError,"MissingArgument",option); 4897 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, 4898 argv[i]); 4899 if (interpolate < 0) 4900 ThrowMogrifyException(OptionError,"UnrecognizedInterpolateMethod", 4901 argv[i]); 4902 break; 4903 } 4904 if (LocaleCompare("interword-spacing",option+1) == 0) 4905 { 4906 if (*option == '+') 4907 break; 4908 i++; 4909 if (i == (ssize_t) (argc-1)) 4910 ThrowMogrifyException(OptionError,"MissingArgument",option); 4911 if (IsGeometry(argv[i]) == MagickFalse) 4912 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4913 break; 4914 } 4915 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 4916 } 4917 case 'k': 4918 { 4919 if (LocaleCompare("kerning",option+1) == 0) 4920 { 4921 if (*option == '+') 4922 break; 4923 i++; 4924 if (i == (ssize_t) (argc-1)) 4925 ThrowMogrifyException(OptionError,"MissingArgument",option); 4926 if (IsGeometry(argv[i]) == MagickFalse) 4927 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4928 break; 4929 } 4930 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 4931 } 4932 case 'l': 4933 { 4934 if (LocaleCompare("label",option+1) == 0) 4935 { 4936 if (*option == '+') 4937 break; 4938 i++; 4939 if (i == (ssize_t) argc) 4940 ThrowMogrifyException(OptionError,"MissingArgument",option); 4941 break; 4942 } 4943 if (LocaleCompare("lat",option+1) == 0) 4944 { 4945 if (*option == '+') 4946 break; 4947 i++; 4948 if (i == (ssize_t) argc) 4949 ThrowMogrifyException(OptionError,"MissingArgument",option); 4950 if (IsGeometry(argv[i]) == MagickFalse) 4951 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4952 } 4953 if (LocaleCompare("layers",option+1) == 0) 4954 { 4955 ssize_t 4956 type; 4957 4958 if (*option == '+') 4959 break; 4960 i++; 4961 if (i == (ssize_t) (argc-1)) 4962 ThrowMogrifyException(OptionError,"MissingArgument",option); 4963 type=ParseCommandOption(MagickLayerOptions,MagickFalse,argv[i]); 4964 if (type < 0) 4965 ThrowMogrifyException(OptionError,"UnrecognizedLayerMethod", 4966 argv[i]); 4967 break; 4968 } 4969 if (LocaleCompare("level",option+1) == 0) 4970 { 4971 i++; 4972 if (i == (ssize_t) argc) 4973 ThrowMogrifyException(OptionError,"MissingArgument",option); 4974 if (IsGeometry(argv[i]) == MagickFalse) 4975 ThrowMogrifyInvalidArgumentException(option,argv[i]); 4976 break; 4977 } 4978 if (LocaleCompare("level-colors",option+1) == 0) 4979 { 4980 i++; 4981 if (i == (ssize_t) argc) 4982 ThrowMogrifyException(OptionError,"MissingArgument",option); 4983 break; 4984 } 4985 if (LocaleCompare("limit",option+1) == 0) 4986 { 4987 char 4988 *p; 4989 4990 double 4991 value; 4992 4993 ssize_t 4994 resource; 4995 4996 if (*option == '+') 4997 break; 4998 i++; 4999 if (i == (ssize_t) argc) 5000 ThrowMogrifyException(OptionError,"MissingArgument",option); 5001 resource=ParseCommandOption(MagickResourceOptions,MagickFalse, 5002 argv[i]); 5003 if (resource < 0) 5004 ThrowMogrifyException(OptionError,"UnrecognizedResourceType", 5005 argv[i]); 5006 i++; 5007 if (i == (ssize_t) argc) 5008 ThrowMogrifyException(OptionError,"MissingArgument",option); 5009 value=StringToDouble(argv[i],&p); 5010 (void) value; 5011 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) 5012 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5013 break; 5014 } 5015 if (LocaleCompare("liquid-rescale",option+1) == 0) 5016 { 5017 i++; 5018 if (i == (ssize_t) argc) 5019 ThrowMogrifyException(OptionError,"MissingArgument",option); 5020 if (IsGeometry(argv[i]) == MagickFalse) 5021 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5022 break; 5023 } 5024 if (LocaleCompare("list",option+1) == 0) 5025 { 5026 ssize_t 5027 list; 5028 5029 if (*option == '+') 5030 break; 5031 i++; 5032 if (i == (ssize_t) argc) 5033 ThrowMogrifyException(OptionError,"MissingArgument",option); 5034 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); 5035 if (list < 0) 5036 ThrowMogrifyException(OptionError,"UnrecognizedListType",argv[i]); 5037 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) 5038 argv+j,exception); 5039 return(status != 0 ? MagickFalse : MagickTrue); 5040 } 5041 if (LocaleCompare("log",option+1) == 0) 5042 { 5043 if (*option == '+') 5044 break; 5045 i++; 5046 if ((i == (ssize_t) argc) || 5047 (strchr(argv[i],'%') == (char *) NULL)) 5048 ThrowMogrifyException(OptionError,"MissingArgument",option); 5049 break; 5050 } 5051 if (LocaleCompare("loop",option+1) == 0) 5052 { 5053 if (*option == '+') 5054 break; 5055 i++; 5056 if (i == (ssize_t) argc) 5057 ThrowMogrifyException(OptionError,"MissingArgument",option); 5058 if (IsGeometry(argv[i]) == MagickFalse) 5059 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5060 break; 5061 } 5062 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 5063 } 5064 case 'm': 5065 { 5066 if (LocaleCompare("map",option+1) == 0) 5067 { 5068 global_colormap=(*option == '+') ? MagickTrue : MagickFalse; 5069 if (*option == '+') 5070 break; 5071 i++; 5072 if (i == (ssize_t) argc) 5073 ThrowMogrifyException(OptionError,"MissingArgument",option); 5074 break; 5075 } 5076 if (LocaleCompare("mask",option+1) == 0) 5077 { 5078 if (*option == '+') 5079 break; 5080 i++; 5081 if (i == (ssize_t) argc) 5082 ThrowMogrifyException(OptionError,"MissingArgument",option); 5083 break; 5084 } 5085 if (LocaleCompare("matte",option+1) == 0) 5086 break; 5087 if (LocaleCompare("mattecolor",option+1) == 0) 5088 { 5089 if (*option == '+') 5090 break; 5091 i++; 5092 if (i == (ssize_t) argc) 5093 ThrowMogrifyException(OptionError,"MissingArgument",option); 5094 break; 5095 } 5096 if (LocaleCompare("maximum",option+1) == 0) 5097 break; 5098 if (LocaleCompare("metric",option+1) == 0) 5099 { 5100 ssize_t 5101 type; 5102 5103 if (*option == '+') 5104 break; 5105 i++; 5106 if (i == (ssize_t) argc) 5107 ThrowMogrifyException(OptionError,"MissingArgument",option); 5108 type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]); 5109 if (type < 0) 5110 ThrowMogrifyException(OptionError,"UnrecognizedMetricType", 5111 argv[i]); 5112 break; 5113 } 5114 if (LocaleCompare("minimum",option+1) == 0) 5115 break; 5116 if (LocaleCompare("modulate",option+1) == 0) 5117 { 5118 if (*option == '+') 5119 break; 5120 i++; 5121 if (i == (ssize_t) argc) 5122 ThrowMogrifyException(OptionError,"MissingArgument",option); 5123 if (IsGeometry(argv[i]) == MagickFalse) 5124 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5125 break; 5126 } 5127 if (LocaleCompare("median",option+1) == 0) 5128 { 5129 if (*option == '+') 5130 break; 5131 i++; 5132 if (i == (ssize_t) argc) 5133 ThrowMogrifyException(OptionError,"MissingArgument",option); 5134 if (IsGeometry(argv[i]) == MagickFalse) 5135 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5136 break; 5137 } 5138 if (LocaleCompare("mode",option+1) == 0) 5139 { 5140 if (*option == '+') 5141 break; 5142 i++; 5143 if (i == (ssize_t) argc) 5144 ThrowMogrifyException(OptionError,"MissingArgument",option); 5145 if (IsGeometry(argv[i]) == MagickFalse) 5146 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5147 break; 5148 } 5149 if (LocaleCompare("monitor",option+1) == 0) 5150 break; 5151 if (LocaleCompare("monochrome",option+1) == 0) 5152 break; 5153 if (LocaleCompare("morph",option+1) == 0) 5154 { 5155 if (*option == '+') 5156 break; 5157 i++; 5158 if (i == (ssize_t) (argc-1)) 5159 ThrowMogrifyException(OptionError,"MissingArgument",option); 5160 if (IsGeometry(argv[i]) == MagickFalse) 5161 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5162 break; 5163 } 5164 if (LocaleCompare("morphology",option+1) == 0) 5165 { 5166 char 5167 token[MaxTextExtent]; 5168 5169 KernelInfo 5170 *kernel_info; 5171 5172 ssize_t 5173 op; 5174 5175 i++; 5176 if (i == (ssize_t) argc) 5177 ThrowMogrifyException(OptionError,"MissingArgument",option); 5178 GetMagickToken(argv[i],NULL,token); 5179 op=ParseCommandOption(MagickMorphologyOptions,MagickFalse,token); 5180 if (op < 0) 5181 ThrowMogrifyException(OptionError,"UnrecognizedMorphologyMethod", 5182 token); 5183 i++; 5184 if (i == (ssize_t) (argc-1)) 5185 ThrowMogrifyException(OptionError,"MissingArgument",option); 5186 kernel_info=AcquireKernelInfo(argv[i]); 5187 if (kernel_info == (KernelInfo *) NULL) 5188 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5189 kernel_info=DestroyKernelInfo(kernel_info); 5190 break; 5191 } 5192 if (LocaleCompare("mosaic",option+1) == 0) 5193 break; 5194 if (LocaleCompare("motion-blur",option+1) == 0) 5195 { 5196 if (*option == '+') 5197 break; 5198 i++; 5199 if (i == (ssize_t) argc) 5200 ThrowMogrifyException(OptionError,"MissingArgument",option); 5201 if (IsGeometry(argv[i]) == MagickFalse) 5202 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5203 break; 5204 } 5205 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 5206 } 5207 case 'n': 5208 { 5209 if (LocaleCompare("negate",option+1) == 0) 5210 break; 5211 if (LocaleCompare("noise",option+1) == 0) 5212 { 5213 i++; 5214 if (i == (ssize_t) argc) 5215 ThrowMogrifyException(OptionError,"MissingArgument",option); 5216 if (*option == '+') 5217 { 5218 ssize_t 5219 noise; 5220 5221 noise=ParseCommandOption(MagickNoiseOptions,MagickFalse,argv[i]); 5222 if (noise < 0) 5223 ThrowMogrifyException(OptionError,"UnrecognizedNoiseType", 5224 argv[i]); 5225 break; 5226 } 5227 if (IsGeometry(argv[i]) == MagickFalse) 5228 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5229 break; 5230 } 5231 if (LocaleCompare("noop",option+1) == 0) 5232 break; 5233 if (LocaleCompare("normalize",option+1) == 0) 5234 break; 5235 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 5236 } 5237 case 'o': 5238 { 5239 if (LocaleCompare("opaque",option+1) == 0) 5240 { 5241 i++; 5242 if (i == (ssize_t) argc) 5243 ThrowMogrifyException(OptionError,"MissingArgument",option); 5244 break; 5245 } 5246 if (LocaleCompare("ordered-dither",option+1) == 0) 5247 { 5248 if (*option == '+') 5249 break; 5250 i++; 5251 if (i == (ssize_t) argc) 5252 ThrowMogrifyException(OptionError,"MissingArgument",option); 5253 break; 5254 } 5255 if (LocaleCompare("orient",option+1) == 0) 5256 { 5257 ssize_t 5258 orientation; 5259 5260 orientation=UndefinedOrientation; 5261 if (*option == '+') 5262 break; 5263 i++; 5264 if (i == (ssize_t) (argc-1)) 5265 ThrowMogrifyException(OptionError,"MissingArgument",option); 5266 orientation=ParseCommandOption(MagickOrientationOptions,MagickFalse, 5267 argv[i]); 5268 if (orientation < 0) 5269 ThrowMogrifyException(OptionError,"UnrecognizedImageOrientation", 5270 argv[i]); 5271 break; 5272 } 5273 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 5274 } 5275 case 'p': 5276 { 5277 if (LocaleCompare("page",option+1) == 0) 5278 { 5279 if (*option == '+') 5280 break; 5281 i++; 5282 if (i == (ssize_t) argc) 5283 ThrowMogrifyException(OptionError,"MissingArgument",option); 5284 break; 5285 } 5286 if (LocaleCompare("paint",option+1) == 0) 5287 { 5288 if (*option == '+') 5289 break; 5290 i++; 5291 if (i == (ssize_t) argc) 5292 ThrowMogrifyException(OptionError,"MissingArgument",option); 5293 if (IsGeometry(argv[i]) == MagickFalse) 5294 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5295 break; 5296 } 5297 if (LocaleCompare("path",option+1) == 0) 5298 { 5299 (void) CloneString(&path,(char *) NULL); 5300 if (*option == '+') 5301 break; 5302 i++; 5303 if (i == (ssize_t) argc) 5304 ThrowMogrifyException(OptionError,"MissingArgument",option); 5305 (void) CloneString(&path,argv[i]); 5306 break; 5307 } 5308 if (LocaleCompare("perceptible",option+1) == 0) 5309 { 5310 if (*option == '+') 5311 break; 5312 i++; 5313 if (i == (ssize_t) argc) 5314 ThrowMogrifyException(OptionError,"MissingArgument",option); 5315 if (IsGeometry(argv[i]) == MagickFalse) 5316 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5317 break; 5318 } 5319 if (LocaleCompare("pointsize",option+1) == 0) 5320 { 5321 if (*option == '+') 5322 break; 5323 i++; 5324 if (i == (ssize_t) argc) 5325 ThrowMogrifyException(OptionError,"MissingArgument",option); 5326 if (IsGeometry(argv[i]) == MagickFalse) 5327 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5328 break; 5329 } 5330 if (LocaleCompare("polaroid",option+1) == 0) 5331 { 5332 if (*option == '+') 5333 break; 5334 i++; 5335 if (i == (ssize_t) argc) 5336 ThrowMogrifyException(OptionError,"MissingArgument",option); 5337 if (IsGeometry(argv[i]) == MagickFalse) 5338 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5339 break; 5340 } 5341 if (LocaleCompare("poly",option+1) == 0) 5342 { 5343 if (*option == '+') 5344 break; 5345 i++; 5346 if (i == (ssize_t) argc) 5347 ThrowMogrifyException(OptionError,"MissingArgument",option); 5348 if (IsGeometry(argv[i]) == MagickFalse) 5349 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5350 break; 5351 } 5352 if (LocaleCompare("posterize",option+1) == 0) 5353 { 5354 if (*option == '+') 5355 break; 5356 i++; 5357 if (i == (ssize_t) argc) 5358 ThrowMogrifyException(OptionError,"MissingArgument",option); 5359 if (IsGeometry(argv[i]) == MagickFalse) 5360 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5361 break; 5362 } 5363 if (LocaleCompare("precision",option+1) == 0) 5364 { 5365 if (*option == '+') 5366 break; 5367 i++; 5368 if (i == (ssize_t) argc) 5369 ThrowMogrifyException(OptionError,"MissingArgument",option); 5370 if (IsGeometry(argv[i]) == MagickFalse) 5371 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5372 break; 5373 } 5374 if (LocaleCompare("print",option+1) == 0) 5375 { 5376 if (*option == '+') 5377 break; 5378 i++; 5379 if (i == (ssize_t) argc) 5380 ThrowMogrifyException(OptionError,"MissingArgument",option); 5381 break; 5382 } 5383 if (LocaleCompare("process",option+1) == 0) 5384 { 5385 if (*option == '+') 5386 break; 5387 i++; 5388 if (i == (ssize_t) (argc-1)) 5389 ThrowMogrifyException(OptionError,"MissingArgument",option); 5390 break; 5391 } 5392 if (LocaleCompare("profile",option+1) == 0) 5393 { 5394 i++; 5395 if (i == (ssize_t) argc) 5396 ThrowMogrifyException(OptionError,"MissingArgument",option); 5397 break; 5398 } 5399 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 5400 } 5401 case 'q': 5402 { 5403 if (LocaleCompare("quality",option+1) == 0) 5404 { 5405 if (*option == '+') 5406 break; 5407 i++; 5408 if (i == (ssize_t) argc) 5409 ThrowMogrifyException(OptionError,"MissingArgument",option); 5410 if (IsGeometry(argv[i]) == MagickFalse) 5411 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5412 break; 5413 } 5414 if (LocaleCompare("quantize",option+1) == 0) 5415 { 5416 ssize_t 5417 colorspace; 5418 5419 if (*option == '+') 5420 break; 5421 i++; 5422 if (i == (ssize_t) (argc-1)) 5423 ThrowMogrifyException(OptionError,"MissingArgument",option); 5424 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, 5425 argv[i]); 5426 if (colorspace < 0) 5427 ThrowMogrifyException(OptionError,"UnrecognizedColorspace", 5428 argv[i]); 5429 break; 5430 } 5431 if (LocaleCompare("quiet",option+1) == 0) 5432 break; 5433 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 5434 } 5435 case 'r': 5436 { 5437 if (LocaleCompare("radial-blur",option+1) == 0) 5438 { 5439 i++; 5440 if (i == (ssize_t) argc) 5441 ThrowMogrifyException(OptionError,"MissingArgument",option); 5442 if (IsGeometry(argv[i]) == MagickFalse) 5443 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5444 break; 5445 } 5446 if (LocaleCompare("raise",option+1) == 0) 5447 { 5448 i++; 5449 if (i == (ssize_t) argc) 5450 ThrowMogrifyException(OptionError,"MissingArgument",option); 5451 if (IsGeometry(argv[i]) == MagickFalse) 5452 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5453 break; 5454 } 5455 if (LocaleCompare("random-threshold",option+1) == 0) 5456 { 5457 if (*option == '+') 5458 break; 5459 i++; 5460 if (i == (ssize_t) argc) 5461 ThrowMogrifyException(OptionError,"MissingArgument",option); 5462 if (IsGeometry(argv[i]) == MagickFalse) 5463 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5464 break; 5465 } 5466 if (LocaleCompare("red-primary",option+1) == 0) 5467 { 5468 if (*option == '+') 5469 break; 5470 i++; 5471 if (i == (ssize_t) argc) 5472 ThrowMogrifyException(OptionError,"MissingArgument",option); 5473 if (IsGeometry(argv[i]) == MagickFalse) 5474 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5475 } 5476 if (LocaleCompare("regard-warnings",option+1) == 0) 5477 break; 5478 if (LocaleCompare("region",option+1) == 0) 5479 { 5480 if (*option == '+') 5481 break; 5482 i++; 5483 if (i == (ssize_t) argc) 5484 ThrowMogrifyException(OptionError,"MissingArgument",option); 5485 if (IsGeometry(argv[i]) == MagickFalse) 5486 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5487 break; 5488 } 5489 if (LocaleCompare("remap",option+1) == 0) 5490 { 5491 if (*option == '+') 5492 break; 5493 i++; 5494 if (i == (ssize_t) (argc-1)) 5495 ThrowMogrifyException(OptionError,"MissingArgument",option); 5496 break; 5497 } 5498 if (LocaleCompare("render",option+1) == 0) 5499 break; 5500 if (LocaleCompare("repage",option+1) == 0) 5501 { 5502 if (*option == '+') 5503 break; 5504 i++; 5505 if (i == (ssize_t) argc) 5506 ThrowMogrifyException(OptionError,"MissingArgument",option); 5507 if (IsGeometry(argv[i]) == MagickFalse) 5508 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5509 break; 5510 } 5511 if (LocaleCompare("resample",option+1) == 0) 5512 { 5513 if (*option == '+') 5514 break; 5515 i++; 5516 if (i == (ssize_t) argc) 5517 ThrowMogrifyException(OptionError,"MissingArgument",option); 5518 if (IsGeometry(argv[i]) == MagickFalse) 5519 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5520 break; 5521 } 5522 if (LocaleCompare("resize",option+1) == 0) 5523 { 5524 if (*option == '+') 5525 break; 5526 i++; 5527 if (i == (ssize_t) argc) 5528 ThrowMogrifyException(OptionError,"MissingArgument",option); 5529 if (IsGeometry(argv[i]) == MagickFalse) 5530 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5531 break; 5532 } 5533 if (LocaleNCompare("respect-parentheses",option+1,17) == 0) 5534 { 5535 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; 5536 break; 5537 } 5538 if (LocaleCompare("reverse",option+1) == 0) 5539 break; 5540 if (LocaleCompare("roll",option+1) == 0) 5541 { 5542 if (*option == '+') 5543 break; 5544 i++; 5545 if (i == (ssize_t) argc) 5546 ThrowMogrifyException(OptionError,"MissingArgument",option); 5547 if (IsGeometry(argv[i]) == MagickFalse) 5548 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5549 break; 5550 } 5551 if (LocaleCompare("rotate",option+1) == 0) 5552 { 5553 i++; 5554 if (i == (ssize_t) argc) 5555 ThrowMogrifyException(OptionError,"MissingArgument",option); 5556 if (IsGeometry(argv[i]) == MagickFalse) 5557 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5558 break; 5559 } 5560 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 5561 } 5562 case 's': 5563 { 5564 if (LocaleCompare("sample",option+1) == 0) 5565 { 5566 if (*option == '+') 5567 break; 5568 i++; 5569 if (i == (ssize_t) argc) 5570 ThrowMogrifyException(OptionError,"MissingArgument",option); 5571 if (IsGeometry(argv[i]) == MagickFalse) 5572 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5573 break; 5574 } 5575 if (LocaleCompare("sampling-factor",option+1) == 0) 5576 { 5577 if (*option == '+') 5578 break; 5579 i++; 5580 if (i == (ssize_t) argc) 5581 ThrowMogrifyException(OptionError,"MissingArgument",option); 5582 if (IsGeometry(argv[i]) == MagickFalse) 5583 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5584 break; 5585 } 5586 if (LocaleCompare("scale",option+1) == 0) 5587 { 5588 if (*option == '+') 5589 break; 5590 i++; 5591 if (i == (ssize_t) argc) 5592 ThrowMogrifyException(OptionError,"MissingArgument",option); 5593 if (IsGeometry(argv[i]) == MagickFalse) 5594 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5595 break; 5596 } 5597 if (LocaleCompare("scene",option+1) == 0) 5598 { 5599 if (*option == '+') 5600 break; 5601 i++; 5602 if (i == (ssize_t) argc) 5603 ThrowMogrifyException(OptionError,"MissingArgument",option); 5604 if (IsGeometry(argv[i]) == MagickFalse) 5605 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5606 break; 5607 } 5608 if (LocaleCompare("seed",option+1) == 0) 5609 { 5610 if (*option == '+') 5611 break; 5612 i++; 5613 if (i == (ssize_t) argc) 5614 ThrowMogrifyException(OptionError,"MissingArgument",option); 5615 if (IsGeometry(argv[i]) == MagickFalse) 5616 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5617 break; 5618 } 5619 if (LocaleCompare("segment",option+1) == 0) 5620 { 5621 if (*option == '+') 5622 break; 5623 i++; 5624 if (i == (ssize_t) argc) 5625 ThrowMogrifyException(OptionError,"MissingArgument",option); 5626 if (IsGeometry(argv[i]) == MagickFalse) 5627 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5628 break; 5629 } 5630 if (LocaleCompare("selective-blur",option+1) == 0) 5631 { 5632 i++; 5633 if (i == (ssize_t) argc) 5634 ThrowMogrifyException(OptionError,"MissingArgument",option); 5635 if (IsGeometry(argv[i]) == MagickFalse) 5636 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5637 break; 5638 } 5639 if (LocaleCompare("separate",option+1) == 0) 5640 break; 5641 if (LocaleCompare("sepia-tone",option+1) == 0) 5642 { 5643 if (*option == '+') 5644 break; 5645 i++; 5646 if (i == (ssize_t) argc) 5647 ThrowMogrifyException(OptionError,"MissingArgument",option); 5648 if (IsGeometry(argv[i]) == MagickFalse) 5649 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5650 break; 5651 } 5652 if (LocaleCompare("set",option+1) == 0) 5653 { 5654 i++; 5655 if (i == (ssize_t) argc) 5656 ThrowMogrifyException(OptionError,"MissingArgument",option); 5657 if (*option == '+') 5658 break; 5659 i++; 5660 if (i == (ssize_t) argc) 5661 ThrowMogrifyException(OptionError,"MissingArgument",option); 5662 break; 5663 } 5664 if (LocaleCompare("shade",option+1) == 0) 5665 { 5666 i++; 5667 if (i == (ssize_t) argc) 5668 ThrowMogrifyException(OptionError,"MissingArgument",option); 5669 if (IsGeometry(argv[i]) == MagickFalse) 5670 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5671 break; 5672 } 5673 if (LocaleCompare("shadow",option+1) == 0) 5674 { 5675 if (*option == '+') 5676 break; 5677 i++; 5678 if (i == (ssize_t) argc) 5679 ThrowMogrifyException(OptionError,"MissingArgument",option); 5680 if (IsGeometry(argv[i]) == MagickFalse) 5681 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5682 break; 5683 } 5684 if (LocaleCompare("sharpen",option+1) == 0) 5685 { 5686 i++; 5687 if (i == (ssize_t) argc) 5688 ThrowMogrifyException(OptionError,"MissingArgument",option); 5689 if (IsGeometry(argv[i]) == MagickFalse) 5690 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5691 break; 5692 } 5693 if (LocaleCompare("shave",option+1) == 0) 5694 { 5695 if (*option == '+') 5696 break; 5697 i++; 5698 if (i == (ssize_t) argc) 5699 ThrowMogrifyException(OptionError,"MissingArgument",option); 5700 if (IsGeometry(argv[i]) == MagickFalse) 5701 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5702 break; 5703 } 5704 if (LocaleCompare("shear",option+1) == 0) 5705 { 5706 i++; 5707 if (i == (ssize_t) argc) 5708 ThrowMogrifyException(OptionError,"MissingArgument",option); 5709 if (IsGeometry(argv[i]) == MagickFalse) 5710 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5711 break; 5712 } 5713 if (LocaleCompare("sigmoidal-contrast",option+1) == 0) 5714 { 5715 i++; 5716 if (i == (ssize_t) (argc-1)) 5717 ThrowMogrifyException(OptionError,"MissingArgument",option); 5718 if (IsGeometry(argv[i]) == MagickFalse) 5719 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5720 break; 5721 } 5722 if (LocaleCompare("size",option+1) == 0) 5723 { 5724 if (*option == '+') 5725 break; 5726 i++; 5727 if (i == (ssize_t) argc) 5728 ThrowMogrifyException(OptionError,"MissingArgument",option); 5729 if (IsGeometry(argv[i]) == MagickFalse) 5730 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5731 break; 5732 } 5733 if (LocaleCompare("sketch",option+1) == 0) 5734 { 5735 if (*option == '+') 5736 break; 5737 i++; 5738 if (i == (ssize_t) argc) 5739 ThrowMogrifyException(OptionError,"MissingArgument",option); 5740 if (IsGeometry(argv[i]) == MagickFalse) 5741 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5742 break; 5743 } 5744 if (LocaleCompare("smush",option+1) == 0) 5745 { 5746 i++; 5747 if (i == (ssize_t) argc) 5748 ThrowMogrifyException(OptionError,"MissingArgument",option); 5749 if (IsGeometry(argv[i]) == MagickFalse) 5750 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5751 i++; 5752 break; 5753 } 5754 if (LocaleCompare("solarize",option+1) == 0) 5755 { 5756 if (*option == '+') 5757 break; 5758 i++; 5759 if (i == (ssize_t) argc) 5760 ThrowMogrifyException(OptionError,"MissingArgument",option); 5761 if (IsGeometry(argv[i]) == MagickFalse) 5762 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5763 break; 5764 } 5765 if (LocaleCompare("sparse-color",option+1) == 0) 5766 { 5767 ssize_t 5768 op; 5769 5770 i++; 5771 if (i == (ssize_t) argc) 5772 ThrowMogrifyException(OptionError,"MissingArgument",option); 5773 op=ParseCommandOption(MagickSparseColorOptions,MagickFalse,argv[i]); 5774 if (op < 0) 5775 ThrowMogrifyException(OptionError,"UnrecognizedSparseColorMethod", 5776 argv[i]); 5777 i++; 5778 if (i == (ssize_t) (argc-1)) 5779 ThrowMogrifyException(OptionError,"MissingArgument",option); 5780 break; 5781 } 5782 if (LocaleCompare("splice",option+1) == 0) 5783 { 5784 if (*option == '+') 5785 break; 5786 i++; 5787 if (i == (ssize_t) argc) 5788 ThrowMogrifyException(OptionError,"MissingArgument",option); 5789 if (IsGeometry(argv[i]) == MagickFalse) 5790 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5791 break; 5792 } 5793 if (LocaleCompare("spread",option+1) == 0) 5794 { 5795 if (*option == '+') 5796 break; 5797 i++; 5798 if (i == (ssize_t) argc) 5799 ThrowMogrifyException(OptionError,"MissingArgument",option); 5800 if (IsGeometry(argv[i]) == MagickFalse) 5801 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5802 break; 5803 } 5804 if (LocaleCompare("statistic",option+1) == 0) 5805 { 5806 ssize_t 5807 op; 5808 5809 if (*option == '+') 5810 break; 5811 i++; 5812 if (i == (ssize_t) argc) 5813 ThrowMogrifyException(OptionError,"MissingArgument",option); 5814 op=ParseCommandOption(MagickStatisticOptions,MagickFalse,argv[i]); 5815 if (op < 0) 5816 ThrowMogrifyException(OptionError,"UnrecognizedStatisticType", 5817 argv[i]); 5818 i++; 5819 if (i == (ssize_t) (argc-1)) 5820 ThrowMogrifyException(OptionError,"MissingArgument",option); 5821 if (IsGeometry(argv[i]) == MagickFalse) 5822 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5823 break; 5824 } 5825 if (LocaleCompare("stretch",option+1) == 0) 5826 { 5827 ssize_t 5828 stretch; 5829 5830 if (*option == '+') 5831 break; 5832 i++; 5833 if (i == (ssize_t) (argc-1)) 5834 ThrowMogrifyException(OptionError,"MissingArgument",option); 5835 stretch=ParseCommandOption(MagickStretchOptions,MagickFalse,argv[i]); 5836 if (stretch < 0) 5837 ThrowMogrifyException(OptionError,"UnrecognizedStyleType", 5838 argv[i]); 5839 break; 5840 } 5841 if (LocaleCompare("strip",option+1) == 0) 5842 break; 5843 if (LocaleCompare("stroke",option+1) == 0) 5844 { 5845 if (*option == '+') 5846 break; 5847 i++; 5848 if (i == (ssize_t) argc) 5849 ThrowMogrifyException(OptionError,"MissingArgument",option); 5850 break; 5851 } 5852 if (LocaleCompare("strokewidth",option+1) == 0) 5853 { 5854 if (*option == '+') 5855 break; 5856 i++; 5857 if (i == (ssize_t) argc) 5858 ThrowMogrifyException(OptionError,"MissingArgument",option); 5859 if (IsGeometry(argv[i]) == MagickFalse) 5860 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5861 break; 5862 } 5863 if (LocaleCompare("style",option+1) == 0) 5864 { 5865 ssize_t 5866 style; 5867 5868 if (*option == '+') 5869 break; 5870 i++; 5871 if (i == (ssize_t) (argc-1)) 5872 ThrowMogrifyException(OptionError,"MissingArgument",option); 5873 style=ParseCommandOption(MagickStyleOptions,MagickFalse,argv[i]); 5874 if (style < 0) 5875 ThrowMogrifyException(OptionError,"UnrecognizedStyleType", 5876 argv[i]); 5877 break; 5878 } 5879 if (LocaleCompare("swap",option+1) == 0) 5880 { 5881 if (*option == '+') 5882 break; 5883 i++; 5884 if (i == (ssize_t) (argc-1)) 5885 ThrowMogrifyException(OptionError,"MissingArgument",option); 5886 if (IsGeometry(argv[i]) == MagickFalse) 5887 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5888 break; 5889 } 5890 if (LocaleCompare("swirl",option+1) == 0) 5891 { 5892 if (*option == '+') 5893 break; 5894 i++; 5895 if (i == (ssize_t) argc) 5896 ThrowMogrifyException(OptionError,"MissingArgument",option); 5897 if (IsGeometry(argv[i]) == MagickFalse) 5898 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5899 break; 5900 } 5901 if (LocaleCompare("synchronize",option+1) == 0) 5902 break; 5903 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 5904 } 5905 case 't': 5906 { 5907 if (LocaleCompare("taint",option+1) == 0) 5908 break; 5909 if (LocaleCompare("texture",option+1) == 0) 5910 { 5911 if (*option == '+') 5912 break; 5913 i++; 5914 if (i == (ssize_t) argc) 5915 ThrowMogrifyException(OptionError,"MissingArgument",option); 5916 break; 5917 } 5918 if (LocaleCompare("tile",option+1) == 0) 5919 { 5920 if (*option == '+') 5921 break; 5922 i++; 5923 if (i == (ssize_t) (argc-1)) 5924 ThrowMogrifyException(OptionError,"MissingArgument",option); 5925 break; 5926 } 5927 if (LocaleCompare("tile-offset",option+1) == 0) 5928 { 5929 if (*option == '+') 5930 break; 5931 i++; 5932 if (i == (ssize_t) argc) 5933 ThrowMogrifyException(OptionError,"MissingArgument",option); 5934 if (IsGeometry(argv[i]) == MagickFalse) 5935 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5936 break; 5937 } 5938 if (LocaleCompare("tint",option+1) == 0) 5939 { 5940 if (*option == '+') 5941 break; 5942 i++; 5943 if (i == (ssize_t) (argc-1)) 5944 ThrowMogrifyException(OptionError,"MissingArgument",option); 5945 if (IsGeometry(argv[i]) == MagickFalse) 5946 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5947 break; 5948 } 5949 if (LocaleCompare("transform",option+1) == 0) 5950 break; 5951 if (LocaleCompare("transpose",option+1) == 0) 5952 break; 5953 if (LocaleCompare("transverse",option+1) == 0) 5954 break; 5955 if (LocaleCompare("threshold",option+1) == 0) 5956 { 5957 if (*option == '+') 5958 break; 5959 i++; 5960 if (i == (ssize_t) argc) 5961 ThrowMogrifyException(OptionError,"MissingArgument",option); 5962 if (IsGeometry(argv[i]) == MagickFalse) 5963 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5964 break; 5965 } 5966 if (LocaleCompare("thumbnail",option+1) == 0) 5967 { 5968 if (*option == '+') 5969 break; 5970 i++; 5971 if (i == (ssize_t) argc) 5972 ThrowMogrifyException(OptionError,"MissingArgument",option); 5973 if (IsGeometry(argv[i]) == MagickFalse) 5974 ThrowMogrifyInvalidArgumentException(option,argv[i]); 5975 break; 5976 } 5977 if (LocaleCompare("transparent",option+1) == 0) 5978 { 5979 i++; 5980 if (i == (ssize_t) argc) 5981 ThrowMogrifyException(OptionError,"MissingArgument",option); 5982 break; 5983 } 5984 if (LocaleCompare("transparent-color",option+1) == 0) 5985 { 5986 if (*option == '+') 5987 break; 5988 i++; 5989 if (i == (ssize_t) (argc-1)) 5990 ThrowMogrifyException(OptionError,"MissingArgument",option); 5991 break; 5992 } 5993 if (LocaleCompare("treedepth",option+1) == 0) 5994 { 5995 if (*option == '+') 5996 break; 5997 i++; 5998 if (i == (ssize_t) argc) 5999 ThrowMogrifyException(OptionError,"MissingArgument",option); 6000 if (IsGeometry(argv[i]) == MagickFalse) 6001 ThrowMogrifyInvalidArgumentException(option,argv[i]); 6002 break; 6003 } 6004 if (LocaleCompare("trim",option+1) == 0) 6005 break; 6006 if (LocaleCompare("type",option+1) == 0) 6007 { 6008 ssize_t 6009 type; 6010 6011 if (*option == '+') 6012 break; 6013 i++; 6014 if (i == (ssize_t) argc) 6015 ThrowMogrifyException(OptionError,"MissingArgument",option); 6016 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); 6017 if (type < 0) 6018 ThrowMogrifyException(OptionError,"UnrecognizedImageType", 6019 argv[i]); 6020 break; 6021 } 6022 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 6023 } 6024 case 'u': 6025 { 6026 if (LocaleCompare("undercolor",option+1) == 0) 6027 { 6028 if (*option == '+') 6029 break; 6030 i++; 6031 if (i == (ssize_t) argc) 6032 ThrowMogrifyException(OptionError,"MissingArgument",option); 6033 break; 6034 } 6035 if (LocaleCompare("unique-colors",option+1) == 0) 6036 break; 6037 if (LocaleCompare("units",option+1) == 0) 6038 { 6039 ssize_t 6040 units; 6041 6042 if (*option == '+') 6043 break; 6044 i++; 6045 if (i == (ssize_t) argc) 6046 ThrowMogrifyException(OptionError,"MissingArgument",option); 6047 units=ParseCommandOption(MagickResolutionOptions,MagickFalse, 6048 argv[i]); 6049 if (units < 0) 6050 ThrowMogrifyException(OptionError,"UnrecognizedUnitsType", 6051 argv[i]); 6052 break; 6053 } 6054 if (LocaleCompare("unsharp",option+1) == 0) 6055 { 6056 i++; 6057 if (i == (ssize_t) argc) 6058 ThrowMogrifyException(OptionError,"MissingArgument",option); 6059 if (IsGeometry(argv[i]) == MagickFalse) 6060 ThrowMogrifyInvalidArgumentException(option,argv[i]); 6061 break; 6062 } 6063 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 6064 } 6065 case 'v': 6066 { 6067 if (LocaleCompare("verbose",option+1) == 0) 6068 { 6069 image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; 6070 break; 6071 } 6072 if ((LocaleCompare("version",option+1) == 0) || 6073 (LocaleCompare("-version",option+1) == 0)) 6074 { 6075 ListMagickVersion(stdout); 6076 break; 6077 } 6078 if (LocaleCompare("view",option+1) == 0) 6079 { 6080 if (*option == '+') 6081 break; 6082 i++; 6083 if (i == (ssize_t) argc) 6084 ThrowMogrifyException(OptionError,"MissingArgument",option); 6085 break; 6086 } 6087 if (LocaleCompare("vignette",option+1) == 0) 6088 { 6089 if (*option == '+') 6090 break; 6091 i++; 6092 if (i == (ssize_t) argc) 6093 ThrowMogrifyException(OptionError,"MissingArgument",option); 6094 if (IsGeometry(argv[i]) == MagickFalse) 6095 ThrowMogrifyInvalidArgumentException(option,argv[i]); 6096 break; 6097 } 6098 if (LocaleCompare("virtual-pixel",option+1) == 0) 6099 { 6100 ssize_t 6101 method; 6102 6103 if (*option == '+') 6104 break; 6105 i++; 6106 if (i == (ssize_t) argc) 6107 ThrowMogrifyException(OptionError,"MissingArgument",option); 6108 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, 6109 argv[i]); 6110 if (method < 0) 6111 ThrowMogrifyException(OptionError, 6112 "UnrecognizedVirtualPixelMethod",argv[i]); 6113 break; 6114 } 6115 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 6116 } 6117 case 'w': 6118 { 6119 if (LocaleCompare("wave",option+1) == 0) 6120 { 6121 i++; 6122 if (i == (ssize_t) argc) 6123 ThrowMogrifyException(OptionError,"MissingArgument",option); 6124 if (IsGeometry(argv[i]) == MagickFalse) 6125 ThrowMogrifyInvalidArgumentException(option,argv[i]); 6126 break; 6127 } 6128 if (LocaleCompare("weight",option+1) == 0) 6129 { 6130 if (*option == '+') 6131 break; 6132 i++; 6133 if (i == (ssize_t) (argc-1)) 6134 ThrowMogrifyException(OptionError,"MissingArgument",option); 6135 break; 6136 } 6137 if (LocaleCompare("white-point",option+1) == 0) 6138 { 6139 if (*option == '+') 6140 break; 6141 i++; 6142 if (i == (ssize_t) argc) 6143 ThrowMogrifyException(OptionError,"MissingArgument",option); 6144 if (IsGeometry(argv[i]) == MagickFalse) 6145 ThrowMogrifyInvalidArgumentException(option,argv[i]); 6146 break; 6147 } 6148 if (LocaleCompare("white-threshold",option+1) == 0) 6149 { 6150 if (*option == '+') 6151 break; 6152 i++; 6153 if (i == (ssize_t) argc) 6154 ThrowMogrifyException(OptionError,"MissingArgument",option); 6155 if (IsGeometry(argv[i]) == MagickFalse) 6156 ThrowMogrifyInvalidArgumentException(option,argv[i]); 6157 break; 6158 } 6159 if (LocaleCompare("write",option+1) == 0) 6160 { 6161 i++; 6162 if (i == (ssize_t) (argc-1)) 6163 ThrowMogrifyException(OptionError,"MissingArgument",option); 6164 break; 6165 } 6166 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 6167 } 6168 case '?': 6169 break; 6170 default: 6171 ThrowMogrifyException(OptionError,"UnrecognizedOption",option) 6172 } 6173 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & 6174 FireOptionFlag) == 0 ? MagickFalse : MagickTrue; 6175 if (fire != MagickFalse) 6176 FireImageStack(MagickFalse,MagickTrue,MagickTrue); 6177 } 6178 if (k != 0) 6179 ThrowMogrifyException(OptionError,"UnbalancedParenthesis",argv[i]); 6180 if (i != (ssize_t) argc) 6181 ThrowMogrifyException(OptionError,"MissingAnImageFilename",argv[i]); 6182 DestroyMogrify(); 6183 return(status != 0 ? MagickTrue : MagickFalse); 6184} 6185 6186/* 6187%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6188% % 6189% % 6190% % 6191+ M o g r i f y I m a g e I n f o % 6192% % 6193% % 6194% % 6195%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 6196% 6197% MogrifyImageInfo() applies image processing settings to the image as 6198% prescribed by command line options. 6199% 6200% The format of the MogrifyImageInfo method is: 6201% 6202% MagickBooleanType MogrifyImageInfo(ImageInfo *image_info,const int argc, 6203% const char **argv,ExceptionInfo *exception) 6204% 6205% A description of each parameter follows: 6206% 6207% o image_info: the image info.. 6208% 6209% o argc: Specifies a pointer to an integer describing the number of 6210% elements in the argument vector. 6211% 6212% o argv: Specifies a pointer to a text array containing the command line 6213% arguments. 6214% 6215% o exception: return any errors or warnings in this structure. 6216% 6217*/ 6218WandExport MagickBooleanType MogrifyImageInfo(ImageInfo *image_info, 6219 const int argc,const char **argv,ExceptionInfo *exception) 6220{ 6221 const char 6222 *option; 6223 6224 GeometryInfo 6225 geometry_info; 6226 6227 ssize_t 6228 count; 6229 6230 register ssize_t 6231 i; 6232 6233 /* 6234 Initialize method variables. 6235 */ 6236 assert(image_info != (ImageInfo *) NULL); 6237 assert(image_info->signature == MagickSignature); 6238 if (image_info->debug != MagickFalse) 6239 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", 6240 image_info->filename); 6241 if (argc < 0) 6242 return(MagickTrue); 6243 /* 6244 Set the image settings. 6245 */ 6246 for (i=0; i < (ssize_t) argc; i++) 6247 { 6248 option=argv[i]; 6249 if (IsCommandOption(option) == MagickFalse) 6250 continue; 6251 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); 6252 count=MagickMax(count,0L); 6253 if ((i+count) >= (ssize_t) argc) 6254 break; 6255 switch (*(option+1)) 6256 { 6257 case 'a': 6258 { 6259 if (LocaleCompare("adjoin",option+1) == 0) 6260 { 6261 image_info->adjoin=(*option == '-') ? MagickTrue : MagickFalse; 6262 break; 6263 } 6264 if (LocaleCompare("antialias",option+1) == 0) 6265 { 6266 image_info->antialias=(*option == '-') ? MagickTrue : MagickFalse; 6267 break; 6268 } 6269 if (LocaleCompare("authenticate",option+1) == 0) 6270 { 6271 if (*option == '+') 6272 (void) DeleteImageOption(image_info,option+1); 6273 else 6274 (void) SetImageOption(image_info,option+1,argv[i+1]); 6275 break; 6276 } 6277 break; 6278 } 6279 case 'b': 6280 { 6281 if (LocaleCompare("background",option+1) == 0) 6282 { 6283 if (*option == '+') 6284 { 6285 (void) DeleteImageOption(image_info,option+1); 6286 (void) QueryColorCompliance(MogrifyBackgroundColor, 6287 AllCompliance,&image_info->background_color,exception); 6288 break; 6289 } 6290 (void) SetImageOption(image_info,option+1,argv[i+1]); 6291 (void) QueryColorCompliance(argv[i+1],AllCompliance, 6292 &image_info->background_color,exception); 6293 break; 6294 } 6295 if (LocaleCompare("bias",option+1) == 0) 6296 { 6297 if (*option == '+') 6298 { 6299 (void) SetImageOption(image_info,option+1,"0.0"); 6300 break; 6301 } 6302 (void) SetImageOption(image_info,option+1,argv[i+1]); 6303 break; 6304 } 6305 if (LocaleCompare("black-point-compensation",option+1) == 0) 6306 { 6307 if (*option == '+') 6308 { 6309 (void) SetImageOption(image_info,option+1,"false"); 6310 break; 6311 } 6312 (void) SetImageOption(image_info,option+1,"true"); 6313 break; 6314 } 6315 if (LocaleCompare("blue-primary",option+1) == 0) 6316 { 6317 if (*option == '+') 6318 { 6319 (void) SetImageOption(image_info,option+1,"0.0"); 6320 break; 6321 } 6322 (void) SetImageOption(image_info,option+1,argv[i+1]); 6323 break; 6324 } 6325 if (LocaleCompare("bordercolor",option+1) == 0) 6326 { 6327 if (*option == '+') 6328 { 6329 (void) DeleteImageOption(image_info,option+1); 6330 (void) QueryColorCompliance(MogrifyBorderColor,AllCompliance, 6331 &image_info->border_color,exception); 6332 break; 6333 } 6334 (void) QueryColorCompliance(argv[i+1],AllCompliance, 6335 &image_info->border_color,exception); 6336 (void) SetImageOption(image_info,option+1,argv[i+1]); 6337 break; 6338 } 6339 if (LocaleCompare("box",option+1) == 0) 6340 { 6341 if (*option == '+') 6342 { 6343 (void) SetImageOption(image_info,"undercolor","none"); 6344 break; 6345 } 6346 (void) SetImageOption(image_info,"undercolor",argv[i+1]); 6347 break; 6348 } 6349 break; 6350 } 6351 case 'c': 6352 { 6353 if (LocaleCompare("cache",option+1) == 0) 6354 { 6355 MagickSizeType 6356 limit; 6357 6358 limit=MagickResourceInfinity; 6359 if (LocaleCompare("unlimited",argv[i+1]) != 0) 6360 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+1], 6361 100.0); 6362 (void) SetMagickResourceLimit(MemoryResource,limit); 6363 (void) SetMagickResourceLimit(MapResource,2*limit); 6364 break; 6365 } 6366 if (LocaleCompare("caption",option+1) == 0) 6367 { 6368 if (*option == '+') 6369 { 6370 (void) DeleteImageOption(image_info,option+1); 6371 break; 6372 } 6373 (void) SetImageOption(image_info,option+1,argv[i+1]); 6374 break; 6375 } 6376 if (LocaleCompare("channel",option+1) == 0) 6377 { 6378 if (*option == '+') 6379 { 6380 image_info->channel=DefaultChannels; 6381 (void) SetImageOption(image_info,option+1,"default"); 6382 break; 6383 } 6384 image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]); 6385 (void) SetImageOption(image_info,option+1,argv[i+1]); 6386 break; 6387 } 6388 if (LocaleCompare("colorspace",option+1) == 0) 6389 { 6390 if (*option == '+') 6391 { 6392 image_info->colorspace=UndefinedColorspace; 6393 (void) SetImageOption(image_info,option+1,"undefined"); 6394 break; 6395 } 6396 image_info->colorspace=(ColorspaceType) ParseCommandOption( 6397 MagickColorspaceOptions,MagickFalse,argv[i+1]); 6398 (void) SetImageOption(image_info,option+1,argv[i+1]); 6399 break; 6400 } 6401 if (LocaleCompare("comment",option+1) == 0) 6402 { 6403 if (*option == '+') 6404 { 6405 (void) DeleteImageOption(image_info,option+1); 6406 break; 6407 } 6408 (void) SetImageOption(image_info,option+1,argv[i+1]); 6409 break; 6410 } 6411 if (LocaleCompare("compose",option+1) == 0) 6412 { 6413 if (*option == '+') 6414 { 6415 (void) SetImageOption(image_info,option+1,"undefined"); 6416 break; 6417 } 6418 (void) SetImageOption(image_info,option+1,argv[i+1]); 6419 break; 6420 } 6421 if (LocaleCompare("compress",option+1) == 0) 6422 { 6423 if (*option == '+') 6424 { 6425 image_info->compression=UndefinedCompression; 6426 (void) SetImageOption(image_info,option+1,"undefined"); 6427 break; 6428 } 6429 image_info->compression=(CompressionType) ParseCommandOption( 6430 MagickCompressOptions,MagickFalse,argv[i+1]); 6431 (void) SetImageOption(image_info,option+1,argv[i+1]); 6432 break; 6433 } 6434 break; 6435 } 6436 case 'd': 6437 { 6438 if (LocaleCompare("debug",option+1) == 0) 6439 { 6440 if (*option == '+') 6441 (void) SetLogEventMask("none"); 6442 else 6443 (void) SetLogEventMask(argv[i+1]); 6444 image_info->debug=IsEventLogging(); 6445 break; 6446 } 6447 if (LocaleCompare("define",option+1) == 0) 6448 { 6449 if (*option == '+') 6450 { 6451 if (LocaleNCompare(argv[i+1],"registry:",9) == 0) 6452 (void) DeleteImageRegistry(argv[i+1]+9); 6453 else 6454 (void) DeleteImageOption(image_info,argv[i+1]); 6455 break; 6456 } 6457 if (LocaleNCompare(argv[i+1],"registry:",9) == 0) 6458 { 6459 (void) DefineImageRegistry(StringRegistryType,argv[i+1]+9, 6460 exception); 6461 break; 6462 } 6463 (void) DefineImageOption(image_info,argv[i+1]); 6464 break; 6465 } 6466 if (LocaleCompare("delay",option+1) == 0) 6467 { 6468 if (*option == '+') 6469 { 6470 (void) SetImageOption(image_info,option+1,"0"); 6471 break; 6472 } 6473 (void) SetImageOption(image_info,option+1,argv[i+1]); 6474 break; 6475 } 6476 if (LocaleCompare("density",option+1) == 0) 6477 { 6478 /* 6479 Set image density. 6480 */ 6481 if (*option == '+') 6482 { 6483 if (image_info->density != (char *) NULL) 6484 image_info->density=DestroyString(image_info->density); 6485 (void) SetImageOption(image_info,option+1,"72"); 6486 break; 6487 } 6488 (void) CloneString(&image_info->density,argv[i+1]); 6489 (void) SetImageOption(image_info,option+1,argv[i+1]); 6490 break; 6491 } 6492 if (LocaleCompare("depth",option+1) == 0) 6493 { 6494 if (*option == '+') 6495 { 6496 image_info->depth=MAGICKCORE_QUANTUM_DEPTH; 6497 break; 6498 } 6499 image_info->depth=StringToUnsignedLong(argv[i+1]); 6500 break; 6501 } 6502 if (LocaleCompare("direction",option+1) == 0) 6503 { 6504 if (*option == '+') 6505 { 6506 (void) SetImageOption(image_info,option+1,"undefined"); 6507 break; 6508 } 6509 (void) SetImageOption(image_info,option+1,argv[i+1]); 6510 break; 6511 } 6512 if (LocaleCompare("display",option+1) == 0) 6513 { 6514 if (*option == '+') 6515 { 6516 if (image_info->server_name != (char *) NULL) 6517 image_info->server_name=DestroyString( 6518 image_info->server_name); 6519 break; 6520 } 6521 (void) CloneString(&image_info->server_name,argv[i+1]); 6522 break; 6523 } 6524 if (LocaleCompare("dispose",option+1) == 0) 6525 { 6526 if (*option == '+') 6527 { 6528 (void) SetImageOption(image_info,option+1,"undefined"); 6529 break; 6530 } 6531 (void) SetImageOption(image_info,option+1,argv[i+1]); 6532 break; 6533 } 6534 if (LocaleCompare("dither",option+1) == 0) 6535 { 6536 if (*option == '+') 6537 { 6538 image_info->dither=MagickFalse; 6539 (void) SetImageOption(image_info,option+1,"none"); 6540 break; 6541 } 6542 (void) SetImageOption(image_info,option+1,argv[i+1]); 6543 image_info->dither=MagickTrue; 6544 break; 6545 } 6546 break; 6547 } 6548 case 'e': 6549 { 6550 if (LocaleCompare("encoding",option+1) == 0) 6551 { 6552 if (*option == '+') 6553 { 6554 (void) SetImageOption(image_info,option+1,"undefined"); 6555 break; 6556 } 6557 (void) SetImageOption(image_info,option+1,argv[i+1]); 6558 break; 6559 } 6560 if (LocaleCompare("endian",option+1) == 0) 6561 { 6562 if (*option == '+') 6563 { 6564 image_info->endian=UndefinedEndian; 6565 (void) SetImageOption(image_info,option+1,"undefined"); 6566 break; 6567 } 6568 image_info->endian=(EndianType) ParseCommandOption( 6569 MagickEndianOptions,MagickFalse,argv[i+1]); 6570 (void) SetImageOption(image_info,option+1,argv[i+1]); 6571 break; 6572 } 6573 if (LocaleCompare("extract",option+1) == 0) 6574 { 6575 /* 6576 Set image extract geometry. 6577 */ 6578 if (*option == '+') 6579 { 6580 if (image_info->extract != (char *) NULL) 6581 image_info->extract=DestroyString(image_info->extract); 6582 break; 6583 } 6584 (void) CloneString(&image_info->extract,argv[i+1]); 6585 break; 6586 } 6587 break; 6588 } 6589 case 'f': 6590 { 6591 if (LocaleCompare("fill",option+1) == 0) 6592 { 6593 if (*option == '+') 6594 { 6595 (void) SetImageOption(image_info,option+1,"none"); 6596 break; 6597 } 6598 (void) SetImageOption(image_info,option+1,argv[i+1]); 6599 break; 6600 } 6601 if (LocaleCompare("filter",option+1) == 0) 6602 { 6603 if (*option == '+') 6604 { 6605 (void) SetImageOption(image_info,option+1,"undefined"); 6606 break; 6607 } 6608 (void) SetImageOption(image_info,option+1,argv[i+1]); 6609 break; 6610 } 6611 if (LocaleCompare("font",option+1) == 0) 6612 { 6613 if (*option == '+') 6614 { 6615 if (image_info->font != (char *) NULL) 6616 image_info->font=DestroyString(image_info->font); 6617 break; 6618 } 6619 (void) CloneString(&image_info->font,argv[i+1]); 6620 break; 6621 } 6622 if (LocaleCompare("format",option+1) == 0) 6623 { 6624 register const char 6625 *q; 6626 6627 for (q=strchr(argv[i+1],'%'); q != (char *) NULL; q=strchr(q+1,'%')) 6628 if (strchr("Agkrz@[#",*(q+1)) != (char *) NULL) 6629 image_info->ping=MagickFalse; 6630 (void) SetImageOption(image_info,option+1,argv[i+1]); 6631 break; 6632 } 6633 if (LocaleCompare("fuzz",option+1) == 0) 6634 { 6635 if (*option == '+') 6636 { 6637 image_info->fuzz=0.0; 6638 (void) SetImageOption(image_info,option+1,"0"); 6639 break; 6640 } 6641 image_info->fuzz=StringToDoubleInterval(argv[i+1],(double) 6642 QuantumRange+1.0); 6643 (void) SetImageOption(image_info,option+1,argv[i+1]); 6644 break; 6645 } 6646 break; 6647 } 6648 case 'g': 6649 { 6650 if (LocaleCompare("gravity",option+1) == 0) 6651 { 6652 if (*option == '+') 6653 { 6654 (void) SetImageOption(image_info,option+1,"undefined"); 6655 break; 6656 } 6657 (void) SetImageOption(image_info,option+1,argv[i+1]); 6658 break; 6659 } 6660 if (LocaleCompare("green-primary",option+1) == 0) 6661 { 6662 if (*option == '+') 6663 { 6664 (void) SetImageOption(image_info,option+1,"0.0"); 6665 break; 6666 } 6667 (void) SetImageOption(image_info,option+1,argv[i+1]); 6668 break; 6669 } 6670 break; 6671 } 6672 case 'i': 6673 { 6674 if (LocaleCompare("intensity",option+1) == 0) 6675 { 6676 if (*option == '+') 6677 { 6678 (void) SetImageOption(image_info,option+1,"undefined"); 6679 break; 6680 } 6681 (void) SetImageOption(image_info,option+1,argv[i+1]); 6682 break; 6683 } 6684 if (LocaleCompare("intent",option+1) == 0) 6685 { 6686 if (*option == '+') 6687 { 6688 (void) SetImageOption(image_info,option+1,"undefined"); 6689 break; 6690 } 6691 (void) SetImageOption(image_info,option+1,argv[i+1]); 6692 break; 6693 } 6694 if (LocaleCompare("interlace",option+1) == 0) 6695 { 6696 if (*option == '+') 6697 { 6698 image_info->interlace=UndefinedInterlace; 6699 (void) SetImageOption(image_info,option+1,"undefined"); 6700 break; 6701 } 6702 image_info->interlace=(InterlaceType) ParseCommandOption( 6703 MagickInterlaceOptions,MagickFalse,argv[i+1]); 6704 (void) SetImageOption(image_info,option+1,argv[i+1]); 6705 break; 6706 } 6707 if (LocaleCompare("interline-spacing",option+1) == 0) 6708 { 6709 if (*option == '+') 6710 { 6711 (void) SetImageOption(image_info,option+1,"undefined"); 6712 break; 6713 } 6714 (void) SetImageOption(image_info,option+1,argv[i+1]); 6715 break; 6716 } 6717 if (LocaleCompare("interpolate",option+1) == 0) 6718 { 6719 if (*option == '+') 6720 { 6721 (void) SetImageOption(image_info,option+1,"undefined"); 6722 break; 6723 } 6724 (void) SetImageOption(image_info,option+1,argv[i+1]); 6725 break; 6726 } 6727 if (LocaleCompare("interword-spacing",option+1) == 0) 6728 { 6729 if (*option == '+') 6730 { 6731 (void) SetImageOption(image_info,option+1,"undefined"); 6732 break; 6733 } 6734 (void) SetImageOption(image_info,option+1,argv[i+1]); 6735 break; 6736 } 6737 break; 6738 } 6739 case 'k': 6740 { 6741 if (LocaleCompare("kerning",option+1) == 0) 6742 { 6743 if (*option == '+') 6744 { 6745 (void) SetImageOption(image_info,option+1,"undefined"); 6746 break; 6747 } 6748 (void) SetImageOption(image_info,option+1,argv[i+1]); 6749 break; 6750 } 6751 break; 6752 } 6753 case 'l': 6754 { 6755 if (LocaleCompare("label",option+1) == 0) 6756 { 6757 if (*option == '+') 6758 { 6759 (void) DeleteImageOption(image_info,option+1); 6760 break; 6761 } 6762 (void) SetImageOption(image_info,option+1,argv[i+1]); 6763 break; 6764 } 6765 if (LocaleCompare("limit",option+1) == 0) 6766 { 6767 MagickSizeType 6768 limit; 6769 6770 ResourceType 6771 type; 6772 6773 if (*option == '+') 6774 break; 6775 type=(ResourceType) ParseCommandOption(MagickResourceOptions, 6776 MagickFalse,argv[i+1]); 6777 limit=MagickResourceInfinity; 6778 if (LocaleCompare("unlimited",argv[i+2]) != 0) 6779 limit=(MagickSizeType) SiPrefixToDoubleInterval(argv[i+2],100.0); 6780 (void) SetMagickResourceLimit(type,limit); 6781 break; 6782 } 6783 if (LocaleCompare("list",option+1) == 0) 6784 { 6785 ssize_t 6786 list; 6787 6788 /* 6789 Display configuration list. 6790 */ 6791 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i+1]); 6792 switch (list) 6793 { 6794 case MagickCoderOptions: 6795 { 6796 (void) ListCoderInfo((FILE *) NULL,exception); 6797 break; 6798 } 6799 case MagickColorOptions: 6800 { 6801 (void) ListColorInfo((FILE *) NULL,exception); 6802 break; 6803 } 6804 case MagickConfigureOptions: 6805 { 6806 (void) ListConfigureInfo((FILE *) NULL,exception); 6807 break; 6808 } 6809 case MagickDelegateOptions: 6810 { 6811 (void) ListDelegateInfo((FILE *) NULL,exception); 6812 break; 6813 } 6814 case MagickFontOptions: 6815 { 6816 (void) ListTypeInfo((FILE *) NULL,exception); 6817 break; 6818 } 6819 case MagickFormatOptions: 6820 { 6821 (void) ListMagickInfo((FILE *) NULL,exception); 6822 break; 6823 } 6824 case MagickLocaleOptions: 6825 { 6826 (void) ListLocaleInfo((FILE *) NULL,exception); 6827 break; 6828 } 6829 case MagickLogOptions: 6830 { 6831 (void) ListLogInfo((FILE *) NULL,exception); 6832 break; 6833 } 6834 case MagickMagicOptions: 6835 { 6836 (void) ListMagicInfo((FILE *) NULL,exception); 6837 break; 6838 } 6839 case MagickMimeOptions: 6840 { 6841 (void) ListMimeInfo((FILE *) NULL,exception); 6842 break; 6843 } 6844 case MagickModuleOptions: 6845 { 6846 (void) ListModuleInfo((FILE *) NULL,exception); 6847 break; 6848 } 6849 case MagickPolicyOptions: 6850 { 6851 (void) ListPolicyInfo((FILE *) NULL,exception); 6852 break; 6853 } 6854 case MagickResourceOptions: 6855 { 6856 (void) ListMagickResourceInfo((FILE *) NULL,exception); 6857 break; 6858 } 6859 case MagickThresholdOptions: 6860 { 6861 (void) ListThresholdMaps((FILE *) NULL,exception); 6862 break; 6863 } 6864 default: 6865 { 6866 (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, 6867 exception); 6868 break; 6869 } 6870 } 6871 break; 6872 } 6873 if (LocaleCompare("log",option+1) == 0) 6874 { 6875 if (*option == '+') 6876 break; 6877 (void) SetLogFormat(argv[i+1]); 6878 break; 6879 } 6880 if (LocaleCompare("loop",option+1) == 0) 6881 { 6882 if (*option == '+') 6883 { 6884 (void) SetImageOption(image_info,option+1,"0"); 6885 break; 6886 } 6887 (void) SetImageOption(image_info,option+1,argv[i+1]); 6888 break; 6889 } 6890 break; 6891 } 6892 case 'm': 6893 { 6894 if (LocaleCompare("matte",option+1) == 0) 6895 { 6896 if (*option == '+') 6897 { 6898 (void) SetImageOption(image_info,option+1,"false"); 6899 break; 6900 } 6901 (void) SetImageOption(image_info,option+1,"true"); 6902 break; 6903 } 6904 if (LocaleCompare("mattecolor",option+1) == 0) 6905 { 6906 if (*option == '+') 6907 { 6908 (void) SetImageOption(image_info,option+1,argv[i+1]); 6909 (void) QueryColorCompliance(MogrifyMatteColor,AllCompliance, 6910 &image_info->matte_color,exception); 6911 break; 6912 } 6913 (void) SetImageOption(image_info,option+1,argv[i+1]); 6914 (void) QueryColorCompliance(argv[i+1],AllCompliance, 6915 &image_info->matte_color,exception); 6916 break; 6917 } 6918 if (LocaleCompare("metric",option+1) == 0) 6919 { 6920 if (*option == '+') 6921 (void) DeleteImageOption(image_info,option+1); 6922 else 6923 (void) SetImageOption(image_info,option+1,argv[i+1]); 6924 break; 6925 } 6926 if (LocaleCompare("monitor",option+1) == 0) 6927 { 6928 (void) SetImageInfoProgressMonitor(image_info,MonitorProgress, 6929 (void *) NULL); 6930 break; 6931 } 6932 if (LocaleCompare("monochrome",option+1) == 0) 6933 { 6934 image_info->monochrome=(*option == '-') ? MagickTrue : MagickFalse; 6935 break; 6936 } 6937 break; 6938 } 6939 case 'o': 6940 { 6941 if (LocaleCompare("orient",option+1) == 0) 6942 { 6943 if (*option == '+') 6944 { 6945 image_info->orientation=UndefinedOrientation; 6946 (void) SetImageOption(image_info,option+1,"undefined"); 6947 break; 6948 } 6949 image_info->orientation=(OrientationType) ParseCommandOption( 6950 MagickOrientationOptions,MagickFalse,argv[i+1]); 6951 (void) SetImageOption(image_info,option+1,argv[i+1]); 6952 break; 6953 } 6954 } 6955 case 'p': 6956 { 6957 if (LocaleCompare("page",option+1) == 0) 6958 { 6959 char 6960 *canonical_page, 6961 page[MaxTextExtent]; 6962 6963 const char 6964 *image_option; 6965 6966 MagickStatusType 6967 flags; 6968 6969 RectangleInfo 6970 geometry; 6971 6972 if (*option == '+') 6973 { 6974 (void) DeleteImageOption(image_info,option+1); 6975 (void) CloneString(&image_info->page,(char *) NULL); 6976 break; 6977 } 6978 (void) ResetMagickMemory(&geometry,0,sizeof(geometry)); 6979 image_option=GetImageOption(image_info,"page"); 6980 if (image_option != (const char *) NULL) 6981 flags=ParseAbsoluteGeometry(image_option,&geometry); 6982 canonical_page=GetPageGeometry(argv[i+1]); 6983 flags=ParseAbsoluteGeometry(canonical_page,&geometry); 6984 canonical_page=DestroyString(canonical_page); 6985 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu", 6986 (unsigned long) geometry.width,(unsigned long) geometry.height); 6987 if (((flags & XValue) != 0) || ((flags & YValue) != 0)) 6988 (void) FormatLocaleString(page,MaxTextExtent,"%lux%lu%+ld%+ld", 6989 (unsigned long) geometry.width,(unsigned long) geometry.height, 6990 (long) geometry.x,(long) geometry.y); 6991 (void) SetImageOption(image_info,option+1,page); 6992 (void) CloneString(&image_info->page,page); 6993 break; 6994 } 6995 if (LocaleCompare("ping",option+1) == 0) 6996 { 6997 image_info->ping=(*option == '-') ? MagickTrue : MagickFalse; 6998 break; 6999 } 7000 if (LocaleCompare("pointsize",option+1) == 0) 7001 { 7002 if (*option == '+') 7003 geometry_info.rho=0.0; 7004 else 7005 (void) ParseGeometry(argv[i+1],&geometry_info); 7006 image_info->pointsize=geometry_info.rho; 7007 break; 7008 } 7009 if (LocaleCompare("precision",option+1) == 0) 7010 { 7011 (void) SetMagickPrecision(StringToInteger(argv[i+1])); 7012 break; 7013 } 7014 if (LocaleCompare("preview",option+1) == 0) 7015 { 7016 /* 7017 Preview image. 7018 */ 7019 if (*option == '+') 7020 { 7021 image_info->preview_type=UndefinedPreview; 7022 break; 7023 } 7024 image_info->preview_type=(PreviewType) ParseCommandOption( 7025 MagickPreviewOptions,MagickFalse,argv[i+1]); 7026 break; 7027 } 7028 break; 7029 } 7030 case 'q': 7031 { 7032 if (LocaleCompare("quality",option+1) == 0) 7033 { 7034 /* 7035 Set image compression quality. 7036 */ 7037 if (*option == '+') 7038 { 7039 image_info->quality=UndefinedCompressionQuality; 7040 (void) SetImageOption(image_info,option+1,"0"); 7041 break; 7042 } 7043 image_info->quality=StringToUnsignedLong(argv[i+1]); 7044 (void) SetImageOption(image_info,option+1,argv[i+1]); 7045 break; 7046 } 7047 if (LocaleCompare("quiet",option+1) == 0) 7048 { 7049 static WarningHandler 7050 warning_handler = (WarningHandler) NULL; 7051 7052 if (*option == '+') 7053 { 7054 /* 7055 Restore error or warning messages. 7056 */ 7057 warning_handler=SetWarningHandler(warning_handler); 7058 break; 7059 } 7060 /* 7061 Suppress error or warning messages. 7062 */ 7063 warning_handler=SetWarningHandler((WarningHandler) NULL); 7064 break; 7065 } 7066 break; 7067 } 7068 case 'r': 7069 { 7070 if (LocaleCompare("red-primary",option+1) == 0) 7071 { 7072 if (*option == '+') 7073 { 7074 (void) SetImageOption(image_info,option+1,"0.0"); 7075 break; 7076 } 7077 (void) SetImageOption(image_info,option+1,argv[i+1]); 7078 break; 7079 } 7080 break; 7081 } 7082 case 's': 7083 { 7084 if (LocaleCompare("sampling-factor",option+1) == 0) 7085 { 7086 /* 7087 Set image sampling factor. 7088 */ 7089 if (*option == '+') 7090 { 7091 if (image_info->sampling_factor != (char *) NULL) 7092 image_info->sampling_factor=DestroyString( 7093 image_info->sampling_factor); 7094 break; 7095 } 7096 (void) CloneString(&image_info->sampling_factor,argv[i+1]); 7097 break; 7098 } 7099 if (LocaleCompare("scene",option+1) == 0) 7100 { 7101 /* 7102 Set image scene. 7103 */ 7104 if (*option == '+') 7105 { 7106 image_info->scene=0; 7107 (void) SetImageOption(image_info,option+1,"0"); 7108 break; 7109 } 7110 image_info->scene=StringToUnsignedLong(argv[i+1]); 7111 (void) SetImageOption(image_info,option+1,argv[i+1]); 7112 break; 7113 } 7114 if (LocaleCompare("seed",option+1) == 0) 7115 { 7116 size_t 7117 seed; 7118 7119 if (*option == '+') 7120 { 7121 seed=(size_t) time((time_t *) NULL); 7122 SetRandomSecretKey(seed); 7123 break; 7124 } 7125 seed=StringToUnsignedLong(argv[i+1]); 7126 SetRandomSecretKey(seed); 7127 break; 7128 } 7129 if (LocaleCompare("size",option+1) == 0) 7130 { 7131 if (*option == '+') 7132 { 7133 if (image_info->size != (char *) NULL) 7134 image_info->size=DestroyString(image_info->size); 7135 break; 7136 } 7137 (void) CloneString(&image_info->size,argv[i+1]); 7138 break; 7139 } 7140 if (LocaleCompare("stroke",option+1) == 0) 7141 { 7142 if (*option == '+') 7143 { 7144 (void) SetImageOption(image_info,option+1,"none"); 7145 break; 7146 } 7147 (void) SetImageOption(image_info,option+1,argv[i+1]); 7148 break; 7149 } 7150 if (LocaleCompare("strokewidth",option+1) == 0) 7151 { 7152 if (*option == '+') 7153 { 7154 (void) SetImageOption(image_info,option+1,"0"); 7155 break; 7156 } 7157 (void) SetImageOption(image_info,option+1,argv[i+1]); 7158 break; 7159 } 7160 if (LocaleCompare("synchronize",option+1) == 0) 7161 { 7162 if (*option == '+') 7163 { 7164 image_info->synchronize=MagickFalse; 7165 break; 7166 } 7167 image_info->synchronize=MagickTrue; 7168 break; 7169 } 7170 break; 7171 } 7172 case 't': 7173 { 7174 if (LocaleCompare("taint",option+1) == 0) 7175 { 7176 if (*option == '+') 7177 { 7178 (void) SetImageOption(image_info,option+1,"false"); 7179 break; 7180 } 7181 (void) SetImageOption(image_info,option+1,"true"); 7182 break; 7183 } 7184 if (LocaleCompare("texture",option+1) == 0) 7185 { 7186 if (*option == '+') 7187 { 7188 if (image_info->texture != (char *) NULL) 7189 image_info->texture=DestroyString(image_info->texture); 7190 break; 7191 } 7192 (void) CloneString(&image_info->texture,argv[i+1]); 7193 break; 7194 } 7195 if (LocaleCompare("tile-offset",option+1) == 0) 7196 { 7197 if (*option == '+') 7198 (void) SetImageOption(image_info,option+1,"0"); 7199 else 7200 (void) SetImageOption(image_info,option+1,argv[i+1]); 7201 break; 7202 } 7203 if (LocaleCompare("transparent-color",option+1) == 0) 7204 { 7205 if (*option == '+') 7206 { 7207 (void) QueryColorCompliance("none",AllCompliance, 7208 &image_info->transparent_color,exception); 7209 (void) SetImageOption(image_info,option+1,"none"); 7210 break; 7211 } 7212 (void) QueryColorCompliance(argv[i+1],AllCompliance, 7213 &image_info->transparent_color,exception); 7214 (void) SetImageOption(image_info,option+1,argv[i+1]); 7215 break; 7216 } 7217 if (LocaleCompare("type",option+1) == 0) 7218 { 7219 if (*option == '+') 7220 { 7221 image_info->type=UndefinedType; 7222 (void) SetImageOption(image_info,option+1,"undefined"); 7223 break; 7224 } 7225 image_info->type=(ImageType) ParseCommandOption(MagickTypeOptions, 7226 MagickFalse,argv[i+1]); 7227 (void) SetImageOption(image_info,option+1,argv[i+1]); 7228 break; 7229 } 7230 break; 7231 } 7232 case 'u': 7233 { 7234 if (LocaleCompare("undercolor",option+1) == 0) 7235 { 7236 if (*option == '+') 7237 (void) DeleteImageOption(image_info,option+1); 7238 else 7239 (void) SetImageOption(image_info,option+1,argv[i+1]); 7240 break; 7241 } 7242 if (LocaleCompare("units",option+1) == 0) 7243 { 7244 if (*option == '+') 7245 { 7246 image_info->units=UndefinedResolution; 7247 (void) SetImageOption(image_info,option+1,"undefined"); 7248 break; 7249 } 7250 image_info->units=(ResolutionType) ParseCommandOption( 7251 MagickResolutionOptions,MagickFalse,argv[i+1]); 7252 (void) SetImageOption(image_info,option+1,argv[i+1]); 7253 break; 7254 } 7255 break; 7256 } 7257 case 'v': 7258 { 7259 if (LocaleCompare("verbose",option+1) == 0) 7260 { 7261 if (*option == '+') 7262 { 7263 image_info->verbose=MagickFalse; 7264 break; 7265 } 7266 image_info->verbose=MagickTrue; 7267 image_info->ping=MagickFalse; 7268 break; 7269 } 7270 if (LocaleCompare("view",option+1) == 0) 7271 { 7272 if (*option == '+') 7273 { 7274 if (image_info->view != (char *) NULL) 7275 image_info->view=DestroyString(image_info->view); 7276 break; 7277 } 7278 (void) CloneString(&image_info->view,argv[i+1]); 7279 break; 7280 } 7281 if (LocaleCompare("virtual-pixel",option+1) == 0) 7282 { 7283 if (*option == '+') 7284 (void) SetImageOption(image_info,option+1,"undefined"); 7285 else 7286 (void) SetImageOption(image_info,option+1,argv[i+1]); 7287 break; 7288 } 7289 break; 7290 } 7291 case 'w': 7292 { 7293 if (LocaleCompare("white-point",option+1) == 0) 7294 { 7295 if (*option == '+') 7296 (void) SetImageOption(image_info,option+1,"0.0"); 7297 else 7298 (void) SetImageOption(image_info,option+1,argv[i+1]); 7299 break; 7300 } 7301 break; 7302 } 7303 default: 7304 break; 7305 } 7306 i+=count; 7307 } 7308 return(MagickTrue); 7309} 7310 7311/* 7312%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7313% % 7314% % 7315% % 7316+ M o g r i f y I m a g e L i s t % 7317% % 7318% % 7319% % 7320%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 7321% 7322% MogrifyImageList() applies any command line options that might affect the 7323% entire image list (e.g. -append, -coalesce, etc.). 7324% 7325% The format of the MogrifyImage method is: 7326% 7327% MagickBooleanType MogrifyImageList(ImageInfo *image_info,const int argc, 7328% const char **argv,Image **images,ExceptionInfo *exception) 7329% 7330% A description of each parameter follows: 7331% 7332% o image_info: the image info.. 7333% 7334% o argc: Specifies a pointer to an integer describing the number of 7335% elements in the argument vector. 7336% 7337% o argv: Specifies a pointer to a text array containing the command line 7338% arguments. 7339% 7340% o images: pointer to pointer of the first image in image list. 7341% 7342% o exception: return any errors or warnings in this structure. 7343% 7344*/ 7345WandExport MagickBooleanType MogrifyImageList(ImageInfo *image_info, 7346 const int argc,const char **argv,Image **images,ExceptionInfo *exception) 7347{ 7348 const char 7349 *option; 7350 7351 ImageInfo 7352 *mogrify_info; 7353 7354 MagickStatusType 7355 status; 7356 7357 PixelInterpolateMethod 7358 interpolate_method; 7359 7360 QuantizeInfo 7361 *quantize_info; 7362 7363 register ssize_t 7364 i; 7365 7366 ssize_t 7367 count, 7368 index; 7369 7370 /* 7371 Apply options to the image list. 7372 */ 7373 assert(image_info != (ImageInfo *) NULL); 7374 assert(image_info->signature == MagickSignature); 7375 assert(images != (Image **) NULL); 7376 assert((*images)->previous == (Image *) NULL); 7377 assert((*images)->signature == MagickSignature); 7378 if ((*images)->debug != MagickFalse) 7379 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", 7380 (*images)->filename); 7381 if ((argc <= 0) || (*argv == (char *) NULL)) 7382 return(MagickTrue); 7383 interpolate_method=UndefinedInterpolatePixel; 7384 mogrify_info=CloneImageInfo(image_info); 7385 quantize_info=AcquireQuantizeInfo(mogrify_info); 7386 status=MagickTrue; 7387 for (i=0; i < (ssize_t) argc; i++) 7388 { 7389 if (*images == (Image *) NULL) 7390 break; 7391 option=argv[i]; 7392 if (IsCommandOption(option) == MagickFalse) 7393 continue; 7394 count=ParseCommandOption(MagickCommandOptions,MagickFalse,option); 7395 count=MagickMax(count,0L); 7396 if ((i+count) >= (ssize_t) argc) 7397 break; 7398 status=MogrifyImageInfo(mogrify_info,(int) count+1,argv+i,exception); 7399 switch (*(option+1)) 7400 { 7401 case 'a': 7402 { 7403 if (LocaleCompare("affinity",option+1) == 0) 7404 { 7405 (void) SyncImagesSettings(mogrify_info,*images,exception); 7406 if (*option == '+') 7407 { 7408 (void) RemapImages(quantize_info,*images,(Image *) NULL, 7409 exception); 7410 break; 7411 } 7412 i++; 7413 break; 7414 } 7415 if (LocaleCompare("append",option+1) == 0) 7416 { 7417 Image 7418 *append_image; 7419 7420 (void) SyncImagesSettings(mogrify_info,*images,exception); 7421 append_image=AppendImages(*images,*option == '-' ? MagickTrue : 7422 MagickFalse,exception); 7423 if (append_image == (Image *) NULL) 7424 { 7425 status=MagickFalse; 7426 break; 7427 } 7428 *images=DestroyImageList(*images); 7429 *images=append_image; 7430 break; 7431 } 7432 if (LocaleCompare("average",option+1) == 0) 7433 { 7434 Image 7435 *average_image; 7436 7437 /* 7438 Average an image sequence (deprecated). 7439 */ 7440 (void) SyncImagesSettings(mogrify_info,*images,exception); 7441 average_image=EvaluateImages(*images,MeanEvaluateOperator, 7442 exception); 7443 if (average_image == (Image *) NULL) 7444 { 7445 status=MagickFalse; 7446 break; 7447 } 7448 *images=DestroyImageList(*images); 7449 *images=average_image; 7450 break; 7451 } 7452 break; 7453 } 7454 case 'c': 7455 { 7456 if (LocaleCompare("channel-fx",option+1) == 0) 7457 { 7458 Image 7459 *channel_image; 7460 7461 (void) SyncImagesSettings(mogrify_info,*images,exception); 7462 channel_image=ChannelFxImage(*images,argv[i+1],exception); 7463 if (channel_image == (Image *) NULL) 7464 { 7465 status=MagickFalse; 7466 break; 7467 } 7468 *images=DestroyImageList(*images); 7469 *images=channel_image; 7470 break; 7471 } 7472 if (LocaleCompare("clut",option+1) == 0) 7473 { 7474 Image 7475 *clut_image, 7476 *image; 7477 7478 (void) SyncImagesSettings(mogrify_info,*images,exception); 7479 image=RemoveFirstImageFromList(images); 7480 clut_image=RemoveFirstImageFromList(images); 7481 if (clut_image == (Image *) NULL) 7482 { 7483 status=MagickFalse; 7484 break; 7485 } 7486 (void) ClutImage(image,clut_image,interpolate_method,exception); 7487 clut_image=DestroyImage(clut_image); 7488 *images=DestroyImageList(*images); 7489 *images=image; 7490 break; 7491 } 7492 if (LocaleCompare("coalesce",option+1) == 0) 7493 { 7494 Image 7495 *coalesce_image; 7496 7497 (void) SyncImagesSettings(mogrify_info,*images,exception); 7498 coalesce_image=CoalesceImages(*images,exception); 7499 if (coalesce_image == (Image *) NULL) 7500 { 7501 status=MagickFalse; 7502 break; 7503 } 7504 *images=DestroyImageList(*images); 7505 *images=coalesce_image; 7506 break; 7507 } 7508 if (LocaleCompare("combine",option+1) == 0) 7509 { 7510 ColorspaceType 7511 colorspace; 7512 7513 Image 7514 *combine_image; 7515 7516 (void) SyncImagesSettings(mogrify_info,*images,exception); 7517 colorspace=(ColorspaceType) ParseCommandOption( 7518 MagickColorspaceOptions,MagickFalse,argv[i+1]); 7519 combine_image=CombineImages(*images,colorspace,exception); 7520 if (combine_image == (Image *) NULL) 7521 { 7522 status=MagickFalse; 7523 break; 7524 } 7525 *images=DestroyImageList(*images); 7526 *images=combine_image; 7527 break; 7528 } 7529 if (LocaleCompare("compare",option+1) == 0) 7530 { 7531 const char 7532 *option; 7533 7534 double 7535 distortion; 7536 7537 Image 7538 *difference_image, 7539 *image, 7540 *reconstruct_image; 7541 7542 MetricType 7543 metric; 7544 7545 /* 7546 Mathematically and visually annotate the difference between an 7547 image and its reconstruction. 7548 */ 7549 (void) SyncImagesSettings(mogrify_info,*images,exception); 7550 image=RemoveFirstImageFromList(images); 7551 reconstruct_image=RemoveFirstImageFromList(images); 7552 if (reconstruct_image == (Image *) NULL) 7553 { 7554 status=MagickFalse; 7555 break; 7556 } 7557 metric=UndefinedErrorMetric; 7558 option=GetImageOption(image_info,"metric"); 7559 if (option != (const char *) NULL) 7560 metric=(MetricType) ParseCommandOption(MagickMetricOptions, 7561 MagickFalse,option); 7562 difference_image=CompareImages(image,reconstruct_image,metric, 7563 &distortion,exception); 7564 if (difference_image == (Image *) NULL) 7565 break; 7566 if (*images != (Image *) NULL) 7567 *images=DestroyImage(*images); 7568 *images=difference_image; 7569 break; 7570 } 7571 if (LocaleCompare("composite",option+1) == 0) 7572 { 7573 const char 7574 *value; 7575 7576 Image 7577 *mask_image, 7578 *composite_image, 7579 *image; 7580 7581 MagickBooleanType 7582 clip_to_self; 7583 7584 RectangleInfo 7585 geometry; 7586 7587 (void) SyncImagesSettings(mogrify_info,*images,exception); 7588 value=GetImageOption(mogrify_info,"compose:clip-to-self"); 7589 if (value == (const char *) NULL) 7590 clip_to_self=MagickTrue; 7591 else 7592 clip_to_self=IsStringTrue(GetImageOption(mogrify_info, 7593 "compose:clip-to-self")); /* if this is true */ 7594 if (IsMagickFalse(clip_to_self)) /* or */ 7595 clip_to_self=IfMagickFalse(IsStringNotFalse(GetImageOption( 7596 mogrify_info,"compose:outside-overlay"))) ? MagickTrue : 7597 MagickFalse; /* this false */ 7598 image=RemoveFirstImageFromList(images); 7599 composite_image=RemoveFirstImageFromList(images); 7600 if (composite_image == (Image *) NULL) 7601 { 7602 status=MagickFalse; 7603 break; 7604 } 7605 (void) TransformImage(&composite_image,(char *) NULL, 7606 composite_image->geometry,exception); 7607 SetGeometry(composite_image,&geometry); 7608 (void) ParseAbsoluteGeometry(composite_image->geometry,&geometry); 7609 GravityAdjustGeometry(image->columns,image->rows,image->gravity, 7610 &geometry); 7611 mask_image=RemoveFirstImageFromList(images); 7612 if (mask_image != (Image *) NULL) 7613 { 7614 if ((image->compose == DisplaceCompositeOp) || 7615 (image->compose == DistortCompositeOp)) 7616 status&=CompositeImage(composite_image,mask_image, 7617 CopyGreenCompositeOp,MagickTrue,0,0,exception); 7618 else 7619 { 7620 Image 7621 *image; 7622 7623 RectangleInfo 7624 composite_geometry; 7625 7626 composite_geometry.width=mask_image->columns; 7627 composite_geometry.height=mask_image->rows; 7628 composite_geometry.x=(-geometry.x); 7629 composite_geometry.y=(-geometry.y); 7630 geometry.x=0; 7631 geometry.y=0; 7632 image=ExtentImage(composite_image,&composite_geometry, 7633 exception); 7634 if (image != (Image *) NULL) 7635 { 7636 composite_image=DestroyImage(composite_image); 7637 composite_image=image; 7638 } 7639 status&=CompositeImage(composite_image,mask_image, 7640 IntensityCompositeOp,MagickTrue,0,0,exception); 7641 } 7642 mask_image=DestroyImage(mask_image); 7643 } 7644 (void) CompositeImage(image,composite_image,image->compose, 7645 clip_to_self,geometry.x,geometry.y,exception); 7646 composite_image=DestroyImage(composite_image); 7647 *images=DestroyImageList(*images); 7648 *images=image; 7649 break; 7650 } 7651 break; 7652 } 7653 case 'd': 7654 { 7655 if (LocaleCompare("deconstruct",option+1) == 0) 7656 { 7657 Image 7658 *deconstruct_image; 7659 7660 (void) SyncImagesSettings(mogrify_info,*images,exception); 7661 deconstruct_image=CompareImagesLayers(*images,CompareAnyLayer, 7662 exception); 7663 if (deconstruct_image == (Image *) NULL) 7664 { 7665 status=MagickFalse; 7666 break; 7667 } 7668 *images=DestroyImageList(*images); 7669 *images=deconstruct_image; 7670 break; 7671 } 7672 if (LocaleCompare("delete",option+1) == 0) 7673 { 7674 if (*option == '+') 7675 DeleteImages(images,"-1",exception); 7676 else 7677 DeleteImages(images,argv[i+1],exception); 7678 break; 7679 } 7680 if (LocaleCompare("dither",option+1) == 0) 7681 { 7682 if (*option == '+') 7683 { 7684 quantize_info->dither_method=NoDitherMethod; 7685 break; 7686 } 7687 quantize_info->dither_method=(DitherMethod) ParseCommandOption( 7688 MagickDitherOptions,MagickFalse,argv[i+1]); 7689 break; 7690 } 7691 if (LocaleCompare("duplicate",option+1) == 0) 7692 { 7693 Image 7694 *duplicate_images; 7695 7696 if (*option == '+') 7697 duplicate_images=DuplicateImages(*images,1,"-1",exception); 7698 else 7699 { 7700 const char 7701 *p; 7702 7703 size_t 7704 number_duplicates; 7705 7706 number_duplicates=(size_t) StringToLong(argv[i+1]); 7707 p=strchr(argv[i+1],','); 7708 if (p == (const char *) NULL) 7709 duplicate_images=DuplicateImages(*images,number_duplicates, 7710 "-1",exception); 7711 else 7712 duplicate_images=DuplicateImages(*images,number_duplicates,p, 7713 exception); 7714 } 7715 AppendImageToList(images, duplicate_images); 7716 (void) SyncImagesSettings(mogrify_info,*images,exception); 7717 break; 7718 } 7719 break; 7720 } 7721 case 'e': 7722 { 7723 if (LocaleCompare("evaluate-sequence",option+1) == 0) 7724 { 7725 Image 7726 *evaluate_image; 7727 7728 MagickEvaluateOperator 7729 op; 7730 7731 (void) SyncImageSettings(mogrify_info,*images,exception); 7732 op=(MagickEvaluateOperator) ParseCommandOption( 7733 MagickEvaluateOptions,MagickFalse,argv[i+1]); 7734 evaluate_image=EvaluateImages(*images,op,exception); 7735 if (evaluate_image == (Image *) NULL) 7736 { 7737 status=MagickFalse; 7738 break; 7739 } 7740 *images=DestroyImageList(*images); 7741 *images=evaluate_image; 7742 break; 7743 } 7744 break; 7745 } 7746 case 'f': 7747 { 7748 if (LocaleCompare("fft",option+1) == 0) 7749 { 7750 Image 7751 *fourier_image; 7752 7753 /* 7754 Implements the discrete Fourier transform (DFT). 7755 */ 7756 (void) SyncImageSettings(mogrify_info,*images,exception); 7757 fourier_image=ForwardFourierTransformImage(*images,*option == '-' ? 7758 MagickTrue : MagickFalse,exception); 7759 if (fourier_image == (Image *) NULL) 7760 break; 7761 *images=DestroyImage(*images); 7762 *images=fourier_image; 7763 break; 7764 } 7765 if (LocaleCompare("flatten",option+1) == 0) 7766 { 7767 Image 7768 *flatten_image; 7769 7770 (void) SyncImagesSettings(mogrify_info,*images,exception); 7771 flatten_image=MergeImageLayers(*images,FlattenLayer,exception); 7772 if (flatten_image == (Image *) NULL) 7773 break; 7774 *images=DestroyImageList(*images); 7775 *images=flatten_image; 7776 break; 7777 } 7778 if (LocaleCompare("fx",option+1) == 0) 7779 { 7780 Image 7781 *fx_image; 7782 7783 (void) SyncImagesSettings(mogrify_info,*images,exception); 7784 fx_image=FxImage(*images,argv[i+1],exception); 7785 if (fx_image == (Image *) NULL) 7786 { 7787 status=MagickFalse; 7788 break; 7789 } 7790 *images=DestroyImageList(*images); 7791 *images=fx_image; 7792 break; 7793 } 7794 break; 7795 } 7796 case 'h': 7797 { 7798 if (LocaleCompare("hald-clut",option+1) == 0) 7799 { 7800 Image 7801 *hald_image, 7802 *image; 7803 7804 (void) SyncImagesSettings(mogrify_info,*images,exception); 7805 image=RemoveFirstImageFromList(images); 7806 hald_image=RemoveFirstImageFromList(images); 7807 if (hald_image == (Image *) NULL) 7808 { 7809 status=MagickFalse; 7810 break; 7811 } 7812 (void) HaldClutImage(image,hald_image,exception); 7813 hald_image=DestroyImage(hald_image); 7814 if (*images != (Image *) NULL) 7815 *images=DestroyImageList(*images); 7816 *images=image; 7817 break; 7818 } 7819 break; 7820 } 7821 case 'i': 7822 { 7823 if (LocaleCompare("ift",option+1) == 0) 7824 { 7825 Image 7826 *fourier_image, 7827 *magnitude_image, 7828 *phase_image; 7829 7830 /* 7831 Implements the inverse fourier discrete Fourier transform (DFT). 7832 */ 7833 (void) SyncImagesSettings(mogrify_info,*images,exception); 7834 magnitude_image=RemoveFirstImageFromList(images); 7835 phase_image=RemoveFirstImageFromList(images); 7836 if (phase_image == (Image *) NULL) 7837 { 7838 status=MagickFalse; 7839 break; 7840 } 7841 fourier_image=InverseFourierTransformImage(magnitude_image, 7842 phase_image,*option == '-' ? MagickTrue : MagickFalse,exception); 7843 if (fourier_image == (Image *) NULL) 7844 break; 7845 if (*images != (Image *) NULL) 7846 *images=DestroyImage(*images); 7847 *images=fourier_image; 7848 break; 7849 } 7850 if (LocaleCompare("insert",option+1) == 0) 7851 { 7852 Image 7853 *p, 7854 *q; 7855 7856 index=0; 7857 if (*option != '+') 7858 index=(ssize_t) StringToLong(argv[i+1]); 7859 p=RemoveLastImageFromList(images); 7860 if (p == (Image *) NULL) 7861 { 7862 (void) ThrowMagickException(exception,GetMagickModule(), 7863 OptionError,"NoSuchImage","`%s'",argv[i+1]); 7864 status=MagickFalse; 7865 break; 7866 } 7867 q=p; 7868 if (index == 0) 7869 PrependImageToList(images,q); 7870 else 7871 if (index == (ssize_t) GetImageListLength(*images)) 7872 AppendImageToList(images,q); 7873 else 7874 { 7875 q=GetImageFromList(*images,index-1); 7876 if (q == (Image *) NULL) 7877 { 7878 (void) ThrowMagickException(exception,GetMagickModule(), 7879 OptionError,"NoSuchImage","`%s'",argv[i+1]); 7880 status=MagickFalse; 7881 break; 7882 } 7883 InsertImageInList(&q,p); 7884 } 7885 *images=GetFirstImageInList(q); 7886 break; 7887 } 7888 if (LocaleCompare("interpolate",option+1) == 0) 7889 { 7890 interpolate_method=(PixelInterpolateMethod) ParseCommandOption( 7891 MagickInterpolateOptions,MagickFalse,argv[i+1]); 7892 break; 7893 } 7894 break; 7895 } 7896 case 'l': 7897 { 7898 if (LocaleCompare("layers",option+1) == 0) 7899 { 7900 Image 7901 *layers; 7902 7903 LayerMethod 7904 method; 7905 7906 (void) SyncImagesSettings(mogrify_info,*images,exception); 7907 layers=(Image *) NULL; 7908 method=(LayerMethod) ParseCommandOption(MagickLayerOptions, 7909 MagickFalse,argv[i+1]); 7910 switch (method) 7911 { 7912 case CoalesceLayer: 7913 { 7914 layers=CoalesceImages(*images,exception); 7915 break; 7916 } 7917 case CompareAnyLayer: 7918 case CompareClearLayer: 7919 case CompareOverlayLayer: 7920 default: 7921 { 7922 layers=CompareImagesLayers(*images,method,exception); 7923 break; 7924 } 7925 case MergeLayer: 7926 case FlattenLayer: 7927 case MosaicLayer: 7928 case TrimBoundsLayer: 7929 { 7930 layers=MergeImageLayers(*images,method,exception); 7931 break; 7932 } 7933 case DisposeLayer: 7934 { 7935 layers=DisposeImages(*images,exception); 7936 break; 7937 } 7938 case OptimizeImageLayer: 7939 { 7940 layers=OptimizeImageLayers(*images,exception); 7941 break; 7942 } 7943 case OptimizePlusLayer: 7944 { 7945 layers=OptimizePlusImageLayers(*images,exception); 7946 break; 7947 } 7948 case OptimizeTransLayer: 7949 { 7950 OptimizeImageTransparency(*images,exception); 7951 break; 7952 } 7953 case RemoveDupsLayer: 7954 { 7955 RemoveDuplicateLayers(images,exception); 7956 break; 7957 } 7958 case RemoveZeroLayer: 7959 { 7960 RemoveZeroDelayLayers(images,exception); 7961 break; 7962 } 7963 case OptimizeLayer: 7964 { 7965 /* 7966 General Purpose, GIF Animation Optimizer. 7967 */ 7968 layers=CoalesceImages(*images,exception); 7969 if (layers == (Image *) NULL) 7970 { 7971 status=MagickFalse; 7972 break; 7973 } 7974 *images=DestroyImageList(*images); 7975 *images=layers; 7976 layers=OptimizeImageLayers(*images,exception); 7977 if (layers == (Image *) NULL) 7978 { 7979 status=MagickFalse; 7980 break; 7981 } 7982 *images=DestroyImageList(*images); 7983 *images=layers; 7984 layers=(Image *) NULL; 7985 OptimizeImageTransparency(*images,exception); 7986 (void) RemapImages(quantize_info,*images,(Image *) NULL, 7987 exception); 7988 break; 7989 } 7990 case CompositeLayer: 7991 { 7992 CompositeOperator 7993 compose; 7994 7995 Image 7996 *source; 7997 7998 RectangleInfo 7999 geometry; 8000 8001 /* 8002 Split image sequence at the first 'NULL:' image. 8003 */ 8004 source=(*images); 8005 while (source != (Image *) NULL) 8006 { 8007 source=GetNextImageInList(source); 8008 if ((source != (Image *) NULL) && 8009 (LocaleCompare(source->magick,"NULL") == 0)) 8010 break; 8011 } 8012 if (source != (Image *) NULL) 8013 { 8014 if ((GetPreviousImageInList(source) == (Image *) NULL) || 8015 (GetNextImageInList(source) == (Image *) NULL)) 8016 source=(Image *) NULL; 8017 else 8018 { 8019 /* 8020 Separate the two lists, junk the null: image. 8021 */ 8022 source=SplitImageList(source->previous); 8023 DeleteImageFromList(&source); 8024 } 8025 } 8026 if (source == (Image *) NULL) 8027 { 8028 (void) ThrowMagickException(exception,GetMagickModule(), 8029 OptionError,"MissingNullSeparator","layers Composite"); 8030 status=MagickFalse; 8031 break; 8032 } 8033 /* 8034 Adjust offset with gravity and virtual canvas. 8035 */ 8036 SetGeometry(*images,&geometry); 8037 (void) ParseAbsoluteGeometry((*images)->geometry,&geometry); 8038 geometry.width=source->page.width != 0 ? 8039 source->page.width : source->columns; 8040 geometry.height=source->page.height != 0 ? 8041 source->page.height : source->rows; 8042 GravityAdjustGeometry((*images)->page.width != 0 ? 8043 (*images)->page.width : (*images)->columns, 8044 (*images)->page.height != 0 ? (*images)->page.height : 8045 (*images)->rows,(*images)->gravity,&geometry); 8046 compose=OverCompositeOp; 8047 option=GetImageOption(mogrify_info,"compose"); 8048 if (option != (const char *) NULL) 8049 compose=(CompositeOperator) ParseCommandOption( 8050 MagickComposeOptions,MagickFalse,option); 8051 CompositeLayers(*images,compose,source,geometry.x,geometry.y, 8052 exception); 8053 source=DestroyImageList(source); 8054 break; 8055 } 8056 } 8057 if (layers == (Image *) NULL) 8058 break; 8059 *images=DestroyImageList(*images); 8060 *images=layers; 8061 break; 8062 } 8063 break; 8064 } 8065 case 'm': 8066 { 8067 if (LocaleCompare("map",option+1) == 0) 8068 { 8069 (void) SyncImagesSettings(mogrify_info,*images,exception); 8070 if (*option == '+') 8071 { 8072 (void) RemapImages(quantize_info,*images,(Image *) NULL, 8073 exception); 8074 break; 8075 } 8076 i++; 8077 break; 8078 } 8079 if (LocaleCompare("maximum",option+1) == 0) 8080 { 8081 Image 8082 *maximum_image; 8083 8084 /* 8085 Maximum image sequence (deprecated). 8086 */ 8087 (void) SyncImagesSettings(mogrify_info,*images,exception); 8088 maximum_image=EvaluateImages(*images,MaxEvaluateOperator,exception); 8089 if (maximum_image == (Image *) NULL) 8090 { 8091 status=MagickFalse; 8092 break; 8093 } 8094 *images=DestroyImageList(*images); 8095 *images=maximum_image; 8096 break; 8097 } 8098 if (LocaleCompare("minimum",option+1) == 0) 8099 { 8100 Image 8101 *minimum_image; 8102 8103 /* 8104 Minimum image sequence (deprecated). 8105 */ 8106 (void) SyncImagesSettings(mogrify_info,*images,exception); 8107 minimum_image=EvaluateImages(*images,MinEvaluateOperator,exception); 8108 if (minimum_image == (Image *) NULL) 8109 { 8110 status=MagickFalse; 8111 break; 8112 } 8113 *images=DestroyImageList(*images); 8114 *images=minimum_image; 8115 break; 8116 } 8117 if (LocaleCompare("morph",option+1) == 0) 8118 { 8119 Image 8120 *morph_image; 8121 8122 (void) SyncImagesSettings(mogrify_info,*images,exception); 8123 morph_image=MorphImages(*images,StringToUnsignedLong(argv[i+1]), 8124 exception); 8125 if (morph_image == (Image *) NULL) 8126 { 8127 status=MagickFalse; 8128 break; 8129 } 8130 *images=DestroyImageList(*images); 8131 *images=morph_image; 8132 break; 8133 } 8134 if (LocaleCompare("mosaic",option+1) == 0) 8135 { 8136 Image 8137 *mosaic_image; 8138 8139 (void) SyncImagesSettings(mogrify_info,*images,exception); 8140 mosaic_image=MergeImageLayers(*images,MosaicLayer,exception); 8141 if (mosaic_image == (Image *) NULL) 8142 { 8143 status=MagickFalse; 8144 break; 8145 } 8146 *images=DestroyImageList(*images); 8147 *images=mosaic_image; 8148 break; 8149 } 8150 break; 8151 } 8152 case 'p': 8153 { 8154 if (LocaleCompare("poly",option+1) == 0) 8155 { 8156 char 8157 *args, 8158 token[MaxTextExtent]; 8159 8160 const char 8161 *p; 8162 8163 double 8164 *arguments; 8165 8166 Image 8167 *polynomial_image; 8168 8169 register ssize_t 8170 x; 8171 8172 size_t 8173 number_arguments; 8174 8175 /* 8176 Polynomial image. 8177 */ 8178 (void) SyncImageSettings(mogrify_info,*images,exception); 8179 args=InterpretImageProperties(mogrify_info,*images,argv[i+1], 8180 exception); 8181 if (args == (char *) NULL) 8182 break; 8183 p=(char *) args; 8184 for (x=0; *p != '\0'; x++) 8185 { 8186 GetMagickToken(p,&p,token); 8187 if (*token == ',') 8188 GetMagickToken(p,&p,token); 8189 } 8190 number_arguments=(size_t) x; 8191 arguments=(double *) AcquireQuantumMemory(number_arguments, 8192 sizeof(*arguments)); 8193 if (arguments == (double *) NULL) 8194 ThrowWandFatalException(ResourceLimitFatalError, 8195 "MemoryAllocationFailed",(*images)->filename); 8196 (void) ResetMagickMemory(arguments,0,number_arguments* 8197 sizeof(*arguments)); 8198 p=(char *) args; 8199 for (x=0; (x < (ssize_t) number_arguments) && (*p != '\0'); x++) 8200 { 8201 GetMagickToken(p,&p,token); 8202 if (*token == ',') 8203 GetMagickToken(p,&p,token); 8204 arguments[x]=StringToDouble(token,(char **) NULL); 8205 } 8206 args=DestroyString(args); 8207 polynomial_image=PolynomialImage(*images,number_arguments >> 1, 8208 arguments,exception); 8209 arguments=(double *) RelinquishMagickMemory(arguments); 8210 if (polynomial_image == (Image *) NULL) 8211 { 8212 status=MagickFalse; 8213 break; 8214 } 8215 *images=DestroyImageList(*images); 8216 *images=polynomial_image; 8217 } 8218 if (LocaleCompare("print",option+1) == 0) 8219 { 8220 char 8221 *string; 8222 8223 (void) SyncImagesSettings(mogrify_info,*images,exception); 8224 string=InterpretImageProperties(mogrify_info,*images,argv[i+1], 8225 exception); 8226 if (string == (char *) NULL) 8227 break; 8228 (void) FormatLocaleFile(stdout,"%s",string); 8229 string=DestroyString(string); 8230 } 8231 if (LocaleCompare("process",option+1) == 0) 8232 { 8233 char 8234 **arguments; 8235 8236 int 8237 j, 8238 number_arguments; 8239 8240 (void) SyncImagesSettings(mogrify_info,*images,exception); 8241 arguments=StringToArgv(argv[i+1],&number_arguments); 8242 if (arguments == (char **) NULL) 8243 break; 8244 if ((argc > 1) && (strchr(arguments[1],'=') != (char *) NULL)) 8245 { 8246 char 8247 breaker, 8248 quote, 8249 *token; 8250 8251 const char 8252 *arguments; 8253 8254 int 8255 next, 8256 status; 8257 8258 size_t 8259 length; 8260 8261 TokenInfo 8262 *token_info; 8263 8264 /* 8265 Support old style syntax, filter="-option arg". 8266 */ 8267 length=strlen(argv[i+1]); 8268 token=(char *) NULL; 8269 if (~length >= (MaxTextExtent-1)) 8270 token=(char *) AcquireQuantumMemory(length+MaxTextExtent, 8271 sizeof(*token)); 8272 if (token == (char *) NULL) 8273 break; 8274 next=0; 8275 arguments=argv[i+1]; 8276 token_info=AcquireTokenInfo(); 8277 status=Tokenizer(token_info,0,token,length,arguments,"","=", 8278 "\"",'\0',&breaker,&next,"e); 8279 token_info=DestroyTokenInfo(token_info); 8280 if (status == 0) 8281 { 8282 const char 8283 *argv; 8284 8285 argv=(&(arguments[next])); 8286 (void) InvokeDynamicImageFilter(token,&(*images),1,&argv, 8287 exception); 8288 } 8289 token=DestroyString(token); 8290 break; 8291 } 8292 (void) SubstituteString(&arguments[1],"-",""); 8293 (void) InvokeDynamicImageFilter(arguments[1],&(*images), 8294 number_arguments-2,(const char **) arguments+2,exception); 8295 for (j=0; j < number_arguments; j++) 8296 arguments[j]=DestroyString(arguments[j]); 8297 arguments=(char **) RelinquishMagickMemory(arguments); 8298 break; 8299 } 8300 break; 8301 } 8302 case 'r': 8303 { 8304 if (LocaleCompare("reverse",option+1) == 0) 8305 { 8306 ReverseImageList(images); 8307 break; 8308 } 8309 break; 8310 } 8311 case 's': 8312 { 8313 if (LocaleCompare("smush",option+1) == 0) 8314 { 8315 Image 8316 *smush_image; 8317 8318 ssize_t 8319 offset; 8320 8321 (void) SyncImagesSettings(mogrify_info,*images,exception); 8322 offset=(ssize_t) StringToLong(argv[i+1]); 8323 smush_image=SmushImages(*images,*option == '-' ? MagickTrue : 8324 MagickFalse,offset,exception); 8325 if (smush_image == (Image *) NULL) 8326 { 8327 status=MagickFalse; 8328 break; 8329 } 8330 *images=DestroyImageList(*images); 8331 *images=smush_image; 8332 break; 8333 } 8334 if (LocaleCompare("swap",option+1) == 0) 8335 { 8336 Image 8337 *p, 8338 *q, 8339 *swap; 8340 8341 ssize_t 8342 swap_index; 8343 8344 index=(-1); 8345 swap_index=(-2); 8346 if (*option != '+') 8347 { 8348 GeometryInfo 8349 geometry_info; 8350 8351 MagickStatusType 8352 flags; 8353 8354 swap_index=(-1); 8355 flags=ParseGeometry(argv[i+1],&geometry_info); 8356 index=(ssize_t) geometry_info.rho; 8357 if ((flags & SigmaValue) != 0) 8358 swap_index=(ssize_t) geometry_info.sigma; 8359 } 8360 p=GetImageFromList(*images,index); 8361 q=GetImageFromList(*images,swap_index); 8362 if ((p == (Image *) NULL) || (q == (Image *) NULL)) 8363 { 8364 (void) ThrowMagickException(exception,GetMagickModule(), 8365 OptionError,"NoSuchImage","`%s'",(*images)->filename); 8366 status=MagickFalse; 8367 break; 8368 } 8369 if (p == q) 8370 break; 8371 swap=CloneImage(p,0,0,MagickTrue,exception); 8372 ReplaceImageInList(&p,CloneImage(q,0,0,MagickTrue,exception)); 8373 ReplaceImageInList(&q,swap); 8374 *images=GetFirstImageInList(q); 8375 break; 8376 } 8377 break; 8378 } 8379 case 'w': 8380 { 8381 if (LocaleCompare("write",option+1) == 0) 8382 { 8383 char 8384 key[MaxTextExtent]; 8385 8386 Image 8387 *write_images; 8388 8389 ImageInfo 8390 *write_info; 8391 8392 (void) SyncImagesSettings(mogrify_info,*images,exception); 8393 (void) FormatLocaleString(key,MaxTextExtent,"cache:%s",argv[i+1]); 8394 (void) DeleteImageRegistry(key); 8395 write_images=(*images); 8396 if (*option == '+') 8397 write_images=CloneImageList(*images,exception); 8398 write_info=CloneImageInfo(mogrify_info); 8399 status&=WriteImages(write_info,write_images,argv[i+1],exception); 8400 write_info=DestroyImageInfo(write_info); 8401 if (*option == '+') 8402 write_images=DestroyImageList(write_images); 8403 break; 8404 } 8405 break; 8406 } 8407 default: 8408 break; 8409 } 8410 i+=count; 8411 } 8412 quantize_info=DestroyQuantizeInfo(quantize_info); 8413 mogrify_info=DestroyImageInfo(mogrify_info); 8414 status&=MogrifyImageInfo(image_info,argc,argv,exception); 8415 return(status != 0 ? MagickTrue : MagickFalse); 8416} 8417 8418/* 8419%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8420% % 8421% % 8422% % 8423+ M o g r i f y I m a g e s % 8424% % 8425% % 8426% % 8427%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8428% 8429% MogrifyImages() applies image processing options to a sequence of images as 8430% prescribed by command line options. 8431% 8432% The format of the MogrifyImage method is: 8433% 8434% MagickBooleanType MogrifyImages(ImageInfo *image_info, 8435% const MagickBooleanType post,const int argc,const char **argv, 8436% Image **images,Exceptioninfo *exception) 8437% 8438% A description of each parameter follows: 8439% 8440% o image_info: the image info.. 8441% 8442% o post: If true, post process image list operators otherwise pre-process. 8443% 8444% o argc: Specifies a pointer to an integer describing the number of 8445% elements in the argument vector. 8446% 8447% o argv: Specifies a pointer to a text array containing the command line 8448% arguments. 8449% 8450% o images: pointer to a pointer of the first image in image list. 8451% 8452% o exception: return any errors or warnings in this structure. 8453% 8454*/ 8455WandExport MagickBooleanType MogrifyImages(ImageInfo *image_info, 8456 const MagickBooleanType post,const int argc,const char **argv, 8457 Image **images,ExceptionInfo *exception) 8458{ 8459#define MogrifyImageTag "Mogrify/Image" 8460 8461 MagickStatusType 8462 status; 8463 8464 MagickBooleanType 8465 proceed; 8466 8467 size_t 8468 n; 8469 8470 register ssize_t 8471 i; 8472 8473 assert(image_info != (ImageInfo *) NULL); 8474 assert(image_info->signature == MagickSignature); 8475 if (images == (Image **) NULL) 8476 return(MogrifyImage(image_info,argc,argv,images,exception)); 8477 assert((*images)->previous == (Image *) NULL); 8478 assert((*images)->signature == MagickSignature); 8479 if ((*images)->debug != MagickFalse) 8480 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", 8481 (*images)->filename); 8482 if ((argc <= 0) || (*argv == (char *) NULL)) 8483 return(MagickTrue); 8484 (void) SetImageInfoProgressMonitor(image_info,(MagickProgressMonitor) NULL, 8485 (void *) NULL); 8486 status=0; 8487 8488#if 0 8489 (void) FormatLocaleFile(stderr, "mogrify start %s %d (%s)\n",argv[0],argc, 8490 post?"post":"pre"); 8491#endif 8492 8493 /* 8494 Pre-process multi-image sequence operators 8495 */ 8496 if (post == MagickFalse) 8497 status&=MogrifyImageList(image_info,argc,argv,images,exception); 8498 /* 8499 For each image, process simple single image operators 8500 */ 8501 i=0; 8502 n=GetImageListLength(*images); 8503 for ( ; ; ) 8504 { 8505#if 0 8506 (void) FormatLocaleFile(stderr,"mogrify %ld of %ld\n",(long) 8507 GetImageIndexInList(*images),(long)GetImageListLength(*images)); 8508#endif 8509 status&=MogrifyImage(image_info,argc,argv,images,exception); 8510 proceed=SetImageProgress(*images,MogrifyImageTag,(MagickOffsetType) i, n); 8511 if (proceed == MagickFalse) 8512 break; 8513 if ( (*images)->next == (Image *) NULL ) 8514 break; 8515 *images=(*images)->next; 8516 i++; 8517 } 8518 assert( *images != (Image *) NULL ); 8519#if 0 8520 (void) FormatLocaleFile(stderr,"mogrify end %ld of %ld\n",(long) 8521 GetImageIndexInList(*images),(long)GetImageListLength(*images)); 8522#endif 8523 8524 /* 8525 Post-process, multi-image sequence operators 8526 */ 8527 *images=GetFirstImageInList(*images); 8528 if (post != MagickFalse) 8529 status&=MogrifyImageList(image_info,argc,argv,images,exception); 8530 return(status != 0 ? MagickTrue : MagickFalse); 8531} 8532