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