Often, we need to change the metadatas of our photos. The most common reason is that the clock of our camera was not set correctly. Another common problem is that the cheaper cameras don't recognize the rotation.
We have three command line tools in Debian Linux to modify the exif tags. The exiftran command in exiftran package is ideal for rotating images, the exiftime command in exiftags package can be used to changing the time and date informations, and the exiftool command in libimage-exiftool-perl package can modify all exif tags.
The exiftran is the perfect tool for rotating pictures. It can do loseless rotations. It changes the orientation tag and dimensions. It keeps the irrelevant exif tags untouched. It also rotates the exif thumbnail. It can keep the timestamp of the files.
exiftran -i -p -9 image*.jpg # Rotating clockwise exiftran -i -p -2 pic*.jpg # Rotating reverse clockwise
Modify date and time
The advantage for the exiftime is to rewrite all three date tags together (Created, Generated, Digitalized).
The following command adds 5 days 3 hours and 18 minutes for each of our images:
exiftime -q -fw -v+5d -v+3H -v+18M *.jpg
Unfortunately, the exiftime command modify the creation time of files, so we need to restore it.
for i in *JPG; do touch -t $(exiftime $i| head -1|sed "s/.*: //;s/[: ]//g;s/\(..\)$/.\1/") $i done