Skip to content

Instantly share code, notes, and snippets.

@bleroy
Last active January 21, 2017 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bleroy/6bc5dd2b33351eaaa2a4712d6df6be78 to your computer and use it in GitHub Desktop.
Save bleroy/6bc5dd2b33351eaaa2a4712d6df6be78 to your computer and use it in GitHub Desktop.
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