Beispiel #1
0
        public static void ImageSave(this BaseEntity entity, string sourceImagePath, Size size, string name, bool crop = true)
        {
            HttpContextBase context = new HttpContextWrapper(HttpContext.Current);
            var             destinationImagePath     = entity.GetImagePath(name);
            var             destinationImageRealPath = context.Server.MapPath(destinationImagePath);

            sourceImagePath = (sourceImagePath.StartsWith("/") || sourceImagePath.StartsWith("~")) ? sourceImagePath : ("/" + sourceImagePath);
            sourceImagePath = sourceImagePath.StartsWith("~") ? sourceImagePath : ("~" + sourceImagePath);
            var sourceImageRealPath = context.Server.MapPath(sourceImagePath);
            var sourceImage         = new WebImage(sourceImageRealPath);

            sourceImage.ImageResize(size, crop).Save(destinationImageRealPath, forceCorrectExtension: false);
        }
Beispiel #2
0
 public static WebImage ImageResize(this WebImage webImage, ImageSavingInfo imageSavingInfo)
 {
     return(webImage.ImageResize(new Size(imageSavingInfo.MaxWidth, imageSavingInfo.MaxHeight),
                                 imageSavingInfo.Crop));
 }