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