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