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