WandExport MagickBooleanType ImportImageCommand(ImageInfo *image_info, int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) { #if defined(MAGICKCORE_X11_DELEGATE) #define DestroyImport() \ { \ XDestroyResourceInfo(&resource_info); \ if (display != (Display *) NULL) \ { \ XCloseDisplay(display); \ display=(Display *) NULL; \ } \ DestroyImageStack(); \ if (target_window != (char *) NULL) \ target_window=DestroyString(target_window); \ for (i=0; i < (ssize_t) argc; i++) \ argv[i]=DestroyString(argv[i]); \ argv=(char **) RelinquishMagickMemory(argv); \ } #define ThrowImportException(asperity,tag,option) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ option); \ DestroyImport(); \ return(MagickFalse); \ } #define ThrowImportInvalidArgumentException(option,argument) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ "InvalidArgument","`%s': %s",option,argument); \ DestroyImport(); \ return(MagickFalse); \ } char *filename, *option, *resource_value, *server_name, *target_window; Display *display; Image *image; ImageStack image_stack[MaxImageStackDepth+1]; MagickBooleanType fire, pend, respect_parenthesis; MagickStatusType status; QuantizeInfo *quantize_info; register ssize_t i; ssize_t j, k, snapshots; XImportInfo ximage_info; XResourceInfo resource_info; XrmDatabase resource_database; /* Set defaults. */ assert(image_info != (ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(exception != (ExceptionInfo *) NULL); if (argc == 2) { option=argv[1]; if ((LocaleCompare("version",option+1) == 0) || (LocaleCompare("-version",option+1) == 0)) { (void) FormatLocaleFile(stdout,"Version: %s\n", GetMagickVersion((size_t *) NULL)); (void) FormatLocaleFile(stdout,"Copyright: %s\n", GetMagickCopyright()); (void) FormatLocaleFile(stdout,"Features: %s\n\n", GetMagickFeatures()); return(MagickFalse); } } display=(Display *) NULL; j=1; k=0; NewImageStack(); option=(char *) NULL; pend=MagickFalse; resource_database=(XrmDatabase) NULL; respect_parenthesis=MagickFalse; (void) ResetMagickMemory(&resource_info,0,sizeof(resource_info)); server_name=(char *) NULL; status=MagickTrue; SetNotifyHandlers; target_window=(char *) NULL; /* Check for server name specified on the command line. */ ReadCommandlLine(argc,&argv); status=ExpandFilenames(&argc,&argv); if (status == MagickFalse) ThrowImportException(ResourceLimitError,"MemoryAllocationFailed", GetExceptionMessage(errno)); for (i=1; i < (ssize_t) argc; i++) { /* Check command line for server name. */ option=argv[i]; if (LocaleCompare("display",option+1) == 0) { /* User specified server name. */ i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); server_name=argv[i]; } if ((LocaleCompare("help",option+1) == 0) || (LocaleCompare("-help",option+1) == 0)) return(ImportUsage()); } /* Get user defaults from X resource database. */ display=XOpenDisplay(server_name); if (display == (Display *) NULL) ThrowImportException(XServerError,"UnableToOpenXServer", XDisplayName(server_name)); (void) XSetErrorHandler(XError); resource_database=XGetResourceDatabase(display,GetClientName()); XGetImportInfo(&ximage_info); XGetResourceInfo(image_info,resource_database,GetClientName(), &resource_info); quantize_info=resource_info.quantize_info; resource_value=XGetResourceInstance(resource_database,GetClientName(), "border","False"); ximage_info.borders=IsMagickTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "delay","0"); resource_info.delay=(unsigned int) StringToUnsignedLong(resource_value); image_info->density=XGetResourceInstance(resource_database,GetClientName(), "density",(char *) NULL); resource_value=XGetResourceInstance(resource_database,GetClientName(), "descend","True"); ximage_info.descend=IsMagickTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "frame","False"); ximage_info.frame=IsMagickTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "interlace","none"); image_info->interlace=UndefinedInterlace; if (LocaleCompare("None",resource_value) == 0) image_info->interlace=NoInterlace; if (LocaleCompare("Line",resource_value) == 0) image_info->interlace=LineInterlace; if (LocaleCompare("Plane",resource_value) == 0) image_info->interlace=PlaneInterlace; if (LocaleCompare("Partition",resource_value) == 0) image_info->interlace=PartitionInterlace; if (image_info->interlace == UndefinedInterlace) ThrowImportException(OptionError,"Unrecognized interlace type", resource_value); image_info->page=XGetResourceInstance(resource_database,GetClientName(), "pageGeometry",(char *) NULL); resource_value=XGetResourceInstance(resource_database,GetClientName(), "pause","0"); resource_info.pause=(unsigned int) StringToUnsignedLong(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "quality","85"); image_info->quality=StringToUnsignedLong(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "screen","False"); ximage_info.screen=IsMagickTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "silent","False"); ximage_info.silent=IsMagickTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "verbose","False"); image_info->verbose=IsMagickTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "dither","True"); quantize_info->dither=IsMagickTrue(resource_value); snapshots=1; status=MagickTrue; filename=(char *) NULL; /* Check command syntax. */ for (i=1; i < (ssize_t) argc; i++) { option=argv[i]; if (LocaleCompare(option,"(") == 0) { FireImageStack(MagickFalse,MagickTrue,pend); if (k == MaxImageStackDepth) ThrowImportException(OptionError,"ParenthesisNestedTooDeeply", option); PushImageStack(); continue; } if (LocaleCompare(option,")") == 0) { FireImageStack(MagickFalse,MagickTrue,MagickTrue); if (k == 0) ThrowImportException(OptionError,"UnableToParseExpression",option); PopImageStack(); continue; } if (IsCommandOption(option) == MagickFalse) { Image *images; size_t scene; /* Read image from X server. */ FireImageStack(MagickFalse,MagickFalse,pend); filename=argv[i]; if (target_window != (char *) NULL) (void) CopyMagickString(image_info->filename,target_window, MaxTextExtent); for (scene=0; scene < (size_t) MagickMax(snapshots,1); scene++) { (void) sleep(resource_info.pause); images=XImportImage(image_info,&ximage_info); status&=(images != (Image *) NULL) && (exception->severity < ErrorException); if (images == (Image *) NULL) continue; (void) CopyMagickString(images->filename,filename,MaxTextExtent); (void) CopyMagickString(images->magick,"PS",MaxTextExtent); images->scene=scene; AppendImageStack(images); } continue; } pend=image != (Image *) NULL ? MagickTrue : MagickFalse; switch(*(option+1)) { case 'a': { if (LocaleCompare("adjoin",option+1) == 0) break; if (LocaleCompare("annotate",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); i++; break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'b': { if (LocaleCompare("border",option+1) == 0) { (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); ximage_info.borders=(*option == '-') ? MagickTrue : MagickFalse; break; } if (LocaleCompare("bordercolor",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'c': { if (LocaleCompare("cache",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("channel",option+1) == 0) { ssize_t channel; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); channel=ParseChannelOption(argv[i]); if (channel < 0) ThrowImportException(OptionError,"UnrecognizedChannelType", argv[i]); break; } if (LocaleCompare("colors",option+1) == 0) { quantize_info->number_colors=0; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); quantize_info->number_colors=StringToUnsignedLong(argv[i]); break; } if (LocaleCompare("colorspace",option+1) == 0) { ssize_t colorspace; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, argv[i]); if (colorspace < 0) ThrowImportException(OptionError,"UnrecognizedColorspace", argv[i]); break; } if (LocaleCompare("comment",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); status=SetImageOption(image_info,"comment",argv[i]); if (status == MagickFalse) ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); break; } if (LocaleCompare("compress",option+1) == 0) { ssize_t compress; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); compress=ParseCommandOption(MagickCompressOptions,MagickFalse, argv[i]); if (compress < 0) ThrowImportException(OptionError,"UnrecognizedImageCompression", argv[i]); break; } if (LocaleCompare("concurrent",option+1) == 0) break; if (LocaleCompare("crop",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'd': { if (LocaleCompare("debug",option+1) == 0) { ssize_t event; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); if (event < 0) ThrowImportException(OptionError,"UnrecognizedEventType",argv[i]); (void) SetLogEventMask(argv[i]); break; } if (LocaleCompare("define",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (*option == '+') { const char *define; define=GetImageOption(image_info,argv[i]); if (define == (char *) NULL) ThrowImportException(OptionError,"NoSuchOption",argv[i]); break; } break; } if (LocaleCompare("delay",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); status=SetImageOption(image_info,"delay",argv[i]); if (status == MagickFalse) ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); break; } if (LocaleCompare("density",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("depth",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("descend",option+1) == 0) { ximage_info.descend=(*option == '-') ? MagickTrue : MagickFalse; break; } if (LocaleCompare("display",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("dispose",option+1) == 0) { ssize_t dispose; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,argv[i]); if (dispose < 0) ThrowImportException(OptionError,"UnrecognizedDisposeMethod", argv[i]); break; } if (LocaleCompare("dither",option+1) == 0) { ssize_t method; quantize_info->dither=MagickFalse; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); method=ParseCommandOption(MagickDitherOptions,MagickFalse,argv[i]); if (method < 0) ThrowImportException(OptionError,"UnrecognizedDitherMethod", argv[i]); quantize_info->dither=MagickTrue; quantize_info->dither_method=(DitherMethod) method; break; } if (LocaleCompare("duration",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'e': { if (LocaleCompare("encipher",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("encoding",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("endian",option+1) == 0) { ssize_t endian; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); endian=ParseCommandOption(MagickEndianOptions,MagickFalse, argv[i]); if (endian < 0) ThrowImportException(OptionError,"UnrecognizedEndianType", argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'f': { if (LocaleCompare("filter",option+1) == 0) { ssize_t filter; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); filter=ParseCommandOption(MagickFilterOptions,MagickFalse,argv[i]); if (filter < 0) ThrowImportException(OptionError,"UnrecognizedImageFilter", argv[i]); break; } if (LocaleCompare("frame",option+1) == 0) { (void) CopyMagickString(argv[i]+1,"sans0",MaxTextExtent); ximage_info.frame=(*option == '-') ? MagickTrue : MagickFalse; break; } if (LocaleCompare("format",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'g': { if (LocaleCompare("geometry",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("gravity",option+1) == 0) { ssize_t gravity; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,argv[i]); if (gravity < 0) ThrowImportException(OptionError,"UnrecognizedGravityType", argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'h': { if (LocaleCompare("help",option+1) == 0) break; ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'i': { if (LocaleCompare("identify",option+1) == 0) break; if (LocaleCompare("interlace",option+1) == 0) { ssize_t interlace; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, argv[i]); if (interlace < 0) ThrowImportException(OptionError,"UnrecognizedInterlaceType", argv[i]); break; } if (LocaleCompare("interpolate",option+1) == 0) { ssize_t interpolate; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, argv[i]); if (interpolate < 0) ThrowImportException(OptionError,"UnrecognizedInterpolateMethod", argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'l': { if (LocaleCompare("label",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); status=SetImageOption(image_info,"label",argv[i]); if (status == MagickFalse) ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); break; } if (LocaleCompare("limit",option+1) == 0) { char *p; double value; ssize_t resource; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); resource=ParseCommandOption(MagickResourceOptions,MagickFalse, argv[i]); if (resource < 0) ThrowImportException(OptionError,"UnrecognizedResourceType", argv[i]); i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); value=InterpretLocaleValue(argv[i],&p); (void) value; if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("list",option+1) == 0) { ssize_t list; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); if (list < 0) ThrowImportException(OptionError,"UnrecognizedListType",argv[i]); status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) argv+j,exception); DestroyImport(); return(status != 0 ? MagickFalse : MagickTrue); } if (LocaleCompare("log",option+1) == 0) { if (*option == '+') break; i++; if ((i == (ssize_t) argc) || (strchr(argv[i],'%') == (char *) NULL)) ThrowImportException(OptionError,"MissingArgument",option); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'm': { if (LocaleCompare("monitor",option+1) == 0) break; if (LocaleCompare("monochrome",option+1) == 0) { if (*option == '+') break; quantize_info->number_colors=2; quantize_info->colorspace=GRAYColorspace; break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'n': { if (LocaleCompare("negate",option+1) == 0) break; ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'p': { if (LocaleCompare("page",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); status=SetImageOption(image_info,"page",argv[i]); if (status == MagickFalse) ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); break; } if (LocaleCompare("pause",option+1) == 0) { resource_info.pause=0; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); resource_info.pause=(unsigned int) StringToUnsignedLong(argv[i]); break; } if (LocaleCompare("ping",option+1) == 0) break; /* deprecated option */ if (LocaleCompare("pointsize",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'q': { if (LocaleCompare("quality",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("quantize",option+1) == 0) { ssize_t colorspace; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); colorspace=ParseCommandOption(MagickColorspaceOptions, MagickFalse,argv[i]); if (colorspace < 0) ThrowImportException(OptionError,"UnrecognizedColorspace", argv[i]); break; } if (LocaleCompare("quiet",option+1) == 0) break; ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'r': { if (LocaleCompare("regard-warnings",option+1) == 0) break; if (LocaleCompare("repage",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("resize",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleNCompare("respect-parentheses",option+1,17) == 0) { respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; break; } if (LocaleCompare("rotate",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 's': { if (LocaleCompare("sampling-factor",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("scene",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("set",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("screen",option+1) == 0) { ximage_info.screen=(*option == '-') ? MagickTrue : MagickFalse; break; } if (LocaleCompare("seed",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("silent",option+1) == 0) { ximage_info.silent=(*option == '-') ? MagickTrue : MagickFalse; break; } if (LocaleCompare("snaps",option+1) == 0) { (void) CopyMagickString(argv[i]+1,"sans",MaxTextExtent); i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); snapshots=(ssize_t) StringToLong(argv[i]); break; } if (LocaleCompare("strip",option+1) == 0) break; if (LocaleCompare("support",option+1) == 0) { i++; /* deprecated */ break; } if (LocaleCompare("synchronize",option+1) == 0) break; ThrowImportException(OptionError,"UnrecognizedOption",option); } case 't': { if (LocaleCompare("taint",option+1) == 0) break; if (LocaleCompare("thumbnail",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("transparent",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("transparent-color",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("treedepth",option+1) == 0) { quantize_info->tree_depth=0; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); quantize_info->tree_depth=StringToUnsignedLong(argv[i]); break; } if (LocaleCompare("trim",option+1) == 0) break; if (LocaleCompare("type",option+1) == 0) { ssize_t type; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); if (type < 0) ThrowImportException(OptionError,"UnrecognizedImageType",argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'w': { i++; if (i == (ssize_t) argc) ThrowImportException(OptionError,"MissingArgument",option); (void) CloneString(&target_window,argv[i]); break; } case 'v': { if (LocaleCompare("verbose",option+1) == 0) break; if ((LocaleCompare("version",option+1) == 0) || (LocaleCompare("-version",option+1) == 0)) { (void) FormatLocaleFile(stdout,"Version: %s\n", GetMagickVersion((size_t *) NULL)); (void) FormatLocaleFile(stdout,"Copyright: %s\n", GetMagickCopyright()); (void) FormatLocaleFile(stdout,"Features: %s\n\n", GetMagickFeatures()); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case '?': break; default: ThrowImportException(OptionError,"UnrecognizedOption",option); } fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & FireOptionFlag) == 0 ? MagickFalse : MagickTrue; if (fire != MagickFalse) FireImageStack(MagickFalse,MagickTrue,MagickTrue); } if (k != 0) ThrowImportException(OptionError,"UnbalancedParenthesis",argv[i]); if (i-- != (ssize_t) argc) ThrowImportException(OptionError,"MissingAnImageFilename",argv[i]); if (image == (Image *) NULL) ThrowImportException(OptionError,"MissingAnImageFilename",argv[argc-1]); FinalizeImageSettings(image_info,image,MagickTrue); status&=WriteImages(image_info,image,filename,exception); DestroyImport(); return(status != 0 ? MagickTrue : MagickFalse); #else (void) argc; (void) argv; (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError, "DelegateLibrarySupportNotBuiltIn","`%s' (X11)",image_info->filename); return(ImportUsage()); #endif }
MagickExport MagickBooleanType ImportImageCommand(ImageInfo *image_info, int argc,char **argv,char **magick_unused(metadata),ExceptionInfo *exception) { #if defined(HasX11) #define DestroyImport() \ { \ XDestroyResourceInfo(&resource_info); \ if (display != (Display *) NULL) \ { \ XCloseDisplay(display); \ display=(Display *) NULL; \ } \ for ( ; k >= 0; k--) \ image_stack[k]=DestroyImageList(image_stack[k]); \ for (i=0; i < (long) argc; i++) \ argv[i]=(char *) RelinquishMagickMemory(argv[i]); \ argv=(char **) RelinquishMagickMemory(argv); \ } #define ThrowImportException(asperity,tag,option) \ { \ if (exception->severity == UndefinedException) \ (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag, \ "`%s'",option); \ DestroyImport(); \ return(MagickFalse); \ } #define ThrowImportInvalidArgumentException(option,argument) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ "InvalidArgument","`%s': %s",argument,option); \ DestroyImport(); \ return(MagickFalse); \ } char *filename, *option, *resource_value, *server_name, *target_window; Display *display; Image *image_stack[MaxImageStackDepth+1]; long j, k, snapshots; MagickStatusType pend, status; QuantizeInfo *quantize_info; register long i; XImportInfo ximage_info; XResourceInfo resource_info; XrmDatabase resource_database; /* Set defaults. */ assert(image_info != (ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(exception != (ExceptionInfo *) NULL); display=(Display *) NULL; j=1; k=0; image_stack[k]=NewImageList(); option=(char *) NULL; pend=MagickFalse; resource_database=(XrmDatabase) NULL; (void) ResetMagickMemory(&resource_info,0,sizeof(resource_info)); server_name=(char *) NULL; status=MagickTrue; SetNotifyHandlers; /* Check for server name specified on the command line. */ ReadCommandlLine(argc,&argv); status=ExpandFilenames(&argc,&argv); if (status == MagickFalse) ThrowImportException(ResourceLimitError,"MemoryAllocationFailed", strerror(errno)); for (i=1; i < (long) argc; i++) { /* Check command line for server name. */ option=argv[i]; if (IsMagickOption(option) == MagickFalse) continue; if (LocaleCompare("display",option+1) == 0) { /* User specified server name. */ i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); server_name=argv[i]; break; } } /* Get user defaults from X resource database. */ display=XOpenDisplay(server_name); if (display == (Display *) NULL) ThrowImportException(XServerError,"UnableToOpenXServer", XDisplayName(server_name)); (void) XSetErrorHandler(XError); resource_database=XGetResourceDatabase(display,GetClientName()); XGetImportInfo(&ximage_info); XGetResourceInfo(resource_database,GetClientName(),&resource_info); image_info=resource_info.image_info; quantize_info=resource_info.quantize_info; resource_value=XGetResourceInstance(resource_database,GetClientName(), "border","False"); ximage_info.borders=IsTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "delay","0"); resource_info.delay=(unsigned int) atoi(resource_value); image_info->density=XGetResourceInstance(resource_database,GetClientName(), "density",(char *) NULL); resource_value=XGetResourceInstance(resource_database,GetClientName(), "descend","True"); ximage_info.descend=IsTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "frame","False"); ximage_info.frame=IsTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "interlace","none"); image_info->interlace=UndefinedInterlace; if (LocaleCompare("None",resource_value) == 0) image_info->interlace=NoInterlace; if (LocaleCompare("Line",resource_value) == 0) image_info->interlace=LineInterlace; if (LocaleCompare("Plane",resource_value) == 0) image_info->interlace=PlaneInterlace; if (LocaleCompare("Partition",resource_value) == 0) image_info->interlace=PartitionInterlace; if (image_info->interlace == UndefinedInterlace) ThrowImportException(OptionError,"Unrecognized interlace type", resource_value); image_info->page=XGetResourceInstance(resource_database,GetClientName(), "pageGeometry",(char *) NULL); resource_value=XGetResourceInstance(resource_database,GetClientName(), "pause","0"); resource_info.pause=(unsigned int) atol(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "quality","85"); image_info->quality=(unsigned long) atol(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "screen","False"); ximage_info.screen=IsTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "silent","False"); ximage_info.silent=IsTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "verbose","False"); image_info->verbose=IsTrue(resource_value); resource_value=XGetResourceInstance(resource_database,GetClientName(), "dither","True"); quantize_info->dither=IsTrue(resource_value); snapshots=1; status=MagickTrue; filename=(char *) NULL; target_window=(char *) NULL; /* Check command syntax. */ for (i=1; i < (long) argc; i++) { option=argv[i]; if (LocaleCompare(option,"(") == 0) { if (k == MaxImageStackDepth) ThrowImportException(OptionError,"ParenthesisNestedTooDeeply", option); MogrifyImageStack(image_stack[k],MagickTrue,pend); k++; image_stack[k]=NewImageList(); continue; } if (LocaleCompare(option,")") == 0) { if (k == 0) ThrowImportException(OptionError,"UnableToParseExpression",option); if (image_stack[k] != (Image *) NULL) { MogrifyImageStack(image_stack[k],MagickTrue,MagickTrue); AppendImageToList(&image_stack[k-1],image_stack[k]); } k--; continue; } if (IsMagickOption(option) == MagickFalse) { Image *image; unsigned long scene; /* Read image from X server. */ MogrifyImageStack(image_stack[k],MagickFalse,pend); filename=argv[i]; if (target_window != (char *) NULL) (void) CopyMagickString(image_info->filename,target_window, MaxTextExtent); for (scene=0; scene < (unsigned long) Max(snapshots,1); scene++) { (void) sleep(resource_info.pause); image=XImportImage(image_info,&ximage_info); status&=(image != (Image *) NULL) && (exception->severity < ErrorException); if (image == (Image *) NULL) continue; (void) CopyMagickString(image->filename,filename,MaxTextExtent); (void) strcpy(image->magick,"PS"); image->scene=scene; AppendImageToList(&image_stack[k],image); MogrifyImageStack(image_stack[k],MagickFalse,MagickTrue); } continue; } pend=image_stack[k] != (Image *) NULL ? MagickTrue : MagickFalse; switch(*(option+1)) { case 'a': { if (LocaleCompare("adjoin",option+1) == 0) break; if (LocaleCompare("annotate",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); if (i == (long) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); i++; break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'b': { if (LocaleCompare("border",option+1) == 0) { ximage_info.borders=(MagickBooleanType) (*option == '-'); (void) strcpy(argv[i]+1,"{0}"); break; } if (LocaleCompare("bordercolor",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'c': { if (LocaleCompare("cache",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("channel",option+1) == 0) { long channel; if (*option == '+') break; i++; if (i == (long) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); channel=ParseChannelOption(argv[i]); if (channel < 0) ThrowImportException(OptionError,"UnrecognizedChannelType", argv[i]); break; } if (LocaleCompare("colors",option+1) == 0) { quantize_info->number_colors=0; if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); quantize_info->number_colors=(unsigned long) atol(argv[i]); break; } if (LocaleCompare("colorspace",option+1) == 0) { long colorspace; quantize_info->colorspace=UndefinedColorspace; if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse, argv[i]); if (colorspace < 0) ThrowImportException(OptionError,"UnrecognizedColorspace", argv[i]); quantize_info->colorspace=(ColorspaceType) colorspace; if (quantize_info->colorspace == GRAYColorspace) { quantize_info->colorspace=GRAYColorspace; quantize_info->number_colors=256; quantize_info->tree_depth=8; } break; } if (LocaleCompare("comment",option+1) == 0) { if (*option == '-') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); status=SetImageOption(image_info,"Comment",argv[i]); if (status == MagickFalse) ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); break; } if (LocaleCompare("compress",option+1) == 0) { long compression; if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); compression=ParseMagickOption(MagickCompressionOptions, MagickFalse,argv[i]); if (compression < 0) ThrowImportException(OptionError,"UnrecognizedImageCompression", argv[i]); break; } if (LocaleCompare("crop",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'd': { if (LocaleCompare("debug",option+1) == 0) { LogEventType event_mask; (void) SetLogEventMask("None"); if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); event_mask=SetLogEventMask(argv[i]); if (event_mask == UndefinedEvents) ThrowImportException(OptionError,"UnrecognizedEventType",option); break; } if (LocaleCompare("define",option+1) == 0) { i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (*option == '+') { const char *define; define=GetImageOption(image_info,argv[i]); if (define == (char *) NULL) ThrowImportException(OptionError,"NoSuchOption",argv[i]); break; } break; } if (LocaleCompare("delay",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); status=SetImageOption(image_info,"delay",argv[i]); if (status == MagickFalse) ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); break; } if (LocaleCompare("density",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("depth",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("descend",option+1) == 0) { ximage_info.descend=(MagickBooleanType) (*option == '-'); break; } if (LocaleCompare("display",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("dispose",option+1) == 0) { long dispose; if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,argv[i]); if (dispose < 0) ThrowImportException(OptionError,"UnrecognizedDisposeMethod", argv[i]); break; } if (LocaleCompare("dither",option+1) == 0) { quantize_info->dither=(MagickBooleanType) (*option == '-'); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'e': { if (LocaleCompare("encoding",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("endian",option+1) == 0) { long endian; if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); endian=ParseMagickOption(MagickEndianOptions,MagickFalse, argv[i]); if (endian < 0) ThrowImportException(OptionError,"UnrecognizedEndianType", argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'f': { if (LocaleCompare("frame",option+1) == 0) { ximage_info.frame=(MagickBooleanType) (*option == '-'); (void) strcpy(argv[i]+1,"{0}"); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'g': { if (LocaleCompare("geometry",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("gravity",option+1) == 0) { long gravity; if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,argv[i]); if (gravity < 0) ThrowImportException(OptionError,"UnrecognizedGravityType", argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'h': { if (LocaleCompare("help",option+1) == 0) ImportUsage(); ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'i': { if (LocaleCompare("interlace",option+1) == 0) { long interlace; if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); interlace=ParseMagickOption(MagickInterlaceOptions,MagickFalse, argv[i]); if (interlace < 0) ThrowImportException(OptionError,"UnrecognizedInterlaceType", argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'l': { if (LocaleCompare("label",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); status=SetImageOption(image_info,"label",argv[i]); if (status == MagickFalse) ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); break; } if (LocaleCompare("limit",option+1) == 0) { long resource; if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); resource=ParseMagickOption(MagickResourceOptions,MagickFalse, argv[i]); if (resource < 0) ThrowImportException(OptionError,"UnrecognizedResourceType", argv[i]); i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if ((LocaleCompare("unlimited",argv[i]) != 0) && (IsGeometry(argv[i]) == MagickFalse)) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("log",option+1) == 0) { if (*option == '+') break; i++; if ((i == (long) argc) || (strchr(argv[i],'%') == (char *) NULL)) ThrowImportException(OptionError,"MissingArgument",option); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'm': { if (LocaleCompare("monitor",option+1) == 0) break; if (LocaleCompare("monochrome",option+1) == 0) { if (*option == '+') break; quantize_info->number_colors=2; quantize_info->tree_depth=8; quantize_info->colorspace=GRAYColorspace; break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'n': { if (LocaleCompare("negate",option+1) == 0) break; ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'p': { if (LocaleCompare("page",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); status=SetImageOption(image_info,"page",argv[i]); if (status == MagickFalse) ThrowImportException(OptionError,"UnrecognizedOption",argv[i]); break; } if (LocaleCompare("pause",option+1) == 0) { resource_info.pause=0; if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); resource_info.pause=(unsigned int) atoi(argv[i]); break; } if (LocaleCompare("ping",option+1) == 0) ThrowImportException(OptionError,"DeprecatedOption",option); if (LocaleCompare("pointsize",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'q': { if (LocaleCompare("quality",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("quiet",option+1) == 0) break; ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'r': { if (LocaleCompare("repage",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) (argc-1)) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("resize",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("rotate",option+1) == 0) { i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 's': { if (LocaleCompare("sampling-factor",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("scene",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("set",option+1) == 0) { i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("screen",option+1) == 0) { ximage_info.screen=(MagickBooleanType) (*option == '-'); break; } if (LocaleCompare("silent",option+1) == 0) { ximage_info.silent=(MagickBooleanType) (*option == '-'); break; } if (LocaleCompare("snaps",option+1) == 0) { (void) strcpy(argv[i]+1,"{1}"); i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); snapshots=atol(argv[i]); break; } if (LocaleCompare("strip",option+1) == 0) break; if (LocaleCompare("support",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 't': { if (LocaleCompare("thumnail",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("transparent",option+1) == 0) { if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("treedepth",option+1) == 0) { quantize_info->tree_depth=0; if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowImportInvalidArgumentException(option,argv[i]); quantize_info->tree_depth=(unsigned long) atol(argv[i]); break; } if (LocaleCompare("trim",option+1) == 0) break; if (LocaleCompare("type",option+1) == 0) { long type; if (*option == '+') break; i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); type=ParseMagickOption(MagickImageOptions,MagickFalse,argv[i]); if (type < 0) ThrowImportException(OptionError,"UnrecognizedImageType",argv[i]); break; } ThrowImportException(OptionError,"UnrecognizedOption",option); } case 'w': { i++; if (i == (long) argc) ThrowImportException(OptionError,"MissingArgument",option); (void) CloneString(&target_window,argv[i]); break; } case 'v': { if (LocaleCompare("verbose",option+1) == 0) break; if (LocaleCompare("version",option+1) == 0) break; ThrowImportException(OptionError,"UnrecognizedOption",option); } case '?': break; default: ThrowImportException(OptionError,"UnrecognizedOption",option); } status=(MagickStatusType) ParseMagickOption(MagickMogrifyOptions,MagickFalse,option+1); if (status == MagickTrue) MogrifyImageStack(image_stack[k],MagickTrue,MagickTrue); } if (k != 0) ThrowImportException(OptionError,"UnbalancedParenthesis",argv[i]); if (i != argc) ThrowImportException(OptionError,"MissingAnImageFilename",argv[i]); if (image_stack[k] == (Image *) NULL) ThrowImportException(OptionError,"MissingAnImageFilename",argv[argc-1]); MogrifyImageStack(image_stack[k],MagickTrue,MagickTrue) GetImageException(image_stack[k],exception); status&=WriteImages(image_info,image_stack[k],filename,exception); DestroyImport(); return(status != 0 ? MagickTrue : MagickFalse); #else (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError, "XWindowLibraryIsNotAvailable","`%s'",image_info->filename); ImportUsage(); return(MagickFalse); #endif }