1 /* 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 3 % % 4 % % 5 % % 6 % DDDD IIIII SSSSS PPPP L AAA Y Y % 7 % D D I SS P P L A A Y Y % 8 % D D I SSS PPPP L AAAAA Y % 9 % D D I SS P L A A Y % 10 % DDDD IIIII SSSSS P LLLLL A A Y % 11 % % 12 % % 13 % Methods to Interactively Display and Edit an Image % 14 % % 15 % Software Design % 16 % Cristy % 17 % July 1992 % 18 % % 19 % % 20 % Copyright 1999-2019 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 % https://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 display program to display an image or image sequence on any X 37 % server. 38 % 39 */ 40 41 /* 43 Include declarations. 44 */ 45 #include "MagickWand/studio.h" 46 #include "MagickWand/MagickWand.h" 47 #include "MagickWand/mogrify-private.h" 48 #include "MagickCore/display-private.h" 49 #include "MagickCore/string-private.h" 50 51 /* 53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 54 % % 55 % % 56 % % 57 + D i s p l a y I m a g e C o m m a n d % 58 % % 59 % % 60 % % 61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 62 % 63 % DisplayImageCommand() displays a sequence of images on any workstation 64 % display running an X server. Display first determines the hardware 65 % capabilities of the workstation. If the number of unique colors in an image 66 % is less than or equal to the number the workstation can support, the image 67 % is displayed in an X window. Otherwise the number of colors in the image is 68 % first reduced to match the color resolution of the workstation before it is 69 % displayed. 70 % 71 % This means that a continuous-tone 24 bits/pixel image can display on a 8 72 % bit pseudo-color device or monochrome device. In most instances the reduced 73 % color image closely resembles the original. Alternatively, a monochrome or 74 % pseudo-color image sequence can display on a continuous-tone 24 bits/pixels 75 % device. 76 % 77 % The format of the DisplayImageCommand method is: 78 % 79 % MagickBooleanType DisplayImageCommand(ImageInfo *image_info,int argc, 80 % char **argv,char **metadata,ExceptionInfo *exception) 81 % 82 % A description of each parameter follows: 83 % 84 % o image_info: the image info. 85 % 86 % o argc: the number of elements in the argument vector. 87 % 88 % o argv: A text array containing the command line arguments. 89 % 90 % o metadata: any metadata is returned here. 91 % 92 % o exception: return any errors or warnings in this structure. 93 % 94 */ 95 96 static MagickBooleanType DisplayUsage(void) 97 { 98 const char 99 **p; 100 101 static const char 102 *buttons[]= 103 { 104 "1 press to map or unmap the Command widget", 105 "2 press and drag to magnify a region of an image", 106 "3 press to load an image from a visual image directory", 107 (char *) NULL 108 }, 109 *miscellaneous[]= 110 { 111 "-debug events display copious debugging information", 112 "-help print program options", 113 "-list type print a list of supported option arguments", 114 "-log format format of debugging information", 115 "-version print version information", 116 (char *) NULL 117 }, 118 *operators[]= 119 { 120 "-auto-orient automagically orient image", 121 "-border geometry surround image with a border of color", 122 "-clip clip along the first path from the 8BIM profile", 123 "-clip-path id clip along a named path from the 8BIM profile", 124 "-colors value preferred number of colors in the image", 125 "-contrast enhance or reduce the image contrast", 126 "-crop geometry preferred size and location of the cropped image", 127 "-decipher filename convert cipher pixels to plain pixels", 128 "-deskew threshold straighten an image", 129 "-despeckle reduce the speckles within an image", 130 "-edge factor apply a filter to detect edges in the image", 131 "-enhance apply a digital filter to enhance a noisy image", 132 "-equalize perform histogram equalization to an image", 133 "-extract geometry extract area from image", 134 "-flip flip image in the vertical direction", 135 "-flop flop image in the horizontal direction", 136 "-frame geometry surround image with an ornamental border", 137 "-fuzz distance colors within this distance are considered equal", 138 "-gamma value level of gamma correction", 139 "-monochrome transform image to black and white", 140 "-negate replace every pixel with its complementary color", 141 "-normalize transform image to span the full range of colors", 142 "-raise value lighten/darken image edges to create a 3-D effect", 143 "-resample geometry change the resolution of an image", 144 "-resize geometry resize the image", 145 "-roll geometry roll an image vertically or horizontally", 146 "-rotate degrees apply Paeth rotation to the image", 147 "-sample geometry scale image with pixel sampling", 148 "-segment value segment an image", 149 "-sharpen geometry sharpen the image", 150 "-strip strip image of all profiles and comments", 151 "-threshold value threshold the image", 152 "-thumbnail geometry create a thumbnail of the image", 153 "-trim trim image edges", 154 (char *) NULL 155 }, 156 *settings[]= 157 { 158 "-alpha option on, activate, off, deactivate, set, opaque, copy", 159 " transparent, extract, background, or shape", 160 "-antialias remove pixel-aliasing", 161 "-authenticate password", 162 " decipher image with this password", 163 "-backdrop display image centered on a backdrop", 164 "-channel type apply option to select image channels", 165 "-colormap type Shared or Private", 166 "-colorspace type alternate image colorspace", 167 "-comment string annotate image with comment", 168 "-compress type type of pixel compression when writing the image", 169 "-define format:option", 170 " define one or more image format options", 171 "-delay value display the next image after pausing", 172 "-density geometry horizontal and vertical density of the image", 173 "-depth value image depth", 174 "-display server display image to this X server", 175 "-dispose method layer disposal method", 176 "-dither method apply error diffusion to image", 177 "-endian type endianness (MSB or LSB) of the image", 178 "-filter type use this filter when resizing an image", 179 "-format string output formatted image characteristics", 180 "-geometry geometry preferred size and location of the Image window", 181 "-gravity type horizontal and vertical backdrop placement", 182 "-identify identify the format and characteristics of the image", 183 "-immutable displayed image cannot be modified", 184 "-interlace type type of image interlacing scheme", 185 "-interpolate method pixel color interpolation method", 186 "-label string assign a label to an image", 187 "-limit type value pixel cache resource limit", 188 "-loop iterations loop images then exit", 189 "-map type display image using this Standard Colormap", 190 "-matte store matte channel if the image has one", 191 "-monitor monitor progress", 192 "-nostdin do not try to open stdin", 193 "-page geometry size and location of an image canvas", 194 "-profile filename add, delete, or apply an image profile", 195 "-quality value JPEG/MIFF/PNG compression level", 196 "-quantize colorspace reduce colors in this colorspace", 197 "-quiet suppress all warning messages", 198 "-regard-warnings pay attention to warning messages", 199 "-remote command execute a command in an remote display process", 200 "-repage geometry size and location of an image canvas (operator)", 201 "-respect-parentheses settings remain in effect until parenthesis boundary", 202 "-sampling-factor geometry", 203 " horizontal and vertical sampling factor", 204 "-scenes range image scene range", 205 "-seed value seed a new sequence of pseudo-random numbers", 206 "-set property value set an image property", 207 "-size geometry width and height of image", 208 "-support factor resize support: > 1.0 is blurry, < 1.0 is sharp", 209 "-texture filename name of texture to tile onto the image background", 210 "-transparent-color color", 211 " transparent color", 212 "-treedepth value color tree depth", 213 "-update seconds detect when image file is modified and redisplay", 214 "-verbose print detailed information about the image", 215 "-visual type display image using this visual type", 216 "-virtual-pixel method", 217 " virtual pixel access method", 218 "-window id display image to background of this window", 219 "-window-group id exit program when this window id is destroyed", 220 "-write filename write image to a file", 221 (char *) NULL 222 }, 223 *sequence_operators[]= 224 { 225 "-coalesce merge a sequence of images", 226 "-flatten flatten a sequence of images", 227 (char *) NULL 228 }; 229 230 ListMagickVersion(stdout); 231 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", 232 GetClientName()); 233 (void) printf("\nImage Settings:\n"); 234 for (p=settings; *p != (char *) NULL; p++) 235 (void) printf(" %s\n",*p); 236 (void) printf("\nImage Operators:\n"); 237 for (p=operators; *p != (char *) NULL; p++) 238 (void) printf(" %s\n",*p); 239 (void) printf("\nImage Sequence Operators:\n"); 240 for (p=sequence_operators; *p != (char *) NULL; p++) 241 (void) printf(" %s\n",*p); 242 (void) printf("\nMiscellaneous Options:\n"); 243 for (p=miscellaneous; *p != (char *) NULL; p++) 244 (void) printf(" %s\n",*p); 245 (void) printf( 246 "\nIn addition to those listed above, you can specify these standard X\n"); 247 (void) printf( 248 "resources as command line options: -background, -bordercolor,\n"); 249 (void) printf( 250 " -mattecolor, -borderwidth, -font, -foreground, -iconGeometry,\n"); 251 (void) printf("-iconic, -name, -shared-memory, -usePixmap, or -title.\n"); 252 (void) printf( 253 "\nBy default, the image format of 'file' is determined by its magic\n"); 254 (void) printf( 255 "number. To specify a particular image format, precede the filename\n"); 256 (void) printf( 257 "with an image format name and a colon (i.e. ps:image) or specify the\n"); 258 (void) printf( 259 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); 260 (void) printf("'-' for standard input or output.\n"); 261 (void) printf("\nButtons: \n"); 262 for (p=buttons; *p != (char *) NULL; p++) 263 (void) printf(" %s\n",*p); 264 return(MagickFalse); 265 } 266 267 WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info, 268 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) 269 { 270 #if defined(MAGICKCORE_X11_DELEGATE) 271 #define DestroyDisplay() \ 272 { \ 273 if ((state & ExitState) == 0) \ 274 DestroyXResources(); \ 275 if (display != (Display *) NULL) \ 276 { \ 277 XCloseDisplay(display); \ 278 display=(Display *) NULL; \ 279 } \ 280 XDestroyResourceInfo(&resource_info); \ 281 DestroyImageStack(); \ 282 if (image_marker != (size_t *) NULL) \ 283 image_marker=(size_t *) RelinquishMagickMemory(image_marker); \ 284 for (i=0; i < (ssize_t) argc; i++) \ 285 argv[i]=DestroyString(argv[i]); \ 286 argv=(char **) RelinquishMagickMemory(argv); \ 287 } 288 #define ThrowDisplayException(asperity,tag,option) \ 289 { \ 290 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ 291 option); \ 292 DestroyDisplay(); \ 293 return(MagickFalse); \ 294 } 295 #define ThrowDisplayInvalidArgumentException(option,argument) \ 296 { \ 297 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ 298 "InvalidArgument","'%s': %s",option,argument); \ 299 DestroyDisplay(); \ 300 return(MagickFalse); \ 301 } 302 303 char 304 *resource_value, 305 *server_name; 306 307 const char 308 *option; 309 310 Display 311 *display; 312 313 Image 314 *image; 315 316 ImageStack 317 image_stack[MaxImageStackDepth+1]; 318 319 MagickBooleanType 320 fire, 321 nostdin, 322 pend, 323 respect_parenthesis; 324 325 MagickStatusType 326 status; 327 328 QuantizeInfo 329 *quantize_info; 330 331 register ssize_t 332 i; 333 334 size_t 335 *image_marker, 336 iterations, 337 last_image, 338 state; 339 340 ssize_t 341 image_number, 342 iteration, 343 j, 344 k, 345 l; 346 347 XResourceInfo 348 resource_info; 349 350 XrmDatabase 351 resource_database; 352 353 /* 354 Set defaults. 355 */ 356 assert(image_info != (ImageInfo *) NULL); 357 assert(image_info->signature == MagickCoreSignature); 358 if (image_info->debug != MagickFalse) 359 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 360 assert(exception != (ExceptionInfo *) NULL); 361 if (argc == 2) 362 { 363 option=argv[1]; 364 if ((LocaleCompare("version",option+1) == 0) || 365 (LocaleCompare("-version",option+1) == 0)) 366 { 367 ListMagickVersion(stdout); 368 return(MagickTrue); 369 } 370 } 371 SetNotifyHandlers; 372 display=(Display *) NULL; 373 j=1; 374 k=0; 375 image_marker=(size_t *) NULL; 376 image_number=0; 377 last_image=0; 378 NewImageStack(); 379 option=(char *) NULL; 380 pend=MagickFalse; 381 respect_parenthesis=MagickFalse; 382 nostdin=MagickFalse; 383 resource_database=(XrmDatabase) NULL; 384 (void) memset(&resource_info,0,sizeof(resource_info)); 385 server_name=(char *) NULL; 386 state=0; 387 status=MagickTrue; 388 ReadCommandlLine(argc,&argv); 389 status=ExpandFilenames(&argc,&argv); 390 if (status == MagickFalse) 391 ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed", 392 GetExceptionMessage(errno)); 393 image_marker=(size_t *) AcquireQuantumMemory((size_t) argc+1UL, 394 sizeof(*image_marker)); 395 if (image_marker == (size_t *) NULL) 396 ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed", 397 GetExceptionMessage(errno)); 398 for (i=0; i <= (ssize_t) argc; i++) 399 image_marker[i]=(size_t) argc; 400 /* 401 Check for server name specified on the command line. 402 */ 403 for (i=1; i < (ssize_t) argc; i++) 404 { 405 /* 406 Check command line for server name. 407 */ 408 option=argv[i]; 409 if (IsCommandOption(option) == MagickFalse) 410 continue; 411 if (LocaleCompare("display",option+1) == 0) 412 { 413 /* 414 User specified server name. 415 */ 416 i++; 417 if (i == (ssize_t) argc) 418 ThrowDisplayException(OptionError,"MissingArgument",option); 419 server_name=argv[i]; 420 } 421 if (LocaleCompare("nostdin",option+1) == 0) 422 nostdin=MagickTrue; 423 if ((LocaleCompare("help",option+1) == 0) || 424 (LocaleCompare("-help",option+1) == 0)) 425 return(DisplayUsage()); 426 } 427 /* 428 Get user defaults from X resource database. 429 */ 430 display=XOpenDisplay(server_name); 431 if (display == (Display *) NULL) 432 ThrowDisplayException(XServerError,"UnableToOpenXServer", 433 XDisplayName(server_name)); 434 (void) XSetErrorHandler(XError); 435 resource_database=XGetResourceDatabase(display,GetClientName()); 436 XGetResourceInfo(image_info,resource_database,GetClientName(), 437 &resource_info); 438 quantize_info=resource_info.quantize_info; 439 image_info->density=XGetResourceInstance(resource_database,GetClientName(), 440 "density",(char *) NULL); 441 if (image_info->density == (char *) NULL) 442 image_info->density=XGetScreenDensity(display); 443 resource_value=XGetResourceInstance(resource_database,GetClientName(), 444 "interlace","none"); 445 image_info->interlace=(InterlaceType) 446 ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value); 447 image_info->page=XGetResourceInstance(resource_database,GetClientName(), 448 "pageGeometry",(char *) NULL); 449 resource_value=XGetResourceInstance(resource_database,GetClientName(), 450 "quality","75"); 451 image_info->quality=StringToUnsignedLong(resource_value); 452 resource_value=XGetResourceInstance(resource_database,GetClientName(), 453 "verbose","False"); 454 image_info->verbose=IsStringTrue(resource_value); 455 resource_value=XGetResourceInstance(resource_database,GetClientName(), 456 "dither","True"); 457 quantize_info->dither_method=IsStringTrue(resource_value) != MagickFalse ? 458 RiemersmaDitherMethod : NoDitherMethod; 459 /* 460 Parse command line. 461 */ 462 iteration=0; 463 for (i=1; ((i <= (ssize_t) argc) && ((state & ExitState) == 0)); i++) 464 { 465 if (i < (ssize_t) argc) 466 option=argv[i]; 467 else 468 if (image != (Image *) NULL) 469 break; 470 else 471 if (isatty(STDIN_FILENO) != MagickFalse || (nostdin != MagickFalse)) 472 option="logo:"; 473 else 474 option="-"; 475 if (LocaleCompare(option,"(") == 0) 476 { 477 FireImageStack(MagickFalse,MagickTrue,pend); 478 if (k == MaxImageStackDepth) 479 ThrowDisplayException(OptionError,"ParenthesisNestedTooDeeply", 480 option); 481 PushImageStack(); 482 continue; 483 } 484 if (LocaleCompare(option,")") == 0) 485 { 486 FireImageStack(MagickFalse,MagickTrue,MagickTrue); 487 if (k == 0) 488 ThrowDisplayException(OptionError,"UnableToParseExpression",option); 489 PopImageStack(); 490 continue; 491 } 492 if (IsCommandOption(option) == MagickFalse) 493 { 494 const char 495 *filename; 496 497 Image 498 *display_image, 499 *image_list, 500 *images; 501 502 /* 503 Option is a file name. 504 */ 505 FireImageStack(MagickFalse,MagickFalse,pend); 506 filename=option; 507 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) 508 { 509 option=argv[++i]; 510 filename=option; 511 } 512 (void) CopyMagickString(image_info->filename,filename,MagickPathExtent); 513 images=ReadImage(image_info,exception); 514 CatchException(exception); 515 status&=(images != (Image *) NULL) && 516 (exception->severity < ErrorException); 517 if (images == (Image *) NULL) 518 continue; 519 AppendImageStack(images); 520 FinalizeImageSettings(image_info,image,MagickFalse); 521 iterations=image->iterations; 522 image_list=CloneImageList(image,exception); 523 if (image_list == (Image *) NULL) 524 ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed", 525 GetExceptionMessage(errno)); 526 display_image=image_list; 527 do 528 { 529 /* 530 Transmogrify image as defined by the image processing options. 531 */ 532 resource_info.quantum=1; 533 if (resource_info.window_id != (char *) NULL) 534 { 535 /* 536 Display image to a specified X window. 537 */ 538 status=XDisplayBackgroundImage(display,&resource_info, 539 display_image,exception); 540 if (status != MagickFalse) 541 { 542 state|=RetainColorsState; 543 status=MagickFalse; 544 } 545 if (GetNextImageInList(display_image) == (Image *) NULL) 546 state|=ExitState; 547 } 548 else 549 do 550 { 551 Image 552 *nexus; 553 554 /* 555 Display image to X server. 556 */ 557 if (resource_info.delay != 1) 558 display_image->delay=resource_info.delay; 559 nexus=XDisplayImage(display,&resource_info,argv,argc, 560 &display_image,&state,exception); 561 if (nexus == (Image *) NULL) 562 break; 563 while ((nexus != (Image *) NULL) && ((state & ExitState) == 0)) 564 { 565 Image 566 *next; 567 568 if (nexus->montage != (char *) NULL) 569 { 570 /* 571 User selected a visual directory image (montage). 572 */ 573 display_image=nexus; 574 break; 575 } 576 next=XDisplayImage(display,&resource_info,argv,argc,&nexus, 577 &state,exception); 578 if ((next == (Image *) NULL) && 579 (GetNextImageInList(nexus) != (Image *) NULL)) 580 { 581 display_image=GetNextImageInList(nexus); 582 nexus=NewImageList(); 583 } 584 else 585 { 586 if (nexus != display_image) 587 nexus=DestroyImageList(nexus); 588 nexus=next; 589 } 590 } 591 } while ((state & ExitState) == 0); 592 if (resource_info.write_filename != (char *) NULL) 593 { 594 /* 595 Write image. 596 */ 597 (void) CopyMagickString(display_image->filename, 598 resource_info.write_filename,MagickPathExtent); 599 (void) SetImageInfo(image_info,1,exception); 600 status&=WriteImage(image_info,display_image,exception); 601 } 602 /* 603 Proceed to next/previous image. 604 */ 605 if ((state & FormerImageState) != 0) 606 for (l=0; l < (ssize_t) resource_info.quantum; l++) 607 { 608 if (GetPreviousImageInList(display_image) == (Image *) NULL) 609 break; 610 display_image=GetPreviousImageInList(display_image); 611 } 612 else 613 for (l=0; l < (ssize_t) resource_info.quantum; l++) 614 { 615 if (GetNextImageInList(display_image) == (Image *) NULL) 616 break; 617 display_image=GetNextImageInList(display_image); 618 } 619 if (l < (ssize_t) resource_info.quantum) 620 break; 621 } while ((display_image != (Image *) NULL) && ((state & ExitState) == 0)); 622 /* 623 Free image resources. 624 */ 625 display_image=DestroyImageList(display_image); 626 if ((state & FormerImageState) == 0) 627 { 628 last_image=(size_t) image_number; 629 image_marker[i]=(size_t) image_number++; 630 } 631 else 632 { 633 /* 634 Proceed to previous image. 635 */ 636 for (i--; i > 0; i--) 637 if (image_marker[i] == (size_t) (image_number-2)) 638 break; 639 image_number--; 640 } 641 if ((i == (ssize_t) argc) && ((state & ExitState) == 0)) 642 i=0; 643 if ((state & ExitState) != 0) 644 break; 645 /* 646 Determine if we should proceed to the first image. 647 */ 648 if (image_number < 0) 649 { 650 if ((state & FormerImageState) != 0) 651 { 652 653 for (i=1; i < (ssize_t) (argc-2); i++) 654 if (last_image == image_marker[i]) 655 break; 656 image_number=(ssize_t) image_marker[i]+1; 657 } 658 continue; 659 } 660 if (resource_info.window_id != (char *) NULL) 661 state|=ExitState; 662 if (iterations != 0) 663 { 664 if (++iteration == (ssize_t) iterations) 665 state|=ExitState; 666 i=0; 667 } 668 if (LocaleCompare(filename,"-") == 0) 669 state|=ExitState; 670 RemoveAllImageStack(); 671 continue; 672 } 673 pend=image != (Image *) NULL ? MagickTrue : MagickFalse; 674 switch (*(option+1)) 675 { 676 case 'a': 677 { 678 if (LocaleCompare("alpha",option+1) == 0) 679 { 680 ssize_t 681 type; 682 683 if (*option == '+') 684 break; 685 i++; 686 if (i == (ssize_t) argc) 687 ThrowDisplayException(OptionError,"MissingArgument",option); 688 type=ParseCommandOption(MagickAlphaChannelOptions,MagickFalse, 689 argv[i]); 690 if (type < 0) 691 ThrowDisplayException(OptionError, 692 "UnrecognizedAlphaChannelOption",argv[i]); 693 break; 694 } 695 if (LocaleCompare("antialias",option+1) == 0) 696 break; 697 if (LocaleCompare("authenticate",option+1) == 0) 698 { 699 if (*option == '+') 700 break; 701 i++; 702 if (i == (ssize_t) argc) 703 ThrowDisplayException(OptionError,"MissingArgument",option); 704 break; 705 } 706 if (LocaleCompare("auto-orient",option+1) == 0) 707 break; 708 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 709 } 710 case 'b': 711 { 712 if (LocaleCompare("backdrop",option+1) == 0) 713 { 714 resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse; 715 break; 716 } 717 if (LocaleCompare("background",option+1) == 0) 718 { 719 if (*option == '+') 720 break; 721 i++; 722 if (i == (ssize_t) argc) 723 ThrowDisplayException(OptionError,"MissingArgument",option); 724 resource_info.background_color=argv[i]; 725 break; 726 } 727 if (LocaleCompare("border",option+1) == 0) 728 { 729 if (*option == '+') 730 break; 731 i++; 732 if (i == (ssize_t) argc) 733 ThrowDisplayException(OptionError,"MissingArgument",option); 734 if (IsGeometry(argv[i]) == MagickFalse) 735 ThrowDisplayInvalidArgumentException(option,argv[i]); 736 break; 737 } 738 if (LocaleCompare("bordercolor",option+1) == 0) 739 { 740 if (*option == '+') 741 break; 742 i++; 743 if (i == (ssize_t) argc) 744 ThrowDisplayException(OptionError,"MissingArgument",option); 745 resource_info.border_color=argv[i]; 746 break; 747 } 748 if (LocaleCompare("borderwidth",option+1) == 0) 749 { 750 resource_info.border_width=0; 751 if (*option == '+') 752 break; 753 i++; 754 if (i == (ssize_t) argc) 755 ThrowDisplayException(OptionError,"MissingArgument",option); 756 if (IsGeometry(argv[i]) == MagickFalse) 757 ThrowDisplayInvalidArgumentException(option,argv[i]); 758 resource_info.border_width=(unsigned int) 759 StringToUnsignedLong(argv[i]); 760 break; 761 } 762 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 763 } 764 case 'c': 765 { 766 if (LocaleCompare("cache",option+1) == 0) 767 { 768 if (*option == '+') 769 break; 770 i++; 771 if (i == (ssize_t) argc) 772 ThrowDisplayException(OptionError,"MissingArgument",option); 773 if (IsGeometry(argv[i]) == MagickFalse) 774 ThrowDisplayInvalidArgumentException(option,argv[i]); 775 break; 776 } 777 if (LocaleCompare("channel",option+1) == 0) 778 { 779 ssize_t 780 channel; 781 782 if (*option == '+') 783 break; 784 i++; 785 if (i == (ssize_t) argc) 786 ThrowDisplayException(OptionError,"MissingArgument",option); 787 channel=ParseChannelOption(argv[i]); 788 if (channel < 0) 789 ThrowDisplayException(OptionError,"UnrecognizedChannelType", 790 argv[i]); 791 break; 792 } 793 if (LocaleCompare("clip",option+1) == 0) 794 break; 795 if (LocaleCompare("clip-path",option+1) == 0) 796 { 797 i++; 798 if (i == (ssize_t) argc) 799 ThrowDisplayException(OptionError,"MissingArgument",option); 800 break; 801 } 802 if (LocaleCompare("coalesce",option+1) == 0) 803 break; 804 if (LocaleCompare("colormap",option+1) == 0) 805 { 806 resource_info.colormap=PrivateColormap; 807 if (*option == '+') 808 break; 809 i++; 810 if (i == (ssize_t) argc) 811 ThrowDisplayException(OptionError,"MissingArgument",option); 812 resource_info.colormap=UndefinedColormap; 813 if (LocaleCompare("private",argv[i]) == 0) 814 resource_info.colormap=PrivateColormap; 815 if (LocaleCompare("shared",argv[i]) == 0) 816 resource_info.colormap=SharedColormap; 817 if (resource_info.colormap == UndefinedColormap) 818 ThrowDisplayException(OptionError,"UnrecognizedColormapType", 819 argv[i]); 820 break; 821 } 822 if (LocaleCompare("colors",option+1) == 0) 823 { 824 quantize_info->number_colors=0; 825 if (*option == '+') 826 break; 827 i++; 828 if (i == (ssize_t) argc) 829 ThrowDisplayException(OptionError,"MissingArgument",option); 830 if (IsGeometry(argv[i]) == MagickFalse) 831 ThrowDisplayInvalidArgumentException(option,argv[i]); 832 quantize_info->number_colors=StringToUnsignedLong(argv[i]); 833 break; 834 } 835 if (LocaleCompare("colorspace",option+1) == 0) 836 { 837 ssize_t 838 colorspace; 839 840 if (*option == '+') 841 break; 842 i++; 843 if (i == (ssize_t) argc) 844 ThrowDisplayException(OptionError,"MissingArgument",option); 845 colorspace=ParseCommandOption(MagickColorspaceOptions, 846 MagickFalse,argv[i]); 847 if (colorspace < 0) 848 ThrowDisplayException(OptionError,"UnrecognizedColorspace", 849 argv[i]); 850 break; 851 } 852 if (LocaleCompare("comment",option+1) == 0) 853 { 854 if (*option == '+') 855 break; 856 i++; 857 if (i == (ssize_t) argc) 858 ThrowDisplayException(OptionError,"MissingArgument",option); 859 break; 860 } 861 if (LocaleCompare("compress",option+1) == 0) 862 { 863 ssize_t 864 compress; 865 866 if (*option == '+') 867 break; 868 i++; 869 if (i == (ssize_t) argc) 870 ThrowDisplayException(OptionError,"MissingArgument",option); 871 compress=ParseCommandOption(MagickCompressOptions,MagickFalse, 872 argv[i]); 873 if (compress < 0) 874 ThrowDisplayException(OptionError,"UnrecognizedImageCompression", 875 argv[i]); 876 break; 877 } 878 if (LocaleCompare("concurrent",option+1) == 0) 879 break; 880 if (LocaleCompare("contrast",option+1) == 0) 881 break; 882 if (LocaleCompare("crop",option+1) == 0) 883 { 884 if (*option == '+') 885 break; 886 i++; 887 if (i == (ssize_t) argc) 888 ThrowDisplayException(OptionError,"MissingArgument",option); 889 if (IsGeometry(argv[i]) == MagickFalse) 890 ThrowDisplayInvalidArgumentException(option,argv[i]); 891 break; 892 } 893 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 894 } 895 case 'd': 896 { 897 if (LocaleCompare("debug",option+1) == 0) 898 { 899 ssize_t 900 event; 901 902 if (*option == '+') 903 break; 904 i++; 905 if (i == (ssize_t) argc) 906 ThrowDisplayException(OptionError,"MissingArgument",option); 907 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); 908 if (event < 0) 909 ThrowDisplayException(OptionError,"UnrecognizedEventType", 910 argv[i]); 911 (void) SetLogEventMask(argv[i]); 912 break; 913 } 914 if (LocaleCompare("decipher",option+1) == 0) 915 { 916 if (*option == '+') 917 break; 918 i++; 919 if (i == (ssize_t) argc) 920 ThrowDisplayException(OptionError,"MissingArgument",option); 921 break; 922 } 923 if (LocaleCompare("define",option+1) == 0) 924 { 925 i++; 926 if (i == (ssize_t) argc) 927 ThrowDisplayException(OptionError,"MissingArgument",option); 928 if (*option == '+') 929 { 930 const char 931 *define; 932 933 define=GetImageOption(image_info,argv[i]); 934 if (define == (const char *) NULL) 935 ThrowDisplayException(OptionError,"NoSuchOption",argv[i]); 936 break; 937 } 938 break; 939 } 940 if (LocaleCompare("delay",option+1) == 0) 941 { 942 if (*option == '+') 943 break; 944 i++; 945 if (i == (ssize_t) argc) 946 ThrowDisplayException(OptionError,"MissingArgument",option); 947 if (IsGeometry(argv[i]) == MagickFalse) 948 ThrowDisplayInvalidArgumentException(option,argv[i]); 949 break; 950 } 951 if (LocaleCompare("density",option+1) == 0) 952 { 953 if (*option == '+') 954 break; 955 i++; 956 if (i == (ssize_t) argc) 957 ThrowDisplayException(OptionError,"MissingArgument",option); 958 if (IsGeometry(argv[i]) == MagickFalse) 959 ThrowDisplayInvalidArgumentException(option,argv[i]); 960 break; 961 } 962 if (LocaleCompare("depth",option+1) == 0) 963 { 964 if (*option == '+') 965 break; 966 i++; 967 if (i == (ssize_t) argc) 968 ThrowDisplayException(OptionError,"MissingArgument",option); 969 if (IsGeometry(argv[i]) == MagickFalse) 970 ThrowDisplayInvalidArgumentException(option,argv[i]); 971 break; 972 } 973 if (LocaleCompare("deskew",option+1) == 0) 974 { 975 if (*option == '+') 976 break; 977 i++; 978 if (i == (ssize_t) argc) 979 ThrowDisplayException(OptionError,"MissingArgument",option); 980 if (IsGeometry(argv[i]) == MagickFalse) 981 ThrowDisplayInvalidArgumentException(option,argv[i]); 982 break; 983 } 984 if (LocaleCompare("despeckle",option+1) == 0) 985 break; 986 if (LocaleCompare("display",option+1) == 0) 987 { 988 if (*option == '+') 989 break; 990 i++; 991 if (i == (ssize_t) argc) 992 ThrowDisplayException(OptionError,"MissingArgument",option); 993 break; 994 } 995 if (LocaleCompare("dispose",option+1) == 0) 996 { 997 ssize_t 998 dispose; 999 1000 if (*option == '+') 1001 break; 1002 i++; 1003 if (i == (ssize_t) argc) 1004 ThrowDisplayException(OptionError,"MissingArgument",option); 1005 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); 1006 if (dispose < 0) 1007 ThrowDisplayException(OptionError,"UnrecognizedDisposeMethod", 1008 argv[i]); 1009 break; 1010 } 1011 if (LocaleCompare("dither",option+1) == 0) 1012 { 1013 ssize_t 1014 method; 1015 1016 quantize_info->dither_method=NoDitherMethod; 1017 if (*option == '+') 1018 break; 1019 i++; 1020 if (i == (ssize_t) argc) 1021 ThrowDisplayException(OptionError,"MissingArgument",option); 1022 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); 1023 if (method < 0) 1024 ThrowDisplayException(OptionError,"UnrecognizedDitherMethod", 1025 argv[i]); 1026 quantize_info->dither_method=(DitherMethod) method; 1027 break; 1028 } 1029 if (LocaleCompare("duration",option+1) == 0) 1030 { 1031 if (*option == '+') 1032 break; 1033 i++; 1034 if (i == (ssize_t) argc) 1035 ThrowDisplayException(OptionError,"MissingArgument",option); 1036 if (IsGeometry(argv[i]) == MagickFalse) 1037 ThrowDisplayInvalidArgumentException(option,argv[i]); 1038 break; 1039 } 1040 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1041 } 1042 case 'e': 1043 { 1044 if (LocaleCompare("edge",option+1) == 0) 1045 { 1046 if (*option == '+') 1047 break; 1048 i++; 1049 if (i == (ssize_t) argc) 1050 ThrowDisplayException(OptionError,"MissingArgument",option); 1051 if (IsGeometry(argv[i]) == MagickFalse) 1052 ThrowDisplayInvalidArgumentException(option,argv[i]); 1053 break; 1054 } 1055 if (LocaleCompare("endian",option+1) == 0) 1056 { 1057 ssize_t 1058 endian; 1059 1060 if (*option == '+') 1061 break; 1062 i++; 1063 if (i == (ssize_t) argc) 1064 ThrowDisplayException(OptionError,"MissingArgument",option); 1065 endian=ParseCommandOption(MagickEndianOptions,MagickFalse, 1066 argv[i]); 1067 if (endian < 0) 1068 ThrowDisplayException(OptionError,"UnrecognizedEndianType", 1069 argv[i]); 1070 break; 1071 } 1072 if (LocaleCompare("enhance",option+1) == 0) 1073 break; 1074 if (LocaleCompare("equalize",option+1) == 0) 1075 break; 1076 if (LocaleCompare("extract",option+1) == 0) 1077 { 1078 if (*option == '+') 1079 break; 1080 i++; 1081 if (i == (ssize_t) argc) 1082 ThrowDisplayException(OptionError,"MissingArgument",option); 1083 if (IsGeometry(argv[i]) == MagickFalse) 1084 ThrowDisplayInvalidArgumentException(option,argv[i]); 1085 break; 1086 } 1087 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1088 } 1089 case 'f': 1090 { 1091 if (LocaleCompare("filter",option+1) == 0) 1092 { 1093 ssize_t 1094 filter; 1095 1096 if (*option == '+') 1097 break; 1098 i++; 1099 if (i == (ssize_t) argc) 1100 ThrowDisplayException(OptionError,"MissingArgument",option); 1101 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); 1102 if (filter < 0) 1103 ThrowDisplayException(OptionError,"UnrecognizedImageFilter", 1104 argv[i]); 1105 break; 1106 } 1107 if (LocaleCompare("flatten",option+1) == 0) 1108 break; 1109 if (LocaleCompare("flip",option+1) == 0) 1110 break; 1111 if (LocaleCompare("flop",option+1) == 0) 1112 break; 1113 if (LocaleCompare("font",option+1) == 0) 1114 { 1115 if (*option == '+') 1116 break; 1117 i++; 1118 if (i == (ssize_t) argc) 1119 ThrowDisplayException(OptionError,"MissingArgument",option); 1120 resource_info.font=XGetResourceClass(resource_database, 1121 GetClientName(),"font",argv[i]); 1122 break; 1123 } 1124 if (LocaleCompare("foreground",option+1) == 0) 1125 { 1126 if (*option == '+') 1127 break; 1128 i++; 1129 if (i == (ssize_t) argc) 1130 ThrowDisplayException(OptionError,"MissingArgument",option); 1131 resource_info.foreground_color=argv[i]; 1132 break; 1133 } 1134 if (LocaleCompare("format",option+1) == 0) 1135 { 1136 if (*option == '+') 1137 break; 1138 i++; 1139 if (i == (ssize_t) argc) 1140 ThrowDisplayException(OptionError,"MissingArgument",option); 1141 break; 1142 } 1143 if (LocaleCompare("frame",option+1) == 0) 1144 { 1145 if (*option == '+') 1146 break; 1147 i++; 1148 if (i == (ssize_t) argc) 1149 ThrowDisplayException(OptionError,"MissingArgument",option); 1150 if (IsGeometry(argv[i]) == MagickFalse) 1151 ThrowDisplayInvalidArgumentException(option,argv[i]); 1152 break; 1153 } 1154 if (LocaleCompare("fuzz",option+1) == 0) 1155 { 1156 if (*option == '+') 1157 break; 1158 i++; 1159 if (i == (ssize_t) argc) 1160 ThrowDisplayException(OptionError,"MissingArgument",option); 1161 if (IsGeometry(argv[i]) == MagickFalse) 1162 ThrowDisplayInvalidArgumentException(option,argv[i]); 1163 break; 1164 } 1165 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1166 } 1167 case 'g': 1168 { 1169 if (LocaleCompare("gamma",option+1) == 0) 1170 { 1171 i++; 1172 if (i == (ssize_t) argc) 1173 ThrowDisplayException(OptionError,"MissingArgument",option); 1174 if (IsGeometry(argv[i]) == MagickFalse) 1175 ThrowDisplayInvalidArgumentException(option,argv[i]); 1176 break; 1177 } 1178 if (LocaleCompare("geometry",option+1) == 0) 1179 { 1180 resource_info.image_geometry=(char *) NULL; 1181 if (*option == '+') 1182 break; 1183 (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent); 1184 i++; 1185 if (i == (ssize_t) argc) 1186 ThrowDisplayException(OptionError,"MissingArgument",option); 1187 if (IsGeometry(argv[i]) == MagickFalse) 1188 ThrowDisplayInvalidArgumentException(option,argv[i]); 1189 resource_info.image_geometry=ConstantString(argv[i]); 1190 break; 1191 } 1192 if (LocaleCompare("gravity",option+1) == 0) 1193 { 1194 ssize_t 1195 gravity; 1196 1197 if (*option == '+') 1198 break; 1199 i++; 1200 if (i == (ssize_t) argc) 1201 ThrowDisplayException(OptionError,"MissingArgument",option); 1202 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse, 1203 argv[i]); 1204 if (gravity < 0) 1205 ThrowDisplayException(OptionError,"UnrecognizedGravityType", 1206 argv[i]); 1207 break; 1208 } 1209 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1210 } 1211 case 'h': 1212 { 1213 if ((LocaleCompare("help",option+1) == 0) || 1214 (LocaleCompare("-help",option+1) == 0)) 1215 break; 1216 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1217 } 1218 case 'i': 1219 { 1220 if (LocaleCompare("identify",option+1) == 0) 1221 break; 1222 if (LocaleCompare("iconGeometry",option+1) == 0) 1223 { 1224 resource_info.icon_geometry=(char *) NULL; 1225 if (*option == '+') 1226 break; 1227 i++; 1228 if (i == (ssize_t) argc) 1229 ThrowDisplayException(OptionError,"MissingArgument",option); 1230 if (IsGeometry(argv[i]) == MagickFalse) 1231 ThrowDisplayInvalidArgumentException(option,argv[i]); 1232 resource_info.icon_geometry=argv[i]; 1233 break; 1234 } 1235 if (LocaleCompare("iconic",option+1) == 0) 1236 { 1237 resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse; 1238 break; 1239 } 1240 if (LocaleCompare("immutable",option+1) == 0) 1241 { 1242 resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse; 1243 break; 1244 } 1245 if (LocaleCompare("interlace",option+1) == 0) 1246 { 1247 ssize_t 1248 interlace; 1249 1250 if (*option == '+') 1251 break; 1252 i++; 1253 if (i == (ssize_t) argc) 1254 ThrowDisplayException(OptionError,"MissingArgument",option); 1255 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, 1256 argv[i]); 1257 if (interlace < 0) 1258 ThrowDisplayException(OptionError,"UnrecognizedInterlaceType", 1259 argv[i]); 1260 break; 1261 } 1262 if (LocaleCompare("interpolate",option+1) == 0) 1263 { 1264 ssize_t 1265 interpolate; 1266 1267 if (*option == '+') 1268 break; 1269 i++; 1270 if (i == (ssize_t) argc) 1271 ThrowDisplayException(OptionError,"MissingArgument",option); 1272 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, 1273 argv[i]); 1274 if (interpolate < 0) 1275 ThrowDisplayException(OptionError,"UnrecognizedInterpolateMethod", 1276 argv[i]); 1277 break; 1278 } 1279 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1280 } 1281 case 'l': 1282 { 1283 if (LocaleCompare("label",option+1) == 0) 1284 { 1285 if (*option == '+') 1286 break; 1287 i++; 1288 if (i == (ssize_t) argc) 1289 ThrowDisplayException(OptionError,"MissingArgument",option); 1290 break; 1291 } 1292 if (LocaleCompare("limit",option+1) == 0) 1293 { 1294 char 1295 *p; 1296 1297 double 1298 value; 1299 1300 ssize_t 1301 resource; 1302 1303 if (*option == '+') 1304 break; 1305 i++; 1306 if (i == (ssize_t) argc) 1307 ThrowDisplayException(OptionError,"MissingArgument",option); 1308 resource=ParseCommandOption(MagickResourceOptions,MagickFalse, 1309 argv[i]); 1310 if (resource < 0) 1311 ThrowDisplayException(OptionError,"UnrecognizedResourceType", 1312 argv[i]); 1313 i++; 1314 if (i == (ssize_t) argc) 1315 ThrowDisplayException(OptionError,"MissingArgument",option); 1316 value=StringToDouble(argv[i],&p); 1317 (void) value; 1318 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) 1319 ThrowDisplayInvalidArgumentException(option,argv[i]); 1320 break; 1321 } 1322 if (LocaleCompare("list",option+1) == 0) 1323 { 1324 ssize_t 1325 list; 1326 1327 if (*option == '+') 1328 break; 1329 i++; 1330 if (i == (ssize_t) argc) 1331 ThrowDisplayException(OptionError,"MissingArgument",option); 1332 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); 1333 if (list < 0) 1334 ThrowDisplayException(OptionError,"UnrecognizedListType",argv[i]); 1335 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) 1336 argv+j,exception); 1337 DestroyDisplay(); 1338 return(status == 0 ? MagickFalse : MagickTrue); 1339 } 1340 if (LocaleCompare("log",option+1) == 0) 1341 { 1342 if (*option == '+') 1343 break; 1344 i++; 1345 if ((i == (ssize_t) argc) || 1346 (strchr(argv[i],'%') == (char *) NULL)) 1347 ThrowDisplayException(OptionError,"MissingArgument",option); 1348 break; 1349 } 1350 if (LocaleCompare("loop",option+1) == 0) 1351 { 1352 if (*option == '+') 1353 break; 1354 i++; 1355 if (i == (ssize_t) argc) 1356 ThrowDisplayException(OptionError,"MissingArgument",option); 1357 if (IsGeometry(argv[i]) == MagickFalse) 1358 ThrowDisplayInvalidArgumentException(option,argv[i]); 1359 iterations=StringToUnsignedLong(argv[i]); 1360 break; 1361 } 1362 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1363 } 1364 case 'm': 1365 { 1366 if (LocaleCompare("magnify",option+1) == 0) 1367 { 1368 resource_info.magnify=2; 1369 if (*option == '+') 1370 break; 1371 i++; 1372 if (i == (ssize_t) argc) 1373 ThrowDisplayException(OptionError,"MissingArgument",option); 1374 if (IsGeometry(argv[i]) == MagickFalse) 1375 ThrowDisplayInvalidArgumentException(option,argv[i]); 1376 resource_info.magnify=(unsigned int) StringToUnsignedLong(argv[i]); 1377 break; 1378 } 1379 if (LocaleCompare("map",option+1) == 0) 1380 { 1381 resource_info.map_type=(char *) NULL; 1382 if (*option == '+') 1383 break; 1384 (void) strcpy(argv[i]+1,"san"); 1385 i++; 1386 if (i == (ssize_t) argc) 1387 ThrowDisplayException(OptionError,"MissingArgument",option); 1388 resource_info.map_type=argv[i]; 1389 break; 1390 } 1391 if (LocaleCompare("matte",option+1) == 0) 1392 break; 1393 if (LocaleCompare("mattecolor",option+1) == 0) 1394 { 1395 if (*option == '+') 1396 break; 1397 i++; 1398 if (i == (ssize_t) argc) 1399 ThrowDisplayException(OptionError,"MissingArgument",option); 1400 resource_info.matte_color=argv[i]; 1401 break; 1402 } 1403 if (LocaleCompare("monitor",option+1) == 0) 1404 break; 1405 if (LocaleCompare("monochrome",option+1) == 0) 1406 { 1407 if (*option == '+') 1408 break; 1409 quantize_info->number_colors=2; 1410 quantize_info->colorspace=GRAYColorspace; 1411 break; 1412 } 1413 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1414 } 1415 case 'n': 1416 { 1417 if (LocaleCompare("name",option+1) == 0) 1418 { 1419 resource_info.name=(char *) NULL; 1420 if (*option == '+') 1421 break; 1422 i++; 1423 if (i == (ssize_t) argc) 1424 ThrowDisplayException(OptionError,"MissingArgument",option); 1425 resource_info.name=ConstantString(argv[i]); 1426 break; 1427 } 1428 if (LocaleCompare("negate",option+1) == 0) 1429 break; 1430 if (LocaleCompare("noop",option+1) == 0) 1431 break; 1432 if (LocaleCompare("normalize",option+1) == 0) 1433 break; 1434 if (LocaleCompare("nostdin",option+1) == 0) 1435 break; 1436 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1437 } 1438 case 'p': 1439 { 1440 if (LocaleCompare("page",option+1) == 0) 1441 { 1442 resource_info.image_geometry=(char *) NULL; 1443 if (*option == '+') 1444 break; 1445 i++; 1446 if (i == (ssize_t) argc) 1447 ThrowDisplayException(OptionError,"MissingArgument",option); 1448 resource_info.image_geometry=ConstantString(argv[i]); 1449 break; 1450 } 1451 if (LocaleCompare("profile",option+1) == 0) 1452 { 1453 i++; 1454 if (i == (ssize_t) argc) 1455 ThrowDisplayException(OptionError,"MissingArgument",option); 1456 break; 1457 } 1458 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1459 } 1460 case 'q': 1461 { 1462 if (LocaleCompare("quality",option+1) == 0) 1463 { 1464 if (*option == '+') 1465 break; 1466 i++; 1467 if (i == (ssize_t) argc) 1468 ThrowDisplayException(OptionError,"MissingArgument",option); 1469 if (IsGeometry(argv[i]) == MagickFalse) 1470 ThrowDisplayInvalidArgumentException(option,argv[i]); 1471 break; 1472 } 1473 if (LocaleCompare("quantize",option+1) == 0) 1474 { 1475 ssize_t 1476 colorspace; 1477 1478 if (*option == '+') 1479 break; 1480 i++; 1481 if (i == (ssize_t) argc) 1482 ThrowDisplayException(OptionError,"MissingArgument",option); 1483 colorspace=ParseCommandOption(MagickColorspaceOptions, 1484 MagickFalse,argv[i]); 1485 if (colorspace < 0) 1486 ThrowDisplayException(OptionError,"UnrecognizedColorspace", 1487 argv[i]); 1488 break; 1489 } 1490 if (LocaleCompare("quiet",option+1) == 0) 1491 break; 1492 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1493 } 1494 case 'r': 1495 { 1496 if (LocaleCompare("raise",option+1) == 0) 1497 { 1498 i++; 1499 if (i == (ssize_t) argc) 1500 ThrowDisplayException(OptionError,"MissingArgument",option); 1501 if (IsGeometry(argv[i]) == MagickFalse) 1502 ThrowDisplayInvalidArgumentException(option,argv[i]); 1503 break; 1504 } 1505 if (LocaleCompare("regard-warnings",option+1) == 0) 1506 break; 1507 if (LocaleCompare("remote",option+1) == 0) 1508 { 1509 i++; 1510 if (i == (ssize_t) argc) 1511 ThrowDisplayException(OptionError,"MissingArgument",option); 1512 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0) 1513 return(MagickFalse); 1514 i--; 1515 break; 1516 } 1517 if (LocaleCompare("repage",option+1) == 0) 1518 { 1519 if (*option == '+') 1520 break; 1521 i++; 1522 if (i == (ssize_t) argc) 1523 ThrowDisplayException(OptionError,"MissingArgument",option); 1524 if (IsGeometry(argv[i]) == MagickFalse) 1525 ThrowDisplayInvalidArgumentException(option,argv[i]); 1526 break; 1527 } 1528 if (LocaleCompare("resample",option+1) == 0) 1529 { 1530 if (*option == '+') 1531 break; 1532 i++; 1533 if (i == (ssize_t) argc) 1534 ThrowDisplayException(OptionError,"MissingArgument",option); 1535 if (IsGeometry(argv[i]) == MagickFalse) 1536 ThrowDisplayInvalidArgumentException(option,argv[i]); 1537 break; 1538 } 1539 if (LocaleCompare("resize",option+1) == 0) 1540 { 1541 if (*option == '+') 1542 break; 1543 i++; 1544 if (i == (ssize_t) argc) 1545 ThrowDisplayException(OptionError,"MissingArgument",option); 1546 if (IsGeometry(argv[i]) == MagickFalse) 1547 ThrowDisplayInvalidArgumentException(option,argv[i]); 1548 break; 1549 } 1550 if (LocaleNCompare("respect-parentheses",option+1,17) == 0) 1551 { 1552 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; 1553 break; 1554 } 1555 if (LocaleCompare("roll",option+1) == 0) 1556 { 1557 if (*option == '+') 1558 break; 1559 i++; 1560 if (i == (ssize_t) argc) 1561 ThrowDisplayException(OptionError,"MissingArgument",option); 1562 if (IsGeometry(argv[i]) == MagickFalse) 1563 ThrowDisplayInvalidArgumentException(option,argv[i]); 1564 break; 1565 } 1566 if (LocaleCompare("rotate",option+1) == 0) 1567 { 1568 i++; 1569 if (i == (ssize_t) argc) 1570 ThrowDisplayException(OptionError,"MissingArgument",option); 1571 if (IsGeometry(argv[i]) == MagickFalse) 1572 ThrowDisplayInvalidArgumentException(option,argv[i]); 1573 break; 1574 } 1575 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1576 } 1577 case 's': 1578 { 1579 if (LocaleCompare("sample",option+1) == 0) 1580 { 1581 if (*option == '+') 1582 break; 1583 i++; 1584 if (i == (ssize_t) argc) 1585 ThrowDisplayException(OptionError,"MissingArgument",option); 1586 if (IsGeometry(argv[i]) == MagickFalse) 1587 ThrowDisplayInvalidArgumentException(option,argv[i]); 1588 break; 1589 } 1590 if (LocaleCompare("sampling-factor",option+1) == 0) 1591 { 1592 if (*option == '+') 1593 break; 1594 i++; 1595 if (i == (ssize_t) argc) 1596 ThrowDisplayException(OptionError,"MissingArgument",option); 1597 if (IsGeometry(argv[i]) == MagickFalse) 1598 ThrowDisplayInvalidArgumentException(option,argv[i]); 1599 break; 1600 } 1601 if (LocaleCompare("scenes",option+1) == 0) 1602 { 1603 if (*option == '+') 1604 break; 1605 i++; 1606 if (i == (ssize_t) argc) 1607 ThrowDisplayException(OptionError,"MissingArgument",option); 1608 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse) 1609 ThrowDisplayInvalidArgumentException(option,argv[i]); 1610 break; 1611 } 1612 if (LocaleCompare("seed",option+1) == 0) 1613 { 1614 if (*option == '+') 1615 break; 1616 i++; 1617 if (i == (ssize_t) argc) 1618 ThrowDisplayException(OptionError,"MissingArgument",option); 1619 if (IsGeometry(argv[i]) == MagickFalse) 1620 ThrowDisplayInvalidArgumentException(option,argv[i]); 1621 break; 1622 } 1623 if (LocaleCompare("segment",option+1) == 0) 1624 { 1625 if (*option == '+') 1626 break; 1627 i++; 1628 if (i == (ssize_t) argc) 1629 ThrowDisplayException(OptionError,"MissingArgument",option); 1630 if (IsGeometry(argv[i]) == MagickFalse) 1631 ThrowDisplayInvalidArgumentException(option,argv[i]); 1632 break; 1633 } 1634 if (LocaleCompare("set",option+1) == 0) 1635 { 1636 i++; 1637 if (i == (ssize_t) argc) 1638 ThrowDisplayException(OptionError,"MissingArgument",option); 1639 if (*option == '+') 1640 break; 1641 i++; 1642 if (i == (ssize_t) argc) 1643 ThrowDisplayException(OptionError,"MissingArgument",option); 1644 break; 1645 } 1646 if (LocaleCompare("sharpen",option+1) == 0) 1647 { 1648 if (*option == '+') 1649 break; 1650 i++; 1651 if (i == (ssize_t) argc) 1652 ThrowDisplayException(OptionError,"MissingArgument",option); 1653 if (IsGeometry(argv[i]) == MagickFalse) 1654 ThrowDisplayInvalidArgumentException(option,argv[i]); 1655 break; 1656 } 1657 if (LocaleCompare("shared-memory",option+1) == 0) 1658 { 1659 resource_info.use_shared_memory= (*option == '-') ? MagickTrue : 1660 MagickFalse; 1661 break; 1662 } 1663 if (LocaleCompare("size",option+1) == 0) 1664 { 1665 if (*option == '+') 1666 break; 1667 i++; 1668 if (i == (ssize_t) argc) 1669 ThrowDisplayException(OptionError,"MissingArgument",option); 1670 if (IsGeometry(argv[i]) == MagickFalse) 1671 ThrowDisplayInvalidArgumentException(option,argv[i]); 1672 break; 1673 } 1674 if (LocaleCompare("strip",option+1) == 0) 1675 break; 1676 if (LocaleCompare("support",option+1) == 0) 1677 { 1678 i++; /* deprecated */ 1679 break; 1680 } 1681 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1682 } 1683 case 't': 1684 { 1685 if (LocaleCompare("text-font",option+1) == 0) 1686 { 1687 resource_info.text_font=(char *) NULL; 1688 if (*option == '+') 1689 break; 1690 i++; 1691 if (i == (ssize_t) argc) 1692 ThrowDisplayException(OptionError,"MissingArgument",option); 1693 resource_info.text_font=XGetResourceClass(resource_database, 1694 GetClientName(),"font",argv[i]); 1695 break; 1696 } 1697 if (LocaleCompare("texture",option+1) == 0) 1698 { 1699 if (*option == '+') 1700 break; 1701 i++; 1702 if (i == (ssize_t) argc) 1703 ThrowDisplayException(OptionError,"MissingArgument",option); 1704 break; 1705 } 1706 if (LocaleCompare("threshold",option+1) == 0) 1707 { 1708 if (*option == '+') 1709 break; 1710 i++; 1711 if (i == (ssize_t) argc) 1712 ThrowDisplayException(OptionError,"MissingArgument",option); 1713 if (IsGeometry(argv[i]) == MagickFalse) 1714 ThrowDisplayInvalidArgumentException(option,argv[i]); 1715 break; 1716 } 1717 if (LocaleCompare("thumbnail",option+1) == 0) 1718 { 1719 if (*option == '+') 1720 break; 1721 i++; 1722 if (i == (ssize_t) argc) 1723 ThrowDisplayException(OptionError,"MissingArgument",option); 1724 if (IsGeometry(argv[i]) == MagickFalse) 1725 ThrowDisplayInvalidArgumentException(option,argv[i]); 1726 break; 1727 } 1728 if (LocaleCompare("title",option+1) == 0) 1729 { 1730 resource_info.title=(char *) NULL; 1731 if (*option == '+') 1732 break; 1733 i++; 1734 if (i == (ssize_t) argc) 1735 ThrowDisplayException(OptionError,"MissingArgument",option); 1736 resource_info.title=argv[i]; 1737 break; 1738 } 1739 if (LocaleCompare("transparent-color",option+1) == 0) 1740 { 1741 if (*option == '+') 1742 break; 1743 i++; 1744 if (i == (ssize_t) argc) 1745 ThrowDisplayException(OptionError,"MissingArgument",option); 1746 break; 1747 } 1748 if (LocaleCompare("treedepth",option+1) == 0) 1749 { 1750 quantize_info->tree_depth=0; 1751 if (*option == '+') 1752 break; 1753 i++; 1754 if (i == (ssize_t) argc) 1755 ThrowDisplayException(OptionError,"MissingArgument",option); 1756 if (IsGeometry(argv[i]) == MagickFalse) 1757 ThrowDisplayInvalidArgumentException(option,argv[i]); 1758 quantize_info->tree_depth=StringToUnsignedLong(argv[i]); 1759 break; 1760 } 1761 if (LocaleCompare("trim",option+1) == 0) 1762 break; 1763 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1764 } 1765 case 'u': 1766 { 1767 if (LocaleCompare("update",option+1) == 0) 1768 { 1769 resource_info.update=(unsigned int) (*option == '-'); 1770 if (*option == '+') 1771 break; 1772 i++; 1773 if (i == (ssize_t) argc) 1774 ThrowDisplayException(OptionError,"MissingArgument",option); 1775 if (IsGeometry(argv[i]) == MagickFalse) 1776 ThrowDisplayInvalidArgumentException(option,argv[i]); 1777 resource_info.update=(unsigned int) StringToUnsignedLong(argv[i]); 1778 break; 1779 } 1780 if (LocaleCompare("use-pixmap",option+1) == 0) 1781 { 1782 resource_info.use_pixmap=(*option == '-') ? MagickTrue : 1783 MagickFalse; 1784 break; 1785 } 1786 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1787 } 1788 case 'v': 1789 { 1790 if (LocaleCompare("verbose",option+1) == 0) 1791 break; 1792 if ((LocaleCompare("version",option+1) == 0) || 1793 (LocaleCompare("-version",option+1) == 0)) 1794 { 1795 ListMagickVersion(stdout); 1796 break; 1797 } 1798 if (LocaleCompare("visual",option+1) == 0) 1799 { 1800 resource_info.visual_type=(char *) NULL; 1801 if (*option == '+') 1802 break; 1803 i++; 1804 if (i == (ssize_t) argc) 1805 ThrowDisplayException(OptionError,"MissingArgument",option); 1806 resource_info.visual_type=argv[i]; 1807 break; 1808 } 1809 if (LocaleCompare("virtual-pixel",option+1) == 0) 1810 { 1811 ssize_t 1812 method; 1813 1814 if (*option == '+') 1815 break; 1816 i++; 1817 if (i == (ssize_t) argc) 1818 ThrowDisplayException(OptionError,"MissingArgument",option); 1819 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, 1820 argv[i]); 1821 if (method < 0) 1822 ThrowDisplayException(OptionError, 1823 "UnrecognizedVirtualPixelMethod",argv[i]); 1824 break; 1825 } 1826 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1827 } 1828 case 'w': 1829 { 1830 if (LocaleCompare("window",option+1) == 0) 1831 { 1832 resource_info.window_id=(char *) NULL; 1833 if (*option == '+') 1834 break; 1835 i++; 1836 if (i == (ssize_t) argc) 1837 ThrowDisplayException(OptionError,"MissingArgument",option); 1838 resource_info.window_id=argv[i]; 1839 break; 1840 } 1841 if (LocaleCompare("window-group",option+1) == 0) 1842 { 1843 resource_info.window_group=(char *) NULL; 1844 if (*option == '+') 1845 break; 1846 i++; 1847 if (i == (ssize_t) argc) 1848 ThrowDisplayException(OptionError,"MissingArgument",option); 1849 if (StringToDouble(argv[i],(char **) NULL) != 0) 1850 resource_info.window_group=argv[i]; 1851 break; 1852 } 1853 if (LocaleCompare("write",option+1) == 0) 1854 { 1855 resource_info.write_filename=(char *) NULL; 1856 if (*option == '+') 1857 break; 1858 i++; 1859 if (i == (ssize_t) argc) 1860 ThrowDisplayException(OptionError,"MissingArgument",option); 1861 resource_info.write_filename=argv[i]; 1862 if (IsPathAccessible(resource_info.write_filename) != MagickFalse) 1863 { 1864 char 1865 answer[2], 1866 *p; 1867 1868 (void) FormatLocaleFile(stderr,"Overwrite %s? ", 1869 resource_info.write_filename); 1870 p=fgets(answer,(int) sizeof(answer),stdin); 1871 (void) p; 1872 if (((*answer != 'y') && (*answer != 'Y'))) 1873 return(MagickFalse); 1874 } 1875 break; 1876 } 1877 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1878 } 1879 case '?': 1880 break; 1881 default: 1882 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 1883 } 1884 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & 1885 FireOptionFlag) == 0 ? MagickFalse : MagickTrue; 1886 if (fire != MagickFalse) 1887 FireImageStack(MagickFalse,MagickTrue,MagickTrue); 1888 } 1889 if (k != 0) 1890 ThrowDisplayException(OptionError,"UnbalancedParenthesis",argv[i]); 1891 if (state & RetainColorsState) 1892 { 1893 XRetainWindowColors(display,XRootWindow(display,XDefaultScreen(display))); 1894 (void) XSync(display,MagickFalse); 1895 } 1896 DestroyDisplay(); 1897 return(status != 0 ? MagickTrue : MagickFalse); 1898 #else 1899 wand_unreferenced(argc); 1900 wand_unreferenced(argv); 1901 wand_unreferenced(metadata); 1902 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError, 1903 "DelegateLibrarySupportNotBuiltIn","'%s' (X11)",image_info->filename); 1904 return(DisplayUsage()); 1905 #endif 1906 } 1907