MagickWand  6.9.13-50
Convert, Edit, Or Compose Bitmap Images
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/license/ %
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 
94 static 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 
242 WandExport 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  char *message = GetExceptionMessage(errno); \
266  (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag, \
267  "`%s'",option == (char *) NULL ? message : option); \
268  message=DestroyString(message); \
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 
293  ImageStack
294  image_stack[MaxImageStackDepth+1];
295 
296  MagickBooleanType
297  fire,
298  nostdin,
299  pend,
300  respect_parenthesis;
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  wand_unreferenced(metadata);
331 
332  /*
333  Set defaults.
334  */
335  assert(image_info != (ImageInfo *) NULL);
336  assert(image_info->signature == MagickCoreSignature);
337  assert(exception != (ExceptionInfo *) NULL);
338  if (IsEventLogging() != MagickFalse)
339  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
340  if (argc == 2)
341  {
342  option=argv[1];
343  if ((LocaleCompare("version",option+1) == 0) ||
344  (LocaleCompare("-version",option+1) == 0))
345  {
346  ListMagickVersion(stdout);
347  return(MagickTrue);
348  }
349  }
350  SetNotifyHandlers;
351  display=(Display *) NULL;
352  j=1;
353  k=0;
354  image_marker=(size_t *) NULL;
355  image_number=0;
356  last_image=0;
357  NewImageStack();
358  option=(char *) NULL;
359  pend=MagickFalse;
360  respect_parenthesis=MagickFalse;
361  nostdin=MagickFalse;
362  resource_database=(XrmDatabase) NULL;
363  (void) memset(&resource_info,0,sizeof(resource_info));
364  server_name=(char *) NULL;
365  state=0;
366  status=MagickTrue;
367  ReadCommandlLine(argc,&argv);
368  status=ExpandFilenames(&argc,&argv);
369  if (status == MagickFalse)
370  ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed",
371  (char *) NULL);
372  image_marker=(size_t *) AcquireQuantumMemory((size_t) argc+1UL,
373  sizeof(*image_marker));
374  if (image_marker == (size_t *) NULL)
375  ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed",
376  (char *) NULL);
377  for (i=0; i <= (ssize_t) argc; i++)
378  image_marker[i]=(size_t) argc;
379  /*
380  Check for server name specified on the command line.
381  */
382  for (i=1; i < (ssize_t) argc; i++)
383  {
384  /*
385  Check command line for server name.
386  */
387  option=argv[i];
388  if (IsCommandOption(option) == MagickFalse)
389  continue;
390  if (LocaleCompare("display",option+1) == 0)
391  {
392  /*
393  User specified server name.
394  */
395  i++;
396  if (i == (ssize_t) argc)
397  ThrowDisplayException(OptionError,"MissingArgument",option);
398  server_name=argv[i];
399  }
400  if (LocaleCompare("nostdin",option+1) == 0)
401  nostdin=MagickTrue;
402  if ((LocaleCompare("help",option+1) == 0) ||
403  (LocaleCompare("-help",option+1) == 0))
404  {
405  DestroyDisplay();
406  return(DisplayUsage());
407  }
408  }
409  /*
410  Get user defaults from X resource database.
411  */
412  display=XOpenDisplay(server_name);
413  if (display == (Display *) NULL)
414  ThrowDisplayException(XServerError,"UnableToOpenXServer",
415  XDisplayName(server_name));
416  (void) XSetErrorHandler(XError);
417  resource_database=XGetResourceDatabase(display,GetClientName());
418  XGetResourceInfo(image_info,resource_database,GetClientName(),
419  &resource_info);
420  quantize_info=resource_info.quantize_info;
421  image_info->density=XGetResourceInstance(resource_database,GetClientName(),
422  "density",(char *) NULL);
423  if (image_info->density == (char *) NULL)
424  image_info->density=XGetScreenDensity(display);
425  resource_value=XGetResourceInstance(resource_database,GetClientName(),
426  "interlace","none");
427  image_info->interlace=(InterlaceType)
428  ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value);
429  image_info->page=XGetResourceInstance(resource_database,GetClientName(),
430  "pageGeometry",(char *) NULL);
431  resource_value=XGetResourceInstance(resource_database,GetClientName(),
432  "quality","75");
433  image_info->quality=StringToUnsignedLong(resource_value);
434  resource_value=XGetResourceInstance(resource_database,GetClientName(),
435  "verbose","False");
436  image_info->verbose=IsMagickTrue(resource_value);
437  resource_value=XGetResourceInstance(resource_database,GetClientName(),
438  "dither","True");
439  quantize_info->dither=IsMagickTrue(resource_value);
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,MaxTextExtent);
494  images=ReadImage(image_info,exception);
495  CatchException(exception);
496  status&=(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  (char *) NULL);
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);
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);
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);
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,MaxTextExtent);
580  (void) SetImageInfo(image_info,1,&display_image->exception);
581  status&=WriteImage(image_info,display_image);
582  GetImageException(display_image,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) &&
604  ((state & ExitState) == 0));
605  /*
606  Free image resources.
607  */
608  display_image=DestroyImageList(display_image);
609  if ((state & FormerImageState) == 0)
610  {
611  last_image=(size_t) image_number;
612  image_marker[i]=(size_t) image_number++;
613  }
614  else
615  {
616  /*
617  Proceed to previous image.
618  */
619  for (i--; i > 0; i--)
620  if (image_marker[i] == (size_t) (image_number-2))
621  break;
622  image_number--;
623  }
624  if ((i == (ssize_t) argc) && ((state & ExitState) == 0))
625  i=0;
626  if ((state & ExitState) != 0)
627  break;
628  /*
629  Determine if we should proceed to the first image.
630  */
631  if (image_number < 0)
632  {
633  if ((state & FormerImageState) != 0)
634  {
635 
636  for (i=1; i < ((ssize_t) argc-2); i++)
637  if (last_image == image_marker[i])
638  break;
639  image_number=(ssize_t) image_marker[i]+1;
640  }
641  continue;
642  }
643  if (resource_info.window_id != (char *) NULL)
644  state|=ExitState;
645  if (iterations != 0)
646  {
647  if (++iteration == (ssize_t) iterations)
648  state|=ExitState;
649  i=0;
650  }
651  if (LocaleCompare(filename,"-") == 0)
652  state|=ExitState;
653  RemoveAllImageStack();
654  continue;
655  }
656  pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
657  switch (*(option+1))
658  {
659  case 'a':
660  {
661  if (LocaleCompare("alpha",option+1) == 0)
662  {
663  ssize_t
664  type;
665 
666  if (*option == '+')
667  break;
668  i++;
669  if (i == (ssize_t) argc)
670  ThrowDisplayException(OptionError,"MissingArgument",option);
671  type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
672  if (type < 0)
673  ThrowDisplayException(OptionError,"UnrecognizedAlphaChannelType",
674  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-orient",option+1) == 0)
689  break;
690  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
691  }
692  case 'b':
693  {
694  if (LocaleCompare("backdrop",option+1) == 0)
695  {
696  resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse;
697  break;
698  }
699  if (LocaleCompare("background",option+1) == 0)
700  {
701  if (*option == '+')
702  break;
703  i++;
704  if (i == (ssize_t) argc)
705  ThrowDisplayException(OptionError,"MissingArgument",option);
706  resource_info.background_color=argv[i];
707  break;
708  }
709  if (LocaleCompare("border",option+1) == 0)
710  {
711  if (*option == '+')
712  break;
713  i++;
714  if (i == (ssize_t) argc)
715  ThrowDisplayException(OptionError,"MissingArgument",option);
716  if (IsGeometry(argv[i]) == MagickFalse)
717  ThrowDisplayInvalidArgumentException(option,argv[i]);
718  break;
719  }
720  if (LocaleCompare("bordercolor",option+1) == 0)
721  {
722  if (*option == '+')
723  break;
724  i++;
725  if (i == (ssize_t) argc)
726  ThrowDisplayException(OptionError,"MissingArgument",option);
727  resource_info.border_color=argv[i];
728  break;
729  }
730  if (LocaleCompare("borderwidth",option+1) == 0)
731  {
732  resource_info.border_width=0;
733  if (*option == '+')
734  break;
735  i++;
736  if (i == (ssize_t) argc)
737  ThrowDisplayException(OptionError,"MissingArgument",option);
738  if (IsGeometry(argv[i]) == MagickFalse)
739  ThrowDisplayInvalidArgumentException(option,argv[i]);
740  resource_info.border_width=(unsigned int)
741  StringToUnsignedLong(argv[i]);
742  break;
743  }
744  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
745  }
746  case 'c':
747  {
748  if (LocaleCompare("cache",option+1) == 0)
749  {
750  if (*option == '+')
751  break;
752  i++;
753  if (i == (ssize_t) argc)
754  ThrowDisplayException(OptionError,"MissingArgument",option);
755  if (IsGeometry(argv[i]) == MagickFalse)
756  ThrowDisplayInvalidArgumentException(option,argv[i]);
757  break;
758  }
759  if (LocaleCompare("channel",option+1) == 0)
760  {
761  ssize_t
762  channel;
763 
764  if (*option == '+')
765  break;
766  i++;
767  if (i == (ssize_t) argc)
768  ThrowDisplayException(OptionError,"MissingArgument",option);
769  channel=ParseChannelOption(argv[i]);
770  if (channel < 0)
771  ThrowDisplayException(OptionError,"UnrecognizedChannelType",
772  argv[i]);
773  break;
774  }
775  if (LocaleCompare("clip",option+1) == 0)
776  break;
777  if (LocaleCompare("clip-path",option+1) == 0)
778  {
779  i++;
780  if (i == (ssize_t) argc)
781  ThrowDisplayException(OptionError,"MissingArgument",option);
782  break;
783  }
784  if (LocaleCompare("coalesce",option+1) == 0)
785  break;
786  if (LocaleCompare("colormap",option+1) == 0)
787  {
788  resource_info.colormap=PrivateColormap;
789  if (*option == '+')
790  break;
791  i++;
792  if (i == (ssize_t) argc)
793  ThrowDisplayException(OptionError,"MissingArgument",option);
794  resource_info.colormap=UndefinedColormap;
795  if (LocaleCompare("private",argv[i]) == 0)
796  resource_info.colormap=PrivateColormap;
797  if (LocaleCompare("shared",argv[i]) == 0)
798  resource_info.colormap=SharedColormap;
799  if (resource_info.colormap == UndefinedColormap)
800  ThrowDisplayException(OptionError,"UnrecognizedColormapType",
801  argv[i]);
802  break;
803  }
804  if (LocaleCompare("colors",option+1) == 0)
805  {
806  quantize_info->number_colors=0;
807  if (*option == '+')
808  break;
809  i++;
810  if (i == (ssize_t) argc)
811  ThrowDisplayException(OptionError,"MissingArgument",option);
812  if (IsGeometry(argv[i]) == MagickFalse)
813  ThrowDisplayInvalidArgumentException(option,argv[i]);
814  quantize_info->number_colors=StringToUnsignedLong(argv[i]);
815  break;
816  }
817  if (LocaleCompare("colorspace",option+1) == 0)
818  {
819  ssize_t
820  colorspace;
821 
822  if (*option == '+')
823  break;
824  i++;
825  if (i == (ssize_t) argc)
826  ThrowDisplayException(OptionError,"MissingArgument",option);
827  colorspace=ParseCommandOption(MagickColorspaceOptions,
828  MagickFalse,argv[i]);
829  if (colorspace < 0)
830  ThrowDisplayException(OptionError,"UnrecognizedColorspace",
831  argv[i]);
832  break;
833  }
834  if (LocaleCompare("comment",option+1) == 0)
835  {
836  if (*option == '+')
837  break;
838  i++;
839  if (i == (ssize_t) argc)
840  ThrowDisplayException(OptionError,"MissingArgument",option);
841  break;
842  }
843  if (LocaleCompare("compress",option+1) == 0)
844  {
845  ssize_t
846  compress;
847 
848  if (*option == '+')
849  break;
850  i++;
851  if (i == (ssize_t) argc)
852  ThrowDisplayException(OptionError,"MissingArgument",option);
853  compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
854  argv[i]);
855  if (compress < 0)
856  ThrowDisplayException(OptionError,"UnrecognizedImageCompression",
857  argv[i]);
858  break;
859  }
860  if (LocaleCompare("concurrent",option+1) == 0)
861  break;
862  if (LocaleCompare("contrast",option+1) == 0)
863  break;
864  if (LocaleCompare("crop",option+1) == 0)
865  {
866  if (*option == '+')
867  break;
868  i++;
869  if (i == (ssize_t) argc)
870  ThrowDisplayException(OptionError,"MissingArgument",option);
871  if (IsGeometry(argv[i]) == MagickFalse)
872  ThrowDisplayInvalidArgumentException(option,argv[i]);
873  break;
874  }
875  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
876  }
877  case 'd':
878  {
879  if (LocaleCompare("debug",option+1) == 0)
880  {
881  ssize_t
882  event;
883 
884  if (*option == '+')
885  break;
886  i++;
887  if (i == (ssize_t) argc)
888  ThrowDisplayException(OptionError,"MissingArgument",option);
889  event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
890  if (event < 0)
891  ThrowDisplayException(OptionError,"UnrecognizedEventType",
892  argv[i]);
893  (void) SetLogEventMask(argv[i]);
894  break;
895  }
896  if (LocaleCompare("decipher",option+1) == 0)
897  {
898  if (*option == '+')
899  break;
900  i++;
901  if (i == (ssize_t) argc)
902  ThrowDisplayException(OptionError,"MissingArgument",option);
903  break;
904  }
905  if (LocaleCompare("define",option+1) == 0)
906  {
907  i++;
908  if (i == (ssize_t) argc)
909  ThrowDisplayException(OptionError,"MissingArgument",option);
910  if (*option == '+')
911  {
912  const char
913  *define;
914 
915  define=GetImageOption(image_info,argv[i]);
916  if (define == (const char *) NULL)
917  ThrowDisplayException(OptionError,"NoSuchOption",argv[i]);
918  break;
919  }
920  break;
921  }
922  if (LocaleCompare("delay",option+1) == 0)
923  {
924  if (*option == '+')
925  break;
926  i++;
927  if (i == (ssize_t) argc)
928  ThrowDisplayException(OptionError,"MissingArgument",option);
929  if (IsGeometry(argv[i]) == MagickFalse)
930  ThrowDisplayInvalidArgumentException(option,argv[i]);
931  break;
932  }
933  if (LocaleCompare("density",option+1) == 0)
934  {
935  if (*option == '+')
936  break;
937  i++;
938  if (i == (ssize_t) argc)
939  ThrowDisplayException(OptionError,"MissingArgument",option);
940  if (IsGeometry(argv[i]) == MagickFalse)
941  ThrowDisplayInvalidArgumentException(option,argv[i]);
942  break;
943  }
944  if (LocaleCompare("depth",option+1) == 0)
945  {
946  if (*option == '+')
947  break;
948  i++;
949  if (i == (ssize_t) argc)
950  ThrowDisplayException(OptionError,"MissingArgument",option);
951  if (IsGeometry(argv[i]) == MagickFalse)
952  ThrowDisplayInvalidArgumentException(option,argv[i]);
953  break;
954  }
955  if (LocaleCompare("deskew",option+1) == 0)
956  {
957  if (*option == '+')
958  break;
959  i++;
960  if (i == (ssize_t) argc)
961  ThrowDisplayException(OptionError,"MissingArgument",option);
962  if (IsGeometry(argv[i]) == MagickFalse)
963  ThrowDisplayInvalidArgumentException(option,argv[i]);
964  break;
965  }
966  if (LocaleCompare("despeckle",option+1) == 0)
967  break;
968  if (LocaleCompare("display",option+1) == 0)
969  {
970  if (*option == '+')
971  break;
972  i++;
973  if (i == (ssize_t) argc)
974  ThrowDisplayException(OptionError,"MissingArgument",option);
975  break;
976  }
977  if (LocaleCompare("dispose",option+1) == 0)
978  {
979  ssize_t
980  dispose;
981 
982  if (*option == '+')
983  break;
984  i++;
985  if (i == (ssize_t) argc)
986  ThrowDisplayException(OptionError,"MissingArgument",option);
987  dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
988  if (dispose < 0)
989  ThrowDisplayException(OptionError,"UnrecognizedDisposeMethod",
990  argv[i]);
991  break;
992  }
993  if (LocaleCompare("dither",option+1) == 0)
994  {
995  ssize_t
996  method;
997 
998  quantize_info->dither=MagickFalse;
999  if (*option == '+')
1000  break;
1001  i++;
1002  if (i == (ssize_t) argc)
1003  ThrowDisplayException(OptionError,"MissingArgument",option);
1004  method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
1005  if (method < 0)
1006  ThrowDisplayException(OptionError,"UnrecognizedDitherMethod",
1007  argv[i]);
1008  quantize_info->dither=MagickTrue;
1009  quantize_info->dither_method=(DitherMethod) method;
1010  break;
1011  }
1012  if (LocaleCompare("duration",option+1) == 0)
1013  {
1014  if (*option == '+')
1015  break;
1016  i++;
1017  if (i == (ssize_t) argc)
1018  ThrowDisplayException(OptionError,"MissingArgument",option);
1019  if (IsGeometry(argv[i]) == MagickFalse)
1020  ThrowDisplayInvalidArgumentException(option,argv[i]);
1021  break;
1022  }
1023  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1024  }
1025  case 'e':
1026  {
1027  if (LocaleCompare("edge",option+1) == 0)
1028  {
1029  if (*option == '+')
1030  break;
1031  i++;
1032  if (i == (ssize_t) argc)
1033  ThrowDisplayException(OptionError,"MissingArgument",option);
1034  if (IsGeometry(argv[i]) == MagickFalse)
1035  ThrowDisplayInvalidArgumentException(option,argv[i]);
1036  break;
1037  }
1038  if (LocaleCompare("endian",option+1) == 0)
1039  {
1040  ssize_t
1041  endian;
1042 
1043  if (*option == '+')
1044  break;
1045  i++;
1046  if (i == (ssize_t) argc)
1047  ThrowDisplayException(OptionError,"MissingArgument",option);
1048  endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
1049  argv[i]);
1050  if (endian < 0)
1051  ThrowDisplayException(OptionError,"UnrecognizedEndianType",
1052  argv[i]);
1053  break;
1054  }
1055  if (LocaleCompare("enhance",option+1) == 0)
1056  break;
1057  if (LocaleCompare("equalize",option+1) == 0)
1058  break;
1059  if (LocaleCompare("extract",option+1) == 0)
1060  {
1061  if (*option == '+')
1062  break;
1063  i++;
1064  if (i == (ssize_t) argc)
1065  ThrowDisplayException(OptionError,"MissingArgument",option);
1066  if (IsGeometry(argv[i]) == MagickFalse)
1067  ThrowDisplayInvalidArgumentException(option,argv[i]);
1068  break;
1069  }
1070  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1071  }
1072  case 'f':
1073  {
1074  if (LocaleCompare("filter",option+1) == 0)
1075  {
1076  ssize_t
1077  filter;
1078 
1079  if (*option == '+')
1080  break;
1081  i++;
1082  if (i == (ssize_t) argc)
1083  ThrowDisplayException(OptionError,"MissingArgument",option);
1084  filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
1085  if (filter < 0)
1086  ThrowDisplayException(OptionError,"UnrecognizedImageFilter",
1087  argv[i]);
1088  break;
1089  }
1090  if (LocaleCompare("flatten",option+1) == 0)
1091  break;
1092  if (LocaleCompare("flip",option+1) == 0)
1093  break;
1094  if (LocaleCompare("flop",option+1) == 0)
1095  break;
1096  if (LocaleCompare("font",option+1) == 0)
1097  {
1098  if (*option == '+')
1099  break;
1100  i++;
1101  if (i == (ssize_t) argc)
1102  ThrowDisplayException(OptionError,"MissingArgument",option);
1103  resource_info.font=XGetResourceClass(resource_database,
1104  GetClientName(),"font",argv[i]);
1105  break;
1106  }
1107  if (LocaleCompare("foreground",option+1) == 0)
1108  {
1109  if (*option == '+')
1110  break;
1111  i++;
1112  if (i == (ssize_t) argc)
1113  ThrowDisplayException(OptionError,"MissingArgument",option);
1114  resource_info.foreground_color=argv[i];
1115  break;
1116  }
1117  if (LocaleCompare("format",option+1) == 0)
1118  {
1119  if (*option == '+')
1120  break;
1121  i++;
1122  if (i == (ssize_t) argc)
1123  ThrowDisplayException(OptionError,"MissingArgument",option);
1124  break;
1125  }
1126  if (LocaleCompare("frame",option+1) == 0)
1127  {
1128  if (*option == '+')
1129  break;
1130  i++;
1131  if (i == (ssize_t) argc)
1132  ThrowDisplayException(OptionError,"MissingArgument",option);
1133  if (IsGeometry(argv[i]) == MagickFalse)
1134  ThrowDisplayInvalidArgumentException(option,argv[i]);
1135  break;
1136  }
1137  if (LocaleCompare("fuzz",option+1) == 0)
1138  {
1139  if (*option == '+')
1140  break;
1141  i++;
1142  if (i == (ssize_t) argc)
1143  ThrowDisplayException(OptionError,"MissingArgument",option);
1144  if (IsGeometry(argv[i]) == MagickFalse)
1145  ThrowDisplayInvalidArgumentException(option,argv[i]);
1146  break;
1147  }
1148  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1149  }
1150  case 'g':
1151  {
1152  if (LocaleCompare("gamma",option+1) == 0)
1153  {
1154  i++;
1155  if (i == (ssize_t) argc)
1156  ThrowDisplayException(OptionError,"MissingArgument",option);
1157  if (IsGeometry(argv[i]) == MagickFalse)
1158  ThrowDisplayInvalidArgumentException(option,argv[i]);
1159  break;
1160  }
1161  if (LocaleCompare("geometry",option+1) == 0)
1162  {
1163  resource_info.image_geometry=(char *) NULL;
1164  if (*option == '+')
1165  break;
1166  (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
1167  i++;
1168  if (i == (ssize_t) argc)
1169  ThrowDisplayException(OptionError,"MissingArgument",option);
1170  if (IsGeometry(argv[i]) == MagickFalse)
1171  ThrowDisplayInvalidArgumentException(option,argv[i]);
1172  resource_info.image_geometry=ConstantString(argv[i]);
1173  break;
1174  }
1175  if (LocaleCompare("gravity",option+1) == 0)
1176  {
1177  ssize_t
1178  gravity;
1179 
1180  if (*option == '+')
1181  break;
1182  i++;
1183  if (i == (ssize_t) argc)
1184  ThrowDisplayException(OptionError,"MissingArgument",option);
1185  gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
1186  argv[i]);
1187  if (gravity < 0)
1188  ThrowDisplayException(OptionError,"UnrecognizedGravityType",
1189  argv[i]);
1190  break;
1191  }
1192  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1193  }
1194  case 'h':
1195  {
1196  if ((LocaleCompare("help",option+1) == 0) ||
1197  (LocaleCompare("-help",option+1) == 0))
1198  break;
1199  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1200  }
1201  case 'i':
1202  {
1203  if (LocaleCompare("identify",option+1) == 0)
1204  break;
1205  if (LocaleCompare("iconGeometry",option+1) == 0)
1206  {
1207  resource_info.icon_geometry=(char *) NULL;
1208  if (*option == '+')
1209  break;
1210  i++;
1211  if (i == (ssize_t) argc)
1212  ThrowDisplayException(OptionError,"MissingArgument",option);
1213  if (IsGeometry(argv[i]) == MagickFalse)
1214  ThrowDisplayInvalidArgumentException(option,argv[i]);
1215  resource_info.icon_geometry=argv[i];
1216  break;
1217  }
1218  if (LocaleCompare("iconic",option+1) == 0)
1219  {
1220  resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
1221  break;
1222  }
1223  if (LocaleCompare("immutable",option+1) == 0)
1224  {
1225  resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
1226  break;
1227  }
1228  if (LocaleCompare("interlace",option+1) == 0)
1229  {
1230  ssize_t
1231  interlace;
1232 
1233  if (*option == '+')
1234  break;
1235  i++;
1236  if (i == (ssize_t) argc)
1237  ThrowDisplayException(OptionError,"MissingArgument",option);
1238  interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
1239  argv[i]);
1240  if (interlace < 0)
1241  ThrowDisplayException(OptionError,"UnrecognizedInterlaceType",
1242  argv[i]);
1243  break;
1244  }
1245  if (LocaleCompare("interpolate",option+1) == 0)
1246  {
1247  ssize_t
1248  interpolate;
1249 
1250  if (*option == '+')
1251  break;
1252  i++;
1253  if (i == (ssize_t) argc)
1254  ThrowDisplayException(OptionError,"MissingArgument",option);
1255  interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
1256  argv[i]);
1257  if (interpolate < 0)
1258  ThrowDisplayException(OptionError,"UnrecognizedInterpolateMethod",
1259  argv[i]);
1260  break;
1261  }
1262  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1263  }
1264  case 'l':
1265  {
1266  if (LocaleCompare("label",option+1) == 0)
1267  {
1268  if (*option == '+')
1269  break;
1270  i++;
1271  if (i == (ssize_t) argc)
1272  ThrowDisplayException(OptionError,"MissingArgument",option);
1273  break;
1274  }
1275  if (LocaleCompare("limit",option+1) == 0)
1276  {
1277  char
1278  *p;
1279 
1280  double
1281  value;
1282 
1283  ssize_t
1284  resource;
1285 
1286  if (*option == '+')
1287  break;
1288  i++;
1289  if (i == (ssize_t) argc)
1290  ThrowDisplayException(OptionError,"MissingArgument",option);
1291  resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
1292  argv[i]);
1293  if (resource < 0)
1294  ThrowDisplayException(OptionError,"UnrecognizedResourceType",
1295  argv[i]);
1296  i++;
1297  if (i == (ssize_t) argc)
1298  ThrowDisplayException(OptionError,"MissingArgument",option);
1299  value=StringToDouble(argv[i],&p);
1300  (void) value;
1301  if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1302  ThrowDisplayInvalidArgumentException(option,argv[i]);
1303  break;
1304  }
1305  if (LocaleCompare("list",option+1) == 0)
1306  {
1307  ssize_t
1308  list;
1309 
1310  if (*option == '+')
1311  break;
1312  i++;
1313  if (i == (ssize_t) argc)
1314  ThrowDisplayException(OptionError,"MissingArgument",option);
1315  list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
1316  if (list < 0)
1317  ThrowDisplayException(OptionError,"UnrecognizedListType",argv[i]);
1318  status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
1319  argv+j,exception);
1320  DestroyDisplay();
1321  return(status == 0 ? MagickFalse : MagickTrue);
1322  }
1323  if (LocaleCompare("log",option+1) == 0)
1324  {
1325  if (*option == '+')
1326  break;
1327  i++;
1328  if ((i == (ssize_t) argc) ||
1329  (strchr(argv[i],'%') == (char *) NULL))
1330  ThrowDisplayException(OptionError,"MissingArgument",option);
1331  break;
1332  }
1333  if (LocaleCompare("loop",option+1) == 0)
1334  {
1335  if (*option == '+')
1336  break;
1337  i++;
1338  if (i == (ssize_t) argc)
1339  ThrowDisplayException(OptionError,"MissingArgument",option);
1340  if (IsGeometry(argv[i]) == MagickFalse)
1341  ThrowDisplayInvalidArgumentException(option,argv[i]);
1342  iterations=StringToUnsignedLong(argv[i]);
1343  break;
1344  }
1345  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1346  }
1347  case 'm':
1348  {
1349  if (LocaleCompare("magnify",option+1) == 0)
1350  {
1351  resource_info.magnify=2;
1352  if (*option == '+')
1353  break;
1354  i++;
1355  if (i == (ssize_t) argc)
1356  ThrowDisplayException(OptionError,"MissingArgument",option);
1357  if (IsGeometry(argv[i]) == MagickFalse)
1358  ThrowDisplayInvalidArgumentException(option,argv[i]);
1359  resource_info.magnify=(unsigned int) StringToUnsignedLong(argv[i]);
1360  break;
1361  }
1362  if (LocaleCompare("map",option+1) == 0)
1363  {
1364  resource_info.map_type=(char *) NULL;
1365  if (*option == '+')
1366  break;
1367  (void) CopyMagickString(argv[i]+1,"sans",strlen(argv[i]+1)+1);
1368  i++;
1369  if (i == (ssize_t) argc)
1370  ThrowDisplayException(OptionError,"MissingArgument",option);
1371  resource_info.map_type=argv[i];
1372  break;
1373  }
1374  if (LocaleCompare("matte",option+1) == 0)
1375  break;
1376  if (LocaleCompare("mattecolor",option+1) == 0)
1377  {
1378  if (*option == '+')
1379  break;
1380  i++;
1381  if (i == (ssize_t) argc)
1382  ThrowDisplayException(OptionError,"MissingArgument",option);
1383  resource_info.matte_color=argv[i];
1384  break;
1385  }
1386  if (LocaleCompare("monitor",option+1) == 0)
1387  break;
1388  if (LocaleCompare("monochrome",option+1) == 0)
1389  {
1390  if (*option == '+')
1391  break;
1392  quantize_info->number_colors=2;
1393  quantize_info->colorspace=GRAYColorspace;
1394  break;
1395  }
1396  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1397  }
1398  case 'n':
1399  {
1400  if (LocaleCompare("name",option+1) == 0)
1401  {
1402  resource_info.name=(char *) NULL;
1403  if (*option == '+')
1404  break;
1405  i++;
1406  if (i == (ssize_t) argc)
1407  ThrowDisplayException(OptionError,"MissingArgument",option);
1408  resource_info.name=ConstantString(argv[i]);
1409  break;
1410  }
1411  if (LocaleCompare("negate",option+1) == 0)
1412  break;
1413  if (LocaleCompare("noop",option+1) == 0)
1414  break;
1415  if (LocaleCompare("normalize",option+1) == 0)
1416  break;
1417  if (LocaleCompare("nostdin",option+1) == 0)
1418  break;
1419  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1420  }
1421  case 'p':
1422  {
1423  if (LocaleCompare("page",option+1) == 0)
1424  {
1425  resource_info.image_geometry=(char *) NULL;
1426  if (*option == '+')
1427  break;
1428  i++;
1429  if (i == (ssize_t) argc)
1430  ThrowDisplayException(OptionError,"MissingArgument",option);
1431  resource_info.image_geometry=ConstantString(argv[i]);
1432  break;
1433  }
1434  if (LocaleCompare("profile",option+1) == 0)
1435  {
1436  i++;
1437  if (i == (ssize_t) argc)
1438  ThrowDisplayException(OptionError,"MissingArgument",option);
1439  break;
1440  }
1441  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1442  }
1443  case 'q':
1444  {
1445  if (LocaleCompare("quality",option+1) == 0)
1446  {
1447  if (*option == '+')
1448  break;
1449  i++;
1450  if (i == (ssize_t) argc)
1451  ThrowDisplayException(OptionError,"MissingArgument",option);
1452  if (IsGeometry(argv[i]) == MagickFalse)
1453  ThrowDisplayInvalidArgumentException(option,argv[i]);
1454  break;
1455  }
1456  if (LocaleCompare("quantize",option+1) == 0)
1457  {
1458  ssize_t
1459  colorspace;
1460 
1461  if (*option == '+')
1462  break;
1463  i++;
1464  if (i == (ssize_t) argc)
1465  ThrowDisplayException(OptionError,"MissingArgument",option);
1466  colorspace=ParseCommandOption(MagickColorspaceOptions,
1467  MagickFalse,argv[i]);
1468  if (colorspace < 0)
1469  ThrowDisplayException(OptionError,"UnrecognizedColorspace",
1470  argv[i]);
1471  break;
1472  }
1473  if (LocaleCompare("quiet",option+1) == 0)
1474  break;
1475  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1476  }
1477  case 'r':
1478  {
1479  if (LocaleCompare("raise",option+1) == 0)
1480  {
1481  i++;
1482  if (i == (ssize_t) argc)
1483  ThrowDisplayException(OptionError,"MissingArgument",option);
1484  if (IsGeometry(argv[i]) == MagickFalse)
1485  ThrowDisplayInvalidArgumentException(option,argv[i]);
1486  break;
1487  }
1488  if (LocaleCompare("regard-warnings",option+1) == 0)
1489  break;
1490  if (LocaleCompare("remote",option+1) == 0)
1491  {
1492  i++;
1493  if (i == (ssize_t) argc)
1494  ThrowDisplayException(OptionError,"MissingArgument",option);
1495  if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1496  {
1497  DestroyDisplay();
1498  return(MagickFalse);
1499  }
1500  i--;
1501  break;
1502  }
1503  if (LocaleCompare("repage",option+1) == 0)
1504  {
1505  if (*option == '+')
1506  break;
1507  i++;
1508  if (i == (ssize_t) argc)
1509  ThrowDisplayException(OptionError,"MissingArgument",option);
1510  if (IsGeometry(argv[i]) == MagickFalse)
1511  ThrowDisplayInvalidArgumentException(option,argv[i]);
1512  break;
1513  }
1514  if (LocaleCompare("resample",option+1) == 0)
1515  {
1516  if (*option == '+')
1517  break;
1518  i++;
1519  if (i == (ssize_t) argc)
1520  ThrowDisplayException(OptionError,"MissingArgument",option);
1521  if (IsGeometry(argv[i]) == MagickFalse)
1522  ThrowDisplayInvalidArgumentException(option,argv[i]);
1523  break;
1524  }
1525  if (LocaleCompare("resize",option+1) == 0)
1526  {
1527  if (*option == '+')
1528  break;
1529  i++;
1530  if (i == (ssize_t) argc)
1531  ThrowDisplayException(OptionError,"MissingArgument",option);
1532  if (IsGeometry(argv[i]) == MagickFalse)
1533  ThrowDisplayInvalidArgumentException(option,argv[i]);
1534  break;
1535  }
1536  if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1537  {
1538  respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1539  break;
1540  }
1541  if (LocaleCompare("roll",option+1) == 0)
1542  {
1543  if (*option == '+')
1544  break;
1545  i++;
1546  if (i == (ssize_t) argc)
1547  ThrowDisplayException(OptionError,"MissingArgument",option);
1548  if (IsGeometry(argv[i]) == MagickFalse)
1549  ThrowDisplayInvalidArgumentException(option,argv[i]);
1550  break;
1551  }
1552  if (LocaleCompare("rotate",option+1) == 0)
1553  {
1554  i++;
1555  if (i == (ssize_t) argc)
1556  ThrowDisplayException(OptionError,"MissingArgument",option);
1557  if (IsGeometry(argv[i]) == MagickFalse)
1558  ThrowDisplayInvalidArgumentException(option,argv[i]);
1559  break;
1560  }
1561  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1562  }
1563  case 's':
1564  {
1565  if (LocaleCompare("sample",option+1) == 0)
1566  {
1567  if (*option == '+')
1568  break;
1569  i++;
1570  if (i == (ssize_t) argc)
1571  ThrowDisplayException(OptionError,"MissingArgument",option);
1572  if (IsGeometry(argv[i]) == MagickFalse)
1573  ThrowDisplayInvalidArgumentException(option,argv[i]);
1574  break;
1575  }
1576  if (LocaleCompare("sampling-factor",option+1) == 0)
1577  {
1578  if (*option == '+')
1579  break;
1580  i++;
1581  if (i == (ssize_t) argc)
1582  ThrowDisplayException(OptionError,"MissingArgument",option);
1583  if (IsGeometry(argv[i]) == MagickFalse)
1584  ThrowDisplayInvalidArgumentException(option,argv[i]);
1585  break;
1586  }
1587  if (LocaleCompare("scenes",option+1) == 0)
1588  {
1589  if (*option == '+')
1590  break;
1591  i++;
1592  if (i == (ssize_t) argc)
1593  ThrowDisplayException(OptionError,"MissingArgument",option);
1594  if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1595  ThrowDisplayInvalidArgumentException(option,argv[i]);
1596  break;
1597  }
1598  if (LocaleCompare("seed",option+1) == 0)
1599  {
1600  if (*option == '+')
1601  break;
1602  i++;
1603  if (i == (ssize_t) argc)
1604  ThrowDisplayException(OptionError,"MissingArgument",option);
1605  if (IsGeometry(argv[i]) == MagickFalse)
1606  ThrowDisplayInvalidArgumentException(option,argv[i]);
1607  break;
1608  }
1609  if (LocaleCompare("segment",option+1) == 0)
1610  {
1611  if (*option == '+')
1612  break;
1613  i++;
1614  if (i == (ssize_t) argc)
1615  ThrowDisplayException(OptionError,"MissingArgument",option);
1616  if (IsGeometry(argv[i]) == MagickFalse)
1617  ThrowDisplayInvalidArgumentException(option,argv[i]);
1618  break;
1619  }
1620  if (LocaleCompare("set",option+1) == 0)
1621  {
1622  i++;
1623  if (i == (ssize_t) argc)
1624  ThrowDisplayException(OptionError,"MissingArgument",option);
1625  if (*option == '+')
1626  break;
1627  i++;
1628  if (i == (ssize_t) argc)
1629  ThrowDisplayException(OptionError,"MissingArgument",option);
1630  break;
1631  }
1632  if (LocaleCompare("sharpen",option+1) == 0)
1633  {
1634  if (*option == '+')
1635  break;
1636  i++;
1637  if (i == (ssize_t) argc)
1638  ThrowDisplayException(OptionError,"MissingArgument",option);
1639  if (IsGeometry(argv[i]) == MagickFalse)
1640  ThrowDisplayInvalidArgumentException(option,argv[i]);
1641  break;
1642  }
1643  if (LocaleCompare("shared-memory",option+1) == 0)
1644  {
1645  resource_info.use_shared_memory= (*option == '-') ? MagickTrue :
1646  MagickFalse;
1647  break;
1648  }
1649  if (LocaleCompare("size",option+1) == 0)
1650  {
1651  if (*option == '+')
1652  break;
1653  i++;
1654  if (i == (ssize_t) argc)
1655  ThrowDisplayException(OptionError,"MissingArgument",option);
1656  if (IsGeometry(argv[i]) == MagickFalse)
1657  ThrowDisplayInvalidArgumentException(option,argv[i]);
1658  break;
1659  }
1660  if (LocaleCompare("strip",option+1) == 0)
1661  break;
1662  if (LocaleCompare("support",option+1) == 0)
1663  {
1664  i++; /* deprecated */
1665  break;
1666  }
1667  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1668  }
1669  case 't':
1670  {
1671  if (LocaleCompare("text-font",option+1) == 0)
1672  {
1673  resource_info.text_font=(char *) NULL;
1674  if (*option == '+')
1675  break;
1676  i++;
1677  if (i == (ssize_t) argc)
1678  ThrowDisplayException(OptionError,"MissingArgument",option);
1679  resource_info.text_font=XGetResourceClass(resource_database,
1680  GetClientName(),"font",argv[i]);
1681  break;
1682  }
1683  if (LocaleCompare("texture",option+1) == 0)
1684  {
1685  if (*option == '+')
1686  break;
1687  i++;
1688  if (i == (ssize_t) argc)
1689  ThrowDisplayException(OptionError,"MissingArgument",option);
1690  break;
1691  }
1692  if (LocaleCompare("threshold",option+1) == 0)
1693  {
1694  if (*option == '+')
1695  break;
1696  i++;
1697  if (i == (ssize_t) argc)
1698  ThrowDisplayException(OptionError,"MissingArgument",option);
1699  if (IsGeometry(argv[i]) == MagickFalse)
1700  ThrowDisplayInvalidArgumentException(option,argv[i]);
1701  break;
1702  }
1703  if (LocaleCompare("thumbnail",option+1) == 0)
1704  {
1705  if (*option == '+')
1706  break;
1707  i++;
1708  if (i == (ssize_t) argc)
1709  ThrowDisplayException(OptionError,"MissingArgument",option);
1710  if (IsGeometry(argv[i]) == MagickFalse)
1711  ThrowDisplayInvalidArgumentException(option,argv[i]);
1712  break;
1713  }
1714  if (LocaleCompare("title",option+1) == 0)
1715  {
1716  resource_info.title=(char *) NULL;
1717  if (*option == '+')
1718  break;
1719  i++;
1720  if (i == (ssize_t) argc)
1721  ThrowDisplayException(OptionError,"MissingArgument",option);
1722  resource_info.title=argv[i];
1723  break;
1724  }
1725  if (LocaleCompare("transparent-color",option+1) == 0)
1726  {
1727  if (*option == '+')
1728  break;
1729  i++;
1730  if (i == (ssize_t) argc)
1731  ThrowDisplayException(OptionError,"MissingArgument",option);
1732  break;
1733  }
1734  if (LocaleCompare("treedepth",option+1) == 0)
1735  {
1736  quantize_info->tree_depth=0;
1737  if (*option == '+')
1738  break;
1739  i++;
1740  if (i == (ssize_t) argc)
1741  ThrowDisplayException(OptionError,"MissingArgument",option);
1742  if (IsGeometry(argv[i]) == MagickFalse)
1743  ThrowDisplayInvalidArgumentException(option,argv[i]);
1744  quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1745  break;
1746  }
1747  if (LocaleCompare("trim",option+1) == 0)
1748  break;
1749  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1750  }
1751  case 'u':
1752  {
1753  if (LocaleCompare("update",option+1) == 0)
1754  {
1755  resource_info.update=(unsigned int) (*option == '-');
1756  if (*option == '+')
1757  break;
1758  i++;
1759  if (i == (ssize_t) argc)
1760  ThrowDisplayException(OptionError,"MissingArgument",option);
1761  if (IsGeometry(argv[i]) == MagickFalse)
1762  ThrowDisplayInvalidArgumentException(option,argv[i]);
1763  resource_info.update=(unsigned int) StringToUnsignedLong(argv[i]);
1764  break;
1765  }
1766  if (LocaleCompare("use-pixmap",option+1) == 0)
1767  {
1768  resource_info.use_pixmap=(*option == '-') ? MagickTrue :
1769  MagickFalse;
1770  break;
1771  }
1772  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1773  }
1774  case 'v':
1775  {
1776  if (LocaleCompare("verbose",option+1) == 0)
1777  break;
1778  if ((LocaleCompare("version",option+1) == 0) ||
1779  (LocaleCompare("-version",option+1) == 0))
1780  {
1781  ListMagickVersion(stdout);
1782  break;
1783  }
1784  if (LocaleCompare("visual",option+1) == 0)
1785  {
1786  resource_info.visual_type=(char *) NULL;
1787  if (*option == '+')
1788  break;
1789  i++;
1790  if (i == (ssize_t) argc)
1791  ThrowDisplayException(OptionError,"MissingArgument",option);
1792  resource_info.visual_type=argv[i];
1793  break;
1794  }
1795  if (LocaleCompare("virtual-pixel",option+1) == 0)
1796  {
1797  ssize_t
1798  method;
1799 
1800  if (*option == '+')
1801  break;
1802  i++;
1803  if (i == (ssize_t) argc)
1804  ThrowDisplayException(OptionError,"MissingArgument",option);
1805  method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
1806  argv[i]);
1807  if (method < 0)
1808  ThrowDisplayException(OptionError,
1809  "UnrecognizedVirtualPixelMethod",argv[i]);
1810  break;
1811  }
1812  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1813  }
1814  case 'w':
1815  {
1816  if (LocaleCompare("window",option+1) == 0)
1817  {
1818  resource_info.window_id=(char *) NULL;
1819  if (*option == '+')
1820  break;
1821  i++;
1822  if (i == (ssize_t) argc)
1823  ThrowDisplayException(OptionError,"MissingArgument",option);
1824  resource_info.window_id=argv[i];
1825  break;
1826  }
1827  if (LocaleCompare("window-group",option+1) == 0)
1828  {
1829  resource_info.window_group=(char *) NULL;
1830  if (*option == '+')
1831  break;
1832  i++;
1833  if (i == (ssize_t) argc)
1834  ThrowDisplayException(OptionError,"MissingArgument",option);
1835  if (StringToDouble(argv[i],(char **) NULL) != 0)
1836  resource_info.window_group=argv[i];
1837  break;
1838  }
1839  if (LocaleCompare("write",option+1) == 0)
1840  {
1841  resource_info.write_filename=(char *) NULL;
1842  if (*option == '+')
1843  break;
1844  i++;
1845  if (i == (ssize_t) argc)
1846  ThrowDisplayException(OptionError,"MissingArgument",option);
1847  resource_info.write_filename=argv[i];
1848  if (IsPathAccessible(resource_info.write_filename) != MagickFalse)
1849  {
1850  char
1851  answer[2],
1852  *p;
1853 
1854  (void) FormatLocaleFile(stderr,"Overwrite %s? ",
1855  resource_info.write_filename);
1856  p=fgets(answer,(int) sizeof(answer),stdin);
1857  (void) p;
1858  if (((*answer != 'y') && (*answer != 'Y')))
1859  return(MagickFalse);
1860  }
1861  break;
1862  }
1863  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1864  }
1865  case '?':
1866  break;
1867  default:
1868  ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1869  }
1870  fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1871  FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1872  if (fire != MagickFalse)
1873  FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1874  }
1875  if (k != 0)
1876  ThrowDisplayException(OptionError,"UnbalancedParenthesis",argv[i]);
1877  if (state & RetainColorsState)
1878  {
1879  XRetainWindowColors(display,XRootWindow(display,XDefaultScreen(display)));
1880  (void) XSync(display,MagickFalse);
1881  }
1882  DestroyDisplay();
1883  return(status != 0 ? MagickTrue : MagickFalse);
1884 #else
1885  magick_unreferenced(argc);
1886  magick_unreferenced(argv);
1887  magick_unreferenced(metadata);
1888 
1889  (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1890  "DelegateLibrarySupportNotBuiltIn","`%s' (X11)",image_info->filename);
1891  return(DisplayUsage());
1892 #endif
1893 }