Archive for September, 2012

How to fix picture’s Date Taken

Ever downloaded your vacation pictures from your digital camera, just to discover that the Date Taken tag is wrong? There is a solution for that! You just need python, shell script and probably Linux skills, and ten minutes to spare.

The following lines will do the magic for you:

import pyexiv2
from datetime import timedelta
import sys

metadata = pyexiv2.ImageMetadata(sys.argv[1])
metadata.read()
tag = metadata['Exif.Image.DateTime']
if tag.value.year == 2011:
   tag.value += timedelta(days=366)
   metadata.write()

To keep things simple, I just assumed that you will run this script with the jpeg image as a parameter, and the pictures appear to be taken last year (happened to me).

To fix all the pictures in a folder, simply run this oneline:

for i in *.JPG; do python fix.py $i; done

There you go!

Later Edit: you would probably also want to change Exif.Photo.DateTimeOriginal and Exif.Photo.DateTimeDigitized tags.