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