blob: 33eb5fa3c842df3e61fc9ebe45f4c527804860cb [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% IIIII M M PPPP OOO RRRR TTTTT %
7% I MM MM P P O O R R T %
8% I M M M PPPP O O RRRR T %
9% I M M P O O R R T %
10% IIIII M M P OOO R R T %
11% %
12% %
13% Import Image from X11 Screen %
14% %
15% Software Design %
cristyde984cd2013-12-01 14:49:27 +000016% Cristy %
cristy3ed852e2009-09-05 21:47:34 +000017% July 1992 %
18% %
19% %
Cristy7ce65e72015-12-12 18:03:16 -050020% Copyright 1999-2016 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 import program to capture some or all of an X server screen and
37% save the image to a file.
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"
cristy4c08aed2011-07-01 19:47:50 +000047#include "MagickCore/string-private.h"
cristya43c34d2015-01-11 23:53:36 +000048#include "MagickCore/image-private.h"
cristy7832dc22011-09-05 01:21:53 +000049#include "MagickCore/xwindow-private.h"
cristy3ed852e2009-09-05 21:47:34 +000050
51/*
52%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53% %
54% %
55% %
56+ I m p o r t I m a g e C o m m a n d %
57% %
58% %
59% %
60%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61%
62% ImportImageCommand() reads an image from any visible window on an X server
63% and outputs it as an image file. You can capture a single window, the
64% entire screen, or any rectangular portion of the screen. You can use the
65% display utility for redisplay, printing, editing, formatting, archiving,
glennrp79b5c332013-01-09 13:19:55 +000066% image processing, etc. of the captured image.
cristy3ed852e2009-09-05 21:47:34 +000067%
68% The target window can be specified by id, name, or may be selected by
69% clicking the mouse in the desired window. If you press a button and then
70% drag, a rectangle will form which expands and contracts as the mouse moves.
71% To save the portion of the screen defined by the rectangle, just release
72% the button. The keyboard bell is rung once at the beginning of the screen
73% capture and twice when it completes.
74%
75% The format of the ImportImageCommand method is:
76%
77% MagickBooleanType ImportImageCommand(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
94static MagickBooleanType ImportUsage(void)
95{
96 const char
97 **p;
98
99 static const char
100 *miscellaneous[]=
101 {
102 "-debug events display copious debugging information",
103 "-help print program options",
104 "-list type print a list of supported option arguments",
105 "-log format format of debugging information",
106 "-version print version information",
107 (char *) NULL
108 },
109 *operators[]=
110 {
111 "-annotate geometry text",
112 " annotate the image with text",
cristy3ed852e2009-09-05 21:47:34 +0000113 "-colors value preferred number of colors in the image",
114 "-crop geometry preferred size and location of the cropped image",
115 "-encipher filename convert plain pixels to cipher pixels",
cristy901f09d2009-10-16 22:56:10 +0000116 "-geometry geometry preferred size or location of the image",
cristy3ed852e2009-09-05 21:47:34 +0000117 "-help print program options",
118 "-monochrome transform image to black and white",
119 "-negate replace every pixel with its complementary color ",
120 "-repage geometry size and location of an image canvas",
121 "-quantize colorspace reduce colors in this colorspace",
122 "-resize geometry resize the image",
123 "-rotate degrees apply Paeth rotation to the image",
124 "-strip strip image of all profiles and comments",
125 "-thumbnail geometry create a thumbnail of the image",
126 "-transparent color make this color transparent within the image",
127 "-trim trim image edges",
128 "-type type image type",
129 (char *) NULL
130 },
131 *settings[]=
132 {
133 "-adjoin join images into a single multi-image file",
cristy079bd9e2010-03-03 15:09:45 +0000134 "-border include window border in the output image",
cristy3ed852e2009-09-05 21:47:34 +0000135 "-channel type apply option to select image channels",
136 "-colorspace type alternate image colorspace",
137 "-comment string annotate image with comment",
138 "-compress type type of pixel compression when writing the image",
139 "-define format:option",
140 " define one or more image format options",
141 "-density geometry horizontal and vertical density of the image",
142 "-depth value image depth",
143 "-descend obtain image by descending window hierarchy",
144 "-display server X server to contact",
145 "-dispose method layer disposal method",
146 "-dither method apply error diffusion to image",
147 "-delay value display the next image after pausing",
148 "-encipher filename convert plain pixels to cipher pixels",
149 "-endian type endianness (MSB or LSB) of the image",
150 "-encoding type text encoding type",
151 "-filter type use this filter when resizing an image",
152 "-format \"string\" output formatted image characteristics",
153 "-frame include window manager frame",
154 "-gravity direction which direction to gravitate towards",
155 "-identify identify the format and characteristics of the image",
156 "-interlace type None, Line, Plane, or Partition",
157 "-interpolate method pixel color interpolation method",
158 "-label string assign a label to an image",
159 "-limit type value Area, Disk, Map, or Memory resource limit",
160 "-monitor monitor progress",
161 "-page geometry size and location of an image canvas",
cristy1fbf9dc2013-10-06 17:19:39 +0000162 "-pause seconds seconds delay between snapshots",
cristy3ed852e2009-09-05 21:47:34 +0000163 "-pointsize value font point size",
164 "-quality value JPEG/MIFF/PNG compression level",
165 "-quiet suppress all warning messages",
166 "-regard-warnings pay attention to warning messages",
167 "-respect-parentheses settings remain in effect until parenthesis boundary",
168 "-sampling-factor geometry",
169 " horizontal and vertical sampling factor",
170 "-scene value image scene number",
171 "-screen select image from root window",
172 "-seed value seed a new sequence of pseudo-random numbers",
173 "-set property value set an image property",
174 "-silent operate silently, i.e. don't ring any bells ",
175 "-snaps value number of screen snapshots",
cristye9252c22013-07-30 15:43:21 +0000176 "-support factor resize support: > 1.0 is blurry, < 1.0 is sharp",
cristyd9a29192010-10-16 16:49:53 +0000177 "-synchronize synchronize image to storage device",
178 "-taint declare the image as modified",
cristy3ed852e2009-09-05 21:47:34 +0000179 "-transparent-color color",
180 " transparent color",
181 "-treedepth value color tree depth",
182 "-verbose print detailed information about the image",
183 "-virtual-pixel method",
184 " Constant, Edge, Mirror, or Tile",
185 "-window id select window with this id or name",
186 (char *) NULL
187 };
188
cristy4f7a6132012-12-23 00:35:19 +0000189 ListMagickVersion(stdout);
cristy3ed852e2009-09-05 21:47:34 +0000190 (void) printf("Usage: %s [options ...] [ file ]\n",
191 GetClientName());
192 (void) printf("\nImage Settings:\n");
193 for (p=settings; *p != (char *) NULL; p++)
194 (void) printf(" %s\n",*p);
195 (void) printf("\nImage Operators:\n");
196 for (p=operators; *p != (char *) NULL; p++)
197 (void) printf(" %s\n",*p);
198 (void) printf("\nMiscellaneous Options:\n");
199 for (p=miscellaneous; *p != (char *) NULL; p++)
200 (void) printf(" %s\n",*p);
201 (void) printf(
202 "\nBy default, 'file' is written in the MIFF image format. To\n");
203 (void) printf(
204 "specify a particular image format, precede the filename with an image\n");
205 (void) printf(
206 "format name and a colon (i.e. ps:image) or specify the image type as\n");
207 (void) printf(
208 "the filename suffix (i.e. image.ps). Specify 'file' as '-' for\n");
209 (void) printf("standard input or output.\n");
210 return(MagickFalse);
211}
212
cristy3ed852e2009-09-05 21:47:34 +0000213WandExport MagickBooleanType ImportImageCommand(ImageInfo *image_info,
214 int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
215{
216#if defined(MAGICKCORE_X11_DELEGATE)
217#define DestroyImport() \
218{ \
219 XDestroyResourceInfo(&resource_info); \
220 if (display != (Display *) NULL) \
221 { \
222 XCloseDisplay(display); \
223 display=(Display *) NULL; \
224 } \
225 DestroyImageStack(); \
226 if (target_window != (char *) NULL) \
227 target_window=DestroyString(target_window); \
cristybb503372010-05-27 20:51:26 +0000228 for (i=0; i < (ssize_t) argc; i++) \
cristy3ed852e2009-09-05 21:47:34 +0000229 argv[i]=DestroyString(argv[i]); \
230 argv=(char **) RelinquishMagickMemory(argv); \
231}
232#define ThrowImportException(asperity,tag,option) \
233{ \
cristyefe601c2013-01-05 17:51:12 +0000234 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
cristy3ed852e2009-09-05 21:47:34 +0000235 option); \
236 DestroyImport(); \
237 return(MagickFalse); \
238}
239#define ThrowImportInvalidArgumentException(option,argument) \
240{ \
241 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
anthonye5b39652012-04-21 05:37:29 +0000242 "InvalidArgument","'%s': %s",option,argument); \
cristy3ed852e2009-09-05 21:47:34 +0000243 DestroyImport(); \
244 return(MagickFalse); \
245}
246
247 char
248 *filename,
249 *option,
250 *resource_value,
251 *server_name,
252 *target_window;
253
254 Display
255 *display;
256
257 Image
258 *image;
259
260 ImageStack
261 image_stack[MaxImageStackDepth+1];
262
cristy3ed852e2009-09-05 21:47:34 +0000263 MagickBooleanType
264 fire,
cristyebbcfea2011-02-25 02:43:54 +0000265 pend,
266 respect_parenthesis;
cristy3ed852e2009-09-05 21:47:34 +0000267
268 MagickStatusType
269 status;
270
271 QuantizeInfo
272 *quantize_info;
273
cristybb503372010-05-27 20:51:26 +0000274 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000275 i;
276
cristy9d314ff2011-03-09 01:30:28 +0000277 ssize_t
278 j,
279 k,
280 snapshots;
281
cristy3ed852e2009-09-05 21:47:34 +0000282 XImportInfo
283 ximage_info;
284
285 XResourceInfo
286 resource_info;
287
288 XrmDatabase
289 resource_database;
290
291 /*
292 Set defaults.
293 */
294 assert(image_info != (ImageInfo *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000295 assert(image_info->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +0000296 if (image_info->debug != MagickFalse)
297 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
298 assert(exception != (ExceptionInfo *) NULL);
299 if (argc == 2)
300 {
301 option=argv[1];
302 if ((LocaleCompare("version",option+1) == 0) ||
303 (LocaleCompare("-version",option+1) == 0))
304 {
cristy4f7a6132012-12-23 00:35:19 +0000305 ListMagickVersion(stdout);
cristy3ed852e2009-09-05 21:47:34 +0000306 return(MagickFalse);
307 }
308 }
309 display=(Display *) NULL;
310 j=1;
311 k=0;
312 NewImageStack();
313 option=(char *) NULL;
314 pend=MagickFalse;
315 resource_database=(XrmDatabase) NULL;
cristyebbcfea2011-02-25 02:43:54 +0000316 respect_parenthesis=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +0000317 (void) ResetMagickMemory(&resource_info,0,sizeof(resource_info));
318 server_name=(char *) NULL;
319 status=MagickTrue;
320 SetNotifyHandlers;
321 target_window=(char *) NULL;
322 /*
323 Check for server name specified on the command line.
324 */
325 ReadCommandlLine(argc,&argv);
326 status=ExpandFilenames(&argc,&argv);
327 if (status == MagickFalse)
328 ThrowImportException(ResourceLimitError,"MemoryAllocationFailed",
329 GetExceptionMessage(errno));
cristybb503372010-05-27 20:51:26 +0000330 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000331 {
332 /*
333 Check command line for server name.
334 */
335 option=argv[i];
336 if (LocaleCompare("display",option+1) == 0)
337 {
338 /*
339 User specified server name.
340 */
341 i++;
cristybb503372010-05-27 20:51:26 +0000342 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000343 ThrowImportException(OptionError,"MissingArgument",option);
344 server_name=argv[i];
345 }
346 if ((LocaleCompare("help",option+1) == 0) ||
347 (LocaleCompare("-help",option+1) == 0))
348 return(ImportUsage());
349 }
350 /*
351 Get user defaults from X resource database.
352 */
353 display=XOpenDisplay(server_name);
354 if (display == (Display *) NULL)
355 ThrowImportException(XServerError,"UnableToOpenXServer",
356 XDisplayName(server_name));
357 (void) XSetErrorHandler(XError);
358 resource_database=XGetResourceDatabase(display,GetClientName());
359 XGetImportInfo(&ximage_info);
360 XGetResourceInfo(image_info,resource_database,GetClientName(),
361 &resource_info);
362 quantize_info=resource_info.quantize_info;
363 resource_value=XGetResourceInstance(resource_database,GetClientName(),
364 "border","False");
anthony2e4501b2012-03-30 04:41:54 +0000365 ximage_info.borders=IsStringTrue(resource_value);
cristy3ed852e2009-09-05 21:47:34 +0000366 resource_value=XGetResourceInstance(resource_database,GetClientName(),
367 "delay","0");
cristye27293e2009-12-18 02:53:20 +0000368 resource_info.delay=(unsigned int) StringToUnsignedLong(resource_value);
cristy3ed852e2009-09-05 21:47:34 +0000369 image_info->density=XGetResourceInstance(resource_database,GetClientName(),
370 "density",(char *) NULL);
371 resource_value=XGetResourceInstance(resource_database,GetClientName(),
cristy64057b02013-01-11 00:09:58 +0000372 "descend","False");
anthony2e4501b2012-03-30 04:41:54 +0000373 ximage_info.descend=IsStringTrue(resource_value);
cristy3ed852e2009-09-05 21:47:34 +0000374 resource_value=XGetResourceInstance(resource_database,GetClientName(),
375 "frame","False");
anthony2e4501b2012-03-30 04:41:54 +0000376 ximage_info.frame=IsStringTrue(resource_value);
cristy3ed852e2009-09-05 21:47:34 +0000377 resource_value=XGetResourceInstance(resource_database,GetClientName(),
378 "interlace","none");
379 image_info->interlace=UndefinedInterlace;
380 if (LocaleCompare("None",resource_value) == 0)
381 image_info->interlace=NoInterlace;
382 if (LocaleCompare("Line",resource_value) == 0)
383 image_info->interlace=LineInterlace;
384 if (LocaleCompare("Plane",resource_value) == 0)
385 image_info->interlace=PlaneInterlace;
386 if (LocaleCompare("Partition",resource_value) == 0)
387 image_info->interlace=PartitionInterlace;
388 if (image_info->interlace == UndefinedInterlace)
389 ThrowImportException(OptionError,"Unrecognized interlace type",
390 resource_value);
391 image_info->page=XGetResourceInstance(resource_database,GetClientName(),
392 "pageGeometry",(char *) NULL);
393 resource_value=XGetResourceInstance(resource_database,GetClientName(),
394 "pause","0");
cristye27293e2009-12-18 02:53:20 +0000395 resource_info.pause=(unsigned int) StringToUnsignedLong(resource_value);
cristy3ed852e2009-09-05 21:47:34 +0000396 resource_value=XGetResourceInstance(resource_database,GetClientName(),
397 "quality","85");
cristye27293e2009-12-18 02:53:20 +0000398 image_info->quality=StringToUnsignedLong(resource_value);
cristy3ed852e2009-09-05 21:47:34 +0000399 resource_value=XGetResourceInstance(resource_database,GetClientName(),
400 "screen","False");
anthony2e4501b2012-03-30 04:41:54 +0000401 ximage_info.screen=IsStringTrue(resource_value);
cristy3ed852e2009-09-05 21:47:34 +0000402 resource_value=XGetResourceInstance(resource_database,GetClientName(),
403 "silent","False");
anthony2e4501b2012-03-30 04:41:54 +0000404 ximage_info.silent=IsStringTrue(resource_value);
cristy3ed852e2009-09-05 21:47:34 +0000405 resource_value=XGetResourceInstance(resource_database,GetClientName(),
406 "verbose","False");
anthony2e4501b2012-03-30 04:41:54 +0000407 image_info->verbose=IsStringTrue(resource_value);
cristy3ed852e2009-09-05 21:47:34 +0000408 resource_value=XGetResourceInstance(resource_database,GetClientName(),
409 "dither","True");
cristycbda6112012-05-27 20:57:16 +0000410 quantize_info->dither_method=IsStringTrue(resource_value) != MagickFalse ?
411 RiemersmaDitherMethod : NoDitherMethod;
cristy3ed852e2009-09-05 21:47:34 +0000412 snapshots=1;
413 status=MagickTrue;
414 filename=(char *) NULL;
415 /*
416 Check command syntax.
417 */
cristybb503372010-05-27 20:51:26 +0000418 for (i=1; i < (ssize_t) argc; i++)
cristy3ed852e2009-09-05 21:47:34 +0000419 {
420 option=argv[i];
421 if (LocaleCompare(option,"(") == 0)
422 {
423 FireImageStack(MagickFalse,MagickTrue,pend);
424 if (k == MaxImageStackDepth)
425 ThrowImportException(OptionError,"ParenthesisNestedTooDeeply",
426 option);
427 PushImageStack();
428 continue;
429 }
430 if (LocaleCompare(option,")") == 0)
431 {
432 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
433 if (k == 0)
434 ThrowImportException(OptionError,"UnableToParseExpression",option);
435 PopImageStack();
436 continue;
437 }
cristy042ee782011-04-22 18:48:30 +0000438 if (IsCommandOption(option) == MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000439 {
440 Image
441 *images;
442
cristybb503372010-05-27 20:51:26 +0000443 size_t
cristy3ed852e2009-09-05 21:47:34 +0000444 scene;
445
446 /*
447 Read image from X server.
448 */
449 FireImageStack(MagickFalse,MagickFalse,pend);
450 filename=argv[i];
451 if (target_window != (char *) NULL)
452 (void) CopyMagickString(image_info->filename,target_window,
cristy151b66d2015-04-15 10:50:31 +0000453 MagickPathExtent);
cristybb503372010-05-27 20:51:26 +0000454 for (scene=0; scene < (size_t) MagickMax(snapshots,1); scene++)
cristy3ed852e2009-09-05 21:47:34 +0000455 {
Cristy66387d22015-11-02 07:41:25 -0500456 MagickDelay(1000*resource_info.pause);
cristy6710d842011-10-20 23:23:00 +0000457 images=XImportImage(image_info,&ximage_info,exception);
cristy3ed852e2009-09-05 21:47:34 +0000458 status&=(images != (Image *) NULL) &&
459 (exception->severity < ErrorException);
460 if (images == (Image *) NULL)
461 continue;
cristy151b66d2015-04-15 10:50:31 +0000462 (void) CopyMagickString(images->filename,filename,MagickPathExtent);
463 (void) CopyMagickString(images->magick,"PS",MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000464 images->scene=scene;
465 AppendImageStack(images);
466 }
467 continue;
468 }
469 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
470 switch(*(option+1))
471 {
472 case 'a':
473 {
474 if (LocaleCompare("adjoin",option+1) == 0)
475 break;
476 if (LocaleCompare("annotate",option+1) == 0)
477 {
478 if (*option == '+')
479 break;
480 i++;
cristye81f5522014-05-07 01:25:59 +0000481 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000482 ThrowImportException(OptionError,"MissingArgument",option);
483 if (IsGeometry(argv[i]) == MagickFalse)
484 ThrowImportInvalidArgumentException(option,argv[i]);
cristye81f5522014-05-07 01:25:59 +0000485 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000486 ThrowImportException(OptionError,"MissingArgument",option);
487 i++;
488 break;
489 }
490 ThrowImportException(OptionError,"UnrecognizedOption",option);
491 }
492 case 'b':
493 {
494 if (LocaleCompare("border",option+1) == 0)
495 {
cristy151b66d2015-04-15 10:50:31 +0000496 (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000497 ximage_info.borders=(*option == '-') ? MagickTrue : MagickFalse;
498 break;
499 }
500 if (LocaleCompare("bordercolor",option+1) == 0)
501 {
502 if (*option == '+')
503 break;
504 i++;
cristybb503372010-05-27 20:51:26 +0000505 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000506 ThrowImportException(OptionError,"MissingArgument",option);
507 break;
508 }
509 ThrowImportException(OptionError,"UnrecognizedOption",option);
510 }
511 case 'c':
512 {
513 if (LocaleCompare("cache",option+1) == 0)
514 {
515 if (*option == '+')
516 break;
517 i++;
cristybb503372010-05-27 20:51:26 +0000518 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000519 ThrowImportException(OptionError,"MissingArgument",option);
520 if (IsGeometry(argv[i]) == MagickFalse)
521 ThrowImportInvalidArgumentException(option,argv[i]);
522 break;
523 }
524 if (LocaleCompare("channel",option+1) == 0)
525 {
cristybb503372010-05-27 20:51:26 +0000526 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000527 channel;
528
529 if (*option == '+')
530 break;
531 i++;
cristye81f5522014-05-07 01:25:59 +0000532 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000533 ThrowImportException(OptionError,"MissingArgument",option);
534 channel=ParseChannelOption(argv[i]);
535 if (channel < 0)
536 ThrowImportException(OptionError,"UnrecognizedChannelType",
537 argv[i]);
538 break;
539 }
540 if (LocaleCompare("colors",option+1) == 0)
541 {
542 quantize_info->number_colors=0;
543 if (*option == '+')
544 break;
545 i++;
cristybb503372010-05-27 20:51:26 +0000546 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000547 ThrowImportException(OptionError,"MissingArgument",option);
548 if (IsGeometry(argv[i]) == MagickFalse)
549 ThrowImportInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +0000550 quantize_info->number_colors=StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000551 break;
552 }
553 if (LocaleCompare("colorspace",option+1) == 0)
554 {
cristybb503372010-05-27 20:51:26 +0000555 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000556 colorspace;
557
558 if (*option == '+')
559 break;
560 i++;
cristybb503372010-05-27 20:51:26 +0000561 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000562 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000563 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000564 argv[i]);
565 if (colorspace < 0)
566 ThrowImportException(OptionError,"UnrecognizedColorspace",
567 argv[i]);
568 break;
569 }
570 if (LocaleCompare("comment",option+1) == 0)
571 {
572 if (*option == '+')
573 break;
574 i++;
cristybb503372010-05-27 20:51:26 +0000575 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000576 ThrowImportException(OptionError,"MissingArgument",option);
577 status=SetImageOption(image_info,"comment",argv[i]);
578 if (status == MagickFalse)
579 ThrowImportException(OptionError,"UnrecognizedOption",argv[i]);
580 break;
581 }
582 if (LocaleCompare("compress",option+1) == 0)
583 {
cristybb503372010-05-27 20:51:26 +0000584 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000585 compress;
586
587 if (*option == '+')
588 break;
589 i++;
cristybb503372010-05-27 20:51:26 +0000590 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000591 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000592 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000593 argv[i]);
594 if (compress < 0)
595 ThrowImportException(OptionError,"UnrecognizedImageCompression",
596 argv[i]);
597 break;
598 }
cristy22879752009-10-25 23:55:40 +0000599 if (LocaleCompare("concurrent",option+1) == 0)
600 break;
cristy3ed852e2009-09-05 21:47:34 +0000601 if (LocaleCompare("crop",option+1) == 0)
602 {
603 if (*option == '+')
604 break;
605 i++;
cristybb503372010-05-27 20:51:26 +0000606 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000607 ThrowImportException(OptionError,"MissingArgument",option);
608 if (IsGeometry(argv[i]) == MagickFalse)
609 ThrowImportInvalidArgumentException(option,argv[i]);
610 break;
611 }
612 ThrowImportException(OptionError,"UnrecognizedOption",option);
613 }
614 case 'd':
615 {
616 if (LocaleCompare("debug",option+1) == 0)
617 {
cristybb503372010-05-27 20:51:26 +0000618 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000619 event;
620
621 if (*option == '+')
622 break;
623 i++;
cristybb503372010-05-27 20:51:26 +0000624 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000625 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000626 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000627 if (event < 0)
628 ThrowImportException(OptionError,"UnrecognizedEventType",argv[i]);
629 (void) SetLogEventMask(argv[i]);
630 break;
631 }
632 if (LocaleCompare("define",option+1) == 0)
633 {
634 i++;
cristybb503372010-05-27 20:51:26 +0000635 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000636 ThrowImportException(OptionError,"MissingArgument",option);
637 if (*option == '+')
638 {
639 const char
640 *define;
641
642 define=GetImageOption(image_info,argv[i]);
643 if (define == (char *) NULL)
644 ThrowImportException(OptionError,"NoSuchOption",argv[i]);
645 break;
646 }
647 break;
648 }
649 if (LocaleCompare("delay",option+1) == 0)
650 {
651 if (*option == '+')
652 break;
653 i++;
cristybb503372010-05-27 20:51:26 +0000654 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000655 ThrowImportException(OptionError,"MissingArgument",option);
656 if (IsGeometry(argv[i]) == MagickFalse)
657 ThrowImportInvalidArgumentException(option,argv[i]);
658 status=SetImageOption(image_info,"delay",argv[i]);
659 if (status == MagickFalse)
660 ThrowImportException(OptionError,"UnrecognizedOption",argv[i]);
661 break;
662 }
663 if (LocaleCompare("density",option+1) == 0)
664 {
665 if (*option == '+')
666 break;
667 i++;
cristybb503372010-05-27 20:51:26 +0000668 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000669 ThrowImportException(OptionError,"MissingArgument",option);
670 if (IsGeometry(argv[i]) == MagickFalse)
671 ThrowImportInvalidArgumentException(option,argv[i]);
672 break;
673 }
674 if (LocaleCompare("depth",option+1) == 0)
675 {
676 if (*option == '+')
677 break;
678 i++;
cristybb503372010-05-27 20:51:26 +0000679 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000680 ThrowImportException(OptionError,"MissingArgument",option);
681 if (IsGeometry(argv[i]) == MagickFalse)
682 ThrowImportInvalidArgumentException(option,argv[i]);
683 break;
684 }
685 if (LocaleCompare("descend",option+1) == 0)
686 {
687 ximage_info.descend=(*option == '-') ? MagickTrue : MagickFalse;
688 break;
689 }
690 if (LocaleCompare("display",option+1) == 0)
691 {
692 if (*option == '+')
693 break;
694 i++;
cristybb503372010-05-27 20:51:26 +0000695 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000696 ThrowImportException(OptionError,"MissingArgument",option);
697 break;
698 }
699 if (LocaleCompare("dispose",option+1) == 0)
700 {
cristybb503372010-05-27 20:51:26 +0000701 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000702 dispose;
703
704 if (*option == '+')
705 break;
706 i++;
cristybb503372010-05-27 20:51:26 +0000707 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000708 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000709 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000710 if (dispose < 0)
711 ThrowImportException(OptionError,"UnrecognizedDisposeMethod",
712 argv[i]);
713 break;
714 }
715 if (LocaleCompare("dither",option+1) == 0)
716 {
cristybb503372010-05-27 20:51:26 +0000717 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000718 method;
719
cristycbda6112012-05-27 20:57:16 +0000720 quantize_info->dither_method=NoDitherMethod;
cristy3ed852e2009-09-05 21:47:34 +0000721 if (*option == '+')
722 break;
723 i++;
cristybb503372010-05-27 20:51:26 +0000724 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000725 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000726 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000727 if (method < 0)
728 ThrowImportException(OptionError,"UnrecognizedDitherMethod",
729 argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000730 quantize_info->dither_method=(DitherMethod) method;
731 break;
732 }
cristy22879752009-10-25 23:55:40 +0000733 if (LocaleCompare("duration",option+1) == 0)
734 {
735 if (*option == '+')
736 break;
737 i++;
cristye81f5522014-05-07 01:25:59 +0000738 if (i == (ssize_t) argc)
cristy22879752009-10-25 23:55:40 +0000739 ThrowImportException(OptionError,"MissingArgument",option);
740 if (IsGeometry(argv[i]) == MagickFalse)
741 ThrowImportInvalidArgumentException(option,argv[i]);
742 break;
743 }
cristy3ed852e2009-09-05 21:47:34 +0000744 ThrowImportException(OptionError,"UnrecognizedOption",option);
745 }
746 case 'e':
747 {
748 if (LocaleCompare("encipher",option+1) == 0)
749 {
750 if (*option == '+')
751 break;
752 i++;
cristye81f5522014-05-07 01:25:59 +0000753 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000754 ThrowImportException(OptionError,"MissingArgument",option);
755 break;
756 }
757 if (LocaleCompare("encoding",option+1) == 0)
758 {
759 if (*option == '+')
760 break;
761 i++;
cristybb503372010-05-27 20:51:26 +0000762 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000763 ThrowImportException(OptionError,"MissingArgument",option);
764 break;
765 }
766 if (LocaleCompare("endian",option+1) == 0)
767 {
cristybb503372010-05-27 20:51:26 +0000768 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000769 endian;
770
771 if (*option == '+')
772 break;
773 i++;
cristybb503372010-05-27 20:51:26 +0000774 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000775 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000776 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000777 argv[i]);
778 if (endian < 0)
779 ThrowImportException(OptionError,"UnrecognizedEndianType",
780 argv[i]);
781 break;
782 }
783 ThrowImportException(OptionError,"UnrecognizedOption",option);
784 }
785 case 'f':
786 {
787 if (LocaleCompare("filter",option+1) == 0)
788 {
cristybb503372010-05-27 20:51:26 +0000789 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000790 filter;
791
792 if (*option == '+')
793 break;
794 i++;
cristye81f5522014-05-07 01:25:59 +0000795 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000796 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000797 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000798 if (filter < 0)
799 ThrowImportException(OptionError,"UnrecognizedImageFilter",
800 argv[i]);
801 break;
802 }
803 if (LocaleCompare("frame",option+1) == 0)
804 {
cristy151b66d2015-04-15 10:50:31 +0000805 (void) CopyMagickString(argv[i]+1,"sans0",MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000806 ximage_info.frame=(*option == '-') ? MagickTrue : MagickFalse;
807 break;
808 }
809 if (LocaleCompare("format",option+1) == 0)
810 {
811 if (*option == '+')
812 break;
813 i++;
cristye81f5522014-05-07 01:25:59 +0000814 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000815 ThrowImportException(OptionError,"MissingArgument",option);
816 break;
817 }
818 ThrowImportException(OptionError,"UnrecognizedOption",option);
819 }
820 case 'g':
821 {
822 if (LocaleCompare("geometry",option+1) == 0)
823 {
824 if (*option == '+')
825 break;
826 i++;
cristybb503372010-05-27 20:51:26 +0000827 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000828 ThrowImportException(OptionError,"MissingArgument",option);
829 if (IsGeometry(argv[i]) == MagickFalse)
830 ThrowImportInvalidArgumentException(option,argv[i]);
831 break;
832 }
833 if (LocaleCompare("gravity",option+1) == 0)
834 {
cristybb503372010-05-27 20:51:26 +0000835 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000836 gravity;
837
838 if (*option == '+')
839 break;
840 i++;
cristybb503372010-05-27 20:51:26 +0000841 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000842 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000843 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000844 if (gravity < 0)
845 ThrowImportException(OptionError,"UnrecognizedGravityType",
846 argv[i]);
847 break;
848 }
849 ThrowImportException(OptionError,"UnrecognizedOption",option);
850 }
851 case 'h':
852 {
853 if (LocaleCompare("help",option+1) == 0)
854 break;
855 ThrowImportException(OptionError,"UnrecognizedOption",option);
856 }
857 case 'i':
858 {
859 if (LocaleCompare("identify",option+1) == 0)
860 break;
861 if (LocaleCompare("interlace",option+1) == 0)
862 {
cristybb503372010-05-27 20:51:26 +0000863 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000864 interlace;
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 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000871 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000872 argv[i]);
873 if (interlace < 0)
874 ThrowImportException(OptionError,"UnrecognizedInterlaceType",
875 argv[i]);
876 break;
877 }
878 if (LocaleCompare("interpolate",option+1) == 0)
879 {
cristybb503372010-05-27 20:51:26 +0000880 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000881 interpolate;
882
883 if (*option == '+')
884 break;
885 i++;
cristybb503372010-05-27 20:51:26 +0000886 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000887 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000888 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000889 argv[i]);
890 if (interpolate < 0)
891 ThrowImportException(OptionError,"UnrecognizedInterpolateMethod",
892 argv[i]);
893 break;
894 }
895 ThrowImportException(OptionError,"UnrecognizedOption",option);
896 }
897 case 'l':
898 {
899 if (LocaleCompare("label",option+1) == 0)
900 {
901 if (*option == '+')
902 break;
903 i++;
cristybb503372010-05-27 20:51:26 +0000904 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000905 ThrowImportException(OptionError,"MissingArgument",option);
906 status=SetImageOption(image_info,"label",argv[i]);
907 if (status == MagickFalse)
908 ThrowImportException(OptionError,"UnrecognizedOption",argv[i]);
909 break;
910 }
911 if (LocaleCompare("limit",option+1) == 0)
912 {
913 char
914 *p;
915
916 double
917 value;
918
cristybb503372010-05-27 20:51:26 +0000919 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000920 resource;
921
922 if (*option == '+')
923 break;
924 i++;
cristybb503372010-05-27 20:51:26 +0000925 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000926 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000927 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
cristy3ed852e2009-09-05 21:47:34 +0000928 argv[i]);
929 if (resource < 0)
930 ThrowImportException(OptionError,"UnrecognizedResourceType",
931 argv[i]);
932 i++;
cristybb503372010-05-27 20:51:26 +0000933 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000934 ThrowImportException(OptionError,"MissingArgument",option);
cristydbdd0e32011-11-04 23:29:40 +0000935 value=StringToDouble(argv[i],&p);
cristyda16f162011-02-19 23:52:17 +0000936 (void) value;
cristy3ed852e2009-09-05 21:47:34 +0000937 if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0))
938 ThrowImportInvalidArgumentException(option,argv[i]);
939 break;
940 }
941 if (LocaleCompare("list",option+1) == 0)
942 {
cristybb503372010-05-27 20:51:26 +0000943 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000944 list;
945
946 if (*option == '+')
947 break;
948 i++;
cristybb503372010-05-27 20:51:26 +0000949 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000950 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +0000951 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +0000952 if (list < 0)
953 ThrowImportException(OptionError,"UnrecognizedListType",argv[i]);
cristyaeb2cbc2010-05-07 13:28:58 +0000954 status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **)
cristy3ed852e2009-09-05 21:47:34 +0000955 argv+j,exception);
956 DestroyImport();
cristy32ce2392014-09-24 19:08:53 +0000957 return(status == 0 ? MagickTrue : MagickFalse);
cristy3ed852e2009-09-05 21:47:34 +0000958 }
959 if (LocaleCompare("log",option+1) == 0)
960 {
961 if (*option == '+')
962 break;
963 i++;
cristybb503372010-05-27 20:51:26 +0000964 if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL))
cristy3ed852e2009-09-05 21:47:34 +0000965 ThrowImportException(OptionError,"MissingArgument",option);
966 break;
967 }
968 ThrowImportException(OptionError,"UnrecognizedOption",option);
969 }
970 case 'm':
971 {
972 if (LocaleCompare("monitor",option+1) == 0)
973 break;
974 if (LocaleCompare("monochrome",option+1) == 0)
975 {
976 if (*option == '+')
977 break;
978 quantize_info->number_colors=2;
979 quantize_info->colorspace=GRAYColorspace;
980 break;
981 }
982 ThrowImportException(OptionError,"UnrecognizedOption",option);
983 }
984 case 'n':
985 {
986 if (LocaleCompare("negate",option+1) == 0)
987 break;
988 ThrowImportException(OptionError,"UnrecognizedOption",option);
989 }
990 case 'p':
991 {
992 if (LocaleCompare("page",option+1) == 0)
993 {
994 if (*option == '+')
995 break;
996 i++;
cristybb503372010-05-27 20:51:26 +0000997 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +0000998 ThrowImportException(OptionError,"MissingArgument",option);
999 status=SetImageOption(image_info,"page",argv[i]);
1000 if (status == MagickFalse)
1001 ThrowImportException(OptionError,"UnrecognizedOption",argv[i]);
1002 break;
1003 }
1004 if (LocaleCompare("pause",option+1) == 0)
1005 {
1006 resource_info.pause=0;
1007 if (*option == '+')
1008 break;
1009 i++;
cristybb503372010-05-27 20:51:26 +00001010 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001011 ThrowImportException(OptionError,"MissingArgument",option);
1012 if (IsGeometry(argv[i]) == MagickFalse)
1013 ThrowImportInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +00001014 resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001015 break;
1016 }
1017 if (LocaleCompare("ping",option+1) == 0)
1018 break; /* deprecated option */
1019 if (LocaleCompare("pointsize",option+1) == 0)
1020 {
1021 if (*option == '+')
1022 break;
1023 i++;
cristybb503372010-05-27 20:51:26 +00001024 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001025 ThrowImportException(OptionError,"MissingArgument",option);
1026 if (IsGeometry(argv[i]) == MagickFalse)
1027 ThrowImportInvalidArgumentException(option,argv[i]);
1028 break;
1029 }
1030 ThrowImportException(OptionError,"UnrecognizedOption",option);
1031 }
1032 case 'q':
1033 {
1034 if (LocaleCompare("quality",option+1) == 0)
1035 {
1036 if (*option == '+')
1037 break;
1038 i++;
cristybb503372010-05-27 20:51:26 +00001039 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001040 ThrowImportException(OptionError,"MissingArgument",option);
1041 if (IsGeometry(argv[i]) == MagickFalse)
1042 ThrowImportInvalidArgumentException(option,argv[i]);
1043 break;
1044 }
1045 if (LocaleCompare("quantize",option+1) == 0)
1046 {
cristybb503372010-05-27 20:51:26 +00001047 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001048 colorspace;
1049
1050 if (*option == '+')
1051 break;
1052 i++;
cristye81f5522014-05-07 01:25:59 +00001053 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001054 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001055 colorspace=ParseCommandOption(MagickColorspaceOptions,
cristy3ed852e2009-09-05 21:47:34 +00001056 MagickFalse,argv[i]);
1057 if (colorspace < 0)
1058 ThrowImportException(OptionError,"UnrecognizedColorspace",
1059 argv[i]);
1060 break;
1061 }
1062 if (LocaleCompare("quiet",option+1) == 0)
1063 break;
1064 ThrowImportException(OptionError,"UnrecognizedOption",option);
1065 }
1066 case 'r':
1067 {
1068 if (LocaleCompare("regard-warnings",option+1) == 0)
1069 break;
1070 if (LocaleCompare("repage",option+1) == 0)
1071 {
1072 if (*option == '+')
1073 break;
1074 i++;
cristye81f5522014-05-07 01:25:59 +00001075 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001076 ThrowImportException(OptionError,"MissingArgument",option);
1077 if (IsGeometry(argv[i]) == MagickFalse)
1078 ThrowImportInvalidArgumentException(option,argv[i]);
1079 break;
1080 }
1081 if (LocaleCompare("resize",option+1) == 0)
1082 {
1083 if (*option == '+')
1084 break;
1085 i++;
cristybb503372010-05-27 20:51:26 +00001086 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001087 ThrowImportException(OptionError,"MissingArgument",option);
1088 if (IsGeometry(argv[i]) == MagickFalse)
1089 ThrowImportInvalidArgumentException(option,argv[i]);
1090 break;
1091 }
1092 if (LocaleNCompare("respect-parentheses",option+1,17) == 0)
1093 {
1094 respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse;
1095 break;
1096 }
1097 if (LocaleCompare("rotate",option+1) == 0)
1098 {
1099 i++;
cristybb503372010-05-27 20:51:26 +00001100 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001101 ThrowImportException(OptionError,"MissingArgument",option);
1102 if (IsGeometry(argv[i]) == MagickFalse)
1103 ThrowImportInvalidArgumentException(option,argv[i]);
1104 break;
1105 }
1106 ThrowImportException(OptionError,"UnrecognizedOption",option);
1107 }
1108 case 's':
1109 {
1110 if (LocaleCompare("sampling-factor",option+1) == 0)
1111 {
1112 if (*option == '+')
1113 break;
1114 i++;
cristybb503372010-05-27 20:51:26 +00001115 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001116 ThrowImportException(OptionError,"MissingArgument",option);
1117 if (IsGeometry(argv[i]) == MagickFalse)
1118 ThrowImportInvalidArgumentException(option,argv[i]);
1119 break;
1120 }
1121 if (LocaleCompare("scene",option+1) == 0)
1122 {
1123 if (*option == '+')
1124 break;
1125 i++;
cristybb503372010-05-27 20:51:26 +00001126 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001127 ThrowImportException(OptionError,"MissingArgument",option);
1128 if (IsGeometry(argv[i]) == MagickFalse)
1129 ThrowImportInvalidArgumentException(option,argv[i]);
1130 break;
1131 }
1132 if (LocaleCompare("set",option+1) == 0)
1133 {
1134 i++;
cristybb503372010-05-27 20:51:26 +00001135 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001136 ThrowImportException(OptionError,"MissingArgument",option);
1137 if (*option == '+')
1138 break;
1139 i++;
cristybb503372010-05-27 20:51:26 +00001140 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001141 ThrowImportException(OptionError,"MissingArgument",option);
1142 break;
1143 }
1144 if (LocaleCompare("screen",option+1) == 0)
1145 {
1146 ximage_info.screen=(*option == '-') ? MagickTrue : MagickFalse;
1147 break;
1148 }
1149 if (LocaleCompare("seed",option+1) == 0)
1150 {
1151 if (*option == '+')
1152 break;
1153 i++;
cristye81f5522014-05-07 01:25:59 +00001154 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001155 ThrowImportException(OptionError,"MissingArgument",option);
1156 if (IsGeometry(argv[i]) == MagickFalse)
1157 ThrowImportInvalidArgumentException(option,argv[i]);
1158 break;
1159 }
1160 if (LocaleCompare("silent",option+1) == 0)
1161 {
1162 ximage_info.silent=(*option == '-') ? MagickTrue : MagickFalse;
1163 break;
1164 }
1165 if (LocaleCompare("snaps",option+1) == 0)
1166 {
cristy151b66d2015-04-15 10:50:31 +00001167 (void) CopyMagickString(argv[i]+1,"sans",MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +00001168 i++;
cristybb503372010-05-27 20:51:26 +00001169 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001170 ThrowImportException(OptionError,"MissingArgument",option);
1171 if (IsGeometry(argv[i]) == MagickFalse)
1172 ThrowImportInvalidArgumentException(option,argv[i]);
cristy32c2aea2010-12-01 01:00:50 +00001173 snapshots=(ssize_t) StringToLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001174 break;
1175 }
1176 if (LocaleCompare("strip",option+1) == 0)
1177 break;
1178 if (LocaleCompare("support",option+1) == 0)
1179 {
1180 i++; /* deprecated */
1181 break;
1182 }
cristyd9a29192010-10-16 16:49:53 +00001183 if (LocaleCompare("synchronize",option+1) == 0)
1184 break;
cristy3ed852e2009-09-05 21:47:34 +00001185 ThrowImportException(OptionError,"UnrecognizedOption",option);
1186 }
1187 case 't':
1188 {
cristyd9a29192010-10-16 16:49:53 +00001189 if (LocaleCompare("taint",option+1) == 0)
1190 break;
anthony4435c712011-05-02 01:46:33 +00001191 if (LocaleCompare("thumbnail",option+1) == 0)
cristy3ed852e2009-09-05 21:47:34 +00001192 {
1193 if (*option == '+')
1194 break;
1195 i++;
cristybb503372010-05-27 20:51:26 +00001196 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001197 ThrowImportException(OptionError,"MissingArgument",option);
1198 if (IsGeometry(argv[i]) == MagickFalse)
1199 ThrowImportInvalidArgumentException(option,argv[i]);
1200 break;
1201 }
1202 if (LocaleCompare("transparent",option+1) == 0)
1203 {
1204 i++;
cristybb503372010-05-27 20:51:26 +00001205 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001206 ThrowImportException(OptionError,"MissingArgument",option);
1207 break;
1208 }
1209 if (LocaleCompare("transparent-color",option+1) == 0)
1210 {
1211 if (*option == '+')
1212 break;
1213 i++;
cristye81f5522014-05-07 01:25:59 +00001214 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001215 ThrowImportException(OptionError,"MissingArgument",option);
1216 break;
1217 }
1218 if (LocaleCompare("treedepth",option+1) == 0)
1219 {
1220 quantize_info->tree_depth=0;
1221 if (*option == '+')
1222 break;
1223 i++;
cristybb503372010-05-27 20:51:26 +00001224 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001225 ThrowImportException(OptionError,"MissingArgument",option);
1226 if (IsGeometry(argv[i]) == MagickFalse)
1227 ThrowImportInvalidArgumentException(option,argv[i]);
cristye27293e2009-12-18 02:53:20 +00001228 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001229 break;
1230 }
1231 if (LocaleCompare("trim",option+1) == 0)
1232 break;
1233 if (LocaleCompare("type",option+1) == 0)
1234 {
cristybb503372010-05-27 20:51:26 +00001235 ssize_t
cristy3ed852e2009-09-05 21:47:34 +00001236 type;
1237
1238 if (*option == '+')
1239 break;
1240 i++;
cristybb503372010-05-27 20:51:26 +00001241 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001242 ThrowImportException(OptionError,"MissingArgument",option);
cristy042ee782011-04-22 18:48:30 +00001243 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
cristy3ed852e2009-09-05 21:47:34 +00001244 if (type < 0)
1245 ThrowImportException(OptionError,"UnrecognizedImageType",argv[i]);
1246 break;
1247 }
1248 ThrowImportException(OptionError,"UnrecognizedOption",option);
1249 }
1250 case 'w':
1251 {
1252 i++;
cristybb503372010-05-27 20:51:26 +00001253 if (i == (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001254 ThrowImportException(OptionError,"MissingArgument",option);
1255 (void) CloneString(&target_window,argv[i]);
1256 break;
1257 }
1258 case 'v':
1259 {
1260 if (LocaleCompare("verbose",option+1) == 0)
1261 break;
1262 if ((LocaleCompare("version",option+1) == 0) ||
1263 (LocaleCompare("-version",option+1) == 0))
1264 {
cristy4f7a6132012-12-23 00:35:19 +00001265 ListMagickVersion(stdout);
cristy3ed852e2009-09-05 21:47:34 +00001266 break;
1267 }
1268 ThrowImportException(OptionError,"UnrecognizedOption",option);
1269 }
1270 case '?':
1271 break;
1272 default:
1273 ThrowImportException(OptionError,"UnrecognizedOption",option);
1274 }
cristy042ee782011-04-22 18:48:30 +00001275 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1276 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
cristy3ed852e2009-09-05 21:47:34 +00001277 if (fire != MagickFalse)
1278 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1279 }
1280 if (k != 0)
1281 ThrowImportException(OptionError,"UnbalancedParenthesis",argv[i]);
cristycee97112010-05-28 00:44:52 +00001282 if (i-- != (ssize_t) argc)
cristy3ed852e2009-09-05 21:47:34 +00001283 ThrowImportException(OptionError,"MissingAnImageFilename",argv[i]);
1284 if (image == (Image *) NULL)
1285 ThrowImportException(OptionError,"MissingAnImageFilename",argv[argc-1]);
1286 FinalizeImageSettings(image_info,image,MagickTrue);
1287 status&=WriteImages(image_info,image,filename,exception);
1288 DestroyImport();
1289 return(status != 0 ? MagickTrue : MagickFalse);
1290#else
1291 (void) argc;
1292 (void) argv;
1293 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
anthonye5b39652012-04-21 05:37:29 +00001294 "DelegateLibrarySupportNotBuiltIn","'%s' (X11)",image_info->filename);
cristy3ed852e2009-09-05 21:47:34 +00001295 return(ImportUsage());
1296#endif
1297}