/// <summary> /// 加载所有规格列表 /// </summary> /// <returns></returns> List <ThumbnailConfig> GetAllThumbnailConfigs() { List <ThumbnailConfig> thumbnailConfigList = Context.Cache["$THUMBNAILCONFIGLIST"] as List <ThumbnailConfig>; if (thumbnailConfigList == null) { if (File.Exists(Server.MapPath("/Config/thumbnail.xml"))) { thumbnailConfigList = new List <ThumbnailConfig>(); XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("/Config/thumbnail.xml")); XmlNodeList ItemListNodes = doc.SelectNodes("/configuration/item"); foreach (XmlNode oldNode in ItemListNodes) { ThumbnailConfig tc = new ThumbnailConfig(); tc.Name = oldNode.Attributes["name"].Value; string[] v = tc.Name.Split(new string[] { ":", ":" }, StringSplitOptions.RemoveEmptyEntries); if (v.Length > 1) { tc.Value = v[1]; } tc.Tag = oldNode.Attributes["value"].Value; thumbnailConfigList.Add(tc); } HelperFactory.Instance.GetHelper <ChannelHelper>().CacherCache("$THUMBNAILCONFIGLIST", Context, thumbnailConfigList, CacheTime.Short); } } return(thumbnailConfigList); }
public AppDataViewComponent( AppConfiguration appConfig, ThumbnailConfig thumbnailConfig ) { this.appConfig = appConfig; this.thumbnailConfig = thumbnailConfig; }
public RegisterSellerViewComponent( AppConfiguration appConfig, ThumbnailConfig thumbnailConfig ) { this.appConfig = appConfig; this.thumbnailConfig = thumbnailConfig; }
public StashController( DefaultContext dbContext, ThumbnailConfig thumbnailConfig ) { this.dbContext = dbContext; this.thumbnailConfig = thumbnailConfig; }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RouteConfig.RegisterRoutes(RouteTable.Routes); ThumbnailConfig.Start().Include("/Images", setting => setting.AllSize().Store() ); }
public PhotosController( DefaultContext dbContext, ICurrentUserProvider currentUserProvider, ThumbnailConfig thumbnailConfig, AppConfiguration appConfiguration ) { this.dbContext = dbContext; this.currentUserProvider = currentUserProvider; this.thumbnailConfig = thumbnailConfig; this.imagesConfiguration = appConfiguration.ImagesConfiguration; }
public void GetSize(out int width, out int height) { width = height = 0; ThumbnailConfig cfg = GetThumbnailCfg(); if (cfg != null) { string size = cfg.Value; string[] ss = size.Split('*'); Int32.TryParse(ss[0], out width); Int32.TryParse(ss[1], out height); } }
/// <summary> /// 根据标签tag,获取缩略图对应规格 /// </summary> /// <param name="list"></param> /// <param name="IdentityChar"></param> /// <returns></returns> ThumbnailConfig SearchThumbnailConfig(List <ThumbnailConfig> list, string IdentityChar) { ThumbnailConfig tc = new ThumbnailConfig(); if (list != null && list.Count > 0) { foreach (ThumbnailConfig thumbnailConfig in list) { if (thumbnailConfig.Tag == IdentityChar) { tc = thumbnailConfig; return(tc); } } } return(null); }
/// <summary> /// 加载缩略图列表 /// </summary> void LoadImages() { if (ArticleID != null) { Article a = ArticleHelper.GetArticle(ArticleID); List <ImageDetail> imageList = new List <ImageDetail>(); string folderPath = ExistFilePath(); if (!Directory.Exists(folderPath)) { return; } else { List <ThumbnailConfig> configList = GetAllThumbnailConfigs(); System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(folderPath); //string[] fields = new string[] { "ChannelFolder" }; //Channel ch = ChannelHelper.GetChannel(OwnerID, fields); //string aid = Helper.GUIDToFormatString(ArticleID); StringBuilder sb = new StringBuilder(); foreach (System.IO.FileInfo fi in dir.GetFiles()) { if (Server.MapPath(a.Thumbnail) == fi.FullName) { continue; } ImageDetail image = new ImageDetail(); image.ImagePath = string.Format("/{0}/thumbnail/{1}", !String.IsNullOrEmpty(a.AttachmentUrlPath)?a.AttachmentUrlPath.Trim('/'):"", fi.Name); image.ImagePath = image.ImagePath.Replace("\\", "/"); string idChar = fi.Name.Substring(fi.Name.LastIndexOf("_") + 1, fi.Name.LastIndexOf(".") - fi.Name.LastIndexOf("_") - 1); ThumbnailConfig config = SearchThumbnailConfig(configList, idChar); image.FileName = fi.Name; if (config != null) { image.Name = config.Name; image.Tag = config.Tag; imageList.Add(image); } } } ImagesRepeater.DataSource = imageList; ImagesRepeater.DataBind(); } }
public static void Run() { /* Create BitcodinApi */ const string apiKey = "YOUR_API_KEY"; var bitApi = new BitcodinApi(apiKey); var thumbnailConfig = new ThumbnailConfig { //insert your jobID JobId = 312840, Height = 320, Position = 5, Async = true, FileName = "filename" }; var thumbnail = bitApi.CreateThumbnail(thumbnailConfig); Debug.WriteLine("Thumbnail URL: " + thumbnail.ThumbnailUrl); }
/// <summary> /// 上传文件 /// </summary> /// <returns></returns> void UploadFile() { string fileName = fuImage.FileName; string ext = Path.GetExtension(fileName); string folder = GetFileFolder(); string newFileName = CreateFileName(); OrignPath = folder.TrimEnd('/') + "/" + newFileName + ext; string physicalpath = Server.MapPath(folder); if (!Directory.Exists(physicalpath)) { Directory.CreateDirectory(physicalpath); } string physicalfilepath = Server.MapPath(OrignPath); fuImage.SaveAs(physicalfilepath); ThumbPath = folder.TrimEnd('/') + "/" + newFileName + "_thumb" + ext; string physicaltargetpath = Server.MapPath(ThumbPath); CreateTumbnail(physicalfilepath, physicaltargetpath); imgThumb.ImageUrl = ThumbPath; info.Add(new ImageItem() { Size = "", Type = "", Src = OrignPath }); ThumbnailConfig cfg = GetThumbnailCfg(); if (cfg != null) { info.Add(new ImageItem() { Size = cfg.Value, Type = cfg.Tag, Src = ThumbPath, Desc = cfg.Name }); } ImageValue.Value = info.ToJson(); }
public ThumbnailsController(IOptions <ThumbnailConfig> thumbnailConfig) { _thumbnailConfig = thumbnailConfig.Value; }
public Thumbnail.Thumbnail CreateThumbnail(ThumbnailConfig config) { return(Post <Thumbnail.Thumbnail>("thumbnail", config)); }