views:

378

answers:

1

Hello,

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).

+2  A: 

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.

Charlie Salts
Okay I kept my solution then, it's working quite well, it's just a lot of code for nothing but it's fast enough :)
TigrouMeow
The only other alternative I know of is ImageMagick - I understand you can do transformations without losing EXIF data but that library is essentially doing the same thing you're already doing, just likely faster.
Charlie Salts