44#include "MagickWand/studio.h"
45#include "MagickWand/MagickWand.h"
46#include "MagickWand/mogrify-private.h"
47#include "MagickCore/string-private.h"
48#include "MagickCore/image-private.h"
49#include "MagickCore/xwindow-private.h"
94static MagickBooleanType ImportUsage(
void)
98 " -debug events display copious debugging information\n"
99 " -help print program options\n"
100 " -list type print a list of supported option arguments\n"
101 " -log format format of debugging information\n"
102 " -version print version information",
104 " -annotate geometry text\n"
105 " annotate the image with text\n"
106 " -colors value preferred number of colors in the image\n"
107 " -crop geometry preferred size and location of the cropped image\n"
108 " -encipher filename convert plain pixels to cipher pixels\n"
109 " -extent geometry set the image size\n"
110 " -geometry geometry preferred size or location of the image\n"
111 " -help print program options\n"
112 " -monochrome transform image to black and white\n"
113 " -negate replace every pixel with its complementary color \n"
114 " -quantize colorspace reduce colors in this colorspace\n"
115 " -resize geometry resize the image\n"
116 " -rotate degrees apply Paeth rotation to the image\n"
117 " -strip strip image of all profiles and comments\n"
118 " -thumbnail geometry create a thumbnail of the image\n"
119 " -transparent color make this color transparent within the image\n"
120 " -trim trim image edges\n"
121 " -type type image type",
123 " -adjoin join images into a single multi-image file\n"
124 " -border include window border in the output image\n"
125 " -channel type apply option to select image channels\n"
126 " -colorspace type alternate image colorspace\n"
127 " -comment string annotate image with comment\n"
128 " -compress type type of pixel compression when writing the image\n"
129 " -define format:option\n"
130 " define one or more image format options\n"
131 " -density geometry horizontal and vertical density of the image\n"
132 " -depth value image depth\n"
133 " -descend obtain image by descending window hierarchy\n"
134 " -display server X server to contact\n"
135 " -dispose method layer disposal method\n"
136 " -dither method apply error diffusion to image\n"
137 " -delay value display the next image after pausing\n"
138 " -encipher filename convert plain pixels to cipher pixels\n"
139 " -endian type endianness (MSB or LSB) of the image\n"
140 " -encoding type text encoding type\n"
141 " -filter type use this filter when resizing an image\n"
142 " -format \"string\" output formatted image characteristics\n"
143 " -frame include window manager frame\n"
144 " -gravity direction which direction to gravitate towards\n"
145 " -identify identify the format and characteristics of the image\n"
146 " -interlace type None, Line, Plane, or Partition\n"
147 " -interpolate method pixel color interpolation method\n"
148 " -label string assign a label to an image\n"
149 " -limit type value Area, Disk, Map, or Memory resource limit\n"
150 " -monitor monitor progress\n"
151 " -page geometry size and location of an image canvas\n"
152 " -pause seconds seconds delay between snapshots\n"
153 " -pointsize value font point size\n"
154 " -quality value JPEG/MIFF/PNG compression level\n"
155 " -quiet suppress all warning messages\n"
156 " -regard-warnings pay attention to warning messages\n"
157 " -repage geometry size and location of an image canvas\n"
158 " -respect-parentheses settings remain in effect until parenthesis boundary\n"
159 " -sampling-factor geometry\n"
160 " horizontal and vertical sampling factor\n"
161 " -scene value image scene number\n"
162 " -screen select image from root window\n"
163 " -seed value seed a new sequence of pseudo-random numbers\n"
164 " -set property value set an image property\n"
165 " -silent operate silently, i.e. don't ring any bells \n"
166 " -snaps value number of screen snapshots\n"
167 " -support factor resize support: > 1.0 is blurry, < 1.0 is sharp\n"
168 " -synchronize synchronize image to storage device\n"
169 " -taint declare the image as modified\n"
170 " -transparent-color color\n"
171 " transparent color\n"
172 " -treedepth value color tree depth\n"
173 " -verbose print detailed information about the image\n"
174 " -virtual-pixel method\n"
175 " Constant, Edge, Mirror, or Tile\n"
176 " -window id select window with this id or name\n"
177 " root selects whole screen";
179 ListMagickVersion(stdout);
180 (void) printf(
"Usage: %s [options ...] [ file ]\n",
182 (void) printf(
"\nImage Settings:\n");
183 (void) puts(settings);
184 (void) printf(
"\nImage Operators:\n");
185 (void) puts(operators);
186 (void) printf(
"\nMiscellaneous Options:\n");
187 (void) puts(miscellaneous);
189 "\nBy default, 'file' is written in the MIFF image format. To\n");
191 "specify a particular image format, precede the filename with an image\n");
193 "format name and a colon (i.e. ps:image) or specify the image type as\n");
195 "the filename suffix (i.e. image.ps). Specify 'file' as '-' for\n");
196 (void) printf(
"standard input or output.\n");
200#if defined(MAGICKCORE_X11_DELEGATE)
201WandExport MagickBooleanType ImportImageCommand(ImageInfo *image_info,
202 int argc,
char **argv,
char **wand_unused(metadata),ExceptionInfo *exception)
204#define DestroyImport() \
206 XDestroyResourceInfo(&resource_info); \
207 if (display != (Display *) NULL) \
209 XCloseDisplay(display); \
210 display=(Display *) NULL; \
212 DestroyImageStack(); \
213 if (target_window != (char *) NULL) \
214 target_window=DestroyString(target_window); \
215 for (i=0; i < (ssize_t) argc; i++) \
216 argv[i]=DestroyString(argv[i]); \
217 argv=(char **) RelinquishMagickMemory(argv); \
219#define ThrowImportException(asperity,tag,option) \
221 (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
224 return(MagickFalse); \
226#define ThrowImportInvalidArgumentException(option,argument) \
228 (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
229 "InvalidArgument","'%s': %s",option,argument); \
231 return(MagickFalse); \
248 image_stack[MaxImageStackDepth+1];
281 assert(image_info != (ImageInfo *) NULL);
282 assert(image_info->signature == MagickCoreSignature);
283 assert(exception != (ExceptionInfo *) NULL);
284 wand_unreferenced(metadata);
285 if (IsEventLogging() != MagickFalse)
286 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
290 if ((LocaleCompare(
"version",option+1) == 0) ||
291 (LocaleCompare(
"-version",option+1) == 0))
293 ListMagickVersion(stdout);
297 display=(Display *) NULL;
301 option=(
char *) NULL;
303 resource_database=(XrmDatabase) NULL;
304 respect_parentheses=MagickFalse;
305 (void) memset(&resource_info,0,
sizeof(resource_info));
306 server_name=(
char *) NULL;
309 target_window=(
char *) NULL;
313 ReadCommandlLine(argc,&argv);
314 status=ExpandFilenames(&argc,&argv);
315 if (status == MagickFalse)
316 ThrowImportException(ResourceLimitError,
"MemoryAllocationFailed",
317 GetExceptionMessage(errno));
318 for (i=1; i < (ssize_t) argc; i++)
324 if (IsCommandOption(option) == MagickFalse)
326 if (LocaleCompare(
"display",option+1) == 0)
332 if (i == (ssize_t) argc)
333 ThrowImportException(OptionError,
"MissingArgument",option);
336 if ((LocaleCompare(
"help",option+1) == 0) ||
337 (LocaleCompare(
"-help",option+1) == 0))
340 return(ImportUsage());
346 display=XOpenDisplay(server_name);
347 if (display == (Display *) NULL)
348 ThrowImportException(XServerError,
"UnableToOpenXServer",
349 XDisplayName(server_name));
350 (void) XSetErrorHandler(XError);
351 resource_database=XGetResourceDatabase(display,GetClientName());
352 XGetImportInfo(&ximage_info);
353 XGetResourceInfo(image_info,resource_database,GetClientName(),
355 quantize_info=resource_info.quantize_info;
356 resource_value=XGetResourceInstance(resource_database,GetClientName(),
358 ximage_info.borders=IsStringTrue(resource_value);
359 resource_value=XGetResourceInstance(resource_database,GetClientName(),
361 resource_info.delay=(
unsigned int) StringToUnsignedLong(resource_value);
362 image_info->density=XGetResourceInstance(resource_database,GetClientName(),
363 "density",(
char *) NULL);
364 resource_value=XGetResourceInstance(resource_database,GetClientName(),
366 ximage_info.descend=IsStringTrue(resource_value);
367 resource_value=XGetResourceInstance(resource_database,GetClientName(),
369 ximage_info.frame=IsStringTrue(resource_value);
370 resource_value=XGetResourceInstance(resource_database,GetClientName(),
372 image_info->interlace=UndefinedInterlace;
373 if (LocaleCompare(
"None",resource_value) == 0)
374 image_info->interlace=NoInterlace;
375 if (LocaleCompare(
"Line",resource_value) == 0)
376 image_info->interlace=LineInterlace;
377 if (LocaleCompare(
"Plane",resource_value) == 0)
378 image_info->interlace=PlaneInterlace;
379 if (LocaleCompare(
"Partition",resource_value) == 0)
380 image_info->interlace=PartitionInterlace;
381 if (image_info->interlace == UndefinedInterlace)
382 ThrowImportException(OptionError,
"Unrecognized interlace type",
384 image_info->page=XGetResourceInstance(resource_database,GetClientName(),
385 "pageGeometry",(
char *) NULL);
386 resource_value=XGetResourceInstance(resource_database,GetClientName(),
388 resource_info.pause=(
unsigned int) StringToUnsignedLong(resource_value);
389 resource_value=XGetResourceInstance(resource_database,GetClientName(),
391 image_info->quality=StringToUnsignedLong(resource_value);
392 resource_value=XGetResourceInstance(resource_database,GetClientName(),
394 ximage_info.screen=IsStringTrue(resource_value);
395 resource_value=XGetResourceInstance(resource_database,GetClientName(),
397 ximage_info.silent=IsStringTrue(resource_value);
398 resource_value=XGetResourceInstance(resource_database,GetClientName(),
400 image_info->verbose=IsStringTrue(resource_value);
401 resource_value=XGetResourceInstance(resource_database,GetClientName(),
403 quantize_info->dither_method=IsStringTrue(resource_value) != MagickFalse ?
404 RiemersmaDitherMethod : NoDitherMethod;
407 filename=(
char *) NULL;
411 for (i=1; i < (ssize_t) argc; i++)
414 if (LocaleCompare(option,
"(") == 0)
416 FireImageStack(MagickFalse,MagickTrue,pend);
417 if (k == MaxImageStackDepth)
418 ThrowImportException(OptionError,
"ParenthesisNestedTooDeeply",
423 if (LocaleCompare(option,
")") == 0)
425 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
427 ThrowImportException(OptionError,
"UnableToParseExpression",option);
431 if (IsCommandOption(option) == MagickFalse)
442 FireImageStack(MagickFalse,MagickFalse,pend);
444 if (target_window != (
char *) NULL)
445 (void) CopyMagickString(image_info->filename,target_window,
447 for (scene=0; scene < (size_t) MagickMax(snapshots,1); scene++)
449 MagickDelay(1000*resource_info.pause);
450 images=XImportImage(image_info,&ximage_info,exception);
451 status&=(MagickStatusType) (images != (Image *) NULL) &&
452 (exception->severity < ErrorException);
453 if (images == (Image *) NULL)
455 (void) CopyMagickString(images->filename,filename,MagickPathExtent);
456 (void) CopyMagickString(images->magick,
"PS",MagickPathExtent);
458 AppendImageStack(images);
462 pend=image != (Image *) NULL ? MagickTrue : MagickFalse;
467 if (LocaleCompare(
"adjoin",option+1) == 0)
469 if (LocaleCompare(
"annotate",option+1) == 0)
474 if (i == (ssize_t) argc)
475 ThrowImportException(OptionError,
"MissingArgument",option);
476 if (IsGeometry(argv[i]) == MagickFalse)
477 ThrowImportInvalidArgumentException(option,argv[i]);
478 if (i == (ssize_t) argc)
479 ThrowImportException(OptionError,
"MissingArgument",option);
483 ThrowImportException(OptionError,
"UnrecognizedOption",option);
487 if (LocaleCompare(
"border",option+1) == 0)
489 (void) CopyMagickString(argv[i]+1,
"sans",MagickPathExtent);
490 ximage_info.borders=(*option ==
'-') ? MagickTrue : MagickFalse;
493 if (LocaleCompare(
"bordercolor",option+1) == 0)
498 if (i == (ssize_t) argc)
499 ThrowImportException(OptionError,
"MissingArgument",option);
502 ThrowImportException(OptionError,
"UnrecognizedOption",option);
506 if (LocaleCompare(
"cache",option+1) == 0)
511 if (i == (ssize_t) argc)
512 ThrowImportException(OptionError,
"MissingArgument",option);
513 if (IsGeometry(argv[i]) == MagickFalse)
514 ThrowImportInvalidArgumentException(option,argv[i]);
517 if (LocaleCompare(
"channel",option+1) == 0)
525 if (i == (ssize_t) argc)
526 ThrowImportException(OptionError,
"MissingArgument",option);
527 channel=ParseChannelOption(argv[i]);
529 ThrowImportException(OptionError,
"UnrecognizedChannelType",
533 if (LocaleCompare(
"colors",option+1) == 0)
535 quantize_info->number_colors=0;
539 if (i == (ssize_t) argc)
540 ThrowImportException(OptionError,
"MissingArgument",option);
541 if (IsGeometry(argv[i]) == MagickFalse)
542 ThrowImportInvalidArgumentException(option,argv[i]);
543 quantize_info->number_colors=StringToUnsignedLong(argv[i]);
546 if (LocaleCompare(
"colorspace",option+1) == 0)
554 if (i == (ssize_t) argc)
555 ThrowImportException(OptionError,
"MissingArgument",option);
556 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
559 ThrowImportException(OptionError,
"UnrecognizedColorspace",
563 if (LocaleCompare(
"comment",option+1) == 0)
568 if (i == (ssize_t) argc)
569 ThrowImportException(OptionError,
"MissingArgument",option);
570 status=SetImageOption(image_info,
"comment",argv[i]);
571 if (status == MagickFalse)
572 ThrowImportException(OptionError,
"UnrecognizedOption",argv[i]);
575 if (LocaleCompare(
"compress",option+1) == 0)
583 if (i == (ssize_t) argc)
584 ThrowImportException(OptionError,
"MissingArgument",option);
585 compress=ParseCommandOption(MagickCompressOptions,MagickFalse,
588 ThrowImportException(OptionError,
"UnrecognizedImageCompression",
592 if (LocaleCompare(
"concurrent",option+1) == 0)
594 if (LocaleCompare(
"crop",option+1) == 0)
599 if (i == (ssize_t) argc)
600 ThrowImportException(OptionError,
"MissingArgument",option);
601 if (IsGeometry(argv[i]) == MagickFalse)
602 ThrowImportInvalidArgumentException(option,argv[i]);
605 ThrowImportException(OptionError,
"UnrecognizedOption",option);
609 if (LocaleCompare(
"debug",option+1) == 0)
617 if (i == (ssize_t) argc)
618 ThrowImportException(OptionError,
"MissingArgument",option);
619 event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
621 ThrowImportException(OptionError,
"UnrecognizedEventType",argv[i]);
622 (void) SetLogEventMask(argv[i]);
625 if (LocaleCompare(
"define",option+1) == 0)
628 if (i == (ssize_t) argc)
629 ThrowImportException(OptionError,
"MissingArgument",option);
635 define=GetImageOption(image_info,argv[i]);
636 if (define == (
char *) NULL)
637 ThrowImportException(OptionError,
"NoSuchOption",argv[i]);
642 if (LocaleCompare(
"delay",option+1) == 0)
647 if (i == (ssize_t) argc)
648 ThrowImportException(OptionError,
"MissingArgument",option);
649 if (IsGeometry(argv[i]) == MagickFalse)
650 ThrowImportInvalidArgumentException(option,argv[i]);
651 status=SetImageOption(image_info,
"delay",argv[i]);
652 if (status == MagickFalse)
653 ThrowImportException(OptionError,
"UnrecognizedOption",argv[i]);
656 if (LocaleCompare(
"density",option+1) == 0)
661 if (i == (ssize_t) argc)
662 ThrowImportException(OptionError,
"MissingArgument",option);
663 if (IsGeometry(argv[i]) == MagickFalse)
664 ThrowImportInvalidArgumentException(option,argv[i]);
667 if (LocaleCompare(
"depth",option+1) == 0)
672 if (i == (ssize_t) argc)
673 ThrowImportException(OptionError,
"MissingArgument",option);
674 if (IsGeometry(argv[i]) == MagickFalse)
675 ThrowImportInvalidArgumentException(option,argv[i]);
678 if (LocaleCompare(
"descend",option+1) == 0)
680 ximage_info.descend=(*option ==
'-') ? MagickTrue : MagickFalse;
683 if (LocaleCompare(
"display",option+1) == 0)
688 if (i == (ssize_t) argc)
689 ThrowImportException(OptionError,
"MissingArgument",option);
692 if (LocaleCompare(
"dispose",option+1) == 0)
700 if (i == (ssize_t) argc)
701 ThrowImportException(OptionError,
"MissingArgument",option);
702 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]);
704 ThrowImportException(OptionError,
"UnrecognizedDisposeMethod",
708 if (LocaleCompare(
"dither",option+1) == 0)
713 quantize_info->dither_method=NoDitherMethod;
717 if (i == (ssize_t) argc)
718 ThrowImportException(OptionError,
"MissingArgument",option);
719 method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]);
721 ThrowImportException(OptionError,
"UnrecognizedDitherMethod",
723 quantize_info->dither_method=(DitherMethod) method;
726 if (LocaleCompare(
"duration",option+1) == 0)
731 if (i == (ssize_t) argc)
732 ThrowImportException(OptionError,
"MissingArgument",option);
733 if (IsGeometry(argv[i]) == MagickFalse)
734 ThrowImportInvalidArgumentException(option,argv[i]);
737 ThrowImportException(OptionError,
"UnrecognizedOption",option);
741 if (LocaleCompare(
"encipher",option+1) == 0)
746 if (i == (ssize_t) argc)
747 ThrowImportException(OptionError,
"MissingArgument",option);
750 if (LocaleCompare(
"encoding",option+1) == 0)
755 if (i == (ssize_t) argc)
756 ThrowImportException(OptionError,
"MissingArgument",option);
759 if (LocaleCompare(
"endian",option+1) == 0)
767 if (i == (ssize_t) argc)
768 ThrowImportException(OptionError,
"MissingArgument",option);
769 endian=ParseCommandOption(MagickEndianOptions,MagickFalse,
772 ThrowImportException(OptionError,
"UnrecognizedEndianType",
776 if (LocaleCompare(
"extent",option+1) == 0)
781 if (i == (ssize_t) argc)
782 ThrowImportException(OptionError,
"MissingArgument",option);
783 if (IsGeometry(argv[i]) == MagickFalse)
784 ThrowImportInvalidArgumentException(option,argv[i]);
787 ThrowImportException(OptionError,
"UnrecognizedOption",option);
791 if (LocaleCompare(
"filter",option+1) == 0)
799 if (i == (ssize_t) argc)
800 ThrowImportException(OptionError,
"MissingArgument",option);
801 filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]);
803 ThrowImportException(OptionError,
"UnrecognizedImageFilter",
807 if (LocaleCompare(
"frame",option+1) == 0)
809 (void) CopyMagickString(argv[i]+1,
"sans0",MagickPathExtent);
810 ximage_info.frame=(*option ==
'-') ? MagickTrue : MagickFalse;
813 if (LocaleCompare(
"format",option+1) == 0)
818 if (i == (ssize_t) argc)
819 ThrowImportException(OptionError,
"MissingArgument",option);
822 ThrowImportException(OptionError,
"UnrecognizedOption",option);
826 if (LocaleCompare(
"geometry",option+1) == 0)
831 if (i == (ssize_t) argc)
832 ThrowImportException(OptionError,
"MissingArgument",option);
833 if (IsGeometry(argv[i]) == MagickFalse)
834 ThrowImportInvalidArgumentException(option,argv[i]);
837 if (LocaleCompare(
"gravity",option+1) == 0)
845 if (i == (ssize_t) argc)
846 ThrowImportException(OptionError,
"MissingArgument",option);
847 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]);
849 ThrowImportException(OptionError,
"UnrecognizedGravityType",
853 ThrowImportException(OptionError,
"UnrecognizedOption",option);
857 if (LocaleCompare(
"help",option+1) == 0)
859 ThrowImportException(OptionError,
"UnrecognizedOption",option);
863 if (LocaleCompare(
"identify",option+1) == 0)
865 if (LocaleCompare(
"interlace",option+1) == 0)
873 if (i == (ssize_t) argc)
874 ThrowImportException(OptionError,
"MissingArgument",option);
875 interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse,
878 ThrowImportException(OptionError,
"UnrecognizedInterlaceType",
882 if (LocaleCompare(
"interpolate",option+1) == 0)
890 if (i == (ssize_t) argc)
891 ThrowImportException(OptionError,
"MissingArgument",option);
892 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
895 ThrowImportException(OptionError,
"UnrecognizedInterpolateMethod",
899 ThrowImportException(OptionError,
"UnrecognizedOption",option);
903 if (LocaleCompare(
"label",option+1) == 0)
908 if (i == (ssize_t) argc)
909 ThrowImportException(OptionError,
"MissingArgument",option);
910 status=SetImageOption(image_info,
"label",argv[i]);
911 if (status == MagickFalse)
912 ThrowImportException(OptionError,
"UnrecognizedOption",argv[i]);
915 if (LocaleCompare(
"limit",option+1) == 0)
929 if (i == (ssize_t) argc)
930 ThrowImportException(OptionError,
"MissingArgument",option);
931 resource=ParseCommandOption(MagickResourceOptions,MagickFalse,
934 ThrowImportException(OptionError,
"UnrecognizedResourceType",
937 if (i == (ssize_t) argc)
938 ThrowImportException(OptionError,
"MissingArgument",option);
939 value=StringToDouble(argv[i],&p);
941 if ((p == argv[i]) && (LocaleCompare(
"unlimited",argv[i]) != 0))
942 ThrowImportInvalidArgumentException(option,argv[i]);
945 if (LocaleCompare(
"list",option+1) == 0)
953 if (i == (ssize_t) argc)
954 ThrowImportException(OptionError,
"MissingArgument",option);
955 list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]);
957 ThrowImportException(OptionError,
"UnrecognizedListType",argv[i]);
958 status=MogrifyImageInfo(image_info,(
int) (i-j+1),(
const char **)
961 return(status == 0 ? MagickFalse : MagickTrue);
963 if (LocaleCompare(
"log",option+1) == 0)
968 if ((i == (ssize_t) argc) || (strchr(argv[i],
'%') == (
char *) NULL))
969 ThrowImportException(OptionError,
"MissingArgument",option);
972 ThrowImportException(OptionError,
"UnrecognizedOption",option);
976 if (LocaleCompare(
"monitor",option+1) == 0)
978 if (LocaleCompare(
"monochrome",option+1) == 0)
982 quantize_info->number_colors=2;
983 quantize_info->colorspace=GRAYColorspace;
986 ThrowImportException(OptionError,
"UnrecognizedOption",option);
990 if (LocaleCompare(
"negate",option+1) == 0)
992 ThrowImportException(OptionError,
"UnrecognizedOption",option);
996 if (LocaleCompare(
"page",option+1) == 0)
1001 if (i == (ssize_t) argc)
1002 ThrowImportException(OptionError,
"MissingArgument",option);
1003 status=SetImageOption(image_info,
"page",argv[i]);
1004 if (status == MagickFalse)
1005 ThrowImportException(OptionError,
"UnrecognizedOption",argv[i]);
1008 if (LocaleCompare(
"pause",option+1) == 0)
1010 resource_info.pause=0;
1014 if (i == (ssize_t) argc)
1015 ThrowImportException(OptionError,
"MissingArgument",option);
1016 if (IsGeometry(argv[i]) == MagickFalse)
1017 ThrowImportInvalidArgumentException(option,argv[i]);
1018 resource_info.pause=(
unsigned int) StringToUnsignedLong(argv[i]);
1021 if (LocaleCompare(
"ping",option+1) == 0)
1023 if (LocaleCompare(
"pointsize",option+1) == 0)
1028 if (i == (ssize_t) argc)
1029 ThrowImportException(OptionError,
"MissingArgument",option);
1030 if (IsGeometry(argv[i]) == MagickFalse)
1031 ThrowImportInvalidArgumentException(option,argv[i]);
1034 ThrowImportException(OptionError,
"UnrecognizedOption",option);
1038 if (LocaleCompare(
"quality",option+1) == 0)
1043 if (i == (ssize_t) argc)
1044 ThrowImportException(OptionError,
"MissingArgument",option);
1045 if (IsGeometry(argv[i]) == MagickFalse)
1046 ThrowImportInvalidArgumentException(option,argv[i]);
1049 if (LocaleCompare(
"quantize",option+1) == 0)
1057 if (i == (ssize_t) argc)
1058 ThrowImportException(OptionError,
"MissingArgument",option);
1059 colorspace=ParseCommandOption(MagickColorspaceOptions,
1060 MagickFalse,argv[i]);
1062 ThrowImportException(OptionError,
"UnrecognizedColorspace",
1066 if (LocaleCompare(
"quiet",option+1) == 0)
1068 ThrowImportException(OptionError,
"UnrecognizedOption",option);
1072 if (LocaleCompare(
"regard-warnings",option+1) == 0)
1074 if (LocaleCompare(
"repage",option+1) == 0)
1079 if (i == (ssize_t) argc)
1080 ThrowImportException(OptionError,
"MissingArgument",option);
1081 if (IsGeometry(argv[i]) == MagickFalse)
1082 ThrowImportInvalidArgumentException(option,argv[i]);
1085 if (LocaleCompare(
"resize",option+1) == 0)
1090 if (i == (ssize_t) argc)
1091 ThrowImportException(OptionError,
"MissingArgument",option);
1092 if (IsGeometry(argv[i]) == MagickFalse)
1093 ThrowImportInvalidArgumentException(option,argv[i]);
1096 if (LocaleNCompare(
"respect-parentheses",option+1,17) == 0)
1098 respect_parentheses=(*option ==
'-') ? MagickTrue : MagickFalse;
1101 if (LocaleCompare(
"rotate",option+1) == 0)
1104 if (i == (ssize_t) argc)
1105 ThrowImportException(OptionError,
"MissingArgument",option);
1106 if (IsGeometry(argv[i]) == MagickFalse)
1107 ThrowImportInvalidArgumentException(option,argv[i]);
1110 ThrowImportException(OptionError,
"UnrecognizedOption",option);
1114 if (LocaleCompare(
"sampling-factor",option+1) == 0)
1119 if (i == (ssize_t) argc)
1120 ThrowImportException(OptionError,
"MissingArgument",option);
1121 if (IsGeometry(argv[i]) == MagickFalse)
1122 ThrowImportInvalidArgumentException(option,argv[i]);
1125 if (LocaleCompare(
"scene",option+1) == 0)
1130 if (i == (ssize_t) argc)
1131 ThrowImportException(OptionError,
"MissingArgument",option);
1132 if (IsGeometry(argv[i]) == MagickFalse)
1133 ThrowImportInvalidArgumentException(option,argv[i]);
1136 if (LocaleCompare(
"set",option+1) == 0)
1139 if (i == (ssize_t) argc)
1140 ThrowImportException(OptionError,
"MissingArgument",option);
1144 if (i == (ssize_t) argc)
1145 ThrowImportException(OptionError,
"MissingArgument",option);
1148 if (LocaleCompare(
"screen",option+1) == 0)
1150 ximage_info.screen=(*option ==
'-') ? MagickTrue : MagickFalse;
1153 if (LocaleCompare(
"seed",option+1) == 0)
1158 if (i == (ssize_t) argc)
1159 ThrowImportException(OptionError,
"MissingArgument",option);
1160 if (IsGeometry(argv[i]) == MagickFalse)
1161 ThrowImportInvalidArgumentException(option,argv[i]);
1164 if (LocaleCompare(
"silent",option+1) == 0)
1166 ximage_info.silent=(*option ==
'-') ? MagickTrue : MagickFalse;
1169 if (LocaleCompare(
"snaps",option+1) == 0)
1171 (void) CopyMagickString(argv[i]+1,
"sans",MagickPathExtent);
1173 if (i == (ssize_t) argc)
1174 ThrowImportException(OptionError,
"MissingArgument",option);
1175 if (IsGeometry(argv[i]) == MagickFalse)
1176 ThrowImportInvalidArgumentException(option,argv[i]);
1177 snapshots=(ssize_t) StringToLong(argv[i]);
1180 if (LocaleCompare(
"strip",option+1) == 0)
1182 if (LocaleCompare(
"support",option+1) == 0)
1187 if (LocaleCompare(
"synchronize",option+1) == 0)
1189 ThrowImportException(OptionError,
"UnrecognizedOption",option);
1193 if (LocaleCompare(
"taint",option+1) == 0)
1195 if (LocaleCompare(
"thumbnail",option+1) == 0)
1200 if (i == (ssize_t) argc)
1201 ThrowImportException(OptionError,
"MissingArgument",option);
1202 if (IsGeometry(argv[i]) == MagickFalse)
1203 ThrowImportInvalidArgumentException(option,argv[i]);
1206 if (LocaleCompare(
"transparent",option+1) == 0)
1209 if (i == (ssize_t) argc)
1210 ThrowImportException(OptionError,
"MissingArgument",option);
1213 if (LocaleCompare(
"transparent-color",option+1) == 0)
1218 if (i == (ssize_t) argc)
1219 ThrowImportException(OptionError,
"MissingArgument",option);
1222 if (LocaleCompare(
"treedepth",option+1) == 0)
1224 quantize_info->tree_depth=0;
1228 if (i == (ssize_t) argc)
1229 ThrowImportException(OptionError,
"MissingArgument",option);
1230 if (IsGeometry(argv[i]) == MagickFalse)
1231 ThrowImportInvalidArgumentException(option,argv[i]);
1232 quantize_info->tree_depth=StringToUnsignedLong(argv[i]);
1235 if (LocaleCompare(
"trim",option+1) == 0)
1237 if (LocaleCompare(
"type",option+1) == 0)
1245 if (i == (ssize_t) argc)
1246 ThrowImportException(OptionError,
"MissingArgument",option);
1247 type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]);
1249 ThrowImportException(OptionError,
"UnrecognizedImageType",argv[i]);
1252 ThrowImportException(OptionError,
"UnrecognizedOption",option);
1257 if (i == (ssize_t) argc)
1258 ThrowImportException(OptionError,
"MissingArgument",option);
1259 (void) CloneString(&target_window,argv[i]);
1264 if (LocaleCompare(
"verbose",option+1) == 0)
1266 if ((LocaleCompare(
"version",option+1) == 0) ||
1267 (LocaleCompare(
"-version",option+1) == 0))
1269 ListMagickVersion(stdout);
1272 ThrowImportException(OptionError,
"UnrecognizedOption",option);
1277 ThrowImportException(OptionError,
"UnrecognizedOption",option);
1279 fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) &
1280 FireOptionFlag) == 0 ? MagickFalse : MagickTrue;
1281 if (fire != MagickFalse)
1282 FireImageStack(MagickFalse,MagickTrue,MagickTrue);
1285 ThrowImportException(OptionError,
"UnbalancedParenthesis",argv[i]);
1286 if (i-- != (ssize_t) argc)
1287 ThrowImportException(OptionError,
"MissingAnImageFilename",argv[i]);
1288 if (image == (Image *) NULL)
1289 ThrowImportException(OptionError,
"MissingAnImageFilename",argv[argc-1]);
1290 FinalizeImageSettings(image_info,image,MagickTrue);
1291 status&=(MagickStatusType) WriteImages(image_info,image,filename,exception);
1293 return(status != 0 ? MagickTrue : MagickFalse);
1295WandExport MagickBooleanType ImportImageCommand(ImageInfo *image_info,
1296 int wand_unused(argc),
char **wand_unused(argv),
char **wand_unused(metadata),
1297 ExceptionInfo *exception)
1299 wand_unreferenced(argc);
1300 wand_unreferenced(argv);
1301 wand_unreferenced(metadata);
1302 (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
1303 "DelegateLibrarySupportNotBuiltIn",
"'%s' (X11)",image_info->filename);
1304 return(ImportUsage());