// 保存图片大小等信息 private void updatePhotoSize(PhotoPost post) { String photoPath = post.DataUrl; Dictionary <String, PhotoInfo> dic = new Dictionary <String, PhotoInfo>(); foreach (KeyValuePair <String, ThumbInfo> kv in ThumbConfig.GetPhotoConfig()) { String xpath = Img.GetThumbPath(strUtil.Join(sys.Path.DiskPhoto, photoPath), kv.Key); String thumbPath = PathHelper.Map(xpath); if (file.Exists(thumbPath) == false) { continue; } Size size = Img.GetPhotoSize(thumbPath); dic.Add(kv.Key, new PhotoInfo { Width = size.Width, Height = size.Height }); } String str = ObjectContext.Create <PhotoInfoHelper>().ConvertString(dic); if (strUtil.IsNullOrEmpty(str)) { return; } post.SizeInfo = str; post.update(); log("重新统计成功=" + post.Id + ",path=" + photoPath); }
// 保存图片大小等信息 private void updatePhotoSize(PhotoPost post) { String photoPath = post.DataUrl; if (strUtil.IsNullOrEmpty(photoPath)) { return; } if (photoPath.ToLower().StartsWith("http://")) { return; } if (photoPath.StartsWith("/")) { return; } Dictionary <String, PhotoInfo> dic = new Dictionary <String, PhotoInfo>(); foreach (KeyValuePair <String, ThumbInfo> kv in ThumbConfig.GetPhotoConfig()) { String xpath = Img.GetThumbPath(strUtil.Join(sys.Path.DiskPhoto, photoPath), kv.Key); String thumbPath = PathHelper.Map(xpath); Size size = Img.GetPhotoSize(thumbPath); dic.Add(kv.Key, new PhotoInfo { Width = size.Width, Height = size.Height }); } String str = ObjectContext.Create <PhotoInfoHelper>().ConvertString(dic); if (strUtil.IsNullOrEmpty(str)) { return; } post.SizeInfo = str; post.update(); }
private void makeThumbPrivate(String photoPath) { // 循环生成所有缩略图 foreach (KeyValuePair <String, ThumbInfo> kv in ThumbConfig.GetPhotoConfig()) { String srcPath = getPhotoSrcPath(photoPath); if (file.Exists(srcPath) == false) { logError("pic original not exist=" + srcPath); continue; } log("begin make " + kv.Key + "=>" + srcPath); try { Uploader.SaveThumbSingle(srcPath, kv.Key, kv.Value); } catch (Exception ex) { logError("error=>" + ex.Message); } } }
/// <summary> /// 保存上传的图片 /// </summary> /// <param name="postedFile"></param> /// <returns></returns> public static Result SaveImg(HttpFile postedFile) { return(SaveImg(postedFile, ThumbConfig.GetPhotoConfig())); }