Get EXIF date from photo

It’s not straightforward to retrieve the EXIF date from an image. Here’s a method to retrieve it using the MetadataExtractor package. It looks for the appropriate date, and if not found, falls back to the file properties. // <package id=”MetadataExtractor” version=”2.0.0″ targetFramework=”net40″ /> static DateTime GetImageDate(string file) { var directories = ImageMetadataReader.ReadMetadata(file); ExifSubIfdDirectory subIfdDirectory = […]

Add EXIF date to photo

If you have a photo that you need to add a timestamp to the EXIF information, you can use the following .NET code. Apparently there are a ridiculous number of formats and standards which are incompatible with each other and conflicting, but from what I’ve found, this should cover regular use cases. I’m sure there’s […]

Resize image in .NET

This will resize image to be 1024 height or width (whichever is bigger). Explore other options to look for things like image quality. using (var image = Image.FromFile(file.FullName)){ int newHeight, newWidth; if (image.Height > image.Width) { newHeight = 1024; newWidth = (int)(1024.0 * image.Width / image.Height); } else { newWidth = 1024; newHeight = (int)(1024.0 […]

Check if two images are similar

I was trying to dedupe my photos, and found that identical photos didn’t have identical file contents, because of the way they were stored in Google Photos, or iCloud, or Amazon Photos, or wherever else I had them stored. So this method will look at two photos, see if they have the same dimensions, then […]