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