public static Image ResizeImageFile(FileInfo fi, int max_width = 128, int max_height = 128) { var rotationDegree = EXIF_Methods.ComputeRotateFlipType(fi.FullName); Image image_blob = Image.FromFile(fi.FullName); Image resized = ImagerLib.Imager.ImageResize(image_blob, max_width, max_height, true, rotationDegree); return(resized); }
/// <summary> /// Rotate the modified picture based on the orientation property of the original picture /// </summary> /// <param name="inputPath">Original picture path</param> /// <param name="outputPath">Modified picture path</param> public static void RotationWhenTransformationIsRequired(string inputPath, string outputPath) { var rotationDegree = EXIF_Methods.ComputeRotateFlipType(inputPath); if (rotationDegree.HasValue && rotationDegree.Value != RotateFlipType.RotateNoneFlipNone) { var bitmap = (Bitmap)Bitmap.FromFile(outputPath); bitmap.RotateFlip(rotationDegree.Value); using (var stream = new FileStream(outputPath, FileMode.Create, FileAccess.Write)) { bitmap.Save(stream, ImageFormat.Jpeg); } } }