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