Search code examples
c#.netimageresizeexif

Resize an image with .NET without losing EXIF data


What is the best way to resize images using .NET, without losing the EXIF data? I'm okay with using .NET 2 System.Drawing.* classes, WPF classes, or open-source libraries.

The only easy way I found to handle this all for now is to use the Graphics.FromImage (.NET 2) to perform the resizing and to re-write the EXIF data with an OpenSource library manually (each piece of data one by one).


Solution

  • Your suggestion of extracting the EXIF data before resizing, and then re-inserting the EXIF data seems like a decent solution.

    EXIF data can be defined only for formats like JPEG and TIFF - when you load such an image into a Graphics object for resizing, you're essentially converting the image to a regular bitmap. Hence, you lose the EXIF data.

    Slightly related thread about EXIF extraction using C# here.