Embedding Picasa Rotation info to Image Exif Headers
I have a camera without an orientation sensor. So I have used to manually fixing the photos using Picasa. Picasa does not modify the original photos, but save the rotation info (and other modifications) into a hidden file “.picasa.ini” in the same folder. If you move this file together with your album, and use Picasa Viewer to view photos, everything works fine..
But this image rotation problem is already solved with Exif. Exif contains an orientation property, which can be used to correctly display the photos on a digital viewer. New cameras, and viewers support the use of this property. So I thought it would be better if I can embed the Picasa rotation information into the Exif headers of photos.
After trying several tools, (even one of them doubling the size of the original photo, while modifying the Exif property ??!) I have settled on using Exiv2.
Then I coded the following simple, short Python script to embed Picasa rotation information to photos:
# Embed Picasa rotation information to EXIF Image Orientation tag.
# Uses Exiv2 command line utility from http://www.exiv2.org/.
#
# Serkan Kenar, 2010, Ankara.
import subprocess
lines = open(".picasa.ini")
filename = None
rot2ori = { 0: 1,
1: 6, # left
2: 3, # bottom
3: 8 } # right
for line in lines:
if line[0] == '[':
filename = line.strip("[]\n")
continue
(action,param) = line.split("=")
if action == "rotate":
yon = int(param[7:8])
try:
subprocess.call(['exiv2',
'-k', # preserve timestamps
'-v',
'-Mset Exif.Image.Orientation %d' % rot2ori[yon],
filename])
except OSError:
print "Exiv2 is not found on the path!"
exit
You should run this script in photos folder with a “.picasa.ini” file. Make sure that exiv2 command-line utility is in your path.
Bu kategori altındaki diğer yazılar: Fotoğraf, Yazılım