Click here to Skip to main content
15,898,134 members
Articles / Programming Languages / C#
Article

EXIF tag Editor for JPG images

Rate me:
Please Sign up or sign in to vote.
4.64/5 (16 votes)
18 Sep 20062 min read 149.3K   7.9K   108   9
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:

C#
.
.
.
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#.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Spain Spain
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Question15 years old - still valid - thanks a lot Pin
Jaxa31312-Oct-21 14:25
Jaxa31312-Oct-21 14:25 
Questionimage.Save(String filename) makes PNG files. Pin
Nyerguds8-Feb-18 21:19
Nyerguds8-Feb-18 21:19 
AnswerRe: image.Save(String filename) makes PNG files. Pin
Croow23-Apr-18 7:41
Croow23-Apr-18 7:41 
QuestionAwesome! Pin
toxicious16-Mar-12 13:20
toxicious16-Mar-12 13:20 
BugIf EXIF tag does noe exist, there is an error, could you help with this Pin
per7811-Dec-11 4:56
per7811-Dec-11 4:56 
GeneralRe: If EXIF tag does noe exist, there is an error, could you help with this Pin
jsanjosem12-Dec-11 0:34
jsanjosem12-Dec-11 0:34 
Sorry, I have no clue about this.
GeneralRe: If EXIF tag does noe exist, there is an error, could you help with this Pin
AlterDiaz23-Sep-12 20:06
AlterDiaz23-Sep-12 20:06 
GeneralThanks! You saved my Day! Pin
h3214-Sep-09 6:50
h3214-Sep-09 6:50 
GeneralLatin Character not work Pin
waimoehtun25-Jan-07 2:07
waimoehtun25-Jan-07 2:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.