blob: efac20d04c3176d00d0e9f78bc79a9eccbece7d0 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
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% John Cristy %
17% July 1992 %
18% %
19% %
cristy1454be72011-12-19 01:52:48 +000020% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% 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*/
cristy4c08aed2011-07-01 19:47:50 +000044#include "MagickWand/studio.h"
45#include "MagickWand/MagickWand.h"
46#include "MagickWand/mogrify-private.h"
47#include "MagickCore/display-private.h"
cristy6b0cc4b2011-10-13 17:17:42 +000048#include "MagickCore/nt-base-private.h"
cristy4c08aed2011-07-01 19:47:50 +000049#include "MagickCore/string-private.h"
cristy7832dc22011-09-05 01:21:53 +000050#include "MagickCore/xwindow-private.h"
cristy3ed852e2009-09-05 21:47:34 +000051
52/*
53%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54% %
55% %
56% %
57+ D i s p l a y I m a g e C o m m a n d %
58% %
59% %
60% %
61%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
62%
63% DisplayImageCommand() displays a sequence of images on any workstation
64% display running an X server. Display first determines the hardware
65% capabilities of the workstation. If the number of unique colors in an image
66% is less than or equal to the number the workstation can support, the image
67% is displayed in an X window. Otherwise the number of colors in the image is
68% first reduced to match the color resolution of the workstation before it is
69% displayed.
70%
71% This means that a continuous-tone 24 bits/pixel image can display on a 8
72% bit pseudo-color device or monochrome device. In most instances the reduced
73% color image closely resembles the original. Alternatively, a monochrome or
74% pseudo-color image sequence can display on a continuous-tone 24 bits/pixels
75% device.
76%
77% The format of the DisplayImageCommand method is:
78%
79% MagickBooleanType DisplayImageCommand(ImageInfo *image_info,int argc,
80% char **argv,char **metadata,ExceptionInfo *exception)
81%
82% A description of each parameter follows:
83%
84% o image_info: the image info.
85%
86% o argc: the number of elements in the argument vector.
87%
88% o argv: A text array containing the command line arguments.
89%
90% o metadata: any metadata is returned here.
91%
92% o exception: return any errors or warnings in this structure.
93%
94*/
95
96static MagickBooleanType DisplayUsage(void)
97{
98 const char
99 **p;
100
101 static const char
102 *buttons[]=
103 {
104 "1 press to map or unmap the Command widget",
105 "2 press and drag to magnify a region of an image",
106 "3 press to load an image from a visual image directory",
107 (char *) NULL
108 },
109 *miscellaneous[]=
110 {
111 "-debug events display copious debugging information",
112 "-help print program options",
113 "-list type print a list of supported option arguments",
114 "-log format format of debugging information",
115 "-version print version information",
116 (char *) NULL
117 },
118 *operators[]=
119 {
120 "-auto-orient automagically orient image",
121 "-border geometry surround image with a border of color",
cristycee97112010-05-28 00:44:52 +0000122 "-clip clip along the first path from the 8BIM profile",
123 "-clip-path id clip along a named path from the 8BIM profile",
cristy3ed852e2009-09-05 21:47:34 +0000124 "-colors value preferred number of colors in the image",
125 "-contrast enhance or reduce the image contrast",
126 "-crop geometry preferred size and location of the cropped image",
127 "-decipher filename convert cipher pixels to plain pixels",
128 "-deskew threshold straighten an image",
129 "-despeckle reduce the speckles within an image",
130 "-edge factor apply a filter to detect edges in the image",
131 "-enhance apply a digital filter to enhance a noisy image",
132 "-equalize perform histogram equalization to an image",
133 "-extract geometry extract area from image",
134 "-flip flip image in the vertical direction",
135 "-flop flop image in the horizontal direction",
136 "-frame geometry surround image with an ornamental border",
137 "-fuzz distance colors within this distance are considered equal",
138 "-gamma value level of gamma correction",
139 "-monochrome transform image to black and white",
140 "-negate replace every pixel with its complementary color",
141 "-normalize transform image to span the full range of colors",
142 "-raise value lighten/darken image edges to create a 3-D effect",
143 "-resample geometry change the resolution of an image",
144 "-resize geometry resize the image",
145 "-roll geometry roll an image vertically or horizontally",
146 "-rotate degrees apply Paeth rotation to the image",
147 "-sample geometry scale image with pixel sampling",
148 "-segment value segment an image",
149 "-sharpen geometry sharpen the image",
150 "-strip strip image of all profiles and comments",
151 "-threshold value threshold the image",
cristye4cbe742010-02-18 22:19:38 +0000152 "-thumbnail geometry create a thumbnail of the image",
cristy3ed852e2009-09-05 21:47:34 +0000153 "-trim trim image edges",
154 (char *) NULL
155 },
156 *settings[]=
157 {
158 "-alpha option on, activate, off, deactivate, set, opaque, copy",
159 " transparent, extract, background, or shape",
160 "-antialias remove pixel-aliasing",
161 "-authenticate password",
162 " decipher image with this password",
163 "-backdrop display image centered on a backdrop",
164 "-channel type apply option to select image channels",
165 "-colormap type Shared or Private",
166 "-colorspace type alternate image colorspace",
167 "-comment string annotate image with comment",
168 "-compress type type of pixel compression when writing the image",
169 "-define format:option",
170 " define one or more image format options",
171 "-delay value display the next image after pausing",
172 "-density geometry horizontal and vertical density of the image",
173 "-depth value image depth",
174 "-display server display image to this X server",
175 "-dispose method layer disposal method",
176 "-dither method apply error diffusion to image",
177 "-endian type endianness (MSB or LSB) of the image",
178 "-filter type use this filter when resizing an image",
179 "-format string output formatted image characteristics",
180 "-geometry geometry preferred size and location of the Image window",
181 "-gravity type horizontal and vertical backdrop placement",
182 "-identify identify the format and characteristics of the image",
183 "-immutable displayed image cannot be modified",
184 "-interlace type type of image interlacing scheme",
185 "-interpolate method pixel color interpolation method",
186 "-label string assign a label to an image",
187 "-limit type value pixel cache resource limit",
188 "-loop iterations loop images then exit",
189 "-map type display image using this Standard Colormap",
190 "-monitor monitor progress",
191 "-page geometry size and location of an image canvas",
192 "-profile filename add, delete, or apply an image profile",
193 "-quality value JPEG/MIFF/PNG compression level",
194 "-quantize colorspace reduce colors in this colorspace",
195 "-quiet suppress all warning messages",
196 "-regard-warnings pay attention to warning messages",
197 "-remote command execute a command in an remote display process",
198 "-repage geometry size and location of an image canvas (operator)",
199 "-respect-parentheses settings remain in effect until parenthesis boundary",
200 "-sampling-factor geometry",
201 " horizontal and vertical sampling factor",
202 "-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 "-texture filename name of texture to tile onto the image background",
206 "-transparent-color color",
207 " transparent color",
208 "-treedepth value color tree depth",
209 "-update seconds detect when image file is modified and redisplay",
210 "-verbose print detailed information about the image",
211 "-visual type display image using this visual type",
212 "-virtual-pixel method",
213 " virtual pixel access method",
214 "-window id display image to background of this window",
215 "-window-group id exit program when this window id is destroyed",
216 "-write filename write image to a file",
217 (char *) NULL
218 },
219 *sequence_operators[]=
220 {
221 "-coalesce merge a sequence of images",
222 "-flatten flatten a sequence of images",
223 (char *) NULL
224 };
225
cristybb503372010-05-27 20:51:26 +0000226 (void) printf("Version: %s\n",GetMagickVersion((size_t *) NULL));
cristy610b2e22009-10-22 14:59:43 +0000227 (void) printf("Copyright: %s\n",GetMagickCopyright());
228 (void) printf("Features: %s\n\n",GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +0000229 (void) printf("Usage: %s [options ...] file [ [options ...] file ...]\n",
230 GetClientName());
231 (void) printf("\nImage Settings:\n");
232 for (p=settings; *p != (char *) NULL; p++)
233 (void) printf(" %s\n",*p);
234 (void) printf("\nImage Operators:\n");
235 for (p=operators; *p != (char *) NULL; p++)
236 (void) printf(" %s\n",*p);
237 (void) printf("\nImage Sequence Operators:\n");
238 for (p=sequence_operators; *p != (char *) NULL; p++)
239 (void) printf(" %s\n",*p);
240 (void) printf("\nMiscellaneous Options:\n");
241 for (p=miscellaneous; *p != (char *) NULL; p++)
242 (void) printf(" %s\n",*p);
243 (void) printf(
244 "\nIn addition to those listed above, you can specify these standard X\n");
245 (void) printf(
246 "resources as command line options: -background, -bordercolor,\n");
247 (void) printf(
248 "-borderwidth, -font, -foreground, -iconGeometry, -iconic, -mattecolor,\n");
249 (void) printf("-name, -shared-memory, -usePixmap, or -title.\n");
250 (void) printf(
251 "\nBy default, the image format of `file' is determined by its magic\n");
252 (void) printf(
253 "number. To specify a particular image format, precede the filename\n");
254 (void) printf(
255 "with an image format name and a colon (i.e. ps:image) or specify the\n");
256 (void) printf(
257 "image type as the filename suffix (i.e. image.ps). Specify 'file' as\n");
258 (void) printf("'-' for standard input or output.\n");
259 (void) printf("\nButtons: \n");
260 for (p=buttons; *p != (char *) NULL; p++)
261 (void) printf(" %s\n",*p);
262 return(MagickFalse);
263}
264
265WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
266 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
267{
268#if defined(MAGICKCORE_X11_DELEGATE)
269#define DestroyDisplay() \
270{ \
271 if ((state & ExitState) == 0) \
272 DestroyXResources(); \
273 if (display != (Display *) NULL) \
274 { \
275 XCloseDisplay(display); \
276 display=(Display *) NULL; \
277 } \
278 XDestroyResourceInfo(&resource_info); \
279 DestroyImageStack(); \
cristybb503372010-05-27 20:51:26 +0000280 if (image_marker != (size_t *) NULL) \
281 image_marker=(size_t *) RelinquishMagickMemory(image_marker); \
282 for (i=0; i < (ssize_t) argc; i++) \
cristy3ed852e2009-09-05 21:47:34 +0000283 argv[i]=DestroyString(argv[i]); \
284 argv=(char **) RelinquishMagickMemory(argv); \
285}
286#define ThrowDisplayException(asperity,tag,option) \
287{ \
288 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
289 option); \
290 DestroyDisplay(); \
291 return(MagickFalse); \
292}
293#define ThrowDisplayInvalidArgumentException(option,argument) \
294{ \
295 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
296 "InvalidArgument","`%s': %s",option,argument); \
297 DestroyDisplay(); \
298 return(MagickFalse); \
299}
300
301 char
302 *resource_value,
303 *server_name;
304
305 const char
306 *option;
307
308 Display
309 *display;
310
311 Image
312 *image;
313
314 ImageStack
315 image_stack[MaxImageStackDepth+1];
316
cristy3ed852e2009-09-05 21:47:34 +0000317 MagickBooleanType
cristyebbcfea2011-02-25 02:43:54 +0000318 fire,
319 pend,
320 respect_parenthesis;
cristy3ed852e2009-09-05 21:47:34 +0000321
322 MagickStatusType
cristy3ed852e2009-09-05 21:47:34 +0000323 status;
324
325 QuantizeInfo
326 *quantize_info;
327
cristybb503372010-05-27 20:51:26 +0000328 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000329 i;
330
cristybb503372010-05-27 20:51:26 +0000331 size_t
cristy3ed852e2009-09-05 21:47:34 +0000332 *image_marker,
333 iterations,
334 last_image,
335 state;
336
cristy9d314ff2011-03-09 01:30:28 +0000337 ssize_t
338 image_number,
339 iteration,
340 j,
341 k,
342 l;
343
cristy3ed852e2009-09-05 21:47:34 +0000344 XResourceInfo
345 resource_info;
346
347 XrmDatabase
348 resource_database;
349
350 /*
351 Set defaults.
352 */
353 assert(image_info != (ImageInfo *) NULL);
354 assert(image_info->signature == MagickSignature);
355 if (image_info->debug != MagickFalse)
356 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
357 assert(exception != (ExceptionInfo *) NULL);
358 if (argc == 2)
359 {
360 option=argv[1];
361 if ((LocaleCompare("version",option+1) == 0) ||
362 (LocaleCompare("-version",option+1) == 0))
363 {
cristyb51dff52011-05-19 16:55:47 +0000364 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +0000365 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +0000366 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
367 GetMagickCopyright());
368 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
369 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +0000370 return(MagickFalse);
371 }
372 }
373 SetNotifyHandlers;
374 display=(Display *) NULL;
375 j=1;
376 k=0;
cristybb503372010-05-27 20:51:26 +0000377 image_marker=(size_t *) NULL;
cristy3ed852e2009-09-05 21:47:34 +0000378 image_number=0;
379 last_image=0;
380 NewImageStack();
381 option=(char *) NULL;
382 pend=MagickFalse;
cristyebbcfea2011-02-25 02:43:54 +0000383 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +0000384 resource_database=(XrmDatabase) NULL;
385 (void) ResetMagickMemory(&resource_info,0,sizeof(resource_info));
386 server_name=(char *) NULL;
387 state=0;
388 status=MagickTrue;
389 ReadCommandlLine(argc,&argv);
390 status=ExpandFilenames(&argc,&argv);
391 if (status == MagickFalse)
392 ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed",
393 GetExceptionMessage(errno));
cristybb503372010-05-27 20:51:26 +0000394 image_marker=(size_t *) AcquireQuantumMemory((size_t) argc+1UL,
cristy3ed852e2009-09-05 21:47:34 +0000395 sizeof(*image_marker));
cristybb503372010-05-27 20:51:26 +0000396 if (image_marker == (size_t *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000397 ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed",
398 GetExceptionMessage(errno));
cristycee97112010-05-28 00:44:52 +0000399 for (i=0; i <= (ssize_t) argc; i++)
cristybb503372010-05-27 20:51:26 +0000400 image_marker[i]=(size_t) argc;
cristy3ed852e2009-09-05 21:47:34 +0000401 /*
402 Check for server name specified on the command line.
403 */
cristybb503372010-05-27 20:51:26 +0000404 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000405 {
406 /*
407 Check command line for server name.
408 */
409 option=argv[i];
410 if (LocaleCompare("display",option+1) == 0)
411 {
412 /*
413 User specified server name.
414 */
415 i++;
cristybb503372010-05-27 20:51:26 +0000416 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000417 ThrowDisplayException(OptionError,"MissingArgument",option);
418 server_name=argv[i];
419 }
420 if ((LocaleCompare("help",option+1) == 0) ||
421 (LocaleCompare("-help",option+1) == 0))
422 return(DisplayUsage());
423 }
424 /*
425 Get user defaults from X resource database.
426 */
427 display=XOpenDisplay(server_name);
428 if (display == (Display *) NULL)
429 ThrowDisplayException(XServerError,"UnableToOpenXServer",
430 XDisplayName(server_name));
431 (void) XSetErrorHandler(XError);
432 resource_database=XGetResourceDatabase(display,GetClientName());
433 XGetResourceInfo(image_info,resource_database,GetClientName(),
434 &resource_info);
435 quantize_info=resource_info.quantize_info;
436 image_info->density=XGetResourceInstance(resource_database,GetClientName(),
437 "density",(char *) NULL);
438 if (image_info->density == (char *) NULL)
439 image_info->density=XGetScreenDensity(display);
440 resource_value=XGetResourceInstance(resource_database,GetClientName(),
441 "interlace","none");
442 image_info->interlace=(InterlaceType)
cristy042ee782011-04-22 18:48:30 +0000443 ParseCommandOption(MagickInterlaceOptions,MagickFalse,resource_value);
cristy3ed852e2009-09-05 21:47:34 +0000444 image_info->page=XGetResourceInstance(resource_database,GetClientName(),
445 "pageGeometry",(char *) NULL);
446 resource_value=XGetResourceInstance(resource_database,GetClientName(),
447 "quality","75");
cristye27293e2009-12-18 02:53:20 +0000448 image_info->quality=StringToUnsignedLong(resource_value);
cristy3ed852e2009-09-05 21:47:34 +0000449 resource_value=XGetResourceInstance(resource_database,GetClientName(),
450 "verbose","False");
451 image_info->verbose=IsMagickTrue(resource_value);
452 resource_value=XGetResourceInstance(resource_database,GetClientName(),
453 "dither","True");
454 quantize_info->dither=IsMagickTrue(resource_value);
455 /*
456 Parse command line.
457 */
458 iteration=0;
cristybb503372010-05-27 20:51:26 +0000459 for (i=1; ((i <= (ssize_t) argc) && ((state & ExitState) == 0)); i++)
cristy3ed852e2009-09-05 21:47:34 +0000460 {
cristybb503372010-05-27 20:51:26 +0000461 if (i < (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000462 option=argv[i];
463 else
464 if (image != (Image *) NULL)
465 break;
466 else
467 if (isatty(STDIN_FILENO) != MagickFalse)
468 option="logo:";
469 else
470 {
471 int
472 c;
473
474 c=getc(stdin);
475 if (c == EOF)
476 break;
477 else
478 {
479 c=ungetc(c,stdin);
480 option="-";
481 }
482 }
483 if (LocaleCompare(option,"(") == 0)
484 {
485 FireImageStack(MagickFalse,MagickTrue,pend);
486 if (k == MaxImageStackDepth)
487 ThrowDisplayException(OptionError,"ParenthesisNestedTooDeeply",
488 option);
489 PushImageStack();
490 continue;
491 }
492 if (LocaleCompare(option,")") == 0)
493 {
494 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
495 if (k == 0)
496 ThrowDisplayException(OptionError,"UnableToParseExpression",option);
497 PopImageStack();
498 continue;
499 }
cristy042ee782011-04-22 18:48:30 +0000500 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000501 {
502 const char
503 *filename;
504
505 Image
cristy5ca51572011-03-24 02:00:31 +0000506 *display_image,
cristy3ed852e2009-09-05 21:47:34 +0000507 *images;
508
509 /*
510 Option is a file name.
511 */
512 FireImageStack(MagickFalse,MagickFalse,pend);
513 filename=option;
cristycee97112010-05-28 00:44:52 +0000514 if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1)))
cristy3ed852e2009-09-05 21:47:34 +0000515 {
516 option=argv[++i];
517 filename=option;
518 }
519 (void) CopyMagickString(image_info->filename,filename,MaxTextExtent);
520 images=ReadImage(image_info,exception);
521 CatchException(exception);
522 status&=(images != (Image *) NULL) &&
523 (exception->severity < ErrorException);
524 if (images == (Image *) NULL)
525 continue;
526 AppendImageStack(images);
527 FinalizeImageSettings(image_info,image,MagickFalse);
cristyf3816382009-11-26 14:57:01 +0000528 iterations=0;
cristycee97112010-05-28 00:44:52 +0000529 if (i == (ssize_t) (argc-1))
cristyf3816382009-11-26 14:57:01 +0000530 iterations=image->iterations;
cristy5ca51572011-03-24 02:00:31 +0000531 display_image=CloneImageList(image,exception);
532 if (display_image == (Image *) NULL)
533 ThrowDisplayException(ResourceLimitError,"MemoryAllocationFailed",
534 GetExceptionMessage(errno));
cristy3ed852e2009-09-05 21:47:34 +0000535 do
536 {
537 /*
538 Transmogrify image as defined by the image processing options.
539 */
540 resource_info.quantum=1;
541 if (resource_info.window_id != (char *) NULL)
542 {
543 /*
544 Display image to a specified X window.
545 */
cristy5ca51572011-03-24 02:00:31 +0000546 status=XDisplayBackgroundImage(display,&resource_info,
cristy051718b2011-08-28 22:49:25 +0000547 display_image,exception);
cristy3ed852e2009-09-05 21:47:34 +0000548 if (status != MagickFalse)
549 {
550 state|=RetainColorsState;
551 status=MagickFalse;
552 }
553 }
554 else
555 do
556 {
557 Image
558 *nexus;
559
560 /*
561 Display image to X server.
562 */
cristy588e8b92010-06-27 13:45:22 +0000563 if (resource_info.delay != 1)
cristy5ca51572011-03-24 02:00:31 +0000564 display_image->delay=resource_info.delay;
565 nexus=XDisplayImage(display,&resource_info,argv,argc,
cristy051718b2011-08-28 22:49:25 +0000566 &display_image,&state,exception);
cristy3ed852e2009-09-05 21:47:34 +0000567 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 */
cristy5ca51572011-03-24 02:00:31 +0000580 display_image=nexus;
cristy3ed852e2009-09-05 21:47:34 +0000581 break;
582 }
583 next=XDisplayImage(display,&resource_info,argv,argc,&nexus,
cristy051718b2011-08-28 22:49:25 +0000584 &state,exception);
cristy3ed852e2009-09-05 21:47:34 +0000585 if ((next == (Image *) NULL) &&
586 (GetNextImageInList(nexus) != (Image *) NULL))
587 {
cristy5ca51572011-03-24 02:00:31 +0000588 display_image=GetNextImageInList(nexus);
cristy3ed852e2009-09-05 21:47:34 +0000589 nexus=NewImageList();
590 }
591 else
592 {
cristy5ca51572011-03-24 02:00:31 +0000593 if (nexus != display_image)
cristy3ed852e2009-09-05 21:47:34 +0000594 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 */
cristy5ca51572011-03-24 02:00:31 +0000604 (void) CopyMagickString(display_image->filename,
cristy3ed852e2009-09-05 21:47:34 +0000605 resource_info.write_filename,MaxTextExtent);
cristyc82a27b2011-10-21 01:07:16 +0000606 (void) SetImageInfo(image_info,1,exception);
607 status&=WriteImage(image_info,display_image,exception);
cristy3ed852e2009-09-05 21:47:34 +0000608 }
609 /*
610 Proceed to next/previous image.
611 */
612 if ((state & FormerImageState) != 0)
cristycee97112010-05-28 00:44:52 +0000613 for (l=0; l < (ssize_t) resource_info.quantum; l++)
cristy3ed852e2009-09-05 21:47:34 +0000614 {
cristy5ca51572011-03-24 02:00:31 +0000615 display_image=GetPreviousImageInList(display_image);
616 if (display_image == (Image *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000617 break;
618 }
619 else
cristycee97112010-05-28 00:44:52 +0000620 for (l=0; l < (ssize_t) resource_info.quantum; l++)
cristy3ed852e2009-09-05 21:47:34 +0000621 {
cristy5ca51572011-03-24 02:00:31 +0000622 display_image=GetNextImageInList(display_image);
623 if (display_image == (Image *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000624 break;
625 }
cristy5ca51572011-03-24 02:00:31 +0000626 } while ((display_image != (Image *) NULL) && ((state & ExitState) == 0));
cristy3ed852e2009-09-05 21:47:34 +0000627 /*
628 Free image resources.
629 */
cristy5ca51572011-03-24 02:00:31 +0000630 display_image=DestroyImageList(display_image);
cristy3ed852e2009-09-05 21:47:34 +0000631 if ((state & FormerImageState) == 0)
632 {
cristybb503372010-05-27 20:51:26 +0000633 last_image=(size_t) image_number;
634 image_marker[i]=(size_t) image_number++;
cristy3ed852e2009-09-05 21:47:34 +0000635 }
636 else
637 {
638 /*
639 Proceed to previous image.
640 */
641 for (i--; i > 0; i--)
cristybb503372010-05-27 20:51:26 +0000642 if (image_marker[i] == (size_t) (image_number-2))
cristy3ed852e2009-09-05 21:47:34 +0000643 break;
644 image_number--;
645 }
cristybb503372010-05-27 20:51:26 +0000646 if ((i == (ssize_t) (argc-1)) && ((state & ExitState) == 0))
cristy3ed852e2009-09-05 21:47:34 +0000647 i=0;
648 if ((state & ExitState) != 0)
649 break;
650 /*
651 Determine if we should proceed to the first image.
652 */
653 if (image_number < 0)
654 {
655 if ((state & FormerImageState) != 0)
656 {
657
cristycee97112010-05-28 00:44:52 +0000658 for (i=1; i < (ssize_t) (argc-2); i++)
cristy3ed852e2009-09-05 21:47:34 +0000659 if (last_image == image_marker[i])
660 break;
cristybb503372010-05-27 20:51:26 +0000661 image_number=(ssize_t) image_marker[i]+1;
cristy3ed852e2009-09-05 21:47:34 +0000662 }
663 continue;
664 }
665 if (resource_info.window_id != (char *) NULL)
666 state|=ExitState;
cristybb503372010-05-27 20:51:26 +0000667 if ((iterations != 0) && (++iteration == (ssize_t) iterations))
cristy3ed852e2009-09-05 21:47:34 +0000668 state|=ExitState;
669 if (LocaleCompare(filename,"-") == 0)
670 state|=ExitState;
cristy9a48b172011-09-20 17:41:05 +0000671 RemoveAllImageStack();
cristy3ed852e2009-09-05 21:47:34 +0000672 continue;
673 }
674 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
675 switch (*(option+1))
676 {
677 case 'a':
678 {
679 if (LocaleCompare("alpha",option+1) == 0)
680 {
cristybb503372010-05-27 20:51:26 +0000681 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000682 type;
683
684 if (*option == '+')
685 break;
686 i++;
cristybb503372010-05-27 20:51:26 +0000687 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000688 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000689 type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000690 if (type < 0)
691 ThrowDisplayException(OptionError,"UnrecognizedAlphaChannelType",
692 argv[i]);
693 break;
694 }
695 if (LocaleCompare("antialias",option+1) == 0)
696 break;
697 if (LocaleCompare("authenticate",option+1) == 0)
698 {
699 if (*option == '+')
700 break;
701 i++;
cristybb503372010-05-27 20:51:26 +0000702 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000703 ThrowDisplayException(OptionError,"MissingArgument",option);
704 break;
705 }
706 if (LocaleCompare("auto-orient",option+1) == 0)
707 break;
708 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
709 }
710 case 'b':
711 {
712 if (LocaleCompare("backdrop",option+1) == 0)
713 {
714 resource_info.backdrop=(*option == '-') ? MagickTrue : MagickFalse;
715 break;
716 }
717 if (LocaleCompare("background",option+1) == 0)
718 {
719 if (*option == '+')
720 break;
721 i++;
cristybb503372010-05-27 20:51:26 +0000722 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000723 ThrowDisplayException(OptionError,"MissingArgument",option);
724 resource_info.background_color=argv[i];
725 break;
726 }
727 if (LocaleCompare("border",option+1) == 0)
728 {
729 if (*option == '+')
730 break;
731 i++;
cristybb503372010-05-27 20:51:26 +0000732 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000733 ThrowDisplayException(OptionError,"MissingArgument",option);
734 if (IsGeometry(argv[i]) == MagickFalse)
735 ThrowDisplayInvalidArgumentException(option,argv[i]);
736 break;
737 }
738 if (LocaleCompare("bordercolor",option+1) == 0)
739 {
740 if (*option == '+')
741 break;
742 i++;
cristybb503372010-05-27 20:51:26 +0000743 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000744 ThrowDisplayException(OptionError,"MissingArgument",option);
745 resource_info.border_color=argv[i];
746 break;
747 }
748 if (LocaleCompare("borderwidth",option+1) == 0)
749 {
750 resource_info.border_width=0;
751 if (*option == '+')
752 break;
753 i++;
cristybb503372010-05-27 20:51:26 +0000754 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000755 ThrowDisplayException(OptionError,"MissingArgument",option);
756 if (IsGeometry(argv[i]) == MagickFalse)
757 ThrowDisplayInvalidArgumentException(option,argv[i]);
cristyb70a4862010-06-18 01:18:44 +0000758 resource_info.border_width=(unsigned int)
759 StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000760 break;
761 }
762 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
763 }
764 case 'c':
765 {
766 if (LocaleCompare("cache",option+1) == 0)
767 {
768 if (*option == '+')
769 break;
770 i++;
cristybb503372010-05-27 20:51:26 +0000771 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000772 ThrowDisplayException(OptionError,"MissingArgument",option);
773 if (IsGeometry(argv[i]) == MagickFalse)
774 ThrowDisplayInvalidArgumentException(option,argv[i]);
775 break;
776 }
777 if (LocaleCompare("channel",option+1) == 0)
778 {
cristybb503372010-05-27 20:51:26 +0000779 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000780 channel;
781
782 if (*option == '+')
783 break;
784 i++;
cristybb503372010-05-27 20:51:26 +0000785 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000786 ThrowDisplayException(OptionError,"MissingArgument",option);
787 channel=ParseChannelOption(argv[i]);
788 if (channel < 0)
789 ThrowDisplayException(OptionError,"UnrecognizedChannelType",
790 argv[i]);
791 break;
792 }
793 if (LocaleCompare("clip",option+1) == 0)
794 break;
795 if (LocaleCompare("clip-path",option+1) == 0)
796 {
797 i++;
cristybb503372010-05-27 20:51:26 +0000798 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000799 ThrowDisplayException(OptionError,"MissingArgument",option);
800 break;
801 }
802 if (LocaleCompare("coalesce",option+1) == 0)
803 break;
804 if (LocaleCompare("colormap",option+1) == 0)
805 {
806 resource_info.colormap=PrivateColormap;
807 if (*option == '+')
808 break;
809 i++;
cristybb503372010-05-27 20:51:26 +0000810 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000811 ThrowDisplayException(OptionError,"MissingArgument",option);
812 resource_info.colormap=UndefinedColormap;
813 if (LocaleCompare("private",argv[i]) == 0)
814 resource_info.colormap=PrivateColormap;
815 if (LocaleCompare("shared",argv[i]) == 0)
816 resource_info.colormap=SharedColormap;
817 if (resource_info.colormap == UndefinedColormap)
818 ThrowDisplayException(OptionError,"UnrecognizedColormapType",
819 argv[i]);
820 break;
821 }
822 if (LocaleCompare("colors",option+1) == 0)
823 {
824 quantize_info->number_colors=0;
825 if (*option == '+')
826 break;
827 i++;
cristybb503372010-05-27 20:51:26 +0000828 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000829 ThrowDisplayException(OptionError,"MissingArgument",option);
830 if (IsGeometry(argv[i]) == MagickFalse)
831 ThrowDisplayInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +0000832 quantize_info->number_colors=StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000833 break;
834 }
835 if (LocaleCompare("colorspace",option+1) == 0)
836 {
cristybb503372010-05-27 20:51:26 +0000837 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000838 colorspace;
839
840 if (*option == '+')
841 break;
842 i++;
cristybb503372010-05-27 20:51:26 +0000843 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000844 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000845 colorspace=ParseCommandOption(MagickColorspaceOptions,
cristy3ed852e2009-09-05 21:47:34 +0000846 MagickFalse,argv[i]);
847 if (colorspace < 0)
848 ThrowDisplayException(OptionError,"UnrecognizedColorspace",
849 argv[i]);
850 break;
851 }
852 if (LocaleCompare("comment",option+1) == 0)
853 {
854 if (*option == '+')
855 break;
856 i++;
cristybb503372010-05-27 20:51:26 +0000857 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000858 ThrowDisplayException(OptionError,"MissingArgument",option);
859 break;
860 }
861 if (LocaleCompare("compress",option+1) == 0)
862 {
cristybb503372010-05-27 20:51:26 +0000863 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000864 compress;
865
866 if (*option == '+')
867 break;
868 i++;
cristybb503372010-05-27 20:51:26 +0000869 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000870 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000871 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000872 argv[i]);
873 if (compress < 0)
874 ThrowDisplayException(OptionError,"UnrecognizedImageCompression",
875 argv[i]);
876 break;
877 }
cristy22879752009-10-25 23:55:40 +0000878 if (LocaleCompare("concurrent",option+1) == 0)
879 break;
cristy3ed852e2009-09-05 21:47:34 +0000880 if (LocaleCompare("contrast",option+1) == 0)
881 break;
882 if (LocaleCompare("crop",option+1) == 0)
883 {
884 if (*option == '+')
885 break;
886 i++;
cristybb503372010-05-27 20:51:26 +0000887 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000888 ThrowDisplayException(OptionError,"MissingArgument",option);
889 if (IsGeometry(argv[i]) == MagickFalse)
890 ThrowDisplayInvalidArgumentException(option,argv[i]);
891 break;
892 }
893 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
894 }
895 case 'd':
896 {
897 if (LocaleCompare("debug",option+1) == 0)
898 {
cristybb503372010-05-27 20:51:26 +0000899 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000900 event;
901
902 if (*option == '+')
903 break;
904 i++;
cristybb503372010-05-27 20:51:26 +0000905 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000906 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000907 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000908 if (event < 0)
909 ThrowDisplayException(OptionError,"UnrecognizedEventType",
910 argv[i]);
911 (void) SetLogEventMask(argv[i]);
912 break;
913 }
914 if (LocaleCompare("decipher",option+1) == 0)
915 {
916 if (*option == '+')
917 break;
918 i++;
cristybb503372010-05-27 20:51:26 +0000919 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000920 ThrowDisplayException(OptionError,"MissingArgument",option);
921 break;
922 }
923 if (LocaleCompare("define",option+1) == 0)
924 {
925 i++;
cristybb503372010-05-27 20:51:26 +0000926 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000927 ThrowDisplayException(OptionError,"MissingArgument",option);
928 if (*option == '+')
929 {
930 const char
931 *define;
932
933 define=GetImageOption(image_info,argv[i]);
934 if (define == (const char *) NULL)
935 ThrowDisplayException(OptionError,"NoSuchOption",argv[i]);
936 break;
937 }
938 break;
939 }
940 if (LocaleCompare("delay",option+1) == 0)
941 {
942 if (*option == '+')
943 break;
944 i++;
cristybb503372010-05-27 20:51:26 +0000945 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000946 ThrowDisplayException(OptionError,"MissingArgument",option);
947 if (IsGeometry(argv[i]) == MagickFalse)
948 ThrowDisplayInvalidArgumentException(option,argv[i]);
949 break;
950 }
951 if (LocaleCompare("density",option+1) == 0)
952 {
953 if (*option == '+')
954 break;
955 i++;
cristybb503372010-05-27 20:51:26 +0000956 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000957 ThrowDisplayException(OptionError,"MissingArgument",option);
958 if (IsGeometry(argv[i]) == MagickFalse)
959 ThrowDisplayInvalidArgumentException(option,argv[i]);
960 break;
961 }
962 if (LocaleCompare("depth",option+1) == 0)
963 {
964 if (*option == '+')
965 break;
966 i++;
cristybb503372010-05-27 20:51:26 +0000967 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000968 ThrowDisplayException(OptionError,"MissingArgument",option);
969 if (IsGeometry(argv[i]) == MagickFalse)
970 ThrowDisplayInvalidArgumentException(option,argv[i]);
971 break;
972 }
973 if (LocaleCompare("deskew",option+1) == 0)
974 {
975 if (*option == '+')
976 break;
977 i++;
cristybb503372010-05-27 20:51:26 +0000978 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +0000979 ThrowDisplayException(OptionError,"MissingArgument",option);
980 if (IsGeometry(argv[i]) == MagickFalse)
981 ThrowDisplayInvalidArgumentException(option,argv[i]);
982 break;
983 }
984 if (LocaleCompare("despeckle",option+1) == 0)
985 break;
986 if (LocaleCompare("display",option+1) == 0)
987 {
988 if (*option == '+')
989 break;
990 i++;
cristybb503372010-05-27 20:51:26 +0000991 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000992 ThrowDisplayException(OptionError,"MissingArgument",option);
993 break;
994 }
995 if (LocaleCompare("dispose",option+1) == 0)
996 {
cristybb503372010-05-27 20:51:26 +0000997 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000998 dispose;
999
1000 if (*option == '+')
1001 break;
1002 i++;
cristybb503372010-05-27 20:51:26 +00001003 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001004 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001005 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001006 if (dispose < 0)
1007 ThrowDisplayException(OptionError,"UnrecognizedDisposeMethod",
1008 argv[i]);
1009 break;
1010 }
1011 if (LocaleCompare("dither",option+1) == 0)
1012 {
cristybb503372010-05-27 20:51:26 +00001013 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001014 method;
1015
1016 quantize_info->dither=MagickFalse;
1017 if (*option == '+')
1018 break;
1019 i++;
cristybb503372010-05-27 20:51:26 +00001020 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001021 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001022 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001023 if (method < 0)
1024 ThrowDisplayException(OptionError,"UnrecognizedDitherMethod",
1025 argv[i]);
1026 quantize_info->dither=MagickTrue;
1027 quantize_info->dither_method=(DitherMethod) method;
1028 break;
1029 }
cristy22879752009-10-25 23:55:40 +00001030 if (LocaleCompare("duration",option+1) == 0)
1031 {
1032 if (*option == '+')
1033 break;
1034 i++;
cristybb503372010-05-27 20:51:26 +00001035 if (i == (ssize_t) (argc-1))
cristy22879752009-10-25 23:55:40 +00001036 ThrowDisplayException(OptionError,"MissingArgument",option);
1037 if (IsGeometry(argv[i]) == MagickFalse)
1038 ThrowDisplayInvalidArgumentException(option,argv[i]);
1039 break;
1040 }
cristy3ed852e2009-09-05 21:47:34 +00001041 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1042 }
1043 case 'e':
1044 {
1045 if (LocaleCompare("edge",option+1) == 0)
1046 {
1047 if (*option == '+')
1048 break;
1049 i++;
cristybb503372010-05-27 20:51:26 +00001050 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001051 ThrowDisplayException(OptionError,"MissingArgument",option);
1052 if (IsGeometry(argv[i]) == MagickFalse)
1053 ThrowDisplayInvalidArgumentException(option,argv[i]);
1054 break;
1055 }
1056 if (LocaleCompare("endian",option+1) == 0)
1057 {
cristybb503372010-05-27 20:51:26 +00001058 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001059 endian;
1060
1061 if (*option == '+')
1062 break;
1063 i++;
cristybb503372010-05-27 20:51:26 +00001064 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001065 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001066 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001067 argv[i]);
1068 if (endian < 0)
1069 ThrowDisplayException(OptionError,"UnrecognizedEndianType",
1070 argv[i]);
1071 break;
1072 }
1073 if (LocaleCompare("enhance",option+1) == 0)
1074 break;
1075 if (LocaleCompare("equalize",option+1) == 0)
1076 break;
1077 if (LocaleCompare("extract",option+1) == 0)
1078 {
1079 if (*option == '+')
1080 break;
1081 i++;
cristybb503372010-05-27 20:51:26 +00001082 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001083 ThrowDisplayException(OptionError,"MissingArgument",option);
1084 if (IsGeometry(argv[i]) == MagickFalse)
1085 ThrowDisplayInvalidArgumentException(option,argv[i]);
1086 break;
1087 }
1088 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1089 }
1090 case 'f':
1091 {
1092 if (LocaleCompare("filter",option+1) == 0)
1093 {
cristybb503372010-05-27 20:51:26 +00001094 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001095 filter;
1096
1097 if (*option == '+')
1098 break;
1099 i++;
cristybb503372010-05-27 20:51:26 +00001100 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001101 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001102 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001103 if (filter < 0)
1104 ThrowDisplayException(OptionError,"UnrecognizedImageFilter",
1105 argv[i]);
1106 break;
1107 }
1108 if (LocaleCompare("flatten",option+1) == 0)
1109 break;
1110 if (LocaleCompare("flip",option+1) == 0)
1111 break;
1112 if (LocaleCompare("flop",option+1) == 0)
1113 break;
1114 if (LocaleCompare("font",option+1) == 0)
1115 {
1116 if (*option == '+')
1117 break;
1118 i++;
cristybb503372010-05-27 20:51:26 +00001119 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001120 ThrowDisplayException(OptionError,"MissingArgument",option);
1121 resource_info.font=XGetResourceClass(resource_database,
1122 GetClientName(),"font",argv[i]);
1123 break;
1124 }
1125 if (LocaleCompare("foreground",option+1) == 0)
1126 {
1127 if (*option == '+')
1128 break;
1129 i++;
cristybb503372010-05-27 20:51:26 +00001130 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001131 ThrowDisplayException(OptionError,"MissingArgument",option);
1132 resource_info.foreground_color=argv[i];
1133 break;
1134 }
1135 if (LocaleCompare("format",option+1) == 0)
1136 {
1137 if (*option == '+')
1138 break;
1139 i++;
cristybb503372010-05-27 20:51:26 +00001140 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001141 ThrowDisplayException(OptionError,"MissingArgument",option);
1142 break;
1143 }
1144 if (LocaleCompare("frame",option+1) == 0)
1145 {
1146 if (*option == '+')
1147 break;
1148 i++;
cristybb503372010-05-27 20:51:26 +00001149 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001150 ThrowDisplayException(OptionError,"MissingArgument",option);
1151 if (IsGeometry(argv[i]) == MagickFalse)
1152 ThrowDisplayInvalidArgumentException(option,argv[i]);
1153 break;
1154 }
1155 if (LocaleCompare("fuzz",option+1) == 0)
1156 {
1157 if (*option == '+')
1158 break;
1159 i++;
cristybb503372010-05-27 20:51:26 +00001160 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001161 ThrowDisplayException(OptionError,"MissingArgument",option);
1162 if (IsGeometry(argv[i]) == MagickFalse)
1163 ThrowDisplayInvalidArgumentException(option,argv[i]);
1164 break;
1165 }
1166 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1167 }
1168 case 'g':
1169 {
1170 if (LocaleCompare("gamma",option+1) == 0)
1171 {
1172 i++;
cristybb503372010-05-27 20:51:26 +00001173 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001174 ThrowDisplayException(OptionError,"MissingArgument",option);
1175 if (IsGeometry(argv[i]) == MagickFalse)
1176 ThrowDisplayInvalidArgumentException(option,argv[i]);
1177 break;
1178 }
1179 if (LocaleCompare("geometry",option+1) == 0)
1180 {
1181 resource_info.image_geometry=(char *) NULL;
1182 if (*option == '+')
1183 break;
1184 (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent);
1185 i++;
cristybb503372010-05-27 20:51:26 +00001186 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001187 ThrowDisplayException(OptionError,"MissingArgument",option);
1188 if (IsGeometry(argv[i]) == MagickFalse)
1189 ThrowDisplayInvalidArgumentException(option,argv[i]);
1190 resource_info.image_geometry=ConstantString(argv[i]);
1191 break;
1192 }
1193 if (LocaleCompare("gravity",option+1) == 0)
1194 {
cristybb503372010-05-27 20:51:26 +00001195 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001196 gravity;
1197
1198 if (*option == '+')
1199 break;
1200 i++;
cristybb503372010-05-27 20:51:26 +00001201 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001202 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001203 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001204 argv[i]);
1205 if (gravity < 0)
1206 ThrowDisplayException(OptionError,"UnrecognizedGravityType",
1207 argv[i]);
1208 break;
1209 }
1210 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1211 }
1212 case 'h':
1213 {
1214 if ((LocaleCompare("help",option+1) == 0) ||
1215 (LocaleCompare("-help",option+1) == 0))
1216 break;
1217 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1218 }
1219 case 'i':
1220 {
1221 if (LocaleCompare("identify",option+1) == 0)
1222 break;
1223 if (LocaleCompare("iconGeometry",option+1) == 0)
1224 {
1225 resource_info.icon_geometry=(char *) NULL;
1226 if (*option == '+')
1227 break;
1228 i++;
cristybb503372010-05-27 20:51:26 +00001229 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001230 ThrowDisplayException(OptionError,"MissingArgument",option);
1231 if (IsGeometry(argv[i]) == MagickFalse)
1232 ThrowDisplayInvalidArgumentException(option,argv[i]);
1233 resource_info.icon_geometry=argv[i];
1234 break;
1235 }
1236 if (LocaleCompare("iconic",option+1) == 0)
1237 {
1238 resource_info.iconic=(*option == '-') ? MagickTrue : MagickFalse;
1239 break;
1240 }
1241 if (LocaleCompare("immutable",option+1) == 0)
1242 {
1243 resource_info.immutable=(*option == '-') ? MagickTrue : MagickFalse;
1244 break;
1245 }
1246 if (LocaleCompare("interlace",option+1) == 0)
1247 {
cristybb503372010-05-27 20:51:26 +00001248 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001249 interlace;
1250
1251 if (*option == '+')
1252 break;
1253 i++;
cristybb503372010-05-27 20:51:26 +00001254 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001255 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001256 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001257 argv[i]);
1258 if (interlace < 0)
1259 ThrowDisplayException(OptionError,"UnrecognizedInterlaceType",
1260 argv[i]);
1261 break;
1262 }
1263 if (LocaleCompare("interpolate",option+1) == 0)
1264 {
cristybb503372010-05-27 20:51:26 +00001265 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001266 interpolate;
1267
1268 if (*option == '+')
1269 break;
1270 i++;
cristybb503372010-05-27 20:51:26 +00001271 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001272 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001273 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001274 argv[i]);
1275 if (interpolate < 0)
1276 ThrowDisplayException(OptionError,"UnrecognizedInterpolateMethod",
1277 argv[i]);
1278 break;
1279 }
1280 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1281 }
1282 case 'l':
1283 {
1284 if (LocaleCompare("label",option+1) == 0)
1285 {
1286 if (*option == '+')
1287 break;
1288 i++;
cristybb503372010-05-27 20:51:26 +00001289 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001290 ThrowDisplayException(OptionError,"MissingArgument",option);
1291 break;
1292 }
1293 if (LocaleCompare("limit",option+1) == 0)
1294 {
1295 char
1296 *p;
1297
1298 double
1299 value;
1300
cristybb503372010-05-27 20:51:26 +00001301 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001302 resource;
1303
1304 if (*option == '+')
1305 break;
1306 i++;
cristybb503372010-05-27 20:51:26 +00001307 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001308 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001309 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001310 argv[i]);
1311 if (resource < 0)
1312 ThrowDisplayException(OptionError,"UnrecognizedResourceType",
1313 argv[i]);
1314 i++;
cristybb503372010-05-27 20:51:26 +00001315 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001316 ThrowDisplayException(OptionError,"MissingArgument",option);
cristydbdd0e32011-11-04 23:29:40 +00001317 value=StringToDouble(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +00001318 (void) value;
cristy3ed852e2009-09-05 21:47:34 +00001319 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
1320 ThrowDisplayInvalidArgumentException(option,argv[i]);
1321 break;
1322 }
1323 if (LocaleCompare("list",option+1) == 0)
1324 {
cristybb503372010-05-27 20:51:26 +00001325 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001326 list;
1327
1328 if (*option == '+')
1329 break;
1330 i++;
cristybb503372010-05-27 20:51:26 +00001331 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001332 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001333 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001334 if (list < 0)
1335 ThrowDisplayException(OptionError,"UnrecognizedListType",argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +00001336 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +00001337 argv+j,exception);
1338 DestroyDisplay();
cristyaeb2cbc2010-05-07 13:28:58 +00001339 return(status != 0 ? MagickFalse : MagickTrue);
cristy3ed852e2009-09-05 21:47:34 +00001340 }
1341 if (LocaleCompare("log",option+1) == 0)
1342 {
1343 if (*option == '+')
1344 break;
1345 i++;
cristybb503372010-05-27 20:51:26 +00001346 if ((i == (ssize_t) argc) ||
cristy3ed852e2009-09-05 21:47:34 +00001347 (strchr(argv[i],'%') == (char *) NULL))
1348 ThrowDisplayException(OptionError,"MissingArgument",option);
1349 break;
1350 }
1351 if (LocaleCompare("loop",option+1) == 0)
1352 {
1353 if (*option == '+')
1354 break;
1355 i++;
cristybb503372010-05-27 20:51:26 +00001356 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001357 ThrowDisplayException(OptionError,"MissingArgument",option);
1358 if (IsGeometry(argv[i]) == MagickFalse)
1359 ThrowDisplayInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +00001360 iterations=StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001361 break;
1362 }
1363 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1364 }
1365 case 'm':
1366 {
1367 if (LocaleCompare("magnify",option+1) == 0)
1368 {
1369 resource_info.magnify=2;
1370 if (*option == '+')
1371 break;
1372 i++;
cristybb503372010-05-27 20:51:26 +00001373 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001374 ThrowDisplayException(OptionError,"MissingArgument",option);
1375 if (IsGeometry(argv[i]) == MagickFalse)
1376 ThrowDisplayInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +00001377 resource_info.magnify=(unsigned int) StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001378 break;
1379 }
1380 if (LocaleCompare("map",option+1) == 0)
1381 {
1382 resource_info.map_type=(char *) NULL;
1383 if (*option == '+')
1384 break;
1385 (void) strcpy(argv[i]+1,"san");
1386 i++;
cristybb503372010-05-27 20:51:26 +00001387 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001388 ThrowDisplayException(OptionError,"MissingArgument",option);
1389 resource_info.map_type=argv[i];
1390 break;
1391 }
1392 if (LocaleCompare("matte",option+1) == 0)
1393 break;
1394 if (LocaleCompare("mattecolor",option+1) == 0)
1395 {
1396 if (*option == '+')
1397 break;
1398 i++;
cristybb503372010-05-27 20:51:26 +00001399 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001400 ThrowDisplayException(OptionError,"MissingArgument",option);
1401 resource_info.matte_color=argv[i];
1402 break;
1403 }
1404 if (LocaleCompare("monitor",option+1) == 0)
1405 break;
1406 if (LocaleCompare("monochrome",option+1) == 0)
1407 {
1408 if (*option == '+')
1409 break;
1410 quantize_info->number_colors=2;
1411 quantize_info->colorspace=GRAYColorspace;
1412 break;
1413 }
1414 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1415 }
1416 case 'n':
1417 {
1418 if (LocaleCompare("name",option+1) == 0)
1419 {
1420 resource_info.name=(char *) NULL;
1421 if (*option == '+')
1422 break;
1423 i++;
cristybb503372010-05-27 20:51:26 +00001424 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001425 ThrowDisplayException(OptionError,"MissingArgument",option);
1426 resource_info.name=ConstantString(argv[i]);
1427 break;
1428 }
1429 if (LocaleCompare("negate",option+1) == 0)
1430 break;
1431 if (LocaleCompare("noop",option+1) == 0)
1432 break;
1433 if (LocaleCompare("normalize",option+1) == 0)
1434 break;
1435 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1436 }
1437 case 'p':
1438 {
1439 if (LocaleCompare("page",option+1) == 0)
1440 {
1441 resource_info.image_geometry=(char *) NULL;
1442 if (*option == '+')
1443 break;
1444 i++;
cristybb503372010-05-27 20:51:26 +00001445 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001446 ThrowDisplayException(OptionError,"MissingArgument",option);
1447 resource_info.image_geometry=ConstantString(argv[i]);
1448 break;
1449 }
1450 if (LocaleCompare("profile",option+1) == 0)
1451 {
1452 i++;
cristybb503372010-05-27 20:51:26 +00001453 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001454 ThrowDisplayException(OptionError,"MissingArgument",option);
1455 break;
1456 }
1457 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1458 }
1459 case 'q':
1460 {
1461 if (LocaleCompare("quality",option+1) == 0)
1462 {
1463 if (*option == '+')
1464 break;
1465 i++;
cristybb503372010-05-27 20:51:26 +00001466 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001467 ThrowDisplayException(OptionError,"MissingArgument",option);
1468 if (IsGeometry(argv[i]) == MagickFalse)
1469 ThrowDisplayInvalidArgumentException(option,argv[i]);
1470 break;
1471 }
1472 if (LocaleCompare("quantize",option+1) == 0)
1473 {
cristybb503372010-05-27 20:51:26 +00001474 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001475 colorspace;
1476
1477 if (*option == '+')
1478 break;
1479 i++;
cristybb503372010-05-27 20:51:26 +00001480 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001481 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001482 colorspace=ParseCommandOption(MagickColorspaceOptions,
cristy3ed852e2009-09-05 21:47:34 +00001483 MagickFalse,argv[i]);
1484 if (colorspace < 0)
1485 ThrowDisplayException(OptionError,"UnrecognizedColorspace",
1486 argv[i]);
1487 break;
1488 }
1489 if (LocaleCompare("quiet",option+1) == 0)
1490 break;
1491 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1492 }
1493 case 'r':
1494 {
1495 if (LocaleCompare("raise",option+1) == 0)
1496 {
1497 i++;
cristybb503372010-05-27 20:51:26 +00001498 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001499 ThrowDisplayException(OptionError,"MissingArgument",option);
1500 if (IsGeometry(argv[i]) == MagickFalse)
1501 ThrowDisplayInvalidArgumentException(option,argv[i]);
1502 break;
1503 }
1504 if (LocaleCompare("regard-warnings",option+1) == 0)
1505 break;
1506 if (LocaleCompare("remote",option+1) == 0)
1507 {
1508 i++;
cristybb503372010-05-27 20:51:26 +00001509 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001510 ThrowDisplayException(OptionError,"MissingArgument",option);
1511 if (XRemoteCommand(display,resource_info.window_id,argv[i]) != 0)
1512 return(MagickFalse);
1513 i--;
1514 break;
1515 }
1516 if (LocaleCompare("repage",option+1) == 0)
1517 {
1518 if (*option == '+')
1519 break;
1520 i++;
cristybb503372010-05-27 20:51:26 +00001521 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001522 ThrowDisplayException(OptionError,"MissingArgument",option);
1523 if (IsGeometry(argv[i]) == MagickFalse)
1524 ThrowDisplayInvalidArgumentException(option,argv[i]);
1525 break;
1526 }
1527 if (LocaleCompare("resample",option+1) == 0)
1528 {
1529 if (*option == '+')
1530 break;
1531 i++;
cristybb503372010-05-27 20:51:26 +00001532 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001533 ThrowDisplayException(OptionError,"MissingArgument",option);
1534 if (IsGeometry(argv[i]) == MagickFalse)
1535 ThrowDisplayInvalidArgumentException(option,argv[i]);
1536 break;
1537 }
1538 if (LocaleCompare("resize",option+1) == 0)
1539 {
1540 if (*option == '+')
1541 break;
1542 i++;
cristybb503372010-05-27 20:51:26 +00001543 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001544 ThrowDisplayException(OptionError,"MissingArgument",option);
1545 if (IsGeometry(argv[i]) == MagickFalse)
1546 ThrowDisplayInvalidArgumentException(option,argv[i]);
1547 break;
1548 }
1549 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1550 {
1551 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1552 break;
1553 }
1554 if (LocaleCompare("roll",option+1) == 0)
1555 {
1556 if (*option == '+')
1557 break;
1558 i++;
cristybb503372010-05-27 20:51:26 +00001559 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001560 ThrowDisplayException(OptionError,"MissingArgument",option);
1561 if (IsGeometry(argv[i]) == MagickFalse)
1562 ThrowDisplayInvalidArgumentException(option,argv[i]);
1563 break;
1564 }
1565 if (LocaleCompare("rotate",option+1) == 0)
1566 {
1567 i++;
cristybb503372010-05-27 20:51:26 +00001568 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001569 ThrowDisplayException(OptionError,"MissingArgument",option);
1570 if (IsGeometry(argv[i]) == MagickFalse)
1571 ThrowDisplayInvalidArgumentException(option,argv[i]);
1572 break;
1573 }
1574 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1575 }
1576 case 's':
1577 {
1578 if (LocaleCompare("sample",option+1) == 0)
1579 {
1580 if (*option == '+')
1581 break;
1582 i++;
cristybb503372010-05-27 20:51:26 +00001583 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001584 ThrowDisplayException(OptionError,"MissingArgument",option);
1585 if (IsGeometry(argv[i]) == MagickFalse)
1586 ThrowDisplayInvalidArgumentException(option,argv[i]);
1587 break;
1588 }
1589 if (LocaleCompare("sampling-factor",option+1) == 0)
1590 {
1591 if (*option == '+')
1592 break;
1593 i++;
cristybb503372010-05-27 20:51:26 +00001594 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001595 ThrowDisplayException(OptionError,"MissingArgument",option);
1596 if (IsGeometry(argv[i]) == MagickFalse)
1597 ThrowDisplayInvalidArgumentException(option,argv[i]);
1598 break;
1599 }
1600 if (LocaleCompare("scenes",option+1) == 0)
1601 {
1602 if (*option == '+')
1603 break;
1604 i++;
cristybb503372010-05-27 20:51:26 +00001605 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001606 ThrowDisplayException(OptionError,"MissingArgument",option);
1607 if (IsSceneGeometry(argv[i],MagickFalse) == MagickFalse)
1608 ThrowDisplayInvalidArgumentException(option,argv[i]);
1609 break;
1610 }
1611 if (LocaleCompare("seed",option+1) == 0)
1612 {
1613 if (*option == '+')
1614 break;
1615 i++;
cristybb503372010-05-27 20:51:26 +00001616 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001617 ThrowDisplayException(OptionError,"MissingArgument",option);
1618 if (IsGeometry(argv[i]) == MagickFalse)
1619 ThrowDisplayInvalidArgumentException(option,argv[i]);
1620 break;
1621 }
1622 if (LocaleCompare("segment",option+1) == 0)
1623 {
1624 if (*option == '+')
1625 break;
1626 i++;
cristybb503372010-05-27 20:51:26 +00001627 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001628 ThrowDisplayException(OptionError,"MissingArgument",option);
1629 if (IsGeometry(argv[i]) == MagickFalse)
1630 ThrowDisplayInvalidArgumentException(option,argv[i]);
1631 break;
1632 }
1633 if (LocaleCompare("set",option+1) == 0)
1634 {
1635 i++;
cristybb503372010-05-27 20:51:26 +00001636 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001637 ThrowDisplayException(OptionError,"MissingArgument",option);
1638 if (*option == '+')
1639 break;
1640 i++;
cristybb503372010-05-27 20:51:26 +00001641 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001642 ThrowDisplayException(OptionError,"MissingArgument",option);
1643 break;
1644 }
1645 if (LocaleCompare("sharpen",option+1) == 0)
1646 {
1647 if (*option == '+')
1648 break;
1649 i++;
cristybb503372010-05-27 20:51:26 +00001650 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001651 ThrowDisplayException(OptionError,"MissingArgument",option);
1652 if (IsGeometry(argv[i]) == MagickFalse)
1653 ThrowDisplayInvalidArgumentException(option,argv[i]);
1654 break;
1655 }
1656 if (LocaleCompare("shared-memory",option+1) == 0)
1657 {
1658 resource_info.use_shared_memory= (*option == '-') ? MagickTrue :
1659 MagickFalse;
1660 break;
1661 }
1662 if (LocaleCompare("size",option+1) == 0)
1663 {
1664 if (*option == '+')
1665 break;
1666 i++;
cristybb503372010-05-27 20:51:26 +00001667 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001668 ThrowDisplayException(OptionError,"MissingArgument",option);
1669 if (IsGeometry(argv[i]) == MagickFalse)
1670 ThrowDisplayInvalidArgumentException(option,argv[i]);
1671 break;
1672 }
1673 if (LocaleCompare("strip",option+1) == 0)
1674 break;
1675 if (LocaleCompare("support",option+1) == 0)
1676 {
1677 i++; /* deprecated */
1678 break;
1679 }
1680 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1681 }
1682 case 't':
1683 {
1684 if (LocaleCompare("text-font",option+1) == 0)
1685 {
1686 resource_info.text_font=(char *) NULL;
1687 if (*option == '+')
1688 break;
1689 i++;
cristybb503372010-05-27 20:51:26 +00001690 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001691 ThrowDisplayException(OptionError,"MissingArgument",option);
1692 resource_info.text_font=XGetResourceClass(resource_database,
1693 GetClientName(),"font",argv[i]);
1694 break;
1695 }
1696 if (LocaleCompare("texture",option+1) == 0)
1697 {
1698 if (*option == '+')
1699 break;
1700 i++;
cristybb503372010-05-27 20:51:26 +00001701 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001702 ThrowDisplayException(OptionError,"MissingArgument",option);
1703 break;
1704 }
1705 if (LocaleCompare("threshold",option+1) == 0)
1706 {
1707 if (*option == '+')
1708 break;
1709 i++;
cristybb503372010-05-27 20:51:26 +00001710 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001711 ThrowDisplayException(OptionError,"MissingArgument",option);
1712 if (IsGeometry(argv[i]) == MagickFalse)
1713 ThrowDisplayInvalidArgumentException(option,argv[i]);
1714 break;
1715 }
1716 if (LocaleCompare("thumbnail",option+1) == 0)
1717 {
1718 if (*option == '+')
1719 break;
1720 i++;
cristybb503372010-05-27 20:51:26 +00001721 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001722 ThrowDisplayException(OptionError,"MissingArgument",option);
1723 if (IsGeometry(argv[i]) == MagickFalse)
1724 ThrowDisplayInvalidArgumentException(option,argv[i]);
1725 break;
1726 }
1727 if (LocaleCompare("title",option+1) == 0)
1728 {
1729 resource_info.title=(char *) NULL;
1730 if (*option == '+')
1731 break;
1732 i++;
cristybb503372010-05-27 20:51:26 +00001733 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001734 ThrowDisplayException(OptionError,"MissingArgument",option);
1735 resource_info.title=argv[i];
1736 break;
1737 }
1738 if (LocaleCompare("transparent-color",option+1) == 0)
1739 {
1740 if (*option == '+')
1741 break;
1742 i++;
cristybb503372010-05-27 20:51:26 +00001743 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001744 ThrowDisplayException(OptionError,"MissingArgument",option);
1745 break;
1746 }
1747 if (LocaleCompare("treedepth",option+1) == 0)
1748 {
1749 quantize_info->tree_depth=0;
1750 if (*option == '+')
1751 break;
1752 i++;
cristybb503372010-05-27 20:51:26 +00001753 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001754 ThrowDisplayException(OptionError,"MissingArgument",option);
1755 if (IsGeometry(argv[i]) == MagickFalse)
1756 ThrowDisplayInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +00001757 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001758 break;
1759 }
1760 if (LocaleCompare("trim",option+1) == 0)
1761 break;
1762 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1763 }
1764 case 'u':
1765 {
1766 if (LocaleCompare("update",option+1) == 0)
1767 {
1768 resource_info.update=(unsigned int) (*option == '-');
1769 if (*option == '+')
1770 break;
1771 i++;
cristybb503372010-05-27 20:51:26 +00001772 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001773 ThrowDisplayException(OptionError,"MissingArgument",option);
1774 if (IsGeometry(argv[i]) == MagickFalse)
1775 ThrowDisplayInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +00001776 resource_info.update=(unsigned int) StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001777 break;
1778 }
1779 if (LocaleCompare("use-pixmap",option+1) == 0)
1780 {
1781 resource_info.use_pixmap=(*option == '-') ? MagickTrue :
1782 MagickFalse;
1783 break;
1784 }
1785 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1786 }
1787 case 'v':
1788 {
1789 if (LocaleCompare("verbose",option+1) == 0)
1790 break;
1791 if ((LocaleCompare("version",option+1) == 0) ||
1792 (LocaleCompare("-version",option+1) == 0))
1793 {
cristyb51dff52011-05-19 16:55:47 +00001794 (void) FormatLocaleFile(stdout,"Version: %s\n",
cristybb503372010-05-27 20:51:26 +00001795 GetMagickVersion((size_t *) NULL));
cristy1e604812011-05-19 18:07:50 +00001796 (void) FormatLocaleFile(stdout,"Copyright: %s\n",
1797 GetMagickCopyright());
1798 (void) FormatLocaleFile(stdout,"Features: %s\n\n",
1799 GetMagickFeatures());
cristy3ed852e2009-09-05 21:47:34 +00001800 break;
1801 }
1802 if (LocaleCompare("visual",option+1) == 0)
1803 {
1804 resource_info.visual_type=(char *) NULL;
1805 if (*option == '+')
1806 break;
1807 i++;
cristybb503372010-05-27 20:51:26 +00001808 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001809 ThrowDisplayException(OptionError,"MissingArgument",option);
1810 resource_info.visual_type=argv[i];
1811 break;
1812 }
1813 if (LocaleCompare("virtual-pixel",option+1) == 0)
1814 {
cristybb503372010-05-27 20:51:26 +00001815 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001816 method;
1817
1818 if (*option == '+')
1819 break;
1820 i++;
cristybb503372010-05-27 20:51:26 +00001821 if (i == (ssize_t) (argc-1))
cristy3ed852e2009-09-05 21:47:34 +00001822 ThrowDisplayException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001823 method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +00001824 argv[i]);
1825 if (method < 0)
1826 ThrowDisplayException(OptionError,
1827 "UnrecognizedVirtualPixelMethod",argv[i]);
1828 break;
1829 }
1830 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1831 }
1832 case 'w':
1833 {
1834 if (LocaleCompare("window",option+1) == 0)
1835 {
1836 resource_info.window_id=(char *) NULL;
1837 if (*option == '+')
1838 break;
1839 i++;
cristybb503372010-05-27 20:51:26 +00001840 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001841 ThrowDisplayException(OptionError,"MissingArgument",option);
1842 resource_info.window_id=argv[i];
1843 break;
1844 }
1845 if (LocaleCompare("window-group",option+1) == 0)
1846 {
1847 resource_info.window_group=(char *) NULL;
1848 if (*option == '+')
1849 break;
1850 i++;
cristybb503372010-05-27 20:51:26 +00001851 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001852 ThrowDisplayException(OptionError,"MissingArgument",option);
cristydbdd0e32011-11-04 23:29:40 +00001853 if (StringToDouble(argv[i],(char **) NULL) != 0)
cristy3ed852e2009-09-05 21:47:34 +00001854 resource_info.window_group=argv[i];
1855 break;
1856 }
1857 if (LocaleCompare("write",option+1) == 0)
1858 {
1859 resource_info.write_filename=(char *) NULL;
1860 if (*option == '+')
1861 break;
1862 i++;
cristybb503372010-05-27 20:51:26 +00001863 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001864 ThrowDisplayException(OptionError,"MissingArgument",option);
1865 resource_info.write_filename=argv[i];
1866 if (IsPathAccessible(resource_info.write_filename) != MagickFalse)
1867 {
1868 char
1869 answer[2],
1870 *p;
1871
cristyb51dff52011-05-19 16:55:47 +00001872 (void) FormatLocaleFile(stderr,"Overwrite %s? ",
cristy3ed852e2009-09-05 21:47:34 +00001873 resource_info.write_filename);
1874 p=fgets(answer,(int) sizeof(answer),stdin);
cristyda16f162011-02-19 23:52:17 +00001875 (void) p;
cristy3ed852e2009-09-05 21:47:34 +00001876 if (((*answer != 'y') && (*answer != 'Y')))
1877 return(MagickFalse);
1878 }
1879 break;
1880 }
1881 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1882 }
1883 case '?':
1884 break;
1885 default:
1886 ThrowDisplayException(OptionError,"UnrecognizedOption",option);
1887 }
cristy042ee782011-04-22 18:48:30 +00001888 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1889 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00001890 if (fire != MagickFalse)
1891 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1892 }
1893 if (k != 0)
1894 ThrowDisplayException(OptionError,"UnbalancedParenthesis",argv[i]);
1895 if (state & RetainColorsState)
1896 {
1897 XRetainWindowColors(display,XRootWindow(display,XDefaultScreen(display)));
1898 (void) XSync(display,MagickFalse);
1899 }
1900 DestroyDisplay();
1901 return(status != 0 ? MagickTrue : MagickFalse);
1902#else
1903 (void) argc;
1904 (void) argv;
1905 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1906 "DelegateLibrarySupportNotBuiltIn","`%s' (X11)",image_info->filename);
1907 return(DisplayUsage());
1908#endif
1909}