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