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