/* Static: set_color_option Purpose: Set a color name as the value of the specified option Note: Call QueryColorDatabase to validate color name */ static VALUE set_color_option(VALUE self, const char *option, VALUE color) { Info *info; char *name; PixelPacket pp; ExceptionInfo exception; MagickBooleanType okay; Data_Get_Struct(self, Info, info); if (NIL_P(color)) { (void) RemoveImageOption(info, option); } else { GetExceptionInfo(&exception); name = StringValuePtr(color); okay = QueryColorDatabase(name, &pp, &exception); (void) DestroyExceptionInfo(&exception); if (!okay) { rb_raise(rb_eArgError, "invalid color name `%s'", name); } (void) RemoveImageOption(info, option); (void) SetImageOption(info, option, name); } return self; }
/* Method: Info#delay= Purpose: Set the delay attribute Notes: Convert from numeric value to string. */ VALUE Info_delay_eq(VALUE self, VALUE string) { Info *info; int delay; int not_num; char dstr[20]; Data_Get_Struct(self, Info, info); if (NIL_P(string)) { (void) RemoveImageOption(info, "delay"); } else { not_num = 0; (void) rb_protect(arg_is_integer, string, ¬_num); if (not_num) { rb_raise(rb_eTypeError, "failed to convert %s into Integer", rb_class2name(CLASS_OF(string))); } delay = NUM2INT(string); sprintf(dstr, "%d", delay); (void) RemoveImageOption(info, "delay"); (void) SetImageOption(info, "delay", dstr); } return self; }
/* Static: set_dbl_option(obj, option, value) Purpose: Set an Image::Info option to a floating-point value Notes: SetImageOption expects the value to be a string. */ static VALUE set_dbl_option(VALUE self, const char *option, VALUE value) { Info *info; char buff[50]; double d; long n; int len; Data_Get_Struct(self, Info, info); if (NIL_P(value)) { (void) RemoveImageOption(info, option); } else { d = NUM2DBL(value); n = floor(d); if (d == n) { len = sprintf(buff, "%-10ld", n); } else { len = sprintf(buff, "%-10.2f", d); } memset(buff+len, '\0', sizeof(buff)-len); (void) RemoveImageOption(info, option); (void) SetImageOption(info, option, buff); } return self; }
/* Method: Info#page=<aString> or <aGeometry> Purpose: store the Postscript page geometry */ VALUE Info_page_eq(VALUE self, VALUE page_arg) { Info *info; volatile VALUE geom_str; char *geometry; Data_Get_Struct(self, Info, info); if (NIL_P(page_arg)) { magick_free(info->page); info->page = NULL; return self; } geom_str = rm_to_s(page_arg); geometry=GetPageGeometry(StringValuePtr(geom_str)); if (*geometry == '\0') { magick_free(info->page); info->page = NULL; return self; } magick_clone_string(&info->page, geometry); (void) SetImageOption(info, "page", StringValuePtr(geom_str)); return self; }
/* Method: Info#gravity= Purpose: Convert a GravityType enum to a gravity option name and store in the Info structure */ VALUE Info_gravity_eq(VALUE self, VALUE grav) { Info *info; GravityType gravity; const char *option; int x; Data_Get_Struct(self, Info, info); if (NIL_P(grav)) { (void) RemoveImageOption(info, "gravity"); return self; } VALUE_TO_ENUM(grav, gravity, GravityType); option = "Undefined"; for (x = 0; x < N_GRAVITY_OPTIONS; x++) { if (gravity == Gravity_Option[x].enumerator) { option = Gravity_Option[x].string; break; } } (void) SetImageOption(info, "gravity", option); return self; }
/* Method: Info#origin=+-x+-y Purpose: Set origin geometry. Argument may be a Geometry object as well as a geometry string. */ VALUE Info_origin_eq(VALUE self, VALUE origin_arg) { Info *info; volatile VALUE origin_str; char *origin; Data_Get_Struct(self, Info, info); if (NIL_P(origin_arg)) { (void) RemoveImageOption(info, "origin"); return self; } origin_str = rm_to_s(origin_arg); origin = GetPageGeometry(StringValuePtr(origin_str)); if (IsGeometry(origin) == MagickFalse) { rb_raise(rb_eArgError, "invalid origin geometry: %s", origin); } (void) SetImageOption(info, "origin", origin); return self; }
/* Method: Info#dispose= Purpose: Convert a DisposeType enumerator into the equivalent dispose option string */ VALUE Info_dispose_eq(VALUE self, VALUE disp) { Info *info; DisposeType dispose; const char *option; int x; Data_Get_Struct(self, Info, info); if (NIL_P(disp)) { (void) RemoveImageOption(info, "dispose"); return self; } VALUE_TO_ENUM(disp, dispose, DisposeType); option = "Undefined"; for (x = 0; x < N_DISPOSE_OPTIONS; x++) { if (dispose == Dispose_Option[x].enumerator) { option = Dispose_Option[x].string; break; } } (void) SetImageOption(info, "dispose", option); return self; }
/* * Class: magick_ImageInfo * Method: setImageOption * Signature: (Ljava/lang/String;Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_magick_ImageInfo_setImageOption (JNIEnv *env, jobject self, jstring option, jstring value) { ImageInfo *info = NULL; const char *cstr1 = NULL; const char *cstr2 = NULL; info = (ImageInfo *) getHandle(env, self, "imageInfoHandle", NULL); if (info == NULL) { throwMagickException(env, "Unable to retrieve handle"); return; } cstr1 = (*env)->GetStringUTFChars(env, option, 0); if (cstr1 == NULL) { throwMagickException(env, "Unable to retrieve Java string chars"); return; } cstr2 = (*env)->GetStringUTFChars(env, value, 0); if (cstr2 == NULL) { throwMagickException(env, "Unable to retrieve Java string chars"); return; } SetImageOption(info, (char *)AcquireString(cstr1), (char *)AcquireString(cstr2)); (*env)->ReleaseStringUTFChars(env, option, cstr1); (*env)->ReleaseStringUTFChars(env, value, cstr2); }
void Magick::Options::setOption(const char *name,const double value_) { char option[MagickPathExtent]; (void) FormatLocaleString(option,MagickPathExtent,"%.20g",value_); (void) SetImageOption(_imageInfo,name,option); }
void Magick::Options::setOption(const char *name,const Color &value_) { std::string option; option=value_; (void) SetImageOption(imageInfo(),name,option.c_str()); }
void Magick::Options::fontFamily(const std::string &family_) { if (family_.length() == 0) { _drawInfo->family=(char *) RelinquishMagickMemory(_drawInfo->font); (void) RemoveImageOption(imageInfo(),"family"); } else { Magick::CloneString(&_drawInfo->family,family_); (void) SetImageOption(imageInfo(),"family",family_.c_str()); } }
VALUE Info_scene_eq(VALUE self, VALUE scene) { Info *info; char buf[25]; Data_Get_Struct(self, Info, info); info->scene = NUM2ULONG(scene); #if defined(HAVE_SNPRINTF) (void) snprintf(buf, sizeof(buf), "%-ld", info->scene); #else (void) sprintf(buf, "%-l", info->scene); #endif (void) SetImageOption(info, "scene", buf); return self; }
/* Method: Info#set_option Purpose: Set the specified option to this value. If the value is nil just unset any current value */ static VALUE set_option(VALUE self, const char *key, VALUE string) { Info *info; char *value; Data_Get_Struct(self, Info, info); if (NIL_P(string)) { (void) RemoveImageOption(info, key); } else { value = StringValuePtr(string); (void) SetImageOption(info, key, value); } return self; }
/* Method: Info#define(format, key[, value]) Purpose: Call SetImageOption Note: The only method in Info that is not an attribute accessor. */ VALUE Info_define(int argc, VALUE *argv, VALUE self) { Info *info; char *format, *key; const char *value = ""; long format_l, key_l; char ckey[100]; unsigned int okay; volatile VALUE fmt_arg; Data_Get_Struct(self, Info, info); switch (argc) { case 3: /* Allow any argument that supports to_s */ fmt_arg = rb_String(argv[2]); value = (const char *)StringValuePtr(fmt_arg); case 2: key = rm_str2cstr(argv[1], &key_l); format = rm_str2cstr(argv[0], &format_l); break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc); } if (2 + format_l + key_l > (long)sizeof(ckey)) { rb_raise(rb_eArgError, "%.20s:%.20s not defined - format or key too long", format, key); } (void) sprintf(ckey, "%s:%s", format, key); (void) RemoveImageOption(info, ckey); okay = SetImageOption(info, ckey, value); if (!okay) { rb_warn("%.20s=\"%.78s\" not defined - SetImageOption failed.", ckey, value); return Qnil; } return self; }
/* Method: Image::Info#tile_offset= geometry Purpose: info.tile_offset = [+/-]x[+/-]y */ VALUE Info_tile_offset_eq(VALUE self, VALUE offset) { Info *info; volatile VALUE offset_str; char *tile_offset; offset_str = rm_to_s(offset); tile_offset = StringValuePtr(offset_str); if (!IsGeometry(tile_offset)) { rb_raise(rb_eArgError, "invalid tile offset geometry: %s", tile_offset); } Data_Get_Struct(self, Info, info); (void) DeleteImageOption(info, "tile-offset"); (void) SetImageOption(info, "tile-offset", tile_offset); return self; }
int vips__magick_read( const char *filename, VipsImage *out ) { Read *read; #ifdef DEBUG printf( "magick2vips: vips__magick_read: %s\n", filename ); #endif /*DEBUG*/ if( !(read = read_new( filename, out )) ) return( -1 ); #ifdef HAVE_SETIMAGEOPTION /* When reading DICOM images, we want to ignore any * window_center/_width setting, since it may put pixels outside the * 0-65535 range and lose data. * * These window settings are attached as vips metadata, so our caller * can interpret them if it wants. */ SetImageOption( read->image_info, "dcm:display-range", "reset" ); #endif /*HAVE_SETIMAGEOPTION*/ read->image = ReadImage( read->image_info, &read->exception ); if( !read->image ) { vips_error( "magick2vips", _( "unable to read file \"%s\"\n" "libMagick error: %s %s" ), filename, read->exception.reason, read->exception.description ); return( -1 ); } if( parse_header( read ) ) return( -1 ); if( vips_image_generate( out, NULL, magick_fill_region, NULL, read, NULL ) ) return( -1 ); return( 0 ); }
void Magick::Options::textGravity(GravityType gravity_) { _drawInfo->gravity=gravity_; (void) SetImageOption(_imageInfo,"gravity",CommandOptionToMnemonic( MagickGravityOptions,(ssize_t) gravity_)); }
void Magick::Options::textEncoding(const std::string &encoding_) { CloneString(&_drawInfo->encoding,encoding_.c_str()); (void) SetImageOption(imageInfo(),"encoding",encoding_.c_str()); }
void Magick::Options::textDirection(DirectionType direction_) { _drawInfo->direction=direction_; (void) SetImageOption(_imageInfo,"direction",CommandOptionToMnemonic( MagickDirectionOptions,(ssize_t) direction_)); }
void Magick::Options::fontStyle(StyleType style_) { _drawInfo->style=style_; (void) SetImageOption(_imageInfo,"style",CommandOptionToMnemonic( MagickStyleOptions,(ssize_t) style_)); }
static Read * read_new( const char *filename, VipsImage *im, gboolean all_frames, const char *density, int page ) { Read *read; static int inited = 0; if( !inited ) { #ifdef HAVE_MAGICKCOREGENESIS MagickCoreGenesis( vips_get_argv0(), MagickFalse ); #else /*!HAVE_MAGICKCOREGENESIS*/ InitializeMagick( "" ); #endif /*HAVE_MAGICKCOREGENESIS*/ inited = 1; } if( !(read = VIPS_NEW( im, Read )) ) return( NULL ); read->filename = filename ? g_strdup( filename ) : NULL; read->all_frames = all_frames; read->page = page; read->im = im; read->image = NULL; read->image_info = CloneImageInfo( NULL ); GetExceptionInfo( &read->exception ); read->n_frames = 0; read->frames = NULL; read->frame_height = 0; read->lock = vips_g_mutex_new(); g_signal_connect( im, "close", G_CALLBACK( read_close ), read ); if( !read->image_info ) return( NULL ); if( filename ) vips_strncpy( read->image_info->filename, filename, MaxTextExtent ); /* Canvas resolution for rendering vector formats like SVG. */ VIPS_SETSTR( read->image_info->density, density ); #ifdef HAVE_SETIMAGEOPTION /* When reading DICOM images, we want to ignore any * window_center/_width setting, since it may put pixels outside the * 0-65535 range and lose data. * * These window settings are attached as vips metadata, so our caller * can interpret them if it wants. */ SetImageOption( read->image_info, "dcm:display-range", "reset" ); #endif /*HAVE_SETIMAGEOPTION*/ if( !all_frames ) { #ifdef HAVE_NUMBER_SCENES /* I can't find docs for these fields, but this seems to work. */ char page[256]; read->image_info->scene = read->page; read->image_info->number_scenes = 1; /* Some IMs must have the string version set as well. */ vips_snprintf( page, 256, "%d", read->page ); read->image_info->scenes = strdup( page ); #else /*!HAVE_NUMBER_SCENES*/ /* This works with GM 1.2.31 and probably others. */ read->image_info->subimage = read->page; read->image_info->subrange = 1; #endif } #ifdef DEBUG printf( "magick2vips: read_new: %s\n", read->filename ); #endif /*DEBUG*/ return( read ); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d I m a g e s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ReadImages() reads one or more images and returns them as an image list. % % The format of the ReadImage method is: % % Image *ReadImages(ImageInfo *image_info,const char *filename, % ExceptionInfo *exception) % % A description of each parameter follows: % % o image_info: the image info. % % o filename: the image filename. % % o exception: return any errors or warnings in this structure. % */ MagickExport Image *ReadImages(ImageInfo *image_info,const char *filename, ExceptionInfo *exception) { char read_filename[MagickPathExtent]; Image *image, *images; ImageInfo *read_info; /* Read image list from a file. */ assert(image_info != (ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); read_info=CloneImageInfo(image_info); *read_info->magick='\0'; (void) SetImageOption(read_info,"filename",filename); (void) CopyMagickString(read_info->filename,filename,MagickPathExtent); (void) InterpretImageFilename(read_info,(Image *) NULL,filename, (int) read_info->scene,read_filename,exception); if (LocaleCompare(read_filename,read_info->filename) != 0) { ExceptionInfo *sans; ssize_t extent, scene; /* Images of the form image-%d.png[1-5]. */ sans=AcquireExceptionInfo(); (void) SetImageInfo(read_info,0,sans); sans=DestroyExceptionInfo(sans); if (read_info->number_scenes == 0) { read_info=DestroyImageInfo(read_info); return(ReadImage(image_info,exception)); } (void) CopyMagickString(read_filename,read_info->filename,MagickPathExtent); images=NewImageList(); extent=(ssize_t) (read_info->scene+read_info->number_scenes); for (scene=(ssize_t) read_info->scene; scene < (ssize_t) extent; scene++) { (void) InterpretImageFilename(image_info,(Image *) NULL,read_filename, (int) scene,read_info->filename,exception); image=ReadImage(read_info,exception); if (image == (Image *) NULL) continue; AppendImageToList(&images,image); } read_info=DestroyImageInfo(read_info); return(images); } image=ReadImage(read_info,exception); read_info=DestroyImageInfo(read_info); return(image); }
WandExport MagickBooleanType ConjureImageCommand(ImageInfo *image_info, int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception) { #define DestroyConjure() \ { \ image=DestroyImageList(image); \ for (i=0; i < (ssize_t) argc; i++) \ argv[i]=DestroyString(argv[i]); \ argv=(char **) RelinquishMagickMemory(argv); \ } #define ThrowConjureException(asperity,tag,option) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"'%s'", \ option); \ DestroyConjure(); \ return(MagickFalse); \ } #define ThrowConjureInvalidArgumentException(option,argument) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ "InvalidArgument","'%s': %s",option,argument); \ DestroyConjure(); \ return(MagickFalse); \ } char filename[MaxTextExtent], *option; Image *image; MagickStatusType status; register ssize_t i; ssize_t number_images; /* 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) return(ConjureUsage()); image=NewImageList(); number_images=0; option=(char *) NULL; /* Conjure an image. */ ReadCommandlLine(argc,&argv); status=ExpandFilenames(&argc,&argv); if (status == MagickFalse) ThrowConjureException(ResourceLimitError,"MemoryAllocationFailed", GetExceptionMessage(errno)); for (i=1; i < (ssize_t) argc; i++) { option=argv[i]; if (IsCommandOption(option) != MagickFalse) { if (LocaleCompare("concurrent",option+1) == 0) break; if (LocaleCompare("debug",option+1) == 0) { ssize_t event; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowConjureException(OptionError,"MissingArgument",option); event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); if (event < 0) ThrowConjureException(OptionError,"UnrecognizedEventType", argv[i]); (void) SetLogEventMask(argv[i]); continue; } if (LocaleCompare("duration",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowConjureException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowConjureInvalidArgumentException(option,argv[i]); continue; } if ((LocaleCompare("help",option+1) == 0) || (LocaleCompare("-help",option+1) == 0)) { if (*option == '-') return(ConjureUsage()); continue; } if (LocaleCompare("log",option+1) == 0) { if (*option == '-') { i++; if (i == (ssize_t) argc) ThrowConjureException(OptionError,"MissingLogFormat",option); (void) SetLogFormat(argv[i]); } continue; } if (LocaleCompare("monitor",option+1) == 0) continue; if (LocaleCompare("quiet",option+1) == 0) continue; if (LocaleCompare("regard-warnings",option+1) == 0) break; if (LocaleCompare("seed",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowConjureException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowConjureInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("verbose",option+1) == 0) { image_info->verbose=(*option == '-') ? MagickTrue : MagickFalse; continue; } 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); } /* Persist key/value pair. */ (void) DeleteImageOption(image_info,option+1); status=SetImageOption(image_info,option+1,argv[i+1]); if (status == MagickFalse) ThrowConjureException(ImageError,"UnableToPersistKey",option); i++; continue; } /* Interpret MSL script. */ (void) DeleteImageOption(image_info,"filename"); status=SetImageOption(image_info,"filename",argv[i]); if (status == MagickFalse) ThrowConjureException(ImageError,"UnableToPersistKey",argv[i]); (void) FormatLocaleString(filename,MaxTextExtent,"msl:%s",argv[i]); image=ReadImages(image_info,filename,exception); CatchException(exception); if (image != (Image *) NULL) image=DestroyImageList(image); status=image != (Image *) NULL ? MagickTrue : MagickFalse; number_images++; } if (i != (ssize_t) argc) ThrowConjureException(OptionError,"MissingAnImageFilename",argv[i]); if (number_images == 0) ThrowConjureException(OptionError,"MissingAnImageFilename",argv[argc-1]); if (image != (Image *) NULL) image=DestroyImageList(image); for (i=0; i < (ssize_t) argc; i++) argv[i]=DestroyString(argv[i]); argv=(char **) RelinquishMagickMemory(argv); return(status != 0 ? MagickTrue : MagickFalse); }
WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info, int argc,char **argv,char **metadata,ExceptionInfo *exception) { #define DestroyIdentify() \ { \ DestroyImageStack(); \ for (i=0; i < (ssize_t) argc; i++) \ argv[i]=DestroyString(argv[i]); \ argv=(char **) RelinquishMagickMemory(argv); \ } #define ThrowIdentifyException(asperity,tag,option) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \ option); \ DestroyIdentify(); \ return(MagickFalse); \ } #define ThrowIdentifyInvalidArgumentException(option,argument) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ "InvalidArgument","`%s': %s",option,argument); \ DestroyIdentify(); \ return(MagickFalse); \ } const char *format, *option; Image *image; ImageStack image_stack[MaxImageStackDepth+1]; MagickBooleanType fire, pend, respect_parenthesis; MagickStatusType status; register ssize_t i; size_t count; ssize_t j, k; /* 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)) { ListMagickVersion(stdout); return(MagickFalse); } } if (argc < 2) return(IdentifyUsage()); count=0; format=NULL; j=1; k=0; NewImageStack(); option=(char *) NULL; pend=MagickFalse; respect_parenthesis=MagickFalse; status=MagickTrue; /* Identify an image. */ ReadCommandlLine(argc,&argv); status=ExpandFilenames(&argc,&argv); if (status == MagickFalse) ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed", GetExceptionMessage(errno)); image_info->ping=MagickTrue; for (i=1; i < (ssize_t) argc; i++) { option=argv[i]; if (LocaleCompare(option,"(") == 0) { FireImageStack(MagickFalse,MagickTrue,pend); if (k == MaxImageStackDepth) ThrowIdentifyException(OptionError,"ParenthesisNestedTooDeeply", option); PushImageStack(); continue; } if (LocaleCompare(option,")") == 0) { FireImageStack(MagickFalse,MagickTrue,MagickTrue); if (k == 0) ThrowIdentifyException(OptionError,"UnableToParseExpression",option); PopImageStack(); continue; } if (IsCommandOption(option) == MagickFalse) { char *filename; Image *images; ImageInfo *identify_info; /* Read input image. */ FireImageStack(MagickFalse,MagickFalse,pend); identify_info=CloneImageInfo(image_info); identify_info->verbose=MagickFalse; filename=argv[i]; if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) filename=argv[++i]; (void) SetImageOption(image_info,"filename",filename); (void) CopyMagickString(identify_info->filename,filename,MaxTextExtent); if (identify_info->ping != MagickFalse) images=PingImages(identify_info,exception); else images=ReadImages(identify_info,exception); identify_info=DestroyImageInfo(identify_info); status&=(images != (Image *) NULL) && (exception->severity < ErrorException); if (images == (Image *) NULL) continue; AppendImageStack(images); FinalizeImageSettings(image_info,image,MagickFalse); for ( ; image != (Image *) NULL; image=GetNextImageInList(image)) { if (image->scene == 0) image->scene=count++; if (format == (char *) NULL) { (void) IdentifyImage(image,stdout,image_info->verbose); continue; } if (metadata != (char **) NULL) { char *text; text=InterpretImageProperties(image_info,image,format); if (text == (char *) NULL) ThrowIdentifyException(ResourceLimitError, "MemoryAllocationFailed",GetExceptionMessage(errno)); (void) ConcatenateString(&(*metadata),text); text=DestroyString(text); if (LocaleCompare(format,"%n") == 0) break; } } RemoveAllImageStack(); continue; } pend=image != (Image *) NULL ? MagickTrue : MagickFalse; switch (*(option+1)) { case 'a': { if (LocaleCompare("alpha",option+1) == 0) { ssize_t type; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); if (type < 0) ThrowIdentifyException(OptionError,"UnrecognizedAlphaChannelType", argv[i]); break; } if (LocaleCompare("antialias",option+1) == 0) break; if (LocaleCompare("authenticate",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'c': { if (LocaleCompare("cache",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("channel",option+1) == 0) { ssize_t channel; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); channel=ParseChannelOption(argv[i]); if (channel < 0) ThrowIdentifyException(OptionError,"UnrecognizedChannelType", argv[i]); break; } if (LocaleCompare("colorspace",option+1) == 0) { ssize_t colorspace; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); colorspace=ParseCommandOption(MagickColorspaceOptions, MagickFalse,argv[i]); if (colorspace < 0) ThrowIdentifyException(OptionError,"UnrecognizedColorspace", argv[i]); break; } if (LocaleCompare("crop",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); image_info->ping=MagickFalse; break; } if (LocaleCompare("concurrent",option+1) == 0) break; ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'd': { if (LocaleCompare("debug",option+1) == 0) { ssize_t event; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]); if (event < 0) ThrowIdentifyException(OptionError,"UnrecognizedEventType", argv[i]); (void) SetLogEventMask(argv[i]); break; } if (LocaleCompare("define",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (*option == '+') { const char *define; define=GetImageOption(image_info,argv[i]); if (define == (const char *) NULL) ThrowIdentifyException(OptionError,"NoSuchOption",argv[i]); break; } break; } if (LocaleCompare("density",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("depth",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("duration",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'e': { if (LocaleCompare("endian",option+1) == 0) { ssize_t endian; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); endian=ParseCommandOption(MagickEndianOptions,MagickFalse, argv[i]); if (endian < 0) ThrowIdentifyException(OptionError,"UnrecognizedEndianType", argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'f': { if (LocaleCompare("features",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("format",option+1) == 0) { format=(char *) NULL; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); format=argv[i]; break; } if (LocaleCompare("fuzz",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'g': { if (LocaleCompare("gamma",option+1) == 0) { i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'h': { if ((LocaleCompare("help",option+1) == 0) || (LocaleCompare("-help",option+1) == 0)) return(IdentifyUsage()); ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'i': { if (LocaleCompare("interlace",option+1) == 0) { ssize_t interlace; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, argv[i]); if (interlace < 0) ThrowIdentifyException(OptionError, "UnrecognizedInterlaceType",argv[i]); break; } if (LocaleCompare("interpolate",option+1) == 0) { ssize_t interpolate; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse, argv[i]); if (interpolate < 0) ThrowIdentifyException(OptionError, "UnrecognizedInterpolateMethod",argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'l': { if (LocaleCompare("limit",option+1) == 0) { char *p; double value; ssize_t resource; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); resource=ParseCommandOption(MagickResourceOptions,MagickFalse, argv[i]); if (resource < 0) ThrowIdentifyException(OptionError,"UnrecognizedResourceType", argv[i]); i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); value=StringToDouble(argv[i],&p); (void) value; if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("list",option+1) == 0) { ssize_t list; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); if (list < 0) ThrowIdentifyException(OptionError,"UnrecognizedListType", argv[i]); status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) argv+j,exception); DestroyIdentify(); 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)) ThrowIdentifyException(OptionError,"MissingArgument",option); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'm': { if (LocaleCompare("matte",option+1) == 0) break; if (LocaleCompare("monitor",option+1) == 0) break; ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'n': { if (LocaleCompare("negate",option+1) == 0) break; ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'p': { if (LocaleCompare("ping",option+1) == 0) break; ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'q': { if (LocaleCompare("quiet",option+1) == 0) break; ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'r': { if (LocaleCompare("regard-warnings",option+1) == 0) break; if (LocaleNCompare("respect-parentheses",option+1,17) == 0) { respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 's': { if (LocaleCompare("sampling-factor",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("seed",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("set",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("size",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("strip",option+1) == 0) break; if (LocaleCompare("support",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowIdentifyInvalidArgumentException(option,argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'u': { if (LocaleCompare("unique",option+1) == 0) break; if (LocaleCompare("units",option+1) == 0) { ssize_t units; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); units=ParseCommandOption(MagickResolutionOptions,MagickFalse, argv[i]); if (units < 0) ThrowIdentifyException(OptionError,"UnrecognizedUnitsType", argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case 'v': { if (LocaleCompare("verbose",option+1) == 0) break; if (LocaleCompare("virtual-pixel",option+1) == 0) { ssize_t method; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowIdentifyException(OptionError,"MissingArgument",option); method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, argv[i]); if (method < 0) ThrowIdentifyException(OptionError, "UnrecognizedVirtualPixelMethod",argv[i]); break; } ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } case '?': break; default: ThrowIdentifyException(OptionError,"UnrecognizedOption",option) } fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & FireOptionFlag) == 0 ? MagickFalse : MagickTrue; if (fire != MagickFalse) FireImageStack(MagickFalse,MagickTrue,MagickTrue); } if (k != 0) ThrowIdentifyException(OptionError,"UnbalancedParenthesis",argv[i]); if (i != (ssize_t) argc) ThrowIdentifyException(OptionError,"MissingAnImageFilename",argv[i]); DestroyIdentify(); return(status != 0 ? MagickTrue : MagickFalse); }
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 }
WandExport MagickBooleanType CompareImageCommand(ImageInfo *image_info, int argc,char **argv,char **metadata,ExceptionInfo *exception) { #define CompareEpsilon (1.0e-06) #define DefaultDissimilarityThreshold 0.31830988618379067154 #define DefaultSimilarityThreshold (-1.0) #define DestroyCompare() \ { \ if (similarity_image != (Image *) NULL) \ similarity_image=DestroyImageList(similarity_image); \ if (difference_image != (Image *) NULL) \ difference_image=DestroyImageList(difference_image); \ DestroyImageStack(); \ for (i=0; i < (ssize_t) argc; i++) \ argv[i]=DestroyString(argv[i]); \ argv=(char **) RelinquishMagickMemory(argv); \ } #define ThrowCompareException(asperity,tag,option) \ { \ if (exception->severity < (asperity)) \ (void) ThrowMagickException(exception,GetMagickModule(),asperity,tag, \ "`%s'",option); \ DestroyCompare(); \ return(MagickFalse); \ } #define ThrowCompareInvalidArgumentException(option,argument) \ { \ (void) ThrowMagickException(exception,GetMagickModule(),OptionError, \ "InvalidArgument","`%s': %s",option,argument); \ DestroyCompare(); \ return(MagickFalse); \ } char *filename, *option; const char *format; ChannelType channels; double dissimilarity_threshold, distortion, similarity_metric, similarity_threshold; Image *difference_image, *image, *reconstruct_image, *similarity_image; ImageInfo *restore_info; ImageStack image_stack[MaxImageStackDepth+1]; MagickBooleanType fire, pend, respect_parenthesis, subimage_search; MagickStatusType status; MetricType metric; RectangleInfo offset; register ssize_t i; ssize_t j, k; /* 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)) { ListMagickVersion(stdout); return(MagickFalse); } } if (argc < 3) return(CompareUsage()); restore_info=image_info; channels=CompositeChannels; difference_image=NewImageList(); similarity_image=NewImageList(); dissimilarity_threshold=DefaultDissimilarityThreshold; similarity_threshold=DefaultSimilarityThreshold; distortion=0.0; format=(char *) NULL; j=1; k=0; metric=UndefinedErrorMetric; NewImageStack(); option=(char *) NULL; pend=MagickFalse; reconstruct_image=NewImageList(); respect_parenthesis=MagickFalse; status=MagickTrue; subimage_search=MagickFalse; /* Compare an image. */ ReadCommandlLine(argc,&argv); status=ExpandFilenames(&argc,&argv); if (status == MagickFalse) ThrowCompareException(ResourceLimitError,"MemoryAllocationFailed", GetExceptionMessage(errno)); for (i=1; i < (ssize_t) (argc-1); i++) { option=argv[i]; if (LocaleCompare(option,"(") == 0) { FireImageStack(MagickTrue,MagickTrue,pend); if (k == MaxImageStackDepth) ThrowCompareException(OptionError,"ParenthesisNestedTooDeeply", option); PushImageStack(); continue; } if (LocaleCompare(option,")") == 0) { FireImageStack(MagickTrue,MagickTrue,MagickTrue); if (k == 0) ThrowCompareException(OptionError,"UnableToParseExpression",option); PopImageStack(); continue; } if (IsCommandOption(option) == MagickFalse) { Image *images; /* Read input image. */ FireImageStack(MagickFalse,MagickFalse,pend); filename=argv[i]; if ((LocaleCompare(filename,"--") == 0) && (i < (ssize_t) (argc-1))) filename=argv[++i]; (void) SetImageOption(image_info,"filename",filename); (void) CopyMagickString(image_info->filename,filename,MaxTextExtent); images=ReadImages(image_info,exception); status&=(images != (Image *) NULL) && (exception->severity < ErrorException); if (images == (Image *) NULL) continue; AppendImageStack(images); continue; } pend=image != (Image *) NULL ? MagickTrue : MagickFalse; switch (*(option+1)) { case 'a': { if (LocaleCompare("alpha",option+1) == 0) { ssize_t type; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); type=ParseCommandOption(MagickAlphaOptions,MagickFalse,argv[i]); if (type < 0) ThrowCompareException(OptionError,"UnrecognizedAlphaChannelType", argv[i]); break; } if (LocaleCompare("authenticate",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option); } case 'c': { if (LocaleCompare("cache",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("channel",option+1) == 0) { ssize_t channel; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); channel=ParseChannelOption(argv[i]); if (channel < 0) ThrowCompareException(OptionError,"UnrecognizedChannelType", argv[i]); channels=(ChannelType) channel; break; } if (LocaleCompare("colorspace",option+1) == 0) { ssize_t colorspace; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse, argv[i]); if (colorspace < 0) ThrowCompareException(OptionError,"UnrecognizedColorspace", argv[i]); break; } if (LocaleCompare("compose",option+1) == 0) { ssize_t compose; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); compose=ParseCommandOption(MagickComposeOptions,MagickFalse, argv[i]); if (compose < 0) ThrowCompareException(OptionError,"UnrecognizedComposeOperator", argv[i]); break; } if (LocaleCompare("compress",option+1) == 0) { ssize_t compress; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); compress=ParseCommandOption(MagickCompressOptions,MagickFalse, argv[i]); if (compress < 0) ThrowCompareException(OptionError,"UnrecognizedImageCompression", argv[i]); break; } if (LocaleCompare("concurrent",option+1) == 0) break; ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'd': { if (LocaleCompare("debug",option+1) == 0) { LogEventType event_mask; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); event_mask=SetLogEventMask(argv[i]); if (event_mask == UndefinedEvents) ThrowCompareException(OptionError,"UnrecognizedEventType", argv[i]); break; } if (LocaleCompare("decipher",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("define",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (*option == '+') { const char *define; define=GetImageOption(image_info,argv[i]); if (define == (const char *) NULL) ThrowCompareException(OptionError,"NoSuchOption",argv[i]); break; } break; } if (LocaleCompare("density",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("depth",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("dissimilarity-threshold",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); if (*option == '+') dissimilarity_threshold=DefaultDissimilarityThreshold; else dissimilarity_threshold=StringToDouble(argv[i],(char **) NULL); break; } if (LocaleCompare("duration",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'e': { if (LocaleCompare("encipher",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("extract",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'f': { if (LocaleCompare("format",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); format=argv[i]; break; } if (LocaleCompare("fuzz",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'h': { if ((LocaleCompare("help",option+1) == 0) || (LocaleCompare("-help",option+1) == 0)) return(CompareUsage()); if (LocaleCompare("highlight-color",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); break; } ThrowCompareException(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) ThrowCompareException(OptionError,"MissingArgument",option); interlace=ParseCommandOption(MagickInterlaceOptions,MagickFalse, argv[i]); if (interlace < 0) ThrowCompareException(OptionError,"UnrecognizedInterlaceType", argv[i]); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'l': { if (LocaleCompare("limit",option+1) == 0) { char *p; double value; ssize_t resource; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); resource=ParseCommandOption(MagickResourceOptions,MagickFalse, argv[i]); if (resource < 0) ThrowCompareException(OptionError,"UnrecognizedResourceType", argv[i]); i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); value=StringToDouble(argv[i],&p); (void) value; if ((p == argv[i]) && (LocaleCompare("unlimited",argv[i]) != 0)) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("list",option+1) == 0) { ssize_t list; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); list=ParseCommandOption(MagickListOptions,MagickFalse,argv[i]); if (list < 0) ThrowCompareException(OptionError,"UnrecognizedListType",argv[i]); status=MogrifyImageInfo(image_info,(int) (i-j+1),(const char **) argv+j,exception); DestroyCompare(); 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)) ThrowCompareException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("lowlight-color",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'm': { if (LocaleCompare("matte",option+1) == 0) break; if (LocaleCompare("metric",option+1) == 0) { ssize_t type; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); type=ParseCommandOption(MagickMetricOptions,MagickTrue,argv[i]); if (type < 0) ThrowCompareException(OptionError,"UnrecognizedMetricType", argv[i]); metric=(MetricType) type; break; } if (LocaleCompare("monitor",option+1) == 0) break; ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'p': { if (LocaleCompare("passphrase",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("profile",option+1) == 0) { i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'q': { if (LocaleCompare("quality",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("quantize",option+1) == 0) { ssize_t colorspace; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); colorspace=ParseCommandOption(MagickColorspaceOptions, MagickFalse,argv[i]); if (colorspace < 0) ThrowCompareException(OptionError,"UnrecognizedColorspace", argv[i]); break; } if (LocaleCompare("quiet",option+1) == 0) break; ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'r': { if (LocaleCompare("regard-warnings",option+1) == 0) break; if (LocaleNCompare("respect-parentheses",option+1,17) == 0) { respect_parenthesis=(*option == '-') ? MagickTrue : MagickFalse; break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 's': { if (LocaleCompare("sampling-factor",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("seed",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("set",option+1) == 0) { i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("similarity-threshold",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); if (*option == '+') similarity_threshold=DefaultSimilarityThreshold; else similarity_threshold=StringToDouble(argv[i],(char **) NULL); break; } if (LocaleCompare("size",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); if (IsGeometry(argv[i]) == MagickFalse) ThrowCompareInvalidArgumentException(option,argv[i]); break; } if (LocaleCompare("subimage-search",option+1) == 0) { if (*option == '+') { subimage_search=MagickFalse; break; } subimage_search=MagickTrue; break; } if (LocaleCompare("synchronize",option+1) == 0) break; ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 't': { if (LocaleCompare("taint",option+1) == 0) break; if (LocaleCompare("transparent-color",option+1) == 0) { if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); break; } if (LocaleCompare("type",option+1) == 0) { ssize_t type; if (*option == '+') break; i++; if (i == (ssize_t) argc) ThrowCompareException(OptionError,"MissingArgument",option); type=ParseCommandOption(MagickTypeOptions,MagickFalse,argv[i]); if (type < 0) ThrowCompareException(OptionError,"UnrecognizedImageType", argv[i]); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case 'v': { if (LocaleCompare("verbose",option+1) == 0) break; if ((LocaleCompare("version",option+1) == 0) || (LocaleCompare("-version",option+1) == 0)) { ListMagickVersion(stdout); break; } if (LocaleCompare("virtual-pixel",option+1) == 0) { ssize_t method; if (*option == '+') break; i++; if (i == (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingArgument",option); method=ParseCommandOption(MagickVirtualPixelOptions,MagickFalse, argv[i]); if (method < 0) ThrowCompareException(OptionError, "UnrecognizedVirtualPixelMethod",argv[i]); break; } ThrowCompareException(OptionError,"UnrecognizedOption",option) } case '?': break; default: ThrowCompareException(OptionError,"UnrecognizedOption",option) } fire=(GetCommandOptionFlags(MagickCommandOptions,MagickFalse,option) & FireOptionFlag) == 0 ? MagickFalse : MagickTrue; if (fire != MagickFalse) FireImageStack(MagickTrue,MagickTrue,MagickTrue); } if (k != 0) ThrowCompareException(OptionError,"UnbalancedParenthesis",argv[i]); if (i-- != (ssize_t) (argc-1)) ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); if ((image == (Image *) NULL) || (GetImageListLength(image) < 2)) ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); FinalizeImageSettings(image_info,image,MagickTrue); if ((image == (Image *) NULL) || (GetImageListLength(image) < 2)) ThrowCompareException(OptionError,"MissingAnImageFilename",argv[i]); image=GetImageFromList(image,0); reconstruct_image=GetImageFromList(image,1); offset.x=0; offset.y=0; if (subimage_search != MagickFalse) { char artifact[MaxTextExtent]; (void) FormatLocaleString(artifact,MaxTextExtent,"%g", similarity_threshold); (void) SetImageArtifact(image,"compare:similarity-threshold",artifact); similarity_image=SimilarityMetricImage(image,reconstruct_image,metric, &offset,&similarity_metric,exception); if (similarity_metric > dissimilarity_threshold) ThrowCompareException(ImageError,"ImagesTooDissimilar",image->filename); } if ((reconstruct_image->columns == image->columns) && (reconstruct_image->rows == image->rows)) difference_image=CompareImageChannels(image,reconstruct_image,channels, metric,&distortion,exception); else if (similarity_image == (Image *) NULL) { unsigned long height, width; width=image->columns; if (reconstruct_image->columns > width) width=reconstruct_image->columns; height=image->rows; if (reconstruct_image->rows > height) height=reconstruct_image->rows; if ((SetImageExtent(image,width,height) != MagickFalse) && (SetImageExtent(reconstruct_image,width,height) != MagickFalse)) difference_image=CompareImageChannels(image,reconstruct_image, channels,metric,&distortion,exception); } else { Image *composite_image; /* Determine if reconstructed image is a subimage of the image. */ composite_image=CloneImage(image,0,0,MagickTrue,exception); if (composite_image == (Image *) NULL) difference_image=CompareImageChannels(image,reconstruct_image, channels,metric,&distortion,exception); else { Image *distort_image; RectangleInfo page; (void) CompositeImage(composite_image,CopyCompositeOp, reconstruct_image,offset.x,offset.y); difference_image=CompareImageChannels(image,composite_image, channels,metric,&distortion,exception); if (difference_image != (Image *) NULL) { difference_image->page.x=offset.x; difference_image->page.y=offset.y; } composite_image=DestroyImage(composite_image); page.width=reconstruct_image->columns; page.height=reconstruct_image->rows; page.x=offset.x; page.y=offset.y; distort_image=CropImage(image,&page,exception); if (distort_image != (Image *) NULL) { Image *sans_image; sans_image=CompareImageChannels(distort_image,reconstruct_image, channels,metric,&distortion,exception); distort_image=DestroyImage(distort_image); if (sans_image != (Image *) NULL) sans_image=DestroyImage(sans_image); } } if (difference_image != (Image *) NULL) { AppendImageToList(&difference_image,similarity_image); similarity_image=(Image *) NULL; } } if (difference_image == (Image *) NULL) status=0; else { if (image_info->verbose != MagickFalse) (void) IsImagesEqual(image,reconstruct_image); if (*difference_image->magick == '\0') (void) CopyMagickString(difference_image->magick,image->magick, MaxTextExtent); if (image_info->verbose == MagickFalse) { switch (metric) { case FuzzErrorMetric: case MeanAbsoluteErrorMetric: case MeanSquaredErrorMetric: case PeakAbsoluteErrorMetric: case RootMeanSquaredErrorMetric: { (void) FormatLocaleFile(stderr,"%g (%g)",QuantumRange*distortion, (double) distortion); if ((reconstruct_image->columns != image->columns) || (reconstruct_image->rows != image->rows)) (void) FormatLocaleFile(stderr," @ %.20g,%.20g",(double) difference_image->page.x,(double) difference_image->page.y); break; } case AbsoluteErrorMetric: case NormalizedCrossCorrelationErrorMetric: case PeakSignalToNoiseRatioMetric: case PerceptualHashErrorMetric: { (void) FormatLocaleFile(stderr,"%g",distortion); if ((reconstruct_image->columns != image->columns) || (reconstruct_image->rows != image->rows)) (void) FormatLocaleFile(stderr," @ %.20g,%.20g",(double) difference_image->page.x,(double) difference_image->page.y); break; } case MeanErrorPerPixelMetric: { (void) FormatLocaleFile(stderr,"%g (%g, %g)",distortion, image->error.normalized_mean_error, image->error.normalized_maximum_error); if ((reconstruct_image->columns != image->columns) || (reconstruct_image->rows != image->rows)) (void) FormatLocaleFile(stderr," @ %.20g,%.20g",(double) difference_image->page.x,(double) difference_image->page.y); break; } case UndefinedErrorMetric: break; } } else { double *channel_distortion; channel_distortion=GetImageChannelDistortions(image,reconstruct_image, metric,&image->exception); (void) FormatLocaleFile(stderr,"Image: %s\n",image->filename); if ((reconstruct_image->columns != image->columns) || (reconstruct_image->rows != image->rows)) (void) FormatLocaleFile(stderr,"Offset: %.20g,%.20g\n",(double) difference_image->page.x,(double) difference_image->page.y); (void) FormatLocaleFile(stderr," Channel distortion: %s\n", CommandOptionToMnemonic(MagickMetricOptions,(ssize_t) metric)); switch (metric) { case FuzzErrorMetric: case MeanAbsoluteErrorMetric: case MeanSquaredErrorMetric: case PeakAbsoluteErrorMetric: case RootMeanSquaredErrorMetric: { switch (image->colorspace) { case RGBColorspace: default: { (void) FormatLocaleFile(stderr," red: %g (%g)\n", QuantumRange*channel_distortion[RedChannel], channel_distortion[RedChannel]); (void) FormatLocaleFile(stderr," green: %g (%g)\n", QuantumRange*channel_distortion[GreenChannel], channel_distortion[GreenChannel]); (void) FormatLocaleFile(stderr," blue: %g (%g)\n", QuantumRange*channel_distortion[BlueChannel], channel_distortion[BlueChannel]); if (image->matte != MagickFalse) (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", QuantumRange*channel_distortion[OpacityChannel], channel_distortion[OpacityChannel]); break; } case CMYKColorspace: { (void) FormatLocaleFile(stderr," cyan: %g (%g)\n", QuantumRange*channel_distortion[CyanChannel], channel_distortion[CyanChannel]); (void) FormatLocaleFile(stderr," magenta: %g (%g)\n", QuantumRange*channel_distortion[MagentaChannel], channel_distortion[MagentaChannel]); (void) FormatLocaleFile(stderr," yellow: %g (%g)\n", QuantumRange*channel_distortion[YellowChannel], channel_distortion[YellowChannel]); (void) FormatLocaleFile(stderr," black: %g (%g)\n", QuantumRange*channel_distortion[BlackChannel], channel_distortion[BlackChannel]); if (image->matte != MagickFalse) (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", QuantumRange*channel_distortion[OpacityChannel], channel_distortion[OpacityChannel]); break; } case GRAYColorspace: { (void) FormatLocaleFile(stderr," gray: %g (%g)\n", QuantumRange*channel_distortion[GrayChannel], channel_distortion[GrayChannel]); if (image->matte != MagickFalse) (void) FormatLocaleFile(stderr," alpha: %g (%g)\n", QuantumRange*channel_distortion[OpacityChannel], channel_distortion[OpacityChannel]); break; } } (void) FormatLocaleFile(stderr," all: %g (%g)\n", QuantumRange*channel_distortion[CompositeChannels], channel_distortion[CompositeChannels]); break; } case AbsoluteErrorMetric: case NormalizedCrossCorrelationErrorMetric: case PeakSignalToNoiseRatioMetric: case PerceptualHashErrorMetric: { switch (image->colorspace) { case RGBColorspace: default: { (void) FormatLocaleFile(stderr," red: %g\n", channel_distortion[RedChannel]); (void) FormatLocaleFile(stderr," green: %g\n", channel_distortion[GreenChannel]); (void) FormatLocaleFile(stderr," blue: %g\n", channel_distortion[BlueChannel]); if (image->matte != MagickFalse) (void) FormatLocaleFile(stderr," alpha: %g\n", channel_distortion[OpacityChannel]); break; } case CMYKColorspace: { (void) FormatLocaleFile(stderr," cyan: %g\n", channel_distortion[CyanChannel]); (void) FormatLocaleFile(stderr," magenta: %g\n", channel_distortion[MagentaChannel]); (void) FormatLocaleFile(stderr," yellow: %g\n", channel_distortion[YellowChannel]); (void) FormatLocaleFile(stderr," black: %g\n", channel_distortion[BlackChannel]); if (image->matte != MagickFalse) (void) FormatLocaleFile(stderr," alpha: %g\n", channel_distortion[OpacityChannel]); break; } case GRAYColorspace: { (void) FormatLocaleFile(stderr," gray: %g\n", channel_distortion[GrayChannel]); if (image->matte != MagickFalse) (void) FormatLocaleFile(stderr," alpha: %g\n", channel_distortion[OpacityChannel]); break; } } (void) FormatLocaleFile(stderr," all: %g\n", channel_distortion[CompositeChannels]); break; } case MeanErrorPerPixelMetric: { (void) FormatLocaleFile(stderr," %g (%g, %g)\n", channel_distortion[CompositeChannels], image->error.normalized_mean_error, image->error.normalized_maximum_error); break; } case UndefinedErrorMetric: break; } channel_distortion=(double *) RelinquishMagickMemory( channel_distortion); } status&=WriteImages(image_info,difference_image,argv[argc-1],exception); if ((metadata != (char **) NULL) && (format != (char *) NULL)) { char *text; text=InterpretImageProperties(image_info,difference_image,format); if (text == (char *) NULL) ThrowCompareException(ResourceLimitError,"MemoryAllocationFailed", GetExceptionMessage(errno)); (void) ConcatenateString(&(*metadata),text); text=DestroyString(text); } difference_image=DestroyImageList(difference_image); } DestroyCompare(); image_info=restore_info; if ((metric == NormalizedCrossCorrelationErrorMetric) || (metric == UndefinedErrorMetric)) { if (fabs(distortion-1.0) > CompareEpsilon) (void) SetImageOption(image_info,"compare:dissimilar","true"); } else if (fabs(distortion) > CompareEpsilon) (void) SetImageOption(image_info,"compare:dissimilar","true"); return(status != 0 ? MagickTrue : MagickFalse); }
/* Method: Info[format, key] = value Purpose: Call SetImageOption Note: Essentially the same function as Info#define but paired with Info#[]= If the value is nil it is equivalent to #undefine. The 2 argument form is the original form. Added support for a single argument after ImageMagick started using Set/GetImageOption for options that aren't represented by fields in the ImageInfo structure. */ VALUE Info_aset(int argc, VALUE *argv, VALUE self) { Info *info; volatile VALUE value; char *format_p, *key_p, *value_p = NULL; long format_l, key_l; char ckey[MaxTextExtent]; unsigned int okay; Data_Get_Struct(self, Info, info); switch (argc) { case 3: format_p = rm_str2cstr(argv[0], &format_l); key_p = rm_str2cstr(argv[1], &key_l); if (format_l > MAX_FORMAT_LEN || format_l+key_l > MaxTextExtent-1) { rb_raise(rb_eArgError, "%.60s:%.1024s not defined - too long", format_p, key_p); } (void) sprintf(ckey, "%.60s:%.*s", format_p, (int)(sizeof(ckey)-MAX_FORMAT_LEN), key_p); value = argv[2]; break; case 2: strncpy(ckey, StringValuePtr(argv[0]), sizeof(ckey)-1); ckey[sizeof(ckey)-1] = '\0'; value = argv[1]; break; default: rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc); break; } if (NIL_P(value)) { (void) RemoveImageOption(info, ckey); } else { /* Allow any argument that supports to_s */ value = rm_to_s(value); value_p = StringValuePtr(value); (void) RemoveImageOption(info, ckey); okay = SetImageOption(info, ckey, value_p); if (!okay) { rb_warn("`%s' not defined - SetImageOption failed.", ckey); return Qnil; } } return self; }
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 }