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