aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-11-17 08:35:01 +0100
committerOlivier Tilloy <olivier@tilloy.net>2009-11-17 08:35:01 +0100
commitf8d8d3b515f58f85c98cf5853eb8b5d47c47e6dc (patch)
tree2ed26336d71fb0af67a8e35686ff2a1538e002a7 /src
parent6abe0099c18fdded48a5acac01a31bb7d08b4f7b (diff)
downloadpyexiv2-f8d8d3b515f58f85c98cf5853eb8b5d47c47e6dc.tar.gz
Added an example script that manipulates EXIF metadata in an image.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/examples.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/examples.py b/src/examples.py
new file mode 100755
index 0000000..9984c75
--- /dev/null
+++ b/src/examples.py
@@ -0,0 +1,30 @@
+#!//usr/bin/python
+# -*- coding: utf-8 -*-
+
+from pyexiv2 import ImageMetadata, ExifTag
+
+import sys
+from datetime import datetime
+
+
+if __name__ == '__main__':
+ # Read an image file's metadata
+ image_file = sys.argv[1]
+ metadata = ImageMetadata(image_file)
+ metadata.read()
+
+ # Print a list of all the keys of the EXIF tags in the image
+ print metadata.exif_keys
+
+ # Print the value of the Exif.Image.DateTime tag
+ print metadata['Exif.Image.DateTime']
+
+ # Set the value of the Exif.Image.DateTime tag
+ metadata['Exif.Image.DateTime'].value = datetime.now()
+
+ # Add a new tag
+ metadata['Exif.Image.Orientation'] = ExifTag('Exif.Image.Orientation', 1)
+
+ # Write back the metadata to the file
+ metadata.write()
+