65.9K
CodeProject is changing. Read more.
Home

EXIF tag Editor for JPG images

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.64/5 (13 votes)

Sep 18, 2006

2 min read

viewsIcon

150630

downloadIcon

7944

JPG images EXIF tag Editor

Click to enlarge ...

Introduction

First of all, I must say that there are very good articles (here on codeProject) dealing with EXIF tag reading:

and some others explaining EXIF tag writing:

But as it happens most of the time, I needed a small app that would allow me to update a specific EXIF tag, and I wanted it done in C# (for learning purposes). After reading the previous articles and some other references carefully, I decided to go ahead and write a binary to solve my problems.

So, what we have here is a utility that updates EXIF tag '0x9003' (Tag DateTimeOriginal) and EXIF tag '0x9004' (Tag DateTimeDigitized). Other EXIF tags could be updated using the same technique:

.
.
.
Encoding _Encoding = Encoding.UTF8;
Image theImage = new Bitmap(m_currImageFileTemp);
PropertyItem propItem36867 = theImage.GetPropertyItem(36867);

propItem36867.Value = _Encoding.GetBytes(m_textPropertyValue.Text + '\0');
theImage.SetPropertyItem(propItem36867);
theImage.Save(m_currImageFile);
.
.
.

Where Encoding, Image, Bitmap and PropertyItem are .NET 2.0 classes.

You can find information about EXIF standard here.

I hope you find the code useful.

Using the utility

As you can see in the image enclosed, the utility reads the date to update from a free input. The format for that string MUST be 'YYYY:MM:DD hh:mm:ss', in any other case the program won't be able to update the EXIF tags safely.

I am enclosing a picture with EXIF tags for testing purposes: you will find it in the root folder of the zip file.

The code was compiled using Microsoft Visual Studio 2005, I can't tell if it will compile with previous versions. To execute it you will need the .NET framework 2.0.

About Jose Javier Sanjosé

Software architect, system administrator, web designer. I have been using C++ for the last 16 years, mainly until .NET come around (even though I try not to follow Microsoft's trends too close anymore).

Nowadays I am very focused in XML, XSLT, JavaScript, Java, ASP.NET, PHP, and well, yes, C#.