/// <summary> /// 生成缩略图保持原来的比例 /// </summary> /// <param name="fileData"></param> /// <param name="fileFolder"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="prefix"></param> /// <returns></returns> /// <summary> /// 生成缩略图保持原来的比例 /// </summary> /// <param name="fileData"></param> /// <param name="fileFolder"></param> /// <param name="width"></param> /// <param name="height"></param> /// <param name="prefix"></param> /// <returns></returns> public FileEntity UploadImageThumbnail2 (HttpPostedFile fileData, string fileFolder, string filePhysicalPath, int width, int height, string prefix = "") { ThumnailMode mode = ThumnailMode.HW; string fileType = "jpg"; FileEntity file = new FileEntity(); if (fileData != null) { try { string filePath = filePhysicalPath + "/"; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } file.DisplayName = Path.GetFileName(fileData.FileName); file.Extension = Path.GetExtension(file.DisplayName); file.Size = fileData.ContentLength; file.ContentType = fileData.ContentType; file.CreateTime = DateTime.Now; file.DbName = GetFileDBName(file.Extension); file.FilePath = "/" + fileFolder + "/" + file.DbName; Image image = Image.FromStream(fileData.InputStream); mode = ThumnailMode.Cut; ThumbnailHelper.Create(image, filePath + file.DbName, width, height, mode, fileType); return(file); } catch (Exception ex) { WebLogAgent.Write(ex); return(null); } } else { return(null); } }