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