4

I want to save an image in EXIF format using System.Drawing.Image.Save or a similar method in a C# application using .NET framework v3.5. The MSDN documentation lists EXIF as an option for ImageFormat. However, it does not seem to be supported - at least not without some configuration unknown to me. When I enumerate the built-in encoders via ImageCodecInfo.GetImageEncoders() EXIF is not included. (Built in encoders on my machine (Vista Ultimate x64) are: BMP, JPEG, GIF, TIFF, and PNG.) If I save an image using the ImageFormat.Exif property, I simply get the default PNG format.

How can I save an image in EXIF format using .NET 3.5?

random
  • 9,774
  • 10
  • 66
  • 83
TMarshall
  • 825
  • 6
  • 15

2 Answers2

4

EXIF isn't a image file format per se, but a format for meta-data found within JPEG images conforming to the DSC (Digital Still Camera) standard as specified by JEITA.

GDI+ (i.e. Microsoft .NET Framework) allows you to read/write metadata image properties via the Image.PropertyItems, however the EXIF properties exposed by GDI+ are pretty cumbersome and don't convert the values the way you would expect. A lot of work is actually needed to be able to natively read/write these values (e.g. you'd need to unpack binary fields containing specially encoded values according to the JEITA spec).

A straight-forward open-source library which implements all the standard EXIF properties can be found at http://code.google.com/p/exif-utils/ This is probably the easiest way to do this. See the simple included demo which reads in a file, prints out all the EXIF properties and then adds a property to the image.

mckamey
  • 17,359
  • 16
  • 83
  • 116
0

Have you seen this: Lossless JPEG Rewrites in C#

Igor Brejc
  • 18,714
  • 13
  • 76
  • 95
  • Thanks, that's an interesting article. It applies to JFIF files, but not EXIF. Still, it's a clever approach. – TMarshall Apr 04 '09 at 19:39