Last active
January 21, 2017 01:03
-
-
Save bleroy/6bc5dd2b33351eaaa2a4712d6df6be78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using FreeImageAPI; | |
const int size = 150; | |
using (var original = FreeImageBitmap.FromFile(path)) | |
{ | |
int width, height; | |
if (original.Width > original.Height) | |
{ | |
width = size; | |
height = original.Height * size / original.Width; | |
} | |
else | |
{ | |
width = original.Width * size / original.Height; | |
height = size; | |
} | |
var resized = new FreeImageBitmap(original, width, height); | |
// JPEG_QUALITYGOOD is 75 JPEG. | |
// JPEG_BASELINE strips metadata (EXIF, etc.) | |
resized.Save(OutputPath(path, outputDirectory, FreeImage), FREE_IMAGE_FORMAT.FIF_JPEG, | |
FREE_IMAGE_SAVE_FLAGS.JPEG_QUALITYGOOD | | |
FREE_IMAGE_SAVE_FLAGS.JPEG_BASELINE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment