|
MagickWand
6.7.5
|
00001 /* 00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00003 % % 00004 % % 00005 % % 00006 % DDDD IIIII SSSSS PPPP L AAA Y Y % 00007 % D D I SS P P L A A Y Y % 00008 % D D I SSS PPPP L AAAAA Y % 00009 % D D I SS P L A A Y % 00010 % DDDD IIIII SSSSS P LLLLL A A Y % 00011 % % 00012 % % 00013 % Methods to Interactively Display and Edit an Image % 00014 % % 00015 % Software Design % 00016 % John Cristy % 00017 % July 1992 % 00018 % % 00019 % % 00020 % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization % 00021 % dedicated to making software imaging solutions freely available. % 00022 % % 00023 % You may not use this file except in compliance with the License. You may % 00024 % obtain a copy of the License at % 00025 % % 00026 % http://www.imagemagick.org/script/license.php % 00027 % % 00028 % Unless required by applicable law or agreed to in writing, software % 00029 % distributed under the License is distributed on an "AS IS" BASIS, % 00030 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % 00031 % See the License for the specific language governing permissions and % 00032 % limitations under the License. % 00033 % % 00034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00035 % 00036 % Use the display program to display an image or image sequence on any X 00037 % server. 00038 % 00039 */ 00040 00041 /* 00042 Include declarations. 00043 */ 00044 #include "MagickWand/studio.h" 00045 #include "MagickWand/MagickWand.h" 00046 #include "MagickWand/mogrify-private.h" 00047 #include "MagickCore/display-private.h" 00048 #include "MagickCore/nt-base-private.h" 00049 #include "MagickCore/string-private.h" 00050 #include "MagickCore/xwindow-private.h" 00051 00052 /* 00053 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00054 % % 00055 % % 00056 % % 00057 + D i s p l a y I m a g e C o m m a n d % 00058 % % 00059 % % 00060 % % 00061 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00062 % 00063 % DisplayImageCommand() displays a sequence of images on any workstation 00064 % display running an X server. Display first determines the hardware 00065 % capabilities of the workstation. If the number of unique colors in an image 00066 % is less than or equal to the number the workstation can support, the image 00067 % is displayed in an X window. Otherwise the number of colors in the image is 00068 % first reduced to match the color resolution of the workstation before it is 00069 % displayed. 00070 % 00071 % This means that a continuous-tone 24 bits/pixel image can display on a 8 00072 % bit pseudo-color device or monochrome device. In most instances the reduced 00073 % color image closely resembles the original. Alternatively, a monochrome or 00074 % pseudo-color image sequence can display on a continuous-tone 24 bits/pixels 00075 % device. 00076 % 00077 % The format of the DisplayImageCommand method is: 00078 % 00079 % MagickBooleanType DisplayImageCommand(ImageInfo *image_info,int argc, 00080 % char **argv,char **metadata,ExceptionInfo *exception) 00081 % 00082 % A description of each parameter follows: 00083 % 00084 % o image_info: the image info. 00085 % 00086 % o argc: the number of elements in the argument vector. 00087 % 00088 % o argv: A text array containing the command line arguments. 00089 % 00090 % o metadata: any metadata is returned here. 00091 % 00092 % o exception: return any errors or warnings in this structure. 00093 % 00094 */ 00095 00096 static MagickBooleanType DisplayUsage(void) 00097 { 00098 const char 00099 **p; 00100 00101 static const char 00102 *buttons[]= 00103 { 00104 "1 press to map or unmap the Command widget", 00105 "2 press and drag to magnify a region of an image", 00106 "3 press to load an image from a visual image directory", 00107 (char *) NULL 00108 }, 00109 *miscellaneous[]= 00110 { 00111 "-debug events display copious debugging information", 00112 "-help print program options", 00113 "-list type print a list of supported option arguments", 00114 "-log format format of debugging information", 00115 "-version print version information", 00116 (char *) NULL 00117 }, 00118 *operators[]= 00119 { 00120 "-auto-orient automagically orient image", 00121 "-border geometry surround image with a border of color", 00122 "-clip clip along the first path from the 8BIM profile", 00123 "-clip-path id clip along a named path from the 8BIM profile", 00124 "-colors value preferred number of colors in the image", 00125 "-contrast enhance or reduce the image contrast", 00126 "-crop geometry preferred size and location of the cropped image", 00127 "-decipher filename convert cipher pixels to plain pixels", 00128 "-deskew threshold straighten an image", 00129 "-despeckle reduce the speckles within an image", 00130 "-edge factor apply a filter to detect edges in the image", 00131 "-enhance apply a digital filter to enhance a noisy image", 00132 "-equalize perform histogram equalization to an image", 00133 "-extract geometry extract area from image", 00134 "-flip flip image in the vertical direction", 00135 "-flop flop image in the horizontal direction", 00136 "-frame geometry surround image with an ornamental border", 00137 "-fuzz distance colors within this distance are considered equal", 00138 "-gamma value level of gamma correction", 00139 "-monochrome transform image to black and white", 00140 "-negate replace every pixel with its complementary color", 00141 "-normalize transform image to span the full range of colors", 00142 "-raise value lighten/darken image edges to create a 3-D effect", 00143 "-resample geometry change the resolution of an image", 00144 "-resize geometry resize the image", 00145 "-roll geometry roll an image vertically or horizontally", 00146 "-rotate degrees apply Paeth rotation to the image", 00147 "-sample geometry scale image with pixel sampling", 00148 "-segment value segment an image", 00149 "-sharpen geometry sharpen the image", 00150 "-strip strip image of all profiles and comments", 00151 "-threshold value threshold the image", 00152 "-thumbnail geometry create a thumbnail of the image", 00153 "-trim trim image edges", 00154 (char *) NULL 00155 }, 00156 *settings[]= 00157 { 00158 "-alpha option on, activate, off, deactivate, set, opaque, copy", 00159 " transparent, extract, background, or shape", 00160 "-antialias remove pixel-aliasing", 00161 "-authenticate password", 00162 " decipher image with this password", 00163 "-backdrop display image centered on a backdrop", 00164 "-channel type apply option to select image channels", 00165 "-colormap type Shared or Private", 00166 "-colorspace type alternate image colorspace", 00167 "-comment string annotate image with comment", 00168 "-compress type type of pixel compression when writing the image", 00169 "-define format:option", 00170 " define one or more image format options", 00171 "-delay value display the next image after pausing", 00172 "-density geometry horizontal and vertical density of the image", 00173 "-depth value image depth", 00174 "-display server display image to this X server", 00175 "-dispose method layer disposal method", 00176 "-dither method apply error diffusion to image", 00177 "-endian type endianness (MSB or LSB) of the image", 00178 "-filter type use this filter when resizing an image", 00179 "-format string output formatted image characteristics", 00180 "-geometry geometry preferred size and location of the Image window", 00181 "-gravity type horizontal and vertical backdrop placement", 00182 "-identify identify the format and characteristics of the image", 00183 "-immutable displayed image cannot be modified", 00184 "-interlace type type of image interlacing scheme", 00185 "-interpolate method pixel color interpolation method", 00186 "-label string assign a label to an image", 00187 "-limit type value pixel cache resource limit", 00188 "-loop iterations loop images then exit", 00189 "-map type display image using this Standard Colormap", 00190 "-monitor monitor progress", 00191 "-page geometry size and location of an image canvas", 00192 "-profile filename add, delete, or apply an image profile", 00193 "-quality value JPEG/MIFF/PNG compression level", 00194 "-quantize colorspace reduce colors in this colorspace", 00195 "-quiet suppress all warning messages", 00196 "-regard-warnings pay attention to warning messages", 00197 "-remote command execute a command in an remote display process", 00198 "-repage geometry size and location of an image canvas (operator)", 00199 "-respect-parentheses settings remain in effect until parenthesis boundary", 00200 "-sampling-factor geometry", 00201 " horizontal and vertical sampling factor", 00202 "-seed value seed a new sequence of pseudo-random numbers", 00203 "-set property value set an image property", 00204 "-size geometry width and height of image", 00205 "-texture filename name of texture to tile onto the image background", 00206 "-transparent-color color", 00207 " transparent color", 00208 "-treedepth value color tree depth", 00209 "-update seconds detect when image file is modified and redisplay", 00210 "-verbose print detailed information about the image", 00211 "-visual type display image using this visual type", 00212 "-virtual-pixel method", 00213 " virtual pixel access method", 00214 "-window id display image to background of this window", 00215 "-window-group id exit program when this window id is destroyed", 00216 "-write filename write image to a file", 00217 (char *) NULL 00218 }, 00219 *sequence_operators[]= 00220 { 00221 "-coalesce merge a sequence of images", 00222 "-flatten flatten a sequence of images", 00223 (char *) NULL 00224 }; 00225 00226 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL)); 00227 (void) printf("Copyright: %s\n",GetMagickCopyright()); 00228 (void) printf("Features: %s\n\n",GetMagickFeatures()); 00229 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n", 00230 GetClientName()); 00231 (void) printf("\nImage Settings:\n"); 00232 for (p=settings; *p != (char *) NULL; p++) 00233 (void) printf(" %s\n",*p); 00234 (void) printf("\nImage Operators:\n"); 00235 for (p=operators; *p != (char *) NULL; p++) 00236 (void) printf(" %s\n",*p); 00237 (void) printf("\nImage Sequence Operators:\n"); 00238 for (p=sequence_operators; *p != (char *) NULL; p++) 00239 (void) printf(" %s\n",*p); 00240 (void) printf("\nMiscellaneous Options:\n"); 00241 for (p=miscellaneous; *p != (char *) NULL; p++) 00242 (void) printf(" %s\n",*p); 00243 (void) printf( 00244 "\nIn addition to those listed above, you can specify these standard X\n"); 00245 (void) printf( 00246 "resources as command line options: -background, -bordercolor,\n"); 00247 (void) printf( 00248 "-borderwidth, -font, -foreground, -iconGeometry, -iconic, -mattecolor,\n"); 00249 (void) printf("-name, -shared-memory, -usePixmap, or -title.\n"); 00250 (void) printf( 00251 "\nBy default, the image format of `file' is determined by its magic\n"); 00252 (void) printf( 00253 "number. To specify a particular image format, precede the filename\n"); 00254 (void) printf( 00255 "with an image format name and a colon (i.e. ps:image) or specify the\n"); 00256 (void) printf( 00257 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n"); 00258 (void) printf("'-' for standard input or output.\n"); 00259 (void) printf("\nButtons: \n"); 00260 for (p=buttons; *p != (char *) NULL; p++) 00261 (void) printf(" %s\n",*p); 00262 return(MagickFalse); 00263 } 00264 00265 WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info, 00266 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) 00267 { 00268 #if defined(MAGICKCORE_X11_DELEGATE) 00269 #define DestroyDisplay() \ 00270 { \ 00271 if ((state & ExitState) == 0) \ 00272 DestroyXResources(); \ 00273 if (display != (Display *) NULL) \ 00274 { \ 00275 XCloseDisplay(display); \ 00276 display=(Display *) NULL; \ 00277 } \ 00278 XDestroyResourceInfo(&resource_info); \ 00279 DestroyImageStack(); \ 00280 if (image_marker != (size_t *) NULL) \ 00281 image_marker=(size_t *) RelinquishMagickMemory(image_marker); \ 00282 for (i=0; i < (ssize_t) argc; i++) \ 00283 argv[i]=DestroyString(argv[i]); \ 00284 argv=(char **) RelinquishMagickMemory(argv); \ 00285 } 00286 #define ThrowDisplayException(asperity,tag,option) \ 00287 { \ 00288 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ 00289 option); \ 00290 DestroyDisplay(); \ 00291 return(MagickFalse); \ 00292 } 00293 #define ThrowDisplayInvalidArgumentException(option,argument) \ 00294 { \ 00295 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ 00296 "InvalidArgument","`%s': %s",option,argument); \ 00297 DestroyDisplay(); \ 00298 return(MagickFalse); \ 00299 } 00300 00301 char 00302 *resource_value, 00303 *server_name; 00304 00305 const char 00306 *option; 00307 00308 Display 00309 *display; 00310 00311 Image 00312 *image; 00313 00314 ImageStack 00315 image_stack[MaxImageStackDepth+1]; 00316 00317 MagickBooleanType 00318 fire, 00319 pend, 00320 respect_parenthesis; 00321 00322 MagickStatusType 00323 status; 00324 00325 QuantizeInfo 00326 *quantize_info; 00327 00328 register ssize_t 00329 i; 00330 00331 size_t 00332 *image_marker, 00333 iterations, 00334 last_image, 00335 state; 00336 00337 ssize_t 00338 image_number, 00339 iteration, 00340 j, 00341 k, 00342 l; 00343 00344 XResourceInfo 00345 resource_info; 00346 00347 XrmDatabase 00348 resource_database; 00349 00350 /* 00351 Set defaults. 00352 */ 00353 assert(image_info != (ImageInfo *) NULL); 00354 assert(image_info->signature == MagickSignature); 00355 if (image_info->debug != MagickFalse) 00356 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 00357 assert(exception != (ExceptionInfo *) NULL); 00358 if (argc == 2) 00359 { 00360 option=argv[1]; 00361 if ((LocaleCompare("version",option+1) == 0) || 00362 (LocaleCompare("-version",option+1) == 0)) 00363 { 00364 (void) FormatLocaleFile(stdout,"Version: %s\n", 00365 GetMagickVersion((size_t *) NULL)); 00366 (void) FormatLocaleFile(stdout,"Copyright: %s\n", 00367 GetMagickCopyright()); 00368 (void) FormatLocaleFile(stdout,"Features: %s\n\n", 00369 GetMagickFeatures()); 00370 return(MagickFalse); 00371 } 00372 } 00373 SetNotifyHandlers; 00374 display=(Display *) NULL; 00375 j=1; 00376 k=0; 00377 image_marker=(size_t *) NULL; 00378 image_number=0; 00379 last_image=0; 00380 NewImageStack(); 00381 option=(char *) NULL; 00382 pend=MagickFalse; 00383 respect_parenthesis=MagickFalse; 00384 resource_database=(XrmDatabase) NULL; 00385 (void) ResetMagickMemory(&resource_info,0,sizeof(resource_info)); 00386 server_name=(char *) NULL; 00387 state=0; 00388 status=MagickTrue; 00389 ReadCommandlLine(argc,&argv); 00390 status=ExpandFilenames(&argc,&argv); 00391 if (status == MagickFalse) 00392 ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed", 00393 GetExceptionMessage(errno)); 00394 image_marker=(size_t *) AcquireQuantumMemory((size_t) argc+1UL, 00395 sizeof(*image_marker)); 00396 if (image_marker == (size_t *) NULL) 00397 ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed", 00398 GetExceptionMessage(errno)); 00399 for (i=0; i <= (ssize_t) argc; i++) 00400 image_marker[i]=(size_t) argc; 00401 /* 00402 Check for server name specified on the command line. 00403 */ 00404 for (i=1; i < (ssize_t) argc; i++) 00405 { 00406 /* 00407 Check command line for server name. 00408 */ 00409 option=argv[i]; 00410 if (LocaleCompare("display",option+1) == 0) 00411 { 00412 /* 00413 User specified server name. 00414 */ 00415 i++; 00416 if (i == (ssize_t) argc) 00417 ThrowDisplayException(OptionError,"MissingArgument",option); 00418 server_name=argv[i]; 00419 } 00420 if ((LocaleCompare("help",option+1) == 0) || 00421 (LocaleCompare("-help",option+1) == 0)) 00422 return(DisplayUsage()); 00423 } 00424 /* 00425 Get user defaults from X resource database. 00426 */ 00427 display=XOpenDisplay(server_name); 00428 if (display == (Display *) NULL) 00429 ThrowDisplayException(XServerError,"UnableToOpenXServer", 00430 XDisplayName(server_name)); 00431 (void) XSetErrorHandler(XError); 00432 resource_database=XGetResourceDatabase(display,GetClientName()); 00433 XGetResourceInfo(image_info,resource_database,GetClientName(), 00434 &resource_info); 00435 quantize_info=resource_info.quantize_info; 00436 image_info->density=XGetResourceInstance(resource_database,GetClientName(), 00437 "density",(char *) NULL); 00438 if (image_info->density == (char *) NULL) 00439 image_info->density=XGetScreenDensity(display); 00440 resource_value=XGetResourceInstance(resource_database,GetClientName(), 00441 "interlace","none"); 00442 image_info->interlace=(InterlaceType) 00443 ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value); 00444 image_info->page=XGetResourceInstance(resource_database,GetClientName(), 00445 "pageGeometry",(char *) NULL); 00446 resource_value=XGetResourceInstance(resource_database,GetClientName(), 00447 "quality","75"); 00448 image_info->quality=StringToUnsignedLong(resource_value); 00449 resource_value=XGetResourceInstance(resource_database,GetClientName(), 00450 "verbose","False"); 00451 image_info->verbose=IsMagickTrue(resource_value); 00452 resource_value=XGetResourceInstance(resource_database,GetClientName(), 00453 "dither","True"); 00454 quantize_info->dither=IsMagickTrue(resource_value); 00455 /* 00456 Parse command line. 00457 */ 00458 iteration=0; 00459 for (i=1; ((i <= (ssize_t) argc) && ((state & ExitState) == 0)); i++) 00460 { 00461 if (i < (ssize_t) argc) 00462 option=argv[i]; 00463 else 00464 if (image != (Image *) NULL) 00465 break; 00466 else 00467 if (isatty(STDIN_FILENO) != MagickFalse) 00468 option="logo:"; 00469 else 00470 { 00471 int 00472 c; 00473 00474 c=getc(stdin); 00475 if (c == EOF) 00476 break; 00477 else 00478 { 00479 c=ungetc(c,stdin); 00480 option="-"; 00481 } 00482 } 00483 if (LocaleCompare(option,"(") == 0) 00484 { 00485 FireImageStack(MagickFalse,MagickTrue,pend); 00486 if (k == MaxImageStackDepth) 00487 ThrowDisplayException(OptionError,"ParenthesisNestedTooDeeply", 00488 option); 00489 PushImageStack(); 00490 continue; 00491 } 00492 if (LocaleCompare(option,")") == 0) 00493 { 00494 FireImageStack(MagickFalse,MagickTrue,MagickTrue); 00495 if (k == 0) 00496 ThrowDisplayException(OptionError,"UnableToParseExpression",option); 00497 PopImageStack(); 00498 continue; 00499 } 00500 if (IsCommandOption(option) == MagickFalse) 00501 { 00502 const char 00503 *filename; 00504 00505 Image 00506 *display_image, 00507 *images; 00508 00509 /* 00510 Option is a file name. 00511 */ 00512 FireImageStack(MagickFalse,MagickFalse,pend); 00513 filename=option; 00514 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) 00515 { 00516 option=argv[++i]; 00517 filename=option; 00518 } 00519 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); 00520 images=ReadImage(image_info,exception); 00521 CatchException(exception); 00522 status&=(images != (Image *) NULL) && 00523 (exception->severity < ErrorException); 00524 if (images == (Image *) NULL) 00525 continue; 00526 AppendImageStack(images); 00527 FinalizeImageSettings(image_info,image,MagickFalse); 00528 iterations=0; 00529 if (i == (ssize_t) (argc-1)) 00530 iterations=image->iterations; 00531 display_image=CloneImageList(image,exception); 00532 if (display_image == (Image *) NULL) 00533 ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed", 00534 GetExceptionMessage(errno)); 00535 do 00536 { 00537 /* 00538 Transmogrify image as defined by the image processing options. 00539 */ 00540 resource_info.quantum=1; 00541 if (resource_info.window_id != (char *) NULL) 00542 { 00543 /* 00544 Display image to a specified X window. 00545 */ 00546 status=XDisplayBackgroundImage(display,&resource_info, 00547 display_image,exception); 00548 if (status != MagickFalse) 00549 { 00550 state|=RetainColorsState; 00551 status=MagickFalse; 00552 } 00553 } 00554 else 00555 do 00556 { 00557 Image 00558 *nexus; 00559 00560 /* 00561 Display image to X server. 00562 */ 00563 if (resource_info.delay != 1) 00564 display_image->delay=resource_info.delay; 00565 nexus=XDisplayImage(display,&resource_info,argv,argc, 00566 &display_image,&state,exception); 00567 status&=nexus != (Image *) NULL; 00568 if (nexus == (Image *) NULL) 00569 break; 00570 while ((nexus != (Image *) NULL) && ((state & ExitState) == 0)) 00571 { 00572 Image 00573 *next; 00574 00575 if (nexus->montage != (char *) NULL) 00576 { 00577 /* 00578 User selected a visual directory image (montage). 00579 */ 00580 display_image=nexus; 00581 break; 00582 } 00583 next=XDisplayImage(display,&resource_info,argv,argc,&nexus, 00584 &state,exception); 00585 if ((next == (Image *) NULL) && 00586 (GetNextImageInList(nexus) != (Image *) NULL)) 00587 { 00588 display_image=GetNextImageInList(nexus); 00589 nexus=NewImageList(); 00590 } 00591 else 00592 { 00593 if (nexus != display_image) 00594 nexus=DestroyImageList(nexus); 00595 nexus=next; 00596 } 00597 } 00598 } while ((state & ExitState) == 0); 00599 if (resource_info.write_filename != (char *) NULL) 00600 { 00601 /* 00602 Write image. 00603 */ 00604 (void) CopyMagickString(display_image->filename, 00605 resource_info.write_filename,MaxTextExtent); 00606 (void) SetImageInfo(image_info,1,exception); 00607 status&=WriteImage(image_info,display_image,exception); 00608 } 00609 /* 00610 Proceed to next/previous image. 00611 */ 00612 if ((state & FormerImageState) != 0) 00613 for (l=0; l < (ssize_t) resource_info.quantum; l++) 00614 { 00615 display_image=GetPreviousImageInList(display_image); 00616 if (display_image == (Image *) NULL) 00617 break; 00618 } 00619 else 00620 for (l=0; l < (ssize_t) resource_info.quantum; l++) 00621 { 00622 display_image=GetNextImageInList(display_image); 00623 if (display_image == (Image *) NULL) 00624 break; 00625 } 00626 } while ((display_image != (Image *) NULL) && ((state & ExitState) == 0)); 00627 /* 00628 Free image resources. 00629 */ 00630 display_image=DestroyImageList(display_image); 00631 if ((state & FormerImageState) == 0) 00632 { 00633 last_image=(size_t) image_number; 00634 image_marker[i]=(size_t) image_number++; 00635 } 00636 else 00637 { 00638 /* 00639 Proceed to previous image. 00640 */ 00641 for (i--; i > 0; i--) 00642 if (image_marker[i] == (size_t) (image_number-2)) 00643 break; 00644 image_number--; 00645 } 00646 if ((i == (ssize_t) (argc-1)) && ((state & ExitState) == 0)) 00647 i=0; 00648 if ((state & ExitState) != 0) 00649 break; 00650 /* 00651 Determine if we should proceed to the first image. 00652 */ 00653 if (image_number < 0) 00654 { 00655 if ((state & FormerImageState) != 0) 00656 { 00657 00658 for (i=1; i < (ssize_t) (argc-2); i++) 00659 if (last_image == image_marker[i]) 00660 break; 00661 image_number=(ssize_t) image_marker[i]+1; 00662 } 00663 continue; 00664 } 00665 if (resource_info.window_id != (char *) NULL) 00666 state|=ExitState; 00667 if ((iterations != 0) && (++iteration == (ssize_t) iterations)) 00668 state|=ExitState; 00669 if (LocaleCompare(filename,"-") == 0) 00670 state|=ExitState; 00671 RemoveAllImageStack(); 00672 continue; 00673 } 00674 pend=image != (Image *) NULL ? MagickTrue : MagickFalse; 00675 switch (*(option+1)) 00676 { 00677 case 'a': 00678 { 00679 if (LocaleCompare("alpha",option+1) == 0) 00680 { 00681 ssize_t 00682 type; 00683 00684 if (*option == '+') 00685 break; 00686 i++; 00687 if (i == (ssize_t) argc) 00688 ThrowDisplayException(OptionError,"MissingArgument",option); 00689 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); 00690 if (type < 0) 00691 ThrowDisplayException(OptionError,"UnrecognizedAlphaChannelType", 00692 argv[i]); 00693 break; 00694 } 00695 if (LocaleCompare("antialias",option+1) == 0) 00696 break; 00697 if (LocaleCompare("authenticate",option+1) == 0) 00698 { 00699 if (*option == '+') 00700 break; 00701 i++; 00702 if (i == (ssize_t) argc) 00703 ThrowDisplayException(OptionError,"MissingArgument",option); 00704 break; 00705 } 00706 if (LocaleCompare("auto-orient",option+1) == 0) 00707 break; 00708 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 00709 } 00710 case 'b': 00711 { 00712 if (LocaleCompare("backdrop",option+1) == 0) 00713 { 00714 resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse; 00715 break; 00716 } 00717 if (LocaleCompare("background",option+1) == 0) 00718 { 00719 if (*option == '+') 00720 break; 00721 i++; 00722 if (i == (ssize_t) argc) 00723 ThrowDisplayException(OptionError,"MissingArgument",option); 00724 resource_info.background_color=argv[i]; 00725 break; 00726 } 00727 if (LocaleCompare("border",option+1) == 0) 00728 { 00729 if (*option == '+') 00730 break; 00731 i++; 00732 if (i == (ssize_t) argc) 00733 ThrowDisplayException(OptionError,"MissingArgument",option); 00734 if (IsGeometry(argv[i]) == MagickFalse) 00735 ThrowDisplayInvalidArgumentException(option,argv[i]); 00736 break; 00737 } 00738 if (LocaleCompare("bordercolor",option+1) == 0) 00739 { 00740 if (*option == '+') 00741 break; 00742 i++; 00743 if (i == (ssize_t) argc) 00744 ThrowDisplayException(OptionError,"MissingArgument",option); 00745 resource_info.border_color=argv[i]; 00746 break; 00747 } 00748 if (LocaleCompare("borderwidth",option+1) == 0) 00749 { 00750 resource_info.border_width=0; 00751 if (*option == '+') 00752 break; 00753 i++; 00754 if (i == (ssize_t) argc) 00755 ThrowDisplayException(OptionError,"MissingArgument",option); 00756 if (IsGeometry(argv[i]) == MagickFalse) 00757 ThrowDisplayInvalidArgumentException(option,argv[i]); 00758 resource_info.border_width=(unsigned int) 00759 StringToUnsignedLong(argv[i]); 00760 break; 00761 } 00762 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 00763 } 00764 case 'c': 00765 { 00766 if (LocaleCompare("cache",option+1) == 0) 00767 { 00768 if (*option == '+') 00769 break; 00770 i++; 00771 if (i == (ssize_t) argc) 00772 ThrowDisplayException(OptionError,"MissingArgument",option); 00773 if (IsGeometry(argv[i]) == MagickFalse) 00774 ThrowDisplayInvalidArgumentException(option,argv[i]); 00775 break; 00776 } 00777 if (LocaleCompare("channel",option+1) == 0) 00778 { 00779 ssize_t 00780 channel; 00781 00782 if (*option == '+') 00783 break; 00784 i++; 00785 if (i == (ssize_t) (argc-1)) 00786 ThrowDisplayException(OptionError,"MissingArgument",option); 00787 channel=ParseChannelOption(argv[i]); 00788 if (channel < 0) 00789 ThrowDisplayException(OptionError,"UnrecognizedChannelType", 00790 argv[i]); 00791 break; 00792 } 00793 if (LocaleCompare("clip",option+1) == 0) 00794 break; 00795 if (LocaleCompare("clip-path",option+1) == 0) 00796 { 00797 i++; 00798 if (i == (ssize_t) argc) 00799 ThrowDisplayException(OptionError,"MissingArgument",option); 00800 break; 00801 } 00802 if (LocaleCompare("coalesce",option+1) == 0) 00803 break; 00804 if (LocaleCompare("colormap",option+1) == 0) 00805 { 00806 resource_info.colormap=PrivateColormap; 00807 if (*option == '+') 00808 break; 00809 i++; 00810 if (i == (ssize_t) argc) 00811 ThrowDisplayException(OptionError,"MissingArgument",option); 00812 resource_info.colormap=UndefinedColormap; 00813 if (LocaleCompare("private",argv[i]) == 0) 00814 resource_info.colormap=PrivateColormap; 00815 if (LocaleCompare("shared",argv[i]) == 0) 00816 resource_info.colormap=SharedColormap; 00817 if (resource_info.colormap == UndefinedColormap) 00818 ThrowDisplayException(OptionError,"UnrecognizedColormapType", 00819 argv[i]); 00820 break; 00821 } 00822 if (LocaleCompare("colors",option+1) == 0) 00823 { 00824 quantize_info->number_colors=0; 00825 if (*option == '+') 00826 break; 00827 i++; 00828 if (i == (ssize_t) argc) 00829 ThrowDisplayException(OptionError,"MissingArgument",option); 00830 if (IsGeometry(argv[i]) == MagickFalse) 00831 ThrowDisplayInvalidArgumentException(option,argv[i]); 00832 quantize_info->number_colors=StringToUnsignedLong(argv[i]); 00833 break; 00834 } 00835 if (LocaleCompare("colorspace",option+1) == 0) 00836 { 00837 ssize_t 00838 colorspace; 00839 00840 if (*option == '+') 00841 break; 00842 i++; 00843 if (i == (ssize_t) argc) 00844 ThrowDisplayException(OptionError,"MissingArgument",option); 00845 colorspace=ParseCommandOption(MagickColorspaceOptions, 00846 MagickFalse,argv[i]); 00847 if (colorspace < 0) 00848 ThrowDisplayException(OptionError,"UnrecognizedColorspace", 00849 argv[i]); 00850 break; 00851 } 00852 if (LocaleCompare("comment",option+1) == 0) 00853 { 00854 if (*option == '+') 00855 break; 00856 i++; 00857 if (i == (ssize_t) argc) 00858 ThrowDisplayException(OptionError,"MissingArgument",option); 00859 break; 00860 } 00861 if (LocaleCompare("compress",option+1) == 0) 00862 { 00863 ssize_t 00864 compress; 00865 00866 if (*option == '+') 00867 break; 00868 i++; 00869 if (i == (ssize_t) argc) 00870 ThrowDisplayException(OptionError,"MissingArgument",option); 00871 compress=ParseCommandOption(MagickCompressOptions,MagickFalse, 00872 argv[i]); 00873 if (compress < 0) 00874 ThrowDisplayException(OptionError,"UnrecognizedImageCompression", 00875 argv[i]); 00876 break; 00877 } 00878 if (LocaleCompare("concurrent",option+1) == 0) 00879 break; 00880 if (LocaleCompare("contrast",option+1) == 0) 00881 break; 00882 if (LocaleCompare("crop",option+1) == 0) 00883 { 00884 if (*option == '+') 00885 break; 00886 i++; 00887 if (i == (ssize_t) argc) 00888 ThrowDisplayException(OptionError,"MissingArgument",option); 00889 if (IsGeometry(argv[i]) == MagickFalse) 00890 ThrowDisplayInvalidArgumentException(option,argv[i]); 00891 break; 00892 } 00893 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 00894 } 00895 case 'd': 00896 { 00897 if (LocaleCompare("debug",option+1) == 0) 00898 { 00899 ssize_t 00900 event; 00901 00902 if (*option == '+') 00903 break; 00904 i++; 00905 if (i == (ssize_t) argc) 00906 ThrowDisplayException(OptionError,"MissingArgument",option); 00907 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); 00908 if (event < 0) 00909 ThrowDisplayException(OptionError,"UnrecognizedEventType", 00910 argv[i]); 00911 (void) SetLogEventMask(argv[i]); 00912 break; 00913 } 00914 if (LocaleCompare("decipher",option+1) == 0) 00915 { 00916 if (*option == '+') 00917 break; 00918 i++; 00919 if (i == (ssize_t) (argc-1)) 00920 ThrowDisplayException(OptionError,"MissingArgument",option); 00921 break; 00922 } 00923 if (LocaleCompare("define",option+1) == 0) 00924 { 00925 i++; 00926 if (i == (ssize_t) argc) 00927 ThrowDisplayException(OptionError,"MissingArgument",option); 00928 if (*option == '+') 00929 { 00930 const char 00931 *define; 00932 00933 define=GetImageOption(image_info,argv[i]); 00934 if (define == (const char *) NULL) 00935 ThrowDisplayException(OptionError,"NoSuchOption",argv[i]); 00936 break; 00937 } 00938 break; 00939 } 00940 if (LocaleCompare("delay",option+1) == 0) 00941 { 00942 if (*option == '+') 00943 break; 00944 i++; 00945 if (i == (ssize_t) argc) 00946 ThrowDisplayException(OptionError,"MissingArgument",option); 00947 if (IsGeometry(argv[i]) == MagickFalse) 00948 ThrowDisplayInvalidArgumentException(option,argv[i]); 00949 break; 00950 } 00951 if (LocaleCompare("density",option+1) == 0) 00952 { 00953 if (*option == '+') 00954 break; 00955 i++; 00956 if (i == (ssize_t) argc) 00957 ThrowDisplayException(OptionError,"MissingArgument",option); 00958 if (IsGeometry(argv[i]) == MagickFalse) 00959 ThrowDisplayInvalidArgumentException(option,argv[i]); 00960 break; 00961 } 00962 if (LocaleCompare("depth",option+1) == 0) 00963 { 00964 if (*option == '+') 00965 break; 00966 i++; 00967 if (i == (ssize_t) argc) 00968 ThrowDisplayException(OptionError,"MissingArgument",option); 00969 if (IsGeometry(argv[i]) == MagickFalse) 00970 ThrowDisplayInvalidArgumentException(option,argv[i]); 00971 break; 00972 } 00973 if (LocaleCompare("deskew",option+1) == 0) 00974 { 00975 if (*option == '+') 00976 break; 00977 i++; 00978 if (i == (ssize_t) (argc-1)) 00979 ThrowDisplayException(OptionError,"MissingArgument",option); 00980 if (IsGeometry(argv[i]) == MagickFalse) 00981 ThrowDisplayInvalidArgumentException(option,argv[i]); 00982 break; 00983 } 00984 if (LocaleCompare("despeckle",option+1) == 0) 00985 break; 00986 if (LocaleCompare("display",option+1) == 0) 00987 { 00988 if (*option == '+') 00989 break; 00990 i++; 00991 if (i == (ssize_t) argc) 00992 ThrowDisplayException(OptionError,"MissingArgument",option); 00993 break; 00994 } 00995 if (LocaleCompare("dispose",option+1) == 0) 00996 { 00997 ssize_t 00998 dispose; 00999 01000 if (*option == '+') 01001 break; 01002 i++; 01003 if (i == (ssize_t) argc) 01004 ThrowDisplayException(OptionError,"MissingArgument",option); 01005 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); 01006 if (dispose < 0) 01007 ThrowDisplayException(OptionError,"UnrecognizedDisposeMethod", 01008 argv[i]); 01009 break; 01010 } 01011 if (LocaleCompare("dither",option+1) == 0) 01012 { 01013 ssize_t 01014 method; 01015 01016 quantize_info->dither=MagickFalse; 01017 if (*option == '+') 01018 break; 01019 i++; 01020 if (i == (ssize_t) argc) 01021 ThrowDisplayException(OptionError,"MissingArgument",option); 01022 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); 01023 if (method < 0) 01024 ThrowDisplayException(OptionError,"UnrecognizedDitherMethod", 01025 argv[i]); 01026 quantize_info->dither=MagickTrue; 01027 quantize_info->dither_method=(DitherMethod) method; 01028 break; 01029 } 01030 if (LocaleCompare("duration",option+1) == 0) 01031 { 01032 if (*option == '+') 01033 break; 01034 i++; 01035 if (i == (ssize_t) (argc-1)) 01036 ThrowDisplayException(OptionError,"MissingArgument",option); 01037 if (IsGeometry(argv[i]) == MagickFalse) 01038 ThrowDisplayInvalidArgumentException(option,argv[i]); 01039 break; 01040 } 01041 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01042 } 01043 case 'e': 01044 { 01045 if (LocaleCompare("edge",option+1) == 0) 01046 { 01047 if (*option == '+') 01048 break; 01049 i++; 01050 if (i == (ssize_t) argc) 01051 ThrowDisplayException(OptionError,"MissingArgument",option); 01052 if (IsGeometry(argv[i]) == MagickFalse) 01053 ThrowDisplayInvalidArgumentException(option,argv[i]); 01054 break; 01055 } 01056 if (LocaleCompare("endian",option+1) == 0) 01057 { 01058 ssize_t 01059 endian; 01060 01061 if (*option == '+') 01062 break; 01063 i++; 01064 if (i == (ssize_t) argc) 01065 ThrowDisplayException(OptionError,"MissingArgument",option); 01066 endian=ParseCommandOption(MagickEndianOptions,MagickFalse, 01067 argv[i]); 01068 if (endian < 0) 01069 ThrowDisplayException(OptionError,"UnrecognizedEndianType", 01070 argv[i]); 01071 break; 01072 } 01073 if (LocaleCompare("enhance",option+1) == 0) 01074 break; 01075 if (LocaleCompare("equalize",option+1) == 0) 01076 break; 01077 if (LocaleCompare("extract",option+1) == 0) 01078 { 01079 if (*option == '+') 01080 break; 01081 i++; 01082 if (i == (ssize_t) argc) 01083 ThrowDisplayException(OptionError,"MissingArgument",option); 01084 if (IsGeometry(argv[i]) == MagickFalse) 01085 ThrowDisplayInvalidArgumentException(option,argv[i]); 01086 break; 01087 } 01088 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01089 } 01090 case 'f': 01091 { 01092 if (LocaleCompare("filter",option+1) == 0) 01093 { 01094 ssize_t 01095 filter; 01096 01097 if (*option == '+') 01098 break; 01099 i++; 01100 if (i == (ssize_t) argc) 01101 ThrowDisplayException(OptionError,"MissingArgument",option); 01102 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); 01103 if (filter < 0) 01104 ThrowDisplayException(OptionError,"UnrecognizedImageFilter", 01105 argv[i]); 01106 break; 01107 } 01108 if (LocaleCompare("flatten",option+1) == 0) 01109 break; 01110 if (LocaleCompare("flip",option+1) == 0) 01111 break; 01112 if (LocaleCompare("flop",option+1) == 0) 01113 break; 01114 if (LocaleCompare("font",option+1) == 0) 01115 { 01116 if (*option == '+') 01117 break; 01118 i++; 01119 if (i == (ssize_t) argc) 01120 ThrowDisplayException(OptionError,"MissingArgument",option); 01121 resource_info.font=XGetResourceClass(resource_database, 01122 GetClientName(),"font",argv[i]); 01123 break; 01124 } 01125 if (LocaleCompare("foreground",option+1) == 0) 01126 { 01127 if (*option == '+') 01128 break; 01129 i++; 01130 if (i == (ssize_t) argc) 01131 ThrowDisplayException(OptionError,"MissingArgument",option); 01132 resource_info.foreground_color=argv[i]; 01133 break; 01134 } 01135 if (LocaleCompare("format",option+1) == 0) 01136 { 01137 if (*option == '+') 01138 break; 01139 i++; 01140 if (i == (ssize_t) (argc-1)) 01141 ThrowDisplayException(OptionError,"MissingArgument",option); 01142 break; 01143 } 01144 if (LocaleCompare("frame",option+1) == 0) 01145 { 01146 if (*option == '+') 01147 break; 01148 i++; 01149 if (i == (ssize_t) argc) 01150 ThrowDisplayException(OptionError,"MissingArgument",option); 01151 if (IsGeometry(argv[i]) == MagickFalse) 01152 ThrowDisplayInvalidArgumentException(option,argv[i]); 01153 break; 01154 } 01155 if (LocaleCompare("fuzz",option+1) == 0) 01156 { 01157 if (*option == '+') 01158 break; 01159 i++; 01160 if (i == (ssize_t) (argc-1)) 01161 ThrowDisplayException(OptionError,"MissingArgument",option); 01162 if (IsGeometry(argv[i]) == MagickFalse) 01163 ThrowDisplayInvalidArgumentException(option,argv[i]); 01164 break; 01165 } 01166 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01167 } 01168 case 'g': 01169 { 01170 if (LocaleCompare("gamma",option+1) == 0) 01171 { 01172 i++; 01173 if (i == (ssize_t) argc) 01174 ThrowDisplayException(OptionError,"MissingArgument",option); 01175 if (IsGeometry(argv[i]) == MagickFalse) 01176 ThrowDisplayInvalidArgumentException(option,argv[i]); 01177 break; 01178 } 01179 if (LocaleCompare("geometry",option+1) == 0) 01180 { 01181 resource_info.image_geometry=(char *) NULL; 01182 if (*option == '+') 01183 break; 01184 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); 01185 i++; 01186 if (i == (ssize_t) argc) 01187 ThrowDisplayException(OptionError,"MissingArgument",option); 01188 if (IsGeometry(argv[i]) == MagickFalse) 01189 ThrowDisplayInvalidArgumentException(option,argv[i]); 01190 resource_info.image_geometry=ConstantString(argv[i]); 01191 break; 01192 } 01193 if (LocaleCompare("gravity",option+1) == 0) 01194 { 01195 ssize_t 01196 gravity; 01197 01198 if (*option == '+') 01199 break; 01200 i++; 01201 if (i == (ssize_t) (argc-1)) 01202 ThrowDisplayException(OptionError,"MissingArgument",option); 01203 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse, 01204 argv[i]); 01205 if (gravity < 0) 01206 ThrowDisplayException(OptionError,"UnrecognizedGravityType", 01207 argv[i]); 01208 break; 01209 } 01210 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01211 } 01212 case 'h': 01213 { 01214 if ((LocaleCompare("help",option+1) == 0) || 01215 (LocaleCompare("-help",option+1) == 0)) 01216 break; 01217 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01218 } 01219 case 'i': 01220 { 01221 if (LocaleCompare("identify",option+1) == 0) 01222 break; 01223 if (LocaleCompare("iconGeometry",option+1) == 0) 01224 { 01225 resource_info.icon_geometry=(char *) NULL; 01226 if (*option == '+') 01227 break; 01228 i++; 01229 if (i == (ssize_t) argc) 01230 ThrowDisplayException(OptionError,"MissingArgument",option); 01231 if (IsGeometry(argv[i]) == MagickFalse) 01232 ThrowDisplayInvalidArgumentException(option,argv[i]); 01233 resource_info.icon_geometry=argv[i]; 01234 break; 01235 } 01236 if (LocaleCompare("iconic",option+1) == 0) 01237 { 01238 resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse; 01239 break; 01240 } 01241 if (LocaleCompare("immutable",option+1) == 0) 01242 { 01243 resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse; 01244 break; 01245 } 01246 if (LocaleCompare("interlace",option+1) == 0) 01247 { 01248 ssize_t 01249 interlace; 01250 01251 if (*option == '+') 01252 break; 01253 i++; 01254 if (i == (ssize_t) argc) 01255 ThrowDisplayException(OptionError,"MissingArgument",option); 01256 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, 01257 argv[i]); 01258 if (interlace < 0) 01259 ThrowDisplayException(OptionError,"UnrecognizedInterlaceType", 01260 argv[i]); 01261 break; 01262 } 01263 if (LocaleCompare("interpolate",option+1) == 0) 01264 { 01265 ssize_t 01266 interpolate; 01267 01268 if (*option == '+') 01269 break; 01270 i++; 01271 if (i == (ssize_t) argc) 01272 ThrowDisplayException(OptionError,"MissingArgument",option); 01273 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, 01274 argv[i]); 01275 if (interpolate < 0) 01276 ThrowDisplayException(OptionError,"UnrecognizedInterpolateMethod", 01277 argv[i]); 01278 break; 01279 } 01280 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01281 } 01282 case 'l': 01283 { 01284 if (LocaleCompare("label",option+1) == 0) 01285 { 01286 if (*option == '+') 01287 break; 01288 i++; 01289 if (i == (ssize_t) argc) 01290 ThrowDisplayException(OptionError,"MissingArgument",option); 01291 break; 01292 } 01293 if (LocaleCompare("limit",option+1) == 0) 01294 { 01295 char 01296 *p; 01297 01298 double 01299 value; 01300 01301 ssize_t 01302 resource; 01303 01304 if (*option == '+') 01305 break; 01306 i++; 01307 if (i == (ssize_t) argc) 01308 ThrowDisplayException(OptionError,"MissingArgument",option); 01309 resource=ParseCommandOption(MagickResourceOptions,MagickFalse, 01310 argv[i]); 01311 if (resource < 0) 01312 ThrowDisplayException(OptionError,"UnrecognizedResourceType", 01313 argv[i]); 01314 i++; 01315 if (i == (ssize_t) argc) 01316 ThrowDisplayException(OptionError,"MissingArgument",option); 01317 value=StringToDouble(argv[i],&p); 01318 (void) value; 01319 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) 01320 ThrowDisplayInvalidArgumentException(option,argv[i]); 01321 break; 01322 } 01323 if (LocaleCompare("list",option+1) == 0) 01324 { 01325 ssize_t 01326 list; 01327 01328 if (*option == '+') 01329 break; 01330 i++; 01331 if (i == (ssize_t) argc) 01332 ThrowDisplayException(OptionError,"MissingArgument",option); 01333 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); 01334 if (list < 0) 01335 ThrowDisplayException(OptionError,"UnrecognizedListType",argv[i]); 01336 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) 01337 argv+j,exception); 01338 DestroyDisplay(); 01339 return(status != 0 ? MagickFalse : MagickTrue); 01340 } 01341 if (LocaleCompare("log",option+1) == 0) 01342 { 01343 if (*option == '+') 01344 break; 01345 i++; 01346 if ((i == (ssize_t) argc) || 01347 (strchr(argv[i],'%') == (char *) NULL)) 01348 ThrowDisplayException(OptionError,"MissingArgument",option); 01349 break; 01350 } 01351 if (LocaleCompare("loop",option+1) == 0) 01352 { 01353 if (*option == '+') 01354 break; 01355 i++; 01356 if (i == (ssize_t) (argc-1)) 01357 ThrowDisplayException(OptionError,"MissingArgument",option); 01358 if (IsGeometry(argv[i]) == MagickFalse) 01359 ThrowDisplayInvalidArgumentException(option,argv[i]); 01360 iterations=StringToUnsignedLong(argv[i]); 01361 break; 01362 } 01363 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01364 } 01365 case 'm': 01366 { 01367 if (LocaleCompare("magnify",option+1) == 0) 01368 { 01369 resource_info.magnify=2; 01370 if (*option == '+') 01371 break; 01372 i++; 01373 if (i == (ssize_t) argc) 01374 ThrowDisplayException(OptionError,"MissingArgument",option); 01375 if (IsGeometry(argv[i]) == MagickFalse) 01376 ThrowDisplayInvalidArgumentException(option,argv[i]); 01377 resource_info.magnify=(unsigned int) StringToUnsignedLong(argv[i]); 01378 break; 01379 } 01380 if (LocaleCompare("map",option+1) == 0) 01381 { 01382 resource_info.map_type=(char *) NULL; 01383 if (*option == '+') 01384 break; 01385 (void) strcpy(argv[i]+1,"san"); 01386 i++; 01387 if (i == (ssize_t) argc) 01388 ThrowDisplayException(OptionError,"MissingArgument",option); 01389 resource_info.map_type=argv[i]; 01390 break; 01391 } 01392 if (LocaleCompare("matte",option+1) == 0) 01393 break; 01394 if (LocaleCompare("mattecolor",option+1) == 0) 01395 { 01396 if (*option == '+') 01397 break; 01398 i++; 01399 if (i == (ssize_t) argc) 01400 ThrowDisplayException(OptionError,"MissingArgument",option); 01401 resource_info.matte_color=argv[i]; 01402 break; 01403 } 01404 if (LocaleCompare("monitor",option+1) == 0) 01405 break; 01406 if (LocaleCompare("monochrome",option+1) == 0) 01407 { 01408 if (*option == '+') 01409 break; 01410 quantize_info->number_colors=2; 01411 quantize_info->colorspace=GRAYColorspace; 01412 break; 01413 } 01414 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01415 } 01416 case 'n': 01417 { 01418 if (LocaleCompare("name",option+1) == 0) 01419 { 01420 resource_info.name=(char *) NULL; 01421 if (*option == '+') 01422 break; 01423 i++; 01424 if (i == (ssize_t) argc) 01425 ThrowDisplayException(OptionError,"MissingArgument",option); 01426 resource_info.name=ConstantString(argv[i]); 01427 break; 01428 } 01429 if (LocaleCompare("negate",option+1) == 0) 01430 break; 01431 if (LocaleCompare("noop",option+1) == 0) 01432 break; 01433 if (LocaleCompare("normalize",option+1) == 0) 01434 break; 01435 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01436 } 01437 case 'p': 01438 { 01439 if (LocaleCompare("page",option+1) == 0) 01440 { 01441 resource_info.image_geometry=(char *) NULL; 01442 if (*option == '+') 01443 break; 01444 i++; 01445 if (i == (ssize_t) argc) 01446 ThrowDisplayException(OptionError,"MissingArgument",option); 01447 resource_info.image_geometry=ConstantString(argv[i]); 01448 break; 01449 } 01450 if (LocaleCompare("profile",option+1) == 0) 01451 { 01452 i++; 01453 if (i == (ssize_t) argc) 01454 ThrowDisplayException(OptionError,"MissingArgument",option); 01455 break; 01456 } 01457 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01458 } 01459 case 'q': 01460 { 01461 if (LocaleCompare("quality",option+1) == 0) 01462 { 01463 if (*option == '+') 01464 break; 01465 i++; 01466 if (i == (ssize_t) argc) 01467 ThrowDisplayException(OptionError,"MissingArgument",option); 01468 if (IsGeometry(argv[i]) == MagickFalse) 01469 ThrowDisplayInvalidArgumentException(option,argv[i]); 01470 break; 01471 } 01472 if (LocaleCompare("quantize",option+1) == 0) 01473 { 01474 ssize_t 01475 colorspace; 01476 01477 if (*option == '+') 01478 break; 01479 i++; 01480 if (i == (ssize_t) (argc-1)) 01481 ThrowDisplayException(OptionError,"MissingArgument",option); 01482 colorspace=ParseCommandOption(MagickColorspaceOptions, 01483 MagickFalse,argv[i]); 01484 if (colorspace < 0) 01485 ThrowDisplayException(OptionError,"UnrecognizedColorspace", 01486 argv[i]); 01487 break; 01488 } 01489 if (LocaleCompare("quiet",option+1) == 0) 01490 break; 01491 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01492 } 01493 case 'r': 01494 { 01495 if (LocaleCompare("raise",option+1) == 0) 01496 { 01497 i++; 01498 if (i == (ssize_t) argc) 01499 ThrowDisplayException(OptionError,"MissingArgument",option); 01500 if (IsGeometry(argv[i]) == MagickFalse) 01501 ThrowDisplayInvalidArgumentException(option,argv[i]); 01502 break; 01503 } 01504 if (LocaleCompare("regard-warnings",option+1) == 0) 01505 break; 01506 if (LocaleCompare("remote",option+1) == 0) 01507 { 01508 i++; 01509 if (i == (ssize_t) argc) 01510 ThrowDisplayException(OptionError,"MissingArgument",option); 01511 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0) 01512 return(MagickFalse); 01513 i--; 01514 break; 01515 } 01516 if (LocaleCompare("repage",option+1) == 0) 01517 { 01518 if (*option == '+') 01519 break; 01520 i++; 01521 if (i == (ssize_t) argc) 01522 ThrowDisplayException(OptionError,"MissingArgument",option); 01523 if (IsGeometry(argv[i]) == MagickFalse) 01524 ThrowDisplayInvalidArgumentException(option,argv[i]); 01525 break; 01526 } 01527 if (LocaleCompare("resample",option+1) == 0) 01528 { 01529 if (*option == '+') 01530 break; 01531 i++; 01532 if (i == (ssize_t) (argc-1)) 01533 ThrowDisplayException(OptionError,"MissingArgument",option); 01534 if (IsGeometry(argv[i]) == MagickFalse) 01535 ThrowDisplayInvalidArgumentException(option,argv[i]); 01536 break; 01537 } 01538 if (LocaleCompare("resize",option+1) == 0) 01539 { 01540 if (*option == '+') 01541 break; 01542 i++; 01543 if (i == (ssize_t) argc) 01544 ThrowDisplayException(OptionError,"MissingArgument",option); 01545 if (IsGeometry(argv[i]) == MagickFalse) 01546 ThrowDisplayInvalidArgumentException(option,argv[i]); 01547 break; 01548 } 01549 if (LocaleNCompare("respect-parentheses",option+1,17) == 0) 01550 { 01551 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; 01552 break; 01553 } 01554 if (LocaleCompare("roll",option+1) == 0) 01555 { 01556 if (*option == '+') 01557 break; 01558 i++; 01559 if (i == (ssize_t) argc) 01560 ThrowDisplayException(OptionError,"MissingArgument",option); 01561 if (IsGeometry(argv[i]) == MagickFalse) 01562 ThrowDisplayInvalidArgumentException(option,argv[i]); 01563 break; 01564 } 01565 if (LocaleCompare("rotate",option+1) == 0) 01566 { 01567 i++; 01568 if (i == (ssize_t) argc) 01569 ThrowDisplayException(OptionError,"MissingArgument",option); 01570 if (IsGeometry(argv[i]) == MagickFalse) 01571 ThrowDisplayInvalidArgumentException(option,argv[i]); 01572 break; 01573 } 01574 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01575 } 01576 case 's': 01577 { 01578 if (LocaleCompare("sample",option+1) == 0) 01579 { 01580 if (*option == '+') 01581 break; 01582 i++; 01583 if (i == (ssize_t) argc) 01584 ThrowDisplayException(OptionError,"MissingArgument",option); 01585 if (IsGeometry(argv[i]) == MagickFalse) 01586 ThrowDisplayInvalidArgumentException(option,argv[i]); 01587 break; 01588 } 01589 if (LocaleCompare("sampling-factor",option+1) == 0) 01590 { 01591 if (*option == '+') 01592 break; 01593 i++; 01594 if (i == (ssize_t) argc) 01595 ThrowDisplayException(OptionError,"MissingArgument",option); 01596 if (IsGeometry(argv[i]) == MagickFalse) 01597 ThrowDisplayInvalidArgumentException(option,argv[i]); 01598 break; 01599 } 01600 if (LocaleCompare("scenes",option+1) == 0) 01601 { 01602 if (*option == '+') 01603 break; 01604 i++; 01605 if (i == (ssize_t) argc) 01606 ThrowDisplayException(OptionError,"MissingArgument",option); 01607 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse) 01608 ThrowDisplayInvalidArgumentException(option,argv[i]); 01609 break; 01610 } 01611 if (LocaleCompare("seed",option+1) == 0) 01612 { 01613 if (*option == '+') 01614 break; 01615 i++; 01616 if (i == (ssize_t) (argc-1)) 01617 ThrowDisplayException(OptionError,"MissingArgument",option); 01618 if (IsGeometry(argv[i]) == MagickFalse) 01619 ThrowDisplayInvalidArgumentException(option,argv[i]); 01620 break; 01621 } 01622 if (LocaleCompare("segment",option+1) == 0) 01623 { 01624 if (*option == '+') 01625 break; 01626 i++; 01627 if (i == (ssize_t) argc) 01628 ThrowDisplayException(OptionError,"MissingArgument",option); 01629 if (IsGeometry(argv[i]) == MagickFalse) 01630 ThrowDisplayInvalidArgumentException(option,argv[i]); 01631 break; 01632 } 01633 if (LocaleCompare("set",option+1) == 0) 01634 { 01635 i++; 01636 if (i == (ssize_t) argc) 01637 ThrowDisplayException(OptionError,"MissingArgument",option); 01638 if (*option == '+') 01639 break; 01640 i++; 01641 if (i == (ssize_t) argc) 01642 ThrowDisplayException(OptionError,"MissingArgument",option); 01643 break; 01644 } 01645 if (LocaleCompare("sharpen",option+1) == 0) 01646 { 01647 if (*option == '+') 01648 break; 01649 i++; 01650 if (i == (ssize_t) argc) 01651 ThrowDisplayException(OptionError,"MissingArgument",option); 01652 if (IsGeometry(argv[i]) == MagickFalse) 01653 ThrowDisplayInvalidArgumentException(option,argv[i]); 01654 break; 01655 } 01656 if (LocaleCompare("shared-memory",option+1) == 0) 01657 { 01658 resource_info.use_shared_memory= (*option == '-') ? MagickTrue : 01659 MagickFalse; 01660 break; 01661 } 01662 if (LocaleCompare("size",option+1) == 0) 01663 { 01664 if (*option == '+') 01665 break; 01666 i++; 01667 if (i == (ssize_t) argc) 01668 ThrowDisplayException(OptionError,"MissingArgument",option); 01669 if (IsGeometry(argv[i]) == MagickFalse) 01670 ThrowDisplayInvalidArgumentException(option,argv[i]); 01671 break; 01672 } 01673 if (LocaleCompare("strip",option+1) == 0) 01674 break; 01675 if (LocaleCompare("support",option+1) == 0) 01676 { 01677 i++; /* deprecated */ 01678 break; 01679 } 01680 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01681 } 01682 case 't': 01683 { 01684 if (LocaleCompare("text-font",option+1) == 0) 01685 { 01686 resource_info.text_font=(char *) NULL; 01687 if (*option == '+') 01688 break; 01689 i++; 01690 if (i == (ssize_t) argc) 01691 ThrowDisplayException(OptionError,"MissingArgument",option); 01692 resource_info.text_font=XGetResourceClass(resource_database, 01693 GetClientName(),"font",argv[i]); 01694 break; 01695 } 01696 if (LocaleCompare("texture",option+1) == 0) 01697 { 01698 if (*option == '+') 01699 break; 01700 i++; 01701 if (i == (ssize_t) argc) 01702 ThrowDisplayException(OptionError,"MissingArgument",option); 01703 break; 01704 } 01705 if (LocaleCompare("threshold",option+1) == 0) 01706 { 01707 if (*option == '+') 01708 break; 01709 i++; 01710 if (i == (ssize_t) argc) 01711 ThrowDisplayException(OptionError,"MissingArgument",option); 01712 if (IsGeometry(argv[i]) == MagickFalse) 01713 ThrowDisplayInvalidArgumentException(option,argv[i]); 01714 break; 01715 } 01716 if (LocaleCompare("thumbnail",option+1) == 0) 01717 { 01718 if (*option == '+') 01719 break; 01720 i++; 01721 if (i == (ssize_t) argc) 01722 ThrowDisplayException(OptionError,"MissingArgument",option); 01723 if (IsGeometry(argv[i]) == MagickFalse) 01724 ThrowDisplayInvalidArgumentException(option,argv[i]); 01725 break; 01726 } 01727 if (LocaleCompare("title",option+1) == 0) 01728 { 01729 resource_info.title=(char *) NULL; 01730 if (*option == '+') 01731 break; 01732 i++; 01733 if (i == (ssize_t) argc) 01734 ThrowDisplayException(OptionError,"MissingArgument",option); 01735 resource_info.title=argv[i]; 01736 break; 01737 } 01738 if (LocaleCompare("transparent-color",option+1) == 0) 01739 { 01740 if (*option == '+') 01741 break; 01742 i++; 01743 if (i == (ssize_t) (argc-1)) 01744 ThrowDisplayException(OptionError,"MissingArgument",option); 01745 break; 01746 } 01747 if (LocaleCompare("treedepth",option+1) == 0) 01748 { 01749 quantize_info->tree_depth=0; 01750 if (*option == '+') 01751 break; 01752 i++; 01753 if (i == (ssize_t) argc) 01754 ThrowDisplayException(OptionError,"MissingArgument",option); 01755 if (IsGeometry(argv[i]) == MagickFalse) 01756 ThrowDisplayInvalidArgumentException(option,argv[i]); 01757 quantize_info->tree_depth=StringToUnsignedLong(argv[i]); 01758 break; 01759 } 01760 if (LocaleCompare("trim",option+1) == 0) 01761 break; 01762 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01763 } 01764 case 'u': 01765 { 01766 if (LocaleCompare("update",option+1) == 0) 01767 { 01768 resource_info.update=(unsigned int) (*option == '-'); 01769 if (*option == '+') 01770 break; 01771 i++; 01772 if (i == (ssize_t) argc) 01773 ThrowDisplayException(OptionError,"MissingArgument",option); 01774 if (IsGeometry(argv[i]) == MagickFalse) 01775 ThrowDisplayInvalidArgumentException(option,argv[i]); 01776 resource_info.update=(unsigned int) StringToUnsignedLong(argv[i]); 01777 break; 01778 } 01779 if (LocaleCompare("use-pixmap",option+1) == 0) 01780 { 01781 resource_info.use_pixmap=(*option == '-') ? MagickTrue : 01782 MagickFalse; 01783 break; 01784 } 01785 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01786 } 01787 case 'v': 01788 { 01789 if (LocaleCompare("verbose",option+1) == 0) 01790 break; 01791 if ((LocaleCompare("version",option+1) == 0) || 01792 (LocaleCompare("-version",option+1) == 0)) 01793 { 01794 (void) FormatLocaleFile(stdout,"Version: %s\n", 01795 GetMagickVersion((size_t *) NULL)); 01796 (void) FormatLocaleFile(stdout,"Copyright: %s\n", 01797 GetMagickCopyright()); 01798 (void) FormatLocaleFile(stdout,"Features: %s\n\n", 01799 GetMagickFeatures()); 01800 break; 01801 } 01802 if (LocaleCompare("visual",option+1) == 0) 01803 { 01804 resource_info.visual_type=(char *) NULL; 01805 if (*option == '+') 01806 break; 01807 i++; 01808 if (i == (ssize_t) argc) 01809 ThrowDisplayException(OptionError,"MissingArgument",option); 01810 resource_info.visual_type=argv[i]; 01811 break; 01812 } 01813 if (LocaleCompare("virtual-pixel",option+1) == 0) 01814 { 01815 ssize_t 01816 method; 01817 01818 if (*option == '+') 01819 break; 01820 i++; 01821 if (i == (ssize_t) (argc-1)) 01822 ThrowDisplayException(OptionError,"MissingArgument",option); 01823 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, 01824 argv[i]); 01825 if (method < 0) 01826 ThrowDisplayException(OptionError, 01827 "UnrecognizedVirtualPixelMethod",argv[i]); 01828 break; 01829 } 01830 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01831 } 01832 case 'w': 01833 { 01834 if (LocaleCompare("window",option+1) == 0) 01835 { 01836 resource_info.window_id=(char *) NULL; 01837 if (*option == '+') 01838 break; 01839 i++; 01840 if (i == (ssize_t) argc) 01841 ThrowDisplayException(OptionError,"MissingArgument",option); 01842 resource_info.window_id=argv[i]; 01843 break; 01844 } 01845 if (LocaleCompare("window-group",option+1) == 0) 01846 { 01847 resource_info.window_group=(char *) NULL; 01848 if (*option == '+') 01849 break; 01850 i++; 01851 if (i == (ssize_t) argc) 01852 ThrowDisplayException(OptionError,"MissingArgument",option); 01853 if (StringToDouble(argv[i],(char **) NULL) != 0) 01854 resource_info.window_group=argv[i]; 01855 break; 01856 } 01857 if (LocaleCompare("write",option+1) == 0) 01858 { 01859 resource_info.write_filename=(char *) NULL; 01860 if (*option == '+') 01861 break; 01862 i++; 01863 if (i == (ssize_t) argc) 01864 ThrowDisplayException(OptionError,"MissingArgument",option); 01865 resource_info.write_filename=argv[i]; 01866 if (IsPathAccessible(resource_info.write_filename) != MagickFalse) 01867 { 01868 char 01869 answer[2], 01870 *p; 01871 01872 (void) FormatLocaleFile(stderr,"Overwrite %s? ", 01873 resource_info.write_filename); 01874 p=fgets(answer,(int) sizeof(answer),stdin); 01875 (void) p; 01876 if (((*answer != 'y') && (*answer != 'Y'))) 01877 return(MagickFalse); 01878 } 01879 break; 01880 } 01881 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01882 } 01883 case '?': 01884 break; 01885 default: 01886 ThrowDisplayException(OptionError,"UnrecognizedOption",option); 01887 } 01888 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & 01889 FireOptionFlag) == 0 ? MagickFalse : MagickTrue; 01890 if (fire != MagickFalse) 01891 FireImageStack(MagickFalse,MagickTrue,MagickTrue); 01892 } 01893 if (k != 0) 01894 ThrowDisplayException(OptionError,"UnbalancedParenthesis",argv[i]); 01895 if (state & RetainColorsState) 01896 { 01897 XRetainWindowColors(display,XRootWindow(display,XDefaultScreen(display))); 01898 (void) XSync(display,MagickFalse); 01899 } 01900 DestroyDisplay(); 01901 return(status != 0 ? MagickTrue : MagickFalse); 01902 #else 01903 (void) argc; 01904 (void) argv; 01905 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError, 01906 "DelegateLibrarySupportNotBuiltIn","`%s' (X11)",image_info->filename); 01907 return(DisplayUsage()); 01908 #endif 01909 }